Skip to content

fix(#900): honour recall strategy flag in unified search path - #909

Merged
ajianaz merged 5 commits into
developfrom
fix/900-strategy-flag-ignored
Aug 6, 2026
Merged

ajianaz merged 5 commits into
developfrom
fix/900-strategy-flag-ignored

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

What

Fixes the strategy flag (--strategy fts5/hybrid/graph) being silently ignored when using the unified search path — the default code path for CLI recall, HTTP /api/recall, and MCP uteke_recall.

Root cause

recall_unified_memories() called self.recall() (vector-only) instead of self.recall_hybrid(). Since recall_unified() did not accept a strategy parameter, it had no way to propagate the user's choice to the memory sub-path.

This meant uteke recall "query" --strategy fts5 silently fell back to pure vector search — the FTS5 index (5,912 entries, verified working via direct SQL) was never queried.

Changes (5 files, +107/-7)

File Change
uteke-core/src/lib.rs Add strategy: RecallStrategy param to recall_unified(), recall_unified_memories(), recall_unified_all(). Memory sub-path now calls recall_hybrid() (dispatches by strategy) instead of recall() (vector-only). +6 test call sites updated +1 new regression test.
uteke-cli/src/commands/recall.rs Pass resolved strategy to recall_unified().
uteke-server/src/types.rs Add strategy: Option<String> to RecallRequest struct.
uteke-server/src/handlers.rs Parse strategy string → RecallStrategy, propagate to recall_unified().
uteke-mcp/src/lib.rs Pass RecallStrategy::Vector as default (no MCP UI for strategy yet).

Regression test

// recall_unified_honours_fts5_strategy
// Inserts a memory with zero-vector embedding (impossible vector match)
// → FTS5 strategy MUST still find it via keyword search.
assert_eq!(results[0].memory_id.as_deref(), Some("fts5-target"));

Why

  • User-facing impact: --strategy fts5 appeared to work (no error) but returned vector results. Silent functional regression.
  • Severity: Critical — defeats the purpose of having multiple recall strategies.
  • Scope: All unified-path callers affected (CLI, HTTP, MCP).

Testing

  • ✅ cargo check --workspace — zero errors
  • ✅ cargo clippy --workspace --all-targets -- -D warnings — zero warnings
  • ✅ cargo test --workspace — 454 passed, 0 failed, 26 ignored (ONNX-dependent)
  • ✅ New regression test: recall_unified_honours_fts5_strategy — verifies FTS5 path is taken when strategy=fts5
  • ✅ Zero new dependencies added

Closes #900.

recall_unified_memories() called self.recall() (vector-only) instead of
self.recall_hybrid(), silently ignoring the user-selected strategy.
This meant --strategy fts5/hybrid had zero effect when using the unified
search path (the default for CLI/HTTP/MCP).

Root cause: recall_unified() did not accept a strategy parameter, so it
could not propagate it to the memory recall sub-path.

Fix:
- Add strategy: RecallStrategy param to recall_unified(),
  recall_unified_memories(), and recall_unified_all()
- recall_unified_memories() now calls recall_hybrid() (which dispatches
  to vector/fts5/hbrid based on strategy) instead of recall() (vector-only)
- CLI recall.rs: pass resolved strategy to recall_unified()
- Server types.rs: add optional strategy field to RecallRequest
- Server handlers.rs: parse strategy string and propagate to recall_unified()
- MCP lib.rs: pass RecallStrategy::Vector as default (no MCP UI for strategy)
- Update all 6 test call sites with explicit strategy argument
- Add regression test: recall_unified_honours_fts5_strategy
@ajianaz ajianaz added the bug Something isn't working label Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

⚠️ Review could not complete. Cora was unable to reach the LLM API after retries. Check the workflow logs for errors.


Review powered by cora-code · BYOK · MIT

Comment thread crates/uteke-core/src/lib.rs Fixed
Comment thread crates/uteke-core/src/lib.rs Fixed
Cora review caught that entity_filter and category_filter were silently
discarded (let _ = ...) instead of applied. Server handler passes them
to recall_unified but had no post-filter logic, causing unfiltered results.

Now post-filters entity/category metadata inside recall_unified_memories()
itself, so ALL callers (CLI, HTTP, MCP) get correct filtering.
Comment thread crates/uteke-core/src/lib.rs Outdated
// entity_filter and category_filter are not natively supported by
// recall_hybrid, so we apply them as post-filters here (#900 cora review).
let results =
self.recall_hybrid(query, limit, tags_filter, namespace, strategy, min_score)?;
CodeCora caught that post-filtering after fetching exactly 'limit' rows
can return fewer results than requested. Now over-fetches 3x (min limit+10)
when entity_filter or category_filter is active, then truncates to limit
after filtering.
@ajianaz
ajianaz merged commit 56f3d3f into develop Aug 6, 2026
12 checks passed
ajianaz added a commit that referenced this pull request Aug 13, 2026
* fix(#900): honour recall strategy flag in unified search path

recall_unified_memories() called self.recall() (vector-only) instead of
self.recall_hybrid(), silently ignoring the user-selected strategy.
This meant --strategy fts5/hybrid had zero effect when using the unified
search path (the default for CLI/HTTP/MCP).

Root cause: recall_unified() did not accept a strategy parameter, so it
could not propagate it to the memory recall sub-path.

Fix:
- Add strategy: RecallStrategy param to recall_unified(),
  recall_unified_memories(), and recall_unified_all()
- recall_unified_memories() now calls recall_hybrid() (which dispatches
  to vector/fts5/hbrid based on strategy) instead of recall() (vector-only)
- CLI recall.rs: pass resolved strategy to recall_unified()
- Server types.rs: add optional strategy field to RecallRequest
- Server handlers.rs: parse strategy string and propagate to recall_unified()
- MCP lib.rs: pass RecallStrategy::Vector as default (no MCP UI for strategy)
- Update all 6 test call sites with explicit strategy argument
- Add regression test: recall_unified_honours_fts5_strategy

* style: cargo fmt

* docs: regenerate api-reference for recall_unified signature change

* fix(#900): post-filter entity/category in recall_unified_memories

Cora review caught that entity_filter and category_filter were silently
discarded (let _ = ...) instead of applied. Server handler passes them
to recall_unified but had no post-filter logic, causing unfiltered results.

Now post-filters entity/category metadata inside recall_unified_memories()
itself, so ALL callers (CLI, HTTP, MCP) get correct filtering.

* fix(#900): over-fetch to fill limit after entity/category post-filter

CodeCora caught that post-filtering after fetching exactly 'limit' rows
can return fewer results than requested. Now over-fetches 3x (min limit+10)
when entity_filter or category_filter is active, then truncates to limit
after filtering.

---------

Co-authored-by: ajianaz <[email protected]>
@ajianaz
ajianaz deleted the fix/900-strategy-flag-ignored branch August 13, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: --strategy flag silently ignored — all recalls use vector search (default path bypasses recall_hybrid)

2 participants