package thintest import ( "strings" "testing" "amadan.net/oficina/equipo/internal/wire" ) // TestTimedOutCandidateGoesToChecks (stopped-jobs audit, example 2): // Engineering ran out of time with its change made; the runner pushed // the work and reported the step done with the reason step_timeout. The // instance keeps the reason (the work is unfinished), runs checks and // then review on the candidate, tells Review the step ran out of time, // and never retries the step on its own. func TestTimedOutCandidateGoesToChecks(t *testing.T) { r := newToolRigAt(t, wire.ProtocolCurrent) base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40) id, d := r.started("o", "Swipe down to dismiss the keyboard") r.step("o-run", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: base, Family: "claude", Account: "claude-a"}) r.step("o-done", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepDone, Reason: "step_timeout", BaseSHA: base, CandidateSHA: cand, Pushed: true, Termination: true, Family: "claude", Account: "claude-a"}) r.expect(wire.FrameWatchMerge) c := r.dispatched(wire.SpecialistChecks, base, cand, 0) k := r.task(id) if s := k.Steps[0]; s.State != wire.StepDone || s.Reason != "step_timeout" || !s.Pushed || k.NeedsYou != "" { t.Fatalf("timed-out candidate %+v needs %q", s, k.NeedsYou) } r.checks("o-c", c, wire.ChecksPassed, exit(0), "", "") rv := r.dispatched(wire.SpecialistReview, base, cand, 0) if !strings.Contains(rv.Brief, "ran out of time") { t.Fatalf("Review not told the step ran out of time: %q", rv.Brief) } if len(r.triageActions("triage_retry")) != 0 { t.Fatal("retried a step that kept its work") } if page := r.get(r.inst.Cookie(), "/tasks/"+id, 200); !strings.Contains(page, "It ran out of time.") { t.Fatalf("task page does not say the step ran out of time: %s", page) } // A finished step's candidate is not marked. id2, d2 := r.started("f", "Fix the typo") r.step("f-run", wire.StepReport{TaskID: id2, StepID: d2.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: base, Family: "claude", Account: "claude-a"}) cand2 := strings.Repeat("3", 40) r.step("f-done", wire.StepReport{TaskID: id2, StepID: d2.StepID, Attempt: 1, State: wire.StepDone, BaseSHA: base, CandidateSHA: cand2, Pushed: true, Termination: true, Family: "claude", Account: "claude-a"}) r.expect(wire.FrameWatchMerge) c2 := r.dispatched(wire.SpecialistChecks, base, cand2, 0) r.checks("f-c", c2, wire.ChecksPassed, exit(0), "", "") if rv := r.dispatched(wire.SpecialistReview, base, cand2, 0); strings.Contains(rv.Brief, "ran out of time") { t.Fatalf("a finished step's Review told it ran out of time: %q", rv.Brief) } }