From cd27095c23f4ce9ae08b527459133b486a2d8521 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Fri, 16 Oct 2026 13:35:56 +0200 Subject: [PATCH 1/2] =?UTF-8?q?test:=20reproduce=20#574=20=E2=80=94=20prev?= =?UTF-8?q?iew=20before=20reclaim=20finishes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Script a slow reclaim so the dry-run setup observes the same missing-ready assertion without relying on host load. --- e2e/capacity-cleanup-nuke.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/capacity-cleanup-nuke.test.ts b/e2e/capacity-cleanup-nuke.test.ts index d55c1d75c..277145f07 100644 --- a/e2e/capacity-cleanup-nuke.test.ts +++ b/e2e/capacity-cleanup-nuke.test.ts @@ -184,6 +184,7 @@ describe("capacity, warm pool, cleanup, and nuke", () => { await waitForCleanupToReach(env, grantX.device.driverDeviceId, "shutdown"); // cleanup --dry-run must report proposals without acting on them. + await env.driverScript.merge({ ios: { latencyMs: { reclaim: 5_000 } } }); await releaseAndForget(env, "dryrun-z"); const rowsAfterZ = await deviceRows(env); const readyDevice = rowsAfterZ.find((row) => row.state === "ready"); From 2e7e5339208d473a5c72b7d7b60e976b8f1acfd8 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Fri, 16 Oct 2026 13:41:38 +0200 Subject: [PATCH 2/2] fix: wait for released device reclaim before cleanup preview 1 failing -> 0 failing. Carry the granted device identity into the dry-run setup and await its ready state while preserving asynchronous release and the slow-reclaim fixture. --- e2e/capacity-cleanup-nuke.test.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/e2e/capacity-cleanup-nuke.test.ts b/e2e/capacity-cleanup-nuke.test.ts index 277145f07..64d2d279e 100644 --- a/e2e/capacity-cleanup-nuke.test.ts +++ b/e2e/capacity-cleanup-nuke.test.ts @@ -57,14 +57,18 @@ function leaseHolder( async function releaseAndForget( env: Awaited>, agentId: string, -): Promise { +): Promise { const holder = leaseHolder(env, agentId); - const grant = JSON.parse(await holder.firstStdoutLine()) as { lease: { id: string } }; + const grant = JSON.parse(await holder.firstStdoutLine()) as { + lease: { id: string }; + device: { driverDeviceId: string }; + }; // Released explicitly, before the process is killed: a SIGKILLed holder frees nothing // (ADR 0004 ยง3), so the release has to be its own step for the device to come back. await env.cli(["release", grant.lease.id]); holder.kill("SIGKILL"); await holder.waitForExit(15_000).catch(() => undefined); + return grant.device.driverDeviceId; } /** @@ -112,10 +116,6 @@ describe("capacity, warm pool, cleanup, and nuke", () => { label: "second requester queues on the managed-device limit, not the running limit", }); - // Release the held device with a deliberately slow reclaim so its transient - // `reclaiming` state is observable. The release RPC itself waits for reclaim to - // finish before responding, so the poll for "reclaiming" must run concurrently - // with the release call, not after it. await env.driverScript.merge({ ios: { latencyMs: { reclaim: 1_500 } } }); const releasePromise = env.cli(["release", grantA.lease.id]); @@ -185,9 +185,12 @@ describe("capacity, warm pool, cleanup, and nuke", () => { // cleanup --dry-run must report proposals without acting on them. await env.driverScript.merge({ ios: { latencyMs: { reclaim: 5_000 } } }); - await releaseAndForget(env, "dryrun-z"); + const dryRunDeviceId = await releaseAndForget(env, "dryrun-z"); + await waitForDeviceState(env, dryRunDeviceId, "ready"); const rowsAfterZ = await deviceRows(env); - const readyDevice = rowsAfterZ.find((row) => row.state === "ready"); + const readyDevice = rowsAfterZ.find( + (row) => row.driverDeviceId === dryRunDeviceId && row.state === "ready", + ); expect(readyDevice, "expected a ready (warm) device for the dry-run preview").toBeDefined(); await waitFor(