@@ -47,6 +47,58 @@ const encodeMessageContext = Schema.encodeEffect(
4747 Schema . fromJsonString ( OrchestrationMessageContext ) ,
4848) ;
4949
50+ it . effect ( "reads project shells without loading threads or resolving excluded projects" , ( ) => {
51+ const resolved : string [ ] = [ ] ;
52+ const layer = OrchestrationProjectionSnapshotQueryLive . pipe (
53+ Layer . provide ( ThreadBackgroundLiveness . layer ) ,
54+ Layer . provide ( ThreadPlanProgress . layer ) ,
55+ Layer . provide (
56+ Layer . succeed ( RepositoryIdentityResolver . RepositoryIdentityResolver , {
57+ resolve : ( root ) =>
58+ Effect . sync ( ( ) => {
59+ resolved . push ( root ) ;
60+ return null ;
61+ } ) ,
62+ } ) ,
63+ ) ,
64+ Layer . provideMerge ( SqlitePersistenceMemory ) ,
65+ ) ;
66+ return Effect . gen ( function * ( ) {
67+ const sql = yield * SqlClient . SqlClient ;
68+ const query = yield * ProjectionSnapshotQuery ;
69+ yield * sql `INSERT INTO projection_projects
70+ (project_id, title, workspace_root, scripts_json, created_at, updated_at, deleted_at)
71+ VALUES
72+ ('p1', 'First', '/first', '[]', '2026-09-01T00:00:00Z', '2026-09-01T00:00:00Z', NULL),
73+ ('p2', 'Second', '/second', '[]', '2026-09-02T00:00:00Z', '2026-09-02T00:00:00Z', NULL),
74+ ('p3', 'Deleted', '/deleted', '[]', '2026-09-03T00:00:00Z', '2026-09-03T00:00:00Z', '2026-09-04T00:00:00Z')` ;
75+ const expected = ( yield * query . getShellSnapshot ( ) ) . projects ;
76+ resolved . length = 0 ;
77+ yield * sql `INSERT INTO projection_threads
78+ (thread_id, project_id, title, model_selection_json, runtime_mode, interaction_mode, created_at, updated_at)
79+ VALUES ('t1', 'p1', 'Thread', 'invalid-json', 'full-access', 'default', '2026-09-01T00:00:00Z', '2026-09-01T00:00:00Z')` ;
80+
81+ const counter = makeSqlStatementCounter ( ) ;
82+ const projects = yield * query . getProjectShells ( ) . pipe ( Effect . withTracer ( counter . tracer ) ) ;
83+ assert . deepStrictEqual ( projects , expected ) ;
84+ assert . strictEqual ( counter . count ( ) , 1 ) ;
85+ assert . deepStrictEqual ( resolved . toSorted ( ) , [ "/first" , "/second" ] ) ;
86+ resolved . length = 0 ;
87+ yield * sql `UPDATE projection_projects SET scripts_json = 'invalid-json' WHERE project_id IN ('p1', 'p3')` ;
88+ assert . deepStrictEqual ( yield * query . getProjectShells ( [ asProjectId ( "p2" ) ] ) , [ expected [ 1 ] ! ] ) ;
89+ assert . deepStrictEqual ( resolved , [ "/second" ] ) ;
90+ resolved . length = 0 ;
91+ const beforeEmpty = counter . count ( ) ;
92+ assert . deepStrictEqual (
93+ yield * query . getProjectShells ( [ ] ) . pipe ( Effect . withTracer ( counter . tracer ) ) ,
94+ [ ] ,
95+ ) ;
96+ assert . strictEqual ( counter . count ( ) , beforeEmpty ) ;
97+ assert . deepStrictEqual ( yield * query . getProjectShells ( [ asProjectId ( "p3" ) ] ) , [ ] ) ;
98+ assert . deepStrictEqual ( resolved , [ ] ) ;
99+ } ) . pipe ( Effect . provide ( layer ) ) ;
100+ } ) ;
101+
50102const projectionSnapshotLayer = it . layer (
51103 OrchestrationProjectionSnapshotQueryLive . pipe (
52104 Layer . provide ( ThreadBackgroundLiveness . layer ) ,
0 commit comments