@fluidframework/container-runtime 2.4.0-297027 → 2.4.0-299374

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 (52) hide show
  1. package/container-runtime.test-files.tar +0 -0
  2. package/dist/containerRuntime.d.ts +8 -0
  3. package/dist/containerRuntime.d.ts.map +1 -1
  4. package/dist/containerRuntime.js +79 -58
  5. package/dist/containerRuntime.js.map +1 -1
  6. package/dist/dataStoreContext.d.ts.map +1 -1
  7. package/dist/dataStoreContext.js +0 -3
  8. package/dist/dataStoreContext.js.map +1 -1
  9. package/dist/packageVersion.d.ts +1 -1
  10. package/dist/packageVersion.js +1 -1
  11. package/dist/packageVersion.js.map +1 -1
  12. package/dist/summary/summarizerNode/summarizerNode.d.ts +30 -13
  13. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  14. package/dist/summary/summarizerNode/summarizerNode.js +84 -102
  15. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  16. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +15 -42
  17. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  18. package/dist/summary/summarizerNode/summarizerNodeUtils.js +10 -88
  19. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  20. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +5 -6
  21. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  22. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +28 -38
  23. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  24. package/lib/containerRuntime.d.ts +8 -0
  25. package/lib/containerRuntime.d.ts.map +1 -1
  26. package/lib/containerRuntime.js +79 -58
  27. package/lib/containerRuntime.js.map +1 -1
  28. package/lib/dataStoreContext.d.ts.map +1 -1
  29. package/lib/dataStoreContext.js +0 -3
  30. package/lib/dataStoreContext.js.map +1 -1
  31. package/lib/packageVersion.d.ts +1 -1
  32. package/lib/packageVersion.js +1 -1
  33. package/lib/packageVersion.js.map +1 -1
  34. package/lib/summary/summarizerNode/summarizerNode.d.ts +30 -13
  35. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  36. package/lib/summary/summarizerNode/summarizerNode.js +85 -103
  37. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  38. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts +15 -42
  39. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  40. package/lib/summary/summarizerNode/summarizerNodeUtils.js +8 -84
  41. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  42. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +5 -6
  43. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  44. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +29 -39
  45. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  46. package/package.json +21 -22
  47. package/src/containerRuntime.ts +98 -76
  48. package/src/dataStoreContext.ts +0 -3
  49. package/src/packageVersion.ts +1 -1
  50. package/src/summary/summarizerNode/summarizerNode.ts +90 -123
  51. package/src/summary/summarizerNode/summarizerNodeUtils.ts +19 -99
  52. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +37 -53
