@e4779/pi-fabric 0.92.17-fork.3

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 (1044) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +181 -0
  3. package/THIRD_PARTY_NOTICES.md +33 -0
  4. package/dist/activity/store.d.ts +33 -0
  5. package/dist/activity/store.d.ts.map +1 -0
  6. package/dist/activity/types.d.ts +104 -0
  7. package/dist/activity/types.d.ts.map +1 -0
  8. package/dist/actors/binding-store.d.ts +17 -0
  9. package/dist/actors/binding-store.d.ts.map +1 -0
  10. package/dist/actors/context.d.ts +13 -0
  11. package/dist/actors/context.d.ts.map +1 -0
  12. package/dist/actors/delivery-policy.d.ts +8 -0
  13. package/dist/actors/delivery-policy.d.ts.map +1 -0
  14. package/dist/actors/directory.d.ts +47 -0
  15. package/dist/actors/directory.d.ts.map +1 -0
  16. package/dist/actors/global-registry.d.ts +47 -0
  17. package/dist/actors/global-registry.d.ts.map +1 -0
  18. package/dist/actors/host-event-observer.d.ts +5 -0
  19. package/dist/actors/host-event-observer.d.ts.map +1 -0
  20. package/dist/actors/host-event-payload.d.ts +14 -0
  21. package/dist/actors/host-event-payload.d.ts.map +1 -0
  22. package/dist/actors/log-store.d.ts +22 -0
  23. package/dist/actors/log-store.d.ts.map +1 -0
  24. package/dist/actors/manager.d.ts +175 -0
  25. package/dist/actors/manager.d.ts.map +1 -0
  26. package/dist/actors/mesh-monitor.d.ts +22 -0
  27. package/dist/actors/mesh-monitor.d.ts.map +1 -0
  28. package/dist/actors/predicate.d.ts +7 -0
  29. package/dist/actors/predicate.d.ts.map +1 -0
  30. package/dist/actors/registry-store.d.ts +15 -0
  31. package/dist/actors/registry-store.d.ts.map +1 -0
  32. package/dist/actors/types.d.ts +218 -0
  33. package/dist/actors/types.d.ts.map +1 -0
  34. package/dist/agents/bash-worktree-add.d.ts +24 -0
  35. package/dist/agents/bash-worktree-add.d.ts.map +1 -0
  36. package/dist/agents/budget-ledger.d.ts +88 -0
  37. package/dist/agents/budget-ledger.d.ts.map +1 -0
  38. package/dist/agents/claude-cli.d.ts +32 -0
  39. package/dist/agents/claude-cli.d.ts.map +1 -0
  40. package/dist/agents/claude-cli.js +17 -0
  41. package/dist/agents/claude-cli.js.map +7 -0
  42. package/dist/agents/clone-first-worktree.d.ts +17 -0
  43. package/dist/agents/clone-first-worktree.d.ts.map +1 -0
  44. package/dist/agents/compact-control.d.ts +32 -0
  45. package/dist/agents/compact-control.d.ts.map +1 -0
  46. package/dist/agents/compact-control.js +129 -0
  47. package/dist/agents/compact-control.js.map +7 -0
  48. package/dist/agents/constants.d.ts +9 -0
  49. package/dist/agents/constants.d.ts.map +1 -0
  50. package/dist/agents/cow-clone.d.ts +8 -0
  51. package/dist/agents/cow-clone.d.ts.map +1 -0
  52. package/dist/agents/handoff-completion.d.ts +4 -0
  53. package/dist/agents/handoff-completion.d.ts.map +1 -0
  54. package/dist/agents/handoff.d.ts +19 -0
  55. package/dist/agents/handoff.d.ts.map +1 -0
  56. package/dist/agents/lifecycle.d.ts +32 -0
  57. package/dist/agents/lifecycle.d.ts.map +1 -0
  58. package/dist/agents/manager.d.ts +75 -0
  59. package/dist/agents/manager.d.ts.map +1 -0
  60. package/dist/agents/pi-binary.d.ts +7 -0
  61. package/dist/agents/pi-binary.d.ts.map +1 -0
  62. package/dist/agents/request.d.ts +13 -0
  63. package/dist/agents/request.d.ts.map +1 -0
  64. package/dist/agents/result.d.ts +8 -0
  65. package/dist/agents/result.d.ts.map +1 -0
  66. package/dist/agents/result.js +9 -0
  67. package/dist/agents/result.js.map +7 -0
  68. package/dist/agents/rm.d.ts +15 -0
  69. package/dist/agents/rm.d.ts.map +1 -0
  70. package/dist/agents/semaphore.d.ts +7 -0
  71. package/dist/agents/semaphore.d.ts.map +1 -0
  72. package/dist/agents/service-provider.d.ts +9 -0
  73. package/dist/agents/service-provider.d.ts.map +1 -0
  74. package/dist/agents/service-schema.d.ts +6 -0
  75. package/dist/agents/service-schema.d.ts.map +1 -0
  76. package/dist/agents/service-types.d.ts +192 -0
  77. package/dist/agents/service-types.d.ts.map +1 -0
  78. package/dist/agents/service.d.ts +36 -0
  79. package/dist/agents/service.d.ts.map +1 -0
  80. package/dist/agents/session-export.d.ts +39 -0
  81. package/dist/agents/session-export.d.ts.map +1 -0
  82. package/dist/agents/session-pins.d.ts +24 -0
  83. package/dist/agents/session-pins.d.ts.map +1 -0
  84. package/dist/agents/thinking-transfer.d.ts +39 -0
  85. package/dist/agents/thinking-transfer.d.ts.map +1 -0
  86. package/dist/agents/transports/herdr-transport.d.ts +10 -0
  87. package/dist/agents/transports/herdr-transport.d.ts.map +1 -0
  88. package/dist/agents/transports/localterm-transport.d.ts +7 -0
  89. package/dist/agents/transports/localterm-transport.d.ts.map +1 -0
  90. package/dist/agents/transports/process-transport.d.ts +7 -0
  91. package/dist/agents/transports/process-transport.d.ts.map +1 -0
  92. package/dist/agents/transports/process-utils.d.ts +33 -0
  93. package/dist/agents/transports/process-utils.d.ts.map +1 -0
  94. package/dist/agents/transports/screen-transport.d.ts +7 -0
  95. package/dist/agents/transports/screen-transport.d.ts.map +1 -0
  96. package/dist/agents/transports/tmux-transport.d.ts +7 -0
  97. package/dist/agents/transports/tmux-transport.d.ts.map +1 -0
  98. package/dist/agents/types.d.ts +280 -0
  99. package/dist/agents/types.d.ts.map +1 -0
  100. package/dist/agents/veda-cli.d.ts +22 -0
  101. package/dist/agents/veda-cli.d.ts.map +1 -0
  102. package/dist/agents/veda-cli.js +13 -0
  103. package/dist/agents/veda-cli.js.map +7 -0
  104. package/dist/agents/worktree-manager.d.ts +14 -0
  105. package/dist/agents/worktree-manager.d.ts.map +1 -0
  106. package/dist/agents/worktree-paths.d.ts +5 -0
  107. package/dist/agents/worktree-paths.d.ts.map +1 -0
  108. package/dist/agents.d.ts +8 -0
  109. package/dist/agents.d.ts.map +1 -0
  110. package/dist/agents.js +761 -0
  111. package/dist/agents.js.map +7 -0
  112. package/dist/async-settlement.d.ts +4 -0
  113. package/dist/async-settlement.d.ts.map +1 -0
  114. package/dist/audit/details.d.ts +86 -0
  115. package/dist/audit/details.d.ts.map +1 -0
  116. package/dist/audit/index.d.ts +4 -0
  117. package/dist/audit/index.d.ts.map +1 -0
  118. package/dist/audit/projection.d.ts +20 -0
  119. package/dist/audit/projection.d.ts.map +1 -0
  120. package/dist/audit/trace.d.ts +99 -0
  121. package/dist/audit/trace.d.ts.map +1 -0
  122. package/dist/capture/catalog.d.ts +30 -0
  123. package/dist/capture/catalog.d.ts.map +1 -0
  124. package/dist/capture/interceptor.d.ts +20 -0
  125. package/dist/capture/interceptor.d.ts.map +1 -0
  126. package/dist/capture/wrapper.d.ts +15 -0
  127. package/dist/capture/wrapper.d.ts.map +1 -0
  128. package/dist/chunks/chunk-2DMJ7MEI.js +1984 -0
  129. package/dist/chunks/chunk-2DMJ7MEI.js.map +7 -0
  130. package/dist/chunks/chunk-2PZWDVJB.js +738 -0
  131. package/dist/chunks/chunk-2PZWDVJB.js.map +7 -0
  132. package/dist/chunks/chunk-2UQV52II.js +440 -0
  133. package/dist/chunks/chunk-2UQV52II.js.map +7 -0
  134. package/dist/chunks/chunk-32BNQ75J.js +1445 -0
  135. package/dist/chunks/chunk-32BNQ75J.js.map +7 -0
  136. package/dist/chunks/chunk-3H7SDWZI.js +467 -0
  137. package/dist/chunks/chunk-3H7SDWZI.js.map +7 -0
  138. package/dist/chunks/chunk-3MEHEH6B.js +41 -0
  139. package/dist/chunks/chunk-3MEHEH6B.js.map +7 -0
  140. package/dist/chunks/chunk-3QECYQGA.js +70 -0
  141. package/dist/chunks/chunk-3QECYQGA.js.map +7 -0
  142. package/dist/chunks/chunk-3WIGAX56.js +644 -0
  143. package/dist/chunks/chunk-3WIGAX56.js.map +7 -0
  144. package/dist/chunks/chunk-3YZUQESG.js +16 -0
  145. package/dist/chunks/chunk-3YZUQESG.js.map +7 -0
  146. package/dist/chunks/chunk-4JETKRFE.js +287 -0
  147. package/dist/chunks/chunk-4JETKRFE.js.map +7 -0
  148. package/dist/chunks/chunk-4SSMGBF4.js +93 -0
  149. package/dist/chunks/chunk-4SSMGBF4.js.map +7 -0
  150. package/dist/chunks/chunk-5SU3YXBS.js +15 -0
  151. package/dist/chunks/chunk-5SU3YXBS.js.map +7 -0
  152. package/dist/chunks/chunk-656HWVFU.js +409 -0
  153. package/dist/chunks/chunk-656HWVFU.js.map +7 -0
  154. package/dist/chunks/chunk-7A6NVHB5.js +1242 -0
  155. package/dist/chunks/chunk-7A6NVHB5.js.map +7 -0
  156. package/dist/chunks/chunk-7TB7NXSL.js +58 -0
  157. package/dist/chunks/chunk-7TB7NXSL.js.map +7 -0
  158. package/dist/chunks/chunk-AAHHYDTO.js +24 -0
  159. package/dist/chunks/chunk-AAHHYDTO.js.map +7 -0
  160. package/dist/chunks/chunk-ARLYAW2A.js +95 -0
  161. package/dist/chunks/chunk-ARLYAW2A.js.map +7 -0
  162. package/dist/chunks/chunk-AYBIR4YV.js +210 -0
  163. package/dist/chunks/chunk-AYBIR4YV.js.map +7 -0
  164. package/dist/chunks/chunk-BOTRGFQQ.js +87 -0
  165. package/dist/chunks/chunk-BOTRGFQQ.js.map +7 -0
  166. package/dist/chunks/chunk-CGPK5WHX.js +96 -0
  167. package/dist/chunks/chunk-CGPK5WHX.js.map +7 -0
  168. package/dist/chunks/chunk-CI56CW53.js +470 -0
  169. package/dist/chunks/chunk-CI56CW53.js.map +7 -0
  170. package/dist/chunks/chunk-CPSW2GW4.js +1466 -0
  171. package/dist/chunks/chunk-CPSW2GW4.js.map +7 -0
  172. package/dist/chunks/chunk-CQFP2RCP.js +64 -0
  173. package/dist/chunks/chunk-CQFP2RCP.js.map +7 -0
  174. package/dist/chunks/chunk-D5WKZONW.js +797 -0
  175. package/dist/chunks/chunk-D5WKZONW.js.map +7 -0
  176. package/dist/chunks/chunk-DLXPTBPL.js +151 -0
  177. package/dist/chunks/chunk-DLXPTBPL.js.map +7 -0
  178. package/dist/chunks/chunk-G4LADAYY.js +287 -0
  179. package/dist/chunks/chunk-G4LADAYY.js.map +7 -0
  180. package/dist/chunks/chunk-GXNR6NRU.js +447 -0
  181. package/dist/chunks/chunk-GXNR6NRU.js.map +7 -0
  182. package/dist/chunks/chunk-IGVDD2HT.js +10 -0
  183. package/dist/chunks/chunk-IGVDD2HT.js.map +7 -0
  184. package/dist/chunks/chunk-J2HV2URQ.js +1125 -0
  185. package/dist/chunks/chunk-J2HV2URQ.js.map +7 -0
  186. package/dist/chunks/chunk-KAD7UWT2.js +99 -0
  187. package/dist/chunks/chunk-KAD7UWT2.js.map +7 -0
  188. package/dist/chunks/chunk-KYXZJNV6.js +227 -0
  189. package/dist/chunks/chunk-KYXZJNV6.js.map +7 -0
  190. package/dist/chunks/chunk-LMAVZN7J.js +8 -0
  191. package/dist/chunks/chunk-LMAVZN7J.js.map +7 -0
  192. package/dist/chunks/chunk-M3S7XITB.js +110 -0
  193. package/dist/chunks/chunk-M3S7XITB.js.map +7 -0
  194. package/dist/chunks/chunk-MGDLRV2R.js +112 -0
  195. package/dist/chunks/chunk-MGDLRV2R.js.map +7 -0
  196. package/dist/chunks/chunk-MGWQOKBV.js +30 -0
  197. package/dist/chunks/chunk-MGWQOKBV.js.map +7 -0
  198. package/dist/chunks/chunk-N5GUXC6F.js +184 -0
  199. package/dist/chunks/chunk-N5GUXC6F.js.map +7 -0
  200. package/dist/chunks/chunk-NQOEHX62.js +215 -0
  201. package/dist/chunks/chunk-NQOEHX62.js.map +7 -0
  202. package/dist/chunks/chunk-OKOHRXGF.js +100 -0
  203. package/dist/chunks/chunk-OKOHRXGF.js.map +7 -0
  204. package/dist/chunks/chunk-OP2KTYQB.js +286 -0
  205. package/dist/chunks/chunk-OP2KTYQB.js.map +7 -0
  206. package/dist/chunks/chunk-OTCASLY2.js +52 -0
  207. package/dist/chunks/chunk-OTCASLY2.js.map +7 -0
  208. package/dist/chunks/chunk-PAN6C3JM.js +42 -0
  209. package/dist/chunks/chunk-PAN6C3JM.js.map +7 -0
  210. package/dist/chunks/chunk-PH7ZJ27F.js +6873 -0
  211. package/dist/chunks/chunk-PH7ZJ27F.js.map +7 -0
  212. package/dist/chunks/chunk-PM5I335G.js +225 -0
  213. package/dist/chunks/chunk-PM5I335G.js.map +7 -0
  214. package/dist/chunks/chunk-PSNXUZMY.js +218 -0
  215. package/dist/chunks/chunk-PSNXUZMY.js.map +7 -0
  216. package/dist/chunks/chunk-PXAICAUT.js +24 -0
  217. package/dist/chunks/chunk-PXAICAUT.js.map +7 -0
  218. package/dist/chunks/chunk-RERA6YWA.js +359 -0
  219. package/dist/chunks/chunk-RERA6YWA.js.map +7 -0
  220. package/dist/chunks/chunk-RNOPHITP.js +1720 -0
  221. package/dist/chunks/chunk-RNOPHITP.js.map +7 -0
  222. package/dist/chunks/chunk-RRGTKHXZ.js +931 -0
  223. package/dist/chunks/chunk-RRGTKHXZ.js.map +7 -0
  224. package/dist/chunks/chunk-SWB2OHYW.js +93 -0
  225. package/dist/chunks/chunk-SWB2OHYW.js.map +7 -0
  226. package/dist/chunks/chunk-T3A5GNCW.js +19 -0
  227. package/dist/chunks/chunk-T3A5GNCW.js.map +7 -0
  228. package/dist/chunks/chunk-TPLMVELH.js +118 -0
  229. package/dist/chunks/chunk-TPLMVELH.js.map +7 -0
  230. package/dist/chunks/chunk-TSRKCXNI.js +17 -0
  231. package/dist/chunks/chunk-TSRKCXNI.js.map +7 -0
  232. package/dist/chunks/chunk-U5FYOMG5.js +119 -0
  233. package/dist/chunks/chunk-U5FYOMG5.js.map +7 -0
  234. package/dist/chunks/chunk-U6CTHPZC.js +1924 -0
  235. package/dist/chunks/chunk-U6CTHPZC.js.map +7 -0
  236. package/dist/chunks/chunk-UDFDF7IY.js +1572 -0
  237. package/dist/chunks/chunk-UDFDF7IY.js.map +7 -0
  238. package/dist/chunks/chunk-UKMQK5VP.js +231 -0
  239. package/dist/chunks/chunk-UKMQK5VP.js.map +7 -0
  240. package/dist/chunks/chunk-UQ4LTUH4.js +2181 -0
  241. package/dist/chunks/chunk-UQ4LTUH4.js.map +7 -0
  242. package/dist/chunks/chunk-UTR3I23Z.js +65 -0
  243. package/dist/chunks/chunk-UTR3I23Z.js.map +7 -0
  244. package/dist/chunks/chunk-VPPIJRNZ.js +50 -0
  245. package/dist/chunks/chunk-VPPIJRNZ.js.map +7 -0
  246. package/dist/chunks/chunk-VRYEGVHR.js +195 -0
  247. package/dist/chunks/chunk-VRYEGVHR.js.map +7 -0
  248. package/dist/chunks/chunk-VRZNFNPB.js +4218 -0
  249. package/dist/chunks/chunk-VRZNFNPB.js.map +7 -0
  250. package/dist/chunks/chunk-VXZZJ44D.js +295 -0
  251. package/dist/chunks/chunk-VXZZJ44D.js.map +7 -0
  252. package/dist/chunks/chunk-W3FRE4VI.js +297 -0
  253. package/dist/chunks/chunk-W3FRE4VI.js.map +7 -0
  254. package/dist/chunks/chunk-WVH324VF.js +60 -0
  255. package/dist/chunks/chunk-WVH324VF.js.map +7 -0
  256. package/dist/chunks/chunk-X7G62ZGH.js +151 -0
  257. package/dist/chunks/chunk-X7G62ZGH.js.map +7 -0
  258. package/dist/chunks/chunk-XB3RJVT4.js +17 -0
  259. package/dist/chunks/chunk-XB3RJVT4.js.map +7 -0
  260. package/dist/chunks/chunk-XT4346N7.js +651 -0
  261. package/dist/chunks/chunk-XT4346N7.js.map +7 -0
  262. package/dist/chunks/chunk-Y7KNRAFL.js +1180 -0
  263. package/dist/chunks/chunk-Y7KNRAFL.js.map +7 -0
  264. package/dist/chunks/chunk-YK5AZ7CZ.js +692 -0
  265. package/dist/chunks/chunk-YK5AZ7CZ.js.map +7 -0
  266. package/dist/chunks/chunk-YU4O6SWQ.js +246 -0
  267. package/dist/chunks/chunk-YU4O6SWQ.js.map +7 -0
  268. package/dist/chunks/chunk-YU62DDKK.js +22 -0
  269. package/dist/chunks/chunk-YU62DDKK.js.map +7 -0
  270. package/dist/chunks/chunk-Z63R5GVN.js +121 -0
  271. package/dist/chunks/chunk-Z63R5GVN.js.map +7 -0
  272. package/dist/chunks/chunk-ZDNGXLEC.js +221 -0
  273. package/dist/chunks/chunk-ZDNGXLEC.js.map +7 -0
  274. package/dist/chunks/chunk-ZZ4LHQYJ.js +777 -0
  275. package/dist/chunks/chunk-ZZ4LHQYJ.js.map +7 -0
  276. package/dist/commands/fabric.d.ts +17 -0
  277. package/dist/commands/fabric.d.ts.map +1 -0
  278. package/dist/compaction/bounds.d.ts +23 -0
  279. package/dist/compaction/bounds.d.ts.map +1 -0
  280. package/dist/compaction/branch-details.d.ts +83 -0
  281. package/dist/compaction/branch-details.d.ts.map +1 -0
  282. package/dist/compaction/branch-summary.d.ts +9 -0
  283. package/dist/compaction/branch-summary.d.ts.map +1 -0
  284. package/dist/compaction/enrichers.d.ts +10 -0
  285. package/dist/compaction/enrichers.d.ts.map +1 -0
  286. package/dist/compaction/hook.d.ts +99 -0
  287. package/dist/compaction/hook.d.ts.map +1 -0
  288. package/dist/compaction/hook.js +22 -0
  289. package/dist/compaction/hook.js.map +7 -0
  290. package/dist/compaction/instructions.d.ts +38 -0
  291. package/dist/compaction/instructions.d.ts.map +1 -0
  292. package/dist/compaction/normalize.d.ts +83 -0
  293. package/dist/compaction/normalize.d.ts.map +1 -0
  294. package/dist/compaction/projections.d.ts +31 -0
  295. package/dist/compaction/projections.d.ts.map +1 -0
  296. package/dist/compaction/qa.d.ts +27 -0
  297. package/dist/compaction/qa.d.ts.map +1 -0
  298. package/dist/compaction/render.d.ts +10 -0
  299. package/dist/compaction/render.d.ts.map +1 -0
  300. package/dist/compaction/threshold.d.ts +5 -0
  301. package/dist/compaction/threshold.d.ts.map +1 -0
  302. package/dist/compaction/trace-events.d.ts +23 -0
  303. package/dist/compaction/trace-events.d.ts.map +1 -0
  304. package/dist/components/catalog.d.ts +25 -0
  305. package/dist/components/catalog.d.ts.map +1 -0
  306. package/dist/components/effect-policy.d.ts +21 -0
  307. package/dist/components/effect-policy.d.ts.map +1 -0
  308. package/dist/components/effect-scope.d.ts +31 -0
  309. package/dist/components/effect-scope.d.ts.map +1 -0
  310. package/dist/components/loader.d.ts +27 -0
  311. package/dist/components/loader.d.ts.map +1 -0
  312. package/dist/components/model-guidance.d.ts +48 -0
  313. package/dist/components/model-guidance.d.ts.map +1 -0
  314. package/dist/components/provider-component.d.ts +31 -0
  315. package/dist/components/provider-component.d.ts.map +1 -0
  316. package/dist/components/supervisor.d.ts +29 -0
  317. package/dist/components/supervisor.d.ts.map +1 -0
  318. package/dist/components/types.d.ts +140 -0
  319. package/dist/components/types.d.ts.map +1 -0
  320. package/dist/config-migrations.d.ts +11 -0
  321. package/dist/config-migrations.d.ts.map +1 -0
  322. package/dist/config.d.ts +282 -0
  323. package/dist/config.d.ts.map +1 -0
  324. package/dist/core/action-arguments.d.ts +12 -0
  325. package/dist/core/action-arguments.d.ts.map +1 -0
  326. package/dist/core/action-registry.d.ts +170 -0
  327. package/dist/core/action-registry.d.ts.map +1 -0
  328. package/dist/core/action-registry.js +20 -0
  329. package/dist/core/action-registry.js.map +7 -0
  330. package/dist/core/action-repair.d.ts +15 -0
  331. package/dist/core/action-repair.d.ts.map +1 -0
  332. package/dist/core/action-result.d.ts +13 -0
  333. package/dist/core/action-result.d.ts.map +1 -0
  334. package/dist/core/agent-dir.d.ts +2 -0
  335. package/dist/core/agent-dir.d.ts.map +1 -0
  336. package/dist/core/approval-controller.d.ts +31 -0
  337. package/dist/core/approval-controller.d.ts.map +1 -0
  338. package/dist/core/atomic-write.d.ts +15 -0
  339. package/dist/core/atomic-write.d.ts.map +1 -0
  340. package/dist/core/auto-approval-classifier.d.ts +17 -0
  341. package/dist/core/auto-approval-classifier.d.ts.map +1 -0
  342. package/dist/core/call-preview.d.ts +8 -0
  343. package/dist/core/call-preview.d.ts.map +1 -0
  344. package/dist/core/child-tool-allowlist.d.ts +3 -0
  345. package/dist/core/child-tool-allowlist.d.ts.map +1 -0
  346. package/dist/core/compact-controller.d.ts +42 -0
  347. package/dist/core/compact-controller.d.ts.map +1 -0
  348. package/dist/core/core-override-guidance.d.ts +7 -0
  349. package/dist/core/core-override-guidance.d.ts.map +1 -0
  350. package/dist/core/damaged-file.d.ts +6 -0
  351. package/dist/core/damaged-file.d.ts.map +1 -0
  352. package/dist/core/direct-tool-approval.d.ts +19 -0
  353. package/dist/core/direct-tool-approval.d.ts.map +1 -0
  354. package/dist/core/effect-conflict.d.ts +3 -0
  355. package/dist/core/effect-conflict.d.ts.map +1 -0
  356. package/dist/core/file-lock.d.ts +12 -0
  357. package/dist/core/file-lock.d.ts.map +1 -0
  358. package/dist/core/kernel-skills.d.ts +3 -0
  359. package/dist/core/kernel-skills.d.ts.map +1 -0
  360. package/dist/core/model-resolution.d.ts +62 -0
  361. package/dist/core/model-resolution.d.ts.map +1 -0
  362. package/dist/core/model-usage.d.ts +8 -0
  363. package/dist/core/model-usage.d.ts.map +1 -0
  364. package/dist/core/pi-arguments.d.ts +3 -0
  365. package/dist/core/pi-arguments.d.ts.map +1 -0
  366. package/dist/core/pi-bash-error.d.ts +9 -0
  367. package/dist/core/pi-bash-error.d.ts.map +1 -0
  368. package/dist/core/pi-tools.d.ts +9 -0
  369. package/dist/core/pi-tools.d.ts.map +1 -0
  370. package/dist/core/provider-bindings.d.ts +47 -0
  371. package/dist/core/provider-bindings.d.ts.map +1 -0
  372. package/dist/core/proxy-contract.d.ts +18 -0
  373. package/dist/core/proxy-contract.d.ts.map +1 -0
  374. package/dist/core/session-context.d.ts +14 -0
  375. package/dist/core/session-context.d.ts.map +1 -0
  376. package/dist/core/shell-jobs.d.ts +99 -0
  377. package/dist/core/shell-jobs.d.ts.map +1 -0
  378. package/dist/core/skill-block.d.ts +10 -0
  379. package/dist/core/skill-block.d.ts.map +1 -0
  380. package/dist/core/skill-dir.d.ts +4 -0
  381. package/dist/core/skill-dir.d.ts.map +1 -0
  382. package/dist/core/skill-prompt.d.ts +3 -0
  383. package/dist/core/skill-prompt.d.ts.map +1 -0
  384. package/dist/core/skill-references.d.ts +7 -0
  385. package/dist/core/skill-references.d.ts.map +1 -0
  386. package/dist/core/stable-hash.d.ts +3 -0
  387. package/dist/core/stable-hash.d.ts.map +1 -0
  388. package/dist/core/system-guidance.d.ts +13 -0
  389. package/dist/core/system-guidance.d.ts.map +1 -0
  390. package/dist/core/token-math.d.ts +16 -0
  391. package/dist/core/token-math.d.ts.map +1 -0
  392. package/dist/core/tool-ownership.d.ts +47 -0
  393. package/dist/core/tool-ownership.d.ts.map +1 -0
  394. package/dist/core/tool-result-proxy.d.ts +18 -0
  395. package/dist/core/tool-result-proxy.d.ts.map +1 -0
  396. package/dist/entropy/active.d.ts +9 -0
  397. package/dist/entropy/active.d.ts.map +1 -0
  398. package/dist/entropy/compiled-store.d.ts +16 -0
  399. package/dist/entropy/compiled-store.d.ts.map +1 -0
  400. package/dist/entropy/compiled-surface.d.ts +57 -0
  401. package/dist/entropy/compiled-surface.d.ts.map +1 -0
  402. package/dist/entropy/compiler.d.ts +27 -0
  403. package/dist/entropy/compiler.d.ts.map +1 -0
  404. package/dist/entropy/corpus.d.ts +22 -0
  405. package/dist/entropy/corpus.d.ts.map +1 -0
  406. package/dist/entropy/fingerprint.d.ts +9 -0
  407. package/dist/entropy/fingerprint.d.ts.map +1 -0
  408. package/dist/entropy/index.d.ts +16 -0
  409. package/dist/entropy/index.d.ts.map +1 -0
  410. package/dist/entropy/index.js +194 -0
  411. package/dist/entropy/index.js.map +7 -0
  412. package/dist/entropy/meter.d.ts +10 -0
  413. package/dist/entropy/meter.d.ts.map +1 -0
  414. package/dist/entropy/normal-form.d.ts +40 -0
  415. package/dist/entropy/normal-form.d.ts.map +1 -0
  416. package/dist/entropy/passes.d.ts +13 -0
  417. package/dist/entropy/passes.d.ts.map +1 -0
  418. package/dist/entropy/pool-store.d.ts +15 -0
  419. package/dist/entropy/pool-store.d.ts.map +1 -0
  420. package/dist/entropy/pool.d.ts +41 -0
  421. package/dist/entropy/pool.d.ts.map +1 -0
  422. package/dist/entropy/presentation.d.ts +12 -0
  423. package/dist/entropy/presentation.d.ts.map +1 -0
  424. package/dist/entropy/sessions.d.ts +47 -0
  425. package/dist/entropy/sessions.d.ts.map +1 -0
  426. package/dist/entropy/surface.d.ts +30 -0
  427. package/dist/entropy/surface.d.ts.map +1 -0
  428. package/dist/entropy/trial.d.ts +38 -0
  429. package/dist/entropy/trial.d.ts.map +1 -0
  430. package/dist/entropy/types.d.ts +181 -0
  431. package/dist/entropy/types.d.ts.map +1 -0
  432. package/dist/execution-service.d.ts +66 -0
  433. package/dist/execution-service.d.ts.map +1 -0
  434. package/dist/fabric-exec-arguments.d.ts +7 -0
  435. package/dist/fabric-exec-arguments.d.ts.map +1 -0
  436. package/dist/fabric-exec-tool.d.ts +8 -0
  437. package/dist/fabric-exec-tool.d.ts.map +1 -0
  438. package/dist/fabric-runtime-state.d.ts +96 -0
  439. package/dist/fabric-runtime-state.d.ts.map +1 -0
  440. package/dist/fabric-runtime-state.js +11928 -0
  441. package/dist/fabric-runtime-state.js.map +7 -0
  442. package/dist/fabric-state.d.ts +95 -0
  443. package/dist/fabric-state.d.ts.map +1 -0
  444. package/dist/failure-progress.d.ts +3 -0
  445. package/dist/failure-progress.d.ts.map +1 -0
  446. package/dist/host-compatibility.d.ts +5 -0
  447. package/dist/host-compatibility.d.ts.map +1 -0
  448. package/dist/index.d.ts +11 -0
  449. package/dist/index.d.ts.map +1 -0
  450. package/dist/index.js +6094 -0
  451. package/dist/index.js.map +7 -0
  452. package/dist/jev/auth.d.ts +5 -0
  453. package/dist/jev/auth.d.ts.map +1 -0
  454. package/dist/jev/browser.d.ts +37 -0
  455. package/dist/jev/browser.d.ts.map +1 -0
  456. package/dist/jev/browser.js +13 -0
  457. package/dist/jev/browser.js.map +7 -0
  458. package/dist/jev/client.d.ts +29 -0
  459. package/dist/jev/client.d.ts.map +1 -0
  460. package/dist/jev/client.js +11 -0
  461. package/dist/jev/client.js.map +7 -0
  462. package/dist/jev/config.d.ts +17 -0
  463. package/dist/jev/config.d.ts.map +1 -0
  464. package/dist/jev/guest-types.d.ts +2 -0
  465. package/dist/jev/guest-types.d.ts.map +1 -0
  466. package/dist/jev/manager.d.ts +36 -0
  467. package/dist/jev/manager.d.ts.map +1 -0
  468. package/dist/jev/observation.d.ts +59 -0
  469. package/dist/jev/observation.d.ts.map +1 -0
  470. package/dist/jev/observation.js +20 -0
  471. package/dist/jev/observation.js.map +7 -0
  472. package/dist/jev/types.d.ts +142 -0
  473. package/dist/jev/types.d.ts.map +1 -0
  474. package/dist/jev/validation.d.ts +8 -0
  475. package/dist/jev/validation.d.ts.map +1 -0
  476. package/dist/jev.d.ts +9 -0
  477. package/dist/jev.d.ts.map +1 -0
  478. package/dist/jev.js +49 -0
  479. package/dist/jev.js.map +7 -0
  480. package/dist/lifecycle/broker.d.ts +30 -0
  481. package/dist/lifecycle/broker.d.ts.map +1 -0
  482. package/dist/lifecycle/delivery-scheduler.d.ts +30 -0
  483. package/dist/lifecycle/delivery-scheduler.d.ts.map +1 -0
  484. package/dist/lifecycle/types.d.ts +91 -0
  485. package/dist/lifecycle/types.d.ts.map +1 -0
  486. package/dist/log-tail.d.ts +11 -0
  487. package/dist/log-tail.d.ts.map +1 -0
  488. package/dist/main-agent.d.ts +70 -0
  489. package/dist/main-agent.d.ts.map +1 -0
  490. package/dist/managed-host.d.ts +22 -0
  491. package/dist/managed-host.d.ts.map +1 -0
  492. package/dist/mcp.d.ts +9 -0
  493. package/dist/mcp.d.ts.map +1 -0
  494. package/dist/mcp.js +21 -0
  495. package/dist/mcp.js.map +7 -0
  496. package/dist/memory/client.d.ts +31 -0
  497. package/dist/memory/client.d.ts.map +1 -0
  498. package/dist/memory/context.d.ts +114 -0
  499. package/dist/memory/context.d.ts.map +1 -0
  500. package/dist/memory/digest.d.ts +48 -0
  501. package/dist/memory/digest.d.ts.map +1 -0
  502. package/dist/memory/digest.js +7 -0
  503. package/dist/memory/digest.js.map +7 -0
  504. package/dist/memory/discovery.d.ts +43 -0
  505. package/dist/memory/discovery.d.ts.map +1 -0
  506. package/dist/memory/discovery.js +25 -0
  507. package/dist/memory/discovery.js.map +7 -0
  508. package/dist/memory/expand-service.d.ts +4 -0
  509. package/dist/memory/expand-service.d.ts.map +1 -0
  510. package/dist/memory/host-source.d.ts +60 -0
  511. package/dist/memory/host-source.d.ts.map +1 -0
  512. package/dist/memory/index.d.ts +113 -0
  513. package/dist/memory/index.d.ts.map +1 -0
  514. package/dist/memory/lineage.d.ts +25 -0
  515. package/dist/memory/lineage.d.ts.map +1 -0
  516. package/dist/memory/normalize.d.ts +188 -0
  517. package/dist/memory/normalize.d.ts.map +1 -0
  518. package/dist/memory/normalize.js +26 -0
  519. package/dist/memory/normalize.js.map +7 -0
  520. package/dist/memory/portable.d.ts +66 -0
  521. package/dist/memory/portable.d.ts.map +1 -0
  522. package/dist/memory/provider.d.ts +15 -0
  523. package/dist/memory/provider.d.ts.map +1 -0
  524. package/dist/memory/recall-service.d.ts +5 -0
  525. package/dist/memory/recall-service.d.ts.map +1 -0
  526. package/dist/memory/regex.d.ts +19 -0
  527. package/dist/memory/regex.d.ts.map +1 -0
  528. package/dist/memory/request-cache.d.ts +49 -0
  529. package/dist/memory/request-cache.d.ts.map +1 -0
  530. package/dist/memory/request-context.d.ts +57 -0
  531. package/dist/memory/request-context.d.ts.map +1 -0
  532. package/dist/memory/request-limits.d.ts +8 -0
  533. package/dist/memory/request-limits.d.ts.map +1 -0
  534. package/dist/memory/search.d.ts +98 -0
  535. package/dist/memory/search.d.ts.map +1 -0
  536. package/dist/memory/search.js +24 -0
  537. package/dist/memory/search.js.map +7 -0
  538. package/dist/memory/sessions-service.d.ts +3 -0
  539. package/dist/memory/sessions-service.d.ts.map +1 -0
  540. package/dist/memory/source-observation.d.ts +28 -0
  541. package/dist/memory/source-observation.d.ts.map +1 -0
  542. package/dist/memory/tokenize.d.ts +24 -0
  543. package/dist/memory/tokenize.d.ts.map +1 -0
  544. package/dist/memory.d.ts +8 -0
  545. package/dist/memory.d.ts.map +1 -0
  546. package/dist/memory.js +119 -0
  547. package/dist/memory.js.map +7 -0
  548. package/dist/mesh/store.d.ts +78 -0
  549. package/dist/mesh/store.d.ts.map +1 -0
  550. package/dist/output-budget.d.ts +12 -0
  551. package/dist/output-budget.d.ts.map +1 -0
  552. package/dist/prewalk/arm.d.ts +8 -0
  553. package/dist/prewalk/arm.d.ts.map +1 -0
  554. package/dist/prewalk/controller.d.ts +66 -0
  555. package/dist/prewalk/controller.d.ts.map +1 -0
  556. package/dist/prewalk/fs-drift.d.ts +19 -0
  557. package/dist/prewalk/fs-drift.d.ts.map +1 -0
  558. package/dist/prewalk/handoff.d.ts +46 -0
  559. package/dist/prewalk/handoff.d.ts.map +1 -0
  560. package/dist/protocol.d.ts +275 -0
  561. package/dist/protocol.d.ts.map +1 -0
  562. package/dist/protocol.js +46 -0
  563. package/dist/protocol.js.map +7 -0
  564. package/dist/providers/agents-actions.d.ts +3 -0
  565. package/dist/providers/agents-actions.d.ts.map +1 -0
  566. package/dist/providers/agents-message-router.d.ts +29 -0
  567. package/dist/providers/agents-message-router.d.ts.map +1 -0
  568. package/dist/providers/agents-progress.d.ts +18 -0
  569. package/dist/providers/agents-progress.d.ts.map +1 -0
  570. package/dist/providers/agents-provider.d.ts +51 -0
  571. package/dist/providers/agents-provider.d.ts.map +1 -0
  572. package/dist/providers/arg-normalization.d.ts +15 -0
  573. package/dist/providers/arg-normalization.d.ts.map +1 -0
  574. package/dist/providers/captured-tools-provider.d.ts +23 -0
  575. package/dist/providers/captured-tools-provider.d.ts.map +1 -0
  576. package/dist/providers/compact-provider.d.ts +14 -0
  577. package/dist/providers/compact-provider.d.ts.map +1 -0
  578. package/dist/providers/components-provider.d.ts +12 -0
  579. package/dist/providers/components-provider.d.ts.map +1 -0
  580. package/dist/providers/jev-provider.d.ts +70 -0
  581. package/dist/providers/jev-provider.d.ts.map +1 -0
  582. package/dist/providers/jev-provider.js +28 -0
  583. package/dist/providers/jev-provider.js.map +7 -0
  584. package/dist/providers/mcp-descriptor-cache.d.ts +47 -0
  585. package/dist/providers/mcp-descriptor-cache.d.ts.map +1 -0
  586. package/dist/providers/mcp-provider.d.ts +47 -0
  587. package/dist/providers/mcp-provider.d.ts.map +1 -0
  588. package/dist/providers/memory-provider.d.ts +32 -0
  589. package/dist/providers/memory-provider.d.ts.map +1 -0
  590. package/dist/providers/memory-provider.js +23 -0
  591. package/dist/providers/memory-provider.js.map +7 -0
  592. package/dist/providers/mesh-provider.d.ts +17 -0
  593. package/dist/providers/mesh-provider.d.ts.map +1 -0
  594. package/dist/providers/pi-bash-cwd.d.ts +49 -0
  595. package/dist/providers/pi-bash-cwd.d.ts.map +1 -0
  596. package/dist/providers/pi-tools-provider.d.ts +25 -0
  597. package/dist/providers/pi-tools-provider.d.ts.map +1 -0
  598. package/dist/providers/schema-provider.d.ts +15 -0
  599. package/dist/providers/schema-provider.d.ts.map +1 -0
  600. package/dist/providers/state-provider.d.ts +16 -0
  601. package/dist/providers/state-provider.d.ts.map +1 -0
  602. package/dist/providers/write-diff-limits.d.ts +5 -0
  603. package/dist/providers/write-diff-limits.d.ts.map +1 -0
  604. package/dist/providers/write-preview.d.ts +3 -0
  605. package/dist/providers/write-preview.d.ts.map +1 -0
  606. package/dist/ref-names.d.ts +2 -0
  607. package/dist/ref-names.d.ts.map +1 -0
  608. package/dist/repairs/active.d.ts +7 -0
  609. package/dist/repairs/active.d.ts.map +1 -0
  610. package/dist/repairs/apply.d.ts +7 -0
  611. package/dist/repairs/apply.d.ts.map +1 -0
  612. package/dist/repairs/catalog-digest.d.ts +5 -0
  613. package/dist/repairs/catalog-digest.d.ts.map +1 -0
  614. package/dist/repairs/classify.d.ts +10 -0
  615. package/dist/repairs/classify.d.ts.map +1 -0
  616. package/dist/repairs/compiler.d.ts +33 -0
  617. package/dist/repairs/compiler.d.ts.map +1 -0
  618. package/dist/repairs/promote.d.ts +4 -0
  619. package/dist/repairs/promote.d.ts.map +1 -0
  620. package/dist/repairs/store.d.ts +10 -0
  621. package/dist/repairs/store.d.ts.map +1 -0
  622. package/dist/repairs/types.d.ts +49 -0
  623. package/dist/repairs/types.d.ts.map +1 -0
  624. package/dist/repeat-guard.d.ts +25 -0
  625. package/dist/repeat-guard.d.ts.map +1 -0
  626. package/dist/residency/actor-client.d.ts +16 -0
  627. package/dist/residency/actor-client.d.ts.map +1 -0
  628. package/dist/residency/actor-client.js +9 -0
  629. package/dist/residency/actor-client.js.map +7 -0
  630. package/dist/residency/client.d.ts +44 -0
  631. package/dist/residency/client.d.ts.map +1 -0
  632. package/dist/residency/host.d.ts +3 -0
  633. package/dist/residency/host.d.ts.map +1 -0
  634. package/dist/residency/host.js +32 -0
  635. package/dist/residency/host.js.map +7 -0
  636. package/dist/residency/launcher-owner.d.ts +7 -0
  637. package/dist/residency/launcher-owner.d.ts.map +1 -0
  638. package/dist/residency/launcher.d.ts +3 -0
  639. package/dist/residency/launcher.d.ts.map +1 -0
  640. package/dist/residency/launcher.js +154 -0
  641. package/dist/residency/launcher.js.map +7 -0
  642. package/dist/residency/pi-entry.d.ts +3 -0
  643. package/dist/residency/pi-entry.d.ts.map +1 -0
  644. package/dist/residency/pi-entry.js +48 -0
  645. package/dist/residency/pi-entry.js.map +7 -0
  646. package/dist/residency/protocol.d.ts +122 -0
  647. package/dist/residency/protocol.d.ts.map +1 -0
  648. package/dist/run-display.d.ts +3 -0
  649. package/dist/run-display.d.ts.map +1 -0
  650. package/dist/runtime/core-override-guest-types.d.ts +15 -0
  651. package/dist/runtime/core-override-guest-types.d.ts.map +1 -0
  652. package/dist/runtime/core-override-guest-types.js +9 -0
  653. package/dist/runtime/core-override-guest-types.js.map +7 -0
  654. package/dist/runtime/core-tool-properties.d.ts +6 -0
  655. package/dist/runtime/core-tool-properties.d.ts.map +1 -0
  656. package/dist/runtime/cpython-child-source.d.ts +2 -0
  657. package/dist/runtime/cpython-child-source.d.ts.map +1 -0
  658. package/dist/runtime/cpython-linux-sandbox.d.ts +2 -0
  659. package/dist/runtime/cpython-linux-sandbox.d.ts.map +1 -0
  660. package/dist/runtime/cpython-runtime.d.ts +9 -0
  661. package/dist/runtime/cpython-runtime.d.ts.map +1 -0
  662. package/dist/runtime/cpython-runtime.js +677 -0
  663. package/dist/runtime/cpython-runtime.js.map +7 -0
  664. package/dist/runtime/dynamic-guest-types.d.ts +3 -0
  665. package/dist/runtime/dynamic-guest-types.d.ts.map +1 -0
  666. package/dist/runtime/dynamic-guest-types.js +8 -0
  667. package/dist/runtime/dynamic-guest-types.js.map +7 -0
  668. package/dist/runtime/guest-code-repair.d.ts +2 -0
  669. package/dist/runtime/guest-code-repair.d.ts.map +1 -0
  670. package/dist/runtime/guest-stack-map.d.ts +11 -0
  671. package/dist/runtime/guest-stack-map.d.ts.map +1 -0
  672. package/dist/runtime/guest-types.d.ts +40 -0
  673. package/dist/runtime/guest-types.d.ts.map +1 -0
  674. package/dist/runtime/guest-types.js +13 -0
  675. package/dist/runtime/guest-types.js.map +7 -0
  676. package/dist/runtime/kernel.d.ts +30 -0
  677. package/dist/runtime/kernel.d.ts.map +1 -0
  678. package/dist/runtime/monty-bridge.d.ts +4 -0
  679. package/dist/runtime/monty-bridge.d.ts.map +1 -0
  680. package/dist/runtime/monty-runtime.d.ts +6 -0
  681. package/dist/runtime/monty-runtime.d.ts.map +1 -0
  682. package/dist/runtime/monty-runtime.js +485 -0
  683. package/dist/runtime/monty-runtime.js.map +7 -0
  684. package/dist/runtime/monty-source.d.ts +10 -0
  685. package/dist/runtime/monty-source.d.ts.map +1 -0
  686. package/dist/runtime/monty-values.d.ts +7 -0
  687. package/dist/runtime/monty-values.d.ts.map +1 -0
  688. package/dist/runtime/node-process-child-source.d.ts +2 -0
  689. package/dist/runtime/node-process-child-source.d.ts.map +1 -0
  690. package/dist/runtime/node-process-runtime.d.ts +10 -0
  691. package/dist/runtime/node-process-runtime.d.ts.map +1 -0
  692. package/dist/runtime/node-process-runtime.js +16 -0
  693. package/dist/runtime/node-process-runtime.js.map +7 -0
  694. package/dist/runtime/orchestration.d.ts +3 -0
  695. package/dist/runtime/orchestration.d.ts.map +1 -0
  696. package/dist/runtime/python-arguments.d.ts +2 -0
  697. package/dist/runtime/python-arguments.d.ts.map +1 -0
  698. package/dist/runtime/python-error-guidance.d.ts +6 -0
  699. package/dist/runtime/python-error-guidance.d.ts.map +1 -0
  700. package/dist/runtime/quickjs-runtime.d.ts +8 -0
  701. package/dist/runtime/quickjs-runtime.d.ts.map +1 -0
  702. package/dist/runtime/quickjs-runtime.js +15 -0
  703. package/dist/runtime/quickjs-runtime.js.map +7 -0
  704. package/dist/runtime/type-checker.d.ts +18 -0
  705. package/dist/runtime/type-checker.d.ts.map +1 -0
  706. package/dist/runtime/type-checker.js +11 -0
  707. package/dist/runtime/type-checker.js.map +7 -0
  708. package/dist/runtime/typescript-kernel.d.ts +14 -0
  709. package/dist/runtime/typescript-kernel.d.ts.map +1 -0
  710. package/dist/runtime/typescript-kernel.js +53 -0
  711. package/dist/runtime/typescript-kernel.js.map +7 -0
  712. package/dist/runtime-paths.d.ts +7 -0
  713. package/dist/runtime-paths.d.ts.map +1 -0
  714. package/dist/runtime-state-builtins.d.ts +26 -0
  715. package/dist/runtime-state-builtins.d.ts.map +1 -0
  716. package/dist/runtime-state-speculation.d.ts +16 -0
  717. package/dist/runtime-state-speculation.d.ts.map +1 -0
  718. package/dist/schema/controller.d.ts +35 -0
  719. package/dist/schema/controller.d.ts.map +1 -0
  720. package/dist/schema/policy.d.ts +2 -0
  721. package/dist/schema/policy.d.ts.map +1 -0
  722. package/dist/schema/types.d.ts +86 -0
  723. package/dist/schema/types.d.ts.map +1 -0
  724. package/dist/schema/workspace.d.ts +19 -0
  725. package/dist/schema/workspace.d.ts.map +1 -0
  726. package/dist/speculation/eligibility.d.ts +22 -0
  727. package/dist/speculation/eligibility.d.ts.map +1 -0
  728. package/dist/speculation/freshness.d.ts +10 -0
  729. package/dist/speculation/freshness.d.ts.map +1 -0
  730. package/dist/speculation/partial-json.d.ts +9 -0
  731. package/dist/speculation/partial-json.d.ts.map +1 -0
  732. package/dist/speculation/python-scanner.d.ts +7 -0
  733. package/dist/speculation/python-scanner.d.ts.map +1 -0
  734. package/dist/speculation/python-scanner.js +166 -0
  735. package/dist/speculation/python-scanner.js.map +7 -0
  736. package/dist/speculation/scanner.d.ts +13 -0
  737. package/dist/speculation/scanner.d.ts.map +1 -0
  738. package/dist/speculation/scanner.js +182 -0
  739. package/dist/speculation/scanner.js.map +7 -0
  740. package/dist/speculation/store.d.ts +41 -0
  741. package/dist/speculation/store.d.ts.map +1 -0
  742. package/dist/speculation/stream-tap.d.ts +30 -0
  743. package/dist/speculation/stream-tap.d.ts.map +1 -0
  744. package/dist/speculation/types.d.ts +44 -0
  745. package/dist/speculation/types.d.ts.map +1 -0
  746. package/dist/state/complexity.d.ts +13 -0
  747. package/dist/state/complexity.d.ts.map +1 -0
  748. package/dist/state/evidence-runner.d.ts +17 -0
  749. package/dist/state/evidence-runner.d.ts.map +1 -0
  750. package/dist/state/store.d.ts +76 -0
  751. package/dist/state/store.d.ts.map +1 -0
  752. package/dist/state/types.d.ts +165 -0
  753. package/dist/state/types.d.ts.map +1 -0
  754. package/dist/storage/retention.d.ts +22 -0
  755. package/dist/storage/retention.d.ts.map +1 -0
  756. package/dist/thinking.d.ts +19 -0
  757. package/dist/thinking.d.ts.map +1 -0
  758. package/dist/topology/control-plane.d.ts +58 -0
  759. package/dist/topology/control-plane.d.ts.map +1 -0
  760. package/dist/topology/participant-directory.d.ts +33 -0
  761. package/dist/topology/participant-directory.d.ts.map +1 -0
  762. package/dist/topology/peer-settle.d.ts +51 -0
  763. package/dist/topology/peer-settle.d.ts.map +1 -0
  764. package/dist/topology/records.d.ts +6 -0
  765. package/dist/topology/records.d.ts.map +1 -0
  766. package/dist/topology/types.d.ts +89 -0
  767. package/dist/topology/types.d.ts.map +1 -0
  768. package/dist/type-error-guidance.d.ts +3 -0
  769. package/dist/type-error-guidance.d.ts.map +1 -0
  770. package/dist/ui/arc-group.d.ts +17 -0
  771. package/dist/ui/arc-group.d.ts.map +1 -0
  772. package/dist/ui/border-status-editor.d.ts +22 -0
  773. package/dist/ui/border-status-editor.d.ts.map +1 -0
  774. package/dist/ui/code-preview-shell.d.ts +11 -0
  775. package/dist/ui/code-preview-shell.d.ts.map +1 -0
  776. package/dist/ui/code-preview.d.ts +53 -0
  777. package/dist/ui/code-preview.d.ts.map +1 -0
  778. package/dist/ui/controller.d.ts +20 -0
  779. package/dist/ui/controller.d.ts.map +1 -0
  780. package/dist/ui/conversation-chrome.d.ts +16 -0
  781. package/dist/ui/conversation-chrome.d.ts.map +1 -0
  782. package/dist/ui/conversation-chrome.js +11 -0
  783. package/dist/ui/conversation-chrome.js.map +7 -0
  784. package/dist/ui/conversation-commands.d.ts +12 -0
  785. package/dist/ui/conversation-commands.d.ts.map +1 -0
  786. package/dist/ui/conversation-history.d.ts +6 -0
  787. package/dist/ui/conversation-history.d.ts.map +1 -0
  788. package/dist/ui/conversation-host.d.ts +7 -0
  789. package/dist/ui/conversation-host.d.ts.map +1 -0
  790. package/dist/ui/conversation-host.js +9 -0
  791. package/dist/ui/conversation-host.js.map +7 -0
  792. package/dist/ui/conversation-native-reader-checkpoint.d.ts +8 -0
  793. package/dist/ui/conversation-native-reader-checkpoint.d.ts.map +1 -0
  794. package/dist/ui/conversation-native-reader-replay.d.ts +10 -0
  795. package/dist/ui/conversation-native-reader-replay.d.ts.map +1 -0
  796. package/dist/ui/conversation-native-reader.d.ts +110 -0
  797. package/dist/ui/conversation-native-reader.d.ts.map +1 -0
  798. package/dist/ui/conversation-native-reader.js +1050 -0
  799. package/dist/ui/conversation-native-reader.js.map +7 -0
  800. package/dist/ui/conversation-queue-store.d.ts +14 -0
  801. package/dist/ui/conversation-queue-store.d.ts.map +1 -0
  802. package/dist/ui/conversation-queue.d.ts +244 -0
  803. package/dist/ui/conversation-queue.d.ts.map +1 -0
  804. package/dist/ui/conversation-render.d.ts +104 -0
  805. package/dist/ui/conversation-render.d.ts.map +1 -0
  806. package/dist/ui/conversation-selection.d.ts +18 -0
  807. package/dist/ui/conversation-selection.d.ts.map +1 -0
  808. package/dist/ui/conversation-shortcut.d.ts +3 -0
  809. package/dist/ui/conversation-shortcut.d.ts.map +1 -0
  810. package/dist/ui/conversation-targets.d.ts +7 -0
  811. package/dist/ui/conversation-targets.d.ts.map +1 -0
  812. package/dist/ui/conversation-targets.js +12 -0
  813. package/dist/ui/conversation-targets.js.map +7 -0
  814. package/dist/ui/conversation-transcript.d.ts +25 -0
  815. package/dist/ui/conversation-transcript.d.ts.map +1 -0
  816. package/dist/ui/conversation.d.ts +219 -0
  817. package/dist/ui/conversation.d.ts.map +1 -0
  818. package/dist/ui/conversation.js +2861 -0
  819. package/dist/ui/conversation.js.map +7 -0
  820. package/dist/ui/core-tool-render.d.ts +20 -0
  821. package/dist/ui/core-tool-render.d.ts.map +1 -0
  822. package/dist/ui/dashboard-detail.d.ts +68 -0
  823. package/dist/ui/dashboard-detail.d.ts.map +1 -0
  824. package/dist/ui/dashboard-fabric-graph.d.ts +50 -0
  825. package/dist/ui/dashboard-fabric-graph.d.ts.map +1 -0
  826. package/dist/ui/dashboard-graph-controller.d.ts +52 -0
  827. package/dist/ui/dashboard-graph-controller.d.ts.map +1 -0
  828. package/dist/ui/dashboard-modal-controller.d.ts +36 -0
  829. package/dist/ui/dashboard-modal-controller.d.ts.map +1 -0
  830. package/dist/ui/dashboard-model.d.ts +111 -0
  831. package/dist/ui/dashboard-model.d.ts.map +1 -0
  832. package/dist/ui/dashboard-presentation.d.ts +6 -0
  833. package/dist/ui/dashboard-presentation.d.ts.map +1 -0
  834. package/dist/ui/dashboard.d.ts +156 -0
  835. package/dist/ui/dashboard.d.ts.map +1 -0
  836. package/dist/ui/dashboard.js +4622 -0
  837. package/dist/ui/dashboard.js.map +7 -0
  838. package/dist/ui/diff-background.d.ts +12 -0
  839. package/dist/ui/diff-background.d.ts.map +1 -0
  840. package/dist/ui/dynamic-border.d.ts +8 -0
  841. package/dist/ui/dynamic-border.d.ts.map +1 -0
  842. package/dist/ui/escape-halt.d.ts +11 -0
  843. package/dist/ui/escape-halt.d.ts.map +1 -0
  844. package/dist/ui/fabric-actor-delivery-selector.d.ts +17 -0
  845. package/dist/ui/fabric-actor-delivery-selector.d.ts.map +1 -0
  846. package/dist/ui/fabric-actor-tool-selector.d.ts +22 -0
  847. package/dist/ui/fabric-actor-tool-selector.d.ts.map +1 -0
  848. package/dist/ui/fabric-code-parser.d.ts +9 -0
  849. package/dist/ui/fabric-code-parser.d.ts.map +1 -0
  850. package/dist/ui/fabric-host-event-selector.d.ts +29 -0
  851. package/dist/ui/fabric-host-event-selector.d.ts.map +1 -0
  852. package/dist/ui/fabric-model-selector.d.ts +64 -0
  853. package/dist/ui/fabric-model-selector.d.ts.map +1 -0
  854. package/dist/ui/fabric-render.d.ts +113 -0
  855. package/dist/ui/fabric-render.d.ts.map +1 -0
  856. package/dist/ui/fabric-thinking-selector.d.ts +26 -0
  857. package/dist/ui/fabric-thinking-selector.d.ts.map +1 -0
  858. package/dist/ui/fabric-title-hint.d.ts +3 -0
  859. package/dist/ui/fabric-title-hint.d.ts.map +1 -0
  860. package/dist/ui/format.d.ts +9 -0
  861. package/dist/ui/format.d.ts.map +1 -0
  862. package/dist/ui/handoff-completion.d.ts +3 -0
  863. package/dist/ui/handoff-completion.d.ts.map +1 -0
  864. package/dist/ui/highlight.d.ts +69 -0
  865. package/dist/ui/highlight.d.ts.map +1 -0
  866. package/dist/ui/model-picker.d.ts +46 -0
  867. package/dist/ui/model-picker.d.ts.map +1 -0
  868. package/dist/ui/model-picker.js +17 -0
  869. package/dist/ui/model-picker.js.map +7 -0
  870. package/dist/ui/preview-lines.d.ts +16 -0
  871. package/dist/ui/preview-lines.d.ts.map +1 -0
  872. package/dist/ui/row-balance.d.ts +29 -0
  873. package/dist/ui/row-balance.d.ts.map +1 -0
  874. package/dist/ui/settings-component.d.ts +26 -0
  875. package/dist/ui/settings-component.d.ts.map +1 -0
  876. package/dist/ui/settings-rpc.d.ts +15 -0
  877. package/dist/ui/settings-rpc.d.ts.map +1 -0
  878. package/dist/ui/settings-section-context.d.ts +18 -0
  879. package/dist/ui/settings-section-context.d.ts.map +1 -0
  880. package/dist/ui/settings-sections-agents.d.ts +5 -0
  881. package/dist/ui/settings-sections-agents.d.ts.map +1 -0
  882. package/dist/ui/settings-sections-execution.d.ts +8 -0
  883. package/dist/ui/settings-sections-execution.d.ts.map +1 -0
  884. package/dist/ui/settings-sections-lifecycle.d.ts +6 -0
  885. package/dist/ui/settings-sections-lifecycle.d.ts.map +1 -0
  886. package/dist/ui/settings-sections-presentation.d.ts +6 -0
  887. package/dist/ui/settings-sections-presentation.d.ts.map +1 -0
  888. package/dist/ui/settings-sections.d.ts +12 -0
  889. package/dist/ui/settings-sections.d.ts.map +1 -0
  890. package/dist/ui/settings-submenus.d.ts +74 -0
  891. package/dist/ui/settings-submenus.d.ts.map +1 -0
  892. package/dist/ui/settings-values.d.ts +63 -0
  893. package/dist/ui/settings-values.d.ts.map +1 -0
  894. package/dist/ui/settings.d.ts +21 -0
  895. package/dist/ui/settings.d.ts.map +1 -0
  896. package/dist/ui/settings.js +1985 -0
  897. package/dist/ui/settings.js.map +7 -0
  898. package/dist/ui/shell-hang-keys.d.ts +11 -0
  899. package/dist/ui/shell-hang-keys.d.ts.map +1 -0
  900. package/dist/ui/shiki-language.d.ts +7 -0
  901. package/dist/ui/shiki-language.d.ts.map +1 -0
  902. package/dist/ui/shiki-theme.d.ts +7 -0
  903. package/dist/ui/shiki-theme.d.ts.map +1 -0
  904. package/dist/ui/snapshot.d.ts +17 -0
  905. package/dist/ui/snapshot.d.ts.map +1 -0
  906. package/dist/ui/spinner.d.ts +6 -0
  907. package/dist/ui/spinner.d.ts.map +1 -0
  908. package/dist/ui/state-file-preview.d.ts +13 -0
  909. package/dist/ui/state-file-preview.d.ts.map +1 -0
  910. package/dist/ui/structured.d.ts +9 -0
  911. package/dist/ui/structured.d.ts.map +1 -0
  912. package/dist/ui/tool-call-timing.d.ts +2 -0
  913. package/dist/ui/tool-call-timing.d.ts.map +1 -0
  914. package/dist/ui/tool-display.d.ts +8 -0
  915. package/dist/ui/tool-display.d.ts.map +1 -0
  916. package/dist/ui/topology.d.ts +162 -0
  917. package/dist/ui/topology.d.ts.map +1 -0
  918. package/dist/ui/transcript-parser.d.ts +18 -0
  919. package/dist/ui/transcript-parser.d.ts.map +1 -0
  920. package/dist/ui/transcript-reader.d.ts +10 -0
  921. package/dist/ui/transcript-reader.d.ts.map +1 -0
  922. package/dist/ui/transcript-sanitization.d.ts +14 -0
  923. package/dist/ui/transcript-sanitization.d.ts.map +1 -0
  924. package/dist/ui/transcript.d.ts +52 -0
  925. package/dist/ui/transcript.d.ts.map +1 -0
  926. package/dist/ui/types.d.ts +84 -0
  927. package/dist/ui/types.d.ts.map +1 -0
  928. package/dist/ui/widget.d.ts +16 -0
  929. package/dist/ui/widget.d.ts.map +1 -0
  930. package/dist/ui/word-diff/alignment.d.ts +6 -0
  931. package/dist/ui/word-diff/alignment.d.ts.map +1 -0
  932. package/dist/ui/word-diff/change-block.d.ts +18 -0
  933. package/dist/ui/word-diff/change-block.d.ts.map +1 -0
  934. package/dist/ui/word-diff/changed-line.d.ts +14 -0
  935. package/dist/ui/word-diff/changed-line.d.ts.map +1 -0
  936. package/dist/ui/word-diff/emphasis.d.ts +9 -0
  937. package/dist/ui/word-diff/emphasis.d.ts.map +1 -0
  938. package/dist/ui/word-diff/line-emphasis.d.ts +7 -0
  939. package/dist/ui/word-diff/line-emphasis.d.ts.map +1 -0
  940. package/dist/ui/word-diff/line-matching.d.ts +10 -0
  941. package/dist/ui/word-diff/line-matching.d.ts.map +1 -0
  942. package/dist/ui/word-diff/line-similarity.d.ts +16 -0
  943. package/dist/ui/word-diff/line-similarity.d.ts.map +1 -0
  944. package/dist/ui/word-diff/normalize.d.ts +3 -0
  945. package/dist/ui/word-diff/normalize.d.ts.map +1 -0
  946. package/dist/ui/word-diff/parse.d.ts +17 -0
  947. package/dist/ui/word-diff/parse.d.ts.map +1 -0
  948. package/dist/ui/word-diff/range-refinement.d.ts +5 -0
  949. package/dist/ui/word-diff/range-refinement.d.ts.map +1 -0
  950. package/dist/ui/word-diff/ranges.d.ts +11 -0
  951. package/dist/ui/word-diff/ranges.d.ts.map +1 -0
  952. package/dist/ui/word-diff/smart-filter.d.ts +3 -0
  953. package/dist/ui/word-diff/smart-filter.d.ts.map +1 -0
  954. package/dist/ui/word-diff/sparse-line-matching.d.ts +25 -0
  955. package/dist/ui/word-diff/sparse-line-matching.d.ts.map +1 -0
  956. package/dist/ui/word-diff/text-boundaries.d.ts +11 -0
  957. package/dist/ui/word-diff/text-boundaries.d.ts.map +1 -0
  958. package/dist/ui/word-diff/token-alignment.d.ts +9 -0
  959. package/dist/ui/word-diff/token-alignment.d.ts.map +1 -0
  960. package/dist/ui/word-diff/token-text-refinement.d.ts +4 -0
  961. package/dist/ui/word-diff/token-text-refinement.d.ts.map +1 -0
  962. package/dist/ui/word-diff/tokens.d.ts +16 -0
  963. package/dist/ui/word-diff/tokens.d.ts.map +1 -0
  964. package/dist/ui/word-diff/types.d.ts +10 -0
  965. package/dist/ui/word-diff/types.d.ts.map +1 -0
  966. package/dist/util.d.ts +3 -0
  967. package/dist/util.d.ts.map +1 -0
  968. package/dist/worker/model-control.d.ts +14 -0
  969. package/dist/worker/model-control.d.ts.map +1 -0
  970. package/dist/worker/model-control.js +118 -0
  971. package/dist/worker/model-control.js.map +7 -0
  972. package/dist/worker/options.d.ts +3 -0
  973. package/dist/worker/options.d.ts.map +1 -0
  974. package/dist/worker/options.js +156 -0
  975. package/dist/worker/options.js.map +7 -0
  976. package/dist/worker/run-record.d.ts +22 -0
  977. package/dist/worker/run-record.d.ts.map +1 -0
  978. package/dist/worker/run-record.js +124 -0
  979. package/dist/worker/run-record.js.map +7 -0
  980. package/dist/worker/session-export.d.ts +45 -0
  981. package/dist/worker/session-export.d.ts.map +1 -0
  982. package/dist/worker/session-export.js +91 -0
  983. package/dist/worker/session-export.js.map +7 -0
  984. package/dist/worker.d.ts +3 -0
  985. package/dist/worker.d.ts.map +1 -0
  986. package/dist/worker.js +1074 -0
  987. package/dist/worker.js.map +7 -0
  988. package/docs/agents.md +618 -0
  989. package/docs/architecture.md +141 -0
  990. package/docs/audit-trace.md +116 -0
  991. package/docs/certification.md +166 -0
  992. package/docs/compaction.md +345 -0
  993. package/docs/component-calculus.md +191 -0
  994. package/docs/components.md +330 -0
  995. package/docs/configuration.md +529 -0
  996. package/docs/entropy.md +214 -0
  997. package/docs/interface.md +210 -0
  998. package/docs/jev.md +289 -0
  999. package/docs/kernels.md +186 -0
  1000. package/docs/memory-recall.md +664 -0
  1001. package/docs/programmatic-compaction.md +205 -0
  1002. package/docs/provider-component-calculus.md +378 -0
  1003. package/docs/providers.md +163 -0
  1004. package/docs/repairs.md +90 -0
  1005. package/docs/residency-runtime.md +82 -0
  1006. package/docs/schema-enforcement.md +166 -0
  1007. package/docs/skills.md +50 -0
  1008. package/docs/speculation.md +171 -0
  1009. package/docs/state-layer.md +197 -0
  1010. package/package.json +135 -0
  1011. package/skillsets/python/fabric-advisor/SKILL.md +29 -0
  1012. package/skillsets/python/fabric-ambient/SKILL.md +44 -0
  1013. package/skillsets/python/fabric-ambient/references/setup.md +67 -0
  1014. package/skillsets/python/fabric-council/SKILL.md +54 -0
  1015. package/skillsets/python/fabric-exec/SKILL.md +74 -0
  1016. package/skillsets/python/fabric-exec/references/agents.md +65 -0
  1017. package/skillsets/python/fabric-exec/references/mcp.md +23 -0
  1018. package/skillsets/python/fabric-exec/references/mesh.md +27 -0
  1019. package/skillsets/python/fabric-fusion/SKILL.md +112 -0
  1020. package/skillsets/python/fabric-guide/SKILL.md +29 -0
  1021. package/skillsets/python/fabric-jev/SKILL.md +162 -0
  1022. package/skillsets/python/fabric-rlm/SKILL.md +120 -0
  1023. package/skillsets/python/fabric-schema/SKILL.md +55 -0
  1024. package/skillsets/python/fabric-spec/SKILL.md +42 -0
  1025. package/skillsets/python/fabric-supervisor/SKILL.md +37 -0
  1026. package/skillsets/python/fabric-swarm/SKILL.md +40 -0
  1027. package/skillsets/python/fabric-workflow/SKILL.md +62 -0
  1028. package/skillsets/typescript/fabric-advisor/SKILL.md +29 -0
  1029. package/skillsets/typescript/fabric-ambient/SKILL.md +44 -0
  1030. package/skillsets/typescript/fabric-ambient/references/setup.md +90 -0
  1031. package/skillsets/typescript/fabric-council/SKILL.md +94 -0
  1032. package/skillsets/typescript/fabric-exec/SKILL.md +142 -0
  1033. package/skillsets/typescript/fabric-exec/references/agents.md +218 -0
  1034. package/skillsets/typescript/fabric-exec/references/mcp.md +49 -0
  1035. package/skillsets/typescript/fabric-exec/references/mesh.md +51 -0
  1036. package/skillsets/typescript/fabric-fusion/SKILL.md +332 -0
  1037. package/skillsets/typescript/fabric-guide/SKILL.md +29 -0
  1038. package/skillsets/typescript/fabric-jev/SKILL.md +159 -0
  1039. package/skillsets/typescript/fabric-rlm/SKILL.md +284 -0
  1040. package/skillsets/typescript/fabric-schema/SKILL.md +121 -0
  1041. package/skillsets/typescript/fabric-spec/SKILL.md +42 -0
  1042. package/skillsets/typescript/fabric-supervisor/SKILL.md +37 -0
  1043. package/skillsets/typescript/fabric-swarm/SKILL.md +80 -0
  1044. package/skillsets/typescript/fabric-workflow/SKILL.md +133 -0
