@@ -94,7 +94,14 @@ const LEGACY_APP_ID = 'com.example.pulllegacy';
9494const LEGACY_BOUND = 'pull_legacy_bound' ;
9595const LEGACY_UNBOUND = 'pull_legacy_unbound' ;
9696
97- const MAPPING_NAME = 'orders_pull' ;
97+ /**
98+ * Each package's own mapping, named under its namespace: a mapping name is held
99+ * by ONE package per deployment (ADR-0048 §3.4 narrowed, 2026-11-06), so these
100+ * packages, installed into one kernel, cannot share one. `mappingTypo` is the
101+ * one-letter typo of a package's own mapping name — a mapping it never declares.
102+ */
103+ const mappingNameOf = ( ns : string ) => `${ ns } _orders_pull` ;
104+ const mappingTypo = ( ns : string ) => `${ ns } _orders_pul` ;
98105
99106function orderObject ( name : string ) {
100107 return {
@@ -105,10 +112,10 @@ function orderObject(name: string) {
105112 } ;
106113}
107114
108- /** A mapping that pulls into `target`; `withSource: false` drops its `connectorSource` (an import-only mapping). */
109- function mapping ( target : string , withSource = true ) {
115+ /** The mapping `name`, pulling into `target`; `withSource: false` drops its `connectorSource` (an import-only mapping). */
116+ function mapping ( name : string , target : string , withSource = true ) {
110117 return {
111- name : MAPPING_NAME ,
118+ name,
112119 targetObject : target ,
113120 fieldMapping : [ { source : 'id' , target : 'external_id' } ] ,
114121 mode : 'upsert' ,
@@ -127,15 +134,15 @@ function pullArtifact(id: string, ns: string, opts: { job: unknown; withSource?:
127134 return {
128135 manifest : { id, namespace : ns , version : '0.1.0' , type : 'app' , name : ns } ,
129136 objects : [ orderObject ( `${ ns } _order` ) ] ,
130- mappings : [ mapping ( `${ ns } _order` , opts . withSource ?? true ) ] ,
137+ mappings : [ mapping ( mappingNameOf ( ns ) , `${ ns } _order` , opts . withSource ?? true ) ] ,
131138 jobs : [ opts . job ] ,
132139 } ;
133140}
134141
135- const GOOD_ARTIFACT = pullArtifact ( GOOD_APP_ID , 'pull_jobs' , { job : pullJob ( GOOD_JOB , MAPPING_NAME ) } ) ;
136- const MISSING_ARTIFACT = pullArtifact ( MISSING_APP_ID , 'pull_missing' , { job : pullJob ( MISSING_JOB , 'orders_pul' ) } ) ;
137- const NOSOURCE_ARTIFACT = pullArtifact ( NOSOURCE_APP_ID , 'pull_nosource' , { job : pullJob ( NOSOURCE_JOB , MAPPING_NAME ) , withSource : false } ) ;
138- const OFF_ARTIFACT = pullArtifact ( OFF_APP_ID , 'pull_off' , { job : pullJob ( OFF_JOB , 'orders_pul' , { enabled : false } ) } ) ;
142+ const GOOD_ARTIFACT = pullArtifact ( GOOD_APP_ID , 'pull_jobs' , { job : pullJob ( GOOD_JOB , mappingNameOf ( 'pull_jobs' ) ) } ) ;
143+ const MISSING_ARTIFACT = pullArtifact ( MISSING_APP_ID , 'pull_missing' , { job : pullJob ( MISSING_JOB , mappingTypo ( 'pull_missing' ) ) } ) ;
144+ const NOSOURCE_ARTIFACT = pullArtifact ( NOSOURCE_APP_ID , 'pull_nosource' , { job : pullJob ( NOSOURCE_JOB , mappingNameOf ( 'pull_nosource' ) ) , withSource : false } ) ;
145+ const OFF_ARTIFACT = pullArtifact ( OFF_APP_ID , 'pull_off' , { job : pullJob ( OFF_JOB , mappingTypo ( 'pull_off' ) , { enabled : false } ) } ) ;
139146
140147/** What the install route persists — the compiled bundle, flattened — in an earlier build's layout. */
141148const LEGACY_ENTRY = {
@@ -150,8 +157,8 @@ const LEGACY_ENTRY = {
150157 type : 'app' ,
151158 name : 'Pull Legacy' ,
152159 objects : [ orderObject ( 'pull_legacy_order' ) ] ,
153- mappings : [ mapping ( 'pull_legacy_order' ) ] ,
154- jobs : [ pullJob ( LEGACY_BOUND , MAPPING_NAME ) , pullJob ( LEGACY_UNBOUND , 'orders_pul' ) ] ,
160+ mappings : [ mapping ( mappingNameOf ( 'pull_legacy' ) , 'pull_legacy_order' ) ] ,
161+ jobs : [ pullJob ( LEGACY_BOUND , mappingNameOf ( 'pull_legacy' ) ) , pullJob ( LEGACY_UNBOUND , mappingTypo ( 'pull_legacy' ) ) ] ,
155162 } ,
156163 installedAt : '2026-01-01T00:00:00.000Z' ,
157164 installedBy : 'admin' ,
@@ -415,7 +422,7 @@ describe('install-local refuses an enabled job whose pull does not bind', () =>
415422 // The CLI names the code the runtime answered with.
416423 expect ( run . output ) . toMatch ( / I n s t a l l f a i l e d \( 4 2 2 V A L I D A T I O N _ E R R O R \) / ) ;
417424 expect ( run . output ) . toContain ( MISSING_JOB ) ;
418- expect ( run . output ) . toContain ( " pull.mapping: this artifact declares no mapping 'orders_pul'" ) ;
425+ expect ( run . output ) . toContain ( ` pull.mapping: this artifact declares no mapping '${ mappingTypo ( 'pull_missing' ) } '` ) ;
419426 expect ( run . output ) . toContain ( 'os validate' ) ;
420427 } ) ;
421428
@@ -424,7 +431,7 @@ describe('install-local refuses an enabled job whose pull does not bind', () =>
424431 expect ( run . exit , `${ run . output } ${ transcript ( 'install' ) } ` ) . toBe ( 1 ) ;
425432 expect ( run . output ) . toMatch ( / I n s t a l l f a i l e d \( 4 2 2 V A L I D A T I O N _ E R R O R \) / ) ;
426433 expect ( run . output ) . toContain ( NOSOURCE_JOB ) ;
427- expect ( run . output ) . toContain ( `mapping '${ MAPPING_NAME } ' declares no connectorSource` ) ;
434+ expect ( run . output ) . toContain ( `mapping '${ mappingNameOf ( 'pull_nosource' ) } ' declares no connectorSource` ) ;
428435 } ) ;
429436
430437 it ( 'a refused package leaves nothing behind: not in the ledger, and its job not scheduled' , ( ) => {
@@ -476,6 +483,6 @@ describe('rehydrate of an entry an earlier build installed, holding a pull job t
476483 const out = readings . output . restart ?? '' ;
477484 const line = out . split ( '\n' ) . find ( ( l ) => l . includes ( LEGACY_UNBOUND ) && l . includes ( 'NOT scheduled' ) ) ;
478485 expect ( line , `no warn names the withheld pull job${ transcript ( 'restart' ) } ` ) . toBeDefined ( ) ;
479- expect ( line ) . toContain ( " pull.mapping: this artifact declares no mapping 'orders_pul'" ) ;
486+ expect ( line ) . toContain ( ` pull.mapping: this artifact declares no mapping '${ mappingTypo ( 'pull_legacy' ) } '` ) ;
480487 } ) ;
481488} ) ;
0 commit comments