feat(triage): the Console resolves Triage's model route at each admit, so Triage starts (#1873) #1995

Merged
jason.woltje merged 3 commits from triage-wiring into refactor 2026-11-18 22:59:34 +00:00
Owner

What changes

The Console gives the Triage host a real route, so Triage can start. Until now it passed route: null.

  • Route. Resolved again at each admit from the route store, the key file <configDir>/secrets/triage/model, each active organization's model catalogue (merged, then held to checkRoutes, called unchanged) and the harness module. The proxy port is read from proxy.json at each admit, by the route and again by the host.
  • Env. The route adds only ANTHROPIC_BASE_URL (the instance proxy, loopback) and ANTHROPIC_AUTH_TOKEN (the Triage key). The host writes the harness bundle and sets the MOSAIC_ names the module declares. The runner keeps its own names. No name has two sources.
  • Harness. claude-code answers. pi is refused as triage-harness-incompatible: it takes its key in another variable and needs a proxy transport.
  • Key. Read at each admit with the key verbs' checks. The reader moved to packages/cli/src/triage-key-file.mjs, which imports node built-ins only. The Console never loads the proxy management client or the key verbs' module, and a test fails if it does. The key goes only into the spawn env. If the agent echoes its key in a Triage line, the host replaces it with [key removed] before the line is stored.
  • Refusals. Each launches nothing and answers 409 with one plain line: no route, no key, key file unsafe, model not offered, no ready catalogue, harness incompatible, proxy not running.
  • Cap fails closed. Two turns in a row with unknown usage end the session with a host line. The next message starts a fresh session and counts again. This closes the gap #1992 left open. The fresh-start marker survives a Console restart.

Jason approved the route design on 2026-11-18 ("route as recommended") and this slice the same day.

How

  • packages/webui/src/triage-route.mjs (new), triage-host.mjs, triage-http.mjs, cli.mjs, public/display.js.
  • packages/cli/src/triage-key-file.mjs (new, moved out of triage-key.mjs, which re-exports it). packages/cli/src/triage.mjs is untouched.
  • Tests: triage-wiring (new, 18), triage-host (49), triage-key (22, unchanged).
  • Nothing under roles/, contracts/, packages/bus/, packages/queue/, packages/organization/ or packages/plugins/. No new HTTP route and no new CLI verb.

Tests

  • An end-to-end test with a stand-in proxy. A test that runs the real adapters/claude/adapter.sh under bwrap with a stub claude binary. One test per refusal. A key scan over files, logs, argv, responses and reads.
  • Mutants: 63 of 65 red. The two survivors look equivalent. One mutant was not run: stopping MOSAIC_CLAUDE_BIN reaching the spawn would start the real /usr/bin/claude. A unit test covers that line.
  • Lane gate on 4a8d310cd: 340 files (webui, cli, model-proxy), 3544 pass, 0 fail, 6 skipped (4 org-quick-live, 1 federation-acceptance, 1 shots).
  • Lead check on 4a8d310cd in a clean environment: 36 files (the webui triage and proxy tests, the cli triage tests, every model-proxy test, browser, single-pane, w15-shell and agent-drawer), 451 tests, 450 pass, 0 fail, 1 skipped (shots).

Review

Two fresh claude-opus-5-5 reviewers. The first said changes, one P1 and three P3s. The P1: no shipped harness could answer, because the route dropped every MOSAIC_ name and the host set none. All four are fixed in the second commit. The second reviewer re-checked that commit and approved with no counted findings. The third commit is one comment.

Left for later

  • The route does not call the module's preflight(), so it does not check which claude binary runs. With MOSAIC_CLAUDE_BIN unset the adapter uses claude from /usr/bin or /bin. A binary under HOME is refused only after the route admits. Both fail closed.
  • pi as Triage's harness.
  • The host cannot know whether the proxy holds the key without the management client. A key the proxy does not hold fails at the model call.
  • Two copies of the catalogue merge rule, here and in #1994, and two catalogue readers in cli.mjs.
  • A turn with no model call reads as unknown, so two such turns in a row end the session.
  • A running session keeps the port, key and model it started with.
