Repository navigation
fix(mod): no prompt.context or classic.SessionStart hook, so a guard has nothing to skip (#2243) - #2413
Merged
Conversation
…has nothing to skip (#2243) Under Claude Code's cc-plugin-sec-default every registered hook the guard sends past prints "its <event> hook was skipped" once per session, matched or not (the host trims only plugins above the first match). Registration cannot depend on $.store: on() runs only inside register(), before $ exists. - The Inbox reminder goes as the first prompt's prompt.submit context for everyone; the prompt.context block and the inboxReminderContextWorks learning code are removed. After a compaction the SessionStart compact command hook's line is now the one copy. - A resumed conversation (an assistant row already in $.session.messages()) gets the session's open Inbox threads as its first prompt's context, once, and no second reminder; guarded users get it too. - Docs: 2.1.314's guard also skips session.compact, and the ExitPlanMode matcher does not stop the classic.PermissionRequest notice; both remain. Part of #2243.
) Review fixes for #2413: - Record in $.store (inboxReminderSessions, newest 500) each session id whose first prompt entered with the reminder; a resumed conversation without the record (an older mod's, or one from before the Inbox ran) gets the reminder once plus its threads, with it only its threads. - Class a conversation at first sight whatever session.start has decided, so a first prompt that outwaits the gate does not make the next look resumed. - An in-process /resume back to a session this process saw gets its threads again. - Docs: the marketing Inbox page and the agent guides say what ships, the ~4 s bound on a resumed first prompt, and the two notices left.
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2243.
What it fixes
On Team/Enterprise accounts Claude Code's built-in
cc-plugin-sec-defaultsits in theprependtier and sendsprompt.context, everyclassic.*event andsession.compact(and a few events the mod does not hook) past user plugins. For each hook of ours the engine passes by that way, Claude Code prints, once per session id:Two findings from Claude Code 2.1.314 (its
claude plugin testkit under a temp HOME, and its host code):classic.SessionStart {source:'resume'}printed at every startup (oronbz's report).$.store.on()works only insideregister(), andregister()runs before$exists: anengine.createstep runs after it,$.storeis refused there, andon()afterregister()returned throws. So "don't register when the store says false" can't be built.So the mod no longer registers either hook:
prompt.submitcontextfor everyone (that event is not skipped). This was already the guarded path from Inbox reminder reaches Team/Enterprise sessions and survives compaction (#2159) #2167. Theprompt.contextblock and theinboxReminderContextWorkslearning code are gone. After a compaction, the existingSessionStartcompactcommand hook still printsPLANNOTATOR_INBOX_REMINDER, and that is now the one copy. Before, standard users also got the re-madeprompt.contextblock, so they had two.classic.SessionStarthook. A resumed conversation ($.session.messages()already holds an assistant row when this process first sees it) gets the session's open Inbox threads as its first prompt's context, and the Inbox is asked once per conversation. Guarded users now get the list too; before, the guard skipped it. The conversation is classed at first sight, even whensession.starthas not decided yet, so a first prompt that outwaits the 2.5 s gate does not make the next one look resumed.prompt.contextblock was never in the transcript, so a conversation started under the old mod and resumed would have none. The mod now records in$.store(inboxReminderSessions, newest 500) each session id whose first prompt entered with the reminder. On resume, a session id with the record gets only its threads; one without it (an older mod's conversation, or one from before the Inbox ran) gets the reminder once plus its threads, and is recorded. A fork has a new id, so it may get a duplicate line. An in-process/resumeback to a session this process already saw gets its thread list again.What it does not silence
Under the guard, Claude Code still prints:
its classic.PermissionRequest hook was skippedat the first permission prompt of a session. The hook is matched on ExitPlanMode, which does not help (see above). Removing it would rely on the Claude Code mod: one plan approval when the plugin guard skips the mod's hook (#2007) #2043 approval record, and CLIs older than that would get a second plan review.its session.compact hook was skippedat the first compaction. Guarded users also get the plain reminder after a compaction, without the thread list.claude-code-mod.mdsaid the opposite of both; that is corrected.Not covered, by choice: subagents no longer get the reminder (they report to their parent, per the
plannotatorskill).Behaviour changes
prompt.contextblock also reached subagents' first messages.prompt.submitruns only for the main conversation, so subagents no longer get the reminder (guarded machines never gave it to them).Tests
Engine harness (
scripts/test-claude-code-mod.sh, Claude Code 2.1.314, temp HOME): 64 pass. The guard stand-in now mirrors 2.1.314's guard and reports each link of ours the engine bypassed (the trace the notice comes from). 8 of the tests fail on main, among them:prompt.contextorclassic.SessionStartlink to skip (on main the kit reports both notices);/resume, and with no open thread).5 fail on this PR's first head (0b7241b), for the review fixes:
session.startslower than the 2.5 s gate: the first prompt goes on bare and the next carries the reminder (it got none before);/resumeback to a session this process already saw gets its threads again.Bun:
apps/hook/hooks/mod/,packages/shared/inbox,tests/agents-md-size.test.ts.tscfor the mod andpackages/shared.claude plugin validate apps/hookpasses and lists noprompt.contextorclassic.SessionStarthook.Version skew
Mod-only change, so none between the mod and the CLI. On engines without hooks modules, the classic command hooks are unchanged. A stored
inboxReminderContextWorksis left in place and ignored; an older mod that reads it still works. The newinboxReminderSessionsrecord is the mod's own$.storekey; an older mod never reads it.Thanks @sshevlyagin for the report and the suggested direction, and @oronbz for the
classic.SessionStartsighting.