Documentation
¶
Overview ¶
Package envelope is the versioned event contract between agent-runner and the remediation-controller: one JSON event per line on the runner's stdout, prefixed so it survives interleaving with any other output. The controller follows the pod log live (issue updates land between the classification and remediation stages of one pod) and re-reads the full log at Job completion as the fallback — events are self-contained and idempotent to re-apply.
Index ¶
Constants ¶
const Prefix = "PATCHY-EVENT: "
Prefix marks an event line on the agent-runner's stdout.
const Version = 1
Version is the current envelope schema version.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Classification ¶
type Classification struct {
Stage
ReportMarkdown string `json:"report_markdown,omitempty"`
Recommendation string `json:"recommendation,omitempty"`
Priority string `json:"priority,omitempty"`
Severity string `json:"severity,omitempty"`
Confidence float64 `json:"confidence,omitempty"`
// RemediationModel/MaxTurns/TokenBudget are the CLAMPED stage-2
// parameters (allowlist and ceilings applied), not the raw suggestion.
RemediationModel string `json:"remediation_model,omitempty"`
MaxTurns int `json:"max_turns,omitempty"`
TokenBudget int `json:"token_budget,omitempty"`
// WillRemediate is the runner's local decision to continue to stage 2.
WillRemediate bool `json:"will_remediate"`
// AwaitApproval marks the breaking-change hold (a better-but-breaking
// fix exists): remediation waits for a human /approve.
AwaitApproval bool `json:"await_approval"`
}
Classification is the stage-1 event payload.
type Event ¶
type Event struct {
V int `json:"v"`
Type Type `json:"type"`
// Issue context so events are self-contained.
Repo string `json:"repo"`
Issue int `json:"issue"`
Classification *Classification `json:"classification,omitempty"`
Remediation *Remediation `json:"remediation,omitempty"`
// Error is set on fatal events.
Error string `json:"error,omitempty"`
}
Event is one envelope line.
type Outcome ¶
type Outcome string
Outcome describes how a stage ended.
const ( OutcomeOK Outcome = "ok" OutcomeRuntimeError Outcome = "runtime_error" OutcomeTimeout Outcome = "timeout" OutcomeBudgetExceeded Outcome = "budget_exceeded" OutcomeReportMissing Outcome = "report_missing" OutcomeReportInvalid Outcome = "report_invalid" OutcomeCommitFailed Outcome = "commit_failed" OutcomeBundleTooLarge Outcome = "bundle_too_large" )
Stage outcomes. Only OutcomeOK carries a trusted report; every other outcome routes the issue to humans.
type Remediation ¶
type Remediation struct {
Stage
ReportMarkdown string `json:"report_markdown,omitempty"`
Success bool `json:"success"`
Confidence float64 `json:"confidence,omitempty"`
// Branch is the local branch carrying the fix; BundleB64 is the
// base64-encoded git bundle of default..branch.
Branch string `json:"branch,omitempty"`
BundleB64 string `json:"bundle_b64,omitempty"`
}
Remediation is the stage-2 event payload.
type Stage ¶
type Stage struct {
Outcome Outcome `json:"outcome"`
Harness string `json:"harness"`
Model string `json:"model"`
SessionID string `json:"session_id,omitempty"`
NumTurns int `json:"num_turns,omitempty"`
Usage Usage `json:"usage"`
ElapsedSeconds float64 `json:"elapsed_seconds"`
// Detail explains a non-ok outcome for humans.
Detail string `json:"detail,omitempty"`
}
Stage carries what every stage reports regardless of kind.
type Usage ¶
type Usage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
CacheReadTokens int `json:"cache_read_tokens"`
CacheCreationTokens int `json:"cache_creation_tokens"`
CostUSD float64 `json:"cost_usd"`
}
Usage is the stage's agent accounting (all fields concrete: the envelope reports what was measured, zeros where the harness didn't say).