Skip to content

Commit 128b657

Browse files
fix(metadata-protocol): a customization pair's row of a name two namespaces hold is judged against its own base, whichever package registered first (ADR-0150 D4) (#33129)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DTWMrxHhXGd1ihAZkAUVAex)_ Fixes #32552 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 改了什么:两个不同命名空间的包都出货同名条目(例如 flow `f`),各自带一个声明过的 `.custom` 覆盖时,删除覆盖、回滚提交、启动普查这三处原来只拿“先注册的那个包”当基准判断;现在对每个出货包分别判断,后注册那个包的覆盖也能正常删除、回滚。启动普查与读取保持一致:flow 和 action 不再把第二个包正在生效的覆盖报成“无人服务、请删除”;页面、应用、数据集、文档、手册、映射这六类读取仍只认先注册的包(#33131 再改),普查也照旧。 - 为什么改:结果原本取决于包的注册顺序(ADR-0150 D4 要求每个持有包的声明覆盖各自成立);后注册的包删自己的覆盖会被 `403 NOT_OVERRIDABLE` 拒掉,回滚失败,普查还会建议删掉一个正在生效的定制。 - 风险与回滚:只放宽(widening),不收紧任何已有答案;单一持有包的行为逐条不变(CONTROL 钉住)。不是任何持有包的配对行仍然 403。回滚 = revert 本 PR,只动 `metadata-protocol` 三个源文件。本轮(复审 s1)把普查收窄到与 #32613 的读取一致。 - 先看:`packages/metadata-protocol/src/protocol-environment-rows.ts` 新增的 `someShipperOf`(判定核心);`protocol-diff-delete-load.ts` 的删除判定与启动普查两处 hunk;`protocol-class-head.ts` 的 `restoreWriteFor`。 - 两分钟验证:`pnpm --filter @objectstack/objectql exec vitest run src/protocol-flow-custom-override.test.ts`,预期 45/45 通过;其中 `[#32552]` 组两种注册顺序、各禁用一个持有包、映射类 CONTROL 以及单持有包 CONTROL 全绿。 - 需要你做的:无,席位落地。 ## What changes For a name two packages of two namespaces ship, each with its paired `.custom` holding a declared override (ADR-0146 D2), three answers judged the pair's row against the one package the bare-name artifact lookup (`packagedArtifactOwner`) answers, so they depended on which package registered first. Each now asks `someShipperOf` (new, `protocol-environment-rows.ts`): the bare-name owner first and alone while it holds (a one-holder name answers exactly as before), then every package that ships the name (`shippingPackageIds` over `shippedArtifactsOf`). No shipper is picked: the row judged is always the one its own `package_id` names. | Door | Second-registered holder B, before | Now | One holder (CONTROL) | |:--|:--|:--|:--| | `DELETE /meta/TYPE/NAME?package=B.custom` (`deleteMetaItem`); pinned for a flow, and an action in the condition-1 probe | `403 NOT_OVERRIDABLE`; B's override stays | `200`, B's override removed (runtime-only), A's untouched; every listed and execution-view entry of the name is its own package's | unchanged: `200`, removed | | `revertCommit` of a commit into `B.custom` (restore limb; the per-item rollback shares `restoreWriteFor`); pinned for a flow | item in `failed[]`, `NOT_OVERRIDABLE`; nothing restored | restored as the pair's declared override | unchanged: restored | | boot census `metadata_sealed_overlay_unserved` (`loadMetaFromDb`), a flow or an action only | named B's live declared override as unserved, to delete | not named | unchanged: not named | Every row is the `widening` arm (epic ruling 6819293900 condition 2). With one of the two holders disabled (ADR-0150 D3) the bare-name answer is still the first-registered holder, so the same three answers moved the same way whichever holder is disabled; a binding never moves with a reversible disable. Unchanged in both: a row of a package that is no shipper's pair keeps its removal `403` and is still named by the census. The census judges a row as the reads serve it (`declinesStoredRow`). Since #32613 (#33126) the reads serve a second holder's declared override per shipper for a flow and an action only, so the census moves for those two types alone. A page, app, dataset, doc, book or mapping keeps the name's first-registered shipper in the census, as in the reads, until #33131 moves them: the second holder's override of such a name is still named (review 6859128505 s1). Files: `protocol-environment-rows.ts` (+`someShipperOf`), `protocol-diff-delete-load.ts` (removal judgement; census, per shipper for a flow and an action), `protocol-class-head.ts` (`restoreWriteFor`), the changeset, and the pins in `packages/objectql/src/protocol-flow-custom-override.test.ts`. ## Tests `packages/objectql/src/protocol-flow-custom-override.test.ts`, describe `[#32552]`, each in both registration orders: - `?package=B.custom` removes B's override, never A's (and the mirror order). - CONTROL: removing a row of a package that is neither holder's pair keeps its refusal. - each holder's commit into its own pair reverts. - the boot census names no holder's declared override as unserved, and still names a stranger's row. - epic ruling 6819293900 condition 1 probe: after the second holder's override is removed, every listed flow and action is its own package's, beside a package-less row of the name. - with each holder disabled in turn: each holder's pair removal and commit revert are admitted, and the census names neither. - CONTROL (new this round): two holders' declared mapping overrides; the census still names the second-registered holder's, `mapping×1`, in both orders. - CONTROL, one holder disabled, and CONTROL, one holder: removal, revert and census answer as before. Ablation, two legs on head `d311b66322`, each rebuilt with `ablation-dist-preflight` proving the mutation reached `dist/`, restored by `git checkout HEAD` with HEAD blob hashes matched and a clean whole-tree `git status`: - Leg A, the census type restriction removed (`perShipperType = true`, marker present in 2 built files): **2 failed / 43 passed of 45**, exactly the two mapping CONTROLs: `AssertionError: expected [] to have a length of 1 but got +0`. - Leg B, the fix's three source files put back to `origin/main` (`someShipperOf` absent from all 24 built files): **12 failed / 33 passed of 45**, every two-holder pin red, every CONTROL green; quoted `Serialized Error: { code: 'NOT_OVERRIDABLE', status: 403 }`. - Restore: rebuilt, `someShipperOf` present and the leg-A marker absent in `dist/`, 45/45. ## Acceptance notes - This branch resumes `claude/project-thread-31hd5y@d4d3241` and merges `origin/main` at `c35a911b30`, and again at `ae11537eae` after #33126 landed (no conflict). The branch had carried PR #32815's round-3 head; the four conflicts (`objectql/src/registry.ts`, the two `package-scoped-*` test files, `18.pair-row-locale-addition-refused.ts`) each take main's landed copy (`e336a33eb`), and the two `32408-*` changesets stay deleted (consumed by version packages #29963). The diff against `main` is the card's five files only. - The census row overlaps #32859 (blocked by this card): after this lands, the census no longer names a second holder's served declared flow or action override. The seat judges whether #32859's remainder still stands; this PR does not close it. - Epic ruling 6819293900 condition 3: #32613 has landed (#33126) and is in this head; #32568 is closed. - Round 2 answers contract review 6859128505: s1 (census in step with #33126's served set, table names the census row's types) and n1 (each row names what it is pinned on). - #32561 shares `objectql/src/registry.ts` and the migration entry and waits for this card; this PR no longer touches either. ## Verification All local readings on head `d311b66322`. <details><summary>Affected suites and typecheck</summary> - `pnpm --filter @objectstack/metadata-protocol test`: Test Files 337 passed, 7 skipped (344); Tests 22803 passed, 36 skipped. `typecheck` exit 0. Lock `VERDICT command-exit 0`. - `pnpm --filter @objectstack/objectql test`: Test Files 595 passed (595); Tests 12851 passed (12851). `typecheck` exit 0. Lock `VERDICT command-exit 0`. - Focused file: 45/45. </details> <details><summary>dispatch-gates</summary> `node scripts/pm/dispatch-gates.mjs --commands` derived 69 commands from 5 paths vs merge base `bf02d33bd`, all 69 exit 0 (`check:dual-build-cjs-loads` measured this round: 123 require entry points across 72 packages load). `dispatch-gates --ran`: "69 derived famil(ies) accounted for — 69 run, 0 NOT-MEASURED (a DERIVED zero — all 69 recorded an exit code and none of them is 3)". ```text node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0 node scripts/check-adr-0087-registration.mjs --self-test :: exit 0 node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0 node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-adoption.mjs :: exit 0 node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/check-dts-emitted.mjs --self-test :: exit 0 node scripts/check-empty-changeset.mjs --base origin/main :: exit 0 node scripts/check-empty-changeset.mjs --self-test :: exit 0 node scripts/check-engine-split-ratio.mjs --self-test :: exit 0 node scripts/check-issue-citations.mjs :: exit 0 node scripts/check-plugin-teardown-shape.mjs :: exit 0 node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0 node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0 node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0 node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0 node scripts/ci/snapshot-next.mjs --self-test :: exit 0 node scripts/docs-audit/check-affected-docs.mjs :: exit 0 node scripts/docs-audit/check-drift-comment.mjs :: exit 0 node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0 node scripts/release-pending-publish.mjs --self-test :: exit 0 pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0 pnpm --filter @objectstack/spec run check:error-code-provenance :: exit 0 pnpm check:adr-symbol-anchors :: exit 0 pnpm check:changeset-gate-self-tests :: exit 0 pnpm check:ci-filter-parity :: exit 0 pnpm check:closed-ceremony-text :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:dispatcher-error-vocabulary :: exit 0 pnpm check:doc-authoring :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:dts-closure :: exit 0 pnpm check:dual-build-cjs-loads :: exit 0 pnpm check:durability-log-level :: exit 0 pnpm check:engine-double-contract :: exit 0 pnpm check:error-status-conformance :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:init-service-contract :: exit 0 pnpm check:issue-citations :: exit 0 pnpm check:keyed-text-bounds :: exit 0 pnpm check:lean-entry-closure :: exit 0 pnpm check:logger-receiver-detach :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:object-def-param-keys :: exit 0 pnpm check:objectql-double-limit :: exit 0 pnpm check:optional-error-sink :: exit 0 pnpm check:org-identifier :: exit 0 pnpm check:page-declaration-shape :: exit 0 pnpm check:platform-object-tenancy-census :: exit 0 pnpm check:published-files :: exit 0 pnpm check:query-options-erasure :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:registry-log-declared :: exit 0 pnpm check:rest-log-spy-declared :: exit 0 pnpm check:settings-bind-window :: exit 0 pnpm check:slot-lookup :: exit 0 pnpm check:sourcemap-no-sources-content :: exit 0 pnpm check:startup-registry-verdict :: exit 0 pnpm check:system-context-census :: exit 0 pnpm check:test-source-alias :: exit 0 pnpm check:tier-file-adoption :: exit 0 pnpm check:type-check-coverage :: exit 0 pnpm check:type-check-debt :: exit 0 pnpm check:undeclared-dep-imports :: exit 0 pnpm check:vouch-for-reference-callers :: exit 0 pnpm check:watch-hint-literal :: exit 0 pnpm check:where-matcher :: exit 0 ``` </details> <details><summary>Lint and dogfood</summary> - `eslint --no-inline-config` on the two TS files changed this round: exit 0. Round 1 `pnpm lint` on `c35a911b30`: exit 0. - Full dogfood, round 1 on `c35a911b30` (not owed: no `!`, no `(narrowing)` arm): Test Files 460 passed, 3 skipped (463); Tests 3874 passed, 42 skipped (3916); lock `VERDICT command-exit 0`. Not re-run for the census-only delta. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_016WV4cyN75XjF6J8fLtD21r)_ <!-- signed: epic:#31527#2 · os-elon-musk · session_016WV4czFhtRVZNBeHdQA6PW --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 40c73a8 commit 128b657

5 files changed

Lines changed: 400 additions & 16 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
---
4+
5+
fix(metadata-protocol): a customization pair's row of a name two namespaces hold is judged against its own base, whichever package registered first — its removal, its commit revert and the boot census (ADR-0150 D4)
6+
7+
Clause-②: yes (widening) — answers that refused or misreported the second-registered holder's declared override now admit or leave it, as they already did for the first. For a name two packages of two namespaces ship, each with its paired `.custom` holding a declared override (ADR-0146 D2), three answers depended on which package registered first, because each judged the pair's row against the one package the bare-name artifact lookup answers. Each is now judged against every package that ships the name. First-party callers in any of these positions: 0.
8+
Metadata-protocol: none
9+
10+
Every row below is the `widening` arm, is pinned in both registration orders in `@objectstack/objectql`'s `protocol-flow-custom-override.test.ts`, and keeps its one-holder answer (the one-holder CONTROL there):
11+
12+
| Door | Second-registered holder B, before | Now | One holder (CONTROL) |
13+
|:--|:--|:--|:--|
14+
| `DELETE /meta/TYPE/NAME?package=<B>.custom` (`deleteMetaItem`); pinned for a flow, and for an action in the list probe below | `403 NOT_OVERRIDABLE` "sealed against removal"; B's override stays | `200`: B's override row removed (runtime-only), A's untouched; afterwards every listed and execution-view entry of the name is its own package's | unchanged: `200`, removed |
15+
| `revertCommit` of a commit into `<B>.custom` (the restore limb; the per-item rollback shares the derivation); pinned for a flow | the item in `failed[]`, `NOT_OVERRIDABLE` "sealed against in-place edits"; nothing restored | restored, judged by the override write gate as the pair's declared override | unchanged: restored |
16+
| boot census `[metadata_sealed_overlay_unserved]` (`loadMetaFromDb`), a flow or an action only | named B's live declared override as an unserved row to delete | not named | unchanged: the override not named |
17+
18+
With one of the two holders disabled (ADR-0150 D3), the bare-name answer is still the first-registered holder, disabled or not, so the same three answers moved the same way whichever holder is disabled: each holder's pair removal and commit revert are admitted now, the disabled holder's pair included, and the census names neither override. A binding never moves with a reversible disable. Pinned in both registration orders with each holder disabled in turn, beside a one-holder disabled CONTROL (its removal and revert admitted, as before).
19+
20+
Unchanged in both: a row of a package that is no shipper's pair keeps its removal `403` and is still named by the census.
21+
22+
The census judges a row as the reads serve it (`declinesStoredRow`). The reads serve a second holder's declared override per shipper for a flow and an action only (#32613), so only those two types move here. A page, app, dataset, doc, book or mapping keeps the name's first-registered shipper in the census, as in the reads, until #33131 moves them: the second holder's override of such a name is still named, pinned for a mapping in both registration orders.
23+
24+
No shipper is picked: the row judged is always the one its own `package_id` names, and the judgement asks only whether that package is a pair of SOME package that ships the name. A name one package ships answers exactly as before (the bare-name answer is read first and alone while it holds).

‎packages/metadata-protocol/src/protocol-class-head.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { PLURAL_TO_SINGULAR } from '@objectstack/spec/shared';
4141
import type { IObjectQLEngine, IPubSub } from '@objectstack/spec/contracts';
4242
import { isPairOf } from '@objectstack/metadata-core';
4343
import { installedManifestsOfEngine } from './installed-manifests.js';
44+
import { someShipperOf } from './protocol-environment-rows.js';
4445
import { overrideWriteRefusalError } from './protocol-packaged-base-refusal.js';
4546
import { OBJECT_EXTENSION_TYPE, registrableObjectExtension } from './protocol-object-extension-item.js';
4647
import type { ObjectExtensionRegistry } from './protocol-object-extension-item.js';
@@ -201,13 +202,17 @@ export class ProtocolClassHeadFacet {
201202
* caller's `artifactBacked` decides the intent, and the body writer is
202203
* {@link restoredBodyWriter}'s alone.
203204
*/
204-
static restoreWriteFor(host: Pick<ProtocolHost, 'engine' | 'overrideWriteVerdict' | 'packagedArtifactOwner' | 'restoredBodyWriter'>, singularType: string,
205+
static restoreWriteFor(host: Pick<ProtocolHost, 'engine' | 'overrideWriteVerdict' | 'packagedArtifactOwner' | 'restoredBodyWriter' | 'shippedArtifactsOf'>, singularType: string,
205206
name: string,
206207
binding: string | null,
207208
artifactBacked: boolean,
208209
source: string,): { intent: 'override-artifact' | 'runtime-only'; deriveRestoredBody: (historyBody: unknown) => Promise<unknown> } {
209-
const owner = artifactBacked ? host.packagedArtifactOwner({ type: singularType, name }) : undefined;
210-
const pairRow = owner !== undefined && isPairOf(binding, owner, installedManifestsOfEngine(host.engine));
210+
// [ADR-0150 D4, #32552] The binding is judged against every package
211+
// that ships the name ({@link someShipperOf}): each namespace's holder
212+
// has its own pair, never only the shipper registered first.
213+
const installed = installedManifestsOfEngine(host.engine);
214+
const pairRow = artifactBacked && someShipperOf(host, singularType, name,
215+
(owner) => owner !== undefined && isPairOf(binding, owner, installed));
211216
const intent: 'override-artifact' | 'runtime-only' = artifactBacked && !pairRow ? 'override-artifact' : 'runtime-only';
212217
const writeRestored = host.restoredBodyWriter(singularType, name, binding, source);
213218
const deriveRestoredBody = pairRow

‎packages/metadata-protocol/src/protocol-diff-delete-load.ts‎

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ import { isMissingTableError } from '@objectstack/metadata/errors';
3939
import { PLURAL_TO_SINGULAR } from '@objectstack/spec/shared';
4040
import { isServedOverrideRowOf } from './served-override.js';
4141
import { installedManifestsOfEngine } from './installed-manifests.js';
42+
import { someShipperOf } from './protocol-environment-rows.js';
4243
import type { ServedOverrideRow } from './served-override.js';
4344
import { REFERENCE_SITES } from './reference-sites.js';
4445
import { computeMetadataDiagnostics } from './metadata-diagnostics.js';
4546
import { hasMetadataRedactor, redactMetadataItem } from './metadata-redaction.js';
4647
import { isPairRowRemoval } from './protocol-packaged-base-refusal.js';
47-
import { canonicalizeMetaRequestType } from './protocol-meta-type-schema.js';
48+
import { canonicalMetaType, canonicalizeMetaRequestType } from './protocol-meta-type-schema.js';
4849
import { boundPackageOf } from './protocol-package-bindings.js';
4950
import { remainingRowsPhrase } from './protocol-authoring-refusals.js';
5051
import { memberOption, mutationEventMember, resolveBundleMemberSelector } from './protocol-bundle-members.js';
@@ -391,7 +392,7 @@ export class ProtocolDiffDeleteLoadFacet {
391392
}
392393

393394
/** [#28355] The body of {@link deleteMetaItem} before its refusal audit; that method's docblock is the contract. */
394-
static async deleteMetaItemUnaudited(host: Pick<ProtocolHost, 'assertLockAllowsDelete' | 'dropObjectStorage' | 'dropStorageRemainingRowsRefusal' | 'emitMetadataMutation' | 'engine' | 'environmentId' | 'findEnvironmentRow' | 'getOverlayRepo' | 'isArtifactBacked' | 'isOverlayAllowed' | 'isRuntimeCreateAllowed' | 'metadataConflictRefusal' | 'originGatedRemovalRefusal' | 'packagedArtifactOwner' | 'packagedBaseRefusal' | 'packagelessAddress' | 'packagelessDraftAddress' | 'packagelessOverlayWriteRefusal' | 'recordMetadataAudit' | 'recordOptimisticConflictAudit' | 'refuseOrganizationScopedWrite' | 'refusePackagedBaseRemoval' | 'registryAllowsOverlay' | 'restoreArtifactRegistryView' | 'runMutationProjector' | 'shouldDropStorage' | 'storedParentForToken'>, request: DeleteMetaItemRequest): Promise<{
395+
static async deleteMetaItemUnaudited(host: Pick<ProtocolHost, 'assertLockAllowsDelete' | 'dropObjectStorage' | 'dropStorageRemainingRowsRefusal' | 'emitMetadataMutation' | 'engine' | 'environmentId' | 'findEnvironmentRow' | 'getOverlayRepo' | 'isArtifactBacked' | 'isOverlayAllowed' | 'isRuntimeCreateAllowed' | 'metadataConflictRefusal' | 'originGatedRemovalRefusal' | 'packagedArtifactOwner' | 'packagedBaseRefusal' | 'packagelessAddress' | 'packagelessDraftAddress' | 'packagelessOverlayWriteRefusal' | 'recordMetadataAudit' | 'recordOptimisticConflictAudit' | 'refuseOrganizationScopedWrite' | 'refusePackagedBaseRemoval' | 'registryAllowsOverlay' | 'restoreArtifactRegistryView' | 'runMutationProjector' | 'shippedArtifactsOf' | 'shouldDropStorage' | 'storedParentForToken'>, request: DeleteMetaItemRequest): Promise<{
395396
success: boolean;
396397
message?: string;
397398
reset?: boolean;
@@ -427,10 +428,13 @@ export class ProtocolDiffDeleteLoadFacet {
427428
// flow's armed) again. Admitted past the sealed-removal refusal and
428429
// told to the store as a runtime-only removal, as the declared save
429430
// is ({@link isPairRowRemoval}).
430-
const pairRowRemoval = isPairRowRemoval(
431-
request.type, host.packagedArtifactOwner({ type: request.type, name: request.name }), request.packageId,
432-
installedManifestsOfEngine(host.engine),
433-
);
431+
// [ADR-0150 D4, #32552] Judged against every package that ships the
432+
// name ({@link someShipperOf}): two namespaces' items of one name each
433+
// carry their own pair, so the pair named here is judged against its
434+
// own base, never against whichever shipper registered first.
435+
const installed = installedManifestsOfEngine(host.engine);
436+
const pairRowRemoval = someShipperOf(host, request.type, request.name,
437+
(base) => isPairRowRemoval(request.type, base, request.packageId, installed));
434438
// Two-tier authorization for delete (mirrors saveMetaItem).
435439
// • Artifact-backed item → delete becomes a tombstone overlay,
436440
// requires `allowEnvironmentOverlay`…
@@ -1105,7 +1109,7 @@ export class ProtocolDiffDeleteLoadFacet {
11051109
}
11061110

11071111
/** The body of `ObjectStackProtocolImplementation#loadMetaFromDb`; the method's docblock there is its contract. */
1108-
static async loadMetaFromDb(host: Pick<ProtocolHost, 'classifyObjectContribution' | 'convertStoredItem' | 'engine' | 'ensureOverlayMembersBackfilled' | 'findEnvironmentRows' | 'hydrateOverlayIntoRegistry' | 'isHostCodeDatasource' | 'isUnservedSealedOverlay' | 'overlayPackageMismatchError' | 'packagedArtifactOwner' | 'packagelessAddress' | 'reportPageRequiresAbsentAtLoad' | 'reportSealedOverlayRows' | 'resolveSduiManifest' | 'storeHydratedIntoRegistry'>): Promise<{ loaded: number; errors: number; invalid: number; storeUnavailable: boolean }> {
1112+
static async loadMetaFromDb(host: Pick<ProtocolHost, 'classifyObjectContribution' | 'convertStoredItem' | 'engine' | 'ensureOverlayMembersBackfilled' | 'findEnvironmentRows' | 'hydrateOverlayIntoRegistry' | 'isHostCodeDatasource' | 'isUnservedSealedOverlay' | 'overlayPackageMismatchError' | 'packagedArtifactOwner' | 'packagelessAddress' | 'reportPageRequiresAbsentAtLoad' | 'reportSealedOverlayRows' | 'resolveSduiManifest' | 'shippedArtifactsOf' | 'storeHydratedIntoRegistry'>): Promise<{ loaded: number; errors: number; invalid: number; storeUnavailable: boolean }> {
11091113
let loaded = 0;
11101114
let errors = 0;
11111115
let invalid = 0;
@@ -1173,13 +1177,25 @@ export class ProtocolDiffDeleteLoadFacet {
11731177
// would prescribe deleting the live customization. The
11741178
// one predicate, on the row's `package_id` column. The
11751179
// census only: what this loop loads is unchanged.
1180+
//
1181+
// [ADR-0150 D4, #32552] …judged as the reads judge it
1182+
// (`declinesStoredRow`): for a flow and an action
1183+
// against every package that ships the name
1184+
// ({@link someShipperOf}), so a second holder's
1185+
// served override is not named for deletion; for the
1186+
// six sealed types against the name's first-registered
1187+
// shipper alone, which is the only override the reads
1188+
// serve for them until #33131 moves them.
1189+
const servedOverrideOf = (base: string | undefined) => isServedOverrideRowOf(
1190+
record as ServedOverrideRow, base, installedManifestsOfEngine(host.engine),
1191+
);
1192+
const recordName = String(record.name);
1193+
const perShipperType = ['flow', 'action'].includes(canonicalMetaType(normalizedType));
11761194
if (
1177-
!host.isHostCodeDatasource(normalizedType, String(record.name))
1178-
&& !isServedOverrideRowOf(
1179-
record as ServedOverrideRow,
1180-
host.packagedArtifactOwner({ type: normalizedType, name: String(record.name) }),
1181-
installedManifestsOfEngine(host.engine),
1182-
)
1195+
!host.isHostCodeDatasource(normalizedType, recordName)
1196+
&& !(perShipperType
1197+
? someShipperOf(host, normalizedType, recordName, servedOverrideOf)
1198+
: servedOverrideOf(host.packagedArtifactOwner({ type: normalizedType, name: recordName })))
11831199
) {
11841200
sealedOverlays.push({ type: normalizedType, name: String(record.name) });
11851201
}

‎packages/metadata-protocol/src/protocol-environment-rows.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,33 @@ export function shippingPackageIds(shipped: readonly unknown[]): ReadonlySet<str
264264
return shippers;
265265
}
266266

267+
/**
268+
* [ADR-0150 D4, #32552] Whether `judge` holds for SOME code package that ships
269+
* `(type, name)`: the package the bare-name artifact lookup answers first (the
270+
* one-holder answer, read alone while it holds), then every shipper
271+
* ({@link shippingPackageIds} over `shippedArtifactsOf`).
272+
*
273+
* The question a pair's row asks of its base — is this row a declared
274+
* override of the item, may this removal or restore treat it as one — when two
275+
* namespaces' packages each ship the name (ADR-0150 D9): each holder has its
276+
* own pair, so a row is judged against its own base, never against whichever
277+
* shipper registered first. No shipper is picked: the row judged is the one
278+
* its own `package_id` names. A name one package ships answers exactly as the
279+
* bare lookup alone did.
280+
*/
281+
export function someShipperOf(
282+
host: {
283+
packagedArtifactOwner(request: { type: string; name: string }): string | undefined;
284+
shippedArtifactsOf(type: string, name: string): unknown[];
285+
},
286+
type: string,
287+
name: string,
288+
judge: (basePackageId: string | undefined) => boolean,
289+
): boolean {
290+
if (judge(host.packagedArtifactOwner({ type, name }))) return true;
291+
return [...shippingPackageIds(host.shippedArtifactsOf(type, name))].some((shipper) => judge(shipper));
292+
}
293+
267294
/**
268295
* [ADR-0146 D11] The READ-ONLY code packages that ship a name, sorted: the
269296
* {@link shippingPackageIds} of `shipped` less every package

0 commit comments

Comments
 (0)