@fluidframework/container-runtime 2.0.0-dev-rc.1.0.0.228517 → 2.0.0-dev-rc.2.0.0.245554

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (695) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +5 -5
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/CHANGELOG.md +54 -0
  4. package/README.md +46 -1
  5. package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
  6. package/api-extractor-lint.json +1 -1
  7. package/api-extractor.json +1 -1
  8. package/api-report/container-runtime.api.md +435 -33
  9. package/dist/batchTracker.d.ts +1 -2
  10. package/dist/batchTracker.d.ts.map +1 -1
  11. package/dist/batchTracker.js.map +1 -1
  12. package/dist/blobManager.d.ts +0 -5
  13. package/dist/blobManager.d.ts.map +1 -1
  14. package/dist/blobManager.js +0 -12
  15. package/dist/blobManager.js.map +1 -1
  16. package/dist/channelCollection.d.ts +225 -0
  17. package/dist/channelCollection.d.ts.map +1 -0
  18. package/dist/{dataStores.js → channelCollection.js} +449 -143
  19. package/dist/channelCollection.js.map +1 -0
  20. package/dist/connectionTelemetry.d.ts +11 -1
  21. package/dist/connectionTelemetry.d.ts.map +1 -1
  22. package/dist/connectionTelemetry.js +42 -4
  23. package/dist/connectionTelemetry.js.map +1 -1
  24. package/dist/container-runtime-alpha.d.ts +138 -49
  25. package/dist/container-runtime-beta.d.ts +75 -9
  26. package/dist/container-runtime-public.d.ts +75 -9
  27. package/dist/container-runtime-untrimmed.d.ts +717 -49
  28. package/dist/containerHandleContext.d.ts +1 -1
  29. package/dist/containerHandleContext.d.ts.map +1 -1
  30. package/dist/containerHandleContext.js.map +1 -1
  31. package/dist/containerRuntime.d.ts +84 -64
  32. package/dist/containerRuntime.d.ts.map +1 -1
  33. package/dist/containerRuntime.js +550 -427
  34. package/dist/containerRuntime.js.map +1 -1
  35. package/dist/dataStore.d.ts +2 -3
  36. package/dist/dataStore.d.ts.map +1 -1
  37. package/dist/dataStore.js +12 -11
  38. package/dist/dataStore.js.map +1 -1
  39. package/dist/dataStoreContext.d.ts +118 -38
  40. package/dist/dataStoreContext.d.ts.map +1 -1
  41. package/dist/dataStoreContext.js +249 -161
  42. package/dist/dataStoreContext.js.map +1 -1
  43. package/dist/dataStoreContexts.d.ts +2 -1
  44. package/dist/dataStoreContexts.d.ts.map +1 -1
  45. package/dist/dataStoreContexts.js +1 -0
  46. package/dist/dataStoreContexts.js.map +1 -1
  47. package/dist/deltaManagerSummarizerProxy.d.ts +29 -4
  48. package/dist/deltaManagerSummarizerProxy.d.ts.map +1 -1
  49. package/dist/deltaManagerSummarizerProxy.js +91 -5
  50. package/dist/deltaManagerSummarizerProxy.js.map +1 -1
  51. package/dist/gc/garbageCollection.d.ts +29 -7
  52. package/dist/gc/garbageCollection.d.ts.map +1 -1
  53. package/dist/gc/garbageCollection.js +179 -98
  54. package/dist/gc/garbageCollection.js.map +1 -1
  55. package/dist/gc/gcConfigs.d.ts +2 -2
  56. package/dist/gc/gcConfigs.d.ts.map +1 -1
  57. package/dist/gc/gcConfigs.js +30 -23
  58. package/dist/gc/gcConfigs.js.map +1 -1
  59. package/dist/gc/gcDefinitions.d.ts +40 -15
  60. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  61. package/dist/gc/gcDefinitions.js +11 -4
  62. package/dist/gc/gcDefinitions.js.map +1 -1
  63. package/dist/gc/gcHelpers.d.ts +2 -2
  64. package/dist/gc/gcHelpers.d.ts.map +1 -1
  65. package/dist/gc/gcHelpers.js.map +1 -1
  66. package/dist/gc/gcReferenceGraphAlgorithm.d.ts +1 -1
  67. package/dist/gc/gcReferenceGraphAlgorithm.d.ts.map +1 -1
  68. package/dist/gc/gcReferenceGraphAlgorithm.js.map +1 -1
  69. package/dist/gc/gcSummaryStateTracker.d.ts +12 -5
  70. package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -1
  71. package/dist/gc/gcSummaryStateTracker.js +18 -6
  72. package/dist/gc/gcSummaryStateTracker.js.map +1 -1
  73. package/dist/gc/gcTelemetry.d.ts +7 -7
  74. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  75. package/dist/gc/gcTelemetry.js +20 -20
  76. package/dist/gc/gcTelemetry.js.map +1 -1
  77. package/dist/gc/gcUnreferencedStateTracker.d.ts +6 -1
  78. package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -1
  79. package/dist/gc/gcUnreferencedStateTracker.js +22 -11
  80. package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
  81. package/dist/gc/index.d.ts +8 -8
  82. package/dist/gc/index.d.ts.map +1 -1
  83. package/dist/gc/index.js +40 -38
  84. package/dist/gc/index.js.map +1 -1
  85. package/dist/index.d.ts +11 -20
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +36 -40
  88. package/dist/index.js.map +1 -1
  89. package/dist/messageTypes.d.ts +4 -4
  90. package/dist/messageTypes.d.ts.map +1 -1
  91. package/dist/messageTypes.js.map +1 -1
  92. package/dist/opLifecycle/batchManager.d.ts +2 -2
  93. package/dist/opLifecycle/batchManager.d.ts.map +1 -1
  94. package/dist/opLifecycle/batchManager.js.map +1 -1
  95. package/dist/opLifecycle/definitions.d.ts +2 -2
  96. package/dist/opLifecycle/definitions.d.ts.map +1 -1
  97. package/dist/opLifecycle/definitions.js.map +1 -1
  98. package/dist/opLifecycle/index.d.ts +8 -8
  99. package/dist/opLifecycle/index.d.ts.map +1 -1
  100. package/dist/opLifecycle/index.js +18 -18
  101. package/dist/opLifecycle/index.js.map +1 -1
  102. package/dist/opLifecycle/opCompressor.d.ts +1 -1
  103. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  104. package/dist/opLifecycle/opCompressor.js +4 -4
  105. package/dist/opLifecycle/opCompressor.js.map +1 -1
  106. package/dist/opLifecycle/opDecompressor.d.ts +1 -1
  107. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  108. package/dist/opLifecycle/opDecompressor.js +3 -3
  109. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  110. package/dist/opLifecycle/opGroupingManager.d.ts +1 -1
  111. package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -1
  112. package/dist/opLifecycle/opGroupingManager.js +1 -10
  113. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  114. package/dist/opLifecycle/opSplitter.d.ts +1 -1
  115. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  116. package/dist/opLifecycle/opSplitter.js +5 -5
  117. package/dist/opLifecycle/opSplitter.js.map +1 -1
  118. package/dist/opLifecycle/outbox.d.ts +7 -7
  119. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  120. package/dist/opLifecycle/outbox.js +20 -12
  121. package/dist/opLifecycle/outbox.js.map +1 -1
  122. package/dist/opLifecycle/remoteMessageProcessor.d.ts +4 -4
  123. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  124. package/dist/opLifecycle/remoteMessageProcessor.js +2 -2
  125. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  126. package/dist/package.json +3 -0
  127. package/dist/packageVersion.d.ts +1 -1
  128. package/dist/packageVersion.js +1 -1
  129. package/dist/packageVersion.js.map +1 -1
  130. package/dist/pendingStateManager.d.ts +2 -1
  131. package/dist/pendingStateManager.d.ts.map +1 -1
  132. package/dist/pendingStateManager.js +18 -10
  133. package/dist/pendingStateManager.js.map +1 -1
  134. package/dist/scheduleManager.d.ts +1 -2
  135. package/dist/scheduleManager.d.ts.map +1 -1
  136. package/dist/scheduleManager.js +5 -5
  137. package/dist/scheduleManager.js.map +1 -1
  138. package/dist/summary/index.d.ts +12 -12
  139. package/dist/summary/index.d.ts.map +1 -1
  140. package/dist/summary/index.js +43 -43
  141. package/dist/summary/index.js.map +1 -1
  142. package/dist/summary/orderedClientElection.js +8 -8
  143. package/dist/summary/orderedClientElection.js.map +1 -1
  144. package/dist/summary/runWhileConnectedCoordinator.d.ts +1 -1
  145. package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -1
  146. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
  147. package/dist/summary/runningSummarizer.d.ts +11 -10
  148. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  149. package/dist/summary/runningSummarizer.js +114 -81
  150. package/dist/summary/runningSummarizer.js.map +1 -1
  151. package/dist/summary/summarizer.d.ts +4 -4
  152. package/dist/summary/summarizer.d.ts.map +1 -1
  153. package/dist/summary/summarizer.js +6 -6
  154. package/dist/summary/summarizer.js.map +1 -1
  155. package/dist/summary/summarizerClientElection.d.ts +2 -2
  156. package/dist/summary/summarizerClientElection.d.ts.map +1 -1
  157. package/dist/summary/summarizerClientElection.js.map +1 -1
  158. package/dist/summary/summarizerHeuristics.d.ts +3 -3
  159. package/dist/summary/summarizerHeuristics.d.ts.map +1 -1
  160. package/dist/summary/summarizerHeuristics.js.map +1 -1
  161. package/dist/summary/summarizerNode/index.d.ts +3 -3
  162. package/dist/summary/summarizerNode/index.d.ts.map +1 -1
  163. package/dist/summary/summarizerNode/index.js +4 -4
  164. package/dist/summary/summarizerNode/index.js.map +1 -1
  165. package/dist/summary/summarizerNode/summarizerNode.d.ts +17 -7
  166. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  167. package/dist/summary/summarizerNode/summarizerNode.js +45 -57
  168. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  169. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +10 -19
  170. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  171. package/dist/summary/summarizerNode/summarizerNodeUtils.js +1 -21
  172. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  173. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +5 -6
  174. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  175. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +16 -16
  176. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  177. package/dist/summary/summarizerTypes.d.ts +10 -21
  178. package/dist/summary/summarizerTypes.d.ts.map +1 -1
  179. package/dist/summary/summarizerTypes.js.map +1 -1
  180. package/dist/summary/summaryFormat.d.ts +15 -2
  181. package/dist/summary/summaryFormat.d.ts.map +1 -1
  182. package/dist/summary/summaryFormat.js.map +1 -1
  183. package/dist/summary/summaryGenerator.d.ts +6 -5
  184. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  185. package/dist/summary/summaryGenerator.js +10 -1
  186. package/dist/summary/summaryGenerator.js.map +1 -1
  187. package/dist/summary/summaryManager.d.ts +5 -6
  188. package/dist/summary/summaryManager.d.ts.map +1 -1
  189. package/dist/summary/summaryManager.js +4 -5
  190. package/dist/summary/summaryManager.js.map +1 -1
  191. package/dist/tsdoc-metadata.json +1 -1
  192. package/lib/{batchTracker.d.mts → batchTracker.d.ts} +2 -3
  193. package/lib/batchTracker.d.ts.map +1 -0
  194. package/lib/{batchTracker.mjs → batchTracker.js} +1 -1
  195. package/lib/batchTracker.js.map +1 -0
  196. package/lib/{blobManager.d.mts → blobManager.d.ts} +1 -6
  197. package/lib/blobManager.d.ts.map +1 -0
  198. package/lib/{blobManager.mjs → blobManager.js} +1 -13
  199. package/lib/blobManager.js.map +1 -0
  200. package/lib/channelCollection.d.ts +225 -0
  201. package/lib/channelCollection.d.ts.map +1 -0
  202. package/lib/{dataStores.mjs → channelCollection.js} +436 -133
  203. package/lib/channelCollection.js.map +1 -0
  204. package/lib/{connectionTelemetry.d.mts → connectionTelemetry.d.ts} +12 -2
  205. package/lib/connectionTelemetry.d.ts.map +1 -0
  206. package/lib/{connectionTelemetry.mjs → connectionTelemetry.js} +43 -5
  207. package/lib/connectionTelemetry.js.map +1 -0
  208. package/lib/{container-runtime-alpha.d.mts → container-runtime-alpha.d.ts} +138 -49
  209. package/lib/{container-runtime-beta.d.mts → container-runtime-beta.d.ts} +75 -9
  210. package/lib/{container-runtime-public.d.mts → container-runtime-public.d.ts} +75 -9
  211. package/lib/{container-runtime-untrimmed.d.mts → container-runtime-untrimmed.d.ts} +717 -49
  212. package/lib/{containerHandleContext.d.mts → containerHandleContext.d.ts} +2 -2
  213. package/lib/containerHandleContext.d.ts.map +1 -0
  214. package/lib/{containerHandleContext.mjs → containerHandleContext.js} +1 -1
  215. package/lib/containerHandleContext.js.map +1 -0
  216. package/lib/{containerRuntime.d.mts → containerRuntime.d.ts} +89 -65
  217. package/lib/containerRuntime.d.ts.map +1 -0
  218. package/lib/{containerRuntime.mjs → containerRuntime.js} +469 -348
  219. package/lib/containerRuntime.js.map +1 -0
  220. package/lib/{dataStore.d.mts → dataStore.d.ts} +3 -4
  221. package/lib/dataStore.d.ts.map +1 -0
  222. package/lib/{dataStore.mjs → dataStore.js} +13 -12
  223. package/lib/dataStore.js.map +1 -0
  224. package/lib/{dataStoreContext.d.mts → dataStoreContext.d.ts} +119 -39
  225. package/lib/dataStoreContext.d.ts.map +1 -0
  226. package/lib/{dataStoreContext.mjs → dataStoreContext.js} +241 -153
  227. package/lib/dataStoreContext.js.map +1 -0
  228. package/lib/{dataStoreContexts.d.mts → dataStoreContexts.d.ts} +3 -2
  229. package/lib/dataStoreContexts.d.ts.map +1 -0
  230. package/lib/{dataStoreContexts.mjs → dataStoreContexts.js} +2 -1
  231. package/lib/dataStoreContexts.js.map +1 -0
  232. package/lib/{dataStoreRegistry.d.mts → dataStoreRegistry.d.ts} +1 -1
  233. package/lib/dataStoreRegistry.d.ts.map +1 -0
  234. package/lib/{dataStoreRegistry.mjs → dataStoreRegistry.js} +5 -1
  235. package/lib/dataStoreRegistry.js.map +1 -0
  236. package/{dist/deltaManagerProxyBase.d.ts → lib/deltaManagerSummarizerProxy.d.ts} +16 -7
  237. package/lib/deltaManagerSummarizerProxy.d.ts.map +1 -0
  238. package/lib/deltaManagerSummarizerProxy.js +124 -0
  239. package/lib/deltaManagerSummarizerProxy.js.map +1 -0
  240. package/lib/{deltaScheduler.d.mts → deltaScheduler.d.ts} +1 -1
  241. package/lib/deltaScheduler.d.ts.map +1 -0
  242. package/lib/{deltaScheduler.mjs → deltaScheduler.js} +1 -1
  243. package/lib/deltaScheduler.js.map +1 -0
  244. package/lib/{error.d.mts → error.d.ts} +1 -1
  245. package/lib/error.d.ts.map +1 -0
  246. package/lib/{error.mjs → error.js} +1 -1
  247. package/lib/error.js.map +1 -0
  248. package/lib/gc/{garbageCollection.d.mts → garbageCollection.d.ts} +30 -8
  249. package/lib/gc/garbageCollection.d.ts.map +1 -0
  250. package/lib/gc/{garbageCollection.mjs → garbageCollection.js} +149 -68
  251. package/lib/gc/garbageCollection.js.map +1 -0
  252. package/lib/gc/{gcConfigs.d.mts → gcConfigs.d.ts} +3 -3
  253. package/lib/gc/gcConfigs.d.ts.map +1 -0
  254. package/lib/gc/{gcConfigs.mjs → gcConfigs.js} +14 -7
  255. package/lib/gc/gcConfigs.js.map +1 -0
  256. package/lib/gc/{gcDefinitions.d.mts → gcDefinitions.d.ts} +41 -16
  257. package/lib/gc/gcDefinitions.d.ts.map +1 -0
  258. package/lib/gc/{gcDefinitions.mjs → gcDefinitions.js} +11 -4
  259. package/lib/gc/gcDefinitions.js.map +1 -0
  260. package/lib/gc/{gcHelpers.d.mts → gcHelpers.d.ts} +3 -3
  261. package/lib/gc/{gcHelpers.d.mts.map → gcHelpers.d.ts.map} +1 -1
  262. package/lib/gc/{gcHelpers.mjs → gcHelpers.js} +1 -1
  263. package/lib/gc/gcHelpers.js.map +1 -0
  264. package/lib/gc/{gcReferenceGraphAlgorithm.d.mts → gcReferenceGraphAlgorithm.d.ts} +2 -2
  265. package/lib/gc/gcReferenceGraphAlgorithm.d.ts.map +1 -0
  266. package/lib/gc/{gcReferenceGraphAlgorithm.mjs → gcReferenceGraphAlgorithm.js} +1 -1
  267. package/lib/gc/gcReferenceGraphAlgorithm.js.map +1 -0
  268. package/lib/gc/{gcSummaryDefinitions.d.mts → gcSummaryDefinitions.d.ts} +1 -1
  269. package/lib/gc/gcSummaryDefinitions.d.ts.map +1 -0
  270. package/lib/gc/{gcSummaryDefinitions.mjs → gcSummaryDefinitions.js} +1 -1
  271. package/lib/gc/gcSummaryDefinitions.js.map +1 -0
  272. package/lib/gc/{gcSummaryStateTracker.d.mts → gcSummaryStateTracker.d.ts} +13 -6
  273. package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -0
  274. package/lib/gc/{gcSummaryStateTracker.mjs → gcSummaryStateTracker.js} +17 -5
  275. package/lib/gc/gcSummaryStateTracker.js.map +1 -0
  276. package/lib/gc/{gcTelemetry.d.mts → gcTelemetry.d.ts} +8 -8
  277. package/lib/gc/gcTelemetry.d.ts.map +1 -0
  278. package/lib/gc/{gcTelemetry.mjs → gcTelemetry.js} +5 -5
  279. package/lib/gc/gcTelemetry.js.map +1 -0
  280. package/lib/gc/{gcUnreferencedStateTracker.d.mts → gcUnreferencedStateTracker.d.ts} +7 -2
  281. package/lib/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
  282. package/lib/gc/{gcUnreferencedStateTracker.mjs → gcUnreferencedStateTracker.js} +12 -2
  283. package/lib/gc/gcUnreferencedStateTracker.js.map +1 -0
  284. package/lib/gc/index.d.ts +13 -0
  285. package/lib/gc/index.d.ts.map +1 -0
  286. package/lib/gc/{index.mjs → index.js} +8 -8
  287. package/lib/gc/index.js.map +1 -0
  288. package/lib/{index.d.mts → index.d.ts} +12 -21
  289. package/lib/index.d.ts.map +1 -0
  290. package/lib/index.js +15 -0
  291. package/lib/index.js.map +1 -0
  292. package/lib/{messageTypes.d.mts → messageTypes.d.ts} +5 -5
  293. package/lib/messageTypes.d.ts.map +1 -0
  294. package/lib/{messageTypes.mjs → messageTypes.js} +1 -1
  295. package/lib/messageTypes.js.map +1 -0
  296. package/lib/{metadata.d.mts → metadata.d.ts} +1 -1
  297. package/lib/metadata.d.ts.map +1 -0
  298. package/lib/{metadata.mjs → metadata.js} +1 -1
  299. package/lib/metadata.js.map +1 -0
  300. package/lib/opLifecycle/{batchManager.d.mts → batchManager.d.ts} +3 -3
  301. package/lib/opLifecycle/batchManager.d.ts.map +1 -0
  302. package/lib/opLifecycle/{batchManager.mjs → batchManager.js} +1 -1
  303. package/lib/opLifecycle/batchManager.js.map +1 -0
  304. package/lib/opLifecycle/{definitions.d.mts → definitions.d.ts} +3 -3
  305. package/lib/opLifecycle/definitions.d.ts.map +1 -0
  306. package/lib/opLifecycle/{definitions.mjs → definitions.js} +1 -1
  307. package/lib/opLifecycle/definitions.js.map +1 -0
  308. package/lib/opLifecycle/index.d.ts +13 -0
  309. package/lib/opLifecycle/index.d.ts.map +1 -0
  310. package/lib/opLifecycle/index.js +12 -0
  311. package/lib/opLifecycle/index.js.map +1 -0
  312. package/lib/opLifecycle/{opCompressor.d.mts → opCompressor.d.ts} +2 -2
  313. package/lib/opLifecycle/opCompressor.d.ts.map +1 -0
  314. package/lib/opLifecycle/{opCompressor.mjs → opCompressor.js} +3 -3
  315. package/lib/opLifecycle/opCompressor.js.map +1 -0
  316. package/lib/opLifecycle/{opDecompressor.d.mts → opDecompressor.d.ts} +2 -2
  317. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -0
  318. package/lib/opLifecycle/{opDecompressor.mjs → opDecompressor.js} +2 -2
  319. package/lib/opLifecycle/opDecompressor.js.map +1 -0
  320. package/lib/opLifecycle/{opGroupingManager.d.mts → opGroupingManager.d.ts} +2 -2
  321. package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -0
  322. package/lib/opLifecycle/{opGroupingManager.mjs → opGroupingManager.js} +2 -11
  323. package/lib/opLifecycle/opGroupingManager.js.map +1 -0
  324. package/lib/opLifecycle/{opSplitter.d.mts → opSplitter.d.ts} +2 -2
  325. package/lib/opLifecycle/opSplitter.d.ts.map +1 -0
  326. package/lib/opLifecycle/{opSplitter.mjs → opSplitter.js} +3 -3
  327. package/lib/opLifecycle/opSplitter.js.map +1 -0
  328. package/lib/opLifecycle/{outbox.d.mts → outbox.d.ts} +8 -8
  329. package/lib/opLifecycle/outbox.d.ts.map +1 -0
  330. package/lib/opLifecycle/{outbox.mjs → outbox.js} +12 -4
  331. package/lib/opLifecycle/outbox.js.map +1 -0
  332. package/lib/opLifecycle/{remoteMessageProcessor.d.mts → remoteMessageProcessor.d.ts} +5 -5
  333. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -0
  334. package/lib/opLifecycle/{remoteMessageProcessor.mjs → remoteMessageProcessor.js} +2 -2
  335. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -0
  336. package/lib/{opProperties.d.mts → opProperties.d.ts} +1 -1
  337. package/lib/opProperties.d.ts.map +1 -0
  338. package/lib/{opProperties.mjs → opProperties.js} +1 -1
  339. package/lib/opProperties.js.map +1 -0
  340. package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
  341. package/lib/packageVersion.d.ts.map +1 -0
  342. package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
  343. package/lib/packageVersion.js.map +1 -0
  344. package/lib/{pendingStateManager.d.mts → pendingStateManager.d.ts} +3 -2
  345. package/lib/pendingStateManager.d.ts.map +1 -0
  346. package/lib/{pendingStateManager.mjs → pendingStateManager.js} +18 -10
  347. package/lib/pendingStateManager.js.map +1 -0
  348. package/lib/{scheduleManager.d.mts → scheduleManager.d.ts} +6 -3
  349. package/lib/scheduleManager.d.ts.map +1 -0
  350. package/lib/{scheduleManager.mjs → scheduleManager.js} +3 -3
  351. package/lib/scheduleManager.js.map +1 -0
  352. package/lib/{storageServiceWithAttachBlobs.d.mts → storageServiceWithAttachBlobs.d.ts} +1 -1
  353. package/lib/storageServiceWithAttachBlobs.d.ts.map +1 -0
  354. package/lib/{storageServiceWithAttachBlobs.mjs → storageServiceWithAttachBlobs.js} +1 -1
  355. package/lib/storageServiceWithAttachBlobs.js.map +1 -0
  356. package/lib/summary/{index.d.mts → index.d.ts} +13 -13
  357. package/lib/summary/index.d.ts.map +1 -0
  358. package/lib/summary/{index.mjs → index.js} +12 -12
  359. package/lib/summary/index.js.map +1 -0
  360. package/lib/summary/{orderedClientElection.d.mts → orderedClientElection.d.ts} +5 -1
  361. package/lib/summary/orderedClientElection.d.ts.map +1 -0
  362. package/lib/summary/{orderedClientElection.mjs → orderedClientElection.js} +2 -2
  363. package/lib/summary/orderedClientElection.js.map +1 -0
  364. package/lib/summary/{runWhileConnectedCoordinator.d.mts → runWhileConnectedCoordinator.d.ts} +2 -2
  365. package/lib/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
  366. package/lib/summary/{runWhileConnectedCoordinator.mjs → runWhileConnectedCoordinator.js} +1 -1
  367. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -0
  368. package/lib/summary/{runningSummarizer.d.mts → runningSummarizer.d.ts} +12 -11
  369. package/lib/summary/runningSummarizer.d.ts.map +1 -0
  370. package/lib/summary/{runningSummarizer.mjs → runningSummarizer.js} +108 -75
  371. package/lib/summary/runningSummarizer.js.map +1 -0
  372. package/lib/summary/{summarizer.d.mts → summarizer.d.ts} +5 -5
  373. package/lib/summary/summarizer.d.ts.map +1 -0
  374. package/lib/summary/{summarizer.mjs → summarizer.js} +4 -4
  375. package/lib/summary/summarizer.js.map +1 -0
  376. package/lib/summary/{summarizerClientElection.d.mts → summarizerClientElection.d.ts} +3 -3
  377. package/lib/summary/summarizerClientElection.d.ts.map +1 -0
  378. package/lib/summary/{summarizerClientElection.mjs → summarizerClientElection.js} +1 -1
  379. package/lib/summary/summarizerClientElection.js.map +1 -0
  380. package/lib/summary/{summarizerHeuristics.d.mts → summarizerHeuristics.d.ts} +4 -4
  381. package/lib/summary/summarizerHeuristics.d.ts.map +1 -0
  382. package/lib/summary/{summarizerHeuristics.mjs → summarizerHeuristics.js} +1 -1
  383. package/lib/summary/summarizerHeuristics.js.map +1 -0
  384. package/lib/summary/summarizerNode/{index.d.mts → index.d.ts} +4 -4
  385. package/lib/summary/summarizerNode/index.d.ts.map +1 -0
  386. package/lib/summary/summarizerNode/index.js +7 -0
  387. package/lib/summary/summarizerNode/index.js.map +1 -0
  388. package/lib/summary/summarizerNode/{summarizerNode.d.mts → summarizerNode.d.ts} +18 -8
  389. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -0
  390. package/lib/summary/summarizerNode/{summarizerNode.mjs → summarizerNode.js} +41 -53
  391. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -0
  392. package/lib/summary/summarizerNode/{summarizerNodeUtils.d.mts → summarizerNodeUtils.d.ts} +11 -20
  393. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -0
  394. package/lib/summary/summarizerNode/{summarizerNodeUtils.mjs → summarizerNodeUtils.js} +1 -20
  395. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -0
  396. package/lib/summary/summarizerNode/{summarizerNodeWithGc.d.mts → summarizerNodeWithGc.d.ts} +6 -7
  397. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -0
  398. package/lib/summary/summarizerNode/{summarizerNodeWithGc.mjs → summarizerNodeWithGc.js} +12 -12
  399. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -0
  400. package/lib/summary/{summarizerTypes.d.mts → summarizerTypes.d.ts} +11 -22
  401. package/lib/summary/summarizerTypes.d.ts.map +1 -0
  402. package/lib/summary/{summarizerTypes.mjs → summarizerTypes.js} +1 -1
  403. package/lib/summary/summarizerTypes.js.map +1 -0
  404. package/lib/summary/{summaryCollection.d.mts → summaryCollection.d.ts} +1 -1
  405. package/lib/summary/summaryCollection.d.ts.map +1 -0
  406. package/lib/summary/{summaryCollection.mjs → summaryCollection.js} +1 -1
  407. package/lib/summary/summaryCollection.js.map +1 -0
  408. package/lib/summary/{summaryFormat.d.mts → summaryFormat.d.ts} +16 -3
  409. package/lib/summary/summaryFormat.d.ts.map +1 -0
  410. package/lib/summary/{summaryFormat.mjs → summaryFormat.js} +1 -1
  411. package/lib/summary/summaryFormat.js.map +1 -0
  412. package/lib/summary/{summaryGenerator.d.mts → summaryGenerator.d.ts} +7 -6
  413. package/lib/summary/summaryGenerator.d.ts.map +1 -0
  414. package/lib/summary/{summaryGenerator.mjs → summaryGenerator.js} +11 -2
  415. package/lib/summary/summaryGenerator.js.map +1 -0
  416. package/lib/summary/{summaryManager.d.mts → summaryManager.d.ts} +6 -7
  417. package/lib/summary/summaryManager.d.ts.map +1 -0
  418. package/lib/summary/{summaryManager.mjs → summaryManager.js} +4 -5
  419. package/lib/summary/summaryManager.js.map +1 -0
  420. package/lib/test/batchTracker.spec.js +88 -0
  421. package/lib/test/batchTracker.spec.js.map +1 -0
  422. package/lib/test/blobManager.spec.js +835 -0
  423. package/lib/test/blobManager.spec.js.map +1 -0
  424. package/lib/test/channelCollection.spec.js +138 -0
  425. package/lib/test/channelCollection.spec.js.map +1 -0
  426. package/lib/test/containerRuntime.spec.js +1748 -0
  427. package/lib/test/containerRuntime.spec.js.map +1 -0
  428. package/lib/test/dataStoreContext.spec.js +771 -0
  429. package/lib/test/dataStoreContext.spec.js.map +1 -0
  430. package/lib/test/dataStoreCreation.spec.js +303 -0
  431. package/lib/test/dataStoreCreation.spec.js.map +1 -0
  432. package/lib/test/dataStoreRegistry.spec.js +26 -0
  433. package/lib/test/dataStoreRegistry.spec.js.map +1 -0
  434. package/lib/test/fuzz/fuzzUtils.js +66 -0
  435. package/lib/test/fuzz/fuzzUtils.js.map +1 -0
  436. package/lib/test/fuzz/summarizer.fuzz.spec.js +31 -0
  437. package/lib/test/fuzz/summarizer.fuzz.spec.js.map +1 -0
  438. package/lib/test/fuzz/summarizerFuzzMocks.js +162 -0
  439. package/lib/test/fuzz/summarizerFuzzMocks.js.map +1 -0
  440. package/lib/test/fuzz/summarizerFuzzSuite.js +106 -0
  441. package/lib/test/fuzz/summarizerFuzzSuite.js.map +1 -0
  442. package/lib/test/gc/garbageCollection.spec.js +1464 -0
  443. package/lib/test/gc/garbageCollection.spec.js.map +1 -0
  444. package/lib/test/gc/gcConfigs.spec.js +689 -0
  445. package/lib/test/gc/gcConfigs.spec.js.map +1 -0
  446. package/lib/test/gc/gcHelpers.spec.js +110 -0
  447. package/lib/test/gc/gcHelpers.spec.js.map +1 -0
  448. package/lib/test/gc/gcReferenceGraphAlgorithm.spec.js +68 -0
  449. package/lib/test/gc/gcReferenceGraphAlgorithm.spec.js.map +1 -0
  450. package/lib/test/gc/gcStats.spec.js +390 -0
  451. package/lib/test/gc/gcStats.spec.js.map +1 -0
  452. package/lib/test/gc/gcSummaryStateTracker.spec.js +228 -0
  453. package/lib/test/gc/gcSummaryStateTracker.spec.js.map +1 -0
  454. package/lib/test/gc/gcTelemetry.spec.js +530 -0
  455. package/lib/test/gc/gcTelemetry.spec.js.map +1 -0
  456. package/lib/test/gc/gcUnitTestHelpers.js +29 -0
  457. package/lib/test/gc/gcUnitTestHelpers.js.map +1 -0
  458. package/lib/test/gc/gcUnreferencedStateTracker.spec.js +192 -0
  459. package/lib/test/gc/gcUnreferencedStateTracker.spec.js.map +1 -0
  460. package/lib/test/getPendingBlobs.spec.js +193 -0
  461. package/lib/test/getPendingBlobs.spec.js.map +1 -0
  462. package/lib/test/hardwareStats.spec.js +93 -0
  463. package/lib/test/hardwareStats.spec.js.map +1 -0
  464. package/lib/test/index.js +6 -0
  465. package/lib/test/index.js.map +1 -0
  466. package/lib/test/opLifecycle/OpGroupingManager.spec.js +225 -0
  467. package/lib/test/opLifecycle/OpGroupingManager.spec.js.map +1 -0
  468. package/lib/test/opLifecycle/batchManager.spec.js +189 -0
  469. package/lib/test/opLifecycle/batchManager.spec.js.map +1 -0
  470. package/lib/test/opLifecycle/opCompressor.spec.js +74 -0
  471. package/lib/test/opLifecycle/opCompressor.spec.js.map +1 -0
  472. package/lib/test/opLifecycle/opDecompressor.spec.js +218 -0
  473. package/lib/test/opLifecycle/opDecompressor.spec.js.map +1 -0
  474. package/lib/test/opLifecycle/opSplitter.spec.js +272 -0
  475. package/lib/test/opLifecycle/opSplitter.spec.js.map +1 -0
  476. package/lib/test/opLifecycle/outbox.spec.js +675 -0
  477. package/lib/test/opLifecycle/outbox.spec.js.map +1 -0
  478. package/lib/test/opLifecycle/remoteMessageProcessor.spec.js +196 -0
  479. package/lib/test/opLifecycle/remoteMessageProcessor.spec.js.map +1 -0
  480. package/lib/test/pendingStateManager.spec.js +329 -0
  481. package/lib/test/pendingStateManager.spec.js.map +1 -0
  482. package/lib/test/scheduleManager.spec.js +270 -0
  483. package/lib/test/scheduleManager.spec.js.map +1 -0
  484. package/lib/test/summarizerNode.spec.js +326 -0
  485. package/lib/test/summarizerNode.spec.js.map +1 -0
  486. package/lib/test/summarizerNodeWithGc.spec.js +318 -0
  487. package/lib/test/summarizerNodeWithGc.spec.js.map +1 -0
  488. package/lib/test/summary/orderedClientElection.spec.js +535 -0
  489. package/lib/test/summary/orderedClientElection.spec.js.map +1 -0
  490. package/lib/test/summary/runningSummarizer.spec.js +1349 -0
  491. package/lib/test/summary/runningSummarizer.spec.js.map +1 -0
  492. package/lib/test/summary/summarizer.spec.js +29 -0
  493. package/lib/test/summary/summarizer.spec.js.map +1 -0
  494. package/lib/test/summary/summarizerClientElection.spec.js +436 -0
  495. package/lib/test/summary/summarizerClientElection.spec.js.map +1 -0
  496. package/lib/test/summary/summarizerHeuristics.spec.js +289 -0
  497. package/lib/test/summary/summarizerHeuristics.spec.js.map +1 -0
  498. package/lib/test/summary/summaryCollection.spec.js +200 -0
  499. package/lib/test/summary/summaryCollection.spec.js.map +1 -0
  500. package/lib/test/summary/summaryManager.spec.js +430 -0
  501. package/lib/test/summary/summaryManager.spec.js.map +1 -0
  502. package/lib/test/summary/testQuorumClients.js +34 -0
  503. package/lib/test/summary/testQuorumClients.js.map +1 -0
  504. package/lib/test/throttler.spec.js +175 -0
  505. package/lib/test/throttler.spec.js.map +1 -0
  506. package/lib/test/types/validateContainerRuntimePrevious.generated.js +180 -0
  507. package/lib/test/types/validateContainerRuntimePrevious.generated.js.map +1 -0
  508. package/lib/{throttler.d.mts → throttler.d.ts} +1 -1
  509. package/lib/throttler.d.ts.map +1 -0
  510. package/lib/{throttler.mjs → throttler.js} +1 -1
  511. package/lib/throttler.js.map +1 -0
  512. package/package.json +106 -87
  513. package/src/batchTracker.ts +1 -1
  514. package/src/blobManager.ts +1 -15
  515. package/src/{dataStores.ts → channelCollection.ts} +622 -170
  516. package/src/connectionTelemetry.ts +42 -3
  517. package/src/containerHandleContext.ts +1 -1
  518. package/src/containerRuntime.ts +683 -483
  519. package/src/dataStore.ts +16 -15
  520. package/src/dataStoreContext.ts +378 -216
  521. package/src/dataStoreContexts.ts +2 -1
  522. package/src/deltaManagerSummarizerProxy.ts +132 -7
  523. package/src/gc/garbageCollection.ts +167 -71
  524. package/src/gc/gcConfigs.ts +17 -7
  525. package/src/gc/gcDefinitions.ts +42 -16
  526. package/src/gc/gcHelpers.ts +2 -2
  527. package/src/gc/gcReferenceGraphAlgorithm.ts +1 -1
  528. package/src/gc/gcSummaryStateTracker.ts +19 -7
  529. package/src/gc/gcTelemetry.ts +10 -9
  530. package/src/gc/gcUnreferencedStateTracker.ts +12 -1
  531. package/src/gc/index.ts +11 -9
  532. package/src/index.ts +29 -26
  533. package/src/messageTypes.ts +4 -4
  534. package/src/opLifecycle/README.md +2 -4
  535. package/src/opLifecycle/batchManager.ts +2 -2
  536. package/src/opLifecycle/definitions.ts +2 -2
  537. package/src/opLifecycle/index.ts +8 -8
  538. package/src/opLifecycle/opCompressor.ts +3 -3
  539. package/src/opLifecycle/opDecompressor.ts +3 -3
  540. package/src/opLifecycle/opGroupingManager.ts +3 -12
  541. package/src/opLifecycle/opSplitter.ts +3 -3
  542. package/src/opLifecycle/outbox.ts +29 -9
  543. package/src/opLifecycle/remoteMessageProcessor.ts +4 -4
  544. package/src/packageVersion.ts +1 -1
  545. package/src/pendingStateManager.ts +19 -13
  546. package/src/scheduleManager.ts +4 -4
  547. package/src/summary/index.ts +13 -12
  548. package/src/summary/orderedClientElection.ts +1 -1
  549. package/src/summary/runWhileConnectedCoordinator.ts +1 -1
  550. package/src/summary/runningSummarizer.ts +141 -93
  551. package/src/summary/summarizer.ts +7 -7
  552. package/src/summary/summarizerClientElection.ts +2 -2
  553. package/src/summary/summarizerHeuristics.ts +3 -3
  554. package/src/summary/summarizerNode/index.ts +6 -3
  555. package/src/summary/summarizerNode/summarizerNode.ts +54 -69
  556. package/src/summary/summarizerNode/summarizerNodeUtils.ts +16 -34
  557. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +11 -17
  558. package/src/summary/summarizerTypes.ts +12 -24
  559. package/src/summary/summaryFormat.ts +16 -2
  560. package/src/summary/summaryGenerator.ts +16 -4
  561. package/src/summary/summaryManager.ts +6 -7
  562. package/tsconfig.cjs.json +7 -0
  563. package/tsconfig.json +2 -5
  564. package/dist/dataStores.d.ts +0 -149
  565. package/dist/dataStores.d.ts.map +0 -1
  566. package/dist/dataStores.js.map +0 -1
  567. package/dist/deltaManagerProxyBase.d.ts.map +0 -1
  568. package/dist/deltaManagerProxyBase.js +0 -77
  569. package/dist/deltaManagerProxyBase.js.map +0 -1
  570. package/lib/batchTracker.d.mts.map +0 -1
  571. package/lib/batchTracker.mjs.map +0 -1
  572. package/lib/blobManager.d.mts.map +0 -1
  573. package/lib/blobManager.mjs.map +0 -1
  574. package/lib/connectionTelemetry.d.mts.map +0 -1
  575. package/lib/connectionTelemetry.mjs.map +0 -1
  576. package/lib/containerHandleContext.d.mts.map +0 -1
  577. package/lib/containerHandleContext.mjs.map +0 -1
  578. package/lib/containerRuntime.d.mts.map +0 -1
  579. package/lib/containerRuntime.mjs.map +0 -1
  580. package/lib/dataStore.d.mts.map +0 -1
  581. package/lib/dataStore.mjs.map +0 -1
  582. package/lib/dataStoreContext.d.mts.map +0 -1
  583. package/lib/dataStoreContext.mjs.map +0 -1
  584. package/lib/dataStoreContexts.d.mts.map +0 -1
  585. package/lib/dataStoreContexts.mjs.map +0 -1
  586. package/lib/dataStoreRegistry.d.mts.map +0 -1
  587. package/lib/dataStoreRegistry.mjs.map +0 -1
  588. package/lib/dataStores.d.mts +0 -149
  589. package/lib/dataStores.d.mts.map +0 -1
  590. package/lib/dataStores.mjs.map +0 -1
  591. package/lib/deltaManagerProxyBase.d.mts +0 -35
  592. package/lib/deltaManagerProxyBase.d.mts.map +0 -1
  593. package/lib/deltaManagerProxyBase.mjs +0 -73
  594. package/lib/deltaManagerProxyBase.mjs.map +0 -1
  595. package/lib/deltaManagerSummarizerProxy.d.mts +0 -19
  596. package/lib/deltaManagerSummarizerProxy.d.mts.map +0 -1
  597. package/lib/deltaManagerSummarizerProxy.mjs +0 -38
  598. package/lib/deltaManagerSummarizerProxy.mjs.map +0 -1
  599. package/lib/deltaScheduler.d.mts.map +0 -1
  600. package/lib/deltaScheduler.mjs.map +0 -1
  601. package/lib/error.d.mts.map +0 -1
  602. package/lib/error.mjs.map +0 -1
  603. package/lib/gc/garbageCollection.d.mts.map +0 -1
  604. package/lib/gc/garbageCollection.mjs.map +0 -1
  605. package/lib/gc/gcConfigs.d.mts.map +0 -1
  606. package/lib/gc/gcConfigs.mjs.map +0 -1
  607. package/lib/gc/gcDefinitions.d.mts.map +0 -1
  608. package/lib/gc/gcDefinitions.mjs.map +0 -1
  609. package/lib/gc/gcHelpers.mjs.map +0 -1
  610. package/lib/gc/gcReferenceGraphAlgorithm.d.mts.map +0 -1
  611. package/lib/gc/gcReferenceGraphAlgorithm.mjs.map +0 -1
  612. package/lib/gc/gcSummaryDefinitions.d.mts.map +0 -1
  613. package/lib/gc/gcSummaryDefinitions.mjs.map +0 -1
  614. package/lib/gc/gcSummaryStateTracker.d.mts.map +0 -1
  615. package/lib/gc/gcSummaryStateTracker.mjs.map +0 -1
  616. package/lib/gc/gcTelemetry.d.mts.map +0 -1
  617. package/lib/gc/gcTelemetry.mjs.map +0 -1
  618. package/lib/gc/gcUnreferencedStateTracker.d.mts.map +0 -1
  619. package/lib/gc/gcUnreferencedStateTracker.mjs.map +0 -1
  620. package/lib/gc/index.d.mts +0 -13
  621. package/lib/gc/index.d.mts.map +0 -1
  622. package/lib/gc/index.mjs.map +0 -1
  623. package/lib/index.d.mts.map +0 -1
  624. package/lib/index.mjs +0 -24
  625. package/lib/index.mjs.map +0 -1
  626. package/lib/messageTypes.d.mts.map +0 -1
  627. package/lib/messageTypes.mjs.map +0 -1
  628. package/lib/metadata.d.mts.map +0 -1
  629. package/lib/metadata.mjs.map +0 -1
  630. package/lib/opLifecycle/batchManager.d.mts.map +0 -1
  631. package/lib/opLifecycle/batchManager.mjs.map +0 -1
  632. package/lib/opLifecycle/definitions.d.mts.map +0 -1
  633. package/lib/opLifecycle/definitions.mjs.map +0 -1
  634. package/lib/opLifecycle/index.d.mts +0 -13
  635. package/lib/opLifecycle/index.d.mts.map +0 -1
  636. package/lib/opLifecycle/index.mjs +0 -12
  637. package/lib/opLifecycle/index.mjs.map +0 -1
  638. package/lib/opLifecycle/opCompressor.d.mts.map +0 -1
  639. package/lib/opLifecycle/opCompressor.mjs.map +0 -1
  640. package/lib/opLifecycle/opDecompressor.d.mts.map +0 -1
  641. package/lib/opLifecycle/opDecompressor.mjs.map +0 -1
  642. package/lib/opLifecycle/opGroupingManager.d.mts.map +0 -1
  643. package/lib/opLifecycle/opGroupingManager.mjs.map +0 -1
  644. package/lib/opLifecycle/opSplitter.d.mts.map +0 -1
  645. package/lib/opLifecycle/opSplitter.mjs.map +0 -1
  646. package/lib/opLifecycle/outbox.d.mts.map +0 -1
  647. package/lib/opLifecycle/outbox.mjs.map +0 -1
  648. package/lib/opLifecycle/remoteMessageProcessor.d.mts.map +0 -1
  649. package/lib/opLifecycle/remoteMessageProcessor.mjs.map +0 -1
  650. package/lib/opProperties.d.mts.map +0 -1
  651. package/lib/opProperties.mjs.map +0 -1
  652. package/lib/packageVersion.d.mts.map +0 -1
  653. package/lib/packageVersion.mjs.map +0 -1
  654. package/lib/pendingStateManager.d.mts.map +0 -1
  655. package/lib/pendingStateManager.mjs.map +0 -1
  656. package/lib/scheduleManager.d.mts.map +0 -1
  657. package/lib/scheduleManager.mjs.map +0 -1
  658. package/lib/storageServiceWithAttachBlobs.d.mts.map +0 -1
  659. package/lib/storageServiceWithAttachBlobs.mjs.map +0 -1
  660. package/lib/summary/index.d.mts.map +0 -1
  661. package/lib/summary/index.mjs.map +0 -1
  662. package/lib/summary/orderedClientElection.d.mts.map +0 -1
  663. package/lib/summary/orderedClientElection.mjs.map +0 -1
  664. package/lib/summary/runWhileConnectedCoordinator.d.mts.map +0 -1
  665. package/lib/summary/runWhileConnectedCoordinator.mjs.map +0 -1
  666. package/lib/summary/runningSummarizer.d.mts.map +0 -1
  667. package/lib/summary/runningSummarizer.mjs.map +0 -1
  668. package/lib/summary/summarizer.d.mts.map +0 -1
  669. package/lib/summary/summarizer.mjs.map +0 -1
  670. package/lib/summary/summarizerClientElection.d.mts.map +0 -1
  671. package/lib/summary/summarizerClientElection.mjs.map +0 -1
  672. package/lib/summary/summarizerHeuristics.d.mts.map +0 -1
  673. package/lib/summary/summarizerHeuristics.mjs.map +0 -1
  674. package/lib/summary/summarizerNode/index.d.mts.map +0 -1
  675. package/lib/summary/summarizerNode/index.mjs +0 -7
  676. package/lib/summary/summarizerNode/index.mjs.map +0 -1
  677. package/lib/summary/summarizerNode/summarizerNode.d.mts.map +0 -1
  678. package/lib/summary/summarizerNode/summarizerNode.mjs.map +0 -1
  679. package/lib/summary/summarizerNode/summarizerNodeUtils.d.mts.map +0 -1
  680. package/lib/summary/summarizerNode/summarizerNodeUtils.mjs.map +0 -1
  681. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.mts.map +0 -1
  682. package/lib/summary/summarizerNode/summarizerNodeWithGc.mjs.map +0 -1
  683. package/lib/summary/summarizerTypes.d.mts.map +0 -1
  684. package/lib/summary/summarizerTypes.mjs.map +0 -1
  685. package/lib/summary/summaryCollection.d.mts.map +0 -1
  686. package/lib/summary/summaryCollection.mjs.map +0 -1
  687. package/lib/summary/summaryFormat.d.mts.map +0 -1
  688. package/lib/summary/summaryFormat.mjs.map +0 -1
  689. package/lib/summary/summaryGenerator.d.mts.map +0 -1
  690. package/lib/summary/summaryGenerator.mjs.map +0 -1
  691. package/lib/summary/summaryManager.d.mts.map +0 -1
  692. package/lib/summary/summaryManager.mjs.map +0 -1
  693. package/lib/throttler.d.mts.map +0 -1
  694. package/lib/throttler.mjs.map +0 -1
  695. package/src/deltaManagerProxyBase.ts +0 -111
