Skip to content

fix(python): withhold a module-object write whose test rebinds the module namespace - #10325

Merged
EffortlessSteven merged 3 commits into
mainfrom
claude/project-thread-9z5l8r
Oct 25, 2026
Merged

EffortlessSteven merged 3 commits into
mainfrom
claude/project-thread-9z5l8r

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • A module-object field write whose related test imports the object from the owner's module and reloads the module or replaces its names (importlib.reload, setattr, __setattr__, delattr, attribute assignment) now reads static_unknown with a mocked_module static limit, like patch does. Before, fix(python): treat reload, __setattr__ and delattr as dynamic namespace writers #10206 left a weak finding whose Python repair card asserted on the stale imported object (assert response.status_code == 400 where response still points at the old object).
  • The check lives in static_limits.rs, the shared owner of test-side limits. It fires only when the changed line is a ModuleField effect and a related oracle-using test both imports that object from the owner's module and assigns its name. Instance-field and module-constant findings are untouched.

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge, dependency, or repo-ops development for ripr-swarm

Source-of-truth Links

Proposal: n/a
Spec: RIPR-SPEC-0028, RIPR-SPEC-0108 (no behavior text changed; the three fixture SPEC.md files now describe the static_unknown module-object finding)
ADR: n/a
Plan item: n/a
Governing issue or accepted claim: #10289 (parent #10184)
Acceptance delta (one sentence): a module-object write whose related test reloads or replaces the module namespace no longer yields a weak finding or a repair card that targets the stale imported object.

Candidate Relationships

