@fluidframework/id-compressor 2.53.1 → 2.61.0-355054
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.
- package/.mocharc.cjs +1 -2
- package/CHANGELOG.md +4 -0
- package/api-report/{id-compressor.legacy.alpha.api.md → id-compressor.legacy.beta.api.md} +11 -11
- package/dist/finalSpace.d.ts +2 -2
- package/dist/finalSpace.d.ts.map +1 -1
- package/dist/finalSpace.js.map +1 -1
- package/dist/idCompressor.d.ts +20 -17
- package/dist/idCompressor.d.ts.map +1 -1
- package/dist/idCompressor.js +14 -13
- package/dist/idCompressor.js.map +1 -1
- package/dist/identifiers.d.ts +1 -1
- package/dist/identifiers.d.ts.map +1 -1
- package/dist/identifiers.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +4 -2
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/persistanceUtilities.d.ts +1 -1
- package/dist/persistanceUtilities.d.ts.map +1 -1
- package/dist/persistanceUtilities.js.map +1 -1
- package/dist/public.d.ts +2 -1
- package/dist/sessionSpaceNormalizer.d.ts +1 -1
- package/dist/sessionSpaceNormalizer.d.ts.map +1 -1
- package/dist/sessionSpaceNormalizer.js.map +1 -1
- package/dist/sessions.d.ts +2 -2
- package/dist/sessions.d.ts.map +1 -1
- package/dist/sessions.js.map +1 -1
- package/dist/test/appendOnlySortedMap.perf.spec.js.map +1 -1
- package/dist/test/idCompressor.perf.spec.js.map +1 -1
- package/dist/test/idCompressor.spec.js.map +1 -1
- package/dist/test/idCompressorTestUtilities.d.ts +4 -4
- package/dist/test/idCompressorTestUtilities.d.ts.map +1 -1
- package/dist/test/idCompressorTestUtilities.js +5 -2
- package/dist/test/idCompressorTestUtilities.js.map +1 -1
- package/dist/test/numericUuid.spec.js.map +1 -1
- package/dist/test/snapshots/summary.spec.js.map +1 -1
- package/dist/test/testCommon.d.ts +2 -2
- package/dist/test/testCommon.d.ts.map +1 -1
- package/dist/test/testCommon.js.map +1 -1
- package/dist/types/idCompressor.d.ts +3 -4
- package/dist/types/idCompressor.d.ts.map +1 -1
- package/dist/types/idCompressor.js.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/persisted-types/0.0.1.d.ts +4 -8
- package/dist/types/persisted-types/0.0.1.d.ts.map +1 -1
- package/dist/types/persisted-types/0.0.1.js.map +1 -1
- package/dist/types/persisted-types/index.d.ts +1 -1
- package/dist/types/persisted-types/index.d.ts.map +1 -1
- package/dist/types/persisted-types/index.js.map +1 -1
- package/dist/utilities.d.ts +3 -4
- package/dist/utilities.d.ts.map +1 -1
- package/dist/utilities.js +1 -2
- package/dist/utilities.js.map +1 -1
- package/internal.d.ts +1 -1
- package/legacy.d.ts +1 -1
- package/lib/finalSpace.d.ts +2 -2
- package/lib/finalSpace.d.ts.map +1 -1
- package/lib/finalSpace.js.map +1 -1
- package/lib/idCompressor.d.ts +20 -17
- package/lib/idCompressor.d.ts.map +1 -1
- package/lib/idCompressor.js +14 -13
- package/lib/idCompressor.js.map +1 -1
- package/lib/identifiers.d.ts +1 -1
- package/lib/identifiers.d.ts.map +1 -1
- package/lib/identifiers.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +4 -2
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/persistanceUtilities.d.ts +1 -1
- package/lib/persistanceUtilities.d.ts.map +1 -1
- package/lib/persistanceUtilities.js.map +1 -1
- package/lib/public.d.ts +2 -1
- package/lib/sessionSpaceNormalizer.d.ts +1 -1
- package/lib/sessionSpaceNormalizer.d.ts.map +1 -1
- package/lib/sessionSpaceNormalizer.js.map +1 -1
- package/lib/sessions.d.ts +2 -2
- package/lib/sessions.d.ts.map +1 -1
- package/lib/sessions.js.map +1 -1
- package/lib/test/appendOnlySortedMap.perf.spec.js.map +1 -1
- package/lib/test/idCompressor.perf.spec.js.map +1 -1
- package/lib/test/idCompressor.spec.js.map +1 -1
- package/lib/test/idCompressorTestUtilities.d.ts +4 -4
- package/lib/test/idCompressorTestUtilities.d.ts.map +1 -1
- package/lib/test/idCompressorTestUtilities.js +5 -2
- package/lib/test/idCompressorTestUtilities.js.map +1 -1
- package/lib/test/numericUuid.spec.js.map +1 -1
- package/lib/test/snapshots/summary.spec.js.map +1 -1
- package/lib/test/testCommon.d.ts +2 -2
- package/lib/test/testCommon.d.ts.map +1 -1
- package/lib/test/testCommon.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/types/idCompressor.d.ts +3 -4
- package/lib/types/idCompressor.d.ts.map +1 -1
- package/lib/types/idCompressor.js.map +1 -1
- package/lib/types/index.d.ts +3 -3
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/persisted-types/0.0.1.d.ts +4 -8
- package/lib/types/persisted-types/0.0.1.d.ts.map +1 -1
- package/lib/types/persisted-types/0.0.1.js.map +1 -1
- package/lib/types/persisted-types/index.d.ts +1 -1
- package/lib/types/persisted-types/index.d.ts.map +1 -1
- package/lib/types/persisted-types/index.js.map +1 -1
- package/lib/utilities.d.ts +3 -4
- package/lib/utilities.d.ts.map +1 -1
- package/lib/utilities.js +1 -2
- package/lib/utilities.js.map +1 -1
- package/package.json +17 -17
- package/src/finalSpace.ts +2 -2
- package/src/idCompressor.ts +42 -49
- package/src/identifiers.ts +1 -1
- package/src/index.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/persistanceUtilities.ts +1 -1
- package/src/sessionSpaceNormalizer.ts +1 -1
- package/src/sessions.ts +2 -2
- package/src/test/idCompressorTestUtilities.ts +18 -15
- package/src/test/testCommon.ts +2 -2
- package/src/types/idCompressor.ts +3 -4
- package/src/types/index.ts +3 -3
- package/src/types/persisted-types/0.0.1.ts +4 -8
- package/src/types/persisted-types/index.ts +1 -1
- package/src/utilities.ts +3 -4
|
@@ -1 +1 @@
|
|
|
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,OAAO,EAIN,uBAAuB,EACvB,UAAU,EACV,UAAU,EACV,kBAAkB,IAAI,sBAAsB,EAC5C,MAAM,EACN,IAAI,GACJ,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAUN,kBAAkB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE1F,OAAO,EAGN,IAAI,EACJ,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,SAAS,GACT,MAAM,iBAAiB,CAAC;AASzB;;GAEG;AACH,MAAM,CAAN,IAAY,MAIX;AAJD,WAAY,MAAM;IACjB,6BAAmB,CAAA;IACnB,6BAAmB,CAAA;IACnB,6BAAmB,CAAA;AACpB,CAAC,EAJW,MAAM,KAAN,MAAM,QAIjB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,UAEX;AAFD,WAAY,UAAU;IACrB,yBAAW,CAAA;AACZ,CAAC,EAFW,UAAU,KAAV,UAAU,QAErB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,aAEX;AAFD,WAAY,aAAa;IACxB,kCAAiB,CAAA;AAClB,CAAC,EAFW,aAAa,KAAb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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\tBaseFuzzTestState,\n\tGenerator,\n\tSaveInfo,\n\tcreateWeightedGenerator,\n\tinterleave,\n\tmakeRandom,\n\tperformFuzzActions as performFuzzActionsBase,\n\trepeat,\n\ttake,\n} from \"@fluid-private/stochastic-test-utils\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\n\nimport { IdCompressor } from \"../idCompressor.js\";\nimport {\n\ttype IIdCompressor,\n\ttype IIdCompressorCore,\n\tIdCreationRange,\n\tOpSpaceCompressedId,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n\tSessionId,\n\tSessionSpaceCompressedId,\n\tStableId,\n\tcreateIdCompressor,\n} from \"../index.js\";\nimport { SessionSpaceNormalizer } from \"../sessionSpaceNormalizer.js\";\nimport { assertIsSessionId, createSessionId, localIdFromGenCount } from \"../utilities.js\";\n\nimport {\n\tFinalCompressedId,\n\tReadonlyIdCompressor,\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(nonLocalSerialized, createSessionId());\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): IIdCompressor & IIdCompressorCore;\nexport function createAlwaysFinalizedIdCompressor(\n\tsessionIdOrLogger?: SessionId | ITelemetryBaseLogger,\n\tloggerOrUndefined?: ITelemetryBaseLogger,\n): IIdCompressor & IIdCompressorCore {\n\tconst sessionId =\n\t\ttypeof sessionIdOrLogger === \"string\" ? sessionIdOrLogger : createSessionId();\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(createSessionId(), 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,OAAO,EAIN,uBAAuB,EACvB,UAAU,EACV,UAAU,EACV,kBAAkB,IAAI,sBAAsB,EAC5C,MAAM,EACN,IAAI,GACJ,MAAM,s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Eb,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;AAiBD,MAAM,UAAU,iCAAiC,CAChD,iBAAoD,EACpD,iBAAwC;IAExC,MAAM,SAAS,GACd,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;IAC/E,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,eAAe,EAAE,EAAE,MAAM,CAAC,CAAC;IACjE,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\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): IIdCompressor & IIdCompressorCore;\nexport function createAlwaysFinalizedIdCompressor(\n\tsessionIdOrLogger?: SessionId | ITelemetryBaseLogger,\n\tloggerOrUndefined?: ITelemetryBaseLogger,\n): IIdCompressor & IIdCompressorCore {\n\tconst sessionId =\n\t\ttypeof sessionIdOrLogger === \"string\" ? sessionIdOrLogger : createSessionId();\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(createSessionId(), logger);\n\t// Permanently put the compressor in a ghost session\n\t(compressor as IdCompressor).startGhostSession(sessionId);\n\treturn compressor;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numericUuid.spec.js","sourceRoot":"","sources":["../../src/test/numericUuid.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EACN,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,GACpB,MAAM,iBAAiB,CAAC;AAEzB,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACtC,MAAM,UAAU,GAAG,sCAAkD,CAAC;QACtE,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IACxF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,E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,CAAC,CAAC,CAAC,CAAC;QACzC,gBAAgB,CAAC,UAAU,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;QACzC,MAAM,YAAY,GAAG,eAAe,CAAC;YACpC,UAAU,EAAE,UAAU;YACtB,WAAW,EAAE,IAAI,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC;YAChD,KAAK,EAAE,CAAC;SACR,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,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 { StableId } from \"../index.js\";\nimport { readNumericUuid, writeNumericUuid } from \"../persistanceUtilities.js\";\nimport {\n\taddNumericUuids,\n\tassertIsSessionId,\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n\tsubtractNumericUuids,\n} from \"../utilities.js\";\n\ndescribe(\"NumericUuid\", () => {\n\tit(\"can roundtrip a uuid string\", () => {\n\t\tconst uuidString = \"00000000-0000-4000-8000-000000000000\" as StableId;\n\t\tassert.equal(stableIdFromNumericUuid(numericUuidFromStableId(uuidString)), uuidString);\n\t});\n\n\tit(\"can add to a uuid\", () => {\n\t\tconst numeric = numericUuidFromStableId(\n\t\t\t\"00000000-0000-4000-8000-000000000000\" as StableId,\n\t\t);\n\t\tassert.equal(\n\t\t\tstableIdFromNumericUuid(offsetNumericUuid(numeric, 1)),\n\t\t\t\"00000000-0000-4000-8000-000000000001\",\n\t\t);\n\t});\n\n\tit(\"can add to a uuid that would spill over the version and variant bits\", () => {\n\t\tconst numeric = numericUuidFromStableId(\n\t\t\t\"e507602d-b150-4fcc-bfff-ffffffffffff\" as StableId,\n\t\t);\n\t\tconst uuidString = stableIdFromNumericUuid(offsetNumericUuid(numeric, 1));\n\t\tassertIsSessionId(uuidString);\n\t\tassert.equal(uuidString, \"e507602d-b150-4fcd-8000-000000000000\");\n\t});\n\n\tit(\"can subtract from a uuid\", () => {\n\t\tconst numeric1 = numericUuidFromStableId(\n\t\t\t\"10000000-0000-4000-8000-000000000005\" as StableId,\n\t\t);\n\t\tconst numeric2 = numericUuidFromStableId(\n\t\t\t\"20000000-0000-4000-8000-000000000009\" as StableId,\n\t\t);\n\t\tassert.equal(\n\t\t\tstableIdFromNumericUuid(subtractNumericUuids(numeric2, numeric1)),\n\t\t\t\"10000000-0000-4000-8000-000000000004\",\n\t\t);\n\t});\n\n\tit(\"can do general uuid math\", () => {\n\t\tconst uuids = [\n\t\t\tnumericUuidFromStableId(\"10000000-0000-4000-8000-000000000005\" as StableId),\n\t\t\tnumericUuidFromStableId(\"00000000-0000-4000-8000-000000000000\" as StableId),\n\t\t\tnumericUuidFromStableId(\"00000000-b7c5-4c99-83ff-c1b8e02c09d6\" as StableId),\n\t\t\tnumericUuidFromStableId(\"748540ca-b7c5-4c99-83ff-c1b8e02c09d6\" as StableId),\n\t\t\tnumericUuidFromStableId(\"748540ca-b7c5-4c99-83ef-c1b8e02c09d6\" as StableId),\n\t\t\tnumericUuidFromStableId(\"748540ca-b7c5-4c99-831f-c1b8e02c09d6\" as StableId),\n\t\t\tnumericUuidFromStableId(\"0002c79e-b536-4776-b000-000266c252d5\" as StableId),\n\t\t\tnumericUuidFromStableId(\"082533b9-6d05-4068-a008-fe2cc43543f7\" as StableId),\n\t\t\tnumericUuidFromStableId(\"2c9fa1f8-48d5-4554-a466-000000000000\" as StableId),\n\t\t\tnumericUuidFromStableId(\"2c9fa1f8-48d5-4000-a000-000000000000\" as StableId),\n\t\t\tnumericUuidFromStableId(\"10000000-0000-4000-b000-000000000000\" as StableId),\n\t\t\tnumericUuidFromStableId(\"10000000-0000-4000-b020-000000000000\" as StableId),\n\t\t\tnumericUuidFromStableId(\"10000000-0000-4000-b00f-ffffffffffff\" as StableId),\n\t\t\tnumericUuidFromStableId(\"10000000-0000-4000-b040-000000000000\" as StableId),\n\t\t\tnumericUuidFromStableId(\"f0000000-0000-4000-8000-000000000000\" as StableId),\n\t\t\tnumericUuidFromStableId(\"efffffff-ffff-4fff-bfff-ffffffffffff\" as StableId),\n\t\t];\n\t\tuuids.sort();\n\t\tconst offsets = [1, 100, 1000000, 10000000000000000];\n\t\tfor (let i = 0; i < uuids.length; i++) {\n\t\t\tconst uuidA = uuids[i];\n\t\t\tfor (const offset of offsets) {\n\t\t\t\tassertIsSessionId(stableIdFromNumericUuid(offsetNumericUuid(uuidA, offset)));\n\t\t\t}\n\t\t\tfor (let j = i; j < uuids.length; j++) {\n\t\t\t\tconst uuidB = uuids[j];\n\t\t\t\tconst uuidDelta = addNumericUuids(uuidB, subtractNumericUuids(uuidA, uuidB));\n\t\t\t\tassert.equal(uuidDelta, uuidA);\n\t\t\t}\n\t\t}\n\t});\n\n\tit(\"can serialize a uuid\", () => {\n\t\tconst uuidString = \"00000000-0000-4000-8000-000000000000\" as StableId;\n\t\tconst numeric = numericUuidFromStableId(uuidString);\n\t\tconst serialized = new BigUint64Array(2);\n\t\twriteNumericUuid(serialized, 0, numeric);\n\t\tconst roundtripped = readNumericUuid({\n\t\t\tbufferUint: serialized,\n\t\t\tbufferFloat: new Float64Array(serialized.buffer),\n\t\t\tindex: 0,\n\t\t});\n\t\tassert.equal(roundtripped, numeric);\n\t});\n});\n"]}
|
|
1
|
+
{"version":3,"file":"numericUuid.spec.js","sourceRoot":"","sources":["../../src/test/numericUuid.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EACN,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,GACpB,MAAM,iBAAiB,CAAC;AAEzB,QAAQ,CA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,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAChC,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE;QAC/B,MAAM,UAAU,GAAG,sCAAkD,CAAC;QACtE,MAAM,OAAO,GAAG,uBAAuB,CAAC,UAAU,CAAC,CAAC;QACpD,MAAM,UAAU,GAAG,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;QACzC,gBAAgB,CAAC,UAAU,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;QACzC,MAAM,YAAY,GAAG,eAAe,CAAC;YACpC,UAAU,EAAE,UAAU;YACtB,WAAW,EAAE,IAAI,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC;YAChD,KAAK,EAAE,CAAC;SACR,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,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 type { StableId } from \"../index.js\";\nimport { readNumericUuid, writeNumericUuid } from \"../persistanceUtilities.js\";\nimport {\n\taddNumericUuids,\n\tassertIsSessionId,\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n\tsubtractNumericUuids,\n} from \"../utilities.js\";\n\ndescribe(\"NumericUuid\", () => {\n\tit(\"can roundtrip a uuid string\", () => {\n\t\tconst uuidString = \"00000000-0000-4000-8000-000000000000\" as StableId;\n\t\tassert.equal(stableIdFromNumericUuid(numericUuidFromStableId(uuidString)), uuidString);\n\t});\n\n\tit(\"can add to a uuid\", () => {\n\t\tconst numeric = numericUuidFromStableId(\n\t\t\t\"00000000-0000-4000-8000-000000000000\" as StableId,\n\t\t);\n\t\tassert.equal(\n\t\t\tstableIdFromNumericUuid(offsetNumericUuid(numeric, 1)),\n\t\t\t\"00000000-0000-4000-8000-000000000001\",\n\t\t);\n\t});\n\n\tit(\"can add to a uuid that would spill over the version and variant bits\", () => {\n\t\tconst numeric = numericUuidFromStableId(\n\t\t\t\"e507602d-b150-4fcc-bfff-ffffffffffff\" as StableId,\n\t\t);\n\t\tconst uuidString = stableIdFromNumericUuid(offsetNumericUuid(numeric, 1));\n\t\tassertIsSessionId(uuidString);\n\t\tassert.equal(uuidString, \"e507602d-b150-4fcd-8000-000000000000\");\n\t});\n\n\tit(\"can subtract from a uuid\", () => {\n\t\tconst numeric1 = numericUuidFromStableId(\n\t\t\t\"10000000-0000-4000-8000-000000000005\" as StableId,\n\t\t);\n\t\tconst numeric2 = numericUuidFromStableId(\n\t\t\t\"20000000-0000-4000-8000-000000000009\" as StableId,\n\t\t);\n\t\tassert.equal(\n\t\t\tstableIdFromNumericUuid(subtractNumericUuids(numeric2, numeric1)),\n\t\t\t\"10000000-0000-4000-8000-000000000004\",\n\t\t);\n\t});\n\n\tit(\"can do general uuid math\", () => {\n\t\tconst uuids = [\n\t\t\tnumericUuidFromStableId(\"10000000-0000-4000-8000-000000000005\" as StableId),\n\t\t\tnumericUuidFromStableId(\"00000000-0000-4000-8000-000000000000\" as StableId),\n\t\t\tnumericUuidFromStableId(\"00000000-b7c5-4c99-83ff-c1b8e02c09d6\" as StableId),\n\t\t\tnumericUuidFromStableId(\"748540ca-b7c5-4c99-83ff-c1b8e02c09d6\" as StableId),\n\t\t\tnumericUuidFromStableId(\"748540ca-b7c5-4c99-83ef-c1b8e02c09d6\" as StableId),\n\t\t\tnumericUuidFromStableId(\"748540ca-b7c5-4c99-831f-c1b8e02c09d6\" as StableId),\n\t\t\tnumericUuidFromStableId(\"0002c79e-b536-4776-b000-000266c252d5\" as StableId),\n\t\t\tnumericUuidFromStableId(\"082533b9-6d05-4068-a008-fe2cc43543f7\" as StableId),\n\t\t\tnumericUuidFromStableId(\"2c9fa1f8-48d5-4554-a466-000000000000\" as StableId),\n\t\t\tnumericUuidFromStableId(\"2c9fa1f8-48d5-4000-a000-000000000000\" as StableId),\n\t\t\tnumericUuidFromStableId(\"10000000-0000-4000-b000-000000000000\" as StableId),\n\t\t\tnumericUuidFromStableId(\"10000000-0000-4000-b020-000000000000\" as StableId),\n\t\t\tnumericUuidFromStableId(\"10000000-0000-4000-b00f-ffffffffffff\" as StableId),\n\t\t\tnumericUuidFromStableId(\"10000000-0000-4000-b040-000000000000\" as StableId),\n\t\t\tnumericUuidFromStableId(\"f0000000-0000-4000-8000-000000000000\" as StableId),\n\t\t\tnumericUuidFromStableId(\"efffffff-ffff-4fff-bfff-ffffffffffff\" as StableId),\n\t\t];\n\t\tuuids.sort();\n\t\tconst offsets = [1, 100, 1000000, 10000000000000000];\n\t\tfor (let i = 0; i < uuids.length; i++) {\n\t\t\tconst uuidA = uuids[i];\n\t\t\tfor (const offset of offsets) {\n\t\t\t\tassertIsSessionId(stableIdFromNumericUuid(offsetNumericUuid(uuidA, offset)));\n\t\t\t}\n\t\t\tfor (let j = i; j < uuids.length; j++) {\n\t\t\t\tconst uuidB = uuids[j];\n\t\t\t\tconst uuidDelta = addNumericUuids(uuidB, subtractNumericUuids(uuidA, uuidB));\n\t\t\t\tassert.equal(uuidDelta, uuidA);\n\t\t\t}\n\t\t}\n\t});\n\n\tit(\"can serialize a uuid\", () => {\n\t\tconst uuidString = \"00000000-0000-4000-8000-000000000000\" as StableId;\n\t\tconst numeric = numericUuidFromStableId(uuidString);\n\t\tconst serialized = new BigUint64Array(2);\n\t\twriteNumericUuid(serialized, 0, numeric);\n\t\tconst roundtripped = readNumericUuid({\n\t\t\tbufferUint: serialized,\n\t\t\tbufferFloat: new Float64Array(serialized.buffer),\n\t\t\tindex: 0,\n\t\t});\n\t\tassert.equal(roundtripped, numeric);\n\t});\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summary.spec.js","sourceRoot":"","sources":["../../../src/test/snapshots/summary.spec.ts"],"names":[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;QAE3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,UAAU,CAAC,oBAAoB,EAAE,CAAC;QACnC,CAAC;QAED,MAAM,gBAAgB,GAAG,UAAU,CAAC,qBAAqB,EAAE,CAAC;QAC5D,UAAU,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;QACnD,WAAW,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;QACpD,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAE9C,YAAY,CAAC,OAAO,CAAC,CAAC;QACtB,YAAY,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,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\";\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\nimport { SessionId, createIdCompressor } from \"../../index.js\";\nimport { modifyClusterSize } from \"../idCompressorTestUtilities.js\";\n\nimport { _dirname } from \"./dirname.cjs\";\n\nconst regenerateSnapshots = process.argv.includes(\"--snapshot\");\n\nlet currentTestName: string | undefined;\nlet currentTestFile: string | undefined;\n\n// Simple filter to avoid tests with a name that would accidentally be parsed as directory traversal or other confusing things.\nconst nameCheck = new RegExp(/^[^\"/\\\\]+$/);\n\nassert(_dirname.match(/(dist|lib)[/\\\\]test[/\\\\]snapshots$/));\nconst snapshotsFolder = path.join(_dirname, `../../../src/test/snapshots`);\nassert(existsSync(snapshotsFolder));\n\n/**\n * Delete the existing test file directory and recreate it.\n *\n * If the directory does not already exist, this will create it.\n *\n * @param dirPath - The path within the `snapshots` directory.\n */\nfunction useSnapshotDirectory(dirPath: string = \"files\"): void {\n\tconst normalizedDir = path.join(snapshotsFolder, dirPath);\n\t// Basic sanity check to avoid bugs like accidentally recursively deleting everything under `/` if something went wrong (like dirPath navigated up directories a lot).\n\tassert(normalizedDir.startsWith(snapshotsFolder));\n\n\tif (regenerateSnapshots) {\n\t\tif (existsSync(normalizedDir)) {\n\t\t\tconsole.log(`removing snapshot directory: ${normalizedDir}`);\n\t\t\trmSync(normalizedDir, { recursive: true, force: true });\n\t\t}\n\t\tmkdirSync(normalizedDir, { recursive: true });\n\t}\n\n\tbeforeEach(function (): void {\n\t\tcurrentTestName = this.currentTest?.title.replace(/ /g, \"-\") ?? assert.fail();\n\t\tcurrentTestFile = path.join(normalizedDir, currentTestName);\n\t});\n\n\tafterEach(() => {\n\t\tcurrentTestFile = undefined;\n\t\tcurrentTestName = undefined;\n\t});\n}\n\nfunction takeSnapshot(data: string, suffix: string = \"\"): void {\n\tassert(\n\t\tcurrentTestName !== undefined,\n\t\t\"use `useSnapshotDirectory` to configure the tests containing describe block to take snapshots\",\n\t);\n\tassert(currentTestFile !== undefined);\n\n\t// Ensure test name doesn't accidentally navigate up directories or things like that.\n\t// Done here instead of in beforeEach so errors surface better.\n\tif (nameCheck.test(currentTestName) === false) {\n\t\tassert.fail(`Expected test name to pass sanitization: \"${currentTestName}\"`);\n\t}\n\n\tconst fullFile = currentTestFile + suffix;\n\n\tconst exists = existsSync(fullFile);\n\tif (regenerateSnapshots) {\n\t\tassert(exists === false, \"snapshot should not already exist: possible name collision.\");\n\t\twriteFileSync(fullFile, data);\n\t} else {\n\t\tassert(exists, `test snapshot file does not exist: \"${fullFile}\"`);\n\t\tconst pastData = readFileSync(fullFile, \"utf8\");\n\t\tassert.equal(data, pastData, `snapshot different for \"${currentTestName}\"`);\n\t}\n}\n\ndescribe(\"snapshot tests\", () => {\n\tconst client1 = \"403f1e16-5265-4074-8507-417d99a05ee9\" as SessionId;\n\tconst client2 = \"4b02675a-5a81-428d-b7b7-d8c33a16bfde\" as SessionId;\n\n\tuseSnapshotDirectory();\n\n\tit(\"empty compressor summary\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst summary = compressor.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t});\n\n\tit(\"compressor with finalized range from one client\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst compressor2 = createIdCompressor(client2);\n\t\tfor (let i = 0; i < 10; i++) {\n\t\t\tcompressor.generateCompressedId();\n\t\t}\n\t\tconst idRange = compressor.takeNextCreationRange();\n\t\tcompressor.finalizeCreationRange(idRange);\n\t\tconst summary = compressor.serialize(false);\n\t\tconst summary2 = compressor2.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t\ttakeSnapshot(summary2, \"-client2\");\n\t});\n\n\tit(\"compressors with finalized ranges from two clients\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst compressor2 = createIdCompressor(client2);\n\n\t\tfor (let i = 0; i < 10; i++) {\n\t\t\tcompressor.generateCompressedId();\n\t\t\tcompressor2.generateCompressedId();\n\t\t}\n\t\tconst idRange = compressor.takeNextCreationRange();\n\t\tconst idRange2 = compressor2.takeNextCreationRange();\n\n\t\tcompressor.finalizeCreationRange(idRange);\n\t\tcompressor2.finalizeCreationRange(idRange);\n\t\tcompressor.finalizeCreationRange(idRange2);\n\t\tcompressor2.finalizeCreationRange(idRange2);\n\n\t\tconst summary = compressor.serialize(false);\n\t\tconst summary2 = compressor2.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t\ttakeSnapshot(summary2, \"-client2\");\n\t});\n\n\tit(\"expansion semantics\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst compressor2 = createIdCompressor(client2);\n\t\tmodifyClusterSize(compressor, 2);\n\t\tcompressor.generateCompressedId();\n\t\tconst idRange = compressor.takeNextCreationRange();\n\t\tcompressor.finalizeCreationRange(idRange);\n\t\tcompressor2.finalizeCreationRange(idRange);\n\n\t\tfor (let i = 0; i < 3; i++) {\n\t\t\tcompressor.generateCompressedId();\n\t\t}\n\n\t\tconst expansionIdRange = compressor.takeNextCreationRange();\n\t\tcompressor.finalizeCreationRange(expansionIdRange);\n\t\tcompressor2.finalizeCreationRange(expansionIdRange);\n\t\tconst summary = compressor.serialize(false);\n\t\tconst summary2 = compressor2.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t\ttakeSnapshot(summary2, \"-client2\");\n\t});\n});\n"]}
|
|
1
|
+
{"version":3,"file":"summary.spec.js","sourceRoot":"","sources":["../../../src/test/snapshots/summary.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAkB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AAEhE,IAAI,eAAmC,CAAC;AACxC,IAAI,eAAmC,CAAC;AAExC,+HAA+H;AAC/H,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC;AAE3C,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC,CAAC;AAC7D,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,6BAA6B,CAAC,CAAC;AAC3E,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC;AAEpC;;;;;;GAMG;AACH,SAAS,oBAAoB,CAAC,UAAkB,OAAO;IACtD,MAAM,aAAa,GAAG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,MAAM,UAAU,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,WAAW,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAChD,iBAAiB,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QACjC,UAAU,CAAC,oBAAoB,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,UAAU,CAAC,qBAAqB,EAAE,CAAC;QACnD,UAAU,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC1C,WAAW,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAE3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,UAAU,CAAC,oBAAoB,EAAE,CAAC;QACnC,CAAC;QAED,MAAM,gBAAgB,GAAG,UAAU,CAAC,qBAAqB,EAAE,CAAC;QAC5D,UAAU,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;QACnD,WAAW,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;QACpD,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAE9C,YAAY,CAAC,OAAO,CAAC,CAAC;QACtB,YAAY,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,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\";\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\nimport { type SessionId, createIdCompressor } from \"../../index.js\";\nimport { modifyClusterSize } from \"../idCompressorTestUtilities.js\";\n\nimport { _dirname } from \"./dirname.cjs\";\n\nconst regenerateSnapshots = process.argv.includes(\"--snapshot\");\n\nlet currentTestName: string | undefined;\nlet currentTestFile: string | undefined;\n\n// Simple filter to avoid tests with a name that would accidentally be parsed as directory traversal or other confusing things.\nconst nameCheck = new RegExp(/^[^\"/\\\\]+$/);\n\nassert(_dirname.match(/(dist|lib)[/\\\\]test[/\\\\]snapshots$/));\nconst snapshotsFolder = path.join(_dirname, `../../../src/test/snapshots`);\nassert(existsSync(snapshotsFolder));\n\n/**\n * Delete the existing test file directory and recreate it.\n *\n * If the directory does not already exist, this will create it.\n *\n * @param dirPath - The path within the `snapshots` directory.\n */\nfunction useSnapshotDirectory(dirPath: string = \"files\"): void {\n\tconst normalizedDir = path.join(snapshotsFolder, dirPath);\n\t// Basic sanity check to avoid bugs like accidentally recursively deleting everything under `/` if something went wrong (like dirPath navigated up directories a lot).\n\tassert(normalizedDir.startsWith(snapshotsFolder));\n\n\tif (regenerateSnapshots) {\n\t\tif (existsSync(normalizedDir)) {\n\t\t\tconsole.log(`removing snapshot directory: ${normalizedDir}`);\n\t\t\trmSync(normalizedDir, { recursive: true, force: true });\n\t\t}\n\t\tmkdirSync(normalizedDir, { recursive: true });\n\t}\n\n\tbeforeEach(function (): void {\n\t\tcurrentTestName = this.currentTest?.title.replace(/ /g, \"-\") ?? assert.fail();\n\t\tcurrentTestFile = path.join(normalizedDir, currentTestName);\n\t});\n\n\tafterEach(() => {\n\t\tcurrentTestFile = undefined;\n\t\tcurrentTestName = undefined;\n\t});\n}\n\nfunction takeSnapshot(data: string, suffix: string = \"\"): void {\n\tassert(\n\t\tcurrentTestName !== undefined,\n\t\t\"use `useSnapshotDirectory` to configure the tests containing describe block to take snapshots\",\n\t);\n\tassert(currentTestFile !== undefined);\n\n\t// Ensure test name doesn't accidentally navigate up directories or things like that.\n\t// Done here instead of in beforeEach so errors surface better.\n\tif (nameCheck.test(currentTestName) === false) {\n\t\tassert.fail(`Expected test name to pass sanitization: \"${currentTestName}\"`);\n\t}\n\n\tconst fullFile = currentTestFile + suffix;\n\n\tconst exists = existsSync(fullFile);\n\tif (regenerateSnapshots) {\n\t\tassert(exists === false, \"snapshot should not already exist: possible name collision.\");\n\t\twriteFileSync(fullFile, data);\n\t} else {\n\t\tassert(exists, `test snapshot file does not exist: \"${fullFile}\"`);\n\t\tconst pastData = readFileSync(fullFile, \"utf8\");\n\t\tassert.equal(data, pastData, `snapshot different for \"${currentTestName}\"`);\n\t}\n}\n\ndescribe(\"snapshot tests\", () => {\n\tconst client1 = \"403f1e16-5265-4074-8507-417d99a05ee9\" as SessionId;\n\tconst client2 = \"4b02675a-5a81-428d-b7b7-d8c33a16bfde\" as SessionId;\n\n\tuseSnapshotDirectory();\n\n\tit(\"empty compressor summary\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst summary = compressor.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t});\n\n\tit(\"compressor with finalized range from one client\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst compressor2 = createIdCompressor(client2);\n\t\tfor (let i = 0; i < 10; i++) {\n\t\t\tcompressor.generateCompressedId();\n\t\t}\n\t\tconst idRange = compressor.takeNextCreationRange();\n\t\tcompressor.finalizeCreationRange(idRange);\n\t\tconst summary = compressor.serialize(false);\n\t\tconst summary2 = compressor2.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t\ttakeSnapshot(summary2, \"-client2\");\n\t});\n\n\tit(\"compressors with finalized ranges from two clients\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst compressor2 = createIdCompressor(client2);\n\n\t\tfor (let i = 0; i < 10; i++) {\n\t\t\tcompressor.generateCompressedId();\n\t\t\tcompressor2.generateCompressedId();\n\t\t}\n\t\tconst idRange = compressor.takeNextCreationRange();\n\t\tconst idRange2 = compressor2.takeNextCreationRange();\n\n\t\tcompressor.finalizeCreationRange(idRange);\n\t\tcompressor2.finalizeCreationRange(idRange);\n\t\tcompressor.finalizeCreationRange(idRange2);\n\t\tcompressor2.finalizeCreationRange(idRange2);\n\n\t\tconst summary = compressor.serialize(false);\n\t\tconst summary2 = compressor2.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t\ttakeSnapshot(summary2, \"-client2\");\n\t});\n\n\tit(\"expansion semantics\", () => {\n\t\tconst compressor = createIdCompressor(client1);\n\t\tconst compressor2 = createIdCompressor(client2);\n\t\tmodifyClusterSize(compressor, 2);\n\t\tcompressor.generateCompressedId();\n\t\tconst idRange = compressor.takeNextCreationRange();\n\t\tcompressor.finalizeCreationRange(idRange);\n\t\tcompressor2.finalizeCreationRange(idRange);\n\n\t\tfor (let i = 0; i < 3; i++) {\n\t\t\tcompressor.generateCompressedId();\n\t\t}\n\n\t\tconst expansionIdRange = compressor.takeNextCreationRange();\n\t\tcompressor.finalizeCreationRange(expansionIdRange);\n\t\tcompressor2.finalizeCreationRange(expansionIdRange);\n\t\tconst summary = compressor.serialize(false);\n\t\tconst summary2 = compressor2.serialize(false);\n\n\t\ttakeSnapshot(summary);\n\t\ttakeSnapshot(summary2, \"-client2\");\n\t});\n});\n"]}
|
package/lib/test/testCommon.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IdCompressor } from "../idCompressor.js";
|
|
6
|
-
import { OpSpaceCompressedId, SessionSpaceCompressedId, StableId } from "../index.js";
|
|
5
|
+
import type { IdCompressor } from "../idCompressor.js";
|
|
6
|
+
import type { OpSpaceCompressedId, SessionSpaceCompressedId, StableId } from "../index.js";
|
|
7
7
|
/**
|
|
8
8
|
* An identifier (v4 UUID) that has been shortened by a distributed compression algorithm.
|
|
9
9
|
* Lacks a space (session/op), meaning its scope is the same as the space-specific ID from which it was derived.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testCommon.d.ts","sourceRoot":"","sources":["../../src/test/testCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE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,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAC1B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAkB,EAAE,MAAc;IACnE,OAAO,uBAAuB,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAC9F,CAAC;AAaD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,kBAAkB,CACjC,KAAoB,EACpB,OAAO,GAAG,6BAA6B;IAEvC,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IACnC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACxB,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\";\n\nimport { IdCompressor } from \"../idCompressor.js\";\nimport { OpSpaceCompressedId, SessionSpaceCompressedId, StableId } from \"../index.js\";\nimport {\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n} from \"../utilities.js\";\n\n/**\n * An identifier (v4 UUID) that has been shortened by a distributed compression algorithm.\n * Lacks a space (session/op), meaning its scope is the same as the space-specific ID from which it was derived.\n */\nexport type CompressedId =\n\t| SessionSpaceCompressedId\n\t| OpSpaceCompressedId\n\t| FinalCompressedId\n\t| LocalCompressedId;\n\n/**\n * A compressed ID that is stable and unique within the scope of network of compressors (i.e. a document).\n * It can only be used/decompressed in the context of the originating document.\n */\nexport type FinalCompressedId = number & {\n\treadonly FinalCompressedId: \"5d83d1e2-98b7-4e4e-a889-54c855cfa73d\";\n\n\t// Same brand as OpNormalizedCompressedId, as final IDs are always finally normalized\n\treadonly OpNormalized: \"9209432d-a959-4df7-b2ad-767ead4dbcae\";\n};\n\n/**\n * A compressed ID that is local to a session (can only be decompressed when paired with a SessionId).\n * Internally, it should not be persisted outside a scope annotated with the originating SessionId in order to be unambiguous.\n * If external persistence is needed (e.g. by a client), a StableId should be used instead.\n */\nexport type LocalCompressedId = number & {\n\treadonly LocalCompressedId: \"6fccb42f-e2a4-4243-bd29-f13d12b9c6d1\";\n} & SessionSpaceCompressedId; // Same brand as CompressedId, as local IDs are always locally normalized\n\n/**\n * Returns true if the supplied ID is a final ID.\n * @returns true if the supplied ID is a final ID.\n */\nexport function isFinalId(id: CompressedId): id is FinalCompressedId {\n\treturn id >= 0;\n}\n\n/**\n * Returns true if the supplied ID is a local ID.\n * @returns true if the supplied ID is a local ID.\n */\nexport function isLocalId(id: CompressedId): id is LocalCompressedId {\n\treturn id < 0;\n}\n\n/**\n * Turns a negative integer into a local compressed ID. For testing only.\n */\nexport function makeLocalId(negativeInteger: number): LocalCompressedId {\n\tconst id = negativeInteger as CompressedId;\n\tassert(isLocalId(id), \"Not a negative integer.\");\n\treturn id;\n}\n\n/**\n * Remove `readonly` from all fields.\n */\nexport type Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - The map to query/update\n * @param key - The key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n */\nexport function getOrCreate<K, V>(map: Map<K, V>, key: K, defaultValue: (key: K) => V): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue(key);\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\nexport function incrementStableId(stableId: StableId, offset: number): StableId {\n\treturn stableIdFromNumericUuid(offsetNumericUuid(numericUuidFromStableId(stableId), offset));\n}\n\n/**\n * An immutable view of an `IdCompressor`\n */\nexport type ReadonlyIdCompressor = Omit<\n\tIdCompressor,\n\t| \"generateCompressedId\"\n\t| \"generateCompressedIdRange\"\n\t| \"takeNextCreationRange\"\n\t| \"finalizeCreationRange\"\n>;\n\n/**\n * Asserts a value is not undefined, and returns the value.\n * Use when violations are logic errors in the program.\n *\n * @remarks\n * When practical, prefer the pattern `x ?? fail('message')` over `assertNotUndefined(x, 'message')`.\n * Using `?? fail` allows for message formatting without incurring the cost of formatting the message\n * in the non failing case.\n *\n * Example:\n * ```typescript\n * x ?? fail(`x should exist for ${y}`)\n * ```\n *\n * Additionally the `?? fail` avoids an extra call/stack frame in the non failing case.\n *\n * Another pattern to prefer over `assertNotUndefined(x, 'message')` is `assert(x !== undefined)`.\n * This pattern is preferred because it is more general (same approach works with typeof, instance of,\n * comparison to other values etc.).\n *\n * @param value - Value to assert against is non undefined.\n * @param message - Message to be printed if assertion fails.\n */\nexport function assertNotUndefined<T>(\n\tvalue: T | undefined,\n\tmessage = \"value must not be undefined\",\n): T {\n\tassert(value !== undefined, message);\n\treturn value;\n}\n\n/**\n * Fails an assertion. Throws an Error that the assertion failed.\n * Use when violations are logic errors in the program.\n * @param message - Message to be printed if assertion fails.\n */\nexport function fail(message: string): never {\n\tassert(false, message);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"testCommon.js","sourceRoot":"","sources":["../../src/test/testCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D,OAAO,EACN,uBAAuB,EACvB,iBAAiB,EACjB,uBAAuB,GACvB,MAAM,iBAAiB,CAAC;AAgCzB;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,EAAgB;IACzC,OAAO,EAAE,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,EAAgB;IACzC,OAAO,EAAE,GAAG,CAAC,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,eAAuB;IAClD,MAAM,EAAE,GAAG,eAA+B,CAAC;IAC3C,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,yBAAyB,CAAC,CAAC;IACjD,OAAO,EAAE,CAAC;AACX,CAAC;AAOD;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAO,GAAc,EAAE,GAAM,EAAE,YAA2B;IACpF,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAC1B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAkB,EAAE,MAAc;IACnE,OAAO,uBAAuB,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAC9F,CAAC;AAaD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,kBAAkB,CACjC,KAAoB,EACpB,OAAO,GAAG,6BAA6B;IAEvC,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IACnC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACxB,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\";\n\nimport type { IdCompressor } from \"../idCompressor.js\";\nimport type { OpSpaceCompressedId, SessionSpaceCompressedId, StableId } from \"../index.js\";\nimport {\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n} from \"../utilities.js\";\n\n/**\n * An identifier (v4 UUID) that has been shortened by a distributed compression algorithm.\n * Lacks a space (session/op), meaning its scope is the same as the space-specific ID from which it was derived.\n */\nexport type CompressedId =\n\t| SessionSpaceCompressedId\n\t| OpSpaceCompressedId\n\t| FinalCompressedId\n\t| LocalCompressedId;\n\n/**\n * A compressed ID that is stable and unique within the scope of network of compressors (i.e. a document).\n * It can only be used/decompressed in the context of the originating document.\n */\nexport type FinalCompressedId = number & {\n\treadonly FinalCompressedId: \"5d83d1e2-98b7-4e4e-a889-54c855cfa73d\";\n\n\t// Same brand as OpNormalizedCompressedId, as final IDs are always finally normalized\n\treadonly OpNormalized: \"9209432d-a959-4df7-b2ad-767ead4dbcae\";\n};\n\n/**\n * A compressed ID that is local to a session (can only be decompressed when paired with a SessionId).\n * Internally, it should not be persisted outside a scope annotated with the originating SessionId in order to be unambiguous.\n * If external persistence is needed (e.g. by a client), a StableId should be used instead.\n */\nexport type LocalCompressedId = number & {\n\treadonly LocalCompressedId: \"6fccb42f-e2a4-4243-bd29-f13d12b9c6d1\";\n} & SessionSpaceCompressedId; // Same brand as CompressedId, as local IDs are always locally normalized\n\n/**\n * Returns true if the supplied ID is a final ID.\n * @returns true if the supplied ID is a final ID.\n */\nexport function isFinalId(id: CompressedId): id is FinalCompressedId {\n\treturn id >= 0;\n}\n\n/**\n * Returns true if the supplied ID is a local ID.\n * @returns true if the supplied ID is a local ID.\n */\nexport function isLocalId(id: CompressedId): id is LocalCompressedId {\n\treturn id < 0;\n}\n\n/**\n * Turns a negative integer into a local compressed ID. For testing only.\n */\nexport function makeLocalId(negativeInteger: number): LocalCompressedId {\n\tconst id = negativeInteger as CompressedId;\n\tassert(isLocalId(id), \"Not a negative integer.\");\n\treturn id;\n}\n\n/**\n * Remove `readonly` from all fields.\n */\nexport type Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - The map to query/update\n * @param key - The key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n */\nexport function getOrCreate<K, V>(map: Map<K, V>, key: K, defaultValue: (key: K) => V): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue(key);\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\nexport function incrementStableId(stableId: StableId, offset: number): StableId {\n\treturn stableIdFromNumericUuid(offsetNumericUuid(numericUuidFromStableId(stableId), offset));\n}\n\n/**\n * An immutable view of an `IdCompressor`\n */\nexport type ReadonlyIdCompressor = Omit<\n\tIdCompressor,\n\t| \"generateCompressedId\"\n\t| \"generateCompressedIdRange\"\n\t| \"takeNextCreationRange\"\n\t| \"finalizeCreationRange\"\n>;\n\n/**\n * Asserts a value is not undefined, and returns the value.\n * Use when violations are logic errors in the program.\n *\n * @remarks\n * When practical, prefer the pattern `x ?? fail('message')` over `assertNotUndefined(x, 'message')`.\n * Using `?? fail` allows for message formatting without incurring the cost of formatting the message\n * in the non failing case.\n *\n * Example:\n * ```typescript\n * x ?? fail(`x should exist for ${y}`)\n * ```\n *\n * Additionally the `?? fail` avoids an extra call/stack frame in the non failing case.\n *\n * Another pattern to prefer over `assertNotUndefined(x, 'message')` is `assert(x !== undefined)`.\n * This pattern is preferred because it is more general (same approach works with typeof, instance of,\n * comparison to other values etc.).\n *\n * @param value - Value to assert against is non undefined.\n * @param message - Message to be printed if assertion fails.\n */\nexport function assertNotUndefined<T>(\n\tvalue: T | undefined,\n\tmessage = \"value must not be undefined\",\n): T {\n\tassert(value !== undefined, message);\n\treturn value;\n}\n\n/**\n * Fails an assertion. Throws an Error that the assertion failed.\n * Use when violations are logic errors in the program.\n * @param message - Message to be printed if assertion fails.\n */\nexport function fail(message: string): never {\n\tassert(false, message);\n}\n"]}
|
package/lib/tsdoc-metadata.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { OpSpaceCompressedId, SessionId, SessionSpaceCompressedId, StableId } from "./identifiers.js";
|
|
6
|
-
import { IdCreationRange, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession } from "./persisted-types/index.js";
|
|
5
|
+
import type { OpSpaceCompressedId, SessionId, SessionSpaceCompressedId, StableId } from "./identifiers.js";
|
|
6
|
+
import type { IdCreationRange, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession } from "./persisted-types/index.js";
|
|
7
7
|
/**
|
|
8
8
|
* A distributed UUID generator and compressor.
|
|
9
9
|
*
|
|
@@ -64,8 +64,7 @@ import { IdCreationRange, SerializedIdCompressorWithNoSession, SerializedIdCompr
|
|
|
64
64
|
*
|
|
65
65
|
* These two spaces naturally define a rule: consumers of compressed IDs should use session-space IDs, but serialized forms such as ops
|
|
66
66
|
* should use op-space IDs.
|
|
67
|
-
* @legacy
|
|
68
|
-
* @alpha
|
|
67
|
+
* @legacy @beta
|
|
69
68
|
*/
|
|
70
69
|
export interface IIdCompressorCore {
|
|
71
70
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idCompressor.d.ts","sourceRoot":"","sources":["../../src/types/idCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"idCompressor.d.ts","sourceRoot":"","sources":["../../src/types/idCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,mBAAmB,EACnB,SAAS,EACT,wBAAwB,EACxB,QAAQ,EACR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACX,eAAe,EACf,m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AIG;IACH,aAAa,CAAC,YAAY,EAAE,QAAQ,GAAG,wBAAwB,GAAG,SAAS,CAAC;CAC5E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idCompressor.js","sourceRoot":"","sources":["../../src/types/idCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tOpSpaceCompressedId,\n\tSessionId,\n\tSessionSpaceCompressedId,\n\tStableId,\n} from \"./identifiers.js\";\nimport {\n\tIdCreationRange,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n} from \"./persisted-types/index.js\";\n\n/**\n * A distributed UUID generator and compressor.\n *\n * Generates arbitrary non-colliding v4 UUIDs, called stable IDs, for multiple \"sessions\" (which can be distributed across the network),\n * providing each session with the ability to map these UUIDs to `numbers`.\n *\n * A session is a unique identifier that denotes a single compressor. New IDs are created through a single compressor API\n * which should then sent in ranges to the server for total ordering (and are subsequently relayed to other clients). When a new ID is\n * created it is said to be created by the compressor's \"local\" session.\n *\n * For each stable ID created, two numeric IDs are provided by the compressor:\n *\n * 1. A session-local ID, which is stable for the lifetime of the session (which could be longer than that of the compressor object, as it may\n * be serialized for offline usage). Available as soon as the stable ID is allocated. These IDs are session-unique and are thus only\n * safely usable within the scope of the compressor that created it.\n *\n * 2. A final ID, which is stable across serialization and deserialization of an IdCompressor. Available as soon as the range containing\n * the corresponding session-local ID is totally ordered (via consensus) with respect to other sessions' allocations.\n * Final IDs are known to and publicly usable by any compressor that has received them.\n *\n * Compressors will allocate UUIDs in non-random ways to reduce entropy allowing for optimized storage of the data needed\n * to map the UUIDs to the numbers.\n *\n * The following invariants are upheld by IdCompressor:\n *\n * 1. Session-local IDs will always decompress to the same UUIDs for the lifetime of the session.\n *\n * 2. Final IDs will always decompress to the same UUIDs.\n *\n * 3. After a server-processed range of session-local IDs (from any session) is received by a compressor, any of those session-local IDs may be\n * translated by the compressor into the corresponding final ID. For any given session-local ID, this translation will always yield the\n * same final ID.\n *\n * 4. A UUID will always compress into the same session-local ID for the lifetime of the session.\n *\n * Session-local IDs are sent across the wire in efficiently-represented ranges. These ranges are created by querying the compressor, and *must*\n * be ordered (i.e. sent to the server) in the order they are created in order to preserve the above invariants.\n *\n * Session-local IDs can be used immediately after creation, but will eventually (after being sequenced) have a corresponding final ID. This\n * could make reasoning about equality of those two forms difficult. For example, if a cache is keyed off of a\n * session-local ID but is later queried using the final ID (which is semantically equal, as it decompresses to the same UUID/string) it will\n * produce a cache miss. In order to make using collections of both remotely created and locally created IDs easy, regardless of whether the\n * session-local IDs have been finalized, the compressor defines two \"spaces\" of IDs:\n *\n * 1. Session space: in this space, all IDs are normalized to their \"most local form\". This means that all IDs created by the local session\n * will be in local form, regardless of if they have been finalized. Remotely created IDs, which could only have been received after\n * finalizing and will never have a local form for the compressor, will of course be final IDs. This space should be used with consumer APIs\n * and data structures, as the lifetime of the IDs is guaranteed to be the same as the compressor object. Care must be taken to not use\n * these IDs across compressor objects, as the local IDs are specific to the compressor that created them.\n *\n * 2. Op space: in this space, all IDs are normalized to their \"most final form\". This means that all IDs except session-local IDs that\n * have not yet been finalized will be in final ID form. This space is useful for serialization in ops (e.g. references), as other clients\n * that receive them need not do any work to normalize them to *their* session-space in the common case. Note that IDs in op space may move\n * out of Op space over time, namely, when a session-local ID in this space becomes finalized, and thereafter has a \"more final form\".\n * Consequentially, it may be useful to restrict parameters of a persisted type to this space (to optimize perf), but it is potentially\n * incorrect to use this type for a runtime variable. This is an asymmetry that does not affect session space, as local IDs are always as\n * \"local as possible\".\n *\n * These two spaces naturally define a rule: consumers of compressed IDs should use session-space IDs, but serialized forms such as ops\n * should use op-space IDs.\n * @legacy\n * @alpha\n */\nexport interface IIdCompressorCore {\n\t/**\n\t * Returns a range of IDs created by this session in a format for sending to the server for finalizing.\n\t * The range will include all IDs generated via calls to `generateCompressedId` since the last time a\n\t * range was taken (via this method or `takeUnfinalizedCreationRange`).\n\t * @returns the range of IDs, which may be empty. This range must be sent to the server for ordering before\n\t * it is finalized. Ranges must be sent to the server in the order that they are taken via calls to this method.\n\t */\n\ttakeNextCreationRange(): IdCreationRange;\n\n\t/**\n\t * Returns a range of IDs created by this session in a format for sending to the server for finalizing.\n\t * The range will include all unfinalized IDs generated via calls to `generateCompressedId`.\n\t * @returns the range of IDs, which may be empty. This range must be sent to the server for ordering before\n\t * it is finalized. Ranges must be sent to the server in the order that they are taken via calls to this method.\n\t * Note: after finalizing the range returned by this method, finalizing any ranges that had been previously taken\n\t * will result in an error.\n\t */\n\ttakeUnfinalizedCreationRange(): IdCreationRange;\n\n\t/**\n\t * Finalizes the supplied range of IDs (which may be from either a remote or local session).\n\t * @param range - the range of session-local IDs to finalize.\n\t */\n\tfinalizeCreationRange(range: IdCreationRange): void;\n\n\t/**\n\t * Run a callback that is performed from the perspective of a special \"ghost\" session.\n\t * Any ids generated by this session will be immediately finalized on the local client as if\n\t * they were created by a remote client with `ghostSessionId`.\n\t *\n\t * *WARNING:* This API requires an external consensus mechanism to safely use:\n\t * In an attached container (i.e. multiple clients may have the document loaded), all clients must guarantee that:\n\t * - They invoke this API starting from the same finalized creation ranges\n\t * - This API is invoked with the same ghost session id\n\t * - `ghostSessionCallback` deterministically mints the same number of ids on each client within the ghost session\n\t * Failure to meet these requirement will result in divergence across clients and eventual consistency errors.\n\t * While the ghost sesion callback is running, IdCompressor does not support serialization.\n\t * @remarks This API is primarily intended for data migration scenarios which are able to deterministically transform\n\t * data in some format into data in a new format.\n\t * The first requirement (that all clients must invoke the API with the same finalized creation ranges) is guaranteed\n\t * for this scenario because the data transformation callback occurs at a specific ack within the op stream on all\n\t * clients, and clients don't finalize creation ranges for local changes they might have at this point in time.\n\t * @param ghostSessionId - The session id that minted ids generated within `ghostSessionCallback` should be attributed to.\n\t * @param ghostSessionCallback - Callback which mints ids attributed to the ghost session.\n\t */\n\tbeginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): void;\n\n\t/**\n\t * Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.\n\t * This includes finalized state as well as un-finalized state and is therefore suitable for use in offline scenarios.\n\t */\n\tserialize(withSession: true): SerializedIdCompressorWithOngoingSession;\n\n\t/**\n\t * Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.\n\t * This only includes finalized state and is therefore suitable for use in summaries.\n\t */\n\tserialize(withSession: false): SerializedIdCompressorWithNoSession;\n}\n\n/**\n * A distributed UUID generator and compressor.\n * `IdCompressor` offers the ability to generate arbitrary non-colliding v4 UUIDs, called stable IDs, while compressing them into small integers\n * for efficient storage and transmission. It also provides the ability to decompress these integers back into their original UUIDs.\n *\n * The compressor is designed to be used in a distributed environment, where multiple clients may be generating IDs concurrently.\n * IDs generated by a compressor, via calls to `generateCompressedId`, are created in the compressor's \"local\" session.\n * These IDs are unique within the session, but may not be unique across sessions. In the context of Fluid, the scope of a session\n * is the same as the scope of a container. This means that anytime IDs are transferred between sessions, they must be translated\n * through a process called \"normalization\":\n * - The scope of a local session (in which local IDs are unique) is called the \"session space\" of the client.\n * - The context of persisted state (in Fluid, this is the context of ops and summaries) is called \"op space\".\n * - `SessionSpaceCompressedId`s, generated via calls to `generateCompressedId`, should NEVER be serialized directly.\n * In Fluid, this means they should not be included in ops or summaries.\n * - Before serialization, IDs must be normalized to op space to ensure they are interpretable by other clients.\n * - Upon receipt, IDs should be normalized back to session space before use.\n *\n * Example Usage:\n *\n * ### Client A (Sender)\n *\n * ```typescript\n * // Generate several local IDs\n * const localId1 = idCompressor.generateCompressedId();\n * const localId2 = idCompressor.generateCompressedId();\n * const localId3 = idCompressor.generateCompressedId();\n *\n * // Normalize these IDs to op space for inclusion in a message\n * const opSpaceId1 = idCompressor.normalizeToOpSpace(localId1);\n * const opSpaceId2 = idCompressor.normalizeToOpSpace(localId2);\n * const opSpaceId3 = idCompressor.normalizeToOpSpace(localId3);\n *\n * // Create and send a message containing these op space IDs along with the sender's session ID\n * // In Fluid, this would be an op or summary\n * const message = {\n * sessionID: idCompressor.localSessionId,\n * ids: [opSpaceId1, opSpaceId2, opSpaceId3]\n * };\n * ```\n *\n * ### Client B (Receiver)\n *\n * ```typescript\n * // Receive the message from Client A\n * const receivedMessage = ...; // In Fluid, this would be an op or summary\n *\n * // Normalize the received IDs back to session space, utilizing the sender's session ID\n * const sessionSpaceId1 = idCompressor.normalizeToSessionSpace(receivedMessage.ids[0], receivedMessage.sessionID);\n * const sessionSpaceId2 = idCompressor.normalizeToSessionSpace(receivedMessage.ids[1], receivedMessage.sessionID);\n * const sessionSpaceId3 = idCompressor.normalizeToSessionSpace(receivedMessage.ids[2], receivedMessage.sessionID);\n * ```\n * @public\n */\nexport interface IIdCompressor {\n\t/**\n\t * The local session ID.\n\t */\n\tlocalSessionId: SessionId;\n\n\t/**\n\t * Generates a new compressed ID.\n\t * The returned ID is in session space and should not be serialized directly. See `IIdCompressor` for more details.\n\t * @returns A new local ID in session space.\n\t */\n\tgenerateCompressedId(): SessionSpaceCompressedId;\n\n\t/**\n\t * Generates a new ID that is guaranteed to be unique across all sessions known to this compressor without the need for any\n\t * normalization. The returned ID is not guaranteed to be a compressed ID (small number); it may be a stable ID (UUID string).\n\t * In Fluid, the likelihood of generating the bulkier stable ID is dictated by network conditions and is highly probably in\n\t * scenarios such as offline. This is still useful for use cases where simplicity is more important than performance and\n\t * this approach will often be superior to generating a UUID.\n\t * If small numbers are a requirement, `generateCompressedId` and normalization should be used instead.\n\t * See `IIdCompressor` for more details.\n\t * @returns A new local ID in session space.\n\t */\n\tgenerateDocumentUniqueId(): (SessionSpaceCompressedId & OpSpaceCompressedId) | StableId;\n\n\t/**\n\t * Normalizes a session space ID into op space.\n\t * The returned ID is in op space and can be safely serialized. However, it should be normalized back to session space before use.\n\t * See `IIdCompressor` for more details.\n\t * @param id - The local ID to normalize.\n\t * @returns The ID in op space.\n\t */\n\tnormalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;\n\n\t/**\n\t * Normalizes an ID into session space.\n\t * @param id - The ID to normalize.\n\t * @param originSessionId - The session from which `id` originated. This should be the ID of the client that normalized `id` to op space.\n\t * This means that it may not be the client that created `id` in the first place, but rather the client that serialized it.\n\t * This is an important distinction in the case of a reference, where a client might refer to an ID created by another client.\n\t * @returns The session-space ID in the local session corresponding to `id`.\n\t */\n\tnormalizeToSessionSpace(\n\t\tid: OpSpaceCompressedId,\n\t\toriginSessionId: SessionId,\n\t): SessionSpaceCompressedId;\n\n\t/**\n\t * Decompresses a previously compressed ID into a UUID.\n\t * @param id - The compressed ID to be decompressed.\n\t * @returns The UUID associated with the compressed ID.\n\t * @throws If the ID was not generated by any session known to this compressor.\n\t */\n\tdecompress(id: SessionSpaceCompressedId): StableId;\n\n\t/**\n\t * Recompresses a UUID.\n\t * @param uncompressed - The UUID to recompress.\n\t * @returns The `CompressedId` associated with `uncompressed`.\n\t * @throws If the UUID was not generated by any session known to this compressor.\n\t */\n\trecompress(uncompressed: StableId): SessionSpaceCompressedId;\n\n\t/**\n\t * Attempts to recompress a UUID.\n\t * @param uncompressed - The UUID to recompress.\n\t * @returns The `CompressedId` associated with `uncompressed` or undefined if the UUID was not generated by any session known to this compressor.\n\t */\n\ttryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"idCompressor.js","sourceRoot":"","sources":["../../src/types/idCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tOpSpaceCompressedId,\n\tSessionId,\n\tSessionSpaceCompressedId,\n\tStableId,\n} from \"./identifiers.js\";\nimport type {\n\tIdCreationRange,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n} from \"./persisted-types/index.js\";\n\n/**\n * A distributed UUID generator and compressor.\n *\n * Generates arbitrary non-colliding v4 UUIDs, called stable IDs, for multiple \"sessions\" (which can be distributed across the network),\n * providing each session with the ability to map these UUIDs to `numbers`.\n *\n * A session is a unique identifier that denotes a single compressor. New IDs are created through a single compressor API\n * which should then sent in ranges to the server for total ordering (and are subsequently relayed to other clients). When a new ID is\n * created it is said to be created by the compressor's \"local\" session.\n *\n * For each stable ID created, two numeric IDs are provided by the compressor:\n *\n * 1. A session-local ID, which is stable for the lifetime of the session (which could be longer than that of the compressor object, as it may\n * be serialized for offline usage). Available as soon as the stable ID is allocated. These IDs are session-unique and are thus only\n * safely usable within the scope of the compressor that created it.\n *\n * 2. A final ID, which is stable across serialization and deserialization of an IdCompressor. Available as soon as the range containing\n * the corresponding session-local ID is totally ordered (via consensus) with respect to other sessions' allocations.\n * Final IDs are known to and publicly usable by any compressor that has received them.\n *\n * Compressors will allocate UUIDs in non-random ways to reduce entropy allowing for optimized storage of the data needed\n * to map the UUIDs to the numbers.\n *\n * The following invariants are upheld by IdCompressor:\n *\n * 1. Session-local IDs will always decompress to the same UUIDs for the lifetime of the session.\n *\n * 2. Final IDs will always decompress to the same UUIDs.\n *\n * 3. After a server-processed range of session-local IDs (from any session) is received by a compressor, any of those session-local IDs may be\n * translated by the compressor into the corresponding final ID. For any given session-local ID, this translation will always yield the\n * same final ID.\n *\n * 4. A UUID will always compress into the same session-local ID for the lifetime of the session.\n *\n * Session-local IDs are sent across the wire in efficiently-represented ranges. These ranges are created by querying the compressor, and *must*\n * be ordered (i.e. sent to the server) in the order they are created in order to preserve the above invariants.\n *\n * Session-local IDs can be used immediately after creation, but will eventually (after being sequenced) have a corresponding final ID. This\n * could make reasoning about equality of those two forms difficult. For example, if a cache is keyed off of a\n * session-local ID but is later queried using the final ID (which is semantically equal, as it decompresses to the same UUID/string) it will\n * produce a cache miss. In order to make using collections of both remotely created and locally created IDs easy, regardless of whether the\n * session-local IDs have been finalized, the compressor defines two \"spaces\" of IDs:\n *\n * 1. Session space: in this space, all IDs are normalized to their \"most local form\". This means that all IDs created by the local session\n * will be in local form, regardless of if they have been finalized. Remotely created IDs, which could only have been received after\n * finalizing and will never have a local form for the compressor, will of course be final IDs. This space should be used with consumer APIs\n * and data structures, as the lifetime of the IDs is guaranteed to be the same as the compressor object. Care must be taken to not use\n * these IDs across compressor objects, as the local IDs are specific to the compressor that created them.\n *\n * 2. Op space: in this space, all IDs are normalized to their \"most final form\". This means that all IDs except session-local IDs that\n * have not yet been finalized will be in final ID form. This space is useful for serialization in ops (e.g. references), as other clients\n * that receive them need not do any work to normalize them to *their* session-space in the common case. Note that IDs in op space may move\n * out of Op space over time, namely, when a session-local ID in this space becomes finalized, and thereafter has a \"more final form\".\n * Consequentially, it may be useful to restrict parameters of a persisted type to this space (to optimize perf), but it is potentially\n * incorrect to use this type for a runtime variable. This is an asymmetry that does not affect session space, as local IDs are always as\n * \"local as possible\".\n *\n * These two spaces naturally define a rule: consumers of compressed IDs should use session-space IDs, but serialized forms such as ops\n * should use op-space IDs.\n * @legacy @beta\n */\nexport interface IIdCompressorCore {\n\t/**\n\t * Returns a range of IDs created by this session in a format for sending to the server for finalizing.\n\t * The range will include all IDs generated via calls to `generateCompressedId` since the last time a\n\t * range was taken (via this method or `takeUnfinalizedCreationRange`).\n\t * @returns the range of IDs, which may be empty. This range must be sent to the server for ordering before\n\t * it is finalized. Ranges must be sent to the server in the order that they are taken via calls to this method.\n\t */\n\ttakeNextCreationRange(): IdCreationRange;\n\n\t/**\n\t * Returns a range of IDs created by this session in a format for sending to the server for finalizing.\n\t * The range will include all unfinalized IDs generated via calls to `generateCompressedId`.\n\t * @returns the range of IDs, which may be empty. This range must be sent to the server for ordering before\n\t * it is finalized. Ranges must be sent to the server in the order that they are taken via calls to this method.\n\t * Note: after finalizing the range returned by this method, finalizing any ranges that had been previously taken\n\t * will result in an error.\n\t */\n\ttakeUnfinalizedCreationRange(): IdCreationRange;\n\n\t/**\n\t * Finalizes the supplied range of IDs (which may be from either a remote or local session).\n\t * @param range - the range of session-local IDs to finalize.\n\t */\n\tfinalizeCreationRange(range: IdCreationRange): void;\n\n\t/**\n\t * Run a callback that is performed from the perspective of a special \"ghost\" session.\n\t * Any ids generated by this session will be immediately finalized on the local client as if\n\t * they were created by a remote client with `ghostSessionId`.\n\t *\n\t * *WARNING:* This API requires an external consensus mechanism to safely use:\n\t * In an attached container (i.e. multiple clients may have the document loaded), all clients must guarantee that:\n\t * - They invoke this API starting from the same finalized creation ranges\n\t * - This API is invoked with the same ghost session id\n\t * - `ghostSessionCallback` deterministically mints the same number of ids on each client within the ghost session\n\t * Failure to meet these requirement will result in divergence across clients and eventual consistency errors.\n\t * While the ghost sesion callback is running, IdCompressor does not support serialization.\n\t * @remarks This API is primarily intended for data migration scenarios which are able to deterministically transform\n\t * data in some format into data in a new format.\n\t * The first requirement (that all clients must invoke the API with the same finalized creation ranges) is guaranteed\n\t * for this scenario because the data transformation callback occurs at a specific ack within the op stream on all\n\t * clients, and clients don't finalize creation ranges for local changes they might have at this point in time.\n\t * @param ghostSessionId - The session id that minted ids generated within `ghostSessionCallback` should be attributed to.\n\t * @param ghostSessionCallback - Callback which mints ids attributed to the ghost session.\n\t */\n\tbeginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): void;\n\n\t/**\n\t * Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.\n\t * This includes finalized state as well as un-finalized state and is therefore suitable for use in offline scenarios.\n\t */\n\tserialize(withSession: true): SerializedIdCompressorWithOngoingSession;\n\n\t/**\n\t * Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.\n\t * This only includes finalized state and is therefore suitable for use in summaries.\n\t */\n\tserialize(withSession: false): SerializedIdCompressorWithNoSession;\n}\n\n/**\n * A distributed UUID generator and compressor.\n * `IdCompressor` offers the ability to generate arbitrary non-colliding v4 UUIDs, called stable IDs, while compressing them into small integers\n * for efficient storage and transmission. It also provides the ability to decompress these integers back into their original UUIDs.\n *\n * The compressor is designed to be used in a distributed environment, where multiple clients may be generating IDs concurrently.\n * IDs generated by a compressor, via calls to `generateCompressedId`, are created in the compressor's \"local\" session.\n * These IDs are unique within the session, but may not be unique across sessions. In the context of Fluid, the scope of a session\n * is the same as the scope of a container. This means that anytime IDs are transferred between sessions, they must be translated\n * through a process called \"normalization\":\n * - The scope of a local session (in which local IDs are unique) is called the \"session space\" of the client.\n * - The context of persisted state (in Fluid, this is the context of ops and summaries) is called \"op space\".\n * - `SessionSpaceCompressedId`s, generated via calls to `generateCompressedId`, should NEVER be serialized directly.\n * In Fluid, this means they should not be included in ops or summaries.\n * - Before serialization, IDs must be normalized to op space to ensure they are interpretable by other clients.\n * - Upon receipt, IDs should be normalized back to session space before use.\n *\n * Example Usage:\n *\n * ### Client A (Sender)\n *\n * ```typescript\n * // Generate several local IDs\n * const localId1 = idCompressor.generateCompressedId();\n * const localId2 = idCompressor.generateCompressedId();\n * const localId3 = idCompressor.generateCompressedId();\n *\n * // Normalize these IDs to op space for inclusion in a message\n * const opSpaceId1 = idCompressor.normalizeToOpSpace(localId1);\n * const opSpaceId2 = idCompressor.normalizeToOpSpace(localId2);\n * const opSpaceId3 = idCompressor.normalizeToOpSpace(localId3);\n *\n * // Create and send a message containing these op space IDs along with the sender's session ID\n * // In Fluid, this would be an op or summary\n * const message = {\n * sessionID: idCompressor.localSessionId,\n * ids: [opSpaceId1, opSpaceId2, opSpaceId3]\n * };\n * ```\n *\n * ### Client B (Receiver)\n *\n * ```typescript\n * // Receive the message from Client A\n * const receivedMessage = ...; // In Fluid, this would be an op or summary\n *\n * // Normalize the received IDs back to session space, utilizing the sender's session ID\n * const sessionSpaceId1 = idCompressor.normalizeToSessionSpace(receivedMessage.ids[0], receivedMessage.sessionID);\n * const sessionSpaceId2 = idCompressor.normalizeToSessionSpace(receivedMessage.ids[1], receivedMessage.sessionID);\n * const sessionSpaceId3 = idCompressor.normalizeToSessionSpace(receivedMessage.ids[2], receivedMessage.sessionID);\n * ```\n * @public\n */\nexport interface IIdCompressor {\n\t/**\n\t * The local session ID.\n\t */\n\tlocalSessionId: SessionId;\n\n\t/**\n\t * Generates a new compressed ID.\n\t * The returned ID is in session space and should not be serialized directly. See `IIdCompressor` for more details.\n\t * @returns A new local ID in session space.\n\t */\n\tgenerateCompressedId(): SessionSpaceCompressedId;\n\n\t/**\n\t * Generates a new ID that is guaranteed to be unique across all sessions known to this compressor without the need for any\n\t * normalization. The returned ID is not guaranteed to be a compressed ID (small number); it may be a stable ID (UUID string).\n\t * In Fluid, the likelihood of generating the bulkier stable ID is dictated by network conditions and is highly probably in\n\t * scenarios such as offline. This is still useful for use cases where simplicity is more important than performance and\n\t * this approach will often be superior to generating a UUID.\n\t * If small numbers are a requirement, `generateCompressedId` and normalization should be used instead.\n\t * See `IIdCompressor` for more details.\n\t * @returns A new local ID in session space.\n\t */\n\tgenerateDocumentUniqueId(): (SessionSpaceCompressedId & OpSpaceCompressedId) | StableId;\n\n\t/**\n\t * Normalizes a session space ID into op space.\n\t * The returned ID is in op space and can be safely serialized. However, it should be normalized back to session space before use.\n\t * See `IIdCompressor` for more details.\n\t * @param id - The local ID to normalize.\n\t * @returns The ID in op space.\n\t */\n\tnormalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;\n\n\t/**\n\t * Normalizes an ID into session space.\n\t * @param id - The ID to normalize.\n\t * @param originSessionId - The session from which `id` originated. This should be the ID of the client that normalized `id` to op space.\n\t * This means that it may not be the client that created `id` in the first place, but rather the client that serialized it.\n\t * This is an important distinction in the case of a reference, where a client might refer to an ID created by another client.\n\t * @returns The session-space ID in the local session corresponding to `id`.\n\t */\n\tnormalizeToSessionSpace(\n\t\tid: OpSpaceCompressedId,\n\t\toriginSessionId: SessionId,\n\t): SessionSpaceCompressedId;\n\n\t/**\n\t * Decompresses a previously compressed ID into a UUID.\n\t * @param id - The compressed ID to be decompressed.\n\t * @returns The UUID associated with the compressed ID.\n\t * @throws If the ID was not generated by any session known to this compressor.\n\t */\n\tdecompress(id: SessionSpaceCompressedId): StableId;\n\n\t/**\n\t * Recompresses a UUID.\n\t * @param uncompressed - The UUID to recompress.\n\t * @returns The `CompressedId` associated with `uncompressed`.\n\t * @throws If the UUID was not generated by any session known to this compressor.\n\t */\n\trecompress(uncompressed: StableId): SessionSpaceCompressedId;\n\n\t/**\n\t * Attempts to recompress a UUID.\n\t * @param uncompressed - The UUID to recompress.\n\t * @returns The `CompressedId` associated with `uncompressed` or undefined if the UUID was not generated by any session known to this compressor.\n\t */\n\ttryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;\n}\n"]}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { IdCreationRange, SerializedIdCompressor, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession, } from "./persisted-types/index.js";
|
|
6
|
-
export { IIdCompressorCore, IIdCompressor } from "./idCompressor.js";
|
|
7
|
-
export { SessionSpaceCompressedId, OpSpaceCompressedId, SessionId, StableId, } from "./identifiers.js";
|
|
5
|
+
export type { IdCreationRange, SerializedIdCompressor, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession, } from "./persisted-types/index.js";
|
|
6
|
+
export type { IIdCompressorCore, IIdCompressor } from "./idCompressor.js";
|
|
7
|
+
export type { SessionSpaceCompressedId, OpSpaceCompressedId, SessionId, StableId, } from "./identifiers.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EACX,eAAe,EACf,sBAAsB,EACtB,mCAAmC,EACnC,wCAAwC,GACxC,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE1E,YAAY,EACX,wBAAwB,EACxB,mBAAmB,EACnB,SAAS,EACT,QAAQ,GACR,MAAM,kBAAkB,CAAC"}
|
package/lib/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tIdCreationRange,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n} from \"./persisted-types/index.js\";\n\nexport { IIdCompressorCore, IIdCompressor } from \"./idCompressor.js\";\n\nexport {\n\tSessionSpaceCompressedId,\n\tOpSpaceCompressedId,\n\tSessionId,\n\tStableId,\n} from \"./identifiers.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type {\n\tIdCreationRange,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n} from \"./persisted-types/index.js\";\n\nexport type { IIdCompressorCore, IIdCompressor } from \"./idCompressor.js\";\n\nexport type {\n\tSessionSpaceCompressedId,\n\tOpSpaceCompressedId,\n\tSessionId,\n\tStableId,\n} from \"./identifiers.js\";\n"]}
|