@loucompanion/forge-bridge 0.1.4-dev.8901ba056f68 → 0.1.4-dev.894bcbd53d64
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 +142 -1
- 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 +87 -14
- package/dist/bridge/bridge.service.js +394 -338
- package/dist/bridge/bridge.types.d.ts +16 -0
- 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 +3 -0
- package/dist/bridge/runner-host-capabilities.js +13 -0
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -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 +74 -12
- package/dist/cli/cli.service.d.ts +19 -10
- package/dist/cli/cli.service.js +149 -186
- 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 +2 -0
- package/dist/runtime/attempt-process-supervisor.js +12 -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-facts.d.ts +2 -1
- package/dist/runtime/host-load-admission.d.ts +18 -3
- package/dist/runtime/host-load-admission.js +19 -4
- package/dist/runtime/host-load-child-environment.d.ts +11 -6
- package/dist/runtime/host-load-child-environment.js +22 -11
- package/dist/runtime/host-load-governor-config.d.ts +19 -1
- package/dist/runtime/host-load-governor-config.js +37 -0
- package/dist/runtime/host-load-governor.d.ts +14 -0
- package/dist/runtime/host-load-governor.js +139 -26
- package/dist/runtime/host-load-ledger-lock.js +6 -4
- 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 +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-contract.d.ts +12 -0
- package/dist/runtime/host-runtime-contract.js +29 -1
- package/dist/runtime/host-runtime-lease.d.ts +59 -3
- package/dist/runtime/host-runtime-lease.js +212 -61
- package/dist/runtime/host-runtime-promotion.d.ts +23 -0
- package/dist/runtime/host-runtime-promotion.js +36 -0
- package/dist/runtime/managed-command-teardown.js +5 -16
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
- package/dist/runtime/runner-settings.d.ts +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 +10 -2
- package/dist/sandbox/host-capacity-broker.js +27 -6
- 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.js +2 -6
- package/dist/session/architect-waits.d.ts +2 -0
- package/dist/session/architect-waits.js +138 -0
- package/dist/session/managed-attempt-tools.d.ts +2 -7
- package/dist/session/managed-attempt-tools.js +94 -104
- package/dist/session/managed-build-coordinator.d.ts +16 -0
- package/dist/session/managed-build-coordinator.js +10 -0
- 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 +2 -0
- package/dist/session/managed-command-host-load.js +2 -1
- package/dist/session/mcp-argument-coercion.d.ts +23 -0
- package/dist/session/mcp-argument-coercion.js +121 -0
- package/dist/session/phase-completion.artifacts.d.ts +7 -0
- package/dist/session/phase-completion.artifacts.js +96 -26
- package/dist/session/phase-completion.command-validation.d.ts +7 -0
- package/dist/session/phase-completion.command-validation.js +77 -0
- package/dist/session/phase-completion.d.ts +10 -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 +4 -10
- package/dist/session/phase-completion.runtime.js +77 -209
- 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-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.js +10 -10
- package/dist/session/pre-publication-step-execution.d.ts +2 -1
- package/dist/session/pre-publication-step-execution.js +6 -5
- package/dist/session/pre-publication-validation.d.ts +30 -14
- package/dist/session/pre-publication-validation.js +207 -134
- 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.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.process.d.ts +15 -36
- package/dist/session/provider-cli/provider-cli.process.js +39 -430
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +5 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +72 -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 +78 -171
- package/dist/session/provider-cli/provider-cli.types.d.ts +26 -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 +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/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/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 +22 -1
- package/dist/session/sandbox-host-capacity-gate.js +42 -14
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.base.d.ts +6 -1
- package/dist/session/session.service.d.ts +9 -2
- package/dist/session/session.service.js +169 -66
- package/dist/session/session.types.js +4 -4
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/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 +13 -1
- package/dist/shared/process/host-process-supervisor.js +66 -14
- 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/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 +31 -5
- package/dist/worktree/worktree.service.js +120 -163
- package/dist/worktree/worktree.types.d.ts +31 -0
- package/package.json +2 -2
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type CompletionPhase, type DebugCompletionPhase, type QaCompletionGate } from "./phase-completion.js";
|
|
2
|
+
export { validateQaGatePassingCommands } from "./phase-completion.command-validation.js";
|
|
3
|
+
export declare const qaEvidenceGates: ReadonlySet<QaCompletionGate>;
|
|
2
4
|
export declare function normalizeCompletionStatus(value: string, phase?: CompletionPhase): string;
|
|
3
5
|
export declare function normalizeQaGateStatus(value: string): string;
|
|
4
6
|
export declare function validatePayloadShape(phase: CompletionPhase, payload: Record<string, unknown>): void;
|
|
@@ -6,9 +8,6 @@ export declare function validateCommentRepairPayloadShape(payload: Record<string
|
|
|
6
8
|
export declare function validateCiRepairPayloadShape(payload: Record<string, unknown>): void;
|
|
7
9
|
export declare function validateDebugPayloadShape(phase: DebugCompletionPhase, payload: Record<string, unknown>): void;
|
|
8
10
|
export declare function validateQaGatePayloadShape(gate: QaCompletionGate, payload: Record<string, unknown>, status: string): void;
|
|
9
|
-
export declare function validateQaGatePassingCommands(commands: readonly unknown[], options?: {
|
|
10
|
-
readonly allowClassifiedNonBlockingFailures?: boolean;
|
|
11
|
-
}): void;
|
|
12
11
|
export declare function validateArchitectPayloadShape(payload: Record<string, unknown>, status: string): void;
|
|
13
12
|
export declare function validateArchitectTaskDevelopScope(task: Record<string, unknown>, taskId: string): void;
|
|
14
13
|
export declare function validateArchitectVerificationScope(task: Record<string, unknown>, taskId: string): void;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { qaBlockerReasons, qaCandidateBugActions, qaFindingScopes, qaFindingSeverities, qaGateToolNames, qaScopeAuthorities, qaScopeCapabilities, qaScopeConfidence, qaScopeEvidence, qaScopeFields, qaScopeSources, qaScopeSurfaces } from "./phase-completion.js";
|
|
2
|
+
import { structuredTypeHint } from "./mcp-argument-coercion.js";
|
|
3
|
+
import { validateArchitectWaits } from "./architect-waits.js";
|
|
4
|
+
import { validateQaGatePassingCommands } from "./phase-completion.command-validation.js";
|
|
5
|
+
export { validateQaGatePassingCommands } from "./phase-completion.command-validation.js";
|
|
6
|
+
export const qaEvidenceGates = new Set(["qa_regression", "qa_api", "qa_manual_web", "qa_bug_repro"]);
|
|
2
7
|
export function normalizeCompletionStatus(value, phase) {
|
|
3
8
|
const normalized = value.trim().toLowerCase().replace(/-/g, "_");
|
|
4
9
|
if (phase === "qa") {
|
|
@@ -157,11 +162,11 @@ export function validateCommentRepairPayloadShape(payload) {
|
|
|
157
162
|
requireNonEmptyStringRecord(record, "summary", `changed_files[${index}].`);
|
|
158
163
|
}
|
|
159
164
|
if (hasFixed && arrayLength(payload, "changed_files") === 0) {
|
|
160
|
-
throw new Error("
|
|
165
|
+
throw new Error("changed_files must include at least one entry when any disposition is fixed.");
|
|
161
166
|
}
|
|
162
167
|
if (arrayLength(payload, "changed_files") > 0) {
|
|
163
168
|
requireNonEmptyArray(payload, "validation");
|
|
164
|
-
validateQaGatePassingCommands(payload.validation);
|
|
169
|
+
validateQaGatePassingCommands(payload.validation, { label: "validation", context: "status is pass" });
|
|
165
170
|
}
|
|
166
171
|
}
|
|
167
172
|
export function validateCiRepairPayloadShape(payload) {
|
|
@@ -196,7 +201,7 @@ export function validateCiRepairPayloadShape(payload) {
|
|
|
196
201
|
for (const key of ["narrow_validation", "broader_validation"]) {
|
|
197
202
|
requireArray(payload, key);
|
|
198
203
|
requireNonEmptyArray(payload, key);
|
|
199
|
-
validateQaGatePassingCommands(payload[key]);
|
|
204
|
+
validateQaGatePassingCommands(payload[key], { label: key, context: "status is pass" });
|
|
200
205
|
}
|
|
201
206
|
requireArray(payload, "workflow_validation");
|
|
202
207
|
requireNonEmptyArray(payload, "workflow_validation");
|
|
@@ -276,6 +281,34 @@ export function validateDebugPayloadShape(phase, payload) {
|
|
|
276
281
|
requireNonEmptyArray(payload, "required_regressions");
|
|
277
282
|
requirePassingCommands(payload);
|
|
278
283
|
}
|
|
284
|
+
// Shared by the QA evidence gates and the final verdict: gate evidence is inherited into the
|
|
285
|
+
// verdict, so a gate must reject what the verdict would reject.
|
|
286
|
+
function validateQaBrowserCheckEntries(browserChecks, status) {
|
|
287
|
+
for (const [index, browserCheck] of browserChecks.entries()) {
|
|
288
|
+
requireEvidenceRecord(browserCheck, `browser_checks[${index}]`);
|
|
289
|
+
const record = browserCheck;
|
|
290
|
+
requireNonEmptyStringRecord(record, "summary", `browser_checks[${index}].`);
|
|
291
|
+
requireNonEmptyStringRecord(record, "status", `browser_checks[${index}].`);
|
|
292
|
+
const checkStatus = optionalString(record, "status");
|
|
293
|
+
if (status === "pass" && checkStatus && normalizedString(checkStatus) !== "pass") {
|
|
294
|
+
throw new Error(`browser_checks[${index}].status must be pass when QA status is pass.`);
|
|
295
|
+
}
|
|
296
|
+
if (!optionalString(record, "url") && !optionalString(record, "route")) {
|
|
297
|
+
throw new Error(`browser_checks[${index}].url is required unless browser_checks[${index}].route is given.`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function validateQaSidecarEntries(sidecars) {
|
|
302
|
+
for (const [index, sidecar] of sidecars.entries()) {
|
|
303
|
+
requireEvidenceRecord(sidecar, `sidecars[${index}]`);
|
|
304
|
+
const record = sidecar;
|
|
305
|
+
requireNonEmptyStringRecord(record, "path", `sidecars[${index}].`);
|
|
306
|
+
requireNonEmptyStringRecord(record, "content_hash", `sidecars[${index}].`);
|
|
307
|
+
if (typeof record.bytes !== "number" || !Number.isFinite(record.bytes) || record.bytes <= 0) {
|
|
308
|
+
throw new Error(`sidecars[${index}].bytes must be greater than 0.`);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
279
312
|
export function validateQaGatePayloadShape(gate, payload, status) {
|
|
280
313
|
requireField(payload, "summary");
|
|
281
314
|
if (status === "skipped") {
|
|
@@ -293,6 +326,12 @@ export function validateQaGatePayloadShape(gate, payload, status) {
|
|
|
293
326
|
throw new Error("complete_qa_plan pass requires checklist with at least one entry.");
|
|
294
327
|
}
|
|
295
328
|
}
|
|
329
|
+
if (qaEvidenceGates.has(gate)) {
|
|
330
|
+
// Every evidence gate's sidecars are merged into the final verdict, so a
|
|
331
|
+
// malformed value must be rejected here, not when the verdict is assembled.
|
|
332
|
+
validateQaSidecarEntries(qaArray(payload, "sidecars", qaEvidenceSource(payload)));
|
|
333
|
+
validateQaBrowserCheckEntries(qaArray(payload, "browser_checks"), status);
|
|
334
|
+
}
|
|
296
335
|
if (gate === "qa_findings" && status !== "blocked") {
|
|
297
336
|
qaObjectArray(payload, "findings");
|
|
298
337
|
qaObjectArray(payload, "candidate_bugs");
|
|
@@ -314,71 +353,8 @@ export function validateQaGatePayloadShape(gate, payload, status) {
|
|
|
314
353
|
}
|
|
315
354
|
}
|
|
316
355
|
}
|
|
317
|
-
export function validateQaGatePassingCommands(commands, options = {}) {
|
|
318
|
-
const issues = [];
|
|
319
|
-
for (const [index, command] of commands.entries()) {
|
|
320
|
-
if (!command || typeof command !== "object" || Array.isArray(command)) {
|
|
321
|
-
issues.push(`commands[${index}] must be an object.`);
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
const record = command;
|
|
325
|
-
if (!optionalString(record, "command"))
|
|
326
|
-
issues.push(`commands[${index}].command is required.`);
|
|
327
|
-
if (!optionalString(record, "status"))
|
|
328
|
-
issues.push(`commands[${index}].status is required.`);
|
|
329
|
-
if (!optionalString(record, "summary"))
|
|
330
|
-
issues.push(`commands[${index}].summary is required.`);
|
|
331
|
-
if (typeof record.exit_code !== "number" || !Number.isFinite(record.exit_code)) {
|
|
332
|
-
issues.push(`commands[${index}].exit_code is required.`);
|
|
333
|
-
continue;
|
|
334
|
-
}
|
|
335
|
-
const passed = record.exit_code === 0 && normalizedString(record.status) === "pass";
|
|
336
|
-
if (!passed
|
|
337
|
-
&& options.allowClassifiedNonBlockingFailures
|
|
338
|
-
&& optionalString(record, "classification")) {
|
|
339
|
-
try {
|
|
340
|
-
validateClassifiedNonBlockingQaFailure(record, index);
|
|
341
|
-
}
|
|
342
|
-
catch (error) {
|
|
343
|
-
issues.push(error instanceof Error ? error.message : String(error));
|
|
344
|
-
}
|
|
345
|
-
continue;
|
|
346
|
-
}
|
|
347
|
-
if (record.exit_code !== 0) {
|
|
348
|
-
issues.push(`commands[${index}].exit_code must be 0 when QA gate status is pass.`);
|
|
349
|
-
}
|
|
350
|
-
if (normalizedString(record.status) !== "pass") {
|
|
351
|
-
issues.push(`commands[${index}].status must be pass when QA gate status is pass.`);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
throwCompletionPayloadIssues(issues);
|
|
355
|
-
}
|
|
356
|
-
function validateClassifiedNonBlockingQaFailure(record, index) {
|
|
357
|
-
const classification = normalizedString(optionalString(record, "classification"));
|
|
358
|
-
if (classification !== "out_of_scope_failure" && classification !== "baseline_failure") {
|
|
359
|
-
throw new Error(`commands[${index}] is non-passing; QA regression pass requires classification out_of_scope_failure or baseline_failure with corroborating evidence.`);
|
|
360
|
-
}
|
|
361
|
-
requireNonEmptyStringRecord(record, "candidate_bug_id", `commands[${index}].`);
|
|
362
|
-
requireNonEmptyStringRecord(record, "scope_evidence", `commands[${index}].`);
|
|
363
|
-
if (record.acceptance_criteria_independent !== true) {
|
|
364
|
-
throw new Error(`commands[${index}].acceptance_criteria_independent must be true for a non-blocking QA regression failure.`);
|
|
365
|
-
}
|
|
366
|
-
if (classification === "out_of_scope_failure") {
|
|
367
|
-
requireNonEmptyStringRecord(record, "repro_command", `commands[${index}].`);
|
|
368
|
-
if (typeof record.repro_exit_code !== "number" || !Number.isFinite(record.repro_exit_code) || record.repro_exit_code === 0) {
|
|
369
|
-
throw new Error(`commands[${index}].repro_exit_code must be a non-zero number for an out-of-scope failure.`);
|
|
370
|
-
}
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
requireNonEmptyStringRecord(record, "baseline_ref", `commands[${index}].`);
|
|
374
|
-
if (typeof record.baseline_exit_code !== "number" || !Number.isFinite(record.baseline_exit_code) || record.baseline_exit_code === 0) {
|
|
375
|
-
throw new Error(`commands[${index}].baseline_exit_code must be a non-zero number for a baseline failure.`);
|
|
376
|
-
}
|
|
377
|
-
if (record.failure_signature_match !== true) {
|
|
378
|
-
throw new Error(`commands[${index}].failure_signature_match must be true for a baseline failure.`);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
356
|
export function validateArchitectPayloadShape(payload, status) {
|
|
357
|
+
validateArchitectWaits(payload, status);
|
|
382
358
|
if (status !== "pass") {
|
|
383
359
|
requireArchitectNonPassEvidence(payload);
|
|
384
360
|
return;
|
|
@@ -732,7 +708,7 @@ export function hasArchitectDependencyCycle(edges) {
|
|
|
732
708
|
return false;
|
|
733
709
|
}
|
|
734
710
|
export function requireArchitectNonPassEvidence(payload) {
|
|
735
|
-
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"];
|
|
736
712
|
const hasEvidence = evidenceKeys.some((key) => {
|
|
737
713
|
const value = payload[key];
|
|
738
714
|
if (typeof value === "string") {
|
|
@@ -794,13 +770,13 @@ export function validateQaPayloadShape(payload, status) {
|
|
|
794
770
|
throw new Error("QA pass/needs_rework requires tested_acceptance_criteria with at least one criterion.");
|
|
795
771
|
}
|
|
796
772
|
if (commands.length === 0 && browserChecks.length === 0 && notes.length === 0) {
|
|
797
|
-
throw new Error("QA pass/needs_rework requires at least one
|
|
773
|
+
throw new Error("QA pass/needs_rework requires at least one entry in commands or browser_checks, or a non-empty notes string.");
|
|
798
774
|
}
|
|
799
775
|
}
|
|
800
776
|
const commandIssues = [];
|
|
801
777
|
for (const [index, command] of commands.entries()) {
|
|
802
778
|
if (!command || typeof command !== "object" || Array.isArray(command)) {
|
|
803
|
-
commandIssues.push(`commands[${index}] must be an object.`);
|
|
779
|
+
commandIssues.push(`commands[${index}] must be an object${structuredTypeHint(command, "object")}.`);
|
|
804
780
|
continue;
|
|
805
781
|
}
|
|
806
782
|
const record = command;
|
|
@@ -821,28 +797,8 @@ export function validateQaPayloadShape(payload, status) {
|
|
|
821
797
|
}
|
|
822
798
|
}
|
|
823
799
|
throwCompletionPayloadIssues(commandIssues);
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
const record = browserCheck;
|
|
827
|
-
requireNonEmptyStringRecord(record, "summary", `browser_checks[${index}].`);
|
|
828
|
-
requireNonEmptyStringRecord(record, "status", `browser_checks[${index}].`);
|
|
829
|
-
const checkStatus = optionalString(record, "status");
|
|
830
|
-
if (status === "pass" && checkStatus && normalizedString(checkStatus) !== "pass") {
|
|
831
|
-
throw new Error(`browser_checks[${index}].status must be pass when QA status is pass.`);
|
|
832
|
-
}
|
|
833
|
-
if (!optionalString(record, "url") && !optionalString(record, "route")) {
|
|
834
|
-
throw new Error(`browser_checks[${index}] must include url or route.`);
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
for (const [index, sidecar] of sidecars.entries()) {
|
|
838
|
-
requireEvidenceRecord(sidecar, `sidecars[${index}]`);
|
|
839
|
-
const record = sidecar;
|
|
840
|
-
requireNonEmptyStringRecord(record, "path", `sidecars[${index}].`);
|
|
841
|
-
requireNonEmptyStringRecord(record, "content_hash", `sidecars[${index}].`);
|
|
842
|
-
if (typeof record.bytes !== "number" || !Number.isFinite(record.bytes) || record.bytes <= 0) {
|
|
843
|
-
throw new Error(`sidecars[${index}].bytes must be greater than 0.`);
|
|
844
|
-
}
|
|
845
|
-
}
|
|
800
|
+
validateQaBrowserCheckEntries(browserChecks, status);
|
|
801
|
+
validateQaSidecarEntries(sidecars);
|
|
846
802
|
for (const [index, finding] of findings.entries()) {
|
|
847
803
|
requireNonEmptyStringRecord(finding, "id", `findings[${index}].`);
|
|
848
804
|
requireNonEmptyStringRecord(finding, "title", `findings[${index}].`);
|
|
@@ -884,7 +840,7 @@ export function validateQaPayloadShape(payload, status) {
|
|
|
884
840
|
}
|
|
885
841
|
if (status === "needs_rework") {
|
|
886
842
|
if (inScopeFindingIds.length === 0) {
|
|
887
|
-
throw new Error("QA needs_rework requires at least one actionable in-scope finding.");
|
|
843
|
+
throw new Error("QA needs_rework requires at least one actionable in-scope finding: add an entry to findings with scope: in_scope.");
|
|
888
844
|
}
|
|
889
845
|
if (optionalString(payload, "blocker_reason")) {
|
|
890
846
|
throw new Error("QA needs_rework must not include blocker_reason.");
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ValidationStep } from "./pre-publication-step-execution.js";
|
|
2
|
+
import { ForgeFailureError, type RunnerDispatchEvent } from "./session.types.js";
|
|
3
|
+
/** The check id a failed restart of the attempt's runtime stack before the pass is reported under. */
|
|
4
|
+
export declare const runtimeRestartCheckId = "host-runtime-restart";
|
|
5
|
+
/** One check that failed in a pass: the step that failed and its clipped diagnostics. */
|
|
6
|
+
export interface PrePublicationCheckFailure {
|
|
7
|
+
readonly checkId: string;
|
|
8
|
+
readonly exitCode: number;
|
|
9
|
+
readonly command: string;
|
|
10
|
+
readonly args: readonly string[];
|
|
11
|
+
readonly detail: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A failed validation pass. The single-check fields name the first failure, as they always have;
|
|
15
|
+
* `failures` lists every check that failed in the pass, in the order the checks ran.
|
|
16
|
+
*/
|
|
17
|
+
export declare class PrePublicationValidationError extends ForgeFailureError {
|
|
18
|
+
readonly checkId: string;
|
|
19
|
+
readonly exitCode: number;
|
|
20
|
+
readonly command: string;
|
|
21
|
+
readonly args: readonly string[];
|
|
22
|
+
readonly detail: string;
|
|
23
|
+
readonly code = "prepublication_validation_failed";
|
|
24
|
+
readonly failures: readonly PrePublicationCheckFailure[];
|
|
25
|
+
constructor(checkId: string, exitCode: number, command: string, args: readonly string[], detail: string, additionalFailures?: readonly PrePublicationCheckFailure[]);
|
|
26
|
+
/** Every failed check's id, first failure first. */
|
|
27
|
+
get checkIds(): readonly string[];
|
|
28
|
+
}
|
|
29
|
+
export declare class PrePublicationPass {
|
|
30
|
+
private readonly runtimeRestartFailure?;
|
|
31
|
+
private readonly failures;
|
|
32
|
+
/** The check whose .NET build failed to compile in this pass, if any. */
|
|
33
|
+
private dotnetCompileFailedIn;
|
|
34
|
+
/** A failed runtime restart before the pass is its first failure. */
|
|
35
|
+
constructor(runtimeRestartFailure?: PrePublicationValidationError | undefined);
|
|
36
|
+
record(failure: PrePublicationCheckFailure, failedStep?: ValidationStep): void;
|
|
37
|
+
/** The failed checks that keep this check from running meaningfully in this pass. */
|
|
38
|
+
blockers(checkId: string): readonly string[];
|
|
39
|
+
/**
|
|
40
|
+
* Whether an error ends the pass with the failures it already found. Only a classified retryable
|
|
41
|
+
* failure (a resource hold, lost infrastructure, a supervisor that did not start) does, once the
|
|
42
|
+
* pass has found a failure: the repair turn can fix those failures now, and the next pass meets
|
|
43
|
+
* the condition again. Any other error, or cancellation, still ends the attempt as it did.
|
|
44
|
+
*/
|
|
45
|
+
stopsAt(error: unknown, signal?: AbortSignal): error is ForgeFailureError;
|
|
46
|
+
stoppedEvent(checkId: string, error: ForgeFailureError): RunnerDispatchEvent;
|
|
47
|
+
/** Throws every failure the pass found as one validation failure. */
|
|
48
|
+
throwIfFailed(): void;
|
|
49
|
+
}
|
|
50
|
+
export declare function skippedCheckEvent(checkId: string, blockedBy: readonly string[]): RunnerDispatchEvent;
|
|
51
|
+
/** The tests a check's steps skipped, so a check that passed with skips says so with each reason. */
|
|
52
|
+
export declare class SkippedTestTally {
|
|
53
|
+
private readonly worktreePath;
|
|
54
|
+
private readonly environment?;
|
|
55
|
+
private summary;
|
|
56
|
+
constructor(worktreePath: string, environment?: Readonly<Record<string, string>> | undefined);
|
|
57
|
+
/** The invocation's own arguments: a managed attempt may direct results to its test-output root. */
|
|
58
|
+
add(args: readonly string[], stepStartedMs: number): Promise<void>;
|
|
59
|
+
passedEvent(checkId: string, secrets: readonly string[]): RunnerDispatchEvent;
|
|
60
|
+
}
|
|
61
|
+
export declare function validationEvent(eventType: string, checkId: string, content: string, detail?: Readonly<Record<string, unknown>>): RunnerDispatchEvent;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { redactText } from "../shared/redaction/redaction.js";
|
|
2
|
+
import { describeSkippedTests, mergeSkippedTests, readSkippedTests, } from "./pre-publication-skipped-tests.js";
|
|
3
|
+
import { ForgeFailureError, failureFactsFromError } from "./session.types.js";
|
|
4
|
+
// One pre-publication validation pass. A failed check no longer ends the pass: the remaining checks
|
|
5
|
+
// that can still meaningfully run keep going, so one in-place repair turn sees every independent
|
|
6
|
+
// failure at once instead of one per turn. The pass records each failure, says which checks it
|
|
7
|
+
// could not run because a check they depend on failed, and reports them all as one failure.
|
|
8
|
+
/** The check id a failed restart of the attempt's runtime stack before the pass is reported under. */
|
|
9
|
+
export const runtimeRestartCheckId = "host-runtime-restart";
|
|
10
|
+
// 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"]);
|
|
13
|
+
// Checks that build the .NET solution themselves and would only repeat the compiler errors once its
|
|
14
|
+
// compile step fails: the OpenAPI export builds Forge.Api and the E2E suite publishes it.
|
|
15
|
+
const dotnetBuildConsumers = new Set(["openapi-and-generated-types", "playwright-e2e"]);
|
|
16
|
+
// Checks that run against the attempt's application stack, which a failed restart left stopped.
|
|
17
|
+
const runtimeStackConsumers = new Set(["playwright-e2e"]);
|
|
18
|
+
// The diagnostics of each further failure that the error message carries; the repair prompt
|
|
19
|
+
// carries every failure's diagnostics in full.
|
|
20
|
+
const additionalFailureMessageDetail = 1500;
|
|
21
|
+
/**
|
|
22
|
+
* A failed validation pass. The single-check fields name the first failure, as they always have;
|
|
23
|
+
* `failures` lists every check that failed in the pass, in the order the checks ran.
|
|
24
|
+
*/
|
|
25
|
+
export class PrePublicationValidationError extends ForgeFailureError {
|
|
26
|
+
checkId;
|
|
27
|
+
exitCode;
|
|
28
|
+
command;
|
|
29
|
+
args;
|
|
30
|
+
detail;
|
|
31
|
+
code = "prepublication_validation_failed";
|
|
32
|
+
failures;
|
|
33
|
+
constructor(checkId, exitCode, command, args, detail, additionalFailures = []) {
|
|
34
|
+
super("prepublication_validation_failed", validationFailureMessage([{ checkId, exitCode, command, args, detail }, ...additionalFailures]), "bridge");
|
|
35
|
+
this.checkId = checkId;
|
|
36
|
+
this.exitCode = exitCode;
|
|
37
|
+
this.command = command;
|
|
38
|
+
this.args = args;
|
|
39
|
+
this.detail = detail;
|
|
40
|
+
this.name = "PrePublicationValidationError";
|
|
41
|
+
this.failures = [{ checkId, exitCode, command, args, detail }, ...additionalFailures];
|
|
42
|
+
}
|
|
43
|
+
/** Every failed check's id, first failure first. */
|
|
44
|
+
get checkIds() {
|
|
45
|
+
return this.failures.map(failure => failure.checkId);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function validationFailureMessage(failures) {
|
|
49
|
+
const [first, ...others] = failures;
|
|
50
|
+
const summary = (failure, detail) => `${failure.checkId} exited ${failure.exitCode}${detail ? `: ${detail}` : ""}`;
|
|
51
|
+
if (others.length === 0)
|
|
52
|
+
return `prepublication_validation_failed: ${summary(first, first.detail)}`;
|
|
53
|
+
// The other check ids come before the first detail, so a clipped failure message still names them.
|
|
54
|
+
const also = `[also failed: ${others.map(failure => failure.checkId).join(", ")}]`;
|
|
55
|
+
const more = others.map(failure => summary(failure, clipDetail(failure.detail)));
|
|
56
|
+
return `prepublication_validation_failed: ${first.checkId} exited ${first.exitCode} ${also}${first.detail ? `: ${first.detail}` : ""}`
|
|
57
|
+
+ `\n\nAlso failed in the same validation pass: ${more.join("\n\n")}`;
|
|
58
|
+
}
|
|
59
|
+
function clipDetail(detail) {
|
|
60
|
+
return detail.length <= additionalFailureMessageDetail
|
|
61
|
+
? detail
|
|
62
|
+
: `${detail.slice(0, additionalFailureMessageDetail)}… (clipped)`;
|
|
63
|
+
}
|
|
64
|
+
export class PrePublicationPass {
|
|
65
|
+
runtimeRestartFailure;
|
|
66
|
+
failures = [];
|
|
67
|
+
/** The check whose .NET build failed to compile in this pass, if any. */
|
|
68
|
+
dotnetCompileFailedIn = null;
|
|
69
|
+
/** A failed runtime restart before the pass is its first failure. */
|
|
70
|
+
constructor(runtimeRestartFailure) {
|
|
71
|
+
this.runtimeRestartFailure = runtimeRestartFailure;
|
|
72
|
+
this.failures.push(...runtimeRestartFailure?.failures ?? []);
|
|
73
|
+
}
|
|
74
|
+
record(failure, failedStep) {
|
|
75
|
+
this.failures.push(failure);
|
|
76
|
+
if (dotnetBuildCheckIds.has(failure.checkId) && failedStep?.command === "dotnet" && failedStep.args[0] === "build") {
|
|
77
|
+
this.dotnetCompileFailedIn ??= failure.checkId;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** The failed checks that keep this check from running meaningfully in this pass. */
|
|
81
|
+
blockers(checkId) {
|
|
82
|
+
return [
|
|
83
|
+
...(this.dotnetCompileFailedIn && dotnetBuildConsumers.has(checkId) ? [this.dotnetCompileFailedIn] : []),
|
|
84
|
+
...(this.runtimeRestartFailure && runtimeStackConsumers.has(checkId) ? [runtimeRestartCheckId] : []),
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Whether an error ends the pass with the failures it already found. Only a classified retryable
|
|
89
|
+
* failure (a resource hold, lost infrastructure, a supervisor that did not start) does, once the
|
|
90
|
+
* pass has found a failure: the repair turn can fix those failures now, and the next pass meets
|
|
91
|
+
* the condition again. Any other error, or cancellation, still ends the attempt as it did.
|
|
92
|
+
*/
|
|
93
|
+
stopsAt(error, signal) {
|
|
94
|
+
if (this.failures.length === 0 || signal?.aborted || !(error instanceof ForgeFailureError))
|
|
95
|
+
return false;
|
|
96
|
+
return failureFactsFromError(error).retryability === "retryable";
|
|
97
|
+
}
|
|
98
|
+
stoppedEvent(checkId, error) {
|
|
99
|
+
const failedCheckIds = this.failures.map(failure => failure.checkId);
|
|
100
|
+
return validationEvent("prepublication_validation_pass_stopped", checkId, `Stopped this pre-publication pass at '${checkId}' (${error.failureCode}). Reporting the ${failedCheckIds.length} failed check${failedCheckIds.length === 1 ? "" : "s"} it already found (${failedCheckIds.join(", ")}) for repair; the next pass runs '${checkId}' again.`, { failureCode: error.failureCode, failedCheckIds });
|
|
101
|
+
}
|
|
102
|
+
/** Throws every failure the pass found as one validation failure. */
|
|
103
|
+
throwIfFailed() {
|
|
104
|
+
const [first, ...others] = this.failures;
|
|
105
|
+
if (!first)
|
|
106
|
+
return;
|
|
107
|
+
throw new PrePublicationValidationError(first.checkId, first.exitCode, first.command, first.args, first.detail, others);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export function skippedCheckEvent(checkId, blockedBy) {
|
|
111
|
+
const reason = blockedBy.map(blocker => blocker === runtimeRestartCheckId
|
|
112
|
+
? "the attempt's runtime stack, whose restart failed"
|
|
113
|
+
: `the .NET build, which failed in '${blocker}'`).join(" and ");
|
|
114
|
+
return validationEvent("prepublication_validation_skipped", checkId, `Skipped pre-publication CI parity check '${checkId}' in this pass: it needs ${reason}. The next pass runs it again.`, { blockedBy });
|
|
115
|
+
}
|
|
116
|
+
/** The tests a check's steps skipped, so a check that passed with skips says so with each reason. */
|
|
117
|
+
export class SkippedTestTally {
|
|
118
|
+
worktreePath;
|
|
119
|
+
environment;
|
|
120
|
+
summary = { count: 0, reasons: [] };
|
|
121
|
+
constructor(worktreePath, environment) {
|
|
122
|
+
this.worktreePath = worktreePath;
|
|
123
|
+
this.environment = environment;
|
|
124
|
+
}
|
|
125
|
+
/** The invocation's own arguments: a managed attempt may direct results to its test-output root. */
|
|
126
|
+
async add(args, stepStartedMs) {
|
|
127
|
+
this.summary = mergeSkippedTests(this.summary, await readSkippedTests(this.worktreePath, args, stepStartedMs, this.environment));
|
|
128
|
+
}
|
|
129
|
+
passedEvent(checkId, secrets) {
|
|
130
|
+
const skipped = {
|
|
131
|
+
...this.summary,
|
|
132
|
+
reasons: this.summary.reasons.map(entry => ({ ...entry, reason: redactText(entry.reason, secrets) })),
|
|
133
|
+
};
|
|
134
|
+
if (skipped.count === 0) {
|
|
135
|
+
return validationEvent("prepublication_validation_passed", checkId, `Pre-publication CI parity check '${checkId}' passed.`);
|
|
136
|
+
}
|
|
137
|
+
return validationEvent("prepublication_validation_passed", checkId, `Pre-publication CI parity check '${checkId}' passed with ${describeSkippedTests(skipped)}.`, { skippedTests: skipped.count, skippedReasons: skipped.reasons });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export function validationEvent(eventType, checkId, content, detail) {
|
|
141
|
+
return {
|
|
142
|
+
role: "runner",
|
|
143
|
+
kind: "checkpoint",
|
|
144
|
+
content,
|
|
145
|
+
eventType,
|
|
146
|
+
data: JSON.stringify({ checkId, contractId: "forge-ci-parity-v1", ...detail }),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
@@ -4,23 +4,26 @@ import { hostRuntimeLegacyTestPostgresEnvironment, hostRuntimeTestPostgresAdminE
|
|
|
4
4
|
import { withoutHostLoadGovernorVariables } from "../runtime/host-load-child-environment.js";
|
|
5
5
|
import { isSubPath } from "../shared/path/path.js";
|
|
6
6
|
import { NodeProcessRunner, ProcessTreeTerminationError } from "../shared/process/process.js";
|
|
7
|
+
import { buildWindowsCmdLaunch } from "../shared/process/windows-launch.js";
|
|
7
8
|
/** Output kept per stream for one validation step (the tail). */
|
|
8
9
|
export const prePublicationOutputLimitChars = 4 * 1024 * 1024;
|
|
9
10
|
export class ProcessPrePublicationCommandRunner {
|
|
10
11
|
async run(command, args, cwd, signal, environment) {
|
|
11
12
|
try {
|
|
12
13
|
const launch = await pnpmDirectoryLaunch(command, args, cwd);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
// npm and pnpm are batch files on Windows, run through cmd.exe. Its command line is
|
|
15
|
+
// passed verbatim: Node's own quoting escapes inner quotes as \", which cmd.exe does
|
|
16
|
+
// not read, so a quoted argument reached the package manager with its quotes.
|
|
17
|
+
const windowsBatch = process.platform === "win32" && (command === "npm" || command === "pnpm")
|
|
18
|
+
? buildWindowsCmdLaunch(`${command}.cmd`, launch.args)
|
|
19
|
+
: null;
|
|
18
20
|
// A process group the runner stops as a whole, settling only once it is gone:
|
|
19
21
|
// a validation step's host capacity is never returned while its test hosts,
|
|
20
22
|
// build nodes or browser workers still run.
|
|
21
23
|
const result = await new NodeProcessRunner().run({
|
|
22
|
-
command:
|
|
23
|
-
args:
|
|
24
|
+
command: windowsBatch?.command ?? command,
|
|
25
|
+
args: windowsBatch?.args ?? [...launch.args],
|
|
26
|
+
windowsVerbatimArguments: windowsBatch !== null,
|
|
24
27
|
cwd: launch.cwd,
|
|
25
28
|
env: prePublicationChildEnvironment(environment),
|
|
26
29
|
rawOutput: true,
|
|
@@ -48,9 +51,6 @@ export class ProcessPrePublicationCommandRunner {
|
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
|
-
function quoteWindowsCommandArgument(value) {
|
|
52
|
-
return /^[A-Za-z0-9_./:@=-]+$/u.test(value) ? value : `"${value.replaceAll('"', '""')}"`;
|
|
53
|
-
}
|
|
54
54
|
export function prePublicationChildEnvironment(environment) {
|
|
55
55
|
const child = {};
|
|
56
56
|
const privilegedNames = new Set([
|
|
@@ -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;
|