@loucompanion/forge-bridge 0.2.1-dev.4f11ffc822f9 → 0.2.1-dev.7171bf414613

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 (152) hide show
  1. package/README.md +41 -3
  2. package/dist/bridge/bridge-state-io.d.ts +6 -2
  3. package/dist/bridge/bridge-state-io.js +22 -4
  4. package/dist/bridge/bridge.service.d.ts +10 -0
  5. package/dist/bridge/bridge.service.js +63 -101
  6. package/dist/bridge/bridge.types.d.ts +16 -0
  7. package/dist/bridge/bridge.types.js +2 -1
  8. package/dist/bridge/default-session-service.d.ts +13 -0
  9. package/dist/bridge/default-session-service.js +22 -0
  10. package/dist/bridge/dispatch-offer-policy.d.ts +22 -0
  11. package/dist/bridge/dispatch-offer-policy.js +58 -0
  12. package/dist/bridge/runner-host-capabilities.js +14 -1
  13. package/dist/bridge/windows-bash-resolution.d.ts +31 -0
  14. package/dist/bridge/windows-bash-resolution.js +153 -0
  15. package/dist/cleanup/cleanup-wip.js +3 -3
  16. package/dist/cleanup/forge-owned-paths.d.ts +2 -0
  17. package/dist/cleanup/forge-owned-paths.js +9 -0
  18. package/dist/cli/cli.help.js +1 -1
  19. package/dist/cli/cli.service.js +11 -43
  20. package/dist/cli/local-config.d.ts +12 -1
  21. package/dist/cli/local-config.js +35 -1
  22. package/dist/cli/provider-cli-advertising.d.ts +24 -0
  23. package/dist/cli/provider-cli-advertising.js +88 -0
  24. package/dist/runtime/host-load-admission.d.ts +5 -0
  25. package/dist/runtime/host-load-capacity.d.ts +198 -0
  26. package/dist/runtime/host-load-capacity.js +353 -0
  27. package/dist/runtime/host-load-child-environment.d.ts +13 -0
  28. package/dist/runtime/host-load-child-environment.js +35 -1
  29. package/dist/runtime/host-load-governor-config.d.ts +33 -3
  30. package/dist/runtime/host-load-governor-config.js +24 -3
  31. package/dist/runtime/host-load-governor.d.ts +89 -2
  32. package/dist/runtime/host-load-governor.js +217 -18
  33. package/dist/runtime/host-load-live-test-slots.d.ts +61 -0
  34. package/dist/runtime/host-load-live-test-slots.js +193 -0
  35. package/dist/runtime/host-load-sampler.d.ts +17 -0
  36. package/dist/runtime/host-load-sampler.js +24 -0
  37. package/dist/runtime/host-load-step-run.d.ts +37 -3
  38. package/dist/runtime/host-load-step-run.js +63 -7
  39. package/dist/runtime/host-load-test-slot.d.ts +3 -0
  40. package/dist/runtime/host-load-test-slot.js +26 -7
  41. package/dist/runtime/host-runtime-contract.js +6 -4
  42. package/dist/runtime/prepared-runtime-readiness.d.ts +12 -2
  43. package/dist/runtime/prepared-runtime-readiness.js +35 -11
  44. package/dist/sandbox/runtime.d.ts +1 -2
  45. package/dist/sandbox/runtime.js +8 -14
  46. package/dist/sandbox/sandbox-input.d.ts +22 -0
  47. package/dist/sandbox/sandbox-input.js +49 -0
  48. package/dist/sandbox/workspace.service.js +15 -2
  49. package/dist/session/managed-attempt-tools.js +6 -29
  50. package/dist/session/managed-build-receipt.d.ts +3 -1
  51. package/dist/session/managed-build-receipt.js +5 -2
  52. package/dist/session/managed-command-environment.d.ts +8 -0
  53. package/dist/session/managed-command-environment.js +28 -0
  54. package/dist/session/managed-command-host-load.d.ts +10 -5
  55. package/dist/session/managed-command-host-load.js +18 -14
  56. package/dist/session/phase-completion.artifact-bundle.d.ts +20 -0
  57. package/dist/session/phase-completion.artifact-bundle.js +167 -0
  58. package/dist/session/phase-completion.artifacts.d.ts +2 -17
  59. package/dist/session/phase-completion.artifacts.js +63 -165
  60. package/dist/session/phase-completion.d.ts +25 -2
  61. package/dist/session/phase-completion.helpers.js +5 -53
  62. package/dist/session/phase-completion.js +15 -32
  63. package/dist/session/phase-completion.mcp-args.js +69 -2
  64. package/dist/session/phase-completion.phase-aliases.d.ts +5 -0
  65. package/dist/session/phase-completion.phase-aliases.js +43 -0
  66. package/dist/session/phase-completion.pr-review-schema.d.ts +1 -0
  67. package/dist/session/phase-completion.pr-review-schema.js +75 -0
  68. package/dist/session/phase-completion.pr-review-threads.d.ts +34 -0
  69. package/dist/session/phase-completion.pr-review-threads.js +90 -0
  70. package/dist/session/phase-completion.pr-review-validation.d.ts +11 -0
  71. package/dist/session/phase-completion.pr-review-validation.js +215 -0
  72. package/dist/session/phase-completion.pr-review.d.ts +36 -0
  73. package/dist/session/phase-completion.pr-review.js +294 -0
  74. package/dist/session/phase-completion.prompts.d.ts +1 -1
  75. package/dist/session/phase-completion.prompts.js +14 -0
  76. package/dist/session/phase-completion.runtime.js +9 -3
  77. package/dist/session/phase-completion.schemas.js +12 -2
  78. package/dist/session/phase-completion.validation.d.ts +1 -0
  79. package/dist/session/phase-completion.validation.js +9 -1
  80. package/dist/session/pr-review-diff-base.d.ts +18 -0
  81. package/dist/session/pr-review-diff-base.js +45 -0
  82. package/dist/session/pr-review-placement.d.ts +50 -0
  83. package/dist/session/pr-review-placement.js +91 -0
  84. package/dist/session/pre-publication-change-set.d.ts +62 -0
  85. package/dist/session/pre-publication-change-set.js +166 -0
  86. package/dist/session/pre-publication-host-load.js +6 -5
  87. package/dist/session/pre-publication-process.js +3 -2
  88. package/dist/session/pre-publication-validation.d.ts +2 -1
  89. package/dist/session/pre-publication-validation.js +31 -36
  90. package/dist/session/provider-cli/dispatch-target-branch.d.ts +7 -0
  91. package/dist/session/provider-cli/dispatch-target-branch.js +8 -0
  92. package/dist/session/provider-cli/pr-review-credential-isolation.d.ts +83 -0
  93. package/dist/session/provider-cli/pr-review-credential-isolation.js +144 -0
  94. package/dist/session/provider-cli/pr-review-guardrails.d.ts +70 -0
  95. package/dist/session/provider-cli/pr-review-guardrails.js +360 -0
  96. package/dist/session/provider-cli/pr-review-prompt.d.ts +11 -0
  97. package/dist/session/provider-cli/pr-review-prompt.js +132 -0
  98. package/dist/session/provider-cli/pre-publication-repair.js +8 -3
  99. package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
  100. package/dist/session/provider-cli/provider-cli.deterministic.d.ts +1 -0
  101. package/dist/session/provider-cli/provider-cli.deterministic.js +5 -0
  102. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +6 -3
  103. package/dist/session/provider-cli/provider-cli.merge-integrity.js +29 -10
  104. package/dist/session/provider-cli/provider-cli.pr-review.d.ts +23 -0
  105. package/dist/session/provider-cli/provider-cli.pr-review.js +213 -0
  106. package/dist/session/provider-cli/provider-cli.prompts.d.ts +10 -3
  107. package/dist/session/provider-cli/provider-cli.prompts.js +123 -70
  108. package/dist/session/provider-cli/provider-cli.reapply-conflicts.d.ts +10 -0
  109. package/dist/session/provider-cli/provider-cli.reapply-conflicts.js +37 -0
  110. package/dist/session/provider-cli/provider-cli.runtime.d.ts +7 -0
  111. package/dist/session/provider-cli/provider-cli.runtime.js +14 -0
  112. package/dist/session/provider-cli/provider-cli.service-support.d.ts +37 -0
  113. package/dist/session/provider-cli/provider-cli.service-support.js +146 -0
  114. package/dist/session/provider-cli/provider-cli.service.d.ts +11 -17
  115. package/dist/session/provider-cli/provider-cli.service.js +33 -148
  116. package/dist/session/provider-cli/provider-cli.types.d.ts +7 -2
  117. package/dist/session/sandbox-host-capacity-gate.js +29 -7
  118. package/dist/session/session-host-project.d.ts +22 -0
  119. package/dist/session/session-host-project.js +98 -0
  120. package/dist/session/session.parse-helpers.d.ts +10 -0
  121. package/dist/session/session.parse-helpers.js +84 -0
  122. package/dist/session/session.runtime-refresh.d.ts +46 -0
  123. package/dist/session/session.runtime-refresh.js +116 -0
  124. package/dist/session/session.service.d.ts +2 -1
  125. package/dist/session/session.service.js +57 -158
  126. package/dist/session/session.types.d.ts +5 -0
  127. package/dist/session/session.types.js +8 -78
  128. package/dist/session/session.types.pr-review.d.ts +59 -0
  129. package/dist/session/session.types.pr-review.js +53 -0
  130. package/dist/shared/provider-capabilities.d.ts +2 -0
  131. package/dist/shared/provider-capabilities.js +9 -0
  132. package/dist/version.d.ts +1 -1
  133. package/dist/version.js +1 -1
  134. package/dist/worktree/artifact-injector.js +24 -0
  135. package/dist/worktree/wip-git.d.ts +25 -0
  136. package/dist/worktree/wip-git.js +64 -4
  137. package/dist/worktree/wip-refs.d.ts +23 -0
  138. package/dist/worktree/wip-refs.js +52 -2
  139. package/dist/worktree/wip-restore.d.ts +13 -0
  140. package/dist/worktree/wip-restore.js +159 -25
  141. package/dist/worktree/wip-snapshot.d.ts +5 -2
  142. package/dist/worktree/wip-snapshot.js +15 -13
  143. package/dist/worktree/worktree-origin-sync.d.ts +1 -0
  144. package/dist/worktree/worktree-origin-sync.js +1 -0
  145. package/dist/worktree/worktree-wip-events.d.ts +2 -0
  146. package/dist/worktree/worktree-wip-events.js +53 -3
  147. package/dist/worktree/worktree-wip.d.ts +7 -0
  148. package/dist/worktree/worktree-wip.js +17 -2
  149. package/dist/worktree/worktree.service.d.ts +23 -1
  150. package/dist/worktree/worktree.service.js +122 -15
  151. package/dist/worktree/worktree.types.d.ts +16 -0
  152. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ import { type HostCapacitySpec, type HostTestSlotsSource } from "./host-load-capacity.js";
1
2
  export type HostLoadGovernorMode = "on" | "off";
2
3
  export interface HostLoadGovernorConfig {
3
4
  /** FORGE_HOST_LOAD_GOVERNOR: the CPU and memory budget. Off by default; `off` is the operator override. */
@@ -5,9 +6,21 @@ export interface HostLoadGovernorConfig {
5
6
  /**
6
7
  * FORGE_HOST_LOAD_TEST_SLOTS (decision 0018): how many heavy steps (builds, test runs,
7
8
  * Playwright, the runtime build) run at once on the host, whatever the budget says.
8
- * 1 by default; 0 turns the slot off, and with the budget off too the governor is off.
9
+ * Unset, it is sized from the host's CPUs and memory (1 to 4); an explicit value is the
10
+ * operator's override. 0 turns the slot off, and with the budget off too the governor is off.
9
11
  */
10
12
  readonly testSlots: number;
13
+ /** Where testSlots came from, and how it was chosen (for logs and wait messages). Absent: a fixed count. */
14
+ readonly testSlotsSource?: HostTestSlotsSource;
15
+ readonly testSlotsDetail?: string;
16
+ /** The host the slots were sized for; live adjustment reads it too. */
17
+ readonly hostCapacity?: HostCapacitySpec | null;
18
+ /**
19
+ * Lower the slot count while other work on the host needs the machine, and raise it again
20
+ * slowly (host-load-capacity.ts). loadHostLoadGovernorConfig turns it on unless
21
+ * FORGE_HOST_LOAD_LIVE_SLOTS=off; absent means off.
22
+ */
23
+ readonly liveTestSlots?: boolean;
11
24
  /** Share of logical CPUs Forge may reserve for heavy steps. */
12
25
  readonly cpuBudgetFraction: number;
13
26
  /** Memory kept free for the rest of the host, taken off MemAvailable. */
@@ -18,8 +31,17 @@ export interface HostLoadGovernorConfig {
18
31
  readonly backpressureSamples: number;
19
32
  /** Host memory PSI `full avg10` (percent) above which admission is a hard stop. */
20
33
  readonly memoryFullThreshold: number;
21
- /** Maximum queue wait before a retryable host_capacity_timeout. */
34
+ /**
35
+ * FORGE_HOST_LOAD_MAX_WAIT_MS: the longest a step waits while its queue is stalled before a retryable
36
+ * host_capacity_timeout. Time spent behind holders of the host test slot that are all healthy (owner
37
+ * alive, lease renewed, not retained) does not count: their steps are making progress.
38
+ */
22
39
  readonly maxWaitMs: number;
40
+ /**
41
+ * FORGE_HOST_LOAD_MAX_TOTAL_WAIT_MS: the longest a step may queue in all, healthy holders or not; the
42
+ * backstop for a holder that is alive but never finishes. Never below maxWaitMs.
43
+ */
44
+ readonly maxTotalWaitMs: number;
23
45
  /** Steps allowed at once when PSI is unavailable (the per-host semaphore fallback). */
24
46
  readonly fallbackSlots: number;
25
47
  /** After this long at the head of the queue, later waiters may no longer overtake it. */
@@ -44,9 +66,17 @@ export interface HostLoadGovernorConfig {
44
66
  readonly cpuBudgetCeilingFraction?: number | null;
45
67
  readonly maxHeavyStepsCeiling?: number | null;
46
68
  }
69
+ /**
70
+ * The fixed count in defaultHostLoadGovernorConfig, which is not sized for any host: a running
71
+ * governor's config comes from loadHostLoadGovernorConfig, which sizes the slots from the host.
72
+ */
47
73
  export declare const defaultHostTestSlots = 1;
48
74
  export declare const defaultHostLoadGovernorConfig: HostLoadGovernorConfig;
49
75
  export declare function parseHostLoadGovernorMode(value: string | undefined): HostLoadGovernorMode;
50
76
  /** The governor admits steps when either rule is on: the host test slot or the budget. */
51
77
  export declare function hostLoadGovernorEnabled(config: Pick<HostLoadGovernorConfig, "mode" | "testSlots">): boolean;
52
- export declare function loadHostLoadGovernorConfig(environment?: Readonly<Record<string, string | undefined>>): HostLoadGovernorConfig;
78
+ /**
79
+ * @param host the host the test slots are sized for, detected from this machine by default.
80
+ * Null means it could not be read: an unset FORGE_HOST_LOAD_TEST_SLOTS then means 1.
81
+ */
82
+ export declare function loadHostLoadGovernorConfig(environment?: Readonly<Record<string, string | undefined>>, host?: HostCapacitySpec | null): HostLoadGovernorConfig;
@@ -1,4 +1,9 @@
1
+ import { detectHostCapacitySpec, resolveHostTestSlots, } from "./host-load-capacity.js";
1
2
  import { defaultHostLoadSampleIntervalMs } from "./host-load-sampler.js";
3
+ /**
4
+ * The fixed count in defaultHostLoadGovernorConfig, which is not sized for any host: a running
5
+ * governor's config comes from loadHostLoadGovernorConfig, which sizes the slots from the host.
6
+ */
2
7
  export const defaultHostTestSlots = 1;
3
8
  export const defaultHostLoadGovernorConfig = {
4
9
  mode: "off",
@@ -9,6 +14,7 @@ export const defaultHostLoadGovernorConfig = {
9
14
  backpressureSamples: 2,
10
15
  memoryFullThreshold: 5,
11
16
  maxWaitMs: 30 * 60_000,
17
+ maxTotalWaitMs: 4 * 60 * 60_000,
12
18
  fallbackSlots: 1,
13
19
  antiStarvationMs: 2 * 60_000,
14
20
  leaseMs: 2 * 60_000,
@@ -25,17 +31,28 @@ export function parseHostLoadGovernorMode(value) {
25
31
  export function hostLoadGovernorEnabled(config) {
26
32
  return config.mode === "on" || config.testSlots > 0;
27
33
  }
28
- export function loadHostLoadGovernorConfig(environment = process.env) {
34
+ /**
35
+ * @param host the host the test slots are sized for, detected from this machine by default.
36
+ * Null means it could not be read: an unset FORGE_HOST_LOAD_TEST_SLOTS then means 1.
37
+ */
38
+ export function loadHostLoadGovernorConfig(environment = process.env, host = detectHostCapacitySpec()) {
29
39
  const defaults = defaultHostLoadGovernorConfig;
40
+ const maxWaitMs = bounded(environment.FORGE_HOST_LOAD_MAX_WAIT_MS, defaults.maxWaitMs, 1_000, 24 * 60 * 60_000);
41
+ const testSlots = resolveHostTestSlots(environment.FORGE_HOST_LOAD_TEST_SLOTS, host);
30
42
  return {
31
43
  mode: parseHostLoadGovernorMode(environment.FORGE_HOST_LOAD_GOVERNOR),
32
- testSlots: Math.round(bounded(environment.FORGE_HOST_LOAD_TEST_SLOTS, defaults.testSlots, 0, 8)),
44
+ testSlots: testSlots.slots,
45
+ testSlotsSource: testSlots.source,
46
+ testSlotsDetail: testSlots.detail,
47
+ hostCapacity: host,
48
+ liveTestSlots: !isOff(environment.FORGE_HOST_LOAD_LIVE_SLOTS),
33
49
  cpuBudgetFraction: bounded(environment.FORGE_HOST_LOAD_CPU_BUDGET_FRACTION, defaults.cpuBudgetFraction, 0.05, 1),
34
50
  memoryReserveBytes: bounded(environment.FORGE_HOST_LOAD_MEMORY_RESERVE_BYTES, defaults.memoryReserveBytes, 0, 1024 ** 4),
35
51
  cpuPressureThreshold: bounded(environment.FORGE_HOST_LOAD_CPU_PRESSURE_THRESHOLD, defaults.cpuPressureThreshold, 1, 100),
36
52
  backpressureSamples: Math.round(bounded(environment.FORGE_HOST_LOAD_BACKPRESSURE_SAMPLES, defaults.backpressureSamples, 1, 60)),
37
53
  memoryFullThreshold: bounded(environment.FORGE_HOST_LOAD_MEMORY_FULL_THRESHOLD, defaults.memoryFullThreshold, 0, 100),
38
- maxWaitMs: bounded(environment.FORGE_HOST_LOAD_MAX_WAIT_MS, defaults.maxWaitMs, 1_000, 24 * 60 * 60_000),
54
+ maxWaitMs,
55
+ maxTotalWaitMs: Math.max(maxWaitMs, bounded(environment.FORGE_HOST_LOAD_MAX_TOTAL_WAIT_MS, defaults.maxTotalWaitMs, 1_000, 24 * 60 * 60_000)),
39
56
  fallbackSlots: Math.round(bounded(environment.FORGE_HOST_LOAD_FALLBACK_SLOTS, defaults.fallbackSlots, 1, 64)),
40
57
  antiStarvationMs: defaults.antiStarvationMs,
41
58
  leaseMs: defaults.leaseMs,
@@ -75,6 +92,10 @@ function optionalHeavySteps(raw) {
75
92
  const value = Number.parseInt(raw, 10);
76
93
  return Number.isFinite(value) ? Math.min(64, Math.max(1, value)) : null;
77
94
  }
95
+ function isOff(raw) {
96
+ const normalized = raw?.trim().toLowerCase() ?? "";
97
+ return normalized === "off" || normalized === "false" || normalized === "0";
98
+ }
78
99
  function bounded(raw, fallback, minimum, maximum) {
79
100
  if (raw === undefined || raw.trim() === "")
80
101
  return fallback;
@@ -3,6 +3,7 @@ import { type HostLoadAdmissionDecision } from "./host-load-admission.js";
3
3
  import { type HostLoadGovernorConfig } from "./host-load-governor-config.js";
4
4
  import type { HostLoadGovernorSource } from "./host-load-sampler.js";
5
5
  import type { HostLoadStepCost } from "./host-load-step-class.js";
6
+ import { type HostTestSlotControllerOptions } from "./host-load-capacity.js";
6
7
  import { type HostLoadStepProcess, type HostLoadStepTerminator } from "./host-load-step-reaper.js";
7
8
  /** What HostLoadStepGate.attachProcess takes, so a gate's callers need only this module. */
8
9
  export type { HostLoadStepProcess } from "./host-load-step-reaper.js";
@@ -17,7 +18,10 @@ export interface HostLoadStepRequest {
17
18
  }
18
19
  export interface HostLoadAcquireOptions {
19
20
  readonly signal?: AbortSignal;
20
- /** Called once, when the first admission decision says the step must wait. */
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
+ */
21
25
  readonly onWaiting?: (decision: HostLoadAdmissionDecision) => void | Promise<void>;
22
26
  }
23
27
  export interface HostLoadAdmission {
@@ -51,7 +55,7 @@ export interface HostLoadAdmission {
51
55
  /** The gate heavy steps call before launching. */
52
56
  export interface HostLoadStepGate {
53
57
  readonly enabled: boolean;
54
- /** The longest a step may queue before host_capacity_timeout, when the gate knows it. */
58
+ /** The longest a step may queue in all before host_capacity_timeout, when the gate knows it. */
55
59
  readonly maxWaitMs?: number;
56
60
  acquire(request: HostLoadStepRequest, options?: HostLoadAcquireOptions): Promise<HostLoadAdmission>;
57
61
  }
@@ -62,6 +66,24 @@ export declare class HostCapacityTimeoutError extends ForgeFailureError {
62
66
  readonly code = "host_capacity_timeout";
63
67
  constructor(stepClass: string, label: string, waitMs: number, detail: string);
64
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;
65
87
  export interface HostLoadGovernorOptions {
66
88
  readonly stateRoot: string;
67
89
  readonly load: HostLoadGovernorSource;
@@ -74,6 +96,8 @@ export interface HostLoadGovernorOptions {
74
96
  readonly terminateStep?: HostLoadStepTerminator;
75
97
  /** Test seam for the host suspend counter. */
76
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">;
77
101
  }
78
102
  /**
79
103
  * Host-wide admission for heavy steps (decision 0013). Waiters queue
@@ -99,6 +123,13 @@ export declare class HostLoadGovernor implements HostLoadStepGate {
99
123
  private idleOwnMemoryBytes;
100
124
  /** The bridge's pushed settings (decision 0014), shared with every governor on this state root. */
101
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;
102
133
  constructor(options: HostLoadGovernorOptions);
103
134
  get maxWaitMs(): number;
104
135
  acquire(request: HostLoadStepRequest, options?: HostLoadAcquireOptions): Promise<HostLoadAdmission>;
@@ -125,6 +156,16 @@ export declare class HostLoadGovernor implements HostLoadStepGate {
125
156
  readonly waiting: number;
126
157
  readonly held: readonly HostLoadToken[];
127
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>;
128
169
  private drain;
129
170
  private drainOnce;
130
171
  /**
@@ -133,6 +174,31 @@ export declare class HostLoadGovernor implements HostLoadStepGate {
133
174
  * The operator's env ceilings hold with or without the file, and over whatever it says.
134
175
  */
135
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;
136
202
  /** The host test slot first (decision 0018), then the budget when it is on. */
137
203
  private decide;
138
204
  private readSignals;
@@ -150,6 +216,19 @@ export declare class HostLoadGovernor implements HostLoadStepGate {
150
216
  */
151
217
  private runningStepsMemoryBytes;
152
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;
153
232
  private settle;
154
233
  /** Renewed tokens reset their lease clock; fenced ones stop their steps (they keep their cost until released). */
155
234
  private applyHeldOutcome;
@@ -184,3 +263,11 @@ export declare class HostLoadGovernor implements HostLoadStepGate {
184
263
  private checkRetained;
185
264
  private renewHeld;
186
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>;