From 742b24423170cbeedcc40f820e5d8c37431abfd0 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 2 Dec 2026 03:36:11 +0000 Subject: [PATCH 1/3] test(rest): pin the bare draft save beside a disabled package's rows and the one enabled shipper (red) The draft save naming no package, where the item's rows are bound to a disabled package D and to E, the only enabled shipper, answers as without D: it writes E's draft and leaves D's rows byte-unchanged. Red on main: 409 RESOURCE_CONFLICT naming D and E. The CONTROL with a second enabled shipper now also pins the draft save's refusal naming the two enabled shippers, never D. Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude --- .../src/meta-disabled-package-doors.test.ts | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/packages/rest/src/meta-disabled-package-doors.test.ts b/packages/rest/src/meta-disabled-package-doors.test.ts index f2f02875947..ab54158c41c 100644 --- a/packages/rest/src/meta-disabled-package-doors.test.ts +++ b/packages/rest/src/meta-disabled-package-doors.test.ts @@ -1485,8 +1485,9 @@ describe('[#37915] RestServer: the history naming no package of a name only a di * and the bare draft discard act at E's address, as without D, and D's rows * stay byte-unchanged. FROM (`main` 8338d070, measured on this fixture, both * save orders, D shipping the name in code or not): both refused `409 - * RESOURCE_CONFLICT` naming D and E. The bare draft save still refuses - * naming both: its judgment sits in a file this change does not edit. + * RESOURCE_CONFLICT` naming D and E. The bare draft save too writes E's + * draft, as without D; FROM (`main` 444dce61): it refused `409` naming D + * and E. */ describe('[#38753] RestServer: the bare delete and draft discard beside a disabled package\'s rows and the one enabled shipper', () => { const lay = (host: ReturnType, pkg: string, label: string, state: 'active' | 'draft') => (host.protocol as any).engine.insert('sys_metadata', { @@ -1534,7 +1535,31 @@ describe('[#38753] RestServer: the bare delete and draft discard beside a disabl expect(effects[0].deleted.map((row) => row.split(':').slice(0, 2).join(':'))).toEqual([`active:${OTHER_PKG}`]); }, 60_000); - it('CONTROL — a second enabled shipper: the bare delete and draft discard still refuse 409 naming the two enabled shippers, never D, and nothing is removed', async () => { + it.each(CELLS)('%s: the bare draft save writes E\'s draft, as without D, never 409 naming D, and D\'s rows stay', async (_label, order, disabledShips) => { + const effects: Array<{ removed: string[]; added: string[] }> = []; + for (const withD of [true, false]) { + const host = await boot(order, withD, disabledShips); + const before = await rowsOf(host); + const saved = await (host.protocol as any).saveMetaItem({ + type: 'dashboard', name: 'one_shipper_dash', mode: 'draft', + item: { name: 'one_shipper_dash', label: 'edited draft', widgets: [] }, + }).catch((error: any) => ({ refused: `${error?.code}:${error?.status ?? error?.httpStatus}:${error?.message}` })); + expect([withD, saved?.refused], String(saved?.refused)).toEqual([withD, undefined]); + const after = await rowsOf(host); + effects.push({ + removed: before.filter((row) => !after.includes(row)), + added: after.filter((row) => !before.includes(row)), + }); + // D's rows, both states, byte-unchanged. + expect(after.filter((row) => row.includes(`:${PKG}:`)), 'D\'s rows').toEqual(before.filter((row) => row.includes(`:${PKG}:`))); + } + expect(effects[0], JSON.stringify(effects)).toEqual(effects[1]); + expect(effects[0].removed.map((row) => row.split(':').slice(0, 2).join(':'))).toEqual([`draft:${OTHER_PKG}`]); + expect(effects[0].added.map((row) => row.split(':').slice(0, 2).join(':'))).toEqual([`draft:${OTHER_PKG}`]); + expect(effects[0].added.join('\n')).toContain('edited draft'); + }, 60_000); + + it('CONTROL — a second enabled shipper: the bare delete, draft discard and draft save still refuse 409 naming the two enabled shippers, never D, and nothing is written', async () => { const THIRD_PKG = 'app.third_demo'; const host = await boot([PKG, OTHER_PKG], true, true); host.registry.installPackage({ id: THIRD_PKG, name: THIRD_PKG, version: '1.0.0' } as any, 'code'); @@ -1547,6 +1572,16 @@ describe('[#38753] RestServer: the bare delete and draft discard beside a disabl for (const pkg of [OTHER_PKG, THIRD_PKG]) expect(String(refusal?.message)).toContain(pkg); expect(String(refusal?.message)).not.toContain(PKG); } + let saveRefusal: any; + try { + await (host.protocol as any).saveMetaItem({ + type: 'dashboard', name: 'one_shipper_dash', mode: 'draft', + item: { name: 'one_shipper_dash', label: 'edited draft', widgets: [] }, + }); + } catch (error) { saveRefusal = error; } + expect([saveRefusal?.code, saveRefusal?.status ?? saveRefusal?.httpStatus], String(saveRefusal?.message)).toEqual(['RESOURCE_CONFLICT', 409]); + for (const pkg of [OTHER_PKG, THIRD_PKG]) expect(String(saveRefusal?.message)).toContain(pkg); + expect(String(saveRefusal?.message)).not.toContain(PKG); expect(await rowsOf(host)).toEqual(before); }, 60_000); From d059c60f2aa5e868678507bd41db89c94bff876f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 2 Dec 2026 03:41:26 +0000 Subject: [PATCH 2/3] fix(metadata-protocol): the bare draft save acts at the one enabled holder beside a disabled package's rows Where a draft save naming no package finds its draft address ambiguous because the rows are bound to a disabled package and to the one enabled holder the read naming no package counts, it now writes that holder's draft (soleEnabledRowHolder), followed as the row-held base is, instead of refusing 409 naming the disabled package. The packagelessHolderRefusal docblock's known-gap paragraph is reworded: the delete, the draft discard and now the draft save all act at that holder first. Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude --- .../metadata-protocol/src/protocol-save.ts | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/packages/metadata-protocol/src/protocol-save.ts b/packages/metadata-protocol/src/protocol-save.ts index 8ade7ae2f33..a319a51b134 100644 --- a/packages/metadata-protocol/src/protocol-save.ts +++ b/packages/metadata-protocol/src/protocol-save.ts @@ -94,6 +94,7 @@ import { overlayMemberValue } from './migrations/overlay-index.js'; import { packagelessContentPackage, shippingPackageIds } from './protocol-environment-rows.js'; import type { StoredOverlayRow } from './item-lock.js'; import { installedManifestsOfEngine } from './installed-manifests.js'; +import { soleEnabledRowHolder } from './protocol-enabled-holders.js'; import { packageScopedRefusalOf } from './protocol-meta-item-reads.js'; import { pairsOf } from '@objectstack/metadata-core'; import { BatchRowHealError, canJudgeBatchObjects, isBatchObjectType, readActiveBatchRow, settleBatchObjectRows, undoBatchRowWrite, undoOutcomeForLog, type WrittenBatchRow } from './batch-object-registration.js'; @@ -946,6 +947,26 @@ export class ProtocolSaveFacet { followedBase = base; } } + // [#38753, ADR-0150 D3/D5, #32354] …or the one ENABLED holder the + // read naming no package counts, where the ambiguous draft address's + // rows are bound to a disabled package beside it + // ({@link soleEnabledRowHolder}): the read serves that holder's item + // and the bare publish save writes its row, so the draft save writes + // its draft, as without the disabled package, and the disabled + // package's rows stay where they are. Followed as the row-held base + // above is, so the two rules below judge the package it inherits. + // FROM (`main` 444dce61): refused `409` naming the disabled package + // and the enabled one. + if (draftAddress?.kind === 'ambiguous') { + const sole = soleEnabledRowHolder( + host, singularType, request.name, itemDiscriminator(singularType, request.item), draftAddress.candidates, + ); + if (sole !== undefined) { + request = { ...request, packageId: sole }; + draftAddress = undefined; + followedBase = sole; + } + } // [#34346, ADR-0150 D3/D5] …and an ambiguous draft address whose // rows are bound to a disabled package too is refused naming the // holders the read naming no package counts, never the disabled one @@ -3643,14 +3664,15 @@ export async function packagelessRowHeldBaseDraftAddress( * registry without the reads. * * [#34346] With two or more ENABLED shippers and a disabled holder, the draft - * save and the delete take their address from the rows, so their refusal of - * rows bound to two or more packages is judged by + * save, the delete and the draft discard take their address from the rows, so + * their refusal of rows bound to two or more packages is judged by * {@link disabledRowHoldersRefusal}, which never names the disabled package. * - * Known gap (#38753): with ONE enabled shipper and the rows bound to it and to - * a disabled package, that helper answers `undefined` and the draft save and - * the delete still refuse `409` naming the disabled package, where the read - * serves the enabled shipper and the publish save writes its row. + * [#38753] With ONE enabled holder and the rows bound to it and to a disabled + * package, the draft save, the delete and the draft discard act at that + * holder's address first (`soleEnabledRowHolder`), where the read serves it + * and the publish save writes its row, so none of them reaches that refusal + * or names the disabled package. */ export function packagelessHolderRefusal( host: Pick, From 4fecd5938b0e9b892fca8e7ef1c21cdf407f91e2 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 2 Dec 2026 03:43:25 +0000 Subject: [PATCH 3/3] chore(changeset): the bare draft save beside a disabled package's rows Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude --- .changeset/38753-draft-save-cell.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .changeset/38753-draft-save-cell.md diff --git a/.changeset/38753-draft-save-cell.md b/.changeset/38753-draft-save-cell.md new file mode 100644 index 00000000000..7b3756af540 --- /dev/null +++ b/.changeset/38753-draft-save-cell.md @@ -0,0 +1,10 @@ +--- +'@objectstack/metadata-protocol': patch +--- + +fix(metadata-protocol): the draft save naming no package beside a disabled package's rows writes the one enabled holder's draft + +Clause-②: no +Metadata-protocol: none + +A draft save that names no package, of an item whose stored rows are bound to a disabled package and to the one enabled package that holds the name, now writes that enabled package's draft, as it does when the disabled package is not installed. The disabled package's rows stay as they are. Before, the save was refused `409 RESOURCE_CONFLICT` naming both packages, the disabled one among them, while the read naming no package served the enabled package's item and the publish save wrote its row. The bare delete and draft discard already act at that package's address. Where two or more enabled packages hold the name, the draft save is still refused naming only those packages.