Skip to content

feat(coverage): retain reviewed file lists - #1686

Closed
ianw-oai wants to merge 3 commits into
mainfrom
feat/file-review-coverage
Closed

ianw-oai wants to merge 3 commits into
mainfrom
feat/file-review-coverage

Conversation

@ianw-oai

@ianw-oai ianw-oai commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Retain file-level review claims in coverage.json so consumers can derive a file count without separate counters.

Changes

  • Add optional reviewedFiles to the semantic draft contract, canonical schema, and generated SDK types. Normalize, sort, and deduplicate paths before saving checkpoints.
  • Validate claims against the source inventory and requested scope during tool writes, file-authored completion, and stopped-scan recovery. Invalid accounting is omitted with a warning while findings are preserved.
  • Preserve claims across checkpoints. Successful Deep scans combine accepted workers' lists only when each worker supplies accounting. Recovery also keeps accounting unknown when a discovery worker's output is missing, malformed, or empty. Reducers do not count as source-review workers.
  • Validate uniqueness of string arrays in linear time, preserving existing equality rules for other JSON values.
  • Keep scan instructions and tool-description prose unchanged. Define the optional field in the schema and document its consumer semantics in the SDK README.

Testing

  • 373 Python tests passed across file accounting, Standard/Deep result recovery, and contract finalization. The final focused accounting rerun passed all 20 tests.
  • 189 focused MCP tests and 92 SDK contract/result tests passed against the rebuilt plugin.
  • Pinned Ruff lint and formatting, build:ci, plugin bundling, and portable source compatibility checks passed, including 9 compatibility tests.
  • Seven new regression cases fail on the previous PR head and pass with these fixes. Coverage includes canonical completion, cancellation, and missing or malformed worker outputs. Diff tests retain deleted files and reject unchanged files.
  • The 10,000-file schema check took about 0.01 seconds. Ten cumulative checkpoints growing to 10,000 files merged in about 0.14 seconds, compared with about 23 seconds in the review reproduction.

Full-suite success remains unverified. Earlier broad review runs encountered failures also reproduced on the unchanged base. No live model scan was run.

Risk and rollout

The field is optional. Existing bundles without it remain valid. No CLI flags, aggregate counters, or dependencies are added.

These are model-reported review claims. Inventory validation checks path eligibility and does not establish that the model examined a file. A count is not a coverage percentage. Missing or invalid accounting remains unknown, and an explicit empty list means no files were reported reviewed. Stopped results retain their stopped status.

This remains a draft for author review.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

@github-actions github-actions Bot added the enhancement New feature or request label Oct 16, 2026
@ianw-oai ianw-oai self-assigned this Oct 16, 2026

@mldangelo-oai mldangelo-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed commit 705cbdf113ef0964daa65615054050dd6aeae133. This is a Comment review with detailed implementation and architecture feedback.

The core approach is reasonable for retaining model-reported review claims. A unique path list is a simple representation, missing-versus-empty semantics are useful, and the Deep aggregation correctly works from accepted discovery results rather than letting reducers manufacture source-review coverage. The separation between review claims and proof of examination should remain explicit.

The main concerns are at the boundaries around that core:

  • Optional accounting can reject an otherwise valid finding checkpoint or final publication.
  • Discovery enumeration is being used as the eligibility authority, even when it omits explicitly requested files or authorized supporting code.
  • Historical recovery regenerates eligibility from a mutable checkout.
  • Each nonempty checkpoint repeats repository enumeration and full inventory parsing.
  • The semantic definition and nested-agent-to-parent handoff need to match the intended consumer guarantee.

The inline comments distinguish reproduced correctness problems from design questions and performance observations.

For architecture, I would keep the existing coverage/checkpoint flow and avoid introducing a separate tracking subsystem. Small normalization and union helpers, an explicit producer contract, and a stable scan-bound eligibility source would be enough. TypeScript tool ingestion and Python file/recovery ingestion should share behavioral cases and a deliberate failure policy; they currently disagree on whether bad accounting blocks findings.

For harness coverage, self-reporting can describe review performed through shell commands, chunked reads, scripts, editor context, MCP responses, Git revisions, or nested agents. It cannot independently verify that those paths were examined, that all delivered content reached the model, or that all reviewed paths were reported. Parsing command strings would not solve those gaps. The product should present this as reported review information and define the meaning of a qualifying investigation independently of the reader/tool used.

