@loucompanion/forge-bridge 0.1.4-dev.fb770705136a → 0.2.1-dev.15efe2d7309f

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 (271) hide show
  1. package/README.md +146 -3
  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 +11 -0
  11. package/dist/bridge/bridge-state-io.js +50 -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 +92 -14
  18. package/dist/bridge/bridge.service.js +446 -380
  19. package/dist/bridge/bridge.types.d.ts +21 -0
  20. package/dist/bridge/in-flight-registry.d.ts +62 -0
  21. package/dist/bridge/in-flight-registry.js +207 -0
  22. package/dist/bridge/local-yield-flag.d.ts +6 -0
  23. package/dist/bridge/local-yield-flag.js +34 -0
  24. package/dist/bridge/readiness-result-outbox.d.ts +5 -1
  25. package/dist/bridge/readiness-result-outbox.js +20 -0
  26. package/dist/bridge/runner-host-capabilities.d.ts +5 -0
  27. package/dist/bridge/runner-host-capabilities.js +31 -1
  28. package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
  29. package/dist/bridge/sandbox-resource-accounting.js +150 -0
  30. package/dist/bridge/test-postgres-capability.d.ts +14 -0
  31. package/dist/bridge/test-postgres-capability.js +120 -0
  32. package/dist/bridge/windows-bash-resolution.d.ts +31 -0
  33. package/dist/bridge/windows-bash-resolution.js +153 -0
  34. package/dist/cleanup/cleanup-wip.d.ts +12 -0
  35. package/dist/cleanup/cleanup-wip.js +66 -0
  36. package/dist/cleanup/cleanup.service.d.ts +20 -1
  37. package/dist/cleanup/cleanup.service.js +150 -169
  38. package/dist/cleanup/cleanup.types.d.ts +6 -0
  39. package/dist/cleanup/forge-owned-paths.d.ts +9 -0
  40. package/dist/cleanup/forge-owned-paths.js +53 -0
  41. package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
  42. package/dist/cleanup/host-runtime-ledger.js +130 -0
  43. package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
  44. package/dist/cleanup/managed-branch-sweep.js +111 -0
  45. package/dist/cli/cli.help.js +74 -12
  46. package/dist/cli/cli.service.d.ts +19 -10
  47. package/dist/cli/cli.service.js +152 -187
  48. package/dist/cli/idle-status.d.ts +84 -0
  49. package/dist/cli/idle-status.js +181 -0
  50. package/dist/cli/local-config.d.ts +6 -0
  51. package/dist/cli/local-config.js +32 -4
  52. package/dist/cli/provider-cli-detection.d.ts +10 -0
  53. package/dist/cli/provider-cli-detection.js +160 -0
  54. package/dist/runtime/aspnet-runtime-prebuild.d.ts +20 -0
  55. package/dist/runtime/aspnet-runtime-prebuild.js +184 -18
  56. package/dist/runtime/attempt-database-broker.d.ts +1 -1
  57. package/dist/runtime/attempt-node-runtime-launcher.d.ts +36 -0
  58. package/dist/runtime/attempt-node-runtime-launcher.js +169 -0
  59. package/dist/runtime/attempt-process-supervisor.d.ts +2 -0
  60. package/dist/runtime/attempt-process-supervisor.js +12 -6
  61. package/dist/runtime/docker-engine-probe.d.ts +5 -0
  62. package/dist/runtime/docker-engine-probe.js +7 -0
  63. package/dist/runtime/dotnet-build-outputs.d.ts +107 -0
  64. package/dist/runtime/dotnet-build-outputs.js +402 -0
  65. package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
  66. package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
  67. package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
  68. package/dist/runtime/ephemeral-test-postgres.js +303 -0
  69. package/dist/runtime/host-facts.d.ts +2 -1
  70. package/dist/runtime/host-listener-inspector.d.ts +26 -0
  71. package/dist/runtime/host-listener-inspector.js +84 -3
  72. package/dist/runtime/host-load-admission.d.ts +72 -0
  73. package/dist/runtime/host-load-admission.js +99 -0
  74. package/dist/runtime/host-load-child-environment.d.ts +27 -0
  75. package/dist/runtime/host-load-child-environment.js +76 -0
  76. package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
  77. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  78. package/dist/runtime/host-load-governor-config.d.ts +61 -0
  79. package/dist/runtime/host-load-governor-config.js +86 -0
  80. package/dist/runtime/host-load-governor.d.ts +193 -0
  81. package/dist/runtime/host-load-governor.js +662 -0
  82. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  83. package/dist/runtime/host-load-ledger-lock.js +187 -0
  84. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  85. package/dist/runtime/host-load-runtime-settings.js +80 -0
  86. package/dist/runtime/host-load-sampler.d.ts +75 -2
  87. package/dist/runtime/host-load-sampler.js +142 -8
  88. package/dist/runtime/host-load-step-class.d.ts +70 -0
  89. package/dist/runtime/host-load-step-class.js +161 -0
  90. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  91. package/dist/runtime/host-load-step-reaper.js +95 -0
  92. package/dist/runtime/host-load-step-run.d.ts +73 -0
  93. package/dist/runtime/host-load-step-run.js +102 -0
  94. package/dist/runtime/host-load-test-slot.d.ts +43 -0
  95. package/dist/runtime/host-load-test-slot.js +88 -0
  96. package/dist/runtime/host-load-token-ledger.d.ts +200 -0
  97. package/dist/runtime/host-load-token-ledger.js +453 -0
  98. package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
  99. package/dist/runtime/host-load-windows-cpu.js +85 -0
  100. package/dist/runtime/host-pressure-stall.d.ts +21 -1
  101. package/dist/runtime/host-pressure-stall.js +48 -1
  102. package/dist/runtime/host-runtime-contract.d.ts +15 -0
  103. package/dist/runtime/host-runtime-contract.js +39 -6
  104. package/dist/runtime/host-runtime-lease.d.ts +101 -6
  105. package/dist/runtime/host-runtime-lease.js +408 -294
  106. package/dist/runtime/host-runtime-ledger-recovery.d.ts +20 -0
  107. package/dist/runtime/host-runtime-ledger-recovery.js +134 -0
  108. package/dist/runtime/host-runtime-promotion.d.ts +101 -2
  109. package/dist/runtime/host-runtime-promotion.js +355 -14
  110. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  111. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  112. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  113. package/dist/runtime/host-runtime-requirements.js +117 -0
  114. package/dist/runtime/managed-command-teardown.js +5 -16
  115. package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
  116. package/dist/runtime/native-test-postgres-fallback.js +60 -8
  117. package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
  118. package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
  119. package/dist/runtime/prepared-runtime-identity.d.ts +4 -0
  120. package/dist/runtime/prepared-runtime-identity.js +130 -9
  121. package/dist/runtime/prepared-runtime-readiness.d.ts +23 -1
  122. package/dist/runtime/prepared-runtime-readiness.js +89 -18
  123. package/dist/runtime/runner-settings.d.ts +104 -0
  124. package/dist/runtime/runner-settings.js +236 -0
  125. package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
  126. package/dist/runtime/supervised-runtime-build-guard.js +112 -0
  127. package/dist/sandbox/host-capacity-broker.d.ts +115 -0
  128. package/dist/sandbox/host-capacity-broker.js +336 -0
  129. package/dist/sandbox/managed-branch.d.ts +13 -0
  130. package/dist/sandbox/managed-branch.js +90 -0
  131. package/dist/sandbox/provider-auth/codex.js +11 -11
  132. package/dist/sandbox/runtime.d.ts +10 -1
  133. package/dist/sandbox/runtime.js +47 -8
  134. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  135. package/dist/sandbox/sandbox-cgroups.js +42 -0
  136. package/dist/session/architect-waits.d.ts +2 -0
  137. package/dist/session/architect-waits.js +138 -0
  138. package/dist/session/managed-attempt-tools.d.ts +2 -7
  139. package/dist/session/managed-attempt-tools.js +207 -121
  140. package/dist/session/managed-build-coordinator.d.ts +16 -0
  141. package/dist/session/managed-build-coordinator.js +10 -0
  142. package/dist/session/managed-build-receipt.d.ts +5 -0
  143. package/dist/session/managed-build-receipt.js +8 -3
  144. package/dist/session/managed-command-host-load.d.ts +47 -0
  145. package/dist/session/managed-command-host-load.js +83 -0
  146. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  147. package/dist/session/mcp-argument-coercion.js +121 -0
  148. package/dist/session/phase-completion.artifacts.d.ts +7 -0
  149. package/dist/session/phase-completion.artifacts.js +96 -26
  150. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  151. package/dist/session/phase-completion.command-validation.js +77 -0
  152. package/dist/session/phase-completion.d.ts +12 -0
  153. package/dist/session/phase-completion.helpers.js +13 -12
  154. package/dist/session/phase-completion.js +5 -0
  155. package/dist/session/phase-completion.mcp-args.d.ts +9 -0
  156. package/dist/session/phase-completion.mcp-args.js +156 -0
  157. package/dist/session/phase-completion.prompts.js +6 -1
  158. package/dist/session/phase-completion.runtime.d.ts +5 -11
  159. package/dist/session/phase-completion.runtime.js +91 -215
  160. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  161. package/dist/session/phase-completion.schema-parts.js +188 -0
  162. package/dist/session/phase-completion.schemas.d.ts +3 -3
  163. package/dist/session/phase-completion.schemas.js +208 -231
  164. package/dist/session/phase-completion.validation.d.ts +2 -3
  165. package/dist/session/phase-completion.validation.js +49 -93
  166. package/dist/session/pre-publication-host-load.d.ts +27 -0
  167. package/dist/session/pre-publication-host-load.js +111 -0
  168. package/dist/session/pre-publication-native-postgres.d.ts +30 -0
  169. package/dist/session/pre-publication-native-postgres.js +111 -0
  170. package/dist/session/pre-publication-pass.d.ts +61 -0
  171. package/dist/session/pre-publication-pass.js +148 -0
  172. package/dist/session/pre-publication-process.d.ts +3 -0
  173. package/dist/session/pre-publication-process.js +31 -19
  174. package/dist/session/pre-publication-step-execution.d.ts +12 -0
  175. package/dist/session/pre-publication-step-execution.js +50 -0
  176. package/dist/session/pre-publication-validation.d.ts +37 -21
  177. package/dist/session/pre-publication-validation.js +221 -182
  178. package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
  179. package/dist/session/provider-cli/claude-background-work.js +181 -0
  180. package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
  181. package/dist/session/provider-cli/host-build-lock.js +30 -0
  182. package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
  183. package/dist/session/provider-cli/pre-publication-repair.js +277 -0
  184. package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
  185. package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
  186. package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
  187. package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
  188. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +6 -3
  189. package/dist/session/provider-cli/provider-cli.merge-integrity.js +29 -10
  190. package/dist/session/provider-cli/provider-cli.process.d.ts +15 -36
  191. package/dist/session/provider-cli/provider-cli.process.js +41 -432
  192. package/dist/session/provider-cli/provider-cli.prompts.d.ts +15 -0
  193. package/dist/session/provider-cli/provider-cli.prompts.js +109 -32
  194. package/dist/session/provider-cli/provider-cli.runtime.d.ts +8 -0
  195. package/dist/session/provider-cli/provider-cli.runtime.js +29 -1
  196. package/dist/session/provider-cli/provider-cli.service.d.ts +7 -1
  197. package/dist/session/provider-cli/provider-cli.service.js +106 -181
  198. package/dist/session/provider-cli/provider-cli.types.d.ts +35 -0
  199. package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
  200. package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
  201. package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
  202. package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
  203. package/dist/session/provider-cli/provider-in-flight-work.d.ts +4 -0
  204. package/dist/session/provider-cli/provider-in-flight-work.js +45 -0
  205. package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
  206. package/dist/session/provider-cli/provider-output-pipes.js +67 -0
  207. package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
  208. package/dist/session/provider-cli/provider-output-state.js +6 -0
  209. package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
  210. package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
  211. package/dist/session/qa-sidecar-validation.d.ts +6 -0
  212. package/dist/session/qa-sidecar-validation.js +28 -0
  213. package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
  214. package/dist/session/sandbox-host-capacity-gate.js +257 -0
  215. package/dist/session/session-host-project.d.ts +22 -0
  216. package/dist/session/session-host-project.js +98 -0
  217. package/dist/session/session-redaction.js +31 -181
  218. package/dist/session/session.base.d.ts +9 -1
  219. package/dist/session/session.service.d.ts +15 -2
  220. package/dist/session/session.service.js +246 -138
  221. package/dist/session/session.types.d.ts +4 -0
  222. package/dist/session/session.types.js +7 -7
  223. package/dist/session/sidecar-json-shape.d.ts +31 -0
  224. package/dist/session/sidecar-json-shape.js +217 -0
  225. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  226. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  227. package/dist/shared/fs/file-identity.d.ts +10 -0
  228. package/dist/shared/fs/file-identity.js +15 -0
  229. package/dist/shared/fs/replace-file.d.ts +7 -0
  230. package/dist/shared/fs/replace-file.js +33 -0
  231. package/dist/shared/process/host-process-recovery.d.ts +14 -3
  232. package/dist/shared/process/host-process-recovery.js +23 -3
  233. package/dist/shared/process/host-process-supervisor.d.ts +14 -1
  234. package/dist/shared/process/host-process-supervisor.js +67 -15
  235. package/dist/shared/process/process-tree.d.ts +52 -0
  236. package/dist/shared/process/process-tree.js +144 -0
  237. package/dist/shared/process/process.d.ts +67 -0
  238. package/dist/shared/process/process.js +213 -11
  239. package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
  240. package/dist/shared/process/windows-app-execution-alias.js +45 -0
  241. package/dist/shared/process/windows-launch.d.ts +18 -0
  242. package/dist/shared/process/windows-launch.js +68 -0
  243. package/dist/shared/provider-capabilities.js +14 -7
  244. package/dist/version.d.ts +1 -1
  245. package/dist/version.js +1 -1
  246. package/dist/worktree/dependency-warmer.d.ts +25 -0
  247. package/dist/worktree/dependency-warmer.js +46 -10
  248. package/dist/worktree/orphan-relink.d.ts +19 -0
  249. package/dist/worktree/orphan-relink.js +106 -0
  250. package/dist/worktree/wip-git.d.ts +58 -0
  251. package/dist/worktree/wip-git.js +182 -0
  252. package/dist/worktree/wip-refs.d.ts +85 -0
  253. package/dist/worktree/wip-refs.js +169 -0
  254. package/dist/worktree/wip-restore.d.ts +51 -0
  255. package/dist/worktree/wip-restore.js +324 -0
  256. package/dist/worktree/wip-snapshot.d.ts +53 -0
  257. package/dist/worktree/wip-snapshot.js +270 -0
  258. package/dist/worktree/worktree-inputs.d.ts +8 -0
  259. package/dist/worktree/worktree-inputs.js +134 -0
  260. package/dist/worktree/worktree-origin-sync.d.ts +35 -0
  261. package/dist/worktree/worktree-origin-sync.js +128 -0
  262. package/dist/worktree/worktree-wip-events.d.ts +20 -0
  263. package/dist/worktree/worktree-wip-events.js +148 -0
  264. package/dist/worktree/worktree-wip.d.ts +57 -0
  265. package/dist/worktree/worktree-wip.js +200 -0
  266. package/dist/worktree/worktree.base.d.ts +7 -1
  267. package/dist/worktree/worktree.service.d.ts +36 -5
  268. package/dist/worktree/worktree.service.js +127 -155
  269. package/dist/worktree/worktree.types.d.ts +47 -0
  270. package/package.json +2 -2
  271. package/runtime/windows-listener-owner.ps1 +12 -1
