diff --git a/doc/idle-environment-cleanup.md b/doc/idle-environment-cleanup.md index aef7b0e870c..a8d2ecdff02 100644 --- a/doc/idle-environment-cleanup.md +++ b/doc/idle-environment-cleanup.md @@ -124,3 +124,25 @@ reconciliation survive drain. A missing expiry retains the existing behavior (no inferred expiration); sleep safety still treats unsupported live resources conservatively. Provider cancellation, failure state, and historical resource verification keep their existing semantics. No Cloud alarm coverage changes. + +## Historical retry test observation + +The historical verification worker intentionally does not delay server readiness. +Its provider sweep finishes before the following database pending-state read +registers a retry deadline. The regression test now waits for that future +deadline before inspecting it; sweep completion alone is not scheduler settlement. +The runtime worker, retry interval, and readiness contract are unchanged. + +A controlled 150ms delay before the real pending-state query reproduced the +current CI failure: the immediate assertion observed a null deadline. The +corrected assertion passed with the same delay. The temporary delay was removed, +and all 14 cleanup tests passed against an isolated PostgreSQL database. The +existing external test-database hook is carried at the stack foundation so +intermediate branches can use this same verification path. + +An initial attempt at the foundation could not start embedded PostgreSQL because +that earlier branch lacked the external fixture hook. A broader fixture wait for +all idle holds to clear then failed three cases that legitimately retain pending +cleanup obligations. That wait was removed. Only the historical deadline assertion +changed; its requirement is now a deadline strictly in the future. The complete +suite passes with the original readiness and idle-hold behavior preserved. diff --git a/server/src/__tests__/environment-cleanup-work.test.ts b/server/src/__tests__/environment-cleanup-work.test.ts index a730d8b2e42..5d71d2d4d42 100644 --- a/server/src/__tests__/environment-cleanup-work.test.ts +++ b/server/src/__tests__/environment-cleanup-work.test.ts @@ -238,7 +238,10 @@ describe.skipIf(!support.supported)("environment cleanup scheduling", () => { it("keeps unknown historical resources scheduled until provider confirmation", async () => { const lease = await pending(); await environmentService(db).releaseLease(lease.id, "failed", { cleanupStatus: "success" }); inspections.mockResolvedValueOnce({ providerLeaseId: lease.providerLeaseId, state: "unknown" }); - await start(true); expect(coordinator!.nextWakeAt()).not.toBeNull(); + await start(true); + // The provider sweep finishes before its pending-state read registers the + // retry. Readiness intentionally does not wait for historical verification. + await vi.waitFor(() => expect(coordinator!.nextWakeAt()).toBeGreaterThan(Date.now())); await settle(300_000); expect(inspections).toHaveBeenCalledTimes(2); await quiet(); }); });