oficina / equipo Public

wire: protocol 15, a reading's time; usage and advice types

Headroom gains checked_at, the time the runner took a reading (ruling
#7 on S3's review). Below 15 Encode drops it from hello, sync and
connection reports, and WithoutReadingTimes keeps it out of the first
hello; frozen protocol 14 headroom tests. Advice, AdviceList,
AdviceAction, the advice card, UsageTotals and their fixtures, with the
secret-shape guard over them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 399029ab5f1a2e505cd52a27e6a3db7c0e74af08 parent 75ba486
15 files changed, +359 −11
  • internal/wire/api.go +2 −0
  • internal/wire/connections.go +5 −1
  • internal/wire/connections_test.go +5 −3
  • internal/wire/mixed_protocol_test.go +1 −1
  • internal/wire/runners.go +15 −3
  • internal/wire/runners_test.go +1 −1
  • internal/wire/schedule_test.go +1 −1
  • internal/wire/usage.go +183 −0
  • internal/wire/usage_test.go +134 −0
  • internal/wire/wiretest/fixtures.go +7 −1
  • internal/wire/wiretest/testdata/api/advice-action.json +1 −0
  • internal/wire/wiretest/testdata/api/advice.json +1 −0
  • internal/wire/wiretest/testdata/api/card-advice.json +1 −0
  • internal/wire/wiretest/testdata/api/usage-month.json +1 −0
  • internal/wire/wiretest/testdata/frames/hello-readings.json +1 −0
diff --git a/internal/wire/api.go b/internal/wire/api.go
index 434da4c1..ba7ea11f 100644
--- a/internal/wire/api.go
+++ b/internal/wire/api.go
@@ -358,6 +358,8 @@ type Card struct {
// Inventory is a research_inventory card's primary and the addresses
// it lists; absent on every other card.
Inventory *CardInventoryView `json:"inventory,omitempty"`
+ // Advice is an advice card's advice; absent on every other card.
+ Advice *Advice `json:"advice,omitempty"`
}
// AnswerCard is the body of POST /api/v1/cards/{id}/answer. Revision must
diff --git a/internal/wire/connections.go b/internal/wire/connections.go
index ff723041..31e57e41 100644
--- a/internal/wire/connections.go
+++ b/internal/wire/connections.go
@@ -80,11 +80,15 @@ type Window struct {
// Headroom is what the provider reported and nothing else. Utilization is
// 0 to 1 (null when unreported); ResetsAt is when a limited connection
-// may answer again (null when the provider did not say).
+// may answer again (null when the provider did not say). CheckedAt is
+// when the runner took the reading (ProtocolReadings; absent from an
+// older runner): Codex's is refreshed without a model turn, Claude's is
+// as last reported on a turn.
type Headroom struct {
Utilization *float64 `json:"utilization"`
ResetsAt *time.Time `json:"resets_at"`
Windows []Window `json:"windows"`
+ CheckedAt *time.Time `json:"checked_at,omitempty"`
}
// ConnectPrompt is what a connecting card shows: Kind is a Prompt*
diff --git a/internal/wire/connections_test.go b/internal/wire/connections_test.go
index 6151a514..b445d16b 100644
--- a/internal/wire/connections_test.go
+++ b/internal/wire/connections_test.go
@@ -42,7 +42,8 @@ func TestConnectionTypesCarryNoSecrets(t *testing.T) {
fieldNames(reflect.TypeOf(v), seen, &names)
}
// seal_key is the runner's public key (spec §2.4): public by design.
- allowed := map[string]bool{"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}
+ // An advice card's key is its kind and subject (connectors spec §9).
+ allowed := map[string]bool{"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}
for _, n := range names {
_, field, _ := strings.Cut(n, ".")
for _, bad := range secretShaped {
@@ -86,8 +87,9 @@ func TestHousekeepingTypesCarryNoSecrets(t *testing.T) {
for _, v := range []any{wire.Housekeeping{}, wire.HousekeepingActions{}, wire.HousekeepingAction{}, wire.SetHousekeeping{}, wire.SetDetector{}, wire.HousekeepingSummary{}, wire.ActionConflict{}, wire.Card{}} {
fieldNames(reflect.TypeOf(v), seen, &names)
}
- // copy_key names a copy string for the error, not a key.
- allowed := map[string]bool{"HousekeepingBudget.tokens": true, "ActionConflict.copy_key": true}
+ // copy_key names a copy string for the error, and an advice card's
+ // key its kind and subject: neither is a secret.
+ allowed := map[string]bool{"HousekeepingBudget.tokens": true, "ActionConflict.copy_key": true, "Advice.key": true}
for _, n := range names {
_, field, _ := strings.Cut(n, ".")
for _, bad := range secretShaped {
diff --git a/internal/wire/mixed_protocol_test.go b/internal/wire/mixed_protocol_test.go
index c5fc2f6b..86b1857b 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.Protocol14 {
+ if wire.ProtocolMetered != wire.Protocol12 || wire.ProtocolResearch != wire.Protocol13 || wire.ProtocolCurrent != wire.Protocol15 {
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/runners.go b/internal/wire/runners.go
index 8aa022a4..4c345fdd 100644
--- a/internal/wire/runners.go
+++ b/internal/wire/runners.go
@@ -40,6 +40,7 @@ const (
Protocol12 = 12
Protocol13 = 13
Protocol14 = 14
+ Protocol15 = 15
// ProtocolSpend is the first protocol with a fix round's Feedback and
// a usage row's Turns; Encode drops both below it.
ProtocolSpend = Protocol3
@@ -104,7 +105,13 @@ const (
// report and a preference with an end, and drops the dispatch fields:
// an older runner has no leave to spend, so it is never handed one.
ProtocolScheduler = Protocol14
- ProtocolCurrent = ProtocolScheduler
+ // ProtocolReadings is the first protocol whose headroom says when it
+ // was read (Headroom.CheckedAt, connectors spec rev 3.2 §6): the
+ // Usage page and the hold line show each reading's age. Encode drops
+ // it below (downgradeReadings); the runner's first hello never
+ // carries it (WithoutReadingTimes).
+ ProtocolReadings = Protocol15
+ ProtocolCurrent = ProtocolReadings
)
// Runner roles. A person's first runner is the primary: the coordinator,
@@ -474,7 +481,9 @@ func Speaks(protocol int, kind string) bool { return protocol >= Protocol2 || !p
var ErrProtocol = errors.New("wire: frame not in this protocol")
// Encode returns f as the given protocol speaks it. Below
-// ProtocolResearch the Research frames and fields are refused or dropped
+// ProtocolReadings a headroom's reading time is dropped; below
+// ProtocolScheduler the scheduler's frames are refused and its fields
+// dropped; below ProtocolResearch the Research frames and fields are refused or dropped
// (downgradeResearch); below ProtocolMetered the metered frames, an
// API-key connect and a metered report are refused and the metered
// fields dropped (downgradeMetered); below ProtocolPreviewHost a hello's
@@ -501,6 +510,9 @@ func Encode(f Frame, protocol int) (Frame, error) {
return Frame{}, err
}
changed := false
+ if protocol < ProtocolReadings {
+ changed = downgradeReadings(body)
+ }
if protocol < ProtocolScheduler {
if schedulerOnly[f.Type] {
return Frame{}, fmt.Errorf("%w: %s at protocol %d", ErrProtocol, f.Type, protocol)
@@ -511,7 +523,7 @@ func Encode(f Frame, protocol int) (Frame, error) {
if p, ok := body.(*PreferenceCommand); ok && p.Until != nil {
return Frame{}, fmt.Errorf("%w: a preference with an end at protocol %d", ErrProtocol, protocol)
}
- changed = downgradeScheduler(body)
+ changed = downgradeScheduler(body) || changed
}
if protocol < ProtocolResearch {
dropped, err := downgradeResearch(body, protocol)
diff --git a/internal/wire/runners_test.go b/internal/wire/runners_test.go
index fa024371..9c744539 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.ProtocolScheduler || wire.ProtocolScheduler != 14 || wire.ProtocolResearch != 13 || wire.ProtocolMetered != 12 || wire.ProtocolPreviewHost != 11 || wire.ProtocolExplore != 10 || wire.ProtocolPreview != 9 {
+ if wire.ProtocolCurrent != wire.ProtocolReadings || 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 1a86f933..f1532fd9 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.Protocol14 {
+ if wire.ProtocolScheduler != wire.Protocol14 || wire.ProtocolCurrent != wire.Protocol15 {
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/usage.go b/internal/wire/usage.go
new file mode 100644
index 00000000..76751879
--- /dev/null
+++ b/internal/wire/usage.go
@@ -0,0 +1,183 @@
+package wire
+
+import (
+ "slices"
+ "time"
+)
+
+// The Usage page and advice (connectors spec 2026-11-12 rev 3.2, §9 and
+// §10, slice S4; Connections rev 3 §6): a reading's age on the wire,
+// the person API's usage totals, and advice with its two actions.
+
+// downgradeReadings drops every headroom's reading time (an instance
+// below ProtocolReadings decodes headroom strictly). It reports whether
+// anything changed.
+func downgradeReadings(body any) bool {
+ switch v := body.(type) {
+ case *Hello:
+ return WithoutReadingTimes(v)
+ case *Sync:
+ return withoutCheckedAt(&v.Connections)
+ case *ConnectionReport:
+ if v.Headroom == nil || v.Headroom.CheckedAt == nil {
+ return false
+ }
+ h := *v.Headroom
+ h.CheckedAt, v.Headroom = nil, &h
+ return true
+ }
+ return false
+}
+
+// WithoutReadingTimes drops the reading time from a hello's connections
+// (in new values, so the caller's are untouched). The runner's first
+// hello on a connection is sent before the instance says its protocol,
+// and an instance below ProtocolReadings decodes it strictly; the next
+// hello carries the times once the welcome says protocol 15.
+func WithoutReadingTimes(h *Hello) bool { return withoutCheckedAt(&h.Connections) }
+
+func withoutCheckedAt(cs *[]HeldConnection) bool {
+ if !slices.ContainsFunc(*cs, func(c HeldConnection) bool { return c.Headroom != nil && c.Headroom.CheckedAt != nil }) {
+ return false
+ }
+ out := slices.Clone(*cs)
+ for i := range out {
+ if out[i].Headroom != nil && out[i].Headroom.CheckedAt != nil {
+ h := *out[i].Headroom
+ h.CheckedAt = nil
+ out[i].Headroom = &h
+ }
+ }
+ *cs = out
+ return true
+}
+
+// Advice kinds (§9), in their arbitration order: a metered connection
+// near a budget, a preferred subscription near its limit while another
+// has room, work that could wait so urgent work goes first, and low
+// work waiting a week.
+const (
+ AdviceBudgetNear = "budget_near"
+ AdvicePreferSwitch = "prefer_switch"
+ AdviceDeferTasks = "defer_tasks"
+ AdviceHeldLong = "held_long"
+)
+
+// AdviceKinds are the kinds in arbitration order.
+var AdviceKinds = []string{AdviceBudgetNear, AdvicePreferSwitch, AdviceDeferTasks, AdviceHeldLong}
+
+// Advice states. The advice table only moves forward: open, then acted,
+// dismissed (Not now) or withdrawn (its facts stopped holding).
+const (
+ AdviceOpen = "open"
+ AdviceActed = "acted"
+ AdviceDismissed = "dismissed"
+ AdviceWithdrawn = "withdrawn"
+)
+
+// CardAdvice is advice's one quiet card in the conversation: never
+// Needs you, never a push; its two choices are act and dismiss.
+const CardAdvice = "advice"
+
+// Choices on an advice card.
+const (
+ ChoiceAct = "act"
+ ChoiceDismiss = "dismiss"
+)
+
+// Advice is GET /api/v1/advice's item: one card of fixed words, its
+// action and its Not now, for the subject its key names. Revision must
+// be named by act and dismiss.
+type Advice struct {
+ ID string `json:"id"`
+ Kind string `json:"kind"`
+ Key string `json:"key"`
+ State string `json:"state"`
+ Subject AdviceSubject `json:"subject"`
+ Text string `json:"text"`
+ // Act and Dismiss are the two buttons' words.
+ Act string `json:"act"`
+ Dismiss string `json:"dismiss"`
+ Revision int64 `json:"revision"`
+ CreatedAt time.Time `json:"created_at"`
+ VisibleAt *time.Time `json:"visible_at"`
+}
+
+// AdviceSubject is what advice is about: a connection (the instance's
+// id), a role and the connection it would move to, or tasks.
+type AdviceSubject struct {
+ Connection string `json:"connection,omitempty"`
+ Role string `json:"role,omitempty"`
+ Tasks []string `json:"tasks,omitempty"`
+}
+
+// AdviceList is GET /api/v1/advice: the person's open advice that may
+// show now (at most one).
+type AdviceList struct {
+ Items []Advice `json:"items"`
+}
+
+// AdviceAction is the body of POST /api/v1/advice/{id}/act and
+// /dismiss: the advice's revision as the person saw it.
+type AdviceAction struct {
+ Revision int64 `json:"revision"`
+}
+
+// Usage periods and groupings (Connections rev 3 §6): today, this week
+// from Monday and this month from the 1st, in the person's zone; rows by
+// connection, role, project or task over one dataset.
+const (
+ UsageDay = "day"
+ UsageWeek = "week"
+ UsageMonth = "month"
+
+ UsageByConnection = "connection"
+ UsageByRole = "role"
+ UsageByProject = "project"
+ UsageByTask = "task"
+)
+
+// UsagePeriods and UsageGroupings are the values the page and the API take.
+var (
+ UsagePeriods = []string{UsageDay, UsageWeek, UsageMonth}
+ UsageGroupings = []string{UsageByConnection, UsageByRole, UsageByProject, UsageByTask}
+)
+
+// UsageTotals is GET /api/v1/usage?period=&by=: the person's recorded
+// token use for the period, one row per key. LeftOut says rows were
+// left out because they overcount (an older runner's). Prices are the
+// price table each metered connection was last charged by.
+type UsageTotals struct {
+ Period string `json:"period"`
+ By string `json:"by"`
+ From time.Time `json:"from"`
+ To time.Time `json:"to"`
+ Rows []UsageRow `json:"rows"`
+ LeftOut bool `json:"left_out"`
+ Prices []PriceSource `json:"prices"`
+}
+
+// UsageRow is one grouping's sums. ID is the connection's, project's or
+// task's id or the role; Label the name the record carries. Partial: a
+// row lacked a figure, so the sums are at least these. Cost is the
+// estimate from the price table where every row was priced (null
+// otherwise), in Currency.
+type UsageRow struct {
+ ID string `json:"id"`
+ Label string `json:"label"`
+ Input int64 `json:"input"`
+ CachedInput int64 `json:"cached_input"`
+ Output int64 `json:"output"`
+ Partial bool `json:"partial"`
+ Cost *int64 `json:"cost"`
+ Currency string `json:"currency"`
+ Attempts int64 `json:"attempts"`
+}
+
+// PriceSource is the price table a metered connection was last charged
+// by: its version names the provider's public page and the day it was
+// read (tensorx-2026-11-12).
+type PriceSource struct {
+ Connection string `json:"connection"`
+ PriceVersion string `json:"price_version"`
+}
diff --git a/internal/wire/usage_test.go b/internal/wire/usage_test.go
new file mode 100644
index 00000000..ca686483
--- /dev/null
+++ b/internal/wire/usage_test.go
@@ -0,0 +1,134 @@
+package wire_test
+
+import (
+ "bytes"
+ "encoding/json"
+ "reflect"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/wire"
+ "amadan.net/oficina/equipo/internal/wire/wiretest"
+)
+
+// frozen14Headroom is a protocol 14 instance's headroom: no reading time.
+var frozen14Headroom = map[string]bool{"utilization": true, "resets_at": true, "windows": true}
+
+// headrooms are the headroom objects a frame's body carries.
+func headrooms(t *testing.T, raw []byte) []map[string]json.RawMessage {
+ t.Helper()
+ var v struct {
+ Connections []struct {
+ Headroom map[string]json.RawMessage `json:"headroom"`
+ } `json:"connections"`
+ Headroom map[string]json.RawMessage `json:"headroom"`
+ }
+ if err := json.Unmarshal(raw, &v); err != nil {
+ t.Fatal(err)
+ }
+ out := []map[string]json.RawMessage{}
+ if v.Headroom != nil {
+ out = append(out, v.Headroom)
+ }
+ for _, c := range v.Connections {
+ if c.Headroom != nil {
+ out = append(out, c.Headroom)
+ }
+ }
+ return out
+}
+
+// Protocol 15 (ProtocolReadings) adds a headroom's reading time. Below
+// it, every headroom a runner sends (hello, sync, a connection report)
+// 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.Protocol15 {
+ t.Fatalf("readings %d, current %d", wire.ProtocolReadings, wire.ProtocolCurrent)
+ }
+ at := time.Date(2026, 11, 12, 9, 58, 0, 0, time.UTC)
+ used := 0.42
+ read := &wire.Headroom{Utilization: &used, Windows: []wire.Window{{Name: "primary", UsedPercent: 42, Minutes: 300}}, CheckedAt: &at}
+ held := []wire.HeldConnection{{LocalID: "codex-1", Person: "p", Provider: "codex", Kind: wire.KindSubscription, State: wire.ConnHealthy, Headroom: read}}
+ hello, _ := wire.NewFrame("h", wire.FrameHello, wire.Hello{Repos: []string{}, CreateIn: []string{}, Catalog: []wire.RepoInfo{}, Connections: held, Protocol: wire.ProtocolCurrent})
+ sync, _ := wire.NewFrame("s", wire.FrameSync, wire.Sync{Connections: held})
+ report, _ := wire.NewFrame("c", wire.FrameConnection, wire.ConnectionReport{LocalID: "codex-1", Person: "p", Provider: "codex", State: wire.ConnHealthy, Headroom: read})
+ for _, f := range []wire.Frame{hello, sync, report} {
+ if same, err := wire.Encode(f, wire.Protocol15); err != nil || !bytes.Equal(same.Data, f.Data) {
+ t.Fatalf("%s changed at 15: %v", f.Type, err)
+ }
+ old, err := wire.Encode(f, wire.Protocol14)
+ if err != nil {
+ t.Fatalf("%s at 14: %v", f.Type, err)
+ }
+ hs := headrooms(t, old.Data)
+ if len(hs) != 1 {
+ t.Fatalf("%s: %d headrooms in %s", f.Type, len(hs), old.Data)
+ }
+ for k := range hs[0] {
+ if !frozen14Headroom[k] {
+ t.Fatalf("%s carries %q, which a protocol 14 peer refuses: %s", f.Type, k, old.Data)
+ }
+ }
+ if _, _, err := wire.ParseFrame(mustFrame(t, old)); err != nil {
+ t.Fatalf("%s at 14 does not parse: %v", f.Type, err)
+ }
+ }
+ if read.CheckedAt == nil || held[0].Headroom.CheckedAt == nil {
+ t.Fatal("Encode changed the caller's headroom")
+ }
+}
+
+func mustFrame(t *testing.T, f wire.Frame) []byte {
+ t.Helper()
+ raw, err := json.Marshal(f)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return raw
+}
+
+// The runner's first hello is said before the instance's protocol is
+// known: WithoutReadingTimes drops the times in new values only.
+func TestWithoutReadingTimes(t *testing.T) {
+ at := time.Date(2026, 11, 12, 9, 58, 0, 0, time.UTC)
+ h := wire.Hello{Connections: []wire.HeldConnection{{LocalID: "a", Headroom: &wire.Headroom{CheckedAt: &at}}, {LocalID: "b"}}}
+ before := h.Connections
+ if !wire.WithoutReadingTimes(&h) {
+ t.Fatal("nothing dropped")
+ }
+ if h.Connections[0].Headroom.CheckedAt != nil || before[0].Headroom.CheckedAt == nil {
+ t.Fatal("the time stayed, or the caller's changed")
+ }
+ if wire.WithoutReadingTimes(&h) {
+ t.Fatal("dropped twice")
+ }
+}
+
+// TestAdviceTypesCarryNoSecrets: the secret-shape guard covers advice,
+// the usage totals and their fixtures. An advice's key is its kind and
+// subject, the one listed exception.
+func TestAdviceTypesCarryNoSecrets(t *testing.T) {
+ var names []string
+ seen := map[reflect.Type]bool{}
+ for _, v := range []any{wire.AdviceList{}, wire.Advice{}, wire.AdviceAction{}, wire.UsageTotals{}, wire.Card{}} {
+ fieldNames(reflect.TypeOf(v), seen, &names)
+ }
+ for _, n := range names {
+ _, field, _ := strings.Cut(n, ".")
+ for _, bad := range secretShaped {
+ if strings.Contains(strings.ToLower(field), bad) && n != "Advice.key" {
+ t.Errorf("%s looks like a secret (%q)", n, bad)
+ }
+ }
+ }
+ for _, name := range []string{"api/advice.json", "api/advice-action.json", "api/card-advice.json", "api/usage-month.json", "frames/hello-readings.json"} {
+ raw := strings.ReplaceAll(strings.ToLower(string(wiretest.Fixture(name))), `"key":`, "")
+ for _, bad := range []string{"token\"", "secret", "credential", "password", "sealed", "_key", "access_token", "refresh"} {
+ if strings.Contains(raw, bad) {
+ t.Errorf("%s contains %q", name, bad)
+ }
+ }
+ }
+}
diff --git a/internal/wire/wiretest/fixtures.go b/internal/wire/wiretest/fixtures.go
index 28ec9fcc..2af6eb2d 100644
--- a/internal/wire/wiretest/fixtures.go
+++ b/internal/wire/wiretest/fixtures.go
@@ -135,8 +135,14 @@ func APIType(name string) any {
return &wire.ActionConflict{}
case "event-housekeeping.json", "event-housekeeping-summary.json":
return &wire.Event{}
- case "card-housekeeping.json", "card-digest.json":
+ case "card-housekeeping.json", "card-digest.json", "card-advice.json":
return &wire.Card{}
+ case "advice.json":
+ return &wire.AdviceList{}
+ case "advice-action.json":
+ return &wire.AdviceAction{}
+ case "usage-month.json":
+ return &wire.UsageTotals{}
}
return nil
}
diff --git a/internal/wire/wiretest/testdata/api/advice-action.json b/internal/wire/wiretest/testdata/api/advice-action.json
new file mode 100644
index 00000000..3590e715
--- /dev/null
+++ b/internal/wire/wiretest/testdata/api/advice-action.json
@@ -0,0 +1 @@
+{"revision":1}
diff --git a/internal/wire/wiretest/testdata/api/advice.json b/internal/wire/wiretest/testdata/api/advice.json
new file mode 100644
index 00000000..f0fa1335
--- /dev/null
+++ b/internal/wire/wiretest/testdata/api/advice.json
@@ -0,0 +1 @@
+{"items":[{"id":"ad_0001","kind":"budget_near","key":"budget_near:cn_0003","state":"open","subject":{"connection":"cn_0003"},"text":"TensorX: $0.84 of today’s $1.","act":"Raise today’s budget to $2","dismiss":"Leave it","revision":1,"created_at":"2026-11-12T09:00:00Z","visible_at":null}]}
diff --git a/internal/wire/wiretest/testdata/api/card-advice.json b/internal/wire/wiretest/testdata/api/card-advice.json
new file mode 100644
index 00000000..5a7b8973
--- /dev/null
+++ b/internal/wire/wiretest/testdata/api/card-advice.json
@@ -0,0 +1 @@
+{"id":"c_0004","revision":1,"kind":"advice","state":"open","turn_id":"","project_id":"","name":"","question":"Claude is near its limit until Thu. Codex has room. Prefer Codex until then?","options":["act","dismiss"],"choice":"","task_id":"","created_at":"2026-11-12T09:00:00Z","updated_at":"2026-11-12T09:00:00Z","advice":{"id":"ad_0002","kind":"prefer_switch","key":"prefer_switch:engineering/cn_0002","state":"open","subject":{"connection":"cn_0002","role":"engineering"},"text":"Claude is near its limit until Thu. Codex has room. Prefer Codex until then?","act":"Prefer Codex until Thu","dismiss":"Not now","revision":1,"created_at":"2026-11-12T09:00:00Z","visible_at":null}}
diff --git a/internal/wire/wiretest/testdata/api/usage-month.json b/internal/wire/wiretest/testdata/api/usage-month.json
new file mode 100644
index 00000000..b45a52a1
--- /dev/null
+++ b/internal/wire/wiretest/testdata/api/usage-month.json
@@ -0,0 +1 @@
+{"period":"month","by":"connection","from":"2026-11-01T00:00:00Z","to":"2026-11-12T09:00:00Z","rows":[{"id":"cn_0001","label":"claude","input":840000,"cached_input":2100000,"output":61000,"partial":false,"cost":null,"currency":"","attempts":42},{"id":"cn_0003","label":"tensorx","input":120000,"cached_input":0,"output":9000,"partial":false,"cost":6200000,"currency":"USD","attempts":7}],"left_out":false,"prices":[{"connection":"cn_0003","price_version":"tensorx-2026-11-12"}]}
diff --git a/internal/wire/wiretest/testdata/frames/hello-readings.json b/internal/wire/wiretest/testdata/frames/hello-readings.json
new file mode 100644
index 00000000..ddb0b383
--- /dev/null
+++ b/internal/wire/wiretest/testdata/frames/hello-readings.json
@@ -0,0 +1 @@
+{"id":"r-hello-4","type":"hello","data":{"generation":4,"repos":[],"create_in":[],"home":"","agent":"equipo-docs-t1","catalog":[],"connections":[{"local_id":"codex-1","person":"owner@example.com","provider":"codex","kind":"subscription","label":"owner@example.com","state":"healthy","plan":"pro","headroom":{"utilization":0.42,"resets_at":null,"windows":[{"name":"primary","used_percent":42,"minutes":300,"resets_at":"2026-11-12T13:00:00Z"},{"name":"secondary","used_percent":18,"minutes":10080,"resets_at":"2026-11-16T10:00:00Z"}],"checked_at":"2026-11-12T09:58:00Z"}}],"versions":{"runner":"5eae410"},"protocol":15}}