@@ -1,31 +1,29 @@
1
1
  import { AttachState, LoaderHeader, } from "@fluidframework/container-definitions";
2
- import { assert, delay, LazyPromise } from "@fluidframework/core-utils";
2
+ import { assert, Deferred, delay, LazyPromise, PromiseCache } from "@fluidframework/core-utils";
3
3
  import { Trace, TypedEventEmitter } from "@fluid-internal/client-utils";
4
- import { createChildLogger, createChildMonitoringContext, DataCorruptionError, DataProcessingError, GenericError, raiseConnectedEvent, PerformanceEvent,
5
- // eslint-disable-next-line import/no-deprecated
6
- TaggedLoggerAdapter, wrapError, UsageError, LoggingError, } from "@fluidframework/telemetry-utils";
4
+ import { createChildLogger, createChildMonitoringContext, DataCorruptionError, DataProcessingError, GenericError, raiseConnectedEvent, PerformanceEvent, TaggedLoggerAdapter, wrapError, UsageError, LoggingError, createSampledLogger, loggerToMonitoringContext, } from "@fluidframework/telemetry-utils";
7
5
  import { DriverHeader, FetchSource, } from "@fluidframework/driver-definitions";
8
6
  import { readAndParse } from "@fluidframework/driver-utils";
9
7
  import { MessageType, SummaryType, } from "@fluidframework/protocol-definitions";
