Skip to content

perf(index): allocate function membership IDs at their own size - #5137

Merged
EffortlessSteven merged 11 commits into
mainfrom
perf/compact-file-function-membership
Oct 4, 2026
Merged

EffortlessSteven merged 11 commits into
mainfrom
perf/compact-file-function-membership

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Summary

Rust 1.95 reuses the consumed Vec<FunctionFact> allocation when insert_file maps facts into small IDs with collect. File-local function memberships consequently retain fact-sized buffers. Allocate their ID vector explicitly at the number of functions, then move facts into the existing canonical arena in the same order.

Swarm / Source Boundary

  • repair or follow-up for a same-repo swarm PR

Ordinary analyzer development; no release, credential, workflow or packaging change.

Source-of-truth Links

Resource parent: #3794. Existing generation-owned fact authority: #5026 / #5109. Contract: RIPR-SPEC-0153.

Related #4996 raw-source ingestion, #4997 seam collection, #4999 shard writing and #5000 Git ingress retain their own acceptance and ownership. This PR completes none of those claims and does not replace #5030.

Candidate Relationships

Branch: perf/compact-file-function-membership.
Head: 99ba3a3def3980fbe022928054dc7e047893d429; tree 7442b1003dd509a8902d504891e996a0e9faf4cb.
Stack prerequisite: #5132 at d9a324eb42e5775197690076c7c9d8c9fa894a1b, above frozen #5109.

This successor is outside current release admission. #5132, #5109, stopped #5062 and pending #5051 remain unchanged.

Scope Classification

  • One production behavior

Functions-only membership allocation. Canonical arena authority, occurrence identity, membership order, slot refresh, replacement, finalization, cache DTOs and serialization remain semantically equivalent. The test-membership collector and secondary structures are unchanged.

Evidence delta: two parser-backed producer controls, governing-spec clarification and targeted traceability mappings.

Support-tier Impact / Policy Impact

  • none

No schema, output, golden, dependency or public API changes.

Proof

Pinned Rust 1.95.0, normal cfg(test), --locked --no-default-features --features lang-rust:

  • Before production mutation, the real nonempty source vector and actual stored membership shared the same pointer: source capacity 64 * 368 = 23,552 bytes became destination capacity 2,944 * 8 = 23,552 bytes for 50 functions. Independent full fallible serialization and payload-move checks passed before the intended capacity assertion failed, native exit 101.
  • Exact committed head passed all 12 selected index controls. The repaired fixture retains 50 * 8 = 400 bytes of handle capacity. The regression oracle requires a capacity bound, not pointer inequality.
  • Restoring only the old production collector failed the same capacity assertion again, native exit 101. Exact byte restoration passed all 12 controls; green/restored source hashes match committed Git objects.
  • Controls cover equal but distinct occurrences, both membership views, replacement, discarded-record compaction, finalized slots, expanded DTO serialization and existing shared-role behaviors.
  • Independent exact-head source/oracle review: REVIEW_INCOMPLETE, no actionable findings, suitable for draft publication.

Committed candidate check-fast passed all 13 selected gates, including strict workspace/all-target Clippy; fixture contracts were skipped by the selector. Native precommit passed. Independent selector verification matched all 54 inherited paths relative to origin/main; the incremental parent-to-head delta is four files. Clean production release build completed with pinned Rust1.95, the lockfile, default shipped language features, LTO/strip/codegen-units=1 and the same flags as d9. It reports exact clean head99ba3a3def3980fbe022928054dc7e047893d429; SHA2568da7494a168b9d97ab2257074e285978423dc2dcd8090f0fbf3abf9970be4475. Diagnostic dirty builds remain separate from this production candidate.

Matched production replay

