@@ -2673,6 +2673,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
26732673 it . effect ( "baselines a new watch across restarts and reports later changes" , ( ) =>
26742674 Effect . gen ( function * ( ) {
26752675 const orchestrator = yield * Orchestrator . OrchestratorV2 ;
2676+ const worker = yield * EffectWorker . OrchestrationEffectWorkerV2 ;
26762677 const threadId = ThreadId . make ( "runtime-pull-request-watch-told" ) ;
26772678 const projectId = ProjectId . make ( "pr-watch-told-project" ) ;
26782679 yield * seedProject ( {
@@ -2710,6 +2711,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
27102711 yield * watch ( true , "start" ) ;
27112712
27122713 let headSha = "ad70160aaa" ;
2714+ let hasChecks = false ;
27132715 const host = Layer . mergeAll (
27142716 NodeServices . layer ,
27152717 Layer . mock ( PullRequestService . PullRequestService ) ( {
@@ -2721,7 +2723,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
27212723 at : "2026-10-02T12:00:00.000Z" ,
27222724 } ) ,
27232725 headSha,
2724- checks : [ "lint" , "test" ] . map ( ( name ) => ( {
2726+ checks : ( hasChecks ? [ "lint" , "test" ] : [ ] ) . map ( ( name ) => ( {
27252727 name,
27262728 status : "success" as const ,
27272729 description : null ,
@@ -2746,32 +2748,56 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
27462748
27472749 const reactor = yield * PullRequestWatchReactor . make . pipe ( Effect . provide ( host ) ) ;
27482750 yield * reactor . sweep ;
2751+ yield * worker . drain ( ) ;
2752+ assert . deepEqual ( yield * summaries , [ ] ) ;
2753+ assert . equal (
2754+ ( yield * orchestrator . getThreadShell ( threadId ) ) ?. pullRequests ?. [ 0 ] ?. watch ?. awaitingBaseline ,
2755+ "checks" ,
2756+ ) ;
2757+ yield * watch ( false , "stop-before-baseline" ) ;
2758+ yield * watch ( true , "resume-before-baseline" ) ;
2759+ const waitingRestart = yield * PullRequestWatchReactor . make . pipe ( Effect . provide ( host ) ) ;
2760+ yield * waitingRestart . sweep ;
2761+ yield * worker . drain ( ) ;
2762+ assert . equal (
2763+ ( yield * orchestrator . getThreadShell ( threadId ) ) ?. pullRequests ?. [ 0 ] ?. watch ?. awaitingBaseline ,
2764+ "checks" ,
2765+ ) ;
2766+ hasChecks = true ;
2767+ yield * TestClock . adjust ( "10 minutes" ) ;
2768+ yield * waitingRestart . sweep ;
2769+ yield * worker . drain ( ) ;
27492770 assert . deepEqual ( yield * summaries , [ ] ) ;
27502771 const baseline = ( yield * orchestrator . getThreadShell ( threadId ) ) ?. pullRequests ?. [ 0 ] ?. watch ;
27512772 assert . equal ( baseline ?. headSha , headSha ) ;
27522773 assert . isTrue ( baseline ?. passed ) ;
27532774 assert . deepEqual ( baseline ?. passedChecks , [ "lint" , "test" ] ) ;
27542775 yield * TestClock . adjust ( "10 minutes" ) ;
27552776 yield * reactor . sweep ;
2777+ yield * worker . drain ( ) ;
27562778 assert . deepEqual ( yield * summaries , [ ] ) ;
27572779
27582780 const restarted = yield * PullRequestWatchReactor . make . pipe ( Effect . provide ( host ) ) ;
27592781 yield * restarted . sweep ;
2782+ yield * worker . drain ( ) ;
27602783 assert . deepEqual ( yield * summaries , [ ] ) ;
27612784
27622785 headSha = "bbbbbbbbbb" ;
27632786 yield * TestClock . adjust ( "10 minutes" ) ;
27642787 yield * restarted . sweep ;
2788+ yield * worker . drain ( ) ;
27652789 assert . deepEqual ( yield * summaries , [ "#12: checks passed" ] ) ;
27662790
27672791 yield * watch ( false , "stop" ) ;
27682792 yield * watch ( true , "again" ) ;
27692793 yield * restarted . sweep ;
2794+ yield * worker . drain ( ) ;
27702795 assert . deepEqual ( yield * summaries , [ "#12: checks passed" ] ) ;
27712796
27722797 headSha = "cccccccccc" ;
27732798 yield * TestClock . adjust ( "10 minutes" ) ;
27742799 yield * restarted . sweep ;
2800+ yield * worker . drain ( ) ;
27752801 assert . deepEqual ( yield * summaries , [ "#12: checks passed" , "#12: checks passed" ] ) ;
27762802 yield * watch ( false , "end" ) ;
27772803 } ) ,
@@ -2858,7 +2884,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
28582884 yield * TestClock . adjust ( "10 minutes" ) ;
28592885 yield * reactor . sweep ;
28602886 yield * worker . drain ( ) ;
2861- assert . deepEqual ( yield * summaries , [ "#12: checks passed" ] ) ;
2887+ assert . deepEqual ( yield * summaries , [ ] ) ;
28622888
28632889 assert . deepEqual (
28642890 ( yield * orchestrator . getThreadShell ( threadId ) ) ?. pullRequests ?. [ 0 ] ?. watch ?. owedChecks ,
@@ -2868,14 +2894,14 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
28682894 const restarted = yield * PullRequestWatchReactor . make . pipe ( Effect . provide ( host ) ) ;
28692895 yield * restarted . sweep ;
28702896 yield * worker . drain ( ) ;
2871- assert . deepEqual ( yield * summaries , [ "#12: checks passed" ] ) ;
2897+ assert . deepEqual ( yield * summaries , [ ] ) ;
28722898
28732899 // A new watch on the same pull request knows what the last one told.
28742900 yield * watch ( false , "stop" ) ;
28752901 yield * watch ( true , "again" ) ;
28762902 yield * restarted . sweep ;
28772903 yield * worker . drain ( ) ;
2878- assert . deepEqual ( yield * summaries , [ "#12: checks passed" ] ) ;
2904+ assert . deepEqual ( yield * summaries , [ ] ) ;
28792905
28802906 assert . deepEqual (
28812907 ( yield * orchestrator . getThreadShell ( threadId ) ) ?. pullRequests ?. [ 0 ] ?. watch ?. owedChecks ,
@@ -2885,11 +2911,11 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
28852911 yield * TestClock . adjust ( "10 minutes" ) ;
28862912 yield * restarted . sweep ;
28872913 yield * worker . drain ( ) ;
2888- assert . deepEqual ( yield * summaries , [ "#12: checks passed" , "#12: checks passed" ] ) ;
2914+ assert . deepEqual ( yield * summaries , [ "#12: checks passed" ] ) ;
28892915 yield * TestClock . adjust ( "10 minutes" ) ;
28902916 yield * restarted . sweep ;
28912917 yield * worker . drain ( ) ;
2892- assert . deepEqual ( yield * summaries , [ "#12: checks passed" , "#12: checks passed" ] ) ;
2918+ assert . deepEqual ( yield * summaries , [ "#12: checks passed" ] ) ;
28932919 assert . deepEqual (
28942920 ( yield * orchestrator . getThreadShell ( threadId ) ) ?. pullRequests ?. [ 0 ] ?. watch ?. owedChecks ,
28952921 [ ] ,
0 commit comments