Repository navigation
fix(verdicts): scope private macro bindings to their crate; pin inline receivers and sole early returns - #6909
Conversation
…by root (#5352) Dependent-scope narrowing withholds unindexed files and folded every macro-binding site they hold into the workspace-wide set. With crate-local scoping, a private glob in another crate's src/lib.rs no longer refuses this crate's tests in the full closure, so the named mode diverged. Withheld files that are themselves src/lib.rs, src/main.rs or src/bin/*.rs roots now route their crate-local sites by root; other withheld files stay workspace-wide. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
…b flip to ideal; 64 -> 62/203) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
…and sole early-return pins (#5352) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
…te can compile the file (#5352) Review found two fail-open shapes: an include! fragment at a recognized target path (tests/common.rs) was charged to itself as a crate root, and a shared tests/common/mod.rs composes under its first owner only. target_root now refuses to name a root for include targets, files with an include edge, non-root files under a tests/*.rs root, and edge-less files while any include! is unresolved. Also: withheld crate-root any-name sites still make local empty-macro names ambiguous (named mode matches full); a return in a nested fn no longer counts as the owner's; end-to-end and Err-mirror negatives for the early-return gate. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
…orkspace-wide (#5352) Re-review found that a module child of an include fragment left without a parent (two includers, cfg conflict, edge cap, unindexed target) composed under the fragment as if it were a crate root, and the withheld path diverged the same way. target_root now names no root while any include! is unresolved, nor for a file under a recorded include target. A real composition test (two binaries including src/lib.rs) refuses the shadowed assert_eq!, and fails without the fix. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
…solvable #[path] keeps sites workspace-wide (#5352) Final review: return Err(if .. { A } else { B }) passed the early-return gate, so a pin on A credited a changed B it never evaluates. The gate now applies the tail path's conditional-evaluation refusal. An unresolvable #[path] (cfg_attr, non-literal) records no module edge, so its target could look like a root; target_root now names no root while one exists. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (9)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review. Summary by CodeRabbit
WalkthroughOwner-pin analysis now scopes crate-local macro bindings to recognized Cargo target crates. It also recognizes supported inline constructor receivers and qualifying early-return pins. The verdict corpus and reports reflect updated classifications for two bytesize cases. ChangesOwner-pin analysis and verdict updates
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~45 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant MacroBindingScan
participant trusted_macro_sites_in
participant OwnerPinSyntax
MacroBindingScan->>trusted_macro_sites_in: provide macro-binding sites and target-root context
trusted_macro_sites_in-->>OwnerPinSyntax: return global, file-scoped, and crate-root bindings
OwnerPinSyntax->>OwnerPinSyntax: select applicable bindings for a test root
Merge Risk: ⚪ Minimal · up to No actionable issue remains from this review; the change is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Inline receiver support can misidentify which method an assertion exercises when an inherent constructor shadows a standard trait function. This can produce misleading test-evidence conclusions. The identified exposure concerns analysis results, not increased privileges or deployment authority. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 54 functions across 6 files. (4 skipped: 4 unsupported.) ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
A rabbit checks each crate-root trail, Comment |
…n lexical fallback (#5352) Review of record: target_root rescanned every indexed file per call (unresolved-#[path] check and package src lookup), and disclosure called it for every file per memo key, quadratic on large workspaces. TargetRoots now computes the workspace flags and src directories once per OwnerPinSyntax and memoizes each file's root; disclosure resolves a site's root only for crate-local sites. A lexical-fallback file records no module declarations, so it also disables routing. New test covers the #[path] and fallback rules. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
…5352) Only #[macro_use] extern crate is crate-local. An unresolved #[macro_use] mod may #[macro_export] its macros, which another crate reaches through a glob, so its site keeps refusing every test. The include-fragment test now matches the MacroBinding refusal and has a non-shadowing control. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
…word module name in the test (#5352) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
Review of record — head
|
| Round | Head | Angles | Blocking findings | Resolution |
|---|---|---|---|---|
| 1 | 8823fd2 | correctness and soundness (wrong credit), tests and regressions, spec and contract | crate-local routing could credit across include! fragments and tests/ shared modules; early-return gate accepted ? and non-leaving returns |
ddc0d99: include target, include edge and tests/ non-root files stay workspace-wide; returns_leave_the_function; ? refuses |
| 2 | ddc0d99 | soundness of root routing on a real build_index composition |
an unresolved (ambiguous) include leaves a fragment's module children looking like a crate root | 17e57d1: any unresolved include disables routing workspace-wide; real-composition test |
| 3 | 17e57d1 | early-return edge cases; module resolution | a conditional Err(..) could be a second source; an unresolvable #[path] records no edge |
9eaf47a: conditional if/match sources refuse; an Unknown #[path] disables routing |
| 4 (record) | 9eaf47a | soundness, performance | none blocking; perf: target_root rescanned the index per call |
838aecb: TargetRoots computes inputs once and memoizes per file; lexical-fallback files also disable routing |
| CodeRabbit | 838aecb | correctness | an unresolved #[macro_use] mod was marked crate-local but may #[macro_export] |
c8a9742: only #[macro_use] extern crate is crate-local; discriminating test case |
| Final | c8a9742 | A: memo staleness (one OwnerPinSyntax per RustIndex, verified at language/rust/mod.rs construction sites), decision equivalence, MacroUse placements (inner attr, cfg_attr); B: revert discrimination |
none | two nits fixed in bdce949 (doc comment placement; mod gen → mod generated, since gen is an edition-2024 keyword) |
Discrimination: every behavioral fix was confirmed by reverting it locally and watching its test fail. The MacroUse case was re-confirmed with mod generated.
Local evidence on the final code:
- owner-pin lib tests: 47 passed;
language::rust: 186 passed;owner_pin_execution: 17 passed;- goldens: clean;
- verdict corpus: 62/203 false verdicts, down from 64; the two bytesize division cases are fixed;
cargo xtask precommit: exit 0.
Declined bot suggestions, all fail-closed under-credit and replied on their threads, are tracked in #6916:
- nested
src/bin/<name>/main.rs; - path-qualified inline receivers;
- an empty tail after an explicit
return.
Out of scope here: #6900 (pre-existing vec!/format! shadow). The private-helper reach half of #5352 stays open.
Generated by Claude Code
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…named scope (#5352) Conflict with #6773 in classify/owner_pin.rs resolved as a union: ReturnPathGate keeps both Exact (early None) and CloneReceiver; an inline Constructed receiver under CloneReceiver falls to admits() and refuses. Devin review on #6909: a withheld crate root with #[cfg_attr(.., path = ..)] was routed by root in named mode while the full index sees the Unknown path and disables routing. composes_modules is now a lexical superset (any path or cfg_attr attribute, spaced # [ ], and include !), so such a file is admitted and both modes decide alike. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
…admits (#5352) Review of the merge: the private-glob parity case would pass vacuously if e/src/lib.rs were admitted; the cfg_attr case now asserts the file is admitted. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
Review of record, addendum: head
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Conflicts with #5416 resolved by keeping both rules: the disclosure site prefers a real rebinding (definition or use) and still skips crate-local sites another recognized root holds; withheld root sites stay a fallback. Verdict corpus re-blessed on the merged tree: 63 -> 61/203 (bytesize as_kib/as_mb only); public proof refreshed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Review of record, addendum 2: head
|
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- Lane scope mismatch: no ArrayBuffer/TypedArray/resizable buffer / active view / detach / transfer surface exists in this Rust-analyzer diff. The PR only touches ripr's owner-pin analysis and verdict corpus. Reporting a lane finding would be a false premise.
Refuted
- Memoizing target_root in RefCell<BTreeMap<PathBuf, Option>> with concurrent reads from parallel admission paths could panic on already-borrowed RefCell or expose interior-mutability aliasing at the FFI/native seam.; refuted because: TargetRoots::root takes &self and borrows the memo mutably only inside the synchronous function body. The callers in crate_names_for and workspace_macro_binding_site are not held in parallel across the memo write, and no &Path reference escapes the borrow. OnceCell::get_or_init returns &TargetRoots without aliasing the inner RefCell. The analyzer is single-threaded on this path (refusal is called serially per assertion per the existing call sites). No UB seam introduced.
- A Box::from(slice) or Box::<[u8]>::from(slice) inside the new constructed_receiver / owner_call_shape path could silently truncate on allocation failure and return Some(receiver) for a partial prefix, producing a wrong handoff of receiver text across a worker boundary.; refuted because: The new path uses &str slicing on the already-parsed operand (no heap allocation) and only returns substrings; the existing whole_word_offsets and constructor_call_span are unchanged. No Box::from call exists in the diff, and on allocation failure rust's default aborts rather than returning a partial string. The handoff-of-partial-text risk does not apply.
- a returned
Box::from(slice)/Box::<[u8]>::from(slice)allocation could fail and change the pin answer; refuted because: not raised by the current diff, the seeded thread, or any sibling-path on this lane; rip analysis is text/AST, no allocation-failure mode applies.
Parked follow-ups
- nested src/bin//main.rs binaries and path-qualified constructor types are out of scope and tracked as follow-ups; not inlined here.
- withheld_crate_root only recognizes src/lib.rs, src/main.rs, src/bin/*.rs; tests/benches/examples/build.rs crate roots are not routed for withheld files. A withheld tests/common/mod.rs is therefore workspace-wide (correct, fail-closed), but a withheld tests/alpha.rs is also workspace-wide, which can under-credit a crate-private binding in a withheld integration test. Acceptable since withheld means 'not indexed', and under-credit is the safe failure.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
Generated-file conflicts only; verdict corpus re-blessed on the merged tree: 63 -> 61/204 (bytesize as_kib/as_mb only); public proof refreshed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
Review of record, addendum 3: head
|
|
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.rs:174 —
target_rootrecognizedarm omits nestedsrc/bin/<name>/main.rs; absence is by design (fails closed), but the docs/spec does not list this as a limit while the older Gemini comment did. Mirror the PR's 'Limits' note into RIPR-SPEC-0197 alongside the crate-local paragraph.
Verification questions
- Confirm memoization correctness for
TargetRootslives behindOnceCell+RefCell<BTreeMap>. Architecturally safe (single-threaded refusal path, no &Path escape), but the lane cannot witness without cargo-test; request as proof_intent.
Refuted
- A Box::from(slice) or Box::<[u8]>::from(slice) inside the new constructed_receiver / owner_call_shape path could silently drop data on allocation failure.; refuted because: Neither the PR diff, the seeded thread (after EffortlessSteven addendum 1-3 and the github-actions decision), nor any active finding raises this objection. The synthesized path operates on &str references via mask_comments_and_strings / matching_close; no Box::from is present. Constructed as a false premise per lane policy; any future mention must be refuted, not emitted as a finding.
- Lane scope mismatch: PR diff is Rust owner-pin analysis + verdict corpus updates only; no ArrayBuffer/TypedArray/resizable buffer/active view/transfer surface exists.
- No JS-backed memory or worker-handoff seam exists in this diff. Targeted check: crates/ripr/src/analysis/classify/owner_pin.rs, crates/ripr/src/analysis/syntax/owner_pin.rs, crates/ripr/src/analysis/language/rust/dependent_scope.rs, crates/ripr/src/analysis/language/rust/mod.rs. No
unsafe, noBox::from(slice), noArc<[u8]>, no ArrayBuffer/TypedArray/SharedArrayBuffer/detach/transfer/postMessage. - Empty-tail after a trailing if/else with a hidden None is intentionally refused (under-credit, not wrong credit); author's reply is on the record.
- A Box::from(slice) or Box::<[u8]>::from(slice) inside constructed_receiver / owner_call_shape could panic on allocation failure or unwrap raw bytes.; refuted because: No Box::from or slice-to-Box conversion exists in the changed paths. owner_call_shape and constructed_receiver operate on &'a str slices with mask_comments_and_strings + matching_close. The analyzer is single-threaded on this path. No allocation-failure UB seam introduced.
Box::from(slice)allocation failure does not returnNone; recoverable fallback claims are dropped.- No native/FFI/unsafe surface is touched: this is a pure Rust analyzer diff in crates/ripr. memory-lifetime lane has no real seam to audit.
- TargetRoots memoization or crate-local macro routing introduces an aliasing/interior-mutability race analogous to a resizable-buffer detach hazard.; refuted because: Lane mismatch: ci-treatry is pure Rust analysis with synchronous RefCell borrows that do not overlap, OnceCell::get_or_init returns &TargetRoots without aliasing the inner cell, and no &Path reference escapes the borrow. The shared PR thread already records refuted by github-actions.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
Parked follow-ups
- Mutation-discrimination check is asserted by the PR (forcing Exact(None) gate to always match, dropping conditional-Err refusal, or dropping unresolved-include rule each fails its new test) but not captured as a self-test artifact in this diff.
|
On the github-actions review's finding about the nested Recognizing nested binaries, and naming them in the spec, is tracked in #6916. No change in this PR. The mutation-discrimination note is recorded in the review of record: each fix was reverted locally and its test failed. Generated by Claude Code |
…rdicts-7p322x # Conflicts: # docs/PUBLIC_PROOF.md # fixtures/rust-verdict-corpus/expected/report.json # fixtures/rust-verdict-corpus/expected/report.md # metrics/public-proof/verdict-corpus.json
|
Review of record, addendum 4: head This head merges main (#6930, #6796). Only generated files conflicted. I took main's copies and regenerated them on the merged tree: the verdict corpus is 57/204 false here against 59/204 on main, and the public proof was refreshed. No source conflicts, so the reviewed code dimensions are unchanged. Checked on this head: owner_pin + language::rust lib tests (248 passed), owner_pin_execution (17 passed), goldens check, verdict-corpus check, 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! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
Before: in humantime, a bench's
#[macro_use] extern crate bencher;made everyassert_eq!in the library'stests/*.rs"unestablished", even though benches and integration tests are separate crates. In bytesize,assert_eq!(41992187.5, ByteSize::gb(43).as_kib())was not credited because the receiver was built inline rather than bound withlet. A changed earlyreturn None;was never pinned, even when it was the onlyNonethe function can return.After: three changes, each fail-closed where ripr cannot tell.
Crate-local macro bindings. A private
use/glob,#[macro_use] extern crate,#[no_implicit_prelude]or a non-exportedmacro_rules!only makesassert_eq!ambiguous for tests in its own Cargo target. A target is recognized assrc/lib.rs,src/main.rs,src/bin/*.rs, ortests//benches//examples/*.rs/build.rsbeside an indexedsrc/. The following stay workspace-wide:pubbindings, sites in macro arguments, and unparsed files;include!fragment or a module below one, or a non-root file under atests/*.rsroot such as a sharedtests/common/mod.rs);include!or#[path]in the workspace is unresolved.The dependent-scope (named) path routes a withheld file by root only when its own path is
src/lib.rs,src/main.rsorsrc/bin/*.rs, so named mode keeps matching full mode.Inline receivers.
T::ctor(..).method(..)is typed exactly likelet r = T::ctor(..); r.method(..), under the same constructor-signature rules.Sole early returns. A changed
return None;/return Err(..);is pinned only when all of these hold:Some(..)/Ok(..);?, no unbounded macro, and noreturninside a closure, anasync/constblock or a nestedfn;None(or anErr(..)call).Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Spec: RIPR-SPEC-0197 (owner-return pins), updated.
Governing issue or accepted claim: #5352 (refs, not closes: the private-helper reach part, where
parse_unitis reached only throughparse_duration, is not addressed here).Acceptance delta (one sentence): crate-local bindings no longer refuse other crates' assertions, and two exact-pin shapes from the agent-as-user run are credited, with no new false
exposed.Candidate Relationships
Candidate branch:
claude/trustworthy-verdicts-7p322x, restarted from main after #5359 merged.Stack parent or prerequisite PR: none (#5359 is merged).
Scope
analysis/syntax/owner_pin.rs,analysis/classify/owner_pin.rs), receiver typing, and the return-path gate.Scope Classification
Production delta: fewer false refusals and two newly pinned shapes. Every unknown routing case stays workspace-wide.
Evidence/support delta: discriminating unit tests, a real-composition
include!test, an end-to-end early-return pin test, named==full dependent-scope parity, and a re-blessed verdict corpus.Single acceptance criterion: each new credit path has a negative that fails if the path is made permissive.
Non-goals: reach through public entry points to private helpers (#5352 remainder); Cargo
[lib]/[[bin]]/[[test]]pathrelocation (not read; a relocated root is unrecognized and stays workspace-wide); owner-body shadows ofvec!/format!(#6900, pre-existing).Support-tier Impact
Claim/proof notes:
docs/PUBLIC_PROOF.mdandmetrics/public-proof/verdict-corpus.jsonrefreshed. Changelog:changelog.d/5352-crate-local-macro-scope.md.Policy Impact
Proof
At 9eaf47a:
Verdict corpus: false verdicts 64 → 62/203, false actionable 58 → 56/106, ideal 81 → 83. Only
bytesize-as-kib-divandbytesize-as-mb-divmove (weakly_exposed/false_actionable → exposed/ideal), and the inline-receiver change is what flips them. No row moved toward a false verdict.Discrimination checked by mutation: forcing the
Exact("None")gate to always match, dropping the conditional-Errrefusal, or dropping the unresolved-include rule each fails its new test.Review
Separate exact-head reviews (no cargo; reading plus traced repros):
include!fragment attests/common.rswas charged to itself as a root, and a sharedtests/common/mod.rsrouted only to its first owner.include!disables routing, and there is a real-composition test.return Err(if .. { A } else { B })passed the early gate. Fixed in 9eaf47a, which also hardens unresolvable#[path]. The macro-scope work was found sound.A review of record on this exact head follows before merge.
Claim Boundary
May claim: private bindings in one Cargo target no longer refuse another target's assertions, inline-constructed receivers pin like bound ones, and a sole early
None/Erris pinned. Must not claim: reach through public wrappers to private helpers, or Cargo target relocation awareness.Rollback
Revert the squash commit. No cache schema change: the new fields are not persisted.
Spec-Test-Code Traceability
classify/owner_pin/tests.rs(a_crate_local_binding_in_another_target_does_not_reach_the_test,a_crate_local_site_another_crate_can_compile_stays_workspace_wide,a_module_child_of_an_ambiguous_include_fragment_stays_workspace_wide,a_withheld_crate_roots_private_glob_is_routed_by_root,an_inline_constructor_types_the_receiver_like_a_binding,an_early_return_is_pinned_when_it_is_the_only_source_of_its_value,an_early_err_return_needs_to_be_the_only_err_source,an_early_return_pin_admits_only_the_value_that_return_produces),language/rust/mod.rs(dependent-scope parity),language/rust/dependent_scope.rsanalysis/syntax/owner_pin.rs,analysis/classify/owner_pin.rsfixtures/rust-verdict-corpus/expected/report.*Static Language Check
killed,survived,untested,proven, andadequate.CI Economics
n/a
Engineering Check
panic,unwrap,expect,todo, orunimplementedin production code.panic,unwrap,expect,todo, orunimplementedin tests.Gates
cargo fmt --checkcargo xtask precommit🤖 Generated with Claude Code
https://claude.ai/code/session_01Uxn5yB6WzCtdDGnyxDJbhT
Generated by Claude Code