Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9d7be15
fix(metadata-protocol): the read naming no package withholds a packag…
claude Nov 15, 2026
5488f48
fix(metadata-protocol): `_env` answers 404 for a name only disabled p…
claude Nov 15, 2026
0097f7f
test(objectql): the hydrated package-less row is a moved cell, not a …
claude Nov 15, 2026
71880ce
chore(changeset): metadata-protocol patch for the disabled-holder `_e…
claude Nov 15, 2026
4fe4ea4
fix(metadata-protocol,rest,runtime): `_env` keeps the refusal when a …
claude Nov 15, 2026
b21cdf1
test(rest,runtime): name the types whose by-name read serves the row-…
claude Nov 15, 2026
74b5505
Merge remote-tracking branch 'origin/main' into claude/area-E1b-33385
claude Nov 15, 2026
6665c85
chore(changeset): rest and runtime patch for the `_env` admission
claude Nov 15, 2026
b5ea0f6
chore(changeset): declare the withhold as a narrowing with its BREAKI…
claude Nov 15, 2026
00d7daf
test(rest,runtime): the qualified-read engine doubles keep findOne as…
claude Nov 15, 2026
4c28847
chore(changeset): declare the direction arm as no (narrowing)
claude Nov 15, 2026
e5bf5bb
fix(rest,runtime): `_env` admits a marked refusal only for the read t…
claude Nov 15, 2026
386c240
fix(rest): the import door's `_env/NAME` admits a name only disabled …
claude Nov 15, 2026
6b2dafe
docs(import-mappings): a mapping only disabled packages hold answers …
claude Nov 15, 2026
7b65fff
test(rest,runtime): type the draft reads of the `_env` draft-switch C…
claude Nov 15, 2026
e6b91bd
fix(rest,runtime): `_env` judges the draft switches as the caller is …
claude Nov 15, 2026
d86adb4
fix(rest): hand the qualified route its resolveExecCtx in the shape e…
claude Nov 15, 2026
69f4887
fix(metadata-protocol): judge the package-less withhold over the acti…
claude Nov 15, 2026
4ccf153
Merge remote-tracking branch 'origin/main' into claude/area-E1b-33385
claude Nov 16, 2026
0f5f95d
test(objectql): pin the package-less action on another object and on …
claude Nov 16, 2026
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
25 changes: 25 additions & 0 deletions .changeset/33385-disabled-holders-env-404.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
'@objectstack/metadata-protocol': patch
'@objectstack/rest': patch
'@objectstack/runtime': patch
---

fix(metadata-protocol,rest,runtime)!: a name only disabled packages hold answers 404 at `_env`, and an environment customization of such a name is hidden until a holder is enabled again (ADR-0150 D3, D4)

Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: updated here — content/docs/data-modeling/import-mappings.mdx (no `skills/**` file teaches an `_env` answer)

<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export changes shape. The moved answers are by-name reads under a reversible package state: no stored row is changed or deleted, so there is nothing for a migration to rewrite and no tombstone. -->

**BREAKING** for a read of an environment customization of a name whose every holding package is disabled. Such a customization is a row saved without a package, for a name an installed package holds. It belongs to that package (ADR-0150 D4), and a disabled package holds no name (ADR-0150 D3).

- **The read that names no package (`GET /meta/:type/:name`, and the execution read).** When every package holding the name is disabled, this read now answers as if the customization were not saved: `404`, where it served the row. That includes a translation the package never shipped, such as an email template's `fr-FR` that only the environment wrote. A customization at a member the package ships was already hidden.
- **The list and the execution list (`GET /meta/:type`).** They now leave out the same customization, so they agree with the read of the name: while every package holding the name is disabled, neither list carries any item of it. Enable a holder again and both list it again.
- **A save or delete naming no package while every holder is disabled.** A save at a member the package never ships is accepted and kept, as before, but it is now hidden from the reads above until a holder is enabled again. A delete of it still removes the row. A save at a member the package ships is still refused `403 NOT_OVERRIDABLE`.
- **`GET /meta/:type/_env/:name`.** When every package holding the name is disabled, the environment address now answers `404`, as for a name no package holds, on both the REST server and the runtime dispatcher. It used to refuse `409 RESOURCE_CONFLICT` naming the disabled packages. It still refuses `409` in three cases: an enabled package holds the name; a package holds it through a saved metadata row that the read of the name serves; or the read carries `?state=draft`, `?preview=draft` or `?layers=`, which read other rows than the plain read. That `409` names only the disabled package the registry holds the name for, as before; it does not name an enabled package that holds the name through a saved row. On a composition whose metadata engine has no package-scoped resolver for the type (its registry lacks the by-name reads), `_env` of a name only disabled packages hold now answers `501 NOT_IMPLEMENTED`, the refusal of a read that engine cannot judge, where it answered `409`. Refusal to refusal; no production composition lacks those reads.
- **The import door's `mappingName: "_env/NAME"`.** The same move, as `GET /meta/mapping/_env/NAME` answers it: `404 MAPPING_NOT_FOUND`, naming no package, where it was refused `409` naming the disabled package.

**Not moved.** With an enabled holder, every answer is unchanged. That includes an enabled package that holds the name only through a saved row the registry has not read yet: the customization is still served and listed, whether the list or the read of the name comes first. A customization of a name no installed package holds is the environment's own item and is still served.

**No migration.** Nothing is deleted or rewritten. Enable the package again and the customization is served again, unchanged. The fix for a caller who needs the row while the package is disabled is to re-enable the package.
9 changes: 6 additions & 3 deletions content/docs/data-modeling/import-mappings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ address `GET /api/v1/meta/mapping/<namespace>/<name>` reads, and the import door
the same way (ADR-0150 D5). The import applies exactly that holder's mapping. When that
namespace, or the environment, holds no mapping of the name and a package does, the
import is refused with the `409 RESOURCE_CONFLICT` that read answers, naming every holder,
and no row is written. A first segment that is neither `_env` nor an installed namespace
and no row is written. A disabled package holds no name: when every package that holds the
name is disabled, `"_env/<name>"` answers `404 MAPPING_NOT_FOUND`, naming no package, as
`GET /api/v1/meta/mapping/_env/<name>` answers `404`. Enable a holder again and the address
is refused with the `409` naming it, as before. A first segment that is neither `_env` nor an installed namespace
is no address: the whole string is read as the name, which no mapping has, so the import
answers `404 MAPPING_NOT_FOUND`. Two limits come with the metadata read's address. Where
two packages that share a namespace (`base`, `system`, `sys`) both hold the name, the
Expand Down Expand Up @@ -274,8 +277,8 @@ These are whole-request failures — nothing is written, and there is no per-row

| Status | `code` | Cause |
|:---|:---|:---|
| 404 | `MAPPING_NOT_FOUND` | No mapping artifact is registered under that name. |
| 409 | `RESOURCE_CONFLICT` | Two or more packages hold a mapping under that name, and the environment holds none; or a qualified `mappingName` (`<namespace>/<name>`, `_env/<name>`) names a holder that holds no mapping of that name while another does. The error names every holder. |
| 404 | `MAPPING_NOT_FOUND` | No mapping artifact is registered under that name, or every package that holds it is disabled. |
| 409 | `RESOURCE_CONFLICT` | Two or more packages hold a mapping under that name, and the environment holds none; or a qualified `mappingName` (`<namespace>/<name>`, `_env/<name>`) names a holder that holds no mapping of that name while another, enabled, package does. The error names every holder. |
| 400 | `MAPPING_TARGET_MISMATCH` | The artifact's `targetObject` is not the object in the URL. |
| 400 | `MAPPING_FORMAT_UNSUPPORTED` | The artifact declares `sourceFormat: 'xml'` or `'sql'`; the endpoint accepts csv, json and xlsx payloads only. |
| 400 | `MAPPING_FORMAT_MISMATCH` | The declared `sourceFormat` contradicts the payload actually sent. A `csv` mapping does apply to an `xlsx` payload — those rows are tabular in the same way — but a `json` mapping does not. |
Expand Down
38 changes: 35 additions & 3 deletions packages/metadata-protocol/src/protocol-exact-qualifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,8 @@ export function resolveMetaItemAddress(
* environment does not hold and a package does is refused
* (`not-held-by-qualifier`, `callerPackageId: null`); otherwise the read is a
* caller with no package, which E8's resolver answers environment-first.
* [#33385] A name only disabled packages hold is refused with a mark the
* doors read ({@link DISABLED_HOLDERS_ONLY_REFUSAL}).
* Types outside the covered set keep the bare read, as `?package=` does for
* them.
*
Expand All @@ -972,8 +974,10 @@ export function admitEnvironmentQualifier(
}
// [#32183, epic ruling R4-B2] The served holders, or every holder when no
// package serves the name: a name only disabled packages hold is refused
// naming them, as before, never read as a caller with no package (that
// read can reach a disabled holder's customization pair row).
// naming them here, never admitted on the registry's word alone. The
// registry does not see a package holding the name only through a stored
// row it has not hydrated, so a read admitted here could serve that
// package's row at the environment's address.
const served = registry.packageScopedHoldersOf(request.type, request.name) ?? [];
const holders = served.length > 0
? served
Expand All @@ -982,6 +986,11 @@ export function admitEnvironmentQualifier(
refuseUnjudgeableByNameRead(host, request, { kind: 'environment' });
return;
}
// [#33385, #32183 row 17] …but marked ({@link DISABLED_HOLDERS_ONLY_REFUSAL}),
// once the read it would admit is judgeable: each door then asks the read
// naming no package, which judges the stored rows too, and answers the
// name as no package's (its 404) when that read withholds it.
if (served.length === 0) refuseUnjudgeableByNameRead(host, request, { kind: 'environment' });
const candidates: PackageScopedHolder[] = holders.map((holder) => ({ kind: 'package' as const, packageId: holder }));
const base = {
status: 'refused' as const,
Expand All @@ -991,5 +1000,28 @@ export function admitEnvironmentQualifier(
callerPackageId: null,
candidates,
};
throw new PackageScopedNameRefusedError({ ...base, message: packageScopedRefusalMessage(base) });
const error = new PackageScopedNameRefusedError({ ...base, message: packageScopedRefusalMessage(base) });
if (served.length === 0) Object.defineProperty(error, DISABLED_HOLDERS_ONLY_REFUSAL, { value: true });
throw error;
}

/**
* [#33385, #32183 row 17 (ruling R4-B2 on PR #32497)] The marker
* {@link admitEnvironmentQualifier} sets on its refusal of a name only
* disabled packages hold, a registered symbol (so every copy of this package
* reads the same key, and no envelope serializes it). The `_env` doors of
* `RestServer` and the runtime dispatcher read it by the same `Symbol.for`
* key (`RestServer` reaches the protocol only as a service, as with the item
* face's `storedRowHoldersRefusal` marker), and answer it in two steps,
* because only an asynchronous read sees a package that holds the name
* through a stored row alone:
*
* - the read naming no package (`getMetaItem`) withholds the name (no item):
* no package serves it, a disabled package holds no name, and the item face
* withholds every customization of its holders (the pair's row, #32814; a
* package-less row of their key, #33401). The door admits `_env` and its
* read answers 404, naming no package;
* - that read serves an item, or refuses: a package holds the name through
* its stored row, so the refusal stands, as before.
*/
const DISABLED_HOLDERS_ONLY_REFUSAL: unique symbol = Symbol.for('objectstack.metadata-protocol.disabledHoldersOnlyRefusal') as never;
100 changes: 99 additions & 1 deletion packages/metadata-protocol/src/protocol-meta-item-face.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,94 @@ function isHoldersPairRow(engine: unknown, type: string, name: string, item: unk
return every.some((holder) => pairsOf(holder, installed).includes(stamp));
}

