Skip to content

Canonicalize linked worktree hook trust keys#24966

Draft
abhinav-oai wants to merge 1 commit into
mainfrom
abhinav/canonical-hook-trust-worktrees
Draft

Canonicalize linked worktree hook trust keys#24966
abhinav-oai wants to merge 1 commit into
mainfrom
abhinav/canonical-hook-trust-worktrees

Conversation

@abhinav-oai
Copy link
Copy Markdown
Collaborator

@abhinav-oai abhinav-oai commented May 28, 2026

Why

Fixes #23996.

Project hooks in linked Git worktrees were being discovered from the root checkout's .codex folder. That preserved a single trust state, but it also meant the active worktree could stop being the source of truth for hook declarations.

That was especially confusing because hooks still execute with the active worktree as their cwd. Hook authors reasonably write commands that resolve paths from the worktree, such as scripts under $(git rev-parse --show-toplevel)/.codex/...; loading the declaration from the root checkout while executing in the linked worktree made those paths disagree.

The goal here is to keep the useful trust property without making hook authors target a separate config directory or giving every worktree its own growing trust entry.

What

  • Stop replacing linked-worktree project hook declarations with root-checkout hook declarations during config loading.
  • Add a separate hook trust-key config folder so discovery can load declarations from the active worktree while canonicalizing the hook key to the matching root-checkout .codex folder.
  • Keep the reported hook source_path pointed at the active worktree, while using the canonical path only for key generation.

@abhinav-oai abhinav-oai requested a review from a team as a code owner May 28, 2026 21:18
@abhinav-oai abhinav-oai marked this pull request as draft May 28, 2026 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project hooks in linked worktrees appear to be loaded from the primary checkout but executed from the linked worktree cwd

1 participant