@@ -0,0 +1,193 @@
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 HostLoadStepProcess, type HostLoadStepTerminator } from "./host-load-step-reaper.js";
7
+ /** What HostLoadStepGate.attachProcess takes, so a gate's callers need only this module. */
8
+ export type { HostLoadStepProcess } from "./host-load-step-reaper.js";
9
+ import { type HostLoadOwnerLiveness, type HostLoadToken, type HostLoadTokenOwner, type HostLoadTokenPriority } from "./host-load-token-ledger.js";
10
+ export interface HostLoadStepRequest {
11
+ readonly stepClass: string;
12
+ /** What the step is, for diagnostics (for example the validation check id). */
13
+ readonly label: string;
14
+ readonly cost: HostLoadStepCost;
15
+ readonly dispatchAttemptId: string | null;
16
+ readonly priority: HostLoadTokenPriority;
17
+ }
18
+ export interface HostLoadAcquireOptions {
19
+ readonly signal?: AbortSignal;
20
+ /** Called once, when the first admission decision says the step must wait. */
21
+ readonly onWaiting?: (decision: HostLoadAdmissionDecision) => void | Promise<void>;
22
+ }
23
+ export interface HostLoadAdmission {
24
+ readonly tokenId: string;
25
+ readonly fencingToken: number;
26
+ readonly stepClass: string;
27
+ /** Time spent queued; never counted as step execution time. */
28
+ readonly waitMs: number;
29
+ readonly decision: HostLoadAdmissionDecision;
30
+ /**
31
+ * Aborted when the reservation is lost while the step runs: with
32
+ * host_capacity_token_fenced when the token was fenced (this owner stalled
33
+ * past its lease and another process saw it), or with
34
+ * host_capacity_ledger_unavailable when it could not be renewed for a whole
35
+ * lease. The step must stop; the token keeps its cost until it is released.
36
+ */
37
+ readonly fenced: AbortSignal;
38
+ /** Records the step's process tree, so a reclaim stops it before reusing its capacity. */
39
+ attachProcess(stepProcess: HostLoadStepProcess): Promise<void>;
40
+ /** Returns the token. Rejects with host_capacity_token_fenced if it was fenced or reclaimed. */
41
+ release(): Promise<void>;
42
+ /**
43
+ * Instead of release: the step ended but part of its process tree could not
44
+ * be proven gone. The token stays held, with its cost, and is returned only
45
+ * once `stillGone` (re-checked on every renewal) resolves true. Without a
46
+ * check, the token's recorded process tree is checked instead; with neither,
47
+ * the token is kept until attempt teardown has stopped the attempt's processes.
48
+ */
49
+ retainUntilStopped(stillGone: (() => Promise<boolean>) | null, reason: Error): void;
50
+ }
51
+ /** The gate heavy steps call before launching. */
52
+ export interface HostLoadStepGate {
53
+ readonly enabled: boolean;
54
+ /** The longest a step may queue in all before host_capacity_timeout, when the gate knows it. */
55
+ readonly maxWaitMs?: number;
56
+ acquire(request: HostLoadStepRequest, options?: HostLoadAcquireOptions): Promise<HostLoadAdmission>;
57
+ }
58
+ export declare class HostCapacityTimeoutError extends ForgeFailureError {
59
+ readonly stepClass: string;
60
+ readonly label: string;
61
+ readonly waitMs: number;
62
+ readonly code = "host_capacity_timeout";
63
+ constructor(stepClass: string, label: string, waitMs: number, detail: string);
64
+ }
65
+ export interface HostLoadGovernorOptions {
66
+ readonly stateRoot: string;
67
+ readonly load: HostLoadGovernorSource;
68
+ readonly config?: HostLoadGovernorConfig;
69
+ readonly liveness?: HostLoadOwnerLiveness;
70
+ /** Owner recorded on tokens (tests model separate processes); defaults to this process. */
71
+ readonly owner?: HostLoadTokenOwner;
72
+ readonly now?: () => number;
73
+ /** Test seam for the ledger's process-tree reaper. */
74
+ readonly terminateStep?: HostLoadStepTerminator;
75
+ /** Test seam for the host suspend counter. */
76
+ readonly suspendedMs?: () => number;
77
+ }
78
+ /**
79
+ * Host-wide admission for heavy steps (decision 0013). Waiters queue
80
+ * foreground before background and FIFO within a class; a waiter that fits may
81
+ * overtake an unfit head until the head has waited past the anti-starvation
82
+ * window. Running steps are never preempted. Reserved cost comes from the
83
+ * shared token ledger, so other processes' steps count against the same budget.
84
+ * The host test slot (decision 0018) comes first: a heavy step waits for it in
85
+ * the host-wide queue the ledger keeps, then for the budget when that is on.
86
+ */
87
+ export declare class HostLoadGovernor implements HostLoadStepGate {
88
+ private readonly options;
89
+ readonly enabled: boolean;
90
+ private readonly config;
91
+ private readonly ledger;
92
+ private readonly waiters;
93
+ private readonly held;
94
+ private recheckTimer;
95
+ private renewTimer;
96
+ private draining;
97
+ private drainAgain;
98
+ /** Own cgroup anonymous memory with no heavy step running: the bridge's baseline. */
99
+ private idleOwnMemoryBytes;
100
+ /** The bridge's pushed settings (decision 0014), shared with every governor on this state root. */
101
+ private readonly runtimeSettings;
102
+ constructor(options: HostLoadGovernorOptions);
103
+ get maxWaitMs(): number;
104
+ acquire(request: HostLoadStepRequest, options?: HostLoadAcquireOptions): Promise<HostLoadAdmission>;
105
+ /** Reclaims tokens whose owner is gone or whose lease expired (bridge startup). */
106
+ reclaim(): Promise<readonly HostLoadToken[]>;
107
+ /** Returns dead owners' unrecorded tokens the caller proved stopped (see the ledger). */
108
+ releaseOrphaned(belongs: (token: HostLoadToken) => boolean): Promise<readonly HostLoadToken[]>;
109
+ /**
110
+ * Attempt teardown: cancels the attempt's queued steps and stops its running
111
+ * ones (their `fenced` signal aborts with dispatch_cancelled). A running step
112
+ * keeps its token, and its cost, until the step itself returns it once its
113
+ * processes are gone, so the capacity is never reused while it still runs.
114
+ */
115
+ stopAttempt(dispatchAttemptId: string): void;
116
+ /**
117
+ * Cancels the attempt's queued steps and returns every token it holds at
118
+ * once. Only for callers that know the attempt's steps are no longer running;
119
+ * attempt teardown uses stopAttempt.
120
+ */
121
+ releaseAttempt(dispatchAttemptId: string): Promise<void>;
122
+ private cancelAttemptWaiters;
123
+ /** Waiting and admitted steps of this process, for diagnostics. */
124
+ snapshot(): {
125
+ readonly waiting: number;
126
+ readonly held: readonly HostLoadToken[];
127
+ };
128
+ private drain;
129
+ private drainOnce;
130
+ /**
131
+ * Decision 0014: the CPU budget (or yield budget) and the heavy-step limit the
132
+ * bridge has in force apply from the next admission; running steps keep theirs.
133
+ * The operator's env ceilings hold with or without the file, and over whatever it says.
134
+ */
135
+ private budgetPass;
136
+ /** The host test slot first (decision 0018), then the budget when it is on. */
137
+ private decide;
138
+ private readSignals;
139
+ /**
140
+ * Consecutive pressured samples ending with the latest one, read from the
141
+ * sampler's history so samples taken while nothing waited still count. A gap
142
+ * in sampling (sampler stopped, host suspended) breaks the streak.
143
+ */
144
+ private pressureStreak;
145
+ /**
146
+ * Memory the running steps already use, which MemAvailable already reflects,
147
+ * so the budget does not count it twice. Measured from the dedicated cgroup
148
+ * above its idle baseline; without one, a step admitted longer than the ramp
149
+ * window ago is assumed to hold its reservation. Never above the reservations.
150
+ */
151
+ private runningStepsMemoryBytes;
152
+ private logicalCpus;
153
+ /**
154
+ * Waiting behind healthy holders of the host test slot is progress: their steps run, and the slot passes
155
+ * down the queue as they finish. Any other wait (a holder past its lease or whose owner is gone, the
156
+ * budget, a recovering ledger) counts toward maxWaitMs from the last time the queue made progress.
157
+ */
158
+ private checkStalled;
159
+ private timeOut;
160
+ private settle;
161
+ /** Renewed tokens reset their lease clock; fenced ones stop their steps (they keep their cost until released). */
162
+ private applyHeldOutcome;
163
+ /** The step must stop: its reservation is no longer guaranteed. */
164
+ private lose;
165
+ /** Ledger failures reach every queued step instead of leaving it to time out. */
166
+ private failWaiters;
167
+ private attachProcess;
168
+ /**
169
+ * Returns a step's token. It stays held (and renewed) until the ledger takes
170
+ * it back, so a ledger outage cannot leave it to lapse into a fenced
171
+ * reservation; the renewal timer retries the release. A fenced token is
172
+ * removed too (its step is over) and the release reports the fence.
173
+ */
174
+ private releaseHeld;
175
+ private forget;
176
+ private armRecheck;
177
+ private disarmRecheck;
178
+ private armRenewal;
179
+ private disarmRenewal;
180
+ /**
181
+ * The step ended but part of its process tree may still run: its token stays
182
+ * held and renewed, with its cost, and the step's own termination check is
183
+ * retried on every renewal tick until it proves the tree gone.
184
+ */
185
+ private retainUntilStopped;
186
+ /**
187
+ * Attempt teardown stopped the attempt's processes (its process supervisor
188
+ * proved them gone): tokens kept for a tree nothing else can check are returned.
189
+ */
190
+ releaseRetainedAfterTeardown(dispatchAttemptId: string): Promise<void>;
191
+ private checkRetained;
192
+ private renewHeld;
193
+ }