Suggested acceptance cases include:

  • A valid finding survives malformed, ineligible, or unavailable optional accounting.
  • A supported search-tool fallback does not make result persistence depend on ripgrep.
  • Explicitly selected ignored files survive multi-path targets.
  • Changed target files and unchanged supporting files follow one documented accounting policy.
  • Nested agents reporting reviewed files with zero findings retain those claims through checkpoints and resume.
  • Missing accounting, explicit empty accounting, and accepted-worker aggregation remain distinct.
  • Frozen recovery remains stable after the live checkout changes.
  • Repeated checkpoints reuse the relevant inventory rather than regenerating it.

Validation performed: the focused TypeScript accounting/canonical suites and Deep scope tests passed. Python runs had 192 passing tests and two skips; six integration cases encountered pre-existing output-directory ownership checks in the test environment. Separate synthetic reproductions exercised the failure cases described inline; the frozen-recovery reproduction used an injected publication-write failure and isolated the unrelated ownership guard in its fixture. No live model scan was run, so actual producer reporting reliability has not been established.

Comment on lines +78 to +82
if (parsed.coverage.reviewedFiles !== undefined)
parsed.coverage.reviewedFiles = await validateReviewedFiles(
context,
parsed.coverage.reviewedFiles,
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P1] Keep optional file accounting from aborting finding persistence

This validation runs before any checkpoint is saved, and an accounting error rejects the entire draft. I reproduced this through both the Standard and worker draft entrypoints: a valid synthetic finding plus reviewedFiles: ["src/a.ts", "src/missing.ts"] produces an error and no finding/checkpoint. Submitting the same finding without the accounting succeeds. The worker entrypoint has the same behavior.

There is also a supported-environment failure here: the core scan instructions allow git grep, find, or grep when native ripgrep is unavailable, but this new path unconditionally invokes an inventory helper requiring rg. With Python configured and rg absent from PATH, a draft without accounting succeeds and adding one reported file makes it fail.

Please isolate accounting failures from substantive result persistence: omit unavailable/invalid accounting, retain the findings and other coverage, and return a warning through the existing warning mechanism. Python recovery already follows that policy. This should also apply to Deep parent publication so a worker's accounting mistake cannot block the accepted findings.

A useful regression case is a draft containing an actual valid finding and invalid/unavailable accounting, followed by cancellation: the finding should still be recoverable. The current test asserting that no checkpoint exists codifies the opposite behavior.

Comment on lines +134 to +136
await prepareReviewItems(context);
const inventory = new Set(
(await readReviewItems(context)).map(({ path }) => posix.normalize(path)),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] Build membership from the exact requested paths

prepareReviewItems(context) passes only context.scope to the inventory generator. For a multi-path target, registration sets that coarse scope to ".", while the exact requested paths live in includePaths. Root enumeration can therefore omit a file the user explicitly selected.

I reproduced an accepted paths recipe selecting ignored.py and other.py, with both files present and ignored.py listed in .gitignore. The generated inventory contains other.py but omits ignored.py; reporting both files then rejects both worker and Deep parent drafts. This is not an attempt to broaden the target: the omitted file is explicitly part of the registered target.

Please derive eligibility from the exact authoritative includes, preserving explicit-file selection even when ordinary recursive enumeration would ignore that file. Cover both multi-file and mixed file/directory targets. There is a related inventory mismatch for tracked files hidden by .rgignore: Git-based discovery can include them, while this ripgrep-based membership check rejects them.

Comment on lines +925 to +928
else:
generate_in_scope_files(source_root, source_scope, output)
inventory = {
os.fsdecode(path).removeprefix("./") for path in output.read_bytes().splitlines()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] Validate recovered claims against the scan's captured source inventory

This regenerates inventory from the current checkout even when the saved source documents have already been frozen for a publication retry. A later filesystem change can therefore change the recovered accounting without any change to the saved review evidence.

I reproduced the workbench recovery path with a synthetic scan:

  1. Save reviewedFiles: ["src/a.ts", "src/b.ts"].
  2. Cancel and inject a publication-write failure after retained source digests have been saved.
  3. Delete src/b.ts from the checkout.
  4. Retry preserve-scan-results.

The first attempted publication contains both claims; the retry seals a canceled result with reviewedFiles absent and a missing-inventory warning. The whole list is dropped, including the still-existing src/a.ts.

Please make historical eligibility depend on a captured, scan-bound inventory/target rather than regenerating the current worktree. Preserve the normal source-change diagnostics separately. This affects recovery before the first successful seal and frozen retries after failed publication; already-sealed unchanged-source retries have a shortcut and are not the reproduction.

The replay regression should pass the real source_root: omitting it skips membership validation and misses this failure.

Comment on lines +150 to +152
!inventory.has(path) ||
!includes.some((scope) => contains(scope, path)) ||
excludes.some((scope) => contains(scope, path))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Contract question: reviewed target files or all authorized supporting files investigated?