@@ -30,24 +30,44 @@ class SummarizerNode {
30
30
  * Returns 0 if there is not yet an acked summary.
31
31
  */
32
32
  get referenceSequenceNumber() {
33
- return this._latestSummary?.referenceSequenceNumber ?? 0;
33
+ return this._lastSummaryReferenceSequenceNumber ?? 0;
34
+ }
35
+ /**
36
+ * returns the handle of the last successful summary of this summarizerNode in string format
37
+ * (this getter is primarily only used in the test code)
38
+ */
39
+ get summaryHandleId() {
40
+ return this._summaryHandleId.toString();
34
41
  }
35
42
  /**
36
43
  * Do not call constructor directly.
37
44
  * Use createRootSummarizerNode to create root node, or createChild to create child nodes.
38
45
  */
39
- constructor(baseLogger, summarizeInternalFn, config, _changeSequenceNumber,
40
- /** Undefined means created without summary */
41
- _latestSummary, wipSummaryLogger,
46
+ constructor(baseLogger, summarizeInternalFn, config,
47
+ /** Encoded handle or path to the node */
48
+ _summaryHandleId, _changeSequenceNumber,
49
+ /** Summary reference sequence number, i.e. last sequence number seen when last successful summary was created */
50
+ _lastSummaryReferenceSequenceNumber, wipSummaryLogger,
42
51
  /** A unique id of this node to be logged when sending telemetry. */
43
52
  telemetryNodeId) {
44
53
  this.summarizeInternalFn = summarizeInternalFn;
54
+ this._summaryHandleId = _summaryHandleId;
45
55
  this._changeSequenceNumber = _changeSequenceNumber;
46
- this._latestSummary = _latestSummary;
56
+ this._lastSummaryReferenceSequenceNumber = _lastSummaryReferenceSequenceNumber;
47
57
  this.wipSummaryLogger = wipSummaryLogger;
48
58
  this.telemetryNodeId = telemetryNodeId;
49
59
  this.children = new Map();
60
+ /**
61
+ * Key value pair of summaries submitted by this client which are not yet acked.
62
+ * Key is the proposalHandle and value is the summary op's referece sequence number.
63
+ */
50
64
  this.pendingSummaries = new Map();
65
+ /**
66
+ * True if the current node was summarized during the current summary process
67
+ * This flag is used to identify scenarios where summarize was not called on a node.
68
+ * For example, this node was created after its parent was already summarized due to out-of-order realization via application code.
69
+ */
70
+ this.wipSummarizeCalled = false;
51
71
  this.wipSkipRecursion = false;
52
72
  this.canReuseHandle = config.canReuseHandle ?? true;
53
73
  // All logs posted by the summarizer node should include the telemetryNodeId.
@@ -72,10 +92,10 @@ class SummarizerNode {
72
92
  startSummary(referenceSequenceNumber, summaryLogger, latestSummaryRefSeqNum) {
73
93
  (0, internal_1.assert)(this.wipSummaryLogger === undefined, 0x19f /* "wipSummaryLogger should not be set yet in startSummary" */);
74
94
  (0, internal_1.assert)(this.wipReferenceSequenceNumber === undefined, 0x1a0 /* "Already tracking a summary" */);
75
- let nodes = 1;
95
+ let nodes = 1; // number of summarizerNodes at the start of the summary
76
96
  let invalidNodes = 0;
77
97
  const sequenceNumberMismatchKeySet = new Set();
78
- const nodeLatestSummaryRefSeqNum = this._latestSummary?.referenceSequenceNumber;
98
+ const nodeLatestSummaryRefSeqNum = this._lastSummaryReferenceSequenceNumber;
79
99
  if (nodeLatestSummaryRefSeqNum !== undefined &&
80
100
  latestSummaryRefSeqNum !== nodeLatestSummaryRefSeqNum) {
81
101
  invalidNodes++;
@@ -102,21 +122,18 @@ class SummarizerNode {
102
122
  if (!trackState) {
103
123
  return this.summarizeInternalFn(fullTree, trackState, telemetryContext);
104
124
  }
125
+ // Set to wipSummarizeCalled true to represent that current node was included in the summary process.
126
+ this.wipSummarizeCalled = true;
105
127
  // Try to reuse the tree if unchanged
106
128
  if (this.canReuseHandle && !fullTree && !this.hasChanged()) {
107
- const latestSummary = this._latestSummary;
108
- if (latestSummary !== undefined) {
109
- this.wipLocalPaths = {
110
- localPath: latestSummary.localPath,
111
- additionalPath: latestSummary.additionalPath,
112
- };
129
+ if (this._lastSummaryReferenceSequenceNumber !== undefined) {
113
130
  this.wipSkipRecursion = true;
114
131
  const stats = (0, internal_3.mergeStats)();
115
132
  stats.handleNodeCount++;
116
133
  return {
117
134
  summary: {
118
135
  type: driver_definitions_1.SummaryType.Handle,
119
- handle: latestSummary.fullPath.path,
136
+ handle: this.summaryHandleId,
120
137
  handleType: driver_definitions_1.SummaryType.Tree,
121
138
  },
122
139
  stats,
@@ -127,20 +144,16 @@ class SummarizerNode {
127
144
  if (!fullTree) {
128
145
  (0, internal_1.assert)(this.wipReferenceSequenceNumber !== undefined, 0x5df /* Summarize should not be called when not tracking the summary */);
129
146
  incrementalSummaryContext =
130
- this._latestSummary !== undefined
147
+ this._lastSummaryReferenceSequenceNumber !== undefined
131
148
  ? {
132
149
  summarySequenceNumber: this.wipReferenceSequenceNumber,
133
- latestSummarySequenceNumber: this._latestSummary.referenceSequenceNumber,
134
- // TODO: remove summaryPath
135
- summaryPath: this._latestSummary.fullPath.path,
150
+ latestSummarySequenceNumber: this._lastSummaryReferenceSequenceNumber,
151
+ // TODO: remove summaryPath.
152
+ summaryPath: this.summaryHandleId,
136
153
  }
137
154
  : undefined;
138
155
  }
139
156
  const result = await this.summarizeInternalFn(fullTree, trackState, telemetryContext, incrementalSummaryContext);
140
- this.wipLocalPaths = { localPath: summarizerNodeUtils_js_1.EscapedPath.create(result.id) };
141
- if (result.pathPartsForChildren !== undefined) {
142
- this.wipLocalPaths.additionalPath = summarizerNodeUtils_js_1.EscapedPath.createAndConcat(result.pathPartsForChildren);
143
- }
144
157
  return { summary: result.summary, stats: result.stats };
145
158
  }
146
159
  /**
@@ -192,8 +205,8 @@ class SummarizerNode {
192
205
  (0, internal_1.assert)(this.wipReferenceSequenceNumber !== undefined, 0x6fd /* Not tracking a summary */);
193
206
  // If the parent node skipped recursion, it did not call summarize on this node. So, summarize was not missed
194
207
  // but was intentionally not called.
195
- // Otherwise, summarize should have been called on this node and wipLocalPaths must be set.
196
- if (parentSkipRecursion || this.wipLocalPaths !== undefined) {
208
+ // Otherwise, summarize should have been called on this node and wipSummarizeCalled must be set.
209
+ if (parentSkipRecursion || this.wipSummarizeCalled) {
197
210
  return false;
198
211
  }
199
212
  /**
@@ -217,7 +230,7 @@ class SummarizerNode {
217
230
  * @param proposalHandle - The handle of the summary that was uploaded to the server.
218
231
  */
219
232
  completeSummary(proposalHandle) {
220
- this.completeSummaryCore(proposalHandle, undefined /* parentPath */, false /* parentSkipRecursion */);
233
+ this.completeSummaryCore(proposalHandle, false /* parentSkipRecursion */);
221
234
  }
222
235
  /**
223
236
  * Recursive implementation for completeSummary, with additional internal-only parameters.
@@ -227,24 +240,10 @@ class SummarizerNode {
227
240
  * In that case, the children will not have work-in-progress state.
228
241
  * @param validate - true to validate that the in-progress summary is correct for all nodes.
229
242
  */
230
- completeSummaryCore(proposalHandle, parentPath, parentSkipRecursion) {
243
+ completeSummaryCore(proposalHandle, parentSkipRecursion) {
231
244
  (0, internal_1.assert)(this.wipReferenceSequenceNumber !== undefined, 0x1a4 /* "Not tracking a summary" */);
232
- let localPathsToUse = this.wipLocalPaths;
233
245
  if (parentSkipRecursion) {
234
- const latestSummary = this._latestSummary;
235
- if (latestSummary !== undefined) {
236
- // This case the parent node created a failure summary or was reused.
237
- // This node and all children should only try to reference their path
238
- // by its last known good state in the actual summary tree.
239
- // If parent fails or is reused, the child summarize is not called so
240
- // it did not get a chance to change its paths.
241
- // In this case, essentially only propagate the new summary ref seq num.
242
- localPathsToUse = {
243
- localPath: latestSummary.localPath,
244
- additionalPath: latestSummary.additionalPath,
245
- };
246
- }
247
- else {
246
+ if (this._lastSummaryReferenceSequenceNumber === undefined) {
248
247
  // This case the child is added after the latest non-failure summary.
249
248
  // This node and all children should consider themselves as still not
250
249
  // having a successful summary yet.
@@ -255,17 +254,8 @@ class SummarizerNode {
255
254
  return;
256
255
  }
257
256
  }
258
- // If localPathsToUse is undefined, it means summarize didn't run for this node and in that case the validate
259
- // step should have failed.
260
- (0, internal_1.assert)(localPathsToUse !== undefined, 0x6fe /* summarize didn't run for node */);
261
- const summary = new summarizerNodeUtils_js_1.SummaryNode({
262
- ...localPathsToUse,
263
- referenceSequenceNumber: this.wipReferenceSequenceNumber,
264
- basePath: parentPath,
265
- });
266
- const fullPathForChildren = summary.fullPathForChildren;
267
257
  for (const child of this.children.values()) {
268
- child.completeSummaryCore(proposalHandle, fullPathForChildren, this.wipSkipRecursion || parentSkipRecursion);
258
+ child.completeSummaryCore(proposalHandle, this.wipSkipRecursion || parentSkipRecursion);
269
259
  }
270
260
  // Note that this overwrites existing pending summary with
271
261
  // the same proposalHandle. If proposalHandle is something like
@@ -273,12 +263,14 @@ class SummarizerNode {
273
263
  // can return the same proposalHandle for a different summary,
274
264
  // this should still be okay, because we should be proposing the
275
265
  // newer one later which would have to overwrite the previous one.
276
- this.pendingSummaries.set(proposalHandle, summary);
266
+ this.pendingSummaries.set(proposalHandle, {
267
+ referenceSequenceNumber: this.wipReferenceSequenceNumber,
268
+ });
277
269
  this.clearSummary();
278
270
  }
279
271
  clearSummary() {
280
272
  this.wipReferenceSequenceNumber = undefined;
281
- this.wipLocalPaths = undefined;
273
+ this.wipSummarizeCalled = false;
282
274
  this.wipSkipRecursion = false;
283
275
  this.wipSummaryLogger = undefined;
284
276
  for (const child of this.children.values()) {
@@ -289,7 +281,8 @@ class SummarizerNode {
289
281
  * Refreshes the latest summary tracked by this node. If we have a pending summary for the given proposal handle,
290
282
  * it becomes the latest summary. If the current summary is already ahead, we skip the update.
291
283
  * If the current summary is behind, then we do not refresh.
292
- *
284
+ * @param proposalHandle - Handle of the generated / uploaded summary.
285
+ * @param summaryRefSeq - Reference sequence of the acked summary
293
286
  * @returns true if the summary is tracked by this node, false otherwise.
294
287
  */
295
288
  async refreshLatestSummary(proposalHandle, summaryRefSeq) {
@@ -314,10 +307,13 @@ class SummarizerNode {
314
307
  if (summaryRefSeq > this.referenceSequenceNumber) {
315
308
  isSummaryNewer = true;
316
309
  }
317
- const maybeSummaryNode = this.pendingSummaries.get(proposalHandle);
318
- if (maybeSummaryNode !== undefined) {
319
- this.refreshLatestSummaryFromPending(proposalHandle, maybeSummaryNode.referenceSequenceNumber);
310
+ // If the acked summary is found in the pendingSummaries, it means the summary was created and tracked by the current client
311
+ // so set the isSummaryTracked to true.
312
+ const pendingSummary = this.pendingSummaries.get(proposalHandle);
313
+ if (pendingSummary?.referenceSequenceNumber !== undefined) {
320
314
  isSummaryTracked = true;
315
+ // update the pendingSummariesMap for the root and all child summarizerNodes
316
+ this.refreshLatestSummaryFromPending(proposalHandle, pendingSummary.referenceSequenceNumber);
321
317
  }
322
318
  event.end({ ...eventProps, isSummaryNewer, pendingSummaryFound: isSummaryTracked });
323
319
  return { isSummaryTracked, isSummaryNewer };
@@ -330,38 +326,32 @@ class SummarizerNode {
330
326
  * @param referenceSequenceNumber - Reference sequence number of sent summary.
331
327
  */
332
328
  refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber) {
333
- const summaryNode = this.pendingSummaries.get(proposalHandle);
334
- if (summaryNode === undefined) {
329
+ const pendingSummary = this.pendingSummaries.get(proposalHandle);
330
+ if (pendingSummary === undefined) {
335
331
  // This should only happen if parent skipped recursion AND no prior summary existed.
336
- (0, internal_1.assert)(this._latestSummary === undefined, 0x1a6 /* "Not found pending summary, but this node has previously completed a summary" */);
332
+ (0, internal_1.assert)(this._lastSummaryReferenceSequenceNumber === undefined, 0x1a6 /* "Not found pending summary, but this node has previously completed a summary" */);
337
333
  return;
338
334
  }
339
335
  else {
340
- (0, internal_1.assert)(referenceSequenceNumber === summaryNode.referenceSequenceNumber, 0x1a7 /* Pending summary reference sequence number should be consistent */);
336
+ (0, internal_1.assert)(referenceSequenceNumber === pendingSummary.referenceSequenceNumber, 0x1a7 /* Pending summary reference sequence number should be consistent */);
341
337
  // Clear earlier pending summaries
342
338
  this.pendingSummaries.delete(proposalHandle);
343
339
  }
344
- this.refreshLatestSummaryCore(referenceSequenceNumber);
345
- this._latestSummary = summaryNode;
340
+ // Delete all summaries whose reference sequence number is smaller than the one just acked.
341
+ for (const [key, summary] of this.pendingSummaries) {
342
+ if (summary.referenceSequenceNumber < referenceSequenceNumber) {
343
+ this.pendingSummaries.delete(key);
344
+ }
345
+ }
346
+ // Update the latest successful summary reference number
347
+ this._lastSummaryReferenceSequenceNumber = pendingSummary.referenceSequenceNumber;
346
348
  // Propagate update to all child nodes
347
349
  for (const child of this.children.values()) {
348
350
  child.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);
349
351
  }
350
352
  }
351
- refreshLatestSummaryCore(referenceSequenceNumber) {
352
- for (const [key, value] of this.pendingSummaries) {
353
- if (value.referenceSequenceNumber < referenceSequenceNumber) {
354
- this.pendingSummaries.delete(key);
355
- }
356
- }
357
- }
358
353
  updateBaseSummaryState(snapshot) {
359
- // Check base summary to see if it has any additional path parts
360
- // separating child SummarizerNodes. Checks for .channels subtrees.
361
- const { childrenPathPart } = (0, summarizerNodeUtils_js_1.parseSummaryForSubtrees)(snapshot);
362
- if (childrenPathPart !== undefined && this._latestSummary !== undefined) {
363
- this._latestSummary.additionalPath = summarizerNodeUtils_js_1.EscapedPath.create(childrenPathPart);
364
- }
354
+ // Function deprecated. Empty declaration is kept around to compat failures.
365
355
  }
366
356
  recordChange(op) {
367
357
  this.invalidate(op.sequenceNumber);
@@ -379,9 +369,6 @@ class SummarizerNode {
379
369
  hasChanged() {
380
370
  return this._changeSequenceNumber > this.referenceSequenceNumber;
381
371
  }
382
- get latestSummary() {
383
- return this._latestSummary;
384
- }
385
372
  createChild(
386
373
  /** Summarize function */
387
374
  summarizeInternalFn,
@@ -395,7 +382,7 @@ class SummarizerNode {
395
382
  createParam, config = {}) {
396
383
  (0, internal_1.assert)(!this.children.has(id), 0x1ab /* "Create SummarizerNode child already exists" */);
397
384
  const createDetails = this.getCreateDetailsForChild(id, createParam);
398
- const child = new SummarizerNode(this.logger, summarizeInternalFn, config, createDetails.changeSequenceNumber, createDetails.latestSummary, this.wipSummaryLogger, createDetails.telemetryNodeId);
385
+ const child = new SummarizerNode(this.logger, summarizeInternalFn, config, createDetails.summaryHandleId, createDetails.changeSequenceNumber, createDetails.lastSummaryReferenceSequenceNumber, this.wipSummaryLogger, createDetails.telemetryNodeId);
399
386
  // There may be additional state that has to be updated in this child. For example, if a summary is being
400
387
  // tracked, the child's summary tracking state needs to be updated too. Same goes for pendingSummaries we might
401
388
  // have outstanding on the parent in case we realize nodes in between Summary Op and Summary Ack.
@@ -413,23 +400,23 @@ class SummarizerNode {
413
400
  * @returns the details needed to create the child node.
414
401
  */
415
402
  getCreateDetailsForChild(id, createParam) {
416
- let latestSummary;
403
+ let childLastSummaryReferenceSequenceNumber;
417
404
  let changeSequenceNumber;
418
- const parentLatestSummary = this._latestSummary;
405
+ const parentLastSummaryReferenceSequenceNumber = this._lastSummaryReferenceSequenceNumber;
419
406
  switch (createParam.type) {
420
407
  case internal_2.CreateSummarizerNodeSource.FromAttach: {
421
- if (parentLatestSummary !== undefined &&
422
- createParam.sequenceNumber <= parentLatestSummary.referenceSequenceNumber) {
408
+ if (parentLastSummaryReferenceSequenceNumber !== undefined &&
409
+ createParam.sequenceNumber <= parentLastSummaryReferenceSequenceNumber) {
423
410
  // Prioritize latest summary if it was after this node was attached.
424
- latestSummary = parentLatestSummary.createForChild(id);
411
+ childLastSummaryReferenceSequenceNumber = parentLastSummaryReferenceSequenceNumber;
425
412
  }
426
413
  changeSequenceNumber = createParam.sequenceNumber;
427
414
  break;
428
415
  }
429
416
  case internal_2.CreateSummarizerNodeSource.FromSummary:
430
417
  case internal_2.CreateSummarizerNodeSource.Local: {
431
- latestSummary = parentLatestSummary?.createForChild(id);
432
- changeSequenceNumber = parentLatestSummary?.referenceSequenceNumber ?? -1;
418
+ childLastSummaryReferenceSequenceNumber = parentLastSummaryReferenceSequenceNumber;
419
+ changeSequenceNumber = parentLastSummaryReferenceSequenceNumber ?? -1;
433
420
  break;
434
421
  }
435
422
  default: {
@@ -438,10 +425,12 @@ class SummarizerNode {
438
425
  }
439
426
  }
440
427
  const childTelemetryNodeId = `${this.telemetryNodeId ?? ""}/${id}`;
428
+ const childSummaryHandleId = this._summaryHandleId.createChildPath(summarizerNodeUtils_js_1.EscapedPath.create(id));
441
429
  return {
442
- latestSummary,
443
430
  changeSequenceNumber,
444
431
  telemetryNodeId: childTelemetryNodeId,
432
+ summaryHandleId: childSummaryHandleId,
433
+ lastSummaryReferenceSequenceNumber: childLastSummaryReferenceSequenceNumber,
445
434
  };
446
435
  }
447
436
  /**
@@ -460,19 +449,14 @@ class SummarizerNode {
460
449
  child.wipReferenceSequenceNumber = this.wipReferenceSequenceNumber;
461
450
  }
462
451
  // In case we have pending summaries on the parent, let's initialize it on the child.
463
- if (child._latestSummary !== undefined) {
464
- for (const [key, value] of this.pendingSummaries.entries()) {
465
- const newLatestSummaryNode = new summarizerNodeUtils_js_1.SummaryNode({
466
- referenceSequenceNumber: value.referenceSequenceNumber,
467
- basePath: child._latestSummary.basePath,
468
- localPath: child._latestSummary.localPath,
469
- });
470
- child.addPendingSummary(key, newLatestSummaryNode);
471
- }
452
+ if (child._lastSummaryReferenceSequenceNumber !== undefined) {
453
+ this.pendingSummaries.forEach((pendingSummaryInfo, proposedHandle) => {
454
+ child.addPendingSummary(proposedHandle, pendingSummaryInfo);
455
+ });
472
456
  }
473
457
  }
474
- addPendingSummary(key, summary) {
475
- this.pendingSummaries.set(key, summary);
458
+ addPendingSummary(key, pendingSummaryInfo) {
459
+ this.pendingSummaries.set(key, pendingSummaryInfo);
476
460
  }
477
461
  /**
478
462
  * Tells whether summary tracking is in progress. True if "startSummary" API is called before summarize.
@@ -505,8 +489,6 @@ exports.SummarizerNode = SummarizerNode;
505
489
  * or undefined if not loaded from summary
506
490
  * @param config - Configure behavior of summarizer node
507
491
  */
508
- const createRootSummarizerNode = (logger, summarizeInternalFn, changeSequenceNumber, referenceSequenceNumber, config = {}) => new SummarizerNode(logger, summarizeInternalFn, config, changeSequenceNumber, referenceSequenceNumber === undefined
509
- ? undefined
510
- : summarizerNodeUtils_js_1.SummaryNode.createForRoot(referenceSequenceNumber), undefined /* wipSummaryLogger */, "" /* telemetryNodeId */);
492
+ const createRootSummarizerNode = (logger, summarizeInternalFn, changeSequenceNumber, referenceSequenceNumber, config = {}) => new SummarizerNode(logger, summarizeInternalFn, config, summarizerNodeUtils_js_1.EscapedPath.create("") /* summaryHandleId */, changeSequenceNumber, referenceSequenceNumber, undefined /* wipSummaryLogger */, "" /* telemetryNodeId */);
511
493
  exports.createRootSummarizerNode = createRootSummarizerNode;
512
494
  //# sourceMappingURL=summarizerNode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"summarizerNode.js","sourceRoot":"","sources":["../../../src/summary/summarizerNode/summarizerNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA8E;AAC9E,2EAAiE;AAKjE,2EASsD;AACtD,qEAAoE;AAEpE,uEAOkD;AAElD,qEASkC;AAIlC;;;;;;;;;;;;GAYG;AACH,MAAa,cAAc;IAC1B;;;OAGG;IACH,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,cAAc,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,IAAI,cAAc,CACjB,MAAM,EACN,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACpB,uBAAuB,KAAK,SAAS;IACpC,CAAC,CAAC,SAAS;IACX,CAAC,CAAC,oCAAW,CAAC,aAAa,CAAC,uBAAuB,CAAC,EACrD,SAAS,CAAC,sBAAsB,EAChC,EAAE,CAAC,qBAAqB,CACxB,CAAC;AAjBU,QAAA,wBAAwB,4BAiBlC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { SummaryType } from \"@fluidframework/driver-definitions\";\nimport {\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIExperimentalIncrementalSummaryContext,\n\tITelemetryContext,\n\tCreateChildSummarizerNodeParam,\n\tCreateSummarizerNodeSource,\n\tISummarizeResult,\n\tISummarizerNode,\n\tISummarizerNodeConfig,\n\tSummarizeInternalFn,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { mergeStats } from \"@fluidframework/runtime-utils/internal\";\nimport { type ITelemetryErrorEventExt } from \"@fluidframework/telemetry-utils/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tLoggingError,\n\tPerformanceEvent,\n\tTelemetryDataTag,\n\tcreateChildLogger,\n\ttagCodeArtifacts,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEscapedPath,\n\tICreateChildDetails,\n\tIRefreshSummaryResult,\n\tIStartSummaryResult,\n\tISummarizerNodeRootContract,\n\tSummaryNode,\n\tValidateSummaryResult,\n\tparseSummaryForSubtrees,\n} from \"./summarizerNodeUtils.js\";\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\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\t/**\n\t * In order to produce a summary with a summarizer node, the summarizer node system must be notified a summary has\n\t * started. This is done by calling startSummary. This will track the reference sequence number of the summary and\n\t * run some validation checks to ensure the summary is correct.\n\t * @param referenceSequenceNumber - the number of ops processed up to this point\n\t * @param summaryLogger - the logger to use for the summary\n\t * @param latestSummaryRefSeqNum - the reference sequence number of the latest summary. Another way to think about\n\t * it is the reference sequence number of the previous summary.\n\t * @returns the number of nodes in the tree, the number of nodes that are invalid, and the different types of\n\t * sequence number mismatches\n\t */\n\tpublic startSummary(\n\t\treferenceSequenceNumber: number,\n\t\tsummaryLogger: ITelemetryBaseLogger,\n\t\tlatestSummaryRefSeqNum: number,\n\t): IStartSummaryResult {\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\tlet nodes = 1;\n\t\tlet invalidNodes = 0;\n\t\tconst sequenceNumberMismatchKeySet = new Set<string>();\n\t\tconst nodeLatestSummaryRefSeqNum = this._latestSummary?.referenceSequenceNumber;\n\t\tif (\n\t\t\tnodeLatestSummaryRefSeqNum !== undefined &&\n\t\t\tlatestSummaryRefSeqNum !== nodeLatestSummaryRefSeqNum\n\t\t) {\n\t\t\tinvalidNodes++;\n\t\t\tsequenceNumberMismatchKeySet.add(\n\t\t\t\t`${latestSummaryRefSeqNum}-${nodeLatestSummaryRefSeqNum}`,\n\t\t\t);\n\t\t}\n\n\t\tthis.wipSummaryLogger = summaryLogger;\n\n\t\tfor (const child of this.children.values()) {\n\t\t\tconst childStartSummaryResult = child.startSummary(\n\t\t\t\treferenceSequenceNumber,\n\t\t\t\tthis.wipSummaryLogger,\n\t\t\t\tlatestSummaryRefSeqNum,\n\t\t\t);\n\t\t\tnodes += childStartSummaryResult.nodes;\n\t\t\tinvalidNodes += childStartSummaryResult.invalidNodes;\n\t\t\tfor (const invalidSequenceNumber of childStartSummaryResult.mismatchNumbers) {\n\t\t\t\tsequenceNumberMismatchKeySet.add(invalidSequenceNumber);\n\t\t\t}\n\t\t}\n\t\tthis.wipReferenceSequenceNumber = referenceSequenceNumber;\n\t\treturn {\n\t\t\tnodes,\n\t\t\tinvalidNodes,\n\t\t\tmismatchNumbers: sequenceNumberMismatchKeySet,\n\t\t};\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\t// If trackState is false, call summarize internal directly and don't track any state.\n\t\tif (!trackState) {\n\t\t\treturn this.summarizeInternalFn(fullTree, trackState, telemetryContext);\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\tlet incrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined;\n\t\tif (!fullTree) {\n\t\t\tassert(\n\t\t\t\tthis.wipReferenceSequenceNumber !== undefined,\n\t\t\t\t0x5df /* Summarize should not be called when not tracking the summary */,\n\t\t\t);\n\t\t\tincrementalSummaryContext =\n\t\t\t\tthis._latestSummary !== undefined\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tsummarySequenceNumber: this.wipReferenceSequenceNumber,\n\t\t\t\t\t\t\tlatestSummarySequenceNumber: this._latestSummary.referenceSequenceNumber,\n\t\t\t\t\t\t\t// TODO: remove summaryPath\n\t\t\t\t\t\t\tsummaryPath: this._latestSummary.fullPath.path,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined;\n\t\t}\n\n\t\tconst result = await this.summarizeInternalFn(\n\t\t\tfullTree,\n\t\t\ttrackState,\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) {\n\t\tthis.completeSummaryCore(\n\t\t\tproposalHandle,\n\t\t\tundefined /* parentPath */,\n\t\t\tfalse /* parentSkipRecursion */,\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) {\n\t\tassert(\n\t\t\tthis.wipReferenceSequenceNumber !== undefined,\n\t\t\t0x1a4 /* \"Not tracking a summary\" */,\n\t\t);\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);\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, we skip the update.\n\t * If the current summary is behind, then we do not refresh.\n\t *\n\t * @returns true if the summary is tracked by this node, false otherwise.\n\t */\n\tpublic async refreshLatestSummary(\n\t\tproposalHandle: string,\n\t\tsummaryRefSeq: number,\n\t): Promise<IRefreshSummaryResult> {\n\t\tconst eventProps: {\n\t\t\tproposalHandle: string | undefined;\n\t\t\tsummaryRefSeq: number;\n\t\t\treferenceSequenceNumber: number;\n\t\t\tisSummaryTracked?: boolean;\n\t\t\tpendingSummaryFound?: 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\tlet isSummaryTracked = false;\n\t\t\t\tlet isSummaryNewer = false;\n\n\t\t\t\tif (summaryRefSeq > this.referenceSequenceNumber) {\n\t\t\t\t\tisSummaryNewer = true;\n\t\t\t\t}\n\t\t\t\tconst maybeSummaryNode = this.pendingSummaries.get(proposalHandle);\n\t\t\t\tif (maybeSummaryNode !== undefined) {\n\t\t\t\t\tthis.refreshLatestSummaryFromPending(\n\t\t\t\t\t\tproposalHandle,\n\t\t\t\t\t\tmaybeSummaryNode.referenceSequenceNumber,\n\t\t\t\t\t);\n\t\t\t\t\tisSummaryTracked = true;\n\t\t\t\t}\n\t\t\t\tevent.end({ ...eventProps, isSummaryNewer, pendingSummaryFound: isSummaryTracked });\n\t\t\t\treturn { isSummaryTracked, isSummaryNewer };\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\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\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 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}\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\tcase CreateSummarizerNodeSource.Local: {\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\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: ITelemetryErrorEventExt): 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 /* 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,kEAA8E;AAC9E,2EAAiE;AAKjE,2EASsD;AACtD,qEAAoE;AAEpE,uEAOkD;AAElD,qEAQkC;AAIlC;;;;;;;;;;;;GAYG;AACH,MAAa,cAAc;IAC1B;;;OAGG;IACH,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,mCAAmC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED;;;OAGG;IACH,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;IACzC,CAAC;IAmBD;;;OAGG;IACH,YACC,UAAgC,EACf,mBAAwC,EACzD,MAA6B;IAC7B,yCAAyC;IACxB,gBAA6B,EACtC,qBAA6B;IACrC,iHAAiH;IACzG,mCAA4C,EAC1C,gBAAuC;IACjD,oEAAoE;IAC1D,eAAwB;QATjB,wBAAmB,GAAnB,mBAAmB,CAAqB;QAGxC,qBAAgB,GAAhB,gBAAgB,CAAa;QACtC,0BAAqB,GAArB,qBAAqB,CAAQ;QAE7B,wCAAmC,GAAnC,mCAAmC,CAA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W,EAAE,kBAAsC;QAC9E,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,mBAAmB;QACzB,OAAO,IAAI,CAAC,0BAA0B,KAAK,SAAS,CAAC;IACtD,CAAC;IAED;;OAEG;IACO,oBAAoB,CAAC,UAAmC;QACjE,MAAM,KAAK,GAAG,IAAI,uBAAY,CAAC,UAAU,CAAC,SAAS,EAAE;YACpD,GAAG,UAAU;YACb,uBAAuB,EAAE,IAAI,CAAC,0BAA0B;YACxD,GAAG,IAAA,2BAAgB,EAAC;gBACnB,EAAE,EAAE,IAAI,CAAC,eAAe;aACxB,CAAC;SACF,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC9C,MAAM,KAAK,CAAC;IACb,CAAC;CACD;AAtkBD,wCAskBC;AAED;;;;;;;;GAQG;AACI,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,oCAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,qBAAqB,EAC5C,oBAAoB,EACpB,uBAAuB,EACvB,SAAS,CAAC,sBAAsB,EAChC,EAAE,CAAC,qBAAqB,CACxB,CAAC;AAhBU,QAAA,wBAAwB,4BAgBlC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { SummaryType } from \"@fluidframework/driver-definitions\";\nimport {\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIExperimentalIncrementalSummaryContext,\n\tITelemetryContext,\n\tCreateChildSummarizerNodeParam,\n\tCreateSummarizerNodeSource,\n\tISummarizeResult,\n\tISummarizerNode,\n\tISummarizerNodeConfig,\n\tSummarizeInternalFn,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { mergeStats } from \"@fluidframework/runtime-utils/internal\";\nimport { type ITelemetryErrorEventExt } from \"@fluidframework/telemetry-utils/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tLoggingError,\n\tPerformanceEvent,\n\tTelemetryDataTag,\n\tcreateChildLogger,\n\ttagCodeArtifacts,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEscapedPath,\n\tICreateChildDetails,\n\tIRefreshSummaryResult,\n\tIStartSummaryResult,\n\tISummarizerNodeRootContract,\n\tValidateSummaryResult,\n\tPendingSummaryInfo,\n} from \"./summarizerNodeUtils.js\";\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._lastSummaryReferenceSequenceNumber ?? 0;\n\t}\n\n\t/**\n\t * returns the handle of the last successful summary of this summarizerNode in string format\n\t * (this getter is primarily only used in the test code)\n\t */\n\tpublic get summaryHandleId(): string {\n\t\treturn this._summaryHandleId.toString();\n\t}\n\n\tprotected readonly children = new Map<string, SummarizerNode>();\n\t/**\n\t * Key value pair of summaries submitted by this client which are not yet acked.\n\t * Key is the proposalHandle and value is the summary op's referece sequence number.\n\t */\n\tprotected readonly pendingSummaries = new Map<string, PendingSummaryInfo>();\n\tprotected wipReferenceSequenceNumber: number | undefined;\n\t/**\n\t * True if the current node was summarized during the current summary process\n\t * This flag is used to identify scenarios where summarize was not called on a node.\n\t * For example, this node was created after its parent was already summarized due to out-of-order realization via application code.\n\t */\n\tprivate wipSummarizeCalled: boolean = false;\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\t/** Encoded handle or path to the node */\n\t\tprivate readonly _summaryHandleId: EscapedPath,\n\t\tprivate _changeSequenceNumber: number,\n\t\t/** Summary reference sequence number, i.e. last sequence number seen when last successful summary was created */\n\t\tprivate _lastSummaryReferenceSequenceNumber?: number,\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\t/**\n\t * In order to produce a summary with a summarizer node, the summarizer node system must be notified a summary has\n\t * started. This is done by calling startSummary. This will track the reference sequence number of the summary and\n\t * run some validation checks to ensure the summary is correct.\n\t * @param referenceSequenceNumber - the number of ops processed up to this point\n\t * @param summaryLogger - the logger to use for the summary\n\t * @param latestSummaryRefSeqNum - the reference sequence number of the latest summary. Another way to think about\n\t * it is the reference sequence number of the previous summary.\n\t * @returns the number of nodes in the tree, the number of nodes that are invalid, and the different types of\n\t * sequence number mismatches\n\t */\n\tpublic startSummary(\n\t\treferenceSequenceNumber: number,\n\t\tsummaryLogger: ITelemetryBaseLogger,\n\t\tlatestSummaryRefSeqNum: number,\n\t): IStartSummaryResult {\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\tlet nodes = 1; // number of summarizerNodes at the start of the summary\n\t\tlet invalidNodes = 0;\n\t\tconst sequenceNumberMismatchKeySet = new Set<string>();\n\t\tconst nodeLatestSummaryRefSeqNum = this._lastSummaryReferenceSequenceNumber;\n\t\tif (\n\t\t\tnodeLatestSummaryRefSeqNum !== undefined &&\n\t\t\tlatestSummaryRefSeqNum !== nodeLatestSummaryRefSeqNum\n\t\t) {\n\t\t\tinvalidNodes++;\n\t\t\tsequenceNumberMismatchKeySet.add(\n\t\t\t\t`${latestSummaryRefSeqNum}-${nodeLatestSummaryRefSeqNum}`,\n\t\t\t);\n\t\t}\n\n\t\tthis.wipSummaryLogger = summaryLogger;\n\n\t\tfor (const child of this.children.values()) {\n\t\t\tconst childStartSummaryResult = child.startSummary(\n\t\t\t\treferenceSequenceNumber,\n\t\t\t\tthis.wipSummaryLogger,\n\t\t\t\tlatestSummaryRefSeqNum,\n\t\t\t);\n\t\t\tnodes += childStartSummaryResult.nodes;\n\t\t\tinvalidNodes += childStartSummaryResult.invalidNodes;\n\t\t\tfor (const invalidSequenceNumber of childStartSummaryResult.mismatchNumbers) {\n\t\t\t\tsequenceNumberMismatchKeySet.add(invalidSequenceNumber);\n\t\t\t}\n\t\t}\n\t\tthis.wipReferenceSequenceNumber = referenceSequenceNumber;\n\t\treturn {\n\t\t\tnodes,\n\t\t\tinvalidNodes,\n\t\t\tmismatchNumbers: sequenceNumberMismatchKeySet,\n\t\t};\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\t// If trackState is false, call summarize internal directly and don't track any state.\n\t\tif (!trackState) {\n\t\t\treturn this.summarizeInternalFn(fullTree, trackState, telemetryContext);\n\t\t}\n\n\t\t// Set to wipSummarizeCalled true to represent that current node was included in the summary process.\n\t\tthis.wipSummarizeCalled = true;\n\n\t\t// Try to reuse the tree if unchanged\n\t\tif (this.canReuseHandle && !fullTree && !this.hasChanged()) {\n\t\t\tif (this._lastSummaryReferenceSequenceNumber !== undefined) {\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: this.summaryHandleId,\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\tlet incrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined;\n\t\tif (!fullTree) {\n\t\t\tassert(\n\t\t\t\tthis.wipReferenceSequenceNumber !== undefined,\n\t\t\t\t0x5df /* Summarize should not be called when not tracking the summary */,\n\t\t\t);\n\t\t\tincrementalSummaryContext =\n\t\t\t\tthis._lastSummaryReferenceSequenceNumber !== undefined\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tsummarySequenceNumber: this.wipReferenceSequenceNumber,\n\t\t\t\t\t\t\tlatestSummarySequenceNumber: this._lastSummaryReferenceSequenceNumber,\n\t\t\t\t\t\t\t// TODO: remove summaryPath.\n\t\t\t\t\t\t\tsummaryPath: this.summaryHandleId,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined;\n\t\t}\n\n\t\tconst result = await this.summarizeInternalFn(\n\t\t\tfullTree,\n\t\t\ttrackState,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t);\n\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 wipSummarizeCalled must be set.\n\t\tif (parentSkipRecursion || this.wipSummarizeCalled) {\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) {\n\t\tthis.completeSummaryCore(proposalHandle, false /* parentSkipRecursion */);\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(proposalHandle: string, parentSkipRecursion: boolean) {\n\t\tassert(\n\t\t\tthis.wipReferenceSequenceNumber !== undefined,\n\t\t\t0x1a4 /* \"Not tracking a summary\" */,\n\t\t);\n\t\tif (parentSkipRecursion) {\n\t\t\tif (this._lastSummaryReferenceSequenceNumber === undefined) {\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\tfor (const child of this.children.values()) {\n\t\t\tchild.completeSummaryCore(proposalHandle, this.wipSkipRecursion || parentSkipRecursion);\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, {\n\t\t\treferenceSequenceNumber: this.wipReferenceSequenceNumber,\n\t\t});\n\t\tthis.clearSummary();\n\t}\n\n\tpublic clearSummary() {\n\t\tthis.wipReferenceSequenceNumber = undefined;\n\t\tthis.wipSummarizeCalled = false;\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, we skip the update.\n\t * If the current summary is behind, then we do not refresh.\n\t * @param proposalHandle - Handle of the generated / uploaded summary.\n\t * @param summaryRefSeq - Reference sequence of the acked summary\n\t * @returns true if the summary is tracked by this node, false otherwise.\n\t */\n\tpublic async refreshLatestSummary(\n\t\tproposalHandle: string,\n\t\tsummaryRefSeq: number,\n\t): Promise<IRefreshSummaryResult> {\n\t\tconst eventProps: {\n\t\t\tproposalHandle: string | undefined;\n\t\t\tsummaryRefSeq: number;\n\t\t\treferenceSequenceNumber: number;\n\t\t\tisSummaryTracked?: boolean;\n\t\t\tpendingSummaryFound?: 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\tlet isSummaryTracked = false;\n\t\t\t\tlet isSummaryNewer = false;\n\n\t\t\t\tif (summaryRefSeq > this.referenceSequenceNumber) {\n\t\t\t\t\tisSummaryNewer = true;\n\t\t\t\t}\n\n\t\t\t\t// If the acked summary is found in the pendingSummaries, it means the summary was created and tracked by the current client\n\t\t\t\t// so set the isSummaryTracked to true.\n\t\t\t\tconst pendingSummary = this.pendingSummaries.get(proposalHandle);\n\t\t\t\tif (pendingSummary?.referenceSequenceNumber !== undefined) {\n\t\t\t\t\tisSummaryTracked = true;\n\t\t\t\t\t// update the pendingSummariesMap for the root and all child summarizerNodes\n\t\t\t\t\tthis.refreshLatestSummaryFromPending(\n\t\t\t\t\t\tproposalHandle,\n\t\t\t\t\t\tpendingSummary.referenceSequenceNumber,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tevent.end({ ...eventProps, isSummaryNewer, pendingSummaryFound: isSummaryTracked });\n\t\t\t\treturn { isSummaryTracked, isSummaryNewer };\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 pendingSummary = this.pendingSummaries.get(proposalHandle);\n\t\tif (pendingSummary === 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._lastSummaryReferenceSequenceNumber === 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 === pendingSummary.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\t// Delete all summaries whose reference sequence number is smaller than the one just acked.\n\t\tfor (const [key, summary] of this.pendingSummaries) {\n\t\t\tif (summary.referenceSequenceNumber < referenceSequenceNumber) {\n\t\t\t\tthis.pendingSummaries.delete(key);\n\t\t\t}\n\t\t}\n\t\t// Update the latest successful summary reference number\n\t\tthis._lastSummaryReferenceSequenceNumber = pendingSummary.referenceSequenceNumber;\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\tpublic updateBaseSummaryState(snapshot: ISnapshotTree) {\n\t\t// Function deprecated. Empty declaration is kept around to compat failures.\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\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.summaryHandleId,\n\t\t\tcreateDetails.changeSequenceNumber,\n\t\t\tcreateDetails.lastSummaryReferenceSequenceNumber,\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 childLastSummaryReferenceSequenceNumber: number | undefined;\n\t\tlet changeSequenceNumber: number;\n\n\t\tconst parentLastSummaryReferenceSequenceNumber = this._lastSummaryReferenceSequenceNumber;\n\t\tswitch (createParam.type) {\n\t\t\tcase CreateSummarizerNodeSource.FromAttach: {\n\t\t\t\tif (\n\t\t\t\t\tparentLastSummaryReferenceSequenceNumber !== undefined &&\n\t\t\t\t\tcreateParam.sequenceNumber <= parentLastSummaryReferenceSequenceNumber\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\tchildLastSummaryReferenceSequenceNumber = parentLastSummaryReferenceSequenceNumber;\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\tcase CreateSummarizerNodeSource.Local: {\n\t\t\t\tchildLastSummaryReferenceSequenceNumber = parentLastSummaryReferenceSequenceNumber;\n\t\t\t\tchangeSequenceNumber = parentLastSummaryReferenceSequenceNumber ?? -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\t\tconst childSummaryHandleId = this._summaryHandleId.createChildPath(EscapedPath.create(id));\n\n\t\treturn {\n\t\t\tchangeSequenceNumber,\n\t\t\ttelemetryNodeId: childTelemetryNodeId,\n\t\t\tsummaryHandleId: childSummaryHandleId,\n\t\t\tlastSummaryReferenceSequenceNumber: childLastSummaryReferenceSequenceNumber,\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._lastSummaryReferenceSequenceNumber !== undefined) {\n\t\t\tthis.pendingSummaries.forEach((pendingSummaryInfo, proposedHandle) => {\n\t\t\t\tchild.addPendingSummary(proposedHandle, pendingSummaryInfo);\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected addPendingSummary(key: string, pendingSummaryInfo: PendingSummaryInfo) {\n\t\tthis.pendingSummaries.set(key, pendingSummaryInfo);\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: ITelemetryErrorEventExt): 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\tEscapedPath.create(\"\") /* summaryHandleId */,\n\t\tchangeSequenceNumber,\n\t\treferenceSequenceNumber,\n\t\tundefined /* wipSummaryLogger */,\n\t\t\"\" /* telemetryNodeId */,\n\t);\n"]}