@loucompanion/forge-bridge 0.1.4-dev.04a1e5b9e484 → 0.1.4-dev.19e5db286f12
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 +3 -3
- package/dist/bridge/bridge.service.d.ts +12 -1
- package/dist/bridge/bridge.service.js +55 -8
- package/dist/bridge/bridge.types.d.ts +6 -0
- package/dist/bridge/dispatch-result-outbox.d.ts +11 -1
- package/dist/bridge/dispatch-result-outbox.js +31 -6
- package/dist/cli/cli.help.js +2 -2
- package/dist/cli/cli.service.js +3 -1
- package/dist/runtime/attempt-process-supervisor.d.ts +19 -0
- package/dist/runtime/attempt-process-supervisor.js +50 -0
- package/dist/runtime/host-database-capability-boundary.d.ts +1 -1
- package/dist/runtime/host-database-capability-boundary.js +1 -0
- package/dist/runtime/host-facts.d.ts +35 -0
- package/dist/runtime/host-facts.js +95 -0
- package/dist/runtime/host-load-admission.d.ts +52 -0
- package/dist/runtime/host-load-admission.js +84 -0
- package/dist/runtime/host-load-forge-cgroups.d.ts +8 -0
- package/dist/runtime/host-load-forge-cgroups.js +51 -0
- package/dist/runtime/host-load-governor-config.d.ts +34 -0
- package/dist/runtime/host-load-governor-config.js +46 -0
- package/dist/runtime/host-load-governor.d.ts +123 -0
- package/dist/runtime/host-load-governor.js +415 -0
- package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
- package/dist/runtime/host-load-ledger-lock.js +185 -0
- package/dist/runtime/host-load-sampler.d.ts +121 -0
- package/dist/runtime/host-load-sampler.js +224 -0
- package/dist/runtime/host-load-step-class.d.ts +33 -0
- package/dist/runtime/host-load-step-class.js +46 -0
- package/dist/runtime/host-load-token-ledger.d.ts +135 -0
- package/dist/runtime/host-load-token-ledger.js +345 -0
- package/dist/runtime/host-pressure-stall.d.ts +61 -0
- package/dist/runtime/host-pressure-stall.js +168 -0
- package/dist/runtime/host-runtime-contract.d.ts +1 -0
- package/dist/runtime/host-runtime-contract.js +2 -0
- package/dist/runtime/host-runtime-lease.d.ts +7 -1
- package/dist/runtime/host-runtime-lease.js +67 -11
- package/dist/runtime/managed-command-teardown.d.ts +62 -0
- package/dist/runtime/managed-command-teardown.js +607 -0
- package/dist/runtime/playwright-browser-cache.d.ts +39 -0
- package/dist/runtime/playwright-browser-cache.js +227 -0
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +11 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +48 -54
- package/dist/session/managed-attempt-tools.d.ts +25 -0
- package/dist/session/managed-attempt-tools.js +212 -15
- package/dist/session/managed-build-coordinator.d.ts +1 -1
- package/dist/session/managed-build-coordinator.js +4 -1
- package/dist/session/phase-completion.artifacts.js +4 -0
- package/dist/session/phase-completion.runtime.js +22 -17
- package/dist/session/pre-publication-host-load.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +96 -0
- package/dist/session/pre-publication-process.d.ts +20 -0
- package/dist/session/pre-publication-process.js +97 -0
- package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
- package/dist/session/pre-publication-skipped-tests.js +109 -0
- package/dist/session/pre-publication-step-execution.d.ts +11 -0
- package/dist/session/pre-publication-step-execution.js +49 -0
- package/dist/session/pre-publication-validation.d.ts +9 -9
- package/dist/session/pre-publication-validation.js +44 -112
- package/dist/session/provider-cli/provider-cli.artifacts.d.ts +2 -1
- package/dist/session/provider-cli/provider-cli.artifacts.js +21 -15
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +37 -1
- package/dist/session/provider-cli/provider-cli.process.js +297 -23
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +5 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +15 -0
- package/dist/session/provider-cli/provider-cli.service.js +126 -26
- package/dist/session/provider-cli/provider-in-flight-work.d.ts +6 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +47 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +6 -0
- package/dist/session/provider-cli/provider-output-state.js +9 -0
- package/dist/session/provider-cli/provider-usage.d.ts +2 -1
- package/dist/session/publishable-worktree-changes.d.ts +54 -0
- package/dist/session/publishable-worktree-changes.js +193 -0
- package/dist/session/session.types.js +13 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/dependency-warmer.js +74 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ Show or change the saved server without editing `bridge.json`:
|
|
|
65
65
|
```bash
|
|
66
66
|
forge-bridge server show
|
|
67
67
|
forge-bridge server set http://localhost:5208
|
|
68
|
-
forge-bridge server set https://
|
|
68
|
+
forge-bridge server set https://forge.example.ts.net:8443
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
`FORGE_URL` overrides the saved server. Changing the saved URL retains runner credentials so aliases for the same deployment keep working; pair again with `--server` when switching to a different Forge deployment.
|
|
@@ -190,9 +190,9 @@ Production shared runners require a Linux rootless Docker daemon. Docker Desktop
|
|
|
190
190
|
|
|
191
191
|
Before selecting `sandbox_required`, save the full approved 40- or 64-character Git commit SHA in the project's Sandbox policy dialog. The server persists that SHA on the immutable attempt and the bridge reads `.forge/forge.sandbox.yml`, `.forge/Dockerfile`, and the tracked build context only from that commit. API-key dispatches carry an opaque one-time grant handle; the authenticated current runner instance redeems it after reservation, and plaintext stays out of offers, database payloads, Docker metadata, and host-persisted control files.
|
|
192
192
|
|
|
193
|
-
Temporary host fallback for `sandbox_preferred` requires both sides to opt in: a project owner must save a reason and future expiry (maximum 30 days), and an operator must enable **Host fallback** for the runner in
|
|
193
|
+
Temporary host fallback for `sandbox_preferred` requires both sides to opt in: a project owner must save a reason and future expiry (maximum 30 days), and an operator must enable **Host fallback** for the runner in Settings › Runners. Either missing or expired authorization fails closed. `sandbox_required` never falls back.
|
|
194
194
|
|
|
195
|
-
The bridge reaps exact-labeled orphan resources before connecting and every minute afterward. Connected passes reconcile current-instance ledgers against an authoritative, instance-scoped server attempt snapshot; startup does not adopt old-instance resources and terminates them before advertising capacity. Per-resource removal outcomes are written mode-0600 under `FORGE_SANDBOX_STATE_ROOT/cleanup-reports` before transmission, replayed after reconnect, acknowledged by report ID, and persisted by the API only when attempt, fence, resource runner instance, and current reporting runner match. Fenced dispatch events also persist image/cache status, build/agent-start/import/teardown timestamps, and a validated inventory of created agent/sidecar containers, networks, volumes, and published ports. Selected-session diagnostics expose that lifecycle data and recent cleanup actions while retaining cleanup-pending state after the agent outcome is terminal. Install `forge-bridge sandbox reap` as an independently supervised OS timer with the same `FORGE_RUNNER_ID`, Docker context, and state root so resources are reconciled while the bridge is down; the Docker-context ownership lock makes an overlapping pass fail safely. A non-zero `degradedReservationCount` means teardown has not completed; the affected capacity remains unavailable until a successful reaper pass. Drain a runner from
|
|
195
|
+
The bridge reaps exact-labeled orphan resources before connecting and every minute afterward. Connected passes reconcile current-instance ledgers against an authoritative, instance-scoped server attempt snapshot; startup does not adopt old-instance resources and terminates them before advertising capacity. Per-resource removal outcomes are written mode-0600 under `FORGE_SANDBOX_STATE_ROOT/cleanup-reports` before transmission, replayed after reconnect, acknowledged by report ID, and persisted by the API only when attempt, fence, resource runner instance, and current reporting runner match. Fenced dispatch events also persist image/cache status, build/agent-start/import/teardown timestamps, and a validated inventory of created agent/sidecar containers, networks, volumes, and published ports. Selected-session diagnostics expose that lifecycle data and recent cleanup actions while retaining cleanup-pending state after the agent outcome is terminal. Install `forge-bridge sandbox reap` as an independently supervised OS timer with the same `FORGE_RUNNER_ID`, Docker context, and state root so resources are reconciled while the bridge is down; the Docker-context ownership lock makes an overlapping pass fail safely. A non-zero `degradedReservationCount` means teardown has not completed; the affected capacity remains unavailable until a successful reaper pass. Drain a runner from Settings › Runners before upgrades or Docker maintenance, wait for active/starting counts to reach zero, then restart the bridge. Settings › Runners also exposes a scoped **Reap** action; the API delivers it only to the currently established protocol-v2 runner instance. Image GC runs only while disk pressure is latched, shares the build lock, preserves active image digests, and prunes only expired images beyond the per-project retention count. Lease renewals are HMAC-bound to the attempt and fence and advance an in-container monotonic deadline; lease, hard-wall, and idle expiry produce distinct failure codes.
|
|
196
196
|
|
|
197
197
|
Every attempt-owned container (including short-lived initialization helpers), network, and volume carries `dev.forge.resource-lease-id` equal to the dispatch execution lease. Ledger schema v2 persists the same `resourceLeaseId`; teardown compares the complete expected label set, and orphan reaping fails closed unless the managed, resource-lease, execution-lease, attempt, runner, runner-instance, and fencing identities are all present and consistent.
|
|
198
198
|
|
|
@@ -7,6 +7,7 @@ import type { SandboxPreflightResult } from "../sandbox/sandbox.types.js";
|
|
|
7
7
|
import { type SandboxRuntime } from "../sandbox/runtime.js";
|
|
8
8
|
import type { BridgeConnection, BridgeConnectionFactory, BridgeService } from "./bridge.base.js";
|
|
9
9
|
import { type RunnerHostCapabilityProbe } from "./runner-host-capabilities.js";
|
|
10
|
+
import { type HostLoadSource } from "../runtime/host-load-sampler.js";
|
|
10
11
|
import type { BridgeCancelHandler, BridgeChatTurnHandler, BridgeDispatchHandler, BridgeLeaseUpdateRequest, BridgeReapRequest, BridgeServiceConfig } from "./bridge.types.js";
|
|
11
12
|
import { type ReadinessResultOutbox } from "./readiness-result-outbox.js";
|
|
12
13
|
import { type DispatchResultOutbox } from "./dispatch-result-outbox.js";
|
|
@@ -29,6 +30,7 @@ export declare class ForgeBridgeService implements BridgeService {
|
|
|
29
30
|
private readonly connections;
|
|
30
31
|
private readonly hostCapabilityProbe;
|
|
31
32
|
private readonly chatProcessRunner;
|
|
33
|
+
private readonly hostLoad;
|
|
32
34
|
private connection;
|
|
33
35
|
private heartbeatTimer;
|
|
34
36
|
private heartbeatInFlight;
|
|
@@ -60,7 +62,7 @@ export declare class ForgeBridgeService implements BridgeService {
|
|
|
60
62
|
private hostCapabilities;
|
|
61
63
|
private readonly recoveredHostAttempts;
|
|
62
64
|
private hostCapabilitiesDetected;
|
|
63
|
-
constructor(config: BridgeServiceConfig, sessions?: SessionService | undefined, connections?: BridgeConnectionFactory, preflight?: DockerPreflight, sandboxRuntime?: SandboxRuntime, sandboxResourceResolver?: SandboxResourceResolver, dockerEngineProbe?: DockerEngineProbe, hostCapabilityProbe?: RunnerHostCapabilityProbe, readinessResultOutbox?: ReadinessResultOutbox, chatProcessRunner?: ProviderProcessRunner, dispatchResultOutbox?: DispatchResultOutbox);
|
|
65
|
+
constructor(config: BridgeServiceConfig, sessions?: SessionService | undefined, connections?: BridgeConnectionFactory, preflight?: DockerPreflight, sandboxRuntime?: SandboxRuntime, sandboxResourceResolver?: SandboxResourceResolver, dockerEngineProbe?: DockerEngineProbe, hostCapabilityProbe?: RunnerHostCapabilityProbe, readinessResultOutbox?: ReadinessResultOutbox, chatProcessRunner?: ProviderProcessRunner, dispatchResultOutbox?: DispatchResultOutbox, hostLoad?: HostLoadSource);
|
|
64
66
|
connectOnce(): Promise<void>;
|
|
65
67
|
private rememberRecoveredHostAttempts;
|
|
66
68
|
private recoveredHostAttemptsForHello;
|
|
@@ -107,6 +109,15 @@ export declare class ForgeBridgeService implements BridgeService {
|
|
|
107
109
|
private sendResultPayloadDirect;
|
|
108
110
|
private flushDispatchResults;
|
|
109
111
|
private flushDispatchResultsCore;
|
|
112
|
+
/**
|
|
113
|
+
* Forge binds each result to the runner instance that ran the attempt. On an
|
|
114
|
+
* authoritative connection it rejects another instance's result with
|
|
115
|
+
* bridge.stale_result_instance; Forge's own recovery handles that attempt,
|
|
116
|
+
* so the record can never be delivered and must not block the replay queue.
|
|
117
|
+
* bridge.stale_runner_instance means this connection is not authoritative
|
|
118
|
+
* and says nothing about the record, so it never quarantines.
|
|
119
|
+
*/
|
|
120
|
+
private isReplacedRunnerInstanceResult;
|
|
110
121
|
private startHeartbeat;
|
|
111
122
|
private heartbeatTick;
|
|
112
123
|
private startLeaseWatchdog;
|
|
@@ -33,8 +33,9 @@ import { codexSandboxProviderAuthAdapter, sandboxProviderAuthAdapterFor, sandbox
|
|
|
33
33
|
import { assertBridgeChatCallbackPayload, bridgeChatMaxProviderThreadIdChars, bridgeChatProtocolVersion, isTerminalChatTurnCallbackKind, parseChatTurnDispatchPacket, } from "./bridge-chat.types.js";
|
|
34
34
|
import { formatBytes } from "../shared/format/format-bytes.js";
|
|
35
35
|
import { emptyRunnerHostCapabilitySnapshot, ProcessRunnerHostCapabilityProbe, } from "./runner-host-capabilities.js";
|
|
36
|
+
import { HostLoadSampler } from "../runtime/host-load-sampler.js";
|
|
36
37
|
import { FileReadinessResultOutbox } from "./readiness-result-outbox.js";
|
|
37
|
-
import { FileDispatchResultOutbox } from "./dispatch-result-outbox.js";
|
|
38
|
+
import { dispatchResultQuarantineDirectory, FileDispatchResultOutbox } from "./dispatch-result-outbox.js";
|
|
38
39
|
/**
|
|
39
40
|
* Protocol-v2 events are acknowledged one at a time before runOnce returns.
|
|
40
41
|
* Sending the complete transcript again in DispatchResult made long QA and CI
|
|
@@ -53,6 +54,7 @@ export class ForgeBridgeService {
|
|
|
53
54
|
connections;
|
|
54
55
|
hostCapabilityProbe;
|
|
55
56
|
chatProcessRunner;
|
|
57
|
+
hostLoad;
|
|
56
58
|
connection = null;
|
|
57
59
|
heartbeatTimer = null;
|
|
58
60
|
heartbeatInFlight = false;
|
|
@@ -87,11 +89,12 @@ export class ForgeBridgeService {
|
|
|
87
89
|
// leaves those attempts on Forge's conservative unknown-outcome path.
|
|
88
90
|
recoveredHostAttempts = new Map();
|
|
89
91
|
hostCapabilitiesDetected = false;
|
|
90
|
-
constructor(config, sessions = undefined, connections = new SignalRBridgeConnectionFactory(), preflight, sandboxRuntime, sandboxResourceResolver, dockerEngineProbe, hostCapabilityProbe = new ProcessRunnerHostCapabilityProbe(), readinessResultOutbox, chatProcessRunner = new StreamingProviderProcessRunner(), dispatchResultOutbox) {
|
|
92
|
+
constructor(config, sessions = undefined, connections = new SignalRBridgeConnectionFactory(), preflight, sandboxRuntime, sandboxResourceResolver, dockerEngineProbe, hostCapabilityProbe = new ProcessRunnerHostCapabilityProbe(), readinessResultOutbox, chatProcessRunner = new StreamingProviderProcessRunner(), dispatchResultOutbox, hostLoad = new HostLoadSampler()) {
|
|
91
93
|
this.config = config;
|
|
92
94
|
this.connections = connections;
|
|
93
95
|
this.hostCapabilityProbe = hostCapabilityProbe;
|
|
94
96
|
this.chatProcessRunner = chatProcessRunner;
|
|
97
|
+
this.hostLoad = hostLoad;
|
|
95
98
|
this.enforceHostDatabaseCapabilityBoundary = sessions === undefined;
|
|
96
99
|
if (this.enforceHostDatabaseCapabilityBoundary) {
|
|
97
100
|
establishHostDatabaseCapabilityBoundary();
|
|
@@ -123,7 +126,7 @@ export class ForgeBridgeService {
|
|
|
123
126
|
},
|
|
124
127
|
onStatus: logBridgeStatus,
|
|
125
128
|
});
|
|
126
|
-
this.sessions = sessions ?? createDefaultSessionService(config.sandboxStateRoot, config.sandboxExecutionRoot, this.dockerEngineProbe);
|
|
129
|
+
this.sessions = sessions ?? createDefaultSessionService(config.sandboxStateRoot, config.sandboxExecutionRoot, this.dockerEngineProbe, hostLoad);
|
|
127
130
|
this.sandboxRuntime = sandboxRuntime ?? new DockerSandboxRuntime(config, (request, signal) => this.redeemPublishGrant(request, signal));
|
|
128
131
|
this.sandboxResourceResolver = sandboxResourceResolver
|
|
129
132
|
?? (dispatch => resolveSandboxResourcesFromRepo(dispatch, this.config.sandboxRuntimeOverheadBytes));
|
|
@@ -156,6 +159,9 @@ export class ForgeBridgeService {
|
|
|
156
159
|
this.hostCapabilities = await this.hostCapabilityProbe.detect(this.config);
|
|
157
160
|
this.hostCapabilitiesDetected = true;
|
|
158
161
|
}
|
|
162
|
+
// Static host facts and the first load sample ride on Hello; the sampler
|
|
163
|
+
// keeps refreshing its cached snapshot for later heartbeats.
|
|
164
|
+
await this.hostLoad.start().catch(() => undefined);
|
|
159
165
|
const connection = this.connections.create(this.config);
|
|
160
166
|
this.connection = connection;
|
|
161
167
|
this.transportRecovery = null;
|
|
@@ -306,6 +312,7 @@ export class ForgeBridgeService {
|
|
|
306
312
|
this.abortActiveSessions("bridge stopping");
|
|
307
313
|
this.abortActiveReadinessProbes("bridge stopping");
|
|
308
314
|
await this.stopConnection();
|
|
315
|
+
this.hostLoad.stop();
|
|
309
316
|
await this.preflight.release();
|
|
310
317
|
}
|
|
311
318
|
async handleChatTurn(rawDispatch) {
|
|
@@ -1468,6 +1475,19 @@ export class ForgeBridgeService {
|
|
|
1468
1475
|
await this.dispatchResultOutbox.acknowledge(pending.payload.leaseId);
|
|
1469
1476
|
continue;
|
|
1470
1477
|
}
|
|
1478
|
+
if (this.isReplacedRunnerInstanceResult(pending.payload, error)) {
|
|
1479
|
+
try {
|
|
1480
|
+
await this.dispatchResultOutbox.quarantine(pending);
|
|
1481
|
+
}
|
|
1482
|
+
catch (quarantineError) {
|
|
1483
|
+
// Keep the record and surface Forge's rejection: replay stays
|
|
1484
|
+
// deferred and a heartbeat tick does not count it as a failure.
|
|
1485
|
+
logBridgeStatus(`Dispatch result ${pending.payload.leaseId} from replaced runner instance ${pending.payload.runnerInstanceId} could not be quarantined: ${errorMessage(quarantineError)}`);
|
|
1486
|
+
throw error;
|
|
1487
|
+
}
|
|
1488
|
+
logBridgeStatus(`Quarantined dispatch result ${pending.payload.leaseId}: Forge rejected it because it belongs to replaced runner instance ${pending.payload.runnerInstanceId}. Forge's own recovery handles that instance's attempt; the redacted result is kept in ${dispatchResultQuarantineDirectory} for reconciliation.`);
|
|
1489
|
+
continue;
|
|
1490
|
+
}
|
|
1471
1491
|
throw error;
|
|
1472
1492
|
}
|
|
1473
1493
|
}
|
|
@@ -1478,6 +1498,20 @@ export class ForgeBridgeService {
|
|
|
1478
1498
|
this.dispatchResultFlushedGeneration = startedGeneration;
|
|
1479
1499
|
}
|
|
1480
1500
|
}
|
|
1501
|
+
/**
|
|
1502
|
+
* Forge binds each result to the runner instance that ran the attempt. On an
|
|
1503
|
+
* authoritative connection it rejects another instance's result with
|
|
1504
|
+
* bridge.stale_result_instance; Forge's own recovery handles that attempt,
|
|
1505
|
+
* so the record can never be delivered and must not block the replay queue.
|
|
1506
|
+
* bridge.stale_runner_instance means this connection is not authoritative
|
|
1507
|
+
* and says nothing about the record, so it never quarantines.
|
|
1508
|
+
*/
|
|
1509
|
+
isReplacedRunnerInstanceResult(payload, error) {
|
|
1510
|
+
return error instanceof BridgeCallbackRejectedError
|
|
1511
|
+
&& error.code === "bridge.stale_result_instance"
|
|
1512
|
+
&& typeof payload.runnerInstanceId === "string"
|
|
1513
|
+
&& payload.runnerInstanceId.toLowerCase() !== this.config.runnerInstanceId.toLowerCase();
|
|
1514
|
+
}
|
|
1481
1515
|
startHeartbeat() {
|
|
1482
1516
|
this.stopHeartbeat();
|
|
1483
1517
|
this.consecutiveHeartbeatFailures = 0;
|
|
@@ -1496,8 +1530,11 @@ export class ForgeBridgeService {
|
|
|
1496
1530
|
return;
|
|
1497
1531
|
this.heartbeatInFlight = true;
|
|
1498
1532
|
try {
|
|
1499
|
-
|
|
1500
|
-
|
|
1533
|
+
// A rejected replay is an answer from Forge, so the connection is alive:
|
|
1534
|
+
// an undeliverable record must not count as a heartbeat failure and
|
|
1535
|
+
// force reconnects. Transport failures still do.
|
|
1536
|
+
await this.flushDispatchResults().catch(deferRejectedReplay("Dispatch"));
|
|
1537
|
+
await this.flushReadinessResults().catch(deferRejectedReplay("Readiness"));
|
|
1501
1538
|
await this.sendHeartbeat();
|
|
1502
1539
|
this.consecutiveHeartbeatFailures = 0;
|
|
1503
1540
|
}
|
|
@@ -1656,7 +1693,7 @@ export class ForgeBridgeService {
|
|
|
1656
1693
|
pendingCommitmentMemoryBytes: Math.max(0, used.memoryBytes - activeResources.memoryBytes),
|
|
1657
1694
|
}) : null;
|
|
1658
1695
|
return {
|
|
1659
|
-
schemaVersion:
|
|
1696
|
+
schemaVersion: 7,
|
|
1660
1697
|
activeSessionCount: this.activeSessions.size,
|
|
1661
1698
|
cliProviders: this.config.cliProviders,
|
|
1662
1699
|
providerStatuses: this.config.providerStatuses,
|
|
@@ -1679,6 +1716,8 @@ export class ForgeBridgeService {
|
|
|
1679
1716
|
playwrightProjects: this.hostCapabilities.playwrightProjects,
|
|
1680
1717
|
browserLaunch: this.hostCapabilities.browserLaunch,
|
|
1681
1718
|
providerConnectivity: this.hostCapabilities.providerConnectivity,
|
|
1719
|
+
host: this.hostLoad.facts(),
|
|
1720
|
+
load: this.hostLoad.current(),
|
|
1682
1721
|
maxConcurrentSandboxes: capacity.sandboxSlots,
|
|
1683
1722
|
reservedSandboxCount: reserved,
|
|
1684
1723
|
activeSandboxCount: runtimeState.active,
|
|
@@ -1880,6 +1919,13 @@ class BridgeCallbackRejectedError extends Error {
|
|
|
1880
1919
|
this.name = "BridgeCallbackRejectedError";
|
|
1881
1920
|
}
|
|
1882
1921
|
}
|
|
1922
|
+
function deferRejectedReplay(kind) {
|
|
1923
|
+
return error => {
|
|
1924
|
+
if (!(error instanceof BridgeCallbackRejectedError))
|
|
1925
|
+
throw error;
|
|
1926
|
+
logBridgeStatus(`${kind} result replay deferred: ${errorMessage(error)}`);
|
|
1927
|
+
};
|
|
1928
|
+
}
|
|
1883
1929
|
function isDispatchNoLongerPending(error) {
|
|
1884
1930
|
if (error instanceof BridgeCallbackRejectedError) {
|
|
1885
1931
|
return error.code === "bridge.dispatch_not_pending" || error.code === "bridge.stale_dispatch";
|
|
@@ -1898,11 +1944,12 @@ function isProviderStorageUnavailable(error) {
|
|
|
1898
1944
|
function isBridgeCallbackTimeout(error) {
|
|
1899
1945
|
return errorMessage(error).startsWith("bridge_callback_timeout:");
|
|
1900
1946
|
}
|
|
1901
|
-
function createDefaultSessionService(sandboxStateRoot, sandboxExecutionRoot, dockerEngineProbe) {
|
|
1947
|
+
function createDefaultSessionService(sandboxStateRoot, sandboxExecutionRoot, dockerEngineProbe, hostLoad) {
|
|
1902
1948
|
const rawProcessRunner = new StreamingProviderProcessRunner();
|
|
1903
1949
|
const processSupervisors = new AttemptProcessSupervisorRegistry();
|
|
1904
1950
|
const coordinatedProcessRunner = new AttemptCoordinatedProviderProcessRunner(processSupervisors, rawProcessRunner);
|
|
1905
|
-
|
|
1951
|
+
const hostRuntime = new HostRuntimeLeaseManager(sandboxStateRoot, undefined, undefined, processSupervisors, rawProcessRunner, undefined, undefined, undefined, undefined, undefined, sandboxExecutionRoot, createNativeTestClusterDatabaseBroker(readNativeTestPostgresFallback, sandboxStateRoot), hostLoad);
|
|
1952
|
+
return new BridgeSessionService(new GitWorktreeService(undefined, new RepositoryCoordinatorLock(sandboxStateRoot)), new RoutingProviderCliService(new ProcessBackedProviderCliService(coordinatedProcessRunner, undefined, undefined, undefined, new PrePublicationValidator(undefined, dockerEngineProbe, readNativeTestPostgresFallback, hostRuntime.hostLoadGovernor))), hostRuntime);
|
|
1906
1953
|
}
|
|
1907
1954
|
export class SignalRBridgeConnectionFactory {
|
|
1908
1955
|
create(config) {
|
|
@@ -3,6 +3,8 @@ import type { SandboxFeatureMatrix } from "../sandbox/sandbox.types.js";
|
|
|
3
3
|
import type { HostRuntimeCapacitySnapshot } from "../runtime/host-runtime-lease.js";
|
|
4
4
|
import type { MemoryAdmissionDiagnostics } from "../runtime/memory-capacity.js";
|
|
5
5
|
import type { DockerEngineCapabilitySnapshot } from "../runtime/docker-engine-probe.js";
|
|
6
|
+
import type { HostFacts } from "../runtime/host-facts.js";
|
|
7
|
+
import type { HostLoadSnapshot } from "../runtime/host-load-sampler.js";
|
|
6
8
|
import type { BridgeChatCapability, ChatTurnCancelPacket } from "./bridge-chat.types.js";
|
|
7
9
|
export interface BridgeServiceConfig {
|
|
8
10
|
readonly serverUrl: string;
|
|
@@ -142,6 +144,10 @@ export interface BridgeCapabilities {
|
|
|
142
144
|
readonly playwrightProjects?: readonly string[] | null;
|
|
143
145
|
readonly browserLaunch?: boolean | null;
|
|
144
146
|
readonly providerConnectivity?: Readonly<Record<string, boolean>> | null;
|
|
147
|
+
/** Static host hardware facts (schema 7). Material: changes are persisted immediately. */
|
|
148
|
+
readonly host?: HostFacts | null;
|
|
149
|
+
/** Live host load sample (schema 7). Never material: heartbeats with only load changes are not persisted. */
|
|
150
|
+
readonly load?: HostLoadSnapshot | null;
|
|
145
151
|
}
|
|
146
152
|
export interface SandboxMemoryCapacityDiagnostics {
|
|
147
153
|
readonly defaultWorkerMemoryLimitBytes: number;
|
|
@@ -8,7 +8,14 @@ export interface DispatchResultOutbox {
|
|
|
8
8
|
persist(payload: BridgeDispatchResultCallback): Promise<void>;
|
|
9
9
|
pending(): Promise<readonly DurableDispatchResult[]>;
|
|
10
10
|
acknowledge(leaseId: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Moves an undeliverable record out of the replay set. The redacted result
|
|
13
|
+
* is kept, with its original persistedAt, so preserved work can be reconciled.
|
|
14
|
+
*/
|
|
15
|
+
quarantine(record: DurableDispatchResult): Promise<void>;
|
|
11
16
|
}
|
|
17
|
+
export declare const dispatchResultOutboxDirectory = "dispatch-results";
|
|
18
|
+
export declare const dispatchResultQuarantineDirectory = "dispatch-results-quarantine";
|
|
12
19
|
/**
|
|
13
20
|
* Persists the already-redacted terminal result before the Bridge attempts its
|
|
14
21
|
* SignalR callback. A transport or API restart can therefore delay delivery,
|
|
@@ -16,10 +23,13 @@ export interface DispatchResultOutbox {
|
|
|
16
23
|
*/
|
|
17
24
|
export declare class FileDispatchResultOutbox implements DispatchResultOutbox {
|
|
18
25
|
private readonly stateRoot;
|
|
26
|
+
private readonly directory;
|
|
19
27
|
private readonly writes;
|
|
20
|
-
constructor(stateRoot: string);
|
|
28
|
+
constructor(stateRoot: string, directory?: string);
|
|
21
29
|
persist(payload: BridgeDispatchResultCallback): Promise<void>;
|
|
30
|
+
private persistRecord;
|
|
22
31
|
pending(): Promise<readonly DurableDispatchResult[]>;
|
|
23
32
|
acknowledge(leaseId: string): Promise<void>;
|
|
33
|
+
quarantine(record: DurableDispatchResult): Promise<void>;
|
|
24
34
|
private operate;
|
|
25
35
|
}
|
|
@@ -3,6 +3,8 @@ import { isDeepStrictEqual } from "node:util";
|
|
|
3
3
|
import { assertCanonicalDirectory, createCanonicalDirectory } from "../runtime/attempt-private-directory.js";
|
|
4
4
|
import { runPinnedDirectoryProcess } from "../runtime/pinned-directory-process.js";
|
|
5
5
|
import { dispatchResultReceiptWorker } from "./dispatch-result-worker.js";
|
|
6
|
+
export const dispatchResultOutboxDirectory = "dispatch-results";
|
|
7
|
+
export const dispatchResultQuarantineDirectory = "dispatch-results-quarantine";
|
|
6
8
|
/**
|
|
7
9
|
* Persists the already-redacted terminal result before the Bridge attempts its
|
|
8
10
|
* SignalR callback. A transport or API restart can therefore delay delivery,
|
|
@@ -10,11 +12,16 @@ import { dispatchResultReceiptWorker } from "./dispatch-result-worker.js";
|
|
|
10
12
|
*/
|
|
11
13
|
export class FileDispatchResultOutbox {
|
|
12
14
|
stateRoot;
|
|
15
|
+
directory;
|
|
13
16
|
writes = new Map();
|
|
14
|
-
constructor(stateRoot) {
|
|
17
|
+
constructor(stateRoot, directory = dispatchResultOutboxDirectory) {
|
|
15
18
|
this.stateRoot = stateRoot;
|
|
19
|
+
this.directory = directory;
|
|
16
20
|
}
|
|
17
21
|
async persist(payload) {
|
|
22
|
+
await this.persistRecord(payload, new Date().toISOString());
|
|
23
|
+
}
|
|
24
|
+
async persistRecord(payload, persistedAt) {
|
|
18
25
|
const name = recordName(payload.leaseId);
|
|
19
26
|
const value = JSON.parse(JSON.stringify({ payload }));
|
|
20
27
|
const pending = this.writes.get(name);
|
|
@@ -27,7 +34,7 @@ export class FileDispatchResultOutbox {
|
|
|
27
34
|
const write = this.operate({
|
|
28
35
|
kind: "persist",
|
|
29
36
|
name,
|
|
30
|
-
record: { schemaVersion: 1, persistedAt
|
|
37
|
+
record: { schemaVersion: 1, persistedAt, ...value },
|
|
31
38
|
}).then(() => undefined);
|
|
32
39
|
this.writes.set(name, { value, write });
|
|
33
40
|
try {
|
|
@@ -44,8 +51,23 @@ export class FileDispatchResultOutbox {
|
|
|
44
51
|
async acknowledge(leaseId) {
|
|
45
52
|
await this.operate({ kind: "acknowledge", name: recordName(leaseId) });
|
|
46
53
|
}
|
|
54
|
+
async quarantine(record) {
|
|
55
|
+
// One execution lease can carry several dispatch attempts, so quarantine
|
|
56
|
+
// files are grouped per attempt: <quarantine>/<attempt>/<lease>.json.
|
|
57
|
+
// Copy before removal: a crash in between leaves an identical record in
|
|
58
|
+
// both places, and the next replay quarantines it again idempotently.
|
|
59
|
+
// A record without an attempt id has no per-attempt bucket; the caller
|
|
60
|
+
// keeps it deferred rather than grouping unrelated attempts together.
|
|
61
|
+
const { payload } = record;
|
|
62
|
+
if (!payload.dispatchAttemptId) {
|
|
63
|
+
throw new Error("dispatch_result_invalid: only attempt-bound results can be quarantined.");
|
|
64
|
+
}
|
|
65
|
+
const bucket = path.join(dispatchResultQuarantineDirectory, compactUuid(payload.dispatchAttemptId));
|
|
66
|
+
await new FileDispatchResultOutbox(this.stateRoot, bucket).persistRecord(payload, record.persistedAt);
|
|
67
|
+
await this.acknowledge(payload.leaseId);
|
|
68
|
+
}
|
|
47
69
|
async operate(operation) {
|
|
48
|
-
const root = path.resolve(this.stateRoot,
|
|
70
|
+
const root = path.resolve(this.stateRoot, this.directory);
|
|
49
71
|
await createCanonicalDirectory(root);
|
|
50
72
|
const identity = await assertCanonicalDirectory(root);
|
|
51
73
|
if (!identity)
|
|
@@ -54,9 +76,12 @@ export class FileDispatchResultOutbox {
|
|
|
54
76
|
}
|
|
55
77
|
}
|
|
56
78
|
function recordName(leaseId) {
|
|
57
|
-
|
|
79
|
+
return `${compactUuid(leaseId)}.json`;
|
|
80
|
+
}
|
|
81
|
+
function compactUuid(id) {
|
|
82
|
+
const value = id.replaceAll("-", "").toLowerCase();
|
|
58
83
|
if (!/^[0-9a-f]{32}$/u.test(value)) {
|
|
59
|
-
throw new Error("dispatch_result_invalid:
|
|
84
|
+
throw new Error("dispatch_result_invalid: identifiers must be UUIDs.");
|
|
60
85
|
}
|
|
61
|
-
return
|
|
86
|
+
return value;
|
|
62
87
|
}
|
package/dist/cli/cli.help.js
CHANGED
|
@@ -28,7 +28,7 @@ export function helpText() {
|
|
|
28
28
|
"",
|
|
29
29
|
"Examples:",
|
|
30
30
|
" npm install -g @loucompanion/forge-bridge@next",
|
|
31
|
-
" forge-bridge pair 1234-5678 --server https://
|
|
31
|
+
" forge-bridge pair 1234-5678 --server https://forge.example.ts.net:8443 --repo-root \"%USERPROFILE%\\ForgeRepos\"",
|
|
32
32
|
" forge-bridge connect",
|
|
33
33
|
" forge-bridge status --check-updates",
|
|
34
34
|
" forge-bridge server set http://localhost:5208",
|
|
@@ -116,7 +116,7 @@ export function commandHelpText(command) {
|
|
|
116
116
|
"",
|
|
117
117
|
"Examples:",
|
|
118
118
|
" forge-bridge server set http://localhost:5208",
|
|
119
|
-
" forge-bridge server set https://
|
|
119
|
+
" forge-bridge server set https://forge.example.ts.net:8443",
|
|
120
120
|
"",
|
|
121
121
|
].join("\n");
|
|
122
122
|
case "add-repo":
|
package/dist/cli/cli.service.js
CHANGED
|
@@ -30,7 +30,9 @@ export class ForgeBridgeCliService {
|
|
|
30
30
|
pairRunner;
|
|
31
31
|
cleanupFactory;
|
|
32
32
|
dotNetToolchainConfigurator;
|
|
33
|
-
constructor(
|
|
33
|
+
constructor(
|
|
34
|
+
// The default session chain validates without the host load governor (Docker-mode gap, decision 0013).
|
|
35
|
+
sessions = new BridgeSessionService(), bridgeFactory = (config) => new ForgeBridgeService(config), pairRunner = claimBridgeRunner, cleanupFactory = stateRoot => new ManagedWorktreeCleanupService(stateRoot), dotNetToolchainConfigurator = configureDotNetToolchain) {
|
|
34
36
|
this.sessions = sessions;
|
|
35
37
|
this.bridgeFactory = bridgeFactory;
|
|
36
38
|
this.pairRunner = pairRunner;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ProviderProcessHandlers, ProviderProcessRunRequest, ProviderProcessRunner, ProviderProcessRunResult } from "../session/provider-cli/provider-cli.process.js";
|
|
2
|
+
import { type ManagedCommandTeardownOptions, type ManagedCommandTeardownOutcome } from "./managed-command-teardown.js";
|
|
2
3
|
export type AttemptProcessChildStatus = "starting" | "running" | "stopping" | "exited" | "failed";
|
|
3
4
|
export type AttemptProcessSupervisorStatus = "active" | "stopping" | "stopped" | "degraded";
|
|
4
5
|
export interface AttemptProcessSupervisorIdentity {
|
|
@@ -32,6 +33,8 @@ export interface AttemptProcessSupervisorLedger {
|
|
|
32
33
|
readonly status: AttemptProcessSupervisorStatus;
|
|
33
34
|
readonly updatedAt: string;
|
|
34
35
|
readonly children: readonly AttemptProcessChildLedgerEntry[];
|
|
36
|
+
/** A provider-exit managed-command cleanup that failed and was left to attempt teardown. */
|
|
37
|
+
readonly deferredManagedCommandTeardownFailure?: string;
|
|
35
38
|
}
|
|
36
39
|
export interface AttemptProcessChildHandle {
|
|
37
40
|
readonly name: string;
|
|
@@ -48,6 +51,7 @@ export interface AttemptProcessSupervisorOptions {
|
|
|
48
51
|
readonly signal?: AbortSignal;
|
|
49
52
|
readonly replaceLedgerFile?: (temporaryPath: string, ledgerPath: string) => Promise<void>;
|
|
50
53
|
readonly ledgerReplaceRetryMs?: number;
|
|
54
|
+
readonly managedCommandTeardownGraceMs?: number;
|
|
51
55
|
}
|
|
52
56
|
export interface AttemptProcessChildReadyOptions {
|
|
53
57
|
readonly maxStartAttempts?: number;
|
|
@@ -66,6 +70,7 @@ export declare class AttemptProcessSupervisor {
|
|
|
66
70
|
private readonly metadataReadyTimeoutMs;
|
|
67
71
|
private readonly replaceLedgerFile;
|
|
68
72
|
private readonly ledgerReplaceRetryMs;
|
|
73
|
+
private readonly managedCommandTeardownGraceMs;
|
|
69
74
|
private readonly records;
|
|
70
75
|
private readonly currentByName;
|
|
71
76
|
private readonly attemptController;
|
|
@@ -73,6 +78,8 @@ export declare class AttemptProcessSupervisor {
|
|
|
73
78
|
private persistTail;
|
|
74
79
|
private persistenceFailure;
|
|
75
80
|
private stopOperation;
|
|
81
|
+
private managedCommandTeardownTail;
|
|
82
|
+
private deferredManagedCommandTeardownFailure;
|
|
76
83
|
constructor(identity: AttemptProcessSupervisorIdentity, runner: ProviderProcessRunner, options?: AttemptProcessSupervisorOptions);
|
|
77
84
|
startChild(name: string, request: ProviderProcessRunRequest, handlers?: ProviderProcessHandlers, signal?: AbortSignal): Promise<AttemptProcessChildHandle>;
|
|
78
85
|
/**
|
|
@@ -86,6 +93,18 @@ export declare class AttemptProcessSupervisor {
|
|
|
86
93
|
stopChild(name: string, generation: number, fencingToken: string, reason?: unknown): Promise<ProviderProcessRunResult>;
|
|
87
94
|
stopAll(fencingToken: string, reason?: unknown): Promise<void>;
|
|
88
95
|
private performStopAll;
|
|
96
|
+
/**
|
|
97
|
+
* Stops the managed commands this attempt's MCP servers started and finalizes their
|
|
98
|
+
* receipts. With `onlyOrphaned`, a command whose owning MCP server is still alive is
|
|
99
|
+
* left running: it survives wait slices and MCP call boundaries within a live provider.
|
|
100
|
+
*/
|
|
101
|
+
terminateManagedCommands(options: Omit<ManagedCommandTeardownOptions, "graceMs">): Promise<readonly ManagedCommandTeardownOutcome[]>;
|
|
102
|
+
/**
|
|
103
|
+
* After a provider exits, stops the managed commands its MCP server left behind. It never
|
|
104
|
+
* fails the provider's result: a command it cannot prove stopped is recorded in the ledger
|
|
105
|
+
* and left to attempt teardown, which fails closed.
|
|
106
|
+
*/
|
|
107
|
+
stopOrphanedManagedCommands(): Promise<void>;
|
|
89
108
|
snapshot(): AttemptProcessSupervisorLedger;
|
|
90
109
|
providerMemoryTelemetry(): AttemptProcessTreeMemoryTelemetry | null;
|
|
91
110
|
private observeChildReady;
|
|
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { ForgeFailureError, sanitizeFailureError } from "../session/session.types.js";
|
|
5
|
+
import { terminateAttemptManagedCommands, } from "./managed-command-teardown.js";
|
|
5
6
|
import { monotonicNowMs } from "../shared/time/monotonic.js";
|
|
6
7
|
const terminalChildStatuses = new Set(["exited", "failed"]);
|
|
7
8
|
const defaultMetadataReadyTimeoutMs = process.platform === "win32" ? 60_000 : 10_000;
|
|
@@ -23,6 +24,7 @@ export class AttemptProcessSupervisor {
|
|
|
23
24
|
metadataReadyTimeoutMs;
|
|
24
25
|
replaceLedgerFile;
|
|
25
26
|
ledgerReplaceRetryMs;
|
|
27
|
+
managedCommandTeardownGraceMs;
|
|
26
28
|
records = [];
|
|
27
29
|
currentByName = new Map();
|
|
28
30
|
attemptController = new AbortController();
|
|
@@ -30,12 +32,15 @@ export class AttemptProcessSupervisor {
|
|
|
30
32
|
persistTail = Promise.resolve();
|
|
31
33
|
persistenceFailure;
|
|
32
34
|
stopOperation = null;
|
|
35
|
+
managedCommandTeardownTail = Promise.resolve();
|
|
36
|
+
deferredManagedCommandTeardownFailure;
|
|
33
37
|
constructor(identity, runner, options = {}) {
|
|
34
38
|
this.runner = runner;
|
|
35
39
|
this.identity = validateIdentity(identity);
|
|
36
40
|
this.metadataReadyTimeoutMs = boundedInteger(options.metadataReadyTimeoutMs ?? defaultMetadataReadyTimeoutMs, 100, 120_000, "metadataReadyTimeoutMs");
|
|
37
41
|
this.replaceLedgerFile = options.replaceLedgerFile ?? ((temporaryPath, ledgerPath) => fs.rename(temporaryPath, ledgerPath));
|
|
38
42
|
this.ledgerReplaceRetryMs = options.ledgerReplaceRetryMs ?? defaultLedgerReplaceRetryMs;
|
|
43
|
+
this.managedCommandTeardownGraceMs = options.managedCommandTeardownGraceMs;
|
|
39
44
|
this.ledgerPath = path.join(this.identity.logDirectory, "attempt-process-supervisor.json");
|
|
40
45
|
if (options.signal?.aborted) {
|
|
41
46
|
this.status = "stopping";
|
|
@@ -199,6 +204,14 @@ export class AttemptProcessSupervisor {
|
|
|
199
204
|
const rejected = results.flatMap((result, index) => result.status === "rejected"
|
|
200
205
|
? [sanitizeFailureError(result.reason, active[index].failureRedactionValues)]
|
|
201
206
|
: []);
|
|
207
|
+
// Managed commands run in their own process groups, outside every child tree stopped
|
|
208
|
+
// above. The attempt is not stopped until each of them is proven stopped too.
|
|
209
|
+
try {
|
|
210
|
+
await this.terminateManagedCommands({ reason: "attempt_teardown" });
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
rejected.push(error instanceof Error ? error : new Error(String(error)));
|
|
214
|
+
}
|
|
202
215
|
const terminalStatus = rejected.length > 0 || this.persistenceFailure !== undefined ? "degraded" : "stopped";
|
|
203
216
|
await this.persist({
|
|
204
217
|
...this.snapshot(),
|
|
@@ -212,6 +225,40 @@ export class AttemptProcessSupervisor {
|
|
|
212
225
|
if (this.persistenceFailure !== undefined)
|
|
213
226
|
throw this.persistenceFailure;
|
|
214
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Stops the managed commands this attempt's MCP servers started and finalizes their
|
|
230
|
+
* receipts. With `onlyOrphaned`, a command whose owning MCP server is still alive is
|
|
231
|
+
* left running: it survives wait slices and MCP call boundaries within a live provider.
|
|
232
|
+
*/
|
|
233
|
+
async terminateManagedCommands(options) {
|
|
234
|
+
// One sweep at a time: a provider-exit sweep and attempt teardown would otherwise
|
|
235
|
+
// signal the same groups and write the same receipts concurrently, and stopAll must
|
|
236
|
+
// not report the attempt stopped while an earlier sweep is still writing.
|
|
237
|
+
const sweep = this.managedCommandTeardownTail.then(async () => await terminateAttemptManagedCommands({
|
|
238
|
+
logDirectory: this.identity.logDirectory,
|
|
239
|
+
dispatchAttemptId: this.identity.dispatchAttemptId,
|
|
240
|
+
runtimeLeaseId: this.identity.executionLeaseId,
|
|
241
|
+
}, {
|
|
242
|
+
...options,
|
|
243
|
+
...(this.managedCommandTeardownGraceMs === undefined ? {} : { graceMs: this.managedCommandTeardownGraceMs }),
|
|
244
|
+
}));
|
|
245
|
+
this.managedCommandTeardownTail = sweep.catch(() => undefined);
|
|
246
|
+
return await sweep;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* After a provider exits, stops the managed commands its MCP server left behind. It never
|
|
250
|
+
* fails the provider's result: a command it cannot prove stopped is recorded in the ledger
|
|
251
|
+
* and left to attempt teardown, which fails closed.
|
|
252
|
+
*/
|
|
253
|
+
async stopOrphanedManagedCommands() {
|
|
254
|
+
try {
|
|
255
|
+
await this.terminateManagedCommands({ reason: "owner_exited", onlyOrphaned: true });
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
this.deferredManagedCommandTeardownFailure = boundedFailure(error, []);
|
|
259
|
+
await this.persist().catch(() => undefined);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
215
262
|
snapshot() {
|
|
216
263
|
return {
|
|
217
264
|
schemaVersion: 1,
|
|
@@ -220,6 +267,9 @@ export class AttemptProcessSupervisor {
|
|
|
220
267
|
executionLeaseId: this.identity.executionLeaseId,
|
|
221
268
|
status: this.status,
|
|
222
269
|
updatedAt: new Date().toISOString(),
|
|
270
|
+
...(this.deferredManagedCommandTeardownFailure
|
|
271
|
+
? { deferredManagedCommandTeardownFailure: this.deferredManagedCommandTeardownFailure }
|
|
272
|
+
: {}),
|
|
223
273
|
children: this.records.map(record => ({
|
|
224
274
|
name: record.name,
|
|
225
275
|
generation: record.generation,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const hostDatabaseCapabilityEnvironmentNames: readonly ["FORGE_TEST_POSTGRES_ADMIN_CONNECTION_STRING", "FORGE_TEST_POSTGRES_CONNECTION_STRING"];
|
|
1
|
+
export declare const hostDatabaseCapabilityEnvironmentNames: readonly ["FORGE_TEST_POSTGRES_ADMIN_CONNECTION_STRING", "FORGE_TEST_POSTGRES_CONNECTION_STRING", "FORGE_TEST_POSTGRES_PROVISIONER_CONNECTION_STRING"];
|
|
2
2
|
export interface HostDatabaseCapabilityBoundaryOptions {
|
|
3
3
|
readonly platform?: NodeJS.Platform;
|
|
4
4
|
readonly processEnvironment?: NodeJS.ProcessEnv;
|
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
export const hostDatabaseCapabilityEnvironmentNames = [
|
|
4
4
|
"FORGE_TEST_POSTGRES_ADMIN_CONNECTION_STRING",
|
|
5
5
|
"FORGE_TEST_POSTGRES_CONNECTION_STRING",
|
|
6
|
+
"FORGE_TEST_POSTGRES_PROVISIONER_CONNECTION_STRING",
|
|
6
7
|
];
|
|
7
8
|
const boundaryAttestationEnvironment = "FORGE_HOST_DATABASE_CAPABILITY_BOUNDARY";
|
|
8
9
|
const boundaryAttestationValue = "user_store_clear";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
/** Static hardware and OS facts a bridge host reports once per process (decision 0013). */
|
|
3
|
+
export interface HostFacts {
|
|
4
|
+
readonly cpuModel: string | null;
|
|
5
|
+
readonly physicalCores: number | null;
|
|
6
|
+
readonly logicalThreads: number;
|
|
7
|
+
readonly totalMemoryBytes: number;
|
|
8
|
+
readonly architecture: string;
|
|
9
|
+
readonly platform: string;
|
|
10
|
+
readonly osName: string | null;
|
|
11
|
+
readonly kernelVersion: string | null;
|
|
12
|
+
readonly psiAvailable: boolean;
|
|
13
|
+
}
|
|
14
|
+
export type HostFileReader = (filePath: string) => Promise<string>;
|
|
15
|
+
export interface HostEnvironment {
|
|
16
|
+
readonly platform: NodeJS.Platform;
|
|
17
|
+
readonly procRoot: string;
|
|
18
|
+
readonly etcRoot: string;
|
|
19
|
+
readonly cgroupRoot: string;
|
|
20
|
+
readonly readFile: HostFileReader;
|
|
21
|
+
readonly cpus: () => readonly Pick<os.CpuInfo, "model">[];
|
|
22
|
+
readonly totalMemoryBytes: () => number;
|
|
23
|
+
readonly freeMemoryBytes: () => number;
|
|
24
|
+
readonly architecture: () => string;
|
|
25
|
+
readonly kernelRelease: () => string;
|
|
26
|
+
readonly osType: () => string;
|
|
27
|
+
readonly osVersion: () => string;
|
|
28
|
+
}
|
|
29
|
+
export declare function defaultHostEnvironment(overrides?: Partial<HostEnvironment>): HostEnvironment;
|
|
30
|
+
export declare function detectHostFacts(environment?: HostEnvironment): Promise<HostFacts>;
|
|
31
|
+
/** PSI is available when the system-wide CPU pressure file exists and parses. */
|
|
32
|
+
export declare function probePsi(environment: HostEnvironment): Promise<boolean>;
|
|
33
|
+
export declare function readOptional(environment: HostEnvironment, filePath: string): Promise<string | null>;
|
|
34
|
+
/** Counts unique (physical id, core id) pairs; null when the topology is not exposed. */
|
|
35
|
+
export declare function physicalCoreCount(cpuinfo: string): number | null;
|