@fluidframework/id-compressor 2.12.0 → 2.20.0

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.
Files changed (85) hide show
  1. package/.eslintrc.cjs +1 -4
  2. package/CHANGELOG.md +8 -0
  3. package/dist/appendOnlySortedMap.d.ts +37 -16
  4. package/dist/appendOnlySortedMap.d.ts.map +1 -1
  5. package/dist/appendOnlySortedMap.js +39 -21
  6. package/dist/appendOnlySortedMap.js.map +1 -1
  7. package/dist/finalSpace.d.ts +2 -2
  8. package/dist/finalSpace.d.ts.map +1 -1
  9. package/dist/finalSpace.js +5 -5
  10. package/dist/finalSpace.js.map +1 -1
  11. package/dist/idCompressor.d.ts.map +1 -1
  12. package/dist/idCompressor.js +18 -15
  13. package/dist/idCompressor.js.map +1 -1
  14. package/dist/identifiers.d.ts +1 -1
  15. package/dist/identifiers.js +1 -1
  16. package/dist/identifiers.js.map +1 -1
  17. package/dist/package.json +2 -1
  18. package/dist/packageVersion.d.ts +1 -1
  19. package/dist/packageVersion.js +1 -1
  20. package/dist/packageVersion.js.map +1 -1
  21. package/dist/sessions.js.map +1 -1
  22. package/dist/test/appendOnlySortedMap.perf.spec.js.map +1 -1
  23. package/dist/test/appendOnlySortedMap.spec.js.map +1 -1
  24. package/dist/test/idCompressor.perf.spec.js.map +1 -1
  25. package/dist/test/idCompressor.spec.js.map +1 -1
  26. package/dist/test/idCompressorTestUtilities.d.ts +39 -13
  27. package/dist/test/idCompressorTestUtilities.d.ts.map +1 -1
  28. package/dist/test/idCompressorTestUtilities.js +68 -59
  29. package/dist/test/idCompressorTestUtilities.js.map +1 -1
  30. package/dist/test/numericUuid.spec.js.map +1 -1
  31. package/dist/test/sessionSpaceNormalizer.spec.js.map +1 -1
  32. package/dist/test/snapshots/summary.spec.js.map +1 -1
  33. package/dist/test/testCommon.d.ts +5 -1
  34. package/dist/test/testCommon.d.ts.map +1 -1
  35. package/dist/test/testCommon.js +2 -0
  36. package/dist/test/testCommon.js.map +1 -1
  37. package/dist/utilities.d.ts.map +1 -1
  38. package/dist/utilities.js +11 -8
  39. package/dist/utilities.js.map +1 -1
  40. package/lib/appendOnlySortedMap.d.ts +37 -16
  41. package/lib/appendOnlySortedMap.d.ts.map +1 -1
  42. package/lib/appendOnlySortedMap.js +39 -21
  43. package/lib/appendOnlySortedMap.js.map +1 -1
  44. package/lib/finalSpace.d.ts +2 -2
  45. package/lib/finalSpace.d.ts.map +1 -1
  46. package/lib/finalSpace.js +5 -5
  47. package/lib/finalSpace.js.map +1 -1
  48. package/lib/idCompressor.d.ts.map +1 -1
  49. package/lib/idCompressor.js +18 -15
  50. package/lib/idCompressor.js.map +1 -1
  51. package/lib/identifiers.d.ts +1 -1
  52. package/lib/identifiers.js +1 -1
  53. package/lib/identifiers.js.map +1 -1
  54. package/lib/packageVersion.d.ts +1 -1
  55. package/lib/packageVersion.js +1 -1
  56. package/lib/packageVersion.js.map +1 -1
  57. package/lib/sessions.js.map +1 -1
  58. package/lib/test/appendOnlySortedMap.perf.spec.js.map +1 -1
  59. package/lib/test/appendOnlySortedMap.spec.js.map +1 -1
  60. package/lib/test/idCompressor.perf.spec.js.map +1 -1
  61. package/lib/test/idCompressor.spec.js.map +1 -1
  62. package/lib/test/idCompressorTestUtilities.d.ts +39 -13
  63. package/lib/test/idCompressorTestUtilities.d.ts.map +1 -1
  64. package/lib/test/idCompressorTestUtilities.js +43 -34
  65. package/lib/test/idCompressorTestUtilities.js.map +1 -1
  66. package/lib/test/numericUuid.spec.js.map +1 -1
  67. package/lib/test/sessionSpaceNormalizer.spec.js.map +1 -1
  68. package/lib/test/snapshots/summary.spec.js.map +1 -1
  69. package/lib/test/testCommon.d.ts +5 -1
  70. package/lib/test/testCommon.d.ts.map +1 -1
  71. package/lib/test/testCommon.js +2 -0
  72. package/lib/test/testCommon.js.map +1 -1
  73. package/lib/utilities.d.ts.map +1 -1
  74. package/lib/utilities.js +11 -8
  75. package/lib/utilities.js.map +1 -1
  76. package/package.json +9 -9
  77. package/src/appendOnlySortedMap.ts +39 -21
  78. package/src/finalSpace.ts +6 -6
  79. package/src/idCompressor.ts +22 -18
  80. package/src/identifiers.ts +1 -1
  81. package/src/packageVersion.ts +1 -1
  82. package/src/sessions.ts +2 -2
  83. package/src/test/idCompressorTestUtilities.ts +70 -41
  84. package/src/test/testCommon.ts +5 -1
  85. package/src/utilities.ts +12 -9
