Documentation
¶
Overview ¶
Package runtime defines Pasture's opaque, version-bounded runtime contracts: the only authority allowed to turn a protocol semantic operation, effect, or typed capability into native runtime behavior for a specific harness at a specific host version.
A RuntimeContract binds exactly one enabled harness (see ir.HarnessID) and a VersionConstraint. It classifies every used orchestration operation, task/process/Git/filesystem effect, and typed capability exactly once as one of effects.RuntimeClass's four members — native, parent-mediated, semantic-instruction, or unsupported — and exposes three separate, opaque-descriptor lookup families:
- LookupOperationBinding accepts an ir.OperationDescriptor[In, Out];
- LookupEffectBinding accepts an ir.EffectDescriptor[In, Out];
- LookupCapabilityBinding accepts an ir.Capability[In, Out].
Every lookup returns (binding, error). Missing, wrong-type, unbound, out-of-range, or unsupported descriptors fail actionably; none collapses into a nil or zero binding. Named string IDs remain descriptor metadata only: an assignable untyped literal is never a lookup operand, because the operand is always a constructor-validated typed descriptor.
External packages contribute a version-bounded binding for an opaque capability descriptor with BindCapability, without editing this package. NewRuntimeContract validates every contribution's codecs, semantics, effect set, and capability-version intersection, requires each requested capability exactly once, and rejects missing, duplicate, or conflicting contributions.
The package also exposes three closed native lifecycle profiles through ClaudeCode2_1_261Lifecycle, Codex0_153_0Lifecycle, and OpenCode1_18_29Lifecycle. Their harness-specific numeric event enums map every pinned native event to observation, gate consultation, or an explicit human response, together with exact transport, blocking, identity, mutation, ordering, reconciliation, failure, and stop-loop behavior. There is no string lookup or registration API. Lifecycle mappings carry generation metadata only: native payloads cannot supply Pasture review/publication authority or create a decision merely because an event occurred. Antigravity fails actionably because no public contract can be pinned; Pi has no adapter profile.
Scope boundary (delivered-surface divergence) ¶
Issue #40 also describes a landing-composition path — the versioned `pasture task integration publish-repository` runtime binding — that threads a MutationContinuation through #43's pure canonicalization/publication preparation and #46's guarded push, and a #49 epoch interaction-mode lowering. Those paths consume task-package APIs (a `task command canonicalize` entry point, a side-effect-free publication preparation, and a `CommitRepositoryPublication` commit) that the ordered #43 base plus #49 policy files do not yet export in internal/tasks. This package therefore delivers the buildable core: the version-bounded contract, the three lookup families, external capability composition, and the initial pinned point contracts. The composite landing binding and the interaction-mode lowering are deferred until their task-side dependencies land as a follow-up change rather than stubbed with a fabricated task surface here.
Index ¶
- Variables
- func AntigravityLifecycleContract() error
- func ComparePrecedence(a, b HostVersion) int
- func ValidatePinnedLifecycleProfiles() error
- type BlockingMode
- type CapabilityRuntimeBinding
- func LookupCapabilityBinding[In, Out any](contract RuntimeContract, capability ir.Capability[In, Out]) (CapabilityRuntimeBinding[In, Out], error)
- func MediatedCapabilityBinding[In, Out any](capability ir.Capability[In, Out], lowering MediatedLowering) (CapabilityRuntimeBinding[In, Out], error)
- func NativeCapabilityBinding[In, Out any](capability ir.Capability[In, Out], call NativeCall) (CapabilityRuntimeBinding[In, Out], error)
- func SemanticCapabilityBinding[In, Out any](capability ir.Capability[In, Out], lowering SemanticLowering) (CapabilityRuntimeBinding[In, Out], error)
- type CapabilityVersionRange
- func (r CapabilityVersionRange) Includes(version ir.CapabilityContractVersion) bool
- func (r CapabilityVersionRange) Intersects(other CapabilityVersionRange) bool
- func (r CapabilityVersionRange) IsValid() bool
- func (r CapabilityVersionRange) Max() ir.CapabilityContractVersion
- func (r CapabilityVersionRange) Min() ir.CapabilityContractVersion
- type ClaudeLifecycleEvent
- type CodexLifecycleEvent
- type CoreOperationDescriptor
- type CoreRuntimeBindings
- type EffectBinding
- func MediatedEffectBinding[In, Out any](descriptor ir.EffectDescriptor[In, Out], lowering MediatedLowering) (EffectBinding, error)
- func NativeEffectBinding[In, Out any](descriptor ir.EffectDescriptor[In, Out], call NativeCall) (EffectBinding, error)
- func SemanticEffectBinding[In, Out any](descriptor ir.EffectDescriptor[In, Out], lowering SemanticLowering) (EffectBinding, error)
- func UnsupportedEffectBinding[In, Out any](descriptor ir.EffectDescriptor[In, Out], reason string) (EffectBinding, error)
- type EventSemantic
- type FailureEvidence
- type FailureMode
- type HandlerOrder
- type HookSurface
- type HostVersion
- type IdentityPolicy
- type LifecycleContract
- func (c LifecycleContract[E]) Events() []E
- func (c LifecycleContract[E]) Harness() ir.HarnessID
- func (c LifecycleContract[E]) ID() ir.RuntimeContractID
- func (c LifecycleContract[E]) IsValid() bool
- func (c LifecycleContract[E]) Mapping(event E) (LifecycleEventMapping, error)
- func (c LifecycleContract[E]) Supports(version HostVersion) bool
- func (c LifecycleContract[E]) Versions() VersionConstraint
- type LifecycleEventMapping
- func (m LifecycleEventMapping) AskEvidence() FailureEvidence
- func (m LifecycleEventMapping) Blocking() BlockingMode
- func (m LifecycleEventMapping) DeclaredFailure() FailureMode
- func (m LifecycleEventMapping) DeclaredField(nativeName string) (NativeIdentityField, bool)
- func (m LifecycleEventMapping) Evidence() FailureEvidence
- func (m LifecycleEventMapping) Failure() FailureMode
- func (m LifecycleEventMapping) Identities() []NativeIdentityField
- func (m LifecycleEventMapping) IdentityPolicy() IdentityPolicy
- func (m LifecycleEventMapping) IsValid() bool
- func (m LifecycleEventMapping) Mutation() MutationMode
- func (m LifecycleEventMapping) NativeName() string
- func (m LifecycleEventMapping) Order() HandlerOrder
- func (m LifecycleEventMapping) PreAction() bool
- func (m LifecycleEventMapping) Reconciliation() ReconciliationMode
- func (m LifecycleEventMapping) Response() ResponseCapability
- func (m LifecycleEventMapping) Semantic() EventSemantic
- func (m LifecycleEventMapping) StopLoop() StopLoopPolicy
- func (m LifecycleEventMapping) Surface() HookSurface
- func (m LifecycleEventMapping) UnresolvedIdentities() []NativeIdentityKind
- type LifecycleFailurePolicy
- type MediatedLowering
- type MutationMode
- type NativeCall
- type NativeIdentityField
- type NativeIdentityKind
- type OpenCode2LifecycleEvent
- type OpenCodeLifecycleEvent
- type OperationBinding
- func MediatedOperationBinding[In, Out any](descriptor ir.OperationDescriptor[In, Out], lowering MediatedLowering) (OperationBinding, error)
- func NativeOperationBinding[In, Out any](descriptor ir.OperationDescriptor[In, Out], call NativeCall) (OperationBinding, error)
- func SemanticOperationBinding[In, Out any](descriptor ir.OperationDescriptor[In, Out], lowering SemanticLowering) (OperationBinding, error)
- func UnsupportedOperationBinding[In, Out any](descriptor ir.OperationDescriptor[In, Out], reason string) (OperationBinding, error)
- type OrchestrationRequest
- type OrchestrationResult
- type ReconciliationMode
- type ResponseCapability
- type RuntimeBinding
- type RuntimeBindingContribution
- type RuntimeContract
- func ClaudeCode2_1_261() RuntimeContract
- func Codex0_153_0() RuntimeContract
- func NewRuntimeContract(id ir.RuntimeContractID, harness ir.HarnessID, versions VersionConstraint, ...) (RuntimeContract, error)
- func OpenCode1_18_29() RuntimeContract
- func OpenCode2_0_20() RuntimeContract
- func PinnedContracts() []RuntimeContract
- type SemanticLowering
- type StopLoopPolicy
- type VersionConstraint
- func (c VersionConstraint) Allows(version HostVersion) bool
- func (c VersionConstraint) Describe() string
- func (c VersionConstraint) HasUpperBound() bool
- func (c VersionConstraint) IncludesPrereleases() bool
- func (c VersionConstraint) IsValid() bool
- func (c VersionConstraint) Max() HostVersion
- func (c VersionConstraint) Min() HostVersion
Constants ¶
This section is empty.
Variables ¶
var ErrLifecycleAdapterUnsupported = errors.New("native lifecycle adapter unsupported")
ErrLifecycleAdapterUnsupported identifies a native lifecycle adapter that cannot be generated from a documented, version-bounded host contract.
Functions ¶
func AntigravityLifecycleContract ¶
func AntigravityLifecycleContract() error
AntigravityLifecycleContract returns the actionable unsupported result for Antigravity generation. No public event catalog or wire contract is available, so returning an error is safer than reserving guessed event names or payloads.
func ComparePrecedence ¶
func ComparePrecedence(a, b HostVersion) int
ComparePrecedence orders two versions by semantic-version precedence. Build metadata is ignored; a prerelease has lower precedence than the same release. It returns -1, 0, or +1.
func ValidatePinnedLifecycleProfiles ¶ added in v0.0.9
func ValidatePinnedLifecycleProfiles() error
ValidatePinnedLifecycleProfiles rebuilds every pinned lifecycle profile and returns the first row that fails contract validation, WITHOUT panicking.
The three profile constructors panic on an invalid row, which is right for a program that is already running: an invalid contract must never reach code generation. A generator, though, has to report the offending row before it writes anything, so it calls this instead and prints the six-part diagnostic.
Types ¶
type BlockingMode ¶
type BlockingMode uint8
BlockingMode records whether the native host waits for and can act on this event's result. ConditionallyBlocking is used where the host excludes a documented matcher variant from blocking.
const ( NonBlocking BlockingMode = iota + 1 Blocking ConditionallyBlocking )
func (BlockingMode) IsValid ¶
func (m BlockingMode) IsValid() bool
func (BlockingMode) String ¶
func (m BlockingMode) String() string
type CapabilityRuntimeBinding ¶
type CapabilityRuntimeBinding[In, Out any] interface { Class() effects.RuntimeClass CapabilityID() ir.CapabilityID Version() ir.CapabilityContractVersion InputSchema() ir.SchemaID OutputSchema() ir.SchemaID Semantics() ir.CapabilitySemantics Effects() ir.EffectSet Native() (NativeCall, bool) Mediated() (MediatedLowering, bool) Semantic() (SemanticLowering, bool) // contains filtered or unexported methods }
CapabilityRuntimeBinding is the typed binding an external package contributes for one opaque capability descriptor. Its marker method is unexported, so the only values that satisfy it are produced by this package's constructors (NativeCapabilityBinding and its siblings): a foreign implementation carrying a dynamic native name or untyped argument map can never cross the BindCapability boundary.
func LookupCapabilityBinding ¶
func LookupCapabilityBinding[In, Out any]( contract RuntimeContract, capability ir.Capability[In, Out], ) (CapabilityRuntimeBinding[In, Out], error)
LookupCapabilityBinding resolves the external capability binding contributed for capability. The capability's exact contract version must fall within the contribution's bound range, and its codecs must match the contributed binding.
func MediatedCapabilityBinding ¶
func MediatedCapabilityBinding[In, Out any](capability ir.Capability[In, Out], lowering MediatedLowering) (CapabilityRuntimeBinding[In, Out], error)
MediatedCapabilityBinding builds a parent-mediated capability binding.
func NativeCapabilityBinding ¶
func NativeCapabilityBinding[In, Out any](capability ir.Capability[In, Out], call NativeCall) (CapabilityRuntimeBinding[In, Out], error)
NativeCapabilityBinding builds a native capability binding.
func SemanticCapabilityBinding ¶
func SemanticCapabilityBinding[In, Out any](capability ir.Capability[In, Out], lowering SemanticLowering) (CapabilityRuntimeBinding[In, Out], error)
SemanticCapabilityBinding builds a semantic-instruction capability binding.
type CapabilityVersionRange ¶
type CapabilityVersionRange struct {
// contains filtered or unexported fields
}
CapabilityVersionRange is an inclusive range over ir.CapabilityContractVersion values (MAJOR.MINOR.PATCH). BindCapability uses it to bound which capability contract versions a contribution honors, and to intersect against the requested capability's exact version.
func NewCapabilityVersionRange ¶
func NewCapabilityVersionRange(min, max ir.CapabilityContractVersion) (CapabilityVersionRange, error)
NewCapabilityVersionRange returns an inclusive [min, max] capability-version range. Both bounds must be well-formed MAJOR.MINOR.PATCH triples and min must not exceed max.
func NewExactCapabilityVersion ¶
func NewExactCapabilityVersion(version ir.CapabilityContractVersion) (CapabilityVersionRange, error)
NewExactCapabilityVersion returns a range accepting exactly one capability contract version.
func (CapabilityVersionRange) Includes ¶
func (r CapabilityVersionRange) Includes(version ir.CapabilityContractVersion) bool
Includes reports whether version falls within the inclusive range.
func (CapabilityVersionRange) Intersects ¶
func (r CapabilityVersionRange) Intersects(other CapabilityVersionRange) bool
Intersects reports whether two ranges overlap.
func (CapabilityVersionRange) IsValid ¶
func (r CapabilityVersionRange) IsValid() bool
func (CapabilityVersionRange) Max ¶
func (r CapabilityVersionRange) Max() ir.CapabilityContractVersion
func (CapabilityVersionRange) Min ¶
func (r CapabilityVersionRange) Min() ir.CapabilityContractVersion
type ClaudeLifecycleEvent ¶
type ClaudeLifecycleEvent uint8
ClaudeLifecycleEvent is the closed native event catalog for the pinned Claude Code lifecycle profile. Its numeric representation prevents arbitrary native event strings from entering the semantic mapping API.
const ( ClaudeEventSessionStart ClaudeLifecycleEvent = iota + 1 ClaudeEventSetup ClaudeEventSessionEnd ClaudeEventUserPromptSubmit ClaudeEventUserPromptExpansion ClaudeEventStop ClaudeEventStopFailure ClaudeEventPreToolUse ClaudeEventPermissionRequest ClaudeEventPermissionDenied ClaudeEventPostToolUse ClaudeEventPostToolUseFailure ClaudeEventPostToolBatch ClaudeEventFileChanged ClaudeEventCwdChanged ClaudeEventConfigChange ClaudeEventInstructionsLoaded ClaudeEventWorktreeCreate ClaudeEventWorktreeRemove ClaudeEventSubagentStart ClaudeEventSubagentStop ClaudeEventTeammateIdle ClaudeEventTaskCreated ClaudeEventTaskCompleted ClaudeEventPreCompact ClaudeEventPostCompact ClaudeEventNotification ClaudeEventMessageDisplay ClaudeEventElicitation ClaudeEventElicitationResult ClaudeEventPreModelSwitch ClaudeEventPostModelSwitch ClaudeEventDirectoryAdded )
func ClaudeLifecycleEvents ¶
func ClaudeLifecycleEvents() []ClaudeLifecycleEvent
ClaudeLifecycleEvents returns the deterministic native catalog order used by codegen. The returned slice is a fresh copy.
func (ClaudeLifecycleEvent) IsValid ¶
func (e ClaudeLifecycleEvent) IsValid() bool
func (ClaudeLifecycleEvent) NativeName ¶
func (e ClaudeLifecycleEvent) NativeName() string
func (ClaudeLifecycleEvent) String ¶
func (e ClaudeLifecycleEvent) String() string
type CodexLifecycleEvent ¶
type CodexLifecycleEvent uint8
CodexLifecycleEvent is the closed native event catalog for the pinned Codex CLI lifecycle profile.
const ( CodexEventSessionStart CodexLifecycleEvent = iota + 1 CodexEventUserPromptSubmit CodexEventPreToolUse CodexEventPermissionRequest CodexEventPostToolUse CodexEventPreCompact CodexEventPostCompact CodexEventSubagentStart CodexEventSubagentStop CodexEventStop CodexEventSessionEnd CodexEventInterrupt )
func CodexLifecycleEvents ¶
func CodexLifecycleEvents() []CodexLifecycleEvent
CodexLifecycleEvents returns the deterministic native catalog order used by codegen. The returned slice is a fresh copy.
func (CodexLifecycleEvent) IsValid ¶
func (e CodexLifecycleEvent) IsValid() bool
func (CodexLifecycleEvent) NativeName ¶
func (e CodexLifecycleEvent) NativeName() string
func (CodexLifecycleEvent) String ¶
func (e CodexLifecycleEvent) String() string
type CoreOperationDescriptor ¶
type CoreOperationDescriptor = ir.OperationDescriptor[OrchestrationRequest, OrchestrationResult]
CoreOperationDescriptor is the shared typed descriptor kind for every pinned core operation. Every profile classifies exactly this descriptor set, so a caller looks operations up with the same descriptors the contracts registered.
func CoreOperationDescriptorFor ¶
func CoreOperationDescriptorFor(kind ir.OperationKind) (CoreOperationDescriptor, bool)
CoreOperationDescriptorFor returns the shared descriptor for a core operation kind, so callers look bindings up with the exact descriptor the pinned contracts registered.
type CoreRuntimeBindings ¶
type CoreRuntimeBindings struct {
// contains filtered or unexported fields
}
CoreRuntimeBindings is the exhaustive classification of the closed core orchestration vocabulary plus the modeled effects a contract lowers. Every core operation kind (see ir.AllOperationKinds) must be bound exactly once, to exactly one runtime class, so a contract can never be missing a plan for a core operation. Effect descriptors are open-ended and are required only to be unique.
func NewCoreRuntimeBindings ¶
func NewCoreRuntimeBindings(operations []OperationBinding, effectBindings []EffectBinding) (CoreRuntimeBindings, error)
NewCoreRuntimeBindings validates that operations cover every core operation kind exactly once and that effects are unique, then returns the immutable core binding set.
func (CoreRuntimeBindings) IsValid ¶
func (b CoreRuntimeBindings) IsValid() bool
type EffectBinding ¶
type EffectBinding struct {
// contains filtered or unexported fields
}
EffectBinding is the opaque, type-erased binding for one typed effect descriptor, produced by the NativeEffectBinding family.
func MediatedEffectBinding ¶
func MediatedEffectBinding[In, Out any](descriptor ir.EffectDescriptor[In, Out], lowering MediatedLowering) (EffectBinding, error)
MediatedEffectBinding classifies an effect as parent-mediated.
func NativeEffectBinding ¶
func NativeEffectBinding[In, Out any](descriptor ir.EffectDescriptor[In, Out], call NativeCall) (EffectBinding, error)
NativeEffectBinding classifies an effect as executed directly by the host.
func SemanticEffectBinding ¶
func SemanticEffectBinding[In, Out any](descriptor ir.EffectDescriptor[In, Out], lowering SemanticLowering) (EffectBinding, error)
SemanticEffectBinding classifies an effect as a semantic instruction.
func UnsupportedEffectBinding ¶
func UnsupportedEffectBinding[In, Out any](descriptor ir.EffectDescriptor[In, Out], reason string) (EffectBinding, error)
UnsupportedEffectBinding classifies an effect as unsupported on this contract.
type EventSemantic ¶
type EventSemantic uint8
EventSemantic is the only Pasture meaning a native lifecycle occurrence may have. A native event never carries Pasture review or publication authority.
const ( SemanticObservation EventSemantic = iota + 1 SemanticGateConsultation SemanticExplicitHumanResponse )
func (EventSemantic) IsValid ¶
func (s EventSemantic) IsValid() bool
func (EventSemantic) String ¶
func (s EventSemantic) String() string
type FailureEvidence ¶ added in v0.0.9
type FailureEvidence struct {
Source string
}
FailureEvidence records WHERE the blocking behavior of a native failure mode was read from the host. A blocking exit code is a claim about somebody else's program, so it must cite its source.
Source is a host documentation URL or a path committed in this repository. An empty Source means "no evidence", and a row with no evidence never carries a blocking exit code: it runs as report-and-continue until its harness supplies the citation.
func (FailureEvidence) IsPresent ¶ added in v0.0.9
func (e FailureEvidence) IsPresent() bool
IsPresent reports whether the evidence cites a source. Whitespace alone is not a citation, so it reads as no evidence and keeps the row non-blocking.
type FailureMode ¶
type FailureMode uint8
FailureMode preserves native process or plugin failure behavior.
const ( FailureReportAndContinue FailureMode = iota + 1 FailureExitTwoBlocks FailureStrictHook FailureStrictExitTwoBlocks FailureThrowFailFast FailureObserveOnly )
func (FailureMode) BlocksByExitCode ¶ added in v0.0.9
func (m FailureMode) BlocksByExitCode() bool
BlocksByExitCode reports whether the mode makes the host REFUSE the native operation because the pasture hook process exited with the blocking exit code. Only the two exit-code arms do that: Claude Code reads exit 2 as "block", and the Codex strict-output contract reads it the same way.
The other four arms never turn a pasture process exit into a host refusal. report-and-continue and observe-only are non-blocking by definition. strict-hook-failure records a failed strict hook without blocking the operation.
throw-fail-fast IS a blocking behavior, and it is excluded for a reason worth stating exactly, because a later slice will act on it. The OpenCode plugin DOES read the process exit code — it throws on any non-zero exit — but that throw is how it reports a FAULT, not how a policy refuses: on that host a refusal is a typed object returned at exit 0. So the exit code is not the refusal channel there, and the citation rule, which exists to make a claim about somebody else's program cite its source, has nothing to add: the blocking behaviour of that surface is carried by pasture's OWN generated plugin, which is a committed artefact of this repository rather than a host documentation URL.
A capability derivation must therefore NOT reuse this predicate as its test for "does this row have a blocking channel". A pasture-owned channel is evidenceable in its own way, and keying a capability on this predicate would make every OpenCode named callback capability-free forever.
This predicate is the gate of the failure-evidence rule: only a mode that blocks by exit code may claim a blocking exit, and only with evidence.
func (FailureMode) IsValid ¶
func (m FailureMode) IsValid() bool
func (FailureMode) String ¶
func (m FailureMode) String() string
type HandlerOrder ¶
type HandlerOrder uint8
HandlerOrder preserves native handler scheduling. It does not impose a Pasture ordering or merge rule on concurrent host handlers.
const ( OrderConcurrentNative HandlerOrder = iota + 1 OrderSequentialLoad OrderObservationStream )
func (HandlerOrder) IsValid ¶
func (o HandlerOrder) IsValid() bool
func (HandlerOrder) String ¶
func (o HandlerOrder) String() string
type HookSurface ¶
type HookSurface uint8
HookSurface identifies the exact native transport the generated adapter must implement. It is intentionally closed; codegen cannot register a new surface or select one by string at runtime.
const ( SurfaceClaudeCommandJSON HookSurface = iota + 1 SurfaceCodexStrictCommandJSON SurfaceOpenCodeNamedOutput SurfaceOpenCodeCatchAllSSE )
func (HookSurface) IsValid ¶
func (s HookSurface) IsValid() bool
func (HookSurface) String ¶
func (s HookSurface) String() string
type HostVersion ¶
type HostVersion struct {
// contains filtered or unexported fields
}
HostVersion is a parsed, comparable harness host version. It follows semantic versioning precedence: a release triple MAJOR.MINOR.PATCH, an optional dot-separated prerelease series (which lowers precedence below the same release), and optional build metadata (which never changes precedence). It is opaque and constructor-owned: the only way to produce a non-zero value is ParseHostVersion, so a HostVersion in hand always parsed cleanly and a contract never has to re-parse a raw, possibly-garbage version string.
func ParseHostVersion ¶
func ParseHostVersion(value string) (HostVersion, error)
ParseHostVersion parses one harness host version. It accepts a leading "v" (so `v2.1.261` and `2.1.261` are the same version), a MAJOR.MINOR.PATCH triple, an optional `-prerelease` series, and optional `+build` metadata. It rejects empty, padded, or otherwise unparsable output actionably rather than letting a garbage string silently compare as some default version.
func (HostVersion) HasPrerelease ¶
func (v HostVersion) HasPrerelease() bool
HasPrerelease reports whether the version carries a prerelease series, which a constraint must explicitly include before it matches.
func (HostVersion) IsValid ¶
func (v HostVersion) IsValid() bool
func (HostVersion) Release ¶ added in v0.0.9
func (v HostVersion) Release() (major, minor, patch uint64)
Release returns the MAJOR, MINOR and PATCH release components. A caller that derives a coarser identity from a version (a "MAJOR.MINOR" family, for example) reads them here instead of re-parsing String().
func (HostVersion) String ¶
func (v HostVersion) String() string
String renders the version in canonical form. Build metadata is preserved for display but never participates in precedence.
type IdentityPolicy ¶ added in v0.0.9
type IdentityPolicy uint8
IdentityPolicy is a TABLE LABEL over a lifecycle row's declared identities. It has NO waist effect: it decides nothing about how an event lands. An IdentityPolicyNone row declares no identities, lands as an occurrence with zero identities and no correlation key, is ordered by ingress sequence only, and never produces an unresolved fact. The label is DERIVED from the identities column rather than stored beside it, so it cannot disagree with the column it describes.
const ( IdentityPolicyInvalid IdentityPolicy = iota // IdentityPolicyNone marks a row that declares no correlation identity. IdentityPolicyNone // IdentityPolicyDeclared marks a row that declares at least one. IdentityPolicyDeclared )
func (IdentityPolicy) IsValid ¶ added in v0.0.9
func (p IdentityPolicy) IsValid() bool
func (IdentityPolicy) String ¶ added in v0.0.9
func (p IdentityPolicy) String() string
type LifecycleContract ¶
type LifecycleContract[E comparable] struct { // contains filtered or unexported fields }
LifecycleContract is an immutable, exact-version native event table. E is a harness-specific uint enum, so callers cannot look up events by arbitrary string. There is no public constructor or registration API; the only values are the three reviewed static profiles in lifecycle_profiles.go.
func ClaudeCode2_1_261Lifecycle ¶ added in v0.0.9
func ClaudeCode2_1_261Lifecycle() LifecycleContract[ClaudeLifecycleEvent]
ClaudeCode2_1_261Lifecycle returns the immutable Claude Code lifecycle table bound to the same exact host version and RuntimeContractID as ClaudeCode2_1_261.
func Codex0_153_0Lifecycle ¶ added in v0.0.9
func Codex0_153_0Lifecycle() LifecycleContract[CodexLifecycleEvent]
Codex0_153_0Lifecycle returns the immutable Codex CLI lifecycle table bound to the same exact host version and RuntimeContractID as Codex0_153_0.
func OpenCode1_18_29Lifecycle ¶ added in v0.0.9
func OpenCode1_18_29Lifecycle() LifecycleContract[OpenCodeLifecycleEvent]
OpenCode1_18_29Lifecycle returns the immutable OpenCode lifecycle table bound to the same exact host version and RuntimeContractID as OpenCode1_18_29.
func OpenCode2_0_20Lifecycle ¶ added in v0.0.9
func OpenCode2_0_20Lifecycle() LifecycleContract[OpenCode2LifecycleEvent]
OpenCode2_0_20Lifecycle returns the immutable OpenCode 2.0.20 lifecycle table bound to the same exact host version and RuntimeContractID as OpenCode2_0_20.
func (LifecycleContract[E]) Events ¶
func (c LifecycleContract[E]) Events() []E
func (LifecycleContract[E]) Harness ¶
func (c LifecycleContract[E]) Harness() ir.HarnessID
func (LifecycleContract[E]) ID ¶
func (c LifecycleContract[E]) ID() ir.RuntimeContractID
func (LifecycleContract[E]) IsValid ¶
func (c LifecycleContract[E]) IsValid() bool
func (LifecycleContract[E]) Mapping ¶
func (c LifecycleContract[E]) Mapping(event E) (LifecycleEventMapping, error)
Mapping returns immutable generation metadata for one typed native event. Missing or zero event values fail actionably; there is deliberately no string lookup counterpart.
func (LifecycleContract[E]) Supports ¶
func (c LifecycleContract[E]) Supports(version HostVersion) bool
func (LifecycleContract[E]) Versions ¶
func (c LifecycleContract[E]) Versions() VersionConstraint
type LifecycleEventMapping ¶
type LifecycleEventMapping struct {
// contains filtered or unexported fields
}
LifecycleEventMapping is immutable generation metadata for one native event. It deliberately contains no native payload and no Pasture command input. In particular, it cannot transport review/publication authority or manufacture a decision from the occurrence of a tool, permission, stop, catch-all, or SSE event.
func OpenCode2PermissionEvaluateCited ¶ added in v0.0.9
func OpenCode2PermissionEvaluateCited(source string) (LifecycleEventMapping, error)
OpenCode2PermissionEvaluateCited builds the v2 permission.evaluate gate with the given response-channel citation, through the same derivation the pinned profile uses. The pinned profile passes the committed capture citation and derives CapabilityDeny; this constructor lets a caller rehearse the same derivation with another source. Encoder and report proofs exercise this constructor rather than a hand-built row, so the refusal they rehearse is the one production will emit.
func (LifecycleEventMapping) AskEvidence ¶ added in v0.0.9
func (m LifecycleEventMapping) AskEvidence() FailureEvidence
func (LifecycleEventMapping) Blocking ¶
func (m LifecycleEventMapping) Blocking() BlockingMode
func (LifecycleEventMapping) DeclaredFailure ¶ added in v0.0.9
func (m LifecycleEventMapping) DeclaredFailure() FailureMode
DeclaredFailure is the mode the host contract declares for this row, before the failure-evidence rule demotes an uncited blocking row. It is for explaining the row to a person. Failure remains the mode every behaviour obeys.
func (LifecycleEventMapping) DeclaredField ¶
func (m LifecycleEventMapping) DeclaredField(nativeName string) (NativeIdentityField, bool)
DeclaredField returns the declared native identity field with the exact native name, if the pinned mapping declares one. It is the single lookup used by every lifecycle frontend and by the waist L2 transform, replacing the four private findDeclaredField copies that previously drifted per package.
The match is by exact native spelling: correlation fields are never normalised, so an unpadded, case-sensitive equality is the only correct comparison. The returned NativeIdentityField is a value copy; callers cannot mutate the pinned mapping through it.
func (LifecycleEventMapping) Evidence ¶ added in v0.0.9
func (m LifecycleEventMapping) Evidence() FailureEvidence
func (LifecycleEventMapping) Failure ¶
func (m LifecycleEventMapping) Failure() FailureMode
func (LifecycleEventMapping) Identities ¶
func (m LifecycleEventMapping) Identities() []NativeIdentityField
func (LifecycleEventMapping) IdentityPolicy ¶ added in v0.0.9
func (m LifecycleEventMapping) IdentityPolicy() IdentityPolicy
IdentityPolicy labels this row by its declared identities. See IdentityPolicy.
func (LifecycleEventMapping) IsValid ¶ added in v0.0.9
func (m LifecycleEventMapping) IsValid() bool
IsValid rejects zero mappings and metadata not derived by a contract.
func (LifecycleEventMapping) Mutation ¶
func (m LifecycleEventMapping) Mutation() MutationMode
func (LifecycleEventMapping) NativeName ¶
func (m LifecycleEventMapping) NativeName() string
func (LifecycleEventMapping) Order ¶
func (m LifecycleEventMapping) Order() HandlerOrder
func (LifecycleEventMapping) PreAction ¶ added in v0.0.9
func (m LifecycleEventMapping) PreAction() bool
func (LifecycleEventMapping) Reconciliation ¶
func (m LifecycleEventMapping) Reconciliation() ReconciliationMode
func (LifecycleEventMapping) Response ¶ added in v0.0.9
func (m LifecycleEventMapping) Response() ResponseCapability
func (LifecycleEventMapping) Semantic ¶
func (m LifecycleEventMapping) Semantic() EventSemantic
func (LifecycleEventMapping) StopLoop ¶
func (m LifecycleEventMapping) StopLoop() StopLoopPolicy
func (LifecycleEventMapping) Surface ¶
func (m LifecycleEventMapping) Surface() HookSurface
func (LifecycleEventMapping) UnresolvedIdentities ¶
func (m LifecycleEventMapping) UnresolvedIdentities() []NativeIdentityKind
type LifecycleFailurePolicy ¶ added in v0.0.9
type LifecycleFailurePolicy struct {
// Mode is the EFFECTIVE failure mode of the row, after the failure-evidence
// rule. Every behaviour obeys this one.
Mode FailureMode
// DeclaredMode is the mode the host contract DECLARES for the row, before
// the evidence rule demotes an uncited blocking row to report-and-continue.
// It equals Mode on every row the rule does not demote.
//
// It is carried so that an EXPLANATION can tell an operator the truth about
// the declaration. A blocking row with no citation and a row that is
// declared report-and-continue are indistinguishable once the demotion has
// happened, and they need opposite advice: the first becomes blockable when
// somebody supplies the citation, the second can never block. Read this
// field only to explain the row; never to choose an exit status.
DeclaredMode FailureMode
Evidence FailureEvidence
// Semantic is the declared class of the event. It is carried here because
// the bytes a host reads as "proceed" depend on the class as well as on the
// harness: a Codex gate is refused unless the continuation says continue,
// while a Codex observation contributes no directives. The zero value means
// the event is not declared by this build, and the caller must not guess a
// class from it.
Semantic EventSemantic
// Blocking and Response come from the same validated runtime row as
// Evidence. Reports must not combine these with another catalogue's mode.
Blocking BlockingMode
Response ResponseCapability
}
LifecycleFailurePolicy is the declared failure behaviour of one native event: the mode the host contract says applies, the citation for a blocking exit code, and the event class the host reads the answer as.
func LookupLifecycleFailure ¶ added in v0.0.9
func LookupLifecycleFailure(harness ir.HarnessID, nativeName string) (LifecycleFailurePolicy, bool)
LookupLifecycleFailure returns the declared failure behaviour of one native event, by the harness and the exact native NAME.
The typed lifecycle contracts have no string lookup on purpose, so a caller cannot invent an event. This function is the ONE narrow exception, and it exists because a real host really does hand the hook a harness and an event NAME on the command line. It answers only this one question, it cannot reach identities, payload fields or ordering, and it returns false for a name no pinned profile declares, so the caller must decide what an unknown event means rather than receive a guess.
OpenCode pins two contract versions on one harness. The lookup tries the production 2.0.20 profile first and the historical 1.18.29 profile second: the three coordinates both versions share declare identical failure policies, so the order is unobservable there, and a 1.18.29-only coordinate still resolves to its declared row instead of the observe-only fallback. Callers that need version-exact rows (the lifecycle handler) resolve through their version-routed dispatch instead; this lookup serves the command-line fault policy, which is fixed before the host version is resolved, and the activation report, which renders one manifest at a time.
func (LifecycleFailurePolicy) Declared ¶ added in v0.0.9
func (p LifecycleFailurePolicy) Declared() bool
Declared reports whether a row of this build's registration declares the event this policy describes. Every declared row carries a valid Semantic — a lifecycle contract refuses a mapping without one, in LifecycleEventMapping.validate — and the one producer of an undeclared policy, the hook command's fallback for a coordinate this build cannot name, leaves it zero. It exists so a diagnostic or a durable record can say "undeclared" instead of calling the mode such a coordinate is treated as a declaration.
type MediatedLowering ¶
type MediatedLowering struct {
// contains filtered or unexported fields
}
MediatedLowering is the lowering a parent-mediated binding owns: the mediator that executes the effect on the agent's behalf, plus the exact instruction it carries out. A mediated binding proves semantic parity by carrying the descriptor's own preconditions, postconditions, result, and effect set (copied at construction), never a paraphrase.
func NewMediatedLowering ¶
func NewMediatedLowering(mediator, instruction string) (MediatedLowering, error)
NewMediatedLowering validates and constructs a parent-mediated lowering.
func (MediatedLowering) Instruction ¶
func (m MediatedLowering) Instruction() string
func (MediatedLowering) IsValid ¶
func (m MediatedLowering) IsValid() bool
func (MediatedLowering) Mediator ¶
func (m MediatedLowering) Mediator() string
type MutationMode ¶
type MutationMode uint8
MutationMode describes the only native payload mutation an adapter may return. Observation and explicit-human mappings always use MutationNone.
const ( MutationNone MutationMode = iota + 1 MutationInput MutationOutput MutationOutputObject )
func (MutationMode) IsValid ¶
func (m MutationMode) IsValid() bool
func (MutationMode) String ¶
func (m MutationMode) String() string
type NativeCall ¶
type NativeCall struct {
// contains filtered or unexported fields
}
NativeCall is the complete native lowering a native binding owns: the exact host call name, its declared argument names, the result/handle semantics, and how the call inherits assignment context. It is opaque and constructor-validated so a native binding can never carry an empty call name or an unnamed result contract.
func NewNativeCall ¶
func NewNativeCall(callName string, arguments []string, resultSemantics, contextInheritance string) (NativeCall, error)
NewNativeCall validates and constructs a native call lowering. callName and resultSemantics are required; arguments and contextInheritance describe the full request/result dataflow the native fixture must reproduce.
func (NativeCall) Arguments ¶
func (n NativeCall) Arguments() []string
func (NativeCall) CallName ¶
func (n NativeCall) CallName() string
func (NativeCall) ContextInheritance ¶
func (n NativeCall) ContextInheritance() string
func (NativeCall) IsValid ¶
func (n NativeCall) IsValid() bool
func (NativeCall) ResultSemantics ¶
func (n NativeCall) ResultSemantics() string
type NativeIdentityField ¶
type NativeIdentityField struct {
// contains filtered or unexported fields
}
NativeIdentityField is one native correlation field the generated adapter must forward byte-for-byte. It is opaque and has no public constructor, so a caller cannot add authority-bearing fields to a lifecycle mapping.
func (NativeIdentityField) IsValid ¶
func (f NativeIdentityField) IsValid() bool
func (NativeIdentityField) Kind ¶
func (f NativeIdentityField) Kind() NativeIdentityKind
func (NativeIdentityField) NativeName ¶
func (f NativeIdentityField) NativeName() string
func (NativeIdentityField) Required ¶
func (f NativeIdentityField) Required() bool
type NativeIdentityKind ¶
type NativeIdentityKind uint8
NativeIdentityKind identifies correlation data owned by the native harness. These values are not Pasture actors, assignments, decisions, journal IDs, revisions, review evidence, or publication evidence.
const ( IdentitySession NativeIdentityKind = iota + 1 IdentityTurn IdentityRequest IdentityToolCall IdentityAgent IdentityMessage )
func (NativeIdentityKind) IsValid ¶
func (k NativeIdentityKind) IsValid() bool
func (NativeIdentityKind) String ¶
func (k NativeIdentityKind) String() string
type OpenCode2LifecycleEvent ¶ added in v0.0.9
type OpenCode2LifecycleEvent uint8
OpenCode2LifecycleEvent is the closed event catalog for OpenCode 2.0.20: one session-start observation plus the plain definition hook surface the 2.0.20 source declares. It covers sixteen hooks (twelve session hooks, two tool hooks, one permission hook and one shell hook) and the session.created bus event that writes the session claim. The provider-SDK hooks (aisdk sdk, language) are provider wiring rather than lifecycle gates and are not modeled here.
Native names are the dotted coordinates the host emits: the session.created bus event carries the type from SessionEvent.Created in packages/schema/src/session-event.ts, and each hook coordinate is the domain the plugin registers through, a dot, and the hook name from the 2.0.20 plugin types. Session coordinates come from SessionHooks in packages/plugin/src/promise/session.ts, tool coordinates from ToolHooks in packages/plugin/src/promise/tool.ts, the permission coordinate from PermissionHooks in packages/plugin/src/promise/permission.ts, and the shell coordinate from ShellHooks in packages/plugin/src/promise/shell.ts (all at the v2.0.20 tag). Two coordinates repeat v1 native names ("session.created", "tool.execute.before", "tool.execute.after" — three in all); they are distinct typed events here with version-qualified symbols because their v2 payload shapes differ (the v2 session.created bus payload carries sessionID and version inside data where v1 carried event.properties.sessionID, and v2 tool hooks carry tool/sessionID/agent/messageID/id/input where v1 carried tool/sessionID/callID plus output args).
Identity follows the host's declared payload fields: every 2.0.20 session payload type declares a readonly sessionID, both ToolHooks declare sessionID plus the call id, and PermissionEvaluation declares sessionID, so every row below carries the session identity and both tool rows also carry the call identity. Only ShellCreateBefore declares no session field and carries none. These bindings are source-declared, not capture-proved: the committed OpenCode 2.0.20 capture sitting (with inventory, substitution, secret scan and clearance) upgrades them to proved coordinates when it lands.
The permission evaluate hook is the one v2 channel through which a plugin mutation reaches the host decision. The 2.0.20 host computes the ruleset effect, yields hooks.trigger("permission", "evaluate", {... effect}) and returns { effect: event.effect, message: event.message, rules } from evaluateInput in packages/core/src/permission.ts, so a plugin that sets event.effect to "deny" is honoured on the path where no saved or configured rule already denied (that path returns early without firing the hook). That channel is capture-measured: the committed OpenCode 2.0.21 deny sitting (named in the row's citation) shows the host surfacing pasture's deny as a Permission.BlockedError with the durable reason and not running the tool. Every other row below therefore carries no response-channel evidence and derives CapabilityNone, exactly like the v1 rows; permission.evaluate carries that citation and derives CapabilityDeny. The named builder carries the evidence as data, so the flip was a supplied value and not a derivation change.
const ( OpenCode2EventSessionCreated OpenCode2LifecycleEvent = iota + 1 OpenCode2EventSessionPrompt OpenCode2EventSessionContext OpenCode2EventSessionCompaction OpenCode2EventSessionGenerate OpenCode2EventSessionTitle OpenCode2EventSessionModelRequest OpenCode2EventSessionHTTPRequest OpenCode2EventSessionHTTPResponse OpenCode2EventSessionExperimentalWSHandshake OpenCode2EventSessionExperimentalWSSend OpenCode2EventSessionExperimentalWSReceive OpenCode2EventSessionRetry OpenCode2EventToolExecuteBefore OpenCode2EventToolExecuteAfter OpenCode2EventPermissionEvaluate OpenCode2EventShellCreateBefore )
func OpenCode2LifecycleEvents ¶ added in v0.0.9
func OpenCode2LifecycleEvents() []OpenCode2LifecycleEvent
OpenCode2LifecycleEvents returns the deterministic native catalog order used by codegen. The returned slice is a fresh copy.
func (OpenCode2LifecycleEvent) IsValid ¶ added in v0.0.9
func (e OpenCode2LifecycleEvent) IsValid() bool
func (OpenCode2LifecycleEvent) NativeName ¶ added in v0.0.9
func (e OpenCode2LifecycleEvent) NativeName() string
func (OpenCode2LifecycleEvent) String ¶ added in v0.0.9
func (e OpenCode2LifecycleEvent) String() string
type OpenCodeLifecycleEvent ¶
type OpenCodeLifecycleEvent uint8
OpenCodeLifecycleEvent is the closed native named-hook and event-bus catalog for the pinned OpenCode lifecycle profile.
const ( OpenCodeEventCommandExecuted OpenCodeLifecycleEvent = iota + 1 OpenCodeEventFileEdited OpenCodeEventFileWatcherUpdated OpenCodeEventInstallationUpdated OpenCodeEventInstallationUpdateAvailable OpenCodeEventLSPClientDiagnostics OpenCodeEventLSPUpdated OpenCodeEventMessageUpdated OpenCodeEventMessageRemoved OpenCodeEventMessagePartUpdated OpenCodeEventMessagePartRemoved OpenCodeEventPermissionUpdated OpenCodeEventPermissionReplied OpenCodeEventServerConnected OpenCodeEventServerInstanceDisposed OpenCodeEventSessionCreated OpenCodeEventSessionUpdated OpenCodeEventSessionDeleted OpenCodeEventSessionCompacted OpenCodeEventSessionDiff OpenCodeEventSessionError OpenCodeEventSessionIdle OpenCodeEventSessionStatus OpenCodeEventTodoUpdated OpenCodeEventTUIPromptAppend OpenCodeEventTUICommandExecute OpenCodeEventTUIToastShow OpenCodeEventPTYCreated OpenCodeEventPTYUpdated OpenCodeEventPTYExited OpenCodeEventPTYDeleted OpenCodeEventVCSBranchUpdated OpenCodeEventChatMessage OpenCodeEventChatParams OpenCodeEventChatHeaders OpenCodeEventPermissionAsk OpenCodeEventCommandExecuteBefore OpenCodeEventToolExecuteBefore OpenCodeEventShellEnv OpenCodeEventToolExecuteAfter OpenCodeEventExperimentalChatMessagesTransform OpenCodeEventExperimentalChatSystemTransform OpenCodeEventExperimentalProviderSmallModel OpenCodeEventExperimentalSessionCompacting OpenCodeEventExperimentalCompactionAutocontinue OpenCodeEventExperimentalTextComplete OpenCodeEventToolDefinition )
func OpenCodeLifecycleEvents ¶
func OpenCodeLifecycleEvents() []OpenCodeLifecycleEvent
OpenCodeLifecycleEvents returns the deterministic native catalog order used by codegen. The returned slice is a fresh copy.
func (OpenCodeLifecycleEvent) IsValid ¶
func (e OpenCodeLifecycleEvent) IsValid() bool
func (OpenCodeLifecycleEvent) NativeName ¶
func (e OpenCodeLifecycleEvent) NativeName() string
func (OpenCodeLifecycleEvent) String ¶
func (e OpenCodeLifecycleEvent) String() string
type OperationBinding ¶
type OperationBinding struct {
// contains filtered or unexported fields
}
OperationBinding is the opaque, type-erased binding for one semantic operation descriptor, produced by the NativeOperationBinding family and collected by NewCoreRuntimeBindings. It carries the descriptor's identity, codecs, semantics, effects, and its exhaustive runtime classification.
func MediatedOperationBinding ¶
func MediatedOperationBinding[In, Out any](descriptor ir.OperationDescriptor[In, Out], lowering MediatedLowering) (OperationBinding, error)
MediatedOperationBinding classifies a semantic operation as parent-mediated.
func NativeOperationBinding ¶
func NativeOperationBinding[In, Out any](descriptor ir.OperationDescriptor[In, Out], call NativeCall) (OperationBinding, error)
NativeOperationBinding classifies a semantic operation as executed directly by the host runtime, owning the complete native call, arguments, result semantics, and context inheritance.
func SemanticOperationBinding ¶
func SemanticOperationBinding[In, Out any](descriptor ir.OperationDescriptor[In, Out], lowering SemanticLowering) (OperationBinding, error)
SemanticOperationBinding classifies a semantic operation as a semantic-instruction the agent must carry out.
func UnsupportedOperationBinding ¶
func UnsupportedOperationBinding[In, Out any](descriptor ir.OperationDescriptor[In, Out], reason string) (OperationBinding, error)
UnsupportedOperationBinding classifies a semantic operation as unsupported on this contract. A later lookup fails actionably with reason; it never falls through to a similarly named native call.
type OrchestrationRequest ¶
type OrchestrationRequest struct {
Operation string `json:"operation"`
Arguments map[string]string `json:"arguments"`
}
OrchestrationRequest is the typed request shape the pinned core operation descriptors carry. It is deliberately simple and JSON-round-trippable so a native binding's fixtures validate a full request shape, not a paraphrase.
type OrchestrationResult ¶
type OrchestrationResult struct {
Status string `json:"status"`
Handles map[string]string `json:"handles"`
}
OrchestrationResult is the typed result shape the pinned core operation descriptors carry.
type ReconciliationMode ¶
type ReconciliationMode uint8
ReconciliationMode specifies who reconciles multiple native handler results. ReconcileNoAdapterMerge is load-bearing for Codex: generated adapters must preserve concurrency without inventing a Pasture merge lattice.
const ( ReconcileNone ReconciliationMode = iota + 1 ReconcileHostNative ReconcileNoAdapterMerge ReconcileSequentialMutation )
func (ReconciliationMode) IsValid ¶
func (m ReconciliationMode) IsValid() bool
func (ReconciliationMode) String ¶
func (m ReconciliationMode) String() string
type ResponseCapability ¶ added in v0.0.9
type ResponseCapability uint8
ResponseCapability is the evidenced response channel of a pre-action gate. Unset means derivation has not run; None means it ran and found no channel. A capability is not activation permission and does not enable a transport.
const ( CapabilityUnset ResponseCapability = iota CapabilityNone CapabilityDeny CapabilityDenyAsk )
func (ResponseCapability) AllowsAsk ¶ added in v0.0.9
func (c ResponseCapability) AllowsAsk() bool
func (ResponseCapability) AllowsDeny ¶ added in v0.0.9
func (c ResponseCapability) AllowsDeny() bool
func (ResponseCapability) IsValid ¶ added in v0.0.9
func (c ResponseCapability) IsValid() bool
func (ResponseCapability) String ¶ added in v0.0.9
func (c ResponseCapability) String() string
type RuntimeBinding ¶
type RuntimeBinding[In, Out any] interface { // Class reports the executable runtime class (never unsupported). Class() effects.RuntimeClass // DescriptorID returns the descriptor identity string. It is metadata only: // it is not a lookup operand and cannot be used to fetch a binding. DescriptorID() string InputSchema() ir.SchemaID OutputSchema() ir.SchemaID // Semantics returns the preconditions/postconditions/result the binding // proves. For mediated and semantic bindings these are the descriptor's own // semantics, copied at construction, not a paraphrase. Semantics() ir.DescriptorSemantics Effects() ir.EffectSet // Native, Mediated, and Semantic expose the class-specific lowering. Exactly // one returns ok == true, matching Class. Native() (NativeCall, bool) Mediated() (MediatedLowering, bool) Semantic() (SemanticLowering, bool) // contains filtered or unexported methods }
RuntimeBinding is the typed result of a successful operation or effect lookup. It is always one of the three executable classes — native, parent-mediated, or semantic-instruction; an unsupported classification never yields a binding, it yields an actionable lookup error. The In/Out type parameters are re-attached at lookup time from the descriptor, so a binding value always agrees with the descriptor that produced it.
func LookupEffectBinding ¶
func LookupEffectBinding[In, Out any]( contract RuntimeContract, descriptor ir.EffectDescriptor[In, Out], ) (RuntimeBinding[In, Out], error)
LookupEffectBinding resolves the runtime binding for a typed effect descriptor with the same guarantees as LookupOperationBinding.
func LookupOperationBinding ¶
func LookupOperationBinding[In, Out any]( contract RuntimeContract, descriptor ir.OperationDescriptor[In, Out], ) (RuntimeBinding[In, Out], error)
LookupOperationBinding resolves the runtime binding for a semantic operation descriptor. The operand is a constructor-validated typed descriptor, never a raw ID, string, or untyped literal. Missing, invalid, type-incompatible, or unsupported descriptors return an actionable error; none collapses into a nil or zero binding.
type RuntimeBindingContribution ¶
type RuntimeBindingContribution interface {
// contains filtered or unexported methods
}
RuntimeBindingContribution is the opaque, heterogeneous contribution BindCapability produces and NewRuntimeContract consumes. Its marker method is unexported so no dynamic native name or untyped argument map can masquerade as a contribution; the only source is BindCapability.
func BindCapability ¶
func BindCapability[In, Out any]( capability ir.Capability[In, Out], versions CapabilityVersionRange, binding CapabilityRuntimeBinding[In, Out], ) (RuntimeBindingContribution, error)
BindCapability contributes a version-bounded runtime binding for one opaque capability descriptor without editing this package. It validates the descriptor's codecs, semantics, and effect set (already enforced by ir.DefineCapability), and the version intersection: the requested capability's exact contract version must fall within versions. The resulting contribution is opaque; NewRuntimeContract validates it further against the full requested-capability set.
type RuntimeContract ¶
type RuntimeContract struct {
// contains filtered or unexported fields
}
RuntimeContract is the opaque, version-bounded profile that lowers protocol semantic operations, effects, and capabilities to native runtime behavior for exactly one harness. The only way to produce a non-zero value is NewRuntimeContract, so a contract in hand has already passed identity, version, exhaustive-core, and contribution validation.
func ClaudeCode2_1_261 ¶ added in v0.0.9
func ClaudeCode2_1_261() RuntimeContract
ClaudeCode2_1_261 is the runtime contract for Claude Code at the recorded host version, the one its id carries (artifact.ProductionRuntimeContract). Admission is a floor: that version and every later release. Its native bindings name only Agent/SendMessage/TaskStop-era tools; it never names a removed team-lifecycle call (TeamCreate/TeamDelete). Any schema or semantic change to this profile requires a new RuntimeContractID.
func Codex0_153_0 ¶ added in v0.0.9
func Codex0_153_0() RuntimeContract
Codex0_153_0 is the runtime contract for Codex at the recorded host version, the one its id carries (artifact.ProductionRuntimeContract). Admission is a floor: that version and every later release. It binds a native call only where this contract declares one; every other operation is parent-mediated or lowered as a semantic instruction rather than invented. The instruction texts state what THIS CONTRACT binds; they make no claim about what the host does or does not expose, because a claim about the host cannot be held true by a version bump.
func NewRuntimeContract ¶
func NewRuntimeContract( id ir.RuntimeContractID, harness ir.HarnessID, versions VersionConstraint, core CoreRuntimeBindings, capabilities ...RuntimeBindingContribution, ) (RuntimeContract, error)
NewRuntimeContract validates and constructs a runtime contract. harness must match the harness encoded in id. Each capability contribution is required at most once; duplicate or conflicting contributions fail before construction.
func OpenCode1_18_29 ¶ added in v0.0.9
func OpenCode1_18_29() RuntimeContract
OpenCode1_18_29 is the historical runtime contract for OpenCode 1.18.29. It is NOT the production profile: its identity (opencode@1.18.29) and its floor (1.18.29) are frozen here rather than read from artifact.ProductionRuntimeContract, so it stays the contract the v1 dispatch row and the recorded 1.18.29 corpus evidence were proved against after the production profile moved to OpenCode2_0_20. It uses only OpenCode's documented skill/task/question surfaces. It never invents a persistent-message, follow-up, wait, or close tool: operations with no documented native surface are lowered as semantic instructions, and stopping an assignment is explicitly unsupported rather than a fabricated close call.
func OpenCode2_0_20 ¶ added in v0.0.9
func OpenCode2_0_20() RuntimeContract
OpenCode2_0_20 is the production runtime contract for OpenCode, at the recorded host version its id carries (artifact.ProductionRuntimeContract). Admission is a floor: that version and every later release. It classifies the same core operation surface as the historical 1.18.29 contract: the v2 plugin API replaces hook registration while the native skill, task and question tools keep their names, so the operation lowerings are unchanged.
func PinnedContracts ¶
func PinnedContracts() []RuntimeContract
PinnedContracts returns the three runtime contracts, one per enabled harness, each admitting its recorded host version and every later release.
func (RuntimeContract) Harness ¶
func (c RuntimeContract) Harness() ir.HarnessID
Harness returns the enabled harness this contract lowers for.
func (RuntimeContract) ID ¶
func (c RuntimeContract) ID() ir.RuntimeContractID
ID returns the contract's version-bounded identity.
func (RuntimeContract) IsValid ¶
func (c RuntimeContract) IsValid() bool
IsValid reports whether the contract was constructed by NewRuntimeContract.
func (RuntimeContract) Supports ¶
func (c RuntimeContract) Supports(version HostVersion) bool
Supports reports whether the contract accepts version. An unparsable or zero host version, an out-of-range version, or a prerelease the constraint does not explicitly include is unsupported.
func (RuntimeContract) Versions ¶
func (c RuntimeContract) Versions() VersionConstraint
Versions returns the version constraint the contract accepts.
type SemanticLowering ¶
type SemanticLowering struct {
// contains filtered or unexported fields
}
SemanticLowering is the lowering a semantic-instruction binding owns: the instruction template the agent must carry out. Like a mediated binding, it proves parity by carrying the descriptor's own semantics and effect set.
func NewSemanticLowering ¶
func NewSemanticLowering(instructionTemplate string) (SemanticLowering, error)
NewSemanticLowering validates and constructs a semantic-instruction lowering.
func (SemanticLowering) InstructionTemplate ¶
func (s SemanticLowering) InstructionTemplate() string
func (SemanticLowering) IsValid ¶
func (s SemanticLowering) IsValid() bool
type StopLoopPolicy ¶
type StopLoopPolicy uint8
StopLoopPolicy records whether a Stop-family event carries host loop state. ConsultWhenInactive prevents a generated adapter from re-blocking the stop hook invocation that was itself triggered by an earlier block.
const ( StopLoopNotApplicable StopLoopPolicy = iota + 1 StopLoopConsultWhenInactive )
func (StopLoopPolicy) IsValid ¶
func (p StopLoopPolicy) IsValid() bool
func (StopLoopPolicy) String ¶
func (p StopLoopPolicy) String() string
type VersionConstraint ¶
type VersionConstraint struct {
// contains filtered or unexported fields
}
VersionConstraint is a host-version admission bounded by semantic-version precedence, in one of two shapes, plus an explicit prerelease-inclusion policy:
- a closed, inclusive range [min, max] (NewVersionConstraint); a pinned point contract sets min == max (NewExactVersion);
- an open floor "at or above min" with no upper bound (NewVersionFloor), so every later release of the host is admitted without a re-pin.
Prereleases are matched only when the constraint explicitly includes them, so an unreleased build never silently satisfies a stable contract. A floor never includes prereleases: a prerelease of a release above the floor is not that release.
func NewExactVersion ¶
func NewExactVersion(version HostVersion) (VersionConstraint, error)
NewExactVersion returns a constraint that accepts exactly one release version. It is the constructor for the initial pinned point ranges.
func NewVersionConstraint ¶
func NewVersionConstraint(min, max HostVersion, includePrereleases bool) (VersionConstraint, error)
NewVersionConstraint returns an inclusive [min, max] host-version range. includePrereleases governs whether prerelease host versions are eligible at all. min must not exceed max by precedence.
func NewVersionFloor ¶ added in v0.0.9
func NewVersionFloor(min HostVersion) (VersionConstraint, error)
NewVersionFloor returns a constraint that accepts min and every release with higher precedence, with no upper bound. It is the admission shape for a host contract whose recorded version is a baseline: the host is allowed to move forward, and a host below the recorded version is refused. Prereleases are never admitted by a floor. HasUpperBound reports false for the result, and Max returns the zero HostVersion, so a caller that needs an upper bound must ask before it reads one.
func (VersionConstraint) Allows ¶
func (c VersionConstraint) Allows(version HostVersion) bool
Allows reports whether version satisfies the constraint. A prerelease host is eligible only when the constraint explicitly includes prereleases; build metadata never changes the decision. A floor admits min and every release above it; a closed range admits min through max inclusive.
func (VersionConstraint) Describe ¶ added in v0.0.9
func (c VersionConstraint) Describe() string
Describe spells the admission for a reader who must act on it: "exactly X" for a pinned point, "from X through Y" for a closed range, and "at or above X" for a floor. Diagnostics quote this text rather than a hand-written number, so the text follows the contract when the contract moves.
func (VersionConstraint) HasUpperBound ¶ added in v0.0.9
func (c VersionConstraint) HasUpperBound() bool
HasUpperBound reports whether the constraint is a closed range (true) or an open floor (false).
func (VersionConstraint) IncludesPrereleases ¶
func (c VersionConstraint) IncludesPrereleases() bool
IncludesPrereleases reports the prerelease-inclusion policy.
func (VersionConstraint) IsValid ¶
func (c VersionConstraint) IsValid() bool
func (VersionConstraint) Max ¶
func (c VersionConstraint) Max() HostVersion
Max returns the inclusive upper bound of a closed range. A floor has no upper bound, so Max returns the zero HostVersion for it; check HasUpperBound first.
func (VersionConstraint) Min ¶
func (c VersionConstraint) Min() HostVersion
Min returns the inclusive lower bound of either shape.