The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 07:00 UTC
fix(server): a stored boolean settledOverride no longer stops startup (#28314)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 1, 2026 at 21:30 UTC
1973e0a68f45a11b642d521724543431585d5f9e
4 files changed
+106
apps/server/src/persistence/Migrations.ts
+2
@@ -79,6 +79,7 @@ import Migration0073 from "./Migrations/073_ActiveTurnItemIndexes.ts";
79
import Migration0074 from "./Migrations/074_ExcludeAttachmentPlaceholdersFromSearch.ts";
80
import Migration0075 from "./Migrations/075_SubagentDeliveryState.ts";
81
import Migration0076 from "./Migrations/076_ProjectionProjectsPinArchive.ts";
82
+import Migration0077 from "./Migrations/077_RepairBooleanSettledOverride.ts";
83
84
const migrationEntries = [
85
[1, "OrchestrationEvents", Migration0001],
@@ -158,6 +159,7 @@ const migrationEntries = [
159
[74, "ExcludeAttachmentPlaceholdersFromSearch", Migration0074],
160
[75, "SubagentDeliveryState", Migration0075],
161
[76, "ProjectionProjectsPinArchive", Migration0076],
162
+ [77, "RepairBooleanSettledOverride", Migration0077],
163
] as const;
164
165
export const migrationManifest = migrationEntries.map(([id, name]) => [id, name] as const);
apps/server/src/persistence/Migrations/077_RepairBooleanSettledOverride.test.ts
new
+88
@@ -0,0 +1,88 @@
1
+import { assert, it } from "@effect/vitest";
2
+import { OrchestrationV2AppThreadJson } from "@t3tools/contracts";
3
+import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
4
+import * as Effect from "effect/Effect";
5
+import * as Schema from "effect/Schema";
6
+import * as SqlClient from "effect/sql/SqlClient";
7
+
8
+import { runMigrations } from "../Migrations.ts";
9
+
10
+const layer = it.layer(NodeSqliteClient.layer({ filename: ":memory:" }));
11
+const createdAt = "2026-09-01T00:00:00.000Z";
12
+const decodeThreadPayload = Schema.decodeUnknownEffect(
13
+ Schema.fromJsonString(OrchestrationV2AppThreadJson),
14
+);
15
+
16
+layer("077_RepairBooleanSettledOverride", (it) => {
17
+ it.effect("canonicalizes boolean settled overrides so recovery can decode them", () =>
18
+ Effect.gen(function* () {
19
+ const sql = yield* SqlClient.SqlClient;
20
+ yield* runMigrations({ toMigrationInclusive: 76 });
21
+ const overrides: ReadonlyArray<readonly [string, unknown]> = [
22
+ ["true", true],
23
+ ["false", false],
24
+ ["settled", "settled"],
25
+ ["active", "active"],
26
+ ["null", null],
27
+ ["absent", undefined],
28
+ ];
29
+ for (const [id, settledOverride] of overrides) {
30
+ const payload = {
31
+ id,
32
+ projectId: "project-1",
33
+ title: id,
34
+ providerInstanceId: "codex",
35
+ modelSelection: { instanceId: "codex", model: "gpt-5.4" },
36
+ runtimeMode: "full-access",
37
+ interactionMode: "default",
38
+ createdBy: "user",
39
+ creationSource: "web",
40
+ branch: null,
41
+ worktreePath: null,
42
+ activeProviderThreadId: null,
43
+ lineage: { parentThreadId: null, relationshipToParent: null, rootThreadId: id },
44
+ forkedFrom: null,
45
+ createdAt,
46
+ updatedAt: createdAt,
47
+ archivedAt: null,
48
+ deletedAt: null,
49
+ settledOverride,
50
+ settledAt: settledOverride === true ? createdAt : null,
51
+ };
52
+ yield* sql`
53
+ INSERT INTO orchestration_v2_projection_threads (
54
+ thread_id, project_id, title, default_provider, runtime_mode, interaction_mode,
55
+ created_at, updated_at, payload_json
56
+ ) VALUES (
57
+ ${id}, 'project-1', ${id}, 'codex', 'full-access', 'default',
58
+ ${createdAt}, ${createdAt}, ${JSON.stringify(payload)}
59
+ )
60
+ `;
61
+ }
62
+ const rows = sql<{ readonly thread_id: string; readonly payload_json: string }>`
63
+ SELECT thread_id, payload_json FROM orchestration_v2_projection_threads ORDER BY thread_id
64
+ `;
65
+ const before = new Map((yield* rows).map((row) => [row.thread_id, row.payload_json]));
66
+
67
+ yield* runMigrations({ toMigrationInclusive: 77 });
68
+ const after = new Map((yield* rows).map((row) => [row.thread_id, row.payload_json]));
69
+ for (const id of ["settled", "active", "null", "absent"]) {
70
+ assert.strictEqual(after.get(id), before.get(id));
71
+ }
72
+ const repaired = yield* sql`
73
+ SELECT thread_id,
74
+ json_type(payload_json, '$.settledOverride') AS type,
75
+ json_extract(payload_json, '$.settledOverride') AS settled_override,
76
+ json_extract(payload_json, '$.settledAt') AS settled_at
77
+ FROM orchestration_v2_projection_threads WHERE thread_id IN ('true', 'false')
78
+ ORDER BY thread_id
79
+ `;
80
+ assert.deepStrictEqual(repaired, [
81
+ { thread_id: "false", type: "null", settled_override: null, settled_at: null },
82
+ { thread_id: "true", type: "text", settled_override: "settled", settled_at: createdAt },
83
+ ]);
84
+ const thread = yield* decodeThreadPayload(after.get("true"));
85
+ assert.strictEqual(thread.settledOverride, "settled");
86
+ }),
87
+ );
88
+});
apps/server/src/persistence/Migrations/077_RepairBooleanSettledOverride.ts
new
+14
@@ -0,0 +1,14 @@
1
+import * as Effect from "effect/Effect";
2
+import * as SqlClient from "effect/sql/SqlClient";
3
+
4
+// Thread projections may hold a boolean settledOverride, which the thread schema rejects.
5
+export default Effect.gen(function* () {
6
+ const sql = yield* SqlClient.SqlClient;
7
+ yield* sql`
8
+ UPDATE orchestration_v2_projection_threads
9
+ SET payload_json = json_set(payload_json, '$.settledOverride',
10
+ IIF(json_type(payload_json, '$.settledOverride') = 'true', 'settled', NULL))
11
+ WHERE json_valid(payload_json)
12
+ AND json_type(payload_json, '$.settledOverride') IN ('true', 'false')
13
+ `;
14
+});
apps/server/src/persistence/reconcileV2PreviewMigration.test.ts
+2
@@ -56,6 +56,7 @@ describe("V2 preview upgrade", () => {
56
[74, "ExcludeAttachmentPlaceholdersFromSearch"],
57
[75, "SubagentDeliveryState"],
58
[76, "ProjectionProjectsPinArchive"],
59
+ [77, "RepairBooleanSettledOverride"],
60
]);
61
assert.deepStrictEqual(yield* runMigrations(), []);
62
assert.deepStrictEqual(yield* sql`SELECT * FROM orchestration_v2_legacy_imports`, imports);
@@ -155,6 +156,7 @@ describe("V2 preview upgrade", () => {
156
[74, "ExcludeAttachmentPlaceholdersFromSearch"],
157
[75, "SubagentDeliveryState"],
158
[76, "ProjectionProjectsPinArchive"],
159
+ [77, "RepairBooleanSettledOverride"],
160
]);
161
}).pipe(Effect.provide(NodeSqliteClient.layer({ filename: ":memory:" }))),
162
);