Skip to content

perf(check): walk a per-file node list in the macro-binding site scan - #10248

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

EffortlessSteven merged 3 commits into
mainfrom
claude/project-thread-2r5n5n

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Summary

The macro-binding site scan walked every syntax node of a file once per queried name set (the union query, then one per looked-up name), plus further full walks for the call fixpoint, drop_in_shadowed and plain_import_names. Every check in those loops is a node-kind cast, so other nodes are no-ops. BindingFreeFileIndex::collect, which already walks each tree once, now also records the relevant nodes in source order (site_nodes, call_nodes); the scan iterates those lists. Order is preserved, so output is identical by construction.

Measurement (cargo pin f3865b2a, ripr check --base 0c38e943 --mode draft, 4 paired warm runs, shared container)

Governing issue or accepted claim: #9794 (warm check on cargo's pinned commit toward 2 s)
Acceptance delta (one sentence): Cuts the macro-binding scan's tree walks to one per file, about 13% faster warm check on the cargo pin with identical findings; the 2 s target is still open.

Test plan

  • cargo test -p ripr --lib: 14154 passed, 1 failed (fallible_literal_full_and_compact_warm_caches_invalidate_changed_inputs, env-dependent, also fails on main).
  • cargo xtask precommit passes.
  • New case use foreign::serde_json; in literal_json_namespace_in_another_source_file_stays_uncredited; dropping USE_TREE from the recorded kinds makes it fail.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QpthemXVhr2eDVUDseqUKd

@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

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 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 168 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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: e8f12589-f5d6-4dc8-a2cd-3c91ee69a730
Commits

Reviewing files that changed from the base of the PR and between feea378 and 88b5b8d.

Files selected for processing: 3
  • changelog.d/9794-macro-scan-node-lists.md
  • crates/ripr/src/analysis/classify/owner_pin/tests/json_construction.rs
  • crates/ripr/src/analysis/syntax/owner_pin.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Copy link
Copy Markdown
Member Author

Independent exact-head source/runtime receipt for #10248

No actionable source defect found in the per-file node-list slice. This is focused local proof; disposition remains REVIEW_INCOMPLETE for hosted/combined-tree qualification.

Subject (re-read unchanged before this receipt):

  • Head: 06a77606f8f153bc591d13b3521c6ab4ce916117; tree: add139eeb92d58bdf23298c68961366dc15d5ebd.
  • Observed GitHub base: ce536ef39e71099065083ce41af7167af7a457da; tree: 713e9bed66e5066aa23793a2373cbf342011a0d4.
  • Actual merge-base/head parent: 7b1fc8d84edaef28ef9e6c7d43cf3d02ef7607d1. Its scan function supplied the old full-tree differential oracle. The base delta leaves the syntax scan and Cargo.lock unchanged; unrelated classification edits do not establish combined-tree proof.
  • Canonical writer remains EffortlessSteven / claude/project-thread-2r5n5n. No implementation branch or author-tree write was made. No submitted reviews/inline threads were visible; Conversation contained only bot quota notices. No task-management connector is available to certify unlinked worker state. Existing ub-review/wheel runs were observed in progress, not duplicated or credited as passes.

Inspected: both changed files; collect/scan/helpers; union/singleton queries; caller path attachment and retained-site selection. All reactive kinds are retained in descendant order, including Rename/Module/UseTree for namespace/drop-in shadowing, MacroRules/MacroDef, Attr/Use/ExternCrate/MacroCall, and TokenTree for nested calls. Unknown-parse handling precedes collection and is unchanged. The lists belong to one parse, with no path-keyed sharing.

