Skip to content

[CLI] Exclude producer-owned outputs from fileIndex — the artifact indexed itself - #12

Merged
qmarcelle merged 1 commit into
mainfrom
fix/meta-198-fileindex-self-inclusion
Jul 26, 2026
Merged

[CLI] Exclude producer-owned outputs from fileIndex — the artifact indexed itself#12
qmarcelle merged 1 commit into
mainfrom
fix/meta-198-fileindex-self-inclusion

Conversation

@qmarcelle

Copy link
Copy Markdown
Contributor

Found by the new four-path producer conformance suite in workspacejson/standard (META-198) on its first run against this producer.

The defect

buildFileIndex indexed the artifact the producer was about to write:

run 1: keys=6  selfIncluded=false
run 2: keys=7  selfIncluded=true    <- .agents/workspace.json now on disk
run 3: keys=7  identical to run 2

The material projection therefore changed with no repository change.

Why it matters more than it looks

  • generate --check fails on every repository's first CI run after adoption. Generate, commit, then check → drift reported on an unchanged tree, non-zero exit.
  • The artifact is self-referential — it indexes its own output, which is not repository evidence and pollutes a stable read path.
  • It converges from run 3 onward, so running generate twice locally hides it completely. Only generate-then-check exposes it, and that is precisely the CI path.

This is exactly the class of defect META-195's own determinism constraint warned about: "any non-determinism makes every run report drift, rewrite the artifact, and break generate --check as a CI gate."

The fix

buildFileIndex takes an optional list of producer-owned outputs and excludes them — the artifact itself and the configured reportDir.

Matching is exact or directory-prefix, not substring. A bare includes() would drop .agents/audit-history-notes.md, a real repository file that merely shares a prefix, silently removing evidence a consumer needs. Covered by a test.

The parameter is optional, so existing callers are unaffected.

Verification

packages/cli                 60 tests passed (was 56 — 4 new)
agents-audit                 44 tests passed
typecheck                    clean
check:architecture           pass
check:architecture:test      20 passed
parity-agents-audit-runtime  PASS — 4 differences match the ratified baseline

Conformance suite against this branch: 28/28 green (was 24/28 with 3 failures before the fix — the watched-red receipt).

Note for reviewers

The hygiene.scannedAt movement I initially suspected as a second defect was a consequence of this one. Once the index converges, the projection is unchanged, carry-forward works correctly, and runs 3+ are byte-identical. One bug, not two.

buildFileIndex indexed the artifact the producer was about to write. Run 1
emitted N keys; run 2 emitted N+1, because .agents/workspace.json now existed
on disk and the scanner reported it. The material projection therefore changed
with no repository change.

Consequences:

- `generate --check` fails on every repository's first CI run after adoption:
  generate, commit, then check reports drift on an unchanged tree.
- The artifact is self-referential — it indexes its own output, which is not
  repository evidence.
- It converges from run 3 onward, so running generate twice locally hides it
  entirely. Only generate-then-check exposes it, and that is the CI path.

Caught by the META-198 four-path conformance suite on its first run against
this producer — exactly the class of defect that suite exists to find.

The exclusion covers producer-owned outputs generally: the artifact itself and
the configured reportDir, matched exactly or as a directory prefix. A bare
substring test would be wrong — `.agents/audit-history-notes.md` is a real
repository file that merely shares a prefix, and dropping it would remove
evidence a consumer needs. Covered by a test.

The parameter is optional, so existing callers are unaffected.
Copilot AI review requested due to automatic review settings July 26, 2026 21:23

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qmarcelle
qmarcelle merged commit 643071c into main Jul 26, 2026
3 checks passed
@qmarcelle
qmarcelle deleted the fix/meta-198-fileindex-self-inclusion branch July 26, 2026 22:04
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.

2 participants