From 8708d3de141bdbe423bb2130289e9b1203416579 Mon Sep 17 00:00:00 2001 From: Mosaic fleet seat mos Date: Fri, 6 Nov 2026 10:03:54 -0600 Subject: [PATCH] salvage 2026-11-06: uncommitted work from scratch/darkwing-scratch/r130/wt (disk cleanup #824) --- docs/TOOLS.md | 5 +++++ packages/cli/README.md | 13 ++++++++++++- packages/cli/src/cli.mjs | 23 +++++++++++++++++++---- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/docs/TOOLS.md b/docs/TOOLS.md index fc38cefab..13366b63a 100644 --- a/docs/TOOLS.md +++ b/docs/TOOLS.md @@ -351,6 +351,11 @@ check is expected to refuse this restored mixed setup; #225 remains open. Later rollback repeats steps 2-6 with the prior shared copy's full id, each live step again approved by Mos. Nothing prunes copies or removes mosaic-old. +After a switch, the human commands and `--tester` work only through `mosaic` +on PATH; the checkout's `scripts/mosaic` exits 3 with `human-required` or +`tester-required`, and queue writes stay on it ([packages/cli/README.md, One +pinned copy](../packages/cli/README.md#one-pinned-copy-row-85-1579)). + ## Console service (`scripts/webui-service.sh`) ```bash diff --git a/packages/cli/README.md b/packages/cli/README.md index fb4532c84..1757ef1b6 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -86,7 +86,9 @@ mosaic launches list [--json] exception to the agent check above: Mos or a T3 seat may run it for a PM test, and the broker still refuses it under a managed run (`tester-required`) or while the business var `bus.tester` isn't `true` - (`tester-off`), each exit 3. `talk --tester` text must start with + (`tester-off`), each exit 3. Like the human commands, `--tester` works + only from the tree the bus runs from ("One pinned copy" below). + `talk --tester` text must start with `[mos test]`, else exit 2 before any call. The role's reply comes back to the tester, not to the human's inbox. `decide`, `stop` and `launches` take no `--tester` (exit 4). @@ -494,6 +496,15 @@ Each live switch/unit change/stop/start requires Mos's go; agents build and test fixtures only. Restarting the bus ends its sessions, so no PM turn may be in flight. Queue writes stay on the canonical scripts/mosaic. +The human commands and `--tester` run only from the tree the bus runs from +(row 130, #1625). The broker checks the path of the calling human-cli.mjs or +tester-cli.mjs against its own. On a host with a pinned copy that tree is +the copy, and `mosaic` on PATH is the wrapper that runs it. The checkout's +`scripts/mosaic` exits 3 with `human-required` or `tester-required` and +prints one more line: "the bus accepts these commands only from the tree it +runs from; on a pinned host run `mosaic` on PATH". Queue writes still go +through the checkout's `scripts/mosaic`. + ## Notifier The notifier is a child of the host. Each poll (every 30 s) it reads the diff --git a/packages/cli/src/cli.mjs b/packages/cli/src/cli.mjs index a547e36c7..a95eabaab 100644 --- a/packages/cli/src/cli.mjs +++ b/packages/cli/src/cli.mjs @@ -388,12 +388,27 @@ export async function main(argv, io = { env: process.env, stdin: process.stdin, throw usage(); } -if (process.argv[1] === fileURLToPath(import.meta.url)) { +// The broker's human and tester proofs accept only the human-cli.mjs and +// tester-cli.mjs of the tree the bus runs from. Since row 85 that is a +// pinned copy, so the checkout's own scripts/mosaic is refused with these +// codes (row 130). The message stays the bare code: app.mjs reads it. +export const OTHER_TREE = "the bus accepts these commands only from the tree it runs from; on a pinned host run `mosaic` on PATH"; +const OTHER_TREE_CODES = new Set(["human-required", "tester-required"]); + +// main, with a CliError printed to stderr. Returns the exit code. +export async function run(argv, io = { env: process.env, stdin: process.stdin, stdout: process.stdout, stderr: process.stderr }, deps = {}) { try { - await main(process.argv.slice(2)); + await main(argv, io, deps); + return 0; } catch (error) { if (!(error instanceof CliError)) throw error; - process.stderr.write(`mosaic: ${error.message}\n`); - process.exitCode = error.exitCode; + io.stderr.write(`mosaic: ${error.message}\n`); + if (OTHER_TREE_CODES.has(error.code)) io.stderr.write(`mosaic: ${OTHER_TREE}\n`); + return error.exitCode; } } + +if (process.argv[1] === fileURLToPath(import.meta.url)) { + const code = await run(process.argv.slice(2)); + if (code !== 0) process.exitCode = code; +}