Skip to content

Preserve carriage returns in review diffs - #1237

Closed
eowca wants to merge 6 commits into
mainfrom
lean178/1126-exact-review-patch
Closed

eowca wants to merge 6 commits into
mainfrom
lean178/1126-exact-review-patch

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 replaces #1140 and carries its diff plus the fixes for its three blocking findings.

Validation

Recorded for ddb222af12ec

  • 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, claude, 73d5449, request_changes
  • delta, claude, ddb222a, approve

eowca and others added 3 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>

@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 73d54496e43164a60a1d16b8b38f300b009ff809, 50.8s: request_changes (0 critical, 1 important, 3 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 docs/ARCHITECTURE.md Resolved
Comment thread src/loopzero/runners.py
)


def render_patch(patch: bytes) -> str:

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: The escaped rendering is applied to the whole patch and nothing tells the reviewer

If any single byte in the patch is not valid UTF-8, render_patch doubles every backslash in every file. That includes Git's \ No newline at end of file markers and backslashes in unrelated UTF-8 source files. Neither the material header nor the reviewer policy says the escaping was applied, so the reviewer can't tell whether \\ means a real double backslash or an escaped single one. Smallest fix: add a flag to the material header when the escaped form is used, e.g. "diff_encoding": "utf-8-backslash-escaped" in build_prompt, or mention the escaping in the policy.

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: The diff is decoded to text and then re-encoded to bytes

run(preserve_newlines=True) decodes stdout with surrogateescape, _git returns that string, and diff_since encodes it back to bytes. This does reproduce the original bytes exactly, but it adds a third output mode to _git (alongside the default and preserve_whitespace) just to undo the decoding. It also means _proc.run now has two decode paths with different error handlers for stdout and stderr. Simpler: let run return raw stdout bytes for this mode (or call it with text=False directly from diff_since). Then diff_since gets the bytes without the round trip, and _git keeps its text-only contract.

Comment thread tests/test_runners.py
command = f"git -C {git_repo} rev-parse HEAD && git -C {git_repo} diff --no-color {base} {head}"
item = {"type": "command_execution", "id": "read-1", "command": command}
output = head + "\n" + native.decode(errors="replace")
events = [

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: The test builds a fake Codex output instead of exercising real Codex behavior

The test creates aggregated_output with native.decode(errors="replace"). That assumes Codex reports command output as lossy UTF-8 with CR bytes kept. If real Codex normalizes CRLF or trims trailing whitespace in aggregated_output, the new digest (which now includes the CR and final newline) would come out unknown in production while this test passes. Consider adding a CRLF case to the fake-codex subprocess test in tests/test_codex_transport.py, which runs real git through the transport path.

Architecture-Review: unchanged; tests exercise the documented exact Git evidence 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 ddb222af12ec0e081225c6e11695a26e26df4258, 14.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 01:13
@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

❌ Left the queue · checks failed

1 min in the queue, less than a minute of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 01:14 · rule main · triggered by @eowca with the @mergifyio queue command
  • ❌ Checks failed · draft #1278
  • 🚫 Left the queue 01:14 · ddb222a

Not proven to be this pull request's failure. It failed on top of the pull requests ahead of it, and was not tested alone.

Reason

The merge conditions cannot be satisfied due to failing checks

  • checks

Failing checks:

To get back in the queue

  • If the failure comes from the pull requests it was tested with, or is a flake, comment @mergifyio queue to queue it again as it is.
  • If it is this pull request's, push a fix: the pull request is queued again once its queue conditions match.

Merge conditions not met when it left the queue

  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-neutral = checks
    • check-skipped = checks
    • check-success = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility
    • check-success = Loop-zero Eligibility
1 merge condition met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@mergify mergify Bot added dequeued and removed queued labels Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Handoff for ddb222a. The full sandboxed check passed, delta review approved with no findings, and loopzero ready --wait accepted the receipt. Queue candidate #1278 failed the source size budget at 7,525 lines against a cap of 7,500. Independently merging the current main tree (fa78ebb) with this head yields the same 7,525 lines, so an unchanged retry would fail today. The source head can keep its approval and be requeued when main has at least 25 lines of headroom for this patch. #1126 remains open.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1353. The source-cap increase cleared the first blocker. This replacement uses a smaller regression fixture to fit the separate test cap after integrating main. The production patch is carried forward.

@eowca eowca closed this Nov 26, 2026
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