@loucompanion/forge-bridge 0.1.4-dev.bbb61d3d6127 → 0.1.4-dev.bd2cfb6b7438

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 (169) hide show
  1. package/README.md +55 -0
  2. package/dist/bridge/bridge-chat-provider-command.d.ts +16 -0
  3. package/dist/bridge/bridge-chat-provider-command.js +137 -0
  4. package/dist/bridge/bridge-chat.types.d.ts +10 -0
  5. package/dist/bridge/bridge-chat.types.js +16 -1
  6. package/dist/bridge/bridge.base.d.ts +9 -0
  7. package/dist/bridge/bridge.service.d.ts +71 -2
  8. package/dist/bridge/bridge.service.js +292 -118
  9. package/dist/bridge/bridge.types.d.ts +11 -0
  10. package/dist/bridge/local-yield-flag.d.ts +6 -0
  11. package/dist/bridge/local-yield-flag.js +34 -0
  12. package/dist/bridge/runner-host-capabilities.d.ts +3 -0
  13. package/dist/bridge/runner-host-capabilities.js +13 -0
  14. package/dist/cleanup/cleanup.service.d.ts +9 -0
  15. package/dist/cleanup/cleanup.service.js +72 -109
  16. package/dist/cleanup/cleanup.types.d.ts +4 -0
  17. package/dist/cleanup/forge-owned-paths.d.ts +9 -0
  18. package/dist/cleanup/forge-owned-paths.js +53 -0
  19. package/dist/cleanup/host-runtime-ledger.d.ts +5 -0
  20. package/dist/cleanup/host-runtime-ledger.js +109 -0
  21. package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
  22. package/dist/cleanup/managed-branch-sweep.js +111 -0
  23. package/dist/cli/cli.help.js +18 -0
  24. package/dist/cli/cli.service.d.ts +16 -0
  25. package/dist/cli/cli.service.js +140 -16
  26. package/dist/cli/local-config.d.ts +4 -0
  27. package/dist/cli/local-config.js +26 -4
  28. package/dist/runtime/aspnet-runtime-prebuild.js +94 -6
  29. package/dist/runtime/attempt-database-broker.d.ts +1 -1
  30. package/dist/runtime/docker-engine-probe.d.ts +5 -0
  31. package/dist/runtime/docker-engine-probe.js +7 -0
  32. package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
  33. package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
  34. package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
  35. package/dist/runtime/ephemeral-test-postgres.js +303 -0
  36. package/dist/runtime/host-facts.d.ts +2 -1
  37. package/dist/runtime/host-load-admission.d.ts +18 -3
  38. package/dist/runtime/host-load-admission.js +19 -4
  39. package/dist/runtime/host-load-child-environment.d.ts +27 -0
  40. package/dist/runtime/host-load-child-environment.js +76 -0
  41. package/dist/runtime/host-load-forge-cgroups.d.ts +41 -0
  42. package/dist/runtime/host-load-forge-cgroups.js +93 -4
  43. package/dist/runtime/host-load-governor-config.d.ts +19 -1
  44. package/dist/runtime/host-load-governor-config.js +37 -0
  45. package/dist/runtime/host-load-governor.d.ts +72 -11
  46. package/dist/runtime/host-load-governor.js +284 -67
  47. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  48. package/dist/runtime/host-load-runtime-settings.js +78 -0
  49. package/dist/runtime/host-load-sampler.d.ts +39 -4
  50. package/dist/runtime/host-load-sampler.js +83 -9
  51. package/dist/runtime/host-load-step-class.d.ts +37 -0
  52. package/dist/runtime/host-load-step-class.js +117 -2
  53. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  54. package/dist/runtime/host-load-step-reaper.js +95 -0
  55. package/dist/runtime/host-load-step-run.d.ts +73 -0
  56. package/dist/runtime/host-load-step-run.js +102 -0
  57. package/dist/runtime/host-load-test-slot.d.ts +43 -0
  58. package/dist/runtime/host-load-test-slot.js +81 -0
  59. package/dist/runtime/host-load-token-ledger.d.ts +82 -17
  60. package/dist/runtime/host-load-token-ledger.js +187 -79
  61. package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
  62. package/dist/runtime/host-load-windows-cpu.js +85 -0
  63. package/dist/runtime/host-runtime-lease.d.ts +62 -3
  64. package/dist/runtime/host-runtime-lease.js +258 -13
  65. package/dist/runtime/host-runtime-promotion.d.ts +23 -0
  66. package/dist/runtime/host-runtime-promotion.js +36 -0
  67. package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
  68. package/dist/runtime/native-test-postgres-fallback.js +60 -8
  69. package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
  70. package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
  71. package/dist/runtime/runner-settings.d.ts +100 -0
  72. package/dist/runtime/runner-settings.js +214 -0
  73. package/dist/sandbox/host-capacity-broker.d.ts +113 -0
  74. package/dist/sandbox/host-capacity-broker.js +334 -0
  75. package/dist/sandbox/runtime.d.ts +10 -1
  76. package/dist/sandbox/runtime.js +45 -2
  77. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  78. package/dist/sandbox/sandbox-cgroups.js +42 -0
  79. package/dist/session/architect-waits.d.ts +2 -0
  80. package/dist/session/architect-waits.js +138 -0
  81. package/dist/session/managed-attempt-tools.d.ts +2 -7
  82. package/dist/session/managed-attempt-tools.js +200 -92
  83. package/dist/session/managed-command-host-load.d.ts +47 -0
  84. package/dist/session/managed-command-host-load.js +83 -0
  85. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  86. package/dist/session/mcp-argument-coercion.js +121 -0
  87. package/dist/session/phase-completion.artifacts.d.ts +7 -0
  88. package/dist/session/phase-completion.artifacts.js +96 -26
  89. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  90. package/dist/session/phase-completion.command-validation.js +77 -0
  91. package/dist/session/phase-completion.d.ts +4 -0
  92. package/dist/session/phase-completion.helpers.js +13 -12
  93. package/dist/session/phase-completion.js +4 -0
  94. package/dist/session/phase-completion.prompts.js +6 -1
  95. package/dist/session/phase-completion.runtime.d.ts +5 -3
  96. package/dist/session/phase-completion.runtime.js +50 -20
  97. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  98. package/dist/session/phase-completion.schema-parts.js +188 -0
  99. package/dist/session/phase-completion.schemas.d.ts +3 -3
  100. package/dist/session/phase-completion.schemas.js +208 -231
  101. package/dist/session/phase-completion.validation.d.ts +2 -3
  102. package/dist/session/phase-completion.validation.js +49 -93
  103. package/dist/session/pre-publication-host-load.js +31 -16
  104. package/dist/session/pre-publication-native-postgres.d.ts +30 -0
  105. package/dist/session/pre-publication-native-postgres.js +111 -0
  106. package/dist/session/pre-publication-pass.d.ts +61 -0
  107. package/dist/session/pre-publication-pass.js +148 -0
  108. package/dist/session/pre-publication-process.d.ts +3 -0
  109. package/dist/session/pre-publication-process.js +23 -11
  110. package/dist/session/pre-publication-step-execution.d.ts +2 -1
  111. package/dist/session/pre-publication-step-execution.js +6 -5
  112. package/dist/session/pre-publication-validation.d.ts +30 -14
  113. package/dist/session/pre-publication-validation.js +211 -134
  114. package/dist/session/provider-cli/claude-background-work.d.ts +66 -0
  115. package/dist/session/provider-cli/claude-background-work.js +180 -0
  116. package/dist/session/provider-cli/pre-publication-repair.d.ts +40 -0
  117. package/dist/session/provider-cli/pre-publication-repair.js +243 -0
  118. package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
  119. package/dist/session/provider-cli/provider-cli.child-environment.js +73 -0
  120. package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
  121. package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
  122. package/dist/session/provider-cli/provider-cli.process.d.ts +13 -22
  123. package/dist/session/provider-cli/provider-cli.process.js +38 -339
  124. package/dist/session/provider-cli/provider-cli.prompts.d.ts +2 -0
  125. package/dist/session/provider-cli/provider-cli.prompts.js +50 -10
  126. package/dist/session/provider-cli/provider-cli.runtime.js +7 -0
  127. package/dist/session/provider-cli/provider-cli.service.d.ts +4 -1
  128. package/dist/session/provider-cli/provider-cli.service.js +93 -162
  129. package/dist/session/provider-cli/provider-cli.types.d.ts +30 -0
  130. package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
  131. package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
  132. package/dist/session/provider-cli/provider-in-flight-work.d.ts +4 -0
  133. package/dist/session/provider-cli/provider-in-flight-work.js +45 -0
  134. package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
  135. package/dist/session/provider-cli/provider-output-pipes.js +67 -0
  136. package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
  137. package/dist/session/provider-cli/provider-output-state.js +6 -0
  138. package/dist/session/qa-sidecar-validation.d.ts +6 -0
  139. package/dist/session/qa-sidecar-validation.js +28 -0
  140. package/dist/session/sandbox-host-capacity-gate.d.ts +30 -0
  141. package/dist/session/sandbox-host-capacity-gate.js +238 -0
  142. package/dist/session/session-redaction.js +31 -181
  143. package/dist/session/session.base.d.ts +6 -1
  144. package/dist/session/session.service.d.ts +7 -2
  145. package/dist/session/session.service.js +115 -5
  146. package/dist/session/session.types.js +4 -4
  147. package/dist/session/sidecar-json-shape.d.ts +31 -0
  148. package/dist/session/sidecar-json-shape.js +217 -0
  149. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  150. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  151. package/dist/shared/process/host-process-supervisor.d.ts +1 -0
  152. package/dist/shared/process/host-process-supervisor.js +1 -1
  153. package/dist/shared/process/process-tree.d.ts +52 -0
  154. package/dist/shared/process/process-tree.js +144 -0
  155. package/dist/shared/process/process.d.ts +67 -0
  156. package/dist/shared/process/process.js +213 -11
  157. package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
  158. package/dist/shared/process/windows-app-execution-alias.js +45 -0
  159. package/dist/shared/process/windows-launch.d.ts +18 -0
  160. package/dist/shared/process/windows-launch.js +68 -0
  161. package/dist/shared/provider-capabilities.js +5 -6
  162. package/dist/version.d.ts +1 -1
  163. package/dist/version.js +1 -1
  164. package/dist/worktree/dependency-warmer.d.ts +25 -0
  165. package/dist/worktree/dependency-warmer.js +46 -10
  166. package/dist/worktree/worktree.service.d.ts +10 -1
  167. package/dist/worktree/worktree.service.js +42 -2
  168. package/dist/worktree/worktree.types.d.ts +7 -0
  169. package/package.json +2 -2
