ir

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package ir defines Pasture's portable, harness-neutral document and orchestration intermediate representation.

Index

Constants

View Source
const (
	RequestUserDecisionSchema  = "pasture.request-user-decision/v1"
	ReportedUserDecisionSchema = "pasture.reported-user-decision/v1"
)
View Source
const (
	HarnessClaudeCode = artifact.HarnessClaudeCode
	HarnessOpenCode   = artifact.HarnessOpenCode
	HarnessCodex      = artifact.HarnessCodex
)

Variables

This section is empty.

Functions

func AssignmentAuthority

func AssignmentAuthority(authority MutationAuthority) (portable.AssignmentRef, bool)

AssignmentAuthority returns the initiating assignment when that is the retained authority.

func BootstrapAuthority

func BootstrapAuthority(authority MutationAuthority) (portable.AgentRef, bool)

BootstrapAuthority returns the initiating bootstrap agent when applicable.

func CanonicalSemanticOperation

func CanonicalSemanticOperation(operation SemanticOperation) ([]byte, error)

CanonicalSemanticOperation returns a defensive copy of the neutral operation codec for validators, goldens, and semantic-instruction lowerings.

func DeterministicMutationRefFactory

func DeterministicMutationRefFactory(seed string) (portable.MutationRef, error)

DeterministicMutationRefFactory is the default MutationRefFactory: the minted ref's value is exactly seed, so by portable.MutationRef's own value-equality semantics, equal seeds always mint an equal ref (continuity across retries and fresh-agent reconstruction) and distinct seeds mint distinct refs (distinct minting), with no additional strategy needed.

func IsDuplicateJSONMember

func IsDuplicateJSONMember(err error) bool

IsDuplicateJSONMember reports whether err (or something it wraps) is a genuine duplicate-member failure from rejectDuplicateJSONMembers, as opposed to empty/truncated/malformed input. Exported alongside StrictJSONWithPresence so a caller outside this package can distinguish "duplicate member" from every other decode failure without reimplementing rejectDuplicateJSONMembers' internal error type.

func ResolveRuntimeValue

func ResolveRuntimeValue[T any](
	bindings RuntimeBindings,
	ref ValueRef[T],
	current ScopeID,
) (T, error)

func StrictJSONWithPresence

func StrictJSONWithPresence(data []byte, requiredFields []string, target any) error

StrictJSONWithPresence decodes exactly one JSON value from data into target, and:

  1. rejects any duplicate JSON object member anywhere in data (see rejectDuplicateJSONMembers) — encoding/json's decoder silently applies "last member wins" for a repeated key, which would let two different byte-identical-looking readers of the same wire bytes disagree about the effective value;
  2. rejects unknown fields (json.Decoder.DisallowUnknownFields);
  3. rejects a decode that omits any of requiredFields — a required field's JSON zero value (e.g. an empty string, 0, or an empty array) is a legitimate value, so presence must be checked independently of the decoded Go value, not inferred from it;
  4. rejects trailing content after the first JSON value.

requiredFields names the top-level JSON object members target must contain; it is the caller's exhaustive omission matrix for that wire type.

