Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/35566-extension-publish-follow-door.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@objectstack/metadata-protocol': patch
---

fix(metadata-protocol): the per-item publish of an `object_extension` draft asks the record-currency follow door its published save asks

Clause-②: no
Metadata-protocol: none

`POST /api/v1/meta/object_extension/NAME/publish` (`publishMetaItem`) now asks the registry's record-currency follow door before it promotes an `object_extension` draft, with the same question the published save of that body asks (`PUT /api/v1/meta/object_extension/NAME`): the extension judged as its object will be served, in the slot of the package it is published into. A draft that adds a record-mode amount whose `currencyField` the served object cannot satisfy is refused `422 INVALID_METADATA` with the registry's sentence, the same one the published save answers, and the draft stays a draft. Two shapes reach it: a pointer naming no field of the object (`currencyField: 'zz_missing'`), and a `master_detail`-led pointer to a parent field that is missing or holds no ISO 4217 code (`invoice.title`).

Before, the publish answered `published`, promoted the draft and registered the amount. Every later write of it was then refused (`ERR_CURRENCY_CODE_REQUIRED`), or, for a pointer to a parent field holding no code, was stored with a value nobody declared as its currency. Nothing an author can save changes: the published save already refused these bodies, and a package publish (`publishPackageDrafts`) already refused them too. To publish such a draft, point `currencyField` at a field that holds the record's ISO 4217 code: a sibling text field declaring `valueDomain: 'iso_4217_currency'`, or `MASTER_DETAIL.CODE_FIELD` on the parent.
27 changes: 27 additions & 0 deletions packages/metadata-protocol/src/protocol-history-and-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import type { HistoryVersionOwner } from './sys-metadata-repository.js';
import { historySlotOf, refusePackageSelectorOutsideSlottedTypes } from './protocol-history-slots.js';
import { captureStoredExpressionChange, fillStoredExpressionChange, type StoredExpressionFillCapture } from './protocol-stored-expression-fill.js';
import { OBJECT_REGISTRY_REFUSED, reportObjectRegistryRefusal } from './protocol-registry-hydration.js';
import { OBJECT_EXTENSION_TYPE, registrableObjectExtension } from './protocol-object-extension-item.js';

/**
* [#32396] A promotion a package publish wrote: what {@link undoLandedPromotions}
Expand Down Expand Up @@ -1063,6 +1064,32 @@ export class ProtocolHistoryAndPublishFacet {
);
if (extensionRefusal) throw extensionRefusal;
}
// [ADR-0144 D2 and D6, amended; #33593 ruling R1] …and the follow
// door the published save of the same body asks (`saveMetaItem`, the
// R1 block beside its own `objectExtensionItemRefusal` call): the
// extension judged as its object will be served, with this body in the
// slot of the package promoted into. The per-item publish makes this
// one body live at once, as that save does; without the question it
// answered `published` for an amount whose `currencyField` the served
// object cannot satisfy — a pointer naming no field, or a
// `master_detail`-led path to a parent field holding no code — and
// every later write of the amount was refused, or stored a currency
// nobody declared. Asked with the save door's call and envelope
// (`422 INVALID_METADATA`, the registry's sentence), before
// `repo.promoteDraft` writes, so the draft stays a draft. Asked only on
// the against-registry question: a package publish judges its
// promoted unit before its commit (`registry-question.ts`). The
// registry answers no verdict for an object nothing serves yet, and
// none before the cold boot sealed it.
if (draftForGate && singularType === OBJECT_EXTENSION_TYPE
&& request.registryQuestion === 'against-registry' && promoteInto) {
const registry = host.engine?.registry as { objectRegistrationRefusal?: (schema: unknown, packageId: string | undefined, ownership: string, options: { againstRegistry?: boolean }) => Error | null } | undefined;
if (typeof registry?.objectRegistrationRefusal === 'function') {
const { extend, priority: _priority, ...contribution } = registrableObjectExtension(draftForGate.body);
const followRefusal = registry.objectRegistrationRefusal({ ...contribution, name: extend }, promoteInto, 'extend', { againstRegistry: true });
if (followRefusal) throw followRefusal;
}
}
// [harden] …and a permission-set draft whose name a DIFFERENT owner
// already holds by the time it is published: a draft save judged the
// holders of its moment, and another owner may have taken that name
Expand Down
Loading
Loading