@loucompanion/forge-bridge 0.1.4-dev.b33004c2b0ea → 0.1.4-dev.bb5355d0d83f
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 +13 -0
- package/dist/bridge/bridge-chat-provider-command.d.ts +16 -0
- package/dist/bridge/bridge-chat-provider-command.js +137 -0
- package/dist/bridge/bridge-chat.types.d.ts +10 -0
- package/dist/bridge/bridge-chat.types.js +16 -1
- package/dist/bridge/bridge.service.d.ts +1 -1
- package/dist/bridge/bridge.service.js +4 -110
- package/dist/bridge/runner-host-capabilities.d.ts +3 -0
- package/dist/bridge/runner-host-capabilities.js +13 -0
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -0
- package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
- package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
- package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
- package/dist/runtime/ephemeral-test-postgres.js +303 -0
- package/dist/runtime/host-facts.d.ts +2 -1
- package/dist/runtime/host-load-admission.d.ts +9 -2
- package/dist/runtime/host-load-child-environment.d.ts +11 -6
- package/dist/runtime/host-load-child-environment.js +19 -10
- package/dist/runtime/host-load-governor-config.d.ts +10 -1
- package/dist/runtime/host-load-governor-config.js +7 -0
- package/dist/runtime/host-load-governor.d.ts +10 -0
- package/dist/runtime/host-load-governor.js +125 -34
- package/dist/runtime/host-load-sampler.d.ts +34 -4
- package/dist/runtime/host-load-sampler.js +73 -7
- package/dist/runtime/host-load-step-class.d.ts +3 -1
- package/dist/runtime/host-load-step-class.js +60 -5
- 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 +26 -0
- package/dist/runtime/host-load-token-ledger.js +93 -61
- package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
- package/dist/runtime/host-load-windows-cpu.js +85 -0
- package/dist/runtime/host-runtime-lease.d.ts +1 -1
- package/dist/runtime/host-runtime-lease.js +1 -1
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/sandbox/host-capacity-broker.d.ts +7 -1
- package/dist/sandbox/host-capacity-broker.js +23 -4
- 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 +0 -7
- package/dist/session/managed-attempt-tools.js +51 -62
- package/dist/session/managed-command-host-load.d.ts +2 -0
- package/dist/session/managed-command-host-load.js +2 -1
- package/dist/session/phase-completion.runtime.js +1 -1
- package/dist/session/phase-completion.schemas.js +25 -23
- package/dist/session/phase-completion.validation.js +3 -1
- 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 +2 -1
- package/dist/session/pre-publication-pass.js +8 -5
- package/dist/session/pre-publication-step-execution.d.ts +2 -1
- package/dist/session/pre-publication-step-execution.js +6 -5
- package/dist/session/pre-publication-validation.d.ts +9 -3
- package/dist/session/pre-publication-validation.js +62 -34
- 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/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +73 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +13 -22
- package/dist/session/provider-cli/provider-cli.process.js +36 -337
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +2 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +45 -8
- package/dist/session/provider-cli/provider-cli.runtime.js +7 -0
- package/dist/session/provider-cli/provider-cli.service.js +2 -8
- package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
- package/dist/session/provider-cli/provider-in-flight-work.d.ts +4 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +45 -0
- package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
- package/dist/session/provider-cli/provider-output-pipes.js +67 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
- package/dist/session/provider-cli/provider-output-state.js +6 -0
- package/dist/session/sandbox-host-capacity-gate.js +12 -3
- package/dist/session/session.types.js +1 -1
- package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
- package/dist/shared/process/windows-app-execution-alias.js +45 -0
- package/dist/shared/process/windows-launch.d.ts +18 -0
- package/dist/shared/process/windows-launch.js +68 -0
- package/dist/shared/provider-capabilities.js +5 -6
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { decomposeGateFileNames, decomposeStatuses, draftStatuses, isDebugCompletionPhase, phaseFiles, qaBlockerReasons, qaGateFileNames } from "./phase-completion.js";
|
|
2
2
|
import { browserCheckSchema, qaSidecarsSchema, qaEvidenceWrapperSchema, qaGateEvidenceWrapperSchema, findingEvidenceSchema, objectToolSchema, evidenceObjectSchema, qaScopeSchema, commandEvidenceSchema, resolvedFindingSchema, acceptanceCriteriaSchema, reviewSectionSchema, reviewSectionProperties } from "./phase-completion.schema-parts.js";
|
|
3
|
+
import { architectNonPassProperties } from "./architect-waits.js";
|
|
3
4
|
export function toolDescription(phase, qaGate = null, decomposeGate = null, draftGate = null) {
|
|
4
5
|
if (qaGate) {
|
|
5
6
|
return qaGate === "qa_verdict"
|
|
@@ -499,17 +500,8 @@ export function toolInputSchema(phase, qaGate = null, decomposeGate = null, draf
|
|
|
499
500
|
report_markdown: { type: "string", description: "Human-readable Architect report. Use report as an alias only when the client cannot send report_markdown." },
|
|
500
501
|
report: { type: "string", description: "Alias for report_markdown." },
|
|
501
502
|
blockers: baseProperties.blockers,
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
description: "Required for needs_revision when blockers are not used.",
|
|
505
|
-
items: { type: "string" }
|
|
506
|
-
},
|
|
507
|
-
revision_reasons: {
|
|
508
|
-
type: "array",
|
|
509
|
-
description: "Concrete reasons that prevent pass status.",
|
|
510
|
-
items: { type: "string" }
|
|
511
|
-
}
|
|
512
|
-
}, ["status", "summary"], "For status pass, include implementation_plan and qa_plan at the top level of the MCP tool arguments, as JSON objects rather than quoted strings. implementation_plan.phases must be a top-level array inside implementation_plan, not nested under another object. For needs_revision or blocked, implementation_plan and qa_plan may be omitted; include blockers, revision_questions, or revision_reasons instead.");
|
|
503
|
+
...architectNonPassProperties()
|
|
504
|
+
}, ["status", "summary"], "For status pass, include implementation_plan and qa_plan at the top level of the MCP tool arguments, as JSON objects rather than quoted strings. implementation_plan.phases must be a top-level array inside implementation_plan, not nested under another object. For needs_revision or blocked, implementation_plan and qa_plan may be omitted; include blockers, revision_questions, or revision_reasons instead. When blocked because another Story or pull request must merge first, also list it in waits_on; when the owner must choose, also set owner_decision.");
|
|
513
505
|
}
|
|
514
506
|
return objectToolSchema({
|
|
515
507
|
...baseProperties,
|
|
@@ -536,6 +528,27 @@ export function toolInputSchema(phase, qaGate = null, decomposeGate = null, draf
|
|
|
536
528
|
ready_for_dev_test: { type: "boolean", default: true, description: "Required for pass and must be true." }
|
|
537
529
|
}, ["status", "summary"], "For status pass, commands must include at least one passing deterministic command, acceptance criteria entries must use status: satisfied plus evidence, and ready_for_dev_test must be true.");
|
|
538
530
|
}
|
|
531
|
+
// Feature-to-Story candidate fields: schedule order, handoff to dependents, and whether the Story
|
|
532
|
+
// needs a design reference before Forge builds it.
|
|
533
|
+
const storyCandidateScheduleProperties = {
|
|
534
|
+
scheduleIndex: { type: "number", description: "Feature-to-Story total schedule order for dependency-safe execution." },
|
|
535
|
+
schedule_index: { type: "number", description: "Snake_case alias for scheduleIndex." },
|
|
536
|
+
waveIndex: { type: "number", description: "Feature-to-Story parallel wave number." },
|
|
537
|
+
wave_index: { type: "number", description: "Snake_case alias for waveIndex." },
|
|
538
|
+
featureScheduleIndex: { type: "number", description: "Optional ordering within the Feature." },
|
|
539
|
+
feature_schedule_index: { type: "number", description: "Snake_case alias for featureScheduleIndex." },
|
|
540
|
+
expectedOutput: { type: "string", description: "Durable output this Story should produce for dependents." },
|
|
541
|
+
expected_output: { type: "string", description: "Snake_case alias for expectedOutput." },
|
|
542
|
+
handoffSummary: { type: "string", description: "How dependent Stories should consume this Story output." },
|
|
543
|
+
handoff_summary: { type: "string", description: "Snake_case alias for handoffSummary." },
|
|
544
|
+
dependencyReason: { type: "string", description: "Why this Story depends on its dependsOn predecessors." },
|
|
545
|
+
dependency_reason: { type: "string", description: "Snake_case alias for dependencyReason." },
|
|
546
|
+
requiresDesign: {
|
|
547
|
+
type: "boolean",
|
|
548
|
+
description: "Feature-to-Story only. True when the Story adds or changes user-visible UI; Forge holds it until a design reference is attached. False for non-visual Stories."
|
|
549
|
+
},
|
|
550
|
+
requires_design: { type: "boolean", description: "Snake_case alias for requiresDesign." }
|
|
551
|
+
};
|
|
539
552
|
function decomposeGateToolInputSchema(gate, phaseProperties) {
|
|
540
553
|
// Advertise every status the Decompose writer accepts, so the schema and the runtime agree.
|
|
541
554
|
const baseProperties = {
|
|
@@ -572,18 +585,7 @@ function decomposeGateToolInputSchema(gate, phaseProperties) {
|
|
|
572
585
|
acceptanceCriteria: { type: "string" },
|
|
573
586
|
planningPacket: { type: "string" },
|
|
574
587
|
sortOrder: { type: "number" },
|
|
575
|
-
|
|
576
|
-
schedule_index: { type: "number", description: "Snake_case alias for scheduleIndex." },
|
|
577
|
-
waveIndex: { type: "number", description: "Feature-to-Story parallel wave number." },
|
|
578
|
-
wave_index: { type: "number", description: "Snake_case alias for waveIndex." },
|
|
579
|
-
featureScheduleIndex: { type: "number", description: "Optional ordering within the Feature." },
|
|
580
|
-
feature_schedule_index: { type: "number", description: "Snake_case alias for featureScheduleIndex." },
|
|
581
|
-
expectedOutput: { type: "string", description: "Durable output this Story should produce for dependents." },
|
|
582
|
-
expected_output: { type: "string", description: "Snake_case alias for expectedOutput." },
|
|
583
|
-
handoffSummary: { type: "string", description: "How dependent Stories should consume this Story output." },
|
|
584
|
-
handoff_summary: { type: "string", description: "Snake_case alias for handoffSummary." },
|
|
585
|
-
dependencyReason: { type: "string", description: "Why this Story depends on its dependsOn predecessors." },
|
|
586
|
-
dependency_reason: { type: "string", description: "Snake_case alias for dependencyReason." },
|
|
588
|
+
...storyCandidateScheduleProperties,
|
|
587
589
|
points: { type: "number" },
|
|
588
590
|
dependsOn: { type: "array", items: { type: "string" } },
|
|
589
591
|
estimatedQaScope: qaScopeSchema("Work Order-to-Feature planning QA estimate. This is not dispatch-authoritative QA scope."),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { qaBlockerReasons, qaCandidateBugActions, qaFindingScopes, qaFindingSeverities, qaGateToolNames, qaScopeAuthorities, qaScopeCapabilities, qaScopeConfidence, qaScopeEvidence, qaScopeFields, qaScopeSources, qaScopeSurfaces } from "./phase-completion.js";
|
|
2
2
|
import { structuredTypeHint } from "./mcp-argument-coercion.js";
|
|
3
|
+
import { validateArchitectWaits } from "./architect-waits.js";
|
|
3
4
|
import { validateQaGatePassingCommands } from "./phase-completion.command-validation.js";
|
|
4
5
|
export { validateQaGatePassingCommands } from "./phase-completion.command-validation.js";
|
|
5
6
|
export const qaEvidenceGates = new Set(["qa_regression", "qa_api", "qa_manual_web", "qa_bug_repro"]);
|
|
@@ -353,6 +354,7 @@ export function validateQaGatePayloadShape(gate, payload, status) {
|
|
|
353
354
|
}
|
|
354
355
|
}
|
|
355
356
|
export function validateArchitectPayloadShape(payload, status) {
|
|
357
|
+
validateArchitectWaits(payload, status);
|
|
356
358
|
if (status !== "pass") {
|
|
357
359
|
requireArchitectNonPassEvidence(payload);
|
|
358
360
|
return;
|
|
@@ -706,7 +708,7 @@ export function hasArchitectDependencyCycle(edges) {
|
|
|
706
708
|
return false;
|
|
707
709
|
}
|
|
708
710
|
export function requireArchitectNonPassEvidence(payload) {
|
|
709
|
-
const evidenceKeys = ["blockers", "revision_questions", "revision_reasons", "known_gaps", "findings", "remaining_risks", "failures"];
|
|
711
|
+
const evidenceKeys = ["blockers", "revision_questions", "revision_reasons", "waits_on", "owner_decision", "known_gaps", "findings", "remaining_risks", "failures"];
|
|
710
712
|
const hasEvidence = evidenceKeys.some((key) => {
|
|
711
713
|
const value = payload[key];
|
|
712
714
|
if (typeof value === "string") {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DockerEngineProbe } from "../runtime/docker-engine-probe.js";
|
|
2
|
+
import { startEphemeralTestPostgresGrant } from "../runtime/ephemeral-test-postgres-grant.js";
|
|
3
|
+
import { type NativeTestPostgresFallback, type NativeTestPostgresGrant } from "../runtime/native-test-postgres-fallback.js";
|
|
4
|
+
import type { RunnerDispatchEvent } from "./session.types.js";
|
|
5
|
+
/**
|
|
6
|
+
* A provisioned native test cluster whose file prefers it serves this check's shared
|
|
7
|
+
* test server without waiting on Docker (owner policy 2026-11-16: native PostgreSQL
|
|
8
|
+
* first). Docker is still probed, never recovered, so the fixtures know whether
|
|
9
|
+
* pinned-engine tests can start their own containers. An unreadable file leaves the
|
|
10
|
+
* check on Docker.
|
|
11
|
+
*/
|
|
12
|
+
export declare function preferredNativeTestPostgres(checkId: string, requiredPrerequisite: string | undefined, readCluster: () => NativeTestPostgresFallback | null, dockerEngineProbe: DockerEngineProbe | undefined, emit?: (event: RunnerDispatchEvent) => Promise<void>, startEphemeral?: typeof startEphemeralTestPostgresGrant): Promise<NativeTestPostgresGrant | undefined>;
|
|
13
|
+
/** Whether this check already has its isolated PostgreSQL without Docker. */
|
|
14
|
+
export declare function isolatedPostgresProvided(checkId: string, environment?: Readonly<Record<string, string>>, postgresAdminConnection?: NativeTestPostgresGrant): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The grant, when it makes its check Docker-free. A native_preferred grant still lets
|
|
17
|
+
* pinned-engine tests start Docker containers, so a Docker loss during its check stays
|
|
18
|
+
* retryable infrastructure; only a native_fallback grant (Docker was already down) does not.
|
|
19
|
+
*/
|
|
20
|
+
export declare function dockerFreeGrant(grant: NativeTestPostgresGrant | undefined): NativeTestPostgresGrant | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Releases a check's ephemeral cluster once the check has ended. A cluster that would not stop
|
|
23
|
+
* is left disowned for the next start's reap and does not change the check's own result.
|
|
24
|
+
*/
|
|
25
|
+
export declare function releaseCheckPostgres(checkId: string, grant: NativeTestPostgresGrant | undefined, emit?: (event: RunnerDispatchEvent) => Promise<void>): Promise<void>;
|
|
26
|
+
/** The native cluster grant for a check while Docker stays down, or null when it cannot use one. */
|
|
27
|
+
export declare function dockerUnavailableNativeTestPostgres(checkId: string, requiredPrerequisite: string | undefined, readCluster: () => NativeTestPostgresFallback | null): NativeTestPostgresGrant | null;
|
|
28
|
+
export type { NativeTestPostgresFallback, NativeTestPostgresGrant };
|
|
29
|
+
/** Starts a check's ephemeral cluster; injectable so tests need no PostgreSQL install. */
|
|
30
|
+
export type StartEphemeralTestPostgresGrant = typeof startEphemeralTestPostgresGrant;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { attemptDatabaseCapabilityEnvironment } from "../runtime/attempt-database-broker.js";
|
|
3
|
+
import { startEphemeralTestPostgresGrant } from "../runtime/ephemeral-test-postgres-grant.js";
|
|
4
|
+
import { nativeTestPostgresFallbackDatabaseMode, nativeTestPostgresGrant, } from "../runtime/native-test-postgres-fallback.js";
|
|
5
|
+
import { validationEvent } from "./pre-publication-pass.js";
|
|
6
|
+
import { supportsNativeTestPostgresFallback } from "./pre-publication-step-execution.js";
|
|
7
|
+
// Which PostgreSQL a pre-publication check's isolated_postgres prerequisite is met by,
|
|
8
|
+
// before the validator falls back to waiting for Docker.
|
|
9
|
+
/**
|
|
10
|
+
* A provisioned native test cluster whose file prefers it serves this check's shared
|
|
11
|
+
* test server without waiting on Docker (owner policy 2026-11-16: native PostgreSQL
|
|
12
|
+
* first). Docker is still probed, never recovered, so the fixtures know whether
|
|
13
|
+
* pinned-engine tests can start their own containers. An unreadable file leaves the
|
|
14
|
+
* check on Docker.
|
|
15
|
+
*/
|
|
16
|
+
export async function preferredNativeTestPostgres(checkId, requiredPrerequisite, readCluster, dockerEngineProbe, emit, startEphemeral = startEphemeralTestPostgresGrant) {
|
|
17
|
+
if (requiredPrerequisite !== "isolated_postgres" || !supportsNativeTestPostgresFallback(checkId))
|
|
18
|
+
return undefined;
|
|
19
|
+
let configured;
|
|
20
|
+
try {
|
|
21
|
+
configured = readCluster();
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
await emit?.(validationEvent("prepublication_prerequisite_native_invalid", checkId, `The native PostgreSQL test cluster configuration was refused, so '${checkId}' uses Docker: ${error instanceof Error ? error.message : String(error)}`));
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (configured?.use === "ephemeral") {
|
|
28
|
+
return await ephemeralNativeTestPostgres(checkId, configured, dockerEngineProbe, emit, startEphemeral);
|
|
29
|
+
}
|
|
30
|
+
if (configured?.use !== "preferred")
|
|
31
|
+
return undefined;
|
|
32
|
+
const dockerAvailable = dockerEngineProbe ? (await dockerEngineProbe.probeWithoutRecovery()).available : false;
|
|
33
|
+
const grant = nativeTestPostgresGrant(configured, dockerAvailable);
|
|
34
|
+
if (!grant)
|
|
35
|
+
return undefined;
|
|
36
|
+
await emit?.(validationEvent("prepublication_prerequisite_native_preferred", checkId, `Pre-publication check '${checkId}' is using the dedicated native PostgreSQL test cluster at ${grant.endpoint} with per-run owned databases${dockerAvailable
|
|
37
|
+
? "; tests that need a pinned engine container still start one in Docker."
|
|
38
|
+
: ". Docker is unavailable, so tests that need a pinned engine container are skipped."}`));
|
|
39
|
+
return grant;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A throwaway cluster of the check's own, whose superuser it holds (owner policy 2026-11-17).
|
|
43
|
+
* If it cannot start, the check falls back to Docker, and to the provisioned cluster only while
|
|
44
|
+
* Docker is down.
|
|
45
|
+
*/
|
|
46
|
+
async function ephemeralNativeTestPostgres(checkId, configured, dockerEngineProbe, emit, startEphemeral) {
|
|
47
|
+
const dockerAvailable = dockerEngineProbe ? (await dockerEngineProbe.probeWithoutRecovery()).available : false;
|
|
48
|
+
let grant;
|
|
49
|
+
try {
|
|
50
|
+
grant = await startEphemeral(configured, dockerAvailable);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
await emit?.(validationEvent("prepublication_prerequisite_ephemeral_unavailable", checkId, `An ephemeral PostgreSQL test cluster could not start for '${checkId}', so it uses Docker: ${error instanceof Error ? error.message : String(error)}`));
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
await emit?.(validationEvent("prepublication_prerequisite_native_ephemeral", checkId, `Pre-publication check '${checkId}' is using its own ephemeral PostgreSQL test cluster at ${grant.endpoint}, deleted when the check ends${dockerAvailable
|
|
58
|
+
? "; tests that need a pinned engine container still start one in Docker."
|
|
59
|
+
: ". Docker is unavailable, so tests that need a pinned engine container are skipped."}`));
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
// The caller releases only a grant it receives, so a failed emit releases it here.
|
|
63
|
+
await grant.release?.().catch(() => undefined);
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
return grant;
|
|
67
|
+
}
|
|
68
|
+
function environmentValue(environment, name) {
|
|
69
|
+
return Object.prototype.hasOwnProperty.call(environment ?? {}, name)
|
|
70
|
+
? environment?.[name]?.trim() ?? ""
|
|
71
|
+
: process.env[name]?.trim() ?? "";
|
|
72
|
+
}
|
|
73
|
+
/** Whether this check already has its isolated PostgreSQL without Docker. */
|
|
74
|
+
export function isolatedPostgresProvided(checkId, environment, postgresAdminConnection) {
|
|
75
|
+
if (checkId === "playwright-e2e") {
|
|
76
|
+
const attemptId = environmentValue(environment, "FORGE_DISPATCH_ATTEMPT_ID");
|
|
77
|
+
return (environmentValue(environment, "FORGE_E2E_OWNERSHIP_MODE") === "attempt"
|
|
78
|
+
|| /^[0-9a-f-]{36}$/iu.test(attemptId))
|
|
79
|
+
&& /^forge_attempt_[0-9a-f]{32}$/u.test(environmentValue(environment, "FORGE_ATTEMPT_DATABASE_SCHEMA"))
|
|
80
|
+
&& path.isAbsolute(environmentValue(environment, "FORGE_ATTEMPT_DATABASE_READINESS_PATH"))
|
|
81
|
+
// The attempt owns a database only once the Bridge's broker has issued it one.
|
|
82
|
+
&& environmentValue(environment, attemptDatabaseCapabilityEnvironment).length > 0;
|
|
83
|
+
}
|
|
84
|
+
return Boolean(postgresAdminConnection);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The grant, when it makes its check Docker-free. A native_preferred grant still lets
|
|
88
|
+
* pinned-engine tests start Docker containers, so a Docker loss during its check stays
|
|
89
|
+
* retryable infrastructure; only a native_fallback grant (Docker was already down) does not.
|
|
90
|
+
*/
|
|
91
|
+
export function dockerFreeGrant(grant) {
|
|
92
|
+
return grant?.mode === nativeTestPostgresFallbackDatabaseMode ? grant : undefined;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Releases a check's ephemeral cluster once the check has ended. A cluster that would not stop
|
|
96
|
+
* is left disowned for the next start's reap and does not change the check's own result.
|
|
97
|
+
*/
|
|
98
|
+
export async function releaseCheckPostgres(checkId, grant, emit) {
|
|
99
|
+
try {
|
|
100
|
+
await grant?.release?.();
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
await emit?.(validationEvent("prepublication_ephemeral_release_failed", checkId, `The ephemeral PostgreSQL test cluster for '${checkId}' could not be released and will be reaped later: ${error instanceof Error ? error.message : String(error)}`)).catch(() => undefined);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** The native cluster grant for a check while Docker stays down, or null when it cannot use one. */
|
|
107
|
+
export function dockerUnavailableNativeTestPostgres(checkId, requiredPrerequisite, readCluster) {
|
|
108
|
+
return requiredPrerequisite === "isolated_postgres" && supportsNativeTestPostgresFallback(checkId)
|
|
109
|
+
? nativeTestPostgresGrant(readCluster(), false)
|
|
110
|
+
: null;
|
|
111
|
+
}
|
|
@@ -29,7 +29,8 @@ export declare class PrePublicationValidationError extends ForgeFailureError {
|
|
|
29
29
|
export declare class PrePublicationPass {
|
|
30
30
|
private readonly runtimeRestartFailure?;
|
|
31
31
|
private readonly failures;
|
|
32
|
-
|
|
32
|
+
/** The check whose .NET build failed to compile in this pass, if any. */
|
|
33
|
+
private dotnetCompileFailedIn;
|
|
33
34
|
/** A failed runtime restart before the pass is its first failure. */
|
|
34
35
|
constructor(runtimeRestartFailure?: PrePublicationValidationError | undefined);
|
|
35
36
|
record(failure: PrePublicationCheckFailure, failedStep?: ValidationStep): void;
|
|
@@ -7,7 +7,9 @@ import { ForgeFailureError, failureFactsFromError } from "./session.types.js";
|
|
|
7
7
|
// could not run because a check they depend on failed, and reports them all as one failure.
|
|
8
8
|
/** The check id a failed restart of the attempt's runtime stack before the pass is reported under. */
|
|
9
9
|
export const runtimeRestartCheckId = "host-runtime-restart";
|
|
10
|
-
|
|
10
|
+
// The checks whose first step builds the .NET solution: CI's whole-tier check and the affected
|
|
11
|
+
// tests every gate profile runs (decision 0017).
|
|
12
|
+
const dotnetBuildCheckIds = new Set(["dotnet-build-and-unit", "comment-repair-dotnet-regression"]);
|
|
11
13
|
// Checks that build the .NET solution themselves and would only repeat the compiler errors once its
|
|
12
14
|
// compile step fails: the OpenAPI export builds Forge.Api and the E2E suite publishes it.
|
|
13
15
|
const dotnetBuildConsumers = new Set(["openapi-and-generated-types", "playwright-e2e"]);
|
|
@@ -62,7 +64,8 @@ function clipDetail(detail) {
|
|
|
62
64
|
export class PrePublicationPass {
|
|
63
65
|
runtimeRestartFailure;
|
|
64
66
|
failures = [];
|
|
65
|
-
|
|
67
|
+
/** The check whose .NET build failed to compile in this pass, if any. */
|
|
68
|
+
dotnetCompileFailedIn = null;
|
|
66
69
|
/** A failed runtime restart before the pass is its first failure. */
|
|
67
70
|
constructor(runtimeRestartFailure) {
|
|
68
71
|
this.runtimeRestartFailure = runtimeRestartFailure;
|
|
@@ -70,14 +73,14 @@ export class PrePublicationPass {
|
|
|
70
73
|
}
|
|
71
74
|
record(failure, failedStep) {
|
|
72
75
|
this.failures.push(failure);
|
|
73
|
-
if (failure.checkId
|
|
74
|
-
this.
|
|
76
|
+
if (dotnetBuildCheckIds.has(failure.checkId) && failedStep?.command === "dotnet" && failedStep.args[0] === "build") {
|
|
77
|
+
this.dotnetCompileFailedIn ??= failure.checkId;
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
/** The failed checks that keep this check from running meaningfully in this pass. */
|
|
78
81
|
blockers(checkId) {
|
|
79
82
|
return [
|
|
80
|
-
...(this.
|
|
83
|
+
...(this.dotnetCompileFailedIn && dotnetBuildConsumers.has(checkId) ? [this.dotnetCompileFailedIn] : []),
|
|
81
84
|
...(this.runtimeRestartFailure && runtimeStackConsumers.has(checkId) ? [runtimeRestartCheckId] : []),
|
|
82
85
|
];
|
|
83
86
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type NativeTestPostgresGrant } from "../runtime/native-test-postgres-fallback.js";
|
|
1
2
|
import type { PrePublicationExecutionContext } from "./pre-publication-validation.js";
|
|
2
3
|
export interface ValidationStep {
|
|
3
4
|
readonly command: string;
|
|
@@ -8,4 +9,4 @@ export interface ValidationStep {
|
|
|
8
9
|
}
|
|
9
10
|
export declare function managedAttemptInvocation(checkId: string, step: ValidationStep, environment?: Readonly<Record<string, string>>): Pick<ValidationStep, "command" | "args">;
|
|
10
11
|
export declare function supportsNativeTestPostgresFallback(checkId: string): boolean;
|
|
11
|
-
export declare function validationExecutionForStep(checkId: string, step: ValidationStep, execution?: PrePublicationExecutionContext, postgresAdminConnection?:
|
|
12
|
+
export declare function validationExecutionForStep(checkId: string, step: ValidationStep, execution?: PrePublicationExecutionContext, postgresAdminConnection?: NativeTestPostgresGrant): PrePublicationExecutionContext | undefined;
|
|
@@ -29,21 +29,22 @@ export function supportsNativeTestPostgresFallback(checkId) {
|
|
|
29
29
|
return nativeFallbackCheckIds.has(checkId);
|
|
30
30
|
}
|
|
31
31
|
export function validationExecutionForStep(checkId, step, execution, postgresAdminConnection) {
|
|
32
|
-
// The
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
// Bridge, and E2E steps never do.
|
|
32
|
+
// The grant only exists when the operator provisioned a dedicated native test
|
|
33
|
+
// cluster, and only the runner-authored .NET test tiers and the suite-identity
|
|
34
|
+
// check receive it; build, client, Bridge, and E2E steps never do.
|
|
36
35
|
if (!postgresAdminConnection || !nativeFallbackCheckIds.has(checkId))
|
|
37
36
|
return execution;
|
|
38
37
|
const runsDotnetTier = step.args.some(argument => nativeFallbackDotnetTierScripts
|
|
39
38
|
.some(script => argument.replaceAll("\\", "/").endsWith(script)));
|
|
40
39
|
if (checkId !== "owned-suite-registration" && !runsDotnetTier)
|
|
41
40
|
return execution;
|
|
41
|
+
// Re-validate the connection before it reaches attempt code.
|
|
42
|
+
parseNativeTestPostgresFallback(postgresAdminConnection.connectionString);
|
|
42
43
|
return {
|
|
43
44
|
...execution,
|
|
44
45
|
environment: {
|
|
45
46
|
...execution?.environment,
|
|
46
|
-
...nativeTestPostgresFallbackEnvironment(
|
|
47
|
+
...nativeTestPostgresFallbackEnvironment(postgresAdminConnection),
|
|
47
48
|
},
|
|
48
49
|
};
|
|
49
50
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DockerEngineProbe } from "../runtime/docker-engine-probe.js";
|
|
2
|
-
import type { NativeTestPostgresFallback } from "../runtime/native-test-postgres-fallback.js";
|
|
3
2
|
import type { HostLoadStepGate } from "../runtime/host-load-governor.js";
|
|
4
3
|
import { type PrePublicationHostLoadOwner } from "./pre-publication-host-load.js";
|
|
4
|
+
import { type NativeTestPostgresFallback, type StartEphemeralTestPostgresGrant } from "./pre-publication-native-postgres.js";
|
|
5
5
|
import { type ValidationStep } from "./pre-publication-step-execution.js";
|
|
6
6
|
import { PrePublicationValidationError, type PrePublicationCheckFailure } from "./pre-publication-pass.js";
|
|
7
7
|
import type { ProviderProcessRunner } from "./provider-cli/provider-cli.process.js";
|
|
@@ -56,7 +56,8 @@ export declare class PrePublicationValidator {
|
|
|
56
56
|
private readonly dockerEngineProbe?;
|
|
57
57
|
private readonly nativeTestPostgresFallback;
|
|
58
58
|
private readonly hostLoad?;
|
|
59
|
-
|
|
59
|
+
private readonly startEphemeral?;
|
|
60
|
+
constructor(commands?: PrePublicationCommandRunner, dockerEngineProbe?: DockerEngineProbe | undefined, nativeTestPostgresFallback?: () => NativeTestPostgresFallback | null, hostLoad?: HostLoadStepGate | undefined, startEphemeral?: StartEphemeralTestPostgresGrant | undefined);
|
|
60
61
|
/**
|
|
61
62
|
* Runs one pre-publication pass. A failed check does not end the pass: every remaining check that
|
|
62
63
|
* can still meaningfully run keeps going, and the pass then throws all of its failures as one
|
|
@@ -66,17 +67,22 @@ export declare class PrePublicationValidator {
|
|
|
66
67
|
private runChecks;
|
|
67
68
|
/** Runs one check's steps in order; the first failed step ends the check, since later steps use its output. */
|
|
68
69
|
private runCheck;
|
|
70
|
+
private runCheckSteps;
|
|
69
71
|
/** Runs a step, confirming once a failure that matches a known transient pattern. */
|
|
70
72
|
private runConfirmedStep;
|
|
71
73
|
private runCheckedStep;
|
|
72
74
|
private confirmStep;
|
|
73
75
|
private confirmInfrastructure;
|
|
74
|
-
/** Returns the native
|
|
76
|
+
/** Returns the native cluster grant when this check uses it instead of Docker. */
|
|
75
77
|
private ensurePrerequisite;
|
|
78
|
+
/** Waits for Docker; returns the native cluster grant when Docker stays down and a cluster is provisioned. */
|
|
79
|
+
private ensureDockerPrerequisite;
|
|
76
80
|
private throwIfPrerequisiteWasLost;
|
|
77
81
|
private checkTestOnlyExports;
|
|
78
82
|
private changedPaths;
|
|
79
83
|
private assertContractMatchesDispatchBaseline;
|
|
84
|
+
/** The approved contract of the branch an in-progress merge brings in (MERGE_HEAD), else null. */
|
|
85
|
+
private mergedInContractDigest;
|
|
80
86
|
private runStep;
|
|
81
87
|
private launchStep;
|
|
82
88
|
private runCommand;
|
|
@@ -4,7 +4,8 @@ import path from "node:path";
|
|
|
4
4
|
import { attemptDatabaseCapabilityEnvironment, attemptDatabaseCapabilitySecrets, } from "../runtime/attempt-database-broker.js";
|
|
5
5
|
import { assertHostDatabaseCapabilityBoundary } from "../runtime/host-database-capability-boundary.js";
|
|
6
6
|
import { runHostGovernedValidationStep } from "./pre-publication-host-load.js";
|
|
7
|
-
import {
|
|
7
|
+
import { dockerFreeGrant, dockerUnavailableNativeTestPostgres, isolatedPostgresProvided, preferredNativeTestPostgres, releaseCheckPostgres, } from "./pre-publication-native-postgres.js";
|
|
8
|
+
import { managedAttemptInvocation, validationExecutionForStep, } from "./pre-publication-step-execution.js";
|
|
8
9
|
import { hostRuntimeLegacyTestPostgresEnvironment, hostRuntimeTestPostgresAdminEnvironment, hostRuntimeTestPostgresProvisionerEnvironment, } from "../runtime/host-runtime-contract.js";
|
|
9
10
|
import { redactText } from "../shared/redaction/redaction.js";
|
|
10
11
|
import { PrePublicationPass, PrePublicationValidationError, SkippedTestTally, skippedCheckEvent, validationEvent, } from "./pre-publication-pass.js";
|
|
@@ -23,16 +24,21 @@ const requiredCheckIds = new Set([
|
|
|
23
24
|
"playwright-e2e",
|
|
24
25
|
"github-provider-policy",
|
|
25
26
|
]);
|
|
26
|
-
|
|
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";
|
|
27
32
|
// Comment repair ran the whole ApiComponent and Orchestration tiers under this contract.
|
|
28
|
-
// Story branches cut before the affected-tests contract still carry it.
|
|
29
33
|
const wholeTierCommentRepairContractDigest = "024de3648c907db9c0eab13def9a4f91e81148433e0a2ba7f44776446421054a";
|
|
30
34
|
// Contracts that declare the comment-repair-dotnet-regression check.
|
|
31
35
|
const commentRepairRegressionContractDigests = new Set([
|
|
32
36
|
currentApprovedContractDigest,
|
|
37
|
+
commentRepairOnlyAffectedContractDigest,
|
|
33
38
|
wholeTierCommentRepairContractDigest,
|
|
34
39
|
]);
|
|
35
40
|
const compatibleApprovedContractDigests = new Set([
|
|
41
|
+
commentRepairOnlyAffectedContractDigest,
|
|
36
42
|
wholeTierCommentRepairContractDigest,
|
|
37
43
|
// Preserve dispatches pinned before comment repair gained all .NET regression tiers.
|
|
38
44
|
"c0014ce6abc0e0b2e66dd2bcf6cb14c47d28506444c73f87d1b76b3d1c06027b",
|
|
@@ -95,11 +101,13 @@ export class PrePublicationValidator {
|
|
|
95
101
|
dockerEngineProbe;
|
|
96
102
|
nativeTestPostgresFallback;
|
|
97
103
|
hostLoad;
|
|
98
|
-
|
|
104
|
+
startEphemeral;
|
|
105
|
+
constructor(commands = new ProcessPrePublicationCommandRunner(), dockerEngineProbe, nativeTestPostgresFallback = () => null, hostLoad, startEphemeral) {
|
|
99
106
|
this.commands = commands;
|
|
100
107
|
this.dockerEngineProbe = dockerEngineProbe;
|
|
101
108
|
this.nativeTestPostgresFallback = nativeTestPostgresFallback;
|
|
102
109
|
this.hostLoad = hostLoad;
|
|
110
|
+
this.startEphemeral = startEphemeral;
|
|
103
111
|
}
|
|
104
112
|
/**
|
|
105
113
|
* Runs one pre-publication pass. A failed check does not end the pass: every remaining check that
|
|
@@ -139,7 +147,7 @@ export class PrePublicationValidator {
|
|
|
139
147
|
capabilities,
|
|
140
148
|
emit,
|
|
141
149
|
signal,
|
|
142
|
-
execution: scoped.execution,
|
|
150
|
+
execution: withValidationBaseRevision(scoped.execution),
|
|
143
151
|
postgresAdminConnection: scoped.postgresAdminConnection,
|
|
144
152
|
};
|
|
145
153
|
return await this.runChecks(applicableChecks(contract, profile, changedPaths), run, pass);
|
|
@@ -184,8 +192,16 @@ export class PrePublicationValidator {
|
|
|
184
192
|
if (check.requiredCapability && !run.capabilities.has(check.requiredCapability)) {
|
|
185
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");
|
|
186
194
|
}
|
|
187
|
-
const
|
|
188
|
-
|
|
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;
|
|
189
205
|
await run.emit?.(validationEvent("prepublication_validation_started", check.id, `Running pre-publication CI parity check '${check.id}'.`));
|
|
190
206
|
const skipped = new SkippedTestTally(run.worktreePath, run.execution?.environment);
|
|
191
207
|
for (const step of check.steps) {
|
|
@@ -201,7 +217,11 @@ export class PrePublicationValidator {
|
|
|
201
217
|
}
|
|
202
218
|
await skipped.add(result.args, stepStartedMs);
|
|
203
219
|
}
|
|
204
|
-
|
|
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
|
+
]));
|
|
205
225
|
return null;
|
|
206
226
|
}
|
|
207
227
|
/** Runs a step, confirming once a failure that matches a known transient pattern. */
|
|
@@ -250,7 +270,7 @@ export class PrePublicationValidator {
|
|
|
250
270
|
await run.emit?.(validationEvent("prepublication_infrastructure_failed", checkId, `Pre-publication infrastructure for '${checkId}' remained unavailable${detail ? `: ${detail}` : "."}`));
|
|
251
271
|
throw new PrePublicationInfrastructureError(checkId, result.exitCode, result.command, result.args, detail);
|
|
252
272
|
}
|
|
253
|
-
/** Returns the native
|
|
273
|
+
/** Returns the native cluster grant when this check uses it instead of Docker. */
|
|
254
274
|
async ensurePrerequisite(check, environment, postgresAdminConnection, emit) {
|
|
255
275
|
if (check.requiredPrerequisite === "isolated_postgres"
|
|
256
276
|
&& isolatedPostgresProvided(check.id, environment, postgresAdminConnection)) {
|
|
@@ -259,6 +279,11 @@ export class PrePublicationValidator {
|
|
|
259
279
|
: `Pre-publication check '${check.id}' is using the configured loopback PostgreSQL test server with per-run owned databases. No Docker daemon is required.`));
|
|
260
280
|
return undefined;
|
|
261
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) {
|
|
262
287
|
if (check.requiredPrerequisite === undefined || !this.dockerEngineProbe)
|
|
263
288
|
return undefined;
|
|
264
289
|
const current = this.dockerEngineProbe.current();
|
|
@@ -270,12 +295,10 @@ export class PrePublicationValidator {
|
|
|
270
295
|
const snapshot = await this.dockerEngineProbe.ensureAvailableForRequiredWork();
|
|
271
296
|
if (!snapshot.available) {
|
|
272
297
|
const detail = `Docker prerequisite unavailable (${snapshot.unavailableCode ?? "docker_engine_unavailable"}): ${snapshot.unavailableReason ?? "the daemon did not pass a fresh readiness probe"}`;
|
|
273
|
-
const fallback = check.
|
|
274
|
-
? this.nativeTestPostgresFallback()
|
|
275
|
-
: null;
|
|
298
|
+
const fallback = dockerUnavailableNativeTestPostgres(check.id, check.requiredPrerequisite, this.nativeTestPostgresFallback);
|
|
276
299
|
if (fallback) {
|
|
277
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.`));
|
|
278
|
-
return fallback
|
|
301
|
+
return fallback;
|
|
279
302
|
}
|
|
280
303
|
await emit?.(validationEvent("prepublication_prerequisite_unavailable", check.id, `Pre-publication check '${check.id}' is waiting for Docker infrastructure recovery: ${detail}`));
|
|
281
304
|
throw new PrePublicationInfrastructureError(check.id, 75, "docker", ["info"], detail);
|
|
@@ -287,7 +310,7 @@ export class PrePublicationValidator {
|
|
|
287
310
|
if (result.exitCode === 0
|
|
288
311
|
|| check.requiredPrerequisite === undefined
|
|
289
312
|
|| (check.requiredPrerequisite === "isolated_postgres"
|
|
290
|
-
&& isolatedPostgresProvided(check.id, environment, postgresAdminConnection))
|
|
313
|
+
&& isolatedPostgresProvided(check.id, environment, dockerFreeGrant(postgresAdminConnection)))
|
|
291
314
|
|| !this.dockerEngineProbe)
|
|
292
315
|
return;
|
|
293
316
|
const snapshot = await this.dockerEngineProbe.refresh(true);
|
|
@@ -353,10 +376,24 @@ export class PrePublicationValidator {
|
|
|
353
376
|
if (!approvedContractDigests.has(baselineDigest)) {
|
|
354
377
|
throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the dispatch baseline uses unapproved CI parity contract ${baselineDigest}.`, "bridge");
|
|
355
378
|
}
|
|
356
|
-
|
|
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) {
|
|
357
381
|
throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the CI parity contract changed after dispatch (baseline ${baselineDigest}, worktree ${contractDigest}).`, "bridge");
|
|
358
382
|
}
|
|
359
383
|
}
|
|
384
|
+
/** The approved contract of the branch an in-progress merge brings in (MERGE_HEAD), else null. */
|
|
385
|
+
async mergedInContractDigest(worktreePath, signal, execution) {
|
|
386
|
+
const merged = await this.runCommand("git", ["show", `MERGE_HEAD:${contractRelativePath}`], worktreePath, signal, execution);
|
|
387
|
+
if (merged.exitCode !== 0)
|
|
388
|
+
return null;
|
|
389
|
+
try {
|
|
390
|
+
const digest = validationContractDigest(JSON.parse(merged.stdout ?? ""));
|
|
391
|
+
return approvedContractDigests.has(digest) ? digest : null;
|
|
392
|
+
}
|
|
393
|
+
catch {
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
360
397
|
async runStep(checkId, step, cwd, signal, execution, postgresAdminConnection, emit) {
|
|
361
398
|
const invocation = managedAttemptInvocation(checkId, step, execution?.environment);
|
|
362
399
|
// Every launch, including confirmation reruns, is admitted by the host load governor first.
|
|
@@ -416,27 +453,11 @@ export class PrePublicationValidator {
|
|
|
416
453
|
}
|
|
417
454
|
}
|
|
418
455
|
}
|
|
419
|
-
function environmentValue(environment, name) {
|
|
420
|
-
return Object.prototype.hasOwnProperty.call(environment ?? {}, name)
|
|
421
|
-
? environment?.[name]?.trim() ?? ""
|
|
422
|
-
: process.env[name]?.trim() ?? "";
|
|
423
|
-
}
|
|
424
|
-
function isolatedPostgresProvided(checkId, environment, postgresAdminConnection) {
|
|
425
|
-
if (checkId === "playwright-e2e") {
|
|
426
|
-
const attemptId = environmentValue(environment, "FORGE_DISPATCH_ATTEMPT_ID");
|
|
427
|
-
return (environmentValue(environment, "FORGE_E2E_OWNERSHIP_MODE") === "attempt"
|
|
428
|
-
|| /^[0-9a-f-]{36}$/iu.test(attemptId))
|
|
429
|
-
&& /^forge_attempt_[0-9a-f]{32}$/u.test(environmentValue(environment, "FORGE_ATTEMPT_DATABASE_SCHEMA"))
|
|
430
|
-
&& path.isAbsolute(environmentValue(environment, "FORGE_ATTEMPT_DATABASE_READINESS_PATH"))
|
|
431
|
-
// The attempt owns a database only once the Bridge's broker has issued it one.
|
|
432
|
-
&& environmentValue(environment, attemptDatabaseCapabilityEnvironment).length > 0;
|
|
433
|
-
}
|
|
434
|
-
return Boolean(postgresAdminConnection);
|
|
435
|
-
}
|
|
436
456
|
function validationExactSecrets(environment) {
|
|
437
457
|
return [
|
|
438
|
-
|
|
439
|
-
environment?.[
|
|
458
|
+
// The connection strings and their passwords: a test may print either.
|
|
459
|
+
...attemptDatabaseCapabilitySecrets(environment?.[hostRuntimeTestPostgresAdminEnvironment]),
|
|
460
|
+
...attemptDatabaseCapabilitySecrets(environment?.[hostRuntimeLegacyTestPostgresEnvironment]),
|
|
440
461
|
environment?.[hostRuntimeTestPostgresProvisionerEnvironment]?.trim() ?? "",
|
|
441
462
|
...attemptDatabaseCapabilitySecrets(environment?.[attemptDatabaseCapabilityEnvironment]),
|
|
442
463
|
].filter((value, index, values) => value.length > 0 && values.indexOf(value) === index);
|
|
@@ -626,6 +647,13 @@ export async function loadValidationContract(worktreePath) {
|
|
|
626
647
|
}
|
|
627
648
|
return contract;
|
|
628
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
|
+
}
|
|
629
657
|
function validationContractDigest(contract) {
|
|
630
658
|
return createHash("sha256")
|
|
631
659
|
.update(JSON.stringify(canonicalizeJson(contract)))
|