Skip to content

Commit 66f6638

Browse files
fix(metadata-protocol,rest,runtime)!: a name only disabled packages hold answers 404 at _env, and its package-less customization is withheld (ADR-0150 D3, D4) (#33995)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbBePzY6g11h3hyWk5ud4vWy)_ Fixes #33385 Fixes #33401 Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: updated here — content/docs/data-modeling/import-mappings.mdx (no `skills/**` file teaches an `_env` answer) **BREAKING** for a read of an environment customization (a package-less row) of a name whose every holding package is disabled: the bare read and the execution read answered the row (200) and now answer 404 as if it were not saved; re-enabling the package serves it again. `_env` of such a name moves from 409 naming the disabled packages to 404, at `/meta` on both transports and at the import door's `mappingName: "_env/NAME"` (`404 MAPPING_NOT_FOUND`). The list and the execution list (`GET /meta/:type`) leave out the same customization while every holder is disabled, so they agree with the read of the name. On the write side, a save naming no package at a member the holder never ships is still accepted and kept, but is hidden from those reads until a holder is enabled again; a delete still removes it; a save at a shipped member is still refused `403 NOT_OVERRIDABLE`. `_env` keeps the 409 in three cases: an enabled package holds the name; it holds it through a stored row the read of the name serves; or the read carries `?state=draft` / `?preview=draft` from a caller admitted to drafts, or `?layers=`. That 409 names only the disabled registry holder. No migration: nothing stored changes (ADR-0087 `not-required (no-migration-prescription)`, in the changeset). The claim declared `Clause-②: no`. The declaration self-check reads the #33401 withhold (served 200 to 404) as a narrowing and finds no widening: the `_env` move replaces one refusal with another. So this body and the changeset declare `no (narrowing)`. #33646's `yes (narrowing)` was for a diff that both widened and narrowed. The deviation is reported to the seat. ## 维护者速读 - **改了什么**:某个元数据名称的所有持有包都被停用时,`/meta/:type/_env/:name` 在两个入口(REST 与 runtime)从 409(点名被停用的包)改为 404,导入接口的 `mappingName: "_env/名称"` 同样改为 404 `MAPPING_NOT_FOUND`;环境里对这些包的名称做的无包定制(含包从未发布的语言版本)在停用期间不再被读出,列表与执行列表也一并不再列出,重新启用后原样恢复。 - **为什么改**:停用包是运维处理冲突的常规手段,但 `_env` 仍然报冲突并点名已停用的包,裸读还在返回属于已停用包的定制内容;#32183 第 17 行(R4-B2)与 #32814 的席位裁决要求按"什么都没存"作答。 - **风险与回滚**:只改读路径判定,不删数据;若某个启用包只通过未水合的存储行持有该名称,`_env` 仍保持 main 的 409;带 `?state=draft`、`?preview=draft` 或 `?layers=` 的 `_env` 读取也保持 409,不会露出启用包的草稿(均已钉住并做消融)。回滚即 revert 本 PR。 - **先看**:`packages/metadata-protocol/src/protocol-meta-item-face.ts`(`packagelessRowWithheld`:启用包通过存储行持有名称时不再扣留,风险最高)、`packages/metadata-protocol/src/protocol-meta-list-reads.ts`(列表按同一判定剔除)、`packages/rest/src/meta-qualified-item-route.ts`(`admitEnvironmentAddress`:标记的拒绝只对普通读取与无草稿权限的调用方放行为 404)。 - **两分钟验证**:`pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/meta-qualified-item-route.test.ts`,预期 381 个测试全部通过(在 `0f5f95d0` 实测)。 - **需要你做的**:无,席位落地。 ## What changes One judgment, shared by both cards: a name whose every holder is disabled answers as if nothing were stored. That covers the bare read (served and execution faces), its `/layers`, and `_env` on both transports. A disabled package's customization is never served, and nothing stored is touched. - **#33401**, `protocol-meta-item-face.ts`: the read naming no package now also withholds a **package-less** row it reached when the row's key is held only by disabled packages (`packagelessRowWithheldHolder`). The key's holders come from the registry's one owner rule, `overlayRowBinding` with every holder counted (seat ruling 6882483833 on #32814: ownership counts every holder, disabled included). - `null` is the environment's own item (D3 (a)) and is served. - One holder: withheld when that holder is disabled. - Two or more: judged as the name's holders are (`disabledOnlyHolderOf`). - Member grain is not part of the key, so a locale the holder never shipped is withheld too. - **#33385**: `admitEnvironmentQualifier` (`protocol-exact-qualifier.ts`) still refuses a name only disabled packages hold. It is synchronous, it reads no stored rows, and its declared signature lives in `protocol.ts`. The refusal now carries a registered-symbol mark (`objectstack.metadata-protocol.disabledHoldersOnlyRefusal`, the same pattern as the face's `storedRowHoldersRefusal`), set only after the read it would admit has passed the 501 judgment. - Each `_env` door handles the mark in `admitEnvironmentAddress`: `packages/rest/src/meta-qualified-item-route.ts` and `packages/runtime/src/domains/meta.ts`. - If the read naming no package (`getMetaItem`) withholds the name, the door admits `_env`, and the read answers 404 naming no package. - If that read serves an item, or refuses, an enabled package holds the name through a stored row the registry has not read, and the 409 stands, as on main. - Review S1: only the read that judged the name is admitted this way. The marked 409 stands, as on main, for exactly three reads, which read other rows than the plain read: `?state=draft` (any case) and `?preview=draft` from a caller `mayReadPendingDrafts` admits to drafts, and the deprecated layered view `?layers=`. A caller who may not read drafts reads the active rows whatever switch it sends, so its draft switch is judged as the plain read (404), on both transports alike. REST asks `resolveExecCtx` for that admission, which is why `rest-server.ts` hands the qualified route its `resolveExecCtx` (deviation, approved by the area seat). - Review S2, `packages/rest/src/import-mapping.ts#namedMappingRead`: the import door's `_env/NAME` reads the same mark and admits it the same way. A mapping only disabled packages hold answers `404 MAPPING_NOT_FOUND`, naming no package, as `GET /meta/mapping/_env/NAME` answers 404. - `content/docs/data-modeling/import-mappings.mdx` documents the new 404 (review S3). - Review#2 S1, `protocol-meta-list-reads.ts#readFlattenedMetaItems` (file approved by the area seat): the list and the execution list now leave out a package-less item that the read of its name withholds, through the same `packagelessRowWithheld`. Before, both lists still carried an `fr-FR` row the by-name read answered 404. - Review#2 S5, `protocol-meta-item-face.ts#packagelessRowWithheld`: the arm is judged over the active rows the face already read. If an enabled package holds the name through one of those stored rows (one the registry has not hydrated, so `overlayRowBinding` does not see it), the package-less row is served, as on main. Before this fix the arm withheld it in that cell. The list asks the same helper, which reads the active rows itself. - Review#2 S4: the residual 409 names only the disabled registry holder, `[{ kind: 'package', packageId: B }]`, as on main; the enabled package holding the name through a stored row is not named. Pinned in both doors' CONTROLs. - Review#2 S3, measured: with every holder disabled, a save naming no package at a member the package never ships is accepted and kept, as on main, and is now hidden until a holder is enabled again; a delete of it removes the row; a save at a shipped member is refused `403 NOT_OVERRIDABLE`, as before. Pinned in `disabled-holder-packageless-row-doors.test.ts`. - `packages/objectql/src/registry.ts`: read only. H3 holds: `overlaySlotBinding` counts every composite holder, so a package-less row of a disabled holder's key binds to that holder, and `getEnvironmentScopedItem` answers `undefined` for it. - The PM's H2 was half true. Without a mark, the `_env` read never reached the face as `_env`. Admitting on the registry alone would have served an enabled package's unhydrated stored row at `_env`. The mark plus the door's bare-read check closes that without touching `protocol.ts`. | Read | State | FROM (origin/main 1e65a38, measured) | TO | |:--|:--|:--|:--| | `GET /meta/:type/_env/:name`, REST and runtime, all 18 `PACKAGE_SCOPED_READ_TYPES` | only holder disabled, no row | 409 `RESOURCE_CONFLICT` naming the disabled holder | 404 `RESOURCE_NOT_FOUND`, naming no package | | same | only holder disabled, a package-less registry row of the name | 409 naming it | 404 | | same, `dashboard` `email_template` `permission` `report` | only registry holder disabled, an enabled package's unhydrated stored row the bare read serves | 409 | 409 (unchanged, CONTROL) | | same, the other 14 types | same fixture; their bare read serves no row of that shape | 409 | 404, as their bare read | | protocol `admitEnvironmentQualifier` (objectql pin, row 17) | the only holder disabled | 409 naming X | 409 naming X, marked; the bare read withholds, so both doors answer 404 | | bare `GET /meta/email_template/:name?member=fr-FR` and the execution read | the only holder disabled, a package-less stored row of a locale it never shipped (stored, or stored and hydrated), both registration orders, disabled before or after | 200, the row | the holder's withheld item (404), equal to the answer with no row stored | | same | two holders, both disabled | 200, the row | withheld | | `_env`, bare read | the holder re-enabled | 409 naming it / the row | unchanged | | `_env` with `?state=draft` (any case) or `?preview=draft`, REST and runtime, all 18 types | only registry holder disabled, an enabled package's draft row only | 409 | 409 (unchanged, CONTROL, review S1) | | `_env` with `?layers=true`, same | only registry holder disabled, an enabled package's unhydrated active row | 409 | 409 (unchanged, CONTROL, review S1) | | import `POST …/import` with `mappingName: "_env/NAME"` | the only holder of the mapping disabled | 409 `RESOURCE_CONFLICT` naming it | 404 `MAPPING_NOT_FOUND`, naming no package; nothing written | | same | the holder re-enabled | 409 naming it | unchanged (CONTROL) | | bare read, `/layers` | package-less row at a member the holder ships | 404 | 404 (unchanged, CONTROL) | | `_env`, protocol `admitEnvironmentQualifier` (review L2 N3) | the only holder disabled, on an engine whose registry has no package-scoped resolver for the type (no by-name reads; not a production composition) | 409 `RESOURCE_CONFLICT` naming the holder | 501 `NOT_IMPLEMENTED`, the read that engine cannot judge (refusal to refusal) | | bare `GET /meta/action/:name` (objectql pin, review L2 S1), both registration orders | the only holder disabled, ships the action on `account`; a package-less action of the name on `contact` | served (`main` since #33898; measured here with the arm ablated) | served, the environment's own item, no `_packageId` (unchanged, CONTROL); re-enabled, the same | | same | same, the package-less action on `account` | withheld (the stamped-item rules) | withheld (unchanged, CONTROL); re-enabled, served under the holder's envelope | | `_env` with a draft switch from a caller who may not read drafts, REST and runtime, all 18 types | only registry holder disabled | 409 | 404 `RESOURCE_NOT_FOUND`, as its plain read (both transports agree) | | `getMetaItems` / `getMetaItemsForExecution` (list, execution list) | the only holder disabled, a package-less row at a never-shipped locale (saved after boot, or hydrated at boot) | the row listed | not listed; re-enabled, listed again (CONTROL) | | bare read and both lists, either order | X's registry holder disabled, enabled Y holds the name through an unhydrated stored row, a package-less row | served and listed | unchanged (CONTROL, review#2 S5); `_env` keeps the marked 409 | | save / delete naming no package | every holder disabled; never-shipped member / shipped member | saved and served / 403 | saved and hidden until re-enable, delete removes it / 403 (unchanged) | The served-to-404 rows are narrowings (hence `Clause-②: no (narrowing)`, the `!` title and the BREAKING banner). The `_env` rows, and the import door's, replace one refusal with another (409 to 404). No answer widens. ## Tests - `packages/objectql/src/package-scoped-exact-qualifier.test.ts` (the face's shared real-registry harness; the area seat approved this file-surface extension): - The R4-B2 `_env` pin now asserts the marked 409 plus the withheld bare read. An unmarked-with-the-holder-enabled CONTROL is added beside it. - New top-level `[#33401]` describe, the bare read at a never-shipped locale: four orders on both faces with re-enable as CONTROL; the answer with the row stored equals the answer with none; two holders both disabled, then both re-enabled giving the read's own 409; the hydrated row. - CONTROLs: an enabled holder, the environment's own item, and a row at a shipped member. - `packages/rest/src/meta-qualified-item-route.test.ts` and `packages/runtime/src/domains/meta-qualified-item-read.test.ts`, for every `PACKAGE_SCOPED_READ_TYPES` type: - `_env` answers 404 beside the other addresses' 404; re-enabled, the 409 naming the holder (CONTROL). - A package-less registry row: the bare read, `/layers` and `_env` answer 404; re-enabled, the 409. - The unhydrated stored-row CONTROL, with the four row-serving types named explicitly so its 409 leg cannot pass vacuously. - Review S1 CONTROL: with an enabled package's draft row only, `_env` with `?state=draft`, `?state=DRAFT` and `?preview=draft` answers 409 and never the draft. With its unhydrated active row, `_env?layers=true` answers 409 and never the row. - Review S1 draft-switch cell: a member caller who may not read drafts sends `?state=draft`, and both transports answer 404 `RESOURCE_NOT_FOUND`, the same answer. - Review#2 S4: the standing 409's `details.candidates` is exactly `[{ kind: 'package', packageId: B }]`, the disabled registry holder, in the draft/layered CONTROL and the row-holder CONTROL, on both transports. - Both harnesses' engine doubles now answer `find` from stored rows (empty unless a pin stores one); `findOne` stays main's `null`. - `packages/rest/src/import-integration.test.ts` (review S2, real engine and protocol): with the only holder disabled, `_env/task_pkg_feed` answers 404 `MAPPING_NOT_FOUND` naming no package, `GET /meta/mapping/_env/task_pkg_feed` answers 404, and no row is written. Re-enabled, the 409 naming the holder (CONTROL). - New `packages/objectql/src/disabled-holder-packageless-row-doors.test.ts` (real ObjectQL engine, in-memory driver, real protocol; 5 tests): - Review#2 S1: a package-less `fr-FR` row, saved after boot or hydrated at boot, with the only holder disabled: the by-name read withholds it and neither list nor execution list carries any item of the name. Re-enabled, both list `en-US`, `fr-FR`, `zh-CN` (CONTROL). - Review#2 S3: with the holder disabled, a save naming no package at `fr-FR` succeeds and keeps one package-less row, the read and both lists hide it, a save at shipped `en-US` is refused `403 NOT_OVERRIDABLE`; re-enabled it is served; a delete while disabled removes the row. - Review#2 S5, both orders (the by-name read first, the list first): X disabled, enabled Y holding the name through an unhydrated stored row, a package-less `fr-FR` row. The read serves `ENV fr` at `fr-FR` and Y's `OTHER en` bare, both lists carry `fr-FR`, as on main; `admitEnvironmentQualifier` still throws the marked 409. - Review L2 S1, `package-scoped-exact-qualifier.test.ts` `[review L2 S1]` (4 tests): the action legs above, each in both registration orders, with re-enable as CONTROL. - Ablations: `scripts/ablation-replace.mjs --hold`. Each mutate leg on metadata-protocol was rebuilt and `ablation-dist-preflight` returned 0; each restore leg was rebuilt, `--absent` returned 0, and the restore was proved blob == HEAD. - #33401 arm removed (at 71880ce, face unchanged since): objectql 7 red of 319, all seven moved cells; every CONTROL green. - The mark removed: objectql 1 red of 320, the row 17 pin. rest 50 red of 353 and runtime 50 red of 363: 18 types times 2 404-pins, plus the 14 non-row-serving types' 404 leg. - The door's withheld check removed: rest 4 red of 353 and runtime 4 red of 363, exactly the four row-serving types' 409 CONTROL. - Review S1, the plain-read guard removed (`ablation-replace --delete`; the mutation landed, and the restore matched the HEAD blob): rest 18 red of 371 and runtime 18 red of 381, one per type. In these harnesses `findOne` answers `null`, so the ablated door answers `404 NO_DRAFT`. - A one-time probe (not committed) gave the doubles a row-serving `findOne`: - Without the guard, both transports answered `200` with the enabled package's draft for all 18 types. This is the widening review S1 describes. - With the guard, both stayed green. - With only the `?layers=` arm removed, 14 types on each transport answered `_env?layers=true` with `404` instead of `409`. That swaps one refusal for another; it does not widen. The guard keeps main's 409. - Review S1 admission (the draft-switch judgment), the caller's admission ignored so every draft switch keeps the refusal: rest 18 red of 371 and runtime 18 red of 381, the member-caller cell for each type. - Review#2 S5, at `69f48871`: `enabledRowHolds(...) ? undefined :` replaced so the arm always withholds; rebuilt, preflight marker in 2 dist files. objectql 2 red of 330, exactly the two S5 orders. Restore: blob == HEAD, `git diff HEAD` empty, rebuilt, `--absent` exit 0. - Review#2 S1, at `69f48871`: the list's `packagelessRowWithheld` call replaced by a never-true marker; rebuilt, preflight in 2 dist files. objectql 3 red of 330: both S1 cells and the S3 test's list assertion. Restore proved the same way. - Review L2 S1, after the merge of `main`, at `8bbac030` (test text as committed; the later amend changed only its comment), objectql 342 tests: - The arm removed (`packagelessRowWithheld` never withholds): 10 red, every `[#33401]` withhold cell and the lists; both action legs stay green. - The arm's binding-`null` exemption replaced by the name's holders (`disabledOnlyHolderOf`): 2 red, exactly the two other-object action cells. - The face's stamped-item rules removed together (`isActionWithheldByDisabledPackage`, `isItemOfDisabledPackage`): 4 red, the two same-object action cells and the two shipped-member CONTROLs. With `isItemOfDisabledPackage` alone removed, only those two CONTROLs went red. - Each mutate leg was rebuilt with `ablation-dist-preflight` exit 0. Each restore was proved by blob == HEAD and an empty `git diff HEAD`, then rebuilt with `--absent` exit 0. - Review S2, the import door's mark check replaced by a bare rethrow: 1 red of 61 in `import-integration.test.ts`, the new pin; the 409 naming the holder came back. ## Acceptance notes - **Correction (review L2 S1):** an earlier body said the card's action CONTROL, "a same-name item on another object is still served", was unreachable. That was true of this branch's old base and false of `main` since 68e726d (#33898), which grafts an action's envelope only onto the item its package holds at that `(object, name)`. The branch now merges `main` (`35cc6638`), and both legs are pinned under a disabled holder, in both registration orders: on another object (`contact`) the package-less action binds to no holder (`overlayRowBinding` answers `null`) and is served as the environment's own item, with no `_packageId`; on the holder's own object (`account`) it is the holder's customization under its envelope and is withheld; re-enabled, both are served. Measured by ablation: the new arm reaches the other-object leg and its binding-`null` exemption keeps it served, as on `main`; the same-object leg is decided by the face's stamped-item rules (`isActionWithheldByDisabledPackage`, `isItemOfDisabledPackage`), as on `main`, because the read reaches the face with the holder's envelope already grafted. - The `_env` door asks the bare read once more before it answers a marked refusal. That costs one extra protocol read, and only on the disabled-only path. The list asks `packagelessRowWithheld` per package-less item only when a disabled holder is in play, and that reads the item's active rows. - **Loose end (review#2 S4), carried by #34261:** the draft and layered `_env` reads keep main's 409 here; whether they should also answer 404 when every holder is disabled is the follow-up. PR #34169 (`claude/area-E1-32849-layered`), which touched the face and both shared test harnesses, has merged and is inside the merged `main`. - **CI note:** Test Core (3/8) was red at `d86adb40` (run 43751883003) on `@objectstack/scenarios` `test/runner/run-date.test.ts` timing out on run date 2028-03-31, the known flake #34081. This diff does not touch `@objectstack/scenarios`. - **Follow-ups, left unfixed; the area filed them:** - #34258: the action withhold at the key's grain (review-c N1, review#2 N1; review L2 N1: with two or more holders on the row's key, `disabledOnlyHolderOf` judges the name's holders, not the key's). - #34259: the unpinned cells and the list memo (review-c N2/N5, review#2 N2 to N5; review L2 N2 and N5). Triage closed it `not_planned` under the maintainer's p3 standard (no user effect), so these cells are an accepted deviation: unpinned, each held by reading as the reviews state. Reopen it if a regression appears. - #34260: an ADR-0150 addendum for "a disabled package holds no name", and the `PATCH /packages/:id/disable` docs (review L2 N4). - #34261: the draft and layered `_env` 409 (the review#2 S4 loose end above). - #34262: the accepted save that stays hidden while every holder is disabled. ### Deviations - `packages/rest/src/rest-server.ts`: the qualified route's host object now hands it `resolveExecCtx`, on its own line as every registrar host spells it (`execctx-consumer-census` unchanged). Outside the claimed surface; approved by the area seat. - `packages/metadata-protocol/src/protocol-meta-list-reads.ts`: the list filter (review#2 S1). Approved by the area seat for this. - `packages/objectql/src/disabled-holder-packageless-row-doors.test.ts`: a new test file for the review#2 S1/S3/S5 pins, on a real ObjectQL engine and protocol. ## Verification All at head `0f5f95d0`, which merges `main` at `35cc6638`. The box is shared, so wall-clock figures are not idle-box figures. <details><summary>Builds, typecheck and suites</summary> - After the merge: `pnpm install --frozen-lockfile` exit 0, and the closure build of metadata-protocol, objectql, rest and runtime exit 0, with lock `VERDICT command-exit 0`. - `typecheck` exit 0 for metadata-protocol, objectql, rest and runtime. - objectql `disabled-holder-packageless-row-doors.test.ts` + `package-scoped-exact-qualifier.test.ts`: 342/342. rest `meta-qualified-item-route.test.ts`: 381/381. - Full suites, each exit 0: - metadata-protocol: 344 passed, 9 skipped files; 22946 passed, 45 skipped tests. - objectql: 599 files; 13307 tests. - rest: 413 files; 8534 passed, 332 skipped. - runtime: 606 files; 11127 passed, 19 skipped. </details> <details><summary>Dogfood battery (narrowing arm)</summary> - At `0f5f95d0`: `pnpm --workspace-concurrency=2 --filter '@objectstack/dogfood^...' build` exit 0, then `pnpm --filter @objectstack/dogfood test` exit 0. - Test Files 469 passed, 3 skipped (472). Tests 3974 passed, 42 skipped (4016). - Lock `VERDICT command-exit 0`. </details> <details><summary>Gates</summary> - `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derives 105 families at `0f5f95d0`. 103 ran locally, and each exited 0. - Two gates are NOT MEASURED locally; CI runs both: - `check:dual-build-cjs-loads` exited 3, PREREQUISITE NOT MET. It reads `dist/` of packages this diff does not touch (`studio`, `scenarios`, and others). - `check:type-check-debt` exited 3, because its closure build queued out on the shared verify lock (99). - `--ran` reconciliation, with every line recorded as `command :: exit code`: `105 derived, 103 run, 2 NOT-MEASURED, 0 UNRUN` (exit 0). - `dispatch-gates --tier`: no path-derived mandate; 1022 changed lines, under 3000. A narrowing owes one contract-review-tier review before the queue. - `git merge-tree --write-tree` at `0f5f95d0` is clean against `origin/main` (`31eb2aed`) and against #34169, #34147, #34025, #34241, and #34224 (`claude/area-E1b-32780`). - `pnpm lint` and the full farm are CI's: PR check-runs at `0f5f95d0`: 53, of which 38 success and 15 skipped, none failed, `mergeable_state` clean. They include `Lint · ESLint`, `Test Core` 1/8 to 8/8, `Type Check · workspace`, `Type Check · debt ledger`, `Type Check · consumer gates`, `Dogfood Regression Gate` and `Check Changeset`. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QsR2jUcj2x2Wr4UErwBi12 <!-- signed: domain:server#5 · zhuangjianguo · session_01QsR2jUcj2x2Wr4UErwBi12 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0241df4 commit 66f6638

14 files changed

Lines changed: 989 additions & 33 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
'@objectstack/rest': patch
4+
'@objectstack/runtime': patch
5+
---
6+
7+
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)
8+
9+
Clause-②: no (narrowing)
10+
Metadata-protocol: none
11+
Skills-docs: updated here — content/docs/data-modeling/import-mappings.mdx (no `skills/**` file teaches an `_env` answer)
12+
13+
<!-- 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. -->
14+
15+
**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).
16+
17+
- **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.
18+
- **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.
19+
- **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`.
20+
- **`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.
21+
- **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.
22+
23+
**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.
24+
25+
**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.