This is the single shared presence-aware strict-JSON codec every checked-in manifest/wire decoder in this module should use — it is exported specifically so internal/codegen/scan (and future manifest-consuming packages such as #43/#46/#40) can call it instead of each maintaining their own byte-for-byte copy of this algorithm. Only the decoder entry points (this function and IsDuplicateJSONMember) are exported; rejectDuplicateJSONMembers stays this package's internal implementation detail.

Types

type AssignmentContext

type AssignmentContext struct {
	// contains filtered or unexported fields
}

AssignmentContext is the complete logical continuity value restored for a resumed or fresh runtime agent.

func NewAssignmentContext

func NewAssignmentContext(
	role portable.RoleID,
	assignment portable.AssignmentRef,
	task portable.TaskRef,
	worktree WorktreeRef,
	evidence []EvidenceRef,
	decisions []DecisionRef,
	outstanding []WorkItemRef,
	mutations []MutationContinuation,
	bindings RuntimeBindings,
) (AssignmentContext, error)

func (AssignmentContext) Assignment

func (c AssignmentContext) Assignment() portable.AssignmentRef

func (AssignmentContext) Bindings

func (c AssignmentContext) Bindings() RuntimeBindings

func (AssignmentContext) Decisions

func (c AssignmentContext) Decisions() []DecisionRef

func (AssignmentContext) Evidence

func (c AssignmentContext) Evidence() []EvidenceRef

func (AssignmentContext) IsValid

func (c AssignmentContext) IsValid() bool

func (AssignmentContext) Mutations

func (c AssignmentContext) Mutations() []MutationContinuation

func (AssignmentContext) Outstanding

func (c AssignmentContext) Outstanding() []WorkItemRef

func (AssignmentContext) Role

func (AssignmentContext) Task

func (AssignmentContext) Worktree

func (c AssignmentContext) Worktree() WorktreeRef

type BindingKey

type BindingKey[T any] struct {
	// contains filtered or unexported fields
}

BindingKey is a typed context-input identity.

func NewBindingKey

func NewBindingKey[T any](name string) (BindingKey[T], error)

func (BindingKey[T]) IsValid

func (k BindingKey[T]) IsValid() bool

func (BindingKey[T]) String

func (k BindingKey[T]) String() string

type CanonicalCommandDigest

type CanonicalCommandDigest struct {
	// contains filtered or unexported fields
}

CanonicalCommandDigest is a SHA-256 digest over canonical command bytes.

func DigestCanonicalCommand

func DigestCanonicalCommand(command []byte) (CanonicalCommandDigest, error)

func ParseCanonicalCommandDigest

func ParseCanonicalCommandDigest(value string) (CanonicalCommandDigest, error)

func (CanonicalCommandDigest) Equal

func (CanonicalCommandDigest) IsValid

func (d CanonicalCommandDigest) IsValid() bool

func (CanonicalCommandDigest) String

func (d CanonicalCommandDigest) String() string

type CanonicalDecisionBytes

type CanonicalDecisionBytes struct {
	// contains filtered or unexported fields
}

CanonicalDecisionBytes is the exact canonical JSON of one report validated through its originating request. It is opaque and constructor-owned: the only way to produce a non-zero value is a successful RequestUserDecision.DecodeReportedResult call, so possessing one is proof the bytes passed every report/request identity and prompt/result invariant.

func (CanonicalDecisionBytes) Bytes

func (b CanonicalDecisionBytes) Bytes() []byte

func (CanonicalDecisionBytes) IsValid

func (b CanonicalDecisionBytes) IsValid() bool

type Capability

type Capability[In, Out any] struct {
	// contains filtered or unexported fields
}

Capability is the opaque typed descriptor for one extension capability contract. It is deliberately not a constructible exported struct: the only way to produce a non-zero value is DefineCapability (or its panicking static-declaration form MustDefineCapability), so a Capability[In, Out] value in hand has already passed identity, codec, semantics, and effect validation, and is registered exactly once for its (CapabilityID, CapabilityContractVersion) pair. InvokeTool accepts only this descriptor — never a raw CapabilityID, string, native harness tool name, or untyped argument map.

func DefineCapability

func DefineCapability[In, Out any](
	id CapabilityID,
	version CapabilityContractVersion,
	semantics CapabilitySemantics,
	effects EffectSet,
	input Codec[In],
	output Codec[Out],
) (Capability[In, Out], error)

DefineCapability validates id, version, semantics, effects, and both codecs, registers the resulting contract exactly once (see registerCapabilityContract), and returns the opaque descriptor. Dynamic or user-supplied inputs must use this error-returning form; a static package declaration should use MustDefineCapability instead.

func MustDefineCapability

func MustDefineCapability[In, Out any](
	id CapabilityID,
	version CapabilityContractVersion,
	semantics CapabilitySemantics,
	effects EffectSet,
	input Codec[In],
	output Codec[Out],
) Capability[In, Out]

MustDefineCapability is DefineCapability restricted to static package declarations (e.g. a top-level `var RenderDiagram = MustDefineCapability(...)`): it panics with DefineCapability's own actionable validation error instead of returning one. Dynamic or user-supplied inputs must use DefineCapability.

func (Capability[In, Out]) Effects

func (c Capability[In, Out]) Effects() EffectSet

func (Capability[In, Out]) ID

func (c Capability[In, Out]) ID() CapabilityID

func (Capability[In, Out]) InputCodec

func (c Capability[In, Out]) InputCodec() Codec[In]

func (Capability[In, Out]) IsValid

func (c Capability[In, Out]) IsValid() bool

func (Capability[In, Out]) OutputCodec

func (c Capability[In, Out]) OutputCodec() Codec[Out]

func (Capability[In, Out]) Semantics

func (c Capability[In, Out]) Semantics() CapabilitySemantics

func (Capability[In, Out]) Version

func (c Capability[In, Out]) Version() CapabilityContractVersion

type CapabilityContractVersion

type CapabilityContractVersion string

CapabilityContractVersion is the exact MAJOR.MINOR.PATCH version of one capability's contract. Two registrations sharing a CapabilityID and CapabilityContractVersion must describe an identical contract (see registerCapabilityContract); a capability evolves by registering a new version, never by silently changing an already-registered version.

func (CapabilityContractVersion) IsValid

func (v CapabilityContractVersion) IsValid() bool

IsValid reports whether version is a well-formed MAJOR.MINOR.PATCH triple.

type CapabilityID

type CapabilityID string

CapabilityID is the portable identity of one typed extension capability: the safe InvokeTool escape for semantic operations that do not justify a dedicated core IR variant (see OperationInvokeSkill and its siblings for the closed, reviewed core vocabulary). It is a named string type, not an opaque struct like SemanticOperationID/SkillID/EffectID: Go's own untyped-literal assignability rule therefore lets a raw string literal compile as a CapabilityID value. That is intentional and accepted by the contract this type implements — the canonical-declaration-site rule is enforced by a separate static-analysis rule (internal/codegen/capabilitylint), not by the type system, precisely because the type system cannot express it for a named string type.

func (CapabilityID) IsValid

func (id CapabilityID) IsValid() bool

IsValid reports whether id is a non-empty, namespaced, control-character- free UTF-8 identity without surrounding whitespace — the same shape validateOpaqueID enforces for every other portable identity in this package. Internal whitespace is permitted (surrounding whitespace is not); this intentionally matches every sibling identity domain (SkillID, EffectID, SemanticOperationID, ...), which validateOpaqueID also backs.

type CapabilitySemantics

type CapabilitySemantics = DescriptorSemantics

CapabilitySemantics is the portable behavioral contract a capability descriptor carries: summary, preconditions, postconditions, and result contract, for a runtime binding to preserve across every harness. It is a type alias for DescriptorSemantics — the identical shape #38 already defined for OperationDescriptor/EffectDescriptor — so a Capability and a core operation/effect descriptor share one semantics contract instead of two structurally identical types that could silently drift apart.

type Codec

type Codec[T any] interface {
	Schema() SchemaID
	Encode(T) ([]byte, error)
	Decode([]byte) (T, error)
}

Codec is a typed, versioned portable value codec.

type CollectAssignmentResults

type CollectAssignmentResults struct {
	// contains filtered or unexported fields
}

func NewCollectAssignmentResults

func NewCollectAssignmentResults(assignments []portable.AssignmentRef, scheduling Scheduling, scope ScopeID, results ...ResultSlotDeclaration) (CollectAssignmentResults, error)

func (CollectAssignmentResults) Assignments

func (CollectAssignmentResults) Results

func (CollectAssignmentResults) Scheduling

func (o CollectAssignmentResults) Scheduling() Scheduling

func (CollectAssignmentResults) Scope

type ContinueAssignment

type ContinueAssignment struct {
	// contains filtered or unexported fields
}

func NewContinueAssignment

func NewContinueAssignment(context AssignmentContext, scope ScopeID, results ...ResultSlotDeclaration) (ContinueAssignment, error)

func (ContinueAssignment) Context

func (ContinueAssignment) Results

func (ContinueAssignment) Scope

func (o ContinueAssignment) Scope() ScopeID

type DecisionOption

type DecisionOption struct {
	ID          OptionID `json:"id"`
	Label       string   `json:"label"`
	Description string   `json:"description"`
}

DecisionOption is one option in presentation order.

func (*DecisionOption) UnmarshalJSON

func (o *DecisionOption) UnmarshalJSON(data []byte) error

UnmarshalJSON makes DecisionOption itself presence-aware: it is nested inside every selection prompt's options array, so without its own decoder an omitted "description" would silently decode as "", indistinguishable from a caller who explicitly supplied an empty description — the same gap PromptStimulus.UnmarshalJSON closes for the stimulus object.

type DecisionPurpose

type DecisionPurpose string

DecisionPurpose identifies why a user interaction is required.

type DecisionRef

type DecisionRef struct {
	// contains filtered or unexported fields
}

DecisionRef identifies a portable prior decision.

func NewDecisionRef

func NewDecisionRef(value string) (DecisionRef, error)

func (DecisionRef) IsValid

func (r DecisionRef) IsValid() bool

func (DecisionRef) String

func (r DecisionRef) String() string

type DelegateAssignment

type DelegateAssignment struct {
	// contains filtered or unexported fields
}

func NewDelegateAssignment

func NewDelegateAssignment(contexts []AssignmentContext, scheduling Scheduling, scope ScopeID, results ...ResultSlotDeclaration) (DelegateAssignment, error)

func (DelegateAssignment) Contexts

func (o DelegateAssignment) Contexts() []AssignmentContext

func (DelegateAssignment) Results

func (DelegateAssignment) Scheduling

func (o DelegateAssignment) Scheduling() Scheduling

func (DelegateAssignment) Scope

func (o DelegateAssignment) Scope() ScopeID

type DescriptorSemantics

type DescriptorSemantics struct {
	Summary        string
	Preconditions  []string
	Postconditions []string
	Result         string
}

DescriptorSemantics is the portable behavioral contract carried by a typed operation or effect descriptor.

type Diagnostic

type Diagnostic struct {
	What   string
	Why    string
	Where  string
	Phase  string
	Impact string
	Fix    string
	Cause  error
}

Diagnostic is the actionable error contract returned by IR construction and compilation. Every field is required so callers can report a useful failure without reverse-engineering compiler internals.

func (*Diagnostic) Error

func (d *Diagnostic) Error() string

func (*Diagnostic) Unwrap

func (d *Diagnostic) Unwrap() error

type Document

type Document struct {
	// contains filtered or unexported fields
}

Document is an immutable validated sequence of opaque parts.

func NewDocument

func NewDocument(parts ...Part) (Document, error)

func (Document) Len

func (d Document) Len() int

type EffectDescriptor

type EffectDescriptor[In, Out any] struct {
	// contains filtered or unexported fields
}

EffectDescriptor is the only valid lookup operand for a typed effect.

func NewEffectDescriptor

func NewEffectDescriptor[In, Out any](
	id EffectID,
	input Codec[In],
	output Codec[Out],
	semantics DescriptorSemantics,
	effects EffectSet,
) (EffectDescriptor[In, Out], error)

func (EffectDescriptor[In, Out]) Effects

func (d EffectDescriptor[In, Out]) Effects() EffectSet

func (EffectDescriptor[In, Out]) ID

func (d EffectDescriptor[In, Out]) ID() EffectID

func (EffectDescriptor[In, Out]) InputCodec

func (d EffectDescriptor[In, Out]) InputCodec() Codec[In]

func (EffectDescriptor[In, Out]) IsValid

func (d EffectDescriptor[In, Out]) IsValid() bool

func (EffectDescriptor[In, Out]) OutputCodec

func (d EffectDescriptor[In, Out]) OutputCodec() Codec[Out]

func (EffectDescriptor[In, Out]) Semantics

func (d EffectDescriptor[In, Out]) Semantics() DescriptorSemantics

type EffectID

type EffectID struct {
	// contains filtered or unexported fields
}

EffectID is the opaque portable identity of a declared effect.

func NewEffectID

func NewEffectID(value string) (EffectID, error)

func (EffectID) IsValid

func (id EffectID) IsValid() bool

func (EffectID) String

func (id EffectID) String() string

type EffectSet

type EffectSet struct {
	// contains filtered or unexported fields
}

EffectSet is an immutable canonical set of portable effect identities.

func NewEffectSet

func NewEffectSet(ids ...EffectID) (EffectSet, error)

NewEffectSet validates, sorts, and deduplicates effect identities.

func (EffectSet) CompatibleWith

func (s EffectSet) CompatibleWith(required EffectSet) bool

CompatibleWith requires exact canonical effect equality. A runtime binding with missing or additional effects does not implement the same descriptor. This is the only compatibility-check spelling: an earlier revision also exported the identical Compatible(required) as an "explicit alias", meaning every caller had to pick between two names for one concept.

func (EffectSet) ContainsAll

func (s EffectSet) ContainsAll(required EffectSet) bool

ContainsAll reports whether s contains every effect in required. It is useful for policy checks, but it is deliberately not descriptor compatibility: silently adding effects changes operation semantics.

func (EffectSet) Equal

func (s EffectSet) Equal(other EffectSet) bool

Equal reports canonical set equality.

func (EffectSet) IDs

func (s EffectSet) IDs() []EffectID

IDs returns a defensive copy in canonical lexical order.

func (EffectSet) IsValid

func (s EffectSet) IsValid() bool

func (EffectSet) MarshalJSON

func (s EffectSet) MarshalJSON() ([]byte, error)

func (*EffectSet) UnmarshalJSON

func (s *EffectSet) UnmarshalJSON(data []byte) error

type EvidenceRef

type EvidenceRef struct {
	// contains filtered or unexported fields
}

EvidenceRef identifies portable evidence retained across continuation.

func NewEvidenceRef

func NewEvidenceRef(value string) (EvidenceRef, error)

func (EvidenceRef) IsValid

func (r EvidenceRef) IsValid() bool

func (EvidenceRef) String

func (r EvidenceRef) String() string

type FreeTextPrompt

type FreeTextPrompt struct{ Stimulus PromptStimulus }

type FreeTextResult

type FreeTextResult struct{ Text string }

type HarnessID

type HarnessID = artifact.Harness

HarnessID identifies a native host family. Harness names are metadata; the selected version-bounded RuntimeContractID determines actual compatibility.

func EnabledHarnessIDs

func EnabledHarnessIDs() []HarnessID

EnabledHarnessIDs returns a fresh defensive copy of the canonical enabled target set. This is the only enumeration accessor for HarnessID: an earlier revision additionally exported a package-level AllHarnessIDs slice initialized once at load time, which callers could mutate to corrupt every later reader. There is exactly one construction spelling for this concept.

type InvokeSkill

type InvokeSkill struct {
	// contains filtered or unexported fields
}

func NewInvokeSkill

func NewInvokeSkill(skill SkillID, operands []ResolvedOperand, scope ScopeID, results ...ResultSlotDeclaration) (InvokeSkill, error)

func (InvokeSkill) Operands

func (o InvokeSkill) Operands() []ResolvedOperand

func (InvokeSkill) Results

func (o InvokeSkill) Results() []ResultSlotDeclaration

func (InvokeSkill) Scope

func (o InvokeSkill) Scope() ScopeID

func (InvokeSkill) Skill

func (o InvokeSkill) Skill() SkillID

type InvokeToolOperation

type InvokeToolOperation struct {
	// contains filtered or unexported fields
}

InvokeToolOperation is the SemanticOperation InvokeTool constructs. It is exported (unlike Capability's internal registration bookkeeping) so a later runtime binding can recover the invoked capability's identity, contract version, and codec-validated input without a JSON round trip through CanonicalSemanticOperation — mirroring InvokeSkill's own Skill()/ Operands() accessors. Its fields are unexported: the only way to produce a non-zero value is InvokeTool itself, so an InvokeToolOperation in hand always carries a capability identity that passed DefineCapability validation, never a raw string, native harness tool name, or arbitrary map.

func (InvokeToolOperation) Capability

func (o InvokeToolOperation) Capability() CapabilityID

Capability returns the invoked capability's identity.

func (InvokeToolOperation) EncodedInput

func (o InvokeToolOperation) EncodedInput() []byte

EncodedInput returns a defensive copy of the codec-encoded input bytes.

func (InvokeToolOperation) InputSchema

func (o InvokeToolOperation) InputSchema() SchemaID

InputSchema returns the capability input codec's schema identity.

func (InvokeToolOperation) OutputSchema

func (o InvokeToolOperation) OutputSchema() SchemaID

OutputSchema returns the capability output codec's schema identity.

func (InvokeToolOperation) Version

Version returns the invoked capability's contract version.

type JSONCodec

type JSONCodec[T any] struct {
	// contains filtered or unexported fields
}

JSONCodec is a strict JSON implementation with an optional semantic validator.

func NewJSONCodec

func NewJSONCodec[T any](schema SchemaID, validate func(T) error) (JSONCodec[T], error)

func (JSONCodec[T]) Decode

func (c JSONCodec[T]) Decode(data []byte) (T, error)

func (JSONCodec[T]) Encode

func (c JSONCodec[T]) Encode(value T) ([]byte, error)

func (JSONCodec[T]) Schema

func (c JSONCodec[T]) Schema() SchemaID

type LexicalScopeSnapshot

type LexicalScopeSnapshot struct {
	// contains filtered or unexported fields
}

LexicalScopeSnapshot is an immutable canonical copy of bindings visible from one scope when a mutation continuation is constructed.

func SnapshotBindings

func SnapshotBindings(bindings RuntimeBindings, scope ScopeID) (LexicalScopeSnapshot, error)

func (LexicalScopeSnapshot) CanonicalBytes

func (s LexicalScopeSnapshot) CanonicalBytes() []byte

func (LexicalScopeSnapshot) Equal

func (LexicalScopeSnapshot) IsValid

func (s LexicalScopeSnapshot) IsValid() bool

func (LexicalScopeSnapshot) Scope

func (s LexicalScopeSnapshot) Scope() ScopeID

type Location

type Location struct {
	// contains filtered or unexported fields
}

Location retains canonical owner and source coordinates for diagnostics.

func NewLocation

func NewLocation(owner, file, section string, sourceRange SourceRange) (Location, error)

func PartLocation

func PartLocation(part Part) (Location, error)

PartLocation returns a copy of a part's retained source location.

func (Location) File

func (l Location) File() string

func (Location) IsValid

func (l Location) IsValid() bool

func (Location) Owner

func (l Location) Owner() string

func (Location) Range

func (l Location) Range() SourceRange

func (Location) Section

func (l Location) Section() string

type MutationAuthority

type MutationAuthority interface {
	// contains filtered or unexported methods
}

MutationAuthority is the exact portable initiating authority retained across retry or fresh-agent continuation.

func BootstrapActor

func BootstrapActor(agent portable.AgentRef) (MutationAuthority, error)

func InitiatingAssignment

func InitiatingAssignment(assignment portable.AssignmentRef) (MutationAuthority, error)

type MutationContinuation

type MutationContinuation struct {
	// contains filtered or unexported fields
}

MutationContinuation is the complete in-memory parent-owned continuation for one logical stateful invocation. It deliberately has no persistence codec.

func NewMutationContinuationFromFactory

func NewMutationContinuationFromFactory(
	factory MutationRefFactory,
	seed string,
	authority MutationAuthority,
	request ResolvedMutationRequest,
	command CanonicalCommandDigest,
	results []ResultSlotDeclaration,
	scope LexicalScopeSnapshot,
) (MutationContinuation, error)

NewMutationContinuationFromFactory mints ref via factory(seed) and otherwise constructs exactly as NewMutationContinuation. A caller retrying the same logical invocation, or a fresh agent reconstructing it from persisted state, must supply the same seed to receive the same MutationRef; a different logical invocation must supply a different seed.

func (MutationContinuation) Authority

func (MutationContinuation) Command

func (MutationContinuation) IsValid

func (c MutationContinuation) IsValid() bool

func (MutationContinuation) ReconstructRequest

func (c MutationContinuation) ReconstructRequest() []byte

func (MutationContinuation) Ref

func (MutationContinuation) Request

func (MutationContinuation) Results

func (MutationContinuation) Scope

type MutationRefFactory

type MutationRefFactory func(seed string) (portable.MutationRef, error)

MutationRefFactory mints a portable.MutationRef for one logical stateful invocation identity (seed). This package deliberately does not hardcode a minting strategy: a real orchestrator may choose any deterministic approach (e.g. a content digest of the resolved request and authority), while every consumer of a MutationRef relies on exactly one invariant — retrying the SAME logical invocation, or reconstructing it from a fresh agent with no memory of prior calls, must mint the exact same ref for the exact same seed; two distinct logical invocations must never collide. Injecting the factory (rather than calling portable.NewMutationRef directly) is what makes that invariant testable independent of whatever strategy production code eventually chooses.

type NativeValidator

type NativeValidator interface{ Validate(RenderedTree) error }

NativeValidator validates a complete in-memory tree against a target loader or schema without publishing files.

type NativeValidatorFunc

type NativeValidatorFunc func(RenderedTree) error

func (NativeValidatorFunc) Validate

func (f NativeValidatorFunc) Validate(tree RenderedTree) error

type OperationDescriptor

type OperationDescriptor[In, Out any] struct {
	// contains filtered or unexported fields
}

OperationDescriptor is the only valid lookup operand for a semantic operation.

func NewOperationDescriptor

func NewOperationDescriptor[In, Out any](
	id SemanticOperationID,
	input Codec[In],
	output Codec[Out],
	semantics DescriptorSemantics,
	effects EffectSet,
) (OperationDescriptor[In, Out], error)

func (OperationDescriptor[In, Out]) Effects

func (d OperationDescriptor[In, Out]) Effects() EffectSet

func (OperationDescriptor[In, Out]) ID

func (d OperationDescriptor[In, Out]) ID() SemanticOperationID

func (OperationDescriptor[In, Out]) InputCodec

func (d OperationDescriptor[In, Out]) InputCodec() Codec[In]

func (OperationDescriptor[In, Out]) IsValid

func (d OperationDescriptor[In, Out]) IsValid() bool

func (OperationDescriptor[In, Out]) OutputCodec

func (d OperationDescriptor[In, Out]) OutputCodec() Codec[Out]

func (OperationDescriptor[In, Out]) Semantics

func (d OperationDescriptor[In, Out]) Semantics() DescriptorSemantics

type OperationKind

type OperationKind string
const (
	OperationInvokeSkill              OperationKind = "invoke_skill"
	OperationDelegateAssignment       OperationKind = "delegate_assignment"
	OperationContinueAssignment       OperationKind = "continue_assignment"
	OperationSendAssignmentMessage    OperationKind = "send_assignment_message"
	OperationCollectAssignmentResults OperationKind = "collect_assignment_results"
	OperationStopAssignment           OperationKind = "stop_assignment"
	OperationRequestUserDecision      OperationKind = "request_user_decision"
)
const OperationInvokeTool OperationKind = "invoke_tool"

OperationInvokeTool is the closed protocol-meaning identity shared by every InvokeTool operation, regardless of which capability it invokes — exactly as every core operation kind shares one fixed SemanticOperationID (see coreOperationIDs). It is deliberately not added to canonicalOperationKinds/AllOperationKinds: that accessor is the closed, reviewed *core* orchestration vocabulary, and InvokeTool is explicitly the escape hatch for semantics that do not (yet) justify a dedicated core IR variant. A frequently used capability graduating to a dedicated core operation is a separate, later change to operations.go, not something this escape hatch does on its own.

func AllOperationKinds

func AllOperationKinds() []OperationKind

AllOperationKinds returns a fresh defensive copy of the closed *core* orchestration variant set, in canonical order. This is a function, not a package-level slice: an earlier revision exported a mutable `var AllOperationKinds []OperationKind` initialized once at package load, so any caller mutation corrupted every later reader for the lifetime of the process.

This accessor enumerates only the reviewed core vocabulary. The full set of SemanticOperation implementers is larger: OperationInvokeTool (the InvokeToolOperation escape hatch, defined in capability.go) is a distinct OperationKind that shares one fixed SemanticOperationID across every capability it invokes and is deliberately excluded here — see OperationInvokeTool's own documentation for why it is not part of the closed core set. Any code that must reason about every SemanticOperation variant (for example the nil-pointer guard below) must account for both the core kinds and OperationInvokeTool.

func SemanticOperationKind

func SemanticOperationKind(operation SemanticOperation) (OperationKind, error)

SemanticOperationKind returns the closed protocol variant identity.

type OperationLowerer

type OperationLowerer interface {
	Lower(operation SemanticOperation, at Location) ([]byte, error)
}

OperationLowerer converts semantic intent for one runtime contract. Native function names belong only inside implementations supplied by the runtime layer.

type OperationLowererFunc

type OperationLowererFunc func(operation SemanticOperation, at Location) ([]byte, error)

func (OperationLowererFunc) Lower

func (f OperationLowererFunc) Lower(operation SemanticOperation, at Location) ([]byte, error)

type OptionID

type OptionID string

OptionID is the stable identity of one presented decision option.

type Part

type Part interface {
	// contains filtered or unexported methods
}

Part is a closed document sum. Concrete parts are immutable and cannot be implemented outside this package.

func Markdown

func Markdown(source []byte, at Location) (Part, error)

Markdown parses source exactly once through Goldmark and retains the owned source plus AST coordinates in the returned opaque part.

func Operation

func Operation(operation SemanticOperation, at Location) (Part, error)

Operation inserts one already validated protocol-semantic operation.

func TargetLiteral

func TargetLiteral(cases []TargetCase, at Location) (Part, error)

TargetLiteral validates exactly one case for every enabled harness.

func Verbatim

func Verbatim(content []byte, at Location) (Part, error)

Verbatim inserts portable text without inferring operational meaning.

type PromptStimulus

type PromptStimulus struct {
	Question        string `json:"question"`
	DefinitionShown string `json:"definition_shown"`
	CommandShown    string `json:"command_shown"`
}

PromptStimulus is the complete material presented to the user.

func (*PromptStimulus) UnmarshalJSON

func (s *PromptStimulus) UnmarshalJSON(data []byte) error

UnmarshalJSON makes PromptStimulus itself presence-aware: it is nested inside every prompt variant's data object, so without its own decoder an omitted "definition_shown" or "command_shown" would silently decode as "", indistinguishable from a caller who explicitly supplied an empty string.

type RenderedFile

type RenderedFile struct {
	// contains filtered or unexported fields
}

RenderedFile is an immutable relative file. Construction is private to this package (see newRenderedFile) — only Compile produces one, so a caller can never fabricate a RenderedFile/RenderedTree to hand to a NativeValidator or downstream publisher and have it pass for genuine compiled output.

func (RenderedFile) Content

func (f RenderedFile) Content() []byte

func (RenderedFile) Path

func (f RenderedFile) Path() string

type RenderedTree

type RenderedTree struct {
	// contains filtered or unexported fields
}

RenderedTree is one complete immutable set of validated relative files. Construction is private to this package (see newRenderedTree); Compile is the only producer.

func Compile

func Compile(document Document, target Target) (RenderedTree, error)

Compile validates and renders entirely in memory. On every error it returns the zero RenderedTree; this package has no filesystem publisher dependency.

func (RenderedTree) File

func (t RenderedTree) File(filePath string) (RenderedFile, bool)

func (RenderedTree) Len

func (t RenderedTree) Len() int

func (RenderedTree) Paths

func (t RenderedTree) Paths() []string

type ReportedUserDecision

type ReportedUserDecision struct {
	Schema          string
	RequestID       UserDecisionRequestID
	Harness         HarnessID
	RuntimeContract RuntimeContractID
	Epoch           portable.TaskRef
	GateTask        portable.TaskRef
	Purpose         DecisionPurpose
	Prompt          UserDecisionPrompt
	Result          UserDecisionResult
	// contains filtered or unexported fields
}

ReportedUserDecision is protocol-reported evidence. It intentionally carries no actor, recorder, trust, authentication, or mutation-authority field. Its base (scope and declared result slot) is never part of the wire form — DecodeReportedResult copies it from the originating, already-validated request, so a caller always knows exactly where a reported answer belongs in the parent's lexical bindings.

func (ReportedUserDecision) MarshalJSON

func (r ReportedUserDecision) MarshalJSON() ([]byte, error)

func (ReportedUserDecision) Results

Results returns a defensive copy of the result slot(s) copied from the originating request.

func (ReportedUserDecision) Scope

func (r ReportedUserDecision) Scope() ScopeID

Scope returns the lexical scope copied from the originating request.

type RequestUserDecision

type RequestUserDecision struct {
	Schema          string
	RequestID       UserDecisionRequestID
	Harness         HarnessID
	RuntimeContract RuntimeContractID
	Epoch           portable.TaskRef
	GateTask        portable.TaskRef
	Purpose         DecisionPurpose
	Prompt          UserDecisionPrompt
	// contains filtered or unexported fields
}

RequestUserDecision is the neutral request a runtime binding presents. Its lexical scope and any declared result slot are constructor-owned (set only by NewRequestUserDecision) rather than public fields: a decision that will bind its answer into RuntimeBindings must use the exact same scope/result validation every other SemanticOperation uses, including out-of-scope result rejection.

func NewRequestUserDecision

func NewRequestUserDecision(
	requestID UserDecisionRequestID,
	harness HarnessID,
	runtimeContract RuntimeContractID,
	epoch portable.TaskRef,
	gateTask portable.TaskRef,
	purpose DecisionPurpose,
	prompt UserDecisionPrompt,
	scope ScopeID,
	results ...ResultSlotDeclaration,
) (RequestUserDecision, error)

NewRequestUserDecision constructs and validates a user-decision request. scope and results follow the same lexical-binding rules as every other SemanticOperation (see newOperationBase): results must be declared in scope, and a caller with no result to capture can pass no results.

func (RequestUserDecision) DecodeReportedResult

func (q RequestUserDecision) DecodeReportedResult(
	r io.Reader,
	maxBytes int64,
) (ReportedUserDecision, CanonicalDecisionBytes, error)

DecodeReportedResult strictly decodes and validates one report through its originating request. There is intentionally no free report decoder.

func (RequestUserDecision) MarshalJSON

func (q RequestUserDecision) MarshalJSON() ([]byte, error)

func (RequestUserDecision) Results

Results returns a defensive copy of the result slot(s) this decision request declared for capturing its reported answer.

func (RequestUserDecision) Scope

func (q RequestUserDecision) Scope() ScopeID

Scope returns the lexical scope this decision request was constructed in.

type ResolvedMutationRequest

type ResolvedMutationRequest struct {
	// contains filtered or unexported fields
}

ResolvedMutationRequest retains protocol meaning, request schema, and exact immutable canonical request bytes.

func NewResolvedMutationRequest

func NewResolvedMutationRequest(
	operation SemanticOperationID,
	schema SchemaID,
	request []byte,
) (ResolvedMutationRequest, error)

func (ResolvedMutationRequest) CanonicalBytes

func (r ResolvedMutationRequest) CanonicalBytes() []byte

func (ResolvedMutationRequest) IsValid

func (r ResolvedMutationRequest) IsValid() bool

func (ResolvedMutationRequest) Operation

func (ResolvedMutationRequest) Schema

func (r ResolvedMutationRequest) Schema() SchemaID

type ResolvedOperand

type ResolvedOperand struct {
	// contains filtered or unexported fields
}

ResolvedOperand is immutable typed dataflow consumed by an operation.

func ResolveOperand

func ResolveOperand[T any](bindings RuntimeBindings, ref ValueRef[T], scope ScopeID) (ResolvedOperand, error)

func (ResolvedOperand) Bytes

func (o ResolvedOperand) Bytes() []byte

func (ResolvedOperand) IsValid

func (o ResolvedOperand) IsValid() bool

func (ResolvedOperand) Key

func (o ResolvedOperand) Key() string

func (ResolvedOperand) TypeName

func (o ResolvedOperand) TypeName() string

type ResultSlot

type ResultSlot[T any] struct {
	// contains filtered or unexported fields
}

ResultSlot declares one typed result produced in a lexical scope.

func NewResultSlot

func NewResultSlot[T any](key BindingKey[T], scope ScopeID, codec Codec[T]) (ResultSlot[T], error)

func (ResultSlot[T]) IsValid

func (s ResultSlot[T]) IsValid() bool

type ResultSlotDeclaration

type ResultSlotDeclaration struct {
	// contains filtered or unexported fields
}

ResultSlotDeclaration is the immutable non-generic metadata retained by an operation and mutation continuation.

func DeclareResultSlot

func DeclareResultSlot[T any](slot ResultSlot[T]) (ResultSlotDeclaration, error)

func (ResultSlotDeclaration) IsValid

func (d ResultSlotDeclaration) IsValid() bool

func (ResultSlotDeclaration) Key

func (d ResultSlotDeclaration) Key() string

func (ResultSlotDeclaration) Schema

func (d ResultSlotDeclaration) Schema() SchemaID

func (ResultSlotDeclaration) Scope

func (d ResultSlotDeclaration) Scope() ScopeID

func (ResultSlotDeclaration) TypeName

func (d ResultSlotDeclaration) TypeName() string

type ReviewRoundRef

type ReviewRoundRef struct {
	// contains filtered or unexported fields
}

ReviewRoundRef identifies a portable review-round result.

func NewReviewRoundRef

func NewReviewRoundRef(value string) (ReviewRoundRef, error)

func (ReviewRoundRef) IsValid

func (r ReviewRoundRef) IsValid() bool

func (ReviewRoundRef) String

func (r ReviewRoundRef) String() string

type RuntimeBindings

type RuntimeBindings struct {
	// contains filtered or unexported fields
}

RuntimeBindings is an immutable typed lexical binding environment.

func BindRuntimeValue

func BindRuntimeValue[T any](
	bindings RuntimeBindings,
	key BindingKey[T],
	scope ScopeID,
	value T,
) (RuntimeBindings, error)

BindRuntimeValue binds a context input: a value already known before any mutation runs (e.g. an assignment's task or worktree). It always stores the entry with valueSourceInput, matching InputValueRef.

func CaptureRuntimeResult

func CaptureRuntimeResult[T any](
	bindings RuntimeBindings,
	slot ResultSlot[T],
	data []byte,
) (RuntimeBindings, error)

CaptureRuntimeResult binds a result produced by running a mutation. It always stores the entry with valueSourceResult, matching ResultValueRef, so a ResultValueRef can never resolve against an entry that was only ever bound as a context input (see ResolveRuntimeValue's source check) — an uncaptured result must stay missing, not silently alias an input that happens to share the same key spelling.

func NewRuntimeBindings

func NewRuntimeBindings() RuntimeBindings

func (RuntimeBindings) Len

func (b RuntimeBindings) Len() int

type RuntimeContractID

type RuntimeContractID = artifact.RuntimeContractID

RuntimeContractID identifies one reviewed, version-bounded runtime profile bound to exactly one enabled harness. It is opaque and constructor-owned: the only way to produce a non-zero value is NewRuntimeContractID (or a successful JSON decode through the same validation), so a RuntimeContractID value in hand always names a real, enabled harness — decision and target code can compare Harness() directly instead of re-deriving it from string prefixes.

func NewRuntimeContractID

func NewRuntimeContractID(harness HarnessID, name string) (RuntimeContractID, error)

NewRuntimeContractID validates name and constructs a RuntimeContractID bound to harness. name may already carry the "<harness>/" prefix (so values round-tripped from String() can be re-supplied); a bare suffix is prefixed automatically.

type ScheduleKind

type ScheduleKind string
const (
	ScheduleIndependent       ScheduleKind = "independent"
	ScheduleDependencyOrdered ScheduleKind = "dependency_ordered"
	ScheduleBoundedParallel   ScheduleKind = "bounded_parallel"
)

type Scheduling

type Scheduling struct {
	// contains filtered or unexported fields
}

func BoundedParallel

func BoundedParallel(maxParallel int) (Scheduling, error)

func DependencyOrdered

func DependencyOrdered() Scheduling

func Independent

func Independent() Scheduling

func (Scheduling) IsValid

func (s Scheduling) IsValid() bool

func (Scheduling) Kind

func (s Scheduling) Kind() ScheduleKind

func (Scheduling) MaxParallel

func (s Scheduling) MaxParallel() int

type SchemaID

type SchemaID string

SchemaID identifies a versioned input or result codec.

type ScopeID

type ScopeID struct {
	// contains filtered or unexported fields
}

ScopeID identifies one lexical runtime scope. Children can consume bindings from ancestors; siblings and descendants are out of scope.

func NewChildScope

func NewChildScope(parent ScopeID, name string) (ScopeID, error)

func NewRootScope

func NewRootScope(name string) (ScopeID, error)

func (ScopeID) IsValid

func (s ScopeID) IsValid() bool

func (ScopeID) String

func (s ScopeID) String() string

type SelectManyPrompt

type SelectManyPrompt struct {
	Stimulus      PromptStimulus
	Options       []DecisionOption
	MinSelections int
	MaxSelections int
}

type SelectManyResult

type SelectManyResult struct {
	Selected       []OptionID
	VerbatimAnswer string
}

type SelectOnePrompt

type SelectOnePrompt struct {
	Stimulus PromptStimulus
	Options  []DecisionOption
}

type SelectOneResult

type SelectOneResult struct {
	Selected       OptionID
	VerbatimAnswer string
}

type SemanticOperation

type SemanticOperation interface {
	// contains filtered or unexported methods
}

func InvokeTool

func InvokeTool[In, Out any](capability Capability[In, Out], input In) SemanticOperation

InvokeTool constructs the SemanticOperation that invokes capability with input. It accepts only an opaque Capability descriptor — never a CapabilityID, raw string, native harness tool name, or untyped argument map — and codec-encodes input immediately so the resulting operation's serialized IR always carries validated identity, capability contract version, and encoded input, never a raw native name. Because this signature (unlike every other SemanticOperation constructor in this package) does not return an error, any construction failure — an invalid capability or an input the capability's codec rejects — is retained and surfaced the first time the operation is validated: when it enters a Document via Operation(...), or through SemanticOperationKind/SemanticOperationIdentity/CanonicalSemanticOperation.

type SemanticOperationID

type SemanticOperationID struct {
	// contains filtered or unexported fields
}

SemanticOperationID is protocol meaning, not a runtime function name or a durable-store idempotency identity.

func CoreOperationID

func CoreOperationID(kind OperationKind) (SemanticOperationID, bool)

CoreOperationID returns the canonical protocol identity for a closed orchestration variant.

func NewSemanticOperationID

func NewSemanticOperationID(value string) (SemanticOperationID, error)

func SemanticOperationIdentity

func SemanticOperationIdentity(operation SemanticOperation) (SemanticOperationID, error)

SemanticOperationIdentity returns the protocol identity, never a native harness function name or durable-store operation ID.

func (SemanticOperationID) IsValid

func (id SemanticOperationID) IsValid() bool

func (SemanticOperationID) String

func (id SemanticOperationID) String() string

type SendAssignmentMessage

type SendAssignmentMessage struct {
	// contains filtered or unexported fields
}

func NewSendAssignmentMessage

func NewSendAssignmentMessage(assignment portable.AssignmentRef, message string, scope ScopeID) (SendAssignmentMessage, error)

func (SendAssignmentMessage) Assignment

func (SendAssignmentMessage) Message

func (o SendAssignmentMessage) Message() string

func (SendAssignmentMessage) Scope

func (o SendAssignmentMessage) Scope() ScopeID

type SkillID

type SkillID struct {
	// contains filtered or unexported fields
}

SkillID is an opaque validated portable skill identity.

func NewSkillID

func NewSkillID(value string) (SkillID, error)

func (SkillID) IsValid

func (id SkillID) IsValid() bool

func (SkillID) String

func (id SkillID) String() string

type SourceRange

type SourceRange struct {
	Start int
	Stop  int
}

SourceRange is a half-open byte range in one owned part source.

func MarkdownSourceRanges

func MarkdownSourceRanges(part Part) ([]SourceRange, error)

MarkdownSourceRanges returns defensive AST-derived source ranges.

type StopAssignment

type StopAssignment struct {
	// contains filtered or unexported fields
}

func NewStopAssignment

func NewStopAssignment(assignments []portable.AssignmentRef, reason string, scope ScopeID) (StopAssignment, error)

func (StopAssignment) Assignments

func (o StopAssignment) Assignments() []portable.AssignmentRef

func (StopAssignment) Reason

func (o StopAssignment) Reason() string

func (StopAssignment) Scope

func (o StopAssignment) Scope() ScopeID

type Target

type Target struct {
	// contains filtered or unexported fields
}

Target is one validated in-memory compilation profile.

func NewTarget

func NewTarget(
	harness HarnessID,
	contract RuntimeContractID,
	outputPath string,
	lowerer OperationLowerer,
	validators ...NativeValidator,
) (Target, error)

func (Target) Harness

func (t Target) Harness() HarnessID

func (Target) OutputPath

func (t Target) OutputPath() string

func (Target) RuntimeContract

func (t Target) RuntimeContract() RuntimeContractID

type TargetCase

type TargetCase interface {
	// contains filtered or unexported methods
}

TargetCase is a closed exhaustive target-literal case.

func LiteralForHarness

func LiteralForHarness(harness HarnessID, contract RuntimeContractID, content []byte, reason string) (TargetCase, error)

LiteralForHarness constructs a contract-bound literal case, explicitly checking that harness is the exact enabled harness contract was constructed for. This is the only literal-construction spelling: an earlier revision additionally offered LiteralFor, which derived harness from the contract itself and forwarded here — now that RuntimeContractID is opaque and self-describing (Harness()), that indirection added a second spelling of the same concept without adding safety. Callers that only have a contract in hand can pass contract.Harness() explicitly.

func LiteralUnsupported

func LiteralUnsupported(harness HarnessID, reason string) (TargetCase, error)

type UserDecisionPrompt

type UserDecisionPrompt interface {
	// contains filtered or unexported methods
}

type UserDecisionRequestID

type UserDecisionRequestID string

UserDecisionRequestID is minted by the parent for one decision request.

type UserDecisionResult

type UserDecisionResult interface {
	// contains filtered or unexported methods
}

type ValueRef

type ValueRef[T any] struct {
	// contains filtered or unexported fields
}

ValueRef is a typed operand referencing a context input or prior result.

func InputValueRef

func InputValueRef[T any](key BindingKey[T], scope ScopeID) (ValueRef[T], error)

func ResultValueRef

func ResultValueRef[T any](slot ResultSlot[T]) (ValueRef[T], error)

type WorkItemRef

type WorkItemRef struct {
	// contains filtered or unexported fields
}

WorkItemRef identifies portable outstanding work.

func NewWorkItemRef

func NewWorkItemRef(value string) (WorkItemRef, error)

func (WorkItemRef) IsValid

func (r WorkItemRef) IsValid() bool

func (WorkItemRef) String

func (r WorkItemRef) String() string

type WorktreeRef

type WorktreeRef struct {
	// contains filtered or unexported fields
}

WorktreeRef identifies assignment-local workspace context.

func NewWorktreeRef

func NewWorktreeRef(value string) (WorktreeRef, error)

func (WorktreeRef) IsValid

func (r WorktreeRef) IsValid() bool

func (WorktreeRef) String

func (r WorktreeRef) String() string

Jump to

Keyboard shortcuts

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