@loucompanion/forge-bridge 0.1.4-dev.63db04bcffca → 0.1.4-dev.81e48ecc185d

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 (170) hide show
  1. package/README.md +54 -2
  2. package/dist/bridge/bridge-chat-provider-command.d.ts +16 -0
  3. package/dist/bridge/bridge-chat-provider-command.js +125 -0
  4. package/dist/bridge/bridge.base.d.ts +9 -0
  5. package/dist/bridge/bridge.service.d.ts +85 -3
  6. package/dist/bridge/bridge.service.js +361 -122
  7. package/dist/bridge/bridge.types.d.ts +22 -0
  8. package/dist/bridge/dispatch-result-outbox.d.ts +11 -1
  9. package/dist/bridge/dispatch-result-outbox.js +31 -6
  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 +2 -0
  13. package/dist/bridge/runner-host-capabilities.js +4 -0
  14. package/dist/bridge/test-postgres-capability.d.ts +14 -0
  15. package/dist/bridge/test-postgres-capability.js +120 -0
  16. package/dist/cleanup/cleanup.service.d.ts +9 -0
  17. package/dist/cleanup/cleanup.service.js +72 -109
  18. package/dist/cleanup/cleanup.types.d.ts +4 -0
  19. package/dist/cleanup/forge-owned-paths.d.ts +9 -0
  20. package/dist/cleanup/forge-owned-paths.js +53 -0
  21. package/dist/cleanup/host-runtime-ledger.d.ts +5 -0
  22. package/dist/cleanup/host-runtime-ledger.js +109 -0
  23. package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
  24. package/dist/cleanup/managed-branch-sweep.js +111 -0
  25. package/dist/cli/cli.help.js +18 -0
  26. package/dist/cli/cli.service.d.ts +16 -0
  27. package/dist/cli/cli.service.js +142 -16
  28. package/dist/cli/local-config.d.ts +4 -0
  29. package/dist/cli/local-config.js +26 -4
  30. package/dist/runtime/aspnet-runtime-prebuild.js +94 -6
  31. package/dist/runtime/attempt-process-supervisor.d.ts +19 -0
  32. package/dist/runtime/attempt-process-supervisor.js +50 -0
  33. package/dist/runtime/host-database-capability-boundary.d.ts +1 -1
  34. package/dist/runtime/host-database-capability-boundary.js +1 -0
  35. package/dist/runtime/host-facts.d.ts +35 -0
  36. package/dist/runtime/host-facts.js +95 -0
  37. package/dist/runtime/host-load-admission.d.ts +64 -0
  38. package/dist/runtime/host-load-admission.js +99 -0
  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 +49 -0
  42. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  43. package/dist/runtime/host-load-governor-config.d.ts +52 -0
  44. package/dist/runtime/host-load-governor-config.js +83 -0
  45. package/dist/runtime/host-load-governor.d.ts +184 -0
  46. package/dist/runtime/host-load-governor.js +632 -0
  47. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  48. package/dist/runtime/host-load-ledger-lock.js +185 -0
  49. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  50. package/dist/runtime/host-load-runtime-settings.js +78 -0
  51. package/dist/runtime/host-load-sampler.d.ts +126 -0
  52. package/dist/runtime/host-load-sampler.js +232 -0
  53. package/dist/runtime/host-load-step-class.d.ts +70 -0
  54. package/dist/runtime/host-load-step-class.js +161 -0
  55. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  56. package/dist/runtime/host-load-step-reaper.js +95 -0
  57. package/dist/runtime/host-load-step-run.d.ts +73 -0
  58. package/dist/runtime/host-load-step-run.js +102 -0
  59. package/dist/runtime/host-load-test-slot.d.ts +43 -0
  60. package/dist/runtime/host-load-test-slot.js +81 -0
  61. package/dist/runtime/host-load-token-ledger.d.ts +200 -0
  62. package/dist/runtime/host-load-token-ledger.js +453 -0
  63. package/dist/runtime/host-pressure-stall.d.ts +61 -0
  64. package/dist/runtime/host-pressure-stall.js +168 -0
  65. package/dist/runtime/host-runtime-contract.d.ts +4 -0
  66. package/dist/runtime/host-runtime-contract.js +6 -1
  67. package/dist/runtime/host-runtime-lease.d.ts +74 -4
  68. package/dist/runtime/host-runtime-lease.js +336 -20
  69. package/dist/runtime/host-runtime-promotion.d.ts +23 -0
  70. package/dist/runtime/host-runtime-promotion.js +48 -0
  71. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  72. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  73. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  74. package/dist/runtime/host-runtime-requirements.js +117 -0
  75. package/dist/runtime/managed-command-teardown.d.ts +62 -0
  76. package/dist/runtime/managed-command-teardown.js +607 -0
  77. package/dist/runtime/playwright-browser-cache.d.ts +39 -0
  78. package/dist/runtime/playwright-browser-cache.js +227 -0
  79. package/dist/runtime/playwright-host-runtime-adapter.d.ts +18 -0
  80. package/dist/runtime/playwright-host-runtime-adapter.js +61 -55
  81. package/dist/runtime/runner-settings.d.ts +100 -0
  82. package/dist/runtime/runner-settings.js +214 -0
  83. package/dist/sandbox/host-capacity-broker.d.ts +113 -0
  84. package/dist/sandbox/host-capacity-broker.js +334 -0
  85. package/dist/sandbox/runtime.d.ts +10 -1
  86. package/dist/sandbox/runtime.js +45 -2
  87. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  88. package/dist/sandbox/sandbox-cgroups.js +42 -0
  89. package/dist/session/managed-attempt-tools.d.ts +27 -0
  90. package/dist/session/managed-attempt-tools.js +356 -41
  91. package/dist/session/managed-build-coordinator.d.ts +1 -1
  92. package/dist/session/managed-build-coordinator.js +4 -1
  93. package/dist/session/managed-command-host-load.d.ts +47 -0
  94. package/dist/session/managed-command-host-load.js +83 -0
  95. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  96. package/dist/session/mcp-argument-coercion.js +121 -0
  97. package/dist/session/phase-completion.artifacts.d.ts +7 -0
  98. package/dist/session/phase-completion.artifacts.js +98 -25
  99. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  100. package/dist/session/phase-completion.command-validation.js +77 -0
  101. package/dist/session/phase-completion.d.ts +4 -0
  102. package/dist/session/phase-completion.helpers.js +13 -12
  103. package/dist/session/phase-completion.js +4 -0
  104. package/dist/session/phase-completion.prompts.js +6 -1
  105. package/dist/session/phase-completion.runtime.d.ts +5 -3
  106. package/dist/session/phase-completion.runtime.js +70 -35
  107. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  108. package/dist/session/phase-completion.schema-parts.js +188 -0
  109. package/dist/session/phase-completion.schemas.d.ts +3 -3
  110. package/dist/session/phase-completion.schemas.js +206 -221
  111. package/dist/session/phase-completion.validation.d.ts +2 -3
  112. package/dist/session/phase-completion.validation.js +46 -92
  113. package/dist/session/pre-publication-host-load.d.ts +27 -0
  114. package/dist/session/pre-publication-host-load.js +111 -0
  115. package/dist/session/pre-publication-pass.d.ts +61 -0
  116. package/dist/session/pre-publication-pass.js +148 -0
  117. package/dist/session/pre-publication-process.d.ts +23 -0
  118. package/dist/session/pre-publication-process.js +109 -0
  119. package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
  120. package/dist/session/pre-publication-skipped-tests.js +109 -0
  121. package/dist/session/pre-publication-step-execution.d.ts +11 -0
  122. package/dist/session/pre-publication-step-execution.js +49 -0
  123. package/dist/session/pre-publication-validation.d.ts +32 -20
  124. package/dist/session/pre-publication-validation.js +202 -195
  125. package/dist/session/provider-cli/claude-background-work.d.ts +66 -0
  126. package/dist/session/provider-cli/claude-background-work.js +180 -0
  127. package/dist/session/provider-cli/pre-publication-repair.d.ts +40 -0
  128. package/dist/session/provider-cli/pre-publication-repair.js +243 -0
  129. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +2 -1
  130. package/dist/session/provider-cli/provider-cli.artifacts.js +21 -15
  131. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
  132. package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
  133. package/dist/session/provider-cli/provider-cli.process.d.ts +39 -2
  134. package/dist/session/provider-cli/provider-cli.process.js +276 -42
  135. package/dist/session/provider-cli/provider-cli.prompts.d.ts +7 -0
  136. package/dist/session/provider-cli/provider-cli.prompts.js +65 -10
  137. package/dist/session/provider-cli/provider-cli.runtime.js +7 -0
  138. package/dist/session/provider-cli/provider-cli.service.d.ts +4 -1
  139. package/dist/session/provider-cli/provider-cli.service.js +203 -172
  140. package/dist/session/provider-cli/provider-cli.types.d.ts +30 -0
  141. package/dist/session/provider-cli/provider-in-flight-work.d.ts +10 -0
  142. package/dist/session/provider-cli/provider-in-flight-work.js +92 -0
  143. package/dist/session/provider-cli/provider-output-state.d.ts +8 -0
  144. package/dist/session/provider-cli/provider-output-state.js +15 -0
  145. package/dist/session/publishable-worktree-changes.d.ts +54 -0
  146. package/dist/session/publishable-worktree-changes.js +193 -0
  147. package/dist/session/sandbox-host-capacity-gate.d.ts +30 -0
  148. package/dist/session/sandbox-host-capacity-gate.js +238 -0
  149. package/dist/session/session.base.d.ts +9 -1
  150. package/dist/session/session.service.d.ts +9 -2
  151. package/dist/session/session.service.js +120 -5
  152. package/dist/session/session.types.d.ts +3 -0
  153. package/dist/session/session.types.js +15 -3
  154. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  155. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  156. package/dist/shared/process/host-process-supervisor.d.ts +1 -0
  157. package/dist/shared/process/host-process-supervisor.js +1 -1
  158. package/dist/shared/process/process-tree.d.ts +52 -0
  159. package/dist/shared/process/process-tree.js +144 -0
  160. package/dist/shared/process/process.d.ts +67 -0
  161. package/dist/shared/process/process.js +213 -11
  162. package/dist/shared/provider-capabilities.js +5 -6
  163. package/dist/version.d.ts +1 -1
  164. package/dist/version.js +1 -1
  165. package/dist/worktree/dependency-warmer.d.ts +25 -0
  166. package/dist/worktree/dependency-warmer.js +46 -10
  167. package/dist/worktree/worktree.service.d.ts +10 -1
  168. package/dist/worktree/worktree.service.js +42 -2
  169. package/dist/worktree/worktree.types.d.ts +7 -0
  170. package/package.json +2 -2
@@ -0,0 +1,83 @@
1
+ import { defaultHostLoadSampleIntervalMs } from "./host-load-sampler.js";
2
+ export const defaultHostTestSlots = 1;
3
+ export const defaultHostLoadGovernorConfig = {
4
+ mode: "off",
5
+ testSlots: defaultHostTestSlots,
6
+ cpuBudgetFraction: 0.8,
7
+ memoryReserveBytes: 1024 ** 3,
8
+ cpuPressureThreshold: 50,
9
+ backpressureSamples: 2,
10
+ memoryFullThreshold: 5,
11
+ maxWaitMs: 30 * 60_000,
12
+ fallbackSlots: 1,
13
+ antiStarvationMs: 2 * 60_000,
14
+ leaseMs: 2 * 60_000,
15
+ recheckIntervalMs: 1_000,
16
+ sampleStaleMs: 30_000,
17
+ sampleIntervalMs: defaultHostLoadSampleIntervalMs,
18
+ memoryRampMs: 60_000,
19
+ };
20
+ export function parseHostLoadGovernorMode(value) {
21
+ const normalized = value?.trim().toLowerCase() ?? "";
22
+ return normalized === "on" || normalized === "true" || normalized === "1" ? "on" : "off";
23
+ }
24
+ /** The governor admits steps when either rule is on: the host test slot or the budget. */
25
+ export function hostLoadGovernorEnabled(config) {
26
+ return config.mode === "on" || config.testSlots > 0;
27
+ }
28
+ export function loadHostLoadGovernorConfig(environment = process.env) {
29
+ const defaults = defaultHostLoadGovernorConfig;
30
+ return {
31
+ mode: parseHostLoadGovernorMode(environment.FORGE_HOST_LOAD_GOVERNOR),
32
+ testSlots: Math.round(bounded(environment.FORGE_HOST_LOAD_TEST_SLOTS, defaults.testSlots, 0, 8)),
33
+ cpuBudgetFraction: bounded(environment.FORGE_HOST_LOAD_CPU_BUDGET_FRACTION, defaults.cpuBudgetFraction, 0.05, 1),
34
+ memoryReserveBytes: bounded(environment.FORGE_HOST_LOAD_MEMORY_RESERVE_BYTES, defaults.memoryReserveBytes, 0, 1024 ** 4),
35
+ cpuPressureThreshold: bounded(environment.FORGE_HOST_LOAD_CPU_PRESSURE_THRESHOLD, defaults.cpuPressureThreshold, 1, 100),
36
+ backpressureSamples: Math.round(bounded(environment.FORGE_HOST_LOAD_BACKPRESSURE_SAMPLES, defaults.backpressureSamples, 1, 60)),
37
+ 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),
39
+ fallbackSlots: Math.round(bounded(environment.FORGE_HOST_LOAD_FALLBACK_SLOTS, defaults.fallbackSlots, 1, 64)),
40
+ antiStarvationMs: defaults.antiStarvationMs,
41
+ leaseMs: defaults.leaseMs,
42
+ recheckIntervalMs: defaults.recheckIntervalMs,
43
+ sampleStaleMs: defaults.sampleStaleMs,
44
+ sampleIntervalMs: defaults.sampleIntervalMs,
45
+ memoryRampMs: defaults.memoryRampMs,
46
+ cpuBudgetCeilingFraction: lowestFraction(optionalCpuPercentFraction(environment.FORGE_HOST_CPU_BUDGET_PERCENT), optionalFraction(environment.FORGE_HOST_LOAD_CPU_BUDGET_FRACTION)),
47
+ maxHeavyStepsCeiling: optionalHeavySteps(environment.FORGE_HOST_MAX_HEAVY_STEPS),
48
+ };
49
+ }
50
+ /** Matches runner-settings' parse of FORGE_HOST_CPU_BUDGET_PERCENT (Number, 10-100); unparsable is unset. */
51
+ function optionalCpuPercentFraction(raw) {
52
+ if (raw === undefined || raw.trim() === "")
53
+ return null;
54
+ const value = Number(raw);
55
+ return Number.isFinite(value) ? Math.min(100, Math.max(10, value)) / 100 : null;
56
+ }
57
+ /** An explicitly set FORGE_HOST_LOAD_CPU_BUDGET_FRACTION is a ceiling too (runner-settings' cpuBudgetCeilings). */
58
+ function optionalFraction(raw) {
59
+ if (raw === undefined || raw.trim() === "")
60
+ return null;
61
+ const value = Number(raw);
62
+ return Number.isFinite(value) ? Math.min(1, Math.max(0.05, value)) : null;
63
+ }
64
+ function lowestFraction(a, b) {
65
+ if (a === null)
66
+ return b;
67
+ if (b === null)
68
+ return a;
69
+ return Math.min(a, b);
70
+ }
71
+ /** Matches runner-settings' parse of FORGE_HOST_MAX_HEAVY_STEPS (parseInt, 1-64); unparsable is unset. */
72
+ function optionalHeavySteps(raw) {
73
+ if (raw === undefined || raw.trim() === "")
74
+ return null;
75
+ const value = Number.parseInt(raw, 10);
76
+ return Number.isFinite(value) ? Math.min(64, Math.max(1, value)) : null;
77
+ }
78
+ function bounded(raw, fallback, minimum, maximum) {
79
+ if (raw === undefined || raw.trim() === "")
80
+ return fallback;
81
+ const value = Number(raw);
82
+ return Number.isFinite(value) ? Math.min(maximum, Math.max(minimum, value)) : fallback;
83
+ }
@@ -0,0 +1,184 @@
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
+ import { type HostLoadOwnerLiveness, type HostLoadToken, type HostLoadTokenOwner, type HostLoadTokenPriority } from "./host-load-token-ledger.js";
8
+ export interface HostLoadStepRequest {
9
+ readonly stepClass: string;
10
+ /** What the step is, for diagnostics (for example the validation check id). */
11
+ readonly label: string;
12
+ readonly cost: HostLoadStepCost;
13
+ readonly dispatchAttemptId: string | null;
14
+ readonly priority: HostLoadTokenPriority;
15
+ }
16
+ export interface HostLoadAcquireOptions {
17
+ readonly signal?: AbortSignal;
18
+ /** Called once, when the first admission decision says the step must wait. */
19
+ readonly onWaiting?: (decision: HostLoadAdmissionDecision) => void | Promise<void>;
20
+ }
21
+ export interface HostLoadAdmission {
22
+ readonly tokenId: string;
23
+ readonly fencingToken: number;
24
+ readonly stepClass: string;
25
+ /** Time spent queued; never counted as step execution time. */
26
+ readonly waitMs: number;
27
+ readonly decision: HostLoadAdmissionDecision;
28
+ /**
29
+ * Aborted when the reservation is lost while the step runs: with
30
+ * host_capacity_token_fenced when the token was fenced (this owner stalled
31
+ * past its lease and another process saw it), or with
32
+ * host_capacity_ledger_unavailable when it could not be renewed for a whole
33
+ * lease. The step must stop; the token keeps its cost until it is released.
34
+ */
35
+ readonly fenced: AbortSignal;
36
+ /** Records the step's process tree, so a reclaim stops it before reusing its capacity. */
37
+ attachProcess(stepProcess: HostLoadStepProcess): Promise<void>;
38
+ /** Returns the token. Rejects with host_capacity_token_fenced if it was fenced or reclaimed. */
39
+ release(): Promise<void>;
40
+ /**
41
+ * Instead of release: the step ended but part of its process tree could not
42
+ * be proven gone. The token stays held, with its cost, and is returned only
43
+ * once `stillGone` (re-checked on every renewal) resolves true. Without a
44
+ * check, the token's recorded process tree is checked instead; with neither,
45
+ * the token is kept until attempt teardown has stopped the attempt's processes.
46
+ */
47
+ retainUntilStopped(stillGone: (() => Promise<boolean>) | null, reason: Error): void;
48
+ }
49
+ /** The gate heavy steps call before launching. */
50
+ export interface HostLoadStepGate {
51
+ readonly enabled: boolean;
52
+ /** The longest a step may queue before host_capacity_timeout, when the gate knows it. */
53
+ readonly maxWaitMs?: number;
54
+ acquire(request: HostLoadStepRequest, options?: HostLoadAcquireOptions): Promise<HostLoadAdmission>;
55
+ }
56
+ export declare class HostCapacityTimeoutError extends ForgeFailureError {
57
+ readonly stepClass: string;
58
+ readonly label: string;
59
+ readonly waitMs: number;
60
+ readonly code = "host_capacity_timeout";
61
+ constructor(stepClass: string, label: string, waitMs: number, detail: string);
62
+ }
63
+ export interface HostLoadGovernorOptions {
64
+ readonly stateRoot: string;
65
+ readonly load: HostLoadGovernorSource;
66
+ readonly config?: HostLoadGovernorConfig;
67
+ readonly liveness?: HostLoadOwnerLiveness;
68
+ /** Owner recorded on tokens (tests model separate processes); defaults to this process. */
69
+ readonly owner?: HostLoadTokenOwner;
70
+ readonly now?: () => number;
71
+ /** Test seam for the ledger's process-tree reaper. */
72
+ readonly terminateStep?: HostLoadStepTerminator;
73
+ /** Test seam for the host suspend counter. */
74
+ readonly suspendedMs?: () => number;
75
+ }
76
+ /**
77
+ * Host-wide admission for heavy steps (decision 0013). Waiters queue
78
+ * foreground before background and FIFO within a class; a waiter that fits may
79
+ * overtake an unfit head until the head has waited past the anti-starvation
80
+ * window. Running steps are never preempted. Reserved cost comes from the
81
+ * shared token ledger, so other processes' steps count against the same budget.
82
+ * The host test slot (decision 0018) comes first: a heavy step waits for it in
83
+ * the host-wide queue the ledger keeps, then for the budget when that is on.
84
+ */
85
+ export declare class HostLoadGovernor implements HostLoadStepGate {
86
+ private readonly options;
87
+ readonly enabled: boolean;
88
+ private readonly config;
89
+ private readonly ledger;
90
+ private readonly waiters;
91
+ private readonly held;
92
+ private recheckTimer;
93
+ private renewTimer;
94
+ private draining;
95
+ private drainAgain;
96
+ /** Own cgroup anonymous memory with no heavy step running: the bridge's baseline. */
97
+ private idleOwnMemoryBytes;
98
+ /** The bridge's pushed settings (decision 0014), shared with every governor on this state root. */
99
+ private readonly runtimeSettings;
100
+ constructor(options: HostLoadGovernorOptions);
101
+ get maxWaitMs(): number;
102
+ acquire(request: HostLoadStepRequest, options?: HostLoadAcquireOptions): Promise<HostLoadAdmission>;
103
+ /** Reclaims tokens whose owner is gone or whose lease expired (bridge startup). */
104
+ reclaim(): Promise<readonly HostLoadToken[]>;
105
+ /** Returns dead owners' unrecorded tokens the caller proved stopped (see the ledger). */
106
+ releaseOrphaned(belongs: (token: HostLoadToken) => boolean): Promise<readonly HostLoadToken[]>;
107
+ /**
108
+ * Attempt teardown: cancels the attempt's queued steps and stops its running
109
+ * ones (their `fenced` signal aborts with dispatch_cancelled). A running step
110
+ * keeps its token, and its cost, until the step itself returns it once its
111
+ * processes are gone, so the capacity is never reused while it still runs.
112
+ */
113
+ stopAttempt(dispatchAttemptId: string): void;
114
+ /**
115
+ * Cancels the attempt's queued steps and returns every token it holds at
116
+ * once. Only for callers that know the attempt's steps are no longer running;
117
+ * attempt teardown uses stopAttempt.
118
+ */
119
+ releaseAttempt(dispatchAttemptId: string): Promise<void>;
120
+ private cancelAttemptWaiters;
121
+ /** Waiting and admitted steps of this process, for diagnostics. */
122
+ snapshot(): {
123
+ readonly waiting: number;
124
+ readonly held: readonly HostLoadToken[];
125
+ };
126
+ private drain;
127
+ private drainOnce;
128
+ /**
129
+ * Decision 0014: the CPU budget (or yield budget) and the heavy-step limit the
130
+ * bridge has in force apply from the next admission; running steps keep theirs.
131
+ * The operator's env ceilings hold with or without the file, and over whatever it says.
132
+ */
133
+ private budgetPass;
134
+ /** The host test slot first (decision 0018), then the budget when it is on. */
135
+ private decide;
136
+ private readSignals;
137
+ /**
138
+ * Consecutive pressured samples ending with the latest one, read from the
139
+ * sampler's history so samples taken while nothing waited still count. A gap
140
+ * in sampling (sampler stopped, host suspended) breaks the streak.
141
+ */
142
+ private pressureStreak;
143
+ /**
144
+ * Memory the running steps already use, which MemAvailable already reflects,
145
+ * so the budget does not count it twice. Measured from the dedicated cgroup
146
+ * above its idle baseline; without one, a step admitted longer than the ramp
147
+ * window ago is assumed to hold its reservation. Never above the reservations.
148
+ */
149
+ private runningStepsMemoryBytes;
150
+ private logicalCpus;
151
+ private settle;
152
+ /** Renewed tokens reset their lease clock; fenced ones stop their steps (they keep their cost until released). */
153
+ private applyHeldOutcome;
154
+ /** The step must stop: its reservation is no longer guaranteed. */
155
+ private lose;
156
+ /** Ledger failures reach every queued step instead of leaving it to time out. */
157
+ private failWaiters;
158
+ private attachProcess;
159
+ /**
160
+ * Returns a step's token. It stays held (and renewed) until the ledger takes
161
+ * it back, so a ledger outage cannot leave it to lapse into a fenced
162
+ * reservation; the renewal timer retries the release. A fenced token is
163
+ * removed too (its step is over) and the release reports the fence.
164
+ */
165
+ private releaseHeld;
166
+ private forget;
167
+ private armRecheck;
168
+ private disarmRecheck;
169
+ private armRenewal;
170
+ private disarmRenewal;
171
+ /**
172
+ * The step ended but part of its process tree may still run: its token stays
173
+ * held and renewed, with its cost, and the step's own termination check is
174
+ * retried on every renewal tick until it proves the tree gone.
175
+ */
176
+ private retainUntilStopped;
177
+ /**
178
+ * Attempt teardown stopped the attempt's processes (its process supervisor
179
+ * proved them gone): tokens kept for a tree nothing else can check are returned.
180
+ */
181
+ releaseRetainedAfterTeardown(dispatchAttemptId: string): Promise<void>;
182
+ private checkRetained;
183
+ private renewHeld;
184
+ }