This predicate restricts the list to the selected discovery inventory and requested target paths. In diff mode that excludes every unchanged supporting file. However, the schema describes repository-relative files the model investigated generally; the existing baseline/investigator instructions explicitly allow supporting files outside requested paths and ask those agents to return their investigated reviewed_files. The diff instructions also allow unchanged code when needed to explain a change.

For example, an investigation of changed src/route.ts may substantively analyze unchanged lib/auth.ts. Reporting both follows the investigation contract but fails this validator. The new test intentionally rejects unchanged files, so this appears to be a contract choice that needs to be reconciled, rather than simply a missing conditional.

Please choose and document one meaning. If this is a count of reviewed target files, explicitly filter authorized supporting-file claims before recording it and label the semantics accordingly. If it represents all authorized files investigated, validate against that authorized source universe instead of only the changed-file worklist. Neither option should turn a legitimate supporting-code investigation into a failed finding write.


// Use the same host-generated inventory as discovery, including deleted diff
// files. Never infer reviewed files from findings or tool command text.
await prepareReviewItems(context);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Architecture/performance: validation should not rebuild discovery state on every checkpoint

Every nonempty accounting update launches the Python helper, re-enumerates the repository, and overwrites the inventory. prepareReviewItems then reads/parses the entire inventory to return a count, after which this function reads/parses it again to build the set. The work scales with the whole inventory even when a checkpoint reports one new file.

Using the actual validator against a synthetic Git repository with 10,000 small source files, ten calls reporting one file took about 1.8 seconds (roughly 169–207 ms per call), excluding checkpoint merge/publication. This is a local measurement, not a general performance guarantee, but it measures work that the list-merging benchmark does not include.

For committed diffs, generation also calls git_blob_samples, which consumes changed blob contents for binary classification; repeated validation can therefore scale with the bytes in the selected diff. Non-Deep completion and stopped-result recovery perform another inventory generation.

If membership enforcement is retained, please prepare a correctly scoped inventory once per scan/target and reuse it through workers and recovery. Keep normalization/union separate from source enumeration. That removes repeated subprocess and filesystem work, avoids mutating discovery artifacts during validation, and supports stable recovery semantics. Any cache should remain bound to the scan and its target, rather than shared across unrelated scans.

export const reviewedFilesSchema = z
.array(repositoryPath)
.describe(
"Repository-relative files the model reports investigating beyond searches or excerpts. This is not observed file access or proof of thorough review. Omit when accounting is unavailable; an empty array means no files reported reviewed.",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Define substantive review independently of how a harness delivers source

Model-reported review claims are a reasonable portable design, but beyond searches or excerpts leaves important cases ambiguous. A whole file can be read through several sed ranges; a source-to-sink investigation can thoroughly analyze the relevant functions without reading every line; a nominal full-file read can return truncated output. Those cases should be classified by the investigation performed, not by the command or response shape.

Please specify what earns a file a claim, whether partial but substantive investigation qualifies, and how authorized supporting files are treated. Mere appearance in a filename list or search hit should not imply investigation, while meaningful analysis of delivered source ranges can still be legitimate review.

The current caveat that this is not observed access or proof of thorough review is important. Inventory membership cannot strengthen that into proof: copying eligible names from the inventory would pass validation without source examination. Shell commands, scripts, pipelines, MCP results, editor context, Git blobs, and nested agents are all supported only insofar as the producing model faithfully reports them.

I would retain this as explicitly best-effort semantic reporting. Comprehensive observed-access accounting would require a different evidence source and would still not establish that the model understood the contents.

excludePaths: z.never().optional(),
receiptRefs: z.never().optional(),
inventoryStrategy: z.never().optional(),
reviewedFiles: reviewedFilesSchema.optional(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Make the producer handoff explicit and exercise it end to end

The optional schema field enables retention, but it does not by itself establish that the existing producers will populate it. The baseline and investigator prompts already return snake_case reviewed_files; the parent guidance does not explicitly map those lists into coverage.reviewedFiles, and final-report.md still describes semantic coverage as { surfaces, explicitExclusions, deferred }.

I understand that keeping instructions unchanged is an intentional scope choice in this PR. In that case, this should be treated as storage support for producers that opt in, with reporting availability unverified. If the intended result is a dependable reported-file count from ordinary scans, please connect the existing child reports to the parent checkpoint contract explicitly.

A useful integration test would deliver a baseline/investigator response with investigated files but no findings, then verify those claims survive the parent checkpoint, final result, and resume. Include an unavailable child list and an explicit empty list so missing accounting is not silently converted to zero. Manually constructing coverage.reviewedFiles in merge tests does not exercise this handoff.

The host can normalize and combine reported claims, but it should not infer review from finding locations or tool command text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants