Repository navigation
refactor(analysis): share per-file source snapshot facts across owner-pin queries (split 1 of #9611) - #10380
Conversation
Move complete-source declaration, name-scope, item-nesting and module-shadow answers onto an immutable per-file SourceSnapshot owned by the index, and share the owner-pin file scope table across short-lived syntax owners. Verdict neutral: verdict-corpus reports are byte-identical to main. Includes the intentional tightenings from the larger candidate (same-named functions on one line yield no scope, function type parameters enter `defines`, the per-test identity memo is keyed by test name); none moves a corpus row. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Z4QZYyfpcDLn8oANQJT1z
|
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 42 minutes. View limit details
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Source snapshot and scope queries crates/ripr/src/analysis/syntax/*, crates/ripr/src/analysis/facts/index.rs |
RustIndex stores source-syntax memos. Snapshots cache parsed syntax and lexical query results. Name-scope lookup includes function type parameters and rejects ambiguous same-line matches. |
Owner-pin snapshot and shadow checks crates/ripr/src/analysis/classify/owner_pin.rs, crates/ripr/src/analysis/classify/owner_pin/tests.rs |
Owner-pin queries use indexed snapshots and shared file-scope tables. Type and trait shadow checks memoize answers and use owner identity in their queries. Tests cover cache reuse, source changes, and ambiguous declarations. |
Call identity and shadow-check callers crates/ripr/src/analysis/classify/call_identity.rs, crates/ripr/src/analysis/classify/related_tests.rs, crates/ripr/src/analysis/classify/related_tests/equality_dispatch.rs, .ripr/traceability.toml, changelog.d/8004-source-snapshot-shared-lexical-facts.md |
Call-identity keys include test names, and test scopes use the index’s source-syntax cache. Related-test callers pass owner scopes and the index to shadow checks. The traceability entry and changelog describe the changes. |
Priority:
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Refactor
Merge Risk: 
Minimal · up to b3979
-
No actionable regression was established for this change. It is ready for normal validation before merging.
Pre-merge checks: 
3 · 
1 · 
1
-
Failed checks: 1 warning · 1 inconclusive Passed checks: 3 passedFull details: Description check
-
Explanation
The description gives detailed scope, candidate relationships, proof results, and rollback details, but it omits or leaves incomplete many required template sections, including Swarm / Source Boundary, Scope, Support-tier Impact, Policy Impact, Claim Boundary, Spec-Test-Code Traceability, Static Language Check, CI Economics, Engineering Check, and Gates.
Resolution
Complete the missing template sections. State the swarm boundary, production and evidence deltas, acceptance criterion, non-goals, support and policy impact, claim boundary, traceability entries, static-language status, CI Economics as n/a if applicable, engineering checks, and each applicable gate result. Add the required source-of-truth links or explicitly mark them as unavailable.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 33 functions across 6 files. (5 skipped: 2 unsupported, 3 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
I’m a rabbit with a syntax tree to roam
I cache each snapshot close to home
When names collide, I won’t choose one
I share scope facts, then hop along
Fresh source gets a fresh burrow
And tests keep watch as I go furrow
Comment @coderabbitai help to get the list of available commands.
|
Review of record, head Angles: the three declared tightenings, memo/cache soundness, dead code and attributes, leakage from the identity gate, and existing consumers. Findings: no blocker or major.
Proof (reviewer-run, exit 0): Gaps: the perl, python and typescript corpora and Currentness: main has moved since and a test merge conflicts in Generated by Claude Code |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Z4QZYyfpcDLn8oANQJT1z
|
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.
Decision
- Needs one verification check before upstream.
Verification questions
- Confirm the owner-shadow tests strongly exercise the new cache contract, but do not independently demonstrate that the old implementation produced the opposite shadow verdict.
Refuted
- The diff introduces an ArrayBuffer/TypedArray resize, detach, transfer, or stale-length vulnerability.; refuted because: No such APIs or analogous mutable backing-store length operations occur in the changed Rust source; this is a source-analysis cache refactor instead.
- The TestKey change can alias distinct callers sharing a file and start line.; refuted because: The key now includes the test name as well as file and start line, and the snapshot scope key additionally includes end line; tests exercise distinct same-line names through shadow-query identity.
- The changed owner-pin consumers introduce an unscanned sibling route that still bypasses the shared snapshot.; refuted because: The reviewed changed call sites route file scopes, nesting, async declarations, name scopes, and shadow checks through SourceSnapshot; the related_tests callers were updated to provide the required index and owner identity. This is bounded to the changed helper group, not proof that unrelated future call sites cannot exist.
Parked follow-ups
- The shared snapshot has sibling consumers for complete-source facts, but owner-pin shadow checks still maintain a separate memo and therefore are not fully consolidated.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
- The full red/green verdict-neutrality claim remains dependent on the writer-run corpus receipts because this packet's ripr sensor failed and cargo-test is only scheduled.
- The PR claims verdict neutrality and identical corpora, but the available review evidence does not independently verify the current head because ripr failed and heavy proof was skipped.
- Executable confirmation remains dependent on the failed ripr run and the late cargo-test/corpus receipts.
- Current-host regression evidence is incomplete in the supplied packet.
|
|
Resolve equality_dispatch.rs against main's type_scope_is_clear extraction by threading the snapshot index through the extracted helper. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Z4QZYyfpcDLn8oANQJT1z
… break Byte-identical to the fix of record in #10351; drops out when that lands. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Z4QZYyfpcDLn8oANQJT1z
|
Head moved to 91ea672. The previous required run (88354c2) failed only The main merge also resolved a real conflict: main extracted Generated by Claude Code |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- Owner-module exemption is now derived from the first matching owner function and its first module, unlike the removed byte-exact owner_enclosing_module logic.
Verification questions
- Confirm the seeded review question asks whether owner-shadow tests prove the old implementation produced the opposite verdict; current tests prove cache behavior and ambiguity handling but do not directly assert that historical contrast.
- Confirm the new shadow-answer key includes owner path/name/start-line, but not owner end-line or an unambiguous owner identity.
Refuted
- The diff introduces an active-view resize, detach, transfer, or stale-length vulnerability.; refuted because: The changed code is Rust source-analysis caching over immutable strings and parsed syntax; it contains no ArrayBuffer/TypedArray APIs, mutable backing-store length operations, or detach/transfer semantics.
- Sharing immutable source snapshots could alias mutable JS-backed memory across worker, async, GC, detach, or transfer boundaries.; refuted because: The sharing domain is only Rust source strings and immutable parser/lexical facts. No JS object, buffer, task, or ownership-transfer boundary is involved.
- A missing cargo-test receipt prevents any oracle assessment.; refuted because: The seeded PR body reports exact-head cargo test, goldens, and verdict-corpus success, while the current packet explicitly schedules cargo-test late before the gate; this lane has no contradictory test evidence.
- The new architecture creates an unbounded or insufficiently scoped shared cache.; refuted because: The snapshot is run/index-local, source identity is checked before reuse, and query memos are keyed by complete relevant identity; no public cross-run or cross-source cache boundary was found.
- The refactor introduced an exploitable memory-safety or denial-of-service primitive through shared mutable state.; refuted because: The changed code uses immutable Arc-backed snapshots with synchronized memo tables, and no unsafe blocks or unbounded attacker-controlled allocation path was introduced; unsafe-review found no new gaps.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
- Broad caller coverage for the changed shared-snapshot routes is not independently demonstrated by the lane packet, despite updated call sites and focused unit tests.
|
Reply to the github-actions review on 91ea672 ("owner-module exemption is derived from the first matching owner function and its first module"). Checked against source; behavior matches the removed
The verdict-neutrality proof for this PR is the unchanged goldens, verdict-corpus Generated by Claude Code |
|
Required run on 91ea672 failed one test: Generated by Claude Code |
|
|
Main now carries its own python_caplog golden re-bless; take it over the port. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Z4QZYyfpcDLn8oANQJT1z
There was a problem hiding this comment.
Verification questions
- Confirm shadow-answer caching appears keyed by all query-dependent inputs, but owner end-line and owner identity beyond name/start-line are not included.
- Confirm the new owner-module derivation selects the first matching function’s first module rather than directly using byte-exact function ancestry.
- Confirm the owner-shadow tests prove the new cache contract, but do not establish that the old implementation returned the opposite shadow verdict for the owner-module exemption.
- Confirm owner-shadow tests establish current cache identity and ambiguity behavior, but do not directly assert that the removed historical owner-module logic produced the opposite verdict.
- Confirm several snapshot tests are implementation-coupled rather than behavior-discriminating: they assert pointer identity and computation counts, which can pass even if the cached answer differs from the historical verdict.
- Confirm async declaration answers are cached under (id,name,start,end), but computation resolves only by name and line, so distinct symbol ids at one name/line are not independently disambiguated.
- Confirm the shared source snapshot is the intended sibling route for lexical facts, but the owner-pin file-scope cache still has a separate source-identity guard and can recompute rather than reuse the snapshot's lexical items.
Refuted
- The shared snapshot boundary leaks analysis-specific owner semantics into a general syntax layer.; refuted because: The snapshot exposes complete-source lexical facts and typed query inputs while owner_pin retains the owner-specific exemption policy; related_tests now passes the owner explicitly instead of pre-resolving an owner module. This keeps the boundary narrower than the removed owner_enclosing_module implementation.
- The shadow cache key can alias distinct callers or owners.; refuted because: The key includes caller name, start/end coordinates, declaration base, kind, and owner file/name/start; source replacement is guarded by source pointer identity.
Evidence gaps
- The advertised architecture refactor lacks a successful current cargo-test receipt; ripr itself failed with exit code 2.
- The lane cannot establish exhaustive sibling-path coverage or verdict neutrality because the ripr sensor failed and scheduled cargo-test evidence was not supplied.
- Model proof intent was rejected by deterministic validation.
Keep both module declarations (source_snapshot, constant_return re-export). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Z4QZYyfpcDLn8oANQJT1z
|
|
Drops the stale mocks argument #10488 removed from collect_tests_from_statements; byte-identical to the fix of record, drops out when #10510 lands. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Z4QZYyfpcDLn8oANQJT1z
There was a problem hiding this comment.
Confirmed findings
- crates/ripr/src/analysis/classify/owner_pin.rs:13345 — Preserve the old byte-exact owner-module semantics in the shared snapshot path, or add focused parity tests comparing the new first-match/first-module derivation with the removed implementation for nested, same-line, and ambiguous owners. The current tests validate cache behavior and selected outcomes but not this boundary's historical equivalence.
Verification questions
- Confirm the PR claims verdict neutrality, but no changed test compares the merge-base implementation with HEAD on discriminating inputs.
- Confirm owner-module exemption is now derived from the first matching function's first module, replacing the removed byte-exact ancestry lookup; the new tests exercise ambiguity and cache keys but do not directly assert parity with the old implementation.
- Confirm the owner-shadow tests do not independently demonstrate that the removed historical owner-module logic produced the opposite verdict.
- Confirm owner shadow answers are cached by owner file/name/start-line but not owner end-line, while the prior owner-module resolution depended on the owner function's exact AST ancestry.
- Confirm the new owner-module exemption depends on the first matching function and its first module range, but the historical implementation used the resolved owner function's nearest enclosing module directly.
- Confirm the source-snapshot route covers the principal changed lexical consumers, but non-lexical sibling routes remain outside this focused scan.
- Confirm the PR claims verdict neutrality, but its added tests primarily prove cache identity, ambiguity handling, and current outputs rather than a direct differential against the removed implementation.
- Confirm the snapshot cache is shared through RustIndex.source_syntax, but owner_pin file scopes retain a separate per-index owner_file_scopes memo keyed by path plus source Arc identity; this duplicates lexical ownership and relies on two cache layers for consistency.
- Confirm the changed related-test and equality-dispatch callers pass owner identity and index into shared shadow queries, but other sibling call sites are not independently enumerated in the diff packet.
- Confirm owner-shadow tests assert current cache semantics and ambiguity handling but do not directly establish that the removed byte-exact owner-module logic returned the opposite verdict.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
…s that also pass pre-refactor The rows (owner shares the type's module, owner in a sibling module, nested owner, ambiguous owner) give identical verdicts on main's byte-exact owner_enclosing_module and on the snapshot derivation. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Z4QZYyfpcDLn8oANQJT1z
|
Head 5d69310. Response to the github-actions finding at Generated by Claude Code |
There was a problem hiding this comment.
Verification questions
- Confirm owner-module exemption is derived from the first unique matching function's first module rather than byte-exact owner ancestry.
- Confirm the PR states verdict neutrality, but the new tests primarily prove cache identity, computation counts, and selected current outcomes rather than comparing merge-base and HEAD verdicts on discriminating inputs.
- Confirm owner-module exemption now derives from the first uniquely matched function's nearest module, while shadow keys omit owner end-line and exact AST identity.
- Confirm snapshot sharing is used by owner-pin, call-identity, related-test, and equality-dispatch routes, but the scoped review did not establish exhaustive coverage of all legacy parse-and-scope helpers elsewhere in the crate.
- Confirm owner-module tests are outcome-only, not historical differential oracles.
- Confirm shadow cache keys omit owner end-line even though owner function lookup uses both start and end coordinates; this can alias distinct owner functions with identical file/name/start-line but different spans.
- Confirm the owner-module exemption test locks in intended outcomes but cannot itself demonstrate red/green behavior because those expectations are also valid on the old implementation.
Refuted
- The new snapshot tests are only smoke or pointer-identity assertions and cannot detect stale answers.; refuted because: They change source, clone/remove entries, mutate query keys, count recomputations, and assert opposite outputs for replacement versus original, which is behavior-discriminating.
- Shared source snapshots can cross JS-backed memory, worker, GC, detach, or transfer boundaries.; refuted because: The changed implementation is Rust-only: it stores immutable Arc source, parsed syntax, and memoized lexical facts in RustIndex. No JavaScript runtime, backing-store ownership, detach/transfer operation, or unsafe mutation is introduced.
- Sharing an Arc-backed immutable snapshot could introduce lifetime or ownership unsoundness.; refuted because: The changed code shares Arc-owned immutable strings, parsed trees, and memo results; consumers clone Arcs and do not expose mutable interior state.
Evidence gaps
- The seeded review already supplies differential evidence for the owner-module boundary, but the failed ripr sensor means no new successful ripr receipt independently corroborates the PR's verdict-neutrality claim.
- Model proof intent was rejected by deterministic validation.
Review of record, head
|
Source-of-truth Links
Governing issue or accepted claim: #7415 (split of #9611 / #8004 to fit the 3000-line admission cap)
Acceptance delta (one sentence): Owner-pin shadow, async and scope queries read shared immutable per-file source snapshot facts instead of re-parsing, with no verdict change: goldens and all four verdict corpora are identical to main.
Summary
Before: #9611 carried this refactor together with the inherent-receiver identity gate, about 3052 counted lines before the withhold work, over the admission cap.
After: this PR is the verdict-neutral refactor only (1249 counted lines vs main).
source_snapshot.rs(new),name_scope.rs, and the call_identity / owner_pin consumers read the shared snapshot;owner_enclosing_moduleis removed. Nothing is dead code and no#[allow]is added. The identity gate (requires_inherent_receiver_identityand its helpers),parse_fragment, the same-file free-helper identity and the test_grip changes are not in this PR; they land in the next PR of the series, which also contains the reviewed receiver-unestablished withhold so the two serde rows never readgapon main.How: hunks taken from #9611's head
a45614b88, applied onto main with a three-way merge. Three intentional tightenings are included and were measured against the corpus: same-named fns on one line return no scope, fn type params go intodefines, andTestKeyincludes the test name. None moved a row.Series order: this PR, then identity gate plus withhold (PR2, from #9611 / #10171), then hardening tests and prose (PR3).
Candidate Relationships
Candidate branch: claude/split-8004-pr1-snapshot
Stack parent or prerequisite PR (if any): none (lands first)
Proposed replacement of PR (if any; not yet accepted): replaces part of #9611
Acceptance retained from a replaced candidate (if any): the verdict-neutral snapshot hunks of #9611
Scope Classification
Review
Independent exact-head review of
4c7bd5fcefound no blocker or major (record on the PR). Headb3979ddb2c6b12509885a597e11c9a8067ec3d85(tree759bac9cde4c50187af0e1539a68b3c99bcef533) is that head plus a merge of main237fa0aa9; the one conflict (related_tests.rs, main's extractedimpl_identity_is_shadowed) was resolved by taking main's side and applying PR1's three call-site changes. The diff of that file against main is exactly those hunks.Proof
Writer-run on the merged head:
cargo fmt --check0;cargo check -p ripr --all-targets0;cargo test -p ripr --lib14612 passed, 1 ignored;cargo xtask goldens check0;cargo xtask verdict-corpus check-all0 for all four corpora, with output identical to pristine main (Rust 670 cases, 3 false verdicts, 0 contradictions);cargo xtask precommit0.Rollback
Revert the squash commit.
🤖 Generated with Claude Code
https://claude.ai/code/session_017Z4QZYyfpcDLn8oANQJT1z