Skip to content

Commit d72c980

Browse files
committed
refactor(metadata-protocol): keep non-private inferred-return methods in protocol.ts and widen the by-path censuses
The declaration bar on the built .d.ts refused the previous split: moving getDiscovery's body made the compiler re-infer its printed return type through the moved function, which dropped the @deprecated docblock on one key. The pilot's rule is back: a non-private method with an inferred return type stays. Regenerated: 61/284 methods move into 9 section modules; protocol.ts goes from 23135 to 15318 lines. The censuses that read protocol.ts by path now also read the modules the split moved bodies to, where the class is spelled host. instead of this. (ruling 6597555122): the recovery-door emit and projector counts, the write-through and registerItem caller sets, the lookupArtifactItem sites, the read-verb fold population (the signature is read off the class member, the fold off the moved body) and the stored-row write census of the view expansion reconcile. Claude-Session: https://claude.ai/code/session_01WGufzgddMBbTQd9yVo4Yuz Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c453e2f commit d72c980

17 files changed

Lines changed: 1733 additions & 1714 deletions

‎packages/metadata-protocol/src/protocol-data-crud.ts‎

Lines changed: 0 additions & 1008 deletions
This file was deleted.

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
/**
44
* [#29985 codemod] The "Diff, deleteMetaItem, loadMetaFromDb, load reports,
55
* findReferencesToMeta" section of `ObjectStackProtocolImplementation`: the
6-
* bodies of `diffMetaItem`, `deleteMetaItem`, `deleteMetaItemUnaudited`,
7-
* `loadMetaFromDb`, `findReferencesToMeta` moved out of `protocol.ts` whole by
6+
* bodies of `diffMetaItem`, `deleteMetaItemUnaudited`, `loadMetaFromDb`,
7+
* `findReferencesToMeta` moved out of `protocol.ts` whole by
88
* `scripts/codemod-split-protocol.mjs`.
99
*
1010
* A MOVE, not a redesign. Each function below is the body of the class method
@@ -40,7 +40,6 @@ import { REFERENCE_SITES } from './reference-sites.js';
4040
import { computeMetadataDiagnostics } from './metadata-diagnostics.js';
4141
import { hasMetadataRedactor, redactMetadataItem } from './metadata-redaction.js';
4242
import { isPairRowRemoval } from './protocol-packaged-base-refusal.js';
43-
import { withRefusalAudit } from './protocol-refusal-audit.js';
4443
import { canonicalizeMetaRequestType } from './protocol-meta-type-schema.js';
4544
import { remainingRowsPhrase } from './protocol-authoring-refusals.js';
4645
import { memberOption, mutationEventMember, resolveBundleMemberSelector } from './protocol-bundle-members.js';
@@ -367,15 +366,6 @@ export async function diffMetaItem(host: Pick<ProtocolHost, 'diffMetaItem' | 'fi
367366
};
368367
}
369368

370-
/** The body of `ObjectStackProtocolImplementation#deleteMetaItem`; the method's docblock there is its contract. */
371-
export async function deleteMetaItem(host: Pick<ProtocolHost, 'deleteMetaItemUnaudited' | 'recordMetadataAudit'>, request: DeleteMetaItemRequest) {
372-
// [#28355] A refusal that carries no row of its own leaves its `denied` row here.
373-
return withRefusalAudit((entry) => host.recordMetadataAudit(entry), {
374-
operation: 'delete', type: request.type, name: request.name, actor: request.actor,
375-
source: 'protocol.deleteMetaItem',
376-
}, () => host.deleteMetaItemUnaudited(request));
377-
}
378-
379369
/** The body of `ObjectStackProtocolImplementation#deleteMetaItemUnaudited`; the method's docblock there is its contract. */
380370
export async function 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<{
381371
success: boolean;

‎packages/metadata-protocol/src/protocol-discovery-and-bases.ts‎

Lines changed: 5 additions & 480 deletions
Large diffs are not rendered by default.

‎packages/metadata-protocol/src/protocol-history-and-publish.ts‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* [#29985 codemod] The "History, publish, drafts, publish backfill" section of
55
* `ObjectStackProtocolImplementation`: the bodies of `historyMetaItem`,
6-
* `publishMetaItem`, `publishMetaItemUnaudited`, `promoteDraftForPublish`,
6+
* `publishMetaItemUnaudited`, `promoteDraftForPublish`,
77
* `runPublishSideEffects`, `discardPackageDrafts` moved out of `protocol.ts`
88
* whole by `scripts/codemod-split-protocol.mjs`.
99
*
@@ -33,7 +33,6 @@ import type { OverrideWriteVerdict } from './protocol-packaged-base-refusal.js';
3333
import { objectBodyExtensionFieldSuffixRefusal } from './protocol-extension-field-suffix.js';
3434
import { storedFlowVerdictBody } from './protocol-flow-save-replay.js';
3535
import { datasourceCredentialsRefSaveRefusal } from './protocol-datasource-credentials-ref.js';
36-
import { withRefusalAudit } from './protocol-refusal-audit.js';
3736
import { canonicalizeMetaRequestType } from './protocol-meta-type-schema.js';
3837
import { packagelessPublishNoDraftRefusal, permissionSetOwnerBindingRefusal } from './protocol-authoring-refusals.js';
3938
import { memberOption, mutationEventMemberOfBody, resolveBundleMemberSelector } from './protocol-bundle-members.js';
@@ -141,15 +140,6 @@ export async function historyMetaItem(host: Pick<ProtocolHost, 'getOverlayRepo'
141140
return { events };
142141
}
143142

144-
/** The body of `ObjectStackProtocolImplementation#publishMetaItem`; the method's docblock there is its contract. */
145-
export async function publishMetaItem(host: Pick<ProtocolHost, 'publishMetaItemUnaudited' | 'recordMetadataAudit'>, request: PublishMetaItemRequest) {
146-
// [#28355] A refusal that carries no row of its own leaves its `denied` row here.
147-
return withRefusalAudit((entry) => host.recordMetadataAudit(entry), {
148-
operation: 'publish', type: request.type, name: request.name, actor: request.actor,
149-
source: 'protocol.publishMetaItem',
150-
}, () => host.publishMetaItemUnaudited(request));
151-
}
152-
153143
/** The body of `ObjectStackProtocolImplementation#publishMetaItemUnaudited`; the method's docblock there is its contract. */
154144
export async function publishMetaItemUnaudited(host: Pick<ProtocolHost, 'emitMetaItemPublished' | 'packagelessOverlayWriteRefusal' | 'promoteDraftForPublish' | 'receiptVersion' | 'recordMetadataAudit' | 'recordPendingDenialAudit' | 'refuseOrganizationScopedWrite' | 'refuseUngrammaticalMetaItemName' | 'runPublishSideEffects'>, request: PublishMetaItemRequest): Promise<{
155145
success: boolean;

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,10 @@ export interface ProtocolHost {
6161
readonly applyRemoteMetadataMutation: ObjectStackProtocolImplementation['applyRemoteMetadataMutation'];
6262
readonly applySeedBodies: ObjectStackProtocolImplementation['applySeedBodies'];
6363
readonly artifactLockLayerAt: ObjectStackProtocolImplementation['artifactLockLayerAt'];
64-
readonly assertAggregationFieldsExist: ObjectStackProtocolImplementation['assertAggregationFieldsExist'];
65-
readonly assertExpandTargetsExist: ObjectStackProtocolImplementation['assertExpandTargetsExist'];
66-
readonly assertFilterFieldsExist: ObjectStackProtocolImplementation['assertFilterFieldsExist'];
67-
readonly assertGroupByFieldsExist: ObjectStackProtocolImplementation['assertGroupByFieldsExist'];
6864
readonly assertLockAllowsDelete: ObjectStackProtocolImplementation['assertLockAllowsDelete'];
6965
readonly assertLockAllowsWrite: ObjectStackProtocolImplementation['assertLockAllowsWrite'];
70-
readonly assertNoInternalFieldEvaluated: ObjectStackProtocolImplementation['assertNoInternalFieldEvaluated'];
7166
readonly assertObjectRegistered: ObjectStackProtocolImplementation['assertObjectRegistered'];
72-
readonly assertProjectionFieldsExist: ObjectStackProtocolImplementation['assertProjectionFieldsExist'];
73-
readonly assertQueryParamsAreFields: ObjectStackProtocolImplementation['assertQueryParamsAreFields'];
7467
readonly assertRuntimeAuthoringRules: ObjectStackProtocolImplementation['assertRuntimeAuthoringRules'];
75-
readonly assertSearchFieldsAreSearchable: ObjectStackProtocolImplementation['assertSearchFieldsAreSearchable'];
76-
readonly assertSortFieldsExist: ObjectStackProtocolImplementation['assertSortFieldsExist'];
7768
readonly assertVersionMatch: ObjectStackProtocolImplementation['assertVersionMatch'];
7869
readonly authoredLockFamily: ObjectStackProtocolImplementation['authoredLockFamily'];
7970
readonly authoringChannel: ObjectStackProtocolImplementation['authoringChannel'];
@@ -91,7 +82,6 @@ export interface ProtocolHost {
9182
readonly credentialChannelFor: ObjectStackProtocolImplementation['credentialChannelFor'];
9283
readonly declinesStoredRow: ObjectStackProtocolImplementation['declinesStoredRow'];
9384
readonly defaultRecordPageSaveRefusal: ObjectStackProtocolImplementation['defaultRecordPageSaveRefusal'];
94-
readonly deleteMetaItemUnaudited: ObjectStackProtocolImplementation['deleteMetaItemUnaudited'];
9585
readonly detachMetadataMutationPubSub: ObjectStackProtocolImplementation['detachMetadataMutationPubSub'];
9686
readonly diffMetaItem: ObjectStackProtocolImplementation['diffMetaItem'];
9787
readonly disabledActionsOf: ObjectStackProtocolImplementation['disabledActionsOf'];
@@ -176,7 +166,6 @@ export interface ProtocolHost {
176166
readonly probeRecord: ObjectStackProtocolImplementation['probeRecord'];
177167
readonly promoteDraftForPublish: ObjectStackProtocolImplementation['promoteDraftForPublish'];
178168
readonly publishMaterializers: ObjectStackProtocolImplementation['publishMaterializers'];
179-
readonly publishMetaItemUnaudited: ObjectStackProtocolImplementation['publishMetaItemUnaudited'];
180169
readonly readActiveOverlayRows: ObjectStackProtocolImplementation['readActiveOverlayRows'];
181170
readonly readFlattenedMetaItems: ObjectStackProtocolImplementation['readFlattenedMetaItems'];
182171
readonly readItemActiveRows: ObjectStackProtocolImplementation['readItemActiveRows'];
@@ -223,19 +212,15 @@ export interface ProtocolHost {
223212
readonly rethrowUnlessMetadataStoreUnprovisioned: ObjectStackProtocolImplementation['rethrowUnlessMetadataStoreUnprovisioned'];
224213
readonly revertCommit: ObjectStackProtocolImplementation['revertCommit'];
225214
readonly rollBackUnmanagedImport: ObjectStackProtocolImplementation['rollBackUnmanagedImport'];
226-
readonly rollbackMetaItemUnaudited: ObjectStackProtocolImplementation['rollbackMetaItemUnaudited'];
227215
readonly runAuthoringGate: ObjectStackProtocolImplementation['runAuthoringGate'];
228216
readonly runMutationProjector: ObjectStackProtocolImplementation['runMutationProjector'];
229217
readonly runPublishSideEffects: ObjectStackProtocolImplementation['runPublishSideEffects'];
230218
readonly runtimeViewContainerObject: ObjectStackProtocolImplementation['runtimeViewContainerObject'];
231219
readonly runtimeViewContainerPackage: ObjectStackProtocolImplementation['runtimeViewContainerPackage'];
232220
readonly saveConflict: ObjectStackProtocolImplementation['saveConflict'];
233221
readonly saveMetaItem: ObjectStackProtocolImplementation['saveMetaItem'];
234-
readonly saveMetaItemUnaudited: ObjectStackProtocolImplementation['saveMetaItemUnaudited'];
235222
readonly saveWriteBinding: ObjectStackProtocolImplementation['saveWriteBinding'];
236-
readonly searchAll: ObjectStackProtocolImplementation['searchAll'];
237223
readonly seedExternalIdSaveRefusal: ObjectStackProtocolImplementation['seedExternalIdSaveRefusal'];
238-
readonly servedExpand: ObjectStackProtocolImplementation['servedExpand'];
239224
readonly servedLockState: ObjectStackProtocolImplementation['servedLockState'];
240225
readonly shippedArtifactsOf: ObjectStackProtocolImplementation['shippedArtifactsOf'];
241226
readonly shippingPackagesOf: ObjectStackProtocolImplementation['shippingPackagesOf'];

‎packages/metadata-protocol/src/protocol-package-commits.ts‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* bodies of `revertStoredPackage`, `duplicatePackage`,
77
* `importUnmanagedPackage`, `reassignOrphanedMetadata`, `listCommits`,
88
* `readRevertableCommit`, `revertCommit`, `rollbackToPackageCommit`,
9-
* `rollbackMetaItem`, `rollbackMetaItemUnaudited` moved out of `protocol.ts`
10-
* whole by `scripts/codemod-split-protocol.mjs`.
9+
* `rollbackMetaItemUnaudited` moved out of `protocol.ts` whole by
10+
* `scripts/codemod-split-protocol.mjs`.
1111
*
1212
* A MOVE, not a redesign. Each function below is the body of the class method
1313
* of the same name as `packages/metadata-protocol/scripts/host-split.mjs` moves
@@ -42,7 +42,6 @@ import {
4242
import { REFERENCE_SITES } from './reference-sites.js';
4343
import { extensionFieldSuffixRefusalError, judgeExtensionFieldSuffix } from './protocol-extension-field-suffix.js';
4444
import { customizationPairManifestRefusal } from './protocol-customization-package.js';
45-
import { withRefusalAudit } from './protocol-refusal-audit.js';
4645
import {
4746
canonicalMetaType,
4847
canonicalizeMetaRequestType,
@@ -1880,15 +1879,6 @@ export async function rollbackToPackageCommit(host: Pick<ProtocolHost, 'listComm
18801879
return { success: failed.length === 0, revertedCommits, failed };
18811880
}
18821881

1883-
/** The body of `ObjectStackProtocolImplementation#rollbackMetaItem`; the method's docblock there is its contract. */
1884-
export async function rollbackMetaItem(host: Pick<ProtocolHost, 'recordMetadataAudit' | 'rollbackMetaItemUnaudited'>, request: RollbackMetaItemRequest) {
1885-
// [#28355] A refusal that carries no row of its own leaves its `denied` row here.
1886-
return withRefusalAudit((entry) => host.recordMetadataAudit(entry), {
1887-
operation: 'rollback', type: request.type, name: request.name, actor: request.actor,
1888-
source: 'protocol.rollbackMetaItem',
1889-
}, () => host.rollbackMetaItemUnaudited(request));
1890-
}
1891-
18921882
/** The body of `ObjectStackProtocolImplementation#rollbackMetaItemUnaudited`; the method's docblock there is its contract. */
18931883
export async function rollbackMetaItemUnaudited(host: Pick<ProtocolHost, 'applyRegistryWriteThrough' | 'assertLockAllowsWrite' | 'emitMetadataMutation' | 'ensureOverlayIndex' | 'getOverlayRepo' | 'isArtifactBacked' | 'isOverlayAllowed' | 'isRuntimeCreateAllowed' | 'metadataConflictRefusal' | 'namedBaseOverlayWriteRefusal' | 'packagelessOverlayWriteRefusal' | 'receiptVersion' | 'recordMetadataAudit' | 'recordOptimisticConflictAudit' | 'refuseOrganizationScopedWrite' | 'resolveOverlayPackageBinding' | 'restoreWriteFor' | 'runMutationProjector'>, request: RollbackMetaItemRequest): Promise<{
18941884
success: boolean;

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* [#29985 codemod] The "Save refusals, saveMetaItem, saveConflict,
55
* migrateStoredMetadata" section of `ObjectStackProtocolImplementation`: the
66
* bodies of `metaTypeNamespaceExists`, `viewContainerNameCollisionRefusal`,
7-
* `saveMetaItem`, `saveMetaItemUnaudited`, `migrateStoredMetadata` moved out of
8-
* `protocol.ts` whole by `scripts/codemod-split-protocol.mjs`.
7+
* `saveMetaItemUnaudited`, `migrateStoredMetadata` moved out of `protocol.ts`
8+
* whole by `scripts/codemod-split-protocol.mjs`.
99
*
1010
* A MOVE, not a redesign. Each function below is the body of the class method
1111
* of the same name as `packages/metadata-protocol/scripts/host-split.mjs` moves
@@ -48,7 +48,6 @@ import { objectBodyExtensionFieldSuffixRefusal } from './protocol-extension-fiel
4848
import { flowVerdictBody } from './protocol-flow-save-replay.js';
4949
import { withParsedStoredActions } from './protocol-stored-action-parse.js';
5050
import { datasourceCredentialsRefSaveRefusal } from './protocol-datasource-credentials-ref.js';
51-
import { withRefusalAudit } from './protocol-refusal-audit.js';
5251
import { withNullMasterRowCounts } from './protocol-destructive-null-master.js';
5352
import { canonicalMetaType, canonicalizeMetaRequestType, resolveOverlaySchema } from './protocol-meta-type-schema.js';
5453
import {
@@ -205,15 +204,6 @@ export async function viewContainerNameCollisionRefusal(host: Pick<ProtocolHost,
205204
return undefined;
206205
}
207206

208-
/** The body of `ObjectStackProtocolImplementation#saveMetaItem`; the method's docblock there is its contract. */
209-
export async function saveMetaItem(host: Pick<ProtocolHost, 'recordMetadataAudit' | 'saveMetaItemUnaudited'>, request: SaveMetaItemRequest) {
210-
// [#28355] A refusal that carries no row of its own leaves its `denied` row here.
211-
return withRefusalAudit((entry) => host.recordMetadataAudit(entry), {
212-
operation: 'save', type: request.type, name: request.name, actor: request.actor,
213-
source: request.source ?? 'protocol.saveMetaItem',
214-
}, () => host.saveMetaItemUnaudited(request));
215-
}
216-
217207
/** The body of `ObjectStackProtocolImplementation#saveMetaItemUnaudited`; the method's docblock there is its contract. */
218208
export async function saveMetaItemUnaudited(host: Pick<ProtocolHost, 'anonymousElevatedFlowRefusal' | 'applyRegistryWriteThrough' | 'assertLockAllowsWrite' | 'assertRuntimeAuthoringRules' | 'authoredLockFamily' | 'authoringChannel' | 'carryForwardRedactedCredentials' | 'classifyObjectContribution' | 'codeOnlyCreateError' | 'codeOnlyOverrideError' | 'credentialChannelFor' | 'defaultRecordPageSaveRefusal' | 'emitMetadataMutation' | 'engine' | 'ensureObjectStorage' | 'ensureOverlayIndex' | 'envWritableTypes' | 'externalBindingSaveRefusal' | 'flowCanonicalizeFallbackWarned' | 'flowSaveReplaysRetired' | 'getOverlayRepo' | 'isArtifactBacked' | 'isOverlayAllowed' | 'isRuntimeCreateAllowed' | 'isWritablePackage' | 'namedBaseOverlayWriteRefusal' | 'objectExtensionItemRefusal' | 'objectNamespacePrefixViolation' | 'objectRegistrationRefusal' | 'overlayPackageMismatchError' | 'overrideWriteVerdict' | 'packagelessAddress' | 'packagelessDraftAddress' | 'packagelessOverlayWriteRefusal' | 'permissionSetNameCollisionRefusal' | 'readMetaItem' | 'receiptVersion' | 'recordMetadataAudit' | 'refuseOrganizationScopedWrite' | 'refusePackagedBaseOverride' | 'refuseUngrammaticalMetaItemName' | 'refuseUnmintableMetaType' | 'registryAllowsOverlay' | 'resolveFlowCanonicalizer' | 'resolveSduiManifest' | 'restoreInjectedColumnEchoes' | 'restoreTranslatedObjectEchoes' | 'restoredCredentialPathsFor' | 'runAuthoringGate' | 'runMutationProjector' | 'saveConflict' | 'saveWriteBinding' | 'seedExternalIdSaveRefusal' | 'storableViewFallbackWarned' | 'storedParentForToken' | 'stripServedObjectColumns' | 'tenantAuthoredWriteRefusal' | 'uninstalledNamedBaseRefusal' | 'unknownDatasourceSaveRefusal' | 'unknownGrantObjectSaveRefusal' | 'unknownPicklistBindingSaveRefusal' | 'viewContainerNameCollisionRefusal'>, request: SaveMetaItemRequest) {
219209
// [ADR-0131 D6] FIRST, before every other gate and every read: an

‎packages/metadata-protocol/src/protocol.hydrate-overlay-canonical-type.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,10 @@ describe('[#9111] the `hydrateOverlayIntoRegistry` caller set stays closed', ()
371371
// `PLURAL_TO_SINGULAR` (tolerant AND incomplete). Pinned positively so
372372
// a "simplification" to the manifest map fails here rather than
373373
// silently re-opening the six spellings section 1 measures.
374-
expect(source).toContain("err.code = 'REGISTRY_TYPE_NOT_CANONICAL';");
375-
expect(source).toMatch(/const canonicalType = canonicalMetaType\(type\);/);
374+
// [#29985] The hydrator's body moved to `protocol-registry-hydration.ts`
375+
// with the codemod split; the assert is read where the body now is.
376+
const hydration = readFileSync(fileURLToPath(new URL('./protocol-registry-hydration.ts', import.meta.url)), 'utf8');
377+
expect(hydration).toContain("err.code = 'REGISTRY_TYPE_NOT_CANONICAL';");
378+
expect(hydration).toMatch(/const canonicalType = canonicalMetaType\(type\);/);
376379
});
377380
});

0 commit comments

Comments
 (0)