Repository navigation
Inbox reminder reaches Team/Enterprise sessions and survives compaction (#2159) - #2167
Merged
Merged
Conversation
…on (#2159) cc-plugin-sec-default sends prompt.context past the mod, so guarded sessions never got the reminder. The mod now learns per machine whether prompt.context runs ($.store inboxReminderContextWorks) and, while it has no evidence that it does, adds the same line as the first prompt's prompt.submit context. After every compaction a SessionStart 'compact' command hook prints the reminder the mod publishes in PLANNOTATOR_INBOX_REMINDER (echo, which parses in sh, bash and PowerShell). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…CLI drops PLANNOTATOR_INBOX_REMINDER (#2159) The engine runs prompt.context before the mod's session.start has registered plannotator_inbox (live on 2.1.310), so the block was missing from every process's first conversation and the first turn taught false on standard machines. session.start now settles a promise with its decision (also on -p, mod off, a throw); prompt.context and the prompt.submit fallback wait on it, at most 2.5 s. The CLI removes PLANNOTATOR_INBOX_REMINDER at startup, so agent jobs and other children of a server the mod launched never inherit it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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 1 of #2159 (part 2 shipped in #2160), built as the approved spec (
inbox-reminder-guarded, options B + D′).What changed
On Team/Enterprise accounts, Claude Code's built-in
cc-plugin-sec-defaultsits in theprependtier and sendsprompt.contextpast every user-tier hook. The mod adds the Inbox reminder in that hook, so guarded sessions never got it.prompt.contextblock is unchanged.register.ts, pure rules ininbox.ts): a$.storekey,inboxReminderContextWorks, is read once per process. It becomestruethe first time the mod'sprompt.contexthook runs. It becomesfalsewhen a conversation's first main-loop turn completes without that hook having run. While the key is nottrue, a conversation's first prompt (notisMeta, not a slash command) carries the same reminder text asprompt.submitcontext. The conversation counts as reached only once the prompt has entered. Two kinds of turn teach nothing: an aborted first turn, and a resumed session ($.session.usage().startedAtmore than a minute before this process's firstsession.start).PLANNOTATOR_INBOX_REMINDERto the reminder text, with the tool's full registered name. It unsets the variable when the reminder gate is off.hooks.jsongains oneSessionStartcommand hook, matchercompact, commandecho "$PLANNOTATOR_INBOX_REMINDER", timeout 5 s. It never starts theplannotatorbinary. The engine trims hook stdout, so an unset variable adds nothing.inboxReminderentry, the mod's Inbox section, a new env-table row in CLAUDE.md/AGENTS.md, and the reminder section inreference/inbox.md.Duplicates, as accepted: a standard user gets one duplicate, in the first conversation after the update. After that, one per compaction (the re-made block plus the hook's line). A resumed guarded conversation gets the copy again. The "prompt.context hook was skipped" transcript note stays for guarded users (spec finding 7).
Engine and platform checks
prompt.submitcontext. Checked in the@anthropic-ai/[email protected]binary: the validator checkse.context, and the entered context becomes ahook_additional_contextrow (pen(it, "prompt.submit")). That build also trims a command hook's stdout before it becomeshook_successcontent. No gate was needed./bin/sh), so the variable is never set. Claude Code 2.1.310 runs a command hook in Git Bash, else in PowerShell (-NoProfile), never in cmd (e.shell ?? <bash|powershell>). The spec's[ -n … ] && printf …is a parse error in PowerShell. The hook therefore usesecho "$PLANNOTATOR_INBOX_REMINDER", which parses and exits 0 in sh, bash and PowerShell. In PowerShell the name is an empty PowerShell variable, so the hook prints only a newline, which the engine trims to nothing.inboxReminderEnvValuenever publishes a value with a backslash or a leading-, so dash'sechoprints the text unchanged. One side effect: without Git Bash, Claude Code shows its "a plugin hook ran in PowerShell" notice once, the first time any of the plugin's command hooks runs. The existing hooks already trigger that notice.Tests
apps/hook/hooks/mod/inbox-reminder.test.ts: the decision table (every row), the first-turn lesson, resume detection, and the env value. It also runs the command fromhooks.jsonfor real under/bin/shand/bin/bash, with the variable set and unset. It checks thecompactmatcher, and checks thatregister.tsspells the env name as the literal. A PowerShell case runs whenpwshis installed; it was skipped here.The engine harness (
apps/hook/tests/register.test.tsviascripts/test-claude-code-mod.sh, Claude Code 2.1.310, run with a tempCLAUDE_CONFIG_DIR) has 12 new cases. They use an inlineprepend-tier stand-in for the guard that doesnext.to(e, 'append')onprompt.contextandclassic.*:true;true, then nothing after/clear);falselearned, a copy in the next conversation);inboxReminder: false, noinbox.json, tool refused,PLANNOTATOR_INBOX_TOOL=0): no copy, and the variable unset;-p: nothing set.All 50 harness tests pass. A mutation that disables the copy fails 4 of them.
bun test apps/hook/hooks/mod/(218 pass before the new file),bun run typecheck,claude plugin validate apps/hook.Not run: a live Team-account session and a live
/compact(the manual checks in the spec).Follow-up: prompt.context ran before session.start had decided
The #2167 review reproduced a bug live on Claude Code 2.1.310. The engine runs
prompt.contextbefore the mod'ssession.starthas registeredplannotator_inbox. As a result, every process's first conversation had no block; main has the same bug. The first turn then learnedfalseon standard machines.session.startnow settles a promise with its decision as soon as the switch,inbox.jsonand the tool name are known. It also settles on the early returns (-p, mod off) and when it throws.prompt.contextand theprompt.submitfallback wait on that promise for at most 2.5 s.prompt.contextcall that runs out of time adds no block, but it still records that it ran. That way the machine is never learned as guarded.PLANNOTATOR_INBOX_REMINDERat startup (apps/hook/server/mod-session-env.ts), next to the other variables it takes from its host. Children of a server the mod launched, including Claude agent jobs, therefore never inherit it.prompt.contextfires whilesession.startwaits on a slow Inbox/mcp. The block lands and the store learnstrue. This case fails without the fix.falsegoes back totrue.session.usagemocked: a session started an hour before this process teaches nothing, and one started 2 s before still teachesfalse.Live check: an interactive Claude Code 2.1.310 session on a standard account, with
--plugin-dir apps/hook, the installed plugin turned off, a scratch data dir and haiku.plannotatorInboxblock is there and the store learnstrue.prompt.contextsettled after 214 ms, beforesession.start(359 ms)./clear: the block again, with no copy./compact: the block, plusSessionStart:compact hook success: Plannotator Inbox is on: …(the accepted duplicate). That hook finished with status 0 in 8 ms.true.Closes #2159.
🤖 Generated with Claude Code