@loucompanion/forge-bridge 0.1.4-dev.fb770705136a → 0.2.1-dev.0f8fb73715e8

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 (329) hide show
  1. package/README.md +183 -4
  2. package/dist/bridge/bridge-chat-giphy-look.d.ts +48 -0
  3. package/dist/bridge/bridge-chat-giphy-look.js +55 -0
  4. package/dist/bridge/bridge-chat-provider-command.d.ts +40 -0
  5. package/dist/bridge/bridge-chat-provider-command.js +230 -0
  6. package/dist/bridge/bridge-chat.types.d.ts +20 -0
  7. package/dist/bridge/bridge-chat.types.js +28 -1
  8. package/dist/bridge/bridge-state-file.d.ts +161 -0
  9. package/dist/bridge/bridge-state-file.js +376 -0
  10. package/dist/bridge/bridge-state-io.d.ts +15 -0
  11. package/dist/bridge/bridge-state-io.js +68 -0
  12. package/dist/bridge/bridge-state-lock.d.ts +11 -0
  13. package/dist/bridge/bridge-state-lock.js +102 -0
  14. package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
  15. package/dist/bridge/bridge-state-unpublished.js +111 -0
  16. package/dist/bridge/bridge.base.d.ts +9 -0
  17. package/dist/bridge/bridge.service.d.ts +102 -14
  18. package/dist/bridge/bridge.service.js +499 -471
  19. package/dist/bridge/bridge.types.d.ts +37 -0
  20. package/dist/bridge/bridge.types.js +2 -1
  21. package/dist/bridge/default-session-service.d.ts +13 -0
  22. package/dist/bridge/default-session-service.js +22 -0
  23. package/dist/bridge/dispatch-offer-policy.d.ts +22 -0
  24. package/dist/bridge/dispatch-offer-policy.js +58 -0
  25. package/dist/bridge/in-flight-registry.d.ts +62 -0
  26. package/dist/bridge/in-flight-registry.js +207 -0
  27. package/dist/bridge/local-yield-flag.d.ts +6 -0
  28. package/dist/bridge/local-yield-flag.js +34 -0
  29. package/dist/bridge/readiness-result-outbox.d.ts +5 -1
  30. package/dist/bridge/readiness-result-outbox.js +20 -0
  31. package/dist/bridge/runner-host-capabilities.d.ts +5 -0
  32. package/dist/bridge/runner-host-capabilities.js +31 -1
  33. package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
  34. package/dist/bridge/sandbox-resource-accounting.js +150 -0
  35. package/dist/bridge/test-postgres-capability.d.ts +14 -0
  36. package/dist/bridge/test-postgres-capability.js +120 -0
  37. package/dist/bridge/windows-bash-resolution.d.ts +31 -0
  38. package/dist/bridge/windows-bash-resolution.js +153 -0
  39. package/dist/cleanup/cleanup-wip.d.ts +12 -0
  40. package/dist/cleanup/cleanup-wip.js +66 -0
  41. package/dist/cleanup/cleanup.service.d.ts +20 -1
  42. package/dist/cleanup/cleanup.service.js +150 -169
  43. package/dist/cleanup/cleanup.types.d.ts +6 -0
  44. package/dist/cleanup/forge-owned-paths.d.ts +11 -0
  45. package/dist/cleanup/forge-owned-paths.js +62 -0
  46. package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
  47. package/dist/cleanup/host-runtime-ledger.js +130 -0
  48. package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
  49. package/dist/cleanup/managed-branch-sweep.js +111 -0
  50. package/dist/cli/cli.help.js +75 -13
  51. package/dist/cli/cli.service.d.ts +19 -10
  52. package/dist/cli/cli.service.js +161 -228
  53. package/dist/cli/idle-status.d.ts +84 -0
  54. package/dist/cli/idle-status.js +181 -0
  55. package/dist/cli/local-config.d.ts +18 -1
  56. package/dist/cli/local-config.js +67 -5
  57. package/dist/cli/provider-cli-advertising.d.ts +24 -0
  58. package/dist/cli/provider-cli-advertising.js +88 -0
  59. package/dist/cli/provider-cli-detection.d.ts +10 -0
  60. package/dist/cli/provider-cli-detection.js +160 -0
  61. package/dist/runtime/aspnet-runtime-prebuild.d.ts +20 -0
  62. package/dist/runtime/aspnet-runtime-prebuild.js +184 -18
  63. package/dist/runtime/attempt-database-broker.d.ts +1 -1
  64. package/dist/runtime/attempt-node-runtime-launcher.d.ts +36 -0
  65. package/dist/runtime/attempt-node-runtime-launcher.js +169 -0
  66. package/dist/runtime/attempt-process-supervisor.d.ts +2 -0
  67. package/dist/runtime/attempt-process-supervisor.js +12 -6
  68. package/dist/runtime/docker-engine-probe.d.ts +5 -0
  69. package/dist/runtime/docker-engine-probe.js +7 -0
  70. package/dist/runtime/dotnet-build-outputs.d.ts +107 -0
  71. package/dist/runtime/dotnet-build-outputs.js +402 -0
  72. package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
  73. package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
  74. package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
  75. package/dist/runtime/ephemeral-test-postgres.js +303 -0
  76. package/dist/runtime/host-facts.d.ts +2 -1
  77. package/dist/runtime/host-listener-inspector.d.ts +26 -0
  78. package/dist/runtime/host-listener-inspector.js +84 -3
  79. package/dist/runtime/host-load-admission.d.ts +72 -0
  80. package/dist/runtime/host-load-admission.js +99 -0
  81. package/dist/runtime/host-load-capacity.d.ts +198 -0
  82. package/dist/runtime/host-load-capacity.js +353 -0
  83. package/dist/runtime/host-load-child-environment.d.ts +40 -0
  84. package/dist/runtime/host-load-child-environment.js +110 -0
  85. package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
  86. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  87. package/dist/runtime/host-load-governor-config.d.ts +82 -0
  88. package/dist/runtime/host-load-governor-config.js +104 -0
  89. package/dist/runtime/host-load-governor.d.ts +273 -0
  90. package/dist/runtime/host-load-governor.js +831 -0
  91. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  92. package/dist/runtime/host-load-ledger-lock.js +187 -0
  93. package/dist/runtime/host-load-live-test-slots.d.ts +61 -0
  94. package/dist/runtime/host-load-live-test-slots.js +193 -0
  95. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  96. package/dist/runtime/host-load-runtime-settings.js +80 -0
  97. package/dist/runtime/host-load-sampler.d.ts +92 -2
  98. package/dist/runtime/host-load-sampler.js +166 -8
  99. package/dist/runtime/host-load-step-class.d.ts +70 -0
  100. package/dist/runtime/host-load-step-class.js +161 -0
  101. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  102. package/dist/runtime/host-load-step-reaper.js +95 -0
  103. package/dist/runtime/host-load-step-run.d.ts +107 -0
  104. package/dist/runtime/host-load-step-run.js +158 -0
  105. package/dist/runtime/host-load-test-slot.d.ts +46 -0
  106. package/dist/runtime/host-load-test-slot.js +100 -0
  107. package/dist/runtime/host-load-token-ledger.d.ts +200 -0
  108. package/dist/runtime/host-load-token-ledger.js +453 -0
  109. package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
  110. package/dist/runtime/host-load-windows-cpu.js +85 -0
  111. package/dist/runtime/host-pressure-stall.d.ts +21 -1
  112. package/dist/runtime/host-pressure-stall.js +48 -1
  113. package/dist/runtime/host-runtime-contract.d.ts +15 -0
  114. package/dist/runtime/host-runtime-contract.js +39 -6
  115. package/dist/runtime/host-runtime-lease.d.ts +101 -6
  116. package/dist/runtime/host-runtime-lease.js +408 -294
  117. package/dist/runtime/host-runtime-ledger-recovery.d.ts +20 -0
  118. package/dist/runtime/host-runtime-ledger-recovery.js +134 -0
  119. package/dist/runtime/host-runtime-promotion.d.ts +101 -2
  120. package/dist/runtime/host-runtime-promotion.js +355 -14
  121. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  122. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  123. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  124. package/dist/runtime/host-runtime-requirements.js +117 -0
  125. package/dist/runtime/managed-command-teardown.js +5 -16
  126. package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
  127. package/dist/runtime/native-test-postgres-fallback.js +60 -8
  128. package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
  129. package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
  130. package/dist/runtime/prepared-runtime-identity.d.ts +4 -0
  131. package/dist/runtime/prepared-runtime-identity.js +130 -9
  132. package/dist/runtime/prepared-runtime-readiness.d.ts +23 -1
  133. package/dist/runtime/prepared-runtime-readiness.js +89 -18
  134. package/dist/runtime/runner-settings.d.ts +104 -0
  135. package/dist/runtime/runner-settings.js +236 -0
  136. package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
  137. package/dist/runtime/supervised-runtime-build-guard.js +112 -0
  138. package/dist/sandbox/host-capacity-broker.d.ts +115 -0
  139. package/dist/sandbox/host-capacity-broker.js +336 -0
  140. package/dist/sandbox/managed-branch.d.ts +13 -0
  141. package/dist/sandbox/managed-branch.js +90 -0
  142. package/dist/sandbox/provider-auth/codex.js +11 -11
  143. package/dist/sandbox/runtime.d.ts +11 -3
  144. package/dist/sandbox/runtime.js +53 -20
  145. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  146. package/dist/sandbox/sandbox-cgroups.js +42 -0
  147. package/dist/sandbox/sandbox-input.d.ts +22 -0
  148. package/dist/sandbox/sandbox-input.js +49 -0
  149. package/dist/sandbox/workspace.service.js +15 -2
  150. package/dist/session/architect-waits.d.ts +2 -0
  151. package/dist/session/architect-waits.js +138 -0
  152. package/dist/session/managed-attempt-tools.d.ts +2 -7
  153. package/dist/session/managed-attempt-tools.js +204 -141
  154. package/dist/session/managed-build-coordinator.d.ts +16 -0
  155. package/dist/session/managed-build-coordinator.js +10 -0
  156. package/dist/session/managed-build-receipt.d.ts +7 -0
  157. package/dist/session/managed-build-receipt.js +11 -3
  158. package/dist/session/managed-command-environment.d.ts +8 -0
  159. package/dist/session/managed-command-environment.js +28 -0
  160. package/dist/session/managed-command-host-load.d.ts +52 -0
  161. package/dist/session/managed-command-host-load.js +87 -0
  162. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  163. package/dist/session/mcp-argument-coercion.js +121 -0
  164. package/dist/session/phase-completion.artifact-bundle.d.ts +20 -0
  165. package/dist/session/phase-completion.artifact-bundle.js +167 -0
  166. package/dist/session/phase-completion.artifacts.d.ts +9 -17
  167. package/dist/session/phase-completion.artifacts.js +158 -190
  168. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  169. package/dist/session/phase-completion.command-validation.js +77 -0
  170. package/dist/session/phase-completion.d.ts +31 -2
  171. package/dist/session/phase-completion.helpers.js +18 -65
  172. package/dist/session/phase-completion.js +19 -32
  173. package/dist/session/phase-completion.mcp-args.d.ts +9 -0
  174. package/dist/session/phase-completion.mcp-args.js +195 -0
  175. package/dist/session/phase-completion.phase-aliases.d.ts +5 -0
  176. package/dist/session/phase-completion.phase-aliases.js +43 -0
  177. package/dist/session/phase-completion.pr-review-schema.d.ts +1 -0
  178. package/dist/session/phase-completion.pr-review-schema.js +75 -0
  179. package/dist/session/phase-completion.pr-review-validation.d.ts +11 -0
  180. package/dist/session/phase-completion.pr-review-validation.js +212 -0
  181. package/dist/session/phase-completion.pr-review.d.ts +36 -0
  182. package/dist/session/phase-completion.pr-review.js +294 -0
  183. package/dist/session/phase-completion.prompts.d.ts +1 -1
  184. package/dist/session/phase-completion.prompts.js +20 -1
  185. package/dist/session/phase-completion.runtime.d.ts +13 -12
  186. package/dist/session/phase-completion.runtime.js +113 -214
  187. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  188. package/dist/session/phase-completion.schema-parts.js +188 -0
  189. package/dist/session/phase-completion.schemas.d.ts +3 -3
  190. package/dist/session/phase-completion.schemas.js +219 -232
  191. package/dist/session/phase-completion.validation.d.ts +3 -3
  192. package/dist/session/phase-completion.validation.js +58 -94
  193. package/dist/session/pr-review-diff-base.d.ts +18 -0
  194. package/dist/session/pr-review-diff-base.js +44 -0
  195. package/dist/session/pr-review-placement.d.ts +50 -0
  196. package/dist/session/pr-review-placement.js +91 -0
  197. package/dist/session/pre-publication-change-set.d.ts +62 -0
  198. package/dist/session/pre-publication-change-set.js +166 -0
  199. package/dist/session/pre-publication-host-load.d.ts +27 -0
  200. package/dist/session/pre-publication-host-load.js +112 -0
  201. package/dist/session/pre-publication-native-postgres.d.ts +30 -0
  202. package/dist/session/pre-publication-native-postgres.js +111 -0
  203. package/dist/session/pre-publication-pass.d.ts +61 -0
  204. package/dist/session/pre-publication-pass.js +148 -0
  205. package/dist/session/pre-publication-process.d.ts +3 -0
  206. package/dist/session/pre-publication-process.js +32 -19
  207. package/dist/session/pre-publication-step-execution.d.ts +12 -0
  208. package/dist/session/pre-publication-step-execution.js +50 -0
  209. package/dist/session/pre-publication-validation.d.ts +39 -22
  210. package/dist/session/pre-publication-validation.js +241 -207
  211. package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
  212. package/dist/session/provider-cli/claude-background-work.js +181 -0
  213. package/dist/session/provider-cli/dispatch-target-branch.d.ts +7 -0
  214. package/dist/session/provider-cli/dispatch-target-branch.js +8 -0
  215. package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
  216. package/dist/session/provider-cli/host-build-lock.js +30 -0
  217. package/dist/session/provider-cli/pr-review-credential-isolation.d.ts +83 -0
  218. package/dist/session/provider-cli/pr-review-credential-isolation.js +144 -0
  219. package/dist/session/provider-cli/pr-review-guardrails.d.ts +70 -0
  220. package/dist/session/provider-cli/pr-review-guardrails.js +360 -0
  221. package/dist/session/provider-cli/pr-review-prompt.d.ts +2 -0
  222. package/dist/session/provider-cli/pr-review-prompt.js +119 -0
  223. package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
  224. package/dist/session/provider-cli/pre-publication-repair.js +281 -0
  225. package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
  226. package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
  227. package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
  228. package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
  229. package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
  230. package/dist/session/provider-cli/provider-cli.deterministic.d.ts +1 -0
  231. package/dist/session/provider-cli/provider-cli.deterministic.js +5 -0
  232. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +6 -3
  233. package/dist/session/provider-cli/provider-cli.merge-integrity.js +29 -10
  234. package/dist/session/provider-cli/provider-cli.pr-review.d.ts +23 -0
  235. package/dist/session/provider-cli/provider-cli.pr-review.js +213 -0
  236. package/dist/session/provider-cli/provider-cli.process.d.ts +15 -36
  237. package/dist/session/provider-cli/provider-cli.process.js +41 -432
  238. package/dist/session/provider-cli/provider-cli.prompts.d.ts +15 -3
  239. package/dist/session/provider-cli/provider-cli.prompts.js +183 -90
  240. package/dist/session/provider-cli/provider-cli.reapply-conflicts.d.ts +10 -0
  241. package/dist/session/provider-cli/provider-cli.reapply-conflicts.js +37 -0
  242. package/dist/session/provider-cli/provider-cli.runtime.d.ts +15 -0
  243. package/dist/session/provider-cli/provider-cli.runtime.js +43 -1
  244. package/dist/session/provider-cli/provider-cli.service-support.d.ts +37 -0
  245. package/dist/session/provider-cli/provider-cli.service-support.js +146 -0
  246. package/dist/session/provider-cli/provider-cli.service.d.ts +18 -18
  247. package/dist/session/provider-cli/provider-cli.service.js +127 -317
  248. package/dist/session/provider-cli/provider-cli.types.d.ts +35 -0
  249. package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
  250. package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
  251. package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
  252. package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
  253. package/dist/session/provider-cli/provider-in-flight-work.d.ts +4 -0
  254. package/dist/session/provider-cli/provider-in-flight-work.js +45 -0
  255. package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
  256. package/dist/session/provider-cli/provider-output-pipes.js +67 -0
  257. package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
  258. package/dist/session/provider-cli/provider-output-state.js +6 -0
  259. package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
  260. package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
  261. package/dist/session/qa-sidecar-validation.d.ts +6 -0
  262. package/dist/session/qa-sidecar-validation.js +28 -0
  263. package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
  264. package/dist/session/sandbox-host-capacity-gate.js +279 -0
  265. package/dist/session/session-host-project.d.ts +22 -0
  266. package/dist/session/session-host-project.js +98 -0
  267. package/dist/session/session-redaction.js +31 -181
  268. package/dist/session/session.base.d.ts +9 -1
  269. package/dist/session/session.parse-helpers.d.ts +10 -0
  270. package/dist/session/session.parse-helpers.js +84 -0
  271. package/dist/session/session.runtime-refresh.d.ts +46 -0
  272. package/dist/session/session.runtime-refresh.js +116 -0
  273. package/dist/session/session.service.d.ts +16 -2
  274. package/dist/session/session.service.js +208 -155
  275. package/dist/session/session.types.d.ts +8 -0
  276. package/dist/session/session.types.js +13 -83
  277. package/dist/session/session.types.pr-review.d.ts +48 -0
  278. package/dist/session/session.types.pr-review.js +51 -0
  279. package/dist/session/sidecar-json-shape.d.ts +31 -0
  280. package/dist/session/sidecar-json-shape.js +217 -0
  281. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  282. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  283. package/dist/shared/fs/file-identity.d.ts +10 -0
  284. package/dist/shared/fs/file-identity.js +15 -0
  285. package/dist/shared/fs/replace-file.d.ts +7 -0
  286. package/dist/shared/fs/replace-file.js +33 -0
  287. package/dist/shared/process/host-process-recovery.d.ts +14 -3
  288. package/dist/shared/process/host-process-recovery.js +23 -3
  289. package/dist/shared/process/host-process-supervisor.d.ts +14 -1
  290. package/dist/shared/process/host-process-supervisor.js +67 -15
  291. package/dist/shared/process/process-tree.d.ts +52 -0
  292. package/dist/shared/process/process-tree.js +144 -0
  293. package/dist/shared/process/process.d.ts +67 -0
  294. package/dist/shared/process/process.js +213 -11
  295. package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
  296. package/dist/shared/process/windows-app-execution-alias.js +45 -0
  297. package/dist/shared/process/windows-launch.d.ts +18 -0
  298. package/dist/shared/process/windows-launch.js +68 -0
  299. package/dist/shared/provider-capabilities.d.ts +2 -0
  300. package/dist/shared/provider-capabilities.js +23 -7
  301. package/dist/version.d.ts +1 -1
  302. package/dist/version.js +1 -1
  303. package/dist/worktree/artifact-injector.js +24 -0
  304. package/dist/worktree/dependency-warmer.d.ts +25 -0
  305. package/dist/worktree/dependency-warmer.js +46 -10
  306. package/dist/worktree/orphan-relink.d.ts +19 -0
  307. package/dist/worktree/orphan-relink.js +106 -0
  308. package/dist/worktree/wip-git.d.ts +58 -0
  309. package/dist/worktree/wip-git.js +182 -0
  310. package/dist/worktree/wip-refs.d.ts +85 -0
  311. package/dist/worktree/wip-refs.js +169 -0
  312. package/dist/worktree/wip-restore.d.ts +51 -0
  313. package/dist/worktree/wip-restore.js +324 -0
  314. package/dist/worktree/wip-snapshot.d.ts +53 -0
  315. package/dist/worktree/wip-snapshot.js +270 -0
  316. package/dist/worktree/worktree-inputs.d.ts +8 -0
  317. package/dist/worktree/worktree-inputs.js +134 -0
  318. package/dist/worktree/worktree-origin-sync.d.ts +35 -0
  319. package/dist/worktree/worktree-origin-sync.js +128 -0
  320. package/dist/worktree/worktree-wip-events.d.ts +20 -0
  321. package/dist/worktree/worktree-wip-events.js +148 -0
  322. package/dist/worktree/worktree-wip.d.ts +57 -0
  323. package/dist/worktree/worktree-wip.js +200 -0
  324. package/dist/worktree/worktree.base.d.ts +7 -1
  325. package/dist/worktree/worktree.service.d.ts +58 -5
  326. package/dist/worktree/worktree.service.js +237 -161
  327. package/dist/worktree/worktree.types.d.ts +54 -0
  328. package/package.json +2 -2
  329. package/runtime/windows-listener-owner.ps1 +12 -1
