Coordinator status reports the runner's preview scanner health (protocol 30)
Stuck tasks (a). The runner's capability report now says whether the pinned preview scanner (gitleaks) is installed and matches its pin, as the scan itself checks it: one fixed state (ok, missing, mismatch, unpinned), never a path or digest. A page renderer has a slot (renderer), absent while the runner has none. The coordinator's status tool reads it from the primary's newest hello as runner.tools, and says unknown when the runner did not say (an older runner) or its report was out of bounds. Protocol 30 (ProtocolStuckTasks): the first hello withholds the tool health and the next one carries it after a protocol 30 welcome; Encode drops it for an older instance, whose strict decoder would refuse it. Tests: wire TestProtocol30ToolHealth; runner/thin TestToolHealthReportsTheScannerPin, TestHandshakeHelloWithholdsToolHealth; thintest TestContractStatusToolHealth. Existing protocol pins move to 30. Mutation checks (each observed failing, then restored): - capability report without Tools: TestToolHealthReportsTheScannerPin - pin check skipped (mismatch reported ok): same test - first hello not withholding: TestHandshakeHelloWithholdsToolHealth - Encode not dropping it below 30: TestProtocol30ToolHealth - ValidCapabilities accepting any state: TestProtocol30ToolHealth and TestContractStatusToolHealth (an invalid report believed) - status always unknown: TestContractStatusToolHealth
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 files changed,
+325
−16
internal/equipo/chat/tools.go+11 −1internal/runner/thin/capabilities.go+3 −0internal/runner/thin/link.go+3 −1internal/runner/thin/mcp.go+1 −1internal/runner/thin/preview_security.go+18 −0internal/runner/thin/tool_health_test.go+92 −0internal/thintest/stuck_contract_test.go+61 −0internal/wire/assistant_test.go+1 −1internal/wire/injection_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/publish_test.go+1 −1internal/wire/runners.go+15 −1internal/wire/runners_test.go+1 −1internal/wire/schedule_test.go+1 −1internal/wire/stuck.go+59 −0internal/wire/stuck_test.go+50 −0internal/wire/usage_test.go+1 −1internal/wire/warm_test.go+1 −1
diff --git a/internal/equipo/chat/tools.go b/internal/equipo/chat/tools.go| index 9e0b19e4..1e3f6635 100644 |
| --- a/internal/equipo/chat/tools.go |
| +++ b/internal/equipo/chat/tools.go |
| @@ -730,7 +730,7 @@ func (t *txn) status(l Lease) (wire.ToolResult, error) { |
| CreateIn []string `json:"create_in"` |
| Home string `json:"home"` |
| Coordinator string `json:"coordinator"` |
| - }{Runner: map[string]any{"online": true, "versions": h.Versions}, Connections: []connection{}, Projects: []project{}, CanAdd: []string{}, CreateIn: []string{}} |
| + }{Runner: map[string]any{"online": true, "versions": h.Versions, "tools": toolHealth(h)}, Connections: []connection{}, Projects: []project{}, CanAdd: []string{}, CreateIn: []string{}} |
| if h.CreateIn != nil { |
| out.CreateIn = h.CreateIn |
| } |
| @@ -770,6 +770,16 @@ func (t *txn) status(l Lease) (wire.ToolResult, error) { |
| return wire.ToolResult{Code: "ok", Text: string(raw)}, nil |
| } |
| +// toolHealth is the primary's word on its pinned tools (protocol 30), |
| +// fixed states only (cleanHello dropped a report out of bounds); unknown |
| +// when it did not say. |
| +func toolHealth(h wire.Hello) wire.ToolHealth { |
| + if h.Capabilities == nil || h.Capabilities.Tools == nil { |
| + return wire.ToolHealth{Scanner: wire.ToolUnknown} |
| + } |
| + return *h.Capabilities.Tools |
| +} |
| + |
| // toolAddProject adds the project and puts an Added card in the |
| // conversation; the person can Remove it. No confirmation step. |
| func (t *txn) toolAddProject(r turnRecord, raw string) (wire.ToolResult, error) { |
diff --git a/internal/runner/thin/capabilities.go b/internal/runner/thin/capabilities.go| index 1d83bd63..05338a55 100644 |
| --- a/internal/runner/thin/capabilities.go |
| +++ b/internal/runner/thin/capabilities.go |
| @@ -87,6 +87,9 @@ func linuxCapabilities(c runner.Config, previews func() *wire.PreviewHost, sites |
| // The Research site inventory's detected addresses (absent when |
| // they cannot be read). |
| out.Research = researchCapability(addrs) |
| + // Whether the pinned preview scanner is installed and matches its |
| + // pin (protocol 30, for the coordinator's status). |
| + out.Tools = previewToolHealth(c) |
| if c.ClaudePath != "" { |
| out.Harness.Claude = provider.ClaudeVersion |
| out.Tags = append(out.Tags, wire.TagClaude) |
diff --git a/internal/runner/thin/link.go b/internal/runner/thin/link.go| index bc39e51e..9be851ea 100644 |
| --- a/internal/runner/thin/link.go |
| +++ b/internal/runner/thin/link.go |
| @@ -564,6 +564,8 @@ func (l *Link) handshake(ctx context.Context, offer int) (*websocket.Conn, *wire |
| heldUsage := wire.WithoutUsageRefresh(&hello) |
| // Nor the sites capability, below protocol 16. |
| heldSites := wire.WithoutSites(&hello) |
| + // Nor the tool health, below protocol 30. |
| + heldTools := wire.WithoutToolHealth(&hello) |
| l.mu.Lock() |
| hello.Generation, hello.Protocol, l.proto = l.generation, offer, offer |
| l.mu.Unlock() |
| @@ -612,7 +614,7 @@ func (l *Link) handshake(ctx context.Context, offer int) (*websocket.Conn, *wire |
| } |
| l.mu.Lock() |
| l.proto, l.role = min(spoken, offer), role |
| - if heldUsage && l.proto >= wire.ProtocolUsageRefresh || held && l.proto >= wire.ProtocolEmptyRepos || heldPreviews && l.proto >= wire.ProtocolExplore || heldResearch && l.proto >= wire.ProtocolResearch || heldReadings && l.proto >= wire.ProtocolReadings || heldSites && l.proto >= wire.ProtocolPublish { |
| + if heldUsage && l.proto >= wire.ProtocolUsageRefresh || held && l.proto >= wire.ProtocolEmptyRepos || heldPreviews && l.proto >= wire.ProtocolExplore || heldResearch && l.proto >= wire.ProtocolResearch || heldReadings && l.proto >= wire.ProtocolReadings || heldSites && l.proto >= wire.ProtocolPublish || heldTools && l.proto >= wire.ProtocolStuckTasks { |
| l.helloSoon = true |
| } |
| l.mu.Unlock() |
diff --git a/internal/runner/thin/mcp.go b/internal/runner/thin/mcp.go| index 1fcea1c0..f0d184ae 100644 |
| --- a/internal/runner/thin/mcp.go |
| +++ b/internal/runner/thin/mcp.go |
| @@ -150,7 +150,7 @@ var str = map[string]string{"type": "string"} |
| // descriptions are for the model; people never read them. |
| var converseTools = []any{ |
| map[string]any{"name": wire.ToolRequestAccess, "description": "Propose an access request for an unreachable repository. The person confirms before filing; never retry unprompted. Prefer one repository; namespace only if explicitly requested. Role defaults to agent.", "inputSchema": toolSchema(map[string]any{"target": str, "role": str, "reason": str}, "target", "reason")}, |
| - map[string]any{"name": "status", "description": "Read-only: this person's runner, model connections, current projects, the repositories you can add (can_add) and the namespaces you can create repositories in (create_in, with home for unrelated new work). Call it before choosing where work goes.", "inputSchema": toolSchema(map[string]any{})}, |
| + map[string]any{"name": "status", "description": "Read-only: this person's runner, model connections, current projects, the repositories you can add (can_add) and the namespaces you can create repositories in (create_in, with home for unrelated new work). Call it before choosing where work goes. runner.tools says whether the runner's pinned preview scanner is installed and matches its pin (ok, missing, mismatch, unpinned, or unknown when the runner does not say): a preview that failed for its scanner needs the runner fixed or updated, not another try.", "inputSchema": toolSchema(map[string]any{})}, |
| map[string]any{"name": "find", "description": "Read-only: find which repository an app, product or feature lives in, by name, alias or keyword (for example Woodstar). Returns candidates with reasons, or says nothing Equipo's agent can reach matches.", "inputSchema": toolSchema(map[string]any{"query": str}, "query")}, |
| map[string]any{"name": "search_code", "description": "Read-only: search a repository's default branch for a fixed string, case insensitive. Returns path:line: text, bounded.", "inputSchema": toolSchema(map[string]any{"repo": str, "query": str}, "repo", "query")}, |
| map[string]any{"name": "read_file", "description": "Read-only: read a file from a repository's default branch with line numbers (up to 300 lines from start), or list a directory (empty path is the root). For a file the person attached, repo is \"attachments\" and path is the one given with their message.", "inputSchema": toolSchema(map[string]any{"repo": str, "path": str, "start": map[string]string{"type": "integer"}}, "repo", "path")}, |
diff --git a/internal/runner/thin/preview_security.go b/internal/runner/thin/preview_security.go| index a58d2f32..14bef507 100644 |
| --- a/internal/runner/thin/preview_security.go |
| +++ b/internal/runner/thin/preview_security.go |
| @@ -3,6 +3,7 @@ package thin |
| import ( |
| "amadan.net/oficina/equipo/internal/release" |
| "amadan.net/oficina/equipo/internal/runner" |
| + "amadan.net/oficina/equipo/internal/wire" |
| "context" |
| "crypto/sha256" |
| "encoding/hex" |
| @@ -40,6 +41,23 @@ var previewScannerTool = func(c runner.Config) (string, string) { |
| return filepath.Join(filepath.Dir(c.Executable), "gitleaks"), release.GitleaksSHA256() |
| } |
| +// previewToolHealth is whether the preview scanner is installed and is the |
| +// pinned build, as scanPreview checks it before every scan: a fixed state |
| +// for the coordinator's status, never the path or the pin. |
| +func previewToolHealth(c runner.Config) *wire.ToolHealth { |
| + binary, pin := previewScannerTool(c) |
| + state := wire.ToolHealthy |
| + switch info, err := os.Lstat(binary); { |
| + case !filepath.IsAbs(binary) || err != nil || !info.Mode().IsRegular(): |
| + state = wire.ToolMissing |
| + case pin == "": |
| + state = wire.ToolUnpinned |
| + case !release.VerifyGitleaks(binary, pin): |
| + state = wire.ToolMismatch |
| + } |
| + return &wire.ToolHealth{Scanner: state} |
| +} |
| + |
| func (e *Engineer) scanPreview(ctx context.Context, stage string) string { |
| binary, pin := previewScannerTool(e.O.Runner) |
| if !release.VerifyGitleaks(binary, pin) { |
diff --git a/internal/runner/thin/tool_health_test.go b/internal/runner/thin/tool_health_test.go| new file mode 100644 |
| index 00000000..8a0a29a4 |
| --- /dev/null |
| +++ b/internal/runner/thin/tool_health_test.go |
| @@ -0,0 +1,92 @@ |
| +package thin |
| + |
| +import ( |
| + "context" |
| + "crypto/sha256" |
| + "encoding/json" |
| + "fmt" |
| + "os" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/runner" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// TestToolHealthReportsTheScannerPin (stuck tasks, protocol 30): the |
| +// capability report says whether the preview scanner is installed and is |
| +// the pinned build, as the scan itself checks it: one fixed state, never |
| +// its path or digest. |
| +func TestToolHealthReportsTheScannerPin(t *testing.T) { |
| + dir := t.TempDir() |
| + binary := filepath.Join(dir, "gitleaks") |
| + if err := os.WriteFile(binary, []byte("#!/bin/sh\nexit 0\n"), 0o700); err != nil { |
| + t.Fatal(err) |
| + } |
| + raw, _ := os.ReadFile(binary) |
| + pin := fmt.Sprintf("%x", sha256.Sum256(raw)) |
| + other := fmt.Sprintf("%x", sha256.Sum256([]byte("another build"))) |
| + old := previewScannerTool |
| + t.Cleanup(func() { previewScannerTool = old }) |
| + report := func(path, want string) wire.Capabilities { |
| + previewScannerTool = func(runner.Config) (string, string) { return path, want } |
| + return linuxCapabilities(runner.Config{}, func() *wire.PreviewHost { return nil }, false, nil)(context.Background()) |
| + } |
| + for _, c := range []struct{ path, pin, want string }{ |
| + {binary, pin, wire.ToolHealthy}, |
| + {binary, other, wire.ToolMismatch}, |
| + {filepath.Join(dir, "absent"), pin, wire.ToolMissing}, |
| + {dir, pin, wire.ToolMissing}, |
| + {binary, "", wire.ToolUnpinned}, |
| + } { |
| + caps := report(c.path, c.pin) |
| + if caps.Tools == nil || caps.Tools.Scanner != c.want || caps.Tools.Renderer != "" { |
| + t.Fatalf("%s pinned %q: %+v", c.path, c.pin, caps.Tools) |
| + } |
| + if err := wire.ValidCapabilities(caps); err != nil { |
| + t.Fatalf("report out of bounds: %v", err) |
| + } |
| + out, _ := json.Marshal(caps) |
| + if strings.Contains(string(out), dir) || strings.Contains(string(out), pin) || strings.Contains(string(out), "gitleaks") { |
| + t.Fatalf("the report names the tool's path or pin: %s", out) |
| + } |
| + } |
| + // Not executable is not installed: the scan would refuse it. |
| + if err := os.Chmod(binary, 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + if caps := report(binary, pin); caps.Tools.Scanner != wire.ToolMismatch && caps.Tools.Scanner != wire.ToolMissing { |
| + t.Fatalf("a scanner the scan refuses reported %q", caps.Tools.Scanner) |
| + } |
| +} |
| + |
| +// TestHandshakeHelloWithholdsToolHealth: the first hello goes out before |
| +// the instance says its protocol, so it never carries the tool health an |
| +// older instance's strict decoder refuses; after a protocol 30 welcome |
| +// the next hello, sent at once, does; at 29 none ever does. |
| +func TestHandshakeHelloWithholdsToolHealth(t *testing.T) { |
| + hello := func() wire.Hello { |
| + return wire.Hello{Repos: []string{"amadan.net/oficina/sample"}, CreateIn: []string{}, Catalog: []wire.RepoInfo{}, Connections: []wire.HeldConnection{}, Versions: map[string]string{"runner": "test", "claude": "2.1.312"}, |
| + Capabilities: &wire.Capabilities{Tags: []string{wire.TagLinux}, Simulators: []wire.Simulator{}, Tools: &wire.ToolHealth{Scanner: wire.ToolMissing}}} |
| + } |
| + for _, protocol := range []int{wire.ProtocolPinnedRelease, wire.ProtocolStuckTasks} { |
| + inst := newFakeInstance(t) |
| + link, _, _, _ := startLinkWith(t, inst.url, &stubCoordinator{}, hello) |
| + c := <-inst.conns |
| + _, raw := read(t, c, wire.FrameHello) |
| + if strings.Contains(string(raw), `"tools"`) || !strings.Contains(string(raw), `"linux"`) { |
| + t.Fatalf("handshake hello: %s", raw) |
| + } |
| + welcome, _ := json.Marshal(wire.Frame{ID: "w-t", Type: wire.FrameWelcome, Data: json.RawMessage(`{"generation":3,"runner_id":"RUNNER1","protocol":` + itoa(int64(protocol)) + `,"role":"primary"}`)}) |
| + write(t, c, welcome) |
| + read(t, c, wire.FrameSync) |
| + if protocol < wire.ProtocolStuckTasks { |
| + link.HelloSoon() |
| + } |
| + _, raw = read(t, c, wire.FrameHello) |
| + if got := strings.Contains(string(raw), `"tools":{"scanner":"missing"}`); got != (protocol >= wire.ProtocolStuckTasks) { |
| + t.Fatalf("protocol %d hello: %s", protocol, raw) |
| + } |
| + } |
| +} |
diff --git a/internal/thintest/stuck_contract_test.go b/internal/thintest/stuck_contract_test.go| new file mode 100644 |
| index 00000000..c96ec929 |
| --- /dev/null |
| +++ b/internal/thintest/stuck_contract_test.go |
| @@ -0,0 +1,61 @@ |
| +package thintest |
| + |
| +import ( |
| + "encoding/json" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// Stuck tasks (Paul, 2026-11-25: "empower Equipo to be more able to do |
| +// work"): the coordinator can see why a preview could not be scanned, |
| +// offer the person a one-tap retry of a failed merge, and run a failed |
| +// preview, checks or review again; it never merges or publishes. |
| + |
| +// toolsOf is status's runner tools. |
| +func toolsOf(t *testing.T, res wire.ToolResult) wire.ToolHealth { |
| + t.Helper() |
| + var out struct { |
| + Runner struct { |
| + Tools *wire.ToolHealth `json:"tools"` |
| + } `json:"runner"` |
| + } |
| + if res.IsError || json.Unmarshal([]byte(res.Text), &out) != nil || out.Runner.Tools == nil { |
| + t.Fatalf("status %+v", res) |
| + } |
| + return *out.Runner.Tools |
| +} |
| + |
| +// TestContractStatusToolHealth: status says whether the primary's pinned |
| +// preview scanner is installed and matches its pin, from its newest |
| +// hello; unknown when the runner does not say (an older runner). Never a |
| +// path. |
| +func TestContractStatusToolHealth(t *testing.T) { |
| + r := newToolRigAt(t, wire.ProtocolCurrent) |
| + if got := toolsOf(t, r.call("s1", wire.ToolStatus, map[string]string{})); got != (wire.ToolHealth{Scanner: wire.ToolUnknown}) { |
| + t.Fatalf("an unsaid health %+v", got) |
| + } |
| + h := primaryAt(toolHello(r.runner.Welcome.Generation), wire.ProtocolCurrent) |
| + h.Capabilities.Tools = &wire.ToolHealth{Scanner: wire.ToolMismatch} |
| + if err := r.runner.Send(r.ctx, "h-tools", wire.FrameHello, h); err != nil { |
| + t.Fatal(err) |
| + } |
| + r.client.Snapshot(r.ctx) |
| + res := r.call("s2", wire.ToolStatus, map[string]string{}) |
| + if got := toolsOf(t, res); got != (wire.ToolHealth{Scanner: wire.ToolMismatch}) { |
| + t.Fatalf("reported health %+v", got) |
| + } |
| + if strings.Contains(res.Text, "/opt/") || strings.Contains(res.Text, "/home/") || strings.Contains(res.Text, "gitleaks") { |
| + t.Fatalf("status names a path: %s", res.Text) |
| + } |
| + // A report out of bounds is not believed: unknown again. |
| + h.Capabilities.Tools = &wire.ToolHealth{Scanner: "fine"} |
| + if err := r.runner.Send(r.ctx, "h-bad", wire.FrameHello, h); err != nil { |
| + t.Fatal(err) |
| + } |
| + r.client.Snapshot(r.ctx) |
| + if got := toolsOf(t, r.call("s3", wire.ToolStatus, map[string]string{})); got.Scanner != wire.ToolUnknown { |
| + t.Fatalf("an invalid report believed %+v", got) |
| + } |
| +} |
diff --git a/internal/wire/assistant_test.go b/internal/wire/assistant_test.go| index bd7e99ae..3d0b8ab5 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) != 29 || wire.ProtocolCurrent != wire.ProtocolPinnedRelease || 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) != 30 || wire.ProtocolCurrent != wire.ProtocolStuckTasks || 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/injection_test.go b/internal/wire/injection_test.go| index ac4325fa..e6678b6c 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 != 29 { |
| + if wire.ProtocolInjectionDefences != 28 || wire.ProtocolCurrent != 30 { |
| t.Fatal("injection guarantees require protocol 28") |
| } |
| - for version, want := range map[int]int{26: 26, 27: 27, 28: 28, 29: 29, 99: 29} { |
| + for version, want := range map[int]int{26: 26, 27: 27, 28: 28, 29: 29, 30: 30, 99: 30} { |
| if got := wire.Spoken(version); got != want { |
| t.Fatalf("negotiated %d as %d, want %d", version, got, want) |
| } |
diff --git a/internal/wire/mixed_protocol_test.go b/internal/wire/mixed_protocol_test.go| index 195b6574..38424ed1 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.Protocol29 { |
| + if wire.ProtocolMetered != wire.Protocol12 || wire.ProtocolResearch != wire.Protocol13 || wire.ProtocolCurrent != wire.Protocol30 { |
| 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 8cfe64b0..28012643 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.Protocol29 { |
| + if wire.ProtocolModels != wire.Protocol18 || wire.ProtocolCurrent != wire.Protocol30 { |
| 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 b4806cde..ef98f25b 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.Protocol29 { |
| + if wire.ProtocolOpenCode != wire.Protocol17 || wire.ProtocolCurrent != wire.Protocol30 { |
| 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 9e602f3c..0a71599a 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.Protocol29 { |
| + if wire.ProtocolPinnedRelease != wire.Protocol29 || wire.ProtocolCurrent != wire.Protocol30 { |
| 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/publish_test.go b/internal/wire/publish_test.go| index 129d9f2e..6f940f0d 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.Protocol29 { |
| + if wire.ProtocolPublish != wire.Protocol16 || wire.ProtocolCurrent != wire.Protocol30 { |
| 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 1d82a593..3070109c 100644 |
| --- a/internal/wire/runners.go |
| +++ b/internal/wire/runners.go |
| @@ -55,6 +55,7 @@ const ( |
| Protocol27 = 27 |
| Protocol28 = 28 |
| Protocol29 = 29 |
| + Protocol30 = 30 |
| // ProtocolSpend is the first protocol with a fix round's Feedback and |
| // a usage row's Turns; Encode drops both below it. |
| ProtocolSpend = Protocol3 |
| @@ -188,7 +189,11 @@ const ( |
| // leave anywhere, metered included, so it is never handed one. The |
| // instance offers an older runner plain Run now, with no promise. |
| ProtocolPinnedRelease = Protocol29 |
| - ProtocolCurrent = ProtocolPinnedRelease |
| + // ProtocolStuckTasks adds the coordinator's powers for stuck tasks |
| + // (stuck.go): a hello's tool health. Below it Encode drops the tool |
| + // health (downgradeStuck). |
| + ProtocolStuckTasks = Protocol30 |
| + ProtocolCurrent = ProtocolStuckTasks |
| ) |
| // Runner roles. A person's first runner is the primary: the coordinator, |
| @@ -268,6 +273,9 @@ type Capabilities struct { |
| // Sites (ProtocolPublish): this runner is paired with a site host and |
| // can publish a merged website. Withheld until the welcome says 16. |
| Sites bool `json:"sites,omitempty"` |
| + // Tools (ProtocolStuckTasks): whether the runner's pinned tools are |
| + // installed and match their pins. Withheld until the welcome says 30. |
| + Tools *ToolHealth `json:"tools,omitempty"` |
| } |
| // PreviewHost is a preview host a runner pairs with: its kind (an |
| @@ -362,6 +370,9 @@ func ValidCapabilities(c Capabilities) error { |
| if h := c.PreviewHost; h != nil && (!c.Previews || h.Kind != PreviewHostDevbox && h.Kind != PreviewHostCarlokuTemp || h.Domain != "" && (len(h.Domain) > 253 || !previewHostDomain.MatchString(h.Domain))) { |
| return ErrCapabilities |
| } |
| + if h := c.Tools; h != nil && !validToolHealth(*h) { |
| + return ErrCapabilities |
| + } |
| if err := checkStrings(reflect.ValueOf(c)); err != nil { |
| return err |
| } |
| @@ -618,6 +629,9 @@ func Encode(f Frame, protocol int) (Frame, error) { |
| return Frame{}, ErrProtocol |
| } |
| changed := false |
| + if protocol < ProtocolStuckTasks { |
| + changed = downgradeStuck(body) |
| + } |
| if protocol < ProtocolPinnedRelease { |
| if v, ok := body.(*ReleaseCommand); ok && v.Connection != "" { |
| return Frame{}, fmt.Errorf("%w: a pinned release at protocol %d", ErrProtocol, protocol) |
diff --git a/internal/wire/runners_test.go b/internal/wire/runners_test.go| index d7f2be8e..cbf4fdd6 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.ProtocolPinnedRelease || 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.ProtocolStuckTasks || 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 12bd0b98..50478281 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.Protocol29 { |
| + if wire.ProtocolScheduler != wire.Protocol14 || wire.ProtocolCurrent != wire.Protocol30 { |
| 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.go b/internal/wire/stuck.go| new file mode 100644 |
| index 00000000..13057f8a |
| --- /dev/null |
| +++ b/internal/wire/stuck.go |
| @@ -0,0 +1,59 @@ |
| +package wire |
| + |
| +import "slices" |
| + |
| +// Stuck tasks (coordinator powers, Paul 2026-11-25): ProtocolStuckTasks |
| +// adds the runner's tool health to its capabilities, so the coordinator's |
| +// status can say why a preview could not be scanned. Below it Encode |
| +// drops a hello's tool health: an older instance decodes a hello |
| +// strictly and has no words for it. |
| + |
| +// ToolHealth is whether the runner's pinned tools are installed and |
| +// match their pins, one fixed state each (ToolHealthy and the rest): |
| +// never a path, a digest or a tool's output. Scanner is the preview's |
| +// secret scanner (gitleaks at release.GitleaksVersion); Renderer is a |
| +// page renderer's, absent while the runner has none. |
| +type ToolHealth struct { |
| + Scanner string `json:"scanner"` |
| + Renderer string `json:"renderer,omitempty"` |
| +} |
| + |
| +// Tool health states. ToolUnknown is the instance's word for a runner |
| +// that did not say (an older one); a runner never reports it. |
| +const ( |
| + ToolHealthy = "ok" |
| + ToolMissing = "missing" |
| + ToolMismatch = "mismatch" |
| + ToolUnpinned = "unpinned" |
| + ToolUnknown = "unknown" |
| +) |
| + |
| +var toolStates = []string{ToolHealthy, ToolMissing, ToolMismatch, ToolUnpinned} |
| + |
| +// validToolHealth reports whether a runner's report is in the fixed set: |
| +// the scanner always said, the renderer only when there is one. |
| +func validToolHealth(h ToolHealth) bool { |
| + return slices.Contains(toolStates, h.Scanner) && (h.Renderer == "" || slices.Contains(toolStates, h.Renderer)) |
| +} |
| + |
| +// WithoutToolHealth drops a hello's tool health, in a copy. The first |
| +// hello is sent before the instance says its protocol: an older |
| +// instance's strict decoder would refuse it. It reports whether it |
| +// dropped anything. |
| +func WithoutToolHealth(h *Hello) bool { |
| + if h.Capabilities == nil || h.Capabilities.Tools == nil { |
| + return false |
| + } |
| + c := *h.Capabilities |
| + c.Tools = nil |
| + h.Capabilities = &c |
| + return true |
| +} |
| + |
| +// downgradeStuck clears ProtocolStuckTasks's fields for an older peer. |
| +func downgradeStuck(body any) bool { |
| + if h, ok := body.(*Hello); ok { |
| + return WithoutToolHealth(h) |
| + } |
| + return false |
| +} |
diff --git a/internal/wire/stuck_test.go b/internal/wire/stuck_test.go| new file mode 100644 |
| index 00000000..23fe4e43 |
| --- /dev/null |
| +++ b/internal/wire/stuck_test.go |
| @@ -0,0 +1,50 @@ |
| +package wire_test |
| + |
| +import ( |
| + "bytes" |
| + "errors" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// 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.Protocol30 || wire.Spoken(99) != 30 { |
| + t.Fatalf("stuck %d, current %d", wire.ProtocolStuckTasks, wire.ProtocolCurrent) |
| + } |
| + caps := func(h *wire.ToolHealth) wire.Capabilities { |
| + return wire.Capabilities{Tags: []string{wire.TagLinux}, Simulators: []wire.Simulator{}, Tools: h} |
| + } |
| + for _, s := range []string{wire.ToolHealthy, wire.ToolMissing, wire.ToolMismatch, wire.ToolUnpinned} { |
| + if err := wire.ValidCapabilities(caps(&wire.ToolHealth{Scanner: s})); err != nil { |
| + t.Fatalf("scanner %s refused: %v", s, err) |
| + } |
| + if err := wire.ValidCapabilities(caps(&wire.ToolHealth{Scanner: wire.ToolHealthy, Renderer: s})); err != nil { |
| + t.Fatalf("renderer %s refused: %v", s, err) |
| + } |
| + } |
| + for _, bad := range []wire.ToolHealth{{}, {Scanner: wire.ToolUnknown}, {Scanner: "fine"}, {Scanner: wire.ToolHealthy, Renderer: wire.ToolUnknown}, {Scanner: "/usr/bin/gitleaks"}} { |
| + if err := wire.ValidCapabilities(caps(&bad)); !errors.Is(err, wire.ErrCapabilities) { |
| + t.Fatalf("%+v accepted", bad) |
| + } |
| + } |
| + hello := wire.Hello{Protocol: wire.Protocol30, Repos: []string{}, Capabilities: &wire.Capabilities{Tags: []string{wire.TagLinux}, Sites: true, Tools: &wire.ToolHealth{Scanner: wire.ToolMismatch}}} |
| + f, _ := wire.NewFrame("h", wire.FrameHello, hello) |
| + if same, err := wire.Encode(f, wire.Protocol30); err != nil || !bytes.Equal(same.Data, f.Data) || !strings.Contains(string(same.Data), `"tools":{"scanner":"mismatch"}`) { |
| + t.Fatalf("hello at 30: %v %s", err, same.Data) |
| + } |
| + got, err := wire.Encode(f, wire.Protocol29) |
| + if err != nil || strings.Contains(string(got.Data), `"tools"`) || !strings.Contains(string(got.Data), `"sites":true`) { |
| + t.Fatalf("hello at 29: %v %s", err, got.Data) |
| + } |
| + if hello.Capabilities.Tools == nil { |
| + t.Fatal("encoding changed the caller's hello") |
| + } |
| + first := hello |
| + if !wire.WithoutToolHealth(&first) || first.Capabilities.Tools != nil || hello.Capabilities.Tools == nil || wire.WithoutToolHealth(&first) { |
| + t.Fatal("WithoutToolHealth") |
| + } |
| +} |
diff --git a/internal/wire/usage_test.go b/internal/wire/usage_test.go| index abf8bfa9..2eeede17 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.Protocol29 { |
| + if wire.ProtocolReadings != wire.Protocol15 || wire.ProtocolCurrent != wire.Protocol30 { |
| 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 352c2c00..81358c7d 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.ProtocolPinnedRelease || wire.Spoken(99) != 29 { |
| + if wire.ProtocolWarm != 24 || wire.ProtocolCurrent != wire.ProtocolStuckTasks || wire.Spoken(99) != 30 { |
| t.Fatalf("protocols %d %d", wire.ProtocolWarm, wire.ProtocolCurrent) |
| } |
| f, err := wire.NewFrame("c1", wire.FrameWarm, wire.WarmCommand{Person: "ana@example.com"}) |