10
8
  import { FlushMode, FlushModeExperimental, gcTreeKey, channelsTreeName, } from "@fluidframework/runtime-definitions";
11
- import { addBlobToSummary, addSummarizeResultToSummary, addTreeToSummary, RequestParser, create404Response, exceptionToResponse, GCDataBuilder, seqFromTree, calculateStats, TelemetryContext, responseToException, } from "@fluidframework/runtime-utils";
9
+ import { addBlobToSummary, addSummarizeResultToSummary, RequestParser, create404Response, exceptionToResponse, GCDataBuilder, seqFromTree, calculateStats, TelemetryContext, responseToException, } from "@fluidframework/runtime-utils";
12
10
  import { v4 as uuid } from "uuid";
13
- import { ContainerFluidHandleContext } from "./containerHandleContext.mjs";
14
- import { FluidDataStoreRegistry } from "./dataStoreRegistry.mjs";
15
- import { ReportOpPerfTelemetry } from "./connectionTelemetry.mjs";
16
- import { PendingStateManager, } from "./pendingStateManager.mjs";
17
- import { pkgVersion } from "./packageVersion.mjs";
18
- import { BlobManager } from "./blobManager.mjs";
19
- import { DataStores, getSummaryForDatastores } from "./dataStores.mjs";
20
- import { aliasBlobName, blobsTreeName, chunksBlobName, createRootSummarizerNodeWithGC, electedSummarizerBlobName, extractSummaryMetadataMessage, idCompressorBlobName, metadataBlobName, Summarizer, SummaryManager, wrapSummaryInChannelsTree, SummaryCollection, OrderedClientCollection, OrderedClientElection, SummarizerClientElection, summarizerClientType, RunWhileConnectedCoordinator, RetriableSummaryError, } from "./summary/index.mjs";
21
- import { formExponentialFn, Throttler } from "./throttler.mjs";
22
- import { GarbageCollector, GCNodeType, gcGenerationOptionName, trimLeadingAndTrailingSlashes, } from "./gc/index.mjs";
23
- import { channelToDataStore, isDataStoreAliasMessage } from "./dataStore.mjs";
24
- import { BindBatchTracker } from "./batchTracker.mjs";
25
- import { ScheduleManager } from "./scheduleManager.mjs";
26
- import { OpCompressor, OpDecompressor, Outbox, OpSplitter, RemoteMessageProcessor, OpGroupingManager, getLongStack, } from "./opLifecycle/index.mjs";
27
- import { DeltaManagerSummarizerProxy } from "./deltaManagerSummarizerProxy.mjs";
28
- import { ContainerMessageType, } from "./messageTypes.mjs";
11
+ import { ContainerFluidHandleContext } from "./containerHandleContext.js";
12
+ import { FluidDataStoreRegistry } from "./dataStoreRegistry.js";
13
+ import { ReportOpPerfTelemetry } from "./connectionTelemetry.js";
14
+ import { PendingStateManager, } from "./pendingStateManager.js";
15
+ import { pkgVersion } from "./packageVersion.js";
16
+ import { BlobManager } from "./blobManager.js";
17
+ import { ChannelCollection, getSummaryForDatastores, wrapContext } from "./channelCollection.js";
18
+ import { aliasBlobName, blobsTreeName, chunksBlobName, createRootSummarizerNodeWithGC, electedSummarizerBlobName, extractSummaryMetadataMessage, idCompressorBlobName, metadataBlobName, Summarizer, SummaryManager, wrapSummaryInChannelsTree, SummaryCollection, OrderedClientCollection, OrderedClientElection, SummarizerClientElection, summarizerClientType, RunWhileConnectedCoordinator, RetriableSummaryError, rootHasIsolatedChannels, } from "./summary/index.js";
19
+ import { formExponentialFn, Throttler } from "./throttler.js";
20
+ import { GarbageCollector, GCNodeType, gcGenerationOptionName, } from "./gc/index.js";
21
+ import { channelToDataStore } from "./dataStore.js";
22
+ import { BindBatchTracker } from "./batchTracker.js";
23
+ import { ScheduleManager } from "./scheduleManager.js";
24
+ import { OpCompressor, OpDecompressor, Outbox, OpSplitter, RemoteMessageProcessor, OpGroupingManager, getLongStack, } from "./opLifecycle/index.js";
25
+ import { DeltaManagerSummarizerProxy } from "./deltaManagerSummarizerProxy.js";
26
+ import { ContainerMessageType, } from "./messageTypes.js";
29
27
  /**
30
28
  * Utility to implement compat behaviors given an unknown message type
31
29
  * The parameters are typed to support compile-time enforcement of handling all known types/behaviors
@@ -55,26 +53,6 @@ export const DefaultSummaryConfiguration = {
55
53
  runtimeOpWeight: 1.0,
56
54
  nonRuntimeHeuristicThreshold: 20,
57
55
  };
58
- /**
59
- * Accepted header keys for requests coming to the runtime.
60
- * @internal
61
- */
62
- export var RuntimeHeaders;
63
- (function (RuntimeHeaders) {
64
- /** True to wait for a data store to be created and loaded before returning it. */
65
- RuntimeHeaders["wait"] = "wait";
66
- /** True if the request is coming from an IFluidHandle. */
67
- RuntimeHeaders["viaHandle"] = "viaHandle";
68
- })(RuntimeHeaders || (RuntimeHeaders = {}));
69
- /** True if a tombstoned object should be returned without erroring
70
- * @alpha
71
- */
72
- export const AllowTombstoneRequestHeaderKey = "allowTombstone"; // Belongs in the enum above, but avoiding the breaking change
73
- /**
74
- * [IRRELEVANT IF throwOnInactiveLoad OPTION NOT SET] True if an inactive object should be returned without erroring
75
- * @internal
76
- */
77
- export const AllowInactiveRequestHeaderKey = "allowInactive"; // Belongs in the enum above, but avoiding the breaking change
78
56
  /**
79
57
  * Tombstone error responses will have this header set to true
80
58
  * @alpha
@@ -243,7 +221,6 @@ export class ContainerRuntime extends TypedEventEmitter {
243
221
  // back-compat: Remove the TaggedLoggerAdapter fallback once all the host are using loader > 0.45
244
222
  const backCompatContext = context;
245
223
  const passLogger = backCompatContext.taggedLogger ??
246
- // eslint-disable-next-line import/no-deprecated
247
224
  new TaggedLoggerAdapter(backCompatContext.logger);
248
225
  const logger = createChildLogger({
249
226
  logger: passLogger,
@@ -253,7 +230,8 @@ export class ContainerRuntime extends TypedEventEmitter {
253
230
  },
254
231
  },
255
232
  });
256
- const { summaryOptions = {}, gcOptions = {}, loadSequenceNumberVerification = "close", flushMode = defaultFlushMode, compressionOptions = defaultCompressionConfig, maxBatchSizeInBytes = defaultMaxBatchSizeInBytes, enableRuntimeIdCompressor = false, chunkSizeInBytes = defaultChunkSizeInBytes, enableOpReentryCheck = false, enableGroupedBatching = false, } = runtimeOptions;
233
+ const mc = loggerToMonitoringContext(logger);
234
+ const { summaryOptions = {}, gcOptions = {}, loadSequenceNumberVerification = "close", flushMode = defaultFlushMode, compressionOptions = defaultCompressionConfig, maxBatchSizeInBytes = defaultMaxBatchSizeInBytes, enableRuntimeIdCompressor = "off", chunkSizeInBytes = defaultChunkSizeInBytes, enableOpReentryCheck = false, enableGroupedBatching = false, } = runtimeOptions;
257
235
  const registry = new FluidDataStoreRegistry(registryEntries);
258
236
  const tryFetchBlob = async (blobName) => {
259
237
  const blobId = context.baseSnapshot?.blobs[blobName];
@@ -298,21 +276,62 @@ export class ContainerRuntime extends TypedEventEmitter {
298
276
  }
299
277
  }
300
278
  }
301
- const idCompressorEnabled = metadata?.idCompressorEnabled ?? runtimeOptions.enableRuntimeIdCompressor ?? false;
302
- let idCompressor;
303
- if (idCompressorEnabled) {
279
+ // Enabling the IdCompressor is a one-way operation and we only want to
280
+ // allow new containers to turn it on
281
+ let idCompressorMode;
282
+ if (existing) {
283
+ // This setting has to be sticky for correctness:
284
+ // 1) if compressior is OFF, it can't be enabled, as already running clients (in given document session) do not know
285
+ // how to process compressor ops
286
+ // 2) if it's ON, then all sessions should load compressor right away
287
+ // 3) Same logic applies for "delayed" mode
288
+ // Maybe in the future we will need to enabled (and figure how to do it safely) "delayed" -> "on" change.
289
+ // We could do "off" -> "on" transtition too, if all clients start loading compressor (but not using it initially) and do so for a while -
290
+ // this will allow clients to eventually to disregard "off" setting (when it's safe so) and start using compressor in future sessions.
291
+ // Everyting is possible, but it needs to be designed and executed carefully, when such need arises.
292
+ idCompressorMode = metadata?.idCompressorMode ?? "off";
293
+ }
294
+ else {
295
+ // FG overwrite
296
+ const enabled = mc.config.getBoolean("Fluid.ContainerRuntime.IdCompressorEnabled");
297
+ switch (enabled) {
298
+ case true:
299
+ idCompressorMode = "on";
300
+ break;
301
+ case false:
302
+ idCompressorMode = "off";
303
+ break;
304
+ default:
305
+ idCompressorMode = enableRuntimeIdCompressor;
306
+ break;
307
+ }
308
+ }
309
+ const createIdCompressorFn = async () => {
304
310
  const { createIdCompressor, deserializeIdCompressor, createSessionId } = await import("@fluidframework/id-compressor");
311
+ /**
312
+ * Because the IdCompressor emits so much telemetry, this function is used to sample
313
+ * approximately 5% of all clients. Only the given percentage of sessions will emit telemetry.
314
+ */
315
+ const idCompressorEventSampler = (() => {
316
+ const isIdCompressorTelemetryEnabled = Math.random() < 0.05;
317
+ return {
318
+ sample: () => {
319
+ return isIdCompressorTelemetryEnabled;
320
+ },
321
+ };
322
+ })();
323
+ const compressorLogger = createSampledLogger(logger, idCompressorEventSampler);
305
324
  const pendingLocalState = context.pendingLocalState;
