Repository navigation
fix: remove O(n) reverse scan in get_related() + fix recall_room() missing columns - #690
Merged
Merged
Conversation
…ssing columns A) get_related() in graph.rs was doing load_all(None) to find reverse metadata relationships — O(n) full table scan. The edge_bfs() method already handles bidirectional lookups via UNION on source_id/target_id using indexed SQL. Removed the full-table scan. Forward-only metadata fallback kept for pre-v8 stores (O(degree), not O(n)). B) recall_room() SQL in memory/rooms.rs was missing m.slug, m.source, m.source_type columns (only selected up to content_type=col16). row_to_memory() expects 20 columns (0-19). Fixed all 4 SQL variants. Refs #689
🔍 Cora AI Code Review🟡 Warning (1)
Review powered by cora-cli · BYOK · MIT |
ajianaz
added a commit
that referenced
this pull request
Aug 13, 2026
fix: remove O(n) reverse scan in get_related() + fix recall_room() missing columns
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.
Summary
Two bug fixes for cross-entity recall correctness and performance.
Changes
A.
get_related()O(n) → O(edges) — graph.rsBefore:
load_all(None)loaded every memory in the database, then iterated all to find metadata relationships pointing TO the target. O(n) with n = total memories.After: Removed the full-table scan.
related_via_edges()→edge_bfs()already usesUNIONonsource_id/target_idvia indexed SQL. Bidirectional coverage is built-in. Forward-only metadata fallback kept for pre-v8 stores (O(degree)).B.
recall_room()missing columns — memory/rooms.rsBefore: SQL selected 17 columns (0-16, up to
content_type).row_to_memory()expects 20 columns (0-19). Columns 17-19 (slug,source,source_type) silently defaulted.After: Added
m.slug, m.source, m.source_typeto all 4 SQL variants inrecall_room().Test Results
dream::testsfailures — ONNX backend unavailable in CI)Refs #689