Repository navigation
fix(owner-pin): std/core/alloc globs are not foreign macro-binding sites (#8388) - #8534
EffortlessSteven wants to merge 7 commits into
Conversation
…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
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
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. View limit details
Comment |
EffortlessSteven
left a comment
There was a problem hiding this comment.
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
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
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 separateuse 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) anduse 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_ambiguousandconvergence_index) were renamed fromuse std::io::prelude::*;touse other::io::prelude::*;because they relied on a saturating foreign glob. With the new guard,stdglob 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::caston descendants still finds the innerUseTreefor each group member; each member carries its ownstar_token().other::*still triggers theitem.star_token().is_some() && !ownforeign 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
CI Diagnosis (Run 39063841926)
|
|
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 ( 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 |
…le proof (#8388) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG7pu7c487BziNNoLfEVWK
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
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_pinand--test match_arm_assert_admissionrun. - 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_aliasaccepts an alias where target==alias (e.g.extern crate std;orextern crate core as core;), the function would still calltext().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 forextern crate std;orextern 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-staticlifetime. 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.
…glob guard (#8388) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG7pu7c487BziNNoLfEVWK
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
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_aliasmatchesalias == "std" \| "core" \| "alloc"and excludestarget == alias, soextern 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 whentarget.as_deref() == Some("std")etc. so plainextern 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.rsand itstrusted_macro_binding_sitesconsumer; verified by walkinganalysis/classify/owner_pin.rsreferences 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 beyonduse/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::*touse other::io::prelude::*intrusted_macro_scan_skips_files_only_once_every_name_is_ambiguousandconvergence_indexcould lose a regression test that std-globs used to saturate the set; refuted because: Renamed fixture still exercises aForeignGlobviaother::(foreign root path), the test label and shadowing setup preserve intent, and the dedicated new teststandard_library_globs_are_not_foreign_macro_binding_sitesre-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-fileextern crate x as std\|core\|allocrefusal,allocstays foreign). Head 8534 retains theextern crate other as std;cross-file case via thestandard_root_aliasmacro-binding candidate (Any) plus the macro_use site, but does NOT add the manifest proof or theallocforeign-by-default rule. Park this as a follow-up rebased on top once #8529 merges, not as a blocker for #8534.
…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
|
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 Generated by Claude Code |
…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>
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/allocno longer makesassert_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 (randsrc/distr/float.rs:15) was recorded as a foreign glob that "may bring in a differentassert_eq!". That site is crate-wide, so plainassert_eq!in unrelated test modules (randuniform_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,coreoralloclists only the standard macros, so it cannot supply a differentassert_eq!. The site scan (macro_binding_ambiguitiesinanalysis/syntax/owner_pin.rs) skips it unless a module,extern crate ... asalias or workspace package in the same file takes the root name. Review follow-up:extern crate other as std;(orcore/alloc) replaces the root for the whole crate, so the alias is now itself a may-rebind site for every trusted name, which keepsuse 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 asAny. Fixtures that used a std glob as their representative foreign glob now useother::.... New teststandard_library_globs_are_not_foreign_macro_binding_sitescovers, positively and negatively: std/::std/core/allocglobs (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; plainextern crate std;plususe core::*;: none).Local verification (debug build):
cargo test -p ripr --lib owner_pin: 250 passedcargo test -p ripr --test match_arm_assert_admission: 6 passedcargo xtask precommitandgoldens check: see the PR comment for the final head94c9078(before the alias follow-up): "not credited" notes went from 2 test-module refusals to 1 (uniform_other.rstest_char_bad_deser, a different cause)Not verified / out of scope:
assert!(it.next().is_none())picked over the exact assertion); both still reproduce on rand94c9078.🤖 Generated with Claude Code