@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,27 @@
1
+ import { type HostLoadStepGate } from "../runtime/host-load-governor.js";
2
+ import { type HostLoadTokenPriority } from "../runtime/host-load-token-ledger.js";
3
+ import type { RunnerDispatchEvent } from "./session.types.js";
4
+ /** Which attempt a governed validation step belongs to, and its queue class. */
5
+ export interface PrePublicationHostLoadOwner {
6
+ readonly dispatchAttemptId: string | null;
7
+ readonly priority: HostLoadTokenPriority;
8
+ }
9
+ export interface GovernedValidationStep {
10
+ readonly checkId: string;
11
+ readonly command: string;
12
+ readonly args: readonly string[];
13
+ readonly owner?: PrePublicationHostLoadOwner;
14
+ readonly signal?: AbortSignal;
15
+ readonly emit?: (event: RunnerDispatchEvent) => Promise<void>;
16
+ }
17
+ /**
18
+ * Runs one pre-publication step behind the host load governor (decision 0013).
19
+ * With the governor off this is a direct call, so behavior is unchanged. With
20
+ * it on, the step waits for admission first; queue time is reported as
21
+ * `host_load_wait_ms` with status `waiting_for_host_capacity`, and the step's
22
+ * own clock (`elapsed_ms`) starts only once it is admitted. `run` gets the
23
+ * signal to launch with: it also aborts when the step's reservation is lost
24
+ * (token fenced, or not renewable for a lease), and the step then fails with
25
+ * that error instead of running on unaccounted.
26
+ */
27
+ export declare function runHostGovernedValidationStep<T>(gate: HostLoadStepGate | undefined, step: GovernedValidationStep, run: (signal: AbortSignal | undefined) => Promise<T>): Promise<T>;
@@ -0,0 +1,111 @@
1
+ import { monotonicNowMs } from "../shared/time/monotonic.js";
2
+ import { HostCapacityTimeoutError } from "../runtime/host-load-governor.js";
3
+ import { HostCapacityLedgerUnavailableError } from "../runtime/host-load-ledger-lock.js";
4
+ import { retentionFor, returnHostLoadToken } from "../runtime/host-load-step-run.js";
5
+ import { classifyValidationStep } from "../runtime/host-load-step-class.js";
6
+ import { HostCapacityTokenFencedError } from "../runtime/host-load-token-ledger.js";
7
+ /**
8
+ * Runs one pre-publication step behind the host load governor (decision 0013).
9
+ * With the governor off this is a direct call, so behavior is unchanged. With
10
+ * it on, the step waits for admission first; queue time is reported as
11
+ * `host_load_wait_ms` with status `waiting_for_host_capacity`, and the step's
12
+ * own clock (`elapsed_ms`) starts only once it is admitted. `run` gets the
13
+ * signal to launch with: it also aborts when the step's reservation is lost
14
+ * (token fenced, or not renewable for a lease), and the step then fails with
15
+ * that error instead of running on unaccounted.
16
+ */
17
+ export async function runHostGovernedValidationStep(gate, step, run) {
18
+ if (!gate?.enabled)
19
+ return await run(step.signal);
20
+ const { stepClass, cost } = classifyValidationStep(step.checkId, step.command, step.args);
21
+ const base = { checkId: step.checkId, contractId: "forge-ci-parity-v1", stepClass };
22
+ const emit = async (eventType, content, data, kind = "checkpoint") => {
23
+ await step.emit?.({ role: "runner", kind, content, eventType, data: JSON.stringify({ ...base, ...data }) })
24
+ .catch(() => undefined);
25
+ };
26
+ let admission;
27
+ try {
28
+ admission = await gate.acquire({
29
+ stepClass,
30
+ label: step.checkId,
31
+ cost,
32
+ dispatchAttemptId: step.owner?.dispatchAttemptId ?? null,
33
+ priority: step.owner?.priority ?? "foreground",
34
+ }, {
35
+ signal: step.signal,
36
+ onWaiting: async (decision) => await emit("prepublication_host_capacity_waiting", `Pre-publication step '${step.checkId}' (${stepClass}) is waiting for host capacity: ${decision.detail}`, { status: "waiting_for_host_capacity", reason: decision.reason, cpuCores: cost.cpuCores, memoryBytes: cost.memoryBytes }),
37
+ });
38
+ }
39
+ catch (error) {
40
+ if (error instanceof HostCapacityTimeoutError) {
41
+ await emit("prepublication_host_capacity_timeout", error.message, { status: "host_capacity_timeout", host_load_wait_ms: Math.round(error.waitMs) }, "error");
42
+ }
43
+ else if (error instanceof HostCapacityLedgerUnavailableError) {
44
+ await emit("prepublication_host_capacity_ledger_unavailable", error.message, { status: "host_capacity_ledger_unavailable" }, "error");
45
+ }
46
+ throw error;
47
+ }
48
+ const waitMs = Math.round(admission.waitMs);
49
+ await emit("prepublication_host_capacity_admitted", `Pre-publication step '${step.checkId}' (${stepClass}) was admitted after ${waitMs}ms waiting for host capacity.`, { status: "running", reason: admission.decision.reason, host_load_wait_ms: waitMs });
50
+ // Step timers start here, after admission: a step can never time out because it waited.
51
+ const startedAtMs = monotonicNowMs();
52
+ const runSignal = step.signal ? AbortSignal.any([step.signal, admission.fenced]) : admission.fenced;
53
+ const reservationLost = async () => {
54
+ const reason = admission.fenced.reason;
55
+ await emit("prepublication_host_capacity_lost", `Pre-publication step '${step.checkId}' (${stepClass}) was stopped because its host capacity reservation was lost: ${reason instanceof Error ? reason.message : String(reason)}`, { status: "host_capacity_lost" }, "error");
56
+ throw reason;
57
+ };
58
+ let unstopped = null;
59
+ try {
60
+ let result;
61
+ try {
62
+ result = await run(runSignal);
63
+ }
64
+ catch (error) {
65
+ // Part of the step may still run: that, not a fence, is what it failed with.
66
+ // Also a supervised runner's failed proof, which arrives sanitized and wrapped.
67
+ const retention = retentionFor(error);
68
+ if (retention) {
69
+ unstopped = retention;
70
+ throw error;
71
+ }
72
+ if (admission.fenced.aborted)
73
+ return await reservationLost();
74
+ throw error;
75
+ }
76
+ // A result produced after the reservation was lost is not trusted either.
77
+ if (admission.fenced.aborted)
78
+ return await reservationLost();
79
+ return result;
80
+ }
81
+ finally {
82
+ const elapsedMs = Math.round(monotonicNowMs() - startedAtMs);
83
+ // Assigned in the catch above; widened, since control-flow narrowing does not see it here.
84
+ const treeLeft = unstopped;
85
+ const returned = {
86
+ failure: treeLeft ? { kind: "retained", message: treeLeft.reason.message } : null,
87
+ };
88
+ // The token is kept, with its cost, while part of the step's tree may still run.
89
+ await returnHostLoadToken(admission, treeLeft, error => {
90
+ returned.failure = {
91
+ kind: error instanceof HostCapacityTokenFencedError ? "fenced" : "ledger_unavailable",
92
+ message: error instanceof Error ? error.message : String(error),
93
+ };
94
+ });
95
+ const failure = returned.failure;
96
+ await emit("prepublication_host_capacity_released", failure?.kind === "retained"
97
+ ? `Pre-publication step '${step.checkId}' ended, but part of its process tree did not stop; its host capacity stays reserved until it is gone: ${failure.message}`
98
+ : failure?.kind === "fenced"
99
+ ? `Pre-publication step '${step.checkId}' finished, but its host capacity token had been reclaimed: ${failure.message}`
100
+ : failure
101
+ ? `Pre-publication step '${step.checkId}' finished, but its host capacity token could not be returned yet (the governor keeps retrying): ${failure.message}`
102
+ : `Pre-publication step '${step.checkId}' (${stepClass}) ran ${elapsedMs}ms after waiting ${waitMs}ms for host capacity.`, {
103
+ status: "completed",
104
+ host_load_wait_ms: waitMs,
105
+ elapsed_ms: elapsedMs,
106
+ tokenFenced: failure?.kind === "fenced",
107
+ releaseFailed: failure?.kind === "ledger_unavailable",
108
+ tokenRetained: failure?.kind === "retained",
109
+ });
110
+ }
111
+ }
@@ -0,0 +1,30 @@
1
+ import type { DockerEngineProbe } from "../runtime/docker-engine-probe.js";
2
+ import { startEphemeralTestPostgresGrant } from "../runtime/ephemeral-test-postgres-grant.js";
3
+ import { type NativeTestPostgresFallback, type NativeTestPostgresGrant } from "../runtime/native-test-postgres-fallback.js";
4
+ import type { RunnerDispatchEvent } from "./session.types.js";
5
+ /**
6
+ * A provisioned native test cluster whose file prefers it serves this check's shared
7
+ * test server without waiting on Docker (owner policy 2026-11-16: native PostgreSQL
8
+ * first). Docker is still probed, never recovered, so the fixtures know whether
9
+ * pinned-engine tests can start their own containers. An unreadable file leaves the
10
+ * check on Docker.
11
+ */
12
+ export declare function preferredNativeTestPostgres(checkId: string, requiredPrerequisite: string | undefined, readCluster: () => NativeTestPostgresFallback | null, dockerEngineProbe: DockerEngineProbe | undefined, emit?: (event: RunnerDispatchEvent) => Promise<void>, startEphemeral?: typeof startEphemeralTestPostgresGrant): Promise<NativeTestPostgresGrant | undefined>;
13
+ /** Whether this check already has its isolated PostgreSQL without Docker. */
14
+ export declare function isolatedPostgresProvided(checkId: string, environment?: Readonly<Record<string, string>>, postgresAdminConnection?: NativeTestPostgresGrant): boolean;
15
+ /**
16
+ * The grant, when it makes its check Docker-free. A native_preferred grant still lets
17
+ * pinned-engine tests start Docker containers, so a Docker loss during its check stays
18
+ * retryable infrastructure; only a native_fallback grant (Docker was already down) does not.
19
+ */
20
+ export declare function dockerFreeGrant(grant: NativeTestPostgresGrant | undefined): NativeTestPostgresGrant | undefined;
21
+ /**
22
+ * Releases a check's ephemeral cluster once the check has ended. A cluster that would not stop
23
+ * is left disowned for the next start's reap and does not change the check's own result.
24
+ */
25
+ export declare function releaseCheckPostgres(checkId: string, grant: NativeTestPostgresGrant | undefined, emit?: (event: RunnerDispatchEvent) => Promise<void>): Promise<void>;
26
+ /** The native cluster grant for a check while Docker stays down, or null when it cannot use one. */
27
+ export declare function dockerUnavailableNativeTestPostgres(checkId: string, requiredPrerequisite: string | undefined, readCluster: () => NativeTestPostgresFallback | null): NativeTestPostgresGrant | null;
28
+ export type { NativeTestPostgresFallback, NativeTestPostgresGrant };
29
+ /** Starts a check's ephemeral cluster; injectable so tests need no PostgreSQL install. */
30
+ export type StartEphemeralTestPostgresGrant = typeof startEphemeralTestPostgresGrant;
@@ -0,0 +1,111 @@
1
+ import path from "node:path";
2
+ import { attemptDatabaseCapabilityEnvironment } from "../runtime/attempt-database-broker.js";
3
+ import { startEphemeralTestPostgresGrant } from "../runtime/ephemeral-test-postgres-grant.js";
4
+ import { nativeTestPostgresFallbackDatabaseMode, nativeTestPostgresGrant, } from "../runtime/native-test-postgres-fallback.js";
5
+ import { validationEvent } from "./pre-publication-pass.js";
6
+ import { supportsNativeTestPostgresFallback } from "./pre-publication-step-execution.js";
7
+ // Which PostgreSQL a pre-publication check's isolated_postgres prerequisite is met by,
8
+ // before the validator falls back to waiting for Docker.
9
+ /**
10
+ * A provisioned native test cluster whose file prefers it serves this check's shared
11
+ * test server without waiting on Docker (owner policy 2026-11-16: native PostgreSQL
12
+ * first). Docker is still probed, never recovered, so the fixtures know whether
13
+ * pinned-engine tests can start their own containers. An unreadable file leaves the
14
+ * check on Docker.
15
+ */
16
+ export async function preferredNativeTestPostgres(checkId, requiredPrerequisite, readCluster, dockerEngineProbe, emit, startEphemeral = startEphemeralTestPostgresGrant) {
17
+ if (requiredPrerequisite !== "isolated_postgres" || !supportsNativeTestPostgresFallback(checkId))
18
+ return undefined;
19
+ let configured;
20
+ try {
21
+ configured = readCluster();
22
+ }
23
+ catch (error) {
24
+ await emit?.(validationEvent("prepublication_prerequisite_native_invalid", checkId, `The native PostgreSQL test cluster configuration was refused, so '${checkId}' uses Docker: ${error instanceof Error ? error.message : String(error)}`));
25
+ return undefined;
26
+ }
27
+ if (configured?.use === "ephemeral") {
28
+ return await ephemeralNativeTestPostgres(checkId, configured, dockerEngineProbe, emit, startEphemeral);
29
+ }
30
+ if (configured?.use !== "preferred")
31
+ return undefined;
32
+ const dockerAvailable = dockerEngineProbe ? (await dockerEngineProbe.probeWithoutRecovery()).available : false;
33
+ const grant = nativeTestPostgresGrant(configured, dockerAvailable);
34
+ if (!grant)
35
+ return undefined;
36
+ await emit?.(validationEvent("prepublication_prerequisite_native_preferred", checkId, `Pre-publication check '${checkId}' is using the dedicated native PostgreSQL test cluster at ${grant.endpoint} with per-run owned databases${dockerAvailable
37
+ ? "; tests that need a pinned engine container still start one in Docker."
38
+ : ". Docker is unavailable, so tests that need a pinned engine container are skipped."}`));
39
+ return grant;
40
+ }
41
+ /**
42
+ * A throwaway cluster of the check's own, whose superuser it holds (owner policy 2026-11-17).
43
+ * If it cannot start, the check falls back to Docker, and to the provisioned cluster only while
44
+ * Docker is down.
45
+ */
46
+ async function ephemeralNativeTestPostgres(checkId, configured, dockerEngineProbe, emit, startEphemeral) {
47
+ const dockerAvailable = dockerEngineProbe ? (await dockerEngineProbe.probeWithoutRecovery()).available : false;
48
+ let grant;
49
+ try {
50
+ grant = await startEphemeral(configured, dockerAvailable);
51
+ }
52
+ catch (error) {
53
+ await emit?.(validationEvent("prepublication_prerequisite_ephemeral_unavailable", checkId, `An ephemeral PostgreSQL test cluster could not start for '${checkId}', so it uses Docker: ${error instanceof Error ? error.message : String(error)}`));
54
+ return undefined;
55
+ }
56
+ try {
57
+ await emit?.(validationEvent("prepublication_prerequisite_native_ephemeral", checkId, `Pre-publication check '${checkId}' is using its own ephemeral PostgreSQL test cluster at ${grant.endpoint}, deleted when the check ends${dockerAvailable
58
+ ? "; tests that need a pinned engine container still start one in Docker."
59
+ : ". Docker is unavailable, so tests that need a pinned engine container are skipped."}`));
60
+ }
61
+ catch (error) {
62
+ // The caller releases only a grant it receives, so a failed emit releases it here.
63
+ await grant.release?.().catch(() => undefined);
64
+ throw error;
65
+ }
66
+ return grant;
67
+ }
68
+ function environmentValue(environment, name) {
69
+ return Object.prototype.hasOwnProperty.call(environment ?? {}, name)
70
+ ? environment?.[name]?.trim() ?? ""
71
+ : process.env[name]?.trim() ?? "";
72
+ }
73
+ /** Whether this check already has its isolated PostgreSQL without Docker. */
74
+ export function isolatedPostgresProvided(checkId, environment, postgresAdminConnection) {
75
+ if (checkId === "playwright-e2e") {
76
+ const attemptId = environmentValue(environment, "FORGE_DISPATCH_ATTEMPT_ID");
77
+ return (environmentValue(environment, "FORGE_E2E_OWNERSHIP_MODE") === "attempt"
78
+ || /^[0-9a-f-]{36}$/iu.test(attemptId))
79
+ && /^forge_attempt_[0-9a-f]{32}$/u.test(environmentValue(environment, "FORGE_ATTEMPT_DATABASE_SCHEMA"))
80
+ && path.isAbsolute(environmentValue(environment, "FORGE_ATTEMPT_DATABASE_READINESS_PATH"))
81
+ // The attempt owns a database only once the Bridge's broker has issued it one.
82
+ && environmentValue(environment, attemptDatabaseCapabilityEnvironment).length > 0;
83
+ }
84
+ return Boolean(postgresAdminConnection);
85
+ }
86
+ /**
87
+ * The grant, when it makes its check Docker-free. A native_preferred grant still lets
88
+ * pinned-engine tests start Docker containers, so a Docker loss during its check stays
89
+ * retryable infrastructure; only a native_fallback grant (Docker was already down) does not.
90
+ */
91
+ export function dockerFreeGrant(grant) {
92
+ return grant?.mode === nativeTestPostgresFallbackDatabaseMode ? grant : undefined;
93
+ }
94
+ /**
95
+ * Releases a check's ephemeral cluster once the check has ended. A cluster that would not stop
96
+ * is left disowned for the next start's reap and does not change the check's own result.
97
+ */
98
+ export async function releaseCheckPostgres(checkId, grant, emit) {
99
+ try {
100
+ await grant?.release?.();
101
+ }
102
+ catch (error) {
103
+ await emit?.(validationEvent("prepublication_ephemeral_release_failed", checkId, `The ephemeral PostgreSQL test cluster for '${checkId}' could not be released and will be reaped later: ${error instanceof Error ? error.message : String(error)}`)).catch(() => undefined);
104
+ }
105
+ }
106
+ /** The native cluster grant for a check while Docker stays down, or null when it cannot use one. */
107
+ export function dockerUnavailableNativeTestPostgres(checkId, requiredPrerequisite, readCluster) {
108
+ return requiredPrerequisite === "isolated_postgres" && supportsNativeTestPostgresFallback(checkId)
109
+ ? nativeTestPostgresGrant(readCluster(), false)
110
+ : null;
111
+ }
@@ -0,0 +1,61 @@
1
+ import type { ValidationStep } from "./pre-publication-step-execution.js";
2
+ import { ForgeFailureError, type RunnerDispatchEvent } from "./session.types.js";
3
+ /** The check id a failed restart of the attempt's runtime stack before the pass is reported under. */
4
+ export declare const runtimeRestartCheckId = "host-runtime-restart";
5
+ /** One check that failed in a pass: the step that failed and its clipped diagnostics. */
6
+ export interface PrePublicationCheckFailure {
7
+ readonly checkId: string;
8
+ readonly exitCode: number;
9
+ readonly command: string;
10
+ readonly args: readonly string[];
11
+ readonly detail: string;
12
+ }
13
+ /**
14
+ * A failed validation pass. The single-check fields name the first failure, as they always have;
15
+ * `failures` lists every check that failed in the pass, in the order the checks ran.
16
+ */
17
+ export declare class PrePublicationValidationError extends ForgeFailureError {
18
+ readonly checkId: string;
19
+ readonly exitCode: number;
20
+ readonly command: string;
21
+ readonly args: readonly string[];
22
+ readonly detail: string;
23
+ readonly code = "prepublication_validation_failed";
24
+ readonly failures: readonly PrePublicationCheckFailure[];
25
+ constructor(checkId: string, exitCode: number, command: string, args: readonly string[], detail: string, additionalFailures?: readonly PrePublicationCheckFailure[]);
26
+ /** Every failed check's id, first failure first. */
27
+ get checkIds(): readonly string[];
28
+ }
29
+ export declare class PrePublicationPass {
30
+ private readonly runtimeRestartFailure?;
31
+ private readonly failures;
32
+ /** The check whose .NET build failed to compile in this pass, if any. */
33
+ private dotnetCompileFailedIn;
34
+ /** A failed runtime restart before the pass is its first failure. */
35
+ constructor(runtimeRestartFailure?: PrePublicationValidationError | undefined);
36
+ record(failure: PrePublicationCheckFailure, failedStep?: ValidationStep): void;
37
+ /** The failed checks that keep this check from running meaningfully in this pass. */
38
+ blockers(checkId: string): readonly string[];
39
+ /**
40
+ * Whether an error ends the pass with the failures it already found. Only a classified retryable
41
+ * failure (a resource hold, lost infrastructure, a supervisor that did not start) does, once the
42
+ * pass has found a failure: the repair turn can fix those failures now, and the next pass meets
43
+ * the condition again. Any other error, or cancellation, still ends the attempt as it did.
44
+ */
45
+ stopsAt(error: unknown, signal?: AbortSignal): error is ForgeFailureError;
46
+ stoppedEvent(checkId: string, error: ForgeFailureError): RunnerDispatchEvent;
47
+ /** Throws every failure the pass found as one validation failure. */
48
+ throwIfFailed(): void;
49
+ }
50
+ export declare function skippedCheckEvent(checkId: string, blockedBy: readonly string[]): RunnerDispatchEvent;
51
+ /** The tests a check's steps skipped, so a check that passed with skips says so with each reason. */
52
+ export declare class SkippedTestTally {
53
+ private readonly worktreePath;
54
+ private readonly environment?;
55
+ private summary;
56
+ constructor(worktreePath: string, environment?: Readonly<Record<string, string>> | undefined);
57
+ /** The invocation's own arguments: a managed attempt may direct results to its test-output root. */
58
+ add(args: readonly string[], stepStartedMs: number): Promise<void>;
59
+ passedEvent(checkId: string, secrets: readonly string[]): RunnerDispatchEvent;
60
+ }
61
+ export declare function validationEvent(eventType: string, checkId: string, content: string, detail?: Readonly<Record<string, unknown>>): RunnerDispatchEvent;
@@ -0,0 +1,148 @@
1
+ import { redactText } from "../shared/redaction/redaction.js";
2
+ import { describeSkippedTests, mergeSkippedTests, readSkippedTests, } from "./pre-publication-skipped-tests.js";
3
+ import { ForgeFailureError, failureFactsFromError } from "./session.types.js";
4
+ // One pre-publication validation pass. A failed check no longer ends the pass: the remaining checks
5
+ // that can still meaningfully run keep going, so one in-place repair turn sees every independent
6
+ // failure at once instead of one per turn. The pass records each failure, says which checks it
7
+ // could not run because a check they depend on failed, and reports them all as one failure.
8
+ /** The check id a failed restart of the attempt's runtime stack before the pass is reported under. */
9
+ export const runtimeRestartCheckId = "host-runtime-restart";
10
+ // The checks whose first step builds the .NET solution: CI's whole-tier check and the affected
11
+ // tests every gate profile runs (decision 0017).
12
+ const dotnetBuildCheckIds = new Set(["dotnet-build-and-unit", "comment-repair-dotnet-regression"]);
13
+ // Checks that build the .NET solution themselves and would only repeat the compiler errors once its
14
+ // compile step fails: the OpenAPI export builds Forge.Api and the E2E suite publishes it.
15
+ const dotnetBuildConsumers = new Set(["openapi-and-generated-types", "playwright-e2e"]);
16
+ // Checks that run against the attempt's application stack, which a failed restart left stopped.
17
+ const runtimeStackConsumers = new Set(["playwright-e2e"]);
18
+ // The diagnostics of each further failure that the error message carries; the repair prompt
19
+ // carries every failure's diagnostics in full.
20
+ const additionalFailureMessageDetail = 1500;
21
+ /**
22
+ * A failed validation pass. The single-check fields name the first failure, as they always have;
23
+ * `failures` lists every check that failed in the pass, in the order the checks ran.
24
+ */
25
+ export class PrePublicationValidationError extends ForgeFailureError {
26
+ checkId;
27
+ exitCode;
28
+ command;
29
+ args;
30
+ detail;
31
+ code = "prepublication_validation_failed";
32
+ failures;
33
+ constructor(checkId, exitCode, command, args, detail, additionalFailures = []) {
34
+ super("prepublication_validation_failed", validationFailureMessage([{ checkId, exitCode, command, args, detail }, ...additionalFailures]), "bridge");
35
+ this.checkId = checkId;
36
+ this.exitCode = exitCode;
37
+ this.command = command;
38
+ this.args = args;
39
+ this.detail = detail;
40
+ this.name = "PrePublicationValidationError";
41
+ this.failures = [{ checkId, exitCode, command, args, detail }, ...additionalFailures];
42
+ }
43
+ /** Every failed check's id, first failure first. */
44
+ get checkIds() {
45
+ return this.failures.map(failure => failure.checkId);
46
+ }
47
+ }
48
+ function validationFailureMessage(failures) {
49
+ const [first, ...others] = failures;
50
+ const summary = (failure, detail) => `${failure.checkId} exited ${failure.exitCode}${detail ? `: ${detail}` : ""}`;
51
+ if (others.length === 0)
52
+ return `prepublication_validation_failed: ${summary(first, first.detail)}`;
53
+ // The other check ids come before the first detail, so a clipped failure message still names them.
54
+ const also = `[also failed: ${others.map(failure => failure.checkId).join(", ")}]`;
55
+ const more = others.map(failure => summary(failure, clipDetail(failure.detail)));
56
+ return `prepublication_validation_failed: ${first.checkId} exited ${first.exitCode} ${also}${first.detail ? `: ${first.detail}` : ""}`
57
+ + `\n\nAlso failed in the same validation pass: ${more.join("\n\n")}`;
58
+ }
59
+ function clipDetail(detail) {
60
+ return detail.length <= additionalFailureMessageDetail
61
+ ? detail
62
+ : `${detail.slice(0, additionalFailureMessageDetail)}… (clipped)`;
63
+ }
64
+ export class PrePublicationPass {
65
+ runtimeRestartFailure;
66
+ failures = [];
67
+ /** The check whose .NET build failed to compile in this pass, if any. */
68
+ dotnetCompileFailedIn = null;
69
+ /** A failed runtime restart before the pass is its first failure. */
70
+ constructor(runtimeRestartFailure) {
71
+ this.runtimeRestartFailure = runtimeRestartFailure;
72
+ this.failures.push(...runtimeRestartFailure?.failures ?? []);
73
+ }
74
+ record(failure, failedStep) {
75
+ this.failures.push(failure);
76
+ if (dotnetBuildCheckIds.has(failure.checkId) && failedStep?.command === "dotnet" && failedStep.args[0] === "build") {
77
+ this.dotnetCompileFailedIn ??= failure.checkId;
78
+ }
79
+ }
80
+ /** The failed checks that keep this check from running meaningfully in this pass. */
81
+ blockers(checkId) {
82
+ return [
83
+ ...(this.dotnetCompileFailedIn && dotnetBuildConsumers.has(checkId) ? [this.dotnetCompileFailedIn] : []),
84
+ ...(this.runtimeRestartFailure && runtimeStackConsumers.has(checkId) ? [runtimeRestartCheckId] : []),
85
+ ];
86
+ }
87
+ /**
88
+ * Whether an error ends the pass with the failures it already found. Only a classified retryable
89
+ * failure (a resource hold, lost infrastructure, a supervisor that did not start) does, once the
90
+ * pass has found a failure: the repair turn can fix those failures now, and the next pass meets
91
+ * the condition again. Any other error, or cancellation, still ends the attempt as it did.
92
+ */
93
+ stopsAt(error, signal) {
94
+ if (this.failures.length === 0 || signal?.aborted || !(error instanceof ForgeFailureError))
95
+ return false;
96
+ return failureFactsFromError(error).retryability === "retryable";
97
+ }
98
+ stoppedEvent(checkId, error) {
99
+ const failedCheckIds = this.failures.map(failure => failure.checkId);
100
+ return validationEvent("prepublication_validation_pass_stopped", checkId, `Stopped this pre-publication pass at '${checkId}' (${error.failureCode}). Reporting the ${failedCheckIds.length} failed check${failedCheckIds.length === 1 ? "" : "s"} it already found (${failedCheckIds.join(", ")}) for repair; the next pass runs '${checkId}' again.`, { failureCode: error.failureCode, failedCheckIds });
101
+ }
102
+ /** Throws every failure the pass found as one validation failure. */
103
+ throwIfFailed() {
104
+ const [first, ...others] = this.failures;
105
+ if (!first)
106
+ return;
107
+ throw new PrePublicationValidationError(first.checkId, first.exitCode, first.command, first.args, first.detail, others);
108
+ }
109
+ }
110
+ export function skippedCheckEvent(checkId, blockedBy) {
111
+ const reason = blockedBy.map(blocker => blocker === runtimeRestartCheckId
112
+ ? "the attempt's runtime stack, whose restart failed"
113
+ : `the .NET build, which failed in '${blocker}'`).join(" and ");
114
+ return validationEvent("prepublication_validation_skipped", checkId, `Skipped pre-publication CI parity check '${checkId}' in this pass: it needs ${reason}. The next pass runs it again.`, { blockedBy });
115
+ }
116
+ /** The tests a check's steps skipped, so a check that passed with skips says so with each reason. */
117
+ export class SkippedTestTally {
118
+ worktreePath;
119
+ environment;
120
+ summary = { count: 0, reasons: [] };
121
+ constructor(worktreePath, environment) {
122
+ this.worktreePath = worktreePath;
123
+ this.environment = environment;
124
+ }
125
+ /** The invocation's own arguments: a managed attempt may direct results to its test-output root. */
126
+ async add(args, stepStartedMs) {
127
+ this.summary = mergeSkippedTests(this.summary, await readSkippedTests(this.worktreePath, args, stepStartedMs, this.environment));
128
+ }
129
+ passedEvent(checkId, secrets) {
130
+ const skipped = {
131
+ ...this.summary,
132
+ reasons: this.summary.reasons.map(entry => ({ ...entry, reason: redactText(entry.reason, secrets) })),
133
+ };
134
+ if (skipped.count === 0) {
135
+ return validationEvent("prepublication_validation_passed", checkId, `Pre-publication CI parity check '${checkId}' passed.`);
136
+ }
137
+ return validationEvent("prepublication_validation_passed", checkId, `Pre-publication CI parity check '${checkId}' passed with ${describeSkippedTests(skipped)}.`, { skippedTests: skipped.count, skippedReasons: skipped.reasons });
138
+ }
139
+ }
140
+ export function validationEvent(eventType, checkId, content, detail) {
141
+ return {
142
+ role: "runner",
143
+ kind: "checkpoint",
144
+ content,
145
+ eventType,
146
+ data: JSON.stringify({ checkId, contractId: "forge-ci-parity-v1", ...detail }),
147
+ };
148
+ }
@@ -0,0 +1,23 @@
1
+ import type { PrePublicationCommandResult, PrePublicationCommandRunner } from "./pre-publication-validation.js";
2
+ /** Output kept per stream for one validation step (the tail). */
3
+ export declare const prePublicationOutputLimitChars: number;
4
+ export declare class ProcessPrePublicationCommandRunner implements PrePublicationCommandRunner {
5
+ run(command: string, args: readonly string[], cwd: string, signal?: AbortSignal, environment?: Readonly<Record<string, string>>): Promise<PrePublicationCommandResult>;
6
+ }
7
+ export declare function prePublicationChildEnvironment(environment?: Readonly<Record<string, string>>): NodeJS.ProcessEnv;
8
+ interface PackageManagerLaunchLocation {
9
+ readonly args: readonly string[];
10
+ readonly cwd: string;
11
+ }
12
+ /**
13
+ * Corepack picks the pnpm version from the nearest package.json `packageManager`
14
+ * pin at or above the process working directory; pnpm's own `--dir` is not
15
+ * consulted. The repository root carries no pin, so `pnpm --dir client ...`
16
+ * launched from the root would run Corepack's host-global default, and pnpm
17
+ * then refuses client's pin (ERR_PNPM_BAD_PM_VERSION). `pnpm --dir X cmd` is
18
+ * `pnpm cmd` run from X, so launch from X and let Corepack walk up from there
19
+ * to the nearest pin. Targets that are absolute, leave the worktree, or do not
20
+ * exist stay unchanged so pnpm reports them itself.
21
+ */
22
+ export declare function pnpmDirectoryLaunch(command: string, args: readonly string[], cwd: string): Promise<PackageManagerLaunchLocation>;
23
+ export {};
@@ -0,0 +1,109 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { hostRuntimeLegacyTestPostgresEnvironment, hostRuntimeTestPostgresAdminEnvironment, hostRuntimeTestPostgresProvisionerEnvironment, } from "../runtime/host-runtime-contract.js";
4
+ import { withoutHostLoadGovernorVariables } from "../runtime/host-load-child-environment.js";
5
+ import { isSubPath } from "../shared/path/path.js";
6
+ import { NodeProcessRunner, ProcessTreeTerminationError } from "../shared/process/process.js";
7
+ import { buildWindowsCmdLaunch } from "../shared/process/windows-launch.js";
8
+ /** Output kept per stream for one validation step (the tail). */
9
+ export const prePublicationOutputLimitChars = 4 * 1024 * 1024;
10
+ export class ProcessPrePublicationCommandRunner {
11
+ async run(command, args, cwd, signal, environment) {
12
+ try {
13
+ const launch = await pnpmDirectoryLaunch(command, args, cwd);
14
+ // npm and pnpm are batch files on Windows, run through cmd.exe. Its command line is
15
+ // passed verbatim: Node's own quoting escapes inner quotes as \", which cmd.exe does
16
+ // not read, so a quoted argument reached the package manager with its quotes.
17
+ const windowsBatch = process.platform === "win32" && (command === "npm" || command === "pnpm")
18
+ ? buildWindowsCmdLaunch(`${command}.cmd`, launch.args)
19
+ : null;
20
+ // A process group the runner stops as a whole, settling only once it is gone:
21
+ // a validation step's host capacity is never returned while its test hosts,
22
+ // build nodes or browser workers still run.
23
+ const result = await new NodeProcessRunner().run({
24
+ command: windowsBatch?.command ?? command,
25
+ args: windowsBatch?.args ?? [...launch.args],
26
+ windowsVerbatimArguments: windowsBatch !== null,
27
+ cwd: launch.cwd,
28
+ env: prePublicationChildEnvironment(environment),
29
+ rawOutput: true,
30
+ processGroup: true,
31
+ // The bound execFile had: a noisy step keeps its last 4 MiB (where failures
32
+ // are reported) instead of holding all of its output in the bridge.
33
+ maxOutputChars: prePublicationOutputLimitChars,
34
+ signal,
35
+ });
36
+ return { exitCode: result.exitCode, stdout: result.stdout, stderr: result.stderr };
37
+ }
38
+ catch (error) {
39
+ const failure = error;
40
+ // Neither is a command result: a stop, or a tree that outlived it.
41
+ if (failure.name === "AbortError" || error instanceof ProcessTreeTerminationError)
42
+ throw error;
43
+ if (failure.code === "ENOENT") {
44
+ return { exitCode: 127, stderr: `executable_not_found: ${command}` };
45
+ }
46
+ return {
47
+ exitCode: typeof failure.code === "number" ? failure.code : 1,
48
+ stdout: failure.stdout,
49
+ stderr: failure.stderr ?? failure.message,
50
+ };
51
+ }
52
+ }
53
+ }
54
+ export function prePublicationChildEnvironment(environment) {
55
+ const child = {};
56
+ const privilegedNames = new Set([
57
+ hostRuntimeTestPostgresAdminEnvironment.toLowerCase(),
58
+ hostRuntimeLegacyTestPostgresEnvironment.toLowerCase(),
59
+ hostRuntimeTestPostgresProvisionerEnvironment.toLowerCase(),
60
+ ]);
61
+ for (const [name, value] of Object.entries(process.env)) {
62
+ if (typeof value === "string" && !privilegedNames.has(name.toLowerCase())) {
63
+ child[name] = value;
64
+ }
65
+ }
66
+ // A validation step must not join the host ledger (it would queue behind its own token)
67
+ // or the sandbox broker, whether the variable is inherited or passed in explicitly.
68
+ return withoutHostLoadGovernorVariables({ ...child, ...environment });
69
+ }
70
+ /**
71
+ * Corepack picks the pnpm version from the nearest package.json `packageManager`
72
+ * pin at or above the process working directory; pnpm's own `--dir` is not
73
+ * consulted. The repository root carries no pin, so `pnpm --dir client ...`
74
+ * launched from the root would run Corepack's host-global default, and pnpm
75
+ * then refuses client's pin (ERR_PNPM_BAD_PM_VERSION). `pnpm --dir X cmd` is
76
+ * `pnpm cmd` run from X, so launch from X and let Corepack walk up from there
77
+ * to the nearest pin. Targets that are absolute, leave the worktree, or do not
78
+ * exist stay unchanged so pnpm reports them itself.
79
+ */
80
+ export async function pnpmDirectoryLaunch(command, args, cwd) {
81
+ const unchanged = { args, cwd };
82
+ if (command !== "pnpm")
83
+ return unchanged;
84
+ const target = pnpmDirectoryArgument(args);
85
+ if (!target || path.isAbsolute(target.directory))
86
+ return unchanged;
87
+ if (!isSubPath(cwd, path.resolve(cwd, target.directory)))
88
+ return unchanged;
89
+ // The lexical check alone would let a symlink (or junction) inside the worktree
90
+ // move the child's cwd outside it, so compare and launch from real paths.
91
+ const realCwd = await fs.realpath(cwd).catch(() => null);
92
+ const packageDirectory = await fs.realpath(path.resolve(cwd, target.directory)).catch(() => null);
93
+ if (!realCwd || !packageDirectory || !isSubPath(realCwd, packageDirectory))
94
+ return unchanged;
95
+ const stat = await fs.stat(packageDirectory).catch(() => null);
96
+ if (!stat?.isDirectory())
97
+ return unchanged;
98
+ return { args: args.slice(target.consumed), cwd: packageDirectory };
99
+ }
100
+ /** Reads a leading `--dir X`, `--dir=X`, `-C X`, `-CX` or `-C=X`. */
101
+ function pnpmDirectoryArgument(args) {
102
+ const first = args[0] ?? "";
103
+ if (first === "--dir" || first === "-C")
104
+ return args[1] ? { directory: args[1], consumed: 2 } : null;
105
+ const inline = first.startsWith("--dir=") ? first.slice("--dir=".length)
106
+ : first.startsWith("-C") ? first.slice(2).replace(/^=/u, "")
107
+ : "";
108
+ return inline ? { directory: inline, consumed: 1 } : null;
109
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Skipped .NET tests from the TRX files a validation step wrote, so a run that skipped tests reads as
3
+ * "passed with N skipped (reasons)" rather than a plain pass. Only files under the step's declared results
4
+ * directory and written since the step started count, and that directory must resolve (through symlinks) inside
5
+ * the worktree or the attempt's own test-output root; nothing here can fail a passing step.
6
+ */
7
+ export interface SkippedTestSummary {
8
+ readonly count: number;
9
+ readonly reasons: readonly {
10
+ readonly reason: string;
11
+ readonly count: number;
12
+ }[];
13
+ }
14
+ /** The attempt-owned output root a managed attempt's tests write under, outside the worktree. */
15
+ export declare const attemptTestOutputEnvironment = "FORGE_TEST_OUTPUT_DIR";
16
+ export declare function resultsDirectoryArgument(args: readonly string[]): string | undefined;
17
+ export declare function readSkippedTests(cwd: string, args: readonly string[], sinceMs: number, environment?: Readonly<Record<string, string>>): Promise<SkippedTestSummary>;
18
+ export declare function mergeSkippedTests(left: SkippedTestSummary, right: SkippedTestSummary): SkippedTestSummary;
19
+ export declare function describeSkippedTests(summary: SkippedTestSummary): string;
20
+ /** Each NotExecuted result's skip reason, from its ErrorInfo message (VSTest's TRX shape). */
21
+ export declare function skippedReasons(trx: string): string[];