@fluidframework/container-runtime 2.0.0-internal.5.4.0 → 2.0.0-internal.6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/dist/batchTracker.d.ts +2 -1
  3. package/dist/batchTracker.d.ts.map +1 -1
  4. package/dist/batchTracker.js.map +1 -1
  5. package/dist/blobManager.d.ts +4 -1
  6. package/dist/blobManager.d.ts.map +1 -1
  7. package/dist/blobManager.js +61 -26
  8. package/dist/blobManager.js.map +1 -1
  9. package/dist/connectionTelemetry.js +10 -2
  10. package/dist/connectionTelemetry.js.map +1 -1
  11. package/dist/containerRuntime.d.ts +26 -11
  12. package/dist/containerRuntime.d.ts.map +1 -1
  13. package/dist/containerRuntime.js +189 -131
  14. package/dist/containerRuntime.js.map +1 -1
  15. package/dist/dataStore.js +8 -2
  16. package/dist/dataStore.js.map +1 -1
  17. package/dist/dataStoreContext.d.ts.map +1 -1
  18. package/dist/dataStoreContext.js +24 -26
  19. package/dist/dataStoreContext.js.map +1 -1
  20. package/dist/dataStores.d.ts +20 -4
  21. package/dist/dataStores.d.ts.map +1 -1
  22. package/dist/dataStores.js +107 -53
  23. package/dist/dataStores.js.map +1 -1
  24. package/dist/deltaManagerProxyBase.d.ts +35 -0
  25. package/dist/deltaManagerProxyBase.d.ts.map +1 -0
  26. package/dist/deltaManagerProxyBase.js +77 -0
  27. package/dist/deltaManagerProxyBase.js.map +1 -0
  28. package/dist/deltaManagerSummarizerProxy.d.ts +1 -1
  29. package/dist/deltaManagerSummarizerProxy.d.ts.map +1 -1
  30. package/dist/deltaManagerSummarizerProxy.js +2 -2
  31. package/dist/deltaManagerSummarizerProxy.js.map +1 -1
  32. package/dist/gc/garbageCollection.js +17 -20
  33. package/dist/gc/garbageCollection.js.map +1 -1
  34. package/dist/gc/gcConfigs.js +13 -11
  35. package/dist/gc/gcConfigs.js.map +1 -1
  36. package/dist/gc/gcHelpers.js +4 -6
  37. package/dist/gc/gcHelpers.js.map +1 -1
  38. package/dist/gc/gcSummaryStateTracker.js +4 -6
  39. package/dist/gc/gcSummaryStateTracker.js.map +1 -1
  40. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  41. package/dist/gc/gcTelemetry.js +55 -37
  42. package/dist/gc/gcTelemetry.js.map +1 -1
  43. package/dist/id-compressor/idCompressor.js +49 -51
  44. package/dist/id-compressor/idCompressor.js.map +1 -1
  45. package/dist/id-compressor/idRange.js +2 -2
  46. package/dist/id-compressor/idRange.js.map +1 -1
  47. package/dist/id-compressor/sessionIdNormalizer.js +11 -16
  48. package/dist/id-compressor/sessionIdNormalizer.js.map +1 -1
  49. package/dist/index.d.ts +1 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js.map +1 -1
  52. package/dist/opLifecycle/batchManager.js +10 -6
  53. package/dist/opLifecycle/batchManager.js.map +1 -1
  54. package/dist/opLifecycle/opCompressor.js +6 -1
  55. package/dist/opLifecycle/opCompressor.js.map +1 -1
  56. package/dist/opLifecycle/opDecompressor.js +11 -9
  57. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  58. package/dist/opLifecycle/opGroupingManager.js +13 -5
  59. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  60. package/dist/opLifecycle/opSplitter.js +10 -6
  61. package/dist/opLifecycle/opSplitter.js.map +1 -1
  62. package/dist/opLifecycle/outbox.js +1 -2
  63. package/dist/opLifecycle/outbox.js.map +1 -1
  64. package/dist/opLifecycle/remoteMessageProcessor.js +1 -1
  65. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  66. package/dist/opProperties.js +1 -2
  67. package/dist/opProperties.js.map +1 -1
  68. package/dist/packageVersion.d.ts +1 -1
  69. package/dist/packageVersion.js +1 -1
  70. package/dist/packageVersion.js.map +1 -1
  71. package/dist/pendingStateManager.d.ts +2 -2
  72. package/dist/pendingStateManager.d.ts.map +1 -1
  73. package/dist/pendingStateManager.js +22 -22
  74. package/dist/pendingStateManager.js.map +1 -1
  75. package/dist/scheduleManager.js +14 -10
  76. package/dist/scheduleManager.js.map +1 -1
  77. package/dist/summary/orderedClientElection.d.ts +2 -1
  78. package/dist/summary/orderedClientElection.d.ts.map +1 -1
  79. package/dist/summary/orderedClientElection.js +17 -18
  80. package/dist/summary/orderedClientElection.js.map +1 -1
  81. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  82. package/dist/summary/runningSummarizer.js +35 -57
  83. package/dist/summary/runningSummarizer.js.map +1 -1
  84. package/dist/summary/summarizer.js +4 -7
  85. package/dist/summary/summarizer.js.map +1 -1
  86. package/dist/summary/summarizerClientElection.js +5 -9
  87. package/dist/summary/summarizerClientElection.js.map +1 -1
  88. package/dist/summary/summarizerHeuristics.js +8 -12
  89. package/dist/summary/summarizerHeuristics.js.map +1 -1
  90. package/dist/summary/summarizerNode/summarizerNode.js +22 -15
  91. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  92. package/dist/summary/summarizerNode/summarizerNodeUtils.js +2 -4
  93. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  94. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +17 -16
  95. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  96. package/dist/summary/summaryCollection.js +3 -5
  97. package/dist/summary/summaryCollection.js.map +1 -1
  98. package/dist/summary/summaryFormat.js +1 -2
  99. package/dist/summary/summaryFormat.js.map +1 -1
  100. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  101. package/dist/summary/summaryGenerator.js +62 -21
  102. package/dist/summary/summaryGenerator.js.map +1 -1
  103. package/dist/summary/summaryManager.js +3 -5
  104. package/dist/summary/summaryManager.js.map +1 -1
  105. package/lib/batchTracker.d.ts +2 -1
  106. package/lib/batchTracker.d.ts.map +1 -1
  107. package/lib/batchTracker.js.map +1 -1
  108. package/lib/blobManager.d.ts +4 -1
  109. package/lib/blobManager.d.ts.map +1 -1
  110. package/lib/blobManager.js +61 -26
  111. package/lib/blobManager.js.map +1 -1
  112. package/lib/connectionTelemetry.js +10 -2
  113. package/lib/connectionTelemetry.js.map +1 -1
  114. package/lib/containerRuntime.d.ts +26 -11
  115. package/lib/containerRuntime.d.ts.map +1 -1
  116. package/lib/containerRuntime.js +189 -131
  117. package/lib/containerRuntime.js.map +1 -1
  118. package/lib/dataStore.js +8 -2
  119. package/lib/dataStore.js.map +1 -1
  120. package/lib/dataStoreContext.d.ts.map +1 -1
  121. package/lib/dataStoreContext.js +24 -26
  122. package/lib/dataStoreContext.js.map +1 -1
  123. package/lib/dataStores.d.ts +20 -4
  124. package/lib/dataStores.d.ts.map +1 -1
  125. package/lib/dataStores.js +107 -53
  126. package/lib/dataStores.js.map +1 -1
  127. package/lib/deltaManagerProxyBase.d.ts +35 -0
  128. package/lib/deltaManagerProxyBase.d.ts.map +1 -0
  129. package/lib/deltaManagerProxyBase.js +73 -0
  130. package/lib/deltaManagerProxyBase.js.map +1 -0
  131. package/lib/deltaManagerSummarizerProxy.d.ts +1 -1
  132. package/lib/deltaManagerSummarizerProxy.d.ts.map +1 -1
  133. package/lib/deltaManagerSummarizerProxy.js +1 -1
  134. package/lib/deltaManagerSummarizerProxy.js.map +1 -1
  135. package/lib/gc/garbageCollection.js +17 -20
  136. package/lib/gc/garbageCollection.js.map +1 -1
  137. package/lib/gc/gcConfigs.js +13 -11
  138. package/lib/gc/gcConfigs.js.map +1 -1
  139. package/lib/gc/gcHelpers.js +4 -6
  140. package/lib/gc/gcHelpers.js.map +1 -1
  141. package/lib/gc/gcSummaryStateTracker.js +4 -6
  142. package/lib/gc/gcSummaryStateTracker.js.map +1 -1
  143. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  144. package/lib/gc/gcTelemetry.js +55 -37
  145. package/lib/gc/gcTelemetry.js.map +1 -1
  146. package/lib/id-compressor/idCompressor.js +49 -51
  147. package/lib/id-compressor/idCompressor.js.map +1 -1
  148. package/lib/id-compressor/idRange.js +2 -2
  149. package/lib/id-compressor/idRange.js.map +1 -1
  150. package/lib/id-compressor/sessionIdNormalizer.js +11 -16
  151. package/lib/id-compressor/sessionIdNormalizer.js.map +1 -1
  152. package/lib/index.d.ts +1 -1
  153. package/lib/index.d.ts.map +1 -1
  154. package/lib/index.js.map +1 -1
  155. package/lib/opLifecycle/batchManager.js +10 -6
  156. package/lib/opLifecycle/batchManager.js.map +1 -1
  157. package/lib/opLifecycle/opCompressor.js +6 -1
  158. package/lib/opLifecycle/opCompressor.js.map +1 -1
  159. package/lib/opLifecycle/opDecompressor.js +11 -9
  160. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  161. package/lib/opLifecycle/opGroupingManager.js +13 -5
  162. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  163. package/lib/opLifecycle/opSplitter.js +10 -6
  164. package/lib/opLifecycle/opSplitter.js.map +1 -1
  165. package/lib/opLifecycle/outbox.js +1 -2
  166. package/lib/opLifecycle/outbox.js.map +1 -1
  167. package/lib/opLifecycle/remoteMessageProcessor.js +1 -1
  168. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  169. package/lib/opProperties.js +1 -2
  170. package/lib/opProperties.js.map +1 -1
  171. package/lib/packageVersion.d.ts +1 -1
  172. package/lib/packageVersion.js +1 -1
  173. package/lib/packageVersion.js.map +1 -1
  174. package/lib/pendingStateManager.d.ts +2 -2
  175. package/lib/pendingStateManager.d.ts.map +1 -1
  176. package/lib/pendingStateManager.js +22 -22
  177. package/lib/pendingStateManager.js.map +1 -1
  178. package/lib/scheduleManager.js +14 -10
  179. package/lib/scheduleManager.js.map +1 -1
  180. package/lib/summary/orderedClientElection.d.ts +2 -1
  181. package/lib/summary/orderedClientElection.d.ts.map +1 -1
  182. package/lib/summary/orderedClientElection.js +17 -18
  183. package/lib/summary/orderedClientElection.js.map +1 -1
  184. package/lib/summary/runningSummarizer.d.ts.map +1 -1
  185. package/lib/summary/runningSummarizer.js +35 -57
  186. package/lib/summary/runningSummarizer.js.map +1 -1
  187. package/lib/summary/summarizer.js +4 -7
  188. package/lib/summary/summarizer.js.map +1 -1
  189. package/lib/summary/summarizerClientElection.js +5 -9
  190. package/lib/summary/summarizerClientElection.js.map +1 -1
  191. package/lib/summary/summarizerHeuristics.js +8 -12
  192. package/lib/summary/summarizerHeuristics.js.map +1 -1
  193. package/lib/summary/summarizerNode/summarizerNode.js +22 -15
  194. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  195. package/lib/summary/summarizerNode/summarizerNodeUtils.js +2 -4
  196. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  197. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +17 -16
  198. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  199. package/lib/summary/summaryCollection.js +3 -5
  200. package/lib/summary/summaryCollection.js.map +1 -1
  201. package/lib/summary/summaryFormat.js +1 -2
  202. package/lib/summary/summaryFormat.js.map +1 -1
  203. package/lib/summary/summaryGenerator.d.ts.map +1 -1
  204. package/lib/summary/summaryGenerator.js +62 -21
  205. package/lib/summary/summaryGenerator.js.map +1 -1
  206. package/lib/summary/summaryManager.js +3 -5
  207. package/lib/summary/summaryManager.js.map +1 -1
  208. package/package.json +19 -19
  209. package/src/batchTracker.ts +2 -1
  210. package/src/blobManager.ts +43 -2
  211. package/src/containerRuntime.ts +95 -67
  212. package/src/dataStore.ts +7 -1
  213. package/src/dataStoreContext.ts +1 -2
  214. package/src/dataStores.ts +95 -55
  215. package/src/deltaManagerProxyBase.ts +111 -0
  216. package/src/deltaManagerSummarizerProxy.ts +2 -1
  217. package/src/gc/gcTelemetry.ts +1 -2
  218. package/src/index.ts +0 -1
  219. package/src/packageVersion.ts +1 -1
  220. package/src/pendingStateManager.ts +12 -15
  221. package/src/summary/orderedClientElection.ts +2 -1
  222. package/src/summary/runningSummarizer.ts +9 -31
  223. package/src/summary/summaryGenerator.ts +0 -1
