Documentation
¶
Overview ¶
Package envelope is the C4 event envelope, frozen at v1 (programme C4). SP2 owns it.
Index ¶
- Constants
- Variables
- func Clip(list []string) ([]string, bool)
- func Control(r rune) bool
- func GitHubURL(s string) bool
- func IntegrationStates() []string
- func LoopEnd(reason string) bool
- func ModelRefusal(code, detail string) string
- func ModelRefusalCause(reason string) string
- func ModelUnavailable(reason string) bool
- func MonitorVerdicts() []string
- func Must(v any) json.RawMessage
- func Oversize(t Type, n int) json.RawMessage
- func ReadOutput(e Event, runID string) (MessageKind, OutputRecord, bool)
- func ShowablePath(p string) bool
- func StatePayload(kind string, fields map[string]any) json.RawMessage
- func TaskStatePayload(f TaskFacts) json.RawMessage
- func ValidBranch(s string) bool
- func ValidClassName(s string) bool
- func ValidCommit(s string) bool
- func ValidEffort(s string) bool
- func ValidID(s string) bool
- func ValidLogin(s string) bool
- func ValidModel(s string) bool
- func ValidPersona(s string) bool
- type Acceptance
- type Actor
- type ActorKind
- type ApprovalDecidedPayload
- type ApprovalRequestedPayload
- type BudgetFact
- type Delivery
- type Draft
- type DriverPayload
- type Event
- type HandoffPayload
- type InputReadRecord
- type InputSource
- type IntegrationResult
- type IssueFact
- type MessageKind
- type MessagePayload
- type Origin
- type OutputFinding
- type OutputRecord
- type OverlapAssessment
- type PRFact
- type ParentFact
- type PartFact
- type ParticipantPayload
- type PolicyClass
- type PolicyConditions
- type PolicyFact
- type ProfileFact
- type ProvenanceFact
- type RunFact
- type Scope
- type SpendFact
- type Split
- type SplitFact
- type TaskFacts
- type ToolCallPayload
- type ToolResultPayload
- type TurnPayload
- type Type
Constants ¶
const ( Version = 1 MaxPayload = 64 << 10 // C4 MaxToolOutput = 16 << 10 // SP2 §4 MaxHumanMessage = 16 << 10 // SP2 §4 )
Envelope version and the size limits the broker enforces.
const ( MaxInputKinds = 16 MaxInputSources = 16 MaxInputCount = 1 << 20 )
The input_read bounds: the source kinds and levels are hardening's closed vocabularies, read here by shape since this package imports no hardening.
const ( EndJudgeImpossible = "judge_impossible" EndStalled = "stalled" EndNotMet = "not_met" )
The loop policy's end reasons, as agent-run sends them on its final read (harness R13).
const ( EndModelBilling = "model_unavailable_billing" EndModelAuth = "model_unavailable_auth" EndModelQuota = "model_unavailable_quota" )
The end reasons of a run whose model provider refused it: a platform condition, not the agent's error. The reason names the cause so the room, the summary and the issue comment can say it.
const ( IntegrationPending = "pending" IntegrationPassed = "passed" IntegrationFailed = "failed" )
The integration states, as the Task CRD's status.result enumerates them. A run reports only a terminal one.
const ( OutcomeSucceeded = "succeeded" OutcomeFailed = "failed" OutcomeBudgetExhausted = "budget_exhausted" OutcomeRevoked = "revoked" OutcomeLost = "lost" OutcomeEnded = "ended" )
A run's outcome, once it has ended. An empty Outcome is a run that has not.
const ( ApprovalOlderCommit = "older_commit" ApprovalBeforeRunsEnded = "before_runs_ended" )
Why a shown approval is stale (PRFact.ApprovalStale): it is of an older commit than the head, or of the head but submitted before the task's last pushing run ended, so before that push landed.
const ( PolicyLive = "live" PolicyShadow = "shadow" PolicyUnarmed = "unarmed" )
The modes of a merge class, the gate's three outcomes: live arms once its conditions hold, shadow is decided like live and never armed, unarmed is never merged by the factory.
const ( MaxPolicyClasses = 16 MaxPolicyList = 8 MaxPolicyEntry = 120 )
The policy fact's bounds: the facts ride one bounded POST, which the broker refuses for good when they fail validation, so the factory clamps to these (Clip) and says so in Truncated.
const ( ScopeReady = "ready" ScopeQuestion = "question" )
The scope's states (scoper design SC6, SC7): ready, the implementer can start; question, the task waits for its issue's author.
const ( MinChildren = 2 MaxChildren = 5 MaxSplitBytes = 21 << 10 )
A split's bounds (splitter design SL2, "The split"): 2 to 5 parts, 21 KiB in all, well under the broker's 64 KiB event beside the scope and the summary.
const BrokerActor = "system:room-broker"
BrokerActor is the room broker's system principal, the one actor whose input_read counts.
const EndBudgetCalls = "budget_calls"
EndBudgetCalls is the harness's end of a scoper run stopped at its tool-call limit before any handoff (harness roles HR2). The factory fails it open, as a missing scope.
const FactoryActor = "system:factory"
FactoryActor is the factory's system principal, the one actor whose output answers and shadows count (the factory config's PrincipalFactory).
const HarnessEnd = "harness_end"
HarnessEnd is the state_changed kind a bridge records when agent-run reports why the loop policy, or the scoper's tool-call limit, ended its run (loops design, "How a run ends"): {"kind":"harness_end","reason":…}.
const HarnessStatus = "harness_status"
HarnessStatus is the state_changed kind a bridge records for a change of its harness's execution_status: {"kind":"harness_status","status","previous"}, plus effort once the harness has told it.
const MaxMicroUSD int64 = 1_000_000_000_000
MaxMicroUSD bounds every dollar amount in the facts ($1,000,000), so sums of them cannot overflow.
const MaxOutputBytes = 8 << 20
MaxOutputBytes caps OutputRecord.Bytes: the largest output, a push bundle (hardening.MaxBundle).
const MaxOutputFindings = 5
MaxOutputFindings caps OutputRecord.Audit.
const MaxPlan = 8
MaxPlan bounds TaskFacts.Plan.
const MaxProfileWhy = 200
MaxProfileWhy bounds the reason a scope gives for its profile.
const MaxProgressNote = 280
MaxProgressNote bounds a progress note, in characters.
const MaxProtectedPath = 256
MaxProtectedPath bounds one protected path a digest-bound approval shows, in bytes.
const MaxRuns = 20
MaxRuns bounds TaskFacts.Runs.
const MaxScopeBytes = 4096
MaxScopeBytes bounds a scope as canonical JSON (SC6).
const MaxVerdict = 32
MaxVerdict bounds RunFact.Verdict, in bytes, as the Task CRD bounds RunRecord.Verdict.
const OverlapAssessmentSchema = `{"type":"object","additionalProperties":false,"required":["classification"],"properties":{` +
`"classification":{"type":"string","enum":["active_duplicate","completed_duplicate","prior_attempt","partial_overlap","unverified_overlap","no_match"]},` +
`"citations":{"type":"array","maxItems":20,"items":{"type":"string","minLength":1,"maxLength":128}},` +
`"sources":{"type":"array","maxItems":4,"items":{"type":"string","enum":["tasks","runs","rooms","github"]}},` +
`"blindSpots":{"type":"array","maxItems":8,"items":{"type":"string","minLength":1,"maxLength":256}},` +
`"note":{"type":"string","maxLength":512}}}`
OverlapAssessmentSchema is the triager-only overlap property of room_handoff's input schema.
const ScopeSchema = `{"type":"object","additionalProperties":false,"required":["state","task","touches","plan","acceptance"],"properties":{` +
`"state":{"type":"string","enum":["ready","question"]},` +
`"task":{"type":"string","minLength":1,"maxLength":1000},` +
`"touches":{"type":"array","minItems":1,"maxItems":10,"items":{"type":"string","minLength":1,"maxLength":200}},` +
`"leave":{"type":"array","maxItems":10,"items":{"type":"string","minLength":1,"maxLength":200}},` +
`"plan":{"type":"array","minItems":1,"maxItems":7,"items":{"type":"string","minLength":1,"maxLength":300}},` +
`"assumptions":{"type":"array","maxItems":5,"items":{"type":"string","minLength":1,"maxLength":300}},` +
`"acceptance":{"type":"array","minItems":1,"maxItems":5,"items":{"type":"object","additionalProperties":false,"required":["check","proves"],` +
`"properties":{"check":{"type":"string","minLength":1,"maxLength":300},"proves":{"type":"string","minLength":1,"maxLength":200}}}},` +
`"question":{"type":"string","maxLength":500},` +
`"profile":{"type":"string","pattern":"^[a-z0-9]([-a-z0-9]{0,38}[a-z0-9])?$"},` +
`"profileWhy":{"type":"string","minLength":1,"maxLength":200}}}`
ScopeSchema is the scope property of room_handoff's input schema, listed to the triager only.
const WaitingReason = "protected_path_needs_approval"
WaitingReason is the one reason an output_waiting record carries: its push touches a protected path and waits for a maintainer (hardening.RefuseNeedsApproval).
Variables ¶
var Efforts = []string{"none", "minimal", "low", "medium", "high", "xhigh", "max"}
Efforts are the reasoning efforts a run may report: the gateway's providers' vocabularies, merged. A closed set of seven, so a value the sandbox chose is still a bounded metric label.
var ErrOverlapAssessment = errors.New("overlap: one known classification; at most 20 citations, four checked sources and eight blind spots")
ErrOverlapAssessment is every refusal of an assessment's bounded shape.
var ErrScope = errors.New("scope: state ready or question; task 1-1000 bytes; touches 1-10 and leave 0-10, each 1-200; " +
"plan 1-7 and assumptions 0-5, each 1-300; acceptance 1-5 of {check 1-300, proves 1-200}; question 1-500 exactly when " +
"state is question, with at least one assumption; profile a profile name and profileWhy 1-200, only when state is " +
"ready; at most 4096 bytes as JSON")
ErrScope is every refusal of Validate: the broker returns it to the model as an argument error.
var ErrSplit = errors.New("split: why 1-500 bytes; children 2-5, in the order they merge, each a scope in state ready " +
"with no question; at most 21504 bytes as JSON; and beside it scope, in state ready: the whole task")
ErrSplit is every refusal of a split: Validate's, and a split handed off without the whole task.
var ProfileRefusalCodes = []string{"profile_unknown", "profile_not_offered", "not_maintainer", "profile_conflict",
"profile_no_tests_paths", "catalogue_unavailable",
"profile_not_allowed", "class_profile_fixed", "class_no_profiles", "profile_internal"}
ProfileRefusalCodes is intake's closed list of profile refusals (intake.ProfileRefusals, held within it by its test), and the four codes a task triaged before the workflow left the class may carry (profile_not_allowed, class_profile_fixed, class_no_profiles, profile_internal; WF4): envelope sits below intake, so the facts' validator keeps its own copy.
var ProfileSources = []string{"label", "schedule", "revert", "oracle", "repository", "floor", "control", "treatment", "scoper", "escalation"}
ProfileSources are where a task's workflow came from (WF3, WF4): the Task CRD's status.profile.source enum. floor is a task triaged before the workflow left the class.
var SplitSchema = `{"type":"object","additionalProperties":false,"required":["why","children"],"properties":{` + `"why":{"type":"string","minLength":1,"maxLength":500},` + `"children":{"type":"array","minItems":2,"maxItems":5,"items":` + strings.Replace(ScopeSchema, `"enum":["ready","question"]`, `"enum":["ready"]`, 1) + `}}}`
SplitSchema is the split property of room_handoff's input schema, listed to the triager only: each part is the scope's schema in state ready.
Functions ¶
func Clip ¶ added in v0.39.0
Clip is list within the policy's bounds, a copy, and whether anything was cut.
func Control ¶
Control is a control character other than tab and newline, or a Unicode format character (zero-width, bidi): the same runes steering.Validate refuses, since a scope is agent-influencing text in later implementer briefs.
func IntegrationStates ¶ added in v0.39.0
func IntegrationStates() []string
IntegrationStates are the values IntegrationResult.State may hold on the Task.
func LoopEnd ¶
LoopEnd reports whether reason is one of the harness's end reasons: the loop policy's three and the scoper's tool-call limit.
func ModelRefusal ¶ added in v0.43.0
ModelRefusal classifies the harness_error a run ended on (litellm's exception class as code, its message as detail) as a model provider's refusal, and returns the end reason it maps to, or "" when the error is not one. Billing text wins over a rate-limit class: Z.ai answers an empty wallet as a RateLimitError. The detail is the harness's own text and is only matched, never repeated.
func ModelRefusalCause ¶ added in v0.43.0
ModelRefusalCause is the cause word of a provider-refusal end reason: billing, auth or quota; "" for any other reason.
func ModelUnavailable ¶ added in v0.43.0
ModelUnavailable reports whether reason is one of the provider-refusal end reasons.
func MonitorVerdicts ¶ added in v0.33.0
func MonitorVerdicts() []string
MonitorVerdicts are the values TaskFacts.Monitor may hold.
func Must ¶
func Must(v any) json.RawMessage
Must marshals a payload struct; the structs here cannot fail to marshal.
func Oversize ¶
func Oversize(t Type, n int) json.RawMessage
Oversize is stored in place of a payload over MaxPayload (ruling P20): refusing a harness event would block the bridge's cursor forever.
func ReadOutput ¶ added in v0.46.0
func ReadOutput(e Event, runID string) (MessageKind, OutputRecord, bool)
ReadOutput is the one reader of safe-output events for run runID: it answers e's kind and record only when the broker's stamp vouches for it, and the record passes Validate. A request counts only from the run's own agent actor ("agent:"+runID) by the client origin, as integration_result reads; an answer, a shadow or a wait only from FactoryActor, exactly, by the client origin. Anything else in the room, however its payload is shaped, is not an output.
func ShowablePath ¶ added in v0.46.0
ShowablePath reports whether p, a protected path from a digest-bound approval's action, may be shown to a person: non-empty, at most MaxProtectedPath bytes of valid UTF-8, with no control character (Cc) and no format character (Cf: bidi overrides, zero-width marks), which could make a path read as another. Every surface that names a path filters through it.
func StatePayload ¶
func StatePayload(kind string, fields map[string]any) json.RawMessage
StatePayload builds a state_changed payload: {kind, …fields}.
func TaskStatePayload ¶
func TaskStatePayload(f TaskFacts) json.RawMessage
TaskStatePayload is the state_changed payload of a TaskFacts: {"kind":"task", ...facts}.
func ValidBranch ¶ added in v0.35.0
ValidBranch reports whether s is an AgentRun's branch (v1alpha1.AgentRunSpec.Branch's pattern): the one thing a forge.push approval binds (v3.x Slack push approval D5).
func ValidClassName ¶ added in v0.39.0
ValidClassName reports whether s is a class name the policy fact carries.
func ValidCommit ¶ added in v0.37.0
ValidCommit reports whether s is empty or a commit id PRFact.ApprovedCommit may carry.
func ValidLogin ¶
ValidLogin reports whether s is a GitHub login in that rule's shape: a user, or an App's "<slug>[bot]". Facts are not refused for an author outside it (legacy logins with double or trailing hyphens, Enterprise Managed Users' "name_shortcode" exist): a view that names the author in a sentence of its own checks it here, and says "the issue's author" otherwise.
func ValidModel ¶
ValidModel reports whether s is 1 to 64 letters, digits and ._:/@+- characters, starting with a letter or digit. spec.model is the claim's, never the sandbox's; this is defence in depth.
func ValidPersona ¶ added in v0.33.0
ValidPersona reports whether s is a persona name: lowercase, at most 32 characters, safe to render and to use as a CSS class suffix.
Types ¶
type Acceptance ¶
Acceptance is one check the judge reads: a command or an observation, and what it proves.
type Actor ¶
type Actor struct {
Kind ActorKind `json:"kind"`
ID string `json:"id"`
Role string `json:"role,omitempty"`
}
Actor is stamped by the broker from the authenticated credential, never taken from a client.
type ActorKind ¶
type ActorKind string
ActorKind is who acted: an agent run, a human, or the platform.
type ApprovalDecidedPayload ¶
type ApprovalDecidedPayload struct {
ApprovalID string `json:"approvalId"`
Decision string `json:"decision"` // approved | denied | expired | superseded
Reason string `json:"reason,omitempty"`
}
ApprovalDecidedPayload is an approval_decided event's payload.
type ApprovalRequestedPayload ¶
type ApprovalRequestedPayload struct {
ApprovalID string `json:"approvalId"`
CallID string `json:"callId"`
Class string `json:"class"`
// Branch is the run's branch, set by the bridge for the classes it forwards (D5): the one
// thing a forge.push approval binds. Empty for every other class and for older requests.
Branch string `json:"branch,omitempty"`
// Digest and Output bind a factory-requested forge.push approval to one push bundle's sha256
// and the output id that carries it (hardening HR28, amending D5): the bundle exists before the
// push, so its digest is what a maintainer approves. Empty on every other approval.
Digest string `json:"digest,omitempty"`
Output string `json:"output,omitempty"`
Action json.RawMessage `json:"action"` // the raw, redacted call (T3)
ExpiresAt time.Time `json:"expiresAt"`
// Prompters are the principals who prompted the turn: with four-eyes on, none of
// them may decide it. The page reads them to say who may.
Prompters []string `json:"prompters,omitempty"`
}
ApprovalRequestedPayload is an approval_requested event's payload.
type BudgetFact ¶
type BudgetFact struct {
UsedTokens int64 `json:"usedTokens"`
LimitTokens int64 `json:"limitTokens"`
}
BudgetFact is the token budget and usage of a task.
type Draft ¶
type Draft struct {
RoomID string
RunID string
Actor Actor
Type Type
CausedBy *int64
Origin Origin
OriginClient string
OriginSeq int64
Redactions []string
Payload json.RawMessage
}
Draft is everything a writer hands the store. The store stamps v, id, seq and ts. OriginClient and OriginSeq are the idempotency key: "agent:<runId>" + harnessSeq, "human:<sub>" + clientSeq, or "broker:<what>" + a fixed step number.
type DriverPayload ¶
type DriverPayload struct {
From string `json:"from"`
To string `json:"to"`
Epoch int64 `json:"epoch"`
Reason string `json:"reason"` // given | requested | taken | lease_expired
}
DriverPayload is a driver event's payload: the driver token moved.
type Event ¶
type Event struct {
V int `json:"v"`
ID string `json:"id"`
Seq int64 `json:"seq"`
RoomID string `json:"roomId"`
RunID string `json:"runId,omitempty"`
Actor Actor `json:"actor"`
Type Type `json:"type"`
CausedBy *int64 `json:"causedBy,omitempty"`
Origin Origin `json:"origin"`
TS time.Time `json:"ts"`
Redactions []string `json:"redactions"`
Payload json.RawMessage `json:"payload"`
}
Event is one durable entry of a room's log.
type HandoffPayload ¶
type HandoffPayload struct {
FromRole string `json:"fromRole"`
ToRole string `json:"toRole"`
Summary string `json:"summary"`
Commit string `json:"commit"`
Branch string `json:"branch"`
// Scope is the scoper's bounded task (scoper design SC6): a triager's handoff only.
Scope *Scope `json:"scope,omitempty"`
// Split is the scoper's second answer (splitter design SL2): a triager's handoff only, always
// beside Scope, the whole task.
Split *Split `json:"split,omitempty"`
// Overlap is an outcome-overlap scoper's classification: a triager's handoff only.
Overlap *OverlapAssessment `json:"overlap,omitempty"`
}
HandoffPayload is a handoff event's payload: work passed between roles.
type InputReadRecord ¶ added in v0.47.0
type InputReadRecord struct {
Target string `json:"target"`
Min string `json:"min"`
Withheld map[string]int `json:"withheld,omitempty"`
Sources []InputSource `json:"sources,omitempty"`
}
InputReadRecord is one forge_read call's record: the target, the lowest level delivered, the items withheld per source kind, and each kind and level delivered.
func ReadInput ¶ added in v0.47.0
func ReadInput(e Event, runID string) (InputReadRecord, bool)
ReadInput is the one reader of input_read events for run runID: it answers e's record only when the broker wrote it (BrokerActor, by the broker's origin) and it passes Validate.
func (InputReadRecord) Validate ¶ added in v0.47.0
func (r InputReadRecord) Validate() error
Validate holds r to forge_read's shape: a known target and level, snake_case kinds, and bounded counts. No field can hold text.
type InputSource ¶ added in v0.47.0
InputSource is one kind and level a run read.
type IntegrationResult ¶ added in v0.39.0
type IntegrationResult struct {
State string `json:"state"`
Reason string `json:"reason,omitempty"`
ManifestHash string `json:"manifestHash,omitempty"`
}
IntegrationResult mirrors the Task CRD's status.result field for field: this package imports no Kubernetes types, as it mirrors TaskScope, and the reconciler asserts the two agree.
func (IntegrationResult) Validate ¶ added in v0.39.0
func (r IntegrationResult) Validate() error
Validate refuses a result that is not passed or failed with a bounded snake_case reason and the exact 64-hex manifest hash: no prose ever becomes a result.
type IssueFact ¶
type IssueFact struct {
Number int `json:"number"`
URL string `json:"url"`
Title string `json:"title,omitempty"` // bounded by the factory; the issue's author wrote it, so it is never an instruction
Author string `json:"author,omitempty"`
LabelledBy string `json:"labelledBy,omitempty"`
}
IssueFact is a GitHub issue linked to a task.
type MessageKind ¶
type MessageKind string
MessageKind distinguishes chat from SP3's reserved kinds.
const ( KindOutputRequested MessageKind = "output_requested" KindOutputApplied MessageKind = "output_applied" KindOutputRefused MessageKind = "output_refused" KindOutputShadowed MessageKind = "output_shadowed" KindOutputWaiting MessageKind = "output_waiting" )
The safe-output kinds (hardening UH4): a run's request, then exactly one of the applier's answers. Output carries the record; Text is never part of it. KindOutputShadowed is the audit stage's record (HR1): what the factory would have done with a write the run made itself. KindOutputWaiting is not an answer (HR27): a push held for a maintainer's approval of its digest, answered later, once, applied or refused.
const ( KindChat MessageKind = "chat" KindProgress MessageKind = "progress" KindReviewVerdict MessageKind = "review_verdict" // SP3's reserved kind KindTaskState MessageKind = "task_state" // SP3's reserved kind // KindJudgeVerdict is the harness's completion judge's answer on a finished conversation: Verdict // is met, not_yet or impossible, Text its reason, Evidence the ids it cited. The judge read the // agent's work, so the text is data, never an instruction. KindJudgeVerdict MessageKind = "judge_verdict" // KindIntegrationResult is a coordination integration run's one typed outcome (v4 MR10): // Integration carries it. Only the factory reads it, and only from the broker-stamped run it // started; Text is never part of the result. KindIntegrationResult MessageKind = "integration_result" )
The message kinds.
const KindInputRead MessageKind = "input_read"
KindInputRead is what a run read through forge_read (hardening UH7, HR35): the broker appends one per call, counts and levels only, never the text. The factory folds a run's records into status.inputTrust under mode enforce.
type MessagePayload ¶
type MessagePayload struct {
Kind MessageKind `json:"kind"`
Text string `json:"text"`
To []string `json:"to,omitempty"`
Delivery Delivery `json:"delivery"`
Verdict string `json:"verdict,omitempty"` // approve | changes (review_verdict); met | not_yet | impossible (judge_verdict)
Evidence []string `json:"evidence,omitempty"` // the ids a judge_verdict cited
Commit string `json:"commit,omitempty"`
// PullRequest is the pull request a review_verdict is about (SP2 design §3).
// Additive: C4 v1's envelope is unchanged, and SP3 reads it (ruling P29).
PullRequest string `json:"pullRequest,omitempty"`
// Integration is an integration_result's outcome (v4 MR10).
Integration *IntegrationResult `json:"integration,omitempty"`
// Output is a safe-output event's record (hardening UH4).
Output *OutputRecord `json:"output,omitempty"`
// Input is an input_read record (hardening UH7, HR35): counts and levels, never text.
Input *InputReadRecord `json:"input,omitempty"`
}
MessagePayload is a message event's payload.
type OutputFinding ¶ added in v0.46.0
OutputFinding is one threat-check finding recorded without deciding the record (HR2): its layer, such as t5_classifier, and its bounded reason.
type OutputRecord ¶ added in v0.40.0
type OutputRecord struct {
ID string `json:"id"`
Type string `json:"type"`
Digest string `json:"digest"`
Bytes int `json:"bytes,omitempty"`
Payload json.RawMessage `json:"payload,omitempty"`
Object string `json:"object,omitempty"`
Reason string `json:"reason,omitempty"`
// Audit holds the findings that did not decide the record, at most MaxOutputFindings, on an
// applied, refused or shadowed record only (HR39: T5 runs in audit after a refusal too).
Audit []OutputFinding `json:"audit,omitempty"`
// ApprovalID names the approval a waiting push waits for, on output_waiting only: a ULID.
ApprovalID string `json:"approvalId,omitempty"`
}
OutputRecord is one safe-output event's record: the request's id, type and payload digest, and the GitHub object an applied output wrote or the one bounded reason a refused one got. The payload itself, for every type but push, is Payload; a push bundle is stored beside the log.
func (OutputRecord) Validate ¶ added in v0.40.0
func (r OutputRecord) Validate(k MessageKind) error
Validate holds r to its kind: an id, type and digest always; an object on github.com only, and always, when applied or shadowed; a snake_case reason always when refused, optionally when shadowed (a would-refuse or would_wait), never otherwise; audit findings only when applied, refused or shadowed; a payload on a request only, so an answer or a shadow never carries the written text; a size from 0 to MaxOutputBytes. A waiting record is a push with WaitingReason and the ULID of its approval, which no other kind carries.
type OverlapAssessment ¶ added in v0.43.0
type OverlapAssessment struct {
Classification string `json:"classification"`
Citations []string `json:"citations,omitempty"`
Sources []string `json:"sources,omitempty"`
BlindSpots []string `json:"blindSpots,omitempty"`
Note string `json:"note,omitempty"`
}
OverlapAssessment is an outcome-overlap scoper's read-only classification. Citations name only candidate IDs supplied in its brief; the reconciler additionally checks them against those candidates.
func (OverlapAssessment) Validate ¶ added in v0.43.0
func (a OverlapAssessment) Validate() error
Validate checks the assessment's independent shape and bounds. Candidate-specific claims are the reconciler's contract: only it knows which IDs and active candidates were actually supplied.
type PRFact ¶
type PRFact struct {
Number int `json:"number"`
URL string `json:"url"`
Author string `json:"author,omitempty"`
Reviewers []string `json:"reviewers,omitempty"`
// ApprovedBy, ApprovedCommit and ApprovalStale are a maintainer's approval of an AwaitingHuman
// pull request the factory shows with merge.approveToMerge off, beside the hand-off's reason,
// which stands: who, a GitHub login; the commit approved; and why it is stale, empty while it is
// current: ApprovalOlderCommit or ApprovalBeforeRunsEnded.
ApprovedBy string `json:"approvedBy,omitempty"`
ApprovedCommit string `json:"approvedCommit,omitempty"`
ApprovalStale string `json:"approvalStale,omitempty"`
}
PRFact is a GitHub pull request linked to a task.
type ParentFact ¶ added in v0.33.0
type ParentFact struct {
Room string `json:"room"`
Issue int `json:"issue"`
Index int `json:"index"`
Of int `json:"of"`
}
ParentFact points a part's room back at the task it was split from, and says which part it is.
type PartFact ¶ added in v0.33.0
type PartFact struct {
Index int `json:"index"`
Issue int `json:"issue"`
Room string `json:"room"`
Outcome string `json:"outcome,omitempty"`
}
PartFact is one part of a split: its place in the merge order (1-based), its issue and room, and how it ended, empty while it has not. Outcome is landed, dropped or reverted.
type ParticipantPayload ¶
type ParticipantPayload struct {
Principal string `json:"principal"`
Change string `json:"change"` // joined | left | role_changed
Role string `json:"role,omitempty"`
Approver bool `json:"approver,omitempty"`
}
ParticipantPayload is a participant event's payload.
type PolicyClass ¶ added in v0.39.0
type PolicyClass struct {
Name string `json:"name"`
Mode string `json:"mode"`
Adopted bool `json:"adopted,omitempty"`
}
PolicyClass is one row of the repository's class table.
type PolicyConditions ¶ added in v0.39.0
type PolicyConditions struct {
AllowedFiles []string `json:"allowedFiles,omitempty"`
ProtectedFiles []string `json:"protectedFiles,omitempty"`
ModifyOnly bool `json:"modifyOnly,omitempty"`
MaxPatchFiles int `json:"maxPatchFiles,omitempty"`
MaxModifiedLines int `json:"maxModifiedLines,omitempty"`
DiffShape string `json:"diffShape,omitempty"`
HoldoutChecks []string `json:"holdoutChecks,omitempty"`
MaxPerDay int `json:"maxPerDay,omitempty"`
AdoptLogins []string `json:"adoptLogins,omitempty"`
RequiredLabel string `json:"requiredLabel,omitempty"`
Oracle bool `json:"oracle,omitempty"`
}
PolicyConditions are a class's declared conditions, as the factory config names them.
type PolicyFact ¶ added in v0.39.0
type PolicyFact struct {
Class string `json:"class,omitempty"`
Mode string `json:"mode"`
// GateOff: no class is live or shadow on the factory, so it holds no merger and merges nothing.
GateOff bool `json:"gateOff,omitempty"`
// ApproveToMerge: a maintainer's approval of the current commit arms the merger (AM1); never
// for an adopted class.
ApproveToMerge bool `json:"approveToMerge,omitempty"`
Adopted bool `json:"adopted,omitempty"`
Conditions *PolicyConditions `json:"conditions,omitempty"`
Classes []PolicyClass `json:"classes,omitempty"`
// MergedHow is how the merger merged the pull request: class or approved, "" otherwise.
MergedHow string `json:"mergedHow,omitempty"`
// Name is the merge policy the gate last decided the pull request under, chosen from its diff
// (merge policies MR1); "" before a decision named one.
Name string `json:"name,omitempty"`
Truncated bool `json:"truncated,omitempty"`
}
PolicyFact is the merge policy that governs the room's task (merge policy view D1): its class and mode, the class's declared conditions, and the repository's class table. It carries the room's own repository only, so it is visible to whoever may read the room (D2).
type ProfileFact ¶ added in v0.42.0
type ProfileFact struct {
Name string `json:"name"`
Source string `json:"source"`
Cohort string `json:"cohort"`
Recommended string `json:"recommended,omitempty"`
Reason string `json:"reason,omitempty"`
Why string `json:"why,omitempty"`
// Requested is the profile a person pinned, and Refused why the pin was not applied: a code of
// ProfileRefusalCodes, empty when honoured.
Requested string `json:"requested,omitempty"`
Refused string `json:"refused,omitempty"`
}
ProfileFact is the harness profile a task runs under, its evaluation cohort and the scoper's recommendation. It is the Task status projected into the room, never a fresh decision.
type ProvenanceFact ¶
type ProvenanceFact struct {
FactoryVersion string `json:"factoryVersion,omitempty"`
CompositionRevision string `json:"compositionRevision,omitempty"`
HarnessImage string `json:"harnessImage,omitempty"`
ServedModels []string `json:"servedModels,omitempty"`
}
ProvenanceFact is what a run ran on (R10): the factory build, the AgentRun CompositionRevision, the harness image digest and the models that served it. Each empty until known.
type RunFact ¶
type RunFact struct {
ID string `json:"id"`
Role string `json:"role"`
Trigger string `json:"trigger,omitempty"`
// Persona is what the run is for, set by the factory alone; Role stays what it may do.
Persona string `json:"persona,omitempty"`
StartedAt time.Time `json:"startedAt,omitzero"`
// EndedAt, Outcome, Verdict and MicroUSD are set once the run has ended.
EndedAt time.Time `json:"endedAt,omitzero"`
Outcome string `json:"outcome,omitempty"`
Verdict string `json:"verdict,omitempty"`
MicroUSD int64 `json:"microUSD,omitempty"`
// What the run ran on (R10), as far as the factory knows it yet.
Provenance *ProvenanceFact `json:"provenance,omitempty"`
}
RunFact is a run's role, trigger, and lifecycle in a task.
type Scope ¶
type Scope struct {
State string `json:"state"`
Task string `json:"task"`
Touches []string `json:"touches"`
Leave []string `json:"leave,omitempty"`
Plan []string `json:"plan"`
Assumptions []string `json:"assumptions,omitempty"`
Acceptance []Acceptance `json:"acceptance"`
Question string `json:"question,omitempty"`
// Profile is the harness profile the scoper recommends over the class's floor, and ProfileWhy
// its reason; a ready scope's only.
Profile string `json:"profile,omitempty"`
ProfileWhy string `json:"profileWhy,omitempty"`
}
Scope is the scoper's bounded task (SC6), carried by a triager's room_handoff. The broker validates it; the factory re-injects it into every implementer brief (SC9).
type SpendFact ¶
type SpendFact struct {
UsedMicroUSD int64 `json:"usedMicroUSD"`
LimitMicroUSD int64 `json:"limitMicroUSD,omitempty"`
}
SpendFact is the dollars a task has spent and, when it has one, its dollar limit.
type Split ¶
Split is the scoper's second answer (SL1, SL2): the task as two to five bounded tasks, in the order they merge, each a scope in state ready. It rides a triager's room_handoff beside the scope of the whole task, which /factory retry runs when a maintainer declines the split.
type SplitFact ¶ added in v0.33.0
SplitFact is a split parent's view of its parts: Of parts, between MinChildren and MaxChildren.
type TaskFacts ¶
type TaskFacts struct {
Phase string `json:"phase"`
Reason string `json:"reason,omitempty"`
Run *RunFact `json:"run,omitempty"`
Budget *BudgetFact `json:"budget,omitempty"`
// Spend is the task's dollars, beside Budget's tokens (BudgetFact is unchanged).
Spend *SpendFact `json:"spend,omitempty"`
// SpendFinal is CD23: the Spend beside it is the task's last figure — priced again after the
// settle window, and never bucketed by the facts key. False while the dollars may still move,
// and for a task whose runs the meter cannot price: no figure is claimed for those.
SpendFinal bool `json:"spendFinal,omitempty"`
// Runs is the task's run history, oldest first, at most MaxRuns.
Runs []RunFact `json:"runs,omitempty"`
Issue *IssueFact `json:"issue,omitempty"`
PR *PRFact `json:"pr,omitempty"`
// Origin is the room of the investigate task this task's issue was published from (RunLore
// agent-to-agent RA10), a C2 id; the webhook tracker repeats it on every event of the room.
Origin string `json:"origin,omitempty"`
// MergeByApproval is the gate's hand-off of an AwaitingHuman pull request (human path AM3): a
// maintainer's approval of the head returns it to the gate, which merges it. False is the
// bypass: the switch off, an adopted class, or a reason no approval returns.
MergeByApproval bool `json:"mergeByApproval,omitempty"`
// Plan is the personas the task expects to run, in order, at most MaxPlan: the factory's
// forecast, so a view can show the steps ahead.
Plan []string `json:"plan,omitempty"`
// Split is the task as a parent of parts (a maintainer accepted the scoper's split).
Split *SplitFact `json:"split,omitempty"`
// Parent is set on a part's room: the task it was split from.
Parent *ParentFact `json:"parent,omitempty"`
// Monitor is the post-merge monitor's verdict (one of MonitorVerdicts), set only for a task with
// an origin. A verdict is final once set; the webhook tracker sends it once as room.monitor_verdict.
Monitor string `json:"monitor,omitempty"`
// Policy is the merge policy that governs the task, as the factory's config declares it.
Policy *PolicyFact `json:"policy,omitempty"`
// Profile is the harness profile and evaluation cohort the task runs under.
Profile *ProfileFact `json:"profile,omitempty"`
}
TaskFacts are what the factory knows about a room's task, written as state_changed{kind:task} so the room summary depends on the room log alone.
type ToolCallPayload ¶
type ToolCallPayload struct {
CallID string `json:"callId"`
Tool string `json:"tool"`
Args json.RawMessage `json:"args"`
Class string `json:"class,omitempty"`
Risk string `json:"risk,omitempty"`
DecidedBy *string `json:"decidedBy"` // policy | human | null
}
ToolCallPayload is a tool_call event's payload.
type ToolResultPayload ¶
type ToolResultPayload struct {
CallID string `json:"callId"`
Status string `json:"status"` // ok | error | rejected
Output string `json:"output"`
Truncated bool `json:"truncated"`
Bytes int `json:"bytes"`
}
ToolResultPayload is a tool_result event's payload.
type TurnPayload ¶
type TurnPayload struct {
RunID string `json:"runId"`
TurnID string `json:"turnId"`
Phase string `json:"phase"` // started | completed | cancelled | failed
}
TurnPayload is a turn event's payload.
type Type ¶
type Type string
Type is an event's kind, one of the ten C4 types.
const ( Message Type = "message" Turn Type = "turn" ToolCall Type = "tool_call" ToolResult Type = "tool_result" ApprovalRequested Type = "approval_requested" ApprovalDecided Type = "approval_decided" Participant Type = "participant" Driver Type = "driver" Handoff Type = "handoff" StateChanged Type = "state_changed" )
The ten C4 event types.