@fluidframework/container-runtime 2.70.0-360753 → 2.70.0-361248

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 (99) hide show
  1. package/api-report/container-runtime.legacy.beta.api.md +0 -3
  2. package/container-runtime.test-files.tar +0 -0
  3. package/dist/containerRuntime.d.ts +5 -5
  4. package/dist/containerRuntime.js +5 -5
  5. package/dist/containerRuntime.js.map +1 -1
  6. package/dist/index.d.ts +0 -5
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/legacy.d.ts +0 -1
  10. package/dist/messageTypes.d.ts +1 -1
  11. package/dist/messageTypes.js +1 -1
  12. package/dist/messageTypes.js.map +1 -1
  13. package/dist/opLifecycle/duplicateBatchDetector.d.ts +2 -2
  14. package/dist/opLifecycle/duplicateBatchDetector.js +2 -2
  15. package/dist/opLifecycle/duplicateBatchDetector.js.map +1 -1
  16. package/dist/opLifecycle/opGroupingManager.d.ts +2 -2
  17. package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -1
  18. package/dist/opLifecycle/opGroupingManager.js +5 -3
  19. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  20. package/dist/opLifecycle/opSerialization.d.ts +2 -2
  21. package/dist/opLifecycle/opSerialization.js +2 -2
  22. package/dist/opLifecycle/opSerialization.js.map +1 -1
  23. package/dist/opLifecycle/opSplitter.d.ts +1 -1
  24. package/dist/opLifecycle/opSplitter.js +1 -1
  25. package/dist/opLifecycle/opSplitter.js.map +1 -1
  26. package/dist/opLifecycle/outbox.d.ts +2 -2
  27. package/dist/opLifecycle/outbox.js +2 -2
  28. package/dist/opLifecycle/outbox.js.map +1 -1
  29. package/dist/packageVersion.d.ts +1 -1
  30. package/dist/packageVersion.js +1 -1
  31. package/dist/packageVersion.js.map +1 -1
  32. package/dist/pendingStateManager.d.ts +1 -1
  33. package/dist/pendingStateManager.js +1 -1
  34. package/dist/pendingStateManager.js.map +1 -1
  35. package/dist/storageServiceWithAttachBlobs.d.ts +7 -7
  36. package/dist/storageServiceWithAttachBlobs.js +7 -7
  37. package/dist/storageServiceWithAttachBlobs.js.map +1 -1
  38. package/dist/summary/documentSchema.d.ts +1 -1
  39. package/dist/summary/documentSchema.js +1 -1
  40. package/dist/summary/documentSchema.js.map +1 -1
  41. package/dist/summary/orderedClientElection.js.map +1 -1
  42. package/dist/summary/summaryFormat.d.ts +6 -6
  43. package/dist/summary/summaryFormat.js.map +1 -1
  44. package/lib/containerRuntime.d.ts +5 -5
  45. package/lib/containerRuntime.js +5 -5
  46. package/lib/containerRuntime.js.map +1 -1
  47. package/lib/index.d.ts +0 -5
  48. package/lib/index.d.ts.map +1 -1
  49. package/lib/index.js.map +1 -1
  50. package/lib/legacy.d.ts +0 -1
  51. package/lib/messageTypes.d.ts +1 -1
  52. package/lib/messageTypes.js +1 -1
  53. package/lib/messageTypes.js.map +1 -1
  54. package/lib/opLifecycle/duplicateBatchDetector.d.ts +2 -2
  55. package/lib/opLifecycle/duplicateBatchDetector.js +2 -2
  56. package/lib/opLifecycle/duplicateBatchDetector.js.map +1 -1
  57. package/lib/opLifecycle/opGroupingManager.d.ts +2 -2
  58. package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -1
  59. package/lib/opLifecycle/opGroupingManager.js +5 -3
  60. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  61. package/lib/opLifecycle/opSerialization.d.ts +2 -2
  62. package/lib/opLifecycle/opSerialization.js +2 -2
  63. package/lib/opLifecycle/opSerialization.js.map +1 -1
  64. package/lib/opLifecycle/opSplitter.d.ts +1 -1
  65. package/lib/opLifecycle/opSplitter.js +1 -1
  66. package/lib/opLifecycle/opSplitter.js.map +1 -1
  67. package/lib/opLifecycle/outbox.d.ts +2 -2
  68. package/lib/opLifecycle/outbox.js +2 -2
  69. package/lib/opLifecycle/outbox.js.map +1 -1
  70. package/lib/packageVersion.d.ts +1 -1
  71. package/lib/packageVersion.js +1 -1
  72. package/lib/packageVersion.js.map +1 -1
  73. package/lib/pendingStateManager.d.ts +1 -1
  74. package/lib/pendingStateManager.js +1 -1
  75. package/lib/pendingStateManager.js.map +1 -1
  76. package/lib/storageServiceWithAttachBlobs.d.ts +7 -7
  77. package/lib/storageServiceWithAttachBlobs.js +7 -7
  78. package/lib/storageServiceWithAttachBlobs.js.map +1 -1
  79. package/lib/summary/documentSchema.d.ts +1 -1
  80. package/lib/summary/documentSchema.js +1 -1
  81. package/lib/summary/documentSchema.js.map +1 -1
  82. package/lib/summary/orderedClientElection.js.map +1 -1
  83. package/lib/summary/summaryFormat.d.ts +6 -6
  84. package/lib/summary/summaryFormat.js.map +1 -1
  85. package/package.json +25 -20
  86. package/src/containerRuntime.ts +5 -5
  87. package/src/index.ts +0 -6
  88. package/src/messageTypes.ts +1 -1
  89. package/src/opLifecycle/duplicateBatchDetector.ts +2 -2
  90. package/src/opLifecycle/opGroupingManager.ts +7 -4
  91. package/src/opLifecycle/opSerialization.ts +2 -2
  92. package/src/opLifecycle/opSplitter.ts +1 -1
  93. package/src/opLifecycle/outbox.ts +2 -2
  94. package/src/packageVersion.ts +1 -1
  95. package/src/pendingStateManager.ts +1 -1
  96. package/src/storageServiceWithAttachBlobs.ts +7 -7
  97. package/src/summary/documentSchema.ts +1 -1
  98. package/src/summary/orderedClientElection.ts +1 -1
  99. package/src/summary/summaryFormat.ts +6 -6
@@ -17,7 +17,7 @@ class StorageServiceWithAttachBlobs {
17
17
  }
18
18
  /**
19
19
  * {@link IRuntimeStorageService.policies}.
20
- * @deprecated - This will be removed in a future release. The DataStore layer does not need this.
20
+ * @deprecated This will be removed in a future release. The DataStore layer does not need this.
21
21
  */
