Skip to content

fix(owner-pin): std/core/alloc globs are not foreign macro-binding sites (#8388) - #8534

Closed
EffortlessSteven wants to merge 7 commits into
mainfrom
claude/fix-8388
Closed

EffortlessSteven wants to merge 7 commits into
mainfrom
claude/fix-8388

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Requested by Steven · project thread

Governing issue or accepted claim: #8388 (item 1 only: plain assert_eq! "not credited as the standard macro"; items 2 and 3 are not addressed here)

Acceptance delta (one sentence): A glob import from std/core/alloc no longer makes assert_eq! ambiguous crate-wide, while globs from any other crate and any alias of the standard root still refuse.

Before: a private #[cfg(feature = "simd_support")] use core::simd::prelude::*; in one file (rand src/distr/float.rs:15) was recorded as a foreign glob that "may bring in a different assert_eq!". That site is crate-wide, so plain assert_eq! in unrelated test modules (rand uniform_float.rs) was refused: assertion not credited: ripr could not establish that it runs as the standard macro, dropping probes to observation no / discriminator no.

After: a glob rooted at std, core or alloc lists only the standard macros, so it cannot supply a different assert_eq!. The site scan (macro_binding_ambiguities in analysis/syntax/owner_pin.rs) skips it unless a module, extern crate ... as alias or workspace package in the same file takes the root name. Review follow-up: extern crate other as std; (or core/alloc) replaces the root for the whole crate, so the alias is now itself a may-rebind site for every trusted name, which keeps use std::*;/use core::*; in another file foreign. Globs from any other crate still refuse, so the actionability flip is not loosened.

How: guard and alias site at the semantic owner (analysis/syntax/owner_pin.rs); the candidate prefilter treats the alias as Any. Fixtures that used a std glob as their representative foreign glob now use other::.... New test standard_library_globs_are_not_foreign_macro_binding_sites covers, positively and negatively: std/::std/core/alloc globs (no site); other::, stdx::, mod core {} and in-file alias (site); and the cross-file cases (alias in one file, glob in another: site present; plain extern crate std; plus use core::*;: none).

Local verification (debug build):

  • cargo test -p ripr --lib owner_pin: 250 passed
  • cargo test -p ripr --test match_arm_assert_admission: 6 passed
  • cargo xtask precommit and goldens check: see the PR comment for the final head
  • Real-crate run on rand 94c9078 (before the alias follow-up): "not credited" notes went from 2 test-module refusals to 1 (uniform_other.rs test_char_bad_deser, a different cause)

Not verified / out of scope:

  • Issue item 2 (same assertion, different strength per probe) and item 3 (assert!(it.next().is_none()) picked over the exact assertion); both still reproduce on rand 94c9078.
  • The generic "could not establish" wording still carries no per-case reason in the related-test line.

🤖 Generated with Claude Code

…tes (#8388)

A crate-local `use core::simd::prelude::*;` made every trusted assertion
macro ambiguous for the whole crate, so plain `assert_eq!` in unrelated
test modules was reported "not credited as the standard macro".
Standard-distribution globs list only the standard macros; they are now
skipped unless a module or alias in the file takes over the root name.

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

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 81 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: a7649f38-a7cb-47a5-862f-25963971b64c
📥 Commits

Reviewing files that changed from the base of the PR and between 4889d21 and 19213c5.

📒 Files selected for processing: 4
  • changelog.d/8388-standard-glob-not-foreign-macro-binding.md
  • crates/ripr/src/analysis/classify/owner_pin/tests.rs
  • crates/ripr/src/analysis/syntax/owner_pin.rs
  • crates/ripr/tests/match_arm_assert_admission.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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

Self-review of head 698431f (hosted checks not yet run; no independent subagent was available to this agent, so this is author self-review, not independent review).

Inspected: the full diff (one guard in macro_binding_ambiguities, one test, one fixture rename, one changelog fragment); the semantic owner and its consumers (trusted_macro_binding_sites, workspace site index, refusal text); the shadowing cases (mod core {}, extern crate other as std, workspace package named like the root); brace-only trees (use {std::*, other::*} has no root path, so it stays foreign); and non-star imports, which are unchanged. The candidate prefilter and saturation hint are conservative supersets and unchanged. Fail-closed: only std/core/alloc roots with no shadowing are skipped; every other glob still refuses.

Evidence: cargo test -p ripr --lib owner_pin 249 passed; cargo xtask precommit exit 0; cargo xtask goldens check clean; rand 94c9078 real-crate run shows the glob-caused refusals gone.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 17, 2026 18:26
@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.

Confirmed findings

  • crates/ripr/src/analysis/classify/owner_pin/tests.rs:5497 — Add an explicit positive fixture for extern crate other as std; use std::*; in file A and a separate use core::*; in file B, asserting workspace refusal site IS present. The added test covers single-file but not cross-file shadowing of the standard root via alias.
  • Fixture rename use std::io::prelude::*; -> use other::io::prelude::*; in trusted_macro_scan_skips_files_only_once_every_name_is_ambiguous and convergence_index is the minimum needed to keep those cases exercising a ForeignGlob; the rename is correct but loses a regression check that std-globs previously saturated the set. Low risk because the new dedicated test re-covers std-globs and the renamed fixture's intent is preserved by the case label and shadowing setup.
  • Guard uses string-equality on root segment (std|core|alloc) which is language-version-stable for std/core/alloc; any future renamed standard root would silently re-become foreign. Not a UB defect, monitor if prelude roots expand.

Verification questions

  • Confirm sibling-path risk: brace-tree use {std::*, other::*} (no root path) and use crate::* / use self::* are not exercised by the new test; the PR body states brace-only trees stay foreign by design and they remain unchanged here, so no behavioral claim is made, but no test pins that. Logging as source-route-gap per sibling-path calibration.
  • Confirm hosted CI receipts (cargo test, xtask precommit, goldens check) are author-reported, not broker-witnessed; late cargo-test sensor is scheduled but not yet landed for this PR head.
  • Confirm two existing fixtures (trusted_macro_scan_skips_files_only_once_every_name_is_ambiguous and convergence_index) were renamed from use std::io::prelude::*; to use other::io::prelude::*; because they relied on a saturating foreign glob. With the new guard, std glob would no longer saturate, breaking the test's intent. Renaming preserves semantic intent. No regressions.

Refuted

  • A standard-distribution glob skip ('if item.star_token().is_some() && standard_root { continue; }') could let a foreign macro binding leak across a JS worker / postMessage / transferable boundary and silently disable the actionability flip in another worker context.; refuted because: The diff is pure Rust static analysis. Owner Pin returns MacroBindingAmbiguity synchronously by value with no thread, channel, or bridge. There is no postMessage, transferable, SharedArrayBuffer, WebAssembly.Memory, or JS-binding surface in the changed code. The std/core/alloc skip is local to one file, fails closed for any other crate, and uses the same drop_in_shadowed predicate drop-in imports already use; the worker-handoff surface is not in scope.
  • A brace-grouped import use {std::*, other::*}; would let the non-standard glob sneak through because the parent UseTree has no star token, breaking the descendant iteration and skipping the foreign check.; refuted because: UseTree::cast on descendants still finds the inner UseTree for each group member; each member carries its own star_token(). other::* still triggers the item.star_token().is_some() && !own foreign path and refuses. Group root path is irrelevant; the foreign signal comes from the starred member.
  • Lane scope mismatch: PR touches Rust macro-binding classification, not JS/WASM resizable buffers. No active-view/ArrayBuffer/TypedArray surface changed.

Evidence gaps

  • cargo-test sensor is scheduled-late (not yet landed). Local lane run not substituted; cannot independently confirm 249 passed count or that the new test is in the executed set rather than only compiled.
  • No UB ledger configured; lane cannot replay miri/sanitizer evidence, so residual memory-safety risk must be verified by hosted CI once available.
  • Model proof intent was rejected by deterministic validation.

…sion fixture (#8388)

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

Copy link
Copy Markdown
Member Author

CI Diagnosis (Run 39063841926)

  • All Required Tests Passed: Step 23 \Required Rust tests\ passed all 17,071 unit tests, and Step 22 \Strict workspace Clippy\ passed cleanly.
  • Root Cause of Failure: The run failed at Step 26 \Golden output contracts\ on:
    • \match_arm_tuple_terminal_generated_constructor\
    • \match_arm_tuple_terminal_imported_formatter\
    • \match_arm_tuple_terminal_inherited_constructor\
  • Remedy: This failure is pure inherited drift from an older base before commit \4229f8187\ (test(fixtures): bless 3 match_arm_tuple_terminal human goldens #8524) blessed these exact fixtures on \main. Merging current \origin/main\ into \claude/fix-8388\ will resolve this without any golden modifications in this PR.

Copy link
Copy Markdown
Member Author

This overlaps #8529, which opened earlier (18:17 vs 18:25 UTC) and implements the same #8388 item 1 guard. #8529 additionally (a) requires the manifest proof (unbound_standard_root) so a Cargo rename of std/core keeps the glob foreign, (b) refuses when any file has a crate-root extern crate x as std|core|alloc, which drop_in_shadowed cannot see across files, and (c) keeps alloc globs foreign since it has no manifest proof. Both were found by an independent exact-head review of #8529. #8529's CI fix (schema example bump for the file-fact cache version) is pushed at 5613d19.

Suggest closing #8534 once #8529 is green and merged, unless you have a case #8529 mishandles. If #8534 lands first I will rebase #8529's extra hardening on top.


Generated by Claude Code

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

Confirmed findings

  • Root name comparison uses string equality on 'std'/'core'/'alloc'; a future language-added standard root would silently become foreign. Not exploitable today; monitor if prelude roots expand.
  • Fixture renames use std::io::prelude::* -> use other::io::prelude::* in trusted_macro_scan_skips_files_only_once_every_name_is_ambiguous (tests.rs:5553) and convergence_index (tests.rs:5628), and use std::prelude::v1::* -> use other::prelude::* in match_arm_assert_admission.rs:164; the renamed fixtures still exercise a ForeignGlob via other:: and the dedicated new test re-covers std/core/alloc positively and negatively, so the actionability flip is preserved.

Verification questions

  • Confirm sensors/ripr/ub-review-sensor-status.json:0 — ripr sensor failed (exit code Some(2)) with no receipt captured. Lane cannot independently re-witness that the standard_root guard did not shift array/slice region classification downstream. Request a fresh cargo test --locked --package ripr --lib owner_pin and --test match_arm_assert_admission run.
  • Confirm unchanged.statement.

Refuted

  • Re-introducing allocation-failure semantics via Box::from(slice) or similar on resizable-buffer path.; refuted because: Diff has zero allocation/slice/Box additions; this objection does not apply to the present diff and is rejected on calibration grounds.
  • If standard_root_alias accepts an alias where target==alias (e.g. extern crate std; or extern crate core as core;), the function would still call text().to_string() and force every pass to allocate an owned String for a no-op equivalence, leaking allocation pressure and (for long-running analyses) minor heap churn.; refuted because: Source-level guard: (matches!(alias, "std" \| "core" \| "alloc") && target.as_deref() != Some(alias)).then(\|\| item.syntax().text().to_string()) — target==alias short-circuits to None, so the to_string allocation is gated and never paid for extern crate std; or extern crate core as core;. No allocation churn.
  • This Rust-only AST patch could regress JS-bound worker/SharedArrayBuffer/transfer/detach semantics somewhere in the wider crate; refuted because: Repo is Rust (crates/ripr) and the diff touches owner_pin syntax analysis only; no JS, no wasm-bindgen, no napi, no bindings surface exists in changed lines or immediate consumers. Lane scope inapplicable.

Evidence gaps

  • ripr sensor reported exit code Some(2): cargo test receipt for this exact PR head is absent from this packet, so active-view UB cannot be re-witnessed end-to-end.
  • Sensor ripr failed (exit 2) but the cross-file workspace acceptance in the new test is workspace_macro_site(...).is_some(), which is the same surface ripr tested; failure is an instrumentation issue, not a memory-lifetime regression introduced by the guard.
  • Model proof intent was rejected by deterministic validation.

Parked follow-ups

  • Seeded review summary flagged a sibling-path risk (brace tree use {std::*, other::*}, use crate::*, use self::*, macro_use prelude). For memory-lifetime lane this is irrelevant: these are pure source-text classification paths and produce no owned data with non-static lifetime. PR body already documents the prior-art reviewer here.
  • Helper boundary is at the syntax owner rather than at classify/owner_pin/tests.rs; private to syntax module, consumed only there, no cross-module duplication introduced.

@EffortlessSteven
EffortlessSteven marked this pull request as draft October 18, 2026 03:32
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 18, 2026 03:32
@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.

Confirmed findings

  • Root segment equality matches the literal text std|core|alloc; a Cargo [patch] or workspace rename of these names would silently re-fail behaviour. Out of scope for this PR but worth monitoring.
  • crates/ripr/src/analysis/syntax/owner_pin.rs:1421 — standard_root_alias matches alias == "std" \| "core" \| "alloc" and excludes target == alias, so extern crate std as std; is silently dropped (no may-rebind site from the alias) and the renamed alias target is unverified. Recommend also emitting a site when target.as_deref() == Some("std") etc. so plain extern crate std; keeps observation consistent with the new cross-file case where it does NOT take over.
  • Sibling lane: no matching helper paths for standard-glob ownership were found outside analysis/syntax/owner_pin.rs and its trusted_macro_binding_sites consumer; verified by walking analysis/classify/owner_pin.rs references and the workspace site index, but the manual cross-check did not enumerate rustc_codegen / serialization / macro_rules expansion siblings because those surfaces do not participate in foreign-glob classification. Reserving a source-route-gap for any future prelude-root expansion.

Verification questions

  • Confirm new branch source.contains("extern") widens the cheap prefilter beyond use/macro; required because extern-crate sites must reach the per-node alias check, but text-only and consistent with existing heuristics.

Refuted

  • The standard_root guard could introduce an allocation-failure or Box::from-style seam because a glob from std/core/alloc might bypass ownership checks downstream; refuted because: Diff is syntax-tree classification only; standard_root path constructs no Box, allocates no slice, and exposes no native pointer. No mem::take, ptr::read, Vec::from_elem, or unsafe block was added in the patched regions or callable from them.
  • Fixture rename from use std::io::prelude::* to use other::io::prelude::* in trusted_macro_scan_skips_files_only_once_every_name_is_ambiguous and convergence_index could lose a regression test that std-globs used to saturate the set; refuted because: Renamed fixture still exercises a ForeignGlob via other:: (foreign root path), the test label and shadowing setup preserve intent, and the dedicated new test standard_library_globs_are_not_foreign_macro_binding_sites re-covers std-globs positively. Actionability flip is preserved.
  • No resizable buffer or active-view UB surface exists in this Rust owner-pin semantic patch; JS/ArrayBuffer/TypedArray detach/transfer concerns do not apply.
  • Adding source.contains("extern") to the macro_binding_ambiguities prefilter could over-widen candidate set and trigger cross-thread amplification if sites were later pushed to a worker pool.; refuted because: ripr's analysis is synchronous on the calling thread; no thread-pool or async runtime dispatches the sites, and the prefilter only gates AST walk, not allocation. The wider prefilter is the documented superset behavior cited in the PR body (candidate prefilter is conservative).
  • Box::from(slice) allocation-failure analysis on Box::from(slice) introduced by the PR diff; refuted because: The PR diff has no allocation-failure semantics change and no Box::from(slice) construction. The opposition lane was asked to check it but no candidate raises it, so per calibration this is a refuted false-premise.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.
  • Ripr sensor failed (exit 2) before this PR's source was visible to it; reviewer cannot independently re-witness production owner_pin on a representative crate. Local test receipts (250 + 6) cover the guard but not array/slice downstream classification.

Parked follow-ups

  • Author self-review note in the PR thread acknowledges #8529 implements three hardenings (manifest unbound_standard_root, cross-file extern crate x as std\|core\|alloc refusal, alloc stays foreign). Head 8534 retains the extern crate other as std; cross-file case via the standard_root_alias macro-binding candidate (Any) plus the macro_use site, but does NOT add the manifest proof or the alloc foreign-by-default rule. Park this as a follow-up rebased on top once #8529 merges, not as a blocker for #8534.

EffortlessSteven pushed a commit that referenced this pull request Oct 18, 2026
…ob foreign (#8388)

Ports the shadow guard found on #8534; merges main.

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

Copy link
Copy Markdown
Member Author

Closing as the weaker duplicate of #8529 for #8388 item 1. #8529 opened first and also requires the manifest proof (so a Cargo rename of std/core stays foreign), refuses crate-root extern crate x as std|core|alloc across files, and keeps alloc globs foreign without manifest proof. The one thing #8534 had that #8529 lacked, the plain-import shadow guard (use other::std;), is now ported into #8529 (cfb8826) with a test that fails without it.


Generated by Claude Code

EffortlessSteven added a commit that referenced this pull request Oct 18, 2026
…ain assert_eq! "not credited" (#8388)

* fix(analysis): standard-crate globs no longer withhold every plain assertion

A glob import rooted at an unshadowed std, core or alloc (for example the
cfg-gated `use core::simd::prelude::*;` in rand) was recorded as a foreign
glob site that may rebind every trusted macro for the whole crate, so each
plain assert_eq! in that crate was reported "assertion not credited"
(rust_assertion_context_unestablished). Such a glob can only import items
the standard library defines. The scan now skips it unless a local module,
extern-crate alias or `use .. as` takes the root name; globs from any other
crate and every real definition or import stay ambiguous.

Refs #8388

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

* fix(rust): require manifest proof and refuse cross-file std aliases for standard globs (#8388)

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

* test(rust): use a foreign glob exemplar in the match-arm admission test (#8388)

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

* docs(schema): rerun example tracks file-fact cache schema 1.44 (#8388)

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

* fix(owner-pin): a plain import binding the root name keeps the std glob foreign (#8388)

Ports the shadow guard found on #8534; merges main.

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

* docs(owner-pin): ForeignGlob doc names the proven standard roots (#8388)

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

* docs(owner-pin): reword ForeignGlob doc for the static-language gate (#8388)

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

* fix(owner-pin): treat use other::std::{self} as binding the std root so its glob stays foreign (#8388)

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
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