You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(core): add observation category filter to search
Add a `categories` filter that scopes observation results to exact category
matches, mirroring the existing entity_types/note_types filter end-to-end.
Previously `entity_types=["observation"]` only narrowed to the observation row
type, so a text search for "requirement" still returned [decision] observations
whose body merely mentions the word. The new `categories` parameter adds a
parameterized `search_index.category IN (...)` predicate so only rows whose
indexed category matches exactly survive (in FTS, vector, and hybrid modes).
The search_notes docstrings advertised a 'category:observation' token that was
never implemented (no token parsing in code); those misleading lines are removed
and replaced with the real `categories=[...]` usage.
Plumbing:
- SearchQuery gains `categories` (included in no_criteria()).
- SearchService threads it through _PreparedSearchQuery, has_criteria,
_prepared_has_filters, _search_repository, and _count_repository.
- SearchRepository protocol + base abstract search/count, plus _search_vector_only
and _search_hybrid (filter re-scan path) carry the new param.
- SQLite and Postgres _build_fts_query_parts add the parameterized IN condition.
- search_notes MCP tool exposes `categories` (with `category` alias) and wires it
into SearchQuery and the search_all_projects fan-out.
Tests (integration-first, both backends):
- tests/repository/test_search_repository.py + test_postgres_search_repository.py:
exact-category match excludes a [decision] obs that mentions "requirement".
- tests/services/test_search_service.py: categories propagates through
_prepare_query/has_criteria and count agrees with search.
- tests/mcp/test_tool_search.py: end-to-end via the MCP tool (FTS + count path).
Closes#430
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: phernandez <paul@basicmachines.co>
0 commit comments