fix(seat,unslop-hook): review round: the linked fixed path test puts the stand-in's real path outside HOME so only its own guard refuses the source; the Stop hook's notes name the late-fallback turn a later Stop can check again and say a second Stop after a blocking hook waits and logs one late entry; the plugins README names the Perl, Ruby, less and resolver hooks and points to REFUSED_NAMES (#1873, lane triage-p3s)

This commit was merged in pull request #1987.
This commit is contained in:
jason.woltje committed 2026-11-18 11:05:35 -06:00
1 parent c641dbfbc9
commit 56cc7b59dd
4 files changed
+28 -17

No files matched your search

+4 -2
View File
@@ -267,8 +267,10 @@ export returns:
`GIT_*`, `MALLOC_*`, `NPM_CONFIG_*`, `XDG_*`, any name ending in `_DIR`,
`_CONF`, `_CONFIG`, `_ASKPASS`, `_CA_BUNDLE` or `_BASE_URL`, PATH, HOME,
TMPDIR, ENV, the founder's and the provider's names, and named shell,
proxy, libc, OpenSSL, Java, askpass, CA bundle and base URL hooks, with
Lua's start code, curl's config home and a TLS key log. `installRoots` lists the directories
proxy, resolver, libc, OpenSSL and Java hooks, Perl and Ruby start
options and library paths, less's input filters, Lua's start code,
curl's config home and a TLS key log. The full list is
`REFUSED_NAMES` in `packages/webui/src/triage-host.mjs`. `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`
+7 -5
View File
@@ -181,7 +181,9 @@ test("a fixed path named through a link: a code root in its real path is refused
const p = await layout(t);
// None of the shipped fixed paths is a link on a test host, so the test hook adds a stand-in.
const home = join(p.root, "home");
const real = join(home, "fixedreal");
// The real path lies outside HOME and the data root, so only the stand-in's own guard can refuse
// a source there.
const real = join(p.root, "fixedreal");
const inst = join(real, "code", "inst");
mkdirSync(inst, { recursive: true });
writeFileSync(join(inst, "a.sh"), "x");
@@ -191,12 +193,12 @@ test("a fixed path named through a link: a code root in its real path is refused
const refused = (opts, fence, message, label) => assert.throws(() => checkHostedRoute({ ...base, ...opts }), (e) => e.code === "hosted-binds-refused" && e.fence === fence && message.test(e.message), label);
// The code root lies in the stand-in's real path, not under the name the list gives.
refused({ codeRoot: join(real, "code") }, "protected", /never set aside/, "code root in a fixed path's real path");
// With the code root elsewhere, the source in the stand-in's real path is refused by its guard,
// which holds the same real spelling, not by HOME: HOME sets the code root aside.
mkdirSync(join(home, "code"));
// With the code root in HOME, the source in the stand-in's real path is refused by the stand-in's
// guard, which holds the same real spelling. No other guard holds that path.
mkdirSync(join(home, "code"), { recursive: true });
refused({ codeRoot: join(home, "code") }, "adapter", /protected path/, "source in a fixed path's real path");
// The same source passes without the stand-in: only the stand-in refused it.
assert.equal(checkHostedRoute({ ...base, alsoFixed: [], codeRoot: join(real, "code") }).adapter.src, join(inst, "a.sh"));
assert.equal(checkHostedRoute({ ...base, alsoFixed: [], codeRoot: join(home, "code") }).adapter.src, join(inst, "a.sh"));
// The hook adds fixed paths and never removes one, and takes only a list of clean absolute paths.
refused({ alsoFixed: [], codeRoot: "/srv/mosaic/x" }, "protected", /never set aside/, "shipped fixed path with an empty hook");
refused({ alsoFixed: ["relative"], codeRoot: join(real, "code") }, "protected", /clean absolute/, "relative stand-in");
+11 -6
View File
@@ -122,12 +122,17 @@ lists.
to 2 s. If it never catches up, the hook checks `last_assistant_message`
alone, logs an empty `entryId` and `late: true`, and the turn's earlier
replies go unchecked; with no `last_assistant_message` it checks nothing.
Two cases can still log a turn twice. After a late fallback the state
keeps the prompt before, so a later Stop with no `last_assistant_message`
can check the fallback turn's replies again. A second Stop in one turn,
after a Stop hook that blocks, waits 2 s and then checks
`last_assistant_message` alone, late. The state file sits in the run
directory with the log, so it is the session's own record too.
Two cases are left. First, a late fallback records no prompt, because
the hook never saw the turn. When that turn lands in the transcript, a
later Stop can take it for its own: one with no
`last_assistant_message`, or one whose reply has the same text as the
late turn's last reply. That Stop checks the late turn's replies again.
Second, a Stop hook that blocks makes Claude go on with no new prompt,
so a second Stop in that turn finds the transcript stale by its prompt.
It waits 2 s and checks `last_assistant_message` alone, late. Managed
sessions do not reach this case: their only Stop hook never blocks. The
state file sits in the run directory with the log, so it is the
session's own record too.
- The word/phrase lists are the mechanical subset of ms-unslop only, keyed to
pattern ids in lists.json. Style judgments (voice, rhythm, structure) stay in
the skill, not the gate.
+6 -4
View File
@@ -120,10 +120,12 @@ function recordStop(session, prompt) {
// hook's own limit is 10 s). A transcript that never catches up gives last_assistant_message
// alone, logged with late: true so a release where it never matches shows in the log; with no
// last_assistant_message there is no reply to check, and nothing is logged.
// After a late fallback the turn's prompt uuid is not known, so the state keeps the one before:
// a later Stop with no last_assistant_message can then log that turn's replies once more. So can
// a second Stop in one turn (a Stop hook that blocks makes Claude go on with no new prompt): its
// transcript is stale by the uuid rule, so it waits and then logs only last_assistant_message.
// Two cases are left. A late fallback records no prompt uuid, since the hook never saw the turn.
// Once that turn lands, a later Stop with no last_assistant_message, or with a reply whose text
// equals the late turn's last reply, takes it for its own and logs its replies again. And a Stop
// hook that blocks makes Claude go on with no new prompt, so a second Stop in that turn finds the
// transcript stale by the uuid rule, waits, and logs only last_assistant_message, late. Managed
// sessions never reach the second case: their only Stop hook never blocks.
const STOP_WAIT_MS = 2000;
const flat = (s) => s.replace(/\s+/g, "");
const pause = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);