fleet-memory/hindsight-api-slim/hindsight_api/engine/retain
Nicolò Boschi f50cc25dfb
perf(stats): add bank_id to memory_links for direct filtering (#718)
The stats endpoint JOINs memory_links to memory_units just to filter
by bank_id.  With 8.2M+ links per bank this takes 18+ seconds, and
the control plane polls every 10s — perpetually blocking the server.

Add bank_id column directly to memory_links so the query can filter
on ml.bank_id instead of mu.bank_id, letting Postgres push the filter
down before the JOIN.

- Migration: add bank_id TEXT NOT NULL, backfill from memory_units
- All 4 INSERT paths (temporal, semantic, entity, causal) now write bank_id
- Stats query filters on ml.bank_id instead of mu.bank_id
2026-03-27 16:12:13 +01:00
..
__init__.py feat: introduce hindsight-api-slim and hindsight-all-slim packages (#560) 2026-03-13 13:50:03 +01:00
bank_utils.py feat: introduce hindsight-api-slim and hindsight-all-slim packages (#560) 2026-03-13 13:50:03 +01:00
chunk_storage.py feat(retain): delta retain — skip LLM for unchanged chunks on upsert (#701) 2026-03-26 13:50:55 +01:00
embedding_processing.py feat: introduce hindsight-api-slim and hindsight-all-slim packages (#560) 2026-03-13 13:50:03 +01:00
embedding_utils.py feat: introduce hindsight-api-slim and hindsight-all-slim packages (#560) 2026-03-13 13:50:03 +01:00
entity_labels.py feat: introduce hindsight-api-slim and hindsight-all-slim packages (#560) 2026-03-13 13:50:03 +01:00
entity_processing.py perf(stats): add bank_id to memory_links for direct filtering (#718) 2026-03-27 16:12:13 +01:00
fact_extraction.py fix: correctly map LLM fact_type \"assistant\" to \"experience\" for DB storage (#609) 2026-03-19 10:32:08 +01:00
fact_storage.py feat(retain): delta retain — skip LLM for unchanged chunks on upsert (#701) 2026-03-26 13:50:55 +01:00
link_creation.py perf(stats): add bank_id to memory_links for direct filtering (#718) 2026-03-27 16:12:13 +01:00
link_utils.py perf(stats): add bank_id to memory_links for direct filtering (#718) 2026-03-27 16:12:13 +01:00
orchestrator.py perf(stats): add bank_id to memory_links for direct filtering (#718) 2026-03-27 16:12:13 +01:00
types.py feat: introduce hindsight-api-slim and hindsight-all-slim packages (#560) 2026-03-13 13:50:03 +01:00