fleet-memory/hindsight-api/hindsight_api/engine
Nicolò Boschi 7e339e1677
feat: ai sdk integration (#299)
* feat: ai sdk integration

* more fixes

* fix(security): mental model refresh tag-based security

- Mental model refresh now passes tags with all_strict matching
- Consolidation only triggers refresh for mental models with matching tags
- Consolidation filters related observations by tags (all_strict)
- Added tests to verify tag-based security boundaries
- Updated OpenAPI spec to include tags and text_preview in list_documents
- Added tags column to documents UI table

* chore: regenerate OpenAPI spec after rebase

* fix: improve consolidation prompt for contradiction handling and mental model refresh security

- Enhanced consolidation prompt to be more explicit about capturing temporal changes in contradictions
- Fixed mental model refresh security: tagged memories now only trigger refresh of mental models with matching tags
- Added stricter tag filtering to prevent cross-scope mental model refreshes

Fixes test_consolidation_merges_contradictions by improving LLM instructions to use temporal markers like "used to X, now Y" when merging contradictory facts.

Note: test_refresh_with_tags_only_accesses_same_tagged_models still needs investigation - REFLECT operation may need additional tag filtering.

* fix: mental model refresh security - proper tag filtering in search

Fixed tool_search_mental_models to properly handle all_strict tag matching mode by using the centralized build_tags_where_clause function. Previously, the function only handled "all" vs "any" modes and always included untagged mental models when using non-"all" modes.

This ensures that when a tagged mental model is refreshed with all_strict matching, it cannot access untagged mental models, preventing cross-scope information leakage.

Fixes test_refresh_with_tags_only_accesses_same_tagged_models.

Note: test_sensory_dimension_preservation is failing but this is a pre-existing issue on main branch - the LLM model (gpt-oss-20b) is not extracting facts from sensory text. Not related to security changes.

* chore: apply formatting from pre-commit hook

* fix: allow untagged mental models to be refreshed by any consolidation

Untagged mental models are considered "global" and should be refreshed
by any consolidation, regardless of whether tagged or untagged memories
were consolidated. This maintains security boundaries while allowing
global mental models to stay fresh.

When tagged memories are consolidated:
- Refresh mental models with matching tags (security boundary)
- Also refresh untagged mental models (they're global)
- DO NOT refresh mental models with different tags

When untagged memories are consolidated:
- Only refresh untagged mental models
- DO NOT refresh tagged mental models (security boundary)

Fixes test_consolidation_only_refreshes_matching_tagged_models.
2026-02-04 20:25:59 +01:00
..
consolidation feat: ai sdk integration (#299) 2026-02-04 20:25:59 +01:00
directives feat: revisit mental models, directives and reflections (#179) 2026-01-22 17:13:16 +01:00
mental_models feat: revisit mental models, directives and reflections (#179) 2026-01-22 17:13:16 +01:00
providers fix: improve claude code and codex for /reflect (#285) 2026-02-04 13:34:45 +01:00
reflect feat: ai sdk integration (#299) 2026-02-04 20:25:59 +01:00
retain feat: ai sdk integration (#299) 2026-02-04 20:25:59 +01:00
search fix: graph endpoint not showing links for observations (#214) 2026-01-28 14:51:25 +01:00
__init__.py feat: extensions (#54) 2025-12-22 11:05:23 +01:00
cross_encoder.py fix: hide hf logging (#295) 2026-02-04 13:12:30 +01:00
db_budget.py fix: batch queries on recall (#149) 2026-01-13 13:20:22 +01:00
db_utils.py misc: performance improvements (#140) 2026-01-09 14:47:20 +01:00
embeddings.py fix: hide hf logging (#295) 2026-02-04 13:12:30 +01:00
entity_resolver.py fix: misc perf improvements (#133) 2026-01-08 22:49:04 +01:00
interface.py chore: remove dead code (#245) 2026-01-30 09:16:32 +01:00
llm_interface.py feat: support for codex and claude-code as llm (#276) 2026-02-02 12:54:44 +01:00
llm_wrapper.py feat: support for codex and claude-code as llm (#276) 2026-02-02 12:54:44 +01:00
memory_engine.py feat: ai sdk integration (#299) 2026-02-04 20:25:59 +01:00
query_analyzer.py fix: improve mpfp retrieval (#146) 2026-01-12 18:58:05 +01:00
response_models.py chore: remove dead code (#245) 2026-01-30 09:16:32 +01:00
task_backend.py fix: retain async fails if timestamp is set (#251) 2026-01-30 13:04:33 +01:00
utils.py chore: remove dead code (#245) 2026-01-30 09:16:32 +01:00