/**
* [#33401, ADR-0150 D4] The package a package-less row (stamped with no
* package, `''` or the `sys_metadata` sentinel) that the read naming no
* package reached is withheld with: the holder whose key the row customizes,
* when every holder of that key is disabled. Seat ruling 6882483833 on
* #32814: a package-less row whose key (`(type, name)`; `(object, name)` for
* an `action`) an installed package holds is that holder's overlay, owned
* over every holder, disabled included (epic ruling 6816940784 on #31699), so
* with every holder disabled the read answers as if no row were stored. The
* member is not part of the key: a locale the holder never shipped is still
* its customization.
*
* The key's holders are the registry's one owner rule
* (`overlayRowBinding`, every holder counted): `null` is the environment's
* own item (D3 (a), no holder at its key, a same-name action on another
* object included), served; one holder is withheld when it is disabled; two
* or more are judged as the name's holders are ({@link disabledOnlyHolderOf}).
* The row itself is untouched, so it is served again on re-enable.
* `undefined` when the item is not such a row, or the registry cannot bind
* one (optional-called: such a registry hides nothing more).
*/
function packagelessRowWithheldHolder(registry: any, type: string, name: string, item: unknown): string | undefined {
const stamp = (item as { _packageId?: unknown } | null | undefined)?._packageId;
if (stamp !== undefined && stamp !== null && stamp !== '' && stamp !== 'sys_metadata') return undefined;
if (typeof registry?.overlayRowBinding !== 'function' || typeof registry?.isPackageDisabled !== 'function') return undefined;
const holder: unknown = registry.overlayRowBinding(type, name, item, { includeDisabledPackages: true });
if (holder === null) return undefined;
if (typeof holder === 'string') return registry.isPackageDisabled(holder) === true ? holder : undefined;
return disabledOnlyHolderOf(registry, type, name);
}

