feat(webui): triage fences, the host checks a copy of the route's answer before anything is written or spawned: harnessEnv names must be declared by the harness module and are refused outright when MOSAIC_, NODE_, LD_, DYLD_, PYTHON, BASH_, GIT_, PATH, HOME, TMPDIR, ENV, a founder or a provider name; values are short clean strings; route env holds only the proxy's two names with a loopback base URL, and the host's port and token shape when given; the adapter and at most 8 mounts resolve inside the module's install roots and never in or around the data root, the config dir, HOME, /srv/mosaic or a secrets path, with dests clear of /tmp, the run dir and the system binds, checked again in hostedBinds; a refused answer answers triage-route-invalid and leaves a host line (#1873, lane triage-fences)
This commit is contained in:
1 parent
cb80b2b8a8
commit
1ca3a38f86
7 files changed
+508
-50
No files matched your search
@@ -258,6 +258,19 @@ export returns:
|
||||
`gateTimeout`, `bundle`, `env`, `turnEnd`, `outputPolicy` and `transcript` give its
|
||||
sandbox binds, web, tool names, S0 lines, bundle files, adapter variables,
|
||||
how a turn ends and where its transcripts land.
|
||||
- `envNames` and `installRoots({env})` (#1873 triage-fences) are optional and
|
||||
outside `kinds.mjs`. A session the Console hosts with no organization
|
||||
(Triage) reads them; organization launches do not. `envNames` lists the
|
||||
names `env()` returns, less the provider's. The host takes a route's
|
||||
`harnessEnv` name only when it is listed here and is not one the host
|
||||
always refuses: `MOSAIC_*`, `NODE_*`, `LD_*`, `DYLD_*`, `PYTHON*`, `BASH_*`,
|
||||
`GIT_*`, PATH, HOME, TMPDIR, ENV, the founder's and the provider's names
|
||||
and a few shell and proxy names. `installRoots` lists the directories
|
||||
where the adapter and the mounts live. A hosted adapter or mount source
|
||||
must resolve inside one of them, and never in or around the data root,
|
||||
the config directory, HOME, `/srv/mosaic` or a path with a `secret`
|
||||
segment. Every claude-code name is `MOSAIC_*`, so a hosted session cannot
|
||||
run Claude Code yet.
|
||||
- `compactions({store, cursors, budget, streams, first})` reads a thread
|
||||
session's native store for row 270's compaction count (row 307). Core keeps
|
||||
the ledger (`packages/seat/src/compactions.mjs`) and passes `store` as
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// session.json. packages/plugins/README.md lists the interface.
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { accessSync, constants, realpathSync, statSync } from "node:fs";
|
||||
import { delimiter, isAbsolute, join } from "node:path";
|
||||
import { delimiter, dirname, isAbsolute, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { claudeBuiltins, MCP_PREFIX } from "../../../harness/src/gate.mjs";
|
||||
import { hasSessionCredential, SESSION_CREDENTIALS } from "../../../seat/src/session.mjs";
|
||||
@@ -145,6 +145,16 @@ export function env({ files, policy, session, proxy = null }) {
|
||||
};
|
||||
}
|
||||
|
||||
// #1873 triage-fences: the names env() returns, less the proxy's, and the directories its adapter
|
||||
// and mounts live in: the pinned binary's when MOSAIC_CLAUDE_BIN is set. A hosted session's host
|
||||
// (Triage) takes harnessEnv names and mount sources only from these; launches don't read them.
|
||||
export const envNames = Object.freeze(["MOSAIC_TOOLS", "MOSAIC_CLAUDE_SETTINGS", "MOSAIC_CLAUDE_MCP_CONFIG", "MOSAIC_THINKING", "MOSAIC_MODEL_ACTIVITY_SOURCE"]);
|
||||
export function installRoots({ env = {} } = {}) {
|
||||
const roots = [join(REPO, "adapters", "claude"), join(REPO, "tools", "unslop-hook")];
|
||||
if (env.MOSAIC_CLAUDE_BIN) roots.push(dirname(realpathSync(env.MOSAIC_CLAUDE_BIN)));
|
||||
return roots;
|
||||
}
|
||||
|
||||
// A turn ends when claude exits; there is no marker.
|
||||
export const turnEnd = () => "exit";
|
||||
export const transcript = ({ runDir, store = null }) => (store ? store.projects : join(runDir, "home", ".claude", "projects"));
|
||||
|
||||
@@ -118,6 +118,12 @@ export function env({ policy, tools, session, proxy = null }) {
|
||||
};
|
||||
}
|
||||
|
||||
// #1873 triage-fences: the names env() returns, less the provider key, and the directories its
|
||||
// adapter and mounts live in. A hosted session's host (Triage) takes harnessEnv names and mount
|
||||
// sources only from these; launches don't read them.
|
||||
export const envNames = Object.freeze(["PI_OFFLINE", "MOSAIC_TOOLS", "MOSAIC_EXTENSIONS", "PI_PROVIDER", "PI_MODEL", "MOSAIC_THINKING"]);
|
||||
export const installRoots = () => [join(REPO, "adapters", "pi"), join(REPO, "packages", "plugins", "harness", "pi"), realpathSync(join(REPO, "node_modules")), join(REPO, "tools", "unslop-hook")];
|
||||
|
||||
// The extension writes the turn marker at agent_end; an exit without it is a failed turn.
|
||||
export const turnEnd = () => "marker";
|
||||
export const transcript = ({ runDir, store = null }) => (store ? store.session : join(runDir, "session"));
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
// the launch (sandbox-unavailable).
|
||||
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { existsSync, lstatSync, mkdirSync, readlinkSync, realpathSync } from "node:fs";
|
||||
import { existsSync, lstatSync, mkdirSync, readlinkSync, realpathSync, statSync } from "node:fs";
|
||||
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { ID_PATTERN } from "../../organization/src/vocabulary.mjs";
|
||||
@@ -193,6 +193,84 @@ export function sandboxArgv(list, runDir, command, { business, role, bwrap = BWR
|
||||
return [bwrap, ...NAMESPACES, ...argsOf(list), "--remount-ro", "/", "--setenv", "HOME", join(runDir, "home"), "--setenv", "TMPDIR", "/tmp", ...identity, "--chdir", runDir, "--", ...KILL_WITH_PARENT, ...command];
|
||||
}
|
||||
|
||||
// #1873 triage-fences: what a model route may hand a hosted session, checked before the host
|
||||
// writes anything and again in hostedBinds. The adapter and each mount's source must be a clean
|
||||
// absolute path whose real path lies under one of the harness module's install roots, named under
|
||||
// that same root, and outside every protected path: the data root, the config directory and HOME
|
||||
// the caller passes, the run directory, ALWAYS_PROTECTED, and any path with a segment that
|
||||
// contains "secret" in any case. A protected path counts in its own spelling and its real path, and
|
||||
// a source may neither lie inside one nor contain one. The bind's source is the real path, so a
|
||||
// link swapped after the check cannot steer it. A mount's dest (its source when it names none) is
|
||||
// never /tmp, the run directory or a system bind's dest, nor inside or around one, never a parent
|
||||
// of or equal to a runner file, the adapter or node, and never repeated. At most
|
||||
// HOSTED_MOUNTS_MAX mounts. A refusal is a HostedRouteError naming its fence, never a path.
|
||||
export const HOSTED_MOUNTS_MAX = 8;
|
||||
const ROOTS_MAX = 16;
|
||||
const PATH_MAX = 4096;
|
||||
const ALWAYS_PROTECTED = Object.freeze(["/srv/mosaic", "/proc", "/sys", "/dev", "/run", "/root", "/boot"]);
|
||||
const MOUNT_KEYS = Object.freeze(["src", "dest", "why"]);
|
||||
|
||||
export class HostedRouteError extends Error {
|
||||
constructor(fence, message) {
|
||||
super(`hosted binds: ${message}`);
|
||||
this.code = "hosted-binds-refused";
|
||||
this.fence = fence;
|
||||
}
|
||||
}
|
||||
const refuseRoute = (fence, message) => { throw new HostedRouteError(fence, message); };
|
||||
|
||||
// Absolute, already normal (no "..", ".", "//" or trailing slash), not "/", no NUL.
|
||||
const cleanPath = (p) => typeof p === "string" && p.length > 1 && p.length <= PATH_MAX && !p.includes("\0") && isAbsolute(p) && resolve(p) === p;
|
||||
const within = (child, parent) => child === parent || child.startsWith(parent + "/");
|
||||
const overlaps = (a, b) => within(a, b) || within(b, a);
|
||||
const secretPath = (p) => p.split("/").some((seg) => /secret/i.test(seg));
|
||||
const realOr = (p) => { try { return realpathSync(p); } catch { return p; } };
|
||||
const plainObject = (o) => o !== null && typeof o === "object" && !Array.isArray(o) && [Object.prototype, null].includes(Object.getPrototypeOf(o));
|
||||
|
||||
export function checkHostedRoute({ adapter, harnessMounts, installRoots, protectedPaths, runDir, node = process.execPath }) {
|
||||
if (!cleanPath(runDir)) refuseRoute("protected", "the run directory is not a clean absolute path");
|
||||
if (!Array.isArray(protectedPaths)) refuseRoute("protected", "no protected paths were given");
|
||||
const guarded = [];
|
||||
for (const p of [...ALWAYS_PROTECTED, ...protectedPaths, runDir]) {
|
||||
if (!cleanPath(p)) refuseRoute("protected", "a protected path is not a clean absolute path");
|
||||
guarded.push(p, realOr(p));
|
||||
}
|
||||
if (!Array.isArray(installRoots) || installRoots.length === 0 || installRoots.length > ROOTS_MAX) refuseRoute("roots", "the harness module declares no usable install roots");
|
||||
const roots = installRoots.map((r) => {
|
||||
if (!cleanPath(r)) refuseRoute("roots", "an install root is not a clean absolute path");
|
||||
let real;
|
||||
try { real = realpathSync(r); } catch { refuseRoute("roots", "an install root is missing"); }
|
||||
if (real === "/" || !statSync(real).isDirectory()) refuseRoute("roots", "an install root is not a directory");
|
||||
return { named: r, real };
|
||||
});
|
||||
const source = (src, fence, what) => {
|
||||
if (!cleanPath(src)) refuseRoute(fence, `${what} is not a clean absolute path`);
|
||||
let real;
|
||||
try { real = realpathSync(src); } catch { refuseRoute(fence, `${what} is missing`); }
|
||||
if (!roots.some((r) => (within(src, r.named) || within(src, r.real)) && within(real, r.real))) refuseRoute(fence, `${what} is not under an install root`);
|
||||
if ([src, real].some((p) => guarded.some((g) => overlaps(p, g)))) refuseRoute(fence, `${what} is in or around a protected path`);
|
||||
if ([src, real].some(secretPath)) refuseRoute(fence, `${what} is in a secrets path`);
|
||||
return real;
|
||||
};
|
||||
const adapterReal = source(adapter, "adapter", "the adapter");
|
||||
if (!statSync(adapterReal).isFile()) refuseRoute("adapter", "the adapter is not a file");
|
||||
if (!Array.isArray(harnessMounts) || harnessMounts.length > HOSTED_MOUNTS_MAX) refuseRoute("mounts", `a hosted session takes at most ${HOSTED_MOUNTS_MAX} harness mounts`);
|
||||
const apart = ["/tmp", runDir, ...systemBinds(node).map((b) => b.dest ?? b.src)];
|
||||
const kept = [...RUNNER_FILES, adapter, node];
|
||||
const dests = new Set();
|
||||
const mounts = harnessMounts.map((m, i) => {
|
||||
const what = `harness mount ${i + 1}`;
|
||||
if (!plainObject(m) || Object.keys(m).some((k) => !MOUNT_KEYS.includes(k)) || typeof m.why !== "string" || !m.why || m.why.length > 256) refuseRoute("mounts", `${what} is not { src, dest, why }`);
|
||||
if (m.dest !== undefined && !cleanPath(m.dest)) refuseRoute("mount-dest", `${what}'s dest is not a clean absolute path`);
|
||||
const real = source(m.src, "mount-src", what);
|
||||
const dest = m.dest ?? m.src;
|
||||
if (apart.some((p) => overlaps(dest, p)) || kept.some((p) => within(p, dest)) || dests.has(dest)) refuseRoute("mount-dest", `${what}'s dest would cover a path the session needs`);
|
||||
dests.add(dest);
|
||||
return { src: real, dest, why: m.why };
|
||||
});
|
||||
return { adapter: { src: adapterReal, dest: adapter }, mounts };
|
||||
}
|
||||
|
||||
// #1873 triage-host: the binds for a session the Console hosts in no organization (Triage). It
|
||||
// gets the system part, the runner's files, the adapter and the harness module's mounts like any
|
||||
// session, and from the data root exactly two directories: its own `runDir` read-write, and
|
||||
@@ -200,7 +278,9 @@ export function sandboxArgv(list, runDir, command, { business, role, bwrap = BWR
|
||||
// calls through stay read-only inside it, and its tmp/ is /tmp. There is no workspace, broker,
|
||||
// launch or git socket, thread store or org root. Each source inside runDir must be what the host
|
||||
// just made there, never a link the session left: bwrap resolves a bind's source on the host.
|
||||
export function hostedBinds({ runDir, healthDir, adapter, harnessMounts = [], relaySocket, node = process.execPath, readOnly = [] }) {
|
||||
// The adapter and the mounts pass checkHostedRoute against `installRoots` and `protectedPaths`
|
||||
// here too; without install roots nothing binds.
|
||||
export function hostedBinds({ runDir, healthDir, adapter, harnessMounts = [], installRoots, protectedPaths, relaySocket, node = process.execPath, readOnly = [] }) {
|
||||
if (relaySocket !== join(runDir, "relay.sock")) throw new Error("hosted binds: the relay socket must be the run directory's relay.sock");
|
||||
const healthDest = join(runDir, "work", "health");
|
||||
for (const p of [runDir, healthDir, join(runDir, "bundle"), join(runDir, "tmp"), join(runDir, "work"), healthDest]) {
|
||||
@@ -213,10 +293,11 @@ export function hostedBinds({ runDir, healthDir, adapter, harnessMounts = [], re
|
||||
try { st = lstatSync(p); } catch { throw new Error(`hosted binds: ${relative(runDir, p)} is missing`); }
|
||||
if (!ok(st)) throw new Error(`hosted binds: ${relative(runDir, p)} is not what the host made`);
|
||||
}
|
||||
const route = checkHostedRoute({ adapter, harnessMounts, installRoots, protectedPaths, runDir, node });
|
||||
const out = systemBinds(node);
|
||||
for (const f of RUNNER_FILES) out.push({ kind: "ro", src: f, why: "a repository file the runner loads" });
|
||||
out.push({ kind: "ro", src: adapter, why: "the harness adapter the runner starts each turn" });
|
||||
for (const m of harnessMounts) out.push({ kind: "ro", src: m.src, ...(m.dest ? { dest: m.dest } : {}), why: m.why });
|
||||
out.push({ kind: "ro", src: route.adapter.src, ...(route.adapter.src !== adapter ? { dest: adapter } : {}), why: "the harness adapter the runner starts each turn" });
|
||||
for (const m of route.mounts) out.push({ kind: "ro", src: m.src, ...(m.dest !== m.src ? { dest: m.dest } : {}), why: m.why });
|
||||
for (const f of readOnly) out.push({ kind: "ro", src: f, why: "a test fixture" });
|
||||
out.push(
|
||||
{ kind: "rw", src: runDir, why: "the session's own state: turns/, session/, work/, tools.sock, turn.done, home/, tmp/" },
|
||||
|
||||
@@ -5,8 +5,8 @@ import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { createServer } from "node:net";
|
||||
import { mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { RUNNER_FILES, hostedArgv, hostedBinds } from "../src/sandbox.mjs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { HOSTED_MOUNTS_MAX, RUNNER_FILES, hostedArgv, hostedBinds } from "../src/sandbox.mjs";
|
||||
|
||||
function layout(t) {
|
||||
const root = mkdtempSync(join(process.env.TMPDIR, "hb-"));
|
||||
@@ -15,19 +15,21 @@ function layout(t) {
|
||||
const healthDir = join(dataRoot, "triage", "health");
|
||||
for (const d of [join(dataRoot, "orgs"), join(dataRoot, "triage", "host"), healthDir, join(runDir, "bundle"), join(runDir, "tmp"), join(runDir, "work", "health")]) mkdirSync(d, { recursive: true });
|
||||
writeFileSync(join(runDir, "session.json"), "{}");
|
||||
const adapter = join(root, "adapter.sh");
|
||||
const install = join(root, "install");
|
||||
mkdirSync(install);
|
||||
const adapter = join(install, "adapter.sh");
|
||||
writeFileSync(adapter, "exit 0\n");
|
||||
return new Promise((resolve) => {
|
||||
const server = createServer().listen(join(runDir, "relay.sock"), () => {
|
||||
t.after(() => server.close());
|
||||
resolve({ root, dataRoot, runDir, healthDir, adapter, relaySocket: join(runDir, "relay.sock") });
|
||||
resolve({ root, dataRoot, runDir, healthDir, adapter, install, relaySocket: join(runDir, "relay.sock"), installRoots: [install], protectedPaths: [dataRoot] });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
test("hosted binds hold the run directory and the health directory of the data root, and nothing else of it", async (t) => {
|
||||
const p = await layout(t);
|
||||
const list = hostedBinds({ runDir: p.runDir, healthDir: p.healthDir, adapter: p.adapter, relaySocket: p.relaySocket });
|
||||
const list = hostedBinds({ runDir: p.runDir, healthDir: p.healthDir, adapter: p.adapter, relaySocket: p.relaySocket, installRoots: p.installRoots, protectedPaths: p.protectedPaths });
|
||||
const fromData = list.filter((b) => typeof b.src === "string" && b.src.startsWith(p.dataRoot + "/"));
|
||||
assert.deepEqual(fromData.map((b) => [b.kind, b.src, b.dest ?? null]), [
|
||||
["rw", p.runDir, null],
|
||||
@@ -46,7 +48,7 @@ test("hosted binds hold the run directory and the health directory of the data r
|
||||
|
||||
test("hosted binds refuse a relay socket elsewhere, and any source in the run directory that the host did not make", async (t) => {
|
||||
const p = await layout(t);
|
||||
const base = { runDir: p.runDir, healthDir: p.healthDir, adapter: p.adapter, relaySocket: p.relaySocket };
|
||||
const base = { runDir: p.runDir, healthDir: p.healthDir, adapter: p.adapter, relaySocket: p.relaySocket, installRoots: p.installRoots, protectedPaths: p.protectedPaths };
|
||||
assert.throws(() => hostedBinds({ ...base, relaySocket: join(p.root, "bus.sock") }), /relay socket must be the run directory's relay\.sock/);
|
||||
// A link in place of each directory the binds read: bwrap would follow it on the host.
|
||||
for (const d of ["bundle", "tmp", "work"]) {
|
||||
@@ -72,7 +74,7 @@ test("hosted binds refuse a relay socket elsewhere, and any source in the run di
|
||||
|
||||
test("the hosted command line sets no git identity and runs the command under the namespaces", async (t) => {
|
||||
const p = await layout(t);
|
||||
const argv = hostedArgv(hostedBinds({ runDir: p.runDir, healthDir: p.healthDir, adapter: p.adapter, relaySocket: p.relaySocket }), p.runDir, ["node", "runner.mjs", p.runDir], { bwrap: "/b/bwrap" });
|
||||
const argv = hostedArgv(hostedBinds({ runDir: p.runDir, healthDir: p.healthDir, adapter: p.adapter, relaySocket: p.relaySocket, installRoots: p.installRoots, protectedPaths: p.protectedPaths }), p.runDir, ["node", "runner.mjs", p.runDir], { bwrap: "/b/bwrap" });
|
||||
assert.equal(argv[0], "/b/bwrap");
|
||||
assert.deepEqual(argv.slice(1, 5), ["--unshare-user", "--unshare-pid", "--unshare-ipc", "--as-pid-1"]);
|
||||
assert.deepEqual(argv.slice(-3), ["node", "runner.mjs", p.runDir]);
|
||||
@@ -81,3 +83,52 @@ test("the hosted command line sets no git identity and runs the command under th
|
||||
assert.equal(argv[home + 1], join(p.runDir, "home"));
|
||||
assert.ok(argv.includes("--remount-ro"));
|
||||
});
|
||||
|
||||
// #1873 triage-fences: hostedBinds checks the adapter and the mounts again, so a caller that skips
|
||||
// the host's own check still binds nothing outside the install roots.
|
||||
test("hosted binds refuse without install roots or protected paths, and refuse an adapter or a mount source outside the roots or in a protected path", async (t) => {
|
||||
const p = await layout(t);
|
||||
const base = { runDir: p.runDir, healthDir: p.healthDir, adapter: p.adapter, relaySocket: p.relaySocket, installRoots: p.installRoots, protectedPaths: p.protectedPaths };
|
||||
const refused = (opts, fence, label) => assert.throws(() => hostedBinds({ ...base, ...opts }), (e) => e.code === "hosted-binds-refused" && e.fence === fence, label);
|
||||
refused({ installRoots: undefined }, "roots", "no roots");
|
||||
refused({ installRoots: [] }, "roots", "empty roots");
|
||||
refused({ installRoots: ["/"] }, "roots", "root /");
|
||||
refused({ installRoots: [join(p.root, "absent")] }, "roots", "missing root");
|
||||
refused({ installRoots: [p.adapter] }, "roots", "a file as root");
|
||||
refused({ protectedPaths: undefined }, "protected", "no protected paths");
|
||||
refused({ protectedPaths: ["relative"] }, "protected", "relative protected path");
|
||||
writeFileSync(join(p.root, "out.sh"), "x");
|
||||
refused({ adapter: join(p.root, "out.sh") }, "adapter", "adapter outside");
|
||||
symlinkSync(join(p.root, "out.sh"), join(p.install, "link.sh"));
|
||||
refused({ adapter: join(p.install, "link.sh") }, "adapter", "adapter link out");
|
||||
refused({ adapter: p.install }, "adapter", "adapter is a directory");
|
||||
refused({ harnessMounts: [{ src: join(p.install, "link.sh"), why: "w" }] }, "mount-src", "mount link out");
|
||||
refused({ harnessMounts: [{ src: join(p.dataRoot, "orgs"), why: "w" }], installRoots: [p.root] }, "mount-src", "mount in the data root");
|
||||
refused({ harnessMounts: [{ src: p.root, why: "w" }], installRoots: [p.root] }, "mount-src", "mount around the data root");
|
||||
mkdirSync(join(p.install, "secrets"));
|
||||
writeFileSync(join(p.install, "secrets", "k"), "x");
|
||||
refused({ harnessMounts: [{ src: join(p.install, "secrets", "k"), why: "w" }] }, "mount-src", "mount in secrets");
|
||||
writeFileSync(join(p.install, "m"), "x");
|
||||
refused({ harnessMounts: Array.from({ length: HOSTED_MOUNTS_MAX + 1 }, (_, i) => ({ src: join(p.install, "m"), dest: `/opt/m${i}`, why: "w" })) }, "mounts", "too many");
|
||||
refused({ harnessMounts: [{ src: join(p.install, "m"), dest: "/tmp/m", why: "w" }] }, "mount-dest", "dest under /tmp");
|
||||
refused({ harnessMounts: [{ src: join(p.install, "m"), dest: p.runDir, why: "w" }] }, "mount-dest", "dest is the run dir");
|
||||
refused({ harnessMounts: [{ src: join(p.install, "m"), dest: join(p.runDir, "session.json"), why: "w" }] }, "mount-dest", "dest is session.json");
|
||||
refused({ harnessMounts: [{ src: join(p.install, "m"), dest: "/usr", why: "w" }] }, "mount-dest", "dest is a system bind");
|
||||
refused({ harnessMounts: [{ src: join(p.install, "m"), dest: dirname(RUNNER_FILES[0]), why: "w" }] }, "mount-dest", "dest holds a runner file");
|
||||
refused({ harnessMounts: [{ src: join(p.install, "m"), why: "w", kind: "rw" }] }, "mounts", "a kind of its own");
|
||||
});
|
||||
|
||||
test("hosted binds bind the real file of a link that stays inside the install root, at the path the route named", async (t) => {
|
||||
const p = await layout(t);
|
||||
writeFileSync(join(p.install, "real.mjs"), "x");
|
||||
symlinkSync(join(p.install, "real.mjs"), join(p.install, "named.mjs"));
|
||||
symlinkSync(p.adapter, join(p.install, "adapter-link.sh"));
|
||||
const list = hostedBinds({
|
||||
runDir: p.runDir, healthDir: p.healthDir, adapter: join(p.install, "adapter-link.sh"), relaySocket: p.relaySocket, installRoots: p.installRoots, protectedPaths: p.protectedPaths,
|
||||
harnessMounts: [{ src: join(p.install, "named.mjs"), why: "w" }, { src: join(p.install, "real.mjs"), dest: "/opt/real.mjs", why: "w2" }],
|
||||
});
|
||||
assert.ok(list.some((b) => b.kind === "ro" && b.src === p.adapter && b.dest === join(p.install, "adapter-link.sh")));
|
||||
assert.ok(list.some((b) => b.kind === "ro" && b.src === join(p.install, "real.mjs") && b.dest === join(p.install, "named.mjs") && b.why === "w"));
|
||||
assert.ok(list.some((b) => b.kind === "ro" && b.src === join(p.install, "real.mjs") && b.dest === "/opt/real.mjs" && b.why === "w2"));
|
||||
assert.ok(!list.some((b) => b.src === join(p.install, "named.mjs")));
|
||||
});
|
||||
@@ -22,13 +22,26 @@
|
||||
// state says so. The route's answer names the harness: adapter, its mounts, harnessEnv, turnEnd,
|
||||
// model and provider, and the proxy variables for the spawn. Over the cap the route refuses until
|
||||
// the next day, and the message is refused with its code.
|
||||
//
|
||||
// #1873 triage-fences: the host checks a copy of the route's answer before it writes anything, and
|
||||
// uses only that copy. harnessEnv names must be in the harness module's envNames and pass
|
||||
// refusedHarnessName; values are clean strings. env holds only ROUTE_ENV_ALLOW names, with
|
||||
// ANTHROPIC_BASE_URL loopback http on a port (the host's proxyPort when it names one) and the
|
||||
// token matching the host's tokenPattern when it names one. The adapter and the mounts pass
|
||||
// checkHostedRoute (sandbox.mjs) against the module's installRoots and the data root, the config
|
||||
// directory and HOME, here and again in hostedBinds. A refused answer reaches no spawn, answers
|
||||
// triage-route-invalid, and writes ROUTE_REFUSED to the transcript.
|
||||
|
||||
import { spawn } from "node:child_process";
|
||||
import { randomBytes, timingSafeEqual } from "node:crypto";
|
||||
import { appendFileSync, closeSync, lstatSync, mkdirSync, openSync, readFileSync, rmSync, chmodSync, writeFileSync } from "node:fs";
|
||||
import { createServer } from "node:net";
|
||||
import { homedir } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
import { BWRAP, REPO, RUNNER_FILES, hostedArgv, hostedBinds } from "../../seat/src/sandbox.mjs";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { BWRAP, REPO, RUNNER_FILES, checkHostedRoute, hostedArgv, hostedBinds } from "../../seat/src/sandbox.mjs";
|
||||
import { isProviderVariable } from "../../seat/src/session.mjs";
|
||||
import { configDir as systemConfigDir } from "../../organization/src/organization-config.mjs";
|
||||
import { typedTools } from "../../harness/src/tools.mjs";
|
||||
import { builtinTools } from "../../harness/src/bundle.mjs";
|
||||
import { FOUNDER_ENV } from "../../harness/src/runner.mjs";
|
||||
@@ -43,6 +56,7 @@ export const QUEUE_MAX = 20;
|
||||
export const UNANSWERED = "Triage stopped before it answered this message. Send it again.";
|
||||
export const NOT_STARTED = "Triage did not start, so this message was not delivered.";
|
||||
export const NOT_TAKEN = "Triage stopped before it read this message. Send it again.";
|
||||
export const ROUTE_REFUSED = "Triage did not start: the model route's answer did not pass the host's checks, so this message was not delivered.";
|
||||
// An over-cap answer is held for at most this long; a later time is not taken.
|
||||
export const CAP_HOLD_MAX_MS = 48 * 3600 * 1000;
|
||||
const ISO_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z$/;
|
||||
@@ -56,7 +70,31 @@ const CAP = /^[0-9a-f]{64}$/;
|
||||
export const SPAWN_ENV_ALLOW = Object.freeze(["PATH", "LANG", "LC_ALL", "TZ", "TERM"]);
|
||||
export const ROUTE_ENV_ALLOW = Object.freeze(["ANTHROPIC_BASE_URL", "ANTHROPIC_AUTH_TOKEN"]);
|
||||
const ENV_NAME = /^[A-Z][A-Z0-9_]{0,63}$/;
|
||||
const deniedHarnessName = (k) => !ENV_NAME.test(k) || k === "MOSAIC_CONFIG" || k.startsWith("MOSAIC_BUS_") || FOUNDER_ENV.includes(k) || k === "SSH_AUTH_SOCK";
|
||||
const ENV_VALUE_MAX = 4096;
|
||||
const HARNESS_ENV_MAX = 64;
|
||||
// Refused in harnessEnv even when the harness module declares them: the runner's own MOSAIC_*
|
||||
// values, loader and interpreter hooks, the shell's start files and the founder's. A provider
|
||||
// name (every ANTHROPIC_* among them) goes through route env or nowhere.
|
||||
const REFUSED_PREFIX = /^(MOSAIC_|NODE_|LD_|DYLD_|PYTHON|BASH_|GIT_)/;
|
||||
const REFUSED_NAMES = new Set([
|
||||
"PATH", "HOME", "TMPDIR", "BASH_ENV", "ENV", "SSH_AUTH_SOCK", "SHELL", "SHELLOPTS", "BASHOPTS", "PS4", "IFS", "CDPATH",
|
||||
"GLOBIGNORE", "PERL5OPT", "PERL5LIB", "RUBYOPT", "RUBYLIB", "HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY", "NO_PROXY",
|
||||
...FOUNDER_ENV,
|
||||
]);
|
||||
export const refusedHarnessName = (k) => typeof k !== "string" || !ENV_NAME.test(k) || REFUSED_PREFIX.test(k) || REFUSED_NAMES.has(k) || isProviderVariable(k);
|
||||
const cleanValue = (v) => typeof v === "string" && v.length <= ENV_VALUE_MAX && !/[\0\n\r]/.test(v);
|
||||
const plainObject = (o) => o !== null && typeof o === "object" && !Array.isArray(o) && [Object.prototype, null].includes(Object.getPrototypeOf(o));
|
||||
// The proxy is on this machine: http, 127.0.0.1, a port, nothing after it.
|
||||
const LOOPBACK_URL = /^http:\/\/127\.0\.0\.1:([1-9][0-9]{0,4})$/;
|
||||
const HARNESS_NAME = /^[a-z][a-z0-9-]{0,31}$/;
|
||||
|
||||
// The harness module a route names, from the repository's own tree; null when there is none.
|
||||
async function repoHarnessModule(name) {
|
||||
if (!HARNESS_NAME.test(name)) return null;
|
||||
const file = join(REPO, "packages", "plugins", "harness", name, "index.mjs");
|
||||
try { if (!lstatSync(file).isFile()) return null; } catch { return null; }
|
||||
return import(pathToFileURL(file).href);
|
||||
}
|
||||
|
||||
export function triageEnv(source, routeEnv = {}, { node = process.execPath } = {}) {
|
||||
const env = { PATH: `${dirname(node)}:/usr/bin:/bin` };
|
||||
@@ -185,8 +223,19 @@ export function createRelay({ socket, cap, take, read, onSend, log = () => {} })
|
||||
// provider, env } | { ok: false, code, until? } } or null for no route
|
||||
// readSnapshot async () -> the snapshot (triage-snapshot.mjs composeSnapshot), written to health/
|
||||
// pollInterval the runner's receive interval in ms, for tests; the runner's default otherwise
|
||||
export function createTriageHost({ dataRoot, route = null, readSnapshot = async () => null, env = process.env, node = process.execPath, bwrap = BWRAP, now = () => new Date(), devOwner = false, log = () => {}, roleDir = join(REPO, "roles"), readOnly = [], pollInterval = null }) {
|
||||
// proxyPort the port ANTHROPIC_BASE_URL must name, or null for any port
|
||||
// tokenPattern a RegExp the whole ANTHROPIC_AUTH_TOKEN must match, or null for no shape check
|
||||
// harnessModule async (name) -> the harness module (envNames, installRoots) or null; the
|
||||
// repository's packages/plugins/harness/<name> by default
|
||||
// home HOME, which no mount may reach; the Console user's by default
|
||||
export function createTriageHost({ dataRoot, route = null, readSnapshot = async () => null, env = process.env, node = process.execPath, bwrap = BWRAP, now = () => new Date(), devOwner = false, log = () => {}, roleDir = join(REPO, "roles"), readOnly = [], pollInterval = null, proxyPort = null, tokenPattern = null, harnessModule = repoHarnessModule, home = homedir() }) {
|
||||
if (typeof dataRoot !== "string" || !dataRoot.startsWith("/")) throw new TriageError("triage-no-data-root", "no data root");
|
||||
if (proxyPort !== null && !(Number.isInteger(proxyPort) && proxyPort > 0 && proxyPort <= 65535)) throw new TypeError("proxyPort must be a port number or null");
|
||||
if (tokenPattern !== null && !(tokenPattern instanceof RegExp)) throw new TypeError("tokenPattern must be a RegExp or null");
|
||||
if (typeof harnessModule !== "function") throw new TypeError("harnessModule must be a function");
|
||||
const tokenShape = tokenPattern && new RegExp(`^(?:${tokenPattern.source})$`, tokenPattern.flags.replace(/[gy]/g, ""));
|
||||
// What no mount source may lie in or around, besides the run directory and the fixed list.
|
||||
const protectedPaths = [dataRoot, systemConfigDir(env), home];
|
||||
const paths = triagePaths(dataRoot);
|
||||
const role = JSON.parse(readFileSync(join(roleDir, "triage.json"), "utf8"));
|
||||
const contract = readFileSync(join(roleDir, role.contract), "utf8");
|
||||
@@ -272,17 +321,44 @@ export function createTriageHost({ dataRoot, route = null, readSnapshot = async
|
||||
writeFileSync(join(a, "session.json"), JSON.stringify(session, null, 2) + "\n", { mode: 0o600, flag: "wx" });
|
||||
};
|
||||
|
||||
const checkAdmitted = (a) => {
|
||||
if (!a || typeof a !== "object" || typeof a.adapter !== "string" || !a.adapter.startsWith("/")
|
||||
|| !["marker", "exit"].includes(a.turnEnd) || typeof a.model !== "string" || !a.model
|
||||
|| typeof a.harness !== "string" || !/^[a-z][a-z0-9-]{0,31}$/.test(a.harness)
|
||||
|| !a.harnessEnv || typeof a.harnessEnv !== "object" || Array.isArray(a.harnessEnv)
|
||||
|| Object.entries(a.harnessEnv).some(([k, v]) => typeof v !== "string" || deniedHarnessName(k))
|
||||
|| !Array.isArray(a.harnessMounts ?? [])) throw new TriageError("triage-route-invalid", "the model route's answer is not usable");
|
||||
// The route's answer, checked. It returns a copy taken once, so a getter or a later change to
|
||||
// the route's object cannot hand the bundle or the binds anything the checks did not see, and
|
||||
// the module's install roots, for hostedBinds. The log names the fence, never a value.
|
||||
const checkAdmitted = async (answer) => {
|
||||
const refuse = (fence) => {
|
||||
log(`triage host: route refused: ${fence}`);
|
||||
throw new TriageError("triage-route-invalid", "the model route's answer is not usable");
|
||||
};
|
||||
let a;
|
||||
try { a = structuredClone(answer); } catch { refuse("shape"); }
|
||||
if (!plainObject(a) || typeof a.adapter !== "string" || !["marker", "exit"].includes(a.turnEnd)
|
||||
|| typeof a.model !== "string" || !a.model || typeof a.harness !== "string" || !HARNESS_NAME.test(a.harness)
|
||||
|| (a.provider !== undefined && typeof a.provider !== "string")) refuse("shape");
|
||||
let mod = null;
|
||||
try { mod = await harnessModule(a.harness); } catch { mod = null; }
|
||||
const declared = mod?.envNames;
|
||||
if (!Array.isArray(declared) || typeof mod.installRoots !== "function") refuse("module");
|
||||
const he = a.harnessEnv;
|
||||
if (!plainObject(he) || Object.keys(he).length > HARNESS_ENV_MAX) refuse("harness-env");
|
||||
for (const [k, v] of Object.entries(he)) if (refusedHarnessName(k) || !declared.includes(k) || !cleanValue(v)) refuse("harness-env");
|
||||
const re = a.env ?? {};
|
||||
if (!plainObject(re) || Object.entries(re).some(([k, v]) => !ROUTE_ENV_ALLOW.includes(k) || !cleanValue(v))) refuse("route-env");
|
||||
const url = LOOPBACK_URL.exec(re.ANTHROPIC_BASE_URL ?? "");
|
||||
if (!url || Number(url[1]) > 65535 || (proxyPort !== null && Number(url[1]) !== proxyPort)) refuse("route-env");
|
||||
if (tokenShape && !(typeof re.ANTHROPIC_AUTH_TOKEN === "string" && tokenShape.test(re.ANTHROPIC_AUTH_TOKEN))) refuse("route-env");
|
||||
let installRoots;
|
||||
try { installRoots = structuredClone(mod.installRoots({ env })); } catch { refuse("module"); }
|
||||
try {
|
||||
checkHostedRoute({ adapter: a.adapter, harnessMounts: a.harnessMounts ?? [], installRoots, protectedPaths, runDir: paths.agent, node });
|
||||
} catch (e) {
|
||||
if (e?.code === "hosted-binds-refused") refuse(e.fence);
|
||||
throw e;
|
||||
}
|
||||
return { admitted: a, installRoots };
|
||||
};
|
||||
|
||||
const start = async (admitted) => {
|
||||
checkAdmitted(admitted);
|
||||
const start = async (answer) => {
|
||||
const { admitted, installRoots } = await checkAdmitted(answer);
|
||||
ensureDirs();
|
||||
writeBundle(admitted);
|
||||
cap = randomBytes(32).toString("hex");
|
||||
@@ -307,7 +383,14 @@ export function createTriageHost({ dataRoot, route = null, readSnapshot = async
|
||||
},
|
||||
log,
|
||||
});
|
||||
const list = hostedBinds({ runDir: paths.agent, healthDir: paths.health, adapter: admitted.adapter, harnessMounts: admitted.harnessMounts ?? [], relaySocket: join(paths.agent, "relay.sock"), node, readOnly });
|
||||
let list;
|
||||
try {
|
||||
list = hostedBinds({ runDir: paths.agent, healthDir: paths.health, adapter: admitted.adapter, harnessMounts: admitted.harnessMounts ?? [], installRoots, protectedPaths, relaySocket: join(paths.agent, "relay.sock"), node, readOnly });
|
||||
} catch (e) {
|
||||
if (e?.code !== "hosted-binds-refused") throw e;
|
||||
log(`triage host: route refused at the binds: ${e.fence}`);
|
||||
throw new TriageError("triage-route-invalid", "the model route's answer is not usable");
|
||||
}
|
||||
const argv = hostedArgv(list, paths.agent, [node, RUNNER, paths.agent], { bwrap });
|
||||
const out = openSync(paths.log, "a", 0o600);
|
||||
try {
|
||||
@@ -406,7 +489,7 @@ export function createTriageHost({ dataRoot, route = null, readSnapshot = async
|
||||
catch (e) {
|
||||
const i = queue.findIndex((m) => m.id === id);
|
||||
if (i >= 0) queue.splice(i, 1);
|
||||
try { append({ at: now().toISOString(), from: "host", in_reply_to: id, text: NOT_STARTED }); } catch {}
|
||||
try { append({ at: now().toISOString(), from: "host", in_reply_to: id, text: e?.code === "triage-route-invalid" ? ROUTE_REFUSED : NOT_STARTED }); } catch {}
|
||||
relay?.close();
|
||||
relay = null;
|
||||
log(`triage host: start failed: ${e.code ?? "error"}`);
|
||||
|
||||
@@ -6,11 +6,13 @@ import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { connect } from "node:net";
|
||||
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, symlinkSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { dirname, join } from "node:path";
|
||||
import { Client } from "../../bus/src/client.mjs";
|
||||
import { sandboxProblem } from "../../seat/src/sandbox.mjs";
|
||||
import { REPO, RUNNER_FILES, checkHostedRoute, sandboxProblem } from "../../seat/src/sandbox.mjs";
|
||||
import { isProviderVariable } from "../../seat/src/session.mjs";
|
||||
import {
|
||||
NOT_STARTED, NOT_TAKEN, RELAY_REFUSED, ROUTE_ENV_ALLOW, SPAWN_ENV_ALLOW, UNANSWERED, createRelay, createTriageHost, hostPrompt, triageEnv,
|
||||
NOT_STARTED, NOT_TAKEN, RELAY_REFUSED, ROUTE_ENV_ALLOW, ROUTE_REFUSED, SPAWN_ENV_ALLOW, UNANSWERED, createRelay, createTriageHost, hostPrompt,
|
||||
refusedHarnessName, triageEnv,
|
||||
} from "../src/triage-host.mjs";
|
||||
|
||||
const FIXTURE = new URL("./fixtures/triage-adapter.mjs", import.meta.url).pathname;
|
||||
@@ -95,13 +97,67 @@ test("the prompt names the snapshot inside the session and the card form, after
|
||||
assert.match(text, /```cards\n\[\{"step": "bus-start", "org": "alpha"\}\]\n```/);
|
||||
});
|
||||
|
||||
// Names the route may try in harnessEnv that the host refuses even when the module declares them.
|
||||
const REFUSED_TRIED = [
|
||||
"MOSAIC_POLICY_FILE", "MOSAIC_TOOLS_FILE", "MOSAIC_CONFIG", "MOSAIC_BUS_CONSOLE_SOCKET", "NODE_OPTIONS", "NODE_PATH", "LD_PRELOAD",
|
||||
"LD_LIBRARY_PATH", "DYLD_INSERT_LIBRARIES", "PYTHONPATH", "PYTHONSTARTUP", "PATH", "HOME", "TMPDIR", "BASH_ENV", "ENV", "SSH_AUTH_SOCK",
|
||||
"GITEA_TOKEN", "GH_TOKEN", "GIT_ASKPASS", "GIT_CONFIG_PARAMETERS", "VIKUNJA_TOKEN", "ANTHROPIC_BASE_URL", "ANTHROPIC_AUTH_TOKEN",
|
||||
"ANTHROPIC_API_KEY", "CLAUDE_CODE_OAUTH_TOKEN", "OPENAI_API_KEY",
|
||||
];
|
||||
// The fake harness module: it declares the probe names and every refused one, so only the host's
|
||||
// own refusal stops those. Its one install root is <root>/install.
|
||||
const DECLARED = Object.freeze(["TRIAGE_PROBE", "FAKE_OK", "FAKE_TWO", ...REFUSED_TRIED]);
|
||||
const fakeModule = (roots, names = DECLARED) => async (name) => name === "fake" ? { envNames: names, installRoots: () => roots } : null;
|
||||
|
||||
function host(t, root, opts = {}) {
|
||||
const dataRoot = join(root, "data");
|
||||
const h = createTriageHost({ dataRoot, readSnapshot: async () => SNAPSHOT, env: CONSOLE_ENV, readOnly: [FIXTURE], pollInterval: 100, ...opts });
|
||||
mkdirSync(join(root, "install"), { recursive: true });
|
||||
if (!existsSync(join(root, "install", "adapter.sh"))) writeFileSync(join(root, "install", "adapter.sh"), "exit 0\n");
|
||||
const h = createTriageHost({ dataRoot, readSnapshot: async () => SNAPSHOT, env: CONSOLE_ENV, readOnly: [FIXTURE], pollInterval: 100, harnessModule: fakeModule([join(root, "install")]), ...opts });
|
||||
t.after(() => h.stop());
|
||||
return { h, dataRoot };
|
||||
}
|
||||
|
||||
// A launcher that only leaves a mark: a spawn is proved by the mark, no spawn by its absence.
|
||||
function spy(root) {
|
||||
const f = join(root, "spy");
|
||||
writeFileSync(f, `#!/bin/sh\n: > '${join(root, "spawned")}'\nexit 0\n`, { mode: 0o755 });
|
||||
return f;
|
||||
}
|
||||
const answer = (root, over = {}) => ({
|
||||
ok: true, adapter: join(root, "install", "adapter.sh"), harness: "fake", harnessEnv: {}, harnessMounts: [], turnEnd: "exit",
|
||||
model: "m", provider: "p", env: { ANTHROPIC_BASE_URL: "http://127.0.0.1:9" }, ...over,
|
||||
});
|
||||
// One route answer through a fresh host: refused before anything is written or spawned, with the
|
||||
// one code, the owner-readable line, and a log line that names the fence.
|
||||
async function refusedRoute(t, label, make, opts = {}) {
|
||||
const root = scratch();
|
||||
mkdirSync(join(root, "install"), { recursive: true });
|
||||
const logs = [];
|
||||
const over = await make(root);
|
||||
const route = { admit: async () => (typeof over === "function" ? over() : answer(root, over)) };
|
||||
const { h, dataRoot } = host(t, root, { route, bwrap: spy(root), log: (l) => logs.push(l), ...(typeof opts === "function" ? opts(root) : opts) });
|
||||
await assert.rejects(h.message("hello"), (e) => e.code === "triage-route-invalid" && e.message === "the model route's answer is not usable", label);
|
||||
assert.equal(existsSync(join(root, "spawned")), false, `${label}: nothing spawned`);
|
||||
assert.equal(h.running, false, label);
|
||||
assert.equal(existsSync(join(dataRoot, "triage", "agent", "session.json")), false, `${label}: no bundle`);
|
||||
const [owner, note, ...rest] = (await h.state()).transcript;
|
||||
assert.deepEqual([owner.from, note.from, note.in_reply_to, note.text, rest.length], ["owner", "host", owner.id, ROUTE_REFUSED, 0], label);
|
||||
assert.ok(logs.some((l) => /^triage host: route refused: [a-z-]+$/.test(l)), `${label}: ${logs.join(" | ")}`);
|
||||
return logs;
|
||||
}
|
||||
// One route answer through a fresh host that must reach the launcher; the session.json it wrote.
|
||||
async function admittedRoute(t, label, make, opts = {}) {
|
||||
const root = scratch();
|
||||
mkdirSync(join(root, "install"), { recursive: true });
|
||||
const over = await make(root);
|
||||
const route = { admit: async () => (typeof over === "function" ? over() : answer(root, over)) };
|
||||
const { h, dataRoot } = host(t, root, { route, bwrap: spy(root), ...(typeof opts === "function" ? opts(root) : opts) });
|
||||
await h.message("hello");
|
||||
await waitFor(() => existsSync(join(root, "spawned")));
|
||||
return JSON.parse(readFileSync(join(dataRoot, "triage", "agent", "session.json"), "utf8"));
|
||||
}
|
||||
|
||||
test("no model route: nothing launches, the message is refused, and the state says the route is not set", async (t) => {
|
||||
const { h, dataRoot } = host(t, scratch());
|
||||
assert.equal((await h.state()).route, "not set");
|
||||
@@ -147,19 +203,177 @@ test("over the cap: the message is refused until the next day and nothing launch
|
||||
await assert.rejects(other.message("hello"), (e) => e.code === "triage-route-refused" && e.until === undefined);
|
||||
});
|
||||
|
||||
test("a route whose answer carries a config, bus or founder variable is refused before anything starts", async (t) => {
|
||||
for (const name of ["MOSAIC_CONFIG", "MOSAIC_BUS_CONSOLE_SOCKET", "GITEA_TOKEN", "SSH_AUTH_SOCK", "lower"]) {
|
||||
const root = scratch();
|
||||
const adapter = join(root, "adapter.sh");
|
||||
writeFileSync(adapter, "exit 0\n");
|
||||
const route = { admit: async () => ({ ok: true, adapter, harness: "fake", harnessEnv: { [name]: "x" }, harnessMounts: [], turnEnd: "exit", model: "m", provider: "p", env: {} }) };
|
||||
const { h, dataRoot } = host(t, root, { route });
|
||||
await assert.rejects(h.message("hello"), (e) => e.code === "triage-route-invalid", name);
|
||||
assert.equal(h.running, false);
|
||||
assert.equal(existsSync(join(dataRoot, "triage", "agent", "session.json")), false);
|
||||
// The owner's line is written before the start; the transcript then says it was not delivered.
|
||||
const [owner, note, ...rest] = (await h.state()).transcript;
|
||||
assert.deepEqual([owner.from, owner.text, note.from, note.in_reply_to, note.text, rest.length], ["owner", "hello", "host", owner.id, NOT_STARTED, 0], name);
|
||||
// #1873 triage-fences, design section 4. Every refused answer reaches no spawn (the spy launcher
|
||||
// leaves no mark), writes no bundle, answers triage-route-invalid and leaves ROUTE_REFUSED under
|
||||
// the owner's line.
|
||||
|
||||
test("fence 1: a harnessEnv name the host refuses is refused even when the harness module declares it", async (t) => {
|
||||
for (const name of REFUSED_TRIED) {
|
||||
assert.ok(DECLARED.includes(name));
|
||||
await refusedRoute(t, name, () => ({ harnessEnv: { [name]: "x" } }));
|
||||
assert.equal(refusedHarnessName(name), true, name);
|
||||
}
|
||||
// Names that are not one plain upper-case name: lower or mixed case, an equals sign, a NUL.
|
||||
for (const name of ["lower", "Mosaic_policy_file", "mosaic_policy_file", "FAKE_OK=x", "A=B", "FAKE_OK\0", " FAKE_OK", "fake_ok"]) {
|
||||
await refusedRoute(t, JSON.stringify(name), () => ({ harnessEnv: { [name]: "x" } }), (root) => ({ harnessModule: fakeModule([join(root, "install")], [...DECLARED, name]) }));
|
||||
}
|
||||
for (const name of ["GIT_DIR", "BASH_FUNC_x%%", "LD_AUDIT", "SHELLOPTS", "PS4", "IFS", "HTTPS_PROXY", "NODE_EXTRA_CA_CERTS", "PYTHONHOME", "MOSAIC_X"]) assert.equal(refusedHarnessName(name), true, name);
|
||||
for (const name of ["FAKE_OK", "PI_MODEL", "TRIAGE_PROBE"]) assert.equal(refusedHarnessName(name), false, name);
|
||||
});
|
||||
|
||||
test("fence 1: values are strings of at most 4096 characters with no NUL, newline or carriage return, and at most 64 names", async (t) => {
|
||||
for (const [label, v] of [["newline", "x\ny"], ["nul", "x\0"], ["cr", "x\ry"], ["4097", "a".repeat(4097)], ["number", 5], ["null", null], ["object", {}], ["array", ["x"]]]) {
|
||||
await refusedRoute(t, label, () => ({ harnessEnv: { FAKE_OK: v } }));
|
||||
}
|
||||
const many = Object.fromEntries(Array.from({ length: 65 }, (_, i) => [`FAKE_N${i}`, "x"]));
|
||||
await refusedRoute(t, "65 names", () => ({ harnessEnv: many }), (root) => ({ harnessModule: fakeModule([join(root, "install")], Object.keys(many)) }));
|
||||
await admittedRoute(t, "64 names", () => ({ harnessEnv: Object.fromEntries(Object.entries(many).slice(0, 64)) }), (root) => ({ harnessModule: fakeModule([join(root, "install")], Object.keys(many)) }));
|
||||
await refusedRoute(t, "array harnessEnv", () => ({ harnessEnv: ["FAKE_OK"] }));
|
||||
await refusedRoute(t, "no harnessEnv", () => ({ harnessEnv: undefined }));
|
||||
const s = await admittedRoute(t, "4096", () => ({ harnessEnv: { FAKE_OK: "a".repeat(4096), FAKE_TWO: "" } }));
|
||||
assert.deepEqual(Object.keys(s.harnessEnv), ["FAKE_OK", "FAKE_TWO"]);
|
||||
});
|
||||
|
||||
test("fence 1: a name the harness module does not declare is refused; a declared one reaches the session's bundle", async (t) => {
|
||||
await refusedRoute(t, "undeclared", () => ({ harnessEnv: { FAKE_UNDECLARED: "x" } }));
|
||||
await refusedRoute(t, "no such module", () => ({ harness: "nope" }));
|
||||
await refusedRoute(t, "module without envNames", () => ({}), (root) => ({ harnessModule: async () => ({ installRoots: () => [join(root, "install")] }) }));
|
||||
await refusedRoute(t, "module without installRoots", () => ({}), { harnessModule: async () => ({ envNames: DECLARED }) });
|
||||
await refusedRoute(t, "module that throws", () => ({}), { harnessModule: async () => { throw new Error("x"); } });
|
||||
await refusedRoute(t, "installRoots that throws", () => ({}), { harnessModule: async () => ({ envNames: DECLARED, installRoots: () => { throw new Error("x"); } }) });
|
||||
const s = await admittedRoute(t, "declared", () => ({ harnessEnv: { FAKE_OK: "yes" } }));
|
||||
assert.deepEqual(s.harnessEnv, { FAKE_OK: "yes" });
|
||||
});
|
||||
|
||||
test("fence 1: the bundle holds the copy the host checked; no MOSAIC_ name reaches session.json, even from a getter", async (t) => {
|
||||
let reads = 0;
|
||||
const s = await admittedRoute(t, "getter", (root) => () => {
|
||||
const a = answer(root);
|
||||
delete a.harnessEnv;
|
||||
Object.defineProperty(a, "harnessEnv", { enumerable: true, get: () => (reads++ === 0 ? { FAKE_OK: "checked" } : { MOSAIC_POLICY_FILE: "/evil", FAKE_OK: "swapped" }) });
|
||||
return a;
|
||||
});
|
||||
assert.equal(reads, 1, "the answer is read once");
|
||||
assert.deepEqual(s.harnessEnv, { FAKE_OK: "checked" });
|
||||
assert.ok(!Object.keys(s.harnessEnv).some((k) => k.startsWith("MOSAIC_")));
|
||||
// An answer that cannot be copied (a function in it) is refused.
|
||||
await refusedRoute(t, "function", (root) => ({ harnessEnv: { FAKE_OK: "x" }, extra: () => 1 }));
|
||||
});
|
||||
|
||||
test("fence 2: route env holds only the proxy's two names, the base URL is http on 127.0.0.1 with a port, and the host's port and token shape hold when given", async (t) => {
|
||||
const bad = [
|
||||
undefined, "", "http://localhost:9", "http://[::1]:9", "https://127.0.0.1:9", "http://127.0.0.1", "http://127.0.0.1:", "http://127.0.0.1:9/",
|
||||
"http://127.0.0.1:9/v1", "http://127.0.0.1:09", "http://127.0.0.1:0", "http://127.0.0.1:65536", "http://127.0.0.1:99999", "http://127.0.0.2:9",
|
||||
"http://[email protected]:9", "HTTP://127.0.0.1:9", "http://127.0.0.1:9\n", "http://127.0.0.1:9 ", "http://127.1:9", "http://2130706433:9",
|
||||
"http://127.0.0.1:9#x", "http://127.0.0.1:9?x", "http://10.0.0.1:9", 9,
|
||||
];
|
||||
for (const url of bad) await refusedRoute(t, `url ${JSON.stringify(url)}`, () => ({ env: url === undefined ? {} : { ANTHROPIC_BASE_URL: url } }));
|
||||
for (const extra of ["OTHER", "MOSAIC_CONFIG", "ANTHROPIC_API_KEY", "PATH", "anthropic_base_url"]) {
|
||||
await refusedRoute(t, `env ${extra}`, () => ({ env: { ANTHROPIC_BASE_URL: "http://127.0.0.1:9", [extra]: "x" } }));
|
||||
}
|
||||
await refusedRoute(t, "token with a newline", () => ({ env: { ANTHROPIC_BASE_URL: "http://127.0.0.1:9", ANTHROPIC_AUTH_TOKEN: "a\nb" } }));
|
||||
await refusedRoute(t, "env array", () => ({ env: ["ANTHROPIC_BASE_URL"] }));
|
||||
await admittedRoute(t, "port 65535", () => ({ env: { ANTHROPIC_BASE_URL: "http://127.0.0.1:65535" } }));
|
||||
// The host's port.
|
||||
await refusedRoute(t, "other port", () => ({ env: { ANTHROPIC_BASE_URL: "http://127.0.0.1:9" } }), { proxyPort: 9001 });
|
||||
await admittedRoute(t, "its port", () => ({ env: { ANTHROPIC_BASE_URL: "http://127.0.0.1:9001" } }), { proxyPort: 9001 });
|
||||
// The host's token shape: the whole token, never a part of it.
|
||||
const tokenPattern = /mst-[0-9a-f]{8}/g;
|
||||
for (const token of [undefined, "xmst-deadbeef", "mst-deadbeefx", "mst-DEADBEEF", "", "mst-deadbee"]) {
|
||||
await refusedRoute(t, `token ${token}`, () => ({ env: { ANTHROPIC_BASE_URL: "http://127.0.0.1:9", ...(token === undefined ? {} : { ANTHROPIC_AUTH_TOKEN: token }) } }), { tokenPattern });
|
||||
}
|
||||
await admittedRoute(t, "token", () => ({ env: { ANTHROPIC_BASE_URL: "http://127.0.0.1:9", ANTHROPIC_AUTH_TOKEN: "mst-deadbeef" } }), { tokenPattern });
|
||||
await admittedRoute(t, "token twice", () => ({ env: { ANTHROPIC_BASE_URL: "http://127.0.0.1:9", ANTHROPIC_AUTH_TOKEN: "mst-deadbeef" } }), { tokenPattern });
|
||||
for (const p of [0, 65536, "9", 1.5]) assert.throws(() => createTriageHost({ dataRoot: "/x", proxyPort: p }), /proxyPort/);
|
||||
assert.throws(() => createTriageHost({ dataRoot: "/x", tokenPattern: "mst-" }), /tokenPattern/);
|
||||
});
|
||||
|
||||
test("fence 3: a mount source outside the install roots, through a link out of them, or in the data root, the config directory, HOME or a secrets path is refused", async (t) => {
|
||||
const file = (p) => { mkdirSync(dirname(p), { recursive: true }); writeFileSync(p, "x"); return p; };
|
||||
const mount = (src, extra = {}) => ({ harnessMounts: [{ src, why: "w", ...extra }] });
|
||||
await refusedRoute(t, "outside", (root) => mount(file(join(root, "elsewhere", "f"))));
|
||||
await refusedRoute(t, "link out", (root) => { file(join(root, "elsewhere", "f")); symlinkSync(join(root, "elsewhere", "f"), join(root, "install", "out")); return mount(join(root, "install", "out")); });
|
||||
await refusedRoute(t, "dir link out", (root) => { file(join(root, "elsewhere", "f")); symlinkSync(join(root, "elsewhere"), join(root, "install", "d")); return mount(join(root, "install", "d", "f")); });
|
||||
await refusedRoute(t, "dotdot", (root) => { file(join(root, "elsewhere", "f")); return mount(`${root}/install/../elsewhere/f`); });
|
||||
await refusedRoute(t, "dotdot in root", (root) => { file(join(root, "install", "f")); return mount(`${root}/install/x/../f`); });
|
||||
await refusedRoute(t, "trailing slash", (root) => { mkdirSync(join(root, "install", "d")); return mount(join(root, "install", "d") + "/"); });
|
||||
await refusedRoute(t, "double slash", (root) => { file(join(root, "install", "f")); return mount(root + "//install/f"); });
|
||||
await refusedRoute(t, "relative", () => mount("install/adapter.sh"));
|
||||
await refusedRoute(t, "missing", (root) => mount(join(root, "install", "absent")));
|
||||
await refusedRoute(t, "case", (root) => { file(join(root, "install", "f")); return mount(join(root, "INSTALL", "f")); });
|
||||
// With the whole scratch root as the install root, only the protected-path fence stands.
|
||||
const wide = (root) => ({ harnessModule: fakeModule([root]) });
|
||||
await refusedRoute(t, "data root", (root) => mount(file(join(root, "data", "f"))), wide);
|
||||
await refusedRoute(t, "parent of data root", (root) => { mkdirSync(join(root, "data"), { recursive: true }); return mount(join(root)); }, wide);
|
||||
await refusedRoute(t, "alias of data root", (root) => { file(join(root, "data", "f")); symlinkSync(join(root, "data"), join(root, "alias")); return mount(join(root, "alias", "f")); }, wide);
|
||||
await refusedRoute(t, "config dir", (root) => mount(file(join(root, "cfg", "f"))), (root) => ({ ...wide(root), env: { ...CONSOLE_ENV, MOSAIC_CONFIG: join(root, "cfg", "config.json") } }));
|
||||
await refusedRoute(t, "home", (root) => mount(file(join(root, "h", "f"))), (root) => ({ ...wide(root), home: join(root, "h") }));
|
||||
await refusedRoute(t, "parent of home", (root) => { file(join(root, "p", "h", "f")); return mount(join(root, "p")); }, (root) => ({ ...wide(root), home: join(root, "p", "h") }));
|
||||
for (const seg of ["secrets", "Secrets", "SECRET", "my-secret-store"]) {
|
||||
await refusedRoute(t, seg, (root) => mount(file(join(root, "install", seg, "token"))));
|
||||
}
|
||||
await refusedRoute(t, "link into secrets", (root) => { file(join(root, "install", "secrets", "token")); symlinkSync(join(root, "install", "secrets", "token"), join(root, "install", "t")); return mount(join(root, "install", "t")); });
|
||||
await refusedRoute(t, "9 mounts", (root) => ({ harnessMounts: Array.from({ length: 9 }, (_, i) => ({ src: file(join(root, "install", `m${i}`)), dest: `/opt/m${i}`, why: "w" })) }));
|
||||
await refusedRoute(t, "mounts not a list", (root) => ({ harnessMounts: { src: file(join(root, "install", "f")) } }));
|
||||
await refusedRoute(t, "extra key", (root) => mount(file(join(root, "install", "f")), { mode: "rw" }));
|
||||
await refusedRoute(t, "no why", (root) => ({ harnessMounts: [{ src: file(join(root, "install", "f")) }] }));
|
||||
await refusedRoute(t, "string mount", (root) => ({ harnessMounts: [file(join(root, "install", "f"))] }));
|
||||
await refusedRoute(t, "install root is /", () => ({}), { harnessModule: fakeModule(["/"]) });
|
||||
await refusedRoute(t, "install root not a list", (root) => ({}), (root) => ({ harnessModule: fakeModule(join(root, "install")) }));
|
||||
await refusedRoute(t, "no install roots", () => ({}), { harnessModule: fakeModule([]) });
|
||||
await admittedRoute(t, "8 mounts", (root) => ({ harnessMounts: Array.from({ length: 8 }, (_, i) => ({ src: file(join(root, "install", `m${i}`)), dest: `/opt/m${i}`, why: "w" })) }));
|
||||
});
|
||||
|
||||
test("fence 3: a mount dest that is or holds /tmp, the run directory, the relay socket, the bundle, session.json, the health dest, a system bind or a runner file is refused", async (t) => {
|
||||
const withDest = (dest) => (root) => {
|
||||
writeFileSync(join(root, "install", "f"), "x");
|
||||
return { harnessMounts: [{ src: join(root, "install", "f"), dest: typeof dest === "function" ? dest(root) : dest, why: "w" }] };
|
||||
};
|
||||
const run = (root, ...p) => join(root, "data", "triage", "agent", ...p);
|
||||
const dests = [
|
||||
["/tmp", "/tmp"], ["under /tmp", "/tmp/x"], ["/tmp/", "/tmp/"], ["root", "/"], ["/usr/bin/sh", "/usr/bin/sh"], ["/usr", "/usr"], ["/etc", "/etc"],
|
||||
["/etc/hosts", "/etc/hosts"], ["relative", "opt/x"], ["dotdot", "/opt/../tmp"], ["empty", ""], ["number", 5],
|
||||
["run dir", (r) => run(r)], ["in run dir", (r) => run(r, "x")], ["relay", (r) => run(r, "relay.sock")], ["bundle", (r) => run(r, "bundle")],
|
||||
["session.json", (r) => run(r, "session.json")], ["health dest", (r) => run(r, "work", "health")], ["parent of run dir", (r) => dirname(run(r))],
|
||||
["parent of data root", (r) => r], ["runner file", RUNNER_FILES[0]], ["holds runner files", join(REPO, "packages")], ["repo", REPO],
|
||||
["node", process.execPath], ["holds node", dirname(process.execPath)], ["adapter", (r) => join(r, "install", "adapter.sh")],
|
||||
["holds adapter", (r) => join(r, "install")],
|
||||
];
|
||||
for (const [label, dest] of dests) await refusedRoute(t, `dest ${label}`, withDest(dest));
|
||||
await refusedRoute(t, "same dest twice", (root) => {
|
||||
writeFileSync(join(root, "install", "f"), "x");
|
||||
writeFileSync(join(root, "install", "g"), "x");
|
||||
return { harnessMounts: [{ src: join(root, "install", "f"), dest: "/opt/x", why: "w" }, { src: join(root, "install", "g"), dest: "/opt/x", why: "w" }] };
|
||||
});
|
||||
await admittedRoute(t, "dest /opt/x", withDest("/opt/x"));
|
||||
});
|
||||
|
||||
test("fence 3: the adapter takes the same checks: inside an install root, a file, not through a link out, not in a protected path", async (t) => {
|
||||
await refusedRoute(t, "outside", (root) => { writeFileSync(join(root, "a.sh"), "exit 0\n"); return { adapter: join(root, "a.sh") }; });
|
||||
await refusedRoute(t, "link out", (root) => { writeFileSync(join(root, "a.sh"), "exit 0\n"); symlinkSync(join(root, "a.sh"), join(root, "install", "a.sh")); return { adapter: join(root, "install", "a.sh") }; });
|
||||
await refusedRoute(t, "directory", (root) => { mkdirSync(join(root, "install", "d")); return { adapter: join(root, "install", "d") }; });
|
||||
await refusedRoute(t, "relative", () => ({ adapter: "install/adapter.sh" }));
|
||||
await refusedRoute(t, "dotdot", (root) => ({ adapter: `${root}/install/../install/adapter.sh` }));
|
||||
await refusedRoute(t, "missing", (root) => ({ adapter: join(root, "install", "absent.sh") }));
|
||||
await refusedRoute(t, "secrets", (root) => { mkdirSync(join(root, "install", "secrets")); writeFileSync(join(root, "install", "secrets", "a.sh"), "x"); return { adapter: join(root, "install", "secrets", "a.sh") }; });
|
||||
await refusedRoute(t, "data root", (root) => { mkdirSync(join(root, "data"), { recursive: true }); writeFileSync(join(root, "data", "a.sh"), "x"); return { adapter: join(root, "data", "a.sh") }; }, (root) => ({ harnessModule: fakeModule([root]) }));
|
||||
await refusedRoute(t, "not a string", () => ({ adapter: 5 }));
|
||||
// A link that stays inside the root is followed: the bind's source is the file itself.
|
||||
await admittedRoute(t, "link inside", (root) => { writeFileSync(join(root, "install", "real.sh"), "exit 0\n"); symlinkSync(join(root, "install", "real.sh"), join(root, "install", "a.sh")); return { adapter: join(root, "install", "a.sh") }; });
|
||||
});
|
||||
|
||||
test("the shipped harness modules declare what their own env() and mounts() hand a session, and their adapter and mounts pass the host's checks", async () => {
|
||||
const dir = scratch();
|
||||
for (const name of ["pi", "claude-code"]) {
|
||||
const mod = await import(new URL(`../../plugins/harness/${name}/index.mjs`, import.meta.url).href);
|
||||
assert.ok(Array.isArray(mod.envNames) && Object.isFrozen(mod.envNames), name);
|
||||
const keys = Object.keys(mod.env({
|
||||
files: { settings: "/s", mcp: "/m" }, policy: { tools: ["read"] }, tools: [], session: { model: "m", thinking: "off", provider: "p" },
|
||||
}));
|
||||
assert.deepEqual(keys.filter((k) => !isProviderVariable(k)).sort(), [...mod.envNames].sort(), name);
|
||||
const roots = mod.installRoots({ env: {} });
|
||||
const got = checkHostedRoute({ adapter: mod.adapter(), harnessMounts: mod.mounts({ env: {} }), installRoots: roots, protectedPaths: [join(dir, "data"), join(dir, "cfg"), join(dir, "home")], runDir: join(dir, "data", "triage", "agent") });
|
||||
assert.equal(got.adapter.dest, mod.adapter(), name);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -211,7 +425,8 @@ test("end to end under the sandbox: the first message starts the session, which
|
||||
// A link left where the host makes its work directory must not steer the bind.
|
||||
mkdirSync(join(dataRoot, "triage", "agent"), { recursive: true, mode: 0o700 });
|
||||
symlinkSync(join(dataRoot, "orgs"), join(dataRoot, "triage", "agent", "work"));
|
||||
const adapter = join(root, "adapter.sh");
|
||||
mkdirSync(join(root, "install"));
|
||||
const adapter = join(root, "install", "adapter.sh");
|
||||
writeFileSync(adapter, `exec '${process.execPath}' '${FIXTURE}'\n`, { mode: 0o644 });
|
||||
const probe = [
|
||||
join(dataRoot, "orgs", "alpha", "org.json"), join(root, "config", "config.json"), join(root, "secrets", "token"),
|
||||
@@ -219,7 +434,7 @@ test("end to end under the sandbox: the first message starts the session, which
|
||||
join(dataRoot, "triage", "health", "snapshot.json"), join(dataRoot, "triage", "agent", "work", "health", "snapshot.json"),
|
||||
];
|
||||
let admits = 0;
|
||||
const route = { admit: async () => { admits += 1; return { ok: true, adapter, harness: "fake", harnessEnv: { TRIAGE_PROBE: JSON.stringify(probe) }, harnessMounts: [], turnEnd: "exit", model: "stub", provider: "stub", env: { ANTHROPIC_BASE_URL: "http://127.0.0.1:9", OTHER: "x" } }; } };
|
||||
const route = { admit: async () => { admits += 1; return { ok: true, adapter, harness: "fake", harnessEnv: { TRIAGE_PROBE: JSON.stringify(probe) }, harnessMounts: [], turnEnd: "exit", model: "stub", provider: "stub", env: { ANTHROPIC_BASE_URL: "http://127.0.0.1:9" } }; } };
|
||||
const { h } = host(t, root, { route });
|
||||
assert.equal(h.running, false, "nothing starts before the owner's first message");
|
||||
assert.equal(existsSync(join(dataRoot, "triage", "agent", "session.json")), false);
|
||||
@@ -280,9 +495,10 @@ test("end to end under the sandbox: the first message starts the session, which
|
||||
|
||||
// A route answer that runs the stub adapter under the sandbox.
|
||||
function stubRoute(root) {
|
||||
const adapter = join(root, "adapter.sh");
|
||||
mkdirSync(join(root, "install"), { recursive: true });
|
||||
const adapter = join(root, "install", "adapter.sh");
|
||||
writeFileSync(adapter, `exec '${process.execPath}' '${FIXTURE}'\n`, { mode: 0o644 });
|
||||
return { admit: async () => ({ ok: true, adapter, harness: "fake", harnessEnv: {}, harnessMounts: [], turnEnd: "exit", model: "stub", provider: "stub", env: {} }) };
|
||||
return { admit: async () => ({ ok: true, adapter, harness: "fake", harnessEnv: {}, harnessMounts: [], turnEnd: "exit", model: "stub", provider: "stub", env: { ANTHROPIC_BASE_URL: "http://127.0.0.1:9" } }) };
|
||||
}
|
||||
const repliesOf = (h, n, from = "triage") => waitFor(async () => {
|
||||
const list = (await h.state()).transcript.filter((e) => e.from === from);
|
||||
@@ -326,9 +542,7 @@ test("a session that ends mid-turn: the message it took is answered by the host,
|
||||
|
||||
test("a launcher that cannot run is a failed start: the message is not delivered, nothing reports running, and the next message is refused the same way", async (t) => {
|
||||
const root = scratch();
|
||||
const adapter = join(root, "adapter.sh");
|
||||
writeFileSync(adapter, "exit 0\n");
|
||||
const route = { admit: async () => ({ ok: true, adapter, harness: "fake", harnessEnv: {}, harnessMounts: [], turnEnd: "exit", model: "m", provider: "p", env: {} }) };
|
||||
const route = { admit: async () => answer(root) };
|
||||
const { h, dataRoot } = host(t, root, { route, bwrap: join(root, "no-such-launcher") });
|
||||
for (const text of ["one", "two"]) {
|
||||
await assert.rejects(h.message(text), (e) => e.code === "triage-start-failed", text);
|
||||
|
||||
Reference in new issue
Block a user