@@ -74,7 +74,7 @@ layer("OrchestrationProjectionPipeline fork projection", (it) => {
7474 } ) ;
7575 yield * projectionPipeline . bootstrap ;
7676
77- let rows = yield * sql < { readonly forkJson : string | null ; readonly sideChat : number } > `
77+ const rows = yield * sql < { readonly forkJson : string | null ; readonly sideChat : number } > `
7878 SELECT fork_json AS "forkJson", side_chat AS "sideChat"
7979 FROM projection_threads
8080 WHERE thread_id = ${ threadId }
@@ -100,13 +100,32 @@ layer("OrchestrationProjectionPipeline fork projection", (it) => {
100100 payload : { threadId, sideChat : false , updatedAt : now } ,
101101 } ) ;
102102 yield * projectionPipeline . bootstrap ;
103- rows = yield * sql < { readonly forkJson : string | null ; readonly sideChat : number } > `
104- SELECT fork_json AS "forkJson", side_chat AS "sideChat"
103+ // Promotion clears the side-chat flag but must leave the lineage intact.
104+ const promotedRows = yield * sql < {
105+ readonly sourceThreadId : string | null ;
106+ readonly sourceTurnId : string | null ;
107+ readonly sourceMessageId : string | null ;
108+ readonly forkedAt : string | null ;
109+ readonly sideChat : number ;
110+ } > `
111+ SELECT
112+ json_extract(fork_json, '$.sourceThreadId') AS "sourceThreadId",
113+ json_extract(fork_json, '$.sourceTurnId') AS "sourceTurnId",
114+ json_extract(fork_json, '$.sourceMessageId') AS "sourceMessageId",
115+ json_extract(fork_json, '$.forkedAt') AS "forkedAt",
116+ side_chat AS "sideChat"
105117 FROM projection_threads
106118 WHERE thread_id = ${ threadId }
107119 ` ;
108- assert . equal ( rows [ 0 ] ?. sideChat , 0 ) ;
109- assert . isNotNull ( rows [ 0 ] ?. forkJson ?? null ) ;
120+ assert . deepEqual ( promotedRows , [
121+ {
122+ sourceThreadId : "thread-source-projection" ,
123+ sourceTurnId : "turn-source-projection" ,
124+ sourceMessageId : null ,
125+ forkedAt : now ,
126+ sideChat : 0 ,
127+ } ,
128+ ] ) ;
110129 } ) ,
111130 ) ;
112131} ) ;
0 commit comments