pulseed 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (910) hide show
  1. package/README.md +13 -9
  2. package/dist/adapters/datasources/artifact-metric-datasource.d.ts +18 -0
  3. package/dist/adapters/datasources/artifact-metric-datasource.d.ts.map +1 -0
  4. package/dist/adapters/datasources/artifact-metric-datasource.js +592 -0
  5. package/dist/adapters/datasources/artifact-metric-datasource.js.map +1 -0
  6. package/dist/adapters/types/mcp.d.ts +6 -6
  7. package/dist/base/state/state-manager-goal-state.d.ts +40 -0
  8. package/dist/base/state/state-manager-goal-state.d.ts.map +1 -0
  9. package/dist/base/state/state-manager-goal-state.js +235 -0
  10. package/dist/base/state/state-manager-goal-state.js.map +1 -0
  11. package/dist/base/state/state-manager.d.ts +0 -5
  12. package/dist/base/state/state-manager.d.ts.map +1 -1
  13. package/dist/base/state/state-manager.js +27 -273
  14. package/dist/base/state/state-manager.js.map +1 -1
  15. package/dist/base/types/goal-activation.d.ts +37 -0
  16. package/dist/base/types/goal-activation.d.ts.map +1 -0
  17. package/dist/base/types/goal-activation.js +13 -0
  18. package/dist/base/types/goal-activation.js.map +1 -0
  19. package/dist/index.d.ts +6 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +4 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/interface/chat/chat-history.d.ts +129 -0
  24. package/dist/interface/chat/chat-history.d.ts.map +1 -1
  25. package/dist/interface/chat/chat-history.js +135 -0
  26. package/dist/interface/chat/chat-history.js.map +1 -1
  27. package/dist/interface/chat/chat-runner-command-helpers.d.ts +50 -0
  28. package/dist/interface/chat/chat-runner-command-helpers.d.ts.map +1 -0
  29. package/dist/interface/chat/chat-runner-command-helpers.js +189 -0
  30. package/dist/interface/chat/chat-runner-command-helpers.js.map +1 -0
  31. package/dist/interface/chat/chat-runner-commands.d.ts +82 -0
  32. package/dist/interface/chat/chat-runner-commands.d.ts.map +1 -0
  33. package/dist/interface/chat/chat-runner-commands.js +906 -0
  34. package/dist/interface/chat/chat-runner-commands.js.map +1 -0
  35. package/dist/interface/chat/chat-runner-event-bridge.d.ts +60 -0
  36. package/dist/interface/chat/chat-runner-event-bridge.d.ts.map +1 -0
  37. package/dist/interface/chat/chat-runner-event-bridge.js +377 -0
  38. package/dist/interface/chat/chat-runner-event-bridge.js.map +1 -0
  39. package/dist/interface/chat/chat-runner-routes.d.ts +67 -0
  40. package/dist/interface/chat/chat-runner-routes.d.ts.map +1 -0
  41. package/dist/interface/chat/chat-runner-routes.js +610 -0
  42. package/dist/interface/chat/chat-runner-routes.js.map +1 -0
  43. package/dist/interface/chat/chat-runner-runtime.d.ts +37 -0
  44. package/dist/interface/chat/chat-runner-runtime.d.ts.map +1 -0
  45. package/dist/interface/chat/chat-runner-runtime.js +236 -0
  46. package/dist/interface/chat/chat-runner-runtime.js.map +1 -0
  47. package/dist/interface/chat/chat-runner-state.d.ts +20 -0
  48. package/dist/interface/chat/chat-runner-state.d.ts.map +1 -0
  49. package/dist/interface/chat/chat-runner-state.js +157 -0
  50. package/dist/interface/chat/chat-runner-state.js.map +1 -0
  51. package/dist/interface/chat/chat-runner-support.d.ts +39 -0
  52. package/dist/interface/chat/chat-runner-support.d.ts.map +1 -0
  53. package/dist/interface/chat/chat-runner-support.js +170 -0
  54. package/dist/interface/chat/chat-runner-support.js.map +1 -0
  55. package/dist/interface/chat/chat-runner.d.ts +10 -153
  56. package/dist/interface/chat/chat-runner.d.ts.map +1 -1
  57. package/dist/interface/chat/chat-runner.js +330 -2643
  58. package/dist/interface/chat/chat-runner.js.map +1 -1
  59. package/dist/interface/chat/chat-session-store.d.ts +32 -0
  60. package/dist/interface/chat/chat-session-store.d.ts.map +1 -1
  61. package/dist/interface/chat/chat-session-store.js +100 -10
  62. package/dist/interface/chat/chat-session-store.js.map +1 -1
  63. package/dist/interface/chat/cross-platform-session.d.ts.map +1 -1
  64. package/dist/interface/chat/cross-platform-session.js +15 -6
  65. package/dist/interface/chat/cross-platform-session.js.map +1 -1
  66. package/dist/interface/chat/event-subscriber.d.ts.map +1 -1
  67. package/dist/interface/chat/event-subscriber.js +61 -0
  68. package/dist/interface/chat/event-subscriber.js.map +1 -1
  69. package/dist/interface/chat/failure-recovery.d.ts +43 -1
  70. package/dist/interface/chat/failure-recovery.d.ts.map +1 -1
  71. package/dist/interface/chat/failure-recovery.js +259 -89
  72. package/dist/interface/chat/failure-recovery.js.map +1 -1
  73. package/dist/interface/chat/ingress-router.d.ts +2 -26
  74. package/dist/interface/chat/ingress-router.d.ts.map +1 -1
  75. package/dist/interface/chat/ingress-router.js +14 -88
  76. package/dist/interface/chat/ingress-router.js.map +1 -1
  77. package/dist/interface/chat/tend-command.d.ts.map +1 -1
  78. package/dist/interface/chat/tend-command.js +3 -0
  79. package/dist/interface/chat/tend-command.js.map +1 -1
  80. package/dist/interface/cli/cli-command-registry.d.ts.map +1 -1
  81. package/dist/interface/cli/cli-command-registry.js +19 -3
  82. package/dist/interface/cli/cli-command-registry.js.map +1 -1
  83. package/dist/interface/cli/commands/daemon-shared.d.ts +33 -0
  84. package/dist/interface/cli/commands/daemon-shared.d.ts.map +1 -0
  85. package/dist/interface/cli/commands/daemon-shared.js +152 -0
  86. package/dist/interface/cli/commands/daemon-shared.js.map +1 -0
  87. package/dist/interface/cli/commands/daemon.d.ts +2 -2
  88. package/dist/interface/cli/commands/daemon.d.ts.map +1 -1
  89. package/dist/interface/cli/commands/daemon.js +62 -127
  90. package/dist/interface/cli/commands/daemon.js.map +1 -1
  91. package/dist/interface/cli/commands/goal-read.d.ts.map +1 -1
  92. package/dist/interface/cli/commands/goal-read.js +10 -3
  93. package/dist/interface/cli/commands/goal-read.js.map +1 -1
  94. package/dist/interface/cli/commands/notify.d.ts.map +1 -1
  95. package/dist/interface/cli/commands/notify.js +7 -1
  96. package/dist/interface/cli/commands/notify.js.map +1 -1
  97. package/dist/interface/cli/commands/run.d.ts.map +1 -1
  98. package/dist/interface/cli/commands/run.js +29 -0
  99. package/dist/interface/cli/commands/run.js.map +1 -1
  100. package/dist/interface/cli/commands/runtime.d.ts +1 -1
  101. package/dist/interface/cli/commands/runtime.d.ts.map +1 -1
  102. package/dist/interface/cli/commands/runtime.js +407 -2
  103. package/dist/interface/cli/commands/runtime.js.map +1 -1
  104. package/dist/interface/cli/commands/schedule/history.d.ts.map +1 -1
  105. package/dist/interface/cli/commands/schedule/history.js +5 -1
  106. package/dist/interface/cli/commands/schedule/history.js.map +1 -1
  107. package/dist/interface/cli/commands/schedule.js +34 -4
  108. package/dist/interface/cli/commands/schedule.js.map +1 -1
  109. package/dist/interface/cli/data-source-bootstrap.d.ts.map +1 -1
  110. package/dist/interface/cli/data-source-bootstrap.js +25 -12
  111. package/dist/interface/cli/data-source-bootstrap.js.map +1 -1
  112. package/dist/interface/cli/setup.d.ts.map +1 -1
  113. package/dist/interface/cli/setup.js +14 -0
  114. package/dist/interface/cli/setup.js.map +1 -1
  115. package/dist/interface/cli/utils/loop-runner.d.ts.map +1 -1
  116. package/dist/interface/cli/utils/loop-runner.js +2 -1
  117. package/dist/interface/cli/utils/loop-runner.js.map +1 -1
  118. package/dist/interface/cli/utils.d.ts.map +1 -1
  119. package/dist/interface/cli/utils.js +8 -1
  120. package/dist/interface/cli/utils.js.map +1 -1
  121. package/dist/interface/tui/app.d.ts +4 -1
  122. package/dist/interface/tui/app.d.ts.map +1 -1
  123. package/dist/interface/tui/app.js +282 -11
  124. package/dist/interface/tui/app.js.map +1 -1
  125. package/dist/interface/tui/chat/suggestions.d.ts.map +1 -1
  126. package/dist/interface/tui/chat/suggestions.js +118 -4
  127. package/dist/interface/tui/chat/suggestions.js.map +1 -1
  128. package/dist/interface/tui/chat-surface.d.ts +2 -0
  129. package/dist/interface/tui/chat-surface.d.ts.map +1 -1
  130. package/dist/interface/tui/chat-surface.js +3 -0
  131. package/dist/interface/tui/chat-surface.js.map +1 -1
  132. package/dist/interface/tui/dashboard.d.ts +37 -1
  133. package/dist/interface/tui/dashboard.d.ts.map +1 -1
  134. package/dist/interface/tui/dashboard.js +264 -1
  135. package/dist/interface/tui/dashboard.js.map +1 -1
  136. package/dist/interface/tui/entry-approval.d.ts +8 -0
  137. package/dist/interface/tui/entry-approval.d.ts.map +1 -0
  138. package/dist/interface/tui/entry-approval.js +59 -0
  139. package/dist/interface/tui/entry-approval.js.map +1 -0
  140. package/dist/interface/tui/entry-daemon.d.ts +12 -0
  141. package/dist/interface/tui/entry-daemon.d.ts.map +1 -0
  142. package/dist/interface/tui/entry-daemon.js +74 -0
  143. package/dist/interface/tui/entry-daemon.js.map +1 -0
  144. package/dist/interface/tui/entry-deps.d.ts +24 -0
  145. package/dist/interface/tui/entry-deps.d.ts.map +1 -0
  146. package/dist/interface/tui/entry-deps.js +427 -0
  147. package/dist/interface/tui/entry-deps.js.map +1 -0
  148. package/dist/interface/tui/entry.d.ts +2 -4
  149. package/dist/interface/tui/entry.d.ts.map +1 -1
  150. package/dist/interface/tui/entry.js +11 -556
  151. package/dist/interface/tui/entry.js.map +1 -1
  152. package/dist/interface/tui/fullscreen-chat-render.d.ts +127 -0
  153. package/dist/interface/tui/fullscreen-chat-render.d.ts.map +1 -0
  154. package/dist/interface/tui/fullscreen-chat-render.js +667 -0
  155. package/dist/interface/tui/fullscreen-chat-render.js.map +1 -0
  156. package/dist/interface/tui/fullscreen-chat.d.ts +2 -111
  157. package/dist/interface/tui/fullscreen-chat.d.ts.map +1 -1
  158. package/dist/interface/tui/fullscreen-chat.js +4 -663
  159. package/dist/interface/tui/fullscreen-chat.js.map +1 -1
  160. package/dist/interface/tui/help-overlay.d.ts.map +1 -1
  161. package/dist/interface/tui/help-overlay.js +1 -1
  162. package/dist/interface/tui/help-overlay.js.map +1 -1
  163. package/dist/interface/tui/intent-recognizer.d.ts +8 -3
  164. package/dist/interface/tui/intent-recognizer.d.ts.map +1 -1
  165. package/dist/interface/tui/intent-recognizer.js +74 -68
  166. package/dist/interface/tui/intent-recognizer.js.map +1 -1
  167. package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.d.ts.map +1 -1
  168. package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.js +49 -0
  169. package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.js.map +1 -1
  170. package/dist/orchestrator/execution/agent-loop/agent-loop-tool-router.d.ts.map +1 -1
  171. package/dist/orchestrator/execution/agent-loop/agent-loop-tool-router.js +2 -1
  172. package/dist/orchestrator/execution/agent-loop/agent-loop-tool-router.js.map +1 -1
  173. package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.d.ts +2 -0
  174. package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.d.ts.map +1 -1
  175. package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.js +31 -0
  176. package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.js.map +1 -1
  177. package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.d.ts +1 -0
  178. package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.d.ts.map +1 -1
  179. package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.js.map +1 -1
  180. package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.d.ts +1 -0
  181. package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.d.ts.map +1 -1
  182. package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.js +36 -2
  183. package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.js.map +1 -1
  184. package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.d.ts +1 -1
  185. package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.d.ts.map +1 -1
  186. package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.js +2 -1
  187. package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.js.map +1 -1
  188. package/dist/orchestrator/execution/agent-loop/core-loop-control-tools.d.ts +19 -0
  189. package/dist/orchestrator/execution/agent-loop/core-loop-control-tools.d.ts.map +1 -1
  190. package/dist/orchestrator/execution/agent-loop/core-loop-control-tools.js +165 -14
  191. package/dist/orchestrator/execution/agent-loop/core-loop-control-tools.js.map +1 -1
  192. package/dist/orchestrator/execution/agent-loop/core-phase-runner.d.ts +1 -1
  193. package/dist/orchestrator/execution/agent-loop/core-phase-runner.d.ts.map +1 -1
  194. package/dist/orchestrator/execution/agent-loop/core-phase-runner.js +10 -1
  195. package/dist/orchestrator/execution/agent-loop/core-phase-runner.js.map +1 -1
  196. package/dist/orchestrator/execution/agent-loop/kaggle-training-benchmark.d.ts +2 -0
  197. package/dist/orchestrator/execution/agent-loop/kaggle-training-benchmark.d.ts.map +1 -1
  198. package/dist/orchestrator/execution/agent-loop/kaggle-training-benchmark.js +4 -0
  199. package/dist/orchestrator/execution/agent-loop/kaggle-training-benchmark.js.map +1 -1
  200. package/dist/orchestrator/execution/agent-loop/task-agent-loop-result.d.ts +8 -8
  201. package/dist/orchestrator/execution/reflection-generator.d.ts +1 -0
  202. package/dist/orchestrator/execution/reflection-generator.d.ts.map +1 -1
  203. package/dist/orchestrator/execution/reflection-generator.js +10 -1
  204. package/dist/orchestrator/execution/reflection-generator.js.map +1 -1
  205. package/dist/orchestrator/execution/task/task-context-enricher.d.ts +2 -0
  206. package/dist/orchestrator/execution/task/task-context-enricher.d.ts.map +1 -1
  207. package/dist/orchestrator/execution/task/task-context-enricher.js +9 -4
  208. package/dist/orchestrator/execution/task/task-context-enricher.js.map +1 -1
  209. package/dist/orchestrator/execution/task/task-execution-helpers-internal.d.ts +5 -0
  210. package/dist/orchestrator/execution/task/task-execution-helpers-internal.d.ts.map +1 -0
  211. package/dist/orchestrator/execution/task/task-execution-helpers-internal.js +6 -0
  212. package/dist/orchestrator/execution/task/task-execution-helpers-internal.js.map +1 -0
  213. package/dist/orchestrator/execution/task/task-generation.d.ts +3 -1
  214. package/dist/orchestrator/execution/task/task-generation.d.ts.map +1 -1
  215. package/dist/orchestrator/execution/task/task-generation.js +25 -5
  216. package/dist/orchestrator/execution/task/task-generation.js.map +1 -1
  217. package/dist/orchestrator/execution/task/task-lifecycle-runner.d.ts +77 -0
  218. package/dist/orchestrator/execution/task/task-lifecycle-runner.d.ts.map +1 -0
  219. package/dist/orchestrator/execution/task/task-lifecycle-runner.js +188 -0
  220. package/dist/orchestrator/execution/task/task-lifecycle-runner.js.map +1 -0
  221. package/dist/orchestrator/execution/task/task-lifecycle.d.ts +17 -8
  222. package/dist/orchestrator/execution/task/task-lifecycle.d.ts.map +1 -1
  223. package/dist/orchestrator/execution/task/task-lifecycle.js +144 -187
  224. package/dist/orchestrator/execution/task/task-lifecycle.js.map +1 -1
  225. package/dist/orchestrator/execution/task/task-prompt-builder.d.ts +2 -1
  226. package/dist/orchestrator/execution/task/task-prompt-builder.d.ts.map +1 -1
  227. package/dist/orchestrator/execution/task/task-prompt-builder.js +4 -2
  228. package/dist/orchestrator/execution/task/task-prompt-builder.js.map +1 -1
  229. package/dist/orchestrator/execution/task/task-verifier-internal.d.ts +2 -0
  230. package/dist/orchestrator/execution/task/task-verifier-internal.d.ts.map +1 -0
  231. package/dist/orchestrator/execution/task/task-verifier-internal.js +2 -0
  232. package/dist/orchestrator/execution/task/task-verifier-internal.js.map +1 -0
  233. package/dist/orchestrator/execution/types/pipeline.d.ts +6 -6
  234. package/dist/orchestrator/goal/goal-negotiator.d.ts.map +1 -1
  235. package/dist/orchestrator/goal/goal-negotiator.js +23 -3
  236. package/dist/orchestrator/goal/goal-negotiator.js.map +1 -1
  237. package/dist/orchestrator/goal/types/goal.d.ts +282 -0
  238. package/dist/orchestrator/goal/types/goal.d.ts.map +1 -1
  239. package/dist/orchestrator/goal/types/goal.js +20 -0
  240. package/dist/orchestrator/goal/types/goal.js.map +1 -1
  241. package/dist/orchestrator/loop/core-loop/contracts.d.ts +47 -3
  242. package/dist/orchestrator/loop/core-loop/contracts.d.ts.map +1 -1
  243. package/dist/orchestrator/loop/core-loop/contracts.js.map +1 -1
  244. package/dist/orchestrator/loop/core-loop/decision-engine.d.ts.map +1 -1
  245. package/dist/orchestrator/loop/core-loop/decision-engine.js +4 -0
  246. package/dist/orchestrator/loop/core-loop/decision-engine.js.map +1 -1
  247. package/dist/orchestrator/loop/core-loop/dream-review-checkpoint.d.ts +48 -0
  248. package/dist/orchestrator/loop/core-loop/dream-review-checkpoint.d.ts.map +1 -0
  249. package/dist/orchestrator/loop/core-loop/dream-review-checkpoint.js +377 -0
  250. package/dist/orchestrator/loop/core-loop/dream-review-checkpoint.js.map +1 -0
  251. package/dist/orchestrator/loop/core-loop/evidence-ledger.js +1 -1
  252. package/dist/orchestrator/loop/core-loop/evidence-ledger.js.map +1 -1
  253. package/dist/orchestrator/loop/core-loop/iteration-kernel-knowledge.d.ts +7 -0
  254. package/dist/orchestrator/loop/core-loop/iteration-kernel-knowledge.d.ts.map +1 -0
  255. package/dist/orchestrator/loop/core-loop/iteration-kernel-knowledge.js +43 -0
  256. package/dist/orchestrator/loop/core-loop/iteration-kernel-knowledge.js.map +1 -0
  257. package/dist/orchestrator/loop/core-loop/iteration-kernel-wait.d.ts +14 -0
  258. package/dist/orchestrator/loop/core-loop/iteration-kernel-wait.d.ts.map +1 -0
  259. package/dist/orchestrator/loop/core-loop/iteration-kernel-wait.js +41 -0
  260. package/dist/orchestrator/loop/core-loop/iteration-kernel-wait.js.map +1 -0
  261. package/dist/orchestrator/loop/core-loop/iteration-kernel.d.ts +4 -2
  262. package/dist/orchestrator/loop/core-loop/iteration-kernel.d.ts.map +1 -1
  263. package/dist/orchestrator/loop/core-loop/iteration-kernel.js +507 -87
  264. package/dist/orchestrator/loop/core-loop/iteration-kernel.js.map +1 -1
  265. package/dist/orchestrator/loop/core-loop/phase-policy.d.ts.map +1 -1
  266. package/dist/orchestrator/loop/core-loop/phase-policy.js +40 -5
  267. package/dist/orchestrator/loop/core-loop/phase-policy.js.map +1 -1
  268. package/dist/orchestrator/loop/core-loop/phase-runtime.d.ts +2 -0
  269. package/dist/orchestrator/loop/core-loop/phase-runtime.d.ts.map +1 -1
  270. package/dist/orchestrator/loop/core-loop/phase-runtime.js +43 -2
  271. package/dist/orchestrator/loop/core-loop/phase-runtime.js.map +1 -1
  272. package/dist/orchestrator/loop/core-loop/phase-specs.d.ts +969 -2
  273. package/dist/orchestrator/loop/core-loop/phase-specs.d.ts.map +1 -1
  274. package/dist/orchestrator/loop/core-loop/phase-specs.js +198 -0
  275. package/dist/orchestrator/loop/core-loop/phase-specs.js.map +1 -1
  276. package/dist/orchestrator/loop/core-loop/public-research.d.ts +32 -0
  277. package/dist/orchestrator/loop/core-loop/public-research.d.ts.map +1 -0
  278. package/dist/orchestrator/loop/core-loop/public-research.js +112 -0
  279. package/dist/orchestrator/loop/core-loop/public-research.js.map +1 -0
  280. package/dist/orchestrator/loop/core-loop/task-cycle-stall.d.ts +9 -0
  281. package/dist/orchestrator/loop/core-loop/task-cycle-stall.d.ts.map +1 -0
  282. package/dist/orchestrator/loop/core-loop/task-cycle-stall.js +433 -0
  283. package/dist/orchestrator/loop/core-loop/task-cycle-stall.js.map +1 -0
  284. package/dist/orchestrator/loop/core-loop/task-cycle-wait.d.ts +11 -0
  285. package/dist/orchestrator/loop/core-loop/task-cycle-wait.d.ts.map +1 -0
  286. package/dist/orchestrator/loop/core-loop/task-cycle-wait.js +176 -0
  287. package/dist/orchestrator/loop/core-loop/task-cycle-wait.js.map +1 -0
  288. package/dist/orchestrator/loop/core-loop/task-cycle.d.ts +7 -15
  289. package/dist/orchestrator/loop/core-loop/task-cycle.d.ts.map +1 -1
  290. package/dist/orchestrator/loop/core-loop/task-cycle.js +17 -444
  291. package/dist/orchestrator/loop/core-loop/task-cycle.js.map +1 -1
  292. package/dist/orchestrator/loop/core-loop.d.ts +18 -5
  293. package/dist/orchestrator/loop/core-loop.d.ts.map +1 -1
  294. package/dist/orchestrator/loop/core-loop.js +287 -17
  295. package/dist/orchestrator/loop/core-loop.js.map +1 -1
  296. package/dist/orchestrator/loop/loop-report-helper.d.ts.map +1 -1
  297. package/dist/orchestrator/loop/loop-report-helper.js +4 -0
  298. package/dist/orchestrator/loop/loop-report-helper.js.map +1 -1
  299. package/dist/orchestrator/loop/loop-result-types.d.ts +20 -1
  300. package/dist/orchestrator/loop/loop-result-types.d.ts.map +1 -1
  301. package/dist/orchestrator/loop/loop-result-types.js.map +1 -1
  302. package/dist/orchestrator/loop/post-loop-hooks.d.ts +1 -0
  303. package/dist/orchestrator/loop/post-loop-hooks.d.ts.map +1 -1
  304. package/dist/orchestrator/loop/post-loop-hooks.js +34 -1
  305. package/dist/orchestrator/loop/post-loop-hooks.js.map +1 -1
  306. package/dist/orchestrator/loop/run-policy.d.ts +10 -0
  307. package/dist/orchestrator/loop/run-policy.d.ts.map +1 -0
  308. package/dist/orchestrator/loop/run-policy.js +30 -0
  309. package/dist/orchestrator/loop/run-policy.js.map +1 -0
  310. package/dist/orchestrator/strategy/divergent-exploration.d.ts +37 -0
  311. package/dist/orchestrator/strategy/divergent-exploration.d.ts.map +1 -0
  312. package/dist/orchestrator/strategy/divergent-exploration.js +324 -0
  313. package/dist/orchestrator/strategy/divergent-exploration.js.map +1 -0
  314. package/dist/orchestrator/strategy/portfolio-manager.d.ts +3 -2
  315. package/dist/orchestrator/strategy/portfolio-manager.d.ts.map +1 -1
  316. package/dist/orchestrator/strategy/portfolio-manager.js +16 -11
  317. package/dist/orchestrator/strategy/portfolio-manager.js.map +1 -1
  318. package/dist/orchestrator/strategy/portfolio-rebalance.d.ts +1 -1
  319. package/dist/orchestrator/strategy/portfolio-rebalance.d.ts.map +1 -1
  320. package/dist/orchestrator/strategy/portfolio-rebalance.js +31 -9
  321. package/dist/orchestrator/strategy/portfolio-rebalance.js.map +1 -1
  322. package/dist/orchestrator/strategy/strategy-helpers.d.ts +108 -0
  323. package/dist/orchestrator/strategy/strategy-helpers.d.ts.map +1 -1
  324. package/dist/orchestrator/strategy/strategy-helpers.js +34 -2
  325. package/dist/orchestrator/strategy/strategy-helpers.js.map +1 -1
  326. package/dist/orchestrator/strategy/strategy-manager-base.d.ts +31 -2
  327. package/dist/orchestrator/strategy/strategy-manager-base.d.ts.map +1 -1
  328. package/dist/orchestrator/strategy/strategy-manager-base.js +93 -12
  329. package/dist/orchestrator/strategy/strategy-manager-base.js.map +1 -1
  330. package/dist/orchestrator/strategy/strategy-manager.d.ts +1 -11
  331. package/dist/orchestrator/strategy/strategy-manager.d.ts.map +1 -1
  332. package/dist/orchestrator/strategy/strategy-manager.js +78 -19
  333. package/dist/orchestrator/strategy/strategy-manager.js.map +1 -1
  334. package/dist/orchestrator/strategy/types/cross-portfolio.d.ts +2 -2
  335. package/dist/orchestrator/strategy/types/strategy.d.ts +364 -0
  336. package/dist/orchestrator/strategy/types/strategy.d.ts.map +1 -1
  337. package/dist/orchestrator/strategy/types/strategy.js +43 -0
  338. package/dist/orchestrator/strategy/types/strategy.js.map +1 -1
  339. package/dist/platform/dream/dream-activation.d.ts +1 -1
  340. package/dist/platform/dream/dream-consolidator/fs-metrics.d.ts +18 -0
  341. package/dist/platform/dream/dream-consolidator/fs-metrics.d.ts.map +1 -0
  342. package/dist/platform/dream/dream-consolidator/fs-metrics.js +130 -0
  343. package/dist/platform/dream/dream-consolidator/fs-metrics.js.map +1 -0
  344. package/dist/platform/dream/dream-consolidator.d.ts +4 -14
  345. package/dist/platform/dream/dream-consolidator.d.ts.map +1 -1
  346. package/dist/platform/dream/dream-consolidator.js +46 -166
  347. package/dist/platform/dream/dream-consolidator.js.map +1 -1
  348. package/dist/platform/dream/dream-event-workflows.d.ts +6 -6
  349. package/dist/platform/dream/dream-soil-sync.d.ts +1 -0
  350. package/dist/platform/dream/dream-soil-sync.d.ts.map +1 -1
  351. package/dist/platform/dream/dream-soil-sync.js +8 -1
  352. package/dist/platform/dream/dream-soil-sync.js.map +1 -1
  353. package/dist/platform/dream/dream-types.d.ts +94 -89
  354. package/dist/platform/dream/dream-types.d.ts.map +1 -1
  355. package/dist/platform/dream/dream-types.js +1 -0
  356. package/dist/platform/dream/dream-types.js.map +1 -1
  357. package/dist/platform/dream/playbook-memory.d.ts +4 -4
  358. package/dist/platform/drive/metric-history.d.ts +61 -0
  359. package/dist/platform/drive/metric-history.d.ts.map +1 -0
  360. package/dist/platform/drive/metric-history.js +206 -0
  361. package/dist/platform/drive/metric-history.js.map +1 -0
  362. package/dist/platform/drive/progress-predictor.d.ts +7 -0
  363. package/dist/platform/drive/progress-predictor.d.ts.map +1 -1
  364. package/dist/platform/drive/progress-predictor.js +23 -0
  365. package/dist/platform/drive/progress-predictor.js.map +1 -1
  366. package/dist/platform/drive/stall-detector/analysis.d.ts +5 -0
  367. package/dist/platform/drive/stall-detector/analysis.d.ts.map +1 -0
  368. package/dist/platform/drive/stall-detector/analysis.js +55 -0
  369. package/dist/platform/drive/stall-detector/analysis.js.map +1 -0
  370. package/dist/platform/drive/stall-detector/repetitive.d.ts +3 -0
  371. package/dist/platform/drive/stall-detector/repetitive.d.ts.map +1 -0
  372. package/dist/platform/drive/stall-detector/repetitive.js +72 -0
  373. package/dist/platform/drive/stall-detector/repetitive.js.map +1 -0
  374. package/dist/platform/drive/stall-detector/thresholds.d.ts +10 -0
  375. package/dist/platform/drive/stall-detector/thresholds.d.ts.map +1 -0
  376. package/dist/platform/drive/stall-detector/thresholds.js +61 -0
  377. package/dist/platform/drive/stall-detector/thresholds.js.map +1 -0
  378. package/dist/platform/drive/stall-detector.d.ts +5 -21
  379. package/dist/platform/drive/stall-detector.d.ts.map +1 -1
  380. package/dist/platform/drive/stall-detector.js +47 -201
  381. package/dist/platform/drive/stall-detector.js.map +1 -1
  382. package/dist/platform/drive/types/satisficing.d.ts +2 -2
  383. package/dist/platform/drive/types/stall.d.ts +4 -0
  384. package/dist/platform/drive/types/stall.d.ts.map +1 -1
  385. package/dist/platform/drive/types/stall.js +1 -0
  386. package/dist/platform/drive/types/stall.js.map +1 -1
  387. package/dist/platform/knowledge/knowledge-manager-agent-memory.d.ts +55 -0
  388. package/dist/platform/knowledge/knowledge-manager-agent-memory.d.ts.map +1 -0
  389. package/dist/platform/knowledge/knowledge-manager-agent-memory.js +232 -0
  390. package/dist/platform/knowledge/knowledge-manager-agent-memory.js.map +1 -0
  391. package/dist/platform/knowledge/knowledge-manager-internals.d.ts +10 -0
  392. package/dist/platform/knowledge/knowledge-manager-internals.d.ts.map +1 -0
  393. package/dist/platform/knowledge/knowledge-manager-internals.js +43 -0
  394. package/dist/platform/knowledge/knowledge-manager-internals.js.map +1 -0
  395. package/dist/platform/knowledge/knowledge-manager-store.d.ts +13 -0
  396. package/dist/platform/knowledge/knowledge-manager-store.d.ts.map +1 -0
  397. package/dist/platform/knowledge/knowledge-manager-store.js +67 -0
  398. package/dist/platform/knowledge/knowledge-manager-store.js.map +1 -0
  399. package/dist/platform/knowledge/knowledge-manager.d.ts +6 -2
  400. package/dist/platform/knowledge/knowledge-manager.d.ts.map +1 -1
  401. package/dist/platform/knowledge/knowledge-manager.js +43 -344
  402. package/dist/platform/knowledge/knowledge-manager.js.map +1 -1
  403. package/dist/platform/knowledge/memory/memory-lifecycle-storage.d.ts +4 -0
  404. package/dist/platform/knowledge/memory/memory-lifecycle-storage.d.ts.map +1 -0
  405. package/dist/platform/knowledge/memory/memory-lifecycle-storage.js +106 -0
  406. package/dist/platform/knowledge/memory/memory-lifecycle-storage.js.map +1 -0
  407. package/dist/platform/knowledge/memory/memory-lifecycle.d.ts.map +1 -1
  408. package/dist/platform/knowledge/memory/memory-lifecycle.js +6 -112
  409. package/dist/platform/knowledge/memory/memory-lifecycle.js.map +1 -1
  410. package/dist/platform/knowledge/types/learning.d.ts +2 -2
  411. package/dist/platform/observation/capability-detector/prompts.d.ts +18 -0
  412. package/dist/platform/observation/capability-detector/prompts.d.ts.map +1 -0
  413. package/dist/platform/observation/capability-detector/prompts.js +80 -0
  414. package/dist/platform/observation/capability-detector/prompts.js.map +1 -0
  415. package/dist/platform/observation/capability-detector/recommendations.d.ts +5 -0
  416. package/dist/platform/observation/capability-detector/recommendations.d.ts.map +1 -0
  417. package/dist/platform/observation/capability-detector/recommendations.js +76 -0
  418. package/dist/platform/observation/capability-detector/recommendations.js.map +1 -0
  419. package/dist/platform/observation/capability-detector/types.d.ts +112 -0
  420. package/dist/platform/observation/capability-detector/types.d.ts.map +1 -0
  421. package/dist/platform/observation/capability-detector/types.js +75 -0
  422. package/dist/platform/observation/capability-detector/types.js.map +1 -0
  423. package/dist/platform/observation/capability-detector.d.ts +4 -9
  424. package/dist/platform/observation/capability-detector.d.ts.map +1 -1
  425. package/dist/platform/observation/capability-detector.js +12 -212
  426. package/dist/platform/observation/capability-detector.js.map +1 -1
  427. package/dist/platform/observation/context-provider/collector.d.ts +13 -0
  428. package/dist/platform/observation/context-provider/collector.d.ts.map +1 -0
  429. package/dist/platform/observation/context-provider/collector.js +259 -0
  430. package/dist/platform/observation/context-provider/collector.js.map +1 -0
  431. package/dist/platform/observation/context-provider/search-terms.d.ts +2 -0
  432. package/dist/platform/observation/context-provider/search-terms.d.ts.map +1 -0
  433. package/dist/platform/observation/context-provider/search-terms.js +24 -0
  434. package/dist/platform/observation/context-provider/search-terms.js.map +1 -0
  435. package/dist/platform/observation/context-provider/shared.d.ts +17 -0
  436. package/dist/platform/observation/context-provider/shared.d.ts.map +1 -0
  437. package/dist/platform/observation/context-provider/shared.js +87 -0
  438. package/dist/platform/observation/context-provider/shared.js.map +1 -0
  439. package/dist/platform/observation/context-provider.d.ts +3 -28
  440. package/dist/platform/observation/context-provider.d.ts.map +1 -1
  441. package/dist/platform/observation/context-provider.js +7 -395
  442. package/dist/platform/observation/context-provider.js.map +1 -1
  443. package/dist/platform/observation/data-source-adapter.d.ts +1 -0
  444. package/dist/platform/observation/data-source-adapter.d.ts.map +1 -1
  445. package/dist/platform/observation/data-source-adapter.js.map +1 -1
  446. package/dist/platform/observation/observation-datasource.d.ts.map +1 -1
  447. package/dist/platform/observation/observation-datasource.js +2 -0
  448. package/dist/platform/observation/observation-datasource.js.map +1 -1
  449. package/dist/platform/observation/types/data-source.d.ts +153 -9
  450. package/dist/platform/observation/types/data-source.d.ts.map +1 -1
  451. package/dist/platform/observation/types/data-source.js +13 -1
  452. package/dist/platform/observation/types/data-source.js.map +1 -1
  453. package/dist/platform/soil/compiled-memory-projections.d.ts +2 -0
  454. package/dist/platform/soil/compiled-memory-projections.d.ts.map +1 -1
  455. package/dist/platform/soil/compiled-memory-projections.js +59 -0
  456. package/dist/platform/soil/compiled-memory-projections.js.map +1 -1
  457. package/dist/platform/soil/contracts.d.ts +67 -67
  458. package/dist/platform/soil/importer.d.ts +6 -6
  459. package/dist/platform/soil/retriever.d.ts +25 -0
  460. package/dist/platform/soil/retriever.d.ts.map +1 -1
  461. package/dist/platform/soil/retriever.js +94 -5
  462. package/dist/platform/soil/retriever.js.map +1 -1
  463. package/dist/platform/soil/sqlite-repository-helpers.d.ts +80 -0
  464. package/dist/platform/soil/sqlite-repository-helpers.d.ts.map +1 -0
  465. package/dist/platform/soil/sqlite-repository-helpers.js +143 -0
  466. package/dist/platform/soil/sqlite-repository-helpers.js.map +1 -0
  467. package/dist/platform/soil/sqlite-repository-search.d.ts +8 -0
  468. package/dist/platform/soil/sqlite-repository-search.d.ts.map +1 -0
  469. package/dist/platform/soil/sqlite-repository-search.js +367 -0
  470. package/dist/platform/soil/sqlite-repository-search.js.map +1 -0
  471. package/dist/platform/soil/sqlite-repository-storage.d.ts +8 -0
  472. package/dist/platform/soil/sqlite-repository-storage.d.ts.map +1 -0
  473. package/dist/platform/soil/sqlite-repository-storage.js +278 -0
  474. package/dist/platform/soil/sqlite-repository-storage.js.map +1 -0
  475. package/dist/platform/soil/sqlite-repository.d.ts +1 -4
  476. package/dist/platform/soil/sqlite-repository.d.ts.map +1 -1
  477. package/dist/platform/soil/sqlite-repository.js +26 -820
  478. package/dist/platform/soil/sqlite-repository.js.map +1 -1
  479. package/dist/platform/soil/types.d.ts +8 -8
  480. package/dist/platform/time/deadline-finalization.d.ts +57 -0
  481. package/dist/platform/time/deadline-finalization.d.ts.map +1 -0
  482. package/dist/platform/time/deadline-finalization.js +136 -0
  483. package/dist/platform/time/deadline-finalization.js.map +1 -0
  484. package/dist/platform/time/execution-mode.d.ts +29 -0
  485. package/dist/platform/time/execution-mode.d.ts.map +1 -0
  486. package/dist/platform/time/execution-mode.js +84 -0
  487. package/dist/platform/time/execution-mode.js.map +1 -0
  488. package/dist/platform/traits/types/curiosity.d.ts +9 -9
  489. package/dist/platform/traits/types/guardrail.d.ts +6 -6
  490. package/dist/reporting/report-formatters.d.ts.map +1 -1
  491. package/dist/reporting/report-formatters.js +67 -2
  492. package/dist/reporting/report-formatters.js.map +1 -1
  493. package/dist/reporting/reporting-engine.d.ts.map +1 -1
  494. package/dist/reporting/reporting-engine.js +3 -1
  495. package/dist/reporting/reporting-engine.js.map +1 -1
  496. package/dist/reporting/reporting-types.d.ts +4 -0
  497. package/dist/reporting/reporting-types.d.ts.map +1 -1
  498. package/dist/reporting/types/report.d.ts +59 -0
  499. package/dist/reporting/types/report.d.ts.map +1 -1
  500. package/dist/reporting/types/report.js +9 -0
  501. package/dist/reporting/types/report.js.map +1 -1
  502. package/dist/runtime/command-dispatcher.d.ts +2 -0
  503. package/dist/runtime/command-dispatcher.d.ts.map +1 -1
  504. package/dist/runtime/command-dispatcher.js +16 -0
  505. package/dist/runtime/command-dispatcher.js.map +1 -1
  506. package/dist/runtime/confirmation-decision.d.ts +94 -0
  507. package/dist/runtime/confirmation-decision.d.ts.map +1 -0
  508. package/dist/runtime/confirmation-decision.js +109 -0
  509. package/dist/runtime/confirmation-decision.js.map +1 -0
  510. package/dist/runtime/control/daemon-runtime-control-executor.d.ts.map +1 -1
  511. package/dist/runtime/control/daemon-runtime-control-executor.js +31 -1
  512. package/dist/runtime/control/daemon-runtime-control-executor.js.map +1 -1
  513. package/dist/runtime/control/runtime-control-intent.d.ts +9 -1
  514. package/dist/runtime/control/runtime-control-intent.d.ts.map +1 -1
  515. package/dist/runtime/control/runtime-control-intent.js +82 -16
  516. package/dist/runtime/control/runtime-control-intent.js.map +1 -1
  517. package/dist/runtime/control/runtime-control-service.d.ts +35 -1
  518. package/dist/runtime/control/runtime-control-service.d.ts.map +1 -1
  519. package/dist/runtime/control/runtime-control-service.js +285 -5
  520. package/dist/runtime/control/runtime-control-service.js.map +1 -1
  521. package/dist/runtime/daemon/client.d.ts +12 -0
  522. package/dist/runtime/daemon/client.d.ts.map +1 -1
  523. package/dist/runtime/daemon/client.js +9 -0
  524. package/dist/runtime/daemon/client.js.map +1 -1
  525. package/dist/runtime/daemon/index.d.ts +1 -1
  526. package/dist/runtime/daemon/index.d.ts.map +1 -1
  527. package/dist/runtime/daemon/index.js +1 -1
  528. package/dist/runtime/daemon/index.js.map +1 -1
  529. package/dist/runtime/daemon/maintenance.d.ts +2 -10
  530. package/dist/runtime/daemon/maintenance.d.ts.map +1 -1
  531. package/dist/runtime/daemon/maintenance.js +14 -45
  532. package/dist/runtime/daemon/maintenance.js.map +1 -1
  533. package/dist/runtime/daemon/runner-bootstrap.d.ts +25 -0
  534. package/dist/runtime/daemon/runner-bootstrap.d.ts.map +1 -0
  535. package/dist/runtime/daemon/runner-bootstrap.js +77 -0
  536. package/dist/runtime/daemon/runner-bootstrap.js.map +1 -0
  537. package/dist/runtime/daemon/runner-commands.d.ts +13 -9
  538. package/dist/runtime/daemon/runner-commands.d.ts.map +1 -1
  539. package/dist/runtime/daemon/runner-commands.js +272 -21
  540. package/dist/runtime/daemon/runner-commands.js.map +1 -1
  541. package/dist/runtime/daemon/runner-goal-cycle.d.ts.map +1 -1
  542. package/dist/runtime/daemon/runner-goal-cycle.js +62 -6
  543. package/dist/runtime/daemon/runner-goal-cycle.js.map +1 -1
  544. package/dist/runtime/daemon/runner-resident-curiosity.d.ts +12 -0
  545. package/dist/runtime/daemon/runner-resident-curiosity.d.ts.map +1 -0
  546. package/dist/runtime/daemon/runner-resident-curiosity.js +155 -0
  547. package/dist/runtime/daemon/runner-resident-curiosity.js.map +1 -0
  548. package/dist/runtime/daemon/runner-resident-dream.d.ts +20 -0
  549. package/dist/runtime/daemon/runner-resident-dream.d.ts.map +1 -0
  550. package/dist/runtime/daemon/runner-resident-dream.js +148 -0
  551. package/dist/runtime/daemon/runner-resident-dream.js.map +1 -0
  552. package/dist/runtime/daemon/runner-resident-proactive.d.ts +4 -0
  553. package/dist/runtime/daemon/runner-resident-proactive.d.ts.map +1 -0
  554. package/dist/runtime/daemon/runner-resident-proactive.js +113 -0
  555. package/dist/runtime/daemon/runner-resident-proactive.js.map +1 -0
  556. package/dist/runtime/daemon/runner-resident-shared.d.ts +40 -0
  557. package/dist/runtime/daemon/runner-resident-shared.d.ts.map +1 -0
  558. package/dist/runtime/daemon/runner-resident-shared.js +101 -0
  559. package/dist/runtime/daemon/runner-resident-shared.js.map +1 -0
  560. package/dist/runtime/daemon/runner-resident.d.ts +4 -68
  561. package/dist/runtime/daemon/runner-resident.d.ts.map +1 -1
  562. package/dist/runtime/daemon/runner-resident.js +4 -506
  563. package/dist/runtime/daemon/runner-resident.js.map +1 -1
  564. package/dist/runtime/daemon/runner-runtime.d.ts +12 -0
  565. package/dist/runtime/daemon/runner-runtime.d.ts.map +1 -0
  566. package/dist/runtime/daemon/runner-runtime.js +43 -0
  567. package/dist/runtime/daemon/runner-runtime.js.map +1 -0
  568. package/dist/runtime/daemon/runner-startup.d.ts.map +1 -1
  569. package/dist/runtime/daemon/runner-startup.js +15 -6
  570. package/dist/runtime/daemon/runner-startup.js.map +1 -1
  571. package/dist/runtime/daemon/runner.d.ts +14 -23
  572. package/dist/runtime/daemon/runner.d.ts.map +1 -1
  573. package/dist/runtime/daemon/runner.js +40 -110
  574. package/dist/runtime/daemon/runner.js.map +1 -1
  575. package/dist/runtime/daemon/runtime-ownership.d.ts +9 -0
  576. package/dist/runtime/daemon/runtime-ownership.d.ts.map +1 -1
  577. package/dist/runtime/daemon/runtime-ownership.js +248 -1
  578. package/dist/runtime/daemon/runtime-ownership.js.map +1 -1
  579. package/dist/runtime/daemon/wait-deadline-resolver.d.ts +5 -2
  580. package/dist/runtime/daemon/wait-deadline-resolver.d.ts.map +1 -1
  581. package/dist/runtime/daemon/wait-deadline-resolver.js +55 -35
  582. package/dist/runtime/daemon/wait-deadline-resolver.js.map +1 -1
  583. package/dist/runtime/dream-sidecar-review.d.ts +92 -0
  584. package/dist/runtime/dream-sidecar-review.d.ts.map +1 -0
  585. package/dist/runtime/dream-sidecar-review.js +495 -0
  586. package/dist/runtime/dream-sidecar-review.js.map +1 -0
  587. package/dist/runtime/event/dispatcher.d.ts +0 -2
  588. package/dist/runtime/event/dispatcher.d.ts.map +1 -1
  589. package/dist/runtime/event/dispatcher.js +0 -4
  590. package/dist/runtime/event/dispatcher.js.map +1 -1
  591. package/dist/runtime/event/server-command-handler.d.ts +2 -4
  592. package/dist/runtime/event/server-command-handler.d.ts.map +1 -1
  593. package/dist/runtime/event/server-command-handler.js +36 -6
  594. package/dist/runtime/event/server-command-handler.js.map +1 -1
  595. package/dist/runtime/event/server-snapshot-reader.d.ts +15 -1
  596. package/dist/runtime/event/server-snapshot-reader.d.ts.map +1 -1
  597. package/dist/runtime/event/server-snapshot-reader.js +66 -2
  598. package/dist/runtime/event/server-snapshot-reader.js.map +1 -1
  599. package/dist/runtime/event/server-types.d.ts +7 -0
  600. package/dist/runtime/event/server-types.d.ts.map +1 -1
  601. package/dist/runtime/event/server.d.ts +5 -0
  602. package/dist/runtime/event/server.d.ts.map +1 -1
  603. package/dist/runtime/event/server.js +43 -11
  604. package/dist/runtime/event/server.js.map +1 -1
  605. package/dist/runtime/evidence-answer.d.ts +41 -0
  606. package/dist/runtime/evidence-answer.d.ts.map +1 -0
  607. package/dist/runtime/evidence-answer.js +366 -0
  608. package/dist/runtime/evidence-answer.js.map +1 -0
  609. package/dist/runtime/executor/goal-worker.d.ts +6 -2
  610. package/dist/runtime/executor/goal-worker.d.ts.map +1 -1
  611. package/dist/runtime/executor/goal-worker.js +7 -2
  612. package/dist/runtime/executor/goal-worker.js.map +1 -1
  613. package/dist/runtime/executor/loop-supervisor.d.ts +7 -0
  614. package/dist/runtime/executor/loop-supervisor.d.ts.map +1 -1
  615. package/dist/runtime/executor/loop-supervisor.js +72 -17
  616. package/dist/runtime/executor/loop-supervisor.js.map +1 -1
  617. package/dist/runtime/guardrails/backpressure-controller.d.ts +32 -0
  618. package/dist/runtime/guardrails/backpressure-controller.d.ts.map +1 -0
  619. package/dist/runtime/guardrails/backpressure-controller.js +88 -0
  620. package/dist/runtime/guardrails/backpressure-controller.js.map +1 -0
  621. package/dist/runtime/guardrails/circuit-breaker.d.ts +32 -0
  622. package/dist/runtime/guardrails/circuit-breaker.d.ts.map +1 -0
  623. package/dist/runtime/guardrails/circuit-breaker.js +88 -0
  624. package/dist/runtime/guardrails/circuit-breaker.js.map +1 -0
  625. package/dist/runtime/guardrails/guardrail-store.d.ts +23 -0
  626. package/dist/runtime/guardrails/guardrail-store.d.ts.map +1 -0
  627. package/dist/runtime/guardrails/guardrail-store.js +95 -0
  628. package/dist/runtime/guardrails/guardrail-store.js.map +1 -0
  629. package/dist/runtime/guardrails/index.d.ts +4 -0
  630. package/dist/runtime/guardrails/index.d.ts.map +1 -0
  631. package/dist/runtime/guardrails/index.js +4 -0
  632. package/dist/runtime/guardrails/index.js.map +1 -0
  633. package/dist/runtime/interactive-automation/browser-session-store.d.ts +43 -0
  634. package/dist/runtime/interactive-automation/browser-session-store.d.ts.map +1 -0
  635. package/dist/runtime/interactive-automation/browser-session-store.js +104 -0
  636. package/dist/runtime/interactive-automation/browser-session-store.js.map +1 -0
  637. package/dist/runtime/interactive-automation/failure-classifier.d.ts +12 -0
  638. package/dist/runtime/interactive-automation/failure-classifier.d.ts.map +1 -0
  639. package/dist/runtime/interactive-automation/failure-classifier.js +50 -0
  640. package/dist/runtime/interactive-automation/failure-classifier.js.map +1 -0
  641. package/dist/runtime/interactive-automation/index.d.ts +2 -0
  642. package/dist/runtime/interactive-automation/index.d.ts.map +1 -1
  643. package/dist/runtime/interactive-automation/index.js +2 -0
  644. package/dist/runtime/interactive-automation/index.js.map +1 -1
  645. package/dist/runtime/interactive-automation/providers/manus-browser.d.ts.map +1 -1
  646. package/dist/runtime/interactive-automation/providers/manus-browser.js +17 -1
  647. package/dist/runtime/interactive-automation/providers/manus-browser.js.map +1 -1
  648. package/dist/runtime/interactive-automation/types.d.ts +4 -0
  649. package/dist/runtime/interactive-automation/types.d.ts.map +1 -1
  650. package/dist/runtime/interactive-automation/types.js.map +1 -1
  651. package/dist/runtime/notification-routing.d.ts +45 -2
  652. package/dist/runtime/notification-routing.d.ts.map +1 -1
  653. package/dist/runtime/notification-routing.js +196 -79
  654. package/dist/runtime/notification-routing.js.map +1 -1
  655. package/dist/runtime/run-spec/confirmation.d.ts +34 -0
  656. package/dist/runtime/run-spec/confirmation.d.ts.map +1 -0
  657. package/dist/runtime/run-spec/confirmation.js +176 -0
  658. package/dist/runtime/run-spec/confirmation.js.map +1 -0
  659. package/dist/runtime/run-spec/derive.d.ts +284 -0
  660. package/dist/runtime/run-spec/derive.d.ts.map +1 -0
  661. package/dist/runtime/run-spec/derive.js +379 -0
  662. package/dist/runtime/run-spec/derive.js.map +1 -0
  663. package/dist/runtime/run-spec/index.d.ts +5 -0
  664. package/dist/runtime/run-spec/index.d.ts.map +1 -0
  665. package/dist/runtime/run-spec/index.js +5 -0
  666. package/dist/runtime/run-spec/index.js.map +1 -0
  667. package/dist/runtime/run-spec/store.d.ts +11 -0
  668. package/dist/runtime/run-spec/store.d.ts.map +1 -0
  669. package/dist/runtime/run-spec/store.js +36 -0
  670. package/dist/runtime/run-spec/store.js.map +1 -0
  671. package/dist/runtime/run-spec/types.d.ts +495 -0
  672. package/dist/runtime/run-spec/types.d.ts.map +1 -0
  673. package/dist/runtime/run-spec/types.js +87 -0
  674. package/dist/runtime/run-spec/types.js.map +1 -0
  675. package/dist/runtime/schedule/engine-cron-reflection.d.ts +31 -0
  676. package/dist/runtime/schedule/engine-cron-reflection.d.ts.map +1 -0
  677. package/dist/runtime/schedule/engine-cron-reflection.js +229 -0
  678. package/dist/runtime/schedule/engine-cron-reflection.js.map +1 -0
  679. package/dist/runtime/schedule/engine-execution.d.ts +48 -0
  680. package/dist/runtime/schedule/engine-execution.d.ts.map +1 -0
  681. package/dist/runtime/schedule/engine-execution.js +424 -0
  682. package/dist/runtime/schedule/engine-execution.js.map +1 -0
  683. package/dist/runtime/schedule/engine-heartbeat.d.ts +5 -0
  684. package/dist/runtime/schedule/engine-heartbeat.d.ts.map +1 -0
  685. package/dist/runtime/schedule/engine-heartbeat.js +104 -0
  686. package/dist/runtime/schedule/engine-heartbeat.js.map +1 -0
  687. package/dist/runtime/schedule/engine-layers.d.ts +4 -1
  688. package/dist/runtime/schedule/engine-layers.d.ts.map +1 -1
  689. package/dist/runtime/schedule/engine-layers.js +15 -229
  690. package/dist/runtime/schedule/engine-layers.js.map +1 -1
  691. package/dist/runtime/schedule/engine-mutations.d.ts +37 -0
  692. package/dist/runtime/schedule/engine-mutations.d.ts.map +1 -0
  693. package/dist/runtime/schedule/engine-mutations.js +263 -0
  694. package/dist/runtime/schedule/engine-mutations.js.map +1 -0
  695. package/dist/runtime/schedule/engine.d.ts +13 -39
  696. package/dist/runtime/schedule/engine.d.ts.map +1 -1
  697. package/dist/runtime/schedule/engine.js +65 -810
  698. package/dist/runtime/schedule/engine.js.map +1 -1
  699. package/dist/runtime/schedule/history.d.ts +20 -4
  700. package/dist/runtime/schedule/history.d.ts.map +1 -1
  701. package/dist/runtime/schedule/history.js +8 -0
  702. package/dist/runtime/schedule/history.js.map +1 -1
  703. package/dist/runtime/schedule/index.d.ts +1 -0
  704. package/dist/runtime/schedule/index.d.ts.map +1 -1
  705. package/dist/runtime/schedule/index.js +1 -0
  706. package/dist/runtime/schedule/index.js.map +1 -1
  707. package/dist/runtime/schedule/legacy-cron-migration.d.ts +9 -0
  708. package/dist/runtime/schedule/legacy-cron-migration.d.ts.map +1 -0
  709. package/dist/runtime/schedule/legacy-cron-migration.js +89 -0
  710. package/dist/runtime/schedule/legacy-cron-migration.js.map +1 -0
  711. package/dist/runtime/schedule/wait-projection.d.ts +6 -0
  712. package/dist/runtime/schedule/wait-projection.d.ts.map +1 -0
  713. package/dist/runtime/schedule/wait-projection.js +102 -0
  714. package/dist/runtime/schedule/wait-projection.js.map +1 -0
  715. package/dist/runtime/session-registry/registry-helpers.d.ts +34 -0
  716. package/dist/runtime/session-registry/registry-helpers.d.ts.map +1 -0
  717. package/dist/runtime/session-registry/registry-helpers.js +241 -0
  718. package/dist/runtime/session-registry/registry-helpers.js.map +1 -0
  719. package/dist/runtime/session-registry/registry.d.ts.map +1 -1
  720. package/dist/runtime/session-registry/registry.js +16 -243
  721. package/dist/runtime/session-registry/registry.js.map +1 -1
  722. package/dist/runtime/session-registry/types.d.ts +138 -130
  723. package/dist/runtime/session-registry/types.d.ts.map +1 -1
  724. package/dist/runtime/session-registry/types.js +2 -0
  725. package/dist/runtime/session-registry/types.js.map +1 -1
  726. package/dist/runtime/store/artifact-retention.d.ts +44 -0
  727. package/dist/runtime/store/artifact-retention.d.ts.map +1 -0
  728. package/dist/runtime/store/artifact-retention.js +263 -0
  729. package/dist/runtime/store/artifact-retention.js.map +1 -0
  730. package/dist/runtime/store/background-run-store.d.ts +1 -0
  731. package/dist/runtime/store/background-run-store.d.ts.map +1 -1
  732. package/dist/runtime/store/background-run-store.js +1 -0
  733. package/dist/runtime/store/background-run-store.js.map +1 -1
  734. package/dist/runtime/store/budget-store.d.ts +442 -0
  735. package/dist/runtime/store/budget-store.d.ts.map +1 -0
  736. package/dist/runtime/store/budget-store.js +318 -0
  737. package/dist/runtime/store/budget-store.js.map +1 -0
  738. package/dist/runtime/store/dream-checkpoints.d.ts +9 -0
  739. package/dist/runtime/store/dream-checkpoints.d.ts.map +1 -0
  740. package/dist/runtime/store/dream-checkpoints.js +16 -0
  741. package/dist/runtime/store/dream-checkpoints.js.map +1 -0
  742. package/dist/runtime/store/evaluator-results.d.ts +97 -0
  743. package/dist/runtime/store/evaluator-results.d.ts.map +1 -0
  744. package/dist/runtime/store/evaluator-results.js +355 -0
  745. package/dist/runtime/store/evaluator-results.js.map +1 -0
  746. package/dist/runtime/store/evidence-ledger.d.ts +5298 -0
  747. package/dist/runtime/store/evidence-ledger.d.ts.map +1 -0
  748. package/dist/runtime/store/evidence-ledger.js +1452 -0
  749. package/dist/runtime/store/evidence-ledger.js.map +1 -0
  750. package/dist/runtime/store/experiment-queue-store.d.ts +1164 -0
  751. package/dist/runtime/store/experiment-queue-store.d.ts.map +1 -0
  752. package/dist/runtime/store/experiment-queue-store.js +341 -0
  753. package/dist/runtime/store/experiment-queue-store.js.map +1 -0
  754. package/dist/runtime/store/health-store.d.ts.map +1 -1
  755. package/dist/runtime/store/health-store.js +6 -0
  756. package/dist/runtime/store/health-store.js.map +1 -1
  757. package/dist/runtime/store/index.d.ts +25 -2
  758. package/dist/runtime/store/index.d.ts.map +1 -1
  759. package/dist/runtime/store/index.js +13 -1
  760. package/dist/runtime/store/index.js.map +1 -1
  761. package/dist/runtime/store/metric-history.d.ts +10 -0
  762. package/dist/runtime/store/metric-history.d.ts.map +1 -0
  763. package/dist/runtime/store/metric-history.js +56 -0
  764. package/dist/runtime/store/metric-history.js.map +1 -0
  765. package/dist/runtime/store/operator-handoff-store.d.ts +179 -0
  766. package/dist/runtime/store/operator-handoff-store.d.ts.map +1 -0
  767. package/dist/runtime/store/operator-handoff-store.js +120 -0
  768. package/dist/runtime/store/operator-handoff-store.js.map +1 -0
  769. package/dist/runtime/store/postmortem-report.d.ts +485 -0
  770. package/dist/runtime/store/postmortem-report.d.ts.map +1 -0
  771. package/dist/runtime/store/postmortem-report.js +561 -0
  772. package/dist/runtime/store/postmortem-report.js.map +1 -0
  773. package/dist/runtime/store/reproducibility-manifest.d.ts +565 -0
  774. package/dist/runtime/store/reproducibility-manifest.d.ts.map +1 -0
  775. package/dist/runtime/store/reproducibility-manifest.js +392 -0
  776. package/dist/runtime/store/reproducibility-manifest.js.map +1 -0
  777. package/dist/runtime/store/research-evidence.d.ts +8 -0
  778. package/dist/runtime/store/research-evidence.d.ts.map +1 -0
  779. package/dist/runtime/store/research-evidence.js +15 -0
  780. package/dist/runtime/store/research-evidence.js.map +1 -0
  781. package/dist/runtime/store/runtime-operation-schemas.d.ts +80 -34
  782. package/dist/runtime/store/runtime-operation-schemas.d.ts.map +1 -1
  783. package/dist/runtime/store/runtime-operation-schemas.js +16 -1
  784. package/dist/runtime/store/runtime-operation-schemas.js.map +1 -1
  785. package/dist/runtime/store/runtime-paths.d.ts +25 -0
  786. package/dist/runtime/store/runtime-paths.d.ts.map +1 -1
  787. package/dist/runtime/store/runtime-paths.js +73 -0
  788. package/dist/runtime/store/runtime-paths.js.map +1 -1
  789. package/dist/runtime/store/runtime-schemas.d.ts +1934 -15
  790. package/dist/runtime/store/runtime-schemas.d.ts.map +1 -1
  791. package/dist/runtime/store/runtime-schemas.js +201 -0
  792. package/dist/runtime/store/runtime-schemas.js.map +1 -1
  793. package/dist/runtime/store/safe-pause-store.d.ts +28 -0
  794. package/dist/runtime/store/safe-pause-store.d.ts.map +1 -0
  795. package/dist/runtime/store/safe-pause-store.js +103 -0
  796. package/dist/runtime/store/safe-pause-store.js.map +1 -0
  797. package/dist/runtime/types/daemon.d.ts +234 -14
  798. package/dist/runtime/types/daemon.d.ts.map +1 -1
  799. package/dist/runtime/types/daemon.js +29 -2
  800. package/dist/runtime/types/daemon.js.map +1 -1
  801. package/dist/runtime/types/envelope.d.ts +10 -10
  802. package/dist/runtime/types/hook.d.ts +9 -9
  803. package/dist/runtime/types/notification.d.ts +6 -6
  804. package/dist/runtime/types/plugin.d.ts +2 -2
  805. package/dist/runtime/types/schedule.d.ts +162 -54
  806. package/dist/runtime/types/schedule.d.ts.map +1 -1
  807. package/dist/runtime/types/schedule.js +15 -1
  808. package/dist/runtime/types/schedule.js.map +1 -1
  809. package/dist/runtime/types/trigger.d.ts +2 -2
  810. package/dist/tools/automation/InteractiveAutomationTools.d.ts +10 -0
  811. package/dist/tools/automation/InteractiveAutomationTools.d.ts.map +1 -1
  812. package/dist/tools/automation/InteractiveAutomationTools.js +139 -8
  813. package/dist/tools/automation/InteractiveAutomationTools.js.map +1 -1
  814. package/dist/tools/builtin/exports.d.ts +2 -1
  815. package/dist/tools/builtin/exports.d.ts.map +1 -1
  816. package/dist/tools/builtin/exports.js +2 -1
  817. package/dist/tools/builtin/exports.js.map +1 -1
  818. package/dist/tools/builtin/factory.d.ts +7 -0
  819. package/dist/tools/builtin/factory.d.ts.map +1 -1
  820. package/dist/tools/builtin/factory.js +26 -3
  821. package/dist/tools/builtin/factory.js.map +1 -1
  822. package/dist/tools/fs/FileValidationTool/protected-path-policy.d.ts +1 -0
  823. package/dist/tools/fs/FileValidationTool/protected-path-policy.d.ts.map +1 -1
  824. package/dist/tools/fs/FileValidationTool/protected-path-policy.js +17 -4
  825. package/dist/tools/fs/FileValidationTool/protected-path-policy.js.map +1 -1
  826. package/dist/tools/fs/ListDirTool/ListDirTool.js +1 -1
  827. package/dist/tools/fs/ListDirTool/ListDirTool.js.map +1 -1
  828. package/dist/tools/kaggle/KaggleExperimentTools.d.ts +792 -8
  829. package/dist/tools/kaggle/KaggleExperimentTools.d.ts.map +1 -1
  830. package/dist/tools/kaggle/KaggleExperimentTools.js +284 -19
  831. package/dist/tools/kaggle/KaggleExperimentTools.js.map +1 -1
  832. package/dist/tools/kaggle/KaggleSubmissionTools.d.ts +18 -12
  833. package/dist/tools/kaggle/KaggleSubmissionTools.d.ts.map +1 -1
  834. package/dist/tools/kaggle/KaggleSubmissionTools.js +23 -4
  835. package/dist/tools/kaggle/KaggleSubmissionTools.js.map +1 -1
  836. package/dist/tools/kaggle/KaggleWorkspacePrepareTool.d.ts +28 -9
  837. package/dist/tools/kaggle/KaggleWorkspacePrepareTool.d.ts.map +1 -1
  838. package/dist/tools/kaggle/KaggleWorkspacePrepareTool.js +182 -4
  839. package/dist/tools/kaggle/KaggleWorkspacePrepareTool.js.map +1 -1
  840. package/dist/tools/kaggle/index.d.ts +1 -1
  841. package/dist/tools/kaggle/index.d.ts.map +1 -1
  842. package/dist/tools/kaggle/index.js +1 -1
  843. package/dist/tools/kaggle/index.js.map +1 -1
  844. package/dist/tools/kaggle/metrics.d.ts +845 -4
  845. package/dist/tools/kaggle/metrics.d.ts.map +1 -1
  846. package/dist/tools/kaggle/metrics.js +410 -1
  847. package/dist/tools/kaggle/metrics.js.map +1 -1
  848. package/dist/tools/kaggle/paths.d.ts.map +1 -1
  849. package/dist/tools/kaggle/paths.js +6 -0
  850. package/dist/tools/kaggle/paths.js.map +1 -1
  851. package/dist/tools/mutation/ConfigureNotificationRoutingTool/ConfigureNotificationRoutingTool.d.ts +6 -0
  852. package/dist/tools/mutation/ConfigureNotificationRoutingTool/ConfigureNotificationRoutingTool.d.ts.map +1 -1
  853. package/dist/tools/mutation/ConfigureNotificationRoutingTool/ConfigureNotificationRoutingTool.js +9 -2
  854. package/dist/tools/mutation/ConfigureNotificationRoutingTool/ConfigureNotificationRoutingTool.js.map +1 -1
  855. package/dist/tools/mutation/TaskCreateTool/TaskCreateTool.d.ts +4 -4
  856. package/dist/tools/network/McpStdioTool/McpStdioTool.d.ts +4 -4
  857. package/dist/tools/query/CodeSearchRepairTool/CodeSearchRepairTool.d.ts.map +1 -1
  858. package/dist/tools/query/CodeSearchRepairTool/CodeSearchRepairTool.js +23 -2
  859. package/dist/tools/query/CodeSearchRepairTool/CodeSearchRepairTool.js.map +1 -1
  860. package/dist/tools/query/CodeSearchTool/CodeSearchTool.d.ts.map +1 -1
  861. package/dist/tools/query/CodeSearchTool/CodeSearchTool.js +24 -2
  862. package/dist/tools/query/CodeSearchTool/CodeSearchTool.js.map +1 -1
  863. package/dist/tools/query/MemoryRecallTool/MemoryRecallTool.d.ts +2 -2
  864. package/dist/tools/query/SoilQueryTool/SoilQueryTool.d.ts.map +1 -1
  865. package/dist/tools/query/SoilQueryTool/SoilQueryTool.js +43 -9
  866. package/dist/tools/query/SoilQueryTool/SoilQueryTool.js.map +1 -1
  867. package/dist/tools/query/code-search-root.d.ts +8 -0
  868. package/dist/tools/query/code-search-root.d.ts.map +1 -0
  869. package/dist/tools/query/code-search-root.js +41 -0
  870. package/dist/tools/query/code-search-root.js.map +1 -0
  871. package/dist/tools/query/runtime-dream-review-tool.d.ts +34 -0
  872. package/dist/tools/query/runtime-dream-review-tool.d.ts.map +1 -0
  873. package/dist/tools/query/runtime-dream-review-tool.js +62 -0
  874. package/dist/tools/query/runtime-dream-review-tool.js.map +1 -0
  875. package/dist/tools/query/runtime-session-tools.d.ts +560 -0
  876. package/dist/tools/query/runtime-session-tools.d.ts.map +1 -0
  877. package/dist/tools/query/runtime-session-tools.js +1017 -0
  878. package/dist/tools/query/runtime-session-tools.js.map +1 -0
  879. package/dist/tools/runtime/LongRunningRuntimeTools.d.ts +821 -0
  880. package/dist/tools/runtime/LongRunningRuntimeTools.d.ts.map +1 -0
  881. package/dist/tools/runtime/LongRunningRuntimeTools.js +905 -0
  882. package/dist/tools/runtime/LongRunningRuntimeTools.js.map +1 -0
  883. package/dist/tools/schedule/CreateScheduleTool/CreateScheduleTool.d.ts +62 -32
  884. package/dist/tools/schedule/CreateScheduleTool/CreateScheduleTool.d.ts.map +1 -1
  885. package/dist/tools/schedule/UpdateScheduleTool/UpdateScheduleTool.d.ts +78 -44
  886. package/dist/tools/schedule/UpdateScheduleTool/UpdateScheduleTool.d.ts.map +1 -1
  887. package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.d.ts +1 -0
  888. package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.d.ts.map +1 -1
  889. package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.js +11 -0
  890. package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.js.map +1 -1
  891. package/dist/tools/system/ShellTool/ShellTool.d.ts.map +1 -1
  892. package/dist/tools/system/ShellTool/ShellTool.js +2 -1
  893. package/dist/tools/system/ShellTool/ShellTool.js.map +1 -1
  894. package/dist/tools/system/TestRunnerTool/TestRunnerTool.d.ts +4 -4
  895. package/dist/tools/types.d.ts +2 -0
  896. package/dist/tools/types.d.ts.map +1 -1
  897. package/dist/tools/types.js.map +1 -1
  898. package/package.json +2 -1
  899. package/dist/base/types/cron.d.ts +0 -2
  900. package/dist/base/types/cron.d.ts.map +0 -1
  901. package/dist/base/types/cron.js +0 -3
  902. package/dist/base/types/cron.js.map +0 -1
  903. package/dist/runtime/cron-scheduler.d.ts +0 -13
  904. package/dist/runtime/cron-scheduler.d.ts.map +0 -1
  905. package/dist/runtime/cron-scheduler.js +0 -90
  906. package/dist/runtime/cron-scheduler.js.map +0 -1
  907. package/dist/runtime/types/cron.d.ts +0 -59
  908. package/dist/runtime/types/cron.d.ts.map +0 -1
  909. package/dist/runtime/types/cron.js +0 -13
  910. package/dist/runtime/types/cron.js.map +0 -1
