@loucompanion/forge-bridge 0.1.4-dev.d2d83bc81b6a → 0.1.4-dev.e83e5bc6ecce
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 +2 -2
- package/dist/bridge/bridge.service.d.ts +5 -1
- package/dist/bridge/bridge.service.js +40 -6
- package/dist/bridge/bridge.types.d.ts +11 -0
- package/dist/bridge/runner-host-capabilities.d.ts +2 -0
- package/dist/bridge/runner-host-capabilities.js +4 -0
- package/dist/bridge/test-postgres-capability.d.ts +14 -0
- package/dist/bridge/test-postgres-capability.js +120 -0
- package/dist/cleanup/cleanup.service.d.ts +9 -0
- package/dist/cleanup/cleanup.service.js +72 -109
- package/dist/cleanup/cleanup.types.d.ts +4 -0
- package/dist/cleanup/forge-owned-paths.d.ts +9 -0
- package/dist/cleanup/forge-owned-paths.js +53 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +5 -0
- package/dist/cleanup/host-runtime-ledger.js +109 -0
- package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
- package/dist/cleanup/managed-branch-sweep.js +111 -0
- package/dist/cli/cli.service.js +10 -2
- package/dist/runtime/host-database-capability-boundary.d.ts +1 -1
- package/dist/runtime/host-database-capability-boundary.js +1 -0
- package/dist/runtime/host-facts.d.ts +35 -0
- package/dist/runtime/host-facts.js +95 -0
- package/dist/runtime/host-load-admission.d.ts +52 -0
- package/dist/runtime/host-load-admission.js +84 -0
- package/dist/runtime/host-load-child-environment.d.ts +22 -0
- package/dist/runtime/host-load-child-environment.js +65 -0
- package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
- package/dist/runtime/host-load-forge-cgroups.js +140 -0
- package/dist/runtime/host-load-governor-config.d.ts +34 -0
- package/dist/runtime/host-load-governor-config.js +46 -0
- package/dist/runtime/host-load-governor.d.ts +172 -0
- package/dist/runtime/host-load-governor.js +519 -0
- package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
- package/dist/runtime/host-load-ledger-lock.js +185 -0
- package/dist/runtime/host-load-sampler.d.ts +126 -0
- package/dist/runtime/host-load-sampler.js +232 -0
- package/dist/runtime/host-load-step-class.d.ts +68 -0
- package/dist/runtime/host-load-step-class.js +106 -0
- package/dist/runtime/host-load-step-reaper.d.ts +27 -0
- package/dist/runtime/host-load-step-reaper.js +95 -0
- package/dist/runtime/host-load-step-run.d.ts +73 -0
- package/dist/runtime/host-load-step-run.js +102 -0
- package/dist/runtime/host-load-token-ledger.d.ts +174 -0
- package/dist/runtime/host-load-token-ledger.js +421 -0
- package/dist/runtime/host-pressure-stall.d.ts +61 -0
- package/dist/runtime/host-pressure-stall.js +168 -0
- package/dist/runtime/host-runtime-contract.d.ts +4 -0
- package/dist/runtime/host-runtime-contract.js +6 -1
- package/dist/runtime/host-runtime-lease.d.ts +17 -3
- package/dist/runtime/host-runtime-lease.js +83 -4
- package/dist/runtime/host-runtime-promotion.js +12 -0
- package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
- package/dist/runtime/host-runtime-requirements-check.js +29 -0
- package/dist/runtime/host-runtime-requirements.d.ts +36 -0
- package/dist/runtime/host-runtime-requirements.js +117 -0
- package/dist/sandbox/host-capacity-broker.d.ts +107 -0
- package/dist/sandbox/host-capacity-broker.js +315 -0
- package/dist/sandbox/runtime.d.ts +10 -1
- package/dist/sandbox/runtime.js +45 -2
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- package/dist/session/managed-attempt-tools.d.ts +2 -0
- package/dist/session/managed-attempt-tools.js +156 -37
- package/dist/session/managed-command-host-load.d.ts +45 -0
- package/dist/session/managed-command-host-load.js +82 -0
- package/dist/session/mcp-argument-coercion.d.ts +23 -0
- package/dist/session/mcp-argument-coercion.js +121 -0
- package/dist/session/phase-completion.artifacts.d.ts +7 -0
- package/dist/session/phase-completion.artifacts.js +98 -25
- package/dist/session/phase-completion.command-validation.d.ts +7 -0
- package/dist/session/phase-completion.command-validation.js +77 -0
- package/dist/session/phase-completion.d.ts +4 -0
- package/dist/session/phase-completion.helpers.js +13 -12
- package/dist/session/phase-completion.js +4 -0
- package/dist/session/phase-completion.prompts.js +6 -1
- package/dist/session/phase-completion.runtime.d.ts +5 -3
- package/dist/session/phase-completion.runtime.js +49 -19
- package/dist/session/phase-completion.schema-parts.d.ts +19 -0
- package/dist/session/phase-completion.schema-parts.js +188 -0
- package/dist/session/phase-completion.schemas.d.ts +3 -3
- package/dist/session/phase-completion.schemas.js +184 -209
- package/dist/session/phase-completion.validation.d.ts +2 -3
- package/dist/session/phase-completion.validation.js +46 -92
- package/dist/session/pre-publication-host-load.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +111 -0
- package/dist/session/pre-publication-process.d.ts +3 -0
- package/dist/session/pre-publication-process.js +25 -12
- package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
- package/dist/session/pre-publication-skipped-tests.js +109 -0
- package/dist/session/pre-publication-step-execution.d.ts +11 -0
- package/dist/session/pre-publication-step-execution.js +49 -0
- package/dist/session/pre-publication-validation.d.ts +9 -9
- package/dist/session/pre-publication-validation.js +44 -59
- package/dist/session/provider-cli/provider-cli.artifacts.d.ts +2 -1
- package/dist/session/provider-cli/provider-cli.artifacts.js +21 -15
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +32 -1
- package/dist/session/provider-cli/provider-cli.process.js +122 -30
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +5 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +16 -1
- package/dist/session/provider-cli/provider-cli.service.js +134 -30
- package/dist/session/provider-cli/provider-cli.types.d.ts +4 -0
- package/dist/session/provider-cli/provider-in-flight-work.d.ts +6 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +47 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +6 -0
- package/dist/session/provider-cli/provider-output-state.js +9 -0
- package/dist/session/publishable-worktree-changes.d.ts +54 -0
- package/dist/session/publishable-worktree-changes.js +193 -0
- package/dist/session/sandbox-host-capacity-gate.d.ts +30 -0
- package/dist/session/sandbox-host-capacity-gate.js +229 -0
- package/dist/session/session.base.d.ts +3 -0
- package/dist/session/session.service.d.ts +2 -0
- package/dist/session/session.service.js +21 -4
- package/dist/session/session.types.d.ts +3 -0
- package/dist/session/session.types.js +14 -2
- package/dist/shared/process/host-process-supervisor.d.ts +1 -0
- package/dist/shared/process/host-process-supervisor.js +1 -1
- package/dist/shared/process/process-tree.d.ts +52 -0
- package/dist/shared/process/process-tree.js +144 -0
- package/dist/shared/process/process.d.ts +67 -0
- package/dist/shared/process/process.js +213 -11
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/dependency-warmer.d.ts +25 -0
- package/dist/worktree/dependency-warmer.js +46 -10
- package/dist/worktree/worktree.service.d.ts +10 -1
- package/dist/worktree/worktree.service.js +42 -2
- package/dist/worktree/worktree.types.d.ts +7 -0
- package/package.json +1 -1
|
@@ -278,7 +278,7 @@ function buildRuntimeContextPrompt(dispatch, prompt, runtimeEnvironment) {
|
|
|
278
278
|
? "- `FORGE_HOST_CONCURRENCY=host_parallel_safe` means Forge verified this contract's assigned-port probe and gave this attempt independent ports, paths, and process supervisors. Do not share or discover another attempt's runtime resources."
|
|
279
279
|
: "- `FORGE_HOST_CONCURRENCY=host_serial_only` means Forge holds the runner-local project singleton named by `FORGE_SINGLETON_KEYS`; do not bypass or release it yourself.";
|
|
280
280
|
const playwright = runtimeEnvironment?.FORGE_PLAYWRIGHT_CONFIG
|
|
281
|
-
? "\n- For Playwright, use the generated `FORGE_PLAYWRIGHT_CONFIG`; it targets this attempt's verified `FORGE_PLAYWRIGHT_BASE_URL`, disables project `webServer` startup/reuse, and writes under `FORGE_TEST_OUTPUT_DIR`. Do not invoke the project Playwright config directly."
|
|
281
|
+
? "\n- For Playwright, use the generated `FORGE_PLAYWRIGHT_CONFIG`; it targets this attempt's verified `FORGE_PLAYWRIGHT_BASE_URL`, disables project `webServer` startup/reuse, and writes under `FORGE_TEST_OUTPUT_DIR`. Do not invoke the project Playwright config directly. Run `playwright test --config <absolute value of FORGE_PLAYWRIGHT_CONFIG>` from the Playwright project directory through `forge.start_managed_command` (in Forge: command `pnpm`, args `[\"--dir\", \"tests/e2e\", \"exec\", \"playwright\", \"test\", \"--config\", \"<path>\"]`), and append spec file paths such as `specs/<name>.spec.ts` to run only the specs you are working on. Repository wrappers that start their own disposable stack, such as Forge's `pnpm --dir tests/e2e test`, refuse to run inside a managed attempt; Forge-owned pre-publication still runs the full suite."
|
|
282
282
|
: "";
|
|
283
283
|
return `${prompt.trimEnd()}
|
|
284
284
|
|
|
@@ -392,6 +392,13 @@ Architect revision context:
|
|
|
392
392
|
- Reviewer feedback: ${dispatch.architectRevision.feedback}
|
|
393
393
|
Revise the prior plan in response to the feedback. Preserve accepted scope and only change what the feedback requires.`;
|
|
394
394
|
}
|
|
395
|
+
/**
|
|
396
|
+
* Headless providers must not end a turn to wait: Forge stops the provider shortly after
|
|
397
|
+
* a turn ends, and nothing started in the background reports back.
|
|
398
|
+
*/
|
|
399
|
+
export function providerTurnEndRule(completionStep) {
|
|
400
|
+
return `Ending your turn ends this run. Forge runs you headless and stops the provider process shortly after a turn ends, together with any managed command it is still running. Background tasks, Monitor, \`run_in_background\` shells and other watchers never report back after that. Do not end your turn to wait for anything: block on \`forge.wait_managed_command\` until it returns a terminal receipt (call it again while \`command_continues=true\`), then ${completionStep} in the same turn.`;
|
|
401
|
+
}
|
|
395
402
|
export function buildImplementationPrompt(dispatch, phase = completionPhaseFromDispatch(dispatch)) {
|
|
396
403
|
return `You are Forge's ${phase.replace(/_/g, " ")} phase runner running locally in a prepared git worktree.
|
|
397
404
|
|
|
@@ -403,6 +410,7 @@ Forge owns protocol files: worktree prep, injected .forge commands/hooks/skills,
|
|
|
403
410
|
Read Forge-provided context under .forge when needed, but do not edit .forge files or create Forge verdict/report artifacts by hand.
|
|
404
411
|
|
|
405
412
|
${completionPromptForPhase(phase)}
|
|
413
|
+
${providerTurnEndRule("call the completion tool")}
|
|
406
414
|
|
|
407
415
|
Finish with a concise summary of changed files and verification after calling the completion tool.`;
|
|
408
416
|
}
|
|
@@ -417,6 +425,7 @@ Forge owns protocol files: worktree prep, injected .forge commands/hooks/skills,
|
|
|
417
425
|
Read Forge-provided context under .forge when needed, but do not edit .forge files or create Forge verdict/report artifacts by hand.
|
|
418
426
|
|
|
419
427
|
${completionPromptForDevelopCycle(phase)}
|
|
428
|
+
${providerTurnEndRule("call the current phase's completion tool")}
|
|
420
429
|
|
|
421
430
|
Finish with a concise summary of changed files and verification after the validation completion tool has accepted the work, or after the current phase tool records a non-pass blocker.`;
|
|
422
431
|
}
|
|
@@ -431,6 +440,7 @@ Forge owns protocol files: worktree prep, injected .forge commands/hooks/skills,
|
|
|
431
440
|
Read Forge-provided context under .forge when needed, but do not edit .forge files or create Forge Debug artifacts by hand.
|
|
432
441
|
|
|
433
442
|
${completionPromptForDebugCycle(isDebugCompletionPhaseForProvider(phase) ? phase : "debug_repro")}
|
|
443
|
+
${providerTurnEndRule("call the current Debug gate's completion tool")}
|
|
434
444
|
|
|
435
445
|
Finish with a concise summary of changed files and verification after the debug_regression completion tool has accepted the work, or after the current Debug gate tool records a non-pass blocker.`;
|
|
436
446
|
}
|
|
@@ -587,6 +597,7 @@ Report in-scope defects as actionable findings with repro steps, expected/actual
|
|
|
587
597
|
Out-of-scope or follow-up issues belong in candidate_bugs instead of blocking the current item. If a broad regression command fails only on a surface outside both the current diff and acceptance criteria, reproduce that failure with a focused command. The regression gate may pass only when the current item has independent passing evidence and the failed command is preserved with classification out_of_scope_failure, candidate_bug_id, scope_evidence, acceptance_criteria_independent: true, repro_command, and a non-zero repro_exit_code. Never use this classification for an unexplained failure, a runner/environment failure, or a failure that can affect the current item.
|
|
588
598
|
|
|
589
599
|
${completionPromptForQaCycle("qa_plan", artifactRoot)}
|
|
600
|
+
${providerTurnEndRule("call the next QA gate's completion tool, through forge.complete_qa_verdict,")}
|
|
590
601
|
|
|
591
602
|
Finish with a concise summary only after forge.complete_qa_verdict accepts the QA bundle.`;
|
|
592
603
|
}
|
|
@@ -607,6 +618,8 @@ export function buildConflictResolvePrompt(dispatch, branchName) {
|
|
|
607
618
|
The current branch is the pull request branch ${branchName}. Resolve merge conflicts against ${targetBranch}.
|
|
608
619
|
Fetch origin, merge ${targetBranch} into ${branchName} with --no-commit, resolve conflicts conservatively, and run relevant validation when practical.
|
|
609
620
|
Leave every repair change uncommitted and unpushed. Forge Bridge owns the sole final commit and compare-and-swap push after validation passes.
|
|
621
|
+
Deletions on ${targetBranch} are part of the merge. Never restore a file that ${targetBranch} deleted and ${branchName} never changed, and never revert ${targetBranch} edits to files ${branchName} never changed, including under .forge/. Forge rejects a resolution that does.
|
|
622
|
+
A modify/delete conflict (one side deleted the file, the other changed it) is a real conflict for you to decide: resolve it explicitly with \`git rm <path>\` to accept the deletion or \`git add <path>\` to keep the changed file, and name each such path and your decision in your final summary. A binary conflict has no markers: put the chosen version on disk and \`git add <path>\`. Forge rejects a merge that leaves any of these unresolved or keeps conflict markers.
|
|
610
623
|
Keep the original work item intent intact:
|
|
611
624
|
- Work item: ${dispatch.workItem.id}
|
|
612
625
|
- Title: ${dispatch.workItem.title}
|
|
@@ -644,6 +657,7 @@ Forge prepared two required inputs before this agent started:
|
|
|
644
657
|
Read both first. The readiness contract supplies attempt-scoped E2E URLs, Playwright/browser readiness, runnable local preflight commands, and provider-only spec patterns. Run every listed local preflight. Do not override the readiness environment or bypass its provider-only exclusions: those specs require infrastructure unavailable inside this managed attempt. Record each applicable provider-only step and the provider check that supplies its proof, and leave provider CI authoritative without weakening its coverage.
|
|
645
658
|
|
|
646
659
|
After repair and validation, call forge.complete_ci_repair with the complete structured handoff. Forge Bridge will validate it and will not commit, push, or report success until that gate passes. If the tool rejects the payload, correct the exact missing evidence it reports and call it again.
|
|
660
|
+
${providerTurnEndRule("call forge.complete_ci_repair")}
|
|
647
661
|
|
|
648
662
|
Keep the original work item intent intact:
|
|
649
663
|
- Work item: ${dispatch.workItem.id}
|
|
@@ -695,6 +709,7 @@ Before handing a changed diff back for publication:
|
|
|
695
709
|
4. Fix validation failures locally before requesting publication. Preserve acceptance criteria and assertions; do not skip tests, weaken checks, change retry budgets, or edit the trusted validation contract to get green. A tier that is still running has not failed to finish: Forge terminates a hung command at its runner-owned limit, which the receipt reports as timeout_ms (${managedMaximumCommandTimeoutMs / 60_000} minutes for dotnet_affected, ${managedQuickTierTimeoutMs / 60_000} minutes for Unit and Contract, ${managedLongTierTimeoutMs / 60_000} minutes for one shard of another tier, and more for an all-shard run, scaled to its shard waves), and its receipt then reports timed_out. Never stop waiting, or record needs_rework, because a required tier is still running. Record a blocker only when infrastructure is unavailable; when a required check ends with a terminal timed_out, timeout_termination_failed, or runner_error receipt that a rerun cannot clear; when a receipt's elapsed time stops rising across waits; or when a real failure cannot be fixed after diagnosis. Then record the exact blocker and preserve the diff without claiming validation passed.
|
|
696
710
|
5. Inspect the final diff after all fixes and generated-file changes, run git diff --check, and rerun checks affected by any subsequent edit. Record commands, the affected-test selection it printed, exit statuses, and terminal evidence paths in the completion evidence. Finalize changed_files from that final diff, not an earlier repair draft.
|
|
697
711
|
Only after applicable local validation passes, call forge.complete_comment_repair with the exact head, issue key, finding identities, and evidence. Legitimate no-code rejection or already-addressed outcomes are successful dispositions and do not require an empty commit or unrelated test suites; provide evidence for each disposition.
|
|
712
|
+
${providerTurnEndRule("call forge.complete_comment_repair")}
|
|
698
713
|
Forge Bridge owns any commit and compare-and-swap push after its independent pre-publication gate succeeds, then selectively resolves only review threads dispositioned fixed, already_addressed, or server-verified accepted_transfer while all fences still match. The accepted-transfer receipt remains in durable repair evidence and source/target scope; Forge does not post a provider reply automatically. A local pass is not a GitHub CI pass: provider-only checks remain pending until CI runs on the pushed head. Do not request another review yourself; Forge owns the green-CI-before-review sequence.
|
|
699
714
|
Keep the original work item intent intact:
|
|
700
715
|
- Work item: ${dispatch.workItem.id}
|
|
@@ -2,14 +2,17 @@ import fs from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { RepositoryCoordinatorLock } from "../../sandbox/repository-lock.js";
|
|
4
4
|
import { GitClient } from "../../shared/git/git.js";
|
|
5
|
+
import { runtimeAdmissionPriority } from "../../runtime/host-runtime-lease.js";
|
|
6
|
+
import { sandboxHostLoadGateFromEnvironment } from "../sandbox-host-capacity-gate.js";
|
|
5
7
|
import { buildSpecBody, selectLaneCommand } from "../../worktree/artifact-injector.js";
|
|
6
8
|
import { defaultWorktreeCoordinatorStateRoot } from "../../worktree/worktree-paths.js";
|
|
7
9
|
import { completionPhaseFromDispatch, prepareCompletionToolRuntime, readCompletionArtifact, usesDebugCycleCompletion, usesDevelopCycleCompletion } from "../phase-completion.js";
|
|
8
10
|
import { ForgeFailureError } from "../session.types.js";
|
|
9
|
-
import { cleanupCompletionTools, commitWorktreeChanges, completionPhaseFromArtifact, emitArchitectStructuredEvents, emitCompletionArtifactRecorded, emitDecomposeGateArtifacts, emitDraftGateArtifacts, emitPhaseCompletionEvent, emitPhaseGateEvents, emitQaArtifactRecorded, emitQaStructuredEvents, enforceQaBrowserLaunchTargetGate, LiveArchitectArtifactEmitter, LiveCompletionArtifactEmitter, LiveQaArtifactEmitter, readCompletionArtifactsForRun, readQaCompletionArtifactBundle,
|
|
11
|
+
import { cleanupCompletionTools, commitWorktreeChanges, completionPhaseFromArtifact, emitArchitectStructuredEvents, emitCompletionArtifactRecorded, emitDecomposeGateArtifacts, emitDraftGateArtifacts, emitPhaseCompletionEvent, emitPhaseGateEvents, emitQaArtifactRecorded, emitQaStructuredEvents, enforceQaBrowserLaunchTargetGate, LiveArchitectArtifactEmitter, LiveCompletionArtifactEmitter, LiveQaArtifactEmitter, readCompletionArtifactsForRun, readQaCompletionArtifactBundle, waitForCompletionArtifact } from "./provider-cli.artifacts.js";
|
|
12
|
+
import { diffClaimedChangedFiles, findUnpublishedWorktreePaths, normalizeChangedFilePath, stagePublishableWorktreeChangeSet, } from "../publishable-worktree-changes.js";
|
|
10
13
|
import { DeterministicProviderCliService } from "./provider-cli.deterministic.js";
|
|
11
14
|
import { buildArchitectPrompt, buildConflictResolvePrompt, buildDebugCyclePrompt, buildDevelopCyclePrompt, buildDraftPrompt, buildDraftSpec, buildImplementationPrompt, buildProviderCliPrompt, buildProviderCliCommand, durableDraftInput, buildPullRequestCheckRepairPrompt, buildPullRequestCommentsPrompt, buildQaPrompt, formatProviderCliCommandForCheckpoint, isDecomposeDraftDispatch, isPullRequestCheckRepairDispatch, isPullRequestCommentsDispatch } from "./provider-cli.prompts.js";
|
|
12
|
-
import { isTransientCodexProviderNotFoundFailure, recoveringProviderProcessRunner, StreamingProviderProcessRunner } from "./provider-cli.process.js";
|
|
15
|
+
import { isTransientCodexProviderNotFoundFailure, providerCompletionToolMissingFailure, recoveringProviderProcessRunner, StreamingProviderProcessRunner } from "./provider-cli.process.js";
|
|
13
16
|
import { emitProviderUsageEvent, prePublicationValidationEnv, providerProcessEnv } from "./provider-cli.runtime.js";
|
|
14
17
|
import { clip, createProviderOutputState, parseJsonLine } from "./provider-output-state.js";
|
|
15
18
|
import { writeCiRepairReadinessManifest } from "./ci-repair-readiness.js";
|
|
@@ -68,12 +71,54 @@ function assertCommentRepairArtifactMatchesChanges(artifact, actualChangedFiles)
|
|
|
68
71
|
const claimed = [...new Set(claimedChangedFiles)].sort();
|
|
69
72
|
const actual = [...new Set(normalizedActual)].sort();
|
|
70
73
|
if (hasFixedDisposition && actual.length === 0) {
|
|
71
|
-
throw
|
|
74
|
+
throw commentRepairChangedFilesMismatch("Comment repair fixed dispositions require an actual publishable source diff.");
|
|
72
75
|
}
|
|
73
76
|
if (claimed.length !== actual.length || claimed.some((value, index) => value !== actual[index])) {
|
|
74
|
-
|
|
77
|
+
const { missing, unexpected } = diffClaimedChangedFiles(claimed, actual);
|
|
78
|
+
throw commentRepairChangedFilesMismatch(`Comment repair changed_files must exactly match the publishable staged source diff${formatChangedFilesDelta(missing, unexpected)}.`);
|
|
75
79
|
}
|
|
76
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* A finding resolved as fixed must not point at a file whose edit Forge leaves out of the
|
|
83
|
+
* published commit; otherwise the thread would be resolved without its fix. That covers
|
|
84
|
+
* runtime output Forge unstaged and untracked or git-ignored files it never stages.
|
|
85
|
+
*/
|
|
86
|
+
async function assertFixedFindingsArePublished(git, worktreePath, dispatch, artifact, changeSet) {
|
|
87
|
+
const findingPaths = new Map((dispatch.pullRequest?.reviewFindings ?? []).map(finding => [
|
|
88
|
+
`${finding.kind.trim().toLowerCase()}:${finding.claimId}:${finding.bodySha256.trim().toLowerCase()}`,
|
|
89
|
+
finding.path ? normalizeChangedFilePath(finding.path) : "",
|
|
90
|
+
]));
|
|
91
|
+
const payload = JSON.parse(artifact.verdictJson);
|
|
92
|
+
const dispositions = Array.isArray(payload.dispositions) ? payload.dispositions : [];
|
|
93
|
+
const fixed = dispositions.flatMap(value => {
|
|
94
|
+
const record = value;
|
|
95
|
+
if (record.disposition !== "fixed")
|
|
96
|
+
return [];
|
|
97
|
+
const identity = `${String(record.kind ?? "").trim().toLowerCase()}:${String(record.claim_id ?? "")}:${String(record.body_sha256 ?? "").trim().toLowerCase()}`;
|
|
98
|
+
const findingPath = findingPaths.get(identity);
|
|
99
|
+
return findingPath ? [{ claimId: String(record.claim_id ?? ""), path: findingPath }] : [];
|
|
100
|
+
});
|
|
101
|
+
if (fixed.length === 0)
|
|
102
|
+
return;
|
|
103
|
+
const unpublished = new Set([
|
|
104
|
+
...changeSet.excluded.map(normalizeChangedFilePath),
|
|
105
|
+
...await findUnpublishedWorktreePaths(git, worktreePath, fixed.map(entry => entry.path), changeSet.publishable),
|
|
106
|
+
]);
|
|
107
|
+
const dropped = fixed.filter(entry => unpublished.has(entry.path)).map(entry => `${entry.claimId} (${entry.path})`);
|
|
108
|
+
if (dropped.length > 0) {
|
|
109
|
+
throw commentRepairChangedFilesMismatch(`Comment repair marked ${dropped.join(", ")} fixed, but Forge does not publish that file (runtime output, untracked, or git-ignored); Forge did not publish or resolve review findings.`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function commentRepairChangedFilesMismatch(message) {
|
|
113
|
+
return new ForgeFailureError("comment_repair_changed_files_mismatch", message);
|
|
114
|
+
}
|
|
115
|
+
function formatChangedFilesDelta(missing, unexpected) {
|
|
116
|
+
const parts = [
|
|
117
|
+
missing.length > 0 ? `missing from changed_files: ${missing.join(", ")}` : "",
|
|
118
|
+
unexpected.length > 0 ? `not in the publishable diff: ${unexpected.join(", ")}` : "",
|
|
119
|
+
].filter(Boolean);
|
|
120
|
+
return parts.length > 0 ? ` (${parts.join("; ")})` : "";
|
|
121
|
+
}
|
|
77
122
|
async function finalizeCommentRepairChangedFiles(artifact, baselineChangedFiles, actualChangedFiles) {
|
|
78
123
|
const payload = JSON.parse(artifact.verdictJson);
|
|
79
124
|
const claimedRecords = Array.isArray(payload.changed_files)
|
|
@@ -90,11 +135,11 @@ async function finalizeCommentRepairChangedFiles(artifact, baselineChangedFiles,
|
|
|
90
135
|
const dispositions = Array.isArray(payload.dispositions) ? payload.dispositions : [];
|
|
91
136
|
const hasFixedDisposition = dispositions.some(value => value.disposition === "fixed");
|
|
92
137
|
if (hasFixedDisposition && authoritativePaths.length === 0) {
|
|
93
|
-
throw
|
|
138
|
+
throw commentRepairChangedFilesMismatch("Comment repair fixed dispositions require an actual publishable source diff.");
|
|
94
139
|
}
|
|
95
140
|
for (const baselinePath of baselineChangedFiles.map(value => value.trim().replaceAll("\\", "/"))) {
|
|
96
141
|
if (baselinePath && !authoritative.has(baselinePath)) {
|
|
97
|
-
throw
|
|
142
|
+
throw commentRepairChangedFilesMismatch(`Comment repair pre-publication repair removed '${baselinePath}' from the publishable staged source diff.`);
|
|
98
143
|
}
|
|
99
144
|
}
|
|
100
145
|
payload.changed_files = authoritativePaths.map(filePath => {
|
|
@@ -170,16 +215,20 @@ function providerOwnsBranchPublication(context) {
|
|
|
170
215
|
return context.dispatch.sandbox?.executionMode !== "docker";
|
|
171
216
|
}
|
|
172
217
|
function prePublicationExecution(context, environment, defaultRunner, baselineRevision) {
|
|
218
|
+
const hostLoadOwner = {
|
|
219
|
+
dispatchAttemptId: context.dispatch.sandbox?.dispatchAttemptId ?? null,
|
|
220
|
+
priority: runtimeAdmissionPriority(context.dispatch),
|
|
221
|
+
};
|
|
173
222
|
if (context.processRunner)
|
|
174
|
-
return { baselineRevision, environment, processRunner: context.processRunner };
|
|
223
|
+
return { baselineRevision, environment, processRunner: context.processRunner, hostLoadOwner };
|
|
175
224
|
if (context.dispatch.sandbox?.executionMode !== "docker")
|
|
176
|
-
return { baselineRevision, environment };
|
|
225
|
+
return { baselineRevision, environment, hostLoadOwner };
|
|
177
226
|
const expectedSandboxId = context.dispatch.sandbox.dispatchAttemptId;
|
|
178
227
|
const observedSandboxId = context.runtimeEnvironment?.FORGE_SANDBOX_ID ?? process.env.FORGE_SANDBOX_ID;
|
|
179
228
|
if (observedSandboxId !== expectedSandboxId) {
|
|
180
229
|
throw new ForgeFailureError("prepublication_execution_scope_invalid", `prepublication_execution_scope_invalid: Docker attempt ${expectedSandboxId} has no runner proven to execute inside that sandbox.`, "bridge");
|
|
181
230
|
}
|
|
182
|
-
return { baselineRevision, environment, processRunner: defaultRunner };
|
|
231
|
+
return { baselineRevision, environment, processRunner: defaultRunner, hostLoadOwner };
|
|
183
232
|
}
|
|
184
233
|
function remoteTrackingRefspec(branchName) {
|
|
185
234
|
return `refs/heads/${branchName}:refs/remotes/origin/${branchName}`;
|
|
@@ -389,7 +438,8 @@ export class ManagedVerificationProgressEmitter {
|
|
|
389
438
|
}
|
|
390
439
|
}
|
|
391
440
|
function isManagedVerificationNonterminal(status) {
|
|
392
|
-
return status === "starting" || status === "running" || status === "waiting_for_build_slot"
|
|
441
|
+
return status === "starting" || status === "running" || status === "waiting_for_build_slot"
|
|
442
|
+
|| status === "waiting_for_host_capacity";
|
|
393
443
|
}
|
|
394
444
|
async function parseManagedVerificationSnapshot(receiptPath) {
|
|
395
445
|
try {
|
|
@@ -429,10 +479,17 @@ class ProviderToolActivityHeartbeat {
|
|
|
429
479
|
emit;
|
|
430
480
|
intervalMs;
|
|
431
481
|
timer = null;
|
|
482
|
+
/** Lets the provider runner hold its end-of-turn timers while a tool call is in flight. */
|
|
483
|
+
isToolCallInFlight = () => this.outputState.hasActiveToolCall;
|
|
484
|
+
/** Forgets tool calls a previous generation left open; called before every relaunch. */
|
|
485
|
+
startGeneration = () => this.outputState.resetActiveToolCalls();
|
|
432
486
|
constructor(outputState, emit, intervalMs) {
|
|
433
487
|
this.outputState = outputState;
|
|
434
488
|
this.emit = emit;
|
|
435
489
|
this.intervalMs = intervalMs;
|
|
490
|
+
// Each heartbeat watches one provider generation. Calls an earlier generation left
|
|
491
|
+
// open died with it; inheriting them would hold the new generation's timers forever.
|
|
492
|
+
this.outputState.resetActiveToolCalls();
|
|
436
493
|
}
|
|
437
494
|
async consume(line) {
|
|
438
495
|
const events = this.outputState.consume(line);
|
|
@@ -514,7 +571,12 @@ export class ProcessBackedProviderCliService {
|
|
|
514
571
|
providerToolHeartbeatIntervalMs;
|
|
515
572
|
publicationCoordinator;
|
|
516
573
|
prePublicationValidator;
|
|
517
|
-
constructor(processRunner = new StreamingProviderProcessRunner(), git = new GitClient(), providerToolHeartbeatIntervalMs = defaultProviderToolHeartbeatIntervalMs, publicationCoordinator = new RepositoryCoordinatorLock(defaultWorktreeCoordinatorStateRoot()),
|
|
574
|
+
constructor(processRunner = new StreamingProviderProcessRunner(), git = new GitClient(), providerToolHeartbeatIntervalMs = defaultProviderToolHeartbeatIntervalMs, publicationCoordinator = new RepositoryCoordinatorLock(defaultWorktreeCoordinatorStateRoot()),
|
|
575
|
+
// The Docker sandbox worker (`forge` run-once via ForgeBridgeCliService) builds
|
|
576
|
+
// this default. A container cannot reach the host ledger, so when the host
|
|
577
|
+
// bridge enabled it, its steps ask the bridge for tokens over the sandbox
|
|
578
|
+
// channel (decision 0013); elsewhere the gate is absent and validation is ungated.
|
|
579
|
+
prePublicationValidator = new PrePublicationValidator(undefined, undefined, undefined, sandboxHostLoadGateFromEnvironment())) {
|
|
518
580
|
this.processRunner = processRunner;
|
|
519
581
|
this.git = git;
|
|
520
582
|
this.providerToolHeartbeatIntervalMs = providerToolHeartbeatIntervalMs;
|
|
@@ -533,7 +595,7 @@ export class ProcessBackedProviderCliService {
|
|
|
533
595
|
await fs.writeFile(path.join(metadataRoot, "spec.md"), buildDraftSpec(dispatch), "utf8");
|
|
534
596
|
const stagedAttachments = await stageDraftAttachments(dispatch, metadataRoot);
|
|
535
597
|
const decomposeDraft = isDecomposeDraftDispatch(dispatch);
|
|
536
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: decomposeDraft ? "decompose" : "draft", runtimeEnvironment: context.runtimeEnvironment });
|
|
598
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: decomposeDraft ? "decompose" : "draft", runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
537
599
|
const draftPrompt = buildDraftPrompt(dispatch, { attachmentReferences: stagedAttachments.textReferences });
|
|
538
600
|
const providerPrompt = buildProviderCliPrompt(dispatch, draftPrompt, context.runtimeEnvironment);
|
|
539
601
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
@@ -586,6 +648,7 @@ export class ProcessBackedProviderCliService {
|
|
|
586
648
|
args: command.args,
|
|
587
649
|
cwd: worktree.worktreePath,
|
|
588
650
|
env: providerProcessEnv(dispatch, context.runtimeEnvironment),
|
|
651
|
+
resumesProviderThread: Boolean(dispatch.session.resumeProviderThreadId),
|
|
589
652
|
stdin: pipePromptToStdin ? providerPrompt : undefined
|
|
590
653
|
}, {
|
|
591
654
|
onStarted: async () => {
|
|
@@ -596,6 +659,8 @@ export class ProcessBackedProviderCliService {
|
|
|
596
659
|
eventType: "provider_cli_started"
|
|
597
660
|
});
|
|
598
661
|
},
|
|
662
|
+
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
663
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
599
664
|
onStdoutLine: async (line) => {
|
|
600
665
|
await toolHeartbeat.consume(line);
|
|
601
666
|
}
|
|
@@ -645,7 +710,7 @@ export class ProcessBackedProviderCliService {
|
|
|
645
710
|
await emitDecomposeGateArtifacts(context.emit, worktree.worktreePath, dispatch.workItem.id);
|
|
646
711
|
const proposalArtifact = earlyProposalArtifact ?? await readCompletionArtifact(worktree.worktreePath, dispatch.workItem.id, "decompose");
|
|
647
712
|
if (!proposalArtifact) {
|
|
648
|
-
throw
|
|
713
|
+
throw providerCompletionToolMissingFailure("Provider CLI Decompose completed but did not call forge.complete_decompose_proposal.", result);
|
|
649
714
|
}
|
|
650
715
|
const proposal = parseJsonLine(proposalArtifact.verdictJson) ?? {};
|
|
651
716
|
const proposalJson = proposal["proposal_json"] ?? proposal["decomposition_json"];
|
|
@@ -668,7 +733,7 @@ export class ProcessBackedProviderCliService {
|
|
|
668
733
|
await emitDraftGateArtifacts(context.emit, worktree.worktreePath, dispatch.workItem.id);
|
|
669
734
|
const proposalArtifact = earlyProposalArtifact ?? await readCompletionArtifact(worktree.worktreePath, dispatch.workItem.id, "draft");
|
|
670
735
|
if (!proposalArtifact) {
|
|
671
|
-
throw
|
|
736
|
+
throw providerCompletionToolMissingFailure("Provider CLI Draft completed but did not call forge.complete_draft_proposal.", result);
|
|
672
737
|
}
|
|
673
738
|
const proposal = parseJsonLine(proposalArtifact.verdictJson) ?? {};
|
|
674
739
|
const draftJson = proposal["draft_json"];
|
|
@@ -713,7 +778,7 @@ export class ProcessBackedProviderCliService {
|
|
|
713
778
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
714
779
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
715
780
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), JSON.stringify({ schema_version: 1, status: "approved", produced_by: "forge-lane-command" }) + "\n", "utf8");
|
|
716
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase, runtimeEnvironment: context.runtimeEnvironment });
|
|
781
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase, runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
717
782
|
const implementationPrompt = debugCycle
|
|
718
783
|
? buildDebugCyclePrompt(dispatch, phase)
|
|
719
784
|
: developCycle
|
|
@@ -755,6 +820,7 @@ export class ProcessBackedProviderCliService {
|
|
|
755
820
|
args: command.args,
|
|
756
821
|
cwd: worktree.worktreePath,
|
|
757
822
|
env: providerProcessEnv(dispatch, context.runtimeEnvironment),
|
|
823
|
+
resumesProviderThread: Boolean(dispatch.session.resumeProviderThreadId),
|
|
758
824
|
stdin: pipePromptToStdin ? providerPrompt : undefined
|
|
759
825
|
}, {
|
|
760
826
|
onStarted: async () => {
|
|
@@ -765,6 +831,8 @@ export class ProcessBackedProviderCliService {
|
|
|
765
831
|
eventType: "provider_cli_started"
|
|
766
832
|
});
|
|
767
833
|
},
|
|
834
|
+
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
835
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
768
836
|
onStdoutLine: async (line) => {
|
|
769
837
|
await toolHeartbeat.consume(line);
|
|
770
838
|
}
|
|
@@ -806,7 +874,7 @@ export class ProcessBackedProviderCliService {
|
|
|
806
874
|
eventType: "worktree_branch_pushed"
|
|
807
875
|
});
|
|
808
876
|
}
|
|
809
|
-
const completionArtifacts = await readCompletionArtifactsForRun(worktree.worktreePath, dispatch.workItem.id, phase, developCycle, debugCycle);
|
|
877
|
+
const completionArtifacts = await readCompletionArtifactsForRun(worktree.worktreePath, dispatch.workItem.id, phase, developCycle, debugCycle, result);
|
|
810
878
|
for (const artifact of completionArtifacts) {
|
|
811
879
|
if (!liveCompletionEvents.hasEmitted(completionPhaseFromArtifact(artifact))) {
|
|
812
880
|
await emitCompletionArtifactRecorded(context.emit, worktree.worktreePath, artifact);
|
|
@@ -858,7 +926,7 @@ export class ProcessBackedProviderCliService {
|
|
|
858
926
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
859
927
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
860
928
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), JSON.stringify({ schema_version: 1, status: "pending_approval", produced_by: "forge-lane-command" }) + "\n", "utf8");
|
|
861
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "architect", runtimeEnvironment: context.runtimeEnvironment });
|
|
929
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "architect", runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
862
930
|
const architectPrompt = buildArchitectPrompt(dispatch);
|
|
863
931
|
const providerPrompt = buildProviderCliPrompt(dispatch, architectPrompt, context.runtimeEnvironment);
|
|
864
932
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
@@ -893,6 +961,7 @@ export class ProcessBackedProviderCliService {
|
|
|
893
961
|
args: command.args,
|
|
894
962
|
cwd: worktree.worktreePath,
|
|
895
963
|
env: providerProcessEnv(dispatch, context.runtimeEnvironment),
|
|
964
|
+
resumesProviderThread: Boolean(dispatch.session.resumeProviderThreadId),
|
|
896
965
|
stdin: pipePromptToStdin ? providerPrompt : undefined
|
|
897
966
|
}, {
|
|
898
967
|
onStarted: async () => {
|
|
@@ -903,6 +972,8 @@ export class ProcessBackedProviderCliService {
|
|
|
903
972
|
eventType: "provider_cli_started"
|
|
904
973
|
});
|
|
905
974
|
},
|
|
975
|
+
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
976
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
906
977
|
onStdoutLine: async (line) => await toolHeartbeat.consume(line)
|
|
907
978
|
}, context.signal);
|
|
908
979
|
}
|
|
@@ -923,7 +994,7 @@ export class ProcessBackedProviderCliService {
|
|
|
923
994
|
await emitProviderUsageEvent(context.emit, dispatch, outputState);
|
|
924
995
|
const architectArtifact = await readCompletionArtifact(worktree.worktreePath, dispatch.workItem.id, "architect");
|
|
925
996
|
if (!architectArtifact) {
|
|
926
|
-
throw
|
|
997
|
+
throw providerCompletionToolMissingFailure("Provider CLI Architect completed but did not call the Forge Architect completion tool.", result);
|
|
927
998
|
}
|
|
928
999
|
if (!liveArchitectEvents.hasEmitted()) {
|
|
929
1000
|
await emitCompletionArtifactRecorded(context.emit, worktree.worktreePath, architectArtifact);
|
|
@@ -960,7 +1031,7 @@ export class ProcessBackedProviderCliService {
|
|
|
960
1031
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
961
1032
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
962
1033
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), JSON.stringify({ schema_version: 1, status: "approved", produced_by: "forge-lane-command" }) + "\n", "utf8");
|
|
963
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "qa", runtimeEnvironment: context.runtimeEnvironment });
|
|
1034
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "qa", runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
964
1035
|
const qaPrompt = buildQaPrompt(dispatch, specBody);
|
|
965
1036
|
const providerPrompt = buildProviderCliPrompt(dispatch, qaPrompt, context.runtimeEnvironment);
|
|
966
1037
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
@@ -997,6 +1068,7 @@ export class ProcessBackedProviderCliService {
|
|
|
997
1068
|
args: command.args,
|
|
998
1069
|
cwd: worktree.worktreePath,
|
|
999
1070
|
env: providerProcessEnv(dispatch, context.runtimeEnvironment),
|
|
1071
|
+
resumesProviderThread: Boolean(dispatch.session.resumeProviderThreadId),
|
|
1000
1072
|
stdin: pipePromptToStdin ? providerPrompt : undefined
|
|
1001
1073
|
}, {
|
|
1002
1074
|
onStarted: async () => {
|
|
@@ -1007,6 +1079,8 @@ export class ProcessBackedProviderCliService {
|
|
|
1007
1079
|
eventType: "provider_cli_started"
|
|
1008
1080
|
});
|
|
1009
1081
|
},
|
|
1082
|
+
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1083
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
1010
1084
|
onStdoutLine: async (line) => await toolHeartbeat.consume(line)
|
|
1011
1085
|
}, context.signal);
|
|
1012
1086
|
}
|
|
@@ -1026,17 +1100,19 @@ export class ProcessBackedProviderCliService {
|
|
|
1026
1100
|
eventType: "provider_cli_completed"
|
|
1027
1101
|
});
|
|
1028
1102
|
await emitProviderUsageEvent(context.emit, dispatch, outputState);
|
|
1103
|
+
const lastRun = { result };
|
|
1029
1104
|
let qaArtifact = await readQaCompletionArtifactBundle(worktree.worktreePath, dispatch.workItem.id, dispatch.cycleRun.ownerType, dispatch.cycleRun.ownerId);
|
|
1030
1105
|
if (!qaArtifact && !(await readCompletionArtifact(worktree.worktreePath, dispatch.workItem.id, "qa"))) {
|
|
1031
1106
|
// A headless provider that ends its turn to "wait for a background watcher"
|
|
1032
1107
|
// exits for good. Resume the same thread instead of failing the session.
|
|
1033
|
-
qaArtifact = await this.recoverMissingQaCompletion({ context, outputState });
|
|
1108
|
+
qaArtifact = await this.recoverMissingQaCompletion({ context, outputState, lastRun });
|
|
1034
1109
|
}
|
|
1035
1110
|
if (!qaArtifact) {
|
|
1036
1111
|
const verdictOnly = await readCompletionArtifact(worktree.worktreePath, dispatch.workItem.id, "qa");
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1112
|
+
if (verdictOnly) {
|
|
1113
|
+
throw new Error("Provider CLI QA completed but did not produce the complete durable QA artifact bundle.");
|
|
1114
|
+
}
|
|
1115
|
+
throw providerCompletionToolMissingFailure("Provider CLI QA completed but did not call the Forge QA completion tool.", lastRun.result);
|
|
1040
1116
|
}
|
|
1041
1117
|
await enforceQaBrowserLaunchTargetGate(dispatch, qaArtifact);
|
|
1042
1118
|
if (!liveQaEvents.hasEmitted()) {
|
|
@@ -1096,7 +1172,9 @@ export class ProcessBackedProviderCliService {
|
|
|
1096
1172
|
};
|
|
1097
1173
|
const readiness = await writeCiRepairReadinessManifest(dispatch, worktree.worktreePath, specPath, context.runtimeEnvironment);
|
|
1098
1174
|
repairEnvironment = readiness.environment;
|
|
1099
|
-
completionTools = await prepareCompletionToolRuntime({
|
|
1175
|
+
completionTools = await prepareCompletionToolRuntime({
|
|
1176
|
+
dispatch, worktree, phase: "ci_repair", runtimeEnvironment: repairEnvironment, hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1177
|
+
});
|
|
1100
1178
|
await context.emit({
|
|
1101
1179
|
role: "runner",
|
|
1102
1180
|
kind: "checkpoint",
|
|
@@ -1111,7 +1189,9 @@ export class ProcessBackedProviderCliService {
|
|
|
1111
1189
|
});
|
|
1112
1190
|
}
|
|
1113
1191
|
if (addressComments) {
|
|
1114
|
-
completionTools = await prepareCompletionToolRuntime({
|
|
1192
|
+
completionTools = await prepareCompletionToolRuntime({
|
|
1193
|
+
dispatch, worktree, phase: "comment_repair", runtimeEnvironment: repairEnvironment, hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1194
|
+
});
|
|
1115
1195
|
await context.emit({
|
|
1116
1196
|
role: "runner",
|
|
1117
1197
|
kind: "checkpoint",
|
|
@@ -1149,6 +1229,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1149
1229
|
args: command.args,
|
|
1150
1230
|
cwd: worktree.worktreePath,
|
|
1151
1231
|
env: providerProcessEnv(dispatch, repairEnvironment),
|
|
1232
|
+
resumesProviderThread: Boolean(dispatch.session.resumeProviderThreadId),
|
|
1152
1233
|
stdin: pipePromptToStdin ? providerPrompt : undefined
|
|
1153
1234
|
}, {
|
|
1154
1235
|
onStarted: async () => {
|
|
@@ -1160,6 +1241,8 @@ export class ProcessBackedProviderCliService {
|
|
|
1160
1241
|
});
|
|
1161
1242
|
providerStarted = true;
|
|
1162
1243
|
},
|
|
1244
|
+
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1245
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
1163
1246
|
onStdoutLine: async (line) => {
|
|
1164
1247
|
await toolHeartbeat.consume(line);
|
|
1165
1248
|
}
|
|
@@ -1194,7 +1277,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1194
1277
|
if (repairChecks) {
|
|
1195
1278
|
repairArtifact = await readCompletionArtifact(worktree.worktreePath, dispatch.workItem.id, "ci_repair");
|
|
1196
1279
|
if (!repairArtifact) {
|
|
1197
|
-
throw
|
|
1280
|
+
throw providerCompletionToolMissingFailure("Provider CLI completed but did not call forge.complete_ci_repair. Forge did not commit or push the repair.", result);
|
|
1198
1281
|
}
|
|
1199
1282
|
if ((repairArtifact.status ?? "").trim().toLowerCase() !== "pass") {
|
|
1200
1283
|
throw new Error(`CI repair completion gate recorded ${repairArtifact.status}; Forge did not commit or push the repair.`);
|
|
@@ -1202,16 +1285,18 @@ export class ProcessBackedProviderCliService {
|
|
|
1202
1285
|
}
|
|
1203
1286
|
if (addressComments) {
|
|
1204
1287
|
repairArtifact = await readCompletionArtifact(worktree.worktreePath, dispatch.workItem.id, "comment_repair");
|
|
1288
|
+
const lastRun = { result };
|
|
1205
1289
|
if (!repairArtifact) {
|
|
1206
1290
|
repairArtifact = await this.recoverMissingCommentRepairCompletion({
|
|
1207
1291
|
context,
|
|
1208
1292
|
repairEnvironment,
|
|
1209
1293
|
outputState,
|
|
1210
1294
|
preparedHeadSha,
|
|
1295
|
+
lastRun,
|
|
1211
1296
|
});
|
|
1212
1297
|
}
|
|
1213
1298
|
if (!repairArtifact) {
|
|
1214
|
-
throw
|
|
1299
|
+
throw providerCompletionToolMissingFailure("Provider CLI completed but did not call forge.complete_comment_repair. Forge did not publish or resolve review findings.", lastRun.result);
|
|
1215
1300
|
}
|
|
1216
1301
|
if ((repairArtifact.status ?? "").trim().toLowerCase() !== "pass") {
|
|
1217
1302
|
throw new Error(`Comment repair completion gate recorded ${repairArtifact.status}; Forge did not publish or resolve review findings.`);
|
|
@@ -1220,7 +1305,9 @@ export class ProcessBackedProviderCliService {
|
|
|
1220
1305
|
}
|
|
1221
1306
|
let commentRepairBaselineChangedFiles = null;
|
|
1222
1307
|
if (addressComments && repairArtifact) {
|
|
1223
|
-
|
|
1308
|
+
const baseline = await stagePublishableWorktreeChangeSet(this.git, worktree.worktreePath);
|
|
1309
|
+
commentRepairBaselineChangedFiles = baseline.publishable;
|
|
1310
|
+
await assertFixedFindingsArePublished(this.git, worktree.worktreePath, dispatch, repairArtifact, baseline);
|
|
1224
1311
|
assertCommentRepairArtifactMatchesChanges(repairArtifact, commentRepairBaselineChangedFiles);
|
|
1225
1312
|
}
|
|
1226
1313
|
const validationProfile = repairChecks
|
|
@@ -1236,8 +1323,10 @@ export class ProcessBackedProviderCliService {
|
|
|
1236
1323
|
preparedHeadSha,
|
|
1237
1324
|
repairScope: "pull_request",
|
|
1238
1325
|
});
|
|
1239
|
-
const
|
|
1326
|
+
const stagedChangeSet = await stagePublishableWorktreeChangeSet(this.git, worktree.worktreePath);
|
|
1327
|
+
const stagedChangedFiles = stagedChangeSet.publishable;
|
|
1240
1328
|
if (addressComments && repairArtifact && commentRepairBaselineChangedFiles) {
|
|
1329
|
+
await assertFixedFindingsArePublished(this.git, worktree.worktreePath, dispatch, repairArtifact, stagedChangeSet);
|
|
1241
1330
|
repairArtifact = await finalizeCommentRepairChangedFiles(repairArtifact, commentRepairBaselineChangedFiles, stagedChangedFiles);
|
|
1242
1331
|
}
|
|
1243
1332
|
const committed = await commitWorktreeChanges(this.git, worktree.worktreePath, dispatch.workItem.id, stagedChangedFiles);
|
|
@@ -1311,6 +1400,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1311
1400
|
worktree,
|
|
1312
1401
|
phase: "qa",
|
|
1313
1402
|
runtimeEnvironment: context.runtimeEnvironment,
|
|
1403
|
+
hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1314
1404
|
});
|
|
1315
1405
|
const command = buildProviderCliCommand(recoveryDispatch, {
|
|
1316
1406
|
worktreePath: worktree.worktreePath,
|
|
@@ -1334,13 +1424,19 @@ export class ProcessBackedProviderCliService {
|
|
|
1334
1424
|
args: command.args,
|
|
1335
1425
|
cwd: worktree.worktreePath,
|
|
1336
1426
|
env: providerProcessEnv(recoveryDispatch, context.runtimeEnvironment),
|
|
1427
|
+
resumesProviderThread: Boolean(recoveryDispatch.session.resumeProviderThreadId),
|
|
1337
1428
|
stdin: pipePromptToStdin ? providerPrompt : undefined,
|
|
1338
|
-
}, {
|
|
1429
|
+
}, {
|
|
1430
|
+
onStdoutLine: async (line) => await toolHeartbeat.consume(line),
|
|
1431
|
+
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1432
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
1433
|
+
}, context.signal);
|
|
1339
1434
|
}
|
|
1340
1435
|
finally {
|
|
1341
1436
|
toolHeartbeat.stop();
|
|
1342
1437
|
await cleanupCompletionTools(completionTools, context.emit);
|
|
1343
1438
|
}
|
|
1439
|
+
options.lastRun.result = result;
|
|
1344
1440
|
if (result.exitCode !== 0)
|
|
1345
1441
|
throw providerCliExitFailure(command.command, result);
|
|
1346
1442
|
const artifact = await readQaCompletionArtifactBundle(worktree.worktreePath, dispatch.workItem.id, dispatch.cycleRun.ownerType, dispatch.cycleRun.ownerId);
|
|
@@ -1414,6 +1510,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1414
1510
|
worktree,
|
|
1415
1511
|
phase: "comment_repair",
|
|
1416
1512
|
runtimeEnvironment: repairEnvironment,
|
|
1513
|
+
hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1417
1514
|
});
|
|
1418
1515
|
const command = buildProviderCliCommand(recoveryDispatch, {
|
|
1419
1516
|
worktreePath: worktree.worktreePath,
|
|
@@ -1438,6 +1535,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1438
1535
|
args: command.args,
|
|
1439
1536
|
cwd: worktree.worktreePath,
|
|
1440
1537
|
env: providerProcessEnv(recoveryDispatch, repairEnvironment),
|
|
1538
|
+
resumesProviderThread: Boolean(recoveryDispatch.session.resumeProviderThreadId),
|
|
1441
1539
|
stdin: pipePromptToStdin ? providerPrompt : undefined,
|
|
1442
1540
|
}, {
|
|
1443
1541
|
onStarted: async () => {
|
|
@@ -1449,6 +1547,8 @@ export class ProcessBackedProviderCliService {
|
|
|
1449
1547
|
eventType: "provider_cli_started",
|
|
1450
1548
|
});
|
|
1451
1549
|
},
|
|
1550
|
+
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1551
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
1452
1552
|
onStdoutLine: async (line) => {
|
|
1453
1553
|
await toolHeartbeat.consume(line);
|
|
1454
1554
|
},
|
|
@@ -1470,6 +1570,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1470
1570
|
await cleanupCompletionTools(completionTools, context.emit);
|
|
1471
1571
|
}
|
|
1472
1572
|
}
|
|
1573
|
+
options.lastRun.result = result;
|
|
1473
1574
|
if (result.exitCode !== 0)
|
|
1474
1575
|
throw providerCliExitFailure(command.command, result);
|
|
1475
1576
|
const postRecoveryHeadSha = (await this.git.run(worktree.worktreePath, ["rev-parse", "HEAD"])).trim();
|
|
@@ -1555,6 +1656,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1555
1656
|
args: command.args,
|
|
1556
1657
|
cwd: worktree.worktreePath,
|
|
1557
1658
|
env: environment,
|
|
1659
|
+
resumesProviderThread: Boolean(repairDispatch.session.resumeProviderThreadId),
|
|
1558
1660
|
stdin: pipePromptToStdin ? providerPrompt : undefined,
|
|
1559
1661
|
}, {
|
|
1560
1662
|
onStarted: async () => {
|
|
@@ -1566,6 +1668,8 @@ export class ProcessBackedProviderCliService {
|
|
|
1566
1668
|
});
|
|
1567
1669
|
providerStarted = true;
|
|
1568
1670
|
},
|
|
1671
|
+
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1672
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
1569
1673
|
onStdoutLine: async (line) => {
|
|
1570
1674
|
await toolHeartbeat.consume(line);
|
|
1571
1675
|
},
|
|
@@ -5,6 +5,8 @@ export interface ProviderCliRunContext {
|
|
|
5
5
|
readonly dispatch: RunOnceDispatchPacket;
|
|
6
6
|
readonly worktree: WorktreeHandle;
|
|
7
7
|
readonly runtimeEnvironment?: Readonly<Record<string, string>>;
|
|
8
|
+
/** Host load governor variables for the completion MCP server only (decision 0013). */
|
|
9
|
+
readonly hostLoadEnvironment?: Readonly<Record<string, string>>;
|
|
8
10
|
readonly processRunner?: ProviderProcessRunner;
|
|
9
11
|
readonly signal?: AbortSignal;
|
|
10
12
|
emit(event: RunnerDispatchEvent): Promise<void>;
|
|
@@ -13,6 +15,8 @@ export interface ProviderCliDraftContext {
|
|
|
13
15
|
readonly dispatch: RunOnceDispatchPacket;
|
|
14
16
|
readonly worktree: WorktreeHandle;
|
|
15
17
|
readonly runtimeEnvironment?: Readonly<Record<string, string>>;
|
|
18
|
+
/** Host load governor variables for the completion MCP server only (decision 0013). */
|
|
19
|
+
readonly hostLoadEnvironment?: Readonly<Record<string, string>>;
|
|
16
20
|
readonly processRunner?: ProviderProcessRunner;
|
|
17
21
|
readonly signal?: AbortSignal;
|
|
18
22
|
emit(event: RunnerDispatchEvent): Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True while an attempt-owned managed command (a receipt under
|
|
3
|
+
* `<FORGE_LOG_DIR>/managed-commands/`) is still starting, queued or running.
|
|
4
|
+
* Unreadable or stale receipts do not count.
|
|
5
|
+
*/
|
|
6
|
+
export declare function hasNonterminalManagedCommand(logDirectory: string | undefined, nowMs?: number): Promise<boolean>;
|