@loucompanion/forge-bridge 0.1.4-dev.bbb61d3d6127 → 0.1.4-dev.bd2cfb6b7438
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/bridge/bridge-chat-provider-command.d.ts +16 -0
- package/dist/bridge/bridge-chat-provider-command.js +137 -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 +292 -118
- 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/cleanup/cleanup.service.d.ts +9 -0
- package/dist/cleanup/cleanup.service.js +72 -109
- package/dist/cleanup/cleanup.types.d.ts +4 -0
- package/dist/cleanup/forge-owned-paths.d.ts +9 -0
- package/dist/cleanup/forge-owned-paths.js +53 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +5 -0
- package/dist/cleanup/host-runtime-ledger.js +109 -0
- package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
- package/dist/cleanup/managed-branch-sweep.js +111 -0
- package/dist/cli/cli.help.js +18 -0
- package/dist/cli/cli.service.d.ts +16 -0
- package/dist/cli/cli.service.js +140 -16
- package/dist/cli/local-config.d.ts +4 -0
- package/dist/cli/local-config.js +26 -4
- package/dist/runtime/aspnet-runtime-prebuild.js +94 -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 +27 -0
- package/dist/runtime/host-load-child-environment.js +76 -0
- package/dist/runtime/host-load-forge-cgroups.d.ts +41 -0
- package/dist/runtime/host-load-forge-cgroups.js +93 -4
- 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 +72 -11
- package/dist/runtime/host-load-governor.js +284 -67
- 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 +39 -4
- package/dist/runtime/host-load-sampler.js +83 -9
- package/dist/runtime/host-load-step-class.d.ts +37 -0
- package/dist/runtime/host-load-step-class.js +117 -2
- package/dist/runtime/host-load-step-reaper.d.ts +27 -0
- package/dist/runtime/host-load-step-reaper.js +95 -0
- package/dist/runtime/host-load-step-run.d.ts +73 -0
- package/dist/runtime/host-load-step-run.js +102 -0
- 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 +82 -17
- package/dist/runtime/host-load-token-ledger.js +187 -79
- 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-lease.d.ts +62 -3
- package/dist/runtime/host-runtime-lease.js +258 -13
- 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 +113 -0
- package/dist/sandbox/host-capacity-broker.js +334 -0
- package/dist/sandbox/runtime.d.ts +10 -1
- package/dist/sandbox/runtime.js +45 -2
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- 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 +2 -7
- package/dist/session/managed-attempt-tools.js +200 -92
- package/dist/session/managed-command-host-load.d.ts +47 -0
- package/dist/session/managed-command-host-load.js +83 -0
- package/dist/session/mcp-argument-coercion.d.ts +23 -0
- package/dist/session/mcp-argument-coercion.js +121 -0
- package/dist/session/phase-completion.artifacts.d.ts +7 -0
- package/dist/session/phase-completion.artifacts.js +96 -26
- package/dist/session/phase-completion.command-validation.d.ts +7 -0
- package/dist/session/phase-completion.command-validation.js +77 -0
- package/dist/session/phase-completion.d.ts +4 -0
- package/dist/session/phase-completion.helpers.js +13 -12
- package/dist/session/phase-completion.js +4 -0
- package/dist/session/phase-completion.prompts.js +6 -1
- package/dist/session/phase-completion.runtime.d.ts +5 -3
- package/dist/session/phase-completion.runtime.js +50 -20
- package/dist/session/phase-completion.schema-parts.d.ts +19 -0
- package/dist/session/phase-completion.schema-parts.js +188 -0
- package/dist/session/phase-completion.schemas.d.ts +3 -3
- package/dist/session/phase-completion.schemas.js +208 -231
- package/dist/session/phase-completion.validation.d.ts +2 -3
- package/dist/session/phase-completion.validation.js +49 -93
- package/dist/session/pre-publication-host-load.js +31 -16
- 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-process.d.ts +3 -0
- package/dist/session/pre-publication-process.js +23 -11
- 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 +211 -134
- package/dist/session/provider-cli/claude-background-work.d.ts +66 -0
- package/dist/session/provider-cli/claude-background-work.js +180 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +40 -0
- package/dist/session/provider-cli/pre-publication-repair.js +243 -0
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +73 -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 +13 -22
- package/dist/session/provider-cli/provider-cli.process.js +38 -339
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +2 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +50 -10
- package/dist/session/provider-cli/provider-cli.runtime.js +7 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +4 -1
- package/dist/session/provider-cli/provider-cli.service.js +93 -162
- package/dist/session/provider-cli/provider-cli.types.d.ts +30 -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-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/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 +30 -0
- package/dist/session/sandbox-host-capacity-gate.js +238 -0
- 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 +115 -5
- 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/host-process-supervisor.d.ts +1 -0
- package/dist/shared/process/host-process-supervisor.js +1 -1
- package/dist/shared/process/process-tree.d.ts +52 -0
- package/dist/shared/process/process-tree.js +144 -0
- package/dist/shared/process/process.d.ts +67 -0
- package/dist/shared/process/process.js +213 -11
- 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 +5 -6
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/dependency-warmer.d.ts +25 -0
- package/dist/worktree/dependency-warmer.js +46 -10
- package/dist/worktree/worktree.service.d.ts +10 -1
- package/dist/worktree/worktree.service.js +42 -2
- package/dist/worktree/worktree.types.d.ts +7 -0
- package/package.json +2 -2
|
@@ -4,11 +4,13 @@ import path from "node:path";
|
|
|
4
4
|
import { attemptDatabaseCapabilityEnvironment, attemptDatabaseCapabilitySecrets, } from "../runtime/attempt-database-broker.js";
|
|
5
5
|
import { assertHostDatabaseCapabilityBoundary } from "../runtime/host-database-capability-boundary.js";
|
|
6
6
|
import { runHostGovernedValidationStep } from "./pre-publication-host-load.js";
|
|
7
|
-
import {
|
|
7
|
+
import { dockerFreeGrant, dockerUnavailableNativeTestPostgres, isolatedPostgresProvided, preferredNativeTestPostgres, releaseCheckPostgres, } from "./pre-publication-native-postgres.js";
|
|
8
|
+
import { managedAttemptInvocation, validationExecutionForStep, } from "./pre-publication-step-execution.js";
|
|
8
9
|
import { hostRuntimeLegacyTestPostgresEnvironment, hostRuntimeTestPostgresAdminEnvironment, hostRuntimeTestPostgresProvisionerEnvironment, } from "../runtime/host-runtime-contract.js";
|
|
9
10
|
import { redactText } from "../shared/redaction/redaction.js";
|
|
10
|
-
import {
|
|
11
|
+
import { PrePublicationPass, PrePublicationValidationError, SkippedTestTally, skippedCheckEvent, validationEvent, } from "./pre-publication-pass.js";
|
|
11
12
|
import { ProcessPrePublicationCommandRunner, pnpmDirectoryLaunch } from "./pre-publication-process.js";
|
|
13
|
+
import { ProcessTreeTerminationError } from "../shared/process/process.js";
|
|
12
14
|
import { findUnreferencedNewExports } from "./unreferenced-exports.js";
|
|
13
15
|
import { ForgeFailureError, sanitizeFailureError, } from "./session.types.js";
|
|
14
16
|
const contractRelativePath = ".forge/validation/ci-parity.v1.json";
|
|
@@ -22,16 +24,21 @@ const requiredCheckIds = new Set([
|
|
|
22
24
|
"playwright-e2e",
|
|
23
25
|
"github-provider-policy",
|
|
24
26
|
]);
|
|
25
|
-
|
|
27
|
+
// Every gate profile runs the affected .NET tests; only CI runs the whole tiers (decision 0017).
|
|
28
|
+
const currentApprovedContractDigest = "9cf3a3070de56f3d3bc2c013dfa45b0fd463d257722849087e6743fb9cb1fd0d";
|
|
29
|
+
// Only comment repair ran the affected tests; the other profiles ran Unit, Contract and
|
|
30
|
+
// Infrastructure whole. Story branches cut before decision 0017 still carry it.
|
|
31
|
+
const commentRepairOnlyAffectedContractDigest = "378c767c7977c850140ffb19d69db41da62d0187c37a33828d6cda8803a61c83";
|
|
26
32
|
// Comment repair ran the whole ApiComponent and Orchestration tiers under this contract.
|
|
27
|
-
// Story branches cut before the affected-tests contract still carry it.
|
|
28
33
|
const wholeTierCommentRepairContractDigest = "024de3648c907db9c0eab13def9a4f91e81148433e0a2ba7f44776446421054a";
|
|
29
34
|
// Contracts that declare the comment-repair-dotnet-regression check.
|
|
30
35
|
const commentRepairRegressionContractDigests = new Set([
|
|
31
36
|
currentApprovedContractDigest,
|
|
37
|
+
commentRepairOnlyAffectedContractDigest,
|
|
32
38
|
wholeTierCommentRepairContractDigest,
|
|
33
39
|
]);
|
|
34
40
|
const compatibleApprovedContractDigests = new Set([
|
|
41
|
+
commentRepairOnlyAffectedContractDigest,
|
|
35
42
|
wholeTierCommentRepairContractDigest,
|
|
36
43
|
// Preserve dispatches pinned before comment repair gained all .NET regression tiers.
|
|
37
44
|
"c0014ce6abc0e0b2e66dd2bcf6cb14c47d28506444c73f87d1b76b3d1c06027b",
|
|
@@ -47,23 +54,31 @@ const approvedContractDigests = new Set([
|
|
|
47
54
|
...compatibleApprovedContractDigests,
|
|
48
55
|
]);
|
|
49
56
|
const ansiColorSequence = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "gu");
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
const timeoutConfirmation = {
|
|
58
|
+
started: [
|
|
59
|
+
"prepublication_validation_timeout_confirmation_started",
|
|
60
|
+
"The full client test step reported only Vitest timeouts; confirming once with the same command and attempt environment.",
|
|
61
|
+
],
|
|
62
|
+
passed: [
|
|
63
|
+
"prepublication_validation_timeout_confirmation_passed",
|
|
64
|
+
"The complete client test step passed on its single timeout confirmation run.",
|
|
65
|
+
],
|
|
66
|
+
failedEvent: "prepublication_validation_timeout_confirmation_failed",
|
|
67
|
+
failedContent: exitCode => `The complete client test step failed on its single timeout confirmation run (exit ${exitCode}).`,
|
|
68
|
+
};
|
|
69
|
+
const cleanupConfirmation = {
|
|
70
|
+
started: [
|
|
71
|
+
"prepublication_validation_cleanup_confirmation_started",
|
|
72
|
+
"The Bridge suite hit the known Windows temporary-worktree cleanup race; confirming once with the same command and attempt environment.",
|
|
73
|
+
],
|
|
74
|
+
passed: [
|
|
75
|
+
"prepublication_validation_cleanup_confirmation_passed",
|
|
76
|
+
"The complete Bridge test step passed on its single cleanup confirmation run.",
|
|
77
|
+
],
|
|
78
|
+
failedEvent: "prepublication_validation_cleanup_confirmation_failed",
|
|
79
|
+
failedContent: exitCode => `The complete Bridge test step failed on its single cleanup confirmation run (exit ${exitCode}).`,
|
|
80
|
+
};
|
|
81
|
+
export { PrePublicationValidationError };
|
|
67
82
|
export class PrePublicationInfrastructureError extends ForgeFailureError {
|
|
68
83
|
checkId;
|
|
69
84
|
exitCode;
|
|
@@ -86,117 +101,176 @@ export class PrePublicationValidator {
|
|
|
86
101
|
dockerEngineProbe;
|
|
87
102
|
nativeTestPostgresFallback;
|
|
88
103
|
hostLoad;
|
|
89
|
-
|
|
104
|
+
startEphemeral;
|
|
105
|
+
constructor(commands = new ProcessPrePublicationCommandRunner(), dockerEngineProbe, nativeTestPostgresFallback = () => null, hostLoad, startEphemeral) {
|
|
90
106
|
this.commands = commands;
|
|
91
107
|
this.dockerEngineProbe = dockerEngineProbe;
|
|
92
108
|
this.nativeTestPostgresFallback = nativeTestPostgresFallback;
|
|
93
109
|
this.hostLoad = hostLoad;
|
|
110
|
+
this.startEphemeral = startEphemeral;
|
|
94
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Runs one pre-publication pass. A failed check does not end the pass: every remaining check that
|
|
114
|
+
* can still meaningfully run keeps going, and the pass then throws all of its failures as one
|
|
115
|
+
* PrePublicationValidationError.
|
|
116
|
+
*/
|
|
95
117
|
async validate(worktreePath, profile, capabilities, emit, signal, execution) {
|
|
96
118
|
const checksExports = profile === "implementation" || profile === "comment_repair";
|
|
119
|
+
const pass = new PrePublicationPass(execution?.runtimeRestartFailure);
|
|
97
120
|
const contract = await loadValidationContract(worktreePath);
|
|
98
121
|
if (contract === null) {
|
|
99
122
|
await emit?.(validationEvent("prepublication_validation_legacy_contract", "legacy-provider-validation", `This checkout predates ${contractRelativePath}; Bridge preserved legacy provider validation without source mutation.`));
|
|
100
123
|
if (checksExports) {
|
|
101
124
|
const legacy = await prepareValidationExecution(execution);
|
|
102
125
|
try {
|
|
103
|
-
await this.
|
|
126
|
+
await this.checkTestOnlyExports(pass, worktreePath, emit, signal, legacy.execution);
|
|
104
127
|
}
|
|
105
128
|
finally {
|
|
106
129
|
await legacy.cleanup();
|
|
107
130
|
}
|
|
108
131
|
}
|
|
132
|
+
pass.throwIfFailed();
|
|
109
133
|
return [];
|
|
110
134
|
}
|
|
111
135
|
const scoped = await prepareValidationExecution(execution);
|
|
112
136
|
try {
|
|
113
137
|
if (checksExports)
|
|
114
|
-
await this.
|
|
138
|
+
await this.checkTestOnlyExports(pass, worktreePath, emit, signal, scoped.execution);
|
|
115
139
|
const contractDigest = validationContractDigest(contract);
|
|
116
140
|
await this.assertContractMatchesDispatchBaseline(worktreePath, contractDigest, signal, scoped.execution);
|
|
117
141
|
if (contractDigest !== currentApprovedContractDigest) {
|
|
118
142
|
await emit?.(validationEvent("prepublication_validation_compatible_contract", "validation-contract", `This checkout is pinned to approved compatible CI parity contract ${contractDigest}; the host's current contract is ${currentApprovedContractDigest}.`));
|
|
119
143
|
}
|
|
120
144
|
const changedPaths = await this.changedPaths(worktreePath, signal, scoped.execution);
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
const postgresAdminConnection = await this.ensurePrerequisite(check, scoped.execution?.environment, scoped.postgresAdminConnection, emit) ?? scoped.postgresAdminConnection;
|
|
132
|
-
await emit?.(validationEvent("prepublication_validation_started", check.id, `Running pre-publication CI parity check '${check.id}'.`));
|
|
133
|
-
let skipped = { count: 0, reasons: [] };
|
|
134
|
-
for (const step of check.steps) {
|
|
135
|
-
const stepStartedMs = Date.now() - 1000;
|
|
136
|
-
let result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection, emit);
|
|
137
|
-
await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
|
|
138
|
-
if (isTimeoutOnlyClientTestFailure(check.id, step, result)) {
|
|
139
|
-
await emit?.(validationEvent("prepublication_validation_timeout_confirmation_started", check.id, "The full client test step reported only Vitest timeouts; confirming once with the same command and attempt environment."));
|
|
140
|
-
result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection, emit);
|
|
141
|
-
await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
|
|
142
|
-
await emit?.(validationEvent(result.exitCode === 0
|
|
143
|
-
? "prepublication_validation_timeout_confirmation_passed"
|
|
144
|
-
: "prepublication_validation_timeout_confirmation_failed", check.id, result.exitCode === 0
|
|
145
|
-
? "The complete client test step passed on its single timeout confirmation run."
|
|
146
|
-
: `The complete client test step failed on its single timeout confirmation run (exit ${result.exitCode}).`));
|
|
147
|
-
}
|
|
148
|
-
if (isTransientBridgeCleanupFailure(check.id, step, result)) {
|
|
149
|
-
await emit?.(validationEvent("prepublication_validation_cleanup_confirmation_started", check.id, "The Bridge suite hit the known Windows temporary-worktree cleanup race; confirming once with the same command and attempt environment."));
|
|
150
|
-
result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection, emit);
|
|
151
|
-
await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
|
|
152
|
-
await emit?.(validationEvent(result.exitCode === 0
|
|
153
|
-
? "prepublication_validation_cleanup_confirmation_passed"
|
|
154
|
-
: "prepublication_validation_cleanup_confirmation_failed", check.id, result.exitCode === 0
|
|
155
|
-
? "The complete Bridge test step passed on its single cleanup confirmation run."
|
|
156
|
-
: `The complete Bridge test step failed on its single cleanup confirmation run (exit ${result.exitCode}).`));
|
|
157
|
-
}
|
|
158
|
-
if (isTransientShellInfrastructureFailure(result)) {
|
|
159
|
-
await emit?.(validationEvent("prepublication_infrastructure_confirmation_started", check.id, "The validation shell reported a known host-runtime failure; confirming once with the same command and attempt environment."));
|
|
160
|
-
result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection, emit);
|
|
161
|
-
await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
|
|
162
|
-
const infrastructureFailed = isTransientShellInfrastructureFailure(result);
|
|
163
|
-
await emit?.(validationEvent(infrastructureFailed
|
|
164
|
-
? "prepublication_infrastructure_confirmation_failed"
|
|
165
|
-
: "prepublication_infrastructure_confirmation_passed", check.id, infrastructureFailed
|
|
166
|
-
? `The validation shell failed again on its single infrastructure confirmation run (exit ${result.exitCode}).`
|
|
167
|
-
: result.exitCode === 0
|
|
168
|
-
? "The validation step recovered on its single infrastructure confirmation run."
|
|
169
|
-
: "The host-runtime failure did not recur; continuing with normal validation failure handling."));
|
|
170
|
-
if (infrastructureFailed) {
|
|
171
|
-
const detail = diagnosticDetail(result);
|
|
172
|
-
await emit?.(validationEvent("prepublication_infrastructure_failed", check.id, `Pre-publication infrastructure for '${check.id}' remained unavailable${detail ? `: ${detail}` : "."}`));
|
|
173
|
-
throw new PrePublicationInfrastructureError(check.id, result.exitCode, result.command, result.args, detail);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
if (result.exitCode !== 0) {
|
|
177
|
-
const detail = diagnosticDetail(result);
|
|
178
|
-
await emit?.(validationEvent("prepublication_validation_failed", check.id, `Pre-publication CI parity check '${check.id}' exited ${result.exitCode}${detail ? `: ${detail}` : "."}`));
|
|
179
|
-
throw new PrePublicationValidationError(check.id, result.exitCode, result.command, result.args, detail);
|
|
180
|
-
}
|
|
181
|
-
// The invocation's own arguments: a managed attempt may direct results to its test-output root.
|
|
182
|
-
skipped = mergeSkippedTests(skipped, await readSkippedTests(worktreePath, result.args, stepStartedMs, scoped.execution?.environment));
|
|
183
|
-
}
|
|
184
|
-
completed.push(check.id);
|
|
185
|
-
// A pass that skipped tests says so, with each reason, instead of reading as a plain pass.
|
|
186
|
-
const secrets = validationExactSecrets(scoped.execution?.environment);
|
|
187
|
-
skipped = { ...skipped, reasons: skipped.reasons.map(entry => ({ ...entry, reason: redactText(entry.reason, secrets) })) };
|
|
188
|
-
const skippedDetail = skipped.count > 0 ? describeSkippedTests(skipped) : undefined;
|
|
189
|
-
await emit?.(validationEvent("prepublication_validation_passed", check.id, skippedDetail
|
|
190
|
-
? `Pre-publication CI parity check '${check.id}' passed with ${skippedDetail}.`
|
|
191
|
-
: `Pre-publication CI parity check '${check.id}' passed.`, skipped.count > 0 ? { skippedTests: skipped.count, skippedReasons: skipped.reasons } : undefined));
|
|
192
|
-
}
|
|
193
|
-
return completed;
|
|
145
|
+
const run = {
|
|
146
|
+
worktreePath,
|
|
147
|
+
capabilities,
|
|
148
|
+
emit,
|
|
149
|
+
signal,
|
|
150
|
+
execution: withValidationBaseRevision(scoped.execution),
|
|
151
|
+
postgresAdminConnection: scoped.postgresAdminConnection,
|
|
152
|
+
};
|
|
153
|
+
return await this.runChecks(applicableChecks(contract, profile, changedPaths), run, pass);
|
|
194
154
|
}
|
|
195
155
|
finally {
|
|
196
156
|
await scoped.cleanup();
|
|
197
157
|
}
|
|
198
158
|
}
|
|
199
|
-
|
|
159
|
+
async runChecks(checks, run, pass) {
|
|
160
|
+
const completed = [];
|
|
161
|
+
for (const check of checks) {
|
|
162
|
+
if (check.providerOnly) {
|
|
163
|
+
await run.emit?.(validationEvent("prepublication_validation_provider_only", check.id, `Preserved provider-only validation '${check.id}' for the provider check run.`));
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const blockedBy = pass.blockers(check.id);
|
|
167
|
+
if (blockedBy.length > 0) {
|
|
168
|
+
await run.emit?.(skippedCheckEvent(check.id, blockedBy));
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
const failed = await this.runCheck(check, run);
|
|
173
|
+
// A cancelled step may settle with an exit code rather than throw; the pass ends either way.
|
|
174
|
+
run.signal?.throwIfAborted();
|
|
175
|
+
if (failed)
|
|
176
|
+
pass.record(failed.failure, failed.step);
|
|
177
|
+
else
|
|
178
|
+
completed.push(check.id);
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
if (!pass.stopsAt(error, run.signal))
|
|
182
|
+
throw error;
|
|
183
|
+
await run.emit?.(pass.stoppedEvent(check.id, error));
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
pass.throwIfFailed();
|
|
188
|
+
return completed;
|
|
189
|
+
}
|
|
190
|
+
/** Runs one check's steps in order; the first failed step ends the check, since later steps use its output. */
|
|
191
|
+
async runCheck(check, run) {
|
|
192
|
+
if (check.requiredCapability && !run.capabilities.has(check.requiredCapability)) {
|
|
193
|
+
throw new ForgeFailureError("prepublication_capability_unavailable", `prepublication_capability_unavailable: ${check.id} requires ${check.requiredCapability}; publication is holding until a capable runner is available.`, "bridge");
|
|
194
|
+
}
|
|
195
|
+
const granted = await this.ensurePrerequisite(check, run.execution?.environment, run.postgresAdminConnection, run.emit);
|
|
196
|
+
try {
|
|
197
|
+
return await this.runCheckSteps({ ...run, check, postgresAdminConnection: granted ?? run.postgresAdminConnection });
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
200
|
+
await releaseCheckPostgres(check.id, granted, run.emit);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async runCheckSteps(stepRun) {
|
|
204
|
+
const { check, ...run } = stepRun;
|
|
205
|
+
await run.emit?.(validationEvent("prepublication_validation_started", check.id, `Running pre-publication CI parity check '${check.id}'.`));
|
|
206
|
+
const skipped = new SkippedTestTally(run.worktreePath, run.execution?.environment);
|
|
207
|
+
for (const step of check.steps) {
|
|
208
|
+
const stepStartedMs = Date.now() - 1000;
|
|
209
|
+
const result = await this.runConfirmedStep(stepRun, step);
|
|
210
|
+
if (result.exitCode !== 0) {
|
|
211
|
+
const detail = diagnosticDetail(result);
|
|
212
|
+
await run.emit?.(validationEvent("prepublication_validation_failed", check.id, `Pre-publication CI parity check '${check.id}' exited ${result.exitCode}${detail ? `: ${detail}` : "."}`));
|
|
213
|
+
return {
|
|
214
|
+
failure: { checkId: check.id, exitCode: result.exitCode, command: result.command, args: result.args, detail },
|
|
215
|
+
step,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
await skipped.add(result.args, stepStartedMs);
|
|
219
|
+
}
|
|
220
|
+
// The check's own grant reaches only its steps' derived environments, so name its secrets too.
|
|
221
|
+
await run.emit?.(skipped.passedEvent(check.id, [
|
|
222
|
+
...validationExactSecrets(run.execution?.environment),
|
|
223
|
+
...attemptDatabaseCapabilitySecrets(run.postgresAdminConnection?.connectionString),
|
|
224
|
+
]));
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
/** Runs a step, confirming once a failure that matches a known transient pattern. */
|
|
228
|
+
async runConfirmedStep(run, step) {
|
|
229
|
+
let result = await this.runCheckedStep(run, step);
|
|
230
|
+
if (isTimeoutOnlyClientTestFailure(run.check.id, step, result)) {
|
|
231
|
+
result = await this.confirmStep(run, step, timeoutConfirmation);
|
|
232
|
+
}
|
|
233
|
+
if (isTransientBridgeCleanupFailure(run.check.id, step, result)) {
|
|
234
|
+
result = await this.confirmStep(run, step, cleanupConfirmation);
|
|
235
|
+
}
|
|
236
|
+
if (isTransientShellInfrastructureFailure(result)) {
|
|
237
|
+
result = await this.confirmInfrastructure(run, step);
|
|
238
|
+
}
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
241
|
+
async runCheckedStep(run, step) {
|
|
242
|
+
const { check, worktreePath, signal, execution, postgresAdminConnection, emit } = run;
|
|
243
|
+
const result = await this.runStep(check.id, step, worktreePath, signal, execution, postgresAdminConnection, emit);
|
|
244
|
+
await this.throwIfPrerequisiteWasLost(check, result, execution?.environment, postgresAdminConnection, emit);
|
|
245
|
+
return result;
|
|
246
|
+
}
|
|
247
|
+
async confirmStep(run, step, confirmation) {
|
|
248
|
+
await run.emit?.(validationEvent(confirmation.started[0], run.check.id, confirmation.started[1]));
|
|
249
|
+
const result = await this.runCheckedStep(run, step);
|
|
250
|
+
await run.emit?.(result.exitCode === 0
|
|
251
|
+
? validationEvent(confirmation.passed[0], run.check.id, confirmation.passed[1])
|
|
252
|
+
: validationEvent(confirmation.failedEvent, run.check.id, confirmation.failedContent(result.exitCode)));
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
async confirmInfrastructure(run, step) {
|
|
256
|
+
const checkId = run.check.id;
|
|
257
|
+
await run.emit?.(validationEvent("prepublication_infrastructure_confirmation_started", checkId, "The validation shell reported a known host-runtime failure; confirming once with the same command and attempt environment."));
|
|
258
|
+
const result = await this.runCheckedStep(run, step);
|
|
259
|
+
const infrastructureFailed = isTransientShellInfrastructureFailure(result);
|
|
260
|
+
await run.emit?.(validationEvent(infrastructureFailed
|
|
261
|
+
? "prepublication_infrastructure_confirmation_failed"
|
|
262
|
+
: "prepublication_infrastructure_confirmation_passed", checkId, infrastructureFailed
|
|
263
|
+
? `The validation shell failed again on its single infrastructure confirmation run (exit ${result.exitCode}).`
|
|
264
|
+
: result.exitCode === 0
|
|
265
|
+
? "The validation step recovered on its single infrastructure confirmation run."
|
|
266
|
+
: "The host-runtime failure did not recur; continuing with normal validation failure handling."));
|
|
267
|
+
if (!infrastructureFailed)
|
|
268
|
+
return result;
|
|
269
|
+
const detail = diagnosticDetail(result);
|
|
270
|
+
await run.emit?.(validationEvent("prepublication_infrastructure_failed", checkId, `Pre-publication infrastructure for '${checkId}' remained unavailable${detail ? `: ${detail}` : "."}`));
|
|
271
|
+
throw new PrePublicationInfrastructureError(checkId, result.exitCode, result.command, result.args, detail);
|
|
272
|
+
}
|
|
273
|
+
/** Returns the native cluster grant when this check uses it instead of Docker. */
|
|
200
274
|
async ensurePrerequisite(check, environment, postgresAdminConnection, emit) {
|
|
201
275
|
if (check.requiredPrerequisite === "isolated_postgres"
|
|
202
276
|
&& isolatedPostgresProvided(check.id, environment, postgresAdminConnection)) {
|
|
@@ -205,6 +279,11 @@ export class PrePublicationValidator {
|
|
|
205
279
|
: `Pre-publication check '${check.id}' is using the configured loopback PostgreSQL test server with per-run owned databases. No Docker daemon is required.`));
|
|
206
280
|
return undefined;
|
|
207
281
|
}
|
|
282
|
+
return await preferredNativeTestPostgres(check.id, check.requiredPrerequisite, this.nativeTestPostgresFallback, this.dockerEngineProbe, emit, this.startEphemeral)
|
|
283
|
+
?? await this.ensureDockerPrerequisite(check, emit);
|
|
284
|
+
}
|
|
285
|
+
/** Waits for Docker; returns the native cluster grant when Docker stays down and a cluster is provisioned. */
|
|
286
|
+
async ensureDockerPrerequisite(check, emit) {
|
|
208
287
|
if (check.requiredPrerequisite === undefined || !this.dockerEngineProbe)
|
|
209
288
|
return undefined;
|
|
210
289
|
const current = this.dockerEngineProbe.current();
|
|
@@ -216,12 +295,10 @@ export class PrePublicationValidator {
|
|
|
216
295
|
const snapshot = await this.dockerEngineProbe.ensureAvailableForRequiredWork();
|
|
217
296
|
if (!snapshot.available) {
|
|
218
297
|
const detail = `Docker prerequisite unavailable (${snapshot.unavailableCode ?? "docker_engine_unavailable"}): ${snapshot.unavailableReason ?? "the daemon did not pass a fresh readiness probe"}`;
|
|
219
|
-
const fallback = check.
|
|
220
|
-
? this.nativeTestPostgresFallback()
|
|
221
|
-
: null;
|
|
298
|
+
const fallback = dockerUnavailableNativeTestPostgres(check.id, check.requiredPrerequisite, this.nativeTestPostgresFallback);
|
|
222
299
|
if (fallback) {
|
|
223
300
|
await emit?.(validationEvent("prepublication_prerequisite_native_fallback", check.id, `${detail}. Pre-publication check '${check.id}' is using the dedicated native PostgreSQL test cluster at ${fallback.endpoint} with per-run owned databases.`));
|
|
224
|
-
return fallback
|
|
301
|
+
return fallback;
|
|
225
302
|
}
|
|
226
303
|
await emit?.(validationEvent("prepublication_prerequisite_unavailable", check.id, `Pre-publication check '${check.id}' is waiting for Docker infrastructure recovery: ${detail}`));
|
|
227
304
|
throw new PrePublicationInfrastructureError(check.id, 75, "docker", ["info"], detail);
|
|
@@ -233,7 +310,7 @@ export class PrePublicationValidator {
|
|
|
233
310
|
if (result.exitCode === 0
|
|
234
311
|
|| check.requiredPrerequisite === undefined
|
|
235
312
|
|| (check.requiredPrerequisite === "isolated_postgres"
|
|
236
|
-
&& isolatedPostgresProvided(check.id, environment, postgresAdminConnection))
|
|
313
|
+
&& isolatedPostgresProvided(check.id, environment, dockerFreeGrant(postgresAdminConnection)))
|
|
237
314
|
|| !this.dockerEngineProbe)
|
|
238
315
|
return;
|
|
239
316
|
const snapshot = await this.dockerEngineProbe.refresh(true);
|
|
@@ -244,7 +321,8 @@ export class PrePublicationValidator {
|
|
|
244
321
|
throw new PrePublicationInfrastructureError(check.id, result.exitCode, result.command, result.args, detail);
|
|
245
322
|
}
|
|
246
323
|
// Runs for every target repository, with or without a CI parity contract: it only reads the worktree.
|
|
247
|
-
|
|
324
|
+
// A failure joins the pass's failures; the contract's checks still run.
|
|
325
|
+
async checkTestOnlyExports(pass, worktreePath, emit, signal, execution) {
|
|
248
326
|
const found = await findUnreferencedNewExports(args => this.runCommand("git", args, worktreePath, signal, execution), worktreePath, execution?.baselineRevision);
|
|
249
327
|
const unused = found.filter(row => !row.testOnly);
|
|
250
328
|
if (unused.length > 0) {
|
|
@@ -255,7 +333,7 @@ export class PrePublicationValidator {
|
|
|
255
333
|
return;
|
|
256
334
|
const detail = `only tests use ${testOnly.map(row => `${row.name} (${row.path})`).join(", ")}. Wire each to a real caller in this Story, or move the export and its test to the Story that first uses it. Do not delete assertions to pass.`;
|
|
257
335
|
await emit?.(validationEvent("prepublication_validation_failed", "unreferenced-exports", `New code is tested but never called: ${detail}`));
|
|
258
|
-
|
|
336
|
+
pass.record({ checkId: "unreferenced-exports", exitCode: 1, command: "git", args: ["grep"], detail });
|
|
259
337
|
}
|
|
260
338
|
async changedPaths(worktreePath, signal, execution) {
|
|
261
339
|
const baselineRevision = execution?.baselineRevision?.trim();
|
|
@@ -298,10 +376,24 @@ export class PrePublicationValidator {
|
|
|
298
376
|
if (!approvedContractDigests.has(baselineDigest)) {
|
|
299
377
|
throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the dispatch baseline uses unapproved CI parity contract ${baselineDigest}.`, "bridge");
|
|
300
378
|
}
|
|
301
|
-
|
|
379
|
+
// A conflict repair's uncommitted merge brings the target branch's contract with it.
|
|
380
|
+
if (baselineDigest !== contractDigest && await this.mergedInContractDigest(worktreePath, signal, execution) !== contractDigest) {
|
|
302
381
|
throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the CI parity contract changed after dispatch (baseline ${baselineDigest}, worktree ${contractDigest}).`, "bridge");
|
|
303
382
|
}
|
|
304
383
|
}
|
|
384
|
+
/** The approved contract of the branch an in-progress merge brings in (MERGE_HEAD), else null. */
|
|
385
|
+
async mergedInContractDigest(worktreePath, signal, execution) {
|
|
386
|
+
const merged = await this.runCommand("git", ["show", `MERGE_HEAD:${contractRelativePath}`], worktreePath, signal, execution);
|
|
387
|
+
if (merged.exitCode !== 0)
|
|
388
|
+
return null;
|
|
389
|
+
try {
|
|
390
|
+
const digest = validationContractDigest(JSON.parse(merged.stdout ?? ""));
|
|
391
|
+
return approvedContractDigests.has(digest) ? digest : null;
|
|
392
|
+
}
|
|
393
|
+
catch {
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
305
397
|
async runStep(checkId, step, cwd, signal, execution, postgresAdminConnection, emit) {
|
|
306
398
|
const invocation = managedAttemptInvocation(checkId, step, execution?.environment);
|
|
307
399
|
// Every launch, including confirmation reruns, is admitted by the host load governor first.
|
|
@@ -354,31 +446,18 @@ export class PrePublicationValidator {
|
|
|
354
446
|
};
|
|
355
447
|
}
|
|
356
448
|
catch (error) {
|
|
449
|
+
// Carries the check its host capacity token waits on; it names only the executable.
|
|
450
|
+
if (error instanceof ProcessTreeTerminationError)
|
|
451
|
+
throw error;
|
|
357
452
|
throw sanitizeFailureError(error, exactSecrets);
|
|
358
453
|
}
|
|
359
454
|
}
|
|
360
455
|
}
|
|
361
|
-
function environmentValue(environment, name) {
|
|
362
|
-
return Object.prototype.hasOwnProperty.call(environment ?? {}, name)
|
|
363
|
-
? environment?.[name]?.trim() ?? ""
|
|
364
|
-
: process.env[name]?.trim() ?? "";
|
|
365
|
-
}
|
|
366
|
-
function isolatedPostgresProvided(checkId, environment, postgresAdminConnection) {
|
|
367
|
-
if (checkId === "playwright-e2e") {
|
|
368
|
-
const attemptId = environmentValue(environment, "FORGE_DISPATCH_ATTEMPT_ID");
|
|
369
|
-
return (environmentValue(environment, "FORGE_E2E_OWNERSHIP_MODE") === "attempt"
|
|
370
|
-
|| /^[0-9a-f-]{36}$/iu.test(attemptId))
|
|
371
|
-
&& /^forge_attempt_[0-9a-f]{32}$/u.test(environmentValue(environment, "FORGE_ATTEMPT_DATABASE_SCHEMA"))
|
|
372
|
-
&& path.isAbsolute(environmentValue(environment, "FORGE_ATTEMPT_DATABASE_READINESS_PATH"))
|
|
373
|
-
// The attempt owns a database only once the Bridge's broker has issued it one.
|
|
374
|
-
&& environmentValue(environment, attemptDatabaseCapabilityEnvironment).length > 0;
|
|
375
|
-
}
|
|
376
|
-
return Boolean(postgresAdminConnection);
|
|
377
|
-
}
|
|
378
456
|
function validationExactSecrets(environment) {
|
|
379
457
|
return [
|
|
380
|
-
|
|
381
|
-
environment?.[
|
|
458
|
+
// The connection strings and their passwords: a test may print either.
|
|
459
|
+
...attemptDatabaseCapabilitySecrets(environment?.[hostRuntimeTestPostgresAdminEnvironment]),
|
|
460
|
+
...attemptDatabaseCapabilitySecrets(environment?.[hostRuntimeLegacyTestPostgresEnvironment]),
|
|
382
461
|
environment?.[hostRuntimeTestPostgresProvisionerEnvironment]?.trim() ?? "",
|
|
383
462
|
...attemptDatabaseCapabilitySecrets(environment?.[attemptDatabaseCapabilityEnvironment]),
|
|
384
463
|
].filter((value, index, values) => value.length > 0 && values.indexOf(value) === index);
|
|
@@ -568,6 +647,13 @@ export async function loadValidationContract(worktreePath) {
|
|
|
568
647
|
}
|
|
569
648
|
return contract;
|
|
570
649
|
}
|
|
650
|
+
/** The affected .NET tests measure the attempt's change against its dispatch baseline (run-affected-dotnet-tests.mjs). */
|
|
651
|
+
function withValidationBaseRevision(execution) {
|
|
652
|
+
const baseline = execution?.baselineRevision?.trim();
|
|
653
|
+
if (!baseline)
|
|
654
|
+
return execution;
|
|
655
|
+
return { ...execution, environment: { ...execution?.environment, FORGE_VALIDATION_BASE_REVISION: baseline } };
|
|
656
|
+
}
|
|
571
657
|
function validationContractDigest(contract) {
|
|
572
658
|
return createHash("sha256")
|
|
573
659
|
.update(JSON.stringify(canonicalizeJson(contract)))
|
|
@@ -582,12 +668,3 @@ function canonicalizeJson(value) {
|
|
|
582
668
|
}
|
|
583
669
|
return value;
|
|
584
670
|
}
|
|
585
|
-
function validationEvent(eventType, checkId, content, detail) {
|
|
586
|
-
return {
|
|
587
|
-
role: "runner",
|
|
588
|
-
kind: "checkpoint",
|
|
589
|
-
content,
|
|
590
|
-
eventType,
|
|
591
|
-
data: JSON.stringify({ checkId, contractId: "forge-ci-parity-v1", ...detail }),
|
|
592
|
-
};
|
|
593
|
-
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ForgeFailureError } from "../session.types.js";
|
|
2
|
+
import type { ProviderProcessHandlers, ProviderProcessRunner, ProviderProcessRunRequest, ProviderProcessRunResult } from "./provider-cli.process.js";
|
|
3
|
+
/**
|
|
4
|
+
* Removes the `run_in_background` parameter from Bash, PowerShell and the Agent tool, runs
|
|
5
|
+
* forked subagents and forked skills in the foreground, and stops Claude Code from moving long
|
|
6
|
+
* shell commands, subagents and MCP calls to the background on its own. Cron disables the
|
|
7
|
+
* session-scoped scheduled tasks (`CronCreate`, `/loop`). Applied last, so a project's runtime
|
|
8
|
+
* environment cannot turn them back on.
|
|
9
|
+
*/
|
|
10
|
+
export declare const claudeHeadlessEnvironment: Readonly<Record<string, string>>;
|
|
11
|
+
/**
|
|
12
|
+
* Tools whose only purpose is work that reports after the turn. `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS`
|
|
13
|
+
* leaves Monitor running in the background, so it is removed here, together with self-paced
|
|
14
|
+
* wakeups, workflows (which run their agents in the background), cloud routines, cron
|
|
15
|
+
* (also disabled by environment), SendMessage, which resumes an earlier subagent in the
|
|
16
|
+
* background, and agent teams, whose teammates run alongside the turn. Foreground subagents
|
|
17
|
+
* stay available: they block the turn until they finish.
|
|
18
|
+
*/
|
|
19
|
+
export declare const claudeHeadlessDisallowedTools: readonly string[];
|
|
20
|
+
/**
|
|
21
|
+
* The Claude Code arguments that apply the restrictions: the tool deny list, and the environment
|
|
22
|
+
* again as flag settings, which outrank a user's or repository's settings `env` block.
|
|
23
|
+
*/
|
|
24
|
+
export declare function claudeHeadlessToolArgs(): readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* The provider ended its turn while background work it started (a background subagent or
|
|
27
|
+
* shell, a Monitor watch, a wakeup) was still live. Claude Code withholds the turn's terminal
|
|
28
|
+
* result for such work, and nothing started in the background reports to Forge, so Forge stops
|
|
29
|
+
* the provider at once instead of waiting for an idle watchdog. Retryable: the harness, not the
|
|
30
|
+
* task, ended the run.
|
|
31
|
+
*/
|
|
32
|
+
export declare function providerTurnEndedWithBackgroundWorkFailure(message: string): ForgeFailureError;
|
|
33
|
+
/**
|
|
34
|
+
* Fails every provider run Forge stopped because its turn ended with background work still live,
|
|
35
|
+
* whether or not the turn recorded a completion first: the stop cut that work short, so nothing
|
|
36
|
+
* may validate, commit or publish the worktree it left behind.
|
|
37
|
+
*/
|
|
38
|
+
export declare class BackgroundWorkStopFailingRunner implements ProviderProcessRunner {
|
|
39
|
+
private readonly inner;
|
|
40
|
+
constructor(inner: ProviderProcessRunner);
|
|
41
|
+
run(request: ProviderProcessRunRequest, handlers?: ProviderProcessHandlers, signal?: AbortSignal): Promise<ProviderProcessRunResult>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Recognizes a main-conversation turn that ended while background tasks it started were still
|
|
45
|
+
* live, the case in which Claude Code withholds the turn's `result`. The turn end is Claude
|
|
46
|
+
* Code's `post_turn_summary` event; the live set is the documented `background_tasks_changed`
|
|
47
|
+
* event (Claude Code's own `ambient` tasks and `awaited` ones do not count). After `graceMs`
|
|
48
|
+
* without the result or new main-conversation activity, it calls `onTurnEndedWithBackgroundWork`
|
|
49
|
+
* once, so the runner can stop the provider instead of waiting on work no one will collect.
|
|
50
|
+
*/
|
|
51
|
+
export declare class ClaudeBackgroundTurnEndWatch {
|
|
52
|
+
private readonly graceMs;
|
|
53
|
+
private readonly onTurnEndedWithBackgroundWork;
|
|
54
|
+
private liveBackgroundTasks;
|
|
55
|
+
private terminalSinceMainActivity;
|
|
56
|
+
private mainTurnEnded;
|
|
57
|
+
private timer;
|
|
58
|
+
private stopped;
|
|
59
|
+
private readonly enabled;
|
|
60
|
+
/** Watches only Claude Code, by its executable `command`; other output is left alone. */
|
|
61
|
+
constructor(command: string, graceMs: number, onTurnEndedWithBackgroundWork: () => void);
|
|
62
|
+
consume(line: string): void;
|
|
63
|
+
stop(): void;
|
|
64
|
+
private armIfTurnEndedWithBackgroundWork;
|
|
65
|
+
private cancel;
|
|
66
|
+
}
|