Repository navigation
fix(python): pair each line of a replacement block with its own old line (#7556) - #7600
Conversation
…#7556) The second line of a comment-plus-return replacement block reads a false exposed on main: the return loses its old line, every token reads as changed, and a test observing only the unchanged operand gets credit. One-line and discriminating controls read correctly. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U7GbrVC98fTYnLnhe3vhFM
…ine (#7556) Every removed line of a block shares the new-side line where the added run starts, so the coordinate lookup found an old line only for the run's first added line. A later changed line read every token as delta and a test observing only an unchanged operand earned a false exposed. The adapter now reads old lines from ChangedFile::aligned_counterparts (#7524), and the new-declaration guard treats a def as changed only when its paired old line looks like it. py-blocks-account-clamp-second-line moves from credited (false exposed) to gap (weakly_exposed); Python false verdicts 6/66 -> 5/66. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U7GbrVC98fTYnLnhe3vhFM
…ge (#7556) Content pairing compares trimmed text, so an annotation that leaves an if block paired with its indented old self and the annotation-only guard suppressed the probe. Both annotation guards now require the paired lines to share their indentation. Adds a rename test (look-alike header keeps its probe) and a body-line positive control, and narrows the SPEC wording to the two second-line cases. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U7GbrVC98fTYnLnhe3vhFM
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
Summary by CodeRabbit
WalkthroughThe Python analyzer now pairs added lines with their replaced counterparts and uses those pairs in import detection and classification. Declaration guards account for paired lines and indentation. New regression tests, verdict-corpus cases, and an adversarial fixture record expected classifications and reports. ChangesPython replacement-block pairing
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to
|
Review of recordHead: Reviewers: three independent agent reviews. Gemini and CodeRabbit were quota-limited on this PR and produced no review.
Findings and resolutions
Proof
Disposition: nothing blocking. Marking Ready for the required check. Generated by Claude Code |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- fixtures/python-verdict-corpus/subjects/authored-py-pytest-blocks.json retains ledger/init.py and tests/init.py with sha256 of the empty-file hash (e3b0c44…b855), which is correct but means the manifest's 'retained_files' can't distinguish present-empty from absent in diffs. Not a correctness issue today, but the corpus tooling's contract should be checked.
Verification questions
- Confirm devin also observed that the new promoted corpus row depends on a single fixture being re-blessed; AGENTS.md evidence-promotion honesty gate should pin an independent non-promotion control.
- Confirm the
same_indentationhelper compares leading whitespace viais_whitespace(), so lines using tabs vs spaces (or mixed) could match differently on different platforms and flip annotation-only guard verdicts. - Confirm the current diff does not reopen the deleted-carrier concern.
- Confirm adopt the authored subject at the hash pinned by
version_label(authored@3eef453). The subject JSON lists sha256 for retained files but nothing in the PR proves the running pytest used exactly these bytes; if the blessed hashes drift, the 'full_checkout_verdict' label silently rots.
Refuted
- All three guards (two annotation + new-declaration) suppress probes whenever an added line pairs with a content-equivalent old line, so any indentation-only or whitespace-only move is treated as annotation-only.; refuted because: All three call sites now require
same_indentation(old, line_text)(annotation-only) orlines_look_alike(new-declaration) before suppressing, and a dedicateddedented_annotation_change_keeps_its_probetest plus negative experiments cover the move-out-of-block case.
Parked follow-ups
- Devin also flagged missing independent evidence-promotion pin; non-goal here, but worth tracking.
- A living tracker outside this PR owns the concern.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
…posed in the honesty corpus (#7556) Review of #7600 (Devin): a rename that shares few tokens with its old header failed lines_look_alike, so the relaxed new-declaration guard suppressed a header that coordinate pairing used to keep. An old def header in the paired position now marks a changed header too. Graduates the confirmed false promotion into the evidence-promotion honesty corpus (RIPR-SPEC-0108) as py_replaced_block_non_delta_operand, backed by the new python_adversarial_replaced_block_non_delta_operand fixture: the return of a two-line block must stay weakly_exposed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U7GbrVC98fTYnLnhe3vhFM
…aration (#7556) Review follow-up: a new def paired by position with a removed decorator or class line is a changed declaration, so its header keeps its probe. Moves the doc comments back onto their functions and corrects the fixture SPEC: the block fixture drops the @Property of the one-line #1276 trap, so its test is related and the class is weakly_exposed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U7GbrVC98fTYnLnhe3vhFM
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- Honesty-corpus entry pins expected_class AND maximum_class both weakly_exposed: a re-bless that escalates to exposed would fail the gate independently of the verdict-corpus row, which closes Devin's promotion-honesty concern at PR scope.
Refuted
- Same indentation helper using
is_whitespace()could match tabs and spaces interchangeably and flip annotation-only verdicts on mixed-indent files.; refuted because:is_whitespace()treats space, tab, and form-feed uniformly, so leading-whitespace sequences compare by character identity, not by visual column width. Mixed tab/space indentation that produces identical prefix strings will match; sequences with different chars will not. Behavior is deterministic and platform-stable. - Boundary placement: is_python_def_line/same_indentation should be promoted to analysis::diff next to lines_look_alike rather than colocated with classify.rs; refuted because: classify.rs is the only caller and the rules encode Python-specific semantics (def/async def trim, indentation-only-suppresses-annotation); colocating avoids a cross-module dep and keeps the diff boundary at the adapter.
- Annotation-only guard will silently accept a mixed-tab/space dedent because lines_look_alike trims but same_indentation compares leading chars via is_whitespace, so ' ' and ' ' both count as whitespace and a CR or NBSP could pass differently on platforms.; refuted because: Both branches trim via trim_start for look-alike and walk leading whitespace generically; a Python source line cannot contain raw CR/NBSP indentation in normal source. Even at edge, only an indentation-only shift with matching content would match, and the changelog and test suite pin the behavior. No reproducible false positive in fixture set.
Evidence gaps
- Rip sensor returned exit-code 2 in the packet, so no ripr binary witness was produced; correctness claims rest on author-attested cargo output and the read of the diff, not on a fresh end-to-end run.
- Ripr sensor failed exit 2 on this diff; rust behavior or tests touched and source changed per flags, but cargo-build/clippy/fmt/check all skipped by profile. Failure blocks local reproduction of the 1600-test count and the goldens pipeline.
- Model proof intent was rejected by deterministic validation.
… Python inventory (#7556) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U7GbrVC98fTYnLnhe3vhFM
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Review of record (update)Head: Changes since the last record
Merge. Merged Proof on the merged tree
Disposition: nothing blocking. Marked Ready for the required check. Generated by Claude Code |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- PR body claims 'cargo xtask verdict-corpus check-all exit 0, after merging main' but no receipt is in this packet. The honest test is the post-merge verdict-corpus row counts, not just the precommit suite; ship a CI receipt.
Verification questions
- Confirm authored subject 'authored-py-pytest-blocks' pins sha256 of two empty files (ledger/init.py and tests/init.py) to the empty-file hash e3b0c44…b855.
- Confirm cargo-test is scheduled-late, not a pytest witness. If pytest tooling can't be wired into the broker, document the manual witness command.
Refuted
- Boundary placement: is_python_def_line/same_indentation should be promoted to analysis::diff next to lines_look_alike rather than colocated with classify.rs; refuted because: classify.rs is the only caller and the rules encode Python-specific semantics (def/async def trim, indentation-only-suppresses-annotation); colocating avoids a cross-module dep and keeps the rules with their semantics. EffortlessSteven review of record agrees.
- Lift is_python_def_line and same_indentation to analysis::diff next to lines_look_alike to keep classify.rs free of Python-specific knowledge.; refuted because: Both helpers encode Python-only semantics (def/async def trim, indentation suppression). Promoting them to analysis::diff would leak Python-specific rules into the diff model. classify.rs is the sole caller, so colocating avoids a cross-module dep and keeps the diff layer language-agnostic, matching the established pattern for lines_look_alike's Python guards.
- Annotation-only guard now requires same_indentation, which uses char.is_whitespace() and compares leading-char sequences verbatim.
Parked follow-ups
- ledger/init.py and tests/init.py retained_files both list the empty-file sha256 e3b0c44…b855; the corpus contract cannot distinguish present-empty from absent in diffs. Not a correctness issue today but worth a contract clarification follow-up.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
…ved by #6670 #6670 (an inequality is never an exact oracle) merged after #7572 added oracle-kind fields to the rows and did not re-bless them, so main's verdict-corpus check fails. The assert_ne/ensure/helper rows now read relational_check, and the assert_ne struct-literal row reads weak, an overclaim that becomes a match. Rust false verdicts 47 -> 46. No-op once main carries the same re-bless. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U7GbrVC98fTYnLnhe3vhFM
|
Cause. #6670 ("an inequality is never an exact oracle") landed on main after #7572 added oracle-kind fields to the rows, and the rows were never re-blessed. This PR touches only the Python adapter. The drift reproduces on current main merged in. Ported fix in
The re-bless is a no-op once main carries it. Re-validated on
Toggling Draft→Ready to re-run the required check. Generated by Claude Code |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
Refuted
- ship a CI receipt showing post-merge cargo xtask verdict-corpus check-all exit 0 and the 6/68 to 7/68 false verdict delta is held.; refuted because: Author labeled at ripr_commit=3eef453 with full_checkout_classifications matching expected rows; the follow-up review thread from EffortlessSteven documents the post-merge rust re-bless (b85722a) and that the re-bless is a no-op once main carries it. Receipt lives outside this PR's diff but its effect is captured in row counts.
- is_python_declaration_line/same_indentation should be promoted to analysis::diff next to lines_look_alike; refuted because: classify.rs is the only caller; rules encode Python-specific semantics (def/async def/class/@, indentation-only-suppresses-annotation). Colocation avoids cross-module dep and keeps rules with semantics. EffortlessSteven review of record agrees.
- same_indentation using is_whitespace() could match tabs and spaces interchangeably and flip annotation-only verdicts on mixed-indent files.; refuted because: Helper compares prefix strings character-by-character after take_while(c.is_whitespace()); unequal prefix strings do not match. Mixed sequences that happen to share the same Unicode scalar sequence will match, others will not. Behavior is deterministic.
Parked follow-ups
- Delete-statement carriers (#7587) remain a parked follow-up; this PR does not claim them. Within its own scope the diff is internally consistent.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
|
Rust gates on b85722a failed in one xtask test: Fix: merged main as 65d3e9f. The Rust corpus rows now match main byte for byte. Local results on 65d3e9f:
I re-toggled Ready for the required check. The review dimensions are unchanged: there are no production or test edits beyond the main merge. Generated by Claude Code |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- No other Python old-line readers were observed in the changed surfaces; consolidation appears complete. Residual risk: future readers added outside this PR could re-introduce coordinate-only pairing.
Verification questions
- Confirm classification guards (annotation-only def, annotation-only var, new-declaration) all read old_line_text and now apply indentation-equality and declaration-line checks before suppressing; failures move to the look-alike rule from analysis::diff, matching TypeScript's posture.
- Confirm effortlessSteven merged main (65d3e9f) after a Rust spec0231 drift that reproduced on current main, blaming #6670 oracle-kind fields, not this PR. Reviewers should not reintroduce the 5 rust rows or re-bless them on a branch pending another capability.
Parked follow-ups
- Authored subject authored-py-pytest-blocks retains init.py files whose sha256 is the empty-file hash; manifest cannot distinguish present-empty from absent in diffs. Not a correctness issue for this PR but worth noting for downstream tooling contract.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
Summary
Before: in a Python replacement block, only the first added line found its old line. When a clamp went into
returnunder a rewritten comment, every token on the return read as changed. A test that only observed the unchanged operand (_balance) then earned a falseexposed.After: the Python adapter reads every old line from
ChangedFile::aligned_counterparts(#7524/#7554). Even blocks pair by position, uneven blocks by content, and interrupted runs by coordinate. The same clamp readsweakly_exposedwhether it is a one-line edit or the second line of a block.How:
python.rscomputes the counterparts once per file. The sink delta, the docstring check and the added-import check all read from them.classify.rsnow treats adefas changed only when its paired old line looks like it (lines_look_alike). This is the same rule TypeScript uses: a newdefpaired by position with an unrelated old line stays unprobed, and a renamed header keeps its probe.ifblock is behavior.Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Governing issue or accepted claim: #7556
Acceptance delta (one sentence): a changed Python line inside a multi-line replacement block is judged against its own old line.
Candidate Relationships
Candidate branch:
claude/project-thread-svy0f3Stack parent or prerequisite PR: #7554 (merged; supplies
aligned_counterparts)Scope Classification
Production delta:
Evidence/support delta:
authored-py-pytest-blockswith three cases, labeled by running pytest on each edit:py-blocks-account-clamp-second-line: the target. The clamp survives, so truth is not_discriminated. Main read it as credited/exposed (a false verdict).py-blocks-account-clamp-one-line: the one-line control. Reads gap/weakly_exposed on main and on this PR.py-blocks-wallet-clamp-second-line: the discriminating control. The clamp is killed. Reads credited/exposed on main and on this PR.python/replaced_block_tests.rs.Non-goals: deleted-statement carrier tracking in uneven blocks (filed as #7587).
Proof
py-blocks-account-clamp-second-line, which goes from credited/exposed/false_exposed to gap/weakly_exposed/ideal. Python false verdicts on the merged tree: 6/68. Without this fix it would be 7/68.old_line_text.is_none()in the new-declaration guard fails the new-def test;Claim Boundary
This PR claims that Python later-line pairing matches TypeScript's. It makes no claim about deleted-line carriers (#7587).
Rollback
Revert the squash commit. The corpus row then returns to credited (false), and the controls are unaffected.
Static Language Check
killed,survived,untested,proven, andadequate.Engineering Check
panic,unwrap,expect,todo, orunimplementedin production code.panic,unwrap,expect,todo, orunimplementedin tests.🤖 Generated with Claude Code
https://claude.ai/code/session_01U7GbrVC98fTYnLnhe3vhFM
Generated by Claude Code