@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
@@ -62,6 +62,11 @@ export declare class DockerEngineProbe {
62
62
  constructor(options?: DockerEngineProbeOptions, commands?: CommandRunner, cacheMs?: number);
63
63
  current(): DockerEngineCapabilitySnapshot | null;
64
64
  refresh(force?: boolean): Promise<DockerEngineCapabilitySnapshot>;
65
+ /**
66
+ * One fresh daemon reading that never starts recovery and leaves the cache and the
67
+ * failure streak alone, for callers that only need to know whether Docker is up.
68
+ */
69
+ probeWithoutRecovery(): Promise<DockerEngineCapabilitySnapshot>;
65
70
  /**
66
71
  * Establishes a fresh daemon fence for work that declares Docker as a hard
67
72
  * prerequisite. This remains bounded, cooldown protected and single-flight;
@@ -69,6 +69,13 @@ export class DockerEngineProbe {
69
69
  this.inFlight = operation;
70
70
  return await operation;
71
71
  }
72
+ /**
73
+ * One fresh daemon reading that never starts recovery and leaves the cache and the
74
+ * failure streak alone, for callers that only need to know whether Docker is up.
75
+ */
76
+ async probeWithoutRecovery() {
77
+ return await this.inspectSafely();
78
+ }
72
79
  /**
73
80
  * Establishes a fresh daemon fence for work that declares Docker as a hard
74
81
  * prerequisite. This remains bounded, cooldown protected and single-flight;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Where a supervised ASP.NET runtime builds and runs from, relative to each project in its
3
+ * graph. Agent builds keep the default `bin/<Configuration>/<TargetFramework>/` output, so they
4
+ * never overwrite (or, on Windows, fail on the locks of) the files a running runtime executes.
5
+ */
6
+ export declare const supervisedRuntimeOutputRoot = "bin/forge-runtime";
7
+ export type DotnetPathPlatform = "win32" | "posix";
8
+ /** A directory option: CLI options are fixed for the whole graph, MSBuild properties resolve per project. */
9
+ export interface DotnetOutputLocation {
10
+ readonly path: string;
11
+ readonly perProject: boolean;
12
+ }
13
+ export interface DotnetOutputSettings {
14
+ readonly configuration: string;
15
+ readonly framework: string | null;
16
+ readonly runtime: string | null;
17
+ /** `-p:OutDir` or `-p:OutputPath`: MSBuild resolves a relative value against each project. */
18
+ readonly outDir: DotnetOutputLocation | null;
19
+ /** `-o`/`--output`: one directory for every project the command builds. */
20
+ readonly output: DotnetOutputLocation | null;
21
+ readonly baseOutputPath: DotnetOutputLocation | null;
22
+ readonly artifactsPath: DotnetOutputLocation | null;
23
+ }
24
+ /** A dotnet command that writes (or, for a runtime, executes from) project build output. */
25
+ export interface DotnetOutputCommand {
26
+ readonly verb: string;
27
+ readonly cwd: string;
28
+ /** Absolute target candidates (project, solution, or directory); empty means the working directory. */
29
+ readonly targets: readonly string[];
30
+ readonly settings: DotnetOutputSettings;
31
+ }
32
+ export interface DotnetProjectFiles {
33
+ readonly read: (file: string) => Promise<string | null>;
34
+ readonly list: (directory: string) => Promise<readonly string[] | null>;
35
+ /** The real location of a path (canonicalExistingPath); without it paths compare as written. */
36
+ readonly canonical?: (target: string) => Promise<string>;
37
+ }
38
+ export interface DotnetOutputCollision {
39
+ /** The project whose output both commands use. */
40
+ readonly project: string;
41
+ readonly outputDirectory: string;
42
+ }
43
+ /**
44
+ * Where a path really is, existing or not yet: its deepest existing ancestor resolved through every
45
+ * symlink and junction, with the rest appended. A lexical path alone lets a link alias another directory.
46
+ * A link whose target does not exist yet still leads to that target, so it is followed by its
47
+ * link text, never taken as its own location; a link loop fails with `path_link_unresolvable`.
48
+ */
49
+ export declare function canonicalExistingPath(target: string): Promise<string>;
50
+ /** canonicalExistingPath, for synchronous planning. */
51
+ export declare function canonicalExistingPathSync(target: string): string;
52
+ export declare const fileSystemProjectFiles: DotnetProjectFiles;
53
+ export declare function hostPathPlatform(): DotnetPathPlatform;
54
+ export declare function isDotnetExecutable(command: string, platform?: DotnetPathPlatform): boolean;
55
+ /**
56
+ * Reads a dotnet command's build-output intent: its verb, target candidates, and output
57
+ * settings. Returns null when the command writes no build output. With `holder`, the command is
58
+ * a running runtime's `dotnet run`: `--no-build` does not matter, it executes from the output.
59
+ */
60
+ export declare function parseDotnetOutputCommand(command: string, args: readonly string[], cwd: string, options?: {
61
+ readonly platform?: DotnetPathPlatform;
62
+ readonly holder?: boolean;
63
+ }): DotnetOutputCommand | null;
64
+ /** True when the arguments already choose where the build output goes. */
65
+ export declare function declaresDotnetOutput(settings: DotnetOutputSettings): boolean;
66
+ /** What the project file itself decides about its output layout. */
67
+ export interface DotnetProjectLayout {
68
+ /** The project sets `<TargetFrameworks>`: the artifacts layout then adds the framework to its pivot. */
69
+ readonly multiTargeted?: boolean;
70
+ }
71
+ /** True when a project file multi-targets (`<TargetFrameworks>`, even with one entry). */
72
+ export declare function isMultiTargetedProject(projectXml: string): boolean;
73
+ /**
74
+ * The directory a project's primary output lands in under these settings. An unknown target
75
+ * framework is the wildcard `*`, which matches any framework in sameOutputDirectory.
76
+ */
77
+ export declare function projectOutputDirectory(projectFile: string, settings: DotnetOutputSettings, platform?: DotnetPathPlatform, layout?: DotnetProjectLayout): string;
78
+ /**
79
+ * The one directory holding every build output of a project under these settings, whatever
80
+ * configuration or framework they leave open: what a runtime's build receipt verifies. Without
81
+ * the project file's name, an artifacts layout's root is its `bin`, above every project's folder.
82
+ */
83
+ export declare function projectOutputRoot(projectDirectory: string, projectFile: string | null, settings: DotnetOutputSettings, platform?: DotnetPathPlatform): string;
84
+ /**
85
+ * Compares two output directories segment by segment. `*` matches any run of characters inside
86
+ * one segment: `*` is any framework folder, and `debug_*` any framework pivot.
87
+ */
88
+ export declare function sameOutputDirectory(left: string, right: string, platform?: DotnetPathPlatform): boolean;
89
+ /** ProjectReference Include values of a project file, ignoring commented-out references. */
90
+ export declare function projectReferenceIncludes(projectXml: string): readonly string[];
91
+ /** Project paths a .sln or .slnx lists. */
92
+ export declare function solutionProjectPaths(solution: string, content: string): readonly string[];
93
+ /** Every project file a command builds: its targets, solution members, and their ProjectReference closure. */
94
+ export declare function dotnetCommandProjects(command: DotnetOutputCommand, files?: DotnetProjectFiles, platform?: DotnetPathPlatform): Promise<readonly string[]>;
95
+ /**
96
+ * The projects whose output a build (`writer`) would write while a runtime (`holder`) executes
97
+ * from that same output, in the runtime's graph order (its own project first).
98
+ */
99
+ export declare function findDotnetOutputCollisions(writer: DotnetOutputCommand, holder: DotnetOutputCommand, files?: DotnetProjectFiles, platform?: DotnetPathPlatform): Promise<readonly DotnetOutputCollision[]>;
100
+ /** A runtime role as a directory name: kept when it is already safe, otherwise a stable digest. */
101
+ export declare function runtimeOutputName(role: string): string;
102
+ /**
103
+ * Gives a supervised `dotnet run` its own build output, `bin/forge-runtime/<role>/` under each
104
+ * project, unless the configured arguments already choose one. The ASP.NET prebuild forwards the
105
+ * same property to its `dotnet build`, so the runtime builds and runs from that directory.
106
+ */
107
+ export declare function isolatedRuntimeOutputArguments(command: string, args: readonly string[], role: string, platform?: DotnetPathPlatform): readonly string[];
@@ -0,0 +1,402 @@
1
+ import { createHash } from "node:crypto";
2
+ import { lstatSync, readlinkSync, realpathSync } from "node:fs";
3
+ import fs from "node:fs/promises";
4
+ import path from "node:path";
5
+ /**
6
+ * Where a supervised ASP.NET runtime builds and runs from, relative to each project in its
7
+ * graph. Agent builds keep the default `bin/<Configuration>/<TargetFramework>/` output, so they
8
+ * never overwrite (or, on Windows, fail on the locks of) the files a running runtime executes.
9
+ */
10
+ export const supervisedRuntimeOutputRoot = "bin/forge-runtime";
11
+ // More links than this on one path is a loop (Linux gives up at 40 too).
12
+ const maxPathLinks = 40;
13
+ /**
14
+ * Where a path really is, existing or not yet: its deepest existing ancestor resolved through every
15
+ * symlink and junction, with the rest appended. A lexical path alone lets a link alias another directory.
16
+ * A link whose target does not exist yet still leads to that target, so it is followed by its
17
+ * link text, never taken as its own location; a link loop fails with `path_link_unresolvable`.
18
+ */
19
+ export async function canonicalExistingPath(target) {
20
+ return await canonicalPathThroughLinks(target, 0);
21
+ }
22
+ async function canonicalPathThroughLinks(target, links) {
23
+ const resolved = path.resolve(target);
24
+ const real = await fs.realpath(resolved).catch(() => null);
25
+ if (real !== null)
26
+ return real;
27
+ if ((await fs.lstat(resolved).catch(() => null))?.isSymbolicLink()) {
28
+ const linkTarget = path.resolve(path.dirname(resolved), await fs.readlink(resolved));
29
+ return await canonicalPathThroughLinks(linkTarget, countedLink(resolved, links));
30
+ }
31
+ const parent = path.dirname(resolved);
32
+ return parent === resolved ? resolved : path.join(await canonicalPathThroughLinks(parent, links), path.basename(resolved));
33
+ }
34
+ /** canonicalExistingPath, for synchronous planning. */
35
+ export function canonicalExistingPathSync(target) {
36
+ return canonicalPathThroughLinksSync(target, 0);
37
+ }
38
+ function canonicalPathThroughLinksSync(target, links) {
39
+ const resolved = path.resolve(target);
40
+ const real = attempt(() => realpathSync.native(resolved));
41
+ if (real !== null)
42
+ return real;
43
+ if (attempt(() => lstatSync(resolved))?.isSymbolicLink()) {
44
+ const linkTarget = path.resolve(path.dirname(resolved), readlinkSync(resolved));
45
+ return canonicalPathThroughLinksSync(linkTarget, countedLink(resolved, links));
46
+ }
47
+ const parent = path.dirname(resolved);
48
+ return parent === resolved ? resolved : path.join(canonicalPathThroughLinksSync(parent, links), path.basename(resolved));
49
+ }
50
+ function attempt(read) {
51
+ try {
52
+ return read();
53
+ }
54
+ catch {
55
+ return null;
56
+ }
57
+ }
58
+ function countedLink(link, links) {
59
+ if (links >= maxPathLinks) {
60
+ throw new Error(`path_link_unresolvable: ${link} leads through more than ${maxPathLinks} links, so Forge cannot tell where it points.`);
61
+ }
62
+ return links + 1;
63
+ }
64
+ export const fileSystemProjectFiles = {
65
+ read: async (file) => await fs.readFile(file, "utf8").catch(() => null),
66
+ list: async (directory) => await fs.readdir(directory).catch(() => null),
67
+ canonical: canonicalExistingPath,
68
+ };
69
+ // Verbs that write (or, for clean, delete) a project's build output.
70
+ const outputWritingVerbs = new Set(["build", "test", "publish", "pack", "run", "msbuild", "clean"]);
71
+ const releaseByDefaultVerbs = new Set(["publish", "pack"]);
72
+ const optionsWithValues = new Set([
73
+ "-c", "--configuration", "-f", "--framework", "-r", "--runtime", "-o", "--output", "-a", "--arch", "--os",
74
+ "-v", "--verbosity", "-s", "--source", "--artifacts-path", "--project", "--solution", "-e", "--environment",
75
+ "-lp", "--launch-profile", "-l", "--logger", "--filter", "--settings", "--results-directory", "--collect",
76
+ "-d", "--diag", "--test-adapter-path", "--version-suffix", "--blame-hang-timeout", "--blame-crash-dump-type",
77
+ "--blame-hang-dump-type", "--max-parallel-test-modules", "--report-trx-filename",
78
+ ]);
79
+ const projectFilePattern = /\.(?:cs|fs|vb)proj$/iu;
80
+ const solutionFilePattern = /\.slnx?$/iu;
81
+ function pathApi(platform) {
82
+ return platform === "win32" ? path.win32 : path.posix;
83
+ }
84
+ export function hostPathPlatform() {
85
+ return process.platform === "win32" ? "win32" : "posix";
86
+ }
87
+ export function isDotnetExecutable(command, platform = hostPathPlatform()) {
88
+ const executable = pathApi(platform).basename(command).toLowerCase();
89
+ return executable === "dotnet" || executable === "dotnet.exe";
90
+ }
91
+ /**
92
+ * Reads a dotnet command's build-output intent: its verb, target candidates, and output
93
+ * settings. Returns null when the command writes no build output. With `holder`, the command is
94
+ * a running runtime's `dotnet run`: `--no-build` does not matter, it executes from the output.
95
+ */
96
+ export function parseDotnetOutputCommand(command, args, cwd, options = {}) {
97
+ const platform = options.platform ?? hostPathPlatform();
98
+ if (!isDotnetExecutable(command, platform))
99
+ return null;
100
+ const separator = args.indexOf("--");
101
+ const commandArgs = separator < 0 ? args : args.slice(0, separator);
102
+ const verbIndex = commandArgs.findIndex(argument => !argument.startsWith("-"));
103
+ const verb = commandArgs[verbIndex]?.toLowerCase() ?? "";
104
+ if (options.holder ? verb !== "run" : !outputWritingVerbs.has(verb))
105
+ return null;
106
+ const parsed = parseArguments(commandArgs.slice(verbIndex + 1));
107
+ if (!options.holder && verb !== "build" && verb !== "msbuild" && verb !== "clean" && parsed.flags.has("--no-build"))
108
+ return null;
109
+ if (verb === "msbuild" && parsed.msbuildTargets.length > 0
110
+ && parsed.msbuildTargets.every(target => target.toLowerCase() === "restore"))
111
+ return null;
112
+ const p = pathApi(platform);
113
+ const resolvedCwd = p.resolve(cwd);
114
+ const explicitTargets = ["--project", "--solution"].flatMap(name => parsed.values.get(name) ?? []);
115
+ // `dotnet run` hands positional arguments to the application; other verbs take them as targets.
116
+ const candidates = verb === "run" ? explicitTargets : [...explicitTargets, ...parsed.positionals];
117
+ return {
118
+ verb,
119
+ cwd: resolvedCwd,
120
+ targets: candidates.map(candidate => p.resolve(resolvedCwd, normalizeSeparators(candidate, platform))),
121
+ settings: outputSettings(verb, parsed, resolvedCwd, platform),
122
+ };
123
+ }
124
+ function parseArguments(args) {
125
+ const parsed = { flags: new Set(), values: new Map(), properties: new Map(), msbuildTargets: [], positionals: [] };
126
+ for (let index = 0; index < args.length; index += 1) {
127
+ const argument = args[index];
128
+ if (readMsbuildSwitch(argument, parsed))
129
+ continue;
130
+ if (!argument.startsWith("-")) {
131
+ parsed.positionals.push(argument);
132
+ continue;
133
+ }
134
+ const inline = /^(--?[A-Za-z][\w-]*)[=:](.*)$/u.exec(argument);
135
+ const name = (inline?.[1] ?? argument).toLowerCase();
136
+ if (inline && optionsWithValues.has(name))
137
+ parsed.values.set(name, inline[2]);
138
+ else if (optionsWithValues.has(name) && index + 1 < args.length)
139
+ parsed.values.set(name, args[++index]);
140
+ else
141
+ parsed.flags.add(name);
142
+ }
143
+ return parsed;
144
+ }
145
+ /** `-p:`/`-property:` assignments and `-t:`/`-target:` lists, in any of MSBuild's prefix spellings. */
146
+ function readMsbuildSwitch(argument, parsed) {
147
+ const property = /^(?:-{1,2}|\/)(?:p|property):(.+)$/iu.exec(argument);
148
+ if (property) {
149
+ for (const assignment of property[1].split(/[;,]/u)) {
150
+ const equals = assignment.indexOf("=");
151
+ if (equals > 0)
152
+ parsed.properties.set(assignment.slice(0, equals).trim().toLowerCase(), assignment.slice(equals + 1).trim());
153
+ }
154
+ return true;
155
+ }
156
+ const target = /^(?:-{1,2}|\/)(?:t|target):(.+)$/iu.exec(argument);
157
+ if (target) {
158
+ parsed.msbuildTargets.push(...target[1].split(/[;,]/u).map(value => value.trim()).filter(Boolean));
159
+ return true;
160
+ }
161
+ return false;
162
+ }
163
+ function outputSettings(verb, parsed, cwd, platform) {
164
+ const p = pathApi(platform);
165
+ const property = (name) => parsed.properties.get(name.toLowerCase()) || null;
166
+ const perProject = (value) => value ? { path: normalizeSeparators(value, platform), perProject: true } : null;
167
+ const fromCwd = (value) => value ? { path: p.resolve(cwd, normalizeSeparators(value, platform)), perProject: false } : null;
168
+ const os = parsed.values.get("--os");
169
+ const arch = parsed.values.get("-a") ?? parsed.values.get("--arch");
170
+ return {
171
+ configuration: parsed.values.get("-c") ?? parsed.values.get("--configuration") ?? property("Configuration")
172
+ ?? (releaseByDefaultVerbs.has(verb) ? "Release" : "Debug"),
173
+ framework: parsed.values.get("-f") ?? parsed.values.get("--framework") ?? property("TargetFramework"),
174
+ runtime: parsed.values.get("-r") ?? parsed.values.get("--runtime") ?? property("RuntimeIdentifier")
175
+ ?? (os || arch ? `${os ?? "*"}-${arch ?? "*"}` : null),
176
+ outDir: perProject(property("OutDir") ?? property("OutputPath")),
177
+ output: fromCwd(parsed.values.get("-o") ?? parsed.values.get("--output")),
178
+ baseOutputPath: perProject(property("BaseOutputPath")),
179
+ artifactsPath: fromCwd(parsed.values.get("--artifacts-path")) ?? perProject(property("ArtifactsPath")),
180
+ };
181
+ }
182
+ function normalizeSeparators(value, platform) {
183
+ return platform === "win32" ? value : value.replaceAll("\\", "/");
184
+ }
185
+ /** True when the arguments already choose where the build output goes. */
186
+ export function declaresDotnetOutput(settings) {
187
+ return Boolean(settings.outDir ?? settings.output ?? settings.baseOutputPath ?? settings.artifactsPath);
188
+ }
189
+ /** True when a project file multi-targets (`<TargetFrameworks>`, even with one entry). */
190
+ export function isMultiTargetedProject(projectXml) {
191
+ return /<TargetFrameworks>\s*[^<\s]/u.test(projectXml.replaceAll(/<!--[\s\S]*?-->/gu, ""));
192
+ }
193
+ /**
194
+ * The directory a project's primary output lands in under these settings. An unknown target
195
+ * framework is the wildcard `*`, which matches any framework in sameOutputDirectory.
196
+ */
197
+ export function projectOutputDirectory(projectFile, settings, platform = hostPathPlatform(), layout = {}) {
198
+ const p = pathApi(platform);
199
+ const projectDirectory = p.dirname(projectFile);
200
+ const at = (location) => location.perProject ? p.resolve(projectDirectory, location.path) : location.path;
201
+ // OutDir wins over the OutputPath that `-o` sets; a global OutputPath is used as given.
202
+ const explicit = settings.outDir ?? settings.output;
203
+ if (explicit)
204
+ return p.resolve(at(explicit));
205
+ if (settings.artifactsPath) {
206
+ // The SDK's ArtifactsPivots: the configuration, the framework only when the project
207
+ // multi-targets, then an explicit RID, lowercased and joined by `_`.
208
+ const pivot = [
209
+ settings.configuration,
210
+ ...(layout.multiTargeted ? [settings.framework ?? "*"] : []),
211
+ ...(settings.runtime ? [settings.runtime] : []),
212
+ ].join("_").toLowerCase();
213
+ return p.join(artifactsProjectRoot(projectFile, at(settings.artifactsPath), platform), pivot);
214
+ }
215
+ const base = settings.baseOutputPath ? at(settings.baseOutputPath) : p.join(projectDirectory, "bin");
216
+ return p.join(base, settings.configuration, settings.framework ?? "*", ...(settings.runtime ? [settings.runtime] : []));
217
+ }
218
+ function artifactsProjectRoot(projectFile, artifactsPath, platform) {
219
+ const p = pathApi(platform);
220
+ return p.join(artifactsPath, "bin", p.basename(projectFile).replace(projectFilePattern, ""));
221
+ }
222
+ /**
223
+ * The one directory holding every build output of a project under these settings, whatever
224
+ * configuration or framework they leave open: what a runtime's build receipt verifies. Without
225
+ * the project file's name, an artifacts layout's root is its `bin`, above every project's folder.
226
+ */
227
+ export function projectOutputRoot(projectDirectory, projectFile, settings, platform = hostPathPlatform()) {
228
+ const p = pathApi(platform);
229
+ const at = (location) => p.resolve(location.perProject ? p.resolve(projectDirectory, location.path) : location.path);
230
+ const explicit = settings.outDir ?? settings.output;
231
+ if (explicit)
232
+ return at(explicit);
233
+ if (settings.artifactsPath) {
234
+ const artifactsPath = at(settings.artifactsPath);
235
+ return projectFile ? artifactsProjectRoot(projectFile, artifactsPath, platform) : p.join(artifactsPath, "bin");
236
+ }
237
+ return settings.baseOutputPath ? at(settings.baseOutputPath) : p.join(projectDirectory, "bin");
238
+ }
239
+ /**
240
+ * Compares two output directories segment by segment. `*` matches any run of characters inside
241
+ * one segment: `*` is any framework folder, and `debug_*` any framework pivot.
242
+ */
243
+ export function sameOutputDirectory(left, right, platform = hostPathPlatform()) {
244
+ const segments = (value) => {
245
+ const resolved = pathApi(platform).resolve(value);
246
+ return (platform === "win32" ? resolved.toLowerCase() : resolved).split(/[\\/]+/u).filter(Boolean);
247
+ };
248
+ const a = segments(left);
249
+ const b = segments(right);
250
+ return a.length === b.length && a.every((segment, index) => sameSegment(segment, b[index]));
251
+ }
252
+ function sameSegment(left, right) {
253
+ if (left === right)
254
+ return true;
255
+ const leftOpen = left.includes("*");
256
+ const rightOpen = right.includes("*");
257
+ // `*` never crosses `_`, so two open pivots meet only with the same parts, each pair able to name one value.
258
+ if (leftOpen && rightOpen) {
259
+ const leftParts = left.split("_");
260
+ const rightParts = right.split("_");
261
+ return leftParts.length === rightParts.length && leftParts.every((part, index) => samePivotPart(part, rightParts[index]));
262
+ }
263
+ if (leftOpen)
264
+ return matchesWildcard(left, right);
265
+ return rightOpen && matchesWildcard(right, left);
266
+ }
267
+ /** One `_`-free pivot part: both open ones share a value when their literal start and end agree. */
268
+ function samePivotPart(left, right) {
269
+ if (left === right)
270
+ return true;
271
+ if (!left.includes("*"))
272
+ return matchesWildcard(right, left);
273
+ if (!right.includes("*"))
274
+ return matchesWildcard(left, right);
275
+ const [leftStart, rightStart] = [left.slice(0, left.indexOf("*")), right.slice(0, right.indexOf("*"))];
276
+ const [leftEnd, rightEnd] = [left.slice(left.lastIndexOf("*") + 1), right.slice(right.lastIndexOf("*") + 1)];
277
+ return (leftStart.startsWith(rightStart) || rightStart.startsWith(leftStart))
278
+ && (leftEnd.endsWith(rightEnd) || rightEnd.endsWith(leftEnd));
279
+ }
280
+ /** `*` stands for one framework or RID value, which never contains the pivot separator `_`. */
281
+ function matchesWildcard(pattern, value) {
282
+ const expression = pattern.split("*").map(part => part.replaceAll(/[.*+?^${}()|[\]\\]/gu, "\\$&")).join("[^_]*");
283
+ return new RegExp(`^${expression}$`, "u").test(value);
284
+ }
285
+ /** ProjectReference Include values of a project file, ignoring commented-out references. */
286
+ export function projectReferenceIncludes(projectXml) {
287
+ const withoutComments = projectXml.replaceAll(/<!--[\s\S]*?-->/gu, "");
288
+ const includes = [];
289
+ for (const match of withoutComments.matchAll(/<ProjectReference\b[^>]*?\bInclude\s*=\s*(?:"([^"]*)"|'([^']*)')/giu)) {
290
+ for (const part of (match[1] ?? match[2] ?? "").split(";")) {
291
+ const trimmed = part.trim();
292
+ if (trimmed)
293
+ includes.push(trimmed);
294
+ }
295
+ }
296
+ return includes;
297
+ }
298
+ /** Project paths a .sln or .slnx lists. */
299
+ export function solutionProjectPaths(solution, content) {
300
+ const pattern = /\.slnx$/iu.test(solution)
301
+ ? /<Project\b[^>]*?\bPath\s*=\s*"([^"]+)"/giu
302
+ : /^Project\("\{[^}]*\}"\)\s*=\s*"[^"]*"\s*,\s*"([^"]+)"/gmu;
303
+ return [...content.matchAll(pattern)].map(match => match[1].trim()).filter(entry => projectFilePattern.test(entry));
304
+ }
305
+ /** Every project file a command builds: its targets, solution members, and their ProjectReference closure. */
306
+ export async function dotnetCommandProjects(command, files = fileSystemProjectFiles, platform = hostPathPlatform()) {
307
+ const p = pathApi(platform);
308
+ const queue = [...await targetProjectFiles(command, files, platform)];
309
+ const visited = new Map();
310
+ while (queue.length > 0) {
311
+ const projectFile = queue.shift();
312
+ const key = platform === "win32" ? projectFile.toLowerCase() : projectFile;
313
+ if (visited.has(key))
314
+ continue;
315
+ const content = await files.read(projectFile);
316
+ if (content === null)
317
+ continue;
318
+ visited.set(key, projectFile);
319
+ for (const include of projectReferenceIncludes(content)) {
320
+ // An MSBuild property cannot be resolved here.
321
+ if (!include.includes("$("))
322
+ queue.push(p.resolve(p.dirname(projectFile), normalizeSeparators(include, platform)));
323
+ }
324
+ }
325
+ return [...visited.values()];
326
+ }
327
+ async function targetProjectFiles(command, files, platform) {
328
+ const fromCandidates = async (candidates) => {
329
+ const found = [];
330
+ for (const candidate of candidates) {
331
+ if (projectFilePattern.test(candidate) || solutionFilePattern.test(candidate))
332
+ found.push(candidate);
333
+ else
334
+ found.push(...((await files.list(candidate)) ?? [])
335
+ .filter(entry => projectFilePattern.test(entry) || solutionFilePattern.test(entry))
336
+ .map(entry => pathApi(platform).join(candidate, entry)));
337
+ }
338
+ return found;
339
+ };
340
+ // A positional value that is no target (an unlisted option's value) leaves the working directory as the target.
341
+ const explicit = await fromCandidates(command.targets);
342
+ const targets = explicit.length > 0 ? explicit : await fromCandidates([command.cwd]);
343
+ const projects = [];
344
+ for (const target of targets) {
345
+ if (!solutionFilePattern.test(target)) {
346
+ projects.push(target);
347
+ continue;
348
+ }
349
+ const content = await files.read(target);
350
+ const p = pathApi(platform);
351
+ for (const entry of content ? solutionProjectPaths(target, content) : []) {
352
+ projects.push(p.resolve(p.dirname(target), normalizeSeparators(entry, platform)));
353
+ }
354
+ }
355
+ return projects;
356
+ }
357
+ /**
358
+ * The projects whose output a build (`writer`) would write while a runtime (`holder`) executes
359
+ * from that same output, in the runtime's graph order (its own project first).
360
+ */
361
+ export async function findDotnetOutputCollisions(writer, holder, files = fileSystemProjectFiles, platform = hostPathPlatform()) {
362
+ const key = (value) => platform === "win32" ? value.toLowerCase() : value;
363
+ // Projects and outputs compare by real location: a link to the worktree or to an output is the same place.
364
+ const real = files.canonical ?? (async (value) => value);
365
+ const written = new Set(await Promise.all((await dotnetCommandProjects(writer, files, platform))
366
+ .map(async (project) => key(await real(project)))));
367
+ const collisions = [];
368
+ for (const project of await dotnetCommandProjects(holder, files, platform)) {
369
+ const realProject = await real(project);
370
+ if (!written.has(key(realProject)))
371
+ continue;
372
+ const layout = { multiTargeted: isMultiTargetedProject((await files.read(project)) ?? "") };
373
+ const held = await real(projectOutputDirectory(project, holder.settings, platform, layout));
374
+ if (sameOutputDirectory(await real(projectOutputDirectory(project, writer.settings, platform, layout)), held, platform)) {
375
+ collisions.push({ project: realProject, outputDirectory: held });
376
+ }
377
+ }
378
+ return collisions;
379
+ }
380
+ /** A runtime role as a directory name: kept when it is already safe, otherwise a stable digest. */
381
+ export function runtimeOutputName(role) {
382
+ return /^[A-Za-z0-9][A-Za-z0-9_-]{0,31}$/u.test(role)
383
+ ? role
384
+ : createHash("sha256").update(role).digest("hex").slice(0, 16);
385
+ }
386
+ /**
387
+ * Gives a supervised `dotnet run` its own build output, `bin/forge-runtime/<role>/` under each
388
+ * project, unless the configured arguments already choose one. The ASP.NET prebuild forwards the
389
+ * same property to its `dotnet build`, so the runtime builds and runs from that directory.
390
+ */
391
+ export function isolatedRuntimeOutputArguments(command, args, role, platform = hostPathPlatform()) {
392
+ const runtime = parseDotnetOutputCommand(command, args, ".", { platform, holder: true });
393
+ if (!runtime || declaresDotnetOutput(runtime.settings))
394
+ return args;
395
+ const separator = args.indexOf("--");
396
+ const insertionIndex = separator < 0 ? args.length : separator;
397
+ return [
398
+ ...args.slice(0, insertionIndex),
399
+ `-p:OutDir=${supervisedRuntimeOutputRoot}/${runtimeOutputName(role)}/`,
400
+ ...args.slice(insertionIndex),
401
+ ];
402
+ }
@@ -0,0 +1,37 @@
1
+ import { type EphemeralTestPostgresCluster, type EphemeralTestPostgresOptions } from "./ephemeral-test-postgres.js";
2
+ import { type NativeTestPostgresFallback, type NativeTestPostgresGrant } from "./native-test-postgres-fallback.js";
3
+ export type StartEphemeralTestPostgres = (options: EphemeralTestPostgresOptions) => Promise<EphemeralTestPostgresCluster>;
4
+ /** The bin directory an ephemeral cluster runs from: the file's `postgresBin`, else the one holding psql. */
5
+ export declare function ephemeralTestPostgresBinDirectory(fallback: Pick<NativeTestPostgresFallback, "postgresBin">, psqlPath?: () => string | null): string;
6
+ /**
7
+ * Starts a throwaway cluster for one check and returns its grant. The grant's mode keeps the
8
+ * Docker semantics of the shared cluster: with Docker up, pinned-engine tests still start their
9
+ * own containers; with Docker down, they are skipped. The caller must call `release`.
10
+ */
11
+ export declare function startEphemeralTestPostgresGrant(fallback: Pick<NativeTestPostgresFallback, "postgresBin">, dockerAvailable: boolean, start?: StartEphemeralTestPostgres): Promise<NativeTestPostgresGrant>;
12
+ /** A managed verification command's database environment, and what to release when the command ends. */
13
+ export interface ManagedVerificationDatabase {
14
+ readonly environment: Readonly<Record<string, string>>;
15
+ /** The connection strings and their passwords, for redaction; never the mode or the cluster id. */
16
+ readonly secrets: readonly string[];
17
+ readonly release: () => Promise<void>;
18
+ }
19
+ /** A command that runs no verification profile gets no database. */
20
+ export declare const noManagedVerificationDatabase: ManagedVerificationDatabase;
21
+ /**
22
+ * Builds a command's setup from its database. If the setup throws, the command never starts and
23
+ * no caller holds the database, so it is released here before the error is rethrown.
24
+ */
25
+ export declare function setUpWithManagedVerificationDatabase<T>(database: Pick<ManagedVerificationDatabase, "release">, setUp: () => T): Promise<T>;
26
+ /**
27
+ * Releases a command's database once the command has ended. A cluster that would not stop is left
28
+ * disowned for the next start's reap; the failure goes to `report` instead of being dropped.
29
+ */
30
+ export declare function releaseManagedVerificationDatabase(database: Pick<ManagedVerificationDatabase, "release">, report: (message: string) => Promise<void>): Promise<void>;
31
+ /**
32
+ * Managed verification on an `ephemeral` host gets a throwaway cluster for the command's
33
+ * lifetime; every other host keeps managedVerificationDatabaseEnvironment's rules. A cluster
34
+ * that cannot start fails the command rather than silently handing it Docker or the shared
35
+ * cluster's narrower login.
36
+ */
37
+ export declare function managedVerificationDatabase(dockerAvailable?: () => Promise<boolean>, readFallback?: () => NativeTestPostgresFallback | null, start?: StartEphemeralTestPostgres): Promise<ManagedVerificationDatabase>;
@@ -0,0 +1,85 @@
1
+ import path from "node:path";
2
+ import { attemptDatabaseCapabilitySecrets, resolvePsqlPath } from "./attempt-database-broker.js";
3
+ import { EphemeralTestPostgresError, ephemeralTestPostgresClusterEnvironment, startEphemeralTestPostgres, } from "./ephemeral-test-postgres.js";
4
+ import { DockerEngineProbe } from "./docker-engine-probe.js";
5
+ import { managedVerificationDatabaseEnvironment, nativeTestPostgresFallbackConfigEnvironment, nativeTestPostgresFallbackDatabaseMode, nativeTestPostgresFallbackEnvironment, nativeTestPostgresPreferredDatabaseMode, readNativeTestPostgresFallback, } from "./native-test-postgres-fallback.js";
6
+ /** The bin directory an ephemeral cluster runs from: the file's `postgresBin`, else the one holding psql. */
7
+ export function ephemeralTestPostgresBinDirectory(fallback, psqlPath = resolvePsqlPath) {
8
+ if (fallback.postgresBin)
9
+ return fallback.postgresBin;
10
+ const psql = psqlPath();
11
+ if (!psql) {
12
+ throw new EphemeralTestPostgresError("no PostgreSQL install was found; set 'postgresBin' in native-test-postgres.json or FORGE_NATIVE_TEST_POSTGRES_PSQL.");
13
+ }
14
+ return path.dirname(psql);
15
+ }
16
+ /**
17
+ * Starts a throwaway cluster for one check and returns its grant. The grant's mode keeps the
18
+ * Docker semantics of the shared cluster: with Docker up, pinned-engine tests still start their
19
+ * own containers; with Docker down, they are skipped. The caller must call `release`.
20
+ */
21
+ export async function startEphemeralTestPostgresGrant(fallback, dockerAvailable, start = startEphemeralTestPostgres) {
22
+ const cluster = await start({ binDirectory: ephemeralTestPostgresBinDirectory(fallback) });
23
+ return {
24
+ connectionString: cluster.connectionString,
25
+ endpoint: cluster.endpoint,
26
+ mode: dockerAvailable ? nativeTestPostgresPreferredDatabaseMode : nativeTestPostgresFallbackDatabaseMode,
27
+ ephemeralClusterId: cluster.id,
28
+ release: cluster.release,
29
+ };
30
+ }
31
+ /** A command that runs no verification profile gets no database. */
32
+ export const noManagedVerificationDatabase = {
33
+ environment: {},
34
+ secrets: [],
35
+ release: async () => undefined,
36
+ };
37
+ /**
38
+ * Builds a command's setup from its database. If the setup throws, the command never starts and
39
+ * no caller holds the database, so it is released here before the error is rethrown.
40
+ */
41
+ export async function setUpWithManagedVerificationDatabase(database, setUp) {
42
+ try {
43
+ return setUp();
44
+ }
45
+ catch (error) {
46
+ await database.release().catch(() => undefined);
47
+ throw error;
48
+ }
49
+ }
50
+ /**
51
+ * Releases a command's database once the command has ended. A cluster that would not stop is left
52
+ * disowned for the next start's reap; the failure goes to `report` instead of being dropped.
53
+ */
54
+ export async function releaseManagedVerificationDatabase(database, report) {
55
+ try {
56
+ await database.release();
57
+ }
58
+ catch (error) {
59
+ await report(error instanceof Error ? error.message : String(error)).catch(() => undefined);
60
+ }
61
+ }
62
+ function databaseSecrets(environment) {
63
+ return Object.entries(environment)
64
+ .filter(([name]) => name !== "FORGE_MANAGED_VERIFICATION_DATABASE_MODE" && name !== ephemeralTestPostgresClusterEnvironment)
65
+ .flatMap(([, value]) => attemptDatabaseCapabilitySecrets(value));
66
+ }
67
+ /**
68
+ * Managed verification on an `ephemeral` host gets a throwaway cluster for the command's
69
+ * lifetime; every other host keeps managedVerificationDatabaseEnvironment's rules. A cluster
70
+ * that cannot start fails the command rather than silently handing it Docker or the shared
71
+ * cluster's narrower login.
72
+ */
73
+ export async function managedVerificationDatabase(dockerAvailable = async () => (await new DockerEngineProbe().probeWithoutRecovery()).available, readFallback = () => {
74
+ const configPath = process.env[nativeTestPostgresFallbackConfigEnvironment]?.trim();
75
+ return configPath ? readNativeTestPostgresFallback(configPath) : null;
76
+ }, start = startEphemeralTestPostgres) {
77
+ const fallback = readFallback();
78
+ if (fallback?.use !== "ephemeral") {
79
+ const environment = await managedVerificationDatabaseEnvironment(dockerAvailable, () => fallback);
80
+ return { environment, secrets: databaseSecrets(environment), release: async () => undefined };
81
+ }
82
+ const grant = await startEphemeralTestPostgresGrant(fallback, await dockerAvailable(), start);
83
+ const environment = nativeTestPostgresFallbackEnvironment(grant);
84
+ return { environment, secrets: databaseSecrets(environment), release: grant.release ?? (async () => undefined) };
85
+ }