Skip to content

Use root repo hooks in linked worktrees#21969

Open
abhinav-oai wants to merge 3 commits into
mainfrom
abhinav/hooks-worktrees-use-root-repo
Open

Use root repo hooks in linked worktrees#21969
abhinav-oai wants to merge 3 commits into
mainfrom
abhinav/hooks-worktrees-use-root-repo

Conversation

@abhinav-oai
Copy link
Copy Markdown
Collaborator

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

Why

Linked worktrees currently load their own project hook declarations, so the same repo can present different hook definitions depending on which checkout is active. #21762 tried to share trust by giving matching worktree hooks a shared synthetic key, but review pointed out that divergent worktree hook definitions would then fight over one trusted_hash.

Instead of introducing a second trust model, this makes linked worktrees use the root checkout as the single source of truth for project hook declarations. Worktree-local project config can still diverge for unrelated settings, but project hooks now keep one real source path and one trust state per repo.

What

  • Teach project config loading to remember the matching root-checkout .codex/ folder for linked-worktree project layers.
  • Keep ordinary project config sourced from the worktree, but replace project hook declarations with the root checkout's matching layer before hook discovery runs.
  • Make hook discovery use that authoritative hook folder for both hooks.json and TOML hook source paths, so linked worktrees produce the same hook key and trust state as the root checkout.

@abhinav-oai abhinav-oai changed the title [codex] Use root repo hooks in linked worktrees Use root repo hooks in linked worktrees May 9, 2026
@abhinav-oai abhinav-oai marked this pull request as ready for review May 9, 2026 21:22
@abhinav-oai abhinav-oai requested a review from a team as a code owner May 9, 2026 21:22
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.

1 participant