@loucompanion/forge-bridge 0.1.3-dev.f66395c3ac21 → 0.1.4-dev.0098fdb4e213

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 (381) hide show
  1. package/README.md +306 -1
  2. package/dist/bridge/bridge-chat-provider-command.d.ts +19 -0
  3. package/dist/bridge/bridge-chat-provider-command.js +132 -0
  4. package/dist/bridge/bridge-chat.types.d.ts +121 -0
  5. package/dist/bridge/bridge-chat.types.js +416 -0
  6. package/dist/bridge/bridge-state-file.d.ts +161 -0
  7. package/dist/bridge/bridge-state-file.js +376 -0
  8. package/dist/bridge/bridge-state-io.d.ts +11 -0
  9. package/dist/bridge/bridge-state-io.js +50 -0
  10. package/dist/bridge/bridge-state-lock.d.ts +11 -0
  11. package/dist/bridge/bridge-state-lock.js +102 -0
  12. package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
  13. package/dist/bridge/bridge-state-unpublished.js +111 -0
  14. package/dist/bridge/bridge.base.d.ts +18 -1
  15. package/dist/bridge/bridge.service.d.ts +216 -4
  16. package/dist/bridge/bridge.service.js +2574 -90
  17. package/dist/bridge/bridge.types.d.ts +245 -2
  18. package/dist/bridge/dispatch-result-outbox.d.ts +35 -0
  19. package/dist/bridge/dispatch-result-outbox.js +87 -0
  20. package/dist/bridge/dispatch-result-worker.d.ts +2 -0
  21. package/dist/bridge/dispatch-result-worker.js +122 -0
  22. package/dist/bridge/in-flight-registry.d.ts +62 -0
  23. package/dist/bridge/in-flight-registry.js +207 -0
  24. package/dist/bridge/internals.d.ts +2 -0
  25. package/dist/bridge/internals.js +1 -0
  26. package/dist/bridge/local-yield-flag.d.ts +6 -0
  27. package/dist/bridge/local-yield-flag.js +34 -0
  28. package/dist/bridge/readiness-result-outbox.d.ts +25 -0
  29. package/dist/bridge/readiness-result-outbox.js +74 -0
  30. package/dist/bridge/readiness-result-worker.d.ts +2 -0
  31. package/dist/bridge/readiness-result-worker.js +121 -0
  32. package/dist/bridge/runner-host-capabilities.d.ts +20 -0
  33. package/dist/bridge/runner-host-capabilities.js +110 -0
  34. package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
  35. package/dist/bridge/sandbox-resource-accounting.js +150 -0
  36. package/dist/bridge/test-postgres-capability.d.ts +14 -0
  37. package/dist/bridge/test-postgres-capability.js +120 -0
  38. package/dist/cleanup/cleanup-wip.d.ts +12 -0
  39. package/dist/cleanup/cleanup-wip.js +66 -0
  40. package/dist/cleanup/cleanup.service.d.ts +33 -2
  41. package/dist/cleanup/cleanup.service.js +477 -3
  42. package/dist/cleanup/cleanup.types.d.ts +16 -0
  43. package/dist/cleanup/forge-owned-paths.d.ts +9 -0
  44. package/dist/cleanup/forge-owned-paths.js +53 -0
  45. package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
  46. package/dist/cleanup/host-runtime-ledger.js +130 -0
  47. package/dist/cleanup/index.d.ts +1 -1
  48. package/dist/cleanup/index.js +1 -1
  49. package/dist/cleanup/internals.d.ts +2 -2
  50. package/dist/cleanup/internals.js +1 -1
  51. package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
  52. package/dist/cleanup/managed-branch-sweep.js +111 -0
  53. package/dist/cli/cli.help.d.ts +2 -0
  54. package/dist/cli/cli.help.js +279 -0
  55. package/dist/cli/cli.service.d.ts +69 -12
  56. package/dist/cli/cli.service.js +557 -382
  57. package/dist/cli/idle-status.d.ts +84 -0
  58. package/dist/cli/idle-status.js +181 -0
  59. package/dist/cli/local-config.d.ts +13 -0
  60. package/dist/cli/local-config.js +82 -6
  61. package/dist/cli/provider-cli-detection.d.ts +10 -0
  62. package/dist/cli/provider-cli-detection.js +160 -0
  63. package/dist/runtime/aspnet-runtime-prebuild.d.ts +41 -0
  64. package/dist/runtime/aspnet-runtime-prebuild.js +474 -0
  65. package/dist/runtime/attempt-database-broker.d.ts +89 -0
  66. package/dist/runtime/attempt-database-broker.js +390 -0
  67. package/dist/runtime/attempt-node-runtime-launcher.d.ts +18 -0
  68. package/dist/runtime/attempt-node-runtime-launcher.js +140 -0
  69. package/dist/runtime/attempt-path-operation.d.ts +21 -0
  70. package/dist/runtime/attempt-path-operation.js +94 -0
  71. package/dist/runtime/attempt-private-directory.d.ts +6 -0
  72. package/dist/runtime/attempt-private-directory.js +54 -0
  73. package/dist/runtime/attempt-process-supervisor-registry.d.ts +20 -0
  74. package/dist/runtime/attempt-process-supervisor-registry.js +64 -0
  75. package/dist/runtime/attempt-process-supervisor.d.ts +121 -0
  76. package/dist/runtime/attempt-process-supervisor.js +471 -0
  77. package/dist/runtime/canonical-source-file.d.ts +3 -0
  78. package/dist/runtime/canonical-source-file.js +54 -0
  79. package/dist/runtime/docker-engine-probe.d.ts +95 -0
  80. package/dist/runtime/docker-engine-probe.js +340 -0
  81. package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
  82. package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
  83. package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
  84. package/dist/runtime/ephemeral-test-postgres.js +303 -0
  85. package/dist/runtime/generated-output-reset.d.ts +20 -0
  86. package/dist/runtime/generated-output-reset.js +157 -0
  87. package/dist/runtime/host-database-capability-boundary.d.ts +16 -0
  88. package/dist/runtime/host-database-capability-boundary.js +63 -0
  89. package/dist/runtime/host-diagnostics.d.ts +11 -0
  90. package/dist/runtime/host-diagnostics.js +192 -0
  91. package/dist/runtime/host-execution-root.d.ts +4 -0
  92. package/dist/runtime/host-execution-root.js +39 -0
  93. package/dist/runtime/host-facts.d.ts +36 -0
  94. package/dist/runtime/host-facts.js +95 -0
  95. package/dist/runtime/host-listener-inspector.d.ts +51 -0
  96. package/dist/runtime/host-listener-inspector.js +385 -0
  97. package/dist/runtime/host-load-admission.d.ts +67 -0
  98. package/dist/runtime/host-load-admission.js +99 -0
  99. package/dist/runtime/host-load-child-environment.d.ts +27 -0
  100. package/dist/runtime/host-load-child-environment.js +76 -0
  101. package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
  102. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  103. package/dist/runtime/host-load-governor-config.d.ts +52 -0
  104. package/dist/runtime/host-load-governor-config.js +83 -0
  105. package/dist/runtime/host-load-governor.d.ts +186 -0
  106. package/dist/runtime/host-load-governor.js +632 -0
  107. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  108. package/dist/runtime/host-load-ledger-lock.js +187 -0
  109. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  110. package/dist/runtime/host-load-runtime-settings.js +80 -0
  111. package/dist/runtime/host-load-sampler.d.ts +156 -0
  112. package/dist/runtime/host-load-sampler.js +298 -0
  113. package/dist/runtime/host-load-step-class.d.ts +70 -0
  114. package/dist/runtime/host-load-step-class.js +161 -0
  115. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  116. package/dist/runtime/host-load-step-reaper.js +95 -0
  117. package/dist/runtime/host-load-step-run.d.ts +73 -0
  118. package/dist/runtime/host-load-step-run.js +102 -0
  119. package/dist/runtime/host-load-test-slot.d.ts +43 -0
  120. package/dist/runtime/host-load-test-slot.js +81 -0
  121. package/dist/runtime/host-load-token-ledger.d.ts +200 -0
  122. package/dist/runtime/host-load-token-ledger.js +453 -0
  123. package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
  124. package/dist/runtime/host-load-windows-cpu.js +85 -0
  125. package/dist/runtime/host-port-broker.d.ts +76 -0
  126. package/dist/runtime/host-port-broker.js +333 -0
  127. package/dist/runtime/host-pressure-stall.d.ts +61 -0
  128. package/dist/runtime/host-pressure-stall.js +168 -0
  129. package/dist/runtime/host-runtime-contract.d.ts +74 -0
  130. package/dist/runtime/host-runtime-contract.js +846 -0
  131. package/dist/runtime/host-runtime-lease.d.ts +287 -0
  132. package/dist/runtime/host-runtime-lease.js +2763 -0
  133. package/dist/runtime/host-runtime-promotion.d.ts +55 -0
  134. package/dist/runtime/host-runtime-promotion.js +254 -0
  135. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  136. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  137. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  138. package/dist/runtime/host-runtime-requirements.js +117 -0
  139. package/dist/runtime/managed-command-teardown.d.ts +62 -0
  140. package/dist/runtime/managed-command-teardown.js +596 -0
  141. package/dist/runtime/memory-capacity.d.ts +70 -0
  142. package/dist/runtime/memory-capacity.js +123 -0
  143. package/dist/runtime/native-test-postgres-fallback.d.ts +69 -0
  144. package/dist/runtime/native-test-postgres-fallback.js +143 -0
  145. package/dist/runtime/node-host-runtime-adapter.d.ts +54 -0
  146. package/dist/runtime/node-host-runtime-adapter.js +286 -0
  147. package/dist/runtime/pinned-directory-process.d.ts +9 -0
  148. package/dist/runtime/pinned-directory-process.js +61 -0
  149. package/dist/runtime/pinned-source-directory.d.ts +17 -0
  150. package/dist/runtime/pinned-source-directory.js +94 -0
  151. package/dist/runtime/playwright-browser-cache.d.ts +39 -0
  152. package/dist/runtime/playwright-browser-cache.js +227 -0
  153. package/dist/runtime/playwright-host-runtime-adapter.d.ts +39 -0
  154. package/dist/runtime/playwright-host-runtime-adapter.js +274 -0
  155. package/dist/runtime/prepared-runtime-identity.d.ts +6 -0
  156. package/dist/runtime/prepared-runtime-identity.js +218 -0
  157. package/dist/runtime/prepared-runtime-readiness.d.ts +30 -0
  158. package/dist/runtime/prepared-runtime-readiness.js +285 -0
  159. package/dist/runtime/runner-settings.d.ts +104 -0
  160. package/dist/runtime/runner-settings.js +236 -0
  161. package/dist/runtime/runtime-isolation-lease.d.ts +67 -0
  162. package/dist/runtime/runtime-isolation-lease.js +161 -0
  163. package/dist/runtime/workspace-resource-estimator.d.ts +17 -0
  164. package/dist/runtime/workspace-resource-estimator.js +174 -0
  165. package/dist/sandbox/command-runner.d.ts +4 -0
  166. package/dist/sandbox/command-runner.js +47 -0
  167. package/dist/sandbox/contract.d.ts +5 -0
  168. package/dist/sandbox/contract.js +276 -0
  169. package/dist/sandbox/event-budget.d.ts +11 -0
  170. package/dist/sandbox/event-budget.js +27 -0
  171. package/dist/sandbox/host-capacity-broker.d.ts +115 -0
  172. package/dist/sandbox/host-capacity-broker.js +336 -0
  173. package/dist/sandbox/image-policy.d.ts +35 -0
  174. package/dist/sandbox/image-policy.js +247 -0
  175. package/dist/sandbox/index.d.ts +5 -0
  176. package/dist/sandbox/index.js +5 -0
  177. package/dist/sandbox/lease-watchdog.d.ts +18 -0
  178. package/dist/sandbox/lease-watchdog.js +67 -0
  179. package/dist/sandbox/managed-branch.d.ts +13 -0
  180. package/dist/sandbox/managed-branch.js +36 -0
  181. package/dist/sandbox/preflight.d.ts +84 -0
  182. package/dist/sandbox/preflight.js +521 -0
  183. package/dist/sandbox/process.d.ts +20 -0
  184. package/dist/sandbox/process.js +209 -0
  185. package/dist/sandbox/provider-auth/codex.d.ts +26 -0
  186. package/dist/sandbox/provider-auth/codex.js +212 -0
  187. package/dist/sandbox/repository-lock.d.ts +6 -0
  188. package/dist/sandbox/repository-lock.js +129 -0
  189. package/dist/sandbox/runtime.d.ts +311 -0
  190. package/dist/sandbox/runtime.js +2407 -0
  191. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  192. package/dist/sandbox/sandbox-cgroups.js +42 -0
  193. package/dist/sandbox/sandbox.types.d.ts +93 -0
  194. package/dist/sandbox/sandbox.types.js +1 -0
  195. package/dist/sandbox/smoke.d.ts +76 -0
  196. package/dist/sandbox/smoke.js +380 -0
  197. package/dist/sandbox/worker-supervisor.d.ts +13 -0
  198. package/dist/sandbox/worker-supervisor.js +36 -0
  199. package/dist/sandbox/worker.d.ts +1 -0
  200. package/dist/sandbox/worker.js +225 -0
  201. package/dist/sandbox/workspace.service.d.ts +13 -0
  202. package/dist/sandbox/workspace.service.js +74 -0
  203. package/dist/session/architect-waits.d.ts +2 -0
  204. package/dist/session/architect-waits.js +138 -0
  205. package/dist/session/managed-attempt-tools.d.ts +48 -0
  206. package/dist/session/managed-attempt-tools.js +1299 -0
  207. package/dist/session/managed-build-coordinator.d.ts +5 -0
  208. package/dist/session/managed-build-coordinator.js +109 -0
  209. package/dist/session/managed-build-receipt.d.ts +26 -0
  210. package/dist/session/managed-build-receipt.js +342 -0
  211. package/dist/session/managed-command-host-load.d.ts +47 -0
  212. package/dist/session/managed-command-host-load.js +83 -0
  213. package/dist/session/managed-verification-timeouts.d.ts +8 -0
  214. package/dist/session/managed-verification-timeouts.js +17 -0
  215. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  216. package/dist/session/mcp-argument-coercion.js +121 -0
  217. package/dist/session/phase-completion.artifacts.d.ts +34 -0
  218. package/dist/session/phase-completion.artifacts.js +903 -0
  219. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  220. package/dist/session/phase-completion.command-validation.js +77 -0
  221. package/dist/session/phase-completion.d.ts +65 -42
  222. package/dist/session/phase-completion.helpers.d.ts +117 -0
  223. package/dist/session/phase-completion.helpers.js +708 -0
  224. package/dist/session/phase-completion.js +130 -3007
  225. package/dist/session/phase-completion.mcp-args.d.ts +9 -0
  226. package/dist/session/phase-completion.mcp-args.js +156 -0
  227. package/dist/session/phase-completion.prompts.d.ts +14 -0
  228. package/dist/session/phase-completion.prompts.js +238 -0
  229. package/dist/session/phase-completion.runtime.d.ts +43 -0
  230. package/dist/session/phase-completion.runtime.js +721 -0
  231. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  232. package/dist/session/phase-completion.schema-parts.js +188 -0
  233. package/dist/session/phase-completion.schemas.d.ts +3 -0
  234. package/dist/session/phase-completion.schemas.js +836 -0
  235. package/dist/session/phase-completion.validation.d.ts +37 -0
  236. package/dist/session/phase-completion.validation.js +874 -0
  237. package/dist/session/pre-publication-host-load.d.ts +27 -0
  238. package/dist/session/pre-publication-host-load.js +111 -0
  239. package/dist/session/pre-publication-native-postgres.d.ts +30 -0
  240. package/dist/session/pre-publication-native-postgres.js +111 -0
  241. package/dist/session/pre-publication-pass.d.ts +61 -0
  242. package/dist/session/pre-publication-pass.js +148 -0
  243. package/dist/session/pre-publication-process.d.ts +23 -0
  244. package/dist/session/pre-publication-process.js +109 -0
  245. package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
  246. package/dist/session/pre-publication-skipped-tests.js +109 -0
  247. package/dist/session/pre-publication-step-execution.d.ts +12 -0
  248. package/dist/session/pre-publication-step-execution.js +50 -0
  249. package/dist/session/pre-publication-validation.d.ts +91 -0
  250. package/dist/session/pre-publication-validation.js +670 -0
  251. package/dist/session/provider-cli/bridge-cli.conformance-fixtures.d.ts +72 -0
  252. package/dist/session/provider-cli/bridge-cli.conformance-fixtures.js +462 -0
  253. package/dist/session/provider-cli/ci-repair-readiness.d.ts +16 -0
  254. package/dist/session/provider-cli/ci-repair-readiness.js +110 -0
  255. package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
  256. package/dist/session/provider-cli/claude-background-work.js +181 -0
  257. package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
  258. package/dist/session/provider-cli/host-build-lock.js +30 -0
  259. package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
  260. package/dist/session/provider-cli/pre-publication-repair.js +276 -0
  261. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +96 -0
  262. package/dist/session/provider-cli/provider-cli.artifacts.js +818 -0
  263. package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
  264. package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
  265. package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
  266. package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
  267. package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
  268. package/dist/session/provider-cli/provider-cli.deterministic-payloads.d.ts +12 -0
  269. package/dist/session/provider-cli/provider-cli.deterministic-payloads.js +279 -0
  270. package/dist/session/provider-cli/provider-cli.deterministic.d.ts +14 -0
  271. package/dist/session/provider-cli/provider-cli.deterministic.js +407 -0
  272. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
  273. package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
  274. package/dist/session/provider-cli/provider-cli.process.d.ts +114 -0
  275. package/dist/session/provider-cli/provider-cli.process.js +757 -0
  276. package/dist/session/provider-cli/provider-cli.prompts.d.ts +62 -0
  277. package/dist/session/provider-cli/provider-cli.prompts.js +770 -0
  278. package/dist/session/provider-cli/provider-cli.qa-sidecars.d.ts +11 -0
  279. package/dist/session/provider-cli/provider-cli.qa-sidecars.js +66 -0
  280. package/dist/session/provider-cli/provider-cli.repair-epoch.d.ts +6 -0
  281. package/dist/session/provider-cli/provider-cli.repair-epoch.js +11 -0
  282. package/dist/session/provider-cli/provider-cli.runtime.d.ts +30 -0
  283. package/dist/session/provider-cli/provider-cli.runtime.js +120 -0
  284. package/dist/session/provider-cli/provider-cli.service.d.ts +53 -53
  285. package/dist/session/provider-cli/provider-cli.service.js +1299 -2523
  286. package/dist/session/provider-cli/provider-cli.types.d.ts +38 -0
  287. package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
  288. package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
  289. package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
  290. package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
  291. package/dist/session/provider-cli/provider-in-flight-work.d.ts +10 -0
  292. package/dist/session/provider-cli/provider-in-flight-work.js +92 -0
  293. package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
  294. package/dist/session/provider-cli/provider-output-pipes.js +67 -0
  295. package/dist/session/provider-cli/provider-output-state.d.ts +40 -0
  296. package/dist/session/provider-cli/provider-output-state.js +832 -0
  297. package/dist/session/provider-cli/provider-usage.d.ts +9 -1
  298. package/dist/session/provider-cli/provider-usage.js +28 -5
  299. package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
  300. package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
  301. package/dist/session/publishable-worktree-changes.d.ts +54 -0
  302. package/dist/session/publishable-worktree-changes.js +193 -0
  303. package/dist/session/qa-sidecar-validation.d.ts +6 -0
  304. package/dist/session/qa-sidecar-validation.js +28 -0
  305. package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
  306. package/dist/session/sandbox-host-capacity-gate.js +257 -0
  307. package/dist/session/session-redaction.d.ts +3 -0
  308. package/dist/session/session-redaction.js +298 -0
  309. package/dist/session/session.base.d.ts +14 -1
  310. package/dist/session/session.service.d.ts +17 -2
  311. package/dist/session/session.service.js +708 -60
  312. package/dist/session/session.types.d.ts +327 -3
  313. package/dist/session/session.types.js +951 -10
  314. package/dist/session/sidecar-json-shape.d.ts +31 -0
  315. package/dist/session/sidecar-json-shape.js +217 -0
  316. package/dist/session/unreferenced-exports.d.ts +12 -0
  317. package/dist/session/unreferenced-exports.js +59 -0
  318. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  319. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  320. package/dist/shared/format/format-bytes.d.ts +1 -0
  321. package/dist/shared/format/format-bytes.js +9 -0
  322. package/dist/shared/fs/file-identity.d.ts +10 -0
  323. package/dist/shared/fs/file-identity.js +15 -0
  324. package/dist/shared/fs/replace-file.d.ts +7 -0
  325. package/dist/shared/fs/replace-file.js +33 -0
  326. package/dist/shared/git/git.js +2 -1
  327. package/dist/shared/path/path.d.ts +1 -0
  328. package/dist/shared/path/path.js +21 -1
  329. package/dist/shared/process/dotnet-toolchain.d.ts +17 -0
  330. package/dist/shared/process/dotnet-toolchain.js +307 -0
  331. package/dist/shared/process/host-process-recovery.d.ts +23 -0
  332. package/dist/shared/process/host-process-recovery.js +99 -0
  333. package/dist/shared/process/host-process-supervisor.d.ts +72 -0
  334. package/dist/shared/process/host-process-supervisor.js +383 -0
  335. package/dist/shared/process/process-tree.d.ts +52 -0
  336. package/dist/shared/process/process-tree.js +144 -0
  337. package/dist/shared/process/process.d.ts +70 -0
  338. package/dist/shared/process/process.js +224 -16
  339. package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
  340. package/dist/shared/process/windows-app-execution-alias.js +45 -0
  341. package/dist/shared/process/windows-launch.d.ts +26 -0
  342. package/dist/shared/process/windows-launch.js +109 -0
  343. package/dist/shared/provider-capabilities.d.ts +4 -0
  344. package/dist/shared/provider-capabilities.js +95 -0
  345. package/dist/shared/redaction/redaction.d.ts +1 -0
  346. package/dist/shared/redaction/redaction.js +47 -4
  347. package/dist/shared/time/monotonic.d.ts +1 -0
  348. package/dist/shared/time/monotonic.js +8 -0
  349. package/dist/version.d.ts +1 -1
  350. package/dist/version.js +1 -1
  351. package/dist/worktree/artifact-injector.d.ts +3 -2
  352. package/dist/worktree/artifact-injector.js +82 -10
  353. package/dist/worktree/dependency-warmer.d.ts +78 -1
  354. package/dist/worktree/dependency-warmer.js +731 -13
  355. package/dist/worktree/index.d.ts +2 -1
  356. package/dist/worktree/index.js +1 -0
  357. package/dist/worktree/prior-phase-artifact-hydrator.d.ts +2 -0
  358. package/dist/worktree/prior-phase-artifact-hydrator.js +136 -0
  359. package/dist/worktree/story-qa-reference-hydrator.d.ts +4 -0
  360. package/dist/worktree/story-qa-reference-hydrator.js +253 -0
  361. package/dist/worktree/wip-git.d.ts +33 -0
  362. package/dist/worktree/wip-git.js +122 -0
  363. package/dist/worktree/wip-refs.d.ts +62 -0
  364. package/dist/worktree/wip-refs.js +119 -0
  365. package/dist/worktree/wip-restore.d.ts +38 -0
  366. package/dist/worktree/wip-restore.js +190 -0
  367. package/dist/worktree/wip-snapshot.d.ts +50 -0
  368. package/dist/worktree/wip-snapshot.js +268 -0
  369. package/dist/worktree/worktree-paths.d.ts +4 -0
  370. package/dist/worktree/worktree-paths.js +30 -0
  371. package/dist/worktree/worktree-wip-events.d.ts +18 -0
  372. package/dist/worktree/worktree-wip-events.js +98 -0
  373. package/dist/worktree/worktree-wip.d.ts +49 -0
  374. package/dist/worktree/worktree-wip.js +182 -0
  375. package/dist/worktree/worktree.base.d.ts +10 -1
  376. package/dist/worktree/worktree.service.d.ts +30 -4
  377. package/dist/worktree/worktree.service.js +379 -54
  378. package/dist/worktree/worktree.types.d.ts +38 -1
  379. package/package.json +12 -7
  380. package/runtime/windows-job-supervisor.ps1 +722 -0
  381. package/runtime/windows-listener-owner.ps1 +33 -0
