Merge main (findings ledger, loop continuation) into usage-limit branch
Keeps the findings ledger, extra visits and on_exhausted=decide alongside the run budget, failure classes, quota parking and error-loop backoff. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,7 +13,7 @@ const (
|
||||
|
||||
// TurnArtifactNames are the files the server itself writes into a model visit's
|
||||
// turn directory. They are always debugging files.
|
||||
var TurnArtifactNames = []string{"input.md", "memory.md", "history.md", "output.md", "session.html"}
|
||||
var TurnArtifactNames = []string{"input.md", "memory.md", "history.md", "findings.md", "output.md", "session.html"}
|
||||
|
||||
// IsDebug reports whether the artifact is a runner-internal debugging file.
|
||||
func (a StageArtifact) IsDebug() bool { return a.Group == ArtifactGroupDebug }
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package protocol
|
||||
|
||||
// Finding is one item of a run's findings ledger. The runner owns the ledger:
|
||||
// stages report new findings and status changes in an output.md "# findings"
|
||||
// section, and the runner assigns the stable ID (F1, F2, ...), keeps the latest
|
||||
// status and records every change as an event.
|
||||
type Finding struct {
|
||||
ID string `json:"id"`
|
||||
Severity string `json:"severity"`
|
||||
Origin string `json:"origin"`
|
||||
Location string `json:"location,omitempty"`
|
||||
Summary string `json:"summary"`
|
||||
Status string `json:"status"`
|
||||
// Reason is the latest status change's reason.
|
||||
Reason string `json:"reason,omitempty"`
|
||||
RaisedBy string `json:"raised_by"`
|
||||
RaisedSequence int `json:"raised_sequence"`
|
||||
UpdatedBy string `json:"updated_by,omitempty"`
|
||||
UpdatedSequence int `json:"updated_sequence,omitempty"`
|
||||
Events []FindingEvent `json:"events,omitempty"`
|
||||
}
|
||||
|
||||
// FindingEvent is one status change of a finding, in the visit that made it.
|
||||
type FindingEvent struct {
|
||||
Sequence int `json:"sequence"`
|
||||
Stage string `json:"stage"`
|
||||
Status string `json:"status"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Finding severities (most severe first), statuses and origins.
|
||||
const (
|
||||
SeverityCritical = "critical"
|
||||
SeverityImportant = "important"
|
||||
SeverityMinor = "minor"
|
||||
SeverityNit = "nit"
|
||||
|
||||
FindingOpen = "open"
|
||||
FindingFixed = "fixed"
|
||||
FindingDismissed = "dismissed"
|
||||
FindingSettled = "settled"
|
||||
|
||||
OriginIntroduced = "introduced"
|
||||
OriginPreExisting = "pre-existing"
|
||||
)
|
||||
|
||||
// ExhaustedKey marks a waiting (then decided) step the runner created when a
|
||||
// loop exhausted its visits on a stage with on_exhausted=decide. The value is a
|
||||
// map with stage, visit, max_visits and targets (option -> target). Such a step
|
||||
// is a decision, never a stage visit.
|
||||
const ExhaustedKey = "exhausted"
|
||||
|
||||
// Exhaustion decision options.
|
||||
const (
|
||||
ExhaustedAccept = "accept"
|
||||
ExhaustedContinue = "continue"
|
||||
ExhaustedAbort = "abort"
|
||||
)
|
||||
|
||||
// ExhaustedInfo reads the exhaustion marker from a step output, or nil.
|
||||
func ExhaustedInfo(output map[string]any) map[string]any {
|
||||
info, _ := output[ExhaustedKey].(map[string]any)
|
||||
return info
|
||||
}
|
||||
@@ -50,6 +50,12 @@ type Stage struct {
|
||||
type StageLimits struct {
|
||||
MaxVisits int `json:"max_visits"`
|
||||
On []string `json:"on,omitempty"`
|
||||
// OnExhausted is "fail" (the default) or "decide": the runner parks the run
|
||||
// on an operator decision (accept / continue / abort) instead of failing
|
||||
// when this stage's loop exhausts its visits.
|
||||
OnExhausted string `json:"on_exhausted,omitempty"`
|
||||
// AcceptTo is the target of the "accept" decision (default #success).
|
||||
AcceptTo string `json:"accept_to,omitempty"`
|
||||
}
|
||||
|
||||
type NotificationPolicy struct {
|
||||
@@ -216,6 +222,11 @@ type Message struct {
|
||||
BudgetUSD float64 `json:"budget_usd,omitempty"`
|
||||
// RunSettings is the get/set_run_settings body and reply.
|
||||
RunSettings *RunSettings `json:"run_settings,omitempty"`
|
||||
// RetryExtraVisits (1-5) grants extra visits to a resumed loop: to
|
||||
// RetryExtraStage when set, otherwise to the stage(s) that exhausted their
|
||||
// visits. The resume continues the exhausted loop instead of failing again.
|
||||
RetryExtraVisits int `json:"retry_extra_visits,omitempty"`
|
||||
RetryExtraStage string `json:"retry_extra_stage,omitempty"`
|
||||
// Search is the broad, read-only search traffic over pipelines, versions,
|
||||
// runs, steps, field text and artifacts. See search.go for the per-type
|
||||
// payloads and the ranking/kind/bound vocabulary.
|
||||
|
||||
@@ -546,6 +546,11 @@ type RunDetail struct {
|
||||
// run's stages, stage services and checks ran with: files and variable
|
||||
// names only, never values. Absent for runs that predate it.
|
||||
Environment *RunEnvironment `json:"environment,omitempty"`
|
||||
// Findings is the run's runner-owned findings ledger, in ID order.
|
||||
Findings []Finding `json:"findings,omitempty"`
|
||||
// VisitGrants are extra visits per stage granted by a retry with
|
||||
// --extra-visits or a "continue" exhaustion decision.
|
||||
VisitGrants map[string]int `json:"visit_grants,omitempty"`
|
||||
}
|
||||
|
||||
// RunEnvironment is the directory environment a run resolved for its
|
||||
|
||||
Reference in New Issue
Block a user