Documentation
¶
Overview ¶
Package agentjson owns the one bounded, versioned document a headless agent reads. It projects canonical results; it decides no lifecycle, readiness, evidence, authority, or scope question of its own.
Index ¶
Constants ¶
const ( NextOperation = "operation" NextHumanHandoff = "human_handoff" NextTerminal = "terminal" NextBlocked = "blocked" )
Next-action variants. Exactly one is legal per envelope.
const ( MaxDataKeys = 40 MaxStringBytes = 4096 MaxListItems = 64 MaxDiagnostics = 100 )
Bounds keep the document small enough to read and impossible to use as a side channel for source text, transcripts, or unbounded process output.
const ExcerptLimit = 2048
ExcerptLimit bounds any process output that reaches the envelope. The full stream stays in stage-5 evidence; the envelope carries a sample and a way back to the authoritative record.
const Schema = "specd.agent/v1"
Schema is the only accepted envelope version. There is no alias and no compatibility reader: an incompatible client is refused, never reinterpreted.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bounded ¶
Bounded is process output as the envelope may carry it: sampled, redacted, and always paired with the digest and evidence reference that make the truncation traceable.
func Bound ¶
Bound samples one stream. Binary bytes, control characters, and secret-like text cannot survive it, and an oversized stream is cut, never widened.
ponytail: verification already redacts what it records, so this is the second boundary rather than the only one; fold the two patterns into one owner if a third caller ever needs redaction.
type Diagnostic ¶
type Diagnostic struct {
Code string `json:"code"`
Severity string `json:"severity"`
Message string `json:"message"`
Path string `json:"path,omitempty"`
Line int `json:"line,omitempty"`
Fix string `json:"fix"`
}
Diagnostic locates one problem and supplies exactly one repair.
type Envelope ¶
type Envelope struct {
Schema string `json:"schema"`
OK bool `json:"ok"`
Operation string `json:"operation"`
Root *Root `json:"root,omitempty"`
Subject *Subject `json:"subject,omitempty"`
State *State `json:"state,omitempty"`
Data map[string]any `json:"data,omitempty"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
Next Next `json:"next"`
Exit Exit `json:"exit"`
}
Envelope is the whole agent-facing document. Field order here is the encoded key order, so goldens stay byte-stable.
type Exit ¶
Exit is the process outcome class. The three classes stay distinct so a fail-closed refusal is never read as a failed gate or as success.
type Next ¶
type Next struct {
Kind string `json:"kind"`
Operation string `json:"operation,omitempty"`
Arguments map[string]string `json:"arguments,omitempty"`
Owner string `json:"owner,omitempty"`
Reason string `json:"reason,omitempty"`
Instruction string `json:"instruction"`
}
Next is the single legal next action. Kind selects the variant; every field outside that variant must be absent, so no envelope offers two moves.