@@ -23,23 +23,11 @@ import { HostChangeFeed } from '../server/host-change-feed.js';
2323
2424test ( 'routes each change kind only to subscribed connections' , ( ) => {
2525 const feed = new HostChangeFeed ( ) ;
26- const artifact : unknown [ ] = [ ] ;
27- const scopedArtifact : unknown [ ] = [ ] ;
2826 const configuration : unknown [ ] = [ ] ;
2927 const project : unknown [ ] = [ ] ;
3028 const scopedSession : unknown [ ] = [ ] ;
3129 const otherGuest : unknown [ ] = [ ] ;
3230 const all : unknown [ ] = [ ] ;
33- feed . attachConnection (
34- 'artifact' ,
35- { artifact : true } ,
36- { send : async ( frame ) => void artifact . push ( frame ) } ,
37- ) ;
38- feed . attachConnection (
39- 'scoped-artifact' ,
40- { artifact : { sessionId : 'session-1' } } ,
41- { send : async ( frame ) => void scopedArtifact . push ( frame ) } ,
42- ) ;
4331 feed . attachConnection (
4432 'configuration' ,
4533 { configuration : true } ,
@@ -53,7 +41,6 @@ test('routes each change kind only to subscribed connections', () => {
5341 feed . attachConnection (
5442 'all' ,
5543 {
56- artifact : true ,
5744 configuration : true ,
5845 connectionCatalog : true ,
5946 projectCatalog : true ,
@@ -73,8 +60,6 @@ test('routes each change kind only to subscribed connections', () => {
7360 { send : async ( frame ) => void otherGuest . push ( frame ) } ,
7461 ) ;
7562
76- feed . publishArtifactDeleted ( 'session-1' , 'artifact-1' ) ;
77- feed . publishArtifactSessionPurged ( 'session-2' ) ;
7863 feed . publishConfiguration ( ) ;
7964 feed . publishConnectionCatalog ( ) ;
8065 feed . publishProjectCatalog ( ) ;
@@ -85,27 +70,6 @@ test('routes each change kind only to subscribed connections', () => {
8570 feed . publishSessionCatalog ( 'session-1' , { kind : 'completed' , eventId : 'terminal-1' } ) ;
8671 feed . publishScheduledTask ( 7 , 'updated' , 'task-1' ) ;
8772
88- assert . deepEqual ( artifact , [
89- {
90- kind : 'artifact.changed' ,
91- reason : 'deleted' ,
92- sessionId : 'session-1' ,
93- artifactId : 'artifact-1' ,
94- } ,
95- {
96- kind : 'artifact.changed' ,
97- reason : 'session_purged' ,
98- sessionId : 'session-2' ,
99- } ,
100- ] ) ;
101- assert . deepEqual ( scopedArtifact , [
102- {
103- kind : 'artifact.changed' ,
104- reason : 'deleted' ,
105- sessionId : 'session-1' ,
106- artifactId : 'artifact-1' ,
107- } ,
108- ] ) ;
10973 assert . deepEqual (
11074 configuration . map ( ( frame ) => ( frame as { kind : string } ) . kind ) ,
11175 [ 'configuration.changed' ] ,
@@ -115,7 +79,7 @@ test('routes each change kind only to subscribed connections', () => {
11579 project . map ( ( frame ) => ( frame as { kind : string } ) . kind ) ,
11680 [ 'project.catalog.changed' ] ,
11781 ) ;
118- assert . equal ( all . length , 10 ) ;
82+ assert . equal ( all . length , 8 ) ;
11983 assert . deepEqual ( all . slice ( 3 , 5 ) , [
12084 { kind : 'session.catalog.changed' , revision : 1 , sessionId : 'session-1' , attention } ,
12185 {
@@ -132,6 +96,39 @@ test('routes each change kind only to subscribed connections', () => {
13296 assert . equal ( otherGuest . length , 3 ) ;
13397} ) ;
13498
99+ test ( 'routes Artifact invalidations by Session scope' , ( ) => {
100+ const feed = new HostChangeFeed ( ) ;
101+ const all : unknown [ ] = [ ] ;
102+ const scoped : unknown [ ] = [ ] ;
103+ feed . attachConnection (
104+ 'all-artifacts' ,
105+ { artifact : true } ,
106+ {
107+ send : async ( frame ) => void all . push ( frame ) ,
108+ } ,
109+ ) ;
110+ feed . attachConnection (
111+ 'session-artifacts' ,
112+ { artifact : { sessionId : 'session-1' } } ,
113+ {
114+ send : async ( frame ) => void scoped . push ( frame ) ,
115+ } ,
116+ ) ;
117+
118+ feed . publishArtifactDeleted ( 'session-1' , 'artifact-1' ) ;
119+ feed . publishArtifactSessionPurged ( 'session-2' ) ;
120+
121+ assert . equal ( all . length , 2 ) ;
122+ assert . deepEqual ( scoped , [
123+ {
124+ kind : 'artifact.changed' ,
125+ reason : 'deleted' ,
126+ sessionId : 'session-1' ,
127+ artifactId : 'artifact-1' ,
128+ } ,
129+ ] ) ;
130+ } ) ;
131+
135132test ( 'keeps catalog revisions independent and removes failed subscriptions' , async ( ) => {
136133 const feed = new HostChangeFeed ( ) ;
137134 const frames : unknown [ ] = [ ] ;
0 commit comments