Skip to content

Keep PR content from hiding changed code from the reviewer - #1206

Closed
eowca wants to merge 4 commits into
mainfrom
lean178/1101-reviewer-diff-integrity
Closed

eowca wants to merge 4 commits into
mainfrom
lean178/1101-reviewer-diff-integrity

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Keep PR content from hiding changed code from the reviewer

Context and goal

  • Goal: The reviewer always receives the changed lines of every text file in a PR, or an explicit line naming any file it is not shown; a PR can no longer make changed code disappear from review.
  • Problem: The reviewer's diff honoured the PR's own .gitattributes and git's "contains a NUL byte" binary guess, so a changed text file could arrive only as "Binary files … differ". When a large diff was reviewed in chunks, a modified file whose added lines contained the text git uses for deleted files was replaced by ": deleted, N lines". In both cases an approval could cover code the model never saw.
  • Context: diff_since builds the review material with git diff in the task worktree. split_diff cuts diffs that exceed the reviewer's size budget into chunks and shortens deleted files to a one-line summary.

Closes #1101

Acceptance

  • A PR that adds .gitattributes marking changed text files -diff or binary still gives the reviewer those files' hunks.
  • A changed UTF-8 text file containing a NUL byte is shown as text. A file whose content at HEAD (at the base when deleted) is not UTF-8, such as a real binary, keeps Git's header line and gets "content not shown: not UTF-8 text, N bytes", never as a bare "Binary files differ".
  • In split_diff, a modified file whose added lines include the deletion header text keeps its hunks; only files git's header reports as deleted are summarized.
  • Tests in tests/test_worktree.py cover all three cases with a real temporary git repository.

Notes

  • Design pass (trust boundary): the reviewed head and, for delta reviews, the earlier reviewed head are PR-controlled; their .gitattributes and file bytes are untrusted. Invariant: every changed path appears in the material, with its changed lines when the content is UTF-8 text. Chosen approach: git diff --text --no-ext-diff --no-textconv (verified locally: --text overrides -diff/binary attributes and NUL detection), read losslessly as Latin-1 and decoded strictly per file block; deletion judged only from the header before the first hunk. Attributes are not taken from the base because a delta's base is itself a PR head.
  • Regression proof: both new tests in tests/test_worktree.py fail on pre-fix source and pass after.
  • Review round one (Codex): files are now classified from their own content, not from the patch, so UTF-8 additions survive a non-UTF-8 old side and a non-UTF-8 byte outside the diff context still yields the notice; Git output is read as bytes, so a bare carriage return in a file cannot fake a file boundary; output is no longer trimmed; notices and deletion summaries keep Git's own (quoted) header line instead of re-parsing paths; deletion needs a whole deleted file mode header line. Regression tests fail at the reviewed head.
  • Review round two (Codex delta): classification uses full object IDs (--full-index), so an abbreviated ID cannot resolve as a ref name; the batch reader consumes every payload, so a submodule commit cannot shift later results (test fails at the delta-reviewed head); object IDs are deduplicated and blobs are validated in 64 KiB chunks instead of buffered whole. Not taken: notices for rename-only or mode-only changes, which change no content and are fully shown by Git's rename/mode lines. This was the last review round under the budget.
  • Trade-off: a binary file that happens to be valid UTF-8 is shown as text (harmless); split_diff already bounds oversized material.

Base

main @ fa78ebb
Base: fa78ebb

Validation

Recorded for a2830cd5b5fe (not current head)

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

  • primary, codex, fda1970, request_changes
  • delta, codex, a2830cd, request_changes

The reviewer diff now treats every file as text and ignores attributes
and diff drivers the PR could set, so a PR-added -diff/binary attribute
or a NUL byte no longer reduces a changed text file to "Binary files
differ". A file block that is not UTF-8 is replaced by its path and size.
Chunked review summarizes a file as deleted only when git's header says
so, not when its added lines contain the header text.

Closes #1101

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot 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.

loopzero primary review by codex on fda19707e348d3360d240df67201223b8e53d7ef, 50.7s: request_changes (2 critical, 3 important, 0 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model gpt-6.2-astra (effort medium); CLI-reported model gpt-6.2-astra (effort medium); configured model gpt-6.2-astra (effort medium)
Raw reviewer output
Native Codex transcript retained in the restricted local review receipt; public evidence is publisher-derived, not backend attestation. Exact raw SHA256: ae08a9950534ecb1e7aee1f81021a54396c17cd456a8e3ec2ff0a9940303f50c

Comment thread src/loopzero/worktree.py Resolved
Comment thread src/loopzero/worktree.py Resolved
Comment thread src/loopzero/worktree.py Resolved
Comment thread src/loopzero/worktree.py Resolved
Comment thread src/loopzero/runners.py Resolved
diff_since now reads Git's output as bytes, so a bare carriage return
cannot fake a file boundary, keeps it untrimmed, and decides whether to
show a file from its HEAD (or deleted base) blob rather than the patch.
Notices and deletion summaries keep Git's own header line, and only a
whole "deleted file mode" header line marks a deletion.

Refs #1101

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot 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.

loopzero delta review by codex on a2830cd5b5feffeba68b65232b77cf7a7fdf541b, 22.5s: request_changes (0 critical, 4 important, 0 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model gpt-6.2-astra (effort medium); CLI-reported model gpt-6.2-astra (effort medium); configured model gpt-6.2-astra (effort medium)
Raw reviewer output
Native Codex transcript retained in the restricted local review receipt; public evidence is publisher-derived, not backend attestation. Exact raw SHA256: a7428b3376640a1d3e1013b030e19fe9379524b6f867fa62048e72455094939b

Comment thread src/loopzero/worktree.py Resolved
Comment thread src/loopzero/worktree.py Resolved
Comment thread src/loopzero/worktree.py Resolved
Comment thread src/loopzero/worktree.py Resolved
eowca and others added 2 commits November 26, 2026 02:11
The reviewer diff now carries full object IDs, so classification cannot
resolve an abbreviated ID as a ref name. The single cat-file batch reads
each object once, consumes every payload (submodule commits included)
and validates UTF-8 in bounded chunks instead of buffering whole files.

Refs #1101

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-diff-integrity

# Conflicts:
#	tests/test_cli.py
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1366. This PR's repair commits after its second (delta) review need review coverage, and the contract puts a head that needs another review in a new PR. #1366 carries the same change plus those repairs, merged with current main. The findings and their dispositions stay recorded in this PR's threads.

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.

security: Keep PR-controlled content from hiding changed code from the reviewer

1 participant