Executed with installed Rust/Cargo 1.95.0, PATH prefix /workspace/.rustup/toolchains/1.95.0-x86_64-unknown-linux-gnu/bin, CARGO_HOME /workspace/.cargo, isolated target /workspace/review-10248-target:

  • Temporary reviewer test: cargo test --locked -p ripr --lib review_10248 -- --nocapture, exit 0: 954 cleanly parsed source/crafted files, 19,080 union/single-name/context queries, 2,295 nonempty results. Complete ordered Debug records (names, lines, kinds, scopes, crate-local flags) matched the old function.
  • Instrumented cargo test --locked --offline -p ripr --lib review_10248 -- --nocapture: the parity and removal/order tests passed. On 208 bounded files / 4,160 queries, actual iteration counters in the two replaced primary loops recorded old 30,859,700 versus indexed 713,880 visits (97.69% fewer). This excludes helper/token/fixpoint-body work and does not imply a corresponding end-to-end speedup. Clearing site_nodes, reversing site_nodes, and clearing call_nodes each produced an output mismatch against the unchanged baseline.
  • That combined invocation exited 101 because my repeated-path fixture compared unequal setup: fresh indices composed package/target-role metadata and reused indices did not. After matching both setups, cargo test --locked --offline -p ripr --lib review_10248_repeated_path_and_unknown_roots -- --nocapture exited 0. Eight successive insert/replace requests on the same path (including malformed source), every trusted name, and known/None/unindexed roots matched fresh-index results. The failed fixture outcome is retained, not attributed to this PR.
  • Four existing filters, each through cargo test --locked --offline -p ripr --lib <filter> -- --nocapture, each exit 0: binding_free_index_is_collected_once_per_file_not_per_macro (1), a_refusal_site_lookup_matches_the_replaced_scan_for_every_name_and_root (1), the_workspace_site_is_the_first_rebinding_in_path_order_else_the_first_site (1), retention_parity (8).
  • Initial offline setup exited 101 for uncached locked oxc_ast_visit; authorized locked registry resolution then succeeded. No toolchain installation or denied-path retry occurred.

Proof-only local trees: instrumented b20fe84c9af32250a20a7d9449c0a48296db73c0, corrected fixture e5c9afe12b5004c518843105a4b65824aba66ba1; these are local experimental objects, not submitted commits. Corrected patch SHA-256: 9442653397d1bb72e835a03aa9a16a1e8a21c07efe4d2125d2ead86fa7a2328c. Experimental source edits were restored; git diff --exit-code returned 0 at the reviewed head.

Limits/next action: no cold/warm CLI byte-parity, RSS, wall-time, full-suite, hosted checkout, required-gate completeness or current combined-tree qualification is claimed. PR-body timings remain reported observations, and #9794's 2 s target remains unmet. The canonical delivery owner should consume this focused proof, reconcile the current integration subject and existing qualification receipts, and address only any concrete remaining delta before normal qualification. No dispatch, Ready, merge, release or protection action was taken.

@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 former full-tree scans are narrowed to site_nodes and call_nodes, so equivalence depends on the new kind allowlist covering every node consumed by macro_binding_sites_in_tree.
  • Confirm security-relevant import, rename, extern-crate, macro, and attribute paths remain represented in site_nodes; missing kinds could silently weaken binding analysis.
  • Confirm the changelog claims byte-identical findings, but the PR-reported validation is from a separate cargo-pin run rather than a differential test proving equivalence of the selected node lists.
  • Confirm the performance claim that findings remain byte-identical depends on preserving source order in both cached lists; the diff collects nodes during one descendants() traversal, which appears order-preserving.
  • Confirm the new site_nodes list is manually restricted to EXTERN_CRATE, RENAME, MODULE, USE_TREE, MACRO_RULES, MACRO_DEF, ATTR, USE, and MACRO_CALL, while the old scan considered every descendant and dispatched by AST casts.
  • Confirm the new site-node filter may omit extern-crate alias nodes if their AST kind is not among the explicitly matched kinds.
  • Confirm the changed implementation has no focused test proving equivalence between the old descendants-based scans and the curated site_nodes/call_nodes traversal.

Refuted

  • The failed cargo-test proves this performance refactor breaks existing behavior.; refuted because: The PR identifies the sole failure as environment-dependent and reproducing on main, so it is not evidence that this diff changed behavior; the actual cargo-test receipt remains pending.
  • The cached SyntaxNode values may create a worker/async/GC lifetime or ownership hazard.; refuted because: No worker, async, JS, GC, detach, or transfer boundary exists in the changed path. The nodes are owned by BindingFreeFileIndex and consumed synchronously while its source tree remains available.

Evidence gaps

  • The ripr sensor failed with exit code 2, and the late cargo-test receipt was not included in the provided packet, leaving executable confirmation of behavior and ordering pending.
  • The PR provides only indirect evidence for the behavioral claim: byte-identical findings are reported in the body, while cargo-test evidence is late and one lib test fails for an environment-dependent reason.
  • Model proof intent was rejected by deterministic validation.

