test(server): give the failed-run termination test its own agent

The test shared one agent between its cancellable run and its
deliberately-failing run. Cancelling the first run made the agent
claim its next queued run — the second run — and that claim failed
for an unrelated reason, so the intended cancellation never happened.

Give the failing run its own agent, so only the intended failure
path runs.

Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
nickyleachandPaperclip committed 2026-09-16 08:20:31 +00:00
1 parent 7dcdd6ae1b
commit 4bc1045e0f
1 file changed
+5 -1
@@ -292,11 +292,15 @@ describeEmbeddedPostgres("terminateActiveRunsForTaskDrain", () => {
// A native run with no bound issue fails deterministically inside the
// real cancellation path (`native_cancellation_binding_missing`), so
// this proves the loop keeps going past one failed run without a race.
// Give it its own agent: cancelling okRunId claims the next queued run
// for ITS agent, so a shared agent would let that claim reach this run
// first and fail it for an unrelated reason before termination did.
const failingAgentId = await seedAgent(companyId);
const failingRunId = randomUUID();
await db.insert(heartbeatRuns).values({
id: failingRunId,
companyId,
agentId,
agentId: failingAgentId,
invocationSource: "assignment",
status: "queued",
runtimeMode: "native",