design: a republish that runs Design afresh records its own protocol
Follow-up review of M4. dispatchTo keeps a republish's source
dispatch protocol, which assumed a republish never runs Design; when
the recorded commit is gone the runner falls back to running Design
afresh (engineer.go). That fallback launches through the launch check
(F1), so the check now records the protocol the fresh execution runs
at (the runner's, at 39) on the attempt, and its stale-notes check
then applies to it too. An actual republication keeps the source's.
Found while testing: a republish's done report is accepted only for
its own recorded commit (tasks.go, Engineering done), so the fresh
commit's report is not accepted at all and never reaches Review
(behaviour from before this round, unchanged). The minimum-option
bypass described in the review is therefore not reachable through
that path; the protocol is recorded regardless.
Test (RED first):
go test ./internal/equipo/chat/ -run TestRepublishFallbackRunsUnderNewRules
(38 source, Retry at 39, prepare and launch checks of the fallback,
a short fresh set; and a real republication)
RED: "the fresh execution recorded at 38"
GREEN: ok; also -run 'TestRepublish|TestHeldDesignLaunch|Stale|
Forget|TestKeptFor'
Mutation: not recording at the launch check is the RED above.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+56
−1
internal/equipo/chat/design_feedback_options_test.go+43 −0internal/equipo/chat/runners.go+10 −0internal/equipo/chat/tasks.go+3 −1
diff --git a/internal/equipo/chat/design_feedback_options_test.go b/internal/equipo/chat/design_feedback_options_test.go| index 88f5cabc..fd1717a5 100644 |
| --- a/internal/equipo/chat/design_feedback_options_test.go |
| +++ b/internal/equipo/chat/design_feedback_options_test.go |
| @@ -433,3 +433,46 @@ func TestRepublishKeepsSourceProtocol(t *testing.T) { |
| t.Fatalf("%d Review steps", n) |
| } |
| } |
| + |
| +// TestRepublishFallbackRunsUnderNewRules (follow-up review of M4): when |
| +// the commit a republish was to publish is gone, the runner runs Design |
| +// afresh (engineer.go's fallback), right after a launch check. That |
| +// launch records the protocol the fresh execution runs at, not its |
| +// source attempt's, so nothing it makes is judged by the old rules. (The |
| +// fresh commit's report is not accepted for a republish at all, as |
| +// before this round: a republish's done is only for its own recorded |
| +// commit; it never reaches Review.) |
| +func TestRepublishFallbackRunsUnderNewRules(t *testing.T) { |
| + r, l, task, s := designAt(t, wire.ProtocolDesignFeedback, wire.KindExplore) |
| + r.exec("UPDATE chat_steps SET dispatch_protocol = ? WHERE id = ?", wire.ProtocolDesign, s.ID) |
| + s = r.stepNow(s.ID) |
| + r.report(l, s, wire.StepReport{State: wire.StepFailed, Reason: "push_failed", BaseSHA: strings.Repeat("b", 40), CandidateSHA: candidateSHA, Termination: true}) |
| + if _, err := r.s.RetryTask(r.ctx, paul, task); err != nil { |
| + t.Fatal(err) |
| + } |
| + re := r.stepNow(s.ID) |
| + if !re.Republish || re.DispatchProtocol != wire.ProtocolDesign { |
| + t.Fatalf("republish %+v", re) |
| + } |
| + r.ackDispatches(re.ID) |
| + for _, purpose := range []string{"", wire.LeasePurposeLaunch} { |
| + if refused := r.authorize(l, re, purpose); refused != "" { |
| + t.Fatalf("the fallback's %q check: %q", purpose, refused) |
| + } |
| + } |
| + if got := r.stepNow(re.ID).DispatchProtocol; got != wire.ProtocolDesignFeedback { |
| + t.Fatalf("the fresh execution recorded at %d", got) |
| + } |
| + r.report(l, re, wire.StepReport{State: wire.StepRunning, BaseSHA: strings.Repeat("b", 40), CandidateSHA: thirdSHA}) |
| + re = r.stepNow(re.ID) |
| + r.doneWith(l, re, thirdSHA, []wire.DesignOption{r.option39(l, re, 1, "Calm", 1), r.option39(l, re, 2, "Bold", 1)}) |
| + if n := r.reviews(task); n != 0 { |
| + t.Fatalf("a short fresh set reached Review: %d", n) |
| + } |
| + // An actual republication (its commit there) keeps the source's. |
| + r2, l2, task2, s2 := designAt(t, wire.ProtocolDesignFeedback, wire.KindExplore) |
| + r2.exec("UPDATE chat_steps SET dispatch_protocol = ? WHERE id = ?", wire.ProtocolDesign, s2.ID) |
| + if got := r2.pushFailedRepublished(l2, task2, r2.stepNow(s2.ID)); got.DispatchProtocol != wire.ProtocolDesign { |
| + t.Fatalf("a republication recorded at %d", got.DispatchProtocol) |
| + } |
| +} |
diff --git a/internal/equipo/chat/runners.go b/internal/equipo/chat/runners.go| index be6213fe..21a168b7 100644 |
| --- a/internal/equipo/chat/runners.go |
| +++ b/internal/equipo/chat/runners.go |
| @@ -1010,6 +1010,16 @@ func (s *Store) Authorize(ctx context.Context, l Lease, stepID string, attempt i |
| // below 39 sends only plain checks, so one of those from below |
| // 39 is checked too. |
| launch := purpose == wire.LeasePurposeLaunch || purpose == "" && l.Protocol < wire.ProtocolDesignFeedback |
| + if purpose == wire.LeasePurposeLaunch && st.Republish && st.DispatchProtocol < l.Protocol { |
| + // A republish whose commit is gone runs Design afresh |
| + // (the runner's fallback): that execution is judged by |
| + // the protocol it runs at, not its source attempt's |
| + // (dispatchTo keeps the source's for a republication). |
| + st.DispatchProtocol = l.Protocol |
| + if err := t.db.Model(&stepRecord{}).Where("id = ? AND attempt = ?", st.ID, st.Attempt).Update("dispatch_protocol", st.DispatchProtocol).Error; err != nil { |
| + return err |
| + } |
| + } |
| if st.DispatchProtocol < wire.ProtocolDesignFeedback || !launch && (purpose != "" || st.StartedAttempt == st.Attempt) { |
| return nil |
| } |
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go| index 63d4aedf..266b53e4 100644 |
| --- a/internal/equipo/chat/tasks.go |
| +++ b/internal/equipo/chat/tasks.go |
| @@ -1439,7 +1439,9 @@ func (t *txn) dispatchStep(k *taskRecord, s *stepRecord) error { |
| // per dispatch, never by a reconnect; 0 when the runner has no |
| // connection on record. A republish keeps its source attempt's: it runs |
| // no Design, so its report (the source's commit and kept options) is |
| -// judged by the rules the source ran under. |
| +// judged by the rules the source ran under; if its commit is gone and |
| +// the runner runs Design afresh, the launch check records the protocol |
| +// it runs at (Authorize). |
| func (t *txn) dispatchTo(s *stepRecord, cmd wire.DispatchCommand) error { |
| var sess runnerSessionRecord |
| if err := t.db.Where("runner_id = ?", s.RunnerID).Limit(1).Find(&sess).Error; err != nil { |