Skip to content

Commit 83fe05c

Browse files
committed
fix(server): include artifacts in unreadable projection scan
1 parent 19e19d5 commit 83fe05c

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
EventId,
66
MessageId,
77
NodeId,
8+
OrchestrationV2ThreadArtifactId,
89
type OrchestrationV2AppThread,
910
type OrchestrationV2Run,
1011
ProjectId,
@@ -1408,3 +1409,37 @@ it.effect("startup ends the provider turn of a native child root it cancels", ()
14081409
);
14091410
}).pipe(Effect.provide(layerRecoveryTest)),
14101411
);
1412+
1413+
it.effect("marks threads with corrupt artifact payloads unreadable", () =>
1414+
Effect.gen(function* () {
1415+
const projections = yield* ProjectionStore.ProjectionStoreV2;
1416+
const sql = yield* SqlClient.SqlClient;
1417+
const now = yield* DateTime.now;
1418+
const threadId = yield* createThread("artifact-corrupt");
1419+
1420+
yield* projections.apply({
1421+
id: EventId.make("event:artifact-corrupt:updated"),
1422+
type: "artifact.updated",
1423+
threadId,
1424+
occurredAt: now,
1425+
payload: {
1426+
id: OrchestrationV2ThreadArtifactId.make("artifact:recovery:1"),
1427+
kind: "file",
1428+
title: "Artifact",
1429+
description: null,
1430+
payload: { path: "/tmp/out.txt" },
1431+
runId: null,
1432+
messageId: null,
1433+
createdAt: now,
1434+
updatedAt: now,
1435+
},
1436+
});
1437+
1438+
assert.deepEqual(yield* projections.getUnreadableThreadIds(), []);
1439+
yield* sql`
1440+
UPDATE orchestration_v2_projection_artifacts SET payload_json = '{}'
1441+
WHERE artifact_id = ${"artifact:recovery:1"}
1442+
`;
1443+
assert.deepEqual(yield* projections.getUnreadableThreadIds(), [threadId]);
1444+
}).pipe(Effect.provide(layerTest)),
1445+
);

‎apps/server/src/orchestration-v2/ProjectionStore.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4380,6 +4380,11 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
43804380
decode: (payload) => decodeMessagePayload(payload),
43814381
},
43824382
{ name: "plans", id: "plan_id", decode: (payload) => decodePlanJson(payload) },
4383+
{
4384+
name: "artifacts",
4385+
id: "artifact_id",
4386+
decode: (payload) => decodeArtifactPayload(payload),
4387+
},
43834388
{
43844389
name: "turn_items",
43854390
id: "turn_item_id",

0 commit comments

Comments
 (0)