/**
* [#33401, review#2 S5] Whether an enabled package holds `(type, name)`
* through a stored active row the reads serve: a row bound to an enabled
* package that the reads do not decline (`declinesStoredRow`) and that is no
* holder's customization pair row (a pair row is that holder's item, never a
* holder of its own). The registry's owner rule does not see such a row
* until it is hydrated, so {@link packagelessRowWithheldHolder} alone would
* withhold a package-less row while an enabled package holds the name, and
* the answer would follow hydration order.
*/
function enabledRowHolds(
host: Pick<ServedRowHost, 'engine' | 'declinesStoredRow'>,
type: string, name: string,
rows: ReadonlyArray<Awaited<ReturnType<ServedRowHost['readItemActiveRows']>>[number]>,
): boolean {
const registry: any = host.engine?.registry;
const every: readonly string[] = registry?.packageScopedHoldersOf?.(type, name, null, { includeDisabledPackages: true }) ?? [];
const installed = installedManifestsOfEngine(host.engine);
return rows.some((row) => {
const bound = typeof row.package_id === 'string' && row.package_id !== '' && row.package_id !== 'sys_metadata'
? row.package_id : undefined;
return bound !== undefined && registry?.isPackageDisabled?.(bound) !== true
&& !host.declinesStoredRow(type, name, row)
&& !every.some((holder) => pairsOf(holder, installed).includes(bound));
});
}

