Skip to content

fix(python): withhold probe for no-op class-header (object) edit - #11941

Closed
EffortlessSteven wants to merge 2 commits into
mainfrom
claude/fix-11888
Closed

EffortlessSteven wants to merge 2 commits into
mainfrom
claude/fix-11888

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Governing issue or accepted claim: #11888

Acceptance delta (one sentence): a Python class X(object): <-> class X: header edit no longer produces a probe (so no false exposed), while any other base/metaclass change keeps its probe.

Adds is_noop_class_header_change (closed allow-list: same name, single-line headers, sole bare object base vs no bases) in python/no_behavior.rs, wired in classify.rs beside the def-header annotation guard. Unit tests: issue repro yields no finding; Base->Other still probes; object, Base vs Base, Base, object, metaclass, rename, multi-line are not no-ops.

Proof: cargo xtask precommit pass; python lib tests 1707 pass, 1 pre-existing unrelated failure (compare_literal_values_fails_open_on_undecoded_literals, numeric literal compare; not touched here).


Generated by Claude Code

…11888)

`class X(object):` <-> `class X:` has no Python 3 behavior delta; add a
closed allow-list guard beside the def-header annotation guard. Other base,
multi-base and metaclass changes keep their probe.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVdGzQvtpKrgEnbdSoyCd8
@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 31, 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 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 150 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: fdc6cfd5-19d7-45ed-aad7-43431bf83a96
Commits

Reviewing files that changed from the base of the PR and between 56444f1 and f427a7c.

Files selected for processing: 5
  • changelog.d/11888-python-noop-class-header.md
  • crates/ripr/src/analysis/language/python.rs
  • crates/ripr/src/analysis/language/python/classify.rs
  • crates/ripr/src/analysis/language/python/no_behavior.rs
  • crates/ripr/src/analysis/language/python/tests.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 31, 2026 22:31
@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!

Copy link
Copy Markdown
Member Author

Independent review of head aeb89ab (diff/source reading, no blockers): the guard accepts only a one-line header where both sides share the name and indentation and exactly one side has a sole bare object base; (object, Base), metaclass, trailing-comma, comments and multi-line headers all fail closed, and suppression is per changed header line so body edits in the same hunk keep their probes. Local: cargo xtask precommit exit 0, new class-header tests pass. The full Python lib run had one failure, guard_activation::tests::compare_literal_values_fails_open_on_undecoded_literals, outside this diff and not re-checked on main. Non-blocking follow-ups noted, not done here: an end-to-end python_noop_* fixture, a same-hunk body-edit test, and class X(): / trailing-comma cases in the conservative test. A module that rebinds the name object is a theoretical gap.


Generated by Claude Code

@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.

Confirmed findings

  • A module that rebinds object could make class X(object): semantically different from class X:, while the new guard suppresses the probe.

Verification questions

  • Confirm only the direct classifier route was established; the packet does not prove that every public/sibling Python entry point reaches the new guard.
  • Confirm the negative controls prove that common base and metaclass changes retain probes, but they do not directly exercise a same-hunk class-body edit.
  • Confirm the direct tests exercise the advertised no-op, a changed-base negative control, and conservative variants including multiple bases, metaclass, rename, and malformed syntax.
  • Confirm the parser and classifier tests cover the intended allow-list, but no end-to-end fixture demonstrates the claimed exposed suppression through the public analysis route.
  • Confirm the tests do not cover a same-hunk class-body edit, so they cannot detect a future guard that suppresses probes for unrelated body changes in the class header's hunk.
  • Confirm the conservative parser tests omit class X(): and trailing-comma forms, leaving ambiguity about whether these syntactic variants should be treated as no-ops or fail closed.
  • Confirm the implementation does not cover related Python no-op forms such as class X(): versus class X:, trailing-comma variants, or same-hunk body edits; the seeded thread records these as follow-ups rather than current blockers.
  • Confirm the new classifier test asserts the no-op header yields no finding, but does not assert that the old classifier would have yielded a finding.

Evidence gaps

  • No cargo-test completion receipt is present in the supplied evidence, leaving the claimed focused behavior without an available late-phase witness.
  • Model proof intent was rejected by deterministic validation.

Parked follow-ups

  • The new helper recognizes only one-line class headers and rejects multi-base, metaclass, renamed, and malformed forms; these cases remain probe-bearing rather than being broadly suppressed.

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Independent review (fresh-context reviewer, head f427a7c): REPAIR_REQUIRED

