From 96f0e54efaf43b335c0bbfc52cf9f00403db35f8 Mon Sep 17 00:00:00 2001 From: Chris Bartholomew Date: Mon, 2 Feb 2026 14:45:40 -0500 Subject: [PATCH] Fix: load operation validator extension in worker process (#280) The worker was not loading the OperationValidatorExtension, so operation validation was silently skipped for all async operations (e.g. refresh_mental_model triggered after consolidation). The API server already loaded this extension but the worker entry point was missing it. --- hindsight-api/hindsight_api/worker/main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hindsight-api/hindsight_api/worker/main.py b/hindsight-api/hindsight_api/worker/main.py index 667a048a..a464b7f6 100644 --- a/hindsight-api/hindsight_api/worker/main.py +++ b/hindsight-api/hindsight_api/worker/main.py @@ -176,7 +176,7 @@ def main(): nonlocal memory, poller import uvicorn - from ..extensions import TenantExtension, load_extension + from ..extensions import OperationValidatorExtension, TenantExtension, load_extension # Load tenant extension BEFORE creating MemoryEngine so it can # set correct schema context during task execution. Without this, @@ -184,6 +184,12 @@ def main(): # causing worker writes to land in the wrong schema. tenant_extension = load_extension("TENANT", TenantExtension) + # Load operation validator so workers can record usage metering + # for async operations (e.g. refresh_mental_model after consolidation) + operation_validator = load_extension("OPERATION_VALIDATOR", OperationValidatorExtension) + if operation_validator: + logger.info(f"Loaded operation validator: {operation_validator.__class__.__name__}") + # Initialize MemoryEngine # Workers use SyncTaskBackend because they execute tasks directly, # they don't need to store tasks (they poll from DB) @@ -191,6 +197,7 @@ def main(): run_migrations=False, # Workers don't run migrations task_backend=SyncTaskBackend(), tenant_extension=tenant_extension, + operation_validator=operation_validator, ) await memory.initialize()