306
325
  if (pendingLocalState?.pendingIdCompressorState !== undefined) {
307
- idCompressor = deserializeIdCompressor(pendingLocalState.pendingIdCompressorState);
326
+ return deserializeIdCompressor(pendingLocalState.pendingIdCompressorState, compressorLogger);
308
327
  }
309
328
  else if (serializedIdCompressor !== undefined) {
310
- idCompressor = deserializeIdCompressor(serializedIdCompressor, createSessionId());
329
+ return deserializeIdCompressor(serializedIdCompressor, createSessionId(), compressorLogger);
311
330
  }
312
331
  else {
313
- idCompressor = createIdCompressor(logger);
332
+ return createIdCompressor(compressorLogger);
314
333
  }
315
- }
334
+ };
316
335
  const runtime = new containerRuntimeCtor(context, registry, metadata, electedSummarizerData, chunks ?? [], aliases ?? [], {
317
336
  summaryOptions,
318
337
  gcOptions,
@@ -324,7 +343,7 @@ export class ContainerRuntime extends TypedEventEmitter {
324
343
  enableRuntimeIdCompressor,
325
344
  enableOpReentryCheck,
326
345
  enableGroupedBatching,
327
- }, containerScope, logger, existing, blobManagerSnapshot, context.storage, idCompressor, provideEntryPoint, requestHandler, undefined);
346
+ }, containerScope, logger, existing, blobManagerSnapshot, context.storage, createIdCompressorFn, idCompressorMode, provideEntryPoint, requestHandler, undefined);
328
347
  // Apply stashed ops with a reference sequence number equal to the sequence number of the snapshot,
329
348
  // or zero. This must be done before Container replays saved ops.
330
349
  await runtime.pendingStateManager.applyStashedOpsAt(runtimeSequenceNumber ?? 0);
