@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,670 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { attemptDatabaseCapabilityEnvironment, attemptDatabaseCapabilitySecrets, } from "../runtime/attempt-database-broker.js";
|
|
5
|
+
import { assertHostDatabaseCapabilityBoundary } from "../runtime/host-database-capability-boundary.js";
|
|
6
|
+
import { runHostGovernedValidationStep } from "./pre-publication-host-load.js";
|
|
7
|
+
import { dockerFreeGrant, dockerUnavailableNativeTestPostgres, isolatedPostgresProvided, preferredNativeTestPostgres, releaseCheckPostgres, } from "./pre-publication-native-postgres.js";
|
|
8
|
+
import { managedAttemptInvocation, validationExecutionForStep, } from "./pre-publication-step-execution.js";
|
|
9
|
+
import { hostRuntimeLegacyTestPostgresEnvironment, hostRuntimeTestPostgresAdminEnvironment, hostRuntimeTestPostgresProvisionerEnvironment, } from "../runtime/host-runtime-contract.js";
|
|
10
|
+
import { redactText } from "../shared/redaction/redaction.js";
|
|
11
|
+
import { PrePublicationPass, PrePublicationValidationError, SkippedTestTally, skippedCheckEvent, validationEvent, } from "./pre-publication-pass.js";
|
|
12
|
+
import { ProcessPrePublicationCommandRunner, pnpmDirectoryLaunch } from "./pre-publication-process.js";
|
|
13
|
+
import { ProcessTreeTerminationError } from "../shared/process/process.js";
|
|
14
|
+
import { findUnreferencedNewExports } from "./unreferenced-exports.js";
|
|
15
|
+
import { ForgeFailureError, sanitizeFailureError, } from "./session.types.js";
|
|
16
|
+
const contractRelativePath = ".forge/validation/ci-parity.v1.json";
|
|
17
|
+
const requiredCheckIds = new Set([
|
|
18
|
+
"file-size-inventory",
|
|
19
|
+
"owned-suite-registration",
|
|
20
|
+
"dotnet-build-and-unit",
|
|
21
|
+
"openapi-and-generated-types",
|
|
22
|
+
"client",
|
|
23
|
+
"bridge",
|
|
24
|
+
"playwright-e2e",
|
|
25
|
+
"github-provider-policy",
|
|
26
|
+
]);
|
|
27
|
+
// Every gate profile runs the affected .NET tests; only CI runs the whole tiers (decision 0017).
|
|
28
|
+
const currentApprovedContractDigest = "9cf3a3070de56f3d3bc2c013dfa45b0fd463d257722849087e6743fb9cb1fd0d";
|
|
29
|
+
// Only comment repair ran the affected tests; the other profiles ran Unit, Contract and
|
|
30
|
+
// Infrastructure whole. Story branches cut before decision 0017 still carry it.
|
|
31
|
+
const commentRepairOnlyAffectedContractDigest = "378c767c7977c850140ffb19d69db41da62d0187c37a33828d6cda8803a61c83";
|
|
32
|
+
// Comment repair ran the whole ApiComponent and Orchestration tiers under this contract.
|
|
33
|
+
const wholeTierCommentRepairContractDigest = "024de3648c907db9c0eab13def9a4f91e81148433e0a2ba7f44776446421054a";
|
|
34
|
+
// Contracts that declare the comment-repair-dotnet-regression check.
|
|
35
|
+
const commentRepairRegressionContractDigests = new Set([
|
|
36
|
+
currentApprovedContractDigest,
|
|
37
|
+
commentRepairOnlyAffectedContractDigest,
|
|
38
|
+
wholeTierCommentRepairContractDigest,
|
|
39
|
+
]);
|
|
40
|
+
const compatibleApprovedContractDigests = new Set([
|
|
41
|
+
commentRepairOnlyAffectedContractDigest,
|
|
42
|
+
wholeTierCommentRepairContractDigest,
|
|
43
|
+
// Preserve dispatches pinned before comment repair gained all .NET regression tiers.
|
|
44
|
+
"c0014ce6abc0e0b2e66dd2bcf6cb14c47d28506444c73f87d1b76b3d1c06027b",
|
|
45
|
+
// The contract immediately before Contract and Infrastructure tiers joined pre-publication parity.
|
|
46
|
+
"06d1ca5ed48614298ae53d044d725109fe3a316a88381d361ef704681e208bbd",
|
|
47
|
+
// The Docker-prerequisite contract immediately before native PostgreSQL QA isolation.
|
|
48
|
+
"02bc1eb622fce173b00d14e15930c841f99678500858da588ec37fe21a7bec5c",
|
|
49
|
+
// The contract used by Stories prepared before prerequisite readiness was made explicit.
|
|
50
|
+
"0e8cfb2b1c1ab52bea1475dabed95aa5a2977bdd3c8500a6895632316dba0de5",
|
|
51
|
+
]);
|
|
52
|
+
const approvedContractDigests = new Set([
|
|
53
|
+
currentApprovedContractDigest,
|
|
54
|
+
...compatibleApprovedContractDigests,
|
|
55
|
+
]);
|
|
56
|
+
const ansiColorSequence = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "gu");
|
|
57
|
+
const timeoutConfirmation = {
|
|
58
|
+
started: [
|
|
59
|
+
"prepublication_validation_timeout_confirmation_started",
|
|
60
|
+
"The full client test step reported only Vitest timeouts; confirming once with the same command and attempt environment.",
|
|
61
|
+
],
|
|
62
|
+
passed: [
|
|
63
|
+
"prepublication_validation_timeout_confirmation_passed",
|
|
64
|
+
"The complete client test step passed on its single timeout confirmation run.",
|
|
65
|
+
],
|
|
66
|
+
failedEvent: "prepublication_validation_timeout_confirmation_failed",
|
|
67
|
+
failedContent: exitCode => `The complete client test step failed on its single timeout confirmation run (exit ${exitCode}).`,
|
|
68
|
+
};
|
|
69
|
+
const cleanupConfirmation = {
|
|
70
|
+
started: [
|
|
71
|
+
"prepublication_validation_cleanup_confirmation_started",
|
|
72
|
+
"The Bridge suite hit the known Windows temporary-worktree cleanup race; confirming once with the same command and attempt environment.",
|
|
73
|
+
],
|
|
74
|
+
passed: [
|
|
75
|
+
"prepublication_validation_cleanup_confirmation_passed",
|
|
76
|
+
"The complete Bridge test step passed on its single cleanup confirmation run.",
|
|
77
|
+
],
|
|
78
|
+
failedEvent: "prepublication_validation_cleanup_confirmation_failed",
|
|
79
|
+
failedContent: exitCode => `The complete Bridge test step failed on its single cleanup confirmation run (exit ${exitCode}).`,
|
|
80
|
+
};
|
|
81
|
+
export { PrePublicationValidationError };
|
|
82
|
+
export class PrePublicationInfrastructureError extends ForgeFailureError {
|
|
83
|
+
checkId;
|
|
84
|
+
exitCode;
|
|
85
|
+
command;
|
|
86
|
+
args;
|
|
87
|
+
detail;
|
|
88
|
+
code = "prepublication_infrastructure_failed";
|
|
89
|
+
constructor(checkId, exitCode, command, args, detail) {
|
|
90
|
+
super("prepublication_infrastructure_failed", `prepublication_infrastructure_failed: ${checkId} exited ${exitCode}${detail ? `: ${detail}` : ""}`, "bridge");
|
|
91
|
+
this.checkId = checkId;
|
|
92
|
+
this.exitCode = exitCode;
|
|
93
|
+
this.command = command;
|
|
94
|
+
this.args = args;
|
|
95
|
+
this.detail = detail;
|
|
96
|
+
this.name = "PrePublicationInfrastructureError";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export class PrePublicationValidator {
|
|
100
|
+
commands;
|
|
101
|
+
dockerEngineProbe;
|
|
102
|
+
nativeTestPostgresFallback;
|
|
103
|
+
hostLoad;
|
|
104
|
+
startEphemeral;
|
|
105
|
+
constructor(commands = new ProcessPrePublicationCommandRunner(), dockerEngineProbe, nativeTestPostgresFallback = () => null, hostLoad, startEphemeral) {
|
|
106
|
+
this.commands = commands;
|
|
107
|
+
this.dockerEngineProbe = dockerEngineProbe;
|
|
108
|
+
this.nativeTestPostgresFallback = nativeTestPostgresFallback;
|
|
109
|
+
this.hostLoad = hostLoad;
|
|
110
|
+
this.startEphemeral = startEphemeral;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Runs one pre-publication pass. A failed check does not end the pass: every remaining check that
|
|
114
|
+
* can still meaningfully run keeps going, and the pass then throws all of its failures as one
|
|
115
|
+
* PrePublicationValidationError.
|
|
116
|
+
*/
|
|
117
|
+
async validate(worktreePath, profile, capabilities, emit, signal, execution) {
|
|
118
|
+
const checksExports = profile === "implementation" || profile === "comment_repair";
|
|
119
|
+
const pass = new PrePublicationPass(execution?.runtimeRestartFailure);
|
|
120
|
+
const contract = await loadValidationContract(worktreePath);
|
|
121
|
+
if (contract === null) {
|
|
122
|
+
await emit?.(validationEvent("prepublication_validation_legacy_contract", "legacy-provider-validation", `This checkout predates ${contractRelativePath}; Bridge preserved legacy provider validation without source mutation.`));
|
|
123
|
+
if (checksExports) {
|
|
124
|
+
const legacy = await prepareValidationExecution(execution);
|
|
125
|
+
try {
|
|
126
|
+
await this.checkTestOnlyExports(pass, worktreePath, emit, signal, legacy.execution);
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
await legacy.cleanup();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
pass.throwIfFailed();
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
const scoped = await prepareValidationExecution(execution);
|
|
136
|
+
try {
|
|
137
|
+
if (checksExports)
|
|
138
|
+
await this.checkTestOnlyExports(pass, worktreePath, emit, signal, scoped.execution);
|
|
139
|
+
const contractDigest = validationContractDigest(contract);
|
|
140
|
+
await this.assertContractMatchesDispatchBaseline(worktreePath, contractDigest, signal, scoped.execution);
|
|
141
|
+
if (contractDigest !== currentApprovedContractDigest) {
|
|
142
|
+
await emit?.(validationEvent("prepublication_validation_compatible_contract", "validation-contract", `This checkout is pinned to approved compatible CI parity contract ${contractDigest}; the host's current contract is ${currentApprovedContractDigest}.`));
|
|
143
|
+
}
|
|
144
|
+
const changedPaths = await this.changedPaths(worktreePath, signal, scoped.execution);
|
|
145
|
+
const run = {
|
|
146
|
+
worktreePath,
|
|
147
|
+
capabilities,
|
|
148
|
+
emit,
|
|
149
|
+
signal,
|
|
150
|
+
execution: withValidationBaseRevision(scoped.execution),
|
|
151
|
+
postgresAdminConnection: scoped.postgresAdminConnection,
|
|
152
|
+
};
|
|
153
|
+
return await this.runChecks(applicableChecks(contract, profile, changedPaths), run, pass);
|
|
154
|
+
}
|
|
155
|
+
finally {
|
|
156
|
+
await scoped.cleanup();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async runChecks(checks, run, pass) {
|
|
160
|
+
const completed = [];
|
|
161
|
+
for (const check of checks) {
|
|
162
|
+
if (check.providerOnly) {
|
|
163
|
+
await run.emit?.(validationEvent("prepublication_validation_provider_only", check.id, `Preserved provider-only validation '${check.id}' for the provider check run.`));
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const blockedBy = pass.blockers(check.id);
|
|
167
|
+
if (blockedBy.length > 0) {
|
|
168
|
+
await run.emit?.(skippedCheckEvent(check.id, blockedBy));
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
const failed = await this.runCheck(check, run);
|
|
173
|
+
// A cancelled step may settle with an exit code rather than throw; the pass ends either way.
|
|
174
|
+
run.signal?.throwIfAborted();
|
|
175
|
+
if (failed)
|
|
176
|
+
pass.record(failed.failure, failed.step);
|
|
177
|
+
else
|
|
178
|
+
completed.push(check.id);
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
if (!pass.stopsAt(error, run.signal))
|
|
182
|
+
throw error;
|
|
183
|
+
await run.emit?.(pass.stoppedEvent(check.id, error));
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
pass.throwIfFailed();
|
|
188
|
+
return completed;
|
|
189
|
+
}
|
|
190
|
+
/** Runs one check's steps in order; the first failed step ends the check, since later steps use its output. */
|
|
191
|
+
async runCheck(check, run) {
|
|
192
|
+
if (check.requiredCapability && !run.capabilities.has(check.requiredCapability)) {
|
|
193
|
+
throw new ForgeFailureError("prepublication_capability_unavailable", `prepublication_capability_unavailable: ${check.id} requires ${check.requiredCapability}; publication is holding until a capable runner is available.`, "bridge");
|
|
194
|
+
}
|
|
195
|
+
const granted = await this.ensurePrerequisite(check, run.execution?.environment, run.postgresAdminConnection, run.emit);
|
|
196
|
+
try {
|
|
197
|
+
return await this.runCheckSteps({ ...run, check, postgresAdminConnection: granted ?? run.postgresAdminConnection });
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
200
|
+
await releaseCheckPostgres(check.id, granted, run.emit);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async runCheckSteps(stepRun) {
|
|
204
|
+
const { check, ...run } = stepRun;
|
|
205
|
+
await run.emit?.(validationEvent("prepublication_validation_started", check.id, `Running pre-publication CI parity check '${check.id}'.`));
|
|
206
|
+
const skipped = new SkippedTestTally(run.worktreePath, run.execution?.environment);
|
|
207
|
+
for (const step of check.steps) {
|
|
208
|
+
const stepStartedMs = Date.now() - 1000;
|
|
209
|
+
const result = await this.runConfirmedStep(stepRun, step);
|
|
210
|
+
if (result.exitCode !== 0) {
|
|
211
|
+
const detail = diagnosticDetail(result);
|
|
212
|
+
await run.emit?.(validationEvent("prepublication_validation_failed", check.id, `Pre-publication CI parity check '${check.id}' exited ${result.exitCode}${detail ? `: ${detail}` : "."}`));
|
|
213
|
+
return {
|
|
214
|
+
failure: { checkId: check.id, exitCode: result.exitCode, command: result.command, args: result.args, detail },
|
|
215
|
+
step,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
await skipped.add(result.args, stepStartedMs);
|
|
219
|
+
}
|
|
220
|
+
// The check's own grant reaches only its steps' derived environments, so name its secrets too.
|
|
221
|
+
await run.emit?.(skipped.passedEvent(check.id, [
|
|
222
|
+
...validationExactSecrets(run.execution?.environment),
|
|
223
|
+
...attemptDatabaseCapabilitySecrets(run.postgresAdminConnection?.connectionString),
|
|
224
|
+
]));
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
/** Runs a step, confirming once a failure that matches a known transient pattern. */
|
|
228
|
+
async runConfirmedStep(run, step) {
|
|
229
|
+
let result = await this.runCheckedStep(run, step);
|
|
230
|
+
if (isTimeoutOnlyClientTestFailure(run.check.id, step, result)) {
|
|
231
|
+
result = await this.confirmStep(run, step, timeoutConfirmation);
|
|
232
|
+
}
|
|
233
|
+
if (isTransientBridgeCleanupFailure(run.check.id, step, result)) {
|
|
234
|
+
result = await this.confirmStep(run, step, cleanupConfirmation);
|
|
235
|
+
}
|
|
236
|
+
if (isTransientShellInfrastructureFailure(result)) {
|
|
237
|
+
result = await this.confirmInfrastructure(run, step);
|
|
238
|
+
}
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
241
|
+
async runCheckedStep(run, step) {
|
|
242
|
+
const { check, worktreePath, signal, execution, postgresAdminConnection, emit } = run;
|
|
243
|
+
const result = await this.runStep(check.id, step, worktreePath, signal, execution, postgresAdminConnection, emit);
|
|
244
|
+
await this.throwIfPrerequisiteWasLost(check, result, execution?.environment, postgresAdminConnection, emit);
|
|
245
|
+
return result;
|
|
246
|
+
}
|
|
247
|
+
async confirmStep(run, step, confirmation) {
|
|
248
|
+
await run.emit?.(validationEvent(confirmation.started[0], run.check.id, confirmation.started[1]));
|
|
249
|
+
const result = await this.runCheckedStep(run, step);
|
|
250
|
+
await run.emit?.(result.exitCode === 0
|
|
251
|
+
? validationEvent(confirmation.passed[0], run.check.id, confirmation.passed[1])
|
|
252
|
+
: validationEvent(confirmation.failedEvent, run.check.id, confirmation.failedContent(result.exitCode)));
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
async confirmInfrastructure(run, step) {
|
|
256
|
+
const checkId = run.check.id;
|
|
257
|
+
await run.emit?.(validationEvent("prepublication_infrastructure_confirmation_started", checkId, "The validation shell reported a known host-runtime failure; confirming once with the same command and attempt environment."));
|
|
258
|
+
const result = await this.runCheckedStep(run, step);
|
|
259
|
+
const infrastructureFailed = isTransientShellInfrastructureFailure(result);
|
|
260
|
+
await run.emit?.(validationEvent(infrastructureFailed
|
|
261
|
+
? "prepublication_infrastructure_confirmation_failed"
|
|
262
|
+
: "prepublication_infrastructure_confirmation_passed", checkId, infrastructureFailed
|
|
263
|
+
? `The validation shell failed again on its single infrastructure confirmation run (exit ${result.exitCode}).`
|
|
264
|
+
: result.exitCode === 0
|
|
265
|
+
? "The validation step recovered on its single infrastructure confirmation run."
|
|
266
|
+
: "The host-runtime failure did not recur; continuing with normal validation failure handling."));
|
|
267
|
+
if (!infrastructureFailed)
|
|
268
|
+
return result;
|
|
269
|
+
const detail = diagnosticDetail(result);
|
|
270
|
+
await run.emit?.(validationEvent("prepublication_infrastructure_failed", checkId, `Pre-publication infrastructure for '${checkId}' remained unavailable${detail ? `: ${detail}` : "."}`));
|
|
271
|
+
throw new PrePublicationInfrastructureError(checkId, result.exitCode, result.command, result.args, detail);
|
|
272
|
+
}
|
|
273
|
+
/** Returns the native cluster grant when this check uses it instead of Docker. */
|
|
274
|
+
async ensurePrerequisite(check, environment, postgresAdminConnection, emit) {
|
|
275
|
+
if (check.requiredPrerequisite === "isolated_postgres"
|
|
276
|
+
&& isolatedPostgresProvided(check.id, environment, postgresAdminConnection)) {
|
|
277
|
+
await emit?.(validationEvent("prepublication_prerequisite_ready", check.id, check.id === "playwright-e2e"
|
|
278
|
+
? `Pre-publication check '${check.id}' is using its attempt-owned PostgreSQL database. No Docker daemon is required.`
|
|
279
|
+
: `Pre-publication check '${check.id}' is using the configured loopback PostgreSQL test server with per-run owned databases. No Docker daemon is required.`));
|
|
280
|
+
return undefined;
|
|
281
|
+
}
|
|
282
|
+
return await preferredNativeTestPostgres(check.id, check.requiredPrerequisite, this.nativeTestPostgresFallback, this.dockerEngineProbe, emit, this.startEphemeral)
|
|
283
|
+
?? await this.ensureDockerPrerequisite(check, emit);
|
|
284
|
+
}
|
|
285
|
+
/** Waits for Docker; returns the native cluster grant when Docker stays down and a cluster is provisioned. */
|
|
286
|
+
async ensureDockerPrerequisite(check, emit) {
|
|
287
|
+
if (check.requiredPrerequisite === undefined || !this.dockerEngineProbe)
|
|
288
|
+
return undefined;
|
|
289
|
+
const current = this.dockerEngineProbe.current();
|
|
290
|
+
await emit?.(validationEvent(current?.available === false
|
|
291
|
+
? "prepublication_prerequisite_recovery_waiting"
|
|
292
|
+
: "prepublication_prerequisite_verification_started", check.id, current?.available === false
|
|
293
|
+
? `Waiting for Docker recovery before pre-publication check '${check.id}'.`
|
|
294
|
+
: `Verifying Docker immediately before pre-publication check '${check.id}'.`));
|
|
295
|
+
const snapshot = await this.dockerEngineProbe.ensureAvailableForRequiredWork();
|
|
296
|
+
if (!snapshot.available) {
|
|
297
|
+
const detail = `Docker prerequisite unavailable (${snapshot.unavailableCode ?? "docker_engine_unavailable"}): ${snapshot.unavailableReason ?? "the daemon did not pass a fresh readiness probe"}`;
|
|
298
|
+
const fallback = dockerUnavailableNativeTestPostgres(check.id, check.requiredPrerequisite, this.nativeTestPostgresFallback);
|
|
299
|
+
if (fallback) {
|
|
300
|
+
await emit?.(validationEvent("prepublication_prerequisite_native_fallback", check.id, `${detail}. Pre-publication check '${check.id}' is using the dedicated native PostgreSQL test cluster at ${fallback.endpoint} with per-run owned databases.`));
|
|
301
|
+
return fallback;
|
|
302
|
+
}
|
|
303
|
+
await emit?.(validationEvent("prepublication_prerequisite_unavailable", check.id, `Pre-publication check '${check.id}' is waiting for Docker infrastructure recovery: ${detail}`));
|
|
304
|
+
throw new PrePublicationInfrastructureError(check.id, 75, "docker", ["info"], detail);
|
|
305
|
+
}
|
|
306
|
+
await emit?.(validationEvent("prepublication_prerequisite_ready", check.id, `Docker passed a fresh daemon probe for pre-publication check '${check.id}'.`));
|
|
307
|
+
return undefined;
|
|
308
|
+
}
|
|
309
|
+
async throwIfPrerequisiteWasLost(check, result, environment, postgresAdminConnection, emit) {
|
|
310
|
+
if (result.exitCode === 0
|
|
311
|
+
|| check.requiredPrerequisite === undefined
|
|
312
|
+
|| (check.requiredPrerequisite === "isolated_postgres"
|
|
313
|
+
&& isolatedPostgresProvided(check.id, environment, dockerFreeGrant(postgresAdminConnection)))
|
|
314
|
+
|| !this.dockerEngineProbe)
|
|
315
|
+
return;
|
|
316
|
+
const snapshot = await this.dockerEngineProbe.refresh(true);
|
|
317
|
+
if (snapshot.available)
|
|
318
|
+
return;
|
|
319
|
+
const detail = `Docker became unavailable while '${check.id}' was running (${snapshot.unavailableCode ?? "docker_engine_unavailable"}): ${snapshot.unavailableReason ?? "the daemon did not pass the failure-time probe"}`;
|
|
320
|
+
await emit?.(validationEvent("prepublication_prerequisite_lost", check.id, `${detail}. The failed command is classified as retryable infrastructure and will not consume an agent repair turn.`));
|
|
321
|
+
throw new PrePublicationInfrastructureError(check.id, result.exitCode, result.command, result.args, detail);
|
|
322
|
+
}
|
|
323
|
+
// Runs for every target repository, with or without a CI parity contract: it only reads the worktree.
|
|
324
|
+
// A failure joins the pass's failures; the contract's checks still run.
|
|
325
|
+
async checkTestOnlyExports(pass, worktreePath, emit, signal, execution) {
|
|
326
|
+
const found = await findUnreferencedNewExports(args => this.runCommand("git", args, worktreePath, signal, execution), worktreePath, execution?.baselineRevision);
|
|
327
|
+
const unused = found.filter(row => !row.testOnly);
|
|
328
|
+
if (unused.length > 0) {
|
|
329
|
+
await emit?.(validationEvent("prepublication_unreferenced_exports", "unreferenced-exports", `New exports with no caller yet: ${unused.map(row => `${row.name} (${row.path})`).join(", ")}. Wire them to a real caller or keep them unexported.`));
|
|
330
|
+
}
|
|
331
|
+
const testOnly = found.filter(row => row.testOnly);
|
|
332
|
+
if (testOnly.length === 0)
|
|
333
|
+
return;
|
|
334
|
+
const detail = `only tests use ${testOnly.map(row => `${row.name} (${row.path})`).join(", ")}. Wire each to a real caller in this Story, or move the export and its test to the Story that first uses it. Do not delete assertions to pass.`;
|
|
335
|
+
await emit?.(validationEvent("prepublication_validation_failed", "unreferenced-exports", `New code is tested but never called: ${detail}`));
|
|
336
|
+
pass.record({ checkId: "unreferenced-exports", exitCode: 1, command: "git", args: ["grep"], detail });
|
|
337
|
+
}
|
|
338
|
+
async changedPaths(worktreePath, signal, execution) {
|
|
339
|
+
const baselineRevision = execution?.baselineRevision?.trim();
|
|
340
|
+
const requests = [
|
|
341
|
+
["diff", "--name-only", "HEAD", "--"],
|
|
342
|
+
...(baselineRevision ? [["diff", "--name-only", `${baselineRevision}..HEAD`, "--"]] : []),
|
|
343
|
+
["status", "--porcelain=v1", "--untracked-files=all"],
|
|
344
|
+
];
|
|
345
|
+
const paths = new Set();
|
|
346
|
+
for (const args of requests) {
|
|
347
|
+
const result = await this.runCommand("git", args, worktreePath, signal, execution);
|
|
348
|
+
if (result.exitCode !== 0) {
|
|
349
|
+
throw new ForgeFailureError("prepublication_validation_failed", `prepublication_validation_failed: unable to inventory changed paths: ${result.stderr ?? result.stdout ?? "git failed"}`, "bridge");
|
|
350
|
+
}
|
|
351
|
+
for (const line of `${result.stdout ?? ""}`.split(/\r?\n/u).filter(Boolean)) {
|
|
352
|
+
const raw = args[0] === "status" ? line.slice(3).split(" -> ").at(-1) ?? "" : line;
|
|
353
|
+
const normalized = raw.trim().replaceAll("\\", "/");
|
|
354
|
+
if (normalized)
|
|
355
|
+
paths.add(normalized);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return [...paths];
|
|
359
|
+
}
|
|
360
|
+
async assertContractMatchesDispatchBaseline(worktreePath, contractDigest, signal, execution) {
|
|
361
|
+
const baselineRevision = execution?.baselineRevision?.trim();
|
|
362
|
+
if (!baselineRevision)
|
|
363
|
+
return;
|
|
364
|
+
const result = await this.runCommand("git", ["show", `${baselineRevision}:${contractRelativePath}`], worktreePath, signal, execution);
|
|
365
|
+
if (result.exitCode !== 0) {
|
|
366
|
+
throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the dispatch baseline contract could not be read from ${baselineRevision}: ${result.stderr ?? result.stdout ?? "git show failed"}`, "bridge");
|
|
367
|
+
}
|
|
368
|
+
let baselineContract;
|
|
369
|
+
try {
|
|
370
|
+
baselineContract = JSON.parse(result.stdout ?? "");
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the dispatch baseline contract at ${baselineRevision} is not valid JSON.`, "bridge", { cause: error });
|
|
374
|
+
}
|
|
375
|
+
const baselineDigest = validationContractDigest(baselineContract);
|
|
376
|
+
if (!approvedContractDigests.has(baselineDigest)) {
|
|
377
|
+
throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the dispatch baseline uses unapproved CI parity contract ${baselineDigest}.`, "bridge");
|
|
378
|
+
}
|
|
379
|
+
// A conflict repair's uncommitted merge brings the target branch's contract with it.
|
|
380
|
+
if (baselineDigest !== contractDigest && await this.mergedInContractDigest(worktreePath, signal, execution) !== contractDigest) {
|
|
381
|
+
throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the CI parity contract changed after dispatch (baseline ${baselineDigest}, worktree ${contractDigest}).`, "bridge");
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
/** The approved contract of the branch an in-progress merge brings in (MERGE_HEAD), else null. */
|
|
385
|
+
async mergedInContractDigest(worktreePath, signal, execution) {
|
|
386
|
+
const merged = await this.runCommand("git", ["show", `MERGE_HEAD:${contractRelativePath}`], worktreePath, signal, execution);
|
|
387
|
+
if (merged.exitCode !== 0)
|
|
388
|
+
return null;
|
|
389
|
+
try {
|
|
390
|
+
const digest = validationContractDigest(JSON.parse(merged.stdout ?? ""));
|
|
391
|
+
return approvedContractDigests.has(digest) ? digest : null;
|
|
392
|
+
}
|
|
393
|
+
catch {
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
async runStep(checkId, step, cwd, signal, execution, postgresAdminConnection, emit) {
|
|
398
|
+
const invocation = managedAttemptInvocation(checkId, step, execution?.environment);
|
|
399
|
+
// Every launch, including confirmation reruns, is admitted by the host load governor first.
|
|
400
|
+
return await runHostGovernedValidationStep(this.hostLoad, {
|
|
401
|
+
checkId, command: invocation.command, args: invocation.args, owner: execution?.hostLoadOwner, signal, emit,
|
|
402
|
+
}, async (stepSignal) => await this.launchStep(checkId, step, invocation, cwd, stepSignal, execution, postgresAdminConnection));
|
|
403
|
+
}
|
|
404
|
+
async launchStep(checkId, step, invocation, cwd, signal, execution, postgresAdminConnection) {
|
|
405
|
+
const stepExecution = validationExecutionForStep(checkId, step, execution, postgresAdminConnection);
|
|
406
|
+
const before = await readValidationFiles(cwd, step.assertUnchangedPaths ?? []);
|
|
407
|
+
const result = await this.runCommand(invocation.command, invocation.args, cwd, signal, stepExecution);
|
|
408
|
+
if (result.exitCode === 127 && step.fallbackCommand) {
|
|
409
|
+
const fallback = await this.runCommand(step.fallbackCommand, step.fallbackArgs ?? step.args, cwd, signal, stepExecution);
|
|
410
|
+
return {
|
|
411
|
+
...await assertValidationFilesUnchanged(cwd, before, fallback),
|
|
412
|
+
command: step.fallbackCommand,
|
|
413
|
+
args: step.fallbackArgs ?? step.args,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
return {
|
|
417
|
+
...await assertValidationFilesUnchanged(cwd, before, result),
|
|
418
|
+
command: invocation.command,
|
|
419
|
+
args: invocation.args,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
async runCommand(command, args, cwd, signal, execution) {
|
|
423
|
+
const exactSecrets = validationExactSecrets(execution?.environment);
|
|
424
|
+
try {
|
|
425
|
+
if (execution?.processRunner) {
|
|
426
|
+
const launch = await pnpmDirectoryLaunch(command, args, cwd);
|
|
427
|
+
const result = await execution.processRunner.run({
|
|
428
|
+
command,
|
|
429
|
+
args: launch.args,
|
|
430
|
+
cwd: launch.cwd,
|
|
431
|
+
env: execution.environment,
|
|
432
|
+
captureOutput: true,
|
|
433
|
+
failureRedactionValues: exactSecrets,
|
|
434
|
+
}, undefined, signal);
|
|
435
|
+
return {
|
|
436
|
+
exitCode: result.exitCode,
|
|
437
|
+
stdout: result.stdout === undefined ? undefined : redactText(result.stdout, exactSecrets),
|
|
438
|
+
stderr: result.stderr === undefined ? undefined : redactText(result.stderr, exactSecrets),
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
const result = await this.commands.run(command, args, cwd, signal, execution?.environment);
|
|
442
|
+
return {
|
|
443
|
+
...result,
|
|
444
|
+
stdout: result.stdout === undefined ? undefined : redactText(result.stdout, exactSecrets),
|
|
445
|
+
stderr: result.stderr === undefined ? undefined : redactText(result.stderr, exactSecrets),
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
catch (error) {
|
|
449
|
+
// Carries the check its host capacity token waits on; it names only the executable.
|
|
450
|
+
if (error instanceof ProcessTreeTerminationError)
|
|
451
|
+
throw error;
|
|
452
|
+
throw sanitizeFailureError(error, exactSecrets);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
function validationExactSecrets(environment) {
|
|
457
|
+
return [
|
|
458
|
+
// The connection strings and their passwords: a test may print either.
|
|
459
|
+
...attemptDatabaseCapabilitySecrets(environment?.[hostRuntimeTestPostgresAdminEnvironment]),
|
|
460
|
+
...attemptDatabaseCapabilitySecrets(environment?.[hostRuntimeLegacyTestPostgresEnvironment]),
|
|
461
|
+
environment?.[hostRuntimeTestPostgresProvisionerEnvironment]?.trim() ?? "",
|
|
462
|
+
...attemptDatabaseCapabilitySecrets(environment?.[attemptDatabaseCapabilityEnvironment]),
|
|
463
|
+
].filter((value, index, values) => value.length > 0 && values.indexOf(value) === index);
|
|
464
|
+
}
|
|
465
|
+
function diagnosticDetail(result) {
|
|
466
|
+
const diagnostic = [result.stderr, result.stdout]
|
|
467
|
+
.map(value => value?.trim() ?? "")
|
|
468
|
+
.filter(Boolean)
|
|
469
|
+
.join("\n");
|
|
470
|
+
if (diagnostic.length <= 6000)
|
|
471
|
+
return diagnostic;
|
|
472
|
+
const lines = diagnostic.split(/\r?\n/u);
|
|
473
|
+
const signal = /(?:^|\s)(?:fail(?:ed|ure)?|error|assertionerror|expected|received|×|❯|not ok)(?:\s|:|$)/iu;
|
|
474
|
+
const signalIndexes = new Set();
|
|
475
|
+
for (const [index, line] of lines.entries()) {
|
|
476
|
+
if (!signal.test(line))
|
|
477
|
+
continue;
|
|
478
|
+
for (let contextIndex = index; contextIndex <= Math.min(lines.length - 1, index + 1); contextIndex += 1) {
|
|
479
|
+
signalIndexes.add(contextIndex);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
const head = diagnostic.slice(0, 1200);
|
|
483
|
+
const focused = [...signalIndexes]
|
|
484
|
+
.sort((left, right) => left - right)
|
|
485
|
+
.map(index => lines[index].slice(0, 1200))
|
|
486
|
+
.join("\n")
|
|
487
|
+
.slice(0, 3000);
|
|
488
|
+
const tail = diagnostic.slice(-1600);
|
|
489
|
+
return [
|
|
490
|
+
head,
|
|
491
|
+
focused ? `--- failure-focused excerpt ---\n${focused}` : "",
|
|
492
|
+
`--- diagnostic tail ---\n${tail}`,
|
|
493
|
+
].filter(Boolean).join("\n").slice(0, 6000);
|
|
494
|
+
}
|
|
495
|
+
function isTimeoutOnlyClientTestFailure(checkId, step, result) {
|
|
496
|
+
if (checkId !== "client"
|
|
497
|
+
|| step.command !== "pnpm"
|
|
498
|
+
|| step.args.join("\0") !== ["--dir", "client", "test"].join("\0")
|
|
499
|
+
|| result.exitCode !== 1) {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
// Only the owned Vitest suite is eligible. A compiler, build, assertion,
|
|
503
|
+
// missing-test, or ambiguous output failure remains terminal.
|
|
504
|
+
const output = [result.stdout, result.stderr].filter(Boolean).join("\n")
|
|
505
|
+
.replace(ansiColorSequence, "");
|
|
506
|
+
if (!output.includes("client_suite_test_failed: Vitest exited 1"))
|
|
507
|
+
return false;
|
|
508
|
+
const lines = output.split(/\r?\n/u);
|
|
509
|
+
const failedTasks = lines.map(line => line.trim())
|
|
510
|
+
.filter(line => /^Failed:\s+@forge\/\S+#test$/u.test(line));
|
|
511
|
+
if (failedTasks.length !== 1 || !/^Failed:\s+@forge\/web#test$/u.test(failedTasks[0])) {
|
|
512
|
+
return false;
|
|
513
|
+
}
|
|
514
|
+
const webLines = lines.filter(line => /^@forge\/web:test:/u.test(line))
|
|
515
|
+
.map(line => line.replace(/^@forge\/web:test:\s*/u, "").trim());
|
|
516
|
+
const failedTests = webLines.map(line => line.match(/\bFailed Tests\s+(\d+)\b/u)).find(Boolean);
|
|
517
|
+
const summary = webLines.find(line => /^Tests\s+\d+ failed\s*\|\s*\d+ passed/u.test(line));
|
|
518
|
+
const expectedCount = failedTests ? Number(failedTests[1]) : 0;
|
|
519
|
+
const summaryCount = summary ? Number(summary.match(/^Tests\s+(\d+) failed/u)?.[1]) : 0;
|
|
520
|
+
const failures = webLines.flatMap((line, index) => /^FAIL\s+\S/u.test(line) ? [index] : []);
|
|
521
|
+
if (expectedCount === 0 || expectedCount !== summaryCount || failures.length !== expectedCount) {
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
return failures.every((start, index) => {
|
|
525
|
+
const end = index + 1 < failures.length ? failures[index + 1] : webLines.length;
|
|
526
|
+
const firstError = webLines.slice(start + 1, end)
|
|
527
|
+
.find(line => /^(?:Error|AssertionError):/u.test(line));
|
|
528
|
+
return /^Error: Test timed out in \d+ms\.$/u.test(firstError ?? "");
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
function isTransientBridgeCleanupFailure(checkId, step, result) {
|
|
532
|
+
if (checkId !== "bridge"
|
|
533
|
+
|| step.command !== "npm"
|
|
534
|
+
|| step.args.join("\0") !== ["--prefix", "tools/forge-bridge", "test"].join("\0")
|
|
535
|
+
|| result.exitCode !== 1) {
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
538
|
+
// Retry only the exact Windows cleanup race observed after the cancellation
|
|
539
|
+
// readiness test. Assertions, compile failures, and unrelated EBUSY errors
|
|
540
|
+
// remain terminal and cannot consume this confirmation run.
|
|
541
|
+
const output = [result.stdout, result.stderr].filter(Boolean).join("\n")
|
|
542
|
+
.replace(ansiColorSequence, "");
|
|
543
|
+
return /\bEBUSY:\s+resource busy or locked,\s+rmdir\s+['"][^'"\r\n]*forge-prepared-probe-cancel-[^'"\r\n]*\\worktree['"]/iu.test(output)
|
|
544
|
+
&& output.includes("waits for probe cleanup on cancellation and never publishes its evidence");
|
|
545
|
+
}
|
|
546
|
+
function isTransientShellInfrastructureFailure(result) {
|
|
547
|
+
if (result.exitCode === 0)
|
|
548
|
+
return false;
|
|
549
|
+
const output = [result.stdout, result.stderr].filter(Boolean).join("\n")
|
|
550
|
+
.replace(ansiColorSequence, "");
|
|
551
|
+
return /(?:Bash\/Service\/E_UNEXPECTED|Wsl\/Service\/E_UNEXPECTED|child_copy: cygheap read copy failed|couldn't create signal pipe)/iu.test(output);
|
|
552
|
+
}
|
|
553
|
+
async function prepareValidationExecution(execution) {
|
|
554
|
+
assertHostDatabaseCapabilityBoundary();
|
|
555
|
+
// Validation executes mutable worktree scripts, SDK targets, and tests. It
|
|
556
|
+
// never inherits a host PostgreSQL administrative capability; the only
|
|
557
|
+
// non-container database is the dedicated native test cluster, selected per
|
|
558
|
+
// check in ensurePrerequisite when Docker is unavailable.
|
|
559
|
+
const postgresAdminConnection = undefined;
|
|
560
|
+
const scopedExecution = execution === undefined
|
|
561
|
+
? undefined
|
|
562
|
+
: { ...execution, environment: withoutPrivilegedPostgresEnvironment(execution.environment) };
|
|
563
|
+
if (process.platform !== "win32" || !execution) {
|
|
564
|
+
return { execution: scopedExecution, postgresAdminConnection, cleanup: async () => undefined };
|
|
565
|
+
}
|
|
566
|
+
const systemDrive = process.env.SystemDrive?.trim() || "C:";
|
|
567
|
+
const configuredRoot = scopedExecution?.environment?.FORGE_VALIDATION_TEMP_ROOT?.trim()
|
|
568
|
+
|| process.env.FORGE_VALIDATION_TEMP_ROOT?.trim();
|
|
569
|
+
const root = configuredRoot || path.win32.join(systemDrive, "ForgeValidationTmp");
|
|
570
|
+
const temporaryRoot = path.win32.join(root, `${process.pid}-${randomUUID().slice(0, 8)}`);
|
|
571
|
+
await fs.mkdir(temporaryRoot, { recursive: true });
|
|
572
|
+
return {
|
|
573
|
+
execution: {
|
|
574
|
+
...scopedExecution,
|
|
575
|
+
environment: {
|
|
576
|
+
...scopedExecution?.environment,
|
|
577
|
+
TEMP: temporaryRoot,
|
|
578
|
+
TMP: temporaryRoot,
|
|
579
|
+
TMPDIR: temporaryRoot,
|
|
580
|
+
},
|
|
581
|
+
},
|
|
582
|
+
postgresAdminConnection,
|
|
583
|
+
cleanup: async () => {
|
|
584
|
+
await fs.rm(temporaryRoot, { recursive: true, force: true, maxRetries: 15, retryDelay: 100 });
|
|
585
|
+
},
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
function withoutPrivilegedPostgresEnvironment(environment) {
|
|
589
|
+
if (!environment)
|
|
590
|
+
return undefined;
|
|
591
|
+
const privilegedNames = new Set([
|
|
592
|
+
hostRuntimeTestPostgresAdminEnvironment.toLowerCase(),
|
|
593
|
+
hostRuntimeLegacyTestPostgresEnvironment.toLowerCase(),
|
|
594
|
+
hostRuntimeTestPostgresProvisionerEnvironment.toLowerCase(),
|
|
595
|
+
]);
|
|
596
|
+
return Object.fromEntries(Object.entries(environment)
|
|
597
|
+
.filter(([name]) => !privilegedNames.has(name.toLowerCase())));
|
|
598
|
+
}
|
|
599
|
+
async function readValidationFiles(cwd, relativePaths) {
|
|
600
|
+
const values = new Map();
|
|
601
|
+
for (const relativePath of relativePaths) {
|
|
602
|
+
values.set(relativePath, await fs.readFile(path.join(cwd, relativePath), "utf8"));
|
|
603
|
+
}
|
|
604
|
+
return values;
|
|
605
|
+
}
|
|
606
|
+
async function assertValidationFilesUnchanged(cwd, before, result) {
|
|
607
|
+
if (result.exitCode !== 0)
|
|
608
|
+
return result;
|
|
609
|
+
for (const [relativePath, original] of before) {
|
|
610
|
+
const current = await fs.readFile(path.join(cwd, relativePath), "utf8");
|
|
611
|
+
if (current !== original) {
|
|
612
|
+
return {
|
|
613
|
+
exitCode: 1,
|
|
614
|
+
stderr: `generated_drift: ${relativePath} changed during validation; regenerate and review it before publication.`,
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
return result;
|
|
619
|
+
}
|
|
620
|
+
export function applicableChecks(contract, profile, changedPaths) {
|
|
621
|
+
return contract.checks.filter(check => check.profiles.includes(profile)
|
|
622
|
+
&& changedPaths.some(changedPath => check.changedPathPatterns.some(pattern => new RegExp(pattern, "u").test(changedPath))));
|
|
623
|
+
}
|
|
624
|
+
export async function loadValidationContract(worktreePath) {
|
|
625
|
+
let source;
|
|
626
|
+
try {
|
|
627
|
+
source = await fs.readFile(path.join(worktreePath, contractRelativePath), "utf8");
|
|
628
|
+
}
|
|
629
|
+
catch (error) {
|
|
630
|
+
if (error.code === "ENOENT")
|
|
631
|
+
return null;
|
|
632
|
+
throw error;
|
|
633
|
+
}
|
|
634
|
+
const contract = JSON.parse(source);
|
|
635
|
+
const ids = new Set(contract.checks?.map(check => check.id));
|
|
636
|
+
const contractDigest = validationContractDigest(contract);
|
|
637
|
+
const expectedCheckIds = commentRepairRegressionContractDigests.has(contractDigest)
|
|
638
|
+
? new Set([...requiredCheckIds, "comment-repair-dotnet-regression"])
|
|
639
|
+
: requiredCheckIds;
|
|
640
|
+
if (contract.schemaVersion !== 1
|
|
641
|
+
|| contract.contractId !== "forge-ci-parity-v1"
|
|
642
|
+
|| !approvedContractDigests.has(contractDigest)
|
|
643
|
+
|| expectedCheckIds.size !== ids.size
|
|
644
|
+
|| [...expectedCheckIds].some(id => !ids.has(id))
|
|
645
|
+
|| contract.checks.some(check => !check.id || !Array.isArray(check.steps) || !Array.isArray(check.changedPathPatterns))) {
|
|
646
|
+
throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the Forge CI parity contract does not match an approved definition (digest ${contractDigest}, current ${currentApprovedContractDigest}).`, "bridge");
|
|
647
|
+
}
|
|
648
|
+
return contract;
|
|
649
|
+
}
|
|
650
|
+
/** The affected .NET tests measure the attempt's change against its dispatch baseline (run-affected-dotnet-tests.mjs). */
|
|
651
|
+
function withValidationBaseRevision(execution) {
|
|
652
|
+
const baseline = execution?.baselineRevision?.trim();
|
|
653
|
+
if (!baseline)
|
|
654
|
+
return execution;
|
|
655
|
+
return { ...execution, environment: { ...execution?.environment, FORGE_VALIDATION_BASE_REVISION: baseline } };
|
|
656
|
+
}
|
|
657
|
+
function validationContractDigest(contract) {
|
|
658
|
+
return createHash("sha256")
|
|
659
|
+
.update(JSON.stringify(canonicalizeJson(contract)))
|
|
660
|
+
.digest("hex");
|
|
661
|
+
}
|
|
662
|
+
function canonicalizeJson(value) {
|
|
663
|
+
if (Array.isArray(value))
|
|
664
|
+
return value.map(canonicalizeJson);
|
|
665
|
+
if (value !== null && typeof value === "object") {
|
|
666
|
+
const record = value;
|
|
667
|
+
return Object.fromEntries(Object.keys(record).sort().map(key => [key, canonicalizeJson(record[key])]));
|
|
668
|
+
}
|
|
669
|
+
return value;
|
|
670
|
+
}
|