Repository navigation
fix(codex): approve Orca's hook in managed Codex homes with Codex's own hash - #25742
Conversation
There was a problem hiding this comment.
ℹ️ No critical issues — one narrow gap worth a look.
Reviewed changes
- Codex's own hash, asked from a throwaway home. New
codex-hook-trust-derivation.tsasks one Codex binary for its hash of Orca's entry, cross-checking the same entry at group 0, after a dummy group, and from a trusted project folder; the answer is cached per binary fingerprint and version in the newcodex-hook-trust-memo.ts(codex-hook-trust.json). - Approval-first write with rollback. New
codex-hook-approval-first-write.tswrites the[hooks.state.*]approval before thehooks.jsonentry, and on failure takes back only its own approval (preserving a switched-off key verbatim, never another writer's).installCodexHooksExclusivelyis rewired to it, and the managed-home background grant session is removed. - Status rebuilt around the answer.
codex-hook-status.tsnow reads the home's files and compares Orca's entry/approval against Codex's last answer (installed/partial/not_installedplus a reason); the ledger-based status path is dropped. - Wait only where Codex is launched.
launchesCodexthreads through the PTY spawn env so only an Orca-launched Codex waits up to 3 s for the answer; plain terminals and structured launches go ahead. - App-start warm-up and CI contract. The lookup starts after shell-PATH hydration in
main-process-ready-runtime.ts; CI adds a pinned-and-latestcodex-hook-file-entry-binary-contractgate, and the CLI status line now names the file each agent reports on.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
256e90a to
9d5efd6
Compare
3c8e2eb to
76f82d4
Compare
9d5efd6 to
668ae79
Compare
…e, cross-checked by position and path
…one at a time and only by the app
…ly its own on failure
…own hash, written first Managed homes (the shared mirror and per-account homes) no longer run a background approval session. Status reads the home's files against Codex's answer, and turning hooks off recognizes every saved version's hashes.
…p their background approval The previous commit carried only the managed resume's wait; this one holds the managed install it relies on. Managed homes (the shared mirror and per-account homes) write Codex's hash before the entry, fall back to their own approvals when the answer is late, and strip Orca's entry only when Codex itself answered with nothing to approve. Status reads the home's files against Codex's answer, and turning hooks off recognizes every saved version's hashes.
… hash; warm it after PATH hydration
… homes, on both pins and latest
…g a plain terminal's
…vals and opt-out re-asking
…rca's own hash, as main did A late, temporary or missing answer with no earlier approval in the home now writes main's self-computed approval instead of leaving the hook out. Codex's answer replaces it at the next install, a definitive answer (no hooks/list, a refused cross-check, 0.128) never uses it, and status says the approval is Orca's until Codex confirms it.
Until Codex answers, a managed home kept only the events it had already approved and dropped Orca's entry from the rest. Each event now keeps the home's approval, else gets Orca's own hash, as main wrote every event. One reader of the approval at Orca's entry serves the stopgap and status.
…disk-only memo - One answer type with a kind (hashes, refused, pending) replaces two types and the three-field decoding at each caller. - The lookup keeps one in-process answer per binary path, replacing the process memo, the global latest answer and the transient-failure map; status now reads the answer for the codex on PATH, not the last one asked. - The memo file keeps Codex's refusals per version, like its hashes. - Derivation takes the version it is given; one 30 s version-probe timeout. - The launch wait reuses withTimeout, and launch prep passes launchesCodex down instead of a wait in milliseconds. - Turning hooks off no longer forgets Codex's answer. - Tests mock the derivation instead of a test-only resolver in production.
…entical scope checks
… Orca's entry may carry
…tatus checks the binary's fingerprint Also names the lookup functions for the answer they return.
… branch reads its own status
9a95263 to
4c50d0e
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (25)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughCodex hook installation now derives and caches hashes from Codex hook listings. Managed trust approvals are written before hook entries and restored when eligible writes fail. Status reads use Codex answers and managed hook slots. Launch preparation passes Codex-specific context through spawn and startup paths. The pull request adds unit, integration, binary-contract, CI, and CLI status coverage. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No identified issue currently prevents merging after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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:
68518ee0-cb0b-4903-8e29-6b75a32b1043
📒 Files selected for processing (51)
.github/workflows/pr.ymlconfig/scripts/pr-code-change-scope.mjsconfig/scripts/pr-code-change-scope.test.mjsconfig/tsconfig.cli.jsonsrc/cli/handlers/agent-hooks.test.tssrc/cli/handlers/agent-hooks.tssrc/main/agent-hooks/local-agent-cli-presence.tssrc/main/agent-hooks/managed-hook-script-refresh.test.tssrc/main/agent-hooks/managed-hook-stdin-lifecycle.test.tssrc/main/agent-hooks/windows-hook-post-interpreter.test.tssrc/main/codex-accounts/runtime-home-service-per-account-migration.test.tssrc/main/codex/codex-app-server-client.tssrc/main/codex/codex-hook-approval-first-write.test.tssrc/main/codex/codex-hook-approval-first-write.tssrc/main/codex/codex-hook-definition.tssrc/main/codex/codex-hook-file-entry-binary-contract.test.tssrc/main/codex/codex-hook-hash-lookup.test.tssrc/main/codex/codex-hook-hash-lookup.tssrc/main/codex/codex-hook-local-install.tssrc/main/codex/codex-hook-local-maintenance.tssrc/main/codex/codex-hook-orca-approvals.tssrc/main/codex/codex-hook-service-implementation.tssrc/main/codex/codex-hook-status.tssrc/main/codex/codex-hook-trust-cleanup.tssrc/main/codex/codex-hook-trust-derivation.test-fixture.tssrc/main/codex/codex-hook-trust-derivation.test.tssrc/main/codex/codex-hook-trust-derivation.tssrc/main/codex/codex-hook-trust-memo.test.tssrc/main/codex/codex-hook-trust-memo.tssrc/main/codex/codex-hook-user-mirroring.tssrc/main/codex/codex-managed-trust-reconciliation.tssrc/main/codex/codex-real-home-shared-entry.test.tssrc/main/codex/codex-trust-grant-host.tssrc/main/codex/config-toml-hook-trust-edit.tssrc/main/codex/config-toml-trust.tssrc/main/codex/hook-service-concurrent-launch-install.test.tssrc/main/codex/hook-service-managed-codex-hashes.test.tssrc/main/codex/hook-service-runtime-trust-repair.test.tssrc/main/codex/hook-service-test-harness.tssrc/main/codex/hook-service-trust-grant.test.tssrc/main/codex/hook-service-wsl-runtime.test.tssrc/main/ipc/pty-spawn-codex-home-unavailable.test.tssrc/main/ipc/pty/host-env/types.tssrc/main/ipc/pty/ipc/spawn-env-codex.tssrc/main/ipc/pty/runtime/spawn-preflight.tssrc/main/startup/codex-hook-hash-warmup-wiring.test.tssrc/main/startup/codex-launch-during-real-home-grant.test.tssrc/main/startup/codex-launch-per-agent-hook-opt-out.test.tssrc/main/startup/codex-launch-preparation.tssrc/main/startup/codex-session-resume-launch.tssrc/main/startup/main-process-ready-runtime.ts
💤 Files with no reviewable changes (1)
- src/main/codex/codex-trust-grant-host.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
…es any hash and writes only on change
…mirrored user approvals, and one rule says which hashes are Orca's
…tes, as Codex on Windows reads only the backslash one

ELI5
Codex asks you to review any hook it hasn't seen approved. Orca's status hook needs an approval written with Codex's own fingerprint ("hash") of the hook. In Orca-managed Codex homes (the shared one and each signed-in account's), Orca used to get that approval by running a background Codex session on every launch. Now Orca asks the installed Codex once per Codex version for that fingerprint, in a throwaway folder, remembers it, and writes the approval before the hook.
What Changed
codex app-serversession to approve Orca's hook, which could take up to about 10 s. If that failed, Orca wrote a fingerprint it computed itself, which has drifted from Codex's before (Fix Codex hook trust hash for matcherless events (UserPromptSubmit/Stop) #7110).Until Codex answers (it's late, not found, or the app hasn't asked yet), each event keeps the approval the home already has, and any event without one gets Orca's own fingerprint, so every event has Orca's hook, as before. Status says "Approved by Orca; not yet confirmed by Codex". Codex's own fingerprint replaces it at the next launch.
A user hook's leftover approval no longer counts as Orca's. Approvals are filed by position. If a user removes a hook listed before Orca's, that hook's old approval ends up in Orca's position. Orca used to keep it, write nothing and report "installed", while Codex put Orca's hook up for review. Now Orca keeps an approval only if it holds Orca's own fingerprint or one Codex gave for Orca's hook; otherwise it writes Orca's fingerprint.
Asking once. At app start, once the shell PATH is loaded, Orca asks the installed Codex for its fingerprint of Orca's hook. It runs
hooks/listin a throwaway Codex home and remembers the answer per Codex version. Launches in managed homes then write the approval first, then the hook, and start nothing. An unchanged launch reads two files.Waiting. A Codex launch waits at most 3 s for an answer it doesn't have yet. Plain terminals don't wait. If the answer is late, Orca keeps the approvals the home already has.
When the hook is removed. Orca removes its hook from a managed home only when Codex itself answered that it can't be approved:
hooks/list(status says to update Codex);"Codex not found" (for example, before the shell PATH is loaded) never removes a working hook.
Codex 0.128. It lists hooks without fingerprints and has no approval system, so Orca writes the hook with no approval.
Turning hooks off removes Orca's approvals written with any remembered Codex version's fingerprint. Orca keeps Codex's answer, so turning hooks back on starts nothing new.
orca agent hooks statusnow prints which file each status is about.~/.codexitself is unchanged in this PR. A follow-up moves it to the same approach. WSL keeps its current approval session.Why
orcacommands never start Codex.Linked Issue
Fixes #
Visual Proof
N/A: no UI change. The only visible difference is the hook status detail text.
Testing
hooks/list;codex execruns it with no review;Notes
.cmdshims get their version re-checked once per app run.codex --versionand one shorthooks/list.--version.