@@ -8,7 +8,7 @@ import { PositionGraphService } from './position-graph.js';
88
99// Minimal engine: resolves find('sys_user_position') and find('sys_member').
1010function makeEngine (
11- assignments : Array < { position : string ; user_id : string ; organization_id ?: string | null } > ,
11+ assignments : Array < { id : string ; position : string ; user_id : string ; organization_id ?: string | null } > ,
1212 members : Array < { role : string ; user_id : string } > ,
1313) {
1414 return {
@@ -27,10 +27,12 @@ function makeEngine(
2727 } as any ;
2828}
2929
30+ // Every `sys_user_position` row carries its `id`, as a stored one does: the
31+ // assignment read pages by it (#29503) and refuses a row it cannot resume after.
3032const ASSIGNMENTS = [
31- { position : 'sales_manager' , user_id : 'u_mgr' } ,
32- { position : 'sales_rep' , user_id : 'u_rep1' } ,
33- { position : 'sales_rep' , user_id : 'u_rep2' } ,
33+ { id : 'up_1' , position : 'sales_manager' , user_id : 'u_mgr' } ,
34+ { id : 'up_2' , position : 'sales_rep' , user_id : 'u_rep1' } ,
35+ { id : 'up_3' , position : 'sales_rep' , user_id : 'u_rep2' } ,
3436] ;
3537// Every `sys_member` row carries its `id`, as a stored one does: the role read
3638// pages by it (#29362) and refuses a row it cannot resume after.
@@ -48,7 +50,7 @@ describe('PositionGraphService (ADR-0090 D3 — flat expansion)', () => {
4850
4951 it ( 'unions the better-auth membership transition source (no duplicates)' , async ( ) => {
5052 const g = new PositionGraphService ( {
51- engine : makeEngine ( [ ...ASSIGNMENTS , { position : 'sales_rep' , user_id : 'u_legacy_rep' } ] , MEMBERS ) ,
53+ engine : makeEngine ( [ ...ASSIGNMENTS , { id : 'up_4' , position : 'sales_rep' , user_id : 'u_legacy_rep' } ] , MEMBERS ) ,
5254 } ) ;
5355 const users = ( await g . expandPositionUsers ( 'sales_rep' ) ) . sort ( ) ;
5456 expect ( users ) . toEqual ( [ 'u_legacy_rep' , 'u_rep1' , 'u_rep2' ] ) ;
@@ -71,10 +73,10 @@ describe('PositionGraphService (ADR-0090 D3 — flat expansion)', () => {
7173 const g = new PositionGraphService ( {
7274 engine : makeEngine (
7375 [
74- { position : 'sales_rep' , user_id : 'u_active' } ,
75- { position : 'sales_rep' , user_id : 'u_expired' , valid_until : past } as any ,
76- { position : 'sales_rep' , user_id : 'u_pending' , valid_from : future } as any ,
77- { position : 'sales_rep' , user_id : 'u_windowed' , valid_from : past , valid_until : future } as any ,
76+ { id : 'up_5' , position : 'sales_rep' , user_id : 'u_active' } ,
77+ { id : 'up_6' , position : 'sales_rep' , user_id : 'u_expired' , valid_until : past } as any ,
78+ { id : 'up_7' , position : 'sales_rep' , user_id : 'u_pending' , valid_from : future } as any ,
79+ { id : 'up_8' , position : 'sales_rep' , user_id : 'u_windowed' , valid_from : past , valid_until : future } as any ,
7880 ] ,
7981 [ ] ,
8082 ) ,
@@ -87,7 +89,7 @@ describe('PositionGraphService (ADR-0090 D3 — flat expansion)', () => {
8789 const engine = {
8890 async find ( object : string , options : any ) {
8991 calls ++ ;
90- if ( object === 'sys_user_position' ) return [ { position : 'p' , user_id : 'u1' } ] ;
92+ if ( object === 'sys_user_position' ) return [ { id : 'up_9' , position : 'p' , user_id : 'u1' } ] ;
9193 return [ ] ;
9294 } ,
9395 } as any ;
@@ -103,14 +105,14 @@ describe('PositionGraphService.holdsPosition — the user-scoped twin of the exp
103105 const past = '2000-01-01T00:00:00Z' ;
104106 const future = '2999-01-01T00:00:00Z' ;
105107 const ASSIGN = [
106- { position : 'rep' , user_id : 'u_a' , organization_id : 'org_a' } ,
107- { position : 'rep' , user_id : 'u_b' , organization_id : 'org_b' } ,
108- { position : 'rep' , user_id : 'u_global' , organization_id : null } ,
109- { position : 'rep' , user_id : 'u_expired' , organization_id : 'org_a' , valid_until : past } ,
110- { position : 'rep' , user_id : 'u_pending' , organization_id : 'org_a' , valid_from : future } ,
111- { position : 'rep' , user_id : 'u_mixed' , organization_id : 'org_a' , valid_until : past } ,
112- { position : 'rep' , user_id : 'u_mixed' , organization_id : 'org_a' , valid_from : past , valid_until : future } ,
113- { position : 'mgr' , user_id : 'u_a' , organization_id : 'org_a' } ,
108+ { id : 'up_10' , position : 'rep' , user_id : 'u_a' , organization_id : 'org_a' } ,
109+ { id : 'up_11' , position : 'rep' , user_id : 'u_b' , organization_id : 'org_b' } ,
110+ { id : 'up_12' , position : 'rep' , user_id : 'u_global' , organization_id : null } ,
111+ { id : 'up_13' , position : 'rep' , user_id : 'u_expired' , organization_id : 'org_a' , valid_until : past } ,
112+ { id : 'up_14' , position : 'rep' , user_id : 'u_pending' , organization_id : 'org_a' , valid_from : future } ,
113+ { id : 'up_15' , position : 'rep' , user_id : 'u_mixed' , organization_id : 'org_a' , valid_until : past } ,
114+ { id : 'up_16' , position : 'rep' , user_id : 'u_mixed' , organization_id : 'org_a' , valid_from : past , valid_until : future } ,
115+ { id : 'up_17' , position : 'mgr' , user_id : 'u_a' , organization_id : 'org_a' } ,
114116 ] ;
115117 const MEMBER = [
116118 { id : 'm_role_a' , role : 'rep' , user_id : 'u_role_a' , organization_id : 'org_a' } ,
0 commit comments