@loucompanion/forge-bridge 0.1.3-dev.d1ca67076aa9 → 0.1.3-dev.eeefdb0d19c1
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 +78 -0
- package/dist/bridge/bridge.base.d.ts +6 -1
- package/dist/bridge/bridge.service.d.ts +60 -3
- package/dist/bridge/bridge.service.js +962 -22
- package/dist/bridge/bridge.types.d.ts +172 -1
- package/dist/cleanup/cleanup.service.d.ts +13 -2
- package/dist/cleanup/cleanup.service.js +435 -3
- package/dist/cleanup/cleanup.types.d.ts +10 -0
- package/dist/cleanup/index.d.ts +1 -1
- package/dist/cleanup/index.js +1 -1
- package/dist/cleanup/internals.d.ts +2 -2
- package/dist/cleanup/internals.js +1 -1
- package/dist/cli/cli.help.js +47 -1
- package/dist/cli/cli.service.d.ts +42 -2
- package/dist/cli/cli.service.js +351 -22
- package/dist/cli/local-config.d.ts +6 -0
- package/dist/cli/local-config.js +47 -3
- package/dist/runtime/attempt-node-runtime-launcher.d.ts +17 -0
- package/dist/runtime/attempt-node-runtime-launcher.js +101 -0
- package/dist/runtime/attempt-process-supervisor-registry.d.ts +20 -0
- package/dist/runtime/attempt-process-supervisor-registry.js +64 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +86 -0
- package/dist/runtime/attempt-process-supervisor.js +343 -0
- package/dist/runtime/generated-output-reset.d.ts +10 -0
- package/dist/runtime/generated-output-reset.js +103 -0
- package/dist/runtime/host-listener-inspector.d.ts +44 -0
- package/dist/runtime/host-listener-inspector.js +324 -0
- package/dist/runtime/host-port-broker.d.ts +76 -0
- package/dist/runtime/host-port-broker.js +333 -0
- package/dist/runtime/host-runtime-contract.d.ts +47 -0
- package/dist/runtime/host-runtime-contract.js +700 -0
- package/dist/runtime/host-runtime-lease.d.ts +133 -0
- package/dist/runtime/host-runtime-lease.js +1460 -0
- package/dist/runtime/host-runtime-promotion.d.ts +23 -0
- package/dist/runtime/host-runtime-promotion.js +159 -0
- package/dist/runtime/node-host-runtime-adapter.d.ts +51 -0
- package/dist/runtime/node-host-runtime-adapter.js +268 -0
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +20 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +220 -0
- package/dist/runtime/runtime-isolation-lease.d.ts +67 -0
- package/dist/runtime/runtime-isolation-lease.js +158 -0
- package/dist/sandbox/command-runner.d.ts +4 -0
- package/dist/sandbox/command-runner.js +47 -0
- package/dist/sandbox/contract.d.ts +5 -0
- package/dist/sandbox/contract.js +276 -0
- package/dist/sandbox/event-budget.d.ts +11 -0
- package/dist/sandbox/event-budget.js +27 -0
- package/dist/sandbox/image-policy.d.ts +35 -0
- package/dist/sandbox/image-policy.js +247 -0
- package/dist/sandbox/index.d.ts +5 -0
- package/dist/sandbox/index.js +5 -0
- package/dist/sandbox/lease-watchdog.d.ts +18 -0
- package/dist/sandbox/lease-watchdog.js +67 -0
- package/dist/sandbox/preflight.d.ts +54 -0
- package/dist/sandbox/preflight.js +335 -0
- package/dist/sandbox/process.d.ts +20 -0
- package/dist/sandbox/process.js +209 -0
- package/dist/sandbox/provider-auth/codex.d.ts +26 -0
- package/dist/sandbox/provider-auth/codex.js +212 -0
- package/dist/sandbox/repository-lock.d.ts +5 -0
- package/dist/sandbox/repository-lock.js +119 -0
- package/dist/sandbox/runtime.d.ts +297 -0
- package/dist/sandbox/runtime.js +2338 -0
- package/dist/sandbox/sandbox.types.d.ts +86 -0
- package/dist/sandbox/sandbox.types.js +1 -0
- package/dist/sandbox/smoke.d.ts +76 -0
- package/dist/sandbox/smoke.js +380 -0
- package/dist/sandbox/worker-supervisor.d.ts +13 -0
- package/dist/sandbox/worker-supervisor.js +36 -0
- package/dist/sandbox/worker.d.ts +1 -0
- package/dist/sandbox/worker.js +225 -0
- package/dist/sandbox/workspace.service.d.ts +13 -0
- package/dist/sandbox/workspace.service.js +72 -0
- package/dist/session/managed-attempt-tools.d.ts +12 -0
- package/dist/session/managed-attempt-tools.js +350 -0
- package/dist/session/phase-completion.artifacts.js +32 -4
- package/dist/session/phase-completion.d.ts +4 -2
- package/dist/session/phase-completion.helpers.js +27 -3
- package/dist/session/phase-completion.js +12 -3
- package/dist/session/phase-completion.prompts.d.ts +3 -3
- package/dist/session/phase-completion.prompts.js +19 -5
- package/dist/session/phase-completion.runtime.d.ts +12 -1
- package/dist/session/phase-completion.runtime.js +127 -7
- package/dist/session/phase-completion.schemas.js +108 -3
- package/dist/session/phase-completion.validation.d.ts +4 -1
- package/dist/session/phase-completion.validation.js +106 -2
- package/dist/session/provider-cli/ci-repair-readiness.d.ts +8 -0
- package/dist/session/provider-cli/ci-repair-readiness.js +90 -0
- package/dist/session/provider-cli/provider-cli.artifacts.d.ts +1 -1
- package/dist/session/provider-cli/provider-cli.artifacts.js +28 -4
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.deterministic.d.ts +2 -0
- package/dist/session/provider-cli/provider-cli.deterministic.js +66 -9
- package/dist/session/provider-cli/provider-cli.process.d.ts +17 -0
- package/dist/session/provider-cli/provider-cli.process.js +223 -14
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +16 -2
- package/dist/session/provider-cli/provider-cli.prompts.js +202 -18
- package/dist/session/provider-cli/provider-cli.qa-sidecars.js +1 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +1 -1
- package/dist/session/provider-cli/provider-cli.runtime.js +3 -2
- package/dist/session/provider-cli/provider-cli.service.d.ts +7 -3
- package/dist/session/provider-cli/provider-cli.service.js +399 -98
- package/dist/session/provider-cli/provider-cli.types.d.ts +6 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
- package/dist/session/provider-cli/provider-output-state.js +30 -2
- package/dist/session/session-redaction.d.ts +3 -0
- package/dist/session/session-redaction.js +23 -0
- package/dist/session/session.base.d.ts +6 -1
- package/dist/session/session.service.d.ts +8 -2
- package/dist/session/session.service.js +463 -58
- package/dist/session/session.types.d.ts +107 -1
- package/dist/session/session.types.js +226 -3
- package/dist/shared/path/path.js +3 -1
- package/dist/shared/process/host-process-recovery.d.ts +12 -0
- package/dist/shared/process/host-process-recovery.js +78 -0
- package/dist/shared/process/host-process-supervisor.d.ts +57 -0
- package/dist/shared/process/host-process-supervisor.js +282 -0
- package/dist/shared/process/process.d.ts +1 -0
- package/dist/shared/process/process.js +1 -0
- package/dist/shared/process/windows-launch.d.ts +1 -1
- package/dist/shared/process/windows-launch.js +6 -3
- package/dist/shared/provider-capabilities.d.ts +1 -0
- package/dist/shared/provider-capabilities.js +3 -0
- package/dist/shared/redaction/redaction.js +10 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.d.ts +3 -2
- package/dist/worktree/artifact-injector.js +43 -4
- package/dist/worktree/dependency-warmer.d.ts +21 -1
- package/dist/worktree/dependency-warmer.js +138 -5
- package/dist/worktree/index.d.ts +1 -0
- package/dist/worktree/index.js +1 -0
- package/dist/worktree/prior-phase-artifact-hydrator.d.ts +2 -0
- package/dist/worktree/prior-phase-artifact-hydrator.js +136 -0
- package/dist/worktree/worktree-paths.d.ts +4 -0
- package/dist/worktree/worktree-paths.js +30 -0
- package/dist/worktree/worktree.base.d.ts +3 -0
- package/dist/worktree/worktree.service.d.ts +7 -2
- package/dist/worktree/worktree.service.js +72 -44
- package/dist/worktree/worktree.types.d.ts +3 -1
- package/package.json +6 -3
- package/runtime/windows-job-supervisor.ps1 +356 -0
- package/runtime/windows-listener-owner.ps1 +33 -0
|
@@ -237,12 +237,19 @@ export async function writeQaGateCompletionArtifact(config, gate, input) {
|
|
|
237
237
|
const status = normalizeQaGateStatus(requiredString(payload, "status"));
|
|
238
238
|
validateQaGatePayloadShape(gate, payload, status);
|
|
239
239
|
validateOptionalWorkItemId(payload, config.workItemId);
|
|
240
|
-
const
|
|
240
|
+
const ownerFields = artifactOwnerFields(config);
|
|
241
|
+
const validatedSidecars = gate === "qa_manual_web"
|
|
242
|
+
? await validateQaSidecarReferences(config.worktreePath, config.workItemId, qaArray(payload, "sidecars", qaEvidenceSource(payload)), ownerFields.owner_type, ownerFields.owner_id)
|
|
243
|
+
: null;
|
|
244
|
+
const redactedPayload = redactSecrets({
|
|
245
|
+
...payload,
|
|
246
|
+
status,
|
|
247
|
+
...(validatedSidecars ? { sidecars: validatedSidecars } : {})
|
|
248
|
+
}, config.redactionSecrets ?? []);
|
|
241
249
|
const producedBy = optionalString(redactedPayload, "produced_by")
|
|
242
250
|
?? optionalString(redactedPayload, "producedBy")
|
|
243
251
|
?? config.producedBy
|
|
244
252
|
?? "forge-completion-tool";
|
|
245
|
-
const ownerFields = artifactOwnerFields(config);
|
|
246
253
|
const artifactRoot = ownerFields.owner_type && ownerFields.owner_id
|
|
247
254
|
? artifactRootForOwner(config.worktreePath, ownerFields.owner_type, ownerFields.owner_id)
|
|
248
255
|
: artifactRootFor(config.worktreePath, config.workItemId);
|
|
@@ -424,7 +431,7 @@ async function synthesizeQaCycleVerdictPayload(config, payload, status) {
|
|
|
424
431
|
]);
|
|
425
432
|
merged.browser_checks = dedupeUnknownArray([
|
|
426
433
|
...qaArray(payload, "browser_checks", payloadEvidence),
|
|
427
|
-
...evidenceGates.flatMap((gate) => qaArray(gate, "browser_checks"))
|
|
434
|
+
...evidenceGates.flatMap((gate) => qaArray(gate, "browser_checks").map(normalizeInheritedQaBrowserCheck))
|
|
428
435
|
]);
|
|
429
436
|
merged.sidecars = dedupeUnknownArray([
|
|
430
437
|
...qaArray(payload, "sidecars", payloadEvidence),
|
|
@@ -516,6 +523,27 @@ function dedupeStrings(values) {
|
|
|
516
523
|
}
|
|
517
524
|
return deduped;
|
|
518
525
|
}
|
|
526
|
+
function normalizeInheritedQaBrowserCheck(browserCheck) {
|
|
527
|
+
if (!browserCheck || typeof browserCheck !== "object" || Array.isArray(browserCheck)) {
|
|
528
|
+
return browserCheck;
|
|
529
|
+
}
|
|
530
|
+
const record = browserCheck;
|
|
531
|
+
if (optionalString(record, "summary")) {
|
|
532
|
+
return record;
|
|
533
|
+
}
|
|
534
|
+
const target = optionalString(record, "url") ?? optionalString(record, "route") ?? "the configured browser target";
|
|
535
|
+
const status = optionalString(record, "status") ?? "recorded";
|
|
536
|
+
return {
|
|
537
|
+
...record,
|
|
538
|
+
summary: `Inherited browser check ${status} for ${target}.`
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
function normalizeSha256ContentHash(contentHash) {
|
|
542
|
+
const normalized = contentHash.trim().toLowerCase();
|
|
543
|
+
return normalized.startsWith("sha256:")
|
|
544
|
+
? normalized.slice("sha256:".length)
|
|
545
|
+
: normalized;
|
|
546
|
+
}
|
|
519
547
|
async function validateQaSidecarReferences(worktreePath, workItemId, sidecars, ownerType, ownerId) {
|
|
520
548
|
if (sidecars.length === 0) {
|
|
521
549
|
return [];
|
|
@@ -557,7 +585,7 @@ async function validateQaSidecarReferences(worktreePath, workItemId, sidecars, o
|
|
|
557
585
|
throw new Error(`sidecars[${index}].bytes does not match the referenced file.`);
|
|
558
586
|
}
|
|
559
587
|
const actualHash = await sha256File(fullPath);
|
|
560
|
-
if (actualHash !== contentHash
|
|
588
|
+
if (actualHash !== normalizeSha256ContentHash(contentHash)) {
|
|
561
589
|
throw new Error(`sidecars[${index}].content_hash does not match the referenced file.`);
|
|
562
590
|
}
|
|
563
591
|
validated.push({
|
|
@@ -9,7 +9,8 @@ export type DebugCompletionPhase = "debug_repro" | "debug_root_cause" | "debug_f
|
|
|
9
9
|
export type ArchitectCompletionPhase = "architect";
|
|
10
10
|
export type DraftCompletionPhase = "draft";
|
|
11
11
|
export type DecomposeCompletionPhase = "decompose";
|
|
12
|
-
export type
|
|
12
|
+
export type CiRepairCompletionPhase = "ci_repair";
|
|
13
|
+
export type CompletionPhase = DevelopCompletionPhase | "qa" | DebugCompletionPhase | ArchitectCompletionPhase | DraftCompletionPhase | DecomposeCompletionPhase | CiRepairCompletionPhase;
|
|
13
14
|
export type QaCompletionGate = "qa_plan" | "qa_regression" | "qa_api" | "qa_manual_web" | "qa_bug_repro" | "qa_findings" | "qa_verdict";
|
|
14
15
|
export type DraftCompletionGate = "draft_intent" | "draft_repo_context" | "draft_graph_context" | "draft_product_scope" | "draft_work_order_plan" | "draft_critic" | "draft_proposal";
|
|
15
16
|
export type DecomposeCompletionGate = "decompose_subject_intake" | "decompose_context_review" | "decompose_breakdown_strategy" | "decompose_child_items" | "decompose_dependency_graph" | "decompose_critic" | "decompose_proposal";
|
|
@@ -25,6 +26,7 @@ export interface CompletionToolRuntimeOptions {
|
|
|
25
26
|
readonly dispatch: RunOnceDispatchPacket;
|
|
26
27
|
readonly worktree: WorktreeHandle;
|
|
27
28
|
readonly phase?: CompletionPhase;
|
|
29
|
+
readonly runtimeEnvironment?: Readonly<Record<string, string>>;
|
|
28
30
|
}
|
|
29
31
|
export interface CompletionToolServerConfig {
|
|
30
32
|
readonly worktreePath: string;
|
|
@@ -56,7 +58,7 @@ export interface CompletionToolCallResult {
|
|
|
56
58
|
readonly allowed: boolean;
|
|
57
59
|
readonly reason: string;
|
|
58
60
|
};
|
|
59
|
-
readonly nextPhase: CompletionPhase | "dev_test_ready" | "qa_ready" | "sign_off_ready";
|
|
61
|
+
readonly nextPhase: CompletionPhase | "dev_test_ready" | "qa_ready" | "sign_off_ready" | "provider_checks_ready";
|
|
60
62
|
readonly nextInstruction: string;
|
|
61
63
|
};
|
|
62
64
|
}
|
|
@@ -85,6 +85,9 @@ export function parseStrictCompletionPhase(value) {
|
|
|
85
85
|
if (normalized === "decompose" || normalized === "decomposition" || normalized === "work_order_decomposition" || normalized === "feature_decomposition") {
|
|
86
86
|
return "decompose";
|
|
87
87
|
}
|
|
88
|
+
if (normalized === "ci_repair" || normalized === "pr_checks" || normalized === "repair_pr_checks") {
|
|
89
|
+
return "ci_repair";
|
|
90
|
+
}
|
|
88
91
|
return null;
|
|
89
92
|
}
|
|
90
93
|
export function normalizeDebugCompletionPhase(value) {
|
|
@@ -156,6 +159,9 @@ export function phaseFromToolName(toolName) {
|
|
|
156
159
|
if (normalized === "forge.complete_architect_plan" || normalized === "complete_architect_plan") {
|
|
157
160
|
return "architect";
|
|
158
161
|
}
|
|
162
|
+
if (normalized === "forge.complete_ci_repair" || normalized === "complete_ci_repair") {
|
|
163
|
+
return "ci_repair";
|
|
164
|
+
}
|
|
159
165
|
if (draftGateFromToolName(toolName)) {
|
|
160
166
|
return "draft";
|
|
161
167
|
}
|
|
@@ -600,9 +606,22 @@ export async function readOptionalFile(filePath) {
|
|
|
600
606
|
}
|
|
601
607
|
export async function writeFileAtomic(filePath, content) {
|
|
602
608
|
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
603
|
-
const tempPath = path.join(path.dirname(filePath), `.${path.basename(filePath)}.${process.pid}.${
|
|
609
|
+
const tempPath = path.join(path.dirname(filePath), `.${path.basename(filePath)}.${process.pid}.${crypto.randomUUID()}.tmp`);
|
|
604
610
|
await fs.writeFile(tempPath, content, "utf8");
|
|
605
|
-
|
|
611
|
+
try {
|
|
612
|
+
await fs.rename(tempPath, filePath);
|
|
613
|
+
}
|
|
614
|
+
catch (error) {
|
|
615
|
+
if (process.platform !== "win32" || !isNodeError(error) || (error.code !== "EPERM" && error.code !== "EEXIST")) {
|
|
616
|
+
await fs.rm(tempPath, { force: true });
|
|
617
|
+
throw error;
|
|
618
|
+
}
|
|
619
|
+
// Windows rename does not reliably replace an existing destination. QA-cycle gates
|
|
620
|
+
// intentionally refresh canonical bundle files, so remove only the exact destination
|
|
621
|
+
// after the replacement temp file is durable, then complete the rename.
|
|
622
|
+
await fs.rm(filePath, { force: true });
|
|
623
|
+
await fs.rename(tempPath, filePath);
|
|
624
|
+
}
|
|
606
625
|
}
|
|
607
626
|
export function stableStringify(value) {
|
|
608
627
|
return JSON.stringify(sortJson(value));
|
|
@@ -626,7 +645,12 @@ export function forgeBridgeCliBinPath() {
|
|
|
626
645
|
return fileURLToPath(new URL("../cli/bin.js", import.meta.url));
|
|
627
646
|
}
|
|
628
647
|
export function tomlString(value) {
|
|
629
|
-
|
|
648
|
+
if (value.includes("'''")) {
|
|
649
|
+
throw new Error("Codex MCP configuration values cannot contain three consecutive apostrophes.");
|
|
650
|
+
}
|
|
651
|
+
// Codex config overrides pass through npm's PowerShell shim on Windows.
|
|
652
|
+
// Literal TOML strings survive that boundary; basic-string double quotes do not.
|
|
653
|
+
return `'''${value}'''`;
|
|
630
654
|
}
|
|
631
655
|
export function tomlStringArray(values) {
|
|
632
656
|
return `[${values.map(tomlString).join(", ")}]`;
|
|
@@ -195,6 +195,10 @@ export const phaseFiles = {
|
|
|
195
195
|
decompose: {
|
|
196
196
|
jsonFileName: "decompose.proposal.json",
|
|
197
197
|
reportFileName: "decompose.report.md"
|
|
198
|
+
},
|
|
199
|
+
ci_repair: {
|
|
200
|
+
jsonFileName: "ci-repair.handoff.json",
|
|
201
|
+
reportFileName: "ci-repair.report.md"
|
|
198
202
|
}
|
|
199
203
|
};
|
|
200
204
|
export function completionPhaseFromDispatch(dispatch) {
|
|
@@ -224,6 +228,9 @@ export function normalizeCompletionPhase(value) {
|
|
|
224
228
|
if (normalized === "decompose" || normalized === "decomposition" || normalized === "work_order_decomposition" || normalized === "feature_decomposition") {
|
|
225
229
|
return "decompose";
|
|
226
230
|
}
|
|
231
|
+
if (normalized === "ci_repair" || normalized === "pr_checks" || normalized === "repair_pr_checks") {
|
|
232
|
+
return "ci_repair";
|
|
233
|
+
}
|
|
227
234
|
return "implementation";
|
|
228
235
|
}
|
|
229
236
|
export function usesDevelopCycleCompletion(dispatch) {
|
|
@@ -275,9 +282,11 @@ export function completionToolNamesForPhase(phase) {
|
|
|
275
282
|
? "complete_self_review"
|
|
276
283
|
: phase === "validation"
|
|
277
284
|
? "complete_validation"
|
|
278
|
-
: phase === "
|
|
279
|
-
? "
|
|
280
|
-
: "
|
|
285
|
+
: phase === "ci_repair"
|
|
286
|
+
? "complete_ci_repair"
|
|
287
|
+
: phase === "architect"
|
|
288
|
+
? "complete_architect_plan"
|
|
289
|
+
: "complete_qa";
|
|
281
290
|
return [`forge.${base}`, base];
|
|
282
291
|
}
|
|
283
292
|
export function completionToolNamesForQaGate(gate) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { type CompletionPhase, type DebugCompletionPhase, type DecomposeCompletionGate, type DevelopCompletionPhase, type DraftCompletionGate, type QaCompletionGate } from "./phase-completion.js";
|
|
2
|
-
export declare function completionPromptForPhase(phase: CompletionPhase): string;
|
|
2
|
+
export declare function completionPromptForPhase(phase: CompletionPhase, artifactRoot?: string): string;
|
|
3
3
|
export declare function completionPromptForDevelopCycle(phase: CompletionPhase): string;
|
|
4
|
-
export declare function completionPromptForQaCycle(currentGate?: QaCompletionGate): string;
|
|
4
|
+
export declare function completionPromptForQaCycle(currentGate?: QaCompletionGate, artifactRoot?: string): string;
|
|
5
5
|
export declare function completionPromptForDraftCycle(currentGate?: DraftCompletionGate): string;
|
|
6
6
|
export declare function completionPromptForDecomposeCycle(currentGate?: DecomposeCompletionGate): string;
|
|
7
7
|
export declare function completionPromptForDebugCycle(currentGate?: DebugCompletionPhase): string;
|
|
8
8
|
export declare function nextPhaseAfter(phase: CompletionPhase): DevelopCompletionPhase | null;
|
|
9
9
|
export declare function nextDebugPhaseAfter(phase: DebugCompletionPhase): DebugCompletionPhase | null;
|
|
10
|
-
export declare function completionToolNextInstruction(completedPhase: CompletionPhase, status: string, nextPhase: CompletionPhase | "dev_test_ready" | "qa_ready" | "sign_off_ready"): string;
|
|
10
|
+
export declare function completionToolNextInstruction(completedPhase: CompletionPhase, status: string, nextPhase: CompletionPhase | "dev_test_ready" | "qa_ready" | "sign_off_ready" | "provider_checks_ready"): string;
|
|
11
11
|
export declare function completionToolNextInstructionForDraftGate(completedGate: DraftCompletionGate, status: string, nextGate: DraftCompletionGate | null): string;
|
|
12
12
|
export declare function completionToolNextInstructionForQaGate(completedGate: QaCompletionGate, status: string, nextGate: QaCompletionGate | null): string;
|
|
13
13
|
export declare function completionToolNextInstructionForDecomposeGate(completedGate: DecomposeCompletionGate, status: string, nextGate: DecomposeCompletionGate | null): string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { completionPhaseOrder, completionToolNamesForPhase, debugCompletionPhaseOrder, expectedCompletionToolName, expectedDebugCompletionToolName, expectedDecomposeCompletionToolName, phaseFiles, toolServerName } from "./phase-completion.js";
|
|
2
2
|
import { isDebugCompletionPhase, isDevelopCompletionPhase } from "./phase-completion.validation.js";
|
|
3
|
-
export function completionPromptForPhase(phase) {
|
|
3
|
+
export function completionPromptForPhase(phase, artifactRoot = ".forge/work-items/{workItemId}/artifacts") {
|
|
4
4
|
const toolName = expectedCompletionToolName(phase);
|
|
5
5
|
const alias = completionToolNamesForPhase(phase).find((name) => name !== toolName);
|
|
6
6
|
const artifactName = phaseFiles[phase].jsonFileName;
|
|
7
7
|
if (phase === "qa") {
|
|
8
8
|
return `Forge completion tools are available through the MCP server named \`${toolServerName}\`.
|
|
9
9
|
Do not write QA artifacts by hand. When QA is complete, call \`${toolName}(...)\`${alias ? ` (or \`${alias}\` if your client shows unqualified MCP tool names)` : ""} with the required structured QA payload.
|
|
10
|
-
That tool writes the durable QA bundle under
|
|
10
|
+
That tool writes the durable QA bundle under \`${artifactRoot}/\`: \`qa.plan.json\`, \`qa.evidence.json\`, \`qa.findings.json\`, \`${artifactName}\`, and \`qa.report.md\`.
|
|
11
11
|
Use \`status: "pass"\` only when the validated changes satisfy acceptance criteria with concrete evidence. Use \`status: "needs_rework"\` with actionable in-scope findings, or \`status: "blocked"\` with a concrete blocker_reason.
|
|
12
12
|
Include \`policy_warnings\` for non-blocking Forge policy or scope mismatches that should remain visible after QA.
|
|
13
13
|
Forge will mirror only the tool-written QA artifacts; reporting QA completion in prose is not enough.`;
|
|
@@ -22,6 +22,14 @@ The payload must put \`phases\`, \`tasks\`, \`dependencies\`, and \`phase_gates\
|
|
|
22
22
|
Dependency entries use canonical \`before\` and \`after\` task ids, for example \`{ "before": "task-1", "after": "task-2" }\`. Forge accepts \`from\`/\`to\` only as aliases and normalizes them before writing artifacts.
|
|
23
23
|
Use \`status: "pass"\` for a valid pending-approval plan, \`needs_revision\` when story/design input must change, or \`blocked\` with a concrete blocker.
|
|
24
24
|
Forge will mirror only the tool-written Architect artifacts; reporting the plan in prose is not enough.`;
|
|
25
|
+
}
|
|
26
|
+
if (phase === "ci_repair") {
|
|
27
|
+
return `Forge completion tools are available through the MCP server named \`${toolServerName}\`.
|
|
28
|
+
Read the generated \`.forge/work-items/{workItemId}/ci-repair.readiness.json\` before running validation.
|
|
29
|
+
Do not write the CI-repair handoff by hand. After the repair and locally equivalent validation are complete, call \`${toolName}(...)\`${alias ? ` (or \`${alias}\` if your client shows unqualified MCP tool names)` : ""}.
|
|
30
|
+
That tool validates failed-check inspection, root cause, scoped changes, narrow proof, every failed-job guard/test/drift step, provider-only classifications, broader validation, remaining risk, provider state, and push readiness.
|
|
31
|
+
It writes \`.forge/work-items/{workItemId}/artifacts/${artifactName}\`. Forge Bridge will not commit, push, or report CI repair success until this gate passes.
|
|
32
|
+
For a step classified \`provider_only\`, include the exact reason and provider check that will supply the missing proof. Do not weaken or delete the provider check.`;
|
|
25
33
|
}
|
|
26
34
|
return `Forge completion tools are available through the MCP server named \`${toolServerName}\`.
|
|
27
35
|
Do not write phase artifacts by hand. When the phase is complete, call \`${toolName}(...)\`${alias ? ` (or \`${alias}\` if your client shows unqualified MCP tool names)` : ""} with the required evidence payload.
|
|
@@ -38,7 +46,7 @@ Complete the dev cycle in order inside this same provider session:
|
|
|
38
46
|
Each tool writes the canonical artifact under \`.forge/work-items/{workItemId}/artifacts/\` and returns the next-phase instruction Forge expects you to follow.
|
|
39
47
|
If the current phase cannot pass, call the current phase tool with a non-pass status and explicit blockers instead of reporting completion in prose only.`;
|
|
40
48
|
}
|
|
41
|
-
export function completionPromptForQaCycle(currentGate = "qa_plan") {
|
|
49
|
+
export function completionPromptForQaCycle(currentGate = "qa_plan", artifactRoot = ".forge/work-items/{workItemId}/artifacts") {
|
|
42
50
|
return `Forge completion tools are available through the MCP server named \`${toolServerName}\`.
|
|
43
51
|
Do not write QA artifacts by hand. The tool server enforces QA gate order and starts this run at \`${currentGate}\`.
|
|
44
52
|
Complete the QA cycle in order inside this same provider session:
|
|
@@ -50,7 +58,8 @@ Complete the QA cycle in order inside this same provider session:
|
|
|
50
58
|
6. Follow the returned findings instruction, then call \`forge.complete_qa_findings(...)\`.
|
|
51
59
|
7. Follow the returned verdict instruction, then call \`forge.complete_qa_verdict(...)\`.
|
|
52
60
|
Use \`status: "skipped"\` with a reason for gates that are not applicable. If a gate is blocked, keep moving through later gates as skipped due to the blocker and finish with a blocked verdict.
|
|
53
|
-
|
|
61
|
+
On a managed host, start solution-wide \`dotnet test Forge.sln\` evidence through \`forge.start_managed_command\` with at least a 45-minute timeout, poll \`forge.get_managed_command\` until it returns a terminal receipt, and include the returned \`managed_command_id\` in its command evidence. The regression gate rejects generic-shell timeouts and non-terminal receipts for that command.
|
|
62
|
+
The final verdict tool writes the canonical QA bundle under \`${artifactRoot}/\`: \`qa.plan.json\`, \`qa.evidence.json\`, \`qa.findings.json\`, \`qa.verdict.json\`, and \`qa.report.md\`.
|
|
54
63
|
Include \`policy_warnings\` in the final verdict for non-blocking Forge policy or scope mismatches that should remain visible after QA.
|
|
55
64
|
The legacy \`forge.complete_qa\` one-shot tool is not available in normal QA-cycle mode. Reporting QA completion in prose is not enough.`;
|
|
56
65
|
}
|
|
@@ -115,6 +124,11 @@ export function completionToolNextInstruction(completedPhase, status, nextPhase)
|
|
|
115
124
|
}
|
|
116
125
|
return "QA accepted. Forge has the structured evidence needed to move this work item to Sign-Off.";
|
|
117
126
|
}
|
|
127
|
+
if (completedPhase === "ci_repair") {
|
|
128
|
+
return status === "pass"
|
|
129
|
+
? "CI repair handoff accepted. Forge Bridge may now commit, push, and return the PR to provider checks."
|
|
130
|
+
: "Stay in CI repair, address the exact missing evidence returned by this gate, then call forge.complete_ci_repair again.";
|
|
131
|
+
}
|
|
118
132
|
if (status !== "pass") {
|
|
119
133
|
return `Stay in ${completedPhase}, address the recorded blockers, then call ${expectedCompletionToolName(completedPhase)} again.`;
|
|
120
134
|
}
|
|
@@ -203,7 +217,7 @@ export function completionToolNextInstructionForDebugGate(completedGate, status,
|
|
|
203
217
|
function qaGateInstruction(gate) {
|
|
204
218
|
switch (gate) {
|
|
205
219
|
case "qa_regression":
|
|
206
|
-
return "Run or explicitly skip applicable regression/build/lint/typecheck/e2e checks, then call forge.complete_qa_regression.";
|
|
220
|
+
return "Run or explicitly skip applicable regression/build/lint/typecheck/e2e checks, then call forge.complete_qa_regression. On a managed host, start solution-wide dotnet test Forge.sln with forge.start_managed_command using at least a 45-minute timeout, poll forge.get_managed_command to a terminal receipt, and include its managed_command_id in the command evidence. A reproduced failure outside the current diff and acceptance criteria may remain non-blocking only when the current item has independent passing evidence: preserve it as an out_of_scope_failure with candidate_bug_id, scope_evidence, acceptance_criteria_independent: true, and a failing focused repro command/exit code. Never classify an unexplained, in-scope, or infrastructure failure this way.";
|
|
207
221
|
case "qa_api":
|
|
208
222
|
return "Run or explicitly skip applicable API/backend contract checks, then call forge.complete_qa_api.";
|
|
209
223
|
case "qa_manual_web":
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CompletionToolCallResult, type CompletionToolRuntime, type CompletionToolRuntimeOptions, type CompletionToolServerConfig } from "./phase-completion.js";
|
|
2
|
+
import { type ManagedAttemptToolResult } from "./managed-attempt-tools.js";
|
|
2
3
|
export declare function prepareCompletionToolRuntime(options: CompletionToolRuntimeOptions): Promise<CompletionToolRuntime>;
|
|
3
4
|
export declare function buildCompletionToolServerArgs(config: CompletionToolServerConfig): readonly string[];
|
|
4
5
|
export declare function codexMcpConfigArgs(runtime: CompletionToolRuntime): readonly string[];
|
|
@@ -10,11 +11,12 @@ export declare class CompletionToolServerSession {
|
|
|
10
11
|
private currentQaGate;
|
|
11
12
|
private currentDraftGate;
|
|
12
13
|
private currentDecomposeGate;
|
|
14
|
+
private readonly managedCommandReceipts;
|
|
13
15
|
private completed;
|
|
14
16
|
constructor(config: CompletionToolServerConfig);
|
|
15
17
|
get instructions(): string;
|
|
16
18
|
toolDefinitions(): readonly unknown[];
|
|
17
|
-
callTool(toolName: string, input: unknown): Promise<CompletionToolCallResult>;
|
|
19
|
+
callTool(toolName: string, input: unknown): Promise<CompletionToolCallResult | ManagedAttemptToolResult>;
|
|
18
20
|
private callDecomposeGateTool;
|
|
19
21
|
private callDraftGateTool;
|
|
20
22
|
private callDebugGateTool;
|
|
@@ -25,6 +27,15 @@ export declare class CompletionToolServerSession {
|
|
|
25
27
|
private advanceAfterQaGate;
|
|
26
28
|
private advanceAfterDebugGate;
|
|
27
29
|
}
|
|
30
|
+
export declare function completionToolRuntimeEnvironment(runtimeEnvironment?: Readonly<Record<string, string>>): Readonly<Record<string, string>>;
|
|
31
|
+
/**
|
|
32
|
+
* A solution-wide Forge test is long enough that a generic provider shell can
|
|
33
|
+
* expire while VSTest is still healthy. On managed host attempts, only the
|
|
34
|
+
* attempt-owned command runner can prove the exact process outcome and clean
|
|
35
|
+
* up its process tree. Keep this check at the completion gate so prompt drift
|
|
36
|
+
* cannot turn an arbitrary shell timeout into a QA blocker.
|
|
37
|
+
*/
|
|
38
|
+
export declare function assertManagedQaRegressionEvidence(input: unknown, receipts: readonly Readonly<Record<string, unknown>>[]): void;
|
|
28
39
|
export declare function runCompletionMcpServer(config: CompletionToolServerConfig): Promise<void>;
|
|
29
40
|
export declare function parseCompletionMcpArgs(argv: readonly string[]): {
|
|
30
41
|
readonly ok: true;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { completionPhaseFromDispatch, completionPhaseOrder, completionRedactionSecretsEnv, completionToolNamesForDebugGate, completionToolNamesForDecomposeGate, completionToolNamesForDraftGate, completionToolNamesForPhase, completionToolNamesForQaGate, debugCompletionPhaseOrder, decomposeCompletionGateOrder, draftCompletionGateOrder, qaCompletionGateOrder, toolServerName, usesArchitectCycleCompletion, usesDebugCycleCompletion, usesDevelopCycleCompletion, usesQaCycleCompletion } from "./phase-completion.js";
|
|
4
|
-
import { asDebugCompletionPhase, asJsonRpcMessage, asMutableRecord, asRecord, decomposeGateFromToolName, draftGateFromToolName, errorMessage, forgeBridgeCliBinPath, isDebugCompletionPhase, isDecomposeDispatch, isDevelopCompletionPhase, normalizedOwnerType, parseCompletionRedactionSecrets, parseOptionalJsonObject, parseStrictCompletionPhase, phaseFromToolName, qaGateFromToolName, requiredString, rpcError, tomlString, tomlStringArray, writeFileAtomic, writeJsonRpc } from "./phase-completion.validation.js";
|
|
4
|
+
import { asDebugCompletionPhase, asJsonRpcMessage, asMutableRecord, asRecord, artifactOwnerRelativeRoot, decomposeGateFromToolName, draftGateFromToolName, errorMessage, forgeBridgeCliBinPath, isDebugCompletionPhase, isDecomposeDispatch, isDevelopCompletionPhase, normalizedOwnerType, parseCompletionRedactionSecrets, parseOptionalJsonObject, parseStrictCompletionPhase, phaseFromToolName, qaGateFromToolName, requiredString, rpcError, tomlString, tomlStringArray, writeFileAtomic, writeJsonRpc } from "./phase-completion.validation.js";
|
|
5
5
|
import { completionPromptForDebugCycle, completionPromptForDecomposeCycle, completionPromptForDevelopCycle, completionPromptForDraftCycle, completionPromptForPhase, completionPromptForQaCycle, completionToolNextInstruction, completionToolNextInstructionForDebugGate, completionToolNextInstructionForDecomposeGate, completionToolNextInstructionForDraftGate, completionToolNextInstructionForQaGate, nextDebugPhaseAfter, nextPhaseAfter } from "./phase-completion.prompts.js";
|
|
6
6
|
import { toolDescription, toolInputSchema } from "./phase-completion.schemas.js";
|
|
7
7
|
import { writeCompletionArtifact, writeDecomposeGateCompletionArtifact, writeDraftGateCompletionArtifact } from "./phase-completion.artifacts.js";
|
|
8
|
+
import { callManagedAttemptTool, isManagedAttemptTool, managedAttemptToolDefinition, managedAttemptToolNames, } from "./managed-attempt-tools.js";
|
|
8
9
|
export async function prepareCompletionToolRuntime(options) {
|
|
9
10
|
const phase = options.phase ?? completionPhaseFromDispatch(options.dispatch);
|
|
10
11
|
const worktreePath = path.resolve(options.worktree.worktreePath);
|
|
@@ -32,7 +33,7 @@ export async function prepareCompletionToolRuntime(options) {
|
|
|
32
33
|
serverName: toolServerName,
|
|
33
34
|
command: process.execPath,
|
|
34
35
|
args: [forgeBridgeCliBinPath(), ...mcpArgs],
|
|
35
|
-
env:
|
|
36
|
+
env: completionToolRuntimeEnvironment(options.runtimeEnvironment),
|
|
36
37
|
cleanup: async () => undefined
|
|
37
38
|
};
|
|
38
39
|
if (options.dispatch.execution.provider.trim().toLowerCase() !== "cursor") {
|
|
@@ -82,7 +83,9 @@ export function codexMcpConfigArgs(runtime) {
|
|
|
82
83
|
"-c",
|
|
83
84
|
`${prefix}.command=${tomlString(runtime.command)}`,
|
|
84
85
|
"-c",
|
|
85
|
-
`${prefix}.args=${tomlStringArray(runtime.args)}
|
|
86
|
+
`${prefix}.args=${tomlStringArray(runtime.args)}`,
|
|
87
|
+
"-c",
|
|
88
|
+
`${prefix}.default_tools_approval_mode=${tomlString("approve")}`
|
|
86
89
|
];
|
|
87
90
|
for (const [key, value] of Object.entries(runtime.env)) {
|
|
88
91
|
args.push("-c", `${prefix}.env.${key}=${tomlString(value)}`);
|
|
@@ -117,6 +120,7 @@ export class CompletionToolServerSession {
|
|
|
117
120
|
currentQaGate = "qa_plan";
|
|
118
121
|
currentDraftGate = "draft_intent";
|
|
119
122
|
currentDecomposeGate = "decompose_subject_intake";
|
|
123
|
+
managedCommandReceipts = [];
|
|
120
124
|
completed = false;
|
|
121
125
|
constructor(config) {
|
|
122
126
|
this.config = config;
|
|
@@ -130,15 +134,28 @@ export class CompletionToolServerSession {
|
|
|
130
134
|
: this.config.debugCycle
|
|
131
135
|
? completionPromptForDebugCycle(asDebugCompletionPhase(this.currentPhase))
|
|
132
136
|
: this.config.qaCycle
|
|
133
|
-
? completionPromptForQaCycle(this.currentQaGate)
|
|
137
|
+
? completionPromptForQaCycle(this.currentQaGate, artifactOwnerRelativeRoot(this.config.ownerType, this.config.ownerId, this.config.workItemId))
|
|
134
138
|
: this.config.developCycle
|
|
135
139
|
? completionPromptForDevelopCycle(this.currentPhase)
|
|
136
|
-
: completionPromptForPhase(this.currentPhase);
|
|
140
|
+
: completionPromptForPhase(this.currentPhase, artifactOwnerRelativeRoot(this.config.ownerType, this.config.ownerId, this.config.workItemId));
|
|
137
141
|
}
|
|
138
142
|
toolDefinitions() {
|
|
139
|
-
|
|
143
|
+
const completionTools = completionToolNamesForServer(this.config).map((name) => toolDefinition(name, phaseFromToolName(name), qaGateFromToolName(name), decomposeGateFromToolName(name)));
|
|
144
|
+
return managedAttemptToolsAvailable()
|
|
145
|
+
? [...completionTools, ...managedAttemptToolNames.map(managedAttemptToolDefinition)]
|
|
146
|
+
: completionTools;
|
|
140
147
|
}
|
|
141
148
|
async callTool(toolName, input) {
|
|
149
|
+
if (isManagedAttemptTool(toolName)) {
|
|
150
|
+
if (!managedAttemptToolsAvailable()) {
|
|
151
|
+
throw new Error("Forge managed-attempt tools require an active managed host runtime.");
|
|
152
|
+
}
|
|
153
|
+
const result = await callManagedAttemptTool(toolName, input, this.config.worktreePath);
|
|
154
|
+
if (Array.isArray(result.structuredContent.command)) {
|
|
155
|
+
this.managedCommandReceipts.push(result.structuredContent);
|
|
156
|
+
}
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
142
159
|
const requestedPhase = phaseFromToolName(toolName);
|
|
143
160
|
if (this.completed) {
|
|
144
161
|
throw new Error("Forge completion cycle is already complete; no more completion calls are accepted.");
|
|
@@ -292,6 +309,9 @@ export class CompletionToolServerSession {
|
|
|
292
309
|
throw new Error(`Tool ${toolName} is out of order. Current Forge QA gate is ${this.currentQaGate}.`);
|
|
293
310
|
}
|
|
294
311
|
const completedGate = this.currentQaGate;
|
|
312
|
+
if (completedGate === "qa_regression" && managedAttemptToolsAvailable()) {
|
|
313
|
+
assertManagedQaRegressionEvidence(input, this.managedCommandReceipts);
|
|
314
|
+
}
|
|
295
315
|
const reference = await writeCompletionArtifact({ ...this.config, phase: "qa" }, toolName, input);
|
|
296
316
|
const status = reference.status.trim().toLowerCase();
|
|
297
317
|
const nextGate = this.advanceAfterQaGate(completedGate);
|
|
@@ -327,6 +347,10 @@ export class CompletionToolServerSession {
|
|
|
327
347
|
this.completed = true;
|
|
328
348
|
return "sign_off_ready";
|
|
329
349
|
}
|
|
350
|
+
if (phase === "ci_repair") {
|
|
351
|
+
this.completed = true;
|
|
352
|
+
return "provider_checks_ready";
|
|
353
|
+
}
|
|
330
354
|
if (isDebugCompletionPhase(phase)) {
|
|
331
355
|
return nextDebugPhaseAfter(phase) ?? "qa_ready";
|
|
332
356
|
}
|
|
@@ -382,6 +406,102 @@ export class CompletionToolServerSession {
|
|
|
382
406
|
return null;
|
|
383
407
|
}
|
|
384
408
|
}
|
|
409
|
+
const completionToolRuntimeEnvironmentNames = [
|
|
410
|
+
"FORGE_RUNTIME_MODE",
|
|
411
|
+
"FORGE_RESOURCE_LEASE_ID",
|
|
412
|
+
"FORGE_DISPATCH_ATTEMPT_ID",
|
|
413
|
+
"FORGE_LOG_DIR",
|
|
414
|
+
"FORGE_TEST_OUTPUT_DIR",
|
|
415
|
+
"FORGE_TMPDIR",
|
|
416
|
+
"TMPDIR",
|
|
417
|
+
"TMP",
|
|
418
|
+
"TEMP",
|
|
419
|
+
];
|
|
420
|
+
export function completionToolRuntimeEnvironment(runtimeEnvironment) {
|
|
421
|
+
if (!runtimeEnvironment)
|
|
422
|
+
return {};
|
|
423
|
+
const env = {};
|
|
424
|
+
for (const name of completionToolRuntimeEnvironmentNames) {
|
|
425
|
+
const value = runtimeEnvironment[name]?.trim();
|
|
426
|
+
if (value)
|
|
427
|
+
env[name] = value;
|
|
428
|
+
}
|
|
429
|
+
return env;
|
|
430
|
+
}
|
|
431
|
+
const minimumManagedSolutionTestTimeoutMs = 45 * 60 * 1000;
|
|
432
|
+
/**
|
|
433
|
+
* A solution-wide Forge test is long enough that a generic provider shell can
|
|
434
|
+
* expire while VSTest is still healthy. On managed host attempts, only the
|
|
435
|
+
* attempt-owned command runner can prove the exact process outcome and clean
|
|
436
|
+
* up its process tree. Keep this check at the completion gate so prompt drift
|
|
437
|
+
* cannot turn an arbitrary shell timeout into a QA blocker.
|
|
438
|
+
*/
|
|
439
|
+
export function assertManagedQaRegressionEvidence(input, receipts) {
|
|
440
|
+
const payload = asRecord(input, "QA regression completion payload");
|
|
441
|
+
const nestedEvidence = asMutableRecord(payload.evidence);
|
|
442
|
+
const commands = payload.commands ?? nestedEvidence.commands;
|
|
443
|
+
if (!Array.isArray(commands))
|
|
444
|
+
return;
|
|
445
|
+
for (const [index, entry] of commands.entries()) {
|
|
446
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
447
|
+
continue;
|
|
448
|
+
const command = entry.command;
|
|
449
|
+
if (typeof command !== "string" || !isForgeSolutionTestCommand(command))
|
|
450
|
+
continue;
|
|
451
|
+
const managedCommandId = entry.managed_command_id;
|
|
452
|
+
if (typeof managedCommandId !== "string" || !managedCommandId.trim()) {
|
|
453
|
+
throw new Error(`qa_regression_managed_command_id_required: commands[${index}] runs the solution-wide Forge test. `
|
|
454
|
+
+ "Run it with forge.start_managed_command, poll forge.get_managed_command to a terminal receipt, and include the returned managed_command_id in this command evidence.");
|
|
455
|
+
}
|
|
456
|
+
const matchingReceipts = receipts.filter((receipt) => {
|
|
457
|
+
const tokens = receipt.command;
|
|
458
|
+
return receipt.command_id === managedCommandId
|
|
459
|
+
&& Array.isArray(tokens)
|
|
460
|
+
&& tokens.every((token) => typeof token === "string")
|
|
461
|
+
&& isForgeSolutionTestCommand(tokens.join(" "));
|
|
462
|
+
});
|
|
463
|
+
if (matchingReceipts.length === 0) {
|
|
464
|
+
throw new Error(`qa_regression_managed_command_required: commands[${index}] runs the solution-wide Forge test. `
|
|
465
|
+
+ "Run it with forge.start_managed_command, poll forge.get_managed_command to a terminal receipt, and include its matching managed_command_id; generic-shell timeout evidence is not accepted on a managed host.");
|
|
466
|
+
}
|
|
467
|
+
const terminalReceipts = matchingReceipts.filter((receipt) => typeof receipt.status === "string" && [
|
|
468
|
+
"pass",
|
|
469
|
+
"fail",
|
|
470
|
+
"timed_out",
|
|
471
|
+
"timeout_termination_failed",
|
|
472
|
+
"runner_error",
|
|
473
|
+
].includes(receipt.status));
|
|
474
|
+
if (terminalReceipts.length === 0) {
|
|
475
|
+
throw new Error(`qa_regression_managed_command_in_progress: commands[${index}] has not produced a terminal managed receipt. `
|
|
476
|
+
+ "Poll forge.get_managed_command until the status is terminal, then resubmit this gate.");
|
|
477
|
+
}
|
|
478
|
+
const adequateReceipt = terminalReceipts.some((receipt) => {
|
|
479
|
+
if (receipt.timed_out !== true)
|
|
480
|
+
return true;
|
|
481
|
+
return typeof receipt.timeout_ms === "number"
|
|
482
|
+
&& receipt.timeout_ms >= minimumManagedSolutionTestTimeoutMs
|
|
483
|
+
&& receipt.process_tree_terminated === true;
|
|
484
|
+
});
|
|
485
|
+
if (!adequateReceipt) {
|
|
486
|
+
throw new Error(`qa_regression_managed_timeout_too_short: commands[${index}] timed out before the minimum `
|
|
487
|
+
+ `${minimumManagedSolutionTestTimeoutMs}ms solution-test budget. Rerun it with forge.start_managed_command `
|
|
488
|
+
+ "using at least a 45-minute timeout and resubmit this gate.");
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
function isForgeSolutionTestCommand(command) {
|
|
493
|
+
const normalized = command.trim().toLowerCase().replaceAll("\\", "/");
|
|
494
|
+
return normalized.includes("dotnet")
|
|
495
|
+
&& /(?:^|\s)test(?:\s|$)/u.test(normalized)
|
|
496
|
+
&& /(?:^|[\s/"'])forge\.sln(?:[\s"']|$)/u.test(normalized);
|
|
497
|
+
}
|
|
498
|
+
function managedAttemptToolsAvailable() {
|
|
499
|
+
return process.env.FORGE_RUNTIME_MODE === "host"
|
|
500
|
+
&& Boolean(process.env.FORGE_RESOURCE_LEASE_ID?.trim())
|
|
501
|
+
&& Boolean(process.env.FORGE_DISPATCH_ATTEMPT_ID?.trim())
|
|
502
|
+
&& Boolean(process.env.FORGE_LOG_DIR?.trim())
|
|
503
|
+
&& Boolean(process.env.FORGE_TEST_OUTPUT_DIR?.trim());
|
|
504
|
+
}
|
|
385
505
|
export async function runCompletionMcpServer(config) {
|
|
386
506
|
const session = new CompletionToolServerSession(config);
|
|
387
507
|
process.stdin.setEncoding("utf8");
|
|
@@ -437,7 +557,7 @@ export function parseCompletionMcpArgs(argv) {
|
|
|
437
557
|
const rawPhase = argv[++index];
|
|
438
558
|
const parsedPhase = parseStrictCompletionPhase(rawPhase);
|
|
439
559
|
if (!parsedPhase) {
|
|
440
|
-
return { ok: false, error: "mcp --phase must be one of: implementation, self-review, validation, qa, architect, draft, debug-repro, debug-root-cause, debug-fix, debug-regression." };
|
|
560
|
+
return { ok: false, error: "mcp --phase must be one of: implementation, self-review, validation, qa, architect, draft, decompose, ci-repair, debug-repro, debug-root-cause, debug-fix, debug-regression." };
|
|
441
561
|
}
|
|
442
562
|
phase = parsedPhase;
|
|
443
563
|
}
|