@@ -49,14 +49,20 @@ import * as ProviderEventIngestor from "./ProviderEventIngestor.ts";
4949import * as McpAppModelContext from "../mcpApps/McpAppModelContext.ts" ;
5050import * as RunExecutionService from "./RunExecutionService.ts" ;
5151import * as RunFinalizationService from "./RunFinalizationService.ts" ;
52+ import * as TurnItemPositionStore from "./TurnItemPositionStore.ts" ;
5253
5354const driver = ProviderDriverKind . make ( "codex" ) ;
5455
56+ const layerTurnItemPositionsTest = Layer . mock ( TurnItemPositionStore . TurnItemPositionStoreV2 ) ( {
57+ allocate : ( ) => Effect . succeed ( 1 ) ,
58+ } ) ;
59+
5560const layerRunExecutionTest = RunExecutionService . layer . pipe (
5661 Layer . provide (
5762 Layer . mergeAll (
5863 McpAppModelContext . layerEmpty ,
5964 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( { captureBaseline : ( ) => Effect . void } ) ,
65+ layerTurnItemPositionsTest ,
6066 Layer . mock ( EventSink . EventSinkV2 ) ( { } ) ,
6167 IdAllocator . layer ,
6268 Layer . mock ( ProviderEventIngestor . ProviderEventIngestorV2 ) ( {
@@ -755,6 +761,7 @@ it.effect("passes the thread's MCP app context to the provider under a safe key"
755761 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( {
756762 captureBaseline : ( ) => Effect . void ,
757763 } ) ,
764+ layerTurnItemPositionsTest ,
758765 Layer . mock ( EventSink . EventSinkV2 ) ( { } ) ,
759766 IdAllocator . layer ,
760767 Layer . mock ( ProviderEventIngestor . ProviderEventIngestorV2 ) ( {
@@ -782,6 +789,7 @@ it.effect("fails the run when its ownership check cannot be read before calling
782789 Layer . mergeAll (
783790 McpAppModelContext . layerEmpty ,
784791 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( { captureBaseline : ( ) => Effect . void } ) ,
792+ layerTurnItemPositionsTest ,
785793 Layer . mock ( EventSink . EventSinkV2 ) ( {
786794 writeIfRunCurrent : ( input ) =>
787795 Ref . update ( writes , ( current ) => [ ...current , ...input . events ] ) . pipe (
@@ -1065,6 +1073,7 @@ it.effect("starts the provider when checkpoint baseline capture fails", () =>
10651073 } ) ,
10661074 ) ,
10671075 } ) ,
1076+ layerTurnItemPositionsTest ,
10681077 Layer . mock ( EventSink . EventSinkV2 ) ( {
10691078 writeWithEffects : ( input ) =>
10701079 Ref . update ( writes , ( current ) => [
@@ -1177,6 +1186,7 @@ it.effect.each(["failure", "interruption", "stale-attempt", "start-guard"] as co
11771186 captureBaseline : ( ) =>
11781187 scenario === "start-guard" ? Effect . void : Effect . die ( "not reached" ) ,
11791188 } ) ,
1189+ layerTurnItemPositionsTest ,
11801190 Layer . mock ( EventSink . EventSinkV2 ) ( {
11811191 writeIfRunCurrent : ( input ) =>
11821192 Effect . gen ( function * ( ) {
@@ -1346,6 +1356,7 @@ it.effect("ingests new member threads of an owned child after the root turn term
13461356 Layer . mergeAll (
13471357 McpAppModelContext . layerEmpty ,
13481358 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( { captureBaseline : ( ) => Effect . void } ) ,
1359+ layerTurnItemPositionsTest ,
13491360 Layer . mock ( EventSink . EventSinkV2 ) ( {
13501361 write : ( ) => Effect . succeed ( [ ] ) ,
13511362 writeWithEffects : ( input ) =>
@@ -1575,6 +1586,7 @@ it.effect("ends a nested native subagent and its thread when the root run is int
15751586 Layer . mergeAll (
15761587 McpAppModelContext . layerEmpty ,
15771588 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( { captureBaseline : ( ) => Effect . void } ) ,
1589+ layerTurnItemPositionsTest ,
15781590 Layer . mock ( EventSink . EventSinkV2 ) ( {
15791591 write : ( ) => Effect . succeed ( [ ] ) ,
15801592 writeWithEffects : ( input ) =>
@@ -1932,6 +1944,7 @@ it.effect(
19321944 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( {
19331945 captureBaseline : ( ) => Effect . void ,
19341946 } ) ,
1947+ layerTurnItemPositionsTest ,
19351948 Layer . mock ( EventSink . EventSinkV2 ) ( {
19361949 write : ( ) => Effect . succeed ( [ ] ) ,
19371950 writeWithEffects : ( input ) =>
@@ -2148,6 +2161,7 @@ it.effect("drops late root provider-thread writes from a superseded attempt", ()
21482161 Layer . mergeAll (
21492162 McpAppModelContext . layerEmpty ,
21502163 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( { captureBaseline : ( ) => Effect . void } ) ,
2164+ layerTurnItemPositionsTest ,
21512165 Layer . mock ( EventSink . EventSinkV2 ) ( {
21522166 write : ( ) => Effect . succeed ( [ ] ) ,
21532167 writeWithEffects : ( input ) =>
@@ -2355,6 +2369,7 @@ it.effect(
23552369 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( {
23562370 captureBaseline : ( ) => Effect . void ,
23572371 } ) ,
2372+ layerTurnItemPositionsTest ,
23582373 Layer . mock ( EventSink . EventSinkV2 ) ( {
23592374 write : ( ) => Effect . succeed ( [ ] ) ,
23602375 writeWithEffects : ( input ) =>
@@ -2527,6 +2542,7 @@ it.effect(
25272542 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( {
25282543 captureBaseline : ( ) => Effect . void ,
25292544 } ) ,
2545+ layerTurnItemPositionsTest ,
25302546 Layer . mock ( EventSink . EventSinkV2 ) ( {
25312547 write : ( ) => Effect . succeed ( [ ] ) ,
25322548 writeWithEffects : ( input ) =>
@@ -2697,6 +2713,7 @@ it.effect(
26972713 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( {
26982714 captureBaseline : ( ) => Effect . void ,
26992715 } ) ,
2716+ layerTurnItemPositionsTest ,
27002717 Layer . mock ( EventSink . EventSinkV2 ) ( {
27012718 write : ( ) => Effect . succeed ( [ ] ) ,
27022719 writeWithEffects : ( input ) =>
@@ -3138,6 +3155,7 @@ it.effect(
31383155 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( {
31393156 captureBaseline : ( ) => Effect . void ,
31403157 } ) ,
3158+ layerTurnItemPositionsTest ,
31413159 Layer . mock ( EventSink . EventSinkV2 ) ( {
31423160 write : ( ) => Effect . succeed ( [ ] ) ,
31433161 writeWithEffects : ( input ) =>
@@ -3862,6 +3880,7 @@ function captureRootRunTermination(input: {
38623880 Layer . mergeAll (
38633881 McpAppModelContext . layerEmpty ,
38643882 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( { captureBaseline : ( ) => Effect . void } ) ,
3883+ layerTurnItemPositionsTest ,
38653884 Layer . mock ( EventSink . EventSinkV2 ) ( {
38663885 write : ( payload ) =>
38673886 Effect . gen ( function * ( ) {
@@ -4343,6 +4362,7 @@ function runBackgroundItemScenario(
43434362 Layer . mergeAll (
43444363 McpAppModelContext . layerEmpty ,
43454364 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( { captureBaseline : ( ) => Effect . void } ) ,
4365+ layerTurnItemPositionsTest ,
43464366 Layer . mock ( EventSink . EventSinkV2 ) ( {
43474367 write : ( ) => Effect . succeed ( [ ] ) ,
43484368 writeWithEffects : ( input ) =>
0 commit comments