Skip to content

Commit d059c60

Browse files
committed
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 <noreply@anthropic.com>
1 parent 742b244 commit d059c60

1 file changed

Lines changed: 28 additions & 6 deletions

File tree

‎packages/metadata-protocol/src/protocol-save.ts‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ import { overlayMemberValue } from './migrations/overlay-index.js';
9494
import { packagelessContentPackage, shippingPackageIds } from './protocol-environment-rows.js';
9595
import type { StoredOverlayRow } from './item-lock.js';
9696
import { installedManifestsOfEngine } from './installed-manifests.js';
97+
import { soleEnabledRowHolder } from './protocol-enabled-holders.js';
9798
import { packageScopedRefusalOf } from './protocol-meta-item-reads.js';
9899
import { pairsOf } from '@objectstack/metadata-core';
99100
import { BatchRowHealError, canJudgeBatchObjects, isBatchObjectType, readActiveBatchRow, settleBatchObjectRows, undoBatchRowWrite, undoOutcomeForLog, type WrittenBatchRow } from './batch-object-registration.js';
@@ -946,6 +947,26 @@ export class ProtocolSaveFacet {
946947
followedBase = base;
947948
}
948949
}
950+
// [#38753, ADR-0150 D3/D5, #32354] …or the one ENABLED holder the
951+
// read naming no package counts, where the ambiguous draft address's
952+
// rows are bound to a disabled package beside it
953+
// ({@link soleEnabledRowHolder}): the read serves that holder's item
954+
// and the bare publish save writes its row, so the draft save writes
955+
// its draft, as without the disabled package, and the disabled
956+
// package's rows stay where they are. Followed as the row-held base
957+
// above is, so the two rules below judge the package it inherits.
958+
// FROM (`main` 444dce61): refused `409` naming the disabled package
959+
// and the enabled one.
960+
if (draftAddress?.kind === 'ambiguous') {
961+
const sole = soleEnabledRowHolder(
962+
host, singularType, request.name, itemDiscriminator(singularType, request.item), draftAddress.candidates,
963+
);
964+
if (sole !== undefined) {
965+
request = { ...request, packageId: sole };
966+
draftAddress = undefined;
967+
followedBase = sole;
968+
}
969+
}
949970
// [#34346, ADR-0150 D3/D5] …and an ambiguous draft address whose
950971
// rows are bound to a disabled package too is refused naming the
951972
// holders the read naming no package counts, never the disabled one
@@ -3643,14 +3664,15 @@ export async function packagelessRowHeldBaseDraftAddress(
36433664
* registry without the reads.
36443665
*
36453666
* [#34346] With two or more ENABLED shippers and a disabled holder, the draft
3646-
* save and the delete take their address from the rows, so their refusal of
3647-
* rows bound to two or more packages is judged by
3667+
* save, the delete and the draft discard take their address from the rows, so
3668+
* their refusal of rows bound to two or more packages is judged by
36483669
* {@link disabledRowHoldersRefusal}, which never names the disabled package.
36493670
*
3650-
* Known gap (#38753): with ONE enabled shipper and the rows bound to it and to
3651-
* a disabled package, that helper answers `undefined` and the draft save and
3652-
* the delete still refuse `409` naming the disabled package, where the read
3653-
* serves the enabled shipper and the publish save writes its row.
3671+
* [#38753] With ONE enabled holder and the rows bound to it and to a disabled
3672+
* package, the draft save, the delete and the draft discard act at that
3673+
* holder's address first (`soleEnabledRowHolder`), where the read serves it
3674+
* and the publish save writes its row, so none of them reaches that refusal
3675+
* or names the disabled package.
36543676
*/
36553677
export function packagelessHolderRefusal(
36563678
host: Pick<ProtocolHost, 'engine' | 'shippedArtifactsOf'>,

0 commit comments

Comments
 (0)