/**
* [#33401] The holder a package-less `item` of `(type, name)` is withheld
* with ({@link packagelessRowWithheldHolder}), unless an enabled package
* holds the name through a stored active row ({@link enabledRowHolds},
* review#2 S5): then the answer is `main`'s, whichever order the rows were
* hydrated in. `rows` are the item's active rows when the caller already
* read them; otherwise they are read here, only once the registry would
* withhold the item. The read naming no package and the list naming no
* package (`protocol-meta-list-reads.ts`) both ask this, so the list carries
* no row the by-name read withholds.
*/
export async function packagelessRowWithheld(
host: Pick<ServedRowHost, 'engine' | 'declinesStoredRow' | 'readItemActiveRows' | 'rethrowUnlessMetadataStoreUnprovisioned'>,
type: string, name: string, item: unknown,
rows?: ReadonlyArray<Awaited<ReturnType<ServedRowHost['readItemActiveRows']>>[number]>,
): Promise<string | undefined> {
const holder = packagelessRowWithheldHolder(host.engine?.registry, type, name, item);
if (holder === undefined) return undefined;
let active: ReadonlyArray<Awaited<ReturnType<ServedRowHost['readItemActiveRows']>>[number]> | undefined = rows;
if (active === undefined) {
try {
active = await host.readItemActiveRows(type, name);
} catch (error) {
host.rethrowUnlessMetadataStoreUnprovisioned(error, 'sys_metadata');
active = [];
}
}
return enabledRowHolds(host, type, name, active) ? undefined : holder;
}

/**
* [#32183] The package whose stack a read naming no package takes, for a
* name a disabled package also holds: the one holder ADR-0150 D3 resolves
Expand Down Expand Up @@ -523,6 +611,11 @@ export async function readMetaItemFace(
// name's holders too, as it does when it reached nothing: a pair row of a
// name only disabled packages hold is their withheld item, the answer the
// same read gives with no row stored.
// [#33401] …and so does a package-less row of a key whose every holder is
// disabled ({@link packagelessRowWithheld}): that holder's customization,
// withheld with it; the environment's own item is served, and so is the
// row while an enabled package holds the name through a stored row
// (review#2 S5), judged over the active rows read above.
const withheldHolder = request.type === 'object' || request.type === 'package'
? undefined
: (request.packageId ? disabledExactAddressHolder(this, { type: request.type, name: request.name, packageId: request.packageId }) : undefined)
Expand All @@ -531,7 +624,12 @@ export async function readMetaItemFace(
? !isStoredUnder(answer.item, request.packageId)
: isHoldersPairRow(this.engine, request.type, request.name, answer.item))
? disabledOnlyHolderOf(this.engine?.registry, request.type, request.name)
: undefined);
: undefined)
?? (request.packageId || answer?.item == null
? undefined
: await packagelessRowWithheld(this, request.type, request.name, answer.item,
activeRows !== undefined && activeRows.type === request.type && activeRows.name === request.name
? activeRows.rows : undefined));
if (withheldHolder === undefined && (request.type === 'object' || request.type === 'package'
|| (!withheldAction && !isItemOfDisabledPackage(this.engine?.registry, answer?.item)))) {
return answer;
Expand Down
Loading
Loading