design: a More round counts its fix rounds from its own start
Final review M8 (Fable 11). Real: round numbers are task-wide and
MaxFixRounds is 2, so a second More options round (round 2, after a
first one Review approved) whose set was short, or that Review asked
to change, went straight to needs fix_rounds with no automatic fix
round (RED below).
progressOfKind now records where the newest More options or More like
this round started (base: a non-rebase maker step whose design_ask
differs from the step before's; its fix rounds and Try another round
carry the same one), and counts free rounds only since then. fixRound,
needsExplore (short set and Review's changes) and the fix round's
"Fix round N of 2" line count from that base.
Not changed: Try again on the direction card uses the same task-wide
arithmetic (Round = max + 1), so it does not start its count afresh
either; the fix list's premise that it does is not what the code
does. Left as it was (out of this item's scope), noted in the report.
Tests (RED first):
go test ./internal/equipo/chat/ -run 'TestSecondMoreRoundGetsFixRounds|TestRoundBase'
RED: "no automatic fix round 1 of the second More round: newest
... round 2 (after ... round 2); needs \"fix_rounds\""
GREEN: ok; whole chat package ok (36 s)
Mutations (each restored):
fixRound without base -> "no automatic fix round 1"
FAIL
needsExplore short check w/o base -> "short set 0: needs
\"fix_rounds\"" FAIL
needsExplore Review check w/o base -> "Review's changes on the
second More round: needs
\"fix_rounds\"" FAIL
feedback count w/o base -> "fix round 1 feedback \"Round
3, which the person asked
for...\"" FAIL
free not reset at a round start -> TestRoundBase "more resets
free" FAIL
rebase steps read as round starts -> TestRoundBase "a rebase" FAIL
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+132
−5
internal/equipo/chat/direction_options_test.go+111 −0internal/equipo/chat/explore.go+2 −2internal/equipo/chat/review.go+19 −3
diff --git a/internal/equipo/chat/direction_options_test.go b/internal/equipo/chat/direction_options_test.go| index f47ae2aa..1a69ba9f 100644 |
| --- a/internal/equipo/chat/direction_options_test.go |
| +++ b/internal/equipo/chat/direction_options_test.go |
| @@ -442,3 +442,114 @@ func TestBuildOptionNeedsItsWords(t *testing.T) { |
| t.Fatalf("built %q", k.BuiltAs) |
| } |
| } |
| + |
| +// moreRounds takes roundOfThree to a second More options round, just |
| +// started at candidate sha2 after a first one Review approved: the |
| +// task, the second round's step and its request. |
| +func moreRounds(t *testing.T) (*hkRig, Lease, string, stepRecord) { |
| + t.Helper() |
| + r, l, task, _, c := roundOfThree(t) |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceMore}); err != nil { |
| + t.Fatal(err) |
| + } |
| + first := r.startRound(l, task, secondSHA) |
| + r.keptRound(l, task, first, secondSHA, wire.VerdictApprove, "Night", "Day", "Dusk") |
| + if err := r.answerCard(r.openDirection(task), wire.AnswerCard{Choice: wire.ChoiceMore, Note: "Louder."}); err != nil { |
| + t.Fatal(err) |
| + } |
| + second := r.startRound(l, task, thirdSHA) |
| + if second.Round != first.Round+1 || second.DesignAsk == "" || second.DesignAsk == first.DesignAsk { |
| + t.Fatalf("second round %+v after %+v", second, first) |
| + } |
| + return r, l, task, second |
| +} |
| + |
| +// TestSecondMoreRoundGetsFixRounds (final review, M8 / Fable 11): round |
| +// numbers are task-wide, so a second More options round started at |
| +// round 2 went straight to fix_rounds when its set was short. A More |
| +// options or More like this round counts its automatic fix rounds from |
| +// its own start: a short set gets wire.MaxFixRounds fix rounds, each |
| +// inheriting the request, and only then does the person decide. |
| +func TestSecondMoreRoundGetsFixRounds(t *testing.T) { |
| + r, l, task, second := moreRounds(t) |
| + shas := []string{"e0e0e00000000000000000000000000000000004", "f0f0f00000000000000000000000000000000005", "a0a0a00000000000000000000000000000000006"} |
| + prev, at := second, thirdSHA |
| + for i := 0; i < wire.MaxFixRounds; i++ { |
| + r.doneWith(l, prev, at, []wire.DesignOption{r.option39(l, prev, 1, "Loud", 1), r.option39(l, prev, 2, "Louder", 1)}) |
| + // As the short set was reported, a fix round is due, not the |
| + // person (needsExplore agrees with fixRound). |
| + var steps []stepRecord |
| + r.must(r.s.db.G.Where("task_id = ? AND idx <= ?", task, prev.Idx).Order("idx").Find(&steps).Error) |
| + k := r.load(task) |
| + k.RepairRound = prev.Round // as it was then: the fix round raised it |
| + if need := progressFor(k, steps).needsExplore(k); need != "" { |
| + t.Fatalf("short set %d: needs %q", i, need) |
| + } |
| + fix := r.makerStep(task) |
| + if fix.ID == prev.ID || fix.Round != prev.Round+1 || fix.DesignAsk != second.DesignAsk { |
| + t.Fatalf("no automatic fix round %d of the second More round: newest %s round %d (after %s round %d); needs %q", i+1, fix.ID, fix.Round, prev.ID, prev.Round, r.needs(task)) |
| + } |
| + if _, d := r.dispatched(fix.ID); !strings.Contains(d.Feedback, designFeedbackOptions) || !strings.Contains(d.Feedback, "Fix round "+itoa64(int64(i+1))+" of 2.") { |
| + t.Fatalf("fix round %d feedback %q", i+1, d.Feedback) |
| + } |
| + prev = r.startRound(l, task, shas[i]) |
| + at = shas[i] |
| + } |
| + r.doneWith(l, prev, at, []wire.DesignOption{r.option39(l, prev, 1, "Loud", 1), r.option39(l, prev, 2, "Louder", 1)}) |
| + if fix := r.makerStep(task); fix.ID != prev.ID || r.needs(task) != wire.NeedsFixRounds { |
| + t.Fatalf("after %d fix rounds: newest %s, needs %q", wire.MaxFixRounds, fix.ID, r.needs(task)) |
| + } |
| + |
| + // Review asking for changes on the second round's set: a fix round |
| + // too, and the person is not asked meanwhile. |
| + r2, l2, task2, second2 := moreRounds(t) |
| + r2.keptRound(l2, task2, second2, thirdSHA, wire.VerdictChanges, "Loud", "Louder", "Loudest") |
| + fix := r2.makerStep(task2) |
| + if fix.ID == second2.ID || fix.Round != second2.Round+1 || fix.DesignAsk != second2.DesignAsk { |
| + t.Fatalf("no fix round after Review on the second More round: %s round %d; needs %q", fix.ID, fix.Round, r2.needs(task2)) |
| + } |
| + var steps []stepRecord |
| + r2.must(r2.s.db.G.Where("task_id = ? AND idx < ?", task2, fix.Idx).Order("idx").Find(&steps).Error) |
| + k := r2.load(task2) |
| + k.RepairRound = second2.Round |
| + if need := progressFor(k, steps).needsExplore(k); need != "" { |
| + t.Fatalf("Review's changes on the second More round: needs %q", need) |
| + } |
| +} |
| + |
| +// needs is the task's NeedsYou as Paul reads it. |
| +func (r *hkRig) needs(task string) string { |
| + r.t.Helper() |
| + v, err := r.s.Task(r.ctx, paul, task) |
| + r.must(err) |
| + return v.NeedsYou |
| +} |
| + |
| +// TestRoundBase: a More options or More like this round's start (a |
| +// round request unlike the step before's) is where its fix rounds count |
| +// from, and rounds without a shell before it no longer count as free; a |
| +// fix round or Try another round carrying the same request, and a |
| +// rebase, start nothing. |
| +func TestRoundBase(t *testing.T) { |
| + eng := func(round int, ask string) stepRecord { |
| + return stepRecord{Specialist: wire.SpecialistEngineering, Round: round, DesignAsk: ask, State: wire.StepDone, Pushed: true, CandidateSHA: candidateSHA} |
| + } |
| + shell := func(s stepRecord) stepRecord { s.Reason = wire.ReasonShellUnavailable; return s } |
| + rebase := eng(4, "") |
| + rebase.Rebase = true |
| + for name, c := range map[string]struct { |
| + steps []stepRecord |
| + base, free int |
| + }{ |
| + "first round": {[]stepRecord{eng(0, ""), shell(eng(1, ""))}, 0, 1}, |
| + "more resets free": {[]stepRecord{eng(0, ""), shell(eng(1, "")), eng(2, "more-a")}, 2, 0}, |
| + "its fix rounds": {[]stepRecord{eng(0, ""), eng(2, "more-a"), shell(eng(3, "more-a"))}, 2, 1}, |
| + "a rebase": {[]stepRecord{eng(0, ""), eng(2, "more-a"), rebase, eng(5, "more-a")}, 2, 0}, |
| + "another more": {[]stepRecord{eng(0, ""), eng(2, "more-a"), eng(3, "more-a"), eng(4, "more-b")}, 4, 0}, |
| + "try again between": {[]stepRecord{eng(2, "more-a"), eng(3, ""), eng(4, "more-a")}, 4, 0}, |
| + } { |
| + if p := progressOfKind(c.steps, wire.KindExplore); p.base != c.base || p.free != c.free { |
| + t.Errorf("%s: base %d free %d, want %d %d", name, p.base, p.free, c.base, c.free) |
| + } |
| + } |
| +} |
diff --git a/internal/equipo/chat/explore.go b/internal/equipo/chat/explore.go| index 32bbb701..b96b7b80 100644 |
| --- a/internal/equipo/chat/explore.go |
| +++ b/internal/equipo/chat/explore.go |
| @@ -62,7 +62,7 @@ func (p progress) needsExplore(k taskRecord) string { |
| // A Design attempt with no valid set of options never reaches |
| // Review: once its fix rounds are used up (fixRound), the person |
| // decides. |
| - if max(k.RepairRound, p.eng.Round)-p.free >= wire.MaxFixRounds || p.repeated { |
| + if max(k.RepairRound, p.eng.Round)-p.free-p.base >= wire.MaxFixRounds || p.repeated { |
| return wire.NeedsFixRounds |
| } |
| return "" |
| @@ -71,7 +71,7 @@ func (p progress) needsExplore(k taskRecord) string { |
| switch { |
| case verdict == wire.VerdictApprove: |
| return wire.NeedsDirection |
| - case verdict == wire.VerdictChanges && p.eng != nil && p.eng.Round >= wire.MaxFixRounds && p.candidate == p.eng.CandidateSHA: |
| + case verdict == wire.VerdictChanges && p.eng != nil && p.eng.Round-p.base >= wire.MaxFixRounds && p.candidate == p.eng.CandidateSHA: |
| return wire.NeedsFixRounds |
| } |
| return "" |
diff --git a/internal/equipo/chat/review.go b/internal/equipo/chat/review.go| index 41fd35bb..66cbe79c 100644 |
| --- a/internal/equipo/chat/review.go |
| +++ b/internal/equipo/chat/review.go |
| @@ -43,6 +43,11 @@ type progress struct { |
| // free is how many fix rounds do not count against the task's |
| // automatic rounds (freeRound). |
| free int |
| + // base is the round the newest More options or More like this round |
| + // started at (0 for none): such a round, like the task's first, |
| + // gets its own automatic fix rounds, counted from there (round |
| + // numbers are task-wide). free counts only the rounds since. |
| + base int |
| // unfinishedWork: the candidate holds the work of an Engineering step |
| // that ran out of time, with any Copy commit, rebase or fix round on |
| // top; unfinishedJudged, that a Review has judged such a candidate. |
| @@ -77,6 +82,7 @@ func counts(s *stepRecord, kind string) bool { |
| func progressOfKind(steps []stepRecord, kind string) progress { |
| p := progress{explore: wire.NormalKind(kind) == wire.KindExplore} |
| + ask := "" |
| for i := range steps { |
| s := &steps[i] |
| if s.Specialist == wire.SpecialistPreview || s.Specialist == wire.SpecialistResearch || s.Specialist == wire.SpecialistPublish { |
| @@ -95,6 +101,15 @@ func progressOfKind(steps []stepRecord, kind string) progress { |
| if s.Specialist != wire.SpecialistMerge { |
| p.work = s |
| } |
| + if s.Specialist == wire.SpecialistEngineering && !s.Rebase { |
| + // A round request (design_ask) unlike the one before is a |
| + // More options or More like this round's start; its fix |
| + // rounds (and Try another round) carry the same one. |
| + if s.DesignAsk != "" && s.DesignAsk != ask { |
| + p.base, p.free = s.Round, 0 |
| + } |
| + ask = s.DesignAsk |
| + } |
| if freeRound(s) && p.free < wire.MaxFixRounds { |
| p.free++ |
| } |
| @@ -401,7 +416,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-p.free >= wire.MaxFixRounds || repeatedChecks(p, steps) { |
| + if k.RepairRound-p.free-p.base >= wire.MaxFixRounds || repeatedChecks(p, steps) { |
| return nil |
| } |
| if handled, err := t.copyRepair(k, p, steps); handled || err != nil { |
| @@ -616,8 +631,9 @@ func fixNoteKind(steps []stepRecord, s stepRecord, kind string) string { |
| if f == "" { |
| return "" |
| } |
| - // A round before that had no working shell did not count. |
| - counted := s.Round - progressOfKind(before, kind).free |
| + // A round before that had no working shell did not count; a More |
| + // options or More like this round's fix rounds count from its start. |
| + counted := s.Round - prior.free - prior.base |
| 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) |