contractplan

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package contractplan owns portable immutable compilation snapshots. It has no catalog, Git, environment, credential, or execution capability.

Index

Constants

View Source
const (
	FormatVersion      = 4
	CompilerID         = "braidplane/contract-plan/v4"
	StructuralPolicyID = "braidplane/structural-policy/v1"
)

Variables

View Source
var ErrInvalid = xerror.New(xerror.KindInvalidInput, "COMPILED_PLAN_INVALID", "compiled contract plan is incomplete, corrupt, or unsupported")

Functions

func ApplyOperationDefaults

func ApplyOperationDefaults(p *pipelinespec.Pipeline, operations []Operation) error

ApplyOperationDefaults preserves both origins. Defaults affect only omitted directions; an explicit step declaration remains an independent obligation.

func CapturePipelinePins

func CapturePipelinePins(pipeline *pipelinespec.Pipeline, projection *odcs.ProjectionPlan, lookup func(*pipelinespec.ODCSContractRef) (*model.ODCSRevision, error)) ([]model.PinnedODCSPort, error)

CapturePipelinePins resolves every authored port through an authorized catalog lookup. Selected structures never pass through the flat ODCS converter.

func CapturePort

func CapturePort(ref *pipelinespec.ODCSContractRef, revision *model.ODCSRevision, projection *odcs.ProjectionPlan) (model.PinnedODCSPort, error)

func Compile

func Compile(input Input) ([]byte, string, error)

Compile freezes every input before computing identity. Authored identity is deliberately independent of saved-operation, projection and compiler changes.

func OperationContracts

func OperationContracts(op Operation) (input, output *payload.Contract, err error)

OperationContracts uses only the captured declarations and their exact pins. The step's promise/requirement is deliberately not part of this result.

func SelectStructuralProjection

func SelectStructuralProjection(plan *odcs.ProjectionPlan, ref *pipelinespec.ODCSContractRef, contract *payload.Contract) (*payload.Structure, string, error)

SelectStructuralProjection identifies one exact executable check shape when a contract object is reused through several mappings.

func Specialize

func Specialize(raw []byte, id string, values map[string]odcs.ResolutionValue) ([]byte, string, error)

Specialize resolves only declared non-secret projection parameters from the stored template. It never reads catalog revisions or mutable operations.

Types

type Input

type Input struct {
	Source     Source
	Authored   json.RawMessage
	Operations []Operation
	Pins       []model.PinnedODCSPort
	Projection *odcs.ProjectionRequest
}

Input contains only already-authorized, environment-independent material. Rich selections retain structural checks independently of catalog access.

type Operation

type Operation struct {
	DataSourceType model.DataSourceType `json:"data_source_type,omitempty"`
	Step           slug.Slug            `json:"step"`
	Role           string               `json:"role"`
	DataSource     slug.Slug            `json:"data_source"`
	Slug           slug.Slug            `json:"slug"`
	Revision       string               `json:"revision"`
	Content        json.RawMessage      `json:"content"`
	Digest         string               `json:"digest"`
}

Operation retains the complete saved definition, including parameter defaults and input requirements. Revision is the authoring revision, never a live alias.

type OperationContent

type OperationContent struct {
	ResourceScope            *resourcescope.Scope          `json:"resource_scope,omitempty"`
	Data                     json.RawMessage               `json:"data"`
	ExpectedInputContract    json.RawMessage               `json:"expected_input_contract,omitempty"`
	ExpectedInputContractRef *pipelinespec.ODCSContractRef `json:"expected_input_contract_ref,omitempty"`
	OutputContract           json.RawMessage               `json:"output_contract,omitempty"`
	OutputContractRef        *pipelinespec.ODCSContractRef `json:"output_contract_ref,omitempty"`
	ContractPins             []model.PinnedODCSPort        `json:"contract_pins,omitempty"`
	Parameters               []OperationParameter          `json:"parameters"`
}

type OperationParameter

type OperationParameter struct {
	Slug     slug.Slug `json:"slug"`
	Name     string    `json:"name"`
	DataType string    `json:"data_type"`
	Required bool      `json:"required"`
	Default  *string   `json:"default,omitempty"`
}

type Plan

type Plan struct {
	Source             Source                  `json:"source"`
	FormatVersion      int                     `json:"format_version"`
	CompilerID         string                  `json:"compiler_id"`
	StructuralPolicyID string                  `json:"structural_policy_id"`
	Authored           json.RawMessage         `json:"authored"`
	AuthoredSpecHash   string                  `json:"authored_spec_hash"`
	Operations         []Operation             `json:"operations"`
	Pins               []model.PinnedODCSPort  `json:"pins"`
	Projection         *odcs.ProjectionPlan    `json:"projection,omitempty"`
	ProjectionDigest   string                  `json:"projection_digest,omitempty"`
	ProjectionInputs   *odcs.ProjectionRequest `json:"projection_inputs,omitempty"`
}

func Read

func Read(raw []byte, expectedDigest string) (*Plan, error)

Read uses only stored material. In particular, it never reruns the compiler, so a future compiler cannot reinterpret a stored snapshot.

func (*Plan) RuntimePipeline

func (p *Plan) RuntimePipeline() (*pipelinespec.Pipeline, error)

RuntimePipeline reconstructs executable declarations from stored material only.

func (*Plan) ValidateProjectionBindings

func (p *Plan) ValidateProjectionBindings() error

ValidateProjectionBindings rejects new public compilations whose selected projections cannot supply the exact port checks. Historical readers stay unchanged.

type Source

type Source struct {
	Commit string `json:"commit"`
	Path   string `json:"path"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL