@interf/compiler 0.13.0 → 0.18.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 (320) hide show
  1. package/LICENSE.md +1 -0
  2. package/README.md +50 -7
  3. package/TRADEMARKS.md +4 -4
  4. package/agent-skills/interf-actions/SKILL.md +51 -5
  5. package/agent-skills/interf-actions/references/cli.md +82 -82
  6. package/builtin-methods/interf-default/README.md +6 -7
  7. package/builtin-methods/interf-default/method.json +7 -68
  8. package/builtin-methods/interf-default/method.schema.json +52 -50
  9. package/dist/cli/commands/agents.d.ts +2 -0
  10. package/dist/cli/commands/agents.js +213 -0
  11. package/dist/cli/commands/compile.js +10 -1
  12. package/dist/cli/commands/doctor.js +1 -1
  13. package/dist/cli/commands/login.js +1 -1
  14. package/dist/cli/commands/logout.js +1 -1
  15. package/dist/cli/commands/mcp.d.ts +42 -0
  16. package/dist/cli/commands/mcp.js +239 -0
  17. package/dist/cli/commands/method.js +1 -1
  18. package/dist/cli/commands/prep.js +81 -7
  19. package/dist/cli/commands/reset.js +1 -1
  20. package/dist/cli/commands/runs.js +1 -1
  21. package/dist/cli/commands/status.js +1 -1
  22. package/dist/cli/commands/verify.d.ts +10 -0
  23. package/dist/cli/commands/{test.js → verify.js} +30 -15
  24. package/dist/cli/commands/web.js +71 -18
  25. package/dist/cli/commands/wizard.js +462 -107
  26. package/dist/cli/index.d.ts +4 -2
  27. package/dist/cli/index.js +7 -3
  28. package/dist/compiler-ui/404.html +1 -1
  29. package/dist/compiler-ui/__next.__PAGE__.txt +2 -2
  30. package/dist/compiler-ui/__next._full.txt +3 -3
  31. package/dist/compiler-ui/__next._head.txt +1 -1
  32. package/dist/compiler-ui/__next._index.txt +2 -2
  33. package/dist/compiler-ui/__next._tree.txt +2 -2
  34. package/dist/compiler-ui/_next/static/chunks/{045gole2ojo3g.css → 0_c_tvh-cukjz.css} +1 -1
  35. package/dist/compiler-ui/_next/static/chunks/0f_geuwdesg_c.js +114 -0
  36. package/dist/compiler-ui/_not-found/__next._full.txt +2 -2
  37. package/dist/compiler-ui/_not-found/__next._head.txt +1 -1
  38. package/dist/compiler-ui/_not-found/__next._index.txt +2 -2
  39. package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
  40. package/dist/compiler-ui/_not-found/__next._not-found.txt +1 -1
  41. package/dist/compiler-ui/_not-found/__next._tree.txt +2 -2
  42. package/dist/compiler-ui/_not-found.html +1 -1
  43. package/dist/compiler-ui/_not-found.txt +2 -2
  44. package/dist/compiler-ui/index.html +1 -1
  45. package/dist/compiler-ui/index.txt +3 -3
  46. package/dist/index.d.ts +2 -2
  47. package/dist/index.js +2 -2
  48. package/dist/packages/contracts/index.d.ts +2 -1
  49. package/dist/packages/contracts/index.js +1 -0
  50. package/dist/packages/contracts/lib/schema.d.ts +324 -31
  51. package/dist/packages/contracts/lib/schema.js +281 -21
  52. package/dist/packages/{local-service → engine}/action-definitions.js +9 -2
  53. package/dist/packages/{local-service → engine}/action-planner.d.ts +1 -1
  54. package/dist/packages/{local-service → engine}/action-planner.js +1 -1
  55. package/dist/packages/{agents → engine/agents}/index.d.ts +3 -0
  56. package/dist/packages/{agents → engine/agents}/index.js +3 -0
  57. package/dist/packages/{agents → engine/agents}/lib/compiled-bootstrap.js +2 -2
  58. package/dist/packages/engine/agents/lib/detection.d.ts +13 -0
  59. package/dist/packages/{agents → engine/agents}/lib/detection.js +11 -0
  60. package/dist/packages/{agents → engine/agents}/lib/executors.d.ts +2 -2
  61. package/dist/packages/{agents → engine/agents}/lib/shells.d.ts +14 -6
  62. package/dist/packages/{agents → engine/agents}/lib/shells.js +133 -126
  63. package/dist/packages/{agents → engine/agents}/lib/user-config.js +2 -2
  64. package/dist/packages/engine/agents/registry.d.ts +91 -0
  65. package/dist/packages/engine/agents/registry.js +321 -0
  66. package/dist/packages/engine/agents/role-executors.d.ts +35 -0
  67. package/dist/packages/engine/agents/role-executors.js +88 -0
  68. package/dist/packages/engine/agents/role-router.d.ts +66 -0
  69. package/dist/packages/engine/agents/role-router.js +73 -0
  70. package/dist/packages/{local-service → engine}/client.d.ts +9 -9
  71. package/dist/packages/{local-service → engine}/client.js +11 -11
  72. package/dist/packages/engine/cloud-seams.d.ts +115 -0
  73. package/dist/packages/engine/cloud-seams.js +84 -0
  74. package/dist/packages/engine/compile/artifact-counts.d.ts +1 -0
  75. package/dist/packages/{compiler → engine/compile}/artifact-counts.js +4 -4
  76. package/dist/packages/engine/compile/artifact-status.d.ts +41 -0
  77. package/dist/packages/engine/compile/artifact-status.js +166 -0
  78. package/dist/packages/engine/compile/billing-events.d.ts +89 -0
  79. package/dist/packages/engine/compile/billing-events.js +74 -0
  80. package/dist/packages/engine/compile/check-evaluator.d.ts +66 -0
  81. package/dist/packages/engine/compile/check-evaluator.js +298 -0
  82. package/dist/packages/{compiler → engine/compile}/compiled-pipeline.d.ts +12 -1
  83. package/dist/packages/{compiler → engine/compile}/compiled-pipeline.js +16 -6
  84. package/dist/packages/engine/compile/compiled-schema.d.ts +21 -0
  85. package/dist/packages/engine/compile/compiled-schema.js +126 -0
  86. package/dist/packages/{compiler → engine/compile}/compiled-stage-plan.d.ts +2 -1
  87. package/dist/packages/{compiler → engine/compile}/compiled-stage-plan.js +35 -18
  88. package/dist/packages/{compiler → engine/compile}/compiled-stage-runner.d.ts +1 -1
  89. package/dist/packages/{compiler → engine/compile}/compiled-stage-runner.js +4 -4
  90. package/dist/packages/{compiler → engine/compile}/compiled-target.d.ts +2 -2
  91. package/dist/packages/{compiler → engine/compile}/compiled-target.js +2 -2
  92. package/dist/packages/{compiler → engine/compile}/discovery.js +1 -1
  93. package/dist/packages/{compiler → engine/compile}/index.d.ts +0 -1
  94. package/dist/packages/{compiler → engine/compile}/index.js +0 -1
  95. package/dist/packages/{compiler → engine/compile}/lib/schema.d.ts +113 -94
  96. package/dist/packages/{compiler → engine/compile}/lib/schema.js +35 -39
  97. package/dist/packages/engine/compile/method-primitives.d.ts +2 -0
  98. package/dist/packages/{compiler → engine/compile}/method-primitives.js +1 -1
  99. package/dist/packages/{compiler → engine/compile}/method-runs.d.ts +3 -3
  100. package/dist/packages/{compiler → engine/compile}/method-runs.js +3 -3
  101. package/dist/packages/{compiler → engine/compile}/reset.js +4 -4
  102. package/dist/packages/{compiler → engine/compile}/runtime-contracts.js +2 -1
  103. package/dist/packages/{compiler → engine/compile}/runtime-prompt.js +3 -2
  104. package/dist/packages/{compiler → engine/compile}/runtime-reconcile.d.ts +1 -1
  105. package/dist/packages/{compiler → engine/compile}/runtime-reconcile.js +47 -45
  106. package/dist/packages/{compiler → engine/compile}/runtime-runs.d.ts +1 -2
  107. package/dist/packages/{compiler → engine/compile}/runtime-runs.js +3 -44
  108. package/dist/packages/{compiler → engine/compile}/runtime-types.d.ts +7 -12
  109. package/dist/packages/engine/compile/runtime.d.ts +5 -0
  110. package/dist/packages/{compiler → engine/compile}/runtime.js +1 -2
  111. package/dist/packages/{compiler → engine/compile}/source-files.d.ts +1 -1
  112. package/dist/packages/{compiler → engine/compile}/source-files.js +3 -3
  113. package/dist/packages/{compiler → engine/compile}/state-health.js +8 -8
  114. package/dist/packages/{compiler → engine/compile}/state-io.js +2 -2
  115. package/dist/packages/{compiler → engine/compile}/state-view.js +9 -8
  116. package/dist/packages/{compiler → engine/compile}/validate-compiled.js +63 -32
  117. package/dist/packages/{compiler → engine/compile}/validate.d.ts +1 -1
  118. package/dist/packages/{compiler → engine/compile}/validate.js +29 -27
  119. package/dist/packages/{execution → engine/execution}/lib/schema.d.ts +81 -55
  120. package/dist/packages/{execution → engine/execution}/lib/schema.js +14 -6
  121. package/dist/packages/engine/index.d.ts +22 -0
  122. package/dist/packages/engine/index.js +15 -0
  123. package/dist/packages/{local-service → engine}/lib/schema.d.ts +620 -435
  124. package/dist/packages/{local-service → engine}/lib/schema.js +103 -63
  125. package/dist/packages/{local-service → engine}/native-run-handlers.d.ts +7 -5
  126. package/dist/packages/{local-service → engine}/native-run-handlers.js +81 -29
  127. package/dist/packages/{local-service → engine}/preparation-store.d.ts +22 -4
  128. package/dist/packages/{local-service → engine}/preparation-store.js +56 -25
  129. package/dist/packages/{local-service → engine}/readiness-check-draft.d.ts +2 -2
  130. package/dist/packages/{local-service → engine}/routes.d.ts +36 -1
  131. package/dist/packages/{local-service → engine}/routes.js +38 -1
  132. package/dist/packages/{local-service → engine}/run-observability.d.ts +3 -3
  133. package/dist/packages/{local-service → engine}/run-observability.js +15 -15
  134. package/dist/packages/{local-service → engine}/runtime-event-applier.d.ts +1 -1
  135. package/dist/packages/{local-service → engine}/runtime-event-applier.js +7 -0
  136. package/dist/packages/{local-service → engine}/runtime-persistence.d.ts +6 -6
  137. package/dist/packages/{local-service → engine}/runtime-persistence.js +9 -9
  138. package/dist/packages/{local-service → engine}/runtime-proposal-helpers.d.ts +1 -1
  139. package/dist/packages/{local-service → engine}/runtime-proposal-helpers.js +5 -5
  140. package/dist/packages/{local-service → engine}/runtime-resource-builders.d.ts +12 -12
  141. package/dist/packages/{local-service → engine}/runtime-resource-builders.js +6 -5
  142. package/dist/packages/{local-service → engine}/runtime.d.ts +147 -56
  143. package/dist/packages/{local-service → engine}/runtime.js +333 -205
  144. package/dist/packages/{local-service → engine}/server.d.ts +25 -0
  145. package/dist/packages/{local-service → engine}/server.js +338 -17
  146. package/dist/packages/engine/verify/index.d.ts +13 -0
  147. package/dist/packages/engine/verify/index.js +10 -0
  148. package/dist/packages/{testing → engine/verify}/lib/schema.d.ts +1 -1
  149. package/dist/packages/{testing → engine/verify}/lib/schema.js +1 -1
  150. package/dist/packages/{testing → engine/verify}/readiness-check-run.d.ts +27 -11
  151. package/dist/packages/{testing → engine/verify}/readiness-check-run.js +72 -60
  152. package/dist/packages/{testing/test-execution.d.ts → engine/verify/verify-execution.d.ts} +2 -2
  153. package/dist/packages/{testing/test-execution.js → engine/verify/verify-execution.js} +2 -2
  154. package/dist/packages/{testing/test-paths.d.ts → engine/verify/verify-paths.d.ts} +1 -1
  155. package/dist/packages/{testing/test-paths.js → engine/verify/verify-paths.js} +2 -2
  156. package/dist/packages/{testing/test-sandbox.d.ts → engine/verify/verify-sandbox.d.ts} +1 -1
  157. package/dist/packages/{testing/test-sandbox.js → engine/verify/verify-sandbox.js} +6 -6
  158. package/dist/packages/{testing/test-specs.d.ts → engine/verify/verify-specs.d.ts} +1 -1
  159. package/dist/packages/{testing/test-specs.js → engine/verify/verify-specs.js} +2 -2
  160. package/dist/packages/{testing/test-targets.d.ts → engine/verify/verify-targets.d.ts} +1 -1
  161. package/dist/packages/{testing/test-targets.js → engine/verify/verify-targets.js} +3 -3
  162. package/dist/packages/{testing/test.d.ts → engine/verify/verify.d.ts} +4 -4
  163. package/dist/packages/{testing/test.js → engine/verify/verify.js} +3 -3
  164. package/dist/packages/engine/wire-schemas.d.ts +545 -0
  165. package/dist/packages/engine/wire-schemas.js +59 -0
  166. package/dist/packages/methods/authoring/method-authoring.d.ts +34 -0
  167. package/dist/packages/methods/authoring/method-authoring.js +260 -0
  168. package/dist/packages/{method-authoring → methods/authoring}/method-edit-session.d.ts +2 -2
  169. package/dist/packages/{method-authoring → methods/authoring}/method-edit-session.js +5 -5
  170. package/dist/packages/{method-authoring → methods/authoring}/method-improvement.d.ts +4 -4
  171. package/dist/packages/{method-authoring → methods/authoring}/method-improvement.js +16 -10
  172. package/dist/packages/{method-package → methods/package}/builtin-compiled-method.d.ts +12 -12
  173. package/dist/packages/{method-package → methods/package}/builtin-compiled-method.js +27 -24
  174. package/dist/packages/methods/package/context-interface.d.ts +73 -0
  175. package/dist/packages/{method-package → methods/package}/context-interface.js +50 -41
  176. package/dist/packages/{method-package → methods/package}/interf-method-package.js +31 -49
  177. package/dist/packages/{method-package → methods/package}/lib/package-root.js +2 -2
  178. package/dist/packages/{method-package → methods/package}/local-methods.d.ts +10 -5
  179. package/dist/packages/{method-package → methods/package}/local-methods.js +41 -68
  180. package/dist/packages/{method-package → methods/package}/method-definitions.d.ts +11 -7
  181. package/dist/packages/{method-package → methods/package}/method-definitions.js +5 -8
  182. package/dist/packages/{method-package → methods/package}/method-helpers.d.ts +1 -3
  183. package/dist/packages/{method-package → methods/package}/method-helpers.js +4 -8
  184. package/dist/packages/{method-package → methods/package}/method-review-paths.d.ts +1 -1
  185. package/dist/packages/{method-package → methods/package}/method-review-paths.js +1 -1
  186. package/dist/packages/{method-package → methods/package}/method-stage-runner.d.ts +4 -9
  187. package/dist/packages/{method-package → methods/package}/method-stage-runner.js +1 -29
  188. package/dist/packages/{method-package → methods/package}/user-methods.js +2 -2
  189. package/dist/packages/{project-model → project}/interf-bootstrap.d.ts +1 -1
  190. package/dist/packages/{project-model → project}/interf-bootstrap.js +1 -1
  191. package/dist/packages/{project-model → project}/interf-detect.js +4 -4
  192. package/dist/packages/{project-model → project}/interf-scaffold.js +18 -18
  193. package/dist/packages/{project-model → project}/lib/schema.d.ts +2 -2
  194. package/dist/packages/{project-model → project}/lib/schema.js +1 -1
  195. package/dist/packages/{project-model → project}/source-config.d.ts +1 -1
  196. package/dist/packages/{project-model → project}/source-config.js +9 -8
  197. package/dist/packages/{project-model → project}/source-folders.js +2 -2
  198. package/package.json +7 -16
  199. package/dist/cli/commands/test.d.ts +0 -9
  200. package/dist/compiler-ui/_next/static/chunks/17t-lulmyawg5.js +0 -89
  201. package/dist/packages/agents/lib/detection.d.ts +0 -7
  202. package/dist/packages/compiler/artifact-counts.d.ts +0 -1
  203. package/dist/packages/compiler/compiled-schema.d.ts +0 -31
  204. package/dist/packages/compiler/compiled-schema.js +0 -141
  205. package/dist/packages/compiler/method-primitives.d.ts +0 -2
  206. package/dist/packages/compiler/runtime-acceptance.d.ts +0 -9
  207. package/dist/packages/compiler/runtime-acceptance.js +0 -262
  208. package/dist/packages/compiler/runtime.d.ts +0 -6
  209. package/dist/packages/local-service/index.d.ts +0 -22
  210. package/dist/packages/local-service/index.js +0 -15
  211. package/dist/packages/method-authoring/method-authoring.d.ts +0 -24
  212. package/dist/packages/method-authoring/method-authoring.js +0 -116
  213. package/dist/packages/method-package/context-interface.d.ts +0 -60
  214. package/dist/packages/testing/index.d.ts +0 -13
  215. package/dist/packages/testing/index.js +0 -10
  216. /package/dist/compiler-ui/_next/static/{C6vVfy3aeYuIO3d2AoNvC → 6qyE1u9m_oBUkvAhhoCmO}/_buildManifest.js +0 -0
  217. /package/dist/compiler-ui/_next/static/{C6vVfy3aeYuIO3d2AoNvC → 6qyE1u9m_oBUkvAhhoCmO}/_clientMiddlewareManifest.js +0 -0
  218. /package/dist/compiler-ui/_next/static/{C6vVfy3aeYuIO3d2AoNvC → 6qyE1u9m_oBUkvAhhoCmO}/_ssgManifest.js +0 -0
  219. /package/dist/packages/{shared → contracts/utils}/file-types.d.ts +0 -0
  220. /package/dist/packages/{shared → contracts/utils}/file-types.js +0 -0
  221. /package/dist/packages/{shared → contracts/utils}/filesystem.d.ts +0 -0
  222. /package/dist/packages/{shared → contracts/utils}/filesystem.js +0 -0
  223. /package/dist/packages/{shared → contracts/utils}/logger.d.ts +0 -0
  224. /package/dist/packages/{shared → contracts/utils}/logger.js +0 -0
  225. /package/dist/packages/{shared → contracts/utils}/naming.d.ts +0 -0
  226. /package/dist/packages/{shared → contracts/utils}/naming.js +0 -0
  227. /package/dist/packages/{shared → contracts/utils}/parse.d.ts +0 -0
  228. /package/dist/packages/{shared → contracts/utils}/parse.js +0 -0
  229. /package/dist/packages/{shared → contracts/utils}/path-guards.d.ts +0 -0
  230. /package/dist/packages/{shared → contracts/utils}/path-guards.js +0 -0
  231. /package/dist/packages/{local-service → engine}/action-definitions.d.ts +0 -0
  232. /package/dist/packages/{local-service → engine}/action-values.d.ts +0 -0
  233. /package/dist/packages/{local-service → engine}/action-values.js +0 -0
  234. /package/dist/packages/{agents → engine/agents}/lib/agents.d.ts +0 -0
  235. /package/dist/packages/{agents → engine/agents}/lib/agents.js +0 -0
  236. /package/dist/packages/{agents → engine/agents}/lib/args.d.ts +0 -0
  237. /package/dist/packages/{agents → engine/agents}/lib/args.js +0 -0
  238. /package/dist/packages/{agents → engine/agents}/lib/chart-guidance.d.ts +0 -0
  239. /package/dist/packages/{agents → engine/agents}/lib/chart-guidance.js +0 -0
  240. /package/dist/packages/{agents → engine/agents}/lib/compiled-bootstrap.d.ts +0 -0
  241. /package/dist/packages/{agents → engine/agents}/lib/constants.d.ts +0 -0
  242. /package/dist/packages/{agents → engine/agents}/lib/constants.js +0 -0
  243. /package/dist/packages/{agents → engine/agents}/lib/execution-profile.d.ts +0 -0
  244. /package/dist/packages/{agents → engine/agents}/lib/execution-profile.js +0 -0
  245. /package/dist/packages/{agents → engine/agents}/lib/execution.d.ts +0 -0
  246. /package/dist/packages/{agents → engine/agents}/lib/execution.js +0 -0
  247. /package/dist/packages/{agents → engine/agents}/lib/executors.js +0 -0
  248. /package/dist/packages/{agents → engine/agents}/lib/logs.d.ts +0 -0
  249. /package/dist/packages/{agents → engine/agents}/lib/logs.js +0 -0
  250. /package/dist/packages/{agents → engine/agents}/lib/preflight.d.ts +0 -0
  251. /package/dist/packages/{agents → engine/agents}/lib/preflight.js +0 -0
  252. /package/dist/packages/{agents → engine/agents}/lib/render.d.ts +0 -0
  253. /package/dist/packages/{agents → engine/agents}/lib/render.js +0 -0
  254. /package/dist/packages/{agents → engine/agents}/lib/schema.d.ts +0 -0
  255. /package/dist/packages/{agents → engine/agents}/lib/schema.js +0 -0
  256. /package/dist/packages/{agents → engine/agents}/lib/status.d.ts +0 -0
  257. /package/dist/packages/{agents → engine/agents}/lib/status.js +0 -0
  258. /package/dist/packages/{agents → engine/agents}/lib/types.d.ts +0 -0
  259. /package/dist/packages/{agents → engine/agents}/lib/types.js +0 -0
  260. /package/dist/packages/{agents → engine/agents}/lib/user-config.d.ts +0 -0
  261. /package/dist/packages/{compiler → engine/compile}/compiled-compile.d.ts +0 -0
  262. /package/dist/packages/{compiler → engine/compile}/compiled-compile.js +0 -0
  263. /package/dist/packages/{compiler → engine/compile}/compiled-paths.d.ts +0 -0
  264. /package/dist/packages/{compiler → engine/compile}/compiled-paths.js +0 -0
  265. /package/dist/packages/{compiler → engine/compile}/discovery.d.ts +0 -0
  266. /package/dist/packages/{compiler → engine/compile}/reset.d.ts +0 -0
  267. /package/dist/packages/{compiler → engine/compile}/runtime-contracts.d.ts +0 -0
  268. /package/dist/packages/{compiler → engine/compile}/runtime-inventory.d.ts +0 -0
  269. /package/dist/packages/{compiler → engine/compile}/runtime-inventory.js +0 -0
  270. /package/dist/packages/{compiler → engine/compile}/runtime-paths.d.ts +0 -0
  271. /package/dist/packages/{compiler → engine/compile}/runtime-paths.js +0 -0
  272. /package/dist/packages/{compiler → engine/compile}/runtime-prompt.d.ts +0 -0
  273. /package/dist/packages/{compiler → engine/compile}/runtime-types.js +0 -0
  274. /package/dist/packages/{compiler → engine/compile}/state-artifacts.d.ts +0 -0
  275. /package/dist/packages/{compiler → engine/compile}/state-artifacts.js +0 -0
  276. /package/dist/packages/{compiler → engine/compile}/state-health.d.ts +0 -0
  277. /package/dist/packages/{compiler → engine/compile}/state-io.d.ts +0 -0
  278. /package/dist/packages/{compiler → engine/compile}/state-paths.d.ts +0 -0
  279. /package/dist/packages/{compiler → engine/compile}/state-paths.js +0 -0
  280. /package/dist/packages/{compiler → engine/compile}/state-view.d.ts +0 -0
  281. /package/dist/packages/{compiler → engine/compile}/state.d.ts +0 -0
  282. /package/dist/packages/{compiler → engine/compile}/state.js +0 -0
  283. /package/dist/packages/{compiler → engine/compile}/validate-compiled.d.ts +0 -0
  284. /package/dist/packages/{compiler → engine/compile}/validate-helpers.d.ts +0 -0
  285. /package/dist/packages/{compiler → engine/compile}/validate-helpers.js +0 -0
  286. /package/dist/packages/{local-service → engine}/connection-config.d.ts +0 -0
  287. /package/dist/packages/{local-service → engine}/connection-config.js +0 -0
  288. /package/dist/packages/{execution → engine/execution}/adapters.d.ts +0 -0
  289. /package/dist/packages/{execution → engine/execution}/adapters.js +0 -0
  290. /package/dist/packages/{execution → engine/execution}/events.d.ts +0 -0
  291. /package/dist/packages/{execution → engine/execution}/events.js +0 -0
  292. /package/dist/packages/{execution → engine/execution}/index.d.ts +0 -0
  293. /package/dist/packages/{execution → engine/execution}/index.js +0 -0
  294. /package/dist/packages/{local-service → engine}/instance-paths.d.ts +0 -0
  295. /package/dist/packages/{local-service → engine}/instance-paths.js +0 -0
  296. /package/dist/packages/{local-service → engine}/readiness-check-draft.js +0 -0
  297. /package/dist/packages/{local-service → engine}/runtime-caches.d.ts +0 -0
  298. /package/dist/packages/{local-service → engine}/runtime-caches.js +0 -0
  299. /package/dist/packages/{local-service → engine}/service-registry.d.ts +0 -0
  300. /package/dist/packages/{local-service → engine}/service-registry.js +0 -0
  301. /package/dist/packages/{testing/test-profile-presets.d.ts → engine/verify/verify-profile-presets.d.ts} +0 -0
  302. /package/dist/packages/{testing/test-profile-presets.js → engine/verify/verify-profile-presets.js} +0 -0
  303. /package/dist/packages/{testing/test-types.d.ts → engine/verify/verify-types.d.ts} +0 -0
  304. /package/dist/packages/{testing/test-types.js → engine/verify/verify-types.js} +0 -0
  305. /package/dist/packages/{method-authoring → methods/authoring}/index.d.ts +0 -0
  306. /package/dist/packages/{method-authoring → methods/authoring}/index.js +0 -0
  307. /package/dist/packages/{method-authoring → methods/authoring}/lib/method-edit-utils.d.ts +0 -0
  308. /package/dist/packages/{method-authoring → methods/authoring}/lib/method-edit-utils.js +0 -0
  309. /package/dist/packages/{method-package → methods/package}/interf-method-package.d.ts +0 -0
  310. /package/dist/packages/{method-package → methods/package}/lib/package-root.d.ts +0 -0
  311. /package/dist/packages/{method-package → methods/package}/user-methods.d.ts +0 -0
  312. /package/dist/packages/{project-model → project}/index.d.ts +0 -0
  313. /package/dist/packages/{project-model → project}/index.js +0 -0
  314. /package/dist/packages/{project-model → project}/interf-detect.d.ts +0 -0
  315. /package/dist/packages/{project-model → project}/interf-scaffold.d.ts +0 -0
  316. /package/dist/packages/{project-model → project}/interf.d.ts +0 -0
  317. /package/dist/packages/{project-model → project}/interf.js +0 -0
  318. /package/dist/packages/{project-model → project}/preparation-entries.d.ts +0 -0
  319. /package/dist/packages/{project-model → project}/preparation-entries.js +0 -0
  320. /package/dist/packages/{project-model → project}/source-folders.d.ts +0 -0
@@ -1,37 +1,43 @@
1
1
  import { existsSync, mkdirSync, rmSync, statSync, } from "node:fs";
2
2
  import { join, resolve } from "node:path";
3
- import { CompileRunSchema, } from "../execution/lib/schema.js";
4
- import { createRunEventId, createRunEventTimestamp, } from "../execution/events.js";
5
- import { loadState, } from "../compiler/state.js";
6
- import { actionProposalPath, actionProposalsRoot, byCreatedAtDesc, compileRunPath, compileRunsRoot, listJsonFiles, localJobPath, localJobsRoot, newestFirst, readActionProposalAt, readCompileRunAt, readLocalJobRunAt, readRuntimeRunHistory, readTestRunAt, testRunPath, testRunsRoot, timestampKey, writeJsonFile, } from "./runtime-persistence.js";
3
+ import { CompileRunSchema, } from "./execution/lib/schema.js";
4
+ import { createRunEventId, createRunEventTimestamp, } from "./execution/events.js";
5
+ import { loadState, } from "./compile/state.js";
6
+ import { actionProposalPath, actionProposalsRoot, byCreatedAtDesc, compileRunPath, compileRunsRoot, listJsonFiles, localJobPath, localJobsRoot, newestFirst, readActionProposalAt, readCompileRunAt, readLocalJobRunAt, readRuntimeRunHistory, readVerifyRunAt, verifyRunPath, verifyRunsRoot, timestampKey, writeJsonFile, } from "./runtime-persistence.js";
7
7
  import { MethodListingCache, MtimeListingCache, ReadinessCache, RunListingCache, } from "./runtime-caches.js";
8
8
  import { applyEventToCompileRun, applyEventToLocalJob, } from "./runtime-event-applier.js";
9
9
  import { buildMethodResource, buildPreparationResource, createRunId, logsForRuntimeRun, logsForStageRun, proofForStage, readinessStateToPreparationReadiness, readinessSummaryForStatus, readinessTargetResult, stageArtifactRefs, } from "./runtime-resource-builders.js";
10
- import { ACTION_PLANNER_CLARIFICATION_MESSAGE, actionAssistantMessage, actionCommandPreview, actionTypeFromValues, actionValueMethodTaskPrompt, configuredAgentName, createActionProposalId, detachMethodFromPreparation, detectedExecutorOptions, directServiceEndpointForAction, hasCompiledTestTarget, methodAuthoringHintFromPrompt, methodAuthoringPromptFallback, methodIdForProposal, methodLabelFromId, numberValue, requireSelectedMethod, sanitizeActionProposalPlan, stringValue, testModeFromValues, testModeValue, } from "./runtime-proposal-helpers.js";
11
- import { ReadinessStateSchema, } from "../contracts/lib/schema.js";
12
- import { discoverSourceFiles, } from "../compiler/discovery.js";
13
- import { resetCompiledGeneratedState, } from "../compiler/reset.js";
14
- import { ensurePortableContextScaffold, readInterfConfig, } from "../project-model/interf.js";
15
- import { findSourcePreparationConfig, fingerprintReadinessChecks, listSourcePreparationConfigs, loadSourceFolderConfig, DEFAULT_METHOD_ID, methodIdForSourcePreparationConfig, resolveConfiguredSourceFolderPath, resolveSourcePreparationPath, removeSourcePreparationConfig, saveSourceFolderConfig, syncCompiledInterfConfigFromSourcePreparationConfig, upsertSourcePreparationConfig, } from "../project-model/source-config.js";
16
- import { listSourceFolderChoices, } from "../project-model/source-folders.js";
10
+ import { ACTION_PLANNER_CLARIFICATION_MESSAGE, actionAssistantMessage, actionCommandPreview, actionTypeFromValues, actionValueMethodTaskPrompt, configuredAgentName, createActionProposalId, detachMethodFromPreparation, detectedExecutorOptions, directServiceEndpointForAction, hasCompiledTestTarget, methodAuthoringHintFromPrompt, methodAuthoringPromptFallback, methodIdForProposal, methodLabelFromId, numberValue, requireSelectedMethod, sanitizeActionProposalPlan, stringValue, testModeFromValues, } from "./runtime-proposal-helpers.js";
11
+ import { ReadinessSchema, } from "../contracts/lib/schema.js";
12
+ import { discoverSourceFiles, } from "./compile/discovery.js";
13
+ import { resetCompiledGeneratedState, } from "./compile/reset.js";
14
+ import { ensurePortableContextScaffold, readInterfConfig, } from "../project/interf.js";
15
+ import { findSourcePreparationConfig, fingerprintReadinessChecks, listSourcePreparationConfigs, loadSourceFolderConfig, DEFAULT_METHOD_ID, methodIdForSourcePreparationConfig, resolveConfiguredSourceFolderPath, resolveSourcePreparationPath, removeSourcePreparationConfig, saveSourceFolderConfig, syncCompiledInterfConfigFromSourcePreparationConfig, upsertSourcePreparationConfig, } from "../project/source-config.js";
16
+ import { listSourceFolderChoices, } from "../project/source-folders.js";
17
17
  import { asPreparationDataDir, preparationPortableContextPath, userMethodsRoot, preparationConfigPath, preparationMethodPackagePath, preparationMethodsRoot, } from "../contracts/lib/preparation-paths.js";
