@@ -5842,11 +5842,11 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
58425842 const windowEdges = round === 4 ;
58435843 // One run of each kind in a random order, then an active run. Every other thread has
58445844 // one user turn and then only wake turns.
5845- // The fourth thread is a long run that a late notification wakes, then enough one-row
5846- // runs that a page stops at the raw turn limit only if it counts that wake as a turn.
5845+ // The fourth thread is a turn, many rolled-back rows, a late notification of that turn,
5846+ // then 149 one-row turns. A page stops at that notification only if it counts as a turn.
58475847 const kinds =
58485848 round === 3
5849- ? [ "late wake" , ...Array . from ( { length : 148 } , ( ) => "one row" ) ]
5849+ ? [ "rolled back" , " late wake", ...Array . from ( { length : 149 } , ( ) => "one row" ) ]
58505850 : windowEdges
58515851 ? [ "short" , "cancelled queued turn" , "folds work" , "long fold" , "stopped" ]
58525852 : [
@@ -5870,7 +5870,7 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
58705870 const attempts : Array < unknown > = [ ] ;
58715871 const items : Array < unknown > = [ ] ;
58725872 const tiedWithHidden : Array < TurnItemId > = [ ] ;
5873- const repliesInStoppedRuns : Array < string > = [ ] ;
5873+ const pageEnds : Array < string > = [ ] ;
58745874 let ordinal = 0 ;
58755875 for ( const [ index , kind ] of [ ...kinds , "active" ] . entries ( ) ) {
58765876 const run = index + 1 ;
@@ -5967,6 +5967,8 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
59675967 : windowEdges
59685968 ? [ "folds work" , "long fold" , "stopped" ] . includes ( kind )
59695969 : kind !== "late wake" && ( agentDriven ? run > 1 : chance ( 0.2 ) ) ;
5970+ if ( round === 3 && kind === "active" )
5971+ pageEnds . push ( `turn-item:window-equivalence:${ round } :${ items . length } ` ) ;
59705972 if ( wakes ) notification ( ) ;
59715973 else
59725974 userMessage (
@@ -5988,9 +5990,9 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
59885990 ? 0
59895991 : Math . floor ( random ( ) * 30 ) ;
59905992 for ( let row = 0 ; row < work ; row += 1 ) {
5991- // The first rows of a long fold belong to the run before it .
5993+ // The first rows of a long fold and the work of a late wake belong to the run before.
59925994 const owner =
5993- kind === "long fold" && row < 140
5995+ ( kind === "long fold" && row < 140 ) || kind === "late wake"
59945996 ? {
59955997 runId : `run:window-equivalence:${ round } :${ run - 1 } ` ,
59965998 nodeId : `node:window-equivalence:${ round } :${ run - 1 } ` ,
@@ -6002,17 +6004,20 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
60026004 // A reply deep in a stopped run: a page that ends on it has enough work below it
60036005 // to fold, and only the stop request above it says that it does not.
60046006 const reply = kind === "stopped" && row === 200 ;
6005- if ( reply )
6006- repliesInStoppedRuns . push ( `turn-item:window-equivalence:${ round } :${ items . length } ` ) ;
6007- // With these replies, the part of a long fold in one window is too small to fold.
6008- if ( reply || ( kind === "long fold" && row % 5 === 0 ) || chance ( 0.02 ) )
6007+ if ( reply ) pageEnds . push ( `turn-item:window-equivalence:${ round } :${ items . length } ` ) ;
6008+ // With these replies, the part of a long fold in one window is too small to fold,
6009+ // and a shown row lies below the notification of a late wake.
6010+ const replies = kind === "long fold" || kind === "late wake" ;
6011+ if ( reply || ( replies && row % 5 === 0 ) || chance ( 0.02 ) )
60096012 add ( "assistant_message" , {
60106013 messageId : `message:window-equivalence:${ round } :${ items . length } ` ,
60116014 text : "Reply" ,
60126015 streaming : false ,
60136016 } ) ;
6014- if ( chance ( 0.01 ) ) notification ( ) ;
6015- if ( chance ( 0.004 ) && ! agentDriven && ! windowEdges ) userMessage ( "steer" ) ;
6017+ // A late wake has no other input above its turn start.
6018+ if ( chance ( 0.01 ) && kind !== "late wake" ) notification ( ) ;
6019+ if ( chance ( 0.004 ) && ! agentDriven && ! windowEdges && kind !== "late wake" )
6020+ userMessage ( "steer" ) ;
60166021 }
60176022 if ( kind === "late wake" ) notification ( ) ;
60186023 if ( kind === "stopped" ) add ( "run_interrupt_request" , { message : "Stop" } ) ;
@@ -6107,7 +6112,7 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
61076112 cursor = page . nextCursor ;
61086113 }
61096114 }
6110- for ( const sourceItemId of repliesInStoppedRuns ) {
6115+ for ( const sourceItemId of pageEnds ) {
61116116 const cursor = encodeThreadHistoryCursor ( {
61126117 snapshotSequence : 0 ,
61136118 sourceThreadId : threadId ,
0 commit comments