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

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
@@ -0,0 +1,34 @@
1
+ import type os from "node:os";
2
+ import type { PressureStallResource } from "./host-pressure-stall.js";
3
+ /** Host CPU time summed over every logical CPU, in milliseconds, from os.cpus(). */
4
+ export interface CpuTimeTotals {
5
+ readonly busyMs: number;
6
+ readonly totalMs: number;
7
+ readonly cpuCount: number;
8
+ }
9
+ export type CpuTimesSource = readonly Partial<Pick<os.CpuInfo, "times">>[];
10
+ /**
11
+ * Host CPU use at which the estimate starts to report pressure. Waits for a CPU
12
+ * are rare below it on a many-core host. 0.6 puts the default backpressure
13
+ * threshold (50%) at 80% host CPU use, the default CPU budget.
14
+ */
15
+ export declare const windowsCpuPressureKnee = 0.6;
16
+ /** Busy is user + nice + sys + irq; idle is not busy. Null when any CPU lacks its times. */
17
+ export declare function cpuTimeTotals(cpus: CpuTimesSource): CpuTimeTotals | null;
18
+ /** Busy share of all logical CPUs (0-1) between two readings; null across a CPU count change or a counter reset. */
19
+ export declare function cpuUtilisation(previous: CpuTimeTotals | null, current: CpuTimeTotals | null): number | null;
20
+ /** Estimated share of wall time (percent) some runnable thread waited for a CPU, for one window. */
21
+ export declare function estimatedCpuStallPercent(utilisation: number): number;
22
+ /**
23
+ * Keeps 10/60/300-second exponentially decaying averages of the estimate, the
24
+ * way the kernel keeps PSI averages, so the governor's threshold and pressure
25
+ * streak read it exactly like PSI. The first window seeds every average, so a
26
+ * host already busy when the bridge starts reports pressure at once.
27
+ */
28
+ export declare class WindowsCpuPressureEstimator {
29
+ private averages;
30
+ /** Folds in one window of host CPU use lasting `elapsedMs`. */
31
+ update(utilisation: number, elapsedMs: number): PressureStallResource;
32
+ current(): PressureStallResource | null;
33
+ reset(): void;
34
+ }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Host CPU use at which the estimate starts to report pressure. Waits for a CPU
3
+ * are rare below it on a many-core host. 0.6 puts the default backpressure
4
+ * threshold (50%) at 80% host CPU use, the default CPU budget.
5
+ */
6
+ export const windowsCpuPressureKnee = 0.6;
7
+ /** Busy is user + nice + sys + irq; idle is not busy. Null when any CPU lacks its times. */
8
+ export function cpuTimeTotals(cpus) {
9
+ if (cpus.length === 0)
10
+ return null;
11
+ let busyMs = 0;
12
+ let idleMs = 0;
13
+ for (const cpu of cpus) {
14
+ const times = cpu.times;
15
+ if (!times)
16
+ return null;
17
+ const values = [times.user, times.nice, times.sys, times.irq, times.idle];
18
+ if (!values.every(value => Number.isFinite(value) && value >= 0))
19
+ return null;
20
+ busyMs += times.user + times.nice + times.sys + times.irq;
21
+ idleMs += times.idle;
22
+ }
23
+ return { busyMs, totalMs: busyMs + idleMs, cpuCount: cpus.length };
24
+ }
25
+ /** Busy share of all logical CPUs (0-1) between two readings; null across a CPU count change or a counter reset. */
26
+ export function cpuUtilisation(previous, current) {
27
+ if (!previous || !current || previous.cpuCount !== current.cpuCount)
28
+ return null;
29
+ const totalDelta = current.totalMs - previous.totalMs;
30
+ const busyDelta = current.busyMs - previous.busyMs;
31
+ if (totalDelta <= 0 || busyDelta < 0)
32
+ return null;
33
+ return Math.min(1, busyDelta / totalDelta);
34
+ }
35
+ /** Estimated share of wall time (percent) some runnable thread waited for a CPU, for one window. */
36
+ export function estimatedCpuStallPercent(utilisation) {
37
+ const share = (utilisation - windowsCpuPressureKnee) / (1 - windowsCpuPressureKnee);
38
+ return Math.min(1, Math.max(0, share)) * 100;
39
+ }
40
+ const averageWindowsSeconds = { avg10: 10, avg60: 60, avg300: 300 };
41
+ /**
42
+ * Keeps 10/60/300-second exponentially decaying averages of the estimate, the
43
+ * way the kernel keeps PSI averages, so the governor's threshold and pressure
44
+ * streak read it exactly like PSI. The first window seeds every average, so a
45
+ * host already busy when the bridge starts reports pressure at once.
46
+ */
47
+ export class WindowsCpuPressureEstimator {
48
+ averages = null;
49
+ /** Folds in one window of host CPU use lasting `elapsedMs`. */
50
+ update(utilisation, elapsedMs) {
51
+ const stall = estimatedCpuStallPercent(utilisation);
52
+ const previous = this.averages;
53
+ this.averages = previous === null
54
+ ? { avg10: stall, avg60: stall, avg300: stall }
55
+ : {
56
+ avg10: decay(previous.avg10, stall, elapsedMs, averageWindowsSeconds.avg10),
57
+ avg60: decay(previous.avg60, stall, elapsedMs, averageWindowsSeconds.avg60),
58
+ avg300: decay(previous.avg300, stall, elapsedMs, averageWindowsSeconds.avg300),
59
+ };
60
+ return this.current();
61
+ }
62
+ current() {
63
+ if (!this.averages)
64
+ return null;
65
+ return {
66
+ some: {
67
+ avg10: roundPercent(this.averages.avg10),
68
+ avg60: roundPercent(this.averages.avg60),
69
+ avg300: roundPercent(this.averages.avg300),
70
+ },
71
+ // `full` (every runnable thread stalled) is not meaningful for CPU and is not estimated.
72
+ full: null,
73
+ };
74
+ }
75
+ reset() {
76
+ this.averages = null;
77
+ }
78
+ }
79
+ function decay(previous, sample, elapsedMs, windowSeconds) {
80
+ const weight = Math.exp(-Math.max(0, elapsedMs) / (windowSeconds * 1_000));
81
+ return sample + (previous - sample) * weight;
82
+ }
83
+ function roundPercent(value) {
84
+ return Math.round(value * 100) / 100;
85
+ }
@@ -27,6 +27,13 @@ export declare function parseMemAvailableBytes(content: string): number | null;
27
27
  * Returns null on pure cgroup v1 hosts (no `0::` entry) and for the root cgroup.
