@@ -1318,32 +1318,32 @@ it.effect("lists only active subagent IDs without loading shell data", () =>
13181318 } ) . pipe ( Effect . provide ( layerTest ) ) ,
13191319) ;
13201320
1321- // regression: #25621 a shell snapshot binds one SQL variable per thread
1322- it . effect ( "reads a shell snapshot with more threads than SQLite has variables " , ( ) =>
1321+ // regression: #25621 SQLite rejects statements binding more than 32,766 variables
1322+ it . effect ( "lists every thread in the shell snapshot past SQLite's bound variable limit " , ( ) =>
13231323 Effect . gen ( function * ( ) {
13241324 const store = yield * ProjectionStore . ProjectionStoreV2 ;
13251325 const sql = yield * SqlClient . SqlClient ;
13261326 const now = yield * DateTime . now ;
1327- const seedId = ThreadId . make ( "thread:many:0 " ) ;
1327+ const templateId = ThreadId . make ( "thread:many:00000 " ) ;
13281328 yield * store . apply ( {
1329- id : EventId . make ( " event:many :created" ) ,
1329+ id : EventId . make ( ` event:${ templateId } :created` ) ,
13301330 type : "thread.created" ,
1331- threadId : seedId ,
1331+ threadId : templateId ,
13321332 occurredAt : now ,
13331333 payload : {
13341334 createdBy : "user" ,
13351335 creationSource : "web" ,
1336- id : seedId ,
1336+ id : templateId ,
13371337 projectId : ProjectId . make ( "project:many" ) ,
1338- title : "Many threads " ,
1338+ title : "Many" ,
13391339 providerInstanceId,
13401340 modelSelection,
13411341 runtimeMode : "full-access" ,
13421342 interactionMode : "default" ,
13431343 branch : null ,
13441344 worktreePath : null ,
13451345 activeProviderThreadId : null ,
1346- lineage : { parentThreadId : null , relationshipToParent : null , rootThreadId : seedId } ,
1346+ lineage : { parentThreadId : null , relationshipToParent : null , rootThreadId : templateId } ,
13471347 forkedFrom : null ,
13481348 createdAt : now ,
13491349 updatedAt : now ,
@@ -1358,23 +1358,27 @@ it.effect("reads a shell snapshot with more threads than SQLite has variables",
13581358 yield * sql `
13591359 CREATE TEMP TABLE many_threads AS
13601360 WITH RECURSIVE n(i) AS (SELECT 1 UNION ALL SELECT i + 1 FROM n WHERE i < ${ threadCount - 1 } )
1361- SELECT t.*, 'thread:many:' || n.i AS clone_id
1362- FROM orchestration_v2_projection_threads t, n
1363- WHERE t.thread_id = ${ seedId }
1361+ SELECT t.*, n.i AS clone_index FROM orchestration_v2_projection_threads t, n
1362+ WHERE t.thread_id = ${ templateId }
13641363 ` ;
13651364 yield * sql `
1366- UPDATE many_threads SET thread_id = clone_id,
1367- payload_json = json_set(payload_json, '$.id', clone_id, '$.lineage.rootThreadId', clone_id)
1365+ UPDATE many_threads SET
1366+ thread_id = printf('thread:many:%05d', clone_index),
1367+ payload_json = json_set(
1368+ payload_json,
1369+ '$.id', printf('thread:many:%05d', clone_index),
1370+ '$.lineage.rootThreadId', printf('thread:many:%05d', clone_index)
1371+ )
13681372 ` ;
1369- yield * sql `ALTER TABLE many_threads DROP COLUMN clone_id ` ;
1373+ yield * sql `ALTER TABLE many_threads DROP COLUMN clone_index ` ;
13701374 yield * sql `INSERT INTO orchestration_v2_projection_threads SELECT * FROM many_threads` ;
13711375
1372- const snapshot = yield * store . getShellSnapshot ( ) ;
1373- assert . strictEqual ( snapshot . threads . length , threadCount ) ;
1374- assert . include (
1375- snapshot . threads . map ( ( thread ) => thread . id ) ,
1376- ThreadId . make ( `thread:many: ${ threadCount - 1 } ` ) ,
1377- ) ;
1376+ const [ unscoped , active ] = yield * Effect . all ( [
1377+ store . getShellSnapshot ( ) ,
1378+ store . getShellSnapshot ( { location : "active" } ) ,
1379+ ] ) ;
1380+ assert . strictEqual ( unscoped . threads . length , threadCount ) ;
1381+ assert . strictEqual ( active . threads . length , threadCount ) ;
13781382 } ) . pipe ( Effect . provide ( layerTest ) ) ,
13791383) ;
13801384
0 commit comments