Skip to content

Commit 50fb2be

Browse files
Bil0000claude
andcommitted
test(orchestration): prove a queued refresh runs after the first ends
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e4f1339 commit 50fb2be

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎apps/server/src/orchestration-v2/RunFinalizationService.test.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ThreadId,
66
type OrchestrationV2ThreadShell,
77
} from "@t3tools/contracts";
8+
import * as Deferred from "effect/Deferred";
89
import * as Effect from "effect/Effect";
910
import * as Layer from "effect/Layer";
1011

@@ -20,6 +21,8 @@ it.effect("runs refreshes per checkout one at a time, without blocking finalize"
2021
const runId = RunId.make("run_refresh_failure");
2122
const scopeId = CheckpointScopeId.make("scope_refresh_failure");
2223
const captured: string[] = [];
24+
const releaseFirst = Deferred.makeUnsafe<void>();
25+
const secondRan = Deferred.makeUnsafe<void>();
2326
const layer = RunFinalization.layer.pipe(
2427
Layer.provide(
2528
Layer.mergeAll(
@@ -39,9 +42,12 @@ it.effect("runs refreshes per checkout one at a time, without blocking finalize"
3942
}),
4043
Layer.succeed(RunFinalization.RunFinalizationObserver, {
4144
refresh: () =>
42-
Effect.sync(() => {
45+
Effect.suspend(() => {
4346
captured.push("refresh");
44-
}).pipe(Effect.andThen(Effect.never)),
47+
return captured.filter((step) => step === "refresh").length === 1
48+
? Deferred.await(releaseFirst)
49+
: Deferred.succeed(secondRan, undefined);
50+
}),
4551
refreshAfterTurn: () => Effect.void,
4652
}),
4753
),
@@ -52,6 +58,9 @@ it.effect("runs refreshes per checkout one at a time, without blocking finalize"
5258
yield* service.finalize({ threadId, runId, scopeId });
5359
yield* service.finalize({ threadId, runId, scopeId });
5460
assert.deepEqual(captured, ["checkpoint", "refresh", "checkpoint"]);
61+
yield* Deferred.succeed(releaseFirst, undefined);
62+
yield* Deferred.await(secondRan);
63+
assert.deepEqual(captured, ["checkpoint", "refresh", "checkpoint", "refresh"]);
5564
}).pipe(Effect.provide(layer));
5665
});
5766

0 commit comments

Comments
 (0)