@loucompanion/forge-bridge 0.1.4-dev.fb770705136a → 0.2.1-dev.0f8fb73715e8
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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { HostProcessRecovery, HostProcessRecoveryOutcome } from "../shared/process/host-process-recovery.js";
|
|
2
|
+
import type { PinnedDirectoryIdentity } from "./pinned-directory-process.js";
|
|
3
|
+
import type { RuntimeIsolationLease } from "./runtime-isolation-lease.js";
|
|
4
|
+
/**
|
|
5
|
+
* Replaces a host runtime ledger with its fully written temporary file. Windows refuses
|
|
6
|
+
* to replace a file another handle has open (EPERM), for example while a recovery pass
|
|
7
|
+
* reads the same ledger, so a transient refusal is retried for about a second, as the
|
|
8
|
+
* attempt supervisor does for its own ledger.
|
|
9
|
+
*/
|
|
10
|
+
export declare function replaceHostRuntimeLedgerFile(temporary: string, target: string, retryMs?: number): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Maintenance retry of a degraded lease's fenced release. The release frees the slot only
|
|
13
|
+
* after its teardown proves the attempt's supervised process tree stopped (the supervisor
|
|
14
|
+
* is stopped with no live child or managed command); otherwise the lease stays degraded
|
|
15
|
+
* and the log says why. Returns whether the lease was released.
|
|
16
|
+
*/
|
|
17
|
+
export declare function retryDegradedHostRelease(lease: RuntimeIsolationLease, release: () => Promise<RuntimeIsolationLease | null>, log: (message: string) => void): Promise<boolean>;
|
|
18
|
+
export declare function logHostRuntimeStatus(message: string): void;
|
|
19
|
+
/** Exact, fenced recovery of the process trees a lease's attempt recorded under its attempt root. */
|
|
20
|
+
export declare function recoverPersistedHostProcesses(lease: RuntimeIsolationLease, attemptRoot: string, expectedAttemptRoot: string, attemptRootIdentity: PinnedDirectoryIdentity, processRecovery: HostProcessRecovery): Promise<readonly HostProcessRecoveryOutcome[]>;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { readCanonicalSourceFile } from "./canonical-source-file.js";
|
|
4
|
+
import { assertHostAttemptRootIdentity } from "./host-diagnostics.js";
|
|
5
|
+
import { terminateAttemptManagedCommands } from "./managed-command-teardown.js";
|
|
6
|
+
import { readPinnedSourceDirectory } from "./pinned-source-directory.js";
|
|
7
|
+
// Host runtime ledger persistence and recovery helpers shared by HostRuntimeLeaseManager.
|
|
8
|
+
const maximumProcessRecoveryMetadataBytes = 1024 * 1024;
|
|
9
|
+
const ledgerReplaceAttempts = 40;
|
|
10
|
+
const transientLedgerReplaceCodes = new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
11
|
+
/**
|
|
12
|
+
* Replaces a host runtime ledger with its fully written temporary file. Windows refuses
|
|
13
|
+
* to replace a file another handle has open (EPERM), for example while a recovery pass
|
|
14
|
+
* reads the same ledger, so a transient refusal is retried for about a second, as the
|
|
15
|
+
* attempt supervisor does for its own ledger.
|
|
16
|
+
*/
|
|
17
|
+
export async function replaceHostRuntimeLedgerFile(temporary, target, retryMs = 25) {
|
|
18
|
+
for (let attempt = 1;; attempt += 1) {
|
|
19
|
+
try {
|
|
20
|
+
await fs.rename(temporary, target);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const code = error.code;
|
|
25
|
+
if (attempt >= ledgerReplaceAttempts || !code || !transientLedgerReplaceCodes.has(code))
|
|
26
|
+
throw error;
|
|
27
|
+
await new Promise(resolve => setTimeout(resolve, retryMs));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Maintenance retry of a degraded lease's fenced release. The release frees the slot only
|
|
33
|
+
* after its teardown proves the attempt's supervised process tree stopped (the supervisor
|
|
34
|
+
* is stopped with no live child or managed command); otherwise the lease stays degraded
|
|
35
|
+
* and the log says why. Returns whether the lease was released.
|
|
36
|
+
*/
|
|
37
|
+
export async function retryDegradedHostRelease(lease, release, log) {
|
|
38
|
+
const subject = `host runtime lease ${lease.leaseId} of attempt ${lease.dispatchAttemptId}`;
|
|
39
|
+
try {
|
|
40
|
+
const released = await release();
|
|
41
|
+
if (released?.state === "released") {
|
|
42
|
+
log(`Released degraded ${subject}: teardown proved its supervised process tree stopped, so its project runtime slot is free.`);
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
log(`Degraded ${subject} stays degraded: its fencing token no longer owns the attempt.`);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
log(`Degraded ${subject} stays degraded: ${error instanceof Error ? error.message : String(error)}`);
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
export function logHostRuntimeStatus(message) {
|
|
53
|
+
process.stderr.write(`[${new Date().toISOString()}] ${message}\n`);
|
|
54
|
+
}
|
|
55
|
+
/** Exact, fenced recovery of the process trees a lease's attempt recorded under its attempt root. */
|
|
56
|
+
export async function recoverPersistedHostProcesses(lease, attemptRoot, expectedAttemptRoot, attemptRootIdentity, processRecovery) {
|
|
57
|
+
const logsRoot = path.join(attemptRoot, "logs");
|
|
58
|
+
if (path.resolve(attemptRoot) !== path.resolve(expectedAttemptRoot)) {
|
|
59
|
+
throw new Error("host_runtime_reaper_invalid: attempt path is outside the fenced attempt root.");
|
|
60
|
+
}
|
|
61
|
+
await assertHostAttemptRootIdentity(attemptRoot, attemptRootIdentity);
|
|
62
|
+
const rootEntries = await readPinnedSourceDirectory(attemptRoot, attemptRootIdentity);
|
|
63
|
+
const logsEntry = rootEntries.find(entry => entry.name === "logs");
|
|
64
|
+
if (!logsEntry)
|
|
65
|
+
return [];
|
|
66
|
+
if (logsEntry.kind !== "directory") {
|
|
67
|
+
throw new Error("host_runtime_reaper_invalid: process ownership log path is not an ordinary directory.");
|
|
68
|
+
}
|
|
69
|
+
const outcomes = [];
|
|
70
|
+
const failures = [];
|
|
71
|
+
try {
|
|
72
|
+
const entries = await readPinnedSourceDirectory(logsRoot, logsEntry.identity);
|
|
73
|
+
for (const entry of entries) {
|
|
74
|
+
if (entry.kind !== "file" || !/^process-supervisor\.[a-z][a-z0-9_-]{0,31}\.\d+\.json$/u.test(entry.name))
|
|
75
|
+
continue;
|
|
76
|
+
const metadataPath = path.join(logsRoot, entry.name);
|
|
77
|
+
const value = JSON.parse((await readCanonicalSourceFile(metadataPath, maximumProcessRecoveryMetadataBytes, entry.identity)).toString("utf8"));
|
|
78
|
+
if (!validHostProcessSupervisorMetadata(value, lease)) {
|
|
79
|
+
throw new Error("host_runtime_reaper_invalid: process ownership metadata did not match the runtime lease.");
|
|
80
|
+
}
|
|
81
|
+
outcomes.push(await processRecovery.recover(value));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
failures.push(error);
|
|
86
|
+
}
|
|
87
|
+
// Managed commands run in their own process groups and record their ownership apart
|
|
88
|
+
// from the attempt's supervised children. They are recovered even when recovering a
|
|
89
|
+
// supervised child failed, and both failures are reported together.
|
|
90
|
+
try {
|
|
91
|
+
const managed = await terminateAttemptManagedCommands({
|
|
92
|
+
logDirectory: logsRoot,
|
|
93
|
+
dispatchAttemptId: lease.dispatchAttemptId,
|
|
94
|
+
runtimeLeaseId: lease.executionLeaseId,
|
|
95
|
+
pinnedLogDirectory: logsEntry.identity,
|
|
96
|
+
}, { reason: "attempt_teardown" });
|
|
97
|
+
for (const command of managed) {
|
|
98
|
+
if (command.outcome === "terminated" || command.outcome === "pid_reused")
|
|
99
|
+
outcomes.push(command.outcome);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
failures.push(error);
|
|
104
|
+
}
|
|
105
|
+
if (failures.length === 1)
|
|
106
|
+
throw failures[0];
|
|
107
|
+
if (failures.length > 1)
|
|
108
|
+
throw new AggregateError(failures, "host_runtime_reaper_recovery_failed");
|
|
109
|
+
return outcomes;
|
|
110
|
+
}
|
|
111
|
+
function validHostProcessSupervisorMetadata(value, lease) {
|
|
112
|
+
if (typeof value !== "object" || value === null)
|
|
113
|
+
return false;
|
|
114
|
+
const metadata = value;
|
|
115
|
+
return metadata.schemaVersion === 1
|
|
116
|
+
&& /^host-[0-9a-f]{32}$/u.test(metadata.supervisorId)
|
|
117
|
+
&& (metadata.strategy === "windows_job_object" || metadata.strategy === "unix_process_group")
|
|
118
|
+
&& Number.isSafeInteger(metadata.rootPid)
|
|
119
|
+
&& metadata.rootPid > 0
|
|
120
|
+
&& Number.isFinite(Date.parse(metadata.rootCreatedAt))
|
|
121
|
+
&& (metadata.rootIdentity == null
|
|
122
|
+
|| (typeof metadata.rootIdentity === "string" && metadata.rootIdentity.length <= 256))
|
|
123
|
+
&& /^[0-9a-f]{64}$/u.test(metadata.commandDigest)
|
|
124
|
+
&& containedMetadataWorktreePath(lease.worktreePath, metadata.worktreePath)
|
|
125
|
+
&& metadata.runtimeLeaseId === lease.executionLeaseId
|
|
126
|
+
&& metadata.dispatchAttemptId === lease.dispatchAttemptId
|
|
127
|
+
&& metadata.fencingToken === lease.fencingToken
|
|
128
|
+
&& Number.isSafeInteger(metadata.bridgePid)
|
|
129
|
+
&& metadata.bridgePid > 0;
|
|
130
|
+
}
|
|
131
|
+
function containedMetadataWorktreePath(worktreePath, metadataWorktreePath) {
|
|
132
|
+
const relative = path.relative(path.resolve(worktreePath), path.resolve(metadataWorktreePath));
|
|
133
|
+
return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
|
|
134
|
+
}
|
|
@@ -5,6 +5,8 @@ export interface HostParallelPromotionRecord {
|
|
|
5
5
|
readonly runtimeContractFingerprint: string;
|
|
6
6
|
readonly inputCommitSha?: string | null;
|
|
7
7
|
readonly sourceFingerprint?: string;
|
|
8
|
+
/** Identity of the isolation inputs the probe ran with; lets other heads with identical inputs reuse it. */
|
|
9
|
+
readonly isolationFingerprint?: string;
|
|
8
10
|
readonly runtimeContractSource?: "project" | "derived";
|
|
9
11
|
readonly observedAt: string;
|
|
10
12
|
readonly observedDispatchAttemptId: string;
|
|
@@ -14,19 +16,116 @@ export interface HostParallelProofIdentity {
|
|
|
14
16
|
readonly runtimeContractFingerprint: string;
|
|
15
17
|
readonly inputCommitSha: string;
|
|
16
18
|
readonly sourceFingerprint?: string;
|
|
19
|
+
readonly isolationFingerprint?: string;
|
|
17
20
|
}
|
|
18
21
|
/** Persists only observed, contract-bound host parallel-safety evidence. */
|
|
19
22
|
export declare class HostParallelPromotionStore {
|
|
20
23
|
private readonly stateRoot;
|
|
24
|
+
/**
|
|
25
|
+
* Repositories whose full invalidation has started but not been confirmed on disk. They
|
|
26
|
+
* have no proof until a retried invalidation succeeds, so a failed delete cannot leave
|
|
27
|
+
* stale records admitting shared runs. A tombstone file beside the records carries the same
|
|
28
|
+
* state to other store instances and across restarts.
|
|
29
|
+
*/
|
|
30
|
+
private readonly revoked;
|
|
31
|
+
/** Bumped by every full invalidation, so a read that raced one is discarded. */
|
|
32
|
+
private readonly revocations;
|
|
33
|
+
/** How long an isolation violation keeps its runtime contract from earning parallel proof again. */
|
|
34
|
+
quarantineMs: number;
|
|
35
|
+
/** Quarantines this instance holds whether or not they reached disk: a failed write cannot lift one. */
|
|
36
|
+
private readonly heldQuarantines;
|
|
37
|
+
/** Per repository, so concurrent invalidations and quarantine writes cannot lose each other's entries. */
|
|
38
|
+
private readonly serialQueues;
|
|
21
39
|
constructor(stateRoot: string);
|
|
40
|
+
/**
|
|
41
|
+
* With an identity, returns proof for it: first a proof observed for the same isolation
|
|
42
|
+
* inputs (runtime contract plus launch-relevant files) at any commit, then a proof for the
|
|
43
|
+
* exact prepared source. The record keeps the commit it was observed at for audit.
|
|
44
|
+
*/
|
|
22
45
|
load(repoId: string, identity?: HostParallelProofIdentity): Promise<HostParallelPromotionRecord | null>;
|
|
46
|
+
private readProof;
|
|
47
|
+
private isRevoked;
|
|
48
|
+
private readRecord;
|
|
23
49
|
list(): Promise<readonly HostParallelPromotionRecord[]>;
|
|
24
|
-
observe(repoId: string, runtimeContract: LoadedHostRuntimeContract, dispatchAttemptId: string, verifiedPortNames: readonly string[], inputCommitSha?: string, sourceFingerprint?: string): Promise<HostParallelPromotionRecord>;
|
|
50
|
+
observe(repoId: string, runtimeContract: LoadedHostRuntimeContract, dispatchAttemptId: string, verifiedPortNames: readonly string[], inputCommitSha?: string, sourceFingerprint?: string, isolationFingerprint?: string, revocationGeneration?: string): Promise<HostParallelPromotionRecord>;
|
|
51
|
+
/** Deletes each record file that still holds this record; one a newer proof has since replaced is left alone. */
|
|
52
|
+
private withdrawRecords;
|
|
53
|
+
/**
|
|
54
|
+
* The repository's revocation generation. A probe captures it at admission and passes it to
|
|
55
|
+
* observe, which then refuses to record if any full invalidation happened since: a violation by
|
|
56
|
+
* the probe itself or by a sibling means the run it watched does not prove isolation. It joins this
|
|
57
|
+
* instance's counter (bumped before any record is touched) with the repository's durable epoch, which
|
|
58
|
+
* every full invalidation bumps before deleting records, so one by another instance fences it too.
|
|
59
|
+
*/
|
|
60
|
+
revocationGeneration(repoId: string): Promise<string>;
|
|
61
|
+
/** A missing epoch is "0"; an unreadable one throws, so a caller fails closed rather than fencing nothing. */
|
|
62
|
+
private readEpoch;
|
|
63
|
+
/** A fresh random epoch rather than a read-modify-write, so concurrent bumps by two processes cannot cancel out. */
|
|
64
|
+
private bumpEpoch;
|
|
65
|
+
private epochPath;
|
|
66
|
+
/**
|
|
67
|
+
* Called on an isolation violation, before the proofs are revoked. A launch-time audit cannot see
|
|
68
|
+
* a listener bound later, and ordinary source is not an isolation input, so without this the next
|
|
69
|
+
* exclusive run of the same contract would re-earn proof at launch and readmit the shared runs that
|
|
70
|
+
* just collided. A quarantine lasts quarantineMs, or until the runtime contract changes.
|
|
71
|
+
*/
|
|
72
|
+
quarantine(repoId: string, runtimeContractFingerprint: string): Promise<void>;
|
|
73
|
+
/** Whether the contract is quarantined, so callers can skip a probe or launch that could never earn proof. */
|
|
74
|
+
quarantined(repoId: string, runtimeContractFingerprint: string): Promise<boolean>;
|
|
75
|
+
private serialized;
|
|
76
|
+
private holdQuarantine;
|
|
77
|
+
private persistQuarantine;
|
|
78
|
+
private isQuarantined;
|
|
79
|
+
/** Unreadable or malformed quarantine state reads as empty; a missing file is the normal case. */
|
|
80
|
+
private readQuarantine;
|
|
81
|
+
private quarantinePath;
|
|
82
|
+
private revokedSince;
|
|
25
83
|
private writeRecord;
|
|
26
84
|
private pruneVersions;
|
|
27
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Deletes the repository's proofs. A full invalidation revokes them in memory first and
|
|
87
|
+
* lifts that only once every record is confirmed deleted, so it fails closed: until then
|
|
88
|
+
* load and list return nothing for the repository and observe refuses to record.
|
|
89
|
+
*/
|
|
90
|
+
invalidate(repoId: string, scope?: "all" | "discovery", quarantineFingerprints?: readonly string[]): Promise<void>;
|
|
91
|
+
private revokeAll;
|
|
92
|
+
private writeTombstone;
|
|
93
|
+
/** The quarantine a tombstone carries; an older plain-timestamp tombstone, or none, carries nothing. */
|
|
94
|
+
private readTombstoneQuarantine;
|
|
95
|
+
private tombstonePath;
|
|
96
|
+
private removeRecords;
|
|
28
97
|
private recordPath;
|
|
98
|
+
private isolationRecordPath;
|
|
29
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Whether a stored proof admits this identity. An identity with isolation inputs (a prepared
|
|
102
|
+
* proof) needs the same isolation inputs, at any commit; one without them (an unprepared run)
|
|
103
|
+
* needs the same commit.
|
|
104
|
+
*/
|
|
105
|
+
export declare function hostParallelPromotionMatches(record: HostParallelPromotionRecord | null, identity: HostParallelProofIdentity): boolean;
|
|
30
106
|
export declare function hostRuntimeContractFingerprint(runtimeContract: LoadedHostRuntimeContract): string;
|
|
107
|
+
export interface ReadmittedHostRuntimeContract {
|
|
108
|
+
readonly runtimeContract: LoadedHostRuntimeContract;
|
|
109
|
+
readonly runtimeContractFingerprint: string;
|
|
110
|
+
readonly changed: boolean;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Decides whether a restart may run the workspace's current runtime contract under the admission
|
|
114
|
+
* granted at start. A restart relaunches from the workspace in any case, so a contract whose only
|
|
115
|
+
* change is the values its ports launch with (launch environment, or discovery inputs that leave
|
|
116
|
+
* the contract itself unchanged) is adopted. This is how a conflict repair survives its own merge:
|
|
117
|
+
* merging the target branch can rename a variable in a derived launch profile, or change a
|
|
118
|
+
* manifest or project file, without changing anything admission granted. Every other part of the
|
|
119
|
+
* contract is admission: source, concurrency, ports (names, adapters, environment names, URL
|
|
120
|
+
* formats, and the command, arguments and working directory that launch them), Playwright, browser
|
|
121
|
+
* profile, singleton resources and declared requirements. Changing any of those throws the
|
|
122
|
+
* retryable host_runtime_contract_changed, so only a fresh attempt runs that contract. An attempt
|
|
123
|
+
* admitted to run in parallel keeps that admission, as it does when a merge changes only source;
|
|
124
|
+
* a restart never promotes, so the adopted contract earns no parallel-safety proof of its own here.
|
|
125
|
+
*/
|
|
126
|
+
export declare function readmitHostRuntimeContract(admitted: {
|
|
127
|
+
readonly runtimeContract: LoadedHostRuntimeContract;
|
|
128
|
+
readonly runtimeContractFingerprint: string;
|
|
129
|
+
}, current: LoadedHostRuntimeContract): ReadmittedHostRuntimeContract;
|
|
31
130
|
export declare function hostRuntimeParallelEligible(runtimeContract: LoadedHostRuntimeContract): boolean;
|
|
32
131
|
export declare function configuredLaunchPortNames(runtimeContract: LoadedHostRuntimeContract): readonly string[];
|