@@ -0,0 +1,1452 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import * as fsp from "node:fs/promises";
3
+ import * as path from "node:path";
4
+ import { z } from "zod";
5
+ import { createRuntimeStorePaths, ensureRuntimeStorePaths, } from "./runtime-paths.js";
6
+ import { summarizeEvidenceMetricTrends } from "./metric-history.js";
7
+ import { summarizeEvidenceEvaluatorResults, } from "./evaluator-results.js";
8
+ import { summarizeEvidenceResearchMemos, } from "./research-evidence.js";
9
+ import { summarizeEvidenceDreamCheckpoints, } from "./dream-checkpoints.js";
10
+ import { summarizeArtifactRetention, RuntimeArtifactRetentionClassSchema, } from "./artifact-retention.js";
11
+ export const RuntimeEvidenceOutcomeSchema = z.enum([
12
+ "improved",
13
+ "regressed",
14
+ "inconclusive",
15
+ "failed",
16
+ "blocked",
17
+ "continued",
18
+ ]);
19
+ export const RuntimeEvidenceEntryKindSchema = z.enum([
20
+ "observation",
21
+ "strategy",
22
+ "task_generation",
23
+ "execution",
24
+ "verification",
25
+ "decision",
26
+ "metric",
27
+ "evaluator",
28
+ "research",
29
+ "dream_checkpoint",
30
+ "artifact",
31
+ "failure",
32
+ "other",
33
+ ]);
34
+ export const RuntimeEvidenceArtifactRefSchema = z.object({
35
+ label: z.string().min(1),
36
+ path: z.string().min(1).optional(),
37
+ state_relative_path: z.string().min(1).optional(),
38
+ url: z.string().url().optional(),
39
+ kind: z.enum(["log", "metrics", "report", "diff", "url", "other"]).default("other"),
40
+ retention_class: RuntimeArtifactRetentionClassSchema.optional(),
41
+ size_bytes: z.number().int().nonnegative().optional(),
42
+ source: z.string().min(1).optional(),
43
+ dependency_refs: z.array(z.string().min(1)).optional(),
44
+ }).strict();
45
+ export const RuntimeEvidenceMetricSchema = z.object({
46
+ label: z.string().min(1),
47
+ value: z.union([z.string(), z.number(), z.boolean(), z.null()]).optional(),
48
+ unit: z.string().min(1).optional(),
49
+ direction: z.enum(["maximize", "minimize", "neutral"]).optional(),
50
+ confidence: z.number().min(0).max(1).optional(),
51
+ observed_at: z.string().datetime().optional(),
52
+ source: z.string().min(1).optional(),
53
+ summary: z.string().min(1).optional(),
54
+ }).strict();
55
+ export const RuntimeEvidenceCandidateDispositionSchema = z.enum(["retained", "promoted", "retired"]);
56
+ export const RuntimeEvidenceCandidateLineageSchema = z.object({
57
+ parent_candidate_id: z.string().min(1).optional(),
58
+ source_candidate_id: z.string().min(1).optional(),
59
+ source_strategy_id: z.string().min(1).optional(),
60
+ source_strategy: z.string().min(1).optional(),
61
+ strategy_family: z.string().min(1),
62
+ feature_lineage: z.array(z.string().min(1)).default([]),
63
+ model_lineage: z.array(z.string().min(1)).default([]),
64
+ config_lineage: z.array(z.string().min(1)).default([]),
65
+ seed_lineage: z.array(z.string().min(1)).default([]),
66
+ fold_lineage: z.array(z.string().min(1)).default([]),
67
+ postprocess_lineage: z.array(z.string().min(1)).default([]),
68
+ notes: z.string().min(1).optional(),
69
+ }).strict();
70
+ export const RuntimeEvidenceCandidateSimilaritySchema = z.object({
71
+ candidate_id: z.string().min(1),
72
+ similarity: z.number().min(0).max(1),
73
+ signal: z.enum(["declared", "lineage", "metric_correlation", "artifact_overlap", "other"]).default("declared"),
74
+ summary: z.string().min(1).optional(),
75
+ }).strict();
76
+ export const RuntimeEvidenceCandidateNearMissReasonSchema = z.enum([
77
+ "close_to_best",
78
+ "stability",
79
+ "novelty",
80
+ "weak_dimension_improvement",
81
+ "complementarity",
82
+ "ensemble_potential",
83
+ ]);
84
+ export const RuntimeEvidenceCandidateNearMissSchema = z.object({
85
+ status: z.enum(["retained", "promoted", "rejected"]).default("retained"),
86
+ reason_to_keep: z.array(RuntimeEvidenceCandidateNearMissReasonSchema).min(1),
87
+ margin_to_best: z.number().min(0).optional(),
88
+ weak_dimensions: z.array(z.string().min(1)).default([]),
89
+ complementary_candidate_ids: z.array(z.string().min(1)).default([]),
90
+ follow_up: z.object({
91
+ title: z.string().min(1),
92
+ rationale: z.string().min(1),
93
+ target_dimensions: z.array(z.string().min(1)).default([]),
94
+ expected_evidence_gain: z.string().min(1).optional(),
95
+ }).strict().optional(),
96
+ evidence_refs: z.array(z.string().min(1)).default([]),
97
+ summary: z.string().min(1).optional(),
98
+ }).strict();
99
+ export const RuntimeEvidenceCandidateRecordSchema = z.object({
100
+ candidate_id: z.string().min(1),
101
+ label: z.string().min(1).optional(),
102
+ lineage: RuntimeEvidenceCandidateLineageSchema,
103
+ metrics: z.array(RuntimeEvidenceMetricSchema).default([]),
104
+ artifacts: z.array(RuntimeEvidenceArtifactRefSchema).default([]),
105
+ similarity: z.array(RuntimeEvidenceCandidateSimilaritySchema).default([]),
106
+ robustness: z.object({
107
+ stability_score: z.number().min(0).max(1).optional(),
108
+ diversity_score: z.number().min(0).max(1).optional(),
109
+ risk_penalty: z.number().min(0).max(1).optional(),
110
+ robust_score: z.number().min(0).max(1).optional(),
111
+ evidence_confidence: z.number().min(0).max(1).optional(),
112
+ repeated_evaluations: z.number().int().nonnegative().optional(),
113
+ mean_score: z.number().optional(),
114
+ max_score: z.number().optional(),
115
+ score_stddev: z.number().min(0).optional(),
116
+ fold_score_range: z.number().min(0).optional(),
117
+ seed_score_range: z.number().min(0).optional(),
118
+ weak_dimensions: z.array(z.string().min(1)).default([]),
119
+ provenance_refs: z.array(z.string().min(1)).default([]),
120
+ summary: z.string().min(1).optional(),
121
+ }).strict().optional(),
122
+ near_miss: RuntimeEvidenceCandidateNearMissSchema.optional(),
123
+ disposition: RuntimeEvidenceCandidateDispositionSchema.default("retained"),
124
+ disposition_reason: z.string().min(1).optional(),
125
+ produced_at: z.string().datetime().optional(),
126
+ }).strict();
127
+ export const RuntimeEvidenceEvaluatorSignalSchema = z.enum(["local", "external"]);
128
+ export const RuntimeEvidenceEvaluatorStatusSchema = z.enum([
129
+ "pending",
130
+ "ready",
131
+ "approval_required",
132
+ "submitted",
133
+ "passed",
134
+ "succeeded",
135
+ "completed",
136
+ "failed",
137
+ "regressed",
138
+ "blocked",
139
+ "unknown",
140
+ ]);
141
+ export const RuntimeEvidenceEvaluatorPublishActionSchema = z.object({
142
+ id: z.string().min(1),
143
+ label: z.string().min(1),
144
+ tool_name: z.string().min(1).optional(),
145
+ payload_ref: z.string().min(1).optional(),
146
+ approval_required: z.literal(true).default(true),
147
+ status: z.enum(["approval_required", "approved", "submitted", "completed", "blocked"]).optional(),
148
+ }).strict();
149
+ export const RuntimeEvidenceEvaluatorValidationSchema = z.object({
150
+ status: z.enum(["pending", "passed", "failed", "blocked", "unknown"]).default("unknown"),
151
+ command: z.string().min(1).optional(),
152
+ summary: z.string().min(1).optional(),
153
+ }).strict();
154
+ export const RuntimeEvidenceEvaluatorProvenanceSchema = z.object({
155
+ kind: z.enum(["local_command", "external_url", "ci", "benchmark", "human_review", "other"]).default("other"),
156
+ command: z.string().min(1).optional(),
157
+ url: z.string().url().optional(),
158
+ run_id: z.string().min(1).optional(),
159
+ external_id: z.string().min(1).optional(),
160
+ raw_ref: z.string().min(1).optional(),
161
+ retrieved_at: z.string().datetime().optional(),
162
+ }).strict();
163
+ export const RuntimeEvidenceEvaluatorBudgetSchema = z.object({
164
+ policy_id: z.string().min(1).optional(),
165
+ max_attempts: z.number().int().positive().optional(),
166
+ used_attempts: z.number().int().nonnegative().optional(),
167
+ remaining_attempts: z.number().int().nonnegative(),
168
+ approval_required: z.boolean().default(true),
169
+ deadline_at: z.string().datetime().optional(),
170
+ phase: z.enum(["exploration", "consolidation", "finalization", "other"]).optional(),
171
+ portfolio_policy: z.object({
172
+ diversified_portfolio_required: z.boolean().default(false),
173
+ reserve_for_finalization: z.boolean().default(false),
174
+ min_strategy_families: z.number().int().positive().optional(),
175
+ }).strict().optional(),
176
+ }).strict();
177
+ export const RuntimeEvidenceEvaluatorCandidateSnapshotSchema = z.object({
178
+ evidence_entry_id: z.string().min(1).optional(),
179
+ primary_metric_label: z.string().min(1).optional(),
180
+ local_metrics: z.array(RuntimeEvidenceMetricSchema).default([]),
181
+ robust_selection: z.object({
182
+ raw_rank: z.number().int().positive().optional(),
183
+ robust_score: z.number().min(0).max(1).optional(),
184
+ stability_score: z.number().min(0).max(1).optional(),
185
+ diversity_score: z.number().min(0).max(1).optional(),
186
+ risk_penalty: z.number().min(0).max(1).optional(),
187
+ portfolio_role: z.enum(["raw_best", "robust_best", "safe", "aggressive", "diverse", "near_miss", "other"]).optional(),
188
+ }).strict().optional(),
189
+ summary: z.string().min(1).optional(),
190
+ }).strict();
191
+ export const RuntimeEvidenceEvaluatorCalibrationSchema = z.object({
192
+ mode: z.literal("calibration_only").default("calibration_only"),
193
+ use_for_selection: z.boolean().default(false),
194
+ direct_optimization_allowed: z.literal(false).default(false),
195
+ minimum_observations: z.number().int().positive().default(1),
196
+ conclusion: z.string().min(1).optional(),
197
+ }).strict();
198
+ export const RuntimeEvidenceEvaluatorObservationSchema = z.object({
199
+ evaluator_id: z.string().min(1),
200
+ signal: RuntimeEvidenceEvaluatorSignalSchema,
201
+ source: z.string().min(1),
202
+ candidate_id: z.string().min(1),
203
+ candidate_label: z.string().min(1).optional(),
204
+ artifact_labels: z.array(z.string().min(1)).optional(),
205
+ status: RuntimeEvidenceEvaluatorStatusSchema.default("unknown"),
206
+ score: z.union([z.string(), z.number(), z.boolean(), z.null()]).optional(),
207
+ score_label: z.string().min(1).optional(),
208
+ direction: z.enum(["maximize", "minimize", "neutral"]).optional(),
209
+ observed_at: z.string().datetime().optional(),
210
+ expected_score: z.union([z.string(), z.number(), z.boolean(), z.null()]).optional(),
211
+ expected_status: RuntimeEvidenceEvaluatorStatusSchema.optional(),
212
+ expectation_source: z.string().min(1).optional(),
213
+ validation: RuntimeEvidenceEvaluatorValidationSchema.optional(),
214
+ publish_action: RuntimeEvidenceEvaluatorPublishActionSchema.optional(),
215
+ provenance: RuntimeEvidenceEvaluatorProvenanceSchema.optional(),
216
+ budget: RuntimeEvidenceEvaluatorBudgetSchema.optional(),
217
+ candidate_snapshot: RuntimeEvidenceEvaluatorCandidateSnapshotSchema.optional(),
218
+ calibration: RuntimeEvidenceEvaluatorCalibrationSchema.optional(),
219
+ summary: z.string().min(1).optional(),
220
+ }).strict();
221
+ export const RuntimeEvidenceResearchSourceSchema = z.object({
222
+ url: z.string().url(),
223
+ title: z.string().min(1).optional(),
224
+ source_type: z.enum(["official_docs", "maintainer", "paper", "issue_thread", "example", "writeup", "other"]).default("other"),
225
+ provenance: z.enum(["quoted", "paraphrased", "summarized"]).default("summarized"),
226
+ relevance: z.string().min(1).optional(),
227
+ }).strict();
228
+ export const RuntimeEvidenceResearchFindingSchema = z.object({
229
+ finding: z.string().min(1),
230
+ source_urls: z.array(z.string().url()).min(1),
231
+ applicability: z.string().min(1),
232
+ risks_constraints: z.array(z.string().min(1)).default([]),
233
+ proposed_experiment: z.string().min(1),
234
+ expected_metric_impact: z.string().min(1),
235
+ fact_vs_adaptation: z.object({
236
+ facts: z.array(z.string().min(1)).default([]),
237
+ adaptation: z.string().min(1),
238
+ }).strict(),
239
+ }).strict();
240
+ export const RuntimeEvidenceResearchExternalActionSchema = z.object({
241
+ label: z.string().min(1),
242
+ reason: z.string().min(1),
243
+ approval_required: z.literal(true).default(true),
244
+ }).strict();
245
+ export const RuntimeEvidenceResearchMemoSchema = z.object({
246
+ trigger: z.enum(["plateau", "uncertainty", "knowledge_gap"]),
247
+ query: z.string().min(1),
248
+ summary: z.string().min(1),
249
+ sources: z.array(RuntimeEvidenceResearchSourceSchema).min(1),
250
+ findings: z.array(RuntimeEvidenceResearchFindingSchema).min(1),
251
+ candidate_playbook: z.object({
252
+ title: z.string().min(1),
253
+ steps: z.array(z.string().min(1)).default([]),
254
+ source_urls: z.array(z.string().url()).default([]),
255
+ }).strict().optional(),
256
+ untrusted_content_policy: z.literal("webpage_instructions_are_untrusted").default("webpage_instructions_are_untrusted"),
257
+ external_actions: z.array(RuntimeEvidenceResearchExternalActionSchema).default([]),
258
+ confidence: z.number().min(0).max(1).default(0.5),
259
+ }).strict();
260
+ export const RuntimeEvidenceDreamCheckpointTriggerSchema = z.enum([
261
+ "iteration",
262
+ "plateau",
263
+ "breakthrough",
264
+ "pre_finalization",
265
+ ]);
266
+ export const RuntimeEvidenceDreamCheckpointMemoryRefSchema = z.object({
267
+ source_type: z.enum(["soil", "playbook", "runtime_evidence", "other"]),
268
+ ref: z.string().min(1).optional(),
269
+ summary: z.string().min(1),
270
+ authority: z.literal("advisory_only").default("advisory_only"),
271
+ relevance_score: z.number().min(0).max(1).optional(),
272
+ source_reliability: z.number().min(0).max(1).optional(),
273
+ recency_score: z.number().min(0).max(1).optional(),
274
+ prior_success_contribution: z.number().min(0).max(1).optional(),
275
+ retrieval: z.object({
276
+ kind: z.enum(["route_hit", "fallback_hit", "checkpoint", "manual", "unknown"]).default("unknown"),
277
+ score: z.number().min(0).max(1).optional(),
278
+ confidence: z.number().min(0).max(1).optional(),
279
+ }).strict().optional(),
280
+ ranking_trace: z.object({
281
+ score: z.number().min(0).max(1),
282
+ decision: z.enum(["admitted", "rejected"]),
283
+ reason: z.string().min(1),
284
+ }).strict().optional(),
285
+ }).strict();
286
+ export const RuntimeEvidenceDreamCheckpointStrategyCandidateSchema = z.object({
287
+ title: z.string().min(1),
288
+ rationale: z.string().min(1),
289
+ target_dimensions: z.array(z.string().min(1)).default([]),
290
+ expected_evidence_gain: z.string().min(1).optional(),
291
+ retry_reason: z.string().min(1).optional(),
292
+ failed_lineage_warning: z.object({
293
+ fingerprint: z.string().min(1),
294
+ count: z.number().int().positive(),
295
+ reason: z.string().min(1),
296
+ }).strict().optional(),
297
+ }).strict();
298
+ export const RuntimeEvidenceDreamCheckpointActiveHypothesisSchema = z.object({
299
+ hypothesis: z.string().min(1),
300
+ supporting_evidence_ref: z.string().min(1).optional(),
301
+ target_metric_or_dimension: z.string().min(1),
302
+ expected_next_observation: z.string().min(1),
303
+ status: z.enum(["active", "testing", "supported", "weakened"]).default("active"),
304
+ }).strict();
305
+ export const RuntimeEvidenceDreamCheckpointRejectedApproachSchema = z.object({
306
+ approach: z.string().min(1),
307
+ rejection_reason: z.string().min(1),
308
+ evidence_ref: z.string().min(1).optional(),
309
+ revisit_condition: z.string().min(1).optional(),
310
+ confidence: z.number().min(0).max(1).default(0.5),
311
+ }).strict();
312
+ export const RuntimeEvidenceDreamRunControlRecommendationSchema = z.object({
313
+ id: z.string().min(1).optional(),
314
+ action: z.enum([
315
+ "stay_current_mode",
316
+ "widen_exploration",
317
+ "consolidate_candidates",
318
+ "freeze_experiment_queue",
319
+ "enter_finalization",
320
+ "preserve_near_miss_candidates",
321
+ "retire_low_value_lineage",
322
+ "request_operator_approval",
323
+ ]),
324
+ rationale: z.string().min(1),
325
+ evidence: z.array(z.object({
326
+ kind: z.enum(["metric", "artifact", "lineage", "task_history", "deadline", "external_feedback", "memory", "runtime_state"]),
327
+ ref: z.string().min(1).optional(),
328
+ summary: z.string().min(1),
329
+ }).strict()).min(1),
330
+ target_mode: z.enum(["exploration", "consolidation", "finalization"]).optional(),
331
+ target_strategy_family: z.string().min(1).optional(),
332
+ candidate_refs: z.array(z.string().min(1)).default([]),
333
+ lineage_refs: z.array(z.string().min(1)).default([]),
334
+ approval_required: z.boolean().default(false),
335
+ risk: z.enum(["low", "medium", "high"]).default("medium"),
336
+ confidence: z.number().min(0).max(1).default(0.5),
337
+ policy_decision: z.object({
338
+ disposition: z.enum(["auto_apply", "approval_required", "advisory_only"]),
339
+ reason: z.string().min(1),
340
+ }).strict().optional(),
341
+ }).strict();
342
+ export const RuntimeEvidenceDreamCheckpointSchema = z.object({
343
+ trigger: RuntimeEvidenceDreamCheckpointTriggerSchema,
344
+ summary: z.string().min(1),
345
+ current_goal: z.string().min(1),
346
+ active_dimensions: z.array(z.string().min(1)).default([]),
347
+ best_evidence_so_far: z.string().min(1).optional(),
348
+ recent_strategy_families: z.array(z.string().min(1)).default([]),
349
+ exhausted: z.array(z.string().min(1)).default([]),
350
+ promising: z.array(z.string().min(1)).default([]),
351
+ relevant_memories: z.array(RuntimeEvidenceDreamCheckpointMemoryRefSchema).default([]),
352
+ active_hypotheses: z.array(RuntimeEvidenceDreamCheckpointActiveHypothesisSchema).default([]),
353
+ rejected_approaches: z.array(RuntimeEvidenceDreamCheckpointRejectedApproachSchema).default([]),
354
+ next_strategy_candidates: z.array(RuntimeEvidenceDreamCheckpointStrategyCandidateSchema).default([]),
355
+ run_control_recommendations: z.array(RuntimeEvidenceDreamRunControlRecommendationSchema).optional(),
356
+ guidance: z.string().min(1),
357
+ uncertainty: z.array(z.string().min(1)).default([]),
358
+ context_authority: z.literal("advisory_only").default("advisory_only"),
359
+ confidence: z.number().min(0).max(1).default(0.5),
360
+ }).strict();
361
+ export const RuntimeEvidenceDivergentHypothesisSchema = z.object({
362
+ strategy_id: z.string().min(1).optional(),
363
+ hypothesis: z.string().min(1),
364
+ strategy_family: z.string().min(1),
365
+ role: z.enum(["exploitation", "adjacent_exploration", "divergent_exploration"]),
366
+ novelty_score: z.number().min(0).max(1),
367
+ similarity_to_recent_failures: z.number().min(0).max(1).default(0),
368
+ expected_cost: z.enum(["low", "medium", "high"]),
369
+ relationship_to_lineage: z.enum([
370
+ "current_best",
371
+ "neighbor",
372
+ "failed_lineage",
373
+ "different_mechanism",
374
+ "different_assumption",
375
+ "unknown",
376
+ ]),
377
+ prior_evidence: z.string().min(1).optional(),
378
+ downrank_reason: z.string().min(1).optional(),
379
+ smoke_status: z.enum(["not_run", "promote", "defer", "retire"]).default("not_run"),
380
+ smoke_reason: z.string().min(1).optional(),
381
+ smoke_evidence_ref: z.string().min(1).optional(),
382
+ evidence_authority: z.literal("speculative_hypothesis").default("speculative_hypothesis"),
383
+ }).strict();
384
+ export const RuntimeEvidenceEntrySchema = z.object({
385
+ schema_version: z.literal("runtime-evidence-entry-v1"),
386
+ id: z.string().min(1),
387
+ occurred_at: z.string().datetime(),
388
+ kind: RuntimeEvidenceEntryKindSchema,
389
+ scope: z.object({
390
+ goal_id: z.string().min(1).optional(),
391
+ run_id: z.string().min(1).optional(),
392
+ task_id: z.string().min(1).optional(),
393
+ loop_index: z.number().int().nonnegative().optional(),
394
+ phase: z.string().min(1).optional(),
395
+ }).strict(),
396
+ hypothesis: z.string().min(1).optional(),
397
+ strategy: z.string().min(1).optional(),
398
+ task: z.object({
399
+ id: z.string().min(1).optional(),
400
+ description: z.string().min(1).optional(),
401
+ action: z.string().min(1).optional(),
402
+ primary_dimension: z.string().min(1).optional(),
403
+ }).strict().optional(),
404
+ verification: z.object({
405
+ command: z.string().min(1).optional(),
406
+ verdict: z.string().min(1).optional(),
407
+ confidence: z.number().min(0).max(1).optional(),
408
+ summary: z.string().min(1).optional(),
409
+ }).strict().optional(),
410
+ metrics: z.array(RuntimeEvidenceMetricSchema).default([]),
411
+ evaluators: z.array(RuntimeEvidenceEvaluatorObservationSchema).optional(),
412
+ research: z.array(RuntimeEvidenceResearchMemoSchema).optional(),
413
+ dream_checkpoints: z.array(RuntimeEvidenceDreamCheckpointSchema).optional(),
414
+ divergent_exploration: z.array(RuntimeEvidenceDivergentHypothesisSchema).optional(),
415
+ candidates: z.array(RuntimeEvidenceCandidateRecordSchema).optional(),
416
+ artifacts: z.array(RuntimeEvidenceArtifactRefSchema).default([]),
417
+ result: z.object({
418
+ status: z.string().min(1).optional(),
419
+ summary: z.string().min(1).optional(),
420
+ error: z.string().min(1).optional(),
421
+ }).strict().optional(),
422
+ outcome: RuntimeEvidenceOutcomeSchema.optional(),
423
+ decision_reason: z.string().min(1).optional(),
424
+ raw_refs: z.array(z.object({
425
+ kind: z.string().min(1),
426
+ id: z.string().min(1).optional(),
427
+ path: z.string().min(1).optional(),
428
+ state_relative_path: z.string().min(1).optional(),
429
+ url: z.string().url().optional(),
430
+ }).strict()).default([]),
431
+ summary: z.string().min(1).optional(),
432
+ }).strict().refine((entry) => entry.scope.goal_id || entry.scope.run_id, {
433
+ message: "goal_id or run_id is required",
434
+ path: ["scope"],
435
+ });
436
+ export class RuntimeEvidenceLedger {
437
+ paths;
438
+ constructor(runtimeRootOrPaths) {
439
+ this.paths =
440
+ typeof runtimeRootOrPaths === "string"
441
+ ? createRuntimeStorePaths(runtimeRootOrPaths)
442
+ : runtimeRootOrPaths ?? createRuntimeStorePaths();
443
+ }
444
+ async ensureReady() {
445
+ await ensureRuntimeStorePaths(this.paths);
446
+ }
447
+ goalPath(goalId) {
448
+ return this.paths.evidenceGoalPath(goalId);
449
+ }
450
+ runPath(runId) {
451
+ return this.paths.evidenceRunPath(runId);
452
+ }
453
+ async append(input) {
454
+ const entry = RuntimeEvidenceEntrySchema.parse({
455
+ schema_version: "runtime-evidence-entry-v1",
456
+ id: input.id ?? randomUUID(),
457
+ occurred_at: input.occurred_at ?? new Date().toISOString(),
458
+ metrics: input.metrics ?? [],
459
+ evaluators: input.evaluators ?? [],
460
+ research: input.research ?? [],
461
+ dream_checkpoints: input.dream_checkpoints ?? [],
462
+ divergent_exploration: input.divergent_exploration ?? [],
463
+ candidates: input.candidates ?? [],
464
+ artifacts: input.artifacts ?? [],
465
+ raw_refs: input.raw_refs ?? [],
466
+ ...input,
467
+ });
468
+ await this.ensureReady();
469
+ const targets = new Set();
470
+ if (entry.scope.goal_id)
471
+ targets.add(this.paths.evidenceGoalPath(entry.scope.goal_id));
472
+ if (entry.scope.run_id)
473
+ targets.add(this.paths.evidenceRunPath(entry.scope.run_id));
474
+ await Promise.all([...targets].map(async (target) => {
475
+ await fsp.mkdir(path.dirname(target), { recursive: true });
476
+ await fsp.appendFile(target, `${JSON.stringify(entry)}\n`, "utf8");
477
+ }));
478
+ await Promise.all([...targets].map(async (target) => {
479
+ await rebuildSummaryIndex(target, this.paths);
480
+ }));
481
+ return [entry];
482
+ }
483
+ async readByGoal(goalId) {
484
+ return readEvidenceFile(this.paths.evidenceGoalPath(goalId));
485
+ }
486
+ async readByRun(runId) {
487
+ return readEvidenceFile(this.paths.evidenceRunPath(runId));
488
+ }
489
+ async summarizeGoal(goalId) {
490
+ const manifests = await readReproducibilityManifests(this.paths, { goal_id: goalId });
491
+ const indexed = manifests.length === 0
492
+ ? await readSummaryIndex(this.paths.evidenceGoalPath(goalId), { goal_id: goalId })
493
+ : null;
494
+ if (indexed)
495
+ return indexed.summary;
496
+ const read = await this.readByGoal(goalId);
497
+ const summary = summarizeEvidence({ goal_id: goalId }, read, manifests);
498
+ return summary;
499
+ }
500
+ async summarizeRun(runId) {
501
+ const manifests = await readReproducibilityManifests(this.paths, { run_id: runId });
502
+ const indexed = manifests.length === 0
503
+ ? await readSummaryIndex(this.paths.evidenceRunPath(runId), { run_id: runId })
504
+ : null;
505
+ if (indexed)
506
+ return indexed.summary;
507
+ const read = await this.readByRun(runId);
508
+ const summary = summarizeEvidence({ run_id: runId }, read, manifests);
509
+ return summary;
510
+ }
511
+ async rebuildSummaryIndexForGoal(goalId) {
512
+ return rebuildSummaryIndex(this.paths.evidenceGoalPath(goalId), this.paths);
513
+ }
514
+ async rebuildSummaryIndexForRun(runId) {
515
+ return rebuildSummaryIndex(this.paths.evidenceRunPath(runId), this.paths);
516
+ }
517
+ }
518
+ async function rebuildSummaryIndex(canonicalPath, paths) {
519
+ const scope = summaryScopeFromPath(canonicalPath);
520
+ const read = await readEvidenceFile(canonicalPath);
521
+ const manifests = await readReproducibilityManifests(paths, scope);
522
+ const summary = summarizeEvidence(scope, read, manifests);
523
+ await writeSummaryIndex(canonicalPath, summary);
524
+ return summary;
525
+ }
526
+ function summaryIndexPath(canonicalPath) {
527
+ return `${canonicalPath}.summary.json`;
528
+ }
529
+ function summaryScopeFromPath(canonicalPath) {
530
+ const basename = path.basename(canonicalPath, ".jsonl");
531
+ const decoded = decodeURIComponent(basename);
532
+ return canonicalPath.includes(`${path.sep}runs${path.sep}`) ? { run_id: decoded } : { goal_id: decoded };
533
+ }
534
+ async function readReproducibilityManifests(paths, scope) {
535
+ let fileNames;
536
+ try {
537
+ fileNames = await fsp.readdir(paths.reproducibilityManifestsDir);
538
+ }
539
+ catch (err) {
540
+ if (err.code === "ENOENT")
541
+ return [];
542
+ throw err;
543
+ }
544
+ const manifests = [];
545
+ for (const fileName of fileNames) {
546
+ if (!fileName.endsWith(".json"))
547
+ continue;
548
+ try {
549
+ const parsed = JSON.parse(await fsp.readFile(path.join(paths.reproducibilityManifestsDir, fileName), "utf8"));
550
+ if (parsed.schema_version !== "runtime-reproducibility-manifest-v1")
551
+ continue;
552
+ if (scope.goal_id && parsed.scope?.goal_id !== scope.goal_id)
553
+ continue;
554
+ if (scope.run_id && parsed.scope?.run_id !== scope.run_id)
555
+ continue;
556
+ manifests.push({
557
+ ...parsed,
558
+ artifacts: Array.isArray(parsed.artifacts) ? parsed.artifacts.filter(isManifestArtifactRef) : [],
559
+ });
560
+ }
561
+ catch {
562
+ continue;
563
+ }
564
+ }
565
+ return manifests;
566
+ }
567
+ function isManifestArtifactRef(value) {
568
+ return typeof value === "object"
569
+ && value !== null
570
+ && typeof value.label === "string";
571
+ }
572
+ async function readSummaryIndex(canonicalPath, expectedScope) {
573
+ let text;
574
+ try {
575
+ text = await fsp.readFile(summaryIndexPath(canonicalPath), "utf8");
576
+ }
577
+ catch (err) {
578
+ if (err.code === "ENOENT")
579
+ return null;
580
+ throw err;
581
+ }
582
+ try {
583
+ const parsed = JSON.parse(text);
584
+ if (parsed.schema_version !== "runtime-evidence-summary-index-v1")
585
+ return null;
586
+ if (parsed.summary.schema_version !== "runtime-evidence-summary-v1")
587
+ return null;
588
+ if (!isCurrentEvidenceSummaryShape(parsed.summary))
589
+ return null;
590
+ const stat = await fsp.stat(canonicalPath);
591
+ if (parsed.canonical_log_size !== stat.size)
592
+ return null;
593
+ if (parsed.canonical_log_mtime_ms !== stat.mtimeMs)
594
+ return null;
595
+ if (expectedScope.goal_id && parsed.summary.scope.goal_id !== expectedScope.goal_id)
596
+ return null;
597
+ if (expectedScope.run_id && parsed.summary.scope.run_id !== expectedScope.run_id)
598
+ return null;
599
+ return parsed;
600
+ }
601
+ catch {
602
+ return null;
603
+ }
604
+ }
605
+ function isCurrentEvidenceSummaryShape(summary) {
606
+ return Array.isArray(summary.candidate_lineages)
607
+ && Array.isArray(summary.recommended_candidate_portfolio)
608
+ && Array.isArray(summary.near_miss_candidates)
609
+ && typeof summary.artifact_retention === "object"
610
+ && summary.artifact_retention !== null
611
+ && Array.isArray(summary.evaluator_summary.budgets)
612
+ && Array.isArray(summary.evaluator_summary.calibration)
613
+ && typeof summary.candidate_selection_summary === "object"
614
+ && summary.candidate_selection_summary !== null;
615
+ }
616
+ async function writeSummaryIndex(canonicalPath, summary) {
617
+ const stat = await fsp.stat(canonicalPath);
618
+ const index = {
619
+ schema_version: "runtime-evidence-summary-index-v1",
620
+ generated_at: new Date().toISOString(),
621
+ canonical_log_path: canonicalPath,
622
+ canonical_log_size: stat.size,
623
+ canonical_log_mtime_ms: stat.mtimeMs,
624
+ summary,
625
+ };
626
+ await fsp.mkdir(path.dirname(canonicalPath), { recursive: true });
627
+ await fsp.writeFile(summaryIndexPath(canonicalPath), `${JSON.stringify(index)}\n`, "utf8");
628
+ }
629
+ async function readEvidenceFile(filePath) {
630
+ let text;
631
+ try {
632
+ text = await fsp.readFile(filePath, "utf8");
633
+ }
634
+ catch (err) {
635
+ if (err.code === "ENOENT") {
636
+ return { entries: [], warnings: [] };
637
+ }
638
+ throw err;
639
+ }
640
+ const entries = [];
641
+ const warnings = [];
642
+ const lines = text.split(/\r?\n/);
643
+ for (let index = 0; index < lines.length; index += 1) {
644
+ const line = lines[index];
645
+ if (!line?.trim())
646
+ continue;
647
+ try {
648
+ const parsed = RuntimeEvidenceEntrySchema.safeParse(JSON.parse(line));
649
+ if (parsed.success) {
650
+ entries.push(parsed.data);
651
+ }
652
+ else {
653
+ warnings.push({
654
+ file: filePath,
655
+ line: index + 1,
656
+ message: parsed.error.issues.map((issue) => issue.message).join("; "),
657
+ });
658
+ }
659
+ }
660
+ catch (err) {
661
+ warnings.push({
662
+ file: filePath,
663
+ line: index + 1,
664
+ message: err instanceof Error ? err.message : String(err),
665
+ });
666
+ }
667
+ }
668
+ return { entries, warnings };
669
+ }
670
+ function summarizeEvidence(scope, read, manifests = []) {
671
+ const entries = [...read.entries].sort((a, b) => a.occurred_at.localeCompare(b.occurred_at));
672
+ const newestFirst = [...entries].reverse();
673
+ const evaluatorSummary = summarizeEvidenceEvaluatorResults(entries);
674
+ return {
675
+ schema_version: "runtime-evidence-summary-v1",
676
+ generated_at: new Date().toISOString(),
677
+ scope,
678
+ total_entries: entries.length,
679
+ latest_strategy: newestFirst.find((entry) => entry.kind === "strategy" || Boolean(entry.strategy) || Boolean(entry.decision_reason)) ?? null,
680
+ best_evidence: chooseBestEvidence(newestFirst),
681
+ metric_trends: summarizeEvidenceMetricTrends(entries),
682
+ evaluator_summary: evaluatorSummary,
683
+ research_memos: summarizeEvidenceResearchMemos(entries),
684
+ dream_checkpoints: summarizeEvidenceDreamCheckpoints(entries),
685
+ divergent_exploration: entries
686
+ .flatMap((entry) => entry.divergent_exploration ?? [])
687
+ .slice(-10)
688
+ .reverse(),
689
+ candidate_lineages: summarizeCandidateLineages(entries),
690
+ recommended_candidate_portfolio: selectDiversifiedCandidatePortfolio(entries),
691
+ candidate_selection_summary: summarizeCandidateSelection(entries, evaluatorSummary),
692
+ near_miss_candidates: summarizeNearMissCandidates(entries),
693
+ artifact_retention: summarizeArtifactRetention(entries, { manifests }),
694
+ recent_failed_attempts: newestFirst
695
+ .filter((entry) => entry.outcome === "failed"
696
+ || entry.outcome === "regressed"
697
+ || entry.kind === "failure"
698
+ || entry.result?.status === "failed"
699
+ || entry.verification?.verdict === "fail")
700
+ .slice(0, 5),
701
+ failed_lineages: summarizeFailedLineages(entries),
702
+ recent_entries: newestFirst.slice(0, 10),
703
+ warnings: read.warnings,
704
+ };
705
+ }
706
+ export function selectDiversifiedCandidatePortfolio(entriesOldestFirst, options = {}) {
707
+ const limit = options.limit ?? 3;
708
+ if (limit <= 0)
709
+ return [];
710
+ const nearDuplicateSimilarity = options.nearDuplicateSimilarity ?? 0.85;
711
+ const primaryMetric = resolvePrimaryCandidateMetricKey(entriesOldestFirst);
712
+ const candidates = extractCandidateEvidenceContexts(entriesOldestFirst, primaryMetric)
713
+ .filter((context) => context.candidate.disposition !== "retired")
714
+ .sort(compareCandidateEvidenceContexts);
715
+ const selected = [];
716
+ const skipped = [];
717
+ for (const candidate of candidates) {
718
+ if (selected.length >= limit)
719
+ break;
720
+ const duplicateSignal = mostSimilarSelectedCandidate(candidate, selected);
721
+ if (duplicateSignal && duplicateSignal.similarity >= nearDuplicateSimilarity) {
722
+ skipped.push({ ...candidate, similarity_to_selected: duplicateSignal });
723
+ continue;
724
+ }
725
+ selected.push({
726
+ ...candidate,
727
+ role: selected.length === 0 ? "top_metric" : "diverse_representative",
728
+ ...(duplicateSignal ? { similarity_to_selected: duplicateSignal } : {}),
729
+ });
730
+ }
731
+ for (const candidate of skipped) {
732
+ if (selected.length >= limit)
733
+ break;
734
+ selected.push({
735
+ ...candidate,
736
+ role: "lineage_representative",
737
+ });
738
+ }
739
+ return selected.map(toPortfolioSlot);
740
+ }
741
+ function summarizeCandidateSelection(entriesOldestFirst, evaluatorSummary) {
742
+ const primaryMetric = resolvePrimaryCandidateMetricKey(entriesOldestFirst);
743
+ const contexts = extractCandidateEvidenceContexts(entriesOldestFirst, primaryMetric)
744
+ .filter((context) => context.candidate.disposition !== "retired");
745
+ const rawRanked = [...contexts].sort(compareCandidateEvidenceContexts);
746
+ const scored = scoreCandidateSelectionContexts(rawRanked, evaluatorSummary?.calibration ?? []);
747
+ const ranked = [...scored].sort((a, b) => b.robust_score - a.robust_score || a.raw_rank - b.raw_rank);
748
+ const rawBest = scored.find((candidate) => candidate.raw_rank === 1) ?? null;
749
+ const robustBest = ranked[0] ?? null;
750
+ return {
751
+ primary_metric: primaryMetric,
752
+ raw_best: rawBest,
753
+ robust_best: robustBest,
754
+ ranked,
755
+ final_portfolio: {
756
+ safe: selectSafeCandidate(scored),
757
+ aggressive: rawBest,
758
+ diverse: selectDiverseCandidate(scored, robustBest),
759
+ },
760
+ };
761
+ }
762
+ function scoreCandidateSelectionContexts(rawRanked, calibration = []) {
763
+ const metricValues = rawRanked
764
+ .map((context) => context.metric?.value)
765
+ .filter((value) => typeof value === "number" && Number.isFinite(value));
766
+ const minMetric = metricValues.length > 0 ? Math.min(...metricValues) : 0;
767
+ const maxMetric = metricValues.length > 0 ? Math.max(...metricValues) : 0;
768
+ const rawBestFamily = rawRanked[0]?.candidate.lineage.strategy_family;
769
+ const allCandidates = rawRanked.map((context) => context.candidate);
770
+ return rawRanked.map((context, index) => {
771
+ const candidate = context.candidate;
772
+ const metricScore = normalizedMetricScore(context.metric, minMetric, maxMetric);
773
+ const stabilityScore = clamp01(candidate.robustness?.stability_score ?? context.metric?.confidence ?? 0.5);
774
+ const inferredDiversity = inferredDiversityScore(candidate, rawBestFamily, allCandidates);
775
+ const diversityScore = clamp01(candidate.robustness?.diversity_score === undefined
776
+ ? inferredDiversity
777
+ : Math.min(candidate.robustness.diversity_score, inferredDiversity));
778
+ const riskPenalty = clamp01(candidate.robustness?.risk_penalty ?? inferredCandidateRiskPenalty(candidate));
779
+ const evidenceConfidence = clamp01(candidate.robustness?.evidence_confidence ?? context.metric?.confidence ?? 0.5);
780
+ const calibrationAdjustment = evaluatorCalibrationAdjustment(candidate.candidate_id, calibration);
781
+ const robustScore = clamp01(candidate.robustness?.robust_score
782
+ ?? (metricScore * 0.45 + stabilityScore * 0.3 + diversityScore * 0.15 + evidenceConfidence * 0.1 - riskPenalty + calibrationAdjustment));
783
+ return {
784
+ candidate_id: candidate.candidate_id,
785
+ ...(candidate.label ? { label: candidate.label } : {}),
786
+ strategy_family: candidate.lineage.strategy_family,
787
+ evidence_entry_id: context.entry_id,
788
+ raw_rank: index + 1,
789
+ ...(context.metric ? { raw_metric: context.metric } : {}),
790
+ robust_score: roundScore(robustScore),
791
+ calibration_adjustment: roundScore(calibrationAdjustment),
792
+ metric_score: roundScore(metricScore),
793
+ stability_score: roundScore(stabilityScore),
794
+ diversity_score: roundScore(diversityScore),
795
+ risk_penalty: roundScore(riskPenalty),
796
+ evidence_confidence: roundScore(evidenceConfidence),
797
+ reasons: candidateSelectionReasons(candidate, {
798
+ metricScore,
799
+ stabilityScore,
800
+ diversityScore,
801
+ riskPenalty,
802
+ evidenceConfidence,
803
+ calibrationAdjustment,
804
+ }),
805
+ };
806
+ });
807
+ }
808
+ function evaluatorCalibrationAdjustment(candidateId, calibration) {
809
+ const relevant = calibration.filter((item) => item.candidate_id === candidateId
810
+ && item.use_for_selection
811
+ && item.direct_optimization_allowed === false);
812
+ if (relevant.length === 0)
813
+ return 0;
814
+ const average = relevant.reduce((sum, item) => sum + item.selection_adjustment, 0) / relevant.length;
815
+ if (relevant.length < Math.max(...relevant.map((item) => item.minimum_observations)))
816
+ return 0;
817
+ return Math.min(0.08, Math.max(-0.08, average));
818
+ }
819
+ function normalizedMetricScore(metric, minMetric, maxMetric) {
820
+ if (!metric)
821
+ return 0;
822
+ if (maxMetric === minMetric)
823
+ return 0.5;
824
+ const distance = metric.direction === "maximize"
825
+ ? (metric.value - minMetric) / (maxMetric - minMetric)
826
+ : (maxMetric - metric.value) / (maxMetric - minMetric);
827
+ return clamp01(distance);
828
+ }
829
+ function inferredDiversityScore(candidate, rawBestFamily, allCandidates) {
830
+ if (!rawBestFamily)
831
+ return 0.5;
832
+ const highestSimilarity = highestKnownSimilarity(candidate, allCandidates);
833
+ const lineageBase = candidate.lineage.strategy_family !== rawBestFamily ? 0.75 : 0.45;
834
+ if (highestSimilarity > 0)
835
+ return clamp01(Math.min(lineageBase, 1 - highestSimilarity));
836
+ return lineageBase;
837
+ }
838
+ function highestKnownSimilarity(candidate, allCandidates) {
839
+ let highest = candidate.similarity.reduce((max, similarity) => Math.max(max, similarity.similarity), 0);
840
+ for (const other of allCandidates) {
841
+ if (other.candidate_id === candidate.candidate_id)
842
+ continue;
843
+ for (const similarity of other.similarity) {
844
+ if (similarity.candidate_id === candidate.candidate_id) {
845
+ highest = Math.max(highest, similarity.similarity);
846
+ }
847
+ }
848
+ }
849
+ return highest;
850
+ }
851
+ function inferredCandidateRiskPenalty(candidate) {
852
+ const lineageText = [
853
+ ...candidate.lineage.config_lineage,
854
+ ...candidate.lineage.postprocess_lineage,
855
+ ].map(normalizeLineageText).join(" ");
856
+ if (lineageText.includes("manual") || lineageText.includes("threshold") || lineageText.includes("postprocess")) {
857
+ return 0.15;
858
+ }
859
+ if (lineageText.includes("calibration") || lineageText.includes("weight")) {
860
+ return 0.08;
861
+ }
862
+ return 0;
863
+ }
864
+ function candidateSelectionReasons(candidate, scores) {
865
+ const reasons = [];
866
+ if (scores.stabilityScore >= 0.8)
867
+ reasons.push("strong stability evidence");
868
+ if (scores.diversityScore >= 0.8)
869
+ reasons.push("diverse lineage");
870
+ if (scores.riskPenalty >= 0.15)
871
+ reasons.push("penalized for overfit-prone lineage or post-processing");
872
+ if (scores.metricScore >= 0.95)
873
+ reasons.push("top raw metric evidence");
874
+ if (scores.calibrationAdjustment > 0)
875
+ reasons.push("external feedback calibrates local validation upward");
876
+ if (scores.calibrationAdjustment < 0)
877
+ reasons.push("external feedback calibrates local validation downward");
878
+ if (candidate.robustness?.summary)
879
+ reasons.push(candidate.robustness.summary);
880
+ return reasons.length > 0 ? reasons : ["risk-adjusted candidate evidence"];
881
+ }
882
+ function selectSafeCandidate(candidates) {
883
+ return [...candidates].sort((a, b) => b.stability_score - a.stability_score
884
+ || a.risk_penalty - b.risk_penalty
885
+ || b.robust_score - a.robust_score
886
+ || a.raw_rank - b.raw_rank)[0] ?? null;
887
+ }
888
+ function selectDiverseCandidate(candidates, robustBest) {
889
+ const robustFamily = robustBest?.strategy_family;
890
+ return [...candidates]
891
+ .filter((candidate) => !robustFamily || candidate.strategy_family !== robustFamily)
892
+ .filter((candidate) => candidate.diversity_score >= 0.5)
893
+ .sort((a, b) => b.diversity_score - a.diversity_score
894
+ || b.robust_score - a.robust_score
895
+ || a.raw_rank - b.raw_rank)[0] ?? null;
896
+ }
897
+ function summarizeNearMissCandidates(entriesOldestFirst) {
898
+ const primaryMetric = resolvePrimaryCandidateMetricKey(entriesOldestFirst);
899
+ const contexts = extractCandidateEvidenceContexts(entriesOldestFirst, primaryMetric)
900
+ .filter((context) => context.candidate.disposition !== "retired");
901
+ const rawRanked = [...contexts].sort(compareCandidateEvidenceContexts);
902
+ const rawBest = rawRanked[0] ?? null;
903
+ const scoredByCandidateId = new Map(scoreCandidateSelectionContexts(rawRanked).map((candidate) => [candidate.candidate_id, candidate]));
904
+ const result = [];
905
+ for (const context of rawRanked) {
906
+ if (!rawBest || context.candidate.candidate_id === rawBest.candidate.candidate_id)
907
+ continue;
908
+ const scored = scoredByCandidateId.get(context.candidate.candidate_id);
909
+ const reasons = nearMissReasonsForCandidate(context, rawBest, scored);
910
+ if (reasons.length === 0)
911
+ continue;
912
+ const nearMiss = context.candidate.near_miss;
913
+ if (nearMiss?.status === "rejected")
914
+ continue;
915
+ result.push({
916
+ candidate_id: context.candidate.candidate_id,
917
+ ...(context.candidate.label ? { label: context.candidate.label } : {}),
918
+ strategy_family: context.candidate.lineage.strategy_family,
919
+ evidence_entry_id: context.entry_id,
920
+ occurred_at: context.occurred_at,
921
+ raw_rank: scored?.raw_rank ?? rawRanked.indexOf(context) + 1,
922
+ ...(context.metric ? { raw_metric: context.metric } : {}),
923
+ raw_best_candidate_id: rawBest.candidate.candidate_id,
924
+ ...nearMissMarginContext(context, rawBest, nearMiss),
925
+ reason_to_keep: reasons,
926
+ weak_dimensions: nearMiss?.weak_dimensions ?? context.candidate.robustness?.weak_dimensions ?? [],
927
+ complementary_candidate_ids: nearMiss?.complementary_candidate_ids ?? complementaryCandidateIds(context.candidate),
928
+ ...(nearMiss?.follow_up ? { follow_up: nearMiss.follow_up } : {}),
929
+ ...(context.candidate.disposition_reason ? { retained_reason: context.candidate.disposition_reason } : {}),
930
+ evidence_refs: nearMiss?.evidence_refs ?? context.candidate.robustness?.provenance_refs ?? [],
931
+ ...(nearMiss?.summary ?? context.candidate.robustness?.summary
932
+ ? { summary: nearMiss?.summary ?? context.candidate.robustness?.summary }
933
+ : {}),
934
+ });
935
+ }
936
+ return result.sort((a, b) => nearMissReasonRank(b.reason_to_keep) - nearMissReasonRank(a.reason_to_keep)
937
+ || (b.raw_metric?.confidence ?? 0) - (a.raw_metric?.confidence ?? 0)
938
+ || a.raw_rank - b.raw_rank).slice(0, 8);
939
+ }
940
+ function nearMissReasonsForCandidate(context, rawBest, scored) {
941
+ const explicit = context.candidate.near_miss?.reason_to_keep ?? [];
942
+ const reasons = new Set(explicit);
943
+ if (context.candidate.near_miss?.status === "retained" || context.candidate.near_miss?.status === "promoted") {
944
+ for (const reason of inferredNearMissReasons(context, rawBest, scored))
945
+ reasons.add(reason);
946
+ }
947
+ else if (context.candidate.near_miss) {
948
+ for (const reason of inferredNearMissReasons(context, rawBest, scored))
949
+ reasons.add(reason);
950
+ }
951
+ else if (isImplicitNearMiss(context, rawBest, scored)) {
952
+ for (const reason of inferredNearMissReasons(context, rawBest, scored))
953
+ reasons.add(reason);
954
+ }
955
+ return [...reasons];
956
+ }
957
+ function inferredNearMissReasons(context, rawBest, scored) {
958
+ const reasons = [];
959
+ const margin = candidateMetricMargin(context.metric, rawBest.metric);
960
+ if (margin !== null && isCloseToBestMargin(margin, rawBest.metric))
961
+ reasons.push("close_to_best");
962
+ if ((context.candidate.robustness?.stability_score ?? 0) >= 0.8)
963
+ reasons.push("stability");
964
+ if ((context.candidate.near_miss?.weak_dimensions.length ?? context.candidate.robustness?.weak_dimensions.length ?? 0) > 0) {
965
+ reasons.push("weak_dimension_improvement");
966
+ }
967
+ if (context.candidate.lineage.strategy_family !== rawBest.candidate.lineage.strategy_family
968
+ && (scored?.diversity_score ?? inferredDiversityScore(context.candidate, rawBest.candidate.lineage.strategy_family, [context.candidate, rawBest.candidate])) >= 0.5) {
969
+ reasons.push("novelty");
970
+ }
971
+ if (complementaryCandidateIds(context.candidate).length > 0 || highestKnownSimilarity(context.candidate, [context.candidate, rawBest.candidate]) <= 0.5) {
972
+ reasons.push("complementarity");
973
+ }
974
+ const lineageText = [
975
+ ...context.candidate.lineage.model_lineage,
976
+ ...context.candidate.lineage.config_lineage,
977
+ ...(context.candidate.near_miss?.summary ? [context.candidate.near_miss.summary] : []),
978
+ ].map(normalizeLineageText).join(" ");
979
+ if (lineageText.includes("stack") || lineageText.includes("ensemble") || lineageText.includes("blend")) {
980
+ reasons.push("ensemble_potential");
981
+ }
982
+ return reasons;
983
+ }
984
+ function isImplicitNearMiss(context, rawBest, scored) {
985
+ if (context.candidate.disposition !== "retained" && context.candidate.disposition !== "promoted")
986
+ return false;
987
+ const margin = candidateMetricMargin(context.metric, rawBest.metric);
988
+ const close = margin !== null && isCloseToBestMargin(margin, rawBest.metric);
989
+ const weakDimension = (context.candidate.robustness?.weak_dimensions.length ?? 0) > 0;
990
+ const distinctFamily = context.candidate.lineage.strategy_family !== rawBest.candidate.lineage.strategy_family
991
+ && (scored?.diversity_score ?? 0) >= 0.5;
992
+ return close || weakDimension || distinctFamily;
993
+ }
994
+ function nearMissMarginContext(context, rawBest, nearMiss) {
995
+ const margin = nearMiss?.margin_to_best ?? candidateMetricMargin(context.metric, rawBest.metric);
996
+ return margin === null || margin === undefined ? {} : { margin_to_raw_best: Math.round(margin * 1_000_000) / 1_000_000 };
997
+ }
998
+ function candidateMetricMargin(candidateMetric, bestMetric) {
999
+ if (!candidateMetric || !bestMetric || candidateMetric.direction !== bestMetric.direction)
1000
+ return null;
1001
+ const margin = candidateMetric.direction === "maximize"
1002
+ ? bestMetric.value - candidateMetric.value
1003
+ : candidateMetric.value - bestMetric.value;
1004
+ return Number.isFinite(margin) ? Math.max(0, margin) : null;
1005
+ }
1006
+ function isCloseToBestMargin(margin, bestMetric) {
1007
+ if (!bestMetric)
1008
+ return false;
1009
+ const tolerance = Math.max(Math.abs(bestMetric.value) * 0.005, 0.001);
1010
+ return margin <= tolerance;
1011
+ }
1012
+ function complementaryCandidateIds(candidate) {
1013
+ const explicit = candidate.near_miss?.complementary_candidate_ids ?? [];
1014
+ if (explicit.length > 0)
1015
+ return explicit;
1016
+ return candidate.similarity
1017
+ .filter((similarity) => similarity.signal === "metric_correlation" && similarity.similarity <= 0.5)
1018
+ .map((similarity) => similarity.candidate_id);
1019
+ }
1020
+ function nearMissReasonRank(reasons) {
1021
+ const weights = {
1022
+ weak_dimension_improvement: 5,
1023
+ novelty: 4,
1024
+ complementarity: 4,
1025
+ ensemble_potential: 3,
1026
+ stability: 2,
1027
+ close_to_best: 1,
1028
+ };
1029
+ return reasons.reduce((score, reason) => score + weights[reason], 0);
1030
+ }
1031
+ function summarizeCandidateLineages(entriesOldestFirst) {
1032
+ const primaryMetric = resolvePrimaryCandidateMetricKey(entriesOldestFirst);
1033
+ const byFamily = new Map();
1034
+ for (const context of extractCandidateEvidenceContexts(entriesOldestFirst, primaryMetric)) {
1035
+ const family = context.candidate.lineage.strategy_family;
1036
+ byFamily.set(family, [...(byFamily.get(family) ?? []), context]);
1037
+ }
1038
+ return [...byFamily.entries()]
1039
+ .map(([strategyFamily, contexts]) => {
1040
+ const sorted = [...contexts].sort(compareCandidateEvidenceContexts);
1041
+ const best = sorted[0];
1042
+ const diversityNotes = new Set();
1043
+ for (const context of contexts) {
1044
+ for (const similarity of context.candidate.similarity) {
1045
+ if (similarity.similarity >= 0.85) {
1046
+ diversityNotes.add(`${context.candidate.candidate_id} near-duplicate of ${similarity.candidate_id}`);
1047
+ }
1048
+ }
1049
+ }
1050
+ return {
1051
+ strategy_family: strategyFamily,
1052
+ candidate_ids: contexts.map((context) => context.candidate.candidate_id),
1053
+ retained_representative_ids: sorted
1054
+ .filter((context) => context.candidate.disposition === "retained" || context.candidate.disposition === "promoted")
1055
+ .map((context) => context.candidate.candidate_id)
1056
+ .slice(0, 3),
1057
+ promoted_ids: contexts
1058
+ .filter((context) => context.candidate.disposition === "promoted")
1059
+ .map((context) => context.candidate.candidate_id),
1060
+ retired_ids: contexts
1061
+ .filter((context) => context.candidate.disposition === "retired")
1062
+ .map((context) => context.candidate.candidate_id),
1063
+ ...(best ? { best_candidate_id: best.candidate.candidate_id } : {}),
1064
+ ...(best?.metric
1065
+ ? {
1066
+ best_metric: {
1067
+ label: best.metric.label,
1068
+ value: best.metric.value,
1069
+ direction: best.metric.direction,
1070
+ },
1071
+ }
1072
+ : {}),
1073
+ diversity_notes: [...diversityNotes].slice(0, 5),
1074
+ };
1075
+ })
1076
+ .sort((a, b) => {
1077
+ const aMetric = a.best_metric;
1078
+ const bMetric = b.best_metric;
1079
+ if (aMetric && bMetric && aMetric.direction === bMetric.direction) {
1080
+ const delta = aMetric.direction === "maximize" ? bMetric.value - aMetric.value : aMetric.value - bMetric.value;
1081
+ if (delta !== 0)
1082
+ return delta;
1083
+ }
1084
+ if (aMetric && !bMetric)
1085
+ return -1;
1086
+ if (!aMetric && bMetric)
1087
+ return 1;
1088
+ return a.strategy_family.localeCompare(b.strategy_family);
1089
+ });
1090
+ }
1091
+ function extractCandidateEvidenceContexts(entriesOldestFirst, primaryMetric) {
1092
+ const contexts = [];
1093
+ for (const entry of entriesOldestFirst) {
1094
+ for (const candidate of entry.candidates ?? []) {
1095
+ contexts.push({
1096
+ entry_id: entry.id,
1097
+ occurred_at: candidate.produced_at ?? entry.occurred_at,
1098
+ candidate,
1099
+ metric: candidateComparableMetric(candidate, primaryMetric),
1100
+ });
1101
+ }
1102
+ }
1103
+ return contexts;
1104
+ }
1105
+ function resolvePrimaryCandidateMetricKey(entriesOldestFirst) {
1106
+ const candidates = entriesOldestFirst.flatMap((entry) => entry.candidates ?? []);
1107
+ const byMetric = new Map();
1108
+ candidates.forEach((candidate, candidateIndex) => {
1109
+ const seenForCandidate = new Set();
1110
+ candidate.metrics.forEach((metric, metricIndex) => {
1111
+ if (typeof metric.value !== "number" || !Number.isFinite(metric.value))
1112
+ return;
1113
+ if (metric.direction !== "maximize" && metric.direction !== "minimize")
1114
+ return;
1115
+ const key = { label: metric.label, direction: metric.direction };
1116
+ const mapKey = `${key.label}:${key.direction}`;
1117
+ if (seenForCandidate.has(mapKey))
1118
+ return;
1119
+ seenForCandidate.add(mapKey);
1120
+ const existing = byMetric.get(mapKey);
1121
+ if (!existing) {
1122
+ byMetric.set(mapKey, {
1123
+ key,
1124
+ candidate_count: 1,
1125
+ position_sum: metricIndex,
1126
+ latest_index: candidateIndex,
1127
+ });
1128
+ return;
1129
+ }
1130
+ existing.candidate_count += 1;
1131
+ existing.position_sum += metricIndex;
1132
+ existing.latest_index = candidateIndex;
1133
+ });
1134
+ });
1135
+ return [...byMetric.values()].sort((a, b) => {
1136
+ const coverageDelta = b.candidate_count - a.candidate_count;
1137
+ if (coverageDelta !== 0)
1138
+ return coverageDelta;
1139
+ const localityDelta = Number(isLocalValidationMetricLabel(b.key.label)) - Number(isLocalValidationMetricLabel(a.key.label));
1140
+ if (localityDelta !== 0)
1141
+ return localityDelta;
1142
+ const positionDelta = a.position_sum / a.candidate_count - b.position_sum / b.candidate_count;
1143
+ if (positionDelta !== 0)
1144
+ return positionDelta;
1145
+ return b.latest_index - a.latest_index;
1146
+ })[0]?.key ?? null;
1147
+ }
1148
+ function isLocalValidationMetricLabel(label) {
1149
+ const normalized = normalizeLineageText(label);
1150
+ const externalHints = ["public", "private", "leaderboard", "external", "lb", "submission"];
1151
+ for (const hint of externalHints) {
1152
+ if (normalized === hint || normalized.includes(hint)) {
1153
+ return false;
1154
+ }
1155
+ }
1156
+ return true;
1157
+ }
1158
+ function candidateComparableMetric(candidate, primaryMetric) {
1159
+ for (const metric of candidate.metrics) {
1160
+ if (primaryMetric && (metric.label !== primaryMetric.label || metric.direction !== primaryMetric.direction))
1161
+ continue;
1162
+ if (typeof metric.value !== "number" || !Number.isFinite(metric.value))
1163
+ continue;
1164
+ if (metric.direction !== "maximize" && metric.direction !== "minimize")
1165
+ continue;
1166
+ return {
1167
+ label: metric.label,
1168
+ value: metric.value,
1169
+ direction: metric.direction,
1170
+ confidence: metric.confidence ?? 1,
1171
+ };
1172
+ }
1173
+ return null;
1174
+ }
1175
+ function compareCandidateEvidenceContexts(a, b) {
1176
+ const metricDelta = compareCandidateMetrics(a.metric, b.metric);
1177
+ if (metricDelta !== 0)
1178
+ return metricDelta;
1179
+ const dispositionDelta = dispositionRank(b.candidate.disposition) - dispositionRank(a.candidate.disposition);
1180
+ if (dispositionDelta !== 0)
1181
+ return dispositionDelta;
1182
+ const confidenceDelta = (b.metric?.confidence ?? 0) - (a.metric?.confidence ?? 0);
1183
+ if (confidenceDelta !== 0)
1184
+ return confidenceDelta;
1185
+ return b.occurred_at.localeCompare(a.occurred_at);
1186
+ }
1187
+ function compareCandidateMetrics(a, b) {
1188
+ if (a && b && a.direction === b.direction) {
1189
+ const valueDelta = a.direction === "maximize" ? b.value - a.value : a.value - b.value;
1190
+ if (valueDelta !== 0)
1191
+ return valueDelta;
1192
+ }
1193
+ if (a && !b)
1194
+ return -1;
1195
+ if (!a && b)
1196
+ return 1;
1197
+ return 0;
1198
+ }
1199
+ function dispositionRank(disposition) {
1200
+ if (disposition === "promoted")
1201
+ return 2;
1202
+ if (disposition === "retained")
1203
+ return 1;
1204
+ return 0;
1205
+ }
1206
+ function mostSimilarSelectedCandidate(candidate, selected) {
1207
+ let best;
1208
+ for (const selectedCandidate of selected) {
1209
+ const similarity = similarityBetweenCandidates(candidate.candidate, selectedCandidate.candidate);
1210
+ if (!similarity)
1211
+ continue;
1212
+ if (!best || similarity.similarity > best.similarity)
1213
+ best = similarity;
1214
+ }
1215
+ return best;
1216
+ }
1217
+ function similarityBetweenCandidates(candidate, selected) {
1218
+ const direct = candidate.similarity.find((similarity) => similarity.candidate_id === selected.candidate_id);
1219
+ const inverse = selected.similarity.find((similarity) => similarity.candidate_id === candidate.candidate_id);
1220
+ if (direct && inverse)
1221
+ return direct.similarity >= inverse.similarity ? direct : inverse;
1222
+ if (direct)
1223
+ return direct;
1224
+ if (inverse) {
1225
+ return {
1226
+ ...inverse,
1227
+ candidate_id: selected.candidate_id,
1228
+ };
1229
+ }
1230
+ if (candidate.lineage.strategy_family === selected.lineage.strategy_family
1231
+ && candidateLineageFingerprint(candidate) === candidateLineageFingerprint(selected)) {
1232
+ return {
1233
+ candidate_id: selected.candidate_id,
1234
+ similarity: 0.9,
1235
+ signal: "lineage",
1236
+ summary: "candidate shares strategy family and lineage fingerprint",
1237
+ };
1238
+ }
1239
+ return undefined;
1240
+ }
1241
+ function candidateLineageFingerprint(candidate) {
1242
+ const lineage = candidate.lineage;
1243
+ return [
1244
+ lineage.strategy_family,
1245
+ ...lineage.feature_lineage,
1246
+ ...lineage.model_lineage,
1247
+ ...lineage.config_lineage,
1248
+ ...lineage.postprocess_lineage,
1249
+ ].map(normalizeLineageText).filter(Boolean).join("|");
1250
+ }
1251
+ function toPortfolioSlot(context) {
1252
+ const candidate = context.candidate;
1253
+ return {
1254
+ candidate_id: candidate.candidate_id,
1255
+ ...(candidate.label ? { label: candidate.label } : {}),
1256
+ strategy_family: candidate.lineage.strategy_family,
1257
+ role: context.role,
1258
+ evidence_entry_id: context.entry_id,
1259
+ occurred_at: context.occurred_at,
1260
+ ...(context.metric ? { metric: context.metric } : {}),
1261
+ ...(candidate.lineage.parent_candidate_id ? { parent_candidate_id: candidate.lineage.parent_candidate_id } : {}),
1262
+ ...(candidate.lineage.source_candidate_id ? { source_candidate_id: candidate.lineage.source_candidate_id } : {}),
1263
+ ...(candidate.lineage.source_strategy_id ? { source_strategy_id: candidate.lineage.source_strategy_id } : {}),
1264
+ disposition: candidate.disposition,
1265
+ ...(candidate.disposition_reason ? { retained_reason: candidate.disposition_reason } : {}),
1266
+ ...(context.similarity_to_selected ? { similarity_to_selected: context.similarity_to_selected } : {}),
1267
+ };
1268
+ }
1269
+ function summarizeFailedLineages(entriesOldestFirst) {
1270
+ const lineages = new Map();
1271
+ for (const entry of entriesOldestFirst) {
1272
+ if (!isFailedEvidenceEntry(entry))
1273
+ continue;
1274
+ const fingerprintInput = failedLineageFingerprintInput(entry);
1275
+ const normalizedIdentityParts = [
1276
+ normalizeLineageText(fingerprintInput.strategy_family),
1277
+ normalizeLineageText(fingerprintInput.hypothesis),
1278
+ normalizeLineageText(fingerprintInput.primary_dimension),
1279
+ normalizeLineageText(fingerprintInput.task_action),
1280
+ ].filter(Boolean);
1281
+ const normalizedFallbackParts = [normalizeLineageText(fingerprintInput.failure_reason)].filter(Boolean);
1282
+ const fingerprintParts = normalizedIdentityParts.length > 0 ? normalizedIdentityParts : normalizedFallbackParts;
1283
+ if (fingerprintParts.length === 0)
1284
+ continue;
1285
+ const fingerprint = fingerprintParts.join("|");
1286
+ const summary = entry.summary
1287
+ ?? entry.result?.summary
1288
+ ?? entry.verification?.summary
1289
+ ?? entry.result?.error
1290
+ ?? `${entry.kind} failed`;
1291
+ const existing = lineages.get(fingerprint);
1292
+ if (!existing) {
1293
+ lineages.set(fingerprint, {
1294
+ fingerprint,
1295
+ count: 1,
1296
+ first_seen_at: entry.occurred_at,
1297
+ last_seen_at: entry.occurred_at,
1298
+ ...(fingerprintInput.strategy_family ? { strategy_family: fingerprintInput.strategy_family } : {}),
1299
+ ...(fingerprintInput.hypothesis ? { hypothesis: fingerprintInput.hypothesis } : {}),
1300
+ ...(fingerprintInput.primary_dimension ? { primary_dimension: fingerprintInput.primary_dimension } : {}),
1301
+ ...(fingerprintInput.task_action ? { task_action: fingerprintInput.task_action } : {}),
1302
+ ...(fingerprintInput.failure_reason ? { failure_reason: fingerprintInput.failure_reason } : {}),
1303
+ representative_entry_id: entry.id,
1304
+ representative_summary: summary,
1305
+ evidence_entry_ids: [entry.id],
1306
+ });
1307
+ continue;
1308
+ }
1309
+ existing.count += 1;
1310
+ existing.last_seen_at = entry.occurred_at;
1311
+ existing.representative_entry_id = entry.id;
1312
+ existing.representative_summary = summary;
1313
+ existing.evidence_entry_ids = [...existing.evidence_entry_ids, entry.id].slice(-5);
1314
+ }
1315
+ return [...lineages.values()]
1316
+ .sort((a, b) => b.count - a.count || b.last_seen_at.localeCompare(a.last_seen_at))
1317
+ .slice(0, 10);
1318
+ }
1319
+ function isFailedEvidenceEntry(entry) {
1320
+ return entry.outcome === "failed"
1321
+ || entry.outcome === "regressed"
1322
+ || entry.kind === "failure"
1323
+ || entry.result?.status === "failed"
1324
+ || entry.verification?.verdict === "fail";
1325
+ }
1326
+ function failedLineageFingerprintInput(entry) {
1327
+ const strategyFamily = entry.strategy ?? entry.task?.action;
1328
+ return {
1329
+ ...(strategyFamily ? { strategy_family: strategyFamily } : {}),
1330
+ ...(entry.hypothesis ? { hypothesis: entry.hypothesis } : {}),
1331
+ ...(entry.task?.primary_dimension ? { primary_dimension: entry.task.primary_dimension } : {}),
1332
+ ...(entry.task?.action ? { task_action: entry.task.action } : {}),
1333
+ ...(entry.result?.error || entry.result?.summary || entry.verification?.summary
1334
+ ? { failure_reason: entry.result?.error ?? entry.result?.summary ?? entry.verification?.summary }
1335
+ : {}),
1336
+ };
1337
+ }
1338
+ function normalizeLineageText(value) {
1339
+ return value?.normalize("NFKC").toLocaleLowerCase().replace(/[^\p{Letter}\p{Number}]+/gu, " ").trim() ?? "";
1340
+ }
1341
+ function clamp01(value) {
1342
+ if (!Number.isFinite(value))
1343
+ return 0;
1344
+ return Math.min(1, Math.max(0, value));
1345
+ }
1346
+ function roundScore(value) {
1347
+ return Math.round(value * 1_000_000) / 1_000_000;
1348
+ }
1349
+ function chooseBestEvidence(entriesNewestFirst) {
1350
+ const metricBest = chooseBestMetricEvidence(entriesNewestFirst);
1351
+ if (metricBest)
1352
+ return metricBest;
1353
+ return chooseBestFallbackEvidence(entriesNewestFirst);
1354
+ }
1355
+ function chooseBestFallbackEvidence(entriesNewestFirst) {
1356
+ return entriesNewestFirst.find((entry) => entry.outcome === "improved")
1357
+ ?? entriesNewestFirst.find((entry) => entry.verification?.verdict === "pass")
1358
+ ?? entriesNewestFirst.find((entry) => entry.metrics.length > 0)
1359
+ ?? entriesNewestFirst.find((entry) => entry.kind === "artifact")
1360
+ ?? null;
1361
+ }
1362
+ function chooseBestMetricEvidence(entriesNewestFirst) {
1363
+ const primaryMetric = resolvePrimaryMetricKey(entriesNewestFirst);
1364
+ if (!primaryMetric)
1365
+ return null;
1366
+ const oldestFirst = [...entriesNewestFirst].reverse();
1367
+ const baseline = findComparableMetric(oldestFirst, primaryMetric)?.value;
1368
+ const candidates = entriesNewestFirst
1369
+ .map((entry) => {
1370
+ const metric = findComparableMetric([entry], primaryMetric);
1371
+ if (!metric)
1372
+ return null;
1373
+ return {
1374
+ entry,
1375
+ metric: metric.metric,
1376
+ value: metric.value,
1377
+ direction: metric.direction,
1378
+ primary_metric: primaryMetric,
1379
+ improvement_strength: baseline === undefined
1380
+ ? 0
1381
+ : metric.direction === "maximize"
1382
+ ? metric.value - baseline
1383
+ : baseline - metric.value,
1384
+ confidence: metric.metric.confidence ?? entry.verification?.confidence ?? 1,
1385
+ has_pass_verification: entry.verification?.verdict === "pass",
1386
+ has_artifact: entry.artifacts.length > 0 || entry.kind === "artifact",
1387
+ };
1388
+ })
1389
+ .filter((candidate) => Boolean(candidate));
1390
+ if (candidates.length === 0)
1391
+ return null;
1392
+ return candidates.sort(compareComparableEvidenceMetrics)[0]?.entry ?? null;
1393
+ }
1394
+ function resolvePrimaryMetricKey(entriesNewestFirst) {
1395
+ for (const entry of entriesNewestFirst) {
1396
+ const metric = findFirstDirectedNumericMetric(entry);
1397
+ if (metric?.direction === "maximize" || metric?.direction === "minimize") {
1398
+ return { label: metric.label, direction: metric.direction };
1399
+ }
1400
+ }
1401
+ return null;
1402
+ }
1403
+ function findComparableMetric(entries, key) {
1404
+ for (const entry of entries) {
1405
+ for (const metric of entry.metrics) {
1406
+ if (metric.label !== key.label || metric.direction !== key.direction)
1407
+ continue;
1408
+ const comparable = toComparableMetric(metric);
1409
+ if (comparable)
1410
+ return comparable;
1411
+ }
1412
+ }
1413
+ return null;
1414
+ }
1415
+ function findFirstDirectedNumericMetric(entry) {
1416
+ for (const metric of entry.metrics) {
1417
+ if (toComparableMetric(metric))
1418
+ return metric;
1419
+ }
1420
+ return null;
1421
+ }
1422
+ function toComparableMetric(metric) {
1423
+ if (typeof metric.value !== "number" || !Number.isFinite(metric.value))
1424
+ return null;
1425
+ if (metric.direction !== "maximize" && metric.direction !== "minimize")
1426
+ return null;
1427
+ return {
1428
+ metric,
1429
+ value: metric.value,
1430
+ direction: metric.direction,
1431
+ };
1432
+ }
1433
+ function compareComparableEvidenceMetrics(a, b) {
1434
+ const direction = a.direction;
1435
+ const valueDelta = direction === "maximize" ? b.value - a.value : a.value - b.value;
1436
+ if (valueDelta !== 0)
1437
+ return valueDelta;
1438
+ const passDelta = Number(b.has_pass_verification) - Number(a.has_pass_verification);
1439
+ if (passDelta !== 0)
1440
+ return passDelta;
1441
+ const artifactDelta = Number(b.has_artifact) - Number(a.has_artifact);
1442
+ if (artifactDelta !== 0)
1443
+ return artifactDelta;
1444
+ const confidenceDelta = b.confidence - a.confidence;
1445
+ if (confidenceDelta !== 0)
1446
+ return confidenceDelta;
1447
+ const improvementDelta = b.improvement_strength - a.improvement_strength;
1448
+ if (improvementDelta !== 0)
1449
+ return improvementDelta;
1450
+ return b.entry.occurred_at.localeCompare(a.entry.occurred_at);
1451
+ }
1452
+ //# sourceMappingURL=evidence-ledger.js.map