Files
stack/packages/cli/tests/other-tree.test.mjs
T
jason.woltjeandClaude Opus 5.5 30d008090e cli: hint at the pinned mosaic when the bus refuses another tree's proof (row 130, #1625)
When the broker answers human-required or tester-required, the CLI
now prints a second line saying the bus accepts these commands only
from its own tree and to run `mosaic` on PATH on a pinned host. The
entry block becomes an exported run(); exit codes are unchanged.

Lands Darkwing's row 130 round 1 candidate, approved by Filbert in
comment 28520 (rev 1228). Candidate manifest 9a5de54d, all four files
match. Landing gate on 9e837ce5f: 23 suites, GATE_PASSED 00:44:07Z.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 19:44:35 -05:00

45 lines
2.3 KiB
JavaScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { OTHER_TREE, run } from "../src/cli.mjs";
import { humanTransport } from "../src/transport.mjs";
import { humanEnv, io, tmp } from "./helpers.mjs";
// Row 130 (#1625): the broker accepts the human and tester proofs only from
// the tree the bus runs from, so a refusal with human-required or
// tester-required gets one more stderr line naming the command that works.
// The spawn stands in for human-cli.mjs and tester-cli.mjs: it exits 1 with
// the code on stderr, and the real transport parses it.
const refusing = (code) => () => ({ status: 1, stdout: "", stderr: `${code}\n` });
const HINT = `mosaic: ${OTHER_TREE}\n`;
test("a human command refused with human-required prints the other-tree line and exits 3", async (t) => {
const x = io();
const transport = (business) => humanTransport({ socket: "/nonexistent/bus.sock", business, env: {}, spawn: refusing("human-required") });
const code = await run(["inbox", "--business", "demo"], x, { system: { dataRoot: tmp(t) }, transport });
assert.equal(code, 3);
assert.equal(x.err.text, `mosaic: human-required\n${HINT}`);
assert.equal(x.out.text, "");
});
test("a --tester command refused with tester-required prints the other-tree line and exits 3", async (t) => {
const x = io({ ...humanEnv(), CLAUDECODE: "1" });
const code = await run(["agents", "--tester", "--business", "demo"], x, { system: { dataRoot: tmp(t) }, testerSpawn: refusing("tester-required") });
assert.equal(code, 3);
assert.equal(x.err.text, `mosaic: tester-required\n${HINT}`);
});
test("other exit-3 refusals print no other-tree line", async (t) => {
const off = io({ ...humanEnv(), CLAUDECODE: "1" });
assert.equal(await run(["agents", "--tester", "--business", "demo"], off, { system: { dataRoot: tmp(t) }, testerSpawn: refusing("tester-off") }), 3);
assert.equal(off.err.text, "mosaic: tester-off\n");
const agent = io({ ...humanEnv(), CLAUDECODE: "1" });
assert.equal(await run(["inbox", "--business", "demo"], agent, { system: { dataRoot: tmp(t) } }), 3);
assert.match(agent.err.text, /^mosaic: refused: this runs only from a human shell/);
assert.doesNotMatch(agent.err.text, /tree it runs from/);
});
test("the line names no path", () => {
assert.doesNotMatch(OTHER_TREE, /\//);
});