fleet-memory/hindsight-api/hindsight_api/worker
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 feat: new 'worker' service (#176) 2026-01-20 10:17:56 +01:00
main.py fix: improve mental model consolidation (#197) 2026-01-26 09:54:25 +01:00
poller.py fix: multi-tenant schema context for worker task execution (#208) 2026-01-27 12:28:47 +01:00