Skip to content

feat(manifest): record excluded files in run coverage - #1901

Merged
lizhengfeng101 merged 3 commits into
alibaba:mainfrom
NicolasRocchia:feat/manifest-excluded-coverage
Nov 13, 2026
Merged

lizhengfeng101 merged 3 commits into
alibaba:mainfrom
NicolasRocchia:feat/manifest-excluded-coverage

Conversation

@NicolasRocchia

Copy link
Copy Markdown
Contributor

Description

Follow-up to discussion #1345 (#1345 (comment)).

The run manifest records why a selected file failed, but not why a changed file was never selected. This PR adds coverage.excluded to the manifest: one entry per file the selection step left out, with the exclude_reason the selection already computes and --preview already reports.

terminal_state is derived exactly as before. complete still means complete over the selected set, and an exclusion never turns a run partial or failed. computeTerminal is untouched.

What changed:

  • internal/session/manifest.go: new ExcludedItem type, Coverage.Excluded, and ManifestBuilder.RegisterExcluded. The field is always serialized as an array, like the other coverage sets, and manifests persisted without it load with an empty one.
  • internal/model/preview.go: ExcludeReason.IsExclusion(), used to reject undefined reasons.
  • internal/agent/agent.go: registerExclusions, called in Run right after selection.
  • pages/src/content/docs/en/faq.md: states what complete covers and where exclusions are recorded.

Design notes:

  • Own type instead of CoverageItem. CoverageItem.Classification is a FailureClass, and consumers read it as a failure marker. Excluded files use exclude_reason, the name --preview uses.
  • No fingerprint. An excluded file is never dispatched and has no checkpoint, and I did not want to persist a digest of the diff of a secret path.
  • Registered in Run, not at sealing. A run with nothing selected returns before sealing; this way a skipped run also reports what it left out.
  • A registration error is a warning only. It is recorded as manifest_error and never sets run_failure.
  • Deleted files are listed with reason deleted, as in --preview.
  • Selected wins on an item_id collision. ItemID normalizes \ to /, so src\a.go and src/a.go share an id. If one is excluded and the other selected, the excluded record is dropped so the run keeps its denominator. The dropped record leaves no trace in the manifest; I kept it silent because the case needs two paths that differ only in separator, but I can add a non-fatal warning if you prefer.

One thing for you to decide: the comment on pendingFailureCause in internal/session/manifest.go says "schema v1 is frozen" as the reason not to add a field, and this PR adds one under ocr.run-manifest/v1. I left that comment alone. The field is additive: the ACP contract decoder and the viewer ignore unknown fields, compare.go reads only completed and reused, and bumping the version would make resume reject earlier sessions. If you would rather have the comment reworded, or a different versioning approach, tell me.

Not in this PR:

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally
  • Manual testing (describe below)

I work on Windows without make or a C toolchain, so I ran the Makefile steps by hand and the tests without -race: gofmt -s -l, go vet, go build ./..., go run scripts/verify-english-only.go, and go test on internal/session, internal/model, internal/agent, internal/viewer and cmd/.... All pass. TestWorkspaceDiffSkipsOversizedUntrackedFile in internal/diff fails on my machine, and it fails the same way on a clean checkout of main. I did not run -race, go mod tidy or the license check locally (no new files).

New tests cover the builder (registration, validation, sealing, JSON shape, slice ownership, legacy manifests) and the agent (a real run with exclusions that ends complete, a skipped run, and the item_id collision).

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA
  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

AI disclosure: the code, tests and docs in this PR were written with Claude Code (model Claude Fable 5.2) and reviewed in two adversarial passes with OpenAI Codex CLI. I read the whole diff before opening this PR.

Related Issues

Discussion #1345. Related: #1197, #1201.

@CLAassistant

CLAassistant commented Nov 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🔍 OpenCodeReview found 1 issue(s) in this PR.

  • ✅ Successfully posted inline: 1 comment(s)

