fix(checkpoints): retain thread-start baseline after failed runs
Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
c4f3a78407
commit
4626a059d9
1 file changed
+29
-6
@@ -92,12 +92,21 @@ export const layer: Layer.Layer<
|
||||
|
||||
const capturedAt = yield* DateTime.now;
|
||||
const baselineOrdinalWithinScope = Math.max(0, run.ordinal - 1);
|
||||
const baselineCheckpoint = projection.checkpoints.some(
|
||||
(candidate) =>
|
||||
candidate.scopeId === scope.id &&
|
||||
candidate.ordinalWithinScope === baselineOrdinalWithinScope &&
|
||||
candidate.status === "ready",
|
||||
)
|
||||
const hasReadyCheckpoint = (ordinalWithinScope: number) =>
|
||||
projection.checkpoints.some(
|
||||
(candidate) =>
|
||||
candidate.scopeId === scope.id &&
|
||||
candidate.ordinalWithinScope === ordinalWithinScope &&
|
||||
candidate.status === "ready",
|
||||
);
|
||||
const threadStartCheckpoint =
|
||||
baselineOrdinalWithinScope === 0 || hasReadyCheckpoint(0)
|
||||
? null
|
||||
: yield* checkpoints.materializeBaselineCheckpoint({
|
||||
scope,
|
||||
ordinalWithinScope: 0,
|
||||
});
|
||||
const baselineCheckpoint = hasReadyCheckpoint(baselineOrdinalWithinScope)
|
||||
? null
|
||||
: yield* checkpoints.materializeBaselineCheckpoint({
|
||||
scope,
|
||||
@@ -119,6 +128,20 @@ export const layer: Layer.Layer<
|
||||
acceptedAt: capturedAt,
|
||||
effects: [],
|
||||
events: [
|
||||
...(threadStartCheckpoint === null
|
||||
? []
|
||||
: [
|
||||
{
|
||||
id: yield* ids.allocate.event({ threadId: input.threadId, commandId }),
|
||||
type: "checkpoint.captured" as const,
|
||||
threadId: input.threadId,
|
||||
nodeId: threadStartCheckpoint.nodeId,
|
||||
driver: providerThread.driver,
|
||||
providerInstanceId: run.providerInstanceId,
|
||||
occurredAt: capturedAt,
|
||||
payload: threadStartCheckpoint,
|
||||
},
|
||||
]),
|
||||
...(baselineCheckpoint === null
|
||||
? []
|
||||
: [
|
||||
|
||||
Reference in new issue
Block a user