@@ -7993,6 +7993,7 @@ it.layer(layerTest)("usage-limit recovery", (it) => {
79937993
79947994 it . effect . each ( [
79957995 "resume" ,
7996+ "resume-started" ,
79967997 "queued-resume" ,
79977998 "rearm" ,
79987999 "snooze-race" ,
@@ -8471,14 +8472,29 @@ it.layer(layerTest)("usage-limit recovery", (it) => {
84718472 yield * orchestrator . dispatch ( resume ) ;
84728473 }
84738474 const after = yield * orchestrator . getThreadProjection ( threadId ) ;
8474- if ( scenario === "resume" ) {
8475+ if ( scenario === "resume" || scenario === "resume-started" ) {
84758476 assert . deepInclude ( after . messages . at ( - 1 ) , {
84768477 text : "Continue where you left off." ,
84778478 createdBy : "agent" ,
84788479 creationSource : "server" ,
84798480 } ) ;
84808481 const continuation = after . runs . at ( - 1 ) ! ;
84818482 assert . equal ( continuation . status , "starting" ) ;
8483+ if ( scenario === "resume-started" ) {
8484+ const startedAt = yield * DateTime . now ;
8485+ yield * events . write ( {
8486+ events : [
8487+ {
8488+ id : EventId . make ( "recovery:continuation-started:resume-started" ) ,
8489+ type : "run.updated" ,
8490+ threadId,
8491+ runId : continuation . id ,
8492+ occurredAt : startedAt ,
8493+ payload : { ...continuation , status : "running" , startedAt } ,
8494+ } ,
8495+ ] ,
8496+ } ) ;
8497+ }
84828498 yield * ( yield * ProviderRuntimeRecoveryService . ProviderRuntimeRecoveryService ) . reconcile (
84838499 "startup" ,
84848500 ) ;
@@ -8490,19 +8506,28 @@ it.layer(layerTest)("usage-limit recovery", (it) => {
84908506 true ,
84918507 DateTime . toEpochMillis ( yield * DateTime . now ) ,
84928508 ) ;
8493- assert ( retry ?. type === "message.dispatch" ) ;
8494- assert . notEqual ( retry . commandId , resume ! . commandId ) ;
8495- yield * orchestrator . dispatch ( retry ) ;
8496- yield * orchestrator . dispatch ( retry ) ;
8497- assert . deepEqual (
8498- ( yield * orchestrator . getThreadProjection ( threadId ) ) . runs . map ( ( row ) => row . status ) ,
8499- [ "failed" , "cancelled" , "starting" ] ,
8500- ) ;
8509+ if ( scenario === "resume-started" ) {
8510+ assert . isNull ( retry ) ;
8511+ assert . equal (
8512+ restartedShell . limitRecovery ?. requestId ,
8513+ after . thread . limitRecovery ?. requestId ,
8514+ ) ;
8515+ } else {
8516+ assert ( retry ?. type === "message.dispatch" ) ;
8517+ assert . notEqual ( retry . commandId , resume ! . commandId ) ;
8518+ yield * orchestrator . dispatch ( retry ) ;
8519+ yield * orchestrator . dispatch ( retry ) ;
8520+ assert . deepEqual (
8521+ ( yield * orchestrator . getThreadProjection ( threadId ) ) . runs . map ( ( row ) => row . status ) ,
8522+ [ "failed" , "cancelled" , "starting" ] ,
8523+ ) ;
8524+ }
85018525 }
85028526 assert . lengthOf (
85038527 after . runs ,
85048528 before . runs . length +
85058529 ( scenario === "resume" ||
8530+ scenario === "resume-started" ||
85068531 stopBeforeArm ||
85078532 scenario === "queued-resume" ||
85088533 scenario === "independent-patches" ||
@@ -8514,6 +8539,7 @@ it.layer(layerTest)("usage-limit recovery", (it) => {
85148539 after . messages ,
85158540 before . messages . length +
85168541 ( scenario === "resume" ||
8542+ scenario === "resume-started" ||
85178543 stopBeforeArm ||
85188544 scenario === "queued-resume" ||
85198545 scenario === "independent-patches" ||
0 commit comments