Documentation
¶
Index ¶
- Constants
- func IsRecoverableTerminalValidationError(err error) bool
- func NewRecoverableTerminalValidationError() error
- func ReasonAllowed(stage Stage, reason ReasonCode) bool
- type BindError
- type BindErrorKind
- type Bindings
- type BoundDefinition
- type BoundEvidenceTool
- func (b BoundEvidenceTool) DescriptionSHA256() [sha256.Size]byte
- func (b BoundEvidenceTool) IdentitySHA256() [sha256.Size]byte
- func (b BoundEvidenceTool) Info() *tool.ToolInfo
- func (b BoundEvidenceTool) Name() string
- func (b BoundEvidenceTool) SchemaSHA256() [sha256.Size]byte
- func (b BoundEvidenceTool) Tool() tool.InvokableTool
- type Definition
- func (d Definition) Bind(ctx context.Context, bindings Bindings) (BoundDefinition, error)
- func (d Definition) Descriptor() DefinitionDescriptor
- func (d Definition) EvidenceToolPolicy() (EvidenceToolPolicy, bool)
- func (d Definition) Limits() Limits
- func (d Definition) Name() Name
- func (d Definition) Participation() Participation
- func (d Definition) PolicyRevision() string
- func (d Definition) RetryPolicy() RetryPolicy
- func (d Definition) Timeout() time.Duration
- type DefinitionDescriptor
- type DefinitionError
- type DefinitionErrorKind
- type EvidenceBindings
- type EvidenceToolPolicy
- type InferenceBinding
- type Limits
- type ModelResolver
- type ModelSource
- type Name
- type Option
- func WithCurrentLoopModel() Option
- func WithEvidenceTools(policy EvidenceToolPolicy) Option
- func WithLimits(limits Limits) Option
- func WithName(name Name) Option
- func WithNamedInference(client inference.Client, model model.Model) Option
- func WithOutputSchema(output inference.OutputSchema) Option
- func WithParticipation(participation Participation) Option
- func WithPolicyRevision(revision string) Option
- func WithRetryPolicy(policy RetryPolicy) Option
- func WithSystemPrompt(prompt, revision string) Option
- func WithTimeout(timeout time.Duration) Option
- type Outcome
- type Participation
- type ReasonCode
- type Request
- type ResolveError
- type ResolveErrorKind
- type Result
- type RetryPolicy
- type RevisionError
- type RunID
- type Stage
- type TerminalStatus
- type ToolLoopLimits
Constants ¶
const ( // MaxEvidenceToolDefinitions bounds the number of definitions in one // evidence policy before any catalog-sized allocation or digest work. MaxEvidenceToolDefinitions = 64 // MaxEvidenceProducedToolNames bounds all concrete tool names declared by // one evidence policy, including names spread across bundle definitions. MaxEvidenceProducedToolNames = 128 // MaxEvidenceToolNameBytes bounds definition and concrete tool names by // encoded UTF-8 bytes, not runes. MaxEvidenceToolNameBytes = 64 // MaxEvidenceToolPolicyRevisionBytes bounds the canonical policy revision // by encoded UTF-8 bytes. MaxEvidenceToolPolicyRevisionBytes = 128 )
const ( // MaxEvidenceToolDescriptionBytes bounds each concrete tool description // by encoded UTF-8 bytes before the metadata is retained or fingerprinted. MaxEvidenceToolDescriptionBytes = 4 << 10 // MaxEvidenceToolSchemaBytes bounds each concrete tool's raw JSON schema // before validation and whitespace compaction. MaxEvidenceToolSchemaBytes = 1 << 20 // MaxEvidenceToolMetadataBytes bounds the aggregate model-facing concrete // tool names, descriptions, and compact schemas in one bound catalog. MaxEvidenceToolMetadataBytes = 4 << 20 )
Variables ¶
This section is empty.
Functions ¶
func IsRecoverableTerminalValidationError ¶
IsRecoverableTerminalValidationError reports whether err contains the package-owned malformed-terminal marker. Matching is typed and never inspects error text.
func NewRecoverableTerminalValidationError ¶
func NewRecoverableTerminalValidationError() error
NewRecoverableTerminalValidationError returns the sealed marker a strict classifier adapter may return when terminal decoding or wire-shape validation is malformed but safe to retry. It must not be used for domain decisions, basis mismatches, unsafe results, or operational failures.
func ReasonAllowed ¶
func ReasonAllowed(stage Stage, reason ReasonCode) bool
ReasonAllowed reports whether reason is a valid durable classification for stage. The closed matrix prevents impossible stage/reason audit records.
Types ¶
type BindError ¶
type BindError struct {
Kind BindErrorKind
Cause error
}
BindError reports why an immutable definition could not be bound.
type BindErrorKind ¶
type BindErrorKind string
BindErrorKind identifies a definition binding failure.
const ( BindInvalidDefinition BindErrorKind = "invalid_definition" BindInvalidContext BindErrorKind = "invalid_context" BindMissingModelResolver BindErrorKind = "missing_model_resolver" BindInvalidEvidenceTools BindErrorKind = "invalid_evidence_tools" )
type Bindings ¶
type Bindings struct {
Models ModelResolver
}
Bindings supplies runtime collaborators needed by a definition.
type BoundDefinition ¶
type BoundDefinition interface {
Name() Name
Participation() Participation
Timeout() time.Duration
Limits() Limits
Descriptor() DefinitionDescriptor
ResolveInference(context.Context, uuid.UUID) (InferenceBinding, error)
SystemPrompt() string
OutputSchema() (*inference.OutputSchema, bool)
EvidenceToolPolicy() (EvidenceToolPolicy, bool)
RetryPolicy() RetryPolicy
BindEvidenceTools(context.Context, EvidenceBindings) ([]BoundEvidenceTool, error)
// contains filtered or unexported methods
}
BoundDefinition is the sealed runtime view of one immutable definition.
type BoundEvidenceTool ¶
type BoundEvidenceTool struct {
// contains filtered or unexported fields
}
BoundEvidenceTool is an immutable, fingerprinted evidence capability. Its model-facing metadata is frozen separately from the concrete execution tool so optional capabilities on that tool remain available to the runtime.
func (BoundEvidenceTool) DescriptionSHA256 ¶
func (b BoundEvidenceTool) DescriptionSHA256() [sha256.Size]byte
func (BoundEvidenceTool) IdentitySHA256 ¶
func (b BoundEvidenceTool) IdentitySHA256() [sha256.Size]byte
func (BoundEvidenceTool) Info ¶
func (b BoundEvidenceTool) Info() *tool.ToolInfo
Info returns a defensive copy of the exact metadata frozen at bind time. Execution uses Tool so optional capabilities on the concrete tool are preserved; runtimes must use this accessor for model-facing metadata.
func (BoundEvidenceTool) Name ¶
func (b BoundEvidenceTool) Name() string
func (BoundEvidenceTool) SchemaSHA256 ¶
func (b BoundEvidenceTool) SchemaSHA256() [sha256.Size]byte
func (BoundEvidenceTool) Tool ¶
func (b BoundEvidenceTool) Tool() tool.InvokableTool
type Definition ¶
type Definition struct {
// contains filtered or unexported fields
}
Definition is an immutable hustle definition. Its zero value is invalid.
func Define ¶
func Define(opts ...Option) (Definition, error)
Define validates and freezes one text-only hustle definition.
func (Definition) Bind ¶
func (d Definition) Bind(ctx context.Context, bindings Bindings) (BoundDefinition, error)
Bind validates runtime collaborators and returns a read-only bound view.
func (Definition) Descriptor ¶
func (d Definition) Descriptor() DefinitionDescriptor
Descriptor returns the definition's secret-free behavioral projection.
func (Definition) EvidenceToolPolicy ¶
func (d Definition) EvidenceToolPolicy() (EvidenceToolPolicy, bool)
EvidenceToolPolicy returns an independently owned policy slice when evidence tools are enabled.
func (Definition) Limits ¶
func (d Definition) Limits() Limits
Limits returns the definition's immutable payload limits.
func (Definition) Participation ¶
func (d Definition) Participation() Participation
Participation returns the definition's fixed execution lane.
func (Definition) PolicyRevision ¶
func (d Definition) PolicyRevision() string
PolicyRevision returns the stable digest of all behavior-affecting fields.
func (Definition) RetryPolicy ¶
func (d Definition) RetryPolicy() RetryPolicy
RetryPolicy returns the immutable bounded retry behavior.
func (Definition) Timeout ¶
func (d Definition) Timeout() time.Duration
Timeout returns the definition's exact invocation timeout.
type DefinitionDescriptor ¶
type DefinitionDescriptor struct {
Name Name
Participation Participation
ModelSource ModelSource
NamedModelKey model.ModelKey
NamedModelPolicyRevision string
PromptRevision string
PromptSHA256 [sha256.Size]byte
OutputSchemaName string `json:",omitzero"`
// OutputSchemaSHA256 covers Description, compact Schema JSON, and Strict.
// It is a behavioral digest; no raw output policy crosses this boundary.
OutputSchemaSHA256 [sha256.Size]byte `json:",omitzero"`
StructuredOutputRevision string `json:",omitzero"`
PolicyRevision string
TimeoutNanos int64
Limits Limits
EvidenceToolPolicyRevision string `json:",omitzero"`
EvidenceToolDefinitionsSHA256 [sha256.Size]byte `json:",omitzero"`
EvidenceProducedToolNamesSHA256 [sha256.Size]byte `json:",omitzero"`
EvidenceToolLimits ToolLoopLimits `json:",omitzero"`
EvidenceToolDefinitionCount int `json:",omitzero"`
StructuredOutputWithTools bool `json:",omitzero"`
RetryPolicy RetryPolicy `json:",omitzero"`
}
DefinitionDescriptor is the complete secret-free behavioral projection used by rig identity and durable audit records.
func (DefinitionDescriptor) Validate ¶
func (d DefinitionDescriptor) Validate() error
Validate checks the complete descriptor-only constructor domain without requiring the raw system prompt or an inference client.
type DefinitionError ¶
type DefinitionError struct {
Kind DefinitionErrorKind
Field string
Cause error
}
DefinitionError reports a definition boundary failure without retaining raw prompts, model endpoints, or client identity in its message.
func (*DefinitionError) Error ¶
func (e *DefinitionError) Error() string
func (*DefinitionError) Unwrap ¶
func (e *DefinitionError) Unwrap() error
type DefinitionErrorKind ¶
type DefinitionErrorKind string
DefinitionErrorKind identifies an invalid immutable hustle definition.
const ( DefinitionMissingName DefinitionErrorKind = "missing_name" DefinitionReservedName DefinitionErrorKind = "reserved_name" DefinitionNilOption DefinitionErrorKind = "nil_option" DefinitionDuplicateOption DefinitionErrorKind = "duplicate_option" DefinitionInvalidParticipation DefinitionErrorKind = "invalid_participation" DefinitionInvalidModelSource DefinitionErrorKind = "invalid_model_source" DefinitionMissingModelSource DefinitionErrorKind = "missing_model_source" DefinitionInvalidClient DefinitionErrorKind = "invalid_client" DefinitionInvalidModel DefinitionErrorKind = "invalid_model" DefinitionInvalidTimeout DefinitionErrorKind = "invalid_timeout" DefinitionInvalidLimits DefinitionErrorKind = "invalid_limits" DefinitionInvalidSystemPrompt DefinitionErrorKind = "invalid_system_prompt" DefinitionInvalidPromptRevision DefinitionErrorKind = "invalid_prompt_revision" DefinitionMissingPolicyRevision DefinitionErrorKind = "missing_policy_revision" DefinitionInvalidPolicyRevision DefinitionErrorKind = "invalid_policy_revision" DefinitionInvalidOutputSchema DefinitionErrorKind = "invalid_output_schema" DefinitionInvalidEvidenceTools DefinitionErrorKind = "invalid_evidence_tools" DefinitionInvalidRetryPolicy DefinitionErrorKind = "invalid_retry_policy" )
type EvidenceBindings ¶
type EvidenceBindings struct {
SessionID uuid.UUID
LoopID uuid.UUID
ReadWorkspace *tool.ReadWorkspaceBinding
}
EvidenceBindings supplies only the invocation origin and structurally read-only workspace capability needed to build one run's evidence catalog. It intentionally cannot carry mutation, delegation, gate, grant, session, observation, or loop-control capabilities.
type EvidenceToolPolicy ¶
type EvidenceToolPolicy struct {
Revision string
Limits ToolLoopLimits
Definitions []tool.Definition
}
EvidenceToolPolicy is the immutable-definition input for a bounded evidence loop. Definitions are copied when the option is created and by Clone.
func (EvidenceToolPolicy) Clone ¶
func (p EvidenceToolPolicy) Clone() EvidenceToolPolicy
Clone returns a policy with an independently owned definition slice.
type InferenceBinding ¶
InferenceBinding pairs a client with its validated, secret-free model.
type ModelResolver ¶
type ModelResolver interface {
ResolveHustleModel(context.Context, uuid.UUID) (InferenceBinding, error)
}
ModelResolver resolves the exact originating loop's live inference binding.
type ModelSource ¶
type ModelSource uint8
ModelSource selects how an invocation obtains its inference binding.
const ( ModelSourceUnknown ModelSource = iota ModelSourceCurrentLoop ModelSourceNamed )
type Option ¶
type Option func(*definitionOptions) error
Option contributes one immutable definition property.
func WithCurrentLoopModel ¶
func WithCurrentLoopModel() Option
WithCurrentLoopModel resolves the originating loop's live model on every run.
func WithEvidenceTools ¶
func WithEvidenceTools(policy EvidenceToolPolicy) Option
WithEvidenceTools enables a bounded evidence-tool loop. The option owns a defensive copy immediately; the zero policy explicitly leaves tools off.
func WithLimits ¶
WithLimits sets serialized input and output byte limits.
func WithNamedInference ¶
WithNamedInference freezes a named client/model pair in the definition.
func WithOutputSchema ¶
func WithOutputSchema(output inference.OutputSchema) Option
WithOutputSchema freezes one optional provider-neutral structured-output policy. The option owns a clone immediately so caller mutations made before Define cannot alter the definition.
func WithParticipation ¶
func WithParticipation(participation Participation) Option
WithParticipation selects the definition's fixed execution lane.
func WithPolicyRevision ¶
WithPolicyRevision identifies opaque parser and request-policy behavior.
func WithRetryPolicy ¶
func WithRetryPolicy(policy RetryPolicy) Option
WithRetryPolicy selects one immutable retry policy. Classified retry is intentionally limited to evidence-backed reviewer definitions.
func WithSystemPrompt ¶
WithSystemPrompt freezes the raw prompt and its public revision label.
func WithTimeout ¶
WithTimeout sets the exact invocation timeout.
type Participation ¶
type Participation uint8
Participation selects the session-global execution lane.
const ( ParticipationUnknown Participation = iota ParticipationBlocking ParticipationBackground )
type ReasonCode ¶
type ReasonCode uint8
ReasonCode is the bounded, security-safe classification of a hustle failure.
const ( ReasonUnknown ReasonCode = iota ReasonRejected ReasonCanceled ReasonTimeout ReasonModelResolution ReasonInference ReasonInvalidOutput ReasonTerminal ReasonFinalization ReasonInternal )
func (ReasonCode) Valid ¶
func (r ReasonCode) Valid() bool
Valid reports whether the reason is recognized for durable audit.
type Request ¶
type Request struct {
Name Name
Cause identity.Cause
Input json.RawMessage
// SecurityCeiling is the per-invocation evidence-tool containment ceiling
// THIS SPECIFIC run's evidence catalog must be bound against (design
// §13.1, §21). Empty means no per-request override: a Hustle without an
// evidence-tool concept (e.g. compaction) never sets it, and never reaches
// the evidence-binding path that would consume it. A permission-review
// Hustle always sets it from that review's own frozen basis
// (gate.ReviewBasis.SecurityCeiling, captured once at StartPermissionReview
// — see internal/sessionruntime/gates.go's respondFromClassifier doc
// comment), never a session-wide constant, so a long session's later
// review is bound against ITS OWN current ceiling rather than one frozen
// at controller construction.
SecurityCeiling string
}
Request is the shared runtime's data-only serialization envelope.
type ResolveError ¶
type ResolveError struct {
Kind ResolveErrorKind
Cause error
}
ResolveError reports a model-resolution failure without exposing model or client details. Cause remains available to trusted callers through errors.Is.
func (*ResolveError) Error ¶
func (e *ResolveError) Error() string
func (*ResolveError) Unwrap ¶
func (e *ResolveError) Unwrap() error
type ResolveErrorKind ¶
type ResolveErrorKind string
ResolveErrorKind identifies an inference binding resolution failure.
const ( ResolveInvalidContext ResolveErrorKind = "invalid_context" ResolveInvalidLoopID ResolveErrorKind = "invalid_loop_id" ResolveModelFailed ResolveErrorKind = "model_failed" ResolveInvalidBinding ResolveErrorKind = "invalid_binding" )
type Result ¶
type Result struct {
Output json.RawMessage
Usage *content.Usage
}
Result is the validated serialized output and normalized usage.
type RetryPolicy ¶
type RetryPolicy uint8
RetryPolicy selects the immutable, bounded retry behavior of one definition. The zero value preserves the historical single-attempt behavior.
const ( RetryPolicyNone RetryPolicy = iota // RetryPolicyClassifiedOnce permits one clean restart after a closed set of // transient inference or recoverable terminal-parse failures. RetryPolicyClassifiedOnce )
func (RetryPolicy) Valid ¶
func (p RetryPolicy) Valid() bool
Valid reports whether the policy is a recognized immutable behavior.
type RevisionError ¶
type RevisionError struct{ Cause error }
RevisionError reports the impossible failure to encode a closed, typed policy projection. It exists so even programmer failures retain type identity.
func (*RevisionError) Error ¶
func (e *RevisionError) Error() string
func (*RevisionError) Unwrap ¶
func (e *RevisionError) Unwrap() error
type Stage ¶
type Stage uint8
Stage identifies the bounded execution phase in which a hustle failed.
type TerminalStatus ¶
type TerminalStatus uint8
TerminalStatus is the bounded outcome dimension used by durable usage aggregates. Interrupted attempts are deliberately not terminal.
const ( TerminalStatusUnknown TerminalStatus = iota TerminalStatusCompleted TerminalStatusFailed )
func (TerminalStatus) Valid ¶
func (s TerminalStatus) Valid() bool
Valid reports whether the value is a durable terminal outcome.