@loucompanion/forge-bridge 0.1.4-dev.a690038a6849 → 0.1.4-dev.b1c678efffd2
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 +44 -2
- package/dist/bridge/bridge-chat-provider-command.d.ts +16 -0
- package/dist/bridge/bridge-chat-provider-command.js +125 -0
- package/dist/bridge/bridge.base.d.ts +9 -0
- package/dist/bridge/bridge.service.d.ts +73 -2
- package/dist/bridge/bridge.service.js +312 -119
- package/dist/bridge/bridge.types.d.ts +16 -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 +2 -0
- package/dist/bridge/runner-host-capabilities.js +4 -0
- package/dist/bridge/test-postgres-capability.d.ts +14 -0
- package/dist/bridge/test-postgres-capability.js +120 -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 +142 -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/host-load-admission.d.ts +60 -0
- package/dist/runtime/host-load-admission.js +99 -0
- package/dist/runtime/host-load-child-environment.d.ts +22 -0
- package/dist/runtime/host-load-child-environment.js +67 -0
- package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
- package/dist/runtime/host-load-forge-cgroups.js +140 -0
- package/dist/runtime/host-load-governor-config.d.ts +43 -0
- package/dist/runtime/host-load-governor-config.js +76 -0
- package/dist/runtime/host-load-governor.d.ts +174 -0
- package/dist/runtime/host-load-governor.js +541 -0
- package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
- package/dist/runtime/host-load-ledger-lock.js +185 -0
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +78 -0
- package/dist/runtime/host-load-sampler.d.ts +43 -0
- package/dist/runtime/host-load-sampler.js +74 -6
- package/dist/runtime/host-load-step-class.d.ts +68 -0
- package/dist/runtime/host-load-step-class.js +106 -0
- 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-token-ledger.d.ts +174 -0
- package/dist/runtime/host-load-token-ledger.js +421 -0
- package/dist/runtime/host-pressure-stall.d.ts +21 -1
- package/dist/runtime/host-pressure-stall.js +48 -1
- package/dist/runtime/host-runtime-contract.d.ts +3 -0
- package/dist/runtime/host-runtime-contract.js +4 -1
- package/dist/runtime/host-runtime-lease.d.ts +74 -4
- package/dist/runtime/host-runtime-lease.js +281 -11
- package/dist/runtime/host-runtime-promotion.d.ts +23 -0
- package/dist/runtime/host-runtime-promotion.js +48 -0
- package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
- package/dist/runtime/host-runtime-requirements-check.js +29 -0
- package/dist/runtime/host-runtime-requirements.d.ts +36 -0
- package/dist/runtime/host-runtime-requirements.js +117 -0
- 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 +107 -0
- package/dist/sandbox/host-capacity-broker.js +315 -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/managed-attempt-tools.d.ts +2 -0
- package/dist/session/managed-attempt-tools.js +156 -37
- package/dist/session/managed-command-host-load.d.ts +45 -0
- package/dist/session/managed-command-host-load.js +82 -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 +94 -25
- 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 +49 -19
- 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 +206 -221
- package/dist/session/phase-completion.validation.d.ts +2 -3
- package/dist/session/phase-completion.validation.js +46 -92
- package/dist/session/pre-publication-host-load.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +111 -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-process.d.ts +3 -0
- package/dist/session/pre-publication-process.js +23 -11
- package/dist/session/pre-publication-step-execution.d.ts +11 -0
- package/dist/session/pre-publication-step-execution.js +49 -0
- package/dist/session/pre-publication-validation.d.ts +30 -20
- package/dist/session/pre-publication-validation.js +166 -155
- 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.artifacts.js +15 -3
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +14 -6
- package/dist/session/provider-cli/provider-cli.process.js +29 -61
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +2 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +52 -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 +107 -153
- package/dist/session/provider-cli/provider-cli.types.d.ts +30 -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-state.d.ts +2 -0
- package/dist/session/provider-cli/provider-output-state.js +6 -0
- package/dist/session/publishable-worktree-changes.d.ts +10 -1
- package/dist/session/publishable-worktree-changes.js +21 -5
- package/dist/session/sandbox-host-capacity-gate.d.ts +30 -0
- package/dist/session/sandbox-host-capacity-gate.js +229 -0
- package/dist/session/session.base.d.ts +9 -1
- package/dist/session/session.service.d.ts +9 -2
- package/dist/session/session.service.js +120 -5
- package/dist/session/session.types.d.ts +3 -0
- package/dist/session/session.types.js +7 -4
- 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/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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PrePublicationExecutionContext } from "./pre-publication-validation.js";
|
|
2
|
+
export interface ValidationStep {
|
|
3
|
+
readonly command: string;
|
|
4
|
+
readonly fallbackCommand?: string;
|
|
5
|
+
readonly args: readonly string[];
|
|
6
|
+
readonly fallbackArgs?: readonly string[];
|
|
7
|
+
readonly assertUnchangedPaths?: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function managedAttemptInvocation(checkId: string, step: ValidationStep, environment?: Readonly<Record<string, string>>): Pick<ValidationStep, "command" | "args">;
|
|
10
|
+
export declare function supportsNativeTestPostgresFallback(checkId: string): boolean;
|
|
11
|
+
export declare function validationExecutionForStep(checkId: string, step: ValidationStep, execution?: PrePublicationExecutionContext, postgresAdminConnection?: string): PrePublicationExecutionContext | undefined;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { nativeTestPostgresFallbackEnvironment, parseNativeTestPostgresFallback, } from "../runtime/native-test-postgres-fallback.js";
|
|
2
|
+
import { ForgeFailureError } from "./session.types.js";
|
|
3
|
+
export function managedAttemptInvocation(checkId, step, environment) {
|
|
4
|
+
const playwrightConfig = environment?.FORGE_PLAYWRIGHT_CONFIG?.trim();
|
|
5
|
+
const attemptOwned = environment?.FORGE_E2E_OWNERSHIP_MODE === "attempt"
|
|
6
|
+
|| Boolean(environment?.FORGE_DISPATCH_ATTEMPT_ID?.trim());
|
|
7
|
+
if (checkId !== "playwright-e2e" || !attemptOwned) {
|
|
8
|
+
return step;
|
|
9
|
+
}
|
|
10
|
+
if (!playwrightConfig) {
|
|
11
|
+
throw new ForgeFailureError("prepublication_capability_unavailable", "prepublication_capability_unavailable: playwright-e2e requires the Bridge-generated FORGE_PLAYWRIGHT_CONFIG for a managed attempt.", "bridge");
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
command: "pnpm",
|
|
15
|
+
args: ["--dir", "tests/e2e", "exec", "playwright", "test", "--config", playwrightConfig],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const nativeFallbackCheckIds = new Set([
|
|
19
|
+
"owned-suite-registration",
|
|
20
|
+
"dotnet-build-and-unit",
|
|
21
|
+
"comment-repair-dotnet-regression",
|
|
22
|
+
]);
|
|
23
|
+
const nativeFallbackDotnetTierScripts = [
|
|
24
|
+
"scripts/run-dotnet-test-tier.ps1",
|
|
25
|
+
"scripts/run-dotnet-test-tier-set.ps1",
|
|
26
|
+
"scripts/run-affected-dotnet-tests.mjs",
|
|
27
|
+
];
|
|
28
|
+
export function supportsNativeTestPostgresFallback(checkId) {
|
|
29
|
+
return nativeFallbackCheckIds.has(checkId);
|
|
30
|
+
}
|
|
31
|
+
export function validationExecutionForStep(checkId, step, execution, postgresAdminConnection) {
|
|
32
|
+
// The connection only exists when Docker is unavailable and the operator
|
|
33
|
+
// provisioned a dedicated native test cluster. Only the runner-authored
|
|
34
|
+
// .NET test tiers and the suite-identity check receive it; build, client,
|
|
35
|
+
// Bridge, and E2E steps never do.
|
|
36
|
+
if (!postgresAdminConnection || !nativeFallbackCheckIds.has(checkId))
|
|
37
|
+
return execution;
|
|
38
|
+
const runsDotnetTier = step.args.some(argument => nativeFallbackDotnetTierScripts
|
|
39
|
+
.some(script => argument.replaceAll("\\", "/").endsWith(script)));
|
|
40
|
+
if (checkId !== "owned-suite-registration" && !runsDotnetTier)
|
|
41
|
+
return execution;
|
|
42
|
+
return {
|
|
43
|
+
...execution,
|
|
44
|
+
environment: {
|
|
45
|
+
...execution?.environment,
|
|
46
|
+
...nativeTestPostgresFallbackEnvironment(parseNativeTestPostgresFallback(postgresAdminConnection)),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import type { DockerEngineProbe } from "../runtime/docker-engine-probe.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { NativeTestPostgresFallback } from "../runtime/native-test-postgres-fallback.js";
|
|
3
|
+
import type { HostLoadStepGate } from "../runtime/host-load-governor.js";
|
|
4
|
+
import { type PrePublicationHostLoadOwner } from "./pre-publication-host-load.js";
|
|
5
|
+
import { type ValidationStep } from "./pre-publication-step-execution.js";
|
|
6
|
+
import { PrePublicationValidationError, type PrePublicationCheckFailure } from "./pre-publication-pass.js";
|
|
3
7
|
import type { ProviderProcessRunner } from "./provider-cli/provider-cli.process.js";
|
|
4
8
|
import { ForgeFailureError, type RunnerDispatchEvent } from "./session.types.js";
|
|
5
9
|
export type PrePublicationProfile = "implementation" | "comment_repair" | "ci_repair" | "conflict_repair";
|
|
6
|
-
interface ValidationStep {
|
|
7
|
-
readonly command: string;
|
|
8
|
-
readonly fallbackCommand?: string;
|
|
9
|
-
readonly args: readonly string[];
|
|
10
|
-
readonly fallbackArgs?: readonly string[];
|
|
11
|
-
readonly assertUnchangedPaths?: readonly string[];
|
|
12
|
-
}
|
|
13
10
|
interface ValidationCheck {
|
|
14
11
|
readonly id: string;
|
|
15
12
|
readonly profiles: readonly string[];
|
|
@@ -36,16 +33,15 @@ export interface PrePublicationExecutionContext {
|
|
|
36
33
|
readonly baselineRevision?: string;
|
|
37
34
|
readonly environment?: Readonly<Record<string, string>>;
|
|
38
35
|
readonly processRunner?: ProviderProcessRunner;
|
|
36
|
+
/** The attempt governed steps reserve host capacity for (decision 0013). */
|
|
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;
|
|
39
43
|
}
|
|
40
|
-
export
|
|
41
|
-
readonly checkId: string;
|
|
42
|
-
readonly exitCode: number;
|
|
43
|
-
readonly command: string;
|
|
44
|
-
readonly args: readonly string[];
|
|
45
|
-
readonly detail: string;
|
|
46
|
-
readonly code = "prepublication_validation_failed";
|
|
47
|
-
constructor(checkId: string, exitCode: number, command: string, args: readonly string[], detail: string);
|
|
48
|
-
}
|
|
44
|
+
export { PrePublicationValidationError, type PrePublicationCheckFailure };
|
|
49
45
|
export declare class PrePublicationInfrastructureError extends ForgeFailureError {
|
|
50
46
|
readonly checkId: string;
|
|
51
47
|
readonly exitCode: number;
|
|
@@ -59,17 +55,31 @@ export declare class PrePublicationValidator {
|
|
|
59
55
|
private readonly commands;
|
|
60
56
|
private readonly dockerEngineProbe?;
|
|
61
57
|
private readonly nativeTestPostgresFallback;
|
|
62
|
-
|
|
58
|
+
private readonly hostLoad?;
|
|
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
|
+
*/
|
|
63
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;
|
|
64
74
|
/** Returns the native fallback connection when this check must use it instead of Docker. */
|
|
65
75
|
private ensurePrerequisite;
|
|
66
76
|
private throwIfPrerequisiteWasLost;
|
|
67
|
-
private
|
|
77
|
+
private checkTestOnlyExports;
|
|
68
78
|
private changedPaths;
|
|
69
79
|
private assertContractMatchesDispatchBaseline;
|
|
70
80
|
private runStep;
|
|
81
|
+
private launchStep;
|
|
71
82
|
private runCommand;
|
|
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 {};
|
|
@@ -3,11 +3,13 @@ import fs from "node:fs/promises";
|
|
|
3
3
|
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
|
-
import {
|
|
6
|
+
import { runHostGovernedValidationStep } from "./pre-publication-host-load.js";
|
|
7
|
+
import { managedAttemptInvocation, supportsNativeTestPostgresFallback, validationExecutionForStep, } from "./pre-publication-step-execution.js";
|
|
7
8
|
import { hostRuntimeLegacyTestPostgresEnvironment, hostRuntimeTestPostgresAdminEnvironment, hostRuntimeTestPostgresProvisionerEnvironment, } from "../runtime/host-runtime-contract.js";
|
|
8
9
|
import { redactText } from "../shared/redaction/redaction.js";
|
|
9
|
-
import {
|
|
10
|
+
import { PrePublicationPass, PrePublicationValidationError, SkippedTestTally, skippedCheckEvent, validationEvent, } from "./pre-publication-pass.js";
|
|
10
11
|
import { ProcessPrePublicationCommandRunner, pnpmDirectoryLaunch } from "./pre-publication-process.js";
|
|
12
|
+
import { ProcessTreeTerminationError } from "../shared/process/process.js";
|
|
11
13
|
import { findUnreferencedNewExports } from "./unreferenced-exports.js";
|
|
12
14
|
import { ForgeFailureError, sanitizeFailureError, } from "./session.types.js";
|
|
13
15
|
const contractRelativePath = ".forge/validation/ci-parity.v1.json";
|
|
@@ -46,23 +48,31 @@ const approvedContractDigests = new Set([
|
|
|
46
48
|
...compatibleApprovedContractDigests,
|
|
47
49
|
]);
|
|
48
50
|
const ansiColorSequence = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "gu");
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
const timeoutConfirmation = {
|
|
52
|
+
started: [
|
|
53
|
+
"prepublication_validation_timeout_confirmation_started",
|
|
54
|
+
"The full client test step reported only Vitest timeouts; confirming once with the same command and attempt environment.",
|
|
55
|
+
],
|
|
56
|
+
passed: [
|
|
57
|
+
"prepublication_validation_timeout_confirmation_passed",
|
|
58
|
+
"The complete client test step passed on its single timeout confirmation run.",
|
|
59
|
+
],
|
|
60
|
+
failedEvent: "prepublication_validation_timeout_confirmation_failed",
|
|
61
|
+
failedContent: exitCode => `The complete client test step failed on its single timeout confirmation run (exit ${exitCode}).`,
|
|
62
|
+
};
|
|
63
|
+
const cleanupConfirmation = {
|
|
64
|
+
started: [
|
|
65
|
+
"prepublication_validation_cleanup_confirmation_started",
|
|
66
|
+
"The Bridge suite hit the known Windows temporary-worktree cleanup race; confirming once with the same command and attempt environment.",
|
|
67
|
+
],
|
|
68
|
+
passed: [
|
|
69
|
+
"prepublication_validation_cleanup_confirmation_passed",
|
|
70
|
+
"The complete Bridge test step passed on its single cleanup confirmation run.",
|
|
71
|
+
],
|
|
72
|
+
failedEvent: "prepublication_validation_cleanup_confirmation_failed",
|
|
73
|
+
failedContent: exitCode => `The complete Bridge test step failed on its single cleanup confirmation run (exit ${exitCode}).`,
|
|
74
|
+
};
|
|
75
|
+
export { PrePublicationValidationError };
|
|
66
76
|
export class PrePublicationInfrastructureError extends ForgeFailureError {
|
|
67
77
|
checkId;
|
|
68
78
|
exitCode;
|
|
@@ -84,115 +94,162 @@ export class PrePublicationValidator {
|
|
|
84
94
|
commands;
|
|
85
95
|
dockerEngineProbe;
|
|
86
96
|
nativeTestPostgresFallback;
|
|
87
|
-
|
|
97
|
+
hostLoad;
|
|
98
|
+
constructor(commands = new ProcessPrePublicationCommandRunner(), dockerEngineProbe, nativeTestPostgresFallback = () => null, hostLoad) {
|
|
88
99
|
this.commands = commands;
|
|
89
100
|
this.dockerEngineProbe = dockerEngineProbe;
|
|
90
101
|
this.nativeTestPostgresFallback = nativeTestPostgresFallback;
|
|
102
|
+
this.hostLoad = hostLoad;
|
|
91
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Runs one pre-publication pass. A failed check does not end the pass: every remaining check that
|
|
106
|
+
* can still meaningfully run keeps going, and the pass then throws all of its failures as one
|
|
107
|
+
* PrePublicationValidationError.
|
|
108
|
+
*/
|
|
92
109
|
async validate(worktreePath, profile, capabilities, emit, signal, execution) {
|
|
93
110
|
const checksExports = profile === "implementation" || profile === "comment_repair";
|
|
111
|
+
const pass = new PrePublicationPass(execution?.runtimeRestartFailure);
|
|
94
112
|
const contract = await loadValidationContract(worktreePath);
|
|
95
113
|
if (contract === null) {
|
|
96
114
|
await emit?.(validationEvent("prepublication_validation_legacy_contract", "legacy-provider-validation", `This checkout predates ${contractRelativePath}; Bridge preserved legacy provider validation without source mutation.`));
|
|
97
115
|
if (checksExports) {
|
|
98
116
|
const legacy = await prepareValidationExecution(execution);
|
|
99
117
|
try {
|
|
100
|
-
await this.
|
|
118
|
+
await this.checkTestOnlyExports(pass, worktreePath, emit, signal, legacy.execution);
|
|
101
119
|
}
|
|
102
120
|
finally {
|
|
103
121
|
await legacy.cleanup();
|
|
104
122
|
}
|
|
105
123
|
}
|
|
124
|
+
pass.throwIfFailed();
|
|
106
125
|
return [];
|
|
107
126
|
}
|
|
108
127
|
const scoped = await prepareValidationExecution(execution);
|
|
109
128
|
try {
|
|
110
129
|
if (checksExports)
|
|
111
|
-
await this.
|
|
130
|
+
await this.checkTestOnlyExports(pass, worktreePath, emit, signal, scoped.execution);
|
|
112
131
|
const contractDigest = validationContractDigest(contract);
|
|
113
132
|
await this.assertContractMatchesDispatchBaseline(worktreePath, contractDigest, signal, scoped.execution);
|
|
114
133
|
if (contractDigest !== currentApprovedContractDigest) {
|
|
115
134
|
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}.`));
|
|
116
135
|
}
|
|
117
136
|
const changedPaths = await this.changedPaths(worktreePath, signal, scoped.execution);
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
const postgresAdminConnection = await this.ensurePrerequisite(check, scoped.execution?.environment, scoped.postgresAdminConnection, emit) ?? scoped.postgresAdminConnection;
|
|
129
|
-
await emit?.(validationEvent("prepublication_validation_started", check.id, `Running pre-publication CI parity check '${check.id}'.`));
|
|
130
|
-
let skipped = { count: 0, reasons: [] };
|
|
131
|
-
for (const step of check.steps) {
|
|
132
|
-
const stepStartedMs = Date.now() - 1000;
|
|
133
|
-
let result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection);
|
|
134
|
-
await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
|
|
135
|
-
if (isTimeoutOnlyClientTestFailure(check.id, step, result)) {
|
|
136
|
-
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."));
|
|
137
|
-
result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection);
|
|
138
|
-
await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
|
|
139
|
-
await emit?.(validationEvent(result.exitCode === 0
|
|
140
|
-
? "prepublication_validation_timeout_confirmation_passed"
|
|
141
|
-
: "prepublication_validation_timeout_confirmation_failed", check.id, result.exitCode === 0
|
|
142
|
-
? "The complete client test step passed on its single timeout confirmation run."
|
|
143
|
-
: `The complete client test step failed on its single timeout confirmation run (exit ${result.exitCode}).`));
|
|
144
|
-
}
|
|
145
|
-
if (isTransientBridgeCleanupFailure(check.id, step, result)) {
|
|
146
|
-
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."));
|
|
147
|
-
result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection);
|
|
148
|
-
await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
|
|
149
|
-
await emit?.(validationEvent(result.exitCode === 0
|
|
150
|
-
? "prepublication_validation_cleanup_confirmation_passed"
|
|
151
|
-
: "prepublication_validation_cleanup_confirmation_failed", check.id, result.exitCode === 0
|
|
152
|
-
? "The complete Bridge test step passed on its single cleanup confirmation run."
|
|
153
|
-
: `The complete Bridge test step failed on its single cleanup confirmation run (exit ${result.exitCode}).`));
|
|
154
|
-
}
|
|
155
|
-
if (isTransientShellInfrastructureFailure(result)) {
|
|
156
|
-
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."));
|
|
157
|
-
result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection);
|
|
158
|
-
await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
|
|
159
|
-
const infrastructureFailed = isTransientShellInfrastructureFailure(result);
|
|
160
|
-
await emit?.(validationEvent(infrastructureFailed
|
|
161
|
-
? "prepublication_infrastructure_confirmation_failed"
|
|
162
|
-
: "prepublication_infrastructure_confirmation_passed", check.id, infrastructureFailed
|
|
163
|
-
? `The validation shell failed again on its single infrastructure confirmation run (exit ${result.exitCode}).`
|
|
164
|
-
: result.exitCode === 0
|
|
165
|
-
? "The validation step recovered on its single infrastructure confirmation run."
|
|
166
|
-
: "The host-runtime failure did not recur; continuing with normal validation failure handling."));
|
|
167
|
-
if (infrastructureFailed) {
|
|
168
|
-
const detail = diagnosticDetail(result);
|
|
169
|
-
await emit?.(validationEvent("prepublication_infrastructure_failed", check.id, `Pre-publication infrastructure for '${check.id}' remained unavailable${detail ? `: ${detail}` : "."}`));
|
|
170
|
-
throw new PrePublicationInfrastructureError(check.id, result.exitCode, result.command, result.args, detail);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (result.exitCode !== 0) {
|
|
174
|
-
const detail = diagnosticDetail(result);
|
|
175
|
-
await emit?.(validationEvent("prepublication_validation_failed", check.id, `Pre-publication CI parity check '${check.id}' exited ${result.exitCode}${detail ? `: ${detail}` : "."}`));
|
|
176
|
-
throw new PrePublicationValidationError(check.id, result.exitCode, result.command, result.args, detail);
|
|
177
|
-
}
|
|
178
|
-
// The invocation's own arguments: a managed attempt may direct results to its test-output root.
|
|
179
|
-
skipped = mergeSkippedTests(skipped, await readSkippedTests(worktreePath, result.args, stepStartedMs, scoped.execution?.environment));
|
|
180
|
-
}
|
|
181
|
-
completed.push(check.id);
|
|
182
|
-
// A pass that skipped tests says so, with each reason, instead of reading as a plain pass.
|
|
183
|
-
const secrets = validationExactSecrets(scoped.execution?.environment);
|
|
184
|
-
skipped = { ...skipped, reasons: skipped.reasons.map(entry => ({ ...entry, reason: redactText(entry.reason, secrets) })) };
|
|
185
|
-
const skippedDetail = skipped.count > 0 ? describeSkippedTests(skipped) : undefined;
|
|
186
|
-
await emit?.(validationEvent("prepublication_validation_passed", check.id, skippedDetail
|
|
187
|
-
? `Pre-publication CI parity check '${check.id}' passed with ${skippedDetail}.`
|
|
188
|
-
: `Pre-publication CI parity check '${check.id}' passed.`, skipped.count > 0 ? { skippedTests: skipped.count, skippedReasons: skipped.reasons } : undefined));
|
|
189
|
-
}
|
|
190
|
-
return completed;
|
|
137
|
+
const run = {
|
|
138
|
+
worktreePath,
|
|
139
|
+
capabilities,
|
|
140
|
+
emit,
|
|
141
|
+
signal,
|
|
142
|
+
execution: scoped.execution,
|
|
143
|
+
postgresAdminConnection: scoped.postgresAdminConnection,
|
|
144
|
+
};
|
|
145
|
+
return await this.runChecks(applicableChecks(contract, profile, changedPaths), run, pass);
|
|
191
146
|
}
|
|
192
147
|
finally {
|
|
193
148
|
await scoped.cleanup();
|
|
194
149
|
}
|
|
195
150
|
}
|
|
151
|
+
async runChecks(checks, run, pass) {
|
|
152
|
+
const completed = [];
|
|
153
|
+
for (const check of checks) {
|
|
154
|
+
if (check.providerOnly) {
|
|
155
|
+
await run.emit?.(validationEvent("prepublication_validation_provider_only", check.id, `Preserved provider-only validation '${check.id}' for the provider check run.`));
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const blockedBy = pass.blockers(check.id);
|
|
159
|
+
if (blockedBy.length > 0) {
|
|
160
|
+
await run.emit?.(skippedCheckEvent(check.id, blockedBy));
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const failed = await this.runCheck(check, run);
|
|
165
|
+
// A cancelled step may settle with an exit code rather than throw; the pass ends either way.
|
|
166
|
+
run.signal?.throwIfAborted();
|
|
167
|
+
if (failed)
|
|
168
|
+
pass.record(failed.failure, failed.step);
|
|
169
|
+
else
|
|
170
|
+
completed.push(check.id);
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
if (!pass.stopsAt(error, run.signal))
|
|
174
|
+
throw error;
|
|
175
|
+
await run.emit?.(pass.stoppedEvent(check.id, error));
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
pass.throwIfFailed();
|
|
180
|
+
return completed;
|
|
181
|
+
}
|
|
182
|
+
/** Runs one check's steps in order; the first failed step ends the check, since later steps use its output. */
|
|
183
|
+
async runCheck(check, run) {
|
|
184
|
+
if (check.requiredCapability && !run.capabilities.has(check.requiredCapability)) {
|
|
185
|
+
throw new ForgeFailureError("prepublication_capability_unavailable", `prepublication_capability_unavailable: ${check.id} requires ${check.requiredCapability}; publication is holding until a capable runner is available.`, "bridge");
|
|
186
|
+
}
|
|
187
|
+
const postgresAdminConnection = await this.ensurePrerequisite(check, run.execution?.environment, run.postgresAdminConnection, run.emit) ?? run.postgresAdminConnection;
|
|
188
|
+
const stepRun = { ...run, check, postgresAdminConnection };
|
|
189
|
+
await run.emit?.(validationEvent("prepublication_validation_started", check.id, `Running pre-publication CI parity check '${check.id}'.`));
|
|
190
|
+
const skipped = new SkippedTestTally(run.worktreePath, run.execution?.environment);
|
|
191
|
+
for (const step of check.steps) {
|
|
192
|
+
const stepStartedMs = Date.now() - 1000;
|
|
193
|
+
const result = await this.runConfirmedStep(stepRun, step);
|
|
194
|
+
if (result.exitCode !== 0) {
|
|
195
|
+
const detail = diagnosticDetail(result);
|
|
196
|
+
await run.emit?.(validationEvent("prepublication_validation_failed", check.id, `Pre-publication CI parity check '${check.id}' exited ${result.exitCode}${detail ? `: ${detail}` : "."}`));
|
|
197
|
+
return {
|
|
198
|
+
failure: { checkId: check.id, exitCode: result.exitCode, command: result.command, args: result.args, detail },
|
|
199
|
+
step,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
await skipped.add(result.args, stepStartedMs);
|
|
203
|
+
}
|
|
204
|
+
await run.emit?.(skipped.passedEvent(check.id, validationExactSecrets(run.execution?.environment)));
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
/** Runs a step, confirming once a failure that matches a known transient pattern. */
|
|
208
|
+
async runConfirmedStep(run, step) {
|
|
209
|
+
let result = await this.runCheckedStep(run, step);
|
|
210
|
+
if (isTimeoutOnlyClientTestFailure(run.check.id, step, result)) {
|
|
211
|
+
result = await this.confirmStep(run, step, timeoutConfirmation);
|
|
212
|
+
}
|
|
213
|
+
if (isTransientBridgeCleanupFailure(run.check.id, step, result)) {
|
|
214
|
+
result = await this.confirmStep(run, step, cleanupConfirmation);
|
|
215
|
+
}
|
|
216
|
+
if (isTransientShellInfrastructureFailure(result)) {
|
|
217
|
+
result = await this.confirmInfrastructure(run, step);
|
|
218
|
+
}
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
async runCheckedStep(run, step) {
|
|
222
|
+
const { check, worktreePath, signal, execution, postgresAdminConnection, emit } = run;
|
|
223
|
+
const result = await this.runStep(check.id, step, worktreePath, signal, execution, postgresAdminConnection, emit);
|
|
224
|
+
await this.throwIfPrerequisiteWasLost(check, result, execution?.environment, postgresAdminConnection, emit);
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
async confirmStep(run, step, confirmation) {
|
|
228
|
+
await run.emit?.(validationEvent(confirmation.started[0], run.check.id, confirmation.started[1]));
|
|
229
|
+
const result = await this.runCheckedStep(run, step);
|
|
230
|
+
await run.emit?.(result.exitCode === 0
|
|
231
|
+
? validationEvent(confirmation.passed[0], run.check.id, confirmation.passed[1])
|
|
232
|
+
: validationEvent(confirmation.failedEvent, run.check.id, confirmation.failedContent(result.exitCode)));
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
235
|
+
async confirmInfrastructure(run, step) {
|
|
236
|
+
const checkId = run.check.id;
|
|
237
|
+
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."));
|
|
238
|
+
const result = await this.runCheckedStep(run, step);
|
|
239
|
+
const infrastructureFailed = isTransientShellInfrastructureFailure(result);
|
|
240
|
+
await run.emit?.(validationEvent(infrastructureFailed
|
|
241
|
+
? "prepublication_infrastructure_confirmation_failed"
|
|
242
|
+
: "prepublication_infrastructure_confirmation_passed", checkId, infrastructureFailed
|
|
243
|
+
? `The validation shell failed again on its single infrastructure confirmation run (exit ${result.exitCode}).`
|
|
244
|
+
: result.exitCode === 0
|
|
245
|
+
? "The validation step recovered on its single infrastructure confirmation run."
|
|
246
|
+
: "The host-runtime failure did not recur; continuing with normal validation failure handling."));
|
|
247
|
+
if (!infrastructureFailed)
|
|
248
|
+
return result;
|
|
249
|
+
const detail = diagnosticDetail(result);
|
|
250
|
+
await run.emit?.(validationEvent("prepublication_infrastructure_failed", checkId, `Pre-publication infrastructure for '${checkId}' remained unavailable${detail ? `: ${detail}` : "."}`));
|
|
251
|
+
throw new PrePublicationInfrastructureError(checkId, result.exitCode, result.command, result.args, detail);
|
|
252
|
+
}
|
|
196
253
|
/** Returns the native fallback connection when this check must use it instead of Docker. */
|
|
197
254
|
async ensurePrerequisite(check, environment, postgresAdminConnection, emit) {
|
|
198
255
|
if (check.requiredPrerequisite === "isolated_postgres"
|
|
@@ -213,7 +270,7 @@ export class PrePublicationValidator {
|
|
|
213
270
|
const snapshot = await this.dockerEngineProbe.ensureAvailableForRequiredWork();
|
|
214
271
|
if (!snapshot.available) {
|
|
215
272
|
const detail = `Docker prerequisite unavailable (${snapshot.unavailableCode ?? "docker_engine_unavailable"}): ${snapshot.unavailableReason ?? "the daemon did not pass a fresh readiness probe"}`;
|
|
216
|
-
const fallback = check.requiredPrerequisite === "isolated_postgres" && supportsNativeTestPostgresFallback(check)
|
|
273
|
+
const fallback = check.requiredPrerequisite === "isolated_postgres" && supportsNativeTestPostgresFallback(check.id)
|
|
217
274
|
? this.nativeTestPostgresFallback()
|
|
218
275
|
: null;
|
|
219
276
|
if (fallback) {
|
|
@@ -241,7 +298,8 @@ export class PrePublicationValidator {
|
|
|
241
298
|
throw new PrePublicationInfrastructureError(check.id, result.exitCode, result.command, result.args, detail);
|
|
242
299
|
}
|
|
243
300
|
// Runs for every target repository, with or without a CI parity contract: it only reads the worktree.
|
|
244
|
-
|
|
301
|
+
// A failure joins the pass's failures; the contract's checks still run.
|
|
302
|
+
async checkTestOnlyExports(pass, worktreePath, emit, signal, execution) {
|
|
245
303
|
const found = await findUnreferencedNewExports(args => this.runCommand("git", args, worktreePath, signal, execution), worktreePath, execution?.baselineRevision);
|
|
246
304
|
const unused = found.filter(row => !row.testOnly);
|
|
247
305
|
if (unused.length > 0) {
|
|
@@ -252,7 +310,7 @@ export class PrePublicationValidator {
|
|
|
252
310
|
return;
|
|
253
311
|
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.`;
|
|
254
312
|
await emit?.(validationEvent("prepublication_validation_failed", "unreferenced-exports", `New code is tested but never called: ${detail}`));
|
|
255
|
-
|
|
313
|
+
pass.record({ checkId: "unreferenced-exports", exitCode: 1, command: "git", args: ["grep"], detail });
|
|
256
314
|
}
|
|
257
315
|
async changedPaths(worktreePath, signal, execution) {
|
|
258
316
|
const baselineRevision = execution?.baselineRevision?.trim();
|
|
@@ -299,8 +357,14 @@ export class PrePublicationValidator {
|
|
|
299
357
|
throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the CI parity contract changed after dispatch (baseline ${baselineDigest}, worktree ${contractDigest}).`, "bridge");
|
|
300
358
|
}
|
|
301
359
|
}
|
|
302
|
-
async runStep(checkId, step, cwd, signal, execution, postgresAdminConnection) {
|
|
360
|
+
async runStep(checkId, step, cwd, signal, execution, postgresAdminConnection, emit) {
|
|
303
361
|
const invocation = managedAttemptInvocation(checkId, step, execution?.environment);
|
|
362
|
+
// Every launch, including confirmation reruns, is admitted by the host load governor first.
|
|
363
|
+
return await runHostGovernedValidationStep(this.hostLoad, {
|
|
364
|
+
checkId, command: invocation.command, args: invocation.args, owner: execution?.hostLoadOwner, signal, emit,
|
|
365
|
+
}, async (stepSignal) => await this.launchStep(checkId, step, invocation, cwd, stepSignal, execution, postgresAdminConnection));
|
|
366
|
+
}
|
|
367
|
+
async launchStep(checkId, step, invocation, cwd, signal, execution, postgresAdminConnection) {
|
|
304
368
|
const stepExecution = validationExecutionForStep(checkId, step, execution, postgresAdminConnection);
|
|
305
369
|
const before = await readValidationFiles(cwd, step.assertUnchangedPaths ?? []);
|
|
306
370
|
const result = await this.runCommand(invocation.command, invocation.args, cwd, signal, stepExecution);
|
|
@@ -345,57 +409,13 @@ export class PrePublicationValidator {
|
|
|
345
409
|
};
|
|
346
410
|
}
|
|
347
411
|
catch (error) {
|
|
412
|
+
// Carries the check its host capacity token waits on; it names only the executable.
|
|
413
|
+
if (error instanceof ProcessTreeTerminationError)
|
|
414
|
+
throw error;
|
|
348
415
|
throw sanitizeFailureError(error, exactSecrets);
|
|
349
416
|
}
|
|
350
417
|
}
|
|
351
418
|
}
|
|
352
|
-
function managedAttemptInvocation(checkId, step, environment) {
|
|
353
|
-
const playwrightConfig = environment?.FORGE_PLAYWRIGHT_CONFIG?.trim();
|
|
354
|
-
const attemptOwned = environment?.FORGE_E2E_OWNERSHIP_MODE === "attempt"
|
|
355
|
-
|| Boolean(environment?.FORGE_DISPATCH_ATTEMPT_ID?.trim());
|
|
356
|
-
if (checkId !== "playwright-e2e" || !attemptOwned) {
|
|
357
|
-
return step;
|
|
358
|
-
}
|
|
359
|
-
if (!playwrightConfig) {
|
|
360
|
-
throw new ForgeFailureError("prepublication_capability_unavailable", "prepublication_capability_unavailable: playwright-e2e requires the Bridge-generated FORGE_PLAYWRIGHT_CONFIG for a managed attempt.", "bridge");
|
|
361
|
-
}
|
|
362
|
-
return {
|
|
363
|
-
command: "pnpm",
|
|
364
|
-
args: ["--dir", "tests/e2e", "exec", "playwright", "test", "--config", playwrightConfig],
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
const nativeFallbackCheckIds = new Set([
|
|
368
|
-
"owned-suite-registration",
|
|
369
|
-
"dotnet-build-and-unit",
|
|
370
|
-
"comment-repair-dotnet-regression",
|
|
371
|
-
]);
|
|
372
|
-
const nativeFallbackDotnetTierScripts = [
|
|
373
|
-
"scripts/run-dotnet-test-tier.ps1",
|
|
374
|
-
"scripts/run-dotnet-test-tier-set.ps1",
|
|
375
|
-
"scripts/run-affected-dotnet-tests.mjs",
|
|
376
|
-
];
|
|
377
|
-
function supportsNativeTestPostgresFallback(check) {
|
|
378
|
-
return nativeFallbackCheckIds.has(check.id);
|
|
379
|
-
}
|
|
380
|
-
function validationExecutionForStep(checkId, step, execution, postgresAdminConnection) {
|
|
381
|
-
// The connection only exists when Docker is unavailable and the operator
|
|
382
|
-
// provisioned a dedicated native test cluster. Only the runner-authored
|
|
383
|
-
// .NET test tiers and the suite-identity check receive it; build, client,
|
|
384
|
-
// Bridge, and E2E steps never do.
|
|
385
|
-
if (!postgresAdminConnection || !nativeFallbackCheckIds.has(checkId))
|
|
386
|
-
return execution;
|
|
387
|
-
const runsDotnetTier = step.args.some(argument => nativeFallbackDotnetTierScripts
|
|
388
|
-
.some(script => argument.replaceAll("\\", "/").endsWith(script)));
|
|
389
|
-
if (checkId !== "owned-suite-registration" && !runsDotnetTier)
|
|
390
|
-
return execution;
|
|
391
|
-
return {
|
|
392
|
-
...execution,
|
|
393
|
-
environment: {
|
|
394
|
-
...execution?.environment,
|
|
395
|
-
...nativeTestPostgresFallbackEnvironment(parseNativeTestPostgresFallback(postgresAdminConnection)),
|
|
396
|
-
},
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
419
|
function environmentValue(environment, name) {
|
|
400
420
|
return Object.prototype.hasOwnProperty.call(environment ?? {}, name)
|
|
401
421
|
? environment?.[name]?.trim() ?? ""
|
|
@@ -620,12 +640,3 @@ function canonicalizeJson(value) {
|
|
|
620
640
|
}
|
|
621
641
|
return value;
|
|
622
642
|
}
|
|
623
|
-
function validationEvent(eventType, checkId, content, detail) {
|
|
624
|
-
return {
|
|
625
|
-
role: "runner",
|
|
626
|
-
kind: "checkpoint",
|
|
627
|
-
content,
|
|
628
|
-
eventType,
|
|
629
|
-
data: JSON.stringify({ checkId, contractId: "forge-ci-parity-v1", ...detail }),
|
|
630
|
-
};
|
|
631
|
-
}
|
|
@@ -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
|
+
}
|