wire: protocol 39 for Design feedback (options, taste, asks)
Protocol 39 (ProtocolDesignFeedback, now ProtocolCurrent) carries Design feedback (spec section 8): option direction and page, capture label, viewport, path and full_page; a dispatch's taste notes, taste and forget revisions, skipped discovery and round request (DesignAsk); AnswerCard option and taste; TaskDirection rounds and preview_refused; ask_design_taste in ConverseTools (activity label added, pending). ValidOptions39 (labels and viewports on every capture, change tasks too), ValidExploreOptions (3 to 4 options, direction, page, 1 to 3 captures), ValidFeels and ValidTasteAnswer. Below 39 Encode refuses a design-v1 dispatch, any dispatch with taste, taste or forget revision, taste_skipped or design_ask, and ask_design_taste; it drops a report's new fields and propose_specialist's feels. ProtocolCurrent pins in internal/wire tests bumped to 39. TDD evidence - go test ./internal/wire/ -run 'TestValidExploreOptions|TestDowngradeDesignFeedback|TestProtocolCurrent39' RED 1: build failed (unknown field Label in wire.DesignCapture, ...). RED 2 (types, stub functions): TestValidOptions39 "an unlabelled report passed at 39"; TestValidExploreOptions "no captures: <nil>"; TestValidTasteAnswer "long other: <nil>"; TestDowngradeDesignFeedback "frame 0 (design-v1 dispatch) encoded at 38: <nil>". GREEN: go test ./internal/wire/... ok. - Mutations (each applied alone, the tests run, then restored), all KILLED: label check; label 40 bytes; viewport; path check; 39 direction when set; 39 page unique; 39 page shape; min options; direction required; page required; captures min; captures max; direction length, utf-8, blank, Cc, Cf, Zl; page length; path length, absolute, characters; feels count, length, plain, unique; answer feels; box utf-8, length, NUL; refuse design profile, taste, taste revision, taste skipped, design ask, forget revision, ask_design_taste; drop feels; drop direction/page; drop capture facts; report changed flag; Encode wiring; Encode changed merge (first SURVIVED; added the feels-at-37 case, then KILLED). - Also run: go test ./internal/thintest/ -run 'TestActivityLabels|Design|Specialist|Protocol', ./internal/runner/thin/ -run 'Design|Protocol|Render|Tools|MCP|Mcp|Stuck|Jobs', ./internal/equipo/chat/ -run 'Design|Specialist|Bound|Grant|Capture|Explore|Direction|Advice|Protocol|Placement', ./internal/equipo/ -run 'Design|Copy|Gallery|Direction|Specialist': ok. staticcheck v0.7.0 ./internal/wire/: clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 files changed,
+826
−50
docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+1 −0internal/equipo/copy.go+1 −0internal/wire/api.go+14 −0internal/wire/assistant_files_test.go+1 −1internal/wire/assistant_test.go+1 −1internal/wire/change_diffs_test.go+1 −1internal/wire/change_files_test.go+1 −1internal/wire/connections_test.go+2 −1internal/wire/design.go+330 −8internal/wire/design_feedback_test.go+373 −0internal/wire/design_test.go+11 −7internal/wire/explore.go+25 −7internal/wire/frames.go+6 −1internal/wire/injection_test.go+2 −2internal/wire/lookup_test.go+1 −1internal/wire/mac_engineering_test.go+2 −2internal/wire/mixed_protocol_test.go+1 −1internal/wire/models_test.go+1 −1internal/wire/opencode_test.go+1 −1internal/wire/pinned_release_test.go+1 −1internal/wire/places_test.go+1 −1internal/wire/publish_test.go+1 −1internal/wire/runners.go+25 −4internal/wire/runners_test.go+1 −1internal/wire/schedule_test.go+1 −1internal/wire/stuck_test.go+1 −1internal/wire/tasks.go+18 −2internal/wire/usage_test.go+1 −1internal/wire/warm_test.go+1 −1
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index fbd59ae2..fe8e3715 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -7219,6 +7219,7 @@ records remain unchanged. |
| | `chat.card.build_note` | Which option should Equipo build? Say it in your own words. | Direction card (dynamic specialists slice 1, 2026-11-29) | 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. | Direction card (dynamic specialists slice 1, 2026-11-29) | 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 | Build task brief (dynamic specialists slice 1, 2026-11-29) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) | |
| +| `chat.activity.ask_design_taste` | Asking about the look you want… | Copy specialist | COPY REVIEW PENDING | |
| ## Task 21 |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index 6c245035..9d1e2d49 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -2026,6 +2026,7 @@ var pageCopy = map[string]string{ |
| "chat.card.specialist_chose_not_now": "Not added. You can ask to add it later.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-12) |
| "chat.card.specialist_revoked": "Removed from your team.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-12) |
| "chat.activity.propose_specialist": "Asking to add a specialist…", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-12) |
| + "chat.activity.ask_design_taste": "Asking about the look you want…", // COPY REVIEW PENDING |
| // Research sources, card and scheduling (Research R2). |
| "work.specialist.research": "Research", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-12) |
diff --git a/internal/wire/api.go b/internal/wire/api.go| index 3cb825ea..bb52d060 100644 |
| --- a/internal/wire/api.go |
| +++ b/internal/wire/api.go |
| @@ -425,6 +425,20 @@ type AnswerCard struct { |
| // direction card's Try again, and its Build this naming the option |
| // they want), at most MaxDirectionNote bytes. |
| Note string `json:"note,omitempty"` |
| + // Option (ProtocolDesignFeedback) is the option a direction card's |
| + // Build this one or More like this names: a maker step of the task |
| + // and the option's place among what the instance kept for it. |
| + Option *OptionRef `json:"option,omitempty"` |
| + // Taste is a design_taste card's answers (Use these); absent on |
| + // every other answer. |
| + Taste *TasteAnswer `json:"taste,omitempty"` |
| +} |
| + |
| +// OptionRef names one kept option: its maker step and its index (from 0) |
| +// in that step's kept options. |
| +type OptionRef struct { |
| + Step string `json:"step"` |
| + Index int `json:"index"` |
| } |
| // Answered is the response: the answered card, and the answer as the |
diff --git a/internal/wire/assistant_files_test.go b/internal/wire/assistant_files_test.go| index ec9c4510..8dc39c6a 100644 |
| --- a/internal/wire/assistant_files_test.go |
| +++ b/internal/wire/assistant_files_test.go |
| @@ -16,7 +16,7 @@ import ( |
| // Assistant message with files is refused, earlier and earlier_more are |
| // dropped, and the Coordinator's and a job's frames go as they are. |
| func TestProtocol33AssistantFiles(t *testing.T) { |
| - if wire.Protocol33 != 33 || wire.ProtocolAssistantFiles != wire.Protocol33 || wire.ProtocolUnfinishedWork != wire.Protocol32 || wire.ProtocolCurrent != wire.ProtocolDesign || wire.Spoken(99) != 38 { |
| + if wire.Protocol33 != 33 || wire.ProtocolAssistantFiles != wire.Protocol33 || wire.ProtocolUnfinishedWork != wire.Protocol32 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback || wire.Spoken(99) != 39 { |
| t.Fatalf("assistant files %d, current %d", wire.ProtocolAssistantFiles, wire.ProtocolCurrent) |
| } |
| if wire.RunnerKeepFiles != 14*24*time.Hour { |
diff --git a/internal/wire/assistant_test.go b/internal/wire/assistant_test.go| index 62844d49..65dbf79b 100644 |
| --- a/internal/wire/assistant_test.go |
| +++ b/internal/wire/assistant_test.go |
| @@ -81,7 +81,7 @@ func TestAssistantCardJSON(t *testing.T) { |
| // A runner that speaks 24 or more is spoken to at 24, the warm |
| // protocol; glances came at 23 and jobs at 22. |
| func TestSpokenIs24(t *testing.T) { |
| - if wire.Spoken(99) != 38 || wire.ProtocolCurrent != wire.ProtocolDesign || wire.ProtocolWarm != wire.Protocol24 || wire.ProtocolGlance != wire.Protocol23 || wire.ProtocolJobs != wire.Protocol22 || wire.ProtocolCopy != wire.Protocol21 || wire.ProtocolUsageRefresh != wire.Protocol20 || wire.ProtocolAssistant != wire.Protocol19 { |
| + if wire.Spoken(99) != 39 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback || wire.ProtocolWarm != wire.Protocol24 || wire.ProtocolGlance != wire.Protocol23 || wire.ProtocolJobs != wire.Protocol22 || wire.ProtocolCopy != wire.Protocol21 || wire.ProtocolUsageRefresh != wire.Protocol20 || wire.ProtocolAssistant != wire.Protocol19 { |
| t.Fatalf("spoken %d, current %d", wire.Spoken(99), wire.ProtocolCurrent) |
| } |
| } |
diff --git a/internal/wire/change_diffs_test.go b/internal/wire/change_diffs_test.go| index 101aba0d..3eca1260 100644 |
| --- a/internal/wire/change_diffs_test.go |
| +++ b/internal/wire/change_diffs_test.go |
| @@ -11,7 +11,7 @@ import ( |
| ) |
| func TestProtocol35ChangeDiffs(t *testing.T) { |
| - if wire.ProtocolChangeDiffs != 35 || wire.ProtocolCurrent != 38 { |
| + if wire.ProtocolChangeDiffs != 35 || wire.ProtocolCurrent != 39 { |
| t.Fatal("protocol") |
| } |
| f, err := wire.NewFrame("diff", wire.FrameChangeDiff, wire.ChangeDiffUpload{}) |
diff --git a/internal/wire/change_files_test.go b/internal/wire/change_files_test.go| index 8567e9ef..f7240666 100644 |
| --- a/internal/wire/change_files_test.go |
| +++ b/internal/wire/change_files_test.go |
| @@ -11,7 +11,7 @@ import ( |
| ) |
| func TestProtocol31ChangeFiles(t *testing.T) { |
| - if wire.ProtocolChangeFiles != 31 || wire.ProtocolCurrent != 38 { |
| + if wire.ProtocolChangeFiles != 31 || wire.ProtocolCurrent != 39 { |
| t.Fatal("protocol not 31") |
| } |
| facts := &wire.ChangeFiles{Base: strings.Repeat("a", 40), SHA: strings.Repeat("b", 40), Files: 1, Additions: 1, Entries: []wire.ChangedFile{{Path: "a.txt", Status: "added", Additions: 1}}} |
diff --git a/internal/wire/connections_test.go b/internal/wire/connections_test.go| index 4ea0c217..95506e46 100644 |
| --- a/internal/wire/connections_test.go |
| +++ b/internal/wire/connections_test.go |
| @@ -45,7 +45,8 @@ func TestConnectionTypesCarryNoSecrets(t *testing.T) { |
| // An advice card’s key is its kind and subject (connectors spec §9). |
| // CopyFlag.key identifies an app string; CopyResult.tokens is its numeric usage. |
| // ChangedFile paths are validated repository-relative names, never account paths. |
| - allowed := map[string]bool{"ChangedFile.path": true, "ChangedFile.old_path": true, "CopyFlag.key": true, "CopyResult.tokens": true, "Advice.key": true, "Hello.seal_key": true, "Runner.seal_key": true, "Usage.input_tokens": true, "Usage.output_tokens": true, "Usage.cached_input_tokens": true, "Usage.cache_write_tokens": true, "Usage.reasoning_output_tokens": true} |
| + // A Design capture's path is the site page render_page took (ValidOptions39). |
| + allowed := map[string]bool{"ChangedFile.path": true, "ChangedFile.old_path": true, "DesignCapture.path": true, "StepCapture.path": true, "CopyFlag.key": true, "CopyResult.tokens": true, "Advice.key": true, "Hello.seal_key": true, "Runner.seal_key": true, "Usage.input_tokens": true, "Usage.output_tokens": true, "Usage.cached_input_tokens": true, "Usage.cache_write_tokens": true, "Usage.reasoning_output_tokens": true} |
| counter, _ := reflect.TypeOf(wire.CopyResult{}).FieldByName("Tokens") |
| if counter.Type.Kind() != reflect.Int64 { |
| t.Fatal("Copy token counter must remain numeric") |
diff --git a/internal/wire/design.go b/internal/wire/design.go| index 6dc910ab..7dde7ef4 100644 |
| --- a/internal/wire/design.go |
| +++ b/internal/wire/design.go |
| @@ -74,19 +74,31 @@ const ( |
| ) |
| // DesignOption is one mockup option of a Design step's candidate: the |
| -// name the person will use for it and the captures that show it. |
| +// name the person will use for it and the captures that show it. From |
| +// ProtocolDesignFeedback, Direction is what the option commits to, in |
| +// plain text (Design's words), and Page its folder under |
| +// mockups/<task>/. |
| type DesignOption struct { |
| - Name string `json:"name"` |
| - Captures []DesignCapture `json:"captures"` |
| + Name string `json:"name"` |
| + Direction string `json:"direction,omitempty"` |
| + Page string `json:"page,omitempty"` |
| + Captures []DesignCapture `json:"captures"` |
| } |
| // DesignCapture is one capture an option names: its render_page file id |
| // (the name under /render/), the SHA-256 of its PNG and the digest of the |
| -// exported tree it was rendered from (a diff carries work's). |
| +// exported tree it was rendered from (a diff carries work's). From |
| +// ProtocolDesignFeedback, Label is what it shows (Design's words, a |
| +// plain label) and Viewport, Path and FullPage are the render call's |
| +// page as the runner recorded it, never the model's. |
| type DesignCapture struct { |
| ID string `json:"id"` |
| SHA256 string `json:"sha256"` |
| TreeDigest string `json:"tree_digest"` |
| + Label string `json:"label,omitempty"` |
| + Viewport string `json:"viewport,omitempty"` |
| + Path string `json:"path,omitempty"` |
| + FullPage bool `json:"full_page,omitempty"` |
| } |
| // StepDesign is what a done Design attempt kept, on the task's read |
| @@ -99,21 +111,30 @@ type StepDesign struct { |
| } |
| // StepDesignOption is one option and its kept captures, in the report's |
| -// order. Name is the specialist's label for it. |
| +// order. Name is the specialist's label for it; Direction and Page are |
| +// the report's (ProtocolDesignFeedback, "" before it). |
| type StepDesignOption struct { |
| - Name string `json:"name"` |
| - Captures []StepCapture `json:"captures"` |
| + Name string `json:"name"` |
| + Direction string `json:"direction,omitempty"` |
| + Page string `json:"page,omitempty"` |
| + Captures []StepCapture `json:"captures"` |
| } |
| // StepCapture is one kept capture: ID is its task file (GET |
| // /tasks/{task}/files/{id}), CaptureID the render_page file it was |
| -// (its tree is in the name), with its size and pixel size. |
| +// (its tree is in the name), with its size and pixel size, and the |
| +// report's label and render facts (ProtocolDesignFeedback, empty |
| +// before it). |
| type StepCapture struct { |
| ID string `json:"id"` |
| CaptureID string `json:"capture_id"` |
| Size int64 `json:"size"` |
| Width int `json:"width"` |
| Height int `json:"height"` |
| + Label string `json:"label,omitempty"` |
| + Viewport string `json:"viewport,omitempty"` |
| + Path string `json:"path,omitempty"` |
| + FullPage bool `json:"full_page,omitempty"` |
| } |
| // CaptureTree is the tree a capture id names: base, work or diff ("" for |
| @@ -434,3 +455,304 @@ func withoutTeamProject(v *ToolCall, protocol int) (bool, error) { |
| v.Args = raw |
| return true, nil |
| } |
| + |
| +// Design feedback (spec 2026-11-28-dynamic-specialists.md, section 8; |
| +// ProtocolDesignFeedback): every capture of a Design report is labelled |
| +// and carries the runner's render facts, an exploration's report has 3 |
| +// or 4 options each with a direction and a page folder, a Design |
| +// dispatch carries the task creator's taste notes and the round's |
| +// request, and a discovery card asks a few taste questions. |
| + |
| +// Bounds of Design feedback. |
| +const ( |
| + // MinDesignOptions is an exploration report's fewest options (at most |
| + // MaxDesignOptions); a change report has no minimum. |
| + MinDesignOptions = 3 |
| + // MaxCapturesPerOption is the most captures one exploration option |
| + // names (at least one). |
| + MaxCapturesPerOption = 3 |
| + // MaxDirection bounds an option's direction, in bytes. |
| + MaxDirection = 500 |
| + // MaxCaptureLabel bounds a capture's label, in bytes. |
| + MaxCaptureLabel = 40 |
| + // MaxFeel bounds one feel label, in bytes, and MaxFeels a list of |
| + // them (propose_specialist's and ask_design_taste's feels, and a |
| + // discovery answer's). |
| + MaxFeel = 30 |
| + MaxFeels = 5 |
| + // MaxTasteBox bounds each discovery box, in characters. |
| + MaxTasteBox = 300 |
| + // maxPage bounds an option's page folder, in bytes; maxCapturePath a |
| + // capture's page path (render_page's own bound). |
| + maxPage = 60 |
| + maxCapturePath = 1024 |
| +) |
| + |
| +// The fixed viewports a capture is rendered at (render.Viewport). |
| +var captureViewports = []string{"phone", "tablet", "desktop"} |
| + |
| +// designProfile is the Design specialist's profile id |
| +// (specialist.ProfileDesign): its steps need ProtocolDesignFeedback. |
| +const designProfile = "design-v1" |
| + |
| +// pageFolder is an option's folder name under mockups/<task>/. |
| +var pageFolder = regexp.MustCompile(`^[a-z0-9]+(-[a-z0-9]+)*$`) |
| + |
| +// DesignAsk is a Design round's request, on its dispatch and inherited |
| +// by its fix rounds: Kind DesignAskMore (new directions unlike Current) |
| +// or DesignAskLike (variations of Option), with the person's optional |
| +// note. Current and Option are Design's words; Note is the person's. |
| +type DesignAsk struct { |
| + Kind string `json:"kind"` |
| + Option *StepDesignOption `json:"option,omitempty"` |
| + Current []StepDesignOption `json:"current,omitempty"` |
| + Note string `json:"note,omitempty"` |
| +} |
| + |
| +// A round request's kind. |
| +const ( |
| + DesignAskMore = "more" |
| + DesignAskLike = "like" |
| +) |
| + |
| +// TasteNote is one of the task creator's design notes, as a Design |
| +// dispatch carries it: its id, its source (TasteSourceWords, the |
| +// person's own typed words, or TasteSourceChoice, a choice among options |
| +// others wrote, with Question the words they chose under), its scope |
| +// (TasteScopeProject or TasteScopeTeam), its body and the date it was |
| +// written. The prompt quotes each under a label naming its source. |
| +type TasteNote struct { |
| + ID string `json:"id"` |
| + Source string `json:"source"` |
| + Scope string `json:"scope"` |
| + Body string `json:"body"` |
| + Question string `json:"question,omitempty"` |
| + Date string `json:"date"` |
| +} |
| + |
| +// A taste note's source and scope. |
| +const ( |
| + TasteSourceWords = "words" |
| + TasteSourceChoice = "choice" |
| + TasteScopeProject = "project" |
| + TasteScopeTeam = "team" |
| +) |
| + |
| +// CardDesignTaste asks a person the Design discovery questions for a |
| +// project; its answers are ChoiceUseThese (with AnswerCard.Taste) and |
| +// ChoiceSkip. |
| +const ( |
| + CardDesignTaste = "design_taste" |
| + ChoiceUseThese = "use" |
| +) |
| + |
| +// TasteAnswer is a discovery card's answers (AnswerCard.Taste, and the |
| +// Add card's): Feels the labels the person tapped among those offered, |
| +// Other the "Something else" box, Like the sites or apps whose look they |
| +// like, Avoid what to avoid and Keep what has to stay. Every part is |
| +// optional (ValidTasteAnswer). |
| +type TasteAnswer struct { |
| + Feels []string `json:"feels,omitempty"` |
| + Other string `json:"other,omitempty"` |
| + Like string `json:"like,omitempty"` |
| + Avoid string `json:"avoid,omitempty"` |
| + Keep string `json:"keep,omitempty"` |
| +} |
| + |
| +// ValidOptions39 strictly bounds a Design report's options at |
| +// ProtocolDesignFeedback, an exploration's or a change's: ValidOptions, |
| +// and every capture labelled (a plain label of at most MaxCaptureLabel |
| +// bytes) at a fixed viewport, with a page path when it has one that is |
| +// absolute printable ASCII without space, backslash or fragment, of at |
| +// most 1024 bytes. An option's direction and page, when set, are as |
| +// ValidExploreOptions has them, each page said once. Any number of |
| +// options up to MaxDesignOptions. |
| +func ValidOptions39(opts []DesignOption) error { |
| + if err := ValidOptions(opts); err != nil { |
| + return err |
| + } |
| + pages := map[string]bool{} |
| + for _, o := range opts { |
| + if o.Direction != "" && !validDirection(o.Direction) { |
| + return fmt.Errorf("%w: option %q's direction", ErrStrict, o.Name) |
| + } |
| + if o.Page != "" { |
| + if !validPage(o.Page) || pages[o.Page] { |
| + return fmt.Errorf("%w: option %q's page %q", ErrStrict, o.Name, o.Page) |
| + } |
| + pages[o.Page] = true |
| + } |
| + for _, c := range o.Captures { |
| + if len(c.Label) > MaxCaptureLabel || !validOptionName(c.Label) { |
| + return fmt.Errorf("%w: capture %q's label", ErrStrict, c.ID) |
| + } |
| + if !slices.Contains(captureViewports, c.Viewport) || c.Path != "" && !validCapturePath(c.Path) { |
| + return fmt.Errorf("%w: capture %q's page", ErrStrict, c.ID) |
| + } |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// ValidExploreOptions strictly bounds an exploration's Design report at |
| +// ProtocolDesignFeedback: ValidOptions39, and MinDesignOptions to |
| +// MaxDesignOptions options, each with a direction (1 to MaxDirection |
| +// bytes of plain text: valid UTF-8, not blank, no control, format or |
| +// line-breaking character), a page folder (lower-case words joined by |
| +// single hyphens, at most 60 bytes, each said once) and 1 to |
| +// MaxCapturesPerOption captures. |
| +func ValidExploreOptions(opts []DesignOption) error { |
| + if err := ValidOptions39(opts); err != nil { |
| + return err |
| + } |
| + if len(opts) < MinDesignOptions { |
| + return fmt.Errorf("%w: %d options", ErrStrict, len(opts)) |
| + } |
| + for _, o := range opts { |
| + switch { |
| + case o.Direction == "": |
| + return fmt.Errorf("%w: option %q has no direction", ErrStrict, o.Name) |
| + case o.Page == "": |
| + return fmt.Errorf("%w: option %q has no page", ErrStrict, o.Name) |
| + case len(o.Captures) < 1 || len(o.Captures) > MaxCapturesPerOption: |
| + return fmt.Errorf("%w: option %q has %d captures", ErrStrict, o.Name, len(o.Captures)) |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// validDirection: 1 to MaxDirection bytes of valid UTF-8, not only |
| +// spaces, with no control, format, line or paragraph separator |
| +// character (so no newline, NUL or bidirectional override). |
| +func validDirection(s string) bool { |
| + if len(s) > MaxDirection || !utf8.ValidString(s) || strings.TrimSpace(s) == "" { |
| + return false |
| + } |
| + for _, r := range s { |
| + if unicode.In(r, unicode.Cc, unicode.Cf, unicode.Zl, unicode.Zp) { |
| + return false |
| + } |
| + } |
| + return true |
| +} |
| + |
| +// validPage: an option's folder name, at most maxPage bytes. |
| +func validPage(s string) bool { return len(s) <= maxPage && pageFolder.MatchString(s) } |
| + |
| +// validCapturePath: a page path as render_page takes one (SitePath, in |
| +// short): absolute, printable ASCII without space, backslash or |
| +// fragment, at most maxCapturePath bytes. |
| +func validCapturePath(p string) bool { |
| + if len(p) > maxCapturePath || !strings.HasPrefix(p, "/") { |
| + return false |
| + } |
| + for i := 0; i < len(p); i++ { |
| + if c := p[i]; c <= ' ' || c >= 0x7f || c == '\\' || c == '#' { |
| + return false |
| + } |
| + } |
| + return true |
| +} |
| + |
| +// ValidFeels bounds a list of feel labels: at most MaxFeels, each a |
| +// plain label (validOptionName) of at most MaxFeel bytes, said once |
| +// (case folded). |
| +func ValidFeels(feels []string) error { |
| + if len(feels) > MaxFeels { |
| + return fmt.Errorf("%w: %d feels", ErrStrict, len(feels)) |
| + } |
| + seen := map[string]bool{} |
| + for _, f := range feels { |
| + folded := strings.ToLower(f) |
| + if len(f) > MaxFeel || !validOptionName(f) || seen[folded] { |
| + return fmt.Errorf("%w: feel %q", ErrStrict, f) |
| + } |
| + seen[folded] = true |
| + } |
| + return nil |
| +} |
| + |
| +// ValidTasteAnswer bounds a discovery answer: its feels (ValidFeels) and |
| +// each box at most MaxTasteBox characters of valid UTF-8 without NUL. |
| +// No answer, and an empty one, are valid (every part is optional). |
| +func ValidTasteAnswer(a *TasteAnswer) error { |
| + if a == nil { |
| + return nil |
| + } |
| + if err := ValidFeels(a.Feels); err != nil { |
| + return err |
| + } |
| + for name, box := range map[string]string{"other": a.Other, "like": a.Like, "avoid": a.Avoid, "keep": a.Keep} { |
| + if !utf8.ValidString(box) || utf8.RuneCountInString(box) > MaxTasteBox || strings.ContainsRune(box, 0) { |
| + return fmt.Errorf("%w: taste box %s", ErrStrict, name) |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// designFeedbackDispatch: a dispatch only a runner at |
| +// ProtocolDesignFeedback may run: a Design step's (whatever else it |
| +// carries, so Design never runs without its labels and directions), or |
| +// any dispatch carrying taste, its revisions, a skipped discovery or a |
| +// round request. |
| +func designFeedbackDispatch(d *DispatchCommand) bool { |
| + return d.Profile == designProfile || len(d.Taste) > 0 || d.TasteRevision != 0 || d.TasteSkipped || d.DesignAsk != nil || d.ForgetRevision != 0 |
| +} |
| + |
| +// downgradeDesignFeedback makes a frame speak a protocol below |
| +// ProtocolDesignFeedback. A Design dispatch, and any dispatch with taste |
| +// or a round request, is refused (designFeedbackDispatch), and so is an |
| +// ask_design_taste call (an older instance has no discovery card). A |
| +// report's option directions and pages and its captures' labels and |
| +// render facts are dropped (its names and captures stay valid under |
| +// ValidOptions), and so are propose_specialist's feels. It reports |
| +// whether anything changed. |
| +func downgradeDesignFeedback(body any, protocol int) (bool, error) { |
| + switch v := body.(type) { |
| + case *DispatchCommand: |
| + if designFeedbackDispatch(v) { |
| + return false, fmt.Errorf("%w: a Design dispatch at protocol %d", ErrProtocol, protocol) |
| + } |
| + case *ToolCall: |
| + if v.Name == ToolAskDesignTaste { |
| + return false, fmt.Errorf("%w: %s at protocol %d", ErrProtocol, v.Name, protocol) |
| + } |
| + return withoutFeels(v) |
| + case *StepReport: |
| + changed := false |
| + for i := range v.Options { |
| + o := &v.Options[i] |
| + changed = changed || o.Direction != "" || o.Page != "" |
| + o.Direction, o.Page = "", "" |
| + for j := range o.Captures { |
| + c := &o.Captures[j] |
| + changed = changed || c.Label != "" || c.Viewport != "" || c.Path != "" || c.FullPage |
| + c.Label, c.Viewport, c.Path, c.FullPage = "", "", "", false |
| + } |
| + } |
| + return changed, nil |
| + } |
| + return false, nil |
| +} |
| + |
| +// withoutFeels drops propose_specialist's feels (the Add card's taste |
| +// questions), which an older instance has no words for. |
| +func withoutFeels(v *ToolCall) (bool, error) { |
| + if v.Name != ToolProposeSpecialist { |
| + return false, nil |
| + } |
| + var args map[string]json.RawMessage |
| + if json.Unmarshal(v.Args, &args) != nil { |
| + return false, nil |
| + } |
| + if _, ok := args["feels"]; !ok { |
| + return false, nil |
| + } |
| + delete(args, "feels") |
| + raw, err := json.Marshal(args) |
| + if err != nil { |
| + return false, err |
| + } |
| + v.Args = raw |
| + return true, nil |
| +} |
diff --git a/internal/wire/design_feedback_test.go b/internal/wire/design_feedback_test.go| new file mode 100644 |
| index 00000000..880a3521 |
| --- /dev/null |
| +++ b/internal/wire/design_feedback_test.go |
| @@ -0,0 +1,373 @@ |
| +package wire_test |
| + |
| +import ( |
| + "bytes" |
| + "encoding/json" |
| + "errors" |
| + "slices" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/specialist" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// labelled is a protocol 39 capture: a capture id, its digests and the |
| +// runner's render facts, with Design's label. |
| +func labelled(id, label, viewport string) wire.DesignCapture { |
| + return wire.DesignCapture{ID: id, SHA256: sum('a'), TreeDigest: sum('b'), Label: label, Viewport: viewport, Path: "/mockups/tk1/writing-desk/", FullPage: true} |
| +} |
| + |
| +// exploreOptions is a valid exploration's three options at protocol 39. |
| +func exploreOptions() []wire.DesignOption { |
| + return []wire.DesignOption{ |
| + {Name: "Writing desk", Direction: "A quiet serif page with wide margins, for reading.", Page: "writing-desk", Captures: []wire.DesignCapture{labelled("1-work-1.png", "Dashboard", "desktop"), labelled("1-work-2.png", "Empty inbox", "phone")}}, |
| + {Name: "Newsroom console", Direction: "Dense columns and a bold grotesque, for scanning.", Page: "newsroom-console", Captures: []wire.DesignCapture{labelled("2-work-1.png", "Dashboard", "tablet")}}, |
| + {Name: "Field notes", Direction: "Hand-drawn accents on warm paper.", Page: "field-notes-2", Captures: []wire.DesignCapture{labelled("3-work-1.png", "Dashboard", "desktop"), labelled("3-work-2.png", "Settings", "desktop"), labelled("3-work-3.png", "Sign in", "phone")}}, |
| + } |
| +} |
| + |
| +// cloneOptions copies options deep enough to change one capture. |
| +func cloneOptions(o []wire.DesignOption) []wire.DesignOption { |
| + o = slices.Clone(o) |
| + for i := range o { |
| + o[i].Captures = slices.Clone(o[i].Captures) |
| + } |
| + return o |
| +} |
| + |
| +// TestProtocolCurrent39: protocol 39 is Design feedback's and the |
| +// current one, with the bounds the spec gives it. |
| +func TestProtocolCurrent39(t *testing.T) { |
| + if wire.Protocol39 != 39 || wire.ProtocolDesignFeedback != wire.Protocol39 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback || wire.Spoken(99) != 39 || wire.Spoken(38) != 38 || wire.ProtocolDesign != 38 { |
| + t.Fatalf("feedback %d, current %d, spoken %d", wire.ProtocolDesignFeedback, wire.ProtocolCurrent, wire.Spoken(99)) |
| + } |
| + if wire.MinDesignOptions != 3 || wire.MaxDesignOptions != 4 || wire.MaxCapturesPerOption != 3 || wire.MaxDirection != 500 || wire.MaxCaptureLabel != 40 || wire.MaxFeel != 30 || wire.MaxFeels != 5 || wire.MaxTasteBox != 300 { |
| + t.Fatal("bounds") |
| + } |
| + if wire.DesignAskMore != "more" || wire.DesignAskLike != "like" || wire.ChoiceMore != "more" || wire.ChoiceLike != "like" || wire.CardDesignTaste != "design_taste" || wire.ChoiceUseThese != "use" || wire.ChoiceSkip != "skip" { |
| + t.Fatal("names") |
| + } |
| + if wire.ToolAskDesignTaste != "ask_design_taste" || !slices.Contains(wire.ConverseTools, wire.ToolAskDesignTaste) || slices.Contains(wire.MoveInTools, wire.ToolAskDesignTaste) { |
| + t.Fatal("ask_design_taste is not a conversation tool") |
| + } |
| +} |
| + |
| +// TestValidOptions39: at protocol 39 every capture of every Design |
| +// report carries a label (plain-label rules, at most 40 bytes) and a |
| +// fixed viewport, on change tasks too, with no minimum of options. The |
| +// old rules (ValidOptions) still take a report without them. |
| +func TestValidOptions39(t *testing.T) { |
| + one := []wire.DesignOption{{Name: "Writing desk", Captures: []wire.DesignCapture{labelled("1-work-1.png", "Dashboard", "desktop"), labelled("1-work-2.png", strings.Repeat("a", wire.MaxCaptureLabel), "tablet")}}} |
| + if err := wire.ValidOptions39(one); err != nil { |
| + t.Fatalf("a one-option change refused: %v", err) |
| + } |
| + if err := wire.ValidOptions39(nil); err != nil { |
| + t.Fatalf("no options refused: %v", err) |
| + } |
| + if err := wire.ValidOptions39(exploreOptions()); err != nil { |
| + t.Fatalf("an exploration's options refused: %v", err) |
| + } |
| + if err := wire.ValidOptions(designOptions()); err != nil { |
| + t.Fatalf("an old report refused by the old rules: %v", err) |
| + } |
| + if err := wire.ValidOptions39(designOptions()); err == nil { |
| + t.Fatal("an unlabelled report passed at 39") |
| + } |
| + five := cloneOptions(exploreOptions()) |
| + five = append(five, wire.DesignOption{Name: "Four"}, wire.DesignOption{Name: "Five"}) |
| + for name, mutate := range map[string]func(o []wire.DesignOption) []wire.DesignOption{ |
| + "missing label": func(o []wire.DesignOption) []wire.DesignOption { o[0].Captures[0].Label = ""; return o }, |
| + "41-byte label": func(o []wire.DesignOption) []wire.DesignOption { |
| + o[0].Captures[0].Label = strings.Repeat("a", 41) |
| + return o |
| + }, |
| + "markup label": func(o []wire.DesignOption) []wire.DesignOption { o[0].Captures[0].Label = "<b>Dashboard</b>"; return o }, |
| + "format label": func(o []wire.DesignOption) []wire.DesignOption { o[0].Captures[0].Label = "Dash\u202eboard"; return o }, |
| + "missing viewport": func(o []wire.DesignOption) []wire.DesignOption { o[0].Captures[0].Viewport = ""; return o }, |
| + "other viewport": func(o []wire.DesignOption) []wire.DesignOption { o[0].Captures[0].Viewport = "watch"; return o }, |
| + "relative path": func(o []wire.DesignOption) []wire.DesignOption { o[0].Captures[0].Path = "mockups/x"; return o }, |
| + "path with space": func(o []wire.DesignOption) []wire.DesignOption { o[0].Captures[0].Path = "/a b"; return o }, |
| + "long path": func(o []wire.DesignOption) []wire.DesignOption { |
| + o[0].Captures[0].Path = "/" + strings.Repeat("a", 1024) |
| + return o |
| + }, |
| + "bad direction": func(o []wire.DesignOption) []wire.DesignOption { o[0].Direction = "A\u202eB"; return o }, |
| + "bad page": func(o []wire.DesignOption) []wire.DesignOption { o[0].Page = "../x"; return o }, |
| + "same page": func(o []wire.DesignOption) []wire.DesignOption { o[1].Page = o[0].Page; return o }, |
| + "old rules": func(o []wire.DesignOption) []wire.DesignOption { o[1].Name = o[0].Name; return o }, |
| + "five options": func([]wire.DesignOption) []wire.DesignOption { return five }, |
| + } { |
| + if err := wire.ValidOptions39(mutate(cloneOptions(exploreOptions()))); !errors.Is(err, wire.ErrStrict) { |
| + t.Fatalf("%s: %v", name, err) |
| + } |
| + } |
| +} |
| + |
| +// TestValidExploreOptions: an exploration's report at protocol 39 has 3 |
| +// or 4 options, each with a direction in plain text, its own page folder |
| +// and 1 to 3 labelled captures. |
| +func TestValidExploreOptions(t *testing.T) { |
| + if err := wire.ValidExploreOptions(exploreOptions()); err != nil { |
| + t.Fatalf("three valid options refused: %v", err) |
| + } |
| + four := append(cloneOptions(exploreOptions()), wire.DesignOption{Name: "Gallery wall", Direction: strings.Repeat("é", wire.MaxDirection/2), Page: strings.Repeat("a", 60), Captures: []wire.DesignCapture{labelled("4-work-1.png", "Dashboard", "desktop")}}) |
| + if err := wire.ValidExploreOptions(four); err != nil { |
| + t.Fatalf("four options, the longest direction and page refused: %v", err) |
| + } |
| + five := append(slices.Clone(four), wire.DesignOption{Name: "Fifth", Direction: "d", Page: "fifth", Captures: []wire.DesignCapture{labelled("5-work-1.png", "Dashboard", "desktop")}}) |
| + for name, mutate := range map[string]func(o []wire.DesignOption) []wire.DesignOption{ |
| + "two options": func(o []wire.DesignOption) []wire.DesignOption { return o[:2] }, |
| + "five options": func([]wire.DesignOption) []wire.DesignOption { return cloneOptions(five) }, |
| + "empty direction": func(o []wire.DesignOption) []wire.DesignOption { o[1].Direction = ""; return o }, |
| + "blank direction": func(o []wire.DesignOption) []wire.DesignOption { o[1].Direction = " "; return o }, |
| + "501-byte": func(o []wire.DesignOption) []wire.DesignOption { o[1].Direction = strings.Repeat("a", 501); return o }, |
| + "right-to-left": func(o []wire.DesignOption) []wire.DesignOption { o[1].Direction = "Calm \u202e and quiet"; return o }, |
| + "control": func(o []wire.DesignOption) []wire.DesignOption { o[1].Direction = "Calm\x00quiet"; return o }, |
| + "line separator": func(o []wire.DesignOption) []wire.DesignOption { o[1].Direction = "Calm\u2028quiet"; return o }, |
| + "invalid utf-8": func(o []wire.DesignOption) []wire.DesignOption { o[1].Direction = "Calm\xff"; return o }, |
| + "duplicate page": func(o []wire.DesignOption) []wire.DesignOption { o[2].Page = "writing-desk"; return o }, |
| + "dot dot page": func(o []wire.DesignOption) []wire.DesignOption { o[2].Page = "../x"; return o }, |
| + "no page": func(o []wire.DesignOption) []wire.DesignOption { o[2].Page = ""; return o }, |
| + "upper-case page": func(o []wire.DesignOption) []wire.DesignOption { o[2].Page = "Writing"; return o }, |
| + "trailing hyphen": func(o []wire.DesignOption) []wire.DesignOption { o[2].Page = "writing-"; return o }, |
| + "61-byte page": func(o []wire.DesignOption) []wire.DesignOption { o[2].Page = strings.Repeat("a", 61); return o }, |
| + "four captures": func(o []wire.DesignOption) []wire.DesignOption { |
| + o[2].Captures = append(o[2].Captures, labelled("3-work-4.png", "More", "desktop")) |
| + return o |
| + }, |
| + "no captures": func(o []wire.DesignOption) []wire.DesignOption { o[1].Captures = nil; return o }, |
| + "missing label": func(o []wire.DesignOption) []wire.DesignOption { o[0].Captures[1].Label = ""; return o }, |
| + "unknown viewport": func(o []wire.DesignOption) []wire.DesignOption { o[0].Captures[1].Viewport = "wide"; return o }, |
| + "a repeated id": func(o []wire.DesignOption) []wire.DesignOption { o[1].Captures[0].ID = "1-work-1.png"; return o }, |
| + "an unplain name": func(o []wire.DesignOption) []wire.DesignOption { o[1].Name = "news/room"; return o }, |
| + "a repeated name": func(o []wire.DesignOption) []wire.DesignOption { o[1].Name = "writing DESK"; return o }, |
| + "a too-long label": func(o []wire.DesignOption) []wire.DesignOption { |
| + o[0].Captures[0].Label = strings.Repeat("b", 41) |
| + return o |
| + }, |
| + "a capture's sha": func(o []wire.DesignOption) []wire.DesignOption { o[0].Captures[0].SHA256 = "x"; return o }, |
| + "a markup label": func(o []wire.DesignOption) []wire.DesignOption { o[0].Captures[0].Label = "<i>x</i>"; return o }, |
| + "a newline label": func(o []wire.DesignOption) []wire.DesignOption { o[0].Captures[0].Label = "a\nb"; return o }, |
| + "a leading-space": func(o []wire.DesignOption) []wire.DesignOption { o[0].Captures[0].Label = " a"; return o }, |
| + "a double space": func(o []wire.DesignOption) []wire.DesignOption { o[0].Captures[0].Label = "a b"; return o }, |
| + } { |
| + if err := wire.ValidExploreOptions(mutate(cloneOptions(exploreOptions()))); !errors.Is(err, wire.ErrStrict) { |
| + t.Fatalf("%s: %v", name, err) |
| + } |
| + } |
| +} |
| + |
| +// TestValidTasteAnswer bounds a discovery answer: at most five feels, |
| +// each a plain label of at most 30 bytes said once; each box at most 300 |
| +// characters of valid UTF-8 without NUL. |
| +func TestValidTasteAnswer(t *testing.T) { |
| + good := wire.TasteAnswer{Feels: []string{"Calm", "Editorial"}, Other: "Like a library", Like: strings.Repeat("é", wire.MaxTasteBox), Avoid: "Neon\ngradients", Keep: "The logo"} |
| + if err := wire.ValidTasteAnswer(&good); err != nil { |
| + t.Fatalf("refused: %v", err) |
| + } |
| + if err := wire.ValidTasteAnswer(&wire.TasteAnswer{}); err != nil { |
| + t.Fatalf("an empty answer refused: %v", err) |
| + } |
| + if err := wire.ValidTasteAnswer(nil); err != nil { |
| + t.Fatalf("no answer refused: %v", err) |
| + } |
| + for name, a := range map[string]wire.TasteAnswer{ |
| + "six feels": {Feels: []string{"A", "B", "C", "D", "E", "F"}}, |
| + "31-byte feel": {Feels: []string{strings.Repeat("a", wire.MaxFeel+1)}}, |
| + "markup feel": {Feels: []string{"<b>Calm</b>"}}, |
| + "empty feel": {Feels: []string{""}}, |
| + "same feel": {Feels: []string{"Calm", "calm"}}, |
| + "301-char box": {Like: strings.Repeat("é", wire.MaxTasteBox+1)}, |
| + "NUL in a box": {Avoid: "a\x00b"}, |
| + "invalid utf-8": {Keep: "a\xffb"}, |
| + "long other": {Other: strings.Repeat("a", wire.MaxTasteBox+1)}, |
| + } { |
| + if err := wire.ValidTasteAnswer(&a); !errors.Is(err, wire.ErrStrict) { |
| + t.Fatalf("%s: %v", name, err) |
| + } |
| + } |
| + if err := wire.ValidFeels([]string{"Calm", "Warm"}); err != nil { |
| + t.Fatalf("feels refused: %v", err) |
| + } |
| + if err := wire.ValidFeels([]string{"A", "B", "C", "D", "E", "F"}); !errors.Is(err, wire.ErrStrict) { |
| + t.Fatalf("six feels: %v", err) |
| + } |
| +} |
| + |
| +// feedbackDispatch is a Design dispatch at 39 with taste and an ask. |
| +func feedbackDispatch() wire.DispatchCommand { |
| + d := designDispatch() |
| + d.Explore = true |
| + d.Taste = []wire.TasteNote{{ID: "tn_1", Source: wire.TasteSourceWords, Scope: wire.TasteScopeProject, Body: "Warm and quiet.", Date: "2026-11-30"}, {ID: "tn_2", Source: wire.TasteSourceChoice, Scope: wire.TasteScopeTeam, Body: "Calm", Question: "What feel are you after?", Date: "2026-11-30"}} |
| + d.TasteRevision, d.ForgetRevision = 4, 2 |
| + d.DesignAsk = &wire.DesignAsk{Kind: wire.DesignAskLike, Option: &wire.StepDesignOption{Name: "Writing desk", Direction: "Quiet.", Page: "writing-desk"}, Current: []wire.StepDesignOption{{Name: "Writing desk"}}, Note: "Warmer."} |
| + return d |
| +} |
| + |
| +// TestDowngradeDesignFeedback: below 39 a Design dispatch is refused |
| +// whatever it carries (an older runner would run Design without its |
| +// labels, directions and taste), and so is any dispatch carrying taste, |
| +// a skipped discovery, a round request or a forget revision, and an |
| +// ask_design_taste call; a report's new option and capture fields are |
| +// dropped, and propose_specialist's feels. At 39 all go out whole. |
| +func TestDowngradeDesignFeedback(t *testing.T) { |
| + bare := designDispatch() |
| + asked := designDispatch() |
| + asked.DesignAsk = &wire.DesignAsk{Kind: wire.DesignAskMore} |
| + full := feedbackDispatch() |
| + report := wire.StepReport{TaskID: "tk1", StepID: "s_1", Attempt: 1, State: wire.StepDone, Findings: []wire.Finding{}, Options: exploreOptions()} |
| + ask := wire.ToolCall{TurnID: "t", CallID: "c", Name: wire.ToolAskDesignTaste, Args: []byte(`{"project":"p_xyz567","feels":["Calm"]}`)} |
| + propose := wire.ToolCall{TurnID: "t", CallID: "c", Name: wire.ToolProposeSpecialist, Args: []byte(`{"profile":"design-v1","name":"Design","brief":"b","capabilities":[],"tools":[],"project":"p_xyz567","feels":["Calm","Warm"]}`)} |
| + frames := []wire.Frame{} |
| + for _, b := range []struct { |
| + kind string |
| + body any |
| + }{{wire.FrameDispatch, bare}, {wire.FrameDispatch, asked}, {wire.FrameDispatch, full}, {wire.FrameStep, report}, {wire.FrameToolCall, ask}, {wire.FrameToolCall, propose}} { |
| + f, err := wire.NewFrame("x", b.kind, b.body) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + frames = append(frames, f) |
| + } |
| + for _, f := range frames { |
| + if same, err := wire.Encode(f, wire.ProtocolDesignFeedback); err != nil || !bytes.Equal(same.Data, f.Data) { |
| + t.Fatalf("%s changed at 39: %v", f.Type, err) |
| + } |
| + } |
| + // Refused at 38 and below. |
| + for i, f := range []wire.Frame{frames[0], frames[1], frames[2], frames[4]} { |
| + for _, p := range []int{wire.ProtocolDesign, wire.ProtocolMacEngineering, wire.Protocol2} { |
| + if _, err := wire.Encode(f, p); !errors.Is(err, wire.ErrProtocol) { |
| + t.Fatalf("frame %d (%s) encoded at %d: %v", i, f.Data, p, err) |
| + } |
| + } |
| + } |
| + // Each new dispatch field alone refuses even a dispatch with no |
| + // binding: no runner below 39 has words for it. |
| + for name, mutate := range map[string]func(*wire.DispatchCommand){ |
| + "taste": func(d *wire.DispatchCommand) { d.Taste = []wire.TasteNote{{ID: "tn_1", Body: "x"}} }, |
| + "taste revision": func(d *wire.DispatchCommand) { d.TasteRevision = 1 }, |
| + "taste skipped": func(d *wire.DispatchCommand) { d.TasteSkipped = true }, |
| + "design ask": func(d *wire.DispatchCommand) { d.DesignAsk = &wire.DesignAsk{Kind: wire.DesignAskMore} }, |
| + "forget revision": func(d *wire.DispatchCommand) { d.ForgetRevision = 1 }, |
| + "design profile": func(d *wire.DispatchCommand) { d.Profile = specialist.ProfileDesign }, |
| + } { |
| + d := wire.DispatchCommand{Person: "owner@example.com", TaskID: "tk1", StepID: "s_1", Attempt: 1, Specialist: wire.SpecialistEngineering, Findings: []wire.Finding{}} |
| + mutate(&d) |
| + f, _ := wire.NewFrame("d", wire.FrameDispatch, d) |
| + if _, err := wire.Encode(f, wire.ProtocolDesign); !errors.Is(err, wire.ErrProtocol) { |
| + t.Fatalf("a dispatch with only its %s at 38: %v", name, err) |
| + } |
| + } |
| + // A Research binding and plain Engineering go out at 38 as before. |
| + research := designDispatch() |
| + research.Profile, research.Capabilities, research.SpecialistProject = "research-v1", []string{"web.research"}, "" |
| + eng := wire.DispatchCommand{Person: "owner@example.com", TaskID: "tk1", StepID: "s_1", Attempt: 1, Specialist: wire.SpecialistEngineering, Findings: []wire.Finding{}} |
| + for _, d := range []wire.DispatchCommand{research, eng} { |
| + f, _ := wire.NewFrame("d", wire.FrameDispatch, d) |
| + if same, err := wire.Encode(f, wire.ProtocolDesign); err != nil || !bytes.Equal(same.Data, f.Data) { |
| + t.Fatalf("%s changed at 38: %v", f.Data, err) |
| + } |
| + } |
| + // A report keeps its names and captures at 38 and loses the rest. |
| + got, err := wire.Encode(frames[3], wire.ProtocolDesign) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, s := range []string{`"direction"`, `"page"`, `"label"`, `"viewport"`, `"path"`, `"full_page"`} { |
| + if strings.Contains(string(got.Data), s) { |
| + t.Fatalf("%s at 38: %s", s, got.Data) |
| + } |
| + } |
| + var back wire.StepReport |
| + if err := wire.Strict(got.Data, &back); err != nil || len(back.Options) != 3 || back.Options[2].Name != "Field notes" || len(back.Options[2].Captures) != 3 || back.Options[2].Captures[2].ID != "3-work-3.png" || back.Options[2].Captures[2].TreeDigest != sum('b') { |
| + t.Fatalf("a report at 38: %+v %v", back, err) |
| + } |
| + if err := wire.ValidOptions(back.Options); err != nil { |
| + t.Fatalf("a downgraded report breaks the old rules: %v", err) |
| + } |
| + // An old report (no new fields) is untouched at 38. |
| + old, _ := wire.NewFrame("r", wire.FrameStep, wire.StepReport{TaskID: "tk1", StepID: "s_1", Attempt: 1, State: wire.StepDone, Findings: []wire.Finding{}, Options: designOptions()}) |
| + if same, err := wire.Encode(old, wire.ProtocolDesign); err != nil || !bytes.Equal(same.Data, old.Data) { |
| + t.Fatalf("an old report changed at 38: %v", err) |
| + } |
| + // propose_specialist loses its feels at 38 and keeps the rest. |
| + got, err = wire.Encode(frames[5], wire.ProtocolDesign) |
| + if err != nil || strings.Contains(string(got.Data), "feels") || !strings.Contains(string(got.Data), `p_xyz567`) { |
| + t.Fatalf("a proposal with feels at 38: %s %v", got.Data, err) |
| + } |
| + // Below 38 too, where the older downgrade has nothing to drop. |
| + team, _ := wire.NewFrame("t", wire.FrameToolCall, wire.ToolCall{TurnID: "t", CallID: "c", Name: wire.ToolProposeSpecialist, Args: []byte(`{"profile":"research-v1","name":"Research","brief":"b","capabilities":[],"tools":[],"feels":["Calm"]}`)}) |
| + got, err = wire.Encode(team, wire.ProtocolMacEngineering) |
| + if err != nil || strings.Contains(string(got.Data), "feels") || !strings.Contains(string(got.Data), `research-v1`) { |
| + t.Fatalf("a proposal with feels at 37: %s %v", got.Data, err) |
| + } |
| +} |
| + |
| +// TestDesignFeedbackRoundTrip: each new field survives the wire exactly |
| +// (strict decode on the far side), with the names the spec gives them, |
| +// and none is on the wire when absent. |
| +func TestDesignFeedbackRoundTrip(t *testing.T) { |
| + for _, c := range []struct { |
| + kind string |
| + body any |
| + want []string |
| + }{ |
| + {wire.FrameDispatch, feedbackDispatch(), []string{`"taste":[{"id":"tn_1","source":"words","scope":"project","body":"Warm and quiet.","date":"2026-11-30"}`, `"question":"What feel are you after?"`, `"taste_revision":4`, `"forget_revision":2`, `"design_ask":{"kind":"like","option":{"name":"Writing desk","direction":"Quiet.","page":"writing-desk"`, `"current":[`, `"note":"Warmer."`}}, |
| + {wire.FrameStep, wire.StepReport{TaskID: "tk1", StepID: "s_1", Attempt: 1, State: wire.StepDone, Findings: []wire.Finding{}, Options: exploreOptions()}, []string{`"direction":"A quiet serif page`, `"page":"writing-desk"`, `"label":"Dashboard","viewport":"desktop","path":"/mockups/tk1/writing-desk/","full_page":true`}}, |
| + } { |
| + f, err := wire.NewFrame("x", c.kind, c.body) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + raw, _ := json.Marshal(f) |
| + g, body, err := wire.ParseFrame(raw) |
| + if err != nil { |
| + t.Fatalf("%s: %v", c.kind, err) |
| + } |
| + again, _ := json.Marshal(body) |
| + if !bytes.Equal(again, g.Data) { |
| + t.Fatalf("%s did not round trip:\n%s\n%s", c.kind, again, g.Data) |
| + } |
| + for _, w := range c.want { |
| + if !strings.Contains(string(g.Data), w) { |
| + t.Fatalf("%s lacks %s: %s", c.kind, w, g.Data) |
| + } |
| + } |
| + } |
| + skipped := designDispatch() |
| + skipped.TasteSkipped = true |
| + f, _ := wire.NewFrame("s", wire.FrameDispatch, skipped) |
| + if !strings.Contains(string(f.Data), `"taste_skipped":true`) { |
| + t.Fatalf("skipped: %s", f.Data) |
| + } |
| + plain, _ := wire.NewFrame("e", wire.FrameDispatch, designDispatch()) |
| + for _, s := range []string{`taste`, `design_ask`, `forget_revision`} { |
| + if strings.Contains(string(plain.Data), s) { |
| + t.Fatalf("an empty %s on the wire: %s", s, plain.Data) |
| + } |
| + } |
| + // The card answer's option and taste, and the direction's rounds. |
| + var answer wire.AnswerCard |
| + if err := wire.Strict([]byte(`{"choice":"like","revision":3,"option":{"step":"s_1","index":2},"note":"Warmer."}`), &answer); err != nil || answer.Option == nil || answer.Option.Step != "s_1" || answer.Option.Index != 2 || answer.Choice != wire.ChoiceLike { |
| + t.Fatalf("option answer: %+v %v", answer, err) |
| + } |
| + answer = wire.AnswerCard{} |
| + if err := wire.Strict([]byte(`{"choice":"use","revision":1,"taste":{"feels":["Calm"],"other":"o","like":"l","avoid":"a","keep":"k"}}`), &answer); err != nil || answer.Taste == nil || !slices.Equal(answer.Taste.Feels, []string{"Calm"}) || answer.Taste.Other != "o" || answer.Taste.Like != "l" || answer.Taste.Avoid != "a" || answer.Taste.Keep != "k" { |
| + t.Fatalf("taste answer: %+v %v", answer, err) |
| + } |
| + if raw, _ := json.Marshal(wire.AnswerCard{Choice: "build", Revision: 1}); strings.Contains(string(raw), "option") || strings.Contains(string(raw), "taste") { |
| + t.Fatalf("an empty answer: %s", raw) |
| + } |
| + dir := wire.TaskDirection{BranchURL: "b", PreviewRefused: true, Rounds: []wire.DirectionRound{{Step: "s_2", Candidate: sum('c'), Options: []wire.StepDesignOption{{Name: "A", Direction: "d", Page: "a", Captures: []wire.StepCapture{{ID: "f1", CaptureID: "1-work-1.png", Label: "Home", Viewport: "phone", Path: "/a/", FullPage: true}}}}, Live: true}}} |
| + raw, _ := json.Marshal(dir) |
| + for _, w := range []string{`"preview_refused":true`, `"rounds":[{"step":"s_2","candidate":"` + sum('c') + `","options":[{"name":"A","direction":"d","page":"a","captures":[{"id":"f1","capture_id":"1-work-1.png","size":0,"width":0,"height":0,"label":"Home","viewport":"phone","path":"/a/","full_page":true}]}],"live":true}]`} { |
| + if !strings.Contains(string(raw), w) { |
| + t.Fatalf("direction lacks %s: %s", w, raw) |
| + } |
| + } |
| + if raw, _ := json.Marshal(wire.TaskDirection{BranchURL: "b"}); strings.Contains(string(raw), "rounds") || strings.Contains(string(raw), "preview_refused") { |
| + t.Fatalf("an empty direction: %s", raw) |
| + } |
| +} |
diff --git a/internal/wire/design_test.go b/internal/wire/design_test.go| index 711f4c18..55e85654 100644 |
| --- a/internal/wire/design_test.go |
| +++ b/internal/wire/design_test.go |
| @@ -33,17 +33,18 @@ func renderFile() wire.RenderFile { |
| return wire.RenderFile{TaskID: "tk1", StepID: "s_1", Attempt: 1, CaptureID: "1-work-1.png", Index: 0, Total: 1, Size: 3, SHA256: sum('a'), Data: "YWJj"} |
| } |
| -// TestProtocol38Design: protocol 38 is the Design specialist's and the |
| -// current one. |
| +// TestProtocol38Design: protocol 38 is the Design specialist's; Design |
| +// feedback's 39 is the current one. |
| func TestProtocol38Design(t *testing.T) { |
| - if wire.Protocol38 != 38 || wire.ProtocolDesign != wire.Protocol38 || wire.ProtocolCurrent != wire.ProtocolDesign || wire.Spoken(99) != 38 || wire.ProtocolMacEngineering != 37 { |
| + if wire.Protocol38 != 38 || wire.ProtocolDesign != wire.Protocol38 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback || wire.Spoken(99) != 39 || wire.ProtocolMacEngineering != 37 { |
| t.Fatalf("design %d, current %d, spoken %d", wire.ProtocolDesign, wire.ProtocolCurrent, wire.Spoken(99)) |
| } |
| } |
| -// TestEncodeBelowProtocol38RefusesDesign: at 38 a bound dispatch, a |
| -// render lease check, a render_file chunk, a report's options and a |
| -// project-scoped proposal go out whole. Below it a dispatch carrying any |
| +// TestEncodeBelowProtocol38RefusesDesign: at 38 a render lease check, a |
| +// render_file chunk, a report's options and a project-scoped proposal go |
| +// out whole, and a Design dispatch at 39 (below 39 it is refused: |
| +// TestDowngradeDesignFeedback). Below it a dispatch carrying any |
| // part of a specialist binding, a render check, a render_file chunk and |
| // a proposal for one project are refused (an older runner would run a |
| // Design step as plain Engineering, an older instance would grant a |
| @@ -56,11 +57,14 @@ func TestEncodeBelowProtocol38RefusesDesign(t *testing.T) { |
| report, _ := wire.NewFrame("r", wire.FrameStep, wire.StepReport{TaskID: "tk1", StepID: "s_1", Attempt: 1, State: wire.StepDone, Findings: []wire.Finding{}, Options: designOptions()}) |
| scoped, _ := wire.NewFrame("t", wire.FrameToolCall, wire.ToolCall{TurnID: "t", CallID: "c", Name: wire.ToolProposeSpecialist, Args: []byte(`{"profile":"design-v1","name":"Design","brief":"b","capabilities":[],"tools":[],"project":"p_xyz567"}`)}) |
| team, _ := wire.NewFrame("t", wire.FrameToolCall, wire.ToolCall{TurnID: "t", CallID: "c", Name: wire.ToolProposeSpecialist, Args: []byte(`{"profile":"research-v1","name":"Research","brief":"b","capabilities":[],"tools":[],"project":""}`)}) |
| - for _, f := range []wire.Frame{dispatch, lease, chunk, report, scoped, team} { |
| + for _, f := range []wire.Frame{lease, chunk, report, scoped, team} { |
| if same, err := wire.Encode(f, wire.ProtocolDesign); err != nil || !bytes.Equal(same.Data, f.Data) { |
| t.Fatalf("%s changed at 38: %v", f.Type, err) |
| } |
| } |
| + if same, err := wire.Encode(dispatch, wire.ProtocolDesignFeedback); err != nil || !bytes.Equal(same.Data, dispatch.Data) { |
| + t.Fatalf("a Design dispatch changed at 39: %v", err) |
| + } |
| if !chunk.Durable() { |
| t.Fatal("render_file is not durable") |
| } |
diff --git a/internal/wire/explore.go b/internal/wire/explore.go| index 30b53f7e..c7d57960 100644 |
| --- a/internal/wire/explore.go |
| +++ b/internal/wire/explore.go |
| @@ -27,12 +27,16 @@ const NeedsDirection = "direction" |
| // CardDirection asks the task's creator which direction to take, once per |
| // candidate; its answers are ChoiceBuild, ChoiceAgain (with a note) and |
| -// ChoiceDrop. |
| +// ChoiceDrop, and for a Design exploration (ProtocolDesignFeedback) |
| +// ChoiceMore (a new round of options) and ChoiceLike (variations of the |
| +// option the answer names), each with an optional note. |
| const ( |
| CardDirection = "direction" |
| ChoiceBuild = "build" |
| ChoiceAgain = "again" |
| ChoiceDrop = "drop" |
| + ChoiceMore = "more" |
| + ChoiceLike = "like" |
| ) |
| // MaxDirectionNote bounds Try again's note and Build this's. |
| @@ -42,13 +46,27 @@ const MaxDirectionNote = 1000 |
| // deployed preview, else its branch on Amadan, and whether the primary |
| // said previews are off. Options are what the newest Design attempt kept |
| // (protocol 38), by option; with more than one, NoteNeeded: Build this |
| -// needs the person's note saying which. |
| +// needs the person's note saying which. Rounds are every kept Design |
| +// round of the task, newest first; PreviewRefused, that the preview host |
| +// refused the candidate's preview for its headers. |
| type TaskDirection struct { |
| - PreviewURL string `json:"preview_url,omitempty"` |
| - BranchURL string `json:"branch_url"` |
| - PreviewsOff bool `json:"previews_off,omitempty"` |
| - Options []StepDesignOption `json:"options,omitempty"` |
| - NoteNeeded bool `json:"note_needed,omitempty"` |
| + PreviewURL string `json:"preview_url,omitempty"` |
| + BranchURL string `json:"branch_url"` |
| + PreviewsOff bool `json:"previews_off,omitempty"` |
| + Options []StepDesignOption `json:"options,omitempty"` |
| + NoteNeeded bool `json:"note_needed,omitempty"` |
| + Rounds []DirectionRound `json:"rounds,omitempty"` |
| + PreviewRefused bool `json:"preview_refused,omitempty"` |
| +} |
| + |
| +// DirectionRound is one kept Design round: its maker step, the candidate |
| +// commit its options are built from, the options it kept, and whether |
| +// its candidate is the deployed preview (each option opens live). |
| +type DirectionRound struct { |
| + Step string `json:"step"` |
| + Candidate string `json:"candidate"` |
| + Options []StepDesignOption `json:"options"` |
| + Live bool `json:"live,omitempty"` |
| } |
| // ConflictDirectionNote is the card conflict a Build this without a note |
diff --git a/internal/wire/frames.go b/internal/wire/frames.go| index 6f8c2c30..7eb4dbfa 100644 |
| --- a/internal/wire/frames.go |
| +++ b/internal/wire/frames.go |
| @@ -621,10 +621,15 @@ const ( |
| // writes the desk, then reports the notebook for the owner's view. |
| ToolWriteNote = "write_note" |
| ToolReadNotes = "read_notes" |
| + // ToolAskDesignTaste raises the Design discovery card for a project |
| + // (ProtocolDesignFeedback): args {project, feels}, feels up to |
| + // MaxFeels plain labels the coordinator writes (ValidFeels). Never in |
| + // a continuation. |
| + ToolAskDesignTaste = "ask_design_taste" |
| ) |
| // ConverseTools is the coordinator's tool set in a conversation. |
| -var ConverseTools = []string{ToolRequestAccess, ToolStatus, ToolFind, ToolSearchCode, ToolReadFile, ToolAddProject, ToolCreateProject, ToolSetProjectHome, ToolStarProject, ToolAskPerson, ToolWriteNote, ToolReadNotes, ToolRecordTask, ToolAddFinding, ToolStartTask, ToolReadTask, ToolCancelTask, ToolAddReport, ToolHoldMerge, ToolSetMergePolicy, ToolProposeSpecialist, ToolResearch, ToolOfferRetry, ToolRetryStep, ToolPlaces, ToolProposePlace, ToolPublishSite, ToolSiteStatus} |
| +var ConverseTools = []string{ToolRequestAccess, ToolStatus, ToolFind, ToolSearchCode, ToolReadFile, ToolAddProject, ToolCreateProject, ToolSetProjectHome, ToolStarProject, ToolAskPerson, ToolWriteNote, ToolReadNotes, ToolRecordTask, ToolAddFinding, ToolStartTask, ToolReadTask, ToolCancelTask, ToolAddReport, ToolHoldMerge, ToolSetMergePolicy, ToolProposeSpecialist, ToolResearch, ToolOfferRetry, ToolRetryStep, ToolPlaces, ToolProposePlace, ToolPublishSite, ToolSiteStatus, ToolAskDesignTaste} |
| // MoveInTools are the tools a move_in or explore turn may use: it looks |
| // around and takes notes, and never acts for the person. |
diff --git a/internal/wire/injection_test.go b/internal/wire/injection_test.go| index 1597958f..292ec62a 100644 |
| --- a/internal/wire/injection_test.go |
| +++ b/internal/wire/injection_test.go |
| @@ -7,10 +7,10 @@ import ( |
| ) |
| func TestInjectionProtocolDowngrade(t *testing.T) { |
| - if wire.ProtocolInjectionDefences != 28 || wire.ProtocolCurrent != 38 { |
| + if wire.ProtocolInjectionDefences != 28 || wire.ProtocolCurrent != 39 { |
| t.Fatal("injection guarantees require protocol 28") |
| } |
| - for version, want := range map[int]int{26: 26, 27: 27, 28: 28, 29: 29, 30: 30, 31: 31, 32: 32, 33: 33, 34: 34, 35: 35, 36: 36, 37: 37, 38: 38, 99: 38} { |
| + for version, want := range map[int]int{26: 26, 27: 27, 28: 28, 29: 29, 30: 30, 31: 31, 32: 32, 33: 33, 34: 34, 35: 35, 36: 36, 37: 37, 38: 38, 39: 39, 99: 39} { |
| if got := wire.Spoken(version); got != want { |
| t.Fatalf("negotiated %d as %d, want %d", version, got, want) |
| } |
diff --git a/internal/wire/lookup_test.go b/internal/wire/lookup_test.go| index 824a2661..206b03fe 100644 |
| --- a/internal/wire/lookup_test.go |
| +++ b/internal/wire/lookup_test.go |
| @@ -13,7 +13,7 @@ import ( |
| func TestProtocolLookupIs36(t *testing.T) { |
| // Lookups stay at 36; Mac Engineering is 37 and Design (38) is the |
| // current protocol. |
| - if wire.ProtocolLookup != 36 || wire.ProtocolMacEngineering != 37 || wire.ProtocolCurrent != wire.ProtocolDesign || wire.Spoken(99) != 38 || wire.Spoken(36) != 36 { |
| + if wire.ProtocolLookup != 36 || wire.ProtocolMacEngineering != 37 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback || wire.Spoken(99) != 39 || wire.Spoken(36) != 36 { |
| t.Fatalf("lookup %d current %d", wire.ProtocolLookup, wire.ProtocolCurrent) |
| } |
| } |
diff --git a/internal/wire/mac_engineering_test.go b/internal/wire/mac_engineering_test.go| index 7b9071d5..f6ff73af 100644 |
| --- a/internal/wire/mac_engineering_test.go |
| +++ b/internal/wire/mac_engineering_test.go |
| @@ -18,10 +18,10 @@ import ( |
| // Engineering. The values are written out so that moving a constant |
| // fails here. |
| func TestProtocol37Constants(t *testing.T) { |
| - if wire.Protocol37 != 37 || wire.ProtocolMacEngineering != wire.Protocol37 || wire.ProtocolCurrent != wire.ProtocolDesign || wire.ProtocolChangeDiffs != 35 || wire.ProtocolLookup != 36 { |
| + if wire.Protocol37 != 37 || wire.ProtocolMacEngineering != wire.Protocol37 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback || wire.ProtocolChangeDiffs != 35 || wire.ProtocolLookup != 36 { |
| t.Fatalf("mac engineering %d, current %d", wire.ProtocolMacEngineering, wire.ProtocolCurrent) |
| } |
| - if wire.Spoken(99) != 38 || wire.Spoken(37) != 37 || wire.Spoken(36) != 36 || wire.Spoken(35) != 35 { |
| + if wire.Spoken(99) != 39 || wire.Spoken(37) != 37 || wire.Spoken(36) != 36 || wire.Spoken(35) != 35 { |
| t.Fatal("spoken protocol") |
| } |
| for kind, want := range map[string]bool{wire.FramePrepareBase: true, wire.FrameBase: true} { |
diff --git a/internal/wire/mixed_protocol_test.go b/internal/wire/mixed_protocol_test.go| index 6f9607e0..7910c6bb 100644 |
| --- a/internal/wire/mixed_protocol_test.go |
| +++ b/internal/wire/mixed_protocol_test.go |
| @@ -15,7 +15,7 @@ import ( |
| // both go out whole; at 11 both are downgraded. The numbers are written |
| // out so that pointing ProtocolResearch back at 12 fails here. |
| func TestEncodeMixedMeteredAndResearch(t *testing.T) { |
| - if wire.ProtocolMetered != wire.Protocol12 || wire.ProtocolResearch != wire.Protocol13 || wire.ProtocolCurrent != wire.ProtocolDesign { |
| + if wire.ProtocolMetered != wire.Protocol12 || wire.ProtocolResearch != wire.Protocol13 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback { |
| t.Fatalf("metered %d, research %d, current %d", wire.ProtocolMetered, wire.ProtocolResearch, wire.ProtocolCurrent) |
| } |
| metered := wire.HeldConnection{LocalID: "tensorx-1", Person: "p", Provider: wire.ProviderTensorX, Kind: wire.KindAPIKey, State: wire.ConnHealthy, Harness: wire.HarnessPi, Upstream: "https://api.tensorx.ai", Billing: wire.BillingMetered, Model: "z-ai/glm-5.3", Budget: &wire.Budget{Day: 1, Month: 2, Currency: "USD"}, Spend: &wire.Spend{Currency: "USD"}} |
diff --git a/internal/wire/models_test.go b/internal/wire/models_test.go| index f0a780b5..1c583f48 100644 |
| --- a/internal/wire/models_test.go |
| +++ b/internal/wire/models_test.go |
| @@ -94,7 +94,7 @@ func modelsFrames(t *testing.T) map[string]wire.Frame { |
| // protocol is checked because an older step in Encode's chain could |
| // undo a newer one (S5's bug). |
| func TestEncodeBelowProtocol18AgainstFrozenSchemas(t *testing.T) { |
| - if wire.ProtocolModels != wire.Protocol18 || wire.ProtocolCurrent != wire.ProtocolDesign { |
| + if wire.ProtocolModels != wire.Protocol18 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback { |
| t.Fatalf("models %d, current %d", wire.ProtocolModels, wire.ProtocolCurrent) |
| } |
| fs := modelsFrames(t) |
diff --git a/internal/wire/opencode_test.go b/internal/wire/opencode_test.go| index e3c79938..f81fa7bf 100644 |
| --- a/internal/wire/opencode_test.go |
| +++ b/internal/wire/opencode_test.go |
| @@ -57,7 +57,7 @@ func providersIn(t *testing.T, raw []byte) (providers, harnesses []string) { |
| // leave hello and sync, its usage rows leave every report, and a connect |
| // or a report about one is refused. At 17 nothing changes. |
| func TestEncodeBelowProtocol17DropsOpenCode(t *testing.T) { |
| - if wire.ProtocolOpenCode != wire.Protocol17 || wire.ProtocolCurrent != wire.ProtocolDesign { |
| + if wire.ProtocolOpenCode != wire.Protocol17 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback { |
| t.Fatalf("opencode %d, current %d", wire.ProtocolOpenCode, wire.ProtocolCurrent) |
| } |
| budget := &wire.Budget{Day: 1_000_000, Month: 10_000_000, Currency: "USD", Revision: 1} |
diff --git a/internal/wire/pinned_release_test.go b/internal/wire/pinned_release_test.go| index ab745b47..997988e1 100644 |
| --- a/internal/wire/pinned_release_test.go |
| +++ b/internal/wire/pinned_release_test.go |
| @@ -13,7 +13,7 @@ import ( |
| // carrying a pinned release loses the release and its pin; an unpinned |
| // release is unchanged from protocol 14. |
| func TestEncodePinnedReleaseBelow29(t *testing.T) { |
| - if wire.ProtocolPinnedRelease != wire.Protocol29 || wire.ProtocolCurrent != wire.ProtocolDesign { |
| + if wire.ProtocolPinnedRelease != wire.Protocol29 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback { |
| t.Fatalf("pinned %d, current %d", wire.ProtocolPinnedRelease, wire.ProtocolCurrent) |
| } |
| pinned, err := wire.NewFrame("f1", wire.FrameRelease, wire.ReleaseCommand{ID: "rl_1", Person: "p", TaskID: "tk1", StepID: "s1", StepRevision: 1, Connection: "claude-1"}) |
diff --git a/internal/wire/places_test.go b/internal/wire/places_test.go| index 22d4d758..4196345c 100644 |
| --- a/internal/wire/places_test.go |
| +++ b/internal/wire/places_test.go |
| @@ -22,7 +22,7 @@ func placesHello() wire.Hello { |
| // refused: an older runner would deploy to its own fixed account, an |
| // older instance would decide a check without the destination. |
| func TestEncodeBelowProtocol31DropsPlaces(t *testing.T) { |
| - if wire.ProtocolPlaces != wire.Protocol34 || wire.ProtocolCurrent != wire.ProtocolDesign || wire.Spoken(99) != 38 { |
| + if wire.ProtocolPlaces != wire.Protocol34 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback || wire.Spoken(99) != 39 { |
| t.Fatalf("places %d, current %d", wire.ProtocolPlaces, wire.ProtocolCurrent) |
| } |
| hello := placesHello() |
diff --git a/internal/wire/publish_test.go b/internal/wire/publish_test.go| index a7ceeea3..c1cf827b 100644 |
| --- a/internal/wire/publish_test.go |
| +++ b/internal/wire/publish_test.go |
| @@ -17,7 +17,7 @@ import ( |
| // and a hello's sites capability are dropped, so nothing a protocol 15 |
| // peer decodes strictly carries them. |
| func TestEncodeBelowProtocol16DropsPublish(t *testing.T) { |
| - if wire.ProtocolPublish != wire.Protocol16 || wire.ProtocolCurrent != wire.ProtocolDesign { |
| + if wire.ProtocolPublish != wire.Protocol16 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback { |
| t.Fatalf("publish %d, current %d", wire.ProtocolPublish, wire.ProtocolCurrent) |
| } |
| publish := wire.DispatchCommand{Person: "p", TaskID: "tk", StepID: "s", Attempt: 1, Specialist: wire.SpecialistPublish, Findings: []wire.Finding{}, CandidateSHA: strings.Repeat("e", 40), Publish: &wire.PublishDispatch{App: "site-sample", Into: "main"}} |
diff --git a/internal/wire/runners.go b/internal/wire/runners.go| index 7de374b5..c70965df 100644 |
| --- a/internal/wire/runners.go |
| +++ b/internal/wire/runners.go |
| @@ -64,6 +64,7 @@ const ( |
| Protocol36 = 36 |
| Protocol37 = 37 |
| Protocol38 = 38 |
| + Protocol39 = 39 |
| // ProtocolSpend is the first protocol with a fix round's Feedback and |
| // a usage row's Turns; Encode drops both below it. |
| ProtocolSpend = Protocol3 |
| @@ -251,8 +252,17 @@ const ( |
| // it Encode refuses a bound dispatch, a render check, a render_file |
| // chunk and a proposal for one project, and drops a report's options |
| // and render records and a proposal's empty project (downgradeDesign). |
| - ProtocolDesign = Protocol38 |
| - ProtocolCurrent = ProtocolDesign |
| + ProtocolDesign = Protocol38 |
| + // ProtocolDesignFeedback adds Design feedback (spec |
| + // 2026-11-28-dynamic-specialists.md, section 8): a Design report's |
| + // option directions and pages and its captures' labels and render |
| + // facts, and a dispatch's taste notes, their revisions, a skipped |
| + // discovery and a round request. A Design step needs it: below it |
| + // Encode refuses a design-v1 dispatch, any dispatch with those fields |
| + // and an ask_design_taste call, and drops a report's new fields and |
| + // propose_specialist's feels (downgradeDesignFeedback). |
| + ProtocolDesignFeedback = Protocol39 |
| + ProtocolCurrent = ProtocolDesignFeedback |
| ) |
| // Runner roles. A person's first runner is the primary: the coordinator, |
| @@ -766,7 +776,11 @@ var ErrProtocol = errors.New("wire: frame not in this protocol") |
| // slice F's fields dropped (downgradeMacEngineering). Below ProtocolDesign |
| // a bound dispatch, a render check, a render_file chunk and a proposal |
| // for one project are refused and a report's options and render records |
| -// dropped (downgradeDesign). |
| +// dropped (downgradeDesign). Below ProtocolDesignFeedback a Design |
| +// dispatch, a dispatch with taste or a round request and an |
| +// ask_design_taste call are refused, and a report's directions, pages, |
| +// labels and render facts and a proposal's feels dropped |
| +// (downgradeDesignFeedback). |
| func Encode(f Frame, protocol int) (Frame, error) { |
| if protocol >= ProtocolCurrent { |
| return f, nil |
| @@ -791,12 +805,19 @@ func Encode(f Frame, protocol int) (Frame, error) { |
| return Frame{}, fmt.Errorf("%w: %s at protocol %d", ErrProtocol, f.Type, protocol) |
| } |
| changed := false |
| + if protocol < ProtocolDesignFeedback { |
| + dropped, err := downgradeDesignFeedback(body, protocol) |
| + if err != nil { |
| + return Frame{}, err |
| + } |
| + changed = dropped |
| + } |
| if protocol < ProtocolDesign { |
| dropped, err := downgradeDesign(body, protocol) |
| if err != nil { |
| return Frame{}, err |
| } |
| - changed = dropped |
| + changed = dropped || changed |
| } |
| if protocol < ProtocolMacEngineering { |
| dropped, err := downgradeMacEngineering(body, protocol) |
diff --git a/internal/wire/runners_test.go b/internal/wire/runners_test.go| index a3f4ccb2..03ef17b3 100644 |
| --- a/internal/wire/runners_test.go |
| +++ b/internal/wire/runners_test.go |
| @@ -413,7 +413,7 @@ func TestEncodeBelowProtocol9DropsPreviews(t *testing.T) { |
| if _, err := wire.Encode(d, wire.ProtocolPreview); err != nil { |
| t.Fatal(err) |
| } |
| - if wire.ProtocolCurrent != wire.ProtocolDesign || wire.ProtocolDesign != 38 || wire.ProtocolMacEngineering != 37 || wire.ProtocolLookup != 36 || wire.ProtocolChangeDiffs != 35 || wire.ProtocolPlaces != 34 || wire.ProtocolAssistantFiles != 33 || wire.ProtocolStuckTasks != 30 || wire.ProtocolPinnedRelease != 29 || wire.ProtocolInjectionDefences != 28 || wire.ProtocolWarm != 24 || wire.ProtocolGlance != 23 || wire.ProtocolJobs != 22 || wire.ProtocolCopy != 21 || wire.ProtocolUsageRefresh != 20 || wire.ProtocolAssistant != 19 || wire.ProtocolModels != 18 || wire.ProtocolOpenCode != 17 || wire.ProtocolPublish != 16 || wire.ProtocolReadings != 15 || wire.ProtocolScheduler != 14 || wire.ProtocolResearch != 13 || wire.ProtocolMetered != 12 || wire.ProtocolPreviewHost != 11 || wire.ProtocolExplore != 10 || wire.ProtocolPreview != 9 { |
| + if wire.ProtocolCurrent != wire.ProtocolDesignFeedback || wire.ProtocolDesignFeedback != 39 || wire.ProtocolDesign != 38 || wire.ProtocolMacEngineering != 37 || wire.ProtocolLookup != 36 || wire.ProtocolChangeDiffs != 35 || wire.ProtocolPlaces != 34 || wire.ProtocolAssistantFiles != 33 || wire.ProtocolStuckTasks != 30 || wire.ProtocolPinnedRelease != 29 || wire.ProtocolInjectionDefences != 28 || wire.ProtocolWarm != 24 || wire.ProtocolGlance != 23 || wire.ProtocolJobs != 22 || wire.ProtocolCopy != 21 || wire.ProtocolUsageRefresh != 20 || wire.ProtocolAssistant != 19 || wire.ProtocolModels != 18 || wire.ProtocolOpenCode != 17 || wire.ProtocolPublish != 16 || wire.ProtocolReadings != 15 || wire.ProtocolScheduler != 14 || wire.ProtocolResearch != 13 || wire.ProtocolMetered != 12 || wire.ProtocolPreviewHost != 11 || wire.ProtocolExplore != 10 || wire.ProtocolPreview != 9 { |
| t.Fatalf("current %d", wire.ProtocolCurrent) |
| } |
| } |
diff --git a/internal/wire/schedule_test.go b/internal/wire/schedule_test.go| index c0b1f260..554d3d68 100644 |
| --- a/internal/wire/schedule_test.go |
| +++ b/internal/wire/schedule_test.go |
| @@ -17,7 +17,7 @@ import ( |
| // refused anything that spends, never handed it), and a dispatch loses |
| // its priority, deadline and release; what 13 already had is unchanged. |
| func TestEncodeBelowProtocol14DropsScheduler(t *testing.T) { |
| - if wire.ProtocolScheduler != wire.Protocol14 || wire.ProtocolCurrent != wire.ProtocolDesign { |
| + if wire.ProtocolScheduler != wire.Protocol14 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback { |
| t.Fatalf("scheduler %d, current %d", wire.ProtocolScheduler, wire.ProtocolCurrent) |
| } |
| by := time.Date(2026, 11, 20, 17, 0, 0, 0, time.UTC) |
diff --git a/internal/wire/stuck_test.go b/internal/wire/stuck_test.go| index 398ae11d..5c10587e 100644 |
| --- a/internal/wire/stuck_test.go |
| +++ b/internal/wire/stuck_test.go |
| @@ -14,7 +14,7 @@ import ( |
| // Stuck tasks (protocol 30): a hello's tool health is a fixed state per |
| // pinned tool, never a path, and an older instance never hears it. |
| func TestProtocol30ToolHealth(t *testing.T) { |
| - if wire.ProtocolStuckTasks != wire.Protocol30 || wire.ProtocolCurrent != wire.ProtocolDesign || wire.Spoken(99) != 38 { |
| + if wire.ProtocolStuckTasks != wire.Protocol30 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback || wire.Spoken(99) != 39 { |
| t.Fatalf("stuck %d, current %d", wire.ProtocolStuckTasks, wire.ProtocolCurrent) |
| } |
| caps := func(h *wire.ToolHealth) wire.Capabilities { |
diff --git a/internal/wire/tasks.go b/internal/wire/tasks.go| index 85641614..3e29fdc9 100644 |
| --- a/internal/wire/tasks.go |
| +++ b/internal/wire/tasks.go |
| @@ -813,6 +813,19 @@ type DispatchCommand struct { |
| // MaxSpecialistBrief bytes), for the maker's prompt. |
| Explore bool `json:"explore,omitempty"` |
| SpecialistBrief string `json:"specialist_brief,omitempty"` |
| + // ProtocolDesignFeedback, a Design step's only: Taste is the task |
| + // creator's design notes for the prompt (project first, then the |
| + // team's, newest first), TasteRevision their notebook revision, |
| + // TasteSkipped that they skipped discovery, DesignAsk the round's |
| + // request (More options or More like this, inherited by its fix |
| + // rounds), and ForgetRevision the notebook's forget revision: the |
| + // runner resumes a saved session only at the same one. Encode |
| + // refuses a dispatch carrying any of them below it. |
| + Taste []TasteNote `json:"taste,omitempty"` |
| + TasteRevision int64 `json:"taste_revision,omitempty"` |
| + TasteSkipped bool `json:"taste_skipped,omitempty"` |
| + DesignAsk *DesignAsk `json:"design_ask,omitempty"` |
| + ForgetRevision int64 `json:"forget_revision,omitempty"` |
| } |
| // WatchMergeCommand watches a task's branch for its candidate landing on |
| @@ -941,8 +954,11 @@ type StepReport struct { |
| SessionID string `json:"session_id,omitempty"` |
| OutcomePhase string `json:"outcome_phase,omitempty"` |
| // ProtocolDesign. Options are a Design step's mockup options and the |
| - // captures it names for each (ValidOptions); their bytes travel |
| - // first, in render_file frames. Encode drops them below it. |
| + // captures it names for each (ValidOptions; ValidOptions39 and |
| + // ValidExploreOptions from ProtocolDesignFeedback); their bytes |
| + // travel first, in render_file frames. Encode drops them below it, |
| + // and their directions, pages, labels and render facts below |
| + // ProtocolDesignFeedback. |
| Options []DesignOption `json:"options,omitempty"` |
| // ProtocolDesign. Renders are a Design step's render_page calls |
| // (ValidRenderAudits), on its final report. Encode drops them below |
diff --git a/internal/wire/usage_test.go b/internal/wire/usage_test.go| index 4026a092..2f26b14a 100644 |
| --- a/internal/wire/usage_test.go |
| +++ b/internal/wire/usage_test.go |
| @@ -44,7 +44,7 @@ func headrooms(t *testing.T, raw []byte) []map[string]json.RawMessage { |
| // decodes strictly against the frozen protocol 14 headroom, and the |
| // caller's own values are untouched; at 15 nothing changes. |
| func TestEncodeBelowProtocol15DropsReadingTimes(t *testing.T) { |
| - if wire.ProtocolReadings != wire.Protocol15 || wire.ProtocolCurrent != wire.ProtocolDesign { |
| + if wire.ProtocolReadings != wire.Protocol15 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback { |
| t.Fatalf("readings %d, current %d", wire.ProtocolReadings, wire.ProtocolCurrent) |
| } |
| at := time.Date(2026, 11, 12, 9, 58, 0, 0, time.UTC) |
diff --git a/internal/wire/warm_test.go b/internal/wire/warm_test.go| index dfde3f8a..909c9132 100644 |
| --- a/internal/wire/warm_test.go |
| +++ b/internal/wire/warm_test.go |
| @@ -13,7 +13,7 @@ import ( |
| // other (durable, acked), and Encode refuses it below 24: an older |
| // runner's strict decoder would close the stream on it. |
| func TestEncodeWarmBelow24(t *testing.T) { |
| - if wire.ProtocolWarm != 24 || wire.ProtocolCurrent != wire.ProtocolDesign || wire.Spoken(99) != 38 { |
| + if wire.ProtocolWarm != 24 || wire.ProtocolCurrent != wire.ProtocolDesignFeedback || wire.Spoken(99) != 39 { |
| t.Fatalf("protocols %d %d", wire.ProtocolWarm, wire.ProtocolCurrent) |
| } |
| f, err := wire.NewFrame("c1", wire.FrameWarm, wire.WarmCommand{Person: "ana@example.com"}) |