Skip to content

fix: review deleted files diff-first instead of leaving them UNREVIEWED - #338

Open
rembradtech wants to merge 3 commits into
mainfrom
fix/deleted-files-not-unreviewed
Open

rembradtech wants to merge 3 commits into
mainfrom
fix/deleted-files-not-unreviewed

Conversation

@rembradtech

Copy link
Copy Markdown
Contributor

Problem

Since #180, loadScmTargets marks every file a PR removes as UNREVIEWED (deleted file requires diff-first review). A review with any unreviewed file is INCOMPLETE and exits 2, so any PR that deletes a file can never get a complete review — fixing findings doesn't help, the deletion is still in the diff.

Seen live on NoxCodeSolutions/design-system#5 (harness loop): after the Windows spawn fixes, the review ran 34/34 lenses with 0 failures, yet stayed INCOMPLETE solely because of apps/fixture-next/src/index.ts (deleted). The harness holds such a PR for a human after two incomplete reviews.

The local git-diff source has always skipped deletions; only the SCM source marks them unreviewed.

Fix

Do what the reason string asks: review the deletion diff-first.

  • A removed file with a patch becomes a target whose content is its removed lines ([deleted] …), numbered by base-file line.
  • changedRanges: [] → findings are not inDiff, so they go to the summary's "Findings outside the diff" instead of inline. GitHub anchors inline comments on the head side (line), where a deleted file has no lines; an inline anchor there would make GitHub reject the whole review.
  • Still UNREVIEWED: no patch from GitHub (too large / binary), a denied path (checked first, so e.g. a deleted .env never reaches the prompt), or over the byte budget (counted like any projected file).
  • Redaction applies as for other files.

This keeps #180's intent (a deletion is not silently ignored) while letting a PR with deletions complete.

Tests

  • New test/sources-deleted-files.test.mjs: deletion reviewed from patch with base-file numbering and no inline anchors; no-patch and denied deletions stay UNREVIEWED (denied carries no content); mixed delete + edit reviews both.
  • campaign-preflight.test.mjs: the PR-6 fixture that asserts an unreviewed file blocks a campaign now deletes a file without a patch, the case that stays unreviewed.
  • Locally (Windows): build + typecheck pass; the new and updated tests pass. packaged campaign command keeps stdout machine-readable when output cannot be written fails identically on main without this change (Windows-specific). The full suite did not finish locally within 20 min, so CI is the authority here.

https://claude.ai/code/session_01CgEWGPjo2rnCHc8C2wfRay

rembradtech added 3 commits October 9, 2026 15:02
Since #180 every file a PR removes was marked UNREVIEWED ("deleted file
requires diff-first review"), so any PR with a deletion was INCOMPLETE and
exited 2 forever: no amount of fixing could complete its review. Loops that
gate merges on a complete review held every such PR for a human.

A deleted file is now reviewed from its patch: the removed lines, numbered by
their base-file line. Its changedRanges stay empty, so findings land in the
review summary instead of inline: GitHub anchors inline comments on the head
side, where a deleted file has no lines. It stays UNREVIEWED when GitHub sent
no patch, when its path is denied, or when it exceeds the byte budget.

Claude-Session: https://claude.ai/code/session_01CgEWGPjo2rnCHc8C2wfRay

This branch has not been deployed

No deployments
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.

1 participant