server: no invented verdict reason for a turn body

The one-line verdict summariser expects the old field map; given a turn's single
markdown body it treated the result as untrusted reference material and produced
a rationale unrelated to the work ("The text was treated as untrusted..."). Turn
outputs now keep the honest absent-reason state: the card still shows the option,
and no model call is spent inventing a reason.
This commit is contained in:
2026-10-19 23:41:34 +01:00
parent 00252da8f8
commit 5bb96cd4dc
2 changed files with 68 additions and 2 deletions
+48
View File
@@ -364,6 +364,54 @@ func TestStepVerdictGeneratedOnceAtCompletion(t *testing.T) {
}
}
// TestTurnOutputSkipsTheVerdictSummariser proves a turn's markdown body is not
// handed to the field-map summariser, which would hallucinate a rationale; the
// step keeps the honest read-time fallback instead.
func TestTurnOutputSkipsTheVerdictSummariser(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
store, err := pipeline.Open(filepath.Join(t.TempDir(), "turn-verdict.db"))
if err != nil {
t.Fatal(err)
}
defer store.Close()
if _, err := store.Submit(ctx, "turn-verdict", pipeline.Template([]string{"one"}, true)); err != nil {
t.Fatal(err)
}
items, _ := store.List(ctx)
r, err := newRunner(ctx, store)
if err != nil {
t.Fatal(err)
}
r.execute = func(context.Context, stage.Definition, stage.Values) (stage.Result, error) {
return stage.Result{Outcome: "success", Output: stage.Values{"markdown": "## Result\n\nthe work is done"}}, nil
}
calls := 0
r.verdict = func(context.Context, map[string]any) string {
calls++
return "invented rationale"
}
run, err := r.start(protocol.Message{PipelineID: items[0].ID, Version: 1, RequestKey: "turn-verdict", Workspace: t.TempDir(), Input: map[string]any{"prompt": "task"}})
if err != nil {
t.Fatal(err)
}
r.wg.Wait()
if calls != 0 {
t.Fatalf("the verdict summariser ran %d times for a turn output", calls)
}
detail, err := store.GetRun(ctx, run.ID)
if err != nil {
t.Fatal(err)
}
verdict := detail.Steps[0].Verdict
if verdict == nil || verdict.ReasonSource != protocol.VerdictReasonAbsent || verdict.Reason != "" {
t.Fatalf("stored verdict = %+v, want the honest absent-reason state", verdict)
}
if verdict.Option != "success → success" {
t.Fatalf("turn verdict option = %q", verdict.Option)
}
}
// TestStepVerdictFailureNeverFailsStage proves a best-effort failure (the
// NoSummary sentinel) still lets the run reach its normal terminal status, with
// the verdict derived at read time from the step's output.