@@ -45,7 +45,7 @@ import {
4545} from './packaged-base-regime.js' ;
4646import { SysMetadataRepository } from './sys-metadata-repository.js' ;
4747import { OBJECT_EXTENSION_TYPE } from './protocol-object-extension-item.js' ;
48- import { customizationPairEnsureRefusal , type PairRegistry } from './protocol-customization-package.js' ;
48+ import { customizationPairEnsureRefusal , kernelPackageScope , type PairRegistry } from './protocol-customization-package.js' ;
4949import { resolveOverlaySchema } from './protocol-meta-type-schema.js' ;
5050import { resolvePackageClosure } from '@objectstack/lint/runtime' ;
5151import { overlayMemberField , overlayMemberOfBody , overlayMemberValue } from './migrations/overlay-index.js' ;
@@ -263,9 +263,12 @@ export type PackagelessWriteOperation = 'save' | 'publish' | 'delete' | 'rollbac
263263 */
264264export function packagelessOverlayWriteRefusal (
265265 request : { type : string ; name : string } ,
266- closed : { base : string ; pair : string } ,
266+ closed : OverlayWriteClose ,
267267 operation : PackagelessWriteOperation ,
268268) : Error {
269+ if ( closed . kernelScope !== undefined ) {
270+ return kernelOverlayWriteRefusal ( request , closed . base , closed . kernelScope , 'packageless' , operation ) ;
271+ }
269272 const { item, shipped, pair, declared, writeInto, ceremony } = closedOverlayWriteClauses ( request , closed ) ;
270273 const rule = `A write naming no package is closed where ${ ceremony } can move its row `
271274 + `(ADR-0146 D11); a package-less row stored before it is served until that command moves it into '${ closed . pair } '.` ;
@@ -310,6 +313,37 @@ function closedOverlayWriteClauses(
310313 return { item, shipped, pair, declared, writeInto, ceremony, boundRowServed } ;
311314}
312315
316+ /**
317+ * [#29594, ruling record 6691217245] Both closes' refusal of a write onto an
318+ * item a kernel package ships ({@link OverlayWriteClose.kernelScope}). Kernel
319+ * objects are not customizable in this version and the kernel has no pair, so
320+ * the sentence names no pair and no fix: the write stays closed (ADR-0146 D11)
321+ * where it was closed before the kernel verdict, under the same
322+ * `403 NOT_OVERRIDABLE`, until a later version's kernel whitelist opens the
323+ * item. A row stored before the close stays served; a row bound to the base
324+ * is still removed by a delete naming it.
325+ */
326+ function kernelOverlayWriteRefusal (
327+ request : { type : string ; name : string } ,
328+ base : string ,
329+ kernelScope : string ,
330+ address : 'packageless' | 'named_base' ,
331+ operation : PackagelessWriteOperation ,
332+ ) : Error {
333+ const type = PLURAL_TO_SINGULAR [ request . type ] ?? request . type ;
334+ const item = `'${ type } /${ request . name } ' ships in kernel package '${ base } ' (scope '${ kernelScope } ')` ;
335+ const write = address === 'packageless'
336+ ? ( operation === 'delete' || operation === 'rollback'
337+ ? `a ${ operation } of its package-less row`
338+ : 'a write naming no package' )
339+ : ( operation === 'rollback' ? `a rollback of its row bound to '${ base } '` : `a write naming '${ base } '` ) ;
340+ const stored = address === 'packageless'
341+ ? 'A package-less row stored before the close stays served.'
342+ : `A row bound to '${ base } ' stored before the close stays served until a delete naming '${ base } ' removes it.` ;
343+ return closedOverlayWriteError ( `${ item } : kernel objects are not customizable in this version, so ${ write } is `
344+ + `refused (ADR-0146 D3, D11). ${ stored } ` ) ;
345+ }
346+
313347/** `403 NOT_OVERRIDABLE`, the code and status the sealed write already answers, so neither close gains a code. */
314348function closedOverlayWriteError ( message : string ) : Error {
315349 const err = new Error ( message ) ;
@@ -357,9 +391,12 @@ export type NamedBaseWriteOperation = Exclude<PackagelessWriteOperation, 'delete
357391 */
358392export function namedBaseOverlayWriteRefusal (
359393 request : { type : string ; name : string } ,
360- closed : { base : string ; pair : string } ,
394+ closed : OverlayWriteClose ,
361395 operation : NamedBaseWriteOperation ,
362396) : Error {
397+ if ( closed . kernelScope !== undefined ) {
398+ return kernelOverlayWriteRefusal ( request , closed . base , closed . kernelScope , 'named_base' , operation ) ;
399+ }
363400 const { item, shipped, pair, declared, writeInto, boundRowServed } = closedOverlayWriteClauses ( request , closed ) ;
364401 const message = operation === 'rollback'
365402 ? `${ item } ${ shipped } , and a rollback of its row bound to the read-only base is closed (ADR-0146 D1, D11): `
@@ -388,6 +425,27 @@ export interface OverlayPairFix {
388425 * about the write the fix takes.
389426 */
390427 readonly pendingPairScope ?: WrittenPackageScope ;
428+ /**
429+ * [#29594, ruling record 6691217245] The base's kernel scope (`system` /
430+ * `cloud`), present only for a kernel base. In this version a kernel
431+ * object is not customizable and the ensure door creates no pair for it,
432+ * so this fix cannot be taken: a close that reads it still refuses the
433+ * write, exactly where it refused it before that verdict, but with
434+ * {@link kernelOverlayWriteRefusal}'s sentence, which names no pair. The
435+ * kernel whitelist (a later version) is what reopens such a write.
436+ */
437+ readonly kernelScope ?: string ;
438+ }
439+
440+ /**
441+ * The subject an overlay-write close refuses ({@link packagelessOverlayWriteRefusal},
442+ * {@link namedBaseOverlayWriteRefusal}): the base, its pair, and — for a
443+ * kernel base — its kernel scope ({@link OverlayPairFix.kernelScope}).
444+ */
445+ export interface OverlayWriteClose {
446+ readonly base : string ;
447+ readonly pair : string ;
448+ readonly kernelScope ?: string ;
391449}
392450
393451/** A written package and the closure of its declared dependencies, as `resolveWritePackageScope` answers it. */
@@ -411,7 +469,10 @@ export type OverrideWriteVerdictAsk = (request: OverrideWriteSubject, writtenSco
411469 * - the base has a pair id ({@link pairOf}; an id ending in
412470 * `.custom` has none);
413471 * - the ensure door would answer or create the pair
414- * ({@link customizationPairEnsureRefusal});
472+ * ({@link customizationPairEnsureRefusal}), its kernel verdict left out:
473+ * [#29594] a kernel base answers a fix carrying its `kernelScope`, so
474+ * both closes keep refusing a kernel item where they did before that
475+ * verdict, naming no pair;
415476 * - the base records a version (`basedOn`, its `manifest.version`, the value
416477 * the ceremony records too).
417478 *
@@ -432,14 +493,17 @@ export function overlayPairFixOf(
432493 const pair = pairId . value ;
433494 const registry = ( host . engine as { registry ?: PairRegistry } | undefined ) ?. registry ;
434495 if ( ! registry || typeof registry . getPackage !== 'function' ) return null ;
435- if ( customizationPairEnsureRefusal ( host . engine , registry , base , pair ) !== undefined ) return null ; // the ensure door would refuse
496+ // The ensure door's other judgements; its kernel verdict is read below.
497+ if ( customizationPairEnsureRefusal ( host . engine , registry , base , pair , { judgeKernel : false } ) !== undefined ) return null ;
436498 const basedOn = registry . getPackage ( base ) ?. manifest ?. version ;
437499 if ( typeof basedOn !== 'string' || basedOn === '' ) return null ; // no `basedOn` to declare
438- if ( registry . getPackage ( pair ) ) return { base, pair, basedOn } ;
500+ const kernelScope = kernelPackageScope ( host . engine , base ) ;
501+ const kernel = kernelScope === undefined ? { } : { kernelScope } ;
502+ if ( registry . getPackage ( pair ) ) return { base, pair, basedOn, ...kernel } ;
439503 // The pair the ensure door would create: one dependency, the base.
440504 const baseClosure = resolvePackageClosure ( base , ( id ) => registry . getPackage ( id ) as { manifest ?: unknown } | undefined ) ;
441505 const dependencies = [ base , ...( baseClosure ?. dependencies ?? [ ] ) . filter ( ( id ) => id !== pair ) ] ;
442- return { base, pair, basedOn, pendingPairScope : { packageId : pair , dependencies } } ;
506+ return { base, pair, basedOn, pendingPairScope : { packageId : pair , dependencies } , ... kernel } ;
443507}
444508
445509/**
@@ -589,7 +653,7 @@ export interface NamedBaseWriteSubject {
589653export function namedBaseCloseSubject (
590654 this : NamedBaseCloseHost ,
591655 request : NamedBaseWriteSubject ,
592- ) : { base : string ; pair : string } | null {
656+ ) : OverlayWriteClose | null {
593657 const base = typeof request . packageId === 'string' && request . packageId . length > 0 ? request . packageId : undefined ;
594658 if ( base === undefined ) return null ; // the package-less write: #28576's close
595659 // A body carrying `overrides` keeps its answer: the D2 gate refuses a
@@ -607,7 +671,7 @@ export function namedBaseCloseSubject(
607671 ? overlayMemberOfBody ( type , written )
608672 : overlayMemberValue ( type , request . member ) ;
609673 if ( ! overlayPairFixAdmits ( this , fix , { type, name : request . name , body : written , member } ) ) return null ;
610- return { base, pair : fix . pair } ;
674+ return fix . kernelScope === undefined ? { base, pair : fix . pair } : { base , pair : fix . pair , kernelScope : fix . kernelScope } ;
611675}
612676
613677// ─────────────────────────────────────────────────────────────────────────
0 commit comments