Skip to content

fix: remove O(n) reverse scan in get_related() + fix recall_room() missing columns - #690

Merged
ajianaz merged 1 commit into
developfrom
fix/cross-entity-bugs-689
Jul 15, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/cross-entity-bugs-689

Conversation

@ajianaz

@ajianaz ajianaz commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two bug fixes for cross-entity recall correctness and performance.

Changes

A. get_related() O(n) → O(edges) — graph.rs

Before: 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 uses UNION on source_id/target_id via 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.rs

Before: 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_type to all 4 SQL variants in recall_room().

Test Results

  • 28/28 graph tests pass ✅
  • 299/303 total tests pass (4 pre-existing dream::tests failures — ONNX backend unavailable in CI)

Refs #689

…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
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

⚠️ Review recommended — warnings found.

🟡 Warning (1)

  • unknown:? — Cora AI review could not complete: failed to parse LLM JSON response: parse failed (original: EOF while parsing a value at line 21 column 11, after repair: expected value at line 21 column 12). Review was skipped; no code quality issues were found by the automated check.

Review powered by cora-cli · BYOK · MIT

@ajianaz
ajianaz merged commit 04582a5 into develop Jul 15, 2026
9 checks passed
@ajianaz
ajianaz deleted the fix/cross-entity-bugs-689 branch July 15, 2026 11:19
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
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.

1 participant