Skip to content

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

Merged
mergify[bot] merged 10 commits into
mainfrom
lean178/1101-reviewer-diff-integrity-3
Nov 26, 2026
Merged

mergify[bot] merged 10 commits into
mainfrom
lean178/1101-reviewer-diff-integrity-3

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, and other non-UTF-8 content is shown escaped (as main already renders it), 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

Base

main @ 29a3f88
Base: 29a3f88

Validation

Recorded for ac76ad772bb9

  • 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, 48e31d5, request_changes
  • delta, codex, ac76ad7, approve

eowca and others added 8 commits November 26, 2026 01:03
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>
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>
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
…-diff-integrity-2

# Conflicts:
#	src/loopzero/runners.py
#	tests/test_cli.py
Folds the submodule case into the main diff test and tightens fixtures so
the test suite stays under its line cap after merging main.

Refs #1101

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reviewer diff now ignores .gitmodules ignore settings, the blob
classifier fails as a Git error on EOF, truncated payloads or a stalled
reader, and SHA-256 object IDs are matched at full length.

Refs #1101

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

# Conflicts:
#	docs/ARCHITECTURE.md
#	src/loopzero/worktree.py
#	tests/test_cli.py
#	tests/test_codex_transport.py

@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 48e31d5e71ec2fcec473ef63fbea43e803b03975, 55.3s: request_changes (0 critical, 1 important, 1 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: f1ce487f47ed760e3b70703b28b6f571a3153d67d716f9a90e7922e9cba2b9d5

Comment thread src/loopzero/worktree.py Resolved
Comment thread docs/ARCHITECTURE.md Outdated
prompt escapes invalid bytes and literal backslashes so the changes stay
visible. The native inspection digest always binds the original Git bytes.
visible. The native inspection digest always binds the original Git bytes. Git diffs
every file as text, ignoring attributes and diff drivers the PR could set.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Describe the specific attribute behavior the options override

Git can still use a .gitattributes diff driver to select function context in hunk headers. Describe the narrower guarantee: Git forces text hunks and disables external diff commands and text conversion. That explains why changed lines remain visible without claiming all attributes are ignored.

eowca and others added 2 commits November 26, 2026 04:27
A reviewer that reruns the exact patch command with --text,
--ignore-submodules=none and --submodule=short is now recorded as a
verified inspection, and ARCHITECTURE.md states the narrower guarantee.

Refs #1101

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moves the two runner imports into the test that uses them, so this branch
merges cleanly with main's concurrent import change.

Refs #1101

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eowca
eowca force-pushed the lean178/1101-reviewer-diff-integrity-3 branch from 49712fb to ac76ad7 Compare November 26, 2026 06:56

@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 ac76ad772bb958de524481815a3fcf0af31c821f, 15.7s: approve (0 critical, 0 important, 2 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: d7315b326fad7f9a0c1c9ed3caf7adee38a5b57cccd3ce453a0c0aea44373f5c

Comment thread tests/test_runners.py


def test_inspection_accepts_the_reviewer_patch_command() -> None:
command = (f"git -C /repo diff --no-color --no-ext-diff --no-textconv --text "

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Exercise the command that diff_since actually emits

The test hand-copies the Git options, so it will still pass if diff_since adds an option that _inspection_commands rejects. Capture the arguments from diff_since and pass their shell-quoted form to the parser so the test catches future drift.

Comment thread tests/test_worktree.py


def test_split_diff_summarizes_only_files_git_reports_deleted(git_repo: Path) -> None:
from loopzero.runners import render_patch, split_diff # keeps the shared import block untouched

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Keep the runner imports at module scope

The inline comment says the local import preserves the shared import block, but this delta edits that block too. Import render_patch and split_diff there and remove the local import and its comment.

@eowca
eowca marked this pull request as ready for review November 26, 2026 07:03
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as 0b74780 at 07:12 UTC

8 min in the queue, 3 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 07:04 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1595
  • ✅ Merged 07:12 · 0b74780 · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit 0b74780 into main Nov 26, 2026
17 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1101-reviewer-diff-integrity-3 branch November 26, 2026 07:13
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