deepline 0.3.89 → 0.3.91
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/contracts/install-commands.json +29 -0
- package/dist/bundling-sources/sdk/src/client.ts +221 -43
- package/dist/bundling-sources/sdk/src/index.ts +4 -0
- package/dist/bundling-sources/sdk/src/monitor-fleet-contract.ts +2 -556
- package/dist/bundling-sources/sdk/src/monitor-fleets.ts +2 -2
- package/dist/bundling-sources/sdk/src/pagination.ts +25 -0
- package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +1 -1
- package/dist/bundling-sources/sdk/src/release.ts +11 -9
- package/dist/bundling-sources/sdk/src/types.ts +29 -1
- package/dist/bundling-sources/shared_libs/integration-contracts/monitor-fleet-contract.ts +549 -0
- package/dist/bundling-sources/shared_libs/monitors/analytics-public.ts +10 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/errors.ts +96 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +8 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/plan.ts +320 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/verdict.ts +106 -0
- package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +8 -1
- package/dist/bundling-sources/shared_libs/monitors/inbound-queue.ts +4 -4
- package/dist/bundling-sources/shared_libs/monitors/inventory-reconciliation.ts +59 -0
- package/dist/bundling-sources/shared_libs/monitors/lifecycle-notifications.ts +7 -9
- package/dist/bundling-sources/shared_libs/monitors/monitor-fleet-limits.ts +2 -12
- package/dist/bundling-sources/shared_libs/monitors/package.json +113 -4
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +56 -9
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-consumer-health.ts +2 -2
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-identity-claims.ts +2 -2
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-public-aliases.ts +1 -1
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +245 -0
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-message.ts +38 -0
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue-ack-probe.ts +94 -0
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue-delivery.ts +60 -0
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue.ts +60 -0
- package/dist/bundling-sources/shared_libs/monitors/snitcher-install-validation.ts +1 -1
- package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +2 -2
- package/dist/bundling-sources/shared_libs/monitors/snitcher-radar.ts +1 -1
- package/dist/bundling-sources/shared_libs/monitors/tracking-provider-integrations.ts +1 -1
- package/dist/bundling-sources/shared_libs/observability/build-context.ts +13 -0
- package/dist/bundling-sources/shared_libs/observability/log-metadata.ts +160 -0
- package/dist/bundling-sources/shared_libs/observability/request-context.ts +68 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +690 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +35 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-work.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-data-plane/neon-constants.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +272 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +46 -1
- package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +66 -1
- package/dist/bundling-sources/shared_libs/play-runtime/async-play-invocation.ts +0 -1
- package/dist/bundling-sources/shared_libs/play-runtime/bounceban-batching.ts +137 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +779 -140
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +46 -0
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-payload-contract.ts +68 -0
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-janitor.ts +103 -0
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-reaper.ts +725 -0
- package/dist/bundling-sources/shared_libs/play-runtime/db-session-lease-store.ts +578 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-execution-relay.ts +521 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-receipt-gateway.ts +1378 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/runtime-topology.ts +1024 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-gateway-route-probe.ts +193 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machine-lifecycle.ts +104 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +1844 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-registry.ts +21 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/process-tree.ts +40 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-gateway-drain.ts +262 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-surface.ts +98 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +303 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-tuple-publication-guardian.ts +70 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-tuple-recovery.ts +519 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/vercel-fly-rollback-alignment.ts +280 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/vercel-production-gate.ts +159 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +29 -0
- package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +23 -0
- package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-invocation-fence.ts +442 -0
- package/dist/bundling-sources/shared_libs/play-runtime/execution-protocol.ts +3 -3
- package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +18 -0
- package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/contracts.ts +66 -0
- package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/job.ts +145 -0
- package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/memory-store.ts +114 -0
- package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/ports.ts +21 -0
- package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/postgres-store.ts +170 -0
- package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +1322 -0
- package/dist/bundling-sources/shared_libs/play-runtime/internal-step-ids.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/lane-retirement-gate.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/launch-source-policy.ts +112 -0
- package/dist/bundling-sources/shared_libs/play-runtime/map-execution-frame.ts +8 -0
- package/dist/bundling-sources/shared_libs/play-runtime/perf-trace.ts +127 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-artifact-runtime-contract.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +24 -1
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/contracts.ts +56 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/index.ts +13 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/job.ts +41 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/ports.ts +17 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/postgres-adapter.ts +54 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/contracts.ts +114 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/engine-suspension.ts +108 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/index.ts +36 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/job.ts +97 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/ports.ts +104 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/postgres-fence-adapter.ts +263 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/worker-terminal-projection.ts +64 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/contracts.ts +29 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/gateway-adapter.ts +56 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/index.ts +15 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/job.ts +65 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/ports.ts +17 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/contracts.ts +42 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/index.ts +17 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +142 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/ports.ts +42 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/postgres-adapter.ts +102 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/contracts.ts +60 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/index.ts +16 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/job.ts +78 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/ports.ts +54 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/postgres-adapter.ts +71 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-batching-registry.ts +4 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/receipt-status.ts +5 -8
- package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +3 -5
- package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +168 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +44 -5
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/child-play-resolver.ts +26 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +3662 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/progress-sidecar.ts +47 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-deadline.ts +84 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-gateway-transport.ts +91 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +424 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-progress-push.ts +321 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-sheet-persistence-retry.ts +110 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +625 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +72 -9
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +6 -12
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +19 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/bundle.ts +0 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +14 -44
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +103 -208
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +201 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-env.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +67 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-release-environment.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-contract.ts +68 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +14 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-telemetry.ts +108 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +4 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +7 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-deadline-reconciliation.ts +88 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-deploy-task.ts +124 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-run-task.ts +68 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +193 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-queue-lifecycle.ts +269 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-queue-suffix.ts +73 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +6642 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +897 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-metrics.ts +120 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-required-env.ts +76 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +476 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-heavy-request-admission.ts +47 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-progress-registry.ts +147 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/index.ts +27 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/lazy.ts +50 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +98 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-budget-state.ts +260 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +1416 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +1255 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +942 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +14636 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +888 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +355 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-terminal-transition.ts +46 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runner-push.ts +60 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +33 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-gateway-health.ts +64 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +835 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +1218 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-operation.ts +207 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-scheduler-schema.ts +10 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/scheduler-capacity.ts +123 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/scheduler-launch-read-observability.ts +78 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/submit-admission.ts +169 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/terminal-contract.ts +20 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-queue-metrics.ts +34 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-resource-metrics.ts +249 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sheet-attempt-sql.ts +7 -0
- package/dist/bundling-sources/shared_libs/play-runtime/step-progress.ts +296 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/native-batch.ts +3 -3
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +20 -1
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +60 -15
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execution-outcome.ts +20 -0
- package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +12 -0
- package/dist/bundling-sources/shared_libs/play-runtime/vercel-protection.ts +14 -1
- package/dist/bundling-sources/shared_libs/play-runtime/webhook-receipt-retry.ts +50 -0
- package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +165 -0
- package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +15 -23
- package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +169 -0
- package/dist/bundling-sources/shared_libs/play-runtime/zerobounce-batching.ts +122 -0
- package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +2 -0
- package/dist/bundling-sources/shared_libs/plays/bundling/repository-adapter.ts +24 -0
- package/dist/bundling-sources/shared_libs/plays/child-run-projection.ts +174 -0
- package/dist/bundling-sources/shared_libs/plays/contracts.ts +2 -0
- package/dist/bundling-sources/shared_libs/plays/deploy/api-client.ts +267 -0
- package/dist/bundling-sources/shared_libs/plays/deploy/control-plane-types.ts +73 -0
- package/dist/bundling-sources/shared_libs/plays/deploy/manifest.ts +162 -0
- package/dist/bundling-sources/shared_libs/plays/deploy/project-serializer.ts +87 -0
- package/dist/bundling-sources/shared_libs/plays/deploy/source-file-path.ts +26 -0
- package/dist/bundling-sources/shared_libs/plays/deploy/target-paths.ts +36 -0
- package/dist/bundling-sources/shared_libs/plays/deployment-status.ts +1 -1
- package/dist/bundling-sources/shared_libs/plays/docflow.ts +1 -1
- package/dist/bundling-sources/shared_libs/plays/launch/input-contract.ts +400 -0
- package/dist/bundling-sources/shared_libs/plays/launch/prepare.ts +96 -0
- package/dist/bundling-sources/shared_libs/plays/local-file-discovery.ts +385 -0
- package/dist/bundling-sources/shared_libs/plays/play-grep-search.ts +112 -0
- package/dist/bundling-sources/shared_libs/plays/play-reference.ts +117 -0
- package/dist/bundling-sources/shared_libs/plays/run-input-summary.ts +260 -0
- package/dist/bundling-sources/shared_libs/plays/run-summary-types.ts +49 -0
- package/dist/bundling-sources/shared_libs/plays/secrets/errors.ts +19 -0
- package/dist/bundling-sources/shared_libs/plays/share/copy.ts +271 -0
- package/dist/bundling-sources/shared_libs/plays/share/metrics.ts +140 -0
- package/dist/bundling-sources/shared_libs/plays/share/public-read-model.ts +86 -0
- package/dist/bundling-sources/shared_libs/plays/share/seo-quality.ts +181 -0
- package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +658 -0
- package/dist/bundling-sources/shared_libs/plays/share/types.ts +197 -0
- package/dist/bundling-sources/shared_libs/plays/sheet-filter.ts +347 -0
- package/dist/bundling-sources/shared_libs/plays/slack-hitl-timeout-error.ts +37 -0
- package/dist/bundling-sources/shared_libs/plays/standard-webhooks.ts +117 -0
- package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +6 -1
- package/dist/bundling-sources/shared_libs/plays/status-result.ts +388 -0
- package/dist/bundling-sources/shared_libs/plays/tool-result-types.ts +1 -1
- package/dist/bundling-sources/shared_libs/plays/transform-factor-structure.ts +377 -0
- package/dist/bundling-sources/shared_libs/plays/webhook-payload.ts +113 -0
- package/dist/bundling-sources/shared_libs/product-notifications/configuration.ts +7 -1
- package/dist/bundling-sources/shared_libs/product-notifications/default-policy.ts +3 -2
- package/dist/bundling-sources/shared_libs/product-notifications/overflow.ts +18 -0
- package/dist/bundling-sources/shared_libs/product-notifications/rolling-limit.ts +24 -0
- package/dist/bundling-sources/shared_libs/product-notifications/slack-delivery.ts +624 -0
- package/dist/bundling-sources/shared_libs/product-notifications/slack-payload.ts +140 -0
- package/dist/bundling-sources/shared_libs/product-notifications/slack-transport.ts +75 -0
- package/dist/bundling-sources/shared_libs/runtime-env.ts +6 -0
- package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +42 -0
- package/dist/bundling-sources/shared_libs/security/header-safe-env.ts +10 -3
- package/dist/bundling-sources/shared_libs/security/slack-sanitize.ts +133 -0
- package/dist/cli/getting-started.d.mts +52 -0
- package/dist/cli/getting-started.d.ts +52 -0
- package/dist/cli/getting-started.js +65 -0
- package/dist/cli/getting-started.mjs +36 -0
- package/dist/cli/index.d.mts +9 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.js +895 -407
- package/dist/cli/index.mjs +893 -414
- package/dist/{compiler-manifest-DsLbQaew.d.mts → compiler-manifest-x14KL83E.d.mts} +4 -2
- package/dist/{compiler-manifest-DsLbQaew.d.ts → compiler-manifest-x14KL83E.d.ts} +4 -2
- package/dist/index.d.mts +124 -154
- package/dist/index.d.ts +124 -154
- package/dist/index.js +132 -28
- package/dist/index.mjs +132 -28
- package/dist/install-integrity.json +182 -2
- package/dist/monitor-fleet-contract.d.mts +131 -0
- package/dist/monitor-fleet-contract.d.ts +131 -0
- package/dist/monitor-fleet-contract.js +406 -0
- package/dist/monitor-fleet-contract.mjs +367 -0
- package/dist/plays/bundle-play-file.d.mts +2 -2
- package/dist/plays/bundle-play-file.d.ts +2 -2
- package/dist/release.d.mts +255 -0
- package/dist/release.d.ts +255 -0
- package/dist/release.js +210 -0
- package/dist/release.mjs +183 -0
- package/package.json +21 -4
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Src-coupled bridge between the vendored Absurd SDK (`packages/absurd`) and
|
|
3
|
+
* the hardened runtime scheduler Postgres pool (`./postgres-pool.ts`).
|
|
4
|
+
*
|
|
5
|
+
* workspace packages stay free of `src/**` imports, so the Absurd client takes an
|
|
6
|
+
* injected `Queryable`. This module supplies that handle by delegating every
|
|
7
|
+
* query through `withRuntimeSchedulerClient`, which is the process-singleton
|
|
8
|
+
* `pg.Pool` with saturation backpressure, a circuit breaker, and idempotent
|
|
9
|
+
* connection-error retries. Each Absurd SQL call is a self-contained plpgsql
|
|
10
|
+
* transaction, so a per-call client checkout is correct — Absurd never relies on
|
|
11
|
+
* cross-call session state.
|
|
12
|
+
*/
|
|
13
|
+
import { createRequire } from 'node:module';
|
|
14
|
+
import { readFileSync } from 'node:fs';
|
|
15
|
+
import path from 'node:path';
|
|
16
|
+
import {
|
|
17
|
+
Absurd,
|
|
18
|
+
type AbsurdOptions,
|
|
19
|
+
type Queryable,
|
|
20
|
+
type QueryResult,
|
|
21
|
+
} from '@deepline/absurd/sdk';
|
|
22
|
+
import {
|
|
23
|
+
ABSURD_SCHEMA_SQL_RELATIVE_PATH,
|
|
24
|
+
ABSURD_SCHEMA_VERSION,
|
|
25
|
+
} from '@deepline/absurd/pool';
|
|
26
|
+
import {
|
|
27
|
+
withRuntimeSchedulerClient,
|
|
28
|
+
type RuntimeSchedulerPoolOptions,
|
|
29
|
+
} from './postgres-pool';
|
|
30
|
+
|
|
31
|
+
export { ABSURD_SCHEMA_VERSION };
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Builds an SDK `Queryable` backed by the hardened runtime scheduler pool.
|
|
35
|
+
* Every query runs on a freshly checked-out pooled client and releases it,
|
|
36
|
+
* inheriting the pool's backpressure/breaker/retry guarantees.
|
|
37
|
+
*/
|
|
38
|
+
export function absurdQueryableForRuntimeScheduler(
|
|
39
|
+
poolOptions: RuntimeSchedulerPoolOptions,
|
|
40
|
+
): Queryable {
|
|
41
|
+
return {
|
|
42
|
+
query: async <Row = Record<string, unknown>>(
|
|
43
|
+
sql: string,
|
|
44
|
+
params?: unknown[],
|
|
45
|
+
): Promise<QueryResult<Row>> => {
|
|
46
|
+
return withRuntimeSchedulerClient(poolOptions, async (client) => {
|
|
47
|
+
const result = await client.query<Row & Record<string, unknown>>(
|
|
48
|
+
sql,
|
|
49
|
+
params,
|
|
50
|
+
);
|
|
51
|
+
return { rows: result.rows as Row[] };
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Constructs an Absurd client wired to the runtime scheduler pool.
|
|
59
|
+
*/
|
|
60
|
+
export function createAbsurdForRuntimeScheduler(
|
|
61
|
+
poolOptions: RuntimeSchedulerPoolOptions,
|
|
62
|
+
options: Omit<AbsurdOptions, 'db'> = {},
|
|
63
|
+
): Absurd {
|
|
64
|
+
return new Absurd({
|
|
65
|
+
...options,
|
|
66
|
+
db: absurdQueryableForRuntimeScheduler(poolOptions),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let cachedSchemaSql: string | null = null;
|
|
71
|
+
let cachedNoSchedulerOrgCapCompatibilitySql: string | null = null;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The vendored schema version cannot represent Deepline-owned compatibility
|
|
75
|
+
* patches. Keep an explicit durable marker in the shared `absurd` schema so
|
|
76
|
+
* cold Vercel instances do not execute `CREATE OR REPLACE FUNCTION` on every
|
|
77
|
+
* first submission. Replacing a function while claims are running is DDL
|
|
78
|
+
* contention, not useful admission work.
|
|
79
|
+
*/
|
|
80
|
+
export const ABSURD_NO_SCHEDULER_ORG_CAP_COMPATIBILITY_VERSION =
|
|
81
|
+
'deepline-no-scheduler-org-cap-v1';
|
|
82
|
+
|
|
83
|
+
function schemaSection(sql: string, start: string, end: string): string {
|
|
84
|
+
const startIndex = sql.indexOf(start);
|
|
85
|
+
const endIndex = sql.indexOf(end);
|
|
86
|
+
if (startIndex < 0 || endIndex < 0 || endIndex <= startIndex) {
|
|
87
|
+
throw new Error('Vendored absurd v5 schema upgrade markers are malformed.');
|
|
88
|
+
}
|
|
89
|
+
return sql.slice(startIndex + start.length, endIndex).trim();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Reads the vendored `absurd.sql` schema text. Cached after first read. Node
|
|
94
|
+
* only — the scheduler control plane and worker run under Node, never workerd.
|
|
95
|
+
*/
|
|
96
|
+
export function readAbsurdSchemaSql(): string {
|
|
97
|
+
if (cachedSchemaSql !== null) {
|
|
98
|
+
return cachedSchemaSql;
|
|
99
|
+
}
|
|
100
|
+
const packagePoolPath = createRequire(import.meta.url).resolve(
|
|
101
|
+
'@deepline/absurd/pool',
|
|
102
|
+
);
|
|
103
|
+
const schemaPath = path.resolve(
|
|
104
|
+
path.dirname(packagePoolPath),
|
|
105
|
+
ABSURD_SCHEMA_SQL_RELATIVE_PATH,
|
|
106
|
+
);
|
|
107
|
+
const sql = readFileSync(schemaPath, 'utf8');
|
|
108
|
+
if (!sql.includes('create schema if not exists absurd')) {
|
|
109
|
+
throw new Error(
|
|
110
|
+
`Vendored absurd schema at ${schemaPath} is missing or malformed.`,
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
cachedSchemaSql = sql;
|
|
114
|
+
return sql;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Applies no-cap behavior without changing the v4 schema contract.
|
|
119
|
+
*
|
|
120
|
+
* During a rolling release older workers still cold-start against v4 and may
|
|
121
|
+
* submit `per_org_concurrency`. Keeping the marker, column, function result
|
|
122
|
+
* shape, and accepted input key lets both versions run. The replacement
|
|
123
|
+
* claim function deliberately ignores the retired setting, so it cannot limit
|
|
124
|
+
* scheduler claims even while its compatibility-only column exists.
|
|
125
|
+
*/
|
|
126
|
+
export function readAbsurdSchemaNoSchedulerOrgCapCompatibilitySql(): string {
|
|
127
|
+
if (cachedNoSchedulerOrgCapCompatibilitySql !== null) {
|
|
128
|
+
return cachedNoSchedulerOrgCapCompatibilitySql;
|
|
129
|
+
}
|
|
130
|
+
const sql = readAbsurdSchemaSql();
|
|
131
|
+
const claim = schemaSection(
|
|
132
|
+
sql,
|
|
133
|
+
'-- Workers call this to reserve a task from a given queue',
|
|
134
|
+
'-- Markes a run as completed',
|
|
135
|
+
);
|
|
136
|
+
const noCapClaim = claim
|
|
137
|
+
.replace(
|
|
138
|
+
` -- DEEPLINE PATCH (a): per-org admission cap from queue policy (null=unlimited).\n v_per_org_cap integer;\n`,
|
|
139
|
+
'',
|
|
140
|
+
)
|
|
141
|
+
.replace(
|
|
142
|
+
`\n select per_org_concurrency into v_per_org_cap\n from absurd.queues\n where queue_name = p_queue_name;\n`,
|
|
143
|
+
'',
|
|
144
|
+
)
|
|
145
|
+
.replace(
|
|
146
|
+
` -- DEEPLINE PATCH (a): fair per-org claiming + priority + admission caps.\n`,
|
|
147
|
+
` -- DEEPLINE PATCH (a): fair per-org claiming + priority.\n`,
|
|
148
|
+
)
|
|
149
|
+
.replace(
|
|
150
|
+
` -- * admission — when the queue sets per_org_concurrency, an org may only\n -- admit (cap - inflight) head-of-line tasks; an org already at\n -- the cap is skipped entirely.\n --\n`,
|
|
151
|
+
'',
|
|
152
|
+
)
|
|
153
|
+
.replace(
|
|
154
|
+
` admissible as (\n select run_id,\n priority,\n available_at,\n created_at,\n (org_rank + inflight_cnt) as fair_rank\n from scored\n where $5::integer is null\n or org_rank <= ($5::integer - inflight_cnt)\n ),\n ranked as (\n select run_id\n from admissible\n`,
|
|
155
|
+
` ranked as (\n select run_id,\n priority,\n available_at,\n created_at,\n (org_rank + inflight_cnt) as fair_rank\n from scored\n`,
|
|
156
|
+
)
|
|
157
|
+
.replace(
|
|
158
|
+
'return query execute v_sql using v_now, v_qty, v_worker_id, v_claim_until, v_per_org_cap;',
|
|
159
|
+
'return query execute v_sql using v_now, v_qty, v_worker_id, v_claim_until;',
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
if (
|
|
163
|
+
noCapClaim.includes('v_per_org_cap') ||
|
|
164
|
+
noCapClaim.includes('$5::integer')
|
|
165
|
+
) {
|
|
166
|
+
throw new Error(
|
|
167
|
+
'Absurd no-cap compatibility patch did not remove the retired claim gate.',
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
// The installed v4 claim function has the identical signature and result
|
|
171
|
+
// type. Replacing only its body is safe for old and new processes alike.
|
|
172
|
+
cachedNoSchedulerOrgCapCompatibilitySql = noCapClaim.replace(
|
|
173
|
+
'create function absurd.claim_task',
|
|
174
|
+
'create or replace function absurd.claim_task',
|
|
175
|
+
);
|
|
176
|
+
return cachedNoSchedulerOrgCapCompatibilitySql;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Marks the no-cap compatibility patch after its replacement claim function
|
|
181
|
+
* has committed. A function keeps the marker in Absurd's global schema and
|
|
182
|
+
* makes it valid for every runtime scheduler namespace that shares it.
|
|
183
|
+
*/
|
|
184
|
+
export function readAbsurdSchemaNoSchedulerOrgCapCompatibilityMarkerSql(): string {
|
|
185
|
+
return `
|
|
186
|
+
CREATE OR REPLACE FUNCTION absurd.deepline_no_scheduler_org_cap_compatibility_version()
|
|
187
|
+
RETURNS text
|
|
188
|
+
LANGUAGE sql
|
|
189
|
+
AS $$
|
|
190
|
+
SELECT '${ABSURD_NO_SCHEDULER_ORG_CAP_COMPATIBILITY_VERSION}'::text
|
|
191
|
+
$$
|
|
192
|
+
`;
|
|
193
|
+
}
|
package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-queue-lifecycle.ts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded lifecycle cleanup for historical Absurd release queues.
|
|
3
|
+
*
|
|
4
|
+
* `runtimeReleases` is authoritative for live/draining lanes, but early
|
|
5
|
+
* release-lane deployments created physical `absurd.queues` entries before
|
|
6
|
+
* the lifecycle registry had a tombstone for every lane. Those queues are
|
|
7
|
+
* still safe to reclaim once they are old, unowned, and have no nonterminal
|
|
8
|
+
* task. This module deliberately owns only those orphan queues; registered
|
|
9
|
+
* retired releases continue through the stronger release-id/run-row gate in
|
|
10
|
+
* `runtime-lanes.ts`.
|
|
11
|
+
*/
|
|
12
|
+
import type { AbsurdLaneTaskCounts } from './absurd-runtime-worker';
|
|
13
|
+
import type {
|
|
14
|
+
RuntimeSchedulerPoolOptions,
|
|
15
|
+
RuntimeSchedulerQueryClient,
|
|
16
|
+
} from './postgres-pool';
|
|
17
|
+
import { withRuntimeSchedulerClient } from './postgres-pool';
|
|
18
|
+
import { absurdQueueNameForRelease } from './absurd-shared';
|
|
19
|
+
import { resolveRuntimeSchedulerSchemaEnv } from './runtime-scheduler-schema';
|
|
20
|
+
|
|
21
|
+
export const ABSURD_ORPHAN_QUEUE_GRACE_MS = 7 * 24 * 60 * 60 * 1_000;
|
|
22
|
+
export const ABSURD_ORPHAN_QUEUE_BATCH_LIMIT = 5;
|
|
23
|
+
/** Query a bounded page then rotate it. A blocked historical queue must never
|
|
24
|
+
* prevent later empty queues from being reclaimed. */
|
|
25
|
+
export const ABSURD_ORPHAN_QUEUE_SCAN_LIMIT = 100;
|
|
26
|
+
|
|
27
|
+
export type AbsurdQueueLifecycleCandidate = {
|
|
28
|
+
queueName: string;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type AbsurdQueueLifecycleOutcome = {
|
|
33
|
+
scanned: number;
|
|
34
|
+
skippedProtected: string[];
|
|
35
|
+
skippedNonTerminal: Array<{
|
|
36
|
+
queueName: string;
|
|
37
|
+
taskCounts: AbsurdLaneTaskCounts;
|
|
38
|
+
}>;
|
|
39
|
+
dropped: string[];
|
|
40
|
+
nextCursor: AbsurdQueueLifecycleCandidate | null;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
function quoteIdent(value: string): string {
|
|
44
|
+
return `"${value.replaceAll('"', '""')}"`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Atomically prove one orphan queue empty and remove it.
|
|
49
|
+
*
|
|
50
|
+
* `absurd.drop_queue` intentionally does not decide whether a queue is safe
|
|
51
|
+
* to delete. The controller locks scheduler runs, the queue registry, and the
|
|
52
|
+
* task table in submit order. Scheduler-run ownership, task count, and drop
|
|
53
|
+
* therefore share one serialization boundary rather than a racy sequence.
|
|
54
|
+
*/
|
|
55
|
+
async function dropAbsurdQueueIfStillEmpty(
|
|
56
|
+
client: RuntimeSchedulerQueryClient,
|
|
57
|
+
queueName: string,
|
|
58
|
+
schedulerSchema: string,
|
|
59
|
+
): Promise<{ dropped: boolean; taskCounts: AbsurdLaneTaskCounts }> {
|
|
60
|
+
let transactionOpen = false;
|
|
61
|
+
try {
|
|
62
|
+
await client.query('BEGIN');
|
|
63
|
+
transactionOpen = true;
|
|
64
|
+
await client.query(
|
|
65
|
+
`SELECT set_config('lock_timeout', '2000ms', true),
|
|
66
|
+
set_config('statement_timeout', '15000ms', true)`,
|
|
67
|
+
);
|
|
68
|
+
// Scheduler submit writes its run row before spawning the Absurd task.
|
|
69
|
+
// Match that lock order: freeze nonterminal run inserts/updates before the
|
|
70
|
+
// queue registry and task table, avoiding both a deadlock and the
|
|
71
|
+
// run-without-task gap.
|
|
72
|
+
await client.query(
|
|
73
|
+
`LOCK TABLE ${quoteIdent(schedulerSchema)}.runs IN SHARE MODE`,
|
|
74
|
+
);
|
|
75
|
+
// `ensure_queue_tables` and `spawn_task` consult this registry before
|
|
76
|
+
// touching queue tables. Holding this lock makes the following task-table
|
|
77
|
+
// gate atomic with respect to a late enqueue.
|
|
78
|
+
await client.query('LOCK TABLE absurd.queues IN ACCESS EXCLUSIVE MODE');
|
|
79
|
+
const taskTable = `t_${queueName}`;
|
|
80
|
+
const present = await client.query<{ present: boolean }>(
|
|
81
|
+
`SELECT to_regclass(format('absurd.%I', $1::text)) IS NOT NULL AS present`,
|
|
82
|
+
[taskTable],
|
|
83
|
+
);
|
|
84
|
+
let taskCounts: AbsurdLaneTaskCounts = {
|
|
85
|
+
nonTerminal: 0,
|
|
86
|
+
claimable: 0,
|
|
87
|
+
running: 0,
|
|
88
|
+
};
|
|
89
|
+
if (present.rows[0]?.present) {
|
|
90
|
+
await client.query(
|
|
91
|
+
`LOCK TABLE absurd.${quoteIdent(taskTable)} IN ACCESS EXCLUSIVE MODE`,
|
|
92
|
+
);
|
|
93
|
+
const taskResult = await client.query<{ non_terminal: string }>(
|
|
94
|
+
`SELECT count(*) FILTER (WHERE state IN ('pending', 'running', 'sleeping'))::text AS non_terminal
|
|
95
|
+
FROM absurd.${quoteIdent(taskTable)}`,
|
|
96
|
+
);
|
|
97
|
+
taskCounts = {
|
|
98
|
+
...taskCounts,
|
|
99
|
+
nonTerminal:
|
|
100
|
+
Number.parseInt(taskResult.rows[0]?.non_terminal ?? '0', 10) || 0,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const schedulerRuns = await client.query<{
|
|
104
|
+
release_id: string | null;
|
|
105
|
+
non_terminal: string;
|
|
106
|
+
}>(
|
|
107
|
+
`SELECT launch_json ->> 'absurdReleaseId' AS release_id,
|
|
108
|
+
count(*)::text AS non_terminal
|
|
109
|
+
FROM ${quoteIdent(schedulerSchema)}.runs
|
|
110
|
+
WHERE status IN ('queued', 'running', 'waiting')
|
|
111
|
+
GROUP BY launch_json ->> 'absurdReleaseId'`,
|
|
112
|
+
);
|
|
113
|
+
for (const row of schedulerRuns.rows) {
|
|
114
|
+
const releaseId = row.release_id?.trim();
|
|
115
|
+
if (!releaseId) continue;
|
|
116
|
+
let runQueue: string;
|
|
117
|
+
try {
|
|
118
|
+
runQueue = absurdQueueNameForRelease(releaseId);
|
|
119
|
+
} catch {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (runQueue !== queueName) continue;
|
|
123
|
+
taskCounts.nonTerminal +=
|
|
124
|
+
Number.parseInt(row.non_terminal ?? '0', 10) || 0;
|
|
125
|
+
}
|
|
126
|
+
if (taskCounts.nonTerminal > 0) {
|
|
127
|
+
await client.query('ROLLBACK');
|
|
128
|
+
transactionOpen = false;
|
|
129
|
+
return { dropped: false, taskCounts };
|
|
130
|
+
}
|
|
131
|
+
await client.query('SELECT absurd.drop_queue($1)', [queueName]);
|
|
132
|
+
await client.query('COMMIT');
|
|
133
|
+
transactionOpen = false;
|
|
134
|
+
return { dropped: true, taskCounts };
|
|
135
|
+
} catch (error) {
|
|
136
|
+
if (transactionOpen) await client.query('ROLLBACK').catch(() => undefined);
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Pure rotating selection shared by the controller and its focused tests. */
|
|
142
|
+
export function selectRotatingAbsurdOrphanQueues(input: {
|
|
143
|
+
candidates: readonly AbsurdQueueLifecycleCandidate[];
|
|
144
|
+
limit?: number;
|
|
145
|
+
}): {
|
|
146
|
+
candidates: AbsurdQueueLifecycleCandidate[];
|
|
147
|
+
nextCursor: AbsurdQueueLifecycleCandidate | null;
|
|
148
|
+
} {
|
|
149
|
+
const candidates = [...input.candidates].sort((left, right) => {
|
|
150
|
+
const created = left.createdAt.localeCompare(right.createdAt);
|
|
151
|
+
return created === 0
|
|
152
|
+
? left.queueName.localeCompare(right.queueName)
|
|
153
|
+
: created;
|
|
154
|
+
});
|
|
155
|
+
if (candidates.length === 0) {
|
|
156
|
+
return { candidates: [], nextCursor: null };
|
|
157
|
+
}
|
|
158
|
+
const count = Math.min(
|
|
159
|
+
candidates.length,
|
|
160
|
+
Math.max(1, Math.floor(input.limit ?? ABSURD_ORPHAN_QUEUE_BATCH_LIMIT)),
|
|
161
|
+
);
|
|
162
|
+
const selected = candidates.slice(0, count);
|
|
163
|
+
return {
|
|
164
|
+
candidates: selected,
|
|
165
|
+
nextCursor: selected.at(-1) ?? null,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Reclaim only old `runs_*` release queues which no current controller/Fly
|
|
171
|
+
* owner can reference. The base `runs` queue is intentionally never eligible:
|
|
172
|
+
* it is the durable dev/default queue and cannot be reverse-mapped to one
|
|
173
|
+
* release safely.
|
|
174
|
+
*
|
|
175
|
+
* The caller supplies a fresh snapshot of every active, draining, retiring,
|
|
176
|
+
* rollback-held, and tombstoned queue. We still re-read each task table just
|
|
177
|
+
* before `drop_queue`; an empty queue is the destructive gate. Work is capped
|
|
178
|
+
* so a historical backlog cannot steal capacity reconciliation time.
|
|
179
|
+
*/
|
|
180
|
+
export async function cleanupAbsurdOrphanReleaseQueues(input: {
|
|
181
|
+
poolOptions: RuntimeSchedulerPoolOptions;
|
|
182
|
+
schedulerSchema?: string | null;
|
|
183
|
+
protectedQueueNames: ReadonlySet<string>;
|
|
184
|
+
nowMs?: number;
|
|
185
|
+
cursor?: AbsurdQueueLifecycleCandidate | null;
|
|
186
|
+
limit?: number;
|
|
187
|
+
scanLimit?: number;
|
|
188
|
+
withClient?: <T>(
|
|
189
|
+
callback: (client: RuntimeSchedulerQueryClient) => Promise<T>,
|
|
190
|
+
) => Promise<T>;
|
|
191
|
+
}): Promise<AbsurdQueueLifecycleOutcome> {
|
|
192
|
+
const nowMs = input.nowMs ?? Date.now();
|
|
193
|
+
const graceCutoff = new Date(nowMs - ABSURD_ORPHAN_QUEUE_GRACE_MS);
|
|
194
|
+
const schedulerSchema =
|
|
195
|
+
input.schedulerSchema?.trim() ||
|
|
196
|
+
resolveRuntimeSchedulerSchemaEnv() ||
|
|
197
|
+
'runtime_scheduler';
|
|
198
|
+
const withClient =
|
|
199
|
+
input.withClient ??
|
|
200
|
+
((callback) => withRuntimeSchedulerClient(input.poolOptions, callback));
|
|
201
|
+
|
|
202
|
+
return withClient(async (client) => {
|
|
203
|
+
const readCandidates = (cursor?: AbsurdQueueLifecycleCandidate | null) =>
|
|
204
|
+
client.query<AbsurdQueueLifecycleCandidate>(
|
|
205
|
+
`SELECT queue_name AS "queueName", created_at::text AS "createdAt"
|
|
206
|
+
FROM absurd.queues
|
|
207
|
+
WHERE queue_name LIKE 'runs\\_%' ESCAPE '\\'
|
|
208
|
+
AND queue_name <> 'runs'
|
|
209
|
+
AND created_at <= $1
|
|
210
|
+
${
|
|
211
|
+
cursor
|
|
212
|
+
? 'AND (created_at, queue_name) > ($2::timestamptz, $3::text)'
|
|
213
|
+
: ''
|
|
214
|
+
}
|
|
215
|
+
ORDER BY created_at ASC, queue_name ASC
|
|
216
|
+
LIMIT $${cursor ? 4 : 2}`,
|
|
217
|
+
cursor
|
|
218
|
+
? [
|
|
219
|
+
graceCutoff.toISOString(),
|
|
220
|
+
cursor.createdAt,
|
|
221
|
+
cursor.queueName,
|
|
222
|
+
input.scanLimit ?? ABSURD_ORPHAN_QUEUE_SCAN_LIMIT,
|
|
223
|
+
]
|
|
224
|
+
: [
|
|
225
|
+
graceCutoff.toISOString(),
|
|
226
|
+
input.scanLimit ?? ABSURD_ORPHAN_QUEUE_SCAN_LIMIT,
|
|
227
|
+
],
|
|
228
|
+
);
|
|
229
|
+
let candidatesResult = await readCandidates(input.cursor);
|
|
230
|
+
if (candidatesResult.rows.length === 0 && input.cursor) {
|
|
231
|
+
candidatesResult = await readCandidates();
|
|
232
|
+
}
|
|
233
|
+
const selection = selectRotatingAbsurdOrphanQueues({
|
|
234
|
+
candidates: candidatesResult.rows,
|
|
235
|
+
limit: input.limit,
|
|
236
|
+
});
|
|
237
|
+
const skippedProtected: string[] = [];
|
|
238
|
+
const skippedNonTerminal: AbsurdQueueLifecycleOutcome['skippedNonTerminal'] =
|
|
239
|
+
[];
|
|
240
|
+
const dropped: string[] = [];
|
|
241
|
+
|
|
242
|
+
for (const candidate of selection.candidates) {
|
|
243
|
+
if (input.protectedQueueNames.has(candidate.queueName)) {
|
|
244
|
+
skippedProtected.push(candidate.queueName);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const removal = await dropAbsurdQueueIfStillEmpty(
|
|
248
|
+
client,
|
|
249
|
+
candidate.queueName,
|
|
250
|
+
schedulerSchema,
|
|
251
|
+
);
|
|
252
|
+
if (!removal.dropped) {
|
|
253
|
+
skippedNonTerminal.push({
|
|
254
|
+
queueName: candidate.queueName,
|
|
255
|
+
taskCounts: removal.taskCounts,
|
|
256
|
+
});
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
dropped.push(candidate.queueName);
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
scanned: selection.candidates.length,
|
|
263
|
+
skippedProtected,
|
|
264
|
+
skippedNonTerminal,
|
|
265
|
+
dropped,
|
|
266
|
+
nextCursor: selection.nextCursor,
|
|
267
|
+
};
|
|
268
|
+
});
|
|
269
|
+
}
|
package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-queue-suffix.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { PROD_DEFAULT_RUNTIME_SCHEDULER_SCHEMA } from '../runtime-scheduler-topology';
|
|
3
|
+
|
|
4
|
+
type EnvMap = Record<string, string | undefined>;
|
|
5
|
+
|
|
6
|
+
/** Per-process suffix used to isolate Absurd queue tables. */
|
|
7
|
+
export const ABSURD_QUEUE_SUFFIX_ENV = 'DEEPLINE_ABSURD_QUEUE_SUFFIX';
|
|
8
|
+
|
|
9
|
+
/** Scheduler schema native to this process. */
|
|
10
|
+
export const ABSURD_SCHEDULER_SCHEMA_ENV = 'DEEPLINE_RUNTIME_SCHEDULER_SCHEMA';
|
|
11
|
+
|
|
12
|
+
/** The production scheduler schema uses the canonical, unsuffixed queues. */
|
|
13
|
+
export const ABSURD_PROD_DEFAULT_SCHEMA = PROD_DEFAULT_RUNTIME_SCHEDULER_SCHEMA;
|
|
14
|
+
|
|
15
|
+
export const ABSURD_DEV_RELEASE_PREFIX = 'dev-';
|
|
16
|
+
|
|
17
|
+
function normalizeQueueSuffixValue(raw: string): string {
|
|
18
|
+
return raw
|
|
19
|
+
.toLowerCase()
|
|
20
|
+
.replace(/[^a-z0-9_]+/g, '_')
|
|
21
|
+
.replace(/^_+|_+$/g, '')
|
|
22
|
+
.slice(0, 32);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Read and normalize the queue suffix owned by this process. */
|
|
26
|
+
export function resolveAbsurdQueueSuffix(env: EnvMap = process.env): string {
|
|
27
|
+
const raw = env[ABSURD_QUEUE_SUFFIX_ENV]?.trim();
|
|
28
|
+
return raw ? normalizeQueueSuffixValue(raw) : '';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Resolve the queue suffix for an explicitly selected scheduler schema.
|
|
33
|
+
* The process-owned suffix applies only to its native schema. A different
|
|
34
|
+
* explicitly selected schema is a remote runtime and therefore derives the
|
|
35
|
+
* stable schema fingerprint provisioned by that runtime's worker workflow.
|
|
36
|
+
*/
|
|
37
|
+
export function resolveAbsurdQueueSuffixForSchema(
|
|
38
|
+
schema?: string | null,
|
|
39
|
+
env: EnvMap = process.env,
|
|
40
|
+
): string {
|
|
41
|
+
const normalizedSchema = schema?.trim();
|
|
42
|
+
const envSuffix = resolveAbsurdQueueSuffix(env);
|
|
43
|
+
if (!normalizedSchema || normalizedSchema === ABSURD_PROD_DEFAULT_SCHEMA) {
|
|
44
|
+
return envSuffix;
|
|
45
|
+
}
|
|
46
|
+
const nativeSchema = env[ABSURD_SCHEDULER_SCHEMA_ENV]?.trim();
|
|
47
|
+
if (envSuffix && nativeSchema === normalizedSchema) return envSuffix;
|
|
48
|
+
return resolveAbsurdQueueSuffixForIsolatedSchema(normalizedSchema);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Pure queue identity for an explicitly selected isolated scheduler schema. */
|
|
52
|
+
export function resolveAbsurdQueueSuffixForIsolatedSchema(
|
|
53
|
+
schema: string,
|
|
54
|
+
): string {
|
|
55
|
+
const normalizedSchema = schema.trim();
|
|
56
|
+
if (!normalizedSchema || normalizedSchema === ABSURD_PROD_DEFAULT_SCHEMA) {
|
|
57
|
+
throw new Error('An isolated scheduler schema is required.');
|
|
58
|
+
}
|
|
59
|
+
return normalizeQueueSuffixValue(
|
|
60
|
+
createHash('sha256').update(normalizedSchema).digest('hex').slice(0, 12),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Map a non-empty isolated queue suffix to its dev-collapse release id. */
|
|
65
|
+
export function absurdDevReleaseIdForQueueSuffix(suffix: string): string {
|
|
66
|
+
const normalized = normalizeQueueSuffixValue(suffix.trim());
|
|
67
|
+
if (!normalized) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
'An isolated Absurd runtime environment requires a non-empty queue suffix.',
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
return `${ABSURD_DEV_RELEASE_PREFIX}${normalized}`;
|
|
73
|
+
}
|