deepline 0.3.89 → 0.3.90
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 +120 -37
- package/dist/bundling-sources/sdk/src/index.ts +4 -0
- 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 +16 -9
- package/dist/bundling-sources/sdk/src/types.ts +23 -0
- package/dist/bundling-sources/shared_libs/monitors/analytics-public.ts +10 -0
- package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +3 -0
- 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/package.json +7 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +44 -2
- 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 +654 -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 +45 -0
- 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/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/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/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 +57 -205
- 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/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/contracts.ts +2 -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/play-grep-search.ts +39 -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/slack-hitl-timeout-error.ts +37 -0
- package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +6 -1
- package/dist/bundling-sources/shared_libs/plays/tool-result-types.ts +1 -1
- 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 +545 -264
- package/dist/cli/index.mjs +543 -271
- package/dist/{compiler-manifest-DsLbQaew.d.mts → compiler-manifest-BaJfE-5H.d.mts} +5 -3
- package/dist/{compiler-manifest-DsLbQaew.d.ts → compiler-manifest-BaJfE-5H.d.ts} +5 -3
- package/dist/index.d.mts +81 -148
- package/dist/index.d.ts +81 -148
- package/dist/index.js +83 -26
- package/dist/index.mjs +83 -26
- package/dist/install-integrity.json +130 -2
- package/dist/monitor-fleet-contract.d.mts +138 -0
- package/dist/monitor-fleet-contract.d.ts +138 -0
- package/dist/monitor-fleet-contract.js +404 -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 +215 -0
- package/dist/release.mjs +188 -0
- package/package.json +21 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Ledger Projection is the delivery job for already-committed Runtime
|
|
3
|
+
* Postgres outbox facts. It never decides a Play Run's terminal state and it
|
|
4
|
+
* never re-executes a Play.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** A caller may ask the durable outbox to advance through one exact event. */
|
|
8
|
+
export type RunLedgerProjectionInput = {
|
|
9
|
+
/** Omit to advance the next claimable outbox fact. */
|
|
10
|
+
targetEventId?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Durable delivery counters. `targetDelivered` is meaningful only for a
|
|
15
|
+
* targeted call; callers must not infer it from `projected`.
|
|
16
|
+
*/
|
|
17
|
+
export type RunLedgerProjectionStats = {
|
|
18
|
+
attempted: number;
|
|
19
|
+
projected: number;
|
|
20
|
+
failed: number;
|
|
21
|
+
retrying: number;
|
|
22
|
+
failedEventIds: string[];
|
|
23
|
+
targetEventId?: string;
|
|
24
|
+
targetDelivered?: boolean;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type RunLedgerProjectionJob = {
|
|
28
|
+
deliver(input?: RunLedgerProjectionInput): Promise<RunLedgerProjectionStats>;
|
|
29
|
+
};
|
package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/gateway-adapter.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { WorkerRuntimeApiContext } from '../../app-runtime-api';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
dispatchRunLedgerOutboxToLedgerBatchOnceWithClientScope,
|
|
5
|
+
dispatchRunLedgerOutboxToLedgerThroughEventWithClientScope,
|
|
6
|
+
type PostgresSchedulerOptions,
|
|
7
|
+
type PostgresSchedulerOutboxDrainResult,
|
|
8
|
+
type PostgresSchedulerQueryClient,
|
|
9
|
+
} from '../../scheduler-backends/postgres';
|
|
10
|
+
|
|
11
|
+
import type { RunLedgerProjectionPorts } from '../../play-runs/projection/ports';
|
|
12
|
+
|
|
13
|
+
export type GatewayRunLedgerProjectionAdapterInput = {
|
|
14
|
+
runId: string;
|
|
15
|
+
runtimeApi: WorkerRuntimeApiContext;
|
|
16
|
+
withClient: <T>(
|
|
17
|
+
operation: (client: PostgresSchedulerQueryClient) => Promise<T>,
|
|
18
|
+
) => Promise<T>;
|
|
19
|
+
schedulerOptions?: Pick<PostgresSchedulerOptions, 'schema'>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Gateway Adapter for the durable Run Ledger outbox. It retains the worker's
|
|
24
|
+
* no-signing-key rule and turns both normal and targeted delivery into the
|
|
25
|
+
* one `RunLedgerProjection.deliver` port.
|
|
26
|
+
*/
|
|
27
|
+
export function createGatewayRunLedgerProjectionAdapter(
|
|
28
|
+
input: GatewayRunLedgerProjectionAdapterInput,
|
|
29
|
+
): RunLedgerProjectionPorts['outbox'] {
|
|
30
|
+
const options = input.schedulerOptions ?? {};
|
|
31
|
+
const dispatchInput = {
|
|
32
|
+
runId: input.runId,
|
|
33
|
+
runtimeApi: input.runtimeApi,
|
|
34
|
+
tokenAuthority: 'gateway' as const,
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
async deliver(request) {
|
|
38
|
+
if (request.targetEventId) {
|
|
39
|
+
return await dispatchRunLedgerOutboxToLedgerThroughEventWithClientScope(
|
|
40
|
+
input.withClient,
|
|
41
|
+
{ ...dispatchInput, targetEventId: request.targetEventId },
|
|
42
|
+
options,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return await dispatchRunLedgerOutboxToLedgerBatchOnceWithClientScope(
|
|
46
|
+
input.withClient,
|
|
47
|
+
dispatchInput,
|
|
48
|
+
options,
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The targeted scheduler result has all public projection counters. */
|
|
55
|
+
export type GatewayRunLedgerProjectionResult =
|
|
56
|
+
PostgresSchedulerOutboxDrainResult;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { createRunLedgerProjectionJob } from '../../play-runs/projection/job';
|
|
2
|
+
export {
|
|
3
|
+
createGatewayRunLedgerProjectionAdapter,
|
|
4
|
+
type GatewayRunLedgerProjectionAdapterInput,
|
|
5
|
+
type GatewayRunLedgerProjectionResult,
|
|
6
|
+
} from '../../play-runs/projection/gateway-adapter';
|
|
7
|
+
export type {
|
|
8
|
+
RunLedgerProjectionInput,
|
|
9
|
+
RunLedgerProjectionJob,
|
|
10
|
+
RunLedgerProjectionStats,
|
|
11
|
+
} from '../../play-runs/projection/contracts';
|
|
12
|
+
export type {
|
|
13
|
+
RunLedgerOutboxDelivery,
|
|
14
|
+
RunLedgerProjectionPorts,
|
|
15
|
+
} from '../../play-runs/projection/ports';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
RunLedgerProjectionInput,
|
|
3
|
+
RunLedgerProjectionJob,
|
|
4
|
+
RunLedgerProjectionStats,
|
|
5
|
+
} from '../../play-runs/projection/contracts';
|
|
6
|
+
import type { RunLedgerProjectionPorts } from '../../play-runs/projection/ports';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates the Run Ledger Projection job.
|
|
10
|
+
*
|
|
11
|
+
* A target is a delivery observation, not a second queue. In particular, a
|
|
12
|
+
* target that remains pending must return the adapter's durable retry result
|
|
13
|
+
* rather than causing the caller to append or retry an event itself.
|
|
14
|
+
*/
|
|
15
|
+
export function createRunLedgerProjectionJob(
|
|
16
|
+
ports: RunLedgerProjectionPorts,
|
|
17
|
+
): RunLedgerProjectionJob {
|
|
18
|
+
return {
|
|
19
|
+
async deliver(
|
|
20
|
+
input: RunLedgerProjectionInput = {},
|
|
21
|
+
): Promise<RunLedgerProjectionStats> {
|
|
22
|
+
if (input.targetEventId !== undefined && !input.targetEventId.trim()) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
'Run Ledger Projection target event id must be non-empty when supplied.',
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const result = await ports.outbox.deliver(input);
|
|
29
|
+
validateStats(result, input);
|
|
30
|
+
return result;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function validateStats(
|
|
36
|
+
result: RunLedgerProjectionStats,
|
|
37
|
+
input: RunLedgerProjectionInput,
|
|
38
|
+
): void {
|
|
39
|
+
for (const value of [
|
|
40
|
+
result.attempted,
|
|
41
|
+
result.projected,
|
|
42
|
+
result.failed,
|
|
43
|
+
result.retrying,
|
|
44
|
+
]) {
|
|
45
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
'Run Ledger Projection adapter returned invalid delivery counters.',
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!Array.isArray(result.failedEventIds)) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
'Run Ledger Projection adapter returned invalid failed event ids.',
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (
|
|
57
|
+
input.targetEventId !== undefined &&
|
|
58
|
+
result.targetEventId !== undefined &&
|
|
59
|
+
result.targetEventId !== input.targetEventId
|
|
60
|
+
) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
'Run Ledger Projection adapter returned delivery stats for a different target event.',
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
RunLedgerProjectionInput,
|
|
3
|
+
RunLedgerProjectionStats,
|
|
4
|
+
} from '../../play-runs/projection/contracts';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The only infrastructure capability this job needs. The adapter owns the
|
|
8
|
+
* Postgres claim, ordered append, delivery idempotency, and durable retry
|
|
9
|
+
* clock; this job gives callers one stable Interface over that capability.
|
|
10
|
+
*/
|
|
11
|
+
export type RunLedgerOutboxDelivery = {
|
|
12
|
+
deliver(input: RunLedgerProjectionInput): Promise<RunLedgerProjectionStats>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type RunLedgerProjectionPorts = {
|
|
16
|
+
outbox: RunLedgerOutboxDelivery;
|
|
17
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox Cleanup reconciles one already-claimed physical resource. It begins
|
|
3
|
+
* after a resource fact and cleanup obligation exist; it neither creates a
|
|
4
|
+
* sandbox nor decides a Play Run terminal state.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type SandboxCleanupResource = {
|
|
8
|
+
provider: 'daytona' | 'modal';
|
|
9
|
+
sandboxId: string;
|
|
10
|
+
routingDomain: string | null;
|
|
11
|
+
runId: string;
|
|
12
|
+
attempt: number;
|
|
13
|
+
cleanupAttempt: number;
|
|
14
|
+
failureCount: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type SandboxCleanupDeleteOutcome =
|
|
18
|
+
| { kind: 'deleted'; routingDomain: string | null }
|
|
19
|
+
| { kind: 'already_absent'; routingDomain: string | null }
|
|
20
|
+
/** The provider outcome is ambiguous or failed; its resource remains live. */
|
|
21
|
+
| { kind: 'failed'; code: string; detail: string };
|
|
22
|
+
|
|
23
|
+
export type SandboxCleanupInput = {
|
|
24
|
+
resource: SandboxCleanupResource;
|
|
25
|
+
timeoutMs: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type SandboxCleanupOutcome =
|
|
29
|
+
| {
|
|
30
|
+
kind: 'completed';
|
|
31
|
+
providerOutcome: 'deleted' | 'already_absent';
|
|
32
|
+
/** The durable claim transition which settled this provider fact. */
|
|
33
|
+
completion: 'completed' | 'late_success_accepted' | 'already_deleted';
|
|
34
|
+
}
|
|
35
|
+
| { kind: 'completion_rejected'; completion: 'missing_obligation' }
|
|
36
|
+
| { kind: 'blocked'; reason: string }
|
|
37
|
+
| { kind: 'retry_scheduled'; retryAfterMs: number }
|
|
38
|
+
| { kind: 'retry_rejected' };
|
|
39
|
+
|
|
40
|
+
export type SandboxCleanupJob = {
|
|
41
|
+
reconcile(input: SandboxCleanupInput): Promise<SandboxCleanupOutcome>;
|
|
42
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { createSandboxCleanupJob } from '../../play-runs/sandbox-cleanup/job';
|
|
2
|
+
export {
|
|
3
|
+
createPostgresSandboxCleanupStore,
|
|
4
|
+
type SandboxCleanupPostgresAdapterInput,
|
|
5
|
+
} from '../../play-runs/sandbox-cleanup/postgres-adapter';
|
|
6
|
+
export type {
|
|
7
|
+
SandboxCleanupDeleteOutcome,
|
|
8
|
+
SandboxCleanupInput,
|
|
9
|
+
SandboxCleanupJob,
|
|
10
|
+
SandboxCleanupOutcome,
|
|
11
|
+
SandboxCleanupResource,
|
|
12
|
+
} from '../../play-runs/sandbox-cleanup/contracts';
|
|
13
|
+
export type {
|
|
14
|
+
SandboxCleanupPorts,
|
|
15
|
+
SandboxCleanupStore,
|
|
16
|
+
SandboxDeletion,
|
|
17
|
+
} from '../../play-runs/sandbox-cleanup/ports';
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SandboxCleanupInput,
|
|
3
|
+
SandboxCleanupJob,
|
|
4
|
+
SandboxCleanupOutcome,
|
|
5
|
+
} from '../../play-runs/sandbox-cleanup/contracts';
|
|
6
|
+
import type { SandboxCleanupPorts } from '../../play-runs/sandbox-cleanup/ports';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates the Sandbox Cleanup job.
|
|
10
|
+
*
|
|
11
|
+
* Capacity ends only after a provider-confirmed deletion or documented
|
|
12
|
+
* already-absent result. Every other provider result retains the durable
|
|
13
|
+
* cleanup obligation and schedules a fenced retry.
|
|
14
|
+
*/
|
|
15
|
+
export function createSandboxCleanupJob(
|
|
16
|
+
ports: SandboxCleanupPorts,
|
|
17
|
+
): SandboxCleanupJob {
|
|
18
|
+
return {
|
|
19
|
+
async reconcile(
|
|
20
|
+
input: SandboxCleanupInput,
|
|
21
|
+
): Promise<SandboxCleanupOutcome> {
|
|
22
|
+
validate(input);
|
|
23
|
+
if (
|
|
24
|
+
input.resource.provider === 'modal' &&
|
|
25
|
+
!input.resource.routingDomain?.trim()
|
|
26
|
+
) {
|
|
27
|
+
const reason =
|
|
28
|
+
'missing_routing_domain: Modal cleanup requires its persisted app id.';
|
|
29
|
+
const blocked = await ports.store.block({
|
|
30
|
+
resource: input.resource,
|
|
31
|
+
reason,
|
|
32
|
+
});
|
|
33
|
+
return blocked === 'blocked'
|
|
34
|
+
? { kind: 'blocked', reason }
|
|
35
|
+
: { kind: 'completion_rejected', completion: 'missing_obligation' };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
const deletion = await ports.deletion.delete(input);
|
|
40
|
+
if (deletion.kind === 'failed') {
|
|
41
|
+
if (deletion.code === 'missing_routing_domain') {
|
|
42
|
+
const reason = `missing_routing_domain: ${deletion.detail}`.slice(
|
|
43
|
+
0,
|
|
44
|
+
2_000,
|
|
45
|
+
);
|
|
46
|
+
const blocked = await ports.store.block({
|
|
47
|
+
resource: input.resource,
|
|
48
|
+
reason,
|
|
49
|
+
});
|
|
50
|
+
return blocked === 'blocked'
|
|
51
|
+
? { kind: 'blocked', reason }
|
|
52
|
+
: {
|
|
53
|
+
kind: 'completion_rejected',
|
|
54
|
+
completion: 'missing_obligation',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return await scheduleRetry(ports, input, deletion.detail);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// A control-plane retry must never keep a provider-confirmed-deleted
|
|
61
|
+
// resource consuming capacity. This precedes cleanup row completion.
|
|
62
|
+
await ports.store.releaseCapacity({ resource: input.resource });
|
|
63
|
+
const completion = await ports.store.complete({
|
|
64
|
+
resource: input.resource,
|
|
65
|
+
providerOutcome: deletion.kind,
|
|
66
|
+
observedRoutingDomain: deletion.routingDomain,
|
|
67
|
+
});
|
|
68
|
+
if (
|
|
69
|
+
completion === 'completed' ||
|
|
70
|
+
completion === 'late_success_accepted' ||
|
|
71
|
+
completion === 'already_deleted'
|
|
72
|
+
) {
|
|
73
|
+
return {
|
|
74
|
+
kind: 'completed',
|
|
75
|
+
providerOutcome: deletion.kind,
|
|
76
|
+
completion,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// A provider confirmation from the wrong routing domain is not a
|
|
80
|
+
// completion rejection: it is a real external-side-effect ambiguity.
|
|
81
|
+
// Preserve the obligation and retry through its existing claim fence.
|
|
82
|
+
if (completion === 'wrong_routing_domain') {
|
|
83
|
+
return await scheduleRetry(
|
|
84
|
+
ports,
|
|
85
|
+
input,
|
|
86
|
+
`${input.resource.provider} sandbox ${input.resource.sandboxId} cleanup confirmation used the wrong routing domain.`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return { kind: 'completion_rejected', completion };
|
|
90
|
+
} catch (error) {
|
|
91
|
+
return await scheduleRetry(
|
|
92
|
+
ports,
|
|
93
|
+
input,
|
|
94
|
+
error instanceof Error ? error.message : String(error),
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function scheduleRetry(
|
|
102
|
+
ports: SandboxCleanupPorts,
|
|
103
|
+
input: SandboxCleanupInput,
|
|
104
|
+
error: string,
|
|
105
|
+
): Promise<SandboxCleanupOutcome> {
|
|
106
|
+
const retryAfterMs = retryDelay(input.resource.failureCount + 1);
|
|
107
|
+
const scheduled = await ports.store.retry({
|
|
108
|
+
resource: input.resource,
|
|
109
|
+
error,
|
|
110
|
+
retryAfterMs,
|
|
111
|
+
});
|
|
112
|
+
return scheduled === 'retry_scheduled'
|
|
113
|
+
? { kind: 'retry_scheduled', retryAfterMs }
|
|
114
|
+
: { kind: 'retry_rejected' };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function retryDelay(nextFailureCount: number): number {
|
|
118
|
+
return Math.min(
|
|
119
|
+
5 * 60_000,
|
|
120
|
+
1_000 * 2 ** Math.min(8, Math.max(0, nextFailureCount - 1)),
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function validate(input: SandboxCleanupInput): void {
|
|
125
|
+
const { resource } = input;
|
|
126
|
+
if (!resource.sandboxId.trim() || !resource.runId.trim()) {
|
|
127
|
+
throw new Error('Sandbox Cleanup requires non-empty sandbox and run ids.');
|
|
128
|
+
}
|
|
129
|
+
if (!Number.isSafeInteger(resource.attempt) || resource.attempt < 1) {
|
|
130
|
+
throw new Error('Sandbox Cleanup requires a positive attempt number.');
|
|
131
|
+
}
|
|
132
|
+
if (
|
|
133
|
+
!Number.isSafeInteger(resource.cleanupAttempt) ||
|
|
134
|
+
resource.cleanupAttempt < 1 ||
|
|
135
|
+
!Number.isSafeInteger(resource.failureCount) ||
|
|
136
|
+
resource.failureCount < 0 ||
|
|
137
|
+
!Number.isFinite(input.timeoutMs) ||
|
|
138
|
+
input.timeoutMs <= 0
|
|
139
|
+
) {
|
|
140
|
+
throw new Error('Sandbox Cleanup received invalid cleanup state.');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SandboxCleanupDeleteOutcome,
|
|
3
|
+
SandboxCleanupResource,
|
|
4
|
+
} from '../../play-runs/sandbox-cleanup/contracts';
|
|
5
|
+
|
|
6
|
+
/** Provider delete proof. A timeout must be reported as `failed`, never cast to deletion. */
|
|
7
|
+
export type SandboxDeletion = {
|
|
8
|
+
delete(input: {
|
|
9
|
+
resource: SandboxCleanupResource;
|
|
10
|
+
timeoutMs: number;
|
|
11
|
+
}): Promise<SandboxCleanupDeleteOutcome>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** Durable cleanup state transitions, all fenced by the claim represented in `resource`. */
|
|
15
|
+
export type SandboxCleanupStore = {
|
|
16
|
+
releaseCapacity(input: { resource: SandboxCleanupResource }): Promise<void>;
|
|
17
|
+
complete(input: {
|
|
18
|
+
resource: SandboxCleanupResource;
|
|
19
|
+
providerOutcome: 'deleted' | 'already_absent';
|
|
20
|
+
observedRoutingDomain: string | null;
|
|
21
|
+
}): Promise<
|
|
22
|
+
| 'completed'
|
|
23
|
+
| 'late_success_accepted'
|
|
24
|
+
| 'already_deleted'
|
|
25
|
+
| 'missing_obligation'
|
|
26
|
+
| 'wrong_routing_domain'
|
|
27
|
+
>;
|
|
28
|
+
retry(input: {
|
|
29
|
+
resource: SandboxCleanupResource;
|
|
30
|
+
error: string;
|
|
31
|
+
retryAfterMs: number;
|
|
32
|
+
}): Promise<'retry_scheduled' | 'rejected'>;
|
|
33
|
+
block(input: {
|
|
34
|
+
resource: SandboxCleanupResource;
|
|
35
|
+
reason: string;
|
|
36
|
+
}): Promise<'blocked' | 'rejected'>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type SandboxCleanupPorts = {
|
|
40
|
+
deletion: SandboxDeletion;
|
|
41
|
+
store: SandboxCleanupStore;
|
|
42
|
+
};
|
package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/postgres-adapter.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
blockPostgresSchedulerSandboxCleanupJob,
|
|
3
|
+
completePostgresSchedulerSandboxCleanupJob,
|
|
4
|
+
retryPostgresSchedulerSandboxCleanupJob,
|
|
5
|
+
type PostgresSchedulerOptions,
|
|
6
|
+
type PostgresSchedulerQueryClient,
|
|
7
|
+
} from '../../scheduler-backends/postgres';
|
|
8
|
+
import { releaseRuntimeSandboxCapacityLeaseForSandbox } from '../../scheduler-backends/runtime-sandbox-capacity';
|
|
9
|
+
|
|
10
|
+
import type { SandboxCleanupPorts } from '../../play-runs/sandbox-cleanup/ports';
|
|
11
|
+
|
|
12
|
+
export type SandboxCleanupPostgresAdapterInput = {
|
|
13
|
+
runWithClient: <T>(
|
|
14
|
+
fn: (client: PostgresSchedulerQueryClient) => Promise<T>,
|
|
15
|
+
) => Promise<T>;
|
|
16
|
+
leaseOwner: string;
|
|
17
|
+
schedulerOptions?: Pick<PostgresSchedulerOptions, 'schema'>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Runtime-Postgres Adapter for SandboxCleanup. The Job owns the state
|
|
22
|
+
* machine; this Adapter only translates its fenced transitions into the
|
|
23
|
+
* existing durable tables and capacity ledger.
|
|
24
|
+
*/
|
|
25
|
+
export function createPostgresSandboxCleanupStore(
|
|
26
|
+
input: SandboxCleanupPostgresAdapterInput,
|
|
27
|
+
): SandboxCleanupPorts['store'] {
|
|
28
|
+
const options = input.schedulerOptions ?? {};
|
|
29
|
+
return {
|
|
30
|
+
async releaseCapacity({ resource }) {
|
|
31
|
+
await input.runWithClient(async (client) => {
|
|
32
|
+
await releaseRuntimeSandboxCapacityLeaseForSandbox(
|
|
33
|
+
client,
|
|
34
|
+
{
|
|
35
|
+
runId: resource.runId,
|
|
36
|
+
provider: resource.provider,
|
|
37
|
+
sandboxId: resource.sandboxId,
|
|
38
|
+
routingDomain: resource.routingDomain,
|
|
39
|
+
},
|
|
40
|
+
options,
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
async complete({ resource, providerOutcome, observedRoutingDomain }) {
|
|
45
|
+
return await input.runWithClient(
|
|
46
|
+
async (client) =>
|
|
47
|
+
await completePostgresSchedulerSandboxCleanupJob(
|
|
48
|
+
client,
|
|
49
|
+
{
|
|
50
|
+
provider: resource.provider,
|
|
51
|
+
sandboxId: resource.sandboxId,
|
|
52
|
+
routingDomain: resource.routingDomain,
|
|
53
|
+
runId: resource.runId,
|
|
54
|
+
attempt: resource.attempt,
|
|
55
|
+
cleanupAttempt: resource.cleanupAttempt,
|
|
56
|
+
leaseOwner: input.leaseOwner,
|
|
57
|
+
providerOutcome,
|
|
58
|
+
observedRoutingDomain,
|
|
59
|
+
},
|
|
60
|
+
options,
|
|
61
|
+
),
|
|
62
|
+
);
|
|
63
|
+
},
|
|
64
|
+
async retry({ resource, error, retryAfterMs }) {
|
|
65
|
+
const outcome = await input.runWithClient(
|
|
66
|
+
async (client) =>
|
|
67
|
+
await retryPostgresSchedulerSandboxCleanupJob(
|
|
68
|
+
client,
|
|
69
|
+
{
|
|
70
|
+
provider: resource.provider,
|
|
71
|
+
sandboxId: resource.sandboxId,
|
|
72
|
+
routingDomain: resource.routingDomain,
|
|
73
|
+
leaseOwner: input.leaseOwner,
|
|
74
|
+
claimGeneration: resource.cleanupAttempt,
|
|
75
|
+
error,
|
|
76
|
+
retryAfterMs,
|
|
77
|
+
},
|
|
78
|
+
options,
|
|
79
|
+
),
|
|
80
|
+
);
|
|
81
|
+
return outcome === 'retry_scheduled' ? outcome : 'rejected';
|
|
82
|
+
},
|
|
83
|
+
async block({ resource, reason }) {
|
|
84
|
+
const outcome = await input.runWithClient(
|
|
85
|
+
async (client) =>
|
|
86
|
+
await blockPostgresSchedulerSandboxCleanupJob(
|
|
87
|
+
client,
|
|
88
|
+
{
|
|
89
|
+
provider: resource.provider,
|
|
90
|
+
sandboxId: resource.sandboxId,
|
|
91
|
+
routingDomain: resource.routingDomain,
|
|
92
|
+
leaseOwner: input.leaseOwner,
|
|
93
|
+
claimGeneration: resource.cleanupAttempt,
|
|
94
|
+
reason,
|
|
95
|
+
},
|
|
96
|
+
options,
|
|
97
|
+
),
|
|
98
|
+
);
|
|
99
|
+
return outcome === 'blocked' ? outcome : 'rejected';
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
directCompletedTerminalContract,
|
|
3
|
+
type DirectCompletedTerminalContract,
|
|
4
|
+
} from '../../scheduler-backends/terminal-contract';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The authenticated authority for one runner attempt to write the Play Run's
|
|
8
|
+
* terminal state. It is intentionally a terminal concept: it carries neither
|
|
9
|
+
* scheduler-row handles nor transport headers.
|
|
10
|
+
*/
|
|
11
|
+
export type PlayRunTerminalAuthority = {
|
|
12
|
+
terminalContract: DirectCompletedTerminalContract;
|
|
13
|
+
leaseToken: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** Parse ingress-only values into the authority the terminal job accepts. */
|
|
17
|
+
export function resolvePlayRunTerminalAuthority(input: {
|
|
18
|
+
terminalContract?: unknown;
|
|
19
|
+
leaseToken?: unknown;
|
|
20
|
+
}): PlayRunTerminalAuthority | null {
|
|
21
|
+
const terminalContract = directCompletedTerminalContract(
|
|
22
|
+
input.terminalContract,
|
|
23
|
+
);
|
|
24
|
+
if (
|
|
25
|
+
terminalContract === null ||
|
|
26
|
+
typeof input.leaseToken !== 'string' ||
|
|
27
|
+
!input.leaseToken.trim()
|
|
28
|
+
) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
terminalContract,
|
|
33
|
+
leaseToken: input.leaseToken.trim(),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The only terminal results visible to an ingress caller. */
|
|
38
|
+
export type PlayRunTerminalOutcome =
|
|
39
|
+
| { kind: 'direct_completed' }
|
|
40
|
+
| { kind: 'stale_attempt_cleaned' }
|
|
41
|
+
| { kind: 'already_terminal' }
|
|
42
|
+
| { kind: 'compatibility_wake_queued' }
|
|
43
|
+
| { kind: 'not_found_or_fence_rejected' };
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* One detached runner's attempt to settle a Play Run. The queue name belongs
|
|
47
|
+
* here because a compatibility wake is a terminal delivery obligation, not a
|
|
48
|
+
* caller-side scheduler detail.
|
|
49
|
+
*/
|
|
50
|
+
export type PlayRunTerminalInput = {
|
|
51
|
+
queueName: string;
|
|
52
|
+
runId: string;
|
|
53
|
+
attempt: number;
|
|
54
|
+
authority?: PlayRunTerminalAuthority | null;
|
|
55
|
+
result: unknown;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type PlayRunTerminalJob = {
|
|
59
|
+
accept(input: PlayRunTerminalInput): Promise<PlayRunTerminalOutcome>;
|
|
60
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { resolvePlayRunTerminalAuthority } from '../../play-runs/terminal/contracts';
|
|
2
|
+
export { createPlayRunTerminalJob } from '../../play-runs/terminal/job';
|
|
3
|
+
export { createPostgresPlayRunTerminalPorts } from '../../play-runs/terminal/postgres-adapter';
|
|
4
|
+
export type {
|
|
5
|
+
PlayRunTerminalAuthority,
|
|
6
|
+
PlayRunTerminalInput,
|
|
7
|
+
PlayRunTerminalJob,
|
|
8
|
+
PlayRunTerminalOutcome,
|
|
9
|
+
} from '../../play-runs/terminal/contracts';
|
|
10
|
+
export type {
|
|
11
|
+
CompatibilityTerminalRecorder,
|
|
12
|
+
DirectTerminalCommitOutcome,
|
|
13
|
+
DirectTerminalCommitter,
|
|
14
|
+
PlayRunTerminalPorts,
|
|
15
|
+
RunnerTerminalWakePublisher,
|
|
16
|
+
} from '../../play-runs/terminal/ports';
|