@@ -498,3 +498,50 @@ t.test('loading a workspace maintains overrides', async t => {
498498 const fooEdge = tree . edgesOut . get ( 'foo' )
499499 t . equal ( tree . overrides , fooEdge . overrides , 'foo edge got the correct overrides' )
500500} )
501+
502+ t . test ( 'applies root packageExtensions to a linked actual tree' , async t => {
503+ // packageExtensions never rewrite a package's package.json, so the extension edge lives only in lockfile metadata.
504+ // The linked store layout forces loadActual onto the filesystem-scan path, where the edge must be re-derived from the root rule set.
505+ const path = t . testdir ( {
506+ 'package.json' : JSON . stringify ( {
507+ name : 'root' ,
508+ version : '1.0.0' ,
509+ dependencies : { broken : '1.0.0' , safe : '1.0.0' } ,
510+ packageExtensions : { 'broken@1' : { dependencies : { missing : '^1.0.0' } } } ,
511+ } ) ,
512+ node_modules : {
513+ broken : t . fixture ( 'symlink' , '.store/broken@1.0.0/node_modules/broken' ) ,
514+ // safe matches no selector, exercising the non-extended path
515+ safe : t . fixture ( 'symlink' , '.store/safe@1.0.0/node_modules/safe' ) ,
516+ '.store' : {
517+ 'broken@1.0.0' : {
518+ node_modules : {
519+ // physical manifest deliberately omits the extension-added dependency
520+ broken : { 'package.json' : JSON . stringify ( { name : 'broken' , version : '1.0.0' } ) } ,
521+ missing : t . fixture ( 'symlink' , '../../missing@1.0.0/node_modules/missing' ) ,
522+ } ,
523+ } ,
524+ 'missing@1.0.0' : {
525+ node_modules : {
526+ missing : { 'package.json' : JSON . stringify ( { name : 'missing' , version : '1.0.0' } ) } ,
527+ } ,
528+ } ,
529+ 'safe@1.0.0' : {
530+ node_modules : {
531+ safe : { 'package.json' : JSON . stringify ( { name : 'safe' , version : '1.0.0' } ) } ,
532+ } ,
533+ } ,
534+ } ,
535+ } ,
536+ } )
537+
538+ const tree = await loadActual ( path )
539+ const brokenLink = tree . children . get ( 'broken' )
540+ const broken = brokenLink . target
541+ const edge = broken . edgesOut . get ( 'missing' )
542+ t . ok ( edge && ! edge . error , 'extension-added edge is present and resolves' )
543+ t . equal ( edge . to . name , 'missing' , 'edge resolves to the installed package' )
544+ const applied = { selector : 'broken@1' , dependencies : [ 'missing' ] }
545+ t . strictSame ( broken . packageExtensionsApplied , applied , 'provenance recorded on the store node' )
546+ t . strictSame ( brokenLink . packageExtensionsApplied , applied , 'provenance mirrored onto the link' )
547+ } )
0 commit comments