Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ThreadLaunchService.test.ts

644 lines24.5 KB

1import { assert, it, vi } from "@effect/vitest";
2import {
3 CommandId,
4 MessageId,
5 ProjectId,
6 ProviderDriverKind,
7 ProviderInstanceId,
8 ThreadId,
9} from "@t3tools/contracts";
10import * as Deferred from "effect/Deferred";
11import * as Duration from "effect/Duration";
12import * as Effect from "effect/Effect";
13import * as Exit from "effect/Exit";
14import * as Layer from "effect/Layer";
15import * as Option from "effect/Option";
16import * as Ref from "effect/Ref";
17import * as SqlClient from "effect/unstable/sql/SqlClient";
18​
19import * as GitWorkflow from "../git/GitWorkflowService.ts";
20import { SqlitePersistenceMemory } from "../persistence/Layers/Sqlite.ts";
21import * as ProjectService from "../project/ProjectService.ts";
22import * as ProjectSetupScriptRunner from "../project/ProjectSetupScriptRunner.ts";
23import * as TextGeneration from "../textGeneration/TextGeneration.ts";
24import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
25import * as CommandReceiptStore from "./CommandReceiptStore.ts";
26import * as EffectOutbox from "./EffectOutbox.ts";
27import * as IdAllocator from "./IdAllocator.ts";
28import type { ProviderAdapterV2Shape } from "./ProviderAdapter.ts";
29import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
30import * as ThreadLaunch from "./ThreadLaunchService.ts";
31import * as ThreadManagement from "./ThreadManagementService.ts";
32import { makeOrchestratorV2ReplayLayerWithRegistry } from "./testkit/ProviderReplayHarness.ts";
33​
34const projectId = ProjectId.make("project:launch-test");
35const modelSelection = {
36 instanceId: ProviderInstanceId.make("codex"),
37 model: "gpt-5.1-codex",
38} as const;
39const project = {
40 id: projectId,
41 title: "Project",
42 workspaceRoot: "/repo",
43 repositoryIdentity: null,
44 faviconPath: null,
45 defaultModelSelection: modelSelection,
46 scripts: [],
47 createdAt: "2026-06-20T00:00:00.000Z",
48 updatedAt: "2026-06-20T00:00:00.000Z",
49 deletedAt: null,
50} as const;
51​
52const adapter = {
53 instanceId: modelSelection.instanceId,
54 driver: ProviderDriverKind.make("codex"),
55 getCapabilities: () => Effect.succeed(CodexProviderCapabilitiesV2),
56 planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" as const }),
57 openSession: () => Effect.die("provider execution is disabled in launch tests"),
58} as ProviderAdapterV2Shape;
59​
60interface HarnessOptions {
61 readonly createWorktree?: GitWorkflow.GitWorkflowService["Service"]["createWorktree"];
62 readonly runSetup?: ProjectSetupScriptRunner.ProjectSetupScriptRunner["Service"]["runForThread"];
63 readonly generateTitle?: TextGeneration.TextGeneration["Service"]["generateThreadTitle"];
65​
66function makeHarness(options: HarnessOptions = {}) {
67 const database = SqlitePersistenceMemory;
68 const registry = ProviderAdapterRegistry.makeLayer([adapter]);
69 const orchestrator = makeOrchestratorV2ReplayLayerWithRegistry(
70 { name: "thread-launch" },
71 registry,
72 { databaseLayer: database, runEffectWorker: false },
73 );
74 const threadManagement = ThreadManagement.layer.pipe(Layer.provide(orchestrator));
75 const receipts = CommandReceiptStore.layer.pipe(Layer.provide(database));
76 const outbox = EffectOutbox.layer.pipe(Layer.provide(database));
77 const createWorktree = vi.fn(
78 options.createWorktree ??
79 (() =>
80 Effect.succeed({
81 worktree: { path: "/repo-worktrees/feature", refName: "feature", headSha: "abc" },
82 } as never)),
83 );
84 const runSetup = vi.fn(
85 options.runSetup ?? (() => Effect.succeed({ status: "no-script" as const })),
86 );
87 const externalServices = Layer.mergeAll(
88 Layer.succeed(ProjectService.ProjectService, {
89 create: () => Effect.die("unused"),
90 bootstrap: () => Effect.die("unused"),
91 update: () => Effect.die("unused"),
92 delete: () => Effect.die("unused"),
93 getById: (id) => Effect.succeed(id === projectId ? Option.some(project) : Option.none()),
94 getByWorkspaceRoot: () => Effect.succeed(Option.some(project)),
95 snapshot: Effect.die("unused"),
96 }),
97 Layer.mock(GitWorkflow.GitWorkflowService)({
98 createWorktree,
99 fetchRemote: () => Effect.void,
100 removeWorktree: () => Effect.void,
101 resolveRemoteTrackingCommit: () =>
102 Effect.succeed({ commitSha: "remote-main-sha", remoteRefName: "origin/main" }),
103 }),
104 Layer.succeed(ProjectSetupScriptRunner.ProjectSetupScriptRunner, {
105 runForThread: runSetup,
106 }),
107 Layer.mock(TextGeneration.TextGeneration)({
108 generateThreadTitle:
109 options.generateTitle ?? (() => Effect.succeed({ title: "Generated title" })),
110 generateBranchName: () => Effect.succeed({ branch: "generated-branch" }),
111 }),
112 );
113 const launch = ThreadLaunch.layer.pipe(
114 Layer.provide(Layer.mergeAll(externalServices, threadManagement, receipts, IdAllocator.layer)),
115 );
116 return {
117 layer: Layer.mergeAll(launch, threadManagement, outbox, database),
118 createWorktree,
119 runSetup,
120 };
122​
123function launchInput(input: {
124 readonly command: string;
125 readonly thread: string;
126 readonly message?: string;
127 readonly workspace?: ThreadLaunch.ThreadLaunchWorkspaceStrategy;
128}) {
129 return {
130 commandId: CommandId.make(input.command),
131 threadId: ThreadId.make(input.thread),
132 projectId,
133 title: "New thread",
134 modelSelection,
135 runtimeMode: "full-access" as const,
136 interactionMode: "default" as const,
137 workspaceStrategy: input.workspace ?? { type: "root" as const },
138 ...(input.message === undefined
139 ? {}
140 : {
141 initialMessage: {
142 messageId: MessageId.make(`${input.message}:id`),
143 text: input.message,
144 attachments: [],
145 },
146 }),
147 createdBy: "user" as const,
148 creationSource: "web" as const,
149 };
151​
152function waitUntil<E, R>(predicate: () => Effect.Effect<boolean, E, R>): Effect.Effect<void, E, R> {
153 return Effect.gen(function* () {
154 for (let attempt = 0; attempt < 200; attempt += 1) {
155 if (yield* predicate()) return;
156 yield* Effect.promise(
157 () =>
158 new Promise<void>((resolve) => {
159 setImmediate(resolve);
160 }),
161 );
162 }
163 assert.fail("Condition was not reached before timeout.");
164 });
166​
167it.effect("returns a visible preparing message while provisioning is still blocked", () =>
168 Effect.gen(function* () {
169 const worktreeEntered = yield* Deferred.make<void>();
170 const allowWorktree = yield* Deferred.make<void>();
171 const setupEntered = yield* Deferred.make<void>();
172 const allowSetup = yield* Deferred.make<void>();
173 const harness = makeHarness({
174 createWorktree: () =>
175 Deferred.succeed(worktreeEntered, undefined).pipe(
176 Effect.andThen(Deferred.await(allowWorktree)),
177 Effect.as({
178 worktree: { path: "/repo-worktrees/feature", refName: "feature", headSha: "abc" },
179 } as never),
180 ),
181 runSetup: () =>
182 Deferred.succeed(setupEntered, undefined).pipe(
183 Effect.andThen(Deferred.await(allowSetup)),
184 Effect.as({ status: "no-script" as const }),
185 ),
186 });
187 yield* Effect.gen(function* () {
188 const launches = yield* ThreadLaunch.ThreadLaunchService;
189 const outbox = yield* EffectOutbox.EffectOutboxV2;
190 const threads = yield* ThreadManagement.ThreadManagementService;
191 const input = launchInput({
192 command: "command:launch:blocked",
193 thread: "thread:launch:blocked",
194 message: "Build the feature",
195 workspace: { type: "worktree", baseRef: "main" },
196 });
197 const launched = yield* launches.launch(input);
198 assert.equal(launched.projection.messages[0]?.text, "Build the feature");
199 assert.equal(launched.projection.runs[0]?.status, "preparing");
200 assert.equal(
201 launched.projection.turnItems.find((item) => item.type === "command_execution")?.status,
202 "running",
203 );
204 yield* Deferred.await(worktreeEntered);
205 let current = yield* threads.getThreadProjection(launched.threadId);
206 assert.equal(
207 current.turnItems.find((item) => item.type === "command_execution")?.title,
208 "Preparing worktree",
209 );
210 yield* Deferred.succeed(allowWorktree, undefined);
211 const entered = yield* Deferred.await(setupEntered).pipe(
212 Effect.timeoutOption(Duration.seconds(2)),
213 );
214 if (Option.isNone(entered)) {
215 current = yield* threads.getThreadProjection(launched.threadId);
216 assert.fail(
217 `Setup was not reached; run=${current.runs[0]?.status ?? "missing"}, worklog=${current.turnItems.find((item) => item.type === "command_execution")?.title ?? "missing"}.`,
218 );
219 }
220 current = yield* threads.getThreadProjection(launched.threadId);
221 assert.equal(
222 current.turnItems.find((item) => item.type === "command_execution")?.title,
223 "Starting setup script",
224 );
225 const prematureEffects = yield* outbox.listByCommandId(
226 CommandId.make("command:launch:blocked:initial-message"),
227 );
228 assert.isEmpty(prematureEffects);
229 yield* Deferred.succeed(allowSetup, undefined);
230 }).pipe(Effect.provide(harness.layer));
231 }),
232);
233​
234it.effect("provisions independent launches concurrently instead of behind a global semaphore", () =>
235 Effect.gen(function* () {
236 const setupCount = yield* Ref.make(0);
237 const bothEntered = yield* Deferred.make<void>();
238 const allowSetup = yield* Deferred.make<void>();
239 const harness = makeHarness({
240 runSetup: () =>
241 Ref.updateAndGet(setupCount, (count) => count + 1).pipe(
242 Effect.tap((count) =>
243 count === 2 ? Deferred.succeed(bothEntered, undefined) : Effect.void,
244 ),
245 Effect.andThen(Deferred.await(allowSetup)),
246 Effect.as({ status: "no-script" as const }),
247 ),
248 });
249 yield* Effect.gen(function* () {
250 const launches = yield* ThreadLaunch.ThreadLaunchService;
251 const results = yield* Effect.all(
252 [
253 launches.launch(
254 launchInput({
255 command: "command:launch:concurrent-a",
256 thread: "thread:launch:concurrent-a",
257 message: "First",
258 }),
259 ),
260 launches.launch(
261 launchInput({
262 command: "command:launch:concurrent-b",
263 thread: "thread:launch:concurrent-b",
264 message: "Second",
265 }),
266 ),
267 ],
268 { concurrency: "unbounded" },
269 );
270 assert.deepEqual(
271 results.map((result) => result.projection.runs[0]?.status),
272 ["preparing", "preparing"],
273 );
274 yield* Deferred.await(bothEntered);
275 assert.equal(yield* Ref.get(setupCount), 2);
276 yield* Deferred.succeed(allowSetup, undefined);
277 }).pipe(Effect.provide(harness.layer));
278 }),
279);
280​
281it.effect("enqueues provider work only after setup has been initiated", () =>
282 Effect.gen(function* () {
283 const setupEntered = yield* Deferred.make<void>();
284 const allowSetup = yield* Deferred.make<void>();
285 const harness = makeHarness({
286 runSetup: () =>
287 Deferred.succeed(setupEntered, undefined).pipe(
288 Effect.andThen(Deferred.await(allowSetup)),
289 Effect.as({
290 status: "started" as const,
291 scriptId: "setup",
292 scriptName: "Setup",
293 terminalId: "setup",
294 cwd: "/repo",
295 }),
296 ),
297 });
298 yield* Effect.gen(function* () {
299 const launches = yield* ThreadLaunch.ThreadLaunchService;
300 const outbox = yield* EffectOutbox.EffectOutboxV2;
301 const threads = yield* ThreadManagement.ThreadManagementService;
302 const input = launchInput({
303 command: "command:launch:release",
304 thread: "thread:launch:release",
305 message: "Start after setup",
306 workspace: { type: "worktree", baseRef: "main" },
307 });
308 const launched = yield* launches.launch(input);
309 yield* Deferred.await(setupEntered);
310 assert.isEmpty(
311 yield* outbox.listByCommandId(CommandId.make("command:launch:release:release")),
312 );
313 yield* Deferred.succeed(allowSetup, undefined);
314 yield* waitUntil(() =>
315 outbox
316 .listByCommandId(CommandId.make("command:launch:release:release"))
317 .pipe(Effect.map((effects) => effects.length === 1)),
318 );
319 const projection = yield* threads.getThreadProjection(launched.threadId);
320 assert.equal(projection.runs[0]?.status, "starting");
321 assert.equal(projection.checkpointScopes[0]?.cwd, "/repo-worktrees/feature");
322 assert.equal(
323 projection.turnItems.find((item) => item.type === "command_execution")?.status,
324 "completed",
325 );
326 }).pipe(Effect.provide(harness.layer));
327 }),
328);
329​
330it.effect(
331 "queues follow-up messages behind preparation and checkpoints them in the final workspace",
332 () =>
333 Effect.gen(function* () {
334 const setupEntered = yield* Deferred.make<void>();
335 const failSetup = yield* Deferred.make<void>();
336 const harness = makeHarness({
337 runSetup: () =>
338 Deferred.succeed(setupEntered, undefined).pipe(
339 Effect.andThen(Deferred.await(failSetup)),
340 Effect.andThen(Effect.fail(new Error("setup failed") as never)),
341 ),
342 });
343 yield* Effect.gen(function* () {
344 const launches = yield* ThreadLaunch.ThreadLaunchService;
345 const threads = yield* ThreadManagement.ThreadManagementService;
346 const launched = yield* launches.launch(
347 launchInput({
348 command: "command:launch:queued-during-preparation",
349 thread: "thread:launch:queued-during-preparation",
350 message: "Prepare the workspace",
351 workspace: { type: "worktree", baseRef: "main" },
352 }),
353 );
354 yield* Deferred.await(setupEntered);
355​
356 const followUp = yield* threads.sendToThread({
357 projectId,
358 commandId: CommandId.make("command:launch:queued-follow-up"),
359 threadId: launched.threadId,
360 messageId: MessageId.make("message:launch:queued-follow-up"),
361 text: "Run after preparation",
362 attachments: [],
363 mode: "auto",
364 createdBy: "user",
365 creationSource: "web",
366 });
367 assert.equal(followUp.delivery, "queued");
368 assert.equal(followUp.run.status, "queued");
369 assert.equal(
370 followUp.projection.nodes.find(
371 (node) => node.runId === followUp.run.id && node.kind === "root_turn",
372 )?.checkpointScopeId,
373 null,
374 );
375​
376 yield* Deferred.succeed(failSetup, undefined);
377 yield* waitUntil(() =>
378 threads
379 .getThreadProjection(launched.threadId)
380 .pipe(
381 Effect.map(
382 (projection) =>
383 projection.runs.find((run) => run.id === followUp.run.id)?.status === "starting",
384 ),
385 ),
386 );
387​
388 const projection = yield* threads.getThreadProjection(launched.threadId);
389 const rootNode = projection.nodes.find(
390 (node) => node.runId === followUp.run.id && node.kind === "root_turn",
391 );
392 assert.isNotNull(rootNode?.checkpointScopeId);
393 assert.equal(
394 projection.checkpointScopes.find((scope) => scope.id === rootNode?.checkpointScopeId)
395 ?.cwd,
396 "/repo-worktrees/feature",
397 );
398 }).pipe(Effect.provide(harness.layer));
399 }),
400);
401​
402it.effect("does not put optional title generation on the provisioning critical path", () =>
403 Effect.gen(function* () {
404 const titleStarted = yield* Deferred.make<void>();
405 const allowTitle = yield* Deferred.make<void>();
406 const setupEntered = yield* Deferred.make<void>();
407 const harness = makeHarness({
408 generateTitle: () =>
409 Deferred.succeed(titleStarted, undefined).pipe(
410 Effect.andThen(Deferred.await(allowTitle)),
411 Effect.as({ title: "Generated later" }),
412 ),
413 runSetup: () =>
414 Deferred.succeed(setupEntered, undefined).pipe(Effect.as({ status: "no-script" as const })),
415 });
416 yield* Effect.gen(function* () {
417 const launches = yield* ThreadLaunch.ThreadLaunchService;
418 const threads = yield* ThreadManagement.ThreadManagementService;
419 const input = launchInput({
420 command: "command:launch:title-independent",
421 thread: "thread:launch:title-independent",
422 message: "Generate my title slowly",
423 });
424 const launched = yield* launches.launch(input);
425 yield* Deferred.await(titleStarted);
426 yield* Deferred.await(setupEntered);
427 yield* waitUntil(() =>
428 threads
429 .getThreadProjection(launched.threadId)
430 .pipe(Effect.map((projection) => projection.runs[0]?.status === "starting")),
431 );
432 assert.equal(
433 (yield* threads.getThreadProjection(launched.threadId)).thread.title,
434 "New thread",
435 );
436 yield* Deferred.succeed(allowTitle, undefined);
437 yield* waitUntil(() =>
438 threads
439 .getThreadProjection(launched.threadId)
440 .pipe(Effect.map((projection) => projection.thread.title === "Generated later")),
441 );
442 }).pipe(Effect.provide(harness.layer));
443 }),
444);
445​
446for (const failurePoint of ["worktree", "setup"] as const) {
447 it.effect(
448 `${failurePoint} failure keeps the thread and message visible and emits failure items`,
449 () =>
450 Effect.gen(function* () {
451 const failure = new Error(`${failurePoint} failed`);
452 const harness = makeHarness(
453 failurePoint === "worktree"
454 ? { createWorktree: () => Effect.fail(failure as never) }
455 : { runSetup: () => Effect.fail(failure as never) },
456 );
457 yield* Effect.gen(function* () {
458 const launches = yield* ThreadLaunch.ThreadLaunchService;
459 const threads = yield* ThreadManagement.ThreadManagementService;
460 const input = launchInput({
461 command: `command:launch:${failurePoint}-failure`,
462 thread: `thread:launch:${failurePoint}-failure`,
463 message: `Fail during ${failurePoint}`,
464 workspace: { type: "worktree", baseRef: "main" },
465 });
466 const launched = yield* launches.launch(input);
467 yield* waitUntil(() =>
468 threads
469 .getThreadProjection(launched.threadId)
470 .pipe(Effect.map((projection) => projection.runs[0]?.status === "failed")),
471 );
472 const projection = yield* threads.getThreadProjection(launched.threadId);
473 assert.equal(projection.messages[0]?.text, `Fail during ${failurePoint}`);
474 assert.equal(projection.runs[0]?.status, "failed");
475 assert.equal(
476 projection.turnItems.find((item) => item.type === "command_execution")?.status,
477 "failed",
478 );
479 assert.match(
480 projection.turnItems.find((item) => item.type === "error")?.failure.message ?? "",
481 new RegExp(`${failurePoint} failed`, "u"),
482 );
483 }).pipe(Effect.provide(harness.layer));
484 }),
485 );
487​
488it.effect("deduplicates retried launch side effects in-process", () =>
489 Effect.gen(function* () {
490 const setupEntered = yield* Deferred.make<void>();
491 const allowSetup = yield* Deferred.make<void>();
492 const harness = makeHarness({
493 runSetup: () =>
494 Deferred.succeed(setupEntered, undefined).pipe(
495 Effect.andThen(Deferred.await(allowSetup)),
496 Effect.as({ status: "no-script" as const }),
497 ),
498 });
499 yield* Effect.gen(function* () {
500 const launches = yield* ThreadLaunch.ThreadLaunchService;
501 const input = launchInput({
502 command: "command:launch:retry",
503 thread: "thread:launch:retry",
504 message: "Only once",
505 });
506 const [first, retry] = yield* Effect.all([launches.launch(input), launches.launch(input)], {
507 concurrency: "unbounded",
508 });
509 yield* Deferred.await(setupEntered);
510 assert.equal(first.threadId, retry.threadId);
511 assert.isFalse(first.resumed);
512 assert.isTrue(retry.resumed);
513 assert.equal(harness.runSetup.mock.calls.length, 1);
514 yield* Deferred.succeed(allowSetup, undefined);
515 }).pipe(Effect.provide(harness.layer));
516 }),
517);
518​
519it.effect("does not let a failing same-command caller strand a concurrent durable launch", () =>
520 Effect.gen(function* () {
521 const setupEntered = yield* Deferred.make<void>();
522 const allowSetup = yield* Deferred.make<void>();
523 const harness = makeHarness({
524 runSetup: () =>
525 Deferred.succeed(setupEntered, undefined).pipe(
526 Effect.andThen(Deferred.await(allowSetup)),
527 Effect.as({ status: "no-script" as const }),
528 ),
529 });
530 yield* Effect.gen(function* () {
531 const launches = yield* ThreadLaunch.ThreadLaunchService;
532 const command = "command:launch:failed-owner-race";
533 const [failed, launched] = yield* Effect.all(
534 [
535 launches
536 .launch({
537 ...launchInput({
538 command,
539 thread: "thread:launch:failed-owner-race",
540 message: "This invalid reuse fails",
541 }),
542 reuseExistingThread: true,
543 })
544 .pipe(Effect.exit),
545 launches.launch(
546 launchInput({
547 command,
548 thread: "thread:launch:successful-peer",
549 message: "This peer persists",
550 }),
551 ),
552 ],
553 { concurrency: "unbounded" },
554 );
555 assert.isTrue(Exit.isFailure(failed));
556 assert.equal(launched.projection.runs[0]?.status, "preparing");
557 const entered = yield* Deferred.await(setupEntered).pipe(
558 Effect.timeoutOption(Duration.seconds(2)),
559 );
560 assert.isTrue(Option.isSome(entered));
561 assert.equal(harness.runSetup.mock.calls.length, 1);
562 yield* Deferred.succeed(allowSetup, undefined);
563 }).pipe(Effect.provide(harness.layer));
564 }),
565);
566​
567it.effect("schedules an accepted preparing message exactly once across concurrent retries", () =>
568 Effect.gen(function* () {
569 const setupEntered = yield* Deferred.make<void>();
570 const allowSetup = yield* Deferred.make<void>();
571 const harness = makeHarness({
572 runSetup: () =>
573 Deferred.succeed(setupEntered, undefined).pipe(
574 Effect.andThen(Deferred.await(allowSetup)),
575 Effect.as({ status: "no-script" as const }),
576 ),
577 });
578 yield* Effect.gen(function* () {
579 const launches = yield* ThreadLaunch.ThreadLaunchService;
580 const threads = yield* ThreadManagement.ThreadManagementService;
581 const input = launchInput({
582 command: "command:launch:accepted-before-fork",
583 thread: "thread:launch:accepted-before-fork",
584 message: "Resume preparation",
585 });
586 const messageId = MessageId.make("message:launch:accepted-before-fork");
587​
588 yield* threads.dispatch({
589 type: "thread.create",
590 commandId: input.commandId,
591 threadId: input.threadId,
592 projectId: input.projectId,
593 title: input.title,
594 modelSelection: input.modelSelection,
595 runtimeMode: input.runtimeMode,
596 interactionMode: input.interactionMode,
597 branch: null,
598 worktreePath: null,
599 createdBy: input.createdBy,
600 creationSource: input.creationSource,
601 });
602 yield* threads.dispatch({
603 type: "message.dispatch",
604 commandId: CommandId.make(`${input.commandId}:initial-message`),
605 threadId: input.threadId,
606 messageId,
607 text: "Resume preparation",
608 attachments: [],
609 modelSelection: input.modelSelection,
610 dispatchMode: { type: "defer_start" },
611 createdBy: input.createdBy,
612 creationSource: input.creationSource,
613 });
614 const preparing = yield* threads.getThreadProjection(input.threadId);
615 assert.equal(preparing.runs[0]?.status, "preparing");
616​
617 const [first, second] = yield* Effect.all([launches.launch(input), launches.launch(input)], {
618 concurrency: "unbounded",
619 });
620 yield* Deferred.await(setupEntered);
621 assert.isTrue(first.resumed);
622 assert.isTrue(second.resumed);
623 assert.equal(harness.runSetup.mock.calls.length, 1);
624 yield* Deferred.succeed(allowSetup, undefined);
625 }).pipe(Effect.provide(harness.layer));
626 }),
627);
628​
629it.effect("does not depend on the legacy launch workflow table", () => {
630 const harness = makeHarness();
631 return Effect.gen(function* () {
632 const sql = yield* SqlClient.SqlClient;
633 const launches = yield* ThreadLaunch.ThreadLaunchService;
634 yield* sql`DROP TABLE orchestration_v2_thread_launch_workflows`;
635 const launched = yield* launches.launch(
636 launchInput({
637 command: "command:launch:no-workflow-table",
638 thread: "thread:launch:no-workflow-table",
639 message: "No private workflow state",
640 }),
641 );
642 assert.equal(launched.projection.messages[0]?.text, "No private workflow state");
643 }).pipe(Effect.provide(harness.layer));
644});