@@ -1,5 +1,6 @@
1
1
  import { type HostEnvironment, type HostFacts } from "./host-facts.js";
2
2
  import { type PressureStallResource } from "./host-pressure-stall.js";
3
+ import { type ForgeCgroupSource } from "./host-load-forge-cgroups.js";
3
4
  export interface HostSystemPressure {
4
5
  readonly cpu: PressureStallResource | null;
5
6
  readonly memory: PressureStallResource | null;
@@ -17,16 +18,34 @@ export interface HostOwnCgroupLoad {
17
18
  /** All memory charged to the unit (`memory.current`), including page cache. */
18
19
  readonly memoryChargedBytes: number | null;
19
20
  }
21
+ /**
22
+ * Where `systemPressure` comes from: Linux PSI, or (decision 0021) an estimate
23
+ * of CPU `some` pressure from whole-host CPU use on Windows, which has no PSI.
24
+ */
25
+ export type HostLoadPressureSource = "psi" | "windows_estimate";
20
26
  /** Live host load. Reported in every heartbeat but never a material capability signal. */
21
27
  export interface HostLoadSnapshot {
22
28
  readonly sampledAt: string;
29
+ /**
30
+ * True when `systemPressure` carries a CPU pressure signal the governor gates on.
31
+ * The wire name predates decision 0021: on Windows the signal is an estimate
32
+ * (see `pressureSource`), and the static host fact `psiAvailable` stays false.
33
+ */
23
34
  readonly psiAvailable: boolean;
35
+ /** Null exactly when `psiAvailable` is false. */
36
+ readonly pressureSource: HostLoadPressureSource | null;
24
37
  readonly systemPressure: HostSystemPressure | null;
25
38
  /** True only when the bridge runs in a cgroup of its own (see isDedicatedBridgeUnit). */
26
39
  readonly ownCgroupDedicated: boolean;
27
40
  /** Reported only for a dedicated unit; never a shared terminal/session/app scope. */
28
41
  readonly ownCgroup: HostOwnCgroupLoad | null;
29
42
  readonly memoryAvailableBytes: number | null;
43
+ /**
44
+ * Busy share (0-100) of all logical CPUs over the last sampling window: /proc/stat deltas
45
+ * on Linux, os.cpus() deltas on Windows. Null on the first sample, after a break in
46
+ * readings, and on other platforms. For display only; the governor gates on pressure.
47
+ */
48
+ readonly hostCpuPercent: number | null;
30
49
  }
31
50
  /** What the bridge service needs: static facts plus the latest cached load sample. */
32
51
  export interface HostLoadSource {
@@ -47,7 +66,7 @@ export interface HostLoadSource {
47
66
  */
48
67
  export interface HostCpuAttribution {
49
68
  readonly sampledAt: string;
50
- /** Busy cores on the whole host, from /proc/stat deltas. */
69
+ /** Busy cores on the whole host, from /proc/stat deltas (os.cpus() deltas on Windows). */
51
70
  readonly hostCoresInUse: number;
52
71
  /** Cores used by the bridge's dedicated cgroup; null when the cgroup is not dedicated. */
53
72
  readonly ownCoresInUse: number | null;
@@ -73,12 +92,15 @@ export interface HostLoadSamplerOptions {
73
92
  readonly monotonicNow?: () => number;
74
93
  /** Systemd unit the operator dedicates to the bridge (FORGE_BRIDGE_CGROUP_UNIT). */
75
94
  readonly cgroupUnit?: string | null;
95
+ /** Docker sandbox cgroups whose CPU time is Forge's own, not external load. */
96
+ readonly forgeCgroups?: ForgeCgroupSource;
76
97
  }
77
98
  export declare const defaultHostLoadSampleIntervalMs = 5000;
78
99
  /**
79
100
  * Samples Linux PSI and the bridge's own cgroup on an interval and caches the
80
- * latest snapshot. Every read is async and failure-tolerant: a host without PSI
81
- * (non-Linux, old kernel, `psi=0`) reports `psiAvailable: false` and no pressure.
101
+ * latest snapshot. Every read is async and failure-tolerant: a Linux host without
102
+ * PSI (old kernel, `psi=0`) or another non-Windows host reports `psiAvailable: false`
103
+ * and no pressure. Windows reports a CPU pressure estimate instead (decision 0021).
82
104
  */
83
105
  export declare class HostLoadSampler implements HostLoadSource {
84
106
  private readonly environment;
@@ -97,6 +119,10 @@ export declare class HostLoadSampler implements HostLoadSource {
97
119
  private hostCpuMark;
98
120
  private latestCpuAttribution;
99
121
  private latestMemoryHeadroom;
122
+ private windowsCpuMark;
123
+ private readonly windowsCpuPressure;
124
+ private readonly forgeCgroups;
125
+ private readonly sandboxCpu;
100
126
  constructor(options?: HostLoadSamplerOptions);
101
127
  facts(): HostFacts | null;
102
128
  current(): HostLoadSnapshot | null;
@@ -110,11 +136,20 @@ export declare class HostLoadSampler implements HostLoadSource {
110
136
  sample(): Promise<HostLoadSnapshot>;
111
137
  private startOnce;
112
138
  private readSnapshot;
139
+ /**
140
+ * Decision 0021: Windows has no PSI or cgroups. CPU pressure is estimated from
141
+ * whole-host CPU use between samples, and memory is available physical memory.
142
+ * The bridge's own share is not attributed, so external load stays unknown and
143
+ * Forge's work counts through reserved cost and the pressure gate (as on a Linux
144
+ * host whose bridge has no dedicated cgroup).
145
+ */
146
+ private readWindowsSnapshot;
113
147
  private readCgroupMemoryHeadroom;
114
148
  private readSystemPressure;
115
149
  private readOwnCgroup;
116
150
  private coresInUse;
117
- private readHostCoresInUse;
151
+ /** Busy share (0-1) of all logical CPUs since the last /proc/stat reading. */
152
+ private readHostCpuUse;
118
153
  private readMemoryAvailable;
119
154
  private fallbackFreeMemory;
120
155
  private readPressure;
@@ -1,14 +1,16 @@
1
1
  import path from "node:path";
2
2
  import { defaultHostEnvironment, detectHostFacts, readOptional, } from "./host-facts.js";
3
3
  import { cgroupLeafName, isDedicatedBridgeUnit, parseCgroupCpuUsageUsec, parseCgroupMemoryAnonBytes, parseMemAvailableBytes, parseNonNegativeInteger, parsePressureStall, parseProcStatCpuTotals, parseUnifiedCgroupMembership, parseUnifiedCgroupPath, } from "./host-pressure-stall.js";
4
- import { readCgroupMemoryHeadroomBytes } from "./host-load-forge-cgroups.js";
4
+ import { ForgeCgroupCpuMeter, readCgroupMemoryHeadroomBytes, } from "./host-load-forge-cgroups.js";
5
+ import { cpuTimeTotals, cpuUtilisation, WindowsCpuPressureEstimator, } from "./host-load-windows-cpu.js";
5
6
  export const defaultHostLoadSampleIntervalMs = 5_000;
6
7
  /** Samples kept for the governor's pressure streak (FORGE_HOST_LOAD_BACKPRESSURE_SAMPLES is at most 60). */
7
8
  const retainedSampleCount = 64;
8
9
  /**
9
10
  * Samples Linux PSI and the bridge's own cgroup on an interval and caches the
10
- * latest snapshot. Every read is async and failure-tolerant: a host without PSI
11
- * (non-Linux, old kernel, `psi=0`) reports `psiAvailable: false` and no pressure.
11
+ * latest snapshot. Every read is async and failure-tolerant: a Linux host without
12
+ * PSI (old kernel, `psi=0`) or another non-Windows host reports `psiAvailable: false`
13
+ * and no pressure. Windows reports a CPU pressure estimate instead (decision 0021).
12
14
  */
13
15
  export class HostLoadSampler {
14
16
  environment;
@@ -27,6 +29,10 @@ export class HostLoadSampler {
27
29
  hostCpuMark = null;
28
30
  latestCpuAttribution = null;
29
31
  latestMemoryHeadroom = null;
32
+ windowsCpuMark = null;
33
+ windowsCpuPressure = new WindowsCpuPressureEstimator();
34
+ forgeCgroups;
35
+ sandboxCpu;
30
36
  constructor(options = {}) {
31
37
  this.environment = options.environment ?? defaultHostEnvironment();
32
38
  this.intervalMs = options.intervalMs !== undefined && Number.isFinite(options.intervalMs) && options.intervalMs > 0
@@ -37,6 +43,8 @@ export class HostLoadSampler {
37
43
  this.cgroupUnit = options.cgroupUnit !== undefined
38
44
  ? options.cgroupUnit
39
45
  : process.env.FORGE_BRIDGE_CGROUP_UNIT?.trim() || null;
46
+ this.forgeCgroups = options.forgeCgroups ?? null;
47
+ this.sandboxCpu = new ForgeCgroupCpuMeter(this.environment);
40
48
  }
41
49
  facts() {
42
50
  return this.hostFacts;
@@ -73,6 +81,9 @@ export class HostLoadSampler {
73
81
  sample() {
74
82
  this.inFlight ??= this.readSnapshot()
75
83
  .then(snapshot => {
84
+ // A Windows reading that did not advance the CPU window returns the last snapshot.
85
+ if (snapshot === this.latest)
86
+ return snapshot;
76
87
  this.latest = snapshot;
77
88
  this.history.push(snapshot);
78
89
  if (this.history.length > retainedSampleCount)
@@ -100,28 +111,72 @@ export class HostLoadSampler {
100
111
  async readSnapshot() {
101
112
  const sampledAtMs = this.now();
102
113
  const monotonicMs = this.monotonicNow();
114
+ if (this.environment.platform === "win32")
115
+ return this.readWindowsSnapshot(sampledAtMs, monotonicMs);
103
116
  const linux = this.environment.platform === "linux";
104
- const [systemPressure, ownCgroup, memoryAvailableBytes, hostCoresInUse, cgroupMemoryHeadroomBytes] = linux
117
+ const [systemPressure, ownCgroup, memoryAvailableBytes, hostCpu, cgroupMemoryHeadroomBytes, sandboxCores] = linux
105
118
  ? await Promise.all([
106
119
  this.readSystemPressure(),
107
120
  this.readOwnCgroup(monotonicMs),
108
121
  this.readMemoryAvailable(),
109
- this.readHostCoresInUse(),
122
+ this.readHostCpuUse(),
110
123
  this.readCgroupMemoryHeadroom(),
124
+ Promise.resolve(this.forgeCgroups?.paths() ?? [])
125
+ .then(paths => this.sandboxCpu.coresInUse(paths, monotonicMs)).catch(() => 0),
111
126
  ])
112
- : [null, null, this.fallbackFreeMemory(), null, null];
127
+ : [null, null, this.fallbackFreeMemory(), null, null, 0];
113
128
  const sampledAt = new Date(sampledAtMs).toISOString();
129
+ // Docker sandbox CPU is Forge's own work, already counted through reserved cost.
130
+ const ownCores = ownCgroup?.cpuCoresInUse ?? null;
114
131
  this.latestMemoryHeadroom = cgroupMemoryHeadroomBytes;
115
- this.latestCpuAttribution = hostCpuAttribution(sampledAt, hostCoresInUse, ownCgroup?.cpuCoresInUse ?? null);
132
+ this.latestCpuAttribution = hostCpuAttribution(sampledAt, hostCpu === null ? null : roundCores(hostCpu.utilisation * hostCpu.cpuCount), ownCores === null ? null : ownCores + sandboxCores);
116
133
  return {
117
134
  sampledAt,
118
135
  psiAvailable: systemPressure !== null,
136
+ pressureSource: systemPressure !== null ? "psi" : null,
119
137
  systemPressure,
120
138
  ownCgroupDedicated: ownCgroup !== null,
121
139
  ownCgroup,
122
140
  memoryAvailableBytes,
141
+ hostCpuPercent: hostCpu === null ? null : hostCpuPercent(hostCpu.utilisation),
123
142
  };
124
143
  }
144
+ /**
145
+ * Decision 0021: Windows has no PSI or cgroups. CPU pressure is estimated from
146
+ * whole-host CPU use between samples, and memory is available physical memory.
147
+ * The bridge's own share is not attributed, so external load stays unknown and
148
+ * Forge's work counts through reserved cost and the pressure gate (as on a Linux
149
+ * host whose bridge has no dedicated cgroup).
150
+ */
151
+ readWindowsSnapshot(sampledAtMs, monotonicMs) {
152
+ let totals;
153
+ try {
154
+ totals = cpuTimeTotals(this.environment.cpus());
155
+ }
156
+ catch {
157
+ totals = null;
158
+ }
159
+ const previous = this.windowsCpuMark;
160
+ const sampledAt = new Date(sampledAtMs).toISOString();
161
+ if (this.latest && totals && previous && previous.totals.cpuCount === totals.cpuCount
162
+ && monotonicMs - previous.atMs < minimumWindowsCpuWindowMs) {
163
+ // Too soon after the last reading (start() right after a sample) for a stable delta:
164
+ // the window stays open and the last snapshot is returned as is. sample() does not
165
+ // record it again, so it never counts as another sample in the pressure streak.
166
+ return this.latest;
167
+ }
168
+ this.windowsCpuMark = totals ? { totals, atMs: monotonicMs } : null;
169
+ const elapsedMs = previous ? monotonicMs - previous.atMs : 0;
170
+ const utilisation = previous && elapsedMs > 0 ? cpuUtilisation(previous.totals, totals) : null;
171
+ // The first sample, or a break in readings (no times, a CPU count change, a counter
172
+ // reset), reports no pressure and restarts the averages from the next window.
173
+ if (utilisation === null)
174
+ this.windowsCpuPressure.reset();
175
+ const cpu = utilisation === null ? null : this.windowsCpuPressure.update(utilisation, elapsedMs);
176
+ this.latestMemoryHeadroom = null;
177
+ this.latestCpuAttribution = hostCpuAttribution(sampledAt, utilisation !== null && totals ? roundCores(utilisation * totals.cpuCount) : null, null);
178
+ return windowsSnapshot(sampledAt, cpu, this.fallbackFreeMemory(), utilisation === null ? null : hostCpuPercent(utilisation));
179
+ }
125
180
  async readCgroupMemoryHeadroom() {
126
181
  const membership = await readOptional(this.environment, path.posix.join(this.environment.procRoot, "self", "cgroup"));
127
182
  const cgroupPath = membership ? parseUnifiedCgroupMembership(membership) : null;
@@ -177,7 +232,8 @@ export class HostLoadSampler {
177
232
  return null;
178
233
  return roundCores(usedUsec / elapsedUsec);
179
234
  }
180
- async readHostCoresInUse() {
235
+ /** Busy share (0-1) of all logical CPUs since the last /proc/stat reading. */
236
+ async readHostCpuUse() {
181
237
  const content = await readOptional(this.environment, path.posix.join(this.environment.procRoot, "stat"));
182
238
  const totals = content ? parseProcStatCpuTotals(content) : null;
183
239
  const previous = this.hostCpuMark;
@@ -188,7 +244,7 @@ export class HostLoadSampler {
188
244
  const busyDelta = totals.busyTicks - previous.busyTicks;
189
245
  if (totalDelta <= 0 || busyDelta < 0)
190
246
  return null;
191
- return roundCores((busyDelta / totalDelta) * totals.cpuCount);
247
+ return { utilisation: Math.min(1, busyDelta / totalDelta), cpuCount: totals.cpuCount };
192
248
  }
193
249
  async readMemoryAvailable() {
194
250
  const meminfo = await readOptional(this.environment, path.posix.join(this.environment.procRoot, "meminfo"));
@@ -208,9 +264,27 @@ export class HostLoadSampler {
208
264
  return content ? parsePressureStall(content) : null;
209
265
  }
210
266
  }
267
+ /** Windows CPU deltas shorter than this are too noisy to fold into the pressure estimate. */
268
+ const minimumWindowsCpuWindowMs = 250;
269
+ function windowsSnapshot(sampledAt, cpu, memoryAvailableBytes, cpuPercent) {
270
+ return {
271
+ sampledAt,
272
+ psiAvailable: cpu !== null,
273
+ pressureSource: cpu !== null ? "windows_estimate" : null,
274
+ systemPressure: cpu ? { cpu, memory: null, io: null } : null,
275
+ ownCgroupDedicated: false,
276
+ ownCgroup: null,
277
+ memoryAvailableBytes,
278
+ hostCpuPercent: cpuPercent,
279
+ };
280
+ }
211
281
  function roundCores(value) {
212
282
  return Math.round(value * 100) / 100;
213
283
  }
284
+ /** A 0-1 busy share as a percentage with two decimals. */
285
+ function hostCpuPercent(utilisation) {
286
+ return Math.round(Math.min(1, Math.max(0, utilisation)) * 10_000) / 100;
287
+ }
214
288
  function hostCpuAttribution(sampledAt, hostCoresInUse, ownCoresInUse) {
215
289
  if (hostCoresInUse === null)
216
290
  return null;
@@ -25,9 +25,46 @@ export declare const defaultHostLoadStepCosts: {
25
25
  readonly cpuCores: 1;
26
26
  readonly memoryBytes: number;
27
27
  };
28
+ /** A `dotnet build` (or test with its build) started as a managed command. */
29
+ readonly managedBuild: {
30
+ readonly cpuCores: 2;
31
+ readonly memoryBytes: number;
32
+ };
33
+ readonly aspnetPrebuild: {
34
+ readonly cpuCores: 2;
35
+ readonly memoryBytes: number;
36
+ };
37
+ /** Dependency installs are mostly network and disk bound, so they cost less than a build. */
38
+ readonly dependencyInstall: {
39
+ readonly cpuCores: 0.5;
40
+ readonly memoryBytes: number;
41
+ };
28
42
  };
43
+ export declare const aspNetPrebuildStepClass: HostLoadStepClassification;
44
+ export declare const dependencyInstallStepClass: HostLoadStepClassification;
29
45
  /**
30
46
  * Maps a pre-publication validation step to its class: `dotnet.tier.<tier>`,
31
47
  * `vitest.<suite>`, `playwright.e2e`, or `generic` for everything else.
32
48
  */
33
49
  export declare function classifyValidationStep(checkId: string, command: string, args: readonly string[]): HostLoadStepClassification;
50
+ export interface ManagedCommandStepInput {
51
+ readonly command: string;
52
+ readonly args: readonly string[];
53
+ /** The runner-authored verification profile, when the command is one. */
54
+ readonly verificationProfile?: string;
55
+ /** Whether the command builds (see isBuildProducingManagedCommand). */
56
+ readonly buildProducing: boolean;
57
+ }
58
+ /**
59
+ * Maps a managed command to its class: `managed.<profile>` for verification
60
+ * profiles (a .NET tier's cost per parallel shard), `managed.playwright`,
61
+ * `managed.build` for build-producing commands, `managed.test` for a test run
62
+ * that reuses an earlier build, and `managed.command` otherwise. Only
63
+ * `managed.command` skips the host test slot (decision 0018).
64
+ */
65
+ export declare function classifyManagedCommand(input: ManagedCommandStepInput): HostLoadStepClassification;
66
+ /**
67
+ * The default cost of a step class, for a step whose cost the requester does
68
+ * not get to choose (a Docker sandbox asking the host bridge for admission).
69
+ */
70
+ export declare function hostLoadStepCostForClass(stepClass: string): HostLoadStepCost;
@@ -1,11 +1,23 @@
1
- // Step classes and conservative default costs for governed heavy steps
2
- // (decision 0013). Step 4 replaces the defaults with P75 estimates from history.
1
+ import path from "node:path";
3
2
  const gib = 1024 ** 3;
4
3
  export const defaultHostLoadStepCosts = {
5
4
  dotnetTier: { cpuCores: 2, memoryBytes: 3 * gib },
6
5
  vitest: { cpuCores: 1, memoryBytes: 1.5 * gib },
7
6
  playwright: { cpuCores: 2, memoryBytes: 2 * gib },
8
7
  generic: { cpuCores: 1, memoryBytes: 1 * gib },
8
+ /** A `dotnet build` (or test with its build) started as a managed command. */
9
+ managedBuild: { cpuCores: 2, memoryBytes: 2 * gib },
10
+ aspnetPrebuild: { cpuCores: 2, memoryBytes: 2 * gib },
11
+ /** Dependency installs are mostly network and disk bound, so they cost less than a build. */
12
+ dependencyInstall: { cpuCores: 0.5, memoryBytes: 0.75 * gib },
13
+ };
14
+ export const aspNetPrebuildStepClass = {
15
+ stepClass: "aspnet.prebuild",
16
+ cost: defaultHostLoadStepCosts.aspnetPrebuild,
17
+ };
18
+ export const dependencyInstallStepClass = {
19
+ stepClass: "deps.install",
20
+ cost: defaultHostLoadStepCosts.dependencyInstall,
9
21
  };
10
22
  const dotnetTierScripts = ["scripts/run-dotnet-test-tier.ps1", "scripts/run-dotnet-test-tier-set.ps1"];
11
23
  const affectedDotnetScript = "scripts/run-affected-dotnet-tests.mjs";
@@ -44,3 +56,106 @@ function stepClassSegment(value) {
44
56
  const segment = value.trim().toLowerCase().replace(/[^a-z0-9]+/gu, "-").replace(/^-+|-+$/gu, "");
45
57
  return segment || "unknown";
46
58
  }
59
+ /**
60
+ * Maps a managed command to its class: `managed.<profile>` for verification
61
+ * profiles (a .NET tier's cost per parallel shard), `managed.playwright`,
62
+ * `managed.build` for build-producing commands, `managed.test` for a test run
63
+ * that reuses an earlier build, and `managed.command` otherwise. Only
64
+ * `managed.command` skips the host test slot (decision 0018).
65
+ */
66
+ export function classifyManagedCommand(input) {
67
+ if (input.verificationProfile) {
68
+ const parallelism = maxParallelismArgument(input.args);
69
+ const tier = defaultHostLoadStepCosts.dotnetTier;
70
+ return {
71
+ stepClass: `managed.${stepClassSegment(input.verificationProfile)}`,
72
+ cost: {
73
+ cpuCores: tier.cpuCores * parallelism,
74
+ memoryBytes: tier.memoryBytes + (parallelism - 1) * 1.5 * gib,
75
+ },
76
+ };
77
+ }
78
+ const invocation = [input.command, ...input.args].map(argument => argument.toLowerCase().replaceAll("\\", "/"));
79
+ const programs = programsRun(invocation);
80
+ if (programs.some(program => path.posix.basename(program).includes("playwright"))) {
81
+ return { stepClass: "managed.playwright", cost: defaultHostLoadStepCosts.playwright };
82
+ }
83
+ if (input.buildProducing)
84
+ return { stepClass: "managed.build", cost: defaultHostLoadStepCosts.managedBuild };
85
+ if (isTestRun(invocation, programs))
86
+ return { stepClass: "managed.test", cost: defaultHostLoadStepCosts.dotnetTier };
87
+ return { stepClass: "managed.command", cost: defaultHostLoadStepCosts.generic };
88
+ }
89
+ const testRunScripts = [...dotnetTierScripts, affectedDotnetScript].map(script => script.toLowerCase());
90
+ const packageManagers = new Set(["npm", "pnpm", "yarn", "npx"]);
91
+ const scriptHosts = new Set(["node", "pwsh", "powershell", "bash", "sh", "tsx"]);
92
+ const programName = (argument) => path.posix.basename(argument).replace(/\.(exe|cmd)$/u, "");
93
+ // Package-manager options that take a value (`pnpm --dir tests/e2e`, `npm --prefix x`), in
94
+ // lower case like the invocation, so `-c` and `-f` are pnpm's `-C` and `-F`.
95
+ const packageManagerValueOptions = new Set(["--dir", "-c", "--prefix", "--filter", "-f", "--workspace", "--cwd", "--config"]);
96
+ /** The operands of an invocation, without options and, for a package manager, the values its options take. */
97
+ function operandsOf(command, args) {
98
+ const operands = [];
99
+ for (let index = 0; index < args.length; index += 1) {
100
+ const argument = args[index];
101
+ if (!argument.startsWith("-"))
102
+ operands.push(argument);
103
+ else if (packageManagers.has(command) && packageManagerValueOptions.has(argument))
104
+ index += 1;
105
+ }
106
+ return operands;
107
+ }
108
+ /**
109
+ * The programs an invocation runs: the executable and, for a script host or a
110
+ * package manager's exec, the script or tool it starts. Arguments after that
111
+ * (a search pattern, a file to read) never classify the command, so
112
+ * `rg vitest src` or `cat playwright.config.ts` stays a plain command.
113
+ */
114
+ function programsRun(invocation) {
115
+ const command = programName(invocation[0] ?? "");
116
+ const operands = operandsOf(command, invocation.slice(1));
117
+ if (scriptHosts.has(command))
118
+ return [command, ...operands.slice(0, 1)];
119
+ if (command === "npx")
120
+ return [command, ...operands.slice(0, 1)];
121
+ if (packageManagers.has(command) && ["exec", "dlx"].includes(operands[0] ?? ""))
122
+ return [command, ...operands.slice(1, 2)];
123
+ // `pnpm vitest`, `yarn playwright test`: these run a package's binary by name.
124
+ if (command === "pnpm" || command === "yarn")
125
+ return [command, ...operands.slice(0, 1)];
126
+ return [command];
127
+ }
128
+ /** `dotnet test`, the tier and affected scripts, Vitest, or a package manager's test script. */
129
+ function isTestRun(invocation, programs) {
130
+ const command = programs[0] ?? "";
131
+ const operands = operandsOf(command, invocation.slice(1));
132
+ if (command === "dotnet" && operands[0] === "test")
133
+ return true;
134
+ if (programs.some(program => testRunScripts.some(script => program.endsWith(script))))
135
+ return true;
136
+ if (programs.some(program => programName(program) === "vitest"))
137
+ return true;
138
+ return packageManagers.has(command) && (operands[0] === "test" || (operands[0] === "run" && operands[1] === "test"));
139
+ }
140
+ /**
141
+ * The default cost of a step class, for a step whose cost the requester does
142
+ * not get to choose (a Docker sandbox asking the host bridge for admission).
143
+ */
144
+ export function hostLoadStepCostForClass(stepClass) {
145
+ if (stepClass.startsWith("dotnet.tier."))
146
+ return defaultHostLoadStepCosts.dotnetTier;
147
+ if (stepClass.startsWith("vitest."))
148
+ return defaultHostLoadStepCosts.vitest;
149
+ if (stepClass === "playwright.e2e")
150
+ return defaultHostLoadStepCosts.playwright;
151
+ if (stepClass === aspNetPrebuildStepClass.stepClass)
152
+ return defaultHostLoadStepCosts.aspnetPrebuild;
153
+ if (stepClass === dependencyInstallStepClass.stepClass)
154
+ return defaultHostLoadStepCosts.dependencyInstall;
155
+ return defaultHostLoadStepCosts.generic;
156
+ }
157
+ function maxParallelismArgument(args) {
158
+ const index = args.findIndex(argument => argument.toLowerCase() === "-maxparallelism");
159
+ const value = index >= 0 ? Number(args[index + 1]) : 1;
160
+ return Number.isSafeInteger(value) && value >= 1 ? Math.min(value, 32) : 1;
161
+ }
@@ -0,0 +1,27 @@
1
+ import { type WindowsProcessTable } from "../shared/process/process-tree.js";
2
+ /** The process tree a governed step runs in, recorded on its token once it launches. */
3
+ export interface HostLoadStepProcess {
4
+ readonly rootPid: number;
5
+ /** OS birth marker of the root, so a reused pid is never signalled. Null where unsupported. */
6
+ readonly rootIdentity: string | null;
7
+ /** The root leads its own process group (Unix): the whole group is stopped and checked. */
8
+ readonly processGroup: boolean;
9
+ }
10
+ /** Stops a step's process tree; resolves true only when no member is left. */
11
+ export type HostLoadStepTerminator = (step: HostLoadStepProcess) => Promise<boolean>;
12
+ /**
13
+ * Stops the recorded tree with SIGTERM, then SIGKILL, and confirms it is gone.
14
+ * A root that cannot be identified (no birth marker) is never signalled and
15
+ * counts as not confirmed, so its token keeps its reserved cost.
16
+ */
17
+ export declare const terminateHostLoadStepProcess: HostLoadStepTerminator;
18
+ /**
19
+ * Windows has no process groups and does not reparent orphans. A root with a
20
+ * recorded birth marker is stopped together with every descendant created
21
+ * after it (found through parent ids, even if the root already exited), and
22
+ * the reservation is reused only once none is left. Without a birth marker the
23
+ * root cannot be told from a reused pid, so it is never signalled and only its
24
+ * absence counts.
25
+ */
26
+ export declare function windowsStepTerminator(table: WindowsProcessTable, waitMs?: number): HostLoadStepTerminator;
27
+ export declare function validHostLoadStepProcess(value: unknown): value is HostLoadStepProcess;
@@ -0,0 +1,95 @@
1
+ import { captureHostProcessIdentity } from "../shared/process/host-process-supervisor.js";
2
+ import { systemWindowsProcessTable, WindowsProcessTree } from "../shared/process/process-tree.js";
3
+ import { monotonicNowMs } from "../shared/time/monotonic.js";
4
+ const graceMs = 250;
5
+ /**
6
+ * Stops the recorded tree with SIGTERM, then SIGKILL, and confirms it is gone.
7
+ * A root that cannot be identified (no birth marker) is never signalled and
8
+ * counts as not confirmed, so its token keeps its reserved cost.
9
+ */
10
+ export const terminateHostLoadStepProcess = async (step) => process.platform === "win32"
11
+ ? await windowsStepTerminator(systemWindowsProcessTable)(step)
12
+ : await terminateUnixStep(step);
13
+ /**
14
+ * Windows has no process groups and does not reparent orphans. A root with a
15
+ * recorded birth marker is stopped together with every descendant created
16
+ * after it (found through parent ids, even if the root already exited), and
17
+ * the reservation is reused only once none is left. Without a birth marker the
18
+ * root cannot be told from a reused pid, so it is never signalled and only its
19
+ * absence counts.
20
+ */
21
+ export function windowsStepTerminator(table, waitMs = 10_000) {
22
+ return async (step) => {
23
+ const createdAt = step.rootIdentity?.startsWith("win32:") ? step.rootIdentity.slice("win32:".length) : null;
24
+ if (createdAt === null)
25
+ return !pidExists(step.rootPid);
26
+ return await new WindowsProcessTree(step.rootPid, table, { exactCreatedAt: createdAt }).stop(Date.now() + waitMs);
27
+ };
28
+ }
29
+ async function terminateUnixStep(step) {
30
+ if (!memberExists(step))
31
+ return true;
32
+ const unixGroup = step.processGroup && process.platform !== "win32";
33
+ if (!pidExists(step.rootPid)) {
34
+ // The root exited but its group lives on. A process group id is never reissued
35
+ // while the group has members, so these are the step's own orphans: stop them.
36
+ if (!unixGroup || !step.rootIdentity)
37
+ return !memberExists(step);
38
+ return await stopTree(step);
39
+ }
40
+ const identity = captureHostProcessIdentity(step.rootPid);
41
+ // The root pid now names another process, so the step's root and its group are gone.
42
+ if (step.rootIdentity && identity && identity !== step.rootIdentity)
43
+ return true;
44
+ if (!step.rootIdentity || !identity)
45
+ return !memberExists(step);
46
+ return await stopTree(step);
47
+ }
48
+ async function stopTree(step) {
49
+ for (const signal of ["SIGTERM", "SIGKILL"]) {
50
+ send(step, signal);
51
+ const deadline = monotonicNowMs() + graceMs;
52
+ while (memberExists(step) && monotonicNowMs() < deadline)
53
+ await delay(10);
54
+ if (!memberExists(step))
55
+ return true;
56
+ }
57
+ return false;
58
+ }
59
+ function memberExists(step) {
60
+ return step.processGroup && process.platform !== "win32" ? groupExists(step.rootPid) : pidExists(step.rootPid);
61
+ }
62
+ function send(step, signal) {
63
+ try {
64
+ process.kill(step.processGroup && process.platform !== "win32" ? -step.rootPid : step.rootPid, signal);
65
+ }
66
+ catch (error) {
67
+ if (error.code !== "ESRCH")
68
+ throw error;
69
+ }
70
+ }
71
+ function pidExists(pid) {
72
+ return signalZero(pid);
73
+ }
74
+ function groupExists(pid) {
75
+ return signalZero(-pid);
76
+ }
77
+ function signalZero(target) {
78
+ try {
79
+ process.kill(target, 0);
80
+ return true;
81
+ }
82
+ catch (error) {
83
+ return error.code === "EPERM";
84
+ }
85
+ }
86
+ async function delay(ms) {
87
+ await new Promise(resolve => setTimeout(resolve, ms));
88
+ }
89
+ export function validHostLoadStepProcess(value) {
90
+ const step = value;
91
+ return Boolean(step)
92
+ && Number.isSafeInteger(step.rootPid) && step.rootPid > 1
93
+ && (step.rootIdentity === null || typeof step.rootIdentity === "string")
94
+ && typeof step.processGroup === "boolean";
95
+ }
@@ -0,0 +1,73 @@
1
+ import type { HostLoadAdmissionDecision } from "./host-load-admission.js";
2
+ import type { HostLoadAdmission, HostLoadStepGate } from "./host-load-governor.js";
3
+ import type { HostLoadStepProcess } from "./host-load-step-reaper.js";
4
+ import type { HostLoadStepClassification } from "./host-load-step-class.js";
5
+ import type { HostLoadTokenPriority } from "./host-load-token-ledger.js";
6
+ export interface HostGovernedStep {
7
+ readonly classification: HostLoadStepClassification;
8
+ /** What the step is, for diagnostics. */
9
+ readonly label: string;
10
+ readonly dispatchAttemptId: string | null;
11
+ readonly priority: HostLoadTokenPriority;
12
+ readonly signal?: AbortSignal;
13
+ /** Called once, when the step first has to wait for capacity. */
14
+ readonly onWaiting?: (decision: HostLoadAdmissionDecision) => void | Promise<void>;
15
+ /**
16
+ * The step records its own fenced outcome (a managed command's receipt). Otherwise a
17
+ * step whose token was reclaimed while it ran fails with host_capacity_token_fenced.
18
+ */
19
+ readonly reportsOwnFence?: boolean;
20
+ /** Called when the token could not be returned; it then lapses with its lease. */
21
+ readonly onReleaseFailed?: (error: unknown) => void | Promise<void>;
22
+ }
23
+ /** Queue time, or null when the governor is off and nothing was queued. */
24
+ export type HostLoadWait = number | null;
25
+ /** What an admitted step gets from its token; both absent while the governor is off. */
26
+ export interface HostLoadStepControl {
27
+ /** Aborted when the token was reclaimed: the step must stop. */
28
+ readonly fenced?: AbortSignal;
29
+ /** Records the step's process tree so a reclaim stops it before reusing its capacity. */
30
+ readonly attachProcess?: (stepProcess: HostLoadStepProcess) => Promise<void>;
31
+ /**
32
+ * For a step that reports its own outcome (a managed command's receipt) when its
33
+ * process tree could not be proven gone: the token is kept, not returned, until
34
+ * `stillGone` proves it (null: see HostLoadAdmission.retainUntilStopped).
35
+ */
36
+ readonly holdUntilStopped?: (stillGone: (() => Promise<boolean>) | null, reason: Error) => void;
37
+ }
38
+ /** Why a step's token is kept after it ended, and what proves its tree gone. */
39
+ export interface HostLoadRetention {
40
+ readonly stillGone: (() => Promise<boolean>) | null;
41
+ readonly reason: Error;
42
+ }
43
+ /**
44
+ * The retention a step's failure calls for: a tree that could not be proven gone,
45
+ * whether the runner said so with its own check (ProcessTreeTerminationError) or a
46
+ * supervisor did (host_process_supervisor_termination_failed, possibly wrapped).
47
+ */
48
+ export declare function retentionFor(error: unknown): HostLoadRetention | null;
49
+ /**
50
+ * With the governor off (or no gate), `run` is called directly with a null
51
+ * wait, so behavior is unchanged. With it on, `run` starts only after
52
+ * admission, so the step's own timers never include queue time, and the token
53
+ * is returned when `run` settles, whether it succeeded, failed or was stopped.
54
+ */
55
+ export declare function runHostGovernedStep<T>(gate: HostLoadStepGate | undefined, step: HostGovernedStep, run: (hostLoadWaitMs: HostLoadWait, control: HostLoadStepControl) => Promise<T>): Promise<T>;
56
+ /**
57
+ * Returns a step's token, unless part of its process tree could not be proven
58
+ * gone: the token (and its cost) is then kept until the tree is.
59
+ */
60
+ export declare function returnHostLoadToken(admission: HostLoadAdmission, retention: HostLoadRetention | null, onReleaseFailed?: (error: unknown) => void | Promise<void>): Promise<void>;
61
+ /**
62
+ * A step stopped because its token was reclaimed reports host_capacity_token_fenced
63
+ * (retryable), not the exit status or error it died with.
64
+ */
65
+ export declare function throwIfFenced<T>(fenced: AbortSignal, outcome: T): T;
66
+ /**
67
+ * Records a supervised step's process tree on its host load token, from the
68
+ * metadata its process supervisor wrote (`FORGE_PROCESS_SUPERVISOR_METADATA_PATH`):
69
+ * a reclaim then stops exactly this tree before reusing its capacity. Rejects when
70
+ * the tree cannot be read or recorded; the caller must then stop the step, since
71
+ * it would otherwise run on without a reservation the host can account for.
72
+ */
73
+ export declare function attachSupervisedStepProcess(control: HostLoadStepControl, metadataPath: string): Promise<void>;