@@ -453,6 +453,84 @@ export function findPublicFormIntakeGaps(args: {
453453 return issues ;
454454}
455455
456+ // ─────────────────────────────────────────────────────────────────────────────
457+ // #28448 — a tenant's copy of a packaged validation rule that changes what the
458+ // package owns.
459+ // ─────────────────────────────────────────────────────────────────────────────
460+
461+ /**
462+ * The rule id of the finding below. Refused on publish, inside the gate's one
463+ * 422 `INVALID_METADATA` envelope.
464+ *
465+ * [ADR-0029 D9.2a, 2026-10-30 note; ruling of record 6524229156, letter C′;
466+ * ruling of record 6545641964, letter B] A validation rule's identity within an
467+ * object is its `name`. A tenant's copy of a rule a code layer ships (the
468+ * packaged owner's or an extension's) may change its `message` and `active`;
469+ * its condition, its `type` and every other key belong to the package. The
470+ * registry fold already runs the package's rule and reports such a copy at load
471+ * (`validation_rule_copy_changed`), never refusing it there, so an upgrade never
472+ * fails on stored data. This is the other half: the save door refuses the copy
473+ * when the admin writes it, with the prescription.
474+ *
475+ * ## Why it is gate-local
476+ *
477+ * Its input is a fact about the DEPLOYMENT: which rules the code packages
478+ * registered here ship, by name. A build machine cannot know what a tenant's
479+ * copy is a copy of, so `AUTHORING_RULES` must not judge it — the reason the
480+ * #6285 and #26188 rules live here. The judgement itself is the registry's
481+ * (`SchemaRegistry.tenantRuleCopyRefusal`), the same predicate its load report
482+ * reads, so the save and the load judge one way; the host asks it and hands
483+ * the verdict in ({@link PackagedRuleCopyRefusal}), and this function stays
484+ * pure.
485+ */
486+ export const VALIDATION_RULE_COPY_CHANGED = 'validation-rule-copy-changed' ;
487+
488+ /** The prescription ruling C′ names, word for word. */
489+ const VALIDATION_RULE_COPY_PRESCRIPTION =
490+ 'To change the condition, add a rule under a new name, or change it in the package.' ;
491+
492+ /**
493+ * The registry's verdict on a tenant `object` body's rule copies, as the host
494+ * reads it from `SchemaRegistry.tenantRuleCopyRefusal`: the first copy that
495+ * changes a key the package owns, the keys it changes (`type` first) and the
496+ * registry's sentence. `null` when every copy changes at most `message` and
497+ * `active`, or no code layer ships a rule of any name the body carries.
498+ */
499+ export interface PackagedRuleCopyRefusal {
500+ ruleName : string ;
501+ changedKeys : readonly string [ ] ;
502+ message : string ;
503+ }
504+
505+ /**
506+ * Judge one about-to-be-published `object` body against the registry's verdict
507+ * on its rule copies: one `error` finding when the verdict refuses, located at
508+ * the copy's first changed key.
509+ *
510+ * PURE — the verdict arrives as an argument. Absent (a host whose engine has no
511+ * registry predicate, such as the CLI) nothing is judged.
512+ */
513+ export function findPackagedRuleCopyGaps ( args : {
514+ type : string ;
515+ name : string ;
516+ body : unknown ;
517+ packagedRuleCopyRefusal ?: PackagedRuleCopyRefusal | null ;
518+ } ) : RuntimeAuthoringIssue [ ] {
519+ if ( args . type !== 'object' || ! args . packagedRuleCopyRefusal ) return [ ] ;
520+ const { ruleName, changedKeys, message } = args . packagedRuleCopyRefusal ;
521+ const rules = isRec ( args . body ) && Array . isArray ( args . body . validations ) ? args . body . validations : [ ] ;
522+ const index = rules . findIndex ( ( rule ) => isRec ( rule ) && rule . name === ruleName ) ;
523+ const rulePath = index >= 0 ? `validations[${ index } ]` : 'validations' ;
524+ return [ {
525+ severity : 'error' ,
526+ rule : VALIDATION_RULE_COPY_CHANGED ,
527+ where : `object "${ args . name } " · validation rule "${ ruleName } "` ,
528+ path : changedKeys . length > 0 && index >= 0 ? `${ rulePath } .${ changedKeys [ 0 ] } ` : rulePath ,
529+ message,
530+ hint : VALIDATION_RULE_COPY_PRESCRIPTION ,
531+ } ] ;
532+ }
533+
456534// ─────────────────────────────────────────────────────────────────────────────
457535// #26188 — a HIERARCHY scope on a runtime with no hierarchy resolver.
458536// ─────────────────────────────────────────────────────────────────────────────
@@ -1118,6 +1196,15 @@ export function evaluateRuntimeAuthoringGate(args: {
11181196 * service registry), nothing is judged, as on the CLI.
11191197 */
11201198 hierarchyResolverMounted ?: boolean ;
1199+ /**
1200+ * [#28448] The registry's verdict on an `object` body's copies of packaged
1201+ * validation rules ({@link PackagedRuleCopyRefusal}). A fact only the host
1202+ * holds, of the #6285 kind: gathered by the impure caller and passed in so
1203+ * this function stays pure. A verdict arms {@link findPackagedRuleCopyGaps};
1204+ * `null` is a clean verdict; absent (a host whose engine has no registry
1205+ * predicate), nothing is judged.
1206+ */
1207+ packagedRuleCopyRefusal ?: PackagedRuleCopyRefusal | null ;
11211208} ) : RuntimeAuthoringVerdict {
11221209 // [#26188] The one finding a draft hears: a hierarchy scope this runtime
11231210 // cannot enforce. Same rule as the publish refusal below, `warning` here.
@@ -1204,8 +1291,19 @@ export function evaluateRuntimeAuthoringGate(args: {
12041291 ? { tenancyPostureInForce : args . tenancyPostureInForce }
12051292 : { } ) ,
12061293 } ) ;
1294+ // [#28448] The gate-local refusal of a tenant's rule copy that changes what
1295+ // the package owns — the registry's verdict, located on the body.
1296+ const packagedRuleCopyGaps = findPackagedRuleCopyGaps ( {
1297+ type : args . type ,
1298+ name : args . name ,
1299+ body : args . body ,
1300+ ...( args . packagedRuleCopyRefusal !== undefined
1301+ ? { packagedRuleCopyRefusal : args . packagedRuleCopyRefusal }
1302+ : { } ) ,
1303+ } ) ;
12071304 const localIssues = [
12081305 ...scheduleOrgGaps ,
1306+ ...packagedRuleCopyGaps ,
12091307 ...hierarchyScopeGaps ,
12101308 ...( pageSourceFindings ?? [ ] ) . filter ( ( f ) => f . severity === 'error' ) . map ( toIssue ) ,
12111309 ] ;
@@ -1272,6 +1370,7 @@ export function evaluateRuntimeAuthoringGate(args: {
12721370 ? [ HIERARCHY_SCOPE_CAPABILITY_REQUIRED ]
12731371 : [ ] ) ,
12741372 ...( pageSourceFindings !== null ? [ HTML_PAGE_SOURCE_COMPILE , PAGE_REQUIRES_DISAGREES_WITH_SOURCE ] : [ ] ) ,
1373+ ...( args . type === 'object' && args . packagedRuleCopyRefusal !== undefined ? [ VALIDATION_RULE_COPY_CHANGED ] : [ ] ) ,
12751374 ] ;
12761375
12771376 if ( unlintedWritesAllowed ( ) ) {
0 commit comments