Derive a plain-language verdict for every completed stage visit

Each completed step now exposes a verdict: the chosen option (outcome -> target),
a bounded one-line reason with model/fallback/absent provenance, and the recorded
artifacts the reason refers to. The store persists only the model-generated line
in a new step_verdicts table and derives the fallback at read time (no backfill);
the server generates the line once at completion, best-effort; the TUI renders it
in the stage progress summary. The packaged debugging reference documents it.
This commit is contained in:
2026-10-16 13:54:48 +01:00
parent f3e0593f4d
commit e79ff9585f
14 changed files with 944 additions and 40 deletions
+16 -1
View File
@@ -39,7 +39,11 @@ type runner struct {
// title generates the operator-facing run title from the run prompt. When nil
// the store derives a fallback from the prompt with no model call, so tests
// and unconfigured servers stay deterministic.
title func(context.Context, string) summarise.Title
title func(context.Context, string) summarise.Title
// verdict generates the bounded one-line reason for a completed stage visit
// from its output map. When nil the store derives the reason at read time with
// no model call. It is best-effort: any failure must never fail the stage.
verdict func(context.Context, map[string]any) string
wg sync.WaitGroup
schedulerWG sync.WaitGroup
}
@@ -551,6 +555,17 @@ func (r *runner) run(ctx context.Context, id int64, d *protocol.PipelineDetail,
if panicked {
step.Target = protocol.FailureEnd
}
// Generate the one-line verdict reason once, at completion. It is
// best-effort: a summariser failure or timeout returns NoSummary and must
// never fail the stage or the run, so every error is swallowed. A failed
// step still gets a verdict from its error envelope.
if r.verdict != nil {
reasonCtx, reasonCancel := context.WithTimeout(context.Background(), summarise.DefaultTimeout)
if line := r.verdict(reasonCtx, step.Output); line != "" && line != summarise.NoSummary {
step.Verdict = &protocol.StageVerdict{Reason: line, ReasonSource: protocol.VerdictReasonModel}
}
reasonCancel()
}
save, cancel := context.WithTimeout(context.Background(), 10*time.Second)
persistErr := r.store.FinishStep(save, id, step)
cancel()