Comment thread internal/model/preview.go
Comment on lines +30 to +38
func (r ExcludeReason) IsExclusion() bool {
switch r {
case ExcludeUserRule, ExcludeExtension, ExcludeDefaultPath, ExcludeSecret,
ExcludeProviderDirectory, ExcludeDeleted, ExcludeBinary, ExcludeTooLarge:
return true
default:
return false
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maintainability · medium
This explicit positive-list switch is a fragile validation gate. If a new ExcludeReason constant is added to this package but not added here, RegisterExcluded will reject it with "invalid exclude reason" — a misleading error for what is actually a valid, just-unlisted reason. Since Go cannot enforce exhaustiveness on string-typed constants, consider inverting the logic to check only the known non-exclusion sentinel (ExcludeNone) and treat everything else as an exclusion, or maintain a package-level map/set that is populated alongside the constants so additions require only one change.

Suggestion:

Suggested change
func (r ExcludeReason) IsExclusion() bool {
switch r {
case ExcludeUserRule, ExcludeExtension, ExcludeDefaultPath, ExcludeSecret,
ExcludeProviderDirectory, ExcludeDeleted, ExcludeBinary, ExcludeTooLarge:
return true
default:
return false
}
}
func (r ExcludeReason) IsExclusion() bool {
return r != ExcludeNone
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi, this is intentional. With r != ExcludeNone, RegisterExcluded would accept any string as a reason, and the manifest would no longer guarantee that exclude_reason is one of the defined values. TestRegisterExcludedValidation covers this. The cost of not listing a new reason is low: it leaves a manifest_error warning, not a failed run. If you prefer a package-level set next to the constants, I can change it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you. I'm such a beginner I am so eager to learn as much as my little brain can handle

@NanaseInori NanaseInori 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.

Reviewed all eight changed-file patches, the builder's finalization/clone path, tests, and existing comments. The accepted direction in #1345 explicitly asks for persisted exclusion reasons while keeping terminal_state derived from selected coverage. The adjacent #1201/#1223 work concerns provider/preview accounting; this change records exclusions that reach run selection, with that boundary documented.

The separate excluded map does not enter the selected denominator or the failure sweep. Registration precedes the zero-selected early return, seal/freeze guards protect mutation, output is sorted, and returned exclusion slices are copied. The regression cases cover complete/skipped outcomes, preview reason agreement, selected/excluded identity collisions and legacy cloning. I found no blocking implementation defect in the reviewed patch.

Please retain the explicit defined-reason validation. The bot's suggested r != ExcludeNone would accept arbitrary unknown strings and contradict TestRegisterExcludedValidation; it is not an equivalent simplification.

Two integration details remain visible for maintainer follow-up: reconcile the existing 'schema v1 is frozen' wording with this intentionally additive field, and synchronize the FAQ explanation across the maintained locales. Neither warrants changing the established selected-set terminal-state policy. The documented silent exclusion loss on an ItemID collision is a limitation, not full raw-path accounting.

Validation: source and regression-test inspection only; I did not independently execute Go/race tests or a live review.

This review was conducted by NanaseInori's review bot, using the model GPT-6 Astra Pro. If you need a human review, please manually @NanaseInori.

@lizhengfeng101

Copy link
Copy Markdown
Contributor

@NicolasRocchia Please also synchronize the FAQ changes in pages/src/content/docs/en/faq.md to the existing zh, ja, ko, and ru versions.

This should include both the corrected description of skipped-run coverage and the new explanation that complete applies only to the selected set, with selection exclusions recorded separately and provider-stage omissions remaining outside that list. Keeping these descriptions aligned will avoid giving readers different explanations of review coverage depending on their language.

@lizhengfeng101

Copy link
Copy Markdown
Contributor

@NicolasRocchia One non-blocking readability suggestion: please trim the new comments where they repeat the code or explain the same invariant in several places.

  • The comment on registerExclusions in internal/agent/agent.go walks through nil handling, continuing after rejected entries, and joining errors. Most of that is directly visible in the short function and can be condensed.
  • The explanation that exclusions stay outside the denominator and do not affect terminal state is repeated in the Coverage and RegisterExcluded comments. Please keep the full invariant with Coverage and focus the method comment on its distinct registration contract.

Please retain the useful "why" comments: registering before the early return, omitting fingerprints for excluded files (especially secret paths), and giving selected items priority on normalized-ID collisions. This is a targeted cleanup of the new comments, not a request to remove existing documentation or change behavior.

@lizhengfeng101

Copy link
Copy Markdown
Contributor

@NicolasRocchia I stepped in and pushed eab58ad to address the remaining follow-ups: synchronizing the FAQ across zh/ja/ko/ru and trimming repetitive comments, including the outdated "schema v1 is frozen" wording.

I am comfortable keeping this additive change in v1 and retaining the documented selection-level scope of the exclusion list. No runtime behavior was changed by my follow-up. Local checks, the targeted race tests, and the translation-sync check passed.

The follow-up edits were prepared with Codex. Thanks for the contribution!

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 65b12d7 into alibaba:main Nov 13, 2026
15 checks passed
@NicolasRocchia

Copy link
Copy Markdown
Contributor Author

Thanks for the review, and for taking care of the FAQ sync and the comment cleanup yourself.

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.

6 participants