Skip to content

A self-organizing Obsidian vault that gives AI coding agents persistent memory.

fix: honor camelCase Stop hook re-entry flags (#325)

Ryan Vo682a50c18973
diff --git a/.claude/scripts/stop-checklist.ts b/.claude/scripts/stop-checklist.ts
index 682c700..2a940c4 100644
--- a/.claude/scripts/stop-checklist.ts
+++ b/.claude/scripts/stop-checklist.ts
@@ -38,7 +38,9 @@
* and the handed-over report are held under Claude Code's hook output cap
* (lib/hook-io.ts).
* The documented event name is the only branch — no agent sniffing and no
- * agent-specific argument.
+ * agent-specific argument. A field one agent spells differently is read under
+ * every spelling, so it means the same thing whoever sent it and never tells
+ * the agents apart (the re-entry flag below).
*
* Under the template's Claude Code mod (#264, lib/om-mod.ts) the mod presents
* the report itself: it runs this script with `om_mod: "report"` to get the
@@ -92,6 +94,7 @@ type HookInput = {
readonly hook_event_name?: unknown;
readonly session_id?: unknown;
readonly stop_hook_active?: unknown;
+ readonly stopHookActive?: unknown;
};
const input = await readStdinJson<HookInput>();
@@ -108,7 +111,9 @@ if (omMod === "standdown") {
// writeSilentHookOutput for why "sometimes silent, sometimes JSON" is the
// weaker contract.
// The mod's `report` run is not a re-entry: the mod decides when to ask.
-if (input?.stop_hook_active === true && omMod !== "report") {
+// The flag counts under either spelling, whichever agent sent it: Grok's Stop
+// carries only `stopHookActive` (#323).
+if ((input?.stop_hook_active === true || input?.stopHookActive === true) && omMod !== "report") {
writeSilentHookOutput();
process.exit(0);
}
diff --git a/.claude/scripts/tests/stop-checklist.test.ts b/.claude/scripts/tests/stop-checklist.test.ts
index 605e32d..1ebfff5 100644
--- a/.claude/scripts/tests/stop-checklist.test.ts
+++ b/.claude/scripts/tests/stop-checklist.test.ts
@@ -1,7 +1,8 @@
/**
* Integration tests for the shared Stop/SessionEnd hook entry point.
* Locks the once-per-session Stop report, the always-on SessionEnd report,
- * stop_hook_active semantics, and the JSON output envelope.
+ * re-entry flag semantics (`stop_hook_active` or `stopHookActive`), and the
+ * JSON output envelope.
*
* Why Stop dedupes instead of moving to SessionEnd (#252): Stop fires after
* every response on Claude Code and Codex, so an unconditional report repeats
@@ -379,10 +380,27 @@ describe("stop-checklist", () => {
assert.match(shownOf(stdout), /Wrap-up checklist:/);
});
- test("string stop_hook_active is not re-entry", () => {
- const { stdout } = run({ ...stop("s-string"), stop_hook_active: "true" });
- assert.match(shownOf(stdout), /Wrap-up checklist:/);
- });
+ // The disagreeing pairs pin "either spelling", which a `??` between the two
+ // keys would break.
+ for (const payload of [
+ { stopHookActive: true },
+ { stop_hook_active: false, stopHookActive: true },
+ { stop_hook_active: true, stopHookActive: false },
+ ]) {
+ test(`either boolean re-entry flag suppresses reporting: ${JSON.stringify(payload)}`, () => {
+ const root = vault("camel-reentry", "Done.md");
+ const result = run({ ...stop("s-camel-reentry"), ...payload }, { vault: root });
+ assert.deepEqual(envelopeOf(result.stdout), {});
+ assert.equal(result.handed, null);
+ });
+ }
+
+ for (const payload of [{ stop_hook_active: "true" }, { stopHookActive: "true" }]) {
+ test(`a string re-entry flag is not re-entry: ${JSON.stringify(payload)}`, () => {
+ const { stdout } = run({ ...stop("s-string"), ...payload });
+ assert.match(shownOf(stdout), /Wrap-up checklist:/);
+ });
+ }
test("SessionEnd reports every time — it is the last chance, not a turn", () => {
const root = vault("session-end", "Done.md");
@@ -553,13 +571,15 @@ describe("stop-checklist — om_mod (a Claude Code mod)", () => {
assert.equal(refreshed(result.stderr), true, "the mod's run replaces the hook's, refresh included");
});
- test("report answers even on a re-entry event: the mod decides when to ask", () => {
- const root = vault("ommod-reentry", "Done.md");
- const result = run({ ...flagged("s-reentry", "report"), stop_hook_active: true }, { vault: root });
- const envelope = envelopeOf(result.stdout) as { report?: { agentText: string } };
- assert.ok(envelope.report, `expected a report, got ${result.stdout}`);
- assert.match(envelope.report.agentText, /work\/active\/Done\.md/);
- });
+ for (const flag of [{ stop_hook_active: true }, { stopHookActive: true }]) {
+ test(`report answers even on a re-entry event: the mod decides when to ask: ${JSON.stringify(flag)}`, () => {
+ const root = vault("ommod-reentry", "Done.md");
+ const result = run({ ...flagged("s-reentry", "report"), ...flag }, { vault: root });
+ const envelope = envelopeOf(result.stdout) as { report?: { agentText: string } };
+ assert.ok(envelope.report, `expected a report, got ${result.stdout}`);
+ assert.match(envelope.report.agentText, /work\/active\/Done\.md/);
+ });
+ }
test("report's key is the report's identity: stable for the same findings, different when they change", () => {
const root = vault("ommod-key", "Done.md");
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index ef47a13..69f805d 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -886,7 +886,7 @@ Step 2 is not documentation garnish. Measured: with the server wired and no repo
## Multi-Agent Portability
-The same scripts serve three agents. Each agent has its own config file mapping equivalent lifecycle events to the shared scripts. The checklist runs on `Stop` for Claude Code and Codex (per response, deduped) and on `SessionEnd` for Gemini (at shutdown). The script branches on the documented event name, never on an agent-specific payload field.
+The same scripts serve three agents. Each agent has its own config file mapping equivalent lifecycle events to the shared scripts. The checklist runs on `Stop` for Claude Code and Codex (per response, deduped) and on `SessionEnd` for Gemini (at shutdown). The script branches on the documented event name and on what a payload field means, never on which agent sent it. Where agents spell one field differently, every spelling is read, so the field can never tell the agents apart: Grok's Stop sends the re-entry flag as `stopHookActive`, and the checklist reads it beside `stop_hook_active` (#323).
Session-boundary output is JSON-or-nothing on all three agents. `stop-checklist.ts` emits `{}` when a Stop has nothing new to say. What the user sees is `systemMessage`, the one user-facing field all three agents share: on a Stop whose findings changed, a one-line-per-section summary, with the full report saved for the next prompt's `UserPromptSubmit` to hand to the agent unseen. Only when the report cannot be saved does it go out as Stop feedback, which Claude Code prints in full; whether Codex honours Stop feedback is unverified. SessionEnd (Gemini) has no next prompt, so there the full report is `systemMessage` only. `om-wrap-up` still owns the deliberate acting pass at the end of a session.