@loucompanion/forge-bridge 0.1.3-dev.f66395c3ac21 → 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 +306 -1
- 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 +18 -1
- package/dist/bridge/bridge.service.d.ts +216 -4
- package/dist/bridge/bridge.service.js +2574 -90
- package/dist/bridge/bridge.types.d.ts +245 -2
- 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 +33 -2
- package/dist/cleanup/cleanup.service.js +477 -3
- package/dist/cleanup/cleanup.types.d.ts +16 -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/index.d.ts +1 -1
- package/dist/cleanup/index.js +1 -1
- package/dist/cleanup/internals.d.ts +2 -2
- package/dist/cleanup/internals.js +1 -1
- package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
- package/dist/cleanup/managed-branch-sweep.js +111 -0
- package/dist/cli/cli.help.d.ts +2 -0
- package/dist/cli/cli.help.js +279 -0
- package/dist/cli/cli.service.d.ts +69 -12
- package/dist/cli/cli.service.js +557 -382
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +13 -0
- package/dist/cli/local-config.js +82 -6
- 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 +18 -0
- package/dist/runtime/attempt-node-runtime-launcher.js +140 -0
- 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-registry.d.ts +20 -0
- package/dist/runtime/attempt-process-supervisor-registry.js +64 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +121 -0
- package/dist/runtime/attempt-process-supervisor.js +471 -0
- 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 +20 -0
- package/dist/runtime/generated-output-reset.js +157 -0
- 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 +51 -0
- package/dist/runtime/host-listener-inspector.js +385 -0
- 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-port-broker.d.ts +76 -0
- package/dist/runtime/host-port-broker.js +333 -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 +74 -0
- package/dist/runtime/host-runtime-contract.js +846 -0
- package/dist/runtime/host-runtime-lease.d.ts +287 -0
- package/dist/runtime/host-runtime-lease.js +2763 -0
- package/dist/runtime/host-runtime-promotion.d.ts +55 -0
- package/dist/runtime/host-runtime-promotion.js +254 -0
- package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
- package/dist/runtime/host-runtime-requirements-check.js +29 -0
- package/dist/runtime/host-runtime-requirements.d.ts +36 -0
- package/dist/runtime/host-runtime-requirements.js +117 -0
- package/dist/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 +54 -0
- package/dist/runtime/node-host-runtime-adapter.js +286 -0
- 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 +39 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +274 -0
- 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.d.ts +67 -0
- package/dist/runtime/runtime-isolation-lease.js +161 -0
- package/dist/runtime/workspace-resource-estimator.d.ts +17 -0
- package/dist/runtime/workspace-resource-estimator.js +174 -0
- package/dist/sandbox/command-runner.d.ts +4 -0
- package/dist/sandbox/command-runner.js +47 -0
- package/dist/sandbox/contract.d.ts +5 -0
- package/dist/sandbox/contract.js +276 -0
- package/dist/sandbox/event-budget.d.ts +11 -0
- package/dist/sandbox/event-budget.js +27 -0
- package/dist/sandbox/host-capacity-broker.d.ts +115 -0
- package/dist/sandbox/host-capacity-broker.js +336 -0
- package/dist/sandbox/image-policy.d.ts +35 -0
- package/dist/sandbox/image-policy.js +247 -0
- package/dist/sandbox/index.d.ts +5 -0
- package/dist/sandbox/index.js +5 -0
- package/dist/sandbox/lease-watchdog.d.ts +18 -0
- package/dist/sandbox/lease-watchdog.js +67 -0
- package/dist/sandbox/managed-branch.d.ts +13 -0
- package/dist/sandbox/managed-branch.js +36 -0
- package/dist/sandbox/preflight.d.ts +84 -0
- package/dist/sandbox/preflight.js +521 -0
- package/dist/sandbox/process.d.ts +20 -0
- package/dist/sandbox/process.js +209 -0
- package/dist/sandbox/provider-auth/codex.d.ts +26 -0
- package/dist/sandbox/provider-auth/codex.js +212 -0
- package/dist/sandbox/repository-lock.d.ts +6 -0
- package/dist/sandbox/repository-lock.js +129 -0
- package/dist/sandbox/runtime.d.ts +311 -0
- package/dist/sandbox/runtime.js +2407 -0
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- package/dist/sandbox/sandbox.types.d.ts +93 -0
- package/dist/sandbox/sandbox.types.js +1 -0
- package/dist/sandbox/smoke.d.ts +76 -0
- package/dist/sandbox/smoke.js +380 -0
- package/dist/sandbox/worker-supervisor.d.ts +13 -0
- package/dist/sandbox/worker-supervisor.js +36 -0
- package/dist/sandbox/worker.d.ts +1 -0
- package/dist/sandbox/worker.js +225 -0
- package/dist/sandbox/workspace.service.d.ts +13 -0
- package/dist/sandbox/workspace.service.js +74 -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 +48 -0
- package/dist/session/managed-attempt-tools.js +1299 -0
- 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 +34 -0
- package/dist/session/phase-completion.artifacts.js +903 -0
- 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 +65 -42
- package/dist/session/phase-completion.helpers.d.ts +117 -0
- package/dist/session/phase-completion.helpers.js +708 -0
- package/dist/session/phase-completion.js +130 -3007
- 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.d.ts +14 -0
- package/dist/session/phase-completion.prompts.js +238 -0
- package/dist/session/phase-completion.runtime.d.ts +43 -0
- package/dist/session/phase-completion.runtime.js +721 -0
- 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 -0
- package/dist/session/phase-completion.schemas.js +836 -0
- package/dist/session/phase-completion.validation.d.ts +37 -0
- package/dist/session/phase-completion.validation.js +874 -0
- 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 +16 -0
- package/dist/session/provider-cli/ci-repair-readiness.js +110 -0
- 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 +96 -0
- package/dist/session/provider-cli/provider-cli.artifacts.js +818 -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-payloads.d.ts +12 -0
- package/dist/session/provider-cli/provider-cli.deterministic-payloads.js +279 -0
- package/dist/session/provider-cli/provider-cli.deterministic.d.ts +14 -0
- package/dist/session/provider-cli/provider-cli.deterministic.js +407 -0
- 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 +114 -0
- package/dist/session/provider-cli/provider-cli.process.js +757 -0
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +62 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +770 -0
- package/dist/session/provider-cli/provider-cli.qa-sidecars.d.ts +11 -0
- package/dist/session/provider-cli/provider-cli.qa-sidecars.js +66 -0
- 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 +30 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +120 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +53 -53
- package/dist/session/provider-cli/provider-cli.service.js +1299 -2523
- package/dist/session/provider-cli/provider-cli.types.d.ts +38 -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 +40 -0
- package/dist/session/provider-cli/provider-output-state.js +832 -0
- 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.d.ts +3 -0
- package/dist/session/session-redaction.js +298 -0
- package/dist/session/session.base.d.ts +14 -1
- package/dist/session/session.service.d.ts +17 -2
- package/dist/session/session.service.js +708 -60
- package/dist/session/session.types.d.ts +327 -3
- package/dist/session/session.types.js +951 -10
- 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 +21 -1
- 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 +23 -0
- package/dist/shared/process/host-process-recovery.js +99 -0
- package/dist/shared/process/host-process-supervisor.d.ts +72 -0
- package/dist/shared/process/host-process-supervisor.js +383 -0
- 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 +70 -0
- package/dist/shared/process/process.js +224 -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 +26 -0
- package/dist/shared/process/windows-launch.js +109 -0
- package/dist/shared/provider-capabilities.d.ts +4 -0
- package/dist/shared/provider-capabilities.js +95 -0
- package/dist/shared/redaction/redaction.d.ts +1 -0
- package/dist/shared/redaction/redaction.js +47 -4
- 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/artifact-injector.d.ts +3 -2
- package/dist/worktree/artifact-injector.js +82 -10
- package/dist/worktree/dependency-warmer.d.ts +78 -1
- package/dist/worktree/dependency-warmer.js +731 -13
- package/dist/worktree/index.d.ts +2 -1
- package/dist/worktree/index.js +1 -0
- package/dist/worktree/prior-phase-artifact-hydrator.d.ts +2 -0
- package/dist/worktree/prior-phase-artifact-hydrator.js +136 -0
- 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-paths.d.ts +4 -0
- package/dist/worktree/worktree-paths.js +30 -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 +10 -1
- package/dist/worktree/worktree.service.d.ts +30 -4
- package/dist/worktree/worktree.service.js +379 -54
- package/dist/worktree/worktree.types.d.ts +38 -1
- package/package.json +12 -7
- package/runtime/windows-job-supervisor.ps1 +722 -0
- package/runtime/windows-listener-owner.ps1 +33 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { BoundedCommandRunner } from "../sandbox/command-runner.js";
|
|
4
|
+
/**
|
|
5
|
+
* Probes ordinary Docker-daemon access for host-run Testcontainers and project
|
|
6
|
+
* services. This is deliberately independent from the stricter Forge sandbox
|
|
7
|
+
* preflight: a usable Docker Desktop engine may satisfy docker_engine even
|
|
8
|
+
* when it is not approved to host an agent sandbox.
|
|
9
|
+
*/
|
|
10
|
+
export class DockerEngineProbe {
|
|
11
|
+
commands;
|
|
12
|
+
cacheMs;
|
|
13
|
+
cached = null;
|
|
14
|
+
sampledAtMs = 0;
|
|
15
|
+
inFlight = null;
|
|
16
|
+
requiredWorkRecoveryInFlight = null;
|
|
17
|
+
consecutiveFailures = 0;
|
|
18
|
+
lastRecoveryAttemptAtMs = null;
|
|
19
|
+
docker;
|
|
20
|
+
context;
|
|
21
|
+
platform;
|
|
22
|
+
dockerHost;
|
|
23
|
+
now;
|
|
24
|
+
wait;
|
|
25
|
+
recovery;
|
|
26
|
+
recoveryExecutor;
|
|
27
|
+
onStatus;
|
|
28
|
+
constructor(options = {}, commands = new BoundedCommandRunner(), cacheMs = 15_000) {
|
|
29
|
+
this.commands = commands;
|
|
30
|
+
this.cacheMs = cacheMs;
|
|
31
|
+
this.docker = options.dockerExecutable ?? process.env.FORGE_DOCKER_EXECUTABLE ?? "docker";
|
|
32
|
+
this.context = options.dockerContext?.trim() || process.env.DOCKER_CONTEXT?.trim() || "default";
|
|
33
|
+
this.platform = options.platform ?? process.platform;
|
|
34
|
+
this.dockerHost = options.dockerHost ?? process.env.DOCKER_HOST?.trim() ?? "";
|
|
35
|
+
this.now = options.now ?? Date.now;
|
|
36
|
+
this.wait = options.wait ?? (delayMs => new Promise(resolve => setTimeout(resolve, delayMs)));
|
|
37
|
+
this.recovery = {
|
|
38
|
+
enabled: options.recovery?.enabled ?? false,
|
|
39
|
+
failureThreshold: positiveInteger(options.recovery?.failureThreshold, 3),
|
|
40
|
+
confirmationDelayMs: positiveInteger(options.recovery?.confirmationDelayMs, 30_000),
|
|
41
|
+
cooldownMs: positiveInteger(options.recovery?.cooldownMs, 10 * 60_000),
|
|
42
|
+
startupTimeoutMs: positiveInteger(options.recovery?.startupTimeoutMs, 2 * 60_000),
|
|
43
|
+
pollIntervalMs: positiveInteger(options.recovery?.pollIntervalMs, 2_000),
|
|
44
|
+
canRecover: options.recovery?.canRecover,
|
|
45
|
+
};
|
|
46
|
+
this.recoveryExecutor = options.recoveryExecutor ?? new WindowsDockerDesktopRecoveryExecutor(this.platform, commands);
|
|
47
|
+
this.onStatus = options.onStatus ?? (() => undefined);
|
|
48
|
+
}
|
|
49
|
+
current() {
|
|
50
|
+
return this.cached;
|
|
51
|
+
}
|
|
52
|
+
async refresh(force = false) {
|
|
53
|
+
if (!force && this.cached && this.now() - this.sampledAtMs < this.cacheMs) {
|
|
54
|
+
return this.cached;
|
|
55
|
+
}
|
|
56
|
+
if (this.inFlight)
|
|
57
|
+
return await this.inFlight;
|
|
58
|
+
const operation = this.inspectSafely()
|
|
59
|
+
.then(result => this.recoverIfEligible(result))
|
|
60
|
+
.then((result) => {
|
|
61
|
+
this.cached = result;
|
|
62
|
+
this.sampledAtMs = this.now();
|
|
63
|
+
return result;
|
|
64
|
+
})
|
|
65
|
+
.finally(() => {
|
|
66
|
+
if (this.inFlight === operation)
|
|
67
|
+
this.inFlight = null;
|
|
68
|
+
});
|
|
69
|
+
this.inFlight = operation;
|
|
70
|
+
return await operation;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* One fresh daemon reading that never starts recovery and leaves the cache and the
|
|
74
|
+
* failure streak alone, for callers that only need to know whether Docker is up.
|
|
75
|
+
*/
|
|
76
|
+
async probeWithoutRecovery() {
|
|
77
|
+
return await this.inspectSafely();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Establishes a fresh daemon fence for work that declares Docker as a hard
|
|
81
|
+
* prerequisite. This remains bounded, cooldown protected and single-flight;
|
|
82
|
+
* it never contacts Docker unless a caller explicitly invokes this method.
|
|
83
|
+
*/
|
|
84
|
+
async ensureAvailableForRequiredWork() {
|
|
85
|
+
const fresh = await this.refresh(true);
|
|
86
|
+
if (fresh.available || !this.recovery.enabled || !this.isLocalDockerDesktopContext()) {
|
|
87
|
+
return fresh;
|
|
88
|
+
}
|
|
89
|
+
if (this.requiredWorkRecoveryInFlight)
|
|
90
|
+
return await this.requiredWorkRecoveryInFlight;
|
|
91
|
+
const operation = this.recoverIfEligible(fresh, true)
|
|
92
|
+
.then((result) => {
|
|
93
|
+
this.cached = result;
|
|
94
|
+
this.sampledAtMs = this.now();
|
|
95
|
+
return result;
|
|
96
|
+
})
|
|
97
|
+
.finally(() => {
|
|
98
|
+
if (this.requiredWorkRecoveryInFlight === operation)
|
|
99
|
+
this.requiredWorkRecoveryInFlight = null;
|
|
100
|
+
});
|
|
101
|
+
this.requiredWorkRecoveryInFlight = operation;
|
|
102
|
+
return await operation;
|
|
103
|
+
}
|
|
104
|
+
async inspectSafely() {
|
|
105
|
+
return await this.inspect().catch((error) => unavailable(this.context, "docker_engine_unreachable", error instanceof Error ? error.message : String(error)));
|
|
106
|
+
}
|
|
107
|
+
async recoverIfEligible(snapshot, requiredWork = false) {
|
|
108
|
+
if (snapshot.available) {
|
|
109
|
+
this.consecutiveFailures = 0;
|
|
110
|
+
return snapshot;
|
|
111
|
+
}
|
|
112
|
+
this.consecutiveFailures += 1;
|
|
113
|
+
if (!this.recovery.enabled
|
|
114
|
+
|| !this.isLocalDockerDesktopContext()
|
|
115
|
+
|| (!requiredWork && this.consecutiveFailures < this.recovery.failureThreshold)
|
|
116
|
+
|| (!requiredWork && this.recovery.canRecover?.() === false)) {
|
|
117
|
+
return snapshot;
|
|
118
|
+
}
|
|
119
|
+
const now = this.now();
|
|
120
|
+
if (this.lastRecoveryAttemptAtMs !== null
|
|
121
|
+
&& now - this.lastRecoveryAttemptAtMs < this.recovery.cooldownMs) {
|
|
122
|
+
return snapshot;
|
|
123
|
+
}
|
|
124
|
+
this.onStatus(`Docker engine remained unavailable for ${this.consecutiveFailures} consecutive probes; waiting for one fresh confirmation before recovery.`);
|
|
125
|
+
await this.wait(this.recovery.confirmationDelayMs);
|
|
126
|
+
const confirmed = await this.inspectSafely();
|
|
127
|
+
if (confirmed.available) {
|
|
128
|
+
this.consecutiveFailures = 0;
|
|
129
|
+
this.onStatus("Docker engine recovered during the confirmation window; skipped Docker Desktop recovery.");
|
|
130
|
+
return confirmed;
|
|
131
|
+
}
|
|
132
|
+
if (!requiredWork && this.recovery.canRecover?.() === false) {
|
|
133
|
+
this.onStatus("Docker Desktop recovery was deferred because runner work became active during confirmation.");
|
|
134
|
+
return confirmed;
|
|
135
|
+
}
|
|
136
|
+
this.consecutiveFailures += 1;
|
|
137
|
+
this.lastRecoveryAttemptAtMs = this.now();
|
|
138
|
+
this.onStatus(`Docker engine remained unavailable after confirmation; starting one bounded Docker Desktop recovery.`);
|
|
139
|
+
const recovery = await this.recoveryExecutor.restart().catch((error) => ({
|
|
140
|
+
started: false,
|
|
141
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
142
|
+
}));
|
|
143
|
+
if (!recovery.started) {
|
|
144
|
+
const reason = recovery.reason?.trim() || "Docker Desktop recovery could not be started.";
|
|
145
|
+
this.onStatus(`Docker Desktop recovery failed to start: ${singleLine(reason)}`);
|
|
146
|
+
return unavailable(this.context, "docker_engine_recovery_failed", reason);
|
|
147
|
+
}
|
|
148
|
+
const deadline = this.now() + this.recovery.startupTimeoutMs;
|
|
149
|
+
while (this.now() < deadline) {
|
|
150
|
+
await this.wait(Math.min(this.recovery.pollIntervalMs, Math.max(1, deadline - this.now())));
|
|
151
|
+
const verified = await this.inspectSafely();
|
|
152
|
+
if (verified.available) {
|
|
153
|
+
this.consecutiveFailures = 0;
|
|
154
|
+
this.onStatus("Docker Desktop recovery completed and the engine passed a fresh daemon probe.");
|
|
155
|
+
return verified;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
this.onStatus("Docker Desktop recovery timed out before the engine became reachable; cooldown is active.");
|
|
159
|
+
return unavailable(this.context, "docker_engine_recovery_timeout", "Docker Desktop restart was requested, but the engine did not become reachable before the recovery timeout.");
|
|
160
|
+
}
|
|
161
|
+
isLocalDockerDesktopContext() {
|
|
162
|
+
return this.platform === "win32"
|
|
163
|
+
&& !this.dockerHost
|
|
164
|
+
&& (this.context === "default" || this.context === "desktop-linux");
|
|
165
|
+
}
|
|
166
|
+
async inspect() {
|
|
167
|
+
const dockerArgs = this.context === "default" ? [] : ["--context", this.context];
|
|
168
|
+
const result = await this.commands.run(this.docker, [...dockerArgs, "info", "--format", "{{json .}}"], { timeoutMs: 10_000, maxOutputBytes: 512 * 1024 });
|
|
169
|
+
if (result.exitCode !== 0) {
|
|
170
|
+
return unavailable(this.context, "docker_engine_unreachable", result.stderr || result.stdout || "Docker daemon is unreachable.");
|
|
171
|
+
}
|
|
172
|
+
let info;
|
|
173
|
+
try {
|
|
174
|
+
const parsed = JSON.parse(result.stdout.trim());
|
|
175
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
176
|
+
throw new Error("not an object");
|
|
177
|
+
info = parsed;
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
return unavailable(this.context, "docker_engine_invalid_response", "Docker returned an invalid info document.");
|
|
181
|
+
}
|
|
182
|
+
const version = clean(info.ServerVersion);
|
|
183
|
+
const operatingSystem = clean(info.OSType)?.toLowerCase() ?? null;
|
|
184
|
+
const serverErrors = Array.isArray(info.ServerErrors)
|
|
185
|
+
? info.ServerErrors.map(clean).filter((value) => Boolean(value))
|
|
186
|
+
: [];
|
|
187
|
+
if (serverErrors.length > 0 || !version || !operatingSystem) {
|
|
188
|
+
return unavailable(this.context, "docker_engine_unavailable_response", serverErrors.join(" ") || "Docker returned an incomplete daemon identity.");
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
available: true,
|
|
192
|
+
sampledAt: new Date().toISOString(),
|
|
193
|
+
runtimeVersion: `docker/${version}`,
|
|
194
|
+
operatingSystem,
|
|
195
|
+
context: this.context,
|
|
196
|
+
unavailableCode: null,
|
|
197
|
+
unavailableReason: null,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Restarts only the local Docker Desktop installation. It never targets a
|
|
203
|
+
* remote daemon and is used only behind the explicit bridge recovery policy.
|
|
204
|
+
*/
|
|
205
|
+
export class WindowsDockerDesktopRecoveryExecutor {
|
|
206
|
+
platform;
|
|
207
|
+
commands;
|
|
208
|
+
programFiles;
|
|
209
|
+
wait;
|
|
210
|
+
constructor(platform = process.platform, commands = new BoundedCommandRunner(), programFiles = process.env.ProgramFiles ?? "C:\\Program Files", wait = delayMs => new Promise(resolve => setTimeout(resolve, delayMs))) {
|
|
211
|
+
this.platform = platform;
|
|
212
|
+
this.commands = commands;
|
|
213
|
+
this.programFiles = programFiles;
|
|
214
|
+
this.wait = wait;
|
|
215
|
+
}
|
|
216
|
+
async restart() {
|
|
217
|
+
if (this.platform !== "win32") {
|
|
218
|
+
return { started: false, reason: "Automatic Docker Desktop recovery is supported only on Windows." };
|
|
219
|
+
}
|
|
220
|
+
const installRoot = path.join(this.programFiles, "Docker", "Docker");
|
|
221
|
+
const desktopExecutable = path.join(installRoot, "Docker Desktop.exe");
|
|
222
|
+
if (!fs.existsSync(desktopExecutable)) {
|
|
223
|
+
return { started: false, reason: "Docker Desktop executable was not found in the standard installation directory." };
|
|
224
|
+
}
|
|
225
|
+
const processState = await this.readProcessState();
|
|
226
|
+
if (processState === "unknown") {
|
|
227
|
+
return { started: false, reason: "Docker Desktop process state could not be determined safely." };
|
|
228
|
+
}
|
|
229
|
+
if (processState === "stopped") {
|
|
230
|
+
if (!await this.cleanupOrphanedCompanions()) {
|
|
231
|
+
return { started: false, reason: "Orphaned Docker Desktop companion processes could not be verified and cleaned safely." };
|
|
232
|
+
}
|
|
233
|
+
await this.wait(1_000);
|
|
234
|
+
return await this.startDesktop(desktopExecutable);
|
|
235
|
+
}
|
|
236
|
+
const dockerCli = path.join(installRoot, "DockerCli.exe");
|
|
237
|
+
if (fs.existsSync(dockerCli)) {
|
|
238
|
+
await this.commands.run(dockerCli, ["-Shutdown"], {
|
|
239
|
+
timeoutMs: 15_000,
|
|
240
|
+
maxOutputBytes: 64 * 1024,
|
|
241
|
+
}).catch(() => undefined);
|
|
242
|
+
}
|
|
243
|
+
const stopScript = [
|
|
244
|
+
"$ErrorActionPreference = 'SilentlyContinue'",
|
|
245
|
+
"Get-Process | Where-Object { $_.ProcessName -in @('Docker Desktop', 'com.docker.backend') } | Stop-Process -Force",
|
|
246
|
+
].join("; ");
|
|
247
|
+
await this.commands.run("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", stopScript], {
|
|
248
|
+
timeoutMs: 15_000,
|
|
249
|
+
maxOutputBytes: 64 * 1024,
|
|
250
|
+
}).catch(() => undefined);
|
|
251
|
+
await this.commands.run("wsl.exe", ["--terminate", "docker-desktop"], {
|
|
252
|
+
timeoutMs: 15_000,
|
|
253
|
+
maxOutputBytes: 64 * 1024,
|
|
254
|
+
}).catch(() => undefined);
|
|
255
|
+
await this.wait(5_000);
|
|
256
|
+
const stoppedState = await this.readProcessState();
|
|
257
|
+
if (stoppedState !== "stopped") {
|
|
258
|
+
return {
|
|
259
|
+
started: false,
|
|
260
|
+
reason: stoppedState === "running"
|
|
261
|
+
? "Docker Desktop processes did not stop before relaunch."
|
|
262
|
+
: "Docker Desktop shutdown state could not be verified safely.",
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
if (!await this.cleanupOrphanedCompanions()) {
|
|
266
|
+
return { started: false, reason: "Orphaned Docker Desktop companion processes could not be verified and cleaned safely." };
|
|
267
|
+
}
|
|
268
|
+
await this.wait(1_000);
|
|
269
|
+
return await this.startDesktop(desktopExecutable);
|
|
270
|
+
}
|
|
271
|
+
async readProcessState() {
|
|
272
|
+
const script = [
|
|
273
|
+
"$ErrorActionPreference = 'Stop'",
|
|
274
|
+
"$processes = @(Get-Process -Name 'Docker Desktop','com.docker.backend' -ErrorAction SilentlyContinue)",
|
|
275
|
+
"if ($processes.Count -gt 0) { Write-Output 'running' } else { Write-Output 'stopped' }",
|
|
276
|
+
].join("; ");
|
|
277
|
+
const result = await this.commands.run("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], { timeoutMs: 5_000, maxOutputBytes: 16 * 1024 }).catch(() => null);
|
|
278
|
+
if (!result || result.exitCode !== 0)
|
|
279
|
+
return "unknown";
|
|
280
|
+
const state = result.stdout.trim().toLowerCase();
|
|
281
|
+
return state === "running" || state === "stopped" ? state : "unknown";
|
|
282
|
+
}
|
|
283
|
+
async cleanupOrphanedCompanions() {
|
|
284
|
+
const dockerRoot = path.join(this.programFiles, "Docker").replaceAll("'", "''");
|
|
285
|
+
const script = [
|
|
286
|
+
"$ErrorActionPreference = 'Stop'",
|
|
287
|
+
`$dockerRoot = [System.IO.Path]::GetFullPath('${dockerRoot}').TrimEnd('\\') + '\\'`,
|
|
288
|
+
"$names = @('com.docker.build.exe','docker-sandbox.exe','docker-agent.exe','local-sandboxesd.exe','docker-sandboxd.exe')",
|
|
289
|
+
"$candidates = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -in $names -and $_.ExecutablePath -and [System.IO.Path]::GetFullPath($_.ExecutablePath).StartsWith($dockerRoot, [System.StringComparison]::OrdinalIgnoreCase) })",
|
|
290
|
+
"foreach ($candidate in $candidates) { $parent = Get-CimInstance Win32_Process -Filter ('ProcessId=' + $candidate.ParentProcessId) -ErrorAction SilentlyContinue; $parentIsDockerBackend = $null -ne $parent -and $parent.Name -eq 'com.docker.backend.exe' -and $parent.ExecutablePath -and [System.IO.Path]::GetFullPath($parent.ExecutablePath).StartsWith($dockerRoot, [System.StringComparison]::OrdinalIgnoreCase); if (-not $parentIsDockerBackend) { Stop-Process -Id $candidate.ProcessId -Force -ErrorAction Stop } }",
|
|
291
|
+
].join("; ");
|
|
292
|
+
const result = await this.commands.run("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], { timeoutMs: 10_000, maxOutputBytes: 32 * 1024 }).catch(() => null);
|
|
293
|
+
return result?.exitCode === 0;
|
|
294
|
+
}
|
|
295
|
+
async startDesktop(desktopExecutable) {
|
|
296
|
+
const quotedDesktop = desktopExecutable.replaceAll("'", "''");
|
|
297
|
+
let lastReason = "Docker Desktop failed to start.";
|
|
298
|
+
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
|
299
|
+
const startScript = [
|
|
300
|
+
"$ErrorActionPreference = 'Stop'",
|
|
301
|
+
`$desktop = Start-Process -FilePath '${quotedDesktop}' -WindowStyle Hidden -PassThru`,
|
|
302
|
+
"Start-Sleep -Seconds 3",
|
|
303
|
+
"if ($desktop.HasExited) { Write-Error ('Docker Desktop exited during startup with code ' + $desktop.ExitCode); exit 1 }",
|
|
304
|
+
].join("; ");
|
|
305
|
+
const start = await this.commands.run("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", startScript], { timeoutMs: 15_000, maxOutputBytes: 64 * 1024 }).catch((error) => ({
|
|
306
|
+
exitCode: 1,
|
|
307
|
+
stdout: "",
|
|
308
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
309
|
+
}));
|
|
310
|
+
if (start.exitCode === 0)
|
|
311
|
+
return { started: true };
|
|
312
|
+
lastReason = start.stderr || start.stdout || lastReason;
|
|
313
|
+
if (attempt < 3)
|
|
314
|
+
await this.wait(5_000);
|
|
315
|
+
}
|
|
316
|
+
return { started: false, reason: singleLine(lastReason) };
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function unavailable(context, code, reason) {
|
|
320
|
+
return {
|
|
321
|
+
available: false,
|
|
322
|
+
sampledAt: new Date().toISOString(),
|
|
323
|
+
runtimeVersion: null,
|
|
324
|
+
operatingSystem: null,
|
|
325
|
+
context,
|
|
326
|
+
unavailableCode: code,
|
|
327
|
+
unavailableReason: singleLine(reason),
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function clean(value) {
|
|
331
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
332
|
+
}
|
|
333
|
+
function singleLine(value) {
|
|
334
|
+
return value.replace(/[\r\n\t]+/gu, " ").trim().slice(0, 1000);
|
|
335
|
+
}
|
|
336
|
+
function positiveInteger(value, fallback) {
|
|
337
|
+
if (value === undefined || !Number.isFinite(value) || value <= 0)
|
|
338
|
+
return fallback;
|
|
339
|
+
return Math.floor(value);
|
|
340
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type EphemeralTestPostgresCluster, type EphemeralTestPostgresOptions } from "./ephemeral-test-postgres.js";
|
|
2
|
+
import { type NativeTestPostgresFallback, type NativeTestPostgresGrant } from "./native-test-postgres-fallback.js";
|
|
3
|
+
export type StartEphemeralTestPostgres = (options: EphemeralTestPostgresOptions) => Promise<EphemeralTestPostgresCluster>;
|
|
4
|
+
/** The bin directory an ephemeral cluster runs from: the file's `postgresBin`, else the one holding psql. */
|
|
5
|
+
export declare function ephemeralTestPostgresBinDirectory(fallback: Pick<NativeTestPostgresFallback, "postgresBin">, psqlPath?: () => string | null): string;
|
|
6
|
+
/**
|
|
7
|
+
* Starts a throwaway cluster for one check and returns its grant. The grant's mode keeps the
|
|
8
|
+
* Docker semantics of the shared cluster: with Docker up, pinned-engine tests still start their
|
|
9
|
+
* own containers; with Docker down, they are skipped. The caller must call `release`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function startEphemeralTestPostgresGrant(fallback: Pick<NativeTestPostgresFallback, "postgresBin">, dockerAvailable: boolean, start?: StartEphemeralTestPostgres): Promise<NativeTestPostgresGrant>;
|
|
12
|
+
/** A managed verification command's database environment, and what to release when the command ends. */
|
|
13
|
+
export interface ManagedVerificationDatabase {
|
|
14
|
+
readonly environment: Readonly<Record<string, string>>;
|
|
15
|
+
/** The connection strings and their passwords, for redaction; never the mode or the cluster id. */
|
|
16
|
+
readonly secrets: readonly string[];
|
|
17
|
+
readonly release: () => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/** A command that runs no verification profile gets no database. */
|
|
20
|
+
export declare const noManagedVerificationDatabase: ManagedVerificationDatabase;
|
|
21
|
+
/**
|
|
22
|
+
* Builds a command's setup from its database. If the setup throws, the command never starts and
|
|
23
|
+
* no caller holds the database, so it is released here before the error is rethrown.
|
|
24
|
+
*/
|
|
25
|
+
export declare function setUpWithManagedVerificationDatabase<T>(database: Pick<ManagedVerificationDatabase, "release">, setUp: () => T): Promise<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Releases a command's database once the command has ended. A cluster that would not stop is left
|
|
28
|
+
* disowned for the next start's reap; the failure goes to `report` instead of being dropped.
|
|
29
|
+
*/
|
|
30
|
+
export declare function releaseManagedVerificationDatabase(database: Pick<ManagedVerificationDatabase, "release">, report: (message: string) => Promise<void>): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Managed verification on an `ephemeral` host gets a throwaway cluster for the command's
|
|
33
|
+
* lifetime; every other host keeps managedVerificationDatabaseEnvironment's rules. A cluster
|
|
34
|
+
* that cannot start fails the command rather than silently handing it Docker or the shared
|
|
35
|
+
* cluster's narrower login.
|
|
36
|
+
*/
|
|
37
|
+
export declare function managedVerificationDatabase(dockerAvailable?: () => Promise<boolean>, readFallback?: () => NativeTestPostgresFallback | null, start?: StartEphemeralTestPostgres): Promise<ManagedVerificationDatabase>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { attemptDatabaseCapabilitySecrets, resolvePsqlPath } from "./attempt-database-broker.js";
|
|
3
|
+
import { EphemeralTestPostgresError, ephemeralTestPostgresClusterEnvironment, startEphemeralTestPostgres, } from "./ephemeral-test-postgres.js";
|
|
4
|
+
import { DockerEngineProbe } from "./docker-engine-probe.js";
|
|
5
|
+
import { managedVerificationDatabaseEnvironment, nativeTestPostgresFallbackConfigEnvironment, nativeTestPostgresFallbackDatabaseMode, nativeTestPostgresFallbackEnvironment, nativeTestPostgresPreferredDatabaseMode, readNativeTestPostgresFallback, } from "./native-test-postgres-fallback.js";
|
|
6
|
+
/** The bin directory an ephemeral cluster runs from: the file's `postgresBin`, else the one holding psql. */
|
|
7
|
+
export function ephemeralTestPostgresBinDirectory(fallback, psqlPath = resolvePsqlPath) {
|
|
8
|
+
if (fallback.postgresBin)
|
|
9
|
+
return fallback.postgresBin;
|
|
10
|
+
const psql = psqlPath();
|
|
11
|
+
if (!psql) {
|
|
12
|
+
throw new EphemeralTestPostgresError("no PostgreSQL install was found; set 'postgresBin' in native-test-postgres.json or FORGE_NATIVE_TEST_POSTGRES_PSQL.");
|
|
13
|
+
}
|
|
14
|
+
return path.dirname(psql);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Starts a throwaway cluster for one check and returns its grant. The grant's mode keeps the
|
|
18
|
+
* Docker semantics of the shared cluster: with Docker up, pinned-engine tests still start their
|
|
19
|
+
* own containers; with Docker down, they are skipped. The caller must call `release`.
|
|
20
|
+
*/
|
|
21
|
+
export async function startEphemeralTestPostgresGrant(fallback, dockerAvailable, start = startEphemeralTestPostgres) {
|
|
22
|
+
const cluster = await start({ binDirectory: ephemeralTestPostgresBinDirectory(fallback) });
|
|
23
|
+
return {
|
|
24
|
+
connectionString: cluster.connectionString,
|
|
25
|
+
endpoint: cluster.endpoint,
|
|
26
|
+
mode: dockerAvailable ? nativeTestPostgresPreferredDatabaseMode : nativeTestPostgresFallbackDatabaseMode,
|
|
27
|
+
ephemeralClusterId: cluster.id,
|
|
28
|
+
release: cluster.release,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** A command that runs no verification profile gets no database. */
|
|
32
|
+
export const noManagedVerificationDatabase = {
|
|
33
|
+
environment: {},
|
|
34
|
+
secrets: [],
|
|
35
|
+
release: async () => undefined,
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Builds a command's setup from its database. If the setup throws, the command never starts and
|
|
39
|
+
* no caller holds the database, so it is released here before the error is rethrown.
|
|
40
|
+
*/
|
|
41
|
+
export async function setUpWithManagedVerificationDatabase(database, setUp) {
|
|
42
|
+
try {
|
|
43
|
+
return setUp();
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
await database.release().catch(() => undefined);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Releases a command's database once the command has ended. A cluster that would not stop is left
|
|
52
|
+
* disowned for the next start's reap; the failure goes to `report` instead of being dropped.
|
|
53
|
+
*/
|
|
54
|
+
export async function releaseManagedVerificationDatabase(database, report) {
|
|
55
|
+
try {
|
|
56
|
+
await database.release();
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
await report(error instanceof Error ? error.message : String(error)).catch(() => undefined);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function databaseSecrets(environment) {
|
|
63
|
+
return Object.entries(environment)
|
|
64
|
+
.filter(([name]) => name !== "FORGE_MANAGED_VERIFICATION_DATABASE_MODE" && name !== ephemeralTestPostgresClusterEnvironment)
|
|
65
|
+
.flatMap(([, value]) => attemptDatabaseCapabilitySecrets(value));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Managed verification on an `ephemeral` host gets a throwaway cluster for the command's
|
|
69
|
+
* lifetime; every other host keeps managedVerificationDatabaseEnvironment's rules. A cluster
|
|
70
|
+
* that cannot start fails the command rather than silently handing it Docker or the shared
|
|
71
|
+
* cluster's narrower login.
|
|
72
|
+
*/
|
|
73
|
+
export async function managedVerificationDatabase(dockerAvailable = async () => (await new DockerEngineProbe().probeWithoutRecovery()).available, readFallback = () => {
|
|
74
|
+
const configPath = process.env[nativeTestPostgresFallbackConfigEnvironment]?.trim();
|
|
75
|
+
return configPath ? readNativeTestPostgresFallback(configPath) : null;
|
|
76
|
+
}, start = startEphemeralTestPostgres) {
|
|
77
|
+
const fallback = readFallback();
|
|
78
|
+
if (fallback?.use !== "ephemeral") {
|
|
79
|
+
const environment = await managedVerificationDatabaseEnvironment(dockerAvailable, () => fallback);
|
|
80
|
+
return { environment, secrets: databaseSecrets(environment), release: async () => undefined };
|
|
81
|
+
}
|
|
82
|
+
const grant = await startEphemeralTestPostgresGrant(fallback, await dockerAvailable(), start);
|
|
83
|
+
const environment = nativeTestPostgresFallbackEnvironment(grant);
|
|
84
|
+
return { environment, secrets: databaseSecrets(environment), release: grant.release ?? (async () => undefined) };
|
|
85
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** Set for a test run on an ephemeral cluster: its id, which the server reports as `forge.ephemeral_cluster`. */
|
|
2
|
+
export declare const ephemeralTestPostgresClusterEnvironment = "FORGE_TEST_POSTGRES_EPHEMERAL_CLUSTER";
|
|
3
|
+
export declare const ephemeralTestPostgresMarkerSetting = "forge.ephemeral_cluster";
|
|
4
|
+
export declare class EphemeralTestPostgresError extends Error {
|
|
5
|
+
readonly code = "ephemeral_test_postgres_unavailable";
|
|
6
|
+
constructor(detail: string);
|
|
7
|
+
}
|
|
8
|
+
export interface EphemeralTestPostgresCluster {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly connectionString: string;
|
|
11
|
+
readonly endpoint: string;
|
|
12
|
+
readonly password: string;
|
|
13
|
+
/**
|
|
14
|
+
* Stops the server and deletes its directory. Safe to call more than once. Rejects, keeping the
|
|
15
|
+
* directory, when the server is still running after the stop.
|
|
16
|
+
*/
|
|
17
|
+
release(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface ToolResult {
|
|
20
|
+
readonly code: number | null;
|
|
21
|
+
readonly output: string;
|
|
22
|
+
}
|
|
23
|
+
/** Runs one PostgreSQL program. `detached` programs (pg_ctl start) leave a server running, so their output goes to its log. */
|
|
24
|
+
export type EphemeralToolRunner = (file: string, args: readonly string[], options: {
|
|
25
|
+
readonly env: Readonly<Record<string, string>>;
|
|
26
|
+
readonly timeoutMs: number;
|
|
27
|
+
readonly detached?: boolean;
|
|
28
|
+
}) => Promise<ToolResult>;
|
|
29
|
+
export interface EphemeralTestPostgresOptions {
|
|
30
|
+
/** The directory holding initdb, pg_ctl and psql of the PostgreSQL install to run. */
|
|
31
|
+
readonly binDirectory: string;
|
|
32
|
+
readonly root?: string;
|
|
33
|
+
readonly ownerPid?: number;
|
|
34
|
+
readonly runTool?: EphemeralToolRunner;
|
|
35
|
+
readonly isProcessAlive?: (pid: number) => boolean;
|
|
36
|
+
readonly freePort?: () => Promise<number>;
|
|
37
|
+
readonly now?: () => number;
|
|
38
|
+
}
|
|
39
|
+
export declare function defaultEphemeralTestPostgresRoot(): string;
|
|
40
|
+
/**
|
|
41
|
+
* A superuser of a cluster run by the `postgres` OS user can read every cluster that user runs,
|
|
42
|
+
* including live ones (Debian and Ubuntu packages run them all as `postgres`). An ephemeral
|
|
43
|
+
* cluster therefore runs only as an ordinary user, the same one that already runs the attempt.
|
|
44
|
+
*/
|
|
45
|
+
export declare function assertEphemeralClusterOsUser(userName?: string, uid?: number | undefined): void;
|
|
46
|
+
/** Creates, starts and prepares one cluster. On any failure nothing of it is left behind. */
|
|
47
|
+
export declare function startEphemeralTestPostgres(options: EphemeralTestPostgresOptions): Promise<EphemeralTestPostgresCluster>;
|
|
48
|
+
/**
|
|
49
|
+
* Removes clusters whose owning Bridge process is gone. Only directories named like a cluster
|
|
50
|
+
* id inside the root are considered, and a live owner's clusters are never touched.
|
|
51
|
+
*/
|
|
52
|
+
export declare function reapEphemeralTestPostgres(options: EphemeralTestPostgresOptions): Promise<readonly string[]>;
|
|
53
|
+
/**
|
|
54
|
+
* On Windows a started postgres inherits pg_ctl's standard handles, so a pipe would stay open for
|
|
55
|
+
* the server's lifetime; a detached program gets no pipes and settles when it exits.
|
|
56
|
+
*/
|
|
57
|
+
export declare const runPostgresTool: EphemeralToolRunner;
|