## What changes The Console gives the Triage host a real route, so Triage can start. Until now it passed `route: null`. - **Route.** Resolved again at each admit from the route store, the key file `<configDir>/secrets/triage/model`, each active organization's model catalogue (merged, then held to `checkRoutes`, called unchanged) and the harness module. The proxy port is read from `proxy.json` at each admit, by the route and again by the host. - **Env.** The route adds only `ANTHROPIC_BASE_URL` (the instance proxy, loopback) and `ANTHROPIC_AUTH_TOKEN` (the Triage key). The host writes the harness bundle and sets the `MOSAIC_` names the module declares. The runner keeps its own names. No name has two sources. - **Harness.** claude-code answers. pi is refused as `triage-harness-incompatible`: it takes its key in another variable and needs a proxy transport. - **Key.** Read at each admit with the key verbs' checks. The reader moved to `packages/cli/src/triage-key-file.mjs`, which imports node built-ins only. The Console never loads the proxy management client or the key verbs' module, and a test fails if it does. The key goes only into the spawn env. If the agent echoes its key in a Triage line, the host replaces it with `[key removed]` before the line is stored. - **Refusals.** Each launches nothing and answers 409 with one plain line: no route, no key, key file unsafe, model not offered, no ready catalogue, harness incompatible, proxy not running. - **Cap fails closed.** Two turns in a row with unknown usage end the session with a host line. The next message starts a fresh session and counts again. This closes the gap #1992 left open. The fresh-start marker survives a Console restart. Jason approved the route design on 2026-11-18 ("route as recommended") and this slice the same day. ## How - `packages/webui/src/triage-route.mjs` (new), `triage-host.mjs`, `triage-http.mjs`, `cli.mjs`, `public/display.js`. - `packages/cli/src/triage-key-file.mjs` (new, moved out of `triage-key.mjs`, which re-exports it). `packages/cli/src/triage.mjs` is untouched. - Tests: `triage-wiring` (new, 18), `triage-host` (49), `triage-key` (22, unchanged). - Nothing under `roles/`, `contracts/`, `packages/bus/`, `packages/queue/`, `packages/organization/` or `packages/plugins/`. No new HTTP route and no new CLI verb. ## Tests - An end-to-end test with a stand-in proxy. A test that runs the real `adapters/claude/adapter.sh` under bwrap with a stub `claude` binary. One test per refusal. A key scan over files, logs, argv, responses and reads. - Mutants: 63 of 65 red. The two survivors look equivalent. One mutant was not run: stopping `MOSAIC_CLAUDE_BIN` reaching the spawn would start the real `/usr/bin/claude`. A unit test covers that line. - Lane gate on 4a8d310cd: 340 files (webui, cli, model-proxy), 3544 pass, 0 fail, 6 skipped (4 `org-quick-live`, 1 `federation-acceptance`, 1 shots). - Lead check on 4a8d310cd in a clean environment: 36 files (the webui triage and proxy tests, the cli triage tests, every model-proxy test, browser, single-pane, w15-shell and agent-drawer), 451 tests, 450 pass, 0 fail, 1 skipped (shots). ## Review Two fresh claude-opus-5-5 reviewers. The first said changes, one P1 and three P3s. The P1: no shipped harness could answer, because the route dropped every `MOSAIC_` name and the host set none. All four are fixed in the second commit. The second reviewer re-checked that commit and approved with no counted findings. The third commit is one comment. ## Left for later - The route does not call the module's `preflight()`, so it does not check which claude binary runs. With `MOSAIC_CLAUDE_BIN` unset the adapter uses `claude` from `/usr/bin` or `/bin`. A binary under HOME is refused only after the route admits. Both fail closed. - pi as Triage's harness. - The host cannot know whether the proxy holds the key without the management client. A key the proxy does not hold fails at the model call. - Two copies of the catalogue merge rule, here and in #1994, and two catalogue readers in `cli.mjs`. - A turn with no model call reads as unknown, so two such turns in a row end the session. - A running session keeps the port, key and model it started with.
jason.woltje added 3 commits 2026-11-18 22:59:18 +00:00
The Triage host got route: null. It now gets a route read fresh at each
admit from the route store, the key file, each active organization's
model catalogue (held to checkRoutes) and the harness module. The spawn
env adds only ANTHROPIC_BASE_URL (the instance proxy) and
ANTHROPIC_AUTH_TOKEN (the Triage key); the host sets every MOSAIC_ name.

The key file reader moves to packages/cli/src/triage-key-file.mjs so the
Console reads the key with the key verbs' checks without loading the
proxy management client; triage-key.mjs re-exports it. Each refusal (no
route, no key, unsafe key, proxy down, model not offered, no catalogue,
harness incompatible) launches nothing and answers 409 with one plain
line. Every admit runs the host's fences on the answer, a session
running or not.

The cap fails closed: two turns in a row with unknown usage end the
session with a host line; the next message starts a new run with a
fresh session directory, and its usage counts again.

#1873, lane triage-wiring
jason.woltje merged commit 4a8d310cd5 into refactor 2026-11-18 22:59:34 +00:00
Sign in to join this conversation.