search
Search (canonical) ·read-only · non-destructive · idempotent · closed-world
Canonical 3ngram search across memories AND content chunks — use first.
Fans one query across both stores, tags every hit with source_type,
and returns a coverage envelope so callers stop pre-routing between
specialist tools and stop silently filling results from unrelated
indexed content when a requested repo/path isn’t indexed (#4123 AC).
Each hit carries source_type ("memory" / "content_chunk")
and a normalized score in [0, 1]. Per-leg scores are min-max
normalized before merge so similarity_floor applies uniformly
across stores. Ranking internals live in the existing sync DB helpers.
Pass memory_ids=[...] for direct visible-id lookup (no embedding
call); this absorbs the standalone get_memory(id) tool. Pair with
include_lineage=True to also attach each decision memory’s
supersession chain (ancestors + descendants via
memories.replaces_memory_id); this absorbs the standalone
get_decision_lineage tool (#4201). Lineage is silently ignored
when memory_ids is not set (vector-search path) so agents can
pass the flag unconditionally. Pass source_type="memory" or
"content" to skip the other leg.
Per ADR-002 §Q3, chunks already promoted to atomic memories via
memories.promoted_from_chunk_id are hidden so content promoted
into a standing reference isn’t double-counted. Pre-#2899 the FK
column is absent and dedup becomes a no-op.
Returns: str
Source: backend/src/engram/mcp/tools/search/unified.py
Parameters
Natural-language query. Ignored when
memory_ids is set.Max total results to return after merge (default 10).
"all" (default), "memory" or "content".Optional list of memory IDs for direct visible-id lookup. Skips embedding + vector search.
When True together with
memory_ids, attach the supersession chain for each decision memory hit. Walks memories.replaces_memory_id in both directions (ancestors + descendants), capped at depth 10. Ignored on the vector-search path (no memory_ids) and a no-op for non-decision memories.Memory leg only — decision/commitment/blocker/ preference/pattern/note/event/fact. Legacy: context -> note.
Memory leg only — restrict to a project tag.
Memory leg only — open/waiting/scheduled/resolved/ expired/overdue/archived. Default returns all active.
Memory leg only — ISO 8601 lower bound.
Memory leg only — ISO 8601 upper bound on
due_date.Memory leg only — manual/hook/mcp/auto memory origin.
Memory leg only — exact tag match.
Memory leg only — auto/relevance/recency/hybrid/updated.
Memory leg only — include archived rows.
Memory leg only — always/auto/never; echoed for envelope parity (unified merge does not append siblings).
Echo retrieval metadata to the envelope.
Memory leg only — atomic = TRUE rows (ADR-002 standing references). Content chunks are skipped.
Optional
"personal" / "work" filter, or "all" to opt out of scope binding. When unset and scope binding is enabled, the search defaults to your primary scope; pass "all" for the legacy cross-scope firehose.Content leg only — path substring (e.g.
B3dmar/engram). When no chunks match, the value lands in coverage.requested_sources_not_found (#4123 AC).Content leg only —
"github" / "local".Content leg only — bypass per-leg floor.
Post-merge floor (default 0.3, zero disables).