fix(webui): triage fences, the host checks a route's env names, mounts and adapter before anything starts (#1873) #1985

Merged
jason.woltje merged 3 commits from triage-fences into refactor 2026-11-16 21:38:56 +00:00
Owner

What changes

The Triage host now checks what a model route hands it before anything is written or started. No route is wired: production still passes route: null, so Triage still does not start and nothing visible changes.

  • Env names. A route's harnessEnv names must be declared by the harness module. Some names are refused even when declared: MOSAIC_, NODE_, LD_, DYLD_, PYTHON, BASH_, GIT_, MALLOC_, NPM_CONFIG_, XDG_, PATH, HOME, TMPDIR, ENV, founder and provider names, and names ending _DIR, _CONF, _CONFIG, _ASKPASS, _CA_BUNDLE or _BASE_URL. Values are short strings with no control characters.
  • Route env. Only the proxy's two names. The base URL must be loopback http with a port. The host's expected port and token shape are checked when the host is given them.
  • Mounts and adapter. At most 8 mounts. Each source and the adapter must resolve, by real path, inside an install root the harness module declares. None may lie in or around the data root, the config directory, HOME, /srv/mosaic or a secrets path. Only HOME may hold the stack's own code. A dest may not be in or around /tmp, the run directory, a system bind or another dest. hostedBinds checks again.
  • Refusal. A refused route answers triage-route-invalid, starts nothing, removes what the start wrote and leaves a host line the owner can read.

How

  • packages/webui/src/triage-host.mjs, packages/seat/src/sandbox.mjs (hostedBinds and new helpers only; binds() and sandboxArgv() are unchanged).
  • packages/plugins/harness/claude-code/index.mjs and pi/index.mjs gain two exports, envNames and installRoots. Launches do not read them. packages/plugins/README.md lists them.
  • No schema, vocabulary, policy or HTTP route change.

Tests

  • triage-host.test.mjs and hosted-binds.test.mjs, each fence red before its change. Mutants over three rounds; in the last, 14 run, 12 red, and a reviewer confirmed the 2 survivors cannot change an outcome.
  • Lane gate on 0de7bd568: 244 files (webui 196, seat 18, harness 30), all exit 0, 4 skipped (org-quick-live).
  • Lead check after rebase onto cb80b2b8a, on bbbefb3f2: 70 files (triage, seat, harness, plugins), 921 tests, 920 pass, 1 fail. The fail is packages/harness/tests/claude-session.test.mjs "row 66 a reply with a tell". It fails the same way on cb80b2b8a without this change, three runs of three, in the Lead's clean environment. The lane's gate passed it. The cause is not known yet.
  • The rebase range-diff shows all three commits unchanged.

Review

Three rounds by fresh claude-opus-5-5 reviewers, each asked to break the fences. Round 1: changes, 1 P2 and 6 P3, all fixed. Re-check 1: approve, 5 P3, all fixed. Re-check 2: approve, 4 P3 left for later.

Left for later

  • The four P3s: a README line, a test for a fixed path that is a link, a real path looked up twice, three optional env names.
  • The host refuses every MOSAIC_ name from a route, so a hosted session's tools and settings must be set by the host itself. That belongs to the lane that wires the route.
  • The exact proxy port and token shape checks need the route store and the key, which do not exist.
  • The claude-session.test.mjs red on the base.
## What changes The Triage host now checks what a model route hands it before anything is written or started. No route is wired: production still passes `route: null`, so Triage still does not start and nothing visible changes. - **Env names.** A route's `harnessEnv` names must be declared by the harness module. Some names are refused even when declared: `MOSAIC_`, `NODE_`, `LD_`, `DYLD_`, `PYTHON`, `BASH_`, `GIT_`, `MALLOC_`, `NPM_CONFIG_`, `XDG_`, `PATH`, `HOME`, `TMPDIR`, `ENV`, founder and provider names, and names ending `_DIR`, `_CONF`, `_CONFIG`, `_ASKPASS`, `_CA_BUNDLE` or `_BASE_URL`. Values are short strings with no control characters. - **Route env.** Only the proxy's two names. The base URL must be loopback http with a port. The host's expected port and token shape are checked when the host is given them. - **Mounts and adapter.** At most 8 mounts. Each source and the adapter must resolve, by real path, inside an install root the harness module declares. None may lie in or around the data root, the config directory, HOME, `/srv/mosaic` or a secrets path. Only HOME may hold the stack's own code. A dest may not be in or around `/tmp`, the run directory, a system bind or another dest. `hostedBinds` checks again. - **Refusal.** A refused route answers `triage-route-invalid`, starts nothing, removes what the start wrote and leaves a host line the owner can read. ## How - `packages/webui/src/triage-host.mjs`, `packages/seat/src/sandbox.mjs` (`hostedBinds` and new helpers only; `binds()` and `sandboxArgv()` are unchanged). - `packages/plugins/harness/claude-code/index.mjs` and `pi/index.mjs` gain two exports, `envNames` and `installRoots`. Launches do not read them. `packages/plugins/README.md` lists them. - No schema, vocabulary, policy or HTTP route change. ## Tests - `triage-host.test.mjs` and `hosted-binds.test.mjs`, each fence red before its change. Mutants over three rounds; in the last, 14 run, 12 red, and a reviewer confirmed the 2 survivors cannot change an outcome. - Lane gate on 0de7bd568: 244 files (webui 196, seat 18, harness 30), all exit 0, 4 skipped (`org-quick-live`). - Lead check after rebase onto cb80b2b8a, on bbbefb3f2: 70 files (triage, seat, harness, plugins), 921 tests, 920 pass, 1 fail. The fail is `packages/harness/tests/claude-session.test.mjs` "row 66 a reply with a tell". It fails the same way on cb80b2b8a without this change, three runs of three, in the Lead's clean environment. The lane's gate passed it. The cause is not known yet. - The rebase range-diff shows all three commits unchanged. ## Review Three rounds by fresh claude-opus-5-5 reviewers, each asked to break the fences. Round 1: changes, 1 P2 and 6 P3, all fixed. Re-check 1: approve, 5 P3, all fixed. Re-check 2: approve, 4 P3 left for later. ## Left for later - The four P3s: a README line, a test for a fixed path that is a link, a real path looked up twice, three optional env names. - The host refuses every `MOSAIC_` name from a route, so a hosted session's tools and settings must be set by the host itself. That belongs to the lane that wires the route. - The exact proxy port and token shape checks need the route store and the key, which do not exist. - The `claude-session.test.mjs` red on the base.
jason.woltje added 3 commits 2026-11-16 21:38:53 +00:00
jason.woltje merged commit bbbefb3f28 into refactor 2026-11-16 21:38:56 +00:00
Sign in to join this conversation.