Repository navigation
feat(manifest): record excluded files in run coverage - #1901
Conversation
|
🔍 OpenCodeReview found 1 issue(s) in this PR.
|
| func (r ExcludeReason) IsExclusion() bool { | ||
| switch r { | ||
| case ExcludeUserRule, ExcludeExtension, ExcludeDefaultPath, ExcludeSecret, | ||
| ExcludeProviderDirectory, ExcludeDeleted, ExcludeBinary, ExcludeTooLarge: | ||
| return true | ||
| default: | ||
| return false | ||
| } | ||
| } |
There was a problem hiding this comment.
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:
| 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 | |
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Thank you. I'm such a beginner I am so eager to learn as much as my little brain can handle
NanaseInori
left a comment
There was a problem hiding this comment.
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.
|
@NicolasRocchia Please also synchronize the FAQ changes in This should include both the corrected description of skipped-run coverage and the new explanation that |
|
@NicolasRocchia One non-blocking readability suggestion: please trim the new comments where they repeat the code or explain the same invariant in several places.
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. |
|
@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! |
|
Thanks for the review, and for taking care of the FAQ sync and the comment cleanup yourself. |
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.excludedto the manifest: one entry per file the selection step left out, with theexclude_reasonthe selection already computes and--previewalready reports.terminal_stateis derived exactly as before.completestill means complete over the selected set, and an exclusion never turns a runpartialorfailed.computeTerminalis untouched.What changed:
internal/session/manifest.go: newExcludedItemtype,Coverage.Excluded, andManifestBuilder.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 inRunright after selection.pages/src/content/docs/en/faq.md: states whatcompletecovers and where exclusions are recorded.Design notes:
CoverageItem.CoverageItem.Classificationis aFailureClass, and consumers read it as a failure marker. Excluded files useexclude_reason, the name--previewuses.Run, not at sealing. A run with nothing selected returns before sealing; this way askippedrun also reports what it left out.manifest_errorand never setsrun_failure.deleted, as in--preview.item_idcollision.ItemIDnormalizes\to/, sosrc\a.goandsrc/a.goshare 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
pendingFailureCauseininternal/session/manifest.gosays "schema v1 is frozen" as the reason not to add a field, and this PR adds one underocr.run-manifest/v1. I left that comment alone. The field is additive: the ACP contract decoder and the viewer ignore unknown fields,compare.goreads onlycompletedandreused, 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:
vendor/,node_modules/), untracked files ignored by.gitignore, and, for a commit or a range, anything matching.gitignore. A normal run does not keep those diffs. This overlaps with Preview omits diff-level vendor directory drops from file totals and exclusion reasons; no tracked-vendor override in v1.11.6 #1197 / fix(review): account for tracked vendor preview exclusions #1201.ru,ja,ko,zh) are not updated; only the English FAQ is.Type of Change
How Has This Been Tested?
make testpasses locallyI work on Windows without
makeor 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, andgo testoninternal/session,internal/model,internal/agent,internal/viewerandcmd/.... All pass.TestWorkspaceDiffSkipsOversizedUntrackedFileininternal/difffails on my machine, and it fails the same way on a clean checkout ofmain. I did not run-race,go mod tidyor 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, askippedrun, and theitem_idcollision).Checklist
go fmt,go vet)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.