diff --git a/internal/agentctx/agentctx.go b/internal/agentctx/agentctx.go index f1555e2..cef93af 100644 --- a/internal/agentctx/agentctx.go +++ b/internal/agentctx/agentctx.go @@ -459,6 +459,12 @@ func renderPlanProgress(in Input) string { fmt.Fprintf(&b, "- %s (%s): verified at %s, stale because the tree is now at %s\n", phase.ID, collapse(phase.Name), short(rec.AtSHA), short(in.Git.HeadSHA)) case rec.Status == domain.PlanPhaseVerified: fmt.Fprintf(&b, "- %s (%s): verified at %s\n", phase.ID, collapse(phase.Name), short(rec.AtSHA)) + case rec.Status == domain.PlanPhaseAwaitingManual && rec.Stale(in.Git.HeadSHA): + // A pending manual gate goes stale for the same reason a verified + // phase does. Run 10 rendered "automated checks passed at + // 94bd45c3b5d6" against a tree that had moved to 7d04aef, because + // only the verified branch consulted Stale. + fmt.Fprintf(&b, "- %s (%s): automated checks passed at %s, stale because the tree is now at %s, waiting for the human to confirm the manual steps\n", phase.ID, collapse(phase.Name), short(rec.AtSHA), short(in.Git.HeadSHA)) case rec.Status == domain.PlanPhaseAwaitingManual: fmt.Fprintf(&b, "- %s (%s): automated checks passed at %s, waiting for the human to confirm the manual steps\n", phase.ID, collapse(phase.Name), short(rec.AtSHA)) default: diff --git a/internal/agentctx/agentctx_test.go b/internal/agentctx/agentctx_test.go index 53579f4..ac887d9 100644 --- a/internal/agentctx/agentctx_test.go +++ b/internal/agentctx/agentctx_test.go @@ -707,3 +707,30 @@ func TestResearchBriefStatesTheFindingIDRule(t *testing.T) { } } } + +// A pending manual gate goes stale for the same reason a verified phase does. +// Run 10 rendered "automated checks passed at 94bd45c3b5d6" against a tree +// that had moved, because only the verified branch consulted Stale. +func TestPendingManualGateRendersStale(t *testing.T) { + plan := &workphase.PlanDoc{Phases: []workphase.PlanPhase{{ID: "phase-1", Name: "one"}}} + task := domain.Task{ + ID: "t1", PlanRef: "ref-a", + PlanProgress: &domain.PlanProgress{PlanRef: "ref-a", Phases: []domain.PlanPhaseRecord{ + {PlanRef: "ref-a", PhaseID: "phase-1", Status: domain.PlanPhaseAwaitingManual, AtSHA: strings.Repeat("a", 40)}, + }}, + } + got := renderPlanProgress(Input{ + Task: task, Phase: domain.WorkPhaseImplement, Plan: plan, + Git: GitState{HeadSHA: strings.Repeat("b", 40)}, + }) + if !strings.Contains(got, "stale because the tree is now at") { + t.Errorf("a pending manual gate at a moved sha did not render stale:\n%s", got) + } + fresh := renderPlanProgress(Input{ + Task: task, Phase: domain.WorkPhaseImplement, Plan: plan, + Git: GitState{HeadSHA: strings.Repeat("a", 40)}, + }) + if strings.Contains(fresh, "stale") { + t.Errorf("a pending manual gate at HEAD rendered stale:\n%s", fresh) + } +}