A fix round without a working shell does not use up a round
Stopped-jobs audit, fix 4: eight jobs ended "still not approved after two fix rounds" after rounds in which the engineer's shell refused every command, so it could not check anything it changed. The runner follows a Claude step's Bash calls in its stream: when the step ran Bash and no call came back without an error, a pushed fix round is reported done with the reason shell_unavailable. The instance does not count such a round against the task's two automatic rounds (at most two such rounds are free), and the next round is still told "Fix round 1 of 2". shell_unavailable is a done-only reason with no words of its own: on any other state the instance records it as unknown. Codex, Pi and OpenCode steps do not report it yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+204
−14
internal/equipo/chat/review.go+19 −4internal/equipo/chat/tasks.go+8 −5internal/equipo/copy_test.go+1 −1internal/runner/thin/engineer.go+64 −4internal/runner/thin/shell_use_test.go+39 −0internal/thintest/shell_round_contract_test.go+58 −0internal/wire/tasks.go+15 −0
diff --git a/internal/equipo/chat/review.go b/internal/equipo/chat/review.go| index 3b35ce39..c23586cf 100644 |
| --- a/internal/equipo/chat/review.go |
| +++ b/internal/equipo/chat/review.go |
| @@ -40,6 +40,16 @@ type progress struct { |
| work *stepRecord |
| // explore: the task is an exploration (progressFor). |
| explore bool |
| + // free is how many fix rounds do not count against the task's |
| + // automatic rounds (freeRounds). |
| + free int |
| +} |
| + |
| +// freeRound: s is a pushed fix round without a working shell |
| +// (wire.ReasonShellUnavailable): it could not check its work, so the |
| +// round does not count, up to wire.MaxFixRounds such rounds. |
| +func freeRound(s *stepRecord) bool { |
| + return s.Specialist == wire.SpecialistEngineering && s.Round >= 1 && !s.Rebase && s.State == wire.StepDone && s.Pushed && s.Reason == wire.ReasonShellUnavailable |
| } |
| // progressFor is progressOf with the branch's state on Amadan. |
| @@ -82,6 +92,9 @@ func progressOfKind(steps []stepRecord, kind string) progress { |
| if s.Specialist != wire.SpecialistMerge { |
| p.work = s |
| } |
| + if freeRound(s) && p.free < wire.MaxFixRounds { |
| + p.free++ |
| + } |
| switch s.Specialist { |
| case wire.SpecialistEngineering: |
| p.eng = s |
| @@ -168,7 +181,7 @@ func (p progress) needsYou(k taskRecord) string { |
| // outcome (connectors spec §8). |
| return wire.NeedsHeld |
| } |
| - if p.last.State != wire.StepDone || p.eng == nil || max(k.RepairRound, p.eng.Round) < wire.MaxFixRounds { |
| + if p.last.State != wire.StepDone || p.eng == nil || max(k.RepairRound, p.eng.Round)-p.free < wire.MaxFixRounds { |
| return "" |
| } |
| checks, _, verdict, _ := p.judged() |
| @@ -364,7 +377,7 @@ func (t *txn) fixRound(k *taskRecord, p progress, steps []stepRecord) error { |
| if k.RepairRound < p.eng.Round { |
| k.RepairRound = p.eng.Round |
| } |
| - if k.RepairRound >= wire.MaxFixRounds || repeatedChecks(p, steps) { |
| + if k.RepairRound-p.free >= wire.MaxFixRounds || repeatedChecks(p, steps) { |
| return nil |
| } |
| if handled, err := t.copyRepair(k, p, steps); handled || err != nil { |
| @@ -525,11 +538,13 @@ func fixNoteKind(steps []stepRecord, s stepRecord, kind string) string { |
| if f == "" { |
| return "" |
| } |
| - if s.Round > wire.MaxFixRounds { |
| + // A round before that had no working shell did not count. |
| + counted := s.Round - progressOfKind(before, kind).free |
| + if counted > wire.MaxFixRounds { |
| // The person asked for another round after the automatic ones. |
| return fmt.Sprintf("Round %d, which the person asked for after the %d automatic fix rounds. Change only what this asks for, on top of the commit already on the branch:\n%s", s.Round, wire.MaxFixRounds, f) |
| } |
| - return fmt.Sprintf("Fix round %d of %d. Change only what this asks for, on top of the commit already on the branch:\n%s", s.Round, wire.MaxFixRounds, f) |
| + return fmt.Sprintf("Fix round %d of %d. Change only what this asks for, on top of the commit already on the branch:\n%s", counted, wire.MaxFixRounds, f) |
| } |
| func checksLine(c stepRecord) string { |
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go| index e1c9898a..25057ef5 100644 |
| --- a/internal/equipo/chat/tasks.go |
| +++ b/internal/equipo/chat/tasks.go |
| @@ -1303,10 +1303,11 @@ func (t *txn) stepReport(l Lease, v *wire.StepReport) error { |
| if v.BaseSHA != "" && !validSHA(v.BaseSHA) || v.CandidateSHA != "" && !validSHA(v.CandidateSHA) { |
| return ErrInvalid |
| } |
| - if !wire.StepReasons[v.Reason] { |
| - // A reason this instance does not know (a newer runner) is recorded |
| - // as unknown: refusing it would close the connection and the |
| - // durable report would be refused again on every replay. |
| + if !wire.StepReasons[v.Reason] || wire.DoneOnlyReasons[v.Reason] && v.State != wire.StepDone { |
| + // A reason this instance does not know (a newer runner), or a |
| + // done-only reason on a step that is not done, is recorded as |
| + // unknown: refusing it would close the connection and the durable |
| + // report would be refused again on every replay. |
| v.Reason = wire.ReasonUnknown |
| } |
| switch v.State { |
| @@ -1559,7 +1560,9 @@ func (t *txn) stepReport(l Lease, v *wire.StepReport) error { |
| // step_timeout: the step ran out of time and the runner |
| // pushed the work it had done; checks and review judge it, |
| // and it is never taken for finished. |
| - if v.Reason == "proposal_failed" || v.Reason == reasonUnfinished { |
| + // shell_unavailable: a fix round without a working shell, |
| + // which does not count against the task's rounds. |
| + if v.Reason == "proposal_failed" || v.Reason == reasonUnfinished || v.Reason == wire.ReasonShellUnavailable { |
| s.Reason = v.Reason |
| } |
| s.Pushed = true |
diff --git a/internal/equipo/copy_test.go b/internal/equipo/copy_test.go| index 10524213..82fa14a3 100644 |
| --- a/internal/equipo/copy_test.go |
| +++ b/internal/equipo/copy_test.go |
| @@ -59,7 +59,7 @@ func TestRunnerCopyInventory(t *testing.T) { |
| // repository, 2026-11-07). |
| func TestStepReasonsHaveWords(t *testing.T) { |
| for reason := range wire.StepReasons { |
| - if reason == "" || reason == "cancelled" { |
| + if reason == "" || reason == "cancelled" || wire.DoneOnlyReasons[reason] { |
| continue |
| } |
| if copyText("work.reason."+reason) == "" { |
diff --git a/internal/runner/thin/engineer.go b/internal/runner/thin/engineer.go| index d25c3f52..45ac414e 100644 |
| --- a/internal/runner/thin/engineer.go |
| +++ b/internal/runner/thin/engineer.go |
| @@ -386,8 +386,14 @@ func (e *Engineer) Exec(ctx context.Context, r stepRow, progress func(wire.StepR |
| r.Base, r.Candidate, rep.CandidateSHA = base, sha, sha |
| progress(rep) |
| rep = e.publish(ctx, r, rep) |
| - if unfinished && rep.Pushed { |
| + switch { |
| + case !rep.Pushed: |
| + case unfinished: |
| rep.Reason = res.reason |
| + case res.noShell && r.Round >= 1 && !r.Rebase: |
| + // A fix round without a working shell: the instance does not |
| + // count it against the task's rounds. |
| + rep.Reason = wire.ReasonShellUnavailable |
| } |
| // The person can ask Engineering about the change it pushed. |
| rep.Askable = kept && rep.Pushed |
| @@ -791,6 +797,8 @@ type stepResult struct { |
| // modelGone: the provider said the step's model does not exist |
| // (§16.4, "After a step fails"). |
| modelGone bool |
| + // noShell: a Claude step ran Bash and no call worked (shellUse). |
| + noShell bool |
| // refused counts the tool requests Equipo refused during the run |
| // (the permission callback's denials, Pi's asks, Codex's approvals). |
| refused int64 |
| @@ -1052,8 +1060,9 @@ func (e *Engineer) run(ctx context.Context, r stepRow, tree workspace.TaskTree, |
| logFile = e.openLog(r) |
| } |
| defer logFile.Close() |
| - res := e.converse(ctx, proc, session, policy, b.Model, frames, logFile, limit, spec.prompt, spec.images, spec.stream, spec.activity) |
| - res.session, res.refused = session, refused.Load() |
| + var shell shellUse |
| + res := e.converse(ctx, proc, session, policy, b.Model, frames, logFile, limit, spec.prompt, spec.images, spec.stream, spec.activity, &shell) |
| + res.session, res.refused, res.noShell = session, refused.Load(), shell.none() |
| res.terminated = stopStep(func() { proc.Stdin().Close() }, exited, kill, ctx.Err() == nil && res.reason == "", 10*time.Second, 30*time.Second) |
| if !res.terminated { |
| // The namespace record stays: a restarted runner verifies it. |
| @@ -1100,7 +1109,7 @@ func stopStep(closeStdin func(), exited <-chan error, kill func(), graceful bool |
| } |
| // converse sends the prompt and reads frames to the result. |
| -func (e *Engineer) converse(ctx context.Context, proc provider.Process, session string, policy provider.Policy, model string, frames <-chan []byte, logFile io.Writer, limit time.Duration, prompt string, images []claude.Image, stream *answerStream, activity func(kind, subject string)) stepResult { |
| +func (e *Engineer) converse(ctx context.Context, proc provider.Process, session string, policy provider.Policy, model string, frames <-chan []byte, logFile io.Writer, limit time.Duration, prompt string, images []claude.Image, stream *answerStream, activity func(kind, subject string), shell *shellUse) stepResult { |
| tail := &stepTail{} |
| lastActivity := "" |
| raw, err := claude.UserContent(session, prompt, images) |
| @@ -1151,6 +1160,9 @@ func (e *Engineer) converse(ctx context.Context, proc provider.Process, session |
| if sig := connect.ClaudeSignal(ev.Payload); sig != "" { |
| signal = sig |
| } |
| + if shell != nil && (ev.Kind == "message" || ev.Kind == "user") { |
| + shell.frame(ev.Payload) |
| + } |
| switch ev.Kind { |
| case "session.init": |
| if err := claude.ValidateInit(policy, model, ev.Payload); err != nil { |
| @@ -1282,6 +1294,54 @@ func toolActivity(raw []byte) [][2]string { |
| return out |
| } |
| +// shellUse follows a Claude step's shell: the Bash calls it made, and how |
| +// many came back without an error. |
| +type shellUse struct { |
| + calls map[string]bool |
| + made, worked int |
| +} |
| + |
| +// frame reads one stream frame: an assistant's Bash calls, and the |
| +// results of those calls. |
| +func (s *shellUse) frame(raw []byte) { |
| + var v struct { |
| + Type string `json:"type"` |
| + Message struct { |
| + Content []struct { |
| + Type string `json:"type"` |
| + ID string `json:"id"` |
| + Name string `json:"name"` |
| + ToolUseID string `json:"tool_use_id"` |
| + IsError bool `json:"is_error"` |
| + } `json:"content"` |
| + } `json:"message"` |
| + } |
| + if json.Unmarshal(raw, &v) != nil { |
| + return |
| + } |
| + for _, c := range v.Message.Content { |
| + switch { |
| + case v.Type == "assistant" && c.Type == "tool_use" && c.Name == "Bash" && c.ID != "": |
| + if s.calls == nil { |
| + s.calls = map[string]bool{} |
| + } |
| + if !s.calls[c.ID] { |
| + s.calls[c.ID] = true |
| + s.made++ |
| + } |
| + case v.Type == "user" && c.Type == "tool_result" && s.calls[c.ToolUseID]: |
| + delete(s.calls, c.ToolUseID) |
| + if !c.IsError { |
| + s.worked++ |
| + } |
| + } |
| + } |
| +} |
| + |
| +// none: the step ran Bash and no call worked (refused, or the sandbox |
| +// could not start): it had no working shell. |
| +func (s *shellUse) none() bool { return s.made > 0 && s.worked == 0 } |
| + |
| // stepTail keeps the last lines a person can follow: the tools the |
| // specialist used (name and file, or the command's first line) and its |
| // text, bounded. |
diff --git a/internal/runner/thin/shell_use_test.go b/internal/runner/thin/shell_use_test.go| new file mode 100644 |
| index 00000000..8e7e5a69 |
| --- /dev/null |
| +++ b/internal/runner/thin/shell_use_test.go |
| @@ -0,0 +1,39 @@ |
| +package thin |
| + |
| +import "testing" |
| + |
| +// A Claude step's shell worked when one of its Bash calls came back |
| +// without an error; it had none when it ran Bash and every call failed |
| +// (refused, or the sandbox could not start). A step that never ran Bash |
| +// had a shell it did not use. |
| +func TestShellUse(t *testing.T) { |
| + bash := func(id string) []byte { |
| + return []byte(`{"type":"assistant","session_id":"s","message":{"content":[{"type":"tool_use","id":"` + id + `","name":"Bash","input":{"command":"go test ./..."}}]}}`) |
| + } |
| + read := []byte(`{"type":"assistant","session_id":"s","message":{"content":[{"type":"tool_use","id":"r1","name":"Read","input":{"file_path":"/workspace/a"}}]}}`) |
| + result := func(id string, failed bool) []byte { |
| + e := "false" |
| + if failed { |
| + e = "true" |
| + } |
| + return []byte(`{"type":"user","session_id":"s","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"` + id + `","content":"x","is_error":` + e + `}]}}`) |
| + } |
| + for name, c := range map[string]struct { |
| + frames [][]byte |
| + none bool |
| + }{ |
| + "never ran": {[][]byte{read, result("r1", true)}, false}, |
| + "all refused": {[][]byte{bash("b1"), result("b1", true), bash("b2"), result("b2", true), read, result("r1", false)}, true}, |
| + "one worked": {[][]byte{bash("b1"), result("b1", true), bash("b2"), result("b2", false)}, false}, |
| + "no result yet": {[][]byte{bash("b1")}, true}, |
| + "another's error": {[][]byte{bash("b1"), result("b1", false), result("zz", true)}, false}, |
| + } { |
| + var s shellUse |
| + for _, f := range c.frames { |
| + s.frame(f) |
| + } |
| + if s.none() != c.none { |
| + t.Errorf("%s: none %v, want %v (%+v)", name, s.none(), c.none, s) |
| + } |
| + } |
| +} |
diff --git a/internal/thintest/shell_round_contract_test.go b/internal/thintest/shell_round_contract_test.go| new file mode 100644 |
| index 00000000..9ba74d4a |
| --- /dev/null |
| +++ b/internal/thintest/shell_round_contract_test.go |
| @@ -0,0 +1,58 @@ |
| +package thintest |
| + |
| +import ( |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// TestShellUnavailableRoundIsFree (stopped-jobs audit, fix 4): a fix |
| +// round the engineer ran without a working shell (the runner reports it |
| +// done with shell_unavailable) does not count against the task's two |
| +// automatic rounds; at most two such rounds are free. The next round is |
| +// still told it is round 1 of 2. |
| +func TestShellUnavailableRoundIsFree(t *testing.T) { |
| + for _, free := range []int{0, 1, 3} { |
| + r := newToolRigAt(t, wire.ProtocolCurrent) |
| + base := strings.Repeat("1", 40) |
| + sha := func(n int) string { return strings.Repeat(string(rune('2'+n)), 40) } |
| + id, _ := r.pushed("f", "Add project rename control", base, sha(0)) |
| + task := r.task(id) |
| + r.expect(wire.FrameWatchMerge) |
| + rounds := 0 |
| + for n := 0; ; n++ { |
| + c := r.dispatched(wire.SpecialistChecks, base, sha(n), n) |
| + r.step("f-c"+itoa(n), hostedReport(c, task.Branch, wire.HostedFailure, "compile")) |
| + if r.task(id).NeedsYou == wire.NeedsFixRounds { |
| + break |
| + } |
| + fix := r.dispatched(wire.SpecialistEngineering, sha(n), "", n+1) |
| + reason := "" |
| + if n < free { |
| + reason = "shell_unavailable" |
| + } |
| + counted := n + 1 - min(n, free, wire.MaxFixRounds) |
| + if want := "Fix round " + itoa(counted) + " of 2."; !strings.Contains(fix.Feedback, want) { |
| + t.Fatalf("free %d, round %d: feedback lacks %q: %q", free, n+1, want, fix.Feedback) |
| + } |
| + r.step("f-e"+itoa(n), wire.StepReport{TaskID: id, StepID: fix.StepID, Attempt: 1, State: wire.StepDone, Reason: reason, BaseSHA: sha(n), CandidateSHA: sha(n + 1), Pushed: true, Termination: true}) |
| + r.expect(wire.FrameWatchMerge) |
| + rounds++ |
| + } |
| + if want := wire.MaxFixRounds + min(free, wire.MaxFixRounds); rounds != want { |
| + t.Fatalf("free %d: %d automatic rounds, want %d", free, rounds, want) |
| + } |
| + } |
| +} |
| + |
| +// shell_unavailable is a done step's reason only: a step that stopped |
| +// with it is recorded as stopped for an unknown reason. |
| +func TestShellUnavailableOnlyOnDone(t *testing.T) { |
| + r := newToolRigAt(t, wire.ProtocolCurrent) |
| + id, d := r.started("x", "Stopped oddly") |
| + r.stop("x", d, wire.ReasonShellUnavailable) |
| + if s := r.task(id).Steps[0]; s.State != wire.StepFailed || s.Reason != wire.ReasonUnknown { |
| + t.Fatalf("step %+v", s) |
| + } |
| +} |
diff --git a/internal/wire/tasks.go b/internal/wire/tasks.go| index 6ea9b383..d4a4e5fe 100644 |
| --- a/internal/wire/tasks.go |
| +++ b/internal/wire/tasks.go |
| @@ -1000,6 +1000,17 @@ type StepRun struct { |
| CandidateSHA string `json:"candidate_sha"` |
| } |
| +// ReasonShellUnavailable is a pushed Engineering fix round whose engineer |
| +// ran shell commands and none worked, so it could not check its work |
| +// (stopped-jobs audit, 2026-11-25, fix 4): the round does not count |
| +// against the task's rounds, up to MaxFixRounds such rounds. |
| +const ReasonShellUnavailable = "shell_unavailable" |
| + |
| +// DoneOnlyReasons are reasons a runner reports only on a done step, where |
| +// no reason is shown as a stop: on any other state the instance records |
| +// them as unknown, so they need no words of their own. |
| +var DoneOnlyReasons = map[string]bool{ReasonShellUnavailable: true} |
| + |
| // StepReasons are the failure codes a runner may report for a step. |
| var StepReasons = map[string]bool{ |
| "copy_budget": true, |
| @@ -1027,6 +1038,10 @@ var StepReasons = map[string]bool{ |
| // tool requests it made (no_changes otherwise). An older instance |
| // records it as unknown. |
| "tools_refused": true, |
| + // A pushed Engineering fix round whose shell commands all failed: it |
| + // does not count against the task's rounds. An older instance takes |
| + // the step as done. |
| + ReasonShellUnavailable: true, |
| // Checks and review. |
| "candidate_unavailable": true, |
| "no_verdict": true, |