oficina / equipo Public

A merge hold stops merges, not retries

The coordinator's merge hold ("Paul should try it before it merges")
also turned off triage: Classify returned nothing for a held task, so a
held task's step_timeout or runner_restarted was never retried, and the
stall sweep never took back its stuck step (stopped-jobs audit,
2026-11-25, example 2 and tkfprjdobe5j).

The hold now stops only the merge-side actions, the rebase of a merge
conflict and the re-check before the merge card. A held task's passing
stop is retried once, its fix-rounds recommendation shows, and the sweep
takes back its stuck step; the hold itself stays. The triage spec says
so.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev f575cecef290c9cee6d0d22275a46f43d5a5bb4e parent fc80376
4 files changed, +107 −30
  • docs/superpowers/specs/2026-11-11-equipo-needs-you-triage.md +12 −6
  • internal/equipo/triage/triage.go +13 −5
  • internal/equipo/triage/triage_test.go +37 −3
  • internal/thintest/triage_contract_test.go +45 −16
diff --git a/docs/superpowers/specs/2026-11-11-equipo-needs-you-triage.md b/docs/superpowers/specs/2026-11-11-equipo-needs-you-triage.md
index 8e6cccea..1c48b56a 100644
--- a/docs/superpowers/specs/2026-11-11-equipo-needs-you-triage.md
+++ b/docs/superpowers/specs/2026-11-11-equipo-needs-you-triage.md
@@ -46,10 +46,14 @@ at start-up (§3), on the housekeeping tick for held rows and in the stall
sweep (§2.5), never under the principal.
**Never touched:** a task ended, cancelled or cancel-requested, folded,
-merging, or held (`merge_hold`); a creator who is not a current member
+or merging; a creator who is not a current member
and owner, has no primary runner (`PrimaryRunner` is empty when execution
is off), or paused their housekeeping. Classify checks the first four itself; the
-store checks the rest in the transaction.
+store checks the rest in the transaction. A coordinator's merge hold
+(`merge_hold`) stops only the merge-side actions (rebase and re-check):
+a held task's passing stop is still retried, and its stuck step still
+taken back (stopped-jobs audit, 2026-11-25: a hold had kept two
+timed-out jobs from their retry).
## 2. The three actions
@@ -157,8 +161,8 @@ tasks with no change for 30 minutes:
that moves nothing is recorded as expired, so it is not tried every
minute.
-Never a merge step, a task Ready to merge or merging, held, cancelled or
-paused. The take-back and the kick run under the principal, so a kick
+Never a merge step, a task Ready to merge or merging, cancelled or
+paused (a merge hold does not stop the sweep: the sweep never merges). The take-back and the kick run under the principal, so a kick
that would make a task Ready or merge it is refused there (the next sync
moves it).
@@ -229,13 +233,15 @@ Contracts in `internal/thintest`, each seen failing before the code:
- `TestTriageBudget`: the fourth retry of a day is held with the
recommendation; the next day claims it; a failed row never acts again.
- `TestTriageRetriageIdempotent`: `Retriage` twice and a sync act once.
-- `TestTriageCancelledUntouched`: cancelled, cancel-requested, held,
+- `TestTriageCancelledUntouched`: cancelled, cancel-requested,
paused: nothing changes.
+- `TestTriageHeldStillRetries`: a held task's `step_timeout` is retried
+ once; the hold stays.
- `TestTriageStaleRebase`: a rebase held for the budget, then the
person's merge Retry on the same SHA conflicting again: never acts.
- `TestTriageSweepsStalled`: running past its time, queued and never
started, stopped with nothing scheduled, done with its next step lost;
- never a merge or a held task.
+ never a merge; a held task's stuck step is taken back.
Unit: the `Classify` table. Headless scenario 4 now expects the
automatic retry; Mac M4 and the sandbox-wait contract keep the person's
diff --git a/internal/equipo/triage/triage.go b/internal/equipo/triage/triage.go
index fb48876c..9e4f2e21 100644
--- a/internal/equipo/triage/triage.go
+++ b/internal/equipo/triage/triage.go
@@ -50,9 +50,10 @@ type Step struct {
// touched; an attempt is taken back only from a runner that is online
// (an offline one is the offline rule's and the next sync's), and never
// from a worker (the offline rule and the Mac checks gate own those); a
-// task Ready to merge or merging is merge authority's.
+// task Ready to merge or merging is merge authority's. A merge hold does
+// not stop the sweep: it stops a merge, and the sweep never merges.
func Stalled(f Facts, s Step, needsYou string, now time.Time) string {
- if f.Ended || f.CancelRequested || f.Folded || f.Merging || f.Held || needsYou != "" || s.Specialist == wire.SpecialistMerge || s.State == "" || s.Worker && !wire.StepTerminal(s.State) {
+ if f.Ended || f.CancelRequested || f.Folded || f.Merging || needsYou != "" || s.Specialist == wire.SpecialistMerge || s.State == "" || s.Worker && !wire.StepTerminal(s.State) {
return ActNone
}
switch s.State {
@@ -96,7 +97,9 @@ type Facts struct {
// NeedsYou is what the person must decide, as progress computes it.
NeedsYou string
// Never touched: ended or cancel-requested, folded into another task,
- // merging, or held by the coordinator.
+ // or merging. Held: the coordinator holds its merge, which stops only
+ // the merge-side actions (a rebase, a re-check before the merge card);
+ // a held task's passing stop is still retried.
Ended, CancelRequested, Folded, Merging, Held bool
// The newest step: its specialist, failure reason, termination proof,
// and whether Equipo already retried it on its own (any attempt).
@@ -128,9 +131,14 @@ type Verdict struct {
Waiting string
}
-// Classify sorts the task's need (spec §§2, 4).
+// Classify sorts the task's need (spec §§2, 4). A merge hold stops only
+// what leads to a merge: the person still decides a held task's merge
+// conflict and its merge, but a step that stopped in passing is retried.
func Classify(f Facts) Verdict {
- if f.Ended || f.CancelRequested || f.Folded || f.Merging || f.Held {
+ if f.Ended || f.CancelRequested || f.Folded || f.Merging {
+ return Verdict{}
+ }
+ if f.Held && (f.NeedsYou == wire.NeedsMergeConflict || f.NeedsYou == wire.NeedsMerge) {
return Verdict{}
}
switch f.NeedsYou {
diff --git a/internal/equipo/triage/triage_test.go b/internal/equipo/triage/triage_test.go
index 273ac422..7ebb42b2 100644
--- a/internal/equipo/triage/triage_test.go
+++ b/internal/equipo/triage/triage_test.go
@@ -53,8 +53,9 @@ func TestClassify(t *testing.T) {
}
}
-// TestClassifyNeverTouches: an ended, cancel-requested, folded, merging or
-// held task is never acted on, whatever it needs.
+// TestClassifyNeverTouches: an ended, cancel-requested, folded or merging
+// task is never acted on, whatever it needs (a held one is
+// TestClassifyHeldStillRetries).
func TestClassifyNeverTouches(t *testing.T) {
base := stopped(wire.SpecialistEngineering, "runner_restarted")
if v := Classify(base); v.Action != ActRetry {
@@ -65,7 +66,6 @@ func TestClassifyNeverTouches(t *testing.T) {
"cancel requested": func(f *Facts) { f.CancelRequested = true },
"folded": func(f *Facts) { f.Folded = true },
"merging": func(f *Facts) { f.Merging = true },
- "held": func(f *Facts) { f.Held = true },
} {
f := base
bend(&f)
@@ -112,3 +112,37 @@ func TestClassifyWaitsOnThePlatform(t *testing.T) {
t.Fatal("a platform wait is not a passing reason")
}
}
+
+// TestClassifyHeldStillRetries: the coordinator's merge hold stops Equipo
+// merging on its own, nothing else. A held task's passing stop is still
+// retried; its merge-side actions (a rebase, a re-check before the merge
+// card) still wait for the person.
+func TestClassifyHeldStillRetries(t *testing.T) {
+ held := func(f Facts) Facts { f.Held = true; return f }
+ for name, c := range map[string]struct {
+ f Facts
+ act, rec string
+ }{
+ "step timeout": {held(stopped(wire.SpecialistEngineering, "step_timeout")), ActRetry, ""},
+ "runner restarted": {held(stopped(wire.SpecialistEngineering, "runner_restarted")), ActRetry, ""},
+ "checks timeout": {held(stopped(wire.SpecialistChecks, "checks_timeout")), ActRetry, ""},
+ "not a passing stop": {held(stopped(wire.SpecialistEngineering, "provider_failed")), ActNone, wire.RecommendRetry},
+ "a merge step, never": {held(stopped(wire.SpecialistMerge, "interrupted")), ActNone, ""},
+ "fix rounds": {held(Facts{NeedsYou: wire.NeedsFixRounds}), ActNone, wire.RecommendRound},
+ "conflict": {held(Facts{NeedsYou: wire.NeedsMergeConflict}), ActNone, ""},
+ "stale checks": {held(Facts{NeedsYou: wire.NeedsMerge, Checks: wire.ChecksCannotRun, ChecksReason: "needs_network", Stale: true}), ActNone, ""},
+ "unborn default": {held(Facts{NeedsYou: wire.NeedsMerge, Specialist: wire.SpecialistMerge, Reason: wire.ReasonMergeUnbornDefault, Terminated: true}), ActNone, ""},
+ } {
+ v := Classify(c.f)
+ if v.Action != c.act || v.Recommend != c.rec || v.Waiting != "" {
+ t.Errorf("held, %s: got %+v, want act %q recommend %q", name, v, c.act, c.rec)
+ }
+ f := c.f
+ f.Held = false
+ if name != "conflict" && name != "stale checks" && name != "unborn default" {
+ if got := Classify(f); got != v {
+ t.Errorf("%s: held %+v, not held %+v", name, v, got)
+ }
+ }
+ }
+}
diff --git a/internal/thintest/triage_contract_test.go b/internal/thintest/triage_contract_test.go
index 2f2c1e5d..1b6aa140 100644
--- a/internal/thintest/triage_contract_test.go
+++ b/internal/thintest/triage_contract_test.go
@@ -437,8 +437,7 @@ func TestTriageRetriageIdempotent(t *testing.T) {
}
}
-// TestTriageCancelledUntouched: a cancelled task, a held one and one whose
-// person paused housekeeping are never touched.
+// TestTriageCancelledUntouched: a cancelled task is never touched.
func TestTriageCancelledUntouched(t *testing.T) {
r := newToolRigAt(t, wire.ProtocolCurrent)
cancelled, d := r.started("x", "Cancelled after it stopped")
@@ -450,11 +449,6 @@ func TestTriageCancelledUntouched(t *testing.T) {
if _, err := r.inst.DB.Writer().Exec("UPDATE chat_steps SET reason = 'runner_restarted' WHERE task_id = ?", cancelled); err != nil {
t.Fatal(err)
}
- held, dh := r.started("h", "Held by the coordinator")
- if res := r.call("h-hold", wire.ToolHoldMerge, map[string]string{"task": held, "reason": "Paul wants to look first."}); res.IsError {
- t.Fatalf("hold %+v", res)
- }
- r.stop("h", dh, "runner_restarted")
for range 2 {
if _, err := r.inst.Store.Chat().Retriage(r.ctx, false); err != nil {
t.Fatal(err)
@@ -464,14 +458,37 @@ func TestTriageCancelledUntouched(t *testing.T) {
if k := r.task(cancelled); k.Stage != wire.StageCancelled || k.Steps[0].Attempt != 1 {
t.Fatalf("cancelled task touched %+v", k)
}
- if k := r.task(held); k.Steps[0].Attempt != 1 || k.NeedsYou != wire.NeedsRetry {
- t.Fatalf("held task touched %+v", k.Steps[0])
- }
if len(r.triageActions("triage_retry")) != 0 || r.heldKinds(wire.FrameDispatch) != 0 {
t.Fatal("acted")
}
}
+// TestTriageHeldStillRetries (stopped-jobs audit, example 2): the
+// coordinator held the merge because the person wants to try the change
+// first, then Engineering ran out of time. The hold stops a merge, not
+// the retry: Equipo tries the step again once, and the hold stays.
+func TestTriageHeldStillRetries(t *testing.T) {
+ r := newToolRigAt(t, wire.ProtocolCurrent)
+ held, dh := r.started("h", "Held by the coordinator")
+ if res := r.call("h-hold", wire.ToolHoldMerge, map[string]string{"task": held, "reason": "Paul wants to look first."}); res.IsError {
+ t.Fatalf("hold %+v", res)
+ }
+ r.stop("h", dh, "step_timeout")
+ again := r.nextDispatch()
+ if again.TaskID != held || again.StepID != dh.StepID || again.Attempt != 2 {
+ t.Fatalf("held task not retried: %+v", again)
+ }
+ if k := r.task(held); k.NeedsYou != "" || k.Triage == nil || k.Triage.Kind != wire.TriageRetrying || k.Triage.Reason != "step_timeout" {
+ t.Fatalf("while retrying %+v %+v", k.NeedsYou, k.Triage)
+ }
+ if hold := r.task(held).MergeHold; hold != "Paul wants to look first." {
+ t.Fatalf("hold lost: %q", hold)
+ }
+ if len(r.triageActions("triage_retry")) != 1 {
+ t.Fatal("not one retry")
+ }
+}
+
// TestTriageStaleRebase: a rebase held for today's budget is bound to the
// merge attempt that raised it. The person's own merge Retry on the same
// SHA conflicting again is a new situation: the held row never acts.
@@ -605,23 +622,35 @@ func TestTriageSweepsStalled(t *testing.T) {
t.Fatal("kicked twice")
}
})
- t.Run("never a merge or a held task", func(t *testing.T) {
+ t.Run("never a merge", func(t *testing.T) {
r := newToolRigAt(t, wire.ProtocolInjectionDefences)
base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40)
id := r.judgedTask("n", "Merging for ever", base, cand, wire.ChecksPassed, "")
m := r.dispatched(wire.SpecialistMerge, base, cand, 0)
r.step("n-m-run", wire.StepReport{TaskID: id, StepID: m.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: base, CandidateSHA: cand})
+ dispatches := r.commands(wire.FrameDispatch)
+ later(r, 3*time.Hour)
+ r.tick()
+ r.tick()
+ if r.commands(wire.FrameCancelStep) != 0 || r.commands(wire.FrameDispatch) != dispatches || len(r.triageActions("triage_stall")) != 0 {
+ t.Fatal("touched a merge")
+ }
+ })
+ // A merge hold stops a merge, not the take-back of a stuck step.
+ t.Run("a held task's stuck step", func(t *testing.T) {
+ r := newToolRigAt(t, wire.ProtocolCurrent)
held, dh := r.started("h", "Held and stuck")
if res := r.call("h-hold", wire.ToolHoldMerge, map[string]string{"task": held, "reason": "Paul wants to look first."}); res.IsError {
t.Fatalf("hold %+v", res)
}
r.step("h-run", wire.StepReport{TaskID: held, StepID: dh.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: dh.BaseSHA})
- dispatches := r.commands(wire.FrameDispatch)
- later(r, 3*time.Hour)
- r.tick()
+ later(r, 2*time.Hour)
r.tick()
- if r.commands(wire.FrameCancelStep) != 0 || r.commands(wire.FrameDispatch) != dispatches || len(r.triageActions("triage_stall")) != 0 {
- t.Fatal("touched a merge or a held task")
+ if _, body := r.expect(wire.FrameCancelStep); body.(*wire.CancelStepCommand).StepID != dh.StepID {
+ t.Fatalf("cancel %+v", body)
+ }
+ if k := r.task(held); k.MergeHold != "Paul wants to look first." || len(r.triageActions("triage_stall")) != 1 {
+ t.Fatalf("after the take-back %+v", k.MergeHold)
}
})
}