18
- import { getCompiledMethod, listCompiledMethodChoices, } from "../method-package/method-definitions.js";
19
- import { contextInterfaceArtifactPath, } from "../method-package/context-interface.js";
20
- import { methodDefinitionPath, resolveMethodPackageSourcePath, seedLocalDefaultMethod, } from "../method-package/local-methods.js";
21
- import { seedLocalMethodPackageFromBase, } from "../method-package/interf-method-package.js";
22
- import { PACKAGE_ROOT } from "../method-package/lib/package-root.js";
23
- import { resolveAgent, detectAgents, supportsAutomatedRuns, } from "../agents/lib/detection.js";
24
- import { loadUserConfig, saveUserConfig, } from "../agents/lib/user-config.js";
25
- import { readSavedReadinessCheckRun, } from "../testing/readiness-check-run.js";
26
- import { createCompiledTestTarget, } from "../testing/test-targets.js";
27
- import { ActionProposalApprovalRequestSchema, ActionProposalCreateRequestSchema, ActionProposalPlanSchema, ActionProposalResourceSchema, ActionProposalTypeSchema, CompileRunCreateRequestSchema, CompileRunResourceSchema, LocalExecutorStatusSchema, LocalExecutorSelectRequestSchema, LocalServiceHealthSchema, LocalRunHandlerResultSchema, LocalJobEventAppendRequestSchema, LocalJobRunCreateRequestSchema, LocalJobRunResourceSchema, SourceFileResourceSchema, WorkspaceFileResourceSchema, PortableContextResourceSchema, PreparationSetupCreateRequestSchema, PreparationSetupResultSchema, WorkspaceBootstrapCreateRequestSchema, WorkspaceBootstrapResultSchema, MethodChangeCreateRequestSchema, MethodChangeResultSchema, PreparationChangeCreateRequestSchema, PreparationChangeResultSchema, ReadinessCheckDraftCreateRequestSchema, ReadinessCheckDraftResultSchema, ResetRequestSchema, ResetResultSchema, ServiceRegistryWorkspaceSchema, TestRunCreateRequestSchema, TestRunResourceSchema, MethodAuthoringCreateRequestSchema, MethodAuthoringResultSchema, } from "./lib/schema.js";
18
+ import { getCompiledMethod, listCompiledMethodChoices, } from "../methods/package/method-definitions.js";
19
+ import { computeArtifactStatuses, } from "./compile/artifact-status.js";
20
+ import { JsonlBillingEventSink, buildCompilationEventsForRun, defaultBillingEventLogPath, } from "./compile/billing-events.js";
21
+ import { methodDefinitionPath, resolveMethodPackageSourcePath, } from "../methods/package/local-methods.js";
22
+ import { seedLocalMethodPackageFromBase, } from "../methods/package/interf-method-package.js";
23
+ import { PACKAGE_ROOT } from "../methods/package/lib/package-root.js";
24
+ import { resolveAgent, detectAgents, supportsAutomatedRuns, } from "./agents/lib/detection.js";
25
+ import { loadUserConfig, saveUserConfig, } from "./agents/lib/user-config.js";
26
+ import { loadAgentsRegistry, registerCustomAgent, unregisterCustomAgent, patchRoleMap, setActiveAgent, } from "./agents/registry.js";
27
+ import { readSavedReadinessCheckRun, } from "./verify/readiness-check-run.js";
28
+ import { createCompiledTestTarget, } from "./verify/verify-targets.js";
29
+ import { ActionProposalApprovalRequestSchema, ActionProposalCreateRequestSchema, ActionProposalPlanSchema, ActionProposalResourceSchema, ActionProposalTypeSchema, CompileRunCreateRequestSchema, CompileRunResourceSchema, LocalExecutorStatusSchema, LocalExecutorSelectRequestSchema, LocalServiceHealthSchema, LocalRunHandlerResultSchema, LocalJobEventAppendRequestSchema, LocalJobRunCreateRequestSchema, LocalJobRunResourceSchema, SourceFileResourceSchema, WorkspaceFileResourceSchema, PortableContextResourceSchema, PreparationSetupCreateRequestSchema, PreparationSetupResultSchema, MethodChangeCreateRequestSchema, MethodChangeResultSchema, PreparationChangeCreateRequestSchema, PreparationChangeResultSchema, ReadinessCheckDraftCreateRequestSchema, ReadinessCheckDraftResultSchema, ResetRequestSchema, ResetResultSchema, ServiceRegistryWorkspaceSchema, VerifyRunCreateRequestSchema, VerifyRunResourceSchema, MethodAuthoringCreateRequestSchema, MethodAuthoringResultSchema, } from "./lib/schema.js";
28
30
  import { buildLocalServiceUrl, } from "./routes.js";
29
31
  import { MethodAuthoringActionValuesSchema, PreparationSetupActionValuesSchema, } from "./action-values.js";
30
- import { compileRunToObservability, jobRunToObservability, testRunToObservability, uniqueArtifacts, } from "./run-observability.js";
32
+ import { compileRunToObservability, jobRunToObservability, verifyRunToObservability, uniqueArtifacts, } from "./run-observability.js";
31
33
  /** TTL for `POST /v1/compile-runs` idempotency-key dedupe entries. */
32
34
  const IDEMPOTENCY_TTL_MS = 60 * 60 * 1000;
33
35
  /** Idempotency cache size at which to schedule an opportunistic prune. */
34
36
  const IDEMPOTENCY_PRUNE_THRESHOLD = 64;
