@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,273 @@
1
+ import { ForgeFailureError } from "../session/session.types.js";
2
+ import { type HostLoadAdmissionDecision } from "./host-load-admission.js";
3
+ import { type HostLoadGovernorConfig } from "./host-load-governor-config.js";
4
+ import type { HostLoadGovernorSource } from "./host-load-sampler.js";
5
+ import type { HostLoadStepCost } from "./host-load-step-class.js";
6
+ import { type HostTestSlotControllerOptions } from "./host-load-capacity.js";
7
+ import { type HostLoadStepProcess, type HostLoadStepTerminator } from "./host-load-step-reaper.js";
8
+ /** What HostLoadStepGate.attachProcess takes, so a gate's callers need only this module. */
9
+ export type { HostLoadStepProcess } from "./host-load-step-reaper.js";
10
+ import { type HostLoadOwnerLiveness, type HostLoadToken, type HostLoadTokenOwner, type HostLoadTokenPriority } from "./host-load-token-ledger.js";
11
+ export interface HostLoadStepRequest {
12
+ readonly stepClass: string;
13
+ /** What the step is, for diagnostics (for example the validation check id). */
14
+ readonly label: string;
15
+ readonly cost: HostLoadStepCost;
16
+ readonly dispatchAttemptId: string | null;
17
+ readonly priority: HostLoadTokenPriority;
18
+ }
19
+ export interface HostLoadAcquireOptions {
20
+ readonly signal?: AbortSignal;
21
+ /**
22
+ * Called when the first admission decision says the step must wait, and again whenever the
23
+ * wait changes (see `waitChanged`), so a waiting receipt never names a holder that is gone.
24
+ */
25
+ readonly onWaiting?: (decision: HostLoadAdmissionDecision) => void | Promise<void>;
26
+ }
27
+ export interface HostLoadAdmission {
28
+ readonly tokenId: string;
29
+ readonly fencingToken: number;
30
+ readonly stepClass: string;
31
+ /** Time spent queued; never counted as step execution time. */
32
+ readonly waitMs: number;
33
+ readonly decision: HostLoadAdmissionDecision;
34
+ /**
35
+ * Aborted when the reservation is lost while the step runs: with
36
+ * host_capacity_token_fenced when the token was fenced (this owner stalled
37
+ * past its lease and another process saw it), or with
38
+ * host_capacity_ledger_unavailable when it could not be renewed for a whole
39
+ * lease. The step must stop; the token keeps its cost until it is released.
40
+ */
41
+ readonly fenced: AbortSignal;
42
+ /** Records the step's process tree, so a reclaim stops it before reusing its capacity. */
43
+ attachProcess(stepProcess: HostLoadStepProcess): Promise<void>;
44
+ /** Returns the token. Rejects with host_capacity_token_fenced if it was fenced or reclaimed. */
45
+ release(): Promise<void>;
46
+ /**
47
+ * Instead of release: the step ended but part of its process tree could not
48
+ * be proven gone. The token stays held, with its cost, and is returned only
49
+ * once `stillGone` (re-checked on every renewal) resolves true. Without a
50
+ * check, the token's recorded process tree is checked instead; with neither,
51
+ * the token is kept until attempt teardown has stopped the attempt's processes.
52
+ */
53
+ retainUntilStopped(stillGone: (() => Promise<boolean>) | null, reason: Error): void;
54
+ }
55
+ /** The gate heavy steps call before launching. */
56
+ export interface HostLoadStepGate {
57
+ readonly enabled: boolean;
58
+ /** The longest a step may queue in all before host_capacity_timeout, when the gate knows it. */
59
+ readonly maxWaitMs?: number;
60
+ acquire(request: HostLoadStepRequest, options?: HostLoadAcquireOptions): Promise<HostLoadAdmission>;
61
+ }
62
+ export declare class HostCapacityTimeoutError extends ForgeFailureError {
63
+ readonly stepClass: string;
64
+ readonly label: string;
65
+ readonly waitMs: number;
66
+ readonly code = "host_capacity_timeout";
67
+ constructor(stepClass: string, label: string, waitMs: number, detail: string);
68
+ }
69
+ /** The host test slot count a governor works with, and why (HostLoadGovernor.testSlotCapacity). */
70
+ export interface HostTestSlotCapacity {
71
+ /** FORGE_HOST_LOAD_TEST_SLOTS, or the auto size when it is unset. */
72
+ readonly configured: number;
73
+ readonly source: "auto" | "operator";
74
+ readonly detail: string;
75
+ /** Whether live load lowers the count (FORGE_HOST_LOAD_LIVE_SLOTS, and more than one slot). */
76
+ readonly liveAdjustment: boolean;
77
+ /**
78
+ * The count at the last admission or refresh pass, with the lowest count another governor on
79
+ * the state root published; the configured count before the first pass.
80
+ */
81
+ readonly inForce: number;
82
+ /** Why inForce is below configured; empty when it is not. */
83
+ readonly inForceDetail: string;
84
+ }
85
+ /** One log line: "Host test slots: 3 at once (auto-sized from …); lowered while other work needs the host." */
86
+ export declare function describeHostTestSlotCapacity(capacity: HostTestSlotCapacity): string;
87
+ export interface HostLoadGovernorOptions {
88
+ readonly stateRoot: string;
89
+ readonly load: HostLoadGovernorSource;
90
+ readonly config?: HostLoadGovernorConfig;
91
+ readonly liveness?: HostLoadOwnerLiveness;
92
+ /** Owner recorded on tokens (tests model separate processes); defaults to this process. */
93
+ readonly owner?: HostLoadTokenOwner;
94
+ readonly now?: () => number;
95
+ /** Test seam for the ledger's process-tree reaper. */
96
+ readonly terminateStep?: HostLoadStepTerminator;
97
+ /** Test seam for the host suspend counter. */
98
+ readonly suspendedMs?: () => number;
99
+ /** Test seam for live slot adjustment's shrink streak and grow settle period. */
100
+ readonly liveTestSlotTiming?: Pick<HostTestSlotControllerOptions, "shrinkSamples" | "growSettleMs">;
101
+ }
102
+ /**
103
+ * Host-wide admission for heavy steps (decision 0013). Waiters queue
104
+ * foreground before background and FIFO within a class; a waiter that fits may
105
+ * overtake an unfit head until the head has waited past the anti-starvation
106
+ * window. Running steps are never preempted. Reserved cost comes from the
107
+ * shared token ledger, so other processes' steps count against the same budget.
108
+ * The host test slot (decision 0018) comes first: a heavy step waits for it in
109
+ * the host-wide queue the ledger keeps, then for the budget when that is on.
110
+ */
111
+ export declare class HostLoadGovernor implements HostLoadStepGate {
112
+ private readonly options;
113
+ readonly enabled: boolean;
114
+ private readonly config;
115
+ private readonly ledger;
116
+ private readonly waiters;
117
+ private readonly held;
118
+ private recheckTimer;
119
+ private renewTimer;
120
+ private draining;
121
+ private drainAgain;
122
+ /** Own cgroup anonymous memory with no heavy step running: the bridge's baseline. */
123
+ private idleOwnMemoryBytes;
124
+ /** The bridge's pushed settings (decision 0014), shared with every governor on this state root. */
125
+ private readonly runtimeSettings;
126
+ /** Lowers the host test slot count while other work needs the machine; null when the count is fixed. */
127
+ private readonly liveTestSlots;
128
+ /** Lowered counts shared with the other governors on this state root. */
129
+ private readonly liveTestSlotsBoard;
130
+ private lastLiveTestSlots;
131
+ /** Feeds the controller while this governor holds slots or its count is lowered, so no backlog builds up. */
132
+ private liveFeedTimer;
133
+ constructor(options: HostLoadGovernorOptions);
134
+ get maxWaitMs(): number;
135
+ acquire(request: HostLoadStepRequest, options?: HostLoadAcquireOptions): Promise<HostLoadAdmission>;
136
+ /** Reclaims tokens whose owner is gone or whose lease expired (bridge startup). */
137
+ reclaim(): Promise<readonly HostLoadToken[]>;
138
+ /** Returns dead owners' unrecorded tokens the caller proved stopped (see the ledger). */
139
+ releaseOrphaned(belongs: (token: HostLoadToken) => boolean): Promise<readonly HostLoadToken[]>;
140
+ /**
141
+ * Attempt teardown: cancels the attempt's queued steps and stops its running
142
+ * ones (their `fenced` signal aborts with dispatch_cancelled). A running step
143
+ * keeps its token, and its cost, until the step itself returns it once its
144
+ * processes are gone, so the capacity is never reused while it still runs.
145
+ */
146
+ stopAttempt(dispatchAttemptId: string): void;
147
+ /**
148
+ * Cancels the attempt's queued steps and returns every token it holds at
149
+ * once. Only for callers that know the attempt's steps are no longer running;
150
+ * attempt teardown uses stopAttempt.
151
+ */
152
+ releaseAttempt(dispatchAttemptId: string): Promise<void>;
153
+ private cancelAttemptWaiters;
154
+ /** Waiting and admitted steps of this process, for diagnostics. */
155
+ snapshot(): {
156
+ readonly waiting: number;
157
+ readonly held: readonly HostLoadToken[];
158
+ };
159
+ /**
160
+ * The host test slot count and why, for diagnostics: the configured count (auto-sized or the
161
+ * operator's), and the count in force after the last live adjustment, with its reason.
162
+ */
163
+ testSlotCapacity(): HostTestSlotCapacity;
164
+ /**
165
+ * Folds the sampler's new readings into the live count with the holders the ledger has now,
166
+ * without admitting anything (the feed timer, and diagnostics). A no-op without live adjustment.
167
+ */
168
+ refreshTestSlots(): Promise<HostTestSlotCapacity>;
169
+ private drain;
170
+ private drainOnce;
171
+ /**
172
+ * Decision 0014: the CPU budget (or yield budget) and the heavy-step limit the
173
+ * bridge has in force apply from the next admission; running steps keep theirs.
174
+ * The operator's env ceilings hold with or without the file, and over whatever it says.
175
+ */
176
+ private budgetPass;
177
+ /**
178
+ * The host test slot count for this admission pass: the configured count, lowered while
179
+ * other work on the host needs the machine (host-load-capacity.ts), and never above the
180
+ * lowest count another governor on this state root has published. The controller folds in
181
+ * every sample it has not seen, each judged with the holders of the passes around it, and it
182
+ * is fed while this governor holds slots or has lowered its count (armLiveFeed), so its
183
+ * streaks follow the sampler's clock, not how often steps happen to queue.
184
+ */
185
+ private testSlotsInForce;
186
+ /** The lowest count other governors have published; null without live adjustment or when none is lowered. */
187
+ private publishedTestSlots;
188
+ /** Stops the live slot feed (tests, shutdown); the next pass that needs it arms it again. */
189
+ stopLiveFeed(): void;
190
+ /**
191
+ * While this governor holds a slot or its count is lowered, the controller is fed on the
192
+ * sampler's interval even when nothing waits: readings are then judged with the holders of
193
+ * their own time, and a lowered count can grow back (and its published file stay fresh).
194
+ * Waiters' admission passes feed it already.
195
+ */
196
+ private armLiveFeed;
197
+ /**
198
+ * The bridge's own cgroup anonymous memory in the latest sample (dedicated cgroup only), and,
199
+ * with no token on the host, its idle baseline: what Forge's steps use is measured above it.
200
+ */
201
+ private observeIdleOwnMemory;
202
+ /** The host test slot first (decision 0018), then the budget when it is on. */
203
+ private decide;
204
+ private readSignals;
205
+ /**
206
+ * Consecutive pressured samples ending with the latest one, read from the
207
+ * sampler's history so samples taken while nothing waited still count. A gap
208
+ * in sampling (sampler stopped, host suspended) breaks the streak.
209
+ */
210
+ private pressureStreak;
211
+ /**
212
+ * Memory the running steps already use, which MemAvailable already reflects,
213
+ * so the budget does not count it twice. Measured from the dedicated cgroup
214
+ * above its idle baseline; without one, a step admitted longer than the ramp
215
+ * window ago is assumed to hold its reservation. Never above the reservations.
216
+ */
217
+ private runningStepsMemoryBytes;
218
+ private logicalCpus;
219
+ /**
220
+ * Waiting behind healthy holders of the host test slot is progress: their steps run, and the slot passes
221
+ * down the queue as they finish. Any other wait (a holder past its lease or whose owner is gone, the
222
+ * budget, a recovering ledger) counts toward maxWaitMs from the last time the queue made progress.
223
+ */
224
+ private checkStalled;
225
+ private timeOut;
226
+ /**
227
+ * Wait reports run one at a time, in order, so a slow report (a dispatch event, a checkpoint) can
228
+ * never land after a newer one. A report still queued when the step is admitted or fails is
229
+ * dropped: it would be stale.
230
+ */
231
+ private notifyWaiting;
232
+ private settle;
233
+ /** Renewed tokens reset their lease clock; fenced ones stop their steps (they keep their cost until released). */
234
+ private applyHeldOutcome;
235
+ /** The step must stop: its reservation is no longer guaranteed. */
236
+ private lose;
237
+ /** Ledger failures reach every queued step instead of leaving it to time out. */
238
+ private failWaiters;
239
+ private attachProcess;
240
+ /**
241
+ * Returns a step's token. It stays held (and renewed) until the ledger takes
242
+ * it back, so a ledger outage cannot leave it to lapse into a fenced
243
+ * reservation; the renewal timer retries the release. A fenced token is
244
+ * removed too (its step is over) and the release reports the fence.
245
+ */
246
+ private releaseHeld;
247
+ private forget;
248
+ private armRecheck;
249
+ private disarmRecheck;
250
+ private armRenewal;
251
+ private disarmRenewal;
252
+ /**
253
+ * The step ended but part of its process tree may still run: its token stays
254
+ * held and renewed, with its cost, and the step's own termination check is
255
+ * retried on every renewal tick until it proves the tree gone.
256
+ */
257
+ private retainUntilStopped;
258
+ /**
259
+ * Attempt teardown stopped the attempt's processes (its process supervisor
260
+ * proved them gone): tokens kept for a tree nothing else can check are returned.
261
+ */
262
+ releaseRetainedAfterTeardown(dispatchAttemptId: string): Promise<void>;
263
+ private checkRetained;
264
+ private renewHeld;
265
+ }
266
+ /**
267
+ * Whether a waiting step should be told about this decision: its first wait, a new reason, or a
268
+ * host test slot wait whose holders or place in the queue moved. Budget and pressure details carry
269
+ * live load figures that change on every recheck, so only their reason counts.
270
+ */
271
+ export declare function waitChanged(previous: HostLoadAdmissionDecision | null, next: HostLoadAdmissionDecision): boolean;
272
+ /** Resolves once `notified` settles, or after `capMs` at the latest. */
273
+ export declare function afterNotified(notified: Promise<void>, capMs?: number): Promise<void>;