Repository navigation
fix(#894): room recall_semantic returns zero for small rooms in large DBs - #897
Merged
Merged
Conversation
… DBs The fixed fetch cap of 200 (#546) caused semantic room recall to return zero results for 93% of rooms. Small rooms (≤20 memories) in large DBs (2,486+ memories) almost never appear in the global top-200 hybrid search results, making the room ID post-filter eliminate everything. Fix: set fetch_limit to total_memories so the hybrid search covers the entire database before filtering to room IDs. HNSW vector search is O(log N), so fetching 2K+ results adds negligible latency. Changes: - rooms.rs: fetch_limit = total_memories (was effective_limit.min(200)) - crud.rs: add count_all_memories() for dynamic fetch sizing - rooms.rs: regression test for small room in large DB Verified on production clone (2,486 memories, 74 rooms): cora-code (20 mem): 0 → 5 results ✅ codecora-marketing: 0 → 5 results ✅ server-infra: 0 → 3 results ✅ uteke-dev: 0 → 1 results ✅
| // | ||
| // Fetch ALL memories so post-filter to room IDs has complete coverage. | ||
| // HNSW vector search is O(log N), so fetching 2K+ results is still fast. | ||
| // The old fixed cap of 200 (#546) caused small rooms to return zero (#894). |
🔍 Cora AI Code Review❌ Blocked — critical issues found. 🔴 Error (1)
Review powered by cora-code · BYOK · MIT |
ajianaz
added a commit
that referenced
this pull request
Aug 5, 2026
) Replace unbounded fetch_limit=total_memories with two-stage algorithm: Stage 1 (Primary): Hybrid search with adaptive bounded limit: fetch_limit = max(room_size * 10, effective_limit * 5) .min(total_memories) .min(MAX_ROOM_FETCH=5000) Stage 2 (Fallback): If primary missed room memories (small room in large DB — the original #894 bug), load missing IDs directly and score them with cosine similarity against query embedding. This guarantees complete room coverage without unbounded global fetch. For a 50K+ DB with a 20-memory room, fetch_limit is capped at 5000 instead of scanning all 50K memories. Addresses reviewer concern about PR #897 unbounded fetch_limit. Tested: 4 rooms in production clone (2,486 memories) all return correct results. cargo test 453 passed, clippy clean. Co-authored-by: ajianaz <[email protected]>
ajianaz
added a commit
that referenced
this pull request
Aug 13, 2026
… DBs (#897) The fixed fetch cap of 200 (#546) caused semantic room recall to return zero results for 93% of rooms. Small rooms (≤20 memories) in large DBs (2,486+ memories) almost never appear in the global top-200 hybrid search results, making the room ID post-filter eliminate everything. Fix: set fetch_limit to total_memories so the hybrid search covers the entire database before filtering to room IDs. HNSW vector search is O(log N), so fetching 2K+ results adds negligible latency. Changes: - rooms.rs: fetch_limit = total_memories (was effective_limit.min(200)) - crud.rs: add count_all_memories() for dynamic fetch sizing - rooms.rs: regression test for small room in large DB Verified on production clone (2,486 memories, 74 rooms): cora-code (20 mem): 0 → 5 results ✅ codecora-marketing: 0 → 5 results ✅ server-infra: 0 → 3 results ✅ uteke-dev: 0 → 1 results ✅ Co-authored-by: ajianaz <[email protected]>
ajianaz
added a commit
that referenced
this pull request
Aug 13, 2026
) Replace unbounded fetch_limit=total_memories with two-stage algorithm: Stage 1 (Primary): Hybrid search with adaptive bounded limit: fetch_limit = max(room_size * 10, effective_limit * 5) .min(total_memories) .min(MAX_ROOM_FETCH=5000) Stage 2 (Fallback): If primary missed room memories (small room in large DB — the original #894 bug), load missing IDs directly and score them with cosine similarity against query embedding. This guarantees complete room coverage without unbounded global fetch. For a 50K+ DB with a 20-memory room, fetch_limit is capped at 5000 instead of scanning all 50K memories. Addresses reviewer concern about PR #897 unbounded fetch_limit. Tested: 4 rooms in production clone (2,486 memories) all return correct results. cargo test 453 passed, clippy clean. Co-authored-by: ajianaz <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fix
recall_room_semanticreturning zero results for small rooms in large databases.Why
The fixed fetch cap of 200 (
#546) caused 93% of rooms to return zero results from semantic recall. Small rooms (≤20 memories) in a 2,486-memory database almost never appear in the global top-200 hybrid search results, so the room ID post-filter eliminated everything.Changes
rooms.rs:92-108fetch_limit = total_memories(waseffective_limit.min(200))crud.rs:93-100count_all_memories()method for dynamic fetch sizingrooms.rs:312-388Verification
Tested on production clone (2,284 memories, 74 rooms):
Testing
cargo clippy --workspace --all-targets -- -D warnings— cleancargo test --workspace— 447 passed, 0 failed, 26 ignoredCloses #894