@@ -66,10 +66,7 @@ const streamingProjectionEvent = (
6666 kind : ( typeof streamingProjectionCases ) [ number ] ,
6767 id : string ,
6868 at : DateTime . Utc ,
69- ) : Extract <
70- OrchestrationV2DomainEvent ,
71- { readonly type : "node.updated" | "message.updated" | "turn-item.updated" }
72- > => {
69+ ) => {
7370 const threadId = ThreadId . make ( "thread:streaming-write" ) ;
7471 const base = {
7572 threadId,
@@ -98,7 +95,7 @@ const streamingProjectionEvent = (
9895 startedAt : at ,
9996 completedAt : null ,
10097 } ,
101- } ;
98+ } as const satisfies OrchestrationV2DomainEvent ;
10299 case "message" :
103100 return {
104101 ...event ,
@@ -115,7 +112,7 @@ const streamingProjectionEvent = (
115112 createdAt : at ,
116113 updatedAt : at ,
117114 } ,
118- } ;
115+ } as const satisfies OrchestrationV2DomainEvent ;
119116 case "turn-item" :
120117 return {
121118 ...event ,
@@ -135,7 +132,7 @@ const streamingProjectionEvent = (
135132 text : "a" . repeat ( 512 ) ,
136133 streaming : true ,
137134 } ,
138- } ;
135+ } as const satisfies OrchestrationV2DomainEvent ;
139136 }
140137} ;
141138
@@ -179,7 +176,6 @@ it.effect.each(streamingProjectionCases)(
179176 ) ;
180177 break ;
181178 case "turn-item.updated" :
182- if ( event . payload . type !== "reasoning" ) return yield * Effect . die ( "Expected reasoning" ) ;
183179 yield * sql . withTransaction (
184180 store . apply ( {
185181 ...event ,
@@ -207,100 +203,79 @@ it.effect.each(streamingProjectionCases)(
207203 const at = DateTime . makeUnsafe ( "2026-10-23T00:00:00.000Z" ) ;
208204 const later = DateTime . add ( at , { seconds : 1 } ) ;
209205 const event = streamingProjectionEvent ( kind , "record:equivalence" , at ) ;
210- const variants : Array < typeof event > = [ event ] ;
206+ const variants : Array < OrchestrationV2DomainEvent > = [ event ] ;
211207 switch ( event . type ) {
212208 case "node.updated" : {
213209 const node = event . payload ;
214- variants . push (
215- { ...event , payload : { ...node , countsForRun : true , completedAt : later } } ,
216- { ...event , payload : { ...node , runId : null , parentNodeId : NodeId . make ( "parent" ) } } ,
217- { ...event , payload : { ...node , runId : RunId . make ( "other-run" ) , status : "completed" } } ,
210+ for ( const payload of [
211+ { ...node , threadId : ThreadId . make ( "other-thread" ) } ,
212+ { ...node , runId : null } ,
213+ { ...node , parentNodeId : NodeId . make ( "parent" ) } ,
214+ { ...node , providerTurnId : null } ,
215+ { ...node , status : "completed" as const } ,
218216 {
219- ...event ,
220- payload : {
221- ...node ,
222- threadId : ThreadId . make ( "other-thread" ) ,
223- kind : "tool_call" ,
224- rootNodeId : NodeId . make ( "other-root" ) ,
225- providerThreadId : null ,
226- providerTurnId : null ,
227- runtimeRequestId : RuntimeRequestId . make ( "request" ) ,
228- checkpointScopeId : CheckpointScopeId . make ( "scope" ) ,
229- startedAt : null ,
230- } ,
217+ ...node ,
218+ countsForRun : true ,
219+ rootNodeId : NodeId . make ( "other-root" ) ,
220+ kind : "tool_call" as const ,
221+ providerThreadId : null ,
222+ runtimeRequestId : RuntimeRequestId . make ( "request" ) ,
223+ checkpointScopeId : CheckpointScopeId . make ( "scope" ) ,
224+ startedAt : null ,
225+ completedAt : later ,
231226 } ,
232- event ,
233- ) ;
227+ ] )
228+ variants . push ( { ... event , payload } , event ) ;
234229 break ;
235230 }
236231 case "message.updated" : {
237232 const message = event . payload ;
238- variants . push (
239- { ...event , payload : { ...message , text : "next chunk" , updatedAt : later } } ,
240- { ...event , payload : { ...message , role : "user" , streaming : false } } ,
241- { ...event , payload : { ...message , runId : null , nodeId : null , createdAt : later } } ,
233+ for ( const payload of [
234+ { ...message , threadId : ThreadId . make ( "other-thread" ) } ,
235+ { ...message , runId : null } ,
236+ { ...message , nodeId : null } ,
237+ { ...message , createdAt : later } ,
242238 {
243- ...event ,
244- payload : {
245- ...message ,
246- threadId : ThreadId . make ( "other-thread" ) ,
247- runId : RunId . make ( "other-run" ) ,
248- nodeId : NodeId . make ( "other-node" ) ,
249- } ,
239+ ...message ,
240+ text : "next chunk" ,
241+ updatedAt : later ,
242+ streaming : false ,
243+ role : "user" as const ,
250244 } ,
251- event ,
252- ) ;
245+ ] )
246+ variants . push ( { ... event , payload } , event ) ;
253247 break ;
254248 }
255249 case "turn-item.updated" : {
256250 const item = event . payload ;
257- if ( item . type !== "reasoning" ) return yield * Effect . die ( "Expected reasoning" ) ;
258- variants . push (
259- { ...event , payload : { ...item , updatedAt : later , title : "next chunk" } } ,
251+ for ( const payload of [
252+ { ...item , threadId : ThreadId . make ( "other-thread" ) } ,
253+ { ...item , runId : null } ,
254+ { ...item , nodeId : null } ,
255+ { ...item , providerTurnId : null } ,
256+ { ...item , ordinal : 9_000_000_000 } ,
257+ { ...item , status : "completed" as const } ,
258+ { ...item , type : "compaction" as const , driver } ,
260259 {
261- ...event ,
262- payload : {
263- ...item ,
264- parentItemId : TurnItemId . make ( "parent" ) ,
265- providerThreadId : null ,
266- runId : null ,
267- nodeId : null ,
268- providerTurnId : null ,
269- } ,
270- } ,
271- {
272- ...event ,
273- payload : {
274- ...item ,
275- threadId : ThreadId . make ( "other-thread" ) ,
276- runId : RunId . make ( "other-run" ) ,
277- nodeId : NodeId . make ( "other-node" ) ,
278- providerTurnId : ProviderTurnId . make ( "other-turn" ) ,
279- ordinal : 9_000_000_000 ,
280- status : "completed" ,
281- type : "compaction" ,
282- driver,
283- } ,
284- } ,
285- {
286- ...event ,
287- payload : {
288- ...item ,
289- type : "error" ,
290- status : "failed" ,
291- failure : { class : "unknown" , message : "Failed" , code : null , retryable : null } ,
292- } ,
293- } ,
294- {
295- ...event ,
296- payload : {
297- ...item ,
298- type : "error" ,
299- status : "failed" ,
300- updatedAt : later ,
301- failure : { class : "unknown" , message : "Updated" , code : null , retryable : null } ,
302- } ,
260+ ...item ,
261+ parentItemId : TurnItemId . make ( "parent" ) ,
262+ providerThreadId : null ,
263+ updatedAt : later ,
264+ title : "next chunk" ,
265+ text : "next chunk" ,
266+ streaming : false ,
303267 } ,
268+ ] )
269+ variants . push ( { ...event , payload } , event ) ;
270+ const failed = {
271+ ...item ,
272+ type : "error" as const ,
273+ status : "failed" as const ,
274+ failure : { class : "unknown" as const , message : "Failed" , code : null , retryable : null } ,
275+ } ;
276+ variants . push (
277+ { ...event , payload : failed } ,
278+ { ...event , payload : { ...failed , updatedAt : later } } ,
304279 event ,
305280 ) ;
306281 break ;
@@ -315,7 +290,6 @@ it.effect.each(streamingProjectionCases)(
315290 yield * store . apply ( variant ) ;
316291 assert . deepEqual ( yield * read , updated ) ;
317292 }
318- assert . deepEqual ( yield * sql `PRAGMA integrity_check` , [ { integrity_check : "ok" } ] ) ;
319293 } ) . pipe ( Effect . provide ( layerTest ) ) ,
320294) ;
321295
0 commit comments