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
14 changes: 14 additions & 0 deletions .changeset/32620-non-holder-row-bare-slot-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@objectstack/metadata-protocol': patch
---

fix(metadata-protocol): after a deployment removes its customization of a name two packages ship, the deleted body is no longer served from the registry until the next reload

Clause-②: no
Metadata-protocol: none

The case: a stored row bound to an installed package that ships no item of the name (an App's customization, ADR-0146), on a name two packages ship, where the pair relation names no single base. After that row was deleted, the registry heal's baseline read was refused (two holders), and the heal stopped with an `error` line. For a `flow` or a `permission`, whose bound row sits in the name's bare registry slot, the removed row's entry stayed there. Until the next reload, a read naming the customizing package served the deleted body, and a read naming either holder was refused with that package as its candidate, although its row no longer existed.

The heal now retires that entry, as it already did for a package-less row (seat ruling 6812637203 Q2). Entry kept → retired, on the epic seat's ruling 6818436831. Retiring picks no holder and registers no baseline. Each holder's read answers its own item again, the read naming no package is the 409 naming both holders, and the list shows the two holders only. The retire verb still refuses a packaged artifact, so no holder's item can be removed.

The other package-scoped types already retired the bound row's own package slot. For them only the `error` line changes: it now says that slot was retired, where it said the entry was left as it was. A peer replica converging on a cluster signal that names no package still keeps the logged stop, because it cannot tell whose entry the bare slot holds.
53 changes: 36 additions & 17 deletions packages/metadata-protocol/src/protocol-registry-hydration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,24 @@ import { ObjectStackProtocolImplementationStatics as ObjectStackProtocolImplemen
* hold) is named as one, with the package the refused read named as the store
* read it (its `callerPackageId`: a package-less read is "no package") and the
* holders its message lists. `entry` says what became of the registry entry:
* left as it was, retired from the bare slot (a refused package-less heal,
* seat ruling 6812637203 Q2), or none retired because the verb removed nothing
* (an empty slot, or a packaged artifact it refuses).
* left as it was, retired from the bare slot (a refused package-less or
* non-holder heal, seat ruling 6812637203 Q2 and epic ruling 6818436831),
* retired from the removed row's own package slot only (#32620: the bare slot
* held none the heal may remove), or none retired because the verb removed
* nothing (an empty slot, or a packaged artifact it refuses).
*/
function registryHealStoppedMessage(type: string, name: string, error: unknown, entry: 'kept' | 'retired' | 'none-retired' = 'kept'): string {
function registryHealStoppedMessage(type: string, name: string, error: unknown, entry: 'kept' | 'retired' | 'slot-retired' | 'none-retired' = 'kept'): string {
const reason = error instanceof Error ? error.message : String(error);
const refusal = packageScopedRefusalOf(error);
const named = boundPackageOf(refusal?.callerPackageId);
const why = refusal !== undefined
? `the metadata service refused the baseline read, which named ${named === undefined ? 'no package' : `package '${named}'`}: ${reason}`
: reason;
if (entry === 'slot-retired') {
return `[Protocol] the registry heal after the removal of ${type} '${name}' stopped: ${why}. `
+ 'The removed row\'s registry entry was retired from its own package\'s slot, the bare slot held none the heal may '
+ 'remove, and no baseline was registered, so a read naming no package answers the store\'s refusal naming every holder.';
}
if (entry === 'none-retired') {
return `[Protocol] the registry heal after the removal of ${type} '${name}' stopped: ${why}. `
+ 'No registry entry was retired, because the bare slot held none the heal may remove (it was empty, or it holds a '
Expand Down Expand Up @@ -125,7 +132,8 @@ type ServiceRead = { data: unknown; degraded: boolean; errors: string[] };
* package candidate the refusal lists is asked whether the removal is a pair
* row of theirs ({@link isPairRowRemoval}, the delete door's own predicate).
* Exactly one base ⇒ its baseline. Otherwise the refusal stands, and the
* walk stops with it, logged;
* walk stops with it, logged, retiring the removed row's bare-slot entry
* (epic ruling 6818436831, #32620);
* - no holder at all (a clean miss) ⇒ the settled miss stands, and the walk
* goes on to tier 3: the row was the item;
* - a degraded read ⇒ degraded: the walk stops without retiring.
Expand Down Expand Up @@ -1711,7 +1719,8 @@ export class ProtocolRegistryHydrationFacet {
* {@link HEAL_BINDING_UNKNOWN} when it never learns the binding (a peer
* converging on a cluster signal that names no package: one from a
* replica that predates the signal's `packageId`, #32451). Both read with
* no package; only `null` retires on a refusal (below). A peer whose
* no package; only `null` retires on a refusal, as a known binding does
* (below), and {@link HEAL_BINDING_UNKNOWN} never. A peer whose
* signal names the package passes that package, as the writer did.
*
* Best-effort: a failure must never block the delete that already
Expand All @@ -1722,7 +1731,9 @@ export class ProtocolRegistryHydrationFacet {
* baseline read is named as one, with the holders it lists. For a
* package-less row that refusal also retires the removed row's bare-slot
* entry and registers no baseline (seat ruling 6812637203 Q2): the next read
* naming no package answers the store's refusal, naming every holder.
* naming no package answers the store's refusal, naming every holder. So it
* does for a row bound to a non-holder of the name whose pair relation names
* zero or several bases (epic ruling 6818436831, #32620).
*/
static async restoreArtifactRegistryView(host: Pick<ProtocolHost, 'anotherPackageShips' | 'applyRegistryWriteThrough' | 'convertStoredItem' | 'engine' | 'findEnvironmentRows' | 'isArtifactBacked' | 'isUnservedSealedOverlay' | 'readItemFromMetadataService' | 'reconcileViewExpansions' | 'registryTakesStoredRows' | 'resyncStoredObjectExtensions' | 'rethrowUnlessMetadataStoreUnprovisioned'>, type: string,
name: string,
Expand Down Expand Up @@ -1909,22 +1920,30 @@ export class ProtocolRegistryHydrationFacet {
// baseline is registered. A read naming no package then answers
// the store's refusal, which names every holder, instead of the
// removed row's body. `removeOverlayEntry` keeps refusing a
// packaged artifact, as on tier 3. A row bound to a package keeps
// the logged stop ({@link readHealBaseline}); the ruling names
// the package-less heal only. So does a caller that does not know
// the binding ({@link HEAL_BINDING_UNKNOWN}, a peer on a
// cluster signal naming no package): it cannot tell the removed
// row was the package-less one.
if (packageId === HEAL_BINDING_UNKNOWN || boundPackageOf(packageId) !== undefined
|| packageScopedRefusalOf(error) === undefined) throw error;
// packaged artifact, as on tier 3.
// [#32620, epic ruling 6818436831] …and so does a row bound to a
// NON-HOLDER (a package holding no item of the name, ADR-0146),
// where the pair relation names zero or several bases: the only
// refusal {@link readHealBaseline} lets through for a bound row.
// Its entry sits in the bare slot for a type with no package
// overlay slot (`flow`, `permission`), where it kept serving the
// deleted body to the non-holder's read and stood as a refused
// holder read's candidate. Retiring it picks nobody and restores
// each holder's exact address (entry kept → retired).
// A caller that does not know the binding
// ({@link HEAL_BINDING_UNKNOWN}, a peer on a cluster signal
// naming no package) keeps the logged stop: it cannot tell
// whose entry the bare slot holds.
if (packageId === HEAL_BINDING_UNKNOWN || packageScopedRefusalOf(error) === undefined) throw error;
// What the verb answers is what the line says: an empty slot, or
// a packaged artifact the verb refuses, retires nothing.
// a packaged artifact the verb refuses, retires nothing. A bound
// row's own package slot, retired above, is said too.
let retired = false;
if (typeof registry.removeOverlayEntry === 'function') {
retired = registry.removeOverlayEntry(singular, name, memberKey) === true;
if (type !== singular) retired = registry.removeOverlayEntry(type, name, memberKey) === true || retired;
}
console.error(registryHealStoppedMessage(type, name, error, retired ? 'retired' : 'none-retired'));
console.error(registryHealStoppedMessage(type, name, error, retired ? 'retired' : slotRetired ? 'slot-retired' : 'none-retired'));
return;
}
// [#22877] A baseline of ANOTHER member is no baseline of this one:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,19 +295,32 @@ describe('[#32366 S1, ADR-0146] a row bound to a package that holds no item of t
expect(healLines(h.logged)).toEqual([]);
});

it('a row of a package that pairs no holder, on a name two packages hold: the refusal stands and is logged, nothing picked or retired', async () => {
it('a row of a package that pairs no holder, on a name two packages hold: the refusal is logged, nothing is picked, and the removed row\'s bare-slot entry is retired', async () => {
const h = makeHarness({ rows: [overlayRow(OTHER)], holders: [[ALPHA, 'alpha'], [BETA, 'beta']], installed: [OTHER] });

const result = await h.protocol.deleteMetaItem({ type: 'action', name: NAME, packageId: OTHER });

expect(result.success).toBe(true);
// A row bound to a package keeps the logged stop: the Q2 retirement
// names the package-less heal only.
expect(tiers(h)).toEqual({ tier1: [false], tier2: [], tier3: [] });
// [#32620, epic ruling 6818436831] Retired as the Q2 package-less row
// is (at a557fa38: kept, `tier3: []`); no holder's baseline is picked.
expect(tiers(h)).toEqual({ tier1: [false], tier2: [], tier3: [`action|${NAME}`] });
const lines = healLines(h.logged);
expect(lines).toHaveLength(1);
expect(lines[0]).toContain(ALPHA);
expect(lines[0]).toContain(BETA);
expect(lines[0]).toContain('was retired from the bare slot');
});

it('…and when the verb removes nothing for that row (an empty bare slot, or a packaged artifact): the line says no entry was retired', async () => {
const h = makeHarness({ rows: [overlayRow(OTHER)], holders: [[ALPHA, 'alpha'], [BETA, 'beta']], installed: [OTHER], retireAnswers: false });

await h.protocol.deleteMetaItem({ type: 'action', name: NAME, packageId: OTHER });

// The verb was asked and removed nothing: the line says so.
expect(tiers(h)).toEqual({ tier1: [false], tier2: [], tier3: [`action|${NAME}`] });
const lines = healLines(h.logged);
expect(lines).toHaveLength(1);
expect(lines[0]).toContain('No registry entry was retired');
});

it('CONTROL — no package holds the name: the row was the item, and tier 3 retires its entry', async () => {
Expand Down
Loading
Loading