feat(webui): the Triage session's server side, a sandboxed host, relay, health snapshot and owner-only routes (#1873) #1983

Merged
jason.woltje merged 7 commits from triage-host into refactor 2026-11-16 20:05:52 +00:00
Owner

What changes

The server side of Triage: a read-only diagnostic session the Console hosts in no organization, for the instance owner only. No drawer, no page and no CLI verb yet.

With this change nothing launches in production. The model route is not wired (route: null), so GET /api/triage says the route is not set and Triage does not start. See Left for later.

  • Health snapshot. The Console writes one JSON file from reads that exist: Console, model proxy, system config validity, and per organization the bus state, processing and config validity. Fixed field list. States, times, counts and codes only. A read that fails says "not read".
  • Cards. A reply may carry cards as {step, org}. The step comes from a fixed list of five existing steps and the org must be in the registry. The server renders the command text. Anything else is dropped. A card is text to read; there is no Run action.
  • Host. A sandboxed harness launch of the triage template on the owner's first message, never at Console start. Under <dataRoot>/triage/: health/ mounted read-only, agent/ mounted read-write, host/ (transcript, 0600) not mounted. No organization root, bus socket, config directory or secrets directory in the mount. The spawn environment is a fixed allowlist.
  • Relay. Answers only a message.send to the human, plus the read verbs the runner needs. Every other verb, decision.raise included, is refused with the one code triage-refused.
  • Routes. GET /api/triage and POST /api/triage/message answer only the instance owner's own session. Everyone else gets byte-for-byte what an unknown route gives that caller. The write also needs --send and the same-origin gates.
  • Cap. The host refuses without a route, and holds a route's over-cap answer until its time.

How

  • New: packages/webui/src/triage-snapshot.mjs, triage-cards.mjs, triage-host.mjs, triage-http.mjs. Wired in serve.mjs and cli.mjs.
  • packages/seat/src/sandbox.mjs gains hostedBinds and hostedArgv. The existing binds() and sandboxArgv() are unchanged, so no other agent's mount changed.
  • Nothing under contracts/ or roles/, no schema change, no change to the bus broker.

Tests

  • New: triage-cards, triage-host, triage-http, triage-snapshot in webui and hosted-binds in seat, 49 tests. The end-to-end test probes from inside the sandbox: it cannot see an org file, a config file, a secrets file or the host's transcript, and the bundle and health/ refuse writes. The route tests compare each refused caller against an unknown route. No real model call is made.
  • Lane: full webui sweep 196 files 1587 pass, 0 fail, 4 skipped, then 37 files 769 pass, 0 fail at the lane's last commit. Mutants on the review fixes: 22 run, 21 red; the survivor cannot be reached.
  • Lead check after rebase onto 6fe3625fa: 226 files (all webui, all seat, and the tests that load the Console CLI), 2401 tests, 2395 pass, 1 fail, 5 skipped. The fail is packages/seat/tests/landing.test.mjs "runGate: an abort stops the running step", a file this change does not touch. Run alone it passes 8/8.
  • After the last review fix: the five triage files, 48 pass, 0 fail. The two new assertions fail on the source before the fix.

Review

Three fresh claude-opus-5-5 reviewers, each asked to attack the boundary: what the agent can read, what it can cause to run, who can reach the routes, what leaves in the snapshot.

  • Review 1: changes, 2 P1, 2 P2, 5 P3. All fixed.
  • Re-check: approve, 5 new P3, all fixed.
  • Final review on the rebased branch: no P1, 1 P2, 6 P3. The P2 is fixed in the last commit: a reply's in_reply_to is kept only when it is an id the host issued. One P3 is fixed there too: the text cleaner now also removes U+061C, U+180E, U+2028, U+2029 and U+FEFF.

Left for later

  • The owner-set model route and daily token cap have no store. Limits today are per organization on each bus, and instance settings has no Triage field. That needs a schema change and the owner's ruling.
  • Before any route is wired: the route's harnessEnv check is a denylist and must become an allowlist, and harnessMounts must be fenced.
  • One 5 s deadline covers all organization reads, so on a loaded host with many organizations some can read "not read".
  • A progress note that names its message settles it, so a kill after that leaves no "unanswered" line.
  • After a hard Console death the detached runner lives until its relay calls fail.
  • Two snapshot timing tests have tight margins.
  • Drawer, CLI verb, run records and logs, Run buttons.
