Skip to content

fix(generate): correct root-file ownership for wildcard configs and mirrored roots - #2008

Merged
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-1981-root-ownership-followup
Jun 23, 2026
Merged

fix(generate): correct root-file ownership for wildcard configs and mirrored roots#2008
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-1981-root-ownership-followup

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

Follow-up fixes for the #1978 root-file-ownership work, addressing the non-blocking findings in #1981.

#1 (mid) — wildcard targets: ["*"] silently bypassed the fix

extractConfigFileTargets filtered out * and returned [] (not undefined), so getConfigFileTargets() did not fall back and root-file ownership was computed against an empty target list — reproducing #1894 for the very common targets: ["*"] config (e.g. generate --check -t codexcli -f rules failing on AGENTS.md). Now * is expanded to the full non-legacy target set, mirroring Config.getTargets().

The ?? getTargets() fallback is intentionally not relied on here: getTargets() is CLI -t filtered, whereas ownership needs the full config-file target list (CLI-independent).

#2 (mid) — rovodev's mirrored ./AGENTS.md was invisible to ownership

computeRootFileOwnership derived owned roots only from getSettablePaths().root, so rovodev's generation-time mirror to the project-root ./AGENTS.md (mirrorsRootToAgentsMd) and any target's alternativeRoots were never attributed — inverting ownership in configs like { codexcli, rovodev }. Both are now registered.

#3 / #4 (low) — documentation

Documented the single-ownership-decision-across-output-roots assumption and the load-bearing "last target in config order wins" semantics at the call site.

#5 (low) — tests

  • config-resolver regression test: ["*"] expands to the full non-legacy list (and stays full even when CLI -t selects one target).
  • E2E: a non-owning target (codexcli) passes --check when rovodev owns the mirrored ./AGENTS.md.

Verification

  • pnpm cicheck passes (fmt, oxlint, typecheck, tests, content).
  • E2E smoke: generate --check -t codexcli passes when rovodev (last in config) owns the mirrored AGENTS.md.

Closes #1981

cm-dyoshikawa and others added 2 commits June 22, 2026 20:30
…irrored roots

Follow-up fixes for the #1978 root-file ownership work (#1981):

- #1 (mid): `extractConfigFileTargets` collapsed the wildcard array form `targets: ["*"]` to an empty list, so `getConfigFileTargets()` did not fall back and ownership was computed against no targets — reproducing #1894 for the very common `["*"]` config. Expand `*` to the full non-legacy target set (mirroring `Config.getTargets()`). Note the fallback to `getTargets()` is intentionally NOT used because it is CLI `-t` filtered, whereas ownership needs the full config-file target list.
- #2 (mid): `computeRootFileOwnership` derived owned roots solely from `getSettablePaths().root`, missing rovodev's generation-time mirror to project-root ./AGENTS.md (mirrorsRootToAgentsMd) and any target's alternativeRoots. Register both so mirrored/aliased root files are attributed to the right target instead of inverting ownership.
- #3/#4 (low): document the single-decision-across-output-roots assumption and the load-bearing last-target-in-config-order-wins semantics at the call site.
- #5 (low): add a config-resolver regression test for `["*"]` expansion (incl. CLI -t independence) and an E2E test asserting a non-owning target passes check when rovodev owns the mirrored ./AGENTS.md.

Closes #1981

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… follow-up)

Address PR review findings on #2008:
- Dedupe the wildcard (`*`) -> non-legacy-target expansion into a single exported `expandWildcardTargets()` helper used by both `Config.getTargets()` and `extractConfigFileTargets()`, removing the drift risk (and the redundant `validTargets.has` check).
- Reword the `alternativeRoots` ownership comment (they are fallback/secondary root locations, not generation-emitted) and note the rovodev mirror overlaps its alt root today.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dyoshikawa

Copy link
Copy Markdown
Owner Author

Thanks — merging. Fixes the #1978 root-file-ownership follow-up findings (wildcard ["*"] configs and rovodev's mirrored ./AGENTS.md), closing #1981.

@dyoshikawa
dyoshikawa merged commit 9904554 into main Jun 23, 2026
8 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-1981-root-ownership-followup branch June 23, 2026 03:44
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.

Follow-up: non-blocking findings from PR #1978 (skip non-owned root files in generate --check)

2 participants