From 1018f1ef3706559f74dea2e783910710e9ee8f73 Mon Sep 17 00:00:00 2001 From: Lyon <88232613+pikasTech@users.noreply.github.com> Date: Wed, 24 Jun 2026 06:47:49 +0800 Subject: [PATCH] fix(workbench): seal timing to source event time (#2025) --- internal/cloud/workbench-projection-writer.test.ts | 5 ++++- internal/cloud/workbench-projection-writer.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/cloud/workbench-projection-writer.test.ts b/internal/cloud/workbench-projection-writer.test.ts index 23f50808..3d56938c 100644 --- a/internal/cloud/workbench-projection-writer.test.ts +++ b/internal/cloud/workbench-projection-writer.test.ts @@ -91,7 +91,8 @@ test("workbench projection writer commits terminal owner evidence as sealed dura test("workbench projection event commit writes trace event and checkpoint facts", async () => { const factWrites = []; - const baseStore = createCloudRuntimeStore({ now: () => "2026-06-20T11:00:00.000Z" }); + let now = "2026-06-20T11:01:05.000Z"; + const baseStore = createCloudRuntimeStore({ now: () => now }); const runtimeStore = { allocateWorkbenchProjectedSeq(params, requestMeta) { return baseStore.allocateWorkbenchProjectedSeq(params, requestMeta); @@ -106,6 +107,7 @@ test("workbench projection event commit writes trace event and checkpoint facts" } }; + now = "2026-06-20T11:03:30.000Z"; await writeWorkbenchProjectionEvent({ runtimeStore, event: { @@ -153,6 +155,7 @@ test("workbench projection event commit writes trace event and checkpoint facts" assert.equal(factWrites[1].params.facts.checkpoints[0].projectionStatus, "caught_up"); assert.equal(factWrites[1].params.facts.checkpoints[0].durationMs, 90000); assert.equal(factWrites[1].params.facts.checkpoints[0].finishedAt, "2026-06-20T11:02:00.000Z"); + assert.equal(factWrites[1].params.facts.checkpoints[0].lastEventAt, "2026-06-20T11:02:00.000Z"); }); test("workbench projection event writer allocates projectedSeq idempotently by source event identity", async () => { diff --git a/internal/cloud/workbench-projection-writer.ts b/internal/cloud/workbench-projection-writer.ts index de4046ca..dedc9e57 100644 --- a/internal/cloud/workbench-projection-writer.ts +++ b/internal/cloud/workbench-projection-writer.ts @@ -110,8 +110,8 @@ export async function writeWorkbenchProjectionEvent({ runtimeStore = null, event const previousTiming = normalizeTimingProjection(previousCheckpoint?.timing) ?? normalizeTimingProjection(previousCheckpoint); const explicitStartedAt = optionalTimestampValue(event.startedAt ?? event.traceStartedAt ?? event.runnerStartedAt); const startedAt = explicitStartedAt ?? previousTiming?.startedAt ?? (sourceSeq <= 1 ? occurredAt : null); - const lastEventAt = latestTimestamp(previousTiming?.lastEventAt, occurredAt, projectedAt); - const finishedAt = terminal ? latestTimestamp(previousTiming?.lastEventAt, optionalTimestampValue(event.finishedAt), occurredAt, projectedAt) : null; + const lastEventAt = latestTimestamp(previousTiming?.lastEventAt, occurredAt); + const finishedAt = terminal ? latestTimestamp(previousTiming?.lastEventAt, optionalTimestampValue(event.finishedAt), occurredAt) : null; const timing = eventTimingProjection({ startedAt, lastEventAt, finishedAt, terminal }); const sourceEventId = workbenchSourceEventId(event, { traceId, sourceSeq, occurredAt }); const allocation = await runtimeStore.allocateWorkbenchProjectedSeq({