oficina / equipo Public

runner: a failover's next attempt reports no pack until its launch

Task 3 review, fix round 2 (spec 8.8). advanceStep cleared
steps.pack_digest but queued the advance frame, which names the next
attempt, with the refused attempt's digest; Engineer.refused moved the
in-memory report to the next attempt keeping it too, so a next attempt
deferred, held or cancelled before its launch reported a pack it never
ran with. Both now clear PackDigest; the next launch sets its own.

Test: TestFailoverReportsNoPackBeforeLaunch. One limited Claude
connection: the step is deferred at attempt 2 with no digest, and the
queued advance frame (attempt 2, running) carries none. Two limited
connections with attempt 2's authorization withdrawn: cancelled at
attempt 2 with no digest. Before the fix it failed: "deferred next
attempt: deferred attempt 2 pack baa2a924...".
Run: thin -run 'Design|Failover|Refus|Advance|Limit|Switch|PackDigest|
PackChange|Prompt' ok (82.6 s); go vet linux and darwin/arm64 ok.

Mutations (each alone, restored), both FAILED the test:
- G1 the advance frame keeps the digest: "the advance frame names
  attempt 2 with pack baa2a924...".
- G2 refused keeps the in-memory digest: "deferred next attempt ...
  pack baa2a924...".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev eade2e621a7012cfd899f4000e7ddd80b5180edb parent 67dfc34
3 files changed, +50 −2
  • internal/runner/thin/design_prompt_linux_test.go +44 −0
  • internal/runner/thin/engineer.go +3 −1
  • internal/runner/thin/step.go +3 −1
diff --git a/internal/runner/thin/design_prompt_linux_test.go b/internal/runner/thin/design_prompt_linux_test.go
index e46cfbb6..66990572 100644
--- a/internal/runner/thin/design_prompt_linux_test.go
+++ b/internal/runner/thin/design_prompt_linux_test.go
@@ -178,3 +178,47 @@ func TestPackChangeStartsAFreshSession(t *testing.T) {
t.Fatalf("round 1 resumed another pack's session: %+v", fix)
}
}
+
+// TestFailoverReportsNoPackBeforeLaunch (spec 8.8): when the provider
+// refuses a Design attempt and the step moves to its next attempt, the
+// queued advance frame (which names the next attempt) carries no pack
+// digest, and neither does that attempt's report when it ends before
+// its launch: deferred for want of a connection, or cancelled when its
+// authorization is withdrawn. The refused attempt ran; the next did not.
+func TestFailoverReportsNoPackBeforeLaunch(t *testing.T) {
+ // Deferred: the person's one Claude connection is limited.
+ r := newDesignRig(t)
+ r.e.Note = " steplimit:" + connPerson + "\n"
+ rep := r.exec(stepRow{DispatchCommand: designDispatch("ds1", 1)})
+ if rep.State != stepDeferred || rep.Attempt != 2 || rep.PackDigest != "" {
+ t.Fatalf("deferred next attempt: %s attempt %d pack %q", rep.State, rep.Attempt, rep.PackDigest)
+ }
+ advanced := false
+ for _, f := range outbox(t, r.e.O.State) {
+ if f.StepID == "ds1" && f.Attempt == 2 && f.State == wire.StepRunning {
+ advanced = true
+ if f.PackDigest != "" {
+ t.Fatalf("the advance frame names attempt 2 with pack %q", f.PackDigest)
+ }
+ }
+ }
+ if !advanced {
+ t.Fatal("no advance frame queued")
+ }
+
+ // Cancelled: attempt 2's authorization is withdrawn before launch.
+ r = newDesignRig(t)
+ r.addClaude("claude-b", "b@example.com")
+ r.ackSteps()
+ r.e.AuthorizeStep = func(_ context.Context, _ string, attempt int64) error {
+ if attempt > 1 {
+ return ErrWithdrawn
+ }
+ return nil
+ }
+ r.e.Note = " steplimit:" + connPerson + " steplimit:b@example.com\n"
+ rep = r.exec(stepRow{DispatchCommand: designDispatch("ds2", 1)})
+ if rep.State != wire.StepCancelled || rep.Attempt != 2 || rep.PackDigest != "" {
+ t.Fatalf("cancelled next attempt: %s attempt %d pack %q", rep.State, rep.Attempt, rep.PackDigest)
+ }
+}
diff --git a/internal/runner/thin/engineer.go b/internal/runner/thin/engineer.go
index 6ed06583..1745b9ba 100644
--- a/internal/runner/thin/engineer.go
+++ b/internal/runner/thin/engineer.go
@@ -540,7 +540,9 @@ func (e *Engineer) refused(ctx context.Context, r *stepRow, rep *wire.StepReport
e.log("step attempt", err)
return false
}
- rep.Attempt = r.Attempt
+ // The report now speaks for the next attempt, which has not run:
+ // its launch sets the pack it runs with (spec 8.8).
+ rep.Attempt, rep.PackDigest = r.Attempt, ""
return true
}
diff --git a/internal/runner/thin/step.go b/internal/runner/thin/step.go
index d5bb3f31..3088a0a3 100644
--- a/internal/runner/thin/step.go
+++ b/internal/runner/thin/step.go
@@ -435,7 +435,9 @@ func (s *State) advanceStep(ctx context.Context, r *stepRow, used []wire.Usage,
return err
}
}
- rep.Attempt, rep.State, rep.Reason = next.Attempt, wire.StepRunning, ""
+ // The frame names the next attempt, which has run with no pack
+ // yet: its launch records its own (spec 8.8).
+ rep.Attempt, rep.State, rep.Reason, rep.PackDigest = next.Attempt, wire.StepRunning, "", ""
return s.enqueue(t, wire.FrameStep, "", rep)
})
if err == nil {