@@ -0,0 +1,1720 @@
1
+ import {
2
+ COMPILED_SURFACE_VERSION,
3
+ ENTROPY_INVOCATION_STAGES,
4
+ ENTROPY_METRIC_VERSION,
5
+ ENTROPY_WEIGHTS,
6
+ MAX_COMPILED_SURFACE_PROPOSALS,
7
+ emptyCompiledSurface,
8
+ withExclusiveFileLock,
9
+ withExclusiveFileLockAsync
10
+ } from "./chunk-3WIGAX56.js";
11
+ import {
12
+ sessionDirForCwd,
13
+ sessionsDirRoot
14
+ } from "./chunk-MGDLRV2R.js";
15
+ import {
16
+ writeJsonAtomic,
17
+ writeJsonAtomicAsync
18
+ } from "./chunk-KAD7UWT2.js";
19
+ import {
20
+ FABRIC_EXECUTION_TRACE_KIND,
21
+ readFabricExecutionTraceV1
22
+ } from "./chunk-D5WKZONW.js";
23
+ import {
24
+ MAX_NORMAL_FORM_PLANS,
25
+ applyNormalFormPlan,
26
+ compareCodeUnits,
27
+ deriveNormalFormPlan,
28
+ provesNormalFormPlan,
29
+ roundMetric,
30
+ shannonEntropyBits,
31
+ shapeSignature,
32
+ signatureDistance,
33
+ staticFreedomFromSchema,
34
+ trendFromScores
35
+ } from "./chunk-G4LADAYY.js";
36
+ import {
37
+ stableJsonHash
38
+ } from "./chunk-3YZUQESG.js";
39
+
40
+ // src/entropy/meter.ts
41
+ var DISCOVERY_PREFIX = "fabric.discovery.";
42
+ var WORKFLOW_PREFIX = "fabric.workflow.";
43
+ var DEFAULT_TASK_KEY = "(none)";
44
+ var TOP_SIGNATURES = 8;
45
+ var createMeasureState = (input) => {
46
+ const surfaceByRef = /* @__PURE__ */ new Map();
47
+ if (input.surface) {
48
+ for (const action of input.surface.actions) surfaceByRef.set(action.ref, action.inputSchema);
49
+ }
50
+ const lexiconByRef = /* @__PURE__ */ new Map();
51
+ let lexiconRows = 0;
52
+ for (const row of input.repairs ?? []) {
53
+ lexiconByRef.set(row.ref, (lexiconByRef.get(row.ref) ?? 0) + 1);
54
+ lexiconRows += 1;
55
+ }
56
+ return {
57
+ surfaceByRef,
58
+ lexiconByRef,
59
+ lexiconRows,
60
+ totals: {
61
+ traces: input.traces.length,
62
+ operations: 0,
63
+ actionOperations: 0,
64
+ discoveryOperations: 0,
65
+ workflowOperations: 0,
66
+ succeeded: 0,
67
+ failed: 0,
68
+ aborted: 0,
69
+ timedOut: 0,
70
+ invocationRejections: 0,
71
+ invocationRejectionsPer1k: 0
72
+ },
73
+ refs: /* @__PURE__ */ new Map(),
74
+ taskSequences: /* @__PURE__ */ new Map(),
75
+ churnPairs: 0,
76
+ churnSum: 0
77
+ };
78
+ };
79
+ var accumulatorFor = (state, ref) => {
80
+ const existing = state.refs.get(ref);
81
+ if (existing) return existing;
82
+ const created = {
83
+ calls: 0,
84
+ succeeded: 0,
85
+ failed: 0,
86
+ signatures: /* @__PURE__ */ new Map(),
87
+ stages: /* @__PURE__ */ new Map(),
88
+ churnPairs: 0,
89
+ churnSum: 0
90
+ };
91
+ state.refs.set(ref, created);
92
+ return created;
93
+ };
94
+ var accumulateTrace = (state, sourceTrace) => {
95
+ const taskKey = sourceTrace.taskKey ?? DEFAULT_TASK_KEY;
96
+ const sequence = [];
97
+ const pendingFailed = /* @__PURE__ */ new Map();
98
+ for (const operation of sourceTrace.operations) {
99
+ state.totals.operations += 1;
100
+ if (operation.ref.startsWith(DISCOVERY_PREFIX)) {
101
+ state.totals.discoveryOperations += 1;
102
+ continue;
103
+ }
104
+ if (operation.ref.startsWith(WORKFLOW_PREFIX)) {
105
+ state.totals.workflowOperations += 1;
106
+ continue;
107
+ }
108
+ state.totals.actionOperations += 1;
109
+ sequence.push(operation.ref);
110
+ const acc = accumulatorFor(state, operation.ref);
111
+ acc.calls += 1;
112
+ if (operation.outcome === "succeeded") {
113
+ state.totals.succeeded += 1;
114
+ acc.succeeded += 1;
115
+ } else if (operation.outcome === "failed") {
116
+ state.totals.failed += 1;
117
+ acc.failed += 1;
118
+ } else if (operation.outcome === "aborted") {
119
+ state.totals.aborted += 1;
120
+ } else {
121
+ state.totals.timedOut += 1;
122
+ }
123
+ const signature = shapeSignature(operation.args);
124
+ acc.signatures.set(signature, (acc.signatures.get(signature) ?? 0) + 1);
125
+ if (operation.outcome === "failed") {
126
+ const stage = operation.failureStage ?? "unknown";
127
+ acc.stages.set(stage, (acc.stages.get(stage) ?? 0) + 1);
128
+ if (ENTROPY_INVOCATION_STAGES.includes(stage)) state.totals.invocationRejections += 1;
129
+ }
130
+ const pending = pendingFailed.get(operation.ref);
131
+ if (pending !== void 0) {
132
+ const distance = signatureDistance(pending, signature);
133
+ acc.churnPairs += 1;
134
+ acc.churnSum += distance;
135
+ state.churnPairs += 1;
136
+ state.churnSum += distance;
137
+ pendingFailed.delete(operation.ref);
138
+ }
139
+ if (operation.outcome === "failed") pendingFailed.set(operation.ref, signature);
140
+ }
141
+ if (sequence.length > 0) {
142
+ const key = sequence.join("\u2192");
143
+ const perTask = state.taskSequences.get(taskKey) ?? /* @__PURE__ */ new Map();
144
+ perTask.set(key, (perTask.get(key) ?? 0) + 1);
145
+ state.taskSequences.set(taskKey, perTask);
146
+ }
147
+ };
148
+ var finalizeMeasure = (input, state) => {
149
+ const refEntries = [...state.refs.entries()].sort(
150
+ ([left], [right]) => compareCodeUnits(left, right)
151
+ );
152
+ const refReports = [];
153
+ let staticFreedomTotal = 0;
154
+ let staticWeighted = 0;
155
+ let shapeWeighted = 0;
156
+ let failureStageWeighted = 0;
157
+ for (const [ref, acc] of refEntries) {
158
+ const shapeEntropyBits = shannonEntropyBits([...acc.signatures.values()]);
159
+ const failureStageEntropyBits = shannonEntropyBits([...acc.stages.values()]);
160
+ const refChurnRate = acc.churnPairs > 0 ? roundMetric(acc.churnSum / acc.churnPairs) : 0;
161
+ const lexicon = state.lexiconByRef.get(ref) ?? 0;
162
+ const staticFreedom = state.surfaceByRef.has(ref) ? staticFreedomFromSchema(state.surfaceByRef.get(ref)) : 0;
163
+ staticFreedomTotal += staticFreedom;
164
+ staticWeighted += ENTROPY_WEIGHTS.staticFreedom * staticFreedom * acc.calls;
165
+ shapeWeighted += shapeEntropyBits * acc.calls;
166
+ failureStageWeighted += failureStageEntropyBits * acc.failed;
167
+ const invocationRejections = ENTROPY_INVOCATION_STAGES.reduce(
168
+ (sum, stage) => sum + (acc.stages.get(stage) ?? 0),
169
+ 0
170
+ );
171
+ const score2 = roundMetric(invocationRejections / acc.calls);
172
+ const shapeSignatures = [...acc.signatures.entries()].map(([signature, count]) => ({ signature, count })).sort(
173
+ (left, right) => right.count - left.count || compareCodeUnits(left.signature, right.signature)
174
+ ).slice(0, TOP_SIGNATURES);
175
+ refReports.push({
176
+ ref,
177
+ calls: acc.calls,
178
+ succeeded: acc.succeeded,
179
+ failed: acc.failed,
180
+ shapeSignatures,
181
+ shapeEntropyBits,
182
+ failureStageEntropyBits,
183
+ churnRate: refChurnRate,
184
+ lexiconRows: lexicon,
185
+ staticFreedom,
186
+ score: score2
187
+ });
188
+ }
189
+ const navigationRatio = state.totals.actionOperations > 0 ? roundMetric(state.totals.discoveryOperations / state.totals.actionOperations) : 0;
190
+ let flowWeighted = 0;
191
+ let flowOccurrences = 0;
192
+ for (const perTask of state.taskSequences.values()) {
193
+ const counts = [...perTask.values()];
194
+ const occurrences = counts.reduce((sum, value) => sum + value, 0);
195
+ flowWeighted += shannonEntropyBits(counts) * occurrences;
196
+ flowOccurrences += occurrences;
197
+ }
198
+ const flowEntropyBits = flowOccurrences > 0 ? roundMetric(flowWeighted / flowOccurrences) : 0;
199
+ state.totals.invocationRejectionsPer1k = state.totals.actionOperations > 0 ? roundMetric(state.totals.invocationRejections / state.totals.actionOperations * 1e3) : 0;
200
+ const score = state.totals.actionOperations > 0 ? roundMetric(state.totals.invocationRejections / state.totals.actionOperations) : 0;
201
+ const staticScore = state.totals.actionOperations > 0 ? roundMetric(staticWeighted / state.totals.actionOperations) : 0;
202
+ const behavioralScore = score;
203
+ const sortedRefs = [...refReports].sort(
204
+ (left, right) => right.score - left.score || compareCodeUnits(left.ref, right.ref)
205
+ );
206
+ return {
207
+ metricVersion: ENTROPY_METRIC_VERSION,
208
+ catalogDigest: input.catalogDigest ?? "",
209
+ totals: state.totals,
210
+ shapeEntropyBits: state.totals.actionOperations > 0 ? roundMetric(shapeWeighted / state.totals.actionOperations) : 0,
211
+ failureStageEntropyBits: state.totals.failed > 0 ? roundMetric(failureStageWeighted / state.totals.failed) : 0,
212
+ churnRate: state.churnPairs > 0 ? roundMetric(state.churnSum / state.churnPairs) : 0,
213
+ navigationRatio,
214
+ flowEntropyBits,
215
+ lexiconRows: state.lexiconRows,
216
+ staticFreedom: roundMetric(staticFreedomTotal),
217
+ staticScore,
218
+ behavioralScore,
219
+ score,
220
+ refs: sortedRefs
221
+ };
222
+ };
223
+ var measureOnce = (input) => {
224
+ const state = createMeasureState(input);
225
+ for (const trace of input.traces) accumulateTrace(state, trace);
226
+ return finalizeMeasure(input, state);
227
+ };
228
+ var measureEntropy = (input) => {
229
+ const report = measureOnce(input);
230
+ const groups = /* @__PURE__ */ new Map();
231
+ for (const sourceTrace of input.traces) {
232
+ if (!sourceTrace.model) continue;
233
+ const group = groups.get(sourceTrace.model) ?? [];
234
+ group.push(sourceTrace);
235
+ groups.set(sourceTrace.model, group);
236
+ }
237
+ const byModel = [...groups.entries()].sort(([left], [right]) => compareCodeUnits(left, right)).map(([model, traces]) => {
238
+ const scoped = measureOnce({ ...input, traces });
239
+ return {
240
+ model,
241
+ operations: scoped.totals.operations,
242
+ actionOperations: scoped.totals.actionOperations,
243
+ succeeded: scoped.totals.succeeded,
244
+ invocationRejections: scoped.totals.invocationRejections,
245
+ invocationRejectionsPer1k: scoped.totals.invocationRejectionsPer1k,
246
+ behavioralScore: scoped.behavioralScore
247
+ };
248
+ });
249
+ return { ...report, byModel };
250
+ };
251
+ var yieldToLoop = () => new Promise((resolve) => setImmediate(resolve));
252
+ var COOPERATIVE_TRACE_CHUNK = 64;
253
+ var measureOnceAsync = async (input) => {
254
+ const state = createMeasureState(input);
255
+ await yieldToLoop();
256
+ for (let index = 0; index < input.traces.length; index += 1) {
257
+ accumulateTrace(state, input.traces[index]);
258
+ if ((index + 1) % COOPERATIVE_TRACE_CHUNK === 0) await yieldToLoop();
259
+ }
260
+ return finalizeMeasure(input, state);
261
+ };
262
+ var measureEntropyAsync = async (input) => {
263
+ const report = await measureOnceAsync(input);
264
+ const groups = /* @__PURE__ */ new Map();
265
+ for (const sourceTrace of input.traces) {
266
+ if (!sourceTrace.model) continue;
267
+ const group = groups.get(sourceTrace.model) ?? [];
268
+ group.push(sourceTrace);
269
+ groups.set(sourceTrace.model, group);
270
+ }
271
+ const byModel = [];
272
+ for (const [model, traces] of [...groups.entries()].sort(
273
+ ([left], [right]) => compareCodeUnits(left, right)
274
+ )) {
275
+ const scoped = await measureOnceAsync({ ...input, traces });
276
+ byModel.push({
277
+ model,
278
+ operations: scoped.totals.operations,
279
+ actionOperations: scoped.totals.actionOperations,
280
+ succeeded: scoped.totals.succeeded,
281
+ invocationRejections: scoped.totals.invocationRejections,
282
+ invocationRejectionsPer1k: scoped.totals.invocationRejectionsPer1k,
283
+ behavioralScore: scoped.behavioralScore
284
+ });
285
+ }
286
+ return { ...report, byModel };
287
+ };
288
+
289
+ // src/entropy/passes.ts
290
+ var ENUM_MIN_OBSERVATIONS = 8;
291
+ var ENUM_MAX_DISTINCT = 8;
292
+ var ENUM_MIN_TOP_SHARE = 0.5;
293
+ var SPLIT_MIN_SHAPE_ENTROPY_BITS = 1;
294
+ var SPLIT_MIN_CLUSTER_CALLS = 2;
295
+ var FUSE_MIN_SEQUENCE_LENGTH = 3;
296
+ var FUSE_MAX_SEQUENCE_LENGTH = 6;
297
+ var FUSE_MIN_OCCURRENCES = 3;
298
+ var FUSE_MIN_EXECUTIONS = 3;
299
+ var MAX_PROPOSALS_PER_KIND = 8;
300
+ var ENTROPY_ENUM_CANDIDATE_ANNOTATION = "x-fabric-enum-candidate";
301
+ var isPlainRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
302
+ var valueKey = (value) => `${typeof value}:${String(value)}`;
303
+ var schemaProperties = (schema) => {
304
+ if (!isPlainRecord(schema)) return void 0;
305
+ const properties = schema.properties;
306
+ return isPlainRecord(properties) ? properties : void 0;
307
+ };
308
+ var contains = (outer, inner) => {
309
+ if (outer.length < inner.length) return false;
310
+ for (let start = 0; start + inner.length <= outer.length; start++) {
311
+ let matches = true;
312
+ for (let index = 0; index < inner.length; index++) {
313
+ if (outer[start + index] !== inner[index]) {
314
+ matches = false;
315
+ break;
316
+ }
317
+ }
318
+ if (matches) return true;
319
+ }
320
+ return false;
321
+ };
322
+ var proposeEntropyReductions = (input) => {
323
+ const calledRefs = /* @__PURE__ */ new Map();
324
+ for (const ref of input.report.refs) calledRefs.set(ref.ref, ref);
325
+ const surfaceByRef = /* @__PURE__ */ new Map();
326
+ if (input.surface) {
327
+ for (const action of input.surface.actions) {
328
+ surfaceByRef.set(action.ref, action.inputSchema);
329
+ }
330
+ }
331
+ const proposals = [];
332
+ for (const action of [...input.surface?.actions ?? []].sort((a, b) => compareCodeUnits(a.ref, b.ref)).slice(0, MAX_NORMAL_FORM_PLANS)) {
333
+ const plan = deriveNormalFormPlan(action.ref, action.inputSchema);
334
+ if (plan) proposals.push({ kind: "normal-form", ref: plan.ref, baseSchemaDigest: plan.baseSchemaDigest, rules: plan.rules });
335
+ }
336
+ const observations = /* @__PURE__ */ new Map();
337
+ const observeValue = (ref, key, value, weight = 1) => {
338
+ const id = `${ref}\0${key}`;
339
+ const entry = observations.get(id) ?? {
340
+ ref,
341
+ key,
342
+ counts: /* @__PURE__ */ new Map(),
343
+ total: 0
344
+ };
345
+ const valueId = valueKey(value);
346
+ const existing = entry.counts.get(valueId);
347
+ entry.counts.set(valueId, { value, count: (existing?.count ?? 0) + weight });
348
+ entry.total += weight;
349
+ observations.set(id, entry);
350
+ };
351
+ if (input.valueObservations) {
352
+ for (const observation of input.valueObservations) {
353
+ observeValue(observation.ref, observation.key, observation.value, observation.count ?? 1);
354
+ }
355
+ } else {
356
+ for (const sourceTrace of input.traces) {
357
+ for (const operation of sourceTrace.operations) {
358
+ if (operation.ref.startsWith("fabric.")) continue;
359
+ for (const [key, value] of Object.entries(operation.args)) {
360
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
361
+ continue;
362
+ }
363
+ observeValue(operation.ref, key, value);
364
+ }
365
+ }
366
+ }
367
+ }
368
+ const eligibleCandidates = [...observations.values()].filter((entry) => entry.total >= ENUM_MIN_OBSERVATIONS).filter((entry) => entry.counts.size >= 2 && entry.counts.size <= ENUM_MAX_DISTINCT).map((entry) => {
369
+ const ranked = [...entry.counts.values()].sort(
370
+ (left, right) => right.count - left.count || compareCodeUnits(valueKey(left.value), valueKey(right.value))
371
+ );
372
+ return { entry, ranked, topShare: roundMetric(ranked[0].count / entry.total) };
373
+ }).filter((candidate) => candidate.topShare >= ENUM_MIN_TOP_SHARE);
374
+ const openCandidates = eligibleCandidates.filter((candidate) => {
375
+ const target = schemaProperties(surfaceByRef.get(candidate.entry.ref))?.[candidate.entry.key];
376
+ return isPlainRecord(target) && target.type !== "boolean" && !Array.isArray(target.enum) && target[ENTROPY_ENUM_CANDIDATE_ANNOTATION] === true;
377
+ });
378
+ const byRefKey = (left, right) => compareCodeUnits(`${left.entry.ref}\0${left.entry.key}`, `${right.entry.ref}\0${right.entry.key}`);
379
+ for (const candidate of openCandidates.sort(byRefKey).slice(0, MAX_PROPOSALS_PER_KIND)) {
380
+ proposals.push({
381
+ kind: "declare-enum",
382
+ ref: candidate.entry.ref,
383
+ key: candidate.entry.key,
384
+ values: candidate.ranked.map((item) => item.value),
385
+ calls: candidate.entry.total,
386
+ distinct: candidate.entry.counts.size,
387
+ topShare: candidate.topShare
388
+ });
389
+ }
390
+ const overloadRefs = new Set(
391
+ input.report.refs.filter((ref) => ref.shapeEntropyBits >= SPLIT_MIN_SHAPE_ENTROPY_BITS).map((ref) => ref.ref)
392
+ );
393
+ if (overloadRefs.size > 0) {
394
+ const keySets = /* @__PURE__ */ new Map();
395
+ for (const sourceTrace of input.traces) {
396
+ for (const operation of sourceTrace.operations) {
397
+ if (!overloadRefs.has(operation.ref)) continue;
398
+ const keys = Object.keys(operation.args).sort();
399
+ const id = keys.join("\0");
400
+ const perRef = keySets.get(operation.ref) ?? /* @__PURE__ */ new Map();
401
+ const cluster = perRef.get(id) ?? { keys, calls: 0 };
402
+ cluster.calls += 1;
403
+ perRef.set(id, cluster);
404
+ keySets.set(operation.ref, perRef);
405
+ }
406
+ }
407
+ let overloadCount = 0;
408
+ for (const [ref, perRef] of [...keySets.entries()].sort(
409
+ ([left], [right]) => compareCodeUnits(left, right)
410
+ )) {
411
+ if (overloadCount >= MAX_PROPOSALS_PER_KIND) break;
412
+ const clusters = [...perRef.values()].filter((cluster) => cluster.calls >= SPLIT_MIN_CLUSTER_CALLS).sort(
413
+ (left, right) => right.calls - left.calls || compareCodeUnits(left.keys.join(","), right.keys.join(","))
414
+ );
415
+ const disjoint = [];
416
+ for (const cluster of clusters) {
417
+ const keys = new Set(cluster.keys);
418
+ if (disjoint.every((candidate) => candidate.keys.every((key) => !keys.has(key)))) {
419
+ disjoint.push(cluster);
420
+ }
421
+ }
422
+ if (disjoint.length >= 2) {
423
+ overloadCount += 1;
424
+ const report = calledRefs.get(ref);
425
+ proposals.push({
426
+ kind: "overload-split",
427
+ ref,
428
+ shapeEntropyBits: report?.shapeEntropyBits ?? 0,
429
+ clusters: disjoint.slice(0, MAX_PROPOSALS_PER_KIND).map((cluster) => ({
430
+ keys: cluster.keys,
431
+ calls: cluster.calls
432
+ }))
433
+ });
434
+ }
435
+ }
436
+ }
437
+ const sequenceCounts = /* @__PURE__ */ new Map();
438
+ const recordSequenceSegment = (refs, execution) => {
439
+ for (let length = FUSE_MIN_SEQUENCE_LENGTH; length <= Math.min(FUSE_MAX_SEQUENCE_LENGTH, refs.length); length++) {
440
+ for (let start = 0; start + length <= refs.length; start++) {
441
+ const sequence = refs.slice(start, start + length);
442
+ if (new Set(sequence).size !== sequence.length) continue;
443
+ const id = sequence.join("\u2192");
444
+ const entry = sequenceCounts.get(id) ?? {
445
+ sequence,
446
+ occurrences: 0,
447
+ executions: /* @__PURE__ */ new Set()
448
+ };
449
+ entry.occurrences += 1;
450
+ entry.executions.add(execution);
451
+ sequenceCounts.set(id, entry);
452
+ }
453
+ }
454
+ };
455
+ input.traces.forEach((sourceTrace, execution) => {
456
+ let segment = [];
457
+ const flush = () => {
458
+ recordSequenceSegment(segment, execution);
459
+ segment = [];
460
+ };
461
+ for (const operation of sourceTrace.operations) {
462
+ if (operation.outcome !== "succeeded" || operation.ref.startsWith("fabric.") || operation.ref.startsWith("pi.")) {
463
+ flush();
464
+ } else {
465
+ segment.push(operation.ref);
466
+ }
467
+ }
468
+ flush();
469
+ });
470
+ const fuseCandidates = [...sequenceCounts.values()].filter(
471
+ (entry) => entry.occurrences >= FUSE_MIN_OCCURRENCES && entry.executions.size >= FUSE_MIN_EXECUTIONS
472
+ ).sort(
473
+ (left, right) => right.sequence.length - left.sequence.length || right.occurrences - left.occurrences || compareCodeUnits(left.sequence.join("\u2192"), right.sequence.join("\u2192"))
474
+ );
475
+ const selected = [];
476
+ for (const candidate of fuseCandidates) {
477
+ if (selected.length >= MAX_PROPOSALS_PER_KIND) break;
478
+ const redundant = selected.some(
479
+ (chosen) => contains(candidate.sequence, chosen.sequence) || contains(chosen.sequence, candidate.sequence)
480
+ );
481
+ if (redundant) continue;
482
+ selected.push(candidate);
483
+ }
484
+ for (const candidate of selected) {
485
+ proposals.push({
486
+ kind: "sequence-fuse",
487
+ sequence: candidate.sequence,
488
+ occurrences: candidate.occurrences
489
+ });
490
+ }
491
+ return proposals;
492
+ };
493
+ var applyProposalsToSurface = (surface, _proposals) => surface;
494
+ var evaluateGate = (before, after) => {
495
+ const reasons = [];
496
+ if (after.score > before.score) {
497
+ reasons.push(`score increased ${before.score} \u2192 ${after.score}`);
498
+ }
499
+ if (after.totals.succeeded < before.totals.succeeded) {
500
+ reasons.push(
501
+ `successful calls dropped ${before.totals.succeeded} \u2192 ${after.totals.succeeded}`
502
+ );
503
+ }
504
+ return {
505
+ passed: reasons.length === 0,
506
+ beforeScore: before.score,
507
+ afterScore: after.score,
508
+ delta: roundMetric(after.score - before.score),
509
+ reasons
510
+ };
511
+ };
512
+
513
+ // src/entropy/pool.ts
514
+ import { createHash } from "node:crypto";
515
+ var OBSERVATION_POOL_VERSION = 1;
516
+ var POOL_TRACKED_VALUES = 16;
517
+ var POOL_TRACKED_SESSIONS = 16;
518
+ var POOL_BAKED_DIGESTS = 512;
519
+ var SEPARATOR = "\0";
520
+ var observationIdentity = (observation) => `${observation.ref}${SEPARATOR}${observation.key}${SEPARATOR}${typeof observation.value}:${String(observation.value)}`;
521
+ var entryValueKey = (value) => `${typeof value}:${String(value)}`;
522
+ var valueFromKey = (valueKey2) => {
523
+ const separator = valueKey2.indexOf(":");
524
+ const type = valueKey2.slice(0, separator);
525
+ const raw = valueKey2.slice(separator + 1);
526
+ if (type === "number") return Number(raw);
527
+ if (type === "boolean") return raw === "true";
528
+ return raw;
529
+ };
530
+ var parseIdentity = (identity) => {
531
+ const first = identity.indexOf(SEPARATOR);
532
+ const second = identity.indexOf(SEPARATOR, first + 1);
533
+ return {
534
+ ref: identity.slice(0, first),
535
+ key: identity.slice(first + 1, second),
536
+ valueKey: identity.slice(second + 1)
537
+ };
538
+ };
539
+ var digestFromIdentityCounts = (counts) => {
540
+ const hash = createHash("sha256");
541
+ hash.update("[");
542
+ let first = true;
543
+ for (const [identity, count] of Object.entries(counts).sort(
544
+ ([left], [right]) => compareCodeUnits(left, right)
545
+ )) {
546
+ const encoded = JSON.stringify(identity);
547
+ const repeated = Array.from({ length: count }, () => encoded).join(",");
548
+ hash.update(first ? repeated : `,${repeated}`);
549
+ first = false;
550
+ }
551
+ hash.update("]");
552
+ return hash.digest("hex");
553
+ };
554
+ var summarizeObservations = (observations) => {
555
+ const counts = {};
556
+ const digestCounts = {};
557
+ for (const observation of observations) {
558
+ const identity = observationIdentity(observation);
559
+ counts[identity] = (counts[identity] ?? 0) + (observation.count ?? 1);
560
+ digestCounts[identity] = (digestCounts[identity] ?? 0) + 1;
561
+ }
562
+ return { counts, digest: digestFromIdentityCounts(digestCounts) };
563
+ };
564
+ var observationWindowDigest = (observations) => summarizeObservations(observations).digest;
565
+ var COOPERATIVE_OBSERVATION_CHUNK = 256;
566
+ var COOPERATIVE_DIGEST_CHUNK = 512;
567
+ var yieldToLoop2 = () => new Promise((resolve) => setImmediate(resolve));
568
+ var digestFromIdentityCountsAsync = async (counts) => {
569
+ const hash = createHash("sha256");
570
+ hash.update("[");
571
+ let first = true;
572
+ let encodedBatch = [];
573
+ const flush = async () => {
574
+ if (encodedBatch.length === 0) return;
575
+ hash.update(`${first ? "" : ","}${encodedBatch.join(",")}`);
576
+ first = false;
577
+ encodedBatch = [];
578
+ await yieldToLoop2();
579
+ };
580
+ for (const [identity, count] of Object.entries(counts).sort(
581
+ ([left], [right]) => compareCodeUnits(left, right)
582
+ )) {
583
+ const encoded = JSON.stringify(identity);
584
+ for (let occurrence = 0; occurrence < count; occurrence += 1) {
585
+ encodedBatch.push(encoded);
586
+ if (encodedBatch.length >= COOPERATIVE_DIGEST_CHUNK) await flush();
587
+ }
588
+ }
589
+ if (encodedBatch.length > 0) {
590
+ hash.update(`${first ? "" : ","}${encodedBatch.join(",")}`);
591
+ }
592
+ hash.update("]");
593
+ return hash.digest("hex");
594
+ };
595
+ var summarizeObservationsAsync = async (observations) => {
596
+ const counts = {};
597
+ const digestCounts = {};
598
+ for (let index = 0; index < observations.length; index += 1) {
599
+ const observation = observations[index];
600
+ const identity = observationIdentity(observation);
601
+ counts[identity] = (counts[identity] ?? 0) + (observation.count ?? 1);
602
+ digestCounts[identity] = (digestCounts[identity] ?? 0) + 1;
603
+ if ((index + 1) % COOPERATIVE_OBSERVATION_CHUNK === 0) await yieldToLoop2();
604
+ }
605
+ return { counts, digest: await digestFromIdentityCountsAsync(digestCounts) };
606
+ };
607
+ var workingFromPool = (pool) => {
608
+ const working = /* @__PURE__ */ new Map();
609
+ if (!pool) return working;
610
+ for (const entry of pool.entries) {
611
+ const values = /* @__PURE__ */ new Map();
612
+ for (const item of entry.values) {
613
+ values.set(entryValueKey(item.value), { value: item.value, count: item.count });
614
+ }
615
+ working.set(`${entry.ref}${SEPARATOR}${entry.key}`, {
616
+ ref: entry.ref,
617
+ key: entry.key,
618
+ values,
619
+ total: entry.total
620
+ });
621
+ }
622
+ return working;
623
+ };
624
+ var applyEntryDelta = (working, identity, weight) => {
625
+ const { ref, key, valueKey: valueKey2 } = parseIdentity(identity);
626
+ const entryId = `${ref}${SEPARATOR}${key}`;
627
+ let entry = working.get(entryId);
628
+ if (!entry) {
629
+ entry = { ref, key, values: /* @__PURE__ */ new Map(), total: 0 };
630
+ working.set(entryId, entry);
631
+ }
632
+ const current = entry.values.get(valueKey2);
633
+ const nextCount = (current?.count ?? 0) + weight;
634
+ entry.total += weight;
635
+ if (nextCount > 0) {
636
+ entry.values.set(valueKey2, {
637
+ value: current?.value ?? valueFromKey(valueKey2),
638
+ count: nextCount
639
+ });
640
+ } else {
641
+ entry.values.delete(valueKey2);
642
+ }
643
+ if (entry.values.size === 0 && entry.total <= 0) working.delete(entryId);
644
+ return entryId;
645
+ };
646
+ var enforceValueCap = (entry) => {
647
+ while (entry.values.size > POOL_TRACKED_VALUES) {
648
+ let evictKey;
649
+ let evictCount = Number.POSITIVE_INFINITY;
650
+ for (const [valueKey2, item] of entry.values) {
651
+ if (evictKey === void 0 || item.count < evictCount || item.count === evictCount && compareCodeUnits(valueKey2, evictKey) > 0) {
652
+ evictKey = valueKey2;
653
+ evictCount = item.count;
654
+ }
655
+ }
656
+ if (evictKey === void 0) return;
657
+ entry.total -= entry.values.get(evictKey).count;
658
+ entry.values.delete(evictKey);
659
+ }
660
+ };
661
+ var serializePool = (working, tracked, baked) => ({
662
+ version: OBSERVATION_POOL_VERSION,
663
+ entries: [...working.values()].map((entry) => ({
664
+ ref: entry.ref,
665
+ key: entry.key,
666
+ total: entry.total,
667
+ values: [...entry.values.values()].map((item) => ({ value: item.value, count: item.count })).sort(
668
+ (left, right) => right.count - left.count || compareCodeUnits(entryValueKey(left.value), entryValueKey(right.value))
669
+ )
670
+ })).sort(
671
+ (left, right) => compareCodeUnits(
672
+ `${left.ref}${SEPARATOR}${left.key}`,
673
+ `${right.ref}${SEPARATOR}${right.key}`
674
+ )
675
+ ),
676
+ tracked,
677
+ baked
678
+ });
679
+ var mergeObservationSummaries = (pool, windows) => {
680
+ const working = workingFromPool(pool);
681
+ const tracked = [...pool?.tracked ?? []];
682
+ const baked = [...pool?.baked ?? []];
683
+ const bakedSet = new Set(baked);
684
+ const trackedDigests = new Set(tracked.map((session) => session.digest));
685
+ let mergedSessions = 0;
686
+ let skippedSessions = 0;
687
+ for (const window of windows) {
688
+ const { digest, counts: fresh } = window.summary;
689
+ if (bakedSet.has(digest) || trackedDigests.has(digest)) {
690
+ skippedSessions += 1;
691
+ continue;
692
+ }
693
+ const existingIndex = tracked.findIndex((session) => session.file === window.file);
694
+ const existing = existingIndex >= 0 ? tracked[existingIndex] : void 0;
695
+ const delta = { ...fresh };
696
+ if (existing) {
697
+ for (const [identity, count] of Object.entries(existing.counts)) {
698
+ delta[identity] = (delta[identity] ?? 0) - count;
699
+ }
700
+ }
701
+ const touched = /* @__PURE__ */ new Set();
702
+ for (const [identity, weight] of Object.entries(delta)) {
703
+ if (weight === 0) continue;
704
+ touched.add(applyEntryDelta(working, identity, weight));
705
+ }
706
+ for (const entryId of touched) {
707
+ const entry = working.get(entryId);
708
+ if (entry) enforceValueCap(entry);
709
+ }
710
+ const trackedSession = { file: window.file, digest, counts: fresh };
711
+ if (existing) {
712
+ tracked[existingIndex] = trackedSession;
713
+ } else {
714
+ tracked.push(trackedSession);
715
+ if (tracked.length > POOL_TRACKED_SESSIONS) {
716
+ const oldest = tracked.shift();
717
+ if (!bakedSet.has(oldest.digest)) {
718
+ baked.push(oldest.digest);
719
+ bakedSet.add(oldest.digest);
720
+ while (baked.length > POOL_BAKED_DIGESTS) {
721
+ bakedSet.delete(baked.shift());
722
+ }
723
+ }
724
+ }
725
+ }
726
+ trackedDigests.add(digest);
727
+ mergedSessions += 1;
728
+ }
729
+ return {
730
+ file: serializePool(working, tracked, baked),
731
+ mergedSessions,
732
+ skippedSessions
733
+ };
734
+ };
735
+ var mergeObservationWindow = (pool, windows) => mergeObservationSummaries(
736
+ pool,
737
+ windows.map((window) => ({
738
+ file: window.file,
739
+ summary: summarizeObservations(window.observations)
740
+ }))
741
+ );
742
+ var mergeObservationWindowAsync = async (pool, windows) => {
743
+ const summarized = [];
744
+ for (const window of windows) {
745
+ summarized.push({
746
+ file: window.file,
747
+ summary: await summarizeObservationsAsync(window.observations)
748
+ });
749
+ }
750
+ await yieldToLoop2();
751
+ return mergeObservationSummaries(pool, summarized);
752
+ };
753
+ var poolToValueObservations = (pool) => {
754
+ if (!pool) return [];
755
+ const observations = [];
756
+ for (const entry of pool.entries) {
757
+ for (const item of entry.values) {
758
+ observations.push({ ref: entry.ref, key: entry.key, value: item.value, count: item.count });
759
+ }
760
+ }
761
+ return observations;
762
+ };
763
+
764
+ // src/entropy/pool-store.ts
765
+ import fs from "node:fs";
766
+ import path from "node:path";
767
+ var POOL_LOCK_ATTEMPTS = 50;
768
+ var POOL_LOCK_DELAY_MS = 5;
769
+ var POOL_STALE_LOCK_MS = 3e4;
770
+ var POOL_MAX_ENTRIES = 8192;
771
+ var POOL_MAX_VALUES_PER_ENTRY = 64;
772
+ var POOL_MAX_TRACKED = 64;
773
+ var POOL_MAX_BAKED = 2048;
774
+ var observationPoolDirectory = (agentDir) => path.join(agentDir, "fabric", "entropy");
775
+ var poolPath = (directory) => path.join(directory, "observation-pool.json");
776
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
777
+ var errorCode = (error) => isRecord(error) && typeof error.code === "string" ? error.code : void 0;
778
+ var errorText = (error) => (error instanceof Error ? error.message : String(error)).slice(0, 200);
779
+ var isPrimitive = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean";
780
+ var parseValueCount = (value) => {
781
+ if (!isRecord(value) || !isPrimitive(value.value)) return void 0;
782
+ if (!Number.isSafeInteger(value.count) || value.count < 1) return void 0;
783
+ return { value: value.value, count: value.count };
784
+ };
785
+ var parseEntry = (value) => {
786
+ if (!isRecord(value) || typeof value.ref !== "string" || !value.ref.trim()) return void 0;
787
+ if (typeof value.key !== "string" || !value.key.trim()) return void 0;
788
+ if (!Number.isSafeInteger(value.total) || value.total < 0) return void 0;
789
+ if (!Array.isArray(value.values) || value.values.length > POOL_MAX_VALUES_PER_ENTRY) {
790
+ return void 0;
791
+ }
792
+ const values = [];
793
+ for (const item of value.values) {
794
+ const parsed = parseValueCount(item);
795
+ if (!parsed) return void 0;
796
+ values.push(parsed);
797
+ }
798
+ const seen = /* @__PURE__ */ new Set();
799
+ for (const item of values) {
800
+ const key = `${typeof item.value}:${String(item.value)}`;
801
+ if (seen.has(key)) return void 0;
802
+ seen.add(key);
803
+ }
804
+ return { ref: value.ref.trim(), key: value.key.trim(), total: value.total, values };
805
+ };
806
+ var parseTrackedSession = (value) => {
807
+ if (!isRecord(value) || typeof value.file !== "string" || !value.file.trim()) return void 0;
808
+ if (typeof value.digest !== "string" || !value.digest.trim()) return void 0;
809
+ if (!isRecord(value.counts)) return void 0;
810
+ const counts = {};
811
+ for (const [identity, count] of Object.entries(value.counts)) {
812
+ if (!Number.isSafeInteger(count) || count < 1) return void 0;
813
+ counts[identity] = count;
814
+ }
815
+ return { file: value.file.trim(), digest: value.digest.trim(), counts };
816
+ };
817
+ var parsePoolFile = (value) => {
818
+ if (!isRecord(value) || value.version !== OBSERVATION_POOL_VERSION) return void 0;
819
+ if (!Array.isArray(value.entries) || value.entries.length > POOL_MAX_ENTRIES) return void 0;
820
+ if (!Array.isArray(value.tracked) || value.tracked.length > POOL_MAX_TRACKED) return void 0;
821
+ if (!Array.isArray(value.baked) || value.baked.length > POOL_MAX_BAKED) return void 0;
822
+ if (!value.baked.every((digest) => typeof digest === "string" && digest.trim())) {
823
+ return void 0;
824
+ }
825
+ const entries = [];
826
+ for (const entry of value.entries) {
827
+ const parsed = parseEntry(entry);
828
+ if (!parsed) return void 0;
829
+ entries.push(parsed);
830
+ }
831
+ const tracked = [];
832
+ const trackedFiles = /* @__PURE__ */ new Set();
833
+ for (const session of value.tracked) {
834
+ const parsed = parseTrackedSession(session);
835
+ if (!parsed) return void 0;
836
+ if (trackedFiles.has(parsed.file)) return void 0;
837
+ trackedFiles.add(parsed.file);
838
+ tracked.push(parsed);
839
+ }
840
+ const entrySeen = /* @__PURE__ */ new Set();
841
+ for (const entry of entries) {
842
+ const id = `${entry.ref}\0${entry.key}`;
843
+ if (entrySeen.has(id)) return void 0;
844
+ entrySeen.add(id);
845
+ }
846
+ return {
847
+ version: OBSERVATION_POOL_VERSION,
848
+ entries,
849
+ tracked,
850
+ baked: value.baked.map((digest) => digest.trim())
851
+ };
852
+ };
853
+ var loadObservationPool = (agentDir) => {
854
+ const file = poolPath(observationPoolDirectory(agentDir));
855
+ let raw;
856
+ try {
857
+ raw = fs.readFileSync(file, "utf8");
858
+ } catch (error) {
859
+ if (errorCode(error) === "ENOENT") return {};
860
+ return { error: `observation pool is unreadable: ${errorText(error)}` };
861
+ }
862
+ let parsed;
863
+ try {
864
+ parsed = JSON.parse(raw);
865
+ } catch {
866
+ return { error: "observation pool is malformed JSON" };
867
+ }
868
+ const parsedFile = parsePoolFile(parsed);
869
+ if (!parsedFile) return { error: "observation pool is invalid" };
870
+ return { file: parsedFile };
871
+ };
872
+ var loadObservationPoolAsync = async (agentDir) => {
873
+ const file = poolPath(observationPoolDirectory(agentDir));
874
+ let raw;
875
+ try {
876
+ raw = await fs.promises.readFile(file, "utf8");
877
+ } catch (error) {
878
+ if (errorCode(error) === "ENOENT") return {};
879
+ return { error: `observation pool is unreadable: ${errorText(error)}` };
880
+ }
881
+ let parsed;
882
+ try {
883
+ parsed = JSON.parse(raw);
884
+ } catch {
885
+ return { error: "observation pool is malformed JSON" };
886
+ }
887
+ const parsedFile = parsePoolFile(parsed);
888
+ return parsedFile ? { file: parsedFile } : { error: "observation pool is invalid" };
889
+ };
890
+ var saveObservationPool = (agentDir, file) => withExclusiveFileLock(
891
+ {
892
+ directory: observationPoolDirectory(agentDir),
893
+ lockName: "observation-pool.lock",
894
+ timeoutMessage: "Timed out waiting for the observation pool lock",
895
+ attempts: POOL_LOCK_ATTEMPTS,
896
+ delayMs: POOL_LOCK_DELAY_MS,
897
+ staleMs: POOL_STALE_LOCK_MS
898
+ },
899
+ () => {
900
+ const loaded = loadObservationPool(agentDir);
901
+ if (loaded.error) throw new Error(loaded.error);
902
+ const target = poolPath(observationPoolDirectory(agentDir));
903
+ const serialized = `${JSON.stringify(file, null, 2)}
904
+ `;
905
+ try {
906
+ if (fs.readFileSync(target, "utf8") === serialized) return { file, written: false };
907
+ } catch {
908
+ }
909
+ writeJsonAtomic(target, file, { space: 2, newline: true, mode: 384, dirMode: 448 });
910
+ return { file, written: true };
911
+ }
912
+ );
913
+ var saveObservationPoolAsync = async (agentDir, file) => withExclusiveFileLockAsync(
914
+ {
915
+ directory: observationPoolDirectory(agentDir),
916
+ lockName: "observation-pool.lock",
917
+ timeoutMessage: "Timed out waiting for the observation pool lock",
918
+ attempts: POOL_LOCK_ATTEMPTS,
919
+ delayMs: POOL_LOCK_DELAY_MS,
920
+ staleMs: POOL_STALE_LOCK_MS
921
+ },
922
+ async () => {
923
+ const loaded = await loadObservationPoolAsync(agentDir);
924
+ if (loaded.error) throw new Error(loaded.error);
925
+ const target = poolPath(observationPoolDirectory(agentDir));
926
+ const serialized = `${JSON.stringify(file, null, 2)}
927
+ `;
928
+ try {
929
+ if (await fs.promises.readFile(target, "utf8") === serialized) {
930
+ return { file, written: false };
931
+ }
932
+ } catch {
933
+ }
934
+ await writeJsonAtomicAsync(target, file, {
935
+ space: 2,
936
+ newline: true,
937
+ mode: 384,
938
+ dirMode: 448
939
+ });
940
+ return { file, written: true };
941
+ }
942
+ );
943
+
944
+ // src/entropy/surface.ts
945
+ var SURFACE_LIST_LIMIT = 1e3;
946
+ var surfaceInvocationContext = (input) => ({
947
+ cwd: input.cwd,
948
+ signal: void 0,
949
+ parentToolCallId: "fabric-entropy-surface",
950
+ nestedToolCallId: "fabric-entropy-surface",
951
+ extensionContext: input.extensionContext,
952
+ update: () => {
953
+ }
954
+ });
955
+ var liveSurfaceSnapshot = async (input) => {
956
+ const actions = await input.registry.list(
957
+ { limit: SURFACE_LIST_LIMIT, declared: true },
958
+ surfaceInvocationContext(input)
959
+ );
960
+ return {
961
+ version: 1,
962
+ actions: actions.map((action) => ({ ref: action.ref, inputSchema: action.inputSchema })).sort((left, right) => compareCodeUnits(left.ref, right.ref))
963
+ };
964
+ };
965
+ var entropySurfaceHash = (surface) => stableJsonHash(surface);
966
+ var surfaceFreedomReport = (surface) => {
967
+ const actions = surface.actions.map((action) => ({ ref: action.ref, freedom: staticFreedomFromSchema(action.inputSchema) })).sort((left, right) => right.freedom - left.freedom || compareCodeUnits(left.ref, right.ref));
968
+ const total = roundMetric(actions.reduce((sum, entry) => sum + entry.freedom, 0));
969
+ return {
970
+ actions,
971
+ total,
972
+ mean: actions.length > 0 ? roundMetric(total / actions.length) : 0
973
+ };
974
+ };
975
+
976
+ // src/entropy/compiler.ts
977
+ var AUTO_APPLY_PROPOSAL_KINDS = ["normal-form"];
978
+ var entropyReviewSignals = (input) => proposeEntropyReductions(input).filter((proposal) => ["declare-enum", "overload-split", "sequence-fuse"].includes(proposal.kind));
979
+ var formatEntropyReviewSignal = (proposal) => {
980
+ if (proposal.kind === "declare-enum") {
981
+ const values = proposal.values.slice(0, 4).map(String).join(", ");
982
+ return `declare-enum ${proposal.ref}.${proposal.key} (${values}${proposal.values.length > 4 ? ", ..." : ""})`;
983
+ }
984
+ if (proposal.kind === "overload-split") return `overload-split ${proposal.ref} (${proposal.clusters.length} key-set clusters)`;
985
+ if (proposal.kind === "sequence-fuse") return `sequence-fuse ${proposal.sequence.join(" -> ")}`;
986
+ return `${proposal.kind} ${proposal.ref}`;
987
+ };
988
+ var sortedActions = (surface) => [...surface.actions].sort((a, b) => a.ref < b.ref ? -1 : a.ref > b.ref ? 1 : 0);
989
+ var finishCompile = (input, report, plans) => {
990
+ const review = entropyReviewSignals({ ...input, report });
991
+ const previous = input.artifact;
992
+ const current = previous?.version === COMPILED_SURFACE_VERSION && previous.actions.length === 0 && previous.quarantined.length === 0 && stableJsonHash(previous.normalizations ?? []) === stableJsonHash(plans);
993
+ if (current || !previous && plans.length === 0) {
994
+ return { status: "converged", ...previous ? { artifact: previous } : {}, report, proposals: review };
995
+ }
996
+ const proposals = plans.map((plan) => ({
997
+ kind: "normal-form",
998
+ ref: plan.ref,
999
+ baseSchemaDigest: plan.baseSchemaDigest,
1000
+ rules: plan.rules
1001
+ }));
1002
+ const gate = { passed: true, beforeScore: report.score, afterScore: report.score, delta: 0, reasons: [] };
1003
+ const artifact = {
1004
+ ...emptyCompiledSurface(),
1005
+ normalizations: plans,
1006
+ applied: plans.slice(0, MAX_COMPILED_SURFACE_PROPOSALS).map((plan) => ({ kind: "normal-form", ref: plan.ref, detail: `${plan.rules.length} proven rules` })),
1007
+ gate: { passed: true, beforeScore: report.score, afterScore: report.score, reasons: [] },
1008
+ evidenceDigest: stableJsonHash({ surface: entropySurfaceHash(input.surface), plans })
1009
+ };
1010
+ return { status: "compiled", artifact, report, after: report, proposals: [...proposals, ...review], gate };
1011
+ };
1012
+ var compileEntropySurface = (input) => {
1013
+ const report = measureEntropy({ ...input, catalogDigest: input.catalogDigest ?? entropySurfaceHash(input.surface) });
1014
+ const plans = [];
1015
+ for (const action of sortedActions(input.surface)) {
1016
+ const plan = deriveNormalFormPlan(action.ref, action.inputSchema);
1017
+ if (plan && plans.length < MAX_NORMAL_FORM_PLANS) plans.push(plan);
1018
+ }
1019
+ return finishCompile(input, report, plans);
1020
+ };
1021
+ var compileEntropySurfaceAsync = async (input) => {
1022
+ const report = await measureEntropyAsync({ ...input, catalogDigest: input.catalogDigest ?? entropySurfaceHash(input.surface) });
1023
+ const plans = [];
1024
+ let processed = 0;
1025
+ for (const action of sortedActions(input.surface)) {
1026
+ const plan = deriveNormalFormPlan(action.ref, action.inputSchema);
1027
+ if (plan && plans.length < MAX_NORMAL_FORM_PLANS) plans.push(plan);
1028
+ if (++processed % 32 === 0) await new Promise((resolve) => setImmediate(resolve));
1029
+ }
1030
+ return finishCompile(input, report, plans);
1031
+ };
1032
+
1033
+ // src/entropy/presentation.ts
1034
+ var METRIC_PRECISION = 6;
1035
+ var ENTROPY_COMMAND_HINTS = [
1036
+ {
1037
+ label: "export",
1038
+ command: "/fabric entropy export [path]",
1039
+ comment: "snapshot the live surface (default <agent dir>/fabric/entropy/surface.json)"
1040
+ },
1041
+ {
1042
+ label: "share",
1043
+ command: "/fabric entropy export-artifact [path]",
1044
+ comment: "write the compiled artifact (default <agent dir>/fabric/entropy/artifact.json)"
1045
+ },
1046
+ {
1047
+ label: "merge",
1048
+ command: "/fabric entropy import <path>",
1049
+ comment: "merge a peer artifact (digest-proven entries only)"
1050
+ }
1051
+ ];
1052
+ var formatEntropyMetric = (value) => value.toFixed(METRIC_PRECISION);
1053
+ var formatEntropyCommandHints = () => {
1054
+ const heads = ENTROPY_COMMAND_HINTS.map((hint) => `${hint.label}: ${hint.command}`);
1055
+ const commentColumn = Math.max(...heads.map((head) => head.length)) + 2;
1056
+ return ENTROPY_COMMAND_HINTS.map(
1057
+ (hint, index) => `${heads[index].padEnd(commentColumn)}# ${hint.comment}`
1058
+ );
1059
+ };
1060
+ var scoreChange = (before, after) => {
1061
+ if (before === after) {
1062
+ return `entropy score unchanged at ${formatEntropyMetric(before)} (lower is better)`;
1063
+ }
1064
+ let precision = METRIC_PRECISION;
1065
+ while (precision < 12 && before.toFixed(precision) === after.toFixed(precision)) precision += 1;
1066
+ const delta = after - before;
1067
+ const format = (value) => value.toFixed(precision);
1068
+ const absoluteDelta = format(Math.abs(delta));
1069
+ const renderedDelta = Number(absoluteDelta) === 0 ? Math.abs(delta).toExponential(2) : absoluteDelta;
1070
+ return `entropy score ${delta < 0 ? "improved" : "changed"} ${format(before)} \u2192 ${format(after)} (${delta > 0 ? "+" : "\u2212"}${renderedDelta}; lower is better)`;
1071
+ };
1072
+ var entropyReviewKey = (proposals) => {
1073
+ const identities = proposals.map((proposal) => {
1074
+ if (proposal.kind === "declare-enum") {
1075
+ return JSON.stringify([
1076
+ proposal.kind,
1077
+ proposal.ref,
1078
+ proposal.key,
1079
+ proposal.values.map((value) => [typeof value, value])
1080
+ ]);
1081
+ }
1082
+ if (proposal.kind === "overload-split") {
1083
+ return JSON.stringify([
1084
+ proposal.kind,
1085
+ proposal.ref,
1086
+ proposal.clusters.map((cluster) => cluster.keys)
1087
+ ]);
1088
+ }
1089
+ if (proposal.kind === "sequence-fuse") {
1090
+ return JSON.stringify([proposal.kind, proposal.sequence]);
1091
+ }
1092
+ return JSON.stringify([proposal.kind, proposal.ref]);
1093
+ });
1094
+ identities.sort();
1095
+ return JSON.stringify(identities);
1096
+ };
1097
+ var reviewLabel = (kind, count) => {
1098
+ const noun = kind === "declare-enum" ? "enum declaration" : kind === "overload-split" ? "action split" : kind === "sequence-fuse" ? "sequence fusion" : kind;
1099
+ return `${count} ${noun}${count === 1 ? "" : "s"}`;
1100
+ };
1101
+ var formatEntropyReviewNotice = (proposals) => {
1102
+ const counts = /* @__PURE__ */ new Map();
1103
+ for (const proposal of proposals) counts.set(proposal.kind, (counts.get(proposal.kind) ?? 0) + 1);
1104
+ const summary = [...counts.entries()].map(([kind, count]) => reviewLabel(kind, count)).join(" \xB7 ");
1105
+ return `entropy: ${proposals.length} suggestion${proposals.length === 1 ? "" : "s"} await review${summary ? ` \xB7 ${summary}` : ""} \xB7 inspect with /fabric entropy`;
1106
+ };
1107
+ var formatEntropyCompileNotice = (input) => {
1108
+ const review = input.reviewCount ? ` \xB7 ${input.reviewCount} suggestion${input.reviewCount === 1 ? "" : "s"} await review (/fabric entropy)` : "";
1109
+ return `entropy: background optimization complete \xB7 ${input.normalizations ?? 0} normal-form plans \xB7 canonical capabilities preserved \xB7 ${scoreChange(input.beforeScore, input.afterScore)} \xB7 safety checks passed${review}`;
1110
+ };
1111
+
1112
+ // src/entropy/corpus.ts
1113
+ var DEFAULT_TASK_KEY2 = "(none)";
1114
+ var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1115
+ var entropyTraceFromFabricTrace = (trace, model) => ({
1116
+ operations: trace.operations.map((operation) => ({
1117
+ ref: operation.ref,
1118
+ args: operation.args,
1119
+ outcome: operation.outcome,
1120
+ ...operation.failureStage !== void 0 ? { failureStage: operation.failureStage } : {},
1121
+ ...operation.normalization ? { normalization: operation.normalization } : {}
1122
+ })),
1123
+ taskKey: trace.phases[0] ?? DEFAULT_TASK_KEY2,
1124
+ ...model ? { model } : {}
1125
+ });
1126
+ var MODEL_CHANGE_FILTER = /"type"\s*:\s*"model_change"/;
1127
+ var ASSISTANT_FILTER = /"role"\s*:\s*"assistant"/;
1128
+ var modelFromRecord = (parsed) => {
1129
+ if (parsed.type === "model_change") {
1130
+ const provider2 = typeof parsed.provider === "string" ? parsed.provider : "";
1131
+ const modelId2 = typeof parsed.modelId === "string" ? parsed.modelId : "";
1132
+ return provider2 && modelId2 ? `${provider2}/${modelId2}` : void 0;
1133
+ }
1134
+ const message = isRecord2(parsed.message) ? parsed.message : void 0;
1135
+ if (!message || message.role !== "assistant") return void 0;
1136
+ const provider = typeof message.provider === "string" ? message.provider : "";
1137
+ const modelId = typeof message.model === "string" ? message.model : "";
1138
+ return provider && modelId ? `${provider}/${modelId}` : void 0;
1139
+ };
1140
+ var scanSessionLine = (line, state) => {
1141
+ if (line === "") return void 0;
1142
+ const traceLine = line.includes(FABRIC_EXECUTION_TRACE_KIND);
1143
+ const modelLine = !traceLine && (MODEL_CHANGE_FILTER.test(line) || ASSISTANT_FILTER.test(line));
1144
+ if (!traceLine && !modelLine) return void 0;
1145
+ let parsed;
1146
+ try {
1147
+ parsed = JSON.parse(line.trim());
1148
+ } catch {
1149
+ return void 0;
1150
+ }
1151
+ if (!isRecord2(parsed)) return void 0;
1152
+ const model = modelFromRecord(parsed);
1153
+ if (model) state.currentModel = model;
1154
+ if (!traceLine) return void 0;
1155
+ const details = isRecord2(parsed.details) ? parsed.details : isRecord2(parsed.message) && isRecord2(parsed.message.details) ? parsed.message.details : void 0;
1156
+ return isRecord2(details) ? { details, ...state.currentModel ? { model: state.currentModel } : {} } : void 0;
1157
+ };
1158
+ var emptySessionEvidence = () => ({
1159
+ traces: [],
1160
+ valueObservations: [],
1161
+ auditCalls: []
1162
+ });
1163
+ var appendSessionRecord = (evidence, record) => {
1164
+ const trace = readFabricExecutionTraceV1(record.details.trace);
1165
+ if (!trace) return;
1166
+ evidence.traces.push(entropyTraceFromFabricTrace(trace, record.model));
1167
+ const audits = record.details.audits;
1168
+ if (!Array.isArray(audits)) return;
1169
+ for (const audit of audits) {
1170
+ if (!isRecord2(audit)) continue;
1171
+ const ref = typeof audit.ref === "string" ? audit.ref : void 0;
1172
+ const args = isRecord2(audit.args) ? audit.args : void 0;
1173
+ if (!ref || !args) continue;
1174
+ evidence.auditCalls.push({ ref, args });
1175
+ for (const [key, value] of Object.entries(args)) {
1176
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1177
+ evidence.valueObservations.push({ ref, key, value });
1178
+ }
1179
+ }
1180
+ }
1181
+ };
1182
+ var entropySessionEvidenceFromJsonl = (lines) => {
1183
+ const evidence = emptySessionEvidence();
1184
+ const state = {};
1185
+ for (const line of lines) {
1186
+ const record = scanSessionLine(line, state);
1187
+ if (record) appendSessionRecord(evidence, record);
1188
+ }
1189
+ return evidence;
1190
+ };
1191
+ var scanEntropySessionJsonlAsync = async (lines, initialModel) => {
1192
+ const evidence = emptySessionEvidence();
1193
+ const state = {
1194
+ ...initialModel ? { currentModel: initialModel } : {}
1195
+ };
1196
+ for await (const line of lines) {
1197
+ const record = scanSessionLine(line, state);
1198
+ if (record) appendSessionRecord(evidence, record);
1199
+ }
1200
+ return {
1201
+ evidence,
1202
+ ...state.currentModel ? { currentModel: state.currentModel } : {}
1203
+ };
1204
+ };
1205
+ var entropySessionEvidenceFromJsonlAsync = async (lines) => (await scanEntropySessionJsonlAsync(lines)).evidence;
1206
+ var entropyTracesFromSessionJsonl = (lines) => entropySessionEvidenceFromJsonl(lines).traces;
1207
+ var entropyValueObservationsFromSessionJsonl = (lines) => entropySessionEvidenceFromJsonl(lines).valueObservations;
1208
+ var entropyAuditCallsFromSessionJsonl = (lines) => entropySessionEvidenceFromJsonl(lines).auditCalls;
1209
+ var entropyRepairRows = (repairs) => repairs.map(
1210
+ (repair) => repair.kind === "keyAlias" ? { kind: "keyAlias", ref: repair.ref, from: repair.from, to: repair.to } : {
1211
+ kind: "actionAlias",
1212
+ ref: `${repair.provider}.${repair.to}`,
1213
+ from: repair.from,
1214
+ to: repair.to
1215
+ }
1216
+ );
1217
+ var entropyReportHash = (report) => stableJsonHash(report);
1218
+
1219
+ // src/entropy/sessions.ts
1220
+ import fs2 from "node:fs";
1221
+ import path2 from "node:path";
1222
+ import { createInterface } from "node:readline";
1223
+ var DEFAULT_SESSION_WINDOW = 8;
1224
+ var SESSION_STAT_CONCURRENCY = 32;
1225
+ var SESSION_READ_CONCURRENCY = 4;
1226
+ var SESSION_EVIDENCE_CACHE_LIMIT = 16;
1227
+ var asyncEvidenceCache = /* @__PURE__ */ new Map();
1228
+ var mapConcurrent = async (items, limit, fn) => {
1229
+ const results = new Array(items.length);
1230
+ let cursor = 0;
1231
+ const worker = async () => {
1232
+ for (; ; ) {
1233
+ const index = cursor++;
1234
+ if (index >= items.length) return;
1235
+ results[index] = await fn(items[index]);
1236
+ }
1237
+ };
1238
+ await Promise.all(
1239
+ Array.from({ length: Math.min(limit, items.length) }, () => worker())
1240
+ );
1241
+ return results;
1242
+ };
1243
+ var byNewestSession = (left, right) => right.mtime - left.mtime || (left.file < right.file ? -1 : left.file > right.file ? 1 : 0);
1244
+ var stampSessionFiles = async (files) => mapConcurrent(files, SESSION_STAT_CONCURRENCY, async (file) => {
1245
+ let mtime = 0;
1246
+ try {
1247
+ mtime = (await fs2.promises.stat(file)).mtimeMs;
1248
+ } catch {
1249
+ }
1250
+ return { file, mtime };
1251
+ });
1252
+ var projectSessionFiles = (agentDir, cwd, limit = DEFAULT_SESSION_WINDOW) => {
1253
+ const dir = sessionDirForCwd(cwd, agentDir);
1254
+ let entries = [];
1255
+ try {
1256
+ entries = fs2.readdirSync(dir, { withFileTypes: true });
1257
+ } catch {
1258
+ return [];
1259
+ }
1260
+ const stamped = entries.filter((entry) => entry.isFile() && entry.name.endsWith(".jsonl")).map((entry) => {
1261
+ const file = path2.join(dir, entry.name);
1262
+ let mtime = 0;
1263
+ try {
1264
+ mtime = fs2.statSync(file).mtimeMs;
1265
+ } catch {
1266
+ mtime = 0;
1267
+ }
1268
+ return { file, mtime };
1269
+ });
1270
+ stamped.sort(
1271
+ (left, right) => right.mtime - left.mtime || (left.file < right.file ? -1 : left.file > right.file ? 1 : 0)
1272
+ );
1273
+ return stamped.slice(0, Math.max(1, limit)).map((entry) => entry.file);
1274
+ };
1275
+ var machineSessionFiles = (agentDir, cwd, limit = DEFAULT_SESSION_WINDOW) => {
1276
+ const root = sessionsDirRoot(agentDir);
1277
+ let projectDirs = [];
1278
+ try {
1279
+ projectDirs = fs2.readdirSync(root, { withFileTypes: true });
1280
+ } catch {
1281
+ return [];
1282
+ }
1283
+ const byNewest = (left, right) => right.mtime - left.mtime || (left.file < right.file ? -1 : left.file > right.file ? 1 : 0);
1284
+ const stamped = [];
1285
+ const directories = projectDirs.filter((entry) => entry.isDirectory()).sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
1286
+ for (const directory of directories) {
1287
+ let entries = [];
1288
+ try {
1289
+ entries = fs2.readdirSync(path2.join(root, directory.name), { withFileTypes: true });
1290
+ } catch {
1291
+ continue;
1292
+ }
1293
+ for (const entry of entries.filter(
1294
+ (candidate) => candidate.isFile() && candidate.name.endsWith(".jsonl")
1295
+ )) {
1296
+ const file = path2.join(root, directory.name, entry.name);
1297
+ let mtime = 0;
1298
+ try {
1299
+ mtime = fs2.statSync(file).mtimeMs;
1300
+ } catch {
1301
+ mtime = 0;
1302
+ }
1303
+ stamped.push({ file, mtime });
1304
+ }
1305
+ }
1306
+ stamped.sort(byNewest);
1307
+ const window = Math.max(1, limit);
1308
+ let selected = stamped.slice(0, window);
1309
+ if (cwd) {
1310
+ const current = projectSessionFiles(agentDir, cwd, 1)[0];
1311
+ if (current !== void 0 && !selected.some((entry) => entry.file === current)) {
1312
+ const kept = [...selected];
1313
+ if (kept.length >= window) kept.length = window - 1;
1314
+ let mtime = 0;
1315
+ try {
1316
+ mtime = fs2.statSync(current).mtimeMs;
1317
+ } catch {
1318
+ mtime = 0;
1319
+ }
1320
+ kept.push({ file: current, mtime });
1321
+ kept.sort(byNewest);
1322
+ selected = kept;
1323
+ }
1324
+ }
1325
+ return selected.map((entry) => entry.file);
1326
+ };
1327
+ var projectSessionFilesAsync = async (agentDir, cwd, limit = DEFAULT_SESSION_WINDOW) => {
1328
+ const dir = sessionDirForCwd(cwd, agentDir);
1329
+ let entries;
1330
+ try {
1331
+ entries = await fs2.promises.readdir(dir, { withFileTypes: true });
1332
+ } catch {
1333
+ return [];
1334
+ }
1335
+ const files = entries.filter((entry) => entry.isFile() && entry.name.endsWith(".jsonl")).map((entry) => path2.join(dir, entry.name));
1336
+ const stamped = await stampSessionFiles(files);
1337
+ stamped.sort(byNewestSession);
1338
+ return stamped.slice(0, Math.max(1, limit)).map((entry) => entry.file);
1339
+ };
1340
+ var machineSessionFilesAsync = async (agentDir, cwd, limit = DEFAULT_SESSION_WINDOW) => {
1341
+ const root = sessionsDirRoot(agentDir);
1342
+ let projectDirs;
1343
+ try {
1344
+ projectDirs = await fs2.promises.readdir(root, { withFileTypes: true });
1345
+ } catch {
1346
+ return [];
1347
+ }
1348
+ const directories = projectDirs.filter((entry) => entry.isDirectory()).sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
1349
+ const filesByDirectory = await mapConcurrent(
1350
+ directories,
1351
+ SESSION_STAT_CONCURRENCY,
1352
+ async (directory) => {
1353
+ const dir = path2.join(root, directory.name);
1354
+ try {
1355
+ return (await fs2.promises.readdir(dir, { withFileTypes: true })).filter((entry) => entry.isFile() && entry.name.endsWith(".jsonl")).map((entry) => path2.join(dir, entry.name));
1356
+ } catch {
1357
+ return [];
1358
+ }
1359
+ }
1360
+ );
1361
+ const stamped = await stampSessionFiles(filesByDirectory.flat());
1362
+ stamped.sort(byNewestSession);
1363
+ const window = Math.max(1, limit);
1364
+ let selected = stamped.slice(0, window);
1365
+ if (cwd) {
1366
+ const current = (await projectSessionFilesAsync(agentDir, cwd, 1))[0];
1367
+ if (current !== void 0 && !selected.some((entry) => entry.file === current)) {
1368
+ const kept = [...selected];
1369
+ if (kept.length >= window) kept.length = window - 1;
1370
+ const [stampedCurrent] = await stampSessionFiles([current]);
1371
+ if (stampedCurrent) kept.push(stampedCurrent);
1372
+ kept.sort(byNewestSession);
1373
+ selected = kept;
1374
+ }
1375
+ }
1376
+ return selected.map((entry) => entry.file);
1377
+ };
1378
+ var finalizeSessionCorpus = (files, sessions) => {
1379
+ const chronological = [...sessions].reverse();
1380
+ const modelScores = /* @__PURE__ */ new Map();
1381
+ for (const session of chronological) {
1382
+ for (const model of session.report.byModel) {
1383
+ const entry = modelScores.get(model.model) ?? { behavioral: [], latest: model };
1384
+ entry.behavioral.push(model.behavioralScore);
1385
+ entry.latest = model;
1386
+ modelScores.set(model.model, entry);
1387
+ }
1388
+ }
1389
+ const models = [...modelScores.entries()].sort(([left], [right]) => compareCodeUnits(left, right)).map(([model, entry]) => ({
1390
+ model,
1391
+ sessions: entry.behavioral.length,
1392
+ latestBehavioralScore: entry.latest.behavioralScore,
1393
+ slopePerSession: trendFromScores(entry.behavioral).slopePerStep,
1394
+ latestRejectionsPer1k: entry.latest.invocationRejectionsPer1k
1395
+ }));
1396
+ return {
1397
+ files,
1398
+ sessions,
1399
+ ...sessions.length > 0 ? { latest: sessions[0].report } : {},
1400
+ trend: trendFromScores(chronological.map((session) => session.report.score)),
1401
+ models
1402
+ };
1403
+ };
1404
+ var measureSessionCorpus = (input) => {
1405
+ const sessions = [];
1406
+ for (const file of input.files) {
1407
+ let text;
1408
+ try {
1409
+ text = fs2.readFileSync(file, "utf8");
1410
+ } catch {
1411
+ continue;
1412
+ }
1413
+ const traces = entropyTracesFromSessionJsonl(text.split("\n"));
1414
+ if (traces.length === 0) continue;
1415
+ const report = measureEntropy({
1416
+ traces,
1417
+ ...input.surface ? { surface: input.surface } : {},
1418
+ ...input.catalogDigest !== void 0 ? { catalogDigest: input.catalogDigest } : {}
1419
+ });
1420
+ if (report.totals.operations === 0) continue;
1421
+ sessions.push({ file, operations: report.totals.operations, report });
1422
+ }
1423
+ return finalizeSessionCorpus(input.files, sessions);
1424
+ };
1425
+ var sessionMetadata = async (file) => {
1426
+ try {
1427
+ const entry = await fs2.promises.stat(file);
1428
+ return {
1429
+ size: entry.size,
1430
+ mtimeMs: entry.mtimeMs,
1431
+ dev: entry.dev,
1432
+ ino: entry.ino
1433
+ };
1434
+ } catch {
1435
+ return void 0;
1436
+ }
1437
+ };
1438
+ var endsAtLineBoundary = async (file, metadata) => {
1439
+ if (metadata.size === 0) return true;
1440
+ let handle;
1441
+ try {
1442
+ handle = await fs2.promises.open(file, "r");
1443
+ const byte = Buffer.allocUnsafe(1);
1444
+ const { bytesRead } = await handle.read(byte, 0, 1, metadata.size - 1);
1445
+ return bytesRead === 1 && byte[0] === 10;
1446
+ } catch {
1447
+ return false;
1448
+ } finally {
1449
+ await handle?.close().catch(() => void 0);
1450
+ }
1451
+ };
1452
+ var scanSessionRange = async (file, start, end, initialModel) => {
1453
+ const input = fs2.createReadStream(file, { encoding: "utf8", start, end });
1454
+ const lines = createInterface({ input, crlfDelay: Infinity });
1455
+ try {
1456
+ return await scanEntropySessionJsonlAsync(lines, initialModel);
1457
+ } finally {
1458
+ lines.close();
1459
+ input.destroy();
1460
+ }
1461
+ };
1462
+ var evidenceWindow = (file, evidence) => ({
1463
+ traces: evidence.traces,
1464
+ valueObservations: evidence.valueObservations,
1465
+ auditCalls: evidence.auditCalls,
1466
+ observationWindows: [{ file, observations: evidence.valueObservations }]
1467
+ });
1468
+ var cacheSessionEvidence = (file, cached) => {
1469
+ asyncEvidenceCache.delete(file);
1470
+ asyncEvidenceCache.set(file, cached);
1471
+ while (asyncEvidenceCache.size > SESSION_EVIDENCE_CACHE_LIMIT) {
1472
+ asyncEvidenceCache.delete(asyncEvidenceCache.keys().next().value);
1473
+ }
1474
+ };
1475
+ var sameSessionFile = (cached, metadata) => cached.dev === metadata.dev && cached.ino === metadata.ino;
1476
+ var readSessionEvidenceAsync = async (file) => {
1477
+ const metadata = await sessionMetadata(file);
1478
+ if (!metadata) return void 0;
1479
+ const cached = asyncEvidenceCache.get(file);
1480
+ if (cached && sameSessionFile(cached, metadata) && cached.size === metadata.size && Math.abs(cached.mtimeMs - metadata.mtimeMs) <= 1e-6) {
1481
+ cacheSessionEvidence(file, cached);
1482
+ return evidenceWindow(file, cached.evidence);
1483
+ }
1484
+ const append = cached && sameSessionFile(cached, metadata) && metadata.size > cached.size ? cached : void 0;
1485
+ const start = append ? append.size : 0;
1486
+ let scan;
1487
+ try {
1488
+ scan = metadata.size === start ? {
1489
+ evidence: { traces: [], valueObservations: [], auditCalls: [] },
1490
+ ...append?.currentModel ? { currentModel: append.currentModel } : {}
1491
+ } : await scanSessionRange(
1492
+ file,
1493
+ start,
1494
+ metadata.size - 1,
1495
+ append?.currentModel
1496
+ );
1497
+ } catch {
1498
+ return void 0;
1499
+ }
1500
+ const evidence = append ? {
1501
+ traces: [...append.evidence.traces, ...scan.evidence.traces],
1502
+ valueObservations: [
1503
+ ...append.evidence.valueObservations,
1504
+ ...scan.evidence.valueObservations
1505
+ ],
1506
+ auditCalls: [...append.evidence.auditCalls, ...scan.evidence.auditCalls]
1507
+ } : scan.evidence;
1508
+ if (await endsAtLineBoundary(file, metadata)) {
1509
+ cacheSessionEvidence(file, {
1510
+ ...metadata,
1511
+ ...scan.currentModel ? { currentModel: scan.currentModel } : {},
1512
+ evidence
1513
+ });
1514
+ } else {
1515
+ asyncEvidenceCache.delete(file);
1516
+ }
1517
+ return evidenceWindow(file, evidence);
1518
+ };
1519
+ var sessionWindowEvidenceAsync = async (files) => {
1520
+ const windows = await mapConcurrent(files, SESSION_READ_CONCURRENCY, readSessionEvidenceAsync);
1521
+ const traces = [];
1522
+ const valueObservations = [];
1523
+ const auditCalls = [];
1524
+ const observationWindows = [];
1525
+ for (const window of windows) {
1526
+ if (!window) continue;
1527
+ traces.push(...window.traces);
1528
+ valueObservations.push(...window.valueObservations);
1529
+ auditCalls.push(...window.auditCalls);
1530
+ observationWindows.push(...window.observationWindows);
1531
+ }
1532
+ return { traces, valueObservations, auditCalls, observationWindows };
1533
+ };
1534
+ var measureSessionCorpusAsync = async (input) => {
1535
+ const windows = await mapConcurrent(
1536
+ input.files,
1537
+ SESSION_READ_CONCURRENCY,
1538
+ readSessionEvidenceAsync
1539
+ );
1540
+ const sessions = [];
1541
+ for (let index = 0; index < input.files.length; index++) {
1542
+ const window = windows[index];
1543
+ const file = input.files[index];
1544
+ if (!window || !file || window.traces.length === 0) continue;
1545
+ const report = await measureEntropyAsync({
1546
+ traces: window.traces,
1547
+ ...input.surface ? { surface: input.surface } : {},
1548
+ ...input.catalogDigest !== void 0 ? { catalogDigest: input.catalogDigest } : {}
1549
+ });
1550
+ if (report.totals.operations === 0) continue;
1551
+ sessions.push({ file, operations: report.totals.operations, report });
1552
+ }
1553
+ return finalizeSessionCorpus(input.files, sessions);
1554
+ };
1555
+ var sessionWindowEvidence = (files) => {
1556
+ const traces = [];
1557
+ const valueObservations = [];
1558
+ const auditCalls = [];
1559
+ const observationWindows = [];
1560
+ for (const file of files) {
1561
+ let text;
1562
+ try {
1563
+ text = fs2.readFileSync(file, "utf8");
1564
+ } catch {
1565
+ continue;
1566
+ }
1567
+ const evidence = entropySessionEvidenceFromJsonl(text.split("\n"));
1568
+ traces.push(...evidence.traces);
1569
+ valueObservations.push(...evidence.valueObservations);
1570
+ auditCalls.push(...evidence.auditCalls);
1571
+ observationWindows.push({ file, observations: evidence.valueObservations });
1572
+ }
1573
+ return { traces, valueObservations, auditCalls, observationWindows };
1574
+ };
1575
+
1576
+ // src/entropy/trial.ts
1577
+ import { Value } from "typebox/value";
1578
+ var accepts = (schema, args) => {
1579
+ try {
1580
+ return typeof schema === "object" && schema !== null && Value.Check(schema, args);
1581
+ } catch {
1582
+ return false;
1583
+ }
1584
+ };
1585
+ var runEntropyTrial = (input) => {
1586
+ const schemas = new Map(input.live.actions.map((action) => [action.ref, action.inputSchema]));
1587
+ const plans = /* @__PURE__ */ new Map();
1588
+ if (input.artifact?.version === COMPILED_SURFACE_VERSION) {
1589
+ for (const plan of input.artifact.normalizations ?? []) {
1590
+ if (provesNormalFormPlan(plan, schemas.get(plan.ref))) plans.set(plan.ref, plan);
1591
+ }
1592
+ }
1593
+ const report = measureEntropy({ traces: input.traces, surface: input.live, catalogDigest: entropySurfaceHash(input.live) });
1594
+ const totals = {
1595
+ operations: 0,
1596
+ bothAccept: 0,
1597
+ bothReject: 0,
1598
+ normalizationWin: 0,
1599
+ canonicalIdentityChecks: 0,
1600
+ canonicalIdentityCost: 0,
1601
+ idempotenceCost: 0,
1602
+ tighteningCost: 0,
1603
+ typedFailureWin: 0,
1604
+ quarantineWin: 0,
1605
+ quarantineCost: 0
1606
+ };
1607
+ const divergences = /* @__PURE__ */ new Map();
1608
+ let plannedOperations = 0;
1609
+ const record = (ref, args) => {
1610
+ if (ref.startsWith("fabric.discovery.") || ref.startsWith("fabric.workflow.")) return;
1611
+ const schema = schemas.get(ref);
1612
+ if (schema === void 0) return;
1613
+ const plan = plans.get(ref);
1614
+ if (plan) plannedOperations++;
1615
+ const before = accepts(schema, args);
1616
+ const normalized = applyNormalFormPlan(ref, schema, args, plan);
1617
+ const after = accepts(schema, normalized.args);
1618
+ totals.operations++;
1619
+ if (before) {
1620
+ totals.canonicalIdentityChecks++;
1621
+ if (normalized.args !== args || normalized.witness) totals.canonicalIdentityCost++;
1622
+ }
1623
+ const twice = applyNormalFormPlan(ref, schema, normalized.args, plan);
1624
+ if (twice.args !== normalized.args || twice.witness) totals.idempotenceCost++;
1625
+ let trialClass;
1626
+ if (before && !after) {
1627
+ totals.tighteningCost++;
1628
+ trialClass = "tightening-cost";
1629
+ } else if (before) {
1630
+ totals.bothAccept++;
1631
+ trialClass = "both-accept";
1632
+ } else if (after && normalized.witness) {
1633
+ totals.normalizationWin++;
1634
+ trialClass = "normalization-win";
1635
+ } else {
1636
+ totals.bothReject++;
1637
+ trialClass = "both-reject";
1638
+ }
1639
+ if (trialClass !== "both-accept" && trialClass !== "both-reject") {
1640
+ const key = JSON.stringify([ref, trialClass]);
1641
+ const entry = divergences.get(key) ?? { ref, trialClass, count: 0 };
1642
+ entry.count++;
1643
+ divergences.set(key, entry);
1644
+ }
1645
+ };
1646
+ const auditedRefs = /* @__PURE__ */ new Set();
1647
+ for (const call of input.auditCalls ?? []) {
1648
+ auditedRefs.add(call.ref);
1649
+ record(call.ref, call.args);
1650
+ }
1651
+ for (const trace of input.traces) {
1652
+ for (const operation of trace.operations) {
1653
+ if (!auditedRefs.has(operation.ref)) record(operation.ref, operation.args);
1654
+ }
1655
+ }
1656
+ const costs = totals.tighteningCost + totals.canonicalIdentityCost + totals.idempotenceCost;
1657
+ return {
1658
+ verdict: costs > 0 ? "costly" : plannedOperations === 0 ? "no-evidence" : "clean",
1659
+ declaredScore: report.score,
1660
+ effectiveScore: report.score,
1661
+ delta: 0,
1662
+ totals,
1663
+ divergences: [...divergences.values()].sort((a, b) => compareCodeUnits(a.ref, b.ref) || compareCodeUnits(a.trialClass, b.trialClass))
1664
+ };
1665
+ };
1666
+
1667
+ export {
1668
+ liveSurfaceSnapshot,
1669
+ entropySurfaceHash,
1670
+ surfaceFreedomReport,
1671
+ entropyTraceFromFabricTrace,
1672
+ entropySessionEvidenceFromJsonl,
1673
+ scanEntropySessionJsonlAsync,
1674
+ entropySessionEvidenceFromJsonlAsync,
1675
+ entropyTracesFromSessionJsonl,
1676
+ entropyValueObservationsFromSessionJsonl,
1677
+ entropyAuditCallsFromSessionJsonl,
1678
+ entropyRepairRows,
1679
+ entropyReportHash,
1680
+ measureEntropy,
1681
+ measureEntropyAsync,
1682
+ projectSessionFiles,
1683
+ machineSessionFiles,
1684
+ projectSessionFilesAsync,
1685
+ machineSessionFilesAsync,
1686
+ measureSessionCorpus,
1687
+ sessionWindowEvidenceAsync,
1688
+ measureSessionCorpusAsync,
1689
+ sessionWindowEvidence,
1690
+ ENTROPY_ENUM_CANDIDATE_ANNOTATION,
1691
+ proposeEntropyReductions,
1692
+ applyProposalsToSurface,
1693
+ evaluateGate,
1694
+ AUTO_APPLY_PROPOSAL_KINDS,
1695
+ entropyReviewSignals,
1696
+ formatEntropyReviewSignal,
1697
+ compileEntropySurface,
1698
+ compileEntropySurfaceAsync,
1699
+ OBSERVATION_POOL_VERSION,
1700
+ POOL_TRACKED_VALUES,
1701
+ POOL_TRACKED_SESSIONS,
1702
+ POOL_BAKED_DIGESTS,
1703
+ observationIdentity,
1704
+ observationWindowDigest,
1705
+ mergeObservationWindow,
1706
+ mergeObservationWindowAsync,
1707
+ poolToValueObservations,
1708
+ observationPoolDirectory,
1709
+ loadObservationPool,
1710
+ loadObservationPoolAsync,
1711
+ saveObservationPool,
1712
+ saveObservationPoolAsync,
1713
+ formatEntropyMetric,
1714
+ formatEntropyCommandHints,
1715
+ entropyReviewKey,
1716
+ formatEntropyReviewNotice,
1717
+ formatEntropyCompileNotice,
1718
+ runEntropyTrial
1719
+ };
1720
+ //# sourceMappingURL=chunk-RNOPHITP.js.map