@@ -3,14 +3,19 @@ import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { attemptDatabaseCapabilityEnvironment, attemptDatabaseCapabilitySecrets, } from "../runtime/attempt-database-broker.js";
5
5
  import { assertHostDatabaseCapabilityBoundary } from "../runtime/host-database-capability-boundary.js";
6
- import { nativeTestPostgresFallbackEnvironment, parseNativeTestPostgresFallback, } from "../runtime/native-test-postgres-fallback.js";
6
+ import { runHostGovernedValidationStep } from "./pre-publication-host-load.js";
7
+ import { dockerFreeGrant, dockerUnavailableNativeTestPostgres, isolatedPostgresProvided, preferredNativeTestPostgres, releaseCheckPostgres, } from "./pre-publication-native-postgres.js";
8
+ import { managedAttemptInvocation, validationExecutionForStep, } from "./pre-publication-step-execution.js";
7
9
  import { hostRuntimeLegacyTestPostgresEnvironment, hostRuntimeTestPostgresAdminEnvironment, hostRuntimeTestPostgresProvisionerEnvironment, } from "../runtime/host-runtime-contract.js";
8
10
  import { redactText } from "../shared/redaction/redaction.js";
9
- import { describeSkippedTests, mergeSkippedTests, readSkippedTests, } from "./pre-publication-skipped-tests.js";
11
+ import { PrePublicationPass, PrePublicationValidationError, SkippedTestTally, skippedCheckEvent, validationEvent, } from "./pre-publication-pass.js";
10
12
  import { ProcessPrePublicationCommandRunner, pnpmDirectoryLaunch } from "./pre-publication-process.js";
