Documentation
¶
Overview ¶
Package envelope is the versioned event contract between agent-runner and the job controllers: one JSON event per line on the runner's stdout, prefixed so it survives interleaving with any other output. The owning controller reads the full log once at Job completion — 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 = 3
Version is the current envelope schema version. Version 2 replaced the git-bundle payload with the structured Changeset; version 3 added the investigation event (exploitability/likelihood/impact analyses) and keys events by finding name.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalysisResult ¶ added in v0.4.0
type AnalysisResult struct {
// Rating is none|low|medium|high|critical.
Rating string `json:"rating"`
// Summary is the agent's short justification.
Summary string `json:"summary,omitempty"`
}
AnalysisResult is one investigation dimension: a rating plus a short justification (the full reasoning lives in the report markdown).
type Changeset ¶ added in v0.3.0
type Changeset struct {
// BaseSHA is the commit the clone was pinned to; the pushed commit's
// parent.
BaseSHA string `json:"base_sha"`
// CommitMessage carries the agent's commit message(s); multiple local
// commits squash into one API commit.
CommitMessage string `json:"commit_message"`
Upserts []FileChange `json:"upserts,omitempty"`
Deletes []string `json:"deletes,omitempty"`
}
Changeset expresses the agent's committed change as file contents so the controller can push it through the GitHub API without git.
type Event ¶
type Event struct {
V int `json:"v"`
Type Type `json:"type"`
// Finding context so events are self-contained.
Repo string `json:"repo"`
// Finding names the owning Finding resource.
Finding string `json:"finding,omitempty"`
Investigation *Investigation `json:"investigation,omitempty"`
Remediation *Remediation `json:"remediation,omitempty"`
// Error is set on fatal events.
Error string `json:"error,omitempty"`
}
Event is one envelope line.
type FileChange ¶ added in v0.3.0
type FileChange struct {
Path string `json:"path"`
// Mode is the git file mode: "100644", "100755", or "120000".
Mode string `json:"mode"`
// ContentB64 is the base64-encoded blob; for a symlink ("120000") it is
// the encoded link target.
ContentB64 string `json:"content_b64"`
}
FileChange is one file created or modified on the remediation branch.
type Investigation ¶ added in v0.4.0
type Investigation struct {
Stage
ReportMarkdown string `json:"report_markdown,omitempty"`
Exploitability AnalysisResult `json:"exploitability"`
Likelihood AnalysisResult `json:"likelihood"`
Impact AnalysisResult `json:"impact"`
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 the analysis suggested (the controller re-clamps before
// launching the remediation job).
RemediationModel string `json:"remediation_model,omitempty"`
MaxTurns int `json:"max_turns,omitempty"`
TokenBudget int `json:"token_budget,omitempty"`
// AwaitApproval marks the breaking-change hold (a better-but-breaking
// fix exists): remediation waits for a human approval.
AwaitApproval bool `json:"await_approval"`
}
Investigation is the analysis-stage event payload (version 3): the agent's exploitability, likelihood, and impact assessments plus its verdict. The runner never decides continuation — the controller routes on the verdict.
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" OutcomeChangesetTooLarge Outcome = "changeset_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; Changeset is its content
// diffed against Changeset.BaseSHA.
Branch string `json:"branch,omitempty"`
Changeset *Changeset `json:"changeset,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).