Skip to content

Commit cde81b5

Browse files
Tag asserts (#26039)
## Description `pnpm run policy-check:asserts` Done using branch from #26036 to workaround issue noted in that PR.
1 parent efb6e62 commit cde81b5

File tree

7 files changed

+24
-12
lines changed

7 files changed

+24
-12
lines changed

packages/dds/tree/src/feature-libraries/modular-schema/comparison.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ export function allowsFieldSuperset(
163163
if (monotonicOnly) {
164164
return supersetKind.options.allowMonotonicUpgradeFrom.has(original.kind);
165165
} else {
166-
const originalKind = policy.fieldKinds.get(original.kind) ?? fail("missing kind");
166+
const originalKind =
167+
policy.fieldKinds.get(original.kind) ?? fail(0xcab /* missing kind */);
167168
return allowsMultiplicitySuperset(originalKind.multiplicity, supersetKind.multiplicity);
168169
}
169170
}

packages/dds/tree/src/shared-tree-core/editManagerCodecsVSharedBranches.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function makeSharedBranchesCodecWithVersion<TChangeset>(
7878
);
7979
assert(
8080
data.originator !== undefined,
81-
"Cannot encode vSharedBranches summary without originator",
81+
0xca5 /* Cannot encode vSharedBranches summary without originator */,
8282
);
8383
const json: Mutable<EncodedEditManager<TChangeset>> = {
8484
main: mainBranch,

packages/dds/tree/src/shared-tree-core/versionedSummarizer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export abstract class VersionedSummarizer<TVersion extends number> implements Su
4444
) {
4545
assert(
4646
this.supportedVersions.has(this.writeVersion),
47-
"Unsupported write version requested.",
47+
0xca6 /* Unsupported write version requested. */,
4848
() => `Write version ${this.writeVersion} requested but not supported with key ${key}.`,
4949
);
5050
}

packages/dds/tree/src/shared-tree/treeCheckout.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,10 @@ export class TreeCheckout implements ITreeCheckoutFork {
559559
.resolve(4)
560560
.json.encode(change, context);
561561

562-
assert(commit.parent !== undefined, "Expected applied commit to be parented");
562+
assert(
563+
commit.parent !== undefined,
564+
0xca4 /* Expected applied commit to be parented */,
565+
);
563566
return {
564567
version: 1,
565568
revision,

packages/dds/tree/src/simple-tree/createContext.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ export function getUnhydratedContext(schema: ImplicitFieldSchema): Context {
3333
// Due to caching, calling this reentrantly can cause issues.
3434
// Due to recursive schema, and generally lots of lazy initialization code depending on this, bugs with this going reentrant are not uncommon.
3535
// To make debugging such cases much easier, we assert that this is not called reentrantly.
36-
assert(!getUnhydratedContextIsRunning, "getUnhydratedContext should not be reentrant");
36+
assert(
37+
!getUnhydratedContextIsRunning,
38+
0xca7 /* getUnhydratedContext should not be reentrant */,
39+
);
3740
getUnhydratedContextIsRunning = true;
3841
try {
3942
return getOrCreate(contextCache, schema, (s) => {

packages/dds/tree/src/simple-tree/toStoredSchema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export function transformSimpleSchema(
189189
const queue = Array.from(root.simpleAllowedTypes.keys());
190190
for (const identifier of queue) {
191191
getOrCreate(simpleNodeSchema, identifier, (id) => {
192-
const nodeSchema = schema.definitions.get(id) ?? fail("missing schema");
192+
const nodeSchema = schema.definitions.get(id) ?? fail(0xca8 /* missing schema */);
193193
const transformed = transformSimpleNodeSchema(nodeSchema, options);
194194
const kind = transformed.kind;
195195
switch (kind) {
@@ -216,12 +216,12 @@ export function transformSimpleSchema(
216216
const definitions = new Map<string, SimpleNodeSchema>(
217217
mapIterable(
218218
filterIterable(schema.definitions.keys(), (id) => simpleNodeSchema.has(id)),
219-
(id) => [id, simpleNodeSchema.get(id) ?? fail("missing schema")],
219+
(id) => [id, simpleNodeSchema.get(id) ?? fail(0xca9 /* missing schema */)],
220220
),
221221
);
222222
assert(
223223
definitions.size === simpleNodeSchema.size,
224-
"Reachable schema missing from input TreeSchema",
224+
0xcaa /* Reachable schema missing from input TreeSchema */,
225225
);
226226
return { root, definitions };
227227
}

packages/runtime/test-runtime-utils/src/assertionShortCodesMap.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,6 @@ export const shortCodeMap = {
14331433
"0xa7b": "Collision of object id property.",
14341434
"0xa7c": "Ref not found.",
14351435
"0xa7d": "Expected at least two types",
1436-
"0xa7e": "Expected at least two types",
14371436
"0xa7f": "Delta manager does not have inbound/outbound queues.",
14381437
"0xa80": "Invalid delta manager",
14391438
"0xa83": "Expected commit(s) for a non no-op rebase",
@@ -1624,7 +1623,6 @@ export const shortCodeMap = {
16241623
"0xb5d": "Expected last remove to be unacked",
16251624
"0xb5e": "Expected prior remove to be acked",
16261625
"0xb5f": "Expected same length for client ids and seqs",
1627-
"0xb60": "Invalid schema",
16281626
"0xb61": "Invalid old reference",
16291627
"0xb62": "Invalid new segment on rebase",
16301628
"0xb63": "Resubmitting obliterate op without obliterate info in segment group",
@@ -1841,7 +1839,6 @@ export const shortCodeMap = {
18411839
"0xc62": "Cannot encode branch base without originatorId",
18421840
"0xc63": "Cannot decode branch id without originatorId",
18431841
"0xc64": "Cannot decode branch base without originatorId",
1844-
"0xc65": "Cannot encode V5 summary without originator",
18451842
"0xc66": "Shared branches must have an id",
18461843
"0xc67": "Duplicate shared branch id",
18471844
"0xc68": "Only commit messages are supported",
@@ -1902,5 +1899,13 @@ export const shortCodeMap = {
19021899
"0xca0": "Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher",
19031900
"0xca1": "Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher",
19041901
"0xca2": "localOpActivity must be undefined when entering rollback",
1905-
"0xca3": "localOpActivity must be undefined when entering applyStashedOp"
1902+
"0xca3": "localOpActivity must be undefined when entering applyStashedOp",
1903+
"0xca4": "Expected applied commit to be parented",
1904+
"0xca5": "Cannot encode vSharedBranches summary without originator",
1905+
"0xca6": "Unsupported write version requested.",
1906+
"0xca7": "getUnhydratedContext should not be reentrant",
1907+
"0xca8": "missing schema",
1908+
"0xca9": "missing schema",
1909+
"0xcaa": "Reachable schema missing from input TreeSchema",
1910+
"0xcab": "missing kind"
19061911
};

0 commit comments

Comments
 (0)