@loucompanion/forge-bridge 0.1.4-dev.f22f5e3d01fe → 0.2.1-dev.0f07274d438b
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 +128 -4
- package/dist/bridge/bridge-chat-giphy-look.d.ts +48 -0
- package/dist/bridge/bridge-chat-giphy-look.js +55 -0
- package/dist/bridge/bridge-chat-provider-command.d.ts +27 -3
- package/dist/bridge/bridge-chat-provider-command.js +131 -26
- package/dist/bridge/bridge-chat.types.d.ts +20 -0
- package/dist/bridge/bridge-chat.types.js +28 -1
- package/dist/bridge/bridge-state-file.d.ts +161 -0
- package/dist/bridge/bridge-state-file.js +376 -0
- package/dist/bridge/bridge-state-io.d.ts +15 -0
- package/dist/bridge/bridge-state-io.js +68 -0
- package/dist/bridge/bridge-state-lock.d.ts +11 -0
- package/dist/bridge/bridge-state-lock.js +102 -0
- package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
- package/dist/bridge/bridge-state-unpublished.js +111 -0
- package/dist/bridge/bridge.service.d.ts +29 -12
- package/dist/bridge/bridge.service.js +215 -380
- package/dist/bridge/bridge.types.d.ts +21 -0
- package/dist/bridge/bridge.types.js +2 -1
- package/dist/bridge/default-session-service.d.ts +13 -0
- package/dist/bridge/default-session-service.js +22 -0
- package/dist/bridge/dispatch-offer-policy.d.ts +22 -0
- package/dist/bridge/dispatch-offer-policy.js +58 -0
- package/dist/bridge/in-flight-registry.d.ts +62 -0
- package/dist/bridge/in-flight-registry.js +207 -0
- package/dist/bridge/readiness-result-outbox.d.ts +5 -1
- package/dist/bridge/readiness-result-outbox.js +20 -0
- package/dist/bridge/runner-host-capabilities.js +14 -1
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -0
- package/dist/bridge/windows-bash-resolution.d.ts +31 -0
- package/dist/bridge/windows-bash-resolution.js +153 -0
- package/dist/cleanup/cleanup-wip.d.ts +12 -0
- package/dist/cleanup/cleanup-wip.js +66 -0
- package/dist/cleanup/cleanup.service.d.ts +11 -1
- package/dist/cleanup/cleanup.service.js +80 -62
- package/dist/cleanup/cleanup.types.d.ts +2 -0
- package/dist/cleanup/forge-owned-paths.d.ts +2 -0
- package/dist/cleanup/forge-owned-paths.js +9 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +2 -0
- package/dist/cleanup/host-runtime-ledger.js +30 -9
- package/dist/cli/cli.help.js +57 -13
- package/dist/cli/cli.service.d.ts +3 -10
- package/dist/cli/cli.service.js +20 -213
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +14 -1
- package/dist/cli/local-config.js +42 -2
- package/dist/cli/provider-cli-advertising.d.ts +24 -0
- package/dist/cli/provider-cli-advertising.js +88 -0
- package/dist/cli/provider-cli-detection.d.ts +10 -0
- package/dist/cli/provider-cli-detection.js +160 -0
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +20 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +104 -26
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/attempt-node-runtime-launcher.d.ts +36 -0
- package/dist/runtime/attempt-node-runtime-launcher.js +169 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +2 -0
- package/dist/runtime/attempt-process-supervisor.js +12 -6
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -0
- package/dist/runtime/dotnet-build-outputs.d.ts +107 -0
- package/dist/runtime/dotnet-build-outputs.js +402 -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-listener-inspector.d.ts +26 -0
- package/dist/runtime/host-listener-inspector.js +84 -3
- package/dist/runtime/host-load-admission.d.ts +5 -0
- package/dist/runtime/host-load-capacity.d.ts +198 -0
- package/dist/runtime/host-load-capacity.js +353 -0
- package/dist/runtime/host-load-child-environment.d.ts +13 -0
- package/dist/runtime/host-load-child-environment.js +35 -1
- package/dist/runtime/host-load-governor-config.d.ts +33 -3
- package/dist/runtime/host-load-governor-config.js +24 -3
- package/dist/runtime/host-load-governor.d.ts +91 -2
- package/dist/runtime/host-load-governor.js +217 -18
- package/dist/runtime/host-load-ledger-lock.js +6 -4
- package/dist/runtime/host-load-live-test-slots.d.ts +61 -0
- package/dist/runtime/host-load-live-test-slots.js +193 -0
- package/dist/runtime/host-load-runtime-settings.js +4 -2
- package/dist/runtime/host-load-sampler.d.ts +25 -1
- package/dist/runtime/host-load-sampler.js +38 -7
- package/dist/runtime/host-load-step-run.d.ts +37 -3
- package/dist/runtime/host-load-step-run.js +63 -7
- package/dist/runtime/host-load-test-slot.d.ts +3 -0
- package/dist/runtime/host-load-test-slot.js +26 -7
- package/dist/runtime/host-runtime-contract.d.ts +12 -0
- package/dist/runtime/host-runtime-contract.js +35 -5
- package/dist/runtime/host-runtime-lease.d.ts +28 -3
- package/dist/runtime/host-runtime-lease.js +140 -296
- package/dist/runtime/host-runtime-ledger-recovery.d.ts +20 -0
- package/dist/runtime/host-runtime-ledger-recovery.js +134 -0
- package/dist/runtime/host-runtime-promotion.d.ts +78 -2
- package/dist/runtime/host-runtime-promotion.js +307 -14
- package/dist/runtime/managed-command-teardown.js +5 -16
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/runtime/prepared-runtime-identity.d.ts +4 -0
- package/dist/runtime/prepared-runtime-identity.js +130 -9
- package/dist/runtime/prepared-runtime-readiness.d.ts +23 -1
- package/dist/runtime/prepared-runtime-readiness.js +89 -18
- package/dist/runtime/runner-settings.d.ts +4 -0
- package/dist/runtime/runner-settings.js +22 -0
- package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
- package/dist/runtime/supervised-runtime-build-guard.js +112 -0
- package/dist/sandbox/host-capacity-broker.d.ts +3 -1
- package/dist/sandbox/host-capacity-broker.js +4 -2
- package/dist/sandbox/managed-branch.d.ts +13 -0
- package/dist/sandbox/managed-branch.js +90 -0
- package/dist/sandbox/provider-auth/codex.js +11 -11
- package/dist/sandbox/runtime.d.ts +1 -2
- package/dist/sandbox/runtime.js +9 -19
- package/dist/sandbox/sandbox-input.d.ts +22 -0
- package/dist/sandbox/sandbox-input.js +49 -0
- package/dist/sandbox/workspace.service.js +15 -2
- package/dist/session/managed-attempt-tools.d.ts +0 -7
- package/dist/session/managed-attempt-tools.js +54 -109
- package/dist/session/managed-build-coordinator.d.ts +16 -0
- package/dist/session/managed-build-coordinator.js +10 -0
- package/dist/session/managed-build-receipt.d.ts +7 -0
- package/dist/session/managed-build-receipt.js +11 -3
- package/dist/session/managed-command-environment.d.ts +8 -0
- package/dist/session/managed-command-environment.js +28 -0
- package/dist/session/managed-command-host-load.d.ts +10 -5
- package/dist/session/managed-command-host-load.js +18 -14
- package/dist/session/phase-completion.artifact-bundle.d.ts +20 -0
- package/dist/session/phase-completion.artifact-bundle.js +167 -0
- package/dist/session/phase-completion.artifacts.d.ts +2 -17
- package/dist/session/phase-completion.artifacts.js +65 -166
- package/dist/session/phase-completion.d.ts +27 -2
- package/dist/session/phase-completion.helpers.js +5 -53
- package/dist/session/phase-completion.js +15 -32
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +195 -0
- package/dist/session/phase-completion.phase-aliases.d.ts +5 -0
- package/dist/session/phase-completion.phase-aliases.js +43 -0
- package/dist/session/phase-completion.pr-review-schema.d.ts +1 -0
- package/dist/session/phase-completion.pr-review-schema.js +75 -0
- package/dist/session/phase-completion.pr-review-validation.d.ts +11 -0
- package/dist/session/phase-completion.pr-review-validation.js +212 -0
- package/dist/session/phase-completion.pr-review.d.ts +36 -0
- package/dist/session/phase-completion.pr-review.js +294 -0
- package/dist/session/phase-completion.prompts.d.ts +1 -1
- package/dist/session/phase-completion.prompts.js +14 -0
- package/dist/session/phase-completion.runtime.d.ts +8 -9
- package/dist/session/phase-completion.runtime.js +65 -196
- package/dist/session/phase-completion.schemas.js +12 -2
- package/dist/session/phase-completion.validation.d.ts +1 -0
- package/dist/session/phase-completion.validation.js +9 -1
- package/dist/session/pr-review-diff-base.d.ts +18 -0
- package/dist/session/pr-review-diff-base.js +44 -0
- package/dist/session/pr-review-placement.d.ts +50 -0
- package/dist/session/pr-review-placement.js +91 -0
- package/dist/session/pre-publication-change-set.d.ts +62 -0
- package/dist/session/pre-publication-change-set.js +166 -0
- package/dist/session/pre-publication-host-load.js +6 -5
- 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-process.js +13 -12
- 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 +9 -4
- package/dist/session/pre-publication-validation.js +62 -65
- package/dist/session/provider-cli/claude-background-work.d.ts +3 -2
- package/dist/session/provider-cli/claude-background-work.js +4 -3
- package/dist/session/provider-cli/dispatch-target-branch.d.ts +7 -0
- package/dist/session/provider-cli/dispatch-target-branch.js +8 -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/pr-review-credential-isolation.d.ts +83 -0
- package/dist/session/provider-cli/pr-review-credential-isolation.js +144 -0
- package/dist/session/provider-cli/pr-review-guardrails.d.ts +70 -0
- package/dist/session/provider-cli/pr-review-guardrails.js +360 -0
- package/dist/session/provider-cli/pr-review-prompt.d.ts +2 -0
- package/dist/session/provider-cli/pr-review-prompt.js +119 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +16 -0
- package/dist/session/provider-cli/pre-publication-repair.js +41 -3
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +4 -2
- package/dist/session/provider-cli/provider-cli.deterministic.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.deterministic.js +5 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +6 -3
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +29 -10
- package/dist/session/provider-cli/provider-cli.pr-review.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.pr-review.js +213 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +2 -14
- package/dist/session/provider-cli/provider-cli.process.js +4 -94
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +13 -3
- package/dist/session/provider-cli/provider-cli.prompts.js +137 -84
- package/dist/session/provider-cli/provider-cli.reapply-conflicts.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.reapply-conflicts.js +37 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +15 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +37 -2
- package/dist/session/provider-cli/provider-cli.service-support.d.ts +37 -0
- package/dist/session/provider-cli/provider-cli.service-support.js +146 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +15 -18
- package/dist/session/provider-cli/provider-cli.service.js +59 -190
- package/dist/session/provider-cli/provider-cli.types.d.ts +7 -2
- 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-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.d.ts +22 -1
- package/dist/session/sandbox-host-capacity-gate.js +63 -22
- package/dist/session/session-host-project.d.ts +22 -0
- package/dist/session/session-host-project.js +98 -0
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.parse-helpers.d.ts +10 -0
- package/dist/session/session.parse-helpers.js +84 -0
- package/dist/session/session.runtime-refresh.d.ts +46 -0
- package/dist/session/session.runtime-refresh.js +116 -0
- package/dist/session/session.service.d.ts +8 -1
- package/dist/session/session.service.js +177 -239
- package/dist/session/session.types.d.ts +5 -0
- package/dist/session/session.types.js +9 -79
- package/dist/session/session.types.pr-review.d.ts +48 -0
- package/dist/session/session.types.pr-review.js +51 -0
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/shared/fs/file-identity.d.ts +10 -0
- package/dist/shared/fs/file-identity.js +15 -0
- package/dist/shared/fs/replace-file.d.ts +7 -0
- package/dist/shared/fs/replace-file.js +33 -0
- package/dist/shared/process/host-process-recovery.d.ts +14 -3
- package/dist/shared/process/host-process-recovery.js +23 -3
- package/dist/shared/process/host-process-supervisor.d.ts +13 -1
- package/dist/shared/process/host-process-supervisor.js +66 -14
- package/dist/shared/provider-capabilities.d.ts +2 -0
- package/dist/shared/provider-capabilities.js +18 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.js +24 -0
- package/dist/worktree/orphan-relink.d.ts +19 -0
- package/dist/worktree/orphan-relink.js +106 -0
- package/dist/worktree/wip-git.d.ts +58 -0
- package/dist/worktree/wip-git.js +182 -0
- package/dist/worktree/wip-refs.d.ts +85 -0
- package/dist/worktree/wip-refs.js +169 -0
- package/dist/worktree/wip-restore.d.ts +51 -0
- package/dist/worktree/wip-restore.js +324 -0
- package/dist/worktree/wip-snapshot.d.ts +53 -0
- package/dist/worktree/wip-snapshot.js +270 -0
- package/dist/worktree/worktree-inputs.d.ts +8 -0
- package/dist/worktree/worktree-inputs.js +134 -0
- package/dist/worktree/worktree-origin-sync.d.ts +35 -0
- package/dist/worktree/worktree-origin-sync.js +128 -0
- package/dist/worktree/worktree-wip-events.d.ts +20 -0
- package/dist/worktree/worktree-wip-events.js +148 -0
- package/dist/worktree/worktree-wip.d.ts +57 -0
- package/dist/worktree/worktree-wip.js +200 -0
- package/dist/worktree/worktree.base.d.ts +7 -1
- package/dist/worktree/worktree.service.d.ts +49 -5
- package/dist/worktree/worktree.service.js +223 -187
- package/dist/worktree/worktree.types.d.ts +47 -0
- package/package.json +1 -1
- package/runtime/windows-listener-owner.ps1 +12 -1
|
@@ -3,19 +3,18 @@ import fs from "node:fs/promises";
|
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { resetGeneratedOutputs } from "../runtime/generated-output-reset.js";
|
|
6
|
-
import { DockerEngineProbe } from "../runtime/docker-engine-probe.js";
|
|
7
6
|
import { attemptDatabaseCapabilityEnvironment, attemptDatabaseCapabilitySecrets, } from "../runtime/attempt-database-broker.js";
|
|
8
7
|
import { assertHostDatabaseCapabilityBoundary } from "../runtime/host-database-capability-boundary.js";
|
|
9
|
-
import {
|
|
8
|
+
import { managedVerificationDatabase, noManagedVerificationDatabase, releaseManagedVerificationDatabase, setUpWithManagedVerificationDatabase } from "../runtime/ephemeral-test-postgres-grant.js";
|
|
10
9
|
import { redactText } from "../shared/redaction/redaction.js";
|
|
11
10
|
import { emptyToolInputHint, isEmptyToolInput } from "./mcp-argument-coercion.js";
|
|
12
|
-
import { ManagedBuildCoordinator } from "./managed-build-coordinator.js";
|
|
11
|
+
import { assertManagedBuildSparesSupervisedRuntimes, ManagedBuildCoordinator } from "./managed-build-coordinator.js";
|
|
13
12
|
import { attachManagedCommandProcess, ManagedCommandHostCapacity, } from "./managed-command-host-load.js";
|
|
14
13
|
import { HostCapacityLedgerUnavailableError } from "../runtime/host-load-ledger-lock.js";
|
|
15
14
|
import { isProcessTreeTerminationUnproven } from "../shared/process/process.js";
|
|
16
15
|
import { HostCapacityTokenFencedError } from "../runtime/host-load-token-ledger.js";
|
|
17
|
-
import {
|
|
18
|
-
import { managedBuildConfiguration, publishManagedBuildReceipt, verifyManagedBuildReceipt, } from "./managed-build-receipt.js";
|
|
16
|
+
import { inheritedManagedCommandEnvironment } from "./managed-command-environment.js";
|
|
17
|
+
import { managedBuildConfiguration, persistJsonAtomically, publishManagedBuildReceipt, verifyManagedBuildReceipt, } from "./managed-build-receipt.js";
|
|
19
18
|
import { managedLongTierTimeoutMs, managedMaximumCommandTimeoutMs, managedVerificationTierTimeoutMs, } from "./managed-verification-timeouts.js";
|
|
20
19
|
import { resolveWindowsCommandFromPath, StreamingProviderProcessRunner } from "./provider-cli/provider-cli.process.js";
|
|
21
20
|
import { monotonicNowMs } from "../shared/time/monotonic.js";
|
|
@@ -38,8 +37,6 @@ const managedCommandRetryAfterMs = 60_000;
|
|
|
38
37
|
const managedCommandLaunchTimeoutMs = 60_000;
|
|
39
38
|
const managedCommandProgressPersistIntervalMs = 5_000;
|
|
40
39
|
const managedCommandReceiptPollIntervalMs = 1_000;
|
|
41
|
-
const managedCommandReceiptReplaceAttempts = 40;
|
|
42
|
-
const managedCommandReceiptReplaceRetryMs = 25;
|
|
43
40
|
const terminalManagedCommandStatuses = new Set([
|
|
44
41
|
"pass",
|
|
45
42
|
"fail",
|
|
@@ -295,6 +292,9 @@ async function launchManagedCommand(record, worktreePath, forceAsync, verificati
|
|
|
295
292
|
buildReceiptReuse,
|
|
296
293
|
controller: new AbortController(),
|
|
297
294
|
};
|
|
295
|
+
// A build aimed at the output a running supervised runtime executes from fails here, naming
|
|
296
|
+
// that runtime, instead of failing on its locked files after the build-slot and capacity waits.
|
|
297
|
+
await assertManagedBuildSparesSupervisedRuntimes(invocation);
|
|
298
298
|
if (forceAsync || timeoutMs > maximumSynchronousWaitMs) {
|
|
299
299
|
const started = managedCommandResult({
|
|
300
300
|
...invocation,
|
|
@@ -512,7 +512,7 @@ async function executeManagedCommand(invocation) {
|
|
|
512
512
|
let processStarted = false;
|
|
513
513
|
// The per-worktree build slot is taken first: holding a host token while
|
|
514
514
|
// queued behind this worktree's own build would waste host capacity.
|
|
515
|
-
const hostCapacity = new ManagedCommandHostCapacity({ ...invocation, label: invocation.verificationProfile ?? invocation.commandId }, async (hostLoad) => await persistManagedCommandReceipt(invocation.receiptPath, managedCommandResult({
|
|
515
|
+
const hostCapacity = new ManagedCommandHostCapacity({ ...invocation, label: invocation.verificationProfile ?? invocation.commandId }, async (hostLoad, fence) => await persistManagedCommandReceipt(invocation.receiptPath, managedCommandResult({
|
|
516
516
|
...invocation,
|
|
517
517
|
hostLoad,
|
|
518
518
|
timedOut: false,
|
|
@@ -521,7 +521,7 @@ async function executeManagedCommand(invocation) {
|
|
|
521
521
|
stdout: "",
|
|
522
522
|
stderr: "",
|
|
523
523
|
launchRequested: false,
|
|
524
|
-
}).structuredContent));
|
|
524
|
+
}).structuredContent, async (replace) => await fence.commit(replace)));
|
|
525
525
|
const launch = async (buildQueueWaitMs) => await hostCapacity.run(invocation.controller.signal, async (hostLoad, control) => {
|
|
526
526
|
processStarted = true;
|
|
527
527
|
// A reclaimed token means this command's capacity is gone: it stops. A fence that
|
|
@@ -594,41 +594,48 @@ async function executeManagedCommand(invocation) {
|
|
|
594
594
|
return managedCommandPublicResult(receipt);
|
|
595
595
|
}
|
|
596
596
|
}
|
|
597
|
+
/** A command's environment and redaction list; a setup that throws releases the database it started. */
|
|
597
598
|
async function managedCommandProcessEnvironment(invocation) {
|
|
598
599
|
assertHostDatabaseCapabilityBoundary();
|
|
599
|
-
const
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
600
|
+
const database = invocation.verificationProfile ? await managedVerificationDatabase() : noManagedVerificationDatabase;
|
|
601
|
+
return await setUpWithManagedVerificationDatabase(database, () => {
|
|
602
|
+
const exactSecrets = [
|
|
603
|
+
...database.secrets,
|
|
604
|
+
// The attempt's brokered database login reaches managed commands; their output never shows it.
|
|
605
|
+
...attemptDatabaseCapabilitySecrets(process.env[attemptDatabaseCapabilityEnvironment]),
|
|
606
|
+
];
|
|
607
|
+
const environment = inheritedManagedCommandEnvironment({
|
|
608
|
+
FORGE_RUNTIME_MODE: "host",
|
|
609
|
+
FORGE_RESOURCE_LEASE_ID: requiredAttemptEnvironment("FORGE_RESOURCE_LEASE_ID"),
|
|
610
|
+
FORGE_DISPATCH_ATTEMPT_ID: requiredAttemptEnvironment("FORGE_DISPATCH_ATTEMPT_ID"),
|
|
611
|
+
// This nested command owns a distinct supervisor identity. A command-local
|
|
612
|
+
// fence avoids exposing the parent attempt's fencing capability to Codex's
|
|
613
|
+
// MCP subprocess configuration while preserving exact-tree cleanup proof.
|
|
614
|
+
FORGE_FENCING_TOKEN: randomUUID(),
|
|
615
|
+
FORGE_LOG_DIR: invocation.logDirectory,
|
|
616
|
+
FORGE_TEST_OUTPUT_DIR: requiredAttemptEnvironment("FORGE_TEST_OUTPUT_DIR"),
|
|
617
|
+
FORGE_PROCESS_SUPERVISOR_ID: `managed-${invocation.commandId.replaceAll("-", "")}`,
|
|
618
|
+
FORGE_PROCESS_SUPERVISOR_METADATA_PATH: invocation.metadataPath,
|
|
619
|
+
...(invocation.verificationProfile
|
|
620
|
+
? {
|
|
621
|
+
FORGE_MANAGED_VERIFICATION_PROFILE: invocation.verificationProfile,
|
|
622
|
+
// Managed verification executes mutable worktree scripts, SDK targets,
|
|
623
|
+
// and test assemblies. It uses an attempt-owned container, or the
|
|
624
|
+
// dedicated native test cluster while Docker is unavailable; it never
|
|
625
|
+
// receives a capability for a server that holds real data.
|
|
626
|
+
FORGE_MANAGED_VERIFICATION_DATABASE_MODE: "container_only",
|
|
627
|
+
...database.environment,
|
|
628
|
+
}
|
|
629
|
+
: {}),
|
|
630
|
+
});
|
|
631
|
+
return { environment, exactSecrets, release: database.release };
|
|
630
632
|
});
|
|
631
|
-
|
|
633
|
+
}
|
|
634
|
+
function clearManagedCommandTimers(...timers) {
|
|
635
|
+
// clearTimeout and clearInterval share one timer table.
|
|
636
|
+
for (const timer of timers)
|
|
637
|
+
if (timer)
|
|
638
|
+
clearTimeout(timer);
|
|
632
639
|
}
|
|
633
640
|
async function executeManagedCommandProcess(invocation) {
|
|
634
641
|
let prepared;
|
|
@@ -830,11 +837,9 @@ async function executeManagedCommandProcess(invocation) {
|
|
|
830
837
|
return managedCommandPublicResult(receipt);
|
|
831
838
|
}
|
|
832
839
|
finally {
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
if (progressHeartbeat)
|
|
837
|
-
clearInterval(progressHeartbeat);
|
|
840
|
+
clearManagedCommandTimers(launchTimer, timer, progressHeartbeat);
|
|
841
|
+
// An ephemeral verification cluster lives exactly as long as its command; one that would not stop is reaped later and named in the receipt.
|
|
842
|
+
await releaseManagedVerificationDatabase(prepared, async (message) => await annotateManagedCommandReceipt(invocation.receiptPath, { ephemeral_cluster_release_error: redactText(message, exactSecrets) }));
|
|
838
843
|
}
|
|
839
844
|
}
|
|
840
845
|
async function readManagedCommand(input) {
|
|
@@ -937,28 +942,8 @@ async function waitManagedCommand(input) {
|
|
|
937
942
|
function managedCommandReceiptPath(logDirectory, commandId) {
|
|
938
943
|
return path.join(logDirectory, "managed-commands", `${commandId}.receipt.json`);
|
|
939
944
|
}
|
|
940
|
-
async function persistManagedCommandReceipt(receiptPath, receipt) {
|
|
941
|
-
|
|
942
|
-
await fs.writeFile(temporaryPath, `${JSON.stringify(receipt, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
|
|
943
|
-
try {
|
|
944
|
-
for (let attempt = 1;; attempt += 1) {
|
|
945
|
-
try {
|
|
946
|
-
await fs.rename(temporaryPath, receiptPath);
|
|
947
|
-
break;
|
|
948
|
-
}
|
|
949
|
-
catch (error) {
|
|
950
|
-
const code = error.code;
|
|
951
|
-
if (attempt >= managedCommandReceiptReplaceAttempts
|
|
952
|
-
|| (code !== "EPERM" && code !== "EBUSY" && code !== "EACCES")) {
|
|
953
|
-
throw error;
|
|
954
|
-
}
|
|
955
|
-
await delay(managedCommandReceiptReplaceRetryMs);
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
finally {
|
|
960
|
-
await fs.rm(temporaryPath, { force: true }).catch(() => undefined);
|
|
961
|
-
}
|
|
945
|
+
async function persistManagedCommandReceipt(receiptPath, receipt, commit) {
|
|
946
|
+
await persistJsonAtomically(receiptPath, receipt, commit);
|
|
962
947
|
}
|
|
963
948
|
function managedCommandResult(values) {
|
|
964
949
|
// Governed commands count elapsed time from admission: queue time is host_load_wait_ms.
|
|
@@ -1113,31 +1098,6 @@ async function containedWorkingDirectory(worktreePath, input) {
|
|
|
1113
1098
|
}
|
|
1114
1099
|
return target;
|
|
1115
1100
|
}
|
|
1116
|
-
function inheritedEnvironment(overrides) {
|
|
1117
|
-
const env = {};
|
|
1118
|
-
// A nested Forge process must not join the host ledger: it would queue behind the
|
|
1119
|
-
// token this command already holds. Every FORGE_HOST_LOAD_* variable is dropped,
|
|
1120
|
-
// the test slot count too (decision 0018).
|
|
1121
|
-
for (const [key, value] of Object.entries(withoutHostLoadGovernorVariables(process.env))) {
|
|
1122
|
-
if (typeof value === "string" && !looksSensitiveEnvironmentName(key))
|
|
1123
|
-
env[key] = value;
|
|
1124
|
-
}
|
|
1125
|
-
return { ...env, ...overrides };
|
|
1126
|
-
}
|
|
1127
|
-
/**
|
|
1128
|
-
* Runner-authored verification normally uses its attempt-owned Testcontainers
|
|
1129
|
-
* database. Only when the Docker engine is unavailable does it switch to the
|
|
1130
|
-
* operator-provisioned native test cluster, which holds no real data.
|
|
1131
|
-
*/
|
|
1132
|
-
export async function managedVerificationDatabaseEnvironment(dockerAvailable = async () => (await new DockerEngineProbe().refresh(true)).available, readFallback = () => {
|
|
1133
|
-
const configPath = process.env[nativeTestPostgresFallbackConfigEnvironment]?.trim();
|
|
1134
|
-
return configPath ? readNativeTestPostgresFallback(configPath) : null;
|
|
1135
|
-
}) {
|
|
1136
|
-
const fallback = readFallback();
|
|
1137
|
-
if (!fallback || await dockerAvailable())
|
|
1138
|
-
return {};
|
|
1139
|
-
return nativeTestPostgresFallbackEnvironment(fallback);
|
|
1140
|
-
}
|
|
1141
1101
|
export function isBuildProducingManagedCommand(command, args) {
|
|
1142
1102
|
const executable = path.basename(command).toLowerCase();
|
|
1143
1103
|
if (executable === "dotnet" || executable === "dotnet.exe") {
|
|
@@ -1149,10 +1109,7 @@ export function isBuildProducingManagedCommand(command, args) {
|
|
|
1149
1109
|
if (["powershell", "powershell.exe", "pwsh", "pwsh.exe"].includes(executable)) {
|
|
1150
1110
|
const fileIndex = args.findIndex(argument => argument.toLowerCase() === "-file");
|
|
1151
1111
|
const script = fileIndex >= 0 ? path.basename(args[fileIndex + 1] ?? "").toLowerCase() : "";
|
|
1152
|
-
if (
|
|
1153
|
-
return !args.some(argument => argument.toLowerCase() === "-nobuild");
|
|
1154
|
-
}
|
|
1155
|
-
if (script === "run-dotnet-test-tier.ps1") {
|
|
1112
|
+
if (["run-dotnet-test-tier.ps1", "run-dotnet-test-tier-set.ps1", "run-dotnet-test-suite.ps1"].includes(script)) {
|
|
1156
1113
|
return !args.some(argument => argument.toLowerCase() === "-nobuild");
|
|
1157
1114
|
}
|
|
1158
1115
|
}
|
|
@@ -1184,18 +1141,6 @@ function managedBuildReceiptCoverage(invocation) {
|
|
|
1184
1141
|
}
|
|
1185
1142
|
return null;
|
|
1186
1143
|
}
|
|
1187
|
-
function looksSensitiveEnvironmentName(name) {
|
|
1188
|
-
const normalized = name.trim().toUpperCase();
|
|
1189
|
-
return normalized.includes("SECRET")
|
|
1190
|
-
|| normalized.includes("TOKEN")
|
|
1191
|
-
|| normalized.includes("PASSWORD")
|
|
1192
|
-
|| normalized.includes("CREDENTIAL")
|
|
1193
|
-
|| normalized.includes("CONNECTION_STRING")
|
|
1194
|
-
|| normalized.startsWith("CONNECTIONSTRINGS__")
|
|
1195
|
-
|| normalized.startsWith("CONNECTIONSTRINGS:")
|
|
1196
|
-
|| normalized.endsWith("_API_KEY")
|
|
1197
|
-
|| normalized === "OPENAI_API_KEY";
|
|
1198
|
-
}
|
|
1199
1144
|
function requiredAttemptEnvironment(name) {
|
|
1200
1145
|
const value = process.env[name]?.trim();
|
|
1201
1146
|
if (!value)
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/** The managed command a build check needs: what it runs, where, and for which attempt. */
|
|
2
|
+
export interface ManagedBuildCandidate {
|
|
3
|
+
readonly command: string;
|
|
4
|
+
readonly args: readonly string[];
|
|
5
|
+
readonly cwd: string;
|
|
6
|
+
readonly worktreePath: string;
|
|
7
|
+
readonly logDirectory: string;
|
|
8
|
+
readonly buildProducing: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Refuses, before launch, a managed command that would build into the output one of the
|
|
12
|
+
* attempt's running supervised runtimes executes from. The build slot below orders builds
|
|
13
|
+
* against each other; a running runtime cannot wait its turn, so the collision fails fast
|
|
14
|
+
* with an error naming the runtime instead of a build stuck on its locked files.
|
|
15
|
+
*/
|
|
16
|
+
export declare function assertManagedBuildSparesSupervisedRuntimes(candidate: ManagedBuildCandidate): Promise<void>;
|
|
1
17
|
export declare class ManagedBuildCoordinator {
|
|
2
18
|
private readonly stateRoot;
|
|
3
19
|
constructor(stateRoot?: string);
|
|
@@ -3,10 +3,20 @@ import fs from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { defaultWorktreeCoordinatorStateRoot } from "../worktree/worktree-paths.js";
|
|
5
5
|
import { monotonicNowMs } from "../shared/time/monotonic.js";
|
|
6
|
+
import { assertBuildSparesSupervisedRuntimes } from "../runtime/supervised-runtime-build-guard.js";
|
|
6
7
|
const heartbeatIntervalMs = 30_000;
|
|
7
8
|
const staleAfterMs = 2 * 60_000;
|
|
8
9
|
const acquisitionTimeoutMs = 2 * 60 * 60_000;
|
|
9
10
|
const pollIntervalMs = 100;
|
|
11
|
+
/**
|
|
12
|
+
* Refuses, before launch, a managed command that would build into the output one of the
|
|
13
|
+
* attempt's running supervised runtimes executes from. The build slot below orders builds
|
|
14
|
+
* against each other; a running runtime cannot wait its turn, so the collision fails fast
|
|
15
|
+
* with an error naming the runtime instead of a build stuck on its locked files.
|
|
16
|
+
*/
|
|
17
|
+
export async function assertManagedBuildSparesSupervisedRuntimes(candidate) {
|
|
18
|
+
await assertBuildSparesSupervisedRuntimes({ ...candidate, buildsWorktreeSolution: candidate.buildProducing });
|
|
19
|
+
}
|
|
10
20
|
export class ManagedBuildCoordinator {
|
|
11
21
|
stateRoot;
|
|
12
22
|
constructor(stateRoot = defaultWorktreeCoordinatorStateRoot()) {
|
|
@@ -19,3 +19,10 @@ export declare function verifyManagedBuildReceipt(options: {
|
|
|
19
19
|
readonly requiredCoverage: string;
|
|
20
20
|
}): Promise<ManagedBuildReceiptEvidence>;
|
|
21
21
|
export declare function managedBuildConfiguration(command: string, args: readonly string[]): string;
|
|
22
|
+
/**
|
|
23
|
+
* Writes a JSON receipt by replacing the whole file. Agents and Forge poll receipts, and on
|
|
24
|
+
* Windows a poll that has one open refuses the replace: that delays a write, never fails it.
|
|
25
|
+
* `commit`, when given, runs the final replace and may skip it (a write that went stale while
|
|
26
|
+
* it was being prepared); the receipt is then left as it was.
|
|
27
|
+
*/
|
|
28
|
+
export declare function persistJsonAtomically(receiptPath: string, value: unknown, commit?: (replace: () => Promise<void>) => Promise<unknown>): Promise<void>;
|
|
@@ -3,6 +3,7 @@ import { spawn } from "node:child_process";
|
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { defaultWorktreeCoordinatorStateRoot } from "../worktree/worktree-paths.js";
|
|
6
|
+
import { replaceFile } from "../shared/fs/replace-file.js";
|
|
6
7
|
const schemaVersion = 1;
|
|
7
8
|
const maximumRetainedReceipts = 8;
|
|
8
9
|
const maximumOutputManifestEntries = 20_000;
|
|
@@ -262,7 +263,7 @@ async function persistImmutableReceipt(receiptPath, receipt) {
|
|
|
262
263
|
const temporaryPath = `${receiptPath}.${randomUUID()}.tmp`;
|
|
263
264
|
await fs.writeFile(temporaryPath, `${JSON.stringify(receipt, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
|
|
264
265
|
try {
|
|
265
|
-
await
|
|
266
|
+
await replaceFile(temporaryPath, receiptPath).catch(async (error) => {
|
|
266
267
|
if (error.code !== "EEXIST")
|
|
267
268
|
throw error;
|
|
268
269
|
});
|
|
@@ -271,11 +272,18 @@ async function persistImmutableReceipt(receiptPath, receipt) {
|
|
|
271
272
|
await fs.rm(temporaryPath, { force: true }).catch(() => undefined);
|
|
272
273
|
}
|
|
273
274
|
}
|
|
274
|
-
|
|
275
|
+
/**
|
|
276
|
+
* Writes a JSON receipt by replacing the whole file. Agents and Forge poll receipts, and on
|
|
277
|
+
* Windows a poll that has one open refuses the replace: that delays a write, never fails it.
|
|
278
|
+
* `commit`, when given, runs the final replace and may skip it (a write that went stale while
|
|
279
|
+
* it was being prepared); the receipt is then left as it was.
|
|
280
|
+
*/
|
|
281
|
+
export async function persistJsonAtomically(receiptPath, value, commit) {
|
|
275
282
|
const temporaryPath = `${receiptPath}.${randomUUID()}.tmp`;
|
|
276
283
|
await fs.writeFile(temporaryPath, `${JSON.stringify(value, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
|
|
277
284
|
try {
|
|
278
|
-
await
|
|
285
|
+
const replace = async () => await replaceFile(temporaryPath, receiptPath);
|
|
286
|
+
await (commit ? commit(replace) : replace());
|
|
279
287
|
}
|
|
280
288
|
finally {
|
|
281
289
|
await fs.rm(temporaryPath, { force: true }).catch(() => undefined);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The environment a managed command runs with: the bridge's own, without secrets and without
|
|
3
|
+
* the host load governor, plus the command's overrides. A nested Forge process must not join
|
|
4
|
+
* the host ledger: it would queue behind the token this command already holds, so every
|
|
5
|
+
* FORGE_HOST_LOAD_* variable is dropped, the test slot count too (decision 0018). A heavy
|
|
6
|
+
* command that shares the host with other heavy steps sizes its test parallelism for its share.
|
|
7
|
+
*/
|
|
8
|
+
export declare function inheritedManagedCommandEnvironment(overrides: Readonly<Record<string, string>>, source?: Readonly<Record<string, string | undefined>>): Readonly<Record<string, string>>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { withHostTestParallelism, withoutHostLoadGovernorVariables } from "../runtime/host-load-child-environment.js";
|
|
2
|
+
/**
|
|
3
|
+
* The environment a managed command runs with: the bridge's own, without secrets and without
|
|
4
|
+
* the host load governor, plus the command's overrides. A nested Forge process must not join
|
|
5
|
+
* the host ledger: it would queue behind the token this command already holds, so every
|
|
6
|
+
* FORGE_HOST_LOAD_* variable is dropped, the test slot count too (decision 0018). A heavy
|
|
7
|
+
* command that shares the host with other heavy steps sizes its test parallelism for its share.
|
|
8
|
+
*/
|
|
9
|
+
export function inheritedManagedCommandEnvironment(overrides, source = process.env) {
|
|
10
|
+
const env = {};
|
|
11
|
+
for (const [key, value] of Object.entries(withoutHostLoadGovernorVariables(source))) {
|
|
12
|
+
if (typeof value === "string" && !looksSensitiveEnvironmentName(key))
|
|
13
|
+
env[key] = value;
|
|
14
|
+
}
|
|
15
|
+
return withHostTestParallelism({ ...env, ...overrides });
|
|
16
|
+
}
|
|
17
|
+
function looksSensitiveEnvironmentName(name) {
|
|
18
|
+
const normalized = name.trim().toUpperCase();
|
|
19
|
+
return normalized.includes("SECRET")
|
|
20
|
+
|| normalized.includes("TOKEN")
|
|
21
|
+
|| normalized.includes("PASSWORD")
|
|
22
|
+
|| normalized.includes("CREDENTIAL")
|
|
23
|
+
|| normalized.includes("CONNECTION_STRING")
|
|
24
|
+
|| normalized.startsWith("CONNECTIONSTRINGS__")
|
|
25
|
+
|| normalized.startsWith("CONNECTIONSTRINGS:")
|
|
26
|
+
|| normalized.endsWith("_API_KEY")
|
|
27
|
+
|| normalized === "OPENAI_API_KEY";
|
|
28
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HostLoadStepGate } from "../runtime/host-load-governor.js";
|
|
2
2
|
import { type HostLoadStepClassification, type ManagedCommandStepInput } from "../runtime/host-load-step-class.js";
|
|
3
|
-
import { type HostLoadStepControl } from "../runtime/host-load-step-run.js";
|
|
3
|
+
import { type HostLoadStepControl, type WaitReportFence } from "../runtime/host-load-step-run.js";
|
|
4
4
|
/** Host-load facts a managed command receipt carries; absent while the governor is off. */
|
|
5
5
|
export interface ManagedCommandHostLoadFields {
|
|
6
6
|
readonly stepClass: string;
|
|
@@ -19,8 +19,13 @@ export declare function managedCommandHostLoadGate(): HostLoadStepGate | undefin
|
|
|
19
19
|
export declare function setManagedCommandHostLoadGateForTesting(value: HostLoadStepGate | undefined | null): void;
|
|
20
20
|
/**
|
|
21
21
|
* Admits one managed command. The waiting receipt is written while the command
|
|
22
|
-
* is queued and
|
|
23
|
-
*
|
|
22
|
+
* is queued, and rewritten whenever the wait changes (a new slot holder, say).
|
|
23
|
+
* The writes run in order and land before the launch receipts, so a stale
|
|
24
|
+
* "waiting" write can never replace a later status or a newer wait. A write
|
|
25
|
+
* that never settles holds the launch (with its token) or the terminal receipt
|
|
26
|
+
* back only for the governor's drain bound; writes still queued after it are
|
|
27
|
+
* dropped as stale, and one still running can no longer replace the receipt
|
|
28
|
+
* (orderedWaitReports, WaitReportFence).
|
|
24
29
|
*/
|
|
25
30
|
export declare class ManagedCommandHostCapacity {
|
|
26
31
|
private readonly persistWaiting;
|
|
@@ -28,10 +33,10 @@ export declare class ManagedCommandHostCapacity {
|
|
|
28
33
|
readonly classification: HostLoadStepClassification;
|
|
29
34
|
private readonly label;
|
|
30
35
|
private requestedAtMs;
|
|
31
|
-
private
|
|
36
|
+
private readonly waitingWrites;
|
|
32
37
|
constructor(input: ManagedCommandStepInput & {
|
|
33
38
|
readonly label: string;
|
|
34
|
-
}, persistWaiting: (fields: ManagedCommandHostLoadFields) => Promise<void>, gateFor?: () => HostLoadStepGate | undefined);
|
|
39
|
+
}, persistWaiting: (fields: ManagedCommandHostLoadFields, fence: WaitReportFence) => Promise<void>, gateFor?: () => HostLoadStepGate | undefined);
|
|
35
40
|
/** Runs `launch` once admitted; `fields` is undefined with the governor off. */
|
|
36
41
|
run<T>(signal: AbortSignal, launch: (fields: ManagedCommandHostLoadFields | undefined, control: HostLoadStepControl) => Promise<T>, onReleaseFailed?: (error: unknown) => Promise<void>): Promise<T>;
|
|
37
42
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { hostLoadGovernorFromChildEnvironment } from "../runtime/host-load-child-environment.js";
|
|
2
2
|
import { HostCapacityTimeoutError } from "../runtime/host-load-governor.js";
|
|
3
3
|
import { classifyManagedCommand } from "../runtime/host-load-step-class.js";
|
|
4
|
-
import { attachSupervisedStepProcess, runHostGovernedStep } from "../runtime/host-load-step-run.js";
|
|
4
|
+
import { attachSupervisedStepProcess, orderedWaitReports, runHostGovernedStep, } from "../runtime/host-load-step-run.js";
|
|
5
5
|
let gate = null;
|
|
6
6
|
/** This MCP server's governor, built once from the environment the bridge handed it. */
|
|
7
7
|
export function managedCommandHostLoadGate() {
|
|
@@ -15,8 +15,13 @@ export function setManagedCommandHostLoadGateForTesting(value) {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Admits one managed command. The waiting receipt is written while the command
|
|
18
|
-
* is queued and
|
|
19
|
-
*
|
|
18
|
+
* is queued, and rewritten whenever the wait changes (a new slot holder, say).
|
|
19
|
+
* The writes run in order and land before the launch receipts, so a stale
|
|
20
|
+
* "waiting" write can never replace a later status or a newer wait. A write
|
|
21
|
+
* that never settles holds the launch (with its token) or the terminal receipt
|
|
22
|
+
* back only for the governor's drain bound; writes still queued after it are
|
|
23
|
+
* dropped as stale, and one still running can no longer replace the receipt
|
|
24
|
+
* (orderedWaitReports, WaitReportFence).
|
|
20
25
|
*/
|
|
21
26
|
export class ManagedCommandHostCapacity {
|
|
22
27
|
persistWaiting;
|
|
@@ -24,12 +29,18 @@ export class ManagedCommandHostCapacity {
|
|
|
24
29
|
classification;
|
|
25
30
|
label;
|
|
26
31
|
requestedAtMs = null;
|
|
27
|
-
|
|
32
|
+
waitingWrites;
|
|
28
33
|
constructor(input, persistWaiting, gateFor = managedCommandHostLoadGate) {
|
|
29
34
|
this.persistWaiting = persistWaiting;
|
|
30
35
|
this.gateFor = gateFor;
|
|
31
36
|
this.classification = classifyManagedCommand(input);
|
|
32
37
|
this.label = input.label;
|
|
38
|
+
this.waitingWrites = orderedWaitReports(async (decision, fence) => await this.persistWaiting({
|
|
39
|
+
stepClass: this.classification.stepClass,
|
|
40
|
+
waitMs: 0,
|
|
41
|
+
waitStartedAt: this.requestedAtMs ?? Date.now(),
|
|
42
|
+
waitDetail: decision.detail,
|
|
43
|
+
}, fence));
|
|
33
44
|
}
|
|
34
45
|
/** Runs `launch` once admitted; `fields` is undefined with the governor off. */
|
|
35
46
|
async run(signal, launch, onReleaseFailed) {
|
|
@@ -45,17 +56,10 @@ export class ManagedCommandHostCapacity {
|
|
|
45
56
|
signal,
|
|
46
57
|
// The receipt says host_capacity_token_fenced itself (termination_reason).
|
|
47
58
|
reportsOwnFence: true,
|
|
48
|
-
onWaiting:
|
|
49
|
-
this.waitingWrite = this.persistWaiting({
|
|
50
|
-
stepClass: this.classification.stepClass,
|
|
51
|
-
waitMs: 0,
|
|
52
|
-
waitStartedAt: this.requestedAtMs ?? Date.now(),
|
|
53
|
-
waitDetail: decision.detail,
|
|
54
|
-
}).catch(() => undefined);
|
|
55
|
-
},
|
|
59
|
+
onWaiting: this.waitingWrites.onWaiting,
|
|
56
60
|
onReleaseFailed,
|
|
57
61
|
}, async (waitMs, control) => {
|
|
58
|
-
await this.
|
|
62
|
+
await this.waitingWrites.drained();
|
|
59
63
|
// The launch timer and timeout_ms start inside `launch`, after admission.
|
|
60
64
|
return await launch(waitMs === null
|
|
61
65
|
? undefined
|
|
@@ -67,7 +71,7 @@ export class ManagedCommandHostCapacity {
|
|
|
67
71
|
* the queue or was stopped while waiting), once its waiting receipt landed.
|
|
68
72
|
*/
|
|
69
73
|
async unadmittedFields(error) {
|
|
70
|
-
await this.
|
|
74
|
+
await this.waitingWrites.drained();
|
|
71
75
|
if (this.requestedAtMs === null)
|
|
72
76
|
return undefined;
|
|
73
77
|
const waitMs = error instanceof HostCapacityTimeoutError ? error.waitMs : Date.now() - this.requestedAtMs;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ArtifactBundleFile {
|
|
2
|
+
readonly fileName: string;
|
|
3
|
+
readonly content: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ArtifactBundlePublicationOptions {
|
|
6
|
+
readonly signal?: AbortSignal;
|
|
7
|
+
/** Fault-injection hook used by publication tests. */
|
|
8
|
+
readonly beforePublishFile?: (fileName: string, index: number) => void | Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Stages a complete phase bundle outside the live artifact directory, then
|
|
12
|
+
* publishes its canonical verdict/marker last. Consumers treat the marker as
|
|
13
|
+
* the bundle's commit point, so they can observe either the old complete bundle
|
|
14
|
+
* or the new complete bundle, never a partially written set. A failed or
|
|
15
|
+
* cancelled publication rolls every touched file back before rejecting.
|
|
16
|
+
*/
|
|
17
|
+
export declare function publishArtifactBundleAtomic(artifactRoot: string, files: readonly ArtifactBundleFile[], commitFileName: string, options?: ArtifactBundlePublicationOptions): Promise<void>;
|
|
18
|
+
export declare function validatePostRedaction(validate: () => void): void;
|
|
19
|
+
export declare function postRedactionValidationError(error: unknown): Error;
|
|
20
|
+
export declare function assertStructuralFieldsUnchanged(original: Record<string, unknown>, redacted: Record<string, unknown>): void;
|