@@ -65,6 +65,7 @@ describe('objectstack verify LIFECYCLE (ADR-0057): declared policies bound growt
6565 let engine : EngineLike ;
6666 let lifecycle : LifecycleLike ;
6767 let driver : DriverLike ;
68+ let organizationId : string ;
6869
6970 // Platform storage convention: `created_at` is registry-injected as a
7071 // `datetime` field, stored as epoch-ms INTEGER on SQLite (a JS Date through
@@ -76,6 +77,11 @@ describe('objectstack verify LIFECYCLE (ADR-0057): declared policies bound growt
7677 beforeAll ( async ( ) => {
7778 stack = await bootShowcase ( ) ;
7879 engine = stack . kernel . getService ( 'objectql' ) as unknown as EngineLike ;
80+ // The runaway writer's rows belong to the install's organization, as the
81+ // engine would stamp them: a fresh tenant column is NOT NULL (ADR-0131 D1).
82+ organizationId = String (
83+ ( ( await ( engine as any ) . find ( 'sys_organization' , { context : { isSystem : true } } ) ) as Array < { id : string } > ) [ 0 ] . id ,
84+ ) ;
7985 lifecycle = stack . kernel . getService ( 'lifecycle' ) as unknown as LifecycleLike ;
8086 expect ( lifecycle ?. sweep , 'the ObjectQLPlugin must register the ADR-0057 lifecycle service' ) . toBeTruthy ( ) ;
8187
@@ -148,12 +154,14 @@ describe('objectstack verify LIFECYCLE (ADR-0057): declared policies bound growt
148154 // any window (must never be touched).
149155 for ( let i = 0 ; i < 40 ; i ++ ) {
150156 await driver . create ( 'growth_probe_event' , {
157+ organization_id : organizationId ,
151158 payload : `tick-${ i } ` ,
152159 created_at : backdated ( 5 + i * 5 ) , // 5d … 200d
153160 } ) ;
154161 }
155162 for ( let i = 0 ; i < 5 ; i ++ ) {
156163 await driver . create ( 'growth_probe_record' , {
164+ organization_id : organizationId ,
157165 payload : `business-${ i } ` ,
158166 created_at : backdated ( 400 ) ,
159167 } ) ;
@@ -215,7 +223,7 @@ describe('objectstack verify LIFECYCLE (ADR-0057): declared policies bound growt
215223 // Round-trip: write through the driver, read through the view, and a
216224 // sweep applies the 'rotation' policy without touching the rows inside
217225 // the window.
218- await streamDriver . create ( 'growth_probe_stream' , { payload : 'tick' } ) ;
226+ await streamDriver . create ( 'growth_probe_stream' , { organization_id : organizationId , payload : 'tick' } ) ;
219227 expect ( await streamDriver . count ( 'growth_probe_stream' , { } ) ) . toBe ( 1 ) ;
220228
221229 const report = await lifecycle . sweep ( ) ;
@@ -227,6 +235,7 @@ describe('objectstack verify LIFECYCLE (ADR-0057): declared policies bound growt
227235 it ( 'ARCHIVE SAFETY: an audit ledger with a declared archive is never hot-deleted unarchived' , async ( ) => {
228236 for ( let i = 0 ; i < 3 ; i ++ ) {
229237 await driver . create ( 'growth_probe_ledger' , {
238+ organization_id : organizationId ,
230239 payload : `ledger-${ i } ` ,
231240 created_at : backdated ( 365 ) , // far past the 90d hot window
232241 } ) ;
0 commit comments