@fluid-experimental/tree 1.3.3 → 1.3.4
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/dist/id-compressor/IdCompressor.d.ts.map +1 -1
- package/dist/id-compressor/IdCompressor.js +26 -18
- package/dist/id-compressor/IdCompressor.js.map +1 -1
- package/dist/id-compressor/SessionIdNormalizer.d.ts +31 -4
- package/dist/id-compressor/SessionIdNormalizer.d.ts.map +1 -1
- package/dist/id-compressor/SessionIdNormalizer.js +64 -18
- package/dist/id-compressor/SessionIdNormalizer.js.map +1 -1
- package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
- package/lib/id-compressor/IdCompressor.js +26 -18
- package/lib/id-compressor/IdCompressor.js.map +1 -1
- package/lib/id-compressor/SessionIdNormalizer.d.ts +31 -4
- package/lib/id-compressor/SessionIdNormalizer.d.ts.map +1 -1
- package/lib/id-compressor/SessionIdNormalizer.js +64 -18
- package/lib/id-compressor/SessionIdNormalizer.js.map +1 -1
- package/lib/test/IdCompressor.tests.js +210 -87
- package/lib/test/IdCompressor.tests.js.map +1 -1
- package/lib/test/SessionIdNormalizer.tests.js +124 -46
- package/lib/test/SessionIdNormalizer.tests.js.map +1 -1
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts +17 -5
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/IdCompressorTestUtilities.js +60 -14
- package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -1
- package/package.json +17 -17
- package/src/id-compressor/IdCompressor.ts +28 -17
- package/src/id-compressor/SessionIdNormalizer.ts +72 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdCompressorTestUtilities.js","sourceRoot":"","sources":["../../../src/test/utilities/IdCompressorTestUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EA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AC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAC1G,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IAC1C,OAAO,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,WAAW,CAAC,GAAW,EAAE,IAAY,EAAE,MAAc;IAC7D,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAwB,EAAE,KAAa;IAC5E,MAAM,GAAG,GAA+B,EAAE,CAAC;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;QAC/B,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;KAC5C;IACD,OAAO,GAAG,CAAC;AACZ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { expect } from 'chai';\nimport {\n\tGenerator,\n\tcreateWeightedGenerator,\n\tinterleave,\n\tmakeRandom,\n\tperformFuzzActions as performFuzzActionsBase,\n\trepeat,\n\tSaveInfo,\n\ttake,\n\tBaseFuzzTestState,\n} from '@fluid-internal/stochastic-test-utils';\nimport { assert, assertNotUndefined, ClosedMap, fail, getOrCreate } from '../../Common';\nimport { IdCompressor, isLocalId } from '../../id-compressor/IdCompressor';\nimport {\n\tcreateSessionId,\n\tensureSessionUuid,\n\tNumericUuid,\n\tnumericUuidFromStableId,\n\tstableIdFromNumericUuid,\n} from '../../id-compressor/NumericUuid';\nimport {\n\tFinalCompressedId,\n\tSessionId,\n\tStableId,\n\tSessionSpaceCompressedId,\n\tAttributionId,\n\tOpSpaceCompressedId,\n} from '../../Identifiers';\nimport { getIds } from '../../id-compressor/IdRange';\nimport type {\n\tIdCreationRange,\n\tSerializedIdCompressorWithOngoingSession,\n\tSerializedIdCompressorWithNoSession,\n} from '../../id-compressor';\nimport { assertIsStableId, assertIsUuidString } from '../../UuidUtilities';\nimport { expectDefined } from './TestCommon';\n\n/** Identifies a compressor in a network */\nexport enum Client {\n\tClient1 = 'Client1',\n\tClient2 = 'Client2',\n\tClient3 = 'Client3',\n}\n\n/** Identifies a compressor with respect to a specific operation */\nexport enum SemanticClient {\n\tLocalClient = 'LocalClient',\n}\n\n/** Identifies categories of compressors */\nexport enum MetaClient {\n\tAll = 'All',\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 | SemanticClient;\nexport const OriginatingClient = { ...Client, ...SemanticClient };\n\n/** Identifies a compressor to which to send an operation */\nexport type DestinationClient = Client | MetaClient;\nexport const DestinationClient = { ...Client, ...MetaClient };\n\n/**\n * Creates a new compressor with the supplied cluster capacity.\n */\nexport function createCompressor(client: Client, clusterCapacity = 5, attributionId?: AttributionId): IdCompressor {\n\tconst compressor = new IdCompressor(sessionIds.get(client), 1024, attributionId);\n\tcompressor.clusterCapacity = clusterCapacity;\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 = ensureSessionUuid(assertIsStableId(`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 * An array of session uuids corresponding to all non-local `Client` entries.\n */\nexport const sessionNumericUuids = new Map(\n\t[...sessionIds.entries()].map(([client, sessionId]) => {\n\t\treturn [client, numericUuidFromStableId(sessionId)];\n\t})\n) as ClientMap<NumericUuid>;\n\nexport const attributionIds = new Map(\n\tObject.values(Client).map((c, i) => [\n\t\tc,\n\t\tassertIsUuidString(`00000000-0000-0000-0000-${(i + 1).toString(16).padStart(12, '0')}`),\n\t])\n) as ClientMap<AttributionId>;\n\n/** An immutable view of an `IdCompressor` */\nexport interface ReadonlyIdCompressor\n\textends Omit<\n\t\tIdCompressor,\n\t\t'generateCompressedId' | 'generateCompressedIdRange' | 'takeNextCreationRange' | 'finalizeCreationRange'\n\t> {\n\treadonly clusterCapacity: number;\n}\n\n/** Information about a generated ID in a network to be validated by tests */\nexport interface TestIdData {\n\treadonly id: SessionSpaceCompressedId;\n\treadonly originatingClient: Client;\n\treadonly sessionId: SessionId;\n\treadonly sessionNumericUuid: NumericUuid;\n\treadonly expectedOverride: string | undefined;\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/** The compressors used in this network */\n\tprivate readonly compressors: ClientMap<IdCompressor>;\n\t/** The log of operations seen by the server so far. Append-only. */\n\tprivate readonly serverOperations: (\n\t\t| [creationRange: IdCreationRange, opSpaceIds: OpSpaceCompressedId[], clientFrom: Client]\n\t\t| number\n\t)[] = [];\n\t/** An index into `serverOperations` for each client which represents how many operations have been delivered to that client */\n\tprivate readonly clientProgress: ClientMap<number>;\n\t/** All ids (local and sequenced) that a client has created or received, in order. */\n\tprivate readonly idLogs: ClientMap<TestIdData[]>;\n\t/** All ids that a client has received from the server, in order. */\n\tprivate readonly sequencedIdLogs: ClientMap<TestIdData[]>;\n\n\tpublic constructor(\n\t\tpublic readonly initialClusterSize = 5,\n\t\tprivate readonly onIdReceived?: (network: IdCompressorTestNetwork, clientTo: Client, ids: TestIdData[]) => void\n\t) {\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 = createCompressor(client, initialClusterSize, attributionIds.get(client));\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 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(_, property) {\n\t\t\t\tconst compressor = compressors.get(client);\n\t\t\t\treturn compressor[property];\n\t\t\t},\n\t\t\tset(_, property, value): boolean {\n\t\t\t\tconst compressor = compressors.get(client);\n\t\t\t\tcompressor[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 * Submit a capacity change operation to the network. It will not take effect immediately but will be processed in sequence order.\n\t */\n\tpublic enqueueCapacityChange(newClusterCapacity: number): void {\n\t\tthis.serverOperations.push(newClusterCapacity);\n\t}\n\n\tprivate addNewId(\n\t\tclient: Client,\n\t\tid: SessionSpaceCompressedId,\n\t\texpectedOverride: string | undefined,\n\t\toriginatingClient: Client,\n\t\tisSequenced: boolean\n\t): void {\n\t\tconst idData = {\n\t\t\tid,\n\t\t\toriginatingClient,\n\t\t\tsessionId: sessionIds.get(originatingClient),\n\t\t\tsessionNumericUuid: sessionNumericUuids.get(originatingClient),\n\t\t\texpectedOverride,\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\tthis.onIdReceived?.(this, client, clientIds);\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(client: Client, numIds: number): OpSpaceCompressedId[];\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(client: Client, numIds: number, overrides: { [index: number]: string }): IdCreationRange;\n\n\tpublic allocateAndSendIds(\n\t\tclient: Client,\n\t\tnumIds: number,\n\t\toverrides: { [index: number]: string } = {}\n\t): OpSpaceCompressedId[] | IdCreationRange {\n\t\tassert(numIds > 0, 'Must allocate a non-zero number of IDs');\n\t\tconst compressor = this.compressors.get(client);\n\t\tlet nextIdIndex = 0;\n\t\tconst opSpaceIds: OpSpaceCompressedId[] = [];\n\t\tfor (const [overrideIndex, uuid] of Object.entries(overrides)\n\t\t\t.map(([id, uuid]) => [Number.parseInt(id, 10), uuid] as [number, string])\n\t\t\t.sort(([a], [b]) => a - b)) {\n\t\t\twhile (nextIdIndex < overrideIndex) {\n\t\t\t\tconst newId = compressor.generateCompressedId();\n\t\t\t\topSpaceIds.push(compressor.normalizeToOpSpace(newId));\n\t\t\t\tthis.addNewId(client, newId, undefined, client, false);\n\t\t\t\tnextIdIndex += 1;\n\t\t\t}\n\t\t\tconst newOverrideId = compressor.generateCompressedId(uuid);\n\t\t\topSpaceIds.push(compressor.normalizeToOpSpace(newOverrideId));\n\t\t\tthis.addNewId(client, newOverrideId, uuid, client, false);\n\t\t\tnextIdIndex += 1;\n\t\t}\n\t\tconst numTrailingIds = numIds - nextIdIndex;\n\t\tif (numTrailingIds > 0) {\n\t\t\tconst sessionSpaceIds = generateCompressedIds(compressor, numTrailingIds);\n\t\t\tfor (let i = 0; i < numTrailingIds; i++) {\n\t\t\t\tthis.addNewId(client, sessionSpaceIds[i], undefined, client, false);\n\t\t\t}\n\t\t\tsessionSpaceIds.forEach((id) => opSpaceIds.push(compressor.normalizeToOpSpace(id)));\n\t\t}\n\t\tconst creationRange = compressor.takeNextCreationRange();\n\t\tthis.serverOperations.push([creationRange, opSpaceIds, client]);\n\t\treturn nextIdIndex === 0 ? opSpaceIds : creationRange;\n\t}\n\n\t/**\n\t * Delivers all undelivered ID ranges and cluster capacity changes from the server to the target clients.\n\t */\n\tpublic deliverOperations(clientTakingDelivery: DestinationClient) {\n\t\tfor (const [clientTo, compressorTo] of this.getTargetCompressors(clientTakingDelivery)) {\n\t\t\tfor (let i = this.clientProgress.get(clientTo); i < this.serverOperations.length; i++) {\n\t\t\t\tconst operation = this.serverOperations[i];\n\t\t\t\tif (typeof operation === 'number') {\n\t\t\t\t\tcompressorTo.clusterCapacity = operation;\n\t\t\t\t} else {\n\t\t\t\t\tconst [range, opSpaceIds, clientFrom] = operation;\n\t\t\t\t\tcompressorTo.finalizeCreationRange(range);\n\n\t\t\t\t\tconst ids = getIds(range);\n\t\t\t\t\tif (ids !== undefined) {\n\t\t\t\t\t\tlet overrideIndex = 0;\n\t\t\t\t\t\tconst overrides = ids.overrides;\n\t\t\t\t\t\tfor (const id of opSpaceIds) {\n\t\t\t\t\t\t\tlet override: string | undefined;\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\toverrides !== undefined &&\n\t\t\t\t\t\t\t\toverrideIndex < overrides.length &&\n\t\t\t\t\t\t\t\tid === overrides[overrideIndex][0]\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\toverride = overrides[overrideIndex][1];\n\t\t\t\t\t\t\t\toverrideIndex++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst sessionSpaceId = compressorTo.normalizeToSessionSpace(id, range.sessionId);\n\t\t\t\t\t\t\tthis.addNewId(clientTo, sessionSpaceId, override, clientFrom, true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tassert(overrideIndex === (overrides?.length ?? 0));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.clientProgress.set(clientTo, this.serverOperations.length);\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 maxLogLength = sequencedLogs.map(([_, data]) => data.length).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<string>();\n\t\tconst finalIds = new Set<FinalCompressedId>();\n\t\tconst idIndicesAggregator = new Map<Client, number>();\n\n\t\tfunction* getLogIndices(\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\tconst creator: [creator: Client, override?: string][] = [];\n\t\t\tlet originatingClient: Client | undefined;\n\t\t\tlet localCount = 0;\n\t\t\tlet rowCount = 0;\n\t\t\tfor (const [current, next] of getLogIndices(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.originatingClient, () => 0);\n\t\t\t\toriginatingClient ??= idDataA.originatingClient;\n\t\t\t\tassert(\n\t\t\t\t\tidDataA.originatingClient === originatingClient,\n\t\t\t\t\t'Test infra gave wrong originating client to TestIdData'\n\t\t\t\t);\n\t\t\t\tconst attributionA = compressorA.attributeId(idDataA.id);\n\t\t\t\tif (attributionA !== attributionIds.get(idDataA.originatingClient)) {\n\t\t\t\t\t// Unification\n\t\t\t\t\texpectDefined(idDataA.expectedOverride);\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\tlocalCount++;\n\t\t\t\t\texpect(idDataA.sessionId).to.equal(this.compressors.get(originatingClient).localSessionId);\n\t\t\t\t\texpect(creator.length === 0 || creator[creator.length - 1][1] === idDataA.expectedOverride).to.be\n\t\t\t\t\t\t.true;\n\t\t\t\t\tcreator.push([originatingClient, idDataA.expectedOverride]);\n\t\t\t\t}\n\n\t\t\t\tconst uuidASessionSpace = compressorA.decompress(sessionSpaceIdA);\n\t\t\t\tif (idDataA.expectedOverride !== undefined) {\n\t\t\t\t\texpect(uuidASessionSpace).to.equal(idDataA.expectedOverride);\n\t\t\t\t} else {\n\t\t\t\t\texpect(uuidASessionSpace).to.equal(stableIdFromNumericUuid(idDataA.sessionNumericUuid, idIndex));\n\t\t\t\t}\n\t\t\t\texpect(compressorA.recompress(uuidASessionSpace)).to.equal(sessionSpaceIdA);\n\t\t\t\tuuids.add(uuidASessionSpace);\n\t\t\t\tconst opSpaceIdA = compressorA.normalizeToOpSpace(sessionSpaceIdA);\n\t\t\t\tif (isLocalId(opSpaceIdA)) {\n\t\t\t\t\texpect.fail('IDs should have been finalized.');\n\t\t\t\t\tfail();\n\t\t\t\t}\n\t\t\t\texpect(compressorA.normalizeToSessionSpace(opSpaceIdA, compressorA.localSessionId)).equals(\n\t\t\t\t\tsessionSpaceIdA\n\t\t\t\t);\n\t\t\t\tfinalIds.add(opSpaceIdA);\n\t\t\t\tconst uuidAOpSpace = compressorA.decompress(opSpaceIdA);\n\n\t\t\t\texpect(uuidASessionSpace).to.equal(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\texpect(uuidASessionSpace).to.equal(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\texpect(opSpaceIdA).to.equal(opSpaceIdB);\n\t\t\t\t\tif (isLocalId(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(opSpaceIdB);\n\t\t\t\t\texpect(uuidAOpSpace).to.equal(uuidBOpSpace);\n\t\t\t\t}\n\n\t\t\t\trowCount += 1;\n\t\t\t}\n\n\t\t\t// A local count === 0 indicates the ID was created as an eager final, and thus cannot have had an\n\t\t\t// override to unify.\n\t\t\tif (rowCount === this.sequencedIdLogs.size && localCount <= 1) {\n\t\t\t\texpect(localCount).to.lessThanOrEqual(1);\n\t\t\t\tfor (const [[compressor, { id, originatingClient }]] of getLogIndices(i)) {\n\t\t\t\t\texpect(compressor.attributeId(id)).to.equal(attributionIds.get(originatingClient));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\texpect(uuids.size).to.equal(finalIds.size);\n\t\t\tassert(originatingClient !== undefined);\n\t\t\tidIndicesAggregator.set(\n\t\t\t\toriginatingClient,\n\t\t\t\tassertNotUndefined(idIndicesAggregator.get(originatingClient)) + 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): [SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession, IdCompressor] {\n\tif (withSession) {\n\t\tconst serialized = compressor.serialize(withSession);\n\t\treturn [serialized, IdCompressor.deserialize(serialized)];\n\t}\n\n\tconst nonLocalSerialized = compressor.serialize(withSession);\n\treturn [nonLocalSerialized, IdCompressor.deserialize(nonLocalSerialized, createSessionId())];\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 expectSerializes(\n\t\twithSession: boolean\n\t): SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession {\n\t\tlet serialized: SerializedIdCompressorWithOngoingSession | 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\tconst chainCount: number[] = [];\n\t\tfor (let i = 0; i < serialized.sessions.length; i++) {\n\t\t\tchainCount[i] = 0;\n\t\t}\n\t\tconst chainProcessed: number[] = [...chainCount];\n\n\t\tfor (const cluster of serialized.clusters) {\n\t\t\tconst [sessionIndex] = cluster;\n\t\t\texpect(sessionIndex < serialized.sessions.length);\n\t\t\tchainCount[sessionIndex]++;\n\t\t}\n\n\t\tfor (const cluster of serialized.clusters) {\n\t\t\tconst [sessionIndex, capacity, maybeSize] = cluster;\n\t\t\tconst chainIndex = chainProcessed[sessionIndex];\n\t\t\tif (chainIndex < chainCount[sessionIndex] - 1) {\n\t\t\t\texpect(maybeSize === undefined);\n\t\t\t} else {\n\t\t\t\texpect(maybeSize === undefined || typeof maybeSize !== 'number' || maybeSize < capacity);\n\t\t\t}\n\t\t\tchainProcessed[sessionIndex]++;\n\t\t}\n\n\t\texpect(compressor.equals(deserialized, withSession)).to.be.true;\n\t\treturn serialized;\n\t}\n\n\treturn [\n\t\texpectSerializes(false) as SerializedIdCompressorWithNoSession,\n\t\texpectSerializes(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\tentry.push(...value);\n\t\t} else {\n\t\t\tto.set(key, [...value]);\n\t\t}\n\t}\n\treturn to;\n}\n\ninterface AllocateIds {\n\ttype: 'allocateIds';\n\tclient: Client;\n\tnumIds: number;\n\toverrides: { [index: number]: string };\n}\n\ninterface DeliverOperations {\n\ttype: 'deliverOperations';\n\tclient: DestinationClient;\n}\n\ninterface ChangeCapacity {\n\ttype: 'changeCapacity';\n\tnewSize: number;\n}\n\ninterface GenerateUnifyingIds {\n\ttype: 'generateUnifyingIds';\n\tclientA: Client;\n\tclientB: Client;\n\tuuid: string;\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 = AllocateIds | DeliverOperations | ChangeCapacity | GenerateUnifyingIds | Reconnect | 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/** whether or not the fuzz actions will generate override UUIDs */\n\tincludeOverrides: boolean;\n\t/** maximum cluster size of the network. Default: 25 */\n\tmaxClusterSize?: number;\n\t/** Number of ops between validation ops. Default: 200 */\n\tvalidateInterval?: number;\n}\n\nconst defaultOptions = {\n\tincludeOverrides: false,\n\tmaxClusterSize: 25,\n\tvalidateInterval: 200,\n};\n\nexport function makeOpGenerator(options: OperationGenerationConfig): Generator<Operation, FuzzTestState> {\n\tconst { includeOverrides, maxClusterSize, validateInterval } = { ...defaultOptions, ...options };\n\n\tfunction allocateIdsGenerator({ activeClients, clusterSize, random }: 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\tconst overrides: AllocateIds['overrides'] = {};\n\t\tif (includeOverrides && random.bool(1 / 4)) {\n\t\t\tfor (let j = 0; j < numIds; j++) {\n\t\t\t\tif (random.bool(1 / 3)) {\n\t\t\t\t\toverrides[j] = random.uuid4();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\ttype: 'allocateIds',\n\t\t\tclient,\n\t\t\tnumIds,\n\t\t\toverrides,\n\t\t};\n\t}\n\n\tfunction changeCapacityGenerator({ random }: FuzzTestState): ChangeCapacity {\n\t\treturn {\n\t\t\ttype: 'changeCapacity',\n\t\t\tnewSize: Math.min(Math.floor(random.real(0, 1) ** 2 * maxClusterSize) + 1, maxClusterSize),\n\t\t};\n\t}\n\n\tfunction deliverOperationsGenerator({ random, selectableClients }: FuzzTestState): DeliverOperations {\n\t\treturn {\n\t\t\ttype: 'deliverOperations',\n\t\t\tclient: random.pick([...selectableClients, MetaClient.All]),\n\t\t};\n\t}\n\n\tfunction generateUnifyingIdsGenerator({ activeClients, random }: FuzzTestState): GenerateUnifyingIds {\n\t\tconst clientA = random.pick(activeClients);\n\t\tconst clientB = random.pick(activeClients.filter((c) => c !== clientA));\n\t\treturn { type: 'generateUnifyingIds', clientA, clientB, uuid: random.uuid4() };\n\t}\n\n\tfunction reconnectGenerator({ activeClients, random }: FuzzTestState): Reconnect {\n\t\treturn { type: 'reconnect', client: random.pick(activeClients) };\n\t}\n\n\treturn interleave(\n\t\tcreateWeightedGenerator<Operation, FuzzTestState>([\n\t\t\t[changeCapacityGenerator, 1],\n\t\t\t[allocateIdsGenerator, 8],\n\t\t\t[deliverOperationsGenerator, 4],\n\t\t\t[generateUnifyingIdsGenerator, 1],\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.getTargetCompressors(MetaClient.All).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, overrides }) => {\n\t\t\t\tnetwork.allocateAndSendIds(client, numIds, overrides);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tchangeCapacity: (state, op) => {\n\t\t\t\tnetwork.enqueueCapacityChange(op.newSize);\n\t\t\t\treturn { ...state, clusterSize: op.newSize };\n\t\t\t},\n\t\t\tdeliverOperations: (state, op) => {\n\t\t\t\tnetwork.deliverOperations(op.client);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tgenerateUnifyingIds: (state, { clientA, clientB, uuid }) => {\n\t\t\t\tnetwork.allocateAndSendIds(clientA, 1, { 0: uuid });\n\t\t\t\tnetwork.allocateAndSendIds(clientB, 1, { 0: uuid });\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\tnetwork.deliverOperations(DestinationClient.All);\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 * Converts the supplied integer to a uuid.\n */\nexport function integerToStableId(num: number | bigint): StableId {\n\tconst bigintNum = BigInt(num);\n\tconst upper = bigintNum >> BigInt(74);\n\tconst middle = (bigintNum & (BigInt(0xfff) << BigInt(62))) >> BigInt(62);\n\tconst lower = bigintNum & BigInt('0x3fffffffffffffff');\n\tconst upperString = padToLength(upper.toString(16), '0', 12);\n\tconst middleString = `4${padToLength(middle.toString(16), '0', 3)}`;\n\tconst lowerString = padToLength((BigInt('0x8000000000000000') | BigInt(lower)).toString(16), '0', 16);\n\tconst uuid = upperString + middleString + lowerString;\n\treturn assertIsStableId(\n\t\t`${uuid.substr(0, 8)}-${uuid.substr(8, 4)}-${uuid.substr(12, 4)}-${uuid.substr(16, 4)}-${uuid.substr(20)}`\n\t);\n}\n\n/**\n * Pads the strings to a length of 32 with zeroes.\n */\nexport function padToUuidLength(str: string): string {\n\treturn padToLength(str, '0', 32);\n}\n\nfunction padToLength(str: string, char: string, length: number): string {\n\treturn char.repeat(length - str.length) + str;\n}\n\n/**\n * Helper to generate a fixed number of IDs.\n */\nexport function generateCompressedIds(compressor: IdCompressor, count: number): 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"]}
|
|
1
|
+
{"version":3,"file":"IdCompressorTestUtilities.js","sourceRoot":"","sources":["../../../src/test/utilities/IdCompressorTestUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAEN,uBAAuB,EACvB,UAAU,EACV,UAAU,EACV,kBAAkB,IAAI,sBAAsB,EAC5C,MAAM,EAEN,IAAI,GAEJ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAa,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,SAAS,EA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AW,CAAC;IACtD,OAAO,gBAAgB,CACtB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAC1G,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IAC1C,OAAO,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,WAAW,CAAC,GAAW,EAAE,IAAY,EAAE,MAAc;IAC7D,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAwB,EAAE,KAAa;IAC5E,MAAM,GAAG,GAA+B,EAAE,CAAC;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;QAC/B,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;KAC5C;IACD,OAAO,GAAG,CAAC;AACZ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { expect } from 'chai';\nimport {\n\tGenerator,\n\tcreateWeightedGenerator,\n\tinterleave,\n\tmakeRandom,\n\tperformFuzzActions as performFuzzActionsBase,\n\trepeat,\n\tSaveInfo,\n\ttake,\n\tBaseFuzzTestState,\n} from '@fluid-internal/stochastic-test-utils';\nimport { assert, assertNotUndefined, ClosedMap, fail, getOrCreate } from '../../Common';\nimport { IdCompressor, isLocalId } from '../../id-compressor/IdCompressor';\nimport {\n\tcreateSessionId,\n\tensureSessionUuid,\n\tNumericUuid,\n\tnumericUuidFromStableId,\n\tstableIdFromNumericUuid,\n} from '../../id-compressor/NumericUuid';\nimport {\n\tFinalCompressedId,\n\tSessionId,\n\tStableId,\n\tSessionSpaceCompressedId,\n\tAttributionId,\n\tOpSpaceCompressedId,\n} from '../../Identifiers';\nimport { getIds } from '../../id-compressor/IdRange';\nimport type {\n\tIdCreationRange,\n\tSerializedIdCompressorWithOngoingSession,\n\tSerializedIdCompressorWithNoSession,\n} from '../../id-compressor';\nimport { assertIsStableId, assertIsUuidString } from '../../UuidUtilities';\nimport { expectDefined } from './TestCommon';\n\n/** Identifies a compressor in a network */\nexport enum Client {\n\tClient1 = 'Client1',\n\tClient2 = 'Client2',\n\tClient3 = 'Client3',\n}\n\n/** Identifies a compressor with respect to a specific operation */\nexport enum SemanticClient {\n\tLocalClient = 'LocalClient',\n}\n\n/** Identifies categories of compressors */\nexport enum MetaClient {\n\tAll = 'All',\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 | SemanticClient;\nexport const OriginatingClient = { ...Client, ...SemanticClient };\n\n/** Identifies a compressor to which to send an operation */\nexport type DestinationClient = Client | MetaClient;\nexport const DestinationClient = { ...Client, ...MetaClient };\n\n/**\n * Creates a new compressor with the supplied cluster capacity.\n */\nexport function createCompressor(client: Client, clusterCapacity = 5, attributionId?: AttributionId): IdCompressor {\n\tconst compressor = new IdCompressor(sessionIds.get(client), 1024, attributionId);\n\tcompressor.clusterCapacity = clusterCapacity;\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 = ensureSessionUuid(assertIsStableId(`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 * An array of session uuids corresponding to all non-local `Client` entries.\n */\nexport const sessionNumericUuids = new Map(\n\t[...sessionIds.entries()].map(([client, sessionId]) => {\n\t\treturn [client, numericUuidFromStableId(sessionId)];\n\t})\n) as ClientMap<NumericUuid>;\n\nexport const attributionIds = new Map(\n\tObject.values(Client).map((c, i) => [\n\t\tc,\n\t\tassertIsUuidString(`00000000-0000-0000-0000-${(i + 1).toString(16).padStart(12, '0')}`),\n\t])\n) as ClientMap<AttributionId>;\n\n/** An immutable view of an `IdCompressor` */\nexport interface ReadonlyIdCompressor\n\textends Omit<\n\t\tIdCompressor,\n\t\t'generateCompressedId' | 'generateCompressedIdRange' | 'takeNextCreationRange' | 'finalizeCreationRange'\n\t> {\n\treadonly clusterCapacity: number;\n}\n\n/** Information about a generated ID in a network to be validated by tests */\nexport interface TestIdData {\n\treadonly id: SessionSpaceCompressedId;\n\treadonly originatingClient: Client;\n\treadonly sessionId: SessionId;\n\treadonly sessionNumericUuid: NumericUuid;\n\treadonly expectedOverride: string | undefined;\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/** The compressors used in this network */\n\tprivate readonly compressors: ClientMap<IdCompressor>;\n\t/** The log of operations seen by the server so far. Append-only. */\n\tprivate readonly serverOperations: (\n\t\t| [creationRange: IdCreationRange, opSpaceIds: OpSpaceCompressedId[], clientFrom: Client]\n\t\t| number\n\t)[] = [];\n\t/** An index into `serverOperations` for each client which represents how many operations have been delivered to that client */\n\tprivate readonly clientProgress: ClientMap<number>;\n\t/** All ids (local and sequenced) that a client has created or received, in order. */\n\tprivate readonly idLogs: ClientMap<TestIdData[]>;\n\t/** All ids that a client has received from the server, in order. */\n\tprivate readonly sequencedIdLogs: ClientMap<TestIdData[]>;\n\n\tpublic constructor(\n\t\tpublic readonly initialClusterSize = 5,\n\t\tprivate readonly onIdReceived?: (network: IdCompressorTestNetwork, clientTo: Client, ids: TestIdData[]) => void\n\t) {\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 = createCompressor(client, initialClusterSize, attributionIds.get(client));\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(_, property) {\n\t\t\t\tconst compressor = compressors.get(client);\n\t\t\t\treturn compressor[property];\n\t\t\t},\n\t\t\tset(_, property, value): boolean {\n\t\t\t\tconst compressor = compressors.get(client);\n\t\t\t\tcompressor[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 * Submit a capacity change operation to the network. It will not take effect immediately but will be processed in sequence order.\n\t */\n\tpublic enqueueCapacityChange(newClusterCapacity: number): void {\n\t\tthis.serverOperations.push(newClusterCapacity);\n\t}\n\n\tprivate addNewId(\n\t\tclient: Client,\n\t\tid: SessionSpaceCompressedId,\n\t\texpectedOverride: string | undefined,\n\t\toriginatingClient: Client,\n\t\tisSequenced: boolean\n\t): void {\n\t\tconst idData = {\n\t\t\tid,\n\t\t\toriginatingClient,\n\t\t\tsessionId: sessionIds.get(originatingClient),\n\t\t\tsessionNumericUuid: sessionNumericUuids.get(originatingClient),\n\t\t\texpectedOverride,\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\tthis.onIdReceived?.(this, client, clientIds);\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(client: Client, numIds: number): OpSpaceCompressedId[];\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(client: Client, numIds: number, overrides: { [index: number]: string }): IdCreationRange;\n\n\tpublic allocateAndSendIds(\n\t\tclient: Client,\n\t\tnumIds: number,\n\t\toverrides: { [index: number]: string } = {}\n\t): OpSpaceCompressedId[] | IdCreationRange {\n\t\tassert(numIds > 0, 'Must allocate a non-zero number of IDs');\n\t\tconst compressor = this.compressors.get(client);\n\t\tlet nextIdIndex = 0;\n\t\tconst opSpaceIds: OpSpaceCompressedId[] = [];\n\t\tfor (const [overrideIndex, uuid] of Object.entries(overrides)\n\t\t\t.map(([id, uuid]) => [Number.parseInt(id, 10), uuid] as [number, string])\n\t\t\t.sort(([a], [b]) => a - b)) {\n\t\t\twhile (nextIdIndex < overrideIndex) {\n\t\t\t\tconst newId = compressor.generateCompressedId();\n\t\t\t\topSpaceIds.push(compressor.normalizeToOpSpace(newId));\n\t\t\t\tthis.addNewId(client, newId, undefined, client, false);\n\t\t\t\tnextIdIndex += 1;\n\t\t\t}\n\t\t\tconst newOverrideId = compressor.generateCompressedId(uuid);\n\t\t\topSpaceIds.push(compressor.normalizeToOpSpace(newOverrideId));\n\t\t\tthis.addNewId(client, newOverrideId, uuid, client, false);\n\t\t\tnextIdIndex += 1;\n\t\t}\n\t\tconst numTrailingIds = numIds - nextIdIndex;\n\t\tif (numTrailingIds > 0) {\n\t\t\tconst sessionSpaceIds = generateCompressedIds(compressor, numTrailingIds);\n\t\t\tfor (let i = 0; i < numTrailingIds; i++) {\n\t\t\t\tthis.addNewId(client, sessionSpaceIds[i], undefined, client, false);\n\t\t\t}\n\t\t\tsessionSpaceIds.forEach((id) => opSpaceIds.push(compressor.normalizeToOpSpace(id)));\n\t\t}\n\t\tconst creationRange = compressor.takeNextCreationRange();\n\t\tthis.serverOperations.push([creationRange, opSpaceIds, client]);\n\t\treturn nextIdIndex === 0 ? opSpaceIds : creationRange;\n\t}\n\n\t/**\n\t * Delivers all undelivered ID ranges and cluster capacity changes from the server to the target clients.\n\t */\n\tpublic deliverOperations(clientTakingDelivery: Client, opsToDeliver?: number);\n\n\t/**\n\t * Delivers all undelivered ID ranges and cluster capacity changes from the server to the target clients.\n\t */\n\tpublic deliverOperations(clientTakingDelivery: DestinationClient);\n\n\t/**\n\t * Delivers all undelivered ID ranges and cluster capacity changes from the server to the target clients.\n\t */\n\tpublic deliverOperations(clientTakingDelivery: DestinationClient, opsToDeliver?: number) {\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.clientProgress.get(clientTakingDelivery) + opsToDeliver\n\t\t\t\t\t: this.serverOperations.length;\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 operation = this.serverOperations[i];\n\t\t\t\tif (typeof operation === 'number') {\n\t\t\t\t\tcompressorTo.clusterCapacity = operation;\n\t\t\t\t} else {\n\t\t\t\t\tconst [range, opSpaceIds, clientFrom] = operation;\n\t\t\t\t\tcompressorTo.finalizeCreationRange(range);\n\n\t\t\t\t\tconst ids = getIds(range);\n\t\t\t\t\tif (ids !== undefined) {\n\t\t\t\t\t\tlet overrideIndex = 0;\n\t\t\t\t\t\tconst overrides = ids.overrides;\n\t\t\t\t\t\tfor (const id of opSpaceIds) {\n\t\t\t\t\t\t\tlet override: string | undefined;\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\toverrides !== undefined &&\n\t\t\t\t\t\t\t\toverrideIndex < overrides.length &&\n\t\t\t\t\t\t\t\tid === overrides[overrideIndex][0]\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\toverride = overrides[overrideIndex][1];\n\t\t\t\t\t\t\t\toverrideIndex++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst sessionSpaceId = compressorTo.normalizeToSessionSpace(id, range.sessionId);\n\t\t\t\t\t\t\tthis.addNewId(clientTo, sessionSpaceId, override, clientFrom, true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tassert(overrideIndex === (overrides?.length ?? 0));\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\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 uuids = 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\texpect(!uuids.has(uuid), 'Duplicate UUID generated.');\n\t\t\t\tuuids.add(uuid);\n\t\t\t}\n\t\t}\n\n\t\tconst maxLogLength = sequencedLogs.map(([_, data]) => data.length).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<string>();\n\t\tconst finalIds = new Set<FinalCompressedId>();\n\t\tconst idIndicesAggregator = new Map<Client, number>();\n\n\t\tfunction* getLogIndices(\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\tconst creator: [creator: Client, override?: string][] = [];\n\t\t\tlet originatingClient: Client | undefined;\n\t\t\tlet localCount = 0;\n\t\t\tlet rowCount = 0;\n\t\t\tfor (const [current, next] of getLogIndices(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.originatingClient, () => 0);\n\t\t\t\toriginatingClient ??= idDataA.originatingClient;\n\t\t\t\tassert(\n\t\t\t\t\tidDataA.originatingClient === originatingClient,\n\t\t\t\t\t'Test infra gave wrong originating client to TestIdData'\n\t\t\t\t);\n\t\t\t\tconst attributionA = compressorA.attributeId(idDataA.id);\n\t\t\t\tif (attributionA !== attributionIds.get(idDataA.originatingClient)) {\n\t\t\t\t\t// Unification\n\t\t\t\t\texpectDefined(idDataA.expectedOverride);\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\tlocalCount++;\n\t\t\t\t\texpect(idDataA.sessionId).to.equal(this.compressors.get(originatingClient).localSessionId);\n\t\t\t\t\texpect(creator.length === 0 || creator[creator.length - 1][1] === idDataA.expectedOverride).to.be\n\t\t\t\t\t\t.true;\n\t\t\t\t\tcreator.push([originatingClient, idDataA.expectedOverride]);\n\t\t\t\t}\n\n\t\t\t\tconst uuidASessionSpace = compressorA.decompress(sessionSpaceIdA);\n\t\t\t\tif (idDataA.expectedOverride !== undefined) {\n\t\t\t\t\texpect(uuidASessionSpace).to.equal(idDataA.expectedOverride);\n\t\t\t\t} else {\n\t\t\t\t\texpect(uuidASessionSpace).to.equal(stableIdFromNumericUuid(idDataA.sessionNumericUuid, idIndex));\n\t\t\t\t}\n\t\t\t\texpect(compressorA.recompress(uuidASessionSpace)).to.equal(sessionSpaceIdA);\n\t\t\t\tuuids.add(uuidASessionSpace);\n\t\t\t\tconst opSpaceIdA = compressorA.normalizeToOpSpace(sessionSpaceIdA);\n\t\t\t\tif (isLocalId(opSpaceIdA)) {\n\t\t\t\t\texpect.fail('IDs should have been finalized.');\n\t\t\t\t\tfail();\n\t\t\t\t}\n\t\t\t\texpect(compressorA.normalizeToSessionSpace(opSpaceIdA, compressorA.localSessionId)).equals(\n\t\t\t\t\tsessionSpaceIdA\n\t\t\t\t);\n\t\t\t\tfinalIds.add(opSpaceIdA);\n\t\t\t\tconst uuidAOpSpace = compressorA.decompress(opSpaceIdA);\n\n\t\t\t\texpect(uuidASessionSpace).to.equal(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\texpect(uuidASessionSpace).to.equal(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\texpect(opSpaceIdA).to.equal(opSpaceIdB);\n\t\t\t\t\tif (isLocalId(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(opSpaceIdB);\n\t\t\t\t\texpect(uuidAOpSpace).to.equal(uuidBOpSpace);\n\t\t\t\t}\n\n\t\t\t\trowCount += 1;\n\t\t\t}\n\n\t\t\t// A local count === 0 indicates the ID was created as an eager final, and thus cannot have had an\n\t\t\t// override to unify.\n\t\t\tif (rowCount === this.sequencedIdLogs.size && localCount <= 1) {\n\t\t\t\texpect(localCount).to.lessThanOrEqual(1);\n\t\t\t\tfor (const [[compressor, { id, originatingClient }]] of getLogIndices(i)) {\n\t\t\t\t\texpect(compressor.attributeId(id)).to.equal(attributionIds.get(originatingClient));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\texpect(uuids.size).to.equal(finalIds.size);\n\t\t\tassert(originatingClient !== undefined);\n\t\t\tidIndicesAggregator.set(\n\t\t\t\toriginatingClient,\n\t\t\t\tassertNotUndefined(idIndicesAggregator.get(originatingClient)) + 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): [SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession, IdCompressor] {\n\tif (withSession) {\n\t\tconst serialized = compressor.serialize(withSession);\n\t\treturn [serialized, IdCompressor.deserialize(serialized)];\n\t}\n\n\tconst nonLocalSerialized = compressor.serialize(withSession);\n\treturn [nonLocalSerialized, IdCompressor.deserialize(nonLocalSerialized, createSessionId())];\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 expectSerializes(\n\t\twithSession: boolean\n\t): SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession {\n\t\tlet serialized: SerializedIdCompressorWithOngoingSession | 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\tconst chainCount: number[] = [];\n\t\tfor (let i = 0; i < serialized.sessions.length; i++) {\n\t\t\tchainCount[i] = 0;\n\t\t}\n\t\tconst chainProcessed: number[] = [...chainCount];\n\n\t\tfor (const cluster of serialized.clusters) {\n\t\t\tconst [sessionIndex] = cluster;\n\t\t\texpect(sessionIndex < serialized.sessions.length).to.be.true;\n\t\t\tchainCount[sessionIndex]++;\n\t\t}\n\n\t\tfor (const cluster of serialized.clusters) {\n\t\t\tconst [sessionIndex, capacity, maybeSize] = cluster;\n\t\t\tconst chainIndex = chainProcessed[sessionIndex];\n\t\t\tif (chainIndex < chainCount[sessionIndex] - 1) {\n\t\t\t\texpect(typeof maybeSize !== 'number').to.be.true;\n\t\t\t} else {\n\t\t\t\texpect(maybeSize === undefined || typeof maybeSize !== 'number' || maybeSize < capacity).to.be.true;\n\t\t\t}\n\t\t\tchainProcessed[sessionIndex]++;\n\t\t}\n\n\t\texpect(compressor.equals(deserialized, withSession)).to.be.true;\n\t\treturn serialized;\n\t}\n\n\treturn [\n\t\texpectSerializes(false) as SerializedIdCompressorWithNoSession,\n\t\texpectSerializes(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\tentry.push(...value);\n\t\t} else {\n\t\t\tto.set(key, [...value]);\n\t\t}\n\t}\n\treturn to;\n}\n\ninterface AllocateIds {\n\ttype: 'allocateIds';\n\tclient: Client;\n\tnumIds: number;\n\toverrides: { [index: number]: string };\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\tnewSize: number;\n}\n\ninterface GenerateUnifyingIds {\n\ttype: 'generateUnifyingIds';\n\tclientA: Client;\n\tclientB: Client;\n\tuuid: string;\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| DeliverSomeOperations\n\t| DeliverAllOperations\n\t| ChangeCapacity\n\t| GenerateUnifyingIds\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/** whether or not the fuzz actions will generate override UUIDs */\n\tincludeOverrides: boolean;\n\t/** maximum cluster size of the network. Default: 25 */\n\tmaxClusterSize?: number;\n\t/** Number of ops between validation ops. Default: 200 */\n\tvalidateInterval?: number;\n}\n\nconst defaultOptions = {\n\tincludeOverrides: false,\n\tmaxClusterSize: 25,\n\tvalidateInterval: 200,\n};\n\nexport function makeOpGenerator(options: OperationGenerationConfig): Generator<Operation, FuzzTestState> {\n\tconst { includeOverrides, maxClusterSize, validateInterval } = { ...defaultOptions, ...options };\n\n\tfunction allocateIdsGenerator({ activeClients, clusterSize, random }: 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\tconst overrides: AllocateIds['overrides'] = {};\n\t\tif (includeOverrides && random.bool(1 / 4)) {\n\t\t\tfor (let j = 0; j < numIds; j++) {\n\t\t\t\tif (random.bool(1 / 3)) {\n\t\t\t\t\toverrides[j] = random.uuid4();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\ttype: 'allocateIds',\n\t\t\tclient,\n\t\t\tnumIds,\n\t\t\toverrides,\n\t\t};\n\t}\n\n\tfunction changeCapacityGenerator({ random }: FuzzTestState): ChangeCapacity {\n\t\treturn {\n\t\t\ttype: 'changeCapacity',\n\t\t\tnewSize: Math.min(Math.floor(random.real(0, 1) ** 2 * maxClusterSize) + 1, maxClusterSize),\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((c) => network.getPendingOperations(c) > 0);\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 generateUnifyingIdsGenerator({ activeClients, random }: FuzzTestState): GenerateUnifyingIds {\n\t\tconst clientA = random.pick(activeClients);\n\t\tconst clientB = random.pick(activeClients.filter((c) => c !== clientA));\n\t\treturn { type: 'generateUnifyingIds', clientA, clientB, uuid: random.uuid4() };\n\t}\n\n\tfunction reconnectGenerator({ activeClients, random }: FuzzTestState): Reconnect {\n\t\treturn { type: 'reconnect', client: random.pick(activeClients) };\n\t}\n\n\treturn interleave(\n\t\tcreateWeightedGenerator<Operation, FuzzTestState>([\n\t\t\t[changeCapacityGenerator, 1],\n\t\t\t[allocateIdsGenerator, 16],\n\t\t\t[deliverAllOperationsGenerator, 2],\n\t\t\t[deliverSomeOperationsGenerator, 6],\n\t\t\t[generateUnifyingIdsGenerator, 2],\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.getTargetCompressors(MetaClient.All).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, overrides }) => {\n\t\t\t\tnetwork.allocateAndSendIds(client, numIds, overrides);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tchangeCapacity: (state, op) => {\n\t\t\t\tnetwork.enqueueCapacityChange(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\tgenerateUnifyingIds: (state, { clientA, clientB, uuid }) => {\n\t\t\t\tnetwork.allocateAndSendIds(clientA, 1, { 0: uuid });\n\t\t\t\tnetwork.allocateAndSendIds(clientB, 1, { 0: uuid });\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\tnetwork.deliverOperations(DestinationClient.All);\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 * Converts the supplied integer to a uuid.\n */\nexport function integerToStableId(num: number | bigint): StableId {\n\tconst bigintNum = BigInt(num);\n\tconst upper = bigintNum >> BigInt(74);\n\tconst middle = (bigintNum & (BigInt(0xfff) << BigInt(62))) >> BigInt(62);\n\tconst lower = bigintNum & BigInt('0x3fffffffffffffff');\n\tconst upperString = padToLength(upper.toString(16), '0', 12);\n\tconst middleString = `4${padToLength(middle.toString(16), '0', 3)}`;\n\tconst lowerString = padToLength((BigInt('0x8000000000000000') | BigInt(lower)).toString(16), '0', 16);\n\tconst uuid = upperString + middleString + lowerString;\n\treturn assertIsStableId(\n\t\t`${uuid.substr(0, 8)}-${uuid.substr(8, 4)}-${uuid.substr(12, 4)}-${uuid.substr(16, 4)}-${uuid.substr(20)}`\n\t);\n}\n\n/**\n * Pads the strings to a length of 32 with zeroes.\n */\nexport function padToUuidLength(str: string): string {\n\treturn padToLength(str, '0', 32);\n}\n\nfunction padToLength(str: string, char: string, length: number): string {\n\treturn char.repeat(length - str.length) + str;\n}\n\n/**\n * Helper to generate a fixed number of IDs.\n */\nexport function generateCompressedIds(compressor: IdCompressor, count: number): 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-experimental/tree",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "Distributed tree",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
40
40
|
"@fluidframework/common-utils": "^0.32.2",
|
|
41
|
-
"@fluidframework/container-definitions": "^1.3.
|
|
42
|
-
"@fluidframework/core-interfaces": "^1.3.
|
|
43
|
-
"@fluidframework/datastore-definitions": "^1.3.
|
|
41
|
+
"@fluidframework/container-definitions": "^1.3.4",
|
|
42
|
+
"@fluidframework/core-interfaces": "^1.3.4",
|
|
43
|
+
"@fluidframework/datastore-definitions": "^1.3.4",
|
|
44
44
|
"@fluidframework/protocol-definitions": "^0.1028.2000",
|
|
45
|
-
"@fluidframework/runtime-definitions": "^1.3.
|
|
46
|
-
"@fluidframework/shared-object-base": "^1.3.
|
|
47
|
-
"@fluidframework/telemetry-utils": "^1.3.
|
|
45
|
+
"@fluidframework/runtime-definitions": "^1.3.4",
|
|
46
|
+
"@fluidframework/shared-object-base": "^1.3.4",
|
|
47
|
+
"@fluidframework/telemetry-utils": "^1.3.4",
|
|
48
48
|
"buffer": "^6.0.3",
|
|
49
49
|
"denque": "^1.5.1",
|
|
50
50
|
"lru-cache": "^6.0.0",
|
|
@@ -52,19 +52,19 @@
|
|
|
52
52
|
"uuid": "^8.3.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@fluid-internal/stochastic-test-utils": "^1.3.
|
|
55
|
+
"@fluid-internal/stochastic-test-utils": "^1.3.4",
|
|
56
56
|
"@fluid-tools/benchmark": "^0.40.0",
|
|
57
57
|
"@fluidframework/build-common": "^0.24.0",
|
|
58
|
-
"@fluidframework/container-loader": "^1.3.
|
|
59
|
-
"@fluidframework/container-runtime": "^1.3.
|
|
58
|
+
"@fluidframework/container-loader": "^1.3.4",
|
|
59
|
+
"@fluidframework/container-runtime": "^1.3.4",
|
|
60
60
|
"@fluidframework/eslint-config-fluid": "^0.28.2000",
|
|
61
|
-
"@fluidframework/mocha-test-setup": "^1.3.
|
|
62
|
-
"@fluidframework/runtime-utils": "^1.3.
|
|
63
|
-
"@fluidframework/test-driver-definitions": "^1.3.
|
|
64
|
-
"@fluidframework/test-drivers": "^1.3.
|
|
65
|
-
"@fluidframework/test-runtime-utils": "^1.3.
|
|
66
|
-
"@fluidframework/test-utils": "^1.3.
|
|
67
|
-
"@fluidframework/undo-redo": "^1.3.
|
|
61
|
+
"@fluidframework/mocha-test-setup": "^1.3.4",
|
|
62
|
+
"@fluidframework/runtime-utils": "^1.3.4",
|
|
63
|
+
"@fluidframework/test-driver-definitions": "^1.3.4",
|
|
64
|
+
"@fluidframework/test-drivers": "^1.3.4",
|
|
65
|
+
"@fluidframework/test-runtime-utils": "^1.3.4",
|
|
66
|
+
"@fluidframework/test-utils": "^1.3.4",
|
|
67
|
+
"@fluidframework/undo-redo": "^1.3.4",
|
|
68
68
|
"@microsoft/api-extractor": "^7.22.2",
|
|
69
69
|
"@rushstack/eslint-config": "^2.5.1",
|
|
70
70
|
"@types/lru-cache": "^5.1.0",
|
|
@@ -576,14 +576,14 @@ export class IdCompressor {
|
|
|
576
576
|
const lastKnownFinal =
|
|
577
577
|
this.sessionIdNormalizer.getLastFinalId() ??
|
|
578
578
|
fail('Cluster exists but normalizer does not have an entry for it.');
|
|
579
|
-
const
|
|
579
|
+
const lastAlignedFinalInCluster = (currentBaseFinalId +
|
|
580
580
|
Math.min(currentCluster.count + finalizeCount, currentCluster.capacity) -
|
|
581
581
|
1) as FinalCompressedId;
|
|
582
|
-
if (
|
|
583
|
-
eagerFinalIdCount =
|
|
582
|
+
if (lastAlignedFinalInCluster > lastKnownFinal) {
|
|
583
|
+
eagerFinalIdCount = lastAlignedFinalInCluster - (lastKnownFinal + 1);
|
|
584
584
|
this.sessionIdNormalizer.addFinalIds(
|
|
585
585
|
(lastKnownFinal + 1) as FinalCompressedId,
|
|
586
|
-
|
|
586
|
+
lastAlignedFinalInCluster,
|
|
587
587
|
currentCluster
|
|
588
588
|
);
|
|
589
589
|
}
|
|
@@ -619,9 +619,20 @@ export class IdCompressor {
|
|
|
619
619
|
// overflow = 2: ----
|
|
620
620
|
// localIdPivot^
|
|
621
621
|
// lastFinalizedFinal^
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
|
|
622
|
+
const newLastFinalizedFinal = (currentBaseFinalId +
|
|
623
|
+
currentCluster.count -
|
|
624
|
+
1) as FinalCompressedId;
|
|
625
|
+
assert(
|
|
626
|
+
session.lastFinalizedLocalId !== undefined,
|
|
627
|
+
'Cluster already exists for session but there is no finalized local ID'
|
|
628
|
+
);
|
|
629
|
+
const finalPivot = (newLastFinalizedFinal - overflow + 1) as FinalCompressedId;
|
|
630
|
+
// Inform the normalizer of all IDs that we now know will end up being finalized into this cluster, including the ones
|
|
631
|
+
// that were given out as locals (non-eager) because they exceeded the bounds of the current cluster before it was expanded.
|
|
632
|
+
// It is safe to associate the unfinalized locals with their future final IDs even before the ranges for those locals are
|
|
633
|
+
// actually finalized, because total order broadcast guarantees that any usage of those final IDs will be observed after
|
|
634
|
+
// the finalization of the ranges.
|
|
635
|
+
this.sessionIdNormalizer.registerFinalIdBlock(finalPivot, expansionAmount, currentCluster);
|
|
625
636
|
this.logger?.sendTelemetryEvent({
|
|
626
637
|
eventName: 'IdCompressor:ClusterExpansion',
|
|
627
638
|
sessionId: this.localSessionId,
|
|
@@ -690,8 +701,7 @@ export class IdCompressor {
|
|
|
690
701
|
clusterCapacity: newCapacity,
|
|
691
702
|
clusterCount: remainingCount,
|
|
692
703
|
});
|
|
693
|
-
|
|
694
|
-
this.sessionIdNormalizer.addFinalIds(newBaseFinalId, lastFinalizedFinal, newCluster);
|
|
704
|
+
this.sessionIdNormalizer.registerFinalIdBlock(newBaseFinalId, newCluster.capacity, newCluster);
|
|
695
705
|
}
|
|
696
706
|
|
|
697
707
|
this.checkClusterForCollision(newCluster);
|
|
@@ -975,10 +985,12 @@ export class IdCompressor {
|
|
|
975
985
|
let eagerFinalId: (FinalCompressedId & SessionSpaceCompressedId) | undefined;
|
|
976
986
|
let cluster: IdCluster | undefined;
|
|
977
987
|
if (currentClusterDetails !== undefined) {
|
|
978
|
-
const { clusterBase } = currentClusterDetails;
|
|
979
988
|
cluster = currentClusterDetails.cluster;
|
|
980
989
|
const lastFinalKnown = sessionIdNormalizer.getLastFinalId();
|
|
981
|
-
if (
|
|
990
|
+
if (
|
|
991
|
+
lastFinalKnown !== undefined &&
|
|
992
|
+
lastFinalKnown - currentClusterDetails.clusterBase + 1 < cluster.capacity
|
|
993
|
+
) {
|
|
982
994
|
eagerFinalId = (lastFinalKnown + 1) as FinalCompressedId & SessionSpaceCompressedId;
|
|
983
995
|
}
|
|
984
996
|
}
|
|
@@ -1155,15 +1167,14 @@ export class IdCompressor {
|
|
|
1155
1167
|
const inversionKey = IdCompressor.createInversionKey(override);
|
|
1156
1168
|
const compressionMapping =
|
|
1157
1169
|
this.clustersAndOverridesInversion.get(inversionKey) ?? fail('Bimap is malformed.');
|
|
1158
|
-
|
|
1159
|
-
!IdCompressor.isClusterInfo(compressionMapping) &&
|
|
1170
|
+
return !IdCompressor.isClusterInfo(compressionMapping) &&
|
|
1160
1171
|
!IdCompressor.isUnfinalizedOverride(compressionMapping) &&
|
|
1161
1172
|
compressionMapping.associatedLocalId === id
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
}
|
|
1173
|
+
? compressionMapping.originalOverridingFinal
|
|
1174
|
+
: (id as OpSpaceCompressedId);
|
|
1165
1175
|
}
|
|
1166
|
-
|
|
1176
|
+
const possibleFinal = this.sessionIdNormalizer.getFinalId(id);
|
|
1177
|
+
return possibleFinal?.[0] ?? (id as OpSpaceCompressedId);
|
|
1167
1178
|
}
|
|
1168
1179
|
const [correspondingFinal, cluster] =
|
|
1169
1180
|
this.sessionIdNormalizer.getFinalId(id) ??
|
|
@@ -222,16 +222,17 @@ export class SessionIdNormalizer<TRangeObject> {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
/**
|
|
225
|
-
* Registers
|
|
226
|
-
* If there are any local IDs at the tip of session-space that do not have a corresponding final,
|
|
227
|
-
* the first of those. Otherwise, will be registered as the next ID in session space in creation order.
|
|
225
|
+
* Registers one or more final IDs with this normalizer.
|
|
226
|
+
* If there are any local IDs at the tip of session-space that do not have a corresponding final, they will be registered (aligned)
|
|
227
|
+
* starting with the first of those. Otherwise, will be registered as the next ID in session space in creation order.
|
|
228
228
|
*
|
|
229
|
+
* An example:
|
|
229
230
|
* Locals: [-1, -2, X, -4]
|
|
230
231
|
* Finals: [ 0, 1, 2, X]
|
|
231
232
|
* Calling `addFinalIds` with first === last === 5 results in the following:
|
|
232
233
|
* Locals: [-1, -2, X, -4]
|
|
233
234
|
* Finals: [ 0, 1, 2, 5]
|
|
234
|
-
*
|
|
235
|
+
* Subsequently calling `addFinalIds` with first === last === 6 results in the following:
|
|
235
236
|
* Locals: [-1, -2, X, -4, X]
|
|
236
237
|
* Finals: [ 0, 1, 2, 5, 6]
|
|
237
238
|
*
|
|
@@ -252,18 +253,8 @@ export class SessionIdNormalizer<TRangeObject> {
|
|
|
252
253
|
finalRangesObj[1] = [firstFinal, lastFinal, rangeObject];
|
|
253
254
|
nextLocal = Math.min(this.nextLocalId, firstLocal - (lastFinal - firstFinal) - 1) as LocalCompressedId;
|
|
254
255
|
} else {
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
let firstAlignedLocal: LocalCompressedId;
|
|
258
|
-
if (isSingle) {
|
|
259
|
-
firstAlignedLocal = firstLocal;
|
|
260
|
-
lastFinalRange = finalRanges;
|
|
261
|
-
} else {
|
|
262
|
-
[firstAlignedLocal, lastFinalRange] = finalRanges.last() ?? fail('Map should be non-empty.');
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
const [firstAlignedFinal, lastAlignedFinal] = lastFinalRange;
|
|
266
|
-
const lastAlignedLocal = firstAlignedLocal - (lastAlignedFinal - firstAlignedFinal);
|
|
256
|
+
const [firstAlignedLocal, lastAlignedLocal, lastAlignedFinal, lastFinalRange] =
|
|
257
|
+
this.getAlignmentOfLastRange(firstLocal, finalRanges);
|
|
267
258
|
nextLocal = Math.min(
|
|
268
259
|
this.nextLocalId,
|
|
269
260
|
lastAlignedLocal - (lastFinal - firstFinal) - 2
|
|
@@ -273,7 +264,7 @@ export class SessionIdNormalizer<TRangeObject> {
|
|
|
273
264
|
} else {
|
|
274
265
|
const alignedLocal = (lastAlignedLocal - 1) as LocalCompressedId;
|
|
275
266
|
let rangeMap: FinalRangesMap<TRangeObject>;
|
|
276
|
-
if (
|
|
267
|
+
if (isSingleRange(finalRanges)) {
|
|
277
268
|
// Convert the single range to a range collection
|
|
278
269
|
rangeMap = SessionIdNormalizer.makeFinalRangesMap();
|
|
279
270
|
rangeMap.append(firstAlignedLocal, lastFinalRange);
|
|
@@ -292,6 +283,70 @@ export class SessionIdNormalizer<TRangeObject> {
|
|
|
292
283
|
this.nextLocalId = nextLocal;
|
|
293
284
|
}
|
|
294
285
|
|
|
286
|
+
/**
|
|
287
|
+
* Alerts the normalizer to the existence of a block of final IDs that are *allocated* (but may not be entirely used).
|
|
288
|
+
*
|
|
289
|
+
* The normalizer may have unaligned (unfinalized) local IDs; any such outstanding locals will be eagerly aligned with
|
|
290
|
+
* as many finals from the registered block as possible.
|
|
291
|
+
*
|
|
292
|
+
* It is important to register blocks via this method as soon as they are created for future eager final generations to be utilized, as such
|
|
293
|
+
* generation is dependant on the normalizer being up-to-date with which local IDs have been aligned with finals. If, for instance,
|
|
294
|
+
* a block of finals is not immediately registered with the normalizer and there are outstanding locals that would have aligned with them,
|
|
295
|
+
* those locals will not be finalized until their creation range is finalized, which could be later if the block was created by an earlier
|
|
296
|
+
* creation range's finalization but is large enough to span them both. In this scenario, no eager finals can be generated until the second
|
|
297
|
+
* creation range is finalized.
|
|
298
|
+
*
|
|
299
|
+
* A usage example:
|
|
300
|
+
* Locals: [-1, -2, X, -4, -5, -6]
|
|
301
|
+
* Finals: [ 0, 1, 2, X, X, X]
|
|
302
|
+
* Calling `registerFinalIdBlock` with firstFinalInBlock === 5 and count === 10 results in the following:
|
|
303
|
+
* Locals: [-1, -2, X, -4, -5, -6]
|
|
304
|
+
* Finals: [ 0, 1, 2, 5, 6, 7]
|
|
305
|
+
* Instead calling `registerFinalIdBlock` with firstFinalInBlock === 5 and count === 2 results in the following:
|
|
306
|
+
* Locals: [-1, -2, X, -4, -5, -6]
|
|
307
|
+
* Finals: [ 0, 1, 2, 5, 6, X]
|
|
308
|
+
*
|
|
309
|
+
*/
|
|
310
|
+
public registerFinalIdBlock(firstFinalInBlock: FinalCompressedId, count: number, rangeObject: TRangeObject): void {
|
|
311
|
+
assert(count >= 1, 'Malformed normalization block.');
|
|
312
|
+
const [firstLocal, [lastLocal, finalRanges]] =
|
|
313
|
+
this.idRanges.last() ?? fail('Final ID block should not be registered before any locals.');
|
|
314
|
+
let unalignedLocalCount: number;
|
|
315
|
+
if (finalRanges === undefined) {
|
|
316
|
+
unalignedLocalCount = firstLocal - lastLocal + 1;
|
|
317
|
+
} else {
|
|
318
|
+
const [_, lastAlignedLocal] = this.getAlignmentOfLastRange(firstLocal, finalRanges);
|
|
319
|
+
unalignedLocalCount = lastAlignedLocal - lastLocal;
|
|
320
|
+
}
|
|
321
|
+
assert(unalignedLocalCount > 0, 'Final ID block should not be registered without an existing local range.');
|
|
322
|
+
const lastFinal = (firstFinalInBlock + Math.min(unalignedLocalCount, count) - 1) as FinalCompressedId;
|
|
323
|
+
this.addFinalIds(firstFinalInBlock, lastFinal, rangeObject);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
private getAlignmentOfLastRange(
|
|
327
|
+
firstLocal: LocalCompressedId,
|
|
328
|
+
finalRanges: FinalRanges<TRangeObject>
|
|
329
|
+
): [
|
|
330
|
+
firstAlignedLocal: LocalCompressedId,
|
|
331
|
+
lastAlignedLocal: LocalCompressedId,
|
|
332
|
+
lastAlignedFinal: FinalCompressedId,
|
|
333
|
+
lastFinalRange: FinalRange<TRangeObject>
|
|
334
|
+
] {
|
|
335
|
+
const isSingle = isSingleRange(finalRanges);
|
|
336
|
+
let lastFinalRange: FinalRange<TRangeObject>;
|
|
337
|
+
let firstAlignedLocal: LocalCompressedId;
|
|
338
|
+
if (isSingle) {
|
|
339
|
+
firstAlignedLocal = firstLocal;
|
|
340
|
+
lastFinalRange = finalRanges;
|
|
341
|
+
} else {
|
|
342
|
+
[firstAlignedLocal, lastFinalRange] = finalRanges.last() ?? fail('Map should be non-empty.');
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const [firstAlignedFinal, lastAlignedFinal] = lastFinalRange;
|
|
346
|
+
const lastAlignedLocal = firstAlignedLocal - (lastAlignedFinal - firstAlignedFinal);
|
|
347
|
+
return [firstAlignedLocal, lastAlignedLocal as LocalCompressedId, lastAlignedFinal, lastFinalRange];
|
|
348
|
+
}
|
|
349
|
+
|
|
295
350
|
/**
|
|
296
351
|
* Returns an enumerable of all session-space IDs known to this normalizer, in creation order.
|
|
297
352
|
*/
|