Repository navigation
fix(claude): write only the hook events and statusLine the user's Claude accepts - #23614
Conversation
…s it gates Pure move of claude-session-end-hook-capability.ts and its tests; the next commit turns its one-event SessionEnd floor into a per-event version table.
Claude 1.0.81 through 2.1.100 validate settings.json `hooks` against a closed event enum and discard the whole file on one unknown name, so Orca's install made Claude <= 2.1.77 silently ignore the user's env, permissions and hooks. Each managed event now carries the first Claude release that knows it (pinned to per-release enums read from the npm packages), and install, status and the SSH/WSL relay installer write only the events the resolved Claude accepts. An unresolved version gets the set every tabled Claude knows; a downgrade removes only Orca's own entry for an event the older Claude would reject.
…module hook-settings.ts is at its line limit; the event list and its version gate move out whole so the next change has room.
…ntries A failed or timed-out version probe is no evidence of an old Claude, so it must not strip StopFailure, PermissionRequest and the other newer events a version-aware install wrote. With the version unknown, install adds only the set every tabled Claude knows and leaves every other entry exactly as it is; only a known version that lacks an event retires Orca's entry.
…ed them Claude validates hooks against a closed event list from 1.0.23, not 1.0.81. The table treated SessionStart, UserPromptSubmit, Stop, SubagentStop, PreToolUse and PostToolUse as known by every resolved version, so a Claude from 1.0.23 to 1.0.61 was still sent names it rejects, and it dropped the whole settings file. Pin each to its first release from the packed enums and keep the unresolved-version set as its own policy.
Claude 1.0.49 through 1.0.66 also reject any unknown top-level settings key, and statusLine joined that schema only in 1.0.64. Orca wrote its statusLine for every Claude, so 1.0.49 to 1.0.63 still dropped the whole settings file even with the event gate. Gate statusLine on 1.0.64, pinned by the packed schemas; a known older Claude has Orca's own statusLine removed along with the opt-out marker, so an upgrade re-adds it. An unresolved version is now assumed to be 1.0.64, which knows the same core events and keeps the statusLine install it had before.
Retiring Orca's statusLine for a Claude older than 1.0.64 forgets the install marker only when Orca's own statusLine was removed. Pin that, so a user who deleted Orca's statusLine is not opted back in by an upgrade.
…ct schema Claude 1.0.49 through 1.0.66 discard the whole settings file over any top-level key their schema lacks. The fixture recorded only whether each release knew statusLine, so a new top-level key Orca wrote would pass every test. Record each release's top-level keys instead (statusLine is derived from them), add the hook enums for every packed release in that window, and check that a real install and a downgrade write only keys and events each strict release accepts.
Qoder (#23581) reuses the Claude settings writer for its own settings file, so it gets a fixed plan from its own events instead of Claude's version table: every Qoder event installed, nothing retired, statusLine left alone.
Review status: ready for reviewHead: Does it fix the problem? Yes. On Claude 2.1.77 and older, Orca's hook install made Claude throw away the user's whole
Orca now writes only what the resolved Claude accepts. A live Windows run with pinned Claude releases confirmed it:
Architecture: one version table records the first Claude release that knows each hook event, plus a floor for
Review loops: four, the last clean. Fixed along the way:
The architecture loop found that Orca writes only two top-level keys ( Validation:
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe change adds Claude CLI version gates for hook events and the status line. ClaudeHookService uses version-derived plans for local and remote installation, status checks, and status-line handling. Hook settings apply planned event installations and retirements while retaining remaining user hooks. Qoder receives a plan that installs its configured events and leaves the status line unchanged. Priority: ⬆️ High Merge Risk: 🟡 Moderate · up to Remote downgrades can leave settings that older Claude rejects, potentially causing it to ignore the entire file. Fix remote status-line retirement before merging; the empty-plan status also needs correction. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Version-aware installation reduces the chance that older Claude versions reject a user's entire settings file. One installation-status edge case remains: a version too old to support any managed hook can be reported as installed. Version detection and remote downgrade behavior also leave some compatibility uncertainty. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 16 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: f090c7c3-3604-41f6-ad81-c173450b72b6
📒 Files selected for processing (21)
config/tsconfig.cli.jsonsrc/main/agent-hooks/managed-agent-hook-controls.test.tssrc/main/agent-hooks/managed-agent-hook-controls.tssrc/main/agent-hooks/managed-hook-detection-commands.tssrc/main/claude/__fixtures__/claude-hook-event-enums.jsonsrc/main/claude/claude-hook-event-install.test.tssrc/main/claude/claude-hook-event-versions.test.tssrc/main/claude/claude-hook-event-versions.tssrc/main/claude/claude-managed-hook-events.tssrc/main/claude/claude-session-end-hook-capability.test.tssrc/main/claude/claude-session-end-hook-capability.tssrc/main/claude/claude-session-end-install.test.tssrc/main/claude/claude-settings-schema-install.test.tssrc/main/claude/claude-status-line-install.test.tssrc/main/claude/compact-status-registration.test.tssrc/main/claude/hook-service.test.tssrc/main/claude/hook-service.tssrc/main/claude/hook-settings.tssrc/main/qoder/hook-service.test.tssrc/main/qoder/hook-service.tssrc/relay/managed-hook-installer.ts
💤 Files with no reviewable changes (3)
- src/main/claude/claude-session-end-hook-capability.test.ts
- src/main/claude/claude-session-end-install.test.ts
- src/main/claude/claude-session-end-hook-capability.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| const missing: string[] = [] | ||
| let presentCount = 0 | ||
| for (const event of this.options.events ?? CLAUDE_EVENTS) { | ||
| for (const event of this.managedHookPlan(options).install) { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Do not report an empty hook plan as installed.
If the resolved version is 1.0.22, every managed event is below its release floor. The loop checks no events, so getStatus reports installed while managedHooksPresent is false. install returns that same misleading status even though it registered no hooks. Return an unsupported or not-installed state when the plan has no install events.
| const nextConfig = applyManagedHooks( | ||
| config, | ||
| hook, | ||
| remoteScriptFileName, | ||
| this.managedHookPlan(options) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Apply status-line retirement during remote downgrades.
If a remote settings file contains an Orca-owned statusLine from an earlier install, a downgrade to Claude 1.0.63 selects statusLine: 'retire'. installRemote applies the plan only to hooks and writes the existing statusLine unchanged. The fixture shows that 1.0.63 rejects this key under its strict schema, so it can discard the entire settings file. Apply remote retirement before writing settings. Keep remote status-line installation disabled.
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline.
Reviewed changes
Reviewed the full branch-vs-main diff: the Claude hook install path now gates what Orca writes into ~/.claude/settings.json on the resolved Claude version, so an older Claude no longer discards the whole settings file over an unknown hook event (or, below 1.0.64, Orca's statusLine).
- Version table — new
claude-hook-event-versions.tsholdsCLAUDE_HOOK_EVENT_FIRST_VERSIONS(first release whose packed enum contains each event), the 1.0.64statusLinefloor,UNRESOLVED_CLAUDE_VERSION, and theclaude --versionparse/probe moved verbatim from the deletedclaude-session-end-hook-capability.ts. - Plan — new
claude-managed-hook-events.tsholds the event list plusgetClaudeManagedHookPlan(version)returning{ install, retire, statusLine }, and fixed plans for OpenClaude and Qoder. - Install/status —
applyManagedHooksnow consumes a plan;install/getStatus/installRemoteresolve it from the version, and a downgrade removes only Orca's own entries and itsstatusLine(with its opt-out marker). - Fixtures/tests — the per-release event enums and top-level settings schemas are checked in and pin every table value to the release just before and at the boundary, plus whole-file schema tests for the strict releases.
I independently re-fetched the @anthropic-ai/claude-code npm tarballs and extracted the packed event enum for every boundary pair: all 13 table values and the 1.0.64 statusLine floor are exactly correct (SessionStart 1.0.61→1.0.62, StopFailure 2.1.77→2.1.78, PostCompact 2.1.75→2.1.76, TeammateIdle 2.1.32→2.1.33, SessionEnd 1.0.84→1.0.85, SubagentStart 2.0.42→2.0.43, PermissionRequest 2.0.44→2.0.45, PostToolUseFailure 2.0.55→2.0.56, and the 1.0.x boundaries). statusLine is absent from the 1.0.63 schema and present in 1.0.64. The changed and adjacent suites pass, as do pnpm tc:node and pnpm tc:cli.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| const missing: string[] = [] | ||
| let presentCount = 0 | ||
| for (const event of this.options.events ?? CLAUDE_EVENTS) { | ||
| for (const event of this.managedHookPlan(options).install) { |
There was a problem hiding this comment.
Settings/CLI read status via MANAGED_AGENT_HOOK_STATUS_READERS, which calls getStatus() with no version, so this loop falls back to the unresolved plan's six core events. That mislabels a complete install on a Claude older than 1.0.62 — e.g. 1.0.52 knows UserPromptSubmit only from 1.0.53 and SessionStart from 1.0.62, so its correct four-event install reads partial, and anything below 1.0.23 reads not_installed, even though install() itself (version-aware) returns installed. Worth confirming this asymmetry is the intended tradeoff versus threading the probed version into the status reader.
Technical details
# Version-less status reader disagrees with the version-aware install
## Affected sites
- `src/main/claude/hook-service.ts:101` — `getStatus()` checks `managedHookPlan(options).install`; with `options = {}` that is the 1.0.64 core set for every caller that cannot supply a version.
- `src/main/agent-hooks/managed-agent-hook-registry.ts:115` — `['claude', () => claudeHookService.getStatus()]`, the Settings/CLI reader, passes no version.
## Required outcome
- Either the status surface and the install agree on what "installed" means for a known-old Claude, or the divergence is documented as intended.
## Open questions for the human
- Is `partial` acceptable for a 1.0.52 user with a complete managed install? If not, the resolved version needs to reach the status reader (probe at status time, or persist the chosen plan/version alongside the marker).…3614) into #23059 Conflicts, resolved to keep main's mechanism and #23059's turn facts: - Codex turn boundaries and translator: main's #23682 wins; the error-driven `fail` end and the oversized-notification settler are gone, and only `turn/completed` ends a turn, a command's turn included. - Codex adapter: the compaction tracker stays deleted; #23618's settlement of sends in an ended turn is kept, and `codexDispatchRejection` is imported from its new home. - Journal reducer: main's per-item creating fence (#23456) moves into the item and submission folds this branch split out of the reducer. - Stale-turn verdict: main's proof-of-death revision; every turn revision states the thread scope. - Failure words: main's retry-control rules (#23608) with this branch's any-command retry step; `commandRefused` drops its retry step beside a Retry, as hostFault does. - Delivery: both the commit wake and main's death-evidence resettle and dispose. - Fold row and transcript slots: both the turn-outcome flag and main's `agentId`. - pr.yml and pnpm-lock.yaml taken from main. Beyond the conflicts, the merged files needed: - use-structured-agent-session: both sides added the same `submissions` key; one kept. - structured-agent-session-projection: the root-item import main still used is unused here. - The desktop message list and the mobile chat view each grew past the line limit from both sides' additions: the turn-membership memo moves into its own hook, and the mobile list footer (live status, then waiting rows) into its own helper.

ELI5
Orca adds its status hooks to Claude's settings file,
~/.claude/settings.json. Older Claude versions check every hook name in that file against a fixed list. If they find even one name they don't recognise, they throw away the whole file. That includes your environment variables, your permissions and your own hooks. On the versions we captured, an interactive Claude stops at a "Settings Error" screen whose default choice quits, andclaude -pgives no warning at all. Orca was writing hook names that are newer than those Claude versions, and on some mid-2025 versions astatusLinesetting they reject the same way. So on an older Claude, turning on Orca's status tracking switched off all of your Claude settings, and an interactive Claude could stop at that error screen on every start. Orca now writes only the hook names and settings that your Claude version understands.What Changed
Before: on Claude 2.1.77 or older, Orca's install added hook names such as
StopFailure(added in 2.1.78) andPostCompact(2.1.76). On Claude 1.0.49 to 1.0.63, which also reject any unknown top-level setting, thestatusLineOrca writes for its usage display had the same effect; those versions learnedstatusLinein 1.0.64. Claude then ignored the whole settings file: API/Bedrock environment, allow and deny rules, and every hook the user had written.claude -p): nothing is shown. 1.0.8x logs the error only under--debug, and 2.1.77 logs nothing; the run simply goes ahead without the user's settings.After: Orca adds only the hook events that the Claude it found knows about, and writes its
statusLineonly if that Claude knows it. That Claude keeps reading the file, and all of the user's settings still apply. After the user upgrades Claude, the next install adds the newer events. Orca installs when it starts, when status hooks are turned on in Settings, and on each SSH or WSL connection.How it works:
hooksandstatusLine. In every Claude release checked, the hook entry and matcher objects accept Orca's fields or silently drop unknown ones (timeoutis ignored before 1.0.41), so the event table and thestatusLinefirst release are the only parts that depend on the version.claude-hook-event-versions.tsholds a table with one entry per event Orca installs: the first Claude release whose list of known hook names includes it.@anthropic-ai/claude-code. Claude has checked user settings against that list since 1.0.23, so the table goes back that far. The six core events have real first releases too, such as SessionStart (1.0.62) and UserPromptSubmit (1.0.53).statusLinehas its own first release,CLAUDE_STATUS_LINE_FIRST_VERSION(1.0.64), read from each release's settings schema the same way.__fixtures__/claude-hook-event-enums.json. That includes the release just before each event first appears. The same file records, for every packed release from 1.0.48 to 1.0.67, the settings schema's full list of top-level keys and whether it rejects any other key. A test pins every table value and thestatusLinefloor to those records, so each entry is exact, not just safe. Another test runs a real install, and a downgrade from a current Claude, for each strict release among them and checks that every top-level key and hook name in the written file is one that release accepts. A key Orca starts writing later fails that test without anyone having to add a new check for it.getClaudeManagedHookPlan(version)inclaude-managed-hook-events.tsturns the Claude version into a plan. The plan lists the events to install, the events whose Orca entry must be removed, and whether to write or remove Orca'sstatusLine. Install, status and the remote installer all use it; the remote installer never writes astatusLine, as before. The event list moved to that file sohook-settings.tsstays under its line limit.claude --versionon the path it resolved for a local install, and the relay's own agent detection for SSH and WSL, where the remote Claude version is used. No new probe was added.claude --versioncan't be read, Orca falls back to the unknown-version set below: the six core events and thestatusLine, which every Claude since 1.0.64 accepts.statusLine, as it did before. Every Claude since 1.0.64 (30 July 2025) accepts all of that. A Claude older than that is only protected when its version is known; then it gets exactly the events its own list has, and nostatusLineif it predates 1.0.64. A known Claude older than 1.0.23 gets no events at all, because its hooks setting has a different shape.statusLine: a known Claude older than 1.0.64 loses Orca'sstatusLinebut never one the user set, and Orca forgets that it had installed one, so an upgrade adds it back instead of reading the removal as the user opting out.~/.openclaude/settings.json, and it accepts every event Orca writes. Orca still never writes astatusLinethere.~/.qoder/settings.jsonand is never gated on a Claude version. Orca never writes astatusLinethere.Why
statusLineit always wrote, which every Claude from the last 14 months understands. Adding none would leave the sidebar with no status at all whenever the check fails.Known limitation
~/.claude/settings.jsonis one file shared by every Claude binary on the machine. Orca only knows the version of the one Claude it resolves. If the user also runs an older Claude from a different path, that Claude can still see events (or, before 1.0.64, astatusLine) it doesn't know, and on 2.1.100 or older it will ignore the settings file. The same applies on an SSH host or WSL distro that has more than one Claude installed. Claude 2.1.101 and newer ignore only the unknown hook name and keep the rest of the file.An unknown version is treated as 1.0.64, so a Claude older than that whose version check fails still gets a file it rejects, as it did before this PR.
One more gap: if the user downgrades Claude and the version check then fails, the newer Orca entries from the earlier install stay in the file until a check succeeds. This is deliberate. A failed check is far more likely on a modern Claude that is merely slow to answer than on a downgraded one. The same holds for a downgrade while Orca is running: the file is corrected at the next install, not at the moment of the downgrade.
Linked Issue
N/A. This was found by checking Orca's installed hook names against the hook-name lists in Claude's npm releases, and confirmed against real Claude binaries from 1.0.81 to 2.1.283 on 2026-09-28. The releases before 1.0.81 were checked in their packaged code only, not run; that includes the settings schemas behind the
statusLinefloor. Whether the top level rejects unknown keys was checked in 65 packed releases from 1.0.0 to 2.1.100, not in every release.Visual Proof
Orca's UI does not change. Both captures are Claude 2.1.77 starting interactively on Windows, rendered from the recorded terminal output, with paths replaced by placeholders. Before: the settings file Orca's install wrote before this PR.
After: the settings file this branch's install writes for 2.1.77, plus the user's own env value and hook. Claude starts, the user's hook fires with the user's env visible, and the turn runs.
Testing
Added and updated tests:
claude-hook-event-versions.test.ts:statusLinefloor to the first release whose settings schema knows it, and checks that the release before it rejects unknown keys and lacksstatusLine.claude-hook-event-install.test.ts:statusLineexactly when that release knows it;envandpermissionssurvive installs at every version and after a downgrade;claude-status-line-install.test.ts:statusLine;statusLine, and an upgrade to 1.0.64 adds it back;statusLinethe user set survives an install for an old Claude;statusLinestays opted out across a downgrade and an upgrade;statusLine.claude-settings-schema-install.test.ts: for every strict release from 1.0.49 to 1.0.66, a real install, and a downgrade from a current Claude, write only top-level keys and hook names in that release's schema.hook-service.test.ts:statusLinewritten for every version;statusLineremoved without forgetting that it had been installed;statusLine;statusLinethere;statusLinefloor set to 1.0.63;statusLineeven when it had not been there to remove, which re-adds it after a user deleted it;enabledPlugins), which fails every strict release;statusLinewritten for every version, which fails 1.0.49 to 1.0.63;pnpm tc:node,pnpm tc:cli,oxlinton the changed files,pnpm run check:code-quality:changed, and vitest over the Claude hook and agent-hook installer, relay and SSH suites.Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Author X: @BrennanKB5
statusLine; entries an earlier install wrote stay. A known Claude older than 1.0.64 no longer gets astatusLine, and one Orca wrote earlier is removed.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)