fix(#2289): context-monitor emits injection envelope only for supported events (#2324)

* fix(#2289): context-monitor emits injection envelope only for supported events

gsd-context-monitor is wired to Codex Stop/SubagentStart/SubagentStop/PreCompact
(#772), but it emitted a hookSpecificOutput.additionalContext envelope for every
event. Codex's Stop schema rejects that shape ("hook returned invalid stop hook
JSON output") exactly when context is low.

Use a positive allowlist: emit only for context-injection events (PostToolUse,
AfterTool, and the pre-existing Gemini missing-name fallback); exit 0 silently
for Stop and every other event. Debounce and critical-session bookkeeping still
run on silenced events. Behavioral regression tests drive the real hook.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs(#2289): backfill PR number 2324 into changeset

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(#2285): de-flake per-plan use_worktree property test on duplicate briefs

The fast-check property in claude-orchestration.test.cjs located each plan's
agent() call via indexOf on the brief, but only plan IDs were unique — briefs
could collide (fast-check shrinks toward short strings). On a colliding seed the
lookup found the first duplicate's line and misattributed its isolation, failing
"use_worktree:true must carry isolation" intermittently (surfaced on macOS CI).
emitWorkflowScript is correct for duplicate briefs (verified); suffix the unique
id onto each agent() label so the test probe is unambiguous.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-07-16 00:56:07 -04:00
committed by GitHub
parent 52fab7d9d7
commit 5ea3401d4f
16 changed files with 309 additions and 82 deletions

View File

@@ -314,7 +314,7 @@
"hooks/gsd-check-update-worker.js": "fa301e6366270d5f",
"hooks/gsd-check-update.js": "4617a98bf529e4c3",
"hooks/gsd-config-reload.js": "96546e0e8bb47904",
"hooks/gsd-context-monitor.js": "6d81d7326e5b2710",
"hooks/gsd-context-monitor.js": "31a4d99fd3b260ad",
"hooks/gsd-cursor-post-tool.js": "9168e0a09de1972a",
"hooks/gsd-cursor-pre-tool.js": "873998b25e308c29",
"hooks/gsd-cursor-session-start.js": "9b2e6f4f0c405375",

View File

@@ -385,7 +385,7 @@
"hooks/gsd-check-update-worker.js": "cc1ef5f840f9dfc9",
"hooks/gsd-check-update.js": "7b3a7983d5f1f5d3",
"hooks/gsd-config-reload.js": "96546e0e8bb47904",
"hooks/gsd-context-monitor.js": "44ff1bbf292747af",
"hooks/gsd-context-monitor.js": "493e24c139c61129",
"hooks/gsd-cursor-post-tool.js": "9168e0a09de1972a",
"hooks/gsd-cursor-pre-tool.js": "873998b25e308c29",
"hooks/gsd-cursor-session-start.js": "9b2e6f4f0c405375",

View File

@@ -384,7 +384,7 @@
"hooks/gsd-check-update-worker.js": "a530efdb5fdc0da3",
"hooks/gsd-check-update.js": "25cde66a12d6b886",
"hooks/gsd-config-reload.js": "96546e0e8bb47904",
"hooks/gsd-context-monitor.js": "ecbe9747e4a442e0",
"hooks/gsd-context-monitor.js": "f2ac6a1033d140de",
"hooks/gsd-cursor-post-tool.js": "8a8a249c0642cc71",
"hooks/gsd-cursor-pre-tool.js": "8cb8e8f895edaec9",
"hooks/gsd-cursor-session-start.js": "05a14e903c5edafa",

View File

@@ -313,7 +313,7 @@
"hooks/gsd-check-update-worker.js": "a530efdb5fdc0da3",
"hooks/gsd-check-update.js": "25cde66a12d6b886",
"hooks/gsd-config-reload.js": "96546e0e8bb47904",
"hooks/gsd-context-monitor.js": "ecbe9747e4a442e0",
"hooks/gsd-context-monitor.js": "f2ac6a1033d140de",
"hooks/gsd-cursor-post-tool.js": "8a8a249c0642cc71",
"hooks/gsd-cursor-pre-tool.js": "8cb8e8f895edaec9",
"hooks/gsd-cursor-session-start.js": "05a14e903c5edafa",

View File

@@ -385,7 +385,7 @@
"hooks/gsd-check-update-worker.js": "bdc9324a2f080ddd",
"hooks/gsd-check-update.js": "b7669f605631e506",
"hooks/gsd-config-reload.js": "96546e0e8bb47904",
"hooks/gsd-context-monitor.js": "f372804867cabe40",
"hooks/gsd-context-monitor.js": "8d512ba0b08fc4e3",
"hooks/gsd-cursor-post-tool.js": "9168e0a09de1972a",
"hooks/gsd-cursor-pre-tool.js": "873998b25e308c29",
"hooks/gsd-cursor-session-start.js": "9b2e6f4f0c405375",

View File

@@ -418,7 +418,7 @@
"gsd-core/workflows/verify-phase.md": "2e12c3cb97a9122a",
"gsd-core/workflows/verify-work.md": "5b348e73fc0d0829",
"hooks/gsd-check-update.js": "ef48957eb6ac6a10",
"hooks/gsd-context-monitor.js": "76fecaaa2babd6c1",
"hooks/gsd-context-monitor.js": "ec76b23f45d29b02",
"scripts/changeset/README.md": "86ff89331dfd94b2",
"scripts/changeset/cli.cjs": "68f92a344b199271",
"scripts/changeset/github-release-notes.cjs": "795677f0c009b132",

View File

@@ -314,7 +314,7 @@
"hooks/gsd-check-update-worker.js": "7989cc2bedd1138d",
"hooks/gsd-check-update.js": "25f5ad726f76fc11",
"hooks/gsd-config-reload.js": "880b696458e85e9b",
"hooks/gsd-context-monitor.js": "41d28e0db7b20968",
"hooks/gsd-context-monitor.js": "b829f618e82406de",
"hooks/gsd-cursor-post-tool.js": "8a8a249c0642cc71",
"hooks/gsd-cursor-pre-tool.js": "8cb8e8f895edaec9",
"hooks/gsd-cursor-session-start.js": "05a14e903c5edafa",

View File

@@ -4,7 +4,7 @@
".kimi/hooks/gsd-check-update-worker.js": "6593f80914f4edee",
".kimi/hooks/gsd-check-update.js": "aac7612ee04ff5fe",
".kimi/hooks/gsd-config-reload.js": "96546e0e8bb47904",
".kimi/hooks/gsd-context-monitor.js": "783c93351e82151f",
".kimi/hooks/gsd-context-monitor.js": "4c0535bc269e130e",
".kimi/hooks/gsd-cursor-post-tool.js": "9168e0a09de1972a",
".kimi/hooks/gsd-cursor-pre-tool.js": "873998b25e308c29",
".kimi/hooks/gsd-cursor-session-start.js": "9b2e6f4f0c405375",

View File

@@ -385,7 +385,7 @@
"hooks/gsd-check-update-worker.js": "385fb7c67810baf6",
"hooks/gsd-check-update.js": "4549451414ffa7d7",
"hooks/gsd-config-reload.js": "96546e0e8bb47904",
"hooks/gsd-context-monitor.js": "7a9787868a39b76d",
"hooks/gsd-context-monitor.js": "91ce47cd2dc3bbe8",
"hooks/gsd-cursor-post-tool.js": "9168e0a09de1972a",
"hooks/gsd-cursor-pre-tool.js": "873998b25e308c29",
"hooks/gsd-cursor-session-start.js": "9b2e6f4f0c405375",

View File

@@ -281,7 +281,7 @@
"hooks/gsd-check-update-worker.js": "55376b5b9335a580",
"hooks/gsd-check-update.js": "a89562537a41f83d",
"hooks/gsd-config-reload.js": "96546e0e8bb47904",
"hooks/gsd-context-monitor.js": "1c48eb0f38a24318",
"hooks/gsd-context-monitor.js": "e72cba19eeab9036",
"hooks/gsd-cursor-post-tool.js": "9168e0a09de1972a",
"hooks/gsd-cursor-pre-tool.js": "873998b25e308c29",
"hooks/gsd-cursor-session-start.js": "9b2e6f4f0c405375",

View File

@@ -314,7 +314,7 @@
"hooks/gsd-check-update-worker.js": "4bb354044e0dff91",
"hooks/gsd-check-update.js": "d2065cb3e725a42a",
"hooks/gsd-config-reload.js": "4f52b8a0120bb1b8",
"hooks/gsd-context-monitor.js": "437a33e6e3058640",
"hooks/gsd-context-monitor.js": "b71785540277e9d7",
"hooks/gsd-cursor-post-tool.js": "8a8a249c0642cc71",
"hooks/gsd-cursor-pre-tool.js": "8cb8e8f895edaec9",
"hooks/gsd-cursor-session-start.js": "05a14e903c5edafa",