fleet-memory/hindsight-api/hindsight_api/engine
Chris Bartholomew 83f44c4b41
fix: multi-tenant schema context for worker task execution (#208)
Background tasks (async retain, consolidation, reflections) fail in
multi-tenant deployments because the worker executes tasks without
setting the tenant schema context. This causes two failures:

1. The cancellation check in execute_task queries public.async_operations
   instead of the tenant's schema, finds no row, and skips the task as
   "cancelled" — even though it wasn't.

2. Even if that were fixed, _authenticate_tenant would throw
   AuthenticationError because background tasks have no API key.

Changes:
- Poller passes task.schema into task_dict so execute_task can set it
- execute_task sets _current_schema before the cancellation check
- Task handlers use RequestContext(internal=True) to signal background ops
- _authenticate_tenant skips extension auth for internal requests when
  schema is already set
- BrokerTaskBackend uses schema_getter for dynamic schema resolution
  when submitting tasks and waiting for results
- Pass tenant_extension to WorkerPoller in create_app
2026-01-27 12:28:47 +01:00
..
consolidation chore: internal renames (#204) 2026-01-27 09:53:28 +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
reflect chore: internal renames (#204) 2026-01-27 09:53:28 +01:00
retain feat: revisit mental models, directives and reflections (#179) 2026-01-22 17:13:16 +01:00
search feat: revisit mental models, directives and reflections (#179) 2026-01-22 17:13:16 +01:00
__init__.py feat: extensions (#54) 2025-12-22 11:05:23 +01:00
cross_encoder.py fix: simplify pytorch model initialization to prevent meta tensor issues (#185) 2026-01-22 16:25:28 +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: simplify pytorch model initialization to prevent meta tensor issues (#185) 2026-01-22 16:25:28 +01:00
entity_resolver.py fix: misc perf improvements (#133) 2026-01-08 22:49:04 +01:00
interface.py feat: introduce mental models (#132) 2026-01-16 11:16:41 +01:00
llm_wrapper.py fix: improve mental model consolidation (#197) 2026-01-26 09:54:25 +01:00
memory_engine.py fix: multi-tenant schema context for worker task execution (#208) 2026-01-27 12:28:47 +01:00
query_analyzer.py fix: improve mpfp retrieval (#146) 2026-01-12 18:58:05 +01:00
response_models.py chore: internal renames (#204) 2026-01-27 09:53:28 +01:00
task_backend.py fix: multi-tenant schema context for worker task execution (#208) 2026-01-27 12:28:47 +01:00
utils.py chore: drop unused access_count column (#178) 2026-01-20 10:36:02 +01:00