Skip to content

fix: skip non-owned root files in generate --check for shared AGENTS.md - #1978

Merged
dyoshikawa merged 1 commit into
mainfrom
resolve-issue-1894-check-shared-root-files
Jun 22, 2026
Merged

fix: skip non-owned root files in generate --check for shared AGENTS.md#1978
dyoshikawa merged 1 commit into
mainfrom
resolve-issue-1894-check-shared-root-files

Conversation

@dyoshikawa-claw

Copy link
Copy Markdown
Collaborator

Summary

When multiple targets share the root AGENTS.md file (e.g., codexcli and antigravity-ide), rulesync generate --check for a single target would fail because the target's expected AGENTS.md content differs from the on-disk content written by the last target in config order (different TOON reference paths like @.codex/memories/* vs @.agents/rules/*).

Fix

Compute root file ownership from the config file's full target list (before --targets CLI override). In check mode, skip root files the target doesn't own, so only the owning target's root file is checked. Non-root files (e.g., .codex/memories/*.md) are always checked regardless.

Changes

  • Add Config.getConfigFileTargets() returning config file targets before CLI --targets override
  • Add computeRootFileOwnership helper in generate.ts that maps root file paths to their owner (last target in config order)
  • Skip non-owned root files in processFeatureGeneration (write check only; orphan detection still sees the full tool file list so shared root files are not treated as orphans)
  • Add e2e test: check codexcli passes when antigravity-ide owns AGENTS.md

Closes #1894

When multiple targets share the root AGENTS.md file (e.g., codexcli and
antigravity-ide), generate --check for a single target would fail because
the target's expected AGENTS.md content differs from the on-disk content
written by the last target in config order (different TOON reference paths).

Fix: compute root file ownership from the config file's full target list
(before --targets CLI override). In check mode, skip root files the target
doesn't own, so only the owning target's root file is checked. Non-root
files (e.g., .codex/memories/*.md) are always checked regardless.

- Add Config.getConfigFileTargets() returning config file targets before
  CLI --targets override
- Add computeRootFileOwnership helper in generate.ts
- Skip non-owned root files in processFeatureGeneration (write check only;
  orphan detection still sees the full tool file list)
- Add e2e test: check codexcli passes when antigravity-ide owns AGENTS.md

Closes #1894
@dyoshikawa
dyoshikawa merged commit 22a6852 into main Jun 22, 2026
9 checks passed
@dyoshikawa

Copy link
Copy Markdown
Owner

@dyoshikawa-claw Thank you!

@dyoshikawa
dyoshikawa deleted the resolve-issue-1894-check-shared-root-files branch June 22, 2026 05:45
dyoshikawa added a commit that referenced this pull request Jun 23, 2026
…irrored roots (#2008)

* fix(generate): correct root-file ownership for wildcard configs and mirrored 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>

* refactor(config): extract shared expandWildcardTargets helper (review 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>

---------

Co-authored-by: dyoshikawa <yoshikawa.daio@classmethod.jp>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
rudironsoni pushed a commit to rudironsoni/rulesync that referenced this pull request Jun 23, 2026
PR dyoshikawa#1979 changed codexcli to fold non-root rules into the root AGENTS.md and
stopped writing the inert .codex/memories/ tree, but the e2e-rules case added
in dyoshikawa#1978 ('should pass check for a non-owning target when another target owns
AGENTS.md') still asserted .codex/memories/detail.md existed. The mismatch left
main's E2E suite red.

Update the assertions to the current behavior: the non-root 'Detail Rule' body
is emitted by the owning target (antigravity-ide) under .agents/rules/, and
codexcli no longer creates .codex/memories/.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

generate --check for codexcli rules fails when another target owns AGENTS.md

2 participants