@@ -13,17 +13,23 @@ import { ReadonlyIdCompressor } from "./testCommon.js";
13
13
  export interface ClosedMap<K, V> extends Omit<Map<K, V>, "delete" | "clear"> {
14
14
  get(key: K): V;
15
15
  }
16
- /** Identifies a compressor in a network */
16
+ /**
17
+ * Identifies a compressor in a network
18
+ */
17
19
  export declare enum Client {
18
20
  Client1 = "Client1",
19
21
  Client2 = "Client2",
20
22
  Client3 = "Client3"
21
23
  }
22
- /** Identifies categories of compressors */
24
+ /**
25
+ * Identifies categories of compressors
26
+ */
23
27
  export declare enum MetaClient {
24
28
  All = "All"
25
29
  }
26
- /** Identifies a compressor inside the network but outside the three specially tracked clients. */
30
+ /**
31
+ * Identifies a compressor inside the network but outside the three specially tracked clients.
32
+ */
27
33
  export declare enum OutsideClient {
28
34
  Remote = "Remote"
29
35
  }
@@ -38,7 +44,9 @@ export declare const OriginatingClient: {
38
44
  Client2: Client.Client2;
39
45
  Client3: Client.Client3;
40
46
  };
41
- /** Identifies a compressor to which to send an operation */
47
+ /**
48
+ * Identifies a compressor to which to send an operation
49
+ */
42
50
  export type DestinationClient = Client | MetaClient;
