diff --git a/packages/webui/src/cli.mjs b/packages/webui/src/cli.mjs index 4fc839b81..bef2d9fdd 100644 --- a/packages/webui/src/cli.mjs +++ b/packages/webui/src/cli.mjs @@ -205,7 +205,7 @@ try { templatesWrite: session.user === undefined && sendOn ? templatesCaller(consoleCall({ dataRoot: root, socket: paths.socket, business: id })) : null, // Starter packs SP6 (#1873): the owner's workflow read, the organization file and its revision as the // writer reads them (the read `mosaic org workflow set` takes its revision from), and the V2 template names - // less the system-only ones. + // less the system-only ones. packs-http's workflowsRead drops them again and is the tested gate. workflowsRead: session.user === undefined ? () => ({ ...organizationWriter({ dir: configDir(), rolesDir: rolesDir() }).read(id), templates: templateHashes(rolesDir()).map(t => t.template).filter(t => !systemOnly(t)) }) : null, reads: consoleReads({ root: REPO, queueRoot: options.checkout ?? REPO, system, configDir: configDir(), rolesDir: rolesDir(), business: id, orgRoot: root }), }; diff --git a/tools/unslop-hook/README.md b/tools/unslop-hook/README.md index 332b989d8..e670289f6 100644 --- a/tools/unslop-hook/README.md +++ b/tools/unslop-hook/README.md @@ -117,8 +117,10 @@ lists. transcript (seen on 2.1.319 to 2.1.325, on any turn). The hook reads the transcript again until its last reply matches `last_assistant_message`, for up to 2 s. If it never does, the hook checks `last_assistant_message` - alone and logs an empty `entryId`, and the turn's earlier replies go - unchecked. + alone, logs an empty `entryId` and `late: true`, and the turn's earlier + replies go unchecked. Two stale cases remain: a hook input with no + `last_assistant_message`, and a reply whose text equals the last turn's + last reply. Either can log the last turn's replies again. - 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. diff --git a/tools/unslop-hook/claude-hook.js b/tools/unslop-hook/claude-hook.js index 14d01a23b..5b9af26bf 100644 --- a/tools/unslop-hook/claude-hook.js +++ b/tools/unslop-hook/claude-hook.js @@ -88,7 +88,11 @@ function turnReplies(path) { // Claude Code can run the Stop hook before it writes the turn to the transcript, so the // transcript may still end with the last turn. Read it again until its last reply is the one // the hook input names, for up to STOP_WAIT_MS (the hook's own limit is 10 s). A transcript that -// never catches up gives last_assistant_message alone, never the last turn's replies again. +// never catches up gives last_assistant_message alone, logged with late: true so a release where +// it never matches shows in the log. +// Two stale cases remain: an input with no last_assistant_message is not waited for, and a reply +// whose text equals the last turn's last reply matches a stale transcript at once. Either can log +// the last turn's replies again. 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); @@ -96,10 +100,11 @@ const pause = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, function stop(input) { const told = typeof input.last_assistant_message === "string" && input.last_assistant_message.trim() ? input.last_assistant_message : null; const deadline = Date.now() + STOP_WAIT_MS; - let turn = turnReplies(input.transcript_path); + let turn = turnReplies(input.transcript_path), late = false; while (told !== null && !(turn.length && flat(turn.at(-1).text) === flat(told))) { if (Date.now() >= deadline) { turn = [{ id: "", text: told }]; + late = true; break; } pause(25); @@ -108,8 +113,9 @@ function stop(input) { for (const r of turn) { const result = check(r.text, "stop"); if (result === null) return; - if (result.clean) log({ ev: "checked", clean: true, entryId: r.id, charsChecked: result.charsChecked }); - else log({ ev: "flagged", clean: false, entryId: r.id, charsChecked: result.charsChecked, findings: result.findings }); + const extra = late ? { late: true } : {}; + if (result.clean) log({ ev: "checked", clean: true, entryId: r.id, charsChecked: result.charsChecked, ...extra }); + else log({ ev: "flagged", clean: false, entryId: r.id, charsChecked: result.charsChecked, findings: result.findings, ...extra }); } } diff --git a/tools/unslop-hook/test-unslop-check.js b/tools/unslop-hook/test-unslop-check.js index e289e764c..227585d42 100644 --- a/tools/unslop-hook/test-unslop-check.js +++ b/tools/unslop-hook/test-unslop-check.js @@ -331,13 +331,13 @@ t("claude-hook: Stop with a transcript that never catches up checks last_assista const log = tmp("hook-stale.jsonl"); const r = hook("stop", { transcript_path: transcript, last_assistant_message: TELL_REPLY }, { MOSAIC_UNSLOP_LOG: log }); assert.strictEqual(r.status, 0, r.stderr); - assert.deepStrictEqual(events(log).map((e) => [e.ev, e.entryId]), [["flagged", ""]]); + assert.deepStrictEqual(events(log).map((e) => [e.ev, e.entryId, e.late]), [["flagged", "", true]]); // A turn already in the transcript is checked at once, with its entry id. const now = tmp("hook-current.jsonl"); const started = Date.now(); hook("stop", { transcript_path: transcript, last_assistant_message: "The build is green." }, { MOSAIC_UNSLOP_LOG: now }); assert.ok(Date.now() - started < 1500, "no wait when the transcript is current"); - assert.deepStrictEqual(events(now).map((e) => [e.ev, e.entryId]), [["checked", "a1"]]); + assert.deepStrictEqual(events(now).map((e) => [e.ev, e.entryId, e.late]), [["checked", "a1", undefined]]); }); let failed = 0;