smol-symphony 0.2.0 → 0.3.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 (716) hide show
  1. package/AGENTS.md +41 -22
  2. package/DESIGN.md +494 -273
  3. package/README.md +109 -57
  4. package/SPEC.md +33 -24
  5. package/WORKFLOW.minimal.yaml +34 -0
  6. package/{WORKFLOW.template.md → WORKFLOW.template.yaml} +409 -256
  7. package/WORKFLOW.yaml +487 -0
  8. package/assets/skills/symphony-issues/SKILL.md +136 -0
  9. package/assets/symphony-mise.system.toml +68 -0
  10. package/dist/src/bin/symphony.js +30 -0
  11. package/dist/src/bin/symphony.js.map +1 -0
  12. package/dist/src/core/actions/context.js +109 -0
  13. package/dist/src/core/actions/context.js.map +1 -0
  14. package/dist/{actions/parsing.js → src/core/actions/parse.js} +33 -114
  15. package/dist/src/core/actions/parse.js.map +1 -0
  16. package/dist/src/core/actions/plan.js +197 -0
  17. package/dist/src/core/actions/plan.js.map +1 -0
  18. package/dist/src/core/actions/predicates.js +111 -0
  19. package/dist/src/core/actions/predicates.js.map +1 -0
  20. package/dist/src/core/actions/run-fold.js +248 -0
  21. package/dist/src/core/actions/run-fold.js.map +1 -0
  22. package/dist/src/core/actions/template.js +118 -0
  23. package/dist/src/core/actions/template.js.map +1 -0
  24. package/dist/src/core/cli/args.js +116 -0
  25. package/dist/src/core/cli/args.js.map +1 -0
  26. package/dist/src/core/coerce.js +75 -0
  27. package/dist/src/core/coerce.js.map +1 -0
  28. package/dist/src/core/credential/account-id.js +20 -0
  29. package/dist/src/core/credential/account-id.js.map +1 -0
  30. package/dist/src/core/credential/adapter-config.js +136 -0
  31. package/dist/src/core/credential/adapter-config.js.map +1 -0
  32. package/dist/src/core/credential/availability.js +98 -0
  33. package/dist/src/core/credential/availability.js.map +1 -0
  34. package/dist/src/core/credential/extract.js +228 -0
  35. package/dist/src/core/credential/extract.js.map +1 -0
  36. package/dist/src/core/credential/fake-creds.js +171 -0
  37. package/dist/src/core/credential/fake-creds.js.map +1 -0
  38. package/dist/src/core/credential/identity.js +125 -0
  39. package/dist/src/core/credential/identity.js.map +1 -0
  40. package/dist/src/core/credential/shape.js +230 -0
  41. package/dist/src/core/credential/shape.js.map +1 -0
  42. package/dist/src/core/credential/strings.js +15 -0
  43. package/dist/src/core/credential/strings.js.map +1 -0
  44. package/dist/src/core/doctor/checks.js +303 -0
  45. package/dist/src/core/doctor/checks.js.map +1 -0
  46. package/dist/src/core/git/result.js +107 -0
  47. package/dist/src/core/git/result.js.map +1 -0
  48. package/dist/src/core/http/decisions.js +225 -0
  49. package/dist/src/core/http/decisions.js.map +1 -0
  50. package/dist/{http.js → src/core/http/render.js} +472 -738
  51. package/dist/src/core/http/render.js.map +1 -0
  52. package/dist/{http-handlers.js → src/core/http/routes.js} +52 -87
  53. package/dist/src/core/http/routes.js.map +1 -0
  54. package/dist/src/core/http/views.js +181 -0
  55. package/dist/src/core/http/views.js.map +1 -0
  56. package/dist/src/core/image/managed-image.js +95 -0
  57. package/dist/src/core/image/managed-image.js.map +1 -0
  58. package/dist/src/core/issue/file.js +149 -0
  59. package/dist/src/core/issue/file.js.map +1 -0
  60. package/dist/src/core/issue/parse.js +210 -0
  61. package/dist/src/core/issue/parse.js.map +1 -0
  62. package/dist/src/core/mcp/dispatch.js +239 -0
  63. package/dist/src/core/mcp/dispatch.js.map +1 -0
  64. package/dist/src/core/mcp/post-move.js +92 -0
  65. package/dist/src/core/mcp/post-move.js.map +1 -0
  66. package/dist/src/core/mcp/protocol.js +293 -0
  67. package/dist/src/core/mcp/protocol.js.map +1 -0
  68. package/dist/src/core/mcp/url.js +162 -0
  69. package/dist/src/core/mcp/url.js.map +1 -0
  70. package/dist/src/core/path.js +63 -0
  71. package/dist/src/core/path.js.map +1 -0
  72. package/dist/src/core/reconcile/image-decide.js +48 -0
  73. package/dist/src/core/reconcile/image-decide.js.map +1 -0
  74. package/dist/src/core/reconcile/ledger.js +142 -0
  75. package/dist/src/core/reconcile/ledger.js.map +1 -0
  76. package/dist/src/core/reconcile/pr-classify.js +62 -0
  77. package/dist/src/core/reconcile/pr-classify.js.map +1 -0
  78. package/dist/{reconciler → src/core/reconcile}/pr-decide.js +25 -12
  79. package/dist/src/core/reconcile/pr-decide.js.map +1 -0
  80. package/dist/src/core/reconcile/pr-loop.js +161 -0
  81. package/dist/src/core/reconcile/pr-loop.js.map +1 -0
  82. package/dist/src/core/reconcile/pr-notes.js +35 -0
  83. package/dist/src/core/reconcile/pr-notes.js.map +1 -0
  84. package/dist/src/core/reconcile/vm-decide.js +70 -0
  85. package/dist/src/core/reconcile/vm-decide.js.map +1 -0
  86. package/dist/src/core/reconcile/vm-reap.js +207 -0
  87. package/dist/src/core/reconcile/vm-reap.js.map +1 -0
  88. package/dist/src/core/reconcile/workspace-decide.js +162 -0
  89. package/dist/src/core/reconcile/workspace-decide.js.map +1 -0
  90. package/dist/src/core/runlog/summary.js +231 -0
  91. package/dist/src/core/runlog/summary.js.map +1 -0
  92. package/dist/src/core/runner/dispatch-config.js +95 -0
  93. package/dist/src/core/runner/dispatch-config.js.map +1 -0
  94. package/dist/src/core/runner/injection.js +61 -0
  95. package/dist/src/core/runner/injection.js.map +1 -0
  96. package/dist/src/core/runner/mise.js +210 -0
  97. package/dist/src/core/runner/mise.js.map +1 -0
  98. package/dist/src/core/runner/prompt.js +720 -0
  99. package/dist/src/core/runner/prompt.js.map +1 -0
  100. package/dist/src/core/runner/turn.js +242 -0
  101. package/dist/src/core/runner/turn.js.map +1 -0
  102. package/dist/src/core/runner/vm-plan.js +390 -0
  103. package/dist/src/core/runner/vm-plan.js.map +1 -0
  104. package/dist/src/core/schedule/admission.js +123 -0
  105. package/dist/src/core/schedule/admission.js.map +1 -0
  106. package/dist/src/core/schedule/circuit-breaker.js +111 -0
  107. package/dist/src/core/schedule/circuit-breaker.js.map +1 -0
  108. package/dist/src/core/schedule/eligibility.js +83 -0
  109. package/dist/src/core/schedule/eligibility.js.map +1 -0
  110. package/dist/src/core/schedule/reconcile-issue.js +82 -0
  111. package/dist/src/core/schedule/reconcile-issue.js.map +1 -0
  112. package/dist/src/core/schedule/retry.js +96 -0
  113. package/dist/src/core/schedule/retry.js.map +1 -0
  114. package/dist/src/core/schedule/sleep-cycle.js +133 -0
  115. package/dist/src/core/schedule/sleep-cycle.js.map +1 -0
  116. package/dist/src/core/schedule/slots.js +124 -0
  117. package/dist/src/core/schedule/slots.js.map +1 -0
  118. package/dist/src/core/schedule/tick.js +553 -0
  119. package/dist/src/core/schedule/tick.js.map +1 -0
  120. package/dist/src/core/schedule/token-fold.js +181 -0
  121. package/dist/src/core/schedule/token-fold.js.map +1 -0
  122. package/dist/src/core/state-resolve.js +86 -0
  123. package/dist/src/core/state-resolve.js.map +1 -0
  124. package/dist/src/core/vm-guards.js +278 -0
  125. package/dist/src/core/vm-guards.js.map +1 -0
  126. package/dist/src/core/workflow/derive.js +107 -0
  127. package/dist/src/core/workflow/derive.js.map +1 -0
  128. package/dist/src/core/workflow/parse.js +687 -0
  129. package/dist/src/core/workflow/parse.js.map +1 -0
  130. package/dist/src/core/workflow/prompt-probe.js +78 -0
  131. package/dist/src/core/workflow/prompt-probe.js.map +1 -0
  132. package/dist/src/core/workflow/validate.js +189 -0
  133. package/dist/src/core/workflow/validate.js.map +1 -0
  134. package/dist/src/core/workspace-key.js +19 -0
  135. package/dist/src/core/workspace-key.js.map +1 -0
  136. package/dist/src/shell/actions-runner.js +356 -0
  137. package/dist/src/shell/actions-runner.js.map +1 -0
  138. package/dist/src/shell/adapter/adapter-registry.js +45 -0
  139. package/dist/src/shell/adapter/adapter-registry.js.map +1 -0
  140. package/dist/src/shell/adapter/clock-random.js +96 -0
  141. package/dist/src/shell/adapter/clock-random.js.map +1 -0
  142. package/dist/src/shell/adapter/gondolin-dispatch-helpers.js +158 -0
  143. package/dist/src/shell/adapter/gondolin-dispatch-helpers.js.map +1 -0
  144. package/dist/src/shell/adapter/gondolin-dispatch.js +385 -0
  145. package/dist/src/shell/adapter/gondolin-dispatch.js.map +1 -0
  146. package/dist/src/shell/adapter/gondolin-image-converter.js +233 -0
  147. package/dist/src/shell/adapter/gondolin-image-converter.js.map +1 -0
  148. package/dist/src/shell/adapter/gondolin-image-fetch.js +180 -0
  149. package/dist/src/shell/adapter/gondolin-image-fetch.js.map +1 -0
  150. package/dist/src/shell/adapter/launcher-asset.js +57 -0
  151. package/dist/src/shell/adapter/launcher-asset.js.map +1 -0
  152. package/dist/src/shell/adapter/mise-config-asset.js +65 -0
  153. package/dist/src/shell/adapter/mise-config-asset.js.map +1 -0
  154. package/dist/src/shell/adapter/workflow-loader.js +304 -0
  155. package/dist/src/shell/adapter/workflow-loader.js.map +1 -0
  156. package/dist/src/shell/cli/doctor.js +268 -0
  157. package/dist/src/shell/cli/doctor.js.map +1 -0
  158. package/dist/src/shell/effect-interpreter-families.js +314 -0
  159. package/dist/src/shell/effect-interpreter-families.js.map +1 -0
  160. package/dist/src/shell/effect-interpreter.js +29 -0
  161. package/dist/src/shell/effect-interpreter.js.map +1 -0
  162. package/dist/src/shell/interp/acp-frame.js +137 -0
  163. package/dist/src/shell/interp/acp-frame.js.map +1 -0
  164. package/dist/src/shell/interp/acp-ws-conn.js +320 -0
  165. package/dist/src/shell/interp/acp-ws-conn.js.map +1 -0
  166. package/dist/src/shell/interp/acp-ws-frames.js +159 -0
  167. package/dist/src/shell/interp/acp-ws-frames.js.map +1 -0
  168. package/dist/src/shell/interp/acp-ws.js +197 -0
  169. package/dist/src/shell/interp/acp-ws.js.map +1 -0
  170. package/dist/src/shell/interp/acp.js +319 -0
  171. package/dist/src/shell/interp/acp.js.map +1 -0
  172. package/dist/src/shell/interp/credential-defaults.js +128 -0
  173. package/dist/src/shell/interp/credential-defaults.js.map +1 -0
  174. package/dist/src/shell/interp/credential-hooks.js +149 -0
  175. package/dist/src/shell/interp/credential-hooks.js.map +1 -0
  176. package/dist/src/shell/interp/credential-registry.js +226 -0
  177. package/dist/src/shell/interp/credential-registry.js.map +1 -0
  178. package/dist/src/shell/interp/credential.js +103 -0
  179. package/dist/src/shell/interp/credential.js.map +1 -0
  180. package/dist/src/shell/interp/gh.js +163 -0
  181. package/dist/src/shell/interp/gh.js.map +1 -0
  182. package/dist/src/shell/interp/git.js +28 -0
  183. package/dist/src/shell/interp/git.js.map +1 -0
  184. package/dist/src/shell/interp/log.js +213 -0
  185. package/dist/src/shell/interp/log.js.map +1 -0
  186. package/dist/src/shell/interp/process.js +178 -0
  187. package/dist/src/shell/interp/process.js.map +1 -0
  188. package/dist/src/shell/interp/runlog.js +193 -0
  189. package/dist/src/shell/interp/runlog.js.map +1 -0
  190. package/dist/src/shell/interp/timer.js +64 -0
  191. package/dist/src/shell/interp/timer.js.map +1 -0
  192. package/dist/src/shell/interp/tracker-disk.js +99 -0
  193. package/dist/src/shell/interp/tracker-disk.js.map +1 -0
  194. package/dist/src/shell/interp/tracker-parse.js +71 -0
  195. package/dist/src/shell/interp/tracker-parse.js.map +1 -0
  196. package/dist/src/shell/interp/tracker-scan.js +238 -0
  197. package/dist/src/shell/interp/tracker-scan.js.map +1 -0
  198. package/dist/src/shell/interp/tracker-write.js +91 -0
  199. package/dist/src/shell/interp/tracker-write.js.map +1 -0
  200. package/dist/src/shell/interp/tracker.js +41 -0
  201. package/dist/src/shell/interp/tracker.js.map +1 -0
  202. package/dist/src/shell/interp/tty.js +48 -0
  203. package/dist/src/shell/interp/tty.js.map +1 -0
  204. package/dist/src/shell/interp/vm.js +199 -0
  205. package/dist/src/shell/interp/vm.js.map +1 -0
  206. package/dist/src/shell/interp/workspace.js +310 -0
  207. package/dist/src/shell/interp/workspace.js.map +1 -0
  208. package/dist/src/shell/main-acp.js +78 -0
  209. package/dist/src/shell/main-acp.js.map +1 -0
  210. package/dist/src/shell/main-adapters.js +222 -0
  211. package/dist/src/shell/main-adapters.js.map +1 -0
  212. package/dist/src/shell/main-credential.js +122 -0
  213. package/dist/src/shell/main-credential.js.map +1 -0
  214. package/dist/src/shell/main-doctor.js +22 -0
  215. package/dist/src/shell/main-doctor.js.map +1 -0
  216. package/dist/src/shell/main-entry.js +46 -0
  217. package/dist/src/shell/main-entry.js.map +1 -0
  218. package/dist/src/shell/main-http-csrf.js +45 -0
  219. package/dist/src/shell/main-http-csrf.js.map +1 -0
  220. package/dist/src/shell/main-http-handler.js +389 -0
  221. package/dist/src/shell/main-http-handler.js.map +1 -0
  222. package/dist/src/shell/main-http-mcp.js +122 -0
  223. package/dist/src/shell/main-http-mcp.js.map +1 -0
  224. package/dist/src/shell/main-http-views.js +253 -0
  225. package/dist/src/shell/main-http-views.js.map +1 -0
  226. package/dist/src/shell/main-http.js +76 -0
  227. package/dist/src/shell/main-http.js.map +1 -0
  228. package/dist/src/shell/main-loops.js +130 -0
  229. package/dist/src/shell/main-loops.js.map +1 -0
  230. package/dist/src/shell/main-mcp.js +129 -0
  231. package/dist/src/shell/main-mcp.js.map +1 -0
  232. package/dist/src/shell/main-orchestrator.js +120 -0
  233. package/dist/src/shell/main-orchestrator.js.map +1 -0
  234. package/dist/src/shell/main-preflight.js +43 -0
  235. package/dist/src/shell/main-preflight.js.map +1 -0
  236. package/dist/src/shell/main-reconcilers-helpers.js +244 -0
  237. package/dist/src/shell/main-reconcilers-helpers.js.map +1 -0
  238. package/dist/src/shell/main-reconcilers-pr.js +148 -0
  239. package/dist/src/shell/main-reconcilers-pr.js.map +1 -0
  240. package/dist/src/shell/main-reconcilers.js +225 -0
  241. package/dist/src/shell/main-reconcilers.js.map +1 -0
  242. package/dist/src/shell/main-runner.js +355 -0
  243. package/dist/src/shell/main-runner.js.map +1 -0
  244. package/dist/src/shell/main-scaffold.js +116 -0
  245. package/dist/src/shell/main-scaffold.js.map +1 -0
  246. package/dist/src/shell/main-shutdown.js +115 -0
  247. package/dist/src/shell/main-shutdown.js.map +1 -0
  248. package/dist/src/shell/main-startup.js +48 -0
  249. package/dist/src/shell/main-startup.js.map +1 -0
  250. package/dist/src/shell/main-substrates.js +43 -0
  251. package/dist/src/shell/main-substrates.js.map +1 -0
  252. package/dist/src/shell/main.js +385 -0
  253. package/dist/src/shell/main.js.map +1 -0
  254. package/dist/src/shell/orchestrator-feedback.js +69 -0
  255. package/dist/src/shell/orchestrator-feedback.js.map +1 -0
  256. package/dist/src/shell/orchestrator-image.js +167 -0
  257. package/dist/src/shell/orchestrator-image.js.map +1 -0
  258. package/dist/src/shell/orchestrator-loop.js +468 -0
  259. package/dist/src/shell/orchestrator-loop.js.map +1 -0
  260. package/dist/src/shell/orchestrator-reconcile.js +36 -0
  261. package/dist/src/shell/orchestrator-reconcile.js.map +1 -0
  262. package/dist/src/shell/reconciler-loop.js +228 -0
  263. package/dist/src/shell/reconciler-loop.js.map +1 -0
  264. package/dist/src/shell/runner-loop-turn.js +301 -0
  265. package/dist/src/shell/runner-loop-turn.js.map +1 -0
  266. package/dist/src/shell/runner-loop.js +338 -0
  267. package/dist/src/shell/runner-loop.js.map +1 -0
  268. package/dist/src/shell/server/http.js +208 -0
  269. package/dist/src/shell/server/http.js.map +1 -0
  270. package/dist/src/shell/server/mcp-runtime-effects.js +237 -0
  271. package/dist/src/shell/server/mcp-runtime-effects.js.map +1 -0
  272. package/dist/src/shell/server/mcp-runtime.js +99 -0
  273. package/dist/src/shell/server/mcp-runtime.js.map +1 -0
  274. package/dist/src/shell/workspace-key.js +14 -0
  275. package/dist/src/shell/workspace-key.js.map +1 -0
  276. package/dist/src/types/acp.js +8 -0
  277. package/dist/src/types/acp.js.map +1 -0
  278. package/dist/src/types/actions/plan.js +6 -0
  279. package/dist/src/types/actions/plan.js.map +1 -0
  280. package/dist/src/types/actions/predicates.js +6 -0
  281. package/dist/src/types/actions/predicates.js.map +1 -0
  282. package/dist/src/types/actions/run-fold.js +8 -0
  283. package/dist/src/types/actions/run-fold.js.map +1 -0
  284. package/dist/src/types/actions.js +7 -0
  285. package/dist/src/types/actions.js.map +1 -0
  286. package/dist/src/types/adapter/clock-random.js +4 -0
  287. package/dist/src/types/adapter/clock-random.js.map +1 -0
  288. package/dist/src/types/adapter/gondolin-image-converter.js +5 -0
  289. package/dist/src/types/adapter/gondolin-image-converter.js.map +1 -0
  290. package/dist/src/types/adapter/gondolin-image-fetch.js +5 -0
  291. package/dist/src/types/adapter/gondolin-image-fetch.js.map +1 -0
  292. package/dist/src/types/adapter/workflow-loader.js +4 -0
  293. package/dist/src/types/adapter/workflow-loader.js.map +1 -0
  294. package/dist/src/types/cli/args.js +8 -0
  295. package/dist/src/types/cli/args.js.map +1 -0
  296. package/dist/src/types/config.js +8 -0
  297. package/dist/src/types/config.js.map +1 -0
  298. package/dist/src/types/credential-interp.js +6 -0
  299. package/dist/src/types/credential-interp.js.map +1 -0
  300. package/dist/src/types/credentials.js +10 -0
  301. package/dist/src/types/credentials.js.map +1 -0
  302. package/dist/src/types/doctor.js +7 -0
  303. package/dist/src/types/doctor.js.map +1 -0
  304. package/dist/src/types/domain.js +7 -0
  305. package/dist/src/types/domain.js.map +1 -0
  306. package/dist/src/types/effect.js +15 -0
  307. package/dist/src/types/effect.js.map +1 -0
  308. package/dist/src/types/errors.js +39 -0
  309. package/dist/src/types/errors.js.map +1 -0
  310. package/dist/src/types/http/decisions.js +6 -0
  311. package/dist/src/types/http/decisions.js.map +1 -0
  312. package/dist/src/types/http/render.js +10 -0
  313. package/dist/src/types/http/render.js.map +1 -0
  314. package/dist/src/types/http/views.js +6 -0
  315. package/dist/src/types/http/views.js.map +1 -0
  316. package/dist/src/types/http.js +9 -0
  317. package/dist/src/types/http.js.map +1 -0
  318. package/dist/src/types/image/managed-image.js +7 -0
  319. package/dist/src/types/image/managed-image.js.map +1 -0
  320. package/dist/src/types/interp/effect-interpreter.js +8 -0
  321. package/dist/src/types/interp/effect-interpreter.js.map +1 -0
  322. package/dist/src/types/interp/tracker.js +7 -0
  323. package/dist/src/types/interp/tracker.js.map +1 -0
  324. package/dist/src/types/issue/file.js +6 -0
  325. package/dist/src/types/issue/file.js.map +1 -0
  326. package/dist/src/types/issue/parse.js +8 -0
  327. package/dist/src/types/issue/parse.js.map +1 -0
  328. package/dist/src/types/main-acp.js +13 -0
  329. package/dist/src/types/main-acp.js.map +1 -0
  330. package/dist/src/types/main-adapters.js +5 -0
  331. package/dist/src/types/main-adapters.js.map +1 -0
  332. package/dist/src/types/main-credential.js +21 -0
  333. package/dist/src/types/main-credential.js.map +1 -0
  334. package/dist/src/types/main-doctor.js +6 -0
  335. package/dist/src/types/main-doctor.js.map +1 -0
  336. package/dist/src/types/main-http-handler.js +12 -0
  337. package/dist/src/types/main-http-handler.js.map +1 -0
  338. package/dist/src/types/main-http.js +5 -0
  339. package/dist/src/types/main-http.js.map +1 -0
  340. package/dist/src/types/main-loops.js +5 -0
  341. package/dist/src/types/main-loops.js.map +1 -0
  342. package/dist/src/types/main-mcp.js +12 -0
  343. package/dist/src/types/main-mcp.js.map +1 -0
  344. package/dist/src/types/main-orchestrator.js +5 -0
  345. package/dist/src/types/main-orchestrator.js.map +1 -0
  346. package/dist/src/types/main-reconcilers.js +11 -0
  347. package/dist/src/types/main-reconcilers.js.map +1 -0
  348. package/dist/src/types/main-runner.js +13 -0
  349. package/dist/src/types/main-runner.js.map +1 -0
  350. package/dist/src/types/main-startup.js +5 -0
  351. package/dist/src/types/main-startup.js.map +1 -0
  352. package/dist/src/types/main-substrates.js +5 -0
  353. package/dist/src/types/main-substrates.js.map +1 -0
  354. package/dist/src/types/mcp/dispatch.js +4 -0
  355. package/dist/src/types/mcp/dispatch.js.map +1 -0
  356. package/dist/src/types/mcp/post-move.js +7 -0
  357. package/dist/src/types/mcp/post-move.js.map +1 -0
  358. package/dist/src/types/mcp.js +9 -0
  359. package/dist/src/types/mcp.js.map +1 -0
  360. package/dist/src/types/ports.js +12 -0
  361. package/dist/src/types/ports.js.map +1 -0
  362. package/dist/src/types/reconcile/image-decide.js +5 -0
  363. package/dist/src/types/reconcile/image-decide.js.map +1 -0
  364. package/dist/src/types/reconcile/ledger.js +7 -0
  365. package/dist/src/types/reconcile/ledger.js.map +1 -0
  366. package/dist/src/types/reconcile/pr-loop.js +8 -0
  367. package/dist/src/types/reconcile/pr-loop.js.map +1 -0
  368. package/dist/src/types/reconcile/vm-reap.js +8 -0
  369. package/dist/src/types/reconcile/vm-reap.js.map +1 -0
  370. package/dist/src/types/reconcile/workspace-decide.js +7 -0
  371. package/dist/src/types/reconcile/workspace-decide.js.map +1 -0
  372. package/dist/src/types/reconcile.js +9 -0
  373. package/dist/src/types/reconcile.js.map +1 -0
  374. package/dist/src/types/runlog.js +7 -0
  375. package/dist/src/types/runlog.js.map +1 -0
  376. package/dist/src/types/runner/actions-runner.js +12 -0
  377. package/dist/src/types/runner/actions-runner.js.map +1 -0
  378. package/dist/src/types/runner/gondolin-dispatch.js +5 -0
  379. package/dist/src/types/runner/gondolin-dispatch.js.map +1 -0
  380. package/dist/src/types/runner/injection.js +6 -0
  381. package/dist/src/types/runner/injection.js.map +1 -0
  382. package/dist/src/types/runner/runner-loop.js +5 -0
  383. package/dist/src/types/runner/runner-loop.js.map +1 -0
  384. package/dist/src/types/runner/turn.js +4 -0
  385. package/dist/src/types/runner/turn.js.map +1 -0
  386. package/dist/src/types/runner/vm-plan.js +4 -0
  387. package/dist/src/types/runner/vm-plan.js.map +1 -0
  388. package/dist/src/types/runtime.js +9 -0
  389. package/dist/src/types/runtime.js.map +1 -0
  390. package/dist/src/types/schedule/admission.js +7 -0
  391. package/dist/src/types/schedule/admission.js.map +1 -0
  392. package/dist/src/types/schedule/circuit-breaker.js +2 -0
  393. package/dist/src/types/schedule/circuit-breaker.js.map +1 -0
  394. package/dist/src/types/schedule/eligibility.js +9 -0
  395. package/dist/src/types/schedule/eligibility.js.map +1 -0
  396. package/dist/src/types/schedule/orchestrator-loop.js +10 -0
  397. package/dist/src/types/schedule/orchestrator-loop.js.map +1 -0
  398. package/dist/src/types/schedule/sleep-cycle.js +4 -0
  399. package/dist/src/types/schedule/sleep-cycle.js.map +1 -0
  400. package/dist/src/types/schedule/slots.js +8 -0
  401. package/dist/src/types/schedule/slots.js.map +1 -0
  402. package/dist/src/types/schedule/tick.js +9 -0
  403. package/dist/src/types/schedule/tick.js.map +1 -0
  404. package/dist/src/types/server/mcp-runtime.js +8 -0
  405. package/dist/src/types/server/mcp-runtime.js.map +1 -0
  406. package/dist/src/types/workflow/parse.js +4 -0
  407. package/dist/src/types/workflow/parse.js.map +1 -0
  408. package/dist/tests/core/account-id.test.js +35 -0
  409. package/dist/tests/core/account-id.test.js.map +1 -0
  410. package/dist/tests/core/actions-parse.test.js +176 -0
  411. package/dist/tests/core/actions-parse.test.js.map +1 -0
  412. package/dist/tests/core/adapter-config.test.js +133 -0
  413. package/dist/tests/core/adapter-config.test.js.map +1 -0
  414. package/dist/tests/core/admission.test.js +215 -0
  415. package/dist/tests/core/admission.test.js.map +1 -0
  416. package/dist/tests/core/args.test.js +132 -0
  417. package/dist/tests/core/args.test.js.map +1 -0
  418. package/dist/tests/core/availability.test.js +62 -0
  419. package/dist/tests/core/availability.test.js.map +1 -0
  420. package/dist/tests/core/checks.test.js +395 -0
  421. package/dist/tests/core/checks.test.js.map +1 -0
  422. package/dist/tests/core/circuit-breaker.test.js +172 -0
  423. package/dist/tests/core/circuit-breaker.test.js.map +1 -0
  424. package/dist/tests/core/coerce.test.js +87 -0
  425. package/dist/tests/core/coerce.test.js.map +1 -0
  426. package/dist/tests/core/context.test.js +228 -0
  427. package/dist/tests/core/context.test.js.map +1 -0
  428. package/dist/tests/core/decisions.test.js +310 -0
  429. package/dist/tests/core/decisions.test.js.map +1 -0
  430. package/dist/tests/core/derive.test.js +205 -0
  431. package/dist/tests/core/derive.test.js.map +1 -0
  432. package/dist/tests/core/dispatch-config.test.js +164 -0
  433. package/dist/tests/core/dispatch-config.test.js.map +1 -0
  434. package/dist/tests/core/dispatch.test.js +302 -0
  435. package/dist/tests/core/dispatch.test.js.map +1 -0
  436. package/dist/tests/core/eligibility.test.js +163 -0
  437. package/dist/tests/core/eligibility.test.js.map +1 -0
  438. package/dist/tests/core/extract.test.js +139 -0
  439. package/dist/tests/core/extract.test.js.map +1 -0
  440. package/dist/tests/core/fake-creds.test.js +134 -0
  441. package/dist/tests/core/fake-creds.test.js.map +1 -0
  442. package/dist/tests/core/file.test.js +197 -0
  443. package/dist/tests/core/file.test.js.map +1 -0
  444. package/dist/tests/core/git-result.test.js +113 -0
  445. package/dist/tests/core/git-result.test.js.map +1 -0
  446. package/dist/tests/core/identity.test.js +180 -0
  447. package/dist/tests/core/identity.test.js.map +1 -0
  448. package/dist/tests/core/image-decide.test.js +59 -0
  449. package/dist/tests/core/image-decide.test.js.map +1 -0
  450. package/dist/tests/core/injection.test.js +163 -0
  451. package/dist/tests/core/injection.test.js.map +1 -0
  452. package/dist/tests/core/ledger.test.js +218 -0
  453. package/dist/tests/core/ledger.test.js.map +1 -0
  454. package/dist/tests/core/managed-image.test.js +68 -0
  455. package/dist/tests/core/managed-image.test.js.map +1 -0
  456. package/dist/tests/core/mise.test.js +138 -0
  457. package/dist/tests/core/mise.test.js.map +1 -0
  458. package/dist/tests/core/parse.test.js +174 -0
  459. package/dist/tests/core/parse.test.js.map +1 -0
  460. package/dist/tests/core/path.test.js +50 -0
  461. package/dist/tests/core/path.test.js.map +1 -0
  462. package/dist/tests/core/plan.test.js +218 -0
  463. package/dist/tests/core/plan.test.js.map +1 -0
  464. package/dist/tests/core/post-move.test.js +162 -0
  465. package/dist/tests/core/post-move.test.js.map +1 -0
  466. package/dist/tests/core/pr-classify.test.js +117 -0
  467. package/dist/tests/core/pr-classify.test.js.map +1 -0
  468. package/dist/tests/core/pr-decide.test.js +298 -0
  469. package/dist/tests/core/pr-decide.test.js.map +1 -0
  470. package/dist/tests/core/pr-loop.test.js +301 -0
  471. package/dist/tests/core/pr-loop.test.js.map +1 -0
  472. package/dist/tests/core/pr-notes.test.js +165 -0
  473. package/dist/tests/core/pr-notes.test.js.map +1 -0
  474. package/dist/tests/core/predicates.test.js +154 -0
  475. package/dist/tests/core/predicates.test.js.map +1 -0
  476. package/dist/tests/core/prompt.test.js +189 -0
  477. package/dist/tests/core/prompt.test.js.map +1 -0
  478. package/dist/tests/core/protocol.test.js +195 -0
  479. package/dist/tests/core/protocol.test.js.map +1 -0
  480. package/dist/tests/core/reconcile-issue.test.js +116 -0
  481. package/dist/tests/core/reconcile-issue.test.js.map +1 -0
  482. package/dist/tests/core/render.test.js +549 -0
  483. package/dist/tests/core/render.test.js.map +1 -0
  484. package/dist/tests/core/retry.test.js +186 -0
  485. package/dist/tests/core/retry.test.js.map +1 -0
  486. package/dist/tests/core/routes.test.js +247 -0
  487. package/dist/tests/core/routes.test.js.map +1 -0
  488. package/dist/tests/core/run-fold.test.js +299 -0
  489. package/dist/tests/core/run-fold.test.js.map +1 -0
  490. package/dist/tests/core/shape.test.js +185 -0
  491. package/dist/tests/core/shape.test.js.map +1 -0
  492. package/dist/tests/core/sleep-cycle.test.js +150 -0
  493. package/dist/tests/core/sleep-cycle.test.js.map +1 -0
  494. package/dist/tests/core/slots.test.js +201 -0
  495. package/dist/tests/core/slots.test.js.map +1 -0
  496. package/dist/tests/core/state-resolve.test.js +80 -0
  497. package/dist/tests/core/state-resolve.test.js.map +1 -0
  498. package/dist/tests/core/summary.test.js +200 -0
  499. package/dist/tests/core/summary.test.js.map +1 -0
  500. package/dist/tests/core/template.test.js +116 -0
  501. package/dist/tests/core/template.test.js.map +1 -0
  502. package/dist/tests/core/tick.test.js +558 -0
  503. package/dist/tests/core/tick.test.js.map +1 -0
  504. package/dist/tests/core/token-fold.test.js +176 -0
  505. package/dist/tests/core/token-fold.test.js.map +1 -0
  506. package/dist/tests/core/turn.test.js +388 -0
  507. package/dist/tests/core/turn.test.js.map +1 -0
  508. package/dist/tests/core/url.test.js +118 -0
  509. package/dist/tests/core/url.test.js.map +1 -0
  510. package/dist/tests/core/validate.test.js +247 -0
  511. package/dist/tests/core/validate.test.js.map +1 -0
  512. package/dist/tests/core/views.test.js +252 -0
  513. package/dist/tests/core/views.test.js.map +1 -0
  514. package/dist/tests/core/vm-decide.test.js +110 -0
  515. package/dist/tests/core/vm-decide.test.js.map +1 -0
  516. package/dist/tests/core/vm-guards.test.js +153 -0
  517. package/dist/tests/core/vm-guards.test.js.map +1 -0
  518. package/dist/tests/core/vm-plan.test.js +332 -0
  519. package/dist/tests/core/vm-plan.test.js.map +1 -0
  520. package/dist/tests/core/vm-reap.test.js +196 -0
  521. package/dist/tests/core/vm-reap.test.js.map +1 -0
  522. package/dist/tests/core/workflow-parse.test.js +493 -0
  523. package/dist/tests/core/workflow-parse.test.js.map +1 -0
  524. package/dist/tests/core/workspace-decide.test.js +236 -0
  525. package/dist/tests/core/workspace-decide.test.js.map +1 -0
  526. package/dist/tests/helpers/fixtures.js +167 -0
  527. package/dist/tests/helpers/fixtures.js.map +1 -0
  528. package/dist/tests/shell/acp-substrate.test.js +101 -0
  529. package/dist/tests/shell/acp-substrate.test.js.map +1 -0
  530. package/dist/tests/shell/actions-runner-push.test.js +203 -0
  531. package/dist/tests/shell/actions-runner-push.test.js.map +1 -0
  532. package/dist/tests/shell/credential-hooks.test.js +36 -0
  533. package/dist/tests/shell/credential-hooks.test.js.map +1 -0
  534. package/dist/tests/shell/credential-registry.test.js +165 -0
  535. package/dist/tests/shell/credential-registry.test.js.map +1 -0
  536. package/dist/tests/shell/credential-substrate.test.js +179 -0
  537. package/dist/tests/shell/credential-substrate.test.js.map +1 -0
  538. package/dist/tests/shell/dockerfile-mise-pin.test.js +51 -0
  539. package/dist/tests/shell/dockerfile-mise-pin.test.js.map +1 -0
  540. package/dist/tests/shell/doctor.test.js +101 -0
  541. package/dist/tests/shell/doctor.test.js.map +1 -0
  542. package/dist/tests/shell/effect-vm-create.test.js +52 -0
  543. package/dist/tests/shell/effect-vm-create.test.js.map +1 -0
  544. package/dist/tests/shell/gh-port.test.js +63 -0
  545. package/dist/tests/shell/gh-port.test.js.map +1 -0
  546. package/dist/tests/shell/gondolin-dispatch-guard.test.js +144 -0
  547. package/dist/tests/shell/gondolin-dispatch-guard.test.js.map +1 -0
  548. package/dist/tests/shell/gondolin-dispatch-shquote.test.js +168 -0
  549. package/dist/tests/shell/gondolin-dispatch-shquote.test.js.map +1 -0
  550. package/dist/tests/shell/gondolin-image-converter.test.js +208 -0
  551. package/dist/tests/shell/gondolin-image-converter.test.js.map +1 -0
  552. package/dist/tests/shell/gondolin-image-fetch.test.js +93 -0
  553. package/dist/tests/shell/gondolin-image-fetch.test.js.map +1 -0
  554. package/dist/tests/shell/http-handler.test.js +608 -0
  555. package/dist/tests/shell/http-handler.test.js.map +1 -0
  556. package/dist/tests/shell/http-server.test.js +53 -0
  557. package/dist/tests/shell/http-server.test.js.map +1 -0
  558. package/dist/tests/shell/mcp-runtime.test.js +366 -0
  559. package/dist/tests/shell/mcp-runtime.test.js.map +1 -0
  560. package/dist/tests/shell/mise-config-asset.test.js +87 -0
  561. package/dist/tests/shell/mise-config-asset.test.js.map +1 -0
  562. package/dist/tests/shell/orchestrator-loop.test.js +583 -0
  563. package/dist/tests/shell/orchestrator-loop.test.js.map +1 -0
  564. package/dist/tests/shell/reconciler-passes.test.js +314 -0
  565. package/dist/tests/shell/reconciler-passes.test.js.map +1 -0
  566. package/dist/tests/shell/runner-loop-turn.test.js +97 -0
  567. package/dist/tests/shell/runner-loop-turn.test.js.map +1 -0
  568. package/dist/tests/shell/runner-slice.test.js +536 -0
  569. package/dist/tests/shell/runner-slice.test.js.map +1 -0
  570. package/dist/tests/shell/scaffold.test.js +65 -0
  571. package/dist/tests/shell/scaffold.test.js.map +1 -0
  572. package/dist/tests/shell/tick-config.test.js +83 -0
  573. package/dist/tests/shell/tick-config.test.js.map +1 -0
  574. package/dist/tests/shell/tracker-parse-dates.test.js +44 -0
  575. package/dist/tests/shell/tracker-parse-dates.test.js.map +1 -0
  576. package/dist/tests/shell/tracker-write-issue.test.js +154 -0
  577. package/dist/tests/shell/tracker-write-issue.test.js.map +1 -0
  578. package/dist/tests/shell/workflow-prompt-split.test.js +208 -0
  579. package/dist/tests/shell/workflow-prompt-split.test.js.map +1 -0
  580. package/dist/tests/shell/workspace-live-config.test.js +140 -0
  581. package/dist/tests/shell/workspace-live-config.test.js.map +1 -0
  582. package/package.json +21 -9
  583. package/patches/@earendil-works+gondolin+0.12.0.patch +173 -0
  584. package/prompts/Reflect.md +91 -0
  585. package/prompts/Review.md +97 -0
  586. package/prompts/Todo.md +96 -0
  587. package/prompts/_footer.md +41 -0
  588. package/prompts/_preamble.md +42 -0
  589. package/prompts-minimal/Todo.md +26 -0
  590. package/scripts/postinstall.mjs +63 -0
  591. package/scripts/vm-agent.mjs +312 -90
  592. package/WORKFLOW.md +0 -744
  593. package/dist/acp-bridge.js +0 -324
  594. package/dist/acp-bridge.js.map +0 -1
  595. package/dist/actions/cache.js +0 -191
  596. package/dist/actions/cache.js.map +0 -1
  597. package/dist/actions/effects.js +0 -41
  598. package/dist/actions/effects.js.map +0 -1
  599. package/dist/actions/executor.js +0 -570
  600. package/dist/actions/executor.js.map +0 -1
  601. package/dist/actions/index.js +0 -13
  602. package/dist/actions/index.js.map +0 -1
  603. package/dist/actions/parsing.js.map +0 -1
  604. package/dist/actions/predicate-env.js +0 -27
  605. package/dist/actions/predicate-env.js.map +0 -1
  606. package/dist/actions/predicates.js +0 -49
  607. package/dist/actions/predicates.js.map +0 -1
  608. package/dist/actions/templating.js +0 -66
  609. package/dist/actions/templating.js.map +0 -1
  610. package/dist/actions/types.js +0 -15
  611. package/dist/actions/types.js.map +0 -1
  612. package/dist/agent/acp.js +0 -473
  613. package/dist/agent/acp.js.map +0 -1
  614. package/dist/agent/adapter-names.js +0 -159
  615. package/dist/agent/adapter-names.js.map +0 -1
  616. package/dist/agent/adapters.js +0 -511
  617. package/dist/agent/adapters.js.map +0 -1
  618. package/dist/agent/credential-extractors.js +0 -342
  619. package/dist/agent/credential-extractors.js.map +0 -1
  620. package/dist/agent/credential-secrets.js +0 -628
  621. package/dist/agent/credential-secrets.js.map +0 -1
  622. package/dist/agent/credential-ticker.js +0 -57
  623. package/dist/agent/credential-ticker.js.map +0 -1
  624. package/dist/agent/gondolin-creds-staging.js +0 -356
  625. package/dist/agent/gondolin-creds-staging.js.map +0 -1
  626. package/dist/agent/gondolin-dispatch.js +0 -375
  627. package/dist/agent/gondolin-dispatch.js.map +0 -1
  628. package/dist/agent/gondolin.js +0 -124
  629. package/dist/agent/gondolin.js.map +0 -1
  630. package/dist/agent/runner-decisions.js +0 -134
  631. package/dist/agent/runner-decisions.js.map +0 -1
  632. package/dist/agent/runner.js +0 -1456
  633. package/dist/agent/runner.js.map +0 -1
  634. package/dist/agent/tool-call-summary.js +0 -102
  635. package/dist/agent/tool-call-summary.js.map +0 -1
  636. package/dist/agent/vm-acp-mapping.js +0 -73
  637. package/dist/agent/vm-acp-mapping.js.map +0 -1
  638. package/dist/agent/vm-guards.js +0 -262
  639. package/dist/agent/vm-guards.js.map +0 -1
  640. package/dist/agent/vm-port.js +0 -22
  641. package/dist/agent/vm-port.js.map +0 -1
  642. package/dist/agent/vm-process-registry.js +0 -79
  643. package/dist/agent/vm-process-registry.js.map +0 -1
  644. package/dist/bin/cli-args.js +0 -105
  645. package/dist/bin/cli-args.js.map +0 -1
  646. package/dist/bin/symphony.js +0 -794
  647. package/dist/bin/symphony.js.map +0 -1
  648. package/dist/errors.js +0 -15
  649. package/dist/errors.js.map +0 -1
  650. package/dist/http-disk.js +0 -135
  651. package/dist/http-disk.js.map +0 -1
  652. package/dist/http-handlers.js.map +0 -1
  653. package/dist/http.js.map +0 -1
  654. package/dist/issues.js +0 -178
  655. package/dist/issues.js.map +0 -1
  656. package/dist/logging.js +0 -203
  657. package/dist/logging.js.map +0 -1
  658. package/dist/mcp.js +0 -706
  659. package/dist/mcp.js.map +0 -1
  660. package/dist/memory.js +0 -85
  661. package/dist/memory.js.map +0 -1
  662. package/dist/orchestrator-decisions.js +0 -331
  663. package/dist/orchestrator-decisions.js.map +0 -1
  664. package/dist/orchestrator.js +0 -1569
  665. package/dist/orchestrator.js.map +0 -1
  666. package/dist/prompt.js +0 -65
  667. package/dist/prompt.js.map +0 -1
  668. package/dist/reconciler/cache.js +0 -65
  669. package/dist/reconciler/cache.js.map +0 -1
  670. package/dist/reconciler/index.js +0 -448
  671. package/dist/reconciler/index.js.map +0 -1
  672. package/dist/reconciler/ledger.js +0 -131
  673. package/dist/reconciler/ledger.js.map +0 -1
  674. package/dist/reconciler/pr-adapters.js +0 -174
  675. package/dist/reconciler/pr-adapters.js.map +0 -1
  676. package/dist/reconciler/pr-decide.js.map +0 -1
  677. package/dist/reconciler/pr.js +0 -422
  678. package/dist/reconciler/pr.js.map +0 -1
  679. package/dist/reconciler/types.js +0 -12
  680. package/dist/reconciler/types.js.map +0 -1
  681. package/dist/reconciler/vm.js +0 -243
  682. package/dist/reconciler/vm.js.map +0 -1
  683. package/dist/reconciler/workspace-defaults.js +0 -83
  684. package/dist/reconciler/workspace-defaults.js.map +0 -1
  685. package/dist/reconciler/workspace.js +0 -272
  686. package/dist/reconciler/workspace.js.map +0 -1
  687. package/dist/runlog.js +0 -403
  688. package/dist/runlog.js.map +0 -1
  689. package/dist/scaffold.js +0 -165
  690. package/dist/scaffold.js.map +0 -1
  691. package/dist/trackers/local.js +0 -445
  692. package/dist/trackers/local.js.map +0 -1
  693. package/dist/trackers/types.js +0 -10
  694. package/dist/trackers/types.js.map +0 -1
  695. package/dist/types.js +0 -3
  696. package/dist/types.js.map +0 -1
  697. package/dist/util/clock.js +0 -12
  698. package/dist/util/clock.js.map +0 -1
  699. package/dist/util/crypto.js +0 -25
  700. package/dist/util/crypto.js.map +0 -1
  701. package/dist/util/frontmatter.js +0 -70
  702. package/dist/util/frontmatter.js.map +0 -1
  703. package/dist/util/fs-issues.js +0 -22
  704. package/dist/util/fs-issues.js.map +0 -1
  705. package/dist/util/process.js +0 -152
  706. package/dist/util/process.js.map +0 -1
  707. package/dist/util/workspace-key.js +0 -10
  708. package/dist/util/workspace-key.js.map +0 -1
  709. package/dist/workflow-loader.js +0 -147
  710. package/dist/workflow-loader.js.map +0 -1
  711. package/dist/workflow.js +0 -822
  712. package/dist/workflow.js.map +0 -1
  713. package/dist/workspace-types.js +0 -8
  714. package/dist/workspace-types.js.map +0 -1
  715. package/dist/workspace.js +0 -443
  716. package/dist/workspace.js.map +0 -1
