@fluidframework/container-runtime 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277

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 (705) hide show
  1. package/.eslintrc.js +19 -29
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +427 -0
  4. package/README.md +69 -0
  5. package/api-extractor-esm.json +4 -0
  6. package/api-extractor-lint.json +4 -0
  7. package/api-extractor.json +2 -2
  8. package/api-report/container-runtime.api.md +863 -0
  9. package/dist/{batchTracker.js → batchTracker.cjs} +9 -8
  10. package/dist/batchTracker.cjs.map +1 -0
  11. package/dist/batchTracker.d.ts +6 -5
  12. package/dist/batchTracker.d.ts.map +1 -1
  13. package/dist/blobManager.cjs +709 -0
  14. package/dist/blobManager.cjs.map +1 -0
  15. package/dist/blobManager.d.ts +140 -39
  16. package/dist/blobManager.d.ts.map +1 -1
  17. package/dist/connectionTelemetry.cjs +230 -0
  18. package/dist/connectionTelemetry.cjs.map +1 -0
  19. package/dist/connectionTelemetry.d.ts +2 -2
  20. package/dist/connectionTelemetry.d.ts.map +1 -1
  21. package/dist/container-runtime-alpha.d.ts +1690 -0
  22. package/dist/container-runtime-beta.d.ts +250 -0
  23. package/dist/container-runtime-public.d.ts +250 -0
  24. package/dist/container-runtime-untrimmed.d.ts +1805 -0
  25. package/dist/{containerHandleContext.js → containerHandleContext.cjs} +4 -2
  26. package/dist/containerHandleContext.cjs.map +1 -0
  27. package/dist/containerHandleContext.d.ts.map +1 -1
  28. package/dist/containerRuntime.cjs +2535 -0
  29. package/dist/containerRuntime.cjs.map +1 -0
  30. package/dist/containerRuntime.d.ts +458 -256
  31. package/dist/containerRuntime.d.ts.map +1 -1
  32. package/dist/{dataStore.js → dataStore.cjs} +54 -45
  33. package/dist/dataStore.cjs.map +1 -0
  34. package/dist/dataStore.d.ts +2 -2
  35. package/dist/dataStore.d.ts.map +1 -1
  36. package/dist/{dataStoreContext.js → dataStoreContext.cjs} +343 -247
  37. package/dist/dataStoreContext.cjs.map +1 -0
  38. package/dist/dataStoreContext.d.ts +73 -41
  39. package/dist/dataStoreContext.d.ts.map +1 -1
  40. package/dist/{dataStoreContexts.js → dataStoreContexts.cjs} +19 -15
  41. package/dist/dataStoreContexts.cjs.map +1 -0
  42. package/dist/dataStoreContexts.d.ts +1 -1
  43. package/dist/dataStoreContexts.d.ts.map +1 -1
  44. package/dist/{dataStoreRegistry.js → dataStoreRegistry.cjs} +9 -4
  45. package/dist/dataStoreRegistry.cjs.map +1 -0
  46. package/dist/dataStoreRegistry.d.ts +3 -0
  47. package/dist/dataStoreRegistry.d.ts.map +1 -1
  48. package/dist/{dataStores.js → dataStores.cjs} +276 -124
  49. package/dist/dataStores.cjs.map +1 -0
  50. package/dist/dataStores.d.ts +56 -23
  51. package/dist/dataStores.d.ts.map +1 -1
  52. package/dist/deltaManagerProxyBase.cjs +77 -0
  53. package/dist/deltaManagerProxyBase.cjs.map +1 -0
  54. package/dist/deltaManagerProxyBase.d.ts +35 -0
  55. package/dist/deltaManagerProxyBase.d.ts.map +1 -0
  56. package/dist/deltaManagerSummarizerProxy.cjs +42 -0
  57. package/dist/deltaManagerSummarizerProxy.cjs.map +1 -0
  58. package/dist/deltaManagerSummarizerProxy.d.ts +19 -0
  59. package/dist/deltaManagerSummarizerProxy.d.ts.map +1 -0
  60. package/dist/{deltaScheduler.js → deltaScheduler.cjs} +25 -18
  61. package/dist/deltaScheduler.cjs.map +1 -0
  62. package/dist/deltaScheduler.d.ts +8 -6
  63. package/dist/deltaScheduler.d.ts.map +1 -1
  64. package/dist/error.cjs +21 -0
  65. package/dist/error.cjs.map +1 -0
  66. package/dist/error.d.ts +14 -0
  67. package/dist/error.d.ts.map +1 -0
  68. package/dist/gc/garbageCollection.cjs +865 -0
  69. package/dist/gc/garbageCollection.cjs.map +1 -0
  70. package/dist/gc/garbageCollection.d.ts +224 -0
  71. package/dist/gc/garbageCollection.d.ts.map +1 -0
  72. package/dist/gc/gcConfigs.cjs +160 -0
  73. package/dist/gc/gcConfigs.cjs.map +1 -0
  74. package/dist/gc/gcConfigs.d.ts +23 -0
  75. package/dist/gc/gcConfigs.d.ts.map +1 -0
  76. package/dist/gc/gcDefinitions.cjs +96 -0
  77. package/dist/gc/gcDefinitions.cjs.map +1 -0
  78. package/dist/gc/gcDefinitions.d.ts +458 -0
  79. package/dist/gc/gcDefinitions.d.ts.map +1 -0
  80. package/dist/gc/gcHelpers.cjs +235 -0
  81. package/dist/gc/gcHelpers.cjs.map +1 -0
  82. package/dist/gc/gcHelpers.d.ts +71 -0
  83. package/dist/gc/gcHelpers.d.ts.map +1 -0
  84. package/dist/gc/gcReferenceGraphAlgorithm.cjs +49 -0
  85. package/dist/gc/gcReferenceGraphAlgorithm.cjs.map +1 -0
  86. package/dist/gc/gcReferenceGraphAlgorithm.d.ts +16 -0
  87. package/dist/gc/gcReferenceGraphAlgorithm.d.ts.map +1 -0
  88. package/dist/{summarizerTypes.js → gc/gcSummaryDefinitions.cjs} +1 -6
  89. package/dist/gc/gcSummaryDefinitions.cjs.map +1 -0
  90. package/dist/gc/gcSummaryDefinitions.d.ts +52 -0
  91. package/dist/gc/gcSummaryDefinitions.d.ts.map +1 -0
  92. package/dist/gc/gcSummaryStateTracker.cjs +213 -0
  93. package/dist/gc/gcSummaryStateTracker.cjs.map +1 -0
  94. package/dist/gc/gcSummaryStateTracker.d.ts +94 -0
  95. package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -0
  96. package/dist/gc/gcTelemetry.cjs +307 -0
  97. package/dist/gc/gcTelemetry.cjs.map +1 -0
  98. package/dist/gc/gcTelemetry.d.ts +99 -0
  99. package/dist/gc/gcTelemetry.d.ts.map +1 -0
  100. package/dist/gc/gcUnreferencedStateTracker.cjs +118 -0
  101. package/dist/gc/gcUnreferencedStateTracker.cjs.map +1 -0
  102. package/dist/gc/gcUnreferencedStateTracker.d.ts +40 -0
  103. package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
  104. package/dist/gc/index.cjs +44 -0
  105. package/dist/gc/index.cjs.map +1 -0
  106. package/dist/gc/index.d.ts +13 -0
  107. package/dist/gc/index.d.ts.map +1 -0
  108. package/dist/index.cjs +47 -0
  109. package/dist/index.cjs.map +1 -0
  110. package/dist/index.d.ts +19 -8
  111. package/dist/index.d.ts.map +1 -1
  112. package/dist/messageTypes.cjs +37 -0
  113. package/dist/messageTypes.cjs.map +1 -0
  114. package/dist/messageTypes.d.ts +142 -0
  115. package/dist/messageTypes.d.ts.map +1 -0
  116. package/dist/metadata.cjs +7 -0
  117. package/dist/metadata.cjs.map +1 -0
  118. package/dist/metadata.d.ts +24 -0
  119. package/dist/metadata.d.ts.map +1 -0
  120. package/dist/opLifecycle/batchManager.cjs +139 -0
  121. package/dist/opLifecycle/batchManager.cjs.map +1 -0
  122. package/dist/opLifecycle/batchManager.d.ts +48 -0
  123. package/dist/opLifecycle/batchManager.d.ts.map +1 -0
  124. package/dist/opLifecycle/definitions.cjs +7 -0
  125. package/dist/opLifecycle/definitions.cjs.map +1 -0
  126. package/dist/opLifecycle/definitions.d.ts +83 -0
  127. package/dist/opLifecycle/definitions.d.ts.map +1 -0
  128. package/dist/opLifecycle/index.cjs +26 -0
  129. package/dist/opLifecycle/index.cjs.map +1 -0
  130. package/dist/opLifecycle/index.d.ts +13 -0
  131. package/dist/opLifecycle/index.d.ts.map +1 -0
  132. package/dist/opLifecycle/opCompressor.cjs +84 -0
  133. package/dist/opLifecycle/opCompressor.cjs.map +1 -0
  134. package/dist/opLifecycle/opCompressor.d.ts +18 -0
  135. package/dist/opLifecycle/opCompressor.d.ts.map +1 -0
  136. package/dist/opLifecycle/opDecompressor.cjs +132 -0
  137. package/dist/opLifecycle/opDecompressor.cjs.map +1 -0
  138. package/dist/opLifecycle/opDecompressor.d.ts +25 -0
  139. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -0
  140. package/dist/opLifecycle/opGroupingManager.cjs +95 -0
  141. package/dist/opLifecycle/opGroupingManager.cjs.map +1 -0
  142. package/dist/opLifecycle/opGroupingManager.d.ts +22 -0
  143. package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -0
  144. package/dist/opLifecycle/opSplitter.cjs +202 -0
  145. package/dist/opLifecycle/opSplitter.cjs.map +1 -0
  146. package/dist/opLifecycle/opSplitter.d.ts +61 -0
  147. package/dist/opLifecycle/opSplitter.d.ts.map +1 -0
  148. package/dist/opLifecycle/outbox.cjs +326 -0
  149. package/dist/opLifecycle/outbox.cjs.map +1 -0
  150. package/dist/opLifecycle/outbox.d.ts +104 -0
  151. package/dist/opLifecycle/outbox.d.ts.map +1 -0
  152. package/dist/opLifecycle/remoteMessageProcessor.cjs +136 -0
  153. package/dist/opLifecycle/remoteMessageProcessor.cjs.map +1 -0
  154. package/dist/opLifecycle/remoteMessageProcessor.d.ts +47 -0
  155. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -0
  156. package/dist/opProperties.cjs +17 -0
  157. package/dist/opProperties.cjs.map +1 -0
  158. package/dist/opProperties.d.ts +7 -0
  159. package/dist/opProperties.d.ts.map +1 -0
  160. package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
  161. package/dist/packageVersion.cjs.map +1 -0
  162. package/dist/packageVersion.d.ts +1 -1
  163. package/dist/packageVersion.d.ts.map +1 -1
  164. package/dist/pendingStateManager.cjs +282 -0
  165. package/dist/pendingStateManager.cjs.map +1 -0
  166. package/dist/pendingStateManager.d.ts +32 -69
  167. package/dist/pendingStateManager.d.ts.map +1 -1
  168. package/dist/scheduleManager.cjs +258 -0
  169. package/dist/scheduleManager.cjs.map +1 -0
  170. package/dist/scheduleManager.d.ts +31 -0
  171. package/dist/scheduleManager.d.ts.map +1 -0
  172. package/dist/storageServiceWithAttachBlobs.cjs +32 -0
  173. package/dist/storageServiceWithAttachBlobs.cjs.map +1 -0
  174. package/dist/storageServiceWithAttachBlobs.d.ts +17 -0
  175. package/dist/storageServiceWithAttachBlobs.d.ts.map +1 -0
  176. package/dist/summary/index.cjs +51 -0
  177. package/dist/summary/index.cjs.map +1 -0
  178. package/dist/summary/index.d.ts +17 -0
  179. package/dist/summary/index.d.ts.map +1 -0
  180. package/dist/{orderedClientElection.js → summary/orderedClientElection.cjs} +100 -84
  181. package/dist/summary/orderedClientElection.cjs.map +1 -0
  182. package/{lib → dist/summary}/orderedClientElection.d.ts +41 -18
  183. package/dist/summary/orderedClientElection.d.ts.map +1 -0
  184. package/dist/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.cjs} +12 -10
  185. package/dist/summary/runWhileConnectedCoordinator.cjs.map +1 -0
  186. package/{lib → dist/summary}/runWhileConnectedCoordinator.d.ts +8 -2
  187. package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
  188. package/dist/summary/runningSummarizer.cjs +679 -0
  189. package/dist/summary/runningSummarizer.cjs.map +1 -0
  190. package/dist/summary/runningSummarizer.d.ts +128 -0
  191. package/dist/summary/runningSummarizer.d.ts.map +1 -0
  192. package/dist/summary/summarizer.cjs +263 -0
  193. package/dist/summary/summarizer.cjs.map +1 -0
  194. package/dist/{summarizer.d.ts → summary/summarizer.d.ts} +18 -33
  195. package/dist/summary/summarizer.d.ts.map +1 -0
  196. package/dist/{summarizerClientElection.js → summary/summarizerClientElection.cjs} +15 -46
  197. package/dist/summary/summarizerClientElection.cjs.map +1 -0
  198. package/{lib → dist/summary}/summarizerClientElection.d.ts +4 -4
  199. package/dist/summary/summarizerClientElection.d.ts.map +1 -0
  200. package/dist/summary/summarizerHeuristics.cjs +156 -0
  201. package/dist/summary/summarizerHeuristics.cjs.map +1 -0
  202. package/{lib → dist/summary}/summarizerHeuristics.d.ts +28 -6
  203. package/dist/summary/summarizerHeuristics.d.ts.map +1 -0
  204. package/dist/summary/summarizerNode/index.cjs +12 -0
  205. package/dist/summary/summarizerNode/index.cjs.map +1 -0
  206. package/dist/summary/summarizerNode/index.d.ts +8 -0
  207. package/dist/summary/summarizerNode/index.d.ts.map +1 -0
  208. package/dist/summary/summarizerNode/summarizerNode.cjs +526 -0
  209. package/dist/summary/summarizerNode/summarizerNode.cjs.map +1 -0
  210. package/dist/summary/summarizerNode/summarizerNode.d.ts +167 -0
  211. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -0
  212. package/dist/summary/summarizerNode/summarizerNodeUtils.cjs +130 -0
  213. package/dist/summary/summarizerNode/summarizerNodeUtils.cjs.map +1 -0
  214. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +121 -0
  215. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -0
  216. package/dist/summary/summarizerNode/summarizerNodeWithGc.cjs +375 -0
  217. package/dist/summary/summarizerNode/summarizerNodeWithGc.cjs.map +1 -0
  218. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +153 -0
  219. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -0
  220. package/dist/summary/summarizerTypes.cjs +7 -0
  221. package/dist/summary/summarizerTypes.cjs.map +1 -0
  222. package/{lib → dist/summary}/summarizerTypes.d.ts +233 -83
  223. package/dist/summary/summarizerTypes.d.ts.map +1 -0
  224. package/dist/{summaryCollection.js → summary/summaryCollection.cjs} +80 -49
  225. package/dist/summary/summaryCollection.cjs.map +1 -0
  226. package/dist/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +23 -5
  227. package/dist/summary/summaryCollection.d.ts.map +1 -0
  228. package/dist/{summaryFormat.js → summary/summaryFormat.cjs} +29 -26
  229. package/dist/summary/summaryFormat.cjs.map +1 -0
  230. package/{lib → dist/summary}/summaryFormat.d.ts +25 -30
  231. package/dist/summary/summaryFormat.d.ts.map +1 -0
  232. package/dist/{summaryGenerator.js → summary/summaryGenerator.cjs} +162 -74
  233. package/dist/summary/summaryGenerator.cjs.map +1 -0
  234. package/dist/{summaryGenerator.d.ts → summary/summaryGenerator.d.ts} +53 -11
  235. package/dist/summary/summaryGenerator.d.ts.map +1 -0
  236. package/dist/{summaryManager.js → summary/summaryManager.cjs} +98 -55
  237. package/dist/summary/summaryManager.cjs.map +1 -0
  238. package/{lib → dist/summary}/summaryManager.d.ts +13 -11
  239. package/dist/summary/summaryManager.d.ts.map +1 -0
  240. package/dist/{throttler.js → throttler.cjs} +21 -21
  241. package/dist/throttler.cjs.map +1 -0
  242. package/dist/throttler.d.ts +2 -2
  243. package/dist/throttler.d.ts.map +1 -1
  244. package/dist/tsdoc-metadata.json +11 -0
  245. package/lib/{batchTracker.d.ts → batchTracker.d.mts} +7 -6
  246. package/lib/batchTracker.d.mts.map +1 -0
  247. package/lib/{batchTracker.js → batchTracker.mjs} +9 -8
  248. package/lib/batchTracker.mjs.map +1 -0
  249. package/lib/blobManager.d.mts +196 -0
  250. package/lib/blobManager.d.mts.map +1 -0
  251. package/lib/blobManager.mjs +704 -0
  252. package/lib/blobManager.mjs.map +1 -0
  253. package/lib/{connectionTelemetry.d.ts → connectionTelemetry.d.mts} +3 -3
  254. package/lib/connectionTelemetry.d.mts.map +1 -0
  255. package/lib/connectionTelemetry.mjs +226 -0
  256. package/lib/connectionTelemetry.mjs.map +1 -0
  257. package/lib/container-runtime-alpha.d.mts +1690 -0
  258. package/lib/container-runtime-beta.d.mts +250 -0
  259. package/lib/container-runtime-public.d.mts +250 -0
  260. package/lib/container-runtime-untrimmed.d.mts +1805 -0
  261. package/lib/{containerHandleContext.d.ts → containerHandleContext.d.mts} +2 -2
  262. package/lib/containerHandleContext.d.mts.map +1 -0
  263. package/lib/{containerHandleContext.js → containerHandleContext.mjs} +4 -2
  264. package/lib/containerHandleContext.mjs.map +1 -0
  265. package/lib/containerRuntime.d.mts +813 -0
  266. package/lib/containerRuntime.d.mts.map +1 -0
  267. package/lib/containerRuntime.mjs +2530 -0
  268. package/lib/containerRuntime.mjs.map +1 -0
  269. package/lib/{dataStore.d.ts → dataStore.d.mts} +5 -5
  270. package/lib/dataStore.d.mts.map +1 -0
  271. package/lib/{dataStore.js → dataStore.mjs} +52 -43
  272. package/lib/dataStore.mjs.map +1 -0
  273. package/lib/{dataStoreContext.d.ts → dataStoreContext.d.mts} +75 -43
  274. package/lib/dataStoreContext.d.mts.map +1 -0
  275. package/lib/{dataStoreContext.js → dataStoreContext.mjs} +309 -213
  276. package/lib/dataStoreContext.mjs.map +1 -0
  277. package/lib/{dataStoreContexts.d.ts → dataStoreContexts.d.mts} +3 -3
  278. package/lib/dataStoreContexts.d.mts.map +1 -0
  279. package/lib/{dataStoreContexts.js → dataStoreContexts.mjs} +12 -8
  280. package/lib/dataStoreContexts.mjs.map +1 -0
  281. package/lib/{dataStoreRegistry.d.ts → dataStoreRegistry.d.mts} +4 -1
  282. package/lib/dataStoreRegistry.d.mts.map +1 -0
  283. package/lib/{dataStoreRegistry.js → dataStoreRegistry.mjs} +7 -6
  284. package/lib/dataStoreRegistry.mjs.map +1 -0
  285. package/lib/{dataStores.d.ts → dataStores.d.mts} +60 -27
  286. package/lib/dataStores.d.mts.map +1 -0
  287. package/lib/{dataStores.js → dataStores.mjs} +257 -105
  288. package/lib/dataStores.mjs.map +1 -0
  289. package/lib/deltaManagerProxyBase.d.mts +35 -0
  290. package/lib/deltaManagerProxyBase.d.mts.map +1 -0
  291. package/lib/deltaManagerProxyBase.mjs +73 -0
  292. package/lib/deltaManagerProxyBase.mjs.map +1 -0
  293. package/lib/deltaManagerSummarizerProxy.d.mts +19 -0
  294. package/lib/deltaManagerSummarizerProxy.d.mts.map +1 -0
  295. package/lib/deltaManagerSummarizerProxy.mjs +38 -0
  296. package/lib/deltaManagerSummarizerProxy.mjs.map +1 -0
  297. package/lib/{deltaScheduler.d.ts → deltaScheduler.d.mts} +9 -7
  298. package/lib/deltaScheduler.d.mts.map +1 -0
  299. package/lib/{deltaScheduler.js → deltaScheduler.mjs} +22 -15
  300. package/lib/deltaScheduler.mjs.map +1 -0
  301. package/lib/error.d.mts +14 -0
  302. package/lib/error.d.mts.map +1 -0
  303. package/lib/error.mjs +17 -0
  304. package/lib/error.mjs.map +1 -0
  305. package/lib/gc/garbageCollection.d.mts +224 -0
  306. package/lib/gc/garbageCollection.d.mts.map +1 -0
  307. package/lib/gc/garbageCollection.mjs +861 -0
  308. package/lib/gc/garbageCollection.mjs.map +1 -0
  309. package/lib/gc/gcConfigs.d.mts +23 -0
  310. package/lib/gc/gcConfigs.d.mts.map +1 -0
  311. package/lib/gc/gcConfigs.mjs +156 -0
  312. package/lib/gc/gcConfigs.mjs.map +1 -0
  313. package/lib/gc/gcDefinitions.d.mts +458 -0
  314. package/lib/gc/gcDefinitions.d.mts.map +1 -0
  315. package/lib/gc/gcDefinitions.mjs +93 -0
  316. package/lib/gc/gcDefinitions.mjs.map +1 -0
  317. package/lib/gc/gcHelpers.d.mts +71 -0
  318. package/lib/gc/gcHelpers.d.mts.map +1 -0
  319. package/lib/gc/gcHelpers.mjs +222 -0
  320. package/lib/gc/gcHelpers.mjs.map +1 -0
  321. package/lib/gc/gcReferenceGraphAlgorithm.d.mts +16 -0
  322. package/lib/gc/gcReferenceGraphAlgorithm.d.mts.map +1 -0
  323. package/lib/gc/gcReferenceGraphAlgorithm.mjs +45 -0
  324. package/lib/gc/gcReferenceGraphAlgorithm.mjs.map +1 -0
  325. package/lib/gc/gcSummaryDefinitions.d.mts +52 -0
  326. package/lib/gc/gcSummaryDefinitions.d.mts.map +1 -0
  327. package/lib/gc/gcSummaryDefinitions.mjs +6 -0
  328. package/lib/gc/gcSummaryDefinitions.mjs.map +1 -0
  329. package/lib/gc/gcSummaryStateTracker.d.mts +94 -0
  330. package/lib/gc/gcSummaryStateTracker.d.mts.map +1 -0
  331. package/lib/gc/gcSummaryStateTracker.mjs +209 -0
  332. package/lib/gc/gcSummaryStateTracker.mjs.map +1 -0
  333. package/lib/gc/gcTelemetry.d.mts +99 -0
  334. package/lib/gc/gcTelemetry.d.mts.map +1 -0
  335. package/lib/gc/gcTelemetry.mjs +302 -0
  336. package/lib/gc/gcTelemetry.mjs.map +1 -0
  337. package/lib/gc/gcUnreferencedStateTracker.d.mts +40 -0
  338. package/lib/gc/gcUnreferencedStateTracker.d.mts.map +1 -0
  339. package/lib/gc/gcUnreferencedStateTracker.mjs +114 -0
  340. package/lib/gc/gcUnreferencedStateTracker.mjs.map +1 -0
  341. package/lib/gc/index.d.mts +13 -0
  342. package/lib/gc/index.d.mts.map +1 -0
  343. package/lib/gc/index.mjs +12 -0
  344. package/lib/gc/index.mjs.map +1 -0
  345. package/lib/index.d.mts +25 -0
  346. package/lib/index.d.mts.map +1 -0
  347. package/lib/index.mjs +24 -0
  348. package/lib/index.mjs.map +1 -0
  349. package/lib/messageTypes.d.mts +142 -0
  350. package/lib/messageTypes.d.mts.map +1 -0
  351. package/lib/messageTypes.mjs +34 -0
  352. package/lib/messageTypes.mjs.map +1 -0
  353. package/lib/metadata.d.mts +24 -0
  354. package/lib/metadata.d.mts.map +1 -0
  355. package/lib/metadata.mjs +6 -0
  356. package/lib/metadata.mjs.map +1 -0
  357. package/lib/opLifecycle/batchManager.d.mts +48 -0
  358. package/lib/opLifecycle/batchManager.d.mts.map +1 -0
  359. package/lib/opLifecycle/batchManager.mjs +133 -0
  360. package/lib/opLifecycle/batchManager.mjs.map +1 -0
  361. package/lib/opLifecycle/definitions.d.mts +83 -0
  362. package/lib/opLifecycle/definitions.d.mts.map +1 -0
  363. package/lib/opLifecycle/definitions.mjs +6 -0
  364. package/lib/opLifecycle/definitions.mjs.map +1 -0
  365. package/lib/opLifecycle/index.d.mts +13 -0
  366. package/lib/opLifecycle/index.d.mts.map +1 -0
  367. package/lib/opLifecycle/index.mjs +12 -0
  368. package/lib/opLifecycle/index.mjs.map +1 -0
  369. package/lib/opLifecycle/opCompressor.d.mts +18 -0
  370. package/lib/opLifecycle/opCompressor.d.mts.map +1 -0
  371. package/lib/opLifecycle/opCompressor.mjs +80 -0
  372. package/lib/opLifecycle/opCompressor.mjs.map +1 -0
  373. package/lib/opLifecycle/opDecompressor.d.mts +25 -0
  374. package/lib/opLifecycle/opDecompressor.d.mts.map +1 -0
  375. package/lib/opLifecycle/opDecompressor.mjs +128 -0
  376. package/lib/opLifecycle/opDecompressor.mjs.map +1 -0
  377. package/lib/opLifecycle/opGroupingManager.d.mts +22 -0
  378. package/lib/opLifecycle/opGroupingManager.d.mts.map +1 -0
  379. package/lib/opLifecycle/opGroupingManager.mjs +91 -0
  380. package/lib/opLifecycle/opGroupingManager.mjs.map +1 -0
  381. package/lib/opLifecycle/opSplitter.d.mts +61 -0
  382. package/lib/opLifecycle/opSplitter.d.mts.map +1 -0
  383. package/lib/opLifecycle/opSplitter.mjs +197 -0
  384. package/lib/opLifecycle/opSplitter.mjs.map +1 -0
  385. package/lib/opLifecycle/outbox.d.mts +104 -0
  386. package/lib/opLifecycle/outbox.d.mts.map +1 -0
  387. package/lib/opLifecycle/outbox.mjs +321 -0
  388. package/lib/opLifecycle/outbox.mjs.map +1 -0
  389. package/lib/opLifecycle/remoteMessageProcessor.d.mts +47 -0
  390. package/lib/opLifecycle/remoteMessageProcessor.d.mts.map +1 -0
  391. package/lib/opLifecycle/remoteMessageProcessor.mjs +131 -0
  392. package/lib/opLifecycle/remoteMessageProcessor.mjs.map +1 -0
  393. package/lib/opProperties.d.mts +7 -0
  394. package/lib/opProperties.d.mts.map +1 -0
  395. package/lib/opProperties.mjs +13 -0
  396. package/lib/opProperties.mjs.map +1 -0
  397. package/lib/{packageVersion.d.ts → packageVersion.d.mts} +2 -2
  398. package/lib/packageVersion.d.mts.map +1 -0
  399. package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
  400. package/lib/packageVersion.mjs.map +1 -0
  401. package/lib/{pendingStateManager.d.ts → pendingStateManager.d.mts} +33 -70
  402. package/lib/pendingStateManager.d.mts.map +1 -0
  403. package/lib/pendingStateManager.mjs +275 -0
  404. package/lib/pendingStateManager.mjs.map +1 -0
  405. package/lib/scheduleManager.d.mts +27 -0
  406. package/lib/scheduleManager.d.mts.map +1 -0
  407. package/lib/scheduleManager.mjs +254 -0
  408. package/lib/scheduleManager.mjs.map +1 -0
  409. package/lib/storageServiceWithAttachBlobs.d.mts +17 -0
  410. package/lib/storageServiceWithAttachBlobs.d.mts.map +1 -0
  411. package/lib/storageServiceWithAttachBlobs.mjs +28 -0
  412. package/lib/storageServiceWithAttachBlobs.mjs.map +1 -0
  413. package/lib/summary/index.d.mts +17 -0
  414. package/lib/summary/index.d.mts.map +1 -0
  415. package/lib/summary/index.mjs +16 -0
  416. package/lib/summary/index.mjs.map +1 -0
  417. package/{dist/orderedClientElection.d.ts → lib/summary/orderedClientElection.d.mts} +42 -23
  418. package/lib/summary/orderedClientElection.d.mts.map +1 -0
  419. package/lib/{orderedClientElection.js → summary/orderedClientElection.mjs} +95 -79
  420. package/lib/summary/orderedClientElection.mjs.map +1 -0
  421. package/{dist/runWhileConnectedCoordinator.d.ts → lib/summary/runWhileConnectedCoordinator.d.mts} +10 -4
  422. package/lib/summary/runWhileConnectedCoordinator.d.mts.map +1 -0
  423. package/lib/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.mjs} +12 -10
  424. package/lib/summary/runWhileConnectedCoordinator.mjs.map +1 -0
  425. package/lib/summary/runningSummarizer.d.mts +128 -0
  426. package/lib/summary/runningSummarizer.d.mts.map +1 -0
  427. package/lib/summary/runningSummarizer.mjs +675 -0
  428. package/lib/summary/runningSummarizer.mjs.map +1 -0
  429. package/lib/{summarizer.d.ts → summary/summarizer.d.mts} +21 -36
  430. package/lib/summary/summarizer.d.mts.map +1 -0
  431. package/lib/summary/summarizer.mjs +257 -0
  432. package/lib/summary/summarizer.mjs.map +1 -0
  433. package/{dist/summarizerClientElection.d.ts → lib/summary/summarizerClientElection.d.mts} +7 -7
  434. package/lib/summary/summarizerClientElection.d.mts.map +1 -0
  435. package/lib/{summarizerClientElection.js → summary/summarizerClientElection.mjs} +14 -45
  436. package/lib/summary/summarizerClientElection.mjs.map +1 -0
  437. package/{dist/summarizerHeuristics.d.ts → lib/summary/summarizerHeuristics.d.mts} +30 -8
  438. package/lib/summary/summarizerHeuristics.d.mts.map +1 -0
  439. package/lib/summary/summarizerHeuristics.mjs +151 -0
  440. package/lib/summary/summarizerHeuristics.mjs.map +1 -0
  441. package/lib/summary/summarizerNode/index.d.mts +8 -0
  442. package/lib/summary/summarizerNode/index.d.mts.map +1 -0
  443. package/lib/summary/summarizerNode/index.mjs +7 -0
  444. package/lib/summary/summarizerNode/index.mjs.map +1 -0
  445. package/lib/summary/summarizerNode/summarizerNode.d.mts +167 -0
  446. package/lib/summary/summarizerNode/summarizerNode.d.mts.map +1 -0
  447. package/lib/summary/summarizerNode/summarizerNode.mjs +521 -0
  448. package/lib/summary/summarizerNode/summarizerNode.mjs.map +1 -0
  449. package/lib/summary/summarizerNode/summarizerNodeUtils.d.mts +121 -0
  450. package/lib/summary/summarizerNode/summarizerNodeUtils.d.mts.map +1 -0
  451. package/lib/summary/summarizerNode/summarizerNodeUtils.mjs +123 -0
  452. package/lib/summary/summarizerNode/summarizerNodeUtils.mjs.map +1 -0
  453. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.mts +153 -0
  454. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.mts.map +1 -0
  455. package/lib/summary/summarizerNode/summarizerNodeWithGc.mjs +370 -0
  456. package/lib/summary/summarizerNode/summarizerNodeWithGc.mjs.map +1 -0
  457. package/{dist/summarizerTypes.d.ts → lib/summary/summarizerTypes.d.mts} +235 -85
  458. package/lib/summary/summarizerTypes.d.mts.map +1 -0
  459. package/lib/summary/summarizerTypes.mjs +6 -0
  460. package/lib/summary/summarizerTypes.mjs.map +1 -0
  461. package/lib/{summaryCollection.d.ts → summary/summaryCollection.d.mts} +24 -6
  462. package/lib/summary/summaryCollection.d.mts.map +1 -0
  463. package/lib/{summaryCollection.js → summary/summaryCollection.mjs} +76 -45
  464. package/lib/summary/summaryCollection.mjs.map +1 -0
  465. package/{dist/summaryFormat.d.ts → lib/summary/summaryFormat.d.mts} +26 -31
  466. package/lib/summary/summaryFormat.d.mts.map +1 -0
  467. package/lib/{summaryFormat.js → summary/summaryFormat.mjs} +30 -26
  468. package/lib/summary/summaryFormat.mjs.map +1 -0
  469. package/lib/summary/summaryGenerator.d.mts +127 -0
  470. package/lib/summary/summaryGenerator.d.mts.map +1 -0
  471. package/lib/{summaryGenerator.js → summary/summaryGenerator.mjs} +153 -67
  472. package/lib/summary/summaryGenerator.mjs.map +1 -0
  473. package/{dist/summaryManager.d.ts → lib/summary/summaryManager.d.mts} +16 -14
  474. package/lib/summary/summaryManager.d.mts.map +1 -0
  475. package/lib/{summaryManager.js → summary/summaryManager.mjs} +94 -51
  476. package/lib/summary/summaryManager.mjs.map +1 -0
  477. package/lib/{throttler.d.ts → throttler.d.mts} +3 -3
  478. package/lib/throttler.d.mts.map +1 -0
  479. package/lib/{throttler.js → throttler.mjs} +21 -21
  480. package/lib/throttler.mjs.map +1 -0
  481. package/package.json +199 -71
  482. package/prettier.config.cjs +8 -0
  483. package/src/batchTracker.ts +59 -54
  484. package/src/blobManager.ts +942 -294
  485. package/src/connectionTelemetry.ts +342 -252
  486. package/src/containerHandleContext.ts +27 -29
  487. package/src/containerRuntime.ts +3883 -3143
  488. package/src/dataStore.ts +170 -140
  489. package/src/dataStoreContext.ts +1166 -986
  490. package/src/dataStoreContexts.ts +176 -163
  491. package/src/dataStoreRegistry.ts +29 -21
  492. package/src/dataStores.ts +924 -678
  493. package/src/deltaManagerProxyBase.ts +111 -0
  494. package/src/deltaManagerSummarizerProxy.ts +49 -0
  495. package/src/deltaScheduler.ts +161 -156
  496. package/src/error.ts +21 -0
  497. package/src/gc/garbageCollection.md +106 -0
  498. package/src/gc/garbageCollection.ts +1157 -0
  499. package/src/gc/gcConfigs.ts +224 -0
  500. package/src/gc/gcDefinitions.ts +524 -0
  501. package/src/gc/gcHelpers.ts +284 -0
  502. package/src/gc/gcReferenceGraphAlgorithm.ts +52 -0
  503. package/src/gc/gcSummaryDefinitions.ts +54 -0
  504. package/src/gc/gcSummaryStateTracker.ts +299 -0
  505. package/src/gc/gcTelemetry.ts +433 -0
  506. package/src/gc/gcUnreferencedStateTracker.ts +153 -0
  507. package/src/gc/index.ts +60 -0
  508. package/src/index.ts +101 -74
  509. package/src/messageTypes.ts +238 -0
  510. package/src/metadata.ts +26 -0
  511. package/src/opLifecycle/README.md +321 -0
  512. package/src/opLifecycle/batchManager.ts +179 -0
  513. package/src/opLifecycle/definitions.ts +89 -0
  514. package/src/opLifecycle/index.ts +19 -0
  515. package/src/opLifecycle/opCompressor.ts +99 -0
  516. package/src/opLifecycle/opDecompressor.ts +190 -0
  517. package/src/opLifecycle/opGroupingManager.ts +133 -0
  518. package/src/opLifecycle/opSplitter.ts +279 -0
  519. package/src/opLifecycle/outbox.ts +474 -0
  520. package/src/opLifecycle/remoteMessageProcessor.ts +175 -0
  521. package/src/opProperties.ts +21 -0
  522. package/src/packageVersion.ts +1 -1
  523. package/src/pendingStateManager.ts +396 -465
  524. package/src/scheduleManager.ts +358 -0
  525. package/src/storageServiceWithAttachBlobs.ts +38 -0
  526. package/src/summary/index.ts +109 -0
  527. package/src/summary/orderedClientElection.ts +571 -0
  528. package/src/summary/runWhileConnectedCoordinator.ts +117 -0
  529. package/src/summary/runningSummarizer.ts +920 -0
  530. package/src/summary/summarizer.ts +352 -0
  531. package/src/summary/summarizerClientElection.ts +140 -0
  532. package/src/summary/summarizerHeuristics.ts +227 -0
  533. package/src/summary/summarizerNode/index.ts +12 -0
  534. package/src/summary/summarizerNode/summarizerNode.ts +725 -0
  535. package/src/summary/summarizerNode/summarizerNodeUtils.ts +206 -0
  536. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +571 -0
  537. package/src/summary/summarizerTypes.ts +631 -0
  538. package/src/summary/summaryCollection.ts +474 -0
  539. package/src/summary/summaryFormat.ts +249 -0
  540. package/src/summary/summaryGenerator.ts +539 -0
  541. package/src/summary/summaryManager.ts +452 -0
  542. package/src/throttler.ts +131 -122
  543. package/tsc-multi.test.json +4 -0
  544. package/tsconfig.json +11 -13
  545. package/dist/batchTracker.js.map +0 -1
  546. package/dist/blobManager.js +0 -249
  547. package/dist/blobManager.js.map +0 -1
  548. package/dist/connectionTelemetry.js +0 -178
  549. package/dist/connectionTelemetry.js.map +0 -1
  550. package/dist/containerHandleContext.js.map +0 -1
  551. package/dist/containerRuntime.js +0 -2174
  552. package/dist/containerRuntime.js.map +0 -1
  553. package/dist/dataStore.js.map +0 -1
  554. package/dist/dataStoreContext.js.map +0 -1
  555. package/dist/dataStoreContexts.js.map +0 -1
  556. package/dist/dataStoreRegistry.js.map +0 -1
  557. package/dist/dataStores.js.map +0 -1
  558. package/dist/deltaScheduler.js.map +0 -1
  559. package/dist/garbageCollection.d.ts +0 -319
  560. package/dist/garbageCollection.d.ts.map +0 -1
  561. package/dist/garbageCollection.js +0 -993
  562. package/dist/garbageCollection.js.map +0 -1
  563. package/dist/index.js +0 -33
  564. package/dist/index.js.map +0 -1
  565. package/dist/opTelemetry.d.ts +0 -22
  566. package/dist/opTelemetry.d.ts.map +0 -1
  567. package/dist/opTelemetry.js +0 -60
  568. package/dist/opTelemetry.js.map +0 -1
  569. package/dist/orderedClientElection.d.ts.map +0 -1
  570. package/dist/orderedClientElection.js.map +0 -1
  571. package/dist/packageVersion.js.map +0 -1
  572. package/dist/pendingStateManager.js +0 -346
  573. package/dist/pendingStateManager.js.map +0 -1
  574. package/dist/runWhileConnectedCoordinator.d.ts.map +0 -1
  575. package/dist/runWhileConnectedCoordinator.js.map +0 -1
  576. package/dist/runningSummarizer.d.ts +0 -93
  577. package/dist/runningSummarizer.d.ts.map +0 -1
  578. package/dist/runningSummarizer.js +0 -384
  579. package/dist/runningSummarizer.js.map +0 -1
  580. package/dist/serializedSnapshotStorage.d.ts +0 -58
  581. package/dist/serializedSnapshotStorage.d.ts.map +0 -1
  582. package/dist/serializedSnapshotStorage.js +0 -108
  583. package/dist/serializedSnapshotStorage.js.map +0 -1
  584. package/dist/summarizer.d.ts.map +0 -1
  585. package/dist/summarizer.js +0 -348
  586. package/dist/summarizer.js.map +0 -1
  587. package/dist/summarizerClientElection.d.ts.map +0 -1
  588. package/dist/summarizerClientElection.js.map +0 -1
  589. package/dist/summarizerHandle.d.ts +0 -12
  590. package/dist/summarizerHandle.d.ts.map +0 -1
  591. package/dist/summarizerHandle.js +0 -22
  592. package/dist/summarizerHandle.js.map +0 -1
  593. package/dist/summarizerHeuristics.d.ts.map +0 -1
  594. package/dist/summarizerHeuristics.js +0 -84
  595. package/dist/summarizerHeuristics.js.map +0 -1
  596. package/dist/summarizerTypes.d.ts.map +0 -1
  597. package/dist/summarizerTypes.js.map +0 -1
  598. package/dist/summaryCollection.d.ts.map +0 -1
  599. package/dist/summaryCollection.js.map +0 -1
  600. package/dist/summaryFormat.d.ts.map +0 -1
  601. package/dist/summaryFormat.js.map +0 -1
  602. package/dist/summaryGenerator.d.ts.map +0 -1
  603. package/dist/summaryGenerator.js.map +0 -1
  604. package/dist/summaryManager.d.ts.map +0 -1
  605. package/dist/summaryManager.js.map +0 -1
  606. package/dist/throttler.js.map +0 -1
  607. package/garbageCollection.md +0 -41
  608. package/lib/batchTracker.d.ts.map +0 -1
  609. package/lib/batchTracker.js.map +0 -1
  610. package/lib/blobManager.d.ts +0 -95
  611. package/lib/blobManager.d.ts.map +0 -1
  612. package/lib/blobManager.js +0 -244
  613. package/lib/blobManager.js.map +0 -1
  614. package/lib/connectionTelemetry.d.ts.map +0 -1
  615. package/lib/connectionTelemetry.js +0 -174
  616. package/lib/connectionTelemetry.js.map +0 -1
  617. package/lib/containerHandleContext.d.ts.map +0 -1
  618. package/lib/containerHandleContext.js.map +0 -1
  619. package/lib/containerRuntime.d.ts +0 -615
  620. package/lib/containerRuntime.d.ts.map +0 -1
  621. package/lib/containerRuntime.js +0 -2166
  622. package/lib/containerRuntime.js.map +0 -1
  623. package/lib/dataStore.d.ts.map +0 -1
  624. package/lib/dataStore.js.map +0 -1
  625. package/lib/dataStoreContext.d.ts.map +0 -1
  626. package/lib/dataStoreContext.js.map +0 -1
  627. package/lib/dataStoreContexts.d.ts.map +0 -1
  628. package/lib/dataStoreContexts.js.map +0 -1
  629. package/lib/dataStoreRegistry.d.ts.map +0 -1
  630. package/lib/dataStoreRegistry.js.map +0 -1
  631. package/lib/dataStores.d.ts.map +0 -1
  632. package/lib/dataStores.js.map +0 -1
  633. package/lib/deltaScheduler.d.ts.map +0 -1
  634. package/lib/deltaScheduler.js.map +0 -1
  635. package/lib/garbageCollection.d.ts +0 -319
  636. package/lib/garbageCollection.d.ts.map +0 -1
  637. package/lib/garbageCollection.js +0 -989
  638. package/lib/garbageCollection.js.map +0 -1
  639. package/lib/index.d.ts +0 -14
  640. package/lib/index.d.ts.map +0 -1
  641. package/lib/index.js +0 -13
  642. package/lib/index.js.map +0 -1
  643. package/lib/opTelemetry.d.ts +0 -22
  644. package/lib/opTelemetry.d.ts.map +0 -1
  645. package/lib/opTelemetry.js +0 -56
  646. package/lib/opTelemetry.js.map +0 -1
  647. package/lib/orderedClientElection.d.ts.map +0 -1
  648. package/lib/orderedClientElection.js.map +0 -1
  649. package/lib/packageVersion.d.ts.map +0 -1
  650. package/lib/packageVersion.js.map +0 -1
  651. package/lib/pendingStateManager.d.ts.map +0 -1
  652. package/lib/pendingStateManager.js +0 -339
  653. package/lib/pendingStateManager.js.map +0 -1
  654. package/lib/runWhileConnectedCoordinator.d.ts.map +0 -1
  655. package/lib/runWhileConnectedCoordinator.js.map +0 -1
  656. package/lib/runningSummarizer.d.ts +0 -93
  657. package/lib/runningSummarizer.d.ts.map +0 -1
  658. package/lib/runningSummarizer.js +0 -380
  659. package/lib/runningSummarizer.js.map +0 -1
  660. package/lib/serializedSnapshotStorage.d.ts +0 -58
  661. package/lib/serializedSnapshotStorage.d.ts.map +0 -1
  662. package/lib/serializedSnapshotStorage.js +0 -104
  663. package/lib/serializedSnapshotStorage.js.map +0 -1
  664. package/lib/summarizer.d.ts.map +0 -1
  665. package/lib/summarizer.js +0 -342
  666. package/lib/summarizer.js.map +0 -1
  667. package/lib/summarizerClientElection.d.ts.map +0 -1
  668. package/lib/summarizerClientElection.js.map +0 -1
  669. package/lib/summarizerHandle.d.ts +0 -12
  670. package/lib/summarizerHandle.d.ts.map +0 -1
  671. package/lib/summarizerHandle.js +0 -18
  672. package/lib/summarizerHandle.js.map +0 -1
  673. package/lib/summarizerHeuristics.d.ts.map +0 -1
  674. package/lib/summarizerHeuristics.js +0 -79
  675. package/lib/summarizerHeuristics.js.map +0 -1
  676. package/lib/summarizerTypes.d.ts.map +0 -1
  677. package/lib/summarizerTypes.js +0 -9
  678. package/lib/summarizerTypes.js.map +0 -1
  679. package/lib/summaryCollection.d.ts.map +0 -1
  680. package/lib/summaryCollection.js.map +0 -1
  681. package/lib/summaryFormat.d.ts.map +0 -1
  682. package/lib/summaryFormat.js.map +0 -1
  683. package/lib/summaryGenerator.d.ts +0 -85
  684. package/lib/summaryGenerator.d.ts.map +0 -1
  685. package/lib/summaryGenerator.js.map +0 -1
  686. package/lib/summaryManager.d.ts.map +0 -1
  687. package/lib/summaryManager.js.map +0 -1
  688. package/lib/throttler.d.ts.map +0 -1
  689. package/lib/throttler.js.map +0 -1
  690. package/src/garbageCollection.ts +0 -1434
  691. package/src/opTelemetry.ts +0 -71
  692. package/src/orderedClientElection.ts +0 -511
  693. package/src/runWhileConnectedCoordinator.ts +0 -106
  694. package/src/runningSummarizer.ts +0 -550
  695. package/src/serializedSnapshotStorage.ts +0 -146
  696. package/src/summarizer.ts +0 -438
  697. package/src/summarizerClientElection.ts +0 -161
  698. package/src/summarizerHandle.ts +0 -21
  699. package/src/summarizerHeuristics.ts +0 -108
  700. package/src/summarizerTypes.ts +0 -462
  701. package/src/summaryCollection.ts +0 -406
  702. package/src/summaryFormat.ts +0 -239
  703. package/src/summaryGenerator.ts +0 -427
  704. package/src/summaryManager.ts +0 -368
  705. package/tsconfig.esnext.json +0 -7