37
+ const INTERRUPTED_COMPILE_RUN_MESSAGE = "Compile run interrupted because the Interf engine stopped before the run reached a terminal state.";
38
+ function isTerminalCompileRunStatus(status) {
39
+ return status === "succeeded" || status === "failed" || status === "cancelled";
40
+ }
35
41
  export class LocalServiceRuntime {
36
42
  host;
37
43
  port;
@@ -51,25 +57,35 @@ export class LocalServiceRuntime {
51
57
  */
52
58
  authToken;
53
59
  /** Map of prepDataDir -> PreparationContext. */
54
- workspaces = new Map();
55
- /** Hook called whenever a workspace is registered or deregistered. */
60
+ preparationContexts = new Map();
61
+ /** Hook called whenever a preparation is registered or deregistered. */
56
62
  onRegistryChanged = null;
57
- /** In-flight runs across all workspaces. Used for `idle_for_seconds`. */
63
+ /** In-flight runs across all preparations. Used for `idle_for_seconds`. */
58
64
  activeRunCount = 0;
59
65
  /**
60
66
  * Active compile-run cancellation handles, keyed by run id. Populated
61
67
  * when a compile run is launched and cleared once the run reaches a
62
68
  * terminal state. Each entry remembers where the persisted record lives
63
69
  * so cancel can mark it without re-resolving the Preparation.
70
+ *
71
+ * TODO(cloud): when the cloud variant lands, wire `RunLeaseStore`
72
+ * (see `cloud-seams.ts` B4.2) through this map. Multi-replica engines
73
+ * need a shared lease store so a replica can take over a run whose
74
+ * owning replica died.
64
75
  */
65
76
  activeCompileRuns = new Map();
66
77
  /**
67
78
  * Idempotency-key cache for `POST /v1/compile-runs`. Outer key is the
68
- * resolved workspace root; inner key is the client-supplied idempotency
69
- * value. Namespacing per workspace prevents key collisions across
70
- * tenants on the same engine (CSO finding: a malicious workspace could
71
- * otherwise hijack another workspace's run id by reusing its key).
79
+ * resolved preparation root; inner key is the client-supplied idempotency
80
+ * value. Namespacing per preparation prevents key collisions across
81
+ * tenants on the same engine (CSO finding: a malicious preparation could
82
+ * otherwise hijack another preparation's run id by reusing its key).
72
83
  * Entries expire after `IDEMPOTENCY_TTL_MS`.
84
+ *
85
+ * TODO(cloud): when the cloud variant lands, wire `IdempotencyStore`
86
+ * (see `cloud-seams.ts` B4.1) through this map. Multi-replica engines
87
+ * need a shared store so retries that land on a different replica
88
+ * still hit the same dedupe entry.
73
89
  */
74
90
  idempotencyKeyCache = new Map();
75
91
  /**
@@ -80,10 +96,26 @@ export class LocalServiceRuntime {
80
96
  * matching write path. See {@link runtime-caches} for design notes.
81
97
  */
82
98
  compileRunCache = new RunListingCache();
83
- testRunCache = new RunListingCache();
99
+ verifyRunCache = new RunListingCache();
84
100
  readinessCache = new ReadinessCache();
85
101
  sourceFilesCache = new MtimeListingCache();
86
102
  methodListingCache = new MethodListingCache();
103
+ /**
104
+ * 0.17 — sink for per-Artifact billing events. Set once at construction.
105
+ * Lazy-defaults to a per-run JSONL writer when no override was injected.
106
+ */
107
+ billingEventSink;
108
+ /**
109
+ * 0.17 — cloud-variant injection points. The local engine accepts
110
+ * these on the options surface but does not consume them yet — the
111
+ * in-process Maps remain authoritative for idempotency and
112
+ * run-lease state. The cloud variant fork will swap to these stores;
113
+ * the option-fields are documented here so the cloud build has a
114
+ * stable target. See `cloud-seams.ts` for the contracts.
115
+ */
116
+ cloudIdempotencyStore;
117
+ cloudRunLeaseStore;
118
+ cloudTokenValidator = null;
87
119
  constructor(options) {
88
120
  this.host = options.host;
89
121
  this.port = options.port;
@@ -92,7 +124,10 @@ export class LocalServiceRuntime {
92
124
  this.handlers = options.handlers ?? {};
93
125
  this.authToken = options.authToken ?? null;
94
126
  this.rootPath = resolve(options.rootPath);
95
- // Auto-register the initial workspace so single-workspace callers
127
+ this.billingEventSink = options.billingEventSink ?? null;
128
+ this.cloudIdempotencyStore = options.idempotencyStore ?? null;
129
+ this.cloudRunLeaseStore = options.runLeaseStore ?? null;
130
+ // Auto-register the initial preparation so single-preparation callers
96
131
  // (existing tests, the current `interf web` command) work without
97
132
  // additional bootstrapping. The constructor seed is the only role
98
133
  // `options.rootPath` plays; runtime methods take `prepDataDir`
@@ -102,18 +137,30 @@ export class LocalServiceRuntime {
102
137
  setBoundPort(port) {
103
138
  this.port = port;
104
139
  }
105
- /** Set a hook that fires whenever the registered workspaces change. */
140
+ /**
141
+ * 0.17 — token validator setter for cloud variants. Stored on the
142
+ * runtime so `isAuthorizedMutation` in `server.ts` can opt into the
143
+ * async per-account check when present. Local default: never set —
144
+ * the static bearer-token check runs.
145
+ */
146
+ setTokenValidator(validator) {
147
+ this.cloudTokenValidator = validator;
148
+ }
149
+ getTokenValidator() {
150
+ return this.cloudTokenValidator;
151
+ }
152
+ /** Set a hook that fires whenever the registered preparations change. */
106
153
  setOnRegistryChanged(handler) {
107
154
  this.onRegistryChanged = handler;
108
155
  }
109
156
  /**
110
- * Register a workspace with this runtime. Returns the PreparationContext.
111
- * Idempotent: re-registering an existing workspace updates `lastActivity`.
157
+ * Register a preparation with this runtime. Returns the PreparationContext.
158
+ * Idempotent: re-registering an existing preparation updates `lastActivity`.
112
159
  */
113
160
  registerPreparation(prepDataDir) {
114
161
  const resolved = resolve(prepDataDir);
115
162
  const now = new Date().toISOString();
116
- const existing = this.workspaces.get(resolved);
163
+ const existing = this.preparationContexts.get(resolved);
117
164
  if (existing) {
118
165
  existing.lastActivity = now;
119
166
  this.onRegistryChanged?.();
@@ -124,57 +171,58 @@ export class LocalServiceRuntime {
124
171
  startedAt: now,
125
172
  lastActivity: now,
126
173
  };
127
- this.workspaces.set(resolved, context);
174
+ this.preparationContexts.set(resolved, context);
175
+ this.finalizeInterruptedCompileRuns(resolved);
128
176
  this.onRegistryChanged?.();
129
177
  return context;
130
178
  }
131
179
  /**
132
- * Remove a workspace from the runtime. Returns true if a workspace was
180
+ * Remove a preparation from the runtime. Returns true if a preparation was
133
181
  * removed.
134
182
  */
135
183
  deregisterPreparation(prepDataDir) {
136
184
  const resolved = resolve(prepDataDir);
137
- const removed = this.workspaces.delete(resolved);
185
+ const removed = this.preparationContexts.delete(resolved);
138
186
  if (removed) {
139
187
  this.onRegistryChanged?.();
140
188
  }
141
189
  return removed;
142
190
  }
143
191
  /**
144
- * Most recently active workspace, or the first registered if none has
192
+ * Most recently active preparation, or the first registered if none has
145
193
  * activity yet. Server code uses this as the fallback when a request
146
- * omits the workspace header. Throws if no workspace is registered.
194
+ * does not specify a preparation. Throws if none are registered.
147
195
  */
148
196
  defaultPreparationDataDir() {
149
- if (this.workspaces.size === 0) {
150
- throw new Error("Local service has no registered workspaces.");
197
+ if (this.preparationContexts.size === 0) {
198
+ throw new Error("Local service has no registered preparations.");
151
199
  }
152
200
  let best = null;
153
201
  let bestKey = -Infinity;
154
- for (const context of this.workspaces.values()) {
202
+ for (const context of this.preparationContexts.values()) {
155
203
  const key = Date.parse(context.lastActivity);
156
204
  if (Number.isFinite(key) && key > bestKey) {
157
205
  best = context;
158
206
  bestKey = key;
159
207
  }
160
208
  }
161
- return (best ?? this.workspaces.values().next().value).rootPath;
209
+ return (best ?? this.preparationContexts.values().next().value).rootPath;
162
210
  }
163
- /** Look up a workspace context by rootPath. */
211
+ /** Look up a preparation context by rootPath. */
164
212
  getPreparationContext(prepDataDir) {
165
- return this.workspaces.get(resolve(prepDataDir)) ?? null;
213
+ return this.preparationContexts.get(resolve(prepDataDir)) ?? null;
166
214
  }
167
- /** All registered workspaces, ordered by registration time. */
215
+ /** All registered preparations, ordered by registration time. */
168
216
  listRegisteredPreparations() {
169
- return Array.from(this.workspaces.values()).sort((left, right) => Date.parse(left.startedAt) - Date.parse(right.startedAt));
217
+ return Array.from(this.preparationContexts.values()).sort((left, right) => Date.parse(left.startedAt) - Date.parse(right.startedAt));
170
218
  }
171
- /** True when no workspaces are registered. */
172
- hasNoWorkspaces() {
173
- return this.workspaces.size === 0;
219
+ /** True when no preparations are registered. */
220
+ hasNoPreparations() {
221
+ return this.preparationContexts.size === 0;
174
222
  }
175
- /** Number of registered workspaces. */
223
+ /** Number of registered preparations. */
176
224
  registeredPreparationCount() {
177
- return this.workspaces.size;
225
+ return this.preparationContexts.size;
178
226
  }
179
227
  /** Increment in-flight run counter. Call when a long-running run starts. */
180
228
  beginActiveRun() {
@@ -185,22 +233,28 @@ export class LocalServiceRuntime {
185
233
  if (this.activeRunCount > 0)
186
234
  this.activeRunCount -= 1;
187
235
  }
188
- /** Sum of in-flight runs across all workspaces. */
236
+ /** Sum of in-flight runs across all preparations. */
189
237
  activeRuns() {
190
238
  return this.activeRunCount;
191
239
  }
192
240
  /**
193
- * Mark the workspace as recently active. Routes call this on entry so
241
+ * Mark the preparation as recently active. Routes call this on entry so
194
242
  * `idleForSeconds` and the registry snapshots stay in sync with the
195
243
  * actual request cadence.
196
244
  */
197
245
  touchPreparation(prepDataDir) {
198
- const context = this.workspaces.get(resolve(prepDataDir));
246
+ const context = this.preparationContexts.get(resolve(prepDataDir));
199
247
  if (context) {
200
248
  context.lastActivity = new Date().toISOString();
201
249
  }
202
250
  }
203
- /** Snapshot of registered workspaces for the registry / status output. */
251
+ /**
252
+ * Snapshot of registered preparations for the registry / status output.
253
+ * Wire shape (`ServiceRegistryWorkspace`) keeps the legacy
254
+ * "workspace" name for backward compatibility with the public health
255
+ * response and `~/.interf/services.json`. Synthetic-workspace bridge
256
+ * code; do not rename without coordinating an API break.
257
+ */
204
258
  registeredPreparationSnapshots() {
205
259
  return this.listRegisteredPreparations().map((context) => ServiceRegistryWorkspaceSchema.parse({
206
260
  control_path: context.rootPath,
@@ -208,7 +262,7 @@ export class LocalServiceRuntime {
208
262
  last_activity: context.lastActivity,
209
263
  }));
210
264
  }
211
- /** Seconds since the most recent workspace activity (0 if active). */
265
+ /** Seconds since the most recent preparation activity (0 if active). */
212
266
  idleForSeconds() {
213
267
  const all = this.listRegisteredPreparations();
214
268
  if (all.length === 0)
@@ -249,9 +303,13 @@ export class LocalServiceRuntime {
249
303
  const config = loadSourceFolderConfig(prepDataDir);
250
304
  return listSourcePreparationConfigs(config).map((preparation) => {
251
305
  const compileRuns = this.listCompileRunsForPreparation(prepDataDir, preparation.name);
252
- const testRuns = this.listTestRunsForPreparation(prepDataDir, preparation.name);
306
+ const verifyRuns = this.listVerifyRunsForPreparation(prepDataDir, preparation.name);
253
307
  const readiness = this.computePreparationReadiness(prepDataDir, preparation);
254
- return buildPreparationResource(prepDataDir, preparation, readiness, compileRuns[0]?.run_id ?? null, testRuns[0]?.run_id ?? null);
308
+ return buildPreparationResource(prepDataDir, preparation, readiness, compileRuns[0]?.run_id ?? null, verifyRuns[0]?.run_id ?? null,
309
+ // 0.17 — surface per-Artifact status from the latest compile
310
+ // run so the UI can render artifact rows on the Preparation
311
+ // page without a separate fetch.
312
+ compileRuns[0]?.artifacts ?? []);
255
313
  });
256
314
  }
257
315
  getPreparation(prepDataDir, preparationName) {
@@ -282,7 +340,7 @@ export class LocalServiceRuntime {
282
340
  const compiledTarget = createCompiledTestTarget(compiledPath, preparation.name, methodIdForSourcePreparationConfig(preparation) ?? DEFAULT_METHOD_ID);
283
341
  const contextReady = compiledTarget.eligible;
284
342
  const compileRun = this.listCompileRunsForPreparation(prepDataDir, preparation.name)[0] ?? null;
285
- const testRun = this.listTestRunsForPreparation(prepDataDir, preparation.name)[0] ?? null;
343
+ const verifyRun = this.listVerifyRunsForPreparation(prepDataDir, preparation.name)[0] ?? null;
286
344
  const readinessRun = this.readLatestReadinessRun(prepDataDir, preparation.name);
287
345
  const configuredChecks = preparation.checks.length;
288
346
  const currentFingerprint = configuredChecks > 0 ? fingerprintReadinessChecks(preparation.checks) : null;
@@ -369,7 +427,7 @@ export class LocalServiceRuntime {
369
427
  const status = (() => {
370
428
  if (compileRun?.status === "queued" || compileRun?.status === "running")
371
429
  return "building";
372
- if (testRun?.status === "queued" || testRun?.status === "running")
430
+ if (verifyRun?.status === "queued" || verifyRun?.status === "running")
373
431
  return "checking";
374
432
  if (compileRun?.status === "failed" || compileRun?.status === "cancelled")
375
433
  return "failed";
@@ -384,7 +442,7 @@ export class LocalServiceRuntime {
384
442
  return contextResult.total > 0 && contextResult.passed === contextResult.total ? "ready" : "not-ready";
385
443
  })();
386
444
  const ready = status === "ready";
387
- return ReadinessStateSchema.parse({
445
+ return ReadinessSchema.parse({
388
446
  kind: "interf-readiness-state",
389
447
  version: 1,
390
448
  generated_at: generatedAt,
@@ -394,7 +452,7 @@ export class LocalServiceRuntime {
394
452
  summary: readinessSummaryForStatus(status),
395
453
  portable_context_path: contextReady ? compiledPath : null,
396
454
  latest_compile_run_id: compileRun?.run_id ?? null,
397
- latest_test_run_id: testRun?.run_id ?? null,
455
+ latest_test_run_id: verifyRun?.run_id ?? null,
398
456
  compile: compileCheck,
399
457
  check_results: {
400
458
  configured: configuredChecks,
@@ -406,10 +464,16 @@ export class LocalServiceRuntime {
406
464
  });
407
465
  }
408
466
  listSourceFiles(prepDataDir, preparationName) {
409
- const preparations = listSourcePreparationConfigs(loadSourceFolderConfig(prepDataDir))
467
+ const config = loadSourceFolderConfig(prepDataDir);
468
+ const preparations = listSourcePreparationConfigs(config)
410
469
  .filter((preparation) => !preparationName || preparation.name === preparationName);
470
+ // 0.13+ source binding: the source folder is the user-supplied
471
+ // absolute path on `source_folder.path`. `preparation.path` is the
472
+ // portable-context name inside `prepDataDir` (legacy field; in the
473
+ // synthetic-workspace bridge it equals `preparation.name`). Walk
474
+ // the actual source bytes, not the portable-context subdir.
475
+ const sourceFolderPath = resolveConfiguredSourceFolderPath(prepDataDir, config) ?? prepDataDir;
411
476
  return preparations.flatMap((preparation) => {
412
- const sourceFolderPath = resolveSourcePreparationPath(prepDataDir, preparation);
413
477
  const compiledPath = preparationPortableContextPath(asPreparationDataDir(prepDataDir), preparation.name);
414
478
  // Cache by source-folder root mtime so identical UI polls do not
415
479
  // re-walk and re-stat the entire tree. The cache imposes a short
@@ -489,19 +553,16 @@ export class LocalServiceRuntime {
489
553
  source_kind: method.scope === "builtin" ? "builtin" : "local",
490
554
  built_in: method.scope === "builtin",
491
555
  active_for_preparations: activeForPreparations,
492
- output_paths: (method.contextInterface?.zones ?? [])
493
- .filter((zone) => zone.role === "output")
494
- .map((zone) => contextInterfaceArtifactPath(zone))
495
- .sort(),
556
+ artifacts: method.contextInterface?.artifacts ?? [],
496
557
  stages: method.stages.map((stage) => ({
497
558
  id: stage.id,
498
559
  label: stage.label,
499
560
  description: stage.description,
500
561
  contract_type: stage.contractType,
501
562
  skill_dir: stage.skillDir,
563
+ role: stage.role && stage.role.trim().length > 0 ? stage.role : "general",
502
564
  reads: stage.reads,
503
565
  writes: stage.writes,
504
- ...(stage.acceptance ? { acceptance: stage.acceptance } : {}),
505
566
  })),
506
567
  });
507
568
  });
@@ -587,8 +648,48 @@ export class LocalServiceRuntime {
587
648
  skillsInstalled: current?.skillsInstalled ?? false,
588
649
  initialized: current?.initialized ?? new Date().toISOString(),
589
650
  });
651
+ // Mirror the selection into the 0.15 role-map. `setActiveAgent`
652
+ // also sweeps any role still pointing at the previous active so
653
+ // single-active-agent setups stay coherent across CLIs.
654
+ try {
655
+ setActiveAgent(selected.name);
656
+ }
657
+ catch {
658
+ // Best effort — the registry update is convenience for the new
659
+ // role-aware path. The user_config.json write above is the
660
+ // source of truth for the legacy `getExecutorStatus()`.
661
+ }
590
662
  return this.getExecutorStatus();
591
663
  }
664
+ // ─── 0.15 connected-agents primitive ─────────────────────────────
665
+ /**
666
+ * Snapshot of the merged agents registry (built-in detected + custom)
667
+ * with the current role-map and resolved active agent.
668
+ */
669
+ getAgentsRegistry() {
670
+ const registry = loadAgentsRegistry();
671
+ return {
672
+ agents: registry.agents,
673
+ role_map: registry.roleMap,
674
+ active_agent: registry.activeAgent,
675
+ };
676
+ }
677
+ registerCustomAgent(input) {
678
+ registerCustomAgent(input);
679
+ return this.getAgentsRegistry();
680
+ }
681
+ unregisterCustomAgent(name) {
682
+ unregisterCustomAgent(name);
683
+ return this.getAgentsRegistry();
684
+ }
685
+ patchAgentsRoleMap(patch) {
686
+ patchRoleMap(patch);
687
+ const registry = loadAgentsRegistry();
688
+ return {
689
+ role_map: registry.roleMap,
690
+ active_agent: registry.activeAgent,
691
+ };
692
+ }
592
693
  listActionProposals(prepDataDir) {
593
694
  return byCreatedAtDesc(listJsonFiles(actionProposalsRoot(prepDataDir))
594
695
  .map(readActionProposalAt)
@@ -654,7 +755,7 @@ export class LocalServiceRuntime {
654
755
  listRunObservability(prepDataDir) {
655
756
  return [
656
757
  ...this.listCompileRuns(prepDataDir).map((resource) => compileRunToObservability(resource.run)),
657
- ...this.listTestRuns(prepDataDir).map(testRunToObservability),
758
+ ...this.listVerifyRuns(prepDataDir).map(verifyRunToObservability),
658
759
  ...this.listJobs(prepDataDir).map(jobRunToObservability),
659
760
  ].sort((left, right) => {
660
761
  const leftTime = timestampKey(left.started_at ?? left.created_at ?? left.finished_at);
@@ -665,6 +766,20 @@ export class LocalServiceRuntime {
665
766
  getRunObservability(prepDataDir, runId) {
666
767
  return this.listRunObservability(prepDataDir).find((run) => run.run_id === runId) ?? null;
667
768
  }
769
+ /**
770
+ * Method-scoped runs: every method-authoring or method-improvement job
771
+ * whose `method` matches `methodId`. Surfaced through
772
+ * `GET /v1/methods/<id>/runs` so Method Detail can show the full audit
773
+ * trail of authoring + improvement work for a Method.
774
+ */
775
+ listMethodRuns(prepDataDir, methodId) {
776
+ return this.listRunObservability(prepDataDir).filter((run) => {
777
+ if (run.method !== methodId)
778
+ return false;
779
+ return (run.run_type === "method-authoring" ||
780
+ run.run_type === "method-improvement");
781
+ });
782
+ }
668
783
  createJobRun(prepDataDir, requestValue) {
669
784
  const request = LocalJobRunCreateRequestSchema.parse(requestValue);
670
785
  const runId = createRunId("job");
@@ -848,74 +963,6 @@ export class LocalServiceRuntime {
848
963
  : `Removed Method ${request.method}.`,
849
964
  });
850
965
  }
851
- /**
852
- * Bootstrap the workspace's source-folder binding and seed the default
853
- * Method. Idempotent: re-running with the same source folder preserves
854
- * existing preparations and reports `changed: false`.
855
- *
856
- * The CLI calls this in place of writing `interf.json` directly, so the
857
- * operation is recorded by the service (and visible to other clients).
858
- */
859
- bootstrapWorkspace(prepDataDir, requestValue) {
860
- const request = WorkspaceBootstrapCreateRequestSchema.parse(requestValue);
861
- const requestedPath = request.source_folder?.path?.trim() ?? null;
862
- const existing = loadSourceFolderConfig(prepDataDir);
863
- const existingSourcePath = existing?.source_folder?.path ?? null;
864
- const preparations = existing?.preparations ?? [];
865
- let sourceFolderPath = existingSourcePath;
866
- let sourceChanged = false;
867
- if (requestedPath && requestedPath.length > 0) {
868
- // Validate that the source folder exists relative to the workspace.
869
- const resolvedSourcePath = resolve(prepDataDir, requestedPath);
870
- if (!existsSync(resolvedSourcePath) || !statSync(resolvedSourcePath).isDirectory()) {
871
- throw new Error(`Source folder "${requestedPath}" is not available.`);
872
- }
873
- if (existingSourcePath !== requestedPath) {
874
- sourceFolderPath = requestedPath;
875
- sourceChanged = true;
876
- }
877
- }
878
- const writeNeeded = !existing || sourceChanged;
879
- if (writeNeeded) {
880
- saveSourceFolderConfig(prepDataDir, {
881
- ...(sourceFolderPath ? { source_folder: { path: sourceFolderPath } } : {}),
882
- preparations,
883
- });
884
- // Source folder rebound: drop every cached read for this workspace.
885
- this.readinessCache.invalidateWorkspace(prepDataDir);
886
- this.compileRunCache.invalidateWorkspace(prepDataDir);
887
- this.testRunCache.invalidateWorkspace(prepDataDir);
888
- this.sourceFilesCache.invalidateAll();
889
- this.methodListingCache.invalidate(prepDataDir);
890
- }
891
- let seededMethodId = null;
892
- let seededDefaultMethod = false;
893
- if (request.seed_default_method) {
894
- const seeded = seedLocalDefaultMethod({ prepDataDir });
895
- seededMethodId = seeded.methodId;
896
- seededDefaultMethod = !seeded.alreadyExisted;
897
- if (seededDefaultMethod) {
898
- this.methodListingCache.invalidate(prepDataDir);
899
- }
900
- }
901
- const changed = writeNeeded || seededDefaultMethod;
902
- return WorkspaceBootstrapResultSchema.parse({
903
- kind: "interf-workspace-bootstrap-result",
904
- version: 1,
905
- control_path: prepDataDir,
906
- config_path: preparationConfigPath(asPreparationDataDir(prepDataDir)),
907
- source_folder_path: sourceFolderPath,
908
- preparations: preparations.length,
909
- seeded_default_method: seededDefaultMethod,
910
- default_method_id: seededMethodId,
911
- changed,
912
- message: changed
913
- ? sourceFolderPath
914
- ? `Workspace ready. Source Folder: ${sourceFolderPath}.`
915
- : `Workspace ready.`
916
- : `Workspace already initialized.`,
917
- });
918
- }
919
966
  applyPreparationSetup(prepDataDir, requestValue) {
920
967
  const request = PreparationSetupCreateRequestSchema.parse(requestValue);
921
968
  const preparationConfig = request.preparation;
@@ -934,7 +981,7 @@ export class LocalServiceRuntime {
934
981
  // caches so the next read reflects the new shape.
935
982
  this.readinessCache.invalidatePreparation(prepDataDir, normalizedPreparationConfig.name);
936
983
  this.compileRunCache.invalidatePreparation(prepDataDir, normalizedPreparationConfig.name);
937
- this.testRunCache.invalidatePreparation(prepDataDir, normalizedPreparationConfig.name);
984
+ this.verifyRunCache.invalidatePreparation(prepDataDir, normalizedPreparationConfig.name);
938
985
  this.methodListingCache.invalidate(prepDataDir);
939
986
  const operation = request.setup_mode === "select-method" ? "select-method" : "create";
940
987
  return PreparationSetupResultSchema.parse({
@@ -964,7 +1011,7 @@ export class LocalServiceRuntime {
964
1011
  removeSourcePreparationConfig(prepDataDir, request.preparation);
965
1012
  this.readinessCache.invalidatePreparation(prepDataDir, request.preparation);
966
1013
  this.compileRunCache.invalidatePreparation(prepDataDir, request.preparation);
967
- this.testRunCache.invalidatePreparation(prepDataDir, request.preparation);
1014
+ this.verifyRunCache.invalidatePreparation(prepDataDir, request.preparation);
968
1015
  this.methodListingCache.invalidate(prepDataDir);
969
1016
  return PreparationChangeResultSchema.parse({
970
1017
  kind: "interf-preparation-change-result",
@@ -991,7 +1038,7 @@ export class LocalServiceRuntime {
991
1038
  resetCompiledGeneratedState(compiledPath, request.scope);
992
1039
  // Reset wipes generated state, including saved compile/test/readiness records.
993
1040
  this.compileRunCache.invalidatePreparation(prepDataDir, request.preparation);
994
- this.testRunCache.invalidatePreparation(prepDataDir, request.preparation);
1041
+ this.verifyRunCache.invalidatePreparation(prepDataDir, request.preparation);
995
1042
  this.readinessCache.invalidatePreparation(prepDataDir, request.preparation);
996
1043
  return ResetResultSchema.parse({
997
1044
  kind: "interf-reset-result",
@@ -1030,6 +1077,7 @@ export class LocalServiceRuntime {
1030
1077
  method_id: request.method_id,
1031
1078
  label: request.label,
1032
1079
  task_prompt: request.task_prompt,
1080
+ artifact_requirements: request.artifact_requirements.length,
1033
1081
  },
1034
1082
  },
1035
1083
  {
@@ -1068,6 +1116,7 @@ export class LocalServiceRuntime {
1068
1116
  method_id: request.method_id,
1069
1117
  label: request.label,
1070
1118
  task_prompt: request.task_prompt,
1119
+ artifact_requirements: request.artifact_requirements.length,
1071
1120
  },
1072
1121
  });
1073
1122
  void this.runMethodAuthoringInBackground(prepDataDir, request, job.run_id);
@@ -1085,7 +1134,7 @@ export class LocalServiceRuntime {
1085
1134
  const path = preparationPortableContextPath(asPreparationDataDir(prepDataDir), preparation.name);
1086
1135
  const config = readInterfConfig(path);
1087
1136
  const compileRuns = this.listCompileRunsForPreparation(prepDataDir, preparation.name);
1088
- const testRuns = this.listTestRunsForPreparation(prepDataDir, preparation.name);
1137
+ const verifyRuns = this.listVerifyRunsForPreparation(prepDataDir, preparation.name);
1089
1138
  const readiness = this.computePreparationReadiness(prepDataDir, preparation);
1090
1139
  const method = config?.method ?? methodIdForSourcePreparationConfig(preparation);
1091
1140
  return PortableContextResourceSchema.parse({
@@ -1095,7 +1144,7 @@ export class LocalServiceRuntime {
1095
1144
  readiness,
1096
1145
  method,
1097
1146
  latest_compile_run_id: compileRuns[0]?.run_id ?? null,
1098
- latest_test_run_id: testRuns[0]?.run_id ?? null,
1147
+ latest_test_run_id: verifyRuns[0]?.run_id ?? null,
1099
1148
  artifacts: uniqueArtifacts(compileRuns[0]?.stages.flatMap((stage) => stage.artifacts) ?? []),
1100
1149
  });
1101
1150
  }
@@ -1187,7 +1236,6 @@ export class LocalServiceRuntime {
1187
1236
  stage_total: stageTotal,
1188
1237
  reads: stage.reads,
1189
1238
  writes: stage.writes,
1190
- ...(stage.acceptance ? { acceptance: stage.acceptance } : {}),
1191
1239
  },
1192
1240
  artifacts: [],
1193
1241
  };
@@ -1226,7 +1274,7 @@ export class LocalServiceRuntime {
1226
1274
  }
1227
1275
  /**
1228
1276
  * Cancel an in-flight compile run. Marks the persisted record as
1229
- * `cancelled`, emits a `run.failed` event to capture the cancellation in
1277
+ * `cancelled`, emits a `run.cancelled` event to capture the cancellation in
1230
1278
  * the run timeline, and clears the active handle so retries may start a
1231
1279
  * fresh run. If the run already finished, returns
1232
1280
  * `{ cancelled: false, reason: "already finished" }` and persists nothing.
@@ -1246,31 +1294,22 @@ export class LocalServiceRuntime {
1246
1294
  handle.cancelled = true;
1247
1295
  handle.cancelledAt = cancelledAt;
1248
1296
  const current = this.readCompileRun(handle.compiledPath, runId);
1249
- if (current && current.status !== "succeeded" && current.status !== "failed" && current.status !== "cancelled") {
1250
- const cancelledRun = {
1251
- ...current,
1252
- status: "cancelled",
1253
- finished_at: current.finished_at ?? cancelledAt,
1254
- events: [
1255
- ...current.events,
1256
- {
1257
- type: "run.failed",
1258
- event_id: createRunEventId("event"),
1259
- run_id: runId,
1260
- timestamp: cancelledAt,
1261
- error: "Compile run cancelled by request.",
1262
- },
1263
- ],
1264
- };
1265
- this.writeCompileRun(handle.prepDataDir, handle.compiledPath, cancelledRun);
1297
+ if (current && !isTerminalCompileRunStatus(current.status)) {
1298
+ this.writeCompileRun(handle.prepDataDir, handle.compiledPath, applyEventToCompileRun(current, {
1299
+ type: "run.cancelled",
1300
+ event_id: createRunEventId("event"),
1301
+ run_id: runId,
1302
+ timestamp: cancelledAt,
1303
+ reason: "Compile run cancelled by request.",
1304
+ }));
1266
1305
  }
1267
1306
  return { cancelled: true };
1268
1307
  }
1269
1308
  /**
1270
1309
  * Look up the run id previously associated with this idempotency key in
1271
1310
  * `prepDataDir`. Returns null when the key is unknown or its TTL has
1272
- * elapsed. The workspace argument is required so that the same key in
1273
- * two different workspaces always returns two different runs.
1311
+ * elapsed. The preparation argument is required so that the same key in
1312
+ * two different preparations always returns two different runs.
1274
1313
  */
1275
1314
  findIdempotentCompileRun(prepDataDir, key) {
1276
1315
  const resolvedRoot = resolve(prepDataDir);
@@ -1313,7 +1352,7 @@ export class LocalServiceRuntime {
1313
1352
  this.pruneIdempotencyKeyCache();
1314
1353
  }
1315
1354
  }
1316
- /** Total cached idempotency entries across all workspaces. */
1355
+ /** Total cached idempotency entries across all preparations. */
1317
1356
  totalIdempotencyEntries() {
1318
1357
  let total = 0;
1319
1358
  for (const bucket of this.idempotencyKeyCache.values())
@@ -1348,46 +1387,45 @@ export class LocalServiceRuntime {
1348
1387
  entry.expiresAt = Date.now() - 1;
1349
1388
  return true;
1350
1389
  }
1351
- listTestRuns(prepDataDir) {
1390
+ listVerifyRuns(prepDataDir) {
1352
1391
  return newestFirst(listSourcePreparationConfigs(loadSourceFolderConfig(prepDataDir))
1353
- .flatMap((preparation) => this.listTestRunsForPreparation(prepDataDir, preparation.name)));
1392
+ .flatMap((preparation) => this.listVerifyRunsForPreparation(prepDataDir, preparation.name)));
1354
1393
  }
1355
- listTestRunsForPreparation(prepDataDir, preparationName) {
1356
- return this.testRunCache.get(prepDataDir, preparationName, () => {
1394
+ listVerifyRunsForPreparation(prepDataDir, preparationName) {
1395
+ return this.verifyRunCache.get(prepDataDir, preparationName, () => {
1357
1396
  const compiledPath = preparationPortableContextPath(asPreparationDataDir(prepDataDir), preparationName);
1358
- return newestFirst(listJsonFiles(testRunsRoot(compiledPath))
1359
- .map(readTestRunAt)
1397
+ return newestFirst(listJsonFiles(verifyRunsRoot(compiledPath))
1398
+ .map(readVerifyRunAt)
1360
1399
  .filter((run) => run !== null));
1361
1400
  }, (run) => run.run_id);
1362
1401
  }
1363
- getTestRun(prepDataDir, runId) {
1364
- const known = this.testRunCache.preparationFor(prepDataDir, runId);
1402
+ getVerifyRun(prepDataDir, runId) {
1403
+ const known = this.verifyRunCache.preparationFor(prepDataDir, runId);
1365
1404
  if (known) {
1366
- const found = this.listTestRunsForPreparation(prepDataDir, known).find((run) => run.run_id === runId);
1405
+ const found = this.listVerifyRunsForPreparation(prepDataDir, known).find((run) => run.run_id === runId);
1367
1406
  if (found)
1368
1407
  return found;
1369
1408
  }
1370
- return this.listTestRuns(prepDataDir).find((run) => run.run_id === runId) ?? null;
1409
+ return this.listVerifyRuns(prepDataDir).find((run) => run.run_id === runId) ?? null;
1371
1410
  }
1372
- async createTestRun(prepDataDir, requestValue) {
1373
- const request = TestRunCreateRequestSchema.parse(requestValue);
1411
+ async createVerifyRun(prepDataDir, requestValue) {
1412
+ const request = VerifyRunCreateRequestSchema.parse(requestValue);
1374
1413
  const preparationConfig = this.resolvePreparationConfig(prepDataDir, request.preparation);
1375
1414
  const compiledPath = preparationPortableContextPath(asPreparationDataDir(prepDataDir), preparationConfig.name);
1376
1415
  const compiledTarget = createCompiledTestTarget(compiledPath, preparationConfig.name, methodIdForSourcePreparationConfig(preparationConfig) ?? DEFAULT_METHOD_ID);
1377
- const runId = createRunId("test");
1416
+ const runId = createRunId("verify");
1378
1417
  const now = new Date().toISOString();
1379
- const initial = TestRunResourceSchema.parse({
1418
+ const initial = VerifyRunResourceSchema.parse({
1380
1419
  run_id: runId,
1381
1420
  status: "running",
1382
1421
  preparation: preparationConfig.name,
1383
- mode: request.mode,
1384
1422
  source_path: prepDataDir,
1385
1423
  portable_context_path: compiledTarget.eligible ? compiledPath : null,
1386
1424
  started_at: now,
1387
1425
  readiness_run: null,
1388
1426
  events: [],
1389
1427
  });
1390
- this.writeTestRun(prepDataDir, compiledPath, initial);
1428
+ this.writeVerifyRun(prepDataDir, compiledPath, initial);
1391
1429
  void this.runTestInBackground(prepDataDir, request, {
1392
1430
  runId,
1393
1431
  sourcePath: prepDataDir,
@@ -1434,6 +1472,9 @@ export class LocalServiceRuntime {
1434
1472
  });
1435
1473
  }
1436
1474
  await this.recordCompileRunEvent(prepDataDir, context.compiledPath, context.runId, this.readinessUpdatedEvent(context.runId, context.preparationConfig.name, this.computePreparationReadiness(prepDataDir, context.preparationConfig)));
1475
+ // 0.17 — emit per-Artifact billing events (stub form: JSONL).
1476
+ // Production sink (Metronome HTTP) wires in 0.18+.
1477
+ this.emitBillingEventsForRun(prepDataDir, context);
1437
1478
  }
1438
1479
  catch (error) {
1439
1480
  await this.recordCompileRunEvent(prepDataDir, context.compiledPath, context.runId, {
@@ -1453,15 +1494,15 @@ export class LocalServiceRuntime {
1453
1494
  async runTestInBackground(prepDataDir, request, context, initial) {
1454
1495
  this.beginActiveRun();
1455
1496
  try {
1456
- if (!this.handlers.createTestRun) {
1457
- throw new Error("No test-run handler is configured for this local service.");
1497
+ if (!this.handlers.createVerifyRun) {
1498
+ throw new Error("No verify-run handler is configured for this local service.");
1458
1499
  }
1459
- const result = LocalRunHandlerResultSchema.parse(await this.handlers.createTestRun(request, context));
1500
+ const result = LocalRunHandlerResultSchema.parse(await this.handlers.createVerifyRun(request, context));
1460
1501
  const readinessRun = result.readiness_run ?? this.readLatestReadinessRun(prepDataDir, context.preparationConfig.name);
1461
1502
  const resultEvent = readinessRun
1462
1503
  ? this.checksEvaluatedEvent(context.runId, readinessRun)
1463
1504
  : null;
1464
- const nextWithoutReadiness = TestRunResourceSchema.parse({
1505
+ const nextWithoutReadiness = VerifyRunResourceSchema.parse({
1465
1506
  ...initial,
1466
1507
  status: result.ok ? "succeeded" : "failed",
1467
1508
  finished_at: new Date().toISOString(),
@@ -1469,9 +1510,9 @@ export class LocalServiceRuntime {
1469
1510
  events: resultEvent ? [resultEvent] : [],
1470
1511
  ...(!result.ok ? { error: result.error ?? "Readiness check failed." } : {}),
1471
1512
  });
1472
- this.writeTestRun(prepDataDir, context.compiledPath, nextWithoutReadiness);
1513
+ this.writeVerifyRun(prepDataDir, context.compiledPath, nextWithoutReadiness);
1473
1514
  const readiness = this.computePreparationReadiness(prepDataDir, context.preparationConfig);
1474
- const next = TestRunResourceSchema.parse({
1515
+ const next = VerifyRunResourceSchema.parse({
1475
1516
  ...nextWithoutReadiness,
1476
1517
  readiness,
1477
1518
  events: [
@@ -1479,23 +1520,23 @@ export class LocalServiceRuntime {
1479
1520
  this.readinessUpdatedEvent(context.runId, context.preparationConfig.name, readiness),
1480
1521
  ],
1481
1522
  });
1482
- this.writeTestRun(prepDataDir, context.compiledPath, next);
1523
+ this.writeVerifyRun(prepDataDir, context.compiledPath, next);
1483
1524
  }
1484
1525
  catch (error) {
1485
- const failedWithoutReadiness = TestRunResourceSchema.parse({
1526
+ const failedWithoutReadiness = VerifyRunResourceSchema.parse({
1486
1527
  ...initial,
1487
1528
  status: "failed",
1488
1529
  finished_at: new Date().toISOString(),
1489
1530
  error: error instanceof Error ? error.message : String(error),
1490
1531
  });
1491
- this.writeTestRun(prepDataDir, context.compiledPath, failedWithoutReadiness);
1532
+ this.writeVerifyRun(prepDataDir, context.compiledPath, failedWithoutReadiness);
1492
1533
  const readiness = this.computePreparationReadiness(prepDataDir, context.preparationConfig);
1493
- const next = TestRunResourceSchema.parse({
1534
+ const next = VerifyRunResourceSchema.parse({
1494
1535
  ...failedWithoutReadiness,
1495
1536
  readiness,
1496
1537
  events: [this.readinessUpdatedEvent(context.runId, context.preparationConfig.name, readiness)],
1497
1538
  });
1498
- this.writeTestRun(prepDataDir, context.compiledPath, next);
1539
+ this.writeVerifyRun(prepDataDir, context.compiledPath, next);
1499
1540
  }
1500
1541
  finally {
1501
1542
  this.endActiveRun();
@@ -1931,10 +1972,11 @@ export class LocalServiceRuntime {
1931
1972
  };
1932
1973
  }
1933
1974
  if (actionType === "test") {
1934
- const defaultMode = hasCompiledTestTarget(prepDataDir, preparationConfig) ? "both" : "source-files";
1975
+ // 0.15 verify runs always judge against the compiled
1976
+ // portable context. The legacy `mode` field is gone from the
1977
+ // wire request shape.
1935
1978
  return {
1936
1979
  preparation: preparationConfig.name,
1937
- mode: testModeValue(proposalValues, defaultMode),
1938
1980
  };
1939
1981
  }
1940
1982
  if (actionType === "readiness-check-draft") {
@@ -1984,9 +2026,7 @@ export class LocalServiceRuntime {
1984
2026
  return "Ask the configured local executor to draft saved readiness checks.";
1985
2027
  return "Ask the configured local executor to create a reusable local Method.";
1986
2028
  })();
1987
- const previewValues = proposalActionType === "test"
1988
- ? { mode: actionRequest.mode }
1989
- : proposalValues;
2029
+ const previewValues = proposalValues;
1990
2030
  const commandPreview = plan.command_preview ?? actionCommandPreview(proposalActionType, preparationConfig.name, methodId, previewValues);
1991
2031
  return ActionProposalResourceSchema.parse({
1992
2032
  kind: "interf-action-proposal",
@@ -2023,10 +2063,10 @@ export class LocalServiceRuntime {
2023
2063
  };
2024
2064
  }
2025
2065
  if (proposal.action_type === "test") {
2026
- const resource = await this.createTestRun(prepDataDir, proposal.request);
2066
+ const resource = await this.createVerifyRun(prepDataDir, proposal.request);
2027
2067
  return {
2028
2068
  runId: resource.run_id,
2029
- runType: "test-run",
2069
+ runType: "verify-run",
2030
2070
  };
2031
2071
  }
2032
2072
  if (proposal.action_type === "readiness-check-draft") {
@@ -2068,6 +2108,81 @@ export class LocalServiceRuntime {
2068
2108
  readCompileRun(compiledPath, runId) {
2069
2109
  return readCompileRunAt(compileRunPath(compiledPath, runId));
2070
2110
  }
2111
+ finalizeInterruptedCompileRuns(prepDataDir) {
2112
+ let preparations;
2113
+ try {
2114
+ preparations = listSourcePreparationConfigs(loadSourceFolderConfig(prepDataDir));
2115
+ }
2116
+ catch {
2117
+ return;
2118
+ }
2119
+ for (const preparation of preparations) {
2120
+ const compiledPath = preparationPortableContextPath(asPreparationDataDir(prepDataDir), preparation.name);
2121
+ for (const run of listJsonFiles(compileRunsRoot(compiledPath))
2122
+ .map(readCompileRunAt)
2123
+ .filter((entry) => entry !== null)) {
2124
+ if (isTerminalCompileRunStatus(run.status) || this.activeCompileRuns.has(run.run_id))
2125
+ continue;
2126
+ const timestamp = createRunEventTimestamp();
2127
+ const interruptedRun = {
2128
+ ...run,
2129
+ stages: run.stages.map((stage) => {
2130
+ if (stage.status !== "running")
2131
+ return stage;
2132
+ return {
2133
+ ...stage,
2134
+ status: "failed",
2135
+ finished_at: stage.finished_at ?? timestamp,
2136
+ summary: stage.summary ?? INTERRUPTED_COMPILE_RUN_MESSAGE,
2137
+ failure: stage.failure ?? INTERRUPTED_COMPILE_RUN_MESSAGE,
2138
+ };
2139
+ }),
2140
+ };
2141
+ this.writeCompileRun(prepDataDir, compiledPath, applyEventToCompileRun(interruptedRun, {
2142
+ type: "run.cancelled",
2143
+ event_id: createRunEventId("event"),
2144
+ run_id: run.run_id,
2145
+ timestamp,
2146
+ reason: INTERRUPTED_COMPILE_RUN_MESSAGE,
2147
+ }));
2148
+ }
2149
+ }
2150
+ }
2151
+ /**
2152
+ * 0.17 — emit per-Artifact billing events when a compile run reaches
2153
+ * a terminal state. STUB FORM: writes a JSONL file alongside the run
2154
+ * record by default. Production sink (Metronome HTTP) wires in 0.18+.
2155
+ * The JSONL output is observability/dev fixture, NOT production
2156
+ * billing data.
2157
+ */
2158
+ emitBillingEventsForRun(prepDataDir, context) {
2159
+ try {
2160
+ const run = this.readCompileRun(context.compiledPath, context.runId);
2161
+ if (!run || run.artifacts.length === 0)
2162
+ return;
2163
+ const sink = this.billingEventSink ?? new JsonlBillingEventSink(defaultBillingEventLogPath({
2164
+ preparationDataDir: prepDataDir,
2165
+ preparationName: run.preparation,
2166
+ runId: context.runId,
2167
+ }));
2168
+ const events = buildCompilationEventsForRun({
2169
+ runId: context.runId,
2170
+ preparation: run.preparation,
2171
+ methodId: run.method,
2172
+ accountId: null, // 0.17 — loopback only; cloud variant fills via tokenValidator (B4.3).
2173
+ artifacts: run.artifacts,
2174
+ startedAt: run.started_at ?? null,
2175
+ finishedAt: run.finished_at ?? null,
2176
+ });
2177
+ for (const event of events) {
2178
+ sink.emit(event);
2179
+ }
2180
+ }
2181
+ catch {
2182
+ // Billing is observability-only in 0.17; never let stub failures
2183
+ // block a successful compile.
2184
+ }
2185
+ }
2071
2186
  writeCompileRun(prepDataDir, compiledPath, run) {
2072
2187
  mkdirSync(compileRunsRoot(compiledPath), { recursive: true });
2073
2188
  writeJsonFile(compileRunPath(compiledPath, run.run_id), CompileRunSchema.parse(run));
@@ -2158,6 +2273,19 @@ export class LocalServiceRuntime {
2158
2273
  }),
2159
2274
  };
2160
2275
  next.latest_proof = [...next.stages].reverse().find((stage) => Boolean(stage.latest_proof))?.latest_proof ?? next.latest_proof;
2276
+ // Recompute per-Artifact status whenever the compile run is
2277
+ // refreshed from runtime state.
2278
+ try {
2279
+ const method = getCompiledMethod(current.method, { prepDataDir });
2280
+ next.artifacts = computeArtifactStatuses({
2281
+ method,
2282
+ compiledPath,
2283
+ stageRuns: next.stages,
2284
+ });
2285
+ }
2286
+ catch {
2287
+ next.artifacts = current.artifacts ?? [];
2288
+ }
2161
2289
  this.writeCompileRun(prepDataDir, compiledPath, next);
2162
2290
  }
2163
2291
  async emitRuntimeDerivedEvents(prepDataDir, compiledPath, runId) {
@@ -2221,10 +2349,10 @@ export class LocalServiceRuntime {
2221
2349
  readiness,
2222
2350
  };
2223
2351
  }
2224
- writeTestRun(prepDataDir, compiledPath, run) {
2225
- mkdirSync(testRunsRoot(compiledPath), { recursive: true });
2226
- writeJsonFile(testRunPath(compiledPath, run.run_id), TestRunResourceSchema.parse(run));
2227
- this.testRunCache.invalidatePreparation(prepDataDir, run.preparation);
2352
+ writeVerifyRun(prepDataDir, compiledPath, run) {
2353
+ mkdirSync(verifyRunsRoot(compiledPath), { recursive: true });
2354
+ writeJsonFile(verifyRunPath(compiledPath, run.run_id), VerifyRunResourceSchema.parse(run));
2355
+ this.verifyRunCache.invalidatePreparation(prepDataDir, run.preparation);
2228
2356
  this.readinessCache.invalidatePreparation(prepDataDir, run.preparation);
2229
2357
  }
2230
2358
  }