@loucompanion/forge-bridge 0.1.3-dev.fbe15023cdfe → 0.1.4-dev.0098fdb4e213
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 +232 -5
- package/dist/bridge/bridge-chat-provider-command.d.ts +19 -0
- package/dist/bridge/bridge-chat-provider-command.js +132 -0
- package/dist/bridge/bridge-chat.types.d.ts +121 -0
- package/dist/bridge/bridge-chat.types.js +416 -0
- package/dist/bridge/bridge-state-file.d.ts +161 -0
- package/dist/bridge/bridge-state-file.js +376 -0
- package/dist/bridge/bridge-state-io.d.ts +11 -0
- package/dist/bridge/bridge-state-io.js +50 -0
- package/dist/bridge/bridge-state-lock.d.ts +11 -0
- package/dist/bridge/bridge-state-lock.js +102 -0
- package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
- package/dist/bridge/bridge-state-unpublished.js +111 -0
- package/dist/bridge/bridge.base.d.ts +13 -1
- package/dist/bridge/bridge.service.d.ts +169 -14
- package/dist/bridge/bridge.service.js +1868 -330
- package/dist/bridge/bridge.types.d.ts +73 -1
- package/dist/bridge/dispatch-result-outbox.d.ts +35 -0
- package/dist/bridge/dispatch-result-outbox.js +87 -0
- package/dist/bridge/dispatch-result-worker.d.ts +2 -0
- package/dist/bridge/dispatch-result-worker.js +122 -0
- package/dist/bridge/in-flight-registry.d.ts +62 -0
- package/dist/bridge/in-flight-registry.js +207 -0
- package/dist/bridge/internals.d.ts +2 -0
- package/dist/bridge/internals.js +1 -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 +25 -0
- package/dist/bridge/readiness-result-outbox.js +74 -0
- package/dist/bridge/readiness-result-worker.d.ts +2 -0
- package/dist/bridge/readiness-result-worker.js +121 -0
- package/dist/bridge/runner-host-capabilities.d.ts +20 -0
- package/dist/bridge/runner-host-capabilities.js +110 -0
- 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/cleanup/cleanup-wip.d.ts +12 -0
- package/dist/cleanup/cleanup-wip.js +66 -0
- package/dist/cleanup/cleanup.service.d.ts +21 -1
- package/dist/cleanup/cleanup.service.js +185 -143
- package/dist/cleanup/cleanup.types.d.ts +6 -0
- package/dist/cleanup/forge-owned-paths.d.ts +9 -0
- package/dist/cleanup/forge-owned-paths.js +53 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
- package/dist/cleanup/host-runtime-ledger.js +130 -0
- package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
- package/dist/cleanup/managed-branch-sweep.js +111 -0
- package/dist/cli/cli.help.js +78 -16
- package/dist/cli/cli.service.d.ts +32 -15
- package/dist/cli/cli.service.js +206 -182
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +7 -0
- package/dist/cli/local-config.js +36 -4
- package/dist/cli/provider-cli-detection.d.ts +10 -0
- package/dist/cli/provider-cli-detection.js +160 -0
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +41 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +474 -0
- package/dist/runtime/attempt-database-broker.d.ts +89 -0
- package/dist/runtime/attempt-database-broker.js +390 -0
- package/dist/runtime/attempt-node-runtime-launcher.d.ts +2 -1
- package/dist/runtime/attempt-node-runtime-launcher.js +57 -18
- package/dist/runtime/attempt-path-operation.d.ts +21 -0
- package/dist/runtime/attempt-path-operation.js +94 -0
- package/dist/runtime/attempt-private-directory.d.ts +6 -0
- package/dist/runtime/attempt-private-directory.js +54 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +35 -0
- package/dist/runtime/attempt-process-supervisor.js +144 -23
- package/dist/runtime/canonical-source-file.d.ts +3 -0
- package/dist/runtime/canonical-source-file.js +54 -0
- package/dist/runtime/docker-engine-probe.d.ts +95 -0
- package/dist/runtime/docker-engine-probe.js +340 -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/generated-output-reset.d.ts +10 -0
- package/dist/runtime/generated-output-reset.js +62 -8
- package/dist/runtime/host-database-capability-boundary.d.ts +16 -0
- package/dist/runtime/host-database-capability-boundary.js +63 -0
- package/dist/runtime/host-diagnostics.d.ts +11 -0
- package/dist/runtime/host-diagnostics.js +192 -0
- package/dist/runtime/host-execution-root.d.ts +4 -0
- package/dist/runtime/host-execution-root.js +39 -0
- package/dist/runtime/host-facts.d.ts +36 -0
- package/dist/runtime/host-facts.js +95 -0
- package/dist/runtime/host-listener-inspector.d.ts +8 -1
- package/dist/runtime/host-listener-inspector.js +121 -60
- package/dist/runtime/host-load-admission.d.ts +67 -0
- package/dist/runtime/host-load-admission.js +99 -0
- package/dist/runtime/host-load-child-environment.d.ts +27 -0
- package/dist/runtime/host-load-child-environment.js +76 -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 +52 -0
- package/dist/runtime/host-load-governor-config.js +83 -0
- package/dist/runtime/host-load-governor.d.ts +186 -0
- package/dist/runtime/host-load-governor.js +632 -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-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +80 -0
- package/dist/runtime/host-load-sampler.d.ts +156 -0
- package/dist/runtime/host-load-sampler.js +298 -0
- 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 +73 -0
- package/dist/runtime/host-load-step-run.js +102 -0
- package/dist/runtime/host-load-test-slot.d.ts +43 -0
- package/dist/runtime/host-load-test-slot.js +81 -0
- package/dist/runtime/host-load-token-ledger.d.ts +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 +61 -0
- package/dist/runtime/host-pressure-stall.js +168 -0
- package/dist/runtime/host-runtime-contract.d.ts +28 -1
- package/dist/runtime/host-runtime-contract.js +203 -57
- package/dist/runtime/host-runtime-lease.d.ts +163 -9
- package/dist/runtime/host-runtime-lease.js +1427 -124
- package/dist/runtime/host-runtime-promotion.d.ts +35 -3
- package/dist/runtime/host-runtime-promotion.js +107 -12
- 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.d.ts +62 -0
- package/dist/runtime/managed-command-teardown.js +596 -0
- package/dist/runtime/memory-capacity.d.ts +70 -0
- package/dist/runtime/memory-capacity.js +123 -0
- package/dist/runtime/native-test-postgres-fallback.d.ts +69 -0
- package/dist/runtime/native-test-postgres-fallback.js +143 -0
- package/dist/runtime/node-host-runtime-adapter.d.ts +3 -0
- package/dist/runtime/node-host-runtime-adapter.js +29 -11
- package/dist/runtime/pinned-directory-process.d.ts +9 -0
- package/dist/runtime/pinned-directory-process.js +61 -0
- package/dist/runtime/pinned-source-directory.d.ts +17 -0
- package/dist/runtime/pinned-source-directory.js +94 -0
- package/dist/runtime/playwright-browser-cache.d.ts +39 -0
- package/dist/runtime/playwright-browser-cache.js +227 -0
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +19 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +113 -59
- package/dist/runtime/prepared-runtime-identity.d.ts +6 -0
- package/dist/runtime/prepared-runtime-identity.js +218 -0
- package/dist/runtime/prepared-runtime-readiness.d.ts +30 -0
- package/dist/runtime/prepared-runtime-readiness.js +285 -0
- package/dist/runtime/runner-settings.d.ts +104 -0
- package/dist/runtime/runner-settings.js +236 -0
- package/dist/runtime/runtime-isolation-lease.js +4 -1
- package/dist/runtime/workspace-resource-estimator.d.ts +17 -0
- package/dist/runtime/workspace-resource-estimator.js +174 -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 +36 -0
- package/dist/sandbox/preflight.d.ts +31 -1
- package/dist/sandbox/preflight.js +237 -51
- package/dist/sandbox/provider-auth/codex.js +11 -11
- package/dist/sandbox/repository-lock.d.ts +2 -1
- package/dist/sandbox/repository-lock.js +19 -9
- package/dist/sandbox/runtime.d.ts +16 -2
- package/dist/sandbox/runtime.js +183 -114
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- package/dist/sandbox/sandbox.types.d.ts +7 -0
- package/dist/sandbox/workspace.service.js +2 -0
- 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 +37 -1
- package/dist/session/managed-attempt-tools.js +822 -84
- package/dist/session/managed-build-coordinator.d.ts +5 -0
- package/dist/session/managed-build-coordinator.js +109 -0
- package/dist/session/managed-build-receipt.d.ts +26 -0
- package/dist/session/managed-build-receipt.js +342 -0
- package/dist/session/managed-command-host-load.d.ts +47 -0
- package/dist/session/managed-command-host-load.js +83 -0
- package/dist/session/managed-verification-timeouts.d.ts +8 -0
- package/dist/session/managed-verification-timeouts.js +17 -0
- package/dist/session/mcp-argument-coercion.d.ts +23 -0
- package/dist/session/mcp-argument-coercion.js +121 -0
- package/dist/session/phase-completion.artifacts.d.ts +24 -0
- package/dist/session/phase-completion.artifacts.js +321 -45
- 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 +23 -1
- package/dist/session/phase-completion.helpers.d.ts +5 -0
- package/dist/session/phase-completion.helpers.js +43 -19
- package/dist/session/phase-completion.js +19 -3
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +156 -0
- package/dist/session/phase-completion.prompts.js +22 -18
- package/dist/session/phase-completion.runtime.d.ts +6 -10
- package/dist/session/phase-completion.runtime.js +214 -224
- 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 +250 -226
- package/dist/session/phase-completion.validation.d.ts +3 -3
- package/dist/session/phase-completion.validation.js +135 -89
- package/dist/session/pre-publication-host-load.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +111 -0
- package/dist/session/pre-publication-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 +23 -0
- package/dist/session/pre-publication-process.js +109 -0
- package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
- package/dist/session/pre-publication-skipped-tests.js +109 -0
- package/dist/session/pre-publication-step-execution.d.ts +12 -0
- package/dist/session/pre-publication-step-execution.js +50 -0
- package/dist/session/pre-publication-validation.d.ts +91 -0
- package/dist/session/pre-publication-validation.js +670 -0
- package/dist/session/provider-cli/bridge-cli.conformance-fixtures.d.ts +72 -0
- package/dist/session/provider-cli/bridge-cli.conformance-fixtures.js +462 -0
- package/dist/session/provider-cli/ci-repair-readiness.d.ts +8 -0
- package/dist/session/provider-cli/ci-repair-readiness.js +23 -3
- package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
- package/dist/session/provider-cli/claude-background-work.js +181 -0
- package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
- package/dist/session/provider-cli/host-build-lock.js +30 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +276 -0
- package/dist/session/provider-cli/provider-cli.artifacts.d.ts +6 -3
- package/dist/session/provider-cli/provider-cli.artifacts.js +62 -22
- 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.js +34 -2
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +85 -19
- package/dist/session/provider-cli/provider-cli.process.js +566 -283
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +15 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +211 -36
- package/dist/session/provider-cli/provider-cli.repair-epoch.d.ts +6 -0
- package/dist/session/provider-cli/provider-cli.repair-epoch.js +11 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +22 -1
- package/dist/session/provider-cli/provider-cli.runtime.js +83 -4
- package/dist/session/provider-cli/provider-cli.service.d.ts +36 -5
- package/dist/session/provider-cli/provider-cli.service.js +818 -99
- package/dist/session/provider-cli/provider-cli.types.d.ts +32 -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 +10 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +92 -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 +18 -0
- package/dist/session/provider-cli/provider-output-state.js +376 -17
- package/dist/session/provider-cli/provider-usage.d.ts +9 -1
- package/dist/session/provider-cli/provider-usage.js +28 -5
- 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/publishable-worktree-changes.d.ts +54 -0
- package/dist/session/publishable-worktree-changes.js +193 -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 +257 -0
- package/dist/session/session-redaction.js +284 -9
- package/dist/session/session.base.d.ts +9 -1
- package/dist/session/session.service.d.ts +11 -2
- package/dist/session/session.service.js +301 -58
- package/dist/session/session.types.d.ts +150 -2
- package/dist/session/session.types.js +599 -7
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/session/unreferenced-exports.d.ts +12 -0
- package/dist/session/unreferenced-exports.js +59 -0
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/format/format-bytes.d.ts +1 -0
- package/dist/shared/format/format-bytes.js +9 -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/git/git.js +2 -1
- package/dist/shared/path/path.d.ts +1 -0
- package/dist/shared/path/path.js +18 -0
- package/dist/shared/process/dotnet-toolchain.d.ts +17 -0
- package/dist/shared/process/dotnet-toolchain.js +307 -0
- package/dist/shared/process/host-process-recovery.d.ts +14 -3
- package/dist/shared/process/host-process-recovery.js +26 -5
- package/dist/shared/process/host-process-supervisor.d.ts +16 -1
- package/dist/shared/process/host-process-supervisor.js +124 -23
- 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 +69 -0
- package/dist/shared/process/process.js +223 -16
- 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 +3 -0
- package/dist/shared/provider-capabilities.js +92 -0
- package/dist/shared/redaction/redaction.d.ts +1 -0
- package/dist/shared/redaction/redaction.js +39 -3
- package/dist/shared/time/monotonic.d.ts +1 -0
- package/dist/shared/time/monotonic.js +8 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/dependency-warmer.d.ts +66 -9
- package/dist/worktree/dependency-warmer.js +609 -24
- package/dist/worktree/index.d.ts +1 -1
- package/dist/worktree/story-qa-reference-hydrator.d.ts +4 -0
- package/dist/worktree/story-qa-reference-hydrator.js +253 -0
- package/dist/worktree/wip-git.d.ts +33 -0
- package/dist/worktree/wip-git.js +122 -0
- package/dist/worktree/wip-refs.d.ts +62 -0
- package/dist/worktree/wip-refs.js +119 -0
- package/dist/worktree/wip-restore.d.ts +38 -0
- package/dist/worktree/wip-restore.js +190 -0
- package/dist/worktree/wip-snapshot.d.ts +50 -0
- package/dist/worktree/wip-snapshot.js +268 -0
- package/dist/worktree/worktree-wip-events.d.ts +18 -0
- package/dist/worktree/worktree-wip-events.js +98 -0
- package/dist/worktree/worktree-wip.d.ts +49 -0
- package/dist/worktree/worktree-wip.js +182 -0
- package/dist/worktree/worktree.base.d.ts +7 -1
- package/dist/worktree/worktree.service.d.ts +22 -2
- package/dist/worktree/worktree.service.js +302 -25
- package/dist/worktree/worktree.types.d.ts +36 -1
- package/package.json +8 -6
- package/runtime/windows-job-supervisor.ps1 +380 -14
|
@@ -1,20 +1,34 @@
|
|
|
1
1
|
import { redactRunnerDispatchEvent, redactRunOnceResultPacket } from "./session-redaction.js";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
2
3
|
import { RoutingProviderCliService } from "./provider-cli/provider-cli.service.js";
|
|
3
|
-
import {
|
|
4
|
+
import { ForgeFailureError, waitKindForEvent, waitWakeCondition } from "./session.types.js";
|
|
5
|
+
import { emitWipRestoreEvent, GitWorktreeService, sessionWipOutcome, settleWorktree } from "../worktree/worktree.service.js";
|
|
4
6
|
import { SandboxWorkspaceService } from "../sandbox/workspace.service.js";
|
|
5
|
-
import { HostRuntimeAdmissionExpiredError, hostRuntimeEventResources, } from "../runtime/host-runtime-lease.js";
|
|
7
|
+
import { HostRuntimeAdmissionExpiredError, hostRuntimeEventResources, hostRuntimeStackEnvironmentKeys, runtimeAdmissionPriority, } from "../runtime/host-runtime-lease.js";
|
|
6
8
|
import { configuredLaunchPortNames, hostRuntimeContractFingerprint, hostRuntimeParallelEligible, } from "../runtime/host-runtime-promotion.js";
|
|
9
|
+
import { readWorkspaceRuntimeFingerprint, sameWorkspaceRuntimeFingerprint, workspaceRuntimeFingerprintChanges, } from "./workspace-runtime-fingerprint.js";
|
|
7
10
|
const minimumReadinessProbeStartupBudgetMs = 150_000;
|
|
8
11
|
export class BridgeSessionService {
|
|
9
12
|
worktrees;
|
|
10
13
|
providerCli;
|
|
11
14
|
hostRuntime;
|
|
15
|
+
workspaceFingerprint;
|
|
12
16
|
constructor(worktrees = process.env.FORGE_SANDBOX_ID
|
|
13
17
|
? new SandboxWorkspaceService()
|
|
14
|
-
: new GitWorktreeService(), providerCli = new RoutingProviderCliService(), hostRuntime) {
|
|
18
|
+
: new GitWorktreeService(), providerCli = new RoutingProviderCliService(), hostRuntime, workspaceFingerprint = readWorkspaceRuntimeFingerprint) {
|
|
15
19
|
this.worktrees = worktrees;
|
|
16
20
|
this.providerCli = providerCli;
|
|
17
21
|
this.hostRuntime = hostRuntime;
|
|
22
|
+
this.workspaceFingerprint = workspaceFingerprint;
|
|
23
|
+
}
|
|
24
|
+
setHostRequirementsCheck(check) {
|
|
25
|
+
this.hostRuntime?.setRequirementsCheck?.(check);
|
|
26
|
+
}
|
|
27
|
+
runnerLimitDefaults() {
|
|
28
|
+
return this.hostRuntime?.capacityLimitDefaults?.() ?? null;
|
|
29
|
+
}
|
|
30
|
+
applyRunnerLimits(limits) {
|
|
31
|
+
this.hostRuntime?.applyCapacityLimits?.(limits);
|
|
18
32
|
}
|
|
19
33
|
async updateLease(dispatchAttemptId, fencingToken, expiresAt) {
|
|
20
34
|
await this.hostRuntime?.updateLease(dispatchAttemptId, fencingToken, expiresAt);
|
|
@@ -37,9 +51,12 @@ export class BridgeSessionService {
|
|
|
37
51
|
let cleanupFailure = null;
|
|
38
52
|
try {
|
|
39
53
|
throwIfAborted(signal);
|
|
40
|
-
await this.hostRuntime.invalidatePromotion?.(request.repoId);
|
|
41
54
|
await this.hostRuntime.acquire(dispatch, signal);
|
|
42
55
|
admissionAcquired = true;
|
|
56
|
+
// Readiness probes acquire background-exclusive project admission. Only
|
|
57
|
+
// invalidate the prior proof after that fence is held so a user lane can
|
|
58
|
+
// never observe the proof disappear underneath shared admission.
|
|
59
|
+
await this.hostRuntime.invalidatePromotion?.(request.repoId, "discovery");
|
|
43
60
|
assertReadinessProbeStartupBudget(request.expiresAt);
|
|
44
61
|
worktree = await this.worktrees.prepare({
|
|
45
62
|
repo: dispatch.repo,
|
|
@@ -51,8 +68,13 @@ export class BridgeSessionService {
|
|
|
51
68
|
lane: "runtime_readiness",
|
|
52
69
|
phase: "readiness_probe",
|
|
53
70
|
allowedRepoRoot: request.repoRoot,
|
|
54
|
-
|
|
71
|
+
// Readiness probes are disposable infrastructure checks, not agent lanes.
|
|
72
|
+
// Always remove their worktree even when the bridge is configured to retain
|
|
73
|
+
// failed agent worktrees for inspection.
|
|
74
|
+
cleanupWorktrees: dispatch.serverLocal.cleanupWorktrees,
|
|
55
75
|
artifacts: [],
|
|
76
|
+
hostLoadOwner: { dispatchAttemptId: dispatch.sandbox?.dispatchAttemptId ?? null, priority: "background" },
|
|
77
|
+
signal,
|
|
56
78
|
});
|
|
57
79
|
assertReadinessProbeStartupBudget(request.expiresAt);
|
|
58
80
|
let started = await this.hostRuntime.start(dispatch, worktree.worktreePath, signal);
|
|
@@ -63,6 +85,7 @@ export class BridgeSessionService {
|
|
|
63
85
|
status: "serialized",
|
|
64
86
|
runtimeContractFingerprint: hostRuntimeContractFingerprint(started.runtimeContract),
|
|
65
87
|
runtimeContractSource: started.runtimeContract.source,
|
|
88
|
+
runtimeRequirements: started.runtimeContract.contract.requires ?? null,
|
|
66
89
|
reasonCode: discovery?.reasonCode ?? "host_runtime_contract_serialized",
|
|
67
90
|
reasonMessage: discovery?.summary ?? "The detected runtime requires serialized host execution.",
|
|
68
91
|
checkedAt: new Date().toISOString(),
|
|
@@ -79,6 +102,7 @@ export class BridgeSessionService {
|
|
|
79
102
|
status: "parallel_ready",
|
|
80
103
|
runtimeContractFingerprint: hostRuntimeContractFingerprint(started.runtimeContract),
|
|
81
104
|
runtimeContractSource: started.runtimeContract.source,
|
|
105
|
+
runtimeRequirements: started.runtimeContract.contract.requires ?? null,
|
|
82
106
|
reasonCode: null,
|
|
83
107
|
reasonMessage: null,
|
|
84
108
|
qaAppLaunchTarget: managedQaLaunchTarget(started.runtimeContract),
|
|
@@ -120,18 +144,39 @@ export class BridgeSessionService {
|
|
|
120
144
|
validateApiKeySecretGrant(dispatch);
|
|
121
145
|
const redactionSecrets = exactSecrets(dispatch);
|
|
122
146
|
const events = [];
|
|
147
|
+
let waitObservationVersion = 0;
|
|
148
|
+
const waitFirstObservedAt = new Map();
|
|
149
|
+
const waitObservation = (eventType, queuePosition) => {
|
|
150
|
+
const occurredAt = new Date().toISOString();
|
|
151
|
+
const kind = waitKindForEvent(eventType);
|
|
152
|
+
const firstObservedAt = waitFirstObservedAt.get(kind) ?? occurredAt;
|
|
153
|
+
waitFirstObservedAt.set(kind, firstObservedAt);
|
|
154
|
+
waitObservationVersion += 1;
|
|
155
|
+
const wait = {
|
|
156
|
+
schemaVersion: 2,
|
|
157
|
+
kind,
|
|
158
|
+
scope: "project",
|
|
159
|
+
resourceKeys: [`project-runtime:${dispatch.repo.id}`],
|
|
160
|
+
...(queuePosition === undefined ? {} : { queuePosition }),
|
|
161
|
+
wakeCondition: waitWakeCondition(kind),
|
|
162
|
+
firstObservedAt,
|
|
163
|
+
observationVersion: waitObservationVersion,
|
|
164
|
+
contractOrigin: "bridge_v2",
|
|
165
|
+
};
|
|
166
|
+
return { occurredAt, wait };
|
|
167
|
+
};
|
|
123
168
|
const emit = async (event) => {
|
|
124
169
|
if (signal?.aborted) {
|
|
125
170
|
return;
|
|
126
171
|
}
|
|
127
|
-
const redacted = redactRunnerDispatchEvent(event, redactionSecrets);
|
|
172
|
+
const redacted = redactRunnerDispatchEvent({ ...event, eventId: event.eventId ?? randomUUID() }, redactionSecrets);
|
|
128
173
|
if (redacted.eventType !== "provider_tool_heartbeat") {
|
|
129
174
|
events.push(redacted);
|
|
130
175
|
}
|
|
131
176
|
await sink.emit(redacted);
|
|
132
177
|
};
|
|
133
178
|
const emitLifecycle = async (event) => {
|
|
134
|
-
const redacted = redactRunnerDispatchEvent(event, redactionSecrets);
|
|
179
|
+
const redacted = redactRunnerDispatchEvent({ ...event, eventId: event.eventId ?? randomUUID() }, redactionSecrets);
|
|
135
180
|
events.push(redacted);
|
|
136
181
|
await sink.emit(redacted);
|
|
137
182
|
};
|
|
@@ -145,16 +190,34 @@ export class BridgeSessionService {
|
|
|
145
190
|
let worktree = null;
|
|
146
191
|
let hostSingletonKeys = null;
|
|
147
192
|
let hostLease = null;
|
|
193
|
+
let succeeded = false;
|
|
148
194
|
try {
|
|
149
195
|
if (dispatch.sandbox?.executionMode === "host" && this.hostRuntime) {
|
|
196
|
+
const capacity = this.hostRuntime.snapshot?.() ?? null;
|
|
197
|
+
const projectCapacity = capacity?.projects.find(project => project.repoId === dispatch.repo.id) ?? null;
|
|
198
|
+
const admissionWait = waitObservation("host_runtime_admission_waiting", capacity ? capacity.waitingAttempts + 1 : undefined);
|
|
150
199
|
await emitLifecycle({
|
|
151
200
|
role: "runner",
|
|
152
201
|
kind: "checkpoint",
|
|
153
|
-
content:
|
|
202
|
+
content: capacity
|
|
203
|
+
? `Waiting for host-runtime admission before preparing the worktree (queue position ${capacity.waitingAttempts + 1}; runner ${capacity.activeAttempts} active, ${capacity.reservedAttempts} reserved; project ${projectCapacity?.activeAttempts ?? 0} active, ${projectCapacity?.waitingAttempts ?? 0} already waiting). This wait can be caused by the project serialization policy, readiness proof, or resource headroom; Forge will continue automatically when admission is available.`
|
|
204
|
+
: "Waiting for host-runtime admission before preparing the worktree. Forge will continue automatically when admission is available.",
|
|
154
205
|
eventType: "host_runtime_admission_waiting",
|
|
206
|
+
...admissionWait,
|
|
207
|
+
data: capacity ? JSON.stringify({
|
|
208
|
+
queue_position: capacity.waitingAttempts + 1,
|
|
209
|
+
runner_active_attempts: capacity.activeAttempts,
|
|
210
|
+
runner_reserved_attempts: capacity.reservedAttempts,
|
|
211
|
+
runner_waiting_attempts: capacity.waitingAttempts,
|
|
212
|
+
project_active_attempts: projectCapacity?.activeAttempts ?? 0,
|
|
213
|
+
project_reserved_attempts: projectCapacity?.reservedAttempts ?? 0,
|
|
214
|
+
project_waiting_attempts: projectCapacity?.waitingAttempts ?? 0,
|
|
215
|
+
project_safety_class: projectCapacity?.safetyClass ?? "unknown",
|
|
216
|
+
}) : undefined,
|
|
155
217
|
});
|
|
156
218
|
try {
|
|
157
|
-
hostSingletonKeys = await this.hostRuntime.
|
|
219
|
+
hostSingletonKeys = await (this.hostRuntime.acquirePreparation?.(dispatch, signal)
|
|
220
|
+
?? this.hostRuntime.acquire(dispatch, signal));
|
|
158
221
|
}
|
|
159
222
|
catch (error) {
|
|
160
223
|
if (error instanceof HostRuntimeAdmissionExpiredError) {
|
|
@@ -168,13 +231,17 @@ export class BridgeSessionService {
|
|
|
168
231
|
throw error;
|
|
169
232
|
}
|
|
170
233
|
throwIfAborted(signal);
|
|
234
|
+
const admissionAcquired = waitObservation("host_runtime_admission_acquired");
|
|
171
235
|
await emitLifecycle({
|
|
172
236
|
role: "runner",
|
|
173
237
|
kind: "checkpoint",
|
|
174
|
-
content:
|
|
175
|
-
?
|
|
176
|
-
:
|
|
238
|
+
content: this.hostRuntime.acquirePreparation
|
|
239
|
+
? "Acquired worktree-preparation capacity. Prepared runtime verification must finish before agent admission."
|
|
240
|
+
: hostSingletonKeys.length > 0
|
|
241
|
+
? `Acquired managed host singleton ${hostSingletonKeys.join(", ")}.`
|
|
242
|
+
: "Observed assigned-port evidence permits provisional parallel host admission; the prepared runtime contract must still match before launch.",
|
|
177
243
|
eventType: "host_runtime_admission_acquired",
|
|
244
|
+
...admissionAcquired,
|
|
178
245
|
});
|
|
179
246
|
}
|
|
180
247
|
try {
|
|
@@ -191,21 +258,36 @@ export class BridgeSessionService {
|
|
|
191
258
|
cleanupWorktrees: dispatch.serverLocal.cleanupWorktrees,
|
|
192
259
|
artifacts: dispatch.artifacts,
|
|
193
260
|
priorPhaseArtifacts: dispatch.priorPhaseArtifacts,
|
|
261
|
+
storyQa: dispatch.storyQa,
|
|
262
|
+
referenceRunId: dispatch.sandbox?.dispatchAttemptId ?? dispatch.cycleRun.id,
|
|
263
|
+
referenceCycleRunId: dispatch.cycleRun.id,
|
|
264
|
+
effectivePlanAmendmentHash: dispatch.cycleRun.effectivePlanAmendmentHash,
|
|
194
265
|
qaRework: dispatch.qaRework,
|
|
195
|
-
warmPathOverrides: dispatch.warmPathOverrides
|
|
266
|
+
warmPathOverrides: dispatch.warmPathOverrides,
|
|
267
|
+
applicationRuntimeRequired: dispatch.runtimeIntent.applicationRuntimeRequired,
|
|
268
|
+
preserveExistingState: Boolean(dispatch.session.resumedFromSessionId),
|
|
269
|
+
sessionId: dispatch.session.id,
|
|
270
|
+
hostLoadOwner: {
|
|
271
|
+
dispatchAttemptId: dispatch.sandbox?.dispatchAttemptId ?? null,
|
|
272
|
+
priority: runtimeAdmissionPriority(dispatch),
|
|
273
|
+
},
|
|
274
|
+
signal,
|
|
196
275
|
});
|
|
197
276
|
}
|
|
198
277
|
catch (error) {
|
|
199
|
-
throw new
|
|
278
|
+
throw new ForgeFailureError("worktree_prepare_failed", `worktree_prepare_failed: ${failureMessage(error)}`, "bridge", { cause: error });
|
|
200
279
|
}
|
|
201
280
|
let providerDispatch = withPreparedQaReworkPacket(dispatch, worktree.qaReworkPacketPath);
|
|
202
281
|
throwIfAborted(signal);
|
|
203
282
|
await emit({
|
|
204
283
|
role: "runner",
|
|
205
284
|
kind: "checkpoint",
|
|
206
|
-
content:
|
|
207
|
-
|
|
285
|
+
content: dispatch.session.resumedFromSessionId
|
|
286
|
+
? `Reattached to worktree ${worktree.branchName} without resetting source or clearing attempt artifacts.`
|
|
287
|
+
: `Prepared worktree ${worktree.branchName}.`,
|
|
288
|
+
eventType: dispatch.session.resumedFromSessionId ? "worktree_reattached" : "worktree_prepared"
|
|
208
289
|
});
|
|
290
|
+
await emitWipRestoreEvent(worktree, emit);
|
|
209
291
|
if ((worktree.hydratedPriorPhaseArtifactCount ?? 0) > 0) {
|
|
210
292
|
await emit({
|
|
211
293
|
role: "runner",
|
|
@@ -218,7 +300,17 @@ export class BridgeSessionService {
|
|
|
218
300
|
await emitDependencyWarmEvents(worktree.dependencyWarm, emit);
|
|
219
301
|
}
|
|
220
302
|
if (dispatch.sandbox?.executionMode === "host" && this.hostRuntime) {
|
|
221
|
-
hostLease = await this.hostRuntime.start(dispatch, worktree.worktreePath, signal)
|
|
303
|
+
hostLease = await this.hostRuntime.start(dispatch, worktree.worktreePath, signal, async (checkpoint) => {
|
|
304
|
+
const observation = waitObservation(checkpoint.code);
|
|
305
|
+
await emitLifecycle({
|
|
306
|
+
role: "runner",
|
|
307
|
+
kind: "checkpoint",
|
|
308
|
+
content: checkpoint.message,
|
|
309
|
+
eventType: checkpoint.code,
|
|
310
|
+
...observation,
|
|
311
|
+
data: JSON.stringify({ expires_at: checkpoint.expiresAt }),
|
|
312
|
+
});
|
|
313
|
+
});
|
|
222
314
|
await emitLifecycle({
|
|
223
315
|
role: "runner",
|
|
224
316
|
kind: "checkpoint",
|
|
@@ -238,7 +330,15 @@ export class BridgeSessionService {
|
|
|
238
330
|
}),
|
|
239
331
|
});
|
|
240
332
|
const unconfiguredPortCount = hostLease.lease.resources.ports.length;
|
|
241
|
-
hostLease = await this.hostRuntime.startConfiguredProject(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken, signal)
|
|
333
|
+
hostLease = await this.hostRuntime.startConfiguredProject(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken, signal, async (checkpoint) => {
|
|
334
|
+
await emitLifecycle({
|
|
335
|
+
role: "runner",
|
|
336
|
+
kind: "checkpoint",
|
|
337
|
+
content: checkpoint.message,
|
|
338
|
+
eventType: checkpoint.code,
|
|
339
|
+
data: checkpoint.data ? JSON.stringify(checkpoint.data) : undefined,
|
|
340
|
+
});
|
|
341
|
+
});
|
|
242
342
|
if (hostLease.lease.resources.ports.length > unconfiguredPortCount) {
|
|
243
343
|
const assigned = hostLease.lease.resources.ports.at(-1);
|
|
244
344
|
await emitLifecycle({
|
|
@@ -250,7 +350,98 @@ export class BridgeSessionService {
|
|
|
250
350
|
});
|
|
251
351
|
}
|
|
252
352
|
}
|
|
353
|
+
// The stack was built and launched from this workspace state. Pre-publication
|
|
354
|
+
// validation restarts it when the provider has changed the source since.
|
|
355
|
+
let refreshRuntimeEnvironment;
|
|
356
|
+
const hostRuntime = this.hostRuntime;
|
|
357
|
+
if (hostLease && dispatch.sandbox && hostRuntime?.restartConfiguredProject
|
|
358
|
+
&& hostLease.executionClass === "managed_runtime"
|
|
359
|
+
&& configuredLaunchPortNames(hostLease.runtimeContract).length > 0) {
|
|
360
|
+
const worktreePath = worktree.worktreePath;
|
|
361
|
+
const dispatchAttemptId = dispatch.sandbox.dispatchAttemptId;
|
|
362
|
+
const fencingToken = dispatch.lease.fencingToken;
|
|
363
|
+
const restartConfiguredProject = hostRuntime.restartConfiguredProject.bind(hostRuntime);
|
|
364
|
+
let launchFingerprint = await this.workspaceFingerprint(worktreePath)
|
|
365
|
+
.catch(() => null);
|
|
366
|
+
// Set while the stack may not match the workspace: a failed restart is retried on the next pass.
|
|
367
|
+
let restartPending = false;
|
|
368
|
+
refreshRuntimeEnvironment = async (refreshSignal) => {
|
|
369
|
+
const current = await this.workspaceFingerprint(worktreePath).catch(() => null);
|
|
370
|
+
if (!restartPending && sameWorkspaceRuntimeFingerprint(launchFingerprint, current))
|
|
371
|
+
return null;
|
|
372
|
+
// Every cause that applies is reported; `reason` is the first of them. Changes are named
|
|
373
|
+
// only when both states were read: an unreadable baseline is not a workspace change.
|
|
374
|
+
const comparable = launchFingerprint !== null && current !== null;
|
|
375
|
+
const changes = comparable ? workspaceRuntimeFingerprintChanges(launchFingerprint, current) : [];
|
|
376
|
+
const causes = [
|
|
377
|
+
...(restartPending ? ["previous_restart_incomplete"] : []),
|
|
378
|
+
...(comparable ? [] : ["fingerprint_unavailable"]),
|
|
379
|
+
...(changes.length > 0 ? ["workspace_changed"] : []),
|
|
380
|
+
];
|
|
381
|
+
const reason = causes[0] ?? "workspace_changed";
|
|
382
|
+
const changeText = changes.length > 0 ? ` The workspace also changed since launch (${changes.join(", ")}).` : "";
|
|
383
|
+
await emitLifecycle({
|
|
384
|
+
role: "runner",
|
|
385
|
+
kind: "checkpoint",
|
|
386
|
+
content: reason === "workspace_changed"
|
|
387
|
+
? `The workspace changed since the attempt runtime stack was launched (${changes.join(", ")}); restarting it so validation runs against the current source.`
|
|
388
|
+
: reason === "previous_restart_incomplete"
|
|
389
|
+
? `The previous attempt runtime restart did not complete; restarting it again so validation runs against the current source.${changeText}`
|
|
390
|
+
: `The workspace state could not be compared with the attempt runtime stack; restarting it so validation runs against the current source.`,
|
|
391
|
+
eventType: "host_runtime_restart_started",
|
|
392
|
+
data: JSON.stringify({
|
|
393
|
+
reason,
|
|
394
|
+
causes,
|
|
395
|
+
changes,
|
|
396
|
+
head_sha: current?.headSha ?? null,
|
|
397
|
+
merge_in_progress: Boolean(current?.mergeHead),
|
|
398
|
+
}),
|
|
399
|
+
});
|
|
400
|
+
restartPending = true;
|
|
401
|
+
let restarted;
|
|
402
|
+
try {
|
|
403
|
+
restarted = await restartConfiguredProject(dispatchAttemptId, fencingToken, refreshSignal ?? signal, async (checkpoint) => {
|
|
404
|
+
await emitLifecycle({
|
|
405
|
+
role: "runner",
|
|
406
|
+
kind: "checkpoint",
|
|
407
|
+
content: checkpoint.message,
|
|
408
|
+
eventType: checkpoint.code,
|
|
409
|
+
data: checkpoint.data ? JSON.stringify(checkpoint.data) : undefined,
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
catch (error) {
|
|
414
|
+
await emitLifecycle({
|
|
415
|
+
role: "runner",
|
|
416
|
+
kind: "error",
|
|
417
|
+
content: `Restarting the attempt runtime stack failed: ${failureMessage(error)}`,
|
|
418
|
+
eventType: "host_runtime_restart_failed",
|
|
419
|
+
data: JSON.stringify({ reason, causes, changes }),
|
|
420
|
+
}).catch(() => undefined);
|
|
421
|
+
throw error;
|
|
422
|
+
}
|
|
423
|
+
hostLease = restarted;
|
|
424
|
+
// The restarted stack serves the workspace as it is now. Read that state again rather than
|
|
425
|
+
// keep the pre-restart reading, which is null when it could not be collected; a null
|
|
426
|
+
// baseline never matches, so every later pass would restart and rotate ports again.
|
|
427
|
+
launchFingerprint = await this.workspaceFingerprint(worktreePath).catch(() => current);
|
|
428
|
+
restartPending = false;
|
|
429
|
+
await emitLifecycle({
|
|
430
|
+
role: "runner",
|
|
431
|
+
kind: "checkpoint",
|
|
432
|
+
content: `Restarted the supervised project runtime on ${restarted.lease.resources.ports.map(port => `${port.name} ${port.hostIp}:${port.hostPort}`).join(", ") || "no ports"}.`,
|
|
433
|
+
eventType: "host_runtime_restarted",
|
|
434
|
+
data: JSON.stringify(hostRuntimeEventResources(restarted.lease, restarted.runtimeContract, restarted.executionClass)),
|
|
435
|
+
});
|
|
436
|
+
return { environment: restarted.environment, reason, changes };
|
|
437
|
+
};
|
|
438
|
+
}
|
|
253
439
|
providerDispatch = withMaterializedManagedQaTarget(providerDispatch, hostLease);
|
|
440
|
+
const providerEnvironment = {
|
|
441
|
+
runtimeEnvironment: hostLease?.environment,
|
|
442
|
+
// Only the completion MCP server gets these: its managed commands share the host ledger.
|
|
443
|
+
hostLoadEnvironment: hostLease ? this.hostRuntime?.hostLoadChildEnvironment?.() : undefined,
|
|
444
|
+
};
|
|
254
445
|
if (dispatch.draft) {
|
|
255
446
|
throwIfAborted(signal);
|
|
256
447
|
const processRunner = hostLease && dispatch.sandbox
|
|
@@ -259,15 +450,16 @@ export class BridgeSessionService {
|
|
|
259
450
|
const run = await this.providerCli.runDraft({
|
|
260
451
|
dispatch: providerDispatch,
|
|
261
452
|
worktree,
|
|
262
|
-
|
|
453
|
+
...providerEnvironment,
|
|
263
454
|
processRunner,
|
|
264
455
|
emit,
|
|
265
456
|
signal
|
|
266
457
|
});
|
|
267
458
|
throwIfAborted(signal);
|
|
268
459
|
const draftArtifacts = run.artifacts?.length ? run.artifacts : run.artifact ? [run.artifact] : [];
|
|
460
|
+
succeeded = true;
|
|
269
461
|
return redactRunOnceResultPacket({
|
|
270
|
-
schemaVersion:
|
|
462
|
+
schemaVersion: 2,
|
|
271
463
|
exitCode: 0,
|
|
272
464
|
summary: run.summary,
|
|
273
465
|
events,
|
|
@@ -287,10 +479,13 @@ export class BridgeSessionService {
|
|
|
287
479
|
const context = {
|
|
288
480
|
dispatch: providerDispatch,
|
|
289
481
|
worktree,
|
|
290
|
-
|
|
482
|
+
...providerEnvironment,
|
|
291
483
|
processRunner: hostLease && dispatch.sandbox
|
|
292
484
|
? this.hostRuntime?.providerProcessRunner?.(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken) ?? undefined
|
|
293
485
|
: undefined,
|
|
486
|
+
...(refreshRuntimeEnvironment && hostLease
|
|
487
|
+
? { refreshRuntimeEnvironment, runtimeStackEnvironmentKeys: hostRuntimeStackEnvironmentKeys(hostLease.runtimeContract) }
|
|
488
|
+
: {}),
|
|
294
489
|
emit,
|
|
295
490
|
signal
|
|
296
491
|
};
|
|
@@ -308,18 +503,22 @@ export class BridgeSessionService {
|
|
|
308
503
|
}
|
|
309
504
|
catch (error) {
|
|
310
505
|
const message = failureMessage(error);
|
|
311
|
-
if (
|
|
312
|
-
|
|
313
|
-
|
|
506
|
+
if (error instanceof ForgeFailureError
|
|
507
|
+
&& (error.failureCode === "attempt_process_supervisor_start_failed"
|
|
508
|
+
|| error.failureCode === "attempt_process_supervisor_start_timeout")) {
|
|
509
|
+
throw new ForgeFailureError("provider_start_unavailable", `provider_start_unavailable: ${message}`, "bridge", { cause: error });
|
|
314
510
|
}
|
|
315
511
|
throw error;
|
|
316
512
|
}
|
|
317
513
|
throwIfAborted(signal);
|
|
318
514
|
const phaseArtifacts = run.artifacts?.length ? run.artifacts : run.artifact ? [run.artifact] : [];
|
|
515
|
+
succeeded = true;
|
|
319
516
|
return redactRunOnceResultPacket({
|
|
320
|
-
schemaVersion:
|
|
517
|
+
schemaVersion: 2,
|
|
321
518
|
exitCode: 0,
|
|
322
519
|
summary: run.summary,
|
|
520
|
+
resultCommitSha: run.resultCommitSha ?? null,
|
|
521
|
+
publishedCommitSha: run.publishedCommitSha ?? null,
|
|
323
522
|
events,
|
|
324
523
|
spec: run.spec ?? null,
|
|
325
524
|
artifact: run.artifact ?? null,
|
|
@@ -327,57 +526,84 @@ export class BridgeSessionService {
|
|
|
327
526
|
}, redactionSecrets);
|
|
328
527
|
}
|
|
329
528
|
finally {
|
|
330
|
-
|
|
331
|
-
|
|
529
|
+
await this.releaseHostRuntime(dispatch, hostLease, hostSingletonKeys, emitLifecycle);
|
|
530
|
+
if (worktree) {
|
|
531
|
+
await settleWorktree(this.worktrees, worktree, sessionWipOutcome(signal, events, succeeded), signal, emitLifecycle);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
/** Reports the provider's peak memory and releases the attempt's host runtime lease. */
|
|
536
|
+
async releaseHostRuntime(dispatch, hostLease, hostSingletonKeys, emitLifecycle) {
|
|
537
|
+
if (hostLease && dispatch.sandbox) {
|
|
538
|
+
const providerMemory = this.hostRuntime?.providerMemoryTelemetry?.(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken);
|
|
539
|
+
if (providerMemory) {
|
|
332
540
|
await emitLifecycle({
|
|
333
541
|
role: "runner",
|
|
334
542
|
kind: "checkpoint",
|
|
335
|
-
content: `
|
|
336
|
-
eventType: "
|
|
337
|
-
occurredAt:
|
|
543
|
+
content: `Observed managed-host provider process-tree peak memory ${formatMemoryBytes(providerMemory.peakMemoryBytes)} from ${providerMemory.sampleCount} sample${providerMemory.sampleCount === 1 ? "" : "s"}.`,
|
|
544
|
+
eventType: "sandbox_peak_memory_observed",
|
|
545
|
+
occurredAt: providerMemory.observedAt,
|
|
546
|
+
data: JSON.stringify({
|
|
547
|
+
peakMemoryBytes: providerMemory.peakMemoryBytes,
|
|
548
|
+
sampleCount: providerMemory.sampleCount,
|
|
549
|
+
source: providerMemory.source,
|
|
550
|
+
containers: [{
|
|
551
|
+
role: "agent",
|
|
552
|
+
peakMemoryBytes: providerMemory.peakMemoryBytes,
|
|
553
|
+
}],
|
|
554
|
+
}),
|
|
338
555
|
}).catch(() => undefined);
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
await emitLifecycle({
|
|
352
|
-
role: "runner",
|
|
353
|
-
kind: "checkpoint",
|
|
354
|
-
content: `Released host runtime lease ${released.leaseId}.`,
|
|
355
|
-
eventType: "sandbox_teardown_completed",
|
|
356
|
-
occurredAt: released.releasedAt,
|
|
357
|
-
}).catch(() => undefined);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
catch (error) {
|
|
556
|
+
}
|
|
557
|
+
const teardownAt = new Date().toISOString();
|
|
558
|
+
await emitLifecycle({
|
|
559
|
+
role: "runner",
|
|
560
|
+
kind: "checkpoint",
|
|
561
|
+
content: `Releasing host runtime lease ${hostLease.lease.leaseId}.`,
|
|
562
|
+
eventType: "sandbox_teardown_started",
|
|
563
|
+
occurredAt: teardownAt,
|
|
564
|
+
}).catch(() => undefined);
|
|
565
|
+
try {
|
|
566
|
+
const released = await this.hostRuntime?.release(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken);
|
|
567
|
+
if (!released) {
|
|
361
568
|
await emitLifecycle({
|
|
362
569
|
role: "runner",
|
|
363
570
|
kind: "error",
|
|
364
|
-
content:
|
|
571
|
+
content: "Host runtime cleanup requires reconciliation: the runtime lease was not current during release.",
|
|
365
572
|
eventType: "teardown_failed",
|
|
366
573
|
occurredAt: new Date().toISOString(),
|
|
367
574
|
}).catch(() => undefined);
|
|
368
575
|
}
|
|
576
|
+
else {
|
|
577
|
+
await emitLifecycle({
|
|
578
|
+
role: "runner",
|
|
579
|
+
kind: "checkpoint",
|
|
580
|
+
content: `Released host runtime lease ${released.leaseId}. Diagnostics remain runner-local.`,
|
|
581
|
+
eventType: "sandbox_teardown_completed",
|
|
582
|
+
occurredAt: released.releasedAt,
|
|
583
|
+
}).catch(() => undefined);
|
|
584
|
+
}
|
|
369
585
|
}
|
|
370
|
-
|
|
371
|
-
await
|
|
586
|
+
catch (error) {
|
|
587
|
+
await emitLifecycle({
|
|
588
|
+
role: "runner",
|
|
589
|
+
kind: "error",
|
|
590
|
+
content: `Host runtime cleanup requires reconciliation: ${error instanceof Error ? error.message : String(error)}`,
|
|
591
|
+
eventType: "teardown_failed",
|
|
592
|
+
occurredAt: new Date().toISOString(),
|
|
593
|
+
}).catch(() => undefined);
|
|
372
594
|
}
|
|
373
|
-
|
|
374
|
-
|
|
595
|
+
}
|
|
596
|
+
if (!hostLease && hostSingletonKeys && dispatch.sandbox) {
|
|
597
|
+
await this.hostRuntime?.release(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken).catch(() => undefined);
|
|
375
598
|
}
|
|
376
599
|
}
|
|
377
600
|
}
|
|
378
601
|
function failureMessage(error) {
|
|
379
602
|
return error instanceof Error ? error.message : String(error);
|
|
380
603
|
}
|
|
604
|
+
function formatMemoryBytes(bytes) {
|
|
605
|
+
return `${(bytes / (1024 ** 2)).toFixed(bytes >= 1024 ** 3 ? 0 : 1)} MiB`;
|
|
606
|
+
}
|
|
381
607
|
function readinessProbeDispatch(request) {
|
|
382
608
|
return {
|
|
383
609
|
schemaVersion: 2,
|
|
@@ -433,7 +659,7 @@ function readinessProbeDispatch(request) {
|
|
|
433
659
|
runnerRepoLocalPath: request.runnerRepoLocalPath,
|
|
434
660
|
},
|
|
435
661
|
runtimeIntent: { executionClass: "managed_runtime", applicationRuntimeRequired: true },
|
|
436
|
-
serverLocal: { repoRoot: request.repoRoot, cleanupWorktrees:
|
|
662
|
+
serverLocal: { repoRoot: request.repoRoot, cleanupWorktrees: true },
|
|
437
663
|
sandbox: {
|
|
438
664
|
dispatchAttemptId: request.requestId,
|
|
439
665
|
executionLeaseId: request.requestId,
|
|
@@ -552,6 +778,23 @@ function withPreparedQaReworkPacket(dispatch, packetPath) {
|
|
|
552
778
|
};
|
|
553
779
|
}
|
|
554
780
|
async function emitDependencyWarmEvents(warm, emit) {
|
|
781
|
+
for (const receipt of warm.receipts) {
|
|
782
|
+
await emit({
|
|
783
|
+
role: "runner",
|
|
784
|
+
kind: "checkpoint",
|
|
785
|
+
content: receipt.cacheHit
|
|
786
|
+
? `Reused verified ${receipt.ecosystem} dependency preparation receipt ${receipt.fingerprint} in ${receipt.packageRoot}.`
|
|
787
|
+
: `Published ${receipt.ecosystem} dependency preparation receipt ${receipt.fingerprint} in ${receipt.packageRoot}.`,
|
|
788
|
+
eventType: receipt.cacheHit ? "dependencies_preparation_cached" : "dependencies_preparation_receipt_published",
|
|
789
|
+
data: JSON.stringify({
|
|
790
|
+
ecosystem: receipt.ecosystem,
|
|
791
|
+
package_root: receipt.packageRoot,
|
|
792
|
+
cache_hit: receipt.cacheHit,
|
|
793
|
+
fingerprint: receipt.fingerprint,
|
|
794
|
+
receipt_path: receipt.receiptPath,
|
|
795
|
+
}),
|
|
796
|
+
});
|
|
797
|
+
}
|
|
555
798
|
if (warm.linked.length > 0) {
|
|
556
799
|
await emit({
|
|
557
800
|
role: "runner",
|