Repository navigation
perf(check): store module item scopes in file facts; memo helper oracles (#5363) - #6993
Conversation
Parser-backed file facts now carry the compact module item scopes that same-file helper crediting reads, so a warm run no longer reparses every test file, and each helper body's assertions are parsed once per run instead of once per calling test. File-fact cache schema 1.31 -> 1.32. On ripr-swarm (pin 7c64b9c) the warm check drops from about 6 s to about 4.4 s with byte-identical JSON (#5363). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y7KT6sUzaJXqPAehHnLJQC
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (13)
🔗 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; 0 remain after this review. Summary by CodeRabbit
WalkthroughThe parser now stores compact module item scopes in file facts. Same-file assertion helper crediting reuses those scopes and caches parser-backed helper results. The file-fact cache schema advances to 1.32. ChangesStored module item scopes
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to The scope cache preserves the checked fallback behavior, and no issue remains that would prevent merging after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change is limited to cached analysis metadata and per-run memoization. Existing helper eligibility checks and cache invalidation remain in place. No introduced security issue was established, but correctness still relies on trusted cache writers. Retained concerns Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❓ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 10 files. (3 skipped: 2 unsupported, 1 too large.) ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
A rabbit found scopes tucked away, Comment |
There was a problem hiding this comment.
Code Review
This pull request optimizes the performance of ripr check on large workspaces by storing each file's compact module item scopes in the parser-backed file facts, eliminating the need to reparse test files on cache hits during same-file helper crediting. Additionally, helper bodies are now parsed once per run rather than once per calling test. These changes require bumping the file-fact cache schema version to 1.32. There are no review comments, and the implementation is clean and well-tested.
There was a problem hiding this comment.
Decision
- Needs verification checks before upstream.
Verification questions
- Confirm helper_oracles memo key omits a body digest, so two files with same (name, start_line) could collide.
- Confirm the serialize_struct field-count literal was bumped to 11 but the struct has 12 named fields (path, functions, tests, module_declarations, unresolved_property_macros, role_provenance, source, item_scopes, plus tests, functions). The count is a hint to serde_json and not validated, so it is not a bug, but it is a lying comment-magnet: future field additions will silently keep the wrong hint.
Refuted
- Boxed Option<Box> on FileFacts is an unbounded memory bloat on large files because the cache keeps every parsed scopes struct resident.; refuted because: retain_names trims direct_calls and bound_names to function-names-plus-call-names; FnItemScope is one enum row per fn. On ripr-swarm peak RSS is unchanged at ~456 MB per the PR body measurement; Box keeps the None case zero-cost and the Some case a single heap allocation shared via Arc-style reuse across the FileFacts field.
- FileFactsView serializer declares 11 fields but tests in transitive_reach/ra/lexical_test_grip construct FileFacts via fields; serde counts struct fields, not wire tuple, so the literal is unused but harmless.
- The helper_oracles memo key (file, helper.start_line, helper.name) is not unique when a file contains a nested fn and a top-level fn with the same name and same start line, or when a name is duplicated across modules with same start line — memo could serve the wrong assertions.; refuted because: unique_assertion_helper already requires exactly one definition per name in the file, and the diff comment states this. The triple key plus the unique-per-name precondition makes the key a singleton in practice; even if two distinct helpers shared the key, the OR insertion would still produce the same oracle set since both helpers would have parsed the same body.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
Review of recordHead: Angles reviewed:
Findings: nothing blocking. Two optional notes from the reviewer agent stay as they are:
Merging. Generated by Claude Code |
Requested by Steven · memory efficiency thread
Summary
Before: on every warm
ripr check, same-file helper crediting reparsed each test file to find module scopes, and reparsed a helper body's assertions once per test that called it. On ripr-swarm (pin 7c64b9c, 4 cores) that phase took about 1.4 s of a 6 s warm check.After: the parser producer stores each file's compact module item scopes in the file facts, the file-fact cache keeps them (schema 1.31 to 1.32), and helper oracles are parsed once per run. The helper phase drops to about 0.4 s, the warm check to about 4.4 s, and the JSON output is byte-identical to main's.
How:
ModuleItemScopesgets a row-form serde wire (one row per fn) because its tuple-keyed maps cannot serialize as JSON object keys.retain_namestrims the stored call and binding sets to names that crediting can ask about (the file's function names plus their call names).FileFacts.item_scopes: Option<Box<ModuleItemScopes>>(boxed to keepFileFactssmall). It isNonefrom the lexical fallback and from hand-built facts, and in that case crediting parsessourceitself as before.unique_assertion_helperalready requires one definition per name in the file, so the key names one body.Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Governing issue or accepted claim: #5363 (warm check on ripr-swarm), after #6977.
Acceptance delta (one sentence): a warm check skips the per-test-file reparse in helper crediting and keeps identical output.
Candidate Relationships
Candidate branch:
claude/memory-efficiency-p9g94v, restarted from main 4233a0a.Stack parent or prerequisite PR: none. #6969 caches macro sites and does not touch this pass.
Scope Classification
Production delta: stored scopes in file facts plus the file-fact cache, and a helper-oracle memo.
Single acceptance criterion: helper crediting gives the same answers from stored scopes as from a fresh parse.
Non-goals: the
cached_parseintegrity digest (about 0.9 s) andtest_styles(about 0.5 s). #5363's 2 s bar is not reached yet.Support-tier Impact
Policy Impact
Proof
Measurement:
ripr check --root . --base HEAD~1 --format jsonon ripr-swarm pin 7c64b9c, withRIPR_REPO_EXPOSURE_LATENCY_TRACE=1.The JSON is byte-identical (
cmp) to a main build's output on the same pin. Peak RSS is unchanged at about 456 MB.New test
the_parser_stores_the_scopes_crediting_would_parse_and_the_cache_keeps_themchecks four things:module_item_scopesparse on every map crediting reads;retain_namesdrops an unrelated binding;Claim Boundary
May claim: a warm check is faster on ripr-swarm by about 1.5 s with identical output.
Must not claim: #5363's 2 s target or any cold-run improvement. The first run after upgrade is slower once, because the file-fact cache is rebuilt.
Rollback
Revert the squash commit. The cache schema goes back to 1.31, and 1.32 entries are rebuilt.
Engineering Check
panic,unwrap,expect,todo, orunimplementedin production code.panic,unwrap,expect,todo, orunimplementedin tests.CI Economics
n/a
🤖 Generated with Claude Code
https://claude.ai/code/session_01Y7KT6sUzaJXqPAehHnLJQC
Generated by Claude Code