@loucompanion/forge-bridge 0.1.4-dev.f22f5e3d01fe → 0.2.1-dev.0f07274d438b
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 +128 -4
- package/dist/bridge/bridge-chat-giphy-look.d.ts +48 -0
- package/dist/bridge/bridge-chat-giphy-look.js +55 -0
- package/dist/bridge/bridge-chat-provider-command.d.ts +27 -3
- package/dist/bridge/bridge-chat-provider-command.js +131 -26
- package/dist/bridge/bridge-chat.types.d.ts +20 -0
- package/dist/bridge/bridge-chat.types.js +28 -1
- package/dist/bridge/bridge-state-file.d.ts +161 -0
- package/dist/bridge/bridge-state-file.js +376 -0
- package/dist/bridge/bridge-state-io.d.ts +15 -0
- package/dist/bridge/bridge-state-io.js +68 -0
- package/dist/bridge/bridge-state-lock.d.ts +11 -0
- package/dist/bridge/bridge-state-lock.js +102 -0
- package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
- package/dist/bridge/bridge-state-unpublished.js +111 -0
- package/dist/bridge/bridge.service.d.ts +29 -12
- package/dist/bridge/bridge.service.js +215 -380
- package/dist/bridge/bridge.types.d.ts +21 -0
- package/dist/bridge/bridge.types.js +2 -1
- package/dist/bridge/default-session-service.d.ts +13 -0
- package/dist/bridge/default-session-service.js +22 -0
- package/dist/bridge/dispatch-offer-policy.d.ts +22 -0
- package/dist/bridge/dispatch-offer-policy.js +58 -0
- package/dist/bridge/in-flight-registry.d.ts +62 -0
- package/dist/bridge/in-flight-registry.js +207 -0
- package/dist/bridge/readiness-result-outbox.d.ts +5 -1
- package/dist/bridge/readiness-result-outbox.js +20 -0
- package/dist/bridge/runner-host-capabilities.js +14 -1
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -0
- package/dist/bridge/windows-bash-resolution.d.ts +31 -0
- package/dist/bridge/windows-bash-resolution.js +153 -0
- package/dist/cleanup/cleanup-wip.d.ts +12 -0
- package/dist/cleanup/cleanup-wip.js +66 -0
- package/dist/cleanup/cleanup.service.d.ts +11 -1
- package/dist/cleanup/cleanup.service.js +80 -62
- package/dist/cleanup/cleanup.types.d.ts +2 -0
- package/dist/cleanup/forge-owned-paths.d.ts +2 -0
- package/dist/cleanup/forge-owned-paths.js +9 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +2 -0
- package/dist/cleanup/host-runtime-ledger.js +30 -9
- package/dist/cli/cli.help.js +57 -13
- package/dist/cli/cli.service.d.ts +3 -10
- package/dist/cli/cli.service.js +20 -213
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +14 -1
- package/dist/cli/local-config.js +42 -2
- package/dist/cli/provider-cli-advertising.d.ts +24 -0
- package/dist/cli/provider-cli-advertising.js +88 -0
- package/dist/cli/provider-cli-detection.d.ts +10 -0
- package/dist/cli/provider-cli-detection.js +160 -0
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +20 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +104 -26
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/attempt-node-runtime-launcher.d.ts +36 -0
- package/dist/runtime/attempt-node-runtime-launcher.js +169 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +2 -0
- package/dist/runtime/attempt-process-supervisor.js +12 -6
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -0
- package/dist/runtime/dotnet-build-outputs.d.ts +107 -0
- package/dist/runtime/dotnet-build-outputs.js +402 -0
- package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
- package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
- package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
- package/dist/runtime/ephemeral-test-postgres.js +303 -0
- package/dist/runtime/host-listener-inspector.d.ts +26 -0
- package/dist/runtime/host-listener-inspector.js +84 -3
- package/dist/runtime/host-load-admission.d.ts +5 -0
- package/dist/runtime/host-load-capacity.d.ts +198 -0
- package/dist/runtime/host-load-capacity.js +353 -0
- package/dist/runtime/host-load-child-environment.d.ts +13 -0
- package/dist/runtime/host-load-child-environment.js +35 -1
- package/dist/runtime/host-load-governor-config.d.ts +33 -3
- package/dist/runtime/host-load-governor-config.js +24 -3
- package/dist/runtime/host-load-governor.d.ts +91 -2
- package/dist/runtime/host-load-governor.js +217 -18
- package/dist/runtime/host-load-ledger-lock.js +6 -4
- package/dist/runtime/host-load-live-test-slots.d.ts +61 -0
- package/dist/runtime/host-load-live-test-slots.js +193 -0
- package/dist/runtime/host-load-runtime-settings.js +4 -2
- package/dist/runtime/host-load-sampler.d.ts +25 -1
- package/dist/runtime/host-load-sampler.js +38 -7
- package/dist/runtime/host-load-step-run.d.ts +37 -3
- package/dist/runtime/host-load-step-run.js +63 -7
- package/dist/runtime/host-load-test-slot.d.ts +3 -0
- package/dist/runtime/host-load-test-slot.js +26 -7
- package/dist/runtime/host-runtime-contract.d.ts +12 -0
- package/dist/runtime/host-runtime-contract.js +35 -5
- package/dist/runtime/host-runtime-lease.d.ts +28 -3
- package/dist/runtime/host-runtime-lease.js +140 -296
- package/dist/runtime/host-runtime-ledger-recovery.d.ts +20 -0
- package/dist/runtime/host-runtime-ledger-recovery.js +134 -0
- package/dist/runtime/host-runtime-promotion.d.ts +78 -2
- package/dist/runtime/host-runtime-promotion.js +307 -14
- package/dist/runtime/managed-command-teardown.js +5 -16
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/runtime/prepared-runtime-identity.d.ts +4 -0
- package/dist/runtime/prepared-runtime-identity.js +130 -9
- package/dist/runtime/prepared-runtime-readiness.d.ts +23 -1
- package/dist/runtime/prepared-runtime-readiness.js +89 -18
- package/dist/runtime/runner-settings.d.ts +4 -0
- package/dist/runtime/runner-settings.js +22 -0
- package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
- package/dist/runtime/supervised-runtime-build-guard.js +112 -0
- package/dist/sandbox/host-capacity-broker.d.ts +3 -1
- package/dist/sandbox/host-capacity-broker.js +4 -2
- package/dist/sandbox/managed-branch.d.ts +13 -0
- package/dist/sandbox/managed-branch.js +90 -0
- package/dist/sandbox/provider-auth/codex.js +11 -11
- package/dist/sandbox/runtime.d.ts +1 -2
- package/dist/sandbox/runtime.js +9 -19
- package/dist/sandbox/sandbox-input.d.ts +22 -0
- package/dist/sandbox/sandbox-input.js +49 -0
- package/dist/sandbox/workspace.service.js +15 -2
- package/dist/session/managed-attempt-tools.d.ts +0 -7
- package/dist/session/managed-attempt-tools.js +54 -109
- package/dist/session/managed-build-coordinator.d.ts +16 -0
- package/dist/session/managed-build-coordinator.js +10 -0
- package/dist/session/managed-build-receipt.d.ts +7 -0
- package/dist/session/managed-build-receipt.js +11 -3
- package/dist/session/managed-command-environment.d.ts +8 -0
- package/dist/session/managed-command-environment.js +28 -0
- package/dist/session/managed-command-host-load.d.ts +10 -5
- package/dist/session/managed-command-host-load.js +18 -14
- package/dist/session/phase-completion.artifact-bundle.d.ts +20 -0
- package/dist/session/phase-completion.artifact-bundle.js +167 -0
- package/dist/session/phase-completion.artifacts.d.ts +2 -17
- package/dist/session/phase-completion.artifacts.js +65 -166
- package/dist/session/phase-completion.d.ts +27 -2
- package/dist/session/phase-completion.helpers.js +5 -53
- package/dist/session/phase-completion.js +15 -32
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +195 -0
- package/dist/session/phase-completion.phase-aliases.d.ts +5 -0
- package/dist/session/phase-completion.phase-aliases.js +43 -0
- package/dist/session/phase-completion.pr-review-schema.d.ts +1 -0
- package/dist/session/phase-completion.pr-review-schema.js +75 -0
- package/dist/session/phase-completion.pr-review-validation.d.ts +11 -0
- package/dist/session/phase-completion.pr-review-validation.js +212 -0
- package/dist/session/phase-completion.pr-review.d.ts +36 -0
- package/dist/session/phase-completion.pr-review.js +294 -0
- package/dist/session/phase-completion.prompts.d.ts +1 -1
- package/dist/session/phase-completion.prompts.js +14 -0
- package/dist/session/phase-completion.runtime.d.ts +8 -9
- package/dist/session/phase-completion.runtime.js +65 -196
- package/dist/session/phase-completion.schemas.js +12 -2
- package/dist/session/phase-completion.validation.d.ts +1 -0
- package/dist/session/phase-completion.validation.js +9 -1
- package/dist/session/pr-review-diff-base.d.ts +18 -0
- package/dist/session/pr-review-diff-base.js +44 -0
- package/dist/session/pr-review-placement.d.ts +50 -0
- package/dist/session/pr-review-placement.js +91 -0
- package/dist/session/pre-publication-change-set.d.ts +62 -0
- package/dist/session/pre-publication-change-set.js +166 -0
- package/dist/session/pre-publication-host-load.js +6 -5
- package/dist/session/pre-publication-native-postgres.d.ts +30 -0
- package/dist/session/pre-publication-native-postgres.js +111 -0
- package/dist/session/pre-publication-process.js +13 -12
- package/dist/session/pre-publication-step-execution.d.ts +2 -1
- package/dist/session/pre-publication-step-execution.js +6 -5
- package/dist/session/pre-publication-validation.d.ts +9 -4
- package/dist/session/pre-publication-validation.js +62 -65
- package/dist/session/provider-cli/claude-background-work.d.ts +3 -2
- package/dist/session/provider-cli/claude-background-work.js +4 -3
- package/dist/session/provider-cli/dispatch-target-branch.d.ts +7 -0
- package/dist/session/provider-cli/dispatch-target-branch.js +8 -0
- package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
- package/dist/session/provider-cli/host-build-lock.js +30 -0
- package/dist/session/provider-cli/pr-review-credential-isolation.d.ts +83 -0
- package/dist/session/provider-cli/pr-review-credential-isolation.js +144 -0
- package/dist/session/provider-cli/pr-review-guardrails.d.ts +70 -0
- package/dist/session/provider-cli/pr-review-guardrails.js +360 -0
- package/dist/session/provider-cli/pr-review-prompt.d.ts +2 -0
- package/dist/session/provider-cli/pr-review-prompt.js +119 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +16 -0
- package/dist/session/provider-cli/pre-publication-repair.js +41 -3
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +4 -2
- package/dist/session/provider-cli/provider-cli.deterministic.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.deterministic.js +5 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +6 -3
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +29 -10
- package/dist/session/provider-cli/provider-cli.pr-review.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.pr-review.js +213 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +2 -14
- package/dist/session/provider-cli/provider-cli.process.js +4 -94
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +13 -3
- package/dist/session/provider-cli/provider-cli.prompts.js +137 -84
- package/dist/session/provider-cli/provider-cli.reapply-conflicts.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.reapply-conflicts.js +37 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +15 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +37 -2
- package/dist/session/provider-cli/provider-cli.service-support.d.ts +37 -0
- package/dist/session/provider-cli/provider-cli.service-support.js +146 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +15 -18
- package/dist/session/provider-cli/provider-cli.service.js +59 -190
- package/dist/session/provider-cli/provider-cli.types.d.ts +7 -2
- package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
- package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
- package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
- package/dist/session/qa-sidecar-validation.d.ts +6 -0
- package/dist/session/qa-sidecar-validation.js +28 -0
- package/dist/session/sandbox-host-capacity-gate.d.ts +22 -1
- package/dist/session/sandbox-host-capacity-gate.js +63 -22
- package/dist/session/session-host-project.d.ts +22 -0
- package/dist/session/session-host-project.js +98 -0
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.parse-helpers.d.ts +10 -0
- package/dist/session/session.parse-helpers.js +84 -0
- package/dist/session/session.runtime-refresh.d.ts +46 -0
- package/dist/session/session.runtime-refresh.js +116 -0
- package/dist/session/session.service.d.ts +8 -1
- package/dist/session/session.service.js +177 -239
- package/dist/session/session.types.d.ts +5 -0
- package/dist/session/session.types.js +9 -79
- package/dist/session/session.types.pr-review.d.ts +48 -0
- package/dist/session/session.types.pr-review.js +51 -0
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/shared/fs/file-identity.d.ts +10 -0
- package/dist/shared/fs/file-identity.js +15 -0
- package/dist/shared/fs/replace-file.d.ts +7 -0
- package/dist/shared/fs/replace-file.js +33 -0
- package/dist/shared/process/host-process-recovery.d.ts +14 -3
- package/dist/shared/process/host-process-recovery.js +23 -3
- package/dist/shared/process/host-process-supervisor.d.ts +13 -1
- package/dist/shared/process/host-process-supervisor.js +66 -14
- package/dist/shared/provider-capabilities.d.ts +2 -0
- package/dist/shared/provider-capabilities.js +18 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.js +24 -0
- package/dist/worktree/orphan-relink.d.ts +19 -0
- package/dist/worktree/orphan-relink.js +106 -0
- package/dist/worktree/wip-git.d.ts +58 -0
- package/dist/worktree/wip-git.js +182 -0
- package/dist/worktree/wip-refs.d.ts +85 -0
- package/dist/worktree/wip-refs.js +169 -0
- package/dist/worktree/wip-restore.d.ts +51 -0
- package/dist/worktree/wip-restore.js +324 -0
- package/dist/worktree/wip-snapshot.d.ts +53 -0
- package/dist/worktree/wip-snapshot.js +270 -0
- package/dist/worktree/worktree-inputs.d.ts +8 -0
- package/dist/worktree/worktree-inputs.js +134 -0
- package/dist/worktree/worktree-origin-sync.d.ts +35 -0
- package/dist/worktree/worktree-origin-sync.js +128 -0
- package/dist/worktree/worktree-wip-events.d.ts +20 -0
- package/dist/worktree/worktree-wip-events.js +148 -0
- package/dist/worktree/worktree-wip.d.ts +57 -0
- package/dist/worktree/worktree-wip.js +200 -0
- package/dist/worktree/worktree.base.d.ts +7 -1
- package/dist/worktree/worktree.service.d.ts +49 -5
- package/dist/worktree/worktree.service.js +223 -187
- package/dist/worktree/worktree.types.d.ts +47 -0
- package/package.json +1 -1
- package/runtime/windows-listener-owner.ps1 +12 -1
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
// forge-bridge run-once's review placement guard (pr-review-placement.ts).
|
|
2
|
+
export { runOnceWithReviewPlacement } from "./pr-review-placement.js";
|
|
1
3
|
import { redactRunnerDispatchEvent, redactRunOnceResultPacket } from "./session-redaction.js";
|
|
2
4
|
import { randomUUID } from "node:crypto";
|
|
3
5
|
import { RoutingProviderCliService } from "./provider-cli/provider-cli.service.js";
|
|
4
6
|
import { ForgeFailureError, waitKindForEvent, waitWakeCondition } from "./session.types.js";
|
|
5
|
-
import { GitWorktreeService } from "../worktree/worktree.service.js";
|
|
7
|
+
import { emitWorktreePreparedEvents, GitWorktreeService, sessionWipOutcome, settleWorktree, } from "../worktree/worktree.service.js";
|
|
6
8
|
import { SandboxWorkspaceService } from "../sandbox/workspace.service.js";
|
|
7
9
|
import { HostRuntimeAdmissionExpiredError, hostRuntimeEventResources, hostRuntimeStackEnvironmentKeys, runtimeAdmissionPriority, } from "../runtime/host-runtime-lease.js";
|
|
8
10
|
import { configuredLaunchPortNames, hostRuntimeContractFingerprint, hostRuntimeParallelEligible, } from "../runtime/host-runtime-promotion.js";
|
|
9
|
-
import {
|
|
11
|
+
import { managedQaLaunchTarget, startOrDeferConfiguredProject, withMaterializedManagedQaTarget, } from "./session-host-project.js";
|
|
12
|
+
import { createConfiguredRuntimeRefresh, readWorkspaceRuntimeFingerprint, } from "./session.runtime-refresh.js";
|
|
10
13
|
const minimumReadinessProbeStartupBudgetMs = 150_000;
|
|
11
14
|
export class BridgeSessionService {
|
|
12
15
|
worktrees;
|
|
@@ -77,7 +80,7 @@ export class BridgeSessionService {
|
|
|
77
80
|
signal,
|
|
78
81
|
});
|
|
79
82
|
assertReadinessProbeStartupBudget(request.expiresAt);
|
|
80
|
-
|
|
83
|
+
const started = await this.hostRuntime.start(dispatch, worktree.worktreePath, signal);
|
|
81
84
|
runtimeStarted = true;
|
|
82
85
|
const discovery = started.runtimeContract.discovery;
|
|
83
86
|
if (!hostRuntimeParallelEligible(started.runtimeContract)) {
|
|
@@ -92,23 +95,7 @@ export class BridgeSessionService {
|
|
|
92
95
|
};
|
|
93
96
|
}
|
|
94
97
|
else {
|
|
95
|
-
|
|
96
|
-
started = await this.hostRuntime.startConfiguredProject(request.requestId, request.fencingToken, signal);
|
|
97
|
-
const requiredPorts = configuredLaunchPortNames(started.runtimeContract);
|
|
98
|
-
const verifiedPorts = started.lease.resources.ports.map(port => port.name);
|
|
99
|
-
const verified = requiredPorts.length > 0 && requiredPorts.every(name => verifiedPorts.includes(name));
|
|
100
|
-
result = verified
|
|
101
|
-
? {
|
|
102
|
-
status: "parallel_ready",
|
|
103
|
-
runtimeContractFingerprint: hostRuntimeContractFingerprint(started.runtimeContract),
|
|
104
|
-
runtimeContractSource: started.runtimeContract.source,
|
|
105
|
-
runtimeRequirements: started.runtimeContract.contract.requires ?? null,
|
|
106
|
-
reasonCode: null,
|
|
107
|
-
reasonMessage: null,
|
|
108
|
-
qaAppLaunchTarget: managedQaLaunchTarget(started.runtimeContract),
|
|
109
|
-
checkedAt: new Date().toISOString(),
|
|
110
|
-
}
|
|
111
|
-
: failedProbe("host_runtime_probe_unverified", "The application did not prove ownership and readiness on every Forge-assigned port.");
|
|
98
|
+
result = await this.probeConfiguredProject(this.hostRuntime, request, started, signal);
|
|
112
99
|
}
|
|
113
100
|
}
|
|
114
101
|
catch (error) {
|
|
@@ -190,6 +177,7 @@ export class BridgeSessionService {
|
|
|
190
177
|
let worktree = null;
|
|
191
178
|
let hostSingletonKeys = null;
|
|
192
179
|
let hostLease = null;
|
|
180
|
+
let succeeded = false;
|
|
193
181
|
try {
|
|
194
182
|
if (dispatch.sandbox?.executionMode === "host" && this.hostRuntime) {
|
|
195
183
|
const capacity = this.hostRuntime.snapshot?.() ?? null;
|
|
@@ -265,10 +253,10 @@ export class BridgeSessionService {
|
|
|
265
253
|
warmPathOverrides: dispatch.warmPathOverrides,
|
|
266
254
|
applicationRuntimeRequired: dispatch.runtimeIntent.applicationRuntimeRequired,
|
|
267
255
|
preserveExistingState: Boolean(dispatch.session.resumedFromSessionId),
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
256
|
+
// A review reads the exact pull request head, detached; it never works on a lease branch.
|
|
257
|
+
detachedHeadSha: prReviewHeadSha(dispatch),
|
|
258
|
+
sessionId: dispatch.session.id,
|
|
259
|
+
...preparedAttemptOwner(dispatch),
|
|
272
260
|
signal,
|
|
273
261
|
});
|
|
274
262
|
}
|
|
@@ -285,6 +273,7 @@ export class BridgeSessionService {
|
|
|
285
273
|
: `Prepared worktree ${worktree.branchName}.`,
|
|
286
274
|
eventType: dispatch.session.resumedFromSessionId ? "worktree_reattached" : "worktree_prepared"
|
|
287
275
|
});
|
|
276
|
+
await emitWorktreePreparedEvents(worktree, emit);
|
|
288
277
|
if ((worktree.hydratedPriorPhaseArtifactCount ?? 0) > 0) {
|
|
289
278
|
await emit({
|
|
290
279
|
role: "runner",
|
|
@@ -296,6 +285,10 @@ export class BridgeSessionService {
|
|
|
296
285
|
if (worktree.dependencyWarm) {
|
|
297
286
|
await emitDependencyWarmEvents(worktree.dependencyWarm, emit);
|
|
298
287
|
}
|
|
288
|
+
// Conflicts a WIP re-apply left for the agent (deferredProjectStartEvent): the project stack
|
|
289
|
+
// is not started on them, and the prompt names them.
|
|
290
|
+
const reapplyConflicts = worktree.reapplyConflicts;
|
|
291
|
+
let projectStartDeferred = false;
|
|
299
292
|
if (dispatch.sandbox?.executionMode === "host" && this.hostRuntime) {
|
|
300
293
|
hostLease = await this.hostRuntime.start(dispatch, worktree.worktreePath, signal, async (checkpoint) => {
|
|
301
294
|
const observation = waitObservation(checkpoint.code);
|
|
@@ -326,114 +319,25 @@ export class BridgeSessionService {
|
|
|
326
319
|
remediation: "Enable Run in Docker in Project Settings.",
|
|
327
320
|
}),
|
|
328
321
|
});
|
|
329
|
-
|
|
330
|
-
hostLease = await this.hostRuntime.startConfiguredProject(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken, signal, async (checkpoint) => {
|
|
331
|
-
await emitLifecycle({
|
|
332
|
-
role: "runner",
|
|
333
|
-
kind: "checkpoint",
|
|
334
|
-
content: checkpoint.message,
|
|
335
|
-
eventType: checkpoint.code,
|
|
336
|
-
data: checkpoint.data ? JSON.stringify(checkpoint.data) : undefined,
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
if (hostLease.lease.resources.ports.length > unconfiguredPortCount) {
|
|
340
|
-
const assigned = hostLease.lease.resources.ports.at(-1);
|
|
341
|
-
await emitLifecycle({
|
|
342
|
-
role: "runner",
|
|
343
|
-
kind: "checkpoint",
|
|
344
|
-
content: `Verified supervised project runtime ${assigned.name} on ${assigned.hostIp}:${assigned.hostPort}.`,
|
|
345
|
-
eventType: "host_runtime_project_ready",
|
|
346
|
-
data: JSON.stringify(hostRuntimeEventResources(hostLease.lease, hostLease.runtimeContract, hostLease.executionClass)),
|
|
347
|
-
});
|
|
348
|
-
}
|
|
322
|
+
({ hostLease, deferred: projectStartDeferred } = await startOrDeferConfiguredProject(this.hostRuntime, hostLease, dispatch, reapplyConflicts, signal, emitLifecycle));
|
|
349
323
|
}
|
|
350
324
|
// The stack was built and launched from this workspace state. Pre-publication
|
|
351
325
|
// validation restarts it when the provider has changed the source since.
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
.catch(() => null);
|
|
363
|
-
// Set while the stack may not match the workspace: a failed restart is retried on the next pass.
|
|
364
|
-
let restartPending = false;
|
|
365
|
-
refreshRuntimeEnvironment = async (refreshSignal) => {
|
|
366
|
-
const current = await this.workspaceFingerprint(worktreePath).catch(() => null);
|
|
367
|
-
if (!restartPending && sameWorkspaceRuntimeFingerprint(launchFingerprint, current))
|
|
368
|
-
return null;
|
|
369
|
-
// Every cause that applies is reported; `reason` is the first of them. Changes are named
|
|
370
|
-
// only when both states were read: an unreadable baseline is not a workspace change.
|
|
371
|
-
const comparable = launchFingerprint !== null && current !== null;
|
|
372
|
-
const changes = comparable ? workspaceRuntimeFingerprintChanges(launchFingerprint, current) : [];
|
|
373
|
-
const causes = [
|
|
374
|
-
...(restartPending ? ["previous_restart_incomplete"] : []),
|
|
375
|
-
...(comparable ? [] : ["fingerprint_unavailable"]),
|
|
376
|
-
...(changes.length > 0 ? ["workspace_changed"] : []),
|
|
377
|
-
];
|
|
378
|
-
const reason = causes[0] ?? "workspace_changed";
|
|
379
|
-
const changeText = changes.length > 0 ? ` The workspace also changed since launch (${changes.join(", ")}).` : "";
|
|
380
|
-
await emitLifecycle({
|
|
381
|
-
role: "runner",
|
|
382
|
-
kind: "checkpoint",
|
|
383
|
-
content: reason === "workspace_changed"
|
|
384
|
-
? `The workspace changed since the attempt runtime stack was launched (${changes.join(", ")}); restarting it so validation runs against the current source.`
|
|
385
|
-
: reason === "previous_restart_incomplete"
|
|
386
|
-
? `The previous attempt runtime restart did not complete; restarting it again so validation runs against the current source.${changeText}`
|
|
387
|
-
: `The workspace state could not be compared with the attempt runtime stack; restarting it so validation runs against the current source.`,
|
|
388
|
-
eventType: "host_runtime_restart_started",
|
|
389
|
-
data: JSON.stringify({
|
|
390
|
-
reason,
|
|
391
|
-
causes,
|
|
392
|
-
changes,
|
|
393
|
-
head_sha: current?.headSha ?? null,
|
|
394
|
-
merge_in_progress: Boolean(current?.mergeHead),
|
|
395
|
-
}),
|
|
396
|
-
});
|
|
397
|
-
restartPending = true;
|
|
398
|
-
let restarted;
|
|
399
|
-
try {
|
|
400
|
-
restarted = await restartConfiguredProject(dispatchAttemptId, fencingToken, refreshSignal ?? signal, async (checkpoint) => {
|
|
401
|
-
await emitLifecycle({
|
|
402
|
-
role: "runner",
|
|
403
|
-
kind: "checkpoint",
|
|
404
|
-
content: checkpoint.message,
|
|
405
|
-
eventType: checkpoint.code,
|
|
406
|
-
data: checkpoint.data ? JSON.stringify(checkpoint.data) : undefined,
|
|
407
|
-
});
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
catch (error) {
|
|
411
|
-
await emitLifecycle({
|
|
412
|
-
role: "runner",
|
|
413
|
-
kind: "error",
|
|
414
|
-
content: `Restarting the attempt runtime stack failed: ${failureMessage(error)}`,
|
|
415
|
-
eventType: "host_runtime_restart_failed",
|
|
416
|
-
data: JSON.stringify({ reason, causes, changes }),
|
|
417
|
-
}).catch(() => undefined);
|
|
418
|
-
throw error;
|
|
419
|
-
}
|
|
326
|
+
const refreshRuntimeEnvironment = await createConfiguredRuntimeRefresh({
|
|
327
|
+
hostLease,
|
|
328
|
+
dispatch,
|
|
329
|
+
hostRuntime: this.hostRuntime,
|
|
330
|
+
worktreePath: worktree.worktreePath,
|
|
331
|
+
readFingerprint: this.workspaceFingerprint,
|
|
332
|
+
emitLifecycle,
|
|
333
|
+
signal,
|
|
334
|
+
assertRunning: () => this.throwIfAbortedOrIsolationViolated(undefined, dispatch, hostLease),
|
|
335
|
+
onRestarted: restarted => {
|
|
420
336
|
hostLease = restarted;
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
restartPending = false;
|
|
426
|
-
await emitLifecycle({
|
|
427
|
-
role: "runner",
|
|
428
|
-
kind: "checkpoint",
|
|
429
|
-
content: `Restarted the supervised project runtime on ${restarted.lease.resources.ports.map(port => `${port.name} ${port.hostIp}:${port.hostPort}`).join(", ") || "no ports"}.`,
|
|
430
|
-
eventType: "host_runtime_restarted",
|
|
431
|
-
data: JSON.stringify(hostRuntimeEventResources(restarted.lease, restarted.runtimeContract, restarted.executionClass)),
|
|
432
|
-
});
|
|
433
|
-
return { environment: restarted.environment, reason, changes };
|
|
434
|
-
};
|
|
435
|
-
}
|
|
436
|
-
providerDispatch = withMaterializedManagedQaTarget(providerDispatch, hostLease);
|
|
337
|
+
},
|
|
338
|
+
startDeferred: projectStartDeferred
|
|
339
|
+
});
|
|
340
|
+
providerDispatch = withMaterializedManagedQaTarget(providerDispatch, hostLease, projectStartDeferred);
|
|
437
341
|
const providerEnvironment = {
|
|
438
342
|
runtimeEnvironment: hostLease?.environment,
|
|
439
343
|
// Only the completion MCP server gets these: its managed commands share the host ledger.
|
|
@@ -452,17 +356,18 @@ export class BridgeSessionService {
|
|
|
452
356
|
emit,
|
|
453
357
|
signal
|
|
454
358
|
});
|
|
455
|
-
|
|
359
|
+
this.throwIfAbortedOrIsolationViolated(signal, dispatch, hostLease);
|
|
456
360
|
const draftArtifacts = run.artifacts?.length ? run.artifacts : run.artifact ? [run.artifact] : [];
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
exitCode: 0,
|
|
460
|
-
summary: run.summary,
|
|
361
|
+
// Redaction can throw (a secret in a structural field); only a returned result is a success.
|
|
362
|
+
const draftResult = redactRunOnceResultPacket({
|
|
363
|
+
schemaVersion: 2, exitCode: 0, summary: run.summary,
|
|
461
364
|
events,
|
|
462
365
|
spec: run.spec ?? null,
|
|
463
366
|
artifact: run.artifact ?? null,
|
|
464
367
|
artifacts: draftArtifacts
|
|
465
368
|
}, redactionSecrets);
|
|
369
|
+
succeeded = true;
|
|
370
|
+
return draftResult;
|
|
466
371
|
}
|
|
467
372
|
throwIfAborted(signal);
|
|
468
373
|
const lane = dispatch.execution.lane.trim().toLowerCase();
|
|
@@ -472,6 +377,7 @@ export class BridgeSessionService {
|
|
|
472
377
|
const isArchitect = role === "architect" || lane === "architect" || cycleKind === "architect";
|
|
473
378
|
const isCiRepair = role === "ci_repair" || lane === "ci_repair" || cycleKind === "pr_checks";
|
|
474
379
|
const isConflictResolve = role === "conflict_resolve" || lane === "conflict_resolve";
|
|
380
|
+
const isPrReview = role === "pr_review" || lane === "pr_review" || cycleKind === "pr_review";
|
|
475
381
|
const context = {
|
|
476
382
|
dispatch: providerDispatch,
|
|
477
383
|
worktree,
|
|
@@ -482,20 +388,24 @@ export class BridgeSessionService {
|
|
|
482
388
|
...(refreshRuntimeEnvironment && hostLease
|
|
483
389
|
? { refreshRuntimeEnvironment, runtimeStackEnvironmentKeys: hostRuntimeStackEnvironmentKeys(hostLease.runtimeContract) }
|
|
484
390
|
: {}),
|
|
391
|
+
reapplyConflicts,
|
|
392
|
+
projectStartDeferred,
|
|
485
393
|
emit,
|
|
486
394
|
signal
|
|
487
395
|
};
|
|
488
396
|
let run;
|
|
489
397
|
try {
|
|
490
|
-
run =
|
|
491
|
-
? await this.providerCli.
|
|
492
|
-
:
|
|
493
|
-
? await this.providerCli.
|
|
494
|
-
:
|
|
495
|
-
? await this.providerCli.
|
|
496
|
-
:
|
|
497
|
-
? await this.providerCli.
|
|
498
|
-
:
|
|
398
|
+
run = isPrReview
|
|
399
|
+
? await this.providerCli.runPrReview(context)
|
|
400
|
+
: isQa
|
|
401
|
+
? await this.providerCli.runQa(context)
|
|
402
|
+
: isArchitect
|
|
403
|
+
? await this.providerCli.runArchitect(context)
|
|
404
|
+
: isCiRepair
|
|
405
|
+
? await this.providerCli.runCiRepair(context)
|
|
406
|
+
: isConflictResolve
|
|
407
|
+
? await this.providerCli.runConflictResolve(context)
|
|
408
|
+
: await this.providerCli.runImplementation(context);
|
|
499
409
|
}
|
|
500
410
|
catch (error) {
|
|
501
411
|
const message = failureMessage(error);
|
|
@@ -506,12 +416,10 @@ export class BridgeSessionService {
|
|
|
506
416
|
}
|
|
507
417
|
throw error;
|
|
508
418
|
}
|
|
509
|
-
|
|
419
|
+
this.throwIfAbortedOrIsolationViolated(signal, dispatch, hostLease);
|
|
510
420
|
const phaseArtifacts = run.artifacts?.length ? run.artifacts : run.artifact ? [run.artifact] : [];
|
|
511
|
-
|
|
512
|
-
schemaVersion: 2,
|
|
513
|
-
exitCode: 0,
|
|
514
|
-
summary: run.summary,
|
|
421
|
+
const result = redactRunOnceResultPacket({
|
|
422
|
+
schemaVersion: 2, exitCode: 0, summary: run.summary,
|
|
515
423
|
resultCommitSha: run.resultCommitSha ?? null,
|
|
516
424
|
publishedCommitSha: run.publishedCommitSha ?? null,
|
|
517
425
|
events,
|
|
@@ -519,74 +427,113 @@ export class BridgeSessionService {
|
|
|
519
427
|
artifact: run.artifact ?? null,
|
|
520
428
|
artifacts: phaseArtifacts
|
|
521
429
|
}, redactionSecrets);
|
|
430
|
+
succeeded = true;
|
|
431
|
+
return result;
|
|
522
432
|
}
|
|
523
433
|
finally {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
434
|
+
await this.releaseHostRuntime(dispatch, hostLease, hostSingletonKeys, emitLifecycle);
|
|
435
|
+
if (worktree) {
|
|
436
|
+
await settleWorktree(this.worktrees, worktree, sessionWipOutcome(signal, events, succeeded), signal, emitLifecycle);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/** Launches a parallel-eligible probe's project, unless its contract is quarantined and so could never earn proof. */
|
|
441
|
+
async probeConfiguredProject(hostRuntime, request, started, signal) {
|
|
442
|
+
if (await hostRuntime.promotionQuarantined?.(request.repoId, hostRuntimeContractFingerprint(started.runtimeContract))) {
|
|
443
|
+
// Not launched; the server retries on its backoff, and the check passes once the quarantine expires.
|
|
444
|
+
return failedProbe("host_runtime_isolation_quarantined", "The runtime contract is quarantined after a recent isolation violation, so it was not probed; its runs stay serialized.");
|
|
445
|
+
}
|
|
446
|
+
assertReadinessProbeStartupBudget(request.expiresAt);
|
|
447
|
+
let isolationDetail = null;
|
|
448
|
+
const launched = await hostRuntime.startConfiguredProject(request.requestId, request.fencingToken, signal, async (checkpoint) => {
|
|
449
|
+
if (checkpoint.code === "host_runtime_isolation_serialized")
|
|
450
|
+
isolationDetail = checkpoint.message;
|
|
451
|
+
});
|
|
452
|
+
return configuredProbeResult(launched, isolationDetail);
|
|
453
|
+
}
|
|
454
|
+
/** A late isolation violation stopped the attempt's project in the background: fail rather than report success. */
|
|
455
|
+
throwIfAbortedOrIsolationViolated(signal, dispatch, hostLease) {
|
|
456
|
+
throwIfAborted(signal);
|
|
457
|
+
const violation = hostLease && dispatch.sandbox
|
|
458
|
+
? this.hostRuntime?.isolationViolation?.(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken)
|
|
459
|
+
: null;
|
|
460
|
+
if (violation)
|
|
461
|
+
throw violation;
|
|
462
|
+
}
|
|
463
|
+
/** Reports the provider's peak memory and releases the attempt's host runtime lease. */
|
|
464
|
+
async releaseHostRuntime(dispatch, hostLease, hostSingletonKeys, emitLifecycle) {
|
|
465
|
+
if (hostLease && dispatch.sandbox) {
|
|
466
|
+
const providerMemory = this.hostRuntime?.providerMemoryTelemetry?.(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken);
|
|
467
|
+
if (providerMemory) {
|
|
545
468
|
await emitLifecycle({
|
|
546
469
|
role: "runner",
|
|
547
470
|
kind: "checkpoint",
|
|
548
|
-
content: `
|
|
549
|
-
eventType: "
|
|
550
|
-
occurredAt:
|
|
471
|
+
content: `Observed managed-host provider process-tree peak memory ${formatMemoryBytes(providerMemory.peakMemoryBytes)} from ${providerMemory.sampleCount} sample${providerMemory.sampleCount === 1 ? "" : "s"}.`,
|
|
472
|
+
eventType: "sandbox_peak_memory_observed",
|
|
473
|
+
occurredAt: providerMemory.observedAt,
|
|
474
|
+
data: JSON.stringify({
|
|
475
|
+
peakMemoryBytes: providerMemory.peakMemoryBytes,
|
|
476
|
+
sampleCount: providerMemory.sampleCount,
|
|
477
|
+
source: providerMemory.source,
|
|
478
|
+
containers: [{
|
|
479
|
+
role: "agent",
|
|
480
|
+
peakMemoryBytes: providerMemory.peakMemoryBytes,
|
|
481
|
+
}],
|
|
482
|
+
}),
|
|
551
483
|
}).catch(() => undefined);
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
await emitLifecycle({
|
|
565
|
-
role: "runner",
|
|
566
|
-
kind: "checkpoint",
|
|
567
|
-
content: `Released host runtime lease ${released.leaseId}. Diagnostics remain runner-local.`,
|
|
568
|
-
eventType: "sandbox_teardown_completed",
|
|
569
|
-
occurredAt: released.releasedAt,
|
|
570
|
-
}).catch(() => undefined);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
catch (error) {
|
|
484
|
+
}
|
|
485
|
+
const teardownAt = new Date().toISOString();
|
|
486
|
+
await emitLifecycle({
|
|
487
|
+
role: "runner",
|
|
488
|
+
kind: "checkpoint",
|
|
489
|
+
content: `Releasing host runtime lease ${hostLease.lease.leaseId}.`,
|
|
490
|
+
eventType: "sandbox_teardown_started",
|
|
491
|
+
occurredAt: teardownAt,
|
|
492
|
+
}).catch(() => undefined);
|
|
493
|
+
try {
|
|
494
|
+
const released = await this.hostRuntime?.release(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken);
|
|
495
|
+
if (!released) {
|
|
574
496
|
await emitLifecycle({
|
|
575
497
|
role: "runner",
|
|
576
498
|
kind: "error",
|
|
577
|
-
content:
|
|
499
|
+
content: "Host runtime cleanup requires reconciliation: the runtime lease was not current during release.",
|
|
578
500
|
eventType: "teardown_failed",
|
|
579
501
|
occurredAt: new Date().toISOString(),
|
|
580
502
|
}).catch(() => undefined);
|
|
581
503
|
}
|
|
504
|
+
else {
|
|
505
|
+
await emitLifecycle({
|
|
506
|
+
role: "runner",
|
|
507
|
+
kind: "checkpoint",
|
|
508
|
+
content: `Released host runtime lease ${released.leaseId}. Diagnostics remain runner-local.`,
|
|
509
|
+
eventType: "sandbox_teardown_completed",
|
|
510
|
+
occurredAt: released.releasedAt,
|
|
511
|
+
}).catch(() => undefined);
|
|
512
|
+
}
|
|
582
513
|
}
|
|
583
|
-
|
|
584
|
-
await
|
|
514
|
+
catch (error) {
|
|
515
|
+
await emitLifecycle({
|
|
516
|
+
role: "runner",
|
|
517
|
+
kind: "error",
|
|
518
|
+
content: `Host runtime cleanup requires reconciliation: ${error instanceof Error ? error.message : String(error)}`,
|
|
519
|
+
eventType: "teardown_failed",
|
|
520
|
+
occurredAt: new Date().toISOString(),
|
|
521
|
+
}).catch(() => undefined);
|
|
585
522
|
}
|
|
586
|
-
if (worktree && !isPauseCancellation(signal))
|
|
587
|
-
await this.worktrees.release(worktree);
|
|
588
523
|
}
|
|
524
|
+
if (!hostLease && hostSingletonKeys && dispatch.sandbox) {
|
|
525
|
+
await this.hostRuntime?.release(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken).catch(() => undefined);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
function prReviewHeadSha(dispatch) {
|
|
530
|
+
const lane = dispatch.execution.lane.trim().toLowerCase();
|
|
531
|
+
const role = dispatch.execution.role.trim().toLowerCase();
|
|
532
|
+
const kind = dispatch.cycleRun.kind.trim().toLowerCase();
|
|
533
|
+
if (role !== "pr_review" && lane !== "pr_review" && kind !== "pr_review") {
|
|
534
|
+
return null;
|
|
589
535
|
}
|
|
536
|
+
return (dispatch.prReview?.headSha || dispatch.pullRequest?.headSha || "").trim() || null;
|
|
590
537
|
}
|
|
591
538
|
function failureMessage(error) {
|
|
592
539
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -594,10 +541,6 @@ function failureMessage(error) {
|
|
|
594
541
|
function formatMemoryBytes(bytes) {
|
|
595
542
|
return `${(bytes / (1024 ** 2)).toFixed(bytes >= 1024 ** 3 ? 0 : 1)} MiB`;
|
|
596
543
|
}
|
|
597
|
-
function isPauseCancellation(signal) {
|
|
598
|
-
return signal?.aborted === true
|
|
599
|
-
&& String(signal.reason ?? "").trim().toLowerCase() === "session pause requested";
|
|
600
|
-
}
|
|
601
544
|
function readinessProbeDispatch(request) {
|
|
602
545
|
return {
|
|
603
546
|
schemaVersion: 2,
|
|
@@ -677,6 +620,31 @@ function readinessProbeDispatch(request) {
|
|
|
677
620
|
artifacts: [],
|
|
678
621
|
};
|
|
679
622
|
}
|
|
623
|
+
/**
|
|
624
|
+
* A probe is parallel_ready only when every configured port proved readiness and the launch earned the
|
|
625
|
+
* parallel promotion, which an isolation violation or a quarantined contract withholds while it runs.
|
|
626
|
+
*/
|
|
627
|
+
function configuredProbeResult(started, isolationDetail) {
|
|
628
|
+
const requiredPorts = configuredLaunchPortNames(started.runtimeContract);
|
|
629
|
+
const verifiedPorts = started.lease.resources.ports.map(port => port.name);
|
|
630
|
+
if (requiredPorts.length === 0 || !requiredPorts.every(name => verifiedPorts.includes(name))) {
|
|
631
|
+
return failedProbe("host_runtime_probe_unverified", "The application did not prove ownership and readiness on every Forge-assigned port.");
|
|
632
|
+
}
|
|
633
|
+
if (started.environment.FORGE_HOST_CONCURRENCY !== "host_parallel_safe") {
|
|
634
|
+
return failedProbe("host_runtime_isolation_violation", isolationDetail
|
|
635
|
+
?? "The application served every Forge-assigned port, but did not earn parallel-safety proof for this runtime contract.");
|
|
636
|
+
}
|
|
637
|
+
return {
|
|
638
|
+
status: "parallel_ready",
|
|
639
|
+
runtimeContractFingerprint: hostRuntimeContractFingerprint(started.runtimeContract),
|
|
640
|
+
runtimeContractSource: started.runtimeContract.source,
|
|
641
|
+
runtimeRequirements: started.runtimeContract.contract.requires ?? null,
|
|
642
|
+
reasonCode: null,
|
|
643
|
+
reasonMessage: null,
|
|
644
|
+
qaAppLaunchTarget: managedQaLaunchTarget(started.runtimeContract),
|
|
645
|
+
checkedAt: new Date().toISOString(),
|
|
646
|
+
};
|
|
647
|
+
}
|
|
680
648
|
function failedProbe(reasonCode, reasonMessage) {
|
|
681
649
|
return { status: "failed", reasonCode, reasonMessage, checkedAt: new Date().toISOString() };
|
|
682
650
|
}
|
|
@@ -686,43 +654,6 @@ function assertReadinessProbeStartupBudget(expiresAt) {
|
|
|
686
654
|
throw new Error("host_runtime_probe_deadline_insufficient: readiness admission completed too close to the probe deadline; Forge released the reservation before launching the application.");
|
|
687
655
|
}
|
|
688
656
|
}
|
|
689
|
-
function managedQaLaunchTarget(runtimeContract) {
|
|
690
|
-
const playwright = runtimeContract.contract.runtime.playwright;
|
|
691
|
-
if (!playwright)
|
|
692
|
-
return null;
|
|
693
|
-
const port = runtimeContract.contract.runtime.ports.find(candidate => candidate.name === playwright.baseUrlPort);
|
|
694
|
-
return port?.launch && port.baseUrlEnv && port.format
|
|
695
|
-
? { managedRuntimePort: port.name, routes: ["/"] }
|
|
696
|
-
: null;
|
|
697
|
-
}
|
|
698
|
-
function withMaterializedManagedQaTarget(dispatch, hostLease) {
|
|
699
|
-
const target = dispatch.qaBrowser?.launchTarget;
|
|
700
|
-
const portName = target?.managed_runtime_port?.trim().toLowerCase();
|
|
701
|
-
if (!target || !portName)
|
|
702
|
-
return dispatch;
|
|
703
|
-
if (!hostLease) {
|
|
704
|
-
throw new Error("qa_managed_runtime_unavailable: Browser QA requires the verified managed host runtime selected during readiness.");
|
|
705
|
-
}
|
|
706
|
-
const normalizedName = portName.toUpperCase().replaceAll(/[^A-Z0-9]/gu, "_");
|
|
707
|
-
const url = hostLease.environment[`FORGE_${normalizedName}_URL`];
|
|
708
|
-
if (!url) {
|
|
709
|
-
throw new Error(`qa_managed_runtime_unavailable: verified runtime port '${portName}' was not launched for this attempt.`);
|
|
710
|
-
}
|
|
711
|
-
return {
|
|
712
|
-
...dispatch,
|
|
713
|
-
qaBrowser: dispatch.qaBrowser ? {
|
|
714
|
-
...dispatch.qaBrowser,
|
|
715
|
-
launchTarget: {
|
|
716
|
-
...target,
|
|
717
|
-
url: target.url ?? url,
|
|
718
|
-
ready_url: target.ready_url ?? url,
|
|
719
|
-
notes: [target.notes, "Forge launched and verified this URL inside the current fenced attempt."]
|
|
720
|
-
.filter(Boolean)
|
|
721
|
-
.join(" "),
|
|
722
|
-
},
|
|
723
|
-
} : dispatch.qaBrowser,
|
|
724
|
-
};
|
|
725
|
-
}
|
|
726
657
|
function probeFailureCode(error) {
|
|
727
658
|
const message = error instanceof Error ? error.message : String(error);
|
|
728
659
|
const candidate = message.split(":", 1)[0]?.trim().toLowerCase() ?? "";
|
|
@@ -737,6 +668,13 @@ function throwIfAborted(signal) {
|
|
|
737
668
|
throw new Error(String(signal.reason ?? "Dispatch cancelled."));
|
|
738
669
|
}
|
|
739
670
|
}
|
|
671
|
+
/** The dispatch attempt a worktree is prepared for: Forge's attempt for its WIP refs, and whose host load it reserves. */
|
|
672
|
+
function preparedAttemptOwner(dispatch) {
|
|
673
|
+
return {
|
|
674
|
+
wipAttempt: dispatch.wipAttempt ?? null,
|
|
675
|
+
hostLoadOwner: { dispatchAttemptId: dispatch.sandbox?.dispatchAttemptId ?? null, priority: runtimeAdmissionPriority(dispatch) },
|
|
676
|
+
};
|
|
677
|
+
}
|
|
740
678
|
function validateApiKeySecretGrant(dispatch) {
|
|
741
679
|
if (!dispatch.execution.requiresApiKeySecretGrant) {
|
|
742
680
|
return;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { HostRuntimeRequirements } from "../runtime/host-runtime-requirements.js";
|
|
2
|
+
import { type DispatchPrReviewContext } from "./session.types.pr-review.js";
|
|
3
|
+
export type { DispatchPrReviewContext, DispatchPrReviewPriorReview, DispatchPrReviewThread, DispatchPrReviewThreadComment } from "./session.types.pr-review.js";
|
|
2
4
|
export interface RunOnceDispatchPacket {
|
|
3
5
|
readonly schemaVersion: 1 | 2;
|
|
4
6
|
readonly userId: string;
|
|
@@ -11,7 +13,10 @@ export interface RunOnceDispatchPacket {
|
|
|
11
13
|
readonly runtimeIntent: DispatchRuntimeIntent;
|
|
12
14
|
readonly serverLocal: DispatchServerLocalConfig;
|
|
13
15
|
readonly sandbox?: DispatchSandboxContext | null;
|
|
16
|
+
readonly wipAttempt?: number | null;
|
|
14
17
|
readonly pullRequest?: DispatchPullRequestContext | null;
|
|
18
|
+
/** Review-only context for the pr_review lane: the head to review and the Story spec text. */
|
|
19
|
+
readonly prReview?: DispatchPrReviewContext | null;
|
|
15
20
|
readonly apiKeySecretGrant?: ApiKeySecretGrant | null;
|
|
16
21
|
readonly apiKeySecretGrantHandle?: ApiKeySecretGrantHandle | null;
|
|
17
22
|
readonly artifacts: readonly DispatchResolvedArtifact[];
|