Inspected:

  • Subject: PR #11941, head f427a7c74dd04c6162086ead478fa9e615aa0c4d, base 56444f1605fa1431054375f9b232c37f72ede436, 5 files, +137/-1. Governed by issue #11888.
  • Cluster for #11888: three PRs claim it. #11932 is merged (merge commit 62a2c41cb3b6635b1d86f5948307c10286a53998, merged_at 2026-10-31T23:17:27Z, body "Closes #11888"). #11941 is this PR. #11933 is open.
  • Semantic owner: crates/ripr/src/analysis/language/python/classify.rs (the probe-suppression guard stack, lines 255-322) and crates/ripr/src/analysis/language/python/no_behavior.rs.

Blocking:

  1. The governing issue is already delivered, and this PR's base contains the delivery. #11932 landed is_object_base_only_class_change (no_behavior.rs:303) and wired it into is_annotation_only_def_change (no_behavior.rs:363-377). compare 62a2c41c...56444f16 reports status=ahead, ahead=21, behind=0, so 62a2c41c is an ancestor of this PR's base. #11932's own acceptance delta already covers this claim's scope and more: "a single-line class header change that only toggles the legacy object base or empty ()". What this PR proposes is a second implementation of behavior already on main, and the repo rule is explicit that upstream delivery wins over duplicate conflict work.
  2. The new guard cannot change any outcome: it is unreachable. classify.rs:301-306 (is_noop_class_header_change) is evaluated after classify.rs:293-298 (is_annotation_only_def_change), and the two carry identical preconditions - old_line_text is Some and same_indentation(old, line_text). The earlier predicate returns true first for every input the new one accepts, because is_annotation_only_def_change now begins with if is_object_base_only_class_change(old_line, new_line) { return true; } (no_behavior.rs:364-366). The merged recognizer is a strict superset of the new one: it also accepts class X(): <-> class X: through empty_parens_class_header_only_change (no_behavior.rs:332-351), and it parses the header with rustpython_parser (legacy_class_header_shape, no_behavior.rs:271) instead of scanning it as text (class_header_parts, no_behavior.rs:382). I walked the new recognizer's accepted set against the merged one: class X(object): <-> class X:, the reverse, and every spelling the text scanner admits are all accepted by the merged parser too; the merged parser additionally accepts class X (object):, class X(object): with a trailing space, and a digit-leading or Unicode class name, all of which the text scanner rejects. The only production caller of the new predicate is classify.rs:303, so no input reaches it with a true result.
  3. No test in this PR discriminates this PR's change. noop_class_header_object_base_emits_no_probe asserts finding.is_none() for class X(object): -> class X:; the merged guard already produces None, so the assertion holds identically with the new code removed. changed_class_base_still_gets_a_probe likewise passes without the change. noop_class_header_detection_is_conservative calls the helper directly, so it would still pass if the helper were never called from the production path. The product contract asks whether the current tests contain a discriminator that would notice if the changed behavior were wrong; here no test distinguishes "the new guard works" from "the new guard is absent", because the merged guard produces the same outcome for every case.

Cluster disposition - survivor: #11932 (merged). #11941 is a redundant, unreachable second guard. #11933 is not viable at its head: crates/ripr/src/analysis/language/python/no_behavior.rs defines is_object_base_only_class_change twice in the same module, once at line 303 (the merged #11932 version, private fn) and again at line 446 (pub(super) fn). I read both definitions at that head, and hosted CI confirms it independently: error[E0428]: the name is_object_base_only_class_change is defined multiple times plus error[E0603]: function is_object_base_only_class_change is private, on ubuntu, windows, macos and the Linux wheel build (jobs 124692412209, 124692412358, 124692412483, 124692540347 of runs 41253737066 and 41253733970). It reports mergeable_state=blocked. Recommended action: close #11941 and #11933 as duplicates of merged #11932 rather than repairing either.