11
- import { findUnreferencedNewExports } from "./unreferenced-exports.js";
13
+ import { ProcessTreeTerminationError } from "../shared/process/process.js";
14
+ import { findUnreferencedNewExports, historyIntegrityEnvironment, passChangeSet, validationRevisionEnvironment, } from "./pre-publication-change-set.js";
12
15
  import { ForgeFailureError, sanitizeFailureError, } from "./session.types.js";
13
16
  const contractRelativePath = ".forge/validation/ci-parity.v1.json";
17
+ // The check whose steps run scripts/run-affected-dotnet-tests.mjs against the pass's revisions.
18
+ const affectedTestsCheckId = "comment-repair-dotnet-regression";
14
19
  const requiredCheckIds = new Set([
15
20
  "file-size-inventory",
16
21
  "owned-suite-registration",
@@ -21,16 +26,26 @@ const requiredCheckIds = new Set([
21
26
  "playwright-e2e",
22
27
  "github-provider-policy",
23
28
  ]);
24
- const currentApprovedContractDigest = "378c767c7977c850140ffb19d69db41da62d0187c37a33828d6cda8803a61c83";
29
+ // Every gate profile runs the affected .NET tests; only CI runs the whole heavier tiers (decision 0017),
30
+ // even when the selection cannot be narrowed (--whole-fallback none).
31
+ const currentApprovedContractDigest = "69dc8a3ac08bdbea938015584eb02bc3e42ef63f3c14a4ec365859a0e77e7909";
32
+ // The gate ran the whole Infrastructure tier when the affected selection could not be narrowed.
33
+ const infrastructureFallbackContractDigest = "9cf3a3070de56f3d3bc2c013dfa45b0fd463d257722849087e6743fb9cb1fd0d";
34
+ // Only comment repair ran the affected tests; the other profiles ran Unit, Contract and
35
+ // Infrastructure whole. Story branches cut before decision 0017 still carry it.
36
+ const commentRepairOnlyAffectedContractDigest = "378c767c7977c850140ffb19d69db41da62d0187c37a33828d6cda8803a61c83";
25
37
  // Comment repair ran the whole ApiComponent and Orchestration tiers under this contract.
26
- // Story branches cut before the affected-tests contract still carry it.
27
38
  const wholeTierCommentRepairContractDigest = "024de3648c907db9c0eab13def9a4f91e81148433e0a2ba7f44776446421054a";
28
39
  // Contracts that declare the comment-repair-dotnet-regression check.
29
40
  const commentRepairRegressionContractDigests = new Set([
30
41
  currentApprovedContractDigest,
42
+ infrastructureFallbackContractDigest,
43
+ commentRepairOnlyAffectedContractDigest,
31
44
  wholeTierCommentRepairContractDigest,
32
45
  ]);
33
46
  const compatibleApprovedContractDigests = new Set([
47
+ infrastructureFallbackContractDigest,
48
+ commentRepairOnlyAffectedContractDigest,
34
49
  wholeTierCommentRepairContractDigest,
35
50
  // Preserve dispatches pinned before comment repair gained all .NET regression tiers.
36
51
  "c0014ce6abc0e0b2e66dd2bcf6cb14c47d28506444c73f87d1b76b3d1c06027b",
@@ -46,23 +61,31 @@ const approvedContractDigests = new Set([
46
61
  ...compatibleApprovedContractDigests,
47
62
  ]);
48
63
  const ansiColorSequence = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "gu");
49
- export class PrePublicationValidationError extends ForgeFailureError {
50
- checkId;
51
- exitCode;
52
- command;
53
- args;
54
- detail;
55
- code = "prepublication_validation_failed";
56
- constructor(checkId, exitCode, command, args, detail) {
57
- super("prepublication_validation_failed", `prepublication_validation_failed: ${checkId} exited ${exitCode}${detail ? `: ${detail}` : ""}`, "bridge");
58
- this.checkId = checkId;
59
- this.exitCode = exitCode;
60
- this.command = command;
61
- this.args = args;
62
- this.detail = detail;
63
- this.name = "PrePublicationValidationError";
64
- }
65
- }
64
+ const timeoutConfirmation = {
65
+ started: [
66
+ "prepublication_validation_timeout_confirmation_started",
67
+ "The full client test step reported only Vitest timeouts; confirming once with the same command and attempt environment.",
68
+ ],
69
+ passed: [
70
+ "prepublication_validation_timeout_confirmation_passed",
71
+ "The complete client test step passed on its single timeout confirmation run.",
72
+ ],
73
+ failedEvent: "prepublication_validation_timeout_confirmation_failed",
74
+ failedContent: exitCode => `The complete client test step failed on its single timeout confirmation run (exit ${exitCode}).`,
75
+ };
76
+ const cleanupConfirmation = {
77
+ started: [
78
+ "prepublication_validation_cleanup_confirmation_started",
79
+ "The Bridge suite hit the known Windows temporary-worktree cleanup race; confirming once with the same command and attempt environment.",
80
+ ],
81
+ passed: [
82
+ "prepublication_validation_cleanup_confirmation_passed",
83
+ "The complete Bridge test step passed on its single cleanup confirmation run.",
84
+ ],
85
+ failedEvent: "prepublication_validation_cleanup_confirmation_failed",
86
+ failedContent: exitCode => `The complete Bridge test step failed on its single cleanup confirmation run (exit ${exitCode}).`,
87
+ };
88
+ export { PrePublicationValidationError };
66
89
  export class PrePublicationInfrastructureError extends ForgeFailureError {
67
90
  checkId;
68
91
  exitCode;
@@ -84,116 +107,183 @@ export class PrePublicationValidator {
84
107
  commands;
85
108
  dockerEngineProbe;
86
109
  nativeTestPostgresFallback;
87
- constructor(commands = new ProcessPrePublicationCommandRunner(), dockerEngineProbe, nativeTestPostgresFallback = () => null) {
110
+ hostLoad;
111
+ startEphemeral;
112
+ constructor(commands = new ProcessPrePublicationCommandRunner(), dockerEngineProbe, nativeTestPostgresFallback = () => null, hostLoad, startEphemeral) {
88
113
  this.commands = commands;
89
114
  this.dockerEngineProbe = dockerEngineProbe;
90
115
  this.nativeTestPostgresFallback = nativeTestPostgresFallback;
116
+ this.hostLoad = hostLoad;
117
+ this.startEphemeral = startEphemeral;
91
118
  }
119
+ /**
120
+ * Runs one pre-publication pass. A failed check does not end the pass: every remaining check that
121
+ * can still meaningfully run keeps going, and the pass then throws all of its failures as one
122
+ * PrePublicationValidationError.
123
+ */
92
124
  async validate(worktreePath, profile, capabilities, emit, signal, execution) {
93
125
  const checksExports = profile === "implementation" || profile === "comment_repair";
126
+ const pass = new PrePublicationPass(execution?.runtimeRestartFailure);
94
127
  const contract = await loadValidationContract(worktreePath);
95
128
  if (contract === null) {
96
129
  await emit?.(validationEvent("prepublication_validation_legacy_contract", "legacy-provider-validation", `This checkout predates ${contractRelativePath}; Bridge preserved legacy provider validation without source mutation.`));
97
130
  if (checksExports) {
98
131
  const legacy = await prepareValidationExecution(execution);
99
132
  try {
100
- await this.assertNoTestOnlyExports(worktreePath, emit, signal, legacy.execution);
133
+ await this.checkTestOnlyExports(pass, worktreePath, emit, signal, withHistoryIntegrity(legacy.execution));
101
134
  }
102
135
  finally {
103
136
  await legacy.cleanup();
104
137
  }
105
138
  }
139
+ pass.throwIfFailed();
106
140
  return [];
107
141
  }
108
142
  const scoped = await prepareValidationExecution(execution);
109
143
  try {
144
+ // The bridge's own git reads history as committed: no replace refs or grafts the agent planted.
145
+ const historyExecution = withHistoryIntegrity(scoped.execution);
110
146
  if (checksExports)
111
- await this.assertNoTestOnlyExports(worktreePath, emit, signal, scoped.execution);
147
+ await this.checkTestOnlyExports(pass, worktreePath, emit, signal, historyExecution);
112
148
  const contractDigest = validationContractDigest(contract);
113
- await this.assertContractMatchesDispatchBaseline(worktreePath, contractDigest, signal, scoped.execution);
149
+ await this.assertContractMatchesDispatchBaseline(worktreePath, contractDigest, signal, historyExecution);
114
150
  if (contractDigest !== currentApprovedContractDigest) {
115
151
  await emit?.(validationEvent("prepublication_validation_compatible_contract", "validation-contract", `This checkout is pinned to approved compatible CI parity contract ${contractDigest}; the host's current contract is ${currentApprovedContractDigest}.`));
116
152
  }
117
- const changedPaths = await this.changedPaths(worktreePath, signal, scoped.execution);
118
- const selected = applicableChecks(contract, profile, changedPaths);
119
- const completed = [];
120
- for (const check of selected) {
121
- if (check.providerOnly) {
122
- await emit?.(validationEvent("prepublication_validation_provider_only", check.id, `Preserved provider-only validation '${check.id}' for the provider check run.`));
123
- continue;
124
- }
125
- if (check.requiredCapability && !capabilities.has(check.requiredCapability)) {
126
- throw new ForgeFailureError("prepublication_capability_unavailable", `prepublication_capability_unavailable: ${check.id} requires ${check.requiredCapability}; publication is holding until a capable runner is available.`, "bridge");
127
- }
128
- const postgresAdminConnection = await this.ensurePrerequisite(check, scoped.execution?.environment, scoped.postgresAdminConnection, emit) ?? scoped.postgresAdminConnection;
129
- await emit?.(validationEvent("prepublication_validation_started", check.id, `Running pre-publication CI parity check '${check.id}'.`));
130
- let skipped = { count: 0, reasons: [] };
131
- for (const step of check.steps) {
132
- const stepStartedMs = Date.now() - 1000;
133
- let result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection);
134
- await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
135
- if (isTimeoutOnlyClientTestFailure(check.id, step, result)) {
136
- await emit?.(validationEvent("prepublication_validation_timeout_confirmation_started", check.id, "The full client test step reported only Vitest timeouts; confirming once with the same command and attempt environment."));
137
- result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection);
138
- await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
139
- await emit?.(validationEvent(result.exitCode === 0
140
- ? "prepublication_validation_timeout_confirmation_passed"
141
- : "prepublication_validation_timeout_confirmation_failed", check.id, result.exitCode === 0
142
- ? "The complete client test step passed on its single timeout confirmation run."
143
- : `The complete client test step failed on its single timeout confirmation run (exit ${result.exitCode}).`));
144
- }
145
- if (isTransientBridgeCleanupFailure(check.id, step, result)) {
146
- await emit?.(validationEvent("prepublication_validation_cleanup_confirmation_started", check.id, "The Bridge suite hit the known Windows temporary-worktree cleanup race; confirming once with the same command and attempt environment."));
147
- result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection);
148
- await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
149
- await emit?.(validationEvent(result.exitCode === 0
150
- ? "prepublication_validation_cleanup_confirmation_passed"
151
- : "prepublication_validation_cleanup_confirmation_failed", check.id, result.exitCode === 0
152
- ? "The complete Bridge test step passed on its single cleanup confirmation run."
153
- : `The complete Bridge test step failed on its single cleanup confirmation run (exit ${result.exitCode}).`));
154
- }
155
- if (isTransientShellInfrastructureFailure(result)) {
156
- await emit?.(validationEvent("prepublication_infrastructure_confirmation_started", check.id, "The validation shell reported a known host-runtime failure; confirming once with the same command and attempt environment."));
157
- result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection);
158
- await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
159
- const infrastructureFailed = isTransientShellInfrastructureFailure(result);
160
- await emit?.(validationEvent(infrastructureFailed
161
- ? "prepublication_infrastructure_confirmation_failed"
162
- : "prepublication_infrastructure_confirmation_passed", check.id, infrastructureFailed
163
- ? `The validation shell failed again on its single infrastructure confirmation run (exit ${result.exitCode}).`
164
- : result.exitCode === 0
165
- ? "The validation step recovered on its single infrastructure confirmation run."
166
- : "The host-runtime failure did not recur; continuing with normal validation failure handling."));
167
- if (infrastructureFailed) {
168
- const detail = diagnosticDetail(result);
169
- await emit?.(validationEvent("prepublication_infrastructure_failed", check.id, `Pre-publication infrastructure for '${check.id}' remained unavailable${detail ? `: ${detail}` : "."}`));
170
- throw new PrePublicationInfrastructureError(check.id, result.exitCode, result.command, result.args, detail);
171
- }
172
- }
173
- if (result.exitCode !== 0) {
174
- const detail = diagnosticDetail(result);
175
- await emit?.(validationEvent("prepublication_validation_failed", check.id, `Pre-publication CI parity check '${check.id}' exited ${result.exitCode}${detail ? `: ${detail}` : "."}`));
176
- throw new PrePublicationValidationError(check.id, result.exitCode, result.command, result.args, detail);
177
- }
178
- // The invocation's own arguments: a managed attempt may direct results to its test-output root.
179
- skipped = mergeSkippedTests(skipped, await readSkippedTests(worktreePath, result.args, stepStartedMs, scoped.execution?.environment));
180
- }
181
- completed.push(check.id);
182
- // A pass that skipped tests says so, with each reason, instead of reading as a plain pass.
183
- const secrets = validationExactSecrets(scoped.execution?.environment);
184
- skipped = { ...skipped, reasons: skipped.reasons.map(entry => ({ ...entry, reason: redactText(entry.reason, secrets) })) };
185
- const skippedDetail = skipped.count > 0 ? describeSkippedTests(skipped) : undefined;
186
- await emit?.(validationEvent("prepublication_validation_passed", check.id, skippedDetail
187
- ? `Pre-publication CI parity check '${check.id}' passed with ${skippedDetail}.`
188
- : `Pre-publication CI parity check '${check.id}' passed.`, skipped.count > 0 ? { skippedTests: skipped.count, skippedReasons: skipped.reasons } : undefined));
189
- }
190
- return completed;
153
+ const git = (args) => this.runCommand("git", args, worktreePath, signal, historyExecution);
154
+ const { mergeParent, changedPaths } = await passChangeSet(git, scoped.execution, emit);
155
+ const run = {
156
+ worktreePath,
157
+ capabilities,
158
+ emit,
159
+ signal,
160
+ execution: withValidationRevisions(scoped.execution, mergeParent),
161
+ postgresAdminConnection: scoped.postgresAdminConnection,
162
+ };
163
+ return await this.runChecks(applicableChecks(contract, profile, changedPaths), run, pass);
191
164
  }
192
165
  finally {
193
166
  await scoped.cleanup();
194
167
  }
195
168
  }
196
- /** Returns the native fallback connection when this check must use it instead of Docker. */
169
+ async runChecks(checks, run, pass) {
170
+ const completed = [];
171
+ for (const check of checks) {
172
+ if (check.providerOnly) {
173
+ await run.emit?.(validationEvent("prepublication_validation_provider_only", check.id, `Preserved provider-only validation '${check.id}' for the provider check run.`));
174
+ continue;
175
+ }
176
+ const blockedBy = pass.blockers(check.id);
177
+ if (blockedBy.length > 0) {
178
+ await run.emit?.(skippedCheckEvent(check.id, blockedBy));
179
+ continue;
180
+ }
181
+ try {
182
+ const failed = await this.runCheck(check, run);
183
+ // A cancelled step may settle with an exit code rather than throw; the pass ends either way.
184
+ run.signal?.throwIfAborted();
185
+ if (failed)
186
+ pass.record(failed.failure, failed.step);
187
+ else
188
+ completed.push(check.id);
189
+ }
190
+ catch (error) {
191
+ if (!pass.stopsAt(error, run.signal))
192
+ throw error;
193
+ await run.emit?.(pass.stoppedEvent(check.id, error));
194
+ break;
195
+ }
196
+ }
197
+ pass.throwIfFailed();
198
+ return completed;
199
+ }
200
+ /** Runs one check's steps in order; the first failed step ends the check, since later steps use its output. */
201
+ async runCheck(check, run) {
202
+ if (check.requiredCapability && !run.capabilities.has(check.requiredCapability)) {
203
+ throw new ForgeFailureError("prepublication_capability_unavailable", `prepublication_capability_unavailable: ${check.id} requires ${check.requiredCapability}; publication is holding until a capable runner is available.`, "bridge");
204
+ }
205
+ const granted = await this.ensurePrerequisite(check, run.execution?.environment, run.postgresAdminConnection, run.emit);
206
+ try {
207
+ // Only the affected .NET run measures against the pass's revisions, so only it reads them as committed;
208
+ // other suites may make replace refs or grafts of their own.
209
+ const execution = check.id === affectedTestsCheckId ? withHistoryIntegrity(run.execution) : run.execution;
210
+ return await this.runCheckSteps({ ...run, check, execution, postgresAdminConnection: granted ?? run.postgresAdminConnection });
211
+ }
212
+ finally {
213
+ await releaseCheckPostgres(check.id, granted, run.emit);
214
+ }
215
+ }
216
+ async runCheckSteps(stepRun) {
217
+ const { check, ...run } = stepRun;
218
+ await run.emit?.(validationEvent("prepublication_validation_started", check.id, `Running pre-publication CI parity check '${check.id}'.`));
219
+ const skipped = new SkippedTestTally(run.worktreePath, run.execution?.environment);
220
+ for (const step of check.steps) {
221
+ const stepStartedMs = Date.now() - 1000;
222
+ const result = await this.runConfirmedStep(stepRun, step);
223
+ if (result.exitCode !== 0) {
224
+ const detail = diagnosticDetail(result);
225
+ await run.emit?.(validationEvent("prepublication_validation_failed", check.id, `Pre-publication CI parity check '${check.id}' exited ${result.exitCode}${detail ? `: ${detail}` : "."}`));
226
+ return {
227
+ failure: { checkId: check.id, exitCode: result.exitCode, command: result.command, args: result.args, detail },
228
+ step,
229
+ };
230
+ }
231
+ await skipped.add(result.args, stepStartedMs);
232
+ }
233
+ // The check's own grant reaches only its steps' derived environments, so name its secrets too.
234
+ await run.emit?.(skipped.passedEvent(check.id, [
235
+ ...validationExactSecrets(run.execution?.environment),
236
+ ...attemptDatabaseCapabilitySecrets(run.postgresAdminConnection?.connectionString),
237
+ ]));
238
+ return null;
239
+ }
240
+ /** Runs a step, confirming once a failure that matches a known transient pattern. */
241
+ async runConfirmedStep(run, step) {
242
+ let result = await this.runCheckedStep(run, step);
243
+ if (isTimeoutOnlyClientTestFailure(run.check.id, step, result)) {
244
+ result = await this.confirmStep(run, step, timeoutConfirmation);
245
+ }
246
+ if (isTransientBridgeCleanupFailure(run.check.id, step, result)) {
247
+ result = await this.confirmStep(run, step, cleanupConfirmation);
248
+ }
249
+ if (isTransientShellInfrastructureFailure(result)) {
250
+ result = await this.confirmInfrastructure(run, step);
251
+ }
252
+ return result;
253
+ }
254
+ async runCheckedStep(run, step) {
255
+ const { check, worktreePath, signal, execution, postgresAdminConnection, emit } = run;
256
+ const result = await this.runStep(check.id, step, worktreePath, signal, execution, postgresAdminConnection, emit);
257
+ await this.throwIfPrerequisiteWasLost(check, result, execution?.environment, postgresAdminConnection, emit);
258
+ return result;
259
+ }
260
+ async confirmStep(run, step, confirmation) {
261
+ await run.emit?.(validationEvent(confirmation.started[0], run.check.id, confirmation.started[1]));
262
+ const result = await this.runCheckedStep(run, step);
263
+ await run.emit?.(result.exitCode === 0
264
+ ? validationEvent(confirmation.passed[0], run.check.id, confirmation.passed[1])
265
+ : validationEvent(confirmation.failedEvent, run.check.id, confirmation.failedContent(result.exitCode)));
266
+ return result;
267
+ }
268
+ async confirmInfrastructure(run, step) {
269
+ const checkId = run.check.id;
270
+ await run.emit?.(validationEvent("prepublication_infrastructure_confirmation_started", checkId, "The validation shell reported a known host-runtime failure; confirming once with the same command and attempt environment."));
271
+ const result = await this.runCheckedStep(run, step);
272
+ const infrastructureFailed = isTransientShellInfrastructureFailure(result);
273
+ await run.emit?.(validationEvent(infrastructureFailed
274
+ ? "prepublication_infrastructure_confirmation_failed"
275
+ : "prepublication_infrastructure_confirmation_passed", checkId, infrastructureFailed
276
+ ? `The validation shell failed again on its single infrastructure confirmation run (exit ${result.exitCode}).`
277
+ : result.exitCode === 0
278
+ ? "The validation step recovered on its single infrastructure confirmation run."
279
+ : "The host-runtime failure did not recur; continuing with normal validation failure handling."));
280
+ if (!infrastructureFailed)
281
+ return result;
282
+ const detail = diagnosticDetail(result);
283
+ await run.emit?.(validationEvent("prepublication_infrastructure_failed", checkId, `Pre-publication infrastructure for '${checkId}' remained unavailable${detail ? `: ${detail}` : "."}`));
284
+ throw new PrePublicationInfrastructureError(checkId, result.exitCode, result.command, result.args, detail);
285
+ }
286
+ /** Returns the native cluster grant when this check uses it instead of Docker. */
197
287
  async ensurePrerequisite(check, environment, postgresAdminConnection, emit) {
198
288
  if (check.requiredPrerequisite === "isolated_postgres"
199
289
  && isolatedPostgresProvided(check.id, environment, postgresAdminConnection)) {
@@ -202,6 +292,11 @@ export class PrePublicationValidator {
202
292
  : `Pre-publication check '${check.id}' is using the configured loopback PostgreSQL test server with per-run owned databases. No Docker daemon is required.`));
203
293
  return undefined;
204
294
  }
295
+ return await preferredNativeTestPostgres(check.id, check.requiredPrerequisite, this.nativeTestPostgresFallback, this.dockerEngineProbe, emit, this.startEphemeral)
296
+ ?? await this.ensureDockerPrerequisite(check, emit);
297
+ }
298
+ /** Waits for Docker; returns the native cluster grant when Docker stays down and a cluster is provisioned. */
299
+ async ensureDockerPrerequisite(check, emit) {
205
300
  if (check.requiredPrerequisite === undefined || !this.dockerEngineProbe)
206
301
  return undefined;
207
302
  const current = this.dockerEngineProbe.current();
@@ -213,12 +308,10 @@ export class PrePublicationValidator {
213
308
  const snapshot = await this.dockerEngineProbe.ensureAvailableForRequiredWork();
214
309
  if (!snapshot.available) {
215
310
  const detail = `Docker prerequisite unavailable (${snapshot.unavailableCode ?? "docker_engine_unavailable"}): ${snapshot.unavailableReason ?? "the daemon did not pass a fresh readiness probe"}`;
216
- const fallback = check.requiredPrerequisite === "isolated_postgres" && supportsNativeTestPostgresFallback(check)
217
- ? this.nativeTestPostgresFallback()
218
- : null;
311
+ const fallback = dockerUnavailableNativeTestPostgres(check.id, check.requiredPrerequisite, this.nativeTestPostgresFallback);
219
312
  if (fallback) {
220
313
  await emit?.(validationEvent("prepublication_prerequisite_native_fallback", check.id, `${detail}. Pre-publication check '${check.id}' is using the dedicated native PostgreSQL test cluster at ${fallback.endpoint} with per-run owned databases.`));
221
- return fallback.connectionString;
314
+ return fallback;
222
315
  }
223
316
  await emit?.(validationEvent("prepublication_prerequisite_unavailable", check.id, `Pre-publication check '${check.id}' is waiting for Docker infrastructure recovery: ${detail}`));
224
317
  throw new PrePublicationInfrastructureError(check.id, 75, "docker", ["info"], detail);
@@ -230,7 +323,7 @@ export class PrePublicationValidator {
230
323
  if (result.exitCode === 0
231
324
  || check.requiredPrerequisite === undefined
232
325
  || (check.requiredPrerequisite === "isolated_postgres"
233
- && isolatedPostgresProvided(check.id, environment, postgresAdminConnection))
326
+ && isolatedPostgresProvided(check.id, environment, dockerFreeGrant(postgresAdminConnection)))
234
327
  || !this.dockerEngineProbe)
235
328
  return;
236
329
  const snapshot = await this.dockerEngineProbe.refresh(true);
@@ -241,7 +334,8 @@ export class PrePublicationValidator {
241
334
  throw new PrePublicationInfrastructureError(check.id, result.exitCode, result.command, result.args, detail);
242
335
  }
243
336
  // Runs for every target repository, with or without a CI parity contract: it only reads the worktree.
244
- async assertNoTestOnlyExports(worktreePath, emit, signal, execution) {
337
+ // A failure joins the pass's failures; the contract's checks still run.
338
+ async checkTestOnlyExports(pass, worktreePath, emit, signal, execution) {
245
339
  const found = await findUnreferencedNewExports(args => this.runCommand("git", args, worktreePath, signal, execution), worktreePath, execution?.baselineRevision);
246
340
  const unused = found.filter(row => !row.testOnly);
247
341
  if (unused.length > 0) {
@@ -252,29 +346,7 @@ export class PrePublicationValidator {
252
346
  return;
253
347
  const detail = `only tests use ${testOnly.map(row => `${row.name} (${row.path})`).join(", ")}. Wire each to a real caller in this Story, or move the export and its test to the Story that first uses it. Do not delete assertions to pass.`;
254
348
  await emit?.(validationEvent("prepublication_validation_failed", "unreferenced-exports", `New code is tested but never called: ${detail}`));
255
- throw new PrePublicationValidationError("unreferenced-exports", 1, "git", ["grep"], detail);
256
- }
257
- async changedPaths(worktreePath, signal, execution) {
258
- const baselineRevision = execution?.baselineRevision?.trim();
259
- const requests = [
260
- ["diff", "--name-only", "HEAD", "--"],
261
- ...(baselineRevision ? [["diff", "--name-only", `${baselineRevision}..HEAD`, "--"]] : []),
262
- ["status", "--porcelain=v1", "--untracked-files=all"],
263
- ];
264
- const paths = new Set();
265
- for (const args of requests) {
266
- const result = await this.runCommand("git", args, worktreePath, signal, execution);
267
- if (result.exitCode !== 0) {
268
- throw new ForgeFailureError("prepublication_validation_failed", `prepublication_validation_failed: unable to inventory changed paths: ${result.stderr ?? result.stdout ?? "git failed"}`, "bridge");
269
- }
270
- for (const line of `${result.stdout ?? ""}`.split(/\r?\n/u).filter(Boolean)) {
271
- const raw = args[0] === "status" ? line.slice(3).split(" -> ").at(-1) ?? "" : line;
272
- const normalized = raw.trim().replaceAll("\\", "/");
273
- if (normalized)
274
- paths.add(normalized);
275
- }
276
- }
277
- return [...paths];
349
+ pass.record({ checkId: "unreferenced-exports", exitCode: 1, command: "git", args: ["grep"], detail });
278
350
  }
279
351
  async assertContractMatchesDispatchBaseline(worktreePath, contractDigest, signal, execution) {
280
352
  const baselineRevision = execution?.baselineRevision?.trim();
@@ -295,12 +367,32 @@ export class PrePublicationValidator {
295
367
  if (!approvedContractDigests.has(baselineDigest)) {
296
368
  throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the dispatch baseline uses unapproved CI parity contract ${baselineDigest}.`, "bridge");
297
369
  }
298
- if (baselineDigest !== contractDigest) {
370
+ // A conflict repair's uncommitted merge brings the target branch's contract with it.
371
+ if (baselineDigest !== contractDigest && await this.mergedInContractDigest(worktreePath, signal, execution) !== contractDigest) {
299
372
  throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the CI parity contract changed after dispatch (baseline ${baselineDigest}, worktree ${contractDigest}).`, "bridge");
300
373
  }
301
374
  }
302
- async runStep(checkId, step, cwd, signal, execution, postgresAdminConnection) {
375
+ /** The approved contract of the branch an in-progress merge brings in (MERGE_HEAD), else null. */
376
+ async mergedInContractDigest(worktreePath, signal, execution) {
377
+ const merged = await this.runCommand("git", ["show", `MERGE_HEAD:${contractRelativePath}`], worktreePath, signal, execution);
378
+ if (merged.exitCode !== 0)
379
+ return null;
380
+ try {
381
+ const digest = validationContractDigest(JSON.parse(merged.stdout ?? ""));
382
+ return approvedContractDigests.has(digest) ? digest : null;
383
+ }
384
+ catch {
385
+ return null;
386
+ }
387
+ }
388
+ async runStep(checkId, step, cwd, signal, execution, postgresAdminConnection, emit) {
303
389
  const invocation = managedAttemptInvocation(checkId, step, execution?.environment);
390
+ // Every launch, including confirmation reruns, is admitted by the host load governor first.
391
+ return await runHostGovernedValidationStep(this.hostLoad, {
392
+ checkId, command: invocation.command, args: invocation.args, owner: execution?.hostLoadOwner, signal, emit,
393
+ }, async (stepSignal) => await this.launchStep(checkId, step, invocation, cwd, stepSignal, execution, postgresAdminConnection));
394
+ }
395
+ async launchStep(checkId, step, invocation, cwd, signal, execution, postgresAdminConnection) {
304
396
  const stepExecution = validationExecutionForStep(checkId, step, execution, postgresAdminConnection);
305
397
  const before = await readValidationFiles(cwd, step.assertUnchangedPaths ?? []);
306
398
  const result = await this.runCommand(invocation.command, invocation.args, cwd, signal, stepExecution);
@@ -345,78 +437,18 @@ export class PrePublicationValidator {
345
437
  };
346
438
  }
347
439
  catch (error) {
440
+ // Carries the check its host capacity token waits on; it names only the executable.
441
+ if (error instanceof ProcessTreeTerminationError)
442
+ throw error;
348
443
  throw sanitizeFailureError(error, exactSecrets);
349
444
  }
350
445
  }
351
446
  }
352
- function managedAttemptInvocation(checkId, step, environment) {
353
- const playwrightConfig = environment?.FORGE_PLAYWRIGHT_CONFIG?.trim();
354
- const attemptOwned = environment?.FORGE_E2E_OWNERSHIP_MODE === "attempt"
355
- || Boolean(environment?.FORGE_DISPATCH_ATTEMPT_ID?.trim());
356
- if (checkId !== "playwright-e2e" || !attemptOwned) {
357
- return step;
358
- }
359
- if (!playwrightConfig) {
360
- throw new ForgeFailureError("prepublication_capability_unavailable", "prepublication_capability_unavailable: playwright-e2e requires the Bridge-generated FORGE_PLAYWRIGHT_CONFIG for a managed attempt.", "bridge");
361
- }
362
- return {
363
- command: "pnpm",
364
- args: ["--dir", "tests/e2e", "exec", "playwright", "test", "--config", playwrightConfig],
365
- };
366
- }
367
- const nativeFallbackCheckIds = new Set([
368
- "owned-suite-registration",
369
- "dotnet-build-and-unit",
370
- "comment-repair-dotnet-regression",
371
- ]);
372
- const nativeFallbackDotnetTierScripts = [
373
- "scripts/run-dotnet-test-tier.ps1",
374
- "scripts/run-dotnet-test-tier-set.ps1",
375
- "scripts/run-affected-dotnet-tests.mjs",
376
- ];
377
- function supportsNativeTestPostgresFallback(check) {
378
- return nativeFallbackCheckIds.has(check.id);
379
- }
380
- function validationExecutionForStep(checkId, step, execution, postgresAdminConnection) {
381
- // The connection only exists when Docker is unavailable and the operator
382
- // provisioned a dedicated native test cluster. Only the runner-authored
383
- // .NET test tiers and the suite-identity check receive it; build, client,
384
- // Bridge, and E2E steps never do.
385
- if (!postgresAdminConnection || !nativeFallbackCheckIds.has(checkId))
386
- return execution;
387
- const runsDotnetTier = step.args.some(argument => nativeFallbackDotnetTierScripts
388
- .some(script => argument.replaceAll("\\", "/").endsWith(script)));
389
- if (checkId !== "owned-suite-registration" && !runsDotnetTier)
390
- return execution;
391
- return {
392
- ...execution,
393
- environment: {
394
- ...execution?.environment,
395
- ...nativeTestPostgresFallbackEnvironment(parseNativeTestPostgresFallback(postgresAdminConnection)),
396
- },
397
- };
398
- }
399
- function environmentValue(environment, name) {
400
- return Object.prototype.hasOwnProperty.call(environment ?? {}, name)
401
- ? environment?.[name]?.trim() ?? ""
402
- : process.env[name]?.trim() ?? "";
403
- }
404
- function isolatedPostgresProvided(checkId, environment, postgresAdminConnection) {
405
- if (checkId === "playwright-e2e") {
406
- const attemptId = environmentValue(environment, "FORGE_DISPATCH_ATTEMPT_ID");
407
- return (environmentValue(environment, "FORGE_E2E_OWNERSHIP_MODE") === "attempt"
408
- || /^[0-9a-f-]{36}$/iu.test(attemptId))
409
- && /^forge_attempt_[0-9a-f]{32}$/u.test(environmentValue(environment, "FORGE_ATTEMPT_DATABASE_SCHEMA"))
410
- && path.isAbsolute(environmentValue(environment, "FORGE_ATTEMPT_DATABASE_READINESS_PATH"))
411
- // The attempt owns a database only once the Bridge's broker has issued it one.
412
- && environmentValue(environment, attemptDatabaseCapabilityEnvironment).length > 0;
413
- }
414
- return Boolean(postgresAdminConnection);
415
- }
416
447
  function validationExactSecrets(environment) {
417
448
  return [
418
- environment?.[hostRuntimeTestPostgresAdminEnvironment]?.trim() ?? "",
419
- environment?.[hostRuntimeLegacyTestPostgresEnvironment]?.trim() ?? "",
449
+ // The connection strings and their passwords: a test may print either.
450
+ ...attemptDatabaseCapabilitySecrets(environment?.[hostRuntimeTestPostgresAdminEnvironment]),
451
+ ...attemptDatabaseCapabilitySecrets(environment?.[hostRuntimeLegacyTestPostgresEnvironment]),
420
452
  environment?.[hostRuntimeTestPostgresProvisionerEnvironment]?.trim() ?? "",
421
453
  ...attemptDatabaseCapabilitySecrets(environment?.[attemptDatabaseCapabilityEnvironment]),
422
454
  ].filter((value, index, values) => value.length > 0 && values.indexOf(value) === index);
@@ -606,6 +638,17 @@ export async function loadValidationContract(worktreePath) {
606
638
  }
607
639
  return contract;
608
640
  }
641
+ /** The affected .NET tests measure the attempt's change against its dispatch baseline and merge parent (run-affected-dotnet-tests.mjs). */
642
+ function withValidationRevisions(execution, mergeParent) {
643
+ const revisions = validationRevisionEnvironment(execution?.baselineRevision, mergeParent);
644
+ if (Object.keys(revisions).length === 0)
645
+ return execution;
646
+ return { ...execution, environment: { ...execution?.environment, ...revisions } };
647
+ }
648
+ /** The execution with git reading history as committed (historyIntegrityEnvironment). */
649
+ function withHistoryIntegrity(execution) {
650
+ return { ...execution, environment: { ...execution?.environment, ...historyIntegrityEnvironment } };
651
+ }
609
652
  function validationContractDigest(contract) {
610
653
  return createHash("sha256")
611
654
  .update(JSON.stringify(canonicalizeJson(contract)))
@@ -620,12 +663,3 @@ function canonicalizeJson(value) {
620
663
  }
621
664
  return value;
622
665
  }
623
- function validationEvent(eventType, checkId, content, detail) {
624
- return {
625
- role: "runner",
626
- kind: "checkpoint",
627
- content,
628
- eventType,
629
- data: JSON.stringify({ checkId, contractId: "forge-ci-parity-v1", ...detail }),
630
- };
631
- }