chat: Build, More like this and More options name an option
Task 6 of the Design feedback 1 plan (spec 8.1, 8.4, 8.7).
- AnswerCard.Option ({step, index from 0}) on the direction card. keptOption
accepts it only for a done, pushed Design maker step of this task whose
options were kept for its commit and whose newest Review of that commit
approved; anything else (index past the options, another task's step,
no approve, no such step) is ErrCardConflict with the current card. A
malformed ref (no step, negative index) is ErrInvalid.
- Build this one with an option needs no note; the brief names it from
records: "Build option N (Design's name for it: "<name>"), from branch B
at commit C, folder mockups/<task>/<page>/." (new copy key
work.explore.build_option, pending), the commit being the option's
round's, then the person's note, if any, as theirs. Build with a note
and no option (older clients) works as before; with neither and more
than one option it is still direction_note.
- raiseDirection offers more and like when Design made the candidate;
answerDirection accepts them (Design's work only, else ErrInvalid).
More options (note optional) and More like this (option required, note
optional) start a round from the candidate as Try again does, with
steps.design_ask (wire.DesignAsk JSON: kind, option, current options as
names, directions and folders, note). The answer is the person acting,
so DesignRuns starts afresh; the round's attempts count against
DesignRunLimit.
- fixRound copies the newest maker step's design_ask onto the fix step
(Review's changes and the option check alike); Try again's round has
none, nor does Build's change task. boundDispatch carries the step's
request on every dispatch of it (retries too).
- directionView fills TaskDirection.Rounds (every kept, approved round,
newest first; Live left for Task 12).
- Web: formOption parses option_step and option_index (0-based) in the
card answer handler; a malformed index stays malformed (-1).
- Migration 0125 appends chat_steps.design_ask text NOT NULL DEFAULT ""
(schema.sql too); the legacy-step migration test reads "" for it.
- thintest: TestContractDesignFinishLine now checks each option's form and
builds through the card's own form (option 1 plus a note); the plain
exploration's More options is refused (TestExploreTryAgain).
TDD evidence:
- go test ./internal/equipo/chat/ -run 'TestBuild|TestMore|TestLike|TestRoundsCount|TestFixRoundInheritsAsk'
first failed to build (stepRecord.DesignAsk). With the field and
migration only, all eight failed for their reasons: the card offers
[build again drop]; "chat: invalid" for more/like; again with an
option accepted; Build with no step fell to direction_note; the
build_option line missing.
- After: chat package, equipo package, thintest -run
'Design|Explore|Direction|Pages|Card', wire and runner/thin -run
'Design|Ask|Prompt' all ok; vet, gofmt, staticcheck (equipo, chat,
thintest) clean.
Mutations (each alone, restored after), all FAILED their tests:
- M1 card offers no more/like: TestBuildOptionOneTap
- M2 more/like not accepted: TestMoreStartsRound, TestLikeNeedsOption, +3
- M3 like without option allowed: TestLikeNeedsOption
- M4 option on other choices allowed: TestLikeNeedsOption
- M5 malformed ref not invalid: TestBuildStaleOption
- M6 more/like not gated on Design: thintest TestExploreTryAgain
- M7 Build with option still needs a note: TestBuildOptionOneTap, +2
- M8 option built from the current candidate: TestBuildEarlierRound
- M9 option name unquoted: TestBuildOptionOneTap, TestBuildEarlierRound
- M10 option number from 0: TestBuildOptionOneTap, TestBuildEarlierRound
- M11 no page in the folder: TestBuildOptionOneTap
- M12 Rounds not filled: TestBuildEarlierRound
- M13 no approve check: TestBuildStaleOption
- M14 no index range check: TestBuildStaleOption
- M15 rounds oldest first: TestBuildEarlierRound
- M16 request keeps captures: TestMoreStartsRound, TestLikeNeedsOption
- M17 like's option not on the request: TestLikeNeedsOption, TestFixRoundInheritsAsk
- M18 fix round inherits nothing: TestFixRoundInheritsAsk
- M19 dispatch carries no request: TestMoreStartsRound, TestRoundsCountAgainstLimit, TestFixRoundInheritsAsk
- M20 Try again keeps the request: TestFixRoundInheritsAsk
- M21 More drops the note: TestMoreStartsRound, TestFixRoundInheritsAsk
- M22 malformed form index read as no option: TestFormOption
- M23 roundAsk reads the newest step of any specialist: TestFixRoundInheritsAsk
- M24 handler does not pass the form's option: thintest TestContractDesignFinishLine
Not here: the forget variant of TestFixRoundInheritsAsk (needs Task 9's
forget revision); the runner's prompt from a request is Task 3's
TestFixPromptCarriesAskAndTaste.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
16 files changed,
+778
−32
docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+1 −0internal/equipo/card_option.go+24 −0internal/equipo/card_option_test.go+40 −0internal/equipo/chat/direction_options.go+158 −0internal/equipo/chat/direction_options_test.go+400 −0internal/equipo/chat/explore.go+88 −12internal/equipo/chat/grants.go+10 −2internal/equipo/chat/review.go+3 −1internal/equipo/chat/tasks.go+8 −1internal/equipo/chat_page.go+1 −1internal/equipo/copy.go+1 −0internal/equipo/design_feedback_migration_test.go+6 −6internal/equipo/migrations/0125_design_feedback.sql+5 −0internal/equipo/migrations/schema.sql+5 −0internal/thintest/design_contract_test.go+23 −8internal/thintest/explore_contract_test.go+5 −1
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index 8ea6c758..21085908 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -7229,6 +7229,7 @@ records remain unchanged. |
| | `chat.card.more_options` | More options | Copy specialist | COPY REVIEW PENDING | |
| | `chat.card.like` | More like this | Copy specialist | COPY REVIEW PENDING | |
| | `chat.card.option_note` | Add a note (optional) | Copy specialist | COPY REVIEW PENDING | |
| +| `work.explore.build_option` | Build option %d (Design's name for it: %s), from branch %s at commit %s, folder %s. | Copy specialist | COPY REVIEW PENDING | |
| ## Task 21 |
diff --git a/internal/equipo/card_option.go b/internal/equipo/card_option.go| new file mode 100644 |
| index 00000000..9f420903 |
| --- /dev/null |
| +++ b/internal/equipo/card_option.go |
| @@ -0,0 +1,24 @@ |
| +package equipo |
| + |
| +import ( |
| + "net/http" |
| + "strconv" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// formOption is the option a direction card's answer form names |
| +// (option_step, and option_index from 0 as wire.OptionRef): nil when the |
| +// form names none. A malformed index is kept malformed (-1), so the |
| +// store refuses the answer rather than reading it as naming no option. |
| +func formOption(r *http.Request) *wire.OptionRef { |
| + step, index := r.PostFormValue("option_step"), r.PostFormValue("option_index") |
| + if step == "" && index == "" { |
| + return nil |
| + } |
| + n, err := strconv.Atoi(index) |
| + if err != nil || n < 0 { |
| + n = -1 |
| + } |
| + return &wire.OptionRef{Step: step, Index: n} |
| +} |
diff --git a/internal/equipo/card_option_test.go b/internal/equipo/card_option_test.go| new file mode 100644 |
| index 00000000..7a87553e |
| --- /dev/null |
| +++ b/internal/equipo/card_option_test.go |
| @@ -0,0 +1,40 @@ |
| +package equipo |
| + |
| +import ( |
| + "net/http" |
| + "net/http/httptest" |
| + "net/url" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// TestFormOption: a direction card's answer form names an option by |
| +// option_step and option_index (from 0, as wire.OptionRef); a form |
| +// naming none gives nil; a malformed index stays malformed, never no |
| +// option. |
| +func TestFormOption(t *testing.T) { |
| + post := func(v url.Values) *http.Request { |
| + r := httptest.NewRequest(http.MethodPost, "/conversation/cards/c1/answer", strings.NewReader(v.Encode())) |
| + r.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| + return r |
| + } |
| + if got := formOption(post(url.Values{"choice": {"build"}, "note": {"x"}})); got != nil { |
| + t.Fatalf("no option fields: %+v", got) |
| + } |
| + if got := formOption(post(url.Values{"choice": {"like"}, "option_step": {"s_1"}, "option_index": {"0"}})); got == nil || *got != (wire.OptionRef{Step: "s_1", Index: 0}) { |
| + t.Fatalf("option 1: %+v", got) |
| + } |
| + if got := formOption(post(url.Values{"option_step": {"s_1"}, "option_index": {"2"}})); got == nil || got.Index != 2 { |
| + t.Fatalf("option 3: %+v", got) |
| + } |
| + for _, index := range []string{"", "x", "-3", "1.5"} { |
| + if got := formOption(post(url.Values{"option_step": {"s_1"}, "option_index": {index}})); got == nil || got.Index != -1 { |
| + t.Fatalf("index %q: %+v", index, got) |
| + } |
| + } |
| + if got := formOption(post(url.Values{"option_index": {"1"}})); got == nil || got.Step != "" { |
| + t.Fatalf("no step: %+v", got) |
| + } |
| +} |
diff --git a/internal/equipo/chat/direction_options.go b/internal/equipo/chat/direction_options.go| new file mode 100644 |
| index 00000000..7154e013 |
| --- /dev/null |
| +++ b/internal/equipo/chat/direction_options.go |
| @@ -0,0 +1,158 @@ |
| +package chat |
| + |
| +import ( |
| + "encoding/json" |
| + "fmt" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// Answers that name an option (spec 2026-11-28-dynamic-specialists.md, |
| +// sections 8.1 and 8.4): Build this one and More like this name a kept |
| +// option by its maker step and index (wire.OptionRef). The instance |
| +// accepts the reference only when that step is a done Design attempt of |
| +// the task, its options kept for its commit, and a Review approved that |
| +// commit: a round the person could see on the task page (designRounds). |
| +// The option's name, direction and folder are Design's words, never the |
| +// person's. |
| + |
| +// chosenOption is a kept option an answer named: its round's maker step, |
| +// its index (from 0) and the option as kept. |
| +type chosenOption struct { |
| + Step stepRecord |
| + Index int |
| + Option wire.StepDesignOption |
| +} |
| + |
| +// keptRound reports whether s is a kept, approved Design round among the |
| +// task's steps (of kind): a done, pushed maker step bound to a |
| +// specialist, holding options kept for its commit, whose newest Review |
| +// of that commit after it (one that counts for kind) approved it. |
| +func keptRound(steps []stepRecord, s stepRecord, kind string) (bool, error) { |
| + if s.Specialist != wire.SpecialistEngineering || s.SpecialistID == "" || s.Rebase || s.State != wire.StepDone || !s.Pushed || s.CandidateSHA == "" { |
| + return false, nil |
| + } |
| + var review *stepRecord |
| + for i := range steps { |
| + o := &steps[i] |
| + if o.Specialist == wire.SpecialistReview && o.Idx > s.Idx && o.CandidateSHA == s.CandidateSHA && counts(o, kind) { |
| + review = o |
| + } |
| + } |
| + if review == nil || review.State != wire.StepDone || review.Verdict != wire.VerdictApprove { |
| + return false, nil |
| + } |
| + kept, err := keptFor(s) |
| + if err != nil { |
| + return false, err |
| + } |
| + return kept != nil && len(kept.Options) > 0, nil |
| +} |
| + |
| +// keptOption is the option ref names among k's kept, approved rounds: |
| +// its step and the option as kept. Anything else (a step of another |
| +// task or none, a round not kept or not approved, an index past its |
| +// options) is ErrCardConflict: the answer is about something the task |
| +// does not offer now. |
| +func (t *txn) keptOption(k taskRecord, ref wire.OptionRef) (stepRecord, wire.StepDesignOption, error) { |
| + steps, err := t.steps(k.ID) |
| + if err != nil { |
| + return stepRecord{}, wire.StepDesignOption{}, err |
| + } |
| + for _, s := range steps { |
| + if s.ID != ref.Step { |
| + continue |
| + } |
| + ok, err := keptRound(steps, s, k.Kind) |
| + if err != nil || !ok { |
| + return stepRecord{}, wire.StepDesignOption{}, conflictUnless(err) |
| + } |
| + v, err := t.designView(s) |
| + if err != nil { |
| + return stepRecord{}, wire.StepDesignOption{}, err |
| + } |
| + if v == nil || ref.Index < 0 || ref.Index >= len(v.Options) { |
| + return stepRecord{}, wire.StepDesignOption{}, ErrCardConflict |
| + } |
| + return s, v.Options[ref.Index], nil |
| + } |
| + return stepRecord{}, wire.StepDesignOption{}, ErrCardConflict |
| +} |
| + |
| +func conflictUnless(err error) error { |
| + if err != nil { |
| + return err |
| + } |
| + return ErrCardConflict |
| +} |
| + |
| +// designRounds is every kept, approved Design round of k, newest first: |
| +// its maker step, the commit its options are built from, and the |
| +// options as kept. Live is left for the preview to say. |
| +func (t *txn) designRounds(k taskRecord, steps []stepRecord) ([]wire.DirectionRound, error) { |
| + var out []wire.DirectionRound |
| + for i := len(steps) - 1; i >= 0; i-- { |
| + s := steps[i] |
| + ok, err := keptRound(steps, s, k.Kind) |
| + if err != nil { |
| + return nil, err |
| + } |
| + if !ok { |
| + continue |
| + } |
| + v, err := t.designView(s) |
| + if err != nil { |
| + return nil, err |
| + } |
| + if v == nil || len(v.Options) == 0 { |
| + continue |
| + } |
| + out = append(out, wire.DirectionRound{Step: s.ID, Candidate: s.CandidateSHA, Options: v.Options}) |
| + } |
| + return out, nil |
| +} |
| + |
| +// askOption is an option as a round request carries it: its name, |
| +// direction and folder (Design's words), without its captures. |
| +func askOption(o wire.StepDesignOption) wire.StepDesignOption { |
| + return wire.StepDesignOption{Name: o.Name, Direction: o.Direction, Page: o.Page} |
| +} |
| + |
| +// 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 { |
| + a := wire.DesignAsk{Kind: kind, Note: note} |
| + for _, o := range current { |
| + a.Current = append(a.Current, askOption(o)) |
| + } |
| + if chosen != nil { |
| + o := askOption(chosen.Option) |
| + a.Option = &o |
| + } |
| + raw, _ := json.Marshal(a) |
| + return string(raw) |
| +} |
| + |
| +// stepAsk decodes the step's round request; nil when it has none. |
| +func stepAsk(s stepRecord) (*wire.DesignAsk, error) { |
| + if s.DesignAsk == "" { |
| + return nil, nil |
| + } |
| + var a wire.DesignAsk |
| + if err := json.Unmarshal([]byte(s.DesignAsk), &a); err != nil { |
| + return nil, fmt.Errorf("%w: step %s design_ask", ErrInvalid, s.ID) |
| + } |
| + return &a, nil |
| +} |
| + |
| +// roundAsk is the request of the round the task's newest maker step |
| +// belongs to (a rebase is not a round): what its fix round inherits. |
| +func roundAsk(steps []stepRecord) string { |
| + for i := len(steps) - 1; i >= 0; i-- { |
| + if s := steps[i]; s.Specialist == wire.SpecialistEngineering && !s.Rebase { |
| + return s.DesignAsk |
| + } |
| + } |
| + return "" |
| +} |
diff --git a/internal/equipo/chat/direction_options_test.go b/internal/equipo/chat/direction_options_test.go| new file mode 100644 |
| index 00000000..a745ebc2 |
| --- /dev/null |
| +++ b/internal/equipo/chat/direction_options_test.go |
| @@ -0,0 +1,400 @@ |
| +package chat |
| + |
| +import ( |
| + "encoding/json" |
| + "errors" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// Design feedback 1, Task 6 (spec 2026-11-28-dynamic-specialists.md, |
| +// sections 8.1 and 8.4): the direction card's answers name an option by |
| +// its maker step and index (wire.OptionRef). Build this one with an |
| +// option needs no note and writes the new task's brief from records; |
| +// More options and More like this start a Design round from the current |
| +// candidate, as Try again does, with the request on the step |
| +// (design_ask), which every fix round of that round inherits. |
| + |
| +// Later rounds' commits (their short forms differ from candidateSHA's). |
| +const ( |
| + secondSHA = "b0b0b00000000000000000000000000000000002" |
| + thirdSHA = "d0d0d00000000000000000000000000000000003" |
| +) |
| + |
| +// judgeRound reports the task's newest Review, on sha, with verdict. |
| +func (r *hkRig) judgeRound(l Lease, task, sha, verdict string) { |
| + r.t.Helper() |
| + var review stepRecord |
| + r.must(r.s.db.G.Where("task_id = ? AND specialist = ?", task, wire.SpecialistReview).Order("idx DESC").First(&review).Error) |
| + if review.CandidateSHA != sha { |
| + r.t.Fatalf("newest Review judges %s, not %s", review.CandidateSHA, sha) |
| + } |
| + r.report(l, review, wire.StepReport{State: wire.StepDone, CandidateSHA: sha, Verdict: verdict, ReviewLabel: wire.ReviewOtherFamily, Termination: true, Findings: []wire.Finding{}}) |
| +} |
| + |
| +// keptRound takes the running Design attempt s to done at sha with one |
| +// valid option per name (protocol 39), and its Review to verdict. |
| +func (r *hkRig) keptRound(l Lease, task string, s stepRecord, sha, verdict string, names ...string) { |
| + r.t.Helper() |
| + var opts []wire.DesignOption |
| + for i, name := range names { |
| + opts = append(opts, r.option39(l, s, i+1, name, 1)) |
| + } |
| + r.doneWith(l, s, sha, opts) |
| + r.judgeRound(l, task, sha, verdict) |
| +} |
| + |
| +// openDirection is the task's open direction card. |
| +func (r *hkRig) openDirection(task string) cardRecord { |
| + r.t.Helper() |
| + var c cardRecord |
| + r.must(r.s.db.G.Where("task_id = ? AND kind = ? AND state = ?", task, wire.CardDirection, wire.CardOpen).First(&c).Error) |
| + return c |
| +} |
| + |
| +// startRound takes the task's newest maker step (just dispatched) to |
| +// running, reporting candidate sha. |
| +func (r *hkRig) startRound(l Lease, task, sha string) stepRecord { |
| + r.t.Helper() |
| + next := r.makerStep(task) |
| + r.ackDispatches(next.ID) |
| + if refused := r.authorize(l, next, ""); refused != "" { |
| + r.t.Fatalf("start %s: %q", next.ID, refused) |
| + } |
| + r.report(l, next, wire.StepReport{State: wire.StepRunning, BaseSHA: candidateSHA, CandidateSHA: sha}) |
| + return r.stepNow(next.ID) |
| +} |
| + |
| +// answerCard answers c at its revision as Paul. |
| +func (r *hkRig) answerCard(c cardRecord, in wire.AnswerCard) error { |
| + in.Revision = c.Revision |
| + _, _, err := r.s.Answer(r.ctx, paul, c.ID, in) |
| + return err |
| +} |
| + |
| +// stepAskOf is the step's stored round request (nil: none). |
| +func stepAskOf(t *testing.T, s stepRecord) *wire.DesignAsk { |
| + t.Helper() |
| + if s.DesignAsk == "" { |
| + return nil |
| + } |
| + var a wire.DesignAsk |
| + if err := json.Unmarshal([]byte(s.DesignAsk), &a); err != nil { |
| + t.Fatalf("design_ask %q: %v", s.DesignAsk, err) |
| + } |
| + return &a |
| +} |
| + |
| +// sameAsk reports whether two round requests say the same. |
| +func sameAsk(a, b *wire.DesignAsk) bool { |
| + x, _ := json.Marshal(a) |
| + y, _ := json.Marshal(b) |
| + return string(x) == string(y) |
| +} |
| + |
| +// buildWords gives the rig the build brief's words as copy.go has them. |
| +func (r *hkRig) buildWords() { |
| + for k, w := range map[string]string{ |
| + "work.explore.build_brief": "Equipo will build the chosen direction from the main branch, using branch %s at commit %s as the design reference. Exploration: %s.", |
| + "work.explore.build_note": "%s said which option to build in their own words: %s", |
| + "work.explore.build_option": "Build option %d (Design's name for it: %s), from branch %s at commit %s, folder %s.", |
| + } { |
| + words, k, w := r.s.authority.Copy, k, w |
| + r.s.authority.Copy = func(key string) string { |
| + if key == k { |
| + return w |
| + } |
| + return words(key) |
| + } |
| + } |
| +} |
| + |
| +// roundOfThree is a protocol-39 exploration whose first round kept Calm, |
| +// Writing desk and Bold at candidateSHA, approved: the direction card is |
| +// open. |
| +func roundOfThree(t *testing.T) (*hkRig, Lease, string, stepRecord, cardRecord) { |
| + r, l, task, s := designAt(t, wire.ProtocolDesignFeedback, wire.KindExplore) |
| + r.buildWords() |
| + r.keptRound(l, task, s, candidateSHA, wire.VerdictApprove, "Calm", "Writing desk", "Bold") |
| + return r, l, task, r.stepNow(s.ID), r.openDirection(task) |
| +} |
| + |
| +// TestBuildOptionOneTap: Build this one naming option 2, with no note, |
| +// builds; the brief names the option by number, its name quoted as |
| +// Design's words under a label saying so (never as the person's), the |
| +// round's commit and branch, and the option's folder. |
| +func TestBuildOptionOneTap(t *testing.T) { |
| + r, _, task, s, c := roundOfThree(t) |
| + var offered []string |
| + r.must(json.Unmarshal([]byte(c.Options), &offered)) |
| + if strings.Join(offered, ",") != "build,again,drop,more,like" { |
| + t.Fatalf("the card offers %v", offered) |
| + } |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceBuild, Option: &wire.OptionRef{Step: s.ID, Index: 1}}); err != nil { |
| + t.Fatal(err) |
| + } |
| + k := r.load(task) |
| + built := r.load(k.BuiltAs) |
| + want := "Build option 2 (Design's name for it: " + wire.QuotedData("Writing desk") + "), from branch " + k.Branch + " at commit " + short(candidateSHA) + ", folder mockups/" + task + "/writing-desk/." |
| + if !strings.HasSuffix(built.Brief, want) { |
| + t.Fatalf("brief %q\nwant suffix %q", built.Brief, want) |
| + } |
| + name, _ := DisplayName(paul) |
| + if strings.Contains(built.Brief, name+" said") || strings.Contains(built.Brief, "own words") { |
| + t.Fatalf("the option's name is under the person's: %q", built.Brief) |
| + } |
| +} |
| + |
| +// TestBuildEarlierRound: after a More options round, the task's rounds |
| +// are listed newest first, and an option of the earlier round builds |
| +// from that round's commit; a note goes after, as the person's words. |
| +func TestBuildEarlierRound(t *testing.T) { |
| + r, l, task, first, c := roundOfThree(t) |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceMore}); err != nil { |
| + t.Fatal(err) |
| + } |
| + second := r.startRound(l, task, secondSHA) |
| + r.keptRound(l, task, second, secondSHA, wire.VerdictApprove, "Night shift", "Field notes", "Paper") |
| + v, err := r.s.Task(r.ctx, paul, task) |
| + r.must(err) |
| + d := v.Direction |
| + if d == nil || len(d.Rounds) != 2 || d.Rounds[0].Step != second.ID || d.Rounds[0].Candidate != secondSHA || d.Rounds[1].Step != first.ID || d.Rounds[1].Candidate != candidateSHA { |
| + t.Fatalf("rounds %+v", d) |
| + } |
| + if o := d.Rounds[1].Options; len(o) != 3 || o[1].Name != "Writing desk" || o[1].Page != "writing-desk" || len(o[1].Captures) != 1 || d.Rounds[0].Live { |
| + t.Fatalf("earlier round's options %+v", o) |
| + } |
| + note := "With the yellow button." |
| + if err := r.answerCard(r.openDirection(task), wire.AnswerCard{Choice: wire.ChoiceBuild, Note: note, Option: &wire.OptionRef{Step: first.ID, Index: 1}}); err != nil { |
| + t.Fatal(err) |
| + } |
| + built := r.load(r.load(task).BuiltAs) |
| + line := "Build option 2 (Design's name for it: " + wire.QuotedData("Writing desk") + "), from branch " + r.load(task).Branch + " at commit " + short(candidateSHA) |
| + name, _ := DisplayName(paul) |
| + said := name + " said which option to build in their own words: " + wire.QuotedData(note) |
| + if !strings.Contains(built.Brief, line) || strings.Contains(built.Brief, short(secondSHA)) || !strings.HasSuffix(built.Brief, said) || strings.Index(built.Brief, line) > strings.Index(built.Brief, said) { |
| + t.Fatalf("brief %q", built.Brief) |
| + } |
| +} |
| + |
| +// TestBuildStaleOption: an option that is not one of this task's kept, |
| +// approved options is a card conflict and builds nothing: an index past |
| +// the round's options, a step of another task, a round whose candidate |
| +// Review did not approve. A malformed one is invalid. |
| +func TestBuildStaleOption(t *testing.T) { |
| + r, l, task, s := designAt(t, wire.ProtocolDesignFeedback, wire.KindExplore) |
| + r.buildWords() |
| + // Round 0 kept options, but Review asked for changes; its fix round |
| + // was approved. |
| + r.keptRound(l, task, s, candidateSHA, wire.VerdictChanges, "Calm", "Writing desk", "Bold") |
| + fix := r.startRound(l, task, secondSHA) |
| + r.keptRound(l, task, fix, secondSHA, wire.VerdictApprove, "Calm", "Writing desk", "Bold") |
| + c := r.openDirection(task) |
| + // The same kept, approved round, under another task. |
| + other := r.stepNow(fix.ID) |
| + other.ID, other.TaskID, other.Idx = "s_other", "tk_other", 1 |
| + r.must(r.s.db.G.Create(&other).Error) |
| + review := stepRecord{ID: "s_other_review", TaskID: "tk_other", Idx: 2, Specialist: wire.SpecialistReview, State: wire.StepDone, Attempt: 1, CandidateSHA: other.CandidateSHA, Verdict: wire.VerdictApprove, Kind: wire.KindExplore} |
| + r.must(r.s.db.G.Create(&review).Error) |
| + for name, ref := range map[string]wire.OptionRef{ |
| + "index past the options": {Step: fix.ID, Index: 5}, |
| + "another task's step": {Step: other.ID, Index: 0}, |
| + "no approve": {Step: s.ID, Index: 0}, |
| + "no such step": {Step: "s_nope", Index: 0}, |
| + } { |
| + ref := ref |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceBuild, Option: &ref}); !errors.Is(err, ErrCardConflict) { |
| + t.Fatalf("%s: %v", name, err) |
| + } |
| + } |
| + for name, ref := range map[string]wire.OptionRef{"negative index": {Step: fix.ID, Index: -1}, "no step": {Index: 0}} { |
| + ref := ref |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceBuild, Option: &ref}); !errors.Is(err, ErrInvalid) { |
| + t.Fatalf("%s: %v", name, err) |
| + } |
| + } |
| + if k := r.load(task); k.BuiltAs != "" || r.openDirection(task).ID != c.ID { |
| + t.Fatalf("built %q", k.BuiltAs) |
| + } |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceBuild, Option: &wire.OptionRef{Step: fix.ID, Index: 2}}); err != nil { |
| + t.Fatalf("the approved round's option: %v", err) |
| + } |
| +} |
| + |
| +// TestBuildNoteOnlyOldClient: an older client's Build with a note and no |
| +// option still builds with three options, the note as the person's |
| +// words and no option line; with neither, it is the direction_note |
| +// conflict. |
| +func TestBuildNoteOnlyOldClient(t *testing.T) { |
| + r, _, task, _, c := roundOfThree(t) |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceBuild}); !errors.Is(err, ErrDirectionNote) { |
| + t.Fatalf("Build with neither: %v", err) |
| + } |
| + note := "The calm one." |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceBuild, Note: note}); err != nil { |
| + t.Fatal(err) |
| + } |
| + built := r.load(r.load(task).BuiltAs) |
| + name, _ := DisplayName(paul) |
| + if !strings.HasSuffix(built.Brief, name+" said which option to build in their own words: "+wire.QuotedData(note)) || strings.Contains(built.Brief, "Build option") { |
| + t.Fatalf("brief %q", built.Brief) |
| + } |
| +} |
| + |
| +// TestMoreStartsRound: More options starts a Design round from the |
| +// current candidate, as Try again does, with the request on the step and |
| +// its dispatch: the current round's options (names, directions and |
| +// folders, Design's words) and the person's note. The tap is the person |
| +// acting: the Design run count starts afresh. |
| +func TestMoreStartsRound(t *testing.T) { |
| + r, _, task, s, c := roundOfThree(t) |
| + r.exec("UPDATE chat_tasks SET design_runs = 2 WHERE id = ?", task) |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceMore, Note: "Bolder."}); err != nil { |
| + t.Fatal(err) |
| + } |
| + next := r.makerStep(task) |
| + if next.ID == s.ID || next.BaseSHA != candidateSHA || next.Round != 1 || next.SpecialistID != s.SpecialistID || next.Note != "" { |
| + t.Fatalf("More's step %+v", next) |
| + } |
| + a := stepAskOf(t, next) |
| + if a == nil || a.Kind != wire.DesignAskMore || a.Note != "Bolder." || a.Option != nil || len(a.Current) != 3 { |
| + t.Fatalf("More's request %+v", a) |
| + } |
| + if o := a.Current[1]; o.Name != "Writing desk" || o.Direction != "Writing desk direction: calm type, warm colour." || o.Page != "writing-desk" || len(o.Captures) != 0 { |
| + t.Fatalf("current option %+v", o) |
| + } |
| + if _, d := r.dispatched(next.ID); !sameAsk(d.DesignAsk, a) { |
| + t.Fatalf("dispatch's request %+v", d.DesignAsk) |
| + } |
| + if k := r.load(task); k.DesignRuns != 1 || k.DirectionAsked != "" || k.Stage != wire.StageInProgress { |
| + t.Fatalf("task after More: runs %d, asked %q, stage %s", k.DesignRuns, k.DirectionAsked, k.Stage) |
| + } |
| + var answered cardRecord |
| + r.must(r.s.db.G.Where("id = ?", c.ID).First(&answered).Error) |
| + if answered.State != wire.CardAnswered || answered.Choice != wire.ChoiceMore { |
| + t.Fatalf("card %s %q", answered.State, answered.Choice) |
| + } |
| +} |
| + |
| +// TestLikeNeedsOption: More like this names an option; without one it is |
| +// invalid, and so is an option on an answer that takes none. With one, |
| +// the round's request carries it (Design's words) and the current |
| +// options. |
| +func TestLikeNeedsOption(t *testing.T) { |
| + r, _, task, s, c := roundOfThree(t) |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceLike}); !errors.Is(err, ErrInvalid) { |
| + t.Fatalf("like without an option: %v", err) |
| + } |
| + for _, choice := range []string{wire.ChoiceMore, wire.ChoiceAgain, wire.ChoiceDrop} { |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: choice, Note: "x", Option: &wire.OptionRef{Step: s.ID, Index: 0}}); !errors.Is(err, ErrInvalid) { |
| + t.Fatalf("%s with an option: %v", choice, err) |
| + } |
| + } |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceLike, Option: &wire.OptionRef{Step: s.ID, Index: 3}}); !errors.Is(err, ErrCardConflict) { |
| + t.Fatalf("like past the options: %v", err) |
| + } |
| + if r.makerStep(task).ID != s.ID || r.openDirection(task).ID != c.ID { |
| + t.Fatal("a refused answer started a round") |
| + } |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceLike, Option: &wire.OptionRef{Step: s.ID, Index: 2}}); err != nil { |
| + t.Fatal(err) |
| + } |
| + a := stepAskOf(t, r.makerStep(task)) |
| + if a == nil || a.Kind != wire.DesignAskLike || a.Option == nil || a.Option.Name != "Bold" || a.Option.Direction != "Bold direction: calm type, warm colour." || a.Option.Page != "bold" || len(a.Option.Captures) != 0 || len(a.Current) != 3 || a.Note != "" { |
| + t.Fatalf("like's request %+v", a) |
| + } |
| +} |
| + |
| +// TestRoundsCountAgainstLimit: a More like this round's attempts count |
| +// against DesignRunLimit: after the tap three attempts go (each carrying |
| +// the request), the fourth is held with design_limit. |
| +func TestRoundsCountAgainstLimit(t *testing.T) { |
| + r, l, task, s, c := roundOfThree(t) |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceLike, Option: &wire.OptionRef{Step: s.ID, Index: 0}}); err != nil { |
| + t.Fatal(err) |
| + } |
| + like := r.makerStep(task) |
| + if !r.attemptSent(like) || r.load(task).DesignRuns != 1 { |
| + t.Fatalf("like's first attempt %+v, runs %d", like, r.load(task).DesignRuns) |
| + } |
| + r.failAndRetry(l, task) |
| + third := r.failAndRetry(l, task) |
| + if _, d := r.dispatched(third.ID); !r.attemptSent(third) || third.ID != like.ID || d.DesignAsk == nil || d.DesignAsk.Kind != wire.DesignAskLike { |
| + t.Fatalf("third attempt %+v, request %+v", third, d.DesignAsk) |
| + } |
| + fourth := r.failAndRetry(l, task) |
| + if r.attemptSent(fourth) || fourth.Placement != wire.PlacementDesignLimit || fourth.Reason != reasonDesignLimit || r.load(task).DesignRuns != 3 { |
| + t.Fatalf("fourth attempt %+v", fourth) |
| + } |
| +} |
| + |
| +// TestFixRoundInheritsAsk: every fix round of a More like this round |
| +// carries its request, on the step and its dispatch: a round Review |
| +// sent back, and a round the option check sent back. Try again's round |
| +// after it carries none (it replaces the request), nor does the task |
| +// Build this makes. |
| +func TestFixRoundInheritsAsk(t *testing.T) { |
| + t.Run("review", func(t *testing.T) { |
| + r, l, task, s, c := roundOfThree(t) |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceLike, Note: "Warmer.", Option: &wire.OptionRef{Step: s.ID, Index: 1}}); err != nil { |
| + t.Fatal(err) |
| + } |
| + like := r.startRound(l, task, secondSHA) |
| + ask := stepAskOf(t, like) |
| + r.keptRound(l, task, like, secondSHA, wire.VerdictChanges, "Desk one", "Desk two", "Desk three") |
| + fix := r.makerStep(task) |
| + if fix.ID == like.ID || fix.Round != like.Round+1 { |
| + t.Fatalf("no fix round after Review: %+v", fix) |
| + } |
| + if _, d := r.dispatched(fix.ID); !sameAsk(stepAskOf(t, fix), ask) || !sameAsk(d.DesignAsk, ask) || d.DesignAsk.Option.Name != "Writing desk" || d.DesignAsk.Note != "Warmer." { |
| + t.Fatalf("fix round's request %q, dispatch %+v", fix.DesignAsk, d.DesignAsk) |
| + } |
| + }) |
| + t.Run("option check", func(t *testing.T) { |
| + r, l, task, s, c := roundOfThree(t) |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceMore}); err != nil { |
| + t.Fatal(err) |
| + } |
| + more := r.startRound(l, task, secondSHA) |
| + ask := stepAskOf(t, more) |
| + // Two options: short of an exploration's three. |
| + r.doneWith(l, more, secondSHA, []wire.DesignOption{r.option39(l, more, 1, "Night", 1), r.option39(l, more, 2, "Day", 1)}) |
| + fix := r.makerStep(task) |
| + if fix.ID == more.ID || fix.ID == s.ID { |
| + t.Fatalf("no fix round after the option check: %+v", fix) |
| + } |
| + if _, d := r.dispatched(fix.ID); ask == nil || !sameAsk(stepAskOf(t, fix), ask) || !sameAsk(d.DesignAsk, ask) || !strings.Contains(d.Feedback, designFeedbackOptions) { |
| + t.Fatalf("fix round's request %q, dispatch %+v", fix.DesignAsk, d.DesignAsk) |
| + } |
| + }) |
| + t.Run("try again and build", func(t *testing.T) { |
| + r, l, task, s, c := roundOfThree(t) |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceLike, Option: &wire.OptionRef{Step: s.ID, Index: 0}}); err != nil { |
| + t.Fatal(err) |
| + } |
| + like := r.startRound(l, task, secondSHA) |
| + r.keptRound(l, task, like, secondSHA, wire.VerdictApprove, "Calm two", "Calm three", "Calm four") |
| + if err := r.answerCard(r.openDirection(task), wire.AnswerCard{Choice: wire.ChoiceAgain, Note: "Start over."}); err != nil { |
| + t.Fatal(err) |
| + } |
| + again := r.startRound(l, task, thirdSHA) |
| + if again.DesignAsk != "" { |
| + t.Fatalf("Try again kept the request %q", again.DesignAsk) |
| + } |
| + if _, d := r.dispatched(again.ID); d.DesignAsk != nil { |
| + t.Fatalf("Try again's dispatch %+v", d.DesignAsk) |
| + } |
| + // Approved, then built from the More like this round's option: |
| + // the change task carries no request. |
| + r.keptRound(l, task, again, thirdSHA, wire.VerdictApprove, "A", "B", "C") |
| + if err := r.answerCard(r.openDirection(task), wire.AnswerCard{Choice: wire.ChoiceBuild, Option: &wire.OptionRef{Step: like.ID, Index: 0}}); err != nil { |
| + t.Fatal(err) |
| + } |
| + b := r.makerStep(r.load(task).BuiltAs) |
| + if _, d := r.dispatched(b.ID); b.DesignAsk != "" || d.DesignAsk != nil { |
| + t.Fatalf("Build's step %q, dispatch %+v", b.DesignAsk, d.DesignAsk) |
| + } |
| + }) |
| +} |
diff --git a/internal/equipo/chat/explore.go b/internal/equipo/chat/explore.go| index c6167647..d72e2ccc 100644 |
| --- a/internal/equipo/chat/explore.go |
| +++ b/internal/equipo/chat/explore.go |
| @@ -4,6 +4,7 @@ import ( |
| "context" |
| "encoding/json" |
| "errors" |
| + "fmt" |
| "slices" |
| "strings" |
| @@ -167,7 +168,12 @@ func (t *txn) raiseDirection(k *taskRecord, p progress) error { |
| if question == "" { |
| question = k.Title |
| } |
| - options, _ := json.Marshal([]string{wire.ChoiceBuild, wire.ChoiceAgain, wire.ChoiceDrop}) |
| + choices := []string{wire.ChoiceBuild, wire.ChoiceAgain, wire.ChoiceDrop} |
| + if p.eng != nil && p.eng.SpecialistID != "" { |
| + // Design made it: More options and More like this (spec 8.4). |
| + choices = append(choices, wire.ChoiceMore, wire.ChoiceLike) |
| + } |
| + options, _ := json.Marshal(choices) |
| c := cardRecord{ID: newID("c_"), Person: k.Creator, Kind: wire.CardDirection, State: wire.CardOpen, ProjectID: k.ProjectID, TaskID: k.ID, Question: question, Options: string(options), Revision: 1, CreatedAt: now, UpdatedAt: now, Lane: k.Lane} |
| if err := t.db.Create(&c).Error; err != nil { |
| return err |
| @@ -218,19 +224,29 @@ func busy(steps []stepRecord, previews bool) bool { |
| // answerDirection is the creator's answer on a direction card, valid only |
| // while it still asks about the task as it stands: an exploration whose |
| // newest candidate is the one asked about, approved, the branch at it and |
| -// nothing at work. Build this one, Try again (with a note) or Drop it. |
| +// nothing at work. Build this one (of an option, or with a note), Try |
| +// again (with a note), Drop it, and for Design's work More options and |
| +// More like this (of an option), each with an optional note. |
| func (t *txn) answerDirection(person string, c cardRecord, in wire.AnswerCard) (wire.Card, wire.Card, error) { |
| v, err := t.cardView(c) |
| if err != nil { |
| return wire.Card{}, wire.Card{}, err |
| } |
| - if !slices.Contains([]string{wire.ChoiceBuild, wire.ChoiceAgain, wire.ChoiceDrop}, in.Choice) { |
| + if !slices.Contains([]string{wire.ChoiceBuild, wire.ChoiceAgain, wire.ChoiceDrop, wire.ChoiceMore, wire.ChoiceLike}, in.Choice) { |
| + return wire.Card{}, wire.Card{}, ErrInvalid |
| + } |
| + // Only Build this one and More like this name an option, and More |
| + // like this always does. |
| + switch { |
| + case in.Option != nil && in.Choice != wire.ChoiceBuild && in.Choice != wire.ChoiceLike, |
| + in.Option == nil && in.Choice == wire.ChoiceLike, |
| + in.Option != nil && (in.Option.Step == "" || in.Option.Index < 0): |
| return wire.Card{}, wire.Card{}, ErrInvalid |
| } |
| note := "" |
| - // Try again needs the person's note; Build this may carry one |
| - // (protocol 38: the option they want), bounded the same way. |
| - if in.Choice == wire.ChoiceAgain || in.Choice == wire.ChoiceBuild && in.Note != "" { |
| + // Try again needs the person's note; Build this, More options and |
| + // More like this may carry one, bounded the same way. |
| + if in.Choice == wire.ChoiceAgain || in.Choice != wire.ChoiceDrop && in.Note != "" { |
| var ok bool |
| if note, ok = cleanText(in.Note, wire.MaxDirectionNote); !ok { |
| return wire.Card{}, wire.Card{}, ErrInvalid |
| @@ -258,7 +274,22 @@ func (t *txn) answerDirection(person string, c cardRecord, in wire.AnswerCard) ( |
| if wire.NormalKind(k.Kind) != wire.KindExplore || wire.FinalStage(k.Stage) || k.CancelRequested || p.moved || p.candidate == "" || k.DirectionAsked != p.candidate || verdict != wire.VerdictApprove || busy(steps, false) || k.BuiltAs != "" { |
| return wire.Card{}, v, ErrCardConflict |
| } |
| - if in.Choice == wire.ChoiceBuild && note == "" { |
| + if (in.Choice == wire.ChoiceMore || in.Choice == wire.ChoiceLike) && (p.eng == nil || p.eng.SpecialistID == "") { |
| + // A round request is for Design's work only. |
| + return wire.Card{}, wire.Card{}, ErrInvalid |
| + } |
| + var chosen *chosenOption |
| + if in.Option != nil { |
| + s, o, err := t.keptOption(k, *in.Option) |
| + if errors.Is(err, ErrCardConflict) { |
| + return wire.Card{}, v, err |
| + } |
| + if err != nil { |
| + return wire.Card{}, wire.Card{}, err |
| + } |
| + chosen = &chosenOption{Step: s, Index: in.Option.Index, Option: o} |
| + } |
| + if in.Choice == wire.ChoiceBuild && note == "" && chosen == nil { |
| // With more than one option, the person says which (spec §5). |
| d, err := t.candidateDesign(p) |
| if err != nil { |
| @@ -274,11 +305,30 @@ func (t *txn) answerDirection(person string, c cardRecord, in wire.AnswerCard) ( |
| } |
| switch in.Choice { |
| case wire.ChoiceBuild: |
| - if err := t.buildThisOne(&k, p, note); err != nil { |
| + if err := t.buildThisOne(&k, p, note, chosen); err != nil { |
| return wire.Card{}, wire.Card{}, err |
| } |
| - case wire.ChoiceAgain: |
| + case wire.ChoiceAgain, wire.ChoiceMore, wire.ChoiceLike: |
| + // A round from the candidate. Try again carries the person's note |
| + // and no request (replacing any); More options and More like this |
| + // carry theirs on the step (design_ask), note included, which its |
| + // fix rounds inherit. |
| s := stepRecord{Specialist: wire.SpecialistEngineering, Person: p.eng.Person, Round: max(k.RepairRound, p.eng.Round) + 1, BaseSHA: p.candidate, Note: note} |
| + if in.Choice != wire.ChoiceAgain { |
| + d, err := t.candidateDesign(p) |
| + if err != nil { |
| + return wire.Card{}, wire.Card{}, err |
| + } |
| + var current []wire.StepDesignOption |
| + if d != nil { |
| + current = d.Options |
| + } |
| + kind := wire.DesignAskMore |
| + if in.Choice == wire.ChoiceLike { |
| + kind = wire.DesignAskLike |
| + } |
| + s.Note, s.DesignAsk = "", designAsk(kind, note, current, chosen) |
| + } |
| // Asked afresh after the round, even about the same commit. |
| k.Stage, k.DirectionAsked = wire.StageInProgress, "" |
| if err := t.nextStep(&k, steps, s); err != nil { |
| @@ -313,16 +363,39 @@ func (t *txn) answerDirection(person string, c cardRecord, in wire.AnswerCard) ( |
| // they gave one (which option, with more than one), ends the brief, |
| // quoted as their own words under their name; the exploration's brief is |
| // cut to make room, never the note. |
| -func (t *txn) buildThisOne(k *taskRecord, p progress, note string) error { |
| +// |
| +// With an option named (chosen), the brief names it from records: its |
| +// number, Design's name for it quoted as Design's words, its round's |
| +// commit and branch, and its folder; the commit is that round's, so an |
| +// earlier round's option is built from its own commit. |
| +func (t *txn) buildThisOne(k *taskRecord, p progress, note string, chosen *chosenOption) error { |
| now := t.now() |
| title := t.words("work.explore.build_title", k.Title) |
| if title == "" { |
| title = "Build: " + k.Title |
| } |
| title = clipText(strings.TrimSpace(title), wire.MaxTaskTitle) |
| - more := t.words("work.explore.build_brief", k.Branch, short(p.candidate), TaskLink(k.ID)) |
| + ref := p.candidate |
| + if chosen != nil { |
| + ref = chosen.Step.CandidateSHA |
| + } |
| + more := t.words("work.explore.build_brief", k.Branch, short(ref), TaskLink(k.ID)) |
| if more == "" { |
| - more = "Build the direction explored on branch " + k.Branch + " at " + short(p.candidate) + " (" + TaskLink(k.ID) + ")." |
| + more = "Build the direction explored on branch " + k.Branch + " at " + short(ref) + " (" + TaskLink(k.ID) + ")." |
| + } |
| + if chosen != nil { |
| + // The folder is the kept page's (validated when kept); an option |
| + // from before pages were named is somewhere under the task's. |
| + folder := "mockups/" + k.ID + "/" |
| + if chosen.Option.Page != "" { |
| + folder += chosen.Option.Page + "/" |
| + } |
| + name := wire.QuotedData(chosen.Option.Name) |
| + line := t.words("work.explore.build_option", chosen.Index+1, name, k.Branch, short(ref), folder) |
| + if line == "" { |
| + line = fmt.Sprintf("Build option %d (Design's name for it: %s), from branch %s at commit %s, folder %s.", chosen.Index+1, name, k.Branch, short(ref), folder) |
| + } |
| + more += "\n\n" + line |
| } |
| if note != "" { |
| name, _ := DisplayName(k.Creator) |
| @@ -509,6 +582,9 @@ func (t *txn) directionView(k taskRecord, repo string, steps []stepRecord, p pro |
| if design != nil { |
| d.Options, d.NoteNeeded = design.Options, len(design.Options) > 1 |
| } |
| + if d.Rounds, err = t.designRounds(k, steps); err != nil { |
| + return nil, err |
| + } |
| now := t.now() |
| for i := len(steps) - 1; i >= 0; i-- { |
| s := steps[i] |
diff --git a/internal/equipo/chat/grants.go b/internal/equipo/chat/grants.go| index dd018ae0..9d0cb8c7 100644 |
| --- a/internal/equipo/chat/grants.go |
| +++ b/internal/equipo/chat/grants.go |
| @@ -143,14 +143,22 @@ func bind(s *stepRecord, sp specialistRecord) { |
| // boundDispatch puts sp's binding and profile in a maker step's |
| // dispatch of task k (protocol 38), with whether k is an exploration and |
| -// sp's brief as its owner added it. |
| -func boundDispatch(cmd *wire.DispatchCommand, sp specialistRecord, k taskRecord) { |
| +// sp's brief as its owner added it, and step s's round request |
| +// (protocol 39: More options or More like this, on the round and each |
| +// of its fix rounds). |
| +func boundDispatch(cmd *wire.DispatchCommand, sp specialistRecord, k taskRecord, s stepRecord) error { |
| + a, err := stepAsk(s) |
| + if err != nil { |
| + return err |
| + } |
| + cmd.DesignAsk = a |
| b := bindingOf(sp) |
| cmd.SpecialistID, cmd.SpecialistRevision, cmd.SpecialistProject, cmd.Profile = b.ID, b.Revision, b.Project, sp.Profile |
| cmd.Explore, cmd.SpecialistBrief = wire.NormalKind(k.Kind) == wire.KindExplore, clipText(sp.Brief, wire.MaxSpecialistBrief) |
| if p, ok := specialist.Lookup(sp.Profile); ok { |
| cmd.Capabilities = slices.Clone(p.Capabilities) |
| } |
| + return nil |
| } |
| // boundCaps are the capabilities the step's binding records. |
diff --git a/internal/equipo/chat/review.go b/internal/equipo/chat/review.go| index db159a20..41fd35bb 100644 |
| --- a/internal/equipo/chat/review.go |
| +++ b/internal/equipo/chat/review.go |
| @@ -408,7 +408,9 @@ func (t *txn) fixRound(k *taskRecord, p progress, steps []stepRecord) error { |
| return err |
| } |
| k.RepairRound++ |
| - s := stepRecord{Specialist: wire.SpecialistEngineering, Person: p.eng.Person, Round: k.RepairRound, BaseSHA: p.candidate} |
| + // A fix round inherits its round's request (More options or More |
| + // like this), so a fresh session still knows what was asked. |
| + s := stepRecord{Specialist: wire.SpecialistEngineering, Person: p.eng.Person, Round: k.RepairRound, BaseSHA: p.candidate, DesignAsk: roundAsk(steps)} |
| k.Stage = wire.StageInProgress |
| return t.nextStep(k, steps, s) |
| } |
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go| index 6c417caa..999fb1f2 100644 |
| --- a/internal/equipo/chat/tasks.go |
| +++ b/internal/equipo/chat/tasks.go |
| @@ -336,6 +336,11 @@ type stepRecord struct { |
| // attempt said, on its accepted final report, that it ran with |
| // (section 8.8); "" when none was said. |
| PackDigest string `gorm:"not null;default:''"` |
| + // DesignAsk is a Design round's request (wire.DesignAsk JSON, "" |
| + // none): set when More options or More like this starts the round, |
| + // copied onto each of its fix rounds (fixRound), and carried on every |
| + // dispatch of the step (boundDispatch). Written once, at creation. |
| + DesignAsk string `gorm:"not null;default:''"` |
| } |
| func (stepRecord) TableName() string { return "chat_steps" } |
| @@ -1403,7 +1408,9 @@ func (t *txn) dispatchStep(k *taskRecord, s *stepRecord) error { |
| // The step's full binding (protocol 38; Encode refuses the |
| // dispatch below it, so it never runs there as plain |
| // Engineering), and the grant's use audited. |
| - boundDispatch(&cmd, *maker, *k) |
| + if err := boundDispatch(&cmd, *maker, *k, *s); err != nil { |
| + return err |
| + } |
| if err := t.specialistUsed(*maker, *k, *s); err != nil { |
| return err |
| } |
diff --git a/internal/equipo/chat_page.go b/internal/equipo/chat_page.go| index 323a919c..98f54881 100644 |
| --- a/internal/equipo/chat_page.go |
| +++ b/internal/equipo/chat_page.go |
| @@ -804,7 +804,7 @@ func (a *application) chatCardAnswer(w http.ResponseWriter, r *http.Request) { |
| } |
| remember = &name |
| } |
| - _, _, err := a.store.Chat().Answer(ctx, address, chi.URLParam(r, "id"), wire.AnswerCard{Choice: r.PostFormValue("choice"), Revision: revision, Note: r.PostFormValue("note"), RememberName: remember}) |
| + _, _, err := a.store.Chat().Answer(ctx, address, chi.URLParam(r, "id"), wire.AnswerCard{Choice: r.PostFormValue("choice"), Revision: revision, Note: r.PostFormValue("note"), Option: formOption(r), RememberName: remember}) |
| return err |
| }) |
| } |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index 7d1d480b..606fd03d 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -2063,6 +2063,7 @@ var pageCopy = map[string]string{ |
| "chat.card.build_note": "Which option should Equipo build? Say it in your own words.", // COPY APPROVED (Paul, 2026-11-29, copy-review v4fsltihakfhehduzju7dgu47m, unchanged) |
| "api.direction_note": "Say which option to build. Open this card on the web to add your note.", // COPY APPROVED (Paul, 2026-11-29, copy-review v4fsltihakfhehduzju7dgu47m, unchanged) |
| "work.explore.build_note": "%s said which option to build in their own words: %s", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) |
| + "work.explore.build_option": "Build option %d (Design's name for it: %s), from branch %s at commit %s, folder %s.", // COPY REVIEW PENDING |
| // Design feedback 1, task 5: capture captions, a link to earlier |
| // rounds, and More options and More like this on the direction card. |
diff --git a/internal/equipo/design_feedback_migration_test.go b/internal/equipo/design_feedback_migration_test.go| index ea36e025..d0005425 100644 |
| --- a/internal/equipo/design_feedback_migration_test.go |
| +++ b/internal/equipo/design_feedback_migration_test.go |
| @@ -8,8 +8,8 @@ import ( |
| ) |
| // TestDesignFeedbackMigrationLegacySteps: a step written before 0125 |
| -// reads dispatch protocol 0 (the old rules) and no pack digest once it |
| -// applies; the migration changes no existing value. |
| +// reads dispatch protocol 0 (the old rules), no pack digest and no round |
| +// request once it applies; the migration changes no existing value. |
| func TestDesignFeedbackMigrationLegacySteps(t *testing.T) { |
| ctx := context.Background() |
| all := Schema.All() |
| @@ -36,11 +36,11 @@ func TestDesignFeedbackMigrationLegacySteps(t *testing.T) { |
| } |
| } |
| var protocol, attempt int |
| - var digest, options string |
| - if err = d.QueryRowContext(ctx, "SELECT dispatch_protocol, pack_digest, attempt, design_options FROM chat_steps WHERE id = 's_old'").Scan(&protocol, &digest, &attempt, &options); err != nil { |
| + var digest, options, ask string |
| + if err = d.QueryRowContext(ctx, "SELECT dispatch_protocol, pack_digest, attempt, design_options, design_ask FROM chat_steps WHERE id = 's_old'").Scan(&protocol, &digest, &attempt, &options, &ask); err != nil { |
| t.Fatal(err) |
| } |
| - if protocol != 0 || digest != "" || attempt != 2 || options != `{"attempt":2,"options":[]}` { |
| - t.Fatalf("legacy step: protocol %d, digest %q, attempt %d, options %q", protocol, digest, attempt, options) |
| + if protocol != 0 || digest != "" || ask != "" || attempt != 2 || options != `{"attempt":2,"options":[]}` { |
| + t.Fatalf("legacy step: protocol %d, digest %q, ask %q, attempt %d, options %q", protocol, digest, ask, attempt, options) |
| } |
| } |
diff --git a/internal/equipo/migrations/0125_design_feedback.sql b/internal/equipo/migrations/0125_design_feedback.sql| index eab7868e..a8f41173 100644 |
| --- a/internal/equipo/migrations/0125_design_feedback.sql |
| +++ b/internal/equipo/migrations/0125_design_feedback.sql |
| @@ -6,3 +6,8 @@ |
| -- ("" none). A team record, as its step; no existing row changes. |
| ALTER TABLE chat_steps ADD COLUMN dispatch_protocol integer NOT NULL DEFAULT 0; |
| ALTER TABLE chat_steps ADD COLUMN pack_digest text NOT NULL DEFAULT ""; |
| +-- A Design round's request (wire.DesignAsk JSON: More options or More |
| +-- like this, the option, the current options and the person's note), |
| +-- set on the step that starts the round and on each of its fix rounds; |
| +-- "" none (every step from before this round). |
| +ALTER TABLE chat_steps ADD COLUMN design_ask text NOT NULL DEFAULT ""; |
diff --git a/internal/equipo/migrations/schema.sql b/internal/equipo/migrations/schema.sql| index 91ed47bb..4dd1b59f 100644 |
| --- a/internal/equipo/migrations/schema.sql |
| +++ b/internal/equipo/migrations/schema.sql |
| @@ -924,3 +924,8 @@ CREATE TABLE chat_step_renders (step_id text, attempt integer, renders text NOT |
| -- ("" none). A team record, as its step; no existing row changes. |
| ALTER TABLE chat_steps ADD COLUMN dispatch_protocol integer NOT NULL DEFAULT 0; |
| ALTER TABLE chat_steps ADD COLUMN pack_digest text NOT NULL DEFAULT ""; |
| +-- A Design round's request (wire.DesignAsk JSON: More options or More |
| +-- like this, the option, the current options and the person's note), |
| +-- set on the step that starts the round and on each of its fix rounds; |
| +-- "" none (every step from before this round). |
| +ALTER TABLE chat_steps ADD COLUMN design_ask text NOT NULL DEFAULT ""; |
diff --git a/internal/thintest/design_contract_test.go b/internal/thintest/design_contract_test.go| index 08f2a37a..5b4a2768 100644 |
| --- a/internal/thintest/design_contract_test.go |
| +++ b/internal/thintest/design_contract_test.go |
| @@ -10,6 +10,8 @@ import ( |
| "image" |
| "image/color" |
| "image/png" |
| + "net/http" |
| + "net/url" |
| "os" |
| "path/filepath" |
| "slices" |
| @@ -354,9 +356,12 @@ func (r *toolRig) makerOf(id string) string { |
| // instance's render check, writes its options under mockups/<task>/ and |
| // submits three (protocol 39: each with its direction, page and |
| // labelled captures); the captures go up as render_file chunks and the |
| -// final report keeps them, with those fields; the task page and the direction card show them; |
| -// Build needs a note and, with one, makes the change task with Design |
| -// as its maker and the note quoted as the person's own words. |
| +// final report keeps them, with those fields; the task page and the direction card show them, |
| +// each option with its own Build this one; an older client's Build |
| +// without a note is refused; the card's Build this one on Calm, with an |
| +// optional note, makes the change task with Design as its maker, the |
| +// option named from records and the note quoted as the person's own |
| +// words. |
| func TestContractDesignFinishLine(t *testing.T) { |
| r := newToolRigSaying(t, wire.ProtocolCurrent, overhaulWords) |
| health := rendererHealth(t, nil) |
| @@ -434,8 +439,12 @@ func TestContractDesignFinishLine(t *testing.T) { |
| t.Fatalf("the task page or the direction card lacks %q", want) |
| } |
| } |
| - if !strings.Contains(conv, "data-direction-build") { |
| - t.Fatal("the direction card's Build asks for no note") |
| + // Each option has its own Build this one and More like this, naming |
| + // it by its round's step (Design feedback 1, Task 6). |
| + for _, want := range []string{`name="option_step" value="` + d.StepID + `"`, `name="option_index" value="2"`, `value="like"`, `value="more"`} { |
| + if !strings.Contains(conv, want) { |
| + t.Fatalf("the direction card lacks %q", want) |
| + } |
| } |
| // Build with two options needs the person's note. |
| @@ -444,15 +453,21 @@ func TestContractDesignFinishLine(t *testing.T) { |
| if st, ok := err.(*ErrStatus); !ok || st.Status != 409 || json.Unmarshal(st.Body, &conflict) != nil || conflict.Code != wire.ConflictDirectionNote { |
| t.Fatalf("Build without a note: %v", err) |
| } |
| - note := "Build Calm, with Bold's yellow button." |
| - if _, err := r.client.AnswerNote(r.ctx, dir.ID, wire.ChoiceBuild, note, dir.Revision); err != nil { |
| - t.Fatal(err) |
| + // The card's own form names the option (Calm, option 1); the note |
| + // is optional and stays the person's words. |
| + note := "With Bold's yellow button." |
| + form := url.Values{"choice": {wire.ChoiceBuild}, "revision": {strconv.FormatInt(dir.Revision, 10)}, "option_step": {d.StepID}, "option_index": {"0"}, "note": {note}} |
| + if status, _ := r.post(r.inst.SessionFor(t, Owner), "/conversation/cards/"+dir.ID+"/answer", form); status != http.StatusSeeOther { |
| + t.Fatalf("Build this one on the card: %d", status) |
| } |
| k = r.task(id) |
| if k.BuiltAs == nil { |
| t.Fatalf("built %+v", k) |
| } |
| built := r.task(k.BuiltAs.ID) |
| + if !strings.Contains(built.Brief, "Build option 1 (Design's name for it: "+wire.QuotedData("Calm")+"), from branch ") || !strings.Contains(built.Brief, "folder mockups/"+id+"/calm/.") { |
| + t.Fatalf("the change task's brief names no option: %q", built.Brief) |
| + } |
| if built.Kind == wire.KindExplore || !strings.HasSuffix(built.Brief, "said which option to build in their own words: "+wire.QuotedData(note)) || r.makerOf(built.ID) != sp.ID { |
| t.Fatalf("the change task %q %q maker %q", built.Kind, built.Brief, r.makerOf(built.ID)) |
| } |
diff --git a/internal/thintest/explore_contract_test.go b/internal/thintest/explore_contract_test.go| index 4eba740f..7365726b 100644 |
| --- a/internal/thintest/explore_contract_test.go |
| +++ b/internal/thintest/explore_contract_test.go |
| @@ -211,7 +211,7 @@ func TestExploreBuildNote(t *testing.T) { |
| } |
| // TestExploreTryAgain: Try again needs the person's note and sends one |
| -// more round with it (brief and resumed-session feedback); its new |
| +// more round with it (More options is refused: Engineering made it) (brief and resumed-session feedback); its new |
| // candidate is asked about afresh. |
| func TestExploreTryAgain(t *testing.T) { |
| r := newToolRigAt(t, wire.ProtocolCurrent) |
| @@ -219,6 +219,10 @@ func TestExploreTryAgain(t *testing.T) { |
| if _, err := r.client.AnswerNote(r.ctx, card.ID, wire.ChoiceAgain, "", card.Revision); Status(err) != 422 { |
| t.Fatalf("no note: %v", err) |
| } |
| + // More options is for Design's work, not Engineering's. |
| + if _, err := r.client.AnswerNote(r.ctx, card.ID, wire.ChoiceMore, "", card.Revision); Status(err) != 422 { |
| + t.Fatalf("More options on Engineering's exploration: %v", err) |
| + } |
| if _, err := r.client.AnswerNote(r.ctx, card.ID, wire.ChoiceAgain, "Make the booking button bigger.", card.Revision); err != nil { |
| t.Fatal(err) |
| } |