The best way to control Claude Code, Codex and more from any computer or phone
fix(server): keep corrupt plan JSON in the typed read error (#21969)
Julius Marminge committed
Oct 19, 2026 at 19:38 UTC
c2fb438b38f5beb970dca6ced542b9f2a7f85f34
2 files changed
+29
-2
apps/server/src/orchestration-v2/ProjectionStore.test.ts
+25
@@ -11,6 +11,7 @@ import {
11
type OrchestrationV2ProviderThread,
12
type OrchestrationV2ThreadShellSnapshot,
13
NodeId,
14
+ PlanId,
15
ProjectId,
16
ProviderDriverKind,
17
ProviderInstanceId,
@@ -997,6 +998,30 @@ it.effect("memory shell snapshots scope to one project", () =>
998
);
999
1000
it.layer(layerTest)("ProjectionStoreV2", (it) => {
1001
+ it.effect("returns a typed read error for malformed stored plan JSON", () =>
1002
+ Effect.gen(function* () {
1003
+ const store = yield* ProjectionStore.ProjectionStoreV2;
1004
+ const sql = yield* SqlClient.SqlClient;
1005
+ const threadId = yield* addRolledBackRecoveryCandidate("corrupt-plan");
1006
+ const planId = PlanId.make("plan:corrupt");
1007
+ yield* sql`INSERT INTO orchestration_v2_projection_plans
1008
+ (plan_id, thread_id, node_id, kind, status, payload_json)
1009
+ VALUES (${planId}, ${threadId}, 'node:corrupt-plan', 'proposed_plan', 'active', '{broken')`;
1010
+
1011
+ const failure = yield* store
1012
+ .getPlan(threadId, planId)
1013
+ .pipe(
1014
+ Effect.flip,
1015
+ Effect.ensuring(
1016
+ Effect.orDie(
1017
+ sql`DELETE FROM orchestration_v2_projection_plans WHERE plan_id = ${planId}`,
1018
+ ),
1019
+ ),
1020
+ );
1021
+ assert.strictEqual(failure._tag, "ProjectionStoreReadError");
1022
+ }),
1023
+ );
1024
+
1025
it.effect(
1026
"SQL recovery selects unfinished runless native subagents",
1027
() => runlessNativeSubagentNeedsRecovery,
apps/server/src/orchestration-v2/ProjectionStore.ts
+4
-2
@@ -1148,6 +1148,7 @@ const encodeMessagePayload = Schema.encodeEffect(
1148
const encodePlanPayload = Schema.encodeEffect(
1149
Schema.fromJsonString(OrchestrationV2PlanArtifactSchema),
1150
);
1151
+const decodePlanPayload = (json: string) => decodePlanJson(json);
1152
const encodeTurnItemPayload = Schema.encodeEffect(
1153
Schema.fromJsonString(OrchestrationV2TurnItemJsonSchema),
1154
);
@@ -1194,8 +1195,9 @@ const decodeRuntimeRequestPayload = Schema.decodeUnknownEffect(
1195
const decodeMessagePayload = Schema.decodeUnknownEffect(
1196
Schema.fromJsonString(OrchestrationV2ConversationMessageJsonSchema),
1197
);
1197
-const decodePlanArtifact = Schema.decodeUnknownEffect(OrchestrationV2PlanArtifactSchema);
1198
-const decodePlanPayload = (json: string) => decodePlanArtifact(parseEncodedPayload(json));
1198
+const decodePlanJson = Schema.decodeUnknownEffect(
1199
+ Schema.fromJsonString(OrchestrationV2PlanArtifactSchema),
1200
+);
1201
const decodeTurnItemPayload = Schema.decodeUnknownEffect(
1202
Schema.fromJsonString(OrchestrationV2TurnItemJsonSchema),
1203
);