@@ -1428,24 +1428,48 @@ describe('SecurityPlugin', () => {
14281428 return harness . run ( opCtx ) ;
14291429 } ;
14301430
1431- it ( 'DENIES deleting a platform-managed position (sys_position managed_by:system )' , async ( ) => {
1431+ it ( 'DENIES deleting a platform-managed position (sys_position managed_by:platform )' , async ( ) => {
14321432 const opCtx : any = {
14331433 object : 'sys_position' , operation : 'delete' ,
14341434 options : { where : { id : 'pos_admin' } } , context : adminCtx ,
14351435 } ;
14361436 await expect (
1437- runGate ( opCtx , ( ) => ( { id : 'pos_admin' , name : 'platform_admin' , managed_by : 'system ' } ) ) ,
1437+ runGate ( opCtx , ( ) => ( { id : 'pos_admin' , name : 'platform_admin' , managed_by : 'platform ' } ) ) ,
14381438 ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
14391439 } ) ;
14401440
1441- it ( 'DENIES updating a package-declared position (sys_position managed_by:config )' , async ( ) => {
1441+ it ( 'DENIES updating a package-declared position (sys_position managed_by:package )' , async ( ) => {
14421442 const opCtx : any = {
14431443 object : 'sys_position' , operation : 'update' ,
14441444 data : { id : 'pos_sales' , label : 'renamed' } , options : { where : { id : 'pos_sales' } } ,
14451445 context : adminCtx ,
14461446 } ;
14471447 await expect (
1448- runGate ( opCtx , ( ) => ( { id : 'pos_sales' , name : 'sales_rep' , managed_by : 'config' } ) ) ,
1448+ runGate ( opCtx , ( ) => ( { id : 'pos_sales' , name : 'sales_rep' , managed_by : 'package' } ) ) ,
1449+ ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
1450+ } ) ;
1451+
1452+ // [#2926 ①] Regression: the A4 rename (system→platform, config→package) once
1453+ // disarmed this gate because the provenance map only knew the legacy values.
1454+ // Rows the boot normalizer has not healed yet must STAY protected too.
1455+ it ( 'KEEPS denying legacy-vocab managed positions (managed_by:system, pre-normalizer rows)' , async ( ) => {
1456+ const opCtx : any = {
1457+ object : 'sys_position' , operation : 'delete' ,
1458+ options : { where : { id : 'pos_legacy' } } , context : adminCtx ,
1459+ } ;
1460+ await expect (
1461+ runGate ( opCtx , ( ) => ( { id : 'pos_legacy' , name : 'everyone' , managed_by : 'system' } ) ) ,
1462+ ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
1463+ } ) ;
1464+
1465+ it ( 'KEEPS denying legacy-vocab managed positions (managed_by:config, pre-normalizer rows)' , async ( ) => {
1466+ const opCtx : any = {
1467+ object : 'sys_position' , operation : 'update' ,
1468+ data : { id : 'pos_legacy2' , label : 'renamed' } , options : { where : { id : 'pos_legacy2' } } ,
1469+ context : adminCtx ,
1470+ } ;
1471+ await expect (
1472+ runGate ( opCtx , ( ) => ( { id : 'pos_legacy2' , name : 'sales_rep' , managed_by : 'config' } ) ) ,
14491473 ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
14501474 } ) ;
14511475
@@ -1470,13 +1494,23 @@ describe('SecurityPlugin', () => {
14701494 ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
14711495 } ) ;
14721496
1473- it ( 'ALLOWS deleting an admin-authored position (sys_position managed_by:user )' , async ( ) => {
1497+ it ( 'ALLOWS deleting an admin-authored position (sys_position managed_by:admin )' , async ( ) => {
14741498 const opCtx : any = {
14751499 object : 'sys_position' , operation : 'delete' ,
14761500 options : { where : { id : 'pos_user' } } , context : adminCtx ,
14771501 } ;
14781502 await expect (
1479- runGate ( opCtx , ( ) => ( { id : 'pos_user' , name : 'my_team' , managed_by : 'user' } ) ) ,
1503+ runGate ( opCtx , ( ) => ( { id : 'pos_user' , name : 'my_team' , managed_by : 'admin' } ) ) ,
1504+ ) . resolves . toBeDefined ( ) ;
1505+ } ) ;
1506+
1507+ it ( 'ALLOWS deleting a legacy admin-authored position (managed_by:user, pre-normalizer)' , async ( ) => {
1508+ const opCtx : any = {
1509+ object : 'sys_position' , operation : 'delete' ,
1510+ options : { where : { id : 'pos_user_legacy' } } , context : adminCtx ,
1511+ } ;
1512+ await expect (
1513+ runGate ( opCtx , ( ) => ( { id : 'pos_user_legacy' , name : 'my_team' , managed_by : 'user' } ) ) ,
14801514 ) . resolves . toBeDefined ( ) ;
14811515 } ) ;
14821516
@@ -1502,10 +1536,18 @@ describe('SecurityPlugin', () => {
15021536 ) . resolves . toBeDefined ( ) ;
15031537 } ) ;
15041538
1505- it ( 'DENIES an admin-door insert that forges platform provenance (sys_position managed_by:system)' , async ( ) => {
1539+ it ( 'DENIES an admin-door insert that forges platform provenance (sys_position managed_by:platform)' , async ( ) => {
1540+ const opCtx : any = {
1541+ object : 'sys_position' , operation : 'insert' ,
1542+ data : { name : 'forged' , managed_by : 'platform' } , context : adminCtx ,
1543+ } ;
1544+ await expect ( runGate ( opCtx ) ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
1545+ } ) ;
1546+
1547+ it ( 'DENIES an admin-door insert that forges LEGACY platform provenance (managed_by:system)' , async ( ) => {
15061548 const opCtx : any = {
15071549 object : 'sys_position' , operation : 'insert' ,
1508- data : { name : 'forged ' , managed_by : 'system' } , context : adminCtx ,
1550+ data : { name : 'forged_legacy ' , managed_by : 'system' } , context : adminCtx ,
15091551 } ;
15101552 await expect ( runGate ( opCtx ) ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
15111553 } ) ;
@@ -1549,14 +1591,14 @@ describe('SecurityPlugin', () => {
15491591 context : adminCtx ,
15501592 } ;
15511593 await expect (
1552- runGate ( opCtx , ( ) => ( { id : 'pos_admin' , managed_by : 'system ' } ) ) ,
1594+ runGate ( opCtx , ( ) => ( { id : 'pos_admin' , managed_by : 'platform ' } ) ) ,
15531595 ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
15541596 } ) ;
15551597
15561598 it ( 'ALLOWS a filter delete that matches only admin-authored rows (probe finds none)' , async ( ) => {
15571599 const opCtx : any = {
15581600 object : 'sys_position' , operation : 'delete' ,
1559- options : { where : { managed_by : 'user ' } } ,
1601+ options : { where : { managed_by : 'admin ' } } ,
15601602 context : adminCtx ,
15611603 } ;
15621604 // The managed-row probe finds nothing → the write proceeds.
@@ -1570,7 +1612,7 @@ describe('SecurityPlugin', () => {
15701612 context : { } , // no roles, no permissions, no userId, not isSystem
15711613 } ;
15721614 await expect (
1573- runGate ( opCtx , ( ) => ( { id : 'pos_admin' , name : 'platform_admin' , managed_by : 'system ' } ) ) ,
1615+ runGate ( opCtx , ( ) => ( { id : 'pos_admin' , name : 'platform_admin' , managed_by : 'platform ' } ) ) ,
15741616 ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
15751617 } ) ;
15761618
@@ -1581,7 +1623,7 @@ describe('SecurityPlugin', () => {
15811623 context : { isSystem : true } ,
15821624 } ;
15831625 await expect (
1584- runGate ( opCtx , ( ) => ( { id : 'pos_admin' , name : 'platform_admin' , managed_by : 'system ' } ) ) ,
1626+ runGate ( opCtx , ( ) => ( { id : 'pos_admin' , name : 'platform_admin' , managed_by : 'platform ' } ) ) ,
15851627 ) . resolves . toBeDefined ( ) ;
15861628 } ) ;
15871629 } ) ;
0 commit comments