Skip to content

Commit 96f0e54

Browse files
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.
1 parent 3825506 commit 96f0e54

File tree

1 file changed

+8
-1
lines changed
  • hindsight-api/hindsight_api/worker

1 file changed

+8
-1
lines changed

hindsight-api/hindsight_api/worker/main.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,21 +176,28 @@ async def run():
176176
nonlocal memory, poller
177177
import uvicorn
178178

179-
from ..extensions import TenantExtension, load_extension
179+
from ..extensions import OperationValidatorExtension, TenantExtension, load_extension
180180

181181
# Load tenant extension BEFORE creating MemoryEngine so it can
182182
# set correct schema context during task execution. Without this,
183183
# _authenticate_tenant sees no extension and resets schema to "public",
184184
# causing worker writes to land in the wrong schema.
185185
tenant_extension = load_extension("TENANT", TenantExtension)
186186

187+
# Load operation validator so workers can record usage metering
188+
# for async operations (e.g. refresh_mental_model after consolidation)
189+
operation_validator = load_extension("OPERATION_VALIDATOR", OperationValidatorExtension)
190+
if operation_validator:
191+
logger.info(f"Loaded operation validator: {operation_validator.__class__.__name__}")
192+
187193
# Initialize MemoryEngine
188194
# Workers use SyncTaskBackend because they execute tasks directly,
189195
# they don't need to store tasks (they poll from DB)
190196
memory = MemoryEngine(
191197
run_migrations=False, # Workers don't run migrations
192198
task_backend=SyncTaskBackend(),
193199
tenant_extension=tenant_extension,
200+
operation_validator=operation_validator,
194201
)
195202

196203
await memory.initialize()

0 commit comments

Comments
 (0)