Repository navigation
Conversation
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
loopzero primary review by claude on 0469418b2ad3b80a89f8afb3f787b1f63b0de9d5, 31.8s: request_changes (0 critical, 1 important, 2 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)
Raw reviewer output
{"duration_api_ms":29456,"stop_reason":"tool_use","session_id":"ebd0f9e1-f285-4382-b8bc-f4125721cd17","total_cost_usd":0.17043039999999998,"usage":{"input_tokens":8,"cache_creation_input_tokens":12630,"cache_read_input_tokens":48892,"output_tokens":2979,"output_tokens_details":{"thinking_tokens":1370},"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":12630,"ephemeral_5m_input_tokens":0},"inference_geo":"global","iterations":[{"input_tokens":2,"output_tokens":1059,"cache_read_input_tokens":17115,"cache_creation_input_tokens":1317,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":1317},"type":"message"}],"speed":"standard","fallback_credit":null},"modelUsage":{"claude-opus-5-5":{"inputTokens":8,"outputTokens":2979,"cacheReadInputTokens":48892,"cacheCreationInputTokens":12630,"webSearchRequests":0,"costUSD":0.17043039999999998,"contextWindow":1000000,"maxOutputTokens":128000,"thinkingTokens":1370,"cacheCreationEphemeral5mInputTokens":0,"cacheCreationEphemeral1hInputTokens":12630,"canonicalModel":"claude-opus-5-5","provider":"firstParty","costBasis":"list"}},"permission_denials":[],"terminal_reason":"completed","fast_mode_state":"off","fast_mode_disabled_reason":"sdk_opt_in_required","subagent_stats":{"spawned":0,"requested":{"background":0,"foreground":0,"unset":0},"started_in_background":0,"max_depth":0,"spawned_by_subagents":0,"completed":0,"failed":0,"killed":{"parent":0,"user":0,"system":0},"refused":{"depth_limit":0,"concurrency_limit":0,"budget":0},"by_type":{}},"safety_stops":0,"is_error":false,"num_turns":7,"subtype":"success","api_error_status":null,"result":"{\"verdict\":\"request_changes\",\"findings\":[{\"severity\":\"important\",\"path\":\"src/loopzero/worktree.py\",\"line\":251,\"title\":\"A non-UTF-8 patch now blocks every review, not just native evidence\",\"body\":\"`diff_since` now decodes strictly, and `_git` turns `UnicodeDecodeError` into `GitError`. `cli.py:949` calls `diff_since` without any guard, before any reviewer family is chosen. So a branch that changes a Latin-1/CP1252 text file (anything Git doesn't treat as binary) can no longer be reviewed by any family, including Claude and unpublished local reviews. Before this change those runs went ahead using `errors=\\\"replace\\\"`, and only the Codex native digest check would have failed to match. The ARCHITECTURE note only says such a patch \\\"cannot supply exact review evidence\\\", which reads as an evidence limit rather than a hard stop. The error text (`git diff ... failed: output is not valid UTF-8`) doesn't name a file or say how to recover, and no test covers this path. Smallest fix: if a hard failure is intended, raise a `CliError` naming the cause and the recovery, document it as a review precondition, and add a test. Otherwise, fall back to replacement decoding and skip or omit `diff_sha256`/`diff_bytes` in `review_context` so evidence is reported as unavailable while the review still runs.\"},{\"severity\":\"suggestion\",\"path\":\"src/loopzero/_proc.py\",\"line\":81,\"title\":\"`preserve_newlines` switches to binary I/O and strict decoding; the name only says newlines\",\"body\":\"The flag does three things: it turns off newline translation, makes stdout decoding strict (raising `UnicodeDecodeError` out of `run`), and changes stderr's default encoding from the locale to UTF-8. Any future caller that sets it to keep CRs will also get the strict-decode exception, which `run`'s other callers don't expect. A clearer name such as `exact_stdout`/`raw_utf8`, or a docstring line saying `run` may raise `UnicodeDecodeError`, would make this explicit. Also, the stdin encoding branch at line 82 is never used, since the only caller passes no input. Removing it would keep the shim smaller.\"},{\"severity\":\"suggestion\",\"path\":\"tests/test_runners.py\",\"line\":276,\"title\":\"Native-inspection check uses a hand-built output, not real Codex output\",\"body\":\"The test builds `aggregated_output` from `subprocess.check_output`, so it only shows that `_native_inspection` matches when the tool output keeps CRs byte-for-byte. It doesn't show that Codex's `aggregated_output` really keeps `\\\\r` from `git diff`. If Codex normalises line endings, CRLF-only patches would still fail to verify in production. Consider adding a note or a fixture recorded from real Codex output.\"}]}","structured_output":{"verdict":"request_changes","findings":[{"severity":"important","path":"src/loopzero/worktree.py","line":251,"title":"A non-UTF-8 patch now blocks every review, not just native evidence","body":"`diff_since` now decodes strictly, and `_git` turns `UnicodeDecodeError` into `GitError`. `cli.py:949` calls `diff_since` without any guard, before any reviewer family is chosen. So a branch that changes a Latin-1/CP1252 text file (anything Git doesn't treat as binary) can no longer be reviewed by any family, including Claude and unpublished local reviews. Before this change those runs went ahead using `errors=\"replace\"`, and only the Codex native digest check would have failed to match. The ARCHITECTURE note only says such a patch \"cannot supply exact review evidence\", which reads as an evidence limit rather than a hard stop. The error text (`git diff ... failed: output is not valid UTF-8`) doesn't name a file or say how to recover, and no test covers this path. Smallest fix: if a hard failure is intended, raise a `CliError` naming the cause and the recovery, document it as a review precondition, and add a test. Otherwise, fall back to replacement decoding and skip or omit `diff_sha256`/`diff_bytes` in `review_context` so evidence is reported as unavailable while the review still runs."},{"severity":"suggestion","path":"src/loopzero/_proc.py","line":81,"title":"`preserve_newlines` switches to binary I/O and strict decoding; the name only says newlines","body":"The flag does three things: it turns off newline translation, makes stdout decoding strict (raising `UnicodeDecodeError` out of `run`), and changes stderr's default encoding from the locale to UTF-8. Any future caller that sets it to keep CRs will also get the strict-decode exception, which `run`'s other callers don't expect. A clearer name such as `exact_stdout`/`raw_utf8`, or a docstring line saying `run` may raise `UnicodeDecodeError`, would make this explicit. Also, the stdin encoding branch at line 82 is never used, since the only caller passes no input. Removing it would keep the shim smaller."},{"severity":"suggestion","path":"tests/test_runners.py","line":276,"title":"Native-inspection check uses a hand-built output, not real Codex output","body":"The test builds `aggregated_output` from `subprocess.check_output`, so it only shows that `_native_inspection` matches when the tool output keeps CRs byte-for-byte. It doesn't show that Codex's `aggregated_output` really keeps `\\r` from `git diff`. If Codex normalises line endings, CRLF-only patches would still fail to verify in production. Consider adding a note or a fixture recorded from real Codex output."}]},"ttft_ms":2122,"type":"result","duration_ms":30283,"uuid":"ca394e59-e8c3-4971-83ea-59e4939b3540","ttft_stream_ms":1283,"time_to_request_ms":699,"first_content_frame_ms":1283,"queued_turn_count":0,"result_index":0}
| """ | ||
| argv = [str(part) for part in argv] | ||
| started = time.monotonic() | ||
| raw_encoding = encoding or "utf-8" |
There was a problem hiding this comment.
suggestion: preserve_newlines switches to binary I/O and strict decoding; the name only says newlines
The flag does three things: it turns off newline translation, makes stdout decoding strict (raising UnicodeDecodeError out of run), and changes stderr's default encoding from the locale to UTF-8. Any future caller that sets it to keep CRs will also get the strict-decode exception, which run's other callers don't expect. A clearer name such as exact_stdout/raw_utf8, or a docstring line saying run may raise UnicodeDecodeError, would make this explicit. Also, the stdin encoding branch at line 82 is never used, since the only caller passes no input. Removing it would keep the shim smaller.
| "diff_sha256": hashlib.sha256(diff.encode()).hexdigest(), "diff_bytes": len(diff.encode()), | ||
| } | ||
| 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} |
There was a problem hiding this comment.
suggestion: Native-inspection check uses a hand-built output, not real Codex output
The test builds aggregated_output from subprocess.check_output, so it only shows that _native_inspection matches when the tool output keeps CRs byte-for-byte. It doesn't show that Codex's aggregated_output really keeps \r from git diff. If Codex normalises line endings, CRLF-only patches would still fail to verify in production. Consider adding a note or a fixture recorded from real Codex output.
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
loopzero delta review by claude on 4525544fe0a1a3535618d0893bd29eebf8df3672, 35.4s: request_changes (0 critical, 2 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)
Raw reviewer output
{"duration_api_ms":33158,"stop_reason":"tool_use","session_id":"f4009ac1-1df4-4881-8406-bda693aea56b","total_cost_usd":0.165126,"usage":{"input_tokens":10,"cache_creation_input_tokens":10933,"cache_read_input_tokens":57010,"output_tokens":3311,"output_tokens_details":{"thinking_tokens":1408},"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":10933,"ephemeral_5m_input_tokens":0},"inference_geo":"global","iterations":[{"input_tokens":2,"output_tokens":1721,"cache_read_input_tokens":15200,"cache_creation_input_tokens":1552,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":1552},"type":"message"}],"speed":"standard","fallback_credit":null},"modelUsage":{"claude-opus-5-5":{"inputTokens":10,"outputTokens":3311,"cacheReadInputTokens":57010,"cacheCreationInputTokens":10933,"webSearchRequests":0,"costUSD":0.165126,"contextWindow":1000000,"maxOutputTokens":128000,"thinkingTokens":1408,"cacheCreationEphemeral5mInputTokens":0,"cacheCreationEphemeral1hInputTokens":10933,"canonicalModel":"claude-opus-5-5","provider":"firstParty","costBasis":"list"}},"permission_denials":[],"terminal_reason":"completed","fast_mode_state":"off","fast_mode_disabled_reason":"sdk_opt_in_required","subagent_stats":{"spawned":0,"requested":{"background":0,"foreground":0,"unset":0},"started_in_background":0,"max_depth":0,"spawned_by_subagents":0,"completed":0,"failed":0,"killed":{"parent":0,"user":0,"system":0},"refused":{"depth_limit":0,"concurrency_limit":0,"budget":0},"by_type":{}},"safety_stops":0,"is_error":false,"num_turns":8,"subtype":"success","api_error_status":null,"result":"{\"verdict\":\"request_changes\",\"findings\":[{\"severity\":\"important\",\"path\":\"src/loopzero/_proc.py\",\"line\":121,\"title\":\"Lossy decoding lets the reviewer approve byte changes it cannot see\",\"body\":\"`diff_since` now decodes with `errors=\\\"replace\\\"`, so every invalid UTF-8 byte turns into U+FFFD. A commit that changes one legacy-encoded byte to another (for example Latin-1 `caf\\\\xe9` to `caf\\\\xe8`, or a cp1252 quote swapped for another) shows up in the supplied patch as `-caf�` / `+caf�`. The two lines are identical, so the reviewer cannot see what changed, yet the review still counts as covering that head. Before this delta, the code failed closed with `GitError(\\\"output is not valid UTF-8\\\")`, and the docs stated that such a patch cannot supply exact review evidence. That safety property is now gone, and nothing tells the reviewer the patch was altered. Smallest fix: decode `preserve_newlines` output with `errors=\\\"backslashreplace\\\"`, which keeps distinct bytes distinct and visible (`\\\\xe9` vs `\\\\xe8`), and keep the native-digest path honest (see the related finding). Alternatively, keep failing closed. In either case, add a test where a non-UTF-8 byte is changed to another non-UTF-8 byte and assert that the -/+ lines differ.\"},{\"severity\":\"important\",\"path\":\"docs/ARCHITECTURE.md\",\"line\":178,\"title\":\"Docs still promise the exact Git patch, and the native digest no longer hashes Git's bytes\",\"body\":\"Line 178 still says stdin carries \\\"the exact UTF-8 Git patch\\\". The next sentence now admits that invalid UTF-8 is replaced, so for non-UTF-8 patches the material is not exact. The task's acceptance also says \\\"Native inspection verifies the digest against Git's output\\\". But `cli.py:969` computes `diff_sha256`/`diff_bytes` from the lossily decoded string, not from Git's raw bytes. `runners._native_inspection` (runners.py:832-848) then matches that digest against Codex's `aggregated_output` re-encoded as UTF-8. For a non-UTF-8 patch this passes only if Codex's own lossy decoding replaces exactly the same byte runs as CPython's `replace` handler. That is an unverified coupling, and when it matches, it verifies the lossy text rather than Git's output. Fix: either reword the docs and evidence claim so they describe the replaced text instead of the exact Git patch, or keep non-UTF-8 patches out of the digest-verified path. Add a test in test_codex_transport/test_runners that covers native inspection for a non-UTF-8 patch.\"},{\"severity\":\"suggestion\",\"path\":\"src/loopzero/_proc.py\",\"line\":75,\"title\":\"Docstring is now ambiguous about error handling\",\"body\":\"The docstring changed from \\\"decode stdout strictly\\\" to \\\"decode output without newline translation\\\", but it does not say that invalid bytes are now replaced. `preserve_newlines` is used by review-evidence code, so callers should not have to guess. State the error policy explicitly, e.g. \\\"invalid bytes are replaced with U+FFFD\\\" or whichever policy you settle on after the finding above.\"}]}","structured_output":{"verdict":"request_changes","findings":[{"severity":"important","path":"src/loopzero/_proc.py","line":121,"title":"Lossy decoding lets the reviewer approve byte changes it cannot see","body":"`diff_since` now decodes with `errors=\"replace\"`, so every invalid UTF-8 byte turns into U+FFFD. A commit that changes one legacy-encoded byte to another (for example Latin-1 `caf\\xe9` to `caf\\xe8`, or a cp1252 quote swapped for another) shows up in the supplied patch as `-caf�` / `+caf�`. The two lines are identical, so the reviewer cannot see what changed, yet the review still counts as covering that head. Before this delta, the code failed closed with `GitError(\"output is not valid UTF-8\")`, and the docs stated that such a patch cannot supply exact review evidence. That safety property is now gone, and nothing tells the reviewer the patch was altered. Smallest fix: decode `preserve_newlines` output with `errors=\"backslashreplace\"`, which keeps distinct bytes distinct and visible (`\\xe9` vs `\\xe8`), and keep the native-digest path honest (see the related finding). Alternatively, keep failing closed. In either case, add a test where a non-UTF-8 byte is changed to another non-UTF-8 byte and assert that the -/+ lines differ."},{"severity":"important","path":"docs/ARCHITECTURE.md","line":178,"title":"Docs still promise the exact Git patch, and the native digest no longer hashes Git's bytes","body":"Line 178 still says stdin carries \"the exact UTF-8 Git patch\". The next sentence now admits that invalid UTF-8 is replaced, so for non-UTF-8 patches the material is not exact. The task's acceptance also says \"Native inspection verifies the digest against Git's output\". But `cli.py:969` computes `diff_sha256`/`diff_bytes` from the lossily decoded string, not from Git's raw bytes. `runners._native_inspection` (runners.py:832-848) then matches that digest against Codex's `aggregated_output` re-encoded as UTF-8. For a non-UTF-8 patch this passes only if Codex's own lossy decoding replaces exactly the same byte runs as CPython's `replace` handler. That is an unverified coupling, and when it matches, it verifies the lossy text rather than Git's output. Fix: either reword the docs and evidence claim so they describe the replaced text instead of the exact Git patch, or keep non-UTF-8 patches out of the digest-verified path. Add a test in test_codex_transport/test_runners that covers native inspection for a non-UTF-8 patch."},{"severity":"suggestion","path":"src/loopzero/_proc.py","line":75,"title":"Docstring is now ambiguous about error handling","body":"The docstring changed from \"decode stdout strictly\" to \"decode output without newline translation\", but it does not say that invalid bytes are now replaced. `preserve_newlines` is used by review-evidence code, so callers should not have to guess. State the error policy explicitly, e.g. \"invalid bytes are replaced with U+FFFD\" or whichever policy you settle on after the finding above."}]},"ttft_ms":2584,"type":"result","duration_ms":33968,"uuid":"aeebc8e1-6441-4d26-bf97-fafab612ffc6","ttft_stream_ms":1496,"time_to_request_ms":657,"first_content_frame_ms":1496,"queued_turn_count":0,"result_index":0}
| `merge_output=True` sends stderr into stdout so interleaving is preserved. | ||
| `input` is written to the child's stdin; without it stdin is /dev/null. | ||
| `encoding` overrides the parent locale for text I/O; None retains subprocess defaults. | ||
| With `preserve_newlines`, decode output without newline translation |
There was a problem hiding this comment.
suggestion: Docstring is now ambiguous about error handling
The docstring changed from "decode stdout strictly" to "decode output without newline translation", but it does not say that invalid bytes are now replaced. preserve_newlines is used by review-evidence code, so callers should not have to guess. State the error policy explicitly, e.g. "invalid bytes are replaced with U+FFFD" or whichever policy you settle on after the finding above.
Co-Authored-By: Codex <noreply@openai.com>
|
Handoff at
|
|
Superseded by #1237, which carries this patch and the fixes for all three blocking findings. |
Preserve carriage returns in review diffs
Context and goal
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.
Validation
(no
loopzero checkrun recorded)Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Review