Repository navigation
fix(config): inherit the primary worktree's local config in linked worktrees - #2110
SomSamantray wants to merge 4 commits into
Conversation
A linked worktree has no `config.local.yaml` of its own, and the rule read only this checkout's files, so personal preferences such as `plan_model` and `cross_model_peer` silently did not apply in every new worktree. The shared config rule now reads the primary worktree's copy of `config.local.yaml` when this checkout is a linked worktree and has none. A local file in this checkout still wins, and `config.yaml` stays this checkout's. The parity fixture, its test, and the configuration guide carry the same rule. Refs EveryInc#1803.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4024ecf253
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ## How keys resolve | ||
|
|
||
| - **Ordinary keys:** read `config.local.yaml`, then `config.yaml`. The first active (non-commented) value wins. A missing file is skipped. Invalid or empty scalars continue to the next layer, then the skill default. A present list or map, including empty, replaces the whole key. | ||
| - **Linked worktrees:** when this checkout is a linked worktree (`git rev-parse --git-dir` differs from `--git-common-dir`) and has no `config.local.yaml`, the local layer is the primary worktree's copy — the parent of the absolute `--git-common-dir`. A local file in this checkout still wins, and `config.yaml` stays this checkout's. |
There was a problem hiding this comment.
Resolve the primary worktree from worktree metadata
For a linked worktree created from git clone --separate-git-dir, a local reproduction returns --show-toplevel=<tmp>/main but --git-common-dir=<tmp>/git-meta; the common dir's parent is <tmp>, not the main checkout, so this reads the wrong .compound-engineering/config.local.yaml (or none) and silently loses the intended preferences. Resolve the actual main worktree path from Git's worktree metadata instead of assuming the common-dir parent.
Useful? React with 👍 / 👎.
|
|
||
| - **Read** `<repo-root>/.compound-engineering/config.local.yaml`, then `config.yaml` (`<repo-root>` = `git rev-parse --show-toplevel`). Missing files are skipped. Gitignore does not change resolution. | ||
| - **Win** with the first active (non-commented) value. For scalars, empty is unset; an invalid value continues to the next layer, then the skill default. For lists and maps, a present key — including an empty list or map — replaces the whole key. | ||
| - **Read** `<repo-root>/.compound-engineering/config.local.yaml` — or the primary worktree's copy of it when this checkout is a linked worktree with no local file — then `config.yaml` (`<repo-root>` = `git rev-parse --show-toplevel`). Missing files are skipped. Gitignore does not change resolution. |
There was a problem hiding this comment.
Inherit the primary local config in the pack resolvers
ce-work invokes skills/ce-work/scripts/packs-resolve.py; its _main builds cfg_dir from this linked checkout's <repo-root> and reads only config.yaml plus that checkout's config.local.yaml (lines 690-696). Thus, when a personal packs: entry exists only in the primary worktree's local file, the pack is omitted in the linked worktree despite this generic rule now promising that CE YAML keys inherit it. Apply the fallback to the pack resolvers and their mirrored copies, or explicitly scope the guarantee to ordinary keys.
Useful? React with 👍 / 👎.
Two review findings on the primary-worktree fallback: - The pack resolvers read only this checkout's local file, so a personal `packs:` entry inherited from the primary worktree was lost. All nine mirrored resolvers now apply the fallback and resolve an inherited file's relative sources against the primary worktree. - The guide derived the primary worktree from the common dir's parent, which is wrong for `--separate-git-dir` clones. It now names the main worktree `git worktree list --porcelain` reports first.
…rding Review follow-ups on the linked-worktree fallback: - Accept the main worktree only when it is itself a checkout, so a bare or `--separate-git-dir` layout leaves the local layer absent instead of reading an unrelated path. The config guide says the same. - Setup's per-checkout wording, AGENTS.md, and the two ce-work restatements now describe the inherited local layer instead of "the two repo files".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e50c180790
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return None | ||
| for line in proc.stdout.splitlines(): | ||
| if line.startswith("worktree "): | ||
| main = line[len("worktree "):].strip() |
There was a problem hiding this comment.
Resolve the primary checkout path for separate-git-dir clones
For a linked checkout whose primary was created with git clone --separate-git-dir, git worktree list --porcelain can emit the metadata directory as its first record (worktree <tmp>/git-meta), not the checkout root. Fresh evidence in this commit is that the new helper passes that path to the rev-parse --show-toplevel probe, which rejects it and returns None; the linked checkout then silently skips the primary config.local.yaml, including packs: entries, despite the guide promising this case. Resolve the actual checkout path instead of treating the first record as one.
AGENTS.md reference: AGENTS.md:L85-L85
Useful? React with 👍 / 👎.
Summary
config.local.yamlis gitignored and per-checkout, and the shared config rule read only files under this checkout'sgit rev-parse --show-toplevel. A linked worktree therefore started with no local layer, so personal preferences such asplan_model,brainstorm_model,cross_model_peer, andcross_model_review_modesilently did not apply. The issue's workaround was apost-checkouthook that symlinks a shared file into each new worktree.This takes the issue's option 2: when the current checkout is a linked worktree and has no
config.local.yaml, the local layer is the primary worktree's copy of it. A local file in this checkout still wins, and committedconfig.yamlstays this checkout's. No user-level layer and no repo-specific key moves;docs_rootremainsconfig.yaml-only.The primary worktree is the one
git worktree list --porcelainreports first, accepted only when it is a checkout itself, so bare and--separate-git-dirlayouts leave the local layer absent rather than reading an unrelated path.Fixes #1803.
Changes
ce-config-layersblock (14 copies: the parity fixture plus 12 skill readers and two references) states the fallback in the same read order: this checkout's local file, else the primary worktree's, then this checkout'sconfig.yaml.packs-resolve.pycopies apply the same fallback, and an inherited file's relative pack sources resolve against the primary worktree. A new test inherits an untracked local pack file into a linked worktree.tests/config-layers-rule-parity.test.tspins the linked-worktree and primary-copy clauses.docs/guides/configuration.md,docs/guides/ce-setup.md,AGENTS.md, and the twoce-workrestatements describe the inherited local layer instead of "the two repo files".The block was restated more tightly so the two skills that carry it as always-loaded text stay under the Codex 8,000-byte bound:
ce-brainstormis 7,888 bytes CRLF-adjusted andce-product-pulse7,941.Validation
bun test tests/skills/ce-packs-resolver.test.ts tests/config-layers-rule-parity.test.ts tests/codex-skill-prompt-budget.test.ts: 65 pass, 0 fail.bun run test:skill-guards: 963 pass.bun run test --changed-since=ee3695a24ae1ccb205e4334b79799cb25c060247at the first two commits: 5229 pass, 18 skip, 0 fail across 196 files. The final commit changes prose and the resolver helper; the targeted suites above re-ran green, and PR CI is the gate for the final head.bun run typecheck: pass.Security Disclosure
The rule permits reading
config.local.yamlfrom the primary worktree of the same repository when the current checkout is a linked worktree, and only when that path is a checkout of this repository. That path stays inside the repository's own worktrees; there is no new network access, credential, or path outside it. The file remains gitignored and per-user.Agent Disclosure