28
28
  */
29
29
  export declare function parseUnifiedCgroupPath(content: string): string | null;
30
+ /**
31
+ * This process's cgroup v2 path from `/proc/self/cgroup`, including the root
32
+ * `/` (a container's own cgroup under a cgroup namespace); null for cgroup v1
33
+ * or a malformed entry. `parseUnifiedCgroupPath` excludes the root, because the
34
+ * root is never the bridge's own unit; memory limits apply there all the same.
35
+ */
36
+ export declare function parseUnifiedCgroupMembership(content: string): string | null;
30
37
  /** The leaf cgroup name, e.g. `forge-bridge.service`. */
31
38
  export declare function cgroupLeafName(cgroupPath: string): string | null;
32
39
  /**
@@ -36,6 +43,19 @@ export declare function cgroupLeafName(cgroupPath: string): string | null;
36
43
  * FORGE_BRIDGE_CGROUP_UNIT. A `.scope` is rejected: a bridge started from a
37
44
  * terminal, SSH session or desktop app shares `session-N.scope` /
38
45
  * `app-*.scope` with unrelated work (possibly the owner's game).
39
- * Container cgroups (e.g. `docker-<id>.scope`) are added in decision 0013 step 2.
46
+ * Container cgroups (e.g. `docker-<id>.scope`) are not treated as dedicated yet.
40
47
  */
41
48
  export declare function isDedicatedBridgeUnit(unit: string, configuredUnit: string | null | undefined): boolean;
49
+ /** Aggregate host CPU time from /proc/stat, in clock ticks, plus the online CPU count. */
50
+ export interface ProcStatCpuTotals {
51
+ readonly busyTicks: number;
52
+ readonly totalTicks: number;
53
+ readonly cpuCount: number;
54
+ }
55
+ /**
56
+ * Reads the aggregate `cpu` line of /proc/stat. Busy time is user + nice +
57
+ * system + irq + softirq + steal (guest time is already inside user/nice);
58
+ * idle and iowait are not busy. Both counters are additive CPU time, so a
59
+ * cgroup's `cpu.stat` usage over the same window can be subtracted from them.
60
+ */
61
+ export declare function parseProcStatCpuTotals(content: string): ProcStatCpuTotals | null;
@@ -97,6 +97,26 @@ export function parseUnifiedCgroupPath(content) {
97
97
  }
98
98
  return null;
99
99
  }
