@loucompanion/forge-bridge 0.1.4-dev.e83e5bc6ecce → 0.1.4-dev.efc418893964
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.
- package/README.md +56 -1
- package/dist/bridge/bridge-chat-provider-command.d.ts +19 -0
- package/dist/bridge/bridge-chat-provider-command.js +132 -0
- package/dist/bridge/bridge-chat.types.d.ts +10 -0
- package/dist/bridge/bridge-chat.types.js +16 -1
- package/dist/bridge/bridge.base.d.ts +9 -0
- package/dist/bridge/bridge.service.d.ts +71 -2
- package/dist/bridge/bridge.service.js +282 -114
- package/dist/bridge/bridge.types.d.ts +11 -0
- package/dist/bridge/local-yield-flag.d.ts +6 -0
- package/dist/bridge/local-yield-flag.js +34 -0
- package/dist/bridge/runner-host-capabilities.d.ts +3 -0
- package/dist/bridge/runner-host-capabilities.js +13 -0
- package/dist/cli/cli.help.js +18 -0
- package/dist/cli/cli.service.d.ts +16 -0
- package/dist/cli/cli.service.js +132 -14
- package/dist/cli/local-config.d.ts +4 -0
- package/dist/cli/local-config.js +26 -4
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +5 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +138 -6
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -0
- package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
- package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
- package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
- package/dist/runtime/ephemeral-test-postgres.js +303 -0
- package/dist/runtime/host-facts.d.ts +2 -1
- package/dist/runtime/host-load-admission.d.ts +18 -3
- package/dist/runtime/host-load-admission.js +19 -4
- package/dist/runtime/host-load-child-environment.d.ts +11 -6
- package/dist/runtime/host-load-child-environment.js +22 -11
- package/dist/runtime/host-load-governor-config.d.ts +19 -1
- package/dist/runtime/host-load-governor-config.js +37 -0
- package/dist/runtime/host-load-governor.d.ts +12 -0
- package/dist/runtime/host-load-governor.js +139 -26
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +78 -0
- package/dist/runtime/host-load-sampler.d.ts +34 -4
- package/dist/runtime/host-load-sampler.js +73 -7
- package/dist/runtime/host-load-step-class.d.ts +3 -1
- package/dist/runtime/host-load-step-class.js +60 -5
- package/dist/runtime/host-load-test-slot.d.ts +43 -0
- package/dist/runtime/host-load-test-slot.js +81 -0
- package/dist/runtime/host-load-token-ledger.d.ts +26 -0
- package/dist/runtime/host-load-token-ledger.js +93 -61
- package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
- package/dist/runtime/host-load-windows-cpu.js +85 -0
- package/dist/runtime/host-runtime-contract.d.ts +12 -0
- package/dist/runtime/host-runtime-contract.js +29 -1
- package/dist/runtime/host-runtime-lease.d.ts +59 -3
- package/dist/runtime/host-runtime-lease.js +209 -58
- package/dist/runtime/host-runtime-promotion.d.ts +23 -0
- package/dist/runtime/host-runtime-promotion.js +36 -0
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
- package/dist/runtime/runner-settings.d.ts +100 -0
- package/dist/runtime/runner-settings.js +214 -0
- package/dist/sandbox/host-capacity-broker.d.ts +7 -1
- package/dist/sandbox/host-capacity-broker.js +23 -4
- package/dist/session/architect-waits.d.ts +2 -0
- package/dist/session/architect-waits.js +138 -0
- package/dist/session/managed-attempt-tools.d.ts +0 -7
- package/dist/session/managed-attempt-tools.js +51 -62
- package/dist/session/managed-command-host-load.d.ts +2 -0
- package/dist/session/managed-command-host-load.js +2 -1
- package/dist/session/phase-completion.artifacts.js +2 -1
- package/dist/session/phase-completion.d.ts +8 -0
- package/dist/session/phase-completion.js +1 -0
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +156 -0
- package/dist/session/phase-completion.runtime.d.ts +0 -8
- package/dist/session/phase-completion.runtime.js +43 -197
- package/dist/session/phase-completion.schemas.js +25 -23
- package/dist/session/phase-completion.validation.js +3 -1
- package/dist/session/pre-publication-native-postgres.d.ts +30 -0
- package/dist/session/pre-publication-native-postgres.js +111 -0
- package/dist/session/pre-publication-pass.d.ts +61 -0
- package/dist/session/pre-publication-pass.js +148 -0
- package/dist/session/pre-publication-step-execution.d.ts +2 -1
- package/dist/session/pre-publication-step-execution.js +6 -5
- package/dist/session/pre-publication-validation.d.ts +30 -14
- package/dist/session/pre-publication-validation.js +207 -134
- package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
- package/dist/session/provider-cli/claude-background-work.js +181 -0
- package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
- package/dist/session/provider-cli/host-build-lock.js +30 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +276 -0
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +15 -36
- package/dist/session/provider-cli/provider-cli.process.js +39 -430
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +5 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +71 -31
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +8 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +29 -1
- package/dist/session/provider-cli/provider-cli.service.d.ts +7 -1
- package/dist/session/provider-cli/provider-cli.service.js +78 -171
- package/dist/session/provider-cli/provider-cli.types.d.ts +26 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
- package/dist/session/provider-cli/provider-in-flight-work.d.ts +4 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +45 -0
- package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
- package/dist/session/provider-cli/provider-output-pipes.js +67 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
- package/dist/session/provider-cli/provider-output-state.js +6 -0
- package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
- package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
- package/dist/session/qa-sidecar-validation.d.ts +6 -0
- package/dist/session/qa-sidecar-validation.js +28 -0
- package/dist/session/sandbox-host-capacity-gate.js +12 -3
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.base.d.ts +6 -1
- package/dist/session/session.service.d.ts +7 -2
- package/dist/session/session.service.js +100 -2
- package/dist/session/session.types.js +4 -4
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
- package/dist/shared/process/windows-app-execution-alias.js +45 -0
- package/dist/shared/process/windows-launch.d.ts +18 -0
- package/dist/shared/process/windows-launch.js +68 -0
- package/dist/shared/provider-capabilities.js +14 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type os from "node:os";
|
|
2
|
+
import type { PressureStallResource } from "./host-pressure-stall.js";
|
|
3
|
+
/** Host CPU time summed over every logical CPU, in milliseconds, from os.cpus(). */
|
|
4
|
+
export interface CpuTimeTotals {
|
|
5
|
+
readonly busyMs: number;
|
|
6
|
+
readonly totalMs: number;
|
|
7
|
+
readonly cpuCount: number;
|
|
8
|
+
}
|
|
9
|
+
export type CpuTimesSource = readonly Partial<Pick<os.CpuInfo, "times">>[];
|
|
10
|
+
/**
|
|
11
|
+
* Host CPU use at which the estimate starts to report pressure. Waits for a CPU
|
|
12
|
+
* are rare below it on a many-core host. 0.6 puts the default backpressure
|
|
13
|
+
* threshold (50%) at 80% host CPU use, the default CPU budget.
|
|
14
|
+
*/
|
|
15
|
+
export declare const windowsCpuPressureKnee = 0.6;
|
|
16
|
+
/** Busy is user + nice + sys + irq; idle is not busy. Null when any CPU lacks its times. */
|
|
17
|
+
export declare function cpuTimeTotals(cpus: CpuTimesSource): CpuTimeTotals | null;
|
|
18
|
+
/** Busy share of all logical CPUs (0-1) between two readings; null across a CPU count change or a counter reset. */
|
|
19
|
+
export declare function cpuUtilisation(previous: CpuTimeTotals | null, current: CpuTimeTotals | null): number | null;
|
|
20
|
+
/** Estimated share of wall time (percent) some runnable thread waited for a CPU, for one window. */
|
|
21
|
+
export declare function estimatedCpuStallPercent(utilisation: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Keeps 10/60/300-second exponentially decaying averages of the estimate, the
|
|
24
|
+
* way the kernel keeps PSI averages, so the governor's threshold and pressure
|
|
25
|
+
* streak read it exactly like PSI. The first window seeds every average, so a
|
|
26
|
+
* host already busy when the bridge starts reports pressure at once.
|
|
27
|
+
*/
|
|
28
|
+
export declare class WindowsCpuPressureEstimator {
|
|
29
|
+
private averages;
|
|
30
|
+
/** Folds in one window of host CPU use lasting `elapsedMs`. */
|
|
31
|
+
update(utilisation: number, elapsedMs: number): PressureStallResource;
|
|
32
|
+
current(): PressureStallResource | null;
|
|
33
|
+
reset(): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host CPU use at which the estimate starts to report pressure. Waits for a CPU
|
|
3
|
+
* are rare below it on a many-core host. 0.6 puts the default backpressure
|
|
4
|
+
* threshold (50%) at 80% host CPU use, the default CPU budget.
|
|
5
|
+
*/
|
|
6
|
+
export const windowsCpuPressureKnee = 0.6;
|
|
7
|
+
/** Busy is user + nice + sys + irq; idle is not busy. Null when any CPU lacks its times. */
|
|
8
|
+
export function cpuTimeTotals(cpus) {
|
|
9
|
+
if (cpus.length === 0)
|
|
10
|
+
return null;
|
|
11
|
+
let busyMs = 0;
|
|
12
|
+
let idleMs = 0;
|
|
13
|
+
for (const cpu of cpus) {
|
|
14
|
+
const times = cpu.times;
|
|
15
|
+
if (!times)
|
|
16
|
+
return null;
|
|
17
|
+
const values = [times.user, times.nice, times.sys, times.irq, times.idle];
|
|
18
|
+
if (!values.every(value => Number.isFinite(value) && value >= 0))
|
|
19
|
+
return null;
|
|
20
|
+
busyMs += times.user + times.nice + times.sys + times.irq;
|
|
21
|
+
idleMs += times.idle;
|
|
22
|
+
}
|
|
23
|
+
return { busyMs, totalMs: busyMs + idleMs, cpuCount: cpus.length };
|
|
24
|
+
}
|
|
25
|
+
/** Busy share of all logical CPUs (0-1) between two readings; null across a CPU count change or a counter reset. */
|
|
26
|
+
export function cpuUtilisation(previous, current) {
|
|
27
|
+
if (!previous || !current || previous.cpuCount !== current.cpuCount)
|
|
28
|
+
return null;
|
|
29
|
+
const totalDelta = current.totalMs - previous.totalMs;
|
|
30
|
+
const busyDelta = current.busyMs - previous.busyMs;
|
|
31
|
+
if (totalDelta <= 0 || busyDelta < 0)
|
|
32
|
+
return null;
|
|
33
|
+
return Math.min(1, busyDelta / totalDelta);
|
|
34
|
+
}
|
|
35
|
+
/** Estimated share of wall time (percent) some runnable thread waited for a CPU, for one window. */
|
|
36
|
+
export function estimatedCpuStallPercent(utilisation) {
|
|
37
|
+
const share = (utilisation - windowsCpuPressureKnee) / (1 - windowsCpuPressureKnee);
|
|
38
|
+
return Math.min(1, Math.max(0, share)) * 100;
|
|
39
|
+
}
|
|
40
|
+
const averageWindowsSeconds = { avg10: 10, avg60: 60, avg300: 300 };
|
|
41
|
+
/**
|
|
42
|
+
* Keeps 10/60/300-second exponentially decaying averages of the estimate, the
|
|
43
|
+
* way the kernel keeps PSI averages, so the governor's threshold and pressure
|
|
44
|
+
* streak read it exactly like PSI. The first window seeds every average, so a
|
|
45
|
+
* host already busy when the bridge starts reports pressure at once.
|
|
46
|
+
*/
|
|
47
|
+
export class WindowsCpuPressureEstimator {
|
|
48
|
+
averages = null;
|
|
49
|
+
/** Folds in one window of host CPU use lasting `elapsedMs`. */
|
|
50
|
+
update(utilisation, elapsedMs) {
|
|
51
|
+
const stall = estimatedCpuStallPercent(utilisation);
|
|
52
|
+
const previous = this.averages;
|
|
53
|
+
this.averages = previous === null
|
|
54
|
+
? { avg10: stall, avg60: stall, avg300: stall }
|
|
55
|
+
: {
|
|
56
|
+
avg10: decay(previous.avg10, stall, elapsedMs, averageWindowsSeconds.avg10),
|
|
57
|
+
avg60: decay(previous.avg60, stall, elapsedMs, averageWindowsSeconds.avg60),
|
|
58
|
+
avg300: decay(previous.avg300, stall, elapsedMs, averageWindowsSeconds.avg300),
|
|
59
|
+
};
|
|
60
|
+
return this.current();
|
|
61
|
+
}
|
|
62
|
+
current() {
|
|
63
|
+
if (!this.averages)
|
|
64
|
+
return null;
|
|
65
|
+
return {
|
|
66
|
+
some: {
|
|
67
|
+
avg10: roundPercent(this.averages.avg10),
|
|
68
|
+
avg60: roundPercent(this.averages.avg60),
|
|
69
|
+
avg300: roundPercent(this.averages.avg300),
|
|
70
|
+
},
|
|
71
|
+
// `full` (every runnable thread stalled) is not meaningful for CPU and is not estimated.
|
|
72
|
+
full: null,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
reset() {
|
|
76
|
+
this.averages = null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function decay(previous, sample, elapsedMs, windowSeconds) {
|
|
80
|
+
const weight = Math.exp(-Math.max(0, elapsedMs) / (windowSeconds * 1_000));
|
|
81
|
+
return sample + (previous - sample) * weight;
|
|
82
|
+
}
|
|
83
|
+
function roundPercent(value) {
|
|
84
|
+
return Math.round(value * 100) / 100;
|
|
85
|
+
}
|
|
@@ -57,6 +57,18 @@ export interface HostRuntimeDirectoryEntry {
|
|
|
57
57
|
/** Returns one identity-bound directory inventory for runtime discovery. */
|
|
58
58
|
export type HostRuntimeDirectorySnapshot = (target: string) => Promise<readonly HostRuntimeDirectoryEntry[]>;
|
|
59
59
|
export declare function loadHostRuntimeContract(worktreePath: string, snapshot?: HostRuntimeSourceSnapshot, directorySnapshot?: HostRuntimeDirectorySnapshot): Promise<LoadedHostRuntimeContract>;
|
|
60
|
+
/** A managed attempt's own API master key: 32 random bytes, base64-encoded, as Security:MasterKey expects. */
|
|
61
|
+
export declare function newAttemptApiMasterKey(): string;
|
|
62
|
+
/**
|
|
63
|
+
* The environment a managed attempt's ASP.NET API launches with. When neither the launch profile
|
|
64
|
+
* nor the runtime contract configures Security__MasterKey or Security__MasterKeyFile, the API gets
|
|
65
|
+
* the attempt's own key. Otherwise ASP.NET Development falls back to the host user's dotnet
|
|
66
|
+
* user-secrets: the host's own key where they exist, and a failed secret write wherever they do not.
|
|
67
|
+
* The caller keeps one key for the attempt's whole life, so a restart against the same attempt
|
|
68
|
+
* database can still decrypt what was stored before it. The key is a secret: it is for the API
|
|
69
|
+
* process only, never for the environment handed to checks or providers.
|
|
70
|
+
*/
|
|
71
|
+
export declare function withAttemptApiMasterKey(port: HostRuntimePortConfig, environment: Readonly<Record<string, string>>, attemptMasterKey: string): Readonly<Record<string, string>>;
|
|
60
72
|
export declare function defaultHostRuntimeContract(): HostRuntimeContract;
|
|
61
73
|
export declare function validateHostRuntimeContract(source: string): HostRuntimeContract;
|
|
62
74
|
export declare function hostPortEnvironment(config: HostRuntimePortConfig, hostIp: "127.0.0.1", hostPort: number): Readonly<Record<string, string>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
1
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { isAlias, parseDocument, visit } from "yaml";
|
|
@@ -425,6 +425,34 @@ function safeAspNetLaunchEnvironment(name, value) {
|
|
|
425
425
|
"TMPDIR",
|
|
426
426
|
]).has(normalized);
|
|
427
427
|
}
|
|
428
|
+
// The settings an ASP.NET API reads its secret-store master key from (Security:MasterKey wins).
|
|
429
|
+
const aspNetMasterKeySettings = ["security__masterkey", "security__masterkeyfile"];
|
|
430
|
+
/** A managed attempt's own API master key: 32 random bytes, base64-encoded, as Security:MasterKey expects. */
|
|
431
|
+
export function newAttemptApiMasterKey() {
|
|
432
|
+
return randomBytes(32).toString("base64");
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* The environment a managed attempt's ASP.NET API launches with. When neither the launch profile
|
|
436
|
+
* nor the runtime contract configures Security__MasterKey or Security__MasterKeyFile, the API gets
|
|
437
|
+
* the attempt's own key. Otherwise ASP.NET Development falls back to the host user's dotnet
|
|
438
|
+
* user-secrets: the host's own key where they exist, and a failed secret write wherever they do not.
|
|
439
|
+
* The caller keeps one key for the attempt's whole life, so a restart against the same attempt
|
|
440
|
+
* database can still decrypt what was stored before it. The key is a secret: it is for the API
|
|
441
|
+
* process only, never for the environment handed to checks or providers.
|
|
442
|
+
*/
|
|
443
|
+
export function withAttemptApiMasterKey(port, environment, attemptMasterKey) {
|
|
444
|
+
if (port.adapter !== "aspnetcore")
|
|
445
|
+
return environment;
|
|
446
|
+
const masterKeySetting = (name) => aspNetMasterKeySettings.includes(name.toLowerCase());
|
|
447
|
+
if (Object.entries(environment).some(([name, value]) => masterKeySetting(name) && value.trim().length > 0)) {
|
|
448
|
+
return environment;
|
|
449
|
+
}
|
|
450
|
+
// A blank setting configures nothing; drop it so the attempt's key is the only one.
|
|
451
|
+
return {
|
|
452
|
+
...Object.fromEntries(Object.entries(environment).filter(([name]) => !masterKeySetting(name))),
|
|
453
|
+
Security__MasterKey: attemptMasterKey,
|
|
454
|
+
};
|
|
455
|
+
}
|
|
428
456
|
async function findFiles(root, accepts, maximumDepth, maximumEntries, snapshot) {
|
|
429
457
|
const results = [];
|
|
430
458
|
let examined = 0;
|
|
@@ -15,6 +15,7 @@ import { HostParallelPromotionStore } from "./host-runtime-promotion.js";
|
|
|
15
15
|
import { type HostProcessRecovery } from "../shared/process/host-process-recovery.js";
|
|
16
16
|
import { HostLoadGovernor } from "./host-load-governor.js";
|
|
17
17
|
import { type HostLoadGovernorSource } from "./host-load-sampler.js";
|
|
18
|
+
import type { RunnerHostDefaults } from "./runner-settings.js";
|
|
18
19
|
export interface HostRuntimeLeaseStart {
|
|
19
20
|
readonly lease: RuntimeIsolationLease;
|
|
20
21
|
readonly environment: Readonly<Record<string, string>>;
|
|
@@ -28,7 +29,7 @@ export interface HostRuntimeAdmissionCheckpoint {
|
|
|
28
29
|
}
|
|
29
30
|
export type HostRuntimeAdmissionCheckpointHandler = (checkpoint: HostRuntimeAdmissionCheckpoint) => void | Promise<void>;
|
|
30
31
|
export interface HostRuntimeProjectCheckpoint {
|
|
31
|
-
readonly code: "host_runtime_build_started" | "host_runtime_build_waiting_for_host_capacity" | "host_runtime_build_cached" | "host_runtime_build_completed" | "host_runtime_database_provisioned";
|
|
32
|
+
readonly code: "host_runtime_build_started" | "host_runtime_build_waiting_for_host_capacity" | "host_runtime_build_cached" | "host_runtime_build_completed" | "host_runtime_database_provisioned" | "host_runtime_contract_readmitted";
|
|
32
33
|
readonly message: string;
|
|
33
34
|
readonly data?: Readonly<Record<string, unknown>>;
|
|
34
35
|
}
|
|
@@ -96,10 +97,20 @@ export interface HostNodeRuntimeLaunch<T> extends NodeRuntimeAdapterLaunch<T> {
|
|
|
96
97
|
}
|
|
97
98
|
export interface HostRuntimeLeaseRuntime {
|
|
98
99
|
setRequirementsCheck?(check: HostRequirementsCheck | null): void;
|
|
100
|
+
/** Decision 0014: today's max attempts and memory reserve defaults, before env bounds. */
|
|
101
|
+
capacityLimitDefaults?(): RunnerHostDefaults;
|
|
102
|
+
/** Decision 0014: the effective max attempts and memory reserve, from the next attempt admission. */
|
|
103
|
+
applyCapacityLimits?(limits: HostCapacityLimits): void;
|
|
99
104
|
acquirePreparation?(dispatch: RunOnceDispatchPacket, signal?: AbortSignal): Promise<readonly string[]>;
|
|
100
105
|
acquire(dispatch: RunOnceDispatchPacket, signal?: AbortSignal): Promise<readonly string[]>;
|
|
101
106
|
start(dispatch: RunOnceDispatchPacket, worktreePath: string, signal?: AbortSignal, onAdmissionCheckpoint?: HostRuntimeAdmissionCheckpointHandler): Promise<HostRuntimeLeaseStart>;
|
|
102
107
|
startConfiguredProject(dispatchAttemptId: string, fencingToken: string, signal?: AbortSignal, onProjectCheckpoint?: HostRuntimeProjectCheckpointHandler): Promise<HostRuntimeLeaseStart>;
|
|
108
|
+
/**
|
|
109
|
+
* Stops the attempt's configured project processes, releases their ports, and
|
|
110
|
+
* starts them again (rebuilding when sources changed) so the stack serves the
|
|
111
|
+
* current workspace. Returns the environment with the newly assigned URLs.
|
|
112
|
+
*/
|
|
113
|
+
restartConfiguredProject?(dispatchAttemptId: string, fencingToken: string, signal?: AbortSignal, onProjectCheckpoint?: HostRuntimeProjectCheckpointHandler): Promise<HostRuntimeLeaseStart>;
|
|
103
114
|
updateLease(dispatchAttemptId: string, fencingToken: string, expiresAt: string): Promise<void>;
|
|
104
115
|
providerProcessRunner?(dispatchAttemptId: string, fencingToken: string): ProviderProcessRunner | null;
|
|
105
116
|
providerMemoryTelemetry?(dispatchAttemptId: string, fencingToken: string): AttemptProcessTreeMemoryTelemetry | null;
|
|
@@ -147,15 +158,25 @@ export declare class HostRuntimeLeaseManager implements HostRuntimeLeaseRuntime
|
|
|
147
158
|
private workspaceAvailableBytes;
|
|
148
159
|
private readonly portBroker;
|
|
149
160
|
private readonly nodeAdapter;
|
|
150
|
-
|
|
161
|
+
/** Rebuilt by applyCapacityLimits (decision 0014); every admission reads the current one. */
|
|
162
|
+
private capacityConfiguration;
|
|
151
163
|
private readonly memoryAvailability;
|
|
152
164
|
private readonly executionRoot;
|
|
153
|
-
/** Host-wide admission for heavy steps (
|
|
165
|
+
/** Host-wide admission for heavy steps (decisions 0013, 0018): the host test slot, and the budget when on. */
|
|
154
166
|
readonly hostLoadGovernor: HostLoadGovernor;
|
|
155
167
|
private requirementsCheck;
|
|
156
168
|
/** Installs the decision 0013 accept-time requirements recheck for host attempts. */
|
|
157
169
|
setRequirementsCheck(check: HostRequirementsCheck | null): void;
|
|
158
170
|
constructor(stateRoot: string, portBroker?: HostPortBroker, nodeAdapter?: NodeHostRuntimeAdapter, processSupervisors?: AttemptProcessSupervisorRegistry, processRunner?: ProviderProcessRunner, listenerInspector?: HostListenerInspector, promotionStore?: HostParallelPromotionStore, playwrightAdapter?: PlaywrightHostRuntimeAdapter, processRecovery?: HostProcessRecovery, capacityResourceSample?: HostCapacityResourceSample | undefined, executionRoot?: string, databaseBroker?: AttemptDatabaseBroker | null, hostLoad?: HostLoadGovernorSource | null);
|
|
171
|
+
/** Today's defaults for the limits the server can push, before any env bound (decision 0014). */
|
|
172
|
+
capacityLimitDefaults(): RunnerHostDefaults;
|
|
173
|
+
/**
|
|
174
|
+
* Decision 0014: the bridge's effective max attempts and memory reserve. They
|
|
175
|
+
* apply from the next attempt admission; admitted attempts keep their
|
|
176
|
+
* reservations and are never preempted, even when the new limit is lower than
|
|
177
|
+
* what already runs. The idle reserve follows the reserve as at startup.
|
|
178
|
+
*/
|
|
179
|
+
applyCapacityLimits(limits: HostCapacityLimits): void;
|
|
159
180
|
hostLoadChildEnvironment(): Readonly<Record<string, string>>;
|
|
160
181
|
reap(options: HostRuntimeReapOptions): Promise<HostRuntimeReapReport>;
|
|
161
182
|
snapshot(): HostRuntimeCapacitySnapshot;
|
|
@@ -178,6 +199,24 @@ export declare class HostRuntimeLeaseManager implements HostRuntimeLeaseRuntime
|
|
|
178
199
|
start(dispatch: RunOnceDispatchPacket, worktreePath: string, signal?: AbortSignal, onAdmissionCheckpoint?: HostRuntimeAdmissionCheckpointHandler): Promise<HostRuntimeLeaseStart>;
|
|
179
200
|
updateLease(dispatchAttemptId: string, fencingToken: string, expiresAt: string): Promise<void>;
|
|
180
201
|
startConfiguredProject(dispatchAttemptId: string, fencingToken: string, signal?: AbortSignal, onProjectCheckpoint?: HostRuntimeProjectCheckpointHandler): Promise<HostRuntimeLeaseStart>;
|
|
202
|
+
/**
|
|
203
|
+
* Launches the configured project. Only the first launch, from the admitted commit's clean
|
|
204
|
+
* source, may record parallel-safety proof: a restart serves the workspace after the provider
|
|
205
|
+
* edited it, and a proof observed there would be stored under the admitted commit and could
|
|
206
|
+
* move this or a later attempt at that commit into shared admission for source it never ran.
|
|
207
|
+
*/
|
|
208
|
+
private launchConfiguredProject;
|
|
209
|
+
/**
|
|
210
|
+
* Relaunches the configured project so it serves the current workspace. Every
|
|
211
|
+
* configured process stops (the API port changes, so the dev server's proxy target
|
|
212
|
+
* must change with it), its port reservation is released and dropped from the
|
|
213
|
+
* persisted lease, and the regular start path runs again, including the ASP.NET
|
|
214
|
+
* prebuild, whose receipt rebuilds only when the sources changed.
|
|
215
|
+
*/
|
|
216
|
+
restartConfiguredProject(dispatchAttemptId: string, fencingToken: string, signal?: AbortSignal, onProjectCheckpoint?: HostRuntimeProjectCheckpointHandler): Promise<HostRuntimeLeaseStart>;
|
|
217
|
+
private runConfiguredProjectRestart;
|
|
218
|
+
/** Stops configured project processes in reverse launch order and releases their ports. */
|
|
219
|
+
private stopConfiguredProject;
|
|
181
220
|
providerProcessRunner(dispatchAttemptId: string, fencingToken: string): ProviderProcessRunner | null;
|
|
182
221
|
private markCapacityReservationRunning;
|
|
183
222
|
providerMemoryTelemetry(dispatchAttemptId: string, fencingToken: string): AttemptProcessTreeMemoryTelemetry | null;
|
|
@@ -228,4 +267,21 @@ export declare class HostRuntimeCapacityRequestImpossibleError extends Error {
|
|
|
228
267
|
}
|
|
229
268
|
export declare function hostRuntimeEventResources(lease: RuntimeIsolationLease, runtimeContract?: LoadedHostRuntimeContract, executionClass?: HostRuntimeExecutionClass): Record<string, unknown>;
|
|
230
269
|
export declare function hostRuntimeSingletonKeys(dispatch: RunOnceDispatchPacket): readonly string[];
|
|
270
|
+
/**
|
|
271
|
+
* Every environment key `hostRuntimeEnvironment` and the Playwright overlay derive from the
|
|
272
|
+
* configured project's assigned ports. They name a live stack, so they are withheld while the
|
|
273
|
+
* stack is down: after its ports are released another attempt may be assigned them.
|
|
274
|
+
*/
|
|
275
|
+
export declare function hostRuntimeStackEnvironmentKeys(runtimeContract: LoadedHostRuntimeContract): readonly string[];
|
|
231
276
|
export declare function runtimeAdmissionPriority(dispatch: RunOnceDispatchPacket): HostRuntimeAdmissionPriority;
|
|
277
|
+
/** The pushed attempt limits (decision 0014), already resolved against host env bounds. */
|
|
278
|
+
export interface HostCapacityLimits {
|
|
279
|
+
readonly maxConcurrentAttempts: number;
|
|
280
|
+
readonly memoryReserveBytes: number;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Today's max attempts and adaptive memory reserve for this host, before
|
|
284
|
+
* FORGE_HOST_MAX_CONCURRENT_ATTEMPTS and FORGE_HOST_MEMORY_RESERVE_BYTES
|
|
285
|
+
* (decision 0014 treats those as bounds on the server's values).
|
|
286
|
+
*/
|
|
287
|
+
export declare function hostCapacityLimitDefaults(capacityResourceSample?: HostCapacityResourceSample): RunnerHostDefaults;
|