Skip to content

Commit cfa4450

Browse files
fix(server): cover pending-work guards for terminal statuses
Adds regression coverage that completed, interrupted, cancelled, and rolled_back threads are still retained while background tasks or runtime requests are pending.
1 parent c324c3a commit cfa4450

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎apps/server/src/storageCleanup.test.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
ProjectId,
44
ProviderInstanceId,
55
RunId,
6+
RuntimeRequestId,
67
ThreadId,
78
type OrchestrationV2ThreadShell,
89
} from "@t3tools/contracts";
@@ -87,6 +88,40 @@ describe("V2 storage cleanup eligibility", () => {
8788
},
8889
);
8990

91+
it.each(["completed", "interrupted", "cancelled", "rolled_back"] as const)(
92+
"retains %s while background work is pending",
93+
(status) => {
94+
expect(
95+
storageCleanupThreadIdle(
96+
{
97+
...candidateWithStatus(status),
98+
pendingBackgroundTasks: [{ taskId: "task-1", kind: "command" }],
99+
},
100+
NOW_MS,
101+
),
102+
).toBe(false);
103+
},
104+
);
105+
106+
it.each(["completed", "interrupted", "cancelled", "rolled_back"] as const)(
107+
"retains %s while a runtime request is pending",
108+
(status) => {
109+
expect(
110+
storageCleanupThreadIdle(
111+
{
112+
...candidateWithStatus(status),
113+
pendingRuntimeRequest: {
114+
id: RuntimeRequestId.make("request-1"),
115+
kind: "command",
116+
createdAt: at(0),
117+
},
118+
},
119+
NOW_MS,
120+
),
121+
).toBe(false);
122+
},
123+
);
124+
90125
it("retains an active run even if the shell status is idle", () => {
91126
expect(
92127
storageCleanupThreadIdle({ ...candidate(), activeRunId: RunId.make("run") }, NOW_MS),

0 commit comments

Comments
 (0)