‎content/docs/data-modeling/import-mappings.mdx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ address `GET /api/v1/meta/mapping/<namespace>/<name>` reads, and the import door
9494
the same way (ADR-0150 D5). The import applies exactly that holder's mapping. When that
9595
namespace, or the environment, holds no mapping of the name and a package does, the
9696
import is refused with the `409 RESOURCE_CONFLICT` that read answers, naming every holder,
97-
and no row is written. A first segment that is neither `_env` nor an installed namespace
97+
and no row is written. A disabled package holds no name: when every package that holds the
98+
name is disabled, `"_env/<name>"` answers `404 MAPPING_NOT_FOUND`, naming no package, as
99+
`GET /api/v1/meta/mapping/_env/<name>` answers `404`. Enable a holder again and the address
100+
is refused with the `409` naming it, as before. A first segment that is neither `_env` nor an installed namespace
98101
is no address: the whole string is read as the name, which no mapping has, so the import
99102
answers `404 MAPPING_NOT_FOUND`. Two limits come with the metadata read's address. Where
100103
two packages that share a namespace (`base`, `system`, `sys`) both hold the name, the
@@ -274,8 +277,8 @@ These are whole-request failures — nothing is written, and there is no per-row
274277

275278
| Status | `code` | Cause |
276279
|:---|:---|:---|
277-
| 404 | `MAPPING_NOT_FOUND` | No mapping artifact is registered under that name. |
278-
| 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. |
280+
| 404 | `MAPPING_NOT_FOUND` | No mapping artifact is registered under that name, or every package that holds it is disabled. |
281+
| 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. |
279282
| 400 | `MAPPING_TARGET_MISMATCH` | The artifact's `targetObject` is not the object in the URL. |
280283
| 400 | `MAPPING_FORMAT_UNSUPPORTED` | The artifact declares `sourceFormat: 'xml'` or `'sql'`; the endpoint accepts csv, json and xlsx payloads only. |
281284
| 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. |

‎packages/metadata-protocol/src/protocol-exact-qualifier.ts‎

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,8 @@ export function resolveMetaItemAddress(
946946
* environment does not hold and a package does is refused
947947
* (`not-held-by-qualifier`, `callerPackageId: null`); otherwise the read is a
948948
* caller with no package, which E8's resolver answers environment-first.
949+
* [#33385] A name only disabled packages hold is refused with a mark the
950+
* doors read ({@link DISABLED_HOLDERS_ONLY_REFUSAL}).
949951
* Types outside the covered set keep the bare read, as `?package=` does for
950952
* them.
951953
*
@@ -972,8 +974,10 @@ export function admitEnvironmentQualifier(
972974
}
973975
// [#32183, epic ruling R4-B2] The served holders, or every holder when no
974976
// package serves the name: a name only disabled packages hold is refused
975-
// naming them, as before, never read as a caller with no package (that
976-
// read can reach a disabled holder's customization pair row).
977+
// naming them here, never admitted on the registry's word alone. The
978+
// registry does not see a package holding the name only through a stored
979+
// row it has not hydrated, so a read admitted here could serve that
980+
// package's row at the environment's address.
977981
const served = registry.packageScopedHoldersOf(request.type, request.name) ?? [];
978982
const holders = served.length > 0
979983
? served
@@ -982,6 +986,11 @@ export function admitEnvironmentQualifier(
982986
refuseUnjudgeableByNameRead(host, request, { kind: 'environment' });
983987
return;
984988
}
989+
// [#33385, #32183 row 17] …but marked ({@link DISABLED_HOLDERS_ONLY_REFUSAL}),
990+
// once the read it would admit is judgeable: each door then asks the read
991+
// naming no package, which judges the stored rows too, and answers the
992+
// name as no package's (its 404) when that read withholds it.
993+
if (served.length === 0) refuseUnjudgeableByNameRead(host, request, { kind: 'environment' });
985994
const candidates: PackageScopedHolder[] = holders.map((holder) => ({ kind: 'package' as const, packageId: holder }));
986995
const base = {
987996
status: 'refused' as const,
@@ -991,5 +1000,28 @@ export function admitEnvironmentQualifier(
9911000
callerPackageId: null,
9921001
candidates,
9931002
};
994-
throw new PackageScopedNameRefusedError({ ...base, message: packageScopedRefusalMessage(base) });
1003+
const error = new PackageScopedNameRefusedError({ ...base, message: packageScopedRefusalMessage(base) });
1004+
if (served.length === 0) Object.defineProperty(error, DISABLED_HOLDERS_ONLY_REFUSAL, { value: true });
1005+
throw error;
9951006
}
1007+
1008+
/**
1009+
* [#33385, #32183 row 17 (ruling R4-B2 on PR #32497)] The marker
1010+
* {@link admitEnvironmentQualifier} sets on its refusal of a name only
1011+
* disabled packages hold, a registered symbol (so every copy of this package
1012+
* reads the same key, and no envelope serializes it). The `_env` doors of
1013+
* `RestServer` and the runtime dispatcher read it by the same `Symbol.for`
1014+
* key (`RestServer` reaches the protocol only as a service, as with the item
1015+
* face's `storedRowHoldersRefusal` marker), and answer it in two steps,
1016+
* because only an asynchronous read sees a package that holds the name
1017+
* through a stored row alone:
1018+
*
1019+
* - the read naming no package (`getMetaItem`) withholds the name (no item):
1020+
* no package serves it, a disabled package holds no name, and the item face
1021+
* withholds every customization of its holders (the pair's row, #32814; a
1022+
* package-less row of their key, #33401). The door admits `_env` and its
1023+
* read answers 404, naming no package;
1024+
* - that read serves an item, or refuses: a package holds the name through
1025+
* its stored row, so the refusal stands, as before.
1026+
*/
1027+
const DISABLED_HOLDERS_ONLY_REFUSAL: unique symbol = Symbol.for('objectstack.metadata-protocol.disabledHoldersOnlyRefusal') as never;

‎packages/metadata-protocol/src/protocol-meta-item-face.ts‎

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,94 @@ function isHoldersPairRow(engine: unknown, type: string, name: string, item: unk
122122
return every.some((holder) => pairsOf(holder, installed).includes(stamp));
123123
}
124124

125+
/**
126+
* [#33401, ADR-0150 D4] The package a package-less row (stamped with no
127+
* package, `''` or the `sys_metadata` sentinel) that the read naming no
128+
* package reached is withheld with: the holder whose key the row customizes,
129+
* when every holder of that key is disabled. Seat ruling 6882483833 on
130+
* #32814: a package-less row whose key (`(type, name)`; `(object, name)` for
131+
* an `action`) an installed package holds is that holder's overlay, owned
132+
* over every holder, disabled included (epic ruling 6816940784 on #31699), so
133+
* with every holder disabled the read answers as if no row were stored. The
134+
* member is not part of the key: a locale the holder never shipped is still
135+
* its customization.
136+
*
137+
* The key's holders are the registry's one owner rule
138+
* (`overlayRowBinding`, every holder counted): `null` is the environment's
139+
* own item (D3 (a), no holder at its key, a same-name action on another
140+
* object included), served; one holder is withheld when it is disabled; two
141+
* or more are judged as the name's holders are ({@link disabledOnlyHolderOf}).
142+
* The row itself is untouched, so it is served again on re-enable.
143+
* `undefined` when the item is not such a row, or the registry cannot bind
144+
* one (optional-called: such a registry hides nothing more).
145+
*/
146+
function packagelessRowWithheldHolder(registry: any, type: string, name: string, item: unknown): string | undefined {
147+
const stamp = (item as { _packageId?: unknown } | null | undefined)?._packageId;
148+
if (stamp !== undefined && stamp !== null && stamp !== '' && stamp !== 'sys_metadata') return undefined;
149+
if (typeof registry?.overlayRowBinding !== 'function' || typeof registry?.isPackageDisabled !== 'function') return undefined;
150+
const holder: unknown = registry.overlayRowBinding(type, name, item, { includeDisabledPackages: true });
151+
if (holder === null) return undefined;
152+
if (typeof holder === 'string') return registry.isPackageDisabled(holder) === true ? holder : undefined;
153+
return disabledOnlyHolderOf(registry, type, name);
154+
}
155+
156+
/**
157+
* [#33401, review#2 S5] Whether an enabled package holds `(type, name)`
158+
* through a stored active row the reads serve: a row bound to an enabled
159+
* package that the reads do not decline (`declinesStoredRow`) and that is no
160+
* holder's customization pair row (a pair row is that holder's item, never a
161+
* holder of its own). The registry's owner rule does not see such a row
162+
* until it is hydrated, so {@link packagelessRowWithheldHolder} alone would
163+
* withhold a package-less row while an enabled package holds the name, and
164+
* the answer would follow hydration order.
165+
*/
166+
function enabledRowHolds(
167+
host: Pick<ServedRowHost, 'engine' | 'declinesStoredRow'>,
168+
type: string, name: string,
169+
rows: ReadonlyArray<Awaited<ReturnType<ServedRowHost['readItemActiveRows']>>[number]>,
170+
): boolean {
171+
const registry: any = host.engine?.registry;
172+
const every: readonly string[] = registry?.packageScopedHoldersOf?.(type, name, null, { includeDisabledPackages: true }) ?? [];
173+
const installed = installedManifestsOfEngine(host.engine);
174+
return rows.some((row) => {
175+
const bound = typeof row.package_id === 'string' && row.package_id !== '' && row.package_id !== 'sys_metadata'
176+
? row.package_id : undefined;
177+
return bound !== undefined && registry?.isPackageDisabled?.(bound) !== true
178+
&& !host.declinesStoredRow(type, name, row)
179+
&& !every.some((holder) => pairsOf(holder, installed).includes(bound));
180+
});
181+
}
182+
183+
/**
184+
* [#33401] The holder a package-less `item` of `(type, name)` is withheld
185+
* with ({@link packagelessRowWithheldHolder}), unless an enabled package
186+
* holds the name through a stored active row ({@link enabledRowHolds},
187+
* review#2 S5): then the answer is `main`'s, whichever order the rows were
188+
* hydrated in. `rows` are the item's active rows when the caller already
189+
* read them; otherwise they are read here, only once the registry would
190+
* withhold the item. The read naming no package and the list naming no
191+
* package (`protocol-meta-list-reads.ts`) both ask this, so the list carries
192+
* no row the by-name read withholds.
193+
*/
194+
export async function packagelessRowWithheld(
195+
host: Pick<ServedRowHost, 'engine' | 'declinesStoredRow' | 'readItemActiveRows' | 'rethrowUnlessMetadataStoreUnprovisioned'>,
196+
type: string, name: string, item: unknown,
197+
rows?: ReadonlyArray<Awaited<ReturnType<ServedRowHost['readItemActiveRows']>>[number]>,
198+
): Promise<string | undefined> {
199+
const holder = packagelessRowWithheldHolder(host.engine?.registry, type, name, item);
200+
if (holder === undefined) return undefined;
201+
let active: ReadonlyArray<Awaited<ReturnType<ServedRowHost['readItemActiveRows']>>[number]> | undefined = rows;
202+
if (active === undefined) {
203+
try {
204+
active = await host.readItemActiveRows(type, name);
205+
} catch (error) {
206+
host.rethrowUnlessMetadataStoreUnprovisioned(error, 'sys_metadata');
207+
active = [];
208+
}
209+
}
210+
return enabledRowHolds(host, type, name, active) ? undefined : holder;
211+
}
212+
125213
/**
126214
* [#32183] The package whose stack a read naming no package takes, for a
127215
* name a disabled package also holds: the one holder ADR-0150 D3 resolves
@@ -523,6 +611,11 @@ export async function readMetaItemFace(
523611
// name's holders too, as it does when it reached nothing: a pair row of a
524612
// name only disabled packages hold is their withheld item, the answer the
525613
// same read gives with no row stored.
614+
// [#33401] …and so does a package-less row of a key whose every holder is
615+
// disabled ({@link packagelessRowWithheld}): that holder's customization,
616+
// withheld with it; the environment's own item is served, and so is the
617+
// row while an enabled package holds the name through a stored row
618+
// (review#2 S5), judged over the active rows read above.
526619
const withheldHolder = request.type === 'object' || request.type === 'package'
527620
? undefined
528621
: (request.packageId ? disabledExactAddressHolder(this, { type: request.type, name: request.name, packageId: request.packageId }) : undefined)
@@ -531,7 +624,12 @@ export async function readMetaItemFace(
531624
? !isStoredUnder(answer.item, request.packageId)
532625
: isHoldersPairRow(this.engine, request.type, request.name, answer.item))
533626
? disabledOnlyHolderOf(this.engine?.registry, request.type, request.name)
534-
: undefined);
627+
: undefined)
628+
?? (request.packageId || answer?.item == null
629+
? undefined
630+
: await packagelessRowWithheld(this, request.type, request.name, answer.item,
631+
activeRows !== undefined && activeRows.type === request.type && activeRows.name === request.name
632+
? activeRows.rows : undefined));
535633
if (withheldHolder === undefined && (request.type === 'object' || request.type === 'package'
536634
|| (!withheldAction && !isItemOfDisabledPackage(this.engine?.registry, answer?.item)))) {
537635
return answer;

0 commit comments

Comments
 (0)