@@ -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 ) ( {
@@ -752,6 +758,7 @@ it.effect("passes the thread's MCP app context to the provider under a safe key"
752758 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( {
753759 captureBaseline : ( ) => Effect . void ,
754760 } ) ,
761+ layerTurnItemPositionsTest ,
755762 Layer . mock ( EventSink . EventSinkV2 ) ( { } ) ,
756763 IdAllocator . layer ,
757764 Layer . mock ( ProviderEventIngestor . ProviderEventIngestorV2 ) ( {
@@ -779,6 +786,7 @@ it.effect("fails the run when its ownership check cannot be read before calling
779786 Layer . mergeAll (
780787 McpAppModelContext . layerEmpty ,
781788 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( { captureBaseline : ( ) => Effect . void } ) ,
789+ layerTurnItemPositionsTest ,
782790 Layer . mock ( EventSink . EventSinkV2 ) ( {
783791 writeIfRunCurrent : ( input ) =>
784792 Ref . update ( writes , ( current ) => [ ...current , ...input . events ] ) . pipe (
@@ -1059,6 +1067,7 @@ it.effect("starts the provider when checkpoint baseline capture fails", () =>
10591067 } ) ,
10601068 ) ,
10611069 } ) ,
1070+ layerTurnItemPositionsTest ,
10621071 Layer . mock ( EventSink . EventSinkV2 ) ( {
10631072 writeWithEffects : ( input ) =>
10641073 Ref . update ( writes , ( current ) => [
@@ -1171,6 +1180,7 @@ it.effect.each(["failure", "interruption", "stale-attempt", "start-guard"] as co
11711180 captureBaseline : ( ) =>
11721181 scenario === "start-guard" ? Effect . void : Effect . die ( "not reached" ) ,
11731182 } ) ,
1183+ layerTurnItemPositionsTest ,
11741184 Layer . mock ( EventSink . EventSinkV2 ) ( {
11751185 writeIfRunCurrent : ( input ) =>
11761186 Effect . gen ( function * ( ) {
@@ -1337,6 +1347,7 @@ it.effect("ingests new member threads of an owned child after the root turn term
13371347 Layer . mergeAll (
13381348 McpAppModelContext . layerEmpty ,
13391349 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( { captureBaseline : ( ) => Effect . void } ) ,
1350+ layerTurnItemPositionsTest ,
13401351 Layer . mock ( EventSink . EventSinkV2 ) ( {
13411352 write : ( ) => Effect . succeed ( [ ] ) ,
13421353 writeWithEffects : ( input ) =>
@@ -1566,6 +1577,7 @@ it.effect("ends a nested native subagent and its thread when the root run is int
15661577 Layer . mergeAll (
15671578 McpAppModelContext . layerEmpty ,
15681579 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( { captureBaseline : ( ) => Effect . void } ) ,
1580+ layerTurnItemPositionsTest ,
15691581 Layer . mock ( EventSink . EventSinkV2 ) ( {
15701582 write : ( ) => Effect . succeed ( [ ] ) ,
15711583 writeWithEffects : ( input ) =>
@@ -1923,6 +1935,7 @@ it.effect(
19231935 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( {
19241936 captureBaseline : ( ) => Effect . void ,
19251937 } ) ,
1938+ layerTurnItemPositionsTest ,
19261939 Layer . mock ( EventSink . EventSinkV2 ) ( {
19271940 write : ( ) => Effect . succeed ( [ ] ) ,
19281941 writeWithEffects : ( input ) =>
@@ -2136,6 +2149,7 @@ it.effect("drops late root provider-thread writes from a superseded attempt", ()
21362149 Layer . mergeAll (
21372150 McpAppModelContext . layerEmpty ,
21382151 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( { captureBaseline : ( ) => Effect . void } ) ,
2152+ layerTurnItemPositionsTest ,
21392153 Layer . mock ( EventSink . EventSinkV2 ) ( {
21402154 write : ( ) => Effect . succeed ( [ ] ) ,
21412155 writeWithEffects : ( input ) =>
@@ -2337,6 +2351,7 @@ it.effect(
23372351 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( {
23382352 captureBaseline : ( ) => Effect . void ,
23392353 } ) ,
2354+ layerTurnItemPositionsTest ,
23402355 Layer . mock ( EventSink . EventSinkV2 ) ( {
23412356 write : ( ) => Effect . succeed ( [ ] ) ,
23422357 writeWithEffects : ( input ) =>
@@ -2506,6 +2521,7 @@ it.effect(
25062521 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( {
25072522 captureBaseline : ( ) => Effect . void ,
25082523 } ) ,
2524+ layerTurnItemPositionsTest ,
25092525 Layer . mock ( EventSink . EventSinkV2 ) ( {
25102526 write : ( ) => Effect . succeed ( [ ] ) ,
25112527 writeWithEffects : ( input ) =>
@@ -2668,6 +2684,7 @@ it.effect(
26682684 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( {
26692685 captureBaseline : ( ) => Effect . void ,
26702686 } ) ,
2687+ layerTurnItemPositionsTest ,
26712688 Layer . mock ( EventSink . EventSinkV2 ) ( {
26722689 write : ( ) => Effect . succeed ( [ ] ) ,
26732690 writeWithEffects : ( input ) =>
@@ -3108,6 +3125,7 @@ it.effect(
31083125 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( {
31093126 captureBaseline : ( ) => Effect . void ,
31103127 } ) ,
3128+ layerTurnItemPositionsTest ,
31113129 Layer . mock ( EventSink . EventSinkV2 ) ( {
31123130 write : ( ) => Effect . succeed ( [ ] ) ,
31133131 writeWithEffects : ( input ) =>
@@ -3885,6 +3903,7 @@ function captureRootRunTermination(input: {
38853903 forThread : ( ) => input . appContext ?? Effect . succeed ( [ ] ) ,
38863904 } ) ,
38873905 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( { captureBaseline : ( ) => Effect . void } ) ,
3906+ layerTurnItemPositionsTest ,
38883907 Layer . mock ( EventSink . EventSinkV2 ) ( {
38893908 write : ( payload ) =>
38903909 Effect . gen ( function * ( ) {
@@ -4370,6 +4389,7 @@ function runBackgroundItemScenario(
43704389 Layer . mergeAll (
43714390 McpAppModelContext . layerEmpty ,
43724391 Layer . mock ( CheckpointService . CheckpointServiceV2 ) ( { captureBaseline : ( ) => Effect . void } ) ,
4392+ layerTurnItemPositionsTest ,
43734393 Layer . mock ( EventSink . EventSinkV2 ) ( {
43744394 write : ( ) => Effect . succeed ( [ ] ) ,
43754395 writeWithEffects : ( input ) =>
0 commit comments