@@ -31,7 +31,6 @@ export class SummarizerNode {
31
31
  _latestSummary, initialSummary, wipSummaryLogger,
32
32
  /** A unique id of this node to be logged when sending telemetry. */
33
33
  telemetryNodeId) {
34
- var _a;
35
34
  this.summarizeInternalFn = summarizeInternalFn;
36
35
  this._changeSequenceNumber = _changeSequenceNumber;
37
36
  this._latestSummary = _latestSummary;
@@ -41,7 +40,7 @@ export class SummarizerNode {
41
40
  this.children = new Map();
42
41
  this.pendingSummaries = new Map();
43
42
  this.wipSkipRecursion = false;
44
- this.canReuseHandle = (_a = config.canReuseHandle) !== null && _a !== void 0 ? _a : true;
43
+ this.canReuseHandle = config.canReuseHandle ?? true;
45
44
  // All logs posted by the summarizer node should include the telemetryNodeId.
46
45
  this.logger = createChildLogger({
47
46
  logger: baseLogger,
@@ -55,8 +54,7 @@ export class SummarizerNode {
55
54
  * Returns 0 if there is not yet an acked summary.
56
55
  */
57
56
  get referenceSequenceNumber() {
58
- var _a, _b;
59
- return (_b = (_a = this._latestSummary) === null || _a === void 0 ? void 0 : _a.referenceSequenceNumber) !== null && _b !== void 0 ? _b : 0;
57
+ return this._latestSummary?.referenceSequenceNumber ?? 0;
60
58
  }
61
59
  startSummary(referenceSequenceNumber, summaryLogger) {
62
60
  assert(this.wipSummaryLogger === undefined, 0x19f /* "wipSummaryLogger should not be set yet in startSummary" */);
@@ -230,7 +228,11 @@ export class SummarizerNode {
230
228
  // If localPathsToUse is undefined, it means summarize didn't run for this node and in that case the validate
231
229
  // step should have failed.
232
230
  assert(localPathsToUse !== undefined, 0x6fe /* summarize didn't run for node */);
233
- const summary = new SummaryNode(Object.assign(Object.assign({}, localPathsToUse), { referenceSequenceNumber: this.wipReferenceSequenceNumber, basePath: parentPath }));
231
+ const summary = new SummaryNode({
232
+ ...localPathsToUse,
233
+ referenceSequenceNumber: this.wipReferenceSequenceNumber,
234
+ basePath: parentPath,
235
+ });
234
236
  const fullPathForChildren = summary.fullPathForChildren;
235
237
  for (const child of this.children.values()) {
236
238
  child.completeSummaryCore(proposalHandle, fullPathForChildren, this.wipSkipRecursion || parentSkipRecursion, validate);
@@ -273,8 +275,10 @@ export class SummarizerNode {
273
275
  summaryRefSeq,
274
276
  referenceSequenceNumber: this.referenceSequenceNumber,
275
277
  };
276
- return PerformanceEvent.timedExecAsync(this.logger, Object.assign({ eventName: "refreshLatestSummary" }, eventProps), async (event) => {
277
- var _a;
278
+ return PerformanceEvent.timedExecAsync(this.logger, {
279
+ eventName: "refreshLatestSummary",
280
+ ...eventProps,
281
+ }, async (event) => {
278
282
  // Refresh latest summary should not happen while a summary is in progress. If it does, it can result
279
283
  // in inconsistent state, so, we should not continue;
280
284
  if (this.isSummaryInProgress()) {
@@ -297,7 +301,7 @@ export class SummarizerNode {
297
301
  }
298
302
  const props = {
299
303
  summaryRefSeq,
300
- pendingSize: (_a = this.pendingSummaries.size) !== null && _a !== void 0 ? _a : undefined,
304
+ pendingSize: this.pendingSummaries.size ?? undefined,
301
305
  };
302
306
  this.logger.sendTelemetryEvent({
303
307
  eventName: "PendingSummaryNotFound",
@@ -456,7 +460,6 @@ export class SummarizerNode {
456
460
  * @returns the details needed to create the child node.
457
461
  */
458
462
  getCreateDetailsForChild(id, createParam) {
459
- var _a, _b;
460
463
  let initialSummary;
461
464
  let latestSummary;
462
465
  let changeSequenceNumber;
@@ -512,8 +515,8 @@ export class SummarizerNode {
512
515
  summary: childSummaryWithStats,
513
516
  };
514
517
  }
515
- latestSummary = parentLatestSummary === null || parentLatestSummary === void 0 ? void 0 : parentLatestSummary.createForChild(id);
516
- changeSequenceNumber = (_a = parentLatestSummary === null || parentLatestSummary === void 0 ? void 0 : parentLatestSummary.referenceSequenceNumber) !== null && _a !== void 0 ? _a : -1;
518
+ latestSummary = parentLatestSummary?.createForChild(id);
519
+ changeSequenceNumber = parentLatestSummary?.referenceSequenceNumber ?? -1;
517
520
  break;
518
521
  }
519
522
  default: {
@@ -521,7 +524,7 @@ export class SummarizerNode {
521
524
  unreachableCase(createParam, `Unexpected CreateSummarizerNodeSource: ${type}`);
522
525
  }
523
526
  }
524
- const childtelemetryNodeId = `${(_b = this.telemetryNodeId) !== null && _b !== void 0 ? _b : ""}/${id}`;
527
+ const childtelemetryNodeId = `${this.telemetryNodeId ?? ""}/${id}`;
525
528
  return {
526
529
  initialSummary,
527
530
  latestSummary,
@@ -569,9 +572,13 @@ export class SummarizerNode {
569
572
  * Creates and throws an error due to unexpected conditions.
570
573
  */
571
574
  throwUnexpectedError(eventProps) {
572
- const error = new LoggingError(eventProps.eventName, Object.assign(Object.assign(Object.assign({}, eventProps), { referenceSequenceNumber: this.wipReferenceSequenceNumber }), tagCodeArtifacts({
573
- id: this.telemetryNodeId,
574
- })));
575
+ const error = new LoggingError(eventProps.eventName, {
576
+ ...eventProps,
577
+ referenceSequenceNumber: this.wipReferenceSequenceNumber,
578
+ ...tagCodeArtifacts({
579
+ id: this.telemetryNodeId,
580
+ }),
581
+ });
575
582
  this.logger.sendErrorEvent(eventProps, error);
576
583
  throw error;
577
584
  }
@@ -1 +1 @@
1
- {"version":3,"file":"summarizerNode.js","sourceRoot":"","sources":["../../../src/summary/summarizerNode/summarizerNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAMN,0BAA0B,GAI1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAEN,WAAW,GAGX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAEN,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACN,oBAAoB,EACpB,cAAc,EACd,UAAU,GAEV,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,WAAW,EAKX,uBAAuB,EACvB,2BAA2B,EAE3B,WAAW,GAEX,MAAM,uBAAuB,CAAC;AAI/B;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAc;IAiB1B;;;OAGG;IACH,YACC,UAAgC,EACf,mBAAwC,EACzD,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,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACI,mBAAmB;QACzB,OAAO,IAAI,CAAC,0BAA0B,KAAK,SAAS,CAAC;IACtD,CAAC;IAED;;OAEG;IACO,oBAAoB,CAAC,UAAgC;QAC9D,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,SAAS,gDAC/C,UAAU,KACb,uBAAuB,EAAE,IAAI,CAAC,0BAA0B,KACrD,gBAAgB,CAAC;YACnB,EAAE,EAAE,IAAI,CAAC,eAAe;SACxB,CAAC,EACD,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC9C,MAAM,KAAK,CAAC;IACb,CAAC;CACD;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACvC,MAA2B,EAC3B,mBAAwC,EACxC,oBAA4B,EAC5B,uBAA2C,EAC3C,SAAgC,EAAE,EACZ,EAAE,CACxB,IAAI,cAAc,CACjB,MAAM,EACN,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACpB,uBAAuB,KAAK,SAAS;IACpC,CAAC,CAAC,SAAS;IACX,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,uBAAuB,CAAC,EACrD,SAAS,CAAC,oBAAoB,EAC9B,SAAS,CAAC,sBAAsB,EAChC,EAAE,CAAC,qBAAqB,CACxB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger, ITelemetryErrorEvent } from \"@fluidframework/core-interfaces\";\nimport {\n\tISummarizerNode,\n\tISummarizerNodeConfig,\n\tISummarizeResult,\n\tISummaryTreeWithStats,\n\tCreateChildSummarizerNodeParam,\n\tCreateSummarizerNodeSource,\n\tSummarizeInternalFn,\n\tITelemetryContext,\n\tIExperimentalIncrementalSummaryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n\tISequencedDocumentMessage,\n\tSummaryType,\n\tISnapshotTree,\n\tSummaryObject,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tITelemetryLoggerExt,\n\tcreateChildLogger,\n\tLoggingError,\n\tPerformanceEvent,\n\tTelemetryDataTag,\n\ttagCodeArtifacts,\n} from \"@fluidframework/telemetry-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/common-utils\";\nimport {\n\tconvertToSummaryTree,\n\tcalculateStats,\n\tmergeStats,\n\tReadAndParseBlob,\n} from \"@fluidframework/runtime-utils\";\nimport {\n\tEscapedPath,\n\tICreateChildDetails,\n\tIFetchSnapshotResult,\n\tIInitialSummary,\n\tISummarizerNodeRootContract,\n\tparseSummaryForSubtrees,\n\tparseSummaryTreeForSubtrees,\n\tRefreshSummaryResult,\n\tSummaryNode,\n\tValidateSummaryResult,\n} from \"./summarizerNodeUtils\";\n\nexport interface IRootSummarizerNode extends ISummarizerNode, ISummarizerNodeRootContract {}\n\n/**\n * Encapsulates the summarizing work and state of an individual tree node in the\n * summary tree. It tracks changes and allows for optimizations when unchanged, or\n * can allow for fallback summaries to be generated when an error is encountered.\n * Usage is for the root node to call startSummary first to begin tracking a WIP\n * (work in progress) summary. Then all nodes will call summarize to summaries their\n * individual parts. Once completed and uploaded to storage, the root node will call\n * completeSummary or clearSummary to clear the WIP summary tracking state if something\n * went wrong. The SummarizerNodes will track all pending summaries that have been\n * recorded by the completeSummary call. When one of them is acked, the root node should\n * call refreshLatestSummary to inform the tree of SummarizerNodes of the new baseline\n * latest successful summary.\n */\nexport class SummarizerNode implements IRootSummarizerNode {\n\t/**\n\t * The reference sequence number of the most recent acked summary.\n\t * Returns 0 if there is not yet an acked summary.\n\t */\n\tpublic get referenceSequenceNumber() {\n\t\treturn this._latestSummary?.referenceSequenceNumber ?? 0;\n\t}\n\n\tprotected readonly children = new Map<string, SummarizerNode>();\n\tprotected readonly pendingSummaries = new Map<string, SummaryNode>();\n\tprotected wipReferenceSequenceNumber: number | undefined;\n\tprivate wipLocalPaths: { localPath: EscapedPath; additionalPath?: EscapedPath } | undefined;\n\tprivate wipSkipRecursion = false;\n\n\tprotected readonly logger: ITelemetryLoggerExt;\n\n\t/**\n\t * Do not call constructor directly.\n\t * Use createRootSummarizerNode to create root node, or createChild to create child nodes.\n\t */\n\tpublic constructor(\n\t\tbaseLogger: ITelemetryBaseLogger,\n\t\tprivate readonly summarizeInternalFn: SummarizeInternalFn,\n\t\tconfig: ISummarizerNodeConfig,\n\t\tprivate _changeSequenceNumber: number,\n\t\t/** Undefined means created without summary */\n\t\tprivate _latestSummary?: SummaryNode,\n\t\tprivate readonly initialSummary?: IInitialSummary,\n\t\tprotected wipSummaryLogger?: ITelemetryBaseLogger,\n\t\t/** A unique id of this node to be logged when sending telemetry. */\n\t\tprotected telemetryNodeId?: string,\n\t) {\n\t\tthis.canReuseHandle = config.canReuseHandle ?? true;\n\t\t// All logs posted by the summarizer node should include the telemetryNodeId.\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: baseLogger,\n\t\t\tproperties: {\n\t\t\t\tall: tagCodeArtifacts({ id: this.telemetryNodeId }),\n\t\t\t},\n\t\t});\n\t}\n\n\tpublic startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryBaseLogger) {\n\t\tassert(\n\t\t\tthis.wipSummaryLogger === undefined,\n\t\t\t0x19f /* \"wipSummaryLogger should not be set yet in startSummary\" */,\n\t\t);\n\t\tassert(\n\t\t\tthis.wipReferenceSequenceNumber === undefined,\n\t\t\t0x1a0 /* \"Already tracking a summary\" */,\n\t\t);\n\n\t\tthis.wipSummaryLogger = summaryLogger;\n\n\t\tfor (const child of this.children.values()) {\n\t\t\tchild.startSummary(referenceSequenceNumber, this.wipSummaryLogger);\n\t\t}\n\t\tthis.wipReferenceSequenceNumber = referenceSequenceNumber;\n\t}\n\n\tpublic async summarize(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean = true,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\tassert(\n\t\t\tthis.isSummaryInProgress(),\n\t\t\t0x1a1 /* \"summarize should not be called when not tracking the summary\" */,\n\t\t);\n\t\tassert(\n\t\t\tthis.wipSummaryLogger !== undefined,\n\t\t\t0x1a2 /* \"wipSummaryLogger should have been set in startSummary or ctor\" */,\n\t\t);\n\n\t\t// Try to reuse the tree if unchanged\n\t\tif (this.canReuseHandle && !fullTree && !this.hasChanged()) {\n\t\t\tconst latestSummary = this._latestSummary;\n\t\t\tif (latestSummary !== undefined) {\n\t\t\t\tthis.wipLocalPaths = {\n\t\t\t\t\tlocalPath: latestSummary.localPath,\n\t\t\t\t\tadditionalPath: latestSummary.additionalPath,\n\t\t\t\t};\n\t\t\t\tthis.wipSkipRecursion = true;\n\t\t\t\tconst stats = mergeStats();\n\t\t\t\tstats.handleNodeCount++;\n\t\t\t\treturn {\n\t\t\t\t\tsummary: {\n\t\t\t\t\t\ttype: SummaryType.Handle,\n\t\t\t\t\t\thandle: latestSummary.fullPath.path,\n\t\t\t\t\t\thandleType: SummaryType.Tree,\n\t\t\t\t\t},\n\t\t\t\t\tstats,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// This assert is the same the other 0a1x1 assert `isSummaryInProgress`, the only difference is that typescript\n\t\t// complains if this assert isn't done this way\n\t\tassert(\n\t\t\tthis.wipReferenceSequenceNumber !== undefined,\n\t\t\t0x5df /* Summarize should not be called when not tracking the summary */,\n\t\t);\n\t\tconst incrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined =\n\t\t\tthis._latestSummary !== undefined\n\t\t\t\t? {\n\t\t\t\t\t\tsummarySequenceNumber: this.wipReferenceSequenceNumber,\n\t\t\t\t\t\tlatestSummarySequenceNumber: this._latestSummary.referenceSequenceNumber,\n\t\t\t\t\t\t// TODO: remove summaryPath\n\t\t\t\t\t\tsummaryPath: this._latestSummary.fullPath.path,\n\t\t\t\t }\n\t\t\t\t: undefined;\n\n\t\tconst result = await this.summarizeInternalFn(\n\t\t\tfullTree,\n\t\t\ttrue,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t);\n\t\tthis.wipLocalPaths = { localPath: EscapedPath.create(result.id) };\n\t\tif (result.pathPartsForChildren !== undefined) {\n\t\t\tthis.wipLocalPaths.additionalPath = EscapedPath.createAndConcat(\n\t\t\t\tresult.pathPartsForChildren,\n\t\t\t);\n\t\t}\n\t\treturn { summary: result.summary, stats: result.stats };\n\t}\n\n\t/**\n\t * Validates that the in-progress summary is correct, i.e., summarize should have run for all non-skipped\n\t * nodes. This will only be called for the root summarizer node and is called by it recursively on all child nodes.\n\t *\n\t * @returns ValidateSummaryResult which contains a boolean success indicating whether the validation was successful.\n\t * In case of failure, additional information is returned indicating type of failure and where it was.\n\t */\n\tpublic validateSummary(): ValidateSummaryResult {\n\t\treturn this.validateSummaryCore(false /* parentSkipRecursion */);\n\t}\n\n\t/**\n\t * Validates that the in-progress summary is correct for all nodes, i.e., summarize should have run for all\n\t * non-skipped nodes.\n\t * @param parentSkipRecursion - true if the parent of this node skipped recursing the child nodes when summarizing.\n\t * In that case, the children will not have work-in-progress state.\n\t *\n\t * @returns ValidateSummaryResult which contains a boolean success indicating whether the validation was successful.\n\t * In case of failure, additional information is returned indicating type of failure and where it was.\n\t */\n\tprotected validateSummaryCore(parentSkipRecursion: boolean): ValidateSummaryResult {\n\t\tif (this.wasSummarizeMissed(parentSkipRecursion)) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\treason: \"NodeDidNotSummarize\",\n\t\t\t\tid: {\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t\tvalue: this.telemetryNodeId,\n\t\t\t\t},\n\t\t\t\t// These errors are usually transient and should go away when summarize is retried.\n\t\t\t\tretryAfterSeconds: 1,\n\t\t\t};\n\t\t}\n\t\tif (parentSkipRecursion) {\n\t\t\treturn { success: true };\n\t\t}\n\n\t\tfor (const child of this.children.values()) {\n\t\t\tconst result = child.validateSummaryCore(this.wipSkipRecursion || parentSkipRecursion);\n\t\t\t// If any child fails, return the failure.\n\t\t\tif (!result.success) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t\treturn { success: true };\n\t}\n\n\tprivate wasSummarizeMissed(parentSkipRecursion: boolean): boolean {\n\t\tassert(\n\t\t\tthis.wipSummaryLogger !== undefined,\n\t\t\t0x6fc /* wipSummaryLogger should have been set in startSummary or ctor */,\n\t\t);\n\t\tassert(this.wipReferenceSequenceNumber !== undefined, 0x6fd /* Not tracking a summary */);\n\n\t\t// If the parent node skipped recursion, it did not call summarize on this node. So, summarize was not missed\n\t\t// but was intentionally not called.\n\t\t// Otherwise, summarize should have been called on this node and wipLocalPaths must be set.\n\t\tif (parentSkipRecursion || this.wipLocalPaths !== undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\t/**\n\t\t * The absence of wip local path indicates that summarize was not called for this node. Return failure.\n\t\t * This can happen if:\n\t\t * 1. A child node was created after summarize was already called on the parent. For example, a data store\n\t\t * is realized (loaded) after summarize was called on it creating summarizer nodes for its DDSes. In this case,\n\t\t * parentSkipRecursion will be true and the if block above would handle it.\n\t\t * 2. A new node was created but summarize was never called on it. This can mean that the summary that is\n\t\t * generated may not have the data from this node. We should not continue, log and throw an error. This\n\t\t * will help us identify these cases and take appropriate action.\n\t\t *\n\t\t * This happens due to scenarios such as data store created during summarize. Such errors should go away when\n\t\t * summarize is attempted again.\n\t\t */\n\t\treturn true;\n\t}\n\n\t/**\n\t * Called after summary has been uploaded to the server. Add the work-in-progress state to the pending summary\n\t * queue. We track this until we get an ack from the server for this summary.\n\t * @param proposalHandle - The handle of the summary that was uploaded to the server.\n\t */\n\tpublic completeSummary(proposalHandle: string, validate: boolean) {\n\t\tthis.completeSummaryCore(\n\t\t\tproposalHandle,\n\t\t\tundefined /* parentPath */,\n\t\t\tfalse /* parentSkipRecursion */,\n\t\t\tvalidate,\n\t\t);\n\t}\n\n\t/**\n\t * Recursive implementation for completeSummary, with additional internal-only parameters.\n\t * @param proposalHandle - The handle of the summary that was uploaded to the server.\n\t * @param parentPath - The path of the parent node which is used to build the path of this node.\n\t * @param parentSkipRecursion - true if the parent of this node skipped recursing the child nodes when summarizing.\n\t * In that case, the children will not have work-in-progress state.\n\t * @param validate - true to validate that the in-progress summary is correct for all nodes.\n\t */\n\tprotected completeSummaryCore(\n\t\tproposalHandle: string,\n\t\tparentPath: EscapedPath | undefined,\n\t\tparentSkipRecursion: boolean,\n\t\tvalidate: boolean,\n\t) {\n\t\tif (validate && this.wasSummarizeMissed(parentSkipRecursion)) {\n\t\t\tthis.throwUnexpectedError({\n\t\t\t\teventName: \"NodeDidNotSummarize\",\n\t\t\t\tproposalHandle,\n\t\t\t});\n\t\t}\n\n\t\tassert(this.wipReferenceSequenceNumber !== undefined, 0x1a4 /* \"Not tracking a summary\" */);\n\t\tlet localPathsToUse = this.wipLocalPaths;\n\n\t\tif (parentSkipRecursion) {\n\t\t\tconst latestSummary = this._latestSummary;\n\t\t\tif (latestSummary !== undefined) {\n\t\t\t\t// This case the parent node created a failure summary or was reused.\n\t\t\t\t// This node and all children should only try to reference their path\n\t\t\t\t// by its last known good state in the actual summary tree.\n\t\t\t\t// If parent fails or is reused, the child summarize is not called so\n\t\t\t\t// it did not get a chance to change its paths.\n\t\t\t\t// In this case, essentially only propagate the new summary ref seq num.\n\t\t\t\tlocalPathsToUse = {\n\t\t\t\t\tlocalPath: latestSummary.localPath,\n\t\t\t\t\tadditionalPath: latestSummary.additionalPath,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\t// This case the child is added after the latest non-failure summary.\n\t\t\t\t// This node and all children should consider themselves as still not\n\t\t\t\t// having a successful summary yet.\n\t\t\t\t// We cannot \"reuse\" this node if unchanged since that summary, because\n\t\t\t\t// handles will be unable to point to that node. It never made it to the\n\t\t\t\t// tree itself, and only exists as an attach op in the _outstandingOps.\n\t\t\t\tthis.clearSummary();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// If localPathsToUse is undefined, it means summarize didn't run for this node and in that case the validate\n\t\t// step should have failed.\n\t\tassert(localPathsToUse !== undefined, 0x6fe /* summarize didn't run for node */);\n\t\tconst summary = new SummaryNode({\n\t\t\t...localPathsToUse,\n\t\t\treferenceSequenceNumber: this.wipReferenceSequenceNumber,\n\t\t\tbasePath: parentPath,\n\t\t});\n\t\tconst fullPathForChildren = summary.fullPathForChildren;\n\t\tfor (const child of this.children.values()) {\n\t\t\tchild.completeSummaryCore(\n\t\t\t\tproposalHandle,\n\t\t\t\tfullPathForChildren,\n\t\t\t\tthis.wipSkipRecursion || parentSkipRecursion,\n\t\t\t\tvalidate,\n\t\t\t);\n\t\t}\n\t\t// Note that this overwrites existing pending summary with\n\t\t// the same proposalHandle. If proposalHandle is something like\n\t\t// a hash or unique identifier, this should be fine. If storage\n\t\t// can return the same proposalHandle for a different summary,\n\t\t// this should still be okay, because we should be proposing the\n\t\t// newer one later which would have to overwrite the previous one.\n\t\tthis.pendingSummaries.set(proposalHandle, summary);\n\t\tthis.clearSummary();\n\t}\n\n\tpublic clearSummary() {\n\t\tthis.wipReferenceSequenceNumber = undefined;\n\t\tthis.wipLocalPaths = undefined;\n\t\tthis.wipSkipRecursion = false;\n\t\tthis.wipSummaryLogger = undefined;\n\t\tfor (const child of this.children.values()) {\n\t\t\tchild.clearSummary();\n\t\t}\n\t}\n\n\t/**\n\t * Refreshes the latest summary tracked by this node. If we have a pending summary for the given proposal handle,\n\t * it becomes the latest summary. If the current summary is already ahead (e.g., loaded from a service summary),\n\t * we skip the update. Otherwise, we fetch the latest snapshot and update latest summary based off of that.\n\t *\n\t * @returns A RefreshSummaryResult type which returns information based on the following three scenarios:\n\t *\n\t * 1. The latest summary was not updated.\n\t *\n\t * 2. The latest summary was updated and the summary corresponding to the params was being tracked.\n\t *\n\t * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this\n\t * case, the latest summary is updated based on the downloaded snapshot which is also returned.\n\t */\n\tpublic async refreshLatestSummary(\n\t\tproposalHandle: string | undefined,\n\t\tsummaryRefSeq: number,\n\t\tfetchLatestSnapshot: () => Promise<IFetchSnapshotResult>,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t\tcorrelatedSummaryLogger: ITelemetryLoggerExt,\n\t): Promise<RefreshSummaryResult> {\n\t\tconst eventProps: {\n\t\t\tproposalHandle: string | undefined;\n\t\t\tsummaryRefSeq: number;\n\t\t\treferenceSequenceNumber: number;\n\t\t\tlatestSummaryUpdated?: boolean;\n\t\t\twasSummaryTracked?: boolean;\n\t\t} = {\n\t\t\tproposalHandle,\n\t\t\tsummaryRefSeq,\n\t\t\treferenceSequenceNumber: this.referenceSequenceNumber,\n\t\t};\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"refreshLatestSummary\",\n\t\t\t\t...eventProps,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\t// Refresh latest summary should not happen while a summary is in progress. If it does, it can result\n\t\t\t\t// in inconsistent state, so, we should not continue;\n\t\t\t\tif (this.isSummaryInProgress()) {\n\t\t\t\t\tthrow new LoggingError(\"UnexpectedRefreshDuringSummarize\", {\n\t\t\t\t\t\tinProgressSummaryRefSeq: this.wipReferenceSequenceNumber,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (proposalHandle !== undefined) {\n\t\t\t\t\tconst maybeSummaryNode = this.pendingSummaries.get(proposalHandle);\n\n\t\t\t\t\tif (maybeSummaryNode !== undefined) {\n\t\t\t\t\t\tthis.refreshLatestSummaryFromPending(\n\t\t\t\t\t\t\tproposalHandle,\n\t\t\t\t\t\t\tmaybeSummaryNode.referenceSequenceNumber,\n\t\t\t\t\t\t);\n\t\t\t\t\t\teventProps.wasSummaryTracked = true;\n\t\t\t\t\t\teventProps.latestSummaryUpdated = true;\n\t\t\t\t\t\tevent.end(eventProps);\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tlatestSummaryUpdated: true,\n\t\t\t\t\t\t\twasSummaryTracked: true,\n\t\t\t\t\t\t\tsummaryRefSeq,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst props = {\n\t\t\t\t\t\tsummaryRefSeq,\n\t\t\t\t\t\tpendingSize: this.pendingSummaries.size ?? undefined,\n\t\t\t\t\t};\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"PendingSummaryNotFound\",\n\t\t\t\t\t\tproposalHandle,\n\t\t\t\t\t\treferenceSequenceNumber: this.referenceSequenceNumber,\n\t\t\t\t\t\tdetails: JSON.stringify(props),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// If the summary for which refresh is called is older than the latest tracked summary, ignore it.\n\t\t\t\tif (this.referenceSequenceNumber >= summaryRefSeq) {\n\t\t\t\t\teventProps.latestSummaryUpdated = false;\n\t\t\t\t\tevent.end(eventProps);\n\t\t\t\t\treturn { latestSummaryUpdated: false };\n\t\t\t\t}\n\n\t\t\t\t// Fetch the latest snapshot and refresh state from it. Note that we need to use the reference sequence number\n\t\t\t\t// of the fetched snapshot and not the \"summaryRefSeq\" that was passed in.\n\t\t\t\tconst { snapshotTree, snapshotRefSeq: fetchedSnapshotRefSeq } =\n\t\t\t\t\tawait fetchLatestSnapshot();\n\n\t\t\t\t// Possible re-entrancy. We may have updated latest summary state while fetching the snapshot. If the fetched\n\t\t\t\t// snapshot is older than the latest tracked summary, ignore it.\n\t\t\t\tif (this.referenceSequenceNumber >= fetchedSnapshotRefSeq) {\n\t\t\t\t\teventProps.latestSummaryUpdated = false;\n\t\t\t\t\tevent.end(eventProps);\n\t\t\t\t\treturn { latestSummaryUpdated: false };\n\t\t\t\t}\n\n\t\t\t\tawait this.refreshLatestSummaryFromSnapshot(\n\t\t\t\t\tfetchedSnapshotRefSeq,\n\t\t\t\t\tsnapshotTree,\n\t\t\t\t\tundefined,\n\t\t\t\t\tEscapedPath.create(\"\"),\n\t\t\t\t\tcorrelatedSummaryLogger,\n\t\t\t\t\treadAndParseBlob,\n\t\t\t\t);\n\n\t\t\t\teventProps.latestSummaryUpdated = true;\n\t\t\t\teventProps.wasSummaryTracked = false;\n\t\t\t\teventProps.summaryRefSeq = fetchedSnapshotRefSeq;\n\t\t\t\tevent.end(eventProps);\n\t\t\t\treturn {\n\t\t\t\t\tlatestSummaryUpdated: true,\n\t\t\t\t\twasSummaryTracked: false,\n\t\t\t\t\tsnapshotTree,\n\t\t\t\t\tsummaryRefSeq: fetchedSnapshotRefSeq,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ start: true, end: true, cancel: \"error\" },\n\t\t);\n\t}\n\t/**\n\t * Called when we get an ack from the server for a summary we've just sent. Updates the reference state of this node\n\t * from the state in the pending summary queue.\n\t * @param proposalHandle - Handle for the current proposal.\n\t * @param referenceSequenceNumber - reference sequence number of sent summary.\n\t */\n\tprotected refreshLatestSummaryFromPending(\n\t\tproposalHandle: string,\n\t\treferenceSequenceNumber: number,\n\t): void {\n\t\tconst summaryNode = this.pendingSummaries.get(proposalHandle);\n\t\tif (summaryNode === undefined) {\n\t\t\t// This should only happen if parent skipped recursion AND no prior summary existed.\n\t\t\tassert(\n\t\t\t\tthis._latestSummary === undefined,\n\t\t\t\t0x1a6 /* \"Not found pending summary, but this node has previously completed a summary\" */,\n\t\t\t);\n\t\t\treturn;\n\t\t} else {\n\t\t\tassert(\n\t\t\t\treferenceSequenceNumber === summaryNode.referenceSequenceNumber,\n\t\t\t\t0x1a7 /* Pending summary reference sequence number should be consistent */,\n\t\t\t);\n\n\t\t\t// Clear earlier pending summaries\n\t\t\tthis.pendingSummaries.delete(proposalHandle);\n\t\t}\n\n\t\tthis.refreshLatestSummaryCore(referenceSequenceNumber);\n\n\t\tthis._latestSummary = summaryNode;\n\t\t// Propagate update to all child nodes\n\t\tfor (const child of this.children.values()) {\n\t\t\tchild.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n\t\t}\n\t}\n\n\tprotected async refreshLatestSummaryFromSnapshot(\n\t\treferenceSequenceNumber: number,\n\t\tsnapshotTree: ISnapshotTree,\n\t\tbasePath: EscapedPath | undefined,\n\t\tlocalPath: EscapedPath,\n\t\tcorrelatedSummaryLogger: ITelemetryLoggerExt,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t): Promise<void> {\n\t\t// Possible re-entrancy. If we have already seen a summary later than this one, ignore it.\n\t\tif (this.referenceSequenceNumber >= referenceSequenceNumber) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.refreshLatestSummaryCore(referenceSequenceNumber);\n\n\t\tthis._latestSummary = new SummaryNode({\n\t\t\treferenceSequenceNumber,\n\t\t\tbasePath,\n\t\t\tlocalPath,\n\t\t});\n\n\t\tconst pathParts: string[] = [];\n\t\tconst { childrenTree, childrenPathPart } = parseSummaryForSubtrees(snapshotTree);\n\t\tif (childrenPathPart !== undefined) {\n\t\t\tpathParts.push(childrenPathPart);\n\t\t}\n\n\t\tif (pathParts.length > 0) {\n\t\t\tthis._latestSummary.additionalPath = EscapedPath.createAndConcat(pathParts);\n\t\t}\n\n\t\t// Propagate update to all child nodes\n\t\tconst pathForChildren = this._latestSummary.fullPathForChildren;\n\t\tawait Promise.all(\n\t\t\tArray.from(this.children)\n\t\t\t\t.filter(([id]) => {\n\t\t\t\t\t// Assuming subtrees missing from snapshot are newer than the snapshot,\n\t\t\t\t\t// but might be nice to assert this using earliest seq for node.\n\t\t\t\t\treturn childrenTree.trees[id] !== undefined;\n\t\t\t\t})\n\t\t\t\t.map(async ([id, child]) => {\n\t\t\t\t\treturn child.refreshLatestSummaryFromSnapshot(\n\t\t\t\t\t\treferenceSequenceNumber,\n\t\t\t\t\t\tchildrenTree.trees[id],\n\t\t\t\t\t\tpathForChildren,\n\t\t\t\t\t\tEscapedPath.create(id),\n\t\t\t\t\t\tcorrelatedSummaryLogger,\n\t\t\t\t\t\treadAndParseBlob,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t);\n\t}\n\n\tprivate refreshLatestSummaryCore(referenceSequenceNumber: number): void {\n\t\tfor (const [key, value] of this.pendingSummaries) {\n\t\t\tif (value.referenceSequenceNumber < referenceSequenceNumber) {\n\t\t\t\tthis.pendingSummaries.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic updateBaseSummaryState(snapshot: ISnapshotTree) {\n\t\t// Check base summary to see if it has any additional path parts\n\t\t// separating child SummarizerNodes. Checks for .channels subtrees.\n\t\tconst { childrenPathPart } = parseSummaryForSubtrees(snapshot);\n\t\tif (childrenPathPart !== undefined && this._latestSummary !== undefined) {\n\t\t\tthis._latestSummary.additionalPath = EscapedPath.create(childrenPathPart);\n\t\t}\n\t}\n\n\tpublic recordChange(op: ISequencedDocumentMessage): void {\n\t\tthis.invalidate(op.sequenceNumber);\n\t}\n\n\tpublic invalidate(sequenceNumber: number): void {\n\t\tif (sequenceNumber > this._changeSequenceNumber) {\n\t\t\tthis._changeSequenceNumber = sequenceNumber;\n\t\t}\n\t}\n\n\t/**\n\t * True if a change has been recorded with sequence number exceeding\n\t * the latest successfully acked summary reference sequence number.\n\t * False implies that the previous summary can be reused.\n\t */\n\tprotected hasChanged(): boolean {\n\t\treturn this._changeSequenceNumber > this.referenceSequenceNumber;\n\t}\n\n\tpublic get latestSummary(): Readonly<SummaryNode> | undefined {\n\t\treturn this._latestSummary;\n\t}\n\n\tprotected readonly canReuseHandle: boolean;\n\n\tpublic createChild(\n\t\t/** Summarize function */\n\t\tsummarizeInternalFn: SummarizeInternalFn,\n\t\t/** Initial id or path part of this node */\n\t\tid: string,\n\t\t/**\n\t\t * Information needed to create the node.\n\t\t * If it is from a base summary, it will assert that a summary has been seen.\n\t\t * Attach information if it is created from an attach op.\n\t\t */\n\t\tcreateParam: CreateChildSummarizerNodeParam,\n\t\tconfig: ISummarizerNodeConfig = {},\n\t): ISummarizerNode {\n\t\tassert(!this.children.has(id), 0x1ab /* \"Create SummarizerNode child already exists\" */);\n\n\t\tconst createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n\t\tconst child = new SummarizerNode(\n\t\t\tthis.logger,\n\t\t\tsummarizeInternalFn,\n\t\t\tconfig,\n\t\t\tcreateDetails.changeSequenceNumber,\n\t\t\tcreateDetails.latestSummary,\n\t\t\tcreateDetails.initialSummary,\n\t\t\tthis.wipSummaryLogger,\n\t\t\tcreateDetails.telemetryNodeId,\n\t\t);\n\n\t\t// There may be additional state that has to be updated in this child. For example, if a summary is being\n\t\t// tracked, the child's summary tracking state needs to be updated too. Same goes for pendingSummaries we might\n\t\t// have outstanding on the parent in case we realize nodes in between Summary Op and Summary Ack.\n\t\tthis.maybeUpdateChildState(child, id);\n\n\t\tthis.children.set(id, child);\n\t\treturn child;\n\t}\n\n\tpublic getChild(id: string): ISummarizerNode | undefined {\n\t\treturn this.children.get(id);\n\t}\n\n\t/**\n\t * Returns the details needed to create a child node.\n\t * @param id - Initial id or path part of the child node.\n\t * @param createParam - Information needed to create the node.\n\t * @returns the details needed to create the child node.\n\t */\n\tprotected getCreateDetailsForChild(\n\t\tid: string,\n\t\tcreateParam: CreateChildSummarizerNodeParam,\n\t): ICreateChildDetails {\n\t\tlet initialSummary: IInitialSummary | undefined;\n\t\tlet latestSummary: SummaryNode | undefined;\n\t\tlet changeSequenceNumber: number;\n\n\t\tconst parentLatestSummary = this._latestSummary;\n\t\tswitch (createParam.type) {\n\t\t\tcase CreateSummarizerNodeSource.FromAttach: {\n\t\t\t\tif (\n\t\t\t\t\tparentLatestSummary !== undefined &&\n\t\t\t\t\tcreateParam.sequenceNumber <= parentLatestSummary.referenceSequenceNumber\n\t\t\t\t) {\n\t\t\t\t\t// Prioritize latest summary if it was after this node was attached.\n\t\t\t\t\tlatestSummary = parentLatestSummary.createForChild(id);\n\t\t\t\t} else {\n\t\t\t\t\tconst summary = convertToSummaryTree(\n\t\t\t\t\t\tcreateParam.snapshot,\n\t\t\t\t\t) as ISummaryTreeWithStats;\n\t\t\t\t\tinitialSummary = {\n\t\t\t\t\t\tsequenceNumber: createParam.sequenceNumber,\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tsummary,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tchangeSequenceNumber = createParam.sequenceNumber;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CreateSummarizerNodeSource.FromSummary: {\n\t\t\t\tif (this.initialSummary === undefined) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!!parentLatestSummary,\n\t\t\t\t\t\t0x1ac /* \"Cannot create child from summary if parent does not have latest summary\" */,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// fallthrough to local\n\t\t\t}\n\t\t\tcase CreateSummarizerNodeSource.Local: {\n\t\t\t\tconst parentInitialSummary = this.initialSummary;\n\t\t\t\tif (parentInitialSummary !== undefined) {\n\t\t\t\t\tlet childSummary: SummaryObject | undefined;\n\t\t\t\t\tif (parentInitialSummary.summary !== undefined) {\n\t\t\t\t\t\tconst { childrenTree } = parseSummaryTreeForSubtrees(\n\t\t\t\t\t\t\tparentInitialSummary.summary.summary,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tchildrenTree.type === SummaryType.Tree,\n\t\t\t\t\t\t\t0x1d6 /* \"Parent summary object is not a tree\" */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tchildSummary = childrenTree.tree[id];\n\t\t\t\t\t}\n\t\t\t\t\tif (createParam.type === CreateSummarizerNodeSource.FromSummary) {\n\t\t\t\t\t\t// Locally created would not have differential subtree.\n\t\t\t\t\t\tassert(!!childSummary, 0x1ad /* \"Missing child summary tree\" */);\n\t\t\t\t\t}\n\t\t\t\t\tlet childSummaryWithStats: ISummaryTreeWithStats | undefined;\n\t\t\t\t\tif (childSummary !== undefined) {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tchildSummary.type === SummaryType.Tree,\n\t\t\t\t\t\t\t0x1ae /* \"Child summary object is not a tree\" */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tchildSummaryWithStats = {\n\t\t\t\t\t\t\tsummary: childSummary,\n\t\t\t\t\t\t\tstats: calculateStats(childSummary),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tinitialSummary = {\n\t\t\t\t\t\tsequenceNumber: parentInitialSummary.sequenceNumber,\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tsummary: childSummaryWithStats,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tlatestSummary = parentLatestSummary?.createForChild(id);\n\t\t\t\tchangeSequenceNumber = parentLatestSummary?.referenceSequenceNumber ?? -1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tconst type = (createParam as unknown as CreateChildSummarizerNodeParam).type;\n\t\t\t\tunreachableCase(createParam, `Unexpected CreateSummarizerNodeSource: ${type}`);\n\t\t\t}\n\t\t}\n\n\t\tconst childtelemetryNodeId = `${this.telemetryNodeId ?? \"\"}/${id}`;\n\n\t\treturn {\n\t\t\tinitialSummary,\n\t\t\tlatestSummary,\n\t\t\tchangeSequenceNumber,\n\t\t\ttelemetryNodeId: childtelemetryNodeId,\n\t\t};\n\t}\n\n\t/**\n\t * Updates the state of the child if required. For example, if a summary is currently being tracked, the child's\n\t * summary tracking state needs to be updated too.\n\t * Also, in case a child node gets realized in between Summary Op and Summary Ack, let's initialize the child's\n\t * pending summary as well.\n\t * @param child - The child node whose state is to be updated.\n\t * @param id - Initial id or path part of this node\n\t *\n\t */\n\tprotected maybeUpdateChildState(child: SummarizerNode, id: string) {\n\t\t// If a summary is in progress, this child was created after the summary started. So, we need to update the\n\t\t// child's summary state as well.\n\t\tif (this.isSummaryInProgress()) {\n\t\t\tchild.wipReferenceSequenceNumber = this.wipReferenceSequenceNumber;\n\t\t}\n\t\t// In case we have pending summaries on the parent, let's initialize it on the child.\n\t\tif (child._latestSummary !== undefined) {\n\t\t\tfor (const [key, value] of this.pendingSummaries.entries()) {\n\t\t\t\tconst newLatestSummaryNode = new SummaryNode({\n\t\t\t\t\treferenceSequenceNumber: value.referenceSequenceNumber,\n\t\t\t\t\tbasePath: child._latestSummary.basePath,\n\t\t\t\t\tlocalPath: child._latestSummary.localPath,\n\t\t\t\t});\n\n\t\t\t\tchild.addPendingSummary(key, newLatestSummaryNode);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected addPendingSummary(key: string, summary: SummaryNode) {\n\t\tthis.pendingSummaries.set(key, summary);\n\t}\n\n\t/**\n\t * Tells whether summary tracking is in progress. True if \"startSummary\" API is called before summarize.\n\t */\n\tpublic isSummaryInProgress(): boolean {\n\t\treturn this.wipReferenceSequenceNumber !== undefined;\n\t}\n\n\t/**\n\t * Creates and throws an error due to unexpected conditions.\n\t */\n\tprotected throwUnexpectedError(eventProps: ITelemetryErrorEvent): never {\n\t\tconst error = new LoggingError(eventProps.eventName, {\n\t\t\t...eventProps,\n\t\t\treferenceSequenceNumber: this.wipReferenceSequenceNumber,\n\t\t\t...tagCodeArtifacts({\n\t\t\t\tid: this.telemetryNodeId,\n\t\t\t}),\n\t\t});\n\t\tthis.logger.sendErrorEvent(eventProps, error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Creates a root summarizer node.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n */\nexport const createRootSummarizerNode = (\n\tlogger: ITelemetryLoggerExt,\n\tsummarizeInternalFn: SummarizeInternalFn,\n\tchangeSequenceNumber: number,\n\treferenceSequenceNumber: number | undefined,\n\tconfig: ISummarizerNodeConfig = {},\n): IRootSummarizerNode =>\n\tnew SummarizerNode(\n\t\tlogger,\n\t\tsummarizeInternalFn,\n\t\tconfig,\n\t\tchangeSequenceNumber,\n\t\treferenceSequenceNumber === undefined\n\t\t\t? undefined\n\t\t\t: SummaryNode.createForRoot(referenceSequenceNumber),\n\t\tundefined /* initialSummary */,\n\t\tundefined /* wipSummaryLogger */,\n\t\t\"\" /* telemetryNodeId */,\n\t);\n"]}
1
+ {"version":3,"file":"summarizerNode.js","sourceRoot":"","sources":["../../../src/summary/summarizerNode/summarizerNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAMN,0BAA0B,GAI1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAEN,WAAW,GAGX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAEN,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACN,oBAAoB,EACpB,cAAc,EACd,UAAU,GAEV,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,WAAW,EAKX,uBAAuB,EACvB,2BAA2B,EAE3B,WAAW,GAEX,MAAM,uBAAuB,CAAC;AAI/B;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAc;IAiB1B;;;OAGG;IACH,YACC,UAAgC,EACf,mBAAwC,EACzD,MAA6B,EACrB,qBAA6B;IACrC,8CAA8C;IACtC,cAA4B,EACnB,cAAgC,EACvC,gBAAuC;IACjD,oEAAoE;IAC1D,eAAwB;QARjB,wBAAmB,GAAnB,mBAAmB,CAAqB;QAEjD,0BAAqB,GAArB,qBAAqB,CAAQ;QAE7B,mBAAc,GAAd,cAAc,CAAc;QACnB,mBAAc,GAAd,cAAc,CAAkB;QACvC,qBAAgB,GAAhB,gBAAgB,CAAuB;QAEvC,oBAAe,GAAf,eAAe,CAAS;QAtBhB,aAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;QAC7C,qBAAgB,GAAG,IAAI,GAAG,EAAuB,CAAC;QAG7D,qBAAgB,GAAG,KAAK,CAAC;QAoBhC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc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AwB,GAAG,CACvC,MAA2B,EAC3B,mBAAwC,EACxC,oBAA4B,EAC5B,uBAA2C,EAC3C,SAAgC,EAAE,EACZ,EAAE,CACxB,IAAI,cAAc,CACjB,MAAM,EACN,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACpB,uBAAuB,KAAK,SAAS;IACpC,CAAC,CAAC,SAAS;IACX,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,uBAAuB,CAAC,EACrD,SAAS,CAAC,oBAAoB,EAC9B,SAAS,CAAC,sBAAsB,EAChC,EAAE,CAAC,qBAAqB,CACxB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger, ITelemetryErrorEvent } from \"@fluidframework/core-interfaces\";\nimport {\n\tISummarizerNode,\n\tISummarizerNodeConfig,\n\tISummarizeResult,\n\tISummaryTreeWithStats,\n\tCreateChildSummarizerNodeParam,\n\tCreateSummarizerNodeSource,\n\tSummarizeInternalFn,\n\tITelemetryContext,\n\tIExperimentalIncrementalSummaryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n\tISequencedDocumentMessage,\n\tSummaryType,\n\tISnapshotTree,\n\tSummaryObject,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tITelemetryLoggerExt,\n\tcreateChildLogger,\n\tLoggingError,\n\tPerformanceEvent,\n\tTelemetryDataTag,\n\ttagCodeArtifacts,\n} from \"@fluidframework/telemetry-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/common-utils\";\nimport {\n\tconvertToSummaryTree,\n\tcalculateStats,\n\tmergeStats,\n\tReadAndParseBlob,\n} from \"@fluidframework/runtime-utils\";\nimport {\n\tEscapedPath,\n\tICreateChildDetails,\n\tIFetchSnapshotResult,\n\tIInitialSummary,\n\tISummarizerNodeRootContract,\n\tparseSummaryForSubtrees,\n\tparseSummaryTreeForSubtrees,\n\tRefreshSummaryResult,\n\tSummaryNode,\n\tValidateSummaryResult,\n} from \"./summarizerNodeUtils\";\n\nexport interface IRootSummarizerNode extends ISummarizerNode, ISummarizerNodeRootContract {}\n\n/**\n * Encapsulates the summarizing work and state of an individual tree node in the\n * summary tree. It tracks changes and allows for optimizations when unchanged, or\n * can allow for fallback summaries to be generated when an error is encountered.\n * Usage is for the root node to call startSummary first to begin tracking a WIP\n * (work in progress) summary. Then all nodes will call summarize to summaries their\n * individual parts. Once completed and uploaded to storage, the root node will call\n * completeSummary or clearSummary to clear the WIP summary tracking state if something\n * went wrong. The SummarizerNodes will track all pending summaries that have been\n * recorded by the completeSummary call. When one of them is acked, the root node should\n * call refreshLatestSummary to inform the tree of SummarizerNodes of the new baseline\n * latest successful summary.\n */\nexport class SummarizerNode implements IRootSummarizerNode {\n\t/**\n\t * The reference sequence number of the most recent acked summary.\n\t * Returns 0 if there is not yet an acked summary.\n\t */\n\tpublic get referenceSequenceNumber() {\n\t\treturn this._latestSummary?.referenceSequenceNumber ?? 0;\n\t}\n\n\tprotected readonly children = new Map<string, SummarizerNode>();\n\tprotected readonly pendingSummaries = new Map<string, SummaryNode>();\n\tprotected wipReferenceSequenceNumber: number | undefined;\n\tprivate wipLocalPaths: { localPath: EscapedPath; additionalPath?: EscapedPath } | undefined;\n\tprivate wipSkipRecursion = false;\n\n\tprotected readonly logger: ITelemetryLoggerExt;\n\n\t/**\n\t * Do not call constructor directly.\n\t * Use createRootSummarizerNode to create root node, or createChild to create child nodes.\n\t */\n\tpublic constructor(\n\t\tbaseLogger: ITelemetryBaseLogger,\n\t\tprivate readonly summarizeInternalFn: SummarizeInternalFn,\n\t\tconfig: ISummarizerNodeConfig,\n\t\tprivate _changeSequenceNumber: number,\n\t\t/** Undefined means created without summary */\n\t\tprivate _latestSummary?: SummaryNode,\n\t\tprivate readonly initialSummary?: IInitialSummary,\n\t\tprotected wipSummaryLogger?: ITelemetryBaseLogger,\n\t\t/** A unique id of this node to be logged when sending telemetry. */\n\t\tprotected telemetryNodeId?: string,\n\t) {\n\t\tthis.canReuseHandle = config.canReuseHandle ?? true;\n\t\t// All logs posted by the summarizer node should include the telemetryNodeId.\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: baseLogger,\n\t\t\tproperties: {\n\t\t\t\tall: tagCodeArtifacts({ id: this.telemetryNodeId }),\n\t\t\t},\n\t\t});\n\t}\n\n\tpublic startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryBaseLogger) {\n\t\tassert(\n\t\t\tthis.wipSummaryLogger === undefined,\n\t\t\t0x19f /* \"wipSummaryLogger should not be set yet in startSummary\" */,\n\t\t);\n\t\tassert(\n\t\t\tthis.wipReferenceSequenceNumber === undefined,\n\t\t\t0x1a0 /* \"Already tracking a summary\" */,\n\t\t);\n\n\t\tthis.wipSummaryLogger = summaryLogger;\n\n\t\tfor (const child of this.children.values()) {\n\t\t\tchild.startSummary(referenceSequenceNumber, this.wipSummaryLogger);\n\t\t}\n\t\tthis.wipReferenceSequenceNumber = referenceSequenceNumber;\n\t}\n\n\tpublic async summarize(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean = true,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\tassert(\n\t\t\tthis.isSummaryInProgress(),\n\t\t\t0x1a1 /* \"summarize should not be called when not tracking the summary\" */,\n\t\t);\n\t\tassert(\n\t\t\tthis.wipSummaryLogger !== undefined,\n\t\t\t0x1a2 /* \"wipSummaryLogger should have been set in startSummary or ctor\" */,\n\t\t);\n\n\t\t// Try to reuse the tree if unchanged\n\t\tif (this.canReuseHandle && !fullTree && !this.hasChanged()) {\n\t\t\tconst latestSummary = this._latestSummary;\n\t\t\tif (latestSummary !== undefined) {\n\t\t\t\tthis.wipLocalPaths = {\n\t\t\t\t\tlocalPath: latestSummary.localPath,\n\t\t\t\t\tadditionalPath: latestSummary.additionalPath,\n\t\t\t\t};\n\t\t\t\tthis.wipSkipRecursion = true;\n\t\t\t\tconst stats = mergeStats();\n\t\t\t\tstats.handleNodeCount++;\n\t\t\t\treturn {\n\t\t\t\t\tsummary: {\n\t\t\t\t\t\ttype: SummaryType.Handle,\n\t\t\t\t\t\thandle: latestSummary.fullPath.path,\n\t\t\t\t\t\thandleType: SummaryType.Tree,\n\t\t\t\t\t},\n\t\t\t\t\tstats,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// This assert is the same the other 0a1x1 assert `isSummaryInProgress`, the only difference is that typescript\n\t\t// complains if this assert isn't done this way\n\t\tassert(\n\t\t\tthis.wipReferenceSequenceNumber !== undefined,\n\t\t\t0x5df /* Summarize should not be called when not tracking the summary */,\n\t\t);\n\t\tconst incrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined =\n\t\t\tthis._latestSummary !== undefined\n\t\t\t\t? {\n\t\t\t\t\t\tsummarySequenceNumber: this.wipReferenceSequenceNumber,\n\t\t\t\t\t\tlatestSummarySequenceNumber: this._latestSummary.referenceSequenceNumber,\n\t\t\t\t\t\t// TODO: remove summaryPath\n\t\t\t\t\t\tsummaryPath: this._latestSummary.fullPath.path,\n\t\t\t\t }\n\t\t\t\t: undefined;\n\n\t\tconst result = await this.summarizeInternalFn(\n\t\t\tfullTree,\n\t\t\ttrue,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t);\n\t\tthis.wipLocalPaths = { localPath: EscapedPath.create(result.id) };\n\t\tif (result.pathPartsForChildren !== undefined) {\n\t\t\tthis.wipLocalPaths.additionalPath = EscapedPath.createAndConcat(\n\t\t\t\tresult.pathPartsForChildren,\n\t\t\t);\n\t\t}\n\t\treturn { summary: result.summary, stats: result.stats };\n\t}\n\n\t/**\n\t * Validates that the in-progress summary is correct, i.e., summarize should have run for all non-skipped\n\t * nodes. This will only be called for the root summarizer node and is called by it recursively on all child nodes.\n\t *\n\t * @returns ValidateSummaryResult which contains a boolean success indicating whether the validation was successful.\n\t * In case of failure, additional information is returned indicating type of failure and where it was.\n\t */\n\tpublic validateSummary(): ValidateSummaryResult {\n\t\treturn this.validateSummaryCore(false /* parentSkipRecursion */);\n\t}\n\n\t/**\n\t * Validates that the in-progress summary is correct for all nodes, i.e., summarize should have run for all\n\t * non-skipped nodes.\n\t * @param parentSkipRecursion - true if the parent of this node skipped recursing the child nodes when summarizing.\n\t * In that case, the children will not have work-in-progress state.\n\t *\n\t * @returns ValidateSummaryResult which contains a boolean success indicating whether the validation was successful.\n\t * In case of failure, additional information is returned indicating type of failure and where it was.\n\t */\n\tprotected validateSummaryCore(parentSkipRecursion: boolean): ValidateSummaryResult {\n\t\tif (this.wasSummarizeMissed(parentSkipRecursion)) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\treason: \"NodeDidNotSummarize\",\n\t\t\t\tid: {\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t\tvalue: this.telemetryNodeId,\n\t\t\t\t},\n\t\t\t\t// These errors are usually transient and should go away when summarize is retried.\n\t\t\t\tretryAfterSeconds: 1,\n\t\t\t};\n\t\t}\n\t\tif (parentSkipRecursion) {\n\t\t\treturn { success: true };\n\t\t}\n\n\t\tfor (const child of this.children.values()) {\n\t\t\tconst result = child.validateSummaryCore(this.wipSkipRecursion || parentSkipRecursion);\n\t\t\t// If any child fails, return the failure.\n\t\t\tif (!result.success) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t\treturn { success: true };\n\t}\n\n\tprivate wasSummarizeMissed(parentSkipRecursion: boolean): boolean {\n\t\tassert(\n\t\t\tthis.wipSummaryLogger !== undefined,\n\t\t\t0x6fc /* wipSummaryLogger should have been set in startSummary or ctor */,\n\t\t);\n\t\tassert(this.wipReferenceSequenceNumber !== undefined, 0x6fd /* Not tracking a summary */);\n\n\t\t// If the parent node skipped recursion, it did not call summarize on this node. So, summarize was not missed\n\t\t// but was intentionally not called.\n\t\t// Otherwise, summarize should have been called on this node and wipLocalPaths must be set.\n\t\tif (parentSkipRecursion || this.wipLocalPaths !== undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\t/**\n\t\t * The absence of wip local path indicates that summarize was not called for this node. Return failure.\n\t\t * This can happen if:\n\t\t * 1. A child node was created after summarize was already called on the parent. For example, a data store\n\t\t * is realized (loaded) after summarize was called on it creating summarizer nodes for its DDSes. In this case,\n\t\t * parentSkipRecursion will be true and the if block above would handle it.\n\t\t * 2. A new node was created but summarize was never called on it. This can mean that the summary that is\n\t\t * generated may not have the data from this node. We should not continue, log and throw an error. This\n\t\t * will help us identify these cases and take appropriate action.\n\t\t *\n\t\t * This happens due to scenarios such as data store created during summarize. Such errors should go away when\n\t\t * summarize is attempted again.\n\t\t */\n\t\treturn true;\n\t}\n\n\t/**\n\t * Called after summary has been uploaded to the server. Add the work-in-progress state to the pending summary\n\t * queue. We track this until we get an ack from the server for this summary.\n\t * @param proposalHandle - The handle of the summary that was uploaded to the server.\n\t */\n\tpublic completeSummary(proposalHandle: string, validate: boolean) {\n\t\tthis.completeSummaryCore(\n\t\t\tproposalHandle,\n\t\t\tundefined /* parentPath */,\n\t\t\tfalse /* parentSkipRecursion */,\n\t\t\tvalidate,\n\t\t);\n\t}\n\n\t/**\n\t * Recursive implementation for completeSummary, with additional internal-only parameters.\n\t * @param proposalHandle - The handle of the summary that was uploaded to the server.\n\t * @param parentPath - The path of the parent node which is used to build the path of this node.\n\t * @param parentSkipRecursion - true if the parent of this node skipped recursing the child nodes when summarizing.\n\t * In that case, the children will not have work-in-progress state.\n\t * @param validate - true to validate that the in-progress summary is correct for all nodes.\n\t */\n\tprotected completeSummaryCore(\n\t\tproposalHandle: string,\n\t\tparentPath: EscapedPath | undefined,\n\t\tparentSkipRecursion: boolean,\n\t\tvalidate: boolean,\n\t) {\n\t\tif (validate && this.wasSummarizeMissed(parentSkipRecursion)) {\n\t\t\tthis.throwUnexpectedError({\n\t\t\t\teventName: \"NodeDidNotSummarize\",\n\t\t\t\tproposalHandle,\n\t\t\t});\n\t\t}\n\n\t\tassert(this.wipReferenceSequenceNumber !== undefined, 0x1a4 /* \"Not tracking a summary\" */);\n\t\tlet localPathsToUse = this.wipLocalPaths;\n\n\t\tif (parentSkipRecursion) {\n\t\t\tconst latestSummary = this._latestSummary;\n\t\t\tif (latestSummary !== undefined) {\n\t\t\t\t// This case the parent node created a failure summary or was reused.\n\t\t\t\t// This node and all children should only try to reference their path\n\t\t\t\t// by its last known good state in the actual summary tree.\n\t\t\t\t// If parent fails or is reused, the child summarize is not called so\n\t\t\t\t// it did not get a chance to change its paths.\n\t\t\t\t// In this case, essentially only propagate the new summary ref seq num.\n\t\t\t\tlocalPathsToUse = {\n\t\t\t\t\tlocalPath: latestSummary.localPath,\n\t\t\t\t\tadditionalPath: latestSummary.additionalPath,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\t// This case the child is added after the latest non-failure summary.\n\t\t\t\t// This node and all children should consider themselves as still not\n\t\t\t\t// having a successful summary yet.\n\t\t\t\t// We cannot \"reuse\" this node if unchanged since that summary, because\n\t\t\t\t// handles will be unable to point to that node. It never made it to the\n\t\t\t\t// tree itself, and only exists as an attach op in the _outstandingOps.\n\t\t\t\tthis.clearSummary();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// If localPathsToUse is undefined, it means summarize didn't run for this node and in that case the validate\n\t\t// step should have failed.\n\t\tassert(localPathsToUse !== undefined, 0x6fe /* summarize didn't run for node */);\n\t\tconst summary = new SummaryNode({\n\t\t\t...localPathsToUse,\n\t\t\treferenceSequenceNumber: this.wipReferenceSequenceNumber,\n\t\t\tbasePath: parentPath,\n\t\t});\n\t\tconst fullPathForChildren = summary.fullPathForChildren;\n\t\tfor (const child of this.children.values()) {\n\t\t\tchild.completeSummaryCore(\n\t\t\t\tproposalHandle,\n\t\t\t\tfullPathForChildren,\n\t\t\t\tthis.wipSkipRecursion || parentSkipRecursion,\n\t\t\t\tvalidate,\n\t\t\t);\n\t\t}\n\t\t// Note that this overwrites existing pending summary with\n\t\t// the same proposalHandle. If proposalHandle is something like\n\t\t// a hash or unique identifier, this should be fine. If storage\n\t\t// can return the same proposalHandle for a different summary,\n\t\t// this should still be okay, because we should be proposing the\n\t\t// newer one later which would have to overwrite the previous one.\n\t\tthis.pendingSummaries.set(proposalHandle, summary);\n\t\tthis.clearSummary();\n\t}\n\n\tpublic clearSummary() {\n\t\tthis.wipReferenceSequenceNumber = undefined;\n\t\tthis.wipLocalPaths = undefined;\n\t\tthis.wipSkipRecursion = false;\n\t\tthis.wipSummaryLogger = undefined;\n\t\tfor (const child of this.children.values()) {\n\t\t\tchild.clearSummary();\n\t\t}\n\t}\n\n\t/**\n\t * Refreshes the latest summary tracked by this node. If we have a pending summary for the given proposal handle,\n\t * it becomes the latest summary. If the current summary is already ahead (e.g., loaded from a service summary),\n\t * we skip the update. Otherwise, we fetch the latest snapshot and update latest summary based off of that.\n\t *\n\t * @returns A RefreshSummaryResult type which returns information based on the following three scenarios:\n\t *\n\t * 1. The latest summary was not updated.\n\t *\n\t * 2. The latest summary was updated and the summary corresponding to the params was being tracked.\n\t *\n\t * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this\n\t * case, the latest summary is updated based on the downloaded snapshot which is also returned.\n\t */\n\tpublic async refreshLatestSummary(\n\t\tproposalHandle: string | undefined,\n\t\tsummaryRefSeq: number,\n\t\tfetchLatestSnapshot: () => Promise<IFetchSnapshotResult>,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t\tcorrelatedSummaryLogger: ITelemetryLoggerExt,\n\t): Promise<RefreshSummaryResult> {\n\t\tconst eventProps: {\n\t\t\tproposalHandle: string | undefined;\n\t\t\tsummaryRefSeq: number;\n\t\t\treferenceSequenceNumber: number;\n\t\t\tlatestSummaryUpdated?: boolean;\n\t\t\twasSummaryTracked?: boolean;\n\t\t} = {\n\t\t\tproposalHandle,\n\t\t\tsummaryRefSeq,\n\t\t\treferenceSequenceNumber: this.referenceSequenceNumber,\n\t\t};\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"refreshLatestSummary\",\n\t\t\t\t...eventProps,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\t// Refresh latest summary should not happen while a summary is in progress. If it does, it can result\n\t\t\t\t// in inconsistent state, so, we should not continue;\n\t\t\t\tif (this.isSummaryInProgress()) {\n\t\t\t\t\tthrow new LoggingError(\"UnexpectedRefreshDuringSummarize\", {\n\t\t\t\t\t\tinProgressSummaryRefSeq: this.wipReferenceSequenceNumber,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (proposalHandle !== undefined) {\n\t\t\t\t\tconst maybeSummaryNode = this.pendingSummaries.get(proposalHandle);\n\n\t\t\t\t\tif (maybeSummaryNode !== undefined) {\n\t\t\t\t\t\tthis.refreshLatestSummaryFromPending(\n\t\t\t\t\t\t\tproposalHandle,\n\t\t\t\t\t\t\tmaybeSummaryNode.referenceSequenceNumber,\n\t\t\t\t\t\t);\n\t\t\t\t\t\teventProps.wasSummaryTracked = true;\n\t\t\t\t\t\teventProps.latestSummaryUpdated = true;\n\t\t\t\t\t\tevent.end(eventProps);\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tlatestSummaryUpdated: true,\n\t\t\t\t\t\t\twasSummaryTracked: true,\n\t\t\t\t\t\t\tsummaryRefSeq,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst props = {\n\t\t\t\t\t\tsummaryRefSeq,\n\t\t\t\t\t\tpendingSize: this.pendingSummaries.size ?? undefined,\n\t\t\t\t\t};\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"PendingSummaryNotFound\",\n\t\t\t\t\t\tproposalHandle,\n\t\t\t\t\t\treferenceSequenceNumber: this.referenceSequenceNumber,\n\t\t\t\t\t\tdetails: JSON.stringify(props),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// If the summary for which refresh is called is older than the latest tracked summary, ignore it.\n\t\t\t\tif (this.referenceSequenceNumber >= summaryRefSeq) {\n\t\t\t\t\teventProps.latestSummaryUpdated = false;\n\t\t\t\t\tevent.end(eventProps);\n\t\t\t\t\treturn { latestSummaryUpdated: false };\n\t\t\t\t}\n\n\t\t\t\t// Fetch the latest snapshot and refresh state from it. Note that we need to use the reference sequence number\n\t\t\t\t// of the fetched snapshot and not the \"summaryRefSeq\" that was passed in.\n\t\t\t\tconst { snapshotTree, snapshotRefSeq: fetchedSnapshotRefSeq } =\n\t\t\t\t\tawait fetchLatestSnapshot();\n\n\t\t\t\t// Possible re-entrancy. We may have updated latest summary state while fetching the snapshot. If the fetched\n\t\t\t\t// snapshot is older than the latest tracked summary, ignore it.\n\t\t\t\tif (this.referenceSequenceNumber >= fetchedSnapshotRefSeq) {\n\t\t\t\t\teventProps.latestSummaryUpdated = false;\n\t\t\t\t\tevent.end(eventProps);\n\t\t\t\t\treturn { latestSummaryUpdated: false };\n\t\t\t\t}\n\n\t\t\t\tawait this.refreshLatestSummaryFromSnapshot(\n\t\t\t\t\tfetchedSnapshotRefSeq,\n\t\t\t\t\tsnapshotTree,\n\t\t\t\t\tundefined,\n\t\t\t\t\tEscapedPath.create(\"\"),\n\t\t\t\t\tcorrelatedSummaryLogger,\n\t\t\t\t\treadAndParseBlob,\n\t\t\t\t);\n\n\t\t\t\teventProps.latestSummaryUpdated = true;\n\t\t\t\teventProps.wasSummaryTracked = false;\n\t\t\t\teventProps.summaryRefSeq = fetchedSnapshotRefSeq;\n\t\t\t\tevent.end(eventProps);\n\t\t\t\treturn {\n\t\t\t\t\tlatestSummaryUpdated: true,\n\t\t\t\t\twasSummaryTracked: false,\n\t\t\t\t\tsnapshotTree,\n\t\t\t\t\tsummaryRefSeq: fetchedSnapshotRefSeq,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ start: true, end: true, cancel: \"error\" },\n\t\t);\n\t}\n\t/**\n\t * Called when we get an ack from the server for a summary we've just sent. Updates the reference state of this node\n\t * from the state in the pending summary queue.\n\t * @param proposalHandle - Handle for the current proposal.\n\t * @param referenceSequenceNumber - reference sequence number of sent summary.\n\t */\n\tprotected refreshLatestSummaryFromPending(\n\t\tproposalHandle: string,\n\t\treferenceSequenceNumber: number,\n\t): void {\n\t\tconst summaryNode = this.pendingSummaries.get(proposalHandle);\n\t\tif (summaryNode === undefined) {\n\t\t\t// This should only happen if parent skipped recursion AND no prior summary existed.\n\t\t\tassert(\n\t\t\t\tthis._latestSummary === undefined,\n\t\t\t\t0x1a6 /* \"Not found pending summary, but this node has previously completed a summary\" */,\n\t\t\t);\n\t\t\treturn;\n\t\t} else {\n\t\t\tassert(\n\t\t\t\treferenceSequenceNumber === summaryNode.referenceSequenceNumber,\n\t\t\t\t0x1a7 /* Pending summary reference sequence number should be consistent */,\n\t\t\t);\n\n\t\t\t// Clear earlier pending summaries\n\t\t\tthis.pendingSummaries.delete(proposalHandle);\n\t\t}\n\n\t\tthis.refreshLatestSummaryCore(referenceSequenceNumber);\n\n\t\tthis._latestSummary = summaryNode;\n\t\t// Propagate update to all child nodes\n\t\tfor (const child of this.children.values()) {\n\t\t\tchild.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n\t\t}\n\t}\n\n\tprotected async refreshLatestSummaryFromSnapshot(\n\t\treferenceSequenceNumber: number,\n\t\tsnapshotTree: ISnapshotTree,\n\t\tbasePath: EscapedPath | undefined,\n\t\tlocalPath: EscapedPath,\n\t\tcorrelatedSummaryLogger: ITelemetryLoggerExt,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t): Promise<void> {\n\t\t// Possible re-entrancy. If we have already seen a summary later than this one, ignore it.\n\t\tif (this.referenceSequenceNumber >= referenceSequenceNumber) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.refreshLatestSummaryCore(referenceSequenceNumber);\n\n\t\tthis._latestSummary = new SummaryNode({\n\t\t\treferenceSequenceNumber,\n\t\t\tbasePath,\n\t\t\tlocalPath,\n\t\t});\n\n\t\tconst pathParts: string[] = [];\n\t\tconst { childrenTree, childrenPathPart } = parseSummaryForSubtrees(snapshotTree);\n\t\tif (childrenPathPart !== undefined) {\n\t\t\tpathParts.push(childrenPathPart);\n\t\t}\n\n\t\tif (pathParts.length > 0) {\n\t\t\tthis._latestSummary.additionalPath = EscapedPath.createAndConcat(pathParts);\n\t\t}\n\n\t\t// Propagate update to all child nodes\n\t\tconst pathForChildren = this._latestSummary.fullPathForChildren;\n\t\tawait Promise.all(\n\t\t\tArray.from(this.children)\n\t\t\t\t.filter(([id]) => {\n\t\t\t\t\t// Assuming subtrees missing from snapshot are newer than the snapshot,\n\t\t\t\t\t// but might be nice to assert this using earliest seq for node.\n\t\t\t\t\treturn childrenTree.trees[id] !== undefined;\n\t\t\t\t})\n\t\t\t\t.map(async ([id, child]) => {\n\t\t\t\t\treturn child.refreshLatestSummaryFromSnapshot(\n\t\t\t\t\t\treferenceSequenceNumber,\n\t\t\t\t\t\tchildrenTree.trees[id],\n\t\t\t\t\t\tpathForChildren,\n\t\t\t\t\t\tEscapedPath.create(id),\n\t\t\t\t\t\tcorrelatedSummaryLogger,\n\t\t\t\t\t\treadAndParseBlob,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t);\n\t}\n\n\tprivate refreshLatestSummaryCore(referenceSequenceNumber: number): void {\n\t\tfor (const [key, value] of this.pendingSummaries) {\n\t\t\tif (value.referenceSequenceNumber < referenceSequenceNumber) {\n\t\t\t\tthis.pendingSummaries.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic updateBaseSummaryState(snapshot: ISnapshotTree) {\n\t\t// Check base summary to see if it has any additional path parts\n\t\t// separating child SummarizerNodes. Checks for .channels subtrees.\n\t\tconst { childrenPathPart } = parseSummaryForSubtrees(snapshot);\n\t\tif (childrenPathPart !== undefined && this._latestSummary !== undefined) {\n\t\t\tthis._latestSummary.additionalPath = EscapedPath.create(childrenPathPart);\n\t\t}\n\t}\n\n\tpublic recordChange(op: ISequencedDocumentMessage): void {\n\t\tthis.invalidate(op.sequenceNumber);\n\t}\n\n\tpublic invalidate(sequenceNumber: number): void {\n\t\tif (sequenceNumber > this._changeSequenceNumber) {\n\t\t\tthis._changeSequenceNumber = sequenceNumber;\n\t\t}\n\t}\n\n\t/**\n\t * True if a change has been recorded with sequence number exceeding\n\t * the latest successfully acked summary reference sequence number.\n\t * False implies that the previous summary can be reused.\n\t */\n\tprotected hasChanged(): boolean {\n\t\treturn this._changeSequenceNumber > this.referenceSequenceNumber;\n\t}\n\n\tpublic get latestSummary(): Readonly<SummaryNode> | undefined {\n\t\treturn this._latestSummary;\n\t}\n\n\tprotected readonly canReuseHandle: boolean;\n\n\tpublic createChild(\n\t\t/** Summarize function */\n\t\tsummarizeInternalFn: SummarizeInternalFn,\n\t\t/** Initial id or path part of this node */\n\t\tid: string,\n\t\t/**\n\t\t * Information needed to create the node.\n\t\t * If it is from a base summary, it will assert that a summary has been seen.\n\t\t * Attach information if it is created from an attach op.\n\t\t */\n\t\tcreateParam: CreateChildSummarizerNodeParam,\n\t\tconfig: ISummarizerNodeConfig = {},\n\t): ISummarizerNode {\n\t\tassert(!this.children.has(id), 0x1ab /* \"Create SummarizerNode child already exists\" */);\n\n\t\tconst createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n\t\tconst child = new SummarizerNode(\n\t\t\tthis.logger,\n\t\t\tsummarizeInternalFn,\n\t\t\tconfig,\n\t\t\tcreateDetails.changeSequenceNumber,\n\t\t\tcreateDetails.latestSummary,\n\t\t\tcreateDetails.initialSummary,\n\t\t\tthis.wipSummaryLogger,\n\t\t\tcreateDetails.telemetryNodeId,\n\t\t);\n\n\t\t// There may be additional state that has to be updated in this child. For example, if a summary is being\n\t\t// tracked, the child's summary tracking state needs to be updated too. Same goes for pendingSummaries we might\n\t\t// have outstanding on the parent in case we realize nodes in between Summary Op and Summary Ack.\n\t\tthis.maybeUpdateChildState(child, id);\n\n\t\tthis.children.set(id, child);\n\t\treturn child;\n\t}\n\n\tpublic getChild(id: string): ISummarizerNode | undefined {\n\t\treturn this.children.get(id);\n\t}\n\n\t/**\n\t * Returns the details needed to create a child node.\n\t * @param id - Initial id or path part of the child node.\n\t * @param createParam - Information needed to create the node.\n\t * @returns the details needed to create the child node.\n\t */\n\tprotected getCreateDetailsForChild(\n\t\tid: string,\n\t\tcreateParam: CreateChildSummarizerNodeParam,\n\t): ICreateChildDetails {\n\t\tlet initialSummary: IInitialSummary | undefined;\n\t\tlet latestSummary: SummaryNode | undefined;\n\t\tlet changeSequenceNumber: number;\n\n\t\tconst parentLatestSummary = this._latestSummary;\n\t\tswitch (createParam.type) {\n\t\t\tcase CreateSummarizerNodeSource.FromAttach: {\n\t\t\t\tif (\n\t\t\t\t\tparentLatestSummary !== undefined &&\n\t\t\t\t\tcreateParam.sequenceNumber <= parentLatestSummary.referenceSequenceNumber\n\t\t\t\t) {\n\t\t\t\t\t// Prioritize latest summary if it was after this node was attached.\n\t\t\t\t\tlatestSummary = parentLatestSummary.createForChild(id);\n\t\t\t\t} else {\n\t\t\t\t\tconst summary = convertToSummaryTree(\n\t\t\t\t\t\tcreateParam.snapshot,\n\t\t\t\t\t) as ISummaryTreeWithStats;\n\t\t\t\t\tinitialSummary = {\n\t\t\t\t\t\tsequenceNumber: createParam.sequenceNumber,\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tsummary,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tchangeSequenceNumber = createParam.sequenceNumber;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CreateSummarizerNodeSource.FromSummary: {\n\t\t\t\tif (this.initialSummary === undefined) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!!parentLatestSummary,\n\t\t\t\t\t\t0x1ac /* \"Cannot create child from summary if parent does not have latest summary\" */,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// fallthrough to local\n\t\t\t}\n\t\t\tcase CreateSummarizerNodeSource.Local: {\n\t\t\t\tconst parentInitialSummary = this.initialSummary;\n\t\t\t\tif (parentInitialSummary !== undefined) {\n\t\t\t\t\tlet childSummary: SummaryObject | undefined;\n\t\t\t\t\tif (parentInitialSummary.summary !== undefined) {\n\t\t\t\t\t\tconst { childrenTree } = parseSummaryTreeForSubtrees(\n\t\t\t\t\t\t\tparentInitialSummary.summary.summary,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tchildrenTree.type === SummaryType.Tree,\n\t\t\t\t\t\t\t0x1d6 /* \"Parent summary object is not a tree\" */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tchildSummary = childrenTree.tree[id];\n\t\t\t\t\t}\n\t\t\t\t\tif (createParam.type === CreateSummarizerNodeSource.FromSummary) {\n\t\t\t\t\t\t// Locally created would not have differential subtree.\n\t\t\t\t\t\tassert(!!childSummary, 0x1ad /* \"Missing child summary tree\" */);\n\t\t\t\t\t}\n\t\t\t\t\tlet childSummaryWithStats: ISummaryTreeWithStats | undefined;\n\t\t\t\t\tif (childSummary !== undefined) {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tchildSummary.type === SummaryType.Tree,\n\t\t\t\t\t\t\t0x1ae /* \"Child summary object is not a tree\" */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tchildSummaryWithStats = {\n\t\t\t\t\t\t\tsummary: childSummary,\n\t\t\t\t\t\t\tstats: calculateStats(childSummary),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tinitialSummary = {\n\t\t\t\t\t\tsequenceNumber: parentInitialSummary.sequenceNumber,\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tsummary: childSummaryWithStats,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tlatestSummary = parentLatestSummary?.createForChild(id);\n\t\t\t\tchangeSequenceNumber = parentLatestSummary?.referenceSequenceNumber ?? -1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tconst type = (createParam as unknown as CreateChildSummarizerNodeParam).type;\n\t\t\t\tunreachableCase(createParam, `Unexpected CreateSummarizerNodeSource: ${type}`);\n\t\t\t}\n\t\t}\n\n\t\tconst childtelemetryNodeId = `${this.telemetryNodeId ?? \"\"}/${id}`;\n\n\t\treturn {\n\t\t\tinitialSummary,\n\t\t\tlatestSummary,\n\t\t\tchangeSequenceNumber,\n\t\t\ttelemetryNodeId: childtelemetryNodeId,\n\t\t};\n\t}\n\n\t/**\n\t * Updates the state of the child if required. For example, if a summary is currently being tracked, the child's\n\t * summary tracking state needs to be updated too.\n\t * Also, in case a child node gets realized in between Summary Op and Summary Ack, let's initialize the child's\n\t * pending summary as well.\n\t * @param child - The child node whose state is to be updated.\n\t * @param id - Initial id or path part of this node\n\t *\n\t */\n\tprotected maybeUpdateChildState(child: SummarizerNode, id: string) {\n\t\t// If a summary is in progress, this child was created after the summary started. So, we need to update the\n\t\t// child's summary state as well.\n\t\tif (this.isSummaryInProgress()) {\n\t\t\tchild.wipReferenceSequenceNumber = this.wipReferenceSequenceNumber;\n\t\t}\n\t\t// In case we have pending summaries on the parent, let's initialize it on the child.\n\t\tif (child._latestSummary !== undefined) {\n\t\t\tfor (const [key, value] of this.pendingSummaries.entries()) {\n\t\t\t\tconst newLatestSummaryNode = new SummaryNode({\n\t\t\t\t\treferenceSequenceNumber: value.referenceSequenceNumber,\n\t\t\t\t\tbasePath: child._latestSummary.basePath,\n\t\t\t\t\tlocalPath: child._latestSummary.localPath,\n\t\t\t\t});\n\n\t\t\t\tchild.addPendingSummary(key, newLatestSummaryNode);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected addPendingSummary(key: string, summary: SummaryNode) {\n\t\tthis.pendingSummaries.set(key, summary);\n\t}\n\n\t/**\n\t * Tells whether summary tracking is in progress. True if \"startSummary\" API is called before summarize.\n\t */\n\tpublic isSummaryInProgress(): boolean {\n\t\treturn this.wipReferenceSequenceNumber !== undefined;\n\t}\n\n\t/**\n\t * Creates and throws an error due to unexpected conditions.\n\t */\n\tprotected throwUnexpectedError(eventProps: ITelemetryErrorEvent): never {\n\t\tconst error = new LoggingError(eventProps.eventName, {\n\t\t\t...eventProps,\n\t\t\treferenceSequenceNumber: this.wipReferenceSequenceNumber,\n\t\t\t...tagCodeArtifacts({\n\t\t\t\tid: this.telemetryNodeId,\n\t\t\t}),\n\t\t});\n\t\tthis.logger.sendErrorEvent(eventProps, error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Creates a root summarizer node.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n */\nexport const createRootSummarizerNode = (\n\tlogger: ITelemetryLoggerExt,\n\tsummarizeInternalFn: SummarizeInternalFn,\n\tchangeSequenceNumber: number,\n\treferenceSequenceNumber: number | undefined,\n\tconfig: ISummarizerNodeConfig = {},\n): IRootSummarizerNode =>\n\tnew SummarizerNode(\n\t\tlogger,\n\t\tsummarizeInternalFn,\n\t\tconfig,\n\t\tchangeSequenceNumber,\n\t\treferenceSequenceNumber === undefined\n\t\t\t? undefined\n\t\t\t: SummaryNode.createForRoot(referenceSequenceNumber),\n\t\tundefined /* initialSummary */,\n\t\tundefined /* wipSummaryLogger */,\n\t\t\"\" /* telemetryNodeId */,\n\t);\n"]}
@@ -12,8 +12,7 @@ export class EscapedPath {
12
12
  return new EscapedPath(encodeURIComponent(path));
13
13
  }
14
14
  static createAndConcat(pathParts) {
15
- var _a;
16
- let ret = EscapedPath.create((_a = pathParts[0]) !== null && _a !== void 0 ? _a : "");
15
+ let ret = EscapedPath.create(pathParts[0] ?? "");
17
16
  for (let i = 1; i < pathParts.length; i++) {
18
17
  ret = ret.concat(EscapedPath.create(pathParts[i]));
19
18
  }
@@ -60,8 +59,7 @@ export class SummaryNode {
60
59
  }
61
60
  /** Gets the full path to this node, to be used when sending a handle */
62
61
  get fullPath() {
63
- var _a, _b;
64
- return (_b = (_a = this.basePath) === null || _a === void 0 ? void 0 : _a.concat(this.localPath)) !== null && _b !== void 0 ? _b : this.localPath;
62
+ return this.basePath?.concat(this.localPath) ?? this.localPath;
65
63
  }
66
64
  /**
67
65
  * Gets the full path to this node's innermost base summary.
@@ -1 +1 @@
1
- {"version":3,"file":"summarizerNodeUtils.js","sourceRoot":"","sources":["../../../src/summary/summarizerNode/summarizerNodeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,gBAAgB,EAAyB,MAAM,qCAAqC,CAAC;AAyE9F,+DAA+D;AAC/D,MAAM,OAAO,WAAW;IACvB,YAAoC,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAC7C,MAAM,CAAC,MAAM,CAAC,IAAY;QAChC,OAAO,IAAI,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;IACM,MAAM,CAAC,eAAe,CAAC,SAAmB;;QAChD,IAAI,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,MAAA,SAAS,CAAC,CAAC,CAAC,mCAAI,EAAE,CAAC,CAAC;QACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC1C,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACnD;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IACM,QAAQ;QACd,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACM,MAAM,CAAC,IAAiB;QAC9B,OAAO,IAAI,WAAW,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;CACD;AAED,0EAA0E;AAC1E,MAAM,OAAO,WAAW;IA6BvB,YACkB,OAKhB;QALgB,YAAO,GAAP,OAAO,CAKvB;IACC,CAAC;IAnCJ,0FAA0F;IACnF,MAAM,CAAC,aAAa,CAAC,uBAA+B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CAAC,CAAC;IACJ,CAAC;CACD;AAgCD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAA0B;IACjE,2EAA2E;IAC3E,MAAM,eAAe,GAAG,WAAW,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC5D,IAAI,eAAe,KAAK,SAAS,EAAE;QAClC,OAAO;YACN,YAAY,EAAE,eAAe;YAC7B,gBAAgB,EAAE,gBAAgB;SAClC,CAAC;KACF;IACD,OAAO;QACN,YAAY,EAAE,WAAW;QACzB,gBAAgB,EAAE,SAAS;KAC3B,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,OAAqB;IAChE,2EAA2E;IAC3E,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACvD,IAAI,eAAe,KAAK,SAAS,EAAE;QAClC,OAAO;YACN,YAAY,EAAE,eAAe;YAC7B,gBAAgB,EAAE,gBAAgB;SAClC,CAAC;KACF;IACD,OAAO;QACN,YAAY,EAAE,OAAO;QACrB,gBAAgB,EAAE,SAAS;KAC3B,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt, TelemetryDataTag } from \"@fluidframework/telemetry-utils\";\nimport { ISnapshotTree, ISummaryTree, SummaryObject } from \"@fluidframework/protocol-definitions\";\nimport { channelsTreeName, ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"@fluidframework/runtime-utils\";\n\n/**\n * Return type of refreshSummaryAck function. There can be three different scenarios based on the passed params:\n *\n * 1. The latest summary was not updated.\n *\n * 2. The latest summary was updated and the summary corresponding to the params was tracked by this client.\n *\n * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this case, the\n * latest snapshot is fetched and the latest summary state is updated based on it.\n */\nexport type RefreshSummaryResult =\n\t| {\n\t\t\tlatestSummaryUpdated: false;\n\t }\n\t| {\n\t\t\tlatestSummaryUpdated: true;\n\t\t\twasSummaryTracked: true;\n\t\t\tsummaryRefSeq: number;\n\t }\n\t| {\n\t\t\tlatestSummaryUpdated: true;\n\t\t\twasSummaryTracked: false;\n\t\t\tsnapshotTree: ISnapshotTree;\n\t\t\tsummaryRefSeq: number;\n\t };\n\n/**\n * Result of snapshot fetch during refreshing latest summary state.\n */\nexport interface IFetchSnapshotResult {\n\tsnapshotTree: ISnapshotTree;\n\tsnapshotRefSeq: number;\n}\n\n/**\n * Return type of validateSummary function. In case of success, the object returned should have success: true.\n * In case of failure, the object returned should have success: false and additional properties to indicate what\n * the failure was, where it was, can it be retried, etc.\n */\nexport type ValidateSummaryResult =\n\t| {\n\t\t\tsuccess: true;\n\t }\n\t| {\n\t\t\tsuccess: false;\n\t\t\t/** The failure reason */\n\t\t\treason: string;\n\t\t\t/** id of the node that failed during validation */\n\t\t\tid: {\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact;\n\t\t\t\tvalue: string | undefined;\n\t\t\t};\n\t\t\t/** If the error can be retried, time to wait before retrying */\n\t\t\tretryAfterSeconds?: number;\n\t };\n\nexport interface ISummarizerNodeRootContract {\n\tstartSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLoggerExt): void;\n\tvalidateSummary(): ValidateSummaryResult;\n\tcompleteSummary(proposalHandle: string, validate: boolean): void;\n\tclearSummary(): void;\n\trefreshLatestSummary(\n\t\tproposalHandle: string | undefined,\n\t\tsummaryRefSeq: number,\n\t\tfetchLatestSnapshot: () => Promise<IFetchSnapshotResult>,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t\tcorrelatedSummaryLogger: ITelemetryLoggerExt,\n\t): Promise<RefreshSummaryResult>;\n}\n\n/** Path for nodes in a tree with escaped special characters */\nexport class EscapedPath {\n\tprivate constructor(public readonly path: string) {}\n\tpublic static create(path: string): EscapedPath {\n\t\treturn new EscapedPath(encodeURIComponent(path));\n\t}\n\tpublic static createAndConcat(pathParts: string[]): EscapedPath {\n\t\tlet ret = EscapedPath.create(pathParts[0] ?? \"\");\n\t\tfor (let i = 1; i < pathParts.length; i++) {\n\t\t\tret = ret.concat(EscapedPath.create(pathParts[i]));\n\t\t}\n\t\treturn ret;\n\t}\n\tpublic toString(): string {\n\t\treturn this.path;\n\t}\n\tpublic concat(path: EscapedPath): EscapedPath {\n\t\treturn new EscapedPath(`${this.path}/${path.path}`);\n\t}\n}\n\n/** Information about a summary relevant to a specific node in the tree */\nexport class SummaryNode {\n\t/** Creates an instance that is valid for the root with specific basePath and localPath */\n\tpublic static createForRoot(referenceSequenceNumber: number): SummaryNode {\n\t\treturn new SummaryNode({\n\t\t\treferenceSequenceNumber,\n\t\t\tbasePath: undefined,\n\t\t\tlocalPath: EscapedPath.create(\"\"), // root hard-coded to \"\"\n\t\t});\n\t}\n\n\t/** Summary reference sequence number, i.e. last sequence number seen when it was created */\n\tpublic get referenceSequenceNumber(): number {\n\t\treturn this.summary.referenceSequenceNumber;\n\t}\n\t/** Full path to parent node, or undefined if this is the root */\n\tpublic get basePath(): EscapedPath | undefined {\n\t\treturn this.summary.basePath;\n\t}\n\t/** Relative path to this node from its parent node */\n\tpublic get localPath(): EscapedPath {\n\t\treturn this.summary.localPath;\n\t}\n\t/** Relative path from this node to its node innermost base summary */\n\tpublic get additionalPath(): EscapedPath | undefined {\n\t\treturn this.summary.additionalPath;\n\t}\n\tpublic set additionalPath(additionalPath: EscapedPath | undefined) {\n\t\tthis.summary.additionalPath = additionalPath;\n\t}\n\tconstructor(\n\t\tprivate readonly summary: {\n\t\t\treadonly referenceSequenceNumber: number;\n\t\t\treadonly basePath: EscapedPath | undefined;\n\t\t\treadonly localPath: EscapedPath;\n\t\t\tadditionalPath?: EscapedPath;\n\t\t},\n\t) {}\n\n\t/** Gets the full path to this node, to be used when sending a handle */\n\tpublic get fullPath(): EscapedPath {\n\t\treturn this.basePath?.concat(this.localPath) ?? this.localPath;\n\t}\n\n\t/**\n\t * Gets the full path to this node's innermost base summary.\n\t * The children nodes can use this as their basePath to determine their path.\n\t */\n\tpublic get fullPathForChildren(): EscapedPath {\n\t\treturn this.additionalPath !== undefined\n\t\t\t? this.fullPath.concat(this.additionalPath)\n\t\t\t: this.fullPath;\n\t}\n\n\t/**\n\t * Creates a new node within the same summary for a child of this node.\n\t * @param id - id of the child node\n\t */\n\tpublic createForChild(id: string): SummaryNode {\n\t\treturn new SummaryNode({\n\t\t\treferenceSequenceNumber: this.referenceSequenceNumber,\n\t\t\tbasePath: this.fullPathForChildren,\n\t\t\tlocalPath: EscapedPath.create(id),\n\t\t});\n\t}\n}\n\n/**\n * Information about the initial summary tree found from an attach op.\n */\nexport interface IInitialSummary {\n\tsequenceNumber: number;\n\tid: string;\n\tsummary: ISummaryTreeWithStats | undefined;\n}\n\n/**\n * Represents the details needed to create a child summarizer node.\n */\nexport interface ICreateChildDetails {\n\t/** Summary from attach op if known */\n\tinitialSummary: IInitialSummary | undefined;\n\t/** Latest summary from server node data */\n\tlatestSummary: SummaryNode | undefined;\n\t/** Sequence number of latest known change to the node */\n\tchangeSequenceNumber: number;\n\t/** A unique id of this child to be logged when sending telemetry. */\n\ttelemetryNodeId: string;\n}\n\nexport interface ISubtreeInfo<T extends ISnapshotTree | SummaryObject> {\n\t/** Tree to use to find children subtrees */\n\tchildrenTree: T;\n\t/** Additional path part where children are isolated */\n\tchildrenPathPart: string | undefined;\n}\n\n/**\n * Checks if the summary contains .channels subtree where the children subtrees\n * would be located if exists.\n * @param baseSummary - summary to check\n */\nexport function parseSummaryForSubtrees(baseSummary: ISnapshotTree): ISubtreeInfo<ISnapshotTree> {\n\t// New versions of snapshots have child nodes isolated in .channels subtree\n\tconst channelsSubtree = baseSummary.trees[channelsTreeName];\n\tif (channelsSubtree !== undefined) {\n\t\treturn {\n\t\t\tchildrenTree: channelsSubtree,\n\t\t\tchildrenPathPart: channelsTreeName,\n\t\t};\n\t}\n\treturn {\n\t\tchildrenTree: baseSummary,\n\t\tchildrenPathPart: undefined,\n\t};\n}\n\n/**\n * Checks if the summary contains .channels subtree where the children subtrees\n * would be located if exists.\n * @param baseSummary - summary to check\n */\nexport function parseSummaryTreeForSubtrees(summary: ISummaryTree): ISubtreeInfo<SummaryObject> {\n\t// New versions of snapshots have child nodes isolated in .channels subtree\n\tconst channelsSubtree = summary.tree[channelsTreeName];\n\tif (channelsSubtree !== undefined) {\n\t\treturn {\n\t\t\tchildrenTree: channelsSubtree,\n\t\t\tchildrenPathPart: channelsTreeName,\n\t\t};\n\t}\n\treturn {\n\t\tchildrenTree: summary,\n\t\tchildrenPathPart: undefined,\n\t};\n}\n"]}
1
+ {"version":3,"file":"summarizerNodeUtils.js","sourceRoot":"","sources":["../../../src/summary/summarizerNode/summarizerNodeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,gBAAgB,EAAyB,MAAM,qCAAqC,CAAC;AAyE9F,+DAA+D;AAC/D,MAAM,OAAO,WAAW;IACvB,YAAoC,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAC7C,MAAM,CAAC,MAAM,CAAC,IAAY;QAChC,OAAO,IAAI,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;IACM,MAAM,CAAC,eAAe,CAAC,SAAmB;QAChD,IAAI,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC1C,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACnD;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IACM,QAAQ;QACd,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACM,MAA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CAAC;YAC3C,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACI,cAAc,CAAC,EAAU;QAC/B,OAAO,IAAI,WAAW,CAAC;YACtB,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;YACrD,QAAQ,EAAE,IAAI,CAAC,mBAAmB;YAClC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;SACjC,CAAC,CAAC;IACJ,CAAC;CACD;AAgCD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAA0B;IACjE,2EAA2E;IAC3E,MAAM,eAAe,GAAG,WAAW,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC5D,IAAI,eAAe,KAAK,SAAS,EAAE;QAClC,OAAO;YACN,YAAY,EAAE,eAAe;YAC7B,gBAAgB,EAAE,gBAAgB;SAClC,CAAC;KACF;IACD,OAAO;QACN,YAAY,EAAE,WAAW;QACzB,gBAAgB,EAAE,SAAS;KAC3B,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,OAAqB;IAChE,2EAA2E;IAC3E,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACvD,IAAI,eAAe,KAAK,SAAS,EAAE;QAClC,OAAO;YACN,YAAY,EAAE,eAAe;YAC7B,gBAAgB,EAAE,gBAAgB;SAClC,CAAC;KACF;IACD,OAAO;QACN,YAAY,EAAE,OAAO;QACrB,gBAAgB,EAAE,SAAS;KAC3B,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt, TelemetryDataTag } from \"@fluidframework/telemetry-utils\";\nimport { ISnapshotTree, ISummaryTree, SummaryObject } from \"@fluidframework/protocol-definitions\";\nimport { channelsTreeName, ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"@fluidframework/runtime-utils\";\n\n/**\n * Return type of refreshSummaryAck function. There can be three different scenarios based on the passed params:\n *\n * 1. The latest summary was not updated.\n *\n * 2. The latest summary was updated and the summary corresponding to the params was tracked by this client.\n *\n * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this case, the\n * latest snapshot is fetched and the latest summary state is updated based on it.\n */\nexport type RefreshSummaryResult =\n\t| {\n\t\t\tlatestSummaryUpdated: false;\n\t }\n\t| {\n\t\t\tlatestSummaryUpdated: true;\n\t\t\twasSummaryTracked: true;\n\t\t\tsummaryRefSeq: number;\n\t }\n\t| {\n\t\t\tlatestSummaryUpdated: true;\n\t\t\twasSummaryTracked: false;\n\t\t\tsnapshotTree: ISnapshotTree;\n\t\t\tsummaryRefSeq: number;\n\t };\n\n/**\n * Result of snapshot fetch during refreshing latest summary state.\n */\nexport interface IFetchSnapshotResult {\n\tsnapshotTree: ISnapshotTree;\n\tsnapshotRefSeq: number;\n}\n\n/**\n * Return type of validateSummary function. In case of success, the object returned should have success: true.\n * In case of failure, the object returned should have success: false and additional properties to indicate what\n * the failure was, where it was, can it be retried, etc.\n */\nexport type ValidateSummaryResult =\n\t| {\n\t\t\tsuccess: true;\n\t }\n\t| {\n\t\t\tsuccess: false;\n\t\t\t/** The failure reason */\n\t\t\treason: string;\n\t\t\t/** id of the node that failed during validation */\n\t\t\tid: {\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact;\n\t\t\t\tvalue: string | undefined;\n\t\t\t};\n\t\t\t/** If the error can be retried, time to wait before retrying */\n\t\t\tretryAfterSeconds?: number;\n\t };\n\nexport interface ISummarizerNodeRootContract {\n\tstartSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLoggerExt): void;\n\tvalidateSummary(): ValidateSummaryResult;\n\tcompleteSummary(proposalHandle: string, validate: boolean): void;\n\tclearSummary(): void;\n\trefreshLatestSummary(\n\t\tproposalHandle: string | undefined,\n\t\tsummaryRefSeq: number,\n\t\tfetchLatestSnapshot: () => Promise<IFetchSnapshotResult>,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t\tcorrelatedSummaryLogger: ITelemetryLoggerExt,\n\t): Promise<RefreshSummaryResult>;\n}\n\n/** Path for nodes in a tree with escaped special characters */\nexport class EscapedPath {\n\tprivate constructor(public readonly path: string) {}\n\tpublic static create(path: string): EscapedPath {\n\t\treturn new EscapedPath(encodeURIComponent(path));\n\t}\n\tpublic static createAndConcat(pathParts: string[]): EscapedPath {\n\t\tlet ret = EscapedPath.create(pathParts[0] ?? \"\");\n\t\tfor (let i = 1; i < pathParts.length; i++) {\n\t\t\tret = ret.concat(EscapedPath.create(pathParts[i]));\n\t\t}\n\t\treturn ret;\n\t}\n\tpublic toString(): string {\n\t\treturn this.path;\n\t}\n\tpublic concat(path: EscapedPath): EscapedPath {\n\t\treturn new EscapedPath(`${this.path}/${path.path}`);\n\t}\n}\n\n/** Information about a summary relevant to a specific node in the tree */\nexport class SummaryNode {\n\t/** Creates an instance that is valid for the root with specific basePath and localPath */\n\tpublic static createForRoot(referenceSequenceNumber: number): SummaryNode {\n\t\treturn new SummaryNode({\n\t\t\treferenceSequenceNumber,\n\t\t\tbasePath: undefined,\n\t\t\tlocalPath: EscapedPath.create(\"\"), // root hard-coded to \"\"\n\t\t});\n\t}\n\n\t/** Summary reference sequence number, i.e. last sequence number seen when it was created */\n\tpublic get referenceSequenceNumber(): number {\n\t\treturn this.summary.referenceSequenceNumber;\n\t}\n\t/** Full path to parent node, or undefined if this is the root */\n\tpublic get basePath(): EscapedPath | undefined {\n\t\treturn this.summary.basePath;\n\t}\n\t/** Relative path to this node from its parent node */\n\tpublic get localPath(): EscapedPath {\n\t\treturn this.summary.localPath;\n\t}\n\t/** Relative path from this node to its node innermost base summary */\n\tpublic get additionalPath(): EscapedPath | undefined {\n\t\treturn this.summary.additionalPath;\n\t}\n\tpublic set additionalPath(additionalPath: EscapedPath | undefined) {\n\t\tthis.summary.additionalPath = additionalPath;\n\t}\n\tconstructor(\n\t\tprivate readonly summary: {\n\t\t\treadonly referenceSequenceNumber: number;\n\t\t\treadonly basePath: EscapedPath | undefined;\n\t\t\treadonly localPath: EscapedPath;\n\t\t\tadditionalPath?: EscapedPath;\n\t\t},\n\t) {}\n\n\t/** Gets the full path to this node, to be used when sending a handle */\n\tpublic get fullPath(): EscapedPath {\n\t\treturn this.basePath?.concat(this.localPath) ?? this.localPath;\n\t}\n\n\t/**\n\t * Gets the full path to this node's innermost base summary.\n\t * The children nodes can use this as their basePath to determine their path.\n\t */\n\tpublic get fullPathForChildren(): EscapedPath {\n\t\treturn this.additionalPath !== undefined\n\t\t\t? this.fullPath.concat(this.additionalPath)\n\t\t\t: this.fullPath;\n\t}\n\n\t/**\n\t * Creates a new node within the same summary for a child of this node.\n\t * @param id - id of the child node\n\t */\n\tpublic createForChild(id: string): SummaryNode {\n\t\treturn new SummaryNode({\n\t\t\treferenceSequenceNumber: this.referenceSequenceNumber,\n\t\t\tbasePath: this.fullPathForChildren,\n\t\t\tlocalPath: EscapedPath.create(id),\n\t\t});\n\t}\n}\n\n/**\n * Information about the initial summary tree found from an attach op.\n */\nexport interface IInitialSummary {\n\tsequenceNumber: number;\n\tid: string;\n\tsummary: ISummaryTreeWithStats | undefined;\n}\n\n/**\n * Represents the details needed to create a child summarizer node.\n */\nexport interface ICreateChildDetails {\n\t/** Summary from attach op if known */\n\tinitialSummary: IInitialSummary | undefined;\n\t/** Latest summary from server node data */\n\tlatestSummary: SummaryNode | undefined;\n\t/** Sequence number of latest known change to the node */\n\tchangeSequenceNumber: number;\n\t/** A unique id of this child to be logged when sending telemetry. */\n\ttelemetryNodeId: string;\n}\n\nexport interface ISubtreeInfo<T extends ISnapshotTree | SummaryObject> {\n\t/** Tree to use to find children subtrees */\n\tchildrenTree: T;\n\t/** Additional path part where children are isolated */\n\tchildrenPathPart: string | undefined;\n}\n\n/**\n * Checks if the summary contains .channels subtree where the children subtrees\n * would be located if exists.\n * @param baseSummary - summary to check\n */\nexport function parseSummaryForSubtrees(baseSummary: ISnapshotTree): ISubtreeInfo<ISnapshotTree> {\n\t// New versions of snapshots have child nodes isolated in .channels subtree\n\tconst channelsSubtree = baseSummary.trees[channelsTreeName];\n\tif (channelsSubtree !== undefined) {\n\t\treturn {\n\t\t\tchildrenTree: channelsSubtree,\n\t\t\tchildrenPathPart: channelsTreeName,\n\t\t};\n\t}\n\treturn {\n\t\tchildrenTree: baseSummary,\n\t\tchildrenPathPart: undefined,\n\t};\n}\n\n/**\n * Checks if the summary contains .channels subtree where the children subtrees\n * would be located if exists.\n * @param baseSummary - summary to check\n */\nexport function parseSummaryTreeForSubtrees(summary: ISummaryTree): ISubtreeInfo<SummaryObject> {\n\t// New versions of snapshots have child nodes isolated in .channels subtree\n\tconst channelsSubtree = summary.tree[channelsTreeName];\n\tif (channelsSubtree !== undefined) {\n\t\treturn {\n\t\t\tchildrenTree: channelsSubtree,\n\t\t\tchildrenPathPart: channelsTreeName,\n\t\t};\n\t}\n\treturn {\n\t\tchildrenTree: summary,\n\t\tchildrenPathPart: undefined,\n\t};\n}\n"]}
@@ -51,8 +51,7 @@ export class SummarizerNodeWithGC extends SummarizerNode {
51
51
  this.usedRoutes = [""];
52
52
  this.gcDisabled = config.gcDisabled === true;
53
53
  this.baseGCDetailsP = new LazyPromise(async () => {
54
- var _a;
55
- return (_a = (await (getBaseGCDetailsFn === null || getBaseGCDetailsFn === void 0 ? void 0 : getBaseGCDetailsFn()))) !== null && _a !== void 0 ? _a : { usedRoutes: [] };
54
+ return (await getBaseGCDetailsFn?.()) ?? { usedRoutes: [] };
56
55
  });
57
56
  this.childNodesBaseGCDetailsP = new LazyPromise(async () => {
58
57
  await this.loadBaseGCDetails();
@@ -223,10 +222,13 @@ export class SummarizerNodeWithGC extends SummarizerNode {
223
222
  // If a pending summary exists, it must have used routes since GC is enabled.
224
223
  const summaryNodeWithGC = summaryNode;
225
224
  if (summaryNodeWithGC.serializedUsedRoutes === undefined) {
226
- const error = new LoggingError("MissingGCStateInPendingSummary", Object.assign({ proposalHandle,
227
- referenceSequenceNumber }, tagCodeArtifacts({
228
- id: this.telemetryNodeId,
229
- })));
225
+ const error = new LoggingError("MissingGCStateInPendingSummary", {
226
+ proposalHandle,
227
+ referenceSequenceNumber,
228
+ ...tagCodeArtifacts({
229
+ id: this.telemetryNodeId,
230
+ }),
231
+ });
230
232
  this.logger.sendErrorEvent({
231
233
  eventName: error.message,
232
234
  }, error);
@@ -298,14 +300,14 @@ export class SummarizerNodeWithGC extends SummarizerNode {
298
300
  }
299
301
  }
300
302
  // Update this node to the same GC state it was when the ack corresponding to this summary was processed.
301
- this.gcData = (gcDetails === null || gcDetails === void 0 ? void 0 : gcDetails.gcData) !== undefined ? cloneGCData(gcDetails.gcData) : undefined;
303
+ this.gcData = gcDetails?.gcData !== undefined ? cloneGCData(gcDetails.gcData) : undefined;
302
304
  this.referenceUsedRoutes =
303
- (gcDetails === null || gcDetails === void 0 ? void 0 : gcDetails.usedRoutes) !== undefined ? Array.from(gcDetails.usedRoutes) : undefined;
305
+ gcDetails?.usedRoutes !== undefined ? Array.from(gcDetails.usedRoutes) : undefined;
304
306
  // If there are no used routes in the GC details, set it to have self route which will make the node
305
307
  // referenced. This scenario can only happen if the snapshot is from a client where GC was not run or
306
308
  // disabled. In both the cases, the node should be referenced.
307
309
  this.usedRoutes =
308
- (gcDetails === null || gcDetails === void 0 ? void 0 : gcDetails.usedRoutes) !== undefined ? Array.from(gcDetails.usedRoutes) : [""];
310
+ gcDetails?.usedRoutes !== undefined ? Array.from(gcDetails.usedRoutes) : [""];
309
311
  if (gcDetails === undefined) {
310
312
  return;
311
313
  }
@@ -332,7 +334,6 @@ export class SummarizerNodeWithGC extends SummarizerNode {
332
334
  * Attach information if it is created from an attach op.
333
335
  */
334
336
  createParam, config = {}, getGCDataFn, getBaseGCDetailsFn) {
335
- var _a;
336
337
  assert(!this.children.has(id), 0x1b6 /* "Create SummarizerNode child already exists" */);
337
338
  /**
338
339
  * Update the child node's base GC details from this node's current GC details instead of updating from the base
@@ -341,14 +342,15 @@ export class SummarizerNodeWithGC extends SummarizerNode {
341
342
  * the one from the downloaded snapshot and not the base GC details.
342
343
  */
343
344
  const getChildBaseGCDetailsFn = async () => {
344
- var _a;
345
345
  const childNodesBaseGCDetails = await this.childNodesBaseGCDetailsP;
346
- return (_a = childNodesBaseGCDetails.get(id)) !== null && _a !== void 0 ? _a : {};
346
+ return childNodesBaseGCDetails.get(id) ?? {};
347
347
  };
348
348
  const createDetails = this.getCreateDetailsForChild(id, createParam);
349
- const child = new SummarizerNodeWithGC(this.logger, summarizeInternalFn, Object.assign(Object.assign({}, config), {
349
+ const child = new SummarizerNodeWithGC(this.logger, summarizeInternalFn, {
350
+ ...config,
350
351
  // Propagate our gcDisabled state to the child if its not explicity specified in child's config.
351
- gcDisabled: (_a = config.gcDisabled) !== null && _a !== void 0 ? _a : this.gcDisabled }), createDetails.changeSequenceNumber, createDetails.latestSummary, createDetails.initialSummary, this.wipSummaryLogger, getGCDataFn, getChildBaseGCDetailsFn, createDetails.telemetryNodeId);
352
+ gcDisabled: config.gcDisabled ?? this.gcDisabled,
353
+ }, createDetails.changeSequenceNumber, createDetails.latestSummary, createDetails.initialSummary, this.wipSummaryLogger, getGCDataFn, getChildBaseGCDetailsFn, createDetails.telemetryNodeId);
352
354
  // There may be additional state that has to be updated in this child. For example, if a summary is being
353
355
  // tracked, the child's summary tracking state needs to be updated too.
354
356
  this.maybeUpdateChildState(child, id);
@@ -365,7 +367,6 @@ export class SummarizerNodeWithGC extends SummarizerNode {
365
367
  * @param id - Initial id or path part of this node
366
368
  */
367
369
  maybeUpdateChildState(child, id) {
368
- var _a;
369
370
  super.maybeUpdateChildState(child, id);
370
371
  // In case we have pending summaries on the parent, let's initialize it on the child.
371
372
  if (child.latestSummary !== undefined) {
@@ -373,7 +374,7 @@ export class SummarizerNodeWithGC extends SummarizerNode {
373
374
  const summaryNodeWithGC = value;
374
375
  if (summaryNodeWithGC.serializedUsedRoutes !== undefined) {
375
376
  const childNodeUsedRoutes = unpackChildNodesUsedRoutes(JSON.parse(summaryNodeWithGC.serializedUsedRoutes));
376
- const newSerializedRoutes = (_a = childNodeUsedRoutes.get(id)) !== null && _a !== void 0 ? _a : [""];
377
+ const newSerializedRoutes = childNodeUsedRoutes.get(id) ?? [""];
377
378
  const newLatestSummaryNode = new SummaryNodeWithGC(JSON.stringify(newSerializedRoutes), {
378
379
  referenceSequenceNumber: value.referenceSequenceNumber,
379
380
  basePath: child.latestSummary.basePath,