fleet-memory/hindsight-api/hindsight_api/api
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
..
__init__.py misc: add mcp integration tests and increase test coverage (#98) 2026-01-05 11:16:55 +01:00
http.py fix: multi-tenant schema context for worker task execution (#208) 2026-01-27 12:28:47 +01:00
mcp.py feat(mcp): add timestamp to retain (#190) 2026-01-23 16:00:43 +01:00