Twelve complete runs: three interleaved cold application-cache pairs per historical subject, reference/successor, successor/reference, reference/successor. Fixed base6823f7f698053621b5330526d3c162d7a381e352; original subject998bbbd4bc9cf6fbe31730f22c53a7337b3332d0; later subject3a6a363a05fc0625aa07d64b9ab7d6e9dea680ef. Same cap4342, request120000ms, outer130s/3GiB child-RSS/1GiB host-availability guards. All native0, complete atomic receipts, no guard intervention, cold cache0hits/4333misses/0corrupt/0storeerrors. Existing workloads and frozen d9 reference binary were reused.

Subject d9 median RSS, KiB successor median RSS, KiB observed median difference d9 median elapsed successor median elapsed
Original 1,667,596 1,661,404 -0.37% 45.12s 45.34s
Later 1,676,748 1,673,976 -0.17% 46.89s 46.52s

Raw RSS by iteration: original reference[1665664,1684620,1667596], successor[1661404,1657452,1675564]; later reference[1667936,1681316,1676748], successor[1674740,1661672,1673976]. Raw elapsed: original reference[45.86,45.12,43.05], successor[45.34,43.86,47.04]; later reference[46.02,46.89,47.28], successor[46.66,45.44,46.52].

These runs do not establish a consistent or material process-RSS benefit or a speedup. Two of six matched pairs increased RSS, and median differences are smaller than within-subject run ranges. The deterministic claim is handle-capacity repair; allocator retention and whole-run peaks are separate.

All six full Markdown comparisons are byte-identical. Full JSON comparisons differ only at the two receipt completed-artifact paths; no golden changes. Default hosted qualification is now terminal as recorded below; all-feature qualification remains separate and unestablished.

Claim Boundary

The exercised fixture proves the allocation mechanism and function-handle capacity repair. Earlier component accounting observed 47,609,000 bytes of file-function membership slack on a historical corpus; this is not a forecast of production RSS savings. Allocator retention, other payloads, construction transients and whole-run peaks remain separate measurements.

Rollback

Revert this single successor commit while retaining its prerequisites. No cache/schema migration or golden promotion is required.

Spec-Test-Code Traceability

RIPR-SPEC-0153 and .ripr/traceability.toml bind the two new producer controls to RustIndex::insert_file and the retained fact-authority contract. The default hosted proof below is separate from local proof; all-feature qualification and release membership are not established.

Hosted Rust-only run37101173966 completed successfully:7,046passed/2ignored across31summaries, lib6,502passed/1ignored, pinned Rust1.95 normalcfgtest. Actual merge checkout29e21fc835e77c094b6edd5d5be89adad8c0459d has parentsd9/99ba and tree7442b1003dd509a8902d504891e996a0e9faf4cb equal to the reviewed head. All-feature qualification and external review remain incomplete.

Hosted default run 37101174436 completed successfully on pinned Rust 1.95: 10,925 passed, 2 skipped across 34 binaries; doctests 2 passed/1 ignored. Required preflight, workspace/all-target strict Clippy, goldens, fixture contracts and PR evidence passed. Actual merge checkout 29e21fc has tree 7442b1003dd509a8902d504891e996a0e9faf4cb equal to the reviewed head. Nextest artifact 11266703637; JUnit SHA256 7150232385cf41e6df54f42603936c5669e8e48a0440b90ff05c6ef71bb7a90a.

All-feature qualification remains unestablished. Droid run 37101174094/job 111140839389 is queued without an assigned runner (runner_id 0). Gemini reported daily quota exhaustion; CodeRabbit skipped review of the nondefault base. UB completed with findings/needs-reviewer-attention, including a scope refusal and test timeout; source-backed disposition is posted in comment 5966286423. These wrappers do not establish substantive approval. REVIEW_INCOMPLETE; retain draft status and keep this optional candidate outside release. No further optimization or extra Jules job is started.

Preserve independent ordered flat and per-file memberships, occurrence identity, role divergences, cache wire shape and borrowed generation lifetimes. Add ownership, equality, compaction and cancellation discriminators while migrating readers and test fixtures.

Focused diagnostic proof passes 67 selected controls, including intended checkpoint-removal and shared-role-overwrite failures followed by restored green. Full pinned native qualification and matched optimized workload measurements remain required.
@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 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 6716fa4b-86b4-49ff-94e4-999ba74f4bf4
📥 Commits

