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
28 changes: 28 additions & 0 deletions .changeset/37499-disabled-holder-unbound-row-bare-write-refused.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
'@objectstack/metadata-protocol': minor
'@objectstack/spec': minor
---

fix(metadata-protocol)!: refuse a write 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 save, draft save, delete or draft discard naming no package over a name only disabled packages hold; the refusal's own sentence names the fix

<!-- adr-0087: registered disabled-holder-package-less-row-bare-write-refused -->

**BREAKING** for a deployment that writes, with no package named, to a metadata 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 write again. Naming the package (`?package=`) is not the fix: it addresses that package's own row and leaves the hidden row where it is.

A package-less row stored at a name a package holds is that package's customization, and a disabled package's items are hidden from every read naming no package (ADR-0150 D3, its 2026-11-26 note). The writes naming no package still reached the row: an admin could edit, draft, discard or delete an item no read showed, and a delete lost the customization for good, so enabling the package again served its item without it.

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):

- `PUT /api/v1/meta/:type/:name` over a stored package-less row: `200` (the hidden row edited) → `409 RESOURCE_CONFLICT`, nothing written.
- `PUT /api/v1/meta/:type/:name?mode=draft` over a stored package-less row or draft: `200` (a draft stored that the draft read answered `404` for) → `409 RESOURCE_CONFLICT`, nothing written.
- `DELETE /api/v1/meta/:type/:name` over a stored package-less row: `200` (the row removed) → `409 RESOURCE_CONFLICT`, nothing deleted.
- `DELETE /api/v1/meta/:type/:name?state=draft` over a stored package-less draft: `200` (the draft removed) → `409 RESOURCE_CONFLICT`, nothing deleted. With a package-less row stored and no draft, the discard answers the same refusal, where it answered the `?package=` refusal or a no-op receipt.
- The same four through the in-process `saveMetaItem` / `deleteMetaItem` with no `packageId`.

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.
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,30 @@ A bare name, read by a caller that belongs to package P, resolves to:

A caller with no package (an environment item, a context-free door, an MCP client) resolves against the whole environment: the environment item of that name first (ADR-0005 overlay precedence keeps the environment's own item ahead), else the unique package holder, else the refusal with candidates (`409` at a door, D5).

> **Amendment note (2026-11-26, #37499).** A package-less row stored at a name a package holds is that holder's customization, never the environment's own item (D4, "A package-less row that bears a package-held name is a customization, never a second item"; D4's 2026-11-24 note excepts one package-less row from that rule in the metadata service's store, the platform's own record, but the judgment at these doors reads no platform mark, so here such a row is judged as any package-less row is). So it hides with its holder: on the reads, and on the four writes this note closes. Two more writes are not judged yet and are named below. The maintainer, in the triage session recorded on card #37499, verbatim: 「我觉得停用就该全部消失」, then 「同意」 to the split that card carries.
>
> While every package that holds the name is disabled, a caller with no package is answered as follows. The writes below are those the ADR-0146 D11 close leaves open; where that close applies it answers first, as it did before this note (the fourth "Unchanged" bullet).
>
> - **Reads stay the missing name.** The by-name read, `/published`, `/layers`, the list and `_env` withhold the row and answer what they answer for the holder's own item (`404`). This was already so (#32183, #32814, #33401); the note records it beside the writes. The by-name draft read answers `404 NO_DRAFT`. Three reads at `_env` still answer `409` at this head (`?state=draft`, `?preview=draft`, `?layers=true`), and card #34261 carries their move to `404`.
> - **Four writes naming no package are refused** where the ADR-0146 D11 close leaves the write open, `409 RESOURCE_CONFLICT` with no new code: the publish-mode save, the draft save, the delete and the draft discard. The refusal names no package, as the refusal of a name only disabled packages hold already did, and its remedy is the enable: `PATCH /api/v1/packages/:id/enable`, then the same request. In these cells it is never `?package=`. A write naming the package addresses that package's own row, so it would leave the hidden row where it is and store a second row beside it.
> - **A package-less draft counts as the row does.** A package-less draft stored for such a name is the same customization: the draft save and the draft discard are refused over it, and the draft discard is refused with the same remedy when no draft is stored and the customization is the active row.
> - **Re-enable serves the row untouched**, as far as those four writes go. A refused write stores, edits and removes nothing, so the row the enable serves is byte-identical to the one stored before the disable.
> - **Not judged yet: the per-item publish and the per-item rollback.** A publish of one item naming no package (`promoteDraftForPublish`, `protocol-history-and-publish.ts`) and a rollback of one item naming no package (`rollbackMetaItem`, `protocol-package-commits.ts`) do not ask this judgment at this head. Read in the code, not measured: each resolves the package-less row or draft as its address, so each can still write the hidden row. Card #37608 carries both doors. Until it lands, "no write lands on a hidden item" holds for the four writes above and not for these two.
> - **Not asked, by design: the rewrites the server states itself.** A save the server issues with `source` set rewrites a row the store already holds (the stored-metadata migration, the stored flow-credential move), and the package duplicate (`writeFace: 'package-duplicate'`) always names its target. Neither is an author's write naming no package, and neither is asked this judgment.
>
> What this replaces, measured on `main` `5dbcc02b` for a `dashboard` on both transports and both registration orders, under a holder whose id derives no pair (the close's `no_pair` cell): each of the four writes answered `200`. The save edited the hidden row, the draft save stored a draft that the draft read then answered `404 NO_DRAFT` for, the draft discard removed it, and the delete removed the row, so the next enable served the package's item without its customization. The save door skipped the disabled-holders judgment whenever a package-less row was stored at the address. So what this change newly refuses is the draft discard in every cell, and the save, the draft save and the delete in the cells the close leaves open. By the close's own list those include a base with no pair, a name several packages ship, a member the package never ships and a holder that is not a read-only code package; the pins below hold the first, the third and the fourth.
>
> Unchanged. The first three are pinned as controls; the last three are measurements, with no pin in this change beyond the one the fourth names:
>
> - A name no package holds is the environment's own item (the rule above): its save, draft save, draft discard and delete answer as before beside a disabled package.
> - A package-less row at a name an ENABLED package holds is written as before, the two-enabled-holders cell included.
> - A name only disabled packages hold with no package-less row stored keeps its refusal and its `?package=` remedy (#34144): there the named write has one row to write and nothing hidden beside it.
> - Where the ADR-0146 D11 close applies, the save, the draft save and the delete naming no package answer that close first, with the holder enabled or disabled: `403 NOT_OVERRIDABLE`, a sentence that names the base's paired package and prescribes `?package=` with the pair's id. That is an item of one of the five overlay types that one read-only code package ships, with a pair that can be ensured and a recorded version, whose package-less row `os migrate packageless-overlays` would move. This change touches neither that close nor its place ahead of the judgment, so `main` answers the same; the draft discard, which that close never asks, answers the `409` above. Measured at this change's head for an `email_template` such a package ships, a package-less row stored, the package disabled, with and without a package-less draft: the three answer the `403` and store nothing, and the discard answers the `409`. The objectql control pins the save with no row stored. Whether that sentence should, over a disabled base, name the pair and prescribe the write this note calls never the fix is a question this note leaves open, for a card of its own.
> - A type sealed against overlays refuses these writes one step earlier, as it does with its holder enabled. Measured for `doc` and `action`, before and after a restart: the save, the draft save and the delete answer `403 NOT_OVERRIDABLE`, and the draft discard has no draft to remove.
> - No write door takes `_env`: neither transport routes a `PUT` or a `DELETE` there.
>
> Code: `packages/metadata-protocol/src/protocol-save.ts#packagelessHolderRefusal`, the one judgment the four doors ask, and `#disabledHoldersCustomizationRefusal`. Pins: `packages/runtime/src/domains/meta-disabled-holder-served-stack.test.ts` ("the package-unbound row of a name only the disabled D ships is hidden with it", "a package-unbound draft of a name only the disabled D ships", "a package-unbound row beside the disabled holder's own row") and `packages/objectql/src/disabled-holder-packageless-row-doors.test.ts` (review#2 S3).

**Two consequences of the rule, as R (#31637) implements it.**

- **(a) A package caller never resolves to an environment-authored item by bare name.** A package cannot declare a dependency on the environment, so an environment item is in no package's closure. A name that only an environment item holds is refused for a package caller (`outside-closure`), and the refusal names the environment as the holder. **This is a declared narrowing**, added by this record within the letter of the ruled rule. Today `getItem` serves the bare slot first to every caller (D4's overlay row), so a package flow's `template: welcome` filled by an environment-authored template is served today and refused once its reader is wired. It is carried by the E rows that wire a package caller (E1–E6, E8) and by U only through G1's door: Studio's held id travels as `?package=` (`client.meta.getItem`), so at the door it is the exact qualifier (D5), never a caller. G1 declares what that refuses. It cannot be measured on a package tree (HotCRM holds no environment), so the D10 upgrade report names each such reference as the migration finds it.
Expand Down
29 changes: 26 additions & 3 deletions packages/metadata-protocol/src/protocol-diff-delete-load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,11 +754,34 @@ export class ProtocolDiffDeleteLoadFacet {
// are refused naming them, and a name only disabled packages hold
// is refused naming none, never one row removed. Over no stored
// row too (the delete and the draft discard answered the no-op
// receipt). A package-unbound row at the address is the
// environment's own, and its removal is left as it was.
// receipt). A package-unbound row at the address of a name
// an enabled package holds, or no package holds, is removed
// as it was.
//
// [ADR-0150 D3, the 2026-11-26 note] …but a package-unbound
// row or draft of a name ONLY disabled packages hold is
// their customization, hidden with them: the delete and the
// draft discard are refused, with the enable as the remedy.
// The delete removed the hidden row, so the next enable
// served the package's item without it. A draft discard
// reads the draft rows, so where a package-unbound row or
// draft is stored it judges the holders over the active
// rows too, as the draft save does: a customization that is
// the ACTIVE row, or a holder that holds only an active row,
// answers that remedy, never `?package=` nor the receipt.
if (request.packageId == null) {
const active = targetState === 'draft'
? await host.packagelessAddress(singularTypeForRepo, request.name, member, 'active')
: undefined;
const holderRefusal = packagelessHolderRefusal(
host, 'delete', request.type, singularTypeForRepo, request.name, member, rowsAtAddress,
host, 'delete', request.type, singularTypeForRepo, request.name, member,
active !== undefined && (rowsAtAddress.unbound || active.unbound)
? {
candidates: [...new Set([...rowsAtAddress.candidates, ...active.candidates])],
unbound: rowsAtAddress.unbound,
customized: active.unbound,
}
: rowsAtAddress,
);
if (holderRefusal) {
addressRefusal = holderRefusal;
Expand Down
Loading
Loading