From 9e044021efabe2e3e54b65c1f8f5b4f0fc73777d Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Wed, 22 Jul 2026 10:53:10 -0700 Subject: [PATCH] test(supervisor): update runner fixture mock for #2750 lock path tryAcquireDbLock now acquires via engine.executeRaw (signal-boundable) and releases via engine.executeRawDirect instead of the sql tagged template. The fixture's mock engine returned [] from executeRaw, so every spawned supervisor failed lock acquisition and exited LOCK_HELD (2), breaking all 8 supervisor integration tests. The mock now returns the lock row for gbrain_cycle_locks queries and stubs executeRawDirect. Co-Authored-By: Claude Fable 5 --- test/fixtures/supervisor-runner.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/fixtures/supervisor-runner.ts b/test/fixtures/supervisor-runner.ts index 6a98979af..79714a0dc 100644 --- a/test/fixtures/supervisor-runner.ts +++ b/test/fixtures/supervisor-runner.ts @@ -24,15 +24,18 @@ import type { BrainEngine } from '../../src/core/engine.ts'; // Mock engine: healthCheck() calls engine.executeRaw; return empty rows so // the query path exercises without needing Postgres. // -// #1849: start() now acquires the queue-scoped DB singleton lock via -// tryAcquireDbLock, which uses the postgres `sql` tagged-template escape hatch. -// The stub returns a single row from every call so acquire succeeds (length 1 -// → acquired) and refresh/release are no-ops. Each spawned runner is a fresh -// process, so there's no cross-test lock state to clean up. +// #1849: start() acquires the queue-scoped DB singleton lock via +// tryAcquireDbLock. #2750 routed the acquire upsert through engine.executeRaw +// (signal-boundable) and release through engine.executeRawDirect, so the +// stub returns a single row from the lock upsert (length 1 → acquired) and +// empty rows everywhere else. Each spawned runner is a fresh process, so +// there's no cross-test lock state to clean up. const sqlStub = (..._args: unknown[]) => Promise.resolve([{ id: 'supervisor-lock' }]); const mockEngine: Partial = { kind: 'postgres' as const, - executeRaw: async () => [], + executeRaw: async (query: string) => + query.includes('gbrain_cycle_locks') ? [{ id: 'supervisor-lock' }] : [], + executeRawDirect: async () => [], sql: sqlStub, } as unknown as BrainEngine;