@@ -7893,6 +7893,89 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
78937893 assertTrue ( result . _tag === "Failure" ) ;
78947894 assertTrue ( result . failure . _tag === "OrchestrationDispatchCommandError" ) ;
78957895 assert . include ( result . failure . message , "worktree exploded" ) ;
7896+ assert . strictEqual ( result . failure . bootstrapThreadDisposition , "deleted" ) ;
7897+ assert . deepEqual (
7898+ dispatchedCommands . map ( ( command ) => command . type ) ,
7899+ [ "thread.create" , "thread.delete" ] ,
7900+ ) ;
7901+ } ) . pipe ( Effect . provide ( NodeHttpServer . layerTest ) ) ,
7902+ ) ;
7903+
7904+ it . effect ( "does not report a deleted bootstrap thread when cleanup fails" , ( ) =>
7905+ Effect . gen ( function * ( ) {
7906+ const dispatchedCommands : Array < OrchestrationCommand > = [ ] ;
7907+ const createWorktree = vi . fn (
7908+ ( _ : Parameters < GitVcsDriver . GitVcsDriver [ "Service" ] [ "createWorktree" ] > [ 0 ] ) =>
7909+ Effect . die ( new Error ( "worktree exploded" ) ) ,
7910+ ) ;
7911+
7912+ yield * buildAppUnderTest ( {
7913+ layers : {
7914+ gitVcsDriver : {
7915+ createWorktree,
7916+ } ,
7917+ orchestrationEngine : {
7918+ dispatch : ( command ) => {
7919+ dispatchedCommands . push ( command ) ;
7920+ if ( command . type === "thread.delete" ) {
7921+ return Effect . fail (
7922+ new OrchestrationListenerCallbackError ( {
7923+ listener : "domain-event" ,
7924+ detail : "thread cleanup exploded" ,
7925+ } ) ,
7926+ ) ;
7927+ }
7928+ return Effect . succeed ( { sequence : dispatchedCommands . length } ) ;
7929+ } ,
7930+ readEvents : ( ) => Stream . empty ,
7931+ } ,
7932+ } ,
7933+ } ) ;
7934+
7935+ const createdAt = "2026-01-01T00:00:00.000Z" ;
7936+ const wsUrl = yield * getWsServerUrl ( "/ws" ) ;
7937+ const result = yield * Effect . scoped (
7938+ withWsRpcClient ( wsUrl , ( client ) =>
7939+ client [ ORCHESTRATION_WS_METHODS . dispatchCommand ] ( {
7940+ type : "thread.turn.start" ,
7941+ commandId : CommandId . make ( "cmd-bootstrap-turn-start-cleanup-defect" ) ,
7942+ threadId : ThreadId . make ( "thread-bootstrap-cleanup-defect" ) ,
7943+ message : {
7944+ messageId : MessageId . make ( "msg-bootstrap-cleanup-defect" ) ,
7945+ role : "user" ,
7946+ text : "hello" ,
7947+ attachments : [ ] ,
7948+ } ,
7949+ modelSelection : defaultModelSelection ,
7950+ runtimeMode : "full-access" ,
7951+ interactionMode : "default" ,
7952+ bootstrap : {
7953+ createThread : {
7954+ projectId : defaultProjectId ,
7955+ title : "Bootstrap Thread" ,
7956+ modelSelection : defaultModelSelection ,
7957+ runtimeMode : "full-access" ,
7958+ interactionMode : "default" ,
7959+ branch : "main" ,
7960+ worktreePath : null ,
7961+ createdAt,
7962+ } ,
7963+ prepareWorktree : {
7964+ projectCwd : "/tmp/project" ,
7965+ baseBranch : "main" ,
7966+ branch : "t3code/bootstrap-refName" ,
7967+ } ,
7968+ runSetupScript : false ,
7969+ } ,
7970+ createdAt,
7971+ } ) ,
7972+ ) . pipe ( Effect . result ) ,
7973+ ) ;
7974+
7975+ assertTrue ( result . _tag === "Failure" ) ;
7976+ assertTrue ( result . failure . _tag === "OrchestrationDispatchCommandError" ) ;
7977+ assert . include ( result . failure . message , "worktree exploded" ) ;
7978+ assert . strictEqual ( result . failure . bootstrapThreadDisposition , undefined ) ;
78967979 assert . deepEqual (
78977980 dispatchedCommands . map ( ( command ) => command . type ) ,
78987981 [ "thread.create" , "thread.delete" ] ,
0 commit comments