@@ -338,6 +357,9 @@ export class ContainerRuntime extends TypedEventEmitter {
338
357
  get storage() {
339
358
  return this._storage;
340
359
  }
360
+ get containerRuntime() {
361
+ return this;
362
+ }
341
363
  get flushMode() {
342
364
  return this._flushMode;
343
365
  }
@@ -350,6 +372,25 @@ export class ContainerRuntime extends TypedEventEmitter {
350
372
  get attachState() {
351
373
  return this._getAttachState();
352
374
  }
375
+ /**
376
+ * See IContainerRuntimeBase.idCompressor() for details.
377
+ */
378
+ get idCompressor() {
379
+ // Expose ID Compressor only if it's On from the start.
380
+ // If container uses delayed mode, then we can only expose generateDocumentUniqueId() and nothing else.
381
+ // That's because any other usage will require immidiate loading of ID Compressor in next sessions in order
382
+ // to reason over such things as session ID space.
383
+ if (this.idCompressorMode === "on") {
384
+ assert(this._idCompressor !== undefined, 0x8ea /* compressor should have been loaded */);
385
+ return this._idCompressor;
386
+ }
387
+ }
388
+ /**
389
+ * See IContainerRuntimeBase.generateDocumentUniqueId() for details.
390
+ */
391
+ generateDocumentUniqueId() {
392
+ return this._idCompressor?.generateDocumentUniqueId() ?? uuid();
393
+ }
353
394
  get IFluidHandleContext() {
354
395
  return this.handleContext;
355
396
  }
@@ -387,9 +428,6 @@ export class ContainerRuntime extends TypedEventEmitter {
387
428
  isSummariesDisabled() {
388
429
  return this.summaryConfiguration.state === "disabled";
389
430
  }
390
- isHeuristicsDisabled() {
391
- return this.summaryConfiguration.state === "disableHeuristics";
392
- }
393
431
  getMaxOpsSinceLastSummary() {
394
432
  return this.summaryConfiguration.state !== "disabled"
395
433
  ? this.summaryConfiguration.maxOpsSinceLastSummary
@@ -414,7 +452,7 @@ export class ContainerRuntime extends TypedEventEmitter {
414
452
  return this.garbageCollector.throwOnTombstoneUsage;
415
453
  }
416
454
  /***/
417
- constructor(context, registry, metadata, electedSummarizerData, chunks, dataStoreAliasMap, runtimeOptions, containerScope, logger, existing, blobManagerSnapshot, _storage, idCompressor, provideEntryPoint, requestHandler, summaryConfiguration = {
455
+ constructor(context, registry, metadata, electedSummarizerData, chunks, dataStoreAliasMap, runtimeOptions, containerScope, logger, existing, blobManagerSnapshot, _storage, createIdCompressor, idCompressorMode, provideEntryPoint, requestHandler, summaryConfiguration = {
418
456
  // the defaults
419
457
  ...DefaultSummaryConfiguration,
420
458
  // the runtime configuration overrides
@@ -422,13 +460,24 @@ export class ContainerRuntime extends TypedEventEmitter {
422
460
  }) {
423
461
  super();
424
462
  this.registry = registry;
463
+ this.metadata = metadata;
425
464
  this.runtimeOptions = runtimeOptions;
426
465
  this.containerScope = containerScope;
427
466
  this.logger = logger;
428
467
  this._storage = _storage;
468
+ this.createIdCompressor = createIdCompressor;
469
+ this.idCompressorMode = idCompressorMode;
429
470
  this.requestHandler = requestHandler;
430
471
  this.summaryConfiguration = summaryConfiguration;
431
472
  this.imminentClosure = false;
473
+ // We accumulate Id compressor Ops while Id compressor is not loaded yet (only for "delayed" mode)
474
+ // Once it loads, it will process all such ops and we will stop accumulating further ops - ops will be processes as they come in.
475
+ this.pendingIdCompressorOps = [];
476
+ /**
477
+ * True if we have ID compressor loading in-flight (async operation). Useful only for
478
+ * this.idCompressorMode === "delayed" mode
479
+ */
480
+ this.compressorLoadInitiated = false;
432
481
  this.defaultMaxConsecutiveReconnects = 7;
433
482
  this._orderSequentiallyCalls = 0;
434
483
  this.flushTaskExists = false;
@@ -450,6 +499,13 @@ export class ContainerRuntime extends TypedEventEmitter {
450
499
  signalTimestamp: 0,
451
500
  trackingSignalSequenceNumber: undefined,
452
501
  };
502
+ /**
503
+ * It a cache for holding mapping for loading groupIds with its snapshot from the service. Add expiry policy of 1 minute.
504
+ * Starting with 1 min and based on recorded usage we can tweak it later on.
505
+ */
506
+ this.snapshotCacheForLoadingGroupIds = new PromiseCache({
507
+ expiry: { policy: "absolute", durationMs: 60000 },
508
+ });
453
509
  const { options, clientDetails, connected, baseSnapshot, submitFn, submitBatchFn, submitSummaryFn, submitSignalFn, disposeFn, closeFn, deltaManager, quorum, audience, loader, pendingLocalState, supportedFeatures, } = context;
454
510
  this.innerDeltaManager = deltaManager;
455
511
  this.deltaManager = new DeltaManagerSummarizerProxy(this.innerDeltaManager);
@@ -459,7 +515,9 @@ export class ContainerRuntime extends TypedEventEmitter {
459
515
  this.submitBatchFn = submitBatchFn;
460
516
  this.submitSummaryFn = submitSummaryFn;
461
517
  this.submitSignalFn = submitSignalFn;
462
- this.options = options;
518
+ // TODO: After IContainerContext.options is removed, we'll just create a new blank object {} here.
519
+ // Values are generally expected to be set from the runtime side.
520
+ this.options = options ?? {};
463
521
  this.clientDetails = clientDetails;
464
522
  this.isSummarizerClient = this.clientDetails.type === summarizerClientType;
465
523
  this.loadedFromVersionId = context.getLoadedFromVersion()?.id;
@@ -497,9 +555,6 @@ export class ContainerRuntime extends TypedEventEmitter {
497
555
  // summaryNumber was renamed from summaryCount. For older docs that haven't been opened for a long time,
498
556
  // the count is reset to 0.
499
557
  loadSummaryNumber = metadata?.summaryNumber ?? 0;
500
- // Enabling the IdCompressor is a one-way operation and we only want to
501
- // allow new containers to turn it on
502
- this.idCompressorEnabled = metadata?.idCompressorEnabled ?? false;
503
558
  }
504
559
  else {
505
560
  this.createContainerMetadata = {
@@ -507,9 +562,6 @@ export class ContainerRuntime extends TypedEventEmitter {
507
562
  createContainerTimestamp: Date.now(),
508
563
  };
509
564
  loadSummaryNumber = 0;
510
- this.idCompressorEnabled =
511
- this.mc.config.getBoolean("Fluid.ContainerRuntime.IdCompressorEnabled") ??
512
- idCompressor !== undefined;
513
565
  }
514
566
  this.nextSummaryNumber = loadSummaryNumber + 1;
515
567
  this.messageAtLastSummary = metadata?.message;
@@ -544,12 +596,8 @@ export class ContainerRuntime extends TypedEventEmitter {
544
596
  // Allow for a break-glass config to override the options
545
597
  disableOpReentryCheck !== true;
546
598
  this.summariesDisabled = this.isSummariesDisabled();
547
- this.heuristicsDisabled = this.isHeuristicsDisabled();
548
599
  this.maxOpsSinceLastSummary = this.getMaxOpsSinceLastSummary();
549
600
  this.initialSummarizerDelayMs = this.getInitialSummarizerDelayMs();
550
- if (this.idCompressorEnabled) {
551
- this.idCompressor = idCompressor;
552
- }
553
601
  this.maxConsecutiveReconnects =
554
602
  this.mc.config.getNumber(maxConsecutiveReconnectsKey) ??
555
603
  this.defaultMaxConsecutiveReconnects;
@@ -563,13 +611,15 @@ export class ContainerRuntime extends TypedEventEmitter {
563
611
  this._flushMode = runtimeOptions.flushMode;
564
612
  }
565
613
  const pendingRuntimeState = pendingLocalState;
566
- const maxSnapshotCacheDurationMs = this._storage?.policies?.maximumCacheDurationMs;
567
- if (maxSnapshotCacheDurationMs !== undefined &&
568
- maxSnapshotCacheDurationMs > 5 * 24 * 60 * 60 * 1000) {
569
- // This is a runtime enforcement of what's already explicit in the policy's type itself,
570
- // which dictates the value is either undefined or exactly 5 days in ms.
571
- // As long as the actual value is less than 5 days, the assumptions GC makes here are valid.
572
- throw new UsageError("Driver's maximumCacheDurationMs policy cannot exceed 5 days");
614
+ if (context.attachState === AttachState.Attached) {
615
+ const maxSnapshotCacheDurationMs = this._storage?.policies?.maximumCacheDurationMs;
616
+ if (maxSnapshotCacheDurationMs !== undefined &&
617
+ maxSnapshotCacheDurationMs > 5 * 24 * 60 * 60 * 1000) {
618
+ // This is a runtime enforcement of what's already explicit in the policy's type itself,
619
+ // which dictates the value is either undefined or exactly 5 days in ms.
620
+ // As long as the actual value is less than 5 days, the assumptions GC makes here are valid.
621
+ throw new UsageError("Driver's maximumCacheDurationMs policy cannot exceed 5 days");
622
+ }
573
623
  }
574
624
  this.garbageCollector = GarbageCollector.create({
575
625
  runtime: this,
@@ -584,6 +634,7 @@ export class ContainerRuntime extends TypedEventEmitter {
584
634
  getLastSummaryTimestampMs: () => this.messageAtLastSummary?.timestamp,
585
635
  readAndParseBlob: async (id) => readAndParse(this.storage, id),
586
636
  submitMessage: (message) => this.submit(message),
637
+ sessionExpiryTimerStarted: pendingRuntimeState?.sessionExpiryTimerStarted,
587
638
  });
588
639
  const loadedFromSequenceNumber = this.deltaManager.initialSequenceNumber;
589
640
  this.summarizerNode = createRootSummarizerNodeWithGC(createChildLogger({ logger: this.logger, namespace: "SummarizerNode" }),
@@ -596,9 +647,6 @@ export class ContainerRuntime extends TypedEventEmitter {
596
647
  // Must set to false to prevent sending summary handle which would be pointing to
597
648
  // a summary with an older protocol state.
598
649
  canReuseHandle: false,
599
- // Must set to true to throw on any data stores failure that was too severe to be handled.
600
- // We also are not decoding the base summaries at the root.
601
- throwOnFailure: true,
602
650
  // If GC should not run, let the summarizer node know so that it does not track GC state.
603
651
  gcDisabled: !this.garbageCollector.shouldRunGC,
604
652
  },
@@ -609,7 +657,16 @@ export class ContainerRuntime extends TypedEventEmitter {
609
657
  if (baseSnapshot) {
610
658
  this.summarizerNode.updateBaseSummaryState(baseSnapshot);
611
659
  }
612
- this.dataStores = new DataStores(getSummaryForDatastores(baseSnapshot, metadata), this, (attachMsg) => this.submit({ type: ContainerMessageType.Attach, contents: attachMsg }), (id, createParam) => (summarizeInternal, getGCDataFn) => this.summarizerNode.createChild(summarizeInternal, id, createParam, undefined, getGCDataFn), (id) => this.summarizerNode.deleteChild(id), this.mc.logger, (path, timestampMs, packagePath) => this.garbageCollector.nodeUpdated(path, "Changed", timestampMs, packagePath), (path) => this.garbageCollector.isNodeDeleted(path), new Map(dataStoreAliasMap));
660
+ const parentContext = wrapContext(this);
661
+ // Due to a mismatch between different layers in terms of
662
+ // what is the interface of passing signals, we need the
663
+ // downstream stores to wrap the signal.
664
+ parentContext.submitSignal = (type, content, targetClientId) => {
665
+ const envelope1 = content;
666
+ const envelope2 = this.createNewSignalEnvelope(envelope1.address, type, envelope1.contents);
667
+ return this.submitSignalFn(envelope2, targetClientId);
668
+ };
669
+ this.channelCollection = new ChannelCollection(getSummaryForDatastores(baseSnapshot, metadata), parentContext, this.mc.logger, (path, reason, timestampMs, packagePath, request, headerData) => this.garbageCollector.nodeUpdated(path, reason, timestampMs, packagePath, request, headerData), (path) => this.garbageCollector.isNodeDeleted(path), new Map(dataStoreAliasMap), async (runtime) => provideEntryPoint);
613
670
  this.blobManager = new BlobManager(this.handleContext, blobManagerSnapshot, () => this.storage, (localId, blobId) => {
614
671
  if (!this.disposed) {
615
672
  this.submit({ type: ContainerMessageType.BlobAttach, contents: undefined }, undefined, {
@@ -627,6 +684,7 @@ export class ContainerRuntime extends TypedEventEmitter {
627
684
  reSubmit: this.reSubmit.bind(this),
628
685
  reSubmitBatch: this.reSubmitBatch.bind(this),
629
686
  isActiveConnection: () => this.innerDeltaManager.active,
687
+ isAttached: () => this.attachState !== AttachState.Detached,
630
688
  }, pendingRuntimeState?.pending, this.logger);
631
689
  const disableCompression = this.mc.config.getBoolean("Fluid.ContainerRuntime.CompressionDisabled");
632
690
  const compressionOptions = disableCompression === true
@@ -718,7 +776,7 @@ export class ContainerRuntime extends TypedEventEmitter {
718
776
  // throttling function increases exponentially (0ms, 40ms, 80ms, 160ms, etc)
719
777
  formExponentialFn({ coefficient: 20, initialDelay: 0 })), {
720
778
  initialDelayMs: this.initialSummarizerDelayMs,
721
- }, this.heuristicsDisabled);
779
+ });
722
780
  this.summaryManager.on("summarize", (eventProps) => {
723
781
  this.emit("summarize", eventProps);
724
782
  });
@@ -733,25 +791,26 @@ export class ContainerRuntime extends TypedEventEmitter {
733
791
  this.mc.logger.sendTelemetryEvent({
734
792
  eventName: "ContainerLoadStats",
735
793
  ...this.createContainerMetadata,
736
- ...this.dataStores.containerLoadStats,
794
+ ...this.channelCollection.containerLoadStats,
737
795
  summaryNumber: loadSummaryNumber,
738
796
  summaryFormatVersion: metadata?.summaryFormatVersion,
739
797
  disableIsolatedChannels: metadata?.disableIsolatedChannels,
740
798
  gcVersion: metadata?.gcFeature,
741
799
  options: JSON.stringify(runtimeOptions),
800
+ idCompressorModeMetadata: metadata?.idCompressorMode,
801
+ idCompressorMode: this.idCompressorMode,
742
802
  featureGates: JSON.stringify({
743
803
  disableCompression,
744
804
  disableOpReentryCheck,
745
805
  disableChunking,
746
806
  disableAttachReorder: this.disableAttachReorder,
747
807
  disablePartialFlush,
748
- idCompressorEnabled: this.idCompressorEnabled,
749
808
  closeSummarizerDelayOverride,
750
809
  }),
751
810
  telemetryDocumentId: this.telemetryDocumentId,
752
811
  groupedBatchingEnabled: this.groupedBatchingEnabled,
753
812
  });
754
- ReportOpPerfTelemetry(this.clientId, this.deltaManager, this.logger);
813
+ ReportOpPerfTelemetry(this.clientId, this.deltaManager, this, this.logger);
755
814
  BindBatchTracker(this, this.logger);
756
815
  this.entryPoint = new LazyPromise(async () => {
757
816
  if (this.isSummarizerClient) {
@@ -760,11 +819,33 @@ export class ContainerRuntime extends TypedEventEmitter {
760
819
  }
761
820
  return provideEntryPoint(this);
762
821
  });
822
+ // If we loaded from pending state, then we need to skip any ops that are already accounted in such
823
+ // saved state, i.e. all the ops marked by Loader layer sa savedOp === true.
824
+ this.skipSavedCompressorOps = pendingRuntimeState?.pendingIdCompressorState !== undefined;
825
+ }
826
+ getCreateChildSummarizerNodeFn(id, createParam) {
827
+ return (summarizeInternal, getGCDataFn) => this.summarizerNode.createChild(summarizeInternal, id, createParam, undefined, getGCDataFn);
828
+ }
829
+ deleteChildSummarizerNode(id) {
830
+ return this.summarizerNode.deleteChild(id);
831
+ }
832
+ /* IFluidParentContext APIs that should not be called on Root */
833
+ makeLocallyVisible() {
834
+ assert(false, 0x8eb /* should not be called */);
835
+ }
836
+ setChannelDirty(address) {
837
+ assert(false, "should not be called");
763
838
  }
764
839
  /**
765
840
  * Initializes the state from the base snapshot this container runtime loaded from.
766
841
  */
767
842
  async initializeBaseState() {
843
+ if (this.idCompressorMode === "on" ||
844
+ (this.idCompressorMode === "delayed" && this.connected)) {
845
+ // This is called from loadRuntime(), long before we process any ops, so there should be no ops accumulated yet.
846
+ assert(this.pendingIdCompressorOps.length === 0, 0x8ec /* no pending ops */);
847
+ this._idCompressor = await this.createIdCompressor();
848
+ }
768
849
  await this.garbageCollector.initializeBaseState();
769
850
  }
770
851
  dispose(error) {
@@ -783,11 +864,110 @@ export class ContainerRuntime extends TypedEventEmitter {
783
864
  }
784
865
  this.garbageCollector.dispose();
785
866
  this._summarizer?.dispose();
786
- this.dataStores.dispose();
867
+ this.channelCollection.dispose();
787
868
  this.pendingStateManager.dispose();
788
869
  this.emit("dispose");
789
870
  this.removeAllListeners();
790
871
  }
872
+ /**
873
+ * Api to fetch the snapshot from the service for a loadingGroupIds.
874
+ * @param loadingGroupIds - LoadingGroupId for which the snapshot is asked for.
875
+ * @param pathParts - Parts of the path, which we want to extract from the snapshot tree.
876
+ * @returns - snapshotTree and the sequence number of the snapshot.
877
+ */
878
+ async getSnapshotForLoadingGroupId(loadingGroupIds, pathParts) {
879
+ const sortedLoadingGroupIds = loadingGroupIds.sort();
880
+ assert(this.storage.getSnapshot !== undefined, 0x8ed /* getSnapshot api should be defined if used */);
881
+ let loadedFromCache = true;
882
+ // Lookup up in the cache, if not present then make the network call as multiple datastores could
883
+ // be in same loading group. So, once we have fetched the snapshot for that loading group on
884
+ // any request, then cache that as same group could be requested in future too.
885
+ const snapshot = await this.snapshotCacheForLoadingGroupIds.addOrGet(sortedLoadingGroupIds.join(), async () => {
886
+ assert(this.storage.getSnapshot !== undefined, 0x8ee /* getSnapshot api should be defined if used */);
887
+ loadedFromCache = false;
888
+ return this.storage.getSnapshot({
889
+ cacheSnapshot: false,
890
+ scenarioName: "snapshotForLoadingGroupId",
891
+ loadingGroupIds: sortedLoadingGroupIds,
892
+ });
893
+ });
894
+ this.logger.sendTelemetryEvent({
895
+ eventName: "GroupIdSnapshotFetched",
896
+ details: JSON.stringify({
897
+ fromCache: loadedFromCache,
898
+ loadingGroupIds: loadingGroupIds.join(","),
899
+ }),
900
+ });
901
+ // Find the snapshotTree inside the returned snapshot based on the path as given in the request.
902
+ const hasIsolatedChannels = rootHasIsolatedChannels(this.metadata);
903
+ const snapshotTreeForPath = this.getSnapshotTreeForPath(snapshot.snapshotTree, pathParts, hasIsolatedChannels);
904
+ assert(snapshotTreeForPath !== undefined, 0x8ef /* no snapshotTree for the path */);
905
+ const snapshotSeqNumber = snapshot.sequenceNumber;
906
+ assert(snapshotSeqNumber !== undefined, 0x8f0 /* snapshotSeqNumber should be present */);
907
+ // This assert fires if we get a snapshot older than the snapshot we loaded from. This is a service issue.
908
+ // Snapshots should only move forward. If we observe an older snapshot than the one we loaded from, then likely
909
+ // the file has been overwritten or service lost data.
910
+ if (snapshotSeqNumber < this.deltaManager.initialSequenceNumber) {
911
+ throw DataProcessingError.create("Downloaded snapshot older than snapshot we loaded from", "getSnapshotForLoadingGroupId", undefined, {
912
+ loadingGroupIds: sortedLoadingGroupIds.join(","),
913
+ snapshotSeqNumber,
914
+ initialSequenceNumber: this.deltaManager.initialSequenceNumber,
915
+ });
916
+ }
917
+ // If the snapshot is ahead of the last seq number of the delta manager, then catch up before
918
+ // returning the snapshot.
919
+ if (snapshotSeqNumber > this.deltaManager.lastSequenceNumber) {
920
+ // If this is a summarizer client, which is trying to load a group and it finds that there is
921
+ // another snapshot from which the summarizer loaded and it is behind, then just give up as
922
+ // the summarizer state is not up to date.
923
+ // This should be a recoverable scenario and shouldn't happen as we should process the ack first.
924
+ if (this.isSummarizerClient) {
925
+ throw new Error("Summarizer client behind, loaded newer snapshot with loadingGroupId");
926
+ }
927
+ // We want to catchup from sequenceNumber to targetSequenceNumber
928
+ const props = {
929
+ eventName: "GroupIdSnapshotCatchup",
930
+ loadingGroupIds: sortedLoadingGroupIds.join(","),
931
+ targetSequenceNumber: snapshotSeqNumber,
932
+ sequenceNumber: this.deltaManager.lastSequenceNumber, // This is so we reuse some columns in telemetry
933
+ };
934
+ const event = PerformanceEvent.start(this.mc.logger, {
935
+ ...props,
936
+ });
937
+ // If the inbound deltas queue is paused or disconnected, we expect a reconnect and unpause
938
+ // as long as it's not a summarizer client.
939
+ if (this.deltaManager.inbound.paused) {
940
+ props.inboundPaused = this.deltaManager.inbound.paused; // reusing telemetry
941
+ }
942
+ const defP = new Deferred();
943
+ this.deltaManager.on("op", (message) => {
944
+ if (message.sequenceNumber >= snapshotSeqNumber) {
945
+ defP.resolve(true);
946
+ }
947
+ });
948
+ await defP.promise;
949
+ event.end(props);
950
+ }
951
+ return { snapshotTree: snapshotTreeForPath, sequenceNumber: snapshotSeqNumber };
952
+ }
953
+ /**
954
+ * Api to find a snapshot tree inside a bigger snapshot tree based on the path in the pathParts array.
955
+ * @param snapshotTree - snapshot tree to look into.
956
+ * @param pathParts - Part of the path, which we want to extract from the snapshot tree.
957
+ * @param hasIsolatedChannels - whether the channels are present inside ".channels" subtree. Older
958
+ * snapshots will not have trees inside ".channels", so check that.
959
+ * @returns - requested snapshot tree based on the path parts.
960
+ */
961
+ getSnapshotTreeForPath(snapshotTree, pathParts, hasIsolatedChannels) {
962
+ let childTree = snapshotTree;
963
+ for (const part of pathParts) {
964
+ if (hasIsolatedChannels) {
965
+ childTree = childTree?.trees[channelsTreeName];
966
+ }
967
+ childTree = childTree?.trees[part];
968
+ }
969
+ return childTree;
970
+ }
791
971
  /**
792
972
  * Notifies this object about the request made to the container.
793
973
  * @param request - Request made to the handler.
@@ -841,15 +1021,7 @@ export class ContainerRuntime extends TypedEventEmitter {
841
1021
  : create404Response(request);
842
1022
  }
843
1023
  else if (requestParser.pathParts.length > 0) {
844
- // Differentiate between requesting the dataStore directly, or one of its children
845
- const requestForChild = !requestParser.isLeaf(1);
846
- const dataStore = await this.getDataStoreFromRequest(id, request, requestForChild);
847
- const subRequest = requestParser.createSubRequest(1);
848
- // We always expect createSubRequest to include a leading slash, but asserting here to protect against
849
- // unintentionally modifying the url if that changes.
850
- assert(subRequest.url.startsWith("/"), 0x126 /* "Expected createSubRequest url to include a leading slash" */);
851
- // eslint-disable-next-line @typescript-eslint/return-await -- Adding an await here causes test failures
852
- return dataStore.request(subRequest);
1024
+ return await this.channelCollection.request(request);
853
1025
  }
854
1026
  return create404Response(request);
855
1027
  }
@@ -864,38 +1036,7 @@ export class ContainerRuntime extends TypedEventEmitter {
864
1036
  return this.entryPoint;
865
1037
  }
866
1038
  internalId(maybeAlias) {
867
- return this.dataStores.aliases.get(maybeAlias) ?? maybeAlias;
868
- }
869
- async getDataStoreFromRequest(id, request, requestForChild) {
870
- const headerData = {};
871
- if (typeof request.headers?.[RuntimeHeaders.wait] === "boolean") {
872
- headerData.wait = request.headers[RuntimeHeaders.wait];
873
- }
874
- if (typeof request.headers?.[RuntimeHeaders.viaHandle] === "boolean") {
875
- headerData.viaHandle = request.headers[RuntimeHeaders.viaHandle];
876
- }
877
- if (typeof request.headers?.[AllowTombstoneRequestHeaderKey] === "boolean") {
878
- headerData.allowTombstone = request.headers[AllowTombstoneRequestHeaderKey];
879
- }
880
- if (typeof request.headers?.[AllowInactiveRequestHeaderKey] === "boolean") {
881
- headerData.allowInactive = request.headers[AllowInactiveRequestHeaderKey];
882
- }
883
- // We allow Tombstone requests for sub-DataStore objects
884
- if (requestForChild) {
885
- headerData.allowTombstone = true;
886
- }
887
- await this.dataStores.waitIfPendingAlias(id);
888
- const internalId = this.internalId(id);
889
- const dataStoreContext = await this.dataStores.getDataStore(internalId, headerData);
890
- // Remove query params, leading and trailing slashes from the url. This is done to make sure the format is
891
- // the same as GC nodes id.
892
- const urlWithoutQuery = trimLeadingAndTrailingSlashes(request.url.split("?")[0]);
893
- // Get the initial snapshot details which contain the data store package path.
894
- const details = await dataStoreContext.getInitialSnapshotDetails();
895
- // Note that this will throw if the data store is inactive or tombstoned and throwing on incorrect usage
896
- // is configured.
897
- this.garbageCollector.nodeUpdated(`/${urlWithoutQuery}`, "Loaded", undefined /* timestampMs */, details.pkg, request, headerData);
898
- return dataStoreContext.realize();
1039
+ return this.channelCollection.internalId(maybeAlias);
899
1040
  }
900
1041
  /** Adds the container's metadata to the given summary tree. */
901
1042
  addMetadataToSummary(summaryTree) {
@@ -910,22 +1051,21 @@ export class ContainerRuntime extends TypedEventEmitter {
910
1051
  message: extractSummaryMetadataMessage(this.deltaManager.lastMessage) ??
911
1052
  this.messageAtLastSummary,
912
1053
  telemetryDocumentId: this.telemetryDocumentId,
913
- idCompressorEnabled: this.idCompressorEnabled ? true : undefined,
1054
+ idCompressorMode: this.idCompressorMode,
914
1055
  };
915
1056
  addBlobToSummary(summaryTree, metadataBlobName, JSON.stringify(metadata));
916
1057
  }
917
1058
  addContainerStateToSummary(summaryTree, fullTree, trackState, telemetryContext) {
918
1059
  this.addMetadataToSummary(summaryTree);
919
- if (this.idCompressorEnabled) {
920
- assert(this.idCompressor !== undefined, 0x67a /* IdCompressor should be defined if enabled */);
921
- const idCompressorState = JSON.stringify(this.idCompressor.serialize(false));
1060
+ if (this._idCompressor) {
1061
+ const idCompressorState = JSON.stringify(this._idCompressor.serialize(false));
922
1062
  addBlobToSummary(summaryTree, idCompressorBlobName, idCompressorState);
923
1063
  }
924
1064
  if (this.remoteMessageProcessor.partialMessages.size > 0) {
925
1065
  const content = JSON.stringify([...this.remoteMessageProcessor.partialMessages]);
926
1066
  addBlobToSummary(summaryTree, chunksBlobName, content);
927
1067
  }
928
- const dataStoreAliases = this.dataStores.aliases;
1068
+ const dataStoreAliases = this.channelCollection.aliases;
929
1069
  if (dataStoreAliases.size > 0) {
930
1070
  addBlobToSummary(summaryTree, aliasBlobName, JSON.stringify([...dataStoreAliases]));
931
1071
  }
@@ -937,7 +1077,7 @@ export class ContainerRuntime extends TypedEventEmitter {
937
1077
  // Some storage (like git) doesn't allow empty tree, so we can omit it.
938
1078
  // and the blob manager can handle the tree not existing when loading
939
1079
  if (Object.keys(blobManagerSummary.summary.tree).length > 0) {
940
- addTreeToSummary(summaryTree, blobsTreeName, blobManagerSummary);
1080
+ addSummarizeResultToSummary(summaryTree, blobsTreeName, blobManagerSummary);
941
1081
  }
942
1082
  const gcSummary = this.garbageCollector.summarize(fullTree, trackState, telemetryContext);
943
1083
  if (gcSummary !== undefined) {
@@ -1024,13 +1164,12 @@ export class ContainerRuntime extends TypedEventEmitter {
1024
1164
  const opContents = this.parseLocalOpContent(serializedOpContent);
1025
1165
  switch (opContents.type) {
1026
1166
  case ContainerMessageType.FluidDataStoreOp:
1027
- return this.dataStores.applyStashedOp(opContents.contents);
1028
1167
  case ContainerMessageType.Attach:
1029
- return this.dataStores.applyStashedAttachOp(opContents.contents);
1168
+ case ContainerMessageType.Alias:
1169
+ return this.channelCollection.applyStashedOp(opContents);
1030
1170
  case ContainerMessageType.IdAllocation:
1031
- assert(this.idCompressor !== undefined, 0x67b /* IdCompressor should be defined if enabled */);
1171
+ assert(this.idCompressorMode !== "off", 0x8f1 /* ID compressor should be in use */);
1032
1172
  return;
1033
- case ContainerMessageType.Alias:
1034
1173
  case ContainerMessageType.BlobAttach:
1035
1174
  return;
1036
1175
  case ContainerMessageType.ChunkedOp:
@@ -1055,10 +1194,26 @@ export class ContainerRuntime extends TypedEventEmitter {
1055
1194
  this.closeFn(error);
1056
1195
  throw error;
1057
1196
  }
1197
+ // Note: Even if its compat behavior allows it, we don't know how to apply this stashed op.
1198
+ // All we can do is ignore it (similar to on process).
1058
1199
  }
1059
1200
  }
1060
1201
  }
1061
1202
  setConnectionState(connected, clientId) {
1203
+ if (connected && this.idCompressorMode === "delayed" && !this.compressorLoadInitiated) {
1204
+ this.compressorLoadInitiated = true;
1205
+ this.createIdCompressor()
1206
+ .then((compressor) => {
1207
+ this._idCompressor = compressor;
1208
+ for (const range of this.pendingIdCompressorOps) {
1209
+ this._idCompressor.finalizeCreationRange(range);
1210
+ }
1211
+ this.pendingIdCompressorOps = [];
1212
+ })
1213
+ .catch((error) => {
1214
+ this.logger.sendErrorEvent({ eventName: "IdCompressorDelayedLoad" }, error);
1215
+ });
1216
+ }
1062
1217
  if (connected === false && this.delayConnectClientId !== undefined) {
1063
1218
  this.delayConnectClientId = undefined;
1064
1219
  this.mc.logger.sendTelemetryEvent({
@@ -1122,7 +1277,7 @@ export class ContainerRuntime extends TypedEventEmitter {
1122
1277
  if (changeOfState) {
1123
1278
  this.replayPendingStates();
1124
1279
  }
1125
- this.dataStores.setConnectionState(connected, clientId);
1280
+ this.channelCollection.setConnectionState(connected, clientId);
1126
1281
  this.garbageCollector.setConnectionState(connected, clientId);
1127
1282
  raiseConnectedEvent(this.mc.logger, this, connected, clientId);
1128
1283
  }
@@ -1205,23 +1360,28 @@ export class ContainerRuntime extends TypedEventEmitter {
1205
1360
  const { local } = messageWithContext;
1206
1361
  switch (messageWithContext.message.type) {
1207
1362
  case ContainerMessageType.Attach:
1208
- this.dataStores.processAttachMessage(messageWithContext.message, local);
1209
- break;
1210
1363
  case ContainerMessageType.Alias:
1211
- this.dataStores.processAliasMessage(messageWithContext.message, localOpMetadata, local);
1212
- break;
1213
1364
  case ContainerMessageType.FluidDataStoreOp:
1214
- this.dataStores.processFluidDataStoreOp(messageWithContext.message, local, localOpMetadata, (from, to) => this.garbageCollector.addedOutboundReference(from, to));
1365
+ this.channelCollection.process(messageWithContext.message, local, localOpMetadata, (from, to) => this.garbageCollector.addedOutboundReference(from, to));
1215
1366
  break;
1216
1367
  case ContainerMessageType.BlobAttach:
1217
1368
  this.blobManager.processBlobAttachOp(messageWithContext.message, local);
1218
1369
  break;
1219
1370
  case ContainerMessageType.IdAllocation:
1220
- assert(this.idCompressor !== undefined, 0x67c /* IdCompressor should be defined if enabled */);
1221
1371
  // Don't re-finalize the range if we're processing a "savedOp" in
1222
1372
  // stashed ops flow. The compressor is stashed with these ops already processed.
1223
- if (messageWithContext.message.metadata?.savedOp !== true) {
1224
- this.idCompressor.finalizeCreationRange(messageWithContext.message.contents);
1373
+ // That said, in idCompressorMode === "delayed", we might not serialize ID compressor, and
1374
+ // thus we need to process all the ops.
1375
+ if (!(this.skipSavedCompressorOps &&
1376
+ messageWithContext.message.metadata?.savedOp ===
1377
+ true)) {
1378
+ const range = messageWithContext.message.contents;
1379
+ if (this._idCompressor === undefined) {
1380
+ this.pendingIdCompressorOps.push(range);
1381
+ }
1382
+ else {
1383
+ this._idCompressor.finalizeCreationRange(range);
1384
+ }
1225
1385
  }
1226
1386
  break;
1227
1387
  case ContainerMessageType.GC:
@@ -1308,7 +1468,15 @@ export class ContainerRuntime extends TypedEventEmitter {
1308
1468
  this.emit("signal", transformed, local);
1309
1469
  return;
1310
1470
  }
1311
- this.dataStores.processSignal(envelope.address, transformed, local);
1471
+ // Due to a mismatch between different layers in terms of
1472
+ // what is the interface of passing signals, we need to adjust
1473
+ // the signal envelope before sending it to the datastores to be processed
1474
+ const envelope2 = {
1475
+ address: envelope.address,
1476
+ contents: transformed.content,
1477
+ };
1478
+ transformed.content = envelope2;
1479
+ this.channelCollection.processSignal(transformed, local);
1312
1480
  }
1313
1481
  /**
1314
1482
  * Flush the pending ops manually.
@@ -1319,6 +1487,9 @@ export class ContainerRuntime extends TypedEventEmitter {
1319
1487
  this.outbox.flush();
1320
1488
  assert(this.outbox.isEmpty, 0x3cf /* reentrancy */);
1321
1489
  }
1490
+ /**
1491
+ * {@inheritDoc @fluidframework/runtime-definitions#IContainerRuntimeBase.orderSequentially}
1492
+ */
1322
1493
  orderSequentially(callback) {
1323
1494
  let checkpoint;
1324
1495
  let result;
@@ -1347,8 +1518,9 @@ export class ContainerRuntime extends TypedEventEmitter {
1347
1518
  }
1348
1519
  }
1349
1520
  else {
1350
- // pre-0.58 error message: orderSequentiallyCallbackException
1351
- this.closeFn(new GenericError("orderSequentially callback exception", error));
1521
+ this.closeFn(wrapError(error, (errorMessage) => new GenericError(`orderSequentially callback exception: ${errorMessage}`, error, {
1522
+ orderSequentiallyCalls: this._orderSequentiallyCalls,
1523
+ })));
1352
1524
  }
1353
1525
  throw error; // throw the original error for the consumer of the runtime
1354
1526
  }
@@ -1368,9 +1540,17 @@ export class ContainerRuntime extends TypedEventEmitter {
1368
1540
  * Returns undefined if no data store has been assigned the given alias.
1369
1541
  */
1370
1542
  async getAliasedDataStoreEntryPoint(alias) {
1371
- await this.dataStores.waitIfPendingAlias(alias);
1543
+ // Back-comapatibility:
1544
+ // There are old files that were created without using data store aliasing feature, but
1545
+ // used createRoot*DataStore*() (already removed) API. Such data stores will have isRoot = true,
1546
+ // and internalID provided by user. The expectation is that such files behave as new files, where
1547
+ // same data store instances created using aliasing feature.
1548
+ // Please also see note on name collisions in DataStores.createDataStoreId()
1549
+ await this.channelCollection.waitIfPendingAlias(alias);
1372
1550
  const internalId = this.internalId(alias);
1373
- const context = await this.dataStores.getDataStoreIfAvailable(internalId, { wait: false });
1551
+ const context = await this.channelCollection.getDataStoreIfAvailable(internalId, {
1552
+ wait: false,
1553
+ });
1374
1554
  // If the data store is not available or not an alias, return undefined.
1375
1555
  if (context === undefined || !(await context.isRoot())) {
1376
1556
  return undefined;
@@ -1382,28 +1562,20 @@ export class ContainerRuntime extends TypedEventEmitter {
1382
1562
  this.garbageCollector.nodeUpdated(`/${internalId}`, "Loaded", undefined /* timestampMs */, context.packagePath);
1383
1563
  return channel.entryPoint;
1384
1564
  }
1385
- createDetachedRootDataStore(pkg, rootDataStoreId) {
1386
- if (rootDataStoreId.includes("/")) {
1387
- throw new UsageError(`Id cannot contain slashes: '${rootDataStoreId}'`);
1388
- }
1389
- return this.dataStores.createDetachedDataStoreCore(pkg, true, rootDataStoreId);
1390
- }
1391
- createDetachedDataStore(pkg) {
1392
- return this.dataStores.createDetachedDataStoreCore(pkg, false);
1565
+ createDetachedDataStore(pkg, loadingGroupId) {
1566
+ return this.channelCollection.createDetachedDataStore(pkg, loadingGroupId);
1393
1567
  }
1394
- async createDataStore(pkg) {
1395
- const id = uuid();
1396
- return channelToDataStore(await this.dataStores
1397
- ._createFluidDataStoreContext(Array.isArray(pkg) ? pkg : [pkg], id)
1398
- .realize(), id, this, this.dataStores, this.mc.logger);
1568
+ async createDataStore(pkg, loadingGroupId) {
1569
+ const context = this.channelCollection.createDataStoreContext(Array.isArray(pkg) ? pkg : [pkg], undefined, // props
1570
+ loadingGroupId);
1571
+ return channelToDataStore(await context.realize(), context.id, this.channelCollection, this.mc.logger);
1399
1572
  }
1400
1573
  /**
1401
1574
  * @deprecated 0.16 Issue #1537, #3631
1402
1575
  */
1403
- async _createDataStoreWithProps(pkg, props, id = uuid()) {
1404
- return channelToDataStore(await this.dataStores
1405
- ._createFluidDataStoreContext(Array.isArray(pkg) ? pkg : [pkg], id, props)
1406
- .realize(), id, this, this.dataStores, this.mc.logger);
1576
+ async _createDataStoreWithProps(pkg, props) {
1577
+ const context = this.channelCollection.createDataStoreContext(Array.isArray(pkg) ? pkg : [pkg], props);
1578
+ return channelToDataStore(await context.realize(), context.id, this.channelCollection, this.mc.logger);
1407
1579
  }
1408
1580
  canSendOps() {
1409
1581
  // Note that the real (non-proxy) delta manager is needed here to get the readonly info. This is because
@@ -1481,16 +1653,6 @@ export class ContainerRuntime extends TypedEventEmitter {
1481
1653
  const envelope = this.createNewSignalEnvelope(undefined /* address */, type, content);
1482
1654
  return this.submitSignalFn(envelope, targetClientId);
1483
1655
  }
1484
- /**
1485
- * Submits the signal to be sent to other clients.
1486
- * @param type - Type of the signal.
1487
- * @param content - Content of the signal.
1488
- * @param targetClientId - When specified, the signal is only sent to the provided client id.
1489
- */
1490
- submitDataStoreSignal(address, type, content, targetClientId) {
1491
- const envelope = this.createNewSignalEnvelope(address, type, content);
1492
- return this.submitSignalFn(envelope, targetClientId);
1493
- }
1494
1656
  setAttachState(attachState) {
1495
1657
  if (attachState === AttachState.Attaching) {
1496
1658
  assert(this.attachState === AttachState.Attaching, 0x12d /* "Container Context should already be in attaching state" */);
@@ -1502,7 +1664,7 @@ export class ContainerRuntime extends TypedEventEmitter {
1502
1664
  if (attachState === AttachState.Attached && !this.hasPendingMessages()) {
1503
1665
  this.updateDocumentDirtyState(false);
1504
1666
  }
1505
- this.dataStores.setAttachState(attachState);
1667
+ this.channelCollection.setAttachState(attachState);
1506
1668
  }
1507
1669
  /**
1508
1670
  * Create a summary. Used when attaching or serializing a detached container.
@@ -1517,18 +1679,18 @@ export class ContainerRuntime extends TypedEventEmitter {
1517
1679
  this.blobManager.setRedirectTable(blobRedirectTable);
1518
1680
  }
1519
1681
  // We can finalize any allocated IDs since we're the only client
1520
- const idRange = this.idCompressor?.takeNextCreationRange();
1682
+ const idRange = this._idCompressor?.takeNextCreationRange();
1521
1683
  if (idRange !== undefined) {
1522
- this.idCompressor?.finalizeCreationRange(idRange);
1684
+ this._idCompressor?.finalizeCreationRange(idRange);
1523
1685
  }
1524
- const summarizeResult = this.dataStores.createSummary(telemetryContext);
1686
+ const summarizeResult = this.channelCollection.getAttachSummary(telemetryContext);
1525
1687
  // Wrap data store summaries in .channels subtree.
1526
1688
  wrapSummaryInChannelsTree(summarizeResult);
1527
1689
  this.addContainerStateToSummary(summarizeResult, true /* fullTree */, false /* trackState */, telemetryContext);
1528
1690
  return summarizeResult.summary;
1529
1691
  }
1530
1692
  async summarizeInternal(fullTree, trackState, telemetryContext) {
1531
- const summarizeResult = await this.dataStores.summarize(fullTree, trackState, telemetryContext);
1693
+ const summarizeResult = await this.channelCollection.summarize(fullTree, trackState, telemetryContext);
1532
1694
  // Wrap data store summaries in .channels subtree.
1533
1695
  wrapSummaryInChannelsTree(summarizeResult);
1534
1696
  const pathPartsForChildren = [channelsTreeName];
@@ -1576,10 +1738,10 @@ export class ContainerRuntime extends TypedEventEmitter {
1576
1738
  * @see IGarbageCollectionRuntime.updateStateBeforeGC
1577
1739
  */
1578
1740
  async updateStateBeforeGC() {
1579
- return this.dataStores.updateStateBeforeGC();
1741
+ return this.channelCollection.updateStateBeforeGC();
1580
1742
  }
1581
1743
  async getGCDataInternal(fullGC) {
1582
- return this.dataStores.getGCData(fullGC);
1744
+ return this.channelCollection.getGCData(fullGC);
1583
1745
  }
1584
1746
  /**
1585
1747
  * Generates and returns the GC data for this container.
@@ -1605,22 +1767,7 @@ export class ContainerRuntime extends TypedEventEmitter {
1605
1767
  // always referenced, so the used routes is only self-route (empty string).
1606
1768
  this.summarizerNode.updateUsedRoutes([""]);
1607
1769
  const { dataStoreRoutes } = this.getDataStoreAndBlobManagerRoutes(usedRoutes);
1608
- this.dataStores.updateUsedRoutes(dataStoreRoutes);
1609
- }
1610
- /**
1611
- * This is called to update objects whose routes are unused.
1612
- * @param unusedRoutes - Data store and attachment blob routes that are unused in this Container.
1613
- */
1614
- updateUnusedRoutes(unusedRoutes) {
1615
- const { blobManagerRoutes, dataStoreRoutes } = this.getDataStoreAndBlobManagerRoutes(unusedRoutes);
1616
- this.blobManager.updateUnusedRoutes(blobManagerRoutes);
1617
- this.dataStores.updateUnusedRoutes(dataStoreRoutes);
1618
- }
1619
- /**
1620
- * @deprecated Replaced by deleteSweepReadyNodes.
1621
- */
1622
- deleteUnusedNodes(unusedRoutes) {
1623
- throw new Error("deleteUnusedRoutes should not be called");
1770
+ this.channelCollection.updateUsedRoutes(dataStoreRoutes);
1624
1771
  }
1625
1772
  /**
1626
1773
  * After GC has run and identified nodes that are sweep ready, this is called to delete the sweep ready nodes.
@@ -1629,7 +1776,7 @@ export class ContainerRuntime extends TypedEventEmitter {
1629
1776
  */
1630
1777
  deleteSweepReadyNodes(sweepReadyRoutes) {
1631
1778
  const { dataStoreRoutes, blobManagerRoutes } = this.getDataStoreAndBlobManagerRoutes(sweepReadyRoutes);
1632
- const deletedRoutes = this.dataStores.deleteSweepReadyNodes(dataStoreRoutes);
1779
+ const deletedRoutes = this.channelCollection.deleteSweepReadyNodes(dataStoreRoutes);
1633
1780
  return deletedRoutes.concat(this.blobManager.deleteSweepReadyNodes(blobManagerRoutes));
1634
1781
  }
1635
1782
  /**
@@ -1643,7 +1790,7 @@ export class ContainerRuntime extends TypedEventEmitter {
1643
1790
  updateTombstonedRoutes(tombstonedRoutes) {
1644
1791
  const { blobManagerRoutes, dataStoreRoutes } = this.getDataStoreAndBlobManagerRoutes(tombstonedRoutes);
1645
1792
  this.blobManager.updateTombstonedRoutes(blobManagerRoutes);
1646
- this.dataStores.updateTombstonedRoutes(dataStoreRoutes);
1793
+ this.channelCollection.updateTombstonedRoutes(dataStoreRoutes);
1647
1794
  }
1648
1795
  /**
1649
1796
  * Returns a server generated referenced timestamp to be used to track unreferenced nodes by GC.
@@ -1661,19 +1808,24 @@ export class ContainerRuntime extends TypedEventEmitter {
1661
1808
  if (this.isBlobPath(nodePath)) {
1662
1809
  return GCNodeType.Blob;
1663
1810
  }
1664
- return this.dataStores.getGCNodeType(nodePath) ?? GCNodeType.Other;
1811
+ return this.channelCollection.getGCNodeType(nodePath) ?? GCNodeType.Other;
1665
1812
  }
1666
1813
  /**
1667
1814
  * Called by GC to retrieve the package path of the node with the given path. The node should belong to a
1668
1815
  * data store or an attachment blob.
1669
1816
  */
1670
1817
  async getGCNodePackagePath(nodePath) {
1818
+ // GC uses "/" when adding "root" references, e.g. for Aliasing or as part of Tombstone Auto-Recovery.
1819
+ // These have no package path so return a special value.
1820
+ if (nodePath === "/") {
1821
+ return ["_gcRoot"];
1822
+ }
1671
1823
  switch (this.getNodeType(nodePath)) {
1672
1824
  case GCNodeType.Blob:
1673
1825
  return [BlobManager.basePath];
1674
1826
  case GCNodeType.DataStore:
1675
1827
  case GCNodeType.SubDataStore:
1676
- return this.dataStores.getDataStorePackagePath(nodePath);
1828
+ return this.channelCollection.getDataStorePackagePath(nodePath);
1677
1829
  default:
1678
1830
  assert(false, 0x2de /* "Package path requested for unsupported node type." */);
1679
1831
  }
@@ -1732,7 +1884,7 @@ export class ContainerRuntime extends TypedEventEmitter {
1732
1884
  * @param options - options controlling how the summary is generated or submitted
1733
1885
  */
1734
1886
  async submitSummary(options) {
1735
- const { fullTree = false, finalAttempt = false, refreshLatestAck, summaryLogger } = options;
1887
+ const { fullTree = false, finalAttempt = false, refreshLatestAck, summaryLogger, latestSummaryRefSeqNum, } = options;
1736
1888
  // The summary number for this summary. This will be updated during the summary process, so get it now and
1737
1889
  // use it for all events logged during this summary.
1738
1890
  const summaryNumber = this.nextSummaryNumber;
@@ -1744,7 +1896,6 @@ export class ContainerRuntime extends TypedEventEmitter {
1744
1896
  });
1745
1897
  assert(this.outbox.isEmpty, 0x3d1 /* Can't trigger summary in the middle of a batch */);
1746
1898
  // We close the summarizer and download a new snapshot and reload the container
1747
- let latestSnapshotVersionId;
1748
1899
  if (refreshLatestAck === true) {
1749
1900
  return this.prefetchLatestSummaryThenClose(createChildLogger({
1750
1901
  logger: summaryNumberLogger,
@@ -1786,6 +1937,7 @@ export class ContainerRuntime extends TypedEventEmitter {
1786
1937
  }
1787
1938
  }
1788
1939
  const shouldPauseInboundSignal = this.mc.config.getBoolean("Fluid.ContainerRuntime.SubmitSummary.disableInboundSignalPause") !== true;
1940
+ const shouldValidatePreSummaryState = this.mc.config.getBoolean("Fluid.ContainerRuntime.SubmitSummary.shouldValidatePreSummaryState") === true;
1789
1941
  let summaryRefSeqNum;
1790
1942
  try {
1791
1943
  await this.deltaManager.inbound.pause();
@@ -1796,7 +1948,25 @@ export class ContainerRuntime extends TypedEventEmitter {
1796
1948
  const minimumSequenceNumber = this.deltaManager.minimumSequenceNumber;
1797
1949
  const message = `Summary @${summaryRefSeqNum}:${this.deltaManager.minimumSequenceNumber}`;
1798
1950
  const lastAck = this.summaryCollection.latestAck;
1799
- this.summarizerNode.startSummary(summaryRefSeqNum, summaryNumberLogger);
1951
+ const startSummaryResult = this.summarizerNode.startSummary(summaryRefSeqNum, summaryNumberLogger, latestSummaryRefSeqNum);
1952
+ if (startSummaryResult.invalidNodes > 0 ||
1953
+ startSummaryResult.mismatchNumbers.size > 0) {
1954
+ summaryLogger.sendErrorEvent({
1955
+ eventName: "LatestSummaryRefSeqNumMismatch",
1956
+ details: {
1957
+ ...startSummaryResult,
1958
+ mismatchNumbers: Array.from(startSummaryResult.mismatchNumbers),
1959
+ },
1960
+ });
1961
+ if (shouldValidatePreSummaryState && !finalAttempt) {
1962
+ return {
1963
+ stage: "base",
1964
+ referenceSequenceNumber: summaryRefSeqNum,
1965
+ minimumSequenceNumber,
1966
+ error: `Summarizer node state inconsistent with summarizer state.`,
1967
+ };
1968
+ }
1969
+ }
1800
1970
  // Helper function to check whether we should still continue between each async step.
1801
1971
  const checkContinue = () => {
1802
1972
  // Do not check for loss of connectivity directly! Instead leave it up to
@@ -1892,8 +2062,8 @@ export class ContainerRuntime extends TypedEventEmitter {
1892
2062
  ? calculateStats(summaryTree.tree[gcTreeKey])
1893
2063
  : undefined;
1894
2064
  const summaryStats = {
1895
- dataStoreCount: this.dataStores.size,
1896
- summarizedDataStoreCount: this.dataStores.size - handleCount,
2065
+ dataStoreCount: this.channelCollection.size,
2066
+ summarizedDataStoreCount: this.channelCollection.size - handleCount,
1897
2067
  gcStateUpdatedDataStoreCount: this.garbageCollector.updatedDSCountSinceLastSummary,
1898
2068
  gcBlobNodeCount: gcSummaryTreeStats?.blobNodeCount,
1899
2069
  gcTotalBlobsSize: gcSummaryTreeStats?.totalBlobSize,
@@ -1912,34 +2082,17 @@ export class ContainerRuntime extends TypedEventEmitter {
1912
2082
  if (!continueResult.continue) {
1913
2083
  return { stage: "generate", ...generateSummaryData, error: continueResult.error };
1914
2084
  }
1915
- // It may happen that the lastAck it not correct due to missing summaryAck in case of single commit
1916
- // summary. So if the previous summarizer closes just after submitting the summary and before
1917
- // submitting the summaryOp then we can't rely on summaryAck. So in case we have
1918
- // latestSnapshotVersionId from storage and it does not match with the lastAck ackHandle, then use
1919
- // the one fetched from storage as parent as that is the latest.
1920
- let summaryContext;
1921
- if (lastAck?.summaryAck.contents.handle !== latestSnapshotVersionId &&
1922
- latestSnapshotVersionId !== undefined) {
1923
- summaryContext = {
1924
- proposalHandle: undefined,
1925
- ackHandle: latestSnapshotVersionId,
1926
- referenceSequenceNumber: summaryRefSeqNum,
1927
- };
1928
- }
1929
- else if (lastAck === undefined) {
1930
- summaryContext = {
2085
+ const summaryContext = lastAck === undefined
2086
+ ? {
1931
2087
  proposalHandle: undefined,
1932
2088
  ackHandle: this.loadedFromVersionId,
1933
2089
  referenceSequenceNumber: summaryRefSeqNum,
1934
- };
1935
- }
1936
- else {
1937
- summaryContext = {
2090
+ }
2091
+ : {
1938
2092
  proposalHandle: lastAck.summaryOp.contents.handle,
1939
2093
  ackHandle: lastAck.summaryAck.contents.handle,
1940
2094
  referenceSequenceNumber: summaryRefSeqNum,
1941
2095
  };
1942
- }
1943
2096
  let handle;
1944
2097
  try {
1945
2098
  handle = await this.storage.uploadSummaryWithContext(summarizeResult.summary, summaryContext);
@@ -2064,48 +2217,29 @@ export class ContainerRuntime extends TypedEventEmitter {
2064
2217
  this.emit(dirty ? "dirty" : "saved");
2065
2218
  }
2066
2219
  }
2067
- submitDataStoreOp(id, contents, localOpMetadata = undefined) {
2068
- const envelope = {
2069
- address: id,
2070
- contents,
2071
- };
2072
- this.submit({ type: ContainerMessageType.FluidDataStoreOp, contents: envelope }, localOpMetadata);
2073
- }
2074
- submitDataStoreAliasOp(contents, localOpMetadata) {
2075
- const aliasMessage = contents;
2076
- if (!isDataStoreAliasMessage(aliasMessage)) {
2077
- throw new UsageError("malformedDataStoreAliasMessage");
2078
- }
2079
- this.submit({ type: ContainerMessageType.Alias, contents }, localOpMetadata);
2220
+ submitMessage(type, contents, localOpMetadata = undefined) {
2221
+ this.submit({ type, contents }, localOpMetadata);
2080
2222
  }
2081
2223
  async uploadBlob(blob, signal) {
2082
2224
  this.verifyNotClosed();
2083
2225
  return this.blobManager.createBlob(blob, signal);
2084
2226
  }
2085
- maybeSubmitIdAllocationOp(type) {
2086
- if (type !== ContainerMessageType.IdAllocation) {
2087
- let idAllocationBatchMessage;
2088
- let idRange;
2089
- if (this.idCompressorEnabled) {
2090
- assert(this.idCompressor !== undefined, 0x67d /* IdCompressor should be defined if enabled */);
2091
- idRange = this.idCompressor.takeNextCreationRange();
2092
- // Don't include the idRange if there weren't any Ids allocated
2093
- idRange = idRange?.ids !== undefined ? idRange : undefined;
2094
- }
2095
- if (idRange !== undefined) {
2227
+ submitIdAllocationOpIfNeeded() {
2228
+ if (this._idCompressor) {
2229
+ const idRange = this._idCompressor.takeNextCreationRange();
2230
+ // Don't include the idRange if there weren't any Ids allocated
2231
+ if (idRange?.ids !== undefined) {
2096
2232
  const idAllocationMessage = {
2097
2233
  type: ContainerMessageType.IdAllocation,
2098
2234
  contents: idRange,
2099
2235
  };
2100
- idAllocationBatchMessage = {
2236
+ const idAllocationBatchMessage = {
2101
2237
  contents: JSON.stringify(idAllocationMessage),
2102
2238
  referenceSequenceNumber: this.deltaManager.lastSequenceNumber,
2103
2239
  metadata: undefined,
2104
2240
  localOpMetadata: undefined,
2105
2241
  type: ContainerMessageType.IdAllocation,
2106
2242
  };
2107
- }
2108
- if (idAllocationBatchMessage !== undefined) {
2109
2243
  this.outbox.submitIdAllocation(idAllocationBatchMessage);
2110
2244
  }
2111
2245
  }
@@ -2133,42 +2267,47 @@ export class ContainerRuntime extends TypedEventEmitter {
2133
2267
  referenceSequenceNumber: this.deltaManager.lastSequenceNumber,
2134
2268
  };
2135
2269
  try {
2136
- // Submit an IdAllocation op if any Ids have been generated since
2137
- // the last op was submitted. Don't submit another if it's an IdAllocation
2138
- // op as that means we're in resubmission flow and we don't want to send
2139
- // IdRanges out of order.
2140
- this.maybeSubmitIdAllocationOp(type);
2141
- // If this is attach message for new data store, and we are in a batch, send this op out of order
2142
- // Is it safe:
2143
- // Yes, this should be safe reordering. Newly created data stores are not visible through API surface.
2144
- // They become visible only when aliased, or handle to some sub-element of newly created datastore
2145
- // is stored in some DDS, i.e. only after some other op.
2146
- // Why:
2147
- // Attach ops are large, and expensive to process. Plus there are scenarios where a lot of new data
2148
- // stores are created, causing issues like relay service throttling (too many ops) and catastrophic
2149
- // failure (batch is too large). Pushing them earlier and outside of main batch should alleviate
2150
- // these issues.
2151
- // Cons:
2152
- // 1. With large batches, relay service may throttle clients. Clients may disconnect while throttled.
2153
- // This change creates new possibility of a lot of newly created data stores never being referenced
2154
- // because client died before it had a change to submit the rest of the ops. This will create more
2155
- // garbage that needs to be collected leveraging GC (Garbage Collection) feature.
2156
- // 2. Sending ops out of order means they are excluded from rollback functionality. This is not an issue
2157
- // today as rollback can't undo creation of data store. To some extent not sending them is a bigger
2158
- // issue than sending.
2159
- // Please note that this does not change file format, so it can be disabled in the future if this
2160
- // optimization no longer makes sense (for example, batch compression may make it less appealing).
2161
- if (this.currentlyBatching() &&
2162
- type === ContainerMessageType.Attach &&
2163
- this.disableAttachReorder !== true) {
2164
- this.outbox.submitAttach(message);
2165
- }
2166
- else if (type === ContainerMessageType.BlobAttach) {
2167
- // BlobAttach ops must have their metadata visible and cannot be grouped (see opGroupingManager.ts)
2168
- this.outbox.submitBlobAttach(message);
2270
+ // If `message` is an allocation op, then we are in the resubmit path and we must redirect the allocation
2271
+ // op into the correct batch to avoid ranges being finalized out of order.
2272
+ // Otherwise, submit an IdAllocation op if any IDs have been generated since the last op was submitted, as
2273
+ // any of the other op types may contain those IDs and thus depend on the allocation op being sent first.
2274
+ if (type === ContainerMessageType.IdAllocation) {
2275
+ this.outbox.submitIdAllocation(message);
2169
2276
  }
2170
2277
  else {
2171
- this.outbox.submit(message);
2278
+ this.submitIdAllocationOpIfNeeded();
2279
+ // If this is attach message for new data store, and we are in a batch, send this op out of order
2280
+ // Is it safe:
2281
+ // Yes, this should be safe reordering. Newly created data stores are not visible through API surface.
2282
+ // They become visible only when aliased, or handle to some sub-element of newly created datastore
2283
+ // is stored in some DDS, i.e. only after some other op.
2284
+ // Why:
2285
+ // Attach ops are large, and expensive to process. Plus there are scenarios where a lot of new data
2286
+ // stores are created, causing issues like relay service throttling (too many ops) and catastrophic
2287
+ // failure (batch is too large). Pushing them earlier and outside of main batch should alleviate
2288
+ // these issues.
2289
+ // Cons:
2290
+ // 1. With large batches, relay service may throttle clients. Clients may disconnect while throttled.
2291
+ // This change creates new possibility of a lot of newly created data stores never being referenced
2292
+ // because client died before it had a change to submit the rest of the ops. This will create more
2293
+ // garbage that needs to be collected leveraging GC (Garbage Collection) feature.
2294
+ // 2. Sending ops out of order means they are excluded from rollback functionality. This is not an issue
2295
+ // today as rollback can't undo creation of data store. To some extent not sending them is a bigger
2296
+ // issue than sending.
2297
+ // Please note that this does not change file format, so it can be disabled in the future if this
2298
+ // optimization no longer makes sense (for example, batch compression may make it less appealing).
2299
+ if (this.currentlyBatching() &&
2300
+ type === ContainerMessageType.Attach &&
2301
+ this.disableAttachReorder !== true) {
2302
+ this.outbox.submitAttach(message);
2303
+ }
2304
+ else if (type === ContainerMessageType.BlobAttach) {
2305
+ // BlobAttach ops must have their metadata visible and cannot be grouped (see opGroupingManager.ts)
2306
+ this.outbox.submitBlobAttach(message);
2307
+ }
2308
+ else {
2309
+ this.outbox.submit(message);
2310
+ }
2172
2311
  }
2173
2312
  if (!this.currentlyBatching()) {
2174
2313
  this.flush();
@@ -2284,14 +2423,15 @@ export class ContainerRuntime extends TypedEventEmitter {
2284
2423
  * @param localOpMetadata - The local metadata associated with the original message.
2285
2424
  */
2286
2425
  reSubmitCore(message, localOpMetadata, opMetadata) {
2426
+ assert(!this.isSummarizerClient, 0x8f2 /* Summarizer never reconnects so should never resubmit */);
2287
2427
  switch (message.type) {
2288
2428
  case ContainerMessageType.FluidDataStoreOp:
2429
+ case ContainerMessageType.Attach:
2430
+ case ContainerMessageType.Alias:
2289
2431
  // For Operations, call resubmitDataStoreOp which will find the right store
2290
2432
  // and trigger resubmission on it.
2291
- this.dataStores.resubmitDataStoreOp(message.contents, localOpMetadata);
2433
+ this.channelCollection.reSubmit(message.type, message.contents, localOpMetadata);
2292
2434
  break;
2293
- case ContainerMessageType.Attach:
2294
- case ContainerMessageType.Alias:
2295
2435
  case ContainerMessageType.IdAllocation: {
2296
2436
  this.submit(message, localOpMetadata);
2297
2437
  break;
@@ -2305,13 +2445,14 @@ export class ContainerRuntime extends TypedEventEmitter {
2305
2445
  this.submit(message);
2306
2446
  break;
2307
2447
  case ContainerMessageType.GC:
2308
- // GC op is only sent in summarizer which should never reconnect.
2309
- throw new LoggingError("GC op not expected to be resubmitted in summarizer");
2448
+ this.submit(message);
2449
+ break;
2310
2450
  default: {
2311
2451
  // This case should be very rare - it would imply an op was stashed from a
2312
- // future version of runtime code and now is being applied on an older version
2452
+ // future version of runtime code and now is being applied on an older version.
2313
2453
  const compatBehavior = message.compatDetails?.behavior;
2314
2454
  if (compatBehaviorAllowsMessageType(message.type, compatBehavior)) {
2455
+ // We do not ultimately resubmit it, to be consistent with this version of the code.
2315
2456
  this.logger.sendTelemetryEvent({
2316
2457
  eventName: "resubmitUnrecognizedMessageTypeAllowed",
2317
2458
  messageDetails: { type: message.type, compatBehavior },
@@ -2337,7 +2478,7 @@ export class ContainerRuntime extends TypedEventEmitter {
2337
2478
  case ContainerMessageType.FluidDataStoreOp:
2338
2479
  // For operations, call rollbackDataStoreOp which will find the right store
2339
2480
  // and trigger rollback on it.
2340
- this.dataStores.rollbackDataStoreOp(contents, localOpMetadata);
2481
+ this.channelCollection.rollback(type, contents, localOpMetadata);
2341
2482
  break;
2342
2483
  default:
2343
2484
  // Don't check message.compatDetails because this is for rolling back a local op so the type will be known
@@ -2358,31 +2499,12 @@ export class ContainerRuntime extends TypedEventEmitter {
2358
2499
  * and then close as the current main client is likely to be re-elected as the parent summarizer again.
2359
2500
  */
2360
2501
  if (!result.isSummaryTracked && result.isSummaryNewer) {
2361
- const fetchResult = await this.fetchLatestSnapshotFromStorage(summaryLogger, {
2502
+ await this.fetchLatestSnapshotFromStorage(summaryLogger, {
2362
2503
  eventName: "RefreshLatestSummaryAckFetch",
2363
2504
  ackHandle,
2364
2505
  targetSequenceNumber: summaryRefSeq,
2365
2506
  }, readAndParseBlob);
2366
- /**
2367
- * If the fetched snapshot is older than the one for which the ack was received, close the container.
2368
- * This should never happen because an ack should be sent after the latest summary is updated in the server.
2369
- * However, there are couple of scenarios where it's possible:
2370
- * 1. A file was modified externally resulting in modifying the snapshot's sequence number. This can lead to
2371
- * the document being unusable and we should not proceed.
2372
- * 2. The server DB failed after the ack was sent which may delete the corresponding snapshot. Ideally, in
2373
- * such cases, the file will be rolled back along with the ack and we will eventually reach a consistent
2374
- * state.
2375
- */
2376
- if (fetchResult.latestSnapshotRefSeq < summaryRefSeq) {
2377
- const error = DataProcessingError.create("Fetched snapshot is older than the received ack", "RefreshLatestSummaryAck", undefined /* sequencedMessage */, {
2378
- ackHandle,
2379
- summaryRefSeq,
2380
- fetchedSnapshotRefSeq: fetchResult.latestSnapshotRefSeq,
2381
- });
2382
- this.disposeFn(error);
2383
- throw error;
2384
- }
2385
- await this.closeStaleSummarizer("RefreshLatestSummaryAckFetch");
2507
+ await this.closeStaleSummarizer();
2386
2508
  return;
2387
2509
  }
2388
2510
  // Notify the garbage collector so it can update its latest summary state.
@@ -2401,7 +2523,7 @@ export class ContainerRuntime extends TypedEventEmitter {
2401
2523
  await this.fetchLatestSnapshotFromStorage(summaryLogger, {
2402
2524
  eventName: "RefreshLatestSummaryFromServerFetch",
2403
2525
  }, readAndParseBlob);
2404
- await this.closeStaleSummarizer("RefreshLatestSummaryFromServerFetch");
2526
+ await this.closeStaleSummarizer();
2405
2527
  return {
2406
2528
  stage: "base",
2407
2529
  error: "summary state stale - Unsupported option 'refreshLatestAck'",
@@ -2409,7 +2531,7 @@ export class ContainerRuntime extends TypedEventEmitter {
2409
2531
  minimumSequenceNumber: this.deltaManager.minimumSequenceNumber,
2410
2532
  };
2411
2533
  }
2412
- async closeStaleSummarizer(codePath) {
2534
+ async closeStaleSummarizer() {
2413
2535
  // Delay before restarting summarizer to prevent the summarizer from restarting too frequently.
2414
2536
  await delay(this.closeSummarizerDelayMs);
2415
2537
  this._summarizer?.stop("latestSummaryStateStale");
@@ -2441,44 +2563,43 @@ export class ContainerRuntime extends TypedEventEmitter {
2441
2563
  };
2442
2564
  });
2443
2565
  }
2444
- async getPendingLocalState(props) {
2445
- return PerformanceEvent.timedExecAsync(this.mc.logger, {
2446
- eventName: "getPendingLocalState",
2447
- notifyImminentClosure: props?.notifyImminentClosure,
2448
- }, async (event) => {
2449
- this.verifyNotClosed();
2450
- // in case imminentClosure is set to true by future code, we don't
2451
- // try to change its value
2452
- if (!this.imminentClosure) {
2453
- this.imminentClosure = props?.notifyImminentClosure ?? this.imminentClosure;
2454
- }
2455
- const stopBlobAttachingSignal = props?.stopBlobAttachingSignal;
2456
- if (this._orderSequentiallyCalls !== 0) {
2457
- throw new UsageError("can't get state during orderSequentially");
2458
- }
2459
- // Flush pending batch.
2460
- // getPendingLocalState() is only exposed through Container.closeAndGetPendingLocalState(), so it's safe
2461
- // to close current batch.
2462
- this.flush();
2463
- const pendingAttachmentBlobs = this.imminentClosure
2464
- ? await this.blobManager.attachAndGetPendingBlobs(stopBlobAttachingSignal)
2465
- : undefined;
2566
+ getPendingLocalState(props) {
2567
+ this.verifyNotClosed();
2568
+ if (this._orderSequentiallyCalls !== 0) {
2569
+ throw new UsageError("can't get state during orderSequentially");
2570
+ }
2571
+ this.imminentClosure || (this.imminentClosure = props?.notifyImminentClosure ?? false);
2572
+ const getSyncState = (pendingAttachmentBlobs) => {
2466
2573
  const pending = this.pendingStateManager.getLocalState();
2467
- if (!pendingAttachmentBlobs && !this.hasPendingMessages()) {
2574
+ if (pendingAttachmentBlobs === undefined && !this.hasPendingMessages()) {
2468
2575
  return; // no pending state to save
2469
2576
  }
2470
- const pendingIdCompressorState = this.idCompressor?.serialize(true);
2471
- const pendingState = {
2577
+ const pendingIdCompressorState = this._idCompressor?.serialize(true);
2578
+ return {
2472
2579
  pending,
2473
- pendingAttachmentBlobs,
2474
2580
  pendingIdCompressorState,
2581
+ pendingAttachmentBlobs,
2582
+ sessionExpiryTimerStarted: this.garbageCollector.sessionExpiryTimerStarted,
2475
2583
  };
2584
+ };
2585
+ const perfEvent = {
2586
+ eventName: "getPendingLocalState",
2587
+ notifyImminentClosure: props?.notifyImminentClosure,
2588
+ };
2589
+ const logAndReturnPendingState = (event, pendingState) => {
2476
2590
  event.end({
2477
- attachmentBlobsSize: Object.keys(pendingAttachmentBlobs ?? {}).length,
2478
- pendingOpsSize: pending?.pendingStates.length,
2591
+ attachmentBlobsSize: Object.keys(pendingState?.pendingAttachmentBlobs ?? {}).length,
2592
+ pendingOpsSize: pendingState?.pending?.pendingStates.length,
2479
2593
  });
2480
2594
  return pendingState;
2481
- });
2595
+ };
2596
+ // Flush pending batch.
2597
+ // getPendingLocalState() is only exposed through Container.closeAndGetPendingLocalState(), so it's safe
2598
+ // to close current batch.
2599
+ this.flush();
2600
+ return props?.notifyImminentClosure === true
2601
+ ? PerformanceEvent.timedExecAsync(this.mc.logger, perfEvent, async (event) => logAndReturnPendingState(event, getSyncState(await this.blobManager.attachAndGetPendingBlobs(props?.stopBlobAttachingSignal))))
2602
+ : PerformanceEvent.timedExec(this.mc.logger, perfEvent, (event) => logAndReturnPendingState(event, getSyncState()));
2482
2603
  }
2483
2604
  summarizeOnDemand(options) {
2484
2605
  if (this.isSummarizerClient) {
@@ -2532,4 +2653,4 @@ export class ContainerRuntime extends TypedEventEmitter {
2532
2653
  return killSwitch !== true && this.runtimeOptions.enableGroupedBatching;
2533
2654
  }
2534
2655
  }
2535
- //# sourceMappingURL=containerRuntime.mjs.map
2656
+ //# sourceMappingURL=containerRuntime.js.map