43
51
  export declare const DestinationClient: {
44
52
  All: MetaClient.All;
@@ -69,7 +77,9 @@ export type ClientMap<T> = ClosedMap<Client, T>;
69
77
  * An array of session ID strings corresponding to all non-local `Client` entries.
70
78
  */
71
79
  export declare const sessionIds: ClientMap<SessionId>;
72
- /** Information about a generated ID in a network to be validated by tests */
80
+ /**
81
+ * Information about a generated ID in a network to be validated by tests
82
+ */
73
83
  export interface TestIdData {
74
84
  readonly id: SessionSpaceCompressedId;
75
85
  readonly originatingClient: OriginatingClient;
@@ -82,15 +92,25 @@ export interface TestIdData {
82
92
  */
83
93
  export declare class IdCompressorTestNetwork {
84
94
  readonly initialClusterSize: number;
85
- /** The compressors used in this network */
95
+ /**
96
+ * The compressors used in this network
97
+ */
86
98
  private readonly compressors;
87
- /** The log of operations seen by the server so far. Append-only. */
99
+ /**
100
+ * The log of operations seen by the server so far. Append-only.
101
+ */
88
102
  private readonly serverOperations;
89
- /** An index into `serverOperations` for each client which represents how many operations have been delivered to that client */
103
+ /**
104
+ * An index into `serverOperations` for each client which represents how many operations have been delivered to that client
105
+ */
90
106
  private readonly clientProgress;
91
- /** All ids (local and sequenced) that a client has created or received, in order. */
107
+ /**
108
+ * All ids (local and sequenced) that a client has created or received, in order.
109
+ */
92
110
  private readonly idLogs;
93
- /** All ids that a client has received from the server, in order. */
111
+ /**
112
+ * All ids that a client has received from the server, in order.
113
+ */
94
114
  private readonly sequencedIdLogs;
95
115
  constructor(initialClusterSize?: number);
96
116
  /**
@@ -209,11 +229,17 @@ interface FuzzTestState extends BaseFuzzTestState {
209
229
  clusterSize: number;
210
230
  }
211
231
  export interface OperationGenerationConfig {
212
- /** maximum cluster size of the network. Default: 25 */
232
+ /**
233
+ * maximum cluster size of the network. Default: 25
234
+ */
213
235
  maxClusterSize?: number;
214
- /** Number of ops between validation ops. Default: 200 */
236
+ /**
237
+ * Number of ops between validation ops. Default: 200
238
+ */
215
239
  validateInterval?: number;
216
- /** Fraction of ID allocations that are from an outside client (not Client1/2/3). */
240
+ /**
241
+ * Fraction of ID allocations that are from an outside client (not Client1/2/3).
242
+ */
217
243
  outsideAllocationFraction?: number;
218
244
  }
219
245
  export declare function makeOpGenerator(options: OperationGenerationConfig): Generator<Operation, FuzzTestState>;
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressorTestUtilities.d.ts","sourceRoot":"","sources":["../../src/test/idCompressorTestUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,iB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uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oFAAoF;IACpF,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACnC;AAQD,wBAAgB,eAAe,CAC9B,OAAO,EAAE,yBAAyB,GAChC,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC,CA4FrC;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC,EAC9C,OAAO,EAAE,uBAAuB,EAChC,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,MAAM,EACvB,gBAAgB,GAAE,OAAc,EAChC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,EACtD,QAAQ,CAAC,EAAE,QAAQ,GACjB,IAAI,CA0DN;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,UAAU,EAAE,YAAY,EACxB,KAAK,EAAE,MAAM,GACX,wBAAwB,EAAE,CAM5B;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAChD,MAAM,CAAC,EAAE,oBAAoB,GAC3B,aAAa,GAAG,iBAAiB,CAAC;AACrC;;;GAGG;AACH,wBAAgB,iCAAiC,CAChD,SAAS,EAAE,SAAS,EACpB,MAAM,CAAC,EAAE,oBAAoB,GAC3B,aAAa,GAAG,iBAAiB,CAAC"}
1
+ {"version":3,"file":"idCompressorTestUtilities.d.ts","sourceRoot":"","sources":["../../src/test/idCompressorTestUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,iBAAiB,EACjB,SAAS,EACT,QAAQ,EAOR,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACN,KAAK,aAAa,EA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AE,aAAa,CAAC,CA4FrC;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC,EAC9C,OAAO,EAAE,uBAAuB,EAChC,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,MAAM,EACvB,gBAAgB,GAAE,OAAc,EAChC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,EACtD,QAAQ,CAAC,EAAE,QAAQ,GACjB,IAAI,CA0DN;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,UAAU,EAAE,YAAY,EACxB,KAAK,EAAE,MAAM,GACX,wBAAwB,EAAE,CAM5B;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAChD,MAAM,CAAC,EAAE,oBAAoB,GAC3B,aAAa,GAAG,iBAAiB,CAAC;AACrC;;;GAGG;AACH,wBAAgB,iCAAiC,CAChD,SAAS,EAAE,SAAS,EACpB,MAAM,CAAC,EAAE,oBAAoB,GAC3B,aAAa,GAAG,iBAAiB,CAAC"}
@@ -2,26 +2,33 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { strict as assert } from "assert";
5
+ // eslint-disable-next-line import/no-nodejs-modules
6
+ import { strict as assert } from "node:assert";
6
7
  import { createWeightedGenerator, interleave, makeRandom, performFuzzActions as performFuzzActionsBase, repeat, take, } from "@fluid-private/stochastic-test-utils";
7
8
  import { IdCompressor } from "../idCompressor.js";
8
9
  import { createIdCompressor, } from "../index.js";
9
10
  import { SessionSpaceNormalizer } from "../sessionSpaceNormalizer.js";
10
11
  import { assertIsSessionId, createSessionId, localIdFromGenCount } from "../utilities.js";
11
12
  import { fail, getOrCreate, incrementStableId, isFinalId, isLocalId, } from "./testCommon.js";
12
- /** Identifies a compressor in a network */
13
+ /**
14
+ * Identifies a compressor in a network
15
+ */
13
16
  export var Client;
14
17
  (function (Client) {
15
18
  Client["Client1"] = "Client1";
16
19
  Client["Client2"] = "Client2";
17
20
  Client["Client3"] = "Client3";
18
21
  })(Client || (Client = {}));
19
- /** Identifies categories of compressors */
22
+ /**
23
+ * Identifies categories of compressors
24
+ */
20
25
  export var MetaClient;
21
26
  (function (MetaClient) {
22
27
  MetaClient["All"] = "All";
23
28
  })(MetaClient || (MetaClient = {}));
24
- /** Identifies a compressor inside the network but outside the three specially tracked clients. */
29
+ /**
30
+ * Identifies a compressor inside the network but outside the three specially tracked clients.
31
+ */
25
32
  export var OutsideClient;
26
33
  (function (OutsideClient) {
27
34
  OutsideClient["Remote"] = "Remote";
@@ -98,7 +105,9 @@ export const sessionIds = makeSessionIds();
98
105
  export class IdCompressorTestNetwork {
99
106
  constructor(initialClusterSize = 5) {
100
107
  this.initialClusterSize = initialClusterSize;
101
- /** The log of operations seen by the server so far. Append-only. */
108
+ /**
109
+ * The log of operations seen by the server so far. Append-only.
110
+ */
102
111
  this.serverOperations = [];
103
112
  const compressors = new Map();
104
113
  const clientProgress = new Map();
@@ -211,6 +220,7 @@ export class IdCompressorTestNetwork {
211
220
  ids: {
212
221
  firstGenCount: 1,
213
222
  count: numIds,
223
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
214
224
  requestedClusterSize: this.getCompressor(Client.Client1)[
215
225
  // eslint-disable-next-line @typescript-eslint/dot-notation
216
226
  "nextRequestedClusterSize"],
@@ -248,9 +258,9 @@ export class IdCompressorTestNetwork {
248
258
  }
249
259
  else {
250
260
  opIndexBound =
251
- opsToDeliver !== undefined
252
- ? this.clientProgress.get(clientTakingDelivery) + opsToDeliver
253
- : this.serverOperations.length;
261
+ opsToDeliver === undefined
262
+ ? this.serverOperations.length
263
+ : this.clientProgress.get(clientTakingDelivery) + opsToDeliver;
254
264
  }
255
265
  for (const [clientTo, compressorTo] of this.getTargetCompressors(clientTakingDelivery)) {
256
266
  for (let i = this.clientProgress.get(clientTo); i < opIndexBound; i++) {
@@ -298,33 +308,33 @@ export class IdCompressorTestNetwork {
298
308
  return localIdsInCreationRange;
299
309
  };
300
310
  // Ensure creation ranges for clients we track contain the correct local ID ranges
301
- this.serverOperations.forEach(([range, opSpaceIds, clientFrom]) => {
311
+ for (const [range, opSpaceIds, clientFrom] of this.serverOperations) {
302
312
  if (clientFrom !== OriginatingClient.Remote) {
303
313
  const localIdsInCreationRange = getLocalIdsInRange(range, opSpaceIds);
304
314
  let localCount = 0;
305
- opSpaceIds.forEach((id) => {
315
+ for (const id of opSpaceIds) {
306
316
  if (isLocalId(id)) {
307
317
  localCount++;
308
318
  assert(localIdsInCreationRange.has(id), "Local ID not in creation range");
309
319
  }
310
- });
320
+ }
311
321
  assert.strictEqual(localCount, localIdsInCreationRange.size, "Local ID count mismatch");
312
322
  }
313
- });
323
+ }
314
324
  const undeliveredRanges = new Map();
315
- this.clientProgress.forEach((progress, client) => {
325
+ for (const [client, progress] of this.clientProgress.entries()) {
316
326
  const ranges = this.serverOperations
317
327
  .slice(progress)
318
328
  .filter((op) => op[2] === client)
319
329
  .map(([range]) => range);
320
330
  undeliveredRanges.set(client, ranges);
321
- });
322
- undeliveredRanges.forEach((ranges, client) => {
331
+ }
332
+ for (const [client, ranges] of undeliveredRanges.entries()) {
323
333
  const compressor = this.compressors.get(client);
324
334
  let firstGenCount;
325
335
  let totalCount = 0;
326
336
  const unionedLocalRanges = new SessionSpaceNormalizer();
327
- ranges.forEach((range) => {
337
+ for (const range of ranges) {
328
338
  assert(range.sessionId === compressor.localSessionId);
329
339
  if (range.ids !== undefined) {
330
340
  // initialize firstGenCount if not set
@@ -332,26 +342,26 @@ export class IdCompressorTestNetwork {
332
342
  firstGenCount = range.ids.firstGenCount;
333
343
  }
334
344
  totalCount += range.ids.count;
335
- range.ids.localIdRanges.forEach(([genCount, count]) => {
345
+ for (const [genCount, count] of range.ids.localIdRanges) {
336
346
  unionedLocalRanges.addLocalRange(genCount, count);
337
- });
347
+ }
338
348
  }
339
- });
349
+ }
340
350
  const retakenRange = compressor.takeUnfinalizedCreationRange();
341
- if (retakenRange.ids !== undefined) {
351
+ if (retakenRange.ids === undefined) {
352
+ assert.strictEqual(totalCount, 0);
353
+ assert.strictEqual(unionedLocalRanges.idRanges.size, 0);
354
+ }
355
+ else {
342
356
  const retakenLocalIds = new SessionSpaceNormalizer();
343
- retakenRange.ids.localIdRanges.forEach(([genCount, count]) => {
357
+ for (const [genCount, count] of retakenRange.ids.localIdRanges) {
344
358
  retakenLocalIds.addLocalRange(genCount, count);
345
- });
359
+ }
346
360
  assert.strictEqual(retakenLocalIds.equals(unionedLocalRanges), true, "Local ID ranges mismatch");
347
361
  assert.strictEqual(retakenRange.ids.count, totalCount, "Count mismatch");
348
362
  assert.strictEqual(retakenRange.ids.firstGenCount, firstGenCount, "Count mismatch");
349
363
  }
350
- else {
351
- assert.strictEqual(totalCount, 0);
352
- assert.strictEqual(unionedLocalRanges.idRanges.size, 0);
353
- }
354
- });
364
+ }
355
365
  // First, ensure all clients each generated a unique ID for each of their own calls to generate.
356
366
  for (const [compressor, ids] of sequencedLogs) {
357
367
  const allUuids = new Set();
@@ -363,6 +373,7 @@ export class IdCompressorTestNetwork {
363
373
  }
364
374
  const maxLogLength = sequencedLogs
365
375
  .map(([_, data]) => data.length)
376
+ // eslint-disable-next-line unicorn/no-array-reduce
366
377
  .reduce((p, n) => Math.max(p, n));
367
378
  function getNextLogWithEntryAt(logsIndex, entryIndex) {
368
379
  for (let i = logsIndex; i < sequencedLogs.length; i++) {
@@ -444,9 +455,7 @@ export class IdCompressorTestNetwork {
444
455
  assert(idCreatorCount <= 1, "Only one client can create an ID.");
445
456
  assert.strictEqual(uuids.size, finalIds.size);
446
457
  assert(originatingSession !== undefined, "Expected originating client to be defined");
447
- idIndicesAggregator.set(originatingSession,
448
- // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
449
- (idIndicesAggregator.get(originatingSession) ??
458
+ idIndicesAggregator.set(originatingSession, (idIndicesAggregator.get(originatingSession) ??
450
459
  fail("Expected pre-existing index for originating client")) + 1);
451
460
  }
452
461
  for (const [compressor] of sequencedLogs) {
@@ -461,7 +470,7 @@ function changeCapacity(compressor, newClusterCapacity) {
461
470
  export function roundtrip(compressor, withSession) {
462
471
  // preserve the capacity request as this property is normally private and resets
463
472
  // to a default on construction (deserialization)
464
- // eslint-disable-next-line @typescript-eslint/dot-notation
473
+ // eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-assignment
465
474
  const capacity = compressor["nextRequestedClusterSize"];
466
475
  if (withSession) {
467
476
  const serialized = compressor.serialize(withSession);
@@ -503,11 +512,11 @@ export function expectSerializes(compressor) {
503
512
  export function mergeArrayMaps(to, from) {
504
513
  for (const [key, value] of from.entries()) {
505
514
  const entry = to.get(key);
506
- if (entry !== undefined) {
507
- entry.push(...value);
515
+ if (entry === undefined) {
516
+ to.set(key, [...value]);
508
517
  }
509
518
  else {
510
- to.set(key, [...value]);
519
+ entry.push(...value);
511
520
  }
512
521
  }
513
522
  return to;
@@ -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,QAAQ,CAAC;AAE1C,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,SAA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C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"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/** Identifies a compressor in a network */\nexport enum Client {\n\tClient1 = \"Client1\",\n\tClient2 = \"Client2\",\n\tClient3 = \"Client3\",\n}\n\n/** Identifies categories of compressors */\nexport enum MetaClient {\n\tAll = \"All\",\n}\n\n/** Identifies a compressor inside the network but outside the three specially tracked clients. */\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/** Identifies a compressor to which to send an operation */\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\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\tcompressor[\"nextRequestedClusterSize\"] = clusterCapacity;\n\t\treturn compressor;\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/** Information about a generated ID in a network to be validated by tests */\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/** 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\tcreationRange: IdCreationRange,\n\t\topSpaceIds: OpSpaceCompressedId[],\n\t\tclientFrom: OriginatingClient,\n\t\tsessionIdFrom: SessionId,\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(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\tchangeCapacity(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: this.getCompressor(Client.Client1)[\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\t\t\t\t\t\"nextRequestedClusterSize\"\n\t\t\t\t\t],\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.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 [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\tthis.serverOperations.forEach(([range, opSpaceIds, clientFrom]) => {\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\topSpaceIds.forEach((id) => {\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\tthis.clientProgress.forEach((progress, client) => {\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\tundeliveredRanges.forEach((ranges, client) => {\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\tranges.forEach((range) => {\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\trange.ids.localIdRanges.forEach(([genCount, count]) => {\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\tconst retakenLocalIds = new SessionSpaceNormalizer();\n\t\t\t\tretakenRange.ids.localIdRanges.forEach(([genCount, count]) => {\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} else {\n\t\t\t\tassert.strictEqual(totalCount, 0);\n\t\t\t\tassert.strictEqual(unionedLocalRanges.idRanges.size, 0);\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.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\t\t\t\t// eslint-disable-next-line @typescript-eslint/restrict-plus-operands\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\nfunction changeCapacity(compressor: IdCompressor, newClusterCapacity: number): void {\n\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\tcompressor[\"nextRequestedClusterSize\"] = newClusterCapacity;\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\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\tconst capacity = compressor[\"nextRequestedClusterSize\"];\n\tif (withSession) {\n\t\tconst serialized = compressor.serialize(withSession);\n\t\tconst roundtripped = IdCompressor.deserialize(serialized);\n\t\tchangeCapacity(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\tchangeCapacity(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\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}\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/** 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\t/** Fraction of ID allocations that are from an outside client (not Client1/2/3). */\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 compressor =\n\t\tsessionIdOrLogger === undefined\n\t\t\t? createIdCompressor()\n\t\t\t: typeof sessionIdOrLogger === \"string\"\n\t\t\t\t? createIdCompressor(sessionIdOrLogger, loggerOrUndefined)\n\t\t\t\t: createIdCompressor(sessionIdOrLogger);\n\t// Permanently put the compressor in a ghost session\n\t(compressor as IdCompressor).startGhostSession(createSessionId());\n\treturn compressor;\n}\n"]}
1
+ {"version":3,"file":"idCompressorTestUtilities.js","sourceRoot":"","sources":["../../src/test/idCompressorTestUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oDAAoD;AACpD,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,aAAa,QAExB;AAOD,MA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C;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACpC,UAAwB,EACxB,KAAa;IAEb,MAAM,GAAG,GAA+B,EAAE,CAAC;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAiBD,MAAM,UAAU,iCAAiC,CAChD,iBAAoD,EACpD,iBAAwC;IAExC,MAAM,UAAU,GACf,iBAAiB,KAAK,SAAS;QAC9B,CAAC,CAAC,kBAAkB,EAAE;QACtB,CAAC,CAAC,OAAO,iBAAiB,KAAK,QAAQ;YACtC,CAAC,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;YAC1D,CAAC,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;IAC3C,oDAAoD;IACnD,UAA2B,CAAC,iBAAiB,CAAC,eAAe,EAAE,CAAC,CAAC;IAClE,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-nodejs-modules\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\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\tcompressor[\"nextRequestedClusterSize\"] = clusterCapacity;\n\t\treturn compressor;\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\tchangeCapacity(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\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\trequestedClusterSize: this.getCompressor(Client.Client1)[\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\t\t\t\t\t\"nextRequestedClusterSize\"\n\t\t\t\t\t],\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\nfunction changeCapacity(compressor: IdCompressor, newClusterCapacity: number): void {\n\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\tcompressor[\"nextRequestedClusterSize\"] = newClusterCapacity;\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\t// eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-assignment\n\tconst capacity: number = compressor[\"nextRequestedClusterSize\"];\n\tif (withSession) {\n\t\tconst serialized = compressor.serialize(withSession);\n\t\tconst roundtripped = IdCompressor.deserialize(serialized);\n\t\tchangeCapacity(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\tchangeCapacity(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 compressor =\n\t\tsessionIdOrLogger === undefined\n\t\t\t? createIdCompressor()\n\t\t\t: typeof sessionIdOrLogger === \"string\"\n\t\t\t\t? createIdCompressor(sessionIdOrLogger, loggerOrUndefined)\n\t\t\t\t: createIdCompressor(sessionIdOrLogger);\n\t// Permanently put the compressor in a ghost session\n\t(compressor as IdCompressor).startGhostSession(createSessionId());\n\treturn compressor;\n}\n"]}