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

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 (459) hide show
  1. package/api-report/container-runtime.api.md +81 -27
  2. package/dist/batchTracker.d.ts +1 -1
  3. package/dist/batchTracker.d.ts.map +1 -1
  4. package/dist/batchTracker.js +2 -2
  5. package/dist/batchTracker.js.map +1 -1
  6. package/dist/blobManager.d.ts +3 -3
  7. package/dist/blobManager.d.ts.map +1 -1
  8. package/dist/blobManager.js +3 -3
  9. package/dist/blobManager.js.map +1 -1
  10. package/dist/channelCollection.d.ts +6 -5
  11. package/dist/channelCollection.d.ts.map +1 -1
  12. package/dist/channelCollection.js +57 -19
  13. package/dist/channelCollection.js.map +1 -1
  14. package/dist/connectionTelemetry.d.ts +2 -2
  15. package/dist/connectionTelemetry.d.ts.map +1 -1
  16. package/dist/connectionTelemetry.js +3 -3
  17. package/dist/connectionTelemetry.js.map +1 -1
  18. package/dist/container-runtime-alpha.d.ts +205 -12
  19. package/dist/container-runtime-beta.d.ts +16 -3
  20. package/dist/container-runtime-public.d.ts +16 -3
  21. package/dist/container-runtime-untrimmed.d.ts +207 -26
  22. package/dist/containerHandleContext.d.ts.map +1 -1
  23. package/dist/containerHandleContext.js.map +1 -1
  24. package/dist/containerRuntime.d.ts +32 -26
  25. package/dist/containerRuntime.d.ts.map +1 -1
  26. package/dist/containerRuntime.js +235 -133
  27. package/dist/containerRuntime.js.map +1 -1
  28. package/dist/dataStore.d.ts +1 -1
  29. package/dist/dataStore.d.ts.map +1 -1
  30. package/dist/dataStore.js +2 -2
  31. package/dist/dataStore.js.map +1 -1
  32. package/dist/dataStoreContext.d.ts +4 -4
  33. package/dist/dataStoreContext.d.ts.map +1 -1
  34. package/dist/dataStoreContext.js +18 -18
  35. package/dist/dataStoreContext.js.map +1 -1
  36. package/dist/dataStoreContexts.d.ts.map +1 -1
  37. package/dist/dataStoreContexts.js.map +1 -1
  38. package/dist/dataStoreRegistry.d.ts +4 -0
  39. package/dist/dataStoreRegistry.d.ts.map +1 -1
  40. package/dist/dataStoreRegistry.js +2 -2
  41. package/dist/dataStoreRegistry.js.map +1 -1
  42. package/dist/deltaScheduler.d.ts +1 -1
  43. package/dist/deltaScheduler.d.ts.map +1 -1
  44. package/dist/deltaScheduler.js +1 -1
  45. package/dist/deltaScheduler.js.map +1 -1
  46. package/dist/gc/garbageCollection.d.ts +1 -1
  47. package/dist/gc/garbageCollection.d.ts.map +1 -1
  48. package/dist/gc/garbageCollection.js +1 -1
  49. package/dist/gc/garbageCollection.js.map +1 -1
  50. package/dist/gc/gcConfigs.d.ts +1 -1
  51. package/dist/gc/gcConfigs.d.ts.map +1 -1
  52. package/dist/gc/gcConfigs.js.map +1 -1
  53. package/dist/gc/gcDefinitions.d.ts +1 -1
  54. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  55. package/dist/gc/gcDefinitions.js.map +1 -1
  56. package/dist/gc/gcHelpers.d.ts.map +1 -1
  57. package/dist/gc/gcHelpers.js.map +1 -1
  58. package/dist/gc/gcSummaryStateTracker.d.ts +1 -1
  59. package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -1
  60. package/dist/gc/gcSummaryStateTracker.js.map +1 -1
  61. package/dist/gc/gcTelemetry.d.ts +1 -1
  62. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  63. package/dist/gc/gcTelemetry.js.map +1 -1
  64. package/dist/index.d.ts +2 -2
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +4 -2
  67. package/dist/index.js.map +1 -1
  68. package/dist/messageTypes.d.ts +11 -5
  69. package/dist/messageTypes.d.ts.map +1 -1
  70. package/dist/messageTypes.js +4 -0
  71. package/dist/messageTypes.js.map +1 -1
  72. package/dist/opLifecycle/definitions.d.ts +1 -19
  73. package/dist/opLifecycle/definitions.d.ts.map +1 -1
  74. package/dist/opLifecycle/definitions.js.map +1 -1
  75. package/dist/opLifecycle/index.d.ts +3 -3
  76. package/dist/opLifecycle/index.d.ts.map +1 -1
  77. package/dist/opLifecycle/index.js +3 -1
  78. package/dist/opLifecycle/index.js.map +1 -1
  79. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  80. package/dist/opLifecycle/opCompressor.js +2 -3
  81. package/dist/opLifecycle/opCompressor.js.map +1 -1
  82. package/dist/opLifecycle/opDecompressor.d.ts +15 -4
  83. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  84. package/dist/opLifecycle/opDecompressor.js +60 -61
  85. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  86. package/dist/opLifecycle/opGroupingManager.d.ts +2 -1
  87. package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -1
  88. package/dist/opLifecycle/opGroupingManager.js +9 -11
  89. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  90. package/dist/opLifecycle/opSplitter.d.ts +11 -3
  91. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  92. package/dist/opLifecycle/opSplitter.js +48 -38
  93. package/dist/opLifecycle/opSplitter.js.map +1 -1
  94. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  95. package/dist/opLifecycle/outbox.js +18 -17
  96. package/dist/opLifecycle/outbox.js.map +1 -1
  97. package/dist/opLifecycle/remoteMessageProcessor.d.ts +8 -0
  98. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  99. package/dist/opLifecycle/remoteMessageProcessor.js +36 -32
  100. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  101. package/dist/packageVersion.d.ts +1 -1
  102. package/dist/packageVersion.js +1 -1
  103. package/dist/packageVersion.js.map +1 -1
  104. package/dist/pendingStateManager.d.ts +1 -1
  105. package/dist/pendingStateManager.d.ts.map +1 -1
  106. package/dist/pendingStateManager.js.map +1 -1
  107. package/dist/scheduleManager.d.ts +1 -1
  108. package/dist/scheduleManager.d.ts.map +1 -1
  109. package/dist/scheduleManager.js +6 -2
  110. package/dist/scheduleManager.js.map +1 -1
  111. package/dist/summary/documentSchema.d.ts +178 -0
  112. package/dist/summary/documentSchema.d.ts.map +1 -0
  113. package/dist/summary/documentSchema.js +345 -0
  114. package/dist/summary/documentSchema.js.map +1 -0
  115. package/dist/summary/index.d.ts +2 -1
  116. package/dist/summary/index.d.ts.map +1 -1
  117. package/dist/summary/index.js +4 -1
  118. package/dist/summary/index.js.map +1 -1
  119. package/dist/summary/orderedClientElection.d.ts +2 -2
  120. package/dist/summary/orderedClientElection.d.ts.map +1 -1
  121. package/dist/summary/orderedClientElection.js +7 -2
  122. package/dist/summary/orderedClientElection.js.map +1 -1
  123. package/dist/summary/runWhileConnectedCoordinator.d.ts +1 -1
  124. package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -1
  125. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
  126. package/dist/summary/runningSummarizer.d.ts +2 -2
  127. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  128. package/dist/summary/runningSummarizer.js +2 -2
  129. package/dist/summary/runningSummarizer.js.map +1 -1
  130. package/dist/summary/summarizer.d.ts +2 -2
  131. package/dist/summary/summarizer.d.ts.map +1 -1
  132. package/dist/summary/summarizer.js +2 -2
  133. package/dist/summary/summarizer.js.map +1 -1
  134. package/dist/summary/summarizerClientElection.d.ts +2 -2
  135. package/dist/summary/summarizerClientElection.d.ts.map +1 -1
  136. package/dist/summary/summarizerClientElection.js.map +1 -1
  137. package/dist/summary/summarizerHeuristics.d.ts +1 -1
  138. package/dist/summary/summarizerHeuristics.d.ts.map +1 -1
  139. package/dist/summary/summarizerHeuristics.js.map +1 -1
  140. package/dist/summary/summarizerNode/summarizerNode.d.ts +2 -2
  141. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  142. package/dist/summary/summarizerNode/summarizerNode.js +3 -3
  143. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  144. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +1 -1
  145. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  146. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  147. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +1 -1
  148. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  149. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +1 -1
  150. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  151. package/dist/summary/summarizerTypes.d.ts +3 -3
  152. package/dist/summary/summarizerTypes.d.ts.map +1 -1
  153. package/dist/summary/summarizerTypes.js.map +1 -1
  154. package/dist/summary/summaryCollection.d.ts +2 -2
  155. package/dist/summary/summaryCollection.d.ts.map +1 -1
  156. package/dist/summary/summaryCollection.js +1 -1
  157. package/dist/summary/summaryCollection.js.map +1 -1
  158. package/dist/summary/summaryFormat.d.ts +5 -16
  159. package/dist/summary/summaryFormat.d.ts.map +1 -1
  160. package/dist/summary/summaryFormat.js.map +1 -1
  161. package/dist/summary/summaryGenerator.d.ts +2 -2
  162. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  163. package/dist/summary/summaryGenerator.js +2 -2
  164. package/dist/summary/summaryGenerator.js.map +1 -1
  165. package/dist/summary/summaryManager.d.ts +1 -1
  166. package/dist/summary/summaryManager.d.ts.map +1 -1
  167. package/dist/summary/summaryManager.js +2 -2
  168. package/dist/summary/summaryManager.js.map +1 -1
  169. package/lib/batchTracker.d.ts +1 -1
  170. package/lib/batchTracker.d.ts.map +1 -1
  171. package/lib/batchTracker.js +2 -2
  172. package/lib/batchTracker.js.map +1 -1
  173. package/lib/blobManager.d.ts +3 -3
  174. package/lib/blobManager.d.ts.map +1 -1
  175. package/lib/blobManager.js +5 -5
  176. package/lib/blobManager.js.map +1 -1
  177. package/lib/channelCollection.d.ts +6 -5
  178. package/lib/channelCollection.d.ts.map +1 -1
  179. package/lib/channelCollection.js +59 -21
  180. package/lib/channelCollection.js.map +1 -1
  181. package/lib/connectionTelemetry.d.ts +2 -2
  182. package/lib/connectionTelemetry.d.ts.map +1 -1
  183. package/lib/connectionTelemetry.js +3 -3
  184. package/lib/connectionTelemetry.js.map +1 -1
  185. package/lib/container-runtime-alpha.d.ts +205 -12
  186. package/lib/container-runtime-beta.d.ts +16 -3
  187. package/lib/container-runtime-public.d.ts +16 -3
  188. package/lib/container-runtime-untrimmed.d.ts +207 -26
  189. package/lib/containerHandleContext.d.ts.map +1 -1
  190. package/lib/containerHandleContext.js.map +1 -1
  191. package/lib/containerRuntime.d.ts +32 -26
  192. package/lib/containerRuntime.d.ts.map +1 -1
  193. package/lib/containerRuntime.js +197 -95
  194. package/lib/containerRuntime.js.map +1 -1
  195. package/lib/dataStore.d.ts +1 -1
  196. package/lib/dataStore.d.ts.map +1 -1
  197. package/lib/dataStore.js +2 -2
  198. package/lib/dataStore.js.map +1 -1
  199. package/lib/dataStoreContext.d.ts +4 -4
  200. package/lib/dataStoreContext.d.ts.map +1 -1
  201. package/lib/dataStoreContext.js +3 -3
  202. package/lib/dataStoreContext.js.map +1 -1
  203. package/lib/dataStoreContexts.d.ts.map +1 -1
  204. package/lib/dataStoreContexts.js.map +1 -1
  205. package/lib/dataStoreRegistry.d.ts +4 -0
  206. package/lib/dataStoreRegistry.d.ts.map +1 -1
  207. package/lib/dataStoreRegistry.js.map +1 -1
  208. package/lib/deltaScheduler.d.ts +1 -1
  209. package/lib/deltaScheduler.d.ts.map +1 -1
  210. package/lib/deltaScheduler.js +1 -1
  211. package/lib/deltaScheduler.js.map +1 -1
  212. package/lib/gc/garbageCollection.d.ts +1 -1
  213. package/lib/gc/garbageCollection.d.ts.map +1 -1
  214. package/lib/gc/garbageCollection.js +3 -3
  215. package/lib/gc/garbageCollection.js.map +1 -1
  216. package/lib/gc/gcConfigs.d.ts +1 -1
  217. package/lib/gc/gcConfigs.d.ts.map +1 -1
  218. package/lib/gc/gcConfigs.js +1 -1
  219. package/lib/gc/gcConfigs.js.map +1 -1
  220. package/lib/gc/gcDefinitions.d.ts +1 -1
  221. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  222. package/lib/gc/gcDefinitions.js.map +1 -1
  223. package/lib/gc/gcHelpers.d.ts.map +1 -1
  224. package/lib/gc/gcHelpers.js.map +1 -1
  225. package/lib/gc/gcSummaryStateTracker.d.ts +1 -1
  226. package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -1
  227. package/lib/gc/gcSummaryStateTracker.js +1 -1
  228. package/lib/gc/gcSummaryStateTracker.js.map +1 -1
  229. package/lib/gc/gcTelemetry.d.ts +1 -1
  230. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  231. package/lib/gc/gcTelemetry.js +1 -1
  232. package/lib/gc/gcTelemetry.js.map +1 -1
  233. package/lib/index.d.ts +2 -2
  234. package/lib/index.d.ts.map +1 -1
  235. package/lib/index.js +2 -2
  236. package/lib/index.js.map +1 -1
  237. package/lib/messageTypes.d.ts +11 -5
  238. package/lib/messageTypes.d.ts.map +1 -1
  239. package/lib/messageTypes.js +4 -0
  240. package/lib/messageTypes.js.map +1 -1
  241. package/lib/opLifecycle/definitions.d.ts +1 -19
  242. package/lib/opLifecycle/definitions.d.ts.map +1 -1
  243. package/lib/opLifecycle/definitions.js.map +1 -1
  244. package/lib/opLifecycle/index.d.ts +3 -3
  245. package/lib/opLifecycle/index.d.ts.map +1 -1
  246. package/lib/opLifecycle/index.js +2 -2
  247. package/lib/opLifecycle/index.js.map +1 -1
  248. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  249. package/lib/opLifecycle/opCompressor.js +2 -3
  250. package/lib/opLifecycle/opCompressor.js.map +1 -1
  251. package/lib/opLifecycle/opDecompressor.d.ts +15 -4
  252. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  253. package/lib/opLifecycle/opDecompressor.js +60 -61
  254. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  255. package/lib/opLifecycle/opGroupingManager.d.ts +2 -1
  256. package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -1
  257. package/lib/opLifecycle/opGroupingManager.js +7 -10
  258. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  259. package/lib/opLifecycle/opSplitter.d.ts +11 -3
  260. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  261. package/lib/opLifecycle/opSplitter.js +46 -37
  262. package/lib/opLifecycle/opSplitter.js.map +1 -1
  263. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  264. package/lib/opLifecycle/outbox.js +18 -17
  265. package/lib/opLifecycle/outbox.js.map +1 -1
  266. package/lib/opLifecycle/remoteMessageProcessor.d.ts +8 -0
  267. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  268. package/lib/opLifecycle/remoteMessageProcessor.js +36 -32
  269. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  270. package/lib/packageVersion.d.ts +1 -1
  271. package/lib/packageVersion.js +1 -1
  272. package/lib/packageVersion.js.map +1 -1
  273. package/lib/pendingStateManager.d.ts +1 -1
  274. package/lib/pendingStateManager.d.ts.map +1 -1
  275. package/lib/pendingStateManager.js.map +1 -1
  276. package/lib/scheduleManager.d.ts +1 -1
  277. package/lib/scheduleManager.d.ts.map +1 -1
  278. package/lib/scheduleManager.js +6 -2
  279. package/lib/scheduleManager.js.map +1 -1
  280. package/lib/summary/documentSchema.d.ts +178 -0
  281. package/lib/summary/documentSchema.d.ts.map +1 -0
  282. package/lib/summary/documentSchema.js +341 -0
  283. package/lib/summary/documentSchema.js.map +1 -0
  284. package/lib/summary/index.d.ts +2 -1
  285. package/lib/summary/index.d.ts.map +1 -1
  286. package/lib/summary/index.js +1 -0
  287. package/lib/summary/index.js.map +1 -1
  288. package/lib/summary/orderedClientElection.d.ts +2 -2
  289. package/lib/summary/orderedClientElection.d.ts.map +1 -1
  290. package/lib/summary/orderedClientElection.js +7 -2
  291. package/lib/summary/orderedClientElection.js.map +1 -1
  292. package/lib/summary/runWhileConnectedCoordinator.d.ts +1 -1
  293. package/lib/summary/runWhileConnectedCoordinator.d.ts.map +1 -1
  294. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
  295. package/lib/summary/runningSummarizer.d.ts +2 -2
  296. package/lib/summary/runningSummarizer.d.ts.map +1 -1
  297. package/lib/summary/runningSummarizer.js +3 -3
  298. package/lib/summary/runningSummarizer.js.map +1 -1
  299. package/lib/summary/summarizer.d.ts +2 -2
  300. package/lib/summary/summarizer.d.ts.map +1 -1
  301. package/lib/summary/summarizer.js +3 -3
  302. package/lib/summary/summarizer.js.map +1 -1
  303. package/lib/summary/summarizerClientElection.d.ts +2 -2
  304. package/lib/summary/summarizerClientElection.d.ts.map +1 -1
  305. package/lib/summary/summarizerClientElection.js.map +1 -1
  306. package/lib/summary/summarizerHeuristics.d.ts +1 -1
  307. package/lib/summary/summarizerHeuristics.d.ts.map +1 -1
  308. package/lib/summary/summarizerHeuristics.js.map +1 -1
  309. package/lib/summary/summarizerNode/summarizerNode.d.ts +2 -2
  310. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  311. package/lib/summary/summarizerNode/summarizerNode.js +4 -4
  312. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  313. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts +1 -1
  314. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  315. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  316. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +1 -1
  317. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  318. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +1 -1
  319. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  320. package/lib/summary/summarizerTypes.d.ts +3 -3
  321. package/lib/summary/summarizerTypes.d.ts.map +1 -1
  322. package/lib/summary/summarizerTypes.js.map +1 -1
  323. package/lib/summary/summaryCollection.d.ts +2 -2
  324. package/lib/summary/summaryCollection.d.ts.map +1 -1
  325. package/lib/summary/summaryCollection.js +1 -1
  326. package/lib/summary/summaryCollection.js.map +1 -1
  327. package/lib/summary/summaryFormat.d.ts +5 -16
  328. package/lib/summary/summaryFormat.d.ts.map +1 -1
  329. package/lib/summary/summaryFormat.js +1 -1
  330. package/lib/summary/summaryFormat.js.map +1 -1
  331. package/lib/summary/summaryGenerator.d.ts +2 -2
  332. package/lib/summary/summaryGenerator.d.ts.map +1 -1
  333. package/lib/summary/summaryGenerator.js +3 -3
  334. package/lib/summary/summaryGenerator.js.map +1 -1
  335. package/lib/summary/summaryManager.d.ts +1 -1
  336. package/lib/summary/summaryManager.d.ts.map +1 -1
  337. package/lib/summary/summaryManager.js +2 -2
  338. package/lib/summary/summaryManager.js.map +1 -1
  339. package/lib/test/blobManager.spec.js +3 -3
  340. package/lib/test/blobManager.spec.js.map +1 -1
  341. package/lib/test/containerRuntime.spec.js +6 -4
  342. package/lib/test/containerRuntime.spec.js.map +1 -1
  343. package/lib/test/dataStoreContext.spec.js +4 -4
  344. package/lib/test/dataStoreContext.spec.js.map +1 -1
  345. package/lib/test/dataStoreCreation.spec.js +1 -1
  346. package/lib/test/dataStoreCreation.spec.js.map +1 -1
  347. package/lib/test/dataStoreRegistry.spec.js.map +1 -1
  348. package/lib/test/documentSchema.spec.js +282 -0
  349. package/lib/test/documentSchema.spec.js.map +1 -0
  350. package/lib/test/fuzz/fuzzUtils.js +11 -7
  351. package/lib/test/fuzz/fuzzUtils.js.map +1 -1
  352. package/lib/test/fuzz/summarizer.fuzz.spec.js +9 -7
  353. package/lib/test/fuzz/summarizer.fuzz.spec.js.map +1 -1
  354. package/lib/test/fuzz/summarizerFuzzMocks.js +43 -25
  355. package/lib/test/fuzz/summarizerFuzzMocks.js.map +1 -1
  356. package/lib/test/fuzz/summarizerFuzzSuite.js +7 -4
  357. package/lib/test/fuzz/summarizerFuzzSuite.js.map +1 -1
  358. package/lib/test/gc/garbageCollection.spec.js +5 -5
  359. package/lib/test/gc/garbageCollection.spec.js.map +1 -1
  360. package/lib/test/gc/gcConfigs.spec.js +2 -2
  361. package/lib/test/gc/gcConfigs.spec.js.map +1 -1
  362. package/lib/test/gc/gcHelpers.spec.js.map +1 -1
  363. package/lib/test/gc/gcStats.spec.js +2 -2
  364. package/lib/test/gc/gcStats.spec.js.map +1 -1
  365. package/lib/test/gc/gcSummaryStateTracker.spec.js +1 -1
  366. package/lib/test/gc/gcSummaryStateTracker.spec.js.map +1 -1
  367. package/lib/test/gc/gcTelemetry.spec.js +3 -3
  368. package/lib/test/gc/gcTelemetry.spec.js.map +1 -1
  369. package/lib/test/gc/gcUnreferencedStateTracker.spec.js +1 -1
  370. package/lib/test/gc/gcUnreferencedStateTracker.spec.js.map +1 -1
  371. package/lib/test/getPendingBlobs.spec.js +1 -1
  372. package/lib/test/getPendingBlobs.spec.js.map +1 -1
  373. package/lib/test/hardwareStats.spec.js +1 -1
  374. package/lib/test/hardwareStats.spec.js.map +1 -1
  375. package/lib/test/opLifecycle/OpGroupingManager.spec.js +95 -118
  376. package/lib/test/opLifecycle/OpGroupingManager.spec.js.map +1 -1
  377. package/lib/test/opLifecycle/batchManager.spec.js +1 -1
  378. package/lib/test/opLifecycle/batchManager.spec.js.map +1 -1
  379. package/lib/test/opLifecycle/opCompressor.spec.js +0 -1
  380. package/lib/test/opLifecycle/opCompressor.spec.js.map +1 -1
  381. package/lib/test/opLifecycle/opDecompressor.spec.js +60 -55
  382. package/lib/test/opLifecycle/opDecompressor.spec.js.map +1 -1
  383. package/lib/test/opLifecycle/opSplitter.spec.js +56 -41
  384. package/lib/test/opLifecycle/opSplitter.spec.js.map +1 -1
  385. package/lib/test/opLifecycle/outbox.spec.js +118 -10
  386. package/lib/test/opLifecycle/outbox.spec.js.map +1 -1
  387. package/lib/test/opLifecycle/remoteMessageProcessor.spec.js +115 -91
  388. package/lib/test/opLifecycle/remoteMessageProcessor.spec.js.map +1 -1
  389. package/lib/test/pendingStateManager.spec.js +1 -1
  390. package/lib/test/pendingStateManager.spec.js.map +1 -1
  391. package/lib/test/scheduleManager.spec.js +1 -1
  392. package/lib/test/scheduleManager.spec.js.map +1 -1
  393. package/lib/test/summarizerNode.spec.js +1 -1
  394. package/lib/test/summarizerNode.spec.js.map +1 -1
  395. package/lib/test/summarizerNodeWithGc.spec.js +1 -1
  396. package/lib/test/summarizerNodeWithGc.spec.js.map +1 -1
  397. package/lib/test/summary/runningSummarizer.spec.js +4 -4
  398. package/lib/test/summary/runningSummarizer.spec.js.map +1 -1
  399. package/lib/test/summary/summarizer.spec.js.map +1 -1
  400. package/lib/test/summary/summarizerClientElection.spec.js +2 -2
  401. package/lib/test/summary/summarizerClientElection.spec.js.map +1 -1
  402. package/lib/test/summary/summarizerHeuristics.spec.js +1 -1
  403. package/lib/test/summary/summarizerHeuristics.spec.js.map +1 -1
  404. package/lib/test/summary/summaryCollection.spec.js +1 -1
  405. package/lib/test/summary/summaryCollection.spec.js.map +1 -1
  406. package/lib/test/summary/summaryManager.spec.js +3 -3
  407. package/lib/test/summary/summaryManager.spec.js.map +1 -1
  408. package/lib/test/throttler.spec.js +1 -1
  409. package/lib/test/throttler.spec.js.map +1 -1
  410. package/lib/test/types/validateContainerRuntimePrevious.generated.js +6 -4
  411. package/lib/test/types/validateContainerRuntimePrevious.generated.js.map +1 -1
  412. package/package.json +35 -21
  413. package/src/batchTracker.ts +3 -3
  414. package/src/blobManager.ts +15 -15
  415. package/src/channelCollection.ts +90 -44
  416. package/src/connectionTelemetry.ts +10 -10
  417. package/src/containerHandleContext.ts +1 -1
  418. package/src/containerRuntime.ts +375 -213
  419. package/src/dataStore.ts +2 -2
  420. package/src/dataStoreContext.ts +19 -19
  421. package/src/dataStoreContexts.ts +2 -2
  422. package/src/dataStoreRegistry.ts +2 -1
  423. package/src/deltaScheduler.ts +1 -1
  424. package/src/gc/garbageCollection.ts +12 -12
  425. package/src/gc/gcConfigs.ts +11 -11
  426. package/src/gc/gcDefinitions.ts +2 -2
  427. package/src/gc/gcHelpers.ts +2 -2
  428. package/src/gc/gcSummaryStateTracker.ts +4 -4
  429. package/src/gc/gcTelemetry.ts +6 -6
  430. package/src/index.ts +8 -1
  431. package/src/messageTypes.ts +18 -5
  432. package/src/opLifecycle/README.md +89 -0
  433. package/src/opLifecycle/definitions.ts +1 -20
  434. package/src/opLifecycle/index.ts +3 -9
  435. package/src/opLifecycle/opCompressor.ts +4 -5
  436. package/src/opLifecycle/opDecompressor.ts +83 -100
  437. package/src/opLifecycle/opGroupingManager.ts +9 -12
  438. package/src/opLifecycle/opSplitter.ts +73 -47
  439. package/src/opLifecycle/outbox.ts +26 -37
  440. package/src/opLifecycle/remoteMessageProcessor.ts +41 -55
  441. package/src/packageVersion.ts +1 -1
  442. package/src/pendingStateManager.ts +2 -2
  443. package/src/scheduleManager.ts +8 -7
  444. package/src/summary/documentSchema.ts +553 -0
  445. package/src/summary/index.ts +10 -1
  446. package/src/summary/orderedClientElection.ts +7 -5
  447. package/src/summary/runWhileConnectedCoordinator.ts +1 -1
  448. package/src/summary/runningSummarizer.ts +19 -19
  449. package/src/summary/summarizer.ts +14 -14
  450. package/src/summary/summarizerClientElection.ts +2 -2
  451. package/src/summary/summarizerHeuristics.ts +2 -2
  452. package/src/summary/summarizerNode/summarizerNode.ts +15 -15
  453. package/src/summary/summarizerNode/summarizerNodeUtils.ts +1 -1
  454. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +4 -4
  455. package/src/summary/summarizerTypes.ts +3 -3
  456. package/src/summary/summaryCollection.ts +3 -3
  457. package/src/summary/summaryFormat.ts +8 -19
  458. package/src/summary/summaryGenerator.ts +10 -10
  459. package/src/summary/summaryManager.ts +4 -4
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Descripe allowed type for properties in document schema.
3
+ * Please note that for all property types we should use undefined to indicate that particular capability is off.
4
+ * Using false, or some string value (like "off") will result in clients who do not understand that property failing, whereas
5
+ * we want them to continue to collaborate alongside clients who support that capability, but such capability is shipping dark for now.
6
+ * @alpha
7
+ */
8
+ export type DocumentSchemaValueType = string | true | number | undefined;
9
+ /**
10
+ * ID Compressor mode.
11
+ * "on" - compressor is On. It's loaded as part of container load. This mode is sticky - once on, compressor is On for all
12
+ * sessions for a given document. This results in IContainerRuntime.idCompressor to be always available.
13
+ * "delayed" - ID compressor bundle is loaded only on establishing of first delta connection, i.e. it does not impact boot of cotnainer.
14
+ * In such mode IContainerRuntime.idCompressor is not made available (unless previous sessions of same document had it "On").
15
+ * The only thing that is available is IContainerRuntime.generateDocumentUniqueId() that provides opportunistically short IDs.
16
+ * undefined - ID compressor is not loaded.
17
+ * While IContainerRuntime.generateDocumentUniqueId() is available, it will produce long IDs that are do not compress well.
18
+ *
19
+ * @alpha
20
+ */
21
+ export type IdCompressorMode = "on" | "delayed" | undefined;
22
+ /**
23
+ * Document schema information.
24
+ * Describes overall shape of document schema, including unknown (to this version) properties.
25
+ *
26
+ * Used by runtime to make a call if it can understand document schema.
27
+ * If it can't, it should not continue with document and immediately fail, preventing random (cryptic) failures
28
+ * down the road and potentially corrupting documents.
29
+ * For now this structure and appropriate interpretation / behavior is focused only on runtime features.
30
+ * In the future that could be interpolated to more areas, including DDSs used, and even possibly - application
31
+ * schema.
32
+ *
33
+ * Runtime will ignore any properties at the root that it does not understand (i.e. IDocumentSchema.app), but will
34
+ * stop (and fail session) on any unknown properties within "runtime" sub-tree.
35
+ *
36
+ * In most cases values preserved in the document will not dictate if such features should be enabled in a given session.
37
+ * I.e. if compression is mentioned in document schema, this means that runtime version that opens such document must know
38
+ * how to interpret such ops, but does not need to actually use compression itself. That said, some options could be
39
+ * sticky, i.e. influence feature selection for all runtimes opening a document. ID compression is one such example.
40
+ * Currently there is no mechanism to remove feature from this property bag, i.e. once compression was used, even if it's
41
+ * disabled (through feature gate or code deployment), all existing documents that used compression will continue to fail
42
+ * if opened by clients who do not support compression.
43
+ *
44
+ * For now we are limiting it to just plain properties, and only really simple types, but that can be changed in the future.
45
+ *
46
+ * @alpha
47
+ */
48
+ export interface IDocumentSchema {
49
+ version: number;
50
+ refSeq: number;
51
+ runtime: Record<string, DocumentSchemaValueType>;
52
+ }
53
+ /**
54
+ * Content of the type=ContainerMessageType.DocumentSchemaChange ops.
55
+ * The meaning of refSeq field is different in such messages (compared to other usages of IDocumentSchemaCurrent)
56
+ * ContainerMessageType.DocumentSchemaChange messages use CAS (Compare-and-swap) semantics, and convey
57
+ * regSeq of last known schema change (known to a client proposing schema change).
58
+ * @see ContainerRuntimeDocumentSchemaMessage
59
+ * @alpha
60
+ */
61
+ export type IDocumentSchemaChangeMessage = IDocumentSchema;
62
+ /**
63
+ * Settings that this session would like to have, based on options and feature gates.
64
+ *
65
+ * WARNING: This type is used to infer IDocumentSchemaCurrent type!
66
+ * Any changes here (including renaming of properties) are potentially changing document format and should be considered carefully!
67
+ *
68
+ * @alpha
69
+ */
70
+ export interface IDocumentSchemaFeatures {
71
+ explicitSchemaControl: boolean;
72
+ compressionLz4: boolean;
73
+ idCompressorMode: IdCompressorMode;
74
+ opGroupingEnabled: boolean;
75
+ }
76
+ /**
77
+ * Current version known properties that define document schema
78
+ * This must be bumped whenever the format of document schema or protocol for changing the current document schema changes.
79
+ * Ex: adding a new configuration property (under IDocumentSchema.runtime) does not require changing this version.
80
+ * Ex: Changing the 'document schema acceptance' mechanism from convert-and-swap to one requiring consensus does require changing this version.
81
+ * @alpha
82
+ */
83
+ export declare const currentDocumentVersionSchema = 1;
84
+ /**
85
+ * Current document schema.
86
+ * @alpha
87
+ */
88
+ export type IDocumentSchemaCurrent = {
89
+ version: 1;
90
+ refSeq: number;
91
+ runtime: {
92
+ [P in keyof IDocumentSchemaFeatures]?: IDocumentSchemaFeatures[P] extends boolean ? true : IDocumentSchemaFeatures[P];
93
+ };
94
+ };
95
+ /**
96
+ * Controller of document schema.
97
+ *
98
+ * Recommended pre-reading: https://github.com/microsoft/FluidFramework/blob/main/packages/dds/SchemaVersioning.md
99
+ *
100
+ * This class manages current document schema and transitions between document schemas.
101
+ * At the moment, it only focuses on subset of document schema, specifically - how FluidFramework runtime serializes data
102
+ * (summary and op format), features & capabilities that a version of runtime has to support and understand in
103
+ * order to collaborate on a document.
104
+ * New features that modify document format have to be included in document schema definition.
105
+ * Usage of such features could only happen after document schema has been updated to reflect such feature.
106
+ *
107
+ * This formality allows clients that do not understand such features to fail right away when they observe
108
+ * document schema listing capabilities that such client does not understand.
109
+ * Old clients will fail in predictable way. This allows us to
110
+ * 1) Immediately see such issues and adjust if features are enabled too early, before changes have been saturated.
111
+ * 2) There is no way to get to 100% saturation with new code. Even if we have 99.99% saturation, there are
112
+ * still 0.01% of clients who will fail. Failing early and predictably ensures they have no chance to limp along
113
+ * and potentially corrupt the document. This is especially true for summarizer client, who could simply "undo"
114
+ * changes it does not understands.
115
+ *
116
+ * It's important to note how it overlaps with feature gates and safe velocity.
117
+ * If new feature was in use, that resulted in a number of documents referencing such feature in document schema.
118
+ * But, developers (through code deployment or feature gates) could disable usage of such features.
119
+ * That will stop a process of further document schema changes (for documents that were not using such feature).
120
+ * And documents that already list such capability in their schema will continue to do so. Later ensures that old
121
+ * clients who do not understand such feature will continue to fail to open such documents, as such documents very
122
+ * likely contain data in a new format.
123
+ *
124
+ * Users of this class need to use DocumentsSchemaController.sessionSchema to determine what features can be used.
125
+ *
126
+ * There are two modes this class can operate:
127
+ * 1) Legacy mode. In such mode it does not issue any ops to change document schema. Any changes happen implicitly,
128
+ * right away, and new features are available right away
129
+ * 2) Non-legacy mode. In such mode any changes to schema require an op roundtrip. This class will manage such transitions.
130
+ * However code should assume that any new features that were not enabled in a given document will not be available
131
+ * for a given session. That's because this session may never send any ops (including read-only documents). Or it may
132
+ * fail to convert schema.
133
+ * This class promises eventual movement forward. I.e. if new feature is allowed (let's say - through feature gates),
134
+ * then eventually all documents that are modified will have that feature reflected in their schema. It could require
135
+ * multiple reloads / new sessions to get there (depends on if code reacts to schema changes right away, or only consults
136
+ * schema on document load).
137
+ *
138
+ * How schemas are changed (in non-legacy mode):
139
+ * If a client needs to change a schema, it will attempt to do so as part of normal ops sending process.
140
+ * Changes happen in CAS (Compare-and-swap) fashion, i.e. client tells current schema and schema it wants to change to.
141
+ * When a number of clients race to change a schema, then only one of them will win, all others will fail because they will
142
+ * reference old schema that is no longer in effect.
143
+ * Clients can retry, but current implementation is simply - they will not (and will rely on next session / reload to do
144
+ * recalc and decide if schema needs to be changed or not).
145
+ *
146
+ * @alpha
147
+ */
148
+ export declare class DocumentsSchemaController {
149
+ private readonly onSchemaChange;
150
+ private explicitSchemaControl;
151
+ private sendOp;
152
+ private documentSchema;
153
+ private readonly desiredSchema;
154
+ private futureSchema;
155
+ sessionSchema: IDocumentSchemaCurrent;
156
+ /**
157
+ * Constructs DocumentsSchemaController that controls current schema and processes around it, including changes in schema.
158
+ * @param explicitSchemaControl - Tells if schema changes are done implicitly (without ops - legacy behavior), or go through formal schema change ops process.
159
+ * @param existing - Is the document existing document, or a new doc.
160
+ * @param documentMetadataSchema - current document's schema, if present.
161
+ * @param compressionAlgorithm - desired compression algorith to use
162
+ * @param idCompressorModeArg - desired ID compressor mode to use
163
+ * @param opGroupingEnabled - true if it's desired to use op grouping.
164
+ */
165
+ constructor(existing: boolean, documentMetadataSchema: IDocumentSchema | undefined, features: IDocumentSchemaFeatures, onSchemaChange: (schema: IDocumentSchemaCurrent) => void);
166
+ summarizeDocumentSchema(refSeq: number): IDocumentSchemaCurrent | undefined;
167
+ onMessageSent(send: (content: IDocumentSchemaChangeMessage) => void): void;
168
+ /**
169
+ * Process document schema change message
170
+ * @param content - content of the message
171
+ * @param local - whether op is local
172
+ * @param sequenceNumber - sequence number of the op
173
+ * @returns - true if schema was accepted, otherwise false (rejected due to failed CAS)
174
+ */
175
+ processDocumentSchemaOp(content: IDocumentSchemaChangeMessage, local: boolean, sequenceNumber: number): boolean;
176
+ onDisconnect(): void;
177
+ }
178
+ //# sourceMappingURL=documentSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentSchema.d.ts","sourceRoot":"","sources":["../../src/summary/documentSchema.ts"],"names":[],"mappings":"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AAC,aAAa,CAAyB;IAGvD,OAAO,CAAC,YAAY,CAAqC;IAOlD,aAAa,EAAE,sBAAsB,CAAC;IAE7C;;;;;;;;OAQG;gBAEF,QAAQ,EAAE,OAAO,EACjB,sBAAsB,EAAE,eAAe,GAAG,SAAS,EACnD,QAAQ,EAAE,uBAAuB,EAChB,cAAc,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,IAAI;IAyDnE,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS;IAmB3E,aAAa,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,4BAA4B,KAAK,IAAI;IAe1E;;;;;;OAMG;IACI,uBAAuB,CAC7B,OAAO,EAAE,4BAA4B,EACrC,KAAK,EAAE,OAAO,EACd,cAAc,EAAE,MAAM;IAyChB,YAAY;CAGnB"}
@@ -0,0 +1,345 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DocumentsSchemaController = exports.currentDocumentVersionSchema = void 0;
4
+ /*!
5
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
6
+ * Licensed under the MIT License.
7
+ */
8
+ const core_utils_1 = require("@fluidframework/core-utils");
9
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
10
+ /**
11
+ * Current version known properties that define document schema
12
+ * This must be bumped whenever the format of document schema or protocol for changing the current document schema changes.
13
+ * Ex: adding a new configuration property (under IDocumentSchema.runtime) does not require changing this version.
14
+ * Ex: Changing the 'document schema acceptance' mechanism from convert-and-swap to one requiring consensus does require changing this version.
15
+ * @alpha
16
+ */
17
+ exports.currentDocumentVersionSchema = 1;
18
+ class TrueOrUndefined {
19
+ and(currentDocSchema, desiredDocSchema) {
20
+ return currentDocSchema === true && desiredDocSchema === true ? true : undefined;
21
+ }
22
+ or(currentDocSchema, desiredDocSchema) {
23
+ return currentDocSchema === true || desiredDocSchema === true ? true : undefined;
24
+ }
25
+ validate(t) {
26
+ return t === undefined || t === true;
27
+ }
28
+ }
29
+ class TrueOrUndefinedMax extends TrueOrUndefined {
30
+ and(currentDocSchema, desiredDocSchema) {
31
+ return this.or(currentDocSchema, desiredDocSchema);
32
+ }
33
+ }
34
+ class MultiChoice {
35
+ constructor(choices) {
36
+ this.choices = choices;
37
+ }
38
+ and(currentDocSchema, desiredDocSchema) {
39
+ if (currentDocSchema === undefined || desiredDocSchema === undefined) {
40
+ return undefined;
41
+ }
42
+ return this.choices[Math.min(this.choices.indexOf(currentDocSchema), this.choices.indexOf(desiredDocSchema))];
43
+ }
44
+ or(currentDocSchema, desiredDocSchema) {
45
+ if (currentDocSchema === undefined) {
46
+ return desiredDocSchema;
47
+ }
48
+ if (desiredDocSchema === undefined) {
49
+ return currentDocSchema;
50
+ }
51
+ return this.choices[Math.max(this.choices.indexOf(currentDocSchema), this.choices.indexOf(desiredDocSchema))];
52
+ }
53
+ validate(t) {
54
+ return t === undefined || (typeof t === "string" && this.choices.includes(t));
55
+ }
56
+ }
57
+ class IdCompressorProperty extends MultiChoice {
58
+ // document schema always wins!
59
+ and(currentDocSchema, desiredDocSchema) {
60
+ return currentDocSchema;
61
+ }
62
+ }
63
+ /**
64
+ * Helper structure to valida if a schema is compatible with existing code.
65
+ */
66
+ const documentSchemaSupportedConfigs = {
67
+ explicitSchemaControl: new TrueOrUndefinedMax(),
68
+ idCompressorMode: new IdCompressorProperty(["delayed", "on"]),
69
+ opGroupingEnabled: new TrueOrUndefined(),
70
+ compressionLz4: new TrueOrUndefined(),
71
+ };
72
+ /**
73
+ * Checks if a given schema is compatible with current code, i.e. if current code can understand all the features of that schema.
74
+ * If schema is not compatible with current code, it throws an exception.
75
+ * @param documentSchema - current schema
76
+ */
77
+ function checkRuntimeCompatibility(documentSchema) {
78
+ // Back-compat - we can't do anything about legacy documents.
79
+ // There is no way to validate them, so we are taking a guess that safe deployment processes used by a given app
80
+ // do not run into compat problems.
81
+ if (documentSchema === undefined) {
82
+ return;
83
+ }
84
+ const msg = "Document can't be opened with current version of the code";
85
+ if (documentSchema.version !== exports.currentDocumentVersionSchema) {
86
+ throw telemetry_utils_1.DataProcessingError.create(msg, "checkRuntimeCompat", undefined, // message
87
+ {
88
+ runtimeSchemaVersion: documentSchema.version,
89
+ currentRuntimeSchemaVersion: exports.currentDocumentVersionSchema,
90
+ });
91
+ }
92
+ let unknownProperty;
93
+ const regSeq = documentSchema.refSeq;
94
+ // defence in depth - it should not be possible to get here anything other than integer, but worth validating it.
95
+ if (typeof regSeq !== "number" || regSeq < 0 || !Number.isInteger(regSeq)) {
96
+ unknownProperty = "refSeq";
97
+ }
98
+ else if (documentSchema.runtime === null || typeof documentSchema.runtime !== "object") {
99
+ unknownProperty = "runtime";
100
+ }
101
+ else {
102
+ for (const [name, value] of Object.entries(documentSchema.runtime)) {
103
+ const validator = documentSchemaSupportedConfigs[name];
104
+ if (validator === undefined || !validator.validate(value)) {
105
+ unknownProperty = `runtime/${name}`;
106
+ }
107
+ }
108
+ }
109
+ if (unknownProperty !== undefined) {
110
+ const value = documentSchema[unknownProperty];
111
+ throw telemetry_utils_1.DataProcessingError.create(msg, "checkRuntimeCompat", undefined, // message
112
+ {
113
+ codeVersion: exports.currentDocumentVersionSchema,
114
+ property: unknownProperty,
115
+ value,
116
+ });
117
+ }
118
+ }
119
+ function and(currentDocSchema, desiredDocSchema) {
120
+ const runtime = {};
121
+ for (const key of new Set([
122
+ ...Object.keys(currentDocSchema.runtime),
123
+ ...Object.keys(desiredDocSchema.runtime),
124
+ ])) {
125
+ runtime[key] = documentSchemaSupportedConfigs[key].and(currentDocSchema.runtime[key], desiredDocSchema.runtime[key]);
126
+ }
127
+ return {
128
+ version: exports.currentDocumentVersionSchema,
129
+ refSeq: currentDocSchema.refSeq,
130
+ runtime,
131
+ };
132
+ }
133
+ function or(currentDocSchema, desiredDocSchema) {
134
+ const runtime = {};
135
+ for (const key of new Set([
136
+ ...Object.keys(currentDocSchema.runtime),
137
+ ...Object.keys(desiredDocSchema.runtime),
138
+ ])) {
139
+ runtime[key] = documentSchemaSupportedConfigs[key].or(currentDocSchema.runtime[key], desiredDocSchema.runtime[key]);
140
+ }
141
+ return {
142
+ version: exports.currentDocumentVersionSchema,
143
+ refSeq: currentDocSchema.refSeq,
144
+ runtime,
145
+ };
146
+ }
147
+ function same(currentDocSchema, desiredDocSchema) {
148
+ for (const key of new Set([
149
+ ...Object.keys(currentDocSchema.runtime),
150
+ ...Object.keys(desiredDocSchema.runtime),
151
+ ])) {
152
+ // If schemas differ only by type of behavior, then we should not send schema change ops!
153
+ if (key !== "explicitSchemaControl" &&
154
+ currentDocSchema.runtime[key] !== desiredDocSchema.runtime[key]) {
155
+ return false;
156
+ }
157
+ }
158
+ return true;
159
+ }
160
+ function boolToProp(b) {
161
+ return b ? true : undefined;
162
+ }
163
+ /* eslint-disable jsdoc/check-indentation */
164
+ /**
165
+ * Controller of document schema.
166
+ *
167
+ * Recommended pre-reading: https://github.com/microsoft/FluidFramework/blob/main/packages/dds/SchemaVersioning.md
168
+ *
169
+ * This class manages current document schema and transitions between document schemas.
170
+ * At the moment, it only focuses on subset of document schema, specifically - how FluidFramework runtime serializes data
171
+ * (summary and op format), features & capabilities that a version of runtime has to support and understand in
172
+ * order to collaborate on a document.
173
+ * New features that modify document format have to be included in document schema definition.
174
+ * Usage of such features could only happen after document schema has been updated to reflect such feature.
175
+ *
176
+ * This formality allows clients that do not understand such features to fail right away when they observe
177
+ * document schema listing capabilities that such client does not understand.
178
+ * Old clients will fail in predictable way. This allows us to
179
+ * 1) Immediately see such issues and adjust if features are enabled too early, before changes have been saturated.
180
+ * 2) There is no way to get to 100% saturation with new code. Even if we have 99.99% saturation, there are
181
+ * still 0.01% of clients who will fail. Failing early and predictably ensures they have no chance to limp along
182
+ * and potentially corrupt the document. This is especially true for summarizer client, who could simply "undo"
183
+ * changes it does not understands.
184
+ *
185
+ * It's important to note how it overlaps with feature gates and safe velocity.
186
+ * If new feature was in use, that resulted in a number of documents referencing such feature in document schema.
187
+ * But, developers (through code deployment or feature gates) could disable usage of such features.
188
+ * That will stop a process of further document schema changes (for documents that were not using such feature).
189
+ * And documents that already list such capability in their schema will continue to do so. Later ensures that old
190
+ * clients who do not understand such feature will continue to fail to open such documents, as such documents very
191
+ * likely contain data in a new format.
192
+ *
193
+ * Users of this class need to use DocumentsSchemaController.sessionSchema to determine what features can be used.
194
+ *
195
+ * There are two modes this class can operate:
196
+ * 1) Legacy mode. In such mode it does not issue any ops to change document schema. Any changes happen implicitly,
197
+ * right away, and new features are available right away
198
+ * 2) Non-legacy mode. In such mode any changes to schema require an op roundtrip. This class will manage such transitions.
199
+ * However code should assume that any new features that were not enabled in a given document will not be available
200
+ * for a given session. That's because this session may never send any ops (including read-only documents). Or it may
201
+ * fail to convert schema.
202
+ * This class promises eventual movement forward. I.e. if new feature is allowed (let's say - through feature gates),
203
+ * then eventually all documents that are modified will have that feature reflected in their schema. It could require
204
+ * multiple reloads / new sessions to get there (depends on if code reacts to schema changes right away, or only consults
205
+ * schema on document load).
206
+ *
207
+ * How schemas are changed (in non-legacy mode):
208
+ * If a client needs to change a schema, it will attempt to do so as part of normal ops sending process.
209
+ * Changes happen in CAS (Compare-and-swap) fashion, i.e. client tells current schema and schema it wants to change to.
210
+ * When a number of clients race to change a schema, then only one of them will win, all others will fail because they will
211
+ * reference old schema that is no longer in effect.
212
+ * Clients can retry, but current implementation is simply - they will not (and will rely on next session / reload to do
213
+ * recalc and decide if schema needs to be changed or not).
214
+ *
215
+ * @alpha
216
+ */
217
+ class DocumentsSchemaController {
218
+ /**
219
+ * Constructs DocumentsSchemaController that controls current schema and processes around it, including changes in schema.
220
+ * @param explicitSchemaControl - Tells if schema changes are done implicitly (without ops - legacy behavior), or go through formal schema change ops process.
221
+ * @param existing - Is the document existing document, or a new doc.
222
+ * @param documentMetadataSchema - current document's schema, if present.
223
+ * @param compressionAlgorithm - desired compression algorith to use
224
+ * @param idCompressorModeArg - desired ID compressor mode to use
225
+ * @param opGroupingEnabled - true if it's desired to use op grouping.
226
+ */
227
+ constructor(existing, documentMetadataSchema, features, onSchemaChange) {
228
+ this.onSchemaChange = onSchemaChange;
229
+ this.sendOp = true;
230
+ checkRuntimeCompatibility(documentMetadataSchema);
231
+ this.documentSchema =
232
+ documentMetadataSchema ??
233
+ ({
234
+ version: exports.currentDocumentVersionSchema,
235
+ // see comment in summarizeDocumentSchema() on why it has to stay zero
236
+ refSeq: 0,
237
+ // If it's existing document and it has no schema, then it was written by legacy client.
238
+ // If it's a new document, then we define it's legacy-related behaviors.
239
+ runtime: {
240
+ explicitSchemaControl: boolToProp(!existing && features.explicitSchemaControl),
241
+ },
242
+ });
243
+ // Use legacy behavior only if both document and options tell us to use legacy.
244
+ // Otherwise it's no longer legacy time!
245
+ this.explicitSchemaControl =
246
+ this.documentSchema.runtime.explicitSchemaControl === true ||
247
+ features.explicitSchemaControl;
248
+ this.desiredSchema = {
249
+ version: exports.currentDocumentVersionSchema,
250
+ refSeq: this.documentSchema.refSeq,
251
+ runtime: {
252
+ explicitSchemaControl: boolToProp(features.explicitSchemaControl),
253
+ compressionLz4: boolToProp(features.compressionLz4),
254
+ idCompressorMode: features.idCompressorMode,
255
+ opGroupingEnabled: boolToProp(features.opGroupingEnabled),
256
+ },
257
+ };
258
+ if (!this.explicitSchemaControl || !existing) {
259
+ this.sessionSchema = this.desiredSchema;
260
+ (0, core_utils_1.assert)(boolToProp(this.explicitSchemaControl) ===
261
+ this.sessionSchema.runtime.explicitSchemaControl, "explicitSchemaControl");
262
+ this.futureSchema = undefined;
263
+ }
264
+ else {
265
+ this.sessionSchema = and(this.documentSchema, this.desiredSchema);
266
+ this.futureSchema = or(this.documentSchema, this.desiredSchema);
267
+ (0, core_utils_1.assert)(this.sessionSchema.runtime.explicitSchemaControl === true, "legacy");
268
+ (0, core_utils_1.assert)(this.futureSchema.runtime.explicitSchemaControl === true, "legacy");
269
+ if (same(this.documentSchema, this.futureSchema)) {
270
+ this.futureSchema = undefined;
271
+ }
272
+ }
273
+ // Validate that schema we are operating in is actually a schema we consider compatible with current runtime.
274
+ checkRuntimeCompatibility(this.sessionSchema);
275
+ checkRuntimeCompatibility(this.futureSchema);
276
+ }
277
+ summarizeDocumentSchema(refSeq) {
278
+ // For legacy behavior, we could write nothing (return undefined).
279
+ // It does not buy us anything, as whatever written in summary does not actually impact clients operating in legacy mode.
280
+ // But writing current used config (and assuming most of the clients settle on same config over time) will help with transition
281
+ // out of legacy mode, as clients transitioning out of it would be able to use all the
282
+ // features that are mentioned in schema right away, without a need to go through schema transition (and thus for a session or
283
+ // two losing ability to use all the features)
284
+ const schema = this.explicitSchemaControl ? this.documentSchema : this.desiredSchema;
285
+ // It's important to keep refSeq at zero in legacy mode, such that transition out of it is simple and we do not have
286
+ // race conditions. If we put any other number (including latest seq number), then we will have two clients
287
+ // (loading from two different summaries) with different numbers, and eventual consistency will be broken as schema
288
+ // change ops will be interpretted differently by those two clients.
289
+ (0, core_utils_1.assert)(this.explicitSchemaControl || schema.refSeq === 0, "refSeq should be zero");
290
+ return schema;
291
+ }
292
+ onMessageSent(send) {
293
+ if (this.sendOp && this.futureSchema !== undefined) {
294
+ (0, core_utils_1.assert)(this.explicitSchemaControl &&
295
+ this.futureSchema.runtime.explicitSchemaControl === true, "not legacy");
296
+ send({
297
+ ...this.futureSchema,
298
+ refSeq: this.documentSchema.refSeq,
299
+ });
300
+ }
301
+ this.sendOp = false;
302
+ }
303
+ /**
304
+ * Process document schema change message
305
+ * @param content - content of the message
306
+ * @param local - whether op is local
307
+ * @param sequenceNumber - sequence number of the op
308
+ * @returns - true if schema was accepted, otherwise false (rejected due to failed CAS)
309
+ */
310
+ processDocumentSchemaOp(content, local, sequenceNumber) {
311
+ (0, core_utils_1.assert)(content.refSeq <= this.documentSchema.refSeq, "did we lose a message somewhere?");
312
+ (0, core_utils_1.assert)(this.documentSchema.refSeq < sequenceNumber, "time should move forward only!");
313
+ if (content.refSeq !== this.documentSchema.refSeq) {
314
+ // CAS failed
315
+ return false;
316
+ }
317
+ // This assert should be after checking for successful CAS above.
318
+ // This will ensure we do not trip on our own messages that are no longer wanted as we processed someone else schema change message.
319
+ (0, core_utils_1.assert)(!local || (this.explicitSchemaControl && this.futureSchema !== undefined), "not sending ops");
320
+ // Changes are in effect. Immediately check that this client understands these changes
321
+ checkRuntimeCompatibility(content);
322
+ const schema = { ...content, refSeq: sequenceNumber };
323
+ this.documentSchema = schema;
324
+ this.sessionSchema = and(this.documentSchema, this.desiredSchema);
325
+ // legacy behavior is automatically off for the document once someone sends a schema op -
326
+ // from now on it's fully controlled by ops.
327
+ // This is very important, as summarizeDocumentSchema() should use this new schema!
328
+ this.explicitSchemaControl = true;
329
+ // Stop attempting changing schema.
330
+ // If it was local op, then we succeeded and do not need to try again.
331
+ // If it was remote op, then some changes happened to schema.
332
+ // We would need to recalculate this.futureSchema by merging changes that we just received.
333
+ // Avoid this complexity for now - a new client session (loading from new summary with these changes)
334
+ // will automatically do this recalculation and will figure out
335
+ this.futureSchema = undefined;
336
+ this.onSchemaChange(this.sessionSchema);
337
+ return true;
338
+ }
339
+ onDisconnect() {
340
+ this.sendOp = true;
341
+ }
342
+ }
343
+ exports.DocumentsSchemaController = DocumentsSchemaController;
344
+ /* eslint-enable jsdoc/check-indentation */
345
+ //# sourceMappingURL=documentSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentSchema.js","sourceRoot":"","sources":["../../src/summary/documentSchema.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,2DAAoD;AACpD,qEAAsE;AA2FtE;;;;;;GAMG;AACU,QAAA,4BAA4B,GAAG,CAAC,CAAC;AAwB9C,MAAM,eAAe;IACb,GAAG,CAAC,gBAAuB,EAAE,gBAAuB;QAC1D,OAAO,gBAAgB,KAAK,IAAI,IAAI,gBAAgB,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF,CAAC;IAEM,EAAE,CAAC,gBAAuB,EAAE,gBAAuB;QACzD,OAAO,gBAAgB,KAAK,IA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nC,sEAAsE;QACtE,6DAA6D;QAC7D,2FAA2F;QAC3F,qGAAqG;QACrG,+DAA+D;QAC/D,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAE9B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAExC,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,YAAY;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACpB,CAAC;CACD;AAnLD,8DAmLC;AAED,2CAA2C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { assert } from \"@fluidframework/core-utils\";\nimport { DataProcessingError } from \"@fluidframework/telemetry-utils\";\n\n/**\n * Descripe allowed type for properties in document schema.\n * Please note that for all property types we should use undefined to indicate that particular capability is off.\n * Using false, or some string value (like \"off\") will result in clients who do not understand that property failing, whereas\n * we want them to continue to collaborate alongside clients who support that capability, but such capability is shipping dark for now.\n * @alpha\n */\nexport type DocumentSchemaValueType = string | true | number | undefined;\n\n/**\n * ID Compressor mode.\n * \"on\" - compressor is On. It's loaded as part of container load. This mode is sticky - once on, compressor is On for all\n * sessions for a given document. This results in IContainerRuntime.idCompressor to be always available.\n * \"delayed\" - ID compressor bundle is loaded only on establishing of first delta connection, i.e. it does not impact boot of cotnainer.\n * In such mode IContainerRuntime.idCompressor is not made available (unless previous sessions of same document had it \"On\").\n * The only thing that is available is IContainerRuntime.generateDocumentUniqueId() that provides opportunistically short IDs.\n * undefined - ID compressor is not loaded.\n * While IContainerRuntime.generateDocumentUniqueId() is available, it will produce long IDs that are do not compress well.\n *\n * @alpha\n */\nexport type IdCompressorMode = \"on\" | \"delayed\" | undefined;\n\n/**\n * Document schema information.\n * Describes overall shape of document schema, including unknown (to this version) properties.\n *\n * Used by runtime to make a call if it can understand document schema.\n * If it can't, it should not continue with document and immediately fail, preventing random (cryptic) failures\n * down the road and potentially corrupting documents.\n * For now this structure and appropriate interpretation / behavior is focused only on runtime features.\n * In the future that could be interpolated to more areas, including DDSs used, and even possibly - application\n * schema.\n *\n * Runtime will ignore any properties at the root that it does not understand (i.e. IDocumentSchema.app), but will\n * stop (and fail session) on any unknown properties within \"runtime\" sub-tree.\n *\n * In most cases values preserved in the document will not dictate if such features should be enabled in a given session.\n * I.e. if compression is mentioned in document schema, this means that runtime version that opens such document must know\n * how to interpret such ops, but does not need to actually use compression itself. That said, some options could be\n * sticky, i.e. influence feature selection for all runtimes opening a document. ID compression is one such example.\n * Currently there is no mechanism to remove feature from this property bag, i.e. once compression was used, even if it's\n * disabled (through feature gate or code deployment), all existing documents that used compression will continue to fail\n * if opened by clients who do not support compression.\n *\n * For now we are limiting it to just plain properties, and only really simple types, but that can be changed in the future.\n *\n * @alpha\n */\nexport interface IDocumentSchema {\n\t// version that describes how data is stored in this structure.\n\t// If runtime sees a version it does not understand, it should immediately fail and not\n\t// attempt to interpret any further data.\n\tversion: number;\n\n\t// Sequence number when this schema became active.\n\trefSeq: number;\n\n\truntime: Record<string, DocumentSchemaValueType>;\n}\n\n/**\n * Content of the type=ContainerMessageType.DocumentSchemaChange ops.\n * The meaning of refSeq field is different in such messages (compared to other usages of IDocumentSchemaCurrent)\n * ContainerMessageType.DocumentSchemaChange messages use CAS (Compare-and-swap) semantics, and convey\n * regSeq of last known schema change (known to a client proposing schema change).\n * @see ContainerRuntimeDocumentSchemaMessage\n * @alpha\n */\nexport type IDocumentSchemaChangeMessage = IDocumentSchema;\n\n/**\n * Settings that this session would like to have, based on options and feature gates.\n *\n * WARNING: This type is used to infer IDocumentSchemaCurrent type!\n * Any changes here (including renaming of properties) are potentially changing document format and should be considered carefully!\n *\n * @alpha\n */\nexport interface IDocumentSchemaFeatures {\n\t// Tells if client uses legacy behavior of changing schema.\n\t// - Legacy behavior - changing schema without leveraging schema change ops.\n\t// - New behavior - changes in schema require ops and take into affect with delay.\n\texplicitSchemaControl: boolean;\n\tcompressionLz4: boolean;\n\tidCompressorMode: IdCompressorMode;\n\topGroupingEnabled: boolean;\n}\n\n/**\n * Current version known properties that define document schema\n * This must be bumped whenever the format of document schema or protocol for changing the current document schema changes.\n * Ex: adding a new configuration property (under IDocumentSchema.runtime) does not require changing this version.\n * Ex: Changing the 'document schema acceptance' mechanism from convert-and-swap to one requiring consensus does require changing this version.\n * @alpha\n */\nexport const currentDocumentVersionSchema = 1;\n\n/**\n * Current document schema.\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type IDocumentSchemaCurrent = {\n\tversion: 1;\n\trefSeq: number;\n\n\truntime: {\n\t\t[P in keyof IDocumentSchemaFeatures]?: IDocumentSchemaFeatures[P] extends boolean\n\t\t\t? true\n\t\t\t: IDocumentSchemaFeatures[P];\n\t};\n};\n\ninterface IProperty<T = unknown> {\n\tand: (currentDocSchema: T, desiredDocSchema: T) => T;\n\tor: (currentDocSchema: T, desiredDocSchema: T) => T;\n\tvalidate(t: unknown): boolean;\n}\n\nclass TrueOrUndefined implements IProperty<true | undefined> {\n\tpublic and(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn currentDocSchema === true && desiredDocSchema === true ? true : undefined;\n\t}\n\n\tpublic or(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn currentDocSchema === true || desiredDocSchema === true ? true : undefined;\n\t}\n\n\tpublic validate(t: unknown) {\n\t\treturn t === undefined || t === true;\n\t}\n}\n\nclass TrueOrUndefinedMax extends TrueOrUndefined {\n\tpublic and(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn this.or(currentDocSchema, desiredDocSchema);\n\t}\n}\n\nclass MultiChoice implements IProperty<string | undefined> {\n\tconstructor(private readonly choices: string[]) {}\n\n\tpublic and(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\tif (currentDocSchema === undefined || desiredDocSchema === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.choices[\n\t\t\tMath.min(this.choices.indexOf(currentDocSchema), this.choices.indexOf(desiredDocSchema))\n\t\t];\n\t}\n\n\tpublic or(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\tif (currentDocSchema === undefined) {\n\t\t\treturn desiredDocSchema;\n\t\t}\n\t\tif (desiredDocSchema === undefined) {\n\t\t\treturn currentDocSchema;\n\t\t}\n\t\treturn this.choices[\n\t\t\tMath.max(this.choices.indexOf(currentDocSchema), this.choices.indexOf(desiredDocSchema))\n\t\t];\n\t}\n\n\tpublic validate(t: unknown) {\n\t\treturn t === undefined || (typeof t === \"string\" && this.choices.includes(t));\n\t}\n}\n\nclass IdCompressorProperty extends MultiChoice {\n\t// document schema always wins!\n\tpublic and(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\treturn currentDocSchema;\n\t}\n}\n\n/**\n * Helper structure to valida if a schema is compatible with existing code.\n */\nconst documentSchemaSupportedConfigs = {\n\texplicitSchemaControl: new TrueOrUndefinedMax(), // once new behavior shows up, it's sticky\n\tidCompressorMode: new IdCompressorProperty([\"delayed\", \"on\"]),\n\topGroupingEnabled: new TrueOrUndefined(),\n\tcompressionLz4: new TrueOrUndefined(),\n};\n\n/**\n * Checks if a given schema is compatible with current code, i.e. if current code can understand all the features of that schema.\n * If schema is not compatible with current code, it throws an exception.\n * @param documentSchema - current schema\n */\nfunction checkRuntimeCompatibility(documentSchema?: IDocumentSchema) {\n\t// Back-compat - we can't do anything about legacy documents.\n\t// There is no way to validate them, so we are taking a guess that safe deployment processes used by a given app\n\t// do not run into compat problems.\n\tif (documentSchema === undefined) {\n\t\treturn;\n\t}\n\n\tconst msg = \"Document can't be opened with current version of the code\";\n\tif (documentSchema.version !== currentDocumentVersionSchema) {\n\t\tthrow DataProcessingError.create(\n\t\t\tmsg,\n\t\t\t\"checkRuntimeCompat\",\n\t\t\tundefined, // message\n\t\t\t{\n\t\t\t\truntimeSchemaVersion: documentSchema.version,\n\t\t\t\tcurrentRuntimeSchemaVersion: currentDocumentVersionSchema,\n\t\t\t},\n\t\t);\n\t}\n\n\tlet unknownProperty: string | undefined;\n\n\tconst regSeq = documentSchema.refSeq;\n\t// defence in depth - it should not be possible to get here anything other than integer, but worth validating it.\n\tif (typeof regSeq !== \"number\" || regSeq < 0 || !Number.isInteger(regSeq)) {\n\t\tunknownProperty = \"refSeq\";\n\t} else if (documentSchema.runtime === null || typeof documentSchema.runtime !== \"object\") {\n\t\tunknownProperty = \"runtime\";\n\t} else {\n\t\tfor (const [name, value] of Object.entries(documentSchema.runtime)) {\n\t\t\tconst validator = documentSchemaSupportedConfigs[name] as IProperty | undefined;\n\t\t\tif (validator === undefined || !validator.validate(value)) {\n\t\t\t\tunknownProperty = `runtime/${name}`;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (unknownProperty !== undefined) {\n\t\tconst value = documentSchema[unknownProperty];\n\t\tthrow DataProcessingError.create(\n\t\t\tmsg,\n\t\t\t\"checkRuntimeCompat\",\n\t\t\tundefined, // message\n\t\t\t{\n\t\t\t\tcodeVersion: currentDocumentVersionSchema,\n\t\t\t\tproperty: unknownProperty,\n\t\t\t\tvalue,\n\t\t\t},\n\t\t);\n\t}\n}\n\nfunction and(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): IDocumentSchemaCurrent {\n\tconst runtime = {};\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\truntime[key] = (documentSchemaSupportedConfigs[key] as IProperty).and(\n\t\t\tcurrentDocSchema.runtime[key],\n\t\t\tdesiredDocSchema.runtime[key],\n\t\t);\n\t}\n\treturn {\n\t\tversion: currentDocumentVersionSchema,\n\t\trefSeq: currentDocSchema.refSeq,\n\t\truntime,\n\t} as unknown as IDocumentSchemaCurrent;\n}\n\nfunction or(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): IDocumentSchemaCurrent {\n\tconst runtime = {};\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\truntime[key] = (documentSchemaSupportedConfigs[key] as IProperty).or(\n\t\t\tcurrentDocSchema.runtime[key],\n\t\t\tdesiredDocSchema.runtime[key],\n\t\t);\n\t}\n\treturn {\n\t\tversion: currentDocumentVersionSchema,\n\t\trefSeq: currentDocSchema.refSeq,\n\t\truntime,\n\t} as unknown as IDocumentSchemaCurrent;\n}\n\nfunction same(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): boolean {\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\t// If schemas differ only by type of behavior, then we should not send schema change ops!\n\t\tif (\n\t\t\tkey !== \"explicitSchemaControl\" &&\n\t\t\tcurrentDocSchema.runtime[key] !== desiredDocSchema.runtime[key]\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction boolToProp(b: boolean) {\n\treturn b ? true : undefined;\n}\n\n/* eslint-disable jsdoc/check-indentation */\n\n/**\n * Controller of document schema.\n *\n * Recommended pre-reading: https://github.com/microsoft/FluidFramework/blob/main/packages/dds/SchemaVersioning.md\n *\n * This class manages current document schema and transitions between document schemas.\n * At the moment, it only focuses on subset of document schema, specifically - how FluidFramework runtime serializes data\n * (summary and op format), features & capabilities that a version of runtime has to support and understand in\n * order to collaborate on a document.\n * New features that modify document format have to be included in document schema definition.\n * Usage of such features could only happen after document schema has been updated to reflect such feature.\n *\n * This formality allows clients that do not understand such features to fail right away when they observe\n * document schema listing capabilities that such client does not understand.\n * Old clients will fail in predictable way. This allows us to\n * 1) Immediately see such issues and adjust if features are enabled too early, before changes have been saturated.\n * 2) There is no way to get to 100% saturation with new code. Even if we have 99.99% saturation, there are\n * still 0.01% of clients who will fail. Failing early and predictably ensures they have no chance to limp along\n * and potentially corrupt the document. This is especially true for summarizer client, who could simply \"undo\"\n * changes it does not understands.\n *\n * It's important to note how it overlaps with feature gates and safe velocity.\n * If new feature was in use, that resulted in a number of documents referencing such feature in document schema.\n * But, developers (through code deployment or feature gates) could disable usage of such features.\n * That will stop a process of further document schema changes (for documents that were not using such feature).\n * And documents that already list such capability in their schema will continue to do so. Later ensures that old\n * clients who do not understand such feature will continue to fail to open such documents, as such documents very\n * likely contain data in a new format.\n *\n * Users of this class need to use DocumentsSchemaController.sessionSchema to determine what features can be used.\n *\n * There are two modes this class can operate:\n * 1) Legacy mode. In such mode it does not issue any ops to change document schema. Any changes happen implicitly,\n * right away, and new features are available right away\n * 2) Non-legacy mode. In such mode any changes to schema require an op roundtrip. This class will manage such transitions.\n * However code should assume that any new features that were not enabled in a given document will not be available\n * for a given session. That's because this session may never send any ops (including read-only documents). Or it may\n * fail to convert schema.\n * This class promises eventual movement forward. I.e. if new feature is allowed (let's say - through feature gates),\n * then eventually all documents that are modified will have that feature reflected in their schema. It could require\n * multiple reloads / new sessions to get there (depends on if code reacts to schema changes right away, or only consults\n * schema on document load).\n *\n * How schemas are changed (in non-legacy mode):\n * If a client needs to change a schema, it will attempt to do so as part of normal ops sending process.\n * Changes happen in CAS (Compare-and-swap) fashion, i.e. client tells current schema and schema it wants to change to.\n * When a number of clients race to change a schema, then only one of them will win, all others will fail because they will\n * reference old schema that is no longer in effect.\n * Clients can retry, but current implementation is simply - they will not (and will rely on next session / reload to do\n * recalc and decide if schema needs to be changed or not).\n *\n * @alpha\n */\nexport class DocumentsSchemaController {\n\tprivate explicitSchemaControl: boolean;\n\tprivate sendOp = true;\n\n\t// schema coming from document metadata (snapshot we loaded from)\n\tprivate documentSchema: IDocumentSchemaCurrent;\n\n\t// desired schema, based on feature gates / runtime options.\n\t// This includes requests to enable to disable functionality\n\tprivate readonly desiredSchema: IDocumentSchemaCurrent;\n\n\t// OR() of document schema and desired schema. It enables all the features that are enabled in either of schemas.\n\tprivate futureSchema: IDocumentSchemaCurrent | undefined;\n\n\t// Current schema this session operates with.\n\t// 1) Legacy mode: this is same as desired schema - all options that were requested to be on are on, and all options requested to be off are off.\n\t// 2) Non-legacy mode: this is AND() of document schema and desired schema. Only options that are enabled in both are enabled here.\n\t// If there are any options that are not enabled in document schema, but are enabled in desired schema, then attempt to change schema\n\t// (and enable such options) will be made through the session.\n\tpublic sessionSchema: IDocumentSchemaCurrent;\n\n\t/**\n\t * Constructs DocumentsSchemaController that controls current schema and processes around it, including changes in schema.\n\t * @param explicitSchemaControl - Tells if schema changes are done implicitly (without ops - legacy behavior), or go through formal schema change ops process.\n\t * @param existing - Is the document existing document, or a new doc.\n\t * @param documentMetadataSchema - current document's schema, if present.\n\t * @param compressionAlgorithm - desired compression algorith to use\n\t * @param idCompressorModeArg - desired ID compressor mode to use\n\t * @param opGroupingEnabled - true if it's desired to use op grouping.\n\t */\n\tconstructor(\n\t\texisting: boolean,\n\t\tdocumentMetadataSchema: IDocumentSchema | undefined,\n\t\tfeatures: IDocumentSchemaFeatures,\n\t\tprivate readonly onSchemaChange: (schema: IDocumentSchemaCurrent) => void,\n\t) {\n\t\tcheckRuntimeCompatibility(documentMetadataSchema);\n\n\t\tthis.documentSchema =\n\t\t\t(documentMetadataSchema as IDocumentSchemaCurrent) ??\n\t\t\t({\n\t\t\t\tversion: currentDocumentVersionSchema,\n\t\t\t\t// see comment in summarizeDocumentSchema() on why it has to stay zero\n\t\t\t\trefSeq: 0,\n\t\t\t\t// If it's existing document and it has no schema, then it was written by legacy client.\n\t\t\t\t// If it's a new document, then we define it's legacy-related behaviors.\n\t\t\t\truntime: {\n\t\t\t\t\texplicitSchemaControl: boolToProp(!existing && features.explicitSchemaControl),\n\t\t\t\t},\n\t\t\t} satisfies IDocumentSchemaCurrent);\n\n\t\t// Use legacy behavior only if both document and options tell us to use legacy.\n\t\t// Otherwise it's no longer legacy time!\n\t\tthis.explicitSchemaControl =\n\t\t\tthis.documentSchema.runtime.explicitSchemaControl === true ||\n\t\t\tfeatures.explicitSchemaControl;\n\n\t\tthis.desiredSchema = {\n\t\t\tversion: currentDocumentVersionSchema,\n\t\t\trefSeq: this.documentSchema.refSeq,\n\t\t\truntime: {\n\t\t\t\texplicitSchemaControl: boolToProp(features.explicitSchemaControl),\n\t\t\t\tcompressionLz4: boolToProp(features.compressionLz4),\n\t\t\t\tidCompressorMode: features.idCompressorMode,\n\t\t\t\topGroupingEnabled: boolToProp(features.opGroupingEnabled),\n\t\t\t},\n\t\t};\n\n\t\tif (!this.explicitSchemaControl || !existing) {\n\t\t\tthis.sessionSchema = this.desiredSchema;\n\t\t\tassert(\n\t\t\t\tboolToProp(this.explicitSchemaControl) ===\n\t\t\t\t\tthis.sessionSchema.runtime.explicitSchemaControl,\n\t\t\t\t\"explicitSchemaControl\",\n\t\t\t);\n\t\t\tthis.futureSchema = undefined;\n\t\t} else {\n\t\t\tthis.sessionSchema = and(this.documentSchema, this.desiredSchema);\n\t\t\tthis.futureSchema = or(this.documentSchema, this.desiredSchema);\n\t\t\tassert(this.sessionSchema.runtime.explicitSchemaControl === true, \"legacy\");\n\t\t\tassert(this.futureSchema.runtime.explicitSchemaControl === true, \"legacy\");\n\t\t\tif (same(this.documentSchema, this.futureSchema)) {\n\t\t\t\tthis.futureSchema = undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Validate that schema we are operating in is actually a schema we consider compatible with current runtime.\n\t\tcheckRuntimeCompatibility(this.sessionSchema);\n\t\tcheckRuntimeCompatibility(this.futureSchema);\n\t}\n\n\tpublic summarizeDocumentSchema(refSeq: number): IDocumentSchemaCurrent | undefined {\n\t\t// For legacy behavior, we could write nothing (return undefined).\n\t\t// It does not buy us anything, as whatever written in summary does not actually impact clients operating in legacy mode.\n\t\t// But writing current used config (and assuming most of the clients settle on same config over time) will help with transition\n\t\t// out of legacy mode, as clients transitioning out of it would be able to use all the\n\t\t// features that are mentioned in schema right away, without a need to go through schema transition (and thus for a session or\n\t\t// two losing ability to use all the features)\n\n\t\tconst schema = this.explicitSchemaControl ? this.documentSchema : this.desiredSchema;\n\n\t\t// It's important to keep refSeq at zero in legacy mode, such that transition out of it is simple and we do not have\n\t\t// race conditions. If we put any other number (including latest seq number), then we will have two clients\n\t\t// (loading from two different summaries) with different numbers, and eventual consistency will be broken as schema\n\t\t// change ops will be interpretted differently by those two clients.\n\t\tassert(this.explicitSchemaControl || schema.refSeq === 0, \"refSeq should be zero\");\n\n\t\treturn schema;\n\t}\n\n\tpublic onMessageSent(send: (content: IDocumentSchemaChangeMessage) => void) {\n\t\tif (this.sendOp && this.futureSchema !== undefined) {\n\t\t\tassert(\n\t\t\t\tthis.explicitSchemaControl &&\n\t\t\t\t\tthis.futureSchema.runtime.explicitSchemaControl === true,\n\t\t\t\t\"not legacy\",\n\t\t\t);\n\t\t\tsend({\n\t\t\t\t...this.futureSchema,\n\t\t\t\trefSeq: this.documentSchema.refSeq,\n\t\t\t});\n\t\t}\n\t\tthis.sendOp = false;\n\t}\n\n\t/**\n\t * Process document schema change message\n\t * @param content - content of the message\n\t * @param local - whether op is local\n\t * @param sequenceNumber - sequence number of the op\n\t * @returns - true if schema was accepted, otherwise false (rejected due to failed CAS)\n\t */\n\tpublic processDocumentSchemaOp(\n\t\tcontent: IDocumentSchemaChangeMessage,\n\t\tlocal: boolean,\n\t\tsequenceNumber: number,\n\t) {\n\t\tassert(content.refSeq <= this.documentSchema.refSeq, \"did we lose a message somewhere?\");\n\t\tassert(this.documentSchema.refSeq < sequenceNumber, \"time should move forward only!\");\n\t\tif (content.refSeq !== this.documentSchema.refSeq) {\n\t\t\t// CAS failed\n\t\t\treturn false;\n\t\t}\n\n\t\t// This assert should be after checking for successful CAS above.\n\t\t// This will ensure we do not trip on our own messages that are no longer wanted as we processed someone else schema change message.\n\t\tassert(\n\t\t\t!local || (this.explicitSchemaControl && this.futureSchema !== undefined),\n\t\t\t\"not sending ops\",\n\t\t);\n\n\t\t// Changes are in effect. Immediately check that this client understands these changes\n\t\tcheckRuntimeCompatibility(content);\n\n\t\tconst schema: IDocumentSchema = { ...content, refSeq: sequenceNumber };\n\t\tthis.documentSchema = schema as IDocumentSchemaCurrent;\n\t\tthis.sessionSchema = and(this.documentSchema, this.desiredSchema);\n\n\t\t// legacy behavior is automatically off for the document once someone sends a schema op -\n\t\t// from now on it's fully controlled by ops.\n\t\t// This is very important, as summarizeDocumentSchema() should use this new schema!\n\t\tthis.explicitSchemaControl = true;\n\n\t\t// Stop attempting changing schema.\n\t\t// If it was local op, then we succeeded and do not need to try again.\n\t\t// If it was remote op, then some changes happened to schema.\n\t\t// We would need to recalculate this.futureSchema by merging changes that we just received.\n\t\t// Avoid this complexity for now - a new client session (loading from new summary with these changes)\n\t\t// will automatically do this recalculation and will figure out\n\t\tthis.futureSchema = undefined;\n\n\t\tthis.onSchemaChange(this.sessionSchema);\n\n\t\treturn true;\n\t}\n\n\tpublic onDisconnect() {\n\t\tthis.sendOp = true;\n\t}\n}\n\n/* eslint-enable jsdoc/check-indentation */\n"]}
@@ -11,7 +11,8 @@ export { SummarizeHeuristicData, SummarizeHeuristicRunner } from "./summarizerHe
11
11
  export { createRootSummarizerNode, createRootSummarizerNodeWithGC, IRefreshSummaryResult, IRootSummarizerNode, IRootSummarizerNodeWithGC, } from "./summarizerNode/index.js";
12
12
  export { IConnectableRuntime, IGeneratedSummaryStats, IRefreshSummaryAckOptions, ISubmitSummaryOptions, ISummarizeAttempt, ISummarizeHeuristicData, ISummarizer, ISummarizeResults, ISummarizerEvents, ISummarizerInternalsProvider, ISummarizerRuntime, ISummaryCancellationToken, SubmitSummaryResult, SummarizerStopReason, EnqueueSummarizeResult, IAckSummaryResult, IBaseSummarizeResult, IBroadcastSummaryResult, ICancellationToken, IEnqueueSummarizeOptions, IGenerateSummaryTreeResult, INackSummaryResult, IOnDemandSummarizeOptions, ISubmitSummaryOpResult, ISummarizeOptions, ISummarizingWarning, IUploadSummaryResult, SummarizeResultPart, SubmitSummaryFailureData, SummaryStage, IRetriableFailureResult, ISummarizeEventProps, } from "./summarizerTypes.js";
13
13
  export { IAckedSummary, ISummaryCollectionOpEvents, ISummaryOpMessage, SummaryCollection, IClientSummaryWatcher, ISummary, ISummaryAckMessage, ISummaryNackMessage, OpActionEventListener, OpActionEventName, } from "./summaryCollection.js";
14
- export { aliasBlobName, blobsTreeName, chunksBlobName, dataStoreAttributesBlobName, electedSummarizerBlobName, extractSummaryMetadataMessage, getAttributesFormatVersion, getFluidDataStoreAttributes, hasIsolatedChannels, IContainerRuntimeMetadata, ICreateContainerMetadata, ISummaryMetadataMessage, metadataBlobName, nonDataStorePaths, ReadFluidDataStoreAttributes, rootHasIsolatedChannels, WriteFluidDataStoreAttributes, wrapSummaryInChannelsTree, idCompressorBlobName, IdCompressorMode, } from "./summaryFormat.js";
14
+ export { aliasBlobName, blobsTreeName, chunksBlobName, dataStoreAttributesBlobName, electedSummarizerBlobName, extractSummaryMetadataMessage, getAttributesFormatVersion, getFluidDataStoreAttributes, hasIsolatedChannels, IContainerRuntimeMetadata, ICreateContainerMetadata, ISummaryMetadataMessage, metadataBlobName, nonDataStorePaths, ReadFluidDataStoreAttributes, rootHasIsolatedChannels, WriteFluidDataStoreAttributes, wrapSummaryInChannelsTree, idCompressorBlobName, } from "./summaryFormat.js";
15
+ export { IdCompressorMode, IDocumentSchemaCurrent, IDocumentSchema, currentDocumentVersionSchema, DocumentSchemaValueType, DocumentsSchemaController, IDocumentSchemaChangeMessage, IDocumentSchemaFeatures, } from "./documentSchema.js";
15
16
  export { getFailMessage, RetriableSummaryError, SummarizeReason } from "./summaryGenerator.js";
16
17
  export { IConnectedEvents, IConnectedState, ISummaryManagerConfig, SummaryManager, SummaryManagerState, } from "./summaryManager.js";
17
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/summary/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,qBAAqB,GACrB,M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C3B,yBAAyB,EACzB,6BAA6B,EAC7B,0BAA0B,EAC1B,2BAA2B,EAC3B,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,gBAAgB,EAChB,iBAAiB,EACjB,4BAA4B,EAC5B,uBAAuB,EACvB,6BAA6B,EAC7B,yBAAyB,EACzB,oBAAoB,EACpB,gBAAgB,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EACN,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,GACnB,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/summary/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,qBAAqB,GACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mCAAmC,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,EACN,gCAAgC,EAChC,0BAA0B,EAC1B,4BAA4B,GAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACN,yBAAyB,EACzB,+BAA+B,EAC/B,wBAAwB,EACxB,oBAAoB,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC7F,OAAO,EACN,wBAAwB,EACxB,8BAA8B,EAC9B,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB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