perf(conversations): rank cross-thread hits before materializing#64
Conversation
Port OpenHuman host commit 007a99b62 (drift ledger D1). The cross-thread inverted-index search cloned the KB-sized `CrossThreadHit` (content, message_id, created_at) for *every* Phase-2 match, then sorted and truncated to `limit`. Phase 2 can leave thousands of candidates while callers ask for 3-10 results, so ~99% of those clones were discarded. Now rank on cheap borrowed keys first — `(doc_id, matched: usize, created_at: &str)` — truncate to `limit`, and materialize the heavy `CrossThreadHit` only for the survivors. Ranking by `matched` (usize) is order-equivalent to ranking by `score = matched / total_terms` since `total_terms` is a positive constant, so returned order is unchanged. Pinned by the new `ranks_by_score_then_recency_before_truncating` test.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 36 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Comment |
Module
memory::conversations::inverted_indexWhat
Ports OpenHuman host commit
007a99b62— drift-ledger row D1 of the TinyCortex memory migration. The cross-thread inverted-index search cloned the KB-sizedCrossThreadHit(content,message_id,created_at) for every Phase-2 match, then sorted by score and truncated tolimit. Phase 2 can leave thousands of candidates while callers ask for 3–10 results, so ~99% of those clones were immediately discarded.Now ranks on cheap borrowed keys first —
(doc_id, matched: usize, created_at: &str)— truncates tolimit, and materializes the heavyCrossThreadHitonly for the survivors.Behavior parity
Ranking by
matched(usize) is order-equivalent to ranking byscore = matched / total_termsbecausetotal_termsis a positive constant, so the returned order (score desc, thencreated_atdesc tiebreak) is unchanged. Scores in the returned hits are stillmatched / total_terms.Tests
cargo test --lib conversations::inverted_index— 16 pass, incl. newranks_by_score_then_recency_before_truncating(more matches thanlimit; asserts the top-(score, recency) hits survive truncation, pinning that ranking happens before the cut).Gates host workstream W7 (long-tail cutover — conversations).
https://claude.ai/code/session_01X39btnEnHSTuPSYYvgyjrb