mirror of
https://github.com/samvallad33/vestige.git
synced 2026-06-22 21:28:08 +02:00
Adds an optional `tag_prefix` string parameter to the `search` MCP tool. When set, only results that carry at least one tag whose value starts with the prefix are returned (case-sensitive, matching the existing exact-tag semantics in memory_timeline / export / gc). Motivation: external consumers that need "all memories tagged `<class>:*`" (e.g. `meeting:standup`, `meeting:1-on-1`) currently have three paths, all bad: (i) export everything and filter client-side (heavy), (ii) enumerate the prefix space and pass exact tags as a list (impractical for open-set tag classes), or (iii) read SQLite directly (an anti-pattern that couples consumers to internal schema). This PR closes that gap with a minimal, additive surface. Implementation note: filter runs at the MCP layer, NOT in the storage predicate. Rationale: (a) leaves crates/vestige-core/src/storage/ untouched, avoiding collision with PR #61's storage-trait extraction; (b) `SearchResult.node.tags` is already loaded from the same JSON-array column the brief's proposed SQL would scan, so the post-filter is functionally equivalent; (c) post-filter applies BEFORE the reranker so the cross-encoder does not waste cycles on memories the caller will not receive, and BEFORE strengthen-on-access so dropped results do not get a testing-effect boost they did not earn. Headroom: when tag_prefix is set, the hybrid path doubles its overfetch multiplier (capped at the existing 100 ceiling) and the concrete path fetches 3x its normal limit, both to leave the post-filter enough pool to still return ~limit results after thinning. The Stage 0 keyword-priority merge also re-applies the prefix filter so it cannot re-introduce filtered-out memories. Backwards-compat: parameter is optional, defaults to None; every existing call shape and response shape is unchanged. Tests: - tags_match_prefix unit (prefix-vs-substring, case-sensitivity, tagless-memory semantics, empty-prefix corner case) - schema introspection (property present, type=string, not required) - hybrid-path filter excludes non-matching tag-classes - hybrid-path filter excludes tagless memories - backwards-compat: no tag_prefix → behavior unchanged - concrete-path filter (literal-query branch) honors tag_prefix Closes a gap surfaced in the knowledge-mgmt-sota-uplift initiative (KMSU Session 89 audit; ~3,300-memory production Vestige). |
||
|---|---|---|
| .. | ||
| vestige-core | ||
| vestige-mcp | ||