Skip to content

Commit ecc6bc8

Browse files
committed
fix(models): restore inherited new-thread defaults
1 parent 9b2d043 commit ecc6bc8

10 files changed

Lines changed: 685 additions & 35 deletions

File tree

‎apps/server/src/cli/project.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import * as ProjectionSnapshotQuery from "../orchestration/Services/ProjectionSn
3030
import { OrchestrationLayerLive } from "../orchestration/runtimeLayer.ts";
3131
import { layerConfig as SqlitePersistenceLayerLive } from "../persistence/Layers/Sqlite.ts";
3232
import * as RepositoryIdentityResolver from "../project/RepositoryIdentityResolver.ts";
33-
import * as ServerRuntimeStartup from "../serverRuntimeStartup.ts";
3433
import {
3534
clearPersistedServerRuntimeState,
3635
readPersistedServerRuntimeState,
@@ -481,7 +480,7 @@ const projectAddCommand = Command.make("add", {
481480
projectId,
482481
title,
483482
workspaceRoot,
484-
defaultModelSelection: ServerRuntimeStartup.getAutoBootstrapDefaultModelSelection(),
483+
defaultModelSelection: null,
485484
createdAt: DateTime.formatIso(yield* DateTime.now),
486485
});
487486
return `Added project ${projectId} (${title}) at ${workspaceRoot}.`;

‎apps/server/src/persistence/Migrations.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import Migration0040 from "./Migrations/040_ProjectionProjectFaviconPath.ts";
5656
import Migration0041 from "./Migrations/041_AuthSessionClientConnection.ts";
5757
import Migration0042 from "./Migrations/042_ProjectionThreadLinkedPullRequest.ts";
5858
import Migration0043 from "./Migrations/043_ProjectionThreadsUnsettledAt.ts";
59+
import Migration0044 from "./Migrations/044_ClearImplicitProjectModelDefaults.ts";
5960

6061
/**
6162
* Migration loader with all migrations defined inline.
@@ -111,6 +112,7 @@ export const migrationEntries = [
111112
[41, "AuthSessionClientConnection", Migration0041],
112113
[42, "ProjectionThreadLinkedPullRequest", Migration0042],
113114
[43, "ProjectionThreadsUnsettledAt", Migration0043],
115+
[44, "ClearImplicitProjectModelDefaults", Migration0044],
114116
] as const;
115117

116118
export const migrationManifest = migrationEntries.map(([id, name]) => [id, name] as const);
Lines changed: 317 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,317 @@
1+
import { assert, it } from "@effect/vitest";
2+
import * as Effect from "effect/Effect";
3+
import * as Layer from "effect/Layer";
4+
import * as SqlClient from "effect/unstable/sql/SqlClient";
5+
6+
import { runMigrations } from "../Migrations.ts";
7+
import * as NodeSqliteClient from "../NodeSqliteClient.ts";
8+
9+
const layer = it.layer(Layer.mergeAll(NodeSqliteClient.layerMemory()));
10+
11+
layer("044_ClearImplicitProjectModelDefaults", (it) => {
12+
it.effect("clears creation-only Codex seeds and preserves later default updates", () =>
13+
Effect.gen(function* () {
14+
const sql = yield* SqlClient.SqlClient;
15+
16+
yield* runMigrations({ toMigrationInclusive: 43 });
17+
yield* sql`
18+
INSERT INTO projection_projects (
19+
project_id,
20+
title,
21+
workspace_root,
22+
scripts_json,
23+
created_at,
24+
updated_at,
25+
deleted_at,
26+
default_model_selection_json
27+
) VALUES
28+
(
29+
'auto-sol',
30+
'Auto Sol',
31+
'/tmp/auto-sol',
32+
'[]',
33+
'2026-01-01T00:00:00.000Z',
34+
'2026-01-01T00:00:00.000Z',
35+
NULL,
36+
'{"instanceId":"codex","model":"gpt-5.6-sol"}'
37+
),
38+
(
39+
'auto-5-4',
40+
'Auto 5.4',
41+
'/tmp/auto-5-4',
42+
'[]',
43+
'2026-01-02T00:00:00.000Z',
44+
'2026-01-02T00:00:00.000Z',
45+
NULL,
46+
'{"instanceId":"codex","model":"gpt-5.4"}'
47+
),
48+
(
49+
'renamed-project',
50+
'Renamed project',
51+
'/tmp/renamed-project',
52+
'[]',
53+
'2026-01-03T00:00:00.000Z',
54+
'2026-01-04T00:00:00.000Z',
55+
NULL,
56+
'{"instanceId":"codex","model":"gpt-5.6-sol"}'
57+
),
58+
(
59+
'explicit-meta',
60+
'Explicit metadata update',
61+
'/tmp/explicit-meta',
62+
'[]',
63+
'2026-01-05T00:00:00.000Z',
64+
'2026-01-06T00:00:00.000Z',
65+
NULL,
66+
'{"instanceId":"codex","model":"gpt-5.6-sol"}'
67+
),
68+
(
69+
'explicit-reset',
70+
'Explicit reset',
71+
'/tmp/explicit-reset',
72+
'[]',
73+
'2026-01-07T00:00:00.000Z',
74+
'2026-01-08T00:00:00.000Z',
75+
NULL,
76+
NULL
77+
),
78+
(
79+
'explicit-options',
80+
'Explicit options',
81+
'/tmp/explicit-options',
82+
'[]',
83+
'2026-01-09T00:00:00.000Z',
84+
'2026-01-09T00:00:00.000Z',
85+
NULL,
86+
'{"instanceId":"codex","model":"gpt-5.6-sol","options":[{"id":"reasoningEffort","value":"high"}]}'
87+
),
88+
(
89+
'other-provider',
90+
'Other provider',
91+
'/tmp/other-provider',
92+
'[]',
93+
'2026-01-10T00:00:00.000Z',
94+
'2026-01-10T00:00:00.000Z',
95+
NULL,
96+
'{"instanceId":"claudeAgent","model":"claude-opus-4-8"}'
97+
)
98+
`;
99+
yield* sql`
100+
INSERT INTO orchestration_events (
101+
event_id,
102+
aggregate_kind,
103+
stream_id,
104+
stream_version,
105+
event_type,
106+
occurred_at,
107+
command_id,
108+
causation_event_id,
109+
correlation_id,
110+
actor_kind,
111+
payload_json,
112+
metadata_json
113+
) VALUES
114+
(
115+
'event-auto-sol',
116+
'project',
117+
'auto-sol',
118+
0,
119+
'project.created',
120+
'2026-01-01T00:00:00.000Z',
121+
'command-auto-sol',
122+
NULL,
123+
NULL,
124+
'client',
125+
'{"projectId":"auto-sol","defaultModelSelection":{"instanceId":"codex","model":"gpt-5.6-sol"}}',
126+
'{}'
127+
),
128+
(
129+
'event-auto-5-4',
130+
'project',
131+
'auto-5-4',
132+
0,
133+
'project.created',
134+
'2026-01-02T00:00:00.000Z',
135+
'command-auto-5-4',
136+
NULL,
137+
NULL,
138+
'client',
139+
'{"projectId":"auto-5-4","defaultModelSelection":{"instanceId":"codex","model":"gpt-5.4"}}',
140+
'{}'
141+
),
142+
(
143+
'event-renamed-created',
144+
'project',
145+
'renamed-project',
146+
0,
147+
'project.created',
148+
'2026-01-03T00:00:00.000Z',
149+
'command-renamed-created',
150+
NULL,
151+
NULL,
152+
'client',
153+
'{"projectId":"renamed-project","defaultModelSelection":{"instanceId":"codex","model":"gpt-5.6-sol"}}',
154+
'{}'
155+
),
156+
(
157+
'event-explicit-meta-created',
158+
'project',
159+
'explicit-meta',
160+
0,
161+
'project.created',
162+
'2026-01-05T00:00:00.000Z',
163+
'command-explicit-meta-created',
164+
NULL,
165+
NULL,
166+
'client',
167+
'{"projectId":"explicit-meta","defaultModelSelection":{"instanceId":"codex","model":"gpt-5.6-sol"}}',
168+
'{}'
169+
),
170+
(
171+
'event-explicit-reset-created',
172+
'project',
173+
'explicit-reset',
174+
0,
175+
'project.created',
176+
'2026-01-07T00:00:00.000Z',
177+
'command-explicit-reset-created',
178+
NULL,
179+
NULL,
180+
'client',
181+
'{"projectId":"explicit-reset","defaultModelSelection":{"instanceId":"codex","model":"gpt-5.6-sol"}}',
182+
'{}'
183+
),
184+
(
185+
'event-explicit-options',
186+
'project',
187+
'explicit-options',
188+
0,
189+
'project.created',
190+
'2026-01-09T00:00:00.000Z',
191+
'command-explicit-options',
192+
NULL,
193+
NULL,
194+
'client',
195+
'{"projectId":"explicit-options","defaultModelSelection":{"instanceId":"codex","model":"gpt-5.6-sol","options":[{"id":"reasoningEffort","value":"high"}]}}',
196+
'{}'
197+
),
198+
(
199+
'event-other-provider',
200+
'project',
201+
'other-provider',
202+
0,
203+
'project.created',
204+
'2026-01-10T00:00:00.000Z',
205+
'command-other-provider',
206+
NULL,
207+
NULL,
208+
'client',
209+
'{"projectId":"other-provider","defaultModelSelection":{"instanceId":"claudeAgent","model":"claude-opus-4-8"}}',
210+
'{}'
211+
),
212+
(
213+
'event-renamed-meta',
214+
'project',
215+
'renamed-project',
216+
1,
217+
'project.meta-updated',
218+
'2026-01-04T00:00:00.000Z',
219+
'command-renamed-meta',
220+
NULL,
221+
NULL,
222+
'client',
223+
'{"projectId":"renamed-project","title":"Renamed project"}',
224+
'{}'
225+
),
226+
(
227+
'event-explicit-meta-updated',
228+
'project',
229+
'explicit-meta',
230+
1,
231+
'project.meta-updated',
232+
'2026-01-06T00:00:00.000Z',
233+
'command-explicit-meta-updated',
234+
NULL,
235+
NULL,
236+
'client',
237+
'{"projectId":"explicit-meta","defaultModelSelection":{"instanceId":"codex","model":"gpt-5.6-sol"}}',
238+
'{}'
239+
),
240+
(
241+
'event-explicit-reset-meta',
242+
'project',
243+
'explicit-reset',
244+
1,
245+
'project.meta-updated',
246+
'2026-01-08T00:00:00.000Z',
247+
'command-explicit-reset-meta',
248+
NULL,
249+
NULL,
250+
'client',
251+
'{"projectId":"explicit-reset","defaultModelSelection":null}',
252+
'{}'
253+
)
254+
`;
255+
256+
yield* runMigrations({ toMigrationInclusive: 44 });
257+
258+
const projects = yield* sql<{
259+
readonly projectId: string;
260+
readonly defaultModelSelection: string | null;
261+
}>`
262+
SELECT
263+
project_id AS "projectId",
264+
default_model_selection_json AS "defaultModelSelection"
265+
FROM projection_projects
266+
ORDER BY project_id
267+
`;
268+
assert.deepStrictEqual(projects, [
269+
{ projectId: "auto-5-4", defaultModelSelection: null },
270+
{ projectId: "auto-sol", defaultModelSelection: null },
271+
{
272+
projectId: "explicit-meta",
273+
defaultModelSelection: '{"instanceId":"codex","model":"gpt-5.6-sol"}',
274+
},
275+
{
276+
projectId: "explicit-options",
277+
defaultModelSelection:
278+
'{"instanceId":"codex","model":"gpt-5.6-sol","options":[{"id":"reasoningEffort","value":"high"}]}',
279+
},
280+
{ projectId: "explicit-reset", defaultModelSelection: null },
281+
{ projectId: "other-provider", defaultModelSelection: null },
282+
{ projectId: "renamed-project", defaultModelSelection: null },
283+
]);
284+
285+
const createdEvents = yield* sql<{
286+
readonly streamId: string;
287+
readonly defaultModelSelection: string | null;
288+
}>`
289+
SELECT
290+
stream_id AS "streamId",
291+
json_extract(payload_json, '$.defaultModelSelection') AS "defaultModelSelection"
292+
FROM orchestration_events
293+
WHERE event_type = 'project.created'
294+
ORDER BY stream_id
295+
`;
296+
assert.deepStrictEqual(createdEvents, [
297+
{ streamId: "auto-5-4", defaultModelSelection: null },
298+
{ streamId: "auto-sol", defaultModelSelection: null },
299+
{
300+
streamId: "explicit-meta",
301+
defaultModelSelection: '{"instanceId":"codex","model":"gpt-5.6-sol"}',
302+
},
303+
{
304+
streamId: "explicit-options",
305+
defaultModelSelection:
306+
'{"instanceId":"codex","model":"gpt-5.6-sol","options":[{"id":"reasoningEffort","value":"high"}]}',
307+
},
308+
{
309+
streamId: "explicit-reset",
310+
defaultModelSelection: '{"instanceId":"codex","model":"gpt-5.6-sol"}',
311+
},
312+
{ streamId: "other-provider", defaultModelSelection: null },
313+
{ streamId: "renamed-project", defaultModelSelection: null },
314+
]);
315+
}),
316+
);
317+
});

0 commit comments

Comments
 (0)