@@ -1279,24 +1279,48 @@ describe('SecurityPlugin', () => {
12791279 return harness . run ( opCtx ) ;
12801280 } ;
12811281
1282- it ( 'DENIES deleting a platform-managed position (sys_position managed_by:system )' , async ( ) => {
1282+ it ( 'DENIES deleting a platform-managed position (sys_position managed_by:platform )' , async ( ) => {
12831283 const opCtx : any = {
12841284 object : 'sys_position' , operation : 'delete' ,
12851285 options : { where : { id : 'pos_admin' } } , context : adminCtx ,
12861286 } ;
12871287 await expect (
1288- runGate ( opCtx , ( ) => ( { id : 'pos_admin' , name : 'platform_admin' , managed_by : 'system ' } ) ) ,
1288+ runGate ( opCtx , ( ) => ( { id : 'pos_admin' , name : 'platform_admin' , managed_by : 'platform ' } ) ) ,
12891289 ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
12901290 } ) ;
12911291
1292- it ( 'DENIES updating a package-declared position (sys_position managed_by:config )' , async ( ) => {
1292+ it ( 'DENIES updating a package-declared position (sys_position managed_by:package )' , async ( ) => {
12931293 const opCtx : any = {
12941294 object : 'sys_position' , operation : 'update' ,
12951295 data : { id : 'pos_sales' , label : 'renamed' } , options : { where : { id : 'pos_sales' } } ,
12961296 context : adminCtx ,
12971297 } ;
12981298 await expect (
1299- runGate ( opCtx , ( ) => ( { id : 'pos_sales' , name : 'sales_rep' , managed_by : 'config' } ) ) ,
1299+ runGate ( opCtx , ( ) => ( { id : 'pos_sales' , name : 'sales_rep' , managed_by : 'package' } ) ) ,
1300+ ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
1301+ } ) ;
1302+
1303+ // [#2926 ①] Regression: the A4 rename (system→platform, config→package) once
1304+ // disarmed this gate because the provenance map only knew the legacy values.
1305+ // Rows the boot normalizer has not healed yet must STAY protected too.
1306+ it ( 'KEEPS denying legacy-vocab managed positions (managed_by:system, pre-normalizer rows)' , async ( ) => {
1307+ const opCtx : any = {
1308+ object : 'sys_position' , operation : 'delete' ,
1309+ options : { where : { id : 'pos_legacy' } } , context : adminCtx ,
1310+ } ;
1311+ await expect (
1312+ runGate ( opCtx , ( ) => ( { id : 'pos_legacy' , name : 'everyone' , managed_by : 'system' } ) ) ,
1313+ ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
1314+ } ) ;
1315+
1316+ it ( 'KEEPS denying legacy-vocab managed positions (managed_by:config, pre-normalizer rows)' , async ( ) => {
1317+ const opCtx : any = {
1318+ object : 'sys_position' , operation : 'update' ,
1319+ data : { id : 'pos_legacy2' , label : 'renamed' } , options : { where : { id : 'pos_legacy2' } } ,
1320+ context : adminCtx ,
1321+ } ;
1322+ await expect (
1323+ runGate ( opCtx , ( ) => ( { id : 'pos_legacy2' , name : 'sales_rep' , managed_by : 'config' } ) ) ,
13001324 ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
13011325 } ) ;
13021326
@@ -1321,13 +1345,23 @@ describe('SecurityPlugin', () => {
13211345 ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
13221346 } ) ;
13231347
1324- it ( 'ALLOWS deleting an admin-authored position (sys_position managed_by:user )' , async ( ) => {
1348+ it ( 'ALLOWS deleting an admin-authored position (sys_position managed_by:admin )' , async ( ) => {
13251349 const opCtx : any = {
13261350 object : 'sys_position' , operation : 'delete' ,
13271351 options : { where : { id : 'pos_user' } } , context : adminCtx ,
13281352 } ;
13291353 await expect (
1330- runGate ( opCtx , ( ) => ( { id : 'pos_user' , name : 'my_team' , managed_by : 'user' } ) ) ,
1354+ runGate ( opCtx , ( ) => ( { id : 'pos_user' , name : 'my_team' , managed_by : 'admin' } ) ) ,
1355+ ) . resolves . toBeDefined ( ) ;
1356+ } ) ;
1357+
1358+ it ( 'ALLOWS deleting a legacy admin-authored position (managed_by:user, pre-normalizer)' , async ( ) => {
1359+ const opCtx : any = {
1360+ object : 'sys_position' , operation : 'delete' ,
1361+ options : { where : { id : 'pos_user_legacy' } } , context : adminCtx ,
1362+ } ;
1363+ await expect (
1364+ runGate ( opCtx , ( ) => ( { id : 'pos_user_legacy' , name : 'my_team' , managed_by : 'user' } ) ) ,
13311365 ) . resolves . toBeDefined ( ) ;
13321366 } ) ;
13331367
@@ -1353,10 +1387,18 @@ describe('SecurityPlugin', () => {
13531387 ) . resolves . toBeDefined ( ) ;
13541388 } ) ;
13551389
1356- it ( 'DENIES an admin-door insert that forges platform provenance (sys_position managed_by:system)' , async ( ) => {
1390+ it ( 'DENIES an admin-door insert that forges platform provenance (sys_position managed_by:platform)' , async ( ) => {
1391+ const opCtx : any = {
1392+ object : 'sys_position' , operation : 'insert' ,
1393+ data : { name : 'forged' , managed_by : 'platform' } , context : adminCtx ,
1394+ } ;
1395+ await expect ( runGate ( opCtx ) ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
1396+ } ) ;
1397+
1398+ it ( 'DENIES an admin-door insert that forges LEGACY platform provenance (managed_by:system)' , async ( ) => {
13571399 const opCtx : any = {
13581400 object : 'sys_position' , operation : 'insert' ,
1359- data : { name : 'forged ' , managed_by : 'system' } , context : adminCtx ,
1401+ data : { name : 'forged_legacy ' , managed_by : 'system' } , context : adminCtx ,
13601402 } ;
13611403 await expect ( runGate ( opCtx ) ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
13621404 } ) ;
@@ -1400,14 +1442,14 @@ describe('SecurityPlugin', () => {
14001442 context : adminCtx ,
14011443 } ;
14021444 await expect (
1403- runGate ( opCtx , ( ) => ( { id : 'pos_admin' , managed_by : 'system ' } ) ) ,
1445+ runGate ( opCtx , ( ) => ( { id : 'pos_admin' , managed_by : 'platform ' } ) ) ,
14041446 ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
14051447 } ) ;
14061448
14071449 it ( 'ALLOWS a filter delete that matches only admin-authored rows (probe finds none)' , async ( ) => {
14081450 const opCtx : any = {
14091451 object : 'sys_position' , operation : 'delete' ,
1410- options : { where : { managed_by : 'user ' } } ,
1452+ options : { where : { managed_by : 'admin ' } } ,
14111453 context : adminCtx ,
14121454 } ;
14131455 // The managed-row probe finds nothing → the write proceeds.
@@ -1421,7 +1463,7 @@ describe('SecurityPlugin', () => {
14211463 context : { } , // no roles, no permissions, no userId, not isSystem
14221464 } ;
14231465 await expect (
1424- runGate ( opCtx , ( ) => ( { id : 'pos_admin' , name : 'platform_admin' , managed_by : 'system ' } ) ) ,
1466+ runGate ( opCtx , ( ) => ( { id : 'pos_admin' , name : 'platform_admin' , managed_by : 'platform ' } ) ) ,
14251467 ) . rejects . toMatchObject ( { name : 'PermissionDeniedError' } ) ;
14261468 } ) ;
14271469
@@ -1432,7 +1474,7 @@ describe('SecurityPlugin', () => {
14321474 context : { isSystem : true } ,
14331475 } ;
14341476 await expect (
1435- runGate ( opCtx , ( ) => ( { id : 'pos_admin' , name : 'platform_admin' , managed_by : 'system ' } ) ) ,
1477+ runGate ( opCtx , ( ) => ( { id : 'pos_admin' , name : 'platform_admin' , managed_by : 'platform ' } ) ) ,
14361478 ) . resolves . toBeDefined ( ) ;
14371479 } ) ;
14381480 } ) ;
0 commit comments