## What changes The server side of Triage: a read-only diagnostic session the Console hosts in no organization, for the instance owner only. No drawer, no page and no CLI verb yet. With this change nothing launches in production. The model route is not wired (`route: null`), so `GET /api/triage` says the route is not set and Triage does not start. See Left for later. - **Health snapshot.** The Console writes one JSON file from reads that exist: Console, model proxy, system config validity, and per organization the bus state, processing and config validity. Fixed field list. States, times, counts and codes only. A read that fails says "not read". - **Cards.** A reply may carry cards as `{step, org}`. The step comes from a fixed list of five existing steps and the org must be in the registry. The server renders the command text. Anything else is dropped. A card is text to read; there is no Run action. - **Host.** A sandboxed harness launch of the `triage` template on the owner's first message, never at Console start. Under `<dataRoot>/triage/`: `health/` mounted read-only, `agent/` mounted read-write, `host/` (transcript, 0600) not mounted. No organization root, bus socket, config directory or secrets directory in the mount. The spawn environment is a fixed allowlist. - **Relay.** Answers only a `message.send` to the human, plus the read verbs the runner needs. Every other verb, `decision.raise` included, is refused with the one code `triage-refused`. - **Routes.** `GET /api/triage` and `POST /api/triage/message` answer only the instance owner's own session. Everyone else gets byte-for-byte what an unknown route gives that caller. The write also needs `--send` and the same-origin gates. - **Cap.** The host refuses without a route, and holds a route's over-cap answer until its time. ## How - New: `packages/webui/src/triage-snapshot.mjs`, `triage-cards.mjs`, `triage-host.mjs`, `triage-http.mjs`. Wired in `serve.mjs` and `cli.mjs`. - `packages/seat/src/sandbox.mjs` gains `hostedBinds` and `hostedArgv`. The existing `binds()` and `sandboxArgv()` are unchanged, so no other agent's mount changed. - Nothing under `contracts/` or `roles/`, no schema change, no change to the bus broker. ## Tests - New: `triage-cards`, `triage-host`, `triage-http`, `triage-snapshot` in webui and `hosted-binds` in seat, 49 tests. The end-to-end test probes from inside the sandbox: it cannot see an org file, a config file, a secrets file or the host's transcript, and the bundle and `health/` refuse writes. The route tests compare each refused caller against an unknown route. No real model call is made. - Lane: full webui sweep 196 files 1587 pass, 0 fail, 4 skipped, then 37 files 769 pass, 0 fail at the lane's last commit. Mutants on the review fixes: 22 run, 21 red; the survivor cannot be reached. - Lead check after rebase onto 6fe3625fa: 226 files (all webui, all seat, and the tests that load the Console CLI), 2401 tests, 2395 pass, 1 fail, 5 skipped. The fail is `packages/seat/tests/landing.test.mjs` "runGate: an abort stops the running step", a file this change does not touch. Run alone it passes 8/8. - After the last review fix: the five triage files, 48 pass, 0 fail. The two new assertions fail on the source before the fix. ## Review Three fresh claude-opus-5-5 reviewers, each asked to attack the boundary: what the agent can read, what it can cause to run, who can reach the routes, what leaves in the snapshot. - Review 1: changes, 2 P1, 2 P2, 5 P3. All fixed. - Re-check: approve, 5 new P3, all fixed. - Final review on the rebased branch: no P1, 1 P2, 6 P3. The P2 is fixed in the last commit: a reply's `in_reply_to` is kept only when it is an id the host issued. One P3 is fixed there too: the text cleaner now also removes U+061C, U+180E, U+2028, U+2029 and U+FEFF. ## Left for later - The owner-set model route and daily token cap have no store. Limits today are per organization on each bus, and instance settings has no Triage field. That needs a schema change and the owner's ruling. - Before any route is wired: the route's `harnessEnv` check is a denylist and must become an allowlist, and `harnessMounts` must be fenced. - One 5 s deadline covers all organization reads, so on a loaded host with many organizations some can read "not read". - A progress note that names its message settles it, so a kill after that leaves no "unanswered" line. - After a hard Console death the detached runner lives until its relay calls fail. - Two snapshot timing tests have tight margins. - Drawer, CLI verb, run records and logs, Run buttons.
jason.woltje added 7 commits 2026-11-16 20:05:48 +00:00
The snapshot is one 0600 JSON file with a fixed field list: the Console's
answer, the model proxy unit, the system config check, and each active org's
bus state, last start, processing and org config check. States, times, counts
and codes only; a read that fails or hangs says "not read". The system config
check runs scripts/mosaic-config.mjs validate in a child with stdout ignored and
keeps the exit code and one fixed refusal code; the org config check keeps its
exit code only. Cards are { step, org } with a known step and a registered org;
the server renders the command and drops anything else.
The Console holds <dataRoot>/triage/ (0700): health/ mounted read-only at
work/health inside the session, agent/ the session's own run directory, and
host/ with the 0600 transcript and the runner's log, never mounted. The seat
package's new hostedBinds and hostedArgv give the session the system part,
the runner's files, the adapter and those two directories, and nothing else
of the data root: no org root, bus socket, config or secrets, and no git
identity. Each source inside agent/ is made fresh at start (rm never follows
a link), and hostedBinds refuses a link in place of any of them.

The spawn environment is PATH (fixed), LANG, LC_ALL, TZ, TERM and the
route's ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY; bwrap
sets HOME and TMPDIR. A route answer whose harnessEnv names MOSAIC_CONFIG,
a MOSAIC_BUS_ variable or a founder credential variable is refused.

The relay is the only broker the runner reaches. It answers the runner's
lifecycle verbs with fixed answers, hands over the owner's messages, and keeps
a message.send only when it is addressed to "human": its text goes to the
transcript with its cards checked. Every other verb, a send to anyone else
and a call without the capability are refused with triage-refused.

The model route is injected; without one nothing launches (triage-no-route),
and a route over its cap refuses with triage-over-cap and its until. The
tests run the session end to end under bwrap with a stub adapter.
P1-1: the organizations branch lets the instance owner's own session through to the two Triage paths;
everyone else still gets this Console's unknown /api/ answer.
P1-2: each start clears turns/, so the runner's numbered turn files do not collide on restart.
P2-1: on exit, a message the session took and never marked read leaves the queue with a host line.
P2-2: member, signed-out, organizations-Console and org-selected route tests.
P3-1: bus-start cards carry --dev-local-owner on a dev local owner Console.
P3-2: a failed start writes a host line; the queue index is guarded.
P3-3: one shared refresh, a unique temp name per write, four organizations read at a time.
P3-4: the restart path waits for stop() inside its two-second exit.
P3-5: ANTHROPIC_API_KEY no longer passes from the route.
jason.woltje merged commit 820f45e474 into refactor 2026-11-16 20:05:52 +00:00
Sign in to join this conversation.