Candidate branch (GitHub PR head is authoritative after publication): claude/project-thread-9z5l8r
Stack parent or prerequisite PR (if any): none (#10206 merged)
Proposed replacement of PR (if any; not yet accepted): none
Acceptance retained from a replaced candidate (if any): none
Accepted winner and losing candidate disposition (when decided): n/a

Scope

  • static_limits.rs (one new limit), module_field_tests.rs, the repair-card inventory (31 → 28), three fixtures re-blessed, three honesty-corpus entries (expected_class → maximum_class plus must_emit_limitation: mocked_module), changelog fragment.

Scope Classification

  • One production behavior

Production delta: one static limit for module-object writes under a rebinding test.

Single acceptance criterion: the three dynamic-namespace fixtures' module-object finding is static_unknown with no card.

Non-goals: receiver-aware precision; module-constant cards (their advice is a boundary input, not an assertion on a stale object).

Support-tier Impact

  • none

Policy Impact

  • none

Proof

  • cargo test -p ripr --lib python: 1449 passed on the merged head. The reload, __setattr__, renamed-delattr, patch, assignment and setattr cases pin static_unknown; the live-read credit control stays exposed.
  • cargo xtask goldens check: no drift after the bless. The route.py finding in each fixture is static_unknown and hidden; the unchanged constant finding remains weak.
  • Repair-card inventory test passes at orthogonal=28; the honesty-corpus gate test passes and so do the 84 evidence_promotion and 33 benchmark_semantic xtask tests. maximum_class alone cannot tell static_unknown from a regression (it only caps severity), so each entry also requires a mocked_module limitation; reverting the limit fails them.
  • cargo fmt --check clean. cargo xtask precommit policy checks pass; its lint stage exceeded my local time limit, so hosted CI owns it.

Claim Boundary

May claim: the module-object write under a rebinding test is withheld, no stale-object card.
Must not claim: every dynamic rebinding is detected. The match is textual and file-level, as in #10206: an unrelated setattr, vars or locals in a test file that imports the object can also withhold the finding, which loses an advisory but never adds credit.

Rollback

Revert the commit.

Spec-Test-Code Traceability

  • Spec: RIPR-SPEC-0028, RIPR-SPEC-0108
  • Tests: module_field_tests.rs, gap_decision_ledger.rs inventory, fixtures/python_dynamic_namespace_*

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.

CI Economics

n/a

🤖 Generated with Claude Code

https://claude.ai/code/session_01FtMtd6sDKNAUbvAJ7jzpmt

…dule namespace (#10289)

A related test that reloads the module or replaces its names (assignment, setattr, __setattr__, delattr, importlib.reload) reads a different object than the owner mutates. The weak finding it left behind carried a repair card asserting on the stale imported object, so the finding is now a mocked_module static limit (static_unknown, no card), like patch.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FtMtd6sDKNAUbvAJ7jzpmt
@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 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Summary by CodeRabbit

  • Bug Fixes
    • Python analysis reports now distinguish findings affected by module replacement or reloading from confirmed weak findings.
    • Reports no longer suggest a repair based on a stale module reference in these cases. They identify the analysis limitation and recommend testing the real implementation without a mock.
    • Finding summaries and counts now reflect the updated classifications; unrelated findings remain unchanged.

Walkthrough

The Python analysis now reports module-field writes as static_unknown when a related oracle-eligible test rebinds the module namespace. The report no longer offers a weak-finding repair card for those cases. Tests, fixture outputs, and corpus expectations reflect this classification.

Changes

Python module rebinding

Layer / File(s) Summary
Detect rebinding and assert the classification
crates/ripr/src/analysis/language/python/static_limits.rs, crates/ripr/src/analysis/language/python/module_field_tests.rs
The static-limit check detects a changed module field that an oracle-eligible related test rebinds. The reload, __setattr__, and renamed delattr tests now expect StaticUnknown.
Update fixture reports and corpus expectations
fixtures/python_dynamic_namespace_*/expected/*, fixtures/evidence-promotion-honesty-corpus/corpus.json, crates/ripr/src/output/gap_decision_ledger.rs, changelog.d/10289-python-module-object-rebind-static-limit.md
The three fixture reports classify the route finding as static_unknown with a mocked_module limit and remove its repair card. The corpus expectations, ledger count, and changelog entries reflect the updated results.

Priority: Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

  • Issue 10178: The new limit withholds module-field credit when a related test rebinds the module attribute. The PR does not show the issue’s exact setattr and patch cases, so coverage is partial.
  • Issue 10184: The PR updates reload, __setattr__, and renamed delattr cases listed in the issue. The issue’s separate constant-path concern is not covered by the described changes.
Merge Risk: Moderate · up to 7d43a

Module-field writes can now be reported as static_unknown, with no repair card, even when another related test independently observes the changed value on the live object. This withholds findings that should stay actionable. It is conservative and produces no false positives, but the loss of coverage should be fixed or explicitly accepted before merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. (14 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: withholding module-object writes when related tests rebind the module namespace.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description is mostly complete and follows the required structure. It clearly states the behavior change, scope, acceptance criterion, proof, claim boundary, rollback, traceability, a…
Full details: Description check

Explanation

The pull request description is mostly complete and follows the required structure. It clearly states the behavior change, scope, acceptance criterion, proof, claim boundary, rollback, traceability, and static-language status. The Engineering Check section and the detailed Gates checklist are omitted, and the traceability section does not list code, golden outputs, metrics, or ADR/learning entries.

Full details: Docstring Coverage

Explanation

Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. (14 skipped: 14 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the module’s name,
A rebinding changes what came.
No stale repair card hops along,
The report marks what can’t be known.
Three test paths now match the rule,
And carrots wait beside the tool.

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

coderabbitai[bot]

This comment was marked as resolved.

…e honesty corpus (#10289)

Review repairs: the new limit fires only for a related test that imports the object from the owner's module, since only such a test can read a stale one. The three honesty entries now also require a mocked_module limitation, so reverting the limit fails them; the fixture SPEC text names the static_unknown module-object finding.

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

@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 new route uses assigns_attribute(&object), but the diff does not demonstrate broad coverage of related-test discovery and module-object rebinding variants beyond reload, setattr, dunder-setattr, and renamed-delattr.
  • Confirm the textual rebinding detector can over- or under-match dynamic namespace operations.

Refuted

  • The fix belongs in fixture output or repair-card generation because the defect is stale-object repair guidance.; refuted because: The changed source branch classifies the probe before card creation and uses the shared static-limit mechanism; fixture reblessings are consequences rather than the behavioral fix.
  • The patch may remove useful repair evidence without proving the stale-object scenario.; refuted because: The changed fixtures explicitly exercise module rebinding and the production logic withholds only the affected module-object probe as static_unknown, matching the stated acceptance criterion.

Evidence gaps

  • The correctness-critical Rust test proof remains unavailable in the packet because ripr failed and cargo-test is scheduled late.
  • Model proof intent was rejected by deterministic validation.
  • The changed golden outputs encode static_unknown and remove the stale-object repair card, but their execution provenance is not confirmed in the available receipts.

…-9z5l8r

# Conflicts:
#	crates/ripr/src/analysis/language/python/static_limits.rs
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 25, 2026 11:13

Copy link
Copy Markdown
Member Author

Review of record for head 4403386 (base 6657a7a).

  • Angles: (1) correctness and edge cases; (2) tests, oracle grip, spec and contract. Two independent read-only reviewers.
  • Findings and resolutions:
    • Over-suppression: the first version did not require the related test to import the object. Fixed: the limit now needs an import from the owner's module (same filter the reader uses). Residual, documented in the claim boundary: the file-level textual writer match (vars, locals, unrelated setattr) can still withhold a finding for a test that imports the object. That loses an advisory only and matches fix(python): treat reload, __setattr__ and delattr as dynamic namespace writers #10206's policy.
    • maximum_class could not tell a limited finding from a regression to weak. Fixed: each honesty entry also requires a mocked_module limitation, so a revert fails it.
    • Stale fixture SPEC text said "weakly_exposed" for both findings. Fixed in all three.
    • Reused mocked_module guidance text in human-full reads slightly off for reload and delattr. Left as is: the limit kind is shared, and a distinct kind would change the output contract. Noted for a follow-up if wanted.
  • Proof: see the PR body. Hosted required run to follow.

Generated by Claude Code

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

@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: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

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

Verification questions

  • Confirm the reblessed check.json files no longer include the test file in source_subject, although related_tests still names it.

Refuted

  • The any-over-related-tests behavior invalidates independently established live-read credit and is a blocker in this PR.; refuted because: The path is real, but the seeded review traced and explicitly accepted it as conservative missed credit consistent with existing finding-wide mocked_module semantics; changing per-test credit joining is outside this PR.
  • The new limit is overbroad because any rebinding test can suppress a finding.; refuted because: The changed branch requires a ModuleField effect, a rebinding of that object, an oracle-using related test, and an import of the object from the owner module. Remaining textual matching and finding-wide any semantics are explicitly bounded in the claim boundary and prior thread.
  • The new limit can suppress an independent live-read sibling test without limitation.; refuted because: This real conservative-credit objection was acknowledged and deliberately deferred in the seeded thread; the current diff retains the same any-related-candidate behavior.
  • The current patch must preserve observation credit from an independent live-read sibling test.; refuted because: That behavior does not hold under the documented finding-wide static-limit policy, but it only loses advisory credit and was already traced and accepted in the seeded thread.

Evidence gaps

  • The central Rust and golden-test proof claims are not confirmed by evidence available to this lane.
  • Focused package proof is still required: the ripr sensor failed and cargo-test had only scheduled-late status, so the changed Rust behavior and fixture inventory are not independently proven in this packet.
  • Model proof intent was rejected by deterministic validation.

Parked follow-ups

  • Finding-wide any semantics can withhold independently earned live-read credit when sibling tests exist; this is an acknowledged conservative limitation rather than a new blocker.
  • The limit is finding-wide: one rebinding test can suppress credit supplied by a sibling test that observes the object live.
  • The finding-wide any() semantics can downgrade an independently live-read sibling test to static_unknown, but this is a documented conservative missed-credit limitation rather than false evidence.
  • The route may withhold credit whenever any related oracle test rebinds the object, even if a sibling test observes the live object; the seeded thread explicitly accepts this as conservative missed credit.

@EffortlessSteven
EffortlessSteven merged commit 9811f0b into main Oct 25, 2026
56 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/project-thread-9z5l8r branch October 25, 2026 12:10

Copy link
Copy Markdown
Member Author

Merge log line (status.md write was refused, so it goes here): #10325 merged as 9811f0b on expected head 4403386 after the required Ripr Rust Small Result passed. A module-object write whose related test rebinds the module namespace now reads static_unknown with a mocked_module limit. Closes #10289. Known residual: the limit is finding-wide, so one rebinding test also withholds credit from a live-reading sibling (loses advisory credit, never adds any). I'll file it if it shows up in the corpus.


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