Skip to content

fix(python): abstain on pytest.approx bands and caplog.text membership - #9544

Merged
EffortlessSteven merged 9 commits into
mainfrom
claude/py-oracle-caplog-approx
Oct 22, 2026
Merged

EffortlessSteven merged 9 commits into
mainfrom
claude/py-oracle-caplog-approx

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Source-of-truth Links

Spec: RIPR-SPEC-0238
Governing issue or accepted claim: #9412 (closes #9424, closes #9428)
Acceptance delta (one sentence): Python approx-band and caplog.text membership checks no longer produce false weak-gap verdicts.

Scope

  • Analyzer (python/static_limits.rs), unit tests, spec rules 21/22, four corpus rows, one golden, changelog fragment. cargo xtask precommit and verdict-corpus check-all pass on this head.

Generated by Claude Code


Devin Review

#9424, #9428)

A pytest.approx call with an explicit rel/abs band, and an `in caplog.text`
check on the changed log call, now abstain with static_unknown
(unsupported_syntax) instead of reading a weak gap. RIPR-SPEC-0238 rules 21
and 22. Four idioms corpus rows and the python_pytest_oracle_shapes golden
move with stated reasons.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TJm1ic5tVeaxnwQM8c6xmr
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 52 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 107 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 438d9936-10de-4162-b28e-0495aa87cc13
📥 Commits

Reviewing files that changed from the base of the PR and between cc069d3 and 012d5c5.

📒 Files selected for processing: 16
  • changelog.d/9428-python-approx-caplog-abstain.md
  • crates/ripr/src/analysis/language/python/static_limits.rs
  • crates/ripr/src/analysis/language/python/tests.rs
  • crates/ripr/src/output/gap_decision_ledger.rs
  • docs/specs/RIPR-SPEC-0238-python-oracle-and-reach-rules.md
  • fixtures/python-verdict-corpus/expected/rows/py-idioms-approx-constant-outside-tolerance.json
  • fixtures/python-verdict-corpus/expected/rows/py-idioms-approx-constant-within-tolerance.json
  • fixtures/python-verdict-corpus/expected/rows/py-idioms-caplog-level.json
  • fixtures/python-verdict-corpus/expected/rows/py-idioms-caplog-message.json
  • fixtures/python-verdict-corpus/known-false/py-idioms-approx-constant-within-tolerance.toml
  • fixtures/python-verdict-corpus/known-false/py-idioms-caplog-level.toml
  • fixtures/python-verdict-corpus/known-false/py-idioms-caplog-message.toml
  • fixtures/python_pytest_oracle_shapes/SPEC.md
  • fixtures/python_pytest_oracle_shapes/expected/CHANGELOG.md
  • fixtures/python_pytest_oracle_shapes/expected/check.json
  • fixtures/python_pytest_oracle_shapes/expected/human.txt
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 3 potential issues.

Devin Review

…ng approx spreads

Review findings on #9544: the caplog word overlap read the whole assertion, so
scaffolding words (assert, text) could trigger an abstention; a spread in the
first position of pytest.approx now counts as a possible band. The repair-card
inventory pin drops from 27 to 26 because the abstained caplog finding no
longer carries a card.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TJm1ic5tVeaxnwQM8c6xmr

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Decision

  • Needs one verification check before upstream.

Verification questions

  • Confirm focused coverage does not establish that all equivalent approx/caplog syntaxes traverse the newly matched routes; unusual attribute, qualified-call, multiline, or membership-expression variants remain a parser-coverage risk.

Refuted

  • Adding the two limits inside static_limit_for_focused_change duplicates evaluation across unrelated_candidates loops and risks redundant work; refuted because: each limit is gated by distinct, narrow conditions (digit presence + approx band; logging-call literal + caplog overlap), and the new code reuses select_relevant_assertion rather than re-walking candidates. No duplication beyond the unavoidable per-candidate filter pattern already in the file.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.
  • No cargo-test receipt yet (ripr sensor failed exit 2, cargo-test scheduled-late); the new rules' behavior is only proven by in-tree unit tests, not the integration corpus suite.