Copy link
Copy Markdown
Member Author

Review of record, head 3fa5adafb445e6f214bec18a78bea71507ebea8e (code identical to 06a77606 except one added test case).

Angles:

  • Equivalence (independent agent, read-only): every node kind the site loop, json_namespace_rebound, drop_in_shadowed and the call fixpoint react to is in site_nodes/call_nodes; lists are built in one preorder pass before any continue, so order is preserved. No counterexample.
  • Tests, memory, callers (independent agent): all reactive kinds have discriminating tests except the UseTree arm of json_namespace_rebound; the index is per file and dropped after its scans; collect has one caller. Finding: the UseTree arm was untested. Resolved in 3fa5adaf: added use foreign::serde_json; to literal_json_namespace_in_another_source_file_stays_uncredited; mutation check (dropping K::USE_TREE from the recorded kinds) makes it fail, restored it passes.
  • Independent exact-head receipt by EffortlessSteven (comment above): differential run against the old walk, 19,080 queries over 954 files, ordered records identical; removing or reordering the lists produces mismatches.

Own proof: cmp of full ripr check JSON on the cargo pin, base vs head, identical; cargo test -p ripr --lib 14154 passed with the single known env-dependent failure that also fails on main; cargo xtask precommit passes on 06a77606.

Measurement (cargo pin, 4 paired warm runs, shared container): wall 3.8–4.25 s to 3.16–3.67 s, CPU 7.5–8.1 s to 6.05–6.9 s, RSS 133–135 MB to 134–141 MB. The 2 s target is not met by this PR.

Gemini and CodeRabbit reported quota limits, so their review is missing, not clean. Marking ready and requesting the required check.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 25, 2026 06:33
@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 one verification check before upstream.

Verification questions

  • Confirm the explicit SyntaxKind allowlist creates a maintenance coupling: adding a new dispatch arm to macro_binding_sites_in_tree without updating BindingFreeFileIndex would silently exclude it.

Refuted

  • The per-file node lists may behave like a stale or detached active view after the backing syntax tree changes.; refuted because: Each retained item is an owned SyntaxNode clone collected from the tree being indexed, and this diff introduces no mutation, resizing, detachment, transfer, or cached length operation for those vectors.
  • Collecting cloned SyntaxNode values could cross a JS worker handoff or require unsafe/GC ownership handling.; refuted because: The changed surface is Rust syntax analysis only. No worker handoff, JS object, asynchronous capture, GC, detach, or transfer operation is introduced or modified; ordinary Rust clone/drop semantics apply.
  • Moving the site scan to a selected node list changes its architectural scope or duplicates the existing uses index.; refuted because: site_nodes is a distinct reactive-node stream; uses remains a specialized UseTree collection used by plain_import_names, with no competing ownership of the binding scan.
  • The optimization could create a denial-of-service or unbounded-work regression through repeated AST traversal or hidden state.; refuted because: The change replaces repeated full descendants() scans with per-file vectors populated during one traversal; the lists are bounded by the source tree and are consumed by the existing bounded scans.

Evidence gaps

  • The full behavioral oracle remains partially dependent on pending or failed evidence, so the lane cannot independently certify repository-wide equivalence.
  • Model proof intent was rejected by deterministic validation.
  • The changelog's byte-identical and approximately 13% performance claims are not independently substantiated by the supplied receipts because the ripr sensor failed.

Copy link
Copy Markdown
Member Author

CI note on 3fa5adaf: the only failing gate is cargo xtask goldens check (job "Ripr Rust Small on GitHub Hosted / Rust gates"), reporting human-full.txt drift on 14 fixtures (13 Python fixtures plus rust_qualified_foreign_receiver). It is not this PR's: it adds Next: lines from RIPR-SPEC-0319 (#9449) that fixtures from #10235 landed without, and it reproduces on main at 8d5d0d0 (this PR touches no fixture or output code; all other gates in that job passed up to goldens). The fix of record is #10269 (re-bless of those 14 fixtures; #10273 is a duplicate). I am not porting 28 golden files into this PR. Once #10269 merges I will merge main here and re-apply merge-ready.


Generated by Claude Code

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

@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

@EffortlessSteven
EffortlessSteven merged commit 7391513 into main Oct 25, 2026
51 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/project-thread-2r5n5n branch October 25, 2026 09:21
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