@@ -0,0 +1,356 @@
1
+ // FCIS rewrite — imperative shell: the terminal-state `actions:` runner.
2
+ //
3
+ // The IMPERATIVE driver behind the runner loop's phase 8 (the per-state cleanup
4
+ // block; the VM is still alive so a `run_in_vm` action can exec into it). Every
5
+ // routing / precedence / retry DECISION lives in the functional core
6
+ // (core/actions/{plan,context,predicates,run-fold}.ts + core/workflow/derive.ts);
7
+ // this shell only EXECUTES: it resolves the state's actions, plans the per-action
8
+ // Effect sequences, runs them through the SAME central effect interpreter the rest
9
+ // of the runner uses, and folds each outcome back through the pure run-fold ledger.
10
+ //
11
+ // A `run_in_vm` action is the one kind the shell execs directly: the planner emits
12
+ // a `vm.exec` whose vmId is a placeholder (core holds no VM handle), so this runner
13
+ // execs the rendered command on the live per-issue VM (phase 8 keeps it alive) and
14
+ // maps the exit code to the ActionOutcome. The run is uncached.
15
+ //
16
+ // Per the FCIS layout rule a shell module imports from src/types ONLY; the pure
17
+ // core deciders arrive INJECTED via `ActionsRunnerCore` (the composition root binds
18
+ // the real core fns). The interpreter / clock / runlog are ports.
19
+ const STDIO_CAPTURE_LIMIT = 65_536;
20
+ const DEFAULT_COMMAND_TIMEOUT_MS = 300_000;
21
+ /**
22
+ * Build the terminal-state actions runner the runner-loop's phase 8 calls. The
23
+ * returned `runStateActions` resolves the state's `actions:` block, derives the
24
+ * context, plans the per-action effects, and drives the run-fold loop — returning
25
+ * a {@link StateActionsRun} (the non-routed abort reason for the attempt outcome
26
+ * plus the retain-workspace reason for a failed handoff). On a route it ALSO moves
27
+ * the issue OUT of the (terminal) action state into the `on_error.then.route_to`
28
+ * holding state so a failed Done handoff is operator-visible (issue 235); if that
29
+ * reroute move ITSELF fails the issue is still stranded in the terminal state, so the
30
+ * failure is surfaced as a non-routed attempt failure (worker exits abnormal) rather
31
+ * than dead-ending silently — the workspace is retained on both paths.
32
+ */
33
+ export function createActionsRunner(deps) {
34
+ async function runStateActions(args) {
35
+ const cfg = deps.cfg();
36
+ const actions = deps.core.resolveActionsForState(cfg, args.state);
37
+ if (!actions || actions.length === 0)
38
+ return { nonRouted: null, markHandoffReason: null };
39
+ const ctx = deps.core.deriveActionContext({
40
+ view: toView(args.entry, args.workspacePath),
41
+ extraEnv: undefined,
42
+ repoEnv: deps.readEnv('SYMPHONY_REPO'),
43
+ repoDefault: cfg.workspace.github_repo,
44
+ baseBranchDefault: cfg.workspace.base_branch,
45
+ });
46
+ const planned = deps.core.planActions(actions, ctx, {
47
+ workspacePath: args.workspacePath,
48
+ defaultCommandTimeoutMs: deps.defaultCommandTimeoutMs ?? DEFAULT_COMMAND_TIMEOUT_MS,
49
+ });
50
+ const result = await runPlanned(deps, planned, args, args.workspacePath);
51
+ // Rewrite the failure reason once into operator-actionable text (a
52
+ // workflow-scope push decline → "manual SSH push required"; issue 235).
53
+ const reason = result.reason !== null ? deps.core.describeHandoffFailure(result.reason) : null;
54
+ // The route is a clean handoff to a holding state: MOVE the issue out of the
55
+ // terminal action state (so the stranded handoff is operator-visible, not a
56
+ // silent terminal-Done) and RETAIN its workspace so the unpushed commit
57
+ // survives. A bare abort surfaces a non-routed failure to the caller instead.
58
+ if (result.route_to !== null) {
59
+ const routed = await routeOutOfState(deps, args, result.route_to, reason ?? '');
60
+ // The reroute MOVE itself failed (tracker broken): the issue is still stranded
61
+ // in the terminal state, so a clean exit would recreate the silent terminal-Done
62
+ // this issue closes. Surface the failed reroute as a non-routed attempt failure
63
+ // (worker exits ABNORMAL) while still retaining the workspace (issue 235).
64
+ if (routed.error !== null) {
65
+ const detail = reason ? ` (handoff: ${reason})` : '';
66
+ return { nonRouted: `reroute to ${result.route_to} failed: ${routed.error}${detail}`, markHandoffReason: reason };
67
+ }
68
+ return { nonRouted: null, markHandoffReason: reason };
69
+ }
70
+ if (result.ok)
71
+ return { nonRouted: null, markHandoffReason: null };
72
+ return { nonRouted: reason, markHandoffReason: reason };
73
+ }
74
+ return { runStateActions };
75
+ }
76
+ /**
77
+ * Move the issue out of its terminal action state into the routed holding state and
78
+ * record the rerouted transition on the live entry (issue 235). The agent already
79
+ * moved the file INTO the terminal state via `symphony.transition`; this re-moves it
80
+ * to the holding state with the failure reason appended as notes, so a failed Done
81
+ * handoff parks somewhere the operator sees it. Returns the move error when the
82
+ * tracker move itself FAILED (the issue is still stranded in the terminal state) so
83
+ * the caller can surface it as a non-routed attempt failure instead of exiting clean
84
+ * into a silent terminal-Done; `last_transition` is recorded as rerouted ONLY when
85
+ * the move actually landed (otherwise it would lie about where the issue lives).
86
+ */
87
+ async function routeOutOfState(deps, args, toState, reason) {
88
+ const actor = args.entry.resolved_actor || null;
89
+ const move = {
90
+ family: 'tracker',
91
+ kind: 'move_state',
92
+ issueId: args.entry.issue_id,
93
+ toState,
94
+ fromRoot: args.entry.tracker_root_at_dispatch ?? null,
95
+ fromState: args.state,
96
+ notes: reason,
97
+ actor,
98
+ };
99
+ const r = await deps.interpreter.execute(move).catch((err) => ({ ok: false, error: err.message }));
100
+ const moved = 'kind' in r && r.kind === 'move_state';
101
+ deps.runlog.system(args.entry.issue_id, 'state_actions_routed', {
102
+ state: args.state,
103
+ route_to: toState,
104
+ reason,
105
+ moved,
106
+ });
107
+ if (!moved) {
108
+ const error = 'ok' in r && r.ok === false ? r.error : 'unexpected move result';
109
+ deps.log.withIssue(args.entry.issue_id).emit('error', 'handoff reroute move failed', { route_to: toState, error });
110
+ return { error };
111
+ }
112
+ args.entry.last_transition = {
113
+ from_state: args.state,
114
+ to_state: toState,
115
+ notes: reason,
116
+ actor,
117
+ terminal: false,
118
+ rerouted: true,
119
+ };
120
+ return { error: null };
121
+ }
122
+ /** Drive the run-fold loop over the planned actions; returns the aggregated run. */
123
+ async function runPlanned(deps, planned, args, workspacePath) {
124
+ let ledger = [];
125
+ let routeTo = null;
126
+ let routeReason = null;
127
+ let abortReason = null;
128
+ for (const action of planned) {
129
+ const step = await runOneAction(deps, action, args, workspacePath, ledger);
130
+ ledger = step.ledger;
131
+ await drainEffects(deps, step.effects);
132
+ if (step.decision.kind === 'route') {
133
+ routeTo = step.decision.routeTo;
134
+ // Capture the route's own reason; summarizeRun only carries the abort reason,
135
+ // so without this the routed-handoff notes (and the holding-state move) would
136
+ // be empty (issue 235).
137
+ routeReason = step.decision.reason;
138
+ abortReason = null;
139
+ break;
140
+ }
141
+ if (step.decision.kind === 'abort') {
142
+ abortReason = step.decision.reason;
143
+ break;
144
+ }
145
+ // 'done' / 'retry-exhausted-into-done' — advance to the next action.
146
+ }
147
+ const run = deps.core.summarizeRun({ ledger, routeTo, abortReason });
148
+ return { ok: run.ok, reason: run.reason ?? routeReason, route_to: run.route_to };
149
+ }
150
+ /** Run one planned action: predicate → effects (with retry) → fold. */
151
+ async function runOneAction(deps, action, args, workspacePath, ledger) {
152
+ const nowIso = deps.clock.iso();
153
+ if (action.kind === 'render_failed') {
154
+ return deps.core.foldRenderFailed({ action: action.snapshotKey, error: action.error.message, ledger, nowIso });
155
+ }
156
+ let next = deps.core.beginAction(ledger, { resource: 'actions', action: action.snapshotKey, nowIso });
157
+ // ── predicate (`if:`) ───────────────────────────────────────────────────────
158
+ const pred = await resolvePredicate(deps, action);
159
+ if (pred.kind === 'error') {
160
+ return deps.core.foldPredicateError({ action: action.snapshotKey, error: pred.error, ledger: next, nowIso });
161
+ }
162
+ if (!pred.value) {
163
+ return deps.core.foldSkipped({ action: action.snapshotKey, ledger: next, nowIso });
164
+ }
165
+ // ── run the effect sequence, with retry per the action's policy ─────────────
166
+ let attempt = 0;
167
+ for (;;) {
168
+ const outcome = await applyAction(deps, action, args, workspacePath);
169
+ const fold = deps.core.foldActionOutcome({
170
+ action: action.snapshotKey,
171
+ outcome,
172
+ policy: action.policy,
173
+ attempt,
174
+ ledger: next,
175
+ nowIso: deps.clock.iso(),
176
+ });
177
+ next = fold.ledger;
178
+ if (fold.decision.kind !== 'retry')
179
+ return { ...fold, ledger: next };
180
+ // retry: the fold already emitted the warn + timer.sleep; drain them (the
181
+ // sleep is honoured through the interpreter's timer port), then re-apply.
182
+ await drainEffects(deps, fold.effects);
183
+ attempt = fold.decision.attempt;
184
+ }
185
+ }
186
+ /** Resolve the planned `if:` predicate (pure value, or run the probe effect). */
187
+ async function resolvePredicate(deps, action) {
188
+ const p = action.predicate;
189
+ if (p.kind === 'resolved')
190
+ return { kind: 'value', value: p.value };
191
+ if (p.kind === 'error')
192
+ return { kind: 'error', error: p.error.message };
193
+ const r = await deps.interpreter.execute(p.effect);
194
+ return { kind: 'value', value: deps.core.foldPredicateProbe(r) };
195
+ }
196
+ /**
197
+ * Apply one action's effect sequence and reduce it to an ActionOutcome. run_in_vm
198
+ * is the special case (exec on the live VM); every other kind runs its git/gh/
199
+ * tracker effects through the central interpreter and a non-OK result is the
200
+ * failure reason. push_branch additionally runs its NFF force-with-lease fallback
201
+ * when the primary push rejects non-fast-forward.
202
+ */
203
+ async function applyAction(deps, action, args, workspacePath) {
204
+ if (action.actionKind === 'run_in_vm')
205
+ return applyRunInVm(deps, action, args, workspacePath);
206
+ const isPush = action.actionKind === 'push_branch';
207
+ const primary = await runEffectSequence(deps, action.effects, isPush);
208
+ if (primary.kind === 'fail')
209
+ return { ok: false, reason: primary.reason, route_to: null };
210
+ // push_branch NFF recovery: re-run the fetch → rev-parse → force-with-lease
211
+ // sub-sequence the planner emitted, binding the resolved remote SHA into the
212
+ // force-push's expectedRemoteSha placeholder. The original NFF push reason rides
213
+ // along so a failed recovery surfaces it instead of its own masking error (227).
214
+ if (primary.nonFastForward && isPush && action.nffFallback) {
215
+ return runNffFallback(deps, action.nffFallback, primary.pushReason);
216
+ }
217
+ return { ok: true, reason: null, route_to: null };
218
+ }
219
+ /**
220
+ * Run a git/gh/tracker effect sequence through the interpreter, stopping on the
221
+ * first failure — except a non-fast-forward push under `pushTolerant`, which is
222
+ * recovered by the caller's NFF fallback rather than failing here.
223
+ */
224
+ async function runEffectSequence(deps, effects, pushTolerant) {
225
+ let nonFastForward = false;
226
+ let pushReason = null;
227
+ for (const effect of effects) {
228
+ const r = await deps.interpreter.execute(effect);
229
+ if ('kind' in r && r.kind === 'git_status' && r.nonFastForward) {
230
+ nonFastForward = true;
231
+ // Capture the real push stderr so the NFF fallback can surface it if its own
232
+ // fetch→force recovery later fails — rather than masking it (227).
233
+ pushReason = runResultReason(r.result, 'non-fast-forward push rejected');
234
+ }
235
+ const reason = failureReason(r);
236
+ if (reason !== null && !(nonFastForward && pushTolerant))
237
+ return { kind: 'fail', reason };
238
+ }
239
+ return { kind: 'ok', nonFastForward, pushReason };
240
+ }
241
+ /**
242
+ * push_branch non-fast-forward recovery: fetch → rev-parse → force-with-lease.
243
+ * If the recovery itself fails (e.g. the fetch can't find the remote ref because
244
+ * the push never landed), surface the ORIGINAL push reason — the message the
245
+ * operator must act on — instead of masking it with the recovery's own error (227).
246
+ */
247
+ async function runNffFallback(deps, fallback, originalPushReason) {
248
+ let expectedSha = '';
249
+ for (const effect of fallback) {
250
+ const bound = bindExpectedSha(effect, expectedSha);
251
+ const r = await deps.interpreter.execute(bound);
252
+ if ('kind' in r && r.kind === 'rev_parse')
253
+ expectedSha = r.sha ?? '';
254
+ const reason = failureReason(r);
255
+ if (reason !== null)
256
+ return { ok: false, reason: originalPushReason ?? reason, route_to: null };
257
+ }
258
+ return { ok: true, reason: null, route_to: null };
259
+ }
260
+ /** Substitute the rev-parse SHA into a push_force_with_lease effect placeholder. */
261
+ function bindExpectedSha(effect, sha) {
262
+ if (effect.family === 'git' && effect.kind === 'push_force_with_lease') {
263
+ return { ...effect, expectedRemoteSha: sha };
264
+ }
265
+ return effect;
266
+ }
267
+ /**
268
+ * Run a `run_in_vm` action: exec the rendered command on the live per-issue VM
269
+ * (phase 8 keeps it alive) and map the exit code to the ActionOutcome. Uncached —
270
+ * every dispatch re-execs.
271
+ */
272
+ async function applyRunInVm(deps, action, args, workspacePath) {
273
+ const a = action.rendered;
274
+ const env = a.env ?? {};
275
+ if (!args.vm)
276
+ return { ok: false, reason: `run_in_vm "${a.name}" has no live VM`, route_to: null };
277
+ const timeoutMs = a.timeout !== undefined ? a.timeout * 1000 : deps.defaultCommandTimeoutMs ?? DEFAULT_COMMAND_TIMEOUT_MS;
278
+ const exec = await execOnVm(args.vm, { name: a.name, cmd: a.cmd, env, workdir: workspacePath, timeoutMs }, deps, args.entry);
279
+ if (exec.exit_code === 0)
280
+ return { ok: true, reason: null, route_to: null };
281
+ return { ok: false, reason: `run_in_vm "${a.name}" exited ${exec.exit_code ?? 'signal'}`, route_to: null };
282
+ }
283
+ /** Exec one run_in_vm command on the live VM, capturing bounded stdout/stderr. */
284
+ function execOnVm(vm, cmd, deps, entry) {
285
+ return new Promise((resolve) => {
286
+ let stream;
287
+ try {
288
+ stream = vm.exec({ command: cmd.cmd, workdir: cmd.workdir, env: cmd.env, timeoutMs: cmd.timeoutMs });
289
+ }
290
+ catch (err) {
291
+ resolve({ exit_code: null, stdout: '', stderr: err.message });
292
+ return;
293
+ }
294
+ try {
295
+ stream.stdin.end();
296
+ }
297
+ catch { /* idempotent */ }
298
+ // Accumulate stdout/stderr uniformly (capped) + mirror each chunk to the run log.
299
+ const acc = { stdout: '', stderr: '' };
300
+ for (const ch of ['stdout', 'stderr']) {
301
+ stream[ch].setEncoding('utf8');
302
+ stream[ch].on('data', (chunk) => {
303
+ acc[ch] = capture(acc[ch], chunk);
304
+ deps.runlog.record(entry.issue_id, { channel: 'hook', hook: `run_in_vm:${cmd.name}`, stream: ch, text: chunk });
305
+ });
306
+ }
307
+ const timer = setTimeout(() => { try {
308
+ stream.kill();
309
+ }
310
+ catch { /* idempotent */ } }, cmd.timeoutMs);
311
+ stream.exit.then(({ code }) => { clearTimeout(timer); resolve({ exit_code: code, ...acc }); }, (err) => { clearTimeout(timer); resolve({ exit_code: null, stdout: acc.stdout, stderr: acc.stderr || err.message }); });
312
+ });
313
+ }
314
+ function capture(acc, chunk) {
315
+ const next = acc + chunk;
316
+ return next.length > STDIO_CAPTURE_LIMIT ? next.slice(0, STDIO_CAPTURE_LIMIT) : next;
317
+ }
318
+ /** Drain a fold step's emitted effects (warn logs + timer.sleep) through the interpreter. */
319
+ async function drainEffects(deps, effects) {
320
+ for (const effect of effects)
321
+ await deps.interpreter.execute(effect).catch(() => undefined);
322
+ }
323
+ /** A non-OK EffectResult → its failure reason; null when the effect succeeded. */
324
+ function failureReason(r) {
325
+ if ('ok' in r && r.ok === false)
326
+ return r.error;
327
+ if (!('kind' in r))
328
+ return null;
329
+ if (r.kind === 'run_result' && r.result.exit_code !== 0)
330
+ return runResultReason(r.result, `exit ${r.result.exit_code}`);
331
+ if (r.kind === 'git_status' && !r.clean && !r.nonFastForward)
332
+ return runResultReason(r.result, 'git command failed');
333
+ return null;
334
+ }
335
+ /** Pick the best human-facing reason off a captured RunResultData. */
336
+ function runResultReason(result, fallback) {
337
+ return result.stderr.trim() || result.stdout.trim() || fallback;
338
+ }
339
+ /** Project a live RunningEntry into the read-only view the core context wants.
340
+ * workspace_path is overridden with the live path; active_tool_call_count is
341
+ * derived from the live Set; every other field is a verbatim copy. */
342
+ function toView(entry, workspacePath) {
343
+ return {
344
+ issue_id: entry.issue_id, identifier: entry.identifier, issue: entry.issue, session_id: entry.session_id,
345
+ workspace_path: workspacePath, started_at: entry.started_at, turn_count: entry.turn_count,
346
+ retry_attempt: entry.retry_attempt, input_tokens: entry.input_tokens, output_tokens: entry.output_tokens,
347
+ total_tokens: entry.total_tokens, last_event: entry.last_event, last_event_at: entry.last_event_at,
348
+ last_message: entry.last_message, recent_events: entry.recent_events, last_error: entry.last_error,
349
+ transitioned: entry.transitioned, steering_requested: entry.steering_requested,
350
+ steering_question: entry.steering_question, steering_context: entry.steering_context,
351
+ active_tool_call_count: entry.active_tool_calls.size, resolved_actor: entry.resolved_actor,
352
+ base_branch_at_dispatch: entry.base_branch_at_dispatch, github_repo_at_dispatch: entry.github_repo_at_dispatch,
353
+ tracker_root_at_dispatch: entry.tracker_root_at_dispatch, cleanup_workspace_on_exit: entry.cleanup_workspace_on_exit,
354
+ };
355
+ }
356
+ //# sourceMappingURL=actions-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions-runner.js","sourceRoot":"","sources":["../../../src/shell/actions-runner.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,qEAAqE;AACrE,kFAAkF;AAClF,kFAAkF;AAClF,mFAAmF;AACnF,oFAAoF;AACpF,EAAE;AACF,mFAAmF;AACnF,oFAAoF;AACpF,mFAAmF;AACnF,gEAAgE;AAChE,EAAE;AACF,gFAAgF;AAChF,oFAAoF;AACpF,kEAAkE;AAiBlE,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAuB;IACzD,KAAK,UAAU,eAAe,CAAC,IAK9B;QACC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAClE,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;QAE1F,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC;YACxC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC;YAC5C,QAAQ,EAAE,SAAS;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;YACtC,WAAW,EAAE,GAAG,CAAC,SAAS,CAAC,WAAW;YACtC,iBAAiB,EAAE,GAAG,CAAC,SA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,KAAK,CAAC,uBAAuB,EAAE,uBAAuB,EAAE,KAAK,CAAC,uBAAuB;QAC9G,wBAAwB,EAAE,KAAK,CAAC,wBAAwB,EAAE,yBAAyB,EAAE,KAAK,CAAC,yBAAyB;KACrH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,45 @@
1
+ // FCIS rewrite — the AdapterRegistry port (shell adapter).
2
+ //
3
+ // Ports the per-adapter launch PROFILES from the reference `src/agent/adapters.ts`
4
+ // (`ADAPTERS` / `profileFor`). A profile is data + small pure injection closures
5
+ // (no IO): the ACP launch argv plus the model/effort injection channels the pure
6
+ // core `applyRuntimeInjections` fold consumes. Credentials are NOT here (the guest
7
+ // holds only placeholders Gondolin substitutes at egress).
8
+ //
9
+ // Shell rule: imports from src/types/** ONLY (these are pure data profiles, but the
10
+ // registry is a shell value so it can live here without importing core).
11
+ const CLAUDE_SETTINGS_GUEST_PATH = '/root/.claude/settings.json';
12
+ /** The two known adapter profiles (faithful to the reference ADAPTERS record). */
13
+ const ADAPTERS = {
14
+ claude: {
15
+ id: 'claude',
16
+ binary: ['claude-agent-acp'],
17
+ // claude-agent-acp reads ANTHROPIC_MODEL on startup.
18
+ modelInjection: (model) => ({ env: { ANTHROPIC_MODEL: model } }),
19
+ // effortLevel rides a staged settings.json copied to /root/.claude/settings.json.
20
+ effortInjection: (effort) => ({
21
+ stagedFiles: [
22
+ {
23
+ stagedName: 'claude-settings.json',
24
+ content: JSON.stringify({ effortLevel: effort }),
25
+ guestPath: CLAUDE_SETTINGS_GUEST_PATH,
26
+ },
27
+ ],
28
+ }),
29
+ },
30
+ codex: {
31
+ id: 'codex',
32
+ binary: ['codex-acp'],
33
+ // codex-acp config override: `-c model="<model>"` (TOML-quoted).
34
+ modelInjection: (model) => ({ extraArgs: ['-c', `model=${JSON.stringify(model)}`] }),
35
+ },
36
+ };
37
+ const KNOWN = new Set(Object.keys(ADAPTERS));
38
+ /** Build the AdapterRegistry port the runner-loop's injection phase consumes. */
39
+ export function createAdapterRegistry() {
40
+ return {
41
+ isKnown: (id) => KNOWN.has(id),
42
+ profile: (id) => ADAPTERS[id],
43
+ };
44
+ }
45
+ //# sourceMappingURL=adapter-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-registry.js","sourceRoot":"","sources":["../../../../src/shell/adapter/adapter-registry.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,EAAE;AACF,mFAAmF;AACnF,iFAAiF;AACjF,iFAAiF;AACjF,mFAAmF;AACnF,2DAA2D;AAC3D,EAAE;AACF,oFAAoF;AACpF,yEAAyE;AAKzE,MAAM,0BAA0B,GAAG,6BAA6B,CAAC;AAEjE,kFAAkF;AAClF,MAAM,QAAQ,GAAyC;IACrD,MAAM,EAAE;QACN,EAAE,EAAE,QAAQ;QACZ,MAAM,EAAE,CAAC,kBAAkB,CAAC;QAC5B,qDAAqD;QACrD,cAAc,EAAE,CAAC,KAAK,EAAkB,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,CAAC;QAChF,kFAAkF;QAClF,eAAe,EAAE,CAAC,MAAM,EAAmB,EAAE,CAAC,CAAC;YAC7C,WAAW,EAAE;gBACX;oBACE,UAAU,EAAE,sBAAsB;oBAClC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;oBAChD,SAAS,EAAE,0BAA0B;iBACtC;aACF;SACF,CAAC;KACH;IACD,KAAK,EAAE;QACL,EAAE,EAAE,OAAO;QACX,MAAM,EAAE,CAAC,WAAW,CAAC;QACrB,iEAAiE;QACjE,cAAc,EAAE,CAAC,KAAK,EAAkB,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;KACrG;CACF,CAAC;AAEF,MAAM,KAAK,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAElE,iFAAiF;AACjF,MAAM,UAAU,qBAAqB;IACnC,OAAO;QACL,OAAO,EAAE,CAAC,EAAU,EAAsB,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1D,OAAO,EAAE,CAAC,EAAgB,EAAkB,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;KAC5D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,96 @@
1
+ // FCIS rewrite — deterministic-seam adapters (kind: adapter).
2
+ //
3
+ // The four SYNCHRONOUS seams the functional core consumes as injected VALUES
4
+ // (see src/types/ports.ts §"Deterministic seams"): Clock, RandomSource,
5
+ // CryptoEnv, MemProbe. Cores stay pure + synchronous by reading these through
6
+ // the port instead of touching `Date.now()` / `node:crypto` / `/proc/meminfo`
7
+ // directly; tests pin a deterministic stub in the same shape.
8
+ //
9
+ // Ported faithfully from the original src/util/clock.ts, src/util/crypto.ts,
10
+ // and src/memory.ts. Behaviour preserved exactly:
11
+ // - Clock.now = Date.now(); Clock.iso = new Date(now).toISOString()
12
+ // - RandomSource.newToken = randomBytes(24).toString('base64url')
13
+ // - CryptoEnv.constantTimeEqual = UTF-8 byte-length guard then timingSafeEqual
14
+ // - MemProbe.read = MemAvailable (MiB) parsed from /proc/meminfo, else null
15
+ import { randomBytes, timingSafeEqual } from 'node:crypto';
16
+ import { Buffer } from 'node:buffer';
17
+ import { readFileSync } from 'node:fs';
18
+ // ─── Clock ────────────────────────────────────────────────────────────────
19
+ /**
20
+ * Production clock: real wall clock. `iso()` formats the SAME reading via
21
+ * `new Date(now).toISOString()` (mirrors the original `isoFromClock`).
22
+ */
23
+ export function systemClock() {
24
+ return {
25
+ now: () => Date.now(),
26
+ iso: () => new Date(Date.now()).toISOString(),
27
+ };
28
+ }
29
+ // ─── RandomSource ───────────────────────────────────────────────────────────
30
+ /**
31
+ * Per-dispatch bearer-token mint: 24 random bytes, base64url-encoded — the
32
+ * exact token shape the MCP registry / per-dispatch auth depends on.
33
+ */
34
+ export function tokenRandomSource() {
35
+ return {
36
+ newToken: () => randomBytes(24).toString('base64url'),
37
+ };
38
+ }
39
+ // ─── CryptoEnv ────────────────────────────────────────────────────────────
40
+ /**
41
+ * Production crypto seam.
42
+ *
43
+ * `constantTimeEqual` compares BYTE lengths after UTF-8 encoding, NOT JS
44
+ * string `.length` (UTF-16 code units). An attacker-supplied non-ASCII token
45
+ * can match the real token's code-unit count while encoding to a different
46
+ * byte length; handing those buffers to `timingSafeEqual` would throw
47
+ * ("Input buffers must have the same byte length") and surface as an HTTP 500
48
+ * instead of a clean wrong-token rejection. So we reject mismatched byte
49
+ * lengths up front and only equal-length pairs reach `timingSafeEqual`, whose
50
+ * per-byte timing therefore can't leak the matching prefix.
51
+ */
52
+ export function nodeCryptoEnv() {
53
+ return {
54
+ constantTimeEqual: (a, b) => {
55
+ const aBuf = Buffer.from(a, 'utf8');
56
+ const bBuf = Buffer.from(b, 'utf8');
57
+ if (aBuf.length !== bBuf.length)
58
+ return false;
59
+ return timingSafeEqual(aBuf, bBuf);
60
+ },
61
+ };
62
+ }
63
+ // ─── MemProbe ─────────────────────────────────────────────────────────────
64
+ const PROC_MEMINFO = '/proc/meminfo';
65
+ /**
66
+ * Production memory probe — synchronously reads `/proc/meminfo` (a kernel
67
+ * virtual file: no disk I/O, microsecond-cheap, run once per tick). On any
68
+ * read or parse failure `read()` returns null so the orchestrator falls back
69
+ * to the static admission cap rather than dropping to zero on a transient
70
+ * error or on a non-Linux host (e.g. `npm test` on macOS).
71
+ *
72
+ * The `MemAvailable` parse is the PURE core decision
73
+ * (`core/schedule/admission.ts:parseMemAvailableMib`), injected by the
74
+ * composition root so this adapter only performs the `/proc` read; the shell
75
+ * never re-implements the parse.
76
+ *
77
+ * The original `MemorySnapshot.supported` flag is intentionally dropped: the
78
+ * rewrite's `MemProbe.read(): number | null` collapses
79
+ * "unsupported"/"unparseable" into the same null the admission decider
80
+ * already handles uniformly.
81
+ */
82
+ export function nodeMemProbe(parseMemAvailableMib) {
83
+ return {
84
+ read: () => {
85
+ let body;
86
+ try {
87
+ body = readFileSync(PROC_MEMINFO, 'utf8');
88
+ }
89
+ catch {
90
+ return null;
91
+ }
92
+ return parseMemAvailableMib(body);
93
+ },
94
+ };
95
+ }
96
+ //# sourceMappingURL=clock-random.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clock-random.js","sourceRoot":"","sources":["../../../../src/shell/adapter/clock-random.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,6EAA6E;AAC7E,wEAAwE;AACxE,8EAA8E;AAC9E,8EAA8E;AAC9E,8DAA8D;AAC9D,EAAE;AACF,6EAA6E;AAC7E,kDAAkD;AAClD,uEAAuE;AACvE,oEAAoE;AACpE,iFAAiF;AACjF,8EAA8E;AAE9E,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAWvC,6EAA6E;AAE7E;;;GAGG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;QACrB,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE;KAC9C,CAAC;AACJ,CAAC;AAED,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,QAAQ,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;KACtD,CAAC;AACJ,CAAC;AAED,6EAA6E;AAE7E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO;QACL,iBAAiB,EAAE,CAAC,CAAC,EAAE,CAAC,EAA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