Copy link
Copy Markdown
Member Author

Review of record, head 28da2ed

Angles: (1) correctness and edge cases, (2) spec and test grip, (3) bot findings (Devin x3, github-actions verification question).

Findings and resolutions

  • caplog word overlap read the whole assertion, so assert / text counted as overlap. Found independently by the reviewer agent and Devin. Fixed in 28da2ed: only the checked literal, past the assert keyword, supplies words; added a control (assert text: %s changed message vs. "payment accepted" check keeps its verdict). Byte vs. character length also fixed.
  • Leading */** spread in approx(...) was skipped as the expected value. Real. Fixed; tests added for both shapes.
  • nan_ok=True counted as a band. Does not reproduce (only rel/abs with a non-None value count); pinned with a default-tolerance control that must stay Exposed.
  • CI Ripr Rust Small lib failure on c982232 was the repair-card inventory pin (27 to 26: the abstained caplog finding no longer carries a card). Fixed with a comment in the pin; full cargo test -p ripr --lib and cargo xtask precommit pass locally, and Rust-only feature lane is green on 28da2ed.
  • Verification question on syntax variants: approx is matched identifier-bounded as bare or attribute call (approx(, pytest.approx(), arguments split at top level so multi-line calls are covered; caplog matches the <literal> in caplog.text form after assert. A variant these do not match keeps its pre-change verdict (no new abstention, no new credit), so the risk is a missed abstention, not a wrong one. caplog.messages / caplog.records and tolerance/format evaluation are tracked in python: credit caplog message edits and evaluate approx tolerance instead of abstaining #9546.

Not blocking: a digit anywhere in the changed line (identifier, string) plus an approx band abstains on a non-numeric edit. Fail-open, noted in the rule.

Result: no blocking findings remain. Merging on green Ripr Rust Small Result for this head.


Generated by Claude Code

Resolves the python_pytest_oracle_shapes golden conflict with #9055 (typed miss
rows): CHANGELOG keeps both entries, check.json and human.txt are re-blessed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TJm1ic5tVeaxnwQM8c6xmr
…/caplog abstentions (#9424, #9428)

Merges main (#9446 ledger) and removes py-idioms-caplog-message,
py-idioms-caplog-level and py-idioms-approx-constant-within-tolerance, which
are no longer false verdicts on this head.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TJm1ic5tVeaxnwQM8c6xmr

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • Sensor evidence is thin: ripr failed exit 2, cargo-test scheduled-late, no in-tree integration corpus receipt yet. The PR body claims verdict-corpus check-all and cargo xtask precommit pass on head, but the UB packet only shows tokmd + ast-grep receipts.
  • approx_call_has_band and changed_logging_call_literal each have one consumer in static_limits.rs; sibling routes (parameterized fixtures, asyncio, numpy.testing approx) are not enumerated. Rule text in RIPR-SP-0238 says "not read by this rule" for caplog.records/messages, but no other scope-test asserts the boundary.
  • crates/ripr/src/analysis/language/python/static_limits.rs:772 — changed_logging_call_literal slices to the first matching quote; an f-string "text {x}" or ("a", "b") tuple is not the adapter's stated scope but a log literal containing a stray apostrophe "it's done" would truncate. Cheap to gate the call on the literal not containing an unmatched quote before storing, or skip when body.find(quote) is None.

Verification questions

  • Confirm caplog rule restricts to one literal per call; multi-line f-strings or concatenated literals fall through body.find(quote) on first quote — plausible scope gap.
  • Confirm equivalent approx/caplog syntax coverage is not established beyond the displayed unit and corpus cases; unusual multiline, qualified, or membership-expression forms remain parser risk.
  • Confirm focused unit tests cover explicit-rel/abs, positional 2nd arg, *spread, **spread, default tolerance, nan_ok, exact equality, overlapping caplog word, unrelated caplog text, and a scaffolding-word control. However, devin's verification question about qualified-call (np.testing.approx) and multiline-attribute call shapes is not directly exercised; the existing call_arglists_with_offsets helper has limited parser coverage.
  • Confirm fixtures/python-verdict-corpus/expected/rows/py-idioms-approx-constant-outside-tolerance.json:0 — The corpus row now marks outcome=abstained for a row whose truth=discriminated, ideal_verdict=credited. The pre-PR row was already marked ideal; the move to abstained drops one credited reading. Confirm verdict-corpus check-all is green and that the abstained bucket is allowed for this case, since the prior outcome=ideal is replaced by an abstention rather than a credited finding.

Refuted

  • Adding the two limits inside static_limit_for_focused_change duplicates evaluation across unrelated_candidates loops and risks redundant work or duplicate verdicts.; refuted because: Each limit is gated by distinct, narrow conditions (digit presence + approx band; logging literal + caplog overlap) and reuses select_relevant_assertion rather than re-walking candidates. No duplication beyond the per-candidate filter pattern already in the file.

Parked follow-ups

  • Word-overlap heuristic in rule 22 only matches alphanumeric tokens >=3 chars; %-formatted parameter substitutions that share a substring (not a word) with the assertion literal will not trip the limit and will keep the old (weak) verdict until #9412 lands.

Evidence gaps

  • ripr sensor failed exit 2 on this head; cargo-test is scheduled-late only. The new rules are proven by in-tree unit tests, not the verdict-corpus integration suite, so the corpus row changes are asserted but not freshly executed by this packet.
  • Model proof intent was rejected by deterministic validation.

Copy link
Copy Markdown
Member Author

Response to the github-actions review on c1dc4a4, finding by finding.

  • Stray apostrophe truncation: does not reproduce for the cited shape. changed_logging_call_literal takes the first quote character of either kind and closes on that same character, so "it's done" is read whole. A single-quoted literal containing an escaped quote ('it\'s') yields a shorter prefix, which has fewer words to overlap and can only reduce an abstention, never add one or add credit. Same for f-strings and concatenations: they shorten the literal, fail-open.
  • py-idioms-approx-constant-outside-tolerance now abstained instead of credited: intended. The adapter does not evaluate the approx band, so it cannot tell the outside-tolerance edit from the within-tolerance one (whose old reading was a false exposed). Abstention is inside the row's acceptable set; ideal remains credited, and evaluating the band is python: credit caplog message edits and evaluate approx tolerance instead of abstaining #9546.
  • Corpus not freshly executed by the packet: cargo xtask verdict-corpus check-all exits 0 (4 corpora checked) on this exact head after merging main (chore(corpus): reconcile all known_false drift on main (#9430) #9588), and cargo xtask precommit passes; Rust-only feature lane is green on c1dc4a4. The required Ripr Rust Small Result is still running.
  • Qualified and multi-line call shapes, numpy.testing, caplog.messages/records: not exercised beyond the existing cases, as noted in the review of record. An unmatched shape keeps its previous verdict, so the exposure is a missed abstention, tracked in python: credit caplog message edits and evaluate approx tolerance instead of abstaining #9546.

No change needed on this head.


Generated by Claude Code

Resolves the repair-card inventory pin against #9429 (direct 8, no-strong 26 with
the caplog finding now abstained) and the Python known_false ledger against
#9550/#9583 (keeps main's list minus the three rows fixed here).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TJm1ic5tVeaxnwQM8c6xmr

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • Ripgrep coverage of in caplog.text in the new rule text is single-pattern: split_once(" in caplog.text") will miss assert "x" in caplog.text (multi-space), assert ("x" in caplog.text), or assert "x" in caplog.text, "msg" (pytest assertion rewrite + message). Out-of-scope for rule 22 per spec, but the spec does not enumerate variants, so future corpus rows with rewritten messages may silently fall back to weakly_exposed.

Verification questions

  • Confirm changed_logging_call_literal's first-quote slice is a parser-coverage gap (stray apostrophe, f-string body, tuple log arg). It can only shorten a literal -> fewer words -> fewer abstentions, never the reverse, so the rule is fail-open by construction. The caplog gate's evidence-side risk is bounded.
  • Confirm the approx band rule is gated on trimmed.chars().any(is_ascii_digit) so non-numeric edits never spuriously abstains; the caplog arm is gated on changed_logging_call_literal returning Some, so only true logging calls trigger.

Evidence gaps

  • No in-tree integration corpus (verdict-corpus check-all) receipt in the UB packet; ripr sensor failed exit 2, cargo-test scheduled-late. The PR body's claim that the corpus and precommit pass on head is unverified by the lane receipts.
  • Model proof intent was rejected by deterministic validation.
  • Sensor evidence is thin: ripr exit 2, cargo-test scheduled-late; rules proven only by in-tree unit tests, not the integration verdict-corpus receipt in this packet.

Python known_false list: keep main's entries minus the three py-idioms rows fixed here.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TJm1ic5tVeaxnwQM8c6xmr

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Decision

  • Needs verification checks before upstream.

Verification questions

  • Confirm the caplog route matches only the literal byte-normalized substring " in caplog.text", so equivalent assertion layouts can bypass rule 22.
  • Confirm the caplog route recognizes only an exact one-space in caplog.text suffix, so equivalent asserted syntax can miss the typed limit.

Evidence gaps

  • The PR packet lacks a successful deterministic cargo-test/corpus receipt despite changed Rust behavior and expected JSON goldens.
  • Model proof intent was rejected by deterministic validation.
  • Current-head integration proof is still absent from the packet despite the PR claiming precommit and corpus checks pass.
  • The packet has no fresh cargo-test receipt; ripr itself failed with exit 2.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • The rule misses semantically equivalent membership layouts because split_once(" in caplog.text") requires one exact space sequence and the selected assertion is already reduced to gate text. A multiline or parenthesized assertion can retain the false weak-gap verdict this change is meant to eliminate. Parse/normalize the checked expression and receiver, or explicitly document/test that these layouts are unsupported and ensure they abstain or are excluded from rule 22. (crates/ripr/src/analysis/language/python/static_limits.rs:789).

Verification questions

  • Confirm caplog matching recognizes only an exact in caplog.text substring; multiline, parenthesized, or extra-whitespace layouts can still fall through to the old weak-gap verdict.
  • Confirm focused tests do not enumerate equivalent caplog membership layouts or multiline/qualified logging-call forms; these remain bounded syntax-route coverage risks.
  • Confirm caplog recognition is an exact substring route ( in caplog.text) and logging literals use first-quote slicing; valid equivalent layouts may bypass rule 22, while malformed/complex literals fail open rather than over-abstain.
  • Confirm approx recognition delegates to call_arglists_with_offsets for bare/qualified attribute forms, but no broad sibling-route coverage demonstrates equivalent multiline or alternate call spellings consistently reach rule 21.
  • Confirm caplog.text recognition requires the exact substring " in caplog.text", so equivalent spacing, parenthesization, or assertion-message layouts bypass the typed abstention.

Refuted

  • Adding approx and caplog limits in static_limit_for_focused_change duplicates evaluation across unrelated_candidate loops.; refuted because: The two checks are mutually independent, share the already-selected candidate/focus inputs, and each returns immediately with a distinct limit; no new repeated candidate traversal is introduced.

Parked follow-ups

  • Exact textual recognition of in caplog.text is intentionally narrower than equivalent Python layouts; this is residual parser-coverage risk rather than a smaller-complete-fix violation in the stated rule.

Evidence gaps

  • Changed Rust behavior and corpus expectations lack a completed current-packet cargo-test receipt; ripr exited 2.
  • Model proof intent was rejected by deterministic validation.
  • The PR's claimed integration proof is not established by this packet: ripr failed with exit 2 and cargo-test was only scheduled-late.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants