Engine: run findings ledger, findings gate, loop continuation, larger memory, loop lint, retry partial work, resume_session
- Runner-owned findings ledger per run: stages report a # findings section (new items and F<n> status changes); stable IDs, persisted (run_loop_state), in RunDetail.findings, findings.md, memory.md, inspect. - type=findings gate stage routes open/clear on the ledger mechanically. - retry --extra-visits N [--stage KEY] continues an exhausted loop; limits on_exhausted=decide parks the run on accept/continue/abort. - Essential memory cap 20 KB, task never truncated, handoff and open findings ahead of the outcome ledger. - Lint rejects limits.on outcomes on forward edges; warns on ineffective limits and resume_session. - A resumed retry carries the failed visit's output.md and private/ under previous-attempt/. - resume_session=true resumes a Claude stage's previous session on loop visits. 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 {
|
||||
@@ -208,6 +214,11 @@ type Message struct {
|
||||
RetryVisit int `json:"retry_visit,omitempty"`
|
||||
RetryVersion int `json:"retry_version,omitempty"`
|
||||
RetryInput map[string]any `json:"retry_input,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.
|
||||
|
||||
@@ -532,6 +532,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