100
+ /**
101
+ * This process's cgroup v2 path from `/proc/self/cgroup`, including the root
102
+ * `/` (a container's own cgroup under a cgroup namespace); null for cgroup v1
103
+ * or a malformed entry. `parseUnifiedCgroupPath` excludes the root, because the
104
+ * root is never the bridge's own unit; memory limits apply there all the same.
105
+ */
106
+ export function parseUnifiedCgroupMembership(content) {
107
+ for (const rawLine of content.split(/\r?\n/u)) {
108
+ const line = rawLine.trim();
109
+ if (!line.startsWith("0::"))
110
+ continue;
111
+ const cgroupPath = line.slice(3).trim();
112
+ if (!cgroupPath.startsWith("/"))
113
+ return null;
114
+ if (cgroupPath.split("/").some(segment => segment === ".."))
115
+ return null;
116
+ return cgroupPath;
117
+ }
118
+ return null;
119
+ }
100
120
  /** The leaf cgroup name, e.g. `forge-bridge.service`. */
101
121
  export function cgroupLeafName(cgroupPath) {
102
122
  return cgroupPath.split("/").filter(Boolean).at(-1) ?? null;
@@ -108,7 +128,7 @@ export function cgroupLeafName(cgroupPath) {
108
128
  * FORGE_BRIDGE_CGROUP_UNIT. A `.scope` is rejected: a bridge started from a
109
129
  * terminal, SSH session or desktop app shares `session-N.scope` /
110
130
  * `app-*.scope` with unrelated work (possibly the owner's game).
111
- * Container cgroups (e.g. `docker-<id>.scope`) are added in decision 0013 step 2.
131
+ * Container cgroups (e.g. `docker-<id>.scope`) are not treated as dedicated yet.
112
132
  */
113
133
  export function isDedicatedBridgeUnit(unit, configuredUnit) {
114
134
  const configured = configuredUnit?.trim();
@@ -119,3 +139,30 @@ export function isDedicatedBridgeUnit(unit, configuredUnit) {
119
139
  && !/^app-/u.test(unit)
120
140
  && !/^user@\d+\.service$/u.test(unit);
121
141
  }
142
+ /**
143
+ * Reads the aggregate `cpu` line of /proc/stat. Busy time is user + nice +
144
+ * system + irq + softirq + steal (guest time is already inside user/nice);
145
+ * idle and iowait are not busy. Both counters are additive CPU time, so a
146
+ * cgroup's `cpu.stat` usage over the same window can be subtracted from them.
147
+ */
148
+ export function parseProcStatCpuTotals(content) {
149
+ let aggregate = null;
150
+ let cpuCount = 0;
151
+ for (const rawLine of content.split(/\r?\n/u)) {
152
+ const fields = rawLine.trim().split(/\s+/u);
153
+ if (fields[0] === "cpu") {
154
+ const values = fields.slice(1, 9).map(Number);
155
+ if (values.length < 8 || values.some(value => !Number.isSafeInteger(value) || value < 0))
156
+ return null;
157
+ aggregate = values;
158
+ }
159
+ else if (/^cpu\d+$/u.test(fields[0] ?? "")) {
160
+ cpuCount += 1;
161
+ }
162
+ }
163
+ if (!aggregate || cpuCount === 0)
164
+ return null;
165
+ const [user, nice, system, idle, iowait, irq, softirq, steal] = aggregate;
166
+ const busyTicks = user + nice + system + irq + softirq + steal;
167
+ return { busyTicks, totalTicks: busyTicks + idle + iowait, cpuCount };
168
+ }
@@ -1,3 +1,4 @@
1
+ import { type HostRuntimeRequirements } from "./host-runtime-requirements.js";
1
2
  export declare const hostRuntimeContractPath = ".forge/forge.runtime.yml";
2
3
  export declare const hostRuntimeTestPostgresAdminEnvironment = "FORGE_TEST_POSTGRES_ADMIN_CONNECTION_STRING";
3
4
  export declare const hostRuntimeLegacyTestPostgresEnvironment = "FORGE_TEST_POSTGRES_CONNECTION_STRING";
@@ -32,6 +33,8 @@ export interface HostRuntimeContract {
32
33
  readonly browserProfile: "isolated";
33
34
  readonly singletonResources: readonly string[];
34
35
  };
36
+ /** Decision 0013 placement requirements; absent or null when the contract declares none. */
37
+ readonly requires?: HostRuntimeRequirements | null;
35
38
  }
36
39
  export interface LoadedHostRuntimeContract {
37
40
  readonly contract: HostRuntimeContract;
@@ -54,6 +57,18 @@ export interface HostRuntimeDirectoryEntry {
54
57
  /** Returns one identity-bound directory inventory for runtime discovery. */
55
58
  export type HostRuntimeDirectorySnapshot = (target: string) => Promise<readonly HostRuntimeDirectoryEntry[]>;
56
59
  export declare function loadHostRuntimeContract(worktreePath: string, snapshot?: HostRuntimeSourceSnapshot, directorySnapshot?: HostRuntimeDirectorySnapshot): Promise<LoadedHostRuntimeContract>;
60
+ /** A managed attempt's own API master key: 32 random bytes, base64-encoded, as Security:MasterKey expects. */
61
+ export declare function newAttemptApiMasterKey(): string;
62
+ /**
63
+ * The environment a managed attempt's ASP.NET API launches with. When neither the launch profile
64
+ * nor the runtime contract configures Security__MasterKey or Security__MasterKeyFile, the API gets
65
+ * the attempt's own key. Otherwise ASP.NET Development falls back to the host user's dotnet
66
+ * user-secrets: the host's own key where they exist, and a failed secret write wherever they do not.
67
+ * The caller keeps one key for the attempt's whole life, so a restart against the same attempt
68
+ * database can still decrypt what was stored before it. The key is a secret: it is for the API
69
+ * process only, never for the environment handed to checks or providers.
70
+ */
71
+ export declare function withAttemptApiMasterKey(port: HostRuntimePortConfig, environment: Readonly<Record<string, string>>, attemptMasterKey: string): Readonly<Record<string, string>>;
57
72
  export declare function defaultHostRuntimeContract(): HostRuntimeContract;
58
73
  export declare function validateHostRuntimeContract(source: string): HostRuntimeContract;
59
74
  export declare function hostPortEnvironment(config: HostRuntimePortConfig, hostIp: "127.0.0.1", hostPort: number): Readonly<Record<string, string>>;
@@ -1,9 +1,12 @@
1
- import { createHash } from "node:crypto";
1
+ import { createHash, randomBytes } from "node:crypto";
2
2
  import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { isAlias, parseDocument, visit } from "yaml";
5
5
  import { readCanonicalSourceFile } from "./canonical-source-file.js";
6
6
  import { isGeneratedOutputDirectoryName } from "./generated-output-reset.js";
7
+ import { parseHostRuntimeRequirements } from "./host-runtime-requirements.js";
8
+ // A contract a WIP re-apply left conflicted runs as committed until the agent resolves it (see wip-git.ts).
9
+ import { committedWhileReapplyConflicted } from "../worktree/wip-git.js";
7
10
  export const hostRuntimeContractPath = ".forge/forge.runtime.yml";
8
11
  export const hostRuntimeTestPostgresAdminEnvironment = "FORGE_TEST_POSTGRES_ADMIN_CONNECTION_STRING";
9
12
  export const hostRuntimeLegacyTestPostgresEnvironment = "FORGE_TEST_POSTGRES_CONNECTION_STRING";
@@ -47,7 +50,7 @@ const ignoredDiscoveryDirectories = new Set([
47
50
  "vendor",
48
51
  "venv",
49
52
  ]);
50
- const topLevelKeys = new Set(["schemaVersion", "runtime"]);
53
+ const topLevelKeys = new Set(["schemaVersion", "runtime", "requires", "costHints"]);
51
54
  const runtimeKeys = new Set(["hostConcurrency", "ports", "playwright", "browserProfile", "singletonResources"]);
52
55
  const portKeys = new Set(["adapter", "launch", "env", "baseUrlEnv", "format"]);
53
56
  const launchKeys = new Set(["command", "args", "workingDirectory", "environment"]);
@@ -67,10 +70,10 @@ export async function loadHostRuntimeContract(worktreePath, snapshot, directoryS
67
70
  return await discoverHostRuntimeContract(worktreePath, snapshot, directorySnapshot);
68
71
  throw error;
69
72
  }
70
- return {
71
- contract: validateHostRuntimeContract(source.toString("utf8")),
72
- source: "project",
73
- };
73
+ const text = await committedWhileReapplyConflicted(worktreePath, hostRuntimeContractPath, source.toString("utf8"));
74
+ if (text === null)
75
+ return await discoverHostRuntimeContract(worktreePath, snapshot, directorySnapshot);
76
+ return { contract: validateHostRuntimeContract(text), source: "project" };
74
77
  }
75
78
  async function discoverHostRuntimeContract(worktreePath, snapshot, directorySnapshot) {
76
79
  const root = path.resolve(worktreePath);
@@ -424,6 +427,34 @@ function safeAspNetLaunchEnvironment(name, value) {
424
427
  "TMPDIR",
425
428
  ]).has(normalized);
426
429
  }
430
+ // The settings an ASP.NET API reads its secret-store master key from (Security:MasterKey wins).
431
+ const aspNetMasterKeySettings = ["security__masterkey", "security__masterkeyfile"];
432
+ /** A managed attempt's own API master key: 32 random bytes, base64-encoded, as Security:MasterKey expects. */
433
+ export function newAttemptApiMasterKey() {
434
+ return randomBytes(32).toString("base64");
435
+ }
436
+ /**
437
+ * The environment a managed attempt's ASP.NET API launches with. When neither the launch profile
438
+ * nor the runtime contract configures Security__MasterKey or Security__MasterKeyFile, the API gets
439
+ * the attempt's own key. Otherwise ASP.NET Development falls back to the host user's dotnet
440
+ * user-secrets: the host's own key where they exist, and a failed secret write wherever they do not.
441
+ * The caller keeps one key for the attempt's whole life, so a restart against the same attempt
442
+ * database can still decrypt what was stored before it. The key is a secret: it is for the API
443
+ * process only, never for the environment handed to checks or providers.
444
+ */
445
+ export function withAttemptApiMasterKey(port, environment, attemptMasterKey) {
446
+ if (port.adapter !== "aspnetcore")
447
+ return environment;
448
+ const masterKeySetting = (name) => aspNetMasterKeySettings.includes(name.toLowerCase());
449
+ if (Object.entries(environment).some(([name, value]) => masterKeySetting(name) && value.trim().length > 0)) {
450
+ return environment;
451
+ }
452
+ // A blank setting configures nothing; drop it so the attempt's key is the only one.
453
+ return {
454
+ ...Object.fromEntries(Object.entries(environment).filter(([name]) => !masterKeySetting(name))),
455
+ Security__MasterKey: attemptMasterKey,
456
+ };
457
+ }
427
458
  async function findFiles(root, accepts, maximumDepth, maximumEntries, snapshot) {
428
459
  const results = [];
429
460
  let examined = 0;
@@ -549,6 +580,7 @@ export function validateHostRuntimeContract(source) {
549
580
  throw new Error("runtime_contract_invalid: runtime.browserProfile must be isolated.");
550
581
  }
551
582
  const ports = parsePorts(runtime.ports);
583
+ const requires = parseHostRuntimeRequirements(root.requires, root.costHints);
552
584
  return {
553
585
  schemaVersion: 1,
554
586
  runtime: {
@@ -558,6 +590,7 @@ export function validateHostRuntimeContract(source) {
558
590
  browserProfile,
559
591
  singletonResources: parseSingletonResources(runtime.singletonResources),
560
592
  },
593
+ ...(requires ? { requires } : {}),
561
594
  };
562
595
  }
563
596
  function parsePlaywright(value, ports) {
@@ -1,4 +1,5 @@
1
- import type { RunOnceDispatchPacket } from "../session/session.types.js";
1
+ import type { HostRequirementsCheck } from "./host-runtime-requirements-check.js";
2
+ import { type RunOnceDispatchPacket } from "../session/session.types.js";
2
3
  import { type ProviderProcessRunner } from "../session/provider-cli/provider-cli.process.js";
3
4
  import { type RuntimeIsolationLease } from "./runtime-isolation-lease.js";
4
5
  import { type LoadedHostRuntimeContract } from "./host-runtime-contract.js";
@@ -12,6 +13,9 @@ import { type MemoryAdmissionDiagnostics } from "./memory-capacity.js";
12
13
  import { PlaywrightHostRuntimeAdapter } from "./playwright-host-runtime-adapter.js";
13
14
  import { HostParallelPromotionStore } from "./host-runtime-promotion.js";
14
15
  import { type HostProcessRecovery } from "../shared/process/host-process-recovery.js";
16
+ import { HostLoadGovernor } from "./host-load-governor.js";
17
+ import { type HostLoadGovernorSource } from "./host-load-sampler.js";
18
+ import type { RunnerHostDefaults } from "./runner-settings.js";
15
19
  export interface HostRuntimeLeaseStart {
16
20
  readonly lease: RuntimeIsolationLease;
17
21
  readonly environment: Readonly<Record<string, string>>;
@@ -25,7 +29,7 @@ export interface HostRuntimeAdmissionCheckpoint {
25
29
  }
26
30
  export type HostRuntimeAdmissionCheckpointHandler = (checkpoint: HostRuntimeAdmissionCheckpoint) => void | Promise<void>;
27
31
  export interface HostRuntimeProjectCheckpoint {
28
- readonly code: "host_runtime_build_started" | "host_runtime_build_cached" | "host_runtime_build_completed" | "host_runtime_database_provisioned";
32
+ readonly code: "host_runtime_build_started" | "host_runtime_build_waiting_for_host_capacity" | "host_runtime_build_cached" | "host_runtime_build_completed" | "host_runtime_database_provisioned" | "host_runtime_contract_readmitted" | "host_runtime_isolation_serialized";
29
33
  readonly message: string;
30
34
  readonly data?: Readonly<Record<string, unknown>>;
31
35
  }
@@ -69,6 +73,8 @@ export interface HostRuntimeReapOptions {
69
73
  readonly runnerId: string;
70
74
  readonly runnerInstanceId: string;
71
75
  readonly nowMs?: number;
76
+ /** Where maintenance reports a degraded lease it released or kept; the bridge log by default. */
77
+ readonly log?: (message: string) => void;
72
78
  }
73
79
  export interface HostRuntimeReapReport {
74
80
  readonly examined: number;
@@ -92,19 +98,36 @@ export interface HostNodeRuntimeLaunch<T> extends NodeRuntimeAdapterLaunch<T> {
92
98
  readonly runtimeLease: RuntimeIsolationLease;
93
99
  }
94
100
  export interface HostRuntimeLeaseRuntime {
101
+ setRequirementsCheck?(check: HostRequirementsCheck | null): void;
102
+ /** Decision 0014: today's max attempts and memory reserve defaults, before env bounds. */
103
+ capacityLimitDefaults?(): RunnerHostDefaults;
104
+ /** Decision 0014: the effective max attempts and memory reserve, from the next attempt admission. */
105
+ applyCapacityLimits?(limits: HostCapacityLimits): void;
95
106
  acquirePreparation?(dispatch: RunOnceDispatchPacket, signal?: AbortSignal): Promise<readonly string[]>;
96
107
  acquire(dispatch: RunOnceDispatchPacket, signal?: AbortSignal): Promise<readonly string[]>;
97
108
  start(dispatch: RunOnceDispatchPacket, worktreePath: string, signal?: AbortSignal, onAdmissionCheckpoint?: HostRuntimeAdmissionCheckpointHandler): Promise<HostRuntimeLeaseStart>;
98
109
  startConfiguredProject(dispatchAttemptId: string, fencingToken: string, signal?: AbortSignal, onProjectCheckpoint?: HostRuntimeProjectCheckpointHandler): Promise<HostRuntimeLeaseStart>;
110
+ /**
111
+ * Stops the attempt's configured project processes, releases their ports, and
112
+ * starts them again (rebuilding when sources changed) so the stack serves the
113
+ * current workspace. Returns the environment with the newly assigned URLs.
114
+ */
115
+ restartConfiguredProject?(dispatchAttemptId: string, fencingToken: string, signal?: AbortSignal, onProjectCheckpoint?: HostRuntimeProjectCheckpointHandler): Promise<HostRuntimeLeaseStart>;
99
116
  updateLease(dispatchAttemptId: string, fencingToken: string, expiresAt: string): Promise<void>;
100
117
  providerProcessRunner?(dispatchAttemptId: string, fencingToken: string): ProviderProcessRunner | null;
101
118
  providerMemoryTelemetry?(dispatchAttemptId: string, fencingToken: string): AttemptProcessTreeMemoryTelemetry | null;
102
119
  release(dispatchAttemptId: string, fencingToken: string): Promise<RuntimeIsolationLease | null>;
103
120
  invalidatePromotion?(repoId: string, scope?: "all" | "discovery"): Promise<void>;
121
+ promotionQuarantined?(repoId: string, runtimeContractFingerprint: string): Promise<boolean>;
122
+ /** The isolation violation the shared-run listener monitor found after launch, if any; the attempt must fail with it. */
123
+ isolationViolation?(dispatchAttemptId: string, fencingToken: string): Error | null;
104
124
  hasForegroundDemand?(): boolean;
105
125
  reap?(options: HostRuntimeReapOptions): Promise<HostRuntimeReapReport>;
106
126
  snapshot?(): HostRuntimeCapacitySnapshot;
127
+ /** Variables that let the completion MCP server share this host's load governor. */
128
+ hostLoadChildEnvironment?(): Readonly<Record<string, string>>;
107
129
  }
130
+ export type HostRuntimeAdmissionPriority = "foreground" | "background";
108
131
  export interface HostCapacityResourceSample {
109
132
  readonly totalMemoryBytes: number;
110
133
  readonly availableMemoryBytes: number;
@@ -140,15 +163,41 @@ export declare class HostRuntimeLeaseManager implements HostRuntimeLeaseRuntime
140
163
  private workspaceAvailableBytes;
141
164
  private readonly portBroker;
142
165
  private readonly nodeAdapter;
143
- private readonly capacityConfiguration;
166
+ /** Rebuilt by applyCapacityLimits (decision 0014); every admission reads the current one. */
167
+ private capacityConfiguration;
144
168
  private readonly memoryAvailability;
145
169
  private readonly executionRoot;
146
- constructor(stateRoot: string, portBroker?: HostPortBroker, nodeAdapter?: NodeHostRuntimeAdapter, processSupervisors?: AttemptProcessSupervisorRegistry, processRunner?: ProviderProcessRunner, listenerInspector?: HostListenerInspector, promotionStore?: HostParallelPromotionStore, playwrightAdapter?: PlaywrightHostRuntimeAdapter, processRecovery?: HostProcessRecovery, capacityResourceSample?: HostCapacityResourceSample | undefined, executionRoot?: string, databaseBroker?: AttemptDatabaseBroker | null);
170
+ /** Host-wide admission for heavy steps (decisions 0013, 0018): the host test slot, and the budget when on. */
171
+ readonly hostLoadGovernor: HostLoadGovernor;
172
+ private requirementsCheck;
173
+ /** Installs the decision 0013 accept-time requirements recheck for host attempts. */
174
+ setRequirementsCheck(check: HostRequirementsCheck | null): void;
175
+ constructor(stateRoot: string, portBroker?: HostPortBroker, nodeAdapter?: NodeHostRuntimeAdapter, processSupervisors?: AttemptProcessSupervisorRegistry, processRunner?: ProviderProcessRunner, listenerInspector?: HostListenerInspector, promotionStore?: HostParallelPromotionStore, playwrightAdapter?: PlaywrightHostRuntimeAdapter, processRecovery?: HostProcessRecovery, capacityResourceSample?: HostCapacityResourceSample | undefined, executionRoot?: string, databaseBroker?: AttemptDatabaseBroker | null, hostLoad?: HostLoadGovernorSource | null);
176
+ /** Today's defaults for the limits the server can push, before any env bound (decision 0014). */
177
+ capacityLimitDefaults(): RunnerHostDefaults;
178
+ /**
179
+ * Decision 0014: the bridge's effective max attempts and memory reserve. They
180
+ * apply from the next attempt admission; admitted attempts keep their
181
+ * reservations and are never preempted, even when the new limit is lower than
182
+ * what already runs. The idle reserve follows the reserve as at startup.
183
+ */
184
+ applyCapacityLimits(limits: HostCapacityLimits): void;
185
+ hostLoadChildEnvironment(): Readonly<Record<string, string>>;
147
186
  reap(options: HostRuntimeReapOptions): Promise<HostRuntimeReapReport>;
148
187
  snapshot(): HostRuntimeCapacitySnapshot;
149
188
  hasForegroundDemand(): boolean;
150
189
  acquirePreparation(dispatch: RunOnceDispatchPacket, signal?: AbortSignal): Promise<readonly string[]>;
151
190
  acquire(dispatch: RunOnceDispatchPacket, signal?: AbortSignal): Promise<readonly string[]>;
191
+ /**
192
+ * Whether acquire asks for shared project admission. A parallel-eligible probe in a promoted repository
193
+ * runs beside its shared runs (the listener audit fails it closed); otherwise it probes exclusively.
194
+ */
195
+ private sharedAdmissionRequested;
196
+ /**
197
+ * Whether a shared admission may launch without downgrading to exclusive: a stored proof matches the
198
+ * contract by isolation inputs or exact commit, or it is a still-eligible probe of an unrevoked repository.
199
+ */
200
+ private sharedAdmissionStillValid;
152
201
  private reserveHostCapacity;
153
202
  private reserveBackgroundAdmission;
154
203
  private hostCapacityAvailable;
@@ -165,14 +214,41 @@ export declare class HostRuntimeLeaseManager implements HostRuntimeLeaseRuntime
165
214
  start(dispatch: RunOnceDispatchPacket, worktreePath: string, signal?: AbortSignal, onAdmissionCheckpoint?: HostRuntimeAdmissionCheckpointHandler): Promise<HostRuntimeLeaseStart>;
166
215
  updateLease(dispatchAttemptId: string, fencingToken: string, expiresAt: string): Promise<void>;
167
216
  startConfiguredProject(dispatchAttemptId: string, fencingToken: string, signal?: AbortSignal, onProjectCheckpoint?: HostRuntimeProjectCheckpointHandler): Promise<HostRuntimeLeaseStart>;
217
+ /**
218
+ * Launches the configured project. Only the first launch, from the admitted commit's clean
219
+ * source, may record parallel-safety proof: a restart serves the workspace after the provider
220
+ * edited it, and a proof observed there would be stored under the admitted commit and could
221
+ * move this or a later attempt at that commit into shared admission for source it never ran.
222
+ */
223
+ private launchConfiguredProject;
224
+ /**
225
+ * Relaunches the configured project so it serves the current workspace. Every
226
+ * configured process stops (the API port changes, so the dev server's proxy target
227
+ * must change with it), its port reservation is released and dropped from the
228
+ * persisted lease, and the regular start path runs again, including the ASP.NET
229
+ * prebuild, whose receipt rebuilds only when the sources changed.
230
+ */
231
+ restartConfiguredProject(dispatchAttemptId: string, fencingToken: string, signal?: AbortSignal, onProjectCheckpoint?: HostRuntimeProjectCheckpointHandler): Promise<HostRuntimeLeaseStart>;
232
+ private runConfiguredProjectRestart;
233
+ /** Stops configured project processes in reverse launch order and releases their ports. */
234
+ private stopConfiguredProject;
168
235
  providerProcessRunner(dispatchAttemptId: string, fencingToken: string): ProviderProcessRunner | null;
236
+ isolationViolation(dispatchAttemptId: string, fencingToken: string): Error | null;
169
237
  private markCapacityReservationRunning;
170
238
  providerMemoryTelemetry(dispatchAttemptId: string, fencingToken: string): AttemptProcessTreeMemoryTelemetry | null;
239
+ /** Isolation enforcement for parallel-eligible contracts after each launch (restarts included); see monitorListeners. */
240
+ private auditRuntimeListeners;
241
+ /**
242
+ * Quarantines the contract and drops every promotion for the repository. An exclusive run collides with nobody, so it
243
+ * keeps running unpromoted and reports why; a shared one stops its project (a failed stop is left to release) and fails.
244
+ */
245
+ private handleIsolationViolation;
246
+ private monitorSharedRuntimeListeners;
171
247
  private promoteVerifiedRuntime;
172
248
  launchNodeRuntime<T>(dispatchAttemptId: string, fencingToken: string, portName: string, command: NodeRuntimeCommand, launcher: NodeRuntimeCommandLauncher<T>, signal?: AbortSignal): Promise<HostNodeRuntimeLaunch<T>>;
173
249
  release(dispatchAttemptId: string, fencingToken: string, preservePreparation?: boolean): Promise<RuntimeIsolationLease | null>;
174
250
  private readLedgers;
175
- private recoverPersistedProcesses;
251
+ /** Degrades and counts a ledger whose runtime may still be live. A retained released ledger owns no slot, so it is neither changed nor counted. */
176
252
  private markLedgerDegraded;
177
253
  private rememberDegraded;
178
254
  private forgetDegraded;
@@ -197,7 +273,8 @@ export declare class HostRuntimeLeaseManager implements HostRuntimeLeaseRuntime
197
273
  private drainParallelProjectWaiters;
198
274
  private drainBackgroundAdmissionWaiters;
199
275
  private refreshKnownPromotions;
200
- invalidatePromotion(repoId: string, scope?: "all" | "discovery"): Promise<void>;
276
+ invalidatePromotion(repoId: string, scope?: "all" | "discovery", quarantineFingerprints?: readonly string[]): Promise<void>;
277
+ promotionQuarantined(repoId: string, fingerprint: string): Promise<boolean>;
201
278
  private drainAdmissionWaiters;
202
279
  private reconcileReservationOwners;
203
280
  private reservationOwnerIsLive;
@@ -215,3 +292,21 @@ export declare class HostRuntimeCapacityRequestImpossibleError extends Error {
215
292
  }
216
293
  export declare function hostRuntimeEventResources(lease: RuntimeIsolationLease, runtimeContract?: LoadedHostRuntimeContract, executionClass?: HostRuntimeExecutionClass): Record<string, unknown>;
217
294
  export declare function hostRuntimeSingletonKeys(dispatch: RunOnceDispatchPacket): readonly string[];
295
+ /**
296
+ * Every environment key `hostRuntimeEnvironment` and the Playwright overlay derive from the
297
+ * configured project's assigned ports. They name a live stack, so they are withheld while the
298
+ * stack is down: after its ports are released another attempt may be assigned them.
299
+ */
300
+ export declare function hostRuntimeStackEnvironmentKeys(runtimeContract: LoadedHostRuntimeContract): readonly string[];
301
+ export declare function runtimeAdmissionPriority(dispatch: RunOnceDispatchPacket): HostRuntimeAdmissionPriority;
302
+ /** The pushed attempt limits (decision 0014), already resolved against host env bounds. */
303
+ export interface HostCapacityLimits {
304
+ readonly maxConcurrentAttempts: number;
305
+ readonly memoryReserveBytes: number;
306
+ }
307
+ /**
308
+ * Today's max attempts and adaptive memory reserve for this host, before
309
+ * FORGE_HOST_MAX_CONCURRENT_ATTEMPTS and FORGE_HOST_MEMORY_RESERVE_BYTES
310
+ * (decision 0014 treats those as bounds on the server's values).
311
+ */
312
+ export declare function hostCapacityLimitDefaults(capacityResourceSample?: HostCapacityResourceSample): RunnerHostDefaults;