@loucompanion/forge-bridge 0.1.4-dev.fb770705136a → 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 +183 -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 +40 -0
- package/dist/bridge/bridge-chat-provider-command.js +230 -0
- 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.base.d.ts +9 -0
- package/dist/bridge/bridge.service.d.ts +102 -14
- package/dist/bridge/bridge.service.js +499 -471
- package/dist/bridge/bridge.types.d.ts +37 -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/local-yield-flag.d.ts +6 -0
- package/dist/bridge/local-yield-flag.js +34 -0
- package/dist/bridge/readiness-result-outbox.d.ts +5 -1
- package/dist/bridge/readiness-result-outbox.js +20 -0
- package/dist/bridge/runner-host-capabilities.d.ts +5 -0
- package/dist/bridge/runner-host-capabilities.js +31 -1
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -0
- package/dist/bridge/test-postgres-capability.d.ts +14 -0
- package/dist/bridge/test-postgres-capability.js +120 -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 +20 -1
- package/dist/cleanup/cleanup.service.js +150 -169
- package/dist/cleanup/cleanup.types.d.ts +6 -0
- package/dist/cleanup/forge-owned-paths.d.ts +11 -0
- package/dist/cleanup/forge-owned-paths.js +62 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
- package/dist/cleanup/host-runtime-ledger.js +130 -0
- package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
- package/dist/cleanup/managed-branch-sweep.js +111 -0
- package/dist/cli/cli.help.js +75 -13
- package/dist/cli/cli.service.d.ts +19 -10
- package/dist/cli/cli.service.js +161 -228
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +18 -1
- package/dist/cli/local-config.js +67 -5
- 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 +184 -18
- 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-facts.d.ts +2 -1
- 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 +72 -0
- package/dist/runtime/host-load-admission.js +99 -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 +40 -0
- package/dist/runtime/host-load-child-environment.js +110 -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 +82 -0
- package/dist/runtime/host-load-governor-config.js +104 -0
- package/dist/runtime/host-load-governor.d.ts +273 -0
- package/dist/runtime/host-load-governor.js +831 -0
- package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
- package/dist/runtime/host-load-ledger-lock.js +187 -0
- 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.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +80 -0
- package/dist/runtime/host-load-sampler.d.ts +92 -2
- package/dist/runtime/host-load-sampler.js +166 -8
- package/dist/runtime/host-load-step-class.d.ts +70 -0
- package/dist/runtime/host-load-step-class.js +161 -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 +107 -0
- package/dist/runtime/host-load-step-run.js +158 -0
- package/dist/runtime/host-load-test-slot.d.ts +46 -0
- package/dist/runtime/host-load-test-slot.js +100 -0
- package/dist/runtime/host-load-token-ledger.d.ts +200 -0
- package/dist/runtime/host-load-token-ledger.js +453 -0
- package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
- package/dist/runtime/host-load-windows-cpu.js +85 -0
- package/dist/runtime/host-pressure-stall.d.ts +21 -1
- package/dist/runtime/host-pressure-stall.js +48 -1
- package/dist/runtime/host-runtime-contract.d.ts +15 -0
- package/dist/runtime/host-runtime-contract.js +39 -6
- package/dist/runtime/host-runtime-lease.d.ts +101 -6
- package/dist/runtime/host-runtime-lease.js +408 -294
- 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 +101 -2
- package/dist/runtime/host-runtime-promotion.js +355 -14
- 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/runtime/managed-command-teardown.js +5 -16
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
- package/dist/runtime/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 +104 -0
- package/dist/runtime/runner-settings.js +236 -0
- package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
- package/dist/runtime/supervised-runtime-build-guard.js +112 -0
- package/dist/sandbox/host-capacity-broker.d.ts +115 -0
- package/dist/sandbox/host-capacity-broker.js +336 -0
- 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 +11 -3
- package/dist/sandbox/runtime.js +53 -20
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- 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/architect-waits.d.ts +2 -0
- package/dist/session/architect-waits.js +138 -0
- package/dist/session/managed-attempt-tools.d.ts +2 -7
- package/dist/session/managed-attempt-tools.js +204 -141
- 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 +52 -0
- package/dist/session/managed-command-host-load.js +87 -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.artifact-bundle.d.ts +20 -0
- package/dist/session/phase-completion.artifact-bundle.js +167 -0
- package/dist/session/phase-completion.artifacts.d.ts +9 -17
- package/dist/session/phase-completion.artifacts.js +158 -190
- 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 +31 -2
- package/dist/session/phase-completion.helpers.js +18 -65
- package/dist/session/phase-completion.js +19 -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 +20 -1
- package/dist/session/phase-completion.runtime.d.ts +13 -12
- package/dist/session/phase-completion.runtime.js +113 -214
- 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 +219 -232
- package/dist/session/phase-completion.validation.d.ts +3 -3
- package/dist/session/phase-completion.validation.js +58 -94
- 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.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +112 -0
- package/dist/session/pre-publication-native-postgres.d.ts +30 -0
- package/dist/session/pre-publication-native-postgres.js +111 -0
- package/dist/session/pre-publication-pass.d.ts +61 -0
- package/dist/session/pre-publication-pass.js +148 -0
- package/dist/session/pre-publication-process.d.ts +3 -0
- package/dist/session/pre-publication-process.js +32 -19
- package/dist/session/pre-publication-step-execution.d.ts +12 -0
- package/dist/session/pre-publication-step-execution.js +50 -0
- package/dist/session/pre-publication-validation.d.ts +39 -22
- package/dist/session/pre-publication-validation.js +241 -207
- package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
- package/dist/session/provider-cli/claude-background-work.js +181 -0
- package/dist/session/provider-cli/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 +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +281 -0
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
- package/dist/session/provider-cli/provider-cli.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 +15 -36
- package/dist/session/provider-cli/provider-cli.process.js +41 -432
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +15 -3
- package/dist/session/provider-cli/provider-cli.prompts.js +183 -90
- 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 +43 -1
- 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 +18 -18
- package/dist/session/provider-cli/provider-cli.service.js +127 -317
- package/dist/session/provider-cli/provider-cli.types.d.ts +35 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
- package/dist/session/provider-cli/provider-in-flight-work.d.ts +4 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +45 -0
- package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
- package/dist/session/provider-cli/provider-output-pipes.js +67 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
- package/dist/session/provider-cli/provider-output-state.js +6 -0
- package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
- package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
- package/dist/session/qa-sidecar-validation.d.ts +6 -0
- package/dist/session/qa-sidecar-validation.js +28 -0
- package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
- package/dist/session/sandbox-host-capacity-gate.js +279 -0
- 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.base.d.ts +9 -1
- 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 +16 -2
- package/dist/session/session.service.js +208 -155
- package/dist/session/session.types.d.ts +8 -0
- package/dist/session/session.types.js +13 -83
- 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/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/fs/file-identity.d.ts +10 -0
- package/dist/shared/fs/file-identity.js +15 -0
- package/dist/shared/fs/replace-file.d.ts +7 -0
- package/dist/shared/fs/replace-file.js +33 -0
- package/dist/shared/process/host-process-recovery.d.ts +14 -3
- package/dist/shared/process/host-process-recovery.js +23 -3
- package/dist/shared/process/host-process-supervisor.d.ts +14 -1
- package/dist/shared/process/host-process-supervisor.js +67 -15
- 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/shared/process/windows-app-execution-alias.d.ts +19 -0
- package/dist/shared/process/windows-app-execution-alias.js +45 -0
- package/dist/shared/process/windows-launch.d.ts +18 -0
- package/dist/shared/process/windows-launch.js +68 -0
- package/dist/shared/provider-capabilities.d.ts +2 -0
- package/dist/shared/provider-capabilities.js +23 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.js +24 -0
- package/dist/worktree/dependency-warmer.d.ts +25 -0
- package/dist/worktree/dependency-warmer.js +46 -10
- 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 +58 -5
- package/dist/worktree/worktree.service.js +237 -161
- package/dist/worktree/worktree.types.d.ts +54 -0
- package/package.json +2 -2
- package/runtime/windows-listener-owner.ps1 +12 -1
|
@@ -1,22 +1,37 @@
|
|
|
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
|
-
import { HostRuntimeAdmissionExpiredError, hostRuntimeEventResources, } from "../runtime/host-runtime-lease.js";
|
|
9
|
+
import { HostRuntimeAdmissionExpiredError, hostRuntimeEventResources, hostRuntimeStackEnvironmentKeys, runtimeAdmissionPriority, } from "../runtime/host-runtime-lease.js";
|
|
8
10
|
import { configuredLaunchPortNames, hostRuntimeContractFingerprint, hostRuntimeParallelEligible, } from "../runtime/host-runtime-promotion.js";
|
|
11
|
+
import { managedQaLaunchTarget, startOrDeferConfiguredProject, withMaterializedManagedQaTarget, } from "./session-host-project.js";
|
|
12
|
+
import { createConfiguredRuntimeRefresh, readWorkspaceRuntimeFingerprint, } from "./session.runtime-refresh.js";
|
|
9
13
|
const minimumReadinessProbeStartupBudgetMs = 150_000;
|
|
10
14
|
export class BridgeSessionService {
|
|
11
15
|
worktrees;
|
|
12
16
|
providerCli;
|
|
13
17
|
hostRuntime;
|
|
18
|
+
workspaceFingerprint;
|
|
14
19
|
constructor(worktrees = process.env.FORGE_SANDBOX_ID
|
|
15
20
|
? new SandboxWorkspaceService()
|
|
16
|
-
: new GitWorktreeService(), providerCli = new RoutingProviderCliService(), hostRuntime) {
|
|
21
|
+
: new GitWorktreeService(), providerCli = new RoutingProviderCliService(), hostRuntime, workspaceFingerprint = readWorkspaceRuntimeFingerprint) {
|
|
17
22
|
this.worktrees = worktrees;
|
|
18
23
|
this.providerCli = providerCli;
|
|
19
24
|
this.hostRuntime = hostRuntime;
|
|
25
|
+
this.workspaceFingerprint = workspaceFingerprint;
|
|
26
|
+
}
|
|
27
|
+
setHostRequirementsCheck(check) {
|
|
28
|
+
this.hostRuntime?.setRequirementsCheck?.(check);
|
|
29
|
+
}
|
|
30
|
+
runnerLimitDefaults() {
|
|
31
|
+
return this.hostRuntime?.capacityLimitDefaults?.() ?? null;
|
|
32
|
+
}
|
|
33
|
+
applyRunnerLimits(limits) {
|
|
34
|
+
this.hostRuntime?.applyCapacityLimits?.(limits);
|
|
20
35
|
}
|
|
21
36
|
async updateLease(dispatchAttemptId, fencingToken, expiresAt) {
|
|
22
37
|
await this.hostRuntime?.updateLease(dispatchAttemptId, fencingToken, expiresAt);
|
|
@@ -61,9 +76,11 @@ export class BridgeSessionService {
|
|
|
61
76
|
// failed agent worktrees for inspection.
|
|
62
77
|
cleanupWorktrees: dispatch.serverLocal.cleanupWorktrees,
|
|
63
78
|
artifacts: [],
|
|
79
|
+
hostLoadOwner: { dispatchAttemptId: dispatch.sandbox?.dispatchAttemptId ?? null, priority: "background" },
|
|
80
|
+
signal,
|
|
64
81
|
});
|
|
65
82
|
assertReadinessProbeStartupBudget(request.expiresAt);
|
|
66
|
-
|
|
83
|
+
const started = await this.hostRuntime.start(dispatch, worktree.worktreePath, signal);
|
|
67
84
|
runtimeStarted = true;
|
|
68
85
|
const discovery = started.runtimeContract.discovery;
|
|
69
86
|
if (!hostRuntimeParallelEligible(started.runtimeContract)) {
|
|
@@ -71,28 +88,14 @@ export class BridgeSessionService {
|
|
|
71
88
|
status: "serialized",
|
|
72
89
|
runtimeContractFingerprint: hostRuntimeContractFingerprint(started.runtimeContract),
|
|
73
90
|
runtimeContractSource: started.runtimeContract.source,
|
|
91
|
+
runtimeRequirements: started.runtimeContract.contract.requires ?? null,
|
|
74
92
|
reasonCode: discovery?.reasonCode ?? "host_runtime_contract_serialized",
|
|
75
93
|
reasonMessage: discovery?.summary ?? "The detected runtime requires serialized host execution.",
|
|
76
94
|
checkedAt: new Date().toISOString(),
|
|
77
95
|
};
|
|
78
96
|
}
|
|
79
97
|
else {
|
|
80
|
-
|
|
81
|
-
started = await this.hostRuntime.startConfiguredProject(request.requestId, request.fencingToken, signal);
|
|
82
|
-
const requiredPorts = configuredLaunchPortNames(started.runtimeContract);
|
|
83
|
-
const verifiedPorts = started.lease.resources.ports.map(port => port.name);
|
|
84
|
-
const verified = requiredPorts.length > 0 && requiredPorts.every(name => verifiedPorts.includes(name));
|
|
85
|
-
result = verified
|
|
86
|
-
? {
|
|
87
|
-
status: "parallel_ready",
|
|
88
|
-
runtimeContractFingerprint: hostRuntimeContractFingerprint(started.runtimeContract),
|
|
89
|
-
runtimeContractSource: started.runtimeContract.source,
|
|
90
|
-
reasonCode: null,
|
|
91
|
-
reasonMessage: null,
|
|
92
|
-
qaAppLaunchTarget: managedQaLaunchTarget(started.runtimeContract),
|
|
93
|
-
checkedAt: new Date().toISOString(),
|
|
94
|
-
}
|
|
95
|
-
: 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);
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
catch (error) {
|
|
@@ -174,6 +177,7 @@ export class BridgeSessionService {
|
|
|
174
177
|
let worktree = null;
|
|
175
178
|
let hostSingletonKeys = null;
|
|
176
179
|
let hostLease = null;
|
|
180
|
+
let succeeded = false;
|
|
177
181
|
try {
|
|
178
182
|
if (dispatch.sandbox?.executionMode === "host" && this.hostRuntime) {
|
|
179
183
|
const capacity = this.hostRuntime.snapshot?.() ?? null;
|
|
@@ -248,7 +252,12 @@ export class BridgeSessionService {
|
|
|
248
252
|
qaRework: dispatch.qaRework,
|
|
249
253
|
warmPathOverrides: dispatch.warmPathOverrides,
|
|
250
254
|
applicationRuntimeRequired: dispatch.runtimeIntent.applicationRuntimeRequired,
|
|
251
|
-
preserveExistingState: Boolean(dispatch.session.resumedFromSessionId)
|
|
255
|
+
preserveExistingState: Boolean(dispatch.session.resumedFromSessionId),
|
|
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),
|
|
260
|
+
signal,
|
|
252
261
|
});
|
|
253
262
|
}
|
|
254
263
|
catch (error) {
|
|
@@ -264,6 +273,7 @@ export class BridgeSessionService {
|
|
|
264
273
|
: `Prepared worktree ${worktree.branchName}.`,
|
|
265
274
|
eventType: dispatch.session.resumedFromSessionId ? "worktree_reattached" : "worktree_prepared"
|
|
266
275
|
});
|
|
276
|
+
await emitWorktreePreparedEvents(worktree, emit);
|
|
267
277
|
if ((worktree.hydratedPriorPhaseArtifactCount ?? 0) > 0) {
|
|
268
278
|
await emit({
|
|
269
279
|
role: "runner",
|
|
@@ -275,6 +285,10 @@ export class BridgeSessionService {
|
|
|
275
285
|
if (worktree.dependencyWarm) {
|
|
276
286
|
await emitDependencyWarmEvents(worktree.dependencyWarm, emit);
|
|
277
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;
|
|
278
292
|
if (dispatch.sandbox?.executionMode === "host" && this.hostRuntime) {
|
|
279
293
|
hostLease = await this.hostRuntime.start(dispatch, worktree.worktreePath, signal, async (checkpoint) => {
|
|
280
294
|
const observation = waitObservation(checkpoint.code);
|
|
@@ -305,28 +319,30 @@ export class BridgeSessionService {
|
|
|
305
319
|
remediation: "Enable Run in Docker in Project Settings.",
|
|
306
320
|
}),
|
|
307
321
|
});
|
|
308
|
-
|
|
309
|
-
hostLease = await this.hostRuntime.startConfiguredProject(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken, signal, async (checkpoint) => {
|
|
310
|
-
await emitLifecycle({
|
|
311
|
-
role: "runner",
|
|
312
|
-
kind: "checkpoint",
|
|
313
|
-
content: checkpoint.message,
|
|
314
|
-
eventType: checkpoint.code,
|
|
315
|
-
data: checkpoint.data ? JSON.stringify(checkpoint.data) : undefined,
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
if (hostLease.lease.resources.ports.length > unconfiguredPortCount) {
|
|
319
|
-
const assigned = hostLease.lease.resources.ports.at(-1);
|
|
320
|
-
await emitLifecycle({
|
|
321
|
-
role: "runner",
|
|
322
|
-
kind: "checkpoint",
|
|
323
|
-
content: `Verified supervised project runtime ${assigned.name} on ${assigned.hostIp}:${assigned.hostPort}.`,
|
|
324
|
-
eventType: "host_runtime_project_ready",
|
|
325
|
-
data: JSON.stringify(hostRuntimeEventResources(hostLease.lease, hostLease.runtimeContract, hostLease.executionClass)),
|
|
326
|
-
});
|
|
327
|
-
}
|
|
322
|
+
({ hostLease, deferred: projectStartDeferred } = await startOrDeferConfiguredProject(this.hostRuntime, hostLease, dispatch, reapplyConflicts, signal, emitLifecycle));
|
|
328
323
|
}
|
|
329
|
-
|
|
324
|
+
// The stack was built and launched from this workspace state. Pre-publication
|
|
325
|
+
// validation restarts it when the provider has changed the source since.
|
|
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 => {
|
|
336
|
+
hostLease = restarted;
|
|
337
|
+
},
|
|
338
|
+
startDeferred: projectStartDeferred
|
|
339
|
+
});
|
|
340
|
+
providerDispatch = withMaterializedManagedQaTarget(providerDispatch, hostLease, projectStartDeferred);
|
|
341
|
+
const providerEnvironment = {
|
|
342
|
+
runtimeEnvironment: hostLease?.environment,
|
|
343
|
+
// Only the completion MCP server gets these: its managed commands share the host ledger.
|
|
344
|
+
hostLoadEnvironment: hostLease ? this.hostRuntime?.hostLoadChildEnvironment?.() : undefined,
|
|
345
|
+
};
|
|
330
346
|
if (dispatch.draft) {
|
|
331
347
|
throwIfAborted(signal);
|
|
332
348
|
const processRunner = hostLease && dispatch.sandbox
|
|
@@ -335,22 +351,23 @@ export class BridgeSessionService {
|
|
|
335
351
|
const run = await this.providerCli.runDraft({
|
|
336
352
|
dispatch: providerDispatch,
|
|
337
353
|
worktree,
|
|
338
|
-
|
|
354
|
+
...providerEnvironment,
|
|
339
355
|
processRunner,
|
|
340
356
|
emit,
|
|
341
357
|
signal
|
|
342
358
|
});
|
|
343
|
-
|
|
359
|
+
this.throwIfAbortedOrIsolationViolated(signal, dispatch, hostLease);
|
|
344
360
|
const draftArtifacts = run.artifacts?.length ? run.artifacts : run.artifact ? [run.artifact] : [];
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
exitCode: 0,
|
|
348
|
-
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,
|
|
349
364
|
events,
|
|
350
365
|
spec: run.spec ?? null,
|
|
351
366
|
artifact: run.artifact ?? null,
|
|
352
367
|
artifacts: draftArtifacts
|
|
353
368
|
}, redactionSecrets);
|
|
369
|
+
succeeded = true;
|
|
370
|
+
return draftResult;
|
|
354
371
|
}
|
|
355
372
|
throwIfAborted(signal);
|
|
356
373
|
const lane = dispatch.execution.lane.trim().toLowerCase();
|
|
@@ -360,27 +377,35 @@ export class BridgeSessionService {
|
|
|
360
377
|
const isArchitect = role === "architect" || lane === "architect" || cycleKind === "architect";
|
|
361
378
|
const isCiRepair = role === "ci_repair" || lane === "ci_repair" || cycleKind === "pr_checks";
|
|
362
379
|
const isConflictResolve = role === "conflict_resolve" || lane === "conflict_resolve";
|
|
380
|
+
const isPrReview = role === "pr_review" || lane === "pr_review" || cycleKind === "pr_review";
|
|
363
381
|
const context = {
|
|
364
382
|
dispatch: providerDispatch,
|
|
365
383
|
worktree,
|
|
366
|
-
|
|
384
|
+
...providerEnvironment,
|
|
367
385
|
processRunner: hostLease && dispatch.sandbox
|
|
368
386
|
? this.hostRuntime?.providerProcessRunner?.(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken) ?? undefined
|
|
369
387
|
: undefined,
|
|
388
|
+
...(refreshRuntimeEnvironment && hostLease
|
|
389
|
+
? { refreshRuntimeEnvironment, runtimeStackEnvironmentKeys: hostRuntimeStackEnvironmentKeys(hostLease.runtimeContract) }
|
|
390
|
+
: {}),
|
|
391
|
+
reapplyConflicts,
|
|
392
|
+
projectStartDeferred,
|
|
370
393
|
emit,
|
|
371
394
|
signal
|
|
372
395
|
};
|
|
373
396
|
let run;
|
|
374
397
|
try {
|
|
375
|
-
run =
|
|
376
|
-
? await this.providerCli.
|
|
377
|
-
:
|
|
378
|
-
? await this.providerCli.
|
|
379
|
-
:
|
|
380
|
-
? await this.providerCli.
|
|
381
|
-
:
|
|
382
|
-
? await this.providerCli.
|
|
383
|
-
:
|
|
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);
|
|
384
409
|
}
|
|
385
410
|
catch (error) {
|
|
386
411
|
const message = failureMessage(error);
|
|
@@ -391,12 +416,10 @@ export class BridgeSessionService {
|
|
|
391
416
|
}
|
|
392
417
|
throw error;
|
|
393
418
|
}
|
|
394
|
-
|
|
419
|
+
this.throwIfAbortedOrIsolationViolated(signal, dispatch, hostLease);
|
|
395
420
|
const phaseArtifacts = run.artifacts?.length ? run.artifacts : run.artifact ? [run.artifact] : [];
|
|
396
|
-
|
|
397
|
-
schemaVersion: 2,
|
|
398
|
-
exitCode: 0,
|
|
399
|
-
summary: run.summary,
|
|
421
|
+
const result = redactRunOnceResultPacket({
|
|
422
|
+
schemaVersion: 2, exitCode: 0, summary: run.summary,
|
|
400
423
|
resultCommitSha: run.resultCommitSha ?? null,
|
|
401
424
|
publishedCommitSha: run.publishedCommitSha ?? null,
|
|
402
425
|
events,
|
|
@@ -404,85 +427,120 @@ export class BridgeSessionService {
|
|
|
404
427
|
artifact: run.artifact ?? null,
|
|
405
428
|
artifacts: phaseArtifacts
|
|
406
429
|
}, redactionSecrets);
|
|
430
|
+
succeeded = true;
|
|
431
|
+
return result;
|
|
407
432
|
}
|
|
408
433
|
finally {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
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) {
|
|
430
468
|
await emitLifecycle({
|
|
431
469
|
role: "runner",
|
|
432
470
|
kind: "checkpoint",
|
|
433
|
-
content: `
|
|
434
|
-
eventType: "
|
|
435
|
-
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
|
+
}),
|
|
436
483
|
}).catch(() => undefined);
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
await emitLifecycle({
|
|
450
|
-
role: "runner",
|
|
451
|
-
kind: "checkpoint",
|
|
452
|
-
content: `Released host runtime lease ${released.leaseId}. Diagnostics remain runner-local.`,
|
|
453
|
-
eventType: "sandbox_teardown_completed",
|
|
454
|
-
occurredAt: released.releasedAt,
|
|
455
|
-
}).catch(() => undefined);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
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) {
|
|
459
496
|
await emitLifecycle({
|
|
460
497
|
role: "runner",
|
|
461
498
|
kind: "error",
|
|
462
|
-
content:
|
|
499
|
+
content: "Host runtime cleanup requires reconciliation: the runtime lease was not current during release.",
|
|
463
500
|
eventType: "teardown_failed",
|
|
464
501
|
occurredAt: new Date().toISOString(),
|
|
465
502
|
}).catch(() => undefined);
|
|
466
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
|
+
}
|
|
467
513
|
}
|
|
468
|
-
|
|
469
|
-
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);
|
|
470
522
|
}
|
|
471
|
-
|
|
472
|
-
|
|
523
|
+
}
|
|
524
|
+
if (!hostLease && hostSingletonKeys && dispatch.sandbox) {
|
|
525
|
+
await this.hostRuntime?.release(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken).catch(() => undefined);
|
|
473
526
|
}
|
|
474
527
|
}
|
|
475
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;
|
|
535
|
+
}
|
|
536
|
+
return (dispatch.prReview?.headSha || dispatch.pullRequest?.headSha || "").trim() || null;
|
|
537
|
+
}
|
|
476
538
|
function failureMessage(error) {
|
|
477
539
|
return error instanceof Error ? error.message : String(error);
|
|
478
540
|
}
|
|
479
541
|
function formatMemoryBytes(bytes) {
|
|
480
542
|
return `${(bytes / (1024 ** 2)).toFixed(bytes >= 1024 ** 3 ? 0 : 1)} MiB`;
|
|
481
543
|
}
|
|
482
|
-
function isPauseCancellation(signal) {
|
|
483
|
-
return signal?.aborted === true
|
|
484
|
-
&& String(signal.reason ?? "").trim().toLowerCase() === "session pause requested";
|
|
485
|
-
}
|
|
486
544
|
function readinessProbeDispatch(request) {
|
|
487
545
|
return {
|
|
488
546
|
schemaVersion: 2,
|
|
@@ -562,6 +620,31 @@ function readinessProbeDispatch(request) {
|
|
|
562
620
|
artifacts: [],
|
|
563
621
|
};
|
|
564
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
|
+
}
|
|
565
648
|
function failedProbe(reasonCode, reasonMessage) {
|
|
566
649
|
return { status: "failed", reasonCode, reasonMessage, checkedAt: new Date().toISOString() };
|
|
567
650
|
}
|
|
@@ -571,43 +654,6 @@ function assertReadinessProbeStartupBudget(expiresAt) {
|
|
|
571
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.");
|
|
572
655
|
}
|
|
573
656
|
}
|
|
574
|
-
function managedQaLaunchTarget(runtimeContract) {
|
|
575
|
-
const playwright = runtimeContract.contract.runtime.playwright;
|
|
576
|
-
if (!playwright)
|
|
577
|
-
return null;
|
|
578
|
-
const port = runtimeContract.contract.runtime.ports.find(candidate => candidate.name === playwright.baseUrlPort);
|
|
579
|
-
return port?.launch && port.baseUrlEnv && port.format
|
|
580
|
-
? { managedRuntimePort: port.name, routes: ["/"] }
|
|
581
|
-
: null;
|
|
582
|
-
}
|
|
583
|
-
function withMaterializedManagedQaTarget(dispatch, hostLease) {
|
|
584
|
-
const target = dispatch.qaBrowser?.launchTarget;
|
|
585
|
-
const portName = target?.managed_runtime_port?.trim().toLowerCase();
|
|
586
|
-
if (!target || !portName)
|
|
587
|
-
return dispatch;
|
|
588
|
-
if (!hostLease) {
|
|
589
|
-
throw new Error("qa_managed_runtime_unavailable: Browser QA requires the verified managed host runtime selected during readiness.");
|
|
590
|
-
}
|
|
591
|
-
const normalizedName = portName.toUpperCase().replaceAll(/[^A-Z0-9]/gu, "_");
|
|
592
|
-
const url = hostLease.environment[`FORGE_${normalizedName}_URL`];
|
|
593
|
-
if (!url) {
|
|
594
|
-
throw new Error(`qa_managed_runtime_unavailable: verified runtime port '${portName}' was not launched for this attempt.`);
|
|
595
|
-
}
|
|
596
|
-
return {
|
|
597
|
-
...dispatch,
|
|
598
|
-
qaBrowser: dispatch.qaBrowser ? {
|
|
599
|
-
...dispatch.qaBrowser,
|
|
600
|
-
launchTarget: {
|
|
601
|
-
...target,
|
|
602
|
-
url: target.url ?? url,
|
|
603
|
-
ready_url: target.ready_url ?? url,
|
|
604
|
-
notes: [target.notes, "Forge launched and verified this URL inside the current fenced attempt."]
|
|
605
|
-
.filter(Boolean)
|
|
606
|
-
.join(" "),
|
|
607
|
-
},
|
|
608
|
-
} : dispatch.qaBrowser,
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
657
|
function probeFailureCode(error) {
|
|
612
658
|
const message = error instanceof Error ? error.message : String(error);
|
|
613
659
|
const candidate = message.split(":", 1)[0]?.trim().toLowerCase() ?? "";
|
|
@@ -622,6 +668,13 @@ function throwIfAborted(signal) {
|
|
|
622
668
|
throw new Error(String(signal.reason ?? "Dispatch cancelled."));
|
|
623
669
|
}
|
|
624
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
|
+
}
|
|
625
678
|
function validateApiKeySecretGrant(dispatch) {
|
|
626
679
|
if (!dispatch.execution.requiresApiKeySecretGrant) {
|
|
627
680
|
return;
|
|
@@ -1,3 +1,6 @@
|
|
|
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";
|
|
1
4
|
export interface RunOnceDispatchPacket {
|
|
2
5
|
readonly schemaVersion: 1 | 2;
|
|
3
6
|
readonly userId: string;
|
|
@@ -10,7 +13,10 @@ export interface RunOnceDispatchPacket {
|
|
|
10
13
|
readonly runtimeIntent: DispatchRuntimeIntent;
|
|
11
14
|
readonly serverLocal: DispatchServerLocalConfig;
|
|
12
15
|
readonly sandbox?: DispatchSandboxContext | null;
|
|
16
|
+
readonly wipAttempt?: number | null;
|
|
13
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;
|
|
14
20
|
readonly apiKeySecretGrant?: ApiKeySecretGrant | null;
|
|
15
21
|
readonly apiKeySecretGrantHandle?: ApiKeySecretGrantHandle | null;
|
|
16
22
|
readonly artifacts: readonly DispatchResolvedArtifact[];
|
|
@@ -546,6 +552,8 @@ export interface HostRuntimeReadinessProbeResult {
|
|
|
546
552
|
readonly status: "parallel_ready" | "serialized" | "failed";
|
|
547
553
|
readonly runtimeContractFingerprint?: string | null;
|
|
548
554
|
readonly runtimeContractSource?: string | null;
|
|
555
|
+
/** Requirements declared by the probed contract (decision 0013); null when none. */
|
|
556
|
+
readonly runtimeRequirements?: HostRuntimeRequirements | null;
|
|
549
557
|
readonly reasonCode?: string | null;
|
|
550
558
|
readonly reasonMessage?: string | null;
|
|
551
559
|
readonly qaAppLaunchTarget?: HostRuntimeReadinessQaLaunchTarget | null;
|