Skip to content

Preserve carriage returns in review diffs - #1353

Merged
mergify[bot] merged 10 commits into
mainfrom
lean178/1126-patch-bytes
Nov 26, 2026
Merged

mergify[bot] merged 10 commits into
mainfrom
lean178/1126-patch-bytes

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Preserve carriage returns in review diffs

Context and goal

  • Goal: Show reviewers line-ending changes and verify the captured patch against native Git output.
  • Problem: Universal newline translation and trimming change review patch content.
  • Context: Diff capture preserves the patch while other Git callers retain their text behavior.

Acceptance

A committed CRLF-only change keeps its carriage return and final newline in the supplied patch. Native inspection verifies the digest against Git's output. Existing text-mode callers retain their behavior.

Closes #1126

Base

Base: 47bdb17

Notes

The committed CRLF fixture failed before the change because the prompt dropped its carriage return and final newline. The full runner test file passed with the fix.

This supersedes #1237. It carries the original #1140 patch and its review fixes, with a smaller regression fixture to fit the test line budget. The transport test exercises both CRLF and legacy-encoded committed patches.

Validation

Recorded for 1752ac831900

  • 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

eowca and others added 9 commits November 26, 2026 00:40
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; retain the documented Git patch capture and main’s branch name whitespace handling.

Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; tests exercise the documented exact Git evidence path.

Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the compact fixtures verify the documented original patch digest.

Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the transport test covers both exact and rendered patches.

Co-Authored-By: Codex <noreply@openai.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 claude on e8a5bde8fb4b0b4034a083ab0a0edcb453ab066d, 33.0s: approve (0 critical, 0 important, 1 suggestion)

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

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/worktree.py

def diff_since(wt: Path, sha: str) -> str:
return _git(Path(wt), "diff", "--no-color", sha, "HEAD")
def diff_since(wt: Path, sha: str) -> bytes:

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: diff_since turns Git's bytes into text and back again

diff_since asks _proc.run(preserve_newlines=True) to turn Git's raw stdout into text using surrogateescape. It then turns that text straight back into bytes. That round trip is the only reason _proc.run needs to set stdout and stderr to different error handlers, and for preserve_newlines to also switch the encoding to UTF-8. The result is correct because surrogateescape gets the original bytes back exactly. Still, the bytes are the real data here, so there's no reason to go through text. A simpler fix: add a small raw-bytes mode to _proc.run (or a _git_bytes helper) that returns proc.stdout unchanged, and have diff_since return it directly. That removes the surrogateescape conversions and means a future caller can't accidentally write the surrogateescaped string somewhere that expects strict UTF-8.

Architecture-Review: unchanged; the deletion fixture follows the documented patch rendering path.

Co-Authored-By: Codex <noreply@openai.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 claude on 1752ac831900f9c14093e6bfaab923849803f53a, 7.1s: approve (0 critical, 0 important, 0 suggestion)

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

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

@eowca
eowca marked this pull request as ready for review November 26, 2026 02:25
@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 c5232bb at 02:31 UTC

5 min in the queue, 4 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 02:26 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1395
  • ✅ Merged 02:31 · c5232bb · 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

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

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.

Preserve committed CRLF changes in reviewer diffs and evidence hashes

1 participant