Skip to content

Commit

Permalink
Automation: main-next integrate
Browse files Browse the repository at this point in the history
  • Loading branch information
CraigMacomber committed Dec 12, 2023
2 parents 6b2f40b + 799c950 commit 5d2dce4
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 71 deletions.
4 changes: 2 additions & 2 deletions experimental/dds/tree2/src/class-tree/integerIndexable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function integerIndexable<T, TTarget extends object>(
get: (target, key, receiver): T | unknown => {
const index = keyToNumber(key);
if (index !== undefined) {
assert(isValidIndex(index), "invalid index");
assert(isValidIndex(index), 0x839 /* invalid index */);
return provider.read(index);
}

Expand Down Expand Up @@ -100,7 +100,7 @@ export function integerIndexable<T, TTarget extends object>(
set: (target, key, newValue): boolean => {
const index = keyToNumber(key);
if (index !== undefined) {
assert(isValidIndex(index), "invalid index");
assert(isValidIndex(index), 0x83a /* invalid index */);
return provider.write(index, newValue);
}
return Reflect.set(target, key, newValue);
Expand Down
6 changes: 3 additions & 3 deletions experimental/dds/tree2/src/class-tree/schemaFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ export class SchemaFactory<TScope extends string, TName extends number | string
if (isFlexTreeNode(input)) {
assert(
getClassSchema(input.schema) === this.constructor,
"building node with wrong schema",
0x83b /* building node with wrong schema */,
);
}
// TODO: make this a better user facing error, and explain how to copy explicitly.
assert(
!(input instanceof NodeBase),
"Existing nodes cannot be used as new content to insert. They must either be moved or explicitly copied",
0x83c /* Existing nodes cannot be used as new content to insert. They must either be moved or explicitly copied */,
);
}
}
Expand Down Expand Up @@ -576,7 +576,7 @@ export function structuralName<const T extends string>(
} else {
const names = allowedTypes.map((t): string => {
// Ensure that lazy types (functions) don't slip through here.
assert(!isLazy(t), "invalid type provided");
assert(!isLazy(t), 0x83d /* invalid type provided */);
return t.identifier;
});
// Ensure name is order independent
Expand Down
10 changes: 5 additions & 5 deletions experimental/dds/tree2/src/class-tree/toFlexSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ export function toFlexSchema(root: ImplicitFieldSchema): TreeSchema {
const schema = value.toFlex();
const classSchema = getClassSchema(schema);
if (classSchema === undefined) {
assert(schemaIsLeaf(schema), "invalid leaf");
assert(schemaIsLeaf(schema), 0x83e /* invalid leaf */);
} else {
assert(
cachedFlexSchemaFromClassSchema(classSchema) === schema,
"mismatched schema",
0x83f /* mismatched schema */,
);
}
return [key, schema];
Expand Down Expand Up @@ -194,7 +194,7 @@ export function convertNodeSchema(
const cached =
cachedFlexSchemaFromClassSchema(schema) ??
fail("leaf schema should be pre-cached");
assert(schemaIsLeaf(cached), "expected leaf");
assert(schemaIsLeaf(cached), 0x840 /* expected leaf */);
return cached;
}
case NodeKind.Map: {
Expand Down Expand Up @@ -240,13 +240,13 @@ export function convertNodeSchema(
default:
unreachableCase(kind);
}
assert(out instanceof FlexTreeNodeSchemaBase, "invalid schema produced");
assert(out instanceof FlexTreeNodeSchemaBase, 0x841 /* invalid schema produced */);
{
const cached = cachedFlexSchemaFromClassSchema(schema);
if (cached !== undefined) {
assert(
cachedFlexSchemaFromClassSchema(schema) === out,
"incorrect flexSchemaSymbol",
0x842 /* incorrect flexSchemaSymbol */,
);
} else {
setFlexSchemaFromClassSchema(schema, out);
Expand Down
4 changes: 2 additions & 2 deletions experimental/dds/tree2/src/domains/json/jsonCursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ export function cursorToJsonObject(reader: ITreeCursor): JsonCompatible {
case leaf.number.name:
case leaf.boolean.name:
case leaf.string.name:
assert(reader.value !== undefined, "out of schema: missing value");
assert(!isFluidHandle(reader.value), "out of schema: unexpected FluidHandle");
assert(reader.value !== undefined, 0x84f /* out of schema: missing value */);
assert(!isFluidHandle(reader.value), 0x850 /* out of schema: unexpected FluidHandle */);
return reader.value;
case jsonArray.name: {
reader.enterField(EmptyKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,10 @@ export class ModularChangeFamily
for (const fieldChange of fieldsToUpdate) {
const originalFieldChange = fieldChange.change;
const context = crossFieldTable.originalFieldToContext.get(fieldChange);
assert(context !== undefined, "Should have context for every invalidated field");
assert(
context !== undefined,
0x851 /* Should have context for every invalidated field */,
);
const { invertedField, revision } = context;

const amendedChange = getChangeHandler(
Expand Down Expand Up @@ -534,7 +537,7 @@ export class ModularChangeFamily
for (const field of fieldsToUpdate) {
// TODO: Should we copy the context table out before this loop?
const context = crossFieldTable.rebasedFieldToContext.get(field);
assert(context !== undefined, "Every field should have a context");
assert(context !== undefined, 0x852 /* Every field should have a context */);
const {
fieldKind,
changesets: [fieldChangeset, baseChangeset],
Expand Down Expand Up @@ -844,7 +847,10 @@ export function intoDelta(
const builds: DeltaDetachedNodeBuild[] = [];
forEachInNestedMap(change.builds, (tree, major, minor) => {
const cursor = decode(tree).cursor();
assert(cursor.getFieldLength() === 1, "each encoded chunk should only contain 1 node.");
assert(
cursor.getFieldLength() === 1,
0x853 /* each encoded chunk should only contain 1 node. */,
);
cursor.enterNode(0);
builds.push({
id: makeDetachedNodeId(major ?? revision, minor),
Expand Down Expand Up @@ -1194,7 +1200,7 @@ export class ModularEditBuilder extends EditBuilder<ModularChangeset> {

// TODO:YA6307 adopt more efficient representation, likely based on contiguous runs of IDs
for (const tree of encodedTrees) {
assert(!innerMap.has(id), "Unexpected duplicate build ID");
assert(!innerMap.has(id), 0x854 /* Unexpected duplicate build ID */);
innerMap.set(id, tree);
id = brand((id as number) + 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ export const optionalChangeRebaser: FieldChangeRebaser<OptionalChangeset> = {
if (originalSrc !== undefined) {
const [dst2, existingTarget] =
current.srcToDst.get(originalSrc) ?? fail("expected backward mapping");
assert(areEqualRegisterIds(dst2, src), "expected consistent backward mapping");
assert(
areEqualRegisterIds(dst2, src),
0x855 /* expected consistent backward mapping */,
);
currentTarget = existingTarget;
} else {
originalSrc = src;
Expand Down Expand Up @@ -300,7 +303,7 @@ export const optionalChangeRebaser: FieldChangeRebaser<OptionalChangeset> = {
// TODO:AB#6298: This assert can legitimately fail for transactions, meaning we have little test coverage there.
assert(
src === "self" || dst === "self",
"Invert is not currently supported for changes that transfer nodes between non-self registers.",
0x856 /* Invert is not currently supported for changes that transfer nodes between non-self registers. */,
);
if (src !== "self" && dst === "self") {
inverseEmptiesSelf = true;
Expand Down Expand Up @@ -365,7 +368,7 @@ export const optionalChangeRebaser: FieldChangeRebaser<OptionalChangeset> = {

for (const [src, dst, target] of moves) {
if (target === "cellTargeting") {
assert(src === "self", "Cell targeting moves must have self as a source");
assert(src === "self", 0x857 /* Cell targeting moves must have self as a source */);
// TODO: Should we drop cell targeting / node targeting and just special-case 'self'? Might be simpler to understand.
// Holding off on making a call until AB#6298 is addressed (possibly support for rebasing transactions makes the
// answer to this more obvious).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ function compareCellPositions(

assert(
baseCellId.revision !== undefined && newCellId.revision !== undefined,
"Cells should have defined revisions",
0x858 /* Cells should have defined revisions */,
);

if (!isNewAttach(newMark)) {
Expand All @@ -695,7 +695,7 @@ function compareCellPositions(
const baseRevisionIndex = metadata.getIndex(baseCellId.revision);
assert(
newRevisionIndex !== undefined,
"A cell from a new attach should have a defined revision index",
0x859 /* A cell from a new attach should have a defined revision index */,
);

// We use the tiebreaking policy of the newer cell.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ function compareCellPositions(
const baseLength = baseMark.count;
assert(baseId?.revision !== undefined, 0x6a0 /* baseMark should have cell ID */);
const newId = getInputCellId(newMark, undefined, metadata);
assert(newId !== undefined, "newMark should have cell ID");
assert(newId !== undefined, 0x85a /* newMark should have cell ID */);
const newLength = newMark.count;
if (newId !== undefined && baseId.revision === newId.revision) {
const cmp = compareCellsFromSameRevision(baseId, baseMark.count, newId, newMark.count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ export function compareCellsFromSameRevision(
cell2: CellId,
count2: number,
): number | undefined {
assert(cell1.revision === cell2.revision, "Expected cells to have the same revision");
assert(cell1.revision === cell2.revision, 0x85b /* Expected cells to have the same revision */);
if (areOverlappingIdRanges(cell1.localId, count1, cell2.localId, count2)) {
return cell1.localId - cell2.localId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function isFluidHandle(value: unknown): value is IFluidHandle {
export function assertAllowedValue(
value: undefined | FluidSerializableReadOnly,
): asserts value is Value {
assert(isAllowedValue(value), "invalid value");
assert(isAllowedValue(value), 0x843 /* invalid value */);
}

export function isAllowedValue(value: undefined | FluidSerializableReadOnly): value is Value {
Expand Down
7 changes: 5 additions & 2 deletions experimental/dds/tree2/src/simple-tree/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,10 @@ export function extractFactoryContent(
content = input as FactoryContent;
}

assert(!(content instanceof NodeBase), "Unhydrated insertion content should have FlexNode");
assert(
!(content instanceof NodeBase),
0x844 /* Unhydrated insertion content should have FlexNode */,
);

let type: NodeKind;
let extractedContent: ExtractedFactoryContent;
Expand All @@ -945,7 +948,7 @@ export function extractFactoryContent(

if (input instanceof NodeBase) {
const kindFromSchema = getNodeKind(input);
assert(kindFromSchema === type, "kind of data should match kind of schema");
assert(kindFromSchema === type, 0x845 /* kind of data should match kind of schema */);
}

if (fromFactory) {
Expand Down
21 changes: 12 additions & 9 deletions experimental/dds/tree2/src/simple-tree/toMapTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function nodeDataToMapTree(
context: TreeDataContext,
typeSet: TreeTypeSet,
): MapTree {
assert(data !== undefined, "Cannot map undefined tree.");
assert(data !== undefined, 0x846 /* Cannot map undefined tree. */);

if (data === null) {
return valueToMapTree(data, context, typeSet);
Expand Down Expand Up @@ -148,15 +148,15 @@ export function fieldDataToMapTrees(
if (data === undefined) {
assert(
multiplicity === Multiplicity.Forbidden || multiplicity === Multiplicity.Optional,
"`undefined` provided for a field that does not support `undefined`",
0x847 /* `undefined` provided for a field that does not support `undefined` */,
);
return [];
}

const typeSet = fieldSchema.types;

if (multiplicity === Multiplicity.Sequence) {
assert(Array.isArray(data), "Expected an array as sequence input.");
assert(Array.isArray(data), 0x848 /* Expected an array as sequence input. */);
const children = Array.from(data, (child) => {
// We do not support undefined sequence entries.
// If we encounter an undefined entry, use null instead if supported by the schema, otherwise throw.
Expand All @@ -174,7 +174,7 @@ export function fieldDataToMapTrees(
}
assert(
multiplicity === Multiplicity.Single || multiplicity === Multiplicity.Optional,
"A single value was provided for an unsupported field",
0x849 /* A single value was provided for an unsupported field */,
);
return [nodeDataToMapTree(data, context, typeSet)];
}
Expand All @@ -191,7 +191,7 @@ function valueToMapTree(
const schema = getSchema(context, type);
assert(
allowsValue(schema.leafValue, mappedValue),
"Unsupported schema for provided primitive.",
0x84a /* Unsupported schema for provided primitive. */,
);

return {
Expand Down Expand Up @@ -247,7 +247,7 @@ function arrayToMapTree(
const primaryField = getPrimaryField(schema);
assert(
primaryField !== undefined,
"Array data reported comparable with the schema without a primary field.",
0x84b /* Array data reported comparable with the schema without a primary field. */,
);

const mappedChildren = fieldDataToMapTrees(data, context, primaryField.schema);
Expand All @@ -273,7 +273,7 @@ function mapToMapTree(

const fields = new Map<FieldKey, MapTree[]>();
for (const [key, value] of data) {
assert(!fields.has(brand(key)), "Keys should not be duplicated");
assert(!fields.has(brand(key)), 0x84c /* Keys should not be duplicated */);

// Omit undefined record entries - an entry with an undefined key is equivalent to no entry
if (value !== undefined) {
Expand Down Expand Up @@ -302,7 +302,7 @@ function recordToMapTree(
const keys = Reflect.ownKeys(data).filter((key) => typeof key === "string") as FieldKey[];

for (const key of keys) {
assert(!fields.has(key), "Keys should not be duplicated");
assert(!fields.has(key), 0x84d /* Keys should not be duplicated */);
const value = data[key];

// Omit undefined record entries - an entry with an undefined key is equivalent to no entry
Expand All @@ -325,7 +325,10 @@ function getType(
typeSet: TreeTypeSet,
): TreeNodeSchemaIdentifier {
const possibleTypes = getPossibleTypes(context, typeSet, data as ContextuallyTypedNodeData);
assert(possibleTypes.length !== 0, "data is incompatible with all types allowed by the schema");
assert(
possibleTypes.length !== 0,
0x84e /* data is incompatible with all types allowed by the schema */,
);
checkInput(
possibleTypes.length === 1,
() =>
Expand Down
2 changes: 1 addition & 1 deletion packages/dds/map/src/directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec

assert(
subdirNames.length === this._subdirectories.size,
"The count of keys for iteration should be consistent with the size of actual data",
0x85c /* The count of keys for iteration should be consistent with the size of actual data */,
);

const entriesIterator = {
Expand Down
10 changes: 5 additions & 5 deletions packages/dds/matrix/src/matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,11 @@ export class SharedMatrix<T = any>
* @param callback - code that needs to protected against reentrancy.
*/
private protectAgainstReentrancy(callback: () => void) {
assert(this.reentrantCount === 0, "reentrant code");
assert(this.reentrantCount === 0, 0x85d /* reentrant code */);
this.reentrantCount++;
callback();
this.reentrantCount--;
assert(this.reentrantCount === 0, "reentrant code on exit");
assert(this.reentrantCount === 0, 0x85e /* reentrant code on exit */);
}

private submitVectorMessage(
Expand Down Expand Up @@ -746,9 +746,9 @@ export class SharedMatrix<T = any>
) {
assert(
this.setCellLwwToFwwPolicySwitchOpSeqNumber > -1,
"should be in Fww mode when calling this method",
0x85f /* should be in Fww mode when calling this method */,
);
assert(message.clientId !== null, "clientId should not be null");
assert(message.clientId !== null, 0x860 /* clientId should not be null */);
const lastCellModificationDetails = this.cellLastWriteTracker.getCell(rowHandle, colHandle);
// If someone tried to Overwrite the cell value or first write on this cell or
// same client tried to modify the cell.
Expand Down Expand Up @@ -789,7 +789,7 @@ export class SharedMatrix<T = any>
this.setCellLwwToFwwPolicySwitchOpSeqNumber = rawMessage.sequenceNumber;
}

assert(rawMessage.clientId !== null, "clientId should not be null!!");
assert(rawMessage.clientId !== null, 0x861 /* clientId should not be null!! */);
if (local) {
// We are receiving the ACK for a local pending set operation.
const { rowHandle, colHandle, localSeq } = localOpMetadata as ISetOpMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ export class UnreferencedStateTracker {
this._state = UnreferencedState.SweepReady;
assert(
!this.inactiveTimer.hasTimer && !this.tombstoneTimer.hasTimer,
"inactiveTimer or tombstoneTimer still running after sweepTimer fired!",
0x863 /* inactiveTimer or tombstoneTimer still running after sweepTimer fired! */,
);
});

this.tombstoneTimer = new TimerWithNoDefaultTimeout(() => {
this._state = UnreferencedState.TombstoneReady;
assert(
!this.inactiveTimer.hasTimer,
"inactiveTimer still running after tombstoneTimer fired!",
0x864 /* inactiveTimer still running after tombstoneTimer fired! */,
); // aka 0x3b1

if (this.sweepGracePeriodMs > 0) {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/datastore/src/dataStoreRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export class FluidDataStoreRuntime

this.verifyNotClosed();

assert(!this.contexts.has(id), "addChannel() with existing ID");
assert(!this.contexts.has(id), 0x865 /* addChannel() with existing ID */);

const type = channel.attributes.type;
const factory = this.sharedObjectRegistry.get(channel.attributes.type);
Expand Down
Loading

0 comments on commit 5d2dce4

Please sign in to comment.