Reviewing files that changed from the base of the PR and between a5499a6 and c7a4f34.

📒 Files selected for processing (5)
  • .ripr/traceability.toml
  • crates/ripr/src/analysis/facts/index.rs
  • crates/ripr/src/analysis/facts/index_tests.rs
  • crates/ripr/src/analysis/test_grip_evidence/related_tests/context.rs
  • docs/specs/RIPR-SPEC-0153-rust-source-role.md
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Limit details: You’ve used all 10 included reviews currently available.


Summary by CodeRabbit

  • Performance
    • Reduced memory overhead when tracking which functions belong to each file, especially for compacted indexes.
    • File membership information continues to be preserved across serialization and index updates.

Walkthrough

Per-file function membership storage is preallocated for function IDs. New tests cover membership capacity, fact sharing, compaction, finalization, and serialization. A related test fixture now accesses index data through RustIndex methods.

Changes

Compact file-function memberships

Layer / File(s) Summary
Membership allocation contract and implementation
docs/specs/RIPR-SPEC-0153-rust-source-role.md, crates/ripr/src/analysis/facts/index.rs
The specification describes fresh handle-sized storage for per-file function memberships. insert_file preallocates the ID storage and pushes each allocated ID into it.
Membership finalization and round-trip tests
crates/ripr/src/analysis/facts/index_tests.rs, crates/ripr/src/analysis/test_grip_evidence/related_tests/context.rs, .ripr/traceability.toml
Tests cover membership capacity, shared facts, payload allocations, compaction, replacement, removal, finalized slots, and serialization. A related fixture uses RustIndex methods. Traceability references the added tests.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to c7a4f

