wire: protocol 36, live-only lookup frames, lookups on a message
Task 3.4, renumbered: main took 34 (places) and 35 (diffs), so ProtocolLookup is 36 and current. lookup_step and lookup_result decode strictly, are not durable, and are refused below 36. The pack, results, pages and bounds; ValidQueryResult and ValidAnswerResult. wire.Message gains Lookups (answer and sources), documented in the OpenAPI document.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
24 files changed,
+362
−40
docs/api/equipo-v1.openapi.json+74 −21internal/wire/api.go+4 −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/frames.go+4 −0internal/wire/injection_test.go+2 −2internal/wire/lookup.go+145 −0internal/wire/lookup_test.go+106 −0internal/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+10 −2internal/wire/runners_test.go+1 −1internal/wire/schedule_test.go+1 −1internal/wire/stuck_test.go+1 −1internal/wire/usage_test.go+1 −1internal/wire/warm_test.go+1 −1internal/wire/wiretest/testdata/frames/lookup-result.json+1 −0internal/wire/wiretest/testdata/frames/lookup-step.json+1 −0
diff --git a/docs/api/equipo-v1.openapi.json b/docs/api/equipo-v1.openapi.json| index 36c40835..6d43934a 100644 |
| --- a/docs/api/equipo-v1.openapi.json |
| +++ b/docs/api/equipo-v1.openapi.json |
| @@ -18076,6 +18076,13 @@ |
| "items": { |
| "$ref": "#/components/schemas/MessageAttachment" |
| } |
| + }, |
| + "lookups": { |
| + "items": { |
| + "$ref": "#/components/schemas/AssistantLookup" |
| + }, |
| + "maxItems": 2, |
| + "type": "array" |
| } |
| }, |
| "required": [ |
| @@ -20807,36 +20814,42 @@ |
| "x-go-type": "wire.Merged" |
| }, |
| "Message": { |
| - "type": "object", |
| + "additionalProperties": false, |
| "properties": { |
| - "project_id": { |
| + "attachments": { |
| + "items": { |
| + "$ref": "#/components/schemas/MessageAttachment" |
| + }, |
| + "type": "array" |
| + }, |
| + "created_at": { |
| + "format": "date-time", |
| "type": "string" |
| }, |
| "id": { |
| "type": "string" |
| }, |
| + "lookups": { |
| + "items": { |
| + "$ref": "#/components/schemas/AssistantLookup" |
| + }, |
| + "type": "array" |
| + }, |
| + "project_id": { |
| + "type": "string" |
| + }, |
| "revision": { |
| - "type": "integer", |
| - "format": "int64" |
| + "format": "int64", |
| + "type": "integer" |
| }, |
| "role": { |
| - "type": "string", |
| "enum": [ |
| "", |
| "person", |
| "coordinator" |
| - ] |
| - }, |
| - "text": { |
| - "type": "string" |
| - }, |
| - "turn_id": { |
| + ], |
| "type": "string" |
| }, |
| - "created_at": { |
| - "type": "string", |
| - "format": "date-time" |
| - }, |
| "switched": { |
| "anyOf": [ |
| { |
| @@ -20847,11 +20860,11 @@ |
| } |
| ] |
| }, |
| - "attachments": { |
| - "type": "array", |
| - "items": { |
| - "$ref": "#/components/schemas/MessageAttachment" |
| - } |
| + "text": { |
| + "type": "string" |
| + }, |
| + "turn_id": { |
| + "type": "string" |
| } |
| }, |
| "required": [ |
| @@ -20863,7 +20876,7 @@ |
| "created_at", |
| "switched" |
| ], |
| - "additionalProperties": false, |
| + "type": "object", |
| "x-go-type": "wire.Message" |
| }, |
| "MessageAttachment": { |
| @@ -25090,6 +25103,46 @@ |
| "revision" |
| ], |
| "additionalProperties": false |
| + }, |
| + "AssistantLookup": { |
| + "additionalProperties": false, |
| + "properties": { |
| + "answer": { |
| + "type": "string" |
| + }, |
| + "sources": { |
| + "items": { |
| + "$ref": "#/components/schemas/LookupSource" |
| + }, |
| + "type": [ |
| + "array", |
| + "null" |
| + ] |
| + } |
| + }, |
| + "required": [ |
| + "answer", |
| + "sources" |
| + ], |
| + "type": "object", |
| + "x-go-type": "wire.AssistantLookup" |
| + }, |
| + "LookupSource": { |
| + "additionalProperties": false, |
| + "properties": { |
| + "title": { |
| + "type": "string" |
| + }, |
| + "url": { |
| + "type": "string" |
| + } |
| + }, |
| + "required": [ |
| + "url", |
| + "title" |
| + ], |
| + "type": "object", |
| + "x-go-type": "wire.LookupSource" |
| } |
| }, |
| "responses": { |
diff --git a/internal/wire/api.go b/internal/wire/api.go| index 77c09cc8..10c95aa8 100644 |
| --- a/internal/wire/api.go |
| +++ b/internal/wire/api.go |
| @@ -176,6 +176,10 @@ type Message struct { |
| // Attachments are the images and files sent with a person's message, |
| // in the order they were attached; omitted when there are none. |
| Attachments []MessageAttachment `json:"attachments,omitempty"` |
| + // Lookups are the answers and sources shown under an Assistant reply, |
| + // in call order, at most MaxLookupsPerReply; omitted when there are |
| + // none (spec 2026-11-26-assistant-abilities §4.6). |
| + Lookups []AssistantLookup `json:"lookups,omitempty"` |
| } |
| // MessageAttachment is an image or file the person uploaded (POST |
diff --git a/internal/wire/assistant_files_test.go b/internal/wire/assistant_files_test.go| index d16cd3fe..418ea6bb 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.ProtocolChangeDiffs || wire.Spoken(99) != 35 { |
| + if wire.Protocol33 != 33 || wire.ProtocolAssistantFiles != wire.Protocol33 || wire.ProtocolUnfinishedWork != wire.Protocol32 || wire.ProtocolCurrent != wire.ProtocolLookup || wire.Spoken(99) != 36 { |
| 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 5835cc3c..78a13638 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) != 35 || wire.ProtocolCurrent != wire.ProtocolChangeDiffs || 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) != 36 || wire.ProtocolCurrent != wire.ProtocolLookup || 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 be98e166..953a57e7 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 != 35 { |
| + if wire.ProtocolChangeDiffs != 35 || wire.ProtocolCurrent != 36 { |
| 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 d4f39ae3..431d80e9 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 != 35 { |
| + if wire.ProtocolChangeFiles != 31 || wire.ProtocolCurrent != 36 { |
| 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/frames.go b/internal/wire/frames.go| index 674739df..4fb41db4 100644 |
| --- a/internal/wire/frames.go |
| +++ b/internal/wire/frames.go |
| @@ -186,6 +186,10 @@ func (f Frame) Decode() (any, error) { |
| v = &Refused{} |
| case FrameChangeDiff: |
| v = &ChangeDiffUpload{} |
| + case FrameLookupStep: |
| + v = &LookupStep{} |
| + case FrameLookupResult: |
| + v = &LookupResult{} |
| case FrameResearchFile: |
| v = &ResearchFile{} |
| case FrameRelease: |
diff --git a/internal/wire/injection_test.go b/internal/wire/injection_test.go| index f6ff8397..aafd57d5 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 != 35 { |
| + if wire.ProtocolInjectionDefences != 28 || wire.ProtocolCurrent != 36 { |
| 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, 99: 35} { |
| + 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, 99: 36} { |
| if got := wire.Spoken(version); got != want { |
| t.Fatalf("negotiated %d as %d, want %d", version, got, want) |
| } |
diff --git a/internal/wire/lookup.go b/internal/wire/lookup.go| new file mode 100644 |
| index 00000000..1a00cef6 |
| --- /dev/null |
| +++ b/internal/wire/lookup.go |
| @@ -0,0 +1,145 @@ |
| +package wire |
| + |
| +import ( |
| + "errors" |
| + "unicode/utf8" |
| +) |
| + |
| +// Lookups (spec 2026-11-26-assistant-abilities §4.2): the instance asks |
| +// the person's runner for two isolated model steps, the query and the |
| +// answer, over a live-only channel. Neither frame is durable: nothing is |
| +// written to runner_commands, acked or resent; an answer is accepted only |
| +// for the lookup's current attempt and nonce. |
| +const ( |
| + // FrameLookupStep is instance to runner, live only. |
| + FrameLookupStep = "lookup_step" |
| + // FrameLookupResult is runner to instance, live only. |
| + FrameLookupResult = "lookup_result" |
| +) |
| + |
| +// The two stages. |
| +const ( |
| + LookupStageQuery = "query" |
| + LookupStageAnswer = "answer" |
| +) |
| + |
| +// Bounds on a lookup's frames and results. |
| +const ( |
| + MaxLookupPack = 4 << 10 |
| + MaxLookupStepBytes = 56 << 10 |
| + MaxLookupAnswer = 1200 |
| + MaxLookupQueries = 2 |
| + MaxLookupQuery = 200 |
| + MaxLookupSources = 5 |
| + MaxLookupsPerReply = 2 |
| +) |
| + |
| +// LookupPack is what the query writer sees (§4.2 step 1): the person's |
| +// question now, the lookup questions it follows on from (newest first), |
| +// their zone's city and today's date there. |
| +type LookupPack struct { |
| + Question string `json:"question"` |
| + Earlier []string `json:"earlier,omitempty"` |
| + City string `json:"city,omitempty"` |
| + Date string `json:"date"` |
| +} |
| + |
| +// SearchResult is one search result as the answer step reads it. |
| +type SearchResult struct { |
| + Title string `json:"title"` |
| + URL string `json:"url"` |
| + Snippet string `json:"snippet"` |
| + Date string `json:"date"` |
| +} |
| + |
| +// LookupPage is one page read, as readable text. |
| +type LookupPage struct { |
| + URL string `json:"url"` |
| + Title string `json:"title"` |
| + Text string `json:"text"` |
| +} |
| + |
| +// LookupStep asks the runner for one stage: the query (from the pack) or |
| +// the answer (from the pack, the results and the pages). The prompts are |
| +// the runner's own constants (lookup_prompts.go), chosen by Stage. |
| +type LookupStep struct { |
| + Lookup string `json:"lookup"` |
| + Attempt int `json:"attempt"` |
| + Nonce string `json:"nonce"` |
| + Stage string `json:"stage"` |
| + Pack LookupPack `json:"pack"` |
| + Results []SearchResult `json:"results,omitempty"` |
| + Pages []LookupPage `json:"pages,omitempty"` |
| + Truncated bool `json:"truncated,omitempty"` |
| +} |
| + |
| +// LookupResult is the runner's answer to one stage: the queries, or the |
| +// answer and the indexes of the results it used, or a failure code. |
| +type LookupResult struct { |
| + Lookup string `json:"lookup"` |
| + Attempt int `json:"attempt"` |
| + Nonce string `json:"nonce"` |
| + Stage string `json:"stage"` |
| + Queries []string `json:"queries,omitempty"` |
| + Answer string `json:"answer,omitempty"` |
| + Used []int `json:"used,omitempty"` |
| + Code string `json:"code,omitempty"` |
| +} |
| + |
| +// AssistantLookup is one lookup shown under a reply: its answer and the |
| +// pages it came from (spec §4.6). |
| +type AssistantLookup struct { |
| + Answer string `json:"answer"` |
| + Sources []LookupSource `json:"sources"` |
| +} |
| + |
| +// LookupSource is a page a lookup's answer came from. |
| +type LookupSource struct { |
| + URL string `json:"url"` |
| + Title string `json:"title"` |
| +} |
| + |
| +// The lookup codes: model-facing results and step failures. |
| +const ( |
| + CodeLookupShown = "shown" |
| + CodeLookupFailed = "lookup_failed" |
| + CodeNothingFound = "nothing_found" |
| + CodeLookupLimit = "lookup_limit" |
| + CodeLookupUnsupported = "lookup_unsupported" |
| +) |
| + |
| +var errLookupResult = errors.New("wire: lookup result out of bounds") |
| + |
| +// ValidQueryResult checks a query step's result: 1 or 2 queries, each 1 |
| +// to 200 characters, and nothing else. |
| +func ValidQueryResult(r LookupResult) error { |
| + if r.Code != "" || r.Answer != "" || r.Used != nil || len(r.Queries) == 0 || len(r.Queries) > MaxLookupQueries { |
| + return errLookupResult |
| + } |
| + for _, q := range r.Queries { |
| + if n := utf8.RuneCountInString(q); n == 0 || n > MaxLookupQuery || !utf8.ValidString(q) { |
| + return errLookupResult |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// ValidAnswerResult checks an answer step's result: an answer of 1 to |
| +// 1,200 characters, the results it used among the results given, and no |
| +// queries. |
| +func ValidAnswerResult(r LookupResult, results int) error { |
| + if r.Code != "" || r.Queries != nil || !utf8.ValidString(r.Answer) { |
| + return errLookupResult |
| + } |
| + if n := utf8.RuneCountInString(r.Answer); n == 0 || n > MaxLookupAnswer { |
| + return errLookupResult |
| + } |
| + seen := map[int]bool{} |
| + for _, i := range r.Used { |
| + if i < 0 || i >= results || seen[i] { |
| + return errLookupResult |
| + } |
| + seen[i] = true |
| + } |
| + return nil |
| +} |
diff --git a/internal/wire/lookup_test.go b/internal/wire/lookup_test.go| new file mode 100644 |
| index 00000000..ea939bba |
| --- /dev/null |
| +++ b/internal/wire/lookup_test.go |
| @@ -0,0 +1,106 @@ |
| +package wire_test |
| + |
| +import ( |
| + "encoding/json" |
| + "errors" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| + "amadan.net/oficina/equipo/internal/wire/wiretest" |
| +) |
| + |
| +func TestProtocolLookupIs36(t *testing.T) { |
| + if wire.ProtocolLookup != 36 || wire.ProtocolCurrent != wire.ProtocolLookup || wire.Spoken(99) != 36 { |
| + t.Fatalf("lookup %d current %d", wire.ProtocolLookup, wire.ProtocolCurrent) |
| + } |
| +} |
| + |
| +func TestLookupFramesRoundTrip(t *testing.T) { |
| + for _, name := range []string{"frames/lookup-step.json", "frames/lookup-result.json"} { |
| + f, body, err := wire.ParseFrame(wiretest.Fixture(name)) |
| + if err != nil { |
| + t.Fatalf("%s: %v", name, err) |
| + } |
| + switch v := body.(type) { |
| + case *wire.LookupStep: |
| + if v.Stage != wire.LookupStageAnswer || len(v.Pages) != 1 || v.Pack.City != "Dublin" { |
| + t.Errorf("step %+v", v) |
| + } |
| + case *wire.LookupResult: |
| + if err := wire.ValidAnswerResult(*v, 1); err != nil { |
| + t.Errorf("result %+v: %v", v, err) |
| + } |
| + default: |
| + t.Errorf("%s decoded as %T (%s)", name, body, f.Type) |
| + } |
| + } |
| +} |
| + |
| +// Neither lookup frame is acked or resent. |
| +func TestLookupFramesNotDurable(t *testing.T) { |
| + for _, kind := range []string{wire.FrameLookupStep, wire.FrameLookupResult} { |
| + if (wire.Frame{Type: kind}).Durable() { |
| + t.Errorf("%s is durable", kind) |
| + } |
| + } |
| +} |
| + |
| +func TestEncodeRefusesLookupBelow36(t *testing.T) { |
| + f, _, err := wire.ParseFrame(wiretest.Fixture("frames/lookup-step.json")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := wire.Encode(f, wire.Protocol35); !errors.Is(err, wire.ErrProtocol) { |
| + t.Errorf("at 35: %v", err) |
| + } |
| + if _, err := wire.Encode(f, wire.ProtocolLookup); err != nil { |
| + t.Errorf("at 36: %v", err) |
| + } |
| +} |
| + |
| +// Results are checked strictly: three queries, a 201-character query, an |
| +// answer with an extra field, an answer too long or a used index out of |
| +// range each fail. |
| +func TestLookupStepsStrictJSON(t *testing.T) { |
| + q := func(qs ...string) wire.LookupResult { |
| + return wire.LookupResult{Stage: wire.LookupStageQuery, Queries: qs} |
| + } |
| + if err := wire.ValidQueryResult(q("dublin weather", "dublin forecast tomorrow")); err != nil { |
| + t.Errorf("two queries: %v", err) |
| + } |
| + for name, r := range map[string]wire.LookupResult{ |
| + "three": q("a", "b", "c"), |
| + "long": q(strings.Repeat("x", 201)), |
| + "empty": q(""), |
| + "none": q(), |
| + "answer": {Queries: []string{"a"}, Answer: "no"}, |
| + "a code": {Queries: []string{"a"}, Code: "lookup_failed"}, |
| + } { |
| + if wire.ValidQueryResult(r) == nil { |
| + t.Errorf("query %s accepted", name) |
| + } |
| + } |
| + for name, r := range map[string]wire.LookupResult{ |
| + "too long": {Answer: strings.Repeat("é", 1201)}, |
| + "empty": {}, |
| + "used out": {Answer: "ok", Used: []int{3}}, |
| + "used twice": {Answer: "ok", Used: []int{0, 0}}, |
| + "queries": {Answer: "ok", Queries: []string{"a"}}, |
| + } { |
| + if wire.ValidAnswerResult(r, 2) == nil { |
| + t.Errorf("answer %s accepted", name) |
| + } |
| + } |
| + if err := wire.ValidAnswerResult(wire.LookupResult{Answer: strings.Repeat("é", 1200), Used: []int{1}}, 2); err != nil { |
| + t.Errorf("1200 characters: %v", err) |
| + } |
| + extra := []byte(`{"id":"x","type":"lookup_result","data":{"lookup":"l","attempt":1,"nonce":"n","stage":"answer","answer":"ok","extra":true}}`) |
| + if _, _, err := wire.ParseFrame(extra); err == nil { |
| + t.Error("an extra field was accepted") |
| + } |
| + var m wire.Message |
| + if err := json.Unmarshal([]byte(`{"id":"m","revision":1,"role":"assistant","text":"","turn_id":"t","created_at":"2026-11-28T10:00:00Z","switched":null,"lookups":[{"answer":"Rain.","sources":[{"url":"https://www.met.ie/","title":"Met"}]}]}`), &m); err != nil || len(m.Lookups) != 1 { |
| + t.Errorf("a message's lookups: %+v %v", m, err) |
| + } |
| +} |
diff --git a/internal/wire/mixed_protocol_test.go b/internal/wire/mixed_protocol_test.go| index 9b1745b4..e954c79c 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.ProtocolChangeDiffs { |
| + if wire.ProtocolMetered != wire.Protocol12 || wire.ProtocolResearch != wire.Protocol13 || wire.ProtocolCurrent != wire.ProtocolLookup { |
| 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 797653a0..676a8a41 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.ProtocolChangeDiffs { |
| + if wire.ProtocolModels != wire.Protocol18 || wire.ProtocolCurrent != wire.ProtocolLookup { |
| 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 d67e0442..dc94372c 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.ProtocolChangeDiffs { |
| + if wire.ProtocolOpenCode != wire.Protocol17 || wire.ProtocolCurrent != wire.ProtocolLookup { |
| 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 994f5625..a2f18be0 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.ProtocolChangeDiffs { |
| + if wire.ProtocolPinnedRelease != wire.Protocol29 || wire.ProtocolCurrent != wire.ProtocolLookup { |
| 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 b9ce131b..301b6bb0 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.ProtocolChangeDiffs || wire.Spoken(99) != 35 { |
| + if wire.ProtocolPlaces != wire.Protocol34 || wire.ProtocolCurrent != wire.ProtocolLookup || wire.Spoken(99) != 36 { |
| 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 2b4ae7b0..989a5a0c 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.ProtocolChangeDiffs { |
| + if wire.ProtocolPublish != wire.Protocol16 || wire.ProtocolCurrent != wire.ProtocolLookup { |
| 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 50f45fca..33d21304 100644 |
| --- a/internal/wire/runners.go |
| +++ b/internal/wire/runners.go |
| @@ -61,6 +61,7 @@ const ( |
| Protocol33 = 33 |
| Protocol34 = 34 |
| Protocol35 = 35 |
| + Protocol36 = 36 |
| // ProtocolSpend is the first protocol with a fix round's Feedback and |
| // a usage row's Turns; Encode drops both below it. |
| ProtocolSpend = Protocol3 |
| @@ -226,7 +227,11 @@ const ( |
| // report's change_diffs and the change_diff_upload frame. Below it |
| // Encode drops the report's diffs and refuses the upload. |
| ProtocolChangeDiffs = Protocol35 |
| - ProtocolCurrent = ProtocolChangeDiffs |
| + // ProtocolLookup adds the lookups' two isolated model steps (spec |
| + // 2026-11-26-assistant-abilities §4.2): the live-only lookup_step and |
| + // lookup_result frames (lookup.go). Below it Encode refuses both. |
| + ProtocolLookup = Protocol36 |
| + ProtocolCurrent = ProtocolLookup |
| ) |
| // Runner roles. A person's first runner is the primary: the coordinator, |
| @@ -651,7 +656,7 @@ var ErrProtocol = errors.New("wire: frame not in this protocol") |
| // (downgradeAssistantFiles); below ProtocolPlaces the places fields are |
| // dropped and their frames refused (downgradePlaces); below |
| // ProtocolChangeDiffs a change_diff upload is refused and a step report's |
| -// change_diffs dropped. |
| +// change_diffs dropped; below ProtocolLookup the lookup frames are refused. |
| func Encode(f Frame, protocol int) (Frame, error) { |
| if protocol >= ProtocolCurrent { |
| return f, nil |
| @@ -672,6 +677,9 @@ func Encode(f Frame, protocol int) (Frame, error) { |
| if v, ok := body.(*LeaseCheck); ok && v.AccessCard != "" && protocol < ProtocolAccess { |
| return Frame{}, ErrProtocol |
| } |
| + if protocol < ProtocolLookup && (f.Type == FrameLookupStep || f.Type == FrameLookupResult) { |
| + return Frame{}, fmt.Errorf("%w: %s at protocol %d", ErrProtocol, f.Type, protocol) |
| + } |
| changed := false |
| if protocol < ProtocolChangeDiffs { |
| switch v := body.(type) { |
diff --git a/internal/wire/runners_test.go b/internal/wire/runners_test.go| index 00a8ac9b..241bbd93 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.ProtocolChangeDiffs || 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.ProtocolLookup || 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 1c3832e2..757c13f6 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.ProtocolChangeDiffs { |
| + if wire.ProtocolScheduler != wire.Protocol14 || wire.ProtocolCurrent != wire.ProtocolLookup { |
| 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 b0790c7f..dd901565 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.ProtocolChangeDiffs || wire.Spoken(99) != 35 { |
| + if wire.ProtocolStuckTasks != wire.Protocol30 || wire.ProtocolCurrent != wire.ProtocolLookup || wire.Spoken(99) != 36 { |
| t.Fatalf("stuck %d, current %d", wire.ProtocolStuckTasks, wire.ProtocolCurrent) |
| } |
| caps := func(h *wire.ToolHealth) wire.Capabilities { |
diff --git a/internal/wire/usage_test.go b/internal/wire/usage_test.go| index 2ef4ad2e..d7bf7a24 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.ProtocolChangeDiffs { |
| + if wire.ProtocolReadings != wire.Protocol15 || wire.ProtocolCurrent != wire.ProtocolLookup { |
| 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 1801da18..7439ac97 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.ProtocolChangeDiffs || wire.Spoken(99) != 35 { |
| + if wire.ProtocolWarm != 24 || wire.ProtocolCurrent != wire.ProtocolLookup || wire.Spoken(99) != 36 { |
| t.Fatalf("protocols %d %d", wire.ProtocolWarm, wire.ProtocolCurrent) |
| } |
| f, err := wire.NewFrame("c1", wire.FrameWarm, wire.WarmCommand{Person: "ana@example.com"}) |
diff --git a/internal/wire/wiretest/testdata/frames/lookup-result.json b/internal/wire/wiretest/testdata/frames/lookup-result.json| new file mode 100644 |
| index 00000000..2b170a9a |
| --- /dev/null |
| +++ b/internal/wire/wiretest/testdata/frames/lookup-result.json |
| @@ -0,0 +1 @@ |
| +{"id":"l-2","type":"lookup_result","data":{"lookup":"lk_0001","attempt":1,"nonce":"n0001","stage":"answer","answer":"Rain at first, clearing later, with highs of 11 degrees.","used":[0]}} |
| \ No newline at end of file |
diff --git a/internal/wire/wiretest/testdata/frames/lookup-step.json b/internal/wire/wiretest/testdata/frames/lookup-step.json| new file mode 100644 |
| index 00000000..4164aa0f |
| --- /dev/null |
| +++ b/internal/wire/wiretest/testdata/frames/lookup-step.json |
| @@ -0,0 +1 @@ |
| +{"id":"l-1","type":"lookup_step","data":{"lookup":"lk_0001","attempt":1,"nonce":"n0001","stage":"answer","pack":{"question":"What's the weather in Dublin?","city":"Dublin","date":"2026-11-28, Saturday"},"results":[{"title":"Dublin forecast","url":"https://www.met.ie/forecasts/dublin","snippet":"Rain at first.","date":"2026-11-28"}],"pages":[{"url":"https://www.met.ie/forecasts/dublin","title":"Dublin forecast","text":"Rain at first, clearing later. Highs of 11 degrees."}]}} |
| \ No newline at end of file |