@@ -16,6 +16,7 @@ import {
1616 DEFAULT_PROVIDER_INTERACTION_MODE ,
1717 EventId ,
1818 MessageId ,
19+ type OrchestrationCommand ,
1920 ProjectId ,
2021 ProviderItemId ,
2122 type ServerSettings ,
@@ -256,57 +257,52 @@ describe("ProviderRuntimeIngestion", () => {
256257 scope = await Effect . runPromise ( Scope . make ( "sequential" ) ) ;
257258 await Effect . runPromise ( ingestion . start ( ) . pipe ( Scope . provide ( scope ) ) ) ;
258259 const drain = ( ) => Effect . runPromise ( ingestion . drain ) ;
260+ const dispatch = ( command : OrchestrationCommand ) => Effect . runPromise ( engine . dispatch ( command ) ) ;
259261
260262 const createdAt = "2026-01-01T00:00:00.000Z" ;
261- await Effect . runPromise (
262- engine . dispatch ( {
263- type : "project.create" ,
264- commandId : CommandId . make ( "cmd-provider-project-create" ) ,
265- projectId : asProjectId ( "project-1" ) ,
266- title : "Provider Project" ,
267- workspaceRoot,
268- defaultModelSelection : {
269- instanceId : ProviderInstanceId . make ( "codex" ) ,
270- model : "gpt-5-codex" ,
271- } ,
272- createdAt,
273- } ) ,
274- ) ;
275- await Effect . runPromise (
276- engine . dispatch ( {
277- type : "thread.create" ,
278- commandId : CommandId . make ( "cmd-thread-create" ) ,
263+ await dispatch ( {
264+ type : "project.create" ,
265+ commandId : CommandId . make ( "cmd-provider-project-create" ) ,
266+ projectId : asProjectId ( "project-1" ) ,
267+ title : "Provider Project" ,
268+ workspaceRoot,
269+ defaultModelSelection : {
270+ instanceId : ProviderInstanceId . make ( "codex" ) ,
271+ model : "gpt-5-codex" ,
272+ } ,
273+ createdAt,
274+ } ) ;
275+ await dispatch ( {
276+ type : "thread.create" ,
277+ commandId : CommandId . make ( "cmd-thread-create" ) ,
278+ threadId : ThreadId . make ( "thread-1" ) ,
279+ projectId : asProjectId ( "project-1" ) ,
280+ title : "Thread" ,
281+ modelSelection : {
282+ instanceId : ProviderInstanceId . make ( "codex" ) ,
283+ model : "gpt-5-codex" ,
284+ } ,
285+ interactionMode : DEFAULT_PROVIDER_INTERACTION_MODE ,
286+ runtimeMode : "approval-required" ,
287+ branch : null ,
288+ worktreePath : null ,
289+ createdAt,
290+ } ) ;
291+ await dispatch ( {
292+ type : "thread.session.set" ,
293+ commandId : CommandId . make ( "cmd-session-seed" ) ,
294+ threadId : ThreadId . make ( "thread-1" ) ,
295+ session : {
279296 threadId : ThreadId . make ( "thread-1" ) ,
280- projectId : asProjectId ( "project-1" ) ,
281- title : "Thread" ,
282- modelSelection : {
283- instanceId : ProviderInstanceId . make ( "codex" ) ,
284- model : "gpt-5-codex" ,
285- } ,
286- interactionMode : DEFAULT_PROVIDER_INTERACTION_MODE ,
297+ status : "ready" ,
298+ providerName : "codex" ,
287299 runtimeMode : "approval-required" ,
288- branch : null ,
289- worktreePath : null ,
290- createdAt,
291- } ) ,
292- ) ;
293- await Effect . runPromise (
294- engine . dispatch ( {
295- type : "thread.session.set" ,
296- commandId : CommandId . make ( "cmd-session-seed" ) ,
297- threadId : ThreadId . make ( "thread-1" ) ,
298- session : {
299- threadId : ThreadId . make ( "thread-1" ) ,
300- status : "ready" ,
301- providerName : "codex" ,
302- runtimeMode : "approval-required" ,
303- activeTurnId : null ,
304- updatedAt : createdAt ,
305- lastError : null ,
306- } ,
307- createdAt,
308- } ) ,
309- ) ;
300+ activeTurnId : null ,
301+ updatedAt : createdAt ,
302+ lastError : null ,
303+ } ,
304+ createdAt,
305+ } ) ;
310306 provider . setSession ( {
311307 provider : ProviderDriverKind . make ( "codex" ) ,
312308 status : "ready" ,
@@ -318,6 +314,7 @@ describe("ProviderRuntimeIngestion", () => {
318314
319315 return {
320316 engine,
317+ dispatch,
321318 readModel : ( ) => Effect . runPromise ( snapshotQuery . getSnapshot ( ) ) ,
322319 emit : provider . emit ,
323320 setProviderSession : provider . setSession ,
@@ -851,23 +848,21 @@ describe("ProviderRuntimeIngestion", () => {
851848 // turn tracked yet. This is the window the Claude resume handshake's
852849 // phantom (turn.completed with no turnId) used to slip through, stomping
853850 // "starting" back to "ready" for a turn that never existed.
854- await Effect . runPromise (
855- harness . engine . dispatch ( {
856- type : "thread.session.set" ,
857- commandId : CommandId . make ( "cmd-session-seed-untargeted-completion" ) ,
851+ await harness . dispatch ( {
852+ type : "thread.session.set" ,
853+ commandId : CommandId . make ( "cmd-session-seed-untargeted-completion" ) ,
854+ threadId : ThreadId . make ( "thread-1" ) ,
855+ session : {
858856 threadId : ThreadId . make ( "thread-1" ) ,
859- session : {
860- threadId : ThreadId . make ( "thread-1" ) ,
861- status : "starting" ,
862- providerName : "claudeAgent" ,
863- runtimeMode : "approval-required" ,
864- activeTurnId : null ,
865- updatedAt : seededAt ,
866- lastError : null ,
867- } ,
868- createdAt : seededAt ,
869- } ) ,
870- ) ;
857+ status : "starting" ,
858+ providerName : "claudeAgent" ,
859+ runtimeMode : "approval-required" ,
860+ activeTurnId : null ,
861+ updatedAt : seededAt ,
862+ lastError : null ,
863+ } ,
864+ createdAt : seededAt ,
865+ } ) ;
871866
872867 harness . emit ( {
873868 type : "turn.completed" ,
@@ -892,23 +887,21 @@ describe("ProviderRuntimeIngestion", () => {
892887 // A completion that names its turn still lands even when no active turn
893888 // is tracked (e.g. its turn.started was lost). Only untargeted
894889 // completions are rejected.
895- await Effect . runPromise (
896- harness . engine . dispatch ( {
897- type : "thread.session.set" ,
898- commandId : CommandId . make ( "cmd-session-seed-targeted-completion" ) ,
890+ await harness . dispatch ( {
891+ type : "thread.session.set" ,
892+ commandId : CommandId . make ( "cmd-session-seed-targeted-completion" ) ,
893+ threadId : ThreadId . make ( "thread-1" ) ,
894+ session : {
899895 threadId : ThreadId . make ( "thread-1" ) ,
900- session : {
901- threadId : ThreadId . make ( "thread-1" ) ,
902- status : "starting" ,
903- providerName : "claudeAgent" ,
904- runtimeMode : "approval-required" ,
905- activeTurnId : null ,
906- updatedAt : seededAt ,
907- lastError : null ,
908- } ,
909- createdAt : seededAt ,
910- } ) ,
911- ) ;
896+ status : "starting" ,
897+ providerName : "claudeAgent" ,
898+ runtimeMode : "approval-required" ,
899+ activeTurnId : null ,
900+ updatedAt : seededAt ,
901+ lastError : null ,
902+ } ,
903+ createdAt : seededAt ,
904+ } ) ;
912905
913906 harness . emit ( {
914907 type : "turn.completed" ,
0 commit comments