Skip to content

fix(python): bind an import alias to the test that imports it (#8247) - #8323

Merged
EffortlessSteven merged 7 commits into
mainfrom
claude/blissful-curie-5yrhti
Oct 17, 2026
Merged

EffortlessSteven merged 7 commits into
mainfrom
claude/blissful-curie-5yrhti

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Related to #8247 (does not close it).

Claim

Sink alignment pooled owner import aliases across every Python test. An uncalling test that imports the owner as quote (from src.shop import fee as quote) let a different test's assert quote(10) == 30 (where quote is src.fixed.fixed) count as observing the owner, so the finding was reported exposed / alias. The alias credit branch now reads only the asserting test's own imports. When a unit has no source facts, the pooled set is kept as before.

Evidence

  • RED/GREEN: another_tests_owner_alias_does_not_credit_a_different_function fails with the fix reverted and passes with it. It includes a renamed-donor control and a positive control (the asserting test's own alias stays exposed).
  • New fixture python_cross_test_import_alias: weakly_exposed with orthogonal alignment.
  • New honesty-corpus case py_cross_test_import_alias_not_borrowed; cargo xtask check-evidence-promotion-honesty passes.
  • cargo xtask precommit exit 0. All real Python fixtures pass. verdict-corpus check is unchanged at 13/486 false, 0 contradictions.
  • Not run locally: cargo xtask goldens check (offline cargo cache cannot prepare fixture deps), full workspace tests, hosted CI.

Remaining on #8247

Wrong-receiver pooling and the walrus / match / module-level stand-in fail-opens stay open.


Generated by Claude Code

Sink alignment pooled owner import aliases across every test, so an
uncalling test importing the owner as `quote` let another test's
`assert quote(10) == 30` (a different function) count as observing the
owner. The alias credit branch now reads the asserting test's own imports.

Related to #8247 (does not close it).

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

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 62 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
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: fe590fe0-b912-4483-aa1a-9c272ddc53a5
📥 Commits

Reviewing files that changed from the base of the PR and between e6b8a56 and e4f7897.

📒 Files selected for processing: 18
  • .ripr/traceability.toml
  • changelog.d/8247-python-cross-test-import-alias.md
  • crates/ripr/src/analysis/language/python.rs
  • crates/ripr/src/analysis/language/python/sink_alignment.rs
  • crates/ripr/src/analysis/language/python/tests.rs
  • crates/ripr/src/output/gap_decision_ledger.rs
  • fixtures/evidence-promotion-honesty-corpus/corpus.json
  • fixtures/python_cross_test_import_alias/SPEC.md
  • fixtures/python_cross_test_import_alias/diff.patch
  • fixtures/python_cross_test_import_alias/expected/CHANGELOG.md
  • fixtures/python_cross_test_import_alias/expected/check.json
  • fixtures/python_cross_test_import_alias/expected/human-full.txt
  • fixtures/python_cross_test_import_alias/expected/human.txt
  • fixtures/python_cross_test_import_alias/input/ripr.toml
  • fixtures/python_cross_test_import_alias/input/src/fixed.py
  • fixtures/python_cross_test_import_alias/input/src/shop.py
  • fixtures/python_cross_test_import_alias/input/tests/test_catalog.py
  • fixtures/python_cross_test_import_alias/input/tests/test_shop.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@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 import use-list trim removes import_module_may_be_owners from both python.rs and sink_alignment.rs with no remaining callers in this diff; verify it is still referenced elsewhere before relying on the trim as dead-code removal.
  • Confirm per-test alias scope drops legitimate cross-statement calls in the donor test when source facts exist.
  • Confirm positive control asserts equality of fixture output, not the fix's reported classification path.
  • Confirm cargo-test sensor is scheduled-late; no witness receipt is in this packet. Until a focused cargo test --locked -p ripr (or equivalent) receipt lands, red/green proof rests on author attestation plus corpus/goldens.

Refuted

  • A different test's from m import owner as quote could still let an unrelated method-owner or activation-controlled test count as observing the owner via the pooled alias_tokens used by the None-test fallback; refuted because: Inspected alias_tokens construction: for method owners is_method_owner early-returns empty; for activation-controlled tests activation_control(test).is_some() early-returns empty. The pooled set therefore only contains free-function aliases from non-activation tests, matching the documented fallback.
  • is_method_owner branch was silently removed and method-class aliases now leak into the free-function alias set.; refuted because: owner_aliases_in early-returns Vec::new() when is_method_owner is true, preserving the previous behavior of skipping method owners for alias pooling. The original code used an if is_method_owner {...} else {...} inside the loop; the new closure short-circuits earlier but yields the same empty set.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.
  • ripr sensor failed exit_code=2 in this packet; cargo-test is scheduled-late so RED/GREEN proof of another_tests_owner_alias_does_not_credit_a_different_function is not in evidence yet.

Copy link
Copy Markdown
Member Author

Claiming this PR for review and merge convergence (newest-first backlog lane). Backlog-oldest-first thread: please skip #8323.


Generated by Claude Code

…8247

The repair-card corpus gains one orthogonal card from the new fixture, and the
human golden follows the compact summary format on main.

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

Copy link
Copy Markdown
Member Author

Local proof at head 7e95df9 (includes a merge of current main):

  • Independent Sonnet review of a44f0bd: REVIEW_READY, no blocking findings (static read).
  • cargo test -p ripr --lib python: found python_repair_card_corpus_pins_alignment_inventory drift (orthogonal 13→14 from the new fixture); fixed in 7e95df9, test passes.
  • cargo xtask fixtures: this PR's python_cross_test_import_alias human.txt golden was stale vs main's compact summary format; refreshed in 7e95df9 and no longer drifts. Eight other fixtures (e.g. one_hop_field_projection, rust_map_overwrite_count) drift the same way on main already, unrelated to this PR.
  • check-traceability, check-fixture-contracts: pass.
  • cargo xtask precommit: exit 0.
    Not verified: goldens check (needs the locked-deps prepare step, unavailable offline here).

Generated by Claude Code

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

@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 hard import.alias.len() >= 2 filter added in owner_aliases_in (single-letter aliases dropped) and continued into pooled fallback; could miss same-named function bivariance in 1-char alias edge cases not covered by SPEC.
  • Confirm import_module_may_be_owners removed from both python.rs and sink_alignment.rs use lists in this diff; verify it has no remaining in-crate caller before treating the trim as dead-code.
  • Confirm the positive control only asserts assert_shop_fee_exposed(&own); the asserting test's own alias is still observed, which the PR claims is the only way alias credit should attach. Without inspecting assert_shop_fee_exposed it cannot be verified whether 'exposed' here comes from the own-alias branch or from a different rule (e.g. direct imported_or_called identity).

Refuted

  • The positive-control branch assert_shop_fee_exposed(&own) is tautological because it asserts the classification produced by the function under test; refuted because: assert_shop_fee_exposed is an existing helper that pins the classification output against the expected class string; it asserts the rendered result, not the function. Additionally, this branch proves the alias scope change does not over-trim (the asserting test's own alias still credits), which is a distinct invariant from the borrowed-donor branch.
  • Helper locality is wrong: closure belongs in related_tests.rs next to alias-resolution helpers, not nested in classify_sink_alignment_with_old, which already mixes source_facts, related_tests, and inference.; refuted because: Closure is a one-line projection from (test, owner) used only at two sites in this same function (consumer + pooled flatten). Extracting it now would add indirection without reducing coupling; locality is consistent with the pre-existing pattern of inline closures in this classifier.

Parked follow-ups

  • The trimmed import use list removes import_module_may_be_owners from python.rs and sink_alignment.rs but the author note flags confirming it is still referenced elsewhere before relying on trim as dead-code removal.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.
  • New triple-branch test (borrowed, renamed_donor control, own_alias positive) plus corpus case py_cross_test_import_alias_not_borrowed constitute red/green proof for #8247. Without a focused cargo test --locked -p ripr receipt, proof rests on author attestation plus corpus/goldens.

@EffortlessSteven
EffortlessSteven marked this pull request as draft October 17, 2026 05:12
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 17, 2026 05:12
@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

Previous hosted Rust gate on 7e95df9 failed only on cli_smoke::check_python_finding_with_repair_card_points_at_the_card, a test that was red on main (stale (preview_limited) State oracle after #8275). Main has since fixed it (#8341 lineage), so I toggled Draft → Ready to re-admit the head against current main. No code change in this PR for it.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven marked this pull request as draft October 17, 2026 05:34
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 17, 2026 05:34
@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!

…ct (#8165)

Ported from #8351 so this PR's required goldens check is not red on a
base-branch drift it did not cause.

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

Copy link
Copy Markdown
Member Author

CI status on the previous head: Ripr Rust Small / Rust gates failed in goldens check on 8 fixtures this PR does not touch (one_hop_field_projection*, rust_map_insert_count_empty, rust_map_overwrite_count, seeded_push_after_early_return, typescript_mock_payload_iife_impl). I reproduced the same human.txt drift on a clean origin/main (61c4449): the plain-language Summary line from #8165 landed without re-blessing them. Open PR #8351 carries that bless, so I ported the same formatting-only re-bless into this branch (9b22c3d, after merging current main). It becomes a no-op once #8351 lands. My own fixture python_cross_test_import_alias and check-evidence-promotion-honesty still pass locally. The earlier Rust-only feature lane failure on a44f0bd7 predates this and is not yet re-checked on the new head.


Generated by Claude Code

# Conflicts:
#	fixtures/one_hop_field_projection/expected/CHANGELOG.md
#	fixtures/one_hop_field_projection_discarded/expected/CHANGELOG.md
#	fixtures/one_hop_field_projection_sibling/expected/CHANGELOG.md
#	fixtures/one_hop_field_projection_wrong_sink/expected/CHANGELOG.md
#	fixtures/rust_map_insert_count_empty/expected/CHANGELOG.md
#	fixtures/rust_map_overwrite_count/expected/CHANGELOG.md
#	fixtures/seeded_push_after_early_return/expected/CHANGELOG.md
#	fixtures/typescript_mock_payload_iife_impl/expected/CHANGELOG.md

@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

  • Corpus inventory pin in gap_decision_ledger.rs was bumped orthogonal 13→14 with an inline comment crediting this PR; any future fixture change that also adds an orthogonal card will require re-blessing this pin and a fresh review.
  • evidence-promotion-honesty corpus adds py_cross_test_import_alias_not_borrowed with expected_class=weakly_exposed and expected_finding_count=1; assertion must_not_promote is the load-bearing one. No run receipt in this packet.

Verification questions

  • Confirm import_module_may_be_owners trimmed from python.rs and sink_alignment.rs use lists but the PR text and prior thread flagged 'verify it has no remaining in-crate caller.' Local read of the diff does not show in-crate use; sink_alignment.rs previously called it inside the removed loop only. Symbol still appears in related_tests module (file not fully re-read).
  • Confirm import_module_may_be_owners import removed from both python.rs and sink_alignment.rs use lists; dead-code trim appears safe in-crate.
  • Confirm positive control in another_tests_owner_alias_does_not_credit_a_different_function relies on assert_shop_fee_exposed; helper semantics and the alias-vs-direct identity split were not inspected by this lane.
  • Confirm import_module_may_be_owners removal in python.rs is dead-code trim; verify no other in-crate caller before relying on it.
  • Confirm hard import.alias.len() >= 2 filter drops single-letter aliases (e.g. as q) globally, including the asserting test's own alias; this is a behavior tightening not described in SPEC.md or changelog, and could miss a real exposed case in production code.

Refuted

  • Positive control 'assert_shop_fee_exposed(&own)' is tautological because it asserts the function-under-test's own output.; refuted because: assert_shop_fee_exposed is an existing classification-pinning helper used throughout this test module. The positive control demonstrates the asserting test's own alias still observes the owner — the intended behavior — without referencing the function under test directly.
  • Closure change re-runs the per-test loop N times (one per unit) instead of the original O(all_testsimports) once, leaking quadratic behavior.; refuted because: owner_aliases_in is still O(all_testsimports) when built once via flat_map into alias_tokens; the per-test call site is over unit.test (the single assertion-bearing test of the current unit) plus the pooled fallback for None-test units, so the worst-case is roughly 2x the original aggregation, not quadratic.

Parked follow-ups

  • Hard alias.len() >= 2 filter drops single-character aliases globally; edge-case 1-char owner names may under-credit legitimate bivariance.

Evidence gaps

  • New test another_tests_owner_alias_does_not_credit_a_different_function covers the cross-test alias case plus renamed-donor control and positive control, but cargo-test is scheduled-late; no receipt in this packet. Until cargo test --locked -p ripr --lib python (or equivalent) lands, red/green proof rests on author attestation.

Copy link
Copy Markdown
Member Author

Reply to the github-actions review on this head, source-checked:

  • alias.len() >= 2 is not a new tightening. main already ran alias_tokens.retain(|token| token.len() >= 2) on the pooled alias set; owner_aliases_in applies the same bound per test, so one-character aliases were already excluded before this PR.
  • import_module_may_be_owners still has live callers in related_tests.rs (lines ~787, 998, 1036, 1444, 1593). Only the now-unused re-export in python.rs and the use in sink_alignment.rs were removed; its sole use in sink_alignment.rs was inside the method-owner branch of the removed loop, which was already dead because that loop filtered on !is_method_owner.
  • Positive control: assert_shop_fee_exposed pins class, oracle kind/strength and direct|alias alignment of the result. The control's asserting test imports fee as quote itself, so it can only be exposed through its own alias.
  • Red/green: with the sink_alignment.rs change reverted, another_tests_owner_alias_does_not_credit_a_different_function fails; with it, it passes (run locally). The hosted run on this head should provide the CI receipt.
  • Ledger pin 13→14 is intentional: the new fixture adds one orthogonal card.

Generated by Claude Code

@EffortlessSteven
EffortlessSteven marked this pull request as draft October 17, 2026 07:10
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 17, 2026 07:11
@settings settings Bot removed the merge-ready label Oct 17, 2026
@EffortlessSteven
EffortlessSteven merged commit 41b18d2 into main Oct 17, 2026
41 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/blissful-curie-5yrhti branch October 17, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants