design: each More tap is its own round, whatever it asks
Follow-up review of M8. The round base was found by the stored
design_ask changing; two More options taps with the same request (no
note, the same current options) produced identical JSON, so the second
round inherited the first's spent fix-round allowance and went
straight to fix_rounds.
designAsk now stores round, the id of the card whose tap started the
round, beside the request (stored only: the dispatch decodes the
request into wire.DesignAsk without it). Fix rounds and Try another
round copy the whole string, so they stay in the round; a new tap is
always a new round.
Test (RED first):
go test ./internal/equipo/chat/ -run TestIdenticalMoreTapsAreSeparateRounds
(first More round spends both fix rounds keeping round 0's options;
the second identical tap's short set)
RED: "no fix round for the second identical tap: ... round 4;
needs \"fix_rounds\""
GREEN: ok; also -run 'Round|Ask|Direction|More|Like'
Mutation: round "" for every tap -> the RED above.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+46
−4
internal/equipo/chat/direction_options.go+9 −3internal/equipo/chat/direction_options_test.go+36 −0internal/equipo/chat/explore.go+1 −1
diff --git a/internal/equipo/chat/direction_options.go b/internal/equipo/chat/direction_options.go| index 7154e013..6af07c4d 100644 |
| --- a/internal/equipo/chat/direction_options.go |
| +++ b/internal/equipo/chat/direction_options.go |
| @@ -120,8 +120,11 @@ func askOption(o wire.StepDesignOption) wire.StepDesignOption { |
| // designAsk is the stored request (step's DesignAsk JSON) of a More |
| // options (chosen nil) or More like this round: the current round's |
| -// options and the person's note. |
| -func designAsk(kind, note string, current []wire.StepDesignOption, chosen *chosenOption) string { |
| +// options and the person's note, and round, the card whose tap started |
| +// it: two taps that ask the same are still separate rounds |
| +// (progressOfKind's base), and a fix round inherits the whole string. |
| +// round is stored only; the dispatch decodes the request without it. |
| +func designAsk(kind, note, round string, current []wire.StepDesignOption, chosen *chosenOption) string { |
| a := wire.DesignAsk{Kind: kind, Note: note} |
| for _, o := range current { |
| a.Current = append(a.Current, askOption(o)) |
| @@ -130,7 +133,10 @@ func designAsk(kind, note string, current []wire.StepDesignOption, chosen *chose |
| o := askOption(chosen.Option) |
| a.Option = &o |
| } |
| - raw, _ := json.Marshal(a) |
| + raw, _ := json.Marshal(struct { |
| + wire.DesignAsk |
| + Round string `json:"round"` |
| + }{a, round}) |
| return string(raw) |
| } |
diff --git a/internal/equipo/chat/direction_options_test.go b/internal/equipo/chat/direction_options_test.go| index a8282228..d5e5d570 100644 |
| --- a/internal/equipo/chat/direction_options_test.go |
| +++ b/internal/equipo/chat/direction_options_test.go |
| @@ -587,3 +587,39 @@ func TestTryAnotherRoundKeepsAsk(t *testing.T) { |
| t.Fatalf("Try another round started a new round: base %d", p.base) |
| } |
| } |
| + |
| +// TestIdenticalMoreTapsAreSeparateRounds (follow-up review of M8): two |
| +// More options taps whose requests say the same (no note, the same |
| +// current options) are still separate rounds: the second counts its fix |
| +// rounds from its own start, so a short set gets a fix round. |
| +func TestIdenticalMoreTapsAreSeparateRounds(t *testing.T) { |
| + 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) |
| + // The first More round uses both its fix rounds (Review asks for |
| + // changes twice, then approves), keeping the same three options as |
| + // round 0 throughout, so the second tap's request lists the very |
| + // same current options. |
| + names := []string{"Calm", "Writing desk", "Bold"} |
| + r.keptRound(l, task, first, secondSHA, wire.VerdictChanges, names...) |
| + fix1 := r.startRound(l, task, "e0e0e00000000000000000000000000000000004") |
| + r.keptRound(l, task, fix1, "e0e0e00000000000000000000000000000000004", wire.VerdictChanges, names...) |
| + fix2 := r.startRound(l, task, "f0f0f00000000000000000000000000000000005") |
| + if fix2.Round != first.Round+2 { |
| + t.Fatalf("fix rounds of the first: %d after %d", fix2.Round, first.Round) |
| + } |
| + r.keptRound(l, task, fix2, "f0f0f00000000000000000000000000000000005", wire.VerdictApprove, names...) |
| + if err := r.answerCard(r.openDirection(task), wire.AnswerCard{Choice: wire.ChoiceMore}); err != nil { |
| + t.Fatal(err) |
| + } |
| + second := r.startRound(l, task, thirdSHA) |
| + if !sameAsk(stepAskOf(t, first), stepAskOf(t, second)) { |
| + t.Fatalf("the requests differ: %q %q", first.DesignAsk, second.DesignAsk) |
| + } |
| + r.doneWith(l, second, thirdSHA, []wire.DesignOption{r.option39(l, second, 1, "Loud", 1), r.option39(l, second, 2, "Louder", 1)}) |
| + if fix := r.makerStep(task); fix.ID == second.ID || fix.Round != second.Round+1 || fix.DesignAsk != second.DesignAsk { |
| + t.Fatalf("no fix round for the second identical tap: newest %s round %d; needs %q", fix.ID, fix.Round, r.needs(task)) |
| + } |
| +} |
diff --git a/internal/equipo/chat/explore.go b/internal/equipo/chat/explore.go| index b96b7b80..791738ac 100644 |
| --- a/internal/equipo/chat/explore.go |
| +++ b/internal/equipo/chat/explore.go |
| @@ -337,7 +337,7 @@ func (t *txn) answerDirection(person string, c cardRecord, in wire.AnswerCard) ( |
| if in.Choice == wire.ChoiceLike { |
| kind = wire.DesignAskLike |
| } |
| - s.Note, s.DesignAsk = "", designAsk(kind, note, current, chosen) |
| + s.Note, s.DesignAsk = "", designAsk(kind, note, c.ID, current, chosen) |
| } |
| // Asked afresh after the round, even about the same commit. |
| k.Stage, k.DirectionAsked = wire.StageInProgress, "" |