Skip to content

fix(python): read for/with/comprehension targets as a builtins-module rebinding (#12591) - #12702

Merged
EffortlessSteven merged 2 commits into
mainfrom
fix-12591-py-for-with-rebind
Nov 3, 2026
Merged

EffortlessSteven merged 2 commits into
mainfrom
fix-12591-py-for-with-rebind

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Governing issue or accepted claim: #12591
Acceptance delta (one sentence): A Python isinstance guard now reads as unknown (fail-closed) when a for, with ... as or comprehension target rebinds a builtin through the builtins module, while plain for x in items: / with ctx() as x: still leave it readable.

Adds binds_in_header beside rebinds_target in arm_activation.rs, positive and discriminating-negative controls in guard_atoms_tests.rs, the RIPR-SPEC-0260 rebinding rule extended, and a changelog fragment. Persisted facts are unchanged, so PYTHON_FILE_FACT_SCHEMA_VERSION is not bumped.

Closes #12591


Generated by Claude Code

… rebinding (#12591)

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

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 147 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: 8b0f32ca-2b23-450a-9f64-45419a98d0fc
Commits

Reviewing files that changed from the base of the PR and between 16233a1 and 650186a.

Files selected for processing: 4
  • changelog.d/12591-for-with-builtin-rebind-guard.md
  • crates/ripr/src/analysis/language/python/arm_activation.rs
  • crates/ripr/src/analysis/language/python/guard_atoms_tests.rs
  • docs/specs/RIPR-SPEC-0260-python-guarded-arm-activation.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review November 2, 2026 20:03
@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

Review of record, head 7a10f90 (full diff read: 4 files, +159/-10)

Angles: semantic owner, fail-closed direction, test stimulus/oracle, spec/public claim, schema.

  • Owner: the change lives in arm_activation.rs beside rebinds_target/patches_builtin, the existing owner of builtins-module rebinding. No parallel validator.
  • Direction: binds_in_header can only add "rebinding" reads, so a false positive degrades a guard to unknown (fail-closed). Strings are masked, so a for/as inside a literal is not read. word_at rejects .for/x_for forms. as is only read when the statement also has a standalone with, so import x as y is not read.
  • Targets: for ends at depth-0 in; with ... as ends at depth-0 , or : or the enclosing close bracket, covering the parenthesized multi-item form and tuple targets. Comprehension clauses, async for, spaced b . isinstance and b['isinstance'] are covered.
  • Oracle: 14 positive controls and 9 discriminating negatives (plain targets, attribute only read in the iterable/context expression/condition/string, import ... as). Positives and negatives share the same owner builder, so the assertion distinguishes by the target alone.
  • Claim and schema: SPEC-0260 rule extended in the same sentence; changelog fragment present; persisted facts unchanged, so no schema bump.

No blocking findings. Hosted proof is requested by merge-ready; I merge only on a green Ripr Rust Small Result on this exact head.


Generated by Claude Code

Copy link
Copy Markdown
Member Author

Ripr Rust Small Result failed on 7a10f90 because test shard 1 of 4 died at 21:16Z (no logs retained, the job hung in "Complete job"), which then failed verify. Shards 2–4, gates, doctests and PR evidence passed. That reads as a runner loss rather than a test failure, so I re-ran the failed jobs once. I'll merge only if the Result is green on this exact head.


Generated by Claude Code

Copy link
Copy Markdown
Member Author

Delta review of record, head 650186a (previous review: 7a10f90)

The only change is a merge of current main (16233a1), which brings in the shard-build memory fix #12704 (be9d00d). Test shard 1 had been killed three times by runner shutdown (exit 143) at the xtask compile on the old base. The PR's own diff is unchanged: the same 4 files, +159/-10, compared file by file against the reviewed head. The earlier review's findings and conclusion carry over; no production, test, spec or schema dimension moved. Requesting a fresh merge-ready run on this head.


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.

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • The security-relevant behavior is fail-closed: recognizing a builtins-module rebinding makes the isinstance guard unknown rather than granting credit.

Verification questions

  • Confirm the suite lacks a negative control where the builtin attribute appears in the target position but is not a store slot, so it may not discriminate binding from incidental target text.
  • Confirm the changed detection path covers for, with-as, and comprehension targets through a shared binds_in_header helper.
  • Confirm the implementation identifies header targets textually and does not use a Python parser, leaving unusual but valid store forms outside the demonstrated scope.

Evidence gaps

  • Completed execution evidence for the modified Rust analysis path is not available in this review packet.
  • Model proof intent was rejected by deterministic validation.
  • The ripr sensor failed with exit code 2 and the cargo-test receipt remains absent, leaving red/green execution unconfirmed.
  • Completion evidence for the new Rust tests is unavailable because the scheduled cargo-test receipt is absent.
  • The exact-head runtime oracle remains incomplete because the ripr sensor failed and the late cargo-test receipt is absent.

@EffortlessSteven
EffortlessSteven merged commit 45b0245 into main Nov 3, 2026
70 checks passed
@EffortlessSteven
EffortlessSteven deleted the fix-12591-py-for-with-rebind branch November 3, 2026 01:17
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.

Python guard reader: for/with targets that rebind a builtins-module attribute are not read as a rebinding

1 participant