Skip to content

Use root repo hooks in linked worktrees#21969

Merged
abhinav-oai merged 8 commits into
mainfrom
abhinav/hooks-worktrees-use-root-repo
May 13, 2026
Merged

Use root repo hooks in linked worktrees#21969
abhinav-oai merged 8 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 actual 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, including linked-worktree layers with .codex/ but no local config.toml.
  • 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.
  • Cover the linked-worktree path plus regressions for missing worktree config.toml and nested non-worktree project roots.

@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
@abhinav-oai abhinav-oai enabled auto-merge (squash) May 13, 2026 06:28
@abhinav-oai abhinav-oai merged commit 934a40c into main May 13, 2026
27 checks passed
@abhinav-oai abhinav-oai deleted the abhinav/hooks-worktrees-use-root-repo branch May 13, 2026 06:59
@github-actions github-actions Bot locked and limited conversation to collaborators May 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants