Skip to content

Commit d311b66

Browse files
committed
fix(metadata-protocol): the boot census judges a second holder's override per shipper for a flow and an action only, as the reads serve it
The six sealed types keep the name's first-registered shipper in the census, as in the reads, until #33131; a mapping CONTROL pins it in both registration orders. The changeset table names what each row is pinned on. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cyN75XjF6J8fLtD21r
1 parent ae11537 commit d311b66

3 files changed

Lines changed: 60 additions & 13 deletions

File tree

‎.changeset/32552-pair-row-removal-every-shipper.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ Every row below is the `widening` arm, is pinned in both registration orders in
1111

1212
| Door | Second-registered holder B, before | Now | One holder (CONTROL) |
1313
|:--|:--|:--|:--|
14-
| `DELETE /meta/flow/NAME?package=<B>.custom` (`deleteMetaItem`), any open override type | `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) | 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`) | named B's live declared override as an unserved row to delete | not named | unchanged: the override not named |
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 |
1717

1818
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).
1919

2020
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.
2121

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+
2224
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-diff-delete-load.ts‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { REFERENCE_SITES } from './reference-sites.js';
4545
import { computeMetadataDiagnostics } from './metadata-diagnostics.js';
4646
import { hasMetadataRedactor, redactMetadataItem } from './metadata-redaction.js';
4747
import { isPairRowRemoval } from './protocol-packaged-base-refusal.js';
48-
import { canonicalizeMetaRequestType } from './protocol-meta-type-schema.js';
48+
import { canonicalMetaType, canonicalizeMetaRequestType } from './protocol-meta-type-schema.js';
4949
import { boundPackageOf } from './protocol-package-bindings.js';
5050
import { remainingRowsPhrase } from './protocol-authoring-refusals.js';
5151
import { memberOption, mutationEventMember, resolveBundleMemberSelector } from './protocol-bundle-members.js';
@@ -1177,13 +1177,25 @@ export class ProtocolDiffDeleteLoadFacet {
11771177
// would prescribe deleting the live customization. The
11781178
// one predicate, on the row's `package_id` column. The
11791179
// 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));
11801194
if (
1181-
!host.isHostCodeDatasource(normalizedType, String(record.name))
1182-
// [ADR-0150 D4, #32552] …judged against every
1183-
// package that ships the name ({@link someShipperOf}).
1184-
&& !someShipperOf(host, normalizedType, String(record.name), (base) => isServedOverrideRowOf(
1185-
record as ServedOverrideRow, base, installedManifestsOfEngine(host.engine),
1186-
))
1195+
!host.isHostCodeDatasource(normalizedType, recordName)
1196+
&& !(perShipperType
1197+
? someShipperOf(host, normalizedType, recordName, servedOverrideOf)
1198+
: servedOverrideOf(host.packagedArtifactOwner({ type: normalizedType, name: recordName })))
11871199
) {
11881200
sealedOverlays.push({ type: normalizedType, name: String(record.name) });
11891201
}

‎packages/objectql/src/protocol-flow-custom-override.test.ts‎

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,16 +783,23 @@ describe('[#32552] a pair\'s row of a name two namespaces hold is judged against
783783
const sharedAction = (label: string, extra: Record<string, unknown> = {}) => ({
784784
name: SHARED, label, type: 'script', body: { language: 'js', source: `return { ran: '${label}' };` }, ...extra,
785785
});
786-
const holderManifest = (id: string, ns: string) => ({
786+
/** An import mapping of one name, a sealed type that keeps the first-registered holder's judgment until #33131. */
787+
const MAPPING = 'shared_feed';
788+
const sharedMapping = (ns: string, label: string, extra: Record<string, unknown> = {}) => ({
789+
name: MAPPING, label, sourceFormat: 'csv', targetObject: `${ns}_task`,
790+
fieldMapping: [{ source: 'Title', target: 'title' }], mode: 'insert', ...extra,
791+
});
792+
const holderManifest = (id: string, ns: string, opts: { mapping?: boolean } = {}) => ({
787793
id, name: ns, version: '1.0.0', namespace: ns, type: 'app',
788794
objects: [{ name: `${ns}_task`, label: 'Task', sharingModel: 'private', fields: { title: { name: 'title', label: 'title', type: 'text' } } }],
789795
flows: [flowBody(`SHIPPED-${ns}`)],
790796
actions: [sharedAction(`SHIPPED-${ns}`)],
797+
...(opts.mapping ? { mappings: [sharedMapping(ns, `SHIPPED-${ns}`)] } : {}),
791798
});
792799
const nsOf = (id: string) => id.split('.').pop()!;
793800

794801
/** The holders registered in `holders`' order, each with its pair and its pair's declared flow and action overrides. */
795-
async function bootHolders(holders: readonly string[]) {
802+
async function bootHolders(holders: readonly string[], opts: { mapping?: boolean } = {}) {
796803
const engine = new ObjectQL();
797804
const { driver, stores } = makeMemoryDriver();
798805
engine.registerDriver(driver, true);
@@ -801,7 +808,7 @@ describe('[#32552] a pair\'s row of a name two namespaces hold is judged against
801808
for (const o of [SysMetadataHistoryObject, SysMetadataAuditObject, SysMetadataCommitObject]) {
802809
engine.registry.registerObject(o as any, 'test-package');
803810
}
804-
for (const id of holders) engine.registerApp(holderManifest(id, nsOf(id)));
811+
for (const id of holders) engine.registerApp(holderManifest(id, nsOf(id), opts));
805812
const protocol = new ObjectStackProtocolImplementation(engine, () => new Map());
806813
for (const base of holders) {
807814
await (protocol as any).installPackage({
@@ -906,6 +913,32 @@ describe('[#32552] a pair\'s row of a name two namespaces hold is judged against
906913
expect(named[0]).toContain(`flow×1 (${FLOW})`);
907914
});
908915

916+
// [#32552 review s1] The census judges a row as the reads serve it. The
917+
// reads serve a second holder's declared override per shipper for a flow
918+
// and an action only (#32613); the six sealed types keep the name's
919+
// first-registered shipper until #33131, so the second holder's mapping
920+
// override is unserved and the census still names it.
921+
it(`CONTROL, ${nsOf(first)} registered first: a sealed type's census keeps the first-registered holder's judgment (a mapping)`, async () => {
922+
const { engine, protocol } = await bootHolders(first === ALPHA ? [ALPHA, BETA] : [BETA, ALPHA], { mapping: true });
923+
for (const base of [ALPHA, BETA]) {
924+
await engine.insert('sys_metadata', {
925+
type: 'mapping', name: MAPPING, organization_id: null, package_id: `${base}.custom`,
926+
metadata: JSON.stringify(sharedMapping(nsOf(base), `OVERRIDE-${nsOf(base)}`, { overrides: { package: base, basedOn: '1.0.0' } })),
927+
state: 'active', version: 1,
928+
}, { context: { isSystem: true } });
929+
}
930+
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
931+
let named: string[];
932+
try {
933+
await (protocol as any).loadMetaFromDb();
934+
named = warn.mock.calls.map((c) => String(c[0])).filter((m) => m.includes('metadata_sealed_overlay_unserved'));
935+
} finally {
936+
warn.mockRestore();
937+
}
938+
expect(named).toHaveLength(1);
939+
expect(named[0]).toContain(`mapping×1 (${MAPPING})`);
940+
});
941+
909942

910943
it(`${nsOf(first)} registered first: 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`, async () => {
911944
const { engine, protocol } = await bootTwo(first);

0 commit comments

Comments
 (0)