No actionable issue was identified in the membership-allocation change; it is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: allocating function-membership IDs at their own size.
Description check ✅ Passed The description gives a detailed summary, scope, source references, candidate relationships, proof, claim boundaries, rollback plan, and spec-test-code traceability. Some template items are omitted or…
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. (2 skipped: 2 u…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 5
  • Waived: $1.25 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.


A rabbit checks the handles in a row,
And sees compact memberships grow.
The facts stay shared; the tests confirm,
Slots and wire forms keep their form.
Hop, hop—the round trips come and go.

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

@EffortlessSteven EffortlessSteven left a comment •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REVIEW_INCOMPLETE — suitable for draft publication; no actionable source or oracle findings. Reviewed exact head 99ba3a3, tree 7442b1003dd509a8902d504891e996a0e9faf4cb, parent d9a324e.

The functions-only explicit ID vector preserves canonical arena allocation and occurrence order, independent duplicate occurrences, flat/file memberships, slot refresh, replacement, compaction and expanded DTO serialization. Test membership is unchanged. Spec and targeted traceability mappings match that boundary.

The real parser/insert_file discriminator established the old source allocation reuse and rejected its 23,552-byte capacity only after full fallible DTO and payload-move parity. Exact committed normal Rust 1.95 cfg(test) passed 12/12 with 400 handle bytes for 50 functions. Restoring only the old collector failed the same capacity oracle, native 101; exact byte restoration passed 12/12 again. Root independently verified native exits, counts and green/restored source hashes against Git objects. Strict workspace/all-target Clippy, 13 selected policy gates and native precommit passed; fixture contracts were explicitly skipped by selector.

Clean exact-head production replay completed 12/12, with six byte-identical Markdown comparisons and full JSON differences confined to the two receipt artifact paths. Observed median RSS differences were -0.37%/-0.17%; two of six pairs increased RSS and run ranges exceed those differences. No consistent process-RSS benefit or speedup is established. Default hosted qualification is terminal below. No RSS forecast, broader resource-issue completion or release admission is claimed. Allocator retention and construction peaks are separate from Vec capacity. The author records COMMENT, not approval or merge readiness.

Terminal hosted Rust-only37101173966 passed7,046tests/2ignored across31summaries on actual merge29e21fc835e77c094b6edd5d5be89adad8c0459d, tree7442b100 equalreviewedhead. All-feature qualification remains incomplete. UB37101173929 is advisory findings/needs-reviewer-attention with scope refusal/testtimeout; public source-backed disposition5966286423 addresses its allocation objection and informational test diagnostic. No substantive UB pass is claimed.

Hosted default run 37101174436 completed successfully on pinned Rust 1.95: 10,925 passed, 2 skipped across 34 binaries; doctests 2 passed/1 ignored. Required preflight, workspace/all-target strict Clippy, goldens, fixture contracts and PR evidence passed. Actual merge checkout 29e21fc has tree 7442b1003dd509a8902d504891e996a0e9faf4cb equal to the reviewed head. Nextest artifact 11266703637; JUnit SHA256 7150232385cf41e6df54f42603936c5669e8e48a0440b90ff05c6ef71bb7a90a.

All-feature qualification remains unestablished. Droid run 37101174094/job 111140839389 is queued without an assigned runner (runner_id 0). Gemini reported daily quota exhaustion; CodeRabbit skipped review of the nondefault base. UB completed with findings/needs-reviewer-attention, including a scope refusal and test timeout; source-backed disposition is posted in comment 5966286423. These wrappers do not establish substantive approval. REVIEW_INCOMPLETE; retain draft status and keep this optional candidate outside release. No further optimization or extra Jules job is started.

@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 reviewer attention before upstream: findings remain.

Confirmed findings

  • Fixture eprintln leaks an allocation-reuse diagnostic pointer pair into test logs; informational only, but should not appear in committed test output for a release-track candidate.

Refuted

  • Switching from collect() to with_capacity+push could drop or reorder a function handle if allocate panics mid-loop, leaving a partially built file membership.; refuted because: allocate is infallible in this arena (returns a plain FactId, no Result), and on panic the RustIndex is dropped wholesale so no stale half-built per-file vec is observable; arena authority and ordering are unchanged because push order matches source order.
  • The old .into_iter().map(...).collect::<Vec<_>>() on functions: Vec<FunctionFact> does not reuse the source Vec's allocation in the way the diff claims under Rust 1.95: collect into a Vec<T2> from an iterator of T2 produces a new buffer with capacity >= len * size_of::(); it does not keep the source Vec alive or copy its capacity. The PR body's claim of 23552-byte reuse describes the consumed function-fact source allocation leaking into the destination via collect's IntoIter having dropped but collect's buffer hint coming from Iterator::size_hint which is ExactSizeIterator-derived, not the source Vec's capacity. This is a false premise in the framing but the observed growth is real because Vec reallocation patterns under the global allocator can pick adjacent/larger blocks.
  • Worker handoff / async capture UB could be introduced by replacing collect::<Vec<_>> with Vec::with_capacity + push loop in insert_file; refuted because: No JS, Web Worker, SharedArrayBuffer, postMessage, transferables, Tokio task, rayon par_iter, or async boundary exists on the changed path. The replacement loop is purely synchronous, allocates a Rust-owned Vec, and drops the source FunctionFact Vec in the same synchronous frame. Worker-handoff UB model does not apply.
  • adjacent test-membership vector still uses in-place collect and would exhibit the same fact-sized retention bug for 1-element test vectors; refuted because: PR explicitly scopes to function IDs only; TestFact size and per-file test count (typically 1) make the asymmetry tolerable and #5026/#5109 retain test fact arena authority; new control file_function_membership_retains_only_handle_capacity does not measure test membership capacity. Out-of-scope follow-up, not a sibling bug introduced here.
  • Fix should have introduced a generic collect_fact_ids<F: Fact>(&mut self, facts: Vec<F>, arena: &mut Arena<F>) -> Vec<FactId<F>> helper to prevent future-style drift between function and test collectors; refuted because: Helper would exceed the smallest-complete-fix scope: PR is classified 'one production behavior, functions-only' (PR body Scope Classification) and the test collector is intentionally unchanged. Adding a generic helper now would conflate function-ID allocation with test-ID allocation, risking behavior change in a non-goal site and bloating a perf-only successor.

Parked follow-ups

  • adjacent tests membership uses the same map/collect pattern but is out of scope; no sibling helper group identified that mirrors the function allocation repair.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

@EffortlessSteven

Copy link
Copy Markdown
Member Author

Disposition of UB review 5399329058, bound to head 99ba3a3def3980fbe022928054dc7e047893d429:

  • The allocation-premise objection is refuted by the pinned Rust 1.95 implementation and the actual producer control. library/alloc/src/vec/in_place_collect.rs::from_iter_in_place takes the source buffer, casts it for destination items and computes destination capacity from source capacity times the source/destination element-size ratio. The retained old-collector control observed the same pointer and exactly 64 * 368 / 8 = 2,944 handles. This is not an ExactSizeIterator estimate of 50 or an inference from allocator usable-size rounding. Full serialization and payload identity passed before the capacity assertion failed; restoring the old collector on the committed head repeated that failure.
  • The pointer diagnostic is an informational test-output suggestion. It is confined to cfg(test) and introduces no production logging. This draft is explicitly outside current release admission, so the review's release-track premise does not describe this candidate. It is not treated as a production source defect or a substantive security pass.
  • Test membership and generic collector refactoring remain out of scope. The retained historical test-membership capacity was 594,400 bytes versus 421,536 live bytes; the extreme measured slack and reproduced mechanism belong to function membership. No speculative secondary optimization is proposed.

The advisory wrapper's pass does not establish full review or qualification. Actual disposition is analysis_result=findings, terminal_status=needs-reviewer-attention; the RIPR sensor refused 854 indexed files above its 800-file cap and the optional cargo-test sensor timed out after 900 seconds. Artifact 11266423102 retains those limits. The independent exact-head review, targeted red/green/restoration and completed Rust-only execution are separate evidence. The PR remains draft / REVIEW_INCOMPLETE.

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review (independent read-only reviewer) — draft PR, head 99ba3a3def3980fbe022928054dc7e047893d429

Reviewed the actual delta against its stack parent #5132 (d9a324eb): one production hunk in RustIndex::insert_file (index.rs:443-449) replacing the in-place map(...).collect() with Vec::with_capacity(functions.len()) + push, plus two producer controls and a SPEC-0153 clarification. Hosted default and Rust-only runs are green at the head (tree 7442b1003dd…).

Memory/perf claim vs code

The claim holds. Under pinned Rust 1.95, vec::into_iter().map(...).collect::<Vec<_>>() takes the in-place-collection specialization (library/alloc/src/vec/in_place_collect.rs), reusing the source FunctionFact buffer (record size 368 B) for the 8-byte FactId handles — the PR's before-shot (source capacity 64 × 368 = 23,552 B becoming destination capacity 2,944 × 8) is exactly the size-ratio behavior of that specialization, not an allocator accident. Note: the UB-review bot's refutation that the reuse premise is a "false premise" is itself incorrect on this point (the specialization exists and applies to Map<vec::IntoIter> when destination size/alignment fit); the author's disposition comment on the PR says the same with the control evidence. The new collector allocates exactly count * 8 B and frees the fact-sized source in the same synchronous frame.

Identity-stability risk (IDs feeding digests/goldens)

No behavior change, verified three ways:

  1. Allocation order is unchanged — the loop calls the same allocate in the same source order the old collect did, so every FactId offset, per-file membership order, and flat function_order are identical.
  2. FactId is not serialized (offsets are rebuilt on decode), and the new compact_membership_preserves_occurrences_replacement_and_finalized_slots test pins byte-identical expanded wire output across insert/replace/remove/finalize/serde round-trip — so no golden or digest surface can drift from this change.
  3. The regression oracle asserts destination_capacity <= count (a capacity bound), explicitly not pointer inequality, so allocator address reuse cannot flake it.

The honest claim boundary in the body is worth preserving: the matched-pair runs show no material RSS or elapsed difference (-0.37 %/-0.17 % medians, within run range), and the body says so. The deterministic claim is the per-file membership capacity repair (47.6 MB historical slack cited as component accounting, not a forecast).

Before this leaves draft

Nothing new from me beyond what is already tracked: the eprintln! allocation diagnostic in file_function_membership_retains_only_handle_capacity is the one open bot finding (informational, cfg(test)-only), and the adjacent tests membership still uses the old collect pattern — explicitly out of scope here and correctly parked as a follow-up rather than expanded into this successor. Applying the same two-line repair to test membership later would be a natural sibling, but I agree it does not belong in this PR.

Verdict: the change is minimal, behavior-preserving, and properly controlled; the evidence honestly distinguishes the deterministic capacity repair from whole-process effects.

claude added 5 commits October 3, 2026 22:57
Resolve conflicts with main's property-macro quarantine (#5051) and
parser-backed classifier test fixtures:

- thread FileFacts::unresolved_property_macros through the
  generation-owned FileData, its expanded serialization and owned_file
  round trip so the new field keeps its wire shape;
- port main's owner_pin, oracles and classifier test helper to the
  borrowed files()/insert_file authority;
- union both sides of .ripr/traceability.toml.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S5D7B2JxJ754s1p6ktir1Y
The merged #5051 field travels through the hand-written FileFactsView
serializer, which a compiler cannot force to stay complete. Add a
parser-backed control that the view, whole-index wire, decoded index and
owned_file round trip all preserve unresolved_property_macros.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S5D7B2JxJ754s1p6ktir1Y
…e-4996

Carry the #5109 merge with origin/main (property-macro witness threading
and its control) into this stacked successor. No conflicts.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S5D7B2JxJ754s1p6ktir1Y
…-membership

