Repository navigation
fix(codex): stop 'hooks pending review' from reappearing on every Orca-launched Codex session - #7896
Conversation
…eappearing as pending review Approvals the user makes inside Orca-launched Codex are written by Codex into the runtime CODEX_HOME's config.toml. install() treated any runtime trust entry it didn't expect as stale and deleted it on the next launch, so users with personal hooks in ~/.codex/hooks.json (never approved outside Orca) re-approved the same hooks on every single launch. - hook-trust-promotion.ts: before install/refresh rewrites runtime files, translate externally-written runtime approvals back to the user's ~/.codex/config.toml keyed to their own hooks.json (content-signature mapping; managed status hooks are never promoted). A provenance snapshot of what Orca last wrote distinguishes fresh approvals from revoked mirrors, so system-side revocation still wins. - Mirror key-matched system user-hook trust hashes verbatim instead of requiring them to equal our recomputation, so user-hook trust survives Codex hash-algorithm drift (#7110-class bugs). - Extract shared codex-hook-identity.ts (event labels, signature, entry builder) to avoid a promotion<->hook-service import cycle. Verified live against codex-cli 0.143.0: a hook trusted with our computed hash executes; a wrong hash is suppressed. Co-authored-by: Orca <[email protected]>
📝 WalkthroughWalkthroughThis PR adds a shared Codex hook identity module for event labels, managed script names, trust-entry construction, and trust signatures. It extends trust config handling to support explicit trusted hashes and enabled states. A new promotion module snapshots runtime trust provenance and promotes matching runtime approvals into system trust config. Hook-service is updated to use the shared Codex utilities and to call promotion and snapshot steps during install and refresh flows. A Vitest suite and tsconfig include list are updated to cover the new behavior. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 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 |
…pshot On the first launch after upgrading (no snapshot yet), a mirrored copy of system trust that the user has since revoked or disabled in ~/.codex is indistinguishable from an in-Orca approval. Promoting it would resurrect revoked trust into the user's real config. Skip promotion for that launch; install() writes the first snapshot and promotion starts on the next one. Found by adversarial review; regression tests cover both sequences (revoked block resurrected, disabled hook flipped back to enabled). Co-authored-by: Orca <[email protected]>
|
Live end-to-end verification (real
The reported loop is reproduced-then-fixed against the real binary, including the visible notification lifecycle. |
…ve-override guard, gate test path - Restore per-launch Codex hook upkeep on the interactive PTY launch path via a shared maintainCodexLaunchHooks() helper (fire-and-forget from the sync spawn path, awaited from commit-message prep). This keeps #7896's runtime /hooks approval promotion + user-hook refresh running on every Codex launch, which the presence-gating refactor had dropped from the interactive path. Enabled installs stay presence-gated. - Relay CLI presence: report 'unknown' for a relative (non-absolute, non-home) override path instead of probing it against the relay process CWD, mirroring the local detector's guard. Adds a regression test. - Repoint the agent-hooks.cli-presence-gating reliability gate at the split-out ssh-relay-session-agent-hook-presence.test.ts where those assertions now live.
…ller loop, honest Windows-remote presence - Launch-prep no longer drops #7896 approval promotion when the presence gate skips the managed install (false-'missing' PATH probe or relative command override). Promotion now runs on every Codex launch; only the managed-config write stays presence-gated. Guarded by a new predicate test. - Remove the now-dead duplicated installer loop + errorStatus from install-telemetry (production uses the CLI-safe copy in controls); keep the electron-coupled recorder there and test it directly. Add fail-open loop coverage to controls where the loop actually lives. - Relay Windows presence reports 'unknown' (honest) instead of a false 'missing'; drop the unused 'unsupported_remote_platform' skip reason.
Reconcile presence-gated Codex launch prep with main's #7969 WSL runtime-home status-hook install: - WSL runtime-home installs (installForRuntimeHome/refreshRuntimeUserHooksForRuntimeHome) run unconditionally and synchronously — never presence-gated, since the Windows-side PATH probe cannot see a codex CLI living inside the WSL distro (gating it would regress #7969). - Non-WSL launches keep the presence gate plus the always-run #7896 approval promotion from this branch's review fixes. - Keep both new tsconfig.cli entries and the added imports (getDefaultWslDistro, codexLaunchNeedsDirectApprovalPromotion).
|
thanks for reporting. looking into it |
…a-launched Codex session (stablyai#7896) Co-authored-by: Orca <[email protected]>
Problem
User report: "Whenever I launch Codex in Orca, I receive a notification that there are hooks pending review; even after I acknowledge them, the notification reappears upon subsequent launches."
Root cause (reproduced in a test before fixing): Orca launches Codex with a managed runtime
CODEX_HOMEand mirrors the user's~/.codex/hooks.jsonhooks into it. Trust for those mirrored hooks is only carried over when it already exists in~/.codex/config.toml. When a personal hook was never approved outside Orca:/hooks→ Codex writes the trust entry into the runtimeconfig.toml.install()'sremoveStaleRuntimeHookTrustEntriesdeletes every runtime trust entry not in its expected set — the user's approval isn't in that set → wiped. Prompt returns. Forever.This only hits users with personal hooks in
~/.codex/hooks.jsonthat lack system-side trust, which is why most users never see it.Fix: write-back promotion (
~/.codexstays the single source of truth)hook-trust-promotion.ts— before install/refresh rewrites the runtime files, approvals Codex wrote into the runtimeconfig.tomlare translated back to the user's~/.codex/config.toml, keyed to their ownhooks.json(mapped by hook-content signature, so the prepended managed hook and dedupe-collapsed duplicates are handled; one approval promotes to every identical system entry). The normal mirror path then picks the trust up on the same launch and it survives stale cleanup — permanently, including for terminal Codex sessions..orca-hook-trust-provenance.jsonin the runtime home) — records what Orca last wrote, so a fresh Codex approval is distinguishable from an Orca-mirrored entry whose system backing the user has since revoked. Revocation in~/.codex/config.tomlstill wins and is not resurrected. When no snapshot exists yet (first launch after upgrading to this build, or a corrupted snapshot), promotion sits the launch out entirely — a stale mirror of since-revoked trust is indistinguishable from an approval, and resurrecting revoked trust is the one failure we must never have. Install writes the first snapshot; promotion starts on the next launch.~/.codexfor Orca's managed hooks — promotion explicitly excludes managed commands; the isolation that the runtimeCODEX_HOMEexists for is preserved.codex-hook-identity.tsextracts the shared event-label maps / content signature / trust-entry builder out ofhook-service.ts(which shrank) to avoid an import cycle.Verification
~/.codex/config.toml; steady-state launches rewrite nothing), revocation not resurrected (including the two post-upgrade resurrection sequences below), in-Orca/hooksdisable propagating back to the system config, Codex hash-drift survival, dedupe fan-out, hook-deleted-from-system skip, the hooks-disabled refresh path, managed-hook exclusion, and upgrade-path no-op guarantees (first launch with no provenance leaves~/.codexbyte-identical).pnpm typecheck(node+cli+web), lint, and the max-lines ratchet green.CODEX_HOME: a SessionStart hook trusted with Orca's computed hash executed; the same hook with a wrong hash was suppressed — confirming both the hash reproduction and the trust gate this design relies on.~/.codexbetween their last old-build launch and the upgrade — fixed in 8e1e9c8 with both sequences pinned by regression tests (mutation-checked: the tests fail without the guard). Environment pass (Windows keys, WSL separation, SSH remote, CLI-offline compile, concurrent writers, macOS realpath) came back clean.Upgrade behavior
First launch on this build never writes to
~/.codex(promotion is disabled until the first provenance snapshot exists). A user currently stuck in the loop approves one final time; that approval is promoted on the following launch and the prompt never returns.Crash-triage summary
Description
Fixes the uncaptured macOS report submitted at 2026-07-09T03:39:48Z: an Orca-launched Codex session repeatedly showed hooks pending review after the user approved the hook, with Codex running under Orca’s managed
CODEX_HOME. Orca now promotes a user’s approval from the managed runtime config back to the matching personal hook in~/.codex/config.toml, so the next managed-home refresh preserves it.Clear, undeniable fix evidence
The regression test
keeps an in-Orca approval of a user hook across launches and promotes it to ~/.codexencodes the reported loop at the realCodexHookService.install()seam:Current-main verification:
pnpm exec vitest run --config config/vitest.config.ts src/main/codex/hook-trust-promotion.test.ts— 12/12 passed.ELI5
Orca gives Codex a separate “home folder.” The user approved a hook inside that folder, but Orca rebuilt the folder on the next launch and threw the approval away. Orca now copies approvals for the user’s own hooks back to their normal Codex settings before rebuilding, so Codex remembers the answer.
Trade-offs
~/.codex/config.toml. This is the intended persistence point, but it is a new write to the user’s normal Codex config.~/.codex/config.tomlremains authoritative.