Non-blocking:

  • No spec amendment and no traceability registration. The three new test functions in crates/ripr/src/analysis/language/python/tests.rs are absent from .ripr/traceability.toml, so the new discriminator is unlinked from the spec that owns the behavior. The sibling #11933's body states it carries a "RIPR-SPEC-0028 amendment, traceability rows, changelog fragment"; this PR carries only the changelog fragment.
  • The changelog fragment announces a fix main already has. #11932 merged without one, so there is no duplicate-file collision, but landing this fragment would publish a second entry for behavior that shipped in #11932.
  • Undisclosed false-negative limit: neither recognizer checks that object is the builtin rather than a module-local rebinding, so class X(object): where object is a user-defined class is treated as a no-op although it changes the base class. This PR's body has no "Known limits" section and does not mention it; #11933 discloses it explicitly.
  • PR body / hosted-evidence mismatch: the body's "Proof" line reports the failure set as one python-lib failure (compare_literal_values_fails_open_on_undecoded_literals). The hosted lane at this head fails three different tests and none of them is that one. A reader of the body alone would not know what is red at this head.
  • Efficiency: neutral for this PR. class_header_parts scans one header line with two split_once substrings; is_noop_class_header_change short-circuits on the first failed parse; it is evaluated at most once per candidate line, and only after the earlier guard has already returned for most inputs. No new I/O, no process spawning, no cache added, invalidated or mis-keyed, no collection growth, and no previously short-circuited computation is now always run. For contrast the merged recognizer is the heavier one - it invokes rustpython_parser twice per candidate header - but that cost is main's, not this PR's.
  • Corroborates the github-actions[bot] COMMENTED review at aeb89ab5 on the general shape; the bot's questions do not reach the merged-#11932 overlap, which is the finding that decides this PR.

Not run:

  • No Rust toolchain on this host (rustc, cargo, rustup are absent from PATH). cargo xtask precommit, cargo test -p ripr --lib and cargo xtask check-traceability were not executed and no local Rust receipt is claimed. The reachability argument is established by reading source at this head - guard order and preconditions in classify.rs, the first statement of is_annotation_only_def_change, and both recognizer bodies - not by execution.
  • Hosted Rust gates at this exact head are still in progress: "Merge-ready request f427a7c" (run 41252215727), job "Ripr Rust Small on GitHub Hosted / Rust gates" (id 124688659733). No superseded run was read as this head's result.
  • The "CI" workflow at this head is red, and the red is inherited from the base. Attribution rests on a base comparison plus a direct source-level chain:
    • -p ripr --test cli_smoke: check_worktree_drill_in_commands_reach_the_uncommitted_finding and selector_location_misses_explain_syntax_and_preserve_retry_scope. The base commit itself - 56444f1, "fix(explain): suggest check --format json in selector hints (#11570 item 4) (#11844)" - changed the explain hint from --json to --format json in crates/ripr/src/app/explain.rs and did not update crates/ripr/tests/cli_smoke.rs, which pins the old spelling. The observed message carries --format json where the test expects --json.
    • -p ripr --lib: lsp::backend::list_actionable_items_tests::list_actionable_items_names_gaps_the_actionable_profile_hides fails on an exact ordering assertion - left: ["probe:pricing:94:predicate", "probe:pricing:98:predicate"] against the expected ["probe:pricing:98:predicate", "probe:pricing:94:predicate"]. The list order comes from canonical_group_members in crates/ripr/src/lsp/diagnostics.rs, whose bucket keys are canonical:, raw: and - added by main commit 927e92a, "fix(lsp): collapse same-site gap diagnostics with one missing discriminator (#11796) (#11862)" - site-missing:. 927e92a is an ancestor of this PR's base (compare 927e92aeb...56444f16 gives ahead=5, behind=0) and is not an ancestor of 3229707, where the same test passed in a completed green run (job 124679977754 of PR #11823's CI run 41249542061). This PR touches no lsp/ and no app/ file.
    • The base push run for 56444f1 (CI id 41252096978) was cancelled before any job reported, so there is no green base lane to compare against directly; the attribution rests on the source-level chain above plus the green run at ca39083.
  • The parse behaviour of rustpython_parser on the header spellings was not executed here; the recognizer comparison is from reading the merged implementation at the base.

Reviewed by an independent Mavis review agent on behalf of the maintainer; bound to head f427a7c74dd04c6162086ead478fa9e615aa0c4d. Not an approval.

Copy link
Copy Markdown
Member Author

Closing as superseded: #11932 (merged 62a2c41) already delivers #11888, with a strict superset recognizer. This PR's guard is unreachable behind it and its tests don't discriminate. The independent review's finding is verified.


Generated by Claude Code

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants