@logixjs/core 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (398) hide show
  1. package/LICENSE +201 -0
  2. package/dist/{Action-mqVvtEHt.d.ts → Action-DYl88bwj.d.ts} +1 -1
  3. package/dist/{Action-BkRHy2vg.d.cts → Action-DkxsI_DK.d.cts} +1 -1
  4. package/dist/Action.cjs.map +1 -1
  5. package/dist/Action.d.cts +1 -1
  6. package/dist/Action.d.ts +1 -1
  7. package/dist/Action.js +2 -2
  8. package/dist/{Actions-AsQ07yTP.d.cts → Actions-Dicm7jdc.d.cts} +2 -2
  9. package/dist/{Actions-AsQ07yTP.d.ts → Actions-Dicm7jdc.d.ts} +2 -2
  10. package/dist/Actions.cjs.map +1 -1
  11. package/dist/Actions.d.cts +1 -1
  12. package/dist/Actions.d.ts +1 -1
  13. package/dist/Actions.js +1 -1
  14. package/dist/{Bound-BN1DQ_lM.d.ts → Bound-1OJLzVIS.d.ts} +2 -2
  15. package/dist/{Bound-BPIfH9SS.d.cts → Bound-BMLrtQ1V.d.cts} +2 -2
  16. package/dist/Bound.cjs +1737 -399
  17. package/dist/Bound.cjs.map +1 -1
  18. package/dist/Bound.d.cts +5 -5
  19. package/dist/Bound.d.ts +5 -5
  20. package/dist/Bound.js +19 -17
  21. package/dist/{Debug-B5q5Bkzx.d.ts → Debug-DKrWP5H1.d.ts} +40 -22
  22. package/dist/{Debug-Bq8Sqjcr.d.cts → Debug-hIT44XsY.d.cts} +40 -22
  23. package/dist/Debug.cjs +1348 -318
  24. package/dist/Debug.cjs.map +1 -1
  25. package/dist/Debug.d.cts +12 -11
  26. package/dist/Debug.d.ts +12 -11
  27. package/dist/Debug.js +20 -11
  28. package/dist/EffectOp.cjs +15 -6
  29. package/dist/EffectOp.cjs.map +1 -1
  30. package/dist/EffectOp.js +3 -3
  31. package/dist/Env.cjs +772 -6
  32. package/dist/Env.cjs.map +1 -1
  33. package/dist/Env.js +5 -2
  34. package/dist/ExternalStore-DqJKKRJ4.d.ts +61 -0
  35. package/dist/ExternalStore-JC-gAgEI.d.cts +61 -0
  36. package/dist/ExternalStore.cjs +774 -0
  37. package/dist/ExternalStore.cjs.map +1 -0
  38. package/dist/ExternalStore.d.cts +8 -0
  39. package/dist/ExternalStore.d.ts +8 -0
  40. package/dist/ExternalStore.js +19 -0
  41. package/dist/ExternalStore.js.map +1 -0
  42. package/dist/{Flow-BhpjE22E.d.ts → Flow-CZmXRDqp.d.cts} +13 -4
  43. package/dist/{Flow-1fZT8MpX.d.cts → Flow-DIVDxz7R.d.ts} +13 -4
  44. package/dist/Flow.cjs +765 -148
  45. package/dist/Flow.cjs.map +1 -1
  46. package/dist/Flow.d.cts +6 -6
  47. package/dist/Flow.d.ts +6 -6
  48. package/dist/Flow.js +9 -8
  49. package/dist/{Handle-D_cLW1Z3.d.ts → Handle-Bo6cAFut.d.ts} +1 -1
  50. package/dist/{Handle-D8D1zPb_.d.cts → Handle-CfDvSqN7.d.cts} +1 -1
  51. package/dist/Handle.d.cts +5 -5
  52. package/dist/Handle.d.ts +5 -5
  53. package/dist/{Kernel-8kC-jOda.d.cts → Kernel-CuXBF9S_.d.cts} +16 -7
  54. package/dist/{Kernel-CnGE1Fyk.d.ts → Kernel-D9guNwRL.d.ts} +16 -7
  55. package/dist/Kernel.cjs +814 -26
  56. package/dist/Kernel.cjs.map +1 -1
  57. package/dist/Kernel.d.cts +13 -12
  58. package/dist/Kernel.d.ts +13 -12
  59. package/dist/Kernel.js +7 -4
  60. package/dist/{Link-Db7975nU.d.ts → Link-CUM0yUCH.d.ts} +10 -3
  61. package/dist/{Link-fX8x1eCK.d.cts → Link-NAfR6uGD.d.cts} +10 -3
  62. package/dist/Link.cjs +1294 -121
  63. package/dist/Link.cjs.map +1 -1
  64. package/dist/Link.d.cts +5 -5
  65. package/dist/Link.d.ts +5 -5
  66. package/dist/Link.js +37 -29
  67. package/dist/{Logic-DRh4sDZj.d.cts → Logic-09VQpIj3.d.cts} +7 -4
  68. package/dist/{Logic-BRjEMr-W.d.ts → Logic-DKg7ghGy.d.ts} +7 -4
  69. package/dist/Logic.cjs +2 -1
  70. package/dist/Logic.cjs.map +1 -1
  71. package/dist/Logic.d.cts +5 -5
  72. package/dist/Logic.d.ts +5 -5
  73. package/dist/Logic.js +1 -1
  74. package/dist/{MatchBuilder-CJk5oCkR.d.cts → MatchBuilder-CsW5jgrL.d.ts} +1 -1
  75. package/dist/{MatchBuilder-0QOc-nlU.d.ts → MatchBuilder-Dksk07F4.d.cts} +1 -1
  76. package/dist/MatchBuilder.cjs +2 -2
  77. package/dist/MatchBuilder.cjs.map +1 -1
  78. package/dist/MatchBuilder.d.cts +6 -6
  79. package/dist/MatchBuilder.d.ts +6 -6
  80. package/dist/MatchBuilder.js +2 -2
  81. package/dist/Middleware-D8tUDLv_.d.cts +100 -0
  82. package/dist/Middleware-DS7CbTTN.d.ts +100 -0
  83. package/dist/Middleware.cjs +678 -58
  84. package/dist/Middleware.cjs.map +1 -1
  85. package/dist/Middleware.d.cts +2 -86
  86. package/dist/Middleware.d.ts +2 -86
  87. package/dist/Middleware.js +15 -12
  88. package/dist/{Module-DnzluX2J.d.ts → Module-B_Cntyms.d.ts} +54 -25
  89. package/dist/{Module-B_0xRDMR.d.cts → Module-CmNOVXzf.d.cts} +54 -25
  90. package/dist/Module.cjs +9331 -3317
  91. package/dist/Module.cjs.map +1 -1
  92. package/dist/Module.d.cts +7 -6
  93. package/dist/Module.d.ts +7 -6
  94. package/dist/Module.js +39 -31
  95. package/dist/ModuleTag-CGho_InD.d.ts +113 -0
  96. package/dist/ModuleTag-CITb8L_G.d.cts +113 -0
  97. package/dist/ModuleTag.cjs +7248 -2847
  98. package/dist/ModuleTag.cjs.map +1 -1
  99. package/dist/ModuleTag.d.cts +6 -6
  100. package/dist/ModuleTag.d.ts +6 -6
  101. package/dist/ModuleTag.js +35 -29
  102. package/dist/Observability-Bdhnx2Dv.d.ts +385 -0
  103. package/dist/Observability-DXGAFBIT.d.cts +385 -0
  104. package/dist/Observability.cjs +5093 -1556
  105. package/dist/Observability.cjs.map +1 -1
  106. package/dist/Observability.d.cts +6 -7
  107. package/dist/Observability.d.ts +6 -7
  108. package/dist/Observability.js +28 -23
  109. package/dist/{Platform-CHX8o-U4.d.ts → Platform-B4s8tg6C.d.cts} +4 -5
  110. package/dist/{Platform-C49Pv956.d.cts → Platform-BV_0MW7g.d.cts} +5 -2
  111. package/dist/{Platform-C49Pv956.d.ts → Platform-BV_0MW7g.d.ts} +5 -2
  112. package/dist/{Platform-CVlv0xLQ.d.cts → Platform-W0Mefy_e.d.ts} +4 -5
  113. package/dist/Platform.cjs +2 -1
  114. package/dist/Platform.cjs.map +1 -1
  115. package/dist/Platform.d.cts +2 -3
  116. package/dist/Platform.d.ts +2 -3
  117. package/dist/Platform.js +2 -2
  118. package/dist/{Process-CM9xbMdP.d.ts → Process-CO8G7HO9.d.cts} +30 -5
  119. package/dist/{Process-mL8fHDSB.d.cts → Process-Cyf6VNDR.d.ts} +30 -5
  120. package/dist/Process.cjs +1288 -120
  121. package/dist/Process.cjs.map +1 -1
  122. package/dist/Process.d.cts +6 -6
  123. package/dist/Process.d.ts +6 -6
  124. package/dist/Process.js +34 -26
  125. package/dist/ReadQuery-C_or5nLC.d.ts +128 -0
  126. package/dist/ReadQuery-DXLzCE0E.d.cts +614 -0
  127. package/dist/ReadQuery-DXLzCE0E.d.ts +614 -0
  128. package/dist/ReadQuery-Yve1lmUo.d.cts +128 -0
  129. package/dist/ReadQuery.cjs +290 -5
  130. package/dist/ReadQuery.cjs.map +1 -1
  131. package/dist/ReadQuery.d.cts +3 -2
  132. package/dist/ReadQuery.d.ts +3 -2
  133. package/dist/ReadQuery.js +23 -5
  134. package/dist/{Reflection-CQnKwPXj.d.ts → Reflection-B2Xi1e4Q.d.ts} +89 -7
  135. package/dist/{Reflection-Kabo1mlU.d.cts → Reflection-DNB4V4_e.d.cts} +89 -7
  136. package/dist/Reflection.cjs +3227 -1617
  137. package/dist/Reflection.cjs.map +1 -1
  138. package/dist/Reflection.d.cts +17 -15
  139. package/dist/Reflection.d.ts +17 -15
  140. package/dist/Reflection.js +33 -25
  141. package/dist/{Resource-Dy1xD_DG.d.cts → Resource-pKvQQ4x5.d.cts} +3 -3
  142. package/dist/{Resource-Dy1xD_DG.d.ts → Resource-pKvQQ4x5.d.ts} +3 -3
  143. package/dist/Resource.cjs +781 -15
  144. package/dist/Resource.cjs.map +1 -1
  145. package/dist/Resource.d.cts +1 -1
  146. package/dist/Resource.d.ts +1 -1
  147. package/dist/Resource.js +6 -3
  148. package/dist/{Root-7ADUMk4t.d.cts → Root-CCVuFHB6.d.cts} +3 -3
  149. package/dist/{Root-7ADUMk4t.d.ts → Root-CCVuFHB6.d.ts} +3 -3
  150. package/dist/Root.cjs +786 -20
  151. package/dist/Root.cjs.map +1 -1
  152. package/dist/Root.d.cts +2 -2
  153. package/dist/Root.d.ts +2 -2
  154. package/dist/Root.js +7 -3
  155. package/dist/{Runtime-CtyzZG4i.d.ts → Runtime-CRmvwK4I.d.ts} +70 -14
  156. package/dist/{Runtime-B-aL-f29.d.cts → Runtime-C_wJM9mN.d.cts} +70 -14
  157. package/dist/Runtime.cjs +4942 -1601
  158. package/dist/Runtime.cjs.map +1 -1
  159. package/dist/Runtime.d.cts +17 -15
  160. package/dist/Runtime.d.ts +17 -15
  161. package/dist/Runtime.js +44 -32
  162. package/dist/{ScopeRegistry-D1owDNSm.d.cts → ScopeRegistry-BhYzqWri.d.cts} +6 -6
  163. package/dist/{ScopeRegistry-D1owDNSm.d.ts → ScopeRegistry-BhYzqWri.d.ts} +6 -6
  164. package/dist/ScopeRegistry.cjs +776 -10
  165. package/dist/ScopeRegistry.cjs.map +1 -1
  166. package/dist/ScopeRegistry.d.cts +1 -1
  167. package/dist/ScopeRegistry.d.ts +1 -1
  168. package/dist/ScopeRegistry.js +6 -3
  169. package/dist/{State-CU50R26M.d.cts → State-rNFsFPTl.d.cts} +2 -2
  170. package/dist/{State-CU50R26M.d.ts → State-rNFsFPTl.d.ts} +2 -2
  171. package/dist/State.cjs.map +1 -1
  172. package/dist/State.d.cts +1 -1
  173. package/dist/State.d.ts +1 -1
  174. package/dist/State.js +1 -1
  175. package/dist/{StateTrait-BGsZghTz.d.ts → StateTrait-CijdwNb6.d.ts} +25 -8
  176. package/dist/{StateTrait-OWhbj12c.d.cts → StateTrait-Dltto6PU.d.cts} +25 -8
  177. package/dist/StateTrait.cjs +1890 -528
  178. package/dist/StateTrait.cjs.map +1 -1
  179. package/dist/StateTrait.d.cts +9 -7
  180. package/dist/StateTrait.d.ts +9 -7
  181. package/dist/StateTrait.js +18 -14
  182. package/dist/{TraitLifecycle-CwV5WPFX.d.cts → TraitLifecycle-BKzDqzLu.d.cts} +2 -2
  183. package/dist/{TraitLifecycle-LdIWmKlg.d.ts → TraitLifecycle-Cvo94uDB.d.ts} +2 -2
  184. package/dist/TraitLifecycle.cjs +630 -67
  185. package/dist/TraitLifecycle.cjs.map +1 -1
  186. package/dist/TraitLifecycle.d.cts +6 -6
  187. package/dist/TraitLifecycle.d.ts +6 -6
  188. package/dist/TraitLifecycle.js +8 -7
  189. package/dist/Workflow-C_OWr4dV.d.ts +415 -0
  190. package/dist/Workflow-DmydkHO8.d.cts +415 -0
  191. package/dist/Workflow.cjs +3150 -0
  192. package/dist/Workflow.cjs.map +1 -0
  193. package/dist/Workflow.d.cts +7 -0
  194. package/dist/Workflow.d.ts +7 -0
  195. package/dist/Workflow.js +58 -0
  196. package/dist/Workflow.js.map +1 -0
  197. package/dist/{action-DiMDD_0v.d.cts → action-BQxjPFEw.d.cts} +5 -5
  198. package/dist/{action-DiMDD_0v.d.ts → action-BQxjPFEw.d.ts} +5 -5
  199. package/dist/chunk-2XRLXDWR.js +276 -0
  200. package/dist/chunk-2XRLXDWR.js.map +1 -0
  201. package/dist/chunk-3L6QGFMM.js +701 -0
  202. package/dist/chunk-3L6QGFMM.js.map +1 -0
  203. package/dist/{chunk-GMPEOUP2.js → chunk-4MZ7BT3R.js} +2 -2
  204. package/dist/chunk-4MZ7BT3R.js.map +1 -0
  205. package/dist/{chunk-3IYZ5IGG.js → chunk-5WKUGEBY.js} +2 -2
  206. package/dist/{chunk-3RMKLXHX.js → chunk-63ZQ5RIN.js} +2 -2
  207. package/dist/{chunk-M3WTHJHJ.js → chunk-67DIEA53.js} +385 -148
  208. package/dist/chunk-67DIEA53.js.map +1 -0
  209. package/dist/{chunk-YS3AZQ2G.js → chunk-6HFAW2MH.js} +1 -1
  210. package/dist/chunk-6HFAW2MH.js.map +1 -0
  211. package/dist/{chunk-EY4NZKDR.js → chunk-6Y2TKCNY.js} +2 -2
  212. package/dist/{chunk-76WT3HOR.js → chunk-6YZOXFPQ.js} +25 -24
  213. package/dist/chunk-6YZOXFPQ.js.map +1 -0
  214. package/dist/{chunk-G5ZBFPNU.js → chunk-A2RQOJC7.js} +2 -2
  215. package/dist/{chunk-AUIR5O6W.js → chunk-AFSB6NKM.js} +13 -19
  216. package/dist/chunk-AFSB6NKM.js.map +1 -0
  217. package/dist/{chunk-JCXGZRMU.js → chunk-AO4JEOKD.js} +22 -23
  218. package/dist/chunk-AO4JEOKD.js.map +1 -0
  219. package/dist/{chunk-TAAPQVZN.js → chunk-AYELIQXR.js} +2 -2
  220. package/dist/{chunk-QMM6O4CD.js → chunk-BLHZW7DG.js} +15 -3
  221. package/dist/{chunk-QMM6O4CD.js.map → chunk-BLHZW7DG.js.map} +1 -1
  222. package/dist/{chunk-TQOBJYDP.js → chunk-CD4N74YC.js} +1 -1
  223. package/dist/chunk-CD4N74YC.js.map +1 -0
  224. package/dist/{chunk-ANLBCBDC.js → chunk-CGE2HBTH.js} +11 -11
  225. package/dist/chunk-CGE2HBTH.js.map +1 -0
  226. package/dist/{chunk-OFADUJWJ.js → chunk-CYYSQMLO.js} +5 -5
  227. package/dist/chunk-CYYSQMLO.js.map +1 -0
  228. package/dist/{chunk-66ALHVEX.js → chunk-EB46EYI7.js} +3 -3
  229. package/dist/{chunk-NZJKFF45.js → chunk-EKCDHWRK.js} +4 -4
  230. package/dist/chunk-EKCDHWRK.js.map +1 -0
  231. package/dist/{chunk-BABLDP24.js → chunk-EPQFNJU3.js} +152 -7
  232. package/dist/chunk-EPQFNJU3.js.map +1 -0
  233. package/dist/{chunk-OGWBVHB3.js → chunk-ESR6HGOY.js} +73 -14
  234. package/dist/chunk-ESR6HGOY.js.map +1 -0
  235. package/dist/{chunk-NBD3KUOZ.js → chunk-F6RP62H3.js} +150 -98
  236. package/dist/chunk-F6RP62H3.js.map +1 -0
  237. package/dist/chunk-FBYW3QDI.js +252 -0
  238. package/dist/chunk-FBYW3QDI.js.map +1 -0
  239. package/dist/{chunk-IPF7E66P.js → chunk-FYAODKVP.js} +2 -2
  240. package/dist/chunk-GNEN7NKO.js +908 -0
  241. package/dist/chunk-GNEN7NKO.js.map +1 -0
  242. package/dist/chunk-GWSM4KLB.js +763 -0
  243. package/dist/chunk-GWSM4KLB.js.map +1 -0
  244. package/dist/{chunk-4SO6JMZL.js → chunk-HDMXCUZL.js} +1 -1
  245. package/dist/chunk-HDMXCUZL.js.map +1 -0
  246. package/dist/{chunk-ZFY7U2FR.js → chunk-HJM5Y5NU.js} +43 -3
  247. package/dist/chunk-HJM5Y5NU.js.map +1 -0
  248. package/dist/{chunk-ZGDVUPTM.js → chunk-IOZ3VKPK.js} +129 -68
  249. package/dist/chunk-IOZ3VKPK.js.map +1 -0
  250. package/dist/{chunk-PYOE4VSI.js → chunk-IVXSVHO4.js} +303 -247
  251. package/dist/chunk-IVXSVHO4.js.map +1 -0
  252. package/dist/chunk-J3CWXIPV.js +242 -0
  253. package/dist/chunk-J3CWXIPV.js.map +1 -0
  254. package/dist/chunk-K6JQW266.js +42 -0
  255. package/dist/chunk-K6JQW266.js.map +1 -0
  256. package/dist/chunk-KMZYQF6Q.js +202 -0
  257. package/dist/chunk-KMZYQF6Q.js.map +1 -0
  258. package/dist/{chunk-JWOYLO27.js → chunk-LPPZDFTD.js} +22 -12
  259. package/dist/chunk-LPPZDFTD.js.map +1 -0
  260. package/dist/{chunk-PAYXCY6A.js → chunk-MYB2B5WX.js} +997 -576
  261. package/dist/chunk-MYB2B5WX.js.map +1 -0
  262. package/dist/chunk-MYKNINNN.js +228 -0
  263. package/dist/chunk-MYKNINNN.js.map +1 -0
  264. package/dist/chunk-NSQIRMVF.js +27 -0
  265. package/dist/{chunk-QCHIQWAJ.js.map → chunk-NSQIRMVF.js.map} +1 -1
  266. package/dist/chunk-NUDBM4MM.js +30 -0
  267. package/dist/chunk-NUDBM4MM.js.map +1 -0
  268. package/dist/chunk-NZMWWDAY.js +23 -0
  269. package/dist/chunk-NZMWWDAY.js.map +1 -0
  270. package/dist/{chunk-RNFE3ML2.js → chunk-OCUV2Y25.js} +4 -3
  271. package/dist/chunk-OCUV2Y25.js.map +1 -0
  272. package/dist/chunk-P4ZJOQA7.js +271 -0
  273. package/dist/chunk-P4ZJOQA7.js.map +1 -0
  274. package/dist/chunk-P6C5EZ3D.js +342 -0
  275. package/dist/chunk-P6C5EZ3D.js.map +1 -0
  276. package/dist/{chunk-CW6T36TN.js → chunk-PBD7BJUN.js} +62 -4
  277. package/dist/chunk-PBD7BJUN.js.map +1 -0
  278. package/dist/chunk-PBIUCQY3.js +696 -0
  279. package/dist/chunk-PBIUCQY3.js.map +1 -0
  280. package/dist/chunk-PD6YECQH.js +845 -0
  281. package/dist/chunk-PD6YECQH.js.map +1 -0
  282. package/dist/{chunk-M7IYCTJV.js → chunk-R4LFQGP3.js} +2 -2
  283. package/dist/chunk-RHJIGDUE.js +21 -0
  284. package/dist/chunk-RHJIGDUE.js.map +1 -0
  285. package/dist/{chunk-KP7MUZNX.js → chunk-RLXO27MW.js} +30 -8
  286. package/dist/chunk-RLXO27MW.js.map +1 -0
  287. package/dist/{chunk-DFNM3WX2.js → chunk-S44BEV4B.js} +168 -45
  288. package/dist/chunk-S44BEV4B.js.map +1 -0
  289. package/dist/chunk-S4S5N4BJ.js +1461 -0
  290. package/dist/chunk-S4S5N4BJ.js.map +1 -0
  291. package/dist/{chunk-BZ2SHDN2.js → chunk-SGTRAXXX.js} +3 -3
  292. package/dist/chunk-SGTRAXXX.js.map +1 -0
  293. package/dist/{chunk-M2RGJPXX.js → chunk-SJAE5PB5.js} +3 -3
  294. package/dist/{chunk-JGIWG6SR.js → chunk-SNPNHU3H.js} +3937 -1776
  295. package/dist/chunk-SNPNHU3H.js.map +1 -0
  296. package/dist/{chunk-IHVBV5C2.js → chunk-SOOBFXRR.js} +94 -71
  297. package/dist/chunk-SOOBFXRR.js.map +1 -0
  298. package/dist/{chunk-ZDTRWK5F.js → chunk-TAHFWKS6.js} +2 -2
  299. package/dist/chunk-UEFFTVPY.js +9 -0
  300. package/dist/chunk-UEFFTVPY.js.map +1 -0
  301. package/dist/{chunk-24VULZ7A.js → chunk-UR5BXLBP.js} +3 -3
  302. package/dist/chunk-UR5BXLBP.js.map +1 -0
  303. package/dist/{chunk-DMBALCE2.js → chunk-V2SBGVDO.js} +471 -186
  304. package/dist/chunk-V2SBGVDO.js.map +1 -0
  305. package/dist/chunk-VJLWD47W.js +23 -0
  306. package/dist/chunk-VJLWD47W.js.map +1 -0
  307. package/dist/{chunk-4CQAV7YB.js → chunk-W647DX5Z.js} +2 -2
  308. package/dist/{chunk-THATMZXD.js → chunk-WFIIU3YZ.js} +2 -2
  309. package/dist/{chunk-THATMZXD.js.map → chunk-WFIIU3YZ.js.map} +1 -1
  310. package/dist/chunk-YZDJMAKL.js +82 -0
  311. package/dist/chunk-YZDJMAKL.js.map +1 -0
  312. package/dist/{chunk-3TMODYZV.js → chunk-Z5XH6VHY.js} +5 -5
  313. package/dist/chunk-Z5XH6VHY.js.map +1 -0
  314. package/dist/{chunk-BE3HW4FY.js → chunk-ZBBMZMA6.js} +377 -170
  315. package/dist/chunk-ZBBMZMA6.js.map +1 -0
  316. package/dist/index.cjs +21224 -11714
  317. package/dist/index.cjs.map +1 -1
  318. package/dist/index.d.cts +195 -49
  319. package/dist/index.d.ts +195 -49
  320. package/dist/index.js +150 -74
  321. package/dist/index.js.map +1 -1
  322. package/dist/{ir-BMP7yxJJ.d.cts → ir-BSosEwc8.d.cts} +1 -1
  323. package/dist/{ir-DUOz6H-5.d.ts → ir-D-uqwL_4.d.ts} +1 -1
  324. package/dist/{module-B8CBqIZ_.d.cts → module-Ds4tarcI.d.cts} +230 -140
  325. package/dist/{module-k7m3txak.d.ts → module-Zd1Gn-Nj.d.ts} +230 -140
  326. package/package.json +20 -4
  327. package/dist/ModuleTag-C8FHY_sY.d.ts +0 -93
  328. package/dist/ModuleTag-EGbgBMpZ.d.cts +0 -93
  329. package/dist/Observability-COqEvp2C.d.cts +0 -713
  330. package/dist/Observability-cY4kLn0S.d.ts +0 -713
  331. package/dist/ReadQuery-BlMwhe-F.d.ts +0 -30
  332. package/dist/ReadQuery-CL5XlXts.d.cts +0 -30
  333. package/dist/ReadQuery-SinbStGF.d.cts +0 -38
  334. package/dist/ReadQuery-SinbStGF.d.ts +0 -38
  335. package/dist/chunk-24VULZ7A.js.map +0 -1
  336. package/dist/chunk-3QMIVH35.js +0 -43
  337. package/dist/chunk-3QMIVH35.js.map +0 -1
  338. package/dist/chunk-3TMODYZV.js.map +0 -1
  339. package/dist/chunk-4SO6JMZL.js.map +0 -1
  340. package/dist/chunk-76WT3HOR.js.map +0 -1
  341. package/dist/chunk-ANLBCBDC.js.map +0 -1
  342. package/dist/chunk-AUIR5O6W.js.map +0 -1
  343. package/dist/chunk-BABLDP24.js.map +0 -1
  344. package/dist/chunk-BE3HW4FY.js.map +0 -1
  345. package/dist/chunk-BZ2SHDN2.js.map +0 -1
  346. package/dist/chunk-CW6T36TN.js.map +0 -1
  347. package/dist/chunk-DFNM3WX2.js.map +0 -1
  348. package/dist/chunk-DMBALCE2.js.map +0 -1
  349. package/dist/chunk-EGK3KN7B.js +0 -406
  350. package/dist/chunk-EGK3KN7B.js.map +0 -1
  351. package/dist/chunk-GMPEOUP2.js.map +0 -1
  352. package/dist/chunk-IHVBV5C2.js.map +0 -1
  353. package/dist/chunk-JCXGZRMU.js.map +0 -1
  354. package/dist/chunk-JGIWG6SR.js.map +0 -1
  355. package/dist/chunk-JWOYLO27.js.map +0 -1
  356. package/dist/chunk-KIXAU3GM.js +0 -137
  357. package/dist/chunk-KIXAU3GM.js.map +0 -1
  358. package/dist/chunk-KL5ACTCT.js +0 -8
  359. package/dist/chunk-KL5ACTCT.js.map +0 -1
  360. package/dist/chunk-KP7MUZNX.js.map +0 -1
  361. package/dist/chunk-M3BFQ7HK.js +0 -13
  362. package/dist/chunk-M3BFQ7HK.js.map +0 -1
  363. package/dist/chunk-M3WTHJHJ.js.map +0 -1
  364. package/dist/chunk-NBD3KUOZ.js.map +0 -1
  365. package/dist/chunk-NQZ2OSGR.js +0 -151
  366. package/dist/chunk-NQZ2OSGR.js.map +0 -1
  367. package/dist/chunk-NZJKFF45.js.map +0 -1
  368. package/dist/chunk-OFADUJWJ.js.map +0 -1
  369. package/dist/chunk-OGWBVHB3.js.map +0 -1
  370. package/dist/chunk-PAYXCY6A.js.map +0 -1
  371. package/dist/chunk-PYOE4VSI.js.map +0 -1
  372. package/dist/chunk-QCHIQWAJ.js +0 -21
  373. package/dist/chunk-RNFE3ML2.js.map +0 -1
  374. package/dist/chunk-TKZ7MEIA.js +0 -27
  375. package/dist/chunk-TKZ7MEIA.js.map +0 -1
  376. package/dist/chunk-TQOBJYDP.js.map +0 -1
  377. package/dist/chunk-VZB726PE.js +0 -93
  378. package/dist/chunk-VZB726PE.js.map +0 -1
  379. package/dist/chunk-W3TEWHLO.js +0 -568
  380. package/dist/chunk-W3TEWHLO.js.map +0 -1
  381. package/dist/chunk-YS3AZQ2G.js.map +0 -1
  382. package/dist/chunk-ZFLHVFUC.js +0 -192
  383. package/dist/chunk-ZFLHVFUC.js.map +0 -1
  384. package/dist/chunk-ZFY7U2FR.js.map +0 -1
  385. package/dist/chunk-ZGDVUPTM.js.map +0 -1
  386. package/dist/protocol-g_1897M2.d.cts +0 -127
  387. package/dist/protocol-g_1897M2.d.ts +0 -127
  388. /package/dist/{chunk-3IYZ5IGG.js.map → chunk-5WKUGEBY.js.map} +0 -0
  389. /package/dist/{chunk-3RMKLXHX.js.map → chunk-63ZQ5RIN.js.map} +0 -0
  390. /package/dist/{chunk-EY4NZKDR.js.map → chunk-6Y2TKCNY.js.map} +0 -0
  391. /package/dist/{chunk-G5ZBFPNU.js.map → chunk-A2RQOJC7.js.map} +0 -0
  392. /package/dist/{chunk-TAAPQVZN.js.map → chunk-AYELIQXR.js.map} +0 -0
  393. /package/dist/{chunk-66ALHVEX.js.map → chunk-EB46EYI7.js.map} +0 -0
  394. /package/dist/{chunk-IPF7E66P.js.map → chunk-FYAODKVP.js.map} +0 -0
  395. /package/dist/{chunk-M7IYCTJV.js.map → chunk-R4LFQGP3.js.map} +0 -0
  396. /package/dist/{chunk-M2RGJPXX.js.map → chunk-SJAE5PB5.js.map} +0 -0
  397. /package/dist/{chunk-ZDTRWK5F.js.map → chunk-TAHFWKS6.js.map} +0 -0
  398. /package/dist/{chunk-4CQAV7YB.js.map → chunk-W647DX5Z.js.map} +0 -0
package/dist/Debug.cjs CHANGED
@@ -23,10 +23,12 @@ __export(Debug_exports, {
23
23
  appendSinks: () => appendSinks,
24
24
  clearDevtoolsEvents: () => clearDevtoolsEvents2,
25
25
  devtoolsHubLayer: () => devtoolsHubLayer,
26
- diagnosticsLevel: () => diagnosticsLevel,
26
+ diagnosticsLevel: () => diagnosticsLevel2,
27
+ diagnosticsMaterialization: () => diagnosticsMaterialization2,
27
28
  exportEvidencePackage: () => exportEvidencePackage2,
28
29
  getDevtoolsRunId: () => getDevtoolsRunId2,
29
30
  getDevtoolsSnapshot: () => getDevtoolsSnapshot2,
31
+ getDevtoolsSnapshotByRuntimeLabel: () => getDevtoolsSnapshotByRuntimeLabel2,
30
32
  getDevtoolsSnapshotToken: () => getDevtoolsSnapshotToken2,
31
33
  getInstanceLabel: () => getInstanceLabel2,
32
34
  getModuleFinalTraits: () => getModuleFinalTraits,
@@ -48,13 +50,14 @@ __export(Debug_exports, {
48
50
  subscribeDevtoolsSnapshot: () => subscribeDevtoolsSnapshot2,
49
51
  toRuntimeDebugEventRef: () => toRuntimeDebugEventRef2,
50
52
  traceLayer: () => traceLayer,
53
+ traceMode: () => traceMode2,
51
54
  traitConvergeDiagnosticsSampling: () => traitConvergeDiagnosticsSampling2,
52
55
  withPrettyLogger: () => withPrettyLogger
53
56
  });
54
57
  module.exports = __toCommonJS(Debug_exports);
55
- var import_effect7 = require("effect");
58
+ var import_effect12 = require("effect");
56
59
 
57
- // src/internal/runtime/core/DebugSink.ts
60
+ // src/internal/runtime/core/DebugSink.record.ts
58
61
  var import_effect3 = require("effect");
59
62
 
60
63
  // src/internal/observability/jsonValue.ts
@@ -146,11 +149,12 @@ var toJsonValueInternal = (input, options, stats, seen, depth) => {
146
149
  stats.nonSerializable += 1;
147
150
  return truncateString(String(input), options.maxStringLength, stats);
148
151
  }
149
- const entries = Object.entries(input);
150
- const limit = Math.min(entries.length, options.maxObjectKeys);
152
+ const keys = Object.keys(input).sort();
153
+ const limit = Math.min(keys.length, options.maxObjectKeys);
151
154
  const out = {};
152
155
  for (let i = 0; i < limit; i++) {
153
- const [rawKey, rawValue] = entries[i];
156
+ const rawKey = keys[i];
157
+ const rawValue = input[rawKey];
154
158
  const key = truncateString(rawKey, options.maxStringLength, stats);
155
159
  if (rawValue === void 0) {
156
160
  stats.dropped += 1;
@@ -158,9 +162,9 @@ var toJsonValueInternal = (input, options, stats, seen, depth) => {
158
162
  }
159
163
  out[key] = toJsonValueInternal(rawValue, options, stats, seen, depth + 1);
160
164
  }
161
- if (entries.length > limit) {
165
+ if (keys.length > limit) {
162
166
  stats.oversized += 1;
163
- out.__truncatedKeys = entries.length - limit;
167
+ out.__truncatedKeys = keys.length - limit;
164
168
  }
165
169
  return out;
166
170
  };
@@ -239,7 +243,7 @@ var getMessageFromUnknown = (cause) => {
239
243
  return cause.message;
240
244
  }
241
245
  try {
242
- const pretty = import_effect.Cause.pretty(cause, { renderErrorCause: true });
246
+ const pretty = import_effect.Cause.pretty(cause);
243
247
  if (typeof pretty === "string" && pretty.length > 0) return pretty;
244
248
  } catch {
245
249
  }
@@ -293,21 +297,50 @@ var toSerializableErrorSummary = (cause, options) => {
293
297
 
294
298
  // src/internal/runtime/core/EffectOpCore.ts
295
299
  var import_effect2 = require("effect");
296
- var currentLinkId = import_effect2.FiberRef.unsafeMake(void 0);
297
- var EffectOpMiddlewareTag = class extends import_effect2.Context.Tag("Logix/EffectOpMiddleware")() {
300
+ var currentLinkId = import_effect2.ServiceMap.Reference("@logixjs/core/CurrentLinkId", {
301
+ defaultValue: () => void 0
302
+ });
303
+ var EffectOpMiddlewareTag = class extends import_effect2.ServiceMap.Service()("Logix/EffectOpMiddleware") {
298
304
  };
299
305
 
300
- // src/internal/runtime/core/DebugSink.ts
301
- var currentDebugSinks = import_effect3.FiberRef.unsafeMake([]);
302
- var currentRuntimeLabel = import_effect3.FiberRef.unsafeMake(void 0);
303
- var currentTxnId = import_effect3.FiberRef.unsafeMake(void 0);
304
- var currentOpSeq = import_effect3.FiberRef.unsafeMake(void 0);
305
- var currentDiagnosticsLevel = import_effect3.FiberRef.unsafeMake("off");
306
- var currentTraitConvergeDiagnosticsSampling = import_effect3.FiberRef.unsafeMake({
307
- sampleEveryN: 32,
308
- topK: 3
306
+ // src/internal/runtime/core/DebugSink.record.ts
307
+ var currentDebugSinks = import_effect3.ServiceMap.Reference("@logixjs/core/Debug.currentDebugSinks", {
308
+ defaultValue: () => []
309
+ });
310
+ var currentRuntimeLabel = import_effect3.ServiceMap.Reference("@logixjs/core/Debug.currentRuntimeLabel", {
311
+ defaultValue: () => void 0
312
+ });
313
+ var currentTxnId = import_effect3.ServiceMap.Reference("@logixjs/core/Debug.currentTxnId", {
314
+ defaultValue: () => void 0
309
315
  });
310
- var traitConvergeDiagnosticsSampling = (config) => import_effect3.Layer.fiberRefLocallyScopedWith(currentTraitConvergeDiagnosticsSampling, () => config);
316
+ var currentOpSeq = import_effect3.ServiceMap.Reference("@logixjs/core/Debug.currentOpSeq", {
317
+ defaultValue: () => void 0
318
+ });
319
+ var currentDiagnosticsLevel = import_effect3.ServiceMap.Reference("@logixjs/core/Debug.currentDiagnosticsLevel", {
320
+ defaultValue: () => "off"
321
+ });
322
+ var diagnosticsLevel = (level) => import_effect3.Layer.succeed(currentDiagnosticsLevel, level);
323
+ var currentDiagnosticsMaterialization = import_effect3.ServiceMap.Reference(
324
+ "@logixjs/core/Debug.currentDiagnosticsMaterialization",
325
+ {
326
+ defaultValue: () => "eager"
327
+ }
328
+ );
329
+ var diagnosticsMaterialization = (mode) => import_effect3.Layer.succeed(currentDiagnosticsMaterialization, mode);
330
+ var currentTraceMode = import_effect3.ServiceMap.Reference("@logixjs/core/Debug.currentTraceMode", {
331
+ defaultValue: () => "on"
332
+ });
333
+ var traceMode = (mode) => import_effect3.Layer.succeed(currentTraceMode, mode);
334
+ var currentTraitConvergeDiagnosticsSampling = import_effect3.ServiceMap.Reference(
335
+ "@logixjs/core/Debug.currentTraitConvergeDiagnosticsSampling",
336
+ {
337
+ defaultValue: () => ({
338
+ sampleEveryN: 32,
339
+ topK: 3
340
+ })
341
+ }
342
+ );
343
+ var traitConvergeDiagnosticsSampling = (config) => import_effect3.Layer.succeed(currentTraitConvergeDiagnosticsSampling, config);
311
344
  var nextGlobalEventSeq = 0;
312
345
  var clearRuntimeDebugEventSeq = () => {
313
346
  nextGlobalEventSeq = 0;
@@ -322,8 +355,89 @@ var mergeDowngrade2 = (current, next) => {
322
355
  if (!next) return current;
323
356
  if (current === "non_serializable" || next === "non_serializable") return "non_serializable";
324
357
  if (current === "oversized" || next === "oversized") return "oversized";
358
+ if (current === "budget_exceeded" || next === "budget_exceeded") return "budget_exceeded";
325
359
  return "unknown";
326
360
  };
361
+ var stripDirtyRootPaths = (value) => {
362
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
363
+ const { rootPaths, ...rest } = value;
364
+ return rest;
365
+ };
366
+ var stripTraitConvergeLegacyFields = (value) => {
367
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
368
+ const anyValue = value;
369
+ const { dirtyRoots, ...rest } = anyValue;
370
+ const dirty = rest.dirty;
371
+ if (!dirty || typeof dirty !== "object" || Array.isArray(dirty)) {
372
+ return rest;
373
+ }
374
+ return {
375
+ ...rest,
376
+ dirty: stripDirtyRootPaths(dirty)
377
+ };
378
+ };
379
+ var stripTraitConvergeLight = (value) => {
380
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
381
+ const anyValue = value;
382
+ const dirty = anyValue.dirty;
383
+ const dirtySlim = dirty && typeof dirty === "object" && !Array.isArray(dirty) ? {
384
+ dirtyAll: dirty.dirtyAll,
385
+ ...typeof dirty.reason === "string" ? { reason: dirty.reason } : null,
386
+ ...Array.isArray(dirty.rootIds) ? { rootIds: dirty.rootIds } : null,
387
+ ...typeof dirty.rootIdsTruncated === "boolean" ? { rootIdsTruncated: dirty.rootIdsTruncated } : null
388
+ } : void 0;
389
+ const { top3, dirtyRoots, ...rest } = anyValue;
390
+ return dirtySlim ? { ...rest, dirty: dirtySlim } : rest;
391
+ };
392
+ var stripTraitConvergeSampled = (value) => {
393
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
394
+ const anyValue = value;
395
+ const dirty = anyValue.dirty;
396
+ const dirtySlim = dirty && typeof dirty === "object" && !Array.isArray(dirty) ? {
397
+ dirtyAll: dirty.dirtyAll,
398
+ ...typeof dirty.reason === "string" ? { reason: dirty.reason } : null
399
+ } : void 0;
400
+ const { dirtyRoots, ...rest } = anyValue;
401
+ return dirtySlim ? { ...rest, dirty: dirtySlim } : rest;
402
+ };
403
+ var stripTraitCheckLight = (value) => {
404
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
405
+ const anyValue = value;
406
+ const degraded = anyValue.degraded;
407
+ const degradedSlim = degraded && typeof degraded === "object" && !Array.isArray(degraded) ? { kind: degraded.kind } : void 0;
408
+ const summary = anyValue.summary;
409
+ let summarySlim;
410
+ if (summary && typeof summary === "object" && !Array.isArray(summary)) {
411
+ const candidate = {};
412
+ let hasSummaryField = false;
413
+ if (typeof summary.scannedRows === "number") {
414
+ candidate.scannedRows = summary.scannedRows;
415
+ hasSummaryField = true;
416
+ }
417
+ if (typeof summary.affectedRows === "number") {
418
+ candidate.affectedRows = summary.affectedRows;
419
+ hasSummaryField = true;
420
+ }
421
+ if (typeof summary.changedRows === "number") {
422
+ candidate.changedRows = summary.changedRows;
423
+ hasSummaryField = true;
424
+ }
425
+ if (hasSummaryField) {
426
+ summarySlim = candidate;
427
+ }
428
+ }
429
+ const slim = {};
430
+ if (typeof anyValue.ruleId === "string") slim.ruleId = anyValue.ruleId;
431
+ if (Array.isArray(anyValue.scopeFieldPath)) slim.scopeFieldPath = anyValue.scopeFieldPath;
432
+ if (typeof anyValue.mode === "string") slim.mode = anyValue.mode;
433
+ if (anyValue.trigger && typeof anyValue.trigger === "object" && !Array.isArray(anyValue.trigger)) {
434
+ slim.trigger = anyValue.trigger;
435
+ }
436
+ if (typeof anyValue.rowIdMode === "string") slim.rowIdMode = anyValue.rowIdMode;
437
+ if (summarySlim) slim.summary = summarySlim;
438
+ if (degradedSlim) slim.degraded = degradedSlim;
439
+ return slim;
440
+ };
327
441
  var browserLifecycleSeen = /* @__PURE__ */ new Set();
328
442
  var browserDiagnosticSeen = /* @__PURE__ */ new Set();
329
443
  var lastTxnByInstance = /* @__PURE__ */ new Map();
@@ -360,9 +474,7 @@ var lifecycleErrorLog = (event) => {
360
474
  const moduleId = event.moduleId ?? "unknown";
361
475
  const causePretty = (() => {
362
476
  try {
363
- return import_effect3.Cause.pretty(event.cause, {
364
- renderErrorCause: true
365
- });
477
+ return import_effect3.Cause.pretty(event.cause);
366
478
  } catch {
367
479
  try {
368
480
  return JSON.stringify(event.cause, null, 2);
@@ -403,16 +515,16 @@ ${detail}`;
403
515
  }
404
516
  return base.pipe(import_effect3.Effect.annotateLogs(annotations));
405
517
  };
406
- var noopLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, []);
518
+ var noopLayer = import_effect3.Layer.succeed(currentDebugSinks, []);
407
519
  var errorOnlySink = {
408
520
  record: (event) => event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" && event.severity !== "info" ? diagnosticLog(event) : import_effect3.Effect.void
409
521
  };
410
- var errorOnlyLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, [errorOnlySink]);
522
+ var errorOnlyLayer = import_effect3.Layer.succeed(currentDebugSinks, [errorOnlySink]);
411
523
  var isErrorOnlyOnlySinks = (sinks) => sinks.length === 1 && sinks[0] === errorOnlySink;
412
524
  var consoleSink = {
413
525
  record: (event) => event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" ? diagnosticLog(event) : import_effect3.Effect.logDebug({ debugEvent: event })
414
526
  };
415
- var consoleLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, [consoleSink]);
527
+ var consoleLayer = import_effect3.Layer.succeed(currentDebugSinks, [consoleSink]);
416
528
  var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
417
529
  var renderBrowserConsoleEvent = (event) => {
418
530
  if (typeof event.type === "string" && event.type.startsWith("trace:")) {
@@ -438,7 +550,7 @@ var renderBrowserConsoleEvent = (event) => {
438
550
  const moduleId = event.moduleId ?? "unknown";
439
551
  const causePretty = (() => {
440
552
  try {
441
- return import_effect3.Cause.pretty(event.cause, { renderErrorCause: true });
553
+ return import_effect3.Cause.pretty(event.cause);
442
554
  } catch {
443
555
  try {
444
556
  return JSON.stringify(event.cause, null, 2);
@@ -504,7 +616,7 @@ var browserConsoleSink = {
504
616
  return renderBrowserConsoleEvent(event);
505
617
  }
506
618
  };
507
- var browserConsoleLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, [browserConsoleSink]);
619
+ var browserConsoleLayer = import_effect3.Layer.succeed(currentDebugSinks, [browserConsoleSink]);
508
620
  var browserDiagnosticConsoleSink = {
509
621
  record: (event) => {
510
622
  if (!isBrowser) {
@@ -513,36 +625,33 @@ var browserDiagnosticConsoleSink = {
513
625
  return event.type === "lifecycle:error" || event.type === "diagnostic" && event.severity !== "info" ? renderBrowserConsoleEvent(event) : import_effect3.Effect.void;
514
626
  }
515
627
  };
516
- var browserDiagnosticConsoleLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, [browserDiagnosticConsoleSink]);
517
- var browserPrettyLoggerLayer = import_effect3.Logger.replace(
518
- import_effect3.Logger.defaultLogger,
519
- import_effect3.Logger.prettyLogger({ mode: "browser", colors: true })
628
+ var browserDiagnosticConsoleLayer = import_effect3.Layer.succeed(currentDebugSinks, [browserDiagnosticConsoleSink]);
629
+ var browserPrettyLoggerLayer = import_effect3.Layer.effect(
630
+ import_effect3.Logger.CurrentLoggers,
631
+ import_effect3.Effect.gen(function* () {
632
+ const current = yield* import_effect3.Effect.service(import_effect3.Logger.CurrentLoggers);
633
+ return new Set(
634
+ [...current].filter((logger) => logger !== import_effect3.Logger.defaultLogger).concat(import_effect3.Logger.consolePretty({ mode: "browser", colors: true }))
635
+ );
636
+ })
520
637
  );
521
638
  var record = (event) => import_effect3.Effect.gen(function* () {
522
- const sinks = yield* import_effect3.FiberRef.get(currentDebugSinks);
639
+ const sinks = yield* import_effect3.Effect.service(currentDebugSinks);
523
640
  if (isErrorOnlyOnlySinks(sinks)) {
524
641
  if (event.type === "lifecycle:error") {
525
642
  yield* lifecycleErrorLog(event);
526
643
  return;
527
644
  }
528
- if (event.type === "diagnostic") {
529
- if (event.severity !== "info") {
530
- yield* diagnosticLog(event);
531
- } else {
532
- yield* import_effect3.Effect.void;
533
- }
534
- return;
645
+ if (event.type === "diagnostic" && event.severity !== "info") {
646
+ yield* diagnosticLog(event);
535
647
  }
536
- yield* import_effect3.Effect.void;
537
648
  return;
538
649
  }
539
650
  if (sinks.length === 0) {
540
651
  if (isBrowser) {
541
652
  if (event.type === "lifecycle:error" || event.type === "diagnostic") {
542
653
  yield* renderBrowserConsoleEvent(event);
543
- return;
544
654
  }
545
- yield* import_effect3.Effect.void;
546
655
  return;
547
656
  }
548
657
  if (event.type === "lifecycle:error") {
@@ -551,41 +660,43 @@ var record = (event) => import_effect3.Effect.gen(function* () {
551
660
  }
552
661
  if (event.type === "diagnostic") {
553
662
  yield* diagnosticLog(event);
554
- return;
555
663
  }
556
- yield* import_effect3.Effect.void;
557
664
  return;
558
665
  }
666
+ if (typeof event.type === "string" && event.type.startsWith("trace:")) {
667
+ const mode = yield* import_effect3.Effect.service(currentTraceMode);
668
+ if (mode === "off") return;
669
+ }
559
670
  const enriched = event;
560
- const diagnosticsLevel2 = yield* import_effect3.FiberRef.get(currentDiagnosticsLevel);
671
+ const diagnosticsLevel3 = yield* import_effect3.Effect.service(currentDiagnosticsLevel);
561
672
  let now;
562
673
  const getNow = () => {
563
674
  if (now === void 0) now = Date.now();
564
675
  return now;
565
676
  };
566
- if (enriched.timestamp === void 0 && (diagnosticsLevel2 !== "off" || enriched.type === "lifecycle:error" || enriched.type === "diagnostic")) {
677
+ if (enriched.timestamp === void 0 && (diagnosticsLevel3 !== "off" || enriched.type === "lifecycle:error" || enriched.type === "diagnostic")) {
567
678
  ;
568
679
  enriched.timestamp = getNow();
569
680
  }
570
- if (diagnosticsLevel2 !== "off" && enriched.runtimeLabel === void 0) {
571
- const runtimeLabel2 = yield* import_effect3.FiberRef.get(currentRuntimeLabel);
681
+ if (diagnosticsLevel3 !== "off" && enriched.runtimeLabel === void 0) {
682
+ const runtimeLabel2 = yield* import_effect3.Effect.service(currentRuntimeLabel);
572
683
  if (runtimeLabel2) {
573
684
  ;
574
685
  enriched.runtimeLabel = runtimeLabel2;
575
686
  }
576
687
  }
577
688
  if (enriched.type === "diagnostic" && enriched.txnId === void 0) {
578
- const txnId = yield* import_effect3.FiberRef.get(currentTxnId);
689
+ const txnId = yield* import_effect3.Effect.service(currentTxnId);
579
690
  if (txnId) {
580
691
  ;
581
692
  enriched.txnId = txnId;
582
693
  }
583
694
  }
584
- if (diagnosticsLevel2 !== "off" && enriched.type === "trace:effectop" && enriched.linkId === void 0) {
585
- const linkId = yield* import_effect3.FiberRef.get(currentLinkId);
586
- if (linkId) {
695
+ if (diagnosticsLevel3 !== "off" && enriched.type === "trace:effectop" && enriched.linkId === void 0) {
696
+ const maybeLinkId = yield* import_effect3.Effect.serviceOption(currentLinkId);
697
+ if (import_effect3.Option.isSome(maybeLinkId) && maybeLinkId.value) {
587
698
  ;
588
- enriched.linkId = linkId;
699
+ enriched.linkId = maybeLinkId.value;
589
700
  }
590
701
  }
591
702
  if (sinks.length === 1) {
@@ -595,11 +706,13 @@ var record = (event) => import_effect3.Effect.gen(function* () {
595
706
  yield* import_effect3.Effect.forEach(sinks, (sink) => sink.record(enriched), { discard: true });
596
707
  });
597
708
  var toRuntimeDebugEventRef = (event, options) => {
598
- const diagnosticsLevel2 = options?.diagnosticsLevel ?? "full";
599
- if (diagnosticsLevel2 === "off") {
709
+ const diagnosticsLevel3 = options?.diagnosticsLevel ?? "full";
710
+ if (diagnosticsLevel3 === "off") {
600
711
  return void 0;
601
712
  }
602
- const isLightLike = diagnosticsLevel2 === "light" || diagnosticsLevel2 === "sampled";
713
+ const isLightLike = diagnosticsLevel3 === "light" || diagnosticsLevel3 === "sampled";
714
+ const materialization = options?.materialization ?? "eager";
715
+ const isLazyMaterialization = materialization === "lazy";
603
716
  const timestamp = typeof event.timestamp === "number" && Number.isFinite(event.timestamp) ? event.timestamp : Date.now();
604
717
  const moduleIdRaw = event.moduleId;
605
718
  const moduleId = typeof moduleIdRaw === "string" && moduleIdRaw.length > 0 ? moduleIdRaw : "unknown";
@@ -697,63 +810,23 @@ var toRuntimeDebugEventRef = (event, options) => {
697
810
  }
698
811
  case "state:update": {
699
812
  const e = event;
700
- const resolveDirtySetRootPaths = () => {
701
- const resolve = options?.resolveConvergeStaticIr;
702
- if (!resolve) return void 0;
703
- const digest = e.staticIrDigest;
704
- if (typeof digest !== "string" || digest.length === 0) return void 0;
705
- const dirtySet = e.dirtySet;
706
- if (!dirtySet || typeof dirtySet !== "object" || Array.isArray(dirtySet)) return void 0;
707
- const rootIds = dirtySet.rootIds;
708
- if (!Array.isArray(rootIds) || rootIds.length === 0) return void 0;
709
- const ir = resolve(digest);
710
- const fieldPaths = ir?.fieldPaths;
711
- if (!Array.isArray(fieldPaths) || fieldPaths.length === 0) return void 0;
712
- const out = [];
713
- for (const rawId of rootIds) {
714
- if (typeof rawId !== "number" || !Number.isFinite(rawId)) continue;
715
- const id = Math.floor(rawId);
716
- if (id < 0) continue;
717
- const path = fieldPaths[id];
718
- if (!Array.isArray(path) || path.length === 0) continue;
719
- if (!path.every((seg) => typeof seg === "string" && seg.length > 0)) continue;
720
- out.push(path);
721
- }
722
- return out.length > 0 ? out : void 0;
723
- };
724
- const dirtySetWithRootPaths = (() => {
725
- const rootPaths = resolveDirtySetRootPaths();
726
- if (!rootPaths) return e.dirtySet;
727
- const dirtySet = e.dirtySet;
728
- if (!dirtySet || typeof dirtySet !== "object" || Array.isArray(dirtySet)) return e.dirtySet;
729
- return { ...dirtySet, rootPaths };
730
- })();
731
- const metaInput = isLightLike ? {
732
- state: e.state,
733
- dirtySet: dirtySetWithRootPaths,
734
- patchCount: e.patchCount,
735
- patchesTruncated: e.patchesTruncated,
736
- patchesTruncatedReason: e.patchesTruncatedReason,
737
- staticIrDigest: e.staticIrDigest,
738
- commitMode: e.commitMode,
739
- priority: e.priority,
740
- originKind: e.originKind,
741
- originName: e.originName
742
- } : {
743
- state: e.state,
744
- dirtySet: dirtySetWithRootPaths,
745
- patchCount: e.patchCount,
746
- patchesTruncated: e.patchesTruncated,
747
- patchesTruncatedReason: e.patchesTruncatedReason,
748
- staticIrDigest: e.staticIrDigest,
749
- commitMode: e.commitMode,
750
- priority: e.priority,
751
- originKind: e.originKind,
752
- originName: e.originName,
753
- traitSummary: e.traitSummary,
754
- replayEvent: e.replayEvent
755
- };
756
- const metaProjection = projectJsonValue(metaInput);
813
+ const dirtySetCanonical = stripDirtyRootPaths(e.dirtySet);
814
+ const slimMetaInput = {};
815
+ if (dirtySetCanonical !== void 0) slimMetaInput.dirtySet = dirtySetCanonical;
816
+ if (e.patchCount !== void 0) slimMetaInput.patchCount = e.patchCount;
817
+ if (e.patchesTruncated !== void 0) slimMetaInput.patchesTruncated = e.patchesTruncated;
818
+ if (e.patchesTruncatedReason !== void 0) slimMetaInput.patchesTruncatedReason = e.patchesTruncatedReason;
819
+ if (e.staticIrDigest !== void 0) slimMetaInput.staticIrDigest = e.staticIrDigest;
820
+ if (e.commitMode !== void 0) slimMetaInput.commitMode = e.commitMode;
821
+ if (e.priority !== void 0) slimMetaInput.priority = e.priority;
822
+ if (e.originKind !== void 0) slimMetaInput.originKind = e.originKind;
823
+ if (e.originName !== void 0) slimMetaInput.originName = e.originName;
824
+ const metaInput = isLightLike ? isLazyMaterialization ? slimMetaInput : { state: e.state, ...slimMetaInput } : isLazyMaterialization ? slimMetaInput : { state: e.state, ...slimMetaInput, traitSummary: e.traitSummary, replayEvent: e.replayEvent };
825
+ const metaProjection = isLazyMaterialization ? {
826
+ value: metaInput,
827
+ stats: { dropped: 0, oversized: 0, nonSerializable: 0 },
828
+ downgrade: void 0
829
+ } : projectJsonValue(metaInput);
757
830
  options?.onMetaProjection?.({
758
831
  stats: metaProjection.stats,
759
832
  downgrade: metaProjection.downgrade
@@ -785,7 +858,9 @@ var toRuntimeDebugEventRef = (event, options) => {
785
858
  timestampMs: e.timestampMs,
786
859
  trigger: e.trigger,
787
860
  dispatch: e.dispatch,
788
- error: e.error
861
+ error: e.error,
862
+ budgetEnvelope: e.budgetEnvelope,
863
+ degrade: e.degrade
789
864
  };
790
865
  const metaProjection = projectJsonValue(metaInput);
791
866
  options?.onMetaProjection?.({
@@ -793,6 +868,17 @@ var toRuntimeDebugEventRef = (event, options) => {
793
868
  downgrade: metaProjection.downgrade
794
869
  });
795
870
  downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
871
+ const processDegradeReason = (() => {
872
+ const marker = e.degrade;
873
+ if (!marker || typeof marker !== "object" || Array.isArray(marker)) return void 0;
874
+ if (marker.degraded !== true) return void 0;
875
+ const reason = marker.reason;
876
+ if (reason === "budget_exceeded") return "budget_exceeded";
877
+ if (reason === "payload_oversized") return "oversized";
878
+ if (reason === "payload_non_serializable") return "non_serializable";
879
+ return "unknown";
880
+ })();
881
+ downgrade = mergeDowngrade2(downgrade, processDegradeReason);
796
882
  const errorSummary = e.type === "process:error" || e.type === "process:restart" ? e.error : void 0;
797
883
  return withDowngrade({
798
884
  ...base,
@@ -840,6 +926,7 @@ var toRuntimeDebugEventRef = (event, options) => {
840
926
  hint: e.hint,
841
927
  actionTag: e.actionTag,
842
928
  kind: e.kind,
929
+ opSeq: e.opSeq,
843
930
  trigger: e.trigger
844
931
  };
845
932
  const metaProjection = projectJsonValue(metaInput);
@@ -855,10 +942,103 @@ var toRuntimeDebugEventRef = (event, options) => {
855
942
  meta: metaProjection.value
856
943
  });
857
944
  }
945
+ case "warn:priority-inversion": {
946
+ const e = event;
947
+ const metaInput = isLightLike ? {
948
+ tickSeq: e.tickSeq,
949
+ reason: e.reason,
950
+ selectorId: e.selectorId
951
+ } : {
952
+ tickSeq: e.tickSeq,
953
+ reason: e.reason,
954
+ selectorId: e.selectorId
955
+ };
956
+ const metaProjection = projectJsonValue(metaInput);
957
+ options?.onMetaProjection?.({
958
+ stats: metaProjection.stats,
959
+ downgrade: metaProjection.downgrade
960
+ });
961
+ downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
962
+ return withDowngrade({
963
+ ...base,
964
+ kind: "diagnostic",
965
+ label: e.type,
966
+ meta: metaProjection.value
967
+ });
968
+ }
969
+ case "warn:microtask-starvation": {
970
+ const e = event;
971
+ const metaInput = isLightLike ? {
972
+ tickSeq: e.tickSeq,
973
+ microtaskChainDepth: e.microtaskChainDepth
974
+ } : {
975
+ tickSeq: e.tickSeq,
976
+ microtaskChainDepth: e.microtaskChainDepth
977
+ };
978
+ const metaProjection = projectJsonValue(metaInput);
979
+ options?.onMetaProjection?.({
980
+ stats: metaProjection.stats,
981
+ downgrade: metaProjection.downgrade
982
+ });
983
+ downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
984
+ return withDowngrade({
985
+ ...base,
986
+ kind: "diagnostic",
987
+ label: e.type,
988
+ meta: metaProjection.value
989
+ });
990
+ }
858
991
  default: {
859
992
  if (typeof event.type !== "string" || !event.type.startsWith("trace:")) {
860
993
  return void 0;
861
994
  }
995
+ if (event.type === "trace:devtools:ring-trim-policy") {
996
+ const data = event.data;
997
+ const metaInput = {
998
+ mode: data?.mode,
999
+ threshold: data?.threshold,
1000
+ bufferSize: data?.bufferSize
1001
+ };
1002
+ const metaProjection2 = projectJsonValue(metaInput);
1003
+ options?.onMetaProjection?.({
1004
+ stats: metaProjection2.stats,
1005
+ downgrade: metaProjection2.downgrade
1006
+ });
1007
+ downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
1008
+ return withDowngrade({
1009
+ ...base,
1010
+ kind: "devtools",
1011
+ label: event.type,
1012
+ meta: metaProjection2.value
1013
+ });
1014
+ }
1015
+ if (event.type === "trace:tick") {
1016
+ const data = event.data;
1017
+ const metaInput = isLightLike ? {
1018
+ tickSeq: data?.tickSeq,
1019
+ phase: data?.phase,
1020
+ schedule: data?.schedule,
1021
+ triggerSummary: data?.triggerSummary,
1022
+ anchors: data?.anchors,
1023
+ budget: data?.budget,
1024
+ backlog: data?.backlog,
1025
+ result: data?.result
1026
+ } : {
1027
+ data
1028
+ };
1029
+ const metaProjection2 = projectJsonValue(metaInput);
1030
+ options?.onMetaProjection?.({
1031
+ stats: metaProjection2.stats,
1032
+ downgrade: metaProjection2.downgrade
1033
+ });
1034
+ downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
1035
+ return withDowngrade({
1036
+ ...base,
1037
+ kind: "devtools",
1038
+ label: event.type,
1039
+ meta: metaProjection2.value
1040
+ });
1041
+ }
862
1042
  if (event.type === "trace:txn-lane") {
863
1043
  const data = event.data;
864
1044
  const evidence = data?.evidence ?? data;
@@ -876,6 +1056,55 @@ var toRuntimeDebugEventRef = (event, options) => {
876
1056
  meta: metaProjection2.value
877
1057
  });
878
1058
  }
1059
+ if (event.type === "trace:txn-phase") {
1060
+ const data = event.data;
1061
+ const metaInput = isLightLike ? {
1062
+ kind: data?.kind,
1063
+ originKind: data?.originKind,
1064
+ originName: data?.originName,
1065
+ commitMode: data?.commitMode,
1066
+ priority: data?.priority,
1067
+ txnPreludeMs: data?.txnPreludeMs,
1068
+ queue: data?.queue ? {
1069
+ lane: data.queue.lane,
1070
+ contextLookupMs: data.queue.contextLookupMs,
1071
+ resolvePolicyMs: data.queue.resolvePolicyMs,
1072
+ backpressureMs: data.queue.backpressureMs,
1073
+ enqueueBookkeepingMs: data.queue.enqueueBookkeepingMs,
1074
+ queueWaitMs: data.queue.queueWaitMs,
1075
+ startHandoffMs: data.queue.startHandoffMs,
1076
+ startMode: data.queue.startMode
1077
+ } : void 0,
1078
+ dispatchActionRecordMs: data?.dispatchActionRecordMs,
1079
+ dispatchActionCommitHubMs: data?.dispatchActionCommitHubMs,
1080
+ dispatchActionCount: data?.dispatchActionCount,
1081
+ bodyShellMs: data?.bodyShellMs,
1082
+ asyncEscapeGuardMs: data?.asyncEscapeGuardMs,
1083
+ traitConvergeMs: data?.traitConvergeMs,
1084
+ scopedValidateMs: data?.scopedValidateMs,
1085
+ sourceSyncMs: data?.sourceSyncMs,
1086
+ commit: data?.commit ? {
1087
+ totalMs: data.commit.totalMs,
1088
+ rowIdSyncMs: data.commit.rowIdSyncMs,
1089
+ publishCommitMs: data.commit.publishCommitMs,
1090
+ stateUpdateDebugRecordMs: data.commit.stateUpdateDebugRecordMs,
1091
+ onCommitBeforeStateUpdateMs: data.commit.onCommitBeforeStateUpdateMs,
1092
+ onCommitAfterStateUpdateMs: data.commit.onCommitAfterStateUpdateMs
1093
+ } : void 0
1094
+ } : data;
1095
+ const metaProjection2 = projectJsonValue(metaInput);
1096
+ options?.onMetaProjection?.({
1097
+ stats: metaProjection2.stats,
1098
+ downgrade: metaProjection2.downgrade
1099
+ });
1100
+ downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
1101
+ return withDowngrade({
1102
+ ...base,
1103
+ kind: "devtools",
1104
+ label: event.type,
1105
+ meta: metaProjection2.value
1106
+ });
1107
+ }
879
1108
  if (event.type === "trace:react-render" || event.type === "trace:react-selector") {
880
1109
  const data = event.data;
881
1110
  const metaProjection2 = projectJsonValue(
@@ -980,77 +1209,8 @@ var toRuntimeDebugEventRef = (event, options) => {
980
1209
  });
981
1210
  }
982
1211
  if (event.type === "trace:trait:converge") {
983
- const resolveDirtyRootPaths = (args) => {
984
- const resolve = options?.resolveConvergeStaticIr;
985
- if (!resolve) return void 0;
986
- const digest = args.staticIrDigest;
987
- if (typeof digest !== "string" || digest.length === 0) return void 0;
988
- const rootIds = args.rootIds;
989
- if (!Array.isArray(rootIds) || rootIds.length === 0) return void 0;
990
- const ir = resolve(digest);
991
- const fieldPaths = ir?.fieldPaths;
992
- if (!Array.isArray(fieldPaths) || fieldPaths.length === 0) return void 0;
993
- const out = [];
994
- for (const id of rootIds) {
995
- if (typeof id !== "number" || !Number.isFinite(id)) continue;
996
- const idx = Math.floor(id);
997
- if (idx < 0 || idx >= fieldPaths.length) continue;
998
- const path = fieldPaths[idx];
999
- if (Array.isArray(path)) {
1000
- out.push(path);
1001
- }
1002
- }
1003
- return out.length > 0 ? out : void 0;
1004
- };
1005
- const enrichDirtyRootPaths = (value) => {
1006
- if (!value || typeof value !== "object" || Array.isArray(value)) return value;
1007
- const anyValue = value;
1008
- const dirty = anyValue.dirty;
1009
- if (!dirty || typeof dirty !== "object" || Array.isArray(dirty)) return value;
1010
- const dirtyRootPaths = resolveDirtyRootPaths({
1011
- staticIrDigest: anyValue.staticIrDigest,
1012
- rootIds: dirty?.rootIds
1013
- });
1014
- if (!dirtyRootPaths) return value;
1015
- return {
1016
- ...anyValue,
1017
- dirty: {
1018
- ...dirty,
1019
- rootPaths: dirtyRootPaths
1020
- }
1021
- };
1022
- };
1023
- const stripHeavyLight = (value) => {
1024
- if (!value || typeof value !== "object" || Array.isArray(value)) return value;
1025
- const anyValue = value;
1026
- const dirty = anyValue.dirty;
1027
- const dirtyRootPaths = resolveDirtyRootPaths({
1028
- staticIrDigest: anyValue.staticIrDigest,
1029
- rootIds: dirty?.rootIds
1030
- });
1031
- const dirtySlim = dirty && typeof dirty === "object" && !Array.isArray(dirty) ? {
1032
- dirtyAll: dirty.dirtyAll,
1033
- ...typeof dirty.reason === "string" ? { reason: dirty.reason } : null,
1034
- ...Array.isArray(dirty.rootIds) ? { rootIds: dirty.rootIds } : null,
1035
- ...typeof dirty.rootIdsTruncated === "boolean" ? { rootIdsTruncated: dirty.rootIdsTruncated } : null,
1036
- ...dirtyRootPaths ? { rootPaths: dirtyRootPaths } : null
1037
- } : void 0;
1038
- const { top3, dirtyRoots, ...rest } = anyValue;
1039
- return dirtySlim ? { ...rest, dirty: dirtySlim } : rest;
1040
- };
1041
- const stripHeavySampled = (value) => {
1042
- if (!value || typeof value !== "object" || Array.isArray(value)) return value;
1043
- const anyValue = value;
1044
- const dirty = anyValue.dirty;
1045
- const dirtySlim = dirty && typeof dirty === "object" && !Array.isArray(dirty) ? {
1046
- dirtyAll: dirty.dirtyAll,
1047
- ...typeof dirty.reason === "string" ? { reason: dirty.reason } : null
1048
- } : void 0;
1049
- const { dirtyRoots, ...rest } = anyValue;
1050
- return dirtySlim ? { ...rest, dirty: dirtySlim } : rest;
1051
- };
1052
1212
  const data = event.data;
1053
- const metaInput = diagnosticsLevel2 === "light" ? stripHeavyLight(data) : diagnosticsLevel2 === "sampled" ? stripHeavySampled(data) : enrichDirtyRootPaths(data);
1213
+ const metaInput = diagnosticsLevel3 === "light" ? stripTraitConvergeLight(data) : diagnosticsLevel3 === "sampled" ? stripTraitConvergeSampled(data) : stripTraitConvergeLegacyFields(data);
1054
1214
  const metaProjection2 = projectJsonValue(metaInput);
1055
1215
  options?.onMetaProjection?.({
1056
1216
  stats: metaProjection2.stats,
@@ -1065,16 +1225,8 @@ var toRuntimeDebugEventRef = (event, options) => {
1065
1225
  });
1066
1226
  }
1067
1227
  if (event.type === "trace:trait:check") {
1068
- const stripHeavy = (value) => {
1069
- if (!value || typeof value !== "object" || Array.isArray(value)) return value;
1070
- const anyValue = value;
1071
- const degraded = anyValue.degraded;
1072
- const degradedSlim = degraded && typeof degraded === "object" && !Array.isArray(degraded) ? { kind: degraded.kind } : void 0;
1073
- const { degraded: _degraded, ...rest } = anyValue;
1074
- return degradedSlim ? { ...rest, degraded: degradedSlim } : rest;
1075
- };
1076
1228
  const data = event.data;
1077
- const metaInput = isLightLike ? stripHeavy(data) : data;
1229
+ const metaInput = isLightLike ? stripTraitCheckLight(data) : data;
1078
1230
  const metaProjection2 = projectJsonValue(metaInput);
1079
1231
  options?.onMetaProjection?.({
1080
1232
  stats: metaProjection2.stats,
@@ -1244,17 +1396,294 @@ var exportEvidencePackage = (options) => {
1244
1396
  };
1245
1397
  };
1246
1398
 
1399
+ // src/internal/runtime/core/HostScheduler.ts
1400
+ var noopCancel = () => {
1401
+ };
1402
+ var safeNowMs = () => {
1403
+ const perf = globalThis.performance;
1404
+ if (perf && typeof perf.now === "function") {
1405
+ try {
1406
+ const v = perf.now();
1407
+ if (typeof v === "number" && Number.isFinite(v)) return v;
1408
+ } catch {
1409
+ }
1410
+ }
1411
+ return Date.now();
1412
+ };
1413
+ var safeQueueMicrotask = (cb) => {
1414
+ const qm = globalThis.queueMicrotask;
1415
+ if (typeof qm === "function") {
1416
+ try {
1417
+ qm(cb);
1418
+ return;
1419
+ } catch {
1420
+ }
1421
+ }
1422
+ try {
1423
+ Promise.resolve().then(cb);
1424
+ } catch {
1425
+ setTimeout(cb, 0);
1426
+ }
1427
+ };
1428
+ var safeSetTimeout = (ms, cb) => {
1429
+ const id = setTimeout(cb, ms);
1430
+ return () => {
1431
+ try {
1432
+ clearTimeout(id);
1433
+ } catch {
1434
+ }
1435
+ };
1436
+ };
1437
+ var makeMessageChannelMacrotask = () => {
1438
+ const MC = globalThis.MessageChannel;
1439
+ if (typeof MC !== "function") return void 0;
1440
+ let channel;
1441
+ try {
1442
+ channel = new MC();
1443
+ } catch {
1444
+ return void 0;
1445
+ }
1446
+ const queue = [];
1447
+ let scheduled = false;
1448
+ const flush = () => {
1449
+ scheduled = false;
1450
+ const tasks = queue.splice(0, queue.length);
1451
+ for (const t of tasks) {
1452
+ if (t.canceled) continue;
1453
+ try {
1454
+ t.cb();
1455
+ } catch {
1456
+ }
1457
+ }
1458
+ };
1459
+ try {
1460
+ channel.port1.onmessage = flush;
1461
+ } catch {
1462
+ return void 0;
1463
+ }
1464
+ const schedule = (cb) => {
1465
+ const task = { canceled: false, cb };
1466
+ queue.push(task);
1467
+ if (!scheduled) {
1468
+ scheduled = true;
1469
+ try {
1470
+ channel.port2.postMessage(void 0);
1471
+ } catch {
1472
+ scheduled = false;
1473
+ return safeSetTimeout(0, cb);
1474
+ }
1475
+ }
1476
+ return () => {
1477
+ task.canceled = true;
1478
+ };
1479
+ };
1480
+ return schedule;
1481
+ };
1482
+ var makeSetImmediateMacrotask = () => {
1483
+ const si = globalThis.setImmediate;
1484
+ const ci = globalThis.clearImmediate;
1485
+ if (typeof si !== "function") return void 0;
1486
+ return (cb) => {
1487
+ let id;
1488
+ try {
1489
+ id = si(cb);
1490
+ } catch {
1491
+ return safeSetTimeout(0, cb);
1492
+ }
1493
+ return () => {
1494
+ if (typeof ci !== "function") return;
1495
+ try {
1496
+ ci(id);
1497
+ } catch {
1498
+ }
1499
+ };
1500
+ };
1501
+ };
1502
+ var makeRaf = () => {
1503
+ const raf = globalThis.requestAnimationFrame;
1504
+ const cancel = globalThis.cancelAnimationFrame;
1505
+ if (typeof raf !== "function") return void 0;
1506
+ return (cb) => {
1507
+ let id;
1508
+ try {
1509
+ id = raf(cb);
1510
+ } catch {
1511
+ return noopCancel;
1512
+ }
1513
+ return () => {
1514
+ if (typeof cancel !== "function") return;
1515
+ try {
1516
+ cancel(id);
1517
+ } catch {
1518
+ }
1519
+ };
1520
+ };
1521
+ };
1522
+ var makeDefaultHostScheduler = () => {
1523
+ const macrotask = makeSetImmediateMacrotask() ?? makeMessageChannelMacrotask() ?? ((cb) => safeSetTimeout(0, cb));
1524
+ const raf = makeRaf();
1525
+ return {
1526
+ nowMs: safeNowMs,
1527
+ scheduleMicrotask: safeQueueMicrotask,
1528
+ scheduleMacrotask: macrotask,
1529
+ scheduleAnimationFrame: (cb) => raf?.(cb) ?? macrotask(cb),
1530
+ scheduleTimeout: safeSetTimeout
1531
+ };
1532
+ };
1533
+ var globalHostScheduler;
1534
+ var getGlobalHostScheduler = () => {
1535
+ globalHostScheduler ?? (globalHostScheduler = makeDefaultHostScheduler());
1536
+ return globalHostScheduler;
1537
+ };
1538
+
1247
1539
  // src/internal/runtime/core/DevtoolsHub.ts
1248
1540
  var instances = /* @__PURE__ */ new Map();
1249
- var latestStates = /* @__PURE__ */ new Map();
1250
- var latestTraitSummaries = /* @__PURE__ */ new Map();
1251
1541
  var instanceLabels = /* @__PURE__ */ new Map();
1252
1542
  var convergeStaticIrByDigest = /* @__PURE__ */ new Map();
1253
- var liveInstanceKeys = /* @__PURE__ */ new Set();
1543
+ var toCapacity = (value) => {
1544
+ if (typeof value !== "number" || !Number.isFinite(value)) return 0;
1545
+ const n = Math.floor(value);
1546
+ return n > 0 ? n : 0;
1547
+ };
1548
+ var makeEventRing = (capacity) => {
1549
+ const cap = toCapacity(capacity);
1550
+ return {
1551
+ capacity: cap,
1552
+ start: 0,
1553
+ size: 0,
1554
+ data: cap > 0 ? new Array(cap) : [],
1555
+ view: [],
1556
+ dirty: true
1557
+ };
1558
+ };
1559
+ var clearEventRing = (ring) => {
1560
+ ring.start = 0;
1561
+ ring.size = 0;
1562
+ ring.data = ring.capacity > 0 ? new Array(ring.capacity) : [];
1563
+ ring.view.length = 0;
1564
+ ring.dirty = true;
1565
+ };
1566
+ var pushEventRing = (ring, ref) => {
1567
+ const cap = ring.capacity;
1568
+ if (cap <= 0) return;
1569
+ if (ring.size < cap) {
1570
+ ring.data[(ring.start + ring.size) % cap] = ref;
1571
+ ring.size += 1;
1572
+ } else {
1573
+ ring.data[ring.start] = ref;
1574
+ ring.start = (ring.start + 1) % cap;
1575
+ }
1576
+ ring.dirty = true;
1577
+ };
1578
+ var getEventRingView = (ring) => {
1579
+ if (!ring.dirty) return ring.view;
1580
+ const cap = ring.capacity;
1581
+ const size = ring.size;
1582
+ const out = ring.view;
1583
+ out.length = size;
1584
+ if (cap <= 0 || size === 0) {
1585
+ ring.dirty = false;
1586
+ return out;
1587
+ }
1588
+ const start = ring.start;
1589
+ const data = ring.data;
1590
+ for (let i = 0; i < size; i++) {
1591
+ out[i] = data[(start + i) % cap];
1592
+ }
1593
+ ring.dirty = false;
1594
+ return out;
1595
+ };
1596
+ var resizeEventRing = (ring, capacity) => {
1597
+ const cap = toCapacity(capacity);
1598
+ if (cap === ring.capacity) return;
1599
+ const snapshot = getEventRingView(ring);
1600
+ const keepStart = cap <= 0 ? snapshot.length : Math.max(0, snapshot.length - cap);
1601
+ const keep = [];
1602
+ for (let i = keepStart; i < snapshot.length; i++) {
1603
+ keep.push(snapshot[i]);
1604
+ }
1605
+ ring.capacity = cap;
1606
+ ring.start = 0;
1607
+ ring.size = 0;
1608
+ ring.data = cap > 0 ? new Array(cap) : [];
1609
+ ring.view.length = 0;
1610
+ ring.dirty = true;
1611
+ for (let i = 0; i < keep.length; i++) {
1612
+ pushEventRing(ring, keep[i]);
1613
+ }
1614
+ };
1615
+ var rebuildEventRingFromOrdered = (ring, ordered) => {
1616
+ clearEventRing(ring);
1617
+ for (let i = 0; i < ordered.length; i++) {
1618
+ pushEventRing(ring, ordered[i]);
1619
+ }
1620
+ };
1621
+ var runtimeBuckets = /* @__PURE__ */ new Map();
1622
+ var getRuntimeBucket = (runtimeLabel2) => runtimeBuckets.get(runtimeLabel2);
1623
+ var getOrCreateRuntimeBucket = (runtimeLabel2) => {
1624
+ const existing = runtimeBuckets.get(runtimeLabel2);
1625
+ if (existing) return existing;
1626
+ const created = {
1627
+ runtimeLabel: runtimeLabel2,
1628
+ ring: makeEventRing(bufferSize),
1629
+ latestStates: /* @__PURE__ */ new Map(),
1630
+ latestTraitSummaries: /* @__PURE__ */ new Map(),
1631
+ exportBudget: {
1632
+ dropped: 0,
1633
+ oversized: 0
1634
+ }
1635
+ };
1636
+ runtimeBuckets.set(runtimeLabel2, created);
1637
+ return created;
1638
+ };
1639
+ var latestStates = /* @__PURE__ */ new Map();
1640
+ var latestTraitSummaries = /* @__PURE__ */ new Map();
1641
+ var runtimeModules = /* @__PURE__ */ new Map();
1642
+ var normalizeKeyPart = (value) => value === void 0 || value === null ? "unknown" : String(value);
1643
+ var getRuntimeModuleEntry = (runtimeLabel2, moduleId) => runtimeModules.get(runtimeLabel2)?.get(moduleId);
1644
+ var getOrCreateRuntimeModuleEntry = (runtimeLabel2, moduleId) => {
1645
+ let modulesById = runtimeModules.get(runtimeLabel2);
1646
+ if (!modulesById) {
1647
+ modulesById = /* @__PURE__ */ new Map();
1648
+ runtimeModules.set(runtimeLabel2, modulesById);
1649
+ }
1650
+ let moduleEntry = modulesById.get(moduleId);
1651
+ if (!moduleEntry) {
1652
+ moduleEntry = {
1653
+ moduleKey: `${runtimeLabel2}::${moduleId}`,
1654
+ instanceKeyById: /* @__PURE__ */ new Map()
1655
+ };
1656
+ modulesById.set(moduleId, moduleEntry);
1657
+ }
1658
+ return moduleEntry;
1659
+ };
1660
+ var cleanupRuntimeModuleEntryIfUnused = (runtimeLabel2, moduleId, moduleKey) => {
1661
+ const modulesById = runtimeModules.get(runtimeLabel2);
1662
+ if (!modulesById) return;
1663
+ const moduleEntry = modulesById.get(moduleId);
1664
+ if (!moduleEntry) return;
1665
+ if (moduleEntry.instanceKeyById.size > 0) return;
1666
+ if ((instances.get(moduleKey) ?? 0) > 0) return;
1667
+ modulesById.delete(moduleId);
1668
+ if (modulesById.size === 0) {
1669
+ runtimeModules.delete(runtimeLabel2);
1670
+ }
1671
+ };
1672
+ var resolveLiveInstanceKey = (runtimeLabel2, moduleId, instanceId) => runtimeModules.get(runtimeLabel2)?.get(moduleId)?.instanceKeyById.get(instanceId);
1254
1673
  var exportBudget = {
1255
1674
  dropped: 0,
1256
1675
  oversized: 0
1257
1676
  };
1677
+ var recalculateGlobalExportBudget = () => {
1678
+ let dropped = 0;
1679
+ let oversized = 0;
1680
+ for (const bucket of runtimeBuckets.values()) {
1681
+ dropped += bucket.exportBudget.dropped;
1682
+ oversized += bucket.exportBudget.oversized;
1683
+ }
1684
+ exportBudget.dropped = dropped;
1685
+ exportBudget.oversized = oversized;
1686
+ };
1258
1687
  var lastRunTs = 0;
1259
1688
  var lastRunTsSeq = 0;
1260
1689
  var nextRunId = () => {
@@ -1268,43 +1697,99 @@ var nextRunId = () => {
1268
1697
  return lastRunTsSeq === 0 ? `run-${ts}` : `run-${ts}.${lastRunTsSeq}`;
1269
1698
  };
1270
1699
  var currentRunId = nextRunId();
1271
- var nextSeq = 1;
1272
1700
  var bufferSize = 500;
1273
- var ringBuffer = [];
1274
- var ringBufferSeq = [];
1275
- var snapshotToken = 0;
1276
- var ensureRingBufferSize = () => {
1701
+ var globalRing = makeEventRing(bufferSize);
1702
+ var ringTrimMode = "strict";
1703
+ var ringTrimThreshold = bufferSize;
1704
+ var RING_TRIM_POLICY_EVENT_LABEL = "trace:devtools:ring-trim-policy";
1705
+ var RING_TRIM_POLICY_MODULE_ID = "devtools:hub";
1706
+ var RING_TRIM_POLICY_INSTANCE_ID = "devtools:hub";
1707
+ var RING_TRIM_POLICY_RUNTIME_LABEL = "DevtoolsHub";
1708
+ var normalizeRuntimeLabel = (runtimeLabel2) => normalizeKeyPart(runtimeLabel2);
1709
+ var getRingTrimPolicySnapshot = () => ({
1710
+ mode: ringTrimMode,
1711
+ threshold: ringTrimThreshold,
1712
+ bufferSize
1713
+ });
1714
+ var refreshRingTrimPolicy = () => {
1715
+ const prevMode = ringTrimMode;
1716
+ const prevThreshold = ringTrimThreshold;
1277
1717
  if (bufferSize <= 0) {
1278
- ringBuffer.length = 0;
1279
- ringBufferSeq.length = 0;
1280
- return;
1718
+ ringTrimMode = "disabled";
1719
+ ringTrimThreshold = 0;
1720
+ return prevMode !== ringTrimMode || prevThreshold !== ringTrimThreshold;
1281
1721
  }
1282
- if (ringBuffer.length <= bufferSize) return;
1283
- const excess = ringBuffer.length - bufferSize;
1284
- ringBuffer.splice(0, excess);
1285
- ringBufferSeq.splice(0, excess);
1722
+ ringTrimMode = "strict";
1723
+ ringTrimThreshold = bufferSize;
1724
+ return prevMode !== ringTrimMode || prevThreshold !== ringTrimThreshold;
1286
1725
  };
1287
- var trimRingBufferIfNeeded = () => {
1288
- if (bufferSize <= 0) {
1289
- ringBuffer.length = 0;
1290
- ringBufferSeq.length = 0;
1291
- return;
1726
+ refreshRingTrimPolicy();
1727
+ var snapshotToken = 0;
1728
+ var parseDiagnosticsLevel = (value) => value === "off" || value === "light" || value === "sampled" || value === "full" ? value : "light";
1729
+ var appendRuntimeRef = (runtimeLabel2, ref) => {
1730
+ const bucket = getOrCreateRuntimeBucket(runtimeLabel2);
1731
+ pushEventRing(bucket.ring, ref);
1732
+ pushEventRing(globalRing, ref);
1733
+ };
1734
+ var clearRuntimeBucketEvents = (runtimeLabel2) => {
1735
+ const bucket = getRuntimeBucket(runtimeLabel2);
1736
+ if (!bucket) return false;
1737
+ let changed = false;
1738
+ if (bucket.ring.size > 0) {
1739
+ clearEventRing(bucket.ring);
1740
+ changed = true;
1292
1741
  }
1293
- if (bufferSize <= 64) {
1294
- ensureRingBufferSize();
1295
- return;
1742
+ if (bucket.exportBudget.dropped !== 0 || bucket.exportBudget.oversized !== 0) {
1743
+ bucket.exportBudget.dropped = 0;
1744
+ bucket.exportBudget.oversized = 0;
1745
+ changed = true;
1296
1746
  }
1297
- const slack = Math.min(1024, Math.floor(bufferSize / 2));
1298
- const threshold = bufferSize + Math.max(1, slack);
1299
- if (ringBuffer.length <= threshold) return;
1300
- const excess = ringBuffer.length - bufferSize;
1301
- ringBuffer.splice(0, excess);
1302
- ringBufferSeq.splice(0, excess);
1747
+ if (!changed) return false;
1748
+ const kept = getEventRingView(globalRing).filter((event) => normalizeRuntimeLabel(event.runtimeLabel) !== runtimeLabel2);
1749
+ rebuildEventRingFromOrdered(globalRing, kept);
1750
+ recalculateGlobalExportBudget();
1751
+ return true;
1752
+ };
1753
+ var clearAllRuntimeBucketEvents = () => {
1754
+ let changed = false;
1755
+ for (const bucket of runtimeBuckets.values()) {
1756
+ if (bucket.ring.size > 0) {
1757
+ clearEventRing(bucket.ring);
1758
+ changed = true;
1759
+ }
1760
+ if (bucket.exportBudget.dropped !== 0 || bucket.exportBudget.oversized !== 0) {
1761
+ bucket.exportBudget.dropped = 0;
1762
+ bucket.exportBudget.oversized = 0;
1763
+ changed = true;
1764
+ }
1765
+ }
1766
+ if (globalRing.size > 0) {
1767
+ clearEventRing(globalRing);
1768
+ changed = true;
1769
+ }
1770
+ recalculateGlobalExportBudget();
1771
+ return changed;
1772
+ };
1773
+ var emitRingTrimPolicyEvent = (diagnosticsLevel3) => {
1774
+ if (diagnosticsLevel3 === "off") return;
1775
+ if (bufferSize <= 0) return;
1776
+ const ref = toRuntimeDebugEventRef(
1777
+ {
1778
+ type: RING_TRIM_POLICY_EVENT_LABEL,
1779
+ moduleId: RING_TRIM_POLICY_MODULE_ID,
1780
+ instanceId: RING_TRIM_POLICY_INSTANCE_ID,
1781
+ runtimeLabel: RING_TRIM_POLICY_RUNTIME_LABEL,
1782
+ data: getRingTrimPolicySnapshot()
1783
+ },
1784
+ { diagnosticsLevel: diagnosticsLevel3 }
1785
+ );
1786
+ if (!ref) return;
1787
+ appendRuntimeRef(RING_TRIM_POLICY_RUNTIME_LABEL, ref);
1303
1788
  };
1304
1789
  var currentSnapshot = {
1305
1790
  snapshotToken,
1306
1791
  instances,
1307
- events: ringBuffer,
1792
+ events: globalRing.view,
1308
1793
  latestStates,
1309
1794
  latestTraitSummaries,
1310
1795
  exportBudget
@@ -1312,9 +1797,10 @@ var currentSnapshot = {
1312
1797
  var listeners = /* @__PURE__ */ new Set();
1313
1798
  var notifyScheduled = false;
1314
1799
  var scheduleNotify = () => {
1800
+ if (listeners.size === 0) return;
1315
1801
  if (notifyScheduled) return;
1316
1802
  notifyScheduled = true;
1317
- queueMicrotask(() => {
1803
+ getGlobalHostScheduler().scheduleMicrotask(() => {
1318
1804
  notifyScheduled = false;
1319
1805
  for (const listener of listeners) {
1320
1806
  listener();
@@ -1337,14 +1823,43 @@ var configureDevtoolsHub = (options) => {
1337
1823
  const nextBufferSize = next >= 0 ? next : 0;
1338
1824
  if (nextBufferSize !== bufferSize) {
1339
1825
  bufferSize = nextBufferSize;
1340
- ensureRingBufferSize();
1826
+ const policyChanged = refreshRingTrimPolicy();
1827
+ resizeEventRing(globalRing, bufferSize);
1828
+ for (const bucket of runtimeBuckets.values()) {
1829
+ resizeEventRing(bucket.ring, bufferSize);
1830
+ }
1831
+ if (policyChanged && options?.diagnosticsLevel !== void 0) {
1832
+ emitRingTrimPolicyEvent(parseDiagnosticsLevel(options.diagnosticsLevel));
1833
+ }
1341
1834
  markSnapshotChanged();
1342
1835
  }
1343
1836
  }
1344
1837
  };
1345
1838
  var isDevtoolsEnabled = () => devtoolsEnabled;
1346
- var getDevtoolsSnapshot = () => currentSnapshot;
1839
+ var getDevtoolsSnapshot = () => {
1840
+ getEventRingView(globalRing);
1841
+ return currentSnapshot;
1842
+ };
1347
1843
  var getDevtoolsSnapshotToken = () => snapshotToken;
1844
+ var getDevtoolsSnapshotByRuntimeLabel = (runtimeLabel2) => {
1845
+ const normalizedRuntimeLabel = normalizeRuntimeLabel(runtimeLabel2);
1846
+ const bucket = getRuntimeBucket(normalizedRuntimeLabel);
1847
+ const runtimeInstances = /* @__PURE__ */ new Map();
1848
+ const runtimePrefix = `${normalizedRuntimeLabel}::`;
1849
+ for (const [moduleKey, count] of instances.entries()) {
1850
+ if (moduleKey.startsWith(runtimePrefix)) {
1851
+ runtimeInstances.set(moduleKey, count);
1852
+ }
1853
+ }
1854
+ return {
1855
+ snapshotToken,
1856
+ instances: runtimeInstances,
1857
+ events: bucket ? getEventRingView(bucket.ring) : [],
1858
+ latestStates: bucket?.latestStates ?? /* @__PURE__ */ new Map(),
1859
+ latestTraitSummaries: bucket?.latestTraitSummaries ?? /* @__PURE__ */ new Map(),
1860
+ exportBudget: bucket?.exportBudget ?? { dropped: 0, oversized: 0 }
1861
+ };
1862
+ };
1348
1863
  var subscribeDevtoolsSnapshot = (listener) => {
1349
1864
  listeners.add(listener);
1350
1865
  return () => {
@@ -1361,16 +1876,18 @@ var setDevtoolsRunId = (runId) => {
1361
1876
  };
1362
1877
  var startDevtoolsRun = (runId) => {
1363
1878
  currentRunId = typeof runId === "string" && runId.length > 0 ? runId : nextRunId();
1364
- nextSeq = 1;
1365
1879
  clearRuntimeDebugEventSeq();
1366
1880
  clearDevtoolsEvents();
1367
1881
  return currentRunId;
1368
1882
  };
1369
- var clearDevtoolsEvents = () => {
1370
- ringBuffer.length = 0;
1371
- ringBufferSeq.length = 0;
1372
- exportBudget.dropped = 0;
1373
- exportBudget.oversized = 0;
1883
+ var clearDevtoolsEvents = (runtimeLabel2) => {
1884
+ if (runtimeLabel2 !== void 0) {
1885
+ if (clearRuntimeBucketEvents(normalizeRuntimeLabel(runtimeLabel2))) {
1886
+ markSnapshotChanged();
1887
+ }
1888
+ return;
1889
+ }
1890
+ clearAllRuntimeBucketEvents();
1374
1891
  markSnapshotChanged();
1375
1892
  };
1376
1893
  var setInstanceLabel = (instanceId, label) => {
@@ -1388,37 +1905,46 @@ var exportDevtoolsEvidencePackage = (options) => {
1388
1905
  const protocolVersion = options?.protocolVersion ?? OBSERVABILITY_PROTOCOL_VERSION;
1389
1906
  const runId = options?.runId ?? currentRunId;
1390
1907
  const source = options?.source ?? { host: "unknown" };
1391
- const events = ringBuffer.map((payload, i) => ({
1908
+ const refs = getEventRingView(globalRing);
1909
+ const events = refs.map((payload, i) => ({
1392
1910
  protocolVersion,
1393
1911
  runId,
1394
- seq: ringBufferSeq[i] ?? i + 1,
1912
+ seq: typeof payload.eventSeq === "number" && Number.isFinite(payload.eventSeq) && payload.eventSeq > 0 ? Math.floor(payload.eventSeq) : i + 1,
1395
1913
  timestamp: payload.timestamp,
1396
1914
  type: "debug:event",
1397
1915
  payload
1398
1916
  }));
1399
1917
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1400
1918
  const convergeDigests = /* @__PURE__ */ new Set();
1401
- let sawFullConverge = false;
1402
- for (const ref of ringBuffer) {
1403
- if (ref.kind !== "trait:converge") continue;
1404
- const meta = ref.meta;
1405
- if (!isRecord(meta)) continue;
1406
- const digest = meta.staticIrDigest;
1407
- if (typeof digest === "string" && digest.length > 0) {
1408
- convergeDigests.add(digest);
1919
+ const sawFullByDigest = /* @__PURE__ */ new Set();
1920
+ for (const ref of refs) {
1921
+ const meta = isRecord(ref.meta) ? ref.meta : void 0;
1922
+ if (!meta) continue;
1923
+ if (ref.kind === "trait:converge") {
1924
+ const digest = meta.staticIrDigest;
1925
+ if (typeof digest === "string" && digest.length > 0) {
1926
+ convergeDigests.add(digest);
1927
+ const dirty = meta.dirty;
1928
+ if (isRecord(dirty) && typeof dirty.rootCount === "number") {
1929
+ sawFullByDigest.add(digest);
1930
+ }
1931
+ }
1932
+ continue;
1409
1933
  }
1410
- const dirty = meta.dirty;
1411
- if (isRecord(dirty) && typeof dirty.rootCount === "number") {
1412
- sawFullConverge = true;
1934
+ if (ref.kind === "state" && ref.label === "state:update") {
1935
+ const digest = meta.staticIrDigest;
1936
+ if (typeof digest === "string" && digest.length > 0) {
1937
+ convergeDigests.add(digest);
1938
+ }
1413
1939
  }
1414
1940
  }
1415
1941
  let summary;
1416
- if (sawFullConverge && convergeDigests.size > 0) {
1942
+ if (convergeDigests.size > 0) {
1417
1943
  const staticIrByDigest = {};
1418
1944
  for (const digest of convergeDigests) {
1419
1945
  const ir = convergeStaticIrByDigest.get(digest);
1420
1946
  if (ir) {
1421
- staticIrByDigest[digest] = ir;
1947
+ staticIrByDigest[digest] = sawFullByDigest.has(digest) ? ir : { fieldPaths: ir.fieldPaths };
1422
1948
  }
1423
1949
  }
1424
1950
  if (Object.keys(staticIrByDigest).length > 0) {
@@ -1435,7 +1961,9 @@ var exportDevtoolsEvidencePackage = (options) => {
1435
1961
  };
1436
1962
  var devtoolsHubSink = {
1437
1963
  record: (event) => import_effect4.Effect.gen(function* () {
1438
- const level = yield* import_effect4.FiberRef.get(currentDiagnosticsLevel);
1964
+ const level = yield* import_effect4.Effect.service(currentDiagnosticsLevel).pipe(import_effect4.Effect.orDie);
1965
+ const materialization = yield* import_effect4.Effect.service(currentDiagnosticsMaterialization).pipe(import_effect4.Effect.orDie);
1966
+ const eventRuntimeLabel = normalizeRuntimeLabel(event.runtimeLabel);
1439
1967
  let changed = false;
1440
1968
  if (event.type === "trace:instanceLabel") {
1441
1969
  const instanceId = event.instanceId;
@@ -1447,51 +1975,74 @@ var devtoolsHubSink = {
1447
1975
  }
1448
1976
  }
1449
1977
  if (event.type === "module:init" || event.type === "module:destroy") {
1450
- const moduleId = event.moduleId ?? "unknown";
1451
- const runtimeLabel2 = event.runtimeLabel ?? "unknown";
1978
+ const moduleId = normalizeKeyPart(event.moduleId);
1979
+ const runtimeLabel2 = eventRuntimeLabel;
1980
+ const runtimeBucket2 = getOrCreateRuntimeBucket(runtimeLabel2);
1452
1981
  const instanceId = event.instanceId;
1453
- const key = `${runtimeLabel2}::${moduleId}`;
1454
- const prev = instances.get(key) ?? 0;
1455
1982
  if (event.type === "module:init") {
1456
- instances.set(key, prev + 1);
1983
+ const moduleEntry = getOrCreateRuntimeModuleEntry(runtimeLabel2, moduleId);
1984
+ const moduleKey = moduleEntry.moduleKey;
1985
+ const prev = instances.get(moduleKey) ?? 0;
1986
+ instances.set(moduleKey, prev + 1);
1457
1987
  changed = true;
1458
1988
  if (instanceId) {
1459
- const instanceKey = `${runtimeLabel2}::${moduleId}::${instanceId}`;
1460
- liveInstanceKeys.add(instanceKey);
1989
+ const cachedInstanceKey = moduleEntry.instanceKeyById.get(instanceId);
1990
+ const instanceKey = cachedInstanceKey ?? `${moduleKey}::${instanceId}`;
1991
+ if (cachedInstanceKey === void 0) {
1992
+ moduleEntry.instanceKeyById.set(instanceId, instanceKey);
1993
+ }
1461
1994
  if (latestStates.delete(instanceKey)) changed = true;
1462
1995
  if (latestTraitSummaries.delete(instanceKey)) changed = true;
1996
+ if (runtimeBucket2.latestStates.delete(instanceKey)) changed = true;
1997
+ if (runtimeBucket2.latestTraitSummaries.delete(instanceKey)) changed = true;
1463
1998
  }
1464
1999
  } else {
2000
+ const moduleEntry = getRuntimeModuleEntry(runtimeLabel2, moduleId);
2001
+ const moduleKey = moduleEntry?.moduleKey ?? `${runtimeLabel2}::${moduleId}`;
2002
+ const prev = instances.get(moduleKey) ?? 0;
1465
2003
  const next = prev - 1;
1466
2004
  if (next <= 0) {
1467
- if (instances.delete(key)) changed = true;
2005
+ if (instances.delete(moduleKey)) changed = true;
1468
2006
  } else {
1469
- instances.set(key, next);
2007
+ instances.set(moduleKey, next);
1470
2008
  changed = true;
1471
2009
  }
1472
2010
  if (instanceId) {
1473
- const instanceKey = `${runtimeLabel2}::${moduleId}::${instanceId}`;
1474
- liveInstanceKeys.delete(instanceKey);
2011
+ const instanceKey = moduleEntry?.instanceKeyById.get(instanceId) ?? `${moduleKey}::${instanceId}`;
2012
+ moduleEntry?.instanceKeyById.delete(instanceId);
1475
2013
  if (latestStates.delete(instanceKey)) changed = true;
1476
2014
  if (latestTraitSummaries.delete(instanceKey)) changed = true;
2015
+ if (runtimeBucket2.latestStates.delete(instanceKey)) changed = true;
2016
+ if (runtimeBucket2.latestTraitSummaries.delete(instanceKey)) changed = true;
1477
2017
  if (instanceLabels.delete(instanceId)) changed = true;
1478
2018
  changed = true;
1479
2019
  }
2020
+ cleanupRuntimeModuleEntryIfUnused(runtimeLabel2, moduleId, moduleKey);
2021
+ }
2022
+ }
2023
+ if (level === "off") {
2024
+ if (changed) {
2025
+ markSnapshotChanged();
1480
2026
  }
2027
+ return;
1481
2028
  }
1482
- let exportBudgetChanged = false;
2029
+ let projectedDropped = 0;
2030
+ let projectedOversized = 0;
1483
2031
  const ref = toRuntimeDebugEventRef(event, {
1484
2032
  diagnosticsLevel: level,
1485
- resolveConvergeStaticIr: (staticIrDigest) => convergeStaticIrByDigest.get(staticIrDigest),
2033
+ materialization,
1486
2034
  onMetaProjection: ({ stats }) => {
1487
- if (stats.dropped !== 0 || stats.oversized !== 0) {
1488
- exportBudgetChanged = true;
1489
- }
1490
- exportBudget.dropped += stats.dropped;
1491
- exportBudget.oversized += stats.oversized;
2035
+ projectedDropped += stats.dropped;
2036
+ projectedOversized += stats.oversized;
1492
2037
  }
1493
2038
  });
1494
- if (exportBudgetChanged) {
2039
+ if (projectedDropped !== 0 || projectedOversized !== 0) {
2040
+ const budgetRuntimeLabel = normalizeRuntimeLabel(ref?.runtimeLabel ?? eventRuntimeLabel);
2041
+ const runtimeBucket2 = getOrCreateRuntimeBucket(budgetRuntimeLabel);
2042
+ runtimeBucket2.exportBudget.dropped += projectedDropped;
2043
+ runtimeBucket2.exportBudget.oversized += projectedOversized;
2044
+ exportBudget.dropped += projectedDropped;
2045
+ exportBudget.oversized += projectedOversized;
1495
2046
  changed = true;
1496
2047
  }
1497
2048
  if (!ref) {
@@ -1500,28 +2051,28 @@ var devtoolsHubSink = {
1500
2051
  }
1501
2052
  return;
1502
2053
  }
2054
+ const refRuntimeLabel = normalizeRuntimeLabel(ref.runtimeLabel);
2055
+ const runtimeBucket = getOrCreateRuntimeBucket(refRuntimeLabel);
1503
2056
  if (ref.kind === "state" && ref.label === "state:update") {
1504
- const runtimeLabel2 = ref.runtimeLabel ?? "unknown";
1505
- const key = `${runtimeLabel2}::${ref.moduleId}::${ref.instanceId}`;
1506
- if (liveInstanceKeys.has(key)) {
2057
+ const instanceKey = resolveLiveInstanceKey(refRuntimeLabel, ref.moduleId, ref.instanceId);
2058
+ if (instanceKey) {
1507
2059
  if (ref.meta && typeof ref.meta === "object" && !Array.isArray(ref.meta)) {
1508
2060
  const anyMeta = ref.meta;
1509
2061
  if ("state" in anyMeta) {
1510
- latestStates.set(key, anyMeta.state);
2062
+ latestStates.set(instanceKey, anyMeta.state);
2063
+ runtimeBucket.latestStates.set(instanceKey, anyMeta.state);
1511
2064
  changed = true;
1512
2065
  }
1513
2066
  if ("traitSummary" in anyMeta && anyMeta.traitSummary !== void 0) {
1514
- latestTraitSummaries.set(key, anyMeta.traitSummary);
2067
+ latestTraitSummaries.set(instanceKey, anyMeta.traitSummary);
2068
+ runtimeBucket.latestTraitSummaries.set(instanceKey, anyMeta.traitSummary);
1515
2069
  changed = true;
1516
2070
  }
1517
2071
  }
1518
2072
  }
1519
2073
  }
1520
2074
  if (bufferSize > 0) {
1521
- const seq = nextSeq++;
1522
- ringBuffer.push(ref);
1523
- ringBufferSeq.push(seq);
1524
- trimRingBufferIfNeeded();
2075
+ appendRuntimeRef(refRuntimeLabel, ref);
1525
2076
  changed = true;
1526
2077
  }
1527
2078
  if (changed) {
@@ -1532,14 +2083,400 @@ var devtoolsHubSink = {
1532
2083
 
1533
2084
  // src/internal/runtime/core/ConvergeStaticIrCollector.ts
1534
2085
  var import_effect5 = require("effect");
1535
- var currentConvergeStaticIrCollectors = import_effect5.FiberRef.unsafeMake([]);
1536
- var appendConvergeStaticIrCollectors = (collectors) => import_effect5.Layer.fiberRefLocallyScopedWith(currentConvergeStaticIrCollectors, (current) => [
1537
- ...current,
1538
- ...collectors
1539
- ]);
2086
+ var currentConvergeStaticIrCollectors = import_effect5.ServiceMap.Reference(
2087
+ "@logixjs/core/ConvergeStaticIrCollectors",
2088
+ {
2089
+ defaultValue: () => []
2090
+ }
2091
+ );
2092
+ var appendConvergeStaticIrCollectors = (collectors) => import_effect5.Layer.effect(
2093
+ currentConvergeStaticIrCollectors,
2094
+ import_effect5.Effect.gen(function* () {
2095
+ const current = yield* import_effect5.Effect.service(currentConvergeStaticIrCollectors);
2096
+ return [...current, ...collectors];
2097
+ })
2098
+ );
1540
2099
 
1541
2100
  // src/internal/runtime/core/env.ts
2101
+ var import_effect11 = require("effect");
2102
+
2103
+ // src/internal/runtime/core/RuntimeStore.ts
2104
+ var parseTopicKey = (topicKey) => {
2105
+ const idx = topicKey.indexOf("::");
2106
+ if (idx <= 0) return void 0;
2107
+ const moduleId = topicKey.slice(0, idx);
2108
+ const rest = topicKey.slice(idx + 2);
2109
+ if (rest.length === 0) return void 0;
2110
+ const idx2 = rest.indexOf("::");
2111
+ if (idx2 < 0) {
2112
+ return { kind: "module", moduleInstanceKey: `${moduleId}::${rest}` };
2113
+ }
2114
+ const instanceId = rest.slice(0, idx2);
2115
+ const suffix = rest.slice(idx2 + 2);
2116
+ if (suffix.startsWith("rq:")) {
2117
+ const selectorId = suffix.slice("rq:".length);
2118
+ if (selectorId.length === 0) return void 0;
2119
+ return {
2120
+ kind: "readQuery",
2121
+ moduleInstanceKey: `${moduleId}::${instanceId}`,
2122
+ selectorId
2123
+ };
2124
+ }
2125
+ return { kind: "module", moduleInstanceKey: `${moduleId}::${instanceId}` };
2126
+ };
2127
+ var EMPTY_LISTENER_SNAPSHOT = [];
2128
+ var NO_CHANGED_TOPIC_LISTENERS = [];
2129
+ var makeRuntimeStore = () => {
2130
+ let tickSeq = 0;
2131
+ const moduleStates = /* @__PURE__ */ new Map();
2132
+ const topicVersions = /* @__PURE__ */ new Map();
2133
+ const topicPriorities = /* @__PURE__ */ new Map();
2134
+ const listenersByTopic = /* @__PURE__ */ new Map();
2135
+ const subscriberCountByModule = /* @__PURE__ */ new Map();
2136
+ const getTopicVersion = (topicKey) => topicVersions.get(topicKey) ?? 0;
2137
+ const getTopicPriority = (topicKey) => topicPriorities.get(topicKey) ?? "normal";
2138
+ const commitTopicBump = (topicKey, priority) => {
2139
+ const prev = topicVersions.get(topicKey) ?? 0;
2140
+ topicVersions.set(topicKey, prev + 1);
2141
+ topicPriorities.set(topicKey, priority);
2142
+ };
2143
+ const refreshTopicSnapshot = (state) => {
2144
+ state.snapshot = Array.from(state.listeners);
2145
+ };
2146
+ const subscribeTopic = (topicKey, listener) => {
2147
+ const info = parseTopicKey(topicKey);
2148
+ const existing = listenersByTopic.get(topicKey);
2149
+ const state = existing ?? { listeners: /* @__PURE__ */ new Set(), snapshot: EMPTY_LISTENER_SNAPSHOT };
2150
+ const alreadyHas = state.listeners.has(listener);
2151
+ if (!alreadyHas) {
2152
+ state.listeners.add(listener);
2153
+ refreshTopicSnapshot(state);
2154
+ }
2155
+ if (!existing) {
2156
+ listenersByTopic.set(topicKey, state);
2157
+ }
2158
+ if (!alreadyHas && info) {
2159
+ const prev = subscriberCountByModule.get(info.moduleInstanceKey) ?? 0;
2160
+ subscriberCountByModule.set(info.moduleInstanceKey, prev + 1);
2161
+ }
2162
+ return () => {
2163
+ const currentState = listenersByTopic.get(topicKey);
2164
+ if (!currentState) return;
2165
+ const deleted = currentState.listeners.delete(listener);
2166
+ if (deleted && info) {
2167
+ const prev = subscriberCountByModule.get(info.moduleInstanceKey) ?? 0;
2168
+ const next = prev - 1;
2169
+ if (next <= 0) {
2170
+ subscriberCountByModule.delete(info.moduleInstanceKey);
2171
+ } else {
2172
+ subscriberCountByModule.set(info.moduleInstanceKey, next);
2173
+ }
2174
+ }
2175
+ if (currentState.listeners.size === 0) {
2176
+ listenersByTopic.delete(topicKey);
2177
+ } else if (deleted) {
2178
+ refreshTopicSnapshot(currentState);
2179
+ }
2180
+ };
2181
+ };
2182
+ const getTopicSubscriberCount = (topicKey) => listenersByTopic.get(topicKey)?.listeners.size ?? 0;
2183
+ const getModuleSubscriberCount = (moduleInstanceKey) => subscriberCountByModule.get(moduleInstanceKey) ?? 0;
2184
+ const registerModuleInstance = (args) => {
2185
+ moduleStates.set(args.moduleInstanceKey, args.initialState);
2186
+ if (!topicVersions.has(args.moduleInstanceKey)) {
2187
+ topicVersions.set(args.moduleInstanceKey, 0);
2188
+ topicPriorities.set(args.moduleInstanceKey, "normal");
2189
+ }
2190
+ };
2191
+ const unregisterModuleInstance = (moduleInstanceKey) => {
2192
+ moduleStates.delete(moduleInstanceKey);
2193
+ };
2194
+ const commitTick = (args) => {
2195
+ tickSeq = args.tickSeq;
2196
+ for (const [key, commit] of args.accepted.modules) {
2197
+ moduleStates.set(key, commit.state);
2198
+ }
2199
+ if (args.accepted.dirtyTopics.size === 0) {
2200
+ return {
2201
+ changedTopicListeners: NO_CHANGED_TOPIC_LISTENERS
2202
+ };
2203
+ }
2204
+ if (args.onListener) {
2205
+ let firstTopicListeners;
2206
+ let secondTopicListeners;
2207
+ let restTopicListeners;
2208
+ for (const [topicKey, priority] of args.accepted.dirtyTopics) {
2209
+ commitTopicBump(topicKey, priority);
2210
+ const listeners2 = listenersByTopic.get(topicKey)?.snapshot ?? EMPTY_LISTENER_SNAPSHOT;
2211
+ if (listeners2.length === 0) {
2212
+ continue;
2213
+ }
2214
+ if (!firstTopicListeners) {
2215
+ firstTopicListeners = listeners2;
2216
+ continue;
2217
+ }
2218
+ if (!secondTopicListeners) {
2219
+ secondTopicListeners = listeners2;
2220
+ continue;
2221
+ }
2222
+ if (!restTopicListeners) {
2223
+ restTopicListeners = [];
2224
+ }
2225
+ restTopicListeners.push(listeners2);
2226
+ }
2227
+ if (firstTopicListeners) {
2228
+ for (const listener of firstTopicListeners) {
2229
+ try {
2230
+ args.onListener(listener);
2231
+ } catch {
2232
+ }
2233
+ }
2234
+ }
2235
+ if (secondTopicListeners) {
2236
+ for (const listener of secondTopicListeners) {
2237
+ try {
2238
+ args.onListener(listener);
2239
+ } catch {
2240
+ }
2241
+ }
2242
+ }
2243
+ if (restTopicListeners) {
2244
+ for (const listeners2 of restTopicListeners) {
2245
+ for (const listener of listeners2) {
2246
+ try {
2247
+ args.onListener(listener);
2248
+ } catch {
2249
+ }
2250
+ }
2251
+ }
2252
+ }
2253
+ return {
2254
+ changedTopicListeners: NO_CHANGED_TOPIC_LISTENERS
2255
+ };
2256
+ }
2257
+ let singleTopicListeners;
2258
+ let flattenedTopicListeners;
2259
+ for (const [topicKey, priority] of args.accepted.dirtyTopics) {
2260
+ commitTopicBump(topicKey, priority);
2261
+ const listeners2 = listenersByTopic.get(topicKey)?.snapshot ?? EMPTY_LISTENER_SNAPSHOT;
2262
+ if (listeners2.length === 0) {
2263
+ continue;
2264
+ }
2265
+ if (flattenedTopicListeners) {
2266
+ for (const listener of listeners2) {
2267
+ flattenedTopicListeners.push(listener);
2268
+ }
2269
+ continue;
2270
+ }
2271
+ if (!singleTopicListeners) {
2272
+ singleTopicListeners = listeners2;
2273
+ continue;
2274
+ }
2275
+ flattenedTopicListeners = Array.from(singleTopicListeners);
2276
+ for (const listener of listeners2) {
2277
+ flattenedTopicListeners.push(listener);
2278
+ }
2279
+ }
2280
+ return {
2281
+ changedTopicListeners: flattenedTopicListeners ?? singleTopicListeners ?? NO_CHANGED_TOPIC_LISTENERS
2282
+ };
2283
+ };
2284
+ const getModuleState = (moduleInstanceKey) => moduleStates.get(moduleInstanceKey);
2285
+ const dispose = () => {
2286
+ moduleStates.clear();
2287
+ topicVersions.clear();
2288
+ topicPriorities.clear();
2289
+ listenersByTopic.clear();
2290
+ subscriberCountByModule.clear();
2291
+ };
2292
+ return {
2293
+ getTickSeq: () => tickSeq,
2294
+ getModuleState,
2295
+ getTopicVersion,
2296
+ getTopicPriority,
2297
+ subscribeTopic,
2298
+ getTopicSubscriberCount,
2299
+ getModuleSubscriberCount,
2300
+ registerModuleInstance,
2301
+ unregisterModuleInstance,
2302
+ commitTick,
2303
+ dispose
2304
+ };
2305
+ };
2306
+
2307
+ // src/internal/runtime/core/TickScheduler.ts
2308
+ var import_effect9 = require("effect");
2309
+
2310
+ // src/internal/runtime/core/TaskRunner.ts
2311
+ var import_effect8 = require("effect");
2312
+
2313
+ // src/internal/runtime/core/ModeRunner.ts
2314
+ var import_effect7 = require("effect");
2315
+
2316
+ // src/internal/runtime/core/LatestFiberSlot.ts
1542
2317
  var import_effect6 = require("effect");
2318
+
2319
+ // src/internal/runtime/core/TaskRunner.ts
2320
+ var inSyncTransactionFiber = import_effect8.ServiceMap.Reference("@logixjs/core/TaskRunner.inSyncTransactionFiber", {
2321
+ defaultValue: () => false
2322
+ });
2323
+ var forceSourceRefresh = import_effect8.ServiceMap.Reference("@logixjs/core/TaskRunner.forceSourceRefresh", {
2324
+ defaultValue: () => false
2325
+ });
2326
+
2327
+ // src/internal/runtime/core/DeclarativeLinkRuntime.ts
2328
+ var import_effect10 = require("effect");
2329
+ var makeDeclarativeLinkRuntime = () => {
2330
+ const moduleAsSourceById = /* @__PURE__ */ new Map();
2331
+ const moduleAsSourceIdsBySource = /* @__PURE__ */ new Map();
2332
+ const declarativeById = /* @__PURE__ */ new Map();
2333
+ const declarativeReadNodesBySource = /* @__PURE__ */ new Map();
2334
+ const registerModuleAsSourceLink = (link) => {
2335
+ const stored = {
2336
+ ...link,
2337
+ hasValue: false,
2338
+ lastValue: void 0
2339
+ };
2340
+ moduleAsSourceById.set(link.id, stored);
2341
+ const set = moduleAsSourceIdsBySource.get(link.sourceModuleInstanceKey) ?? /* @__PURE__ */ new Set();
2342
+ set.add(link.id);
2343
+ moduleAsSourceIdsBySource.set(link.sourceModuleInstanceKey, set);
2344
+ return () => {
2345
+ moduleAsSourceById.delete(link.id);
2346
+ const current = moduleAsSourceIdsBySource.get(link.sourceModuleInstanceKey);
2347
+ if (!current) return;
2348
+ current.delete(link.id);
2349
+ if (current.size === 0) {
2350
+ moduleAsSourceIdsBySource.delete(link.sourceModuleInstanceKey);
2351
+ }
2352
+ };
2353
+ };
2354
+ const registerDeclarativeLink = (link) => {
2355
+ const readNodeById = /* @__PURE__ */ new Map();
2356
+ for (const n of link.readNodes) {
2357
+ readNodeById.set(n.nodeId, n);
2358
+ }
2359
+ const dispatchNodeById = /* @__PURE__ */ new Map();
2360
+ for (const n of link.dispatchNodes) {
2361
+ dispatchNodeById.set(n.nodeId, n);
2362
+ }
2363
+ const incomingByDispatch = /* @__PURE__ */ new Map();
2364
+ for (const e of link.ir.edges) {
2365
+ const to = e.to;
2366
+ const isDispatch = dispatchNodeById.has(to);
2367
+ if (!isDispatch) continue;
2368
+ incomingByDispatch.set(to, (incomingByDispatch.get(to) ?? 0) + 1);
2369
+ const count = incomingByDispatch.get(to) ?? 0;
2370
+ if (count > 1) {
2371
+ throw new Error(
2372
+ `[DeclarativeLinkRuntime] Invalid DeclarativeLinkIR: dispatch node has multiple incoming edges (linkId=${link.linkId}, nodeId=${to}).`
2373
+ );
2374
+ }
2375
+ }
2376
+ const dispatchTargetsByReadNode = /* @__PURE__ */ new Map();
2377
+ for (const e of link.ir.edges) {
2378
+ const from = e.from;
2379
+ const to = e.to;
2380
+ if (!readNodeById.has(from)) continue;
2381
+ if (!dispatchNodeById.has(to)) continue;
2382
+ const list = dispatchTargetsByReadNode.get(from) ?? [];
2383
+ list.push(to);
2384
+ dispatchTargetsByReadNode.set(from, list);
2385
+ }
2386
+ const stored = {
2387
+ ...link,
2388
+ readNodeById,
2389
+ dispatchNodeById,
2390
+ dispatchTargetsByReadNode,
2391
+ readNodeState: /* @__PURE__ */ new Map()
2392
+ };
2393
+ declarativeById.set(link.linkId, stored);
2394
+ for (const n of link.readNodes) {
2395
+ const list = declarativeReadNodesBySource.get(n.moduleInstanceKey) ?? [];
2396
+ list.push({ linkId: link.linkId, nodeId: n.nodeId });
2397
+ declarativeReadNodesBySource.set(n.moduleInstanceKey, list);
2398
+ }
2399
+ return () => {
2400
+ declarativeById.delete(link.linkId);
2401
+ for (const n of link.readNodes) {
2402
+ const list = declarativeReadNodesBySource.get(n.moduleInstanceKey);
2403
+ if (!list) continue;
2404
+ const next = list.filter((x) => !(x.linkId === link.linkId && x.nodeId === n.nodeId));
2405
+ if (next.length === 0) {
2406
+ declarativeReadNodesBySource.delete(n.moduleInstanceKey);
2407
+ } else {
2408
+ declarativeReadNodesBySource.set(n.moduleInstanceKey, next);
2409
+ }
2410
+ }
2411
+ };
2412
+ };
2413
+ const applyForSources = (args) => import_effect10.Effect.gen(function* () {
2414
+ let scheduled = false;
2415
+ for (const sourceKey of args.changedModuleInstanceKeys) {
2416
+ const ids = moduleAsSourceIdsBySource.get(sourceKey);
2417
+ if (!ids || ids.size === 0) continue;
2418
+ const commit = args.acceptedModules.get(sourceKey);
2419
+ if (!commit) continue;
2420
+ for (const id of ids) {
2421
+ const link = moduleAsSourceById.get(id);
2422
+ if (!link) continue;
2423
+ let selected;
2424
+ try {
2425
+ selected = link.readQuery.select(commit.state);
2426
+ } catch {
2427
+ continue;
2428
+ }
2429
+ const nextValue = link.computeValue(selected);
2430
+ if (link.hasValue && link.equalsValue(link.lastValue, nextValue)) {
2431
+ continue;
2432
+ }
2433
+ link.hasValue = true;
2434
+ link.lastValue = nextValue;
2435
+ scheduled = true;
2436
+ yield* link.applyValue(nextValue);
2437
+ }
2438
+ }
2439
+ for (const sourceKey of args.changedModuleInstanceKeys) {
2440
+ const refs = declarativeReadNodesBySource.get(sourceKey);
2441
+ if (!refs || refs.length === 0) continue;
2442
+ const commit = args.acceptedModules.get(sourceKey);
2443
+ if (!commit) continue;
2444
+ for (const ref of refs) {
2445
+ const link = declarativeById.get(ref.linkId);
2446
+ if (!link) continue;
2447
+ const readNode = link.readNodeById.get(ref.nodeId);
2448
+ if (!readNode) continue;
2449
+ let value;
2450
+ try {
2451
+ value = readNode.readQuery.select(commit.state);
2452
+ } catch {
2453
+ continue;
2454
+ }
2455
+ const state = link.readNodeState.get(ref.nodeId) ?? { hasValue: false, lastValue: void 0 };
2456
+ const changed = !state.hasValue || !Object.is(state.lastValue, value);
2457
+ if (!changed) continue;
2458
+ state.hasValue = true;
2459
+ state.lastValue = value;
2460
+ link.readNodeState.set(ref.nodeId, state);
2461
+ const targets = link.dispatchTargetsByReadNode.get(ref.nodeId) ?? [];
2462
+ for (const dispatchNodeId of targets) {
2463
+ const node = link.dispatchNodeById.get(dispatchNodeId);
2464
+ if (!node) continue;
2465
+ scheduled = true;
2466
+ yield* node.dispatch(value);
2467
+ }
2468
+ }
2469
+ }
2470
+ return { scheduled };
2471
+ });
2472
+ return {
2473
+ registerModuleAsSourceLink,
2474
+ registerDeclarativeLink,
2475
+ applyForSources
2476
+ };
2477
+ };
2478
+
2479
+ // src/internal/runtime/core/env.ts
1543
2480
  var getNodeEnv = () => {
1544
2481
  try {
1545
2482
  const env = globalThis?.process?.env;
@@ -1549,17 +2486,40 @@ var getNodeEnv = () => {
1549
2486
  }
1550
2487
  };
1551
2488
  var isDevEnv = () => getNodeEnv() !== "production";
1552
- var StateTransactionConfigTagImpl = class extends import_effect6.Context.Tag("@logixjs/core/StateTransactionRuntimeConfig")() {
2489
+ var StateTransactionConfigTagImpl = class extends import_effect11.ServiceMap.Service()("@logixjs/core/StateTransactionRuntimeConfig") {
2490
+ };
2491
+ var ReadQueryStrictGateConfigTagImpl = class extends import_effect11.ServiceMap.Service()("@logixjs/core/ReadQueryStrictGateRuntimeConfig") {
2492
+ };
2493
+ var ReplayModeConfigTagImpl = class extends import_effect11.ServiceMap.Service()("@logixjs/core/ReplayModeConfig") {
1553
2494
  };
1554
- var ReadQueryStrictGateConfigTagImpl = class extends import_effect6.Context.Tag("@logixjs/core/ReadQueryStrictGateRuntimeConfig")() {
2495
+ var StateTransactionOverridesTagImpl = class extends import_effect11.ServiceMap.Service()("@logixjs/core/StateTransactionOverrides") {
1555
2496
  };
1556
- var ReplayModeConfigTagImpl = class extends import_effect6.Context.Tag("@logixjs/core/ReplayModeConfig")() {
2497
+ var SchedulingPolicySurfaceTagImpl = class extends import_effect11.ServiceMap.Service()("@logixjs/core/SchedulingPolicySurface") {
1557
2498
  };
1558
- var StateTransactionOverridesTagImpl = class extends import_effect6.Context.Tag("@logixjs/core/StateTransactionOverrides")() {
2499
+ var SchedulingPolicySurfaceOverridesTagImpl = class extends import_effect11.ServiceMap.Service()("@logixjs/core/SchedulingPolicySurfaceOverrides") {
2500
+ };
2501
+ var RuntimeStoreTag = class extends import_effect11.ServiceMap.Service()("@logixjs/core/RuntimeStore") {
2502
+ };
2503
+ var runtimeStoreLayer = import_effect11.Layer.effect(
2504
+ RuntimeStoreTag,
2505
+ import_effect11.Effect.acquireRelease(
2506
+ import_effect11.Effect.sync(() => makeRuntimeStore()),
2507
+ (store) => import_effect11.Effect.sync(() => store.dispose())
2508
+ )
2509
+ );
2510
+ var HostSchedulerTag = class extends import_effect11.ServiceMap.Service()("@logixjs/core/HostScheduler") {
1559
2511
  };
1560
- var ConcurrencyPolicyTagImpl = class extends import_effect6.Context.Tag("@logixjs/core/ConcurrencyPolicy")() {
2512
+ var hostSchedulerLayer = import_effect11.Layer.succeed(
2513
+ HostSchedulerTag,
2514
+ getGlobalHostScheduler()
2515
+ );
2516
+ var DeclarativeLinkRuntimeTag = class extends import_effect11.ServiceMap.Service()("@logixjs/core/DeclarativeLinkRuntime") {
1561
2517
  };
1562
- var ConcurrencyPolicyOverridesTagImpl = class extends import_effect6.Context.Tag("@logixjs/core/ConcurrencyPolicyOverrides")() {
2518
+ var declarativeLinkRuntimeLayer = import_effect11.Layer.succeed(
2519
+ DeclarativeLinkRuntimeTag,
2520
+ makeDeclarativeLinkRuntime()
2521
+ );
2522
+ var TickSchedulerTag = class extends import_effect11.ServiceMap.Service()("@logixjs/core/TickScheduler") {
1563
2523
  };
1564
2524
 
1565
2525
  // src/internal/debug/ModuleTraitsRegistry.ts
@@ -1616,10 +2576,13 @@ var internal = {
1616
2576
  currentDebugSinks,
1617
2577
  currentRuntimeLabel,
1618
2578
  currentDiagnosticsLevel,
2579
+ currentDiagnosticsMaterialization,
2580
+ currentTraceMode,
1619
2581
  currentTraitConvergeDiagnosticsSampling,
1620
2582
  toRuntimeDebugEventRef
1621
2583
  };
1622
2584
  var getDevtoolsSnapshot2 = getDevtoolsSnapshot;
2585
+ var getDevtoolsSnapshotByRuntimeLabel2 = getDevtoolsSnapshotByRuntimeLabel;
1623
2586
  var getDevtoolsSnapshotToken2 = getDevtoolsSnapshotToken;
1624
2587
  var subscribeDevtoolsSnapshot2 = subscribeDevtoolsSnapshot;
1625
2588
  var clearDevtoolsEvents2 = clearDevtoolsEvents;
@@ -1629,13 +2592,15 @@ var startDevtoolsRun2 = startDevtoolsRun;
1629
2592
  var setInstanceLabel2 = setInstanceLabel;
1630
2593
  var getInstanceLabel2 = getInstanceLabel;
1631
2594
  var exportEvidencePackage2 = (options) => exportDevtoolsEvidencePackage(options);
1632
- var diagnosticsLevel = (level) => import_effect7.Layer.fiberRefLocallyScopedWith(currentDiagnosticsLevel, () => level);
2595
+ var diagnosticsLevel2 = (level) => diagnosticsLevel(level);
2596
+ var diagnosticsMaterialization2 = (mode) => diagnosticsMaterialization(mode);
2597
+ var traceMode2 = (mode) => traceMode(mode);
1633
2598
  var traitConvergeDiagnosticsSampling2 = (config) => traitConvergeDiagnosticsSampling(config);
1634
2599
  var isDevtoolsEnabled2 = isDevtoolsEnabled;
1635
2600
  var makeModuleRuntimeCounterSink = () => {
1636
2601
  const counts = /* @__PURE__ */ new Map();
1637
2602
  const sink = {
1638
- record: (event) => import_effect7.Effect.sync(() => {
2603
+ record: (event) => import_effect12.Effect.sync(() => {
1639
2604
  if (event.type === "module:init") {
1640
2605
  const moduleId = event.moduleId ?? "unknown";
1641
2606
  const runtimeLabel2 = "runtimeLabel" in event && event.runtimeLabel ? event.runtimeLabel : "unknown";
@@ -1662,21 +2627,53 @@ var makeModuleRuntimeCounterSink = () => {
1662
2627
  return { sink, getSnapshot };
1663
2628
  };
1664
2629
  var makeRingBufferSink = (capacity = 1e3) => {
1665
- const buffer = [];
2630
+ const boundedCapacity = Number.isFinite(capacity) ? Math.ceil(capacity) : 0;
2631
+ const isBounded = boundedCapacity > 0;
2632
+ const boundedBuffer = isBounded ? new Array(boundedCapacity) : [];
2633
+ const unboundedBuffer = isBounded ? [] : [];
2634
+ let head = 0;
2635
+ let size = 0;
1666
2636
  const sink = {
1667
- record: (event) => import_effect7.Effect.sync(() => {
2637
+ record: (event) => import_effect12.Effect.sync(() => {
1668
2638
  if (capacity <= 0) {
1669
2639
  return;
1670
2640
  }
1671
- if (buffer.length >= capacity) {
1672
- buffer.shift();
2641
+ if (!isBounded) {
2642
+ unboundedBuffer.push(event);
2643
+ return;
2644
+ }
2645
+ const writeIndex = (head + size) % boundedCapacity;
2646
+ boundedBuffer[writeIndex] = event;
2647
+ if (size < boundedCapacity) {
2648
+ size += 1;
2649
+ return;
1673
2650
  }
1674
- buffer.push(event);
2651
+ head = (head + 1) % boundedCapacity;
1675
2652
  })
1676
2653
  };
1677
- const getSnapshot = () => buffer.slice();
2654
+ const getSnapshot = () => {
2655
+ if (!isBounded) {
2656
+ return unboundedBuffer.slice();
2657
+ }
2658
+ if (size === 0) {
2659
+ return [];
2660
+ }
2661
+ const snapshot = new Array(size);
2662
+ for (let i = 0; i < size; i++) {
2663
+ snapshot[i] = boundedBuffer[(head + i) % boundedCapacity];
2664
+ }
2665
+ return snapshot;
2666
+ };
1678
2667
  const clear = () => {
1679
- buffer.length = 0;
2668
+ if (!isBounded) {
2669
+ unboundedBuffer.length = 0;
2670
+ return;
2671
+ }
2672
+ for (let i = 0; i < size; i++) {
2673
+ boundedBuffer[(head + i) % boundedCapacity] = void 0;
2674
+ }
2675
+ head = 0;
2676
+ size = 0;
1680
2677
  };
1681
2678
  return { sink, getSnapshot, clear };
1682
2679
  };
@@ -1704,35 +2701,59 @@ var layer = (options) => {
1704
2701
  }
1705
2702
  }
1706
2703
  })();
1707
- return diagnostics ? import_effect7.Layer.mergeAll(sinks, diagnosticsLevel(diagnostics)) : sinks;
2704
+ const trace = mode === "dev" ? traceMode2("on") : traceMode2("off");
2705
+ const base = import_effect12.Layer.mergeAll(sinks, trace);
2706
+ return diagnostics ? import_effect12.Layer.mergeAll(base, diagnosticsLevel2(diagnostics)) : base;
1708
2707
  };
1709
- var withPrettyLogger = (base, options) => import_effect7.Layer.merge(
2708
+ var withPrettyLogger = (base, options) => import_effect12.Layer.merge(
1710
2709
  base,
1711
- import_effect7.Logger.replace(import_effect7.Logger.defaultLogger, import_effect7.Logger.prettyLogger(options))
2710
+ import_effect12.Layer.effect(
2711
+ import_effect12.Logger.CurrentLoggers,
2712
+ import_effect12.Effect.gen(function* () {
2713
+ const current = yield* import_effect12.Effect.service(import_effect12.Logger.CurrentLoggers);
2714
+ return new Set([...current].filter((logger) => logger !== import_effect12.Logger.defaultLogger).concat(import_effect12.Logger.consolePretty(options)));
2715
+ })
2716
+ )
2717
+ );
2718
+ var replace = (sinks) => import_effect12.Layer.succeed(internal.currentDebugSinks, sinks);
2719
+ var appendSinks = (sinks) => import_effect12.Layer.effect(
2720
+ internal.currentDebugSinks,
2721
+ import_effect12.Effect.gen(function* () {
2722
+ const current = yield* internal.currentDebugSinks;
2723
+ return [...current, ...sinks];
2724
+ })
1712
2725
  );
1713
- var replace = (sinks) => import_effect7.Layer.locallyScoped(internal.currentDebugSinks, sinks);
1714
- var appendSinks = (sinks) => import_effect7.Layer.fiberRefLocallyScopedWith(currentDebugSinks, (current) => [
1715
- ...current,
1716
- ...sinks
1717
- ]);
1718
2726
  function devtoolsHubLayer(baseOrOptions, maybeOptions) {
1719
- const isLayerValue = (value) => typeof value === "object" && value !== null && "_op_layer" in value;
2727
+ const isLayerValue = (value) => import_effect12.Layer.isLayer(value);
1720
2728
  const hasBase = isLayerValue(baseOrOptions);
1721
- const base = hasBase ? baseOrOptions : import_effect7.Layer.empty;
2729
+ const base = hasBase ? baseOrOptions : import_effect12.Layer.empty;
1722
2730
  const options = hasBase ? maybeOptions : baseOrOptions;
1723
2731
  configureDevtoolsHub(options);
1724
2732
  const append = appendSinks([devtoolsHubSink]);
1725
2733
  const appendConvergeStaticIr = appendConvergeStaticIrCollectors([
1726
2734
  devtoolsHubConvergeStaticIrCollector
1727
2735
  ]);
1728
- const enableExportableDiagnostics = diagnosticsLevel(options?.diagnosticsLevel ?? "light");
1729
- const convergeSamplingLayer = options?.traitConvergeDiagnosticsSampling ? traitConvergeDiagnosticsSampling2(options.traitConvergeDiagnosticsSampling) : import_effect7.Layer.empty;
1730
- return import_effect7.Layer.provideMerge(
1731
- import_effect7.Layer.mergeAll(append, enableExportableDiagnostics, convergeSamplingLayer, appendConvergeStaticIr),
2736
+ const resolvedDiagnosticsLevel = options?.diagnosticsLevel ?? "light";
2737
+ const resolvedTraceMode = options?.traceMode ?? (resolvedDiagnosticsLevel === "off" ? "off" : getNodeEnv() === "production" ? "off" : "on");
2738
+ const enableExportableDiagnostics = diagnosticsLevel2(resolvedDiagnosticsLevel);
2739
+ const enableMaterialization = diagnosticsMaterialization2(
2740
+ options?.materialization ?? (resolvedDiagnosticsLevel === "full" && getNodeEnv() === "production" ? "lazy" : "eager")
2741
+ );
2742
+ const enableTraceMode = traceMode2(resolvedTraceMode);
2743
+ const convergeSamplingLayer = options?.traitConvergeDiagnosticsSampling ? traitConvergeDiagnosticsSampling2(options.traitConvergeDiagnosticsSampling) : import_effect12.Layer.empty;
2744
+ return import_effect12.Layer.provideMerge(
2745
+ import_effect12.Layer.mergeAll(
2746
+ append,
2747
+ enableExportableDiagnostics,
2748
+ enableMaterialization,
2749
+ enableTraceMode,
2750
+ convergeSamplingLayer,
2751
+ appendConvergeStaticIr
2752
+ ),
1732
2753
  base
1733
2754
  );
1734
2755
  }
1735
- var runtimeLabel = (label) => import_effect7.Layer.fiberRefLocallyScopedWith(internal.currentRuntimeLabel, () => label);
2756
+ var runtimeLabel = (label) => import_effect12.Layer.succeed(internal.currentRuntimeLabel, label);
1736
2757
  var getModuleTraits = (module2) => {
1737
2758
  const moduleTag = module2.tag ? module2.tag : module2;
1738
2759
  const program = getModuleTraitsProgram(moduleTag);
@@ -1774,16 +2795,22 @@ var getModuleFinalTraits = (runtime) => {
1774
2795
  provenance: snapshot.provenanceIndex[t.traitId]
1775
2796
  }));
1776
2797
  };
1777
- var isLayer = (value) => typeof value === "object" && value !== null && "_op_layer" in value;
2798
+ var isLayer = (value) => typeof value === "object" && value !== null && "build" in value;
1778
2799
  function traceLayer(baseOrHandler, maybeOnTrace) {
1779
2800
  const hasBase = isLayer(baseOrHandler);
1780
- const base = hasBase ? baseOrHandler : import_effect7.Layer.empty;
2801
+ const base = hasBase ? baseOrHandler : import_effect12.Layer.empty;
1781
2802
  const onTrace = hasBase ? maybeOnTrace : baseOrHandler;
1782
2803
  const traceSink = {
1783
- record: (event) => typeof event.type === "string" && event.type.startsWith("trace:") ? onTrace ? onTrace(event) : import_effect7.Effect.logDebug({ traceEvent: event }) : import_effect7.Effect.void
2804
+ record: (event) => typeof event.type === "string" && event.type.startsWith("trace:") ? onTrace ? onTrace(event) : import_effect12.Effect.logDebug({ traceEvent: event }) : import_effect12.Effect.void
1784
2805
  };
1785
- const appendTrace = import_effect7.Layer.fiberRefLocallyScopedWith(currentDebugSinks, (sinks) => [...sinks, traceSink]);
1786
- return import_effect7.Layer.provideMerge(appendTrace, base);
2806
+ const appendTrace = import_effect12.Layer.effect(
2807
+ currentDebugSinks,
2808
+ import_effect12.Effect.gen(function* () {
2809
+ const sinks = yield* currentDebugSinks;
2810
+ return [...sinks, traceSink];
2811
+ })
2812
+ );
2813
+ return import_effect12.Layer.provideMerge(appendTrace, base);
1787
2814
  }
1788
2815
  // Annotate the CommonJS export names for ESM import in node:
1789
2816
  0 && (module.exports = {
@@ -1791,9 +2818,11 @@ function traceLayer(baseOrHandler, maybeOnTrace) {
1791
2818
  clearDevtoolsEvents,
1792
2819
  devtoolsHubLayer,
1793
2820
  diagnosticsLevel,
2821
+ diagnosticsMaterialization,
1794
2822
  exportEvidencePackage,
1795
2823
  getDevtoolsRunId,
1796
2824
  getDevtoolsSnapshot,
2825
+ getDevtoolsSnapshotByRuntimeLabel,
1797
2826
  getDevtoolsSnapshotToken,
1798
2827
  getInstanceLabel,
1799
2828
  getModuleFinalTraits,
@@ -1815,6 +2844,7 @@ function traceLayer(baseOrHandler, maybeOnTrace) {
1815
2844
  subscribeDevtoolsSnapshot,
1816
2845
  toRuntimeDebugEventRef,
1817
2846
  traceLayer,
2847
+ traceMode,
1818
2848
  traitConvergeDiagnosticsSampling,
1819
2849
  withPrettyLogger
1820
2850
  });