@@ -0,0 +1,55 @@
1
+ import type { LoadedHostRuntimeContract } from "./host-runtime-contract.js";
2
+ export interface HostParallelPromotionRecord {
3
+ readonly schemaVersion: 1;
4
+ readonly repoId: string;
5
+ readonly runtimeContractFingerprint: string;
6
+ readonly inputCommitSha?: string | null;
7
+ readonly sourceFingerprint?: string;
8
+ readonly runtimeContractSource?: "project" | "derived";
9
+ readonly observedAt: string;
10
+ readonly observedDispatchAttemptId: string;
11
+ readonly verifiedPortNames: readonly string[];
12
+ }
13
+ export interface HostParallelProofIdentity {
14
+ readonly runtimeContractFingerprint: string;
15
+ readonly inputCommitSha: string;
16
+ readonly sourceFingerprint?: string;
17
+ }
18
+ /** Persists only observed, contract-bound host parallel-safety evidence. */
19
+ export declare class HostParallelPromotionStore {
20
+ private readonly stateRoot;
21
+ constructor(stateRoot: string);
22
+ load(repoId: string, identity?: HostParallelProofIdentity): Promise<HostParallelPromotionRecord | null>;
23
+ list(): Promise<readonly HostParallelPromotionRecord[]>;
24
+ observe(repoId: string, runtimeContract: LoadedHostRuntimeContract, dispatchAttemptId: string, verifiedPortNames: readonly string[], inputCommitSha?: string, sourceFingerprint?: string): Promise<HostParallelPromotionRecord>;
25
+ private writeRecord;
26
+ private pruneVersions;
27
+ invalidate(repoId: string, scope?: "all" | "discovery"): Promise<void>;
28
+ private recordPath;
29
+ }
30
+ export declare function hostRuntimeContractFingerprint(runtimeContract: LoadedHostRuntimeContract): string;
31
+ export interface ReadmittedHostRuntimeContract {
32
+ readonly runtimeContract: LoadedHostRuntimeContract;
33
+ readonly runtimeContractFingerprint: string;
34
+ readonly changed: boolean;
35
+ }
36
+ /**
37
+ * Decides whether a restart may run the workspace's current runtime contract under the admission
38
+ * granted at start. A restart relaunches from the workspace in any case, so a contract whose only
39
+ * change is the values its ports launch with (launch environment, or discovery inputs that leave
40
+ * the contract itself unchanged) is adopted. This is how a conflict repair survives its own merge:
41
+ * merging the target branch can rename a variable in a derived launch profile, or change a
42
+ * manifest or project file, without changing anything admission granted. Every other part of the
43
+ * contract is admission: source, concurrency, ports (names, adapters, environment names, URL
44
+ * formats, and the command, arguments and working directory that launch them), Playwright, browser
45
+ * profile, singleton resources and declared requirements. Changing any of those throws the
46
+ * retryable host_runtime_contract_changed, so only a fresh attempt runs that contract. An attempt
47
+ * admitted to run in parallel keeps that admission, as it does when a merge changes only source;
48
+ * a restart never promotes, so the adopted contract earns no parallel-safety proof of its own here.
49
+ */
50
+ export declare function readmitHostRuntimeContract(admitted: {
51
+ readonly runtimeContract: LoadedHostRuntimeContract;
52
+ readonly runtimeContractFingerprint: string;
53
+ }, current: LoadedHostRuntimeContract): ReadmittedHostRuntimeContract;
54
+ export declare function hostRuntimeParallelEligible(runtimeContract: LoadedHostRuntimeContract): boolean;
55
+ export declare function configuredLaunchPortNames(runtimeContract: LoadedHostRuntimeContract): readonly string[];
@@ -0,0 +1,254 @@
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { ForgeFailureError } from "../session/session.types.js";
5
+ /** Persists only observed, contract-bound host parallel-safety evidence. */
6
+ export class HostParallelPromotionStore {
7
+ stateRoot;
8
+ constructor(stateRoot) {
9
+ this.stateRoot = stateRoot;
10
+ }
11
+ async load(repoId, identity) {
12
+ const normalizedRepoId = normalizeRepoId(repoId);
13
+ try {
14
+ const parsed = JSON.parse(await fs.readFile(this.recordPath(normalizedRepoId, identity), "utf8"));
15
+ return validRecord(parsed, normalizedRepoId)
16
+ && (!identity || matchesIdentity(parsed, identity)) ? parsed : null;
17
+ }
18
+ catch (error) {
19
+ if (error.code === "ENOENT" || error instanceof SyntaxError)
20
+ return null;
21
+ throw error;
22
+ }
23
+ }
24
+ async list() {
25
+ const root = path.join(this.stateRoot, "runtime-promotion", "host");
26
+ let entries;
27
+ try {
28
+ entries = await fs.readdir(root);
29
+ }
30
+ catch (error) {
31
+ if (error.code === "ENOENT")
32
+ return [];
33
+ throw error;
34
+ }
35
+ const records = [];
36
+ for (const entry of entries.filter(value => /^[0-9a-f]{64}\.json$/u.test(value)).slice(0, 4096)) {
37
+ try {
38
+ const parsed = JSON.parse(await fs.readFile(path.join(root, entry), "utf8"));
39
+ const repoId = typeof parsed.repoId === "string" ? normalizeRepoId(parsed.repoId) : "";
40
+ if (repoId && validRecord(parsed, repoId))
41
+ records.push(parsed);
42
+ }
43
+ catch (error) {
44
+ if (!(error instanceof SyntaxError))
45
+ throw error;
46
+ }
47
+ }
48
+ return records.sort((left, right) => left.repoId.localeCompare(right.repoId));
49
+ }
50
+ async observe(repoId, runtimeContract, dispatchAttemptId, verifiedPortNames, inputCommitSha, sourceFingerprint) {
51
+ if (!hostRuntimeParallelEligible(runtimeContract)) {
52
+ throw new Error("host_parallel_promotion_ineligible: the runtime contract is not eligible for parallel host execution.");
53
+ }
54
+ const requiredPorts = configuredLaunchPortNames(runtimeContract);
55
+ const observedPorts = [...new Set(verifiedPortNames)].sort((left, right) => left.localeCompare(right));
56
+ if (requiredPorts.length !== observedPorts.length
57
+ || requiredPorts.some((name, index) => name !== observedPorts[index])) {
58
+ throw new Error("host_parallel_promotion_unverified: every configured runtime listener must pass its assigned-port probe.");
59
+ }
60
+ const normalizedRepoId = normalizeRepoId(repoId);
61
+ const record = {
62
+ schemaVersion: 1,
63
+ repoId: normalizedRepoId,
64
+ runtimeContractFingerprint: hostRuntimeContractFingerprint(runtimeContract),
65
+ inputCommitSha: inputCommitSha ?? null,
66
+ ...(sourceFingerprint ? { sourceFingerprint } : {}),
67
+ runtimeContractSource: runtimeContract.source === "project" ? "project" : "derived",
68
+ observedAt: new Date().toISOString(),
69
+ observedDispatchAttemptId: normalizedUuid(dispatchAttemptId, "dispatch attempt"),
70
+ verifiedPortNames: observedPorts,
71
+ };
72
+ if (inputCommitSha) {
73
+ await this.writeRecord(this.recordPath(normalizedRepoId, {
74
+ runtimeContractFingerprint: record.runtimeContractFingerprint, inputCommitSha, sourceFingerprint,
75
+ }), record);
76
+ }
77
+ await this.writeRecord(this.recordPath(normalizedRepoId), record);
78
+ await this.pruneVersions(normalizedRepoId);
79
+ return record;
80
+ }
81
+ async writeRecord(target, record) {
82
+ const root = path.dirname(target);
83
+ await ensurePrivateDirectory(root);
84
+ const temporary = `${target}.${randomUUID()}.tmp`;
85
+ try {
86
+ const handle = await fs.open(temporary, "wx", 0o600);
87
+ try {
88
+ await handle.writeFile(`${JSON.stringify(record)}\n`, "utf8");
89
+ await handle.sync();
90
+ }
91
+ finally {
92
+ await handle.close();
93
+ }
94
+ await fs.rename(temporary, target);
95
+ }
96
+ catch (error) {
97
+ await fs.rm(temporary, { force: true }).catch(() => undefined);
98
+ throw error;
99
+ }
100
+ }
101
+ async pruneVersions(repoId) {
102
+ const target = this.recordPath(repoId);
103
+ const root = path.dirname(target);
104
+ const prefix = path.basename(target, ".json") + ".";
105
+ const versions = (await fs.readdir(root)).filter(name => name.startsWith(prefix)
106
+ && /^[0-9a-f]{64}\.[0-9a-f]{64}\.json$/u.test(name));
107
+ if (versions.length <= 128)
108
+ return;
109
+ const dated = await Promise.all(versions.map(async (name) => ({ name,
110
+ at: await fs.stat(path.join(root, name)).then(stat => stat.mtimeMs, () => Number.MAX_SAFE_INTEGER) })));
111
+ for (const entry of dated.sort((a, b) => b.at - a.at).slice(128)) {
112
+ await fs.rm(path.join(root, entry.name), { force: true });
113
+ }
114
+ }
115
+ async invalidate(repoId, scope = "all") {
116
+ const target = this.recordPath(normalizeRepoId(repoId));
117
+ await fs.rm(target, { force: true });
118
+ // Background/default-branch discovery must not erase proofs bound to other
119
+ // prepared sources. Actual containment/cleanup degradation invalidates all.
120
+ if (scope === "discovery")
121
+ return;
122
+ const prefix = path.basename(target, ".json") + ".";
123
+ const entries = await fs.readdir(path.dirname(target)).catch((error) => {
124
+ if (error.code === "ENOENT")
125
+ return [];
126
+ throw error;
127
+ });
128
+ for (const entry of entries.filter(name => name.startsWith(prefix) && /^[0-9a-f]{64}\.[0-9a-f]{64}\.json$/u.test(name))) {
129
+ await fs.rm(path.join(path.dirname(target), entry), { force: true });
130
+ }
131
+ }
132
+ recordPath(normalizedRepoId, identity) {
133
+ const key = createHash("sha256").update(normalizedRepoId).digest("hex");
134
+ const version = identity ? `.${createHash("sha256").update(JSON.stringify([
135
+ identity.runtimeContractFingerprint, identity.inputCommitSha, identity.sourceFingerprint ?? null,
136
+ ])).digest("hex")}` : "";
137
+ return path.join(this.stateRoot, "runtime-promotion", "host", `${key}${version}.json`);
138
+ }
139
+ }
140
+ function matchesIdentity(record, identity) {
141
+ return record.runtimeContractFingerprint === identity.runtimeContractFingerprint
142
+ && record.inputCommitSha === identity.inputCommitSha
143
+ && record.sourceFingerprint === identity.sourceFingerprint;
144
+ }
145
+ export function hostRuntimeContractFingerprint(runtimeContract) {
146
+ const canonical = JSON.stringify({
147
+ schemaVersion: runtimeContract.contract.schemaVersion,
148
+ runtime: runtimeContract.contract.runtime,
149
+ // Requirements join the fingerprint only when declared, so fingerprints of contracts
150
+ // written before decision 0013 (and their stored promotions) stay unchanged.
151
+ ...requirementsFingerprintPart(runtimeContract.contract.requires),
152
+ derivedCandidateFingerprint: runtimeContract.source === "derived"
153
+ ? runtimeContract.discovery?.candidateFingerprint ?? null
154
+ : null,
155
+ });
156
+ return `sha256:${createHash("sha256").update(canonical).digest("hex")}`;
157
+ }
158
+ /**
159
+ * Decides whether a restart may run the workspace's current runtime contract under the admission
160
+ * granted at start. A restart relaunches from the workspace in any case, so a contract whose only
161
+ * change is the values its ports launch with (launch environment, or discovery inputs that leave
162
+ * the contract itself unchanged) is adopted. This is how a conflict repair survives its own merge:
163
+ * merging the target branch can rename a variable in a derived launch profile, or change a
164
+ * manifest or project file, without changing anything admission granted. Every other part of the
165
+ * contract is admission: source, concurrency, ports (names, adapters, environment names, URL
166
+ * formats, and the command, arguments and working directory that launch them), Playwright, browser
167
+ * profile, singleton resources and declared requirements. Changing any of those throws the
168
+ * retryable host_runtime_contract_changed, so only a fresh attempt runs that contract. An attempt
169
+ * admitted to run in parallel keeps that admission, as it does when a merge changes only source;
170
+ * a restart never promotes, so the adopted contract earns no parallel-safety proof of its own here.
171
+ */
172
+ export function readmitHostRuntimeContract(admitted, current) {
173
+ const runtimeContractFingerprint = hostRuntimeContractFingerprint(current);
174
+ // The fingerprint leaves out the source of a project or default contract, but parallel
175
+ // eligibility depends on it, so an unchanged fingerprint alone does not prove the same admission.
176
+ if (runtimeContractFingerprint === admitted.runtimeContractFingerprint && current.source === admitted.runtimeContract.source) {
177
+ return { runtimeContract: admitted.runtimeContract, runtimeContractFingerprint, changed: false };
178
+ }
179
+ if (hostRuntimeAdmissionShape(current) !== hostRuntimeAdmissionShape(admitted.runtimeContract)) {
180
+ throw new ForgeFailureError("host_runtime_contract_changed", "host_runtime_contract_changed: the workspace's runtime contract changed after this attempt's runtime was admitted; a fresh attempt is needed to run it.");
181
+ }
182
+ return { runtimeContract: current, runtimeContractFingerprint, changed: true };
183
+ }
184
+ function hostRuntimeAdmissionShape(runtimeContract) {
185
+ const runtime = runtimeContract.contract.runtime;
186
+ return JSON.stringify({
187
+ source: runtimeContract.source,
188
+ schemaVersion: runtimeContract.contract.schemaVersion,
189
+ runtime: { ...runtime, ports: runtime.ports.map(port => ({ ...port, launch: port.launch && { ...port.launch, environment: undefined } })) },
190
+ ...requirementsFingerprintPart(runtimeContract.contract.requires),
191
+ });
192
+ }
193
+ // Cost hints are estimates, not placement constraints: they never change the fingerprint.
194
+ function requirementsFingerprintPart(requires) {
195
+ if (!requires)
196
+ return {};
197
+ const { costHints: _costHints, ...constraints } = requires;
198
+ const declared = constraints.minThreads !== null || constraints.minMemoryGiB !== null || constraints.toolchains.length > 0
199
+ || constraints.docker || constraints.playwright !== null || constraints.testPostgres !== null;
200
+ return declared ? { requires: constraints } : {};
201
+ }
202
+ export function hostRuntimeParallelEligible(runtimeContract) {
203
+ const runtime = runtimeContract.contract.runtime;
204
+ const launchedPorts = runtime.ports.filter(port => port.launch !== null);
205
+ return (runtimeContract.source === "project" || runtimeContract.source === "derived")
206
+ && runtime.hostConcurrency === "parallel"
207
+ && runtime.browserProfile === "isolated"
208
+ && runtime.singletonResources.length === 0
209
+ && launchedPorts.length > 0
210
+ && launchedPorts.length === runtime.ports.length
211
+ && launchedPorts.every(port => port.adapter !== null);
212
+ }
213
+ export function configuredLaunchPortNames(runtimeContract) {
214
+ return runtimeContract.contract.runtime.ports
215
+ .filter(port => port.launch !== null)
216
+ .map(port => port.name)
217
+ .sort((left, right) => left.localeCompare(right));
218
+ }
219
+ function validRecord(value, repoId) {
220
+ if (!value || typeof value !== "object" || Array.isArray(value))
221
+ return false;
222
+ const record = value;
223
+ return record.schemaVersion === 1
224
+ && record.repoId === repoId
225
+ && /^sha256:[0-9a-f]{64}$/u.test(record.runtimeContractFingerprint ?? "")
226
+ && Number.isFinite(Date.parse(record.observedAt ?? ""))
227
+ && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u.test(record.observedDispatchAttemptId ?? "")
228
+ && Array.isArray(record.verifiedPortNames)
229
+ && record.verifiedPortNames.length > 0
230
+ && record.verifiedPortNames.length <= 16
231
+ && record.verifiedPortNames.every(name => typeof name === "string" && /^[a-z][a-z0-9_-]{0,63}$/u.test(name));
232
+ }
233
+ function normalizeRepoId(repoId) {
234
+ const normalized = repoId.trim().toLowerCase();
235
+ if (!normalized || normalized.length > 512 || Array.from(normalized).some(character => {
236
+ const codePoint = character.codePointAt(0) ?? 0;
237
+ return codePoint < 32 || codePoint === 127;
238
+ })) {
239
+ throw new Error("host_parallel_promotion_invalid: repository identity is invalid.");
240
+ }
241
+ return normalized;
242
+ }
243
+ function normalizedUuid(value, label) {
244
+ const normalized = value.trim().toLowerCase();
245
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u.test(normalized)) {
246
+ throw new Error(`host_parallel_promotion_invalid: ${label} must be a full UUID.`);
247
+ }
248
+ return normalized;
249
+ }
250
+ async function ensurePrivateDirectory(target) {
251
+ await fs.mkdir(target, { recursive: true, mode: 0o700 });
252
+ if (process.platform !== "win32")
253
+ await fs.chmod(target, 0o700);
254
+ }
@@ -0,0 +1,17 @@
1
+ import type { HostRuntimeRequirements } from "./host-runtime-requirements.js";
2
+ /** What this bridge host offers, for the accept-time requirements recheck (decision 0013). */
3
+ export interface HostRequirementFacts {
4
+ readonly logicalThreads: number;
5
+ readonly totalMemoryBytes: number;
6
+ readonly availableToolchains: readonly string[];
7
+ readonly dockerAvailable: boolean;
8
+ readonly browserLaunch: boolean;
9
+ readonly testPostgresSuperuser: boolean | null;
10
+ }
11
+ export type HostRequirementsCheck = (requires: HostRuntimeRequirements | null | undefined) => readonly string[];
12
+ /**
13
+ * Reasons this host fails a host-mode attempt's declared requirements. The API filters on
14
+ * stored requirements; this recheck closes the gap when they were not reported yet or the
15
+ * attempt's contract differs from the probed one. Mirrors the API's wording.
16
+ */
17
+ export declare function unmetHostRuntimeRequirements(requires: HostRuntimeRequirements | null | undefined, facts: HostRequirementFacts): readonly string[];
@@ -0,0 +1,29 @@
1
+ const gib = 1024 * 1024 * 1024;
2
+ /**
3
+ * Reasons this host fails a host-mode attempt's declared requirements. The API filters on
4
+ * stored requirements; this recheck closes the gap when they were not reported yet or the
5
+ * attempt's contract differs from the probed one. Mirrors the API's wording.
6
+ */
7
+ export function unmetHostRuntimeRequirements(requires, facts) {
8
+ if (!requires)
9
+ return [];
10
+ const unmet = [];
11
+ if (requires.minThreads !== null && facts.logicalThreads < requires.minThreads) {
12
+ unmet.push(`needs ≥ ${requires.minThreads} threads; this host has ${facts.logicalThreads}`);
13
+ }
14
+ if (requires.minMemoryGiB !== null && facts.totalMemoryBytes / gib < requires.minMemoryGiB) {
15
+ unmet.push(`needs ≥ ${requires.minMemoryGiB} GiB; this host has ${(Math.floor(facts.totalMemoryBytes / gib * 100) / 100)}`);
16
+ }
17
+ const available = new Set(facts.availableToolchains.map(name => name.toLowerCase()));
18
+ const missing = requires.toolchains.filter(name => !available.has(name));
19
+ if (missing.length > 0)
20
+ unmet.push(`needs ${missing.join(", ")}; this host does not have ${missing.length === 1 ? "it" : "them"}`);
21
+ if (requires.docker && !facts.dockerAvailable)
22
+ unmet.push("needs Docker; this host does not have it");
23
+ if (requires.testPostgres?.superuser && !facts.dockerAvailable && facts.testPostgresSuperuser !== true) {
24
+ unmet.push("needs Docker or a superuser test database; this host has neither");
25
+ }
26
+ if (requires.playwright && !facts.browserLaunch)
27
+ unmet.push("needs Playwright browsers; this host cannot launch them");
28
+ return unmet;
29
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Project host requirements declared in `.forge/forge.runtime.yml` (decision 0013 §3).
3
+ *
4
+ * The bridge parses them with the runtime contract and reports them, with the contract
5
+ * fingerprint, in its readiness payload. The API stores them per fingerprint and uses them
6
+ * as hard placement filters. A contract without a `requires` section has no requirements.
7
+ */
8
+ export interface HostRuntimePlaywrightRequirement {
9
+ /** Pinned Playwright revision. Recorded; enforced once bridges probe browser revisions. */
10
+ readonly revision: string | null;
11
+ }
12
+ export interface HostRuntimeTestPostgresRequirement {
13
+ readonly extensions: readonly string[];
14
+ /** Suites need a superuser role (or Docker-backed Testcontainers). */
15
+ readonly superuser: boolean;
16
+ }
17
+ export interface HostRuntimeCostHint {
18
+ readonly cores: number | null;
19
+ readonly memoryGiB: number | null;
20
+ }
21
+ export interface HostRuntimeRequirements {
22
+ readonly minThreads: number | null;
23
+ readonly minMemoryGiB: number | null;
24
+ readonly toolchains: readonly string[];
25
+ /** Suites need a Docker engine (for example Testcontainers). */
26
+ readonly docker: boolean;
27
+ readonly playwright: HostRuntimePlaywrightRequirement | null;
28
+ readonly testPostgres: HostRuntimeTestPostgresRequirement | null;
29
+ /** Accepted and reported, not yet used for placement. */
30
+ readonly costHints: Readonly<Record<string, HostRuntimeCostHint>>;
31
+ }
32
+ /**
33
+ * Validates the optional top-level `requires` and `costHints` sections. Returns null when
34
+ * neither section is present, so contracts written before decision 0013 keep their meaning.
35
+ */
36
+ export declare function parseHostRuntimeRequirements(requires: unknown, costHints: unknown): HostRuntimeRequirements | null;
@@ -0,0 +1,117 @@
1
+ const requiresKeys = new Set(["minThreads", "minMemoryGiB", "toolchains", "docker", "playwright", "testPostgres"]);
2
+ const playwrightKeys = new Set(["revision"]);
3
+ const testPostgresKeys = new Set(["extensions", "superuser"]);
4
+ const costHintKeys = new Set(["cores", "memoryGiB"]);
5
+ const toolchainPattern = /^[a-z][a-z0-9_.-]{0,63}$/u;
6
+ const extensionPattern = /^[a-z][a-z0-9_]{0,62}$/u;
7
+ const stepClassPattern = /^[a-z][a-z0-9_.:-]{0,127}$/u;
8
+ const revisionPattern = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$/u;
9
+ /**
10
+ * Validates the optional top-level `requires` and `costHints` sections. Returns null when
11
+ * neither section is present, so contracts written before decision 0013 keep their meaning.
12
+ */
13
+ export function parseHostRuntimeRequirements(requires, costHints) {
14
+ if (isAbsent(requires) && isAbsent(costHints))
15
+ return null;
16
+ const section = isAbsent(requires) ? {} : object(requires, "requires");
17
+ rejectUnknownKeys(section, requiresKeys, "requires");
18
+ return {
19
+ minThreads: optionalNumber(section.minThreads, "requires.minThreads", 1, 1024, true),
20
+ minMemoryGiB: optionalNumber(section.minMemoryGiB, "requires.minMemoryGiB", 0.125, 4096, false),
21
+ toolchains: nameList(section.toolchains, "requires.toolchains", toolchainPattern, 32),
22
+ docker: optionalBoolean(section.docker, "requires.docker"),
23
+ playwright: parsePlaywright(section.playwright),
24
+ testPostgres: parseTestPostgres(section.testPostgres),
25
+ costHints: parseCostHints(costHints),
26
+ };
27
+ }
28
+ function parsePlaywright(value) {
29
+ if (isAbsent(value) || value === false)
30
+ return null;
31
+ if (value === true)
32
+ return { revision: null };
33
+ const playwright = object(value, "requires.playwright");
34
+ rejectUnknownKeys(playwright, playwrightKeys, "requires.playwright");
35
+ if (isAbsent(playwright.revision))
36
+ return { revision: null };
37
+ if (typeof playwright.revision !== "string" || !revisionPattern.test(playwright.revision.trim())) {
38
+ throw invalid("requires.playwright.revision must be a version or revision string.");
39
+ }
40
+ return { revision: playwright.revision.trim() };
41
+ }
42
+ function parseTestPostgres(value) {
43
+ if (isAbsent(value))
44
+ return null;
45
+ const testPostgres = object(value, "requires.testPostgres");
46
+ rejectUnknownKeys(testPostgres, testPostgresKeys, "requires.testPostgres");
47
+ return {
48
+ extensions: nameList(testPostgres.extensions, "requires.testPostgres.extensions", extensionPattern, 16),
49
+ superuser: optionalBoolean(testPostgres.superuser, "requires.testPostgres.superuser"),
50
+ };
51
+ }
52
+ function parseCostHints(value) {
53
+ if (isAbsent(value))
54
+ return {};
55
+ const hints = object(value, "costHints");
56
+ const entries = Object.entries(hints);
57
+ if (entries.length > 32)
58
+ throw invalid("costHints may declare at most 32 step classes.");
59
+ const parsed = {};
60
+ for (const [stepClass, hint] of entries.sort(([left], [right]) => left.localeCompare(right))) {
61
+ if (!stepClassPattern.test(stepClass))
62
+ throw invalid(`costHints step class '${stepClass}' is invalid.`);
63
+ const entry = object(hint, `costHints.${stepClass}`);
64
+ rejectUnknownKeys(entry, costHintKeys, `costHints.${stepClass}`);
65
+ parsed[stepClass] = {
66
+ cores: optionalNumber(entry.cores, `costHints.${stepClass}.cores`, 0.01, 1024, false),
67
+ memoryGiB: optionalNumber(entry.memoryGiB, `costHints.${stepClass}.memoryGiB`, 0.01, 4096, false),
68
+ };
69
+ }
70
+ return parsed;
71
+ }
72
+ function optionalNumber(value, label, minimum, maximum, integer) {
73
+ if (isAbsent(value))
74
+ return null;
75
+ if (typeof value !== "number" || !Number.isFinite(value) || value < minimum || value > maximum
76
+ || (integer && !Number.isSafeInteger(value))) {
77
+ throw invalid(`${label} must be ${integer ? "an integer" : "a number"} between ${minimum} and ${maximum}.`);
78
+ }
79
+ return value;
80
+ }
81
+ function nameList(value, label, pattern, maximum) {
82
+ if (isAbsent(value))
83
+ return [];
84
+ if (!Array.isArray(value) || value.length > maximum) {
85
+ throw invalid(`${label} must be a list with at most ${maximum} entries.`);
86
+ }
87
+ const names = value.map((entry, index) => {
88
+ const name = typeof entry === "string" ? entry.trim().toLowerCase() : "";
89
+ if (!pattern.test(name))
90
+ throw invalid(`${label}[${index}] is invalid.`);
91
+ return name;
92
+ });
93
+ return [...new Set(names)].sort((left, right) => left.localeCompare(right));
94
+ }
95
+ function optionalBoolean(value, label) {
96
+ if (isAbsent(value))
97
+ return false;
98
+ if (typeof value !== "boolean")
99
+ throw invalid(`${label} must be true or false.`);
100
+ return value;
101
+ }
102
+ function isAbsent(value) {
103
+ return value === undefined || value === null;
104
+ }
105
+ function object(value, label) {
106
+ if (!value || typeof value !== "object" || Array.isArray(value))
107
+ throw invalid(`${label} must be an object.`);
108
+ return value;
109
+ }
110
+ function rejectUnknownKeys(value, allowed, label) {
111
+ const unknown = Object.keys(value).find(key => !allowed.has(key));
112
+ if (unknown)
113
+ throw invalid(`unknown ${label} key '${unknown}'.`);
114
+ }
115
+ function invalid(message) {
116
+ return new Error(`runtime_contract_invalid: ${message}`);
117
+ }
@@ -0,0 +1,62 @@
1
+ import type { PinnedDirectoryIdentity } from "./pinned-directory-process.js";
2
+ /**
3
+ * Why Forge stopped a managed command that had not finished:
4
+ * - `owner_exited`: the provider process whose MCP server started it has exited, so no
5
+ * process is left to supervise it or write its receipt.
6
+ * - `attempt_teardown`: the dispatch attempt is being torn down.
7
+ */
8
+ export type ManagedCommandTeardownReason = "owner_exited" | "attempt_teardown";
9
+ export interface ManagedCommandTeardownScope {
10
+ /** The attempt's private FORGE_LOG_DIR; managed commands record ownership under it. */
11
+ readonly logDirectory: string;
12
+ readonly dispatchAttemptId: string;
13
+ readonly runtimeLeaseId: string;
14
+ /**
15
+ * Reads the ownership records through pinned directory and file identities instead of
16
+ * pathnames. Restart recovery supplies the verified identity of the attempt's logs.
17
+ */
18
+ readonly pinnedLogDirectory?: PinnedDirectoryIdentity;
19
+ }
20
+ export interface ManagedCommandTeardownOptions {
21
+ readonly reason: ManagedCommandTeardownReason;
22
+ /**
23
+ * Stop only commands whose owning MCP server process is gone. A command whose owner is
24
+ * alive is still supervised by it and must survive wait slices and MCP call boundaries.
25
+ */
26
+ readonly onlyOrphaned?: boolean;
27
+ readonly graceMs?: number;
28
+ readonly platform?: NodeJS.Platform;
29
+ }
30
+ export type ManagedCommandTeardownOutcomeKind =
31
+ /** The recorded process tree had already exited. */
32
+ "absent"
33
+ /** Forge stopped the recorded process tree and proved it gone. */
34
+ | "terminated"
35
+ /** The recorded root PID now names another process, so the recorded tree is gone. */
36
+ | "pid_reused"
37
+ /** The command's owning MCP server is alive and still supervises it. */
38
+ | "owner_alive"
39
+ /** The command finished on its own; nothing was signalled or rewritten. */
40
+ | "already_terminal"
41
+ /** The command never recorded a process: it was queued, or its launch was interrupted. */
42
+ | "no_process_record";
43
+ export interface ManagedCommandTeardownOutcome {
44
+ readonly commandId: string;
45
+ readonly outcome: ManagedCommandTeardownOutcomeKind;
46
+ readonly receiptFinalized: boolean;
47
+ }
48
+ /** Test support: points the Linux process inventory at another directory (null restores /proc). */
49
+ export declare function setManagedCommandProcRootForTesting(root: string | null): void;
50
+ /**
51
+ * Stops managed commands that an attempt's MCP servers started and proves their process
52
+ * trees are gone. Managed commands run in their own process group (Unix) or Job Object
53
+ * (Windows), outside the provider tree that the attempt supervisor stops, so stopping the
54
+ * provider alone leaves them running. Each command's durable receipt is given a terminal
55
+ * status when its owner can no longer write one.
56
+ *
57
+ * Every signal is fenced: the recorded root must still carry the recorded birth identity
58
+ * and, on Linux, this command's supervisor and attempt identity in its environment. A
59
+ * tree that cannot be proven to be the command's own fails the teardown instead of being
60
+ * reported stopped.
61
+ */
62
+ export declare function terminateAttemptManagedCommands(scope: ManagedCommandTeardownScope, options: ManagedCommandTeardownOptions): Promise<readonly ManagedCommandTeardownOutcome[]>;