@@ -0,0 +1,865 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.GarbageCollector = void 0;
8
+ const core_utils_1 = require("@fluidframework/core-utils");
9
+ const runtime_definitions_1 = require("@fluidframework/runtime-definitions");
10
+ const runtime_utils_1 = require("@fluidframework/runtime-utils");
11
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
12
+ const containerRuntime_1 = require("../containerRuntime.cjs");
13
+ const error_1 = require("../error.cjs");
14
+ const messageTypes_1 = require("../messageTypes.cjs");
15
+ const gcConfigs_1 = require("./gcConfigs.cjs");
16
+ const gcDefinitions_1 = require("./gcDefinitions.cjs");
17
+ const gcHelpers_1 = require("./gcHelpers.cjs");
18
+ const gcReferenceGraphAlgorithm_1 = require("./gcReferenceGraphAlgorithm.cjs");
19
+ const gcSummaryStateTracker_1 = require("./gcSummaryStateTracker.cjs");
20
+ const gcUnreferencedStateTracker_1 = require("./gcUnreferencedStateTracker.cjs");
21
+ const gcTelemetry_1 = require("./gcTelemetry.cjs");
22
+ /**
23
+ * The garbage collector for the container runtime. It consolidates the garbage collection functionality and maintains
24
+ * its state across summaries.
25
+ *
26
+ * Node - represented as nodeId, it's a node on the GC graph
27
+ *
28
+ * Outbound Route - a path from one node to another node, think `nodeA` -\> `nodeB`
29
+ *
30
+ * Graph - all nodes with their respective routes
31
+ *
32
+ * ```
33
+ * GC Graph
34
+ *
35
+ * Node
36
+ * NodeId = "datastore1"
37
+ * / \\
38
+ * OutboundRoute OutboundRoute
39
+ * / \\
40
+ * Node Node
41
+ * NodeId = "dds1" NodeId = "dds2"
42
+ * ```
43
+ */
44
+ class GarbageCollector {
45
+ static create(createParams) {
46
+ return new GarbageCollector(createParams);
47
+ }
48
+ get shouldRunGC() {
49
+ return this.configs.shouldRunGC;
50
+ }
51
+ /** If false, loading or using a Tombstoned object should merely log, not fail */
52
+ get tombstoneEnforcementAllowed() {
53
+ return this.configs.sweepEnabled;
54
+ }
55
+ /** If true, throw an error when a tombstone data store is retrieved */
56
+ get throwOnTombstoneLoad() {
57
+ return this.configs.throwOnTombstoneLoad;
58
+ }
59
+ /** If true, throw an error when a tombstone data store is used */
60
+ get throwOnTombstoneUsage() {
61
+ return this.configs.throwOnTombstoneUsage;
62
+ }
63
+ get summaryStateNeedsReset() {
64
+ return this.summaryStateTracker.doesSummaryStateNeedReset;
65
+ }
66
+ /** Returns the count of data stores whose GC state updated since the last summary. */
67
+ get updatedDSCountSinceLastSummary() {
68
+ return this.summaryStateTracker.updatedDSCountSinceLastSummary;
69
+ }
70
+ constructor(createParams) {
71
+ // Keeps a list of references (edges in the GC graph) between GC runs. Each entry has a node id and a list of
72
+ // outbound routes from that node.
73
+ this.newReferencesSinceLastRun = new Map();
74
+ // A list of nodes that have been tombstoned.
75
+ this.tombstones = [];
76
+ // A list of nodes that have been deleted during sweep phase.
77
+ this.deletedNodes = new Set();
78
+ // Map of node ids to their unreferenced state tracker.
79
+ this.unreferencedNodesState = new Map();
80
+ // The number of times GC has successfully completed on this instance of GarbageCollector.
81
+ this.completedRuns = 0;
82
+ this.runtime = createParams.runtime;
83
+ this.isSummarizerClient = createParams.isSummarizerClient;
84
+ this.getNodePackagePath = createParams.getNodePackagePath;
85
+ this.getLastSummaryTimestampMs = createParams.getLastSummaryTimestampMs;
86
+ this.submitMessage = createParams.submitMessage;
87
+ const baseSnapshot = createParams.baseSnapshot;
88
+ const readAndParseBlob = createParams.readAndParseBlob;
89
+ this.mc = (0, telemetry_utils_1.createChildMonitoringContext)({
90
+ logger: createParams.baseLogger,
91
+ namespace: "GarbageCollector",
92
+ properties: {
93
+ all: { completedGCRuns: () => this.completedRuns },
94
+ },
95
+ });
96
+ this.configs = (0, gcConfigs_1.generateGCConfigs)(this.mc, createParams);
97
+ // If session expiry is enabled, we need to close the container when the session expiry timeout expires.
98
+ if (this.configs.sessionExpiryTimeoutMs !== undefined) {
99
+ // If Test Override config is set, override Session Expiry timeout.
100
+ const overrideSessionExpiryTimeoutMs = this.mc.config.getNumber("Fluid.GarbageCollection.TestOverride.SessionExpiryMs");
101
+ const timeoutMs = overrideSessionExpiryTimeoutMs ?? this.configs.sessionExpiryTimeoutMs;
102
+ this.sessionExpiryTimer = new core_utils_1.Timer(timeoutMs, () => {
103
+ this.runtime.closeFn(new error_1.ClientSessionExpiredError(`Client session expired.`, timeoutMs));
104
+ });
105
+ this.sessionExpiryTimer.start();
106
+ }
107
+ this.summaryStateTracker = new gcSummaryStateTracker_1.GCSummaryStateTracker(this.configs, baseSnapshot?.trees[runtime_definitions_1.gcTreeKey] !== undefined /* wasGCRunInBaseSnapshot */);
108
+ this.telemetryTracker = new gcTelemetry_1.GCTelemetryTracker(this.mc, this.configs, this.isSummarizerClient, createParams.createContainerMetadata, (nodeId) => this.runtime.getNodeType(nodeId), (nodeId) => this.unreferencedNodesState.get(nodeId), this.getNodePackagePath);
109
+ // Get the GC data from the base snapshot. Use LazyPromise because we only want to do this once since it
110
+ // it involves fetching blobs from storage which is expensive.
111
+ this.baseSnapshotDataP = new core_utils_1.LazyPromise(async () => {
112
+ if (baseSnapshot === undefined) {
113
+ return undefined;
114
+ }
115
+ try {
116
+ // For newer documents, GC data should be present in the GC tree in the root of the snapshot.
117
+ const gcSnapshotTree = baseSnapshot.trees[runtime_definitions_1.gcTreeKey];
118
+ if (gcSnapshotTree === undefined) {
119
+ // back-compat - Older documents get their gc data reset for simplicity as there are few of them
120
+ // incremental gc summary will not work with older gc data as well
121
+ return undefined;
122
+ }
123
+ const snapshotData = await (0, gcHelpers_1.getGCDataFromSnapshot)(gcSnapshotTree, readAndParseBlob);
124
+ // If the GC version in base snapshot does not match the GC version currently in effect, the GC data
125
+ // in the snapshot cannot be interpreted correctly. Set everything to undefined except for
126
+ // deletedNodes because irrespective of GC versions, these nodes have been deleted and cannot be
127
+ // brought back. The deletedNodes info is needed to identify when these nodes are used.
128
+ if (this.configs.gcVersionInEffect !== this.configs.gcVersionInBaseSnapshot) {
129
+ return {
130
+ gcState: undefined,
131
+ tombstones: undefined,
132
+ deletedNodes: snapshotData.deletedNodes,
133
+ };
134
+ }
135
+ return snapshotData;
136
+ }
137
+ catch (error) {
138
+ const dpe = telemetry_utils_1.DataProcessingError.wrapIfUnrecognized(error, "FailedToInitializeGC");
139
+ dpe.addTelemetryProperties({
140
+ gcConfigs: JSON.stringify(this.configs),
141
+ });
142
+ throw dpe;
143
+ }
144
+ });
145
+ /**
146
+ * Set up the initializer which initializes the GC state from the data in base snapshot. It sets up GC data
147
+ * from the base GC state and starts tracking the state of unreferenced nodes.
148
+ *
149
+ * Must only be called if there is a current reference timestamp.
150
+ */
151
+ this.initializeGCStateFromBaseSnapshotP = new core_utils_1.LazyPromise(async () => {
152
+ const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();
153
+ (0, core_utils_1.assert)(currentReferenceTimestampMs !== undefined, "Trying to initialize GC state without current timestamp");
154
+ /**
155
+ * The base snapshot data will not be present if the container is loaded from:
156
+ * 1. The first summary created by the detached container.
157
+ * 2. A summary that was generated with GC disabled.
158
+ * 3. A summary that was generated before GC even existed.
159
+ */
160
+ const baseSnapshotData = await this.baseSnapshotDataP;
161
+ this.summaryStateTracker.initializeBaseState(baseSnapshotData);
162
+ if (baseSnapshotData?.gcState === undefined) {
163
+ return;
164
+ }
165
+ // Update unreferenced state tracking as per the GC state in the snapshot data and update gcDataFromLastRun
166
+ // to the GC data from the snapshot data.
167
+ const gcNodes = {};
168
+ for (const [nodeId, nodeData] of Object.entries(baseSnapshotData.gcState.gcNodes)) {
169
+ if (nodeData.unreferencedTimestampMs !== undefined) {
170
+ this.unreferencedNodesState.set(nodeId, new gcUnreferencedStateTracker_1.UnreferencedStateTracker(nodeData.unreferencedTimestampMs, this.configs.inactiveTimeoutMs, currentReferenceTimestampMs, this.configs.tombstoneTimeoutMs, this.configs.sweepGracePeriodMs));
171
+ }
172
+ gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);
173
+ }
174
+ this.gcDataFromLastRun = { gcNodes };
175
+ });
176
+ // Get the GC details from the GC state in the base summary. This is returned in getBaseGCDetails which is
177
+ // used to initialize the GC state of all the nodes in the container.
178
+ this.baseGCDetailsP = new core_utils_1.LazyPromise(async () => {
179
+ const baseSnapshotData = await this.baseSnapshotDataP;
180
+ if (baseSnapshotData?.gcState === undefined) {
181
+ return {};
182
+ }
183
+ const gcNodes = {};
184
+ for (const [nodeId, nodeData] of Object.entries(baseSnapshotData.gcState.gcNodes)) {
185
+ gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);
186
+ }
187
+ // Run GC on the nodes in the base summary to get the routes used in each node in the container.
188
+ // This is an optimization for space (vs performance) wherein we don't need to store the used routes of
189
+ // each node in the summary.
190
+ const usedRoutes = (0, gcReferenceGraphAlgorithm_1.runGarbageCollection)(gcNodes, ["/"]).referencedNodeIds;
191
+ return { gcData: { gcNodes }, usedRoutes };
192
+ });
193
+ // Log all the GC options and the state determined by the garbage collector.
194
+ // This is useful even for interactive clients since they track unreferenced nodes and log errors.
195
+ this.mc.logger.sendTelemetryEvent({
196
+ eventName: "GarbageCollectorLoaded",
197
+ gcConfigs: JSON.stringify(this.configs),
198
+ gcOptions: JSON.stringify(createParams.gcOptions),
199
+ ...createParams.createContainerMetadata,
200
+ });
201
+ }
202
+ /**
203
+ * Called during container initialization. Initializes the tombstone and deleted nodes state from the base snapshot.
204
+ * Also, initializes the GC state including unreferenced nodes tracking if a current reference timestamp exists.
205
+ * Note that if there is any GC state in the base snapshot, then there will definitely be a reference timestamp
206
+ * to work with - The GC state would have been generated using a timestamp which is part of the snapshot.
207
+ */
208
+ async initializeBaseState() {
209
+ const baseSnapshotData = await this.baseSnapshotDataP;
210
+ /**
211
+ * The base snapshot data will not be present if the container is loaded from:
212
+ * 1. The first summary created by the detached container.
213
+ * 2. A summary that was generated with GC disabled.
214
+ * 3. A summary that was generated before GC even existed.
215
+ */
216
+ if (baseSnapshotData === undefined) {
217
+ return;
218
+ }
219
+ // Initialize the deleted nodes from the snapshot. This is done irrespective of whether sweep is enabled or not
220
+ // to identify deleted nodes' usage.
221
+ if (baseSnapshotData.deletedNodes !== undefined) {
222
+ this.deletedNodes = new Set(baseSnapshotData.deletedNodes);
223
+ }
224
+ // If running in tombstone mode, initialize the tombstone state from the snapshot. Also, notify the runtime of
225
+ // tombstone routes.
226
+ if (this.configs.tombstoneMode && baseSnapshotData.tombstones !== undefined) {
227
+ // Create a copy since we are writing from a source we don't control
228
+ this.tombstones = Array.from(baseSnapshotData.tombstones);
229
+ this.runtime.updateTombstonedRoutes(this.tombstones);
230
+ }
231
+ await this.initializeOrUpdateGCState();
232
+ }
233
+ /**
234
+ * Initialize the GC state if not already initialized. If GC state is already initialized, update the unreferenced
235
+ * state tracking as per the current reference timestamp.
236
+ */
237
+ async initializeOrUpdateGCState() {
238
+ const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();
239
+ if (currentReferenceTimestampMs === undefined) {
240
+ return;
241
+ }
242
+ // If the GC state hasn't been initialized yet, initialize it and return.
243
+ if (this.gcDataFromLastRun === undefined) {
244
+ await this.initializeGCStateFromBaseSnapshotP;
245
+ return;
246
+ }
247
+ // If the GC state has been initialized, update the tracking of unreferenced nodes as per the current
248
+ // reference timestamp.
249
+ for (const [, nodeStateTracker] of this.unreferencedNodesState) {
250
+ nodeStateTracker.updateTracking(currentReferenceTimestampMs);
251
+ }
252
+ }
253
+ /**
254
+ * Called when the connection state of the runtime changes, i.e., it connects or disconnects. GC subscribes to this
255
+ * to initialize or update the unreference state tracking.
256
+ * @param connected - Whether the runtime connected / disconnected.
257
+ * @param clientId - The clientId of this runtime.
258
+ */
259
+ setConnectionState(connected, clientId) {
260
+ /**
261
+ * When the client connects (or reconnects), attempt to initialize or update the GC state. This will keep
262
+ * the unreferenced state tracking updated as per the reference timestamp at the time of connection.
263
+ *
264
+ * During GC initialization and during connections in read mode, it is possible that either no ops are
265
+ * processed or only trailing ops are processed. This means that the GC state is not initialized or initialized
266
+ * with an older reference timestamp. So, doing this on every connection will keep the unreferenced state
267
+ * tracking up-to-date.
268
+ */
269
+ if (connected && this.configs.shouldRunGC) {
270
+ this.initializeOrUpdateGCState().catch((error) => {
271
+ this.mc.logger.sendErrorEvent({
272
+ eventName: "GCInitializationOrUpdateFailed",
273
+ gcConfigs: JSON.stringify(this.configs),
274
+ clientId,
275
+ }, error);
276
+ });
277
+ }
278
+ }
279
+ /**
280
+ * Returns a the GC details generated from the base summary. This is used to initialize the GC state of the nodes
281
+ * in the container.
282
+ */
283
+ async getBaseGCDetails() {
284
+ return this.baseGCDetailsP;
285
+ }
286
+ /**
287
+ * Runs garbage collection and updates the reference / used state of the nodes in the container.
288
+ * @returns stats of the GC run or undefined if GC did not run.
289
+ */
290
+ async collectGarbage(options, telemetryContext) {
291
+ const fullGC = options.fullGC ??
292
+ (this.configs.runFullGC === true || this.summaryStateTracker.doesSummaryStateNeedReset);
293
+ // Add the options that are used to run GC to the telemetry context.
294
+ telemetryContext?.setMultiple("fluid_GC", "Options", {
295
+ fullGC,
296
+ runSweep: options.runSweep,
297
+ });
298
+ const logger = options.logger
299
+ ? (0, telemetry_utils_1.createChildLogger)({
300
+ logger: options.logger,
301
+ properties: {
302
+ all: { completedGCRuns: () => this.completedRuns },
303
+ },
304
+ })
305
+ : this.mc.logger;
306
+ /**
307
+ * If there is no current reference timestamp, skip running GC. We need the current timestamp to track
308
+ * how long objects have been unreferenced and if they should be deleted.
309
+ *
310
+ * Note that the only scenario where GC is called and there is no reference timestamp is when no ops have ever
311
+ * been processed for this container and it is in read mode. In this scenario, there is no point in running GC
312
+ * anyway because references in the container do not change without any ops, i.e., there is nothing to collect.
313
+ */
314
+ const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();
315
+ if (currentReferenceTimestampMs === undefined) {
316
+ // Log an event so we can evaluate how often we run into this scenario.
317
+ logger.sendErrorEvent({
318
+ eventName: "CollectGarbageCalledWithoutTimestamp",
319
+ gcConfigs: JSON.stringify(this.configs),
320
+ });
321
+ return undefined;
322
+ }
323
+ return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "GarbageCollection" }, async (event) => {
324
+ /** Pre-GC steps */
325
+ // Ensure that state has been initialized from the base snapshot data.
326
+ await this.initializeGCStateFromBaseSnapshotP;
327
+ // Let the runtime update its pending state before GC runs.
328
+ await this.runtime.updateStateBeforeGC();
329
+ /** GC step */
330
+ const gcStats = await this.runGC(fullGC, currentReferenceTimestampMs, logger);
331
+ event.end({
332
+ ...gcStats,
333
+ details: {
334
+ timestamp: currentReferenceTimestampMs,
335
+ sweep: this.configs.shouldRunSweep,
336
+ tombstone: this.configs.throwOnTombstoneLoad,
337
+ },
338
+ });
339
+ /** Post-GC steps */
340
+ // Log pending unreferenced events such as a node being used after inactive. This is done after GC runs and
341
+ // updates its state so that we don't send false positives based on intermediate state. For example, we may get
342
+ // reference to an unreferenced node from another unreferenced node which means the node wasn't revived.
343
+ await this.telemetryTracker.logPendingEvents(logger);
344
+ // Update the state of summary state tracker from this run's stats.
345
+ this.summaryStateTracker.updateStateFromGCRunStats(gcStats);
346
+ this.newReferencesSinceLastRun.clear();
347
+ this.completedRuns++;
348
+ return gcStats;
349
+ }, { end: true, cancel: "error" });
350
+ }
351
+ /**
352
+ * Runs garbage collection. It does the following:
353
+ *
354
+ * 1. It generates / analyzes the runtime's reference graph.
355
+ *
356
+ * 2. Generates mark phase stats.
357
+ *
358
+ * 3. Runs Mark phase.
359
+ *
360
+ * 4. Runs Sweep phase.
361
+ *
362
+ * 5. Generates sweep phase stats.
363
+ */
364
+ async runGC(fullGC, currentReferenceTimestampMs, logger) {
365
+ // 1. Generate / analyze the runtime's reference graph.
366
+ // Get the reference graph (gcData) and run GC algorithm to get referenced / unreferenced nodes.
367
+ const gcData = await this.runtime.getGCData(fullGC);
368
+ const gcResult = (0, gcReferenceGraphAlgorithm_1.runGarbageCollection)(gcData.gcNodes, ["/"]);
369
+ // Get all referenced nodes - References in this run + references between the previous and current runs.
370
+ const allReferencedNodeIds = this.findAllNodesReferencedBetweenGCs(gcData, this.gcDataFromLastRun, logger) ??
371
+ gcResult.referencedNodeIds;
372
+ // 2. Get the mark phase stats based on the previous / current GC state.
373
+ // This is done before running mark phase because we need the previous GC state before it is updated.
374
+ const markPhaseStats = this.getMarkPhaseStats(gcResult);
375
+ // 3. Run the Mark phase.
376
+ // It will mark nodes as referenced / unreferenced and return lists of tombstone-ready and sweep-ready nodes.
377
+ const { tombstoneReadyNodeIds, sweepReadyNodeIds } = this.runMarkPhase(gcResult, allReferencedNodeIds, currentReferenceTimestampMs);
378
+ // 4. Run the Sweep phase.
379
+ // It will tombstone any tombstone-ready nodes, and initiate the deletion of sweep-ready nodes by sending a
380
+ // sweep op. All clients, including this one, will delete these nodes once it processes the op.
381
+ this.runSweepPhase(gcResult, tombstoneReadyNodeIds, sweepReadyNodeIds);
382
+ this.gcDataFromLastRun = (0, gcHelpers_1.cloneGCData)(gcData);
383
+ // 5. Get the sweep phase stats.
384
+ const sweepPhaseStats = this.getSweepPhaseStats(this.deletedNodes, sweepReadyNodeIds, markPhaseStats);
385
+ return { ...markPhaseStats, ...sweepPhaseStats };
386
+ }
387
+ /**
388
+ * Runs the GC Mark phase. It does the following:
389
+ *
390
+ * 1. Marks all referenced nodes in this run by clearing tracking for them.
391
+ *
392
+ * 2. Marks unreferenced nodes in this run by starting tracking for them.
393
+ *
394
+ * 3. Calls the runtime to update nodes that were marked referenced.
395
+ *
396
+ * @param gcResult - The result of the GC run on the gcData.
397
+ * @param allReferencedNodeIds - Nodes referenced in this GC run + referenced between previous and current GC run.
398
+ * @param currentReferenceTimestampMs - The timestamp to be used for unreferenced nodes' timestamp.
399
+ * @returns The sets of tombstone-ready and sweep-ready nodes, i.e., nodes that ready to be tombstoned or deleted.
400
+ */
401
+ runMarkPhase(gcResult, allReferencedNodeIds, currentReferenceTimestampMs) {
402
+ // 1. Marks all referenced nodes by clearing their unreferenced tracker, if any.
403
+ for (const nodeId of allReferencedNodeIds) {
404
+ const nodeStateTracker = this.unreferencedNodesState.get(nodeId);
405
+ if (nodeStateTracker !== undefined) {
406
+ // Stop tracking so as to clear out any running timers.
407
+ nodeStateTracker.stopTracking();
408
+ // Delete the node as we don't need to track it any more.
409
+ this.unreferencedNodesState.delete(nodeId);
410
+ }
411
+ }
412
+ // 2. Mark unreferenced nodes in this run by starting unreferenced tracking for them.
413
+ const tombstoneReadyNodeIds = new Set();
414
+ const sweepReadyNodeIds = new Set();
415
+ for (const nodeId of gcResult.deletedNodeIds) {
416
+ const nodeStateTracker = this.unreferencedNodesState.get(nodeId);
417
+ if (nodeStateTracker === undefined) {
418
+ this.unreferencedNodesState.set(nodeId, new gcUnreferencedStateTracker_1.UnreferencedStateTracker(currentReferenceTimestampMs, this.configs.inactiveTimeoutMs, currentReferenceTimestampMs, this.configs.tombstoneTimeoutMs, this.configs.sweepGracePeriodMs));
419
+ }
420
+ else {
421
+ // If a node was already unreferenced, update its tracking information. Since the current reference time
422
+ // is from the ops seen, this will ensure that we keep updating unreferenced state as time moves forward.
423
+ nodeStateTracker.updateTracking(currentReferenceTimestampMs);
424
+ // If a node is tombstone or sweep-ready, store it so it can be returned.
425
+ if (nodeStateTracker.state === gcDefinitions_1.UnreferencedState.TombstoneReady) {
426
+ tombstoneReadyNodeIds.add(nodeId);
427
+ }
428
+ if (nodeStateTracker.state === gcDefinitions_1.UnreferencedState.SweepReady) {
429
+ sweepReadyNodeIds.add(nodeId);
430
+ }
431
+ }
432
+ }
433
+ // 3. Call the runtime to update referenced nodes in this run.
434
+ this.runtime.updateUsedRoutes(gcResult.referencedNodeIds);
435
+ return { tombstoneReadyNodeIds, sweepReadyNodeIds };
436
+ }
437
+ /**
438
+ * Runs the GC Sweep phase. It does the following:
439
+ *
440
+ * 1. Marks tombstone-ready nodes as tombstones.
441
+ *
442
+ * 2. Sends a sweep op to delete nodes that are sweep-ready. Once the op is ack'd, these nodes will be deleted.
443
+ *
444
+ * @param gcResult - The result of the GC run on the gcData.
445
+ * @param tombstoneReadyNodes - List of nodes that are tombstone-ready.
446
+ * @param sweepReadyNodes - List of nodes that are sweep-ready.
447
+ */
448
+ runSweepPhase(gcResult, tombstoneReadyNodes, sweepReadyNodes) {
449
+ /**
450
+ * Under "Test Mode", unreferenced nodes are immediately deleted without waiting for them to be sweep-ready.
451
+ *
452
+ * Otherwise, depending on how long it's been since the node was unreferenced, it will either be
453
+ * marked as Tombstone, or deleted by Sweep.
454
+ */
455
+ if (this.configs.testMode) {
456
+ // If we are running in GC test mode, unreferenced nodes (gcResult.deletedNodeIds) are deleted.
457
+ this.runtime.updateUnusedRoutes(gcResult.deletedNodeIds);
458
+ return;
459
+ }
460
+ // If sweep is disabled, we'll tombstone both tombstone-ready and sweep-ready nodes.
461
+ // This is important because a container may never load during a node's Sweep Grace Period,
462
+ // so that node would directly become sweep-ready skipping over tombstone-ready state,
463
+ // but should be Tombstoned since Sweep is disabled.
464
+ const { nodesToTombstone, nodesToDelete } = this.configs.shouldRunSweep
465
+ ? {
466
+ nodesToTombstone: [...tombstoneReadyNodes],
467
+ nodesToDelete: [...sweepReadyNodes],
468
+ }
469
+ : {
470
+ nodesToTombstone: [...tombstoneReadyNodes, ...sweepReadyNodes],
471
+ nodesToDelete: [],
472
+ };
473
+ if (this.configs.tombstoneMode) {
474
+ this.tombstones = nodesToTombstone;
475
+ // If we are running in GC tombstone mode, update tombstoned routes.
476
+ this.runtime.updateTombstonedRoutes(this.tombstones);
477
+ }
478
+ if (this.configs.shouldRunSweep && nodesToDelete.length > 0) {
479
+ // Do not send DDS node ids in the GC op. This is an optimization to reduce its size. Since GC applies to
480
+ // to data store only, all its DDSes are deleted along with it. The DDS ids will be retrieved from the
481
+ // local state when processing the op.
482
+ const sweepReadyDSAndBlobs = nodesToDelete.filter((nodeId) => {
483
+ const nodeType = this.runtime.getNodeType(nodeId);
484
+ return nodeType === gcDefinitions_1.GCNodeType.DataStore || nodeType === gcDefinitions_1.GCNodeType.Blob;
485
+ });
486
+ const contents = {
487
+ type: gcDefinitions_1.GarbageCollectionMessageType.Sweep,
488
+ deletedNodeIds: sweepReadyDSAndBlobs,
489
+ };
490
+ // Its fine for older clients to ignore this op because it doesn't have any functional impact. This op
491
+ // is an optimization to ensure that all clients are in sync when it comes to deleted nodes to prevent their
492
+ // accidental usage. The clients will sync without the delete op too but it may take longer.
493
+ const containerGCMessage = {
494
+ type: messageTypes_1.ContainerMessageType.GC,
495
+ contents,
496
+ compatDetails: { behavior: "Ignore" },
497
+ };
498
+ this.submitMessage(containerGCMessage);
499
+ return;
500
+ }
501
+ }
502
+ /**
503
+ * Since GC runs periodically, the GC data that is generated only tells us the state of the world at that point in
504
+ * time. There can be nodes that were referenced in between two runs and their unreferenced state needs to be
505
+ * updated. For example, in the following scenarios not updating the unreferenced timestamp can lead to deletion of
506
+ * these objects while there can be in-memory referenced to it:
507
+ * 1. A node transitions from `unreferenced -> referenced -> unreferenced` between two runs. When the reference is
508
+ * added, the object may have been accessed and in-memory reference to it added.
509
+ * 2. A reference is added from one unreferenced node to one or more unreferenced nodes. Even though the node[s] were
510
+ * unreferenced, they could have been accessed and in-memory reference to them added.
511
+ *
512
+ * This function identifies nodes that were referenced since the last run.
513
+ * If these nodes are currently unreferenced, they will be assigned new unreferenced state by the current run.
514
+ *
515
+ * @returns A list of all nodes referenced from the last local summary until now.
516
+ */
517
+ findAllNodesReferencedBetweenGCs(currentGCData, previousGCData, logger) {
518
+ // If we haven't run GC before there is nothing to do.
519
+ // No previousGCData, means nothing is unreferenced, and there are no reference state trackers to clear
520
+ if (previousGCData === undefined) {
521
+ return undefined;
522
+ }
523
+ /**
524
+ * If there are references that were not explicitly notified to GC, log an error because this should never happen.
525
+ * If it does, this may result in the unreferenced timestamps of these nodes not updated when they were referenced.
526
+ */
527
+ this.telemetryTracker.logIfMissingExplicitReferences(currentGCData, previousGCData, this.newReferencesSinceLastRun, logger);
528
+ // No references were added since the last run so we don't have to update reference states of any unreferenced
529
+ // nodes. There is no in between state at this point.
530
+ if (this.newReferencesSinceLastRun.size === 0) {
531
+ return undefined;
532
+ }
533
+ /**
534
+ * Generate a super set of the GC data that contains the nodes and edges from last run, plus any new node and
535
+ * edges that have been added since then. To do this, combine the GC data from the last run and the current
536
+ * run, and then add the references since last run.
537
+ *
538
+ * Note on why we need to combine the data from previous run, current run and all references in between -
539
+ * 1. We need data from last run because some of its references may have been deleted since then. If those
540
+ * references added new outbound references before they were deleted, we need to detect them.
541
+ *
542
+ * 2. We need new outbound references since last run because some of them may have been deleted later. If those
543
+ * references added new outbound references before they were deleted, we need to detect them.
544
+ *
545
+ * 3. We need data from the current run because currently we may not detect when DDSes are referenced:
546
+ * - We don't require DDSes handles to be stored in a referenced DDS.
547
+ * - A new data store may have "root" DDSes already created and we don't detect them today.
548
+ */
549
+ const gcDataSuperSet = (0, gcHelpers_1.concatGarbageCollectionData)(previousGCData, currentGCData);
550
+ const newOutboundRoutesSinceLastRun = [];
551
+ this.newReferencesSinceLastRun.forEach((outboundRoutes, sourceNodeId) => {
552
+ if (gcDataSuperSet.gcNodes[sourceNodeId] === undefined) {
553
+ gcDataSuperSet.gcNodes[sourceNodeId] = outboundRoutes;
554
+ }
555
+ else {
556
+ gcDataSuperSet.gcNodes[sourceNodeId].push(...outboundRoutes);
557
+ }
558
+ newOutboundRoutesSinceLastRun.push(...outboundRoutes);
559
+ });
560
+ /**
561
+ * Run GC on the above reference graph starting with root and all new outbound routes. This will generate a
562
+ * list of all nodes that could have been referenced since the last run. If any of these nodes are unreferenced,
563
+ * unreferenced, stop tracking them and remove from unreferenced list.
564
+ * Note that some of these nodes may be unreferenced now and if so, the current run will mark them as
565
+ * unreferenced and add unreferenced state.
566
+ */
567
+ const gcResult = (0, gcReferenceGraphAlgorithm_1.runGarbageCollection)(gcDataSuperSet.gcNodes, [
568
+ "/",
569
+ ...newOutboundRoutesSinceLastRun,
570
+ ]);
571
+ return gcResult.referencedNodeIds;
572
+ }
573
+ /**
574
+ * Summarizes the GC data and returns it as a summary tree.
575
+ * We current write the entire GC state in a single blob. This can be modified later to write multiple
576
+ * blobs. All the blob keys should start with `gcBlobPrefix`.
577
+ */
578
+ summarize(fullTree, trackState, telemetryContext) {
579
+ if (!this.configs.shouldRunGC || this.gcDataFromLastRun === undefined) {
580
+ return;
581
+ }
582
+ const gcState = { gcNodes: {} };
583
+ for (const [nodeId, outboundRoutes] of Object.entries(this.gcDataFromLastRun.gcNodes)) {
584
+ gcState.gcNodes[nodeId] = {
585
+ outboundRoutes,
586
+ unreferencedTimestampMs: this.unreferencedNodesState.get(nodeId)?.unreferencedTimestampMs,
587
+ };
588
+ }
589
+ return this.summaryStateTracker.summarize(fullTree, trackState, gcState, this.deletedNodes, this.tombstones);
590
+ }
591
+ getMetadata() {
592
+ return {
593
+ /**
594
+ * If GC is enabled, the GC data is written using the GC version in effect and that is the gcFeature that goes
595
+ * into the metadata blob. If GC is disabled, the gcFeature is 0.
596
+ */
597
+ gcFeature: this.configs.gcEnabled ? this.configs.gcVersionInEffect : 0,
598
+ gcFeatureMatrix: this.configs.persistedGcFeatureMatrix,
599
+ sessionExpiryTimeoutMs: this.configs.sessionExpiryTimeoutMs,
600
+ sweepEnabled: false,
601
+ tombstoneTimeoutMs: this.configs.tombstoneTimeoutMs,
602
+ };
603
+ }
604
+ /**
605
+ * Called to refresh the latest summary state. This happens when either a pending summary is acked.
606
+ */
607
+ async refreshLatestSummary(result) {
608
+ return this.summaryStateTracker.refreshLatestSummary(result);
609
+ }
610
+ /**
611
+ * Process a GC message.
612
+ * @param message - The GC message from the container runtime.
613
+ * @param local - Whether it was send by this client.
614
+ */
615
+ processMessage(message, local) {
616
+ switch (message.contents.type) {
617
+ case "Sweep": {
618
+ // Delete the nodes whose ids are present in the contents.
619
+ this.deleteSweepReadyNodes(message.contents.deletedNodeIds);
620
+ break;
621
+ }
622
+ default: {
623
+ if (!(0, gcHelpers_1.compatBehaviorAllowsGCMessageType)(message.contents.type, message.compatDetails?.behavior)) {
624
+ const error = telemetry_utils_1.DataProcessingError.create(`Garbage collection message of unknown type ${message.contents.type}`, "processMessage");
625
+ throw error;
626
+ }
627
+ break;
628
+ }
629
+ }
630
+ }
631
+ /**
632
+ * Delete nodes that are sweep-ready. Call the runtime to delete these nodes and clear the unreferenced state
633
+ * tracking for nodes that are actually deleted by the runtime.
634
+ * @param sweepReadyNodeIds - The ids of nodes that are ready to be deleted.
635
+ */
636
+ deleteSweepReadyNodes(sweepReadyNodeIds) {
637
+ // Use a set for lookup because its much faster than array or map.
638
+ const sweepReadyNodesSet = new Set(sweepReadyNodeIds);
639
+ // The ids in the sweep-ready nodes do not contain DDS node ids. This is an optimization to reduce the size
640
+ // of the GC op. Since GC applies to data store only, all its DDSes are deleted along with it. So, get the
641
+ // DDS nodes ID from the unreferenced nodes state.
642
+ const allSweepReadyNodeIds = Array.from(sweepReadyNodeIds);
643
+ for (const [id] of this.unreferencedNodesState) {
644
+ // Ignore data store nodes since they would already be in the list.
645
+ const pathParts = id.split("/");
646
+ if (pathParts.length <= 2) {
647
+ continue;
648
+ }
649
+ // Get the data store id part. Note that this may include blobs but that's okay since the part would just
650
+ // be "_blobs" and it won't be found.
651
+ const dsId = `/${pathParts[1]}`;
652
+ if (sweepReadyNodesSet.has(dsId)) {
653
+ allSweepReadyNodeIds.push(id);
654
+ }
655
+ }
656
+ const deletedNodeIds = this.runtime.deleteSweepReadyNodes(allSweepReadyNodeIds);
657
+ // Clear unreferenced state tracking for deleted nodes.
658
+ for (const nodeId of deletedNodeIds) {
659
+ const nodeStateTracker = this.unreferencedNodesState.get(nodeId);
660
+ if (nodeStateTracker !== undefined) {
661
+ // Stop tracking so as to clear out any running timers.
662
+ nodeStateTracker.stopTracking();
663
+ // Delete the node as we don't need to track it any more.
664
+ this.unreferencedNodesState.delete(nodeId);
665
+ }
666
+ this.deletedNodes.add(nodeId);
667
+ }
668
+ }
669
+ /**
670
+ * Called when a node with the given id is updated. If the node is inactive or tombstoned, this will log an error
671
+ * or throw an error if failing on incorrect usage is configured.
672
+ * @param nodePath - The path of the node that changed.
673
+ * @param reason - Whether the node was loaded or changed.
674
+ * @param timestampMs - The timestamp when the node changed.
675
+ * @param packagePath - The package path of the node. This may not be available if the node hasn't been loaded yet.
676
+ * @param request - The original request for loads to preserve it in telemetry.
677
+ * @param requestHeaders - If the node was loaded via request path, the headers in the request.
678
+ */
679
+ nodeUpdated(nodePath, reason, timestampMs, packagePath, request, headerData) {
680
+ if (!this.configs.shouldRunGC) {
681
+ return;
682
+ }
683
+ const isTombstoned = this.tombstones.includes(nodePath);
684
+ // This will log if appropriate
685
+ this.telemetryTracker.nodeUsed({
686
+ id: nodePath,
687
+ usageType: reason,
688
+ currentReferenceTimestampMs: timestampMs ?? this.runtime.getCurrentReferenceTimestampMs(),
689
+ packagePath,
690
+ completedGCRuns: this.completedRuns,
691
+ isTombstoned,
692
+ lastSummaryTime: this.getLastSummaryTimestampMs(),
693
+ headers: headerData,
694
+ });
695
+ const nodeType = this.runtime.getNodeType(nodePath);
696
+ // Unless this is a Loaded event for a Blob or DataStore, we're done after telemetry tracking
697
+ if (reason !== "Loaded" || ![gcDefinitions_1.GCNodeType.Blob, gcDefinitions_1.GCNodeType.DataStore].includes(nodeType)) {
698
+ return;
699
+ }
700
+ const errorRequest = request ?? { url: nodePath };
701
+ // If the object is tombstoned and tombstone enforcement is configured, throw an error.
702
+ if (isTombstoned && this.throwOnTombstoneLoad && headerData?.allowTombstone !== true) {
703
+ // The requested data store is removed by gc. Create a 404 gc response exception.
704
+ throw (0, runtime_utils_1.responseToException)((0, runtime_utils_1.createResponseError)(404, `${nodeType} was tombstoned`, errorRequest, {
705
+ [containerRuntime_1.TombstoneResponseHeaderKey]: true,
706
+ }), errorRequest);
707
+ }
708
+ // If the object is inactive and inactive enforcement is configured, throw an error.
709
+ if (this.unreferencedNodesState.get(nodePath)?.state === "Inactive") {
710
+ const shouldThrowOnInactiveLoad = !this.isSummarizerClient &&
711
+ this.configs.throwOnInactiveLoad === true &&
712
+ headerData?.allowInactive !== true;
713
+ if (shouldThrowOnInactiveLoad) {
714
+ throw (0, runtime_utils_1.responseToException)((0, runtime_utils_1.createResponseError)(404, `${nodeType} is inactive`, errorRequest, {
715
+ [containerRuntime_1.InactiveResponseHeaderKey]: true,
716
+ }), errorRequest);
717
+ }
718
+ }
719
+ }
720
+ /**
721
+ * Called when an outbound reference is added to a node. This is used to identify all nodes that have been
722
+ * referenced between summaries so that their unreferenced timestamp can be reset.
723
+ *
724
+ * @param fromNodePath - The node from which the reference is added.
725
+ * @param toNodePath - The node to which the reference is added.
726
+ */
727
+ addedOutboundReference(fromNodePath, toNodePath) {
728
+ if (!this.configs.shouldRunGC) {
729
+ return;
730
+ }
731
+ const outboundRoutes = this.newReferencesSinceLastRun.get(fromNodePath) ?? [];
732
+ outboundRoutes.push(toNodePath);
733
+ this.newReferencesSinceLastRun.set(fromNodePath, outboundRoutes);
734
+ this.telemetryTracker.nodeUsed({
735
+ id: toNodePath,
736
+ usageType: "Revived",
737
+ currentReferenceTimestampMs: this.runtime.getCurrentReferenceTimestampMs(),
738
+ packagePath: undefined,
739
+ completedGCRuns: this.completedRuns,
740
+ isTombstoned: this.tombstones.includes(toNodePath),
741
+ lastSummaryTime: this.getLastSummaryTimestampMs(),
742
+ fromId: fromNodePath,
743
+ });
744
+ }
745
+ /**
746
+ * Returns whether a node with the given path has been deleted or not. This can be used by the runtime to identify
747
+ * cases where objects are used after they are deleted and throw / log errors accordingly.
748
+ */
749
+ isNodeDeleted(nodePath) {
750
+ return this.deletedNodes.has(nodePath);
751
+ }
752
+ dispose() {
753
+ this.sessionExpiryTimer?.clear();
754
+ this.sessionExpiryTimer = undefined;
755
+ }
756
+ /**
757
+ * Generates the stats of a garbage collection mark phase run.
758
+ * @param gcResult - The result of the current GC run.
759
+ * @returns the stats of the mark phase run.
760
+ */
761
+ getMarkPhaseStats(gcResult) {
762
+ const markPhaseStats = {
763
+ nodeCount: 0,
764
+ dataStoreCount: 0,
765
+ attachmentBlobCount: 0,
766
+ unrefNodeCount: 0,
767
+ unrefDataStoreCount: 0,
768
+ unrefAttachmentBlobCount: 0,
769
+ updatedNodeCount: 0,
770
+ updatedDataStoreCount: 0,
771
+ updatedAttachmentBlobCount: 0,
772
+ };
773
+ const updateNodeStats = (nodeId, referenced) => {
774
+ markPhaseStats.nodeCount++;
775
+ // If there is no previous GC data, every node's state is generated and is considered as updated.
776
+ // Otherwise, find out if any node went from referenced to unreferenced or vice-versa.
777
+ const stateUpdated = this.gcDataFromLastRun === undefined ||
778
+ this.unreferencedNodesState.has(nodeId) === referenced;
779
+ if (stateUpdated) {
780
+ markPhaseStats.updatedNodeCount++;
781
+ }
782
+ if (!referenced) {
783
+ markPhaseStats.unrefNodeCount++;
784
+ }
785
+ if (this.runtime.getNodeType(nodeId) === gcDefinitions_1.GCNodeType.DataStore) {
786
+ markPhaseStats.dataStoreCount++;
787
+ if (stateUpdated) {
788
+ markPhaseStats.updatedDataStoreCount++;
789
+ }
790
+ if (!referenced) {
791
+ markPhaseStats.unrefDataStoreCount++;
792
+ }
793
+ }
794
+ if (this.runtime.getNodeType(nodeId) === gcDefinitions_1.GCNodeType.Blob) {
795
+ markPhaseStats.attachmentBlobCount++;
796
+ if (stateUpdated) {
797
+ markPhaseStats.updatedAttachmentBlobCount++;
798
+ }
799
+ if (!referenced) {
800
+ markPhaseStats.unrefAttachmentBlobCount++;
801
+ }
802
+ }
803
+ };
804
+ for (const nodeId of gcResult.referencedNodeIds) {
805
+ updateNodeStats(nodeId, true /* referenced */);
806
+ }
807
+ for (const nodeId of gcResult.deletedNodeIds) {
808
+ updateNodeStats(nodeId, false /* referenced */);
809
+ }
810
+ return markPhaseStats;
811
+ }
812
+ /**
813
+ * Generates the stats of a garbage collection sweep phase run.
814
+ * @param deletedNodes - The nodes that have been deleted until this run.
815
+ * @param sweepReadyNodes - The nodes that are sweep-ready in this GC run.
816
+ * @param markPhaseStats - The stats of the mark phase run.
817
+ * @returns the stats of the sweep phase run.
818
+ */
819
+ getSweepPhaseStats(deletedNodes, sweepReadyNodes, markPhaseStats) {
820
+ // Initialize the life time node counts to the mark phase node counts. If sweep is not enabled,
821
+ // these will be the life time node count for this container.
822
+ const sweepPhaseStats = {
823
+ lifetimeNodeCount: markPhaseStats.nodeCount,
824
+ lifetimeDataStoreCount: markPhaseStats.dataStoreCount,
825
+ lifetimeAttachmentBlobCount: markPhaseStats.attachmentBlobCount,
826
+ deletedNodeCount: 0,
827
+ deletedDataStoreCount: 0,
828
+ deletedAttachmentBlobCount: 0,
829
+ };
830
+ for (const nodeId of deletedNodes) {
831
+ sweepPhaseStats.deletedNodeCount++;
832
+ const nodeType = this.runtime.getNodeType(nodeId);
833
+ if (nodeType === gcDefinitions_1.GCNodeType.DataStore) {
834
+ sweepPhaseStats.deletedDataStoreCount++;
835
+ }
836
+ else if (nodeType === gcDefinitions_1.GCNodeType.Blob) {
837
+ sweepPhaseStats.deletedAttachmentBlobCount++;
838
+ }
839
+ }
840
+ // If sweep is enabled, the counts from the mark phase stats do not include nodes that have been
841
+ // deleted in previous runs. So, add the deleted node counts to life time stats.
842
+ sweepPhaseStats.lifetimeNodeCount += sweepPhaseStats.deletedNodeCount;
843
+ sweepPhaseStats.lifetimeDataStoreCount += sweepPhaseStats.deletedDataStoreCount;
844
+ sweepPhaseStats.lifetimeAttachmentBlobCount += sweepPhaseStats.deletedAttachmentBlobCount;
845
+ if (this.configs.shouldRunSweep) {
846
+ return sweepPhaseStats;
847
+ }
848
+ // If sweep is not enabled, the current sweep-ready node stats should be added to deleted stats since this
849
+ // is the final state the node will be in.
850
+ // If sweep is enabled, this will happen in the run after the GC op round trips back.
851
+ for (const nodeId of sweepReadyNodes) {
852
+ sweepPhaseStats.deletedNodeCount++;
853
+ const nodeType = this.runtime.getNodeType(nodeId);
854
+ if (nodeType === gcDefinitions_1.GCNodeType.DataStore) {
855
+ sweepPhaseStats.deletedDataStoreCount++;
856
+ }
857
+ else if (nodeType === gcDefinitions_1.GCNodeType.Blob) {
858
+ sweepPhaseStats.deletedAttachmentBlobCount++;
859
+ }
860
+ }
861
+ return sweepPhaseStats;
862
+ }
863
+ }
864
+ exports.GarbageCollector = GarbageCollector;
865
+ //# sourceMappingURL=garbageCollection.cjs.map