Skip to content

fix(config): inherit the primary worktree's local config in linked worktrees - #2110

Open
SomSamantray wants to merge 4 commits into
EveryInc:mainfrom
SomSamantray:fix/config-local-primary-worktree
Open

SomSamantray wants to merge 4 commits into
EveryInc:mainfrom
SomSamantray:fix/config-local-primary-worktree

Conversation

@SomSamantray

@SomSamantray SomSamantray commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

config.local.yaml is gitignored and per-checkout, and the shared config rule read only files under this checkout's git rev-parse --show-toplevel. A linked worktree therefore started with no local layer, so personal preferences such as plan_model, brainstorm_model, cross_model_peer, and cross_model_review_mode silently did not apply. The issue's workaround was a post-checkout hook 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 committed config.yaml stays this checkout's. No user-level layer and no repo-specific key moves; docs_root remains config.yaml-only.

The primary worktree is the one git worktree list --porcelain reports first, accepted only when it is a checkout itself, so bare and --separate-git-dir layouts leave the local layer absent rather than reading an unrelated path.

Fixes #1803.

Changes

  • The canonical ce-config-layers block (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's config.yaml.
  • All nine mirrored packs-resolve.py copies 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.ts pins the linked-worktree and primary-copy clauses.
  • docs/guides/configuration.md, docs/guides/ce-setup.md, AGENTS.md, and the two ce-work restatements 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-brainstorm is 7,888 bytes CRLF-adjusted and ce-product-pulse 7,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=ee3695a24ae1ccb205e4334b79799cb25c060247 at 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.
  • The rule is instruction prose, so no behavioural eval was possible here: both host CLIs are unauthenticated in this environment (Claude Code OAuth session expired; Codex CLI token refresh 401).

Security Disclosure

The rule permits reading config.local.yaml from 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

  • Tool: DeepSeek Harness

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T07:40:30.403254Z e50c180 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread docs/guides/configuration.md Outdated
## 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

This branch has not been deployed

No deployments
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.

Config: support a user-level config layer or fall back to the primary worktree's config.local.yaml

1 participant