@fluidframework/container-runtime 2.20.0 → 2.21.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.
- package/.eslintrc.cjs +36 -6
- package/CHANGELOG.md +38 -0
- package/api-report/container-runtime.legacy.alpha.api.md +31 -31
- package/dist/batchTracker.d.ts +1 -2
- package/dist/batchTracker.d.ts.map +1 -1
- package/dist/batchTracker.js +1 -1
- package/dist/batchTracker.js.map +1 -1
- package/dist/blobManager/blobManager.d.ts.map +1 -1
- package/dist/blobManager/blobManager.js +14 -11
- package/dist/blobManager/blobManager.js.map +1 -1
- package/dist/blobManager/blobManagerSnapSum.d.ts +1 -0
- package/dist/blobManager/blobManagerSnapSum.d.ts.map +1 -1
- package/dist/blobManager/blobManagerSnapSum.js +7 -5
- package/dist/blobManager/blobManagerSnapSum.js.map +1 -1
- package/dist/channelCollection.d.ts.map +1 -1
- package/dist/channelCollection.js +63 -41
- package/dist/channelCollection.js.map +1 -1
- package/dist/connectionTelemetry.d.ts +2 -2
- package/dist/connectionTelemetry.d.ts.map +1 -1
- package/dist/connectionTelemetry.js +4 -4
- package/dist/connectionTelemetry.js.map +1 -1
- package/dist/containerRuntime.d.ts +14 -30
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +264 -194
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStore.js +6 -3
- package/dist/dataStore.js.map +1 -1
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +16 -11
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStoreContexts.d.ts.map +1 -1
- package/dist/dataStoreContexts.js +1 -0
- package/dist/dataStoreContexts.js.map +1 -1
- package/dist/deltaScheduler.d.ts.map +1 -1
- package/dist/deltaScheduler.js +5 -5
- package/dist/deltaScheduler.js.map +1 -1
- package/dist/gc/garbageCollection.d.ts.map +1 -1
- package/dist/gc/garbageCollection.js +36 -14
- package/dist/gc/garbageCollection.js.map +1 -1
- package/dist/gc/gcConfigs.d.ts.map +1 -1
- package/dist/gc/gcConfigs.js +2 -0
- package/dist/gc/gcConfigs.js.map +1 -1
- package/dist/gc/gcDefinitions.d.ts +8 -0
- package/dist/gc/gcDefinitions.d.ts.map +1 -1
- package/dist/gc/gcDefinitions.js +1 -0
- package/dist/gc/gcDefinitions.js.map +1 -1
- package/dist/gc/gcHelpers.d.ts.map +1 -1
- package/dist/gc/gcHelpers.js +8 -5
- package/dist/gc/gcHelpers.js.map +1 -1
- package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -1
- package/dist/gc/gcSummaryStateTracker.js +2 -1
- package/dist/gc/gcSummaryStateTracker.js.map +1 -1
- package/dist/gc/gcTelemetry.d.ts.map +1 -1
- package/dist/gc/gcTelemetry.js +29 -15
- package/dist/gc/gcTelemetry.js.map +1 -1
- package/dist/inboundBatchAggregator.js +3 -3
- package/dist/inboundBatchAggregator.js.map +1 -1
- package/dist/layerCompatState.d.ts +19 -0
- package/dist/layerCompatState.d.ts.map +1 -0
- package/dist/layerCompatState.js +64 -0
- package/dist/layerCompatState.js.map +1 -0
- package/dist/messageTypes.d.ts.map +1 -1
- package/dist/messageTypes.js.map +1 -1
- package/dist/opLifecycle/duplicateBatchDetector.js +2 -2
- package/dist/opLifecycle/duplicateBatchDetector.js.map +1 -1
- package/dist/opLifecycle/opCompressor.d.ts +3 -2
- package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
- package/dist/opLifecycle/opCompressor.js +13 -19
- package/dist/opLifecycle/opCompressor.js.map +1 -1
- package/dist/opLifecycle/opDecompressor.d.ts +3 -0
- package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
- package/dist/opLifecycle/opDecompressor.js +4 -1
- package/dist/opLifecycle/opDecompressor.js.map +1 -1
- package/dist/opLifecycle/opGroupingManager.d.ts +1 -1
- package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -1
- package/dist/opLifecycle/opGroupingManager.js +5 -3
- package/dist/opLifecycle/opGroupingManager.js.map +1 -1
- package/dist/opLifecycle/opSplitter.d.ts +13 -10
- package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
- package/dist/opLifecycle/opSplitter.js +14 -11
- package/dist/opLifecycle/opSplitter.js.map +1 -1
- package/dist/opLifecycle/outbox.d.ts +3 -3
- package/dist/opLifecycle/outbox.d.ts.map +1 -1
- package/dist/opLifecycle/outbox.js +11 -15
- package/dist/opLifecycle/outbox.js.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.js +3 -1
- package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/pendingStateManager.d.ts +3 -4
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +11 -10
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/summary/documentSchema.d.ts +7 -0
- package/dist/summary/documentSchema.d.ts.map +1 -1
- package/dist/summary/documentSchema.js +6 -4
- package/dist/summary/documentSchema.js.map +1 -1
- package/dist/summary/orderedClientElection.d.ts +1 -0
- package/dist/summary/orderedClientElection.d.ts.map +1 -1
- package/dist/summary/orderedClientElection.js +13 -11
- package/dist/summary/orderedClientElection.js.map +1 -1
- package/dist/summary/runWhileConnectedCoordinator.d.ts +1 -0
- package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -1
- package/dist/summary/runWhileConnectedCoordinator.js +7 -2
- package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
- package/dist/summary/runningSummarizer.d.ts +2 -2
- package/dist/summary/runningSummarizer.d.ts.map +1 -1
- package/dist/summary/runningSummarizer.js +38 -17
- package/dist/summary/runningSummarizer.js.map +1 -1
- package/dist/summary/summarizer.d.ts +1 -0
- package/dist/summary/summarizer.d.ts.map +1 -1
- package/dist/summary/summarizer.js +18 -9
- package/dist/summary/summarizer.js.map +1 -1
- package/dist/summary/summarizerClientElection.d.ts.map +1 -1
- package/dist/summary/summarizerClientElection.js +1 -0
- package/dist/summary/summarizerClientElection.js.map +1 -1
- package/dist/summary/summarizerHeuristics.js +1 -1
- package/dist/summary/summarizerHeuristics.js.map +1 -1
- package/dist/summary/summarizerNode/index.d.ts.map +1 -1
- package/dist/summary/summarizerNode/index.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
- package/dist/summary/summarizerNode/summarizerNode.js +30 -31
- package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +1 -1
- package/dist/summary/summarizerNode/summarizerNodeWithGc.js +3 -3
- package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
- package/dist/summary/summarizerTypes.d.ts +7 -0
- package/dist/summary/summarizerTypes.d.ts.map +1 -1
- package/dist/summary/summarizerTypes.js.map +1 -1
- package/dist/summary/summaryCollection.d.ts +3 -4
- package/dist/summary/summaryCollection.d.ts.map +1 -1
- package/dist/summary/summaryCollection.js +9 -6
- package/dist/summary/summaryCollection.js.map +1 -1
- package/dist/summary/summaryFormat.d.ts +4 -1
- package/dist/summary/summaryFormat.d.ts.map +1 -1
- package/dist/summary/summaryFormat.js +3 -2
- package/dist/summary/summaryFormat.js.map +1 -1
- package/dist/summary/summaryGenerator.d.ts.map +1 -1
- package/dist/summary/summaryGenerator.js +19 -8
- package/dist/summary/summaryGenerator.js.map +1 -1
- package/dist/summary/summaryManager.d.ts.map +1 -1
- package/dist/summary/summaryManager.js +12 -9
- package/dist/summary/summaryManager.js.map +1 -1
- package/lib/batchTracker.d.ts +1 -2
- package/lib/batchTracker.d.ts.map +1 -1
- package/lib/batchTracker.js +2 -2
- package/lib/batchTracker.js.map +1 -1
- package/lib/blobManager/blobManager.d.ts.map +1 -1
- package/lib/blobManager/blobManager.js +14 -11
- package/lib/blobManager/blobManager.js.map +1 -1
- package/lib/blobManager/blobManagerSnapSum.d.ts +1 -0
- package/lib/blobManager/blobManagerSnapSum.d.ts.map +1 -1
- package/lib/blobManager/blobManagerSnapSum.js +7 -5
- package/lib/blobManager/blobManagerSnapSum.js.map +1 -1
- package/lib/channelCollection.d.ts.map +1 -1
- package/lib/channelCollection.js +66 -42
- package/lib/channelCollection.js.map +1 -1
- package/lib/connectionTelemetry.d.ts +2 -2
- package/lib/connectionTelemetry.d.ts.map +1 -1
- package/lib/connectionTelemetry.js +5 -5
- package/lib/connectionTelemetry.js.map +1 -1
- package/lib/containerRuntime.d.ts +14 -30
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +271 -196
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStore.js +6 -3
- package/lib/dataStore.js.map +1 -1
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +16 -11
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStoreContexts.d.ts.map +1 -1
- package/lib/dataStoreContexts.js +1 -0
- package/lib/dataStoreContexts.js.map +1 -1
- package/lib/deltaScheduler.d.ts.map +1 -1
- package/lib/deltaScheduler.js +6 -6
- package/lib/deltaScheduler.js.map +1 -1
- package/lib/gc/garbageCollection.d.ts.map +1 -1
- package/lib/gc/garbageCollection.js +39 -15
- package/lib/gc/garbageCollection.js.map +1 -1
- package/lib/gc/gcConfigs.d.ts.map +1 -1
- package/lib/gc/gcConfigs.js +2 -0
- package/lib/gc/gcConfigs.js.map +1 -1
- package/lib/gc/gcDefinitions.d.ts +8 -0
- package/lib/gc/gcDefinitions.d.ts.map +1 -1
- package/lib/gc/gcDefinitions.js +1 -0
- package/lib/gc/gcDefinitions.js.map +1 -1
- package/lib/gc/gcHelpers.d.ts.map +1 -1
- package/lib/gc/gcHelpers.js +8 -5
- package/lib/gc/gcHelpers.js.map +1 -1
- package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -1
- package/lib/gc/gcSummaryStateTracker.js +2 -1
- package/lib/gc/gcSummaryStateTracker.js.map +1 -1
- package/lib/gc/gcTelemetry.d.ts.map +1 -1
- package/lib/gc/gcTelemetry.js +32 -16
- package/lib/gc/gcTelemetry.js.map +1 -1
- package/lib/inboundBatchAggregator.js +4 -4
- package/lib/inboundBatchAggregator.js.map +1 -1
- package/lib/layerCompatState.d.ts +19 -0
- package/lib/layerCompatState.d.ts.map +1 -0
- package/lib/layerCompatState.js +60 -0
- package/lib/layerCompatState.js.map +1 -0
- package/lib/messageTypes.d.ts.map +1 -1
- package/lib/messageTypes.js.map +1 -1
- package/lib/opLifecycle/duplicateBatchDetector.js +2 -2
- package/lib/opLifecycle/duplicateBatchDetector.js.map +1 -1
- package/lib/opLifecycle/opCompressor.d.ts +3 -2
- package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
- package/lib/opLifecycle/opCompressor.js +13 -19
- package/lib/opLifecycle/opCompressor.js.map +1 -1
- package/lib/opLifecycle/opDecompressor.d.ts +3 -0
- package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
- package/lib/opLifecycle/opDecompressor.js +4 -1
- package/lib/opLifecycle/opDecompressor.js.map +1 -1
- package/lib/opLifecycle/opGroupingManager.d.ts +1 -1
- package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -1
- package/lib/opLifecycle/opGroupingManager.js +5 -3
- package/lib/opLifecycle/opGroupingManager.js.map +1 -1
- package/lib/opLifecycle/opSplitter.d.ts +13 -10
- package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
- package/lib/opLifecycle/opSplitter.js +14 -11
- package/lib/opLifecycle/opSplitter.js.map +1 -1
- package/lib/opLifecycle/outbox.d.ts +3 -3
- package/lib/opLifecycle/outbox.d.ts.map +1 -1
- package/lib/opLifecycle/outbox.js +11 -15
- package/lib/opLifecycle/outbox.js.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.js +3 -1
- package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/pendingStateManager.d.ts +3 -4
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +12 -11
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/summary/documentSchema.d.ts +7 -0
- package/lib/summary/documentSchema.d.ts.map +1 -1
- package/lib/summary/documentSchema.js +6 -4
- package/lib/summary/documentSchema.js.map +1 -1
- package/lib/summary/orderedClientElection.d.ts +1 -0
- package/lib/summary/orderedClientElection.d.ts.map +1 -1
- package/lib/summary/orderedClientElection.js +13 -11
- package/lib/summary/orderedClientElection.js.map +1 -1
- package/lib/summary/runWhileConnectedCoordinator.d.ts +1 -0
- package/lib/summary/runWhileConnectedCoordinator.d.ts.map +1 -1
- package/lib/summary/runWhileConnectedCoordinator.js +7 -2
- package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
- package/lib/summary/runningSummarizer.d.ts +2 -2
- package/lib/summary/runningSummarizer.d.ts.map +1 -1
- package/lib/summary/runningSummarizer.js +38 -17
- package/lib/summary/runningSummarizer.js.map +1 -1
- package/lib/summary/summarizer.d.ts +1 -0
- package/lib/summary/summarizer.d.ts.map +1 -1
- package/lib/summary/summarizer.js +18 -9
- package/lib/summary/summarizer.js.map +1 -1
- package/lib/summary/summarizerClientElection.d.ts.map +1 -1
- package/lib/summary/summarizerClientElection.js +1 -0
- package/lib/summary/summarizerClientElection.js.map +1 -1
- package/lib/summary/summarizerHeuristics.js +1 -1
- package/lib/summary/summarizerHeuristics.js.map +1 -1
- package/lib/summary/summarizerNode/index.d.ts.map +1 -1
- package/lib/summary/summarizerNode/index.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
- package/lib/summary/summarizerNode/summarizerNode.js +30 -31
- package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +1 -1
- package/lib/summary/summarizerNode/summarizerNodeWithGc.js +3 -3
- package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
- package/lib/summary/summarizerTypes.d.ts +7 -0
- package/lib/summary/summarizerTypes.d.ts.map +1 -1
- package/lib/summary/summarizerTypes.js.map +1 -1
- package/lib/summary/summaryCollection.d.ts +3 -4
- package/lib/summary/summaryCollection.d.ts.map +1 -1
- package/lib/summary/summaryCollection.js +9 -6
- package/lib/summary/summaryCollection.js.map +1 -1
- package/lib/summary/summaryFormat.d.ts +4 -1
- package/lib/summary/summaryFormat.d.ts.map +1 -1
- package/lib/summary/summaryFormat.js +2 -2
- package/lib/summary/summaryFormat.js.map +1 -1
- package/lib/summary/summaryGenerator.d.ts.map +1 -1
- package/lib/summary/summaryGenerator.js +19 -8
- package/lib/summary/summaryGenerator.js.map +1 -1
- package/lib/summary/summaryManager.d.ts.map +1 -1
- package/lib/summary/summaryManager.js +12 -9
- package/lib/summary/summaryManager.js.map +1 -1
- package/package.json +21 -43
- package/src/batchTracker.ts +3 -3
- package/src/blobManager/blobManager.ts +16 -14
- package/src/blobManager/blobManagerSnapSum.ts +8 -8
- package/src/channelCollection.ts +63 -44
- package/src/connectionTelemetry.ts +12 -6
- package/src/containerRuntime.ts +306 -235
- package/src/dataStore.ts +6 -3
- package/src/dataStoreContext.ts +16 -16
- package/src/dataStoreContexts.ts +1 -0
- package/src/deltaScheduler.ts +6 -6
- package/src/gc/garbageCollection.ts +47 -20
- package/src/gc/gcConfigs.ts +9 -1
- package/src/gc/gcDefinitions.ts +12 -0
- package/src/gc/gcHelpers.ts +9 -4
- package/src/gc/gcSummaryStateTracker.ts +3 -1
- package/src/gc/gcTelemetry.ts +26 -11
- package/src/inboundBatchAggregator.ts +4 -4
- package/src/layerCompatState.ts +75 -0
- package/src/messageTypes.ts +2 -0
- package/src/opLifecycle/README.md +43 -34
- package/src/opLifecycle/duplicateBatchDetector.ts +2 -2
- package/src/opLifecycle/opCompressor.ts +16 -23
- package/src/opLifecycle/opDecompressor.ts +4 -1
- package/src/opLifecycle/opGroupingManager.ts +5 -4
- package/src/opLifecycle/opSplitter.ts +14 -11
- package/src/opLifecycle/outbox.ts +13 -20
- package/src/opLifecycle/remoteMessageProcessor.ts +3 -1
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +15 -10
- package/src/summary/documentSchema.ts +11 -4
- package/src/summary/orderedClientElection.ts +14 -11
- package/src/summary/runWhileConnectedCoordinator.ts +6 -0
- package/src/summary/runningSummarizer.ts +43 -19
- package/src/summary/summarizer.ts +24 -11
- package/src/summary/summarizerClientElection.ts +2 -0
- package/src/summary/summarizerHeuristics.ts +1 -1
- package/src/summary/summarizerNode/index.ts +1 -0
- package/src/summary/summarizerNode/summarizerNode.ts +32 -31
- package/src/summary/summarizerNode/summarizerNodeWithGc.ts +4 -4
- package/src/summary/summarizerTypes.ts +7 -0
- package/src/summary/summaryCollection.ts +19 -8
- package/src/summary/summaryFormat.ts +10 -5
- package/src/summary/summaryGenerator.ts +25 -10
- package/src/summary/summaryManager.ts +14 -12
- package/container-runtime.test-files.tar +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runningSummarizer.js","sourceRoot":"","sources":["../../src/summary/runningSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAQjE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAC5F,OAAO,EACN,gBAAgB,EAChB,WAAW,GAEX,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAEN,UAAU,EACV,iBAAiB,EACjB,4BAA4B,EAC5B,YAAY,GAEZ,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAuBrE,OAAO,EACN,qBAAqB,EAErB,sBAAsB,E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AC,gBAAgB,CACpB,EAAE,eAAe,EAAE,mBAAmB,MAAM,EAAE,EAAE,EAChD,gBAAgB,EAChB,cAAc,CACd,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAEO,sBAAsB;QAC7B,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YACxC,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,CACvC,uCAAuC,EACvC,IAAI,qBAAqB,CAAC,uCAAuC,CAAC,CAClE,CAAC;YACF,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QAClC,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tISummarizeEventProps,\n\tISummarizerEvents,\n\tISummarizerObservabilityProps,\n\tSummarizerStopReason,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport { IDisposable, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred, PromiseTimer, delay } from \"@fluidframework/core-utils/internal\";\nimport {\n\tDriverErrorTypes,\n\tMessageType,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tMonitoringContext,\n\tUsageError,\n\tcreateChildLogger,\n\tcreateChildMonitoringContext,\n\tisFluidError,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ISummaryConfiguration } from \"../containerRuntime.js\";\nimport { opSize } from \"../opProperties.js\";\n\nimport { SummarizeHeuristicRunner } from \"./summarizerHeuristics.js\";\nimport {\n\tEnqueueSummarizeResult,\n\tIEnqueueSummarizeOptions,\n\tIOnDemandSummarizeOptions,\n\tIRefreshSummaryAckOptions,\n\tISubmitSummaryOptions,\n\tISummarizeHeuristicData,\n\tISummarizeHeuristicRunner,\n\tISummarizeOptions,\n\tISummarizeResults,\n\tISummarizeRunnerTelemetry,\n\tISummarizeTelemetryProperties,\n\tISummarizerRuntime,\n\tISummaryCancellationToken,\n\tSubmitSummaryResult,\n\ttype IRetriableFailureError,\n} from \"./summarizerTypes.js\";\nimport {\n\tIAckedSummary,\n\tIClientSummaryWatcher,\n\tSummaryCollection,\n} from \"./summaryCollection.js\";\nimport {\n\tRetriableSummaryError,\n\tSummarizeReason,\n\tSummarizeResultBuilder,\n\tSummaryGenerator,\n\traceTimer,\n} from \"./summaryGenerator.js\";\n\nconst maxSummarizeAckWaitTime = 10 * 60 * 1000; // 10 minutes\n\n/**\n * The maximum number of summarization attempts that will be done by default in case of failures\n * that can be retried.\n */\nexport const defaultMaxAttempts = 2;\n/**\n * The default value for maximum number of summarization attempts that will be done for summarization failures where\n * submit fails and the failure can be retried.\n */\nexport const defaultMaxAttemptsForSubmitFailures = 5;\n\n/**\n * An instance of RunningSummarizer manages the heuristics for summarizing.\n * Until disposed, the instance of RunningSummarizer can assume that it is\n * in a state of running, meaning it is connected and initialized. It keeps\n * track of summaries that it is generating as they are broadcast and acked/nacked.\n * This object is created and controlled by Summarizer object.\n */\nexport class RunningSummarizer\n\textends TypedEventEmitter<ISummarizerEvents>\n\timplements IDisposable\n{\n\tpublic static async start(\n\t\tlogger: ITelemetryBaseLogger,\n\t\tsummaryWatcher: IClientSummaryWatcher,\n\t\tconfiguration: ISummaryConfiguration,\n\t\tsubmitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>,\n\t\trefreshLatestSummaryAckCallback: (options: IRefreshSummaryAckOptions) => Promise<void>,\n\t\theuristicData: ISummarizeHeuristicData,\n\t\tsummaryCollection: SummaryCollection,\n\t\tcancellationToken: ISummaryCancellationToken,\n\t\tstopSummarizerCallback: (reason: SummarizerStopReason) => void,\n\t\truntime: ISummarizerRuntime,\n\t): Promise<RunningSummarizer> {\n\t\tconst summarizer = new RunningSummarizer(\n\t\t\tlogger,\n\t\t\tsummaryWatcher,\n\t\t\tconfiguration,\n\t\t\tsubmitSummaryCallback,\n\t\t\trefreshLatestSummaryAckCallback,\n\t\t\theuristicData,\n\t\t\tsummaryCollection,\n\t\t\tcancellationToken,\n\t\t\tstopSummarizerCallback,\n\t\t\truntime,\n\t\t);\n\n\t\t// If there have been any acks newer that the one this client loaded from until now, process them before\n\t\t// starting the running summarizer which will trigger summary heuristics.\n\t\t// This is done primarily to handle scenarios where the summarizer loads from a cached snapshot and there\n\t\t// is newer one available. The ack for the newer summary is processed before summarizing because otherwise\n\t\t// that summary would fail as it has an older parent.\n\t\tlet nextReferenceSequenceNumber = runtime.deltaManager.initialSequenceNumber + 1;\n\t\tconst latestAck = summaryCollection.latestAck;\n\t\tif (\n\t\t\tlatestAck !== undefined &&\n\t\t\tlatestAck.summaryOp.referenceSequenceNumber >= nextReferenceSequenceNumber\n\t\t) {\n\t\t\tawait summarizer.handleSummaryAck(latestAck);\n\t\t\tnextReferenceSequenceNumber = latestAck.summaryOp.referenceSequenceNumber + 1;\n\t\t}\n\n\t\tawait summarizer.waitStart();\n\n\t\t// Process summary acks asynchronously\n\t\t// Note: no exceptions are thrown from processIncomingSummaryAcks handler as it handles all exceptions\n\t\tsummarizer.processIncomingSummaryAcks(nextReferenceSequenceNumber).catch((error) => {\n\t\t\tcreateChildLogger({ logger }).sendErrorEvent(\n\t\t\t\t{ eventName: \"HandleSummaryAckFatalError\" },\n\t\t\t\terror,\n\t\t\t);\n\t\t});\n\n\t\t// Update heuristic counts\n\t\t// By the time we get here, there are potentially ops missing from the heuristic summary counts\n\t\t// Examples of where this could happen:\n\t\t// 1. Op is processed during the time that we are initiating the RunningSummarizer instance but before we\n\t\t// listen for the op events (will get missed by the handlers in the current workflow)\n\t\t// 2. Op was sequenced after the last time we summarized (op sequence number > summarize ref sequence number)\n\t\tconst diff =\n\t\t\truntime.deltaManager.lastSequenceNumber -\n\t\t\t(heuristicData.lastSuccessfulSummary.refSequenceNumber +\n\t\t\t\theuristicData.numNonRuntimeOps +\n\t\t\t\theuristicData.numRuntimeOps);\n\t\theuristicData.hasMissingOpData = diff > 0;\n\n\t\tif (heuristicData.hasMissingOpData) {\n\t\t\t// Split the diff 50-50 and increment the counts appropriately\n\t\t\theuristicData.numNonRuntimeOps += Math.ceil(diff / 2);\n\t\t\theuristicData.numRuntimeOps += Math.floor(diff / 2);\n\t\t}\n\n\t\t// Update last seq number (in case the handlers haven't processed anything yet)\n\t\theuristicData.lastOpSequenceNumber = runtime.deltaManager.lastSequenceNumber;\n\n\t\t// Start heuristics\n\t\tsummarizer.heuristicRunner?.start();\n\t\tsummarizer.heuristicRunner?.run();\n\n\t\treturn summarizer;\n\t}\n\n\tpublic get disposed(): boolean {\n\t\treturn this._disposed;\n\t}\n\tprivate stopping = false;\n\tprivate _disposed = false;\n\tprivate summarizingLock: Promise<void> | undefined;\n\tprivate tryWhileSummarizing = false;\n\tprivate readonly pendingAckTimer: PromiseTimer;\n\tprivate heuristicRunner?: ISummarizeHeuristicRunner;\n\tprivate readonly generator: SummaryGenerator;\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate enqueuedSummary:\n\t\t| {\n\t\t\t\treason: SummarizeReason;\n\t\t\t\tafterSequenceNumber: number;\n\t\t\t\tsummarizeOptions: ISummarizeOptions;\n\t\t\t\treadonly resultsBuilder: SummarizeResultBuilder;\n\t\t }\n\t\t| undefined;\n\tprivate summarizeCount = 0;\n\tprivate totalSuccessfulAttempts = 0;\n\tprivate initialized = false;\n\n\tprivate readonly runtimeListener;\n\n\t/**\n\t * The maximum number of summary attempts to do when submit summary fails.\n\t */\n\tprivate readonly maxAttemptsForSubmitFailures: number;\n\n\t/**\n\t * These are necessary to store outside of methods because of the logic around runnning a lastSummary.\n\t * We want the lastSummary to also be captured as \"all attempts failed\".\n\t */\n\tprivate lastSummarizeFailureEventProps: Omit<ISummarizeEventProps, \"result\"> | undefined =\n\t\tundefined;\n\n\tprivate constructor(\n\t\tbaseLogger: ITelemetryBaseLogger,\n\t\tprivate readonly summaryWatcher: IClientSummaryWatcher,\n\t\tprivate readonly configuration: ISummaryConfiguration,\n\t\tprivate readonly submitSummaryCallback: (\n\t\t\toptions: ISubmitSummaryOptions,\n\t\t) => Promise<SubmitSummaryResult>,\n\t\tprivate readonly refreshLatestSummaryAckCallback: (\n\t\t\toptions: IRefreshSummaryAckOptions,\n\t\t) => Promise<void>,\n\t\tprivate readonly heuristicData: ISummarizeHeuristicData,\n\t\tprivate readonly summaryCollection: SummaryCollection,\n\t\tprivate readonly cancellationToken: ISummaryCancellationToken,\n\t\tprivate readonly stopSummarizerCallback: (reason: SummarizerStopReason) => void,\n\t\tprivate readonly runtime: ISummarizerRuntime,\n\t) {\n\t\tsuper();\n\n\t\tconst telemetryProps: ISummarizeRunnerTelemetry = {\n\t\t\tsummarizeCount: () => this.summarizeCount,\n\t\t\tsummarizerSuccessfulAttempts: () => this.totalSuccessfulAttempts,\n\t\t};\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: baseLogger,\n\t\t\tnamespace: \"Running\",\n\t\t\tproperties: {\n\t\t\t\tall: telemetryProps,\n\t\t\t},\n\t\t});\n\n\t\tif (configuration.state !== \"disableHeuristics\") {\n\t\t\tassert(\n\t\t\t\tthis.configuration.state === \"enabled\",\n\t\t\t\t0x2ea /* \"Configuration state should be enabled\" */,\n\t\t\t);\n\t\t\tthis.heuristicRunner = new SummarizeHeuristicRunner(\n\t\t\t\theuristicData,\n\t\t\t\tthis.configuration,\n\t\t\t\t(reason) => this.trySummarize(reason),\n\t\t\t\tthis.mc.logger,\n\t\t\t);\n\t\t}\n\n\t\tassert(\n\t\t\tthis.configuration.state !== \"disabled\",\n\t\t\t0x2eb /* \"Summary not supported with configuration disabled\" */,\n\t\t);\n\n\t\t// Cap the maximum amount of time client will wait for a summarize op ack to maxSummarizeAckWaitTime\n\t\t// configuration.maxAckWaitTime is composed from defaults, server values, and runtime overrides\n\n\t\tconst maxAckWaitTime = Math.min(\n\t\t\tthis.configuration.maxAckWaitTime,\n\t\t\tmaxSummarizeAckWaitTime,\n\t\t);\n\n\t\tthis.pendingAckTimer = new PromiseTimer(maxAckWaitTime, () => {\n\t\t\t// Note: summarizeCount (from ChildLogger definition) may be 0,\n\t\t\t// since this code path is hit when RunningSummarizer first starts up,\n\t\t\t// before this instance has kicked off a new summarize run.\n\t\t\tthis.mc.logger.sendErrorEvent({\n\t\t\t\teventName: \"SummaryAckWaitTimeout\",\n\t\t\t\tmessage: \"Pending summary ack not received in time\",\n\t\t\t\tmaxAckWaitTime,\n\t\t\t\treferenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n\t\t\t\tsummarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n\t\t\t\ttimePending: Date.now() - this.heuristicData.lastAttempt.summaryTime,\n\t\t\t});\n\t\t});\n\t\t// Set up pending ack timeout by op timestamp differences for previous summaries.\n\t\tsummaryCollection.setPendingAckTimerTimeoutCallback(maxAckWaitTime, () => {\n\t\t\tif (this.pendingAckTimer.hasTimer) {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"MissingSummaryAckFoundByOps\",\n\t\t\t\t\treferenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n\t\t\t\t\tsummarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n\t\t\t\t});\n\t\t\t\tthis.pendingAckTimer.clear();\n\t\t\t}\n\t\t});\n\n\t\tconst immediatelyRefreshLatestSummaryAck =\n\t\t\tthis.mc.config.getBoolean(\"Fluid.Summarizer.immediatelyRefreshLatestSummaryAck\") ?? true;\n\t\tthis.generator = new SummaryGenerator(\n\t\t\tthis.pendingAckTimer,\n\t\t\tthis.heuristicData,\n\t\t\tthis.submitSummaryCallback,\n\t\t\t() => {\n\t\t\t\tthis.totalSuccessfulAttempts++;\n\t\t\t},\n\t\t\tasync (options: IRefreshSummaryAckOptions) => {\n\t\t\t\tif (immediatelyRefreshLatestSummaryAck) {\n\t\t\t\t\tawait this.refreshLatestSummaryAckAndHandleError(options);\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.summaryWatcher,\n\t\t\tthis.mc.logger,\n\t\t);\n\n\t\t// Listen to runtime for ops\n\t\tthis.runtimeListener = (op: ISequencedDocumentMessage, runtimeMessage?: boolean) => {\n\t\t\tthis.handleOp(op, runtimeMessage === true);\n\t\t};\n\t\tthis.runtime.on(\"op\", this.runtimeListener);\n\n\t\t// The max attempts for submit failures can be overridden via a feature flag. This allows us to\n\t\t// tweak this as per telemetry data until we arrive at a stable number.\n\t\t// If its set to a number higher than `defaultMaxAttemptsForSubmitFailures`, it will be ignored.\n\t\tconst overrideMaxAttempts = this.mc.config.getNumber(\n\t\t\t\"Fluid.Summarizer.AttemptsForSubmitFailures\",\n\t\t);\n\t\tthis.maxAttemptsForSubmitFailures =\n\t\t\toverrideMaxAttempts && overrideMaxAttempts < defaultMaxAttemptsForSubmitFailures\n\t\t\t\t? overrideMaxAttempts\n\t\t\t\t: defaultMaxAttemptsForSubmitFailures;\n\t}\n\n\tprivate async handleSummaryAck(ack: IAckedSummary): Promise<void> {\n\t\tconst refSequenceNumber = ack.summaryOp.referenceSequenceNumber;\n\t\tconst summaryLogger = this.tryGetCorrelatedLogger(refSequenceNumber) ?? this.mc.logger;\n\t\tconst summaryOpHandle = ack.summaryOp.contents.handle;\n\t\tconst summaryAckHandle = ack.summaryAck.contents.handle;\n\t\twhile (this.summarizingLock !== undefined) {\n\t\t\tsummaryLogger.sendTelemetryEvent({\n\t\t\t\teventName: \"RefreshAttemptWithSummarizerRunning\",\n\t\t\t\treferenceSequenceNumber: refSequenceNumber,\n\t\t\t\tproposalHandle: summaryOpHandle,\n\t\t\t\tackHandle: summaryAckHandle,\n\t\t\t});\n\t\t\tawait this.summarizingLock;\n\t\t}\n\n\t\t// Make sure we block any summarizer from being executed/enqueued while\n\t\t// executing the refreshLatestSummaryAck.\n\t\t// https://dev.azure.com/fluidframework/internal/_workitems/edit/779\n\t\tawait this.lockedSummaryAction(\n\t\t\t() => {},\n\t\t\tasync () => {\n\t\t\t\tconst options: IRefreshSummaryAckOptions = {\n\t\t\t\t\tproposalHandle: summaryOpHandle,\n\t\t\t\t\tackHandle: summaryAckHandle,\n\t\t\t\t\tsummaryRefSeq: refSequenceNumber,\n\t\t\t\t\tsummaryLogger,\n\t\t\t\t};\n\t\t\t\tawait this.refreshLatestSummaryAckAndHandleError(options);\n\t\t\t},\n\t\t\t() => {},\n\t\t);\n\t}\n\n\tprivate readonly refreshLatestSummaryAckAndHandleError = async (\n\t\toptions: IRefreshSummaryAckOptions,\n\t): Promise<void> => {\n\t\treturn this.refreshLatestSummaryAckCallback(options).catch(async (error) => {\n\t\t\t// If the error is 404, so maybe the fetched version no longer exists on server. We just\n\t\t\t// ignore this error in that case, as that means we will have another summaryAck for the\n\t\t\t// latest version with which we will refresh the state. However in case of single commit\n\t\t\t// summary, we might be missing a summary ack, so in that case we are still fine as the\n\t\t\t// code in `submitSummary` function in container runtime, will refresh the latest state\n\t\t\t// by calling `prefetchLatestSummaryThenClose`. We will load the next summarizer from the\n\t\t\t// updated state and be fine.\n\t\t\tconst isIgnoredError =\n\t\t\t\tisFluidError(error) &&\n\t\t\t\terror.errorType === DriverErrorTypes.fileNotFoundOrAccessDeniedError;\n\n\t\t\toptions.summaryLogger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: isIgnoredError\n\t\t\t\t\t\t? \"HandleSummaryAckErrorIgnored\"\n\t\t\t\t\t\t: \"HandleLastSummaryAckError\",\n\t\t\t\t\treferenceSequenceNumber: options.summaryRefSeq,\n\t\t\t\t\tproposalHandle: options.proposalHandle,\n\t\t\t\t\tackHandle: options.ackHandle,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t});\n\t};\n\n\t/**\n\t * Responsible for receiving and processing all the summary acks.\n\t * It starts processing ACKs after the one for the summary this client loaded from (initialSequenceNumber). Any\n\t * ACK before that is not interesting as it will simply be ignored.\n\t *\n\t * @param referenceSequenceNumber - The referenceSequenceNumber of the summary from which to start processing\n\t * acks.\n\t */\n\tprivate async processIncomingSummaryAcks(referenceSequenceNumber: number): Promise<void> {\n\t\t// Start waiting for acks that are for summaries newer that the one this client loaded from.\n\t\tlet nextReferenceSequenceNumber = referenceSequenceNumber;\n\t\twhile (!this.disposed) {\n\t\t\tconst ackedSummary = await this.summaryCollection.waitSummaryAck(\n\t\t\t\tnextReferenceSequenceNumber,\n\t\t\t);\n\t\t\tawait this.handleSummaryAck(ackedSummary);\n\t\t\tnextReferenceSequenceNumber = ackedSummary.summaryOp.referenceSequenceNumber + 1;\n\t\t}\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.runtime.off(\"op\", this.runtimeListener);\n\t\tthis.summaryWatcher.dispose();\n\t\tthis.heuristicRunner?.dispose();\n\t\tthis.heuristicRunner = undefined;\n\t\tthis.generator.dispose();\n\t\tthis.pendingAckTimer.clear();\n\t\tthis.disposeEnqueuedSummary();\n\t\tthis._disposed = true;\n\t\tthis.stopping = true;\n\t}\n\n\t/**\n\t * RunningSummarizer's logger includes the sequenced index of the current summary on each event.\n\t * If some other Summarizer code wants that event on their logs they can get it here,\n\t * but only if they're logging about that same summary.\n\t * @param summaryOpRefSeq - RefSeq number of the summary op, to ensure the log correlation will be correct\n\t */\n\tpublic tryGetCorrelatedLogger = (\n\t\tsummaryOpRefSeq: number,\n\t): ITelemetryLoggerExt | undefined =>\n\t\tthis.heuristicData.lastAttempt.refSequenceNumber === summaryOpRefSeq\n\t\t\t? this.mc.logger\n\t\t\t: undefined;\n\n\t/**\n\t * We only want a single heuristic runner micro-task (will provide better optimized grouping of ops)\n\t */\n\tprivate heuristicRunnerMicroTaskExists = false;\n\n\tpublic handleOp(op: ISequencedDocumentMessage, runtimeMessage: boolean): void {\n\t\tthis.heuristicData.lastOpSequenceNumber = op.sequenceNumber;\n\n\t\tif (runtimeMessage) {\n\t\t\tthis.heuristicData.numRuntimeOps++;\n\t\t} else {\n\t\t\tthis.heuristicData.numNonRuntimeOps++;\n\t\t}\n\n\t\tthis.heuristicData.totalOpsSize += opSize(op);\n\n\t\t// Check for enqueued on-demand summaries; Intentionally do nothing otherwise\n\t\tif (\n\t\t\tthis.initialized &&\n\t\t\tthis.opCanTriggerSummary(op, runtimeMessage) &&\n\t\t\t!this.tryRunEnqueuedSummary() &&\n\t\t\t!this.heuristicRunnerMicroTaskExists\n\t\t) {\n\t\t\tthis.heuristicRunnerMicroTaskExists = true;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\tPromise.resolve()\n\t\t\t\t.then(() => {\n\t\t\t\t\tthis.heuristicRunner?.run();\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis.heuristicRunnerMicroTaskExists = false;\n\t\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Can the given op trigger a summary?\n\t * # Currently always prevents summaries for Summarize and SummaryAck/Nack ops\n\t * @param op - op to check\n\t * @returns true if this op can trigger a summary\n\t */\n\tprivate opCanTriggerSummary(\n\t\top: ISequencedDocumentMessage,\n\t\truntimeMessage: boolean,\n\t): boolean {\n\t\tswitch (op.type) {\n\t\t\tcase MessageType.Summarize:\n\t\t\tcase MessageType.SummaryAck:\n\t\t\tcase MessageType.SummaryNack:\n\t\t\t\treturn false;\n\t\t\tdefault:\n\t\t\t\treturn runtimeMessage || this.nonRuntimeOpCanTriggerSummary();\n\t\t}\n\t}\n\n\tprivate nonRuntimeOpCanTriggerSummary(): boolean {\n\t\tconst opsSinceLastAck =\n\t\t\tthis.heuristicData.lastOpSequenceNumber -\n\t\t\tthis.heuristicData.lastSuccessfulSummary.refSequenceNumber;\n\t\treturn (\n\t\t\tthis.configuration.state === \"enabled\" &&\n\t\t\t(this.configuration.nonRuntimeHeuristicThreshold === undefined ||\n\t\t\t\tthis.configuration.nonRuntimeHeuristicThreshold <= opsSinceLastAck)\n\t\t);\n\t}\n\n\tpublic async waitStop(allowLastSummary: boolean): Promise<void> {\n\t\tif (this.stopping) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.stopping = true;\n\n\t\tthis.disposeEnqueuedSummary();\n\n\t\t// This will try to run lastSummary if needed.\n\t\tif (allowLastSummary && this.heuristicRunner?.shouldRunLastSummary()) {\n\t\t\tif (this.summarizingLock === undefined) {\n\t\t\t\tthis.trySummarizeOnce(\n\t\t\t\t\t// summarizeProps\n\t\t\t\t\t{ summarizeReason: \"lastSummary\" },\n\t\t\t\t\t{},\n\t\t\t\t\tundefined,\n\t\t\t\t\ttrue /* isLastSummary */,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Note that trySummarizeOnce() call above returns right away, without waiting.\n\t\t// So we need to wait for its completion, otherwise it would be destroyed right away.\n\t\t// That said, if summary lock was taken upfront, this wait might wait on multiple retries to\n\t\t// submit summary. We should reconsider this flow and make summarizer move to exit faster.\n\t\t// This resolves when the current pending summary gets an ack or fails.\n\t\tawait this.summarizingLock;\n\n\t\tif (this.lastSummarizeFailureEventProps !== undefined) {\n\t\t\tthis.emit(\"summarizeAllAttemptsFailed\", {\n\t\t\t\t...this.lastSummarizeFailureEventProps,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t});\n\t\t}\n\t\tthis.lastSummarizeFailureEventProps = undefined;\n\t}\n\n\tprivate async waitStart(): Promise<void> {\n\t\t// Wait no longer than ack timeout for all pending\n\t\tconst waitStartResult = await raceTimer(\n\t\t\tthis.summaryWatcher.waitFlushed(),\n\t\t\tthis.pendingAckTimer.start(),\n\t\t);\n\t\tthis.pendingAckTimer.clear();\n\n\t\t// Remove pending ack wait timeout by op timestamp comparison, because\n\t\t// it has race conditions with summaries submitted by this same client.\n\t\tthis.summaryCollection.unsetPendingAckTimerTimeoutCallback();\n\n\t\tif (waitStartResult.result === \"done\" && waitStartResult.value !== undefined) {\n\t\t\tthis.heuristicData.updateWithLastSummaryAckInfo({\n\t\t\t\trefSequenceNumber: waitStartResult.value.summaryOp.referenceSequenceNumber,\n\t\t\t\t// This will be the Summarizer starting point so only use timestamps from client's machine.\n\t\t\t\tsummaryTime: Date.now(),\n\t\t\t\tsummarySequenceNumber: waitStartResult.value.summaryOp.sequenceNumber,\n\t\t\t});\n\t\t}\n\t\tthis.initialized = true;\n\t}\n\n\tprivate beforeSummaryAction(): void {\n\t\tthis.summarizeCount++;\n\t}\n\n\tprivate afterSummaryAction(): void {\n\t\tconst retry = this.tryWhileSummarizing;\n\t\tthis.tryWhileSummarizing = false;\n\n\t\t// After summarizing, we should check to see if we need to summarize again.\n\t\t// Rerun the heuristics and check for enqueued summaries.\n\t\tif (!this.stopping && !this.tryRunEnqueuedSummary() && retry) {\n\t\t\tthis.heuristicRunner?.run();\n\t\t}\n\t}\n\n\t/**\n\t * Runs single summary action that prevents any other concurrent actions.\n\t * Assumes that caller checked upfront for lack of concurrent action (this.summarizingLock)\n\t * before calling this API. I.e. caller is responsible for either erroring out or waiting on this promise.\n\t * @param before - set of instructions to run before running the action.\n\t * @param action - action to perform.\n\t * @param after - set of instructions to run after running the action.\n\t * @returns The result of the action.\n\t */\n\tprivate async lockedSummaryAction<T>(\n\t\tbefore: () => void,\n\t\taction: () => Promise<T>,\n\t\tafter: () => void,\n\t): Promise<T> {\n\t\tassert(\n\t\t\tthis.summarizingLock === undefined,\n\t\t\t0x25b /* \"Caller is responsible for checking lock\" */,\n\t\t);\n\n\t\tconst summarizingLock = new Deferred<void>();\n\t\tthis.summarizingLock = summarizingLock.promise;\n\n\t\tbefore();\n\n\t\treturn action().finally(() => {\n\t\t\tsummarizingLock.resolve();\n\t\t\tthis.summarizingLock = undefined;\n\t\t\tafter();\n\t\t});\n\t}\n\n\t/**\n\t * Runs single summarize attempt\n\t * @param summarizeProps - props to log with each telemetry event associated with this attempt\n\t * @param options - summary options\n\t * @param cancellationToken - cancellation token to use to be able to cancel this summary, if needed\n\t * @param resultsBuilder - optional, result builder to use.\n\t * @param isLastSummary - optional, is the call to this method for a last summary when shutting down the summarizer?\n\t * @returns ISummarizeResult - result of running a summary.\n\t */\n\tprivate trySummarizeOnce(\n\t\tsummarizeProps: ISummarizeTelemetryProperties,\n\t\toptions: ISummarizeOptions,\n\t\tresultsBuilder = new SummarizeResultBuilder(),\n\t\tisLastSummary = false,\n\t): ISummarizeResults {\n\t\tthis.lockedSummaryAction(\n\t\t\t() => {\n\t\t\t\tthis.beforeSummaryAction();\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryLogger = createChildLogger({\n\t\t\t\t\tlogger: this.mc.logger,\n\t\t\t\t\tproperties: { all: summarizeProps },\n\t\t\t\t});\n\t\t\t\tconst summaryOptions: ISubmitSummaryOptions = {\n\t\t\t\t\t...options,\n\t\t\t\t\tsummaryLogger,\n\t\t\t\t\tcancellationToken: this.cancellationToken,\n\t\t\t\t\tlatestSummaryRefSeqNum: this.heuristicData.lastSuccessfulSummary.refSequenceNumber,\n\t\t\t\t};\n\t\t\t\tconst summarizeResult = this.generator.summarize(summaryOptions, resultsBuilder);\n\t\t\t\t// ensure we wait till the end of the process\n\t\t\t\tconst result = await summarizeResult.receivedSummaryAckOrNack;\n\n\t\t\t\tif (result.success) {\n\t\t\t\t\tthis.emit(\"summarize\", {\n\t\t\t\t\t\tresult: \"success\",\n\t\t\t\t\t\tcurrentAttempt: 1,\n\t\t\t\t\t\tmaxAttempts: 1,\n\t\t\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t\t\t\tisLastSummary,\n\t\t\t\t\t});\n\t\t\t\t\tthis.lastSummarizeFailureEventProps = undefined;\n\t\t\t\t} else {\n\t\t\t\t\tthis.emit(\"summarize\", {\n\t\t\t\t\t\tresult: \"failure\",\n\t\t\t\t\t\tcurrentAttempt: 1,\n\t\t\t\t\t\tmaxAttempts: 1,\n\t\t\t\t\t\terror: result.error,\n\t\t\t\t\t\tfailureMessage: result.message,\n\t\t\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t\t\t\tisLastSummary,\n\t\t\t\t\t});\n\t\t\t\t\tthis.mc.logger.sendErrorEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"SummarizeFailed\",\n\t\t\t\t\t\t\tmaxAttempts: 1,\n\t\t\t\t\t\t\tsummaryAttempts: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresult.error,\n\t\t\t\t\t);\n\t\t\t\t\tif (isLastSummary) {\n\t\t\t\t\t\tthis.lastSummarizeFailureEventProps = {\n\t\t\t\t\t\t\tcurrentAttempt: (this.lastSummarizeFailureEventProps?.currentAttempt ?? 0) + 1,\n\t\t\t\t\t\t\tmaxAttempts: (this.lastSummarizeFailureEventProps?.currentAttempt ?? 0) + 1,\n\t\t\t\t\t\t\terror: result.error,\n\t\t\t\t\t\t\tfailureMessage: result.message,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tthis.afterSummaryAction();\n\t\t\t},\n\t\t).catch((error) => {\n\t\t\t// SummaryGenerator.summarize() does not throw exceptions - it converts them to failed result\n\t\t\t// on resultsBuilder\n\t\t\t// We do not care about exceptions on receivedSummaryAckOrNack - caller should check results\n\t\t\t// and take a appropriate action.\n\t\t});\n\n\t\treturn resultsBuilder.build();\n\t}\n\n\t/**\n\t * Heuristics summarize attempt.\n\t */\n\tprivate trySummarize(reason: SummarizeReason): void {\n\t\tif (this.summarizingLock !== undefined) {\n\t\t\t// lockedSummaryAction() will retry heuristic-based summary at the end of current attempt\n\t\t\t// if it's still needed\n\t\t\tthis.tryWhileSummarizing = true;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.lockedSummaryAction(\n\t\t\t() => {\n\t\t\t\tthis.beforeSummaryAction();\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\treturn this.trySummarizeWithRetries(reason);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tthis.afterSummaryAction();\n\t\t\t},\n\t\t).catch((error) => {\n\t\t\tthis.mc.logger.sendErrorEvent({ eventName: \"UnexpectedSummarizeError\" }, error);\n\t\t});\n\t}\n\n\t/**\n\t * Tries to summarize with retries where retry is based on the failure params.\n\t * For example, summarization may be retried for failures with \"retryAfterSeconds\" param.\n\t */\n\tprivate async trySummarizeWithRetries(\n\t\treason: SummarizeReason,\n\t): Promise<ISummarizeResults | undefined> {\n\t\t// Helper to set summarize options, telemetry properties and call summarize.\n\t\tconst attemptSummarize = (\n\t\t\tattemptNumber: number,\n\t\t\tfinalAttempt: boolean,\n\t\t): {\n\t\t\tsummarizeProps: ISummarizeTelemetryProperties;\n\t\t\tsummarizeResult: ISummarizeResults;\n\t\t} => {\n\t\t\tconst summarizeOptions: ISummarizeOptions = {\n\t\t\t\tfullTree: false,\n\t\t\t};\n\t\t\tconst summarizeProps: ISummarizeTelemetryProperties = {\n\t\t\t\tsummarizeReason: reason,\n\t\t\t\tsummaryAttempts: attemptNumber,\n\t\t\t\t...summarizeOptions,\n\t\t\t\tfinalAttempt,\n\t\t\t};\n\t\t\tconst summaryLogger = createChildLogger({\n\t\t\t\tlogger: this.mc.logger,\n\t\t\t\tproperties: { all: summarizeProps },\n\t\t\t});\n\t\t\tconst summaryOptions: ISubmitSummaryOptions = {\n\t\t\t\t...summarizeOptions,\n\t\t\t\tsummaryLogger,\n\t\t\t\tcancellationToken: this.cancellationToken,\n\t\t\t\tfinalAttempt,\n\t\t\t\tlatestSummaryRefSeqNum: this.heuristicData.lastSuccessfulSummary.refSequenceNumber,\n\t\t\t};\n\t\t\tconst summarizeResult = this.generator.summarize(summaryOptions);\n\t\t\treturn { summarizeProps, summarizeResult };\n\t\t};\n\n\t\t// The max number of attempts are based on the stage at which summarization failed. If it fails before it is\n\t\t// submitted, a different value is used compared to if it fails after submission. Usually, in the former case,\n\t\t// we would retry more often as its cheaper and retries are likely to succeed.\n\t\t// This makes it harder to predict how many attempts would actually happen as that depends on how far an attempt\n\t\t// made. To keep things simple, the max attempts is reset after every attempt based on where it failed. This may\n\t\t// result in some failures not being retried depending on what happened before this attempt. That's fine because\n\t\t// such scenarios are very unlikely and even if it happens, it would resolve when a new summarizer starts over.\n\t\t// For example - When failure switches from one the submit failures to nack failure, only one more retry will\n\t\t// happen irrespective of the value of `defaultMaxAttempts`.\n\t\tlet maxAttempts = defaultMaxAttempts;\n\t\tlet currentAttempt = 0;\n\t\tlet retryAfterSeconds: number | undefined;\n\t\tlet done = false;\n\t\tlet status: \"success\" | \"failure\" | \"canceled\" = \"success\";\n\t\tlet results: ISummarizeResults | undefined;\n\t\tlet error: IRetriableFailureError | undefined;\n\t\tlet failureMessage: string | undefined;\n\t\tdo {\n\t\t\tcurrentAttempt++;\n\t\t\tif (this.cancellationToken.cancelled) {\n\t\t\t\tstatus = \"canceled\";\n\t\t\t\tdone = true;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst attemptResult = attemptSummarize(currentAttempt, false /* finalAttempt */);\n\t\t\tresults = attemptResult.summarizeResult;\n\n\t\t\t// Ack / nack is the final step, so if it succeeds we're done.\n\t\t\tconst ackNackResult = await results.receivedSummaryAckOrNack;\n\t\t\tif (ackNackResult.success) {\n\t\t\t\tstatus = \"success\";\n\t\t\t\tdone = true;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Update max attempts from the failure result.\n\t\t\t// If submit summary failed, use maxAttemptsForSubmitFailures. Else use the defaultMaxAttempts.\n\t\t\t// Note: Check \"summarySubmitted\" result first because if it fails, ack nack would fail as well.\n\t\t\tconst submitSummaryResult = await results.summarySubmitted;\n\t\t\tmaxAttempts = !submitSummaryResult.success\n\t\t\t\t? this.maxAttemptsForSubmitFailures\n\t\t\t\t: defaultMaxAttempts;\n\n\t\t\t// Emit \"summarize\" event for this failed attempt.\n\t\t\tstatus = \"failure\";\n\t\t\terror = ackNackResult.error;\n\t\t\tfailureMessage = ackNackResult.message;\n\t\t\tretryAfterSeconds = error.retryAfterSeconds;\n\t\t\tconst eventProps: ISummarizeEventProps & ISummarizerObservabilityProps = {\n\t\t\t\tresult: status,\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\terror,\n\t\t\t\tfailureMessage,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t};\n\t\t\tthis.emit(\"summarize\", eventProps);\n\n\t\t\t// Break if the failure doesn't have \"retryAfterSeconds\" or we are one less from max number of attempts.\n\t\t\t// Note that the final attempt if \"retryAfterSeconds\" does exist happens outside of the do..while loop.\n\t\t\tif (retryAfterSeconds === undefined || currentAttempt >= maxAttempts - 1) {\n\t\t\t\tdone = true;\n\t\t\t}\n\n\t\t\t// If the failure has \"retryAfterSeconds\", add a delay of that time before starting the next attempt.\n\t\t\tif (retryAfterSeconds !== undefined && retryAfterSeconds > 0) {\n\t\t\t\tthis.mc.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"SummarizeAttemptDelay\",\n\t\t\t\t\tduration: retryAfterSeconds * 1000,\n\t\t\t\t\tsummaryNackDelay: ackNackResult.data !== undefined, // This will only be defined only for nack failures.\n\t\t\t\t\tstage: submitSummaryResult.data?.stage,\n\t\t\t\t\t...attemptResult.summarizeProps,\n\t\t\t\t});\n\t\t\t\tawait delay(retryAfterSeconds * 1000);\n\t\t\t}\n\t\t} while (!done);\n\n\t\t// If the attempt was successful, emit \"summarize\" event and return. A failed attempt may be retried below.\n\t\tif (status !== \"failure\") {\n\t\t\tthis.emit(\"summarize\", {\n\t\t\t\tresult: status,\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t});\n\t\t\treturn results;\n\t\t}\n\n\t\t// If summarization wasn't successful above and the failure contains \"retryAfterSeconds\", perform one last\n\t\t// attempt. This gives a chance to the runtime to perform additional steps in the last attempt.\n\t\tif (retryAfterSeconds !== undefined) {\n\t\t\tconst { summarizeResult } = attemptSummarize(++currentAttempt, true /* finalAttempt */);\n\t\t\t// Ack / nack is the final step, so if it succeeds we're done.\n\t\t\tconst ackNackResult = await summarizeResult.receivedSummaryAckOrNack;\n\t\t\tstatus = ackNackResult.success ? \"success\" : \"failure\";\n\t\t\terror = ackNackResult.success ? undefined : ackNackResult.error;\n\t\t\tfailureMessage = ackNackResult.success ? undefined : ackNackResult.message;\n\t\t\tconst eventProps: ISummarizeEventProps & ISummarizerObservabilityProps = {\n\t\t\t\tresult: status,\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\terror,\n\t\t\t\tfailureMessage,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t};\n\t\t\tthis.emit(\"summarize\", eventProps);\n\t\t\tresults = summarizeResult;\n\t\t}\n\n\t\t// If summarization is still unsuccessful, stop the summarizer.\n\t\tif (status === \"failure\") {\n\t\t\tthis.mc.logger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"SummarizeFailed\",\n\t\t\t\t\tmaxAttempts,\n\t\t\t\t\tsummaryAttempts: currentAttempt,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\tthis.lastSummarizeFailureEventProps = {\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\terror,\n\t\t\t\tfailureMessage,\n\t\t\t};\n\t\t\tthis.stopSummarizerCallback(\"failToSummarize\");\n\t\t}\n\t\treturn results;\n\t}\n\n\t/**\n\t * Attempts to generate a summary on demand with retries in case of failures. The retry logic is the same\n\t * as heuristics based summaries.\n\t */\n\tprivate async summarizeOnDemandWithRetries(\n\t\treason: SummarizeReason,\n\t\tresultsBuilder: SummarizeResultBuilder,\n\t): Promise<ISummarizeResults> {\n\t\tconst results = await this.trySummarizeWithRetries(reason);\n\t\tif (results === undefined) {\n\t\t\tresultsBuilder.fail(\n\t\t\t\t\"Summarization was canceled\",\n\t\t\t\tnew RetriableSummaryError(\"Summarization was canceled\"),\n\t\t\t);\n\t\t\treturn resultsBuilder.build();\n\t\t}\n\t\tconst submitResult = await results.summarySubmitted;\n\t\tconst summaryOpBroadcastedResult = await results.summaryOpBroadcasted;\n\t\tconst ackNackResult = await results.receivedSummaryAckOrNack;\n\t\tresultsBuilder.summarySubmitted.resolve(submitResult);\n\t\tresultsBuilder.summaryOpBroadcasted.resolve(summaryOpBroadcastedResult);\n\t\tresultsBuilder.receivedSummaryAckOrNack.resolve(ackNackResult);\n\t\treturn resultsBuilder.build();\n\t}\n\n\t/**\n\t * {@inheritdoc (ISummarizer:interface).summarizeOnDemand}\n\t */\n\tpublic summarizeOnDemand(\n\t\toptions: IOnDemandSummarizeOptions,\n\t\tresultsBuilder: SummarizeResultBuilder = new SummarizeResultBuilder(),\n\t): ISummarizeResults {\n\t\tif (this.stopping) {\n\t\t\tresultsBuilder.fail(\n\t\t\t\t\"RunningSummarizer stopped or disposed\",\n\t\t\t\tnew RetriableSummaryError(\"RunningSummarizer stopped or disposed\"),\n\t\t\t);\n\t\t\treturn resultsBuilder.build();\n\t\t}\n\t\t// Check for concurrent summary attempts. If one is found,\n\t\t// return a promise that caller can await before trying again.\n\t\tif (this.summarizingLock !== undefined) {\n\t\t\t// The heuristics are blocking concurrent summarize attempts.\n\t\t\tthrow new UsageError(\"Attempted to run an already-running summarizer on demand\");\n\t\t}\n\n\t\tconst { reason, ...summarizeOptions } = options;\n\t\tif (options.retryOnFailure === true) {\n\t\t\tthis.summarizeOnDemandWithRetries(`onDemand;${reason}`, resultsBuilder).catch(\n\t\t\t\t(error) => {\n\t\t\t\t\tresultsBuilder.fail(\"summarize failed\", error);\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\tthis.trySummarizeOnce(\n\t\t\t\t{ summarizeReason: `onDemand/${reason}` },\n\t\t\t\tsummarizeOptions,\n\t\t\t\tresultsBuilder,\n\t\t\t);\n\t\t}\n\t\treturn resultsBuilder.build();\n\t}\n\n\t/**\n\t * {@inheritdoc (ISummarizer:interface).enqueueSummarize}\n\t */\n\tpublic enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tconst { reason, afterSequenceNumber = 0, override = false, ...summarizeOptions } = options;\n\t\tlet overridden = false;\n\t\tif (this.enqueuedSummary !== undefined) {\n\t\t\tif (!override) {\n\t\t\t\treturn { alreadyEnqueued: true };\n\t\t\t}\n\t\t\t// Override existing enqueued summarize attempt.\n\t\t\tthis.enqueuedSummary.resultsBuilder.fail(\n\t\t\t\t\"Aborted; overridden by another enqueue summarize attempt\",\n\t\t\t\tnew RetriableSummaryError(\n\t\t\t\t\t\"Summary was overridden by another enqueue summarize attempt\",\n\t\t\t\t),\n\t\t\t);\n\t\t\tthis.enqueuedSummary = undefined;\n\t\t\toverridden = true;\n\t\t}\n\n\t\tthis.enqueuedSummary = {\n\t\t\treason: `enqueue;${reason}`,\n\t\t\tafterSequenceNumber,\n\t\t\tsummarizeOptions,\n\t\t\tresultsBuilder: new SummarizeResultBuilder(),\n\t\t};\n\t\tconst results = this.enqueuedSummary.resultsBuilder.build();\n\t\tthis.tryRunEnqueuedSummary();\n\t\treturn overridden\n\t\t\t? {\n\t\t\t\t\t...results,\n\t\t\t\t\talreadyEnqueued: true,\n\t\t\t\t\toverridden: true,\n\t\t\t\t}\n\t\t\t: results;\n\t}\n\n\tprivate tryRunEnqueuedSummary(): boolean {\n\t\tif (this.stopping) {\n\t\t\tthis.disposeEnqueuedSummary();\n\t\t\treturn false;\n\t\t}\n\t\tif (\n\t\t\tthis.enqueuedSummary === undefined ||\n\t\t\tthis.heuristicData.lastOpSequenceNumber < this.enqueuedSummary.afterSequenceNumber ||\n\t\t\tthis.summarizingLock !== undefined\n\t\t) {\n\t\t\t// If no enqueued summary is ready or a summary is already in progress, take no action.\n\t\t\treturn false;\n\t\t}\n\t\tconst { reason, resultsBuilder, summarizeOptions } = this.enqueuedSummary;\n\t\t// Set to undefined first, so that subsequent enqueue attempt while summarize will occur later.\n\t\tthis.enqueuedSummary = undefined;\n\t\tthis.trySummarizeOnce(\n\t\t\t{ summarizeReason: `enqueuedSummary/${reason}` },\n\t\t\tsummarizeOptions,\n\t\t\tresultsBuilder,\n\t\t);\n\t\treturn true;\n\t}\n\n\tprivate disposeEnqueuedSummary(): void {\n\t\tif (this.enqueuedSummary !== undefined) {\n\t\t\tthis.enqueuedSummary.resultsBuilder.fail(\n\t\t\t\t\"RunningSummarizer stopped or disposed\",\n\t\t\t\tnew RetriableSummaryError(\"RunningSummarizer stopped or disposed\"),\n\t\t\t);\n\t\t\tthis.enqueuedSummary = undefined;\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runningSummarizer.js","sourceRoot":"","sources":["../../src/summary/runningSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAQjE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAC5F,OAAO,EACN,gBAAgB,EAChB,WAAW,GAEX,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAEN,UAAU,EACV,iBAAiB,EACjB,4BAA4B,EAC5B,YAAY,GAEZ,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AA2BrE,OAAO,EACN,qBAA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;YACF,uFAAuF;YACvF,OAAO,KAAK,CAAC;QACd,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC;QAC1E,+FAA+F;QAC/F,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,gBAAgB,CACpB,EAAE,eAAe,EAAE,mBAAmB,MAAM,EAAE,EAAE,EAChD,gBAAgB,EAChB,cAAc,CACd,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAEO,sBAAsB;QAC7B,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YACxC,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,CACvC,uCAAuC,EACvC,IAAI,qBAAqB,CAAC,uCAAuC,CAAC,CAClE,CAAC;YACF,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QAClC,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tISummarizeEventProps,\n\tISummarizerEvents,\n\tISummarizerObservabilityProps,\n\tSummarizerStopReason,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport { IDisposable, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred, PromiseTimer, delay } from \"@fluidframework/core-utils/internal\";\nimport {\n\tDriverErrorTypes,\n\tMessageType,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tMonitoringContext,\n\tUsageError,\n\tcreateChildLogger,\n\tcreateChildMonitoringContext,\n\tisFluidError,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ISummaryConfiguration } from \"../containerRuntime.js\";\nimport { opSize } from \"../opProperties.js\";\n\nimport { SummarizeHeuristicRunner } from \"./summarizerHeuristics.js\";\nimport {\n\tEnqueueSummarizeResult,\n\tIEnqueueSummarizeOptions,\n\tIOnDemandSummarizeOptions,\n\t// eslint-disable-next-line import/no-deprecated\n\tIRefreshSummaryAckOptions,\n\t// eslint-disable-next-line import/no-deprecated\n\tISubmitSummaryOptions,\n\tISummarizeHeuristicData,\n\tISummarizeHeuristicRunner,\n\tISummarizeOptions,\n\tISummarizeResults,\n\tISummarizeRunnerTelemetry,\n\tISummarizeTelemetryProperties,\n\t// eslint-disable-next-line import/no-deprecated\n\tISummarizerRuntime,\n\t// eslint-disable-next-line import/no-deprecated\n\tISummaryCancellationToken,\n\tSubmitSummaryResult,\n\ttype IRetriableFailureError,\n} from \"./summarizerTypes.js\";\nimport {\n\tIAckedSummary,\n\tIClientSummaryWatcher,\n\tSummaryCollection,\n} from \"./summaryCollection.js\";\nimport {\n\tRetriableSummaryError,\n\tSummarizeReason,\n\tSummarizeResultBuilder,\n\tSummaryGenerator,\n\traceTimer,\n} from \"./summaryGenerator.js\";\n\nconst maxSummarizeAckWaitTime = 10 * 60 * 1000; // 10 minutes\n\n/**\n * The maximum number of summarization attempts that will be done by default in case of failures\n * that can be retried.\n */\nexport const defaultMaxAttempts = 2;\n/**\n * The default value for maximum number of summarization attempts that will be done for summarization failures where\n * submit fails and the failure can be retried.\n */\nexport const defaultMaxAttemptsForSubmitFailures = 5;\n\n/**\n * An instance of RunningSummarizer manages the heuristics for summarizing.\n * Until disposed, the instance of RunningSummarizer can assume that it is\n * in a state of running, meaning it is connected and initialized. It keeps\n * track of summaries that it is generating as they are broadcast and acked/nacked.\n * This object is created and controlled by Summarizer object.\n */\nexport class RunningSummarizer\n\textends TypedEventEmitter<ISummarizerEvents>\n\timplements IDisposable\n{\n\tpublic static async start(\n\t\tlogger: ITelemetryBaseLogger,\n\t\tsummaryWatcher: IClientSummaryWatcher,\n\t\tconfiguration: ISummaryConfiguration,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tsubmitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\trefreshLatestSummaryAckCallback: (options: IRefreshSummaryAckOptions) => Promise<void>,\n\t\theuristicData: ISummarizeHeuristicData,\n\t\tsummaryCollection: SummaryCollection,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tcancellationToken: ISummaryCancellationToken,\n\t\tstopSummarizerCallback: (reason: SummarizerStopReason) => void,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\truntime: ISummarizerRuntime,\n\t): Promise<RunningSummarizer> {\n\t\tconst summarizer = new RunningSummarizer(\n\t\t\tlogger,\n\t\t\tsummaryWatcher,\n\t\t\tconfiguration,\n\t\t\tsubmitSummaryCallback,\n\t\t\trefreshLatestSummaryAckCallback,\n\t\t\theuristicData,\n\t\t\tsummaryCollection,\n\t\t\tcancellationToken,\n\t\t\tstopSummarizerCallback,\n\t\t\truntime,\n\t\t);\n\n\t\t// If there have been any acks newer that the one this client loaded from until now, process them before\n\t\t// starting the running summarizer which will trigger summary heuristics.\n\t\t// This is done primarily to handle scenarios where the summarizer loads from a cached snapshot and there\n\t\t// is newer one available. The ack for the newer summary is processed before summarizing because otherwise\n\t\t// that summary would fail as it has an older parent.\n\t\tlet nextReferenceSequenceNumber = runtime.deltaManager.initialSequenceNumber + 1;\n\t\tconst latestAck = summaryCollection.latestAck;\n\t\tif (\n\t\t\tlatestAck !== undefined &&\n\t\t\tlatestAck.summaryOp.referenceSequenceNumber >= nextReferenceSequenceNumber\n\t\t) {\n\t\t\tawait summarizer.handleSummaryAck(latestAck);\n\t\t\tnextReferenceSequenceNumber = latestAck.summaryOp.referenceSequenceNumber + 1;\n\t\t}\n\n\t\tawait summarizer.waitStart();\n\n\t\t// Process summary acks asynchronously\n\t\t// Note: no exceptions are thrown from processIncomingSummaryAcks handler as it handles all exceptions\n\t\tsummarizer.processIncomingSummaryAcks(nextReferenceSequenceNumber).catch((error) => {\n\t\t\tcreateChildLogger({ logger }).sendErrorEvent(\n\t\t\t\t{ eventName: \"HandleSummaryAckFatalError\" },\n\t\t\t\terror,\n\t\t\t);\n\t\t});\n\n\t\t// Update heuristic counts\n\t\t// By the time we get here, there are potentially ops missing from the heuristic summary counts\n\t\t// Examples of where this could happen:\n\t\t// 1. Op is processed during the time that we are initiating the RunningSummarizer instance but before we\n\t\t// listen for the op events (will get missed by the handlers in the current workflow)\n\t\t// 2. Op was sequenced after the last time we summarized (op sequence number > summarize ref sequence number)\n\t\tconst diff =\n\t\t\truntime.deltaManager.lastSequenceNumber -\n\t\t\t(heuristicData.lastSuccessfulSummary.refSequenceNumber +\n\t\t\t\theuristicData.numNonRuntimeOps +\n\t\t\t\theuristicData.numRuntimeOps);\n\t\theuristicData.hasMissingOpData = diff > 0;\n\n\t\tif (heuristicData.hasMissingOpData) {\n\t\t\t// Split the diff 50-50 and increment the counts appropriately\n\t\t\theuristicData.numNonRuntimeOps += Math.ceil(diff / 2);\n\t\t\theuristicData.numRuntimeOps += Math.floor(diff / 2);\n\t\t}\n\n\t\t// Update last seq number (in case the handlers haven't processed anything yet)\n\t\theuristicData.lastOpSequenceNumber = runtime.deltaManager.lastSequenceNumber;\n\n\t\t// Start heuristics\n\t\tsummarizer.heuristicRunner?.start();\n\t\tsummarizer.heuristicRunner?.run();\n\n\t\treturn summarizer;\n\t}\n\n\tpublic get disposed(): boolean {\n\t\treturn this._disposed;\n\t}\n\tprivate stopping = false;\n\tprivate _disposed = false;\n\tprivate summarizingLock: Promise<void> | undefined;\n\tprivate tryWhileSummarizing = false;\n\tprivate readonly pendingAckTimer: PromiseTimer;\n\tprivate heuristicRunner?: ISummarizeHeuristicRunner;\n\tprivate readonly generator: SummaryGenerator;\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate enqueuedSummary:\n\t\t| {\n\t\t\t\treason: SummarizeReason;\n\t\t\t\tafterSequenceNumber: number;\n\t\t\t\tsummarizeOptions: ISummarizeOptions;\n\t\t\t\treadonly resultsBuilder: SummarizeResultBuilder;\n\t\t }\n\t\t| undefined;\n\tprivate summarizeCount = 0;\n\tprivate totalSuccessfulAttempts = 0;\n\tprivate initialized = false;\n\n\tprivate readonly runtimeListener: (\n\t\top: ISequencedDocumentMessage,\n\t\truntimeMessage?: boolean,\n\t) => void;\n\n\t/**\n\t * The maximum number of summary attempts to do when submit summary fails.\n\t */\n\tprivate readonly maxAttemptsForSubmitFailures: number;\n\n\t/**\n\t * These are necessary to store outside of methods because of the logic around runnning a lastSummary.\n\t * We want the lastSummary to also be captured as \"all attempts failed\".\n\t */\n\tprivate lastSummarizeFailureEventProps: Omit<ISummarizeEventProps, \"result\"> | undefined =\n\t\tundefined;\n\n\tprivate constructor(\n\t\tbaseLogger: ITelemetryBaseLogger,\n\t\tprivate readonly summaryWatcher: IClientSummaryWatcher,\n\t\tprivate readonly configuration: ISummaryConfiguration,\n\t\tprivate readonly submitSummaryCallback: (\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\toptions: ISubmitSummaryOptions,\n\t\t) => Promise<SubmitSummaryResult>,\n\t\tprivate readonly refreshLatestSummaryAckCallback: (\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\toptions: IRefreshSummaryAckOptions,\n\t\t) => Promise<void>,\n\t\tprivate readonly heuristicData: ISummarizeHeuristicData,\n\t\tprivate readonly summaryCollection: SummaryCollection,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tprivate readonly cancellationToken: ISummaryCancellationToken,\n\t\tprivate readonly stopSummarizerCallback: (reason: SummarizerStopReason) => void,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tprivate readonly runtime: ISummarizerRuntime,\n\t) {\n\t\tsuper();\n\n\t\tconst telemetryProps: ISummarizeRunnerTelemetry = {\n\t\t\tsummarizeCount: () => this.summarizeCount,\n\t\t\tsummarizerSuccessfulAttempts: () => this.totalSuccessfulAttempts,\n\t\t};\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: baseLogger,\n\t\t\tnamespace: \"Running\",\n\t\t\tproperties: {\n\t\t\t\tall: telemetryProps,\n\t\t\t},\n\t\t});\n\n\t\tif (configuration.state !== \"disableHeuristics\") {\n\t\t\tassert(\n\t\t\t\tthis.configuration.state === \"enabled\",\n\t\t\t\t0x2ea /* \"Configuration state should be enabled\" */,\n\t\t\t);\n\t\t\tthis.heuristicRunner = new SummarizeHeuristicRunner(\n\t\t\t\theuristicData,\n\t\t\t\tthis.configuration,\n\t\t\t\t(reason) => this.trySummarize(reason),\n\t\t\t\tthis.mc.logger,\n\t\t\t);\n\t\t}\n\n\t\tassert(\n\t\t\tthis.configuration.state !== \"disabled\",\n\t\t\t0x2eb /* \"Summary not supported with configuration disabled\" */,\n\t\t);\n\n\t\t// Cap the maximum amount of time client will wait for a summarize op ack to maxSummarizeAckWaitTime\n\t\t// configuration.maxAckWaitTime is composed from defaults, server values, and runtime overrides\n\n\t\tconst maxAckWaitTime = Math.min(\n\t\t\tthis.configuration.maxAckWaitTime,\n\t\t\tmaxSummarizeAckWaitTime,\n\t\t);\n\n\t\tthis.pendingAckTimer = new PromiseTimer(maxAckWaitTime, () => {\n\t\t\t// Note: summarizeCount (from ChildLogger definition) may be 0,\n\t\t\t// since this code path is hit when RunningSummarizer first starts up,\n\t\t\t// before this instance has kicked off a new summarize run.\n\t\t\tthis.mc.logger.sendErrorEvent({\n\t\t\t\teventName: \"SummaryAckWaitTimeout\",\n\t\t\t\tmessage: \"Pending summary ack not received in time\",\n\t\t\t\tmaxAckWaitTime,\n\t\t\t\treferenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n\t\t\t\tsummarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n\t\t\t\ttimePending: Date.now() - this.heuristicData.lastAttempt.summaryTime,\n\t\t\t});\n\t\t});\n\t\t// Set up pending ack timeout by op timestamp differences for previous summaries.\n\t\tsummaryCollection.setPendingAckTimerTimeoutCallback(maxAckWaitTime, () => {\n\t\t\tif (this.pendingAckTimer.hasTimer) {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"MissingSummaryAckFoundByOps\",\n\t\t\t\t\treferenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n\t\t\t\t\tsummarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n\t\t\t\t});\n\t\t\t\tthis.pendingAckTimer.clear();\n\t\t\t}\n\t\t});\n\n\t\tconst immediatelyRefreshLatestSummaryAck =\n\t\t\tthis.mc.config.getBoolean(\"Fluid.Summarizer.immediatelyRefreshLatestSummaryAck\") ?? true;\n\t\tthis.generator = new SummaryGenerator(\n\t\t\tthis.pendingAckTimer,\n\t\t\tthis.heuristicData,\n\t\t\tthis.submitSummaryCallback,\n\t\t\t() => {\n\t\t\t\tthis.totalSuccessfulAttempts++;\n\t\t\t},\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\tasync (options: IRefreshSummaryAckOptions) => {\n\t\t\t\tif (immediatelyRefreshLatestSummaryAck) {\n\t\t\t\t\tawait this.refreshLatestSummaryAckAndHandleError(options);\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.summaryWatcher,\n\t\t\tthis.mc.logger,\n\t\t);\n\n\t\t// Listen to runtime for ops\n\t\tthis.runtimeListener = (op: ISequencedDocumentMessage, runtimeMessage?: boolean) => {\n\t\t\tthis.handleOp(op, runtimeMessage === true);\n\t\t};\n\t\tthis.runtime.on(\"op\", this.runtimeListener);\n\n\t\t// The max attempts for submit failures can be overridden via a feature flag. This allows us to\n\t\t// tweak this as per telemetry data until we arrive at a stable number.\n\t\t// If its set to a number higher than `defaultMaxAttemptsForSubmitFailures`, it will be ignored.\n\t\tconst overrideMaxAttempts = this.mc.config.getNumber(\n\t\t\t\"Fluid.Summarizer.AttemptsForSubmitFailures\",\n\t\t);\n\t\tthis.maxAttemptsForSubmitFailures =\n\t\t\toverrideMaxAttempts && overrideMaxAttempts < defaultMaxAttemptsForSubmitFailures\n\t\t\t\t? overrideMaxAttempts\n\t\t\t\t: defaultMaxAttemptsForSubmitFailures;\n\t}\n\n\tprivate async handleSummaryAck(ack: IAckedSummary): Promise<void> {\n\t\tconst refSequenceNumber = ack.summaryOp.referenceSequenceNumber;\n\t\tconst summaryLogger = this.tryGetCorrelatedLogger(refSequenceNumber) ?? this.mc.logger;\n\t\tconst summaryOpHandle = ack.summaryOp.contents.handle;\n\t\tconst summaryAckHandle = ack.summaryAck.contents.handle;\n\t\twhile (this.summarizingLock !== undefined) {\n\t\t\tsummaryLogger.sendTelemetryEvent({\n\t\t\t\teventName: \"RefreshAttemptWithSummarizerRunning\",\n\t\t\t\treferenceSequenceNumber: refSequenceNumber,\n\t\t\t\tproposalHandle: summaryOpHandle,\n\t\t\t\tackHandle: summaryAckHandle,\n\t\t\t});\n\t\t\tawait this.summarizingLock;\n\t\t}\n\n\t\t// Make sure we block any summarizer from being executed/enqueued while\n\t\t// executing the refreshLatestSummaryAck.\n\t\t// https://dev.azure.com/fluidframework/internal/_workitems/edit/779\n\t\tawait this.lockedSummaryAction(\n\t\t\t() => {},\n\t\t\tasync () => {\n\t\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\t\tconst options: IRefreshSummaryAckOptions = {\n\t\t\t\t\tproposalHandle: summaryOpHandle,\n\t\t\t\t\tackHandle: summaryAckHandle,\n\t\t\t\t\tsummaryRefSeq: refSequenceNumber,\n\t\t\t\t\tsummaryLogger,\n\t\t\t\t};\n\t\t\t\tawait this.refreshLatestSummaryAckAndHandleError(options);\n\t\t\t},\n\t\t\t() => {},\n\t\t);\n\t}\n\n\tprivate readonly refreshLatestSummaryAckAndHandleError = async (\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\toptions: IRefreshSummaryAckOptions,\n\t): Promise<void> => {\n\t\treturn this.refreshLatestSummaryAckCallback(options).catch(async (error) => {\n\t\t\t// If the error is 404, so maybe the fetched version no longer exists on server. We just\n\t\t\t// ignore this error in that case, as that means we will have another summaryAck for the\n\t\t\t// latest version with which we will refresh the state. However in case of single commit\n\t\t\t// summary, we might be missing a summary ack, so in that case we are still fine as the\n\t\t\t// code in `submitSummary` function in container runtime, will refresh the latest state\n\t\t\t// by calling `prefetchLatestSummaryThenClose`. We will load the next summarizer from the\n\t\t\t// updated state and be fine.\n\t\t\tconst isIgnoredError =\n\t\t\t\tisFluidError(error) &&\n\t\t\t\terror.errorType === DriverErrorTypes.fileNotFoundOrAccessDeniedError;\n\n\t\t\toptions.summaryLogger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: isIgnoredError\n\t\t\t\t\t\t? \"HandleSummaryAckErrorIgnored\"\n\t\t\t\t\t\t: \"HandleLastSummaryAckError\",\n\t\t\t\t\treferenceSequenceNumber: options.summaryRefSeq,\n\t\t\t\t\tproposalHandle: options.proposalHandle,\n\t\t\t\t\tackHandle: options.ackHandle,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t});\n\t};\n\n\t/**\n\t * Responsible for receiving and processing all the summary acks.\n\t * It starts processing ACKs after the one for the summary this client loaded from (initialSequenceNumber). Any\n\t * ACK before that is not interesting as it will simply be ignored.\n\t *\n\t * @param referenceSequenceNumber - The referenceSequenceNumber of the summary from which to start processing\n\t * acks.\n\t */\n\tprivate async processIncomingSummaryAcks(referenceSequenceNumber: number): Promise<void> {\n\t\t// Start waiting for acks that are for summaries newer that the one this client loaded from.\n\t\tlet nextReferenceSequenceNumber = referenceSequenceNumber;\n\t\twhile (!this.disposed) {\n\t\t\tconst ackedSummary = await this.summaryCollection.waitSummaryAck(\n\t\t\t\tnextReferenceSequenceNumber,\n\t\t\t);\n\t\t\tawait this.handleSummaryAck(ackedSummary);\n\t\t\tnextReferenceSequenceNumber = ackedSummary.summaryOp.referenceSequenceNumber + 1;\n\t\t}\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.runtime.off(\"op\", this.runtimeListener);\n\t\tthis.summaryWatcher.dispose();\n\t\tthis.heuristicRunner?.dispose();\n\t\tthis.heuristicRunner = undefined;\n\t\tthis.generator.dispose();\n\t\tthis.pendingAckTimer.clear();\n\t\tthis.disposeEnqueuedSummary();\n\t\tthis._disposed = true;\n\t\tthis.stopping = true;\n\t}\n\n\t/**\n\t * RunningSummarizer's logger includes the sequenced index of the current summary on each event.\n\t * If some other Summarizer code wants that event on their logs they can get it here,\n\t * but only if they're logging about that same summary.\n\t * @param summaryOpRefSeq - RefSeq number of the summary op, to ensure the log correlation will be correct\n\t */\n\tpublic tryGetCorrelatedLogger = (\n\t\tsummaryOpRefSeq: number,\n\t): ITelemetryLoggerExt | undefined =>\n\t\tthis.heuristicData.lastAttempt.refSequenceNumber === summaryOpRefSeq\n\t\t\t? this.mc.logger\n\t\t\t: undefined;\n\n\t/**\n\t * We only want a single heuristic runner micro-task (will provide better optimized grouping of ops)\n\t */\n\tprivate heuristicRunnerMicroTaskExists = false;\n\n\tpublic handleOp(op: ISequencedDocumentMessage, runtimeMessage: boolean): void {\n\t\tthis.heuristicData.lastOpSequenceNumber = op.sequenceNumber;\n\n\t\tif (runtimeMessage) {\n\t\t\tthis.heuristicData.numRuntimeOps++;\n\t\t} else {\n\t\t\tthis.heuristicData.numNonRuntimeOps++;\n\t\t}\n\n\t\tthis.heuristicData.totalOpsSize += opSize(op);\n\n\t\t// Check for enqueued on-demand summaries; Intentionally do nothing otherwise\n\t\tif (\n\t\t\tthis.initialized &&\n\t\t\tthis.opCanTriggerSummary(op, runtimeMessage) &&\n\t\t\t!this.tryRunEnqueuedSummary() &&\n\t\t\t!this.heuristicRunnerMicroTaskExists\n\t\t) {\n\t\t\tthis.heuristicRunnerMicroTaskExists = true;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\tPromise.resolve()\n\t\t\t\t.then(() => {\n\t\t\t\t\tthis.heuristicRunner?.run();\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis.heuristicRunnerMicroTaskExists = false;\n\t\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Can the given op trigger a summary?\n\t * # Currently always prevents summaries for Summarize and SummaryAck/Nack ops\n\t * @param op - op to check\n\t * @returns true if this op can trigger a summary\n\t */\n\tprivate opCanTriggerSummary(\n\t\top: ISequencedDocumentMessage,\n\t\truntimeMessage: boolean,\n\t): boolean {\n\t\tswitch (op.type) {\n\t\t\tcase MessageType.Summarize:\n\t\t\tcase MessageType.SummaryAck:\n\t\t\tcase MessageType.SummaryNack: {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn runtimeMessage || this.nonRuntimeOpCanTriggerSummary();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate nonRuntimeOpCanTriggerSummary(): boolean {\n\t\tconst opsSinceLastAck =\n\t\t\tthis.heuristicData.lastOpSequenceNumber -\n\t\t\tthis.heuristicData.lastSuccessfulSummary.refSequenceNumber;\n\t\treturn (\n\t\t\tthis.configuration.state === \"enabled\" &&\n\t\t\t(this.configuration.nonRuntimeHeuristicThreshold === undefined ||\n\t\t\t\tthis.configuration.nonRuntimeHeuristicThreshold <= opsSinceLastAck)\n\t\t);\n\t}\n\n\tpublic async waitStop(allowLastSummary: boolean): Promise<void> {\n\t\tif (this.stopping) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.stopping = true;\n\n\t\tthis.disposeEnqueuedSummary();\n\n\t\t// This will try to run lastSummary if needed.\n\t\tif (\n\t\t\tallowLastSummary &&\n\t\t\tthis.heuristicRunner?.shouldRunLastSummary() &&\n\t\t\tthis.summarizingLock === undefined\n\t\t) {\n\t\t\tthis.trySummarizeOnce(\n\t\t\t\t// summarizeProps\n\t\t\t\t{ summarizeReason: \"lastSummary\" },\n\t\t\t\t{},\n\t\t\t\tundefined,\n\t\t\t\ttrue /* isLastSummary */,\n\t\t\t);\n\t\t}\n\n\t\t// Note that trySummarizeOnce() call above returns right away, without waiting.\n\t\t// So we need to wait for its completion, otherwise it would be destroyed right away.\n\t\t// That said, if summary lock was taken upfront, this wait might wait on multiple retries to\n\t\t// submit summary. We should reconsider this flow and make summarizer move to exit faster.\n\t\t// This resolves when the current pending summary gets an ack or fails.\n\t\tawait this.summarizingLock;\n\n\t\tif (this.lastSummarizeFailureEventProps !== undefined) {\n\t\t\tthis.emit(\"summarizeAllAttemptsFailed\", {\n\t\t\t\t...this.lastSummarizeFailureEventProps,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t});\n\t\t}\n\t\tthis.lastSummarizeFailureEventProps = undefined;\n\t}\n\n\tprivate async waitStart(): Promise<void> {\n\t\t// Wait no longer than ack timeout for all pending\n\t\tconst waitStartResult = await raceTimer(\n\t\t\tthis.summaryWatcher.waitFlushed(),\n\t\t\tthis.pendingAckTimer.start(),\n\t\t);\n\t\tthis.pendingAckTimer.clear();\n\n\t\t// Remove pending ack wait timeout by op timestamp comparison, because\n\t\t// it has race conditions with summaries submitted by this same client.\n\t\tthis.summaryCollection.unsetPendingAckTimerTimeoutCallback();\n\n\t\tif (waitStartResult.result === \"done\" && waitStartResult.value !== undefined) {\n\t\t\tthis.heuristicData.updateWithLastSummaryAckInfo({\n\t\t\t\trefSequenceNumber: waitStartResult.value.summaryOp.referenceSequenceNumber,\n\t\t\t\t// This will be the Summarizer starting point so only use timestamps from client's machine.\n\t\t\t\tsummaryTime: Date.now(),\n\t\t\t\tsummarySequenceNumber: waitStartResult.value.summaryOp.sequenceNumber,\n\t\t\t});\n\t\t}\n\t\tthis.initialized = true;\n\t}\n\n\tprivate beforeSummaryAction(): void {\n\t\tthis.summarizeCount++;\n\t}\n\n\tprivate afterSummaryAction(): void {\n\t\tconst retry = this.tryWhileSummarizing;\n\t\tthis.tryWhileSummarizing = false;\n\n\t\t// After summarizing, we should check to see if we need to summarize again.\n\t\t// Rerun the heuristics and check for enqueued summaries.\n\t\tif (!this.stopping && !this.tryRunEnqueuedSummary() && retry) {\n\t\t\tthis.heuristicRunner?.run();\n\t\t}\n\t}\n\n\t/**\n\t * Runs single summary action that prevents any other concurrent actions.\n\t * Assumes that caller checked upfront for lack of concurrent action (this.summarizingLock)\n\t * before calling this API. I.e. caller is responsible for either erroring out or waiting on this promise.\n\t * @param before - set of instructions to run before running the action.\n\t * @param action - action to perform.\n\t * @param after - set of instructions to run after running the action.\n\t * @returns The result of the action.\n\t */\n\tprivate async lockedSummaryAction<T>(\n\t\tbefore: () => void,\n\t\taction: () => Promise<T>,\n\t\tafter: () => void,\n\t): Promise<T> {\n\t\tassert(\n\t\t\tthis.summarizingLock === undefined,\n\t\t\t0x25b /* \"Caller is responsible for checking lock\" */,\n\t\t);\n\n\t\tconst summarizingLock = new Deferred<void>();\n\t\tthis.summarizingLock = summarizingLock.promise;\n\n\t\tbefore();\n\n\t\treturn action().finally(() => {\n\t\t\tsummarizingLock.resolve();\n\t\t\tthis.summarizingLock = undefined;\n\t\t\tafter();\n\t\t});\n\t}\n\n\t/**\n\t * Runs single summarize attempt\n\t * @param summarizeProps - props to log with each telemetry event associated with this attempt\n\t * @param options - summary options\n\t * @param cancellationToken - cancellation token to use to be able to cancel this summary, if needed\n\t * @param resultsBuilder - optional, result builder to use.\n\t * @param isLastSummary - optional, is the call to this method for a last summary when shutting down the summarizer?\n\t * @returns ISummarizeResult - result of running a summary.\n\t */\n\tprivate trySummarizeOnce(\n\t\tsummarizeProps: ISummarizeTelemetryProperties,\n\t\toptions: ISummarizeOptions,\n\t\tresultsBuilder = new SummarizeResultBuilder(),\n\t\tisLastSummary = false,\n\t): ISummarizeResults {\n\t\tthis.lockedSummaryAction(\n\t\t\t() => {\n\t\t\t\tthis.beforeSummaryAction();\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryLogger = createChildLogger({\n\t\t\t\t\tlogger: this.mc.logger,\n\t\t\t\t\tproperties: { all: summarizeProps },\n\t\t\t\t});\n\t\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\t\tconst summaryOptions: ISubmitSummaryOptions = {\n\t\t\t\t\t...options,\n\t\t\t\t\tsummaryLogger,\n\t\t\t\t\tcancellationToken: this.cancellationToken,\n\t\t\t\t\tlatestSummaryRefSeqNum: this.heuristicData.lastSuccessfulSummary.refSequenceNumber,\n\t\t\t\t};\n\t\t\t\tconst summarizeResult = this.generator.summarize(summaryOptions, resultsBuilder);\n\t\t\t\t// ensure we wait till the end of the process\n\t\t\t\tconst result = await summarizeResult.receivedSummaryAckOrNack;\n\n\t\t\t\tif (result.success) {\n\t\t\t\t\tthis.emit(\"summarize\", {\n\t\t\t\t\t\tresult: \"success\",\n\t\t\t\t\t\tcurrentAttempt: 1,\n\t\t\t\t\t\tmaxAttempts: 1,\n\t\t\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t\t\t\tisLastSummary,\n\t\t\t\t\t});\n\t\t\t\t\tthis.lastSummarizeFailureEventProps = undefined;\n\t\t\t\t} else {\n\t\t\t\t\tthis.emit(\"summarize\", {\n\t\t\t\t\t\tresult: \"failure\",\n\t\t\t\t\t\tcurrentAttempt: 1,\n\t\t\t\t\t\tmaxAttempts: 1,\n\t\t\t\t\t\terror: result.error,\n\t\t\t\t\t\tfailureMessage: result.message,\n\t\t\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t\t\t\tisLastSummary,\n\t\t\t\t\t});\n\t\t\t\t\tthis.mc.logger.sendErrorEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"SummarizeFailed\",\n\t\t\t\t\t\t\tmaxAttempts: 1,\n\t\t\t\t\t\t\tsummaryAttempts: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresult.error,\n\t\t\t\t\t);\n\t\t\t\t\tif (isLastSummary) {\n\t\t\t\t\t\tthis.lastSummarizeFailureEventProps = {\n\t\t\t\t\t\t\tcurrentAttempt: (this.lastSummarizeFailureEventProps?.currentAttempt ?? 0) + 1,\n\t\t\t\t\t\t\tmaxAttempts: (this.lastSummarizeFailureEventProps?.currentAttempt ?? 0) + 1,\n\t\t\t\t\t\t\terror: result.error,\n\t\t\t\t\t\t\tfailureMessage: result.message,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tthis.afterSummaryAction();\n\t\t\t},\n\t\t).catch((error) => {\n\t\t\t// SummaryGenerator.summarize() does not throw exceptions - it converts them to failed result\n\t\t\t// on resultsBuilder\n\t\t\t// We do not care about exceptions on receivedSummaryAckOrNack - caller should check results\n\t\t\t// and take a appropriate action.\n\t\t});\n\n\t\treturn resultsBuilder.build();\n\t}\n\n\t/**\n\t * Heuristics summarize attempt.\n\t */\n\tprivate trySummarize(reason: SummarizeReason): void {\n\t\tif (this.summarizingLock !== undefined) {\n\t\t\t// lockedSummaryAction() will retry heuristic-based summary at the end of current attempt\n\t\t\t// if it's still needed\n\t\t\tthis.tryWhileSummarizing = true;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.lockedSummaryAction(\n\t\t\t() => {\n\t\t\t\tthis.beforeSummaryAction();\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\treturn this.trySummarizeWithRetries(reason);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tthis.afterSummaryAction();\n\t\t\t},\n\t\t).catch((error) => {\n\t\t\tthis.mc.logger.sendErrorEvent({ eventName: \"UnexpectedSummarizeError\" }, error);\n\t\t});\n\t}\n\n\t/**\n\t * Tries to summarize with retries where retry is based on the failure params.\n\t * For example, summarization may be retried for failures with \"retryAfterSeconds\" param.\n\t */\n\tprivate async trySummarizeWithRetries(\n\t\treason: SummarizeReason,\n\t): Promise<ISummarizeResults | undefined> {\n\t\t// Helper to set summarize options, telemetry properties and call summarize.\n\t\tconst attemptSummarize = (\n\t\t\tattemptNumber: number,\n\t\t\tfinalAttempt: boolean,\n\t\t): {\n\t\t\tsummarizeProps: ISummarizeTelemetryProperties;\n\t\t\tsummarizeResult: ISummarizeResults;\n\t\t} => {\n\t\t\tconst summarizeOptions: ISummarizeOptions = {\n\t\t\t\tfullTree: false,\n\t\t\t};\n\t\t\tconst summarizeProps: ISummarizeTelemetryProperties = {\n\t\t\t\tsummarizeReason: reason,\n\t\t\t\tsummaryAttempts: attemptNumber,\n\t\t\t\t...summarizeOptions,\n\t\t\t\tfinalAttempt,\n\t\t\t};\n\t\t\tconst summaryLogger = createChildLogger({\n\t\t\t\tlogger: this.mc.logger,\n\t\t\t\tproperties: { all: summarizeProps },\n\t\t\t});\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\tconst summaryOptions: ISubmitSummaryOptions = {\n\t\t\t\t...summarizeOptions,\n\t\t\t\tsummaryLogger,\n\t\t\t\tcancellationToken: this.cancellationToken,\n\t\t\t\tfinalAttempt,\n\t\t\t\tlatestSummaryRefSeqNum: this.heuristicData.lastSuccessfulSummary.refSequenceNumber,\n\t\t\t};\n\t\t\tconst summarizeResult = this.generator.summarize(summaryOptions);\n\t\t\treturn { summarizeProps, summarizeResult };\n\t\t};\n\n\t\t// The max number of attempts are based on the stage at which summarization failed. If it fails before it is\n\t\t// submitted, a different value is used compared to if it fails after submission. Usually, in the former case,\n\t\t// we would retry more often as its cheaper and retries are likely to succeed.\n\t\t// This makes it harder to predict how many attempts would actually happen as that depends on how far an attempt\n\t\t// made. To keep things simple, the max attempts is reset after every attempt based on where it failed. This may\n\t\t// result in some failures not being retried depending on what happened before this attempt. That's fine because\n\t\t// such scenarios are very unlikely and even if it happens, it would resolve when a new summarizer starts over.\n\t\t// For example - When failure switches from one the submit failures to nack failure, only one more retry will\n\t\t// happen irrespective of the value of `defaultMaxAttempts`.\n\t\tlet maxAttempts = defaultMaxAttempts;\n\t\tlet currentAttempt = 0;\n\t\tlet retryAfterSeconds: number | undefined;\n\t\tlet done = false;\n\t\tlet status: \"success\" | \"failure\" | \"canceled\" = \"success\";\n\t\tlet results: ISummarizeResults | undefined;\n\t\tlet error: IRetriableFailureError | undefined;\n\t\tlet failureMessage: string | undefined;\n\t\tdo {\n\t\t\tcurrentAttempt++;\n\t\t\tif (this.cancellationToken.cancelled) {\n\t\t\t\tstatus = \"canceled\";\n\t\t\t\tdone = true;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst attemptResult = attemptSummarize(currentAttempt, false /* finalAttempt */);\n\t\t\tresults = attemptResult.summarizeResult;\n\n\t\t\t// Ack / nack is the final step, so if it succeeds we're done.\n\t\t\tconst ackNackResult = await results.receivedSummaryAckOrNack;\n\t\t\tif (ackNackResult.success) {\n\t\t\t\tstatus = \"success\";\n\t\t\t\tdone = true;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Update max attempts from the failure result.\n\t\t\t// If submit summary failed, use maxAttemptsForSubmitFailures. Else use the defaultMaxAttempts.\n\t\t\t// Note: Check \"summarySubmitted\" result first because if it fails, ack nack would fail as well.\n\t\t\tconst submitSummaryResult = await results.summarySubmitted;\n\t\t\tmaxAttempts = submitSummaryResult.success\n\t\t\t\t? defaultMaxAttempts\n\t\t\t\t: this.maxAttemptsForSubmitFailures;\n\n\t\t\t// Emit \"summarize\" event for this failed attempt.\n\t\t\tstatus = \"failure\";\n\t\t\terror = ackNackResult.error;\n\t\t\tfailureMessage = ackNackResult.message;\n\t\t\tretryAfterSeconds = error.retryAfterSeconds;\n\t\t\tconst eventProps: ISummarizeEventProps & ISummarizerObservabilityProps = {\n\t\t\t\tresult: status,\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\terror,\n\t\t\t\tfailureMessage,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t};\n\t\t\tthis.emit(\"summarize\", eventProps);\n\n\t\t\t// Break if the failure doesn't have \"retryAfterSeconds\" or we are one less from max number of attempts.\n\t\t\t// Note that the final attempt if \"retryAfterSeconds\" does exist happens outside of the do..while loop.\n\t\t\tif (retryAfterSeconds === undefined || currentAttempt >= maxAttempts - 1) {\n\t\t\t\tdone = true;\n\t\t\t}\n\n\t\t\t// If the failure has \"retryAfterSeconds\", add a delay of that time before starting the next attempt.\n\t\t\tif (retryAfterSeconds !== undefined && retryAfterSeconds > 0) {\n\t\t\t\tthis.mc.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"SummarizeAttemptDelay\",\n\t\t\t\t\tduration: retryAfterSeconds * 1000,\n\t\t\t\t\tsummaryNackDelay: ackNackResult.data !== undefined, // This will only be defined only for nack failures.\n\t\t\t\t\tstage: submitSummaryResult.data?.stage,\n\t\t\t\t\t...attemptResult.summarizeProps,\n\t\t\t\t});\n\t\t\t\tawait delay(retryAfterSeconds * 1000);\n\t\t\t}\n\t\t} while (!done);\n\n\t\t// If the attempt was successful, emit \"summarize\" event and return. A failed attempt may be retried below.\n\t\tif (status !== \"failure\") {\n\t\t\tthis.emit(\"summarize\", {\n\t\t\t\tresult: status,\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t});\n\t\t\treturn results;\n\t\t}\n\n\t\t// If summarization wasn't successful above and the failure contains \"retryAfterSeconds\", perform one last\n\t\t// attempt. This gives a chance to the runtime to perform additional steps in the last attempt.\n\t\tif (retryAfterSeconds !== undefined) {\n\t\t\tconst { summarizeResult } = attemptSummarize(++currentAttempt, true /* finalAttempt */);\n\t\t\t// Ack / nack is the final step, so if it succeeds we're done.\n\t\t\tconst ackNackResult = await summarizeResult.receivedSummaryAckOrNack;\n\t\t\tstatus = ackNackResult.success ? \"success\" : \"failure\";\n\t\t\terror = ackNackResult.success ? undefined : ackNackResult.error;\n\t\t\tfailureMessage = ackNackResult.success ? undefined : ackNackResult.message;\n\t\t\tconst eventProps: ISummarizeEventProps & ISummarizerObservabilityProps = {\n\t\t\t\tresult: status,\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\terror,\n\t\t\t\tfailureMessage,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t};\n\t\t\tthis.emit(\"summarize\", eventProps);\n\t\t\tresults = summarizeResult;\n\t\t}\n\n\t\t// If summarization is still unsuccessful, stop the summarizer.\n\t\tif (status === \"failure\") {\n\t\t\tthis.mc.logger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"SummarizeFailed\",\n\t\t\t\t\tmaxAttempts,\n\t\t\t\t\tsummaryAttempts: currentAttempt,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\tthis.lastSummarizeFailureEventProps = {\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\terror,\n\t\t\t\tfailureMessage,\n\t\t\t};\n\t\t\tthis.stopSummarizerCallback(\"failToSummarize\");\n\t\t}\n\t\treturn results;\n\t}\n\n\t/**\n\t * Attempts to generate a summary on demand with retries in case of failures. The retry logic is the same\n\t * as heuristics based summaries.\n\t */\n\tprivate async summarizeOnDemandWithRetries(\n\t\treason: SummarizeReason,\n\t\tresultsBuilder: SummarizeResultBuilder,\n\t): Promise<ISummarizeResults> {\n\t\tconst results = await this.trySummarizeWithRetries(reason);\n\t\tif (results === undefined) {\n\t\t\tresultsBuilder.fail(\n\t\t\t\t\"Summarization was canceled\",\n\t\t\t\tnew RetriableSummaryError(\"Summarization was canceled\"),\n\t\t\t);\n\t\t\treturn resultsBuilder.build();\n\t\t}\n\t\tconst submitResult = await results.summarySubmitted;\n\t\tconst summaryOpBroadcastedResult = await results.summaryOpBroadcasted;\n\t\tconst ackNackResult = await results.receivedSummaryAckOrNack;\n\t\tresultsBuilder.summarySubmitted.resolve(submitResult);\n\t\tresultsBuilder.summaryOpBroadcasted.resolve(summaryOpBroadcastedResult);\n\t\tresultsBuilder.receivedSummaryAckOrNack.resolve(ackNackResult);\n\t\treturn resultsBuilder.build();\n\t}\n\n\t/**\n\t *{@inheritdoc (ISummarizer:interface).summarizeOnDemand}\n\t */\n\tpublic summarizeOnDemand(\n\t\toptions: IOnDemandSummarizeOptions,\n\t\tresultsBuilder: SummarizeResultBuilder = new SummarizeResultBuilder(),\n\t): ISummarizeResults {\n\t\tif (this.stopping) {\n\t\t\tresultsBuilder.fail(\n\t\t\t\t\"RunningSummarizer stopped or disposed\",\n\t\t\t\tnew RetriableSummaryError(\"RunningSummarizer stopped or disposed\"),\n\t\t\t);\n\t\t\treturn resultsBuilder.build();\n\t\t}\n\t\t// Check for concurrent summary attempts. If one is found,\n\t\t// return a promise that caller can await before trying again.\n\t\tif (this.summarizingLock !== undefined) {\n\t\t\t// The heuristics are blocking concurrent summarize attempts.\n\t\t\tthrow new UsageError(\"Attempted to run an already-running summarizer on demand\");\n\t\t}\n\n\t\tconst { reason, ...summarizeOptions } = options;\n\t\tif (options.retryOnFailure === true) {\n\t\t\tthis.summarizeOnDemandWithRetries(`onDemand;${reason}`, resultsBuilder).catch(\n\t\t\t\t(error: IRetriableFailureError) => {\n\t\t\t\t\tresultsBuilder.fail(\"summarize failed\", error);\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\tthis.trySummarizeOnce(\n\t\t\t\t{ summarizeReason: `onDemand/${reason}` },\n\t\t\t\tsummarizeOptions,\n\t\t\t\tresultsBuilder,\n\t\t\t);\n\t\t}\n\t\treturn resultsBuilder.build();\n\t}\n\n\t/**\n\t *{@inheritdoc (ISummarizer:interface).enqueueSummarize}\n\t */\n\tpublic enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tconst { reason, afterSequenceNumber = 0, override = false, ...summarizeOptions } = options;\n\t\tlet overridden = false;\n\t\tif (this.enqueuedSummary !== undefined) {\n\t\t\tif (!override) {\n\t\t\t\treturn { alreadyEnqueued: true };\n\t\t\t}\n\t\t\t// Override existing enqueued summarize attempt.\n\t\t\tthis.enqueuedSummary.resultsBuilder.fail(\n\t\t\t\t\"Aborted; overridden by another enqueue summarize attempt\",\n\t\t\t\tnew RetriableSummaryError(\n\t\t\t\t\t\"Summary was overridden by another enqueue summarize attempt\",\n\t\t\t\t),\n\t\t\t);\n\t\t\tthis.enqueuedSummary = undefined;\n\t\t\toverridden = true;\n\t\t}\n\n\t\tthis.enqueuedSummary = {\n\t\t\treason: `enqueue;${reason}`,\n\t\t\tafterSequenceNumber,\n\t\t\tsummarizeOptions,\n\t\t\tresultsBuilder: new SummarizeResultBuilder(),\n\t\t};\n\t\tconst results = this.enqueuedSummary.resultsBuilder.build();\n\t\tthis.tryRunEnqueuedSummary();\n\t\treturn overridden\n\t\t\t? {\n\t\t\t\t\t...results,\n\t\t\t\t\talreadyEnqueued: true,\n\t\t\t\t\toverridden: true,\n\t\t\t\t}\n\t\t\t: results;\n\t}\n\n\tprivate tryRunEnqueuedSummary(): boolean {\n\t\tif (this.stopping) {\n\t\t\tthis.disposeEnqueuedSummary();\n\t\t\treturn false;\n\t\t}\n\t\tif (\n\t\t\tthis.enqueuedSummary === undefined ||\n\t\t\tthis.heuristicData.lastOpSequenceNumber < this.enqueuedSummary.afterSequenceNumber ||\n\t\t\tthis.summarizingLock !== undefined\n\t\t) {\n\t\t\t// If no enqueued summary is ready or a summary is already in progress, take no action.\n\t\t\treturn false;\n\t\t}\n\t\tconst { reason, resultsBuilder, summarizeOptions } = this.enqueuedSummary;\n\t\t// Set to undefined first, so that subsequent enqueue attempt while summarize will occur later.\n\t\tthis.enqueuedSummary = undefined;\n\t\tthis.trySummarizeOnce(\n\t\t\t{ summarizeReason: `enqueuedSummary/${reason}` },\n\t\t\tsummarizeOptions,\n\t\t\tresultsBuilder,\n\t\t);\n\t\treturn true;\n\t}\n\n\tprivate disposeEnqueuedSummary(): void {\n\t\tif (this.enqueuedSummary !== undefined) {\n\t\t\tthis.enqueuedSummary.resultsBuilder.fail(\n\t\t\t\t\"RunningSummarizer stopped or disposed\",\n\t\t\t\tnew RetriableSummaryError(\"RunningSummarizer stopped or disposed\"),\n\t\t\t);\n\t\t\tthis.enqueuedSummary = undefined;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -24,6 +24,7 @@ export declare const createSummarizingWarning: (errorMessage: string, logged: bo
|
|
|
24
24
|
* It is created only by summarizing container (i.e. one with clientType === "summarizer")
|
|
25
25
|
* @legacy
|
|
26
26
|
* @alpha
|
|
27
|
+
* @deprecated This type will be moved to internal in 2.30. External usage is not necessary or supported.
|
|
27
28
|
*/
|
|
28
29
|
export declare class Summarizer extends TypedEventEmitter<ISummarizerEvents> implements ISummarizer {
|
|
29
30
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizer.d.ts","sourceRoot":"","sources":["../../src/summary/summarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EACX,iBAAiB,EACjB,oBAAoB,EACpB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE/E,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,YAAY,EAIZ,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"summarizer.d.ts","sourceRoot":"","sources":["../../src/summary/summarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EACX,iBAAiB,EACjB,oBAAoB,EACpB,MAAM,wDAAwD,CAA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AC,MAAM,CAAsB;IAC7C,OAAO,CAAC,iBAAiB,CAAC,CAAoB;IAC9C,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,QAAQ,CAAkB;IAElC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAwC;;IAGpE;;;OAGG;IAEc,OAAO,EAAE,kBAAkB,EAC3B,mBAAmB,EAAE,MAAM,qBAAqB;IACjE;;;OAGG;IAEc,iBAAiB,EAAE,4BAA4B,EAChE,aAAa,EAAE,mBAAmB,EAClB,iBAAiB,EAAE,iBAAiB,EACnC,sBAAsB,EAAE,CAExC,OAAO,EAAE,mBAAmB,KAExB,OAAO,CAAC,gCAAgC,CAAC;IASlC,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAuBnE;;;;OAIG;IACI,IAAI,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;IAIxC,KAAK,IAAI,IAAI;YAON,OAAO;IAgErB;;;;;OAKG;WACW,2BAA2B,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO;IAIpF,OAAO,CAAC,cAAc,CAAsC;IAE5D;;;;;;;;OAQG;YACW,KAAK;IA0DnB;;;;;OAKG;IACI,OAAO,IAAI,IAAI;IAYf,iBAAiB,CAAC,OAAO,EAAE,yBAAyB,GAAG,iBAAiB;IA4DxE,gBAAgB,CAAC,OAAO,EAAE,wBAAwB,GAAG,sBAAsB;IAW3E,oBAAoB,CAAC,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI;IAI7D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiC;IAEjE,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,sBAAsB;CAM9B"}
|
|
@@ -28,6 +28,7 @@ export const createSummarizingWarning = (errorMessage, logged) => new Summarizin
|
|
|
28
28
|
* It is created only by summarizing container (i.e. one with clientType === "summarizer")
|
|
29
29
|
* @legacy
|
|
30
30
|
* @alpha
|
|
31
|
+
* @deprecated This type will be moved to internal in 2.30. External usage is not necessary or supported.
|
|
31
32
|
*/
|
|
32
33
|
export class Summarizer extends TypedEventEmitter {
|
|
33
34
|
get ISummarizer() {
|
|
@@ -38,11 +39,13 @@ export class Summarizer extends TypedEventEmitter {
|
|
|
38
39
|
* Reference to runtime that created this object.
|
|
39
40
|
* i.e. runtime with clientType === "summarizer"
|
|
40
41
|
*/
|
|
42
|
+
// eslint-disable-next-line import/no-deprecated
|
|
41
43
|
runtime, configurationGetter,
|
|
42
44
|
/**
|
|
43
45
|
* Represents an object that can generate summary.
|
|
44
46
|
* In practical terms, it's same runtime (this.runtime) with clientType === "summarizer".
|
|
45
47
|
*/
|
|
48
|
+
// eslint-disable-next-line import/no-deprecated
|
|
46
49
|
internalsProvider, handleContext, summaryCollection, runCoordinatorCreateFn) {
|
|
47
50
|
super();
|
|
48
51
|
this.runtime = runtime;
|
|
@@ -98,9 +101,11 @@ export class Summarizer extends TypedEventEmitter {
|
|
|
98
101
|
this.runtime.disposeFn();
|
|
99
102
|
}
|
|
100
103
|
async runCore(onBehalfOf) {
|
|
104
|
+
// eslint-disable-next-line import/no-deprecated
|
|
101
105
|
const runCoordinator = await this.runCoordinatorCreateFn(this.runtime);
|
|
102
106
|
// Wait for either external signal to cancel, or loss of connectivity.
|
|
103
107
|
const stopP = Promise.race([runCoordinator.waitCancelled, this.stopDeferred.promise]);
|
|
108
|
+
// eslint-disable-next-line no-void
|
|
104
109
|
void stopP.then((reason) => {
|
|
105
110
|
this.logger.sendTelemetryEvent({
|
|
106
111
|
eventName: "StoppingSummarizer",
|
|
@@ -163,7 +168,9 @@ export class Summarizer extends TypedEventEmitter {
|
|
|
163
168
|
* @param newConfig - Summary configuration to override the existing config when invoking the RunningSummarizer.
|
|
164
169
|
* @returns A promise that is fulfilled when the RunningSummarizer is ready.
|
|
165
170
|
*/
|
|
166
|
-
async start(onBehalfOf,
|
|
171
|
+
async start(onBehalfOf,
|
|
172
|
+
// eslint-disable-next-line import/no-deprecated
|
|
173
|
+
runCoordinator) {
|
|
167
174
|
if (this.runningSummarizer) {
|
|
168
175
|
if (this.runningSummarizer.disposed) {
|
|
169
176
|
throw new UsageError("Starting a disposed summarizer");
|
|
@@ -257,12 +264,12 @@ export class Summarizer extends TypedEventEmitter {
|
|
|
257
264
|
runCoordinator.stop(stopReason);
|
|
258
265
|
this.close();
|
|
259
266
|
})
|
|
260
|
-
.catch((
|
|
261
|
-
builder.fail("Failed to start summarizer",
|
|
267
|
+
.catch((error) => {
|
|
268
|
+
builder.fail("Failed to start summarizer", error);
|
|
262
269
|
});
|
|
263
270
|
})
|
|
264
|
-
.catch((
|
|
265
|
-
builder.fail("Failed to create cancellation token",
|
|
271
|
+
.catch((error) => {
|
|
272
|
+
builder.fail("Failed to create cancellation token", error);
|
|
266
273
|
});
|
|
267
274
|
return builder.build();
|
|
268
275
|
}
|
|
@@ -282,18 +289,20 @@ export class Summarizer extends TypedEventEmitter {
|
|
|
282
289
|
this._heuristicData?.recordAttempt(summaryRefSeqNum);
|
|
283
290
|
}
|
|
284
291
|
setupForwardedEvents() {
|
|
285
|
-
["summarize", "summarizeAllAttemptsFailed"]
|
|
292
|
+
for (const event of ["summarize", "summarizeAllAttemptsFailed"]) {
|
|
286
293
|
const listener = (...args) => {
|
|
287
294
|
this.emit(event, ...args);
|
|
288
295
|
};
|
|
289
296
|
// TODO: better typing here
|
|
290
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
297
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
291
298
|
this.runningSummarizer?.on(event, listener);
|
|
292
299
|
this.forwardedEvents.set(event, listener);
|
|
293
|
-
}
|
|
300
|
+
}
|
|
294
301
|
}
|
|
295
302
|
cleanupForwardedEvents() {
|
|
296
|
-
|
|
303
|
+
for (const [event, listener] of this.forwardedEvents.entries()) {
|
|
304
|
+
this.runningSummarizer?.off(event, listener);
|
|
305
|
+
}
|
|
297
306
|
this.forwardedEvents.cl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,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tISummarizerEvents,\n\tSummarizerStopReason,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport { IFluidHandleContext } from \"@fluidframework/core-interfaces/internal\";\nimport { Deferred } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIFluidErrorBase,\n\tITelemetryLoggerExt,\n\tLoggingError,\n\tUsageError,\n\tcreateChildLogger,\n\twrapErrorAndLog,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ISummaryConfiguration } from \"../containerRuntime.js\";\n\nimport { ICancellableSummarizerController } from \"./runWhileConnectedCoordinator.js\";\nimport { RunningSummarizer } from \"./runningSummarizer.js\";\nimport { SummarizeHeuristicData } from \"./summarizerHeuristics.js\";\nimport {\n\tEnqueueSummarizeResult,\n\tIConnectableRuntime,\n\tIEnqueueSummarizeOptions,\n\tIOnDemandSummarizeOptions,\n\tISummarizeHeuristicData,\n\tISummarizeResults,\n\tISummarizer,\n\tISummarizerInternalsProvider,\n\tISummarizerRuntime,\n\tISummarizingWarning,\n} from \"./summarizerTypes.js\";\nimport { SummaryCollection } from \"./summaryCollection.js\";\nimport { SummarizeResultBuilder } from \"./summaryGenerator.js\";\n\nconst summarizingError = \"summarizingError\";\n\nexport class SummarizingWarning\n\textends LoggingError\n\timplements ISummarizingWarning, IFluidErrorBase\n{\n\treadonly errorType = summarizingError;\n\treadonly canRetry = true;\n\n\tconstructor(\n\t\terrorMessage: string,\n\t\treadonly logged: boolean = false,\n\t) {\n\t\tsuper(errorMessage);\n\t}\n\n\tstatic wrap(\n\t\terror: unknown,\n\t\tlogged: boolean = false,\n\t\tlogger: ITelemetryLoggerExt,\n\t): SummarizingWarning {\n\t\tconst newErrorFn = (errMsg: string): SummarizingWarning =>\n\t\t\tnew SummarizingWarning(errMsg, logged);\n\t\treturn wrapErrorAndLog<SummarizingWarning>(error, newErrorFn, logger);\n\t}\n}\n\nexport const createSummarizingWarning = (\n\terrorMessage: string,\n\tlogged: boolean,\n): SummarizingWarning => new SummarizingWarning(errorMessage, logged);\n\n/**\n * Summarizer is responsible for coordinating when to generate and send summaries.\n * It is the main entry point for summary work.\n * It is created only by summarizing container (i.e. one with clientType === \"summarizer\")\n * @legacy\n * @alpha\n */\nexport class Summarizer extends TypedEventEmitter<ISummarizerEvents> implements ISummarizer {\n\tpublic get ISummarizer(): this {\n\t\treturn this;\n\t}\n\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate runningSummarizer?: RunningSummarizer;\n\tprivate _disposed: boolean = false;\n\tprivate starting: boolean = false;\n\n\tprivate readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n\tconstructor(\n\t\t/**\n\t\t * Reference to runtime that created this object.\n\t\t * i.e. runtime with clientType === \"summarizer\"\n\t\t */\n\t\tprivate readonly runtime: ISummarizerRuntime,\n\t\tprivate readonly configurationGetter: () => ISummaryConfiguration,\n\t\t/**\n\t\t * Represents an object that can generate summary.\n\t\t * In practical terms, it's same runtime (this.runtime) with clientType === \"summarizer\".\n\t\t */\n\t\tprivate readonly internalsProvider: ISummarizerInternalsProvider,\n\t\thandleContext: IFluidHandleContext,\n\t\tpublic readonly summaryCollection: SummaryCollection,\n\t\tprivate readonly runCoordinatorCreateFn: (\n\t\t\truntime: IConnectableRuntime,\n\t\t) => Promise<ICancellableSummarizerController>,\n\t) {\n\t\tsuper();\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: this.runtime.baseLogger,\n\t\t\tnamespace: \"Summarizer\",\n\t\t});\n\t}\n\n\tpublic async run(onBehalfOf: string): Promise<SummarizerStopReason> {\n\t\ttry {\n\t\t\tconst stopReason = await this.runCore(onBehalfOf);\n\t\t\tthis.emit(\"summarizerStop\", {\n\t\t\t\tstopReason,\n\t\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t\t});\n\t\t\treturn stopReason;\n\t\t} catch (error) {\n\t\t\tthis.stop(\"summarizerException\");\n\t\t\tthis.emit(\"summarizerStop\", {\n\t\t\t\tstopReason: \"summarizerException\",\n\t\t\t\terror,\n\t\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t\t});\n\t\t\tthrow SummarizingWarning.wrap(error, false /* logged */, this.logger);\n\t\t} finally {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\t/**\n\t * Stops the summarizer from running. This will complete\n\t * the run promise, and also close the container.\n\t * @param reason - reason code for stopping\n\t */\n\tpublic stop(reason: SummarizerStopReason): void {\n\t\tthis.stopDeferred.resolve(reason);\n\t}\n\n\tpublic close(): void {\n\t\t// This will result in \"summarizerClientDisconnected\" stop reason recorded in telemetry,\n\t\t// unless stop() was called earlier\n\t\tthis.dispose();\n\t\tthis.runtime.disposeFn();\n\t}\n\n\tprivate async runCore(onBehalfOf: string): Promise<SummarizerStopReason> {\n\t\tconst runCoordinator: ICancellableSummarizerController = await this.runCoordinatorCreateFn(\n\t\t\tthis.runtime,\n\t\t);\n\n\t\t// Wait for either external signal to cancel, or loss of connectivity.\n\t\tconst stopP = Promise.race([runCoordinator.waitCancelled, this.stopDeferred.promise]);\n\t\tvoid stopP.then((reason) => {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"StoppingSummarizer\",\n\t\t\t\tonBehalfOf,\n\t\t\t\treason,\n\t\t\t});\n\t\t});\n\n\t\tif (runCoordinator.cancelled) {\n\t\t\tthis.emit(\"summarizerStartupFailed\", {\n\t\t\t\treason: await runCoordinator.waitCancelled,\n\t\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t\t});\n\t\t\treturn runCoordinator.waitCancelled;\n\t\t}\n\n\t\tthis.emit(\"summarizerStart\", {\n\t\t\tonBehalfOf,\n\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t});\n\n\t\tconst runningSummarizer = await this.start(onBehalfOf, runCoordinator);\n\n\t\t// Wait for either external signal to cancel, or loss of connectivity.\n\t\tconst stopReason = await stopP;\n\n\t\t// There are two possible approaches here:\n\t\t// 1. Propagate cancellation from this.stopDeferred to runCoordinator. This will ensure that we move to the exit\n\t\t// faster, including breaking out of the RunningSummarizer.trySummarize() faster.\n\t\t// We could create new coordinator and pass it to waitStop() -> trySummarizeOnce(\"lastSummary\") flow.\n\t\t// The con of this approach is that we might cancel active summary, and lastSummary will fail because it\n\t\t// did not wait for ack/nack from previous summary. Plus we disregard any 429 kind of info from service\n\t\t// that way (i.e. trySummarize() loop might have been waiting for 5 min because storage told us so).\n\t\t// In general, it's more wasted resources.\n\t\t// 2. We can not do it and make waitStop() do last summary only if there was no active summary. This ensures\n\t\t// that client behaves properly (from server POV) and we do not waste resources. But, it may mean we wait\n\t\t// substantially longer for trySummarize() retries to play out and thus this summary loop may run into\n\t\t// conflict with new summarizer client starting on different client.\n\t\t// As of now, #2 is implemented. It's more forward looking, as issue #7279 suggests changing design for new\n\t\t// summarizer client to not be created until current summarizer fully moves to exit, and that would reduce\n\t\t// cons of #2 substantially.\n\n\t\t// Cleanup after running\n\t\tawait runningSummarizer.waitStop(\n\t\t\t!runCoordinator.cancelled && Summarizer.stopReasonCanRunLastSummary(stopReason),\n\t\t);\n\n\t\t// Propagate reason and ensure that if someone is waiting for cancellation token, they are moving to exit\n\t\trunCoordinator.stop(stopReason);\n\n\t\treturn stopReason;\n\t}\n\n\t/**\n\t * Should we try to run a last summary for the given stop reason?\n\t * Currently only allows \"parentNotConnected\"\n\t * @param stopReason - SummarizerStopReason\n\t * @returns `true` if the stop reason can run a last summary, otherwise `false`.\n\t */\n\tpublic static stopReasonCanRunLastSummary(stopReason: SummarizerStopReason): boolean {\n\t\treturn stopReason === \"parentNotConnected\";\n\t}\n\n\tprivate _heuristicData: ISummarizeHeuristicData | undefined;\n\n\t/**\n\t * Put the summarizer in a started state, including creating and initializing the RunningSummarizer.\n\t * The start request can come either from the SummaryManager (in the auto-summarize case) or from the user\n\t * (in the on-demand case).\n\t * @param onBehalfOf - ID of the client that requested that the summarizer start\n\t * @param runCoordinator - cancellation token\n\t * @param newConfig - Summary configuration to override the existing config when invoking the RunningSummarizer.\n\t * @returns A promise that is fulfilled when the RunningSummarizer is ready.\n\t */\n\tprivate async start(\n\t\tonBehalfOf: string,\n\t\trunCoordinator: ICancellableSummarizerController,\n\t): Promise<RunningSummarizer> {\n\t\tif (this.runningSummarizer) {\n\t\t\tif (this.runningSummarizer.disposed) {\n\t\t\t\tthrow new UsageError(\"Starting a disposed summarizer\");\n\t\t\t}\n\t\t\treturn this.runningSummarizer;\n\t\t}\n\t\tif (this.starting) {\n\t\t\tthrow new UsageError(\"Attempting to start a summarizer that is already starting\");\n\t\t}\n\t\tthis.starting = true;\n\t\t// Initialize values and first ack (time is not exact)\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"RunningSummarizer\",\n\t\t\tonBehalfOf,\n\t\t\tinitSummarySeqNumber: this.runtime.deltaManager.initialSequenceNumber,\n\t\t\tconfig: JSON.stringify(this.configurationGetter()),\n\t\t});\n\n\t\t// Summarizing container ID (with clientType === \"summarizer\")\n\t\tconst clientId = this.runtime.clientId;\n\t\tif (clientId === undefined) {\n\t\t\tthrow new UsageError(\"clientId should be defined if connected.\");\n\t\t}\n\n\t\tthis._heuristicData = new SummarizeHeuristicData(\n\t\t\tthis.runtime.deltaManager.lastSequenceNumber,\n\t\t\t{\n\t\t\t\t/**\n\t\t\t\t * summary attempt baseline for heuristics\n\t\t\t\t */\n\t\t\t\trefSequenceNumber: this.runtime.deltaManager.initialSequenceNumber,\n\t\t\t\tsummaryTime: Date.now(),\n\t\t\t} as const,\n\t\t);\n\n\t\tconst runningSummarizer = await RunningSummarizer.start(\n\t\t\tthis.logger,\n\t\t\tthis.summaryCollection.createWatcher(clientId),\n\t\t\tthis.configurationGetter(),\n\t\t\tasync (...args) => this.internalsProvider.submitSummary(...args), // submitSummaryCallback\n\t\t\tasync (...args) => this.internalsProvider.refreshLatestSummaryAck(...args), // refreshLatestSummaryAckCallback\n\t\t\tthis._heuristicData,\n\t\t\tthis.summaryCollection,\n\t\t\trunCoordinator /* cancellationToken */,\n\t\t\t(reason) => runCoordinator.stop(reason) /* stopSummarizerCallback */,\n\t\t\tthis.runtime,\n\t\t);\n\t\tthis.runningSummarizer = runningSummarizer;\n\t\tthis.setupForwardedEvents();\n\t\tthis.starting = false;\n\t\treturn runningSummarizer;\n\t}\n\n\t/**\n\t * Disposes of resources after running. This cleanup will\n\t * clear any outstanding timers and reset some of the state\n\t * properties.\n\t * Called by ContainerRuntime when it is disposed, as well as at the end the run().\n\t */\n\tpublic dispose(): void {\n\t\t// Given that the call can come from own ContainerRuntime, ensure that we stop all the processes.\n\t\tthis.stop(\"summarizerClientDisconnected\");\n\n\t\tthis._disposed = true;\n\t\tif (this.runningSummarizer) {\n\t\t\tthis.cleanupForwardedEvents();\n\t\t\tthis.runningSummarizer.dispose();\n\t\t\tthis.runningSummarizer = undefined;\n\t\t}\n\t}\n\n\tpublic summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults {\n\t\ttry {\n\t\t\tif (this._disposed || this.runningSummarizer?.disposed) {\n\t\t\t\tthrow new UsageError(\"Summarizer is already disposed.\");\n\t\t\t}\n\t\t\tif (\n\t\t\t\tthis.runtime.summarizerClientId !== undefined &&\n\t\t\t\tthis.runtime.summarizerClientId !== this.runtime.clientId\n\t\t\t) {\n\t\t\t\t// If there is an elected summarizer, and it's not this one, don't allow on-demand summary.\n\t\t\t\t// This is to prevent the on-demand summary and heuristic-based summary from stepping on\n\t\t\t\t// each other.\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\"On-demand summary attempted while an elected summarizer is present\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst builder = new SummarizeResultBuilder();\n\t\t\tif (this.runningSummarizer) {\n\t\t\t\t// Summarizer is already running. Go ahead and start.\n\t\t\t\treturn this.runningSummarizer.summarizeOnDemand(options, builder);\n\t\t\t}\n\n\t\t\t// Summarizer isn't running, so we need to start it, which is an async operation.\n\t\t\t// Manage the promise related to creating the cancellation token here.\n\t\t\t// The promises related to starting, summarizing,\n\t\t\t// and submitting are communicated to the caller through the results builder.\n\t\t\tconst coordinatorCreateP = this.runCoordinatorCreateFn(this.runtime);\n\n\t\t\tcoordinatorCreateP\n\t\t\t\t.then((runCoordinator) => {\n\t\t\t\t\t// Successfully created the cancellation token. Start the summarizer.\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst startP = this.start(this.runtime.clientId!, runCoordinator);\n\t\t\t\t\tstartP\n\t\t\t\t\t\t.then(async (runningSummarizer) => {\n\t\t\t\t\t\t\t// Successfully started the summarizer. Run it.\n\t\t\t\t\t\t\trunningSummarizer.summarizeOnDemand(options, builder);\n\t\t\t\t\t\t\t// Wait for a command to stop or loss of connectivity before tearing down the summarizer and client.\n\t\t\t\t\t\t\tconst stopReason = await Promise.race([\n\t\t\t\t\t\t\t\tthis.stopDeferred.promise,\n\t\t\t\t\t\t\t\trunCoordinator.waitCancelled,\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\tawait runningSummarizer.waitStop(false);\n\t\t\t\t\t\t\trunCoordinator.stop(stopReason);\n\t\t\t\t\t\t\tthis.close();\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch((reason) => {\n\t\t\t\t\t\t\tbuilder.fail(\"Failed to start summarizer\", reason);\n\t\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.catch((reason) => {\n\t\t\t\t\tbuilder.fail(\"Failed to create cancellation token\", reason);\n\t\t\t\t});\n\n\t\t\treturn builder.build();\n\t\t} catch (error) {\n\t\t\tthrow SummarizingWarning.wrap(error, false /* logged */, this.logger);\n\t\t}\n\t}\n\n\tpublic enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tif (\n\t\t\tthis._disposed ||\n\t\t\tthis.runningSummarizer === undefined ||\n\t\t\tthis.runningSummarizer.disposed\n\t\t) {\n\t\t\tthrow new UsageError(\"Summarizer is not running or already disposed.\");\n\t\t}\n\t\treturn this.runningSummarizer.enqueueSummarize(options);\n\t}\n\n\tpublic recordSummaryAttempt?(summaryRefSeqNum?: number): void {\n\t\tthis._heuristicData?.recordAttempt(summaryRefSeqNum);\n\t}\n\n\tprivate readonly forwardedEvents = new Map<string, () => void>();\n\n\tprivate setupForwardedEvents(): void {\n\t\t[\"summarize\", \"summarizeAllAttemptsFailed\"].forEach((event) => {\n\t\t\tconst listener = (...args: any[]): void => {\n\t\t\t\tthis.emit(event, ...args);\n\t\t\t};\n\t\t\t// TODO: better typing here\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tthis.runningSummarizer?.on(event as any, listener);\n\t\t\tthis.forwardedEvents.set(event, listener);\n\t\t});\n\t}\n\n\tprivate cleanupForwardedEvents(): void {\n\t\tthis.forwardedEvents.forEach((listener, event) =>\n\t\t\tthis.runningSummarizer?.off(event, listener),\n\t\t);\n\t\tthis.forwardedEvents.clear();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"summarizer.js","sourceRoot":"","sources":["../../src/summary/summarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAMjE,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,EAGN,YAAY,EACZ,UAAU,EACV,iBAAiB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AI,CAAC,SAAS;YACd,IAAI,CAAC,iBAAiB,KAAK,SAAS;YACpC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAC9B,CAAC;YACF,MAAM,IAAI,UAAU,CAAC,gDAAgD,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IAEM,oBAAoB,CAAE,gBAAyB;QACrD,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACtD,CAAC;IAIO,oBAAoB;QAC3B,KAAK,MAAM,KAAK,IAAI,CAAC,WAAW,EAAE,4BAA4B,CAAC,EAAE,CAAC;YACjE,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAe,EAAQ,EAAE;gBAC7C,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;YAC3B,CAAC,CAAC;YACF,2BAA2B;YAC3B,qGAAqG;YACrG,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC,KAAY,EAAE,QAAQ,CAAC,CAAC;YACnD,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC3C,CAAC;IACF,CAAC;IAEO,sBAAsB;QAC7B,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC;YAChE,IAAI,CAAC,iBAAiB,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tISummarizerEvents,\n\tSummarizerStopReason,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport { IFluidHandleContext } from \"@fluidframework/core-interfaces/internal\";\nimport { Deferred } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIFluidErrorBase,\n\tITelemetryLoggerExt,\n\tLoggingError,\n\tUsageError,\n\tcreateChildLogger,\n\twrapErrorAndLog,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ISummaryConfiguration } from \"../containerRuntime.js\";\n\n// eslint-disable-next-line import/no-deprecated\nimport { ICancellableSummarizerController } from \"./runWhileConnectedCoordinator.js\";\nimport { RunningSummarizer } from \"./runningSummarizer.js\";\nimport { SummarizeHeuristicData } from \"./summarizerHeuristics.js\";\nimport {\n\tEnqueueSummarizeResult,\n\t// eslint-disable-next-line import/no-deprecated\n\tIConnectableRuntime,\n\tIEnqueueSummarizeOptions,\n\tIOnDemandSummarizeOptions,\n\tISummarizeHeuristicData,\n\tISummarizeResults,\n\tISummarizer,\n\t// eslint-disable-next-line import/no-deprecated\n\tISummarizerInternalsProvider,\n\t// eslint-disable-next-line import/no-deprecated\n\tISummarizerRuntime,\n\tISummarizingWarning,\n\ttype IRetriableFailureError,\n} from \"./summarizerTypes.js\";\nimport { SummaryCollection } from \"./summaryCollection.js\";\nimport { SummarizeResultBuilder } from \"./summaryGenerator.js\";\n\nconst summarizingError = \"summarizingError\";\n\nexport class SummarizingWarning\n\textends LoggingError\n\timplements ISummarizingWarning, IFluidErrorBase\n{\n\treadonly errorType = summarizingError;\n\treadonly canRetry = true;\n\n\tconstructor(\n\t\terrorMessage: string,\n\t\treadonly logged: boolean = false,\n\t) {\n\t\tsuper(errorMessage);\n\t}\n\n\tstatic wrap(\n\t\terror: unknown,\n\t\tlogged: boolean = false,\n\t\tlogger: ITelemetryLoggerExt,\n\t): SummarizingWarning {\n\t\tconst newErrorFn = (errMsg: string): SummarizingWarning =>\n\t\t\tnew SummarizingWarning(errMsg, logged);\n\t\treturn wrapErrorAndLog<SummarizingWarning>(error, newErrorFn, logger);\n\t}\n}\n\nexport const createSummarizingWarning = (\n\terrorMessage: string,\n\tlogged: boolean,\n): SummarizingWarning => new SummarizingWarning(errorMessage, logged);\n\n/**\n * Summarizer is responsible for coordinating when to generate and send summaries.\n * It is the main entry point for summary work.\n * It is created only by summarizing container (i.e. one with clientType === \"summarizer\")\n * @legacy\n * @alpha\n * @deprecated This type will be moved to internal in 2.30. External usage is not necessary or supported.\n */\nexport class Summarizer extends TypedEventEmitter<ISummarizerEvents> implements ISummarizer {\n\tpublic get ISummarizer(): this {\n\t\treturn this;\n\t}\n\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate runningSummarizer?: RunningSummarizer;\n\tprivate _disposed: boolean = false;\n\tprivate starting: boolean = false;\n\n\tprivate readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n\tconstructor(\n\t\t/**\n\t\t * Reference to runtime that created this object.\n\t\t * i.e. runtime with clientType === \"summarizer\"\n\t\t */\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tprivate readonly runtime: ISummarizerRuntime,\n\t\tprivate readonly configurationGetter: () => ISummaryConfiguration,\n\t\t/**\n\t\t * Represents an object that can generate summary.\n\t\t * In practical terms, it's same runtime (this.runtime) with clientType === \"summarizer\".\n\t\t */\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tprivate readonly internalsProvider: ISummarizerInternalsProvider,\n\t\thandleContext: IFluidHandleContext,\n\t\tpublic readonly summaryCollection: SummaryCollection,\n\t\tprivate readonly runCoordinatorCreateFn: (\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\truntime: IConnectableRuntime,\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t) => Promise<ICancellableSummarizerController>,\n\t) {\n\t\tsuper();\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: this.runtime.baseLogger,\n\t\t\tnamespace: \"Summarizer\",\n\t\t});\n\t}\n\n\tpublic async run(onBehalfOf: string): Promise<SummarizerStopReason> {\n\t\ttry {\n\t\t\tconst stopReason = await this.runCore(onBehalfOf);\n\t\t\tthis.emit(\"summarizerStop\", {\n\t\t\t\tstopReason,\n\t\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t\t});\n\t\t\treturn stopReason;\n\t\t} catch (error) {\n\t\t\tthis.stop(\"summarizerException\");\n\t\t\tthis.emit(\"summarizerStop\", {\n\t\t\t\tstopReason: \"summarizerException\",\n\t\t\t\terror,\n\t\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t\t});\n\t\t\tthrow SummarizingWarning.wrap(error, false /* logged */, this.logger);\n\t\t} finally {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\t/**\n\t * Stops the summarizer from running. This will complete\n\t * the run promise, and also close the container.\n\t * @param reason - reason code for stopping\n\t */\n\tpublic stop(reason: SummarizerStopReason): void {\n\t\tthis.stopDeferred.resolve(reason);\n\t}\n\n\tpublic close(): void {\n\t\t// This will result in \"summarizerClientDisconnected\" stop reason recorded in telemetry,\n\t\t// unless stop() was called earlier\n\t\tthis.dispose();\n\t\tthis.runtime.disposeFn();\n\t}\n\n\tprivate async runCore(onBehalfOf: string): Promise<SummarizerStopReason> {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tconst runCoordinator: ICancellableSummarizerController = await this.runCoordinatorCreateFn(\n\t\t\tthis.runtime,\n\t\t);\n\n\t\t// Wait for either external signal to cancel, or loss of connectivity.\n\t\tconst stopP = Promise.race([runCoordinator.waitCancelled, this.stopDeferred.promise]);\n\t\t// eslint-disable-next-line no-void\n\t\tvoid stopP.then((reason) => {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"StoppingSummarizer\",\n\t\t\t\tonBehalfOf,\n\t\t\t\treason,\n\t\t\t});\n\t\t});\n\n\t\tif (runCoordinator.cancelled) {\n\t\t\tthis.emit(\"summarizerStartupFailed\", {\n\t\t\t\treason: await runCoordinator.waitCancelled,\n\t\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t\t});\n\t\t\treturn runCoordinator.waitCancelled;\n\t\t}\n\n\t\tthis.emit(\"summarizerStart\", {\n\t\t\tonBehalfOf,\n\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t});\n\n\t\tconst runningSummarizer = await this.start(onBehalfOf, runCoordinator);\n\n\t\t// Wait for either external signal to cancel, or loss of connectivity.\n\t\tconst stopReason = await stopP;\n\n\t\t// There are two possible approaches here:\n\t\t// 1. Propagate cancellation from this.stopDeferred to runCoordinator. This will ensure that we move to the exit\n\t\t// faster, including breaking out of the RunningSummarizer.trySummarize() faster.\n\t\t// We could create new coordinator and pass it to waitStop() -> trySummarizeOnce(\"lastSummary\") flow.\n\t\t// The con of this approach is that we might cancel active summary, and lastSummary will fail because it\n\t\t// did not wait for ack/nack from previous summary. Plus we disregard any 429 kind of info from service\n\t\t// that way (i.e. trySummarize() loop might have been waiting for 5 min because storage told us so).\n\t\t// In general, it's more wasted resources.\n\t\t// 2. We can not do it and make waitStop() do last summary only if there was no active summary. This ensures\n\t\t// that client behaves properly (from server POV) and we do not waste resources. But, it may mean we wait\n\t\t// substantially longer for trySummarize() retries to play out and thus this summary loop may run into\n\t\t// conflict with new summarizer client starting on different client.\n\t\t// As of now, #2 is implemented. It's more forward looking, as issue #7279 suggests changing design for new\n\t\t// summarizer client to not be created until current summarizer fully moves to exit, and that would reduce\n\t\t// cons of #2 substantially.\n\n\t\t// Cleanup after running\n\t\tawait runningSummarizer.waitStop(\n\t\t\t!runCoordinator.cancelled && Summarizer.stopReasonCanRunLastSummary(stopReason),\n\t\t);\n\n\t\t// Propagate reason and ensure that if someone is waiting for cancellation token, they are moving to exit\n\t\trunCoordinator.stop(stopReason);\n\n\t\treturn stopReason;\n\t}\n\n\t/**\n\t * Should we try to run a last summary for the given stop reason?\n\t * Currently only allows \"parentNotConnected\"\n\t * @param stopReason - SummarizerStopReason\n\t * @returns `true` if the stop reason can run a last summary, otherwise `false`.\n\t */\n\tpublic static stopReasonCanRunLastSummary(stopReason: SummarizerStopReason): boolean {\n\t\treturn stopReason === \"parentNotConnected\";\n\t}\n\n\tprivate _heuristicData: ISummarizeHeuristicData | undefined;\n\n\t/**\n\t * Put the summarizer in a started state, including creating and initializing the RunningSummarizer.\n\t * The start request can come either from the SummaryManager (in the auto-summarize case) or from the user\n\t * (in the on-demand case).\n\t * @param onBehalfOf - ID of the client that requested that the summarizer start\n\t * @param runCoordinator - cancellation token\n\t * @param newConfig - Summary configuration to override the existing config when invoking the RunningSummarizer.\n\t * @returns A promise that is fulfilled when the RunningSummarizer is ready.\n\t */\n\tprivate async start(\n\t\tonBehalfOf: string,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\trunCoordinator: ICancellableSummarizerController,\n\t): Promise<RunningSummarizer> {\n\t\tif (this.runningSummarizer) {\n\t\t\tif (this.runningSummarizer.disposed) {\n\t\t\t\tthrow new UsageError(\"Starting a disposed summarizer\");\n\t\t\t}\n\t\t\treturn this.runningSummarizer;\n\t\t}\n\t\tif (this.starting) {\n\t\t\tthrow new UsageError(\"Attempting to start a summarizer that is already starting\");\n\t\t}\n\t\tthis.starting = true;\n\t\t// Initialize values and first ack (time is not exact)\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"RunningSummarizer\",\n\t\t\tonBehalfOf,\n\t\t\tinitSummarySeqNumber: this.runtime.deltaManager.initialSequenceNumber,\n\t\t\tconfig: JSON.stringify(this.configurationGetter()),\n\t\t});\n\n\t\t// Summarizing container ID (with clientType === \"summarizer\")\n\t\tconst clientId = this.runtime.clientId;\n\t\tif (clientId === undefined) {\n\t\t\tthrow new UsageError(\"clientId should be defined if connected.\");\n\t\t}\n\n\t\tthis._heuristicData = new SummarizeHeuristicData(\n\t\t\tthis.runtime.deltaManager.lastSequenceNumber,\n\t\t\t{\n\t\t\t\t/**\n\t\t\t\t * summary attempt baseline for heuristics\n\t\t\t\t */\n\t\t\t\trefSequenceNumber: this.runtime.deltaManager.initialSequenceNumber,\n\t\t\t\tsummaryTime: Date.now(),\n\t\t\t} as const,\n\t\t);\n\n\t\tconst runningSummarizer = await RunningSummarizer.start(\n\t\t\tthis.logger,\n\t\t\tthis.summaryCollection.createWatcher(clientId),\n\t\t\tthis.configurationGetter(),\n\t\t\tasync (...args) => this.internalsProvider.submitSummary(...args), // submitSummaryCallback\n\t\t\tasync (...args) => this.internalsProvider.refreshLatestSummaryAck(...args), // refreshLatestSummaryAckCallback\n\t\t\tthis._heuristicData,\n\t\t\tthis.summaryCollection,\n\t\t\trunCoordinator /* cancellationToken */,\n\t\t\t(reason) => runCoordinator.stop(reason) /* stopSummarizerCallback */,\n\t\t\tthis.runtime,\n\t\t);\n\t\tthis.runningSummarizer = runningSummarizer;\n\t\tthis.setupForwardedEvents();\n\t\tthis.starting = false;\n\t\treturn runningSummarizer;\n\t}\n\n\t/**\n\t * Disposes of resources after running. This cleanup will\n\t * clear any outstanding timers and reset some of the state\n\t * properties.\n\t * Called by ContainerRuntime when it is disposed, as well as at the end the run().\n\t */\n\tpublic dispose(): void {\n\t\t// Given that the call can come from own ContainerRuntime, ensure that we stop all the processes.\n\t\tthis.stop(\"summarizerClientDisconnected\");\n\n\t\tthis._disposed = true;\n\t\tif (this.runningSummarizer) {\n\t\t\tthis.cleanupForwardedEvents();\n\t\t\tthis.runningSummarizer.dispose();\n\t\t\tthis.runningSummarizer = undefined;\n\t\t}\n\t}\n\n\tpublic summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults {\n\t\ttry {\n\t\t\tif (this._disposed || this.runningSummarizer?.disposed) {\n\t\t\t\tthrow new UsageError(\"Summarizer is already disposed.\");\n\t\t\t}\n\t\t\tif (\n\t\t\t\tthis.runtime.summarizerClientId !== undefined &&\n\t\t\t\tthis.runtime.summarizerClientId !== this.runtime.clientId\n\t\t\t) {\n\t\t\t\t// If there is an elected summarizer, and it's not this one, don't allow on-demand summary.\n\t\t\t\t// This is to prevent the on-demand summary and heuristic-based summary from stepping on\n\t\t\t\t// each other.\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\"On-demand summary attempted while an elected summarizer is present\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst builder = new SummarizeResultBuilder();\n\t\t\tif (this.runningSummarizer) {\n\t\t\t\t// Summarizer is already running. Go ahead and start.\n\t\t\t\treturn this.runningSummarizer.summarizeOnDemand(options, builder);\n\t\t\t}\n\n\t\t\t// Summarizer isn't running, so we need to start it, which is an async operation.\n\t\t\t// Manage the promise related to creating the cancellation token here.\n\t\t\t// The promises related to starting, summarizing,\n\t\t\t// and submitting are communicated to the caller through the results builder.\n\t\t\tconst coordinatorCreateP = this.runCoordinatorCreateFn(this.runtime);\n\n\t\t\tcoordinatorCreateP\n\t\t\t\t.then((runCoordinator) => {\n\t\t\t\t\t// Successfully created the cancellation token. Start the summarizer.\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst startP = this.start(this.runtime.clientId!, runCoordinator);\n\t\t\t\t\tstartP\n\t\t\t\t\t\t.then(async (runningSummarizer) => {\n\t\t\t\t\t\t\t// Successfully started the summarizer. Run it.\n\t\t\t\t\t\t\trunningSummarizer.summarizeOnDemand(options, builder);\n\t\t\t\t\t\t\t// Wait for a command to stop or loss of connectivity before tearing down the summarizer and client.\n\t\t\t\t\t\t\tconst stopReason = await Promise.race([\n\t\t\t\t\t\t\t\tthis.stopDeferred.promise,\n\t\t\t\t\t\t\t\trunCoordinator.waitCancelled,\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\tawait runningSummarizer.waitStop(false);\n\t\t\t\t\t\t\trunCoordinator.stop(stopReason);\n\t\t\t\t\t\t\tthis.close();\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch((error: IRetriableFailureError) => {\n\t\t\t\t\t\t\tbuilder.fail(\"Failed to start summarizer\", error);\n\t\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.catch((error: IRetriableFailureError) => {\n\t\t\t\t\tbuilder.fail(\"Failed to create cancellation token\", error);\n\t\t\t\t});\n\n\t\t\treturn builder.build();\n\t\t} catch (error) {\n\t\t\tthrow SummarizingWarning.wrap(error, false /* logged */, this.logger);\n\t\t}\n\t}\n\n\tpublic enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tif (\n\t\t\tthis._disposed ||\n\t\t\tthis.runningSummarizer === undefined ||\n\t\t\tthis.runningSummarizer.disposed\n\t\t) {\n\t\t\tthrow new UsageError(\"Summarizer is not running or already disposed.\");\n\t\t}\n\t\treturn this.runningSummarizer.enqueueSummarize(options);\n\t}\n\n\tpublic recordSummaryAttempt?(summaryRefSeqNum?: number): void {\n\t\tthis._heuristicData?.recordAttempt(summaryRefSeqNum);\n\t}\n\n\tprivate readonly forwardedEvents = new Map<string, () => void>();\n\n\tprivate setupForwardedEvents(): void {\n\t\tfor (const event of [\"summarize\", \"summarizeAllAttemptsFailed\"]) {\n\t\t\tconst listener = (...args: unknown[]): void => {\n\t\t\t\tthis.emit(event, ...args);\n\t\t\t};\n\t\t\t// TODO: better typing here\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument\n\t\t\tthis.runningSummarizer?.on(event as any, listener);\n\t\t\tthis.forwardedEvents.set(event, listener);\n\t\t}\n\t}\n\n\tprivate cleanupForwardedEvents(): void {\n\t\tfor (const [event, listener] of this.forwardedEvents.entries()) {\n\t\t\tthis.runningSummarizer?.off(event, listener);\n\t\t}\n\t\tthis.forwardedEvents.clear();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizerClientElection.d.ts","sourceRoot":"","sources":["../../src/summary/summarizerClientElection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE/E,OAAO,EACN,sBAAsB,
|
|
1
|
+
{"version":3,"file":"summarizerClientElection.d.ts","sourceRoot":"","sources":["../../src/summary/summarizerClientElection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE/E,OAAO,EACN,sBAAsB,EAEtB,mBAAmB,EACnB,cAAc,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEpE,eAAO,MAAM,oBAAoB,eAAe,CAAC;AAEjD,MAAM,WAAW,+BAAgC,SAAQ,MAAM;IAC9D,CAAC,KAAK,EAAE,0BAA0B,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CAC/D;AAED,MAAM,WAAW,yBAChB,SAAQ,cAAc,CAAC,+BAA+B,CAAC;IACvD,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7C;AAED;;;;GAIG;AACH,qBAAa,wBACZ,SAAQ,iBAAiB,CAAC,+BAA+B,CACzD,YAAW,yBAAyB;IAwBnC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;aAClB,cAAc,EAAE,sBAAsB;IACtD,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IAzBxC;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B,CAAqB;IACvD;;;;OAIG;IACH,OAAO,CAAC,eAAe,CAAK;IAE5B,IAAW,eAAe,IAAI,MAAM,GAAG,SAAS,CAE/C;IACD,IAAW,eAAe,IAAI,MAAM,GAAG,SAAS,CAE/C;gBAGiB,MAAM,EAAE,mBAAmB,EAC3B,iBAAiB,EAAE,cAAc,CAAC,0BAA0B,CAAC,EAC9D,cAAc,EAAE,sBAAsB,EACrC,sBAAsB,EAAE,MAAM;IA0DzC,SAAS,IAAI,mBAAmB;WAUzB,gBAAgB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO;IAS/D,gBAAuB,2BAA2B,YAAa,cAAc,KAAG,OAAO,CACZ;CAC3E"}
|
|
@@ -79,6 +79,7 @@ export class SummarizerClientElection extends TypedEventEmitter {
|
|
|
79
79
|
this.emit("electedSummarizerChanged");
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
+
// eslint-disable-next-line import/no-deprecated
|
|
82
83
|
serialize() {
|
|
83
84
|
const { electedClientId, electedParentId, electionSequenceNumber } = this.clientElection.serialize();
|
|
84
85
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizerClientElection.js","sourceRoot":"","sources":["../../src/summary/summarizerClientElection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"summarizerClientElection.js","sourceRoot":"","sources":["../../src/summary/summarizerClientElection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,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ED,gDAAgD;IACzC,SAAS;QACf,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,sBAAsB,EAAE,GACjE,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;QACjC,OAAO;YACN,eAAe;YACf,eAAe;YACf,sBAAsB,EAAE,IAAI,CAAC,0BAA0B,IAAI,sBAAsB;SACjF,CAAC;IACH,CAAC;IAEM,MAAM,CAAC,gBAAgB,CAAC,MAAsB;QACpD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;QACtC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC3B,+BAA+B;YAC/B,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,wBAAwB,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC;IACtE,CAAC;;AAEsB,oDAA2B,GAAG,CAAC,OAAuB,EAAW,EAAE,CACzF,OAAO,CAAC,YAAY,CAAC,WAAW,IAAI,OAAO,CAAC,IAAI,KAAK,oBAAoB,AADxB,CACyB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IEvent, IEventProvider } from \"@fluidframework/core-interfaces\";\nimport { IClientDetails } from \"@fluidframework/driver-definitions\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tIOrderedClientElection,\n\t// eslint-disable-next-line import/no-deprecated\n\tISerializedElection,\n\tITrackedClient,\n} from \"./orderedClientElection.js\";\nimport { ISummaryCollectionOpEvents } from \"./summaryCollection.js\";\n\nexport const summarizerClientType = \"summarizer\";\n\nexport interface ISummarizerClientElectionEvents extends IEvent {\n\t(event: \"electedSummarizerChanged\", handler: () => void): void;\n}\n\nexport interface ISummarizerClientElection\n\textends IEventProvider<ISummarizerClientElectionEvents> {\n\treadonly electedClientId: string | undefined;\n\treadonly electedParentId: string | undefined;\n}\n\n/**\n * This class encapsulates logic around tracking the elected summarizer client.\n * It will handle updating the elected client when a summary ack hasn't been seen\n * for some configured number of ops.\n */\nexport class SummarizerClientElection\n\textends TypedEventEmitter<ISummarizerClientElectionEvents>\n\timplements ISummarizerClientElection\n{\n\t/**\n\t * Used to calculate number of ops since last summary ack for the current elected client.\n\t * This will be undefined if there is no elected summarizer, or no summary ack has been\n\t * observed since this client was elected.\n\t * When a summary ack comes in, this will be set to the sequence number of the summary ack.\n\t */\n\tprivate lastSummaryAckSeqForClient: number | undefined;\n\t/**\n\t * Used to prevent excess logging by recording the sequence number that we last reported at,\n\t * and making sure we don't report another event to telemetry. If things work as intended,\n\t * this is not needed, otherwise it could report an event on every op in worst case scenario.\n\t */\n\tprivate lastReportedSeq = 0;\n\n\tpublic get electedClientId(): string | undefined {\n\t\treturn this.clientElection.electedClient?.clientId;\n\t}\n\tpublic get electedParentId(): string | undefined {\n\t\treturn this.clientElection.electedParent?.clientId;\n\t}\n\n\tconstructor(\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly summaryCollection: IEventProvider<ISummaryCollectionOpEvents>,\n\t\tpublic readonly clientElection: IOrderedClientElection,\n\t\tprivate readonly maxOpsSinceLastSummary: number,\n\t) {\n\t\tsuper();\n\t\t// On every inbound op, if enough ops pass without seeing a summary ack (per elected client),\n\t\t// elect a new client and log to telemetry.\n\t\tthis.summaryCollection.on(\"default\", ({ sequenceNumber }) => {\n\t\t\tconst electedClientId = this.electedClientId;\n\t\t\tif (electedClientId === undefined) {\n\t\t\t\t// Reset election if no elected client, but eligible clients are connected.\n\t\t\t\t// This should be uncommon, but is possible if the initial state of the\n\t\t\t\t// ordered client election contains an undefined client id or one not found\n\t\t\t\t// in the quorum (the latter would already log an error).\n\t\t\t\tif (this.clientElection.eligibleCount > 0) {\n\t\t\t\t\tthis.clientElection.resetElectedClient(sequenceNumber);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst electionSequenceNumber = this.clientElection.electionSequenceNumber;\n\t\t\tconst opsWithoutSummary =\n\t\t\t\tsequenceNumber - (this.lastSummaryAckSeqForClient ?? electionSequenceNumber);\n\t\t\tif (opsWithoutSummary > this.maxOpsSinceLastSummary) {\n\t\t\t\t// Log and elect a new summarizer client.\n\t\t\t\tconst opsSinceLastReport = sequenceNumber - this.lastReportedSeq;\n\t\t\t\tif (opsSinceLastReport > this.maxOpsSinceLastSummary) {\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"ElectedClientNotSummarizing\",\n\t\t\t\t\t\telectedClientId,\n\t\t\t\t\t\tlastSummaryAckSeqForClient: this.lastSummaryAckSeqForClient,\n\t\t\t\t\t\telectionSequenceNumber,\n\t\t\t\t\t\tnextElectedClientId: this.clientElection.peekNextElectedClient()?.clientId,\n\t\t\t\t\t});\n\t\t\t\t\tthis.lastReportedSeq = sequenceNumber;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// When a summary ack comes in, reset our op seq counter.\n\t\tthis.summaryCollection.on(MessageType.SummaryAck, (op) => {\n\t\t\tthis.lastSummaryAckSeqForClient = op.sequenceNumber;\n\t\t});\n\n\t\t// Use oldest client election for unanimously and deterministically deciding\n\t\t// which client should summarize.\n\t\tthis.clientElection.on(\"election\", (client, sequenceNumber) => {\n\t\t\tthis.lastSummaryAckSeqForClient = undefined;\n\t\t\tif (client === undefined && this.clientElection.eligibleCount > 0) {\n\t\t\t\t// If no client is valid for election, reset to the oldest again.\n\t\t\t\t// Also make extra sure not to get stuck in an infinite loop here:\n\t\t\t\t// If there are no eligible clients, just wait until a client joins\n\t\t\t\t// and will be auto-elected.\n\t\t\t\tthis.clientElection.resetElectedClient(sequenceNumber);\n\t\t\t}\n\t\t\t// Election can trigger a change in SummaryManager state.\n\t\t\tthis.emit(\"electedSummarizerChanged\");\n\t\t});\n\t}\n\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic serialize(): ISerializedElection {\n\t\tconst { electedClientId, electedParentId, electionSequenceNumber } =\n\t\t\tthis.clientElection.serialize();\n\t\treturn {\n\t\t\telectedClientId,\n\t\t\telectedParentId,\n\t\t\telectionSequenceNumber: this.lastSummaryAckSeqForClient ?? electionSequenceNumber,\n\t\t};\n\t}\n\n\tpublic static isClientEligible(client: ITrackedClient): boolean {\n\t\tconst details = client.client.details;\n\t\tif (details === undefined) {\n\t\t\t// Very old clients back-compat\n\t\t\treturn true;\n\t\t}\n\t\treturn SummarizerClientElection.clientDetailsPermitElection(details);\n\t}\n\n\tpublic static readonly clientDetailsPermitElection = (details: IClientDetails): boolean =>\n\t\tdetails.capabilities.interactive || details.type === summarizerClientType;\n}\n"]}
|