@graphrefly/ts 0.0.1 → 0.0.2

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 (330) hide show
  1. package/dist/actions-types-CSC3NMDl.d.ts +657 -0
  2. package/dist/actions-types-wl9Mgkmr.d.cts +657 -0
  3. package/dist/adapters/index.cjs +5157 -2951
  4. package/dist/adapters/index.cjs.map +1 -1
  5. package/dist/adapters/index.d.cts +207 -70
  6. package/dist/adapters/index.d.ts +207 -70
  7. package/dist/adapters/index.js +3738 -1688
  8. package/dist/adapters/index.js.map +1 -1
  9. package/dist/adapters/nestjs/microservices.cjs +841 -0
  10. package/dist/adapters/nestjs/microservices.cjs.map +1 -0
  11. package/dist/adapters/nestjs/microservices.d.cts +45 -0
  12. package/dist/adapters/nestjs/microservices.d.ts +45 -0
  13. package/dist/adapters/nestjs/microservices.js +206 -0
  14. package/dist/adapters/nestjs/microservices.js.map +1 -0
  15. package/dist/adapters/nestjs/native.cjs +1391 -0
  16. package/dist/adapters/nestjs/native.cjs.map +1 -0
  17. package/dist/adapters/nestjs/native.d.cts +111 -0
  18. package/dist/adapters/nestjs/native.d.ts +111 -0
  19. package/dist/adapters/nestjs/native.js +577 -0
  20. package/dist/adapters/nestjs/native.js.map +1 -0
  21. package/dist/adapters/nestjs/websockets.cjs +924 -0
  22. package/dist/adapters/nestjs/websockets.cjs.map +1 -0
  23. package/dist/adapters/nestjs/websockets.d.cts +47 -0
  24. package/dist/adapters/nestjs/websockets.d.ts +47 -0
  25. package/dist/adapters/nestjs/websockets.js +286 -0
  26. package/dist/adapters/nestjs/websockets.js.map +1 -0
  27. package/dist/adapters/nestjs.cjs +1085 -0
  28. package/dist/adapters/nestjs.cjs.map +1 -0
  29. package/dist/adapters/nestjs.d.cts +385 -0
  30. package/dist/adapters/nestjs.d.ts +385 -0
  31. package/dist/adapters/nestjs.js +112 -0
  32. package/dist/adapters/nestjs.js.map +1 -0
  33. package/dist/adapters/observe-storage.d.cts +3 -3
  34. package/dist/adapters/observe-storage.d.ts +3 -3
  35. package/dist/adapters/observe-storage.js +4 -4
  36. package/dist/adapters/react.cjs.map +1 -1
  37. package/dist/adapters/react.d.cts +2 -2
  38. package/dist/adapters/react.d.ts +2 -2
  39. package/dist/adapters/react.js +1 -1
  40. package/dist/adapters/solid.cjs.map +1 -1
  41. package/dist/adapters/solid.d.cts +2 -2
  42. package/dist/adapters/solid.d.ts +2 -2
  43. package/dist/adapters/solid.js +1 -1
  44. package/dist/adapters/svelte.cjs.map +1 -1
  45. package/dist/adapters/svelte.d.cts +2 -2
  46. package/dist/adapters/svelte.d.ts +2 -2
  47. package/dist/adapters/svelte.js +1 -1
  48. package/dist/adapters/vue.cjs.map +1 -1
  49. package/dist/adapters/vue.d.cts +2 -2
  50. package/dist/adapters/vue.d.ts +2 -2
  51. package/dist/adapters/vue.js +1 -1
  52. package/dist/{agent-runtime-DZTJ3C-p.d.cts → agent-runtime-types-core-CaXfKNtY.d.cts} +171 -320
  53. package/dist/{agent-runtime-BesGDZcB.d.ts → agent-runtime-types-core-hU299uIC.d.ts} +171 -320
  54. package/dist/agent-runtime-types-tool-BEpSINol.d.ts +695 -0
  55. package/dist/agent-runtime-types-tool-DninPEzk.d.cts +695 -0
  56. package/dist/agentic-memory-retention-BmGX368S.d.ts +14 -0
  57. package/dist/agentic-memory-retention-Ih1qhX9Z.d.cts +14 -0
  58. package/dist/{agentic-memory-BmRCvh0d.d.ts → agentic-memory-types-CVSUS6XR.d.ts} +13 -57
  59. package/dist/{agentic-memory-DfuVZ-lY.d.cts → agentic-memory-types-FnnYlVUs.d.cts} +13 -57
  60. package/dist/{capability-admission-g0mn9hpq.d.ts → capability-admission-BW2CziT6.d.ts} +3 -3
  61. package/dist/{capability-admission-B0BzqAm5.d.cts → capability-admission-lwSecxXs.d.cts} +3 -3
  62. package/dist/chunk-2KUAG2GZ.js +9693 -0
  63. package/dist/chunk-2KUAG2GZ.js.map +1 -0
  64. package/dist/chunk-2NJP6GO4.js +1320 -0
  65. package/dist/chunk-2NJP6GO4.js.map +1 -0
  66. package/dist/{chunk-YDSIVHRR.js → chunk-4NWSNI4K.js} +1598 -1584
  67. package/dist/chunk-4NWSNI4K.js.map +1 -0
  68. package/dist/{chunk-Z2ANQ6JW.js → chunk-4Q77MMJY.js} +2 -2
  69. package/dist/chunk-6E76H4OU.js +132 -0
  70. package/dist/chunk-6E76H4OU.js.map +1 -0
  71. package/dist/chunk-7GOTIIQ7.js +819 -0
  72. package/dist/chunk-7GOTIIQ7.js.map +1 -0
  73. package/dist/{chunk-IXZBUWSP.js → chunk-7HZRJMN6.js} +2 -2
  74. package/dist/{chunk-SS2A464I.js → chunk-CJIFGJQG.js} +3 -3
  75. package/dist/{chunk-V7CIJE4B.js → chunk-CX6B6PO2.js} +92 -9
  76. package/dist/chunk-CX6B6PO2.js.map +1 -0
  77. package/dist/{chunk-FBUU43PM.js → chunk-E4QCH32M.js} +448 -446
  78. package/dist/chunk-E4QCH32M.js.map +1 -0
  79. package/dist/{chunk-HKK2JD7Z.js → chunk-ECURQ3HD.js} +12 -125
  80. package/dist/chunk-ECURQ3HD.js.map +1 -0
  81. package/dist/{chunk-3JR3EDB2.js → chunk-EOKT4QFF.js} +121 -115
  82. package/dist/chunk-EOKT4QFF.js.map +1 -0
  83. package/dist/{chunk-K3FXTC3I.js → chunk-HJACH5PU.js} +3 -3
  84. package/dist/{chunk-GTPCOEOZ.js → chunk-IDMLXLLG.js} +3 -3
  85. package/dist/{chunk-DKP56CSW.js → chunk-JKAYLDQV.js} +2 -2
  86. package/dist/{chunk-4VLAQHZI.js → chunk-K7FB3JTD.js} +17 -1
  87. package/dist/chunk-K7FB3JTD.js.map +1 -0
  88. package/dist/{chunk-H75VXTGT.js → chunk-L6LDXRWE.js} +3 -3
  89. package/dist/{chunk-H75VXTGT.js.map → chunk-L6LDXRWE.js.map} +1 -1
  90. package/dist/{chunk-YXMZ2N6J.js → chunk-M7J6Z4IJ.js} +1071 -1025
  91. package/dist/chunk-M7J6Z4IJ.js.map +1 -0
  92. package/dist/chunk-MQEQMS7B.js +1009 -0
  93. package/dist/chunk-MQEQMS7B.js.map +1 -0
  94. package/dist/chunk-MTELVIYR.js +1421 -0
  95. package/dist/chunk-MTELVIYR.js.map +1 -0
  96. package/dist/{chunk-QFY4AFY4.js → chunk-PVC7WDKI.js} +58 -52
  97. package/dist/chunk-PVC7WDKI.js.map +1 -0
  98. package/dist/{chunk-VTHLCFN4.js → chunk-RAHNUYA5.js} +2 -2
  99. package/dist/{chunk-XKXWK2KP.js → chunk-SHZDP2MQ.js} +1157 -1021
  100. package/dist/chunk-SHZDP2MQ.js.map +1 -0
  101. package/dist/{chunk-CZNV3VXM.js → chunk-SIDJO2T4.js} +11 -11
  102. package/dist/chunk-STXRMPW4.js +4131 -0
  103. package/dist/chunk-STXRMPW4.js.map +1 -0
  104. package/dist/{chunk-2747WN4Y.js → chunk-TPND5MJS.js} +3 -3
  105. package/dist/chunk-TQPCAIQI.js +612 -0
  106. package/dist/chunk-TQPCAIQI.js.map +1 -0
  107. package/dist/{chunk-43BKLFZU.js → chunk-YDWBXXQZ.js} +10 -10
  108. package/dist/{chunk-6PHB5CJS.js → chunk-ZLFRB6FI.js} +2 -2
  109. package/dist/composition/index.cjs +1228 -1076
  110. package/dist/composition/index.cjs.map +1 -1
  111. package/dist/composition/index.d.cts +3 -3
  112. package/dist/composition/index.d.ts +3 -3
  113. package/dist/composition/index.js +4 -4
  114. package/dist/core/index.cjs +1198 -1046
  115. package/dist/core/index.cjs.map +1 -1
  116. package/dist/core/index.d.cts +1 -1
  117. package/dist/core/index.d.ts +1 -1
  118. package/dist/core/index.js +2 -2
  119. package/dist/cqrs/index.d.cts +3 -3
  120. package/dist/cqrs/index.d.ts +3 -3
  121. package/dist/cqrs/messaging.d.cts +4 -4
  122. package/dist/cqrs/messaging.d.ts +4 -4
  123. package/dist/cqrs/work-queue.d.cts +5 -5
  124. package/dist/cqrs/work-queue.d.ts +5 -5
  125. package/dist/data-structures/index.cjs +1226 -1074
  126. package/dist/data-structures/index.cjs.map +1 -1
  127. package/dist/data-structures/index.d.cts +8 -7
  128. package/dist/data-structures/index.d.ts +8 -7
  129. package/dist/data-structures/index.js +6 -5
  130. package/dist/{describe-BpyJuWkw.d.ts → describe-B_A5fbXH.d.ts} +1 -1
  131. package/dist/{describe-DYMw_l1C.d.cts → describe-CQRrkv-Q.d.cts} +1 -1
  132. package/dist/executors/tool-provider-adapters.cjs +3091 -0
  133. package/dist/executors/tool-provider-adapters.cjs.map +1 -0
  134. package/dist/executors/tool-provider-adapters.d.cts +174 -0
  135. package/dist/executors/tool-provider-adapters.d.ts +174 -0
  136. package/dist/executors/tool-provider-adapters.js +1336 -0
  137. package/dist/executors/tool-provider-adapters.js.map +1 -0
  138. package/dist/executors/tool-provider-runtime.cjs +5178 -0
  139. package/dist/executors/tool-provider-runtime.cjs.map +1 -0
  140. package/dist/executors/tool-provider-runtime.d.cts +17 -0
  141. package/dist/executors/tool-provider-runtime.d.ts +17 -0
  142. package/dist/executors/tool-provider-runtime.js +15 -0
  143. package/dist/executors/tool-provider-runtime.js.map +1 -0
  144. package/dist/executors/tool-provider.cjs +6392 -0
  145. package/dist/executors/tool-provider.cjs.map +1 -0
  146. package/dist/executors/tool-provider.d.cts +60 -0
  147. package/dist/executors/tool-provider.d.ts +60 -0
  148. package/dist/executors/tool-provider.js +89 -0
  149. package/dist/executors/tool-provider.js.map +1 -0
  150. package/dist/executors/work-queue.d.cts +6 -6
  151. package/dist/executors/work-queue.d.ts +6 -6
  152. package/dist/graph/index.cjs +1499 -1341
  153. package/dist/graph/index.cjs.map +1 -1
  154. package/dist/graph/index.d.cts +9 -8
  155. package/dist/graph/index.d.ts +9 -8
  156. package/dist/graph/index.js +23 -22
  157. package/dist/{graph-DCEWh4T2.d.cts → graph-CWK3HLPB.d.cts} +133 -131
  158. package/dist/{graph-D-1-SQeC.d.ts → graph-ho5sotHP.d.ts} +133 -131
  159. package/dist/{index-Bmxeu0nK.d.ts → index-CQWcE0Dw.d.ts} +18 -4
  160. package/dist/{index-72VZC0-E.d.cts → index-DHA1i67c.d.cts} +18 -4
  161. package/dist/index.cjs +3397 -3140
  162. package/dist/index.cjs.map +1 -1
  163. package/dist/index.d.cts +12 -9
  164. package/dist/index.d.ts +12 -9
  165. package/dist/index.js +110 -109
  166. package/dist/inspection/boundary.d.cts +4 -4
  167. package/dist/inspection/boundary.d.ts +4 -4
  168. package/dist/measurements-C0mAvWU1.d.cts +164 -0
  169. package/dist/measurements-OMpCeBwh.d.ts +164 -0
  170. package/dist/messaging/index.cjs +57 -51
  171. package/dist/messaging/index.cjs.map +1 -1
  172. package/dist/messaging/index.d.cts +11 -276
  173. package/dist/messaging/index.d.ts +11 -276
  174. package/dist/messaging/index.js +1 -1
  175. package/dist/operators/index.cjs +1228 -1076
  176. package/dist/operators/index.cjs.map +1 -1
  177. package/dist/operators/index.d.cts +5 -5
  178. package/dist/operators/index.d.ts +5 -5
  179. package/dist/operators/index.js +5 -5
  180. package/dist/orchestration/index.cjs +8844 -6071
  181. package/dist/orchestration/index.cjs.map +1 -1
  182. package/dist/orchestration/index.d.cts +171 -224
  183. package/dist/orchestration/index.d.ts +171 -224
  184. package/dist/orchestration/index.js +42 -991
  185. package/dist/orchestration/index.js.map +1 -1
  186. package/dist/orchestration/messaging.d.cts +5 -8
  187. package/dist/orchestration/messaging.d.ts +5 -8
  188. package/dist/orchestration/work-queue.cjs +1243 -5
  189. package/dist/orchestration/work-queue.cjs.map +1 -1
  190. package/dist/orchestration/work-queue.d.cts +121 -10
  191. package/dist/orchestration/work-queue.d.ts +121 -10
  192. package/dist/orchestration/work-queue.js +1067 -4
  193. package/dist/orchestration/work-queue.js.map +1 -1
  194. package/dist/patterns/event-flow.cjs +6 -20
  195. package/dist/patterns/event-flow.cjs.map +1 -1
  196. package/dist/patterns/event-flow.d.cts +4 -4
  197. package/dist/patterns/event-flow.d.ts +4 -4
  198. package/dist/patterns/event-flow.js +2 -2
  199. package/dist/patterns/index.cjs +453 -465
  200. package/dist/patterns/index.cjs.map +1 -1
  201. package/dist/patterns/index.d.cts +6 -5
  202. package/dist/patterns/index.d.ts +6 -5
  203. package/dist/patterns/index.js +3 -3
  204. package/dist/process-types-C9uMYz3i.d.ts +200 -0
  205. package/dist/process-types-h3uRlzDc.d.cts +200 -0
  206. package/dist/{reactive-collection-DNV0-gFi.d.cts → reactive-collection-B9R0Bl1P.d.cts} +4 -34
  207. package/dist/{reactive-collection-BAmfrGjd.d.ts → reactive-collection-BXFrH0U2.d.ts} +4 -34
  208. package/dist/{reactive-collection-storage-BNEldDyi.d.cts → reactive-collection-storage-BLGv8Xp8.d.cts} +5 -5
  209. package/dist/{reactive-collection-storage-YZsAQsWK.d.ts → reactive-collection-storage-a4zD3665.d.ts} +5 -5
  210. package/dist/{reactive-map-DRD1LJ2H.d.cts → reactive-map-C_8sOfdS.d.cts} +3 -2
  211. package/dist/{reactive-map-EsDiCmJk.d.ts → reactive-map-jle5dnok.d.ts} +3 -2
  212. package/dist/render/index.d.cts +2 -2
  213. package/dist/render/index.d.ts +2 -2
  214. package/dist/scheduled-readiness-5rwQlyjV.d.ts +91 -0
  215. package/dist/scheduled-readiness-DpRY8jI0.d.cts +91 -0
  216. package/dist/semantic-memory-graph-C2ZUwIlq.d.ts +30 -0
  217. package/dist/semantic-memory-graph-DlZBD_Eu.d.cts +30 -0
  218. package/dist/{semantic-memory-graph-DKuNzuWw.d.cts → semantic-memory-graph-types-BvzdqmkY.d.cts} +2 -28
  219. package/dist/{semantic-memory-graph-uwbwJdhe.d.ts → semantic-memory-graph-types-Ci-OtahO.d.ts} +2 -28
  220. package/dist/solutions/index.cjs +6353 -6169
  221. package/dist/solutions/index.cjs.map +1 -1
  222. package/dist/solutions/index.d.cts +12 -10
  223. package/dist/solutions/index.d.ts +12 -10
  224. package/dist/solutions/index.js +5 -5
  225. package/dist/solutions/reactive-layout/browser/index.cjs +116 -108
  226. package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -1
  227. package/dist/solutions/reactive-layout/browser/index.d.cts +4 -4
  228. package/dist/solutions/reactive-layout/browser/index.d.ts +4 -4
  229. package/dist/solutions/reactive-layout/browser/index.js +3 -3
  230. package/dist/solutions/reactive-layout/index.cjs +3578 -3350
  231. package/dist/solutions/reactive-layout/index.cjs.map +1 -1
  232. package/dist/solutions/reactive-layout/index.d.cts +32 -576
  233. package/dist/solutions/reactive-layout/index.d.ts +32 -576
  234. package/dist/solutions/reactive-layout/index.js +65 -5
  235. package/dist/solutions/reactive-layout/node-canvas/index.cjs +127 -117
  236. package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -1
  237. package/dist/solutions/reactive-layout/node-canvas/index.d.cts +4 -4
  238. package/dist/solutions/reactive-layout/node-canvas/index.d.ts +4 -4
  239. package/dist/solutions/reactive-layout/node-canvas/index.js +3 -3
  240. package/dist/solutions/reactive-layout/react-native/index.cjs +127 -117
  241. package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -1
  242. package/dist/solutions/reactive-layout/react-native/index.d.cts +4 -4
  243. package/dist/solutions/reactive-layout/react-native/index.d.ts +4 -4
  244. package/dist/solutions/reactive-layout/react-native/index.js +3 -3
  245. package/dist/solutions/reactive-layout/skia/index.cjs +127 -117
  246. package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -1
  247. package/dist/solutions/reactive-layout/skia/index.d.cts +4 -4
  248. package/dist/solutions/reactive-layout/skia/index.d.ts +4 -4
  249. package/dist/solutions/reactive-layout/skia/index.js +3 -3
  250. package/dist/solutions/work-item/actions.cjs +1609 -1428
  251. package/dist/solutions/work-item/actions.cjs.map +1 -1
  252. package/dist/solutions/work-item/actions.d.cts +23 -184
  253. package/dist/solutions/work-item/actions.d.ts +23 -184
  254. package/dist/solutions/work-item/actions.js +1558 -934
  255. package/dist/solutions/work-item/actions.js.map +1 -1
  256. package/dist/solutions/work-item/scheduling.cjs +9181 -1838
  257. package/dist/solutions/work-item/scheduling.cjs.map +1 -1
  258. package/dist/solutions/work-item/scheduling.d.cts +1763 -328
  259. package/dist/solutions/work-item/scheduling.d.ts +1763 -328
  260. package/dist/solutions/work-item/scheduling.js +117 -3
  261. package/dist/solutions/work-item/work-queue.d.cts +7 -7
  262. package/dist/solutions/work-item/work-queue.d.ts +7 -7
  263. package/dist/sources/browser.cjs +1318 -1083
  264. package/dist/sources/browser.cjs.map +1 -1
  265. package/dist/sources/browser.d.cts +4 -4
  266. package/dist/sources/browser.d.ts +4 -4
  267. package/dist/sources/browser.js +4 -4
  268. package/dist/sources/index.cjs +1318 -1083
  269. package/dist/sources/index.cjs.map +1 -1
  270. package/dist/sources/index.d.cts +4 -4
  271. package/dist/sources/index.d.ts +4 -4
  272. package/dist/sources/index.js +4 -4
  273. package/dist/sources/node.d.cts +3 -3
  274. package/dist/sources/node.d.ts +3 -3
  275. package/dist/storage/browser.cjs +16 -0
  276. package/dist/storage/browser.cjs.map +1 -1
  277. package/dist/storage/browser.js +3 -3
  278. package/dist/storage/index.cjs +16 -0
  279. package/dist/storage/index.cjs.map +1 -1
  280. package/dist/storage/index.d.cts +5 -4
  281. package/dist/storage/index.d.ts +5 -4
  282. package/dist/storage/index.js +6 -6
  283. package/dist/storage/node.cjs +16 -0
  284. package/dist/storage/node.cjs.map +1 -1
  285. package/dist/storage/node.js +3 -3
  286. package/dist/{store-C-joM4gh.d.ts → store-BmtEs9mG.d.ts} +1 -1
  287. package/dist/{store-CNJwmT-h.d.cts → store-PAAsYvML.d.cts} +1 -1
  288. package/dist/types-BRNKoFHj.d.ts +357 -0
  289. package/dist/{types-CcPIn7sy.d.cts → types-BS6CyR-x.d.cts} +27 -108
  290. package/dist/types-BWK2ay3e.d.cts +457 -0
  291. package/dist/types-BXKSAoE1.d.cts +357 -0
  292. package/dist/types-BaPpZItj.d.ts +457 -0
  293. package/dist/types-BhveCMg5.d.cts +274 -0
  294. package/dist/{types-BsJvElYZ.d.ts → types-C9NOgNJw.d.ts} +27 -108
  295. package/dist/types-CTsQ8Ww4.d.ts +274 -0
  296. package/dist/types-DL_05n2M.d.ts +34 -0
  297. package/dist/types-XDoqxYO9.d.cts +34 -0
  298. package/dist/{work-item-runtime-C3M79vE9.d.ts → work-item-runtime-types-BqtWnSCS.d.ts} +3 -93
  299. package/dist/{work-item-runtime-qaVgsL0T.d.cts → work-item-runtime-types-CHO03AKh.d.cts} +3 -93
  300. package/dist/work-queue/index.cjs +957 -953
  301. package/dist/work-queue/index.cjs.map +1 -1
  302. package/dist/work-queue/index.d.cts +9 -357
  303. package/dist/work-queue/index.d.ts +9 -357
  304. package/dist/work-queue/index.js +957 -953
  305. package/dist/work-queue/index.js.map +1 -1
  306. package/package.json +603 -513
  307. package/dist/chunk-3JR3EDB2.js.map +0 -1
  308. package/dist/chunk-4VLAQHZI.js.map +0 -1
  309. package/dist/chunk-6XAIOL3X.js +0 -2407
  310. package/dist/chunk-6XAIOL3X.js.map +0 -1
  311. package/dist/chunk-FBUU43PM.js.map +0 -1
  312. package/dist/chunk-HKK2JD7Z.js.map +0 -1
  313. package/dist/chunk-PC3BTTBE.js +0 -3217
  314. package/dist/chunk-PC3BTTBE.js.map +0 -1
  315. package/dist/chunk-QFY4AFY4.js.map +0 -1
  316. package/dist/chunk-V7CIJE4B.js.map +0 -1
  317. package/dist/chunk-XKXWK2KP.js.map +0 -1
  318. package/dist/chunk-YDSIVHRR.js.map +0 -1
  319. package/dist/chunk-YXMZ2N6J.js.map +0 -1
  320. /package/dist/{chunk-Z2ANQ6JW.js.map → chunk-4Q77MMJY.js.map} +0 -0
  321. /package/dist/{chunk-IXZBUWSP.js.map → chunk-7HZRJMN6.js.map} +0 -0
  322. /package/dist/{chunk-SS2A464I.js.map → chunk-CJIFGJQG.js.map} +0 -0
  323. /package/dist/{chunk-K3FXTC3I.js.map → chunk-HJACH5PU.js.map} +0 -0
  324. /package/dist/{chunk-GTPCOEOZ.js.map → chunk-IDMLXLLG.js.map} +0 -0
  325. /package/dist/{chunk-DKP56CSW.js.map → chunk-JKAYLDQV.js.map} +0 -0
  326. /package/dist/{chunk-VTHLCFN4.js.map → chunk-RAHNUYA5.js.map} +0 -0
  327. /package/dist/{chunk-CZNV3VXM.js.map → chunk-SIDJO2T4.js.map} +0 -0
  328. /package/dist/{chunk-2747WN4Y.js.map → chunk-TPND5MJS.js.map} +0 -0
  329. /package/dist/{chunk-43BKLFZU.js.map → chunk-YDWBXXQZ.js.map} +0 -0
  330. /package/dist/{chunk-6PHB5CJS.js.map → chunk-ZLFRB6FI.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/graph/data-structures/core.ts","../src/graph/data-structures/reactive-index.ts","../src/graph/data-structures/reactive-list.ts","../src/graph/data-structures/reactive-log.ts","../src/graph/data-structures/reactive-map.ts","../src/data-structures/persistence.ts"],"sourcesContent":["/**\n * The shared reactiveCollection core (CSP-2.8, D60).\n *\n * Every reactive data structure (list/map/index/log) is `collectionCore(backend) + a typed method\n * surface` (D60 #5). The core owns the TWO output ports and nothing else:\n *\n * - BACKEND — the single materialized state (D60 #1): a plain mutable object with a monotonic\n * `version` + a `snapshot()`. It applies deltas and IS the materialized state; there is NO ACC\n * node and NO effect bridge re-deriving it (the misdesign D60 rejected — the backend already\n * integrates, its cost is intrinsic). The backend is a closure object, not a graph node, so its\n * durability is structural (survives last-subscriber disconnect; node ROM/RAM is moot, D60 #1).\n *\n * - DELTA port (D60 #2a) — an always-on bare source ({@link CollectionCore.delta}); each mutation\n * pushes ONE change payload (O(1)/mutation). Downstream watches events anytime. It is the\n * structure's BACKBONE: the snapshot node declares it as its dep (D60 reactiveList topology).\n *\n * - SNAPSHOT port (D60 #2b) — a pull-mode node ({@link CollectionCore.snapshot}, R-pull/D269) that\n * is QUIET by default and, on a cone-routed PULL demand, LAZILY reads `backend.snapshot()`\n * (one O(n) materialization) and pushes it once, then re-quiets. The O(n) build happens ONLY on\n * demand — never eagerly per mutation (D60 #2b: lazy is P·O(n), not M·O(n)). It has NO value of\n * its own — its fn reads the backend on demand, so the backend stays the single source of truth\n * (D60 #3). Coalesce-on-no-change is free: the delta-dep's DIRTY/DATA arms the pull node via\n * R-pull's quiet-absorb accounting; a demand with no intervening delta emits no duplicate DATA.\n *\n * Demand path: a downstream consumer issues `ctx.upNext([[\"PULL\", { pullId: core.pullId }]])`\n * (boundary-deferred self-demand, R-up-routing/D269) — it needs the snapshot node upstream in its\n * declared cone, NOT its reference. Cold-start (a demand before any mutation) emits no DATA; for an\n * initial/imperative read use the structure's synchronous quick-read (the deliberately-non-reactive\n * peek, D60) — the reactive pull serves the watch-delta-then-demand pattern.\n *\n * Per-language (D6/D24, never in parity, no conformance — the substrate pull is already C-16).\n */\n\nimport { type Ctx, depBatch } from \"../../ctx/types.js\";\nimport type { Dispatcher } from \"../../dispatcher/index.js\";\nimport { Node, releaseRuntimeOfNode } from \"../../node/node.js\";\nimport { errorPayload } from \"../../protocol/messages.js\";\nimport { type GraphCheckpointJson, registerBackendStateContributor } from \"../checkpoint.js\";\nimport type { Graph } from \"../graph.js\";\nimport type { Operator } from \"../operators.js\";\nimport type { ViewCachePolicy } from \"../policies/types.js\";\n\n/** The materialized-state contract a structure's backend must satisfy (D60 #1). */\nexport interface CollectionBackend<S> {\n\t/** Monotonic mutation counter; advances on every visible state change (idempotency, D49). */\n\treadonly version: number;\n\t/** A fresh defensive materialization of the current state (D60: first-cut defensive copy). */\n\tsnapshot(): S;\n}\n\nexport interface CollectionCoreOptions {\n\t/** Debug/inspection name; the delta/snapshot nodes derive `${name}.delta` / `${name}.snapshot`. */\n\tname?: string;\n\t/** Dispatcher for the core's nodes (default = process-global, D26). */\n\tdispatcher?: Dispatcher;\n\t/** Graph funnel for describe-visible input folds (D61). Required by *From/attach methods. */\n\tgraph?: Graph;\n}\n\nexport interface CollectionCore<S, C> {\n\t/** DELTA backbone (D60 #2a): a bare source; every {@link CollectionCore.emit} pushes one change. */\n\treadonly delta: Node<C>;\n\t/** SNAPSHOT pull node (D60 #2b): demand via `ctx.upNext([[\"PULL\", { pullId }]])`; lazy O(n) on demand. */\n\treadonly snapshot: Node<S>;\n\t/** The snapshot node's pullId — the author writes it verbatim into the demander's fn (D269). */\n\treadonly pullId: symbol;\n\t/** Push one delta event (the imperative path: a method mutates the backend, then calls this). */\n\temit(change: C): void;\n\t/**\n\t * D54 widening: fold an in-graph producer `src` into the backend. `apply` mutates the backend +\n\t * `emit`s the change(s). The folder is a DECLARED-dep node (describe shows `src → folder`, NOT a\n\t * D45 island); its emit is the structure's plumbing (D54-sanctioned). Returns a disposer.\n\t */\n\tbindSource<V>(src: Node<V>, apply: (value: V) => void): () => void;\n}\n\n/**\n * Public D121 collection-view surface. A view is a derived surface: `delta` is the pushed update\n * port, `snapshot` is a lazy pull node, and neither port is writable authority.\n */\nexport interface ReactiveView<C, S> {\n\t/** Derived DELTA/update stream for the view. For light views this is recomputed from the parent backend. */\n\treadonly delta: Node<C>;\n\t/** Derived SNAPSHOT pull node: demand via `pullId` to materialize the current view. */\n\treadonly snapshot: Node<S>;\n\t/** The snapshot node's pullId (R-pull/D269), minted per view instance. */\n\treadonly pullId: symbol;\n\t/** Release memoized/light-view resources owned by the parent collection. */\n\tdispose(): void;\n}\n\ninterface LightReactiveViewOptions<S> extends CollectionCoreOptions {\n\treadonly factory: string;\n\treadonly materializeSnapshot: () => S;\n\treadonly onDispose?: () => void;\n}\n\ninterface CollectionRestoreSpec {\n\treadonly deltaRef: string;\n\treadonly snapshotRef: string;\n\treadonly config?: GraphCheckpointJson;\n\treadonly backendState: () => unknown;\n}\n\nfunction validateViewCacheMaxEntries(policy: ViewCachePolicy | undefined): number | undefined {\n\tconst maxEntries = policy?.maxEntries;\n\tif (maxEntries === undefined) return undefined;\n\tif (!Number.isInteger(maxEntries) || maxEntries < 0) {\n\t\tthrow new RangeError(`viewCache.maxEntries must be a non-negative integer (got ${maxEntries})`);\n\t}\n\treturn maxEntries;\n}\n\n/**\n * Internal D80 memo manager for derived views. Eviction drops only the structure's memo lookup;\n * returned ReactiveView handles remain live until explicitly disposed or their parent releases all\n * live views.\n */\nexport class ViewMemoCache<K, V extends { dispose(): void }> {\n\tprivate readonly maxEntries: number | undefined;\n\tprivate readonly equals: (a: K, b: K) => boolean;\n\tprivate readonly memo: Array<{ key: K; value: V }> = [];\n\tprivate readonly live = new Set<V>();\n\n\tconstructor(policy: ViewCachePolicy | undefined, equals: (a: K, b: K) => boolean = Object.is) {\n\t\tthis.maxEntries = validateViewCacheMaxEntries(policy);\n\t\tthis.equals = equals;\n\t}\n\n\tget(key: K): V | undefined {\n\t\tconst index = this.memo.findIndex((entry) => this.equals(entry.key, key));\n\t\tif (index < 0) return undefined;\n\t\tconst [entry] = this.memo.splice(index, 1);\n\t\tif (entry === undefined) return undefined;\n\t\tthis.memo.push(entry);\n\t\treturn entry.value;\n\t}\n\n\tset(key: K, value: V): void {\n\t\tthis.deleteValue(value);\n\t\tthis.live.add(value);\n\t\tif (this.maxEntries === 0) return;\n\t\tthis.memo.push({ key, value });\n\t\twhile (this.maxEntries !== undefined && this.memo.length > this.maxEntries) {\n\t\t\tthis.memo.shift();\n\t\t}\n\t}\n\n\tdeleteValue(value: V): void {\n\t\tfor (let i = this.memo.length - 1; i >= 0; i -= 1) {\n\t\t\tif (this.memo[i]?.value === value) this.memo.splice(i, 1);\n\t\t}\n\t\tthis.live.delete(value);\n\t}\n\n\tdisposeAll(): void {\n\t\tfor (const view of [...this.live]) view.dispose();\n\t\tthis.memo.length = 0;\n\t\tthis.live.clear();\n\t}\n}\n\n/**\n * Build a D121 first-cut light view. The view declares `parent.delta -> view.delta ->\n * view.snapshot`; the pushed `delta` forwards parent delta events as the view's arm/update stream,\n * while `snapshot` reads the parent collection backend through the supplied materializer on demand.\n * No writable state/cache is exposed (D120).\n */\nexport function lightReactiveView<C, S>(\n\tparentDelta: Node<unknown>,\n\topts: LightReactiveViewOptions<S>,\n): ReactiveView<C, S> {\n\tconst { dispatcher, factory, graph, materializeSnapshot, name, onDispose } = opts;\n\tconst base = dispatcher ? { dispatcher } : {};\n\tconst group = graph?.topologyGroup({ name: name ?? factory });\n\tconst deltaBody = (ctx: Ctx): void => {\n\t\tfor (const change of (depBatch(ctx, 0) ?? []) as readonly C[]) {\n\t\t\tctx.down([[\"DATA\", change]]);\n\t\t}\n\t};\n\tconst delta = group\n\t\t? group.node<C>([parentDelta], deltaBody, {\n\t\t\t\tfactory: `${factory}.delta`,\n\t\t\t\tname: name ? `${name}.delta` : undefined,\n\t\t\t\tmeta: { kind: \"collection_view_delta\", factory },\n\t\t\t\tpartial: true,\n\t\t\t})\n\t\t: new Node<C>([parentDelta], deltaBody, {\n\t\t\t\t...base,\n\t\t\t\tfactory: `${factory}.delta`,\n\t\t\t\tname: name ? `${name}.delta` : undefined,\n\t\t\t\tpartial: true,\n\t\t\t});\n\n\tconst pullId = Symbol(name ? `${name}.snapshot` : `${factory}.snapshot`);\n\tconst snapshotBody = (ctx: Ctx): void => {\n\t\ttry {\n\t\t\tctx.down([[\"DATA\", materializeSnapshot()]]);\n\t\t} catch (e) {\n\t\t\tctx.down([[\"ERROR\", errorPayload(e, `${factory}.snapshot materializer failed`)]]);\n\t\t}\n\t};\n\tconst snapshot = group\n\t\t? group.node<S>([delta as Node<unknown>], snapshotBody, {\n\t\t\t\tfactory: `${factory}.snapshot`,\n\t\t\t\tname: name ? `${name}.snapshot` : undefined,\n\t\t\t\tmeta: { kind: \"collection_view_snapshot\", factory },\n\t\t\t\tpartial: true,\n\t\t\t\tpullId,\n\t\t\t})\n\t\t: new Node<S>([delta as Node<unknown>], snapshotBody, {\n\t\t\t\t...base,\n\t\t\t\tfactory: `${factory}.snapshot`,\n\t\t\t\tname: name ? `${name}.snapshot` : undefined,\n\t\t\t\tpartial: true,\n\t\t\t\tpullId,\n\t\t\t});\n\n\tlet disposed = false;\n\treturn {\n\t\tdelta,\n\t\tsnapshot,\n\t\tpullId,\n\t\tdispose(): void {\n\t\t\tif (disposed) return;\n\t\t\tif (group) {\n\t\t\t\tgroup.release({ reason: factory });\n\t\t\t} else {\n\t\t\t\treleaseRuntimeOfNode(delta as Node<unknown>);\n\t\t\t\treleaseRuntimeOfNode(snapshot as Node<unknown>);\n\t\t\t}\n\t\t\tdisposed = true;\n\t\t\tonDispose?.();\n\t\t},\n\t};\n}\n\n/**\n * Build the shared core for a reactive structure (D60). `factory` names the nodes for describe\n * (D6/D51 auto-discovery). The structure passes its `backend` (any {@link CollectionBackend}) and\n * layers a typed method surface on top.\n */\nexport function collectionCore<S, C>(\n\tbackend: CollectionBackend<S>,\n\tfactory: string,\n\topts: CollectionCoreOptions = {},\n\trestore?: CollectionRestoreSpec,\n): CollectionCore<S, C> {\n\tconst { name, dispatcher, graph } = opts;\n\tconst base: { dispatcher?: Dispatcher } = dispatcher ? { dispatcher } : {};\n\tlet bindSeq = 0;\n\n\t// DELTA backbone: a bare source (D60 #2a / review #2 — node([], null), no `initial`, so a late\n\t// subscriber gets no fake \"initial change\"; state is the snapshot port's job).\n\tconst delta = graph\n\t\t? graph.node<C>([], null, {\n\t\t\t\tfactory: `${factory}.delta`,\n\t\t\t\tname: name ? `${name}.delta` : undefined,\n\t\t\t\tmeta: { kind: \"collection_delta\", collection: factory },\n\t\t\t\t...(restore ? { restore: { ref: restore.deltaRef, config: restore.config } } : {}),\n\t\t\t})\n\t\t: new Node<C>([], null, {\n\t\t\t\t...base,\n\t\t\t\tfactory: `${factory}.delta`,\n\t\t\t\tname: name ? `${name}.delta` : undefined,\n\t\t\t});\n\n\t// SNAPSHOT pull node: dep=[delta] (the backbone arms it via quiet-absorb so coalesce is free,\n\t// D60). The fn IGNORES the delta value — it reads `backend.snapshot()` on demand (D60 #3). The\n\t// pullId is a unique Symbol (R-pull/D269: matched by identity, zero collision with pause locks).\n\t// `partial:true`: the fn does not need the delta's value, so it must not gate on \"all deps\n\t// settled\" — it fires whenever armed (a mutation since the last delivery).\n\tconst pullId = Symbol(name ? `${name}.snapshot` : `${factory}.snapshot`);\n\tlet deliveredVersion = backend.version;\n\tconst snapFn = (ctx: Ctx): void => {\n\t\tif (ctx.pull !== undefined && backend.version === deliveredVersion) return;\n\t\tdeliveredVersion = backend.version;\n\t\tctx.down([[\"DATA\", backend.snapshot()]]);\n\t};\n\tconst snapshot = graph\n\t\t? graph.node<S>([delta as Node<unknown>], snapFn, {\n\t\t\t\tpullId,\n\t\t\t\tpartial: true,\n\t\t\t\tfactory: `${factory}.snapshot`,\n\t\t\t\tname: name ? `${name}.snapshot` : undefined,\n\t\t\t\tmeta: { kind: \"collection_snapshot\", collection: factory },\n\t\t\t\t...(restore ? { restore: { ref: restore.snapshotRef, config: restore.config } } : {}),\n\t\t\t})\n\t\t: new Node<S>([delta as Node<unknown>], snapFn, {\n\t\t\t\t...base,\n\t\t\t\tpullId,\n\t\t\t\tpartial: true,\n\t\t\t\tfactory: `${factory}.snapshot`,\n\t\t\t\tname: name ? `${name}.snapshot` : undefined,\n\t\t\t});\n\n\tif (restore !== undefined) {\n\t\tregisterBackendStateContributor(delta as Node<unknown>, restore.backendState);\n\t}\n\n\tfunction emit(change: C): void {\n\t\t// External tier-3 emit → the substrate synthesizes the leading DIRTY (R-dirty-before-data),\n\t\t// which the quiet snapshot node absorbs (R-pull) and uses to arm its next demand delivery.\n\t\tdelta.down([[\"DATA\", change]]);\n\t}\n\n\tfunction bindSource<V>(src: Node<V>, apply: (value: V) => void): () => void {\n\t\tif (graph === undefined)\n\t\t\tthrow new Error(\n\t\t\t\t\"collectionCore.bindSource requires options.graph so the input fold is describe-visible (D61)\",\n\t\t\t);\n\t\t// A graph-bound declared-dep folder (effect-shaped): reads each src batch value, applies it\n\t\t// to the backend (apply mutates + emits the delta). src → folder is a real edge describe\n\t\t// shows (D54/D61), not an internal subscribe island.\n\t\tconst op: Operator<V, void> = {\n\t\t\tfactory: `${factory}.bindSource`,\n\t\t\tbody: (ctx: Ctx) => {\n\t\t\t\tconst b = depBatch(ctx, 0);\n\t\t\t\ttry {\n\t\t\t\t\tif (b) for (const v of b) apply(v as V);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"collectionCore.bindSource failed\")]]);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tconst folder = graph.initNode(op, [src], {\n\t\t\tname: name ? `${name}.bind#${bindSeq++}` : undefined,\n\t\t\tmeta: { kind: \"collection_bind_source\", collection: factory },\n\t\t});\n\t\treturn graph.retain(folder, { reason: `${factory}.bindSource` });\n\t}\n\n\treturn { delta, snapshot, pullId, emit, bindSource };\n}\n","/**\n * Reactive dual-key index (CSP-2.8, D54/D60) — unique primary key, rows sorted by (secondary, primary).\n *\n * Shape = the shared {@link collectionCore} two ports over a sorted-array + parallel-Map BACKEND\n * (D60). The SNAPSHOT port delivers the ordered `IndexRow[]`. Secondary/reverse lookup = \"Z\"\n * (review #4): `has`/`get`/`rangeByPrimary` are SYNCHRONOUS point-reads over the backend's parallel\n * Map (NOT topology, like `.cache`); `byPrimary` is an OPTIONAL reactive derived over the delta\n * backbone (a pushed primary→value map), LAZILY created on first access (no default keepalive,\n * R-rom-ram). The two coexist: the derived is the reactive reverse-lookup port; the sync reads are\n * the point query.\n *\n * Per-language (D6/D24, never in parity, no conformance — the substrate pull is already C-16).\n */\n\nimport { type Ctx, depBatch, depCount, depLatest } from \"../../ctx/types.js\";\nimport { Node, node } from \"../../node/node.js\";\nimport { errorPayload } from \"../../protocol/messages.js\";\nimport type { Operator } from \"../operators.js\";\nimport type { OrderedCapacityPolicy, ReactiveOpt, ViewCachePolicy } from \"../policies/types.js\";\nimport type { IndexChange } from \"./change.js\";\nimport {\n\ttype CollectionCore,\n\ttype CollectionCoreOptions,\n\tcollectionCore,\n\tlightReactiveView,\n\ttype ReactiveView,\n\tViewMemoCache,\n} from \"./core.js\";\n\nexport type ReactiveIndexOpt<T> = ReactiveOpt<T>;\nexport type ReactiveIndexCapacityOrder = \"secondary\" | \"primary\" | \"lru\";\n\nexport interface ReactiveIndexCapacityPolicy\n\textends OrderedCapacityPolicy<ReactiveIndexCapacityOrder> {}\n\nexport interface ReactiveIndexOptions extends CollectionCoreOptions {\n\t/**\n\t * D73 explicit capacity policy: no implicit eviction default.\n\t * `order` chooses eviction semantics and `maxSize` may be static or node-valued (D68).\n\t */\n\treadonly capacity?: ReactiveIndexCapacityPolicy;\n\t/** Static D80 memo policy for D121 light views. Eviction does not dispose returned views. */\n\treadonly viewCache?: ViewCachePolicy;\n}\n\nexport interface IndexRow<K, V = unknown> {\n\treadonly primary: K;\n\treadonly secondary: unknown;\n\treadonly value: V;\n}\n\nexport interface ReactiveIndex<K, V = unknown> {\n\treadonly delta: Node<IndexChange<K, V>>;\n\t/** SNAPSHOT pull node: demand → rows sorted by (secondary, primary) (lazy O(n)). */\n\treadonly snapshot: Node<readonly IndexRow<K, V>[]>;\n\treadonly pullId: symbol;\n\t/** Row count (O(1)). Sync non-reactive read. */\n\treadonly size: number;\n\t/** O(1) primary-key existence. Sync read (Z). */\n\thas(primary: K): boolean;\n\t/** O(1) value lookup by primary key. Sync read (Z). */\n\tget(primary: K): V | undefined;\n\t/** Values whose primary sorts within `[start, end)`, ascending primary order. Sync read (Z). */\n\trangeByPrimary(start: K, end: K): V[];\n\t/**\n\t * D121 light range view over the primary axis. `delta` forwards parent index mutations, and\n\t * `snapshot` is a pull node that materializes the current range on demand.\n\t */\n\trange(start: K, end: K): ReactiveView<IndexChange<K, V>, readonly V[]>;\n\t/** Ordered rows (fresh copy). Sync non-reactive read (cold-start peek). */\n\ttoArray(): readonly IndexRow<K, V>[];\n\t/** Primary→value map (fresh copy). Sync non-reactive read. */\n\ttoPrimaryMap(): ReadonlyMap<K, V>;\n\t/**\n\t * OPTIONAL reactive reverse-lookup port (Z): a derived primary→value map, pushed on every\n\t * mutation. Lazily created on first access (no keepalive — live only while subscribed). Use the\n\t * synchronous {@link ReactiveIndex.get} for a one-shot point query.\n\t */\n\treadonly byPrimary: Node<ReadonlyMap<K, V>>;\n\t/** Insert/replace a row. Returns `true` if a NEW row was inserted (primary was absent). */\n\tupsert(primary: K, secondary: unknown, value: V): boolean;\n\t/** Bulk upsert; one delta per row. No-op if empty. */\n\tupsertMany(rows: Iterable<{ primary: K; secondary: unknown; value: V }>): void;\n\tdelete(primary: K): void;\n\t/** Bulk delete; one delta event. No-op if nothing removed. */\n\tdeleteMany(primaries: Iterable<K>): void;\n\tclear(): void;\n\t/** D54 widening: every row from `src` is upserted. Returns a disposer. */\n\tupsertFrom(src: Node<{ primary: K; secondary: unknown; value: V }>): () => void;\n\tdispose(): void;\n}\n\n// ── ordering helpers (pure; backend-internal) ──\nfunction cmpOrd(a: unknown, b: unknown): number {\n\tif (a === b) return 0;\n\tconst ta = typeof a;\n\tif (\n\t\tta === typeof b &&\n\t\t(ta === \"number\" || ta === \"string\" || ta === \"boolean\" || ta === \"bigint\")\n\t) {\n\t\tconst ax = a as number | string;\n\t\tconst bx = b as number | string;\n\t\treturn ax < bx ? -1 : ax > bx ? 1 : 0;\n\t}\n\treturn String(a).localeCompare(String(b));\n}\nfunction compareRows<K, V>(a: IndexRow<K, V>, b: IndexRow<K, V>): number {\n\tconst c = cmpOrd(a.secondary, b.secondary);\n\treturn c !== 0 ? c : cmpOrd(a.primary, b.primary);\n}\nfunction bisectLeft<K, V>(rows: readonly IndexRow<K, V>[], row: IndexRow<K, V>): number {\n\tlet lo = 0;\n\tlet hi = rows.length;\n\twhile (lo < hi) {\n\t\tconst mid = (lo + hi) >> 1;\n\t\tif (compareRows(rows[mid] as IndexRow<K, V>, row) < 0) lo = mid + 1;\n\t\telse hi = mid;\n\t}\n\treturn lo;\n}\n\n/** Default sorted-array + parallel-Map backend (D60 first-cut; B-tree/persistent backend deferred). */\nclass IndexBackend<K, V> {\n\tprivate _version = 0;\n\tprivate readonly buf: IndexRow<K, V>[] = [];\n\tprivate readonly byKey = new Map<K, IndexRow<K, V>>();\n\tprivate readonly trackLru: boolean;\n\n\tconstructor(trackLru: boolean, initialRows: readonly IndexRow<K, V>[] = []) {\n\t\tthis.trackLru = trackLru;\n\t\tfor (const row of initialRows) {\n\t\t\tthis.upsert(row.primary, row.secondary, row.value);\n\t\t}\n\t\tthis._version = 0;\n\t}\n\n\tget version(): number {\n\t\treturn this._version;\n\t}\n\tget size(): number {\n\t\treturn this.buf.length;\n\t}\n\thas(primary: K): boolean {\n\t\tconst row = this.byKey.get(primary);\n\t\tif (row === undefined) return false;\n\t\tthis.touchLru(row);\n\t\treturn true;\n\t}\n\tget(primary: K): V | undefined {\n\t\tconst row = this.byKey.get(primary);\n\t\tif (row === undefined) return undefined;\n\t\tthis.touchLru(row);\n\t\treturn row.value;\n\t}\n\n\tprivate touchLru(row: IndexRow<K, V>): void {\n\t\tif (!this.trackLru) return;\n\t\tthis.byKey.delete(row.primary);\n\t\tthis.byKey.set(row.primary, row);\n\t}\n\n\tprivate removeRow(row: IndexRow<K, V>): void {\n\t\tconst start = bisectLeft(this.buf, row);\n\t\tfor (\n\t\t\tlet i = start;\n\t\t\ti < this.buf.length && compareRows(this.buf[i] as IndexRow<K, V>, row) === 0;\n\t\t\ti++\n\t\t) {\n\t\t\tif (this.buf[i] === row) {\n\t\t\t\tthis.buf.splice(i, 1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tconst fallback = this.buf.indexOf(row);\n\t\tif (fallback >= 0) {\n\t\t\tthis.buf.splice(fallback, 1);\n\t\t\treturn;\n\t\t}\n\t\tthrow new Error(\"reactiveIndex: internal row index desynchronized\");\n\t}\n\n\tupsert(primary: K, secondary: unknown, value: V): boolean {\n\t\tconst existing = this.byKey.get(primary);\n\t\tconst row: IndexRow<K, V> = { primary, secondary, value };\n\t\tif (existing !== undefined) {\n\t\t\tthis.removeRow(existing);\n\t\t\tthis.byKey.delete(primary);\n\t\t}\n\t\tthis.buf.splice(bisectLeft(this.buf, row), 0, row);\n\t\tthis.byKey.set(primary, row);\n\t\tthis._version += 1;\n\t\treturn existing === undefined;\n\t}\n\n\tdelete(primary: K): boolean {\n\t\tconst existing = this.byKey.get(primary);\n\t\tif (existing === undefined) return false;\n\t\tthis.removeRow(existing);\n\t\tthis.byKey.delete(primary);\n\t\tthis._version += 1;\n\t\treturn true;\n\t}\n\n\tclear(): number {\n\t\tconst n = this.buf.length;\n\t\tif (n === 0) return 0;\n\t\tthis.buf.length = 0;\n\t\tthis.byKey.clear();\n\t\tthis._version += 1;\n\t\treturn n;\n\t}\n\n\trangeByPrimary(start: K, end: K): V[] {\n\t\tif (cmpOrd(start, end) >= 0) return [];\n\t\tconst rows = [...this.byKey.entries()].filter(\n\t\t\t([p]) => cmpOrd(p, start) >= 0 && cmpOrd(p, end) < 0,\n\t\t);\n\t\trows.sort(([a], [b]) => cmpOrd(a, b));\n\t\treturn rows.map(([, r]) => r.value);\n\t}\n\n\tevictOneForCapacity(order: ReactiveIndexCapacityOrder, maxSize?: number): K | undefined {\n\t\tif (maxSize === undefined) return undefined;\n\t\tif (!Number.isInteger(maxSize) || maxSize < 1)\n\t\t\tthrow new RangeError(`reactiveIndex: maxSize must be a positive integer (got ${maxSize})`);\n\t\tconst overflow = this.buf.length - maxSize;\n\t\tif (overflow <= 0) return undefined;\n\n\t\tswitch (order) {\n\t\t\tcase \"secondary\": {\n\t\t\t\tconst row = this.buf[0] as IndexRow<K, V> | undefined;\n\t\t\t\tif (row === undefined) return undefined;\n\t\t\t\tthis.buf.shift();\n\t\t\t\tthis.byKey.delete(row.primary);\n\t\t\t\tthis._version += 1;\n\t\t\t\treturn row.primary;\n\t\t\t}\n\t\t\tcase \"primary\": {\n\t\t\t\tlet victim: K | undefined;\n\t\t\t\tfor (const key of this.byKey.keys()) {\n\t\t\t\t\tif (victim === undefined || cmpOrd(key, victim) < 0) victim = key;\n\t\t\t\t}\n\t\t\t\tif (victim === undefined) return undefined;\n\t\t\t\tconst row = this.byKey.get(victim);\n\t\t\t\tif (row !== undefined) this.removeRow(row);\n\t\t\t\tthis.byKey.delete(victim);\n\t\t\t\tthis._version += 1;\n\t\t\t\treturn victim;\n\t\t\t}\n\t\t\tcase \"lru\": {\n\t\t\t\tconst oldest = this.byKey.keys().next().value as K | undefined;\n\t\t\t\tif (oldest === undefined) return undefined;\n\t\t\t\tconst row = this.byKey.get(oldest);\n\t\t\t\tif (row !== undefined) this.removeRow(row);\n\t\t\t\tthis.byKey.delete(oldest);\n\t\t\t\tthis._version += 1;\n\t\t\t\treturn oldest;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`reactiveIndex: unknown capacity order '${String(order)}'`);\n\t\t\t}\n\t\t}\n\t}\n\n\tsnapshot(): readonly IndexRow<K, V>[] {\n\t\treturn [...this.buf];\n\t}\n\ttoPrimaryMap(): ReadonlyMap<K, V> {\n\t\tconst m = new Map<K, V>();\n\t\tfor (const r of this.buf) m.set(r.primary, r.value);\n\t\treturn m;\n\t}\n}\n\nfunction assertCheckpointableIndexRows(rows: readonly IndexRow<unknown, unknown>[]): void {\n\tfor (const [i, row] of rows.entries()) {\n\t\tconst primary = row.primary;\n\t\tif (\n\t\t\tprimary === null ||\n\t\t\ttypeof primary === \"string\" ||\n\t\t\ttypeof primary === \"number\" ||\n\t\t\ttypeof primary === \"boolean\"\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tthrow new TypeError(\n\t\t\t`reactiveIndex checkpoint backendState[${i}].primary must be a JSON primitive primary key for D160 restore`,\n\t\t);\n\t}\n}\n\n/**\n * Create a reactive dual-key index (D54/D60). DELTA + lazy pull SNAPSHOT + pullId via\n * {@link collectionCore}; this layer adds the sorted backend + Z reverse-lookup surface.\n */\nexport function reactiveIndex<K, V = unknown>(\n\toptions: ReactiveIndexOptions = {},\n): ReactiveIndex<K, V> {\n\treturn createReactiveIndex(options);\n}\n\n/** @internal D160 restore path: seed the backend without replaying public deltas. */\nexport function restoreReactiveIndexFromBackendState<K, V = unknown>(\n\tinitialRows: readonly IndexRow<K, V>[],\n\toptions: ReactiveIndexOptions = {},\n): ReactiveIndex<K, V> {\n\treturn createReactiveIndex(options, initialRows);\n}\n\nfunction createReactiveIndex<K, V = unknown>(\n\toptions: ReactiveIndexOptions = {},\n\tinitialRows: readonly IndexRow<K, V>[] = [],\n): ReactiveIndex<K, V> {\n\tconst { capacity, graph, dispatcher, name } = options;\n\tconst lruEnabled = capacity?.order === \"lru\";\n\tconst backend = new IndexBackend<K, V>(lruEnabled, initialRows);\n\tconst core: CollectionCore<readonly IndexRow<K, V>[], IndexChange<K, V>> = collectionCore(\n\t\tbackend,\n\t\t\"reactiveIndex\",\n\t\toptions,\n\t\tgraph !== undefined && name !== undefined && capacity === undefined\n\t\t\t? {\n\t\t\t\t\tdeltaRef: \"reactiveIndex.delta\",\n\t\t\t\t\tsnapshotRef: \"reactiveIndex.snapshot\",\n\t\t\t\t\tbackendState: () => {\n\t\t\t\t\t\tconst rows = backend.snapshot();\n\t\t\t\t\t\tassertCheckpointableIndexRows(rows);\n\t\t\t\t\t\treturn rows;\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: undefined,\n\t);\n\tconst binds: Array<() => void> = [];\n\tconst base = dispatcher ? { dispatcher } : {};\n\tconst bindDeps = new WeakSet<Node<unknown>>();\n\tconst rangeMemo = new ViewMemoCache<\n\t\treadonly [K, K],\n\t\tReactiveView<IndexChange<K, V>, readonly V[]>\n\t>(options.viewCache, ([aStart, aEnd], [bStart, bEnd]) => {\n\t\treturn cmpOrd(aStart, bStart) === 0 && cmpOrd(aEnd, bEnd) === 0;\n\t});\n\tlet bindSeq = 0;\n\tlet rangeSeq = 0;\n\tlet capacityPolicy: Node<number> | undefined;\n\tlet apply: Node<IndexChange<K, V>> | undefined;\n\tlet releaseApply = () => {};\n\n\tfunction isNodeOpt<T>(x: ReactiveIndexOpt<T>): x is Node<T> {\n\t\treturn x instanceof Node;\n\t}\n\n\tfunction validateMaxSize(v: number): number {\n\t\tif (!Number.isFinite(v) || !Number.isInteger(v) || v < 1)\n\t\t\tthrow new RangeError(`reactiveIndex: maxSize must be a positive integer (got ${v})`);\n\t\treturn v;\n\t}\n\n\tfunction enforceCapacity(): void {\n\t\tif (currentCapacityOrder === undefined) return;\n\t\tfor (;;) {\n\t\t\tconst primary = backend.evictOneForCapacity(currentCapacityOrder, currentMaxSize);\n\t\t\tif (primary === undefined) return;\n\t\t\tcore.emit({ kind: \"delete\", primary });\n\t\t}\n\t}\n\n\tconst applyBody = (ctx: Ctx): void => {\n\t\tconst deps = apply?.deps ?? [];\n\t\tfor (let i = 0; i < depCount(ctx); i++) {\n\t\t\tconst dep = deps[i];\n\t\t\tif (dep === capacityPolicy) {\n\t\t\t\tconst latest = depLatest(ctx, i);\n\t\t\t\tif (latest !== undefined) currentMaxSize = validateMaxSize(latest as number);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (dep && bindDeps.has(dep)) {\n\t\t\t\tfor (const r of (depBatch(ctx, i) ?? []) as readonly {\n\t\t\t\t\tprimary: K;\n\t\t\t\t\tsecondary: unknown;\n\t\t\t\t\tvalue: V;\n\t\t\t\t}[]) {\n\t\t\t\t\tbackend.upsert(r.primary, r.secondary, r.value);\n\t\t\t\t\tcore.emit({ kind: \"upsert\", primary: r.primary, secondary: r.secondary, value: r.value });\n\t\t\t\t\tenforceCapacity();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tenforceCapacity();\n\t};\n\n\tfunction ensureApply(): Node<IndexChange<K, V>> {\n\t\tif (apply !== undefined) return apply;\n\t\tconst op: Operator<unknown, IndexChange<K, V>> = {\n\t\t\tfactory: \"reactiveIndex.capacityPolicy\",\n\t\t\tbody: applyBody,\n\t\t\topts: { partial: true },\n\t\t};\n\t\tconst deps = capacityPolicy ? [capacityPolicy as Node<unknown>] : [];\n\t\tapply = graph\n\t\t\t? graph.initNode(op, deps, {\n\t\t\t\t\tname: name ? `${name}.capacityPolicy` : undefined,\n\t\t\t\t\tmeta: { kind: \"collection_policy_apply\", collection: \"reactiveIndex\" },\n\t\t\t\t})\n\t\t\t: new Node<IndexChange<K, V>>(deps, op.body, {\n\t\t\t\t\t...base,\n\t\t\t\t\tfactory: \"reactiveIndex.capacityPolicy\",\n\t\t\t\t\tpartial: true,\n\t\t\t\t\tname: name ? `${name}.capacityPolicy` : undefined,\n\t\t\t\t});\n\t\treleaseApply = graph\n\t\t\t? graph.retain(apply, { reason: \"reactiveIndex.capacityPolicy\" })\n\t\t\t: apply.subscribe(() => {});\n\t\treturn apply;\n\t}\n\n\tlet currentMaxSize: number | undefined;\n\tconst currentCapacityOrder: ReactiveIndexCapacityOrder | undefined = capacity?.order;\n\tif (capacity !== undefined) {\n\t\tif (\n\t\t\tcurrentCapacityOrder !== \"secondary\" &&\n\t\t\tcurrentCapacityOrder !== \"primary\" &&\n\t\t\tcurrentCapacityOrder !== \"lru\"\n\t\t) {\n\t\t\tthrow new Error(\"reactiveIndex: capacity.order must be one of secondary|primary|lru (D73)\");\n\t\t}\n\n\t\tconst maxSize = capacity.maxSize;\n\t\tif (isNodeOpt(maxSize) && graph === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t\"reactiveIndex capacity.maxSize Node option requires options.graph so the policy edge is describe-visible (D73)\",\n\t\t\t);\n\t\t}\n\n\t\tcapacityPolicy = isNodeOpt(maxSize)\n\t\t\t? maxSize\n\t\t\t: graph\n\t\t\t\t? graph.initNode<number, number>(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfactory: \"reactiveIndex.maxSizePolicy\",\n\t\t\t\t\t\t\tbody: () => {},\n\t\t\t\t\t\t\topts: { initial: validateMaxSize(maxSize) },\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[],\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: name ? `${name}.maxSizePolicy` : undefined,\n\t\t\t\t\t\t\tmeta: { kind: \"collection_policy\", collection: \"reactiveIndex\", policy: \"maxSize\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t: undefined;\n\n\t\tif (!isNodeOpt(maxSize)) currentMaxSize = validateMaxSize(maxSize);\n\n\t\tif (capacityPolicy instanceof Node) ensureApply();\n\t}\n\n\t// Lazy reactive reverse-lookup port (Z): a delta-driven pushed primary→value map. Created on\n\t// first access so an index that never uses it pays nothing (no keepalive — R-rom-ram).\n\tlet byPrimaryNode: Node<ReadonlyMap<K, V>> | undefined;\n\tfunction getByPrimary(): Node<ReadonlyMap<K, V>> {\n\t\tif (byPrimaryNode === undefined) {\n\t\t\tbyPrimaryNode = node<ReadonlyMap<K, V>>(\n\t\t\t\t[core.delta as Node<unknown>],\n\t\t\t\t(ctx: Ctx) => {\n\t\t\t\t\t// pushed reverse-lookup: re-read the backend's primary map on each delta (the\n\t\t\t\t\t// structure's own backend, D60 #1 — not a foreign .cache peek).\n\t\t\t\t\tctx.down([[\"DATA\", backend.toPrimaryMap()]]);\n\t\t\t\t},\n\t\t\t\t{ factory: \"reactiveIndex.byPrimary\", partial: true },\n\t\t\t);\n\t\t}\n\t\treturn byPrimaryNode;\n\t}\n\n\tfunction getRange(start: K, end: K): ReactiveView<IndexChange<K, V>, readonly V[]> {\n\t\tconst key = [start, end] as const;\n\t\tconst hit = rangeMemo.get(key);\n\t\tif (hit !== undefined) return hit;\n\t\tconst materialize = (): readonly V[] => backend.rangeByPrimary(start, end);\n\t\tlet view: ReactiveView<IndexChange<K, V>, readonly V[]>;\n\t\tview = lightReactiveView<IndexChange<K, V>, readonly V[]>(core.delta as Node<unknown>, {\n\t\t\t...options,\n\t\t\tfactory: \"reactiveIndex.range\",\n\t\t\tname: name ? `${name}.range#${rangeSeq++}` : undefined,\n\t\t\tmaterializeSnapshot: materialize,\n\t\t\tonDispose: () => {\n\t\t\t\trangeMemo.deleteValue(view);\n\t\t\t},\n\t\t});\n\t\trangeMemo.set(key, view);\n\t\treturn view;\n\t}\n\n\treturn {\n\t\tdelta: core.delta,\n\t\tsnapshot: core.snapshot,\n\t\tpullId: core.pullId,\n\n\t\tget size(): number {\n\t\t\treturn backend.size;\n\t\t},\n\t\thas(primary: K): boolean {\n\t\t\treturn backend.has(primary);\n\t\t},\n\t\tget(primary: K): V | undefined {\n\t\t\treturn backend.get(primary);\n\t\t},\n\t\trangeByPrimary(start: K, end: K): V[] {\n\t\t\treturn backend.rangeByPrimary(start, end);\n\t\t},\n\t\trange(start: K, end: K): ReactiveView<IndexChange<K, V>, readonly V[]> {\n\t\t\treturn getRange(start, end);\n\t\t},\n\t\ttoArray(): readonly IndexRow<K, V>[] {\n\t\t\treturn backend.snapshot();\n\t\t},\n\t\ttoPrimaryMap(): ReadonlyMap<K, V> {\n\t\t\treturn backend.toPrimaryMap();\n\t\t},\n\t\tget byPrimary(): Node<ReadonlyMap<K, V>> {\n\t\t\treturn getByPrimary();\n\t\t},\n\n\t\tupsert(primary: K, secondary: unknown, value: V): boolean {\n\t\t\tconst inserted = backend.upsert(primary, secondary, value);\n\t\t\tcore.emit({ kind: \"upsert\", primary, secondary, value });\n\t\t\tenforceCapacity();\n\t\t\treturn inserted;\n\t\t},\n\t\tupsertMany(rows: Iterable<{ primary: K; secondary: unknown; value: V }>): void {\n\t\t\tfor (const r of rows) {\n\t\t\t\tbackend.upsert(r.primary, r.secondary, r.value);\n\t\t\t\tcore.emit({ kind: \"upsert\", primary: r.primary, secondary: r.secondary, value: r.value });\n\t\t\t\tenforceCapacity();\n\t\t\t}\n\t\t},\n\t\tdelete(primary: K): void {\n\t\t\tif (backend.delete(primary)) core.emit({ kind: \"delete\", primary });\n\t\t},\n\t\tdeleteMany(primaries: Iterable<K>): void {\n\t\t\tconst removed: K[] = [];\n\t\t\tfor (const p of primaries) if (backend.delete(p)) removed.push(p);\n\t\t\tif (removed.length > 0) core.emit({ kind: \"deleteMany\", primaries: removed });\n\t\t},\n\t\tclear(): void {\n\t\t\tconst count = backend.clear();\n\t\t\tif (count > 0) core.emit({ kind: \"clear\", count });\n\t\t},\n\n\t\tupsertFrom(src: Node<{ primary: K; secondary: unknown; value: V }>): () => void {\n\t\t\tif (graph === undefined)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"reactiveIndex.upsertFrom requires options.graph so the input fold is describe-visible (D61)\",\n\t\t\t\t);\n\t\t\tconst op: Operator<\n\t\t\t\t{ primary: K; secondary: unknown; value: V },\n\t\t\t\t{ primary: K; secondary: unknown; value: V }\n\t\t\t> = {\n\t\t\t\tfactory: \"reactiveIndex.bindSource\",\n\t\t\t\tbody: (ctx: Ctx) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfor (const r of (depBatch(ctx, 0) ?? []) as readonly {\n\t\t\t\t\t\t\tprimary: K;\n\t\t\t\t\t\t\tsecondary: unknown;\n\t\t\t\t\t\t\tvalue: V;\n\t\t\t\t\t\t}[]) {\n\t\t\t\t\t\t\tctx.down([[\"DATA\", r]]);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"reactiveIndex.bindSource failed\")]]);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst folder = graph.initNode(op, [src], {\n\t\t\t\tname: name ? `${name}.bind#${bindSeq++}` : undefined,\n\t\t\t\tmeta: { kind: \"collection_bind_source\", collection: \"reactiveIndex\" },\n\t\t\t});\n\t\t\tbindDeps.add(folder as Node<unknown>);\n\t\t\tconst applyNode = ensureApply();\n\t\t\tapplyNode.subscribeDep(folder as Node<unknown>, applyBody);\n\t\t\tlet active = true;\n\t\t\tconst dispose = () => {\n\t\t\t\tif (!active) return;\n\t\t\t\tactive = false;\n\t\t\t\tapplyNode.unsubscribeDep(folder as Node<unknown>, applyBody);\n\t\t\t};\n\t\t\tbinds.push(dispose);\n\t\t\treturn dispose;\n\t\t},\n\t\tdispose(): void {\n\t\t\tfor (const d of binds) d();\n\t\t\tbinds.length = 0;\n\t\t\treleaseApply();\n\t\t\trangeMemo.disposeAll();\n\t\t},\n\t};\n}\n","/**\n * Reactive positional list (CSP-2.8, D54/D60) — the two-port collection template.\n *\n * Shape (D60 + review #2): a mutable array BACKEND (the single materialized state) + the shared\n * {@link collectionCore} two ports — a DELTA stream ({@link ReactiveList.delta}, one event per\n * mutation, O(1)) and a lazy pull SNAPSHOT ({@link ReactiveList.snapshot}, materialized only on a\n * cone-routed PULL demand). Mutation input is D54 A3 hybrid: ergonomic imperative methods (the\n * external boundary, state-verb-legitimate, D4) + `appendFrom(src)` widening (an in-graph producer\n * drives the list with zero imperative glue). Synchronous quick-reads (`at`/`size`/`toArray`) are\n * the deliberately-non-reactive peek for cold/imperative reads (D60).\n *\n * Per-language (D6/D24, never in parity, no conformance — the substrate pull is already C-16).\n */\n\nimport { type Ctx, depBatch, depCount, depLatest } from \"../../ctx/types.js\";\nimport { Node } from \"../../node/node.js\";\nimport { errorPayload } from \"../../protocol/messages.js\";\nimport type { Operator } from \"../operators.js\";\nimport { trimHeadOverflow } from \"../policies/collection.js\";\nimport type { ReactiveOpt } from \"../policies/types.js\";\nimport type { ListChange } from \"./change.js\";\nimport { type CollectionCore, type CollectionCoreOptions, collectionCore } from \"./core.js\";\n\nexport type ReactiveListOpt<T> = ReactiveOpt<T>;\n\nexport interface ReactiveListOptions extends CollectionCoreOptions {\n\t/**\n\t * Head-trim capacity policy (D72). A static number caps the list locally; a Node-valued maxSize\n\t * must be graph-bound and becomes a declared policy dep that trims on policy changes.\n\t */\n\tmaxSize?: ReactiveListOpt<number>;\n}\n\nexport interface ReactiveList<T> {\n\t/** DELTA stream: one {@link ListChange} per mutation (O(1)). Subscribe to observe events. */\n\treadonly delta: Node<ListChange<T>>;\n\t/** SNAPSHOT pull node: demand via `ctx.upNext([[\"PULL\", { pullId }]])` → one `readonly T[]` (lazy O(n)). */\n\treadonly snapshot: Node<readonly T[]>;\n\t/** The snapshot node's pullId — write it verbatim into the demander's fn (D269). */\n\treadonly pullId: symbol;\n\t/** Current entry count (O(1), synchronous non-reactive read). */\n\treadonly size: number;\n\t/** Positional access (O(1)); negative indices Python-style; `undefined` out of range. Sync read. */\n\tat(index: number): T | undefined;\n\t/** Full current contents (O(n), fresh defensive copy). Sync non-reactive read (cold-start peek). */\n\ttoArray(): readonly T[];\n\tappend(value: T): void;\n\t/** Append all values; one delta event + one snapshot-arm. No-op if `values` is empty. */\n\tappendMany(values: readonly T[]): void;\n\t/** Insert at `index` (0..size). Throws `RangeError` out of range. */\n\tinsert(index: number, value: T): void;\n\t/** Insert all at `index` as one op. No-op if `values` is empty. Throws out of range. */\n\tinsertMany(index: number, values: readonly T[]): void;\n\t/** Remove and return the value at `index` (default last; negative Python-style). Throws if empty/out of range. */\n\tpop(index?: number): T;\n\tclear(): void;\n\t/** D54 widening: every value from `src` is appended. Returns a disposer. */\n\tappendFrom(src: Node<T>): () => void;\n\t/** Release the widening subscriptions (idempotent). */\n\tdispose(): void;\n}\n\n/** Default mutable-array backend (D60 first-cut; pluggable persistent/immutable backend deferred). */\nclass ListBackend<T> {\n\tprivate _version = 0;\n\tprivate readonly buf: T[];\n\n\tconstructor(initial?: readonly T[], maxSize?: number) {\n\t\tthis.buf = initial ? [...initial] : [];\n\t\ttrimHeadOverflow(this.buf, { maxSize });\n\t}\n\n\tget version(): number {\n\t\treturn this._version;\n\t}\n\n\tget size(): number {\n\t\treturn this.buf.length;\n\t}\n\n\tat(index: number): T | undefined {\n\t\tif (!Number.isInteger(index)) return undefined;\n\t\tconst i = index >= 0 ? index : this.buf.length + index;\n\t\treturn i < 0 || i >= this.buf.length ? undefined : this.buf[i];\n\t}\n\n\tsnapshot(): readonly T[] {\n\t\treturn [...this.buf];\n\t}\n\n\tappend(value: T): void {\n\t\tthis.buf.push(value);\n\t\tthis._version += 1;\n\t}\n\n\tappendMany(values: readonly T[]): void {\n\t\tif (values.length === 0) return;\n\t\tfor (const v of values) this.buf.push(v);\n\t\tthis._version += 1;\n\t}\n\n\tinsert(index: number, value: T): void {\n\t\tif (!Number.isInteger(index) || index < 0 || index > this.buf.length)\n\t\t\tthrow new RangeError(`insert: index ${index} out of range [0, ${this.buf.length}]`);\n\t\tthis.buf.splice(index, 0, value);\n\t\tthis._version += 1;\n\t}\n\n\tinsertMany(index: number, values: readonly T[]): void {\n\t\tif (!Number.isInteger(index) || index < 0 || index > this.buf.length)\n\t\t\tthrow new RangeError(`insertMany: index ${index} out of range [0, ${this.buf.length}]`);\n\t\tif (values.length === 0) return;\n\t\tthis.buf.splice(index, 0, ...values);\n\t\tthis._version += 1;\n\t}\n\n\tpop(index: number): T {\n\t\tif (this.buf.length === 0) throw new RangeError(\"pop from empty list\");\n\t\tif (!Number.isInteger(index)) throw new RangeError(`pop: index ${index} must be an integer`);\n\t\tconst i = index >= 0 ? index : this.buf.length + index;\n\t\tif (i < 0 || i >= this.buf.length) throw new RangeError(`pop: index ${index} out of range`);\n\t\tconst [v] = this.buf.splice(i, 1);\n\t\tthis._version += 1;\n\t\treturn v as T;\n\t}\n\n\tclear(): number {\n\t\tconst n = this.buf.length;\n\t\tif (n === 0) return 0;\n\t\tthis.buf.length = 0;\n\t\tthis._version += 1;\n\t\treturn n;\n\t}\n\n\tenforceMaxSize(maxSize?: number): number {\n\t\tconst removed = trimHeadOverflow(this.buf, { maxSize }).length;\n\t\tif (removed > 0) this._version += 1;\n\t\treturn removed;\n\t}\n}\n\n/**\n * Create a reactive list (D54/D60). The DELTA + SNAPSHOT ports + pullId come from the shared\n * {@link collectionCore}; this layer adds the typed list method surface + backend.\n *\n * @example\n * ```ts\n * const list = reactiveList<number>([1]);\n * // observe events:\n * list.delta.subscribe((m) => { if (m[0] === \"DATA\") console.log(\"Δ\", m[1]); });\n * list.append(2); // delta: {kind:\"append\", value:2}\n * // demand the snapshot (a downstream consumer, holding `list.snapshot` upstream, runs):\n * // ctx.upNext([[\"PULL\", { pullId: list.pullId }]]); → SNAPSHOT delivers [1, 2]\n * list.toArray(); // [1, 2] (synchronous non-reactive read)\n * ```\n */\nexport function reactiveList<T>(\n\tinitial?: readonly T[],\n\toptions: ReactiveListOptions = {},\n): ReactiveList<T> {\n\tconst { maxSize, graph, dispatcher } = options;\n\tconst base = dispatcher ? { dispatcher } : {};\n\n\tfunction isNodeOpt(x: ReactiveListOpt<number> | undefined): x is Node<number> {\n\t\treturn x instanceof Node;\n\t}\n\n\tfunction validateMaxSize(v: number): number {\n\t\tif (!Number.isFinite(v) || !Number.isInteger(v) || v < 1)\n\t\t\tthrow new RangeError(`reactiveList: maxSize must be a positive integer (got ${v})`);\n\t\treturn v;\n\t}\n\n\tconst initialMaxSize = isNodeOpt(maxSize) ? undefined : maxSize;\n\tconst backend = new ListBackend<T>(\n\t\tinitial,\n\t\tinitialMaxSize === undefined ? undefined : validateMaxSize(initialMaxSize),\n\t);\n\tconst restorable = graph !== undefined && options.name !== undefined && maxSize === undefined;\n\tconst core: CollectionCore<readonly T[], ListChange<T>> = collectionCore(\n\t\tbackend,\n\t\t\"reactiveList\",\n\t\toptions,\n\t\trestorable\n\t\t\t? {\n\t\t\t\t\tdeltaRef: \"reactiveList.delta\",\n\t\t\t\t\tsnapshotRef: \"reactiveList.snapshot\",\n\t\t\t\t\tbackendState: () => backend.snapshot(),\n\t\t\t\t}\n\t\t\t: undefined,\n\t);\n\tconst binds: Array<() => void> = [];\n\tconst bindDeps = new WeakSet<Node<unknown>>();\n\tlet bindSeq = 0;\n\tlet capacityPolicy: Node<number> | undefined;\n\tlet apply: Node<ListChange<T>> | undefined;\n\tlet releaseApply = () => {};\n\tlet currentMaxSize = initialMaxSize;\n\n\tfunction emitTrimmed(n: number): void {\n\t\tif (n > 0) core.emit({ kind: \"trimHead\", n });\n\t}\n\n\tfunction enforceCapacity(): void {\n\t\temitTrimmed(backend.enforceMaxSize(currentMaxSize));\n\t}\n\n\tconst applyBody = (ctx: Ctx): void => {\n\t\tconst deps = apply?.deps ?? [];\n\t\tfor (let i = 0; i < depCount(ctx); i++) {\n\t\t\tconst dep = deps[i];\n\t\t\tif (dep === capacityPolicy) {\n\t\t\t\tconst latest = depLatest(ctx, i);\n\t\t\t\tif (latest !== undefined) currentMaxSize = validateMaxSize(latest as number);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (dep && bindDeps.has(dep)) {\n\t\t\t\tfor (const value of (depBatch(ctx, i) ?? []) as readonly T[]) {\n\t\t\t\t\tbackend.append(value);\n\t\t\t\t\tcore.emit({ kind: \"append\", value });\n\t\t\t\t\tenforceCapacity();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tenforceCapacity();\n\t};\n\n\tfunction ensureApply(): Node<ListChange<T>> {\n\t\tif (apply !== undefined) return apply;\n\t\tconst op: Operator<unknown, ListChange<T>> = {\n\t\t\tfactory: \"reactiveList.capacityPolicy\",\n\t\t\tbody: applyBody,\n\t\t\topts: { partial: true },\n\t\t};\n\t\tconst deps = capacityPolicy ? [capacityPolicy as Node<unknown>] : [];\n\t\tapply = graph\n\t\t\t? graph.initNode(op, deps, {\n\t\t\t\t\tname: options.name ? `${options.name}.capacityPolicy` : undefined,\n\t\t\t\t\tmeta: { kind: \"collection_policy_apply\", collection: \"reactiveList\" },\n\t\t\t\t})\n\t\t\t: new Node<ListChange<T>>(deps, op.body, {\n\t\t\t\t\t...base,\n\t\t\t\t\tfactory: \"reactiveList.capacityPolicy\",\n\t\t\t\t\tpartial: true,\n\t\t\t\t\tname: options.name ? `${options.name}.capacityPolicy` : undefined,\n\t\t\t\t});\n\t\treleaseApply = graph\n\t\t\t? graph.retain(apply, { reason: \"reactiveList.capacityPolicy\" })\n\t\t\t: apply.subscribe(() => {});\n\t\treturn apply;\n\t}\n\n\tfunction constPolicyNode(value: number): Node<number> {\n\t\tconst op: Operator<never, number> = {\n\t\t\tfactory: \"reactiveList.maxSizePolicy\",\n\t\t\tbody: () => {},\n\t\t\topts: { initial: value },\n\t\t};\n\t\tif (graph) {\n\t\t\treturn graph.initNode(op, [], {\n\t\t\t\tname: options.name ? `${options.name}.maxSizePolicy` : undefined,\n\t\t\t\tmeta: { kind: \"collection_policy\", collection: \"reactiveList\", policy: \"maxSize\" },\n\t\t\t});\n\t\t}\n\t\treturn new Node<number>([], null, {\n\t\t\t...base,\n\t\t\tinitial: value,\n\t\t\tfactory: \"reactiveList.maxSizePolicy\",\n\t\t\tname: options.name ? `${options.name}.maxSizePolicy` : undefined,\n\t\t});\n\t}\n\n\tif (maxSize !== undefined) {\n\t\tif (isNodeOpt(maxSize) && graph === undefined)\n\t\t\tthrow new Error(\n\t\t\t\t\"reactiveList maxSize Node option requires options.graph so the policy edge is describe-visible (D72)\",\n\t\t\t);\n\t\tcapacityPolicy = isNodeOpt(maxSize)\n\t\t\t? maxSize\n\t\t\t: graph\n\t\t\t\t? constPolicyNode(validateMaxSize(maxSize))\n\t\t\t\t: undefined;\n\t\tif (capacityPolicy !== undefined) ensureApply();\n\t}\n\n\treturn {\n\t\tdelta: core.delta,\n\t\tsnapshot: core.snapshot,\n\t\tpullId: core.pullId,\n\n\t\tget size(): number {\n\t\t\treturn backend.size;\n\t\t},\n\t\tat(index: number): T | undefined {\n\t\t\treturn backend.at(index);\n\t\t},\n\t\ttoArray(): readonly T[] {\n\t\t\treturn backend.snapshot();\n\t\t},\n\n\t\tappend(value: T): void {\n\t\t\tbackend.append(value);\n\t\t\tcore.emit({ kind: \"append\", value });\n\t\t\tenforceCapacity();\n\t\t},\n\t\tappendMany(values: readonly T[]): void {\n\t\t\tif (values.length === 0) return;\n\t\t\tconst copy = [...values];\n\t\t\tbackend.appendMany(copy);\n\t\t\tcore.emit({ kind: \"appendMany\", values: copy });\n\t\t\tenforceCapacity();\n\t\t},\n\t\tinsert(index: number, value: T): void {\n\t\t\tbackend.insert(index, value);\n\t\t\tcore.emit({ kind: \"insert\", index, value });\n\t\t\tenforceCapacity();\n\t\t},\n\t\tinsertMany(index: number, values: readonly T[]): void {\n\t\t\tif (values.length === 0) {\n\t\t\t\t// still validate the index (mirror backend) so an out-of-range empty insert throws\n\t\t\t\tbackend.insertMany(index, values);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst copy = [...values];\n\t\t\tbackend.insertMany(index, copy);\n\t\t\tcore.emit({ kind: \"insertMany\", index, values: copy });\n\t\t\tenforceCapacity();\n\t\t},\n\t\tpop(index = -1): T {\n\t\t\tconst resolved = index < 0 ? backend.size + index : index;\n\t\t\tconst value = backend.pop(index);\n\t\t\tcore.emit({ kind: \"pop\", index: resolved, value });\n\t\t\treturn value;\n\t\t},\n\t\tclear(): void {\n\t\t\tconst count = backend.clear();\n\t\t\tif (count > 0) core.emit({ kind: \"clear\", count });\n\t\t},\n\n\t\tappendFrom(src: Node<T>): () => void {\n\t\t\tif (graph === undefined)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"reactiveList.appendFrom requires options.graph so the input fold is describe-visible (D61)\",\n\t\t\t\t);\n\t\t\tconst op: Operator<T, T> = {\n\t\t\t\tfactory: \"reactiveList.bindSource\",\n\t\t\t\tbody: (ctx: Ctx) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfor (const value of (depBatch(ctx, 0) ?? []) as readonly T[]) {\n\t\t\t\t\t\t\tctx.down([[\"DATA\", value]]);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"reactiveList.bindSource failed\")]]);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst folder = graph.initNode(op, [src], {\n\t\t\t\tname: options.name ? `${options.name}.bind#${bindSeq++}` : undefined,\n\t\t\t\tmeta: { kind: \"collection_bind_source\", collection: \"reactiveList\" },\n\t\t\t});\n\t\t\tbindDeps.add(folder as Node<unknown>);\n\t\t\tconst applyNode = ensureApply();\n\t\t\tapplyNode.subscribeDep(folder as Node<unknown>, applyBody);\n\t\t\tlet active = true;\n\t\t\tconst dispose = () => {\n\t\t\t\tif (!active) return;\n\t\t\t\tactive = false;\n\t\t\t\tapplyNode.unsubscribeDep(folder as Node<unknown>, applyBody);\n\t\t\t};\n\t\t\tbinds.push(dispose);\n\t\t\treturn dispose;\n\t\t},\n\t\tdispose(): void {\n\t\t\tfor (const d of binds) d();\n\t\t\tbinds.length = 0;\n\t\t\treleaseApply();\n\t\t},\n\t};\n}\n","/**\n * Reactive append-only log (CSP-2.8, D54/D60) — two-port collection with incremental views.\n *\n * Shape = the shared {@link collectionCore} two ports over an array (or ring-buffer if `maxSize`)\n * BACKEND (D60). Specializations (D60 #5 / review #5):\n * - SNAPSHOT (the full `readonly T[]`) is the lazy pull port like the others, BUT the log's main\n * consumption is INCREMENTAL: `tail()` / `slice()` / `scan()` re-derive on the DELTA backbone\n * (dep=[delta]), folding each appended value as it arrives — NOT re-scanning a pushed full array.\n * - `append(undefined)` throws: `undefined` is the substrate SENTINEL (R-data-payload / R-sentinel),\n * not a valid value.\n * - empty log: the snapshot is `[]` (a real empty array); a never-appended `scan` seeds its initial.\n * There is NO `[[RESOLVED]]`-for-empty dual role (D49 narrowed RESOLVED to undirty-only, D60 #5b).\n * - `attach(upstream)` = the D54 widening (a declared input-fold dep), NOT an imperative subscribe.\n * - {@link mergeReactiveLogs} is a DECLARED-DEP merge (deps=[...delta streams]), NOT the old\n * internal-subscribe island (D45 must-fix, D60 #5e).\n * - storage persistence = D57 (binding-layer observe-sink), out of scope here.\n *\n * Per-language (D6/D24, never in parity, no conformance — the substrate pull is already C-16).\n */\n\nimport { type Ctx, depBatch, depCount } from \"../../ctx/types.js\";\nimport { type Node, node } from \"../../node/node.js\";\nimport type { GraphCheckpointJson } from \"../checkpoint.js\";\nimport { trimHeadOverflow } from \"../policies/collection.js\";\nimport type { ViewCachePolicy } from \"../policies/types.js\";\nimport type { LogChange } from \"./change.js\";\nimport {\n\ttype CollectionCore,\n\ttype CollectionCoreOptions,\n\tcollectionCore,\n\tlightReactiveView,\n\ttype ReactiveView,\n\tViewMemoCache,\n} from \"./core.js\";\n\nexport interface ReactiveLogOptions extends CollectionCoreOptions {\n\t/** Ring-buffer cap: appends past `maxSize` evict the oldest (head-trim, append-only-safe). */\n\tmaxSize?: number;\n\t/** Static D80 memo policy for D121 light views. Eviction does not dispose returned views. */\n\tviewCache?: ViewCachePolicy;\n}\n\nexport interface ReactiveLog<T> {\n\treadonly delta: Node<LogChange<T>>;\n\t/** SNAPSHOT pull node: demand → full `readonly T[]` (lazy O(n)). For incremental use {@link tail}, {@link slice}, or {@link scan}. */\n\treadonly snapshot: Node<readonly T[]>;\n\treadonly pullId: symbol;\n\t/** Entry count (O(1)). Sync non-reactive read. */\n\treadonly size: number;\n\t/** Positional access (O(1)); negative Python-style; `undefined` out of range. Sync read. */\n\tat(index: number): T | undefined;\n\t/** Full contents (O(n) fresh copy). Sync non-reactive read (cold-start peek). */\n\ttoArray(): readonly T[];\n\t/** Append one value. Throws on `undefined` (substrate SENTINEL, R-data-payload). */\n\tappend(value: T): void;\n\t/** Append many; one delta event. No-op if empty. Throws if any value is `undefined`. */\n\tappendMany(values: readonly T[]): void;\n\tclear(): void;\n\t/** Remove the first `n` entries (clamped to size). */\n\ttrimHead(n: number): void;\n\t/**\n\t * Incremental tail view: a derived node emitting the last `n` entries, recomputed on each delta\n\t * (dep=[delta], D60 #5a). Memoized per `n` until {@link dispose}; use stable ranges for\n\t * long-lived logs. Subscribe to keep it live.\n\t */\n\ttail(n: number): Node<readonly T[]>;\n\t/**\n\t * Incremental positional view: a derived node emitting `toArray().slice(start, stop)`,\n\t * recomputed on each delta (dep=[delta], D60 #5a). Memoized per `[start, stop]` until\n\t * {@link dispose}; use stable ranges for long-lived logs.\n\t */\n\tslice(start: number, stop?: number): Node<readonly T[]>;\n\t/**\n\t * D121 light page view: `delta` forwards parent log mutations, and `snapshot` is a pull node\n\t * that materializes the current page on demand.\n\t */\n\tpage(offset: number, limit: number): ReactiveView<LogChange<T>, readonly T[]>;\n\t/**\n\t * Incremental running aggregate over appended values (dep=[delta], D60 #5a). O(1) per append —\n\t * folds only the new values each delta; resets on `clear`/`trimHead` (a non-append delta) via a\n\t * full re-fold. Emits the current accumulator on every mutation; seeds `initial` on an empty log.\n\t */\n\tscan<A>(initial: A, step: (acc: A, value: T) => A): Node<A>;\n\t/** D54 widening: every value from `src` is appended. Returns a disposer. */\n\tattach(src: Node<T>): () => void;\n\tdispose(): void;\n}\n\n/** Default array / ring-buffer backend (D60 first-cut; persistent backend deferred). */\nclass LogBackend<T> {\n\tprivate _version = 0;\n\tprivate buf: T[];\n\tprivate readonly maxSize?: number;\n\n\tconstructor(initial?: readonly T[], maxSize?: number) {\n\t\tif (maxSize !== undefined && maxSize < 1)\n\t\t\tthrow new RangeError(\"reactiveLog: maxSize must be >= 1\");\n\t\tthis.maxSize = maxSize;\n\t\tthis.buf = initial ? [...initial] : [];\n\t\ttrimHeadOverflow(this.buf, { maxSize });\n\t}\n\n\tget version(): number {\n\t\treturn this._version;\n\t}\n\tget size(): number {\n\t\treturn this.buf.length;\n\t}\n\tat(index: number): T | undefined {\n\t\tif (!Number.isInteger(index)) return undefined;\n\t\tconst i = index >= 0 ? index : this.buf.length + index;\n\t\treturn i < 0 || i >= this.buf.length ? undefined : this.buf[i];\n\t}\n\tsnapshot(): readonly T[] {\n\t\treturn [...this.buf];\n\t}\n\n\tappend(value: T): void {\n\t\tthis.buf.push(value);\n\t\ttrimHeadOverflow(this.buf, { maxSize: this.maxSize });\n\t\tthis._version += 1;\n\t}\n\tappendMany(values: readonly T[]): void {\n\t\tif (values.length === 0) return;\n\t\tfor (const v of values) this.buf.push(v);\n\t\ttrimHeadOverflow(this.buf, { maxSize: this.maxSize });\n\t\tthis._version += 1;\n\t}\n\tclear(): number {\n\t\tconst n = this.buf.length;\n\t\tif (n === 0) return 0;\n\t\tthis.buf.length = 0;\n\t\tthis._version += 1;\n\t\treturn n;\n\t}\n\ttrimHead(n: number): number {\n\t\tif (!Number.isInteger(n) || n < 0)\n\t\t\tthrow new RangeError(`trimHead: n must be a non-negative integer (got ${n})`);\n\t\tif (n === 0 || this.buf.length === 0) return 0;\n\t\tconst removed = Math.min(n, this.buf.length);\n\t\tthis.buf.splice(0, removed);\n\t\tthis._version += 1;\n\t\treturn removed;\n\t}\n}\n\nfunction rejectUndefined<T>(value: T, ctx: string): void {\n\t// R-data-payload / R-sentinel (D60 #5): undefined is the substrate SENTINEL, not a valid value.\n\tif (value === undefined)\n\t\tthrow new TypeError(\n\t\t\t`${ctx}: undefined is the substrate SENTINEL, not a valid value — use null`,\n\t\t);\n}\n\n/**\n * Create an append-only reactive log (D54/D60). DELTA + lazy pull SNAPSHOT + pullId via\n * {@link collectionCore}; this layer adds the typed append surface + incremental view/scan.\n */\nexport function reactiveLog<T>(\n\tinitial?: readonly T[],\n\toptions: ReactiveLogOptions = {},\n): ReactiveLog<T> {\n\tconst { maxSize, viewCache, ...coreOpts } = options;\n\tconst base = coreOpts.dispatcher ? { dispatcher: coreOpts.dispatcher } : {};\n\tconst backend = new LogBackend<T>(initial, maxSize);\n\tconst restoreConfig =\n\t\tcoreOpts.graph !== undefined && coreOpts.name !== undefined\n\t\t\t? ({\n\t\t\t\t\t...(maxSize !== undefined ? { maxSize } : {}),\n\t\t\t\t} as GraphCheckpointJson)\n\t\t\t: undefined;\n\tconst core: CollectionCore<readonly T[], LogChange<T>> = collectionCore(\n\t\tbackend,\n\t\t\"reactiveLog\",\n\t\tcoreOpts,\n\t\trestoreConfig !== undefined\n\t\t\t? {\n\t\t\t\t\tdeltaRef: \"reactiveLog.delta\",\n\t\t\t\t\tsnapshotRef: \"reactiveLog.snapshot\",\n\t\t\t\t\tconfig: restoreConfig,\n\t\t\t\t\tbackendState: () => backend.snapshot(),\n\t\t\t\t}\n\t\t\t: undefined,\n\t);\n\tconst binds: Array<() => void> = [];\n\tconst tailMemo = new Map<number, Node<readonly T[]>>();\n\tconst sliceMemo = new Map<string, Node<readonly T[]>>();\n\tconst pageMemo = new ViewMemoCache<string, ReactiveView<LogChange<T>, readonly T[]>>(viewCache);\n\tlet pageSeq = 0;\n\n\treturn {\n\t\tdelta: core.delta,\n\t\tsnapshot: core.snapshot,\n\t\tpullId: core.pullId,\n\n\t\tget size(): number {\n\t\t\treturn backend.size;\n\t\t},\n\t\tat(index: number): T | undefined {\n\t\t\treturn backend.at(index);\n\t\t},\n\t\ttoArray(): readonly T[] {\n\t\t\treturn backend.snapshot();\n\t\t},\n\n\t\tappend(value: T): void {\n\t\t\trejectUndefined(value, \"reactiveLog.append\");\n\t\t\tbackend.append(value);\n\t\t\tcore.emit({ kind: \"append\", value });\n\t\t},\n\t\tappendMany(values: readonly T[]): void {\n\t\t\tif (values.length === 0) return;\n\t\t\tfor (const v of values) rejectUndefined(v, \"reactiveLog.appendMany\");\n\t\t\tconst copy = [...values];\n\t\t\tbackend.appendMany(copy);\n\t\t\tcore.emit({ kind: \"appendMany\", values: copy });\n\t\t},\n\t\tclear(): void {\n\t\t\tconst count = backend.clear();\n\t\t\tif (count > 0) core.emit({ kind: \"clear\", count });\n\t\t},\n\t\ttrimHead(n: number): void {\n\t\t\tconst removed = backend.trimHead(n);\n\t\t\tif (removed > 0) core.emit({ kind: \"trimHead\", n: removed });\n\t\t},\n\n\t\ttail(n: number): Node<readonly T[]> {\n\t\t\tif (!Number.isInteger(n) || n < 0)\n\t\t\t\tthrow new RangeError(`tail: n must be a non-negative integer (got ${n})`);\n\t\t\tconst hit = tailMemo.get(n);\n\t\t\tif (hit !== undefined) return hit;\n\t\t\t// Incremental on the DELTA backbone (D60 #5a): each delta re-reads the backend's current\n\t\t\t// tail (the backend is this structure's own materialized state, D60 #1 — not a foreign\n\t\t\t// .cache peek). `partial:true` — the tail does not consume the delta value, it fires on arm.\n\t\t\tconst tnode = node<readonly T[]>(\n\t\t\t\t[core.delta as Node<unknown>],\n\t\t\t\t(ctx: Ctx) => {\n\t\t\t\t\tconst all = backend.snapshot();\n\t\t\t\t\tctx.down([[\"DATA\", n === 0 ? [] : all.slice(Math.max(0, all.length - n))]]);\n\t\t\t\t},\n\t\t\t\t{ ...base, factory: \"reactiveLog.tail\", partial: true },\n\t\t\t);\n\t\t\ttailMemo.set(n, tnode);\n\t\t\treturn tnode;\n\t\t},\n\n\t\tslice(start: number, stop?: number): Node<readonly T[]> {\n\t\t\tif (!Number.isInteger(start) || start < 0) {\n\t\t\t\tthrow new RangeError(`slice: start must be a non-negative integer (got ${start})`);\n\t\t\t}\n\t\t\tif (stop !== undefined && (!Number.isInteger(stop) || stop < 0)) {\n\t\t\t\tthrow new RangeError(`slice: stop must be a non-negative integer (got ${stop})`);\n\t\t\t}\n\t\t\tconst key = `${start}:${stop ?? \"\"}`;\n\t\t\tconst hit = sliceMemo.get(key);\n\t\t\tif (hit !== undefined) return hit;\n\t\t\t// Incremental on the DELTA backbone (D60 #5a): each delta re-reads this log's own\n\t\t\t// backend slice. The backend is the single materialized state (D60), not a dep cache.\n\t\t\tconst snode = node<readonly T[]>(\n\t\t\t\t[core.delta as Node<unknown>],\n\t\t\t\t(ctx: Ctx) => {\n\t\t\t\t\tctx.down([[\"DATA\", backend.snapshot().slice(start, stop)]]);\n\t\t\t\t},\n\t\t\t\t{ ...base, factory: \"reactiveLog.slice\", partial: true },\n\t\t\t);\n\t\t\tsliceMemo.set(key, snode);\n\t\t\treturn snode;\n\t\t},\n\n\t\tpage(offset: number, limit: number): ReactiveView<LogChange<T>, readonly T[]> {\n\t\t\tif (!Number.isInteger(offset) || offset < 0) {\n\t\t\t\tthrow new RangeError(`page: offset must be a non-negative integer (got ${offset})`);\n\t\t\t}\n\t\t\tif (!Number.isInteger(limit) || limit < 0) {\n\t\t\t\tthrow new RangeError(`page: limit must be a non-negative integer (got ${limit})`);\n\t\t\t}\n\t\t\tconst key = `${offset}:${limit}`;\n\t\t\tconst hit = pageMemo.get(key);\n\t\t\tif (hit !== undefined) return hit;\n\t\t\tconst materialize = (): readonly T[] => backend.snapshot().slice(offset, offset + limit);\n\t\t\tlet view: ReactiveView<LogChange<T>, readonly T[]>;\n\t\t\tview = lightReactiveView<LogChange<T>, readonly T[]>(core.delta as Node<unknown>, {\n\t\t\t\t...coreOpts,\n\t\t\t\tfactory: \"reactiveLog.page\",\n\t\t\t\tname: coreOpts.name ? `${coreOpts.name}.page#${pageSeq++}` : undefined,\n\t\t\t\tmaterializeSnapshot: materialize,\n\t\t\t\tonDispose: () => {\n\t\t\t\t\tpageMemo.deleteValue(view);\n\t\t\t\t},\n\t\t\t});\n\t\t\tpageMemo.set(key, view);\n\t\t\treturn view;\n\t\t},\n\n\t\tscan<A>(initial: A, step: (acc: A, value: T) => A): Node<A> {\n\t\t\t// Incremental fold on the delta backbone: keep the accumulator + processed-count in\n\t\t\t// ctx.state; fold only the new tail each append; full re-fold on a shrink (clear/trimHead).\n\t\t\treturn node<A>(\n\t\t\t\t[core.delta as Node<unknown>],\n\t\t\t\t(ctx: Ctx) => {\n\t\t\t\t\tconst st = ctx.state.get<{ acc: A; processed: number }>() ?? {\n\t\t\t\t\t\tacc: initial,\n\t\t\t\t\t\tprocessed: 0,\n\t\t\t\t\t};\n\t\t\t\t\tconst all = backend.snapshot();\n\t\t\t\t\tif (all.length < st.processed || (maxSize !== undefined && all.length <= st.processed)) {\n\t\t\t\t\t\t// Shrink or ring-buffer overwrite: re-fold from the current backend snapshot.\n\t\t\t\t\t\tlet acc = initial;\n\t\t\t\t\t\tfor (const v of all) acc = step(acc, v);\n\t\t\t\t\t\tst.acc = acc;\n\t\t\t\t\t\tst.processed = all.length;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfor (let i = st.processed; i < all.length; i++) st.acc = step(st.acc, all[i] as T);\n\t\t\t\t\t\tst.processed = all.length;\n\t\t\t\t\t}\n\t\t\t\t\tctx.state.set(st);\n\t\t\t\t\tctx.down([[\"DATA\", st.acc]]);\n\t\t\t\t},\n\t\t\t\t{ ...base, factory: \"reactiveLog.scan\", partial: true },\n\t\t\t);\n\t\t},\n\n\t\tattach(src: Node<T>): () => void {\n\t\t\tconst dispose = core.bindSource(src, (value: T) => {\n\t\t\t\trejectUndefined(value, \"reactiveLog.attach\");\n\t\t\t\tbackend.append(value);\n\t\t\t\tcore.emit({ kind: \"append\", value });\n\t\t\t});\n\t\t\tbinds.push(dispose);\n\t\t\treturn dispose;\n\t\t},\n\t\tdispose(): void {\n\t\t\tfor (const d of binds) d();\n\t\t\tbinds.length = 0;\n\t\t\ttailMemo.clear();\n\t\t\tsliceMemo.clear();\n\t\t\tpageMemo.disposeAll();\n\t\t},\n\t};\n}\n\n/**\n * Fan-in N reactive logs into one merged DELTA stream (D60 #5e — a DECLARED-DEP merge, NOT the old\n * internal-subscribe island). The returned node declares each log's `delta` as a dep (`partial`)\n * and re-emits every change it sees — describe shows `log[i].delta → merged` truthfully (D45).\n * For the merged SNAPSHOT, fold the merged delta with {@link ReactiveLog.scan}-style logic, or\n * demand each source's snapshot independently.\n */\nexport function mergeReactiveLogs<T>(logs: readonly ReactiveLog<T>[]): Node<LogChange<T>> {\n\tconst deps = logs.map((l) => l.delta as Node<unknown>);\n\treturn node<LogChange<T>>(\n\t\tdeps,\n\t\t(ctx: Ctx) => {\n\t\t\tfor (let i = 0; i < depCount(ctx); i++) {\n\t\t\t\tconst b = depBatch(ctx, i);\n\t\t\t\tif (b) for (const c of b) ctx.down([[\"DATA\", c as LogChange<T>]]);\n\t\t\t}\n\t\t},\n\t\t{ factory: \"mergeReactiveLogs\", partial: true },\n\t);\n}\n\n/**\n * Standalone incremental scan over a reactive log. Equivalent to `log.scan(initial, step)`;\n * provided for pipe-builder and helper-composition call sites.\n */\nexport function scanLog<T, A>(\n\tlog: ReactiveLog<T>,\n\tinitial: A,\n\tstep: (acc: A, value: T) => A,\n): Node<A> {\n\treturn log.scan(initial, step);\n}\n","/**\n * Reactive key–value map (CSP-2.8, D54/D60/D68) — two-port collection with policy opts.\n *\n * Shape = the shared {@link collectionCore} two ports over a `Map` BACKEND (D60). Specializations\n * (D60 #3 / review #3):\n * - TTL/LRU are node-as-opt policies (D68). Static `maxSize` / `defaultTtl` values become constant\n * policy deps; Node-valued opts are declared deps. The graph-visible `reactiveMap.apply` node is\n * the normal backend mutation path and emits the public delta payloads it materializes.\n * - LAZY TTL (no background timer): expiry is checked at read (`get`/`has`) + at synchronous\n * snapshot materialization (`toMap`/`pruneExpired`). A read/prune that deletes an expired key\n * emits the normal delta `delete{reason:\"expired\"}` (D61). Snapshot demand uses an internal pull\n * `snapshotPrep` node: it prunes expired entries and reads the backend once, then public\n * `snapshot` and `delta` derive from that declared prep payload. No snapshot fn drives its own\n * dep (D37).\n * - delete-reason enum {expired|lru-evict|archived|explicit} on the delta (D60 #3c).\n * - LRU `maxSize`: an over-cap `set` evicts the oldest, emitting a `delete{reason:\"lru-evict\"}`.\n * A live-key `get`/`has` touches LRU order WITHOUT a version bump (internal, D60 #3d).\n * - retention (score-archive, D72): `retention.maxSize` is a value-or-Node numeric policy and\n * the static scorer selects archive victims through the normal `reactiveMap.apply` path.\n *\n * Per-language (D6/D24, never in parity, no conformance — the substrate pull is already C-16).\n */\n\nimport {\n\ttype Ctx,\n\tdepBatch,\n\tdepCount,\n\tdepTerminal,\n\tisTerminalComplete,\n\ttype NodeFn,\n} from \"../../ctx/types.js\";\nimport { strictCanonicalJsonBytes } from \"../../json/codec.js\";\nimport { Node } from \"../../node/node.js\";\nimport { errorPayload } from \"../../protocol/messages.js\";\nimport { registerBackendStateContributor } from \"../checkpoint.js\";\nimport { initNode, type Operator } from \"../operators.js\";\nimport {\n\tdeadlines,\n\tlruKeys,\n\tPolicyInputs,\n\ttype PolicyOpt,\n\ttype ScoredEntry,\n\tselectRetentionVictims,\n\ttrimHeadOverflow,\n} from \"../policies/collection.js\";\nimport type { ReactiveOpt, RetentionPolicy, ViewCachePolicy } from \"../policies/types.js\";\nimport { timer } from \"../sources.js\";\nimport type { MapChange } from \"./change.js\";\nimport {\n\ttype CollectionCoreOptions,\n\tlightReactiveView,\n\ttype ReactiveView,\n\tViewMemoCache,\n} from \"./core.js\";\n\nexport type ReactiveMapOpt<T> = ReactiveOpt<T>;\n\nexport interface ReactiveMapRetentionEntry<K, V> {\n\treadonly key: K;\n\treadonly value: V;\n}\n\nexport interface ReactiveMapRetentionPolicy<K, V>\n\textends RetentionPolicy<ReactiveMapRetentionEntry<K, V>> {\n\t/** Archive capacity. Unlike LRU, zero is allowed and archives every live entry. */\n\treadonly maxSize?: ReactiveMapOpt<number>;\n\t/** Higher scores are retained; lowest finite scores are archived first. */\n\tscore(entry: ReactiveMapRetentionEntry<K, V>): number;\n}\n\ninterface ResolvedRetentionPolicy<K, V> {\n\treadonly maxSize?: number;\n\tscore(entry: ReactiveMapRetentionEntry<K, V>): number;\n}\n\nexport interface ReactiveMapOptions<K = unknown, V = unknown> extends CollectionCoreOptions {\n\t/**\n\t * LRU cap as a node-as-opt policy (D68). A static number is a constant policy config; a Node must\n\t * be graph-bound and becomes a declared dep of `reactiveMap.apply`.\n\t */\n\tmaxSize?: ReactiveMapOpt<number>;\n\t/**\n\t * Default TTL in milliseconds as a node-as-opt policy (D68). Per-call `set(...,{ttl})` overrides.\n\t * Lazy expiry only; no active timer in this cut.\n\t */\n\tdefaultTtl?: ReactiveMapOpt<number>;\n\t/**\n\t * Score-based retention/archive policy (D72). The scorer is static local code; only maxSize can be\n\t * a Node-valued policy, keeping graph describe data serializable while apply owns the mutation.\n\t */\n\tretention?: ReactiveMapRetentionPolicy<K, V>;\n\t/** Static D80 memo policy for D121 light views. Eviction does not dispose returned views. */\n\tviewCache?: ViewCachePolicy;\n\t/** Injectable monotonic-ish clock for TTL (default `Date.now`). Graph-local clock = follow-up (D26). */\n\tnow?: () => number;\n}\n\nexport interface ReactiveMap<K, V> {\n\treadonly delta: Node<MapChange<K, V>>;\n\treadonly snapshot: Node<ReadonlyMap<K, V>>;\n\treadonly pullId: symbol;\n\t/** Raw entry count (O(1)); may include not-yet-pruned expired entries. Sync non-reactive read. */\n\treadonly size: number;\n\t/** Get a live value (prunes the key if expired). Sync read. */\n\tget(key: K): V | undefined;\n\t/** Live-key existence (prunes if expired). Sync read. */\n\thas(key: K): boolean;\n\t/** Current live (non-expired) entries (fresh copy). Sync non-reactive read (cold-start peek). */\n\ttoMap(): ReadonlyMap<K, V>;\n\t/**\n\t * D121 light selected-map view. `delta` forwards parent map mutations, and `snapshot` is a pull\n\t * node that materializes the currently matching live entries on demand.\n\t */\n\tselect(\n\t\tpredicate: (value: V, key: K) => boolean,\n\t): ReactiveView<MapChange<K, V>, ReadonlyMap<K, V>>;\n\tset(key: K, value: V, opts?: { ttl?: number }): void;\n\t/** Bulk set; one delta event per entry, one snapshot-arm. No-op if empty. */\n\tsetMany(entries: Iterable<readonly [K, V]>, opts?: { ttl?: number }): void;\n\tdelete(key: K): void;\n\t/** Bulk delete; one delta per removed key. No-op if none present. */\n\tdeleteMany(keys: Iterable<K>): void;\n\tclear(): void;\n\t/** Explicitly prune expired entries; every removed key emits `delete{reason:\"expired\"}` (D61). */\n\tpruneExpired(): void;\n\t/** D54 widening: every `[key, value]` from `src` is set. Returns a disposer. */\n\tsetFrom(src: Node<readonly [K, V]>): () => void;\n\tdispose(): void;\n}\n\ninterface Entry<V> {\n\tvalue: V;\n\texpiresAt?: number;\n}\n\nfunction strictJsonIdentity(value: unknown): string {\n\treturn Array.from(strictCanonicalJsonBytes(value)).join(\",\");\n}\n\ntype Lookup<V> =\n\t| { found: true; value: V }\n\t| { found: false; expired?: false }\n\t| { found: false; expired: true; previous: V };\n\ninterface SnapshotPrep<K, V> {\n\treadonly snapshot: ReadonlyMap<K, V>;\n\treadonly expired: readonly MapChange<K, V>[];\n}\n\ntype MapIntent<K, V> =\n\t| { kind: \"set\"; key: K; value: V; ttl?: number }\n\t| { kind: \"delete\"; key: K }\n\t| { kind: \"clear\" }\n\t| { kind: \"pruneExpired\" }\n\t| { kind: \"pruneKey\"; key: K };\n\n/** Default `Map`-backed store. TTL/LRU policy lives in graph-visible policy/apply nodes (D68). */\nclass MapBackend<K, V> {\n\tprivate _version = 0;\n\tprivate readonly store = new Map<K, Entry<V>>();\n\tprivate readonly now: () => number;\n\n\tconstructor(opts: { now?: () => number }) {\n\t\tthis.now = opts.now ?? Date.now;\n\t}\n\n\tget version(): number {\n\t\treturn this._version;\n\t}\n\n\tget size(): number {\n\t\treturn this.store.size;\n\t}\n\n\tnowMs(): number {\n\t\treturn this.now();\n\t}\n\n\texpiresAtOf(key: K): number | undefined {\n\t\treturn this.store.get(key)?.expiresAt;\n\t}\n\n\tprivate isExpired(e: Entry<V>): boolean {\n\t\treturn e.expiresAt !== undefined && this.now() >= e.expiresAt;\n\t}\n\n\tresolveExpiresAt(ttl?: number): number | undefined {\n\t\tif (ttl === undefined) return undefined;\n\t\tif (!Number.isFinite(ttl) || ttl <= 0)\n\t\t\tthrow new RangeError(`reactiveMap: ttl must be a positive finite number (got ${ttl})`);\n\t\treturn this.now() + ttl;\n\t}\n\n\tprivate deleteExpired(key: K, e: Entry<V>): Array<[K, V]> {\n\t\tthis.store.delete(key);\n\t\tthis._version += 1;\n\t\treturn [[key, e.value]];\n\t}\n\n\t/** Read without materializing expiry. Caller routes expired deletes through the apply node (D68). */\n\tlookup(key: K): Lookup<V> {\n\t\tconst e = this.store.get(key);\n\t\tif (e === undefined) return { found: false };\n\t\tif (this.isExpired(e)) return { found: false, expired: true, previous: e.value };\n\t\t// LRU touch (no version bump — internal, D60 #3d).\n\t\tthis.store.delete(key);\n\t\tthis.store.set(key, e);\n\t\treturn { found: true, value: e.value };\n\t}\n\n\t/** Set; returns the entries evicted by LRU overflow (the caller emits their delete deltas). */\n\tset(key: K, value: V, expiresAt?: number): void {\n\t\tif (this.store.has(key)) this.store.delete(key); // re-insert at LRU end\n\t\tthis.store.set(key, { value, expiresAt });\n\t\tthis._version += 1;\n\t}\n\n\tenforceLru(maxSize?: number): Array<[K, V]> {\n\t\tconst evicted: Array<[K, V]> = [];\n\t\tfor (const oldest of trimHeadOverflow(lruKeys(this.store.keys()).keys(), {\n\t\t\tmaxSize,\n\t\t\tsize: this.store.size,\n\t\t})) {\n\t\t\tconst e = this.store.get(oldest);\n\t\t\tif (e !== undefined) evicted.push([oldest, e.value]);\n\t\t\tthis.store.delete(oldest);\n\t\t}\n\t\tif (evicted.length > 0) this._version += 1;\n\t\treturn evicted;\n\t}\n\n\tenforceRetention(policy?: ResolvedRetentionPolicy<K, V>): Array<[K, V]> {\n\t\tif (policy === undefined || policy.maxSize === undefined) return [];\n\t\tconst scored: ScoredEntry<readonly [K, V]>[] = [];\n\t\tfor (const [key, entry] of this.store) {\n\t\t\tif (!this.isExpired(entry)) {\n\t\t\t\tscored.push({\n\t\t\t\t\tentry: [key, entry.value] as const,\n\t\t\t\t\tscore: policy.score({ key, value: entry.value }),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tconst archived = selectRetentionVictims(scored, { maxSize: policy.maxSize });\n\t\tfor (const [key] of archived) this.store.delete(key);\n\t\tif (archived.length > 0) this._version += 1;\n\t\treturn archived.map(([key, value]) => [key, value]);\n\t}\n\n\tdelete(key: K): Lookup<V> {\n\t\tconst e = this.store.get(key);\n\t\tif (e === undefined) return { found: false };\n\t\tthis.store.delete(key);\n\t\tthis._version += 1;\n\t\treturn { found: true, value: e.value };\n\t}\n\n\tclear(): number {\n\t\tconst n = this.store.size;\n\t\tif (n === 0) return 0;\n\t\tthis.store.clear();\n\t\tthis._version += 1;\n\t\treturn n;\n\t}\n\n\tpruneExpired(): Array<[K, V]> {\n\t\tconst removed: Array<[K, V]> = [];\n\t\tfor (const [k, e] of this.store) {\n\t\t\tif (this.isExpired(e)) {\n\t\t\t\tthis.store.delete(k);\n\t\t\t\tremoved.push([k, e.value]);\n\t\t\t}\n\t\t}\n\t\tif (removed.length > 0) this._version += 1;\n\t\treturn removed;\n\t}\n\n\tpruneKeyIfExpired(key: K): Array<[K, V]> {\n\t\tconst e = this.store.get(key);\n\t\tif (e === undefined || !this.isExpired(e)) return [];\n\t\treturn this.deleteExpired(key, e);\n\t}\n\n\t/** Fresh snapshot of live entries. Does not prune; callers choose whether to materialize expiry. */\n\tsnapshot(): ReadonlyMap<K, V> {\n\t\tconst out = new Map<K, V>();\n\t\tfor (const [k, e] of this.store) if (!this.isExpired(e)) out.set(k, e.value);\n\t\treturn out;\n\t}\n\n\t/** D160 checkpoint payload: exact restorable map entries, excluding TTL-bearing state. */\n\tcheckpointEntries(): readonly (readonly [K, V])[] {\n\t\tconst out: Array<readonly [K, V]> = [];\n\t\tconst seen = new Set<string>();\n\t\tfor (const [key, entry] of this.store) {\n\t\t\tif (entry.expiresAt !== undefined) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\"reactiveMap checkpoint backendState cannot preserve per-entry TTL; persist the map externally or clear TTL state before graph checkpoint (D160)\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst stableKey = strictJsonIdentity(key);\n\t\t\tif (seen.has(stableKey)) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\"reactiveMap checkpoint backendState contains duplicate strict-JSON keys (D160)\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tseen.add(stableKey);\n\t\t\tout.push([key, entry.value] as const);\n\t\t}\n\t\treturn out;\n\t}\n}\n\n/**\n * Create a reactive map (D54/D60). DELTA stream of {@link MapChange} + lazy pull SNAPSHOT (a\n * `ReadonlyMap`) + pullId via {@link collectionCore}; this layer adds the typed map surface.\n */\nexport function reactiveMap<K, V>(options: ReactiveMapOptions<K, V> = {}): ReactiveMap<K, V> {\n\treturn createReactiveMap(options);\n}\n\n/** @internal D161 restore path: seed the backend without replaying public deltas. */\nexport function restoreReactiveMapFromBackendState<K, V>(\n\tinitialEntries: readonly (readonly [K, V])[],\n\toptions: ReactiveMapOptions<K, V> = {},\n): ReactiveMap<K, V> {\n\treturn createReactiveMap(options, initialEntries);\n}\n\nfunction createReactiveMap<K, V>(\n\toptions: ReactiveMapOptions<K, V> = {},\n\tinitialEntries: readonly (readonly [K, V])[] = [],\n): ReactiveMap<K, V> {\n\tconst { maxSize, defaultTtl, retention, viewCache, now, name, dispatcher, graph } = options;\n\tconst backend = new MapBackend<K, V>({ now });\n\tfor (const [key, value] of initialEntries) backend.set(key, value);\n\tconst base = dispatcher ? { dispatcher } : {};\n\tconst restorable =\n\t\tgraph !== undefined &&\n\t\tname !== undefined &&\n\t\tmaxSize === undefined &&\n\t\tdefaultTtl === undefined &&\n\t\tretention === undefined;\n\n\tfunction isNodeOpt<T>(x: PolicyOpt<T> | undefined): x is Node<T> {\n\t\treturn x instanceof Node;\n\t}\n\n\tfunction validateMaxSize(v: number): number {\n\t\tif (!Number.isFinite(v) || !Number.isInteger(v) || v < 1)\n\t\t\tthrow new RangeError(`reactiveMap: maxSize must be a positive integer (got ${v})`);\n\t\treturn v;\n\t}\n\n\tfunction validateTtl(v: number): number {\n\t\tif (!Number.isFinite(v) || v <= 0)\n\t\t\tthrow new RangeError(`reactiveMap: defaultTtl must be a positive finite number (got ${v})`);\n\t\treturn v;\n\t}\n\n\tfunction validateRetentionMaxSize(v: number): number {\n\t\tif (!Number.isFinite(v) || !Number.isInteger(v) || v < 0)\n\t\t\tthrow new RangeError(\n\t\t\t\t`reactiveMap: retention.maxSize must be a non-negative integer (got ${v})`,\n\t\t\t);\n\t\treturn v;\n\t}\n\n\tif (retention !== undefined && typeof retention.score !== \"function\")\n\t\tthrow new TypeError(\"reactiveMap: retention.score must be a function\");\n\n\ttype PolicyLabel = \"lruPolicy\" | \"ttlPolicy\" | \"retentionPolicy\";\n\n\tfunction constPolicyNode(label: PolicyLabel, value: number): Node<number> {\n\t\tconst op: Operator<never, number> = {\n\t\t\tfactory: `reactiveMap.${label}`,\n\t\t\tbody: () => {},\n\t\t\topts: { initial: value },\n\t\t};\n\t\tif (graph) {\n\t\t\treturn graph.initNode(op, [], {\n\t\t\t\tname: name ? `${name}.${label}` : undefined,\n\t\t\t\tmeta: { kind: \"collection_policy\", collection: \"reactiveMap\", policy: label },\n\t\t\t});\n\t\t}\n\t\treturn new Node<number>([], null, {\n\t\t\t...base,\n\t\t\tinitial: value,\n\t\t\tfactory: `reactiveMap.${label}`,\n\t\t\tname: name ? `${name}.${label}` : undefined,\n\t\t});\n\t}\n\n\tfunction policyNode(\n\t\tlabel: PolicyLabel,\n\t\topt: PolicyOpt<number> | undefined,\n\t\tvalidate: (v: number) => number,\n\t): Node<number> | undefined {\n\t\tif (opt === undefined) return undefined;\n\t\tif (isNodeOpt(opt)) {\n\t\t\tif (graph === undefined)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`reactiveMap ${label} Node option requires options.graph so the policy edge is describe-visible (${label === \"retentionPolicy\" ? \"D72\" : \"D68\"})`,\n\t\t\t\t);\n\t\t\treturn opt;\n\t\t}\n\t\treturn constPolicyNode(label, validate(opt));\n\t}\n\n\tconst intentOp: Operator<never, MapIntent<K, V>> = {\n\t\tfactory: \"reactiveMap.intent\",\n\t\tbody: () => {},\n\t};\n\tconst intent = graph\n\t\t? graph.initNode(intentOp, [], {\n\t\t\t\tname: name ? `${name}.intent` : undefined,\n\t\t\t\tmeta: { kind: \"collection_intent\", collection: \"reactiveMap\" },\n\t\t\t\t...(restorable ? { restore: { ref: \"reactiveMap.intent\" } } : {}),\n\t\t\t})\n\t\t: new Node<MapIntent<K, V>>([], null, {\n\t\t\t\t...base,\n\t\t\t\tfactory: \"reactiveMap.intent\",\n\t\t\t\tname: name ? `${name}.intent` : undefined,\n\t\t\t});\n\tconst lruPolicy = policyNode(\"lruPolicy\", maxSize, validateMaxSize);\n\tconst ttlPolicy = policyNode(\"ttlPolicy\", defaultTtl, validateTtl);\n\tconst retentionPolicy = policyNode(\n\t\t\"retentionPolicy\",\n\t\tretention?.maxSize,\n\t\tvalidateRetentionMaxSize,\n\t);\n\n\tlet currentMaxSize = isNodeOpt(maxSize) ? undefined : maxSize;\n\tlet currentDefaultTtl = isNodeOpt(defaultTtl) ? undefined : defaultTtl;\n\tlet currentRetentionMaxSize = isNodeOpt(retention?.maxSize)\n\t\t? undefined\n\t\t: retention?.maxSize === undefined\n\t\t\t? undefined\n\t\t\t: validateRetentionMaxSize(retention.maxSize);\n\tconst ttlHeap = deadlines<K>();\n\tlet ttlTimer: Node<unknown> | null = null;\n\tlet ttlTimerDue: number | undefined;\n\tconst bindDeps = new WeakSet<Node<unknown>>();\n\tlet bindSeq = 0;\n\tlet apply: Node<MapChange<K, V>>;\n\tconst selectMemo = new ViewMemoCache<\n\t\t(value: V, key: K) => boolean,\n\t\tReactiveView<MapChange<K, V>, ReadonlyMap<K, V>>\n\t>(viewCache);\n\tlet selectSeq = 0;\n\n\tconst policyInputs = new PolicyInputs([intent as Node<unknown>]);\n\tconst lruReader = policyInputs.add(lruPolicy);\n\tconst ttlReader = policyInputs.add(ttlPolicy);\n\tconst retentionReader = policyInputs.add(retentionPolicy);\n\n\tfunction emitExpired(ctx: Ctx, entries: Array<[K, V]>): void {\n\t\tfor (const [key, previous] of entries)\n\t\t\tctx.down([[\"DATA\", { kind: \"delete\", key, previous, reason: \"expired\" }]]);\n\t}\n\n\tfunction emitLruEvicted(ctx: Ctx, entries: Array<[K, V]>): void {\n\t\tfor (const [key, previous] of entries)\n\t\t\tctx.down([[\"DATA\", { kind: \"delete\", key, previous, reason: \"lru-evict\" }]]);\n\t}\n\n\tfunction emitArchived(ctx: Ctx, entries: Array<[K, V]>): void {\n\t\tfor (const [key, previous] of entries)\n\t\t\tctx.down([[\"DATA\", { kind: \"delete\", key, previous, reason: \"archived\" }]]);\n\t}\n\n\tfunction nextValidExpiry(): { readonly key: K; readonly expiresAt: number } | undefined {\n\t\tfor (;;) {\n\t\t\tconst top = ttlHeap.peek();\n\t\t\tif (top === undefined) return undefined;\n\t\t\tif (backend.expiresAtOf(top.key) === top.expiresAt) return top;\n\t\t\tttlHeap.pop();\n\t\t}\n\t}\n\n\tfunction scheduleTtl(ctx: Ctx, body: NodeFn): void {\n\t\tfor (;;) {\n\t\t\tconst next = nextValidExpiry();\n\t\t\tif (next === undefined) {\n\t\t\t\tif (ttlTimer) ctx.rewireNext.unsubscribeDep(ttlTimer, body);\n\t\t\t\tttlTimer = null;\n\t\t\t\tttlTimerDue = undefined;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (next.expiresAt <= backend.nowMs()) {\n\t\t\t\temitExpired(ctx, backend.pruneExpired());\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (ttlTimerDue === next.expiresAt) return;\n\t\t\tif (ttlTimer) ctx.rewireNext.unsubscribeDep(ttlTimer, body);\n\t\t\tttlTimerDue = next.expiresAt;\n\t\t\tttlTimer = initNode(timer(Math.max(0, next.expiresAt - backend.nowMs())), [], base);\n\t\t\tctx.rewireNext.subscribeDep(ttlTimer, body);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tfunction applyIntent(ctx: Ctx, intentValue: MapIntent<K, V>): void {\n\t\tif (intentValue.kind === \"set\") {\n\t\t\tconst ttl = intentValue.ttl ?? currentDefaultTtl;\n\t\t\tconst expiresAt = backend.resolveExpiresAt(ttl);\n\t\t\tbackend.set(intentValue.key, intentValue.value, expiresAt);\n\t\t\tif (expiresAt !== undefined) ttlHeap.push({ key: intentValue.key, expiresAt });\n\t\t\tctx.down([[\"DATA\", { kind: \"set\", key: intentValue.key, value: intentValue.value }]]);\n\t\t\temitLruEvicted(ctx, backend.enforceLru(currentMaxSize));\n\t\t\temitArchived(\n\t\t\t\tctx,\n\t\t\t\tbackend.enforceRetention(\n\t\t\t\t\tretention ? { maxSize: currentRetentionMaxSize, score: retention.score } : undefined,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tif (intentValue.kind === \"delete\") {\n\t\t\tconst previous = backend.delete(intentValue.key);\n\t\t\tif (previous.found)\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t{ kind: \"delete\", key: intentValue.key, previous: previous.value, reason: \"explicit\" },\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\treturn;\n\t\t}\n\t\tif (intentValue.kind === \"clear\") {\n\t\t\tconst count = backend.clear();\n\t\t\tif (count > 0) ctx.down([[\"DATA\", { kind: \"clear\", count }]]);\n\t\t\treturn;\n\t\t}\n\t\tif (intentValue.kind === \"pruneExpired\") {\n\t\t\temitExpired(ctx, backend.pruneExpired());\n\t\t\treturn;\n\t\t}\n\t\temitExpired(ctx, backend.pruneKeyIfExpired(intentValue.key));\n\t}\n\n\tconst applyBody: NodeFn = (ctx: Ctx) => {\n\t\tconst nextMaxSize = lruReader.read(ctx, currentMaxSize);\n\t\tcurrentMaxSize = nextMaxSize === undefined ? undefined : validateMaxSize(nextMaxSize);\n\t\tconst nextTtl = ttlReader.read(ctx, currentDefaultTtl);\n\t\tcurrentDefaultTtl = nextTtl === undefined ? undefined : validateTtl(nextTtl);\n\t\tconst nextRetentionMaxSize = retentionReader.read(ctx, currentRetentionMaxSize);\n\t\tcurrentRetentionMaxSize =\n\t\t\tnextRetentionMaxSize === undefined\n\t\t\t\t? undefined\n\t\t\t\t: validateRetentionMaxSize(nextRetentionMaxSize);\n\n\t\tfor (const item of (depBatch(ctx, 0) ?? []) as readonly MapIntent<K, V>[]) {\n\t\t\tapplyIntent(ctx, item);\n\t\t}\n\t\tconst deps = apply.deps;\n\t\tfor (let i = 1; i < depCount(ctx); i++) {\n\t\t\tif (i === lruReader.index || i === ttlReader.index || i === retentionReader.index) continue;\n\t\t\tconst dep = deps[i];\n\t\t\tif (dep && bindDeps.has(dep)) {\n\t\t\t\tfor (const item of (depBatch(ctx, i) ?? []) as readonly MapIntent<K, V>[]) {\n\t\t\t\t\tapplyIntent(ctx, item);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tdep === ttlTimer &&\n\t\t\t\t((depBatch(ctx, i)?.length ?? 0) > 0 || isTerminalComplete(depTerminal(ctx, i)))\n\t\t\t) {\n\t\t\t\tif (ttlTimer) ctx.rewireNext.unsubscribeDep(ttlTimer, applyBody);\n\t\t\t\tttlTimer = null;\n\t\t\t\tttlTimerDue = undefined;\n\t\t\t\temitExpired(ctx, backend.pruneExpired());\n\t\t\t}\n\t\t}\n\t\t// Lowering a reactive maxSize is itself a policy-driven backend mutation (D68).\n\t\temitLruEvicted(ctx, backend.enforceLru(currentMaxSize));\n\t\temitArchived(\n\t\t\tctx,\n\t\t\tbackend.enforceRetention(\n\t\t\t\tretention ? { maxSize: currentRetentionMaxSize, score: retention.score } : undefined,\n\t\t\t),\n\t\t);\n\t\tscheduleTtl(ctx, applyBody);\n\t};\n\n\tconst applyOp: Operator<unknown, MapChange<K, V>> = {\n\t\tfactory: \"reactiveMap.apply\",\n\t\tbody: applyBody,\n\t\topts: { partial: true },\n\t};\n\tapply = graph\n\t\t? graph.initNode(applyOp, policyInputs.deps as readonly Node<unknown>[], {\n\t\t\t\tname: name ? `${name}.apply` : undefined,\n\t\t\t\tmeta: { kind: \"collection_policy_apply\", collection: \"reactiveMap\" },\n\t\t\t\t...(restorable ? { restore: { ref: \"reactiveMap.apply\" } } : {}),\n\t\t\t})\n\t\t: initNode(applyOp, policyInputs.deps, {\n\t\t\t\t...base,\n\t\t\t\tname: name ? `${name}.apply` : undefined,\n\t\t\t});\n\n\tconst pullId = Symbol(name ? `${name}.snapshot` : \"reactiveMap.snapshot\");\n\tconst snapshotPrepOp: Operator<unknown, SnapshotPrep<K, V>> = {\n\t\tfactory: \"reactiveMap.snapshotPrep\",\n\t\tbody: (ctx: Ctx) => {\n\t\t\tconst expired = backend.pruneExpired().map(\n\t\t\t\t([key, previous]): MapChange<K, V> => ({\n\t\t\t\t\tkind: \"delete\",\n\t\t\t\t\tkey,\n\t\t\t\t\tprevious,\n\t\t\t\t\treason: \"expired\",\n\t\t\t\t}),\n\t\t\t);\n\t\t\tctx.down([[\"DATA\", { snapshot: backend.snapshot(), expired }]]);\n\t\t},\n\t\topts: {\n\t\t\t...base,\n\t\t\tpullId,\n\t\t\tpartial: true,\n\t\t},\n\t};\n\tconst snapshotPrep = graph\n\t\t? graph.initNode(snapshotPrepOp, [apply as Node<unknown>], {\n\t\t\t\tname: name ? `${name}.snapshotPrep` : undefined,\n\t\t\t\tmeta: { kind: \"collection_snapshot_prep\", collection: \"reactiveMap\" },\n\t\t\t\t...(restorable ? { restore: { ref: \"reactiveMap.snapshotPrep\" } } : {}),\n\t\t\t})\n\t\t: initNode(snapshotPrepOp, [apply as Node<unknown>], {\n\t\t\t\t...base,\n\t\t\t\tname: name ? `${name}.snapshotPrep` : undefined,\n\t\t\t});\n\tconst deltaOp: Operator<unknown, MapChange<K, V>> = {\n\t\tfactory: \"reactiveMap.delta\",\n\t\tbody: (ctx: Ctx) => {\n\t\t\tfor (const change of depBatch(ctx, 0) ?? []) {\n\t\t\t\tctx.down([[\"DATA\", change as MapChange<K, V>]]);\n\t\t\t}\n\t\t\tfor (const prep of depBatch(ctx, 1) ?? []) {\n\t\t\t\tfor (const change of (prep as SnapshotPrep<K, V>).expired) ctx.down([[\"DATA\", change]]);\n\t\t\t}\n\t\t},\n\t\topts: { partial: true },\n\t};\n\tconst delta = graph\n\t\t? graph.initNode(deltaOp, [apply as Node<unknown>, snapshotPrep as Node<unknown>], {\n\t\t\t\tname: name ? `${name}.delta` : undefined,\n\t\t\t\tmeta: { kind: \"collection_delta\", collection: \"reactiveMap\" },\n\t\t\t\t...(restorable ? { restore: { ref: \"reactiveMap.delta\" } } : {}),\n\t\t\t})\n\t\t: initNode(deltaOp, [apply as Node<unknown>, snapshotPrep as Node<unknown>], {\n\t\t\t\t...base,\n\t\t\t\tname: name ? `${name}.delta` : undefined,\n\t\t\t});\n\tconst snapshotOp: Operator<unknown, ReadonlyMap<K, V>> = {\n\t\tfactory: \"reactiveMap.snapshot\",\n\t\tbody: (ctx: Ctx) => {\n\t\t\tfor (const prep of depBatch(ctx, 0) ?? []) {\n\t\t\t\tctx.down([[\"DATA\", (prep as SnapshotPrep<K, V>).snapshot]]);\n\t\t\t}\n\t\t},\n\t\topts: { partial: true },\n\t};\n\tconst snapshot = graph\n\t\t? graph.initNode(snapshotOp, [snapshotPrep as Node<unknown>], {\n\t\t\t\tname: name ? `${name}.snapshot` : undefined,\n\t\t\t\tmeta: { kind: \"collection_snapshot\", collection: \"reactiveMap\" },\n\t\t\t\t...(restorable ? { restore: { ref: \"reactiveMap.snapshot\" } } : {}),\n\t\t\t})\n\t\t: initNode(snapshotOp, [snapshotPrep as Node<unknown>], {\n\t\t\t\t...base,\n\t\t\t\tname: name ? `${name}.snapshot` : undefined,\n\t\t\t});\n\tif (restorable) {\n\t\tregisterBackendStateContributor(intent as Node<unknown>, () => backend.checkpointEntries());\n\t}\n\tconst releaseApply = graph\n\t\t? graph.retain(apply, { reason: \"reactiveMap.apply\" })\n\t\t: apply.subscribe(() => {});\n\tconst binds: Array<() => void> = [];\n\n\tfunction doSet(key: K, value: V, ttl?: number): void {\n\t\tif (ttl !== undefined) validateTtl(ttl);\n\t\tintent.down([\n\t\t\t[\"DATA\", ttl === undefined ? { kind: \"set\", key, value } : { kind: \"set\", key, value, ttl }],\n\t\t]);\n\t}\n\n\tfunction read(key: K): Lookup<V> {\n\t\tconst r = backend.lookup(key);\n\t\tif (!r.found && r.expired) intent.down([[\"DATA\", { kind: \"pruneKey\", key }]]);\n\t\treturn r;\n\t}\n\n\tfunction selectedSnapshot(predicate: (value: V, key: K) => boolean): ReadonlyMap<K, V> {\n\t\tconst out = new Map<K, V>();\n\t\tfor (const [key, value] of backend.snapshot()) {\n\t\t\tif (predicate(value, key)) out.set(key, value);\n\t\t}\n\t\treturn out;\n\t}\n\n\tfunction select(\n\t\tpredicate: (value: V, key: K) => boolean,\n\t): ReactiveView<MapChange<K, V>, ReadonlyMap<K, V>> {\n\t\tif (typeof predicate !== \"function\")\n\t\t\tthrow new TypeError(\"reactiveMap.select: predicate must be a function\");\n\t\tconst cached = selectMemo.get(predicate);\n\t\tif (cached !== undefined) return cached;\n\t\tlet view: ReactiveView<MapChange<K, V>, ReadonlyMap<K, V>>;\n\t\tview = lightReactiveView<MapChange<K, V>, ReadonlyMap<K, V>>(delta as Node<unknown>, {\n\t\t\tdispatcher,\n\t\t\tgraph,\n\t\t\tfactory: \"reactiveMap.select\",\n\t\t\tname: name ? `${name}.select#${selectSeq++}` : undefined,\n\t\t\tmaterializeSnapshot: () => selectedSnapshot(predicate),\n\t\t\tonDispose: () => {\n\t\t\t\tselectMemo.deleteValue(view);\n\t\t\t},\n\t\t});\n\t\tselectMemo.set(predicate, view);\n\t\treturn view;\n\t}\n\n\treturn {\n\t\tdelta,\n\t\tsnapshot,\n\t\tpullId,\n\n\t\tget size(): number {\n\t\t\treturn backend.size;\n\t\t},\n\t\tget(key: K): V | undefined {\n\t\t\tconst r = read(key);\n\t\t\treturn r.found ? r.value : undefined;\n\t\t},\n\t\thas(key: K): boolean {\n\t\t\treturn read(key).found;\n\t\t},\n\t\ttoMap(): ReadonlyMap<K, V> {\n\t\t\tintent.down([[\"DATA\", { kind: \"pruneExpired\" }]]);\n\t\t\treturn backend.snapshot();\n\t\t},\n\t\tselect,\n\n\t\tset(key: K, value: V, opts?: { ttl?: number }): void {\n\t\t\tdoSet(key, value, opts?.ttl);\n\t\t},\n\t\tsetMany(entries: Iterable<readonly [K, V]>, opts?: { ttl?: number }): void {\n\t\t\tfor (const [k, v] of entries) doSet(k, v, opts?.ttl);\n\t\t},\n\t\tdelete(key: K): void {\n\t\t\tintent.down([[\"DATA\", { kind: \"delete\", key }]]);\n\t\t},\n\t\tdeleteMany(keys: Iterable<K>): void {\n\t\t\tfor (const k of keys) {\n\t\t\t\tintent.down([[\"DATA\", { kind: \"delete\", key: k }]]);\n\t\t\t}\n\t\t},\n\t\tclear(): void {\n\t\t\tintent.down([[\"DATA\", { kind: \"clear\" }]]);\n\t\t},\n\t\tpruneExpired(): void {\n\t\t\tintent.down([[\"DATA\", { kind: \"pruneExpired\" }]]);\n\t\t},\n\n\t\tsetFrom(src: Node<readonly [K, V]>): () => void {\n\t\t\tif (graph === undefined)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"reactiveMap.setFrom requires options.graph so the input fold is describe-visible (D61)\",\n\t\t\t\t);\n\t\t\tconst op: Operator<readonly [K, V], MapIntent<K, V>> = {\n\t\t\t\tfactory: \"reactiveMap.bindSource\",\n\t\t\t\tbody: (ctx: Ctx) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfor (const [k, v] of (depBatch(ctx, 0) ?? []) as readonly (readonly [K, V])[]) {\n\t\t\t\t\t\t\tctx.down([[\"DATA\", { kind: \"set\", key: k, value: v }]]);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"reactiveMap.bindSource failed\")]]);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst folder = graph.initNode(op, [src], {\n\t\t\t\tname: name ? `${name}.bind#${bindSeq++}` : undefined,\n\t\t\t\tmeta: { kind: \"collection_bind_source\", collection: \"reactiveMap\" },\n\t\t\t});\n\t\t\tbindDeps.add(folder as Node<unknown>);\n\t\t\tapply.subscribeDep(folder as Node<unknown>, applyBody);\n\t\t\tlet active = true;\n\t\t\tconst dispose = () => {\n\t\t\t\tif (!active) return;\n\t\t\t\tactive = false;\n\t\t\t\tapply.unsubscribeDep(folder as Node<unknown>, applyBody);\n\t\t\t};\n\t\t\tbinds.push(dispose);\n\t\t\treturn dispose;\n\t\t},\n\t\tdispose(): void {\n\t\t\tselectMemo.disposeAll();\n\t\t\tfor (const d of binds) d();\n\t\t\tbinds.length = 0;\n\t\t\treleaseApply();\n\t\t},\n\t};\n}\n","import type {\n\tIndexRow,\n\tReactiveIndex,\n\tReactiveIndexOptions,\n} from \"../graph/data-structures/reactive-index.js\";\nimport { restoreReactiveIndexFromBackendState } from \"../graph/data-structures/reactive-index.js\";\nimport type { ReactiveListOptions } from \"../graph/data-structures/reactive-list.js\";\nimport { type ReactiveList, reactiveList } from \"../graph/data-structures/reactive-list.js\";\nimport type { ReactiveLogOptions } from \"../graph/data-structures/reactive-log.js\";\nimport { type ReactiveLog, reactiveLog } from \"../graph/data-structures/reactive-log.js\";\nimport type { ReactiveMap, ReactiveMapOptions } from \"../graph/data-structures/reactive-map.js\";\nimport { restoreReactiveMapFromBackendState } from \"../graph/data-structures/reactive-map.js\";\nimport type {\n\tReactiveIndexRestoreState,\n\tReactiveListRestoreState,\n\tReactiveLogRestoreState,\n\tReactiveMapRestoreState,\n} from \"../storage/index.js\";\n\nfunction isListRestoreState<T>(\n\tstate: ReactiveListRestoreState<T> | readonly T[],\n): state is ReactiveListRestoreState<T> {\n\treturn !Array.isArray(state);\n}\n\nfunction restoreListValues<T>(state: ReactiveListRestoreState<T> | readonly T[]): readonly T[] {\n\tif (!isListRestoreState(state)) return state;\n\tif (state.kind !== \"reactiveList\") throw new TypeError(\"restore state kind must be reactiveList\");\n\treturn state.state;\n}\n\nfunction isLogRestoreState<T>(\n\tstate: ReactiveLogRestoreState<T> | readonly T[],\n): state is ReactiveLogRestoreState<T> {\n\treturn !Array.isArray(state);\n}\n\nfunction restoreLogValues<T>(state: ReactiveLogRestoreState<T> | readonly T[]): readonly T[] {\n\tif (!isLogRestoreState(state)) return state;\n\tif (state.kind !== \"reactiveLog\") throw new TypeError(\"restore state kind must be reactiveLog\");\n\treturn state.state;\n}\n\nfunction isMapRestoreState<K, V>(\n\tstate: ReactiveMapRestoreState<K, V> | readonly (readonly [K, V])[],\n): state is ReactiveMapRestoreState<K, V> {\n\treturn !Array.isArray(state);\n}\n\nfunction restoreMapEntries<K, V>(\n\tstate: ReactiveMapRestoreState<K, V> | readonly (readonly [K, V])[],\n): readonly (readonly [K, V])[] {\n\tif (!isMapRestoreState(state)) return state;\n\tif (state.kind !== \"reactiveMap\") throw new TypeError(\"restore state kind must be reactiveMap\");\n\treturn state.state;\n}\n\nfunction isIndexRestoreState<K, V>(\n\tstate: ReactiveIndexRestoreState<K, V> | readonly IndexRow<K, V>[],\n): state is ReactiveIndexRestoreState<K, V> {\n\treturn !Array.isArray(state);\n}\n\nfunction restoreIndexRows<K, V>(\n\tstate: ReactiveIndexRestoreState<K, V> | readonly IndexRow<K, V>[],\n): readonly IndexRow<K, V>[] {\n\tif (!isIndexRestoreState(state)) return state;\n\tif (state.kind !== \"reactiveIndex\") {\n\t\tthrow new TypeError(\"restore state kind must be reactiveIndex\");\n\t}\n\treturn state.state;\n}\n\n/** D161 synchronous collection-owned restore. This helper never reads storage. */\nexport function restoreReactiveList<T = unknown>(\n\tstate: ReactiveListRestoreState<T> | readonly T[],\n\toptions: ReactiveListOptions = {},\n): ReactiveList<T> {\n\tconst values = restoreListValues(state);\n\treturn reactiveList<T>(values, options);\n}\n\n/** D161 synchronous collection-owned restore. This helper never reads storage. */\nexport function restoreReactiveLog<T = unknown>(\n\tstate: ReactiveLogRestoreState<T> | readonly T[],\n\toptions: ReactiveLogOptions = {},\n): ReactiveLog<T> {\n\tconst values = restoreLogValues(state);\n\treturn reactiveLog<T>(values, options);\n}\n\n/** D161 synchronous collection-owned restore for map entries; policy config still comes from options. */\nexport function restoreReactiveMap<K = unknown, V = unknown>(\n\tstate: ReactiveMapRestoreState<K, V> | readonly (readonly [K, V])[],\n\toptions: ReactiveMapOptions<K, V> = {},\n): ReactiveMap<K, V> {\n\tconst entries = restoreMapEntries(state);\n\treturn restoreReactiveMapFromBackendState<K, V>(entries, options);\n}\n\n/** D161 synchronous collection-owned restore for sorted index rows; key-codec I/O stays outside. */\nexport function restoreReactiveIndex<K = unknown, V = unknown>(\n\tstate: ReactiveIndexRestoreState<K, V> | readonly IndexRow<K, V>[],\n\toptions: ReactiveIndexOptions = {},\n): ReactiveIndex<K, V> {\n\tconst rows = restoreIndexRows(state);\n\treturn restoreReactiveIndexFromBackendState<K, V>(rows, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGA,SAAS,4BAA4B,QAAyD;AAC7F,QAAM,aAAa,QAAQ;AAC3B,MAAI,eAAe,OAAW,QAAO;AACrC,MAAI,CAAC,OAAO,UAAU,UAAU,KAAK,aAAa,GAAG;AACpD,UAAM,IAAI,WAAW,4DAA4D,UAAU,GAAG;AAAA,EAC/F;AACA,SAAO;AACR;AAOO,IAAM,gBAAN,MAAsD;AAAA,EAC3C;AAAA,EACA;AAAA,EACA,OAAoC,CAAC;AAAA,EACrC,OAAO,oBAAI,IAAO;AAAA,EAEnC,YAAY,QAAqC,SAAkC,OAAO,IAAI;AAC7F,SAAK,aAAa,4BAA4B,MAAM;AACpD,SAAK,SAAS;AAAA,EACf;AAAA,EAEA,IAAI,KAAuB;AAC1B,UAAM,QAAQ,KAAK,KAAK,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oB,KAAK,EAAG,QAAO;AACxC,MAAI,MAAM,SAAS,iBAAiB;AACnC,UAAM,IAAI,UAAU,0CAA0C;AAAA,EAC/D;AACA,SAAO,MAAM;AACd;AAGO,SAAS,oBACf,OACA,UAA+B,CAAC,GACd;AAClB,QAAM,SAAS,kBAAkB,KAAK;AACtC,SAAO,aAAgB,QAAQ,OAAO;AACvC;AAGO,SAAS,mBACf,OACA,UAA8B,CAAC,GACd;AACjB,QAAM,SAAS,iBAAiB,KAAK;AACrC,SAAO,YAAe,QAAQ,OAAO;AACtC;AAGO,SAAS,mBACf,OACA,UAAoC,CAAC,GACjB;AACpB,QAAM,UAAU,kBAAkB,KAAK;AACvC,SAAO,mCAAyC,SAAS,OAAO;AACjE;AAGO,SAAS,qBACf,OACA,UAAgC,CAAC,GACX;AACtB,QAAM,OAAO,iBAAiB,KAAK;AACnC,SAAO,qCAA2C,MAAM,OAAO;AAChE;","names":["entry","initial"]}
