@fluidframework/id-compressor 2.80.0 → 2.81.0-374083

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/id-compressor";
8
- export declare const pkgVersion = "2.80.0";
8
+ export declare const pkgVersion = "2.81.0-374083";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,WAAW,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,kBAAkB,CAAC"}
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/id-compressor";
11
- exports.pkgVersion = "2.80.0";
11
+ exports.pkgVersion = "2.81.0-374083";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/id-compressor\";\nexport const pkgVersion = \"2.80.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/id-compressor\";\nexport const pkgVersion = \"2.81.0-374083\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../src/sessions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAW5D;;;GAGG;AACH,qBAAa,QAAQ;IAGpB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA8D;IAExF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAiC;gBAE3C,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;IAgBrE,QAAQ,IAAI,gBAAgB,CAAC,OAAO,CAAC;IAIrC,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;IAc1C,GAAG,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS;IAI9C,oBAAoB,CAC1B,KAAK,EAAE,QAAQ,GACb,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,CAAC,GAAG,SAAS;IAmB7D,eAAe,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO;IA0C5C,MAAM,CAAC,KAAK,EAAE,QAAQ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,EAAE,SAAS,CAAC,EAAE,EACjB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,GAChC,CAAC,GAAG,SAAS;IAmBT,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;CAStC;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACzB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IAExC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IAExC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,OAAO,CAQjE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC9B,OAAO,EAAE,SAAS,EAClB,WAAW,EAAE,iBAAiB,GAC5B,iBAAiB,GAAG,SAAS,CAO/B;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC9B,OAAO,EAAE,SAAS,EAClB,WAAW,EAAE,iBAAiB,GAC5B,iBAAiB,CAOnB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,iBAAiB,CAExE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,iBAAiB,CAExE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,iBAAiB,CAExE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,iBAAiB,CAExE"}
package/dist/sessions.js CHANGED
@@ -80,6 +80,7 @@ class Sessions {
80
80
  // the next lower session (which is B) and erroneously determine we do not collide
81
81
  // with any other session, but this situation is impossible to get into as B would
82
82
  // have detected that it collided with A (or the other way around, depending on ordering).
83
+ // eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- using ?. could change behavior
83
84
  while (closestMatch !== undefined && closestMatch[1] === owningSession) {
84
85
  closestMatch = this.uuidSpace.nextLowerPair(closestMatch[0]);
85
86
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../src/sessions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,gEAAkD;AAIlD,iDAQwB;AAExB;;;GAGG;AACH,MAAa,QAAQ;IAOpB,YAAmB,QAAyD;QAN5E,6HAA6H;QAC7H,4DAA4D;QAC3C,cAAS,GAAG,IAAI,wBAAK,CAAuB,SAAS,EAAE,6BAAc,CAAC,CAAC;QACxF,sGAAsG;QACrF,iBAAY,GAAG,IAAI,GAAG,EAAsB,CAAC;QAG7D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC5B,iBAAiB;YACjB,KAAK,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,QAAQ,EAAE,CAAC;gBAC3C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAA,sCAAuB,EAAC,OAAO,CAAc,EAAE,OAAO,CAAC,CAAC;YAC/E,CAAC;YACD,IAAI,CAAC,SAAS,GAAG,IAAI,wBAAK,CAAC,QAAQ,EAAE,6BAAc,CAAC,CAAC;YACrD,IACC,IAAI,CAAC,YAAY,CAAC,IAAI,KAAK,QAAQ,CAAC,MAAM;gBAC1C,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,EACtC,CAAC;gBACF,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;YACpD,CAAC;QACF,CAAC;IACF,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;IACnC,CAAC;IAEM,WAAW,CAAC,SAAoB;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,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C,WAAsB,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAsB,CAAC;AACrF,CAAC;AAFD,gDAEC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAsB,CAAC;AACxF,CAAC;AAFD,gDAEC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAsB,CAAC;AACrF,CAAC;AAFD,gDAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\nimport type { FinalCompressedId, LocalCompressedId, NumericUuid } from \"./identifiers.js\";\nimport type { SessionId, StableId } from \"./types/index.js\";\nimport {\n\tcompareBigints,\n\tgenCountFromLocalId,\n\tlocalIdFromGenCount,\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n\tsubtractNumericUuids,\n} from \"./utilities.js\";\n\n/**\n * A collection of all sessions known to the compressor (i.e. all finalized/acked allocated UUIDs and their corresponding local and final forms).\n * This collection of all sessions comprises a distributed document's IDs.\n */\nexport class Sessions {\n\t// A range-queryable store of all sessions. A btree is used as it solves the predecessor problem for any given UUID, allowing\n\t// us to quickly find the session that may have produced it.\n\tprivate readonly uuidSpace = new BTree<NumericUuid, Session>(undefined, compareBigints);\n\t// A fast lookup table from session ID to the session object, used to avoid accessing the slower btree\n\tprivate readonly sessionCache = new Map<SessionId, Session>();\n\n\tpublic constructor(sessions?: [sessionBase: NumericUuid, session: Session][]) {\n\t\tif (sessions !== undefined) {\n\t\t\t// bulk load path\n\t\t\tfor (const [numeric, session] of sessions) {\n\t\t\t\tthis.sessionCache.set(stableIdFromNumericUuid(numeric) as SessionId, session);\n\t\t\t}\n\t\t\tthis.uuidSpace = new BTree(sessions, compareBigints);\n\t\t\tif (\n\t\t\t\tthis.sessionCache.size !== sessions.length ||\n\t\t\t\tsessions.length !== this.uuidSpace.size\n\t\t\t) {\n\t\t\t\tthrow new Error(\"Cannot resume existing session.\");\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic sessions(): IterableIterator<Session> {\n\t\treturn this.sessionCache.values();\n\t}\n\n\tpublic getOrCreate(sessionId: SessionId): Session {\n\t\tconst existing = this.sessionCache.get(sessionId);\n\t\tif (existing !== undefined) {\n\t\t\treturn existing;\n\t\t}\n\t\tconst session = new Session(sessionId);\n\t\tassert(\n\t\t\tthis.uuidSpace.set(session.sessionUuid, session),\n\t\t\t0x760 /* Duplicate session in map. */,\n\t\t);\n\t\tthis.sessionCache.set(sessionId, session);\n\t\treturn session;\n\t}\n\n\tpublic get(sessionId: SessionId): Session | undefined {\n\t\treturn this.sessionCache.get(sessionId);\n\t}\n\n\tpublic getContainingCluster(\n\t\tquery: StableId,\n\t): [cluster: IdCluster, alignedLocal: LocalCompressedId] | undefined {\n\t\tconst numericStable = numericUuidFromStableId(query);\n\t\tconst possibleMatch = this.uuidSpace.getPairOrNextLower(numericStable);\n\t\tif (possibleMatch === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst [_, session] = possibleMatch;\n\t\tconst numericDelta = subtractNumericUuids(numericStable, session.sessionUuid);\n\t\tif (numericDelta > Number.MAX_SAFE_INTEGER) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst alignedLocal = localIdFromGenCount(Number(numericDelta) + 1);\n\t\tconst containingCluster = session.getClusterByLocal(alignedLocal, true);\n\t\tif (containingCluster === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [containingCluster, alignedLocal];\n\t}\n\n\tpublic clusterCollides(cluster: IdCluster): boolean {\n\t\tconst { session: owningSession, baseLocalId, capacity } = cluster;\n\t\tconst clusterBaseNumeric = offsetNumericUuid(\n\t\t\towningSession.sessionUuid,\n\t\t\tgenCountFromLocalId(baseLocalId) - 1,\n\t\t);\n\t\tconst clusterMaxNumeric = offsetNumericUuid(clusterBaseNumeric, capacity - 1);\n\t\tlet closestMatch: [NumericUuid, Session] | undefined =\n\t\t\tthis.uuidSpace.getPairOrNextLower(clusterMaxNumeric);\n\t\t// Find the first session that is not the owner of this new cluster.\n\t\t// Once we have that, check to see if its cluster chain overlaps with the new cluster.\n\t\t// Consider the following diagram of UUID space:\n\t\t// Cluster chain A: |----------------------|\n\t\t// Cluster chain B: |----------|\n\t\t// Cluster chain C: |-------|\n\t\t// While it is true that when adding a cluster to chain C, we would find\n\t\t// the next lower session (which is B) and erroneously determine we do not collide\n\t\t// with any other session, but this situation is impossible to get into as B would\n\t\t// have detected that it collided with A (or the other way around, depending on ordering).\n\t\twhile (closestMatch !== undefined && closestMatch[1] === owningSession) {\n\t\t\tclosestMatch = this.uuidSpace.nextLowerPair(closestMatch[0]);\n\t\t}\n\t\tif (closestMatch === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst [_, session] = closestMatch;\n\t\tassert(session !== owningSession, 0x761 /* Failed to attempt to detect collisions. */);\n\t\tconst lastCluster = session.getLastCluster();\n\t\tif (lastCluster === undefined) {\n\t\t\t// If the closest session is empty (the local session), then it is guaranteed (probabilistically) that there are no\n\t\t\t// non-empty sessions that have a cluster chain that starts prior to the empty session and collides with the cluster\n\t\t\t// we are checking, so we can return false.\n\t\t\treturn false;\n\t\t}\n\t\tconst lastAllocatedNumeric = offsetNumericUuid(\n\t\t\tsession.sessionUuid,\n\t\t\tgenCountFromLocalId(lastAllocatedLocal(lastCluster)) - 1,\n\t\t);\n\t\treturn lastAllocatedNumeric >= clusterBaseNumeric;\n\t}\n\n\tpublic equals(other: Sessions, includeLocalState: boolean): boolean {\n\t\tconst checkIsSubset = (sessionsA: Sessions, sessionsB: Sessions): boolean => {\n\t\t\tconst first = sessionsA.sessions().next();\n\t\t\tconst firstSessionThis = first.done ? undefined : first.value;\n\t\t\tfor (const [stableId, session] of sessionsA.sessionCache.entries()) {\n\t\t\t\tconst otherSession = sessionsB.sessionCache.get(stableId);\n\t\t\t\tif (otherSession === undefined) {\n\t\t\t\t\tif (!session.isEmpty() || includeLocalState) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tassert(\n\t\t\t\t\t\tsession === firstSessionThis,\n\t\t\t\t\t\t0x762 /* The only non-empty session must be the local session. */,\n\t\t\t\t\t);\n\t\t\t\t} else if (!session.equals(otherSession)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\t\treturn checkIsSubset(this, other) && checkIsSubset(other, this);\n\t}\n}\n\n/**\n * The IDs created by a specific session, stored as a cluster chain to allow for fast conversions.\n */\nexport class Session {\n\t// All clusters created by this session, in creation order (thus sorted by base final and local ID).\n\tprivate readonly clusterChain: IdCluster[] = [];\n\t// The numeric form of the SessionId\n\tpublic readonly sessionUuid: NumericUuid;\n\n\tpublic constructor(sessionId: SessionId | NumericUuid) {\n\t\tthis.sessionUuid =\n\t\t\ttypeof sessionId === \"string\" ? numericUuidFromStableId(sessionId) : sessionId;\n\t}\n\n\t/**\n\t * Adds a new empty cluster to the cluster chain of this session.\n\t */\n\tpublic addNewCluster(\n\t\tbaseFinalId: FinalCompressedId,\n\t\tcapacity: number,\n\t\tcount: number,\n\t): IdCluster {\n\t\tconst lastCluster = this.getLastCluster();\n\t\tconst newCluster: IdCluster = {\n\t\t\tsession: this,\n\t\t\tbaseFinalId,\n\t\t\tbaseLocalId: (lastCluster === undefined\n\t\t\t\t? -1\n\t\t\t\t: lastAllocatedLocal(lastCluster) - 1) as LocalCompressedId,\n\t\t\tcapacity,\n\t\t\tcount,\n\t\t};\n\t\tthis.clusterChain.push(newCluster);\n\t\treturn newCluster;\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.clusterChain.length === 0;\n\t}\n\n\t/**\n\t * Returns the last cluster in this session's cluster chain, if any.\n\t */\n\tpublic getLastCluster(): IdCluster | undefined {\n\t\treturn this.clusterChain[this.clusterChain.length - 1];\n\t}\n\n\t/**\n\t * Converts the local ID from this session to a final ID, if possible.\n\t * @param includeAllocated - true if the conversion should succeed even if the local ID aligns with a part of the cluster that is allocated but not finalized.\n\t */\n\tpublic tryConvertToFinal(\n\t\tsearchLocal: LocalCompressedId,\n\t\tincludeAllocated: boolean,\n\t): FinalCompressedId | undefined {\n\t\tconst containingCluster = this.getClusterByLocal(searchLocal, includeAllocated);\n\t\tif (containingCluster === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn getAlignedFinal(containingCluster, searchLocal);\n\t}\n\n\t/**\n\t * Returns the cluster containing the supplied local ID, if possible.\n\t * @param includeAllocated - true if the conversion should succeed even if the local ID aligns with a part of the cluster that is allocated but not finalized.\n\t */\n\tpublic getClusterByLocal(\n\t\tlocalId: LocalCompressedId,\n\t\tincludeAllocated: boolean,\n\t): IdCluster | undefined {\n\t\tconst lastValidLocal: (cluster: IdCluster) => LocalCompressedId = includeAllocated\n\t\t\t? lastAllocatedLocal\n\t\t\t: lastFinalizedLocal;\n\t\tconst matchedCluster = Session.binarySearch(\n\t\t\tlocalId,\n\t\t\tthis.clusterChain,\n\t\t\t(local, cluster): number => {\n\t\t\t\tconst lastLocal = lastValidLocal(cluster);\n\t\t\t\tif (local < lastLocal) {\n\t\t\t\t\treturn 1;\n\t\t\t\t} else if (local > cluster.baseLocalId) {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t\treturn matchedCluster;\n\t}\n\n\t/**\n\t * Returns the cluster containing the supplied final ID, if possible.\n\t */\n\tpublic getClusterByAllocatedFinal(final: FinalCompressedId): IdCluster | undefined {\n\t\treturn Session.getContainingCluster(final, this.clusterChain);\n\t}\n\n\t/**\n\t * Returns the cluster from the supplied cluster chain containing the supplied final ID, if possible.\n\t * `clusterChain` must be sorted by final/local base ID.\n\t */\n\tpublic static getContainingCluster(\n\t\tfinalId: FinalCompressedId,\n\t\tclusterChain: readonly IdCluster[],\n\t): IdCluster | undefined {\n\t\treturn Session.binarySearch(finalId, clusterChain, (final, cluster) => {\n\t\t\tconst lastFinal = lastAllocatedFinal(cluster);\n\t\t\tif (final < cluster.baseFinalId) {\n\t\t\t\treturn -1;\n\t\t\t} else if (final > lastFinal) {\n\t\t\t\treturn 1;\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t});\n\t}\n\n\tstatic binarySearch<S, T>(\n\t\tsearch: S,\n\t\tarr: readonly T[],\n\t\tcomparator: (a: S, b: T) => number,\n\t): T | undefined {\n\t\tlet left = 0;\n\t\tlet right = arr.length - 1;\n\t\twhile (left <= right) {\n\t\t\tconst mid = Math.floor((left + right) / 2);\n\t\t\tconst value = arr[mid];\n\t\t\tassert(value !== undefined, 0x9dc /* value is undefined in Session.binarySearch */);\n\t\t\tconst c = comparator(search, value);\n\t\t\tif (c === 0) {\n\t\t\t\treturn value; // Found the target, return its index.\n\t\t\t} else if (c > 0) {\n\t\t\t\tleft = mid + 1; // Continue search on right half.\n\t\t\t} else {\n\t\t\t\tright = mid - 1; // Continue search on left half.\n\t\t\t}\n\t\t}\n\t\treturn undefined; // If we reach here, target is not in array.\n\t}\n\n\tpublic equals(other: Session): boolean {\n\t\tfor (const [index, value] of Object.entries(this.clusterChain)) {\n\t\t\tif (!clustersEqual(value, other.clusterChain[index] as IdCluster)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn this.sessionUuid === other.sessionUuid;\n\t}\n}\n\n/**\n * A cluster of final (sequenced via consensus), sequentially allocated compressed IDs.\n * A final ID in a cluster decompresses to a sequentially allocated UUID that is the result of adding its offset within\n * the cluster to base UUID for the session that created it.\n */\nexport interface IdCluster {\n\t/**\n\t * The session that created this cluster.\n\t */\n\treadonly session: Session;\n\n\t/**\n\t * The first final ID in the cluster.\n\t */\n\treadonly baseFinalId: FinalCompressedId;\n\n\t/**\n\t * The local ID aligned with `baseFinalId`.\n\t */\n\treadonly baseLocalId: LocalCompressedId;\n\n\t/**\n\t * The total number of final IDs reserved for allocation in the cluster.\n\t * Clusters are reserved in blocks as a performance optimization.\n\t */\n\tcapacity: number;\n\n\t/**\n\t * The number of final IDs currently allocated in the cluster.\n\t */\n\tcount: number;\n}\n\nexport function clustersEqual(a: IdCluster, b: IdCluster): boolean {\n\treturn (\n\t\ta.session.sessionUuid === b.session.sessionUuid &&\n\t\ta.baseFinalId === b.baseFinalId &&\n\t\ta.baseLocalId === b.baseLocalId &&\n\t\ta.capacity === b.capacity &&\n\t\ta.count === b.count\n\t);\n}\n\n/**\n * Returns the final ID that is aligned with the supplied local ID within a cluster.\n * Includes allocated IDs.\n */\nexport function getAlignedFinal(\n\tcluster: IdCluster,\n\tlocalWithin: LocalCompressedId,\n): FinalCompressedId | undefined {\n\tconst clusterOffset =\n\t\tgenCountFromLocalId(localWithin) - genCountFromLocalId(cluster.baseLocalId);\n\tif (clusterOffset < cluster.capacity) {\n\t\treturn ((cluster.baseFinalId as number) + clusterOffset) as FinalCompressedId;\n\t}\n\treturn undefined;\n}\n\n/**\n * Returns the local ID that is aligned with the supplied final ID within a cluster.\n * Fails if the supplied ID does not fall within the cluster bounds.\n */\nexport function getAlignedLocal(\n\tcluster: IdCluster,\n\tfinalWithin: FinalCompressedId,\n): LocalCompressedId {\n\tassert(\n\t\tfinalWithin >= cluster.baseFinalId && finalWithin <= lastAllocatedFinal(cluster),\n\t\t0x763 /* Supplied ID is not within the cluster. */,\n\t);\n\tconst finalDelta = finalWithin - cluster.baseFinalId;\n\treturn (cluster.baseLocalId - finalDelta) as LocalCompressedId;\n}\n\n/**\n * Returns the last allocated final ID (i.e. any ID between base final and base final + capacity) within a cluster\n */\nexport function lastAllocatedFinal(cluster: IdCluster): FinalCompressedId {\n\treturn ((cluster.baseFinalId as number) + (cluster.capacity - 1)) as FinalCompressedId;\n}\n\n/**\n * Returns the last allocated final ID (i.e. any ID between base final and base final + count) within a cluster\n */\nexport function lastFinalizedFinal(cluster: IdCluster): FinalCompressedId {\n\treturn ((cluster.baseFinalId as number) + (cluster.count - 1)) as FinalCompressedId;\n}\n\n/**\n * Returns the last allocated local ID (i.e. any ID between base local and base local + capacity) within a cluster\n */\nexport function lastAllocatedLocal(cluster: IdCluster): LocalCompressedId {\n\treturn ((cluster.baseLocalId as number) - (cluster.capacity - 1)) as LocalCompressedId;\n}\n\n/**\n * Returns the last allocated local ID (i.e. any ID between base local and base local + count) within a cluster\n */\nexport function lastFinalizedLocal(cluster: IdCluster): LocalCompressedId {\n\treturn ((cluster.baseLocalId as number) - (cluster.count - 1)) as LocalCompressedId;\n}\n"]}
1
+ {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../src/sessions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,gEAAkD;AAIlD,iDAQwB;AAExB;;;GAGG;AACH,MAAa,QAAQ;IAOpB,YAAmB,QAAyD;QAN5E,6HAA6H;QAC7H,4DAA4D;QAC3C,cAAS,GAAG,IAAI,wBAAK,CAAuB,SAAS,EAAE,6BAAc,CAAC,CAAC;QACxF,sGAAsG;QACrF,iBAAY,GAAG,IAAI,GAAG,EAAsB,CAAC;QAG7D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC5B,iBAAiB;YACjB,KAAK,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,QAAQ,EAAE,CAAC;gBAC3C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAA,sCAAuB,EAAC,OAAO,CAAc,EAAE,OAAO,CAAC,CAAC;YAC/E,CAAC;YACD,IAAI,CAAC,SAAS,GAAG,IAAI,wBAAK,CAAC,QAAQ,EAAE,6BAAc,CAAC,CAAC;YACrD,IACC,IAAI,CAAC,YAAY,CAAC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AAC,WAAW,CAAC;IACrD,OAAO,CAAC,OAAO,CAAC,WAAW,GAAG,UAAU,CAAsB,CAAC;AAChE,CAAC;AAVD,0CAUC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAsB,CAAC;AACxF,CAAC;AAFD,gDAEC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAsB,CAAC;AACrF,CAAC;AAFD,gDAEC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAsB,CAAC;AACxF,CAAC;AAFD,gDAEC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAsB,CAAC;AACrF,CAAC;AAFD,gDAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\nimport type { FinalCompressedId, LocalCompressedId, NumericUuid } from \"./identifiers.js\";\nimport type { SessionId, StableId } from \"./types/index.js\";\nimport {\n\tcompareBigints,\n\tgenCountFromLocalId,\n\tlocalIdFromGenCount,\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n\tsubtractNumericUuids,\n} from \"./utilities.js\";\n\n/**\n * A collection of all sessions known to the compressor (i.e. all finalized/acked allocated UUIDs and their corresponding local and final forms).\n * This collection of all sessions comprises a distributed document's IDs.\n */\nexport class Sessions {\n\t// A range-queryable store of all sessions. A btree is used as it solves the predecessor problem for any given UUID, allowing\n\t// us to quickly find the session that may have produced it.\n\tprivate readonly uuidSpace = new BTree<NumericUuid, Session>(undefined, compareBigints);\n\t// A fast lookup table from session ID to the session object, used to avoid accessing the slower btree\n\tprivate readonly sessionCache = new Map<SessionId, Session>();\n\n\tpublic constructor(sessions?: [sessionBase: NumericUuid, session: Session][]) {\n\t\tif (sessions !== undefined) {\n\t\t\t// bulk load path\n\t\t\tfor (const [numeric, session] of sessions) {\n\t\t\t\tthis.sessionCache.set(stableIdFromNumericUuid(numeric) as SessionId, session);\n\t\t\t}\n\t\t\tthis.uuidSpace = new BTree(sessions, compareBigints);\n\t\t\tif (\n\t\t\t\tthis.sessionCache.size !== sessions.length ||\n\t\t\t\tsessions.length !== this.uuidSpace.size\n\t\t\t) {\n\t\t\t\tthrow new Error(\"Cannot resume existing session.\");\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic sessions(): IterableIterator<Session> {\n\t\treturn this.sessionCache.values();\n\t}\n\n\tpublic getOrCreate(sessionId: SessionId): Session {\n\t\tconst existing = this.sessionCache.get(sessionId);\n\t\tif (existing !== undefined) {\n\t\t\treturn existing;\n\t\t}\n\t\tconst session = new Session(sessionId);\n\t\tassert(\n\t\t\tthis.uuidSpace.set(session.sessionUuid, session),\n\t\t\t0x760 /* Duplicate session in map. */,\n\t\t);\n\t\tthis.sessionCache.set(sessionId, session);\n\t\treturn session;\n\t}\n\n\tpublic get(sessionId: SessionId): Session | undefined {\n\t\treturn this.sessionCache.get(sessionId);\n\t}\n\n\tpublic getContainingCluster(\n\t\tquery: StableId,\n\t): [cluster: IdCluster, alignedLocal: LocalCompressedId] | undefined {\n\t\tconst numericStable = numericUuidFromStableId(query);\n\t\tconst possibleMatch = this.uuidSpace.getPairOrNextLower(numericStable);\n\t\tif (possibleMatch === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst [_, session] = possibleMatch;\n\t\tconst numericDelta = subtractNumericUuids(numericStable, session.sessionUuid);\n\t\tif (numericDelta > Number.MAX_SAFE_INTEGER) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst alignedLocal = localIdFromGenCount(Number(numericDelta) + 1);\n\t\tconst containingCluster = session.getClusterByLocal(alignedLocal, true);\n\t\tif (containingCluster === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [containingCluster, alignedLocal];\n\t}\n\n\tpublic clusterCollides(cluster: IdCluster): boolean {\n\t\tconst { session: owningSession, baseLocalId, capacity } = cluster;\n\t\tconst clusterBaseNumeric = offsetNumericUuid(\n\t\t\towningSession.sessionUuid,\n\t\t\tgenCountFromLocalId(baseLocalId) - 1,\n\t\t);\n\t\tconst clusterMaxNumeric = offsetNumericUuid(clusterBaseNumeric, capacity - 1);\n\t\tlet closestMatch: [NumericUuid, Session] | undefined =\n\t\t\tthis.uuidSpace.getPairOrNextLower(clusterMaxNumeric);\n\t\t// Find the first session that is not the owner of this new cluster.\n\t\t// Once we have that, check to see if its cluster chain overlaps with the new cluster.\n\t\t// Consider the following diagram of UUID space:\n\t\t// Cluster chain A: |----------------------|\n\t\t// Cluster chain B: |----------|\n\t\t// Cluster chain C: |-------|\n\t\t// While it is true that when adding a cluster to chain C, we would find\n\t\t// the next lower session (which is B) and erroneously determine we do not collide\n\t\t// with any other session, but this situation is impossible to get into as B would\n\t\t// have detected that it collided with A (or the other way around, depending on ordering).\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- using ?. could change behavior\n\t\twhile (closestMatch !== undefined && closestMatch[1] === owningSession) {\n\t\t\tclosestMatch = this.uuidSpace.nextLowerPair(closestMatch[0]);\n\t\t}\n\t\tif (closestMatch === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst [_, session] = closestMatch;\n\t\tassert(session !== owningSession, 0x761 /* Failed to attempt to detect collisions. */);\n\t\tconst lastCluster = session.getLastCluster();\n\t\tif (lastCluster === undefined) {\n\t\t\t// If the closest session is empty (the local session), then it is guaranteed (probabilistically) that there are no\n\t\t\t// non-empty sessions that have a cluster chain that starts prior to the empty session and collides with the cluster\n\t\t\t// we are checking, so we can return false.\n\t\t\treturn false;\n\t\t}\n\t\tconst lastAllocatedNumeric = offsetNumericUuid(\n\t\t\tsession.sessionUuid,\n\t\t\tgenCountFromLocalId(lastAllocatedLocal(lastCluster)) - 1,\n\t\t);\n\t\treturn lastAllocatedNumeric >= clusterBaseNumeric;\n\t}\n\n\tpublic equals(other: Sessions, includeLocalState: boolean): boolean {\n\t\tconst checkIsSubset = (sessionsA: Sessions, sessionsB: Sessions): boolean => {\n\t\t\tconst first = sessionsA.sessions().next();\n\t\t\tconst firstSessionThis = first.done ? undefined : first.value;\n\t\t\tfor (const [stableId, session] of sessionsA.sessionCache.entries()) {\n\t\t\t\tconst otherSession = sessionsB.sessionCache.get(stableId);\n\t\t\t\tif (otherSession === undefined) {\n\t\t\t\t\tif (!session.isEmpty() || includeLocalState) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tassert(\n\t\t\t\t\t\tsession === firstSessionThis,\n\t\t\t\t\t\t0x762 /* The only non-empty session must be the local session. */,\n\t\t\t\t\t);\n\t\t\t\t} else if (!session.equals(otherSession)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\t\treturn checkIsSubset(this, other) && checkIsSubset(other, this);\n\t}\n}\n\n/**\n * The IDs created by a specific session, stored as a cluster chain to allow for fast conversions.\n */\nexport class Session {\n\t// All clusters created by this session, in creation order (thus sorted by base final and local ID).\n\tprivate readonly clusterChain: IdCluster[] = [];\n\t// The numeric form of the SessionId\n\tpublic readonly sessionUuid: NumericUuid;\n\n\tpublic constructor(sessionId: SessionId | NumericUuid) {\n\t\tthis.sessionUuid =\n\t\t\ttypeof sessionId === \"string\" ? numericUuidFromStableId(sessionId) : sessionId;\n\t}\n\n\t/**\n\t * Adds a new empty cluster to the cluster chain of this session.\n\t */\n\tpublic addNewCluster(\n\t\tbaseFinalId: FinalCompressedId,\n\t\tcapacity: number,\n\t\tcount: number,\n\t): IdCluster {\n\t\tconst lastCluster = this.getLastCluster();\n\t\tconst newCluster: IdCluster = {\n\t\t\tsession: this,\n\t\t\tbaseFinalId,\n\t\t\tbaseLocalId: (lastCluster === undefined\n\t\t\t\t? -1\n\t\t\t\t: lastAllocatedLocal(lastCluster) - 1) as LocalCompressedId,\n\t\t\tcapacity,\n\t\t\tcount,\n\t\t};\n\t\tthis.clusterChain.push(newCluster);\n\t\treturn newCluster;\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.clusterChain.length === 0;\n\t}\n\n\t/**\n\t * Returns the last cluster in this session's cluster chain, if any.\n\t */\n\tpublic getLastCluster(): IdCluster | undefined {\n\t\treturn this.clusterChain[this.clusterChain.length - 1];\n\t}\n\n\t/**\n\t * Converts the local ID from this session to a final ID, if possible.\n\t * @param includeAllocated - true if the conversion should succeed even if the local ID aligns with a part of the cluster that is allocated but not finalized.\n\t */\n\tpublic tryConvertToFinal(\n\t\tsearchLocal: LocalCompressedId,\n\t\tincludeAllocated: boolean,\n\t): FinalCompressedId | undefined {\n\t\tconst containingCluster = this.getClusterByLocal(searchLocal, includeAllocated);\n\t\tif (containingCluster === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn getAlignedFinal(containingCluster, searchLocal);\n\t}\n\n\t/**\n\t * Returns the cluster containing the supplied local ID, if possible.\n\t * @param includeAllocated - true if the conversion should succeed even if the local ID aligns with a part of the cluster that is allocated but not finalized.\n\t */\n\tpublic getClusterByLocal(\n\t\tlocalId: LocalCompressedId,\n\t\tincludeAllocated: boolean,\n\t): IdCluster | undefined {\n\t\tconst lastValidLocal: (cluster: IdCluster) => LocalCompressedId = includeAllocated\n\t\t\t? lastAllocatedLocal\n\t\t\t: lastFinalizedLocal;\n\t\tconst matchedCluster = Session.binarySearch(\n\t\t\tlocalId,\n\t\t\tthis.clusterChain,\n\t\t\t(local, cluster): number => {\n\t\t\t\tconst lastLocal = lastValidLocal(cluster);\n\t\t\t\tif (local < lastLocal) {\n\t\t\t\t\treturn 1;\n\t\t\t\t} else if (local > cluster.baseLocalId) {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t\treturn matchedCluster;\n\t}\n\n\t/**\n\t * Returns the cluster containing the supplied final ID, if possible.\n\t */\n\tpublic getClusterByAllocatedFinal(final: FinalCompressedId): IdCluster | undefined {\n\t\treturn Session.getContainingCluster(final, this.clusterChain);\n\t}\n\n\t/**\n\t * Returns the cluster from the supplied cluster chain containing the supplied final ID, if possible.\n\t * `clusterChain` must be sorted by final/local base ID.\n\t */\n\tpublic static getContainingCluster(\n\t\tfinalId: FinalCompressedId,\n\t\tclusterChain: readonly IdCluster[],\n\t): IdCluster | undefined {\n\t\treturn Session.binarySearch(finalId, clusterChain, (final, cluster) => {\n\t\t\tconst lastFinal = lastAllocatedFinal(cluster);\n\t\t\tif (final < cluster.baseFinalId) {\n\t\t\t\treturn -1;\n\t\t\t} else if (final > lastFinal) {\n\t\t\t\treturn 1;\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t});\n\t}\n\n\tstatic binarySearch<S, T>(\n\t\tsearch: S,\n\t\tarr: readonly T[],\n\t\tcomparator: (a: S, b: T) => number,\n\t): T | undefined {\n\t\tlet left = 0;\n\t\tlet right = arr.length - 1;\n\t\twhile (left <= right) {\n\t\t\tconst mid = Math.floor((left + right) / 2);\n\t\t\tconst value = arr[mid];\n\t\t\tassert(value !== undefined, 0x9dc /* value is undefined in Session.binarySearch */);\n\t\t\tconst c = comparator(search, value);\n\t\t\tif (c === 0) {\n\t\t\t\treturn value; // Found the target, return its index.\n\t\t\t} else if (c > 0) {\n\t\t\t\tleft = mid + 1; // Continue search on right half.\n\t\t\t} else {\n\t\t\t\tright = mid - 1; // Continue search on left half.\n\t\t\t}\n\t\t}\n\t\treturn undefined; // If we reach here, target is not in array.\n\t}\n\n\tpublic equals(other: Session): boolean {\n\t\tfor (const [index, value] of Object.entries(this.clusterChain)) {\n\t\t\tif (!clustersEqual(value, other.clusterChain[index] as IdCluster)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn this.sessionUuid === other.sessionUuid;\n\t}\n}\n\n/**\n * A cluster of final (sequenced via consensus), sequentially allocated compressed IDs.\n * A final ID in a cluster decompresses to a sequentially allocated UUID that is the result of adding its offset within\n * the cluster to base UUID for the session that created it.\n */\nexport interface IdCluster {\n\t/**\n\t * The session that created this cluster.\n\t */\n\treadonly session: Session;\n\n\t/**\n\t * The first final ID in the cluster.\n\t */\n\treadonly baseFinalId: FinalCompressedId;\n\n\t/**\n\t * The local ID aligned with `baseFinalId`.\n\t */\n\treadonly baseLocalId: LocalCompressedId;\n\n\t/**\n\t * The total number of final IDs reserved for allocation in the cluster.\n\t * Clusters are reserved in blocks as a performance optimization.\n\t */\n\tcapacity: number;\n\n\t/**\n\t * The number of final IDs currently allocated in the cluster.\n\t */\n\tcount: number;\n}\n\nexport function clustersEqual(a: IdCluster, b: IdCluster): boolean {\n\treturn (\n\t\ta.session.sessionUuid === b.session.sessionUuid &&\n\t\ta.baseFinalId === b.baseFinalId &&\n\t\ta.baseLocalId === b.baseLocalId &&\n\t\ta.capacity === b.capacity &&\n\t\ta.count === b.count\n\t);\n}\n\n/**\n * Returns the final ID that is aligned with the supplied local ID within a cluster.\n * Includes allocated IDs.\n */\nexport function getAlignedFinal(\n\tcluster: IdCluster,\n\tlocalWithin: LocalCompressedId,\n): FinalCompressedId | undefined {\n\tconst clusterOffset =\n\t\tgenCountFromLocalId(localWithin) - genCountFromLocalId(cluster.baseLocalId);\n\tif (clusterOffset < cluster.capacity) {\n\t\treturn ((cluster.baseFinalId as number) + clusterOffset) as FinalCompressedId;\n\t}\n\treturn undefined;\n}\n\n/**\n * Returns the local ID that is aligned with the supplied final ID within a cluster.\n * Fails if the supplied ID does not fall within the cluster bounds.\n */\nexport function getAlignedLocal(\n\tcluster: IdCluster,\n\tfinalWithin: FinalCompressedId,\n): LocalCompressedId {\n\tassert(\n\t\tfinalWithin >= cluster.baseFinalId && finalWithin <= lastAllocatedFinal(cluster),\n\t\t0x763 /* Supplied ID is not within the cluster. */,\n\t);\n\tconst finalDelta = finalWithin - cluster.baseFinalId;\n\treturn (cluster.baseLocalId - finalDelta) as LocalCompressedId;\n}\n\n/**\n * Returns the last allocated final ID (i.e. any ID between base final and base final + capacity) within a cluster\n */\nexport function lastAllocatedFinal(cluster: IdCluster): FinalCompressedId {\n\treturn ((cluster.baseFinalId as number) + (cluster.capacity - 1)) as FinalCompressedId;\n}\n\n/**\n * Returns the last allocated final ID (i.e. any ID between base final and base final + count) within a cluster\n */\nexport function lastFinalizedFinal(cluster: IdCluster): FinalCompressedId {\n\treturn ((cluster.baseFinalId as number) + (cluster.count - 1)) as FinalCompressedId;\n}\n\n/**\n * Returns the last allocated local ID (i.e. any ID between base local and base local + capacity) within a cluster\n */\nexport function lastAllocatedLocal(cluster: IdCluster): LocalCompressedId {\n\treturn ((cluster.baseLocalId as number) - (cluster.capacity - 1)) as LocalCompressedId;\n}\n\n/**\n * Returns the last allocated local ID (i.e. any ID between base local and base local + count) within a cluster\n */\nexport function lastFinalizedLocal(cluster: IdCluster): LocalCompressedId {\n\treturn ((cluster.baseLocalId as number) - (cluster.count - 1)) as LocalCompressedId;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressorTestUtilities.d.ts","sourceRoot":"","sources":["../../src/test/idCompressorTestUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,QAAQ,EAOb,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EAAE,YAAY,EAA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E,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,yBAAyB;IACzC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACnC;AAQD,wBAAgB,eAAe,CAC9B,OAAO,EAAE,yBAAyB,GAChC,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC,CA4FrC;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC,EAC9C,OAAO,EAAE,uBAAuB,EAChC,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,MAAM,EACvB,gBAAgB,GAAE,OAAc,EAChC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,EACtD,QAAQ,CAAC,EAAE,QAAQ,GACjB,IAAI,CA0DN;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,UAAU,EAAE,YAAY,EACxB,KAAK,EAAE,MAAM,GACX,wBAAwB,EAAE,CAM5B;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAChD,MAAM,CAAC,EAAE,oBAAoB,GAC3B,aAAa,GAAG,iBAAiB,CAAC;AACrC;;;GAGG;AACH,wBAAgB,iCAAiC,CAChD,SAAS,EAAE,SAAS,EACpB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,IAAI,CAAC,EAAE,MAAM,GACX,aAAa,GAAG,iBAAiB,CAAC"}
1
+ {"version":3,"file":"idCompressorTestUtilities.d.ts","sourceRoot":"","sources":["../../src/test/idCompressorTestUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,QAAQ,EAOb,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,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B,EAAE,MAAM,EAAE,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,yBAAyB;IACzC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACnC;AAQD,wBAAgB,eAAe,CAC9B,OAAO,EAAE,yBAAyB,GAChC,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC,CA4FrC;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC,EAC9C,OAAO,EAAE,uBAAuB,EAChC,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,MAAM,EACvB,gBAAgB,GAAE,OAAc,EAChC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,EACtD,QAAQ,CAAC,EAAE,QAAQ,GACjB,IAAI,CA0DN;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,UAAU,EAAE,YAAY,EACxB,KAAK,EAAE,MAAM,GACX,wBAAwB,EAAE,CAM5B;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAChD,MAAM,CAAC,EAAE,oBAAoB,GAC3B,aAAa,GAAG,iBAAiB,CAAC;AACrC;;;GAGG;AACH,wBAAgB,iCAAiC,CAChD,SAAS,EAAE,SAAS,EACpB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,IAAI,CAAC,EAAE,MAAM,GACX,aAAa,GAAG,iBAAiB,CAAC"}
@@ -371,6 +371,7 @@ class IdCompressorTestNetwork {
371
371
  (0, node_assert_1.strict)(range.sessionId === compressor.localSessionId);
372
372
  if (range.ids !== undefined) {
373
373
  // initialize firstGenCount if not set
374
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy
374
375
  if (firstGenCount === undefined) {
375
376
  firstGenCount = range.ids.firstGenCount;
376
377
  }
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressorTestUtilities.js","sourceRoot":"","sources":["../../src/test/idCompressorTestUtilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAA+C;AAE/C,gFAU8C;AAG9C,wDAAkD;AAClD,0CAWqB;AACrB,4EAAsE;AACtE,kDAA0F;AAE1F,mDAQyB;AASzB;;GAEG;AACH,IAAY,MAIX;AAJD,WAAY,MAAM;IACjB,6BAAmB,CAAA;IACnB,6BAAmB,CAAA;IACnB,6BAAmB,CAAA;AACpB,CAAC,EAJW,MAAM,sBAAN,MAAM,QAIjB;AAED;;GAEG;AACH,IAAY,UAEX;AAFD,WAAY,UAAU;IACrB,yBAAW,CAAA;AACZ,CAAC,EAFW,UAAU,0BAAV,UAAU,QAErB;AAED;;GAEG;AACH,IAAY,aAEX;AAFD,WAAY,aAAa;IACxB,kCAAiB,CAAA;AAClB,CAAC,EAFW,aAAa,6BAAb,aAAa,QAExB;AAOY,QAAA,iBAAiB,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,aAAa,EAAE,CAAC;AAMpD,QAAA,iBAAiB,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;AAE9D,kEAAkE;AAClE,MAAa,iBAAiB;IAC7B;;OAEG;IACI,MAAM,CAAC,gBAAgB,CAC7B,MAAc,EACd,eAAe,GAAG,CAAC,EACnB,MAA6B;QAE7B,OAAO,iBAAiB,CAAC,2BAA2B,CACnD,kBAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EACtB,eAAe,EACf,MAAM,CACN,CAAC;IACH,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,2BAA2B,CACxC,SAAoB,EACpB,eAAe,GAAG,CAAC,EACnB,MAA6B;QAE7B,MAAM,UAAU,GAAG,IAAA,6BAAkB,EAAC,SAAS,EAAE,MAAM,CAAiB,CAAC;QACzE,iBAAiB,CAA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* Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\n\nimport {\n\ttype BaseFuzzTestState,\n\ttype Generator,\n\ttype SaveInfo,\n\tcreateWeightedGenerator,\n\tinterleave,\n\tmakeRandom,\n\tperformFuzzActions as performFuzzActionsBase,\n\trepeat,\n\ttake,\n} from \"@fluid-private/stochastic-test-utils\";\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\n\nimport { IdCompressor } from \"../idCompressor.js\";\nimport {\n\ttype IIdCompressor,\n\ttype IIdCompressorCore,\n\ttype IdCreationRange,\n\ttype OpSpaceCompressedId,\n\ttype SerializedIdCompressorWithNoSession,\n\ttype SerializedIdCompressorWithOngoingSession,\n\ttype SessionId,\n\ttype SessionSpaceCompressedId,\n\ttype StableId,\n\tcreateIdCompressor,\n} from \"../index.js\";\nimport { SessionSpaceNormalizer } from \"../sessionSpaceNormalizer.js\";\nimport { assertIsSessionId, createSessionId, localIdFromGenCount } from \"../utilities.js\";\n\nimport {\n\ttype FinalCompressedId,\n\ttype ReadonlyIdCompressor,\n\tfail,\n\tgetOrCreate,\n\tincrementStableId,\n\tisFinalId,\n\tisLocalId,\n} from \"./testCommon.js\";\n\n/**\n * A readonly `Map` which is known to contain a value for every possible key\n */\nexport interface ClosedMap<K, V> extends Omit<Map<K, V>, \"delete\" | \"clear\"> {\n\tget(key: K): V;\n}\n\n/**\n * Identifies a compressor in a network\n */\nexport enum Client {\n\tClient1 = \"Client1\",\n\tClient2 = \"Client2\",\n\tClient3 = \"Client3\",\n}\n\n/**\n * Identifies categories of compressors\n */\nexport enum MetaClient {\n\tAll = \"All\",\n}\n\n/**\n * Identifies a compressor inside the network but outside the three specially tracked clients.\n */\nexport enum OutsideClient {\n\tRemote = \"Remote\",\n}\n\n/**\n * Used to attribute actions to clients in a distributed collaboration session.\n * `Local` implies a local and unsequenced operation. All others imply sequenced operations.\n */\nexport type OriginatingClient = Client | OutsideClient;\nexport const OriginatingClient = { ...Client, ...OutsideClient };\n\n/**\n * Identifies a compressor to which to send an operation\n */\nexport type DestinationClient = Client | MetaClient;\nexport const DestinationClient = { ...Client, ...MetaClient };\n\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport class CompressorFactory {\n\t/**\n\t * Creates a new compressor with the supplied cluster capacity.\n\t */\n\tpublic static createCompressor(\n\t\tclient: Client,\n\t\tclusterCapacity = 5,\n\t\tlogger?: ITelemetryBaseLogger,\n\t): IdCompressor {\n\t\treturn CompressorFactory.createCompressorWithSession(\n\t\t\tsessionIds.get(client),\n\t\t\tclusterCapacity,\n\t\t\tlogger,\n\t\t);\n\t}\n\n\t/**\n\t * Creates a new compressor with the supplied cluster capacity.\n\t */\n\tpublic static createCompressorWithSession(\n\t\tsessionId: SessionId,\n\t\tclusterCapacity = 5,\n\t\tlogger?: ITelemetryBaseLogger,\n\t): IdCompressor {\n\t\tconst compressor = createIdCompressor(sessionId, logger) as IdCompressor;\n\t\tmodifyClusterSize(compressor, clusterCapacity);\n\t\treturn compressor;\n\t}\n}\n\n/**\n * Modify the requested cluster size of the provided compressor.\n * @remarks\n * This is useful for testing purposes for a few reasons:\n * - Id compressor bugs are often related to edge cases that occur on cluster boundaries\n * - Smaller cluster sizes can enable writing tests without for loops generating \"ids until a new cluster is created\"\n */\nexport function modifyClusterSize(compressor: IIdCompressor, newClusterSize: number): void {\n\tverifyCompressorLike(compressor);\n\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\tcompressor[\"nextRequestedClusterSize\"] = newClusterSize;\n}\n\n/**\n * Returns the current cluster size of the compressor.\n * @privateRemarks\n * This is useful in writing tests to avoid having to hardcode the (currently constant) cluster size.\n */\nexport function getClusterSize(compressor: ReadonlyIdCompressor): number {\n\tverifyCompressorLike(compressor);\n\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\treturn compressor[\"nextRequestedClusterSize\"] as number;\n}\n\nfunction verifyCompressorLike(compressor: ReadonlyIdCompressor | IIdCompressor): void {\n\tassert(\n\t\t// Some IdCompressor tests wrap underlying compressors with proxies--allow this for now.\n\t\t// Because of id-compressor's dynamic import in container-runtime, instanceof checks for IdCompressor\n\t\t// also won't necessarily work nicely. Get a small amount of validation that this function should work\n\t\t// as intended by at least verifying the property name exists.\n\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\ttypeof compressor[\"nextRequestedClusterSize\"] === \"number\",\n\t);\n}\n\n/**\n * Utility for building a huge compressor.\n * Build via the compressor factory.\n */\nexport function buildHugeCompressor(\n\tnumSessions = 10000,\n\tcapacity = 10,\n\tnumClustersPerSession = 3,\n): IdCompressor {\n\tconst compressor = CompressorFactory.createCompressorWithSession(\n\t\tcreateSessionId(),\n\t\tcapacity,\n\t);\n\tconst sessions: SessionId[] = [];\n\tfor (let i = 0; i < numSessions; i++) {\n\t\tsessions.push(createSessionId());\n\t}\n\tfor (let i = 0; i < numSessions * numClustersPerSession; i++) {\n\t\tconst sessionId = sessions[i % numSessions];\n\t\tif (Math.random() > 0.1) {\n\t\t\tfor (let j = 0; j < Math.round(capacity / 2); j++) {\n\t\t\t\tcompressor.generateCompressedId();\n\t\t\t}\n\t\t\tcompressor.finalizeCreationRange(compressor.takeNextCreationRange());\n\t\t}\n\t\tcompressor.finalizeCreationRange({\n\t\t\tsessionId,\n\t\t\tids: {\n\t\t\t\tfirstGenCount: Math.floor(i / numSessions) * capacity + 1,\n\t\t\t\tcount: capacity,\n\t\t\t\trequestedClusterSize: capacity,\n\t\t\t\tlocalIdRanges: [], // remote session, can safely ignore in tests\n\t\t\t},\n\t\t});\n\t}\n\treturn compressor;\n}\n\n/**\n * A closed map from NamedClient to T.\n */\nexport type ClientMap<T> = ClosedMap<Client, T>;\n\nfunction makeSessionIds(): ClientMap<SessionId> {\n\tconst stableIds = new Map<Client, SessionId>();\n\tconst clients = Object.values(Client);\n\tfor (let i = 0; i < clients.length; i++) {\n\t\t// Place session uuids roughly in the middle of uuid space to increase odds of encountering interesting\n\t\t// orderings in sorted collections\n\t\tconst sessionId = assertIsSessionId(`88888888-8888-4888-b${i}88-888888888888`);\n\t\tstableIds.set(clients[i], sessionId);\n\t}\n\treturn stableIds as ClientMap<SessionId>;\n}\n\n/**\n * An array of session ID strings corresponding to all non-local `Client` entries.\n */\nexport const sessionIds = makeSessionIds();\n\n/**\n * Information about a generated ID in a network to be validated by tests\n */\nexport interface TestIdData {\n\treadonly id: SessionSpaceCompressedId;\n\treadonly originatingClient: OriginatingClient;\n\treadonly sessionId: SessionId;\n\treadonly isSequenced: boolean;\n}\n\n/**\n * Simulates a network of ID compressors.\n * Not suitable for performance testing.\n */\nexport class IdCompressorTestNetwork {\n\t/**\n\t * The compressors used in this network\n\t */\n\tprivate readonly compressors: ClientMap<IdCompressor>;\n\t/**\n\t * The log of operations seen by the server so far. Append-only.\n\t */\n\tprivate readonly serverOperations: [\n\t\tcreationRange: IdCreationRange,\n\t\topSpaceIds: OpSpaceCompressedId[],\n\t\tclientFrom: OriginatingClient,\n\t\tsessionIdFrom: SessionId,\n\t][] = [];\n\t/**\n\t * An index into `serverOperations` for each client which represents how many operations have been delivered to that client\n\t */\n\tprivate readonly clientProgress: ClientMap<number>;\n\t/**\n\t * All ids (local and sequenced) that a client has created or received, in order.\n\t */\n\tprivate readonly idLogs: ClientMap<TestIdData[]>;\n\t/**\n\t * All ids that a client has received from the server, in order.\n\t */\n\tprivate readonly sequencedIdLogs: ClientMap<TestIdData[]>;\n\n\tpublic constructor(public readonly initialClusterSize = 5) {\n\t\tconst compressors = new Map<Client, IdCompressor>();\n\t\tconst clientProgress = new Map<Client, number>();\n\t\tconst clientIds = new Map<Client, TestIdData[]>();\n\t\tconst clientSequencedIds = new Map<Client, TestIdData[]>();\n\t\tfor (const client of Object.values(Client)) {\n\t\t\tconst compressor = CompressorFactory.createCompressor(client, initialClusterSize);\n\t\t\tcompressors.set(client, compressor);\n\t\t\tclientProgress.set(client, 0);\n\t\t\tclientIds.set(client, []);\n\t\t\tclientSequencedIds.set(client, []);\n\t\t}\n\t\tthis.compressors = compressors as ClientMap<IdCompressor>;\n\t\tthis.clientProgress = clientProgress as ClientMap<number>;\n\t\tthis.idLogs = clientIds as ClientMap<TestIdData[]>;\n\t\tthis.sequencedIdLogs = clientSequencedIds as ClientMap<TestIdData[]>;\n\t}\n\n\t/**\n\t * Returns the number of undelivered operations for the given client that are in flight in the network.\n\t */\n\tpublic getPendingOperations(destination: Client): number {\n\t\treturn this.serverOperations.length - this.clientProgress.get(destination);\n\t}\n\n\t/**\n\t * Returns an immutable handle to a compressor in the network.\n\t */\n\tpublic getCompressor(client: Client): ReadonlyIdCompressor {\n\t\tconst compressors = this.compressors;\n\t\tconst handler = {\n\t\t\tget<P extends keyof IdCompressor>(_: unknown, property: P): IdCompressor[P] {\n\t\t\t\treturn compressors.get(client)[property];\n\t\t\t},\n\t\t\tset<P extends keyof IdCompressor>(\n\t\t\t\t_: unknown,\n\t\t\t\tproperty: P,\n\t\t\t\tvalue: IdCompressor[P],\n\t\t\t): boolean {\n\t\t\t\tcompressors.get(client)[property] = value;\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\t\treturn new Proxy<IdCompressor>({} as unknown as IdCompressor, handler);\n\t}\n\n\t/**\n\t * Returns a mutable handle to a compressor in the network. Use of mutation methods will break the network invariants and\n\t * should only be used if the network will not be used again.\n\t */\n\tpublic getCompressorUnsafe(client: Client): IdCompressor {\n\t\treturn this.getCompressor(client) as IdCompressor;\n\t}\n\n\t/**\n\t * Returns a mutable handle to a compressor in the network. Use of mutation methods will break the network invariants and\n\t * should only be used if the network will not be used again. Additionally, the returned compressor will be invalidated/unusable\n\t * if any network operations cause it to be regenerated (serialization/deserialization, etc.).\n\t */\n\tpublic getCompressorUnsafeNoProxy(client: Client): IdCompressor {\n\t\treturn this.compressors.get(client);\n\t}\n\n\t/**\n\t * Returns data for all IDs created and received by this client, including ack's of their own (i.e. their own IDs will appear twice)\n\t */\n\tpublic getIdLog(client: Client): readonly TestIdData[] {\n\t\treturn this.idLogs.get(client);\n\t}\n\n\t/**\n\t * Returns data for all IDs received by this client, including ack's of their own.\n\t */\n\tpublic getSequencedIdLog(client: Client): readonly TestIdData[] {\n\t\treturn this.sequencedIdLogs.get(client);\n\t}\n\n\t/**\n\t * Get all compressors for the given destination\n\t */\n\tpublic getTargetCompressors(clientTo: DestinationClient): [Client, IdCompressor][] {\n\t\treturn clientTo === MetaClient.All\n\t\t\t? [...this.compressors.entries()]\n\t\t\t: ([[clientTo, this.getCompressor(clientTo)]] as [Client, IdCompressor][]);\n\t}\n\n\t/**\n\t * Changes the capacity request amount for a client. It will take effect immediately.\n\t */\n\tpublic changeCapacity(client: Client, newClusterCapacity: number): void {\n\t\tmodifyClusterSize(this.compressors.get(client), newClusterCapacity);\n\t}\n\n\tprivate addNewId(\n\t\tclient: Client,\n\t\tid: SessionSpaceCompressedId,\n\t\toriginatingClient: OriginatingClient,\n\t\tsessionIdFrom: SessionId,\n\t\tisSequenced: boolean,\n\t): void {\n\t\tconst idData = {\n\t\t\tid,\n\t\t\toriginatingClient,\n\t\t\tsessionId: sessionIdFrom,\n\t\t\tisSequenced,\n\t\t};\n\t\tconst clientIds = this.idLogs.get(client);\n\t\tclientIds.push(idData);\n\t\tif (isSequenced) {\n\t\t\tconst sequencedIds = this.sequencedIdLogs.get(client);\n\t\t\tsequencedIds.push(idData);\n\t\t}\n\t}\n\n\t/**\n\t * Allocates a new range of local IDs and enqueues them for future delivery via a `testIdDelivery` action.\n\t * Calls to this method determine the total order of delivery, regardless of when `deliverOperations` is called.\n\t */\n\tpublic allocateAndSendIds(clientFrom: Client, numIds: number): OpSpaceCompressedId[] {\n\t\treturn this.allocateAndSendIdsFromRemoteClient(\n\t\t\tclientFrom,\n\t\t\tsessionIds.get(clientFrom),\n\t\t\tnumIds,\n\t\t);\n\t}\n\n\t/**\n\t * Same contract as `allocateAndSendIds`, but the originating client will be a client with the supplied sessionId.\n\t */\n\tpublic allocateAndSendIdsFromRemoteClient(\n\t\tclientFrom: OriginatingClient,\n\t\tsessionIdFrom: SessionId,\n\t\tnumIds: number,\n\t): OpSpaceCompressedId[] {\n\t\tassert(numIds > 0, \"Must allocate a non-zero number of IDs\");\n\t\tif (clientFrom === OriginatingClient.Remote) {\n\t\t\tconst range: IdCreationRange = {\n\t\t\t\tsessionId: sessionIdFrom,\n\t\t\t\tids: {\n\t\t\t\t\tfirstGenCount: 1,\n\t\t\t\t\tcount: numIds,\n\t\t\t\t\trequestedClusterSize: getClusterSize(this.getCompressor(Client.Client1)),\n\t\t\t\t\tlocalIdRanges: [], // remote session, can safely ignore in tests\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst opSpaceIds: OpSpaceCompressedId[] = [];\n\t\t\tfor (let i = 0; i < numIds; i++) {\n\t\t\t\topSpaceIds.push(-(i + 1) as OpSpaceCompressedId);\n\t\t\t}\n\t\t\tthis.serverOperations.push([range, opSpaceIds, clientFrom, sessionIdFrom]);\n\t\t\treturn opSpaceIds;\n\t\t} else {\n\t\t\tassert(sessionIdFrom === sessionIds.get(clientFrom));\n\t\t\tconst compressor = this.compressors.get(clientFrom);\n\t\t\tconst sessionSpaceIds = generateCompressedIds(compressor, numIds);\n\t\t\tfor (let i = 0; i < numIds; i++) {\n\t\t\t\tthis.addNewId(clientFrom, sessionSpaceIds[i], clientFrom, sessionIdFrom, false);\n\t\t\t}\n\t\t\tconst opSpaceIds = sessionSpaceIds.map((id) => compressor.normalizeToOpSpace(id));\n\t\t\tconst creationRange = compressor.takeNextCreationRange();\n\t\t\tthis.serverOperations.push([creationRange, opSpaceIds, clientFrom, sessionIdFrom]);\n\t\t\treturn opSpaceIds;\n\t\t}\n\t}\n\n\t/**\n\t * Delivers all undelivered ID ranges from the server to the target clients.\n\t */\n\tpublic deliverOperations(clientTakingDelivery: Client, opsToDeliver?: number): void;\n\n\t/**\n\t * Delivers all undelivered ID ranges from the server to the target clients.\n\t */\n\tpublic deliverOperations(clientTakingDelivery: DestinationClient): void;\n\n\t/**\n\t * Delivers all undelivered ID ranges from the server to the target clients.\n\t */\n\tpublic deliverOperations(\n\t\tclientTakingDelivery: DestinationClient,\n\t\topsToDeliver?: number,\n\t): void {\n\t\tlet opIndexBound: number;\n\t\tif (clientTakingDelivery === DestinationClient.All) {\n\t\t\tassert(opsToDeliver === undefined);\n\t\t\topIndexBound = this.serverOperations.length;\n\t\t} else {\n\t\t\topIndexBound =\n\t\t\t\topsToDeliver === undefined\n\t\t\t\t\t? this.serverOperations.length\n\t\t\t\t\t: this.clientProgress.get(clientTakingDelivery) + opsToDeliver;\n\t\t}\n\t\tfor (const [clientTo, compressorTo] of this.getTargetCompressors(clientTakingDelivery)) {\n\t\t\tfor (let i = this.clientProgress.get(clientTo); i < opIndexBound; i++) {\n\t\t\t\tconst [range, opSpaceIds, clientFrom, sessionIdFrom] = this.serverOperations[i];\n\t\t\t\tcompressorTo.finalizeCreationRange(range);\n\n\t\t\t\tconst ids = range.ids;\n\t\t\t\tif (ids !== undefined) {\n\t\t\t\t\tfor (const id of opSpaceIds) {\n\t\t\t\t\t\tconst sessionSpaceId = compressorTo.normalizeToSessionSpace(id, range.sessionId);\n\t\t\t\t\t\tthis.addNewId(clientTo, sessionSpaceId, clientFrom, sessionIdFrom, true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.clientProgress.set(clientTo, opIndexBound);\n\t\t}\n\t}\n\n\t/**\n\t * Simulate a client disconnecting (and serializing), then reconnecting (and deserializing)\n\t */\n\tpublic goOfflineThenResume(client: Client): void {\n\t\tconst compressor = this.compressors.get(client);\n\t\tconst [_, resumedCompressor] = roundtrip(compressor, true);\n\t\tthis.compressors.set(client, resumedCompressor);\n\t}\n\n\t/**\n\t * Ensure general validity of the network state. Useful for calling periodically or at the end of test scenarios.\n\t */\n\tpublic assertNetworkState(): void {\n\t\tconst sequencedLogs = Object.values(Client).map(\n\t\t\t(client) => [this.compressors.get(client), this.getSequencedIdLog(client)] as const,\n\t\t);\n\n\t\tconst getLocalIdsInRange = (\n\t\t\trange: IdCreationRange,\n\t\t\topSpaceIds?: OpSpaceCompressedId[],\n\t\t): Set<SessionSpaceCompressedId> => {\n\t\t\tconst localIdsInCreationRange = new Set<SessionSpaceCompressedId>();\n\t\t\tconst ids = range.ids;\n\t\t\tif (ids !== undefined) {\n\t\t\t\tconst { firstGenCount, localIdRanges } = ids;\n\t\t\t\tfor (const [genCount, count] of localIdRanges) {\n\t\t\t\t\tfor (let g = genCount; g < genCount + count; g++) {\n\t\t\t\t\t\tconst local = localIdFromGenCount(g);\n\t\t\t\t\t\tif (opSpaceIds) {\n\t\t\t\t\t\t\tassert.strictEqual(opSpaceIds[g - firstGenCount], local);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlocalIdsInCreationRange.add(local);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn localIdsInCreationRange;\n\t\t};\n\n\t\t// Ensure creation ranges for clients we track contain the correct local ID ranges\n\t\tfor (const [range, opSpaceIds, clientFrom] of this.serverOperations) {\n\t\t\tif (clientFrom !== OriginatingClient.Remote) {\n\t\t\t\tconst localIdsInCreationRange = getLocalIdsInRange(range, opSpaceIds);\n\t\t\t\tlet localCount = 0;\n\t\t\t\tfor (const id of opSpaceIds) {\n\t\t\t\t\tif (isLocalId(id)) {\n\t\t\t\t\t\tlocalCount++;\n\t\t\t\t\t\tassert(localIdsInCreationRange.has(id), \"Local ID not in creation range\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\tlocalCount,\n\t\t\t\t\tlocalIdsInCreationRange.size,\n\t\t\t\t\t\"Local ID count mismatch\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst undeliveredRanges = new Map<Client, IdCreationRange[]>();\n\t\tfor (const [client, progress] of this.clientProgress.entries()) {\n\t\t\tconst ranges = this.serverOperations\n\t\t\t\t.slice(progress)\n\t\t\t\t.filter((op) => op[2] === client)\n\t\t\t\t.map(([range]) => range);\n\t\t\tundeliveredRanges.set(client, ranges);\n\t\t}\n\t\tfor (const [client, ranges] of undeliveredRanges.entries()) {\n\t\t\tconst compressor = this.compressors.get(client);\n\t\t\tlet firstGenCount: number | undefined;\n\t\t\tlet totalCount = 0;\n\t\t\tconst unionedLocalRanges = new SessionSpaceNormalizer();\n\t\t\tfor (const range of ranges) {\n\t\t\t\tassert(range.sessionId === compressor.localSessionId);\n\t\t\t\tif (range.ids !== undefined) {\n\t\t\t\t\t// initialize firstGenCount if not set\n\t\t\t\t\tif (firstGenCount === undefined) {\n\t\t\t\t\t\tfirstGenCount = range.ids.firstGenCount;\n\t\t\t\t\t}\n\t\t\t\t\ttotalCount += range.ids.count;\n\t\t\t\t\tfor (const [genCount, count] of range.ids.localIdRanges) {\n\t\t\t\t\t\tunionedLocalRanges.addLocalRange(genCount, count);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst retakenRange = compressor.takeUnfinalizedCreationRange();\n\t\t\tif (retakenRange.ids === undefined) {\n\t\t\t\tassert.strictEqual(totalCount, 0);\n\t\t\t\tassert.strictEqual(unionedLocalRanges.idRanges.size, 0);\n\t\t\t} else {\n\t\t\t\tconst retakenLocalIds = new SessionSpaceNormalizer();\n\t\t\t\tfor (const [genCount, count] of retakenRange.ids.localIdRanges) {\n\t\t\t\t\tretakenLocalIds.addLocalRange(genCount, count);\n\t\t\t\t}\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\tretakenLocalIds.equals(unionedLocalRanges),\n\t\t\t\t\ttrue,\n\t\t\t\t\t\"Local ID ranges mismatch\",\n\t\t\t\t);\n\t\t\t\tassert.strictEqual(retakenRange.ids.count, totalCount, \"Count mismatch\");\n\t\t\t\tassert.strictEqual(retakenRange.ids.firstGenCount, firstGenCount, \"Count mismatch\");\n\t\t\t}\n\t\t}\n\n\t\t// First, ensure all clients each generated a unique ID for each of their own calls to generate.\n\t\tfor (const [compressor, ids] of sequencedLogs) {\n\t\t\tconst allUuids = new Set<StableId | string>();\n\t\t\tfor (const idData of ids) {\n\t\t\t\tconst uuid = compressor.decompress(idData.id);\n\t\t\t\tassert.strictEqual(!allUuids.has(uuid), true, \"Duplicate UUID generated.\");\n\t\t\t\tallUuids.add(uuid);\n\t\t\t}\n\t\t}\n\n\t\tconst maxLogLength = sequencedLogs\n\t\t\t.map(([_, data]) => data.length)\n\t\t\t// eslint-disable-next-line unicorn/no-array-reduce\n\t\t\t.reduce((p, n) => Math.max(p, n));\n\n\t\tfunction getNextLogWithEntryAt(logsIndex: number, entryIndex: number): number | undefined {\n\t\t\tfor (let i = logsIndex; i < sequencedLogs.length; i++) {\n\t\t\t\tconst log = sequencedLogs[i];\n\t\t\t\tif (log[1].length > entryIndex) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst uuids = new Set<StableId>();\n\t\tconst finalIds = new Set<FinalCompressedId>();\n\t\tconst idIndicesAggregator = new Map<SessionId, number>();\n\n\t\tfunction* getIdLogEntries(\n\t\t\tcolumnIndex: number,\n\t\t): Iterable<\n\t\t\t[\n\t\t\t\tcurrent: [compressor: IdCompressor, idData: TestIdData],\n\t\t\t\tnext?: [compressor: IdCompressor, idData: TestIdData],\n\t\t\t]\n\t\t> {\n\t\t\tlet current = getNextLogWithEntryAt(0, columnIndex);\n\t\t\twhile (current !== undefined) {\n\t\t\t\tconst next = getNextLogWithEntryAt(current + 1, columnIndex);\n\t\t\t\tconst [compressor, log] = sequencedLogs[current];\n\t\t\t\tif (next === undefined) {\n\t\t\t\t\tyield [[compressor, log[columnIndex]]];\n\t\t\t\t} else {\n\t\t\t\t\tconst [compressorNext, logNext] = sequencedLogs[next];\n\t\t\t\t\tyield [\n\t\t\t\t\t\t[compressor, log[columnIndex]],\n\t\t\t\t\t\t[compressorNext, logNext[columnIndex]],\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\tcurrent = next;\n\t\t\t}\n\t\t}\n\n\t\tfor (let i = 0; i < maxLogLength; i++) {\n\t\t\tlet idCreatorCount = 0;\n\t\t\tlet originatingSession: SessionId | undefined;\n\t\t\tfor (const [current, next] of getIdLogEntries(i)) {\n\t\t\t\tconst [compressorA, idDataA] = current;\n\t\t\t\tconst sessionSpaceIdA = idDataA.id;\n\t\t\t\tconst idIndex = getOrCreate(idIndicesAggregator, idDataA.sessionId, () => 0);\n\t\t\t\toriginatingSession ??= idDataA.sessionId;\n\t\t\t\tassert(\n\t\t\t\t\tidDataA.sessionId === originatingSession,\n\t\t\t\t\t\"Test infra gave wrong originating client to TestIdData\",\n\t\t\t\t);\n\n\t\t\t\t// Only one client should have this ID as local in its session space, as only one client could have created this ID\n\t\t\t\tif (isLocalId(sessionSpaceIdA)) {\n\t\t\t\t\tif (originatingSession !== OriginatingClient.Remote) {\n\t\t\t\t\t\tassert.strictEqual(\n\t\t\t\t\t\t\tidDataA.sessionId,\n\t\t\t\t\t\t\tthis.compressors.get(idDataA.originatingClient as Client).localSessionId,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tidCreatorCount++;\n\t\t\t\t}\n\n\t\t\t\tconst uuidASessionSpace = compressorA.decompress(sessionSpaceIdA);\n\t\t\t\tassert.strictEqual(uuidASessionSpace, incrementStableId(idDataA.sessionId, idIndex));\n\t\t\t\tassert.strictEqual(compressorA.recompress(uuidASessionSpace), sessionSpaceIdA);\n\t\t\t\tuuids.add(uuidASessionSpace);\n\t\t\t\tconst opSpaceIdA = compressorA.normalizeToOpSpace(sessionSpaceIdA);\n\t\t\t\tif (!isFinalId(opSpaceIdA)) {\n\t\t\t\t\tfail(\"IDs should have been finalized.\");\n\t\t\t\t}\n\t\t\t\tconst reNormalizedIdA = compressorA.normalizeToSessionSpace(\n\t\t\t\t\topSpaceIdA,\n\t\t\t\t\tcompressorA.localSessionId,\n\t\t\t\t);\n\t\t\t\tassert.strictEqual(reNormalizedIdA, sessionSpaceIdA);\n\t\t\t\tfinalIds.add(opSpaceIdA);\n\t\t\t\tconst uuidAOpSpace = compressorA.decompress(reNormalizedIdA);\n\n\t\t\t\tassert.strictEqual(uuidASessionSpace, uuidAOpSpace);\n\n\t\t\t\tif (next !== undefined) {\n\t\t\t\t\tconst [compressorB, idDataB] = next;\n\t\t\t\t\tconst sessionSpaceIdB = idDataB.id;\n\n\t\t\t\t\tconst uuidBSessionSpace = compressorB.decompress(sessionSpaceIdB);\n\t\t\t\t\tassert.strictEqual(uuidASessionSpace, uuidBSessionSpace);\n\t\t\t\t\tconst opSpaceIdB = compressorB.normalizeToOpSpace(sessionSpaceIdB);\n\t\t\t\t\tif (opSpaceIdA !== opSpaceIdB) {\n\t\t\t\t\t\tcompressorB.normalizeToOpSpace(sessionSpaceIdB);\n\t\t\t\t\t\tcompressorA.normalizeToOpSpace(sessionSpaceIdA);\n\t\t\t\t\t}\n\t\t\t\t\tassert.strictEqual(opSpaceIdA, opSpaceIdB);\n\t\t\t\t\tif (!isFinalId(opSpaceIdB)) {\n\t\t\t\t\t\tfail(\"IDs should have been finalized.\");\n\t\t\t\t\t}\n\t\t\t\t\tconst uuidBOpSpace = compressorB.decompress(\n\t\t\t\t\t\topSpaceIdB as unknown as SessionSpaceCompressedId,\n\t\t\t\t\t);\n\t\t\t\t\tassert.strictEqual(uuidAOpSpace, uuidBOpSpace);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tassert(idCreatorCount <= 1, \"Only one client can create an ID.\");\n\t\t\tassert.strictEqual(uuids.size, finalIds.size);\n\t\t\tassert(originatingSession !== undefined, \"Expected originating client to be defined\");\n\t\t\tidIndicesAggregator.set(\n\t\t\t\toriginatingSession,\n\n\t\t\t\t(idIndicesAggregator.get(originatingSession) ??\n\t\t\t\t\tfail(\"Expected pre-existing index for originating client\")) + 1,\n\t\t\t);\n\t\t}\n\n\t\tfor (const [compressor] of sequencedLogs) {\n\t\t\texpectSerializes(compressor);\n\t\t}\n\t}\n}\n\n/**\n * Roundtrips the supplied compressor through serialization and deserialization.\n */\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: true,\n): [SerializedIdCompressorWithOngoingSession, IdCompressor];\n\n/**\n * Roundtrips the supplied compressor through serialization and deserialization.\n */\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: false,\n): [SerializedIdCompressorWithNoSession, IdCompressor];\n\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: boolean,\n): [\n\tSerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession,\n\tIdCompressor,\n] {\n\t// preserve the capacity request as this property is normally private and resets\n\t// to a default on construction (deserialization)\n\tconst capacity: number = getClusterSize(compressor);\n\tif (withSession) {\n\t\tconst serialized = compressor.serialize(withSession);\n\t\tconst roundtripped = IdCompressor.deserialize({ serialized });\n\t\tmodifyClusterSize(roundtripped, capacity);\n\t\treturn [serialized, roundtripped];\n\t} else {\n\t\tconst nonLocalSerialized = compressor.serialize(withSession);\n\t\tconst roundtripped = IdCompressor.deserialize({\n\t\t\tserialized: nonLocalSerialized,\n\t\t\tnewSessionId: createSessionId(),\n\t\t});\n\t\tmodifyClusterSize(roundtripped, capacity);\n\t\treturn [nonLocalSerialized, roundtripped];\n\t}\n}\n\n/**\n * Asserts that the supplied compressor correctly roundtrips through serialization/deserialization.\n */\nexport function expectSerializes(\n\tcompressor: ReadonlyIdCompressor,\n): [SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession] {\n\tfunction expectSerializesWithSession(\n\t\twithSession: boolean,\n\t): SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession {\n\t\tlet serialized:\n\t\t\t| SerializedIdCompressorWithOngoingSession\n\t\t\t| SerializedIdCompressorWithNoSession;\n\t\tlet deserialized: IdCompressor;\n\t\tif (withSession) {\n\t\t\t[serialized, deserialized] = roundtrip(compressor, true);\n\t\t} else {\n\t\t\t[serialized, deserialized] = roundtrip(compressor, false);\n\t\t}\n\t\tassert.strictEqual(compressor.equals(deserialized, withSession), true);\n\t\treturn serialized;\n\t}\n\n\treturn [\n\t\texpectSerializesWithSession(false) as SerializedIdCompressorWithNoSession,\n\t\texpectSerializesWithSession(true) as SerializedIdCompressorWithOngoingSession,\n\t];\n}\n\n/**\n * Merges 'from' into 'to', and returns 'to'.\n */\nexport function mergeArrayMaps<K, V>(\n\tto: Pick<Map<K, V[]>, \"get\" | \"set\">,\n\tfrom: ReadonlyMap<K, V[]>,\n): Pick<Map<K, V[]>, \"get\" | \"set\"> {\n\tfor (const [key, value] of from.entries()) {\n\t\tconst entry = to.get(key);\n\t\tif (entry === undefined) {\n\t\t\tto.set(key, [...value]);\n\t\t} else {\n\t\t\tentry.push(...value);\n\t\t}\n\t}\n\treturn to;\n}\n\ninterface AllocateIds {\n\ttype: \"allocateIds\";\n\tclient: Client;\n\tnumIds: number;\n}\n\ninterface AllocateOutsideIds {\n\ttype: \"allocateOutsideIds\";\n\tsessionId: SessionId;\n\tnumIds: number;\n}\n\ninterface DeliverAllOperations {\n\ttype: \"deliverAllOperations\";\n}\n\ninterface DeliverSomeOperations {\n\ttype: \"deliverSomeOperations\";\n\tclient: Client;\n\tcount: number;\n}\n\ninterface ChangeCapacity {\n\ttype: \"changeCapacity\";\n\tclient: Client;\n\tnewSize: number;\n}\n\n// Represents intent to go offline then resume.\ninterface Reconnect {\n\ttype: \"reconnect\";\n\tclient: Client;\n}\n\ninterface Validate {\n\ttype: \"validate\";\n}\n\ntype Operation =\n\t| AllocateIds\n\t| AllocateOutsideIds\n\t| DeliverSomeOperations\n\t| DeliverAllOperations\n\t| ChangeCapacity\n\t| Reconnect\n\t| Validate;\n\ninterface FuzzTestState extends BaseFuzzTestState {\n\tnetwork: IdCompressorTestNetwork;\n\tactiveClients: Client[];\n\tselectableClients: Client[];\n\tclusterSize: number;\n}\n\nexport interface OperationGenerationConfig {\n\t/**\n\t * maximum cluster size of the network. Default: 25\n\t */\n\tmaxClusterSize?: number;\n\t/**\n\t * Number of ops between validation ops. Default: 200\n\t */\n\tvalidateInterval?: number;\n\t/**\n\t * Fraction of ID allocations that are from an outside client (not Client1/2/3).\n\t */\n\toutsideAllocationFraction?: number;\n}\n\nconst defaultOptions = {\n\tmaxClusterSize: 25,\n\tvalidateInterval: 200,\n\toutsideAllocationFraction: 0.1,\n};\n\nexport function makeOpGenerator(\n\toptions: OperationGenerationConfig,\n): Generator<Operation, FuzzTestState> {\n\tconst { maxClusterSize, validateInterval, outsideAllocationFraction } = {\n\t\t...defaultOptions,\n\t\t...options,\n\t};\n\tassert(outsideAllocationFraction >= 0 && outsideAllocationFraction <= 1);\n\n\tfunction allocateIdsGenerator({\n\t\tactiveClients,\n\t\tclusterSize,\n\t\trandom,\n\t}: FuzzTestState): AllocateIds {\n\t\tconst client = random.pick(activeClients);\n\t\tconst maxIdsPerUsage = clusterSize * 2;\n\t\tconst numIds = Math.floor(random.real(0, 1) ** 3 * maxIdsPerUsage) + 1;\n\t\treturn {\n\t\t\ttype: \"allocateIds\",\n\t\t\tclient,\n\t\t\tnumIds,\n\t\t};\n\t}\n\n\tfunction allocateOutsideIdsGenerator({\n\t\tclusterSize,\n\t\trandom,\n\t}: FuzzTestState): AllocateOutsideIds {\n\t\tconst maxIdsPerUsage = clusterSize * 2;\n\t\tconst numIds = Math.floor(random.real(0, 1) ** 3 * maxIdsPerUsage) + 1;\n\t\treturn {\n\t\t\ttype: \"allocateOutsideIds\",\n\t\t\tsessionId: createSessionId(),\n\t\t\tnumIds,\n\t\t};\n\t}\n\n\tfunction changeCapacityGenerator({ random, activeClients }: FuzzTestState): ChangeCapacity {\n\t\treturn {\n\t\t\ttype: \"changeCapacity\",\n\t\t\tclient: random.pick(activeClients),\n\t\t\tnewSize: Math.min(\n\t\t\t\tMath.floor(random.real(0, 1) ** 2 * maxClusterSize) + 1,\n\t\t\t\tmaxClusterSize,\n\t\t\t),\n\t\t};\n\t}\n\n\tfunction deliverAllOperationsGenerator(): DeliverAllOperations {\n\t\treturn {\n\t\t\ttype: \"deliverAllOperations\",\n\t\t};\n\t}\n\n\tfunction deliverSomeOperationsGenerator({\n\t\trandom,\n\t\tselectableClients,\n\t\tnetwork,\n\t}: FuzzTestState): DeliverSomeOperations {\n\t\tconst pendingClients = selectableClients.filter(\n\t\t\t(c) => network.getPendingOperations(c) > 0,\n\t\t);\n\t\tif (pendingClients.length === 0) {\n\t\t\treturn {\n\t\t\t\ttype: \"deliverSomeOperations\",\n\t\t\t\tclient: random.pick(selectableClients),\n\t\t\t\tcount: 0,\n\t\t\t};\n\t\t}\n\t\tconst client = random.pick(pendingClients);\n\t\treturn {\n\t\t\ttype: \"deliverSomeOperations\",\n\t\t\tclient,\n\t\t\tcount: random.integer(1, network.getPendingOperations(client)),\n\t\t};\n\t}\n\n\tfunction reconnectGenerator({ activeClients, random }: FuzzTestState): Reconnect {\n\t\treturn { type: \"reconnect\", client: random.pick(activeClients) };\n\t}\n\n\tconst allocationWeight = 20;\n\treturn interleave(\n\t\tcreateWeightedGenerator<Operation, FuzzTestState>([\n\t\t\t[changeCapacityGenerator, 1],\n\t\t\t[allocateIdsGenerator, Math.round(allocationWeight * (1 - outsideAllocationFraction))],\n\t\t\t[allocateOutsideIdsGenerator, Math.round(allocationWeight * outsideAllocationFraction)],\n\t\t\t[deliverAllOperationsGenerator, 1],\n\t\t\t[deliverSomeOperationsGenerator, 6],\n\t\t\t[reconnectGenerator, 1],\n\t\t]),\n\t\ttake(1, repeat<Operation, FuzzTestState>({ type: \"validate\" })),\n\t\tvalidateInterval,\n\t);\n}\n\n/**\n * Performs random actions on a test network.\n * @param generator - the generator used to provide operations\n * @param network - the test network to test\n * @param seed - the seed for the random generation of the fuzz actions\n * @param observerClient - if provided, this client will never generate local ids\n * @param synchronizeAtEnd - if provided, all client will have all operations delivered from the server at the end of the test\n * @param validator - if provided, this callback will be invoked periodically during the fuzz test.\n */\nexport function performFuzzActions(\n\tgenerator: Generator<Operation, FuzzTestState>,\n\tnetwork: IdCompressorTestNetwork,\n\tseed: number,\n\tobserverClient?: Client,\n\tsynchronizeAtEnd: boolean = true,\n\tvalidator?: (network: IdCompressorTestNetwork) => void,\n\tsaveInfo?: SaveInfo,\n): void {\n\tconst random = makeRandom(seed);\n\tconst selectableClients: Client[] = network\n\t\t.getTargetCompressors(MetaClient.All)\n\t\t.map(([client]) => client);\n\n\tconst initialState: FuzzTestState = {\n\t\trandom,\n\t\tnetwork,\n\t\tactiveClients: selectableClients.filter((c) => c !== observerClient),\n\t\tselectableClients,\n\t\tclusterSize: network.initialClusterSize,\n\t};\n\n\tperformFuzzActionsBase(\n\t\tgenerator,\n\t\t{\n\t\t\tallocateIds: (state, { client, numIds }) => {\n\t\t\t\tnetwork.allocateAndSendIdsFromRemoteClient(client, sessionIds.get(client), numIds);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tallocateOutsideIds: (state, { sessionId, numIds }) => {\n\t\t\t\tnetwork.allocateAndSendIdsFromRemoteClient(\n\t\t\t\t\tOriginatingClient.Remote,\n\t\t\t\t\tsessionId,\n\t\t\t\t\tnumIds,\n\t\t\t\t);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tchangeCapacity: (state, op) => {\n\t\t\t\tnetwork.changeCapacity(op.client, op.newSize);\n\t\t\t\treturn { ...state, clusterSize: op.newSize };\n\t\t\t},\n\t\t\tdeliverSomeOperations: (state, op) => {\n\t\t\t\tnetwork.deliverOperations(op.client, op.count);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tdeliverAllOperations: (state) => {\n\t\t\t\tnetwork.deliverOperations(DestinationClient.All);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\treconnect: (state, { client }) => {\n\t\t\t\tnetwork.goOfflineThenResume(client);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tvalidate: (state) => {\n\t\t\t\tvalidator?.(network);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t},\n\t\tinitialState,\n\t\tsaveInfo,\n\t);\n\n\tif (synchronizeAtEnd) {\n\t\tnetwork.deliverOperations(DestinationClient.All);\n\t\tvalidator?.(network);\n\t}\n}\n\n/**\n * Helper to generate a fixed number of IDs.\n */\nexport function generateCompressedIds(\n\tcompressor: IdCompressor,\n\tcount: number,\n): SessionSpaceCompressedId[] {\n\tconst ids: SessionSpaceCompressedId[] = [];\n\tfor (let i = 0; i < count; i++) {\n\t\tids.push(compressor.generateCompressedId());\n\t}\n\treturn ids;\n}\n\n/**\n * Creates a compressor that only produces final IDs.\n * It should only be used for testing purposes.\n */\nexport function createAlwaysFinalizedIdCompressor(\n\tlogger?: ITelemetryBaseLogger,\n): IIdCompressor & IIdCompressorCore;\n/**\n * Creates a compressor that only produces final IDs.\n * It should only be used for testing purposes.\n */\nexport function createAlwaysFinalizedIdCompressor(\n\tsessionId: SessionId,\n\tlogger?: ITelemetryBaseLogger,\n\tseed?: number,\n): IIdCompressor & IIdCompressorCore;\nexport function createAlwaysFinalizedIdCompressor(\n\tsessionIdOrLogger?: SessionId | ITelemetryBaseLogger,\n\tloggerOrUndefined?: ITelemetryBaseLogger,\n\tseed?: number,\n): IIdCompressor & IIdCompressorCore {\n\tconst random = seed === undefined ? makeRandom() : makeRandom(seed);\n\tconst sessionId =\n\t\ttypeof sessionIdOrLogger === \"string\" ? sessionIdOrLogger : (random.uuid4() as SessionId);\n\tconst logger =\n\t\t(loggerOrUndefined ?? typeof sessionIdOrLogger === \"object\")\n\t\t\t? (sessionIdOrLogger as ITelemetryBaseLogger)\n\t\t\t: undefined;\n\t// This local session is unused, but it needs to not collide with the GhostSession, so allocate a random one.\n\t// This causes the compressor to serialize non-deterministically even when provided an explicit SessionId.\n\t// This can be fixed in the future if needed.\n\tconst compressor = createIdCompressor(random.uuid4() as SessionId, logger);\n\t// Permanently put the compressor in a ghost session\n\t(compressor as IdCompressor).startGhostSession(sessionId);\n\treturn compressor;\n}\n"]}
1
+ {"version":3,"file":"idCompressorTestUtilities.js","sourceRoot":"","sources":["../../src/test/idCompressorTestUtilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAA+C;AAE/C,gFAU8C;AAG9C,wDAAkD;AAClD,0CAWqB;AACr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AG,GAA+B,EAAE,CAAC;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AATD,sDASC;AAkBD,SAAgB,iCAAiC,CAChD,iBAAoD,EACpD,iBAAwC,EACxC,IAAa;IAEb,MAAM,MAAM,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAA,kCAAU,GAAE,CAAC,CAAC,CAAC,IAAA,kCAAU,EAAC,IAAI,CAAC,CAAC;IACpE,MAAM,SAAS,GACd,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAE,MAAM,CAAC,KAAK,EAAgB,CAAC;IAC3F,MAAM,MAAM,GACX,CAAC,iBAAiB,IAAI,OAAO,iBAAiB,KAAK,QAAQ,CAAC;QAC3D,CAAC,CAAE,iBAA0C;QAC7C,CAAC,CAAC,SAAS,CAAC;IACd,6GAA6G;IAC7G,0GAA0G;IAC1G,6CAA6C;IAC7C,MAAM,UAAU,GAAG,IAAA,6BAAkB,EAAC,MAAM,CAAC,KAAK,EAAe,EAAE,MAAM,CAAC,CAAC;IAC3E,oDAAoD;IACnD,UAA2B,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC1D,OAAO,UAAU,CAAC;AACnB,CAAC;AAnBD,8EAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\n\nimport {\n\ttype BaseFuzzTestState,\n\ttype Generator,\n\ttype SaveInfo,\n\tcreateWeightedGenerator,\n\tinterleave,\n\tmakeRandom,\n\tperformFuzzActions as performFuzzActionsBase,\n\trepeat,\n\ttake,\n} from \"@fluid-private/stochastic-test-utils\";\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\n\nimport { IdCompressor } from \"../idCompressor.js\";\nimport {\n\ttype IIdCompressor,\n\ttype IIdCompressorCore,\n\ttype IdCreationRange,\n\ttype OpSpaceCompressedId,\n\ttype SerializedIdCompressorWithNoSession,\n\ttype SerializedIdCompressorWithOngoingSession,\n\ttype SessionId,\n\ttype SessionSpaceCompressedId,\n\ttype StableId,\n\tcreateIdCompressor,\n} from \"../index.js\";\nimport { SessionSpaceNormalizer } from \"../sessionSpaceNormalizer.js\";\nimport { assertIsSessionId, createSessionId, localIdFromGenCount } from \"../utilities.js\";\n\nimport {\n\ttype FinalCompressedId,\n\ttype ReadonlyIdCompressor,\n\tfail,\n\tgetOrCreate,\n\tincrementStableId,\n\tisFinalId,\n\tisLocalId,\n} from \"./testCommon.js\";\n\n/**\n * A readonly `Map` which is known to contain a value for every possible key\n */\nexport interface ClosedMap<K, V> extends Omit<Map<K, V>, \"delete\" | \"clear\"> {\n\tget(key: K): V;\n}\n\n/**\n * Identifies a compressor in a network\n */\nexport enum Client {\n\tClient1 = \"Client1\",\n\tClient2 = \"Client2\",\n\tClient3 = \"Client3\",\n}\n\n/**\n * Identifies categories of compressors\n */\nexport enum MetaClient {\n\tAll = \"All\",\n}\n\n/**\n * Identifies a compressor inside the network but outside the three specially tracked clients.\n */\nexport enum OutsideClient {\n\tRemote = \"Remote\",\n}\n\n/**\n * Used to attribute actions to clients in a distributed collaboration session.\n * `Local` implies a local and unsequenced operation. All others imply sequenced operations.\n */\nexport type OriginatingClient = Client | OutsideClient;\nexport const OriginatingClient = { ...Client, ...OutsideClient };\n\n/**\n * Identifies a compressor to which to send an operation\n */\nexport type DestinationClient = Client | MetaClient;\nexport const DestinationClient = { ...Client, ...MetaClient };\n\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport class CompressorFactory {\n\t/**\n\t * Creates a new compressor with the supplied cluster capacity.\n\t */\n\tpublic static createCompressor(\n\t\tclient: Client,\n\t\tclusterCapacity = 5,\n\t\tlogger?: ITelemetryBaseLogger,\n\t): IdCompressor {\n\t\treturn CompressorFactory.createCompressorWithSession(\n\t\t\tsessionIds.get(client),\n\t\t\tclusterCapacity,\n\t\t\tlogger,\n\t\t);\n\t}\n\n\t/**\n\t * Creates a new compressor with the supplied cluster capacity.\n\t */\n\tpublic static createCompressorWithSession(\n\t\tsessionId: SessionId,\n\t\tclusterCapacity = 5,\n\t\tlogger?: ITelemetryBaseLogger,\n\t): IdCompressor {\n\t\tconst compressor = createIdCompressor(sessionId, logger) as IdCompressor;\n\t\tmodifyClusterSize(compressor, clusterCapacity);\n\t\treturn compressor;\n\t}\n}\n\n/**\n * Modify the requested cluster size of the provided compressor.\n * @remarks\n * This is useful for testing purposes for a few reasons:\n * - Id compressor bugs are often related to edge cases that occur on cluster boundaries\n * - Smaller cluster sizes can enable writing tests without for loops generating \"ids until a new cluster is created\"\n */\nexport function modifyClusterSize(compressor: IIdCompressor, newClusterSize: number): void {\n\tverifyCompressorLike(compressor);\n\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\tcompressor[\"nextRequestedClusterSize\"] = newClusterSize;\n}\n\n/**\n * Returns the current cluster size of the compressor.\n * @privateRemarks\n * This is useful in writing tests to avoid having to hardcode the (currently constant) cluster size.\n */\nexport function getClusterSize(compressor: ReadonlyIdCompressor): number {\n\tverifyCompressorLike(compressor);\n\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\treturn compressor[\"nextRequestedClusterSize\"] as number;\n}\n\nfunction verifyCompressorLike(compressor: ReadonlyIdCompressor | IIdCompressor): void {\n\tassert(\n\t\t// Some IdCompressor tests wrap underlying compressors with proxies--allow this for now.\n\t\t// Because of id-compressor's dynamic import in container-runtime, instanceof checks for IdCompressor\n\t\t// also won't necessarily work nicely. Get a small amount of validation that this function should work\n\t\t// as intended by at least verifying the property name exists.\n\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\ttypeof compressor[\"nextRequestedClusterSize\"] === \"number\",\n\t);\n}\n\n/**\n * Utility for building a huge compressor.\n * Build via the compressor factory.\n */\nexport function buildHugeCompressor(\n\tnumSessions = 10000,\n\tcapacity = 10,\n\tnumClustersPerSession = 3,\n): IdCompressor {\n\tconst compressor = CompressorFactory.createCompressorWithSession(\n\t\tcreateSessionId(),\n\t\tcapacity,\n\t);\n\tconst sessions: SessionId[] = [];\n\tfor (let i = 0; i < numSessions; i++) {\n\t\tsessions.push(createSessionId());\n\t}\n\tfor (let i = 0; i < numSessions * numClustersPerSession; i++) {\n\t\tconst sessionId = sessions[i % numSessions];\n\t\tif (Math.random() > 0.1) {\n\t\t\tfor (let j = 0; j < Math.round(capacity / 2); j++) {\n\t\t\t\tcompressor.generateCompressedId();\n\t\t\t}\n\t\t\tcompressor.finalizeCreationRange(compressor.takeNextCreationRange());\n\t\t}\n\t\tcompressor.finalizeCreationRange({\n\t\t\tsessionId,\n\t\t\tids: {\n\t\t\t\tfirstGenCount: Math.floor(i / numSessions) * capacity + 1,\n\t\t\t\tcount: capacity,\n\t\t\t\trequestedClusterSize: capacity,\n\t\t\t\tlocalIdRanges: [], // remote session, can safely ignore in tests\n\t\t\t},\n\t\t});\n\t}\n\treturn compressor;\n}\n\n/**\n * A closed map from NamedClient to T.\n */\nexport type ClientMap<T> = ClosedMap<Client, T>;\n\nfunction makeSessionIds(): ClientMap<SessionId> {\n\tconst stableIds = new Map<Client, SessionId>();\n\tconst clients = Object.values(Client);\n\tfor (let i = 0; i < clients.length; i++) {\n\t\t// Place session uuids roughly in the middle of uuid space to increase odds of encountering interesting\n\t\t// orderings in sorted collections\n\t\tconst sessionId = assertIsSessionId(`88888888-8888-4888-b${i}88-888888888888`);\n\t\tstableIds.set(clients[i], sessionId);\n\t}\n\treturn stableIds as ClientMap<SessionId>;\n}\n\n/**\n * An array of session ID strings corresponding to all non-local `Client` entries.\n */\nexport const sessionIds = makeSessionIds();\n\n/**\n * Information about a generated ID in a network to be validated by tests\n */\nexport interface TestIdData {\n\treadonly id: SessionSpaceCompressedId;\n\treadonly originatingClient: OriginatingClient;\n\treadonly sessionId: SessionId;\n\treadonly isSequenced: boolean;\n}\n\n/**\n * Simulates a network of ID compressors.\n * Not suitable for performance testing.\n */\nexport class IdCompressorTestNetwork {\n\t/**\n\t * The compressors used in this network\n\t */\n\tprivate readonly compressors: ClientMap<IdCompressor>;\n\t/**\n\t * The log of operations seen by the server so far. Append-only.\n\t */\n\tprivate readonly serverOperations: [\n\t\tcreationRange: IdCreationRange,\n\t\topSpaceIds: OpSpaceCompressedId[],\n\t\tclientFrom: OriginatingClient,\n\t\tsessionIdFrom: SessionId,\n\t][] = [];\n\t/**\n\t * An index into `serverOperations` for each client which represents how many operations have been delivered to that client\n\t */\n\tprivate readonly clientProgress: ClientMap<number>;\n\t/**\n\t * All ids (local and sequenced) that a client has created or received, in order.\n\t */\n\tprivate readonly idLogs: ClientMap<TestIdData[]>;\n\t/**\n\t * All ids that a client has received from the server, in order.\n\t */\n\tprivate readonly sequencedIdLogs: ClientMap<TestIdData[]>;\n\n\tpublic constructor(public readonly initialClusterSize = 5) {\n\t\tconst compressors = new Map<Client, IdCompressor>();\n\t\tconst clientProgress = new Map<Client, number>();\n\t\tconst clientIds = new Map<Client, TestIdData[]>();\n\t\tconst clientSequencedIds = new Map<Client, TestIdData[]>();\n\t\tfor (const client of Object.values(Client)) {\n\t\t\tconst compressor = CompressorFactory.createCompressor(client, initialClusterSize);\n\t\t\tcompressors.set(client, compressor);\n\t\t\tclientProgress.set(client, 0);\n\t\t\tclientIds.set(client, []);\n\t\t\tclientSequencedIds.set(client, []);\n\t\t}\n\t\tthis.compressors = compressors as ClientMap<IdCompressor>;\n\t\tthis.clientProgress = clientProgress as ClientMap<number>;\n\t\tthis.idLogs = clientIds as ClientMap<TestIdData[]>;\n\t\tthis.sequencedIdLogs = clientSequencedIds as ClientMap<TestIdData[]>;\n\t}\n\n\t/**\n\t * Returns the number of undelivered operations for the given client that are in flight in the network.\n\t */\n\tpublic getPendingOperations(destination: Client): number {\n\t\treturn this.serverOperations.length - this.clientProgress.get(destination);\n\t}\n\n\t/**\n\t * Returns an immutable handle to a compressor in the network.\n\t */\n\tpublic getCompressor(client: Client): ReadonlyIdCompressor {\n\t\tconst compressors = this.compressors;\n\t\tconst handler = {\n\t\t\tget<P extends keyof IdCompressor>(_: unknown, property: P): IdCompressor[P] {\n\t\t\t\treturn compressors.get(client)[property];\n\t\t\t},\n\t\t\tset<P extends keyof IdCompressor>(\n\t\t\t\t_: unknown,\n\t\t\t\tproperty: P,\n\t\t\t\tvalue: IdCompressor[P],\n\t\t\t): boolean {\n\t\t\t\tcompressors.get(client)[property] = value;\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\t\treturn new Proxy<IdCompressor>({} as unknown as IdCompressor, handler);\n\t}\n\n\t/**\n\t * Returns a mutable handle to a compressor in the network. Use of mutation methods will break the network invariants and\n\t * should only be used if the network will not be used again.\n\t */\n\tpublic getCompressorUnsafe(client: Client): IdCompressor {\n\t\treturn this.getCompressor(client) as IdCompressor;\n\t}\n\n\t/**\n\t * Returns a mutable handle to a compressor in the network. Use of mutation methods will break the network invariants and\n\t * should only be used if the network will not be used again. Additionally, the returned compressor will be invalidated/unusable\n\t * if any network operations cause it to be regenerated (serialization/deserialization, etc.).\n\t */\n\tpublic getCompressorUnsafeNoProxy(client: Client): IdCompressor {\n\t\treturn this.compressors.get(client);\n\t}\n\n\t/**\n\t * Returns data for all IDs created and received by this client, including ack's of their own (i.e. their own IDs will appear twice)\n\t */\n\tpublic getIdLog(client: Client): readonly TestIdData[] {\n\t\treturn this.idLogs.get(client);\n\t}\n\n\t/**\n\t * Returns data for all IDs received by this client, including ack's of their own.\n\t */\n\tpublic getSequencedIdLog(client: Client): readonly TestIdData[] {\n\t\treturn this.sequencedIdLogs.get(client);\n\t}\n\n\t/**\n\t * Get all compressors for the given destination\n\t */\n\tpublic getTargetCompressors(clientTo: DestinationClient): [Client, IdCompressor][] {\n\t\treturn clientTo === MetaClient.All\n\t\t\t? [...this.compressors.entries()]\n\t\t\t: ([[clientTo, this.getCompressor(clientTo)]] as [Client, IdCompressor][]);\n\t}\n\n\t/**\n\t * Changes the capacity request amount for a client. It will take effect immediately.\n\t */\n\tpublic changeCapacity(client: Client, newClusterCapacity: number): void {\n\t\tmodifyClusterSize(this.compressors.get(client), newClusterCapacity);\n\t}\n\n\tprivate addNewId(\n\t\tclient: Client,\n\t\tid: SessionSpaceCompressedId,\n\t\toriginatingClient: OriginatingClient,\n\t\tsessionIdFrom: SessionId,\n\t\tisSequenced: boolean,\n\t): void {\n\t\tconst idData = {\n\t\t\tid,\n\t\t\toriginatingClient,\n\t\t\tsessionId: sessionIdFrom,\n\t\t\tisSequenced,\n\t\t};\n\t\tconst clientIds = this.idLogs.get(client);\n\t\tclientIds.push(idData);\n\t\tif (isSequenced) {\n\t\t\tconst sequencedIds = this.sequencedIdLogs.get(client);\n\t\t\tsequencedIds.push(idData);\n\t\t}\n\t}\n\n\t/**\n\t * Allocates a new range of local IDs and enqueues them for future delivery via a `testIdDelivery` action.\n\t * Calls to this method determine the total order of delivery, regardless of when `deliverOperations` is called.\n\t */\n\tpublic allocateAndSendIds(clientFrom: Client, numIds: number): OpSpaceCompressedId[] {\n\t\treturn this.allocateAndSendIdsFromRemoteClient(\n\t\t\tclientFrom,\n\t\t\tsessionIds.get(clientFrom),\n\t\t\tnumIds,\n\t\t);\n\t}\n\n\t/**\n\t * Same contract as `allocateAndSendIds`, but the originating client will be a client with the supplied sessionId.\n\t */\n\tpublic allocateAndSendIdsFromRemoteClient(\n\t\tclientFrom: OriginatingClient,\n\t\tsessionIdFrom: SessionId,\n\t\tnumIds: number,\n\t): OpSpaceCompressedId[] {\n\t\tassert(numIds > 0, \"Must allocate a non-zero number of IDs\");\n\t\tif (clientFrom === OriginatingClient.Remote) {\n\t\t\tconst range: IdCreationRange = {\n\t\t\t\tsessionId: sessionIdFrom,\n\t\t\t\tids: {\n\t\t\t\t\tfirstGenCount: 1,\n\t\t\t\t\tcount: numIds,\n\t\t\t\t\trequestedClusterSize: getClusterSize(this.getCompressor(Client.Client1)),\n\t\t\t\t\tlocalIdRanges: [], // remote session, can safely ignore in tests\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst opSpaceIds: OpSpaceCompressedId[] = [];\n\t\t\tfor (let i = 0; i < numIds; i++) {\n\t\t\t\topSpaceIds.push(-(i + 1) as OpSpaceCompressedId);\n\t\t\t}\n\t\t\tthis.serverOperations.push([range, opSpaceIds, clientFrom, sessionIdFrom]);\n\t\t\treturn opSpaceIds;\n\t\t} else {\n\t\t\tassert(sessionIdFrom === sessionIds.get(clientFrom));\n\t\t\tconst compressor = this.compressors.get(clientFrom);\n\t\t\tconst sessionSpaceIds = generateCompressedIds(compressor, numIds);\n\t\t\tfor (let i = 0; i < numIds; i++) {\n\t\t\t\tthis.addNewId(clientFrom, sessionSpaceIds[i], clientFrom, sessionIdFrom, false);\n\t\t\t}\n\t\t\tconst opSpaceIds = sessionSpaceIds.map((id) => compressor.normalizeToOpSpace(id));\n\t\t\tconst creationRange = compressor.takeNextCreationRange();\n\t\t\tthis.serverOperations.push([creationRange, opSpaceIds, clientFrom, sessionIdFrom]);\n\t\t\treturn opSpaceIds;\n\t\t}\n\t}\n\n\t/**\n\t * Delivers all undelivered ID ranges from the server to the target clients.\n\t */\n\tpublic deliverOperations(clientTakingDelivery: Client, opsToDeliver?: number): void;\n\n\t/**\n\t * Delivers all undelivered ID ranges from the server to the target clients.\n\t */\n\tpublic deliverOperations(clientTakingDelivery: DestinationClient): void;\n\n\t/**\n\t * Delivers all undelivered ID ranges from the server to the target clients.\n\t */\n\tpublic deliverOperations(\n\t\tclientTakingDelivery: DestinationClient,\n\t\topsToDeliver?: number,\n\t): void {\n\t\tlet opIndexBound: number;\n\t\tif (clientTakingDelivery === DestinationClient.All) {\n\t\t\tassert(opsToDeliver === undefined);\n\t\t\topIndexBound = this.serverOperations.length;\n\t\t} else {\n\t\t\topIndexBound =\n\t\t\t\topsToDeliver === undefined\n\t\t\t\t\t? this.serverOperations.length\n\t\t\t\t\t: this.clientProgress.get(clientTakingDelivery) + opsToDeliver;\n\t\t}\n\t\tfor (const [clientTo, compressorTo] of this.getTargetCompressors(clientTakingDelivery)) {\n\t\t\tfor (let i = this.clientProgress.get(clientTo); i < opIndexBound; i++) {\n\t\t\t\tconst [range, opSpaceIds, clientFrom, sessionIdFrom] = this.serverOperations[i];\n\t\t\t\tcompressorTo.finalizeCreationRange(range);\n\n\t\t\t\tconst ids = range.ids;\n\t\t\t\tif (ids !== undefined) {\n\t\t\t\t\tfor (const id of opSpaceIds) {\n\t\t\t\t\t\tconst sessionSpaceId = compressorTo.normalizeToSessionSpace(id, range.sessionId);\n\t\t\t\t\t\tthis.addNewId(clientTo, sessionSpaceId, clientFrom, sessionIdFrom, true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.clientProgress.set(clientTo, opIndexBound);\n\t\t}\n\t}\n\n\t/**\n\t * Simulate a client disconnecting (and serializing), then reconnecting (and deserializing)\n\t */\n\tpublic goOfflineThenResume(client: Client): void {\n\t\tconst compressor = this.compressors.get(client);\n\t\tconst [_, resumedCompressor] = roundtrip(compressor, true);\n\t\tthis.compressors.set(client, resumedCompressor);\n\t}\n\n\t/**\n\t * Ensure general validity of the network state. Useful for calling periodically or at the end of test scenarios.\n\t */\n\tpublic assertNetworkState(): void {\n\t\tconst sequencedLogs = Object.values(Client).map(\n\t\t\t(client) => [this.compressors.get(client), this.getSequencedIdLog(client)] as const,\n\t\t);\n\n\t\tconst getLocalIdsInRange = (\n\t\t\trange: IdCreationRange,\n\t\t\topSpaceIds?: OpSpaceCompressedId[],\n\t\t): Set<SessionSpaceCompressedId> => {\n\t\t\tconst localIdsInCreationRange = new Set<SessionSpaceCompressedId>();\n\t\t\tconst ids = range.ids;\n\t\t\tif (ids !== undefined) {\n\t\t\t\tconst { firstGenCount, localIdRanges } = ids;\n\t\t\t\tfor (const [genCount, count] of localIdRanges) {\n\t\t\t\t\tfor (let g = genCount; g < genCount + count; g++) {\n\t\t\t\t\t\tconst local = localIdFromGenCount(g);\n\t\t\t\t\t\tif (opSpaceIds) {\n\t\t\t\t\t\t\tassert.strictEqual(opSpaceIds[g - firstGenCount], local);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlocalIdsInCreationRange.add(local);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn localIdsInCreationRange;\n\t\t};\n\n\t\t// Ensure creation ranges for clients we track contain the correct local ID ranges\n\t\tfor (const [range, opSpaceIds, clientFrom] of this.serverOperations) {\n\t\t\tif (clientFrom !== OriginatingClient.Remote) {\n\t\t\t\tconst localIdsInCreationRange = getLocalIdsInRange(range, opSpaceIds);\n\t\t\t\tlet localCount = 0;\n\t\t\t\tfor (const id of opSpaceIds) {\n\t\t\t\t\tif (isLocalId(id)) {\n\t\t\t\t\t\tlocalCount++;\n\t\t\t\t\t\tassert(localIdsInCreationRange.has(id), \"Local ID not in creation range\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\tlocalCount,\n\t\t\t\t\tlocalIdsInCreationRange.size,\n\t\t\t\t\t\"Local ID count mismatch\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst undeliveredRanges = new Map<Client, IdCreationRange[]>();\n\t\tfor (const [client, progress] of this.clientProgress.entries()) {\n\t\t\tconst ranges = this.serverOperations\n\t\t\t\t.slice(progress)\n\t\t\t\t.filter((op) => op[2] === client)\n\t\t\t\t.map(([range]) => range);\n\t\t\tundeliveredRanges.set(client, ranges);\n\t\t}\n\t\tfor (const [client, ranges] of undeliveredRanges.entries()) {\n\t\t\tconst compressor = this.compressors.get(client);\n\t\t\tlet firstGenCount: number | undefined;\n\t\t\tlet totalCount = 0;\n\t\t\tconst unionedLocalRanges = new SessionSpaceNormalizer();\n\t\t\tfor (const range of ranges) {\n\t\t\t\tassert(range.sessionId === compressor.localSessionId);\n\t\t\t\tif (range.ids !== undefined) {\n\t\t\t\t\t// initialize firstGenCount if not set\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\t\t\t\t\tif (firstGenCount === undefined) {\n\t\t\t\t\t\tfirstGenCount = range.ids.firstGenCount;\n\t\t\t\t\t}\n\t\t\t\t\ttotalCount += range.ids.count;\n\t\t\t\t\tfor (const [genCount, count] of range.ids.localIdRanges) {\n\t\t\t\t\t\tunionedLocalRanges.addLocalRange(genCount, count);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst retakenRange = compressor.takeUnfinalizedCreationRange();\n\t\t\tif (retakenRange.ids === undefined) {\n\t\t\t\tassert.strictEqual(totalCount, 0);\n\t\t\t\tassert.strictEqual(unionedLocalRanges.idRanges.size, 0);\n\t\t\t} else {\n\t\t\t\tconst retakenLocalIds = new SessionSpaceNormalizer();\n\t\t\t\tfor (const [genCount, count] of retakenRange.ids.localIdRanges) {\n\t\t\t\t\tretakenLocalIds.addLocalRange(genCount, count);\n\t\t\t\t}\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\tretakenLocalIds.equals(unionedLocalRanges),\n\t\t\t\t\ttrue,\n\t\t\t\t\t\"Local ID ranges mismatch\",\n\t\t\t\t);\n\t\t\t\tassert.strictEqual(retakenRange.ids.count, totalCount, \"Count mismatch\");\n\t\t\t\tassert.strictEqual(retakenRange.ids.firstGenCount, firstGenCount, \"Count mismatch\");\n\t\t\t}\n\t\t}\n\n\t\t// First, ensure all clients each generated a unique ID for each of their own calls to generate.\n\t\tfor (const [compressor, ids] of sequencedLogs) {\n\t\t\tconst allUuids = new Set<StableId | string>();\n\t\t\tfor (const idData of ids) {\n\t\t\t\tconst uuid = compressor.decompress(idData.id);\n\t\t\t\tassert.strictEqual(!allUuids.has(uuid), true, \"Duplicate UUID generated.\");\n\t\t\t\tallUuids.add(uuid);\n\t\t\t}\n\t\t}\n\n\t\tconst maxLogLength = sequencedLogs\n\t\t\t.map(([_, data]) => data.length)\n\t\t\t// eslint-disable-next-line unicorn/no-array-reduce\n\t\t\t.reduce((p, n) => Math.max(p, n));\n\n\t\tfunction getNextLogWithEntryAt(logsIndex: number, entryIndex: number): number | undefined {\n\t\t\tfor (let i = logsIndex; i < sequencedLogs.length; i++) {\n\t\t\t\tconst log = sequencedLogs[i];\n\t\t\t\tif (log[1].length > entryIndex) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst uuids = new Set<StableId>();\n\t\tconst finalIds = new Set<FinalCompressedId>();\n\t\tconst idIndicesAggregator = new Map<SessionId, number>();\n\n\t\tfunction* getIdLogEntries(\n\t\t\tcolumnIndex: number,\n\t\t): Iterable<\n\t\t\t[\n\t\t\t\tcurrent: [compressor: IdCompressor, idData: TestIdData],\n\t\t\t\tnext?: [compressor: IdCompressor, idData: TestIdData],\n\t\t\t]\n\t\t> {\n\t\t\tlet current = getNextLogWithEntryAt(0, columnIndex);\n\t\t\twhile (current !== undefined) {\n\t\t\t\tconst next = getNextLogWithEntryAt(current + 1, columnIndex);\n\t\t\t\tconst [compressor, log] = sequencedLogs[current];\n\t\t\t\tif (next === undefined) {\n\t\t\t\t\tyield [[compressor, log[columnIndex]]];\n\t\t\t\t} else {\n\t\t\t\t\tconst [compressorNext, logNext] = sequencedLogs[next];\n\t\t\t\t\tyield [\n\t\t\t\t\t\t[compressor, log[columnIndex]],\n\t\t\t\t\t\t[compressorNext, logNext[columnIndex]],\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\tcurrent = next;\n\t\t\t}\n\t\t}\n\n\t\tfor (let i = 0; i < maxLogLength; i++) {\n\t\t\tlet idCreatorCount = 0;\n\t\t\tlet originatingSession: SessionId | undefined;\n\t\t\tfor (const [current, next] of getIdLogEntries(i)) {\n\t\t\t\tconst [compressorA, idDataA] = current;\n\t\t\t\tconst sessionSpaceIdA = idDataA.id;\n\t\t\t\tconst idIndex = getOrCreate(idIndicesAggregator, idDataA.sessionId, () => 0);\n\t\t\t\toriginatingSession ??= idDataA.sessionId;\n\t\t\t\tassert(\n\t\t\t\t\tidDataA.sessionId === originatingSession,\n\t\t\t\t\t\"Test infra gave wrong originating client to TestIdData\",\n\t\t\t\t);\n\n\t\t\t\t// Only one client should have this ID as local in its session space, as only one client could have created this ID\n\t\t\t\tif (isLocalId(sessionSpaceIdA)) {\n\t\t\t\t\tif (originatingSession !== OriginatingClient.Remote) {\n\t\t\t\t\t\tassert.strictEqual(\n\t\t\t\t\t\t\tidDataA.sessionId,\n\t\t\t\t\t\t\tthis.compressors.get(idDataA.originatingClient as Client).localSessionId,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tidCreatorCount++;\n\t\t\t\t}\n\n\t\t\t\tconst uuidASessionSpace = compressorA.decompress(sessionSpaceIdA);\n\t\t\t\tassert.strictEqual(uuidASessionSpace, incrementStableId(idDataA.sessionId, idIndex));\n\t\t\t\tassert.strictEqual(compressorA.recompress(uuidASessionSpace), sessionSpaceIdA);\n\t\t\t\tuuids.add(uuidASessionSpace);\n\t\t\t\tconst opSpaceIdA = compressorA.normalizeToOpSpace(sessionSpaceIdA);\n\t\t\t\tif (!isFinalId(opSpaceIdA)) {\n\t\t\t\t\tfail(\"IDs should have been finalized.\");\n\t\t\t\t}\n\t\t\t\tconst reNormalizedIdA = compressorA.normalizeToSessionSpace(\n\t\t\t\t\topSpaceIdA,\n\t\t\t\t\tcompressorA.localSessionId,\n\t\t\t\t);\n\t\t\t\tassert.strictEqual(reNormalizedIdA, sessionSpaceIdA);\n\t\t\t\tfinalIds.add(opSpaceIdA);\n\t\t\t\tconst uuidAOpSpace = compressorA.decompress(reNormalizedIdA);\n\n\t\t\t\tassert.strictEqual(uuidASessionSpace, uuidAOpSpace);\n\n\t\t\t\tif (next !== undefined) {\n\t\t\t\t\tconst [compressorB, idDataB] = next;\n\t\t\t\t\tconst sessionSpaceIdB = idDataB.id;\n\n\t\t\t\t\tconst uuidBSessionSpace = compressorB.decompress(sessionSpaceIdB);\n\t\t\t\t\tassert.strictEqual(uuidASessionSpace, uuidBSessionSpace);\n\t\t\t\t\tconst opSpaceIdB = compressorB.normalizeToOpSpace(sessionSpaceIdB);\n\t\t\t\t\tif (opSpaceIdA !== opSpaceIdB) {\n\t\t\t\t\t\tcompressorB.normalizeToOpSpace(sessionSpaceIdB);\n\t\t\t\t\t\tcompressorA.normalizeToOpSpace(sessionSpaceIdA);\n\t\t\t\t\t}\n\t\t\t\t\tassert.strictEqual(opSpaceIdA, opSpaceIdB);\n\t\t\t\t\tif (!isFinalId(opSpaceIdB)) {\n\t\t\t\t\t\tfail(\"IDs should have been finalized.\");\n\t\t\t\t\t}\n\t\t\t\t\tconst uuidBOpSpace = compressorB.decompress(\n\t\t\t\t\t\topSpaceIdB as unknown as SessionSpaceCompressedId,\n\t\t\t\t\t);\n\t\t\t\t\tassert.strictEqual(uuidAOpSpace, uuidBOpSpace);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tassert(idCreatorCount <= 1, \"Only one client can create an ID.\");\n\t\t\tassert.strictEqual(uuids.size, finalIds.size);\n\t\t\tassert(originatingSession !== undefined, \"Expected originating client to be defined\");\n\t\t\tidIndicesAggregator.set(\n\t\t\t\toriginatingSession,\n\n\t\t\t\t(idIndicesAggregator.get(originatingSession) ??\n\t\t\t\t\tfail(\"Expected pre-existing index for originating client\")) + 1,\n\t\t\t);\n\t\t}\n\n\t\tfor (const [compressor] of sequencedLogs) {\n\t\t\texpectSerializes(compressor);\n\t\t}\n\t}\n}\n\n/**\n * Roundtrips the supplied compressor through serialization and deserialization.\n */\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: true,\n): [SerializedIdCompressorWithOngoingSession, IdCompressor];\n\n/**\n * Roundtrips the supplied compressor through serialization and deserialization.\n */\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: false,\n): [SerializedIdCompressorWithNoSession, IdCompressor];\n\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: boolean,\n): [\n\tSerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession,\n\tIdCompressor,\n] {\n\t// preserve the capacity request as this property is normally private and resets\n\t// to a default on construction (deserialization)\n\tconst capacity: number = getClusterSize(compressor);\n\tif (withSession) {\n\t\tconst serialized = compressor.serialize(withSession);\n\t\tconst roundtripped = IdCompressor.deserialize({ serialized });\n\t\tmodifyClusterSize(roundtripped, capacity);\n\t\treturn [serialized, roundtripped];\n\t} else {\n\t\tconst nonLocalSerialized = compressor.serialize(withSession);\n\t\tconst roundtripped = IdCompressor.deserialize({\n\t\t\tserialized: nonLocalSerialized,\n\t\t\tnewSessionId: createSessionId(),\n\t\t});\n\t\tmodifyClusterSize(roundtripped, capacity);\n\t\treturn [nonLocalSerialized, roundtripped];\n\t}\n}\n\n/**\n * Asserts that the supplied compressor correctly roundtrips through serialization/deserialization.\n */\nexport function expectSerializes(\n\tcompressor: ReadonlyIdCompressor,\n): [SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession] {\n\tfunction expectSerializesWithSession(\n\t\twithSession: boolean,\n\t): SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession {\n\t\tlet serialized:\n\t\t\t| SerializedIdCompressorWithOngoingSession\n\t\t\t| SerializedIdCompressorWithNoSession;\n\t\tlet deserialized: IdCompressor;\n\t\tif (withSession) {\n\t\t\t[serialized, deserialized] = roundtrip(compressor, true);\n\t\t} else {\n\t\t\t[serialized, deserialized] = roundtrip(compressor, false);\n\t\t}\n\t\tassert.strictEqual(compressor.equals(deserialized, withSession), true);\n\t\treturn serialized;\n\t}\n\n\treturn [\n\t\texpectSerializesWithSession(false) as SerializedIdCompressorWithNoSession,\n\t\texpectSerializesWithSession(true) as SerializedIdCompressorWithOngoingSession,\n\t];\n}\n\n/**\n * Merges 'from' into 'to', and returns 'to'.\n */\nexport function mergeArrayMaps<K, V>(\n\tto: Pick<Map<K, V[]>, \"get\" | \"set\">,\n\tfrom: ReadonlyMap<K, V[]>,\n): Pick<Map<K, V[]>, \"get\" | \"set\"> {\n\tfor (const [key, value] of from.entries()) {\n\t\tconst entry = to.get(key);\n\t\tif (entry === undefined) {\n\t\t\tto.set(key, [...value]);\n\t\t} else {\n\t\t\tentry.push(...value);\n\t\t}\n\t}\n\treturn to;\n}\n\ninterface AllocateIds {\n\ttype: \"allocateIds\";\n\tclient: Client;\n\tnumIds: number;\n}\n\ninterface AllocateOutsideIds {\n\ttype: \"allocateOutsideIds\";\n\tsessionId: SessionId;\n\tnumIds: number;\n}\n\ninterface DeliverAllOperations {\n\ttype: \"deliverAllOperations\";\n}\n\ninterface DeliverSomeOperations {\n\ttype: \"deliverSomeOperations\";\n\tclient: Client;\n\tcount: number;\n}\n\ninterface ChangeCapacity {\n\ttype: \"changeCapacity\";\n\tclient: Client;\n\tnewSize: number;\n}\n\n// Represents intent to go offline then resume.\ninterface Reconnect {\n\ttype: \"reconnect\";\n\tclient: Client;\n}\n\ninterface Validate {\n\ttype: \"validate\";\n}\n\ntype Operation =\n\t| AllocateIds\n\t| AllocateOutsideIds\n\t| DeliverSomeOperations\n\t| DeliverAllOperations\n\t| ChangeCapacity\n\t| Reconnect\n\t| Validate;\n\ninterface FuzzTestState extends BaseFuzzTestState {\n\tnetwork: IdCompressorTestNetwork;\n\tactiveClients: Client[];\n\tselectableClients: Client[];\n\tclusterSize: number;\n}\n\nexport interface OperationGenerationConfig {\n\t/**\n\t * maximum cluster size of the network. Default: 25\n\t */\n\tmaxClusterSize?: number;\n\t/**\n\t * Number of ops between validation ops. Default: 200\n\t */\n\tvalidateInterval?: number;\n\t/**\n\t * Fraction of ID allocations that are from an outside client (not Client1/2/3).\n\t */\n\toutsideAllocationFraction?: number;\n}\n\nconst defaultOptions = {\n\tmaxClusterSize: 25,\n\tvalidateInterval: 200,\n\toutsideAllocationFraction: 0.1,\n};\n\nexport function makeOpGenerator(\n\toptions: OperationGenerationConfig,\n): Generator<Operation, FuzzTestState> {\n\tconst { maxClusterSize, validateInterval, outsideAllocationFraction } = {\n\t\t...defaultOptions,\n\t\t...options,\n\t};\n\tassert(outsideAllocationFraction >= 0 && outsideAllocationFraction <= 1);\n\n\tfunction allocateIdsGenerator({\n\t\tactiveClients,\n\t\tclusterSize,\n\t\trandom,\n\t}: FuzzTestState): AllocateIds {\n\t\tconst client = random.pick(activeClients);\n\t\tconst maxIdsPerUsage = clusterSize * 2;\n\t\tconst numIds = Math.floor(random.real(0, 1) ** 3 * maxIdsPerUsage) + 1;\n\t\treturn {\n\t\t\ttype: \"allocateIds\",\n\t\t\tclient,\n\t\t\tnumIds,\n\t\t};\n\t}\n\n\tfunction allocateOutsideIdsGenerator({\n\t\tclusterSize,\n\t\trandom,\n\t}: FuzzTestState): AllocateOutsideIds {\n\t\tconst maxIdsPerUsage = clusterSize * 2;\n\t\tconst numIds = Math.floor(random.real(0, 1) ** 3 * maxIdsPerUsage) + 1;\n\t\treturn {\n\t\t\ttype: \"allocateOutsideIds\",\n\t\t\tsessionId: createSessionId(),\n\t\t\tnumIds,\n\t\t};\n\t}\n\n\tfunction changeCapacityGenerator({ random, activeClients }: FuzzTestState): ChangeCapacity {\n\t\treturn {\n\t\t\ttype: \"changeCapacity\",\n\t\t\tclient: random.pick(activeClients),\n\t\t\tnewSize: Math.min(\n\t\t\t\tMath.floor(random.real(0, 1) ** 2 * maxClusterSize) + 1,\n\t\t\t\tmaxClusterSize,\n\t\t\t),\n\t\t};\n\t}\n\n\tfunction deliverAllOperationsGenerator(): DeliverAllOperations {\n\t\treturn {\n\t\t\ttype: \"deliverAllOperations\",\n\t\t};\n\t}\n\n\tfunction deliverSomeOperationsGenerator({\n\t\trandom,\n\t\tselectableClients,\n\t\tnetwork,\n\t}: FuzzTestState): DeliverSomeOperations {\n\t\tconst pendingClients = selectableClients.filter(\n\t\t\t(c) => network.getPendingOperations(c) > 0,\n\t\t);\n\t\tif (pendingClients.length === 0) {\n\t\t\treturn {\n\t\t\t\ttype: \"deliverSomeOperations\",\n\t\t\t\tclient: random.pick(selectableClients),\n\t\t\t\tcount: 0,\n\t\t\t};\n\t\t}\n\t\tconst client = random.pick(pendingClients);\n\t\treturn {\n\t\t\ttype: \"deliverSomeOperations\",\n\t\t\tclient,\n\t\t\tcount: random.integer(1, network.getPendingOperations(client)),\n\t\t};\n\t}\n\n\tfunction reconnectGenerator({ activeClients, random }: FuzzTestState): Reconnect {\n\t\treturn { type: \"reconnect\", client: random.pick(activeClients) };\n\t}\n\n\tconst allocationWeight = 20;\n\treturn interleave(\n\t\tcreateWeightedGenerator<Operation, FuzzTestState>([\n\t\t\t[changeCapacityGenerator, 1],\n\t\t\t[allocateIdsGenerator, Math.round(allocationWeight * (1 - outsideAllocationFraction))],\n\t\t\t[allocateOutsideIdsGenerator, Math.round(allocationWeight * outsideAllocationFraction)],\n\t\t\t[deliverAllOperationsGenerator, 1],\n\t\t\t[deliverSomeOperationsGenerator, 6],\n\t\t\t[reconnectGenerator, 1],\n\t\t]),\n\t\ttake(1, repeat<Operation, FuzzTestState>({ type: \"validate\" })),\n\t\tvalidateInterval,\n\t);\n}\n\n/**\n * Performs random actions on a test network.\n * @param generator - the generator used to provide operations\n * @param network - the test network to test\n * @param seed - the seed for the random generation of the fuzz actions\n * @param observerClient - if provided, this client will never generate local ids\n * @param synchronizeAtEnd - if provided, all client will have all operations delivered from the server at the end of the test\n * @param validator - if provided, this callback will be invoked periodically during the fuzz test.\n */\nexport function performFuzzActions(\n\tgenerator: Generator<Operation, FuzzTestState>,\n\tnetwork: IdCompressorTestNetwork,\n\tseed: number,\n\tobserverClient?: Client,\n\tsynchronizeAtEnd: boolean = true,\n\tvalidator?: (network: IdCompressorTestNetwork) => void,\n\tsaveInfo?: SaveInfo,\n): void {\n\tconst random = makeRandom(seed);\n\tconst selectableClients: Client[] = network\n\t\t.getTargetCompressors(MetaClient.All)\n\t\t.map(([client]) => client);\n\n\tconst initialState: FuzzTestState = {\n\t\trandom,\n\t\tnetwork,\n\t\tactiveClients: selectableClients.filter((c) => c !== observerClient),\n\t\tselectableClients,\n\t\tclusterSize: network.initialClusterSize,\n\t};\n\n\tperformFuzzActionsBase(\n\t\tgenerator,\n\t\t{\n\t\t\tallocateIds: (state, { client, numIds }) => {\n\t\t\t\tnetwork.allocateAndSendIdsFromRemoteClient(client, sessionIds.get(client), numIds);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tallocateOutsideIds: (state, { sessionId, numIds }) => {\n\t\t\t\tnetwork.allocateAndSendIdsFromRemoteClient(\n\t\t\t\t\tOriginatingClient.Remote,\n\t\t\t\t\tsessionId,\n\t\t\t\t\tnumIds,\n\t\t\t\t);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tchangeCapacity: (state, op) => {\n\t\t\t\tnetwork.changeCapacity(op.client, op.newSize);\n\t\t\t\treturn { ...state, clusterSize: op.newSize };\n\t\t\t},\n\t\t\tdeliverSomeOperations: (state, op) => {\n\t\t\t\tnetwork.deliverOperations(op.client, op.count);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tdeliverAllOperations: (state) => {\n\t\t\t\tnetwork.deliverOperations(DestinationClient.All);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\treconnect: (state, { client }) => {\n\t\t\t\tnetwork.goOfflineThenResume(client);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tvalidate: (state) => {\n\t\t\t\tvalidator?.(network);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t},\n\t\tinitialState,\n\t\tsaveInfo,\n\t);\n\n\tif (synchronizeAtEnd) {\n\t\tnetwork.deliverOperations(DestinationClient.All);\n\t\tvalidator?.(network);\n\t}\n}\n\n/**\n * Helper to generate a fixed number of IDs.\n */\nexport function generateCompressedIds(\n\tcompressor: IdCompressor,\n\tcount: number,\n): SessionSpaceCompressedId[] {\n\tconst ids: SessionSpaceCompressedId[] = [];\n\tfor (let i = 0; i < count; i++) {\n\t\tids.push(compressor.generateCompressedId());\n\t}\n\treturn ids;\n}\n\n/**\n * Creates a compressor that only produces final IDs.\n * It should only be used for testing purposes.\n */\nexport function createAlwaysFinalizedIdCompressor(\n\tlogger?: ITelemetryBaseLogger,\n): IIdCompressor & IIdCompressorCore;\n/**\n * Creates a compressor that only produces final IDs.\n * It should only be used for testing purposes.\n */\nexport function createAlwaysFinalizedIdCompressor(\n\tsessionId: SessionId,\n\tlogger?: ITelemetryBaseLogger,\n\tseed?: number,\n): IIdCompressor & IIdCompressorCore;\nexport function createAlwaysFinalizedIdCompressor(\n\tsessionIdOrLogger?: SessionId | ITelemetryBaseLogger,\n\tloggerOrUndefined?: ITelemetryBaseLogger,\n\tseed?: number,\n): IIdCompressor & IIdCompressorCore {\n\tconst random = seed === undefined ? makeRandom() : makeRandom(seed);\n\tconst sessionId =\n\t\ttypeof sessionIdOrLogger === \"string\" ? sessionIdOrLogger : (random.uuid4() as SessionId);\n\tconst logger =\n\t\t(loggerOrUndefined ?? typeof sessionIdOrLogger === \"object\")\n\t\t\t? (sessionIdOrLogger as ITelemetryBaseLogger)\n\t\t\t: undefined;\n\t// This local session is unused, but it needs to not collide with the GhostSession, so allocate a random one.\n\t// This causes the compressor to serialize non-deterministically even when provided an explicit SessionId.\n\t// This can be fixed in the future if needed.\n\tconst compressor = createIdCompressor(random.uuid4() as SessionId, logger);\n\t// Permanently put the compressor in a ghost session\n\t(compressor as IdCompressor).startGhostSession(sessionId);\n\treturn compressor;\n}\n"]}
package/eslint.config.mts CHANGED
@@ -1,8 +1,8 @@
1
- /* eslint-disable */
2
- /**
3
- * GENERATED FILE - DO NOT EDIT DIRECTLY.
4
- * To regenerate: pnpm tsx scripts/generate-flat-eslint-configs.ts --typescript
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
5
4
  */
5
+
6
6
  import type { Linter } from "eslint";
7
7
  import { recommended } from "../../../common/build/eslint-config-fluid/flat.mts";
8
8
 
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/id-compressor";
8
- export declare const pkgVersion = "2.80.0";
8
+ export declare const pkgVersion = "2.81.0-374083";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,WAAW,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,kBAAkB,CAAC"}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/id-compressor";
8
- export const pkgVersion = "2.80.0";
8
+ export const pkgVersion = "2.81.0-374083";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,+BAA+B,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/id-compressor\";\nexport const pkgVersion = \"2.80.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,+BAA+B,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/id-compressor\";\nexport const pkgVersion = \"2.81.0-374083\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../src/sessions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAW5D;;;GAGG;AACH,qBAAa,QAAQ;IAGpB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA8D;IAExF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAiC;gBAE3C,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;IAgBrE,QAAQ,IAAI,gBAAgB,CAAC,OAAO,CAAC;IAIrC,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;IAc1C,GAAG,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS;IAI9C,oBAAoB,CAC1B,KAAK,EAAE,QAAQ,GACb,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,CAAC,GAAG,SAAS;IAmB7D,eAAe,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO;IA0C5C,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,OAAO,GAAG,OAAO;CAsBnE;AAED;;GAEG;AACH,qBAAa,OAAO;IAEnB,OAA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C,KAAK,MAAM,GAChC,CAAC,GAAG,SAAS;IAmBT,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;CAStC;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACzB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IAExC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IAExC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,OAAO,CAQjE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC9B,OAAO,EAAE,SAAS,EAClB,WAAW,EAAE,iBAAiB,GAC5B,iBAAiB,GAAG,SAAS,CAO/B;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC9B,OAAO,EAAE,SAAS,EAClB,WAAW,EAAE,iBAAiB,GAC5B,iBAAiB,CAOnB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,iBAAiB,CAExE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,iBAAiB,CAExE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,iBAAiB,CAExE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,iBAAiB,CAExE"}
package/lib/sessions.js CHANGED
@@ -77,6 +77,7 @@ export class Sessions {
77
77
  // the next lower session (which is B) and erroneously determine we do not collide
78
78
  // with any other session, but this situation is impossible to get into as B would
79
79
  // have detected that it collided with A (or the other way around, depending on ordering).
80
+ // eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- using ?. could change behavior
80
81
  while (closestMatch !== undefined && closestMatch[1] === owningSession) {
81
82
  closestMatch = this.uuidSpace.nextLowerPair(closestMatch[0]);
82
83
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../src/sessions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAIlD,OAAO,EACN,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,GACpB,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,MAAM,OAAO,QAAQ;IAOpB,YAAmB,QAAyD;QAN5E,6HAA6H;QAC7H,4DAA4D;QAC3C,cAAS,GAAG,IAAI,KAAK,CAAuB,SAAS,EAAE,cAAc,CAAC,CAAC;QACxF,sGAAsG;QACrF,iBAAY,GAAG,IAAI,GAAG,EAAsB,CAAC;QAG7D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC5B,iBAAiB;YACjB,KAAK,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,QAAQ,EAAE,CAAC;gBAC3C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,uBAAuB,CAAC,OAAO,CAAc,EAAE,OAAO,CAAC,CAAC;YAC/E,CAAC;YACD,IAAI,CAAC,SAAS,GAAG,IAAI,KAAK,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;YACrD,IACC,IAAI,CAAC,YAAY,CAAC,IAAI,KAAK,QAAQ,CAAC,MAAM;gBAC1C,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,EACtC,CAAC;gBACF,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;YACpD,CAAC;QACF,CAAC;IACF,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,YAAY,C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,CAAsB,CAAC;AACrF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAsB,CAAC;AACxF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAsB,CAAC;AACrF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\nimport type { FinalCompressedId, LocalCompressedId, NumericUuid } from \"./identifiers.js\";\nimport type { SessionId, StableId } from \"./types/index.js\";\nimport {\n\tcompareBigints,\n\tgenCountFromLocalId,\n\tlocalIdFromGenCount,\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n\tsubtractNumericUuids,\n} from \"./utilities.js\";\n\n/**\n * A collection of all sessions known to the compressor (i.e. all finalized/acked allocated UUIDs and their corresponding local and final forms).\n * This collection of all sessions comprises a distributed document's IDs.\n */\nexport class Sessions {\n\t// A range-queryable store of all sessions. A btree is used as it solves the predecessor problem for any given UUID, allowing\n\t// us to quickly find the session that may have produced it.\n\tprivate readonly uuidSpace = new BTree<NumericUuid, Session>(undefined, compareBigints);\n\t// A fast lookup table from session ID to the session object, used to avoid accessing the slower btree\n\tprivate readonly sessionCache = new Map<SessionId, Session>();\n\n\tpublic constructor(sessions?: [sessionBase: NumericUuid, session: Session][]) {\n\t\tif (sessions !== undefined) {\n\t\t\t// bulk load path\n\t\t\tfor (const [numeric, session] of sessions) {\n\t\t\t\tthis.sessionCache.set(stableIdFromNumericUuid(numeric) as SessionId, session);\n\t\t\t}\n\t\t\tthis.uuidSpace = new BTree(sessions, compareBigints);\n\t\t\tif (\n\t\t\t\tthis.sessionCache.size !== sessions.length ||\n\t\t\t\tsessions.length !== this.uuidSpace.size\n\t\t\t) {\n\t\t\t\tthrow new Error(\"Cannot resume existing session.\");\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic sessions(): IterableIterator<Session> {\n\t\treturn this.sessionCache.values();\n\t}\n\n\tpublic getOrCreate(sessionId: SessionId): Session {\n\t\tconst existing = this.sessionCache.get(sessionId);\n\t\tif (existing !== undefined) {\n\t\t\treturn existing;\n\t\t}\n\t\tconst session = new Session(sessionId);\n\t\tassert(\n\t\t\tthis.uuidSpace.set(session.sessionUuid, session),\n\t\t\t0x760 /* Duplicate session in map. */,\n\t\t);\n\t\tthis.sessionCache.set(sessionId, session);\n\t\treturn session;\n\t}\n\n\tpublic get(sessionId: SessionId): Session | undefined {\n\t\treturn this.sessionCache.get(sessionId);\n\t}\n\n\tpublic getContainingCluster(\n\t\tquery: StableId,\n\t): [cluster: IdCluster, alignedLocal: LocalCompressedId] | undefined {\n\t\tconst numericStable = numericUuidFromStableId(query);\n\t\tconst possibleMatch = this.uuidSpace.getPairOrNextLower(numericStable);\n\t\tif (possibleMatch === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst [_, session] = possibleMatch;\n\t\tconst numericDelta = subtractNumericUuids(numericStable, session.sessionUuid);\n\t\tif (numericDelta > Number.MAX_SAFE_INTEGER) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst alignedLocal = localIdFromGenCount(Number(numericDelta) + 1);\n\t\tconst containingCluster = session.getClusterByLocal(alignedLocal, true);\n\t\tif (containingCluster === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [containingCluster, alignedLocal];\n\t}\n\n\tpublic clusterCollides(cluster: IdCluster): boolean {\n\t\tconst { session: owningSession, baseLocalId, capacity } = cluster;\n\t\tconst clusterBaseNumeric = offsetNumericUuid(\n\t\t\towningSession.sessionUuid,\n\t\t\tgenCountFromLocalId(baseLocalId) - 1,\n\t\t);\n\t\tconst clusterMaxNumeric = offsetNumericUuid(clusterBaseNumeric, capacity - 1);\n\t\tlet closestMatch: [NumericUuid, Session] | undefined =\n\t\t\tthis.uuidSpace.getPairOrNextLower(clusterMaxNumeric);\n\t\t// Find the first session that is not the owner of this new cluster.\n\t\t// Once we have that, check to see if its cluster chain overlaps with the new cluster.\n\t\t// Consider the following diagram of UUID space:\n\t\t// Cluster chain A: |----------------------|\n\t\t// Cluster chain B: |----------|\n\t\t// Cluster chain C: |-------|\n\t\t// While it is true that when adding a cluster to chain C, we would find\n\t\t// the next lower session (which is B) and erroneously determine we do not collide\n\t\t// with any other session, but this situation is impossible to get into as B would\n\t\t// have detected that it collided with A (or the other way around, depending on ordering).\n\t\twhile (closestMatch !== undefined && closestMatch[1] === owningSession) {\n\t\t\tclosestMatch = this.uuidSpace.nextLowerPair(closestMatch[0]);\n\t\t}\n\t\tif (closestMatch === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst [_, session] = closestMatch;\n\t\tassert(session !== owningSession, 0x761 /* Failed to attempt to detect collisions. */);\n\t\tconst lastCluster = session.getLastCluster();\n\t\tif (lastCluster === undefined) {\n\t\t\t// If the closest session is empty (the local session), then it is guaranteed (probabilistically) that there are no\n\t\t\t// non-empty sessions that have a cluster chain that starts prior to the empty session and collides with the cluster\n\t\t\t// we are checking, so we can return false.\n\t\t\treturn false;\n\t\t}\n\t\tconst lastAllocatedNumeric = offsetNumericUuid(\n\t\t\tsession.sessionUuid,\n\t\t\tgenCountFromLocalId(lastAllocatedLocal(lastCluster)) - 1,\n\t\t);\n\t\treturn lastAllocatedNumeric >= clusterBaseNumeric;\n\t}\n\n\tpublic equals(other: Sessions, includeLocalState: boolean): boolean {\n\t\tconst checkIsSubset = (sessionsA: Sessions, sessionsB: Sessions): boolean => {\n\t\t\tconst first = sessionsA.sessions().next();\n\t\t\tconst firstSessionThis = first.done ? undefined : first.value;\n\t\t\tfor (const [stableId, session] of sessionsA.sessionCache.entries()) {\n\t\t\t\tconst otherSession = sessionsB.sessionCache.get(stableId);\n\t\t\t\tif (otherSession === undefined) {\n\t\t\t\t\tif (!session.isEmpty() || includeLocalState) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tassert(\n\t\t\t\t\t\tsession === firstSessionThis,\n\t\t\t\t\t\t0x762 /* The only non-empty session must be the local session. */,\n\t\t\t\t\t);\n\t\t\t\t} else if (!session.equals(otherSession)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\t\treturn checkIsSubset(this, other) && checkIsSubset(other, this);\n\t}\n}\n\n/**\n * The IDs created by a specific session, stored as a cluster chain to allow for fast conversions.\n */\nexport class Session {\n\t// All clusters created by this session, in creation order (thus sorted by base final and local ID).\n\tprivate readonly clusterChain: IdCluster[] = [];\n\t// The numeric form of the SessionId\n\tpublic readonly sessionUuid: NumericUuid;\n\n\tpublic constructor(sessionId: SessionId | NumericUuid) {\n\t\tthis.sessionUuid =\n\t\t\ttypeof sessionId === \"string\" ? numericUuidFromStableId(sessionId) : sessionId;\n\t}\n\n\t/**\n\t * Adds a new empty cluster to the cluster chain of this session.\n\t */\n\tpublic addNewCluster(\n\t\tbaseFinalId: FinalCompressedId,\n\t\tcapacity: number,\n\t\tcount: number,\n\t): IdCluster {\n\t\tconst lastCluster = this.getLastCluster();\n\t\tconst newCluster: IdCluster = {\n\t\t\tsession: this,\n\t\t\tbaseFinalId,\n\t\t\tbaseLocalId: (lastCluster === undefined\n\t\t\t\t? -1\n\t\t\t\t: lastAllocatedLocal(lastCluster) - 1) as LocalCompressedId,\n\t\t\tcapacity,\n\t\t\tcount,\n\t\t};\n\t\tthis.clusterChain.push(newCluster);\n\t\treturn newCluster;\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.clusterChain.length === 0;\n\t}\n\n\t/**\n\t * Returns the last cluster in this session's cluster chain, if any.\n\t */\n\tpublic getLastCluster(): IdCluster | undefined {\n\t\treturn this.clusterChain[this.clusterChain.length - 1];\n\t}\n\n\t/**\n\t * Converts the local ID from this session to a final ID, if possible.\n\t * @param includeAllocated - true if the conversion should succeed even if the local ID aligns with a part of the cluster that is allocated but not finalized.\n\t */\n\tpublic tryConvertToFinal(\n\t\tsearchLocal: LocalCompressedId,\n\t\tincludeAllocated: boolean,\n\t): FinalCompressedId | undefined {\n\t\tconst containingCluster = this.getClusterByLocal(searchLocal, includeAllocated);\n\t\tif (containingCluster === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn getAlignedFinal(containingCluster, searchLocal);\n\t}\n\n\t/**\n\t * Returns the cluster containing the supplied local ID, if possible.\n\t * @param includeAllocated - true if the conversion should succeed even if the local ID aligns with a part of the cluster that is allocated but not finalized.\n\t */\n\tpublic getClusterByLocal(\n\t\tlocalId: LocalCompressedId,\n\t\tincludeAllocated: boolean,\n\t): IdCluster | undefined {\n\t\tconst lastValidLocal: (cluster: IdCluster) => LocalCompressedId = includeAllocated\n\t\t\t? lastAllocatedLocal\n\t\t\t: lastFinalizedLocal;\n\t\tconst matchedCluster = Session.binarySearch(\n\t\t\tlocalId,\n\t\t\tthis.clusterChain,\n\t\t\t(local, cluster): number => {\n\t\t\t\tconst lastLocal = lastValidLocal(cluster);\n\t\t\t\tif (local < lastLocal) {\n\t\t\t\t\treturn 1;\n\t\t\t\t} else if (local > cluster.baseLocalId) {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t\treturn matchedCluster;\n\t}\n\n\t/**\n\t * Returns the cluster containing the supplied final ID, if possible.\n\t */\n\tpublic getClusterByAllocatedFinal(final: FinalCompressedId): IdCluster | undefined {\n\t\treturn Session.getContainingCluster(final, this.clusterChain);\n\t}\n\n\t/**\n\t * Returns the cluster from the supplied cluster chain containing the supplied final ID, if possible.\n\t * `clusterChain` must be sorted by final/local base ID.\n\t */\n\tpublic static getContainingCluster(\n\t\tfinalId: FinalCompressedId,\n\t\tclusterChain: readonly IdCluster[],\n\t): IdCluster | undefined {\n\t\treturn Session.binarySearch(finalId, clusterChain, (final, cluster) => {\n\t\t\tconst lastFinal = lastAllocatedFinal(cluster);\n\t\t\tif (final < cluster.baseFinalId) {\n\t\t\t\treturn -1;\n\t\t\t} else if (final > lastFinal) {\n\t\t\t\treturn 1;\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t});\n\t}\n\n\tstatic binarySearch<S, T>(\n\t\tsearch: S,\n\t\tarr: readonly T[],\n\t\tcomparator: (a: S, b: T) => number,\n\t): T | undefined {\n\t\tlet left = 0;\n\t\tlet right = arr.length - 1;\n\t\twhile (left <= right) {\n\t\t\tconst mid = Math.floor((left + right) / 2);\n\t\t\tconst value = arr[mid];\n\t\t\tassert(value !== undefined, 0x9dc /* value is undefined in Session.binarySearch */);\n\t\t\tconst c = comparator(search, value);\n\t\t\tif (c === 0) {\n\t\t\t\treturn value; // Found the target, return its index.\n\t\t\t} else if (c > 0) {\n\t\t\t\tleft = mid + 1; // Continue search on right half.\n\t\t\t} else {\n\t\t\t\tright = mid - 1; // Continue search on left half.\n\t\t\t}\n\t\t}\n\t\treturn undefined; // If we reach here, target is not in array.\n\t}\n\n\tpublic equals(other: Session): boolean {\n\t\tfor (const [index, value] of Object.entries(this.clusterChain)) {\n\t\t\tif (!clustersEqual(value, other.clusterChain[index] as IdCluster)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn this.sessionUuid === other.sessionUuid;\n\t}\n}\n\n/**\n * A cluster of final (sequenced via consensus), sequentially allocated compressed IDs.\n * A final ID in a cluster decompresses to a sequentially allocated UUID that is the result of adding its offset within\n * the cluster to base UUID for the session that created it.\n */\nexport interface IdCluster {\n\t/**\n\t * The session that created this cluster.\n\t */\n\treadonly session: Session;\n\n\t/**\n\t * The first final ID in the cluster.\n\t */\n\treadonly baseFinalId: FinalCompressedId;\n\n\t/**\n\t * The local ID aligned with `baseFinalId`.\n\t */\n\treadonly baseLocalId: LocalCompressedId;\n\n\t/**\n\t * The total number of final IDs reserved for allocation in the cluster.\n\t * Clusters are reserved in blocks as a performance optimization.\n\t */\n\tcapacity: number;\n\n\t/**\n\t * The number of final IDs currently allocated in the cluster.\n\t */\n\tcount: number;\n}\n\nexport function clustersEqual(a: IdCluster, b: IdCluster): boolean {\n\treturn (\n\t\ta.session.sessionUuid === b.session.sessionUuid &&\n\t\ta.baseFinalId === b.baseFinalId &&\n\t\ta.baseLocalId === b.baseLocalId &&\n\t\ta.capacity === b.capacity &&\n\t\ta.count === b.count\n\t);\n}\n\n/**\n * Returns the final ID that is aligned with the supplied local ID within a cluster.\n * Includes allocated IDs.\n */\nexport function getAlignedFinal(\n\tcluster: IdCluster,\n\tlocalWithin: LocalCompressedId,\n): FinalCompressedId | undefined {\n\tconst clusterOffset =\n\t\tgenCountFromLocalId(localWithin) - genCountFromLocalId(cluster.baseLocalId);\n\tif (clusterOffset < cluster.capacity) {\n\t\treturn ((cluster.baseFinalId as number) + clusterOffset) as FinalCompressedId;\n\t}\n\treturn undefined;\n}\n\n/**\n * Returns the local ID that is aligned with the supplied final ID within a cluster.\n * Fails if the supplied ID does not fall within the cluster bounds.\n */\nexport function getAlignedLocal(\n\tcluster: IdCluster,\n\tfinalWithin: FinalCompressedId,\n): LocalCompressedId {\n\tassert(\n\t\tfinalWithin >= cluster.baseFinalId && finalWithin <= lastAllocatedFinal(cluster),\n\t\t0x763 /* Supplied ID is not within the cluster. */,\n\t);\n\tconst finalDelta = finalWithin - cluster.baseFinalId;\n\treturn (cluster.baseLocalId - finalDelta) as LocalCompressedId;\n}\n\n/**\n * Returns the last allocated final ID (i.e. any ID between base final and base final + capacity) within a cluster\n */\nexport function lastAllocatedFinal(cluster: IdCluster): FinalCompressedId {\n\treturn ((cluster.baseFinalId as number) + (cluster.capacity - 1)) as FinalCompressedId;\n}\n\n/**\n * Returns the last allocated final ID (i.e. any ID between base final and base final + count) within a cluster\n */\nexport function lastFinalizedFinal(cluster: IdCluster): FinalCompressedId {\n\treturn ((cluster.baseFinalId as number) + (cluster.count - 1)) as FinalCompressedId;\n}\n\n/**\n * Returns the last allocated local ID (i.e. any ID between base local and base local + capacity) within a cluster\n */\nexport function lastAllocatedLocal(cluster: IdCluster): LocalCompressedId {\n\treturn ((cluster.baseLocalId as number) - (cluster.capacity - 1)) as LocalCompressedId;\n}\n\n/**\n * Returns the last allocated local ID (i.e. any ID between base local and base local + count) within a cluster\n */\nexport function lastFinalizedLocal(cluster: IdCluster): LocalCompressedId {\n\treturn ((cluster.baseLocalId as number) - (cluster.count - 1)) as LocalCompressedId;\n}\n"]}
1
+ {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../src/sessions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAIlD,OAAO,EACN,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,GACpB,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,MAAM,OAAO,QAAQ;IAOpB,YAAmB,QAAyD;QAN5E,6HAA6H;QAC7H,4DAA4D;QAC3C,cAAS,GAAG,IAAI,KAAK,CAAuB,SAAS,EAAE,cAAc,CAAC,CAAC;QACxF,sGAAsG;QACrF,iBAAY,GAAG,IAAI,GAAG,EAAsB,CAAC;QAG7D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC5B,iBAAiB;YACjB,KAAK,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,QAAQ,EAAE,CAAC;gBAC3C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,uBAAuB,CAAC,OAAO,CAAc,EAAE,OAAO,CAAC,CAAC;YAC/E,CAAC;YACD,IAAI,CA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O,CAAC,WAAW,GAAG,UAAU,CAAsB,CAAC;AAChE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAsB,CAAC;AACxF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAsB,CAAC;AACrF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAsB,CAAC;AACxF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAsB,CAAC;AACrF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\nimport type { FinalCompressedId, LocalCompressedId, NumericUuid } from \"./identifiers.js\";\nimport type { SessionId, StableId } from \"./types/index.js\";\nimport {\n\tcompareBigints,\n\tgenCountFromLocalId,\n\tlocalIdFromGenCount,\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n\tsubtractNumericUuids,\n} from \"./utilities.js\";\n\n/**\n * A collection of all sessions known to the compressor (i.e. all finalized/acked allocated UUIDs and their corresponding local and final forms).\n * This collection of all sessions comprises a distributed document's IDs.\n */\nexport class Sessions {\n\t// A range-queryable store of all sessions. A btree is used as it solves the predecessor problem for any given UUID, allowing\n\t// us to quickly find the session that may have produced it.\n\tprivate readonly uuidSpace = new BTree<NumericUuid, Session>(undefined, compareBigints);\n\t// A fast lookup table from session ID to the session object, used to avoid accessing the slower btree\n\tprivate readonly sessionCache = new Map<SessionId, Session>();\n\n\tpublic constructor(sessions?: [sessionBase: NumericUuid, session: Session][]) {\n\t\tif (sessions !== undefined) {\n\t\t\t// bulk load path\n\t\t\tfor (const [numeric, session] of sessions) {\n\t\t\t\tthis.sessionCache.set(stableIdFromNumericUuid(numeric) as SessionId, session);\n\t\t\t}\n\t\t\tthis.uuidSpace = new BTree(sessions, compareBigints);\n\t\t\tif (\n\t\t\t\tthis.sessionCache.size !== sessions.length ||\n\t\t\t\tsessions.length !== this.uuidSpace.size\n\t\t\t) {\n\t\t\t\tthrow new Error(\"Cannot resume existing session.\");\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic sessions(): IterableIterator<Session> {\n\t\treturn this.sessionCache.values();\n\t}\n\n\tpublic getOrCreate(sessionId: SessionId): Session {\n\t\tconst existing = this.sessionCache.get(sessionId);\n\t\tif (existing !== undefined) {\n\t\t\treturn existing;\n\t\t}\n\t\tconst session = new Session(sessionId);\n\t\tassert(\n\t\t\tthis.uuidSpace.set(session.sessionUuid, session),\n\t\t\t0x760 /* Duplicate session in map. */,\n\t\t);\n\t\tthis.sessionCache.set(sessionId, session);\n\t\treturn session;\n\t}\n\n\tpublic get(sessionId: SessionId): Session | undefined {\n\t\treturn this.sessionCache.get(sessionId);\n\t}\n\n\tpublic getContainingCluster(\n\t\tquery: StableId,\n\t): [cluster: IdCluster, alignedLocal: LocalCompressedId] | undefined {\n\t\tconst numericStable = numericUuidFromStableId(query);\n\t\tconst possibleMatch = this.uuidSpace.getPairOrNextLower(numericStable);\n\t\tif (possibleMatch === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst [_, session] = possibleMatch;\n\t\tconst numericDelta = subtractNumericUuids(numericStable, session.sessionUuid);\n\t\tif (numericDelta > Number.MAX_SAFE_INTEGER) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst alignedLocal = localIdFromGenCount(Number(numericDelta) + 1);\n\t\tconst containingCluster = session.getClusterByLocal(alignedLocal, true);\n\t\tif (containingCluster === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [containingCluster, alignedLocal];\n\t}\n\n\tpublic clusterCollides(cluster: IdCluster): boolean {\n\t\tconst { session: owningSession, baseLocalId, capacity } = cluster;\n\t\tconst clusterBaseNumeric = offsetNumericUuid(\n\t\t\towningSession.sessionUuid,\n\t\t\tgenCountFromLocalId(baseLocalId) - 1,\n\t\t);\n\t\tconst clusterMaxNumeric = offsetNumericUuid(clusterBaseNumeric, capacity - 1);\n\t\tlet closestMatch: [NumericUuid, Session] | undefined =\n\t\t\tthis.uuidSpace.getPairOrNextLower(clusterMaxNumeric);\n\t\t// Find the first session that is not the owner of this new cluster.\n\t\t// Once we have that, check to see if its cluster chain overlaps with the new cluster.\n\t\t// Consider the following diagram of UUID space:\n\t\t// Cluster chain A: |----------------------|\n\t\t// Cluster chain B: |----------|\n\t\t// Cluster chain C: |-------|\n\t\t// While it is true that when adding a cluster to chain C, we would find\n\t\t// the next lower session (which is B) and erroneously determine we do not collide\n\t\t// with any other session, but this situation is impossible to get into as B would\n\t\t// have detected that it collided with A (or the other way around, depending on ordering).\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- using ?. could change behavior\n\t\twhile (closestMatch !== undefined && closestMatch[1] === owningSession) {\n\t\t\tclosestMatch = this.uuidSpace.nextLowerPair(closestMatch[0]);\n\t\t}\n\t\tif (closestMatch === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst [_, session] = closestMatch;\n\t\tassert(session !== owningSession, 0x761 /* Failed to attempt to detect collisions. */);\n\t\tconst lastCluster = session.getLastCluster();\n\t\tif (lastCluster === undefined) {\n\t\t\t// If the closest session is empty (the local session), then it is guaranteed (probabilistically) that there are no\n\t\t\t// non-empty sessions that have a cluster chain that starts prior to the empty session and collides with the cluster\n\t\t\t// we are checking, so we can return false.\n\t\t\treturn false;\n\t\t}\n\t\tconst lastAllocatedNumeric = offsetNumericUuid(\n\t\t\tsession.sessionUuid,\n\t\t\tgenCountFromLocalId(lastAllocatedLocal(lastCluster)) - 1,\n\t\t);\n\t\treturn lastAllocatedNumeric >= clusterBaseNumeric;\n\t}\n\n\tpublic equals(other: Sessions, includeLocalState: boolean): boolean {\n\t\tconst checkIsSubset = (sessionsA: Sessions, sessionsB: Sessions): boolean => {\n\t\t\tconst first = sessionsA.sessions().next();\n\t\t\tconst firstSessionThis = first.done ? undefined : first.value;\n\t\t\tfor (const [stableId, session] of sessionsA.sessionCache.entries()) {\n\t\t\t\tconst otherSession = sessionsB.sessionCache.get(stableId);\n\t\t\t\tif (otherSession === undefined) {\n\t\t\t\t\tif (!session.isEmpty() || includeLocalState) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tassert(\n\t\t\t\t\t\tsession === firstSessionThis,\n\t\t\t\t\t\t0x762 /* The only non-empty session must be the local session. */,\n\t\t\t\t\t);\n\t\t\t\t} else if (!session.equals(otherSession)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\t\treturn checkIsSubset(this, other) && checkIsSubset(other, this);\n\t}\n}\n\n/**\n * The IDs created by a specific session, stored as a cluster chain to allow for fast conversions.\n */\nexport class Session {\n\t// All clusters created by this session, in creation order (thus sorted by base final and local ID).\n\tprivate readonly clusterChain: IdCluster[] = [];\n\t// The numeric form of the SessionId\n\tpublic readonly sessionUuid: NumericUuid;\n\n\tpublic constructor(sessionId: SessionId | NumericUuid) {\n\t\tthis.sessionUuid =\n\t\t\ttypeof sessionId === \"string\" ? numericUuidFromStableId(sessionId) : sessionId;\n\t}\n\n\t/**\n\t * Adds a new empty cluster to the cluster chain of this session.\n\t */\n\tpublic addNewCluster(\n\t\tbaseFinalId: FinalCompressedId,\n\t\tcapacity: number,\n\t\tcount: number,\n\t): IdCluster {\n\t\tconst lastCluster = this.getLastCluster();\n\t\tconst newCluster: IdCluster = {\n\t\t\tsession: this,\n\t\t\tbaseFinalId,\n\t\t\tbaseLocalId: (lastCluster === undefined\n\t\t\t\t? -1\n\t\t\t\t: lastAllocatedLocal(lastCluster) - 1) as LocalCompressedId,\n\t\t\tcapacity,\n\t\t\tcount,\n\t\t};\n\t\tthis.clusterChain.push(newCluster);\n\t\treturn newCluster;\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.clusterChain.length === 0;\n\t}\n\n\t/**\n\t * Returns the last cluster in this session's cluster chain, if any.\n\t */\n\tpublic getLastCluster(): IdCluster | undefined {\n\t\treturn this.clusterChain[this.clusterChain.length - 1];\n\t}\n\n\t/**\n\t * Converts the local ID from this session to a final ID, if possible.\n\t * @param includeAllocated - true if the conversion should succeed even if the local ID aligns with a part of the cluster that is allocated but not finalized.\n\t */\n\tpublic tryConvertToFinal(\n\t\tsearchLocal: LocalCompressedId,\n\t\tincludeAllocated: boolean,\n\t): FinalCompressedId | undefined {\n\t\tconst containingCluster = this.getClusterByLocal(searchLocal, includeAllocated);\n\t\tif (containingCluster === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn getAlignedFinal(containingCluster, searchLocal);\n\t}\n\n\t/**\n\t * Returns the cluster containing the supplied local ID, if possible.\n\t * @param includeAllocated - true if the conversion should succeed even if the local ID aligns with a part of the cluster that is allocated but not finalized.\n\t */\n\tpublic getClusterByLocal(\n\t\tlocalId: LocalCompressedId,\n\t\tincludeAllocated: boolean,\n\t): IdCluster | undefined {\n\t\tconst lastValidLocal: (cluster: IdCluster) => LocalCompressedId = includeAllocated\n\t\t\t? lastAllocatedLocal\n\t\t\t: lastFinalizedLocal;\n\t\tconst matchedCluster = Session.binarySearch(\n\t\t\tlocalId,\n\t\t\tthis.clusterChain,\n\t\t\t(local, cluster): number => {\n\t\t\t\tconst lastLocal = lastValidLocal(cluster);\n\t\t\t\tif (local < lastLocal) {\n\t\t\t\t\treturn 1;\n\t\t\t\t} else if (local > cluster.baseLocalId) {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t\treturn matchedCluster;\n\t}\n\n\t/**\n\t * Returns the cluster containing the supplied final ID, if possible.\n\t */\n\tpublic getClusterByAllocatedFinal(final: FinalCompressedId): IdCluster | undefined {\n\t\treturn Session.getContainingCluster(final, this.clusterChain);\n\t}\n\n\t/**\n\t * Returns the cluster from the supplied cluster chain containing the supplied final ID, if possible.\n\t * `clusterChain` must be sorted by final/local base ID.\n\t */\n\tpublic static getContainingCluster(\n\t\tfinalId: FinalCompressedId,\n\t\tclusterChain: readonly IdCluster[],\n\t): IdCluster | undefined {\n\t\treturn Session.binarySearch(finalId, clusterChain, (final, cluster) => {\n\t\t\tconst lastFinal = lastAllocatedFinal(cluster);\n\t\t\tif (final < cluster.baseFinalId) {\n\t\t\t\treturn -1;\n\t\t\t} else if (final > lastFinal) {\n\t\t\t\treturn 1;\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t});\n\t}\n\n\tstatic binarySearch<S, T>(\n\t\tsearch: S,\n\t\tarr: readonly T[],\n\t\tcomparator: (a: S, b: T) => number,\n\t): T | undefined {\n\t\tlet left = 0;\n\t\tlet right = arr.length - 1;\n\t\twhile (left <= right) {\n\t\t\tconst mid = Math.floor((left + right) / 2);\n\t\t\tconst value = arr[mid];\n\t\t\tassert(value !== undefined, 0x9dc /* value is undefined in Session.binarySearch */);\n\t\t\tconst c = comparator(search, value);\n\t\t\tif (c === 0) {\n\t\t\t\treturn value; // Found the target, return its index.\n\t\t\t} else if (c > 0) {\n\t\t\t\tleft = mid + 1; // Continue search on right half.\n\t\t\t} else {\n\t\t\t\tright = mid - 1; // Continue search on left half.\n\t\t\t}\n\t\t}\n\t\treturn undefined; // If we reach here, target is not in array.\n\t}\n\n\tpublic equals(other: Session): boolean {\n\t\tfor (const [index, value] of Object.entries(this.clusterChain)) {\n\t\t\tif (!clustersEqual(value, other.clusterChain[index] as IdCluster)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn this.sessionUuid === other.sessionUuid;\n\t}\n}\n\n/**\n * A cluster of final (sequenced via consensus), sequentially allocated compressed IDs.\n * A final ID in a cluster decompresses to a sequentially allocated UUID that is the result of adding its offset within\n * the cluster to base UUID for the session that created it.\n */\nexport interface IdCluster {\n\t/**\n\t * The session that created this cluster.\n\t */\n\treadonly session: Session;\n\n\t/**\n\t * The first final ID in the cluster.\n\t */\n\treadonly baseFinalId: FinalCompressedId;\n\n\t/**\n\t * The local ID aligned with `baseFinalId`.\n\t */\n\treadonly baseLocalId: LocalCompressedId;\n\n\t/**\n\t * The total number of final IDs reserved for allocation in the cluster.\n\t * Clusters are reserved in blocks as a performance optimization.\n\t */\n\tcapacity: number;\n\n\t/**\n\t * The number of final IDs currently allocated in the cluster.\n\t */\n\tcount: number;\n}\n\nexport function clustersEqual(a: IdCluster, b: IdCluster): boolean {\n\treturn (\n\t\ta.session.sessionUuid === b.session.sessionUuid &&\n\t\ta.baseFinalId === b.baseFinalId &&\n\t\ta.baseLocalId === b.baseLocalId &&\n\t\ta.capacity === b.capacity &&\n\t\ta.count === b.count\n\t);\n}\n\n/**\n * Returns the final ID that is aligned with the supplied local ID within a cluster.\n * Includes allocated IDs.\n */\nexport function getAlignedFinal(\n\tcluster: IdCluster,\n\tlocalWithin: LocalCompressedId,\n): FinalCompressedId | undefined {\n\tconst clusterOffset =\n\t\tgenCountFromLocalId(localWithin) - genCountFromLocalId(cluster.baseLocalId);\n\tif (clusterOffset < cluster.capacity) {\n\t\treturn ((cluster.baseFinalId as number) + clusterOffset) as FinalCompressedId;\n\t}\n\treturn undefined;\n}\n\n/**\n * Returns the local ID that is aligned with the supplied final ID within a cluster.\n * Fails if the supplied ID does not fall within the cluster bounds.\n */\nexport function getAlignedLocal(\n\tcluster: IdCluster,\n\tfinalWithin: FinalCompressedId,\n): LocalCompressedId {\n\tassert(\n\t\tfinalWithin >= cluster.baseFinalId && finalWithin <= lastAllocatedFinal(cluster),\n\t\t0x763 /* Supplied ID is not within the cluster. */,\n\t);\n\tconst finalDelta = finalWithin - cluster.baseFinalId;\n\treturn (cluster.baseLocalId - finalDelta) as LocalCompressedId;\n}\n\n/**\n * Returns the last allocated final ID (i.e. any ID between base final and base final + capacity) within a cluster\n */\nexport function lastAllocatedFinal(cluster: IdCluster): FinalCompressedId {\n\treturn ((cluster.baseFinalId as number) + (cluster.capacity - 1)) as FinalCompressedId;\n}\n\n/**\n * Returns the last allocated final ID (i.e. any ID between base final and base final + count) within a cluster\n */\nexport function lastFinalizedFinal(cluster: IdCluster): FinalCompressedId {\n\treturn ((cluster.baseFinalId as number) + (cluster.count - 1)) as FinalCompressedId;\n}\n\n/**\n * Returns the last allocated local ID (i.e. any ID between base local and base local + capacity) within a cluster\n */\nexport function lastAllocatedLocal(cluster: IdCluster): LocalCompressedId {\n\treturn ((cluster.baseLocalId as number) - (cluster.capacity - 1)) as LocalCompressedId;\n}\n\n/**\n * Returns the last allocated local ID (i.e. any ID between base local and base local + count) within a cluster\n */\nexport function lastFinalizedLocal(cluster: IdCluster): LocalCompressedId {\n\treturn ((cluster.baseLocalId as number) - (cluster.count - 1)) as LocalCompressedId;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressorTestUtilities.d.ts","sourceRoot":"","sources":["../../src/test/idCompressorTestUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,QAAQ,EAOb,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAEtB,KAAK,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M,CAAC;IACxB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACnC;AAQD,wBAAgB,eAAe,CAC9B,OAAO,EAAE,yBAAyB,GAChC,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC,CA4FrC;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC,EAC9C,OAAO,EAAE,uBAAuB,EAChC,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,MAAM,EACvB,gBAAgB,GAAE,OAAc,EAChC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,EACtD,QAAQ,CAAC,EAAE,QAAQ,GACjB,IAAI,CA0DN;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,UAAU,EAAE,YAAY,EACxB,KAAK,EAAE,MAAM,GACX,wBAAwB,EAAE,CAM5B;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAChD,MAAM,CAAC,EAAE,oBAAoB,GAC3B,aAAa,GAAG,iBAAiB,CAAC;AACrC;;;GAGG;AACH,wBAAgB,iCAAiC,CAChD,SAAS,EAAE,SAAS,EACpB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,IAAI,CAAC,EAAE,MAAM,GACX,aAAa,GAAG,iBAAiB,CAAC"}
1
+ {"version":3,"file":"idCompressorTestUtilities.d.ts","sourceRoot":"","sources":["../../src/test/idCompressorTestUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,QAAQ,EAOb,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACN,KA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yB;IACzC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACnC;AAQD,wBAAgB,eAAe,CAC9B,OAAO,EAAE,yBAAyB,GAChC,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC,CA4FrC;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC,EAC9C,OAAO,EAAE,uBAAuB,EAChC,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,MAAM,EACvB,gBAAgB,GAAE,OAAc,EAChC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,EACtD,QAAQ,CAAC,EAAE,QAAQ,GACjB,IAAI,CA0DN;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,UAAU,EAAE,YAAY,EACxB,KAAK,EAAE,MAAM,GACX,wBAAwB,EAAE,CAM5B;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAChD,MAAM,CAAC,EAAE,oBAAoB,GAC3B,aAAa,GAAG,iBAAiB,CAAC;AACrC;;;GAGG;AACH,wBAAgB,iCAAiC,CAChD,SAAS,EAAE,SAAS,EACpB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,IAAI,CAAC,EAAE,MAAM,GACX,aAAa,GAAG,iBAAiB,CAAC"}
@@ -364,6 +364,7 @@ export class IdCompressorTestNetwork {
364
364
  assert(range.sessionId === compressor.localSessionId);
365
365
  if (range.ids !== undefined) {
366
366
  // initialize firstGenCount if not set
367
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy
367
368
  if (firstGenCount === undefined) {
368
369
  firstGenCount = range.ids.firstGenCount;
369
370
  }
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressorTestUtilities.js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* Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\n\nimport {\n\ttype BaseFuzzTestState,\n\ttype Generator,\n\ttype SaveInfo,\n\tcreateWeightedGenerator,\n\tinterleave,\n\tmakeRandom,\n\tperformFuzzActions as performFuzzActionsBase,\n\trepeat,\n\ttake,\n} from \"@fluid-private/stochastic-test-utils\";\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\n\nimport { IdCompressor } from \"../idCompressor.js\";\nimport {\n\ttype IIdCompressor,\n\ttype IIdCompressorCore,\n\ttype IdCreationRange,\n\ttype OpSpaceCompressedId,\n\ttype SerializedIdCompressorWithNoSession,\n\ttype SerializedIdCompressorWithOngoingSession,\n\ttype SessionId,\n\ttype SessionSpaceCompressedId,\n\ttype StableId,\n\tcreateIdCompressor,\n} from \"../index.js\";\nimport { SessionSpaceNormalizer } from \"../sessionSpaceNormalizer.js\";\nimport { assertIsSessionId, createSessionId, localIdFromGenCount } from \"../utilities.js\";\n\nimport {\n\ttype FinalCompressedId,\n\ttype ReadonlyIdCompressor,\n\tfail,\n\tgetOrCreate,\n\tincrementStableId,\n\tisFinalId,\n\tisLocalId,\n} from \"./testCommon.js\";\n\n/**\n * A readonly `Map` which is known to contain a value for every possible key\n */\nexport interface ClosedMap<K, V> extends Omit<Map<K, V>, \"delete\" | \"clear\"> {\n\tget(key: K): V;\n}\n\n/**\n * Identifies a compressor in a network\n */\nexport enum Client {\n\tClient1 = \"Client1\",\n\tClient2 = \"Client2\",\n\tClient3 = \"Client3\",\n}\n\n/**\n * Identifies categories of compressors\n */\nexport enum MetaClient {\n\tAll = \"All\",\n}\n\n/**\n * Identifies a compressor inside the network but outside the three specially tracked clients.\n */\nexport enum OutsideClient {\n\tRemote = \"Remote\",\n}\n\n/**\n * Used to attribute actions to clients in a distributed collaboration session.\n * `Local` implies a local and unsequenced operation. All others imply sequenced operations.\n */\nexport type OriginatingClient = Client | OutsideClient;\nexport const OriginatingClient = { ...Client, ...OutsideClient };\n\n/**\n * Identifies a compressor to which to send an operation\n */\nexport type DestinationClient = Client | MetaClient;\nexport const DestinationClient = { ...Client, ...MetaClient };\n\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport class CompressorFactory {\n\t/**\n\t * Creates a new compressor with the supplied cluster capacity.\n\t */\n\tpublic static createCompressor(\n\t\tclient: Client,\n\t\tclusterCapacity = 5,\n\t\tlogger?: ITelemetryBaseLogger,\n\t): IdCompressor {\n\t\treturn CompressorFactory.createCompressorWithSession(\n\t\t\tsessionIds.get(client),\n\t\t\tclusterCapacity,\n\t\t\tlogger,\n\t\t);\n\t}\n\n\t/**\n\t * Creates a new compressor with the supplied cluster capacity.\n\t */\n\tpublic static createCompressorWithSession(\n\t\tsessionId: SessionId,\n\t\tclusterCapacity = 5,\n\t\tlogger?: ITelemetryBaseLogger,\n\t): IdCompressor {\n\t\tconst compressor = createIdCompressor(sessionId, logger) as IdCompressor;\n\t\tmodifyClusterSize(compressor, clusterCapacity);\n\t\treturn compressor;\n\t}\n}\n\n/**\n * Modify the requested cluster size of the provided compressor.\n * @remarks\n * This is useful for testing purposes for a few reasons:\n * - Id compressor bugs are often related to edge cases that occur on cluster boundaries\n * - Smaller cluster sizes can enable writing tests without for loops generating \"ids until a new cluster is created\"\n */\nexport function modifyClusterSize(compressor: IIdCompressor, newClusterSize: number): void {\n\tverifyCompressorLike(compressor);\n\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\tcompressor[\"nextRequestedClusterSize\"] = newClusterSize;\n}\n\n/**\n * Returns the current cluster size of the compressor.\n * @privateRemarks\n * This is useful in writing tests to avoid having to hardcode the (currently constant) cluster size.\n */\nexport function getClusterSize(compressor: ReadonlyIdCompressor): number {\n\tverifyCompressorLike(compressor);\n\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\treturn compressor[\"nextRequestedClusterSize\"] as number;\n}\n\nfunction verifyCompressorLike(compressor: ReadonlyIdCompressor | IIdCompressor): void {\n\tassert(\n\t\t// Some IdCompressor tests wrap underlying compressors with proxies--allow this for now.\n\t\t// Because of id-compressor's dynamic import in container-runtime, instanceof checks for IdCompressor\n\t\t// also won't necessarily work nicely. Get a small amount of validation that this function should work\n\t\t// as intended by at least verifying the property name exists.\n\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\ttypeof compressor[\"nextRequestedClusterSize\"] === \"number\",\n\t);\n}\n\n/**\n * Utility for building a huge compressor.\n * Build via the compressor factory.\n */\nexport function buildHugeCompressor(\n\tnumSessions = 10000,\n\tcapacity = 10,\n\tnumClustersPerSession = 3,\n): IdCompressor {\n\tconst compressor = CompressorFactory.createCompressorWithSession(\n\t\tcreateSessionId(),\n\t\tcapacity,\n\t);\n\tconst sessions: SessionId[] = [];\n\tfor (let i = 0; i < numSessions; i++) {\n\t\tsessions.push(createSessionId());\n\t}\n\tfor (let i = 0; i < numSessions * numClustersPerSession; i++) {\n\t\tconst sessionId = sessions[i % numSessions];\n\t\tif (Math.random() > 0.1) {\n\t\t\tfor (let j = 0; j < Math.round(capacity / 2); j++) {\n\t\t\t\tcompressor.generateCompressedId();\n\t\t\t}\n\t\t\tcompressor.finalizeCreationRange(compressor.takeNextCreationRange());\n\t\t}\n\t\tcompressor.finalizeCreationRange({\n\t\t\tsessionId,\n\t\t\tids: {\n\t\t\t\tfirstGenCount: Math.floor(i / numSessions) * capacity + 1,\n\t\t\t\tcount: capacity,\n\t\t\t\trequestedClusterSize: capacity,\n\t\t\t\tlocalIdRanges: [], // remote session, can safely ignore in tests\n\t\t\t},\n\t\t});\n\t}\n\treturn compressor;\n}\n\n/**\n * A closed map from NamedClient to T.\n */\nexport type ClientMap<T> = ClosedMap<Client, T>;\n\nfunction makeSessionIds(): ClientMap<SessionId> {\n\tconst stableIds = new Map<Client, SessionId>();\n\tconst clients = Object.values(Client);\n\tfor (let i = 0; i < clients.length; i++) {\n\t\t// Place session uuids roughly in the middle of uuid space to increase odds of encountering interesting\n\t\t// orderings in sorted collections\n\t\tconst sessionId = assertIsSessionId(`88888888-8888-4888-b${i}88-888888888888`);\n\t\tstableIds.set(clients[i], sessionId);\n\t}\n\treturn stableIds as ClientMap<SessionId>;\n}\n\n/**\n * An array of session ID strings corresponding to all non-local `Client` entries.\n */\nexport const sessionIds = makeSessionIds();\n\n/**\n * Information about a generated ID in a network to be validated by tests\n */\nexport interface TestIdData {\n\treadonly id: SessionSpaceCompressedId;\n\treadonly originatingClient: OriginatingClient;\n\treadonly sessionId: SessionId;\n\treadonly isSequenced: boolean;\n}\n\n/**\n * Simulates a network of ID compressors.\n * Not suitable for performance testing.\n */\nexport class IdCompressorTestNetwork {\n\t/**\n\t * The compressors used in this network\n\t */\n\tprivate readonly compressors: ClientMap<IdCompressor>;\n\t/**\n\t * The log of operations seen by the server so far. Append-only.\n\t */\n\tprivate readonly serverOperations: [\n\t\tcreationRange: IdCreationRange,\n\t\topSpaceIds: OpSpaceCompressedId[],\n\t\tclientFrom: OriginatingClient,\n\t\tsessionIdFrom: SessionId,\n\t][] = [];\n\t/**\n\t * An index into `serverOperations` for each client which represents how many operations have been delivered to that client\n\t */\n\tprivate readonly clientProgress: ClientMap<number>;\n\t/**\n\t * All ids (local and sequenced) that a client has created or received, in order.\n\t */\n\tprivate readonly idLogs: ClientMap<TestIdData[]>;\n\t/**\n\t * All ids that a client has received from the server, in order.\n\t */\n\tprivate readonly sequencedIdLogs: ClientMap<TestIdData[]>;\n\n\tpublic constructor(public readonly initialClusterSize = 5) {\n\t\tconst compressors = new Map<Client, IdCompressor>();\n\t\tconst clientProgress = new Map<Client, number>();\n\t\tconst clientIds = new Map<Client, TestIdData[]>();\n\t\tconst clientSequencedIds = new Map<Client, TestIdData[]>();\n\t\tfor (const client of Object.values(Client)) {\n\t\t\tconst compressor = CompressorFactory.createCompressor(client, initialClusterSize);\n\t\t\tcompressors.set(client, compressor);\n\t\t\tclientProgress.set(client, 0);\n\t\t\tclientIds.set(client, []);\n\t\t\tclientSequencedIds.set(client, []);\n\t\t}\n\t\tthis.compressors = compressors as ClientMap<IdCompressor>;\n\t\tthis.clientProgress = clientProgress as ClientMap<number>;\n\t\tthis.idLogs = clientIds as ClientMap<TestIdData[]>;\n\t\tthis.sequencedIdLogs = clientSequencedIds as ClientMap<TestIdData[]>;\n\t}\n\n\t/**\n\t * Returns the number of undelivered operations for the given client that are in flight in the network.\n\t */\n\tpublic getPendingOperations(destination: Client): number {\n\t\treturn this.serverOperations.length - this.clientProgress.get(destination);\n\t}\n\n\t/**\n\t * Returns an immutable handle to a compressor in the network.\n\t */\n\tpublic getCompressor(client: Client): ReadonlyIdCompressor {\n\t\tconst compressors = this.compressors;\n\t\tconst handler = {\n\t\t\tget<P extends keyof IdCompressor>(_: unknown, property: P): IdCompressor[P] {\n\t\t\t\treturn compressors.get(client)[property];\n\t\t\t},\n\t\t\tset<P extends keyof IdCompressor>(\n\t\t\t\t_: unknown,\n\t\t\t\tproperty: P,\n\t\t\t\tvalue: IdCompressor[P],\n\t\t\t): boolean {\n\t\t\t\tcompressors.get(client)[property] = value;\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\t\treturn new Proxy<IdCompressor>({} as unknown as IdCompressor, handler);\n\t}\n\n\t/**\n\t * Returns a mutable handle to a compressor in the network. Use of mutation methods will break the network invariants and\n\t * should only be used if the network will not be used again.\n\t */\n\tpublic getCompressorUnsafe(client: Client): IdCompressor {\n\t\treturn this.getCompressor(client) as IdCompressor;\n\t}\n\n\t/**\n\t * Returns a mutable handle to a compressor in the network. Use of mutation methods will break the network invariants and\n\t * should only be used if the network will not be used again. Additionally, the returned compressor will be invalidated/unusable\n\t * if any network operations cause it to be regenerated (serialization/deserialization, etc.).\n\t */\n\tpublic getCompressorUnsafeNoProxy(client: Client): IdCompressor {\n\t\treturn this.compressors.get(client);\n\t}\n\n\t/**\n\t * Returns data for all IDs created and received by this client, including ack's of their own (i.e. their own IDs will appear twice)\n\t */\n\tpublic getIdLog(client: Client): readonly TestIdData[] {\n\t\treturn this.idLogs.get(client);\n\t}\n\n\t/**\n\t * Returns data for all IDs received by this client, including ack's of their own.\n\t */\n\tpublic getSequencedIdLog(client: Client): readonly TestIdData[] {\n\t\treturn this.sequencedIdLogs.get(client);\n\t}\n\n\t/**\n\t * Get all compressors for the given destination\n\t */\n\tpublic getTargetCompressors(clientTo: DestinationClient): [Client, IdCompressor][] {\n\t\treturn clientTo === MetaClient.All\n\t\t\t? [...this.compressors.entries()]\n\t\t\t: ([[clientTo, this.getCompressor(clientTo)]] as [Client, IdCompressor][]);\n\t}\n\n\t/**\n\t * Changes the capacity request amount for a client. It will take effect immediately.\n\t */\n\tpublic changeCapacity(client: Client, newClusterCapacity: number): void {\n\t\tmodifyClusterSize(this.compressors.get(client), newClusterCapacity);\n\t}\n\n\tprivate addNewId(\n\t\tclient: Client,\n\t\tid: SessionSpaceCompressedId,\n\t\toriginatingClient: OriginatingClient,\n\t\tsessionIdFrom: SessionId,\n\t\tisSequenced: boolean,\n\t): void {\n\t\tconst idData = {\n\t\t\tid,\n\t\t\toriginatingClient,\n\t\t\tsessionId: sessionIdFrom,\n\t\t\tisSequenced,\n\t\t};\n\t\tconst clientIds = this.idLogs.get(client);\n\t\tclientIds.push(idData);\n\t\tif (isSequenced) {\n\t\t\tconst sequencedIds = this.sequencedIdLogs.get(client);\n\t\t\tsequencedIds.push(idData);\n\t\t}\n\t}\n\n\t/**\n\t * Allocates a new range of local IDs and enqueues them for future delivery via a `testIdDelivery` action.\n\t * Calls to this method determine the total order of delivery, regardless of when `deliverOperations` is called.\n\t */\n\tpublic allocateAndSendIds(clientFrom: Client, numIds: number): OpSpaceCompressedId[] {\n\t\treturn this.allocateAndSendIdsFromRemoteClient(\n\t\t\tclientFrom,\n\t\t\tsessionIds.get(clientFrom),\n\t\t\tnumIds,\n\t\t);\n\t}\n\n\t/**\n\t * Same contract as `allocateAndSendIds`, but the originating client will be a client with the supplied sessionId.\n\t */\n\tpublic allocateAndSendIdsFromRemoteClient(\n\t\tclientFrom: OriginatingClient,\n\t\tsessionIdFrom: SessionId,\n\t\tnumIds: number,\n\t): OpSpaceCompressedId[] {\n\t\tassert(numIds > 0, \"Must allocate a non-zero number of IDs\");\n\t\tif (clientFrom === OriginatingClient.Remote) {\n\t\t\tconst range: IdCreationRange = {\n\t\t\t\tsessionId: sessionIdFrom,\n\t\t\t\tids: {\n\t\t\t\t\tfirstGenCount: 1,\n\t\t\t\t\tcount: numIds,\n\t\t\t\t\trequestedClusterSize: getClusterSize(this.getCompressor(Client.Client1)),\n\t\t\t\t\tlocalIdRanges: [], // remote session, can safely ignore in tests\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst opSpaceIds: OpSpaceCompressedId[] = [];\n\t\t\tfor (let i = 0; i < numIds; i++) {\n\t\t\t\topSpaceIds.push(-(i + 1) as OpSpaceCompressedId);\n\t\t\t}\n\t\t\tthis.serverOperations.push([range, opSpaceIds, clientFrom, sessionIdFrom]);\n\t\t\treturn opSpaceIds;\n\t\t} else {\n\t\t\tassert(sessionIdFrom === sessionIds.get(clientFrom));\n\t\t\tconst compressor = this.compressors.get(clientFrom);\n\t\t\tconst sessionSpaceIds = generateCompressedIds(compressor, numIds);\n\t\t\tfor (let i = 0; i < numIds; i++) {\n\t\t\t\tthis.addNewId(clientFrom, sessionSpaceIds[i], clientFrom, sessionIdFrom, false);\n\t\t\t}\n\t\t\tconst opSpaceIds = sessionSpaceIds.map((id) => compressor.normalizeToOpSpace(id));\n\t\t\tconst creationRange = compressor.takeNextCreationRange();\n\t\t\tthis.serverOperations.push([creationRange, opSpaceIds, clientFrom, sessionIdFrom]);\n\t\t\treturn opSpaceIds;\n\t\t}\n\t}\n\n\t/**\n\t * Delivers all undelivered ID ranges from the server to the target clients.\n\t */\n\tpublic deliverOperations(clientTakingDelivery: Client, opsToDeliver?: number): void;\n\n\t/**\n\t * Delivers all undelivered ID ranges from the server to the target clients.\n\t */\n\tpublic deliverOperations(clientTakingDelivery: DestinationClient): void;\n\n\t/**\n\t * Delivers all undelivered ID ranges from the server to the target clients.\n\t */\n\tpublic deliverOperations(\n\t\tclientTakingDelivery: DestinationClient,\n\t\topsToDeliver?: number,\n\t): void {\n\t\tlet opIndexBound: number;\n\t\tif (clientTakingDelivery === DestinationClient.All) {\n\t\t\tassert(opsToDeliver === undefined);\n\t\t\topIndexBound = this.serverOperations.length;\n\t\t} else {\n\t\t\topIndexBound =\n\t\t\t\topsToDeliver === undefined\n\t\t\t\t\t? this.serverOperations.length\n\t\t\t\t\t: this.clientProgress.get(clientTakingDelivery) + opsToDeliver;\n\t\t}\n\t\tfor (const [clientTo, compressorTo] of this.getTargetCompressors(clientTakingDelivery)) {\n\t\t\tfor (let i = this.clientProgress.get(clientTo); i < opIndexBound; i++) {\n\t\t\t\tconst [range, opSpaceIds, clientFrom, sessionIdFrom] = this.serverOperations[i];\n\t\t\t\tcompressorTo.finalizeCreationRange(range);\n\n\t\t\t\tconst ids = range.ids;\n\t\t\t\tif (ids !== undefined) {\n\t\t\t\t\tfor (const id of opSpaceIds) {\n\t\t\t\t\t\tconst sessionSpaceId = compressorTo.normalizeToSessionSpace(id, range.sessionId);\n\t\t\t\t\t\tthis.addNewId(clientTo, sessionSpaceId, clientFrom, sessionIdFrom, true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.clientProgress.set(clientTo, opIndexBound);\n\t\t}\n\t}\n\n\t/**\n\t * Simulate a client disconnecting (and serializing), then reconnecting (and deserializing)\n\t */\n\tpublic goOfflineThenResume(client: Client): void {\n\t\tconst compressor = this.compressors.get(client);\n\t\tconst [_, resumedCompressor] = roundtrip(compressor, true);\n\t\tthis.compressors.set(client, resumedCompressor);\n\t}\n\n\t/**\n\t * Ensure general validity of the network state. Useful for calling periodically or at the end of test scenarios.\n\t */\n\tpublic assertNetworkState(): void {\n\t\tconst sequencedLogs = Object.values(Client).map(\n\t\t\t(client) => [this.compressors.get(client), this.getSequencedIdLog(client)] as const,\n\t\t);\n\n\t\tconst getLocalIdsInRange = (\n\t\t\trange: IdCreationRange,\n\t\t\topSpaceIds?: OpSpaceCompressedId[],\n\t\t): Set<SessionSpaceCompressedId> => {\n\t\t\tconst localIdsInCreationRange = new Set<SessionSpaceCompressedId>();\n\t\t\tconst ids = range.ids;\n\t\t\tif (ids !== undefined) {\n\t\t\t\tconst { firstGenCount, localIdRanges } = ids;\n\t\t\t\tfor (const [genCount, count] of localIdRanges) {\n\t\t\t\t\tfor (let g = genCount; g < genCount + count; g++) {\n\t\t\t\t\t\tconst local = localIdFromGenCount(g);\n\t\t\t\t\t\tif (opSpaceIds) {\n\t\t\t\t\t\t\tassert.strictEqual(opSpaceIds[g - firstGenCount], local);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlocalIdsInCreationRange.add(local);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn localIdsInCreationRange;\n\t\t};\n\n\t\t// Ensure creation ranges for clients we track contain the correct local ID ranges\n\t\tfor (const [range, opSpaceIds, clientFrom] of this.serverOperations) {\n\t\t\tif (clientFrom !== OriginatingClient.Remote) {\n\t\t\t\tconst localIdsInCreationRange = getLocalIdsInRange(range, opSpaceIds);\n\t\t\t\tlet localCount = 0;\n\t\t\t\tfor (const id of opSpaceIds) {\n\t\t\t\t\tif (isLocalId(id)) {\n\t\t\t\t\t\tlocalCount++;\n\t\t\t\t\t\tassert(localIdsInCreationRange.has(id), \"Local ID not in creation range\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\tlocalCount,\n\t\t\t\t\tlocalIdsInCreationRange.size,\n\t\t\t\t\t\"Local ID count mismatch\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst undeliveredRanges = new Map<Client, IdCreationRange[]>();\n\t\tfor (const [client, progress] of this.clientProgress.entries()) {\n\t\t\tconst ranges = this.serverOperations\n\t\t\t\t.slice(progress)\n\t\t\t\t.filter((op) => op[2] === client)\n\t\t\t\t.map(([range]) => range);\n\t\t\tundeliveredRanges.set(client, ranges);\n\t\t}\n\t\tfor (const [client, ranges] of undeliveredRanges.entries()) {\n\t\t\tconst compressor = this.compressors.get(client);\n\t\t\tlet firstGenCount: number | undefined;\n\t\t\tlet totalCount = 0;\n\t\t\tconst unionedLocalRanges = new SessionSpaceNormalizer();\n\t\t\tfor (const range of ranges) {\n\t\t\t\tassert(range.sessionId === compressor.localSessionId);\n\t\t\t\tif (range.ids !== undefined) {\n\t\t\t\t\t// initialize firstGenCount if not set\n\t\t\t\t\tif (firstGenCount === undefined) {\n\t\t\t\t\t\tfirstGenCount = range.ids.firstGenCount;\n\t\t\t\t\t}\n\t\t\t\t\ttotalCount += range.ids.count;\n\t\t\t\t\tfor (const [genCount, count] of range.ids.localIdRanges) {\n\t\t\t\t\t\tunionedLocalRanges.addLocalRange(genCount, count);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst retakenRange = compressor.takeUnfinalizedCreationRange();\n\t\t\tif (retakenRange.ids === undefined) {\n\t\t\t\tassert.strictEqual(totalCount, 0);\n\t\t\t\tassert.strictEqual(unionedLocalRanges.idRanges.size, 0);\n\t\t\t} else {\n\t\t\t\tconst retakenLocalIds = new SessionSpaceNormalizer();\n\t\t\t\tfor (const [genCount, count] of retakenRange.ids.localIdRanges) {\n\t\t\t\t\tretakenLocalIds.addLocalRange(genCount, count);\n\t\t\t\t}\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\tretakenLocalIds.equals(unionedLocalRanges),\n\t\t\t\t\ttrue,\n\t\t\t\t\t\"Local ID ranges mismatch\",\n\t\t\t\t);\n\t\t\t\tassert.strictEqual(retakenRange.ids.count, totalCount, \"Count mismatch\");\n\t\t\t\tassert.strictEqual(retakenRange.ids.firstGenCount, firstGenCount, \"Count mismatch\");\n\t\t\t}\n\t\t}\n\n\t\t// First, ensure all clients each generated a unique ID for each of their own calls to generate.\n\t\tfor (const [compressor, ids] of sequencedLogs) {\n\t\t\tconst allUuids = new Set<StableId | string>();\n\t\t\tfor (const idData of ids) {\n\t\t\t\tconst uuid = compressor.decompress(idData.id);\n\t\t\t\tassert.strictEqual(!allUuids.has(uuid), true, \"Duplicate UUID generated.\");\n\t\t\t\tallUuids.add(uuid);\n\t\t\t}\n\t\t}\n\n\t\tconst maxLogLength = sequencedLogs\n\t\t\t.map(([_, data]) => data.length)\n\t\t\t// eslint-disable-next-line unicorn/no-array-reduce\n\t\t\t.reduce((p, n) => Math.max(p, n));\n\n\t\tfunction getNextLogWithEntryAt(logsIndex: number, entryIndex: number): number | undefined {\n\t\t\tfor (let i = logsIndex; i < sequencedLogs.length; i++) {\n\t\t\t\tconst log = sequencedLogs[i];\n\t\t\t\tif (log[1].length > entryIndex) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst uuids = new Set<StableId>();\n\t\tconst finalIds = new Set<FinalCompressedId>();\n\t\tconst idIndicesAggregator = new Map<SessionId, number>();\n\n\t\tfunction* getIdLogEntries(\n\t\t\tcolumnIndex: number,\n\t\t): Iterable<\n\t\t\t[\n\t\t\t\tcurrent: [compressor: IdCompressor, idData: TestIdData],\n\t\t\t\tnext?: [compressor: IdCompressor, idData: TestIdData],\n\t\t\t]\n\t\t> {\n\t\t\tlet current = getNextLogWithEntryAt(0, columnIndex);\n\t\t\twhile (current !== undefined) {\n\t\t\t\tconst next = getNextLogWithEntryAt(current + 1, columnIndex);\n\t\t\t\tconst [compressor, log] = sequencedLogs[current];\n\t\t\t\tif (next === undefined) {\n\t\t\t\t\tyield [[compressor, log[columnIndex]]];\n\t\t\t\t} else {\n\t\t\t\t\tconst [compressorNext, logNext] = sequencedLogs[next];\n\t\t\t\t\tyield [\n\t\t\t\t\t\t[compressor, log[columnIndex]],\n\t\t\t\t\t\t[compressorNext, logNext[columnIndex]],\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\tcurrent = next;\n\t\t\t}\n\t\t}\n\n\t\tfor (let i = 0; i < maxLogLength; i++) {\n\t\t\tlet idCreatorCount = 0;\n\t\t\tlet originatingSession: SessionId | undefined;\n\t\t\tfor (const [current, next] of getIdLogEntries(i)) {\n\t\t\t\tconst [compressorA, idDataA] = current;\n\t\t\t\tconst sessionSpaceIdA = idDataA.id;\n\t\t\t\tconst idIndex = getOrCreate(idIndicesAggregator, idDataA.sessionId, () => 0);\n\t\t\t\toriginatingSession ??= idDataA.sessionId;\n\t\t\t\tassert(\n\t\t\t\t\tidDataA.sessionId === originatingSession,\n\t\t\t\t\t\"Test infra gave wrong originating client to TestIdData\",\n\t\t\t\t);\n\n\t\t\t\t// Only one client should have this ID as local in its session space, as only one client could have created this ID\n\t\t\t\tif (isLocalId(sessionSpaceIdA)) {\n\t\t\t\t\tif (originatingSession !== OriginatingClient.Remote) {\n\t\t\t\t\t\tassert.strictEqual(\n\t\t\t\t\t\t\tidDataA.sessionId,\n\t\t\t\t\t\t\tthis.compressors.get(idDataA.originatingClient as Client).localSessionId,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tidCreatorCount++;\n\t\t\t\t}\n\n\t\t\t\tconst uuidASessionSpace = compressorA.decompress(sessionSpaceIdA);\n\t\t\t\tassert.strictEqual(uuidASessionSpace, incrementStableId(idDataA.sessionId, idIndex));\n\t\t\t\tassert.strictEqual(compressorA.recompress(uuidASessionSpace), sessionSpaceIdA);\n\t\t\t\tuuids.add(uuidASessionSpace);\n\t\t\t\tconst opSpaceIdA = compressorA.normalizeToOpSpace(sessionSpaceIdA);\n\t\t\t\tif (!isFinalId(opSpaceIdA)) {\n\t\t\t\t\tfail(\"IDs should have been finalized.\");\n\t\t\t\t}\n\t\t\t\tconst reNormalizedIdA = compressorA.normalizeToSessionSpace(\n\t\t\t\t\topSpaceIdA,\n\t\t\t\t\tcompressorA.localSessionId,\n\t\t\t\t);\n\t\t\t\tassert.strictEqual(reNormalizedIdA, sessionSpaceIdA);\n\t\t\t\tfinalIds.add(opSpaceIdA);\n\t\t\t\tconst uuidAOpSpace = compressorA.decompress(reNormalizedIdA);\n\n\t\t\t\tassert.strictEqual(uuidASessionSpace, uuidAOpSpace);\n\n\t\t\t\tif (next !== undefined) {\n\t\t\t\t\tconst [compressorB, idDataB] = next;\n\t\t\t\t\tconst sessionSpaceIdB = idDataB.id;\n\n\t\t\t\t\tconst uuidBSessionSpace = compressorB.decompress(sessionSpaceIdB);\n\t\t\t\t\tassert.strictEqual(uuidASessionSpace, uuidBSessionSpace);\n\t\t\t\t\tconst opSpaceIdB = compressorB.normalizeToOpSpace(sessionSpaceIdB);\n\t\t\t\t\tif (opSpaceIdA !== opSpaceIdB) {\n\t\t\t\t\t\tcompressorB.normalizeToOpSpace(sessionSpaceIdB);\n\t\t\t\t\t\tcompressorA.normalizeToOpSpace(sessionSpaceIdA);\n\t\t\t\t\t}\n\t\t\t\t\tassert.strictEqual(opSpaceIdA, opSpaceIdB);\n\t\t\t\t\tif (!isFinalId(opSpaceIdB)) {\n\t\t\t\t\t\tfail(\"IDs should have been finalized.\");\n\t\t\t\t\t}\n\t\t\t\t\tconst uuidBOpSpace = compressorB.decompress(\n\t\t\t\t\t\topSpaceIdB as unknown as SessionSpaceCompressedId,\n\t\t\t\t\t);\n\t\t\t\t\tassert.strictEqual(uuidAOpSpace, uuidBOpSpace);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tassert(idCreatorCount <= 1, \"Only one client can create an ID.\");\n\t\t\tassert.strictEqual(uuids.size, finalIds.size);\n\t\t\tassert(originatingSession !== undefined, \"Expected originating client to be defined\");\n\t\t\tidIndicesAggregator.set(\n\t\t\t\toriginatingSession,\n\n\t\t\t\t(idIndicesAggregator.get(originatingSession) ??\n\t\t\t\t\tfail(\"Expected pre-existing index for originating client\")) + 1,\n\t\t\t);\n\t\t}\n\n\t\tfor (const [compressor] of sequencedLogs) {\n\t\t\texpectSerializes(compressor);\n\t\t}\n\t}\n}\n\n/**\n * Roundtrips the supplied compressor through serialization and deserialization.\n */\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: true,\n): [SerializedIdCompressorWithOngoingSession, IdCompressor];\n\n/**\n * Roundtrips the supplied compressor through serialization and deserialization.\n */\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: false,\n): [SerializedIdCompressorWithNoSession, IdCompressor];\n\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: boolean,\n): [\n\tSerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession,\n\tIdCompressor,\n] {\n\t// preserve the capacity request as this property is normally private and resets\n\t// to a default on construction (deserialization)\n\tconst capacity: number = getClusterSize(compressor);\n\tif (withSession) {\n\t\tconst serialized = compressor.serialize(withSession);\n\t\tconst roundtripped = IdCompressor.deserialize({ serialized });\n\t\tmodifyClusterSize(roundtripped, capacity);\n\t\treturn [serialized, roundtripped];\n\t} else {\n\t\tconst nonLocalSerialized = compressor.serialize(withSession);\n\t\tconst roundtripped = IdCompressor.deserialize({\n\t\t\tserialized: nonLocalSerialized,\n\t\t\tnewSessionId: createSessionId(),\n\t\t});\n\t\tmodifyClusterSize(roundtripped, capacity);\n\t\treturn [nonLocalSerialized, roundtripped];\n\t}\n}\n\n/**\n * Asserts that the supplied compressor correctly roundtrips through serialization/deserialization.\n */\nexport function expectSerializes(\n\tcompressor: ReadonlyIdCompressor,\n): [SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession] {\n\tfunction expectSerializesWithSession(\n\t\twithSession: boolean,\n\t): SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession {\n\t\tlet serialized:\n\t\t\t| SerializedIdCompressorWithOngoingSession\n\t\t\t| SerializedIdCompressorWithNoSession;\n\t\tlet deserialized: IdCompressor;\n\t\tif (withSession) {\n\t\t\t[serialized, deserialized] = roundtrip(compressor, true);\n\t\t} else {\n\t\t\t[serialized, deserialized] = roundtrip(compressor, false);\n\t\t}\n\t\tassert.strictEqual(compressor.equals(deserialized, withSession), true);\n\t\treturn serialized;\n\t}\n\n\treturn [\n\t\texpectSerializesWithSession(false) as SerializedIdCompressorWithNoSession,\n\t\texpectSerializesWithSession(true) as SerializedIdCompressorWithOngoingSession,\n\t];\n}\n\n/**\n * Merges 'from' into 'to', and returns 'to'.\n */\nexport function mergeArrayMaps<K, V>(\n\tto: Pick<Map<K, V[]>, \"get\" | \"set\">,\n\tfrom: ReadonlyMap<K, V[]>,\n): Pick<Map<K, V[]>, \"get\" | \"set\"> {\n\tfor (const [key, value] of from.entries()) {\n\t\tconst entry = to.get(key);\n\t\tif (entry === undefined) {\n\t\t\tto.set(key, [...value]);\n\t\t} else {\n\t\t\tentry.push(...value);\n\t\t}\n\t}\n\treturn to;\n}\n\ninterface AllocateIds {\n\ttype: \"allocateIds\";\n\tclient: Client;\n\tnumIds: number;\n}\n\ninterface AllocateOutsideIds {\n\ttype: \"allocateOutsideIds\";\n\tsessionId: SessionId;\n\tnumIds: number;\n}\n\ninterface DeliverAllOperations {\n\ttype: \"deliverAllOperations\";\n}\n\ninterface DeliverSomeOperations {\n\ttype: \"deliverSomeOperations\";\n\tclient: Client;\n\tcount: number;\n}\n\ninterface ChangeCapacity {\n\ttype: \"changeCapacity\";\n\tclient: Client;\n\tnewSize: number;\n}\n\n// Represents intent to go offline then resume.\ninterface Reconnect {\n\ttype: \"reconnect\";\n\tclient: Client;\n}\n\ninterface Validate {\n\ttype: \"validate\";\n}\n\ntype Operation =\n\t| AllocateIds\n\t| AllocateOutsideIds\n\t| DeliverSomeOperations\n\t| DeliverAllOperations\n\t| ChangeCapacity\n\t| Reconnect\n\t| Validate;\n\ninterface FuzzTestState extends BaseFuzzTestState {\n\tnetwork: IdCompressorTestNetwork;\n\tactiveClients: Client[];\n\tselectableClients: Client[];\n\tclusterSize: number;\n}\n\nexport interface OperationGenerationConfig {\n\t/**\n\t * maximum cluster size of the network. Default: 25\n\t */\n\tmaxClusterSize?: number;\n\t/**\n\t * Number of ops between validation ops. Default: 200\n\t */\n\tvalidateInterval?: number;\n\t/**\n\t * Fraction of ID allocations that are from an outside client (not Client1/2/3).\n\t */\n\toutsideAllocationFraction?: number;\n}\n\nconst defaultOptions = {\n\tmaxClusterSize: 25,\n\tvalidateInterval: 200,\n\toutsideAllocationFraction: 0.1,\n};\n\nexport function makeOpGenerator(\n\toptions: OperationGenerationConfig,\n): Generator<Operation, FuzzTestState> {\n\tconst { maxClusterSize, validateInterval, outsideAllocationFraction } = {\n\t\t...defaultOptions,\n\t\t...options,\n\t};\n\tassert(outsideAllocationFraction >= 0 && outsideAllocationFraction <= 1);\n\n\tfunction allocateIdsGenerator({\n\t\tactiveClients,\n\t\tclusterSize,\n\t\trandom,\n\t}: FuzzTestState): AllocateIds {\n\t\tconst client = random.pick(activeClients);\n\t\tconst maxIdsPerUsage = clusterSize * 2;\n\t\tconst numIds = Math.floor(random.real(0, 1) ** 3 * maxIdsPerUsage) + 1;\n\t\treturn {\n\t\t\ttype: \"allocateIds\",\n\t\t\tclient,\n\t\t\tnumIds,\n\t\t};\n\t}\n\n\tfunction allocateOutsideIdsGenerator({\n\t\tclusterSize,\n\t\trandom,\n\t}: FuzzTestState): AllocateOutsideIds {\n\t\tconst maxIdsPerUsage = clusterSize * 2;\n\t\tconst numIds = Math.floor(random.real(0, 1) ** 3 * maxIdsPerUsage) + 1;\n\t\treturn {\n\t\t\ttype: \"allocateOutsideIds\",\n\t\t\tsessionId: createSessionId(),\n\t\t\tnumIds,\n\t\t};\n\t}\n\n\tfunction changeCapacityGenerator({ random, activeClients }: FuzzTestState): ChangeCapacity {\n\t\treturn {\n\t\t\ttype: \"changeCapacity\",\n\t\t\tclient: random.pick(activeClients),\n\t\t\tnewSize: Math.min(\n\t\t\t\tMath.floor(random.real(0, 1) ** 2 * maxClusterSize) + 1,\n\t\t\t\tmaxClusterSize,\n\t\t\t),\n\t\t};\n\t}\n\n\tfunction deliverAllOperationsGenerator(): DeliverAllOperations {\n\t\treturn {\n\t\t\ttype: \"deliverAllOperations\",\n\t\t};\n\t}\n\n\tfunction deliverSomeOperationsGenerator({\n\t\trandom,\n\t\tselectableClients,\n\t\tnetwork,\n\t}: FuzzTestState): DeliverSomeOperations {\n\t\tconst pendingClients = selectableClients.filter(\n\t\t\t(c) => network.getPendingOperations(c) > 0,\n\t\t);\n\t\tif (pendingClients.length === 0) {\n\t\t\treturn {\n\t\t\t\ttype: \"deliverSomeOperations\",\n\t\t\t\tclient: random.pick(selectableClients),\n\t\t\t\tcount: 0,\n\t\t\t};\n\t\t}\n\t\tconst client = random.pick(pendingClients);\n\t\treturn {\n\t\t\ttype: \"deliverSomeOperations\",\n\t\t\tclient,\n\t\t\tcount: random.integer(1, network.getPendingOperations(client)),\n\t\t};\n\t}\n\n\tfunction reconnectGenerator({ activeClients, random }: FuzzTestState): Reconnect {\n\t\treturn { type: \"reconnect\", client: random.pick(activeClients) };\n\t}\n\n\tconst allocationWeight = 20;\n\treturn interleave(\n\t\tcreateWeightedGenerator<Operation, FuzzTestState>([\n\t\t\t[changeCapacityGenerator, 1],\n\t\t\t[allocateIdsGenerator, Math.round(allocationWeight * (1 - outsideAllocationFraction))],\n\t\t\t[allocateOutsideIdsGenerator, Math.round(allocationWeight * outsideAllocationFraction)],\n\t\t\t[deliverAllOperationsGenerator, 1],\n\t\t\t[deliverSomeOperationsGenerator, 6],\n\t\t\t[reconnectGenerator, 1],\n\t\t]),\n\t\ttake(1, repeat<Operation, FuzzTestState>({ type: \"validate\" })),\n\t\tvalidateInterval,\n\t);\n}\n\n/**\n * Performs random actions on a test network.\n * @param generator - the generator used to provide operations\n * @param network - the test network to test\n * @param seed - the seed for the random generation of the fuzz actions\n * @param observerClient - if provided, this client will never generate local ids\n * @param synchronizeAtEnd - if provided, all client will have all operations delivered from the server at the end of the test\n * @param validator - if provided, this callback will be invoked periodically during the fuzz test.\n */\nexport function performFuzzActions(\n\tgenerator: Generator<Operation, FuzzTestState>,\n\tnetwork: IdCompressorTestNetwork,\n\tseed: number,\n\tobserverClient?: Client,\n\tsynchronizeAtEnd: boolean = true,\n\tvalidator?: (network: IdCompressorTestNetwork) => void,\n\tsaveInfo?: SaveInfo,\n): void {\n\tconst random = makeRandom(seed);\n\tconst selectableClients: Client[] = network\n\t\t.getTargetCompressors(MetaClient.All)\n\t\t.map(([client]) => client);\n\n\tconst initialState: FuzzTestState = {\n\t\trandom,\n\t\tnetwork,\n\t\tactiveClients: selectableClients.filter((c) => c !== observerClient),\n\t\tselectableClients,\n\t\tclusterSize: network.initialClusterSize,\n\t};\n\n\tperformFuzzActionsBase(\n\t\tgenerator,\n\t\t{\n\t\t\tallocateIds: (state, { client, numIds }) => {\n\t\t\t\tnetwork.allocateAndSendIdsFromRemoteClient(client, sessionIds.get(client), numIds);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tallocateOutsideIds: (state, { sessionId, numIds }) => {\n\t\t\t\tnetwork.allocateAndSendIdsFromRemoteClient(\n\t\t\t\t\tOriginatingClient.Remote,\n\t\t\t\t\tsessionId,\n\t\t\t\t\tnumIds,\n\t\t\t\t);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tchangeCapacity: (state, op) => {\n\t\t\t\tnetwork.changeCapacity(op.client, op.newSize);\n\t\t\t\treturn { ...state, clusterSize: op.newSize };\n\t\t\t},\n\t\t\tdeliverSomeOperations: (state, op) => {\n\t\t\t\tnetwork.deliverOperations(op.client, op.count);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tdeliverAllOperations: (state) => {\n\t\t\t\tnetwork.deliverOperations(DestinationClient.All);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\treconnect: (state, { client }) => {\n\t\t\t\tnetwork.goOfflineThenResume(client);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tvalidate: (state) => {\n\t\t\t\tvalidator?.(network);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t},\n\t\tinitialState,\n\t\tsaveInfo,\n\t);\n\n\tif (synchronizeAtEnd) {\n\t\tnetwork.deliverOperations(DestinationClient.All);\n\t\tvalidator?.(network);\n\t}\n}\n\n/**\n * Helper to generate a fixed number of IDs.\n */\nexport function generateCompressedIds(\n\tcompressor: IdCompressor,\n\tcount: number,\n): SessionSpaceCompressedId[] {\n\tconst ids: SessionSpaceCompressedId[] = [];\n\tfor (let i = 0; i < count; i++) {\n\t\tids.push(compressor.generateCompressedId());\n\t}\n\treturn ids;\n}\n\n/**\n * Creates a compressor that only produces final IDs.\n * It should only be used for testing purposes.\n */\nexport function createAlwaysFinalizedIdCompressor(\n\tlogger?: ITelemetryBaseLogger,\n): IIdCompressor & IIdCompressorCore;\n/**\n * Creates a compressor that only produces final IDs.\n * It should only be used for testing purposes.\n */\nexport function createAlwaysFinalizedIdCompressor(\n\tsessionId: SessionId,\n\tlogger?: ITelemetryBaseLogger,\n\tseed?: number,\n): IIdCompressor & IIdCompressorCore;\nexport function createAlwaysFinalizedIdCompressor(\n\tsessionIdOrLogger?: SessionId | ITelemetryBaseLogger,\n\tloggerOrUndefined?: ITelemetryBaseLogger,\n\tseed?: number,\n): IIdCompressor & IIdCompressorCore {\n\tconst random = seed === undefined ? makeRandom() : makeRandom(seed);\n\tconst sessionId =\n\t\ttypeof sessionIdOrLogger === \"string\" ? sessionIdOrLogger : (random.uuid4() as SessionId);\n\tconst logger =\n\t\t(loggerOrUndefined ?? typeof sessionIdOrLogger === \"object\")\n\t\t\t? (sessionIdOrLogger as ITelemetryBaseLogger)\n\t\t\t: undefined;\n\t// This local session is unused, but it needs to not collide with the GhostSession, so allocate a random one.\n\t// This causes the compressor to serialize non-deterministically even when provided an explicit SessionId.\n\t// This can be fixed in the future if needed.\n\tconst compressor = createIdCompressor(random.uuid4() as SessionId, logger);\n\t// Permanently put the compressor in a ghost session\n\t(compressor as IdCompressor).startGhostSession(sessionId);\n\treturn compressor;\n}\n"]}
1
+ {"version":3,"file":"idCompressorTestUtilities.js","sourceRoot":"","sources":["../../src/test/idCompressorTestUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAE/C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D,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC;IACtB,CAAC;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACpC,UAAwB,EACxB,KAAa;IAEb,MAAM,GAAG,GAA+B,EAAE,CAAC;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAkBD,MAAM,UAAU,iCAAiC,CAChD,iBAAoD,EACpD,iBAAwC,EACxC,IAAa;IAEb,MAAM,MAAM,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACpE,MAAM,SAAS,GACd,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAE,MAAM,CAAC,KAAK,EAAgB,CAAC;IAC3F,MAAM,MAAM,GACX,CAAC,iBAAiB,IAAI,OAAO,iBAAiB,KAAK,QAAQ,CAAC;QAC3D,CAAC,CAAE,iBAA0C;QAC7C,CAAC,CAAC,SAAS,CAAC;IACd,6GAA6G;IAC7G,0GAA0G;IAC1G,6CAA6C;IAC7C,MAAM,UAAU,GAAG,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAe,EAAE,MAAM,CAAC,CAAC;IAC3E,oDAAoD;IACnD,UAA2B,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC1D,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\n\nimport {\n\ttype BaseFuzzTestState,\n\ttype Generator,\n\ttype SaveInfo,\n\tcreateWeightedGenerator,\n\tinterleave,\n\tmakeRandom,\n\tperformFuzzActions as performFuzzActionsBase,\n\trepeat,\n\ttake,\n} from \"@fluid-private/stochastic-test-utils\";\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\n\nimport { IdCompressor } from \"../idCompressor.js\";\nimport {\n\ttype IIdCompressor,\n\ttype IIdCompressorCore,\n\ttype IdCreationRange,\n\ttype OpSpaceCompressedId,\n\ttype SerializedIdCompressorWithNoSession,\n\ttype SerializedIdCompressorWithOngoingSession,\n\ttype SessionId,\n\ttype SessionSpaceCompressedId,\n\ttype StableId,\n\tcreateIdCompressor,\n} from \"../index.js\";\nimport { SessionSpaceNormalizer } from \"../sessionSpaceNormalizer.js\";\nimport { assertIsSessionId, createSessionId, localIdFromGenCount } from \"../utilities.js\";\n\nimport {\n\ttype FinalCompressedId,\n\ttype ReadonlyIdCompressor,\n\tfail,\n\tgetOrCreate,\n\tincrementStableId,\n\tisFinalId,\n\tisLocalId,\n} from \"./testCommon.js\";\n\n/**\n * A readonly `Map` which is known to contain a value for every possible key\n */\nexport interface ClosedMap<K, V> extends Omit<Map<K, V>, \"delete\" | \"clear\"> {\n\tget(key: K): V;\n}\n\n/**\n * Identifies a compressor in a network\n */\nexport enum Client {\n\tClient1 = \"Client1\",\n\tClient2 = \"Client2\",\n\tClient3 = \"Client3\",\n}\n\n/**\n * Identifies categories of compressors\n */\nexport enum MetaClient {\n\tAll = \"All\",\n}\n\n/**\n * Identifies a compressor inside the network but outside the three specially tracked clients.\n */\nexport enum OutsideClient {\n\tRemote = \"Remote\",\n}\n\n/**\n * Used to attribute actions to clients in a distributed collaboration session.\n * `Local` implies a local and unsequenced operation. All others imply sequenced operations.\n */\nexport type OriginatingClient = Client | OutsideClient;\nexport const OriginatingClient = { ...Client, ...OutsideClient };\n\n/**\n * Identifies a compressor to which to send an operation\n */\nexport type DestinationClient = Client | MetaClient;\nexport const DestinationClient = { ...Client, ...MetaClient };\n\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport class CompressorFactory {\n\t/**\n\t * Creates a new compressor with the supplied cluster capacity.\n\t */\n\tpublic static createCompressor(\n\t\tclient: Client,\n\t\tclusterCapacity = 5,\n\t\tlogger?: ITelemetryBaseLogger,\n\t): IdCompressor {\n\t\treturn CompressorFactory.createCompressorWithSession(\n\t\t\tsessionIds.get(client),\n\t\t\tclusterCapacity,\n\t\t\tlogger,\n\t\t);\n\t}\n\n\t/**\n\t * Creates a new compressor with the supplied cluster capacity.\n\t */\n\tpublic static createCompressorWithSession(\n\t\tsessionId: SessionId,\n\t\tclusterCapacity = 5,\n\t\tlogger?: ITelemetryBaseLogger,\n\t): IdCompressor {\n\t\tconst compressor = createIdCompressor(sessionId, logger) as IdCompressor;\n\t\tmodifyClusterSize(compressor, clusterCapacity);\n\t\treturn compressor;\n\t}\n}\n\n/**\n * Modify the requested cluster size of the provided compressor.\n * @remarks\n * This is useful for testing purposes for a few reasons:\n * - Id compressor bugs are often related to edge cases that occur on cluster boundaries\n * - Smaller cluster sizes can enable writing tests without for loops generating \"ids until a new cluster is created\"\n */\nexport function modifyClusterSize(compressor: IIdCompressor, newClusterSize: number): void {\n\tverifyCompressorLike(compressor);\n\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\tcompressor[\"nextRequestedClusterSize\"] = newClusterSize;\n}\n\n/**\n * Returns the current cluster size of the compressor.\n * @privateRemarks\n * This is useful in writing tests to avoid having to hardcode the (currently constant) cluster size.\n */\nexport function getClusterSize(compressor: ReadonlyIdCompressor): number {\n\tverifyCompressorLike(compressor);\n\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\treturn compressor[\"nextRequestedClusterSize\"] as number;\n}\n\nfunction verifyCompressorLike(compressor: ReadonlyIdCompressor | IIdCompressor): void {\n\tassert(\n\t\t// Some IdCompressor tests wrap underlying compressors with proxies--allow this for now.\n\t\t// Because of id-compressor's dynamic import in container-runtime, instanceof checks for IdCompressor\n\t\t// also won't necessarily work nicely. Get a small amount of validation that this function should work\n\t\t// as intended by at least verifying the property name exists.\n\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\ttypeof compressor[\"nextRequestedClusterSize\"] === \"number\",\n\t);\n}\n\n/**\n * Utility for building a huge compressor.\n * Build via the compressor factory.\n */\nexport function buildHugeCompressor(\n\tnumSessions = 10000,\n\tcapacity = 10,\n\tnumClustersPerSession = 3,\n): IdCompressor {\n\tconst compressor = CompressorFactory.createCompressorWithSession(\n\t\tcreateSessionId(),\n\t\tcapacity,\n\t);\n\tconst sessions: SessionId[] = [];\n\tfor (let i = 0; i < numSessions; i++) {\n\t\tsessions.push(createSessionId());\n\t}\n\tfor (let i = 0; i < numSessions * numClustersPerSession; i++) {\n\t\tconst sessionId = sessions[i % numSessions];\n\t\tif (Math.random() > 0.1) {\n\t\t\tfor (let j = 0; j < Math.round(capacity / 2); j++) {\n\t\t\t\tcompressor.generateCompressedId();\n\t\t\t}\n\t\t\tcompressor.finalizeCreationRange(compressor.takeNextCreationRange());\n\t\t}\n\t\tcompressor.finalizeCreationRange({\n\t\t\tsessionId,\n\t\t\tids: {\n\t\t\t\tfirstGenCount: Math.floor(i / numSessions) * capacity + 1,\n\t\t\t\tcount: capacity,\n\t\t\t\trequestedClusterSize: capacity,\n\t\t\t\tlocalIdRanges: [], // remote session, can safely ignore in tests\n\t\t\t},\n\t\t});\n\t}\n\treturn compressor;\n}\n\n/**\n * A closed map from NamedClient to T.\n */\nexport type ClientMap<T> = ClosedMap<Client, T>;\n\nfunction makeSessionIds(): ClientMap<SessionId> {\n\tconst stableIds = new Map<Client, SessionId>();\n\tconst clients = Object.values(Client);\n\tfor (let i = 0; i < clients.length; i++) {\n\t\t// Place session uuids roughly in the middle of uuid space to increase odds of encountering interesting\n\t\t// orderings in sorted collections\n\t\tconst sessionId = assertIsSessionId(`88888888-8888-4888-b${i}88-888888888888`);\n\t\tstableIds.set(clients[i], sessionId);\n\t}\n\treturn stableIds as ClientMap<SessionId>;\n}\n\n/**\n * An array of session ID strings corresponding to all non-local `Client` entries.\n */\nexport const sessionIds = makeSessionIds();\n\n/**\n * Information about a generated ID in a network to be validated by tests\n */\nexport interface TestIdData {\n\treadonly id: SessionSpaceCompressedId;\n\treadonly originatingClient: OriginatingClient;\n\treadonly sessionId: SessionId;\n\treadonly isSequenced: boolean;\n}\n\n/**\n * Simulates a network of ID compressors.\n * Not suitable for performance testing.\n */\nexport class IdCompressorTestNetwork {\n\t/**\n\t * The compressors used in this network\n\t */\n\tprivate readonly compressors: ClientMap<IdCompressor>;\n\t/**\n\t * The log of operations seen by the server so far. Append-only.\n\t */\n\tprivate readonly serverOperations: [\n\t\tcreationRange: IdCreationRange,\n\t\topSpaceIds: OpSpaceCompressedId[],\n\t\tclientFrom: OriginatingClient,\n\t\tsessionIdFrom: SessionId,\n\t][] = [];\n\t/**\n\t * An index into `serverOperations` for each client which represents how many operations have been delivered to that client\n\t */\n\tprivate readonly clientProgress: ClientMap<number>;\n\t/**\n\t * All ids (local and sequenced) that a client has created or received, in order.\n\t */\n\tprivate readonly idLogs: ClientMap<TestIdData[]>;\n\t/**\n\t * All ids that a client has received from the server, in order.\n\t */\n\tprivate readonly sequencedIdLogs: ClientMap<TestIdData[]>;\n\n\tpublic constructor(public readonly initialClusterSize = 5) {\n\t\tconst compressors = new Map<Client, IdCompressor>();\n\t\tconst clientProgress = new Map<Client, number>();\n\t\tconst clientIds = new Map<Client, TestIdData[]>();\n\t\tconst clientSequencedIds = new Map<Client, TestIdData[]>();\n\t\tfor (const client of Object.values(Client)) {\n\t\t\tconst compressor = CompressorFactory.createCompressor(client, initialClusterSize);\n\t\t\tcompressors.set(client, compressor);\n\t\t\tclientProgress.set(client, 0);\n\t\t\tclientIds.set(client, []);\n\t\t\tclientSequencedIds.set(client, []);\n\t\t}\n\t\tthis.compressors = compressors as ClientMap<IdCompressor>;\n\t\tthis.clientProgress = clientProgress as ClientMap<number>;\n\t\tthis.idLogs = clientIds as ClientMap<TestIdData[]>;\n\t\tthis.sequencedIdLogs = clientSequencedIds as ClientMap<TestIdData[]>;\n\t}\n\n\t/**\n\t * Returns the number of undelivered operations for the given client that are in flight in the network.\n\t */\n\tpublic getPendingOperations(destination: Client): number {\n\t\treturn this.serverOperations.length - this.clientProgress.get(destination);\n\t}\n\n\t/**\n\t * Returns an immutable handle to a compressor in the network.\n\t */\n\tpublic getCompressor(client: Client): ReadonlyIdCompressor {\n\t\tconst compressors = this.compressors;\n\t\tconst handler = {\n\t\t\tget<P extends keyof IdCompressor>(_: unknown, property: P): IdCompressor[P] {\n\t\t\t\treturn compressors.get(client)[property];\n\t\t\t},\n\t\t\tset<P extends keyof IdCompressor>(\n\t\t\t\t_: unknown,\n\t\t\t\tproperty: P,\n\t\t\t\tvalue: IdCompressor[P],\n\t\t\t): boolean {\n\t\t\t\tcompressors.get(client)[property] = value;\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\t\treturn new Proxy<IdCompressor>({} as unknown as IdCompressor, handler);\n\t}\n\n\t/**\n\t * Returns a mutable handle to a compressor in the network. Use of mutation methods will break the network invariants and\n\t * should only be used if the network will not be used again.\n\t */\n\tpublic getCompressorUnsafe(client: Client): IdCompressor {\n\t\treturn this.getCompressor(client) as IdCompressor;\n\t}\n\n\t/**\n\t * Returns a mutable handle to a compressor in the network. Use of mutation methods will break the network invariants and\n\t * should only be used if the network will not be used again. Additionally, the returned compressor will be invalidated/unusable\n\t * if any network operations cause it to be regenerated (serialization/deserialization, etc.).\n\t */\n\tpublic getCompressorUnsafeNoProxy(client: Client): IdCompressor {\n\t\treturn this.compressors.get(client);\n\t}\n\n\t/**\n\t * Returns data for all IDs created and received by this client, including ack's of their own (i.e. their own IDs will appear twice)\n\t */\n\tpublic getIdLog(client: Client): readonly TestIdData[] {\n\t\treturn this.idLogs.get(client);\n\t}\n\n\t/**\n\t * Returns data for all IDs received by this client, including ack's of their own.\n\t */\n\tpublic getSequencedIdLog(client: Client): readonly TestIdData[] {\n\t\treturn this.sequencedIdLogs.get(client);\n\t}\n\n\t/**\n\t * Get all compressors for the given destination\n\t */\n\tpublic getTargetCompressors(clientTo: DestinationClient): [Client, IdCompressor][] {\n\t\treturn clientTo === MetaClient.All\n\t\t\t? [...this.compressors.entries()]\n\t\t\t: ([[clientTo, this.getCompressor(clientTo)]] as [Client, IdCompressor][]);\n\t}\n\n\t/**\n\t * Changes the capacity request amount for a client. It will take effect immediately.\n\t */\n\tpublic changeCapacity(client: Client, newClusterCapacity: number): void {\n\t\tmodifyClusterSize(this.compressors.get(client), newClusterCapacity);\n\t}\n\n\tprivate addNewId(\n\t\tclient: Client,\n\t\tid: SessionSpaceCompressedId,\n\t\toriginatingClient: OriginatingClient,\n\t\tsessionIdFrom: SessionId,\n\t\tisSequenced: boolean,\n\t): void {\n\t\tconst idData = {\n\t\t\tid,\n\t\t\toriginatingClient,\n\t\t\tsessionId: sessionIdFrom,\n\t\t\tisSequenced,\n\t\t};\n\t\tconst clientIds = this.idLogs.get(client);\n\t\tclientIds.push(idData);\n\t\tif (isSequenced) {\n\t\t\tconst sequencedIds = this.sequencedIdLogs.get(client);\n\t\t\tsequencedIds.push(idData);\n\t\t}\n\t}\n\n\t/**\n\t * Allocates a new range of local IDs and enqueues them for future delivery via a `testIdDelivery` action.\n\t * Calls to this method determine the total order of delivery, regardless of when `deliverOperations` is called.\n\t */\n\tpublic allocateAndSendIds(clientFrom: Client, numIds: number): OpSpaceCompressedId[] {\n\t\treturn this.allocateAndSendIdsFromRemoteClient(\n\t\t\tclientFrom,\n\t\t\tsessionIds.get(clientFrom),\n\t\t\tnumIds,\n\t\t);\n\t}\n\n\t/**\n\t * Same contract as `allocateAndSendIds`, but the originating client will be a client with the supplied sessionId.\n\t */\n\tpublic allocateAndSendIdsFromRemoteClient(\n\t\tclientFrom: OriginatingClient,\n\t\tsessionIdFrom: SessionId,\n\t\tnumIds: number,\n\t): OpSpaceCompressedId[] {\n\t\tassert(numIds > 0, \"Must allocate a non-zero number of IDs\");\n\t\tif (clientFrom === OriginatingClient.Remote) {\n\t\t\tconst range: IdCreationRange = {\n\t\t\t\tsessionId: sessionIdFrom,\n\t\t\t\tids: {\n\t\t\t\t\tfirstGenCount: 1,\n\t\t\t\t\tcount: numIds,\n\t\t\t\t\trequestedClusterSize: getClusterSize(this.getCompressor(Client.Client1)),\n\t\t\t\t\tlocalIdRanges: [], // remote session, can safely ignore in tests\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst opSpaceIds: OpSpaceCompressedId[] = [];\n\t\t\tfor (let i = 0; i < numIds; i++) {\n\t\t\t\topSpaceIds.push(-(i + 1) as OpSpaceCompressedId);\n\t\t\t}\n\t\t\tthis.serverOperations.push([range, opSpaceIds, clientFrom, sessionIdFrom]);\n\t\t\treturn opSpaceIds;\n\t\t} else {\n\t\t\tassert(sessionIdFrom === sessionIds.get(clientFrom));\n\t\t\tconst compressor = this.compressors.get(clientFrom);\n\t\t\tconst sessionSpaceIds = generateCompressedIds(compressor, numIds);\n\t\t\tfor (let i = 0; i < numIds; i++) {\n\t\t\t\tthis.addNewId(clientFrom, sessionSpaceIds[i], clientFrom, sessionIdFrom, false);\n\t\t\t}\n\t\t\tconst opSpaceIds = sessionSpaceIds.map((id) => compressor.normalizeToOpSpace(id));\n\t\t\tconst creationRange = compressor.takeNextCreationRange();\n\t\t\tthis.serverOperations.push([creationRange, opSpaceIds, clientFrom, sessionIdFrom]);\n\t\t\treturn opSpaceIds;\n\t\t}\n\t}\n\n\t/**\n\t * Delivers all undelivered ID ranges from the server to the target clients.\n\t */\n\tpublic deliverOperations(clientTakingDelivery: Client, opsToDeliver?: number): void;\n\n\t/**\n\t * Delivers all undelivered ID ranges from the server to the target clients.\n\t */\n\tpublic deliverOperations(clientTakingDelivery: DestinationClient): void;\n\n\t/**\n\t * Delivers all undelivered ID ranges from the server to the target clients.\n\t */\n\tpublic deliverOperations(\n\t\tclientTakingDelivery: DestinationClient,\n\t\topsToDeliver?: number,\n\t): void {\n\t\tlet opIndexBound: number;\n\t\tif (clientTakingDelivery === DestinationClient.All) {\n\t\t\tassert(opsToDeliver === undefined);\n\t\t\topIndexBound = this.serverOperations.length;\n\t\t} else {\n\t\t\topIndexBound =\n\t\t\t\topsToDeliver === undefined\n\t\t\t\t\t? this.serverOperations.length\n\t\t\t\t\t: this.clientProgress.get(clientTakingDelivery) + opsToDeliver;\n\t\t}\n\t\tfor (const [clientTo, compressorTo] of this.getTargetCompressors(clientTakingDelivery)) {\n\t\t\tfor (let i = this.clientProgress.get(clientTo); i < opIndexBound; i++) {\n\t\t\t\tconst [range, opSpaceIds, clientFrom, sessionIdFrom] = this.serverOperations[i];\n\t\t\t\tcompressorTo.finalizeCreationRange(range);\n\n\t\t\t\tconst ids = range.ids;\n\t\t\t\tif (ids !== undefined) {\n\t\t\t\t\tfor (const id of opSpaceIds) {\n\t\t\t\t\t\tconst sessionSpaceId = compressorTo.normalizeToSessionSpace(id, range.sessionId);\n\t\t\t\t\t\tthis.addNewId(clientTo, sessionSpaceId, clientFrom, sessionIdFrom, true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.clientProgress.set(clientTo, opIndexBound);\n\t\t}\n\t}\n\n\t/**\n\t * Simulate a client disconnecting (and serializing), then reconnecting (and deserializing)\n\t */\n\tpublic goOfflineThenResume(client: Client): void {\n\t\tconst compressor = this.compressors.get(client);\n\t\tconst [_, resumedCompressor] = roundtrip(compressor, true);\n\t\tthis.compressors.set(client, resumedCompressor);\n\t}\n\n\t/**\n\t * Ensure general validity of the network state. Useful for calling periodically or at the end of test scenarios.\n\t */\n\tpublic assertNetworkState(): void {\n\t\tconst sequencedLogs = Object.values(Client).map(\n\t\t\t(client) => [this.compressors.get(client), this.getSequencedIdLog(client)] as const,\n\t\t);\n\n\t\tconst getLocalIdsInRange = (\n\t\t\trange: IdCreationRange,\n\t\t\topSpaceIds?: OpSpaceCompressedId[],\n\t\t): Set<SessionSpaceCompressedId> => {\n\t\t\tconst localIdsInCreationRange = new Set<SessionSpaceCompressedId>();\n\t\t\tconst ids = range.ids;\n\t\t\tif (ids !== undefined) {\n\t\t\t\tconst { firstGenCount, localIdRanges } = ids;\n\t\t\t\tfor (const [genCount, count] of localIdRanges) {\n\t\t\t\t\tfor (let g = genCount; g < genCount + count; g++) {\n\t\t\t\t\t\tconst local = localIdFromGenCount(g);\n\t\t\t\t\t\tif (opSpaceIds) {\n\t\t\t\t\t\t\tassert.strictEqual(opSpaceIds[g - firstGenCount], local);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlocalIdsInCreationRange.add(local);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn localIdsInCreationRange;\n\t\t};\n\n\t\t// Ensure creation ranges for clients we track contain the correct local ID ranges\n\t\tfor (const [range, opSpaceIds, clientFrom] of this.serverOperations) {\n\t\t\tif (clientFrom !== OriginatingClient.Remote) {\n\t\t\t\tconst localIdsInCreationRange = getLocalIdsInRange(range, opSpaceIds);\n\t\t\t\tlet localCount = 0;\n\t\t\t\tfor (const id of opSpaceIds) {\n\t\t\t\t\tif (isLocalId(id)) {\n\t\t\t\t\t\tlocalCount++;\n\t\t\t\t\t\tassert(localIdsInCreationRange.has(id), \"Local ID not in creation range\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\tlocalCount,\n\t\t\t\t\tlocalIdsInCreationRange.size,\n\t\t\t\t\t\"Local ID count mismatch\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst undeliveredRanges = new Map<Client, IdCreationRange[]>();\n\t\tfor (const [client, progress] of this.clientProgress.entries()) {\n\t\t\tconst ranges = this.serverOperations\n\t\t\t\t.slice(progress)\n\t\t\t\t.filter((op) => op[2] === client)\n\t\t\t\t.map(([range]) => range);\n\t\t\tundeliveredRanges.set(client, ranges);\n\t\t}\n\t\tfor (const [client, ranges] of undeliveredRanges.entries()) {\n\t\t\tconst compressor = this.compressors.get(client);\n\t\t\tlet firstGenCount: number | undefined;\n\t\t\tlet totalCount = 0;\n\t\t\tconst unionedLocalRanges = new SessionSpaceNormalizer();\n\t\t\tfor (const range of ranges) {\n\t\t\t\tassert(range.sessionId === compressor.localSessionId);\n\t\t\t\tif (range.ids !== undefined) {\n\t\t\t\t\t// initialize firstGenCount if not set\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\t\t\t\t\tif (firstGenCount === undefined) {\n\t\t\t\t\t\tfirstGenCount = range.ids.firstGenCount;\n\t\t\t\t\t}\n\t\t\t\t\ttotalCount += range.ids.count;\n\t\t\t\t\tfor (const [genCount, count] of range.ids.localIdRanges) {\n\t\t\t\t\t\tunionedLocalRanges.addLocalRange(genCount, count);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst retakenRange = compressor.takeUnfinalizedCreationRange();\n\t\t\tif (retakenRange.ids === undefined) {\n\t\t\t\tassert.strictEqual(totalCount, 0);\n\t\t\t\tassert.strictEqual(unionedLocalRanges.idRanges.size, 0);\n\t\t\t} else {\n\t\t\t\tconst retakenLocalIds = new SessionSpaceNormalizer();\n\t\t\t\tfor (const [genCount, count] of retakenRange.ids.localIdRanges) {\n\t\t\t\t\tretakenLocalIds.addLocalRange(genCount, count);\n\t\t\t\t}\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\tretakenLocalIds.equals(unionedLocalRanges),\n\t\t\t\t\ttrue,\n\t\t\t\t\t\"Local ID ranges mismatch\",\n\t\t\t\t);\n\t\t\t\tassert.strictEqual(retakenRange.ids.count, totalCount, \"Count mismatch\");\n\t\t\t\tassert.strictEqual(retakenRange.ids.firstGenCount, firstGenCount, \"Count mismatch\");\n\t\t\t}\n\t\t}\n\n\t\t// First, ensure all clients each generated a unique ID for each of their own calls to generate.\n\t\tfor (const [compressor, ids] of sequencedLogs) {\n\t\t\tconst allUuids = new Set<StableId | string>();\n\t\t\tfor (const idData of ids) {\n\t\t\t\tconst uuid = compressor.decompress(idData.id);\n\t\t\t\tassert.strictEqual(!allUuids.has(uuid), true, \"Duplicate UUID generated.\");\n\t\t\t\tallUuids.add(uuid);\n\t\t\t}\n\t\t}\n\n\t\tconst maxLogLength = sequencedLogs\n\t\t\t.map(([_, data]) => data.length)\n\t\t\t// eslint-disable-next-line unicorn/no-array-reduce\n\t\t\t.reduce((p, n) => Math.max(p, n));\n\n\t\tfunction getNextLogWithEntryAt(logsIndex: number, entryIndex: number): number | undefined {\n\t\t\tfor (let i = logsIndex; i < sequencedLogs.length; i++) {\n\t\t\t\tconst log = sequencedLogs[i];\n\t\t\t\tif (log[1].length > entryIndex) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst uuids = new Set<StableId>();\n\t\tconst finalIds = new Set<FinalCompressedId>();\n\t\tconst idIndicesAggregator = new Map<SessionId, number>();\n\n\t\tfunction* getIdLogEntries(\n\t\t\tcolumnIndex: number,\n\t\t): Iterable<\n\t\t\t[\n\t\t\t\tcurrent: [compressor: IdCompressor, idData: TestIdData],\n\t\t\t\tnext?: [compressor: IdCompressor, idData: TestIdData],\n\t\t\t]\n\t\t> {\n\t\t\tlet current = getNextLogWithEntryAt(0, columnIndex);\n\t\t\twhile (current !== undefined) {\n\t\t\t\tconst next = getNextLogWithEntryAt(current + 1, columnIndex);\n\t\t\t\tconst [compressor, log] = sequencedLogs[current];\n\t\t\t\tif (next === undefined) {\n\t\t\t\t\tyield [[compressor, log[columnIndex]]];\n\t\t\t\t} else {\n\t\t\t\t\tconst [compressorNext, logNext] = sequencedLogs[next];\n\t\t\t\t\tyield [\n\t\t\t\t\t\t[compressor, log[columnIndex]],\n\t\t\t\t\t\t[compressorNext, logNext[columnIndex]],\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\tcurrent = next;\n\t\t\t}\n\t\t}\n\n\t\tfor (let i = 0; i < maxLogLength; i++) {\n\t\t\tlet idCreatorCount = 0;\n\t\t\tlet originatingSession: SessionId | undefined;\n\t\t\tfor (const [current, next] of getIdLogEntries(i)) {\n\t\t\t\tconst [compressorA, idDataA] = current;\n\t\t\t\tconst sessionSpaceIdA = idDataA.id;\n\t\t\t\tconst idIndex = getOrCreate(idIndicesAggregator, idDataA.sessionId, () => 0);\n\t\t\t\toriginatingSession ??= idDataA.sessionId;\n\t\t\t\tassert(\n\t\t\t\t\tidDataA.sessionId === originatingSession,\n\t\t\t\t\t\"Test infra gave wrong originating client to TestIdData\",\n\t\t\t\t);\n\n\t\t\t\t// Only one client should have this ID as local in its session space, as only one client could have created this ID\n\t\t\t\tif (isLocalId(sessionSpaceIdA)) {\n\t\t\t\t\tif (originatingSession !== OriginatingClient.Remote) {\n\t\t\t\t\t\tassert.strictEqual(\n\t\t\t\t\t\t\tidDataA.sessionId,\n\t\t\t\t\t\t\tthis.compressors.get(idDataA.originatingClient as Client).localSessionId,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tidCreatorCount++;\n\t\t\t\t}\n\n\t\t\t\tconst uuidASessionSpace = compressorA.decompress(sessionSpaceIdA);\n\t\t\t\tassert.strictEqual(uuidASessionSpace, incrementStableId(idDataA.sessionId, idIndex));\n\t\t\t\tassert.strictEqual(compressorA.recompress(uuidASessionSpace), sessionSpaceIdA);\n\t\t\t\tuuids.add(uuidASessionSpace);\n\t\t\t\tconst opSpaceIdA = compressorA.normalizeToOpSpace(sessionSpaceIdA);\n\t\t\t\tif (!isFinalId(opSpaceIdA)) {\n\t\t\t\t\tfail(\"IDs should have been finalized.\");\n\t\t\t\t}\n\t\t\t\tconst reNormalizedIdA = compressorA.normalizeToSessionSpace(\n\t\t\t\t\topSpaceIdA,\n\t\t\t\t\tcompressorA.localSessionId,\n\t\t\t\t);\n\t\t\t\tassert.strictEqual(reNormalizedIdA, sessionSpaceIdA);\n\t\t\t\tfinalIds.add(opSpaceIdA);\n\t\t\t\tconst uuidAOpSpace = compressorA.decompress(reNormalizedIdA);\n\n\t\t\t\tassert.strictEqual(uuidASessionSpace, uuidAOpSpace);\n\n\t\t\t\tif (next !== undefined) {\n\t\t\t\t\tconst [compressorB, idDataB] = next;\n\t\t\t\t\tconst sessionSpaceIdB = idDataB.id;\n\n\t\t\t\t\tconst uuidBSessionSpace = compressorB.decompress(sessionSpaceIdB);\n\t\t\t\t\tassert.strictEqual(uuidASessionSpace, uuidBSessionSpace);\n\t\t\t\t\tconst opSpaceIdB = compressorB.normalizeToOpSpace(sessionSpaceIdB);\n\t\t\t\t\tif (opSpaceIdA !== opSpaceIdB) {\n\t\t\t\t\t\tcompressorB.normalizeToOpSpace(sessionSpaceIdB);\n\t\t\t\t\t\tcompressorA.normalizeToOpSpace(sessionSpaceIdA);\n\t\t\t\t\t}\n\t\t\t\t\tassert.strictEqual(opSpaceIdA, opSpaceIdB);\n\t\t\t\t\tif (!isFinalId(opSpaceIdB)) {\n\t\t\t\t\t\tfail(\"IDs should have been finalized.\");\n\t\t\t\t\t}\n\t\t\t\t\tconst uuidBOpSpace = compressorB.decompress(\n\t\t\t\t\t\topSpaceIdB as unknown as SessionSpaceCompressedId,\n\t\t\t\t\t);\n\t\t\t\t\tassert.strictEqual(uuidAOpSpace, uuidBOpSpace);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tassert(idCreatorCount <= 1, \"Only one client can create an ID.\");\n\t\t\tassert.strictEqual(uuids.size, finalIds.size);\n\t\t\tassert(originatingSession !== undefined, \"Expected originating client to be defined\");\n\t\t\tidIndicesAggregator.set(\n\t\t\t\toriginatingSession,\n\n\t\t\t\t(idIndicesAggregator.get(originatingSession) ??\n\t\t\t\t\tfail(\"Expected pre-existing index for originating client\")) + 1,\n\t\t\t);\n\t\t}\n\n\t\tfor (const [compressor] of sequencedLogs) {\n\t\t\texpectSerializes(compressor);\n\t\t}\n\t}\n}\n\n/**\n * Roundtrips the supplied compressor through serialization and deserialization.\n */\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: true,\n): [SerializedIdCompressorWithOngoingSession, IdCompressor];\n\n/**\n * Roundtrips the supplied compressor through serialization and deserialization.\n */\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: false,\n): [SerializedIdCompressorWithNoSession, IdCompressor];\n\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: boolean,\n): [\n\tSerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession,\n\tIdCompressor,\n] {\n\t// preserve the capacity request as this property is normally private and resets\n\t// to a default on construction (deserialization)\n\tconst capacity: number = getClusterSize(compressor);\n\tif (withSession) {\n\t\tconst serialized = compressor.serialize(withSession);\n\t\tconst roundtripped = IdCompressor.deserialize({ serialized });\n\t\tmodifyClusterSize(roundtripped, capacity);\n\t\treturn [serialized, roundtripped];\n\t} else {\n\t\tconst nonLocalSerialized = compressor.serialize(withSession);\n\t\tconst roundtripped = IdCompressor.deserialize({\n\t\t\tserialized: nonLocalSerialized,\n\t\t\tnewSessionId: createSessionId(),\n\t\t});\n\t\tmodifyClusterSize(roundtripped, capacity);\n\t\treturn [nonLocalSerialized, roundtripped];\n\t}\n}\n\n/**\n * Asserts that the supplied compressor correctly roundtrips through serialization/deserialization.\n */\nexport function expectSerializes(\n\tcompressor: ReadonlyIdCompressor,\n): [SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession] {\n\tfunction expectSerializesWithSession(\n\t\twithSession: boolean,\n\t): SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession {\n\t\tlet serialized:\n\t\t\t| SerializedIdCompressorWithOngoingSession\n\t\t\t| SerializedIdCompressorWithNoSession;\n\t\tlet deserialized: IdCompressor;\n\t\tif (withSession) {\n\t\t\t[serialized, deserialized] = roundtrip(compressor, true);\n\t\t} else {\n\t\t\t[serialized, deserialized] = roundtrip(compressor, false);\n\t\t}\n\t\tassert.strictEqual(compressor.equals(deserialized, withSession), true);\n\t\treturn serialized;\n\t}\n\n\treturn [\n\t\texpectSerializesWithSession(false) as SerializedIdCompressorWithNoSession,\n\t\texpectSerializesWithSession(true) as SerializedIdCompressorWithOngoingSession,\n\t];\n}\n\n/**\n * Merges 'from' into 'to', and returns 'to'.\n */\nexport function mergeArrayMaps<K, V>(\n\tto: Pick<Map<K, V[]>, \"get\" | \"set\">,\n\tfrom: ReadonlyMap<K, V[]>,\n): Pick<Map<K, V[]>, \"get\" | \"set\"> {\n\tfor (const [key, value] of from.entries()) {\n\t\tconst entry = to.get(key);\n\t\tif (entry === undefined) {\n\t\t\tto.set(key, [...value]);\n\t\t} else {\n\t\t\tentry.push(...value);\n\t\t}\n\t}\n\treturn to;\n}\n\ninterface AllocateIds {\n\ttype: \"allocateIds\";\n\tclient: Client;\n\tnumIds: number;\n}\n\ninterface AllocateOutsideIds {\n\ttype: \"allocateOutsideIds\";\n\tsessionId: SessionId;\n\tnumIds: number;\n}\n\ninterface DeliverAllOperations {\n\ttype: \"deliverAllOperations\";\n}\n\ninterface DeliverSomeOperations {\n\ttype: \"deliverSomeOperations\";\n\tclient: Client;\n\tcount: number;\n}\n\ninterface ChangeCapacity {\n\ttype: \"changeCapacity\";\n\tclient: Client;\n\tnewSize: number;\n}\n\n// Represents intent to go offline then resume.\ninterface Reconnect {\n\ttype: \"reconnect\";\n\tclient: Client;\n}\n\ninterface Validate {\n\ttype: \"validate\";\n}\n\ntype Operation =\n\t| AllocateIds\n\t| AllocateOutsideIds\n\t| DeliverSomeOperations\n\t| DeliverAllOperations\n\t| ChangeCapacity\n\t| Reconnect\n\t| Validate;\n\ninterface FuzzTestState extends BaseFuzzTestState {\n\tnetwork: IdCompressorTestNetwork;\n\tactiveClients: Client[];\n\tselectableClients: Client[];\n\tclusterSize: number;\n}\n\nexport interface OperationGenerationConfig {\n\t/**\n\t * maximum cluster size of the network. Default: 25\n\t */\n\tmaxClusterSize?: number;\n\t/**\n\t * Number of ops between validation ops. Default: 200\n\t */\n\tvalidateInterval?: number;\n\t/**\n\t * Fraction of ID allocations that are from an outside client (not Client1/2/3).\n\t */\n\toutsideAllocationFraction?: number;\n}\n\nconst defaultOptions = {\n\tmaxClusterSize: 25,\n\tvalidateInterval: 200,\n\toutsideAllocationFraction: 0.1,\n};\n\nexport function makeOpGenerator(\n\toptions: OperationGenerationConfig,\n): Generator<Operation, FuzzTestState> {\n\tconst { maxClusterSize, validateInterval, outsideAllocationFraction } = {\n\t\t...defaultOptions,\n\t\t...options,\n\t};\n\tassert(outsideAllocationFraction >= 0 && outsideAllocationFraction <= 1);\n\n\tfunction allocateIdsGenerator({\n\t\tactiveClients,\n\t\tclusterSize,\n\t\trandom,\n\t}: FuzzTestState): AllocateIds {\n\t\tconst client = random.pick(activeClients);\n\t\tconst maxIdsPerUsage = clusterSize * 2;\n\t\tconst numIds = Math.floor(random.real(0, 1) ** 3 * maxIdsPerUsage) + 1;\n\t\treturn {\n\t\t\ttype: \"allocateIds\",\n\t\t\tclient,\n\t\t\tnumIds,\n\t\t};\n\t}\n\n\tfunction allocateOutsideIdsGenerator({\n\t\tclusterSize,\n\t\trandom,\n\t}: FuzzTestState): AllocateOutsideIds {\n\t\tconst maxIdsPerUsage = clusterSize * 2;\n\t\tconst numIds = Math.floor(random.real(0, 1) ** 3 * maxIdsPerUsage) + 1;\n\t\treturn {\n\t\t\ttype: \"allocateOutsideIds\",\n\t\t\tsessionId: createSessionId(),\n\t\t\tnumIds,\n\t\t};\n\t}\n\n\tfunction changeCapacityGenerator({ random, activeClients }: FuzzTestState): ChangeCapacity {\n\t\treturn {\n\t\t\ttype: \"changeCapacity\",\n\t\t\tclient: random.pick(activeClients),\n\t\t\tnewSize: Math.min(\n\t\t\t\tMath.floor(random.real(0, 1) ** 2 * maxClusterSize) + 1,\n\t\t\t\tmaxClusterSize,\n\t\t\t),\n\t\t};\n\t}\n\n\tfunction deliverAllOperationsGenerator(): DeliverAllOperations {\n\t\treturn {\n\t\t\ttype: \"deliverAllOperations\",\n\t\t};\n\t}\n\n\tfunction deliverSomeOperationsGenerator({\n\t\trandom,\n\t\tselectableClients,\n\t\tnetwork,\n\t}: FuzzTestState): DeliverSomeOperations {\n\t\tconst pendingClients = selectableClients.filter(\n\t\t\t(c) => network.getPendingOperations(c) > 0,\n\t\t);\n\t\tif (pendingClients.length === 0) {\n\t\t\treturn {\n\t\t\t\ttype: \"deliverSomeOperations\",\n\t\t\t\tclient: random.pick(selectableClients),\n\t\t\t\tcount: 0,\n\t\t\t};\n\t\t}\n\t\tconst client = random.pick(pendingClients);\n\t\treturn {\n\t\t\ttype: \"deliverSomeOperations\",\n\t\t\tclient,\n\t\t\tcount: random.integer(1, network.getPendingOperations(client)),\n\t\t};\n\t}\n\n\tfunction reconnectGenerator({ activeClients, random }: FuzzTestState): Reconnect {\n\t\treturn { type: \"reconnect\", client: random.pick(activeClients) };\n\t}\n\n\tconst allocationWeight = 20;\n\treturn interleave(\n\t\tcreateWeightedGenerator<Operation, FuzzTestState>([\n\t\t\t[changeCapacityGenerator, 1],\n\t\t\t[allocateIdsGenerator, Math.round(allocationWeight * (1 - outsideAllocationFraction))],\n\t\t\t[allocateOutsideIdsGenerator, Math.round(allocationWeight * outsideAllocationFraction)],\n\t\t\t[deliverAllOperationsGenerator, 1],\n\t\t\t[deliverSomeOperationsGenerator, 6],\n\t\t\t[reconnectGenerator, 1],\n\t\t]),\n\t\ttake(1, repeat<Operation, FuzzTestState>({ type: \"validate\" })),\n\t\tvalidateInterval,\n\t);\n}\n\n/**\n * Performs random actions on a test network.\n * @param generator - the generator used to provide operations\n * @param network - the test network to test\n * @param seed - the seed for the random generation of the fuzz actions\n * @param observerClient - if provided, this client will never generate local ids\n * @param synchronizeAtEnd - if provided, all client will have all operations delivered from the server at the end of the test\n * @param validator - if provided, this callback will be invoked periodically during the fuzz test.\n */\nexport function performFuzzActions(\n\tgenerator: Generator<Operation, FuzzTestState>,\n\tnetwork: IdCompressorTestNetwork,\n\tseed: number,\n\tobserverClient?: Client,\n\tsynchronizeAtEnd: boolean = true,\n\tvalidator?: (network: IdCompressorTestNetwork) => void,\n\tsaveInfo?: SaveInfo,\n): void {\n\tconst random = makeRandom(seed);\n\tconst selectableClients: Client[] = network\n\t\t.getTargetCompressors(MetaClient.All)\n\t\t.map(([client]) => client);\n\n\tconst initialState: FuzzTestState = {\n\t\trandom,\n\t\tnetwork,\n\t\tactiveClients: selectableClients.filter((c) => c !== observerClient),\n\t\tselectableClients,\n\t\tclusterSize: network.initialClusterSize,\n\t};\n\n\tperformFuzzActionsBase(\n\t\tgenerator,\n\t\t{\n\t\t\tallocateIds: (state, { client, numIds }) => {\n\t\t\t\tnetwork.allocateAndSendIdsFromRemoteClient(client, sessionIds.get(client), numIds);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tallocateOutsideIds: (state, { sessionId, numIds }) => {\n\t\t\t\tnetwork.allocateAndSendIdsFromRemoteClient(\n\t\t\t\t\tOriginatingClient.Remote,\n\t\t\t\t\tsessionId,\n\t\t\t\t\tnumIds,\n\t\t\t\t);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tchangeCapacity: (state, op) => {\n\t\t\t\tnetwork.changeCapacity(op.client, op.newSize);\n\t\t\t\treturn { ...state, clusterSize: op.newSize };\n\t\t\t},\n\t\t\tdeliverSomeOperations: (state, op) => {\n\t\t\t\tnetwork.deliverOperations(op.client, op.count);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tdeliverAllOperations: (state) => {\n\t\t\t\tnetwork.deliverOperations(DestinationClient.All);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\treconnect: (state, { client }) => {\n\t\t\t\tnetwork.goOfflineThenResume(client);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tvalidate: (state) => {\n\t\t\t\tvalidator?.(network);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t},\n\t\tinitialState,\n\t\tsaveInfo,\n\t);\n\n\tif (synchronizeAtEnd) {\n\t\tnetwork.deliverOperations(DestinationClient.All);\n\t\tvalidator?.(network);\n\t}\n}\n\n/**\n * Helper to generate a fixed number of IDs.\n */\nexport function generateCompressedIds(\n\tcompressor: IdCompressor,\n\tcount: number,\n): SessionSpaceCompressedId[] {\n\tconst ids: SessionSpaceCompressedId[] = [];\n\tfor (let i = 0; i < count; i++) {\n\t\tids.push(compressor.generateCompressedId());\n\t}\n\treturn ids;\n}\n\n/**\n * Creates a compressor that only produces final IDs.\n * It should only be used for testing purposes.\n */\nexport function createAlwaysFinalizedIdCompressor(\n\tlogger?: ITelemetryBaseLogger,\n): IIdCompressor & IIdCompressorCore;\n/**\n * Creates a compressor that only produces final IDs.\n * It should only be used for testing purposes.\n */\nexport function createAlwaysFinalizedIdCompressor(\n\tsessionId: SessionId,\n\tlogger?: ITelemetryBaseLogger,\n\tseed?: number,\n): IIdCompressor & IIdCompressorCore;\nexport function createAlwaysFinalizedIdCompressor(\n\tsessionIdOrLogger?: SessionId | ITelemetryBaseLogger,\n\tloggerOrUndefined?: ITelemetryBaseLogger,\n\tseed?: number,\n): IIdCompressor & IIdCompressorCore {\n\tconst random = seed === undefined ? makeRandom() : makeRandom(seed);\n\tconst sessionId =\n\t\ttypeof sessionIdOrLogger === \"string\" ? sessionIdOrLogger : (random.uuid4() as SessionId);\n\tconst logger =\n\t\t(loggerOrUndefined ?? typeof sessionIdOrLogger === \"object\")\n\t\t\t? (sessionIdOrLogger as ITelemetryBaseLogger)\n\t\t\t: undefined;\n\t// This local session is unused, but it needs to not collide with the GhostSession, so allocate a random one.\n\t// This causes the compressor to serialize non-deterministically even when provided an explicit SessionId.\n\t// This can be fixed in the future if needed.\n\tconst compressor = createIdCompressor(random.uuid4() as SessionId, logger);\n\t// Permanently put the compressor in a ghost session\n\t(compressor as IdCompressor).startGhostSession(sessionId);\n\treturn compressor;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/id-compressor",
3
- "version": "2.80.0",
3
+ "version": "2.81.0-374083",
4
4
  "description": "ID compressor",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -81,24 +81,24 @@
81
81
  "temp-directory": "nyc/.nyc_output"
82
82
  },
83
83
  "dependencies": {
84
- "@fluid-internal/client-utils": "~2.80.0",
85
- "@fluidframework/core-interfaces": "~2.80.0",
86
- "@fluidframework/core-utils": "~2.80.0",
87
- "@fluidframework/telemetry-utils": "~2.80.0",
84
+ "@fluid-internal/client-utils": "2.81.0-374083",
85
+ "@fluidframework/core-interfaces": "2.81.0-374083",
86
+ "@fluidframework/core-utils": "2.81.0-374083",
87
+ "@fluidframework/telemetry-utils": "2.81.0-374083",
88
88
  "@tylerbu/sorted-btree-es6": "^1.8.0",
89
89
  "uuid": "^11.1.0"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@arethetypeswrong/cli": "^0.18.2",
93
93
  "@biomejs/biome": "~1.9.3",
94
- "@fluid-internal/mocha-test-setup": "~2.80.0",
95
- "@fluid-private/stochastic-test-utils": "~2.80.0",
96
- "@fluid-tools/benchmark": "^0.51.0",
97
- "@fluid-tools/build-cli": "^0.62.0",
94
+ "@fluid-internal/mocha-test-setup": "2.81.0-374083",
95
+ "@fluid-private/stochastic-test-utils": "2.81.0-374083",
96
+ "@fluid-tools/benchmark": "^0.52.0",
97
+ "@fluid-tools/build-cli": "^0.63.0",
98
98
  "@fluidframework/build-common": "^2.0.3",
99
- "@fluidframework/build-tools": "^0.62.0",
100
- "@fluidframework/eslint-config-fluid": "~2.80.0",
101
- "@fluidframework/id-compressor-previous": "npm:@fluidframework/id-compressor@2.74.0",
99
+ "@fluidframework/build-tools": "^0.63.0",
100
+ "@fluidframework/eslint-config-fluid": "2.81.0-374083",
101
+ "@fluidframework/id-compressor-previous": "npm:@fluidframework/id-compressor@2.80.0",
102
102
  "@microsoft/api-extractor": "7.52.11",
103
103
  "@types/mocha": "^10.0.10",
104
104
  "@types/node": "^18.19.0",
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/id-compressor";
9
- export const pkgVersion = "2.80.0";
9
+ export const pkgVersion = "2.81.0-374083";
package/src/sessions.ts CHANGED
@@ -107,6 +107,7 @@ export class Sessions {
107
107
  // the next lower session (which is B) and erroneously determine we do not collide
108
108
  // with any other session, but this situation is impossible to get into as B would
109
109
  // have detected that it collided with A (or the other way around, depending on ordering).
110
+ // eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- using ?. could change behavior
110
111
  while (closestMatch !== undefined && closestMatch[1] === owningSession) {
111
112
  closestMatch = this.uuidSpace.nextLowerPair(closestMatch[0]);
112
113
  }
@@ -538,6 +538,7 @@ export class IdCompressorTestNetwork {
538
538
  assert(range.sessionId === compressor.localSessionId);
539
539
  if (range.ids !== undefined) {
540
540
  // initialize firstGenCount if not set
541
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy
541
542
  if (firstGenCount === undefined) {
542
543
  firstGenCount = range.ids.firstGenCount;
543
544
  }
package/.eslintrc.cjs DELETED
@@ -1,27 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- module.exports = {
7
- extends: [require.resolve("@fluidframework/eslint-config-fluid/recommended"), "prettier"],
8
- parserOptions: {
9
- project: ["./tsconfig.json", "./src/test/tsconfig.json"],
10
- },
11
- rules: {
12
- "@typescript-eslint/strict-boolean-expressions": "off",
13
- },
14
- overrides: [
15
- {
16
- // Rules only for test files
17
- files: ["*.spec.ts", "src/test/**/*.ts"],
18
- rules: {
19
- // Test files are run in node only so additional node libraries can be used.
20
- "import-x/no-nodejs-modules": [
21
- "error",
22
- { allow: ["node:assert", "node:crypto", "node:fs", "node:path"] },
23
- ],
24
- },
25
- },
26
- ],
27
- };