@loucompanion/forge-bridge 0.1.4-dev.acacfdecaad2 → 0.1.4-dev.b33004c2b0ea
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 +9 -0
- package/dist/runtime/host-runtime-lease.d.ts +1 -1
- package/dist/runtime/host-runtime-lease.js +8 -7
- package/dist/runtime/host-runtime-promotion.d.ts +23 -0
- package/dist/runtime/host-runtime-promotion.js +36 -0
- package/dist/session/pre-publication-pass.d.ts +60 -0
- package/dist/session/pre-publication-pass.js +145 -0
- package/dist/session/pre-publication-validation.d.ts +21 -11
- package/dist/session/pre-publication-validation.js +149 -104
- 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.service.d.ts +4 -7
- package/dist/session/provider-cli/provider-cli.service.js +64 -235
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -162,6 +162,15 @@ While yielding, the bridge takes no new attempts and heavy steps of running atte
|
|
|
162
162
|
budget. Yield is on when this local flag or the runner's Yield toggle in Forge is on. The flag is stored
|
|
163
163
|
in `bridge.yield.json` next to `bridge.json`, and a running bridge notices it within one heartbeat.
|
|
164
164
|
|
|
165
|
+
## Pre-publication repair
|
|
166
|
+
|
|
167
|
+
Before Forge commits and pushes an agent's work, the bridge runs the CI parity checks in
|
|
168
|
+
`.forge/validation/ci-parity.v1.json`. A failed check does not stop the pass: the other checks still
|
|
169
|
+
run, except those that need what failed (the OpenAPI export and E2E after a .NET compile failure, E2E
|
|
170
|
+
after a failed runtime restart). The provider thread then gets one in-place repair turn that lists
|
|
171
|
+
every failed check. A Work Order holds after `FORGE_PREPUBLICATION_REPAIR_TURNS` repair turns (a whole
|
|
172
|
+
number from 1, capped at 10; default 4) if validation still fails.
|
|
173
|
+
|
|
165
174
|
## Docker sandbox runners
|
|
166
175
|
|
|
167
176
|
Protocol-v2 bridges preflight Docker before advertising the `docker` sandbox runtime. Validate a repository contract and the local runner before enabling a project's `sandbox_required` policy:
|
|
@@ -29,7 +29,7 @@ export interface HostRuntimeAdmissionCheckpoint {
|
|
|
29
29
|
}
|
|
30
30
|
export type HostRuntimeAdmissionCheckpointHandler = (checkpoint: HostRuntimeAdmissionCheckpoint) => void | Promise<void>;
|
|
31
31
|
export interface HostRuntimeProjectCheckpoint {
|
|
32
|
-
readonly code: "host_runtime_build_started" | "host_runtime_build_waiting_for_host_capacity" | "host_runtime_build_cached" | "host_runtime_build_completed" | "host_runtime_database_provisioned";
|
|
32
|
+
readonly code: "host_runtime_build_started" | "host_runtime_build_waiting_for_host_capacity" | "host_runtime_build_cached" | "host_runtime_build_completed" | "host_runtime_database_provisioned" | "host_runtime_contract_readmitted";
|
|
33
33
|
readonly message: string;
|
|
34
34
|
readonly data?: Readonly<Record<string, unknown>>;
|
|
35
35
|
}
|
|
@@ -23,7 +23,7 @@ import { AttemptNodeRuntimeLauncher } from "./attempt-node-runtime-launcher.js";
|
|
|
23
23
|
import { HostListenerInspector } from "./host-listener-inspector.js";
|
|
24
24
|
import { RecoveryStabilizedMemory, buildMemoryAdmissionDiagnostics, resolveAdaptiveMemoryReserveBytes, } from "./memory-capacity.js";
|
|
25
25
|
import { PlaywrightHostRuntimeAdapter } from "./playwright-host-runtime-adapter.js";
|
|
26
|
-
import { HostParallelPromotionStore, configuredLaunchPortNames, hostRuntimeContractFingerprint, hostRuntimeParallelEligible, } from "./host-runtime-promotion.js";
|
|
26
|
+
import { HostParallelPromotionStore, configuredLaunchPortNames, hostRuntimeContractFingerprint, hostRuntimeParallelEligible, readmitHostRuntimeContract, } from "./host-runtime-promotion.js";
|
|
27
27
|
import { ExactHostProcessRecovery, } from "../shared/process/host-process-recovery.js";
|
|
28
28
|
import { resetGeneratedOutputs } from "./generated-output-reset.js";
|
|
29
29
|
import { assertCanonicalDirectory, createCanonicalDirectory } from "./attempt-private-directory.js";
|
|
@@ -1418,12 +1418,13 @@ export class HostRuntimeLeaseManager {
|
|
|
1418
1418
|
}
|
|
1419
1419
|
}
|
|
1420
1420
|
async runConfiguredProjectRestart(active, dispatchAttemptId, fencingToken, signal, onProjectCheckpoint) {
|
|
1421
|
-
// The relaunch
|
|
1422
|
-
//
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1421
|
+
// The relaunch keeps the admission granted at start. A workspace contract that changed only its
|
|
1422
|
+
// launch environment is adopted; any other change throws host_runtime_contract_changed.
|
|
1423
|
+
const readmitted = readmitHostRuntimeContract(active, await loadHostRuntimeContract(active.lease.worktreePath));
|
|
1424
|
+
active.runtimeContract = readmitted.runtimeContract;
|
|
1425
|
+
active.runtimeContractFingerprint = readmitted.runtimeContractFingerprint;
|
|
1426
|
+
if (readmitted.changed) {
|
|
1427
|
+
await onProjectCheckpoint?.({ code: "host_runtime_contract_readmitted", message: "The workspace's runtime contract changed only its launch environment; the restart runs it under the admission granted at start." });
|
|
1427
1428
|
}
|
|
1428
1429
|
const portNames = active.executionClass === "analysis_only" ? [] : configuredLaunchPortNames(active.runtimeContract);
|
|
1429
1430
|
const pendingPort = portNames.find(name => active.pendingAdapterLaunches.has(name));
|
|
@@ -28,5 +28,28 @@ export declare class HostParallelPromotionStore {
|
|
|
28
28
|
private recordPath;
|
|
29
29
|
}
|
|
30
30
|
export declare function hostRuntimeContractFingerprint(runtimeContract: LoadedHostRuntimeContract): string;
|
|
31
|
+
export interface ReadmittedHostRuntimeContract {
|
|
32
|
+
readonly runtimeContract: LoadedHostRuntimeContract;
|
|
33
|
+
readonly runtimeContractFingerprint: string;
|
|
34
|
+
readonly changed: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Decides whether a restart may run the workspace's current runtime contract under the admission
|
|
38
|
+
* granted at start. A restart relaunches from the workspace in any case, so a contract whose only
|
|
39
|
+
* change is the values its ports launch with (launch environment, or discovery inputs that leave
|
|
40
|
+
* the contract itself unchanged) is adopted. This is how a conflict repair survives its own merge:
|
|
41
|
+
* merging the target branch can rename a variable in a derived launch profile, or change a
|
|
42
|
+
* manifest or project file, without changing anything admission granted. Every other part of the
|
|
43
|
+
* contract is admission: source, concurrency, ports (names, adapters, environment names, URL
|
|
44
|
+
* formats, and the command, arguments and working directory that launch them), Playwright, browser
|
|
45
|
+
* profile, singleton resources and declared requirements. Changing any of those throws the
|
|
46
|
+
* retryable host_runtime_contract_changed, so only a fresh attempt runs that contract. An attempt
|
|
47
|
+
* admitted to run in parallel keeps that admission, as it does when a merge changes only source;
|
|
48
|
+
* a restart never promotes, so the adopted contract earns no parallel-safety proof of its own here.
|
|
49
|
+
*/
|
|
50
|
+
export declare function readmitHostRuntimeContract(admitted: {
|
|
51
|
+
readonly runtimeContract: LoadedHostRuntimeContract;
|
|
52
|
+
readonly runtimeContractFingerprint: string;
|
|
53
|
+
}, current: LoadedHostRuntimeContract): ReadmittedHostRuntimeContract;
|
|
31
54
|
export declare function hostRuntimeParallelEligible(runtimeContract: LoadedHostRuntimeContract): boolean;
|
|
32
55
|
export declare function configuredLaunchPortNames(runtimeContract: LoadedHostRuntimeContract): readonly string[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { ForgeFailureError } from "../session/session.types.js";
|
|
4
5
|
/** Persists only observed, contract-bound host parallel-safety evidence. */
|
|
5
6
|
export class HostParallelPromotionStore {
|
|
6
7
|
stateRoot;
|
|
@@ -154,6 +155,41 @@ export function hostRuntimeContractFingerprint(runtimeContract) {
|
|
|
154
155
|
});
|
|
155
156
|
return `sha256:${createHash("sha256").update(canonical).digest("hex")}`;
|
|
156
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Decides whether a restart may run the workspace's current runtime contract under the admission
|
|
160
|
+
* granted at start. A restart relaunches from the workspace in any case, so a contract whose only
|
|
161
|
+
* change is the values its ports launch with (launch environment, or discovery inputs that leave
|
|
162
|
+
* the contract itself unchanged) is adopted. This is how a conflict repair survives its own merge:
|
|
163
|
+
* merging the target branch can rename a variable in a derived launch profile, or change a
|
|
164
|
+
* manifest or project file, without changing anything admission granted. Every other part of the
|
|
165
|
+
* contract is admission: source, concurrency, ports (names, adapters, environment names, URL
|
|
166
|
+
* formats, and the command, arguments and working directory that launch them), Playwright, browser
|
|
167
|
+
* profile, singleton resources and declared requirements. Changing any of those throws the
|
|
168
|
+
* retryable host_runtime_contract_changed, so only a fresh attempt runs that contract. An attempt
|
|
169
|
+
* admitted to run in parallel keeps that admission, as it does when a merge changes only source;
|
|
170
|
+
* a restart never promotes, so the adopted contract earns no parallel-safety proof of its own here.
|
|
171
|
+
*/
|
|
172
|
+
export function readmitHostRuntimeContract(admitted, current) {
|
|
173
|
+
const runtimeContractFingerprint = hostRuntimeContractFingerprint(current);
|
|
174
|
+
// The fingerprint leaves out the source of a project or default contract, but parallel
|
|
175
|
+
// eligibility depends on it, so an unchanged fingerprint alone does not prove the same admission.
|
|
176
|
+
if (runtimeContractFingerprint === admitted.runtimeContractFingerprint && current.source === admitted.runtimeContract.source) {
|
|
177
|
+
return { runtimeContract: admitted.runtimeContract, runtimeContractFingerprint, changed: false };
|
|
178
|
+
}
|
|
179
|
+
if (hostRuntimeAdmissionShape(current) !== hostRuntimeAdmissionShape(admitted.runtimeContract)) {
|
|
180
|
+
throw new ForgeFailureError("host_runtime_contract_changed", "host_runtime_contract_changed: the workspace's runtime contract changed after this attempt's runtime was admitted; a fresh attempt is needed to run it.");
|
|
181
|
+
}
|
|
182
|
+
return { runtimeContract: current, runtimeContractFingerprint, changed: true };
|
|
183
|
+
}
|
|
184
|
+
function hostRuntimeAdmissionShape(runtimeContract) {
|
|
185
|
+
const runtime = runtimeContract.contract.runtime;
|
|
186
|
+
return JSON.stringify({
|
|
187
|
+
source: runtimeContract.source,
|
|
188
|
+
schemaVersion: runtimeContract.contract.schemaVersion,
|
|
189
|
+
runtime: { ...runtime, ports: runtime.ports.map(port => ({ ...port, launch: port.launch && { ...port.launch, environment: undefined } })) },
|
|
190
|
+
...requirementsFingerprintPart(runtimeContract.contract.requires),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
157
193
|
// Cost hints are estimates, not placement constraints: they never change the fingerprint.
|
|
158
194
|
function requirementsFingerprintPart(requires) {
|
|
159
195
|
if (!requires)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ValidationStep } from "./pre-publication-step-execution.js";
|
|
2
|
+
import { ForgeFailureError, type RunnerDispatchEvent } from "./session.types.js";
|
|
3
|
+
/** The check id a failed restart of the attempt's runtime stack before the pass is reported under. */
|
|
4
|
+
export declare const runtimeRestartCheckId = "host-runtime-restart";
|
|
5
|
+
/** One check that failed in a pass: the step that failed and its clipped diagnostics. */
|
|
6
|
+
export interface PrePublicationCheckFailure {
|
|
7
|
+
readonly checkId: string;
|
|
8
|
+
readonly exitCode: number;
|
|
9
|
+
readonly command: string;
|
|
10
|
+
readonly args: readonly string[];
|
|
11
|
+
readonly detail: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A failed validation pass. The single-check fields name the first failure, as they always have;
|
|
15
|
+
* `failures` lists every check that failed in the pass, in the order the checks ran.
|
|
16
|
+
*/
|
|
17
|
+
export declare class PrePublicationValidationError extends ForgeFailureError {
|
|
18
|
+
readonly checkId: string;
|
|
19
|
+
readonly exitCode: number;
|
|
20
|
+
readonly command: string;
|
|
21
|
+
readonly args: readonly string[];
|
|
22
|
+
readonly detail: string;
|
|
23
|
+
readonly code = "prepublication_validation_failed";
|
|
24
|
+
readonly failures: readonly PrePublicationCheckFailure[];
|
|
25
|
+
constructor(checkId: string, exitCode: number, command: string, args: readonly string[], detail: string, additionalFailures?: readonly PrePublicationCheckFailure[]);
|
|
26
|
+
/** Every failed check's id, first failure first. */
|
|
27
|
+
get checkIds(): readonly string[];
|
|
28
|
+
}
|
|
29
|
+
export declare class PrePublicationPass {
|
|
30
|
+
private readonly runtimeRestartFailure?;
|
|
31
|
+
private readonly failures;
|
|
32
|
+
private dotnetCompileFailed;
|
|
33
|
+
/** A failed runtime restart before the pass is its first failure. */
|
|
34
|
+
constructor(runtimeRestartFailure?: PrePublicationValidationError | undefined);
|
|
35
|
+
record(failure: PrePublicationCheckFailure, failedStep?: ValidationStep): void;
|
|
36
|
+
/** The failed checks that keep this check from running meaningfully in this pass. */
|
|
37
|
+
blockers(checkId: string): readonly string[];
|
|
38
|
+
/**
|
|
39
|
+
* Whether an error ends the pass with the failures it already found. Only a classified retryable
|
|
40
|
+
* failure (a resource hold, lost infrastructure, a supervisor that did not start) does, once the
|
|
41
|
+
* pass has found a failure: the repair turn can fix those failures now, and the next pass meets
|
|
42
|
+
* the condition again. Any other error, or cancellation, still ends the attempt as it did.
|
|
43
|
+
*/
|
|
44
|
+
stopsAt(error: unknown, signal?: AbortSignal): error is ForgeFailureError;
|
|
45
|
+
stoppedEvent(checkId: string, error: ForgeFailureError): RunnerDispatchEvent;
|
|
46
|
+
/** Throws every failure the pass found as one validation failure. */
|
|
47
|
+
throwIfFailed(): void;
|
|
48
|
+
}
|
|
49
|
+
export declare function skippedCheckEvent(checkId: string, blockedBy: readonly string[]): RunnerDispatchEvent;
|
|
50
|
+
/** The tests a check's steps skipped, so a check that passed with skips says so with each reason. */
|
|
51
|
+
export declare class SkippedTestTally {
|
|
52
|
+
private readonly worktreePath;
|
|
53
|
+
private readonly environment?;
|
|
54
|
+
private summary;
|
|
55
|
+
constructor(worktreePath: string, environment?: Readonly<Record<string, string>> | undefined);
|
|
56
|
+
/** The invocation's own arguments: a managed attempt may direct results to its test-output root. */
|
|
57
|
+
add(args: readonly string[], stepStartedMs: number): Promise<void>;
|
|
58
|
+
passedEvent(checkId: string, secrets: readonly string[]): RunnerDispatchEvent;
|
|
59
|
+
}
|
|
60
|
+
export declare function validationEvent(eventType: string, checkId: string, content: string, detail?: Readonly<Record<string, unknown>>): RunnerDispatchEvent;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { redactText } from "../shared/redaction/redaction.js";
|
|
2
|
+
import { describeSkippedTests, mergeSkippedTests, readSkippedTests, } from "./pre-publication-skipped-tests.js";
|
|
3
|
+
import { ForgeFailureError, failureFactsFromError } from "./session.types.js";
|
|
4
|
+
// One pre-publication validation pass. A failed check no longer ends the pass: the remaining checks
|
|
5
|
+
// that can still meaningfully run keep going, so one in-place repair turn sees every independent
|
|
6
|
+
// failure at once instead of one per turn. The pass records each failure, says which checks it
|
|
7
|
+
// could not run because a check they depend on failed, and reports them all as one failure.
|
|
8
|
+
/** The check id a failed restart of the attempt's runtime stack before the pass is reported under. */
|
|
9
|
+
export const runtimeRestartCheckId = "host-runtime-restart";
|
|
10
|
+
const dotnetBuildCheckId = "dotnet-build-and-unit";
|
|
11
|
+
// Checks that build the .NET solution themselves and would only repeat the compiler errors once its
|
|
12
|
+
// compile step fails: the OpenAPI export builds Forge.Api and the E2E suite publishes it.
|
|
13
|
+
const dotnetBuildConsumers = new Set(["openapi-and-generated-types", "playwright-e2e"]);
|
|
14
|
+
// Checks that run against the attempt's application stack, which a failed restart left stopped.
|
|
15
|
+
const runtimeStackConsumers = new Set(["playwright-e2e"]);
|
|
16
|
+
// The diagnostics of each further failure that the error message carries; the repair prompt
|
|
17
|
+
// carries every failure's diagnostics in full.
|
|
18
|
+
const additionalFailureMessageDetail = 1500;
|
|
19
|
+
/**
|
|
20
|
+
* A failed validation pass. The single-check fields name the first failure, as they always have;
|
|
21
|
+
* `failures` lists every check that failed in the pass, in the order the checks ran.
|
|
22
|
+
*/
|
|
23
|
+
export class PrePublicationValidationError extends ForgeFailureError {
|
|
24
|
+
checkId;
|
|
25
|
+
exitCode;
|
|
26
|
+
command;
|
|
27
|
+
args;
|
|
28
|
+
detail;
|
|
29
|
+
code = "prepublication_validation_failed";
|
|
30
|
+
failures;
|
|
31
|
+
constructor(checkId, exitCode, command, args, detail, additionalFailures = []) {
|
|
32
|
+
super("prepublication_validation_failed", validationFailureMessage([{ checkId, exitCode, command, args, detail }, ...additionalFailures]), "bridge");
|
|
33
|
+
this.checkId = checkId;
|
|
34
|
+
this.exitCode = exitCode;
|
|
35
|
+
this.command = command;
|
|
36
|
+
this.args = args;
|
|
37
|
+
this.detail = detail;
|
|
38
|
+
this.name = "PrePublicationValidationError";
|
|
39
|
+
this.failures = [{ checkId, exitCode, command, args, detail }, ...additionalFailures];
|
|
40
|
+
}
|
|
41
|
+
/** Every failed check's id, first failure first. */
|
|
42
|
+
get checkIds() {
|
|
43
|
+
return this.failures.map(failure => failure.checkId);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function validationFailureMessage(failures) {
|
|
47
|
+
const [first, ...others] = failures;
|
|
48
|
+
const summary = (failure, detail) => `${failure.checkId} exited ${failure.exitCode}${detail ? `: ${detail}` : ""}`;
|
|
49
|
+
if (others.length === 0)
|
|
50
|
+
return `prepublication_validation_failed: ${summary(first, first.detail)}`;
|
|
51
|
+
// The other check ids come before the first detail, so a clipped failure message still names them.
|
|
52
|
+
const also = `[also failed: ${others.map(failure => failure.checkId).join(", ")}]`;
|
|
53
|
+
const more = others.map(failure => summary(failure, clipDetail(failure.detail)));
|
|
54
|
+
return `prepublication_validation_failed: ${first.checkId} exited ${first.exitCode} ${also}${first.detail ? `: ${first.detail}` : ""}`
|
|
55
|
+
+ `\n\nAlso failed in the same validation pass: ${more.join("\n\n")}`;
|
|
56
|
+
}
|
|
57
|
+
function clipDetail(detail) {
|
|
58
|
+
return detail.length <= additionalFailureMessageDetail
|
|
59
|
+
? detail
|
|
60
|
+
: `${detail.slice(0, additionalFailureMessageDetail)}… (clipped)`;
|
|
61
|
+
}
|
|
62
|
+
export class PrePublicationPass {
|
|
63
|
+
runtimeRestartFailure;
|
|
64
|
+
failures = [];
|
|
65
|
+
dotnetCompileFailed = false;
|
|
66
|
+
/** A failed runtime restart before the pass is its first failure. */
|
|
67
|
+
constructor(runtimeRestartFailure) {
|
|
68
|
+
this.runtimeRestartFailure = runtimeRestartFailure;
|
|
69
|
+
this.failures.push(...runtimeRestartFailure?.failures ?? []);
|
|
70
|
+
}
|
|
71
|
+
record(failure, failedStep) {
|
|
72
|
+
this.failures.push(failure);
|
|
73
|
+
if (failure.checkId === dotnetBuildCheckId && failedStep?.command === "dotnet" && failedStep.args[0] === "build") {
|
|
74
|
+
this.dotnetCompileFailed = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** The failed checks that keep this check from running meaningfully in this pass. */
|
|
78
|
+
blockers(checkId) {
|
|
79
|
+
return [
|
|
80
|
+
...(this.dotnetCompileFailed && dotnetBuildConsumers.has(checkId) ? [dotnetBuildCheckId] : []),
|
|
81
|
+
...(this.runtimeRestartFailure && runtimeStackConsumers.has(checkId) ? [runtimeRestartCheckId] : []),
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Whether an error ends the pass with the failures it already found. Only a classified retryable
|
|
86
|
+
* failure (a resource hold, lost infrastructure, a supervisor that did not start) does, once the
|
|
87
|
+
* pass has found a failure: the repair turn can fix those failures now, and the next pass meets
|
|
88
|
+
* the condition again. Any other error, or cancellation, still ends the attempt as it did.
|
|
89
|
+
*/
|
|
90
|
+
stopsAt(error, signal) {
|
|
91
|
+
if (this.failures.length === 0 || signal?.aborted || !(error instanceof ForgeFailureError))
|
|
92
|
+
return false;
|
|
93
|
+
return failureFactsFromError(error).retryability === "retryable";
|
|
94
|
+
}
|
|
95
|
+
stoppedEvent(checkId, error) {
|
|
96
|
+
const failedCheckIds = this.failures.map(failure => failure.checkId);
|
|
97
|
+
return validationEvent("prepublication_validation_pass_stopped", checkId, `Stopped this pre-publication pass at '${checkId}' (${error.failureCode}). Reporting the ${failedCheckIds.length} failed check${failedCheckIds.length === 1 ? "" : "s"} it already found (${failedCheckIds.join(", ")}) for repair; the next pass runs '${checkId}' again.`, { failureCode: error.failureCode, failedCheckIds });
|
|
98
|
+
}
|
|
99
|
+
/** Throws every failure the pass found as one validation failure. */
|
|
100
|
+
throwIfFailed() {
|
|
101
|
+
const [first, ...others] = this.failures;
|
|
102
|
+
if (!first)
|
|
103
|
+
return;
|
|
104
|
+
throw new PrePublicationValidationError(first.checkId, first.exitCode, first.command, first.args, first.detail, others);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export function skippedCheckEvent(checkId, blockedBy) {
|
|
108
|
+
const reason = blockedBy.map(blocker => blocker === runtimeRestartCheckId
|
|
109
|
+
? "the attempt's runtime stack, whose restart failed"
|
|
110
|
+
: `the .NET build, which failed in '${blocker}'`).join(" and ");
|
|
111
|
+
return validationEvent("prepublication_validation_skipped", checkId, `Skipped pre-publication CI parity check '${checkId}' in this pass: it needs ${reason}. The next pass runs it again.`, { blockedBy });
|
|
112
|
+
}
|
|
113
|
+
/** The tests a check's steps skipped, so a check that passed with skips says so with each reason. */
|
|
114
|
+
export class SkippedTestTally {
|
|
115
|
+
worktreePath;
|
|
116
|
+
environment;
|
|
117
|
+
summary = { count: 0, reasons: [] };
|
|
118
|
+
constructor(worktreePath, environment) {
|
|
119
|
+
this.worktreePath = worktreePath;
|
|
120
|
+
this.environment = environment;
|
|
121
|
+
}
|
|
122
|
+
/** The invocation's own arguments: a managed attempt may direct results to its test-output root. */
|
|
123
|
+
async add(args, stepStartedMs) {
|
|
124
|
+
this.summary = mergeSkippedTests(this.summary, await readSkippedTests(this.worktreePath, args, stepStartedMs, this.environment));
|
|
125
|
+
}
|
|
126
|
+
passedEvent(checkId, secrets) {
|
|
127
|
+
const skipped = {
|
|
128
|
+
...this.summary,
|
|
129
|
+
reasons: this.summary.reasons.map(entry => ({ ...entry, reason: redactText(entry.reason, secrets) })),
|
|
130
|
+
};
|
|
131
|
+
if (skipped.count === 0) {
|
|
132
|
+
return validationEvent("prepublication_validation_passed", checkId, `Pre-publication CI parity check '${checkId}' passed.`);
|
|
133
|
+
}
|
|
134
|
+
return validationEvent("prepublication_validation_passed", checkId, `Pre-publication CI parity check '${checkId}' passed with ${describeSkippedTests(skipped)}.`, { skippedTests: skipped.count, skippedReasons: skipped.reasons });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export function validationEvent(eventType, checkId, content, detail) {
|
|
138
|
+
return {
|
|
139
|
+
role: "runner",
|
|
140
|
+
kind: "checkpoint",
|
|
141
|
+
content,
|
|
142
|
+
eventType,
|
|
143
|
+
data: JSON.stringify({ checkId, contractId: "forge-ci-parity-v1", ...detail }),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
@@ -3,6 +3,7 @@ import type { NativeTestPostgresFallback } from "../runtime/native-test-postgres
|
|
|
3
3
|
import type { HostLoadStepGate } from "../runtime/host-load-governor.js";
|
|
4
4
|
import { type PrePublicationHostLoadOwner } from "./pre-publication-host-load.js";
|
|
5
5
|
import { type ValidationStep } from "./pre-publication-step-execution.js";
|
|
6
|
+
import { PrePublicationValidationError, type PrePublicationCheckFailure } from "./pre-publication-pass.js";
|
|
6
7
|
import type { ProviderProcessRunner } from "./provider-cli/provider-cli.process.js";
|
|
7
8
|
import { ForgeFailureError, type RunnerDispatchEvent } from "./session.types.js";
|
|
8
9
|
export type PrePublicationProfile = "implementation" | "comment_repair" | "ci_repair" | "conflict_repair";
|
|
@@ -34,16 +35,13 @@ export interface PrePublicationExecutionContext {
|
|
|
34
35
|
readonly processRunner?: ProviderProcessRunner;
|
|
35
36
|
/** The attempt governed steps reserve host capacity for (decision 0013). */
|
|
36
37
|
readonly hostLoadOwner?: PrePublicationHostLoadOwner;
|
|
38
|
+
/**
|
|
39
|
+
* The failed restart of the attempt's runtime stack before this pass. The pass reports it with
|
|
40
|
+
* its own failures and does not run the checks that need the stopped stack.
|
|
41
|
+
*/
|
|
42
|
+
readonly runtimeRestartFailure?: PrePublicationValidationError;
|
|
37
43
|
}
|
|
38
|
-
export
|
|
39
|
-
readonly checkId: string;
|
|
40
|
-
readonly exitCode: number;
|
|
41
|
-
readonly command: string;
|
|
42
|
-
readonly args: readonly string[];
|
|
43
|
-
readonly detail: string;
|
|
44
|
-
readonly code = "prepublication_validation_failed";
|
|
45
|
-
constructor(checkId: string, exitCode: number, command: string, args: readonly string[], detail: string);
|
|
46
|
-
}
|
|
44
|
+
export { PrePublicationValidationError, type PrePublicationCheckFailure };
|
|
47
45
|
export declare class PrePublicationInfrastructureError extends ForgeFailureError {
|
|
48
46
|
readonly checkId: string;
|
|
49
47
|
readonly exitCode: number;
|
|
@@ -59,11 +57,24 @@ export declare class PrePublicationValidator {
|
|
|
59
57
|
private readonly nativeTestPostgresFallback;
|
|
60
58
|
private readonly hostLoad?;
|
|
61
59
|
constructor(commands?: PrePublicationCommandRunner, dockerEngineProbe?: DockerEngineProbe | undefined, nativeTestPostgresFallback?: () => NativeTestPostgresFallback | null, hostLoad?: HostLoadStepGate | undefined);
|
|
60
|
+
/**
|
|
61
|
+
* Runs one pre-publication pass. A failed check does not end the pass: every remaining check that
|
|
62
|
+
* can still meaningfully run keeps going, and the pass then throws all of its failures as one
|
|
63
|
+
* PrePublicationValidationError.
|
|
64
|
+
*/
|
|
62
65
|
validate(worktreePath: string, profile: PrePublicationProfile, capabilities: ReadonlySet<string>, emit?: (event: RunnerDispatchEvent) => Promise<void>, signal?: AbortSignal, execution?: PrePublicationExecutionContext): Promise<readonly string[]>;
|
|
66
|
+
private runChecks;
|
|
67
|
+
/** Runs one check's steps in order; the first failed step ends the check, since later steps use its output. */
|
|
68
|
+
private runCheck;
|
|
69
|
+
/** Runs a step, confirming once a failure that matches a known transient pattern. */
|
|
70
|
+
private runConfirmedStep;
|
|
71
|
+
private runCheckedStep;
|
|
72
|
+
private confirmStep;
|
|
73
|
+
private confirmInfrastructure;
|
|
63
74
|
/** Returns the native fallback connection when this check must use it instead of Docker. */
|
|
64
75
|
private ensurePrerequisite;
|
|
65
76
|
private throwIfPrerequisiteWasLost;
|
|
66
|
-
private
|
|
77
|
+
private checkTestOnlyExports;
|
|
67
78
|
private changedPaths;
|
|
68
79
|
private assertContractMatchesDispatchBaseline;
|
|
69
80
|
private runStep;
|
|
@@ -72,4 +83,3 @@ export declare class PrePublicationValidator {
|
|
|
72
83
|
}
|
|
73
84
|
export declare function applicableChecks(contract: ValidationContract, profile: PrePublicationProfile | "github_actions", changedPaths: readonly string[]): readonly ValidationCheck[];
|
|
74
85
|
export declare function loadValidationContract(worktreePath: string): Promise<ValidationContract | null>;
|
|
75
|
-
export {};
|