@@ -5,7 +5,7 @@ import {
5
5
  checkpointValue,
6
6
  initNodeWithCore,
7
7
  toCheckpointJson
8
- } from "./chunk-SS2A464I.js";
8
+ } from "./chunk-CJIFGJQG.js";
9
9
  import {
10
10
  EnvironmentDrivers,
11
11
  Node,
@@ -23,7 +23,7 @@ import {
23
23
  subscriberCountOfNode,
24
24
  withEnvironmentDrivers,
25
25
  withNodeCore
26
- } from "./chunk-XKXWK2KP.js";
26
+ } from "./chunk-SHZDP2MQ.js";
27
27
  import {
28
28
  depCount,
29
29
  depLatest
@@ -37,7 +37,7 @@ import {
37
37
  assertStrictJsonObject,
38
38
  stableJsonString,
39
39
  strictCanonicalJsonBytes
40
- } from "./chunk-4VLAQHZI.js";
40
+ } from "./chunk-K7FB3JTD.js";
41
41
 
42
42
  // src/graph/blueprint.ts
43
43
  var GRAPH_BLUEPRINT_VERSION = "graphrefly.blueprint.v1";
@@ -313,28 +313,110 @@ function cloneTopologyValue(value, seen) {
313
313
  return out;
314
314
  }
315
315
 
316
- // src/graph/graph.ts
316
+ // src/graph/graph-lifecycle.ts
317
317
  var restoreRegistrars = /* @__PURE__ */ new WeakMap();
318
318
  var lifecycleRegistrars = /* @__PURE__ */ new WeakMap();
319
- function nodeOwner(n) {
320
- return getNodeOwner(n);
319
+
320
+ // src/graph/graph-support.ts
321
+ function isNonAuthoritativeCollectionHelperMeta(meta) {
322
+ return meta?.kind === "collection_delta" || meta?.kind === "collection_intent" || meta?.kind === "collection_policy_apply" || meta?.kind === "collection_snapshot" || meta?.kind === "collection_snapshot_prep";
321
323
  }
322
- function assertGraphLocalNode(owner, n, label) {
323
- if (isNodeRuntimeReleased(n)) {
324
- throw new Error(`${label} has been released from its graph lifecycle (D122)`);
325
- }
326
- const existing = nodeOwner(n);
327
- if (existing !== void 0 && existing !== owner) {
324
+ function assertCheckpointQuiescentStatus(status, id, op) {
325
+ if (status === "pending" || status === "dirty") {
328
326
  throw new Error(
329
- `${label} belongs to a different graph; cross-graph deps require a wire bridge`
327
+ `${op}: node '${id}' has non-quiescent status '${status}' that cannot be checkpoint-restored yet`
330
328
  );
331
329
  }
332
330
  }
333
- var StateNode = class extends Node {
334
- set(v) {
335
- this.down([["DATA", v]]);
331
+ function topologyPathMatches(eventPath, path) {
332
+ return eventPath === path || eventPath.startsWith(`${path}::`);
333
+ }
334
+ function prefixTopologyPath(prefix, path) {
335
+ return `${prefix}::${path}`;
336
+ }
337
+ function cloneTopologyEvent(event) {
338
+ const deps = Object.freeze([...event.deps]);
339
+ const prevDeps = event.prevDeps === void 0 ? void 0 : Object.freeze([...event.prevDeps]);
340
+ return Object.freeze({
341
+ kind: event.kind,
342
+ path: event.path,
343
+ deps,
344
+ ...prevDeps !== void 0 ? { prevDeps } : {},
345
+ ...event.factory !== void 0 ? { factory: event.factory } : {},
346
+ seq: event.seq
347
+ });
348
+ }
349
+ function checkpointFactory(name, node, unregistered, restore, meta) {
350
+ const state = checkpointStateOfNode(node);
351
+ if (unregistered) {
352
+ return {
353
+ kind: "local-only",
354
+ name,
355
+ reason: "node is an unregistered live dependency auto-discovered from topology"
356
+ };
336
357
  }
337
- };
358
+ if (restore === void 0 && typeof meta?.kind === "string" && meta.kind.startsWith("collection_")) {
359
+ return {
360
+ kind: "local-only",
361
+ name,
362
+ reason: "collection helper node has no backend checkpoint restore metadata"
363
+ };
364
+ }
365
+ if (restore !== void 0) {
366
+ const out = {
367
+ kind: "registry-ref",
368
+ ref: toCheckpointJson(restore.ref, `${name}.factory.ref`)
369
+ };
370
+ if (restore.config !== void 0)
371
+ out.config = toCheckpointJson(restore.config, `${name}.factory.config`);
372
+ if (restore.configVersion !== void 0)
373
+ out.configVersion = toCheckpointJson(restore.configVersion, `${name}.factory.configVersion`);
374
+ return out;
375
+ }
376
+ if (state.handle !== null) {
377
+ return {
378
+ kind: "local-only",
379
+ name,
380
+ reason: "node uses a function body; first-cut checkpoints do not serialize local functions"
381
+ };
382
+ }
383
+ return { kind: "registry-ref", ref: name };
384
+ }
385
+ function explainSubset(snap, chain) {
386
+ const fwd = /* @__PURE__ */ new Map();
387
+ const rev = /* @__PURE__ */ new Map();
388
+ const push = (map, k, v) => {
389
+ const a = map.get(k);
390
+ if (a) a.push(v);
391
+ else map.set(k, [v]);
392
+ };
393
+ for (const e of snap.edges) {
394
+ push(fwd, e.from, e.to);
395
+ push(rev, e.to, e.from);
396
+ }
397
+ const reach = (start, adj) => {
398
+ const seen = /* @__PURE__ */ new Set([start]);
399
+ const stack = [start];
400
+ while (stack.length > 0) {
401
+ const cur = stack.pop();
402
+ for (const nxt of adj.get(cur) ?? []) {
403
+ if (!seen.has(nxt)) {
404
+ seen.add(nxt);
405
+ stack.push(nxt);
406
+ }
407
+ }
408
+ }
409
+ return seen;
410
+ };
411
+ const onPath = new Set([...reach(chain.from, fwd)].filter((id) => reach(chain.to, rev).has(id)));
412
+ return {
413
+ ...snap.name !== void 0 ? { name: snap.name } : {},
414
+ nodes: snap.nodes.filter((n) => onPath.has(n.id)),
415
+ edges: snap.edges.filter((e) => onPath.has(e.from) && onPath.has(e.to))
416
+ };
417
+ }
418
+
419
+ // src/graph/graph-topology-group.ts
338
420
  var GraphTopologyGroup = class {
339
421
  name;
340
422
  _graph;
@@ -395,6 +477,27 @@ var GraphTopologyGroup = class {
395
477
  }
396
478
  }
397
479
  };
480
+
481
+ // src/graph/graph.ts
482
+ function nodeOwner(n) {
483
+ return getNodeOwner(n);
484
+ }
485
+ function assertGraphLocalNode(owner, n, label) {
486
+ if (isNodeRuntimeReleased(n)) {
487
+ throw new Error(`${label} has been released from its graph lifecycle (D122)`);
488
+ }
489
+ const existing = nodeOwner(n);
490
+ if (existing !== void 0 && existing !== owner) {
491
+ throw new Error(
492
+ `${label} belongs to a different graph; cross-graph deps require a wire bridge`
493
+ );
494
+ }
495
+ }
496
+ var StateNode = class extends Node {
497
+ set(v) {
498
+ this.down([["DATA", v]]);
499
+ }
500
+ };
398
501
  var Graph = class {
399
502
  name;
400
503
  _dispatcher;
@@ -1060,103 +1163,6 @@ var Graph = class {
1060
1163
  return out;
1061
1164
  }
1062
1165
  };
1063
- function isNonAuthoritativeCollectionHelperMeta(meta) {
1064
- return meta?.kind === "collection_delta" || meta?.kind === "collection_intent" || meta?.kind === "collection_policy_apply" || meta?.kind === "collection_snapshot" || meta?.kind === "collection_snapshot_prep";
1065
- }
1066
- function assertCheckpointQuiescentStatus(status, id, op) {
1067
- if (status === "pending" || status === "dirty") {
1068
- throw new Error(
1069
- `${op}: node '${id}' has non-quiescent status '${status}' that cannot be checkpoint-restored yet`
1070
- );
1071
- }
1072
- }
1073
- function topologyPathMatches(eventPath, path) {
1074
- return eventPath === path || eventPath.startsWith(`${path}::`);
1075
- }
1076
- function prefixTopologyPath(prefix, path) {
1077
- return `${prefix}::${path}`;
1078
- }
1079
- function cloneTopologyEvent(event) {
1080
- const deps = Object.freeze([...event.deps]);
1081
- const prevDeps = event.prevDeps === void 0 ? void 0 : Object.freeze([...event.prevDeps]);
1082
- return Object.freeze({
1083
- kind: event.kind,
1084
- path: event.path,
1085
- deps,
1086
- ...prevDeps !== void 0 ? { prevDeps } : {},
1087
- ...event.factory !== void 0 ? { factory: event.factory } : {},
1088
- seq: event.seq
1089
- });
1090
- }
1091
- function checkpointFactory(name, node, unregistered, restore, meta) {
1092
- const state = checkpointStateOfNode(node);
1093
- if (unregistered) {
1094
- return {
1095
- kind: "local-only",
1096
- name,
1097
- reason: "node is an unregistered live dependency auto-discovered from topology"
1098
- };
1099
- }
1100
- if (restore === void 0 && typeof meta?.kind === "string" && meta.kind.startsWith("collection_")) {
1101
- return {
1102
- kind: "local-only",
1103
- name,
1104
- reason: "collection helper node has no backend checkpoint restore metadata"
1105
- };
1106
- }
1107
- if (restore !== void 0) {
1108
- const out = {
1109
- kind: "registry-ref",
1110
- ref: toCheckpointJson(restore.ref, `${name}.factory.ref`)
1111
- };
1112
- if (restore.config !== void 0)
1113
- out.config = toCheckpointJson(restore.config, `${name}.factory.config`);
1114
- if (restore.configVersion !== void 0)
1115
- out.configVersion = toCheckpointJson(restore.configVersion, `${name}.factory.configVersion`);
1116
- return out;
1117
- }
1118
- if (state.handle !== null) {
1119
- return {
1120
- kind: "local-only",
1121
- name,
1122
- reason: "node uses a function body; first-cut checkpoints do not serialize local functions"
1123
- };
1124
- }
1125
- return { kind: "registry-ref", ref: name };
1126
- }
1127
- function explainSubset(snap, chain) {
1128
- const fwd = /* @__PURE__ */ new Map();
1129
- const rev = /* @__PURE__ */ new Map();
1130
- const push = (map, k, v) => {
1131
- const a = map.get(k);
1132
- if (a) a.push(v);
1133
- else map.set(k, [v]);
1134
- };
1135
- for (const e of snap.edges) {
1136
- push(fwd, e.from, e.to);
1137
- push(rev, e.to, e.from);
1138
- }
1139
- const reach = (start, adj) => {
1140
- const seen = /* @__PURE__ */ new Set([start]);
1141
- const stack = [start];
1142
- while (stack.length > 0) {
1143
- const cur = stack.pop();
1144
- for (const nxt of adj.get(cur) ?? []) {
1145
- if (!seen.has(nxt)) {
1146
- seen.add(nxt);
1147
- stack.push(nxt);
1148
- }
1149
- }
1150
- }
1151
- return seen;
1152
- };
1153
- const onPath = new Set([...reach(chain.from, fwd)].filter((id) => reach(chain.to, rev).has(id)));
1154
- return {
1155
- ...snap.name !== void 0 ? { name: snap.name } : {},
1156
- nodes: snap.nodes.filter((n) => onPath.has(n.id)),
1157
- edges: snap.edges.filter((e) => onPath.has(e.from) && onPath.has(e.to))
1158
- };
1159
- }
1160
1166
  function graph(opts = {}) {
1161
1167
  return new Graph(opts);
1162
1168
  }
@@ -1186,4 +1192,4 @@ export {
1186
1192
  restoreStateNodeInGraph,
1187
1193
  restoreNodeInGraph
1188
1194
  };
1189
- //# sourceMappingURL=chunk-3JR3EDB2.js.map
1195
+ //# sourceMappingURL=chunk-EOKT4QFF.js.map