@@ -43,8 +43,8 @@ interface MemberRegistry {
4343
4444/**
4545 * [ADR-0146 D3, ruling record 6691022506] The write closure of an App's pair:
46- * `closure` — the pair and what it declares, the App — widened by every
47- * installed package whose pair it is (`pairOf`, `@objectstack/metadata-core`)
46+ * `closure` — the pair and what it declares, the App — widened, when it
47+ * declares its App, by every other installed package whose pair it is (`pairOf`, `@objectstack/metadata-core`)
4848 * and their own declared closures. A customization of any package of the App
4949 * lands in the App's pair, and the pair declares only the App (its range is
5050 * the App's), so the members it overrides and extends are reached through the
@@ -57,14 +57,18 @@ export function widenPairClosureToAppMembers(
5757 registry : MemberRegistry | undefined ,
5858) : { packageId : string ; dependencies : string [ ] } {
5959 const pairId = closure . packageId ;
60- if ( customizationBasePackageId ( pairId ) === null ) return closure ;
60+ const appId = customizationBasePackageId ( pairId ) ;
61+ // Members are reached THROUGH the App: a pair that does not declare its
62+ // App (an installed copy that dropped the dependency) is widened by
63+ // nothing, and the App itself is only ever in the closure by declaration.
64+ if ( appId === null || ! closure . dependencies . includes ( appId ) ) return closure ;
6165 if ( ! registry || typeof registry . getPackage !== 'function' || typeof registry . getAllPackages !== 'function' ) return closure ;
6266 const installed = installedManifestsOf ( registry as { getPackage ( id : string ) : { manifest ?: unknown } | undefined } ) ;
6367 const getPackage = ( id : string ) => registry . getPackage ! . call ( registry , id ) ;
6468 const dependencies = new Set ( closure . dependencies ) ;
6569 for ( const row of registry . getAllPackages . call ( registry ) ) {
6670 const id = ( row ?. manifest as { id ?: unknown } | undefined ) ?. id ;
67- if ( typeof id !== 'string' || id === pairId || dependencies . has ( id ) ) continue ;
71+ if ( typeof id !== 'string' || id === pairId || id === appId || dependencies . has ( id ) ) continue ;
6872 const pair = pairOf ( id , installed ) ;
6973 if ( ! pair . ok || pair . value !== pairId ) continue ;
7074 dependencies . add ( id ) ;
0 commit comments