22
22
  get policies() {
23
23
  return this.internalStorageService.policies;
@@ -33,14 +33,14 @@ class StorageServiceWithAttachBlobs {
33
33
  }
34
34
  /**
35
35
  * {@link IRuntimeStorageService.getSnapshotTree}.
36
- * @deprecated - This will be removed in a future release. The DataStore layer does not need this.
36
+ * @deprecated This will be removed in a future release. The DataStore layer does not need this.
37
37
  */
38
38
  async getSnapshotTree(version, scenarioName) {
39
39
  return this.internalStorageService.getSnapshotTree(version, scenarioName);
40
40
  }
41
41
  /**
42
42
  * {@link IRuntimeStorageService.getSnapshot}.
43
- * @deprecated - This will be removed in a future release. The DataStore layer does not need this.
43
+ * @deprecated This will be removed in a future release. The DataStore layer does not need this.
44
44
  */
45
45
  async getSnapshot(snapshotFetchOptions) {
46
46
  if (this.internalStorageService.getSnapshot !== undefined) {
@@ -50,7 +50,7 @@ class StorageServiceWithAttachBlobs {
50
50
  }
51
51
  /**
52
52
  * {@link IRuntimeStorageService.getVersions}.
53
- * @deprecated - This will be removed in a future release. The DataStore layer does not need this.
53
+ * @deprecated This will be removed in a future release. The DataStore layer does not need this.
54
54
  */
55
55
  async getVersions(
56
56
  // eslint-disable-next-line @rushstack/no-new-null
@@ -59,21 +59,21 @@ class StorageServiceWithAttachBlobs {
59
59
  }
60
60
  /**
61
61
  * {@link IRuntimeStorageService.uploadSummaryWithContext}.
62
- * @deprecated - This will be removed in a future release. The DataStore layer does not need this.
62
+ * @deprecated This will be removed in a future release. The DataStore layer does not need this.
63
63
  */
64
64
  async uploadSummaryWithContext(summary, context) {
65
65
  return this.internalStorageService.uploadSummaryWithContext(summary, context);
66
66
  }
67
67
  /**
68
68
  * {@link IRuntimeStorageService.createBlob}.
69
- * @deprecated - This will be removed in a future release. The DataStore layer does not need this.
69
+ * @deprecated This will be removed in a future release. The DataStore layer does not need this.
70
70
  */
71
71
  async createBlob(file) {
72
72
  return this.internalStorageService.createBlob(file);
73
73
  }
74
74
  /**
75
75
  * {@link IRuntimeStorageService.downloadSummary}.
76
- * @deprecated - This will be removed in a future release. The DataStore layer does not need this.
76
+ * @deprecated This will be removed in a future release. The DataStore layer does not need this.
77
77
  */
78
78
  async downloadSummary(handle) {
79
79
  return this.internalStorageService.downloadSummary(handle);
@@ -1 +1 @@
1
- {"version":3,"file":"storageServiceWithAttachBlobs.js","sourceRoot":"","sources":["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,EACZ,WAAW,CACX,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,wBAAwB,CACpC,OAAqB,EACrB,OAAwB;QAExB,OAAO,IAAI,CAAC,sBAAsB,CAAC,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,UAAU,CAAC,IAAqB;QAC5C,OAAO,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,eAAe,CAAC,MAAsB;QAClD,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;CACD;AA/FD,sEA+FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tFetchSource,\n\tICreateBlobResponse,\n\tIDocumentStorageServicePolicies,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tISnapshotTree,\n\tISummaryContext,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type { IRuntimeStorageService } from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * IRuntimeStorageService proxy which intercepts requests if they can be satisfied by the blobs received in the\n * attach message. We use this to avoid an unnecessary request to the storage service.\n */\nexport class StorageServiceWithAttachBlobs implements IRuntimeStorageService {\n\tconstructor(\n\t\tprivate readonly internalStorageService: IRuntimeStorageService,\n\t\tprivate readonly attachBlobs: Map<string, ArrayBufferLike>,\n\t) {}\n\n\t/**\n\t * {@link IRuntimeStorageService.policies}.\n\t * @deprecated - This will be removed in a future release. The DataStore layer does not need this.\n\t */\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\treturn this.internalStorageService.policies;\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tconst blob = this.attachBlobs.get(id);\n\t\tif (blob !== undefined) {\n\t\t\treturn blob;\n\t\t}\n\n\t\t// Note that it is intentional not to cache the result of this readBlob - we'll trust the real\n\t\t// IRuntimeStorageService to cache appropriately, no need to double-cache.\n\t\treturn this.internalStorageService.readBlob(id);\n\t}\n\n\t/**\n\t * {@link IRuntimeStorageService.getSnapshotTree}.\n\t * @deprecated - This will be removed in a future release. The DataStore layer does not need this.\n\t */\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this.internalStorageService.getSnapshotTree(version, scenarioName);\n\t}\n\n\t/**\n\t * {@link IRuntimeStorageService.getSnapshot}.\n\t * @deprecated - This will be removed in a future release. The DataStore layer does not need this.\n\t */\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\tif (this.internalStorageService.getSnapshot !== undefined) {\n\t\t\treturn this.internalStorageService.getSnapshot(snapshotFetchOptions);\n\t\t}\n\t\tthrow new UsageError(\n\t\t\t\"getSnapshot api should exist on internal storage in documentStorageServiceProxy class\",\n\t\t);\n\t}\n\n\t/**\n\t * {@link IRuntimeStorageService.getVersions}.\n\t * @deprecated - This will be removed in a future release. The DataStore layer does not need this.\n\t */\n\tpublic async getVersions(\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this.internalStorageService.getVersions(\n\t\t\tversionId,\n\t\t\tcount,\n\t\t\tscenarioName,\n\t\t\tfetchSource,\n\t\t);\n\t}\n\n\t/**\n\t * {@link IRuntimeStorageService.uploadSummaryWithContext}.\n\t * @deprecated - This will be removed in a future release. The DataStore layer does not need this.\n\t */\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\treturn this.internalStorageService.uploadSummaryWithContext(summary, context);\n\t}\n\n\t/**\n\t * {@link IRuntimeStorageService.createBlob}.\n\t * @deprecated - This will be removed in a future release. The DataStore layer does not need this.\n\t */\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.internalStorageService.createBlob(file);\n\t}\n\n\t/**\n\t * {@link IRuntimeStorageService.downloadSummary}.\n\t * @deprecated - This will be removed in a future release. The DataStore layer does not need this.\n\t */\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this.internalStorageService.downloadSummary(handle);\n\t}\n}\n"]}
1
+ {"version":3,"file":"storageServiceWithAttachBlobs.js","sourceRoot":"","sources":["../src/storageServiceWithAttachBlobs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAeH,uEAAsE;AAEtE;;;GAGG;AACH,MAAa,6BAA6B;IACzC,YACkB,sBAA8C,EAC9C,WAAyC;QADzC,2BAAsB,GAAtB,sBAAsB,CAAwB;QAC9C,gBAAW,GAAX,WAAW,CAA8B;IACxD,CAAC;IAEJ;;;OAGG;IACH,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAC7C,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,EAAU;QAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACtC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,8FAA8F;QAC9F,0EAA0E;QAC1E,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACjD,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,eAAe,CAC3B,OAAkB,EAClB,YAAqB;QAGrB,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,WAAW,CAAC,oBAA4C;QACpE,IAAI,IAAI,CAAC,sBAAsB,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAC3D,OAAO,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;QACtE,CAAC;QACD,MAAM,IAAI,qBAAU,CACnB,uFAAuF,CACvF,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,WAAW;IACvB,kDAAkD;IAClD,SAAwB,EACxB,KAAa,EACb,YAAqB,EACrB,WAAyB;QAEzB,OAAO,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAC7C,SAAS,EACT,KAAK,EACL,YAAY,EACZ,WAAW,CACX,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,wBAAwB,CACpC,OAAqB,EACrB,OAAwB;QAExB,OAAO,IAAI,CAAC,sBAAsB,CAAC,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,UAAU,CAAC,IAAqB;QAC5C,OAAO,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,eAAe,CAAC,MAAsB;QAClD,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;CACD;AA/FD,sEA+FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tFetchSource,\n\tICreateBlobResponse,\n\tIDocumentStorageServicePolicies,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tISnapshotTree,\n\tISummaryContext,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type { IRuntimeStorageService } from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * IRuntimeStorageService proxy which intercepts requests if they can be satisfied by the blobs received in the\n * attach message. We use this to avoid an unnecessary request to the storage service.\n */\nexport class StorageServiceWithAttachBlobs implements IRuntimeStorageService {\n\tconstructor(\n\t\tprivate readonly internalStorageService: IRuntimeStorageService,\n\t\tprivate readonly attachBlobs: Map<string, ArrayBufferLike>,\n\t) {}\n\n\t/**\n\t * {@link IRuntimeStorageService.policies}.\n\t * @deprecated This will be removed in a future release. The DataStore layer does not need this.\n\t */\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\treturn this.internalStorageService.policies;\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tconst blob = this.attachBlobs.get(id);\n\t\tif (blob !== undefined) {\n\t\t\treturn blob;\n\t\t}\n\n\t\t// Note that it is intentional not to cache the result of this readBlob - we'll trust the real\n\t\t// IRuntimeStorageService to cache appropriately, no need to double-cache.\n\t\treturn this.internalStorageService.readBlob(id);\n\t}\n\n\t/**\n\t * {@link IRuntimeStorageService.getSnapshotTree}.\n\t * @deprecated This will be removed in a future release. The DataStore layer does not need this.\n\t */\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this.internalStorageService.getSnapshotTree(version, scenarioName);\n\t}\n\n\t/**\n\t * {@link IRuntimeStorageService.getSnapshot}.\n\t * @deprecated This will be removed in a future release. The DataStore layer does not need this.\n\t */\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\tif (this.internalStorageService.getSnapshot !== undefined) {\n\t\t\treturn this.internalStorageService.getSnapshot(snapshotFetchOptions);\n\t\t}\n\t\tthrow new UsageError(\n\t\t\t\"getSnapshot api should exist on internal storage in documentStorageServiceProxy class\",\n\t\t);\n\t}\n\n\t/**\n\t * {@link IRuntimeStorageService.getVersions}.\n\t * @deprecated This will be removed in a future release. The DataStore layer does not need this.\n\t */\n\tpublic async getVersions(\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this.internalStorageService.getVersions(\n\t\t\tversionId,\n\t\t\tcount,\n\t\t\tscenarioName,\n\t\t\tfetchSource,\n\t\t);\n\t}\n\n\t/**\n\t * {@link IRuntimeStorageService.uploadSummaryWithContext}.\n\t * @deprecated This will be removed in a future release. The DataStore layer does not need this.\n\t */\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\treturn this.internalStorageService.uploadSummaryWithContext(summary, context);\n\t}\n\n\t/**\n\t * {@link IRuntimeStorageService.createBlob}.\n\t * @deprecated This will be removed in a future release. The DataStore layer does not need this.\n\t */\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.internalStorageService.createBlob(file);\n\t}\n\n\t/**\n\t * {@link IRuntimeStorageService.downloadSummary}.\n\t * @deprecated This will be removed in a future release. The DataStore layer does not need this.\n\t */\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this.internalStorageService.downloadSummary(handle);\n\t}\n}\n"]}
@@ -265,7 +265,7 @@ export declare class DocumentsSchemaController {
265
265
  * @param contents - contents of the messages
266
266
  * @param local - whether op is local
267
267
  * @param sequenceNumber - sequence number of the op
268
- * @returns - true if schema was accepted, otherwise false (rejected due to failed CAS)
268
+ * @returns true if schema was accepted, otherwise false (rejected due to failed CAS)
269
269
  */
270
270
  processDocumentSchemaMessages(contents: IDocumentSchemaChangeMessageIncoming[], local: boolean, sequenceNumber: number): boolean;
271
271
  /**
@@ -422,7 +422,7 @@ class DocumentsSchemaController {
422
422
  * @param contents - contents of the messages
423
423
  * @param local - whether op is local
424
424
  * @param sequenceNumber - sequence number of the op
425
- * @returns - true if schema was accepted, otherwise false (rejected due to failed CAS)
425
+ * @returns true if schema was accepted, otherwise false (rejected due to failed CAS)
426
426
  */
427
427
  processDocumentSchemaMessages(contents, local, sequenceNumber) {
428
428
  for (const content of contents) {
@@ -1 +1 @@
1
- {"version":3,"file":"documentSchema.js","sourceRoot":"","sources":["../../src/summary/documentSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,uEAA+E;AAC/E,yCAA0C;AAE1C,4DAAkD;AAwJlD;;;;;;;;;;;GAWG;AACU,QAAA,4BAA4B,GAAG,CAAC,CAAC;AAsC9C,MAAM,eAAe;IACb,GAAG,CAAC,eAAsB,EAAE,cAAqB;QACvD,OAAO,eAAe,KAAK,IAAI,IAAI,cAAc,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,CAAC;IAEM,EAAE,CAAC,eAAsB,EAAE,cAAqB;QACtD,OAAO,eAAe,KAAK,IAAI,IAAI,cAAc,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,CAAC;IAEM,QAAQ,CAAC,CAAU;QACzB,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC;IACtC,CAAC;CACD;AAED,MAAM,kBAAmB,SAAQ,eAAe;IACxC,GAAG,CAAC,eAAsB,EAAE,cAAqB;QACvD,OAAO,IAAI,CAAC,EAAE,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IACjD,CAAC;CACD;AAED,MAAM,WAAW;IAChB,YAA6B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;IAE3C,GAAG,CAAC,eAAwB,EAAE,cAAuB;QAC3D,IAAI,eAAe,KAAK,SAAS,IA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AU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC;AACrD,CAAC;AAED,2CAA2C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { SemanticVersion } from \"@fluidframework/runtime-utils/internal\";\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\nimport { DataProcessingError } from \"@fluidframework/telemetry-utils/internal\";\nimport { gt, lt, parse } from \"semver-ts\";\n\nimport { pkgVersion } from \"../packageVersion.js\";\n\n/**\n * Descripe allowed type for properties in document schema.\n * Please note that for all property types we should use undefined to indicate that particular capability is off.\n * Using false, or some string value (like \"off\") will result in clients who do not understand that property failing, whereas\n * we want them to continue to collaborate alongside clients who support that capability, but such capability is shipping dark for now.\n * @internal\n */\nexport type DocumentSchemaValueType = string | string[] | true | number | undefined;\n\n/**\n * ID Compressor mode.\n * \"on\" - compressor is On. It's loaded as part of container load. This mode is sticky - once on, compressor is On for all\n * sessions for a given document. This results in IContainerRuntime.idCompressor to be always available.\n * \"delayed\" - ID compressor bundle is loaded only on establishing of first delta connection, i.e. it does not impact boot of cotnainer.\n * In such mode IContainerRuntime.idCompressor is not made available (unless previous sessions of same document had it \"On\").\n * The only thing that is available is IContainerRuntime.generateDocumentUniqueId() that provides opportunistically short IDs.\n * undefined - ID compressor is not loaded.\n * While IContainerRuntime.generateDocumentUniqueId() is available, it will produce long IDs that are do not compress well.\n *\n * @legacy @beta\n */\nexport type IdCompressorMode = \"on\" | \"delayed\" | undefined;\n\n/**\n * Document schema information.\n * Describes overall shape of document schema, including unknown (to this version) properties.\n *\n * Used by runtime to make a call if it can understand document schema.\n * If it can't, it should not continue with document and immediately fail, preventing random (cryptic) failures\n * down the road and potentially corrupting documents.\n * For now this structure and appropriate interpretation / behavior is focused only on runtime features.\n * In the future that could be interpolated to more areas, including DDSs used, and even possibly - application\n * schema.\n *\n * Runtime will ignore any properties at the root that it does not understand (i.e. IDocumentSchema.app), but will\n * stop (and fail session) on any unknown properties within \"runtime\" sub-tree.\n *\n * In most cases values preserved in the document will not dictate if such features should be enabled in a given session.\n * I.e. if compression is mentioned in document schema, this means that runtime version that opens such document must know\n * how to interpret such ops, but does not need to actually use compression itself. That said, some options could be\n * sticky, i.e. influence feature selection for all runtimes opening a document. ID compression is one such example.\n * Currently there is no mechanism to remove feature from this property bag, i.e. once compression was used, even if it's\n * disabled (through feature gate or code deployment), all existing documents that used compression will continue to fail\n * if opened by clients who do not support compression.\n *\n * For now we are limiting it to just plain properties, and only really simple types, but that can be changed in the future.\n *\n * @internal\n */\nexport interface IDocumentSchema {\n\t// Note: Incoming schemas from other clients may have additional root-level properties (i.e. IDocumentSchema.app)\n\t// that this client does not understand. The runtime will ignore these properties, unless they are within the\n\t// \"runtime\" sub-tree, in which case it will fail if it is unable to understand any runtime properties.\n\n\t/**\n\t * Describes how data needed to understand the schema is stored in this structure.\n\t * If runtime sees a version it does not understand, it should immediately fail and not\n\t * attempt to interpret any further data.\n\t */\n\tversion: number;\n\n\t/**\n\t * Sequence number when this schema became active.\n\t */\n\trefSeq: number;\n\n\t/**\n\t * Runtime configurations that affect the document schema. Other clients must understand these\n\t * properties to be able to open the document.\n\t */\n\truntime: Record<string, DocumentSchemaValueType>;\n\n\t/**\n\t * Info about this document that can be updated via Document Schema change op, but isn't required\n\t * to be understood by all clients (unlike the rest of IDocumentSchema properties). Because of this,\n\t * some older documents may not have this property, so it's an optional property.\n\t */\n\tinfo?: IDocumentSchemaInfo;\n}\n\n/**\n * Informational properties of the document that are not subject to strict schema enforcement.\n *\n * @internal\n */\nexport interface IDocumentSchemaInfo {\n\t/**\n\t * The minimum version of the FF runtime that should be used to load this document.\n\t * Will likely be advanced over time as applications pick up later FF versions.\n\t *\n\t * We use this to issue telemetry warning events if a client tries to open a document\n\t * with a runtime version lower than this.\n\t *\n\t * See {@link @fluidframework/container-runtime#LoadContainerRuntimeParams} for additional details on `minVersionForCollab`.\n\t *\n\t * @remarks\n\t * We use `SemanticVersion` instead of `MinimumVersionForCollab` since we may open future documents that with a\n\t * minVersionForCollab version that `MinimumVersionForCollab` does not support.\n\t */\n\tminVersionForCollab: SemanticVersion;\n}\n\n/**\n * Content of the type=ContainerMessageType.DocumentSchemaChange ops.\n * The meaning of refSeq field is different in such messages (compared to other usages of IDocumentSchemaCurrent)\n * ContainerMessageType.DocumentSchemaChange messages use CAS (Compare-and-swap) semantics, and convey\n * regSeq of last known schema change (known to a client proposing schema change).\n * @see InboundContainerRuntimeDocumentSchemaMessage\n * @internal\n */\nexport type IDocumentSchemaChangeMessageIncoming = IDocumentSchema;\n\n/**\n * Similar to {@link IDocumentSchemaChangeMessageIncoming}, but used for outgoing schema messages.\n * @see OutboundContainerRuntimeDocumentSchemaMessage\n * @internal\n */\nexport type IDocumentSchemaChangeMessageOutgoing = IDocumentSchemaCurrent;\n\n/**\n * Settings that this session would like to have, based on options and feature gates.\n *\n * WARNING: This type is used to infer IDocumentSchemaCurrent type!\n * Any changes here (including renaming of properties) are potentially changing document format and should be considered carefully!\n *\n * @internal\n */\nexport interface IDocumentSchemaFeatures {\n\t// Tells if client uses legacy behavior of changing schema.\n\t// - Legacy behavior - changing schema without leveraging schema change ops.\n\t// - New behavior - changes in schema require ops and take into affect with delay.\n\texplicitSchemaControl: boolean;\n\tcompressionLz4: boolean;\n\tidCompressorMode: IdCompressorMode;\n\topGroupingEnabled: boolean;\n\tcreateBlobPayloadPending: true | undefined;\n\n\t/**\n\t * List of disallowed versions of the runtime.\n\t * This option is sticky. Once a version of runtime is added to this list (when supplied to DocumentsSchemaController's constructor)\n\t * it will be added to the list of disallowed versions and stored in document metadata.\n\t * Each runtime checks if its version is in this list on container open. If it is, it immediately exits with error message\n\t * indicating to the user that this version is no longer supported.\n\t * Currently there is no mechanism to remove version from this list. I.e. If it was once added to the list,\n\t * it gets added to any document metadata (documents that gets open by this runtime) and there is no way to clear it from document's\n\t * metadata.\n\t */\n\tdisallowedVersions: string[];\n}\n\n/**\n * Current version known properties that define document schema\n * This must be bumped whenever the format of document schema or protocol for changing the current document schema changes\n * in a way that all old/new clients are required to understand.\n * Ex: Adding a new configuration property (under IDocumentSchema.runtime) does not require changing this version since there is logic\n * in old clients for handling new/unknown properties.\n * Ex: Adding a new property to IDocumentSchema.info does not require changing this version, since info properties are not required to be\n * understood by all clients.\n * Ex: Changing the 'document schema acceptance' mechanism from convert-and-swap to one requiring consensus does require changing this version\n * since all clients need to understand the new protocol.\n * @internal\n */\nexport const currentDocumentVersionSchema = 1;\n\n/**\n * Current document schema.\n * This interface represents the schema that we currently understand and know the\n * structure of (which properties will be present).\n *\n * @internal\n */\nexport interface IDocumentSchemaCurrent extends Required<IDocumentSchema> {\n\t// This is the version of the schema that we currently understand.\n\tversion: typeof currentDocumentVersionSchema;\n\t// This narrows the runtime property to only include the properties in IDocumentSchemaFeatures (all as optional)\n\truntime: {\n\t\t[P in keyof IDocumentSchemaFeatures]?: IDocumentSchemaFeatures[P] extends boolean\n\t\t\t? true\n\t\t\t: IDocumentSchemaFeatures[P];\n\t};\n}\n\n/**\n * Document schema that is incoming from another client but validated to be \"current\".\n *\n * This interface represents when we have validated that an incoming IDocumentSchema object\n * is compatible with the current runtime (by calling `checkRuntimeCompatibility()`).\n * However, the `info` property is optional because some older documents may not have this property, but\n * `info` is not required to be understood by all clients to be compatible.\n */\ninterface IDocumentSchemaCurrentIncoming extends Omit<IDocumentSchemaCurrent, \"info\"> {\n\tinfo?: IDocumentSchemaInfo;\n}\n\ninterface IProperty<T = unknown> {\n\tand: (persistedSchema: T, providedSchema: T) => T;\n\tor: (persistedSchema: T, providedSchema: T) => T;\n\tvalidate(t: unknown): boolean;\n}\n\nclass TrueOrUndefined implements IProperty<true | undefined> {\n\tpublic and(persistedSchema?: true, providedSchema?: true): true | undefined {\n\t\treturn persistedSchema === true && providedSchema === true ? true : undefined;\n\t}\n\n\tpublic or(persistedSchema?: true, providedSchema?: true): true | undefined {\n\t\treturn persistedSchema === true || providedSchema === true ? true : undefined;\n\t}\n\n\tpublic validate(t: unknown): t is true | undefined {\n\t\treturn t === undefined || t === true;\n\t}\n}\n\nclass TrueOrUndefinedMax extends TrueOrUndefined {\n\tpublic and(persistedSchema?: true, providedSchema?: true): true | undefined {\n\t\treturn this.or(persistedSchema, providedSchema);\n\t}\n}\n\nclass MultiChoice implements IProperty<string | undefined> {\n\tconstructor(private readonly choices: string[]) {}\n\n\tpublic and(persistedSchema?: string, providedSchema?: string): string | undefined {\n\t\tif (persistedSchema === undefined || providedSchema === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.choices[\n\t\t\tMath.min(this.choices.indexOf(persistedSchema), this.choices.indexOf(providedSchema))\n\t\t];\n\t}\n\n\tpublic or(persistedSchema?: string, providedSchema?: string): string | undefined {\n\t\tif (persistedSchema === undefined) {\n\t\t\treturn providedSchema;\n\t\t}\n\t\tif (providedSchema === undefined) {\n\t\t\treturn persistedSchema;\n\t\t}\n\t\treturn this.choices[\n\t\t\tMath.max(this.choices.indexOf(persistedSchema), this.choices.indexOf(providedSchema))\n\t\t];\n\t}\n\n\tpublic validate(t: unknown): boolean {\n\t\treturn t === undefined || (typeof t === \"string\" && this.choices.includes(t));\n\t}\n}\n\nclass IdCompressorProperty extends MultiChoice {\n\t// document schema always wins!\n\tpublic and(persistedSchema?: string, providedSchema?: string): string | undefined {\n\t\treturn persistedSchema;\n\t}\n}\n\nclass CheckVersions implements IProperty<string[] | undefined> {\n\tpublic or(\n\t\tpersistedSchema: string[] = [],\n\t\tprovidedSchema: string[] = [],\n\t): string[] | undefined {\n\t\tconst set = new Set<string>([...persistedSchema, ...providedSchema]);\n\t\treturn arrayToProp([...set.values()]);\n\t}\n\n\t// Once version is there, it stays there forever.\n\tpublic and(\n\t\tpersistedSchema: string[] = [],\n\t\tprovidedSchema: string[] = [],\n\t): string[] | undefined {\n\t\treturn this.or(persistedSchema, providedSchema);\n\t}\n\n\tpublic validate(t: unknown): boolean {\n\t\treturn t === undefined || (Array.isArray(t) && !t.includes(pkgVersion));\n\t}\n}\n\n/**\n * Helper structure to valida if a schema is compatible with existing code.\n */\nconst documentSchemaSupportedConfigs = {\n\texplicitSchemaControl: new TrueOrUndefinedMax(), // once new behavior shows up, it's sticky\n\tidCompressorMode: new IdCompressorProperty([\"delayed\", \"on\"]),\n\topGroupingEnabled: new TrueOrUndefined(),\n\tcompressionLz4: new TrueOrUndefined(),\n\tcreateBlobPayloadPending: new TrueOrUndefined(),\n\tdisallowedVersions: new CheckVersions(),\n};\n\n/**\n * Checks if a given schema is compatible with current code, i.e. if current code can understand all the features of that schema.\n * If schema is not compatible with current code, it throws an exception.\n * @param documentSchema - current schema\n */\nfunction checkRuntimeCompatibility(\n\tdocumentSchema: IDocumentSchema | undefined,\n\tschemaName: string,\n): asserts documentSchema is IDocumentSchemaCurrentIncoming {\n\t// Back-compat - we can't do anything about legacy documents.\n\t// There is no way to validate them, so we are taking a guess that safe deployment processes used by a given app\n\t// do not run into compat problems.\n\tif (documentSchema === undefined) {\n\t\treturn;\n\t}\n\n\tconst msg = \"Document can't be opened with current version of the code\";\n\tif (documentSchema.version !== currentDocumentVersionSchema) {\n\t\tthrow DataProcessingError.create(\n\t\t\tmsg,\n\t\t\t\"checkRuntimeCompat1\",\n\t\t\tundefined, // message\n\t\t\t{\n\t\t\t\truntimeSchemaVersion: documentSchema.version,\n\t\t\t\tcurrentRuntimeSchemaVersion: currentDocumentVersionSchema,\n\t\t\t\tschemaName,\n\t\t\t},\n\t\t);\n\t}\n\n\tlet unknownProperty: string | undefined;\n\n\tconst regSeq = documentSchema.refSeq;\n\t// defence in depth - it should not be possible to get here anything other than integer, but worth validating it.\n\tif (typeof regSeq !== \"number\" || regSeq < 0 || !Number.isInteger(regSeq)) {\n\t\tunknownProperty = \"refSeq\";\n\t} else if (documentSchema.runtime === null || typeof documentSchema.runtime !== \"object\") {\n\t\tunknownProperty = \"runtime\";\n\t} else {\n\t\tfor (const [name, value] of Object.entries(documentSchema.runtime)) {\n\t\t\tconst validator = documentSchemaSupportedConfigs[name] as IProperty | undefined;\n\t\t\tif (!(validator?.validate(value) ?? false)) {\n\t\t\t\tunknownProperty = `runtime/${name}`;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (unknownProperty !== undefined) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\tconst value = documentSchema[unknownProperty];\n\t\tthrow DataProcessingError.create(\n\t\t\tmsg,\n\t\t\t\"checkRuntimeCompat2\",\n\t\t\tundefined, // message\n\t\t\t{\n\t\t\t\tcodeVersion: currentDocumentVersionSchema,\n\t\t\t\tproperty: unknownProperty,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tvalue,\n\t\t\t\tschemaName,\n\t\t\t},\n\t\t);\n\t}\n}\n\nfunction and(\n\tpersistedSchema: IDocumentSchemaCurrentIncoming,\n\tprovidedSchema: IDocumentSchemaCurrent,\n): IDocumentSchemaCurrent {\n\tconst runtime = {};\n\tfor (const key of new Set([\n\t\t...Object.keys(persistedSchema.runtime),\n\t\t...Object.keys(providedSchema.runtime),\n\t])) {\n\t\truntime[key] = (documentSchemaSupportedConfigs[key] as IProperty).and(\n\t\t\tpersistedSchema.runtime[key],\n\t\t\tprovidedSchema.runtime[key],\n\t\t);\n\t}\n\n\t// We keep the persisted minVersionForCollab if present, even if the provided minVersionForCollab\n\t// is higher.\n\tconst minVersionForCollab =\n\t\tpersistedSchema.info?.minVersionForCollab ?? providedSchema.info.minVersionForCollab;\n\n\treturn {\n\t\tversion: currentDocumentVersionSchema,\n\t\trefSeq: persistedSchema.refSeq,\n\t\tinfo: { minVersionForCollab },\n\t\truntime,\n\t};\n}\n\nfunction or(\n\tpersistedSchema: IDocumentSchemaCurrentIncoming,\n\tprovidedSchema: IDocumentSchemaCurrent,\n): IDocumentSchemaCurrent {\n\tconst runtime = {};\n\tfor (const key of new Set([\n\t\t...Object.keys(persistedSchema.runtime),\n\t\t...Object.keys(providedSchema.runtime),\n\t])) {\n\t\truntime[key] = (documentSchemaSupportedConfigs[key] as IProperty).or(\n\t\t\tpersistedSchema.runtime[key],\n\t\t\tprovidedSchema.runtime[key],\n\t\t);\n\t}\n\n\t// We take the greater of the persisted/provided minVersionForCollab\n\tconst minVersionForCollab =\n\t\tpersistedSchema.info === undefined\n\t\t\t? providedSchema.info.minVersionForCollab\n\t\t\t: gt(persistedSchema.info.minVersionForCollab, providedSchema.info.minVersionForCollab)\n\t\t\t\t? persistedSchema.info.minVersionForCollab\n\t\t\t\t: providedSchema.info.minVersionForCollab;\n\n\treturn {\n\t\tversion: currentDocumentVersionSchema,\n\t\trefSeq: persistedSchema.refSeq,\n\t\tinfo: { minVersionForCollab },\n\t\truntime,\n\t};\n}\n\n/**\n * Determines if two schemas are the \"same\".\n * Schemas are considered **not** the same if a schema change op is required to make\n * the properties of `persistedSchema` match to the properties of `providedSchema`.\n */\nfunction same(\n\tpersistedSchema: IDocumentSchemaCurrentIncoming,\n\tprovidedSchema: IDocumentSchemaCurrent,\n): boolean {\n\tif (\n\t\tpersistedSchema.info === undefined ||\n\t\tlt(persistedSchema.info.minVersionForCollab, providedSchema.info.minVersionForCollab)\n\t) {\n\t\t// If the persisted schema's minVersionForCollab is undefined or less than the provided schema's\n\t\t// minVersionForCollab, then we should send a schema change op to update the minVersionForCollab.\n\t\treturn false;\n\t}\n\tfor (const key of new Set([\n\t\t...Object.keys(persistedSchema.runtime),\n\t\t...Object.keys(providedSchema.runtime),\n\t])) {\n\t\t// If schemas differ only by type of behavior, then we should not send schema change ops!\n\t\tif (\n\t\t\tkey !== \"explicitSchemaControl\" &&\n\t\t\tpersistedSchema.runtime[key] !== providedSchema.runtime[key]\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction boolToProp(b: boolean): true | undefined {\n\treturn b ? true : undefined;\n}\n\nfunction arrayToProp(arr: string[]): string[] | undefined {\n\treturn arr.length === 0 ? undefined : arr;\n}\n\n/* eslint-disable jsdoc/check-indentation */\n\n/**\n * Controller of document schema.\n *\n * Recommended pre-reading: https://github.com/microsoft/FluidFramework/blob/main/packages/dds/SchemaVersioning.md\n *\n * This class manages current document schema and transitions between document schemas.\n * At the moment, it only focuses on subset of document schema, specifically - how FluidFramework runtime serializes data\n * (summary and op format), features & capabilities that a version of runtime has to support and understand in\n * order to collaborate on a document.\n * New features that modify document format have to be included in document schema definition.\n * Usage of such features could only happen after document schema has been updated to reflect such feature.\n *\n * This formality allows clients that do not understand such features to fail right away when they observe\n * document schema listing capabilities that such client does not understand.\n * Old clients will fail in predictable way. This allows us to\n * 1) Immediately see such issues and adjust if features are enabled too early, before changes have been saturated.\n * 2) There is no way to get to 100% saturation with new code. Even if we have 99.99% saturation, there are\n * still 0.01% of clients who will fail. Failing early and predictably ensures they have no chance to limp along\n * and potentially corrupt the document. This is especially true for summarizer client, who could simply \"undo\"\n * changes it does not understands.\n *\n * It's important to note how it overlaps with feature gates and safe velocity.\n * If new feature was in use, that resulted in a number of documents referencing such feature in document schema.\n * But, developers (through code deployment or feature gates) could disable usage of such features.\n * That will stop a process of further document schema changes (for documents that were not using such feature).\n * And documents that already list such capability in their schema will continue to do so. Later ensures that old\n * clients who do not understand such feature will continue to fail to open such documents, as such documents very\n * likely contain data in a new format.\n *\n * Controller operates with 4 schemas:\n * - document schema: whatever we loaded from summary metadata + ops. It follows eventuall consistency rules (i.e. like DDS).\n * - desired schema - what client is asking for to have (i.e. all the desired settings, based on runtime options / feature gates).\n * - session schema - current session schema. It's \"and\" of the above two schemas.\n * - future schema - \"or\" of document and desires schemas.\n *\n * \"or\" & \"and\" operators are defined individually for each property. For Boolean properties it's literally &&, || operators.\n * But for other properties it's more nuanced.\n *\n * Whenver document schema does not match future schema, controller will send an op that attempts to changs documents schema to\n * future schema.\n *\n * Users of this class need to use DocumentsSchemaController.sessionSchema to determine what features can be used.\n *\n * There are two modes this class can operate:\n * 1) Legacy mode. In such mode it does not issue any ops to change document schema. Any changes happen implicitly,\n * right away, and new features are available right away\n * 2) Non-legacy mode. In such mode any changes to schema require an op roundtrip. This class will manage such transitions.\n * However code should assume that any new features that were not enabled in a given document will not be available\n * for a given session. That's because this session may never send any ops (including read-only documents). Or it may\n * fail to convert schema.\n * This class promises eventual movement forward. I.e. if new feature is allowed (let's say - through feature gates),\n * then eventually all documents that are modified will have that feature reflected in their schema. It could require\n * multiple reloads / new sessions to get there (depends on if code reacts to schema changes right away, or only consults\n * schema on document load).\n *\n * How schemas are changed (in non-legacy mode):\n * If a client needs to change a schema, it will attempt to do so as part of normal ops sending process.\n * Changes happen in CAS (Compare-and-swap) fashion, i.e. client tells current schema and schema it wants to change to.\n * When a number of clients race to change a schema, then only one of them will win, all others will fail because they will\n * reference old schema that is no longer in effect.\n * Clients can retry, but current implementation is simply - they will not (and will rely on next session / reload to do\n * recalc and decide if schema needs to be changed or not).\n *\n * @internal\n * @sealed\n */\nexport class DocumentsSchemaController {\n\tprivate explicitSchemaControl: boolean;\n\n\t/**\n\t * Have we generated a DocumentSchemaChange op and we're waiting for the ack?\n\t * This is used to ensure that we do not generate multiple schema change ops - this client should only ever send one (if any).\n\t */\n\tprivate opPending = false;\n\n\t// schema coming from document metadata (snapshot we loaded from)\n\tprivate documentSchema: IDocumentSchema;\n\n\t// desired schema, based on feature gates / runtime options.\n\t// This includes requests to enable to disable functionality\n\tprivate readonly desiredSchema: IDocumentSchemaCurrent;\n\n\t// OR() of document schema and desired schema. It enables all the features that are enabled in either of schemas.\n\tprivate futureSchema: IDocumentSchemaCurrent | undefined;\n\n\t// Current schema this session operates with.\n\t// 1) Legacy mode (explicitSchemaControl === false): this is same as desired schema - all options that were requested to be on are on, and all options requested to be off are off.\n\t// 2) Non-legacy mode (explicitSchemaControl === true): this is AND() of document schema and desired schema. Only options that are enabled in both are enabled here.\n\t// If there are any options that are not enabled in document schema, but are enabled in desired schema, then attempt to change schema\n\t// (and enable such options) will be made through the session.\n\tpublic sessionSchema: IDocumentSchemaCurrent;\n\n\t/**\n\t * Constructs DocumentsSchemaController that controls current schema and processes around it, including changes in schema.\n\t * @param existing - Is the document existing document, or a new doc.\n\t * @param documentMetadataSchema - current document's schema, if present.\n\t * @param features - features of the document schema that current session wants to see enabled.\n\t * @param onSchemaChange - callback that is called whenever schema is changed (not called on creation / load, only when processing document schema change ops)\n\t * @param info - Informational properties of the document that are not subject to strict schema enforcement\n\t * @param logger - telemetry logger from the runtime\n\t */\n\tconstructor(\n\t\texisting: boolean,\n\t\tsnapshotSequenceNumber: number,\n\t\tdocumentMetadataSchema: IDocumentSchema | undefined,\n\t\tfeatures: IDocumentSchemaFeatures,\n\t\tprivate readonly onSchemaChange: (schema: IDocumentSchemaCurrent) => void,\n\t\tinfo: IDocumentSchemaInfo,\n\t\tlogger: ITelemetryLoggerExt,\n\t) {\n\t\t// For simplicity, let's only support new schema features for explicit schema control mode\n\t\tassert(\n\t\t\tfeatures.disallowedVersions.length === 0 || features.explicitSchemaControl,\n\t\t\t0x949 /* not supported */,\n\t\t);\n\n\t\t// We check the document's metadata to see if there is a minVersionForCollab. If it's not an existing document or\n\t\t// if the document is older, then it won't have one. If it does have a minVersionForCollab, we check if it's greater\n\t\t// than this client's runtime version. If so, we log a telemetry event to warn the customer that the client is outdated.\n\t\t// Note: We only send a warning because we will confirm via `checkRuntimeCompatibility` if this client **can** understand\n\t\t// the existing document's schema. We still want to issue a warning regardless if this client can or cannot understand the\n\t\t// schema since it may be a sign that the customer is not properly waiting for saturation before updating their\n\t\t// `minVersionForCollab` value, which could cause disruptions to users in the future.\n\t\tconst existingMinVersionForCollab = documentMetadataSchema?.info?.minVersionForCollab;\n\t\tif (\n\t\t\texistingMinVersionForCollab !== undefined &&\n\t\t\tgt(existingMinVersionForCollab, pkgVersion) &&\n\t\t\t// We also want to avoid sending the telemetry warning for dev builds, since they currently are formatted as\n\t\t\t// `0.0.0-#####-test`. This will cause the telemetry warning to constantly fire.\n\t\t\t// TODO: This can be removed after ADO:41351\n\t\t\t!isDevBuild(pkgVersion)\n\t\t) {\n\t\t\tconst warnMsg = `WARNING: The version of Fluid Framework used by this client (${pkgVersion}) is not supported by this document! Please upgrade to version ${existingMinVersionForCollab} or later to ensure compatibility.`;\n\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\teventName: \"MinVersionForCollabWarning\",\n\t\t\t\tmessage: warnMsg,\n\t\t\t});\n\t\t}\n\n\t\t// Desired schema by this session - almost all props are coming from arguments\n\t\tthis.desiredSchema = {\n\t\t\tversion: currentDocumentVersionSchema,\n\t\t\trefSeq: documentMetadataSchema?.refSeq ?? 0,\n\t\t\tinfo,\n\t\t\truntime: {\n\t\t\t\texplicitSchemaControl: boolToProp(features.explicitSchemaControl),\n\t\t\t\tcompressionLz4: boolToProp(features.compressionLz4),\n\t\t\t\tidCompressorMode: features.idCompressorMode,\n\t\t\t\topGroupingEnabled: boolToProp(features.opGroupingEnabled),\n\t\t\t\tcreateBlobPayloadPending: features.createBlobPayloadPending,\n\t\t\t\tdisallowedVersions: arrayToProp(features.disallowedVersions),\n\t\t\t},\n\t\t};\n\n\t\t// Schema coming from document metadata (snapshot we loaded from), or if no document exists\n\t\t// (this is a new document) then this is the same as desiredSchema (same as session schema in such case).\n\t\t// Latter is important sure that's what will go into summary.\n\t\tthis.documentSchema = existing\n\t\t\t? (documentMetadataSchema ??\n\t\t\t\t({\n\t\t\t\t\tversion: currentDocumentVersionSchema,\n\t\t\t\t\t// see comment in summarizeDocumentSchema() on why it has to stay zero\n\t\t\t\t\trefSeq: 0,\n\t\t\t\t\tinfo,\n\t\t\t\t\t// If it's existing document and it has no schema, then it was written by legacy client.\n\t\t\t\t\t// If it's a new document, then we define it's legacy-related behaviors.\n\t\t\t\t\truntime: {\n\t\t\t\t\t\texplicitSchemaControl: boolToProp(!existing && features.explicitSchemaControl),\n\t\t\t\t\t},\n\t\t\t\t} satisfies IDocumentSchemaCurrent))\n\t\t\t: this.desiredSchema;\n\n\t\tcheckRuntimeCompatibility(this.documentSchema, \"document\");\n\t\tthis.validateSeqNumber(this.documentSchema.refSeq, snapshotSequenceNumber, \"summary\");\n\n\t\t// Use legacy behavior only if both document and options tell us to use legacy.\n\t\t// Otherwise it's no longer legacy time!\n\t\tthis.explicitSchemaControl =\n\t\t\tthis.documentSchema.runtime.explicitSchemaControl === true ||\n\t\t\tfeatures.explicitSchemaControl;\n\n\t\t// Calculate\n\t\t// - current session schema (overlap of document schema and desired schema)\n\t\t// - future schema to propose (concatination of document schema and desired schema)\n\t\tif (!this.explicitSchemaControl || !existing) {\n\t\t\tthis.sessionSchema = this.desiredSchema;\n\t\t\tassert(\n\t\t\t\tboolToProp(this.explicitSchemaControl) ===\n\t\t\t\t\tthis.sessionSchema.runtime.explicitSchemaControl,\n\t\t\t\t0x94a /* explicitSchemaControl */,\n\t\t\t);\n\t\t\tthis.futureSchema = undefined;\n\t\t} else {\n\t\t\tthis.sessionSchema = and(this.documentSchema, this.desiredSchema);\n\t\t\tthis.futureSchema = or(this.documentSchema, this.desiredSchema);\n\t\t\tassert(this.sessionSchema.runtime.explicitSchemaControl === true, 0x94b /* legacy */);\n\t\t\tassert(this.futureSchema.runtime.explicitSchemaControl === true, 0x94c /* legacy */);\n\t\t\tif (same(this.documentSchema, this.futureSchema)) {\n\t\t\t\tthis.futureSchema = undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Validate that schema we are operating in is actually a schema we consider compatible with current runtime.\n\t\tcheckRuntimeCompatibility(this.desiredSchema, \"desired\");\n\t\tcheckRuntimeCompatibility(this.sessionSchema, \"session\");\n\t\tcheckRuntimeCompatibility(this.futureSchema, \"future\");\n\t}\n\n\tpublic summarizeDocumentSchema(\n\t\trefSeq: number,\n\t): IDocumentSchema | IDocumentSchemaCurrent | undefined {\n\t\t// For legacy behavior, we could write nothing (return undefined).\n\t\t// It does not buy us anything, as whatever written in summary does not actually impact clients operating in legacy mode.\n\t\t// But writing current used config (and assuming most of the clients settle on same config over time) will help with transition\n\t\t// out of legacy mode, as clients transitioning out of it would be able to use all the\n\t\t// features that are mentioned in schema right away, without a need to go through schema transition (and thus for a session or\n\t\t// two losing ability to use all the features)\n\t\tconst schema = this.explicitSchemaControl ? this.documentSchema : this.desiredSchema;\n\n\t\t// It's important to keep refSeq at zero in legacy mode, such that transition out of it is simple and we do not have\n\t\t// race conditions. If we put any other number (including latest seq number), then we will have two clients\n\t\t// (loading from two different summaries) with different numbers, and eventual consistency will be broken as schema\n\t\t// change ops will be interpretted differently by those two clients.\n\t\tassert(\n\t\t\tthis.explicitSchemaControl || schema.refSeq === 0,\n\t\t\t0x94d /* refSeq should be zero */,\n\t\t);\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Called by Container runtime whenever it is about to send some op.\n\t * It gives opportunity for controller to issue its own ops - we do not want to send ops if there are no local changes in document.\n\t * Please consider note above constructor about race conditions - current design is to generate op only once in a session lifetime.\n\t * @returns Optional message to send.\n\t */\n\tpublic maybeGenerateSchemaMessage(): IDocumentSchemaChangeMessageOutgoing | undefined {\n\t\tif (this.futureSchema !== undefined && !this.opPending) {\n\t\t\tthis.opPending = true;\n\t\t\tassert(\n\t\t\t\tthis.explicitSchemaControl && this.futureSchema.runtime.explicitSchemaControl === true,\n\t\t\t\t0x94e /* not legacy */,\n\t\t\t);\n\t\t\treturn this.futureSchema;\n\t\t}\n\t}\n\n\tprivate validateSeqNumber(\n\t\tschemaSeqNumber: number,\n\t\tlastKnowSeqNumber: number,\n\t\tmessage: string,\n\t): void {\n\t\tif (!Number.isInteger(schemaSeqNumber) || !(schemaSeqNumber <= lastKnowSeqNumber)) {\n\t\t\tthrow DataProcessingError.create(\n\t\t\t\t\"DocSchema: Incorrect sequence number\",\n\t\t\t\t\"checkRuntimeCompat3\",\n\t\t\t\tundefined, // message\n\t\t\t\t{\n\t\t\t\t\tschemaSeqNumber,\n\t\t\t\t\tsequenceNumber: lastKnowSeqNumber,\n\t\t\t\t\tmessage,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Process document schema change messages\n\t * Called by ContainerRuntime whenever it sees document schema messages.\n\t * @param contents - contents of the messages\n\t * @param local - whether op is local\n\t * @param sequenceNumber - sequence number of the op\n\t * @returns - true if schema was accepted, otherwise false (rejected due to failed CAS)\n\t */\n\tpublic processDocumentSchemaMessages(\n\t\tcontents: IDocumentSchemaChangeMessageIncoming[],\n\t\tlocal: boolean,\n\t\tsequenceNumber: number,\n\t): boolean {\n\t\tfor (const content of contents) {\n\t\t\tthis.validateSeqNumber(content.refSeq, this.documentSchema.refSeq, \"content.refSeq\");\n\t\t\tthis.validateSeqNumber(this.documentSchema.refSeq, sequenceNumber, \"refSeq\");\n\t\t\t// validate is strickly less, not equal\n\t\t\tassert(\n\t\t\t\tthis.documentSchema.refSeq < sequenceNumber,\n\t\t\t\t0x950 /* time should move forward only! */,\n\t\t\t);\n\n\t\t\tif (content.refSeq !== this.documentSchema.refSeq) {\n\t\t\t\t// CAS failed\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// This assert should be after checking for successful CAS above.\n\t\t\t// This will ensure we do not trip on our own messages that are no longer wanted as we processed someone else schema change message.\n\t\t\tassert(\n\t\t\t\t!local || (this.explicitSchemaControl && this.futureSchema !== undefined),\n\t\t\t\t0x951 /* not sending ops */,\n\t\t\t);\n\n\t\t\t// Changes are in effect. Immediately check that this client understands these changes\n\t\t\tcheckRuntimeCompatibility(content, \"change\");\n\t\t\tconst schema = {\n\t\t\t\t...content,\n\t\t\t\trefSeq: sequenceNumber,\n\t\t\t} satisfies IDocumentSchemaCurrentIncoming;\n\t\t\tthis.documentSchema = schema;\n\t\t\tthis.sessionSchema = and(schema, this.desiredSchema);\n\t\t\tassert(this.sessionSchema.refSeq === sequenceNumber, 0x97d /* seq# */);\n\n\t\t\t// legacy behavior is automatically off for the document once someone sends a schema op -\n\t\t\t// from now on it's fully controlled by ops.\n\t\t\t// This is very important, as summarizeDocumentSchema() should use this new schema!\n\t\t\tthis.explicitSchemaControl = true;\n\n\t\t\t// Stop attempting changing schema.\n\t\t\t// If it was local op, then we succeeded and do not need to try again.\n\t\t\t// If it was remote op, then some changes happened to schema.\n\t\t\t// We would need to recalculate this.futureSchema by merging changes that we just received.\n\t\t\t// Avoid this complexity for now - a new client session (loading from new summary with these changes)\n\t\t\t// will automatically do this recalculation and will figure out\n\t\t\tthis.futureSchema = undefined;\n\n\t\t\tthis.onSchemaChange(this.sessionSchema);\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Indicates the pending op was not ack'd and we may try to send it again if needed.\n\t */\n\tpublic pendingOpNotAcked(): void {\n\t\tthis.opPending = false;\n\t}\n}\n\n/**\n * Determines if a given version is a dev-build (i.e. `0.0.0-#####-test`).\n */\nfunction isDevBuild(version: string): boolean {\n\tconst parsed = parse(version);\n\treturn parsed?.prerelease.includes(\"test\") ?? false;\n}\n\n/* eslint-enable jsdoc/check-indentation */\n"]}
1
+ {"version":3,"file":"documentSchema.js","sourceRoot":"","sources":["../../src/summary/documentSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,uEAA+E;AAC/E,yCAA0C;AAE1C,4DAAkD;AAwJlD;;;;;;;;;;;GAWG;AACU,QAAA,4BAA4B,GAAG,CAAC,CAAC;AAsC9C,MAAM,eAAe;IACb,GAAG,CAAC,eAAsB,EAAE,cAAqB;QACvD,OAAO,eAAe,KAAK,IAAI,IAAI,cAAc,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,CAAC;IAEM,EAAE,CAAC,eAAsB,EAAE,cAAqB;QACtD,OAAO,eAAe,KAAK,IAAI,IAAI,cAAc,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,CAAC;IAEM,QAAQ,CAAC,CAAU;QACzB,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC;IACtC,CAAC;CACD;AAED,MAAM,kBA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aAAa,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;OAEG;IACI,iBAAiB;QACvB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACxB,CAAC;CACD;AA7QD,8DA6QC;AAED;;GAEG;AACH,SAAS,UAAU,CAAC,OAAe;IAClC,MAAM,MAAM,GAAG,IAAA,iBAAK,EAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC;AACrD,CAAC;AAED,2CAA2C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { SemanticVersion } from \"@fluidframework/runtime-utils/internal\";\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\nimport { DataProcessingError } from \"@fluidframework/telemetry-utils/internal\";\nimport { gt, lt, parse } from \"semver-ts\";\n\nimport { pkgVersion } from \"../packageVersion.js\";\n\n/**\n * Descripe allowed type for properties in document schema.\n * Please note that for all property types we should use undefined to indicate that particular capability is off.\n * Using false, or some string value (like \"off\") will result in clients who do not understand that property failing, whereas\n * we want them to continue to collaborate alongside clients who support that capability, but such capability is shipping dark for now.\n * @internal\n */\nexport type DocumentSchemaValueType = string | string[] | true | number | undefined;\n\n/**\n * ID Compressor mode.\n * \"on\" - compressor is On. It's loaded as part of container load. This mode is sticky - once on, compressor is On for all\n * sessions for a given document. This results in IContainerRuntime.idCompressor to be always available.\n * \"delayed\" - ID compressor bundle is loaded only on establishing of first delta connection, i.e. it does not impact boot of cotnainer.\n * In such mode IContainerRuntime.idCompressor is not made available (unless previous sessions of same document had it \"On\").\n * The only thing that is available is IContainerRuntime.generateDocumentUniqueId() that provides opportunistically short IDs.\n * undefined - ID compressor is not loaded.\n * While IContainerRuntime.generateDocumentUniqueId() is available, it will produce long IDs that are do not compress well.\n *\n * @legacy @beta\n */\nexport type IdCompressorMode = \"on\" | \"delayed\" | undefined;\n\n/**\n * Document schema information.\n * Describes overall shape of document schema, including unknown (to this version) properties.\n *\n * Used by runtime to make a call if it can understand document schema.\n * If it can't, it should not continue with document and immediately fail, preventing random (cryptic) failures\n * down the road and potentially corrupting documents.\n * For now this structure and appropriate interpretation / behavior is focused only on runtime features.\n * In the future that could be interpolated to more areas, including DDSs used, and even possibly - application\n * schema.\n *\n * Runtime will ignore any properties at the root that it does not understand (i.e. IDocumentSchema.app), but will\n * stop (and fail session) on any unknown properties within \"runtime\" sub-tree.\n *\n * In most cases values preserved in the document will not dictate if such features should be enabled in a given session.\n * I.e. if compression is mentioned in document schema, this means that runtime version that opens such document must know\n * how to interpret such ops, but does not need to actually use compression itself. That said, some options could be\n * sticky, i.e. influence feature selection for all runtimes opening a document. ID compression is one such example.\n * Currently there is no mechanism to remove feature from this property bag, i.e. once compression was used, even if it's\n * disabled (through feature gate or code deployment), all existing documents that used compression will continue to fail\n * if opened by clients who do not support compression.\n *\n * For now we are limiting it to just plain properties, and only really simple types, but that can be changed in the future.\n *\n * @internal\n */\nexport interface IDocumentSchema {\n\t// Note: Incoming schemas from other clients may have additional root-level properties (i.e. IDocumentSchema.app)\n\t// that this client does not understand. The runtime will ignore these properties, unless they are within the\n\t// \"runtime\" sub-tree, in which case it will fail if it is unable to understand any runtime properties.\n\n\t/**\n\t * Describes how data needed to understand the schema is stored in this structure.\n\t * If runtime sees a version it does not understand, it should immediately fail and not\n\t * attempt to interpret any further data.\n\t */\n\tversion: number;\n\n\t/**\n\t * Sequence number when this schema became active.\n\t */\n\trefSeq: number;\n\n\t/**\n\t * Runtime configurations that affect the document schema. Other clients must understand these\n\t * properties to be able to open the document.\n\t */\n\truntime: Record<string, DocumentSchemaValueType>;\n\n\t/**\n\t * Info about this document that can be updated via Document Schema change op, but isn't required\n\t * to be understood by all clients (unlike the rest of IDocumentSchema properties). Because of this,\n\t * some older documents may not have this property, so it's an optional property.\n\t */\n\tinfo?: IDocumentSchemaInfo;\n}\n\n/**\n * Informational properties of the document that are not subject to strict schema enforcement.\n *\n * @internal\n */\nexport interface IDocumentSchemaInfo {\n\t/**\n\t * The minimum version of the FF runtime that should be used to load this document.\n\t * Will likely be advanced over time as applications pick up later FF versions.\n\t *\n\t * We use this to issue telemetry warning events if a client tries to open a document\n\t * with a runtime version lower than this.\n\t *\n\t * See {@link @fluidframework/container-runtime#LoadContainerRuntimeParams} for additional details on `minVersionForCollab`.\n\t *\n\t * @remarks\n\t * We use `SemanticVersion` instead of `MinimumVersionForCollab` since we may open future documents that with a\n\t * minVersionForCollab version that `MinimumVersionForCollab` does not support.\n\t */\n\tminVersionForCollab: SemanticVersion;\n}\n\n/**\n * Content of the type=ContainerMessageType.DocumentSchemaChange ops.\n * The meaning of refSeq field is different in such messages (compared to other usages of IDocumentSchemaCurrent)\n * ContainerMessageType.DocumentSchemaChange messages use CAS (Compare-and-swap) semantics, and convey\n * regSeq of last known schema change (known to a client proposing schema change).\n * @see InboundContainerRuntimeDocumentSchemaMessage\n * @internal\n */\nexport type IDocumentSchemaChangeMessageIncoming = IDocumentSchema;\n\n/**\n * Similar to {@link IDocumentSchemaChangeMessageIncoming}, but used for outgoing schema messages.\n * @see OutboundContainerRuntimeDocumentSchemaMessage\n * @internal\n */\nexport type IDocumentSchemaChangeMessageOutgoing = IDocumentSchemaCurrent;\n\n/**\n * Settings that this session would like to have, based on options and feature gates.\n *\n * WARNING: This type is used to infer IDocumentSchemaCurrent type!\n * Any changes here (including renaming of properties) are potentially changing document format and should be considered carefully!\n *\n * @internal\n */\nexport interface IDocumentSchemaFeatures {\n\t// Tells if client uses legacy behavior of changing schema.\n\t// - Legacy behavior - changing schema without leveraging schema change ops.\n\t// - New behavior - changes in schema require ops and take into affect with delay.\n\texplicitSchemaControl: boolean;\n\tcompressionLz4: boolean;\n\tidCompressorMode: IdCompressorMode;\n\topGroupingEnabled: boolean;\n\tcreateBlobPayloadPending: true | undefined;\n\n\t/**\n\t * List of disallowed versions of the runtime.\n\t * This option is sticky. Once a version of runtime is added to this list (when supplied to DocumentsSchemaController's constructor)\n\t * it will be added to the list of disallowed versions and stored in document metadata.\n\t * Each runtime checks if its version is in this list on container open. If it is, it immediately exits with error message\n\t * indicating to the user that this version is no longer supported.\n\t * Currently there is no mechanism to remove version from this list. I.e. If it was once added to the list,\n\t * it gets added to any document metadata (documents that gets open by this runtime) and there is no way to clear it from document's\n\t * metadata.\n\t */\n\tdisallowedVersions: string[];\n}\n\n/**\n * Current version known properties that define document schema\n * This must be bumped whenever the format of document schema or protocol for changing the current document schema changes\n * in a way that all old/new clients are required to understand.\n * Ex: Adding a new configuration property (under IDocumentSchema.runtime) does not require changing this version since there is logic\n * in old clients for handling new/unknown properties.\n * Ex: Adding a new property to IDocumentSchema.info does not require changing this version, since info properties are not required to be\n * understood by all clients.\n * Ex: Changing the 'document schema acceptance' mechanism from convert-and-swap to one requiring consensus does require changing this version\n * since all clients need to understand the new protocol.\n * @internal\n */\nexport const currentDocumentVersionSchema = 1;\n\n/**\n * Current document schema.\n * This interface represents the schema that we currently understand and know the\n * structure of (which properties will be present).\n *\n * @internal\n */\nexport interface IDocumentSchemaCurrent extends Required<IDocumentSchema> {\n\t// This is the version of the schema that we currently understand.\n\tversion: typeof currentDocumentVersionSchema;\n\t// This narrows the runtime property to only include the properties in IDocumentSchemaFeatures (all as optional)\n\truntime: {\n\t\t[P in keyof IDocumentSchemaFeatures]?: IDocumentSchemaFeatures[P] extends boolean\n\t\t\t? true\n\t\t\t: IDocumentSchemaFeatures[P];\n\t};\n}\n\n/**\n * Document schema that is incoming from another client but validated to be \"current\".\n *\n * This interface represents when we have validated that an incoming IDocumentSchema object\n * is compatible with the current runtime (by calling `checkRuntimeCompatibility()`).\n * However, the `info` property is optional because some older documents may not have this property, but\n * `info` is not required to be understood by all clients to be compatible.\n */\ninterface IDocumentSchemaCurrentIncoming extends Omit<IDocumentSchemaCurrent, \"info\"> {\n\tinfo?: IDocumentSchemaInfo;\n}\n\ninterface IProperty<T = unknown> {\n\tand: (persistedSchema: T, providedSchema: T) => T;\n\tor: (persistedSchema: T, providedSchema: T) => T;\n\tvalidate(t: unknown): boolean;\n}\n\nclass TrueOrUndefined implements IProperty<true | undefined> {\n\tpublic and(persistedSchema?: true, providedSchema?: true): true | undefined {\n\t\treturn persistedSchema === true && providedSchema === true ? true : undefined;\n\t}\n\n\tpublic or(persistedSchema?: true, providedSchema?: true): true | undefined {\n\t\treturn persistedSchema === true || providedSchema === true ? true : undefined;\n\t}\n\n\tpublic validate(t: unknown): t is true | undefined {\n\t\treturn t === undefined || t === true;\n\t}\n}\n\nclass TrueOrUndefinedMax extends TrueOrUndefined {\n\tpublic and(persistedSchema?: true, providedSchema?: true): true | undefined {\n\t\treturn this.or(persistedSchema, providedSchema);\n\t}\n}\n\nclass MultiChoice implements IProperty<string | undefined> {\n\tconstructor(private readonly choices: string[]) {}\n\n\tpublic and(persistedSchema?: string, providedSchema?: string): string | undefined {\n\t\tif (persistedSchema === undefined || providedSchema === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.choices[\n\t\t\tMath.min(this.choices.indexOf(persistedSchema), this.choices.indexOf(providedSchema))\n\t\t];\n\t}\n\n\tpublic or(persistedSchema?: string, providedSchema?: string): string | undefined {\n\t\tif (persistedSchema === undefined) {\n\t\t\treturn providedSchema;\n\t\t}\n\t\tif (providedSchema === undefined) {\n\t\t\treturn persistedSchema;\n\t\t}\n\t\treturn this.choices[\n\t\t\tMath.max(this.choices.indexOf(persistedSchema), this.choices.indexOf(providedSchema))\n\t\t];\n\t}\n\n\tpublic validate(t: unknown): boolean {\n\t\treturn t === undefined || (typeof t === \"string\" && this.choices.includes(t));\n\t}\n}\n\nclass IdCompressorProperty extends MultiChoice {\n\t// document schema always wins!\n\tpublic and(persistedSchema?: string, providedSchema?: string): string | undefined {\n\t\treturn persistedSchema;\n\t}\n}\n\nclass CheckVersions implements IProperty<string[] | undefined> {\n\tpublic or(\n\t\tpersistedSchema: string[] = [],\n\t\tprovidedSchema: string[] = [],\n\t): string[] | undefined {\n\t\tconst set = new Set<string>([...persistedSchema, ...providedSchema]);\n\t\treturn arrayToProp([...set.values()]);\n\t}\n\n\t// Once version is there, it stays there forever.\n\tpublic and(\n\t\tpersistedSchema: string[] = [],\n\t\tprovidedSchema: string[] = [],\n\t): string[] | undefined {\n\t\treturn this.or(persistedSchema, providedSchema);\n\t}\n\n\tpublic validate(t: unknown): boolean {\n\t\treturn t === undefined || (Array.isArray(t) && !t.includes(pkgVersion));\n\t}\n}\n\n/**\n * Helper structure to valida if a schema is compatible with existing code.\n */\nconst documentSchemaSupportedConfigs = {\n\texplicitSchemaControl: new TrueOrUndefinedMax(), // once new behavior shows up, it's sticky\n\tidCompressorMode: new IdCompressorProperty([\"delayed\", \"on\"]),\n\topGroupingEnabled: new TrueOrUndefined(),\n\tcompressionLz4: new TrueOrUndefined(),\n\tcreateBlobPayloadPending: new TrueOrUndefined(),\n\tdisallowedVersions: new CheckVersions(),\n};\n\n/**\n * Checks if a given schema is compatible with current code, i.e. if current code can understand all the features of that schema.\n * If schema is not compatible with current code, it throws an exception.\n * @param documentSchema - current schema\n */\nfunction checkRuntimeCompatibility(\n\tdocumentSchema: IDocumentSchema | undefined,\n\tschemaName: string,\n): asserts documentSchema is IDocumentSchemaCurrentIncoming {\n\t// Back-compat - we can't do anything about legacy documents.\n\t// There is no way to validate them, so we are taking a guess that safe deployment processes used by a given app\n\t// do not run into compat problems.\n\tif (documentSchema === undefined) {\n\t\treturn;\n\t}\n\n\tconst msg = \"Document can't be opened with current version of the code\";\n\tif (documentSchema.version !== currentDocumentVersionSchema) {\n\t\tthrow DataProcessingError.create(\n\t\t\tmsg,\n\t\t\t\"checkRuntimeCompat1\",\n\t\t\tundefined, // message\n\t\t\t{\n\t\t\t\truntimeSchemaVersion: documentSchema.version,\n\t\t\t\tcurrentRuntimeSchemaVersion: currentDocumentVersionSchema,\n\t\t\t\tschemaName,\n\t\t\t},\n\t\t);\n\t}\n\n\tlet unknownProperty: string | undefined;\n\n\tconst regSeq = documentSchema.refSeq;\n\t// defence in depth - it should not be possible to get here anything other than integer, but worth validating it.\n\tif (typeof regSeq !== \"number\" || regSeq < 0 || !Number.isInteger(regSeq)) {\n\t\tunknownProperty = \"refSeq\";\n\t} else if (documentSchema.runtime === null || typeof documentSchema.runtime !== \"object\") {\n\t\tunknownProperty = \"runtime\";\n\t} else {\n\t\tfor (const [name, value] of Object.entries(documentSchema.runtime)) {\n\t\t\tconst validator = documentSchemaSupportedConfigs[name] as IProperty | undefined;\n\t\t\tif (!(validator?.validate(value) ?? false)) {\n\t\t\t\tunknownProperty = `runtime/${name}`;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (unknownProperty !== undefined) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\tconst value = documentSchema[unknownProperty];\n\t\tthrow DataProcessingError.create(\n\t\t\tmsg,\n\t\t\t\"checkRuntimeCompat2\",\n\t\t\tundefined, // message\n\t\t\t{\n\t\t\t\tcodeVersion: currentDocumentVersionSchema,\n\t\t\t\tproperty: unknownProperty,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tvalue,\n\t\t\t\tschemaName,\n\t\t\t},\n\t\t);\n\t}\n}\n\nfunction and(\n\tpersistedSchema: IDocumentSchemaCurrentIncoming,\n\tprovidedSchema: IDocumentSchemaCurrent,\n): IDocumentSchemaCurrent {\n\tconst runtime = {};\n\tfor (const key of new Set([\n\t\t...Object.keys(persistedSchema.runtime),\n\t\t...Object.keys(providedSchema.runtime),\n\t])) {\n\t\truntime[key] = (documentSchemaSupportedConfigs[key] as IProperty).and(\n\t\t\tpersistedSchema.runtime[key],\n\t\t\tprovidedSchema.runtime[key],\n\t\t);\n\t}\n\n\t// We keep the persisted minVersionForCollab if present, even if the provided minVersionForCollab\n\t// is higher.\n\tconst minVersionForCollab =\n\t\tpersistedSchema.info?.minVersionForCollab ?? providedSchema.info.minVersionForCollab;\n\n\treturn {\n\t\tversion: currentDocumentVersionSchema,\n\t\trefSeq: persistedSchema.refSeq,\n\t\tinfo: { minVersionForCollab },\n\t\truntime,\n\t};\n}\n\nfunction or(\n\tpersistedSchema: IDocumentSchemaCurrentIncoming,\n\tprovidedSchema: IDocumentSchemaCurrent,\n): IDocumentSchemaCurrent {\n\tconst runtime = {};\n\tfor (const key of new Set([\n\t\t...Object.keys(persistedSchema.runtime),\n\t\t...Object.keys(providedSchema.runtime),\n\t])) {\n\t\truntime[key] = (documentSchemaSupportedConfigs[key] as IProperty).or(\n\t\t\tpersistedSchema.runtime[key],\n\t\t\tprovidedSchema.runtime[key],\n\t\t);\n\t}\n\n\t// We take the greater of the persisted/provided minVersionForCollab\n\tconst minVersionForCollab =\n\t\tpersistedSchema.info === undefined\n\t\t\t? providedSchema.info.minVersionForCollab\n\t\t\t: gt(persistedSchema.info.minVersionForCollab, providedSchema.info.minVersionForCollab)\n\t\t\t\t? persistedSchema.info.minVersionForCollab\n\t\t\t\t: providedSchema.info.minVersionForCollab;\n\n\treturn {\n\t\tversion: currentDocumentVersionSchema,\n\t\trefSeq: persistedSchema.refSeq,\n\t\tinfo: { minVersionForCollab },\n\t\truntime,\n\t};\n}\n\n/**\n * Determines if two schemas are the \"same\".\n * Schemas are considered **not** the same if a schema change op is required to make\n * the properties of `persistedSchema` match to the properties of `providedSchema`.\n */\nfunction same(\n\tpersistedSchema: IDocumentSchemaCurrentIncoming,\n\tprovidedSchema: IDocumentSchemaCurrent,\n): boolean {\n\tif (\n\t\tpersistedSchema.info === undefined ||\n\t\tlt(persistedSchema.info.minVersionForCollab, providedSchema.info.minVersionForCollab)\n\t) {\n\t\t// If the persisted schema's minVersionForCollab is undefined or less than the provided schema's\n\t\t// minVersionForCollab, then we should send a schema change op to update the minVersionForCollab.\n\t\treturn false;\n\t}\n\tfor (const key of new Set([\n\t\t...Object.keys(persistedSchema.runtime),\n\t\t...Object.keys(providedSchema.runtime),\n\t])) {\n\t\t// If schemas differ only by type of behavior, then we should not send schema change ops!\n\t\tif (\n\t\t\tkey !== \"explicitSchemaControl\" &&\n\t\t\tpersistedSchema.runtime[key] !== providedSchema.runtime[key]\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction boolToProp(b: boolean): true | undefined {\n\treturn b ? true : undefined;\n}\n\nfunction arrayToProp(arr: string[]): string[] | undefined {\n\treturn arr.length === 0 ? undefined : arr;\n}\n\n/* eslint-disable jsdoc/check-indentation */\n\n/**\n * Controller of document schema.\n *\n * Recommended pre-reading: https://github.com/microsoft/FluidFramework/blob/main/packages/dds/SchemaVersioning.md\n *\n * This class manages current document schema and transitions between document schemas.\n * At the moment, it only focuses on subset of document schema, specifically - how FluidFramework runtime serializes data\n * (summary and op format), features & capabilities that a version of runtime has to support and understand in\n * order to collaborate on a document.\n * New features that modify document format have to be included in document schema definition.\n * Usage of such features could only happen after document schema has been updated to reflect such feature.\n *\n * This formality allows clients that do not understand such features to fail right away when they observe\n * document schema listing capabilities that such client does not understand.\n * Old clients will fail in predictable way. This allows us to\n * 1) Immediately see such issues and adjust if features are enabled too early, before changes have been saturated.\n * 2) There is no way to get to 100% saturation with new code. Even if we have 99.99% saturation, there are\n * still 0.01% of clients who will fail. Failing early and predictably ensures they have no chance to limp along\n * and potentially corrupt the document. This is especially true for summarizer client, who could simply \"undo\"\n * changes it does not understands.\n *\n * It's important to note how it overlaps with feature gates and safe velocity.\n * If new feature was in use, that resulted in a number of documents referencing such feature in document schema.\n * But, developers (through code deployment or feature gates) could disable usage of such features.\n * That will stop a process of further document schema changes (for documents that were not using such feature).\n * And documents that already list such capability in their schema will continue to do so. Later ensures that old\n * clients who do not understand such feature will continue to fail to open such documents, as such documents very\n * likely contain data in a new format.\n *\n * Controller operates with 4 schemas:\n * - document schema: whatever we loaded from summary metadata + ops. It follows eventuall consistency rules (i.e. like DDS).\n * - desired schema - what client is asking for to have (i.e. all the desired settings, based on runtime options / feature gates).\n * - session schema - current session schema. It's \"and\" of the above two schemas.\n * - future schema - \"or\" of document and desires schemas.\n *\n * \"or\" & \"and\" operators are defined individually for each property. For Boolean properties it's literally &&, || operators.\n * But for other properties it's more nuanced.\n *\n * Whenver document schema does not match future schema, controller will send an op that attempts to changs documents schema to\n * future schema.\n *\n * Users of this class need to use DocumentsSchemaController.sessionSchema to determine what features can be used.\n *\n * There are two modes this class can operate:\n * 1) Legacy mode. In such mode it does not issue any ops to change document schema. Any changes happen implicitly,\n * right away, and new features are available right away\n * 2) Non-legacy mode. In such mode any changes to schema require an op roundtrip. This class will manage such transitions.\n * However code should assume that any new features that were not enabled in a given document will not be available\n * for a given session. That's because this session may never send any ops (including read-only documents). Or it may\n * fail to convert schema.\n * This class promises eventual movement forward. I.e. if new feature is allowed (let's say - through feature gates),\n * then eventually all documents that are modified will have that feature reflected in their schema. It could require\n * multiple reloads / new sessions to get there (depends on if code reacts to schema changes right away, or only consults\n * schema on document load).\n *\n * How schemas are changed (in non-legacy mode):\n * If a client needs to change a schema, it will attempt to do so as part of normal ops sending process.\n * Changes happen in CAS (Compare-and-swap) fashion, i.e. client tells current schema and schema it wants to change to.\n * When a number of clients race to change a schema, then only one of them will win, all others will fail because they will\n * reference old schema that is no longer in effect.\n * Clients can retry, but current implementation is simply - they will not (and will rely on next session / reload to do\n * recalc and decide if schema needs to be changed or not).\n *\n * @internal\n * @sealed\n */\nexport class DocumentsSchemaController {\n\tprivate explicitSchemaControl: boolean;\n\n\t/**\n\t * Have we generated a DocumentSchemaChange op and we're waiting for the ack?\n\t * This is used to ensure that we do not generate multiple schema change ops - this client should only ever send one (if any).\n\t */\n\tprivate opPending = false;\n\n\t// schema coming from document metadata (snapshot we loaded from)\n\tprivate documentSchema: IDocumentSchema;\n\n\t// desired schema, based on feature gates / runtime options.\n\t// This includes requests to enable to disable functionality\n\tprivate readonly desiredSchema: IDocumentSchemaCurrent;\n\n\t// OR() of document schema and desired schema. It enables all the features that are enabled in either of schemas.\n\tprivate futureSchema: IDocumentSchemaCurrent | undefined;\n\n\t// Current schema this session operates with.\n\t// 1) Legacy mode (explicitSchemaControl === false): this is same as desired schema - all options that were requested to be on are on, and all options requested to be off are off.\n\t// 2) Non-legacy mode (explicitSchemaControl === true): this is AND() of document schema and desired schema. Only options that are enabled in both are enabled here.\n\t// If there are any options that are not enabled in document schema, but are enabled in desired schema, then attempt to change schema\n\t// (and enable such options) will be made through the session.\n\tpublic sessionSchema: IDocumentSchemaCurrent;\n\n\t/**\n\t * Constructs DocumentsSchemaController that controls current schema and processes around it, including changes in schema.\n\t * @param existing - Is the document existing document, or a new doc.\n\t * @param documentMetadataSchema - current document's schema, if present.\n\t * @param features - features of the document schema that current session wants to see enabled.\n\t * @param onSchemaChange - callback that is called whenever schema is changed (not called on creation / load, only when processing document schema change ops)\n\t * @param info - Informational properties of the document that are not subject to strict schema enforcement\n\t * @param logger - telemetry logger from the runtime\n\t */\n\tconstructor(\n\t\texisting: boolean,\n\t\tsnapshotSequenceNumber: number,\n\t\tdocumentMetadataSchema: IDocumentSchema | undefined,\n\t\tfeatures: IDocumentSchemaFeatures,\n\t\tprivate readonly onSchemaChange: (schema: IDocumentSchemaCurrent) => void,\n\t\tinfo: IDocumentSchemaInfo,\n\t\tlogger: ITelemetryLoggerExt,\n\t) {\n\t\t// For simplicity, let's only support new schema features for explicit schema control mode\n\t\tassert(\n\t\t\tfeatures.disallowedVersions.length === 0 || features.explicitSchemaControl,\n\t\t\t0x949 /* not supported */,\n\t\t);\n\n\t\t// We check the document's metadata to see if there is a minVersionForCollab. If it's not an existing document or\n\t\t// if the document is older, then it won't have one. If it does have a minVersionForCollab, we check if it's greater\n\t\t// than this client's runtime version. If so, we log a telemetry event to warn the customer that the client is outdated.\n\t\t// Note: We only send a warning because we will confirm via `checkRuntimeCompatibility` if this client **can** understand\n\t\t// the existing document's schema. We still want to issue a warning regardless if this client can or cannot understand the\n\t\t// schema since it may be a sign that the customer is not properly waiting for saturation before updating their\n\t\t// `minVersionForCollab` value, which could cause disruptions to users in the future.\n\t\tconst existingMinVersionForCollab = documentMetadataSchema?.info?.minVersionForCollab;\n\t\tif (\n\t\t\texistingMinVersionForCollab !== undefined &&\n\t\t\tgt(existingMinVersionForCollab, pkgVersion) &&\n\t\t\t// We also want to avoid sending the telemetry warning for dev builds, since they currently are formatted as\n\t\t\t// `0.0.0-#####-test`. This will cause the telemetry warning to constantly fire.\n\t\t\t// TODO: This can be removed after ADO:41351\n\t\t\t!isDevBuild(pkgVersion)\n\t\t) {\n\t\t\tconst warnMsg = `WARNING: The version of Fluid Framework used by this client (${pkgVersion}) is not supported by this document! Please upgrade to version ${existingMinVersionForCollab} or later to ensure compatibility.`;\n\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\teventName: \"MinVersionForCollabWarning\",\n\t\t\t\tmessage: warnMsg,\n\t\t\t});\n\t\t}\n\n\t\t// Desired schema by this session - almost all props are coming from arguments\n\t\tthis.desiredSchema = {\n\t\t\tversion: currentDocumentVersionSchema,\n\t\t\trefSeq: documentMetadataSchema?.refSeq ?? 0,\n\t\t\tinfo,\n\t\t\truntime: {\n\t\t\t\texplicitSchemaControl: boolToProp(features.explicitSchemaControl),\n\t\t\t\tcompressionLz4: boolToProp(features.compressionLz4),\n\t\t\t\tidCompressorMode: features.idCompressorMode,\n\t\t\t\topGroupingEnabled: boolToProp(features.opGroupingEnabled),\n\t\t\t\tcreateBlobPayloadPending: features.createBlobPayloadPending,\n\t\t\t\tdisallowedVersions: arrayToProp(features.disallowedVersions),\n\t\t\t},\n\t\t};\n\n\t\t// Schema coming from document metadata (snapshot we loaded from), or if no document exists\n\t\t// (this is a new document) then this is the same as desiredSchema (same as session schema in such case).\n\t\t// Latter is important sure that's what will go into summary.\n\t\tthis.documentSchema = existing\n\t\t\t? (documentMetadataSchema ??\n\t\t\t\t({\n\t\t\t\t\tversion: currentDocumentVersionSchema,\n\t\t\t\t\t// see comment in summarizeDocumentSchema() on why it has to stay zero\n\t\t\t\t\trefSeq: 0,\n\t\t\t\t\tinfo,\n\t\t\t\t\t// If it's existing document and it has no schema, then it was written by legacy client.\n\t\t\t\t\t// If it's a new document, then we define it's legacy-related behaviors.\n\t\t\t\t\truntime: {\n\t\t\t\t\t\texplicitSchemaControl: boolToProp(!existing && features.explicitSchemaControl),\n\t\t\t\t\t},\n\t\t\t\t} satisfies IDocumentSchemaCurrent))\n\t\t\t: this.desiredSchema;\n\n\t\tcheckRuntimeCompatibility(this.documentSchema, \"document\");\n\t\tthis.validateSeqNumber(this.documentSchema.refSeq, snapshotSequenceNumber, \"summary\");\n\n\t\t// Use legacy behavior only if both document and options tell us to use legacy.\n\t\t// Otherwise it's no longer legacy time!\n\t\tthis.explicitSchemaControl =\n\t\t\tthis.documentSchema.runtime.explicitSchemaControl === true ||\n\t\t\tfeatures.explicitSchemaControl;\n\n\t\t// Calculate\n\t\t// - current session schema (overlap of document schema and desired schema)\n\t\t// - future schema to propose (concatination of document schema and desired schema)\n\t\tif (!this.explicitSchemaControl || !existing) {\n\t\t\tthis.sessionSchema = this.desiredSchema;\n\t\t\tassert(\n\t\t\t\tboolToProp(this.explicitSchemaControl) ===\n\t\t\t\t\tthis.sessionSchema.runtime.explicitSchemaControl,\n\t\t\t\t0x94a /* explicitSchemaControl */,\n\t\t\t);\n\t\t\tthis.futureSchema = undefined;\n\t\t} else {\n\t\t\tthis.sessionSchema = and(this.documentSchema, this.desiredSchema);\n\t\t\tthis.futureSchema = or(this.documentSchema, this.desiredSchema);\n\t\t\tassert(this.sessionSchema.runtime.explicitSchemaControl === true, 0x94b /* legacy */);\n\t\t\tassert(this.futureSchema.runtime.explicitSchemaControl === true, 0x94c /* legacy */);\n\t\t\tif (same(this.documentSchema, this.futureSchema)) {\n\t\t\t\tthis.futureSchema = undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Validate that schema we are operating in is actually a schema we consider compatible with current runtime.\n\t\tcheckRuntimeCompatibility(this.desiredSchema, \"desired\");\n\t\tcheckRuntimeCompatibility(this.sessionSchema, \"session\");\n\t\tcheckRuntimeCompatibility(this.futureSchema, \"future\");\n\t}\n\n\tpublic summarizeDocumentSchema(\n\t\trefSeq: number,\n\t): IDocumentSchema | IDocumentSchemaCurrent | undefined {\n\t\t// For legacy behavior, we could write nothing (return undefined).\n\t\t// It does not buy us anything, as whatever written in summary does not actually impact clients operating in legacy mode.\n\t\t// But writing current used config (and assuming most of the clients settle on same config over time) will help with transition\n\t\t// out of legacy mode, as clients transitioning out of it would be able to use all the\n\t\t// features that are mentioned in schema right away, without a need to go through schema transition (and thus for a session or\n\t\t// two losing ability to use all the features)\n\t\tconst schema = this.explicitSchemaControl ? this.documentSchema : this.desiredSchema;\n\n\t\t// It's important to keep refSeq at zero in legacy mode, such that transition out of it is simple and we do not have\n\t\t// race conditions. If we put any other number (including latest seq number), then we will have two clients\n\t\t// (loading from two different summaries) with different numbers, and eventual consistency will be broken as schema\n\t\t// change ops will be interpretted differently by those two clients.\n\t\tassert(\n\t\t\tthis.explicitSchemaControl || schema.refSeq === 0,\n\t\t\t0x94d /* refSeq should be zero */,\n\t\t);\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Called by Container runtime whenever it is about to send some op.\n\t * It gives opportunity for controller to issue its own ops - we do not want to send ops if there are no local changes in document.\n\t * Please consider note above constructor about race conditions - current design is to generate op only once in a session lifetime.\n\t * @returns Optional message to send.\n\t */\n\tpublic maybeGenerateSchemaMessage(): IDocumentSchemaChangeMessageOutgoing | undefined {\n\t\tif (this.futureSchema !== undefined && !this.opPending) {\n\t\t\tthis.opPending = true;\n\t\t\tassert(\n\t\t\t\tthis.explicitSchemaControl && this.futureSchema.runtime.explicitSchemaControl === true,\n\t\t\t\t0x94e /* not legacy */,\n\t\t\t);\n\t\t\treturn this.futureSchema;\n\t\t}\n\t}\n\n\tprivate validateSeqNumber(\n\t\tschemaSeqNumber: number,\n\t\tlastKnowSeqNumber: number,\n\t\tmessage: string,\n\t): void {\n\t\tif (!Number.isInteger(schemaSeqNumber) || !(schemaSeqNumber <= lastKnowSeqNumber)) {\n\t\t\tthrow DataProcessingError.create(\n\t\t\t\t\"DocSchema: Incorrect sequence number\",\n\t\t\t\t\"checkRuntimeCompat3\",\n\t\t\t\tundefined, // message\n\t\t\t\t{\n\t\t\t\t\tschemaSeqNumber,\n\t\t\t\t\tsequenceNumber: lastKnowSeqNumber,\n\t\t\t\t\tmessage,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Process document schema change messages\n\t * Called by ContainerRuntime whenever it sees document schema messages.\n\t * @param contents - contents of the messages\n\t * @param local - whether op is local\n\t * @param sequenceNumber - sequence number of the op\n\t * @returns true if schema was accepted, otherwise false (rejected due to failed CAS)\n\t */\n\tpublic processDocumentSchemaMessages(\n\t\tcontents: IDocumentSchemaChangeMessageIncoming[],\n\t\tlocal: boolean,\n\t\tsequenceNumber: number,\n\t): boolean {\n\t\tfor (const content of contents) {\n\t\t\tthis.validateSeqNumber(content.refSeq, this.documentSchema.refSeq, \"content.refSeq\");\n\t\t\tthis.validateSeqNumber(this.documentSchema.refSeq, sequenceNumber, \"refSeq\");\n\t\t\t// validate is strickly less, not equal\n\t\t\tassert(\n\t\t\t\tthis.documentSchema.refSeq < sequenceNumber,\n\t\t\t\t0x950 /* time should move forward only! */,\n\t\t\t);\n\n\t\t\tif (content.refSeq !== this.documentSchema.refSeq) {\n\t\t\t\t// CAS failed\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// This assert should be after checking for successful CAS above.\n\t\t\t// This will ensure we do not trip on our own messages that are no longer wanted as we processed someone else schema change message.\n\t\t\tassert(\n\t\t\t\t!local || (this.explicitSchemaControl && this.futureSchema !== undefined),\n\t\t\t\t0x951 /* not sending ops */,\n\t\t\t);\n\n\t\t\t// Changes are in effect. Immediately check that this client understands these changes\n\t\t\tcheckRuntimeCompatibility(content, \"change\");\n\t\t\tconst schema = {\n\t\t\t\t...content,\n\t\t\t\trefSeq: sequenceNumber,\n\t\t\t} satisfies IDocumentSchemaCurrentIncoming;\n\t\t\tthis.documentSchema = schema;\n\t\t\tthis.sessionSchema = and(schema, this.desiredSchema);\n\t\t\tassert(this.sessionSchema.refSeq === sequenceNumber, 0x97d /* seq# */);\n\n\t\t\t// legacy behavior is automatically off for the document once someone sends a schema op -\n\t\t\t// from now on it's fully controlled by ops.\n\t\t\t// This is very important, as summarizeDocumentSchema() should use this new schema!\n\t\t\tthis.explicitSchemaControl = true;\n\n\t\t\t// Stop attempting changing schema.\n\t\t\t// If it was local op, then we succeeded and do not need to try again.\n\t\t\t// If it was remote op, then some changes happened to schema.\n\t\t\t// We would need to recalculate this.futureSchema by merging changes that we just received.\n\t\t\t// Avoid this complexity for now - a new client session (loading from new summary with these changes)\n\t\t\t// will automatically do this recalculation and will figure out\n\t\t\tthis.futureSchema = undefined;\n\n\t\t\tthis.onSchemaChange(this.sessionSchema);\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Indicates the pending op was not ack'd and we may try to send it again if needed.\n\t */\n\tpublic pendingOpNotAcked(): void {\n\t\tthis.opPending = false;\n\t}\n}\n\n/**\n * Determines if a given version is a dev-build (i.e. `0.0.0-#####-test`).\n */\nfunction isDevBuild(version: string): boolean {\n\tconst parsed = parse(version);\n\treturn parsed?.prerelease.includes(\"test\") ?? false;\n}\n\n/* eslint-enable jsdoc/check-indentation */\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"orderedClientElection.js","sourceRoot":"","sources":["../../src/summary/orderedClientElection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAA2C;AAE3C,+DAAiE;AAOjE,kEAA6D;AAM7D,uEAIkD;AAElD,6DAA4D;AAoF5D;;;;;;GAMG;AACH,MAAa,uBACZ,SAAQ,gCAAiD;IAqBzD,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IAC5B,CAAC;IACD,IAAW,YAAY;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,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,CAAC;IACH,CAAC;IAEM,SAAS;QACf,OAAO;YACN,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;YACnD,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ;YAC7C,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ;SAC7C,CAAC;IACH,CAAC;IAEO,oBAAoB,CAC3B,SAAiB,EACjB,MAAiC,EACjC,cAAsB,EACtB,YAAqB,KAAK,EAC1B,MAAe;QAEf,IAAI,IAAI,CAAC,uBAAuB,IAAI,SAAS,EAAE,CAAC;YAC/C,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;gBAChC,SAAS;gBACT,QAAQ,EAAE,MAAM,EAAE,QAAQ;gBAC1B,cAAc;gBACd,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ;gBAC7C,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ;gBAC7C,UAAU,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;gBACpE,kBAAkB,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,yCAAoB;gBACxE,MAAM;aACN,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD;AA7VD,sDA6VC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @rushstack/no-new-null */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport type {\n\tIEvent,\n\tIEventProvider,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIClient,\n\tIQuorumClients,\n\tISequencedClient,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tUsageError,\n\tcreateChildLogger,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { summarizerClientType } from \"./summarizerTypes.js\";\n\n// helper types for recursive readonly.\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type ImmutablePrimitives = undefined | null | boolean | string | number | Function;\nexport type Immutable<T> = T extends ImmutablePrimitives\n\t? T\n\t: T extends (infer A)[]\n\t\t? readonly Immutable<A>[]\n\t\t: T extends Map<infer K, infer V>\n\t\t\t? ReadonlyMap<Immutable<K>, Immutable<V>>\n\t\t\t: T extends Set<infer V>\n\t\t\t\t? ReadonlySet<Immutable<V>>\n\t\t\t\t: { readonly [K in keyof T]: Immutable<T[K]> };\n\n/**\n * Minimum information for a client tracked for election consideration.\n */\nexport interface ITrackedClient {\n\treadonly clientId: string;\n\treadonly sequenceNumber: number;\n\treadonly client: Immutable<IClient>;\n}\n\n/**\n * Common contract for link nodes within an OrderedClientCollection.\n */\nexport interface ILinkNode {\n\treadonly sequenceNumber: number;\n\tyoungerClient: ILinkedClient | undefined;\n}\n\n/**\n * Placeholder root node within an OrderedClientCollection; does not represent a client.\n */\nexport interface IRootLinkNode extends ILinkNode {\n\treadonly sequenceNumber: -1;\n\treadonly olderClient: undefined;\n}\n\n/**\n * Additional information required to keep track of the client within the doubly-linked list.\n */\nexport interface ILinkedClient extends ILinkNode, ITrackedClient {\n\tolderClient: LinkNode;\n}\n\n/**\n * Any link node within OrderedClientCollection including the placeholder root node.\n */\nexport type LinkNode = IRootLinkNode | ILinkedClient;\n\n/**\n * Events raised by an OrderedClientCollection.\n */\nexport interface IOrderedClientCollectionEvents extends IEvent {\n\t/**\n\t * Event fires when client is being added.\n\t */\n\t(\n\t\tevent: \"addClient\" | \"removeClient\",\n\t\tlistener: (client: ILinkedClient, sequenceNumber: number) => void,\n\t);\n}\n\n/**\n * Contract for a sorted collection of all clients in the quorum.\n */\nexport interface IOrderedClientCollection\n\textends IEventProvider<IOrderedClientCollectionEvents> {\n\t/**\n\t * Count of clients in the collection.\n\t */\n\treadonly count: number;\n\t/**\n\t * Pointer to the oldest client in the collection.\n\t */\n\treadonly oldestClient: ILinkedClient | undefined;\n\t/**\n\t * Returns a sorted array of all the clients in the collection.\n\t */\n\tgetAllClients(): ILinkedClient[];\n}\n\n/**\n * Tracks clients in the Quorum. It maintains their order using their join op\n * sequence numbers.\n * Internally, the collection of clients is maintained in a doubly-linked list,\n * with pointers to both the first and last nodes.\n * The first (root) node is a placeholder to simplify logic and reduce null checking.\n */\nexport class OrderedClientCollection\n\textends TypedEventEmitter<IOrderedClientCollectionEvents>\n\timplements IOrderedClientCollection\n{\n\t/**\n\t * Collection of ALL clients currently in the quorum, with client ids as keys.\n\t */\n\tprivate readonly clientMap = new Map<string, ILinkedClient>();\n\t/**\n\t * Placeholder head node of linked list, for simplified null checking.\n\t */\n\tprivate readonly rootNode: IRootLinkNode = {\n\t\tsequenceNumber: -1,\n\t\tolderClient: undefined,\n\t\tyoungerClient: undefined,\n\t};\n\t/**\n\t * Pointer to end of linked list, for optimized client adds.\n\t */\n\tprivate _youngestClient: LinkNode = this.rootNode;\n\tprivate readonly logger: ITelemetryLoggerExt;\n\n\tpublic get count(): number {\n\t\treturn this.clientMap.size;\n\t}\n\tpublic get oldestClient(): ILinkedClient | undefined {\n\t\treturn this.rootNode.youngerClient;\n\t}\n\n\tconstructor(\n\t\tlogger: ITelemetryBaseLogger,\n\t\tdeltaManager: Pick<IDeltaManager<unknown, unknown>, \"lastSequenceNumber\">,\n\t\tquorum: Pick<IQuorumClients, \"getMembers\" | \"on\">,\n\t) {\n\t\tsuper();\n\t\tthis.logger = createChildLogger({ logger, namespace: \"OrderedClientCollection\" });\n\t\tconst members = quorum.getMembers();\n\t\tfor (const [clientId, client] of members) {\n\t\t\tthis.addClient(clientId, client);\n\t\t}\n\n\t\tquorum.on(\"addMember\", (clientId, client) => {\n\t\t\tconst newClient = this.addClient(clientId, client);\n\t\t\tthis.emit(\"addClient\", newClient, deltaManager.lastSequenceNumber);\n\t\t});\n\t\tquorum.on(\"removeMember\", (clientId) => {\n\t\t\tconst sequenceNumber = deltaManager.lastSequenceNumber;\n\t\t\tconst removeClient = this.removeClient(clientId);\n\t\t\tif (removeClient === undefined) {\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"ClientNotFound\",\n\t\t\t\t\tclientId,\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.emit(\"removeClient\", removeClient, sequenceNumber);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate addClient(clientId: string, client: ISequencedClient): ITrackedClient {\n\t\t// Normal case is adding the latest client, which will bypass loop.\n\t\t// Find where it belongs otherwise (maybe possible during initial load?).\n\t\tassert(\n\t\t\tclient.sequenceNumber > -1,\n\t\t\t0x1f6 /* \"Negative client sequence number not allowed\" */,\n\t\t);\n\t\tlet currClient = this._youngestClient;\n\t\twhile (currClient.sequenceNumber > client.sequenceNumber) {\n\t\t\tassert(\n\t\t\t\tcurrClient.olderClient !== undefined,\n\t\t\t\t0x1f7 /* \"Previous client should always be defined\" */,\n\t\t\t);\n\t\t\t// Note: If adding a client older than the elected client, it will not be automatically elected.\n\t\t\tcurrClient = currClient.olderClient;\n\t\t}\n\n\t\t// Now currClient is the node right before where the new client node should be.\n\t\tconst newClient: ILinkedClient = {\n\t\t\tclientId,\n\t\t\tsequenceNumber: client.sequenceNumber,\n\t\t\tclient: { ...client.client }, // shallow clone\n\t\t\tolderClient: currClient,\n\t\t\tyoungerClient: currClient.youngerClient,\n\t\t};\n\n\t\t// Update prev node to point to this new node.\n\t\tnewClient.olderClient.youngerClient = newClient;\n\n\t\tif (newClient.youngerClient === undefined) {\n\t\t\t// Update linked list end pointer to youngest client.\n\t\t\tthis._youngestClient = newClient;\n\t\t} else {\n\t\t\t// Update next node to point back to this new node.\n\t\t\tnewClient.youngerClient.olderClient = newClient;\n\t\t}\n\n\t\tthis.clientMap.set(clientId, newClient);\n\t\treturn newClient;\n\t}\n\n\tprivate removeClient(clientId: string): ITrackedClient | undefined {\n\t\tconst removeClient = this.clientMap.get(clientId);\n\t\tif (removeClient === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update prev node to point to next node.\n\t\tremoveClient.olderClient.youngerClient = removeClient.youngerClient;\n\n\t\tif (removeClient.youngerClient === undefined) {\n\t\t\t// Update linked list end pointer to youngest client.\n\t\t\tthis._youngestClient = removeClient.olderClient;\n\t\t} else {\n\t\t\t// Update next node to point back to previous node.\n\t\t\tremoveClient.youngerClient.olderClient = removeClient.olderClient;\n\t\t}\n\n\t\tthis.clientMap.delete(clientId);\n\t\treturn removeClient;\n\t}\n\n\t/**\n\t * Returns an array of all clients being tracked in order from oldest to newest.\n\t */\n\tpublic getAllClients(): ILinkedClient[] {\n\t\tconst result: ILinkedClient[] = [];\n\t\tlet currClient: LinkNode = this.rootNode;\n\t\twhile (currClient.youngerClient !== undefined) {\n\t\t\tresult.push(currClient.youngerClient);\n\t\t\tcurrClient = currClient.youngerClient;\n\t\t}\n\t\treturn result;\n\t}\n}\n\n/**\n * Events raised by an OrderedClientElection.\n */\nexport interface IOrderedClientElectionEvents extends IEvent {\n\t/**\n\t * Event fires when the currently elected client changes.\n\t */\n\t(\n\t\tevent: \"election\",\n\t\tlistener: (\n\t\t\t/**\n\t\t\t * Newly elected client.\n\t\t\t */\n\t\t\tclient: ITrackedClient | undefined,\n\t\t\t/**\n\t\t\t * Sequence number where election took place.\n\t\t\t */\n\t\t\tsequenceNumber: number,\n\t\t\t/**\n\t\t\t * Previously elected client.\n\t\t\t */\n\t\t\tprevClient: ITrackedClient | undefined,\n\t\t) => void,\n\t);\n}\n\n/**\n * Serialized state of IOrderedClientElection.\n * @internal\n */\nexport interface ISerializedElection {\n\t/**\n\t * Sequence number at the time of the latest election.\n\t */\n\treadonly electionSequenceNumber: number;\n\n\t/**\n\t * Most recently elected client id. This is either:\n\t *\n\t * 1. the interactive elected parent client, in which case electedClientId === electedParentId,\n\t * and the SummaryManager on the elected client will spawn a summarizer client, or\n\t *\n\t * 2. the non-interactive summarizer client itself.\n\t */\n\treadonly electedClientId: string | undefined;\n\n\t/**\n\t * Most recently elected parent client id. This is always an interactive client.\n\t */\n\treadonly electedParentId: string | undefined;\n}\n\n/**\n * Contract for maintaining a deterministic client election based on eligibility.\n */\nexport interface IOrderedClientElection extends IEventProvider<IOrderedClientElectionEvents> {\n\t/**\n\t * Count of eligible clients in the collection.\n\t */\n\treadonly eligibleCount: number;\n\n\t/**\n\t * Currently elected client. This is either:\n\t *\n\t * 1. the interactive elected parent client, in which case electedClientId === electedParentId,\n\t * and the SummaryManager on the elected client will spawn a summarizer client, or\n\t *\n\t * 2. the non-interactive summarizer client itself.\n\t */\n\treadonly electedClient: ITrackedClient | undefined;\n\t/**\n\t * Currently elected parent client. This is always an interactive client.\n\t */\n\treadonly electedParent: ITrackedClient | undefined;\n\t/**\n\t * Sequence number of most recent election.\n\t */\n\treadonly electionSequenceNumber: number;\n\t/**\n\t * Resets the currently elected client back to the oldest eligible client.\n\t */\n\tresetElectedClient(sequenceNumber: number): void;\n\t/**\n\t * Peeks at what the next elected client would be if incrementElectedClient were called.\n\t */\n\tpeekNextElectedClient(): ITrackedClient | undefined;\n\t/**\n\t * Returns a sorted array of all the eligible clients in the collection.\n\t */\n\tgetAllEligibleClients(): ITrackedClient[];\n\t/**\n\t * Serialize election data\n\t */\n\tserialize(): ISerializedElection;\n}\n\n/**\n * Adapter for OrderedClientCollection, with the purpose of deterministically maintaining\n * a currently elected client, excluding ineligible clients, in a distributed fashion.\n * This can be true as long as incrementElectedClient and resetElectedClient calls\n * are called under the same conditions for all clients.\n */\nexport class OrderedClientElection\n\textends TypedEventEmitter<IOrderedClientElectionEvents>\n\timplements IOrderedClientElection\n{\n\tprivate _eligibleCount: number = 0;\n\tprivate _electedClient: ILinkedClient | undefined;\n\tprivate _electedParent: ILinkedClient | undefined;\n\tprivate _electionSequenceNumber: number;\n\n\tpublic get eligibleCount(): number {\n\t\treturn this._eligibleCount;\n\t}\n\tpublic get electionSequenceNumber(): number {\n\t\treturn this._electionSequenceNumber;\n\t}\n\n\t/**\n\t * OrderedClientCollection tracks electedClient and electedParent separately. This allows us to handle the case\n\t * where a new interactive parent client has been elected, but the summarizer is still doing work, so\n\t * a new summarizer should not yet be spawned. In this case, changing electedParent will cause SummaryManager\n\t * to stop the current summarizer, but a new summarizer will not be spawned until the old summarizer client has\n\t * left the quorum.\n\t *\n\t * Details:\n\t *\n\t * electedParent is the interactive client that has been elected to spawn a summarizer. It is typically the oldest\n\t * eligible interactive client in the quorum. Only the electedParent is permitted to spawn a summarizer.\n\t * Once elected, this client will remain the electedParent until it leaves the quorum or the summarizer that\n\t * it spawned stops producing summaries, at which point a new electedParent will be chosen.\n\t *\n\t * electedClient is the non-interactive summarizer client if one exists. If not, then electedClient is equal to\n\t * electedParent. If electedParent === electedClient, this is the signal for electedParent to spawn a new\n\t * electedClient. Once a summarizer client becomes electedClient, a new summarizer will not be spawned until\n\t * electedClient leaves the quorum.\n\t *\n\t * A typical sequence looks like this:\n\t *\n\t * i. Begin by electing A. electedParent === A, electedClient === A.\n\t *\n\t * ii. SummaryManager running on A spawns a summarizer client, A'. electedParent === A, electedClient === A'\n\t *\n\t * iii. A' stops producing summaries. A new parent client, B, is elected. electedParent === B, electedClient === A'\n\t *\n\t * iv. SummaryManager running on A detects the change to electedParent and tells the summarizer to stop, but A'\n\t * is in mid-summarization. No new summarizer is spawned, as electedParent !== electedClient.\n\t *\n\t * v. A' completes its summary, and the summarizer and backing client are torn down.\n\t *\n\t * vi. A' leaves the quorum, and B takes its place as electedClient. electedParent === B, electedClient === B\n\t *\n\t * vii. SummaryManager running on B spawns a summarizer client, B'. electedParent === B, electedClient === B'\n\t */\n\tpublic get electedClient(): ILinkedClient | undefined {\n\t\treturn this._electedClient;\n\t}\n\tpublic get electedParent(): ILinkedClient | undefined {\n\t\treturn this._electedParent;\n\t}\n\n\tconstructor(\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly orderedClientCollection: IOrderedClientCollection,\n\t\t/**\n\t\t * Serialized state from summary or current sequence number at time of load if new.\n\t\t */\n\t\tinitialState: ISerializedElection | number,\n\t\tprivate readonly isEligibleFn: (c: ITrackedClient) => boolean,\n\t\tprivate readonly recordPerformanceEvents: boolean = false,\n\t) {\n\t\tsuper();\n\t\tlet initialClient: ILinkedClient | undefined;\n\t\tlet initialParent: ILinkedClient | undefined;\n\t\tfor (const client of orderedClientCollection.getAllClients()) {\n\t\t\tthis.addClient(client, 0);\n\t\t\tif (typeof initialState !== \"number\") {\n\t\t\t\tif (client.clientId === initialState.electedClientId) {\n\t\t\t\t\tinitialClient = client;\n\t\t\t\t\tif (\n\t\t\t\t\t\tinitialState.electedParentId === undefined &&\n\t\t\t\t\t\tclient.client.details.type !== summarizerClientType\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If there was no elected parent in the serialized data, use this one.\n\t\t\t\t\t\tinitialParent = client;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (client.clientId === initialState.electedParentId) {\n\t\t\t\t\tinitialParent = client;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\torderedClientCollection.on(\"addClient\", (client, seq) => this.addClient(client, seq));\n\t\torderedClientCollection.on(\"removeClient\", (client, seq) =>\n\t\t\tthis.removeClient(client, seq),\n\t\t);\n\n\t\tif (typeof initialState === \"number\") {\n\t\t\tthis._electionSequenceNumber = initialState;\n\t\t} else {\n\t\t\t// Override the initially elected client with the initial state.\n\t\t\tif (initialClient?.clientId !== initialState.electedClientId) {\n\t\t\t\t// Cannot find initially elected client, so elect undefined.\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"InitialElectedClientNotFound\",\n\t\t\t\t\telectionSequenceNumber: initialState.electionSequenceNumber,\n\t\t\t\t\texpectedClientId: initialState.electedClientId,\n\t\t\t\t\telectedClientId: initialClient?.clientId,\n\t\t\t\t\tclientCount: orderedClientCollection.count,\n\t\t\t\t});\n\t\t\t} else if (initialClient !== undefined && !isEligibleFn(initialClient)) {\n\t\t\t\t// Initially elected client is ineligible, so elect next eligible client.\n\t\t\t\tinitialClient = initialParent = this.findFirstEligibleParent(initialParent);\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"InitialElectedClientIneligible\",\n\t\t\t\t\telectionSequenceNumber: initialState.electionSequenceNumber,\n\t\t\t\t\texpectedClientId: initialState.electedClientId,\n\t\t\t\t\telectedClientId: initialClient?.clientId,\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis._electedParent = initialParent;\n\t\t\tthis._electedClient = initialClient;\n\t\t\tthis._electionSequenceNumber = initialState.electionSequenceNumber;\n\t\t}\n\t}\n\n\t/**\n\t * Tries changing the elected client, raising an event if it is different.\n\t * Note that this function does no eligibility or suitability checks. If we get here, then\n\t * we will set _electedClient, and we will set _electedParent if this is an interactive client.\n\t */\n\tprivate tryElectingClient(\n\t\tclient: ILinkedClient | undefined,\n\t\tsequenceNumber: number,\n\t\treason: string,\n\t): void {\n\t\tthis.sendPerformanceEvent(\n\t\t\t\"TryElectingClient\",\n\t\t\tclient,\n\t\t\tsequenceNumber,\n\t\t\tfalse /* forceSend */,\n\t\t\treason,\n\t\t);\n\t\tlet change = false;\n\t\tconst isSummarizerClient = client?.client.details.type === summarizerClientType;\n\t\tconst prevClient = this._electedClient;\n\t\tif (this._electedClient !== client) {\n\t\t\tthis.sendPerformanceEvent(\n\t\t\t\t\"ClientElected\",\n\t\t\t\tclient,\n\t\t\t\tsequenceNumber,\n\t\t\t\ttrue /* forceSend */,\n\t\t\t\treason,\n\t\t\t);\n\t\t\t// Changing the elected client. Record the sequence number and note that we have to fire an event.\n\t\t\tthis._electionSequenceNumber = sequenceNumber;\n\t\t\tthis._electedClient = client;\n\t\t\tchange = true;\n\t\t}\n\t\tif (this._electedParent !== client && !isSummarizerClient) {\n\t\t\tthis.sendPerformanceEvent(\n\t\t\t\t\"InteractiveClientElected\",\n\t\t\t\tclient,\n\t\t\t\tsequenceNumber,\n\t\t\t\ttrue /* forceSend */,\n\t\t\t\treason,\n\t\t\t);\n\t\t\t// Changing the elected parent as well.\n\t\t\tthis._electedParent = client;\n\t\t\tchange = true;\n\t\t}\n\t\tif (change) {\n\t\t\tthis.emit(\"election\", client, sequenceNumber, prevClient);\n\t\t}\n\t}\n\n\tprivate tryElectingParent(\n\t\tclient: ILinkedClient | undefined,\n\t\tsequenceNumber: number,\n\t\treason: string,\n\t): void {\n\t\tthis.sendPerformanceEvent(\n\t\t\t\"TryElectingParent\",\n\t\t\tclient,\n\t\t\tsequenceNumber,\n\t\t\tfalse /* forceSend */,\n\t\t\treason,\n\t\t);\n\t\tif (this._electedParent !== client) {\n\t\t\tthis.sendPerformanceEvent(\n\t\t\t\t\"ParentElected\",\n\t\t\t\tclient,\n\t\t\t\tsequenceNumber,\n\t\t\t\ttrue /* forceSend */,\n\t\t\t\treason,\n\t\t\t);\n\t\t\tthis._electedParent = client;\n\t\t\tthis.emit(\"election\", this._electedClient, sequenceNumber, this._electedClient);\n\t\t}\n\t}\n\n\t/**\n\t * Helper function to find the first eligible parent client starting with the passed in client,\n\t * or undefined if none are eligible.\n\t * @param client - client to start checking\n\t * @returns oldest eligible client starting with passed in client or undefined if none.\n\t */\n\tprivate findFirstEligibleParent(\n\t\tclient: ILinkedClient | undefined,\n\t): ILinkedClient | undefined {\n\t\tlet candidateClient = client;\n\t\twhile (\n\t\t\tcandidateClient !== undefined &&\n\t\t\t(!this.isEligibleFn(candidateClient) ||\n\t\t\t\tcandidateClient.client.details.type === summarizerClientType)\n\t\t) {\n\t\t\tcandidateClient = candidateClient.youngerClient;\n\t\t}\n\t\treturn candidateClient;\n\t}\n\n\t/**\n\t * Updates tracking for when a new client is added to the collection.\n\t * Will automatically elect that new client if none is elected currently.\n\t * @param client - client added to the collection\n\t * @param sequenceNumber - sequence number when client was added\n\t */\n\tprivate addClient(client: ILinkedClient, sequenceNumber: number): void {\n\t\tthis.sendPerformanceEvent(\"AddClient\", client, sequenceNumber);\n\t\tif (this.isEligibleFn(client)) {\n\t\t\tthis._eligibleCount++;\n\t\t\tconst newClientIsSummarizer = client.client.details.type === summarizerClientType;\n\t\t\tconst electedClientIsSummarizer =\n\t\t\t\tthis._electedClient?.client.details.type === summarizerClientType;\n\t\t\t// Note that we allow a summarizer client to supersede an interactive client as elected client.\n\t\t\tif (\n\t\t\t\tthis._electedClient === undefined ||\n\t\t\t\t(!electedClientIsSummarizer && newClientIsSummarizer)\n\t\t\t) {\n\t\t\t\tthis.tryElectingClient(client, sequenceNumber, \"AddClient\");\n\t\t\t} else if (this._electedParent === undefined && !newClientIsSummarizer) {\n\t\t\t\t// This is an odd case. If the _electedClient is set, the _electedParent should be as well.\n\t\t\t\tthis.tryElectingParent(client, sequenceNumber, \"AddClient\");\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Updates tracking for when an existing client is removed from the collection.\n\t * Will automatically elect next oldest client if currently elected is removed.\n\t * @param client - client removed from the collection\n\t * @param sequenceNumber - sequence number when client was removed\n\t */\n\tprivate removeClient(client: ILinkedClient, sequenceNumber: number): void {\n\t\tthis.sendPerformanceEvent(\"RemoveClient\", client, sequenceNumber);\n\t\tif (this.isEligibleFn(client)) {\n\t\t\tthis._eligibleCount--;\n\t\t\tif (this._electedClient === client) {\n\t\t\t\t// Removing the _electedClient. There are 2 possible cases:\n\t\t\t\tif (this._electedParent === client) {\n\t\t\t\t\t// 1. The _electedClient is an interactive client that has left the quorum.\n\t\t\t\t\t// Automatically shift to next oldest client.\n\t\t\t\t\tconst nextClient =\n\t\t\t\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\t\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\t\t\t\tthis.tryElectingClient(nextClient, sequenceNumber, \"RemoveClient\");\n\t\t\t\t} else {\n\t\t\t\t\t// 2. The _electedClient is a summarizer that we've been allowing to finish its work.\n\t\t\t\t\t// Let the _electedParent become the _electedClient so that it can start its own summarizer.\n\t\t\t\t\tif (this._electedClient.client.details.type !== summarizerClientType) {\n\t\t\t\t\t\tthrow new UsageError(\"Elected client should be a summarizer client 1\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.tryElectingClient(\n\t\t\t\t\t\tthis._electedParent,\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t\t\"RemoveSummarizerClient\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if (this._electedParent === client) {\n\t\t\t\t// Removing the _electedParent (but not _electedClient).\n\t\t\t\t// Shift to the next oldest parent, but do not replace the _electedClient,\n\t\t\t\t// which is a summarizer that is still doing work.\n\t\t\t\tif (this._electedClient?.client.details.type !== summarizerClientType) {\n\t\t\t\t\tthrow new UsageError(\"Elected client should be a summarizer client 2\");\n\t\t\t\t}\n\t\t\t\tconst nextParent =\n\t\t\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\t\t\tthis.tryElectingParent(nextParent, sequenceNumber, \"RemoveClient\");\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic getAllEligibleClients(): ITrackedClient[] {\n\t\treturn this.orderedClientCollection\n\t\t\t.getAllClients()\n\t\t\t.filter((client) => this.isEligibleFn(client));\n\t}\n\n\t/**\n\t * (Re-)start election with the oldest client in the quorum. This is called if we need to summarize\n\t * and no client has been elected.\n\t */\n\tpublic resetElectedClient(sequenceNumber: number): void {\n\t\tconst firstClient = this.findFirstEligibleParent(\n\t\t\tthis.orderedClientCollection.oldestClient,\n\t\t);\n\t\tif (this._electedClient === undefined || this._electedClient === this._electedParent) {\n\t\t\tthis.tryElectingClient(firstClient, sequenceNumber, \"ResetElectedClient\");\n\t\t} else {\n\t\t\t// The _electedClient is a summarizer and should not be replaced until it leaves the quorum.\n\t\t\t// Changing the _electedParent will stop the summarizer.\n\t\t\tthis.tryElectingParent(firstClient, sequenceNumber, \"ResetElectedClient\");\n\t\t}\n\t}\n\n\tpublic peekNextElectedClient(): ITrackedClient | undefined {\n\t\treturn (\n\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient)\n\t\t);\n\t}\n\n\tpublic serialize(): ISerializedElection {\n\t\treturn {\n\t\t\telectionSequenceNumber: this.electionSequenceNumber,\n\t\t\telectedClientId: this.electedClient?.clientId,\n\t\t\telectedParentId: this.electedParent?.clientId,\n\t\t};\n\t}\n\n\tprivate sendPerformanceEvent(\n\t\teventName: string,\n\t\tclient: ILinkedClient | undefined,\n\t\tsequenceNumber: number,\n\t\tforceSend: boolean = false,\n\t\treason?: string,\n\t): void {\n\t\tif (this.recordPerformanceEvents || forceSend) {\n\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\teventName,\n\t\t\t\tclientId: client?.clientId,\n\t\t\t\tsequenceNumber,\n\t\t\t\telectedClientId: this.electedClient?.clientId,\n\t\t\t\telectedParentId: this.electedParent?.clientId,\n\t\t\t\tisEligible: client === undefined ? false : this.isEligibleFn(client),\n\t\t\t\tisSummarizerClient: client?.client.details.type === summarizerClientType,\n\t\t\t\treason,\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"orderedClientElection.js","sourceRoot":"","sources":["../../src/summary/orderedClientElection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAA2C;AAE3C,+DAAiE;AAOjE,kEAA6D;AAM7D,uEAIkD;AAElD,6DAA4D;AAoF5D;;;;;;GAMG;AACH,MAAa,uBACZ,SAAQ,gCAAiD;IAqBzD,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IAC5B,CAAC;IACD,IAAW,YAAY;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC;IACpC,CAAC;IAED,YACC,MAA4B,EAC5B,YAAyE,EACzE,MAAiD;QAEjD,KAAK,EAAE,CAAC;Q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Ae,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ;YAC7C,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ;SAC7C,CAAC;IACH,CAAC;IAEO,oBAAoB,CAC3B,SAAiB,EACjB,MAAiC,EACjC,cAAsB,EACtB,YAAqB,KAAK,EAC1B,MAAe;QAEf,IAAI,IAAI,CAAC,uBAAuB,IAAI,SAAS,EAAE,CAAC;YAC/C,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;gBAChC,SAAS;gBACT,QAAQ,EAAE,MAAM,EAAE,QAAQ;gBAC1B,cAAc;gBACd,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ;gBAC7C,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ;gBAC7C,UAAU,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;gBACpE,kBAAkB,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,yCAAoB;gBACxE,MAAM;aACN,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD;AA7VD,sDA6VC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @rushstack/no-new-null */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport type {\n\tIEvent,\n\tIEventProvider,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIClient,\n\tIQuorumClients,\n\tISequencedClient,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tUsageError,\n\tcreateChildLogger,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { summarizerClientType } from \"./summarizerTypes.js\";\n\n// helper types for recursive readonly.\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types\nexport type ImmutablePrimitives = undefined | null | boolean | string | number | Function;\nexport type Immutable<T> = T extends ImmutablePrimitives\n\t? T\n\t: T extends (infer A)[]\n\t\t? readonly Immutable<A>[]\n\t\t: T extends Map<infer K, infer V>\n\t\t\t? ReadonlyMap<Immutable<K>, Immutable<V>>\n\t\t\t: T extends Set<infer V>\n\t\t\t\t? ReadonlySet<Immutable<V>>\n\t\t\t\t: { readonly [K in keyof T]: Immutable<T[K]> };\n\n/**\n * Minimum information for a client tracked for election consideration.\n */\nexport interface ITrackedClient {\n\treadonly clientId: string;\n\treadonly sequenceNumber: number;\n\treadonly client: Immutable<IClient>;\n}\n\n/**\n * Common contract for link nodes within an OrderedClientCollection.\n */\nexport interface ILinkNode {\n\treadonly sequenceNumber: number;\n\tyoungerClient: ILinkedClient | undefined;\n}\n\n/**\n * Placeholder root node within an OrderedClientCollection; does not represent a client.\n */\nexport interface IRootLinkNode extends ILinkNode {\n\treadonly sequenceNumber: -1;\n\treadonly olderClient: undefined;\n}\n\n/**\n * Additional information required to keep track of the client within the doubly-linked list.\n */\nexport interface ILinkedClient extends ILinkNode, ITrackedClient {\n\tolderClient: LinkNode;\n}\n\n/**\n * Any link node within OrderedClientCollection including the placeholder root node.\n */\nexport type LinkNode = IRootLinkNode | ILinkedClient;\n\n/**\n * Events raised by an OrderedClientCollection.\n */\nexport interface IOrderedClientCollectionEvents extends IEvent {\n\t/**\n\t * Event fires when client is being added.\n\t */\n\t(\n\t\tevent: \"addClient\" | \"removeClient\",\n\t\tlistener: (client: ILinkedClient, sequenceNumber: number) => void,\n\t);\n}\n\n/**\n * Contract for a sorted collection of all clients in the quorum.\n */\nexport interface IOrderedClientCollection\n\textends IEventProvider<IOrderedClientCollectionEvents> {\n\t/**\n\t * Count of clients in the collection.\n\t */\n\treadonly count: number;\n\t/**\n\t * Pointer to the oldest client in the collection.\n\t */\n\treadonly oldestClient: ILinkedClient | undefined;\n\t/**\n\t * Returns a sorted array of all the clients in the collection.\n\t */\n\tgetAllClients(): ILinkedClient[];\n}\n\n/**\n * Tracks clients in the Quorum. It maintains their order using their join op\n * sequence numbers.\n * Internally, the collection of clients is maintained in a doubly-linked list,\n * with pointers to both the first and last nodes.\n * The first (root) node is a placeholder to simplify logic and reduce null checking.\n */\nexport class OrderedClientCollection\n\textends TypedEventEmitter<IOrderedClientCollectionEvents>\n\timplements IOrderedClientCollection\n{\n\t/**\n\t * Collection of ALL clients currently in the quorum, with client ids as keys.\n\t */\n\tprivate readonly clientMap = new Map<string, ILinkedClient>();\n\t/**\n\t * Placeholder head node of linked list, for simplified null checking.\n\t */\n\tprivate readonly rootNode: IRootLinkNode = {\n\t\tsequenceNumber: -1,\n\t\tolderClient: undefined,\n\t\tyoungerClient: undefined,\n\t};\n\t/**\n\t * Pointer to end of linked list, for optimized client adds.\n\t */\n\tprivate _youngestClient: LinkNode = this.rootNode;\n\tprivate readonly logger: ITelemetryLoggerExt;\n\n\tpublic get count(): number {\n\t\treturn this.clientMap.size;\n\t}\n\tpublic get oldestClient(): ILinkedClient | undefined {\n\t\treturn this.rootNode.youngerClient;\n\t}\n\n\tconstructor(\n\t\tlogger: ITelemetryBaseLogger,\n\t\tdeltaManager: Pick<IDeltaManager<unknown, unknown>, \"lastSequenceNumber\">,\n\t\tquorum: Pick<IQuorumClients, \"getMembers\" | \"on\">,\n\t) {\n\t\tsuper();\n\t\tthis.logger = createChildLogger({ logger, namespace: \"OrderedClientCollection\" });\n\t\tconst members = quorum.getMembers();\n\t\tfor (const [clientId, client] of members) {\n\t\t\tthis.addClient(clientId, client);\n\t\t}\n\n\t\tquorum.on(\"addMember\", (clientId, client) => {\n\t\t\tconst newClient = this.addClient(clientId, client);\n\t\t\tthis.emit(\"addClient\", newClient, deltaManager.lastSequenceNumber);\n\t\t});\n\t\tquorum.on(\"removeMember\", (clientId) => {\n\t\t\tconst sequenceNumber = deltaManager.lastSequenceNumber;\n\t\t\tconst removeClient = this.removeClient(clientId);\n\t\t\tif (removeClient === undefined) {\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"ClientNotFound\",\n\t\t\t\t\tclientId,\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.emit(\"removeClient\", removeClient, sequenceNumber);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate addClient(clientId: string, client: ISequencedClient): ITrackedClient {\n\t\t// Normal case is adding the latest client, which will bypass loop.\n\t\t// Find where it belongs otherwise (maybe possible during initial load?).\n\t\tassert(\n\t\t\tclient.sequenceNumber > -1,\n\t\t\t0x1f6 /* \"Negative client sequence number not allowed\" */,\n\t\t);\n\t\tlet currClient = this._youngestClient;\n\t\twhile (currClient.sequenceNumber > client.sequenceNumber) {\n\t\t\tassert(\n\t\t\t\tcurrClient.olderClient !== undefined,\n\t\t\t\t0x1f7 /* \"Previous client should always be defined\" */,\n\t\t\t);\n\t\t\t// Note: If adding a client older than the elected client, it will not be automatically elected.\n\t\t\tcurrClient = currClient.olderClient;\n\t\t}\n\n\t\t// Now currClient is the node right before where the new client node should be.\n\t\tconst newClient: ILinkedClient = {\n\t\t\tclientId,\n\t\t\tsequenceNumber: client.sequenceNumber,\n\t\t\tclient: { ...client.client }, // shallow clone\n\t\t\tolderClient: currClient,\n\t\t\tyoungerClient: currClient.youngerClient,\n\t\t};\n\n\t\t// Update prev node to point to this new node.\n\t\tnewClient.olderClient.youngerClient = newClient;\n\n\t\tif (newClient.youngerClient === undefined) {\n\t\t\t// Update linked list end pointer to youngest client.\n\t\t\tthis._youngestClient = newClient;\n\t\t} else {\n\t\t\t// Update next node to point back to this new node.\n\t\t\tnewClient.youngerClient.olderClient = newClient;\n\t\t}\n\n\t\tthis.clientMap.set(clientId, newClient);\n\t\treturn newClient;\n\t}\n\n\tprivate removeClient(clientId: string): ITrackedClient | undefined {\n\t\tconst removeClient = this.clientMap.get(clientId);\n\t\tif (removeClient === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update prev node to point to next node.\n\t\tremoveClient.olderClient.youngerClient = removeClient.youngerClient;\n\n\t\tif (removeClient.youngerClient === undefined) {\n\t\t\t// Update linked list end pointer to youngest client.\n\t\t\tthis._youngestClient = removeClient.olderClient;\n\t\t} else {\n\t\t\t// Update next node to point back to previous node.\n\t\t\tremoveClient.youngerClient.olderClient = removeClient.olderClient;\n\t\t}\n\n\t\tthis.clientMap.delete(clientId);\n\t\treturn removeClient;\n\t}\n\n\t/**\n\t * Returns an array of all clients being tracked in order from oldest to newest.\n\t */\n\tpublic getAllClients(): ILinkedClient[] {\n\t\tconst result: ILinkedClient[] = [];\n\t\tlet currClient: LinkNode = this.rootNode;\n\t\twhile (currClient.youngerClient !== undefined) {\n\t\t\tresult.push(currClient.youngerClient);\n\t\t\tcurrClient = currClient.youngerClient;\n\t\t}\n\t\treturn result;\n\t}\n}\n\n/**\n * Events raised by an OrderedClientElection.\n */\nexport interface IOrderedClientElectionEvents extends IEvent {\n\t/**\n\t * Event fires when the currently elected client changes.\n\t */\n\t(\n\t\tevent: \"election\",\n\t\tlistener: (\n\t\t\t/**\n\t\t\t * Newly elected client.\n\t\t\t */\n\t\t\tclient: ITrackedClient | undefined,\n\t\t\t/**\n\t\t\t * Sequence number where election took place.\n\t\t\t */\n\t\t\tsequenceNumber: number,\n\t\t\t/**\n\t\t\t * Previously elected client.\n\t\t\t */\n\t\t\tprevClient: ITrackedClient | undefined,\n\t\t) => void,\n\t);\n}\n\n/**\n * Serialized state of IOrderedClientElection.\n * @internal\n */\nexport interface ISerializedElection {\n\t/**\n\t * Sequence number at the time of the latest election.\n\t */\n\treadonly electionSequenceNumber: number;\n\n\t/**\n\t * Most recently elected client id. This is either:\n\t *\n\t * 1. the interactive elected parent client, in which case electedClientId === electedParentId,\n\t * and the SummaryManager on the elected client will spawn a summarizer client, or\n\t *\n\t * 2. the non-interactive summarizer client itself.\n\t */\n\treadonly electedClientId: string | undefined;\n\n\t/**\n\t * Most recently elected parent client id. This is always an interactive client.\n\t */\n\treadonly electedParentId: string | undefined;\n}\n\n/**\n * Contract for maintaining a deterministic client election based on eligibility.\n */\nexport interface IOrderedClientElection extends IEventProvider<IOrderedClientElectionEvents> {\n\t/**\n\t * Count of eligible clients in the collection.\n\t */\n\treadonly eligibleCount: number;\n\n\t/**\n\t * Currently elected client. This is either:\n\t *\n\t * 1. the interactive elected parent client, in which case electedClientId === electedParentId,\n\t * and the SummaryManager on the elected client will spawn a summarizer client, or\n\t *\n\t * 2. the non-interactive summarizer client itself.\n\t */\n\treadonly electedClient: ITrackedClient | undefined;\n\t/**\n\t * Currently elected parent client. This is always an interactive client.\n\t */\n\treadonly electedParent: ITrackedClient | undefined;\n\t/**\n\t * Sequence number of most recent election.\n\t */\n\treadonly electionSequenceNumber: number;\n\t/**\n\t * Resets the currently elected client back to the oldest eligible client.\n\t */\n\tresetElectedClient(sequenceNumber: number): void;\n\t/**\n\t * Peeks at what the next elected client would be if incrementElectedClient were called.\n\t */\n\tpeekNextElectedClient(): ITrackedClient | undefined;\n\t/**\n\t * Returns a sorted array of all the eligible clients in the collection.\n\t */\n\tgetAllEligibleClients(): ITrackedClient[];\n\t/**\n\t * Serialize election data\n\t */\n\tserialize(): ISerializedElection;\n}\n\n/**\n * Adapter for OrderedClientCollection, with the purpose of deterministically maintaining\n * a currently elected client, excluding ineligible clients, in a distributed fashion.\n * This can be true as long as incrementElectedClient and resetElectedClient calls\n * are called under the same conditions for all clients.\n */\nexport class OrderedClientElection\n\textends TypedEventEmitter<IOrderedClientElectionEvents>\n\timplements IOrderedClientElection\n{\n\tprivate _eligibleCount: number = 0;\n\tprivate _electedClient: ILinkedClient | undefined;\n\tprivate _electedParent: ILinkedClient | undefined;\n\tprivate _electionSequenceNumber: number;\n\n\tpublic get eligibleCount(): number {\n\t\treturn this._eligibleCount;\n\t}\n\tpublic get electionSequenceNumber(): number {\n\t\treturn this._electionSequenceNumber;\n\t}\n\n\t/**\n\t * OrderedClientCollection tracks electedClient and electedParent separately. This allows us to handle the case\n\t * where a new interactive parent client has been elected, but the summarizer is still doing work, so\n\t * a new summarizer should not yet be spawned. In this case, changing electedParent will cause SummaryManager\n\t * to stop the current summarizer, but a new summarizer will not be spawned until the old summarizer client has\n\t * left the quorum.\n\t *\n\t * Details:\n\t *\n\t * electedParent is the interactive client that has been elected to spawn a summarizer. It is typically the oldest\n\t * eligible interactive client in the quorum. Only the electedParent is permitted to spawn a summarizer.\n\t * Once elected, this client will remain the electedParent until it leaves the quorum or the summarizer that\n\t * it spawned stops producing summaries, at which point a new electedParent will be chosen.\n\t *\n\t * electedClient is the non-interactive summarizer client if one exists. If not, then electedClient is equal to\n\t * electedParent. If electedParent === electedClient, this is the signal for electedParent to spawn a new\n\t * electedClient. Once a summarizer client becomes electedClient, a new summarizer will not be spawned until\n\t * electedClient leaves the quorum.\n\t *\n\t * A typical sequence looks like this:\n\t *\n\t * i. Begin by electing A. electedParent === A, electedClient === A.\n\t *\n\t * ii. SummaryManager running on A spawns a summarizer client, A'. electedParent === A, electedClient === A'\n\t *\n\t * iii. A' stops producing summaries. A new parent client, B, is elected. electedParent === B, electedClient === A'\n\t *\n\t * iv. SummaryManager running on A detects the change to electedParent and tells the summarizer to stop, but A'\n\t * is in mid-summarization. No new summarizer is spawned, as electedParent !== electedClient.\n\t *\n\t * v. A' completes its summary, and the summarizer and backing client are torn down.\n\t *\n\t * vi. A' leaves the quorum, and B takes its place as electedClient. electedParent === B, electedClient === B\n\t *\n\t * vii. SummaryManager running on B spawns a summarizer client, B'. electedParent === B, electedClient === B'\n\t */\n\tpublic get electedClient(): ILinkedClient | undefined {\n\t\treturn this._electedClient;\n\t}\n\tpublic get electedParent(): ILinkedClient | undefined {\n\t\treturn this._electedParent;\n\t}\n\n\tconstructor(\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly orderedClientCollection: IOrderedClientCollection,\n\t\t/**\n\t\t * Serialized state from summary or current sequence number at time of load if new.\n\t\t */\n\t\tinitialState: ISerializedElection | number,\n\t\tprivate readonly isEligibleFn: (c: ITrackedClient) => boolean,\n\t\tprivate readonly recordPerformanceEvents: boolean = false,\n\t) {\n\t\tsuper();\n\t\tlet initialClient: ILinkedClient | undefined;\n\t\tlet initialParent: ILinkedClient | undefined;\n\t\tfor (const client of orderedClientCollection.getAllClients()) {\n\t\t\tthis.addClient(client, 0);\n\t\t\tif (typeof initialState !== \"number\") {\n\t\t\t\tif (client.clientId === initialState.electedClientId) {\n\t\t\t\t\tinitialClient = client;\n\t\t\t\t\tif (\n\t\t\t\t\t\tinitialState.electedParentId === undefined &&\n\t\t\t\t\t\tclient.client.details.type !== summarizerClientType\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If there was no elected parent in the serialized data, use this one.\n\t\t\t\t\t\tinitialParent = client;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (client.clientId === initialState.electedParentId) {\n\t\t\t\t\tinitialParent = client;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\torderedClientCollection.on(\"addClient\", (client, seq) => this.addClient(client, seq));\n\t\torderedClientCollection.on(\"removeClient\", (client, seq) =>\n\t\t\tthis.removeClient(client, seq),\n\t\t);\n\n\t\tif (typeof initialState === \"number\") {\n\t\t\tthis._electionSequenceNumber = initialState;\n\t\t} else {\n\t\t\t// Override the initially elected client with the initial state.\n\t\t\tif (initialClient?.clientId !== initialState.electedClientId) {\n\t\t\t\t// Cannot find initially elected client, so elect undefined.\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"InitialElectedClientNotFound\",\n\t\t\t\t\telectionSequenceNumber: initialState.electionSequenceNumber,\n\t\t\t\t\texpectedClientId: initialState.electedClientId,\n\t\t\t\t\telectedClientId: initialClient?.clientId,\n\t\t\t\t\tclientCount: orderedClientCollection.count,\n\t\t\t\t});\n\t\t\t} else if (initialClient !== undefined && !isEligibleFn(initialClient)) {\n\t\t\t\t// Initially elected client is ineligible, so elect next eligible client.\n\t\t\t\tinitialClient = initialParent = this.findFirstEligibleParent(initialParent);\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"InitialElectedClientIneligible\",\n\t\t\t\t\telectionSequenceNumber: initialState.electionSequenceNumber,\n\t\t\t\t\texpectedClientId: initialState.electedClientId,\n\t\t\t\t\telectedClientId: initialClient?.clientId,\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis._electedParent = initialParent;\n\t\t\tthis._electedClient = initialClient;\n\t\t\tthis._electionSequenceNumber = initialState.electionSequenceNumber;\n\t\t}\n\t}\n\n\t/**\n\t * Tries changing the elected client, raising an event if it is different.\n\t * Note that this function does no eligibility or suitability checks. If we get here, then\n\t * we will set _electedClient, and we will set _electedParent if this is an interactive client.\n\t */\n\tprivate tryElectingClient(\n\t\tclient: ILinkedClient | undefined,\n\t\tsequenceNumber: number,\n\t\treason: string,\n\t): void {\n\t\tthis.sendPerformanceEvent(\n\t\t\t\"TryElectingClient\",\n\t\t\tclient,\n\t\t\tsequenceNumber,\n\t\t\tfalse /* forceSend */,\n\t\t\treason,\n\t\t);\n\t\tlet change = false;\n\t\tconst isSummarizerClient = client?.client.details.type === summarizerClientType;\n\t\tconst prevClient = this._electedClient;\n\t\tif (this._electedClient !== client) {\n\t\t\tthis.sendPerformanceEvent(\n\t\t\t\t\"ClientElected\",\n\t\t\t\tclient,\n\t\t\t\tsequenceNumber,\n\t\t\t\ttrue /* forceSend */,\n\t\t\t\treason,\n\t\t\t);\n\t\t\t// Changing the elected client. Record the sequence number and note that we have to fire an event.\n\t\t\tthis._electionSequenceNumber = sequenceNumber;\n\t\t\tthis._electedClient = client;\n\t\t\tchange = true;\n\t\t}\n\t\tif (this._electedParent !== client && !isSummarizerClient) {\n\t\t\tthis.sendPerformanceEvent(\n\t\t\t\t\"InteractiveClientElected\",\n\t\t\t\tclient,\n\t\t\t\tsequenceNumber,\n\t\t\t\ttrue /* forceSend */,\n\t\t\t\treason,\n\t\t\t);\n\t\t\t// Changing the elected parent as well.\n\t\t\tthis._electedParent = client;\n\t\t\tchange = true;\n\t\t}\n\t\tif (change) {\n\t\t\tthis.emit(\"election\", client, sequenceNumber, prevClient);\n\t\t}\n\t}\n\n\tprivate tryElectingParent(\n\t\tclient: ILinkedClient | undefined,\n\t\tsequenceNumber: number,\n\t\treason: string,\n\t): void {\n\t\tthis.sendPerformanceEvent(\n\t\t\t\"TryElectingParent\",\n\t\t\tclient,\n\t\t\tsequenceNumber,\n\t\t\tfalse /* forceSend */,\n\t\t\treason,\n\t\t);\n\t\tif (this._electedParent !== client) {\n\t\t\tthis.sendPerformanceEvent(\n\t\t\t\t\"ParentElected\",\n\t\t\t\tclient,\n\t\t\t\tsequenceNumber,\n\t\t\t\ttrue /* forceSend */,\n\t\t\t\treason,\n\t\t\t);\n\t\t\tthis._electedParent = client;\n\t\t\tthis.emit(\"election\", this._electedClient, sequenceNumber, this._electedClient);\n\t\t}\n\t}\n\n\t/**\n\t * Helper function to find the first eligible parent client starting with the passed in client,\n\t * or undefined if none are eligible.\n\t * @param client - client to start checking\n\t * @returns oldest eligible client starting with passed in client or undefined if none.\n\t */\n\tprivate findFirstEligibleParent(\n\t\tclient: ILinkedClient | undefined,\n\t): ILinkedClient | undefined {\n\t\tlet candidateClient = client;\n\t\twhile (\n\t\t\tcandidateClient !== undefined &&\n\t\t\t(!this.isEligibleFn(candidateClient) ||\n\t\t\t\tcandidateClient.client.details.type === summarizerClientType)\n\t\t) {\n\t\t\tcandidateClient = candidateClient.youngerClient;\n\t\t}\n\t\treturn candidateClient;\n\t}\n\n\t/**\n\t * Updates tracking for when a new client is added to the collection.\n\t * Will automatically elect that new client if none is elected currently.\n\t * @param client - client added to the collection\n\t * @param sequenceNumber - sequence number when client was added\n\t */\n\tprivate addClient(client: ILinkedClient, sequenceNumber: number): void {\n\t\tthis.sendPerformanceEvent(\"AddClient\", client, sequenceNumber);\n\t\tif (this.isEligibleFn(client)) {\n\t\t\tthis._eligibleCount++;\n\t\t\tconst newClientIsSummarizer = client.client.details.type === summarizerClientType;\n\t\t\tconst electedClientIsSummarizer =\n\t\t\t\tthis._electedClient?.client.details.type === summarizerClientType;\n\t\t\t// Note that we allow a summarizer client to supersede an interactive client as elected client.\n\t\t\tif (\n\t\t\t\tthis._electedClient === undefined ||\n\t\t\t\t(!electedClientIsSummarizer && newClientIsSummarizer)\n\t\t\t) {\n\t\t\t\tthis.tryElectingClient(client, sequenceNumber, \"AddClient\");\n\t\t\t} else if (this._electedParent === undefined && !newClientIsSummarizer) {\n\t\t\t\t// This is an odd case. If the _electedClient is set, the _electedParent should be as well.\n\t\t\t\tthis.tryElectingParent(client, sequenceNumber, \"AddClient\");\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Updates tracking for when an existing client is removed from the collection.\n\t * Will automatically elect next oldest client if currently elected is removed.\n\t * @param client - client removed from the collection\n\t * @param sequenceNumber - sequence number when client was removed\n\t */\n\tprivate removeClient(client: ILinkedClient, sequenceNumber: number): void {\n\t\tthis.sendPerformanceEvent(\"RemoveClient\", client, sequenceNumber);\n\t\tif (this.isEligibleFn(client)) {\n\t\t\tthis._eligibleCount--;\n\t\t\tif (this._electedClient === client) {\n\t\t\t\t// Removing the _electedClient. There are 2 possible cases:\n\t\t\t\tif (this._electedParent === client) {\n\t\t\t\t\t// 1. The _electedClient is an interactive client that has left the quorum.\n\t\t\t\t\t// Automatically shift to next oldest client.\n\t\t\t\t\tconst nextClient =\n\t\t\t\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\t\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\t\t\t\tthis.tryElectingClient(nextClient, sequenceNumber, \"RemoveClient\");\n\t\t\t\t} else {\n\t\t\t\t\t// 2. The _electedClient is a summarizer that we've been allowing to finish its work.\n\t\t\t\t\t// Let the _electedParent become the _electedClient so that it can start its own summarizer.\n\t\t\t\t\tif (this._electedClient.client.details.type !== summarizerClientType) {\n\t\t\t\t\t\tthrow new UsageError(\"Elected client should be a summarizer client 1\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.tryElectingClient(\n\t\t\t\t\t\tthis._electedParent,\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t\t\"RemoveSummarizerClient\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if (this._electedParent === client) {\n\t\t\t\t// Removing the _electedParent (but not _electedClient).\n\t\t\t\t// Shift to the next oldest parent, but do not replace the _electedClient,\n\t\t\t\t// which is a summarizer that is still doing work.\n\t\t\t\tif (this._electedClient?.client.details.type !== summarizerClientType) {\n\t\t\t\t\tthrow new UsageError(\"Elected client should be a summarizer client 2\");\n\t\t\t\t}\n\t\t\t\tconst nextParent =\n\t\t\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\t\t\tthis.tryElectingParent(nextParent, sequenceNumber, \"RemoveClient\");\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic getAllEligibleClients(): ITrackedClient[] {\n\t\treturn this.orderedClientCollection\n\t\t\t.getAllClients()\n\t\t\t.filter((client) => this.isEligibleFn(client));\n\t}\n\n\t/**\n\t * (Re-)start election with the oldest client in the quorum. This is called if we need to summarize\n\t * and no client has been elected.\n\t */\n\tpublic resetElectedClient(sequenceNumber: number): void {\n\t\tconst firstClient = this.findFirstEligibleParent(\n\t\t\tthis.orderedClientCollection.oldestClient,\n\t\t);\n\t\tif (this._electedClient === undefined || this._electedClient === this._electedParent) {\n\t\t\tthis.tryElectingClient(firstClient, sequenceNumber, \"ResetElectedClient\");\n\t\t} else {\n\t\t\t// The _electedClient is a summarizer and should not be replaced until it leaves the quorum.\n\t\t\t// Changing the _electedParent will stop the summarizer.\n\t\t\tthis.tryElectingParent(firstClient, sequenceNumber, \"ResetElectedClient\");\n\t\t}\n\t}\n\n\tpublic peekNextElectedClient(): ITrackedClient | undefined {\n\t\treturn (\n\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient)\n\t\t);\n\t}\n\n\tpublic serialize(): ISerializedElection {\n\t\treturn {\n\t\t\telectionSequenceNumber: this.electionSequenceNumber,\n\t\t\telectedClientId: this.electedClient?.clientId,\n\t\t\telectedParentId: this.electedParent?.clientId,\n\t\t};\n\t}\n\n\tprivate sendPerformanceEvent(\n\t\teventName: string,\n\t\tclient: ILinkedClient | undefined,\n\t\tsequenceNumber: number,\n\t\tforceSend: boolean = false,\n\t\treason?: string,\n\t): void {\n\t\tif (this.recordPerformanceEvents || forceSend) {\n\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\teventName,\n\t\t\t\tclientId: client?.clientId,\n\t\t\t\tsequenceNumber,\n\t\t\t\telectedClientId: this.electedClient?.clientId,\n\t\t\t\telectedParentId: this.electedParent?.clientId,\n\t\t\t\tisEligible: client === undefined ? false : this.isEligibleFn(client),\n\t\t\t\tisSummarizerClient: client?.client.details.type === summarizerClientType,\n\t\t\t\treason,\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
@@ -7,12 +7,12 @@ import { type ISummaryTreeWithStats, type IRuntimeStorageService } from "@fluidf
7
7
  import type { IGCMetadata } from "../gc/index.js";
8
8
  import type { IDocumentSchema } from "./documentSchema.js";
9
9
  /**
10
- * @deprecated - This interface will no longer be exported in the future(AB#8004).
10
+ * @deprecated This interface will no longer be exported in the future(AB#8004).
11
11
  * @legacy @beta
12
12
  */
13
13
  export type OmitAttributesVersions<T> = Omit<T, "snapshotFormatVersion" | "summaryFormatVersion">;
14
14
  /**
15
- * @deprecated - This interface will no longer be exported in the future(AB#8004).
15
+ * @deprecated This interface will no longer be exported in the future(AB#8004).
16
16
  * @legacy @beta
17
17
  */
18
18
  export interface IFluidDataStoreAttributes0 {
@@ -27,7 +27,7 @@ export interface IFluidDataStoreAttributes0 {
27
27
  readonly isRootDataStore?: boolean;
28
28
  }
29
29
  /**
30
- * @deprecated - This interface will no longer be exported in the future(AB#8004).
30
+ * @deprecated This interface will no longer be exported in the future(AB#8004).
31
31
  * @legacy @beta
32
32
  */
33
33
  export interface IFluidDataStoreAttributes1 extends OmitAttributesVersions<IFluidDataStoreAttributes0> {
@@ -35,7 +35,7 @@ export interface IFluidDataStoreAttributes1 extends OmitAttributesVersions<IFlui
35
35
  readonly summaryFormatVersion?: undefined;
36
36
  }
37
37
  /**
38
- * @deprecated - This interface will no longer be exported in the future(AB#8004).
38
+ * @deprecated This interface will no longer be exported in the future(AB#8004).
39
39
  * @legacy @beta
40
40
  */
41
41
  export interface IFluidDataStoreAttributes2 extends OmitAttributesVersions<IFluidDataStoreAttributes1> {
@@ -57,7 +57,7 @@ export interface IFluidDataStoreAttributes2 extends OmitAttributesVersions<IFlui
57
57
  * store like the package, snapshotFormatVersion to take different decisions based on a particular
58
58
  * snapshotFormatVersion.
59
59
  *
60
- * @deprecated - This interface will no longer be exported in the future(AB#8004).
60
+ * @deprecated This interface will no longer be exported in the future(AB#8004).
61
61
  *
62
62
  * @legacy @beta
63
63
  *
@@ -72,7 +72,7 @@ export declare function hasIsolatedChannels(attributes: ReadFluidDataStoreAttrib
72
72
  export interface IContainerRuntimeMetadata extends ICreateContainerMetadata, IGCMetadata {
73
73
  readonly summaryFormatVersion: 1;
74
74
  /**
75
- * @deprecated - used by old (prior to 2.0 RC3) runtimes
75
+ * @deprecated used by old (prior to 2.0 RC3) runtimes
76
76
  */
77
77
  readonly message?: ISummaryMetadataMessage;
78
78
  /**