Carry the updated stack (origin/main via #5109, property-macro witness
control) into this successor. index_tests.rs: keep both appended
controls; traceability merged cleanly.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S5D7B2JxJ754s1p6ktir1Y
…sage only

Drop the unconditional eprintln! allocation dump flagged by the UB review
bot; the capacity assertion's failure message already carries the source
reuse diagnostic, so passing runs no longer print pointer values.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S5D7B2JxJ754s1p6ktir1Y

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of exact head 99ba3a3def3980fbe022928054dc7e047893d429 (self-authored PR, COMMENT only).

Findings

  1. Non-blocking: sibling allocation left as-is. In RustIndex::insert_file, tests still uses into_iter().map(allocate).collect(). That is the same pattern this PR repairs for functions. Whether in-place collect reuses the source allocation depends on the type sizes. Please say in the PR whether Vec<FactId<TestFact>> was measured and found unaffected, or make it explicit as well. The spec sentence added to SPEC-0153 only covers function membership.
  2. Non-blocking: diagnostic eprintln! in a test. file_function_membership_retains_only_handle_capacity prints a FUNCTION_MEMBERSHIP_ALLOCATION JSON line on every run. Fine as a retained receipt, but it will appear in nextest output.
  3. Stack dependency. The base is perf/release-review-source-4996 (#5132, itself a draft), not main. This PR cannot land independently. Merge order and a retarget to main after #5132/#5109 land are needed.

Surfaces inspected

facts/index.rs insert_file (a single production change, an explicit Vec::with_capacity plus push loop), the two new index_tests.rs controls, the SPEC-0153 sentence and the traceability rows.

Oracle challenge:

  • The wrong behavior is the old in-place map-collect keeping a capacity of about source_capacity * size_of::<FunctionFact>() / size_of::<FactId>(), which is greater than count.
  • assert!(destination_capacity <= count) would fail on that. The assertion does not depend on pointer equality, which is sound.
  • The test asserts a nonempty fixture (50 functions, bodies, calls). It also asserts payload pointer identity between the flat and file views, ordering, wire-format equality before and after finalize, and a serde round trip.
  • The second test covers occurrence identity (equal facts stay distinct), file replacement, discarded files and finalized slots.

Validation observed

Every check at this head is SUCCESS or SKIPPED except droid-review, which is still QUEUED. mergeable is MERGEABLE, mergeStateStatus UNSTABLE (the pending check). I did not execute the tests or a removal experiment locally. Reverting the loop to the map().collect() form would be the obvious removal control. Please record its result.

Missing evidence

  • Droid review not complete.
  • No recorded removal result.
  • No memory or perf measurement for this slice. Combined effect is deferred to the parent lane.

Disposition

REVIEW_INCOMPLETE: no source defect found, but the draft is stacked on an unlanded draft and the automated review has not completed. Re-review the head after the base changes. Nothing merged, pushed, or resolved.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-04T00:19:31.379905Z bc9a480 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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.

Confirmed findings

  • PR base is origin/perf/release-review-source-4996 (#5132, draft), not main. This candidate cannot land independently; merge order requires #5132 and #5109 first, plus retarget to main. PR body explicitly states this is outside current release admission and not a release-track candidate, so the dependency is documented but not enforceable from this PR alone.
  • Test-only eprintln emits an allocation-reuse diagnostic pointer pair into nextest output. Not a security finding (cfg(test), no secret, non-cfg(test) unaffected).
  • crates/ripr/src/analysis/facts/index_tests.rs:430 — The eprintln! in file_function_membership_retains_only_handle_capacity emits a FUNCTION_MEMBERSHIP_ALLOCATION JSON line on every test run, including in default nextest output. This is diagnostic noise unrelated to the capacity oracle and will appear in CI logs; the same capacity assertion already enforces correctness via assert!.

Verification questions

  • Confirm two new tests in index_tests.rs cover (a) capacity bound for function membership and (b) preserved occurrences/replacement/finalized slots with round-trip DTO parity. Both are bound under RIPR-SPEC-0153 in traceability.toml. Routes into insert_file plus finalize and serialization round-trip.
  • Sibling tests membership (Vec<FactId>) is left as the prior into_iter().map(allocate).collect() pattern in insert_file; not addressed by this PR or by the spec clarification. Architecture question: should the fix be symmetrical or is functions-only intentional?
  • Confirm tests membership still uses into_iter().map(allocate).collect() unchanged; if TestFact size > FactId in_place_collect could similarly retain the source allocation. No measurement in the PR proves tests are unaffected. This is a sibling-path concern already flagged by Steven's finding #1; not asserted by either new test.
  • Confirm compact_membership_preserves_occurrences_replacement_and_finalized_slots exercises the compact path (push order preserved, replacement, compaction, finalized slots, round-trip) but does NOT assert a capacity bound on the discarded/replacement a.rs membership after insert_file — only the final a/b retained membership capacities are checked, and the discarded branch returns false under replace-then-remove so the capacity-bounded file set is just {a,b}.

Refuted

  • A helper like collect_handles(arena, facts) should be introduced so both functions and tests use the same explicit-capacity pattern.; refuted because: The PR is a one-line in-place fix bounded to functions; introducing a helper would broaden scope and is explicitly out of the stack. SPEC-0153 sentence only covers function membership, matching the diff boundary.
  • The 'in_place_collect specialization reuses source allocation, capacity bound is a false premise' objection raised by the UB bot in seeded thread (and restated as a generic 'collect always allocates fresh' intuition).; refuted because: Rejected: alloc/src/vec/in_place_collect.rs::from_iter_in_place exists for Mapvec::IntoIter when destination size/alignment fit and source/dest sizes differ; with pinned Rust 1.95 it produces exactly 64*368/8=2,944 handles for the 50-function fixture. The PR's before-shot (23,552 B source becoming 23,552 B destination) is the documented size-ratio behavior, not allocator accident. The fix's capacity<=count oracle fails on the unfixed collector and passes on the fixed one, so the bound is not a tautology.
  • Switching from collect to with_capacity+push could drop or reorder function handles if allocate panics mid-loop, exposing a partially built file membership with stale FactId handles to borrowed views.; refuted because: function_facts.allocate returns a plain FactId (no Result), so it cannot return a recoverable error mid-iteration; any panic during insert_file propagates and drops the entire RustIndex, taking owned per-file vecs with it. Borrowed views (files()/functions()/tests()) cannot be live during insert_file, so no half-built vec is observable. push order matches source iterator order, preserving occurrence identity and the function_slot contract verified in compact_membership_preserves_occurrences_replacement_and_finalized_slots.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

Parked follow-ups

  • Architecture lane has no public blocker or medium-severity issue. PR is the smallest complete fix at the correct boundary; out-of-scope items (sibling tests membership, stack retarget) are parked or open verification questions, not findings.

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Published-head review for bc9a480d00cbfb0bc1a906a2b09dccb490dfb782.

Merge 3f66e83f: brings in the updated #5132 head b02c8710. The only conflict was index_tests.rs, where both sides appended tests at the end of the file; I kept both. insert_file auto-merged correctly: the explicit Vec::with_capacity function-ID loop sits next to the new unresolved_property_macros destructure.

Repair bc9a480d: removed the unconditional eprintln! allocation dump in file_function_membership_retains_only_handle_capacity. This was the open UB-review finding. The capacity assertion's failure message still reports whether the source allocation was reused, so diagnosis on failure is unchanged and passing runs print nothing. The oracle is the same: destination_capacity <= count.

Hosted on this head: Rust gates (nextest, goldens, fixtures, strict Clippy, PR evidence), Ripr Rust Small Result and the Rust-only lane all passed. No review threads. The Perl/all-feature lane is label-gated and was skipped. Local index controls did not finish because of host overload, so the hosted runs are the execution evidence.

Non-blocking: test membership still uses the in-place collect, which is the parked sibling follow-up. As the PR body says, the matched replays show no material RSS change; the deterministic claim is the handle-capacity repair.

Disposition: no blocking findings. Ready after #5109 and #5132 merge.


Generated by Claude Code

Base automatically changed from perf/release-review-source-4996 to main October 4, 2026 01:37
Resolves add/add conflicts left by the squash merges of #5109 and #5132:
main's index.rs, index_tests.rs and RIPR-SPEC-0153 equal the #5132 head,
so the branch side applies. traceability.toml takes main and re-applies
this PR's two RIPR-SPEC-0153 mappings. Net delta against main equals
b02c871..bc9a480.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S5D7B2JxJ754s1p6ktir1Y
#5062 added retained_import_lines_preserve_unbounded_affinity_and_owner_matching,
which constructs RustIndex from its public tests/functions/files fields.
#5109 made those fields generation-owned arenas behind accessors. Each PR
was green on its own base; together, main's ripr lib tests no longer
compile (E0560/E0615/E0616 at related_tests/context.rs:578-595).

Build the fixture with extend_tests/extend_functions plus insert_file_only,
which keeps the flat facts as occurrences separate from the file copy, as
the original fixture had, and rewrite the flat test through test_at_mut.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S5D7B2JxJ754s1p6ktir1Y

Copy link
Copy Markdown
Member Author

The Rust-only feature lane and Rust gates failures on e2a9b187c are main's, not this PR's. On main a5499a612, ripr lib tests don't compile: #5062's test in related_tests/context.rs builds RustIndex from fields that #5109 made private (E0560/E0615/E0616 at lines 578-595). The fix is #5237. I ported the same change here as c7a4f34d3 (a no-op once main carries it).

On the conflict merge (e2a9b187c): main's index.rs, index_tests.rs and RIPR-SPEC-0153 match the #5132 head byte for byte, so the branch side applies. traceability.toml takes main and re-applies this PR's two mappings. The net diff against main equals b02c8710..bc9a480d apart from line offsets.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven merged commit 0de7941 into main Oct 4, 2026
31 checks passed
@EffortlessSteven
EffortlessSteven deleted the perf/compact-file-function-membership branch October 4, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants