@loucompanion/forge-bridge 0.1.4-dev.04a1e5b9e484 → 0.1.4-dev.176dfdaf5020
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 +145 -4
- package/dist/bridge/bridge-chat-provider-command.d.ts +19 -0
- package/dist/bridge/bridge-chat-provider-command.js +132 -0
- package/dist/bridge/bridge-chat.types.d.ts +10 -0
- package/dist/bridge/bridge-chat.types.js +16 -1
- package/dist/bridge/bridge-state-file.d.ts +161 -0
- package/dist/bridge/bridge-state-file.js +376 -0
- package/dist/bridge/bridge-state-io.d.ts +11 -0
- package/dist/bridge/bridge-state-io.js +50 -0
- package/dist/bridge/bridge-state-lock.d.ts +11 -0
- package/dist/bridge/bridge-state-lock.js +102 -0
- package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
- package/dist/bridge/bridge-state-unpublished.js +111 -0
- package/dist/bridge/bridge.base.d.ts +9 -0
- package/dist/bridge/bridge.service.d.ts +101 -15
- package/dist/bridge/bridge.service.js +472 -345
- package/dist/bridge/bridge.types.d.ts +27 -0
- package/dist/bridge/dispatch-result-outbox.d.ts +11 -1
- package/dist/bridge/dispatch-result-outbox.js +31 -6
- package/dist/bridge/in-flight-registry.d.ts +62 -0
- package/dist/bridge/in-flight-registry.js +207 -0
- package/dist/bridge/local-yield-flag.d.ts +6 -0
- package/dist/bridge/local-yield-flag.js +34 -0
- package/dist/bridge/readiness-result-outbox.d.ts +5 -1
- package/dist/bridge/readiness-result-outbox.js +20 -0
- package/dist/bridge/runner-host-capabilities.d.ts +5 -0
- package/dist/bridge/runner-host-capabilities.js +17 -0
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -0
- package/dist/bridge/test-postgres-capability.d.ts +14 -0
- package/dist/bridge/test-postgres-capability.js +120 -0
- package/dist/cleanup/cleanup-wip.d.ts +12 -0
- package/dist/cleanup/cleanup-wip.js +66 -0
- package/dist/cleanup/cleanup.service.d.ts +20 -1
- package/dist/cleanup/cleanup.service.js +150 -169
- package/dist/cleanup/cleanup.types.d.ts +6 -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 +7 -0
- package/dist/cleanup/host-runtime-ledger.js +130 -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 +76 -14
- package/dist/cli/cli.service.d.ts +19 -10
- package/dist/cli/cli.service.js +152 -187
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +6 -0
- package/dist/cli/local-config.js +32 -4
- package/dist/cli/provider-cli-detection.d.ts +10 -0
- package/dist/cli/provider-cli-detection.js +160 -0
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +20 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +184 -18
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/attempt-node-runtime-launcher.js +9 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +21 -0
- package/dist/runtime/attempt-process-supervisor.js +62 -6
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -0
- package/dist/runtime/dotnet-build-outputs.d.ts +107 -0
- package/dist/runtime/dotnet-build-outputs.js +402 -0
- package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
- package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
- package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
- package/dist/runtime/ephemeral-test-postgres.js +303 -0
- package/dist/runtime/host-database-capability-boundary.d.ts +1 -1
- package/dist/runtime/host-database-capability-boundary.js +1 -0
- package/dist/runtime/host-facts.d.ts +36 -0
- package/dist/runtime/host-facts.js +95 -0
- package/dist/runtime/host-load-admission.d.ts +67 -0
- package/dist/runtime/host-load-admission.js +99 -0
- 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 +49 -0
- package/dist/runtime/host-load-forge-cgroups.js +140 -0
- package/dist/runtime/host-load-governor-config.d.ts +52 -0
- package/dist/runtime/host-load-governor-config.js +83 -0
- package/dist/runtime/host-load-governor.d.ts +186 -0
- package/dist/runtime/host-load-governor.js +632 -0
- package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
- package/dist/runtime/host-load-ledger-lock.js +187 -0
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +80 -0
- package/dist/runtime/host-load-sampler.d.ts +156 -0
- package/dist/runtime/host-load-sampler.js +298 -0
- package/dist/runtime/host-load-step-class.d.ts +70 -0
- package/dist/runtime/host-load-step-class.js +161 -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-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 +200 -0
- package/dist/runtime/host-load-token-ledger.js +453 -0
- 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-pressure-stall.d.ts +61 -0
- package/dist/runtime/host-pressure-stall.js +168 -0
- package/dist/runtime/host-runtime-contract.d.ts +16 -0
- package/dist/runtime/host-runtime-contract.js +35 -2
- package/dist/runtime/host-runtime-lease.d.ts +77 -5
- package/dist/runtime/host-runtime-lease.js +328 -136
- package/dist/runtime/host-runtime-ledger-recovery.d.ts +20 -0
- package/dist/runtime/host-runtime-ledger-recovery.js +134 -0
- package/dist/runtime/host-runtime-promotion.d.ts +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/managed-command-teardown.d.ts +62 -0
- package/dist/runtime/managed-command-teardown.js +596 -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-browser-cache.d.ts +39 -0
- package/dist/runtime/playwright-browser-cache.js +227 -0
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +18 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +61 -55
- package/dist/runtime/runner-settings.d.ts +104 -0
- package/dist/runtime/runner-settings.js +236 -0
- package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
- package/dist/runtime/supervised-runtime-build-guard.js +112 -0
- package/dist/sandbox/host-capacity-broker.d.ts +115 -0
- package/dist/sandbox/host-capacity-broker.js +336 -0
- package/dist/sandbox/managed-branch.d.ts +13 -0
- package/dist/sandbox/managed-branch.js +90 -0
- package/dist/sandbox/provider-auth/codex.js +11 -11
- package/dist/sandbox/runtime.d.ts +10 -1
- package/dist/sandbox/runtime.js +47 -8
- 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 +27 -7
- package/dist/session/managed-attempt-tools.js +406 -123
- package/dist/session/managed-build-coordinator.d.ts +17 -1
- package/dist/session/managed-build-coordinator.js +14 -1
- package/dist/session/managed-build-receipt.d.ts +5 -0
- package/dist/session/managed-build-receipt.js +8 -3
- 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 +100 -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 +12 -0
- package/dist/session/phase-completion.helpers.js +13 -12
- package/dist/session/phase-completion.js +5 -0
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +156 -0
- package/dist/session/phase-completion.prompts.js +6 -1
- package/dist/session/phase-completion.runtime.d.ts +5 -11
- package/dist/session/phase-completion.runtime.js +111 -230
- 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.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +111 -0
- 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 +23 -0
- package/dist/session/pre-publication-process.js +109 -0
- package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
- package/dist/session/pre-publication-skipped-tests.js +109 -0
- package/dist/session/pre-publication-step-execution.d.ts +12 -0
- package/dist/session/pre-publication-step-execution.js +50 -0
- package/dist/session/pre-publication-validation.d.ts +37 -21
- package/dist/session/pre-publication-validation.js +228 -219
- package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
- package/dist/session/provider-cli/claude-background-work.js +181 -0
- package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
- package/dist/session/provider-cli/host-build-lock.js +30 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +276 -0
- package/dist/session/provider-cli/provider-cli.artifacts.d.ts +2 -1
- package/dist/session/provider-cli/provider-cli.artifacts.js +21 -15
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +75 -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.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 +46 -31
- package/dist/session/provider-cli/provider-cli.process.js +286 -403
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +87 -32
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +8 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +29 -1
- package/dist/session/provider-cli/provider-cli.service.d.ts +7 -1
- package/dist/session/provider-cli/provider-cli.service.js +207 -192
- 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-cli.windows-launch.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
- package/dist/session/provider-cli/provider-in-flight-work.d.ts +10 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +92 -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 +8 -0
- package/dist/session/provider-cli/provider-output-state.js +15 -0
- package/dist/session/provider-cli/provider-usage.d.ts +2 -1
- package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
- package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
- package/dist/session/publishable-worktree-changes.d.ts +54 -0
- package/dist/session/publishable-worktree-changes.js +193 -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 +51 -0
- package/dist/session/sandbox-host-capacity-gate.js +257 -0
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.base.d.ts +9 -1
- package/dist/session/session.service.d.ts +11 -2
- package/dist/session/session.service.js +189 -69
- package/dist/session/session.types.d.ts +3 -0
- package/dist/session/session.types.js +15 -3
- 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/fs/file-identity.d.ts +10 -0
- package/dist/shared/fs/file-identity.js +15 -0
- package/dist/shared/fs/replace-file.d.ts +7 -0
- package/dist/shared/fs/replace-file.js +33 -0
- package/dist/shared/process/host-process-recovery.d.ts +14 -3
- package/dist/shared/process/host-process-recovery.js +23 -3
- package/dist/shared/process/host-process-supervisor.d.ts +14 -1
- package/dist/shared/process/host-process-supervisor.js +67 -15
- 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 +14 -7
- 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 +120 -10
- package/dist/worktree/orphan-relink.d.ts +19 -0
- package/dist/worktree/orphan-relink.js +106 -0
- package/dist/worktree/wip-git.d.ts +33 -0
- package/dist/worktree/wip-git.js +122 -0
- package/dist/worktree/wip-refs.d.ts +62 -0
- package/dist/worktree/wip-refs.js +119 -0
- package/dist/worktree/wip-restore.d.ts +38 -0
- package/dist/worktree/wip-restore.js +190 -0
- package/dist/worktree/wip-snapshot.d.ts +50 -0
- package/dist/worktree/wip-snapshot.js +268 -0
- package/dist/worktree/worktree-inputs.d.ts +8 -0
- package/dist/worktree/worktree-inputs.js +134 -0
- package/dist/worktree/worktree-origin-sync.d.ts +34 -0
- package/dist/worktree/worktree-origin-sync.js +127 -0
- package/dist/worktree/worktree-wip-events.d.ts +18 -0
- package/dist/worktree/worktree-wip-events.js +98 -0
- package/dist/worktree/worktree-wip.d.ts +50 -0
- package/dist/worktree/worktree-wip.js +185 -0
- package/dist/worktree/worktree.base.d.ts +7 -1
- package/dist/worktree/worktree.service.d.ts +36 -5
- package/dist/worktree/worktree.service.js +124 -155
- package/dist/worktree/worktree.types.d.ts +38 -0
- package/package.json +2 -2
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
2
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
2
|
import fs from "node:fs/promises";
|
|
4
3
|
import path from "node:path";
|
|
5
|
-
import { promisify } from "node:util";
|
|
6
4
|
import { attemptDatabaseCapabilityEnvironment, attemptDatabaseCapabilitySecrets, } from "../runtime/attempt-database-broker.js";
|
|
7
5
|
import { assertHostDatabaseCapabilityBoundary } from "../runtime/host-database-capability-boundary.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { runHostGovernedValidationStep } from "./pre-publication-host-load.js";
|
|
7
|
+
import { dockerFreeGrant, dockerUnavailableNativeTestPostgres, isolatedPostgresProvided, preferredNativeTestPostgres, releaseCheckPostgres, } from "./pre-publication-native-postgres.js";
|
|
8
|
+
import { managedAttemptInvocation, validationExecutionForStep, } from "./pre-publication-step-execution.js";
|
|
9
|
+
import { hostRuntimeLegacyTestPostgresEnvironment, hostRuntimeTestPostgresAdminEnvironment, hostRuntimeTestPostgresProvisionerEnvironment, } from "../runtime/host-runtime-contract.js";
|
|
10
10
|
import { redactText } from "../shared/redaction/redaction.js";
|
|
11
|
+
import { PrePublicationPass, PrePublicationValidationError, SkippedTestTally, skippedCheckEvent, validationEvent, } from "./pre-publication-pass.js";
|
|
12
|
+
import { ProcessPrePublicationCommandRunner, pnpmDirectoryLaunch } from "./pre-publication-process.js";
|
|
13
|
+
import { ProcessTreeTerminationError } from "../shared/process/process.js";
|
|
11
14
|
import { findUnreferencedNewExports } from "./unreferenced-exports.js";
|
|
12
15
|
import { ForgeFailureError, sanitizeFailureError, } from "./session.types.js";
|
|
13
|
-
const execFileAsync = promisify(execFile);
|
|
14
16
|
const contractRelativePath = ".forge/validation/ci-parity.v1.json";
|
|
15
17
|
const requiredCheckIds = new Set([
|
|
16
18
|
"file-size-inventory",
|
|
@@ -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;
|
|
@@ -81,158 +96,181 @@ export class PrePublicationInfrastructureError extends ForgeFailureError {
|
|
|
81
96
|
this.name = "PrePublicationInfrastructureError";
|
|
82
97
|
}
|
|
83
98
|
}
|
|
84
|
-
class ProcessPrePublicationCommandRunner {
|
|
85
|
-
async run(command, args, cwd, signal, environment) {
|
|
86
|
-
try {
|
|
87
|
-
const windowsBatch = process.platform === "win32" && (command === "npm" || command === "pnpm");
|
|
88
|
-
const executable = windowsBatch ? (process.env.ComSpec ?? "cmd.exe") : command;
|
|
89
|
-
const commandArgs = windowsBatch
|
|
90
|
-
? ["/d", "/s", "/c", [`${command}.cmd`, ...args].map(quoteWindowsCommandArgument).join(" ")]
|
|
91
|
-
: [...args];
|
|
92
|
-
const result = await execFileAsync(executable, commandArgs, {
|
|
93
|
-
cwd,
|
|
94
|
-
encoding: "utf8",
|
|
95
|
-
maxBuffer: 4 * 1024 * 1024,
|
|
96
|
-
signal,
|
|
97
|
-
env: prePublicationChildEnvironment(environment),
|
|
98
|
-
});
|
|
99
|
-
return { exitCode: 0, stdout: result.stdout, stderr: result.stderr };
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
const failure = error;
|
|
103
|
-
if (failure.name === "AbortError")
|
|
104
|
-
throw error;
|
|
105
|
-
if (failure.code === "ENOENT") {
|
|
106
|
-
return { exitCode: 127, stderr: `executable_not_found: ${command}` };
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
exitCode: typeof failure.code === "number" ? failure.code : 1,
|
|
110
|
-
stdout: failure.stdout,
|
|
111
|
-
stderr: failure.stderr ?? failure.message,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function quoteWindowsCommandArgument(value) {
|
|
117
|
-
return /^[A-Za-z0-9_./:@=-]+$/u.test(value) ? value : `"${value.replaceAll('"', '""')}"`;
|
|
118
|
-
}
|
|
119
|
-
function prePublicationChildEnvironment(environment) {
|
|
120
|
-
const child = {};
|
|
121
|
-
const privilegedNames = new Set([
|
|
122
|
-
hostRuntimeTestPostgresAdminEnvironment.toLowerCase(),
|
|
123
|
-
hostRuntimeLegacyTestPostgresEnvironment.toLowerCase(),
|
|
124
|
-
]);
|
|
125
|
-
for (const [name, value] of Object.entries(process.env)) {
|
|
126
|
-
if (typeof value === "string" && !privilegedNames.has(name.toLowerCase())) {
|
|
127
|
-
child[name] = value;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return { ...child, ...environment };
|
|
131
|
-
}
|
|
132
99
|
export class PrePublicationValidator {
|
|
133
100
|
commands;
|
|
134
101
|
dockerEngineProbe;
|
|
135
102
|
nativeTestPostgresFallback;
|
|
136
|
-
|
|
103
|
+
hostLoad;
|
|
104
|
+
startEphemeral;
|
|
105
|
+
constructor(commands = new ProcessPrePublicationCommandRunner(), dockerEngineProbe, nativeTestPostgresFallback = () => null, hostLoad, startEphemeral) {
|
|
137
106
|
this.commands = commands;
|
|
138
107
|
this.dockerEngineProbe = dockerEngineProbe;
|
|
139
108
|
this.nativeTestPostgresFallback = nativeTestPostgresFallback;
|
|
109
|
+
this.hostLoad = hostLoad;
|
|
110
|
+
this.startEphemeral = startEphemeral;
|
|
140
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
|
+
*/
|
|
141
117
|
async validate(worktreePath, profile, capabilities, emit, signal, execution) {
|
|
142
118
|
const checksExports = profile === "implementation" || profile === "comment_repair";
|
|
119
|
+
const pass = new PrePublicationPass(execution?.runtimeRestartFailure);
|
|
143
120
|
const contract = await loadValidationContract(worktreePath);
|
|
144
121
|
if (contract === null) {
|
|
145
122
|
await emit?.(validationEvent("prepublication_validation_legacy_contract", "legacy-provider-validation", `This checkout predates ${contractRelativePath}; Bridge preserved legacy provider validation without source mutation.`));
|
|
146
123
|
if (checksExports) {
|
|
147
124
|
const legacy = await prepareValidationExecution(execution);
|
|
148
125
|
try {
|
|
149
|
-
await this.
|
|
126
|
+
await this.checkTestOnlyExports(pass, worktreePath, emit, signal, legacy.execution);
|
|
150
127
|
}
|
|
151
128
|
finally {
|
|
152
129
|
await legacy.cleanup();
|
|
153
130
|
}
|
|
154
131
|
}
|
|
132
|
+
pass.throwIfFailed();
|
|
155
133
|
return [];
|
|
156
134
|
}
|
|
157
135
|
const scoped = await prepareValidationExecution(execution);
|
|
158
136
|
try {
|
|
159
137
|
if (checksExports)
|
|
160
|
-
await this.
|
|
138
|
+
await this.checkTestOnlyExports(pass, worktreePath, emit, signal, scoped.execution);
|
|
161
139
|
const contractDigest = validationContractDigest(contract);
|
|
162
140
|
await this.assertContractMatchesDispatchBaseline(worktreePath, contractDigest, signal, scoped.execution);
|
|
163
141
|
if (contractDigest !== currentApprovedContractDigest) {
|
|
164
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}.`));
|
|
165
143
|
}
|
|
166
144
|
const changedPaths = await this.changedPaths(worktreePath, signal, scoped.execution);
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
const postgresAdminConnection = await this.ensurePrerequisite(check, scoped.execution?.environment, scoped.postgresAdminConnection, emit) ?? scoped.postgresAdminConnection;
|
|
178
|
-
await emit?.(validationEvent("prepublication_validation_started", check.id, `Running pre-publication CI parity check '${check.id}'.`));
|
|
179
|
-
for (const step of check.steps) {
|
|
180
|
-
let result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection);
|
|
181
|
-
await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
|
|
182
|
-
if (isTimeoutOnlyClientTestFailure(check.id, step, result)) {
|
|
183
|
-
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."));
|
|
184
|
-
result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection);
|
|
185
|
-
await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
|
|
186
|
-
await emit?.(validationEvent(result.exitCode === 0
|
|
187
|
-
? "prepublication_validation_timeout_confirmation_passed"
|
|
188
|
-
: "prepublication_validation_timeout_confirmation_failed", check.id, result.exitCode === 0
|
|
189
|
-
? "The complete client test step passed on its single timeout confirmation run."
|
|
190
|
-
: `The complete client test step failed on its single timeout confirmation run (exit ${result.exitCode}).`));
|
|
191
|
-
}
|
|
192
|
-
if (isTransientBridgeCleanupFailure(check.id, step, result)) {
|
|
193
|
-
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."));
|
|
194
|
-
result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection);
|
|
195
|
-
await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
|
|
196
|
-
await emit?.(validationEvent(result.exitCode === 0
|
|
197
|
-
? "prepublication_validation_cleanup_confirmation_passed"
|
|
198
|
-
: "prepublication_validation_cleanup_confirmation_failed", check.id, result.exitCode === 0
|
|
199
|
-
? "The complete Bridge test step passed on its single cleanup confirmation run."
|
|
200
|
-
: `The complete Bridge test step failed on its single cleanup confirmation run (exit ${result.exitCode}).`));
|
|
201
|
-
}
|
|
202
|
-
if (isTransientShellInfrastructureFailure(result)) {
|
|
203
|
-
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."));
|
|
204
|
-
result = await this.runStep(check.id, step, worktreePath, signal, scoped.execution, postgresAdminConnection);
|
|
205
|
-
await this.throwIfPrerequisiteWasLost(check, result, scoped.execution?.environment, postgresAdminConnection, emit);
|
|
206
|
-
const infrastructureFailed = isTransientShellInfrastructureFailure(result);
|
|
207
|
-
await emit?.(validationEvent(infrastructureFailed
|
|
208
|
-
? "prepublication_infrastructure_confirmation_failed"
|
|
209
|
-
: "prepublication_infrastructure_confirmation_passed", check.id, infrastructureFailed
|
|
210
|
-
? `The validation shell failed again on its single infrastructure confirmation run (exit ${result.exitCode}).`
|
|
211
|
-
: result.exitCode === 0
|
|
212
|
-
? "The validation step recovered on its single infrastructure confirmation run."
|
|
213
|
-
: "The host-runtime failure did not recur; continuing with normal validation failure handling."));
|
|
214
|
-
if (infrastructureFailed) {
|
|
215
|
-
const detail = diagnosticDetail(result);
|
|
216
|
-
await emit?.(validationEvent("prepublication_infrastructure_failed", check.id, `Pre-publication infrastructure for '${check.id}' remained unavailable${detail ? `: ${detail}` : "."}`));
|
|
217
|
-
throw new PrePublicationInfrastructureError(check.id, result.exitCode, result.command, result.args, detail);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
if (result.exitCode !== 0) {
|
|
221
|
-
const detail = diagnosticDetail(result);
|
|
222
|
-
await emit?.(validationEvent("prepublication_validation_failed", check.id, `Pre-publication CI parity check '${check.id}' exited ${result.exitCode}${detail ? `: ${detail}` : "."}`));
|
|
223
|
-
throw new PrePublicationValidationError(check.id, result.exitCode, result.command, result.args, detail);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
completed.push(check.id);
|
|
227
|
-
await emit?.(validationEvent("prepublication_validation_passed", check.id, `Pre-publication CI parity check '${check.id}' passed.`));
|
|
228
|
-
}
|
|
229
|
-
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);
|
|
230
154
|
}
|
|
231
155
|
finally {
|
|
232
156
|
await scoped.cleanup();
|
|
233
157
|
}
|
|
234
158
|
}
|
|
235
|
-
|
|
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. */
|
|
236
274
|
async ensurePrerequisite(check, environment, postgresAdminConnection, emit) {
|
|
237
275
|
if (check.requiredPrerequisite === "isolated_postgres"
|
|
238
276
|
&& isolatedPostgresProvided(check.id, environment, postgresAdminConnection)) {
|
|
@@ -241,6 +279,11 @@ export class PrePublicationValidator {
|
|
|
241
279
|
: `Pre-publication check '${check.id}' is using the configured loopback PostgreSQL test server with per-run owned databases. No Docker daemon is required.`));
|
|
242
280
|
return undefined;
|
|
243
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) {
|
|
244
287
|
if (check.requiredPrerequisite === undefined || !this.dockerEngineProbe)
|
|
245
288
|
return undefined;
|
|
246
289
|
const current = this.dockerEngineProbe.current();
|
|
@@ -252,12 +295,10 @@ export class PrePublicationValidator {
|
|
|
252
295
|
const snapshot = await this.dockerEngineProbe.ensureAvailableForRequiredWork();
|
|
253
296
|
if (!snapshot.available) {
|
|
254
297
|
const detail = `Docker prerequisite unavailable (${snapshot.unavailableCode ?? "docker_engine_unavailable"}): ${snapshot.unavailableReason ?? "the daemon did not pass a fresh readiness probe"}`;
|
|
255
|
-
const fallback = check.requiredPrerequisite
|
|
256
|
-
? this.nativeTestPostgresFallback()
|
|
257
|
-
: null;
|
|
298
|
+
const fallback = dockerUnavailableNativeTestPostgres(check.id, check.requiredPrerequisite, this.nativeTestPostgresFallback);
|
|
258
299
|
if (fallback) {
|
|
259
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.`));
|
|
260
|
-
return fallback
|
|
301
|
+
return fallback;
|
|
261
302
|
}
|
|
262
303
|
await emit?.(validationEvent("prepublication_prerequisite_unavailable", check.id, `Pre-publication check '${check.id}' is waiting for Docker infrastructure recovery: ${detail}`));
|
|
263
304
|
throw new PrePublicationInfrastructureError(check.id, 75, "docker", ["info"], detail);
|
|
@@ -269,7 +310,7 @@ export class PrePublicationValidator {
|
|
|
269
310
|
if (result.exitCode === 0
|
|
270
311
|
|| check.requiredPrerequisite === undefined
|
|
271
312
|
|| (check.requiredPrerequisite === "isolated_postgres"
|
|
272
|
-
&& isolatedPostgresProvided(check.id, environment, postgresAdminConnection))
|
|
313
|
+
&& isolatedPostgresProvided(check.id, environment, dockerFreeGrant(postgresAdminConnection)))
|
|
273
314
|
|| !this.dockerEngineProbe)
|
|
274
315
|
return;
|
|
275
316
|
const snapshot = await this.dockerEngineProbe.refresh(true);
|
|
@@ -280,7 +321,8 @@ export class PrePublicationValidator {
|
|
|
280
321
|
throw new PrePublicationInfrastructureError(check.id, result.exitCode, result.command, result.args, detail);
|
|
281
322
|
}
|
|
282
323
|
// Runs for every target repository, with or without a CI parity contract: it only reads the worktree.
|
|
283
|
-
|
|
324
|
+
// A failure joins the pass's failures; the contract's checks still run.
|
|
325
|
+
async checkTestOnlyExports(pass, worktreePath, emit, signal, execution) {
|
|
284
326
|
const found = await findUnreferencedNewExports(args => this.runCommand("git", args, worktreePath, signal, execution), worktreePath, execution?.baselineRevision);
|
|
285
327
|
const unused = found.filter(row => !row.testOnly);
|
|
286
328
|
if (unused.length > 0) {
|
|
@@ -291,7 +333,7 @@ export class PrePublicationValidator {
|
|
|
291
333
|
return;
|
|
292
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.`;
|
|
293
335
|
await emit?.(validationEvent("prepublication_validation_failed", "unreferenced-exports", `New code is tested but never called: ${detail}`));
|
|
294
|
-
|
|
336
|
+
pass.record({ checkId: "unreferenced-exports", exitCode: 1, command: "git", args: ["grep"], detail });
|
|
295
337
|
}
|
|
296
338
|
async changedPaths(worktreePath, signal, execution) {
|
|
297
339
|
const baselineRevision = execution?.baselineRevision?.trim();
|
|
@@ -334,12 +376,32 @@ export class PrePublicationValidator {
|
|
|
334
376
|
if (!approvedContractDigests.has(baselineDigest)) {
|
|
335
377
|
throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the dispatch baseline uses unapproved CI parity contract ${baselineDigest}.`, "bridge");
|
|
336
378
|
}
|
|
337
|
-
|
|
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) {
|
|
338
381
|
throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the CI parity contract changed after dispatch (baseline ${baselineDigest}, worktree ${contractDigest}).`, "bridge");
|
|
339
382
|
}
|
|
340
383
|
}
|
|
341
|
-
|
|
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
|
+
}
|
|
397
|
+
async runStep(checkId, step, cwd, signal, execution, postgresAdminConnection, emit) {
|
|
342
398
|
const invocation = managedAttemptInvocation(checkId, step, execution?.environment);
|
|
399
|
+
// Every launch, including confirmation reruns, is admitted by the host load governor first.
|
|
400
|
+
return await runHostGovernedValidationStep(this.hostLoad, {
|
|
401
|
+
checkId, command: invocation.command, args: invocation.args, owner: execution?.hostLoadOwner, signal, emit,
|
|
402
|
+
}, async (stepSignal) => await this.launchStep(checkId, step, invocation, cwd, stepSignal, execution, postgresAdminConnection));
|
|
403
|
+
}
|
|
404
|
+
async launchStep(checkId, step, invocation, cwd, signal, execution, postgresAdminConnection) {
|
|
343
405
|
const stepExecution = validationExecutionForStep(checkId, step, execution, postgresAdminConnection);
|
|
344
406
|
const before = await readValidationFiles(cwd, step.assertUnchangedPaths ?? []);
|
|
345
407
|
const result = await this.runCommand(invocation.command, invocation.args, cwd, signal, stepExecution);
|
|
@@ -361,10 +423,11 @@ export class PrePublicationValidator {
|
|
|
361
423
|
const exactSecrets = validationExactSecrets(execution?.environment);
|
|
362
424
|
try {
|
|
363
425
|
if (execution?.processRunner) {
|
|
426
|
+
const launch = await pnpmDirectoryLaunch(command, args, cwd);
|
|
364
427
|
const result = await execution.processRunner.run({
|
|
365
428
|
command,
|
|
366
|
-
args,
|
|
367
|
-
cwd,
|
|
429
|
+
args: launch.args,
|
|
430
|
+
cwd: launch.cwd,
|
|
368
431
|
env: execution.environment,
|
|
369
432
|
captureOutput: true,
|
|
370
433
|
failureRedactionValues: exactSecrets,
|
|
@@ -383,78 +446,19 @@ export class PrePublicationValidator {
|
|
|
383
446
|
};
|
|
384
447
|
}
|
|
385
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;
|
|
386
452
|
throw sanitizeFailureError(error, exactSecrets);
|
|
387
453
|
}
|
|
388
454
|
}
|
|
389
455
|
}
|
|
390
|
-
function managedAttemptInvocation(checkId, step, environment) {
|
|
391
|
-
const playwrightConfig = environment?.FORGE_PLAYWRIGHT_CONFIG?.trim();
|
|
392
|
-
const attemptOwned = environment?.FORGE_E2E_OWNERSHIP_MODE === "attempt"
|
|
393
|
-
|| Boolean(environment?.FORGE_DISPATCH_ATTEMPT_ID?.trim());
|
|
394
|
-
if (checkId !== "playwright-e2e" || !attemptOwned) {
|
|
395
|
-
return step;
|
|
396
|
-
}
|
|
397
|
-
if (!playwrightConfig) {
|
|
398
|
-
throw new ForgeFailureError("prepublication_capability_unavailable", "prepublication_capability_unavailable: playwright-e2e requires the Bridge-generated FORGE_PLAYWRIGHT_CONFIG for a managed attempt.", "bridge");
|
|
399
|
-
}
|
|
400
|
-
return {
|
|
401
|
-
command: "pnpm",
|
|
402
|
-
args: ["--dir", "tests/e2e", "exec", "playwright", "test", "--config", playwrightConfig],
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
const nativeFallbackCheckIds = new Set([
|
|
406
|
-
"owned-suite-registration",
|
|
407
|
-
"dotnet-build-and-unit",
|
|
408
|
-
"comment-repair-dotnet-regression",
|
|
409
|
-
]);
|
|
410
|
-
const nativeFallbackDotnetTierScripts = [
|
|
411
|
-
"scripts/run-dotnet-test-tier.ps1",
|
|
412
|
-
"scripts/run-dotnet-test-tier-set.ps1",
|
|
413
|
-
"scripts/run-affected-dotnet-tests.mjs",
|
|
414
|
-
];
|
|
415
|
-
function supportsNativeTestPostgresFallback(check) {
|
|
416
|
-
return nativeFallbackCheckIds.has(check.id);
|
|
417
|
-
}
|
|
418
|
-
function validationExecutionForStep(checkId, step, execution, postgresAdminConnection) {
|
|
419
|
-
// The connection only exists when Docker is unavailable and the operator
|
|
420
|
-
// provisioned a dedicated native test cluster. Only the runner-authored
|
|
421
|
-
// .NET test tiers and the suite-identity check receive it; build, client,
|
|
422
|
-
// Bridge, and E2E steps never do.
|
|
423
|
-
if (!postgresAdminConnection || !nativeFallbackCheckIds.has(checkId))
|
|
424
|
-
return execution;
|
|
425
|
-
const runsDotnetTier = step.args.some(argument => nativeFallbackDotnetTierScripts
|
|
426
|
-
.some(script => argument.replaceAll("\\", "/").endsWith(script)));
|
|
427
|
-
if (checkId !== "owned-suite-registration" && !runsDotnetTier)
|
|
428
|
-
return execution;
|
|
429
|
-
return {
|
|
430
|
-
...execution,
|
|
431
|
-
environment: {
|
|
432
|
-
...execution?.environment,
|
|
433
|
-
...nativeTestPostgresFallbackEnvironment(parseNativeTestPostgresFallback(postgresAdminConnection)),
|
|
434
|
-
},
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
function environmentValue(environment, name) {
|
|
438
|
-
return Object.prototype.hasOwnProperty.call(environment ?? {}, name)
|
|
439
|
-
? environment?.[name]?.trim() ?? ""
|
|
440
|
-
: process.env[name]?.trim() ?? "";
|
|
441
|
-
}
|
|
442
|
-
function isolatedPostgresProvided(checkId, environment, postgresAdminConnection) {
|
|
443
|
-
if (checkId === "playwright-e2e") {
|
|
444
|
-
const attemptId = environmentValue(environment, "FORGE_DISPATCH_ATTEMPT_ID");
|
|
445
|
-
return (environmentValue(environment, "FORGE_E2E_OWNERSHIP_MODE") === "attempt"
|
|
446
|
-
|| /^[0-9a-f-]{36}$/iu.test(attemptId))
|
|
447
|
-
&& /^forge_attempt_[0-9a-f]{32}$/u.test(environmentValue(environment, "FORGE_ATTEMPT_DATABASE_SCHEMA"))
|
|
448
|
-
&& path.isAbsolute(environmentValue(environment, "FORGE_ATTEMPT_DATABASE_READINESS_PATH"))
|
|
449
|
-
// The attempt owns a database only once the Bridge's broker has issued it one.
|
|
450
|
-
&& environmentValue(environment, attemptDatabaseCapabilityEnvironment).length > 0;
|
|
451
|
-
}
|
|
452
|
-
return Boolean(postgresAdminConnection);
|
|
453
|
-
}
|
|
454
456
|
function validationExactSecrets(environment) {
|
|
455
457
|
return [
|
|
456
|
-
|
|
457
|
-
environment?.[
|
|
458
|
+
// The connection strings and their passwords: a test may print either.
|
|
459
|
+
...attemptDatabaseCapabilitySecrets(environment?.[hostRuntimeTestPostgresAdminEnvironment]),
|
|
460
|
+
...attemptDatabaseCapabilitySecrets(environment?.[hostRuntimeLegacyTestPostgresEnvironment]),
|
|
461
|
+
environment?.[hostRuntimeTestPostgresProvisionerEnvironment]?.trim() ?? "",
|
|
458
462
|
...attemptDatabaseCapabilitySecrets(environment?.[attemptDatabaseCapabilityEnvironment]),
|
|
459
463
|
].filter((value, index, values) => value.length > 0 && values.indexOf(value) === index);
|
|
460
464
|
}
|
|
@@ -587,6 +591,7 @@ function withoutPrivilegedPostgresEnvironment(environment) {
|
|
|
587
591
|
const privilegedNames = new Set([
|
|
588
592
|
hostRuntimeTestPostgresAdminEnvironment.toLowerCase(),
|
|
589
593
|
hostRuntimeLegacyTestPostgresEnvironment.toLowerCase(),
|
|
594
|
+
hostRuntimeTestPostgresProvisionerEnvironment.toLowerCase(),
|
|
590
595
|
]);
|
|
591
596
|
return Object.fromEntries(Object.entries(environment)
|
|
592
597
|
.filter(([name]) => !privilegedNames.has(name.toLowerCase())));
|
|
@@ -642,6 +647,13 @@ export async function loadValidationContract(worktreePath) {
|
|
|
642
647
|
}
|
|
643
648
|
return contract;
|
|
644
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
|
+
}
|
|
645
657
|
function validationContractDigest(contract) {
|
|
646
658
|
return createHash("sha256")
|
|
647
659
|
.update(JSON.stringify(canonicalizeJson(contract)))
|
|
@@ -656,6 +668,3 @@ function canonicalizeJson(value) {
|
|
|
656
668
|
}
|
|
657
669
|
return value;
|
|
658
670
|
}
|
|
659
|
-
function validationEvent(eventType, checkId, content) {
|
|
660
|
-
return { role: "runner", kind: "checkpoint", content, eventType, data: JSON.stringify({ checkId, contractId: "forge-ci-parity-v1" }) };
|
|
661
|
-
}
|