Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
'@objectstack/metadata-protocol': minor
'@objectstack/spec': minor
Expand Down Expand Up @@ -25,4 +25,4 @@

The refusal's message starts with the fix ("Enable the package that holds …") and names no package. Once a holder is enabled again the read naming no package serves the package-less row as it was stored, and the same writes answer as before the disable.

Not moved: an item the ADR-0146 D11 close covers (one read-only code package ships it, with a pair, and `os migrate packageless-overlays` would move its package-less row) keeps that close's answer for the save, the draft save and the delete naming no package, `403 NOT_OVERRIDABLE` with that close's own remedy, with the package enabled or disabled; there only the draft discard moves, from `200` to the `409` above. Also not moved: a name no package holds (the environment's own item) saves, drafts, discards and deletes as before beside a disabled package; a package-less row at a name an enabled package holds; a name only disabled packages hold with no package-less row or draft stored, which keeps its `409` with the `?package=` remedy; the sealed types (`doc`, `action`), which answer `403 NOT_OVERRIDABLE` as before; every read. Migration entry `disabled-holder-package-less-row-bare-write-refused` (`@objectstack/spec`) carries the same fix for the upgrade guide.
Not moved: an item the ADR-0146 D11 close covers (one read-only code package ships it, with a pair, and `os migrate packageless-overlays` would move its package-less row) keeps that close's answer for the save, the draft save and the delete naming no package, `403 NOT_OVERRIDABLE` with that close's own remedy, with the package enabled or disabled; there only the draft discard moves: over a stored package-less draft from `200` to the `409` above, and over a stored package-less row with no draft from the `409` with the `?package=` sentence to the same `409` with the enable sentence. Also not moved: a name no package holds (the environment's own item) saves, drafts, discards and deletes as before beside a disabled package; a package-less row at a name an enabled package holds; a name only disabled packages hold with no package-less row or draft stored, which keeps its `409` with the `?package=` remedy; the sealed types (`doc`, `action`), which answer `403 NOT_OVERRIDABLE` as before; every read. Migration entry `disabled-holder-package-less-row-bare-write-refused` (`@objectstack/spec`) carries the same fix for the upgrade guide.
26 changes: 26 additions & 0 deletions .changeset/37608-disabled-holder-publish-rollback-refused.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'@objectstack/metadata-protocol': minor
'@objectstack/spec': minor
---

fix(metadata-protocol)!: refuse the per-item publish and rollback naming no package over the package-less row of a name only disabled packages hold

Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — no page under `skills/**` or `content/docs/**` teaches a per-item publish or rollback naming no package over a name only disabled packages hold; the refusal's own sentence names the fix

<!-- adr-0087: not-required (already-registered disabled-holder-package-less-row-bare-write-refused) the entry the four other writes of this narrowing registered now names the per-item publish and rollback too -->

**BREAKING** for a deployment that publishes or rolls back one metadata item, with no package named, at a name whose every holder is disabled while a package-less row or draft is stored for it: the write is now refused where it answered `200`. Fix: enable a package that holds the name (`PATCH /api/v1/packages/:id/enable`; `GET /api/v1/packages` shows which are disabled), then send the same publish or rollback again. Naming the package (`?package=`) is not the fix: it addresses that package's own row and leaves the hidden row where it is.

The save, the draft save, the delete and the draft discard naming no package already refuse there (ADR-0150 D3, its 2026-11-26 note): a package-less row stored at a name a package holds is that package's customization, hidden with it. The per-item publish and the per-item rollback did not ask that judgment, so a publish promoted a package-less draft into the hidden row and a rollback rewrote it, and enabling the package again served a body no read had shown.

Every moved answer, before → after, for a type the registry reads by package, while every holder of the name is disabled, where the ADR-0146 D11 close leaves the package-less write open (a base with no pair, a member the package never ships, a holder that is not a read-only code package, among the cells that close lists):

- `POST /api/v1/meta/:type/:name/publish` whose draft address is the package-less draft (beside a package-less row or with none stored): `200` (the package-less draft promoted into the hidden package-less row, or, beside the disabled package's own active row, adopted into that row) → `409 RESOURCE_CONFLICT`, nothing written.
- `POST /api/v1/meta/:type/:name/rollback` with a package-less row stored: `200` (the hidden row rewritten to the version's body) → `409 RESOURCE_CONFLICT`, nothing written.
- The same two through the in-process `publishMetaItem` / `rollbackMetaItem` with no `packageId`.

The refusal's message is the one the save and the delete answer there: it starts with the fix ("Enable the package that holds …"), names no package, and says "send this publish again" or "send this rollback again". Once a holder is enabled again the read naming no package serves the package-less row as it was stored, and the same publish or rollback answers as before the disable.

Not moved: an item the ADR-0146 D11 close covers keeps that close's `403 NOT_OVERRIDABLE` for the publish and the rollback naming no package, with the package enabled or disabled; a publish or rollback naming a package; a publish with no draft at its address, which keeps its `404 NO_DRAFT`; a rollback of a package-bound row; two writes that still land on an item only disabled packages hold, left open for a separate decision (#37851): a publish whose draft address is the disabled package's own draft, promoted into that package's own row (beside a package-less row or not), and a rollback with no package-less row stored, which stores the package-less row again from its history; a name no package holds; a name an enabled package holds; every read. Migration entry `disabled-holder-package-less-row-bare-write-refused` (`@objectstack/spec`), which already carried the four other writes, now carries these two for the upgrade guide.
23 changes: 22 additions & 1 deletion packages/metadata-protocol/src/protocol-history-and-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import type { MutationProjectionOutcome } from './protocol-mutation-events.js';
import { PREFLIGHT_AUDIT_CODE, withPendingAudit } from './protocol-audit-entry.js';
import type { PublishMetaItemRequest } from './protocol-door-requests.js';
import { withRefusalAudit } from './protocol-refusal-audit.js';
import { environmentActionPublishSlotRefusal, packagelessRowHeldBaseAddress } from './protocol-save.js';
import { environmentActionPublishSlotRefusal, packagelessHolderRefusal, packagelessRowHeldBaseAddress } from './protocol-save.js';
import { overlayMemberWhere } from './migrations/overlay-index.js';
import { isMissingTableError } from '@objectstack/metadata/errors';
import { readPublishBackfillRequest } from './protocol-publish-backfill-request.js';
Expand Down Expand Up @@ -876,6 +876,27 @@ export class ProtocolHistoryAndPublishFacet {
if (address.kind === 'none' && address.into !== null && others.length > 0) {
addressRefusal = packagelessPublishNoDraftRefusal(request.type, request.name, address.into, others);
}
// [ADR-0150 D3, the 2026-11-26 note] …and the holders, where
// the promotion reads the package-unbound draft or writes the
// package-unbound active row, as the draft save naming no
// package judges them ({@link packagelessHolderRefusal}, its
// disabled-holders judgment only): of a name only disabled
// packages hold, that draft and that row are their
// customization, hidden with them, and the promotion wrote the
// active row the next enable serves. Refused with the enable
// as the remedy, nothing written. A promotion of a package's
// own draft into its own row (`key` and `into` that package)
// touches no package-less row and is not asked; nor is a
// publish with no draft, which keeps its `NO_DRAFT`.
if (addressRefusal === undefined && address.kind === 'draft' && (address.key === null || address.into === null)) {
const active = await host.packagelessAddress(singularType, request.name, request.member, 'active');
if (active.unbound || address.drafts.unbound) {
addressRefusal = packagelessHolderRefusal(host, 'publish', request.type, singularType, request.name, request.member, {
candidates: [...new Set([...active.candidates, ...address.drafts.candidates])],
unbound: true,
}, 'disabled-holders');
}
}
}
}
// ADR-0010 L3 — lock blocks publish too (publishing is a write).
Expand Down
18 changes: 18 additions & 0 deletions packages/metadata-protocol/src/protocol-package-commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import {
import { isNonCanonicalStoredType } from './protocol-stored-overlay-types.js';
import type { RollbackMetaItemRequest } from './protocol-door-requests.js';
import { historySlotOf, refusePackageSelectorOutsideSlottedTypes } from './protocol-history-slots.js';
import { packagelessHolderRefusal } from './protocol-save.js';
import { withRefusalAudit } from './protocol-refusal-audit.js';
import type { ProtocolHost } from './protocol-host.js';
import type { ImportUnmanagedPackageAnswer, InstallPackageStoredRowHook, StoredPackageRow } from './protocol-package-install.js';
Expand Down Expand Up @@ -2236,6 +2237,23 @@ export class ProtocolPackageCommitsFacet {
);
if (namedBase) throw namedBase;
}
// [ADR-0150 D3, the 2026-11-26 note] A rollback naming no package
// that restores the package-unbound row of a name only disabled
// packages hold rewrote their customization, hidden with them, so the
// next enable served the restored body. It asks the judgment the
// save and the delete ask ({@link packagelessHolderRefusal}, its
// disabled-holders judgment only), after the D11 close above, and is
// refused with the enable as the remedy, nothing written.
if (request.packageId === undefined && rollbackPackageId === null) {
const active = await host.packagelessAddress(singularType, request.name, member, 'active');
if (active.unbound) {
const holderRefusal = packagelessHolderRefusal(
host, 'rollback', request.type, singularType, request.name, member,
{ candidates: active.candidates, unbound: true }, 'disabled-holders',
);
if (holderRefusal) throw holderRefusal;
}
}
// [ADR-0146 D2] A rollback of the base's paired `.custom` row is the
// pair's declared override, as its save is: it edits no managed item,
// so the store is told a runtime-only write — never judged an artifact
Expand Down
40 changes: 30 additions & 10 deletions packages/metadata-protocol/src/protocol-save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3263,6 +3263,15 @@ export async function environmentActionPublishSlotRefusal(
return undefined;
}

/**
* The writes naming no package that ask the disabled-holders judgment
* ({@link packagelessHolderRefusal}): the save (publish and draft mode), the
* delete and the draft discard, and [ADR-0150 D3, the 2026-11-26 note] the
* per-item publish and the per-item rollback. Every verb but `delete` writes a
* row, so its refusal says nothing was written.
*/
export type DisabledHoldersWriteVerb = 'save' | 'delete' | 'publish' | 'rollback';

/**
* [ADR-0150 D3, ruling A on the disabled-only name] The refusal of a write
* naming no package of a name every holder of which is disabled. A disabled
Expand All @@ -3272,11 +3281,11 @@ export async function environmentActionPublishSlotRefusal(
* {@link packagelessAddressAmbiguityRefusal}, with no new code.
*/
export function disabledHoldersOnlyRefusal(
verb: 'save' | 'delete',
verb: DisabledHoldersWriteVerb,
type: string,
name: string,
): Error & { code: 'RESOURCE_CONFLICT'; status: 409 } {
const [nothing, single] = verb === 'save'
const [nothing, single] = verb !== 'delete'
? ['Nothing was written.', 'no row to write']
: ['Nothing was deleted.', 'no row to remove'];
const err = new Error(
Expand All @@ -3294,10 +3303,11 @@ export function disabledHoldersOnlyRefusal(
* no package of a name every holder of which is disabled, where a
* PACKAGE-UNBOUND row or draft is stored for the name. That row is the
* holder's customization (a package-less row over a held name is never a
* second item), so it is hidden with its holder, from the reads and from the
* writes alike: the save edited it unseen, the draft save stored a draft no
* read reaches, and the delete and the draft discard removed what the next
* enable would have served.
* second item), so it is hidden with its holder: the reads withhold it, and
* the writes naming no package that ask {@link packagelessHolderRefusal} leave
* it alone. The save edited it unseen, the draft save stored a draft no read
* reaches, the delete and the draft discard removed what the next enable
* would have served, and the per-item publish and rollback rewrote it.
*
* `409 RESOURCE_CONFLICT`, the refusal family of
* {@link disabledHoldersOnlyRefusal}, with no new code, and naming no package
Expand All @@ -3306,11 +3316,11 @@ export function disabledHoldersOnlyRefusal(
* hidden row where it is and stores a second row beside it.
*/
export function disabledHoldersCustomizationRefusal(
verb: 'save' | 'delete',
verb: DisabledHoldersWriteVerb,
type: string,
name: string,
): Error & { code: 'RESOURCE_CONFLICT'; status: 409 } {
const nothing = verb === 'save' ? 'Nothing was written.' : 'Nothing was deleted.';
const nothing = verb !== 'delete' ? 'Nothing was written.' : 'Nothing was deleted.';
// Kept well under the 500 characters a door's client message is cut at
// (`truncateClientMessage`), so the remedy's last sentence arrives.
const err = new Error(
Expand Down Expand Up @@ -3476,6 +3486,9 @@ export async function packagelessRowHeldBaseDraftAddress(
* bare draft discard answer as the bare read does in the two states below,
* whether or not a row is stored at the address (over none, the delete and
* the discard are refused too, not answered the no-op receipt).
* [ADR-0150 D3, the 2026-11-26 note] The bare per-item publish and the bare
* per-item rollback ask the second state only (`arms: 'disabled-holders'`),
* after the ADR-0146 D11 close, so they write nothing a disabled holder hides.
* Asked after {@link servedPackagelessSaveAddress} (a name an enabled and a
* disabled package both hold) and after the rows' own refusal (two or more
* bindings), so neither answer moves.
Expand Down Expand Up @@ -3513,7 +3526,7 @@ export async function packagelessRowHeldBaseDraftAddress(
*/
export function packagelessHolderRefusal(
host: Pick<ProtocolHost, 'engine' | 'shippedArtifactsOf'>,
verb: 'save' | 'delete',
verb: DisabledHoldersWriteVerb,
shownType: string,
type: string,
name: string,
Expand All @@ -3529,6 +3542,13 @@ export function packagelessHolderRefusal(
*/
readonly customized?: boolean;
},
/**
* `'disabled-holders'`: the disabled-holders judgment only, never the
* two-enabled-holders refusal. The per-item publish and rollback ask it
* so (ADR-0150 D3, the 2026-11-26 note); each has its own refusal of
* two holders' rows (`packagelessAddressAmbiguityRefusal`, `historySlotOf`).
*/
arms: 'all' | 'disabled-holders' = 'all',
): (Error & { code: 'RESOURCE_CONFLICT'; status: 409 }) | undefined {
const registry = host.engine?.registry as HolderRegistry | undefined;
if (typeof registry?.readsByPackage !== 'function' || registry.readsByPackage(type) !== true) return undefined;
Expand All @@ -3538,7 +3558,7 @@ export function packagelessHolderRefusal(
// A package-unbound row at the address leaves the ENABLED holders' answer
// as it was (the write edits that row); only the disabled-holders
// judgment below reads past it.
if (!address.unbound && typeof registry.resolveItem === 'function') {
if (arms === 'all' && verb !== 'rollback' && !address.unbound && typeof registry.resolveItem === 'function') {
try {
registry.resolveItem(type, name, null, member);
} catch (error) {
Expand Down
Loading
Loading