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,201 @@
|
|
|
1
|
+
import { mintWorkflowExecutorToken } from './/workflow-executor-auth';
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_RUNTIME_EXECUTION_CAPABILITIES,
|
|
4
|
+
normalizeRuntimeExecutionCapabilities,
|
|
5
|
+
type RuntimeAuthorityDescriptor,
|
|
6
|
+
type RuntimeExecutionCapability,
|
|
7
|
+
} from './/execution-capabilities';
|
|
8
|
+
import type { FixtureBehavior } from './/fixture-behavior';
|
|
9
|
+
import type { PlaySchedulerSubmitInput } from './/scheduler-backend';
|
|
10
|
+
import type { DirectCompletedTerminalContract } from './/scheduler-backends/terminal-contract';
|
|
11
|
+
|
|
12
|
+
export type RuntimeAuthority = {
|
|
13
|
+
executorToken: string;
|
|
14
|
+
descriptor: RuntimeAuthorityDescriptor;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Derive a child Run's durable authority from its admitted parent. The child
|
|
19
|
+
* owns its authored secret names and play identity; organization, actor,
|
|
20
|
+
* billing, scheduler placement, and capability policy remain parent-owned
|
|
21
|
+
* durable facts. This deliberately does not intersect secret names: a child
|
|
22
|
+
* Play resolves its own scoped declaration, where an equal name can identify
|
|
23
|
+
* a different Play-specific secret.
|
|
24
|
+
*/
|
|
25
|
+
export function deriveAsyncChildRuntimeAuthority(input: {
|
|
26
|
+
parent: RuntimeAuthorityDescriptor;
|
|
27
|
+
workflowId: string;
|
|
28
|
+
runId: string;
|
|
29
|
+
playName: string;
|
|
30
|
+
billingRunId: string;
|
|
31
|
+
allowedSecrets: readonly string[];
|
|
32
|
+
}): RuntimeAuthorityDescriptor {
|
|
33
|
+
return {
|
|
34
|
+
orgId: input.parent.orgId,
|
|
35
|
+
workflowId: input.workflowId,
|
|
36
|
+
runId: input.runId,
|
|
37
|
+
// The scheduler-owned parent launch resolves the billing owner to the
|
|
38
|
+
// root before child admission. Keep the descriptor's token claim aligned
|
|
39
|
+
// with that durable run-state fact even for a legacy intermediate parent
|
|
40
|
+
// that predates `billingRunId` on its authority descriptor.
|
|
41
|
+
billingRunId: input.billingRunId,
|
|
42
|
+
playName: input.playName,
|
|
43
|
+
allowedSecrets: [...new Set(input.allowedSecrets)],
|
|
44
|
+
maxCreditsPerRun: input.parent.maxCreditsPerRun ?? null,
|
|
45
|
+
integrationMode: input.parent.integrationMode ?? null,
|
|
46
|
+
fixtureBehavior: input.parent.fixtureBehavior ?? null,
|
|
47
|
+
synthetic: input.parent.synthetic === true,
|
|
48
|
+
actorUserId: input.parent.actorUserId ?? null,
|
|
49
|
+
actorEmail: input.parent.actorEmail ?? null,
|
|
50
|
+
schedulerSchema: input.parent.schedulerSchema ?? null,
|
|
51
|
+
docflowEnabled: input.parent.docflowEnabled === true,
|
|
52
|
+
asyncChildAdmissionAttemptRequired:
|
|
53
|
+
input.parent.asyncChildAdmissionAttemptRequired === true,
|
|
54
|
+
capabilities: normalizeRuntimeExecutionCapabilities(
|
|
55
|
+
input.parent.capabilities,
|
|
56
|
+
),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function mintPlayRunRuntimeAuthorityDescriptor(input: {
|
|
61
|
+
descriptor: RuntimeAuthorityDescriptor;
|
|
62
|
+
runtimeOrigin?: string | null;
|
|
63
|
+
}): Promise<RuntimeAuthority> {
|
|
64
|
+
return {
|
|
65
|
+
descriptor: input.descriptor,
|
|
66
|
+
executorToken: await mintWorkflowExecutorToken({
|
|
67
|
+
...runtimeAuthorityMintInput(input.descriptor),
|
|
68
|
+
runtimeOrigin: input.runtimeOrigin,
|
|
69
|
+
}),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export async function mintPlayRunRuntimeAuthority(input: {
|
|
74
|
+
orgId: string;
|
|
75
|
+
workflowId: string;
|
|
76
|
+
runId: string;
|
|
77
|
+
billingRunId?: string | null;
|
|
78
|
+
playName: string;
|
|
79
|
+
allowedSecrets?: readonly string[] | null;
|
|
80
|
+
maxCreditsPerRun?: number | null;
|
|
81
|
+
integrationMode?: 'live' | 'eval_stub' | 'fixture' | null;
|
|
82
|
+
fixtureBehavior?: FixtureBehavior | null;
|
|
83
|
+
synthetic?: boolean | null;
|
|
84
|
+
actorUserId?: string | null;
|
|
85
|
+
actorEmail?: string | null;
|
|
86
|
+
schedulerSchema?: string | null;
|
|
87
|
+
/** Docflow rollout answer for the launching actor, resolved by the caller. */
|
|
88
|
+
docflowEnabled?: boolean | null;
|
|
89
|
+
runtimeOrigin?: string | null;
|
|
90
|
+
}): Promise<RuntimeAuthority> {
|
|
91
|
+
const descriptor: RuntimeAuthorityDescriptor = {
|
|
92
|
+
orgId: input.orgId,
|
|
93
|
+
workflowId: input.workflowId,
|
|
94
|
+
runId: input.runId,
|
|
95
|
+
billingRunId: input.billingRunId ?? null,
|
|
96
|
+
playName: input.playName,
|
|
97
|
+
allowedSecrets: [...new Set(input.allowedSecrets ?? [])],
|
|
98
|
+
maxCreditsPerRun: input.maxCreditsPerRun ?? null,
|
|
99
|
+
integrationMode: input.integrationMode ?? null,
|
|
100
|
+
fixtureBehavior: input.fixtureBehavior ?? null,
|
|
101
|
+
synthetic: input.synthetic === true,
|
|
102
|
+
actorUserId: input.actorUserId ?? null,
|
|
103
|
+
actorEmail: input.actorEmail ?? null,
|
|
104
|
+
schedulerSchema: input.schedulerSchema ?? null,
|
|
105
|
+
docflowEnabled: input.docflowEnabled === true,
|
|
106
|
+
capabilities: normalizeRuntimeExecutionCapabilities(
|
|
107
|
+
DEFAULT_RUNTIME_EXECUTION_CAPABILITIES,
|
|
108
|
+
),
|
|
109
|
+
};
|
|
110
|
+
return await mintPlayRunRuntimeAuthorityDescriptor({
|
|
111
|
+
descriptor,
|
|
112
|
+
runtimeOrigin: input.runtimeOrigin,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function runtimeAuthorityMintInput(
|
|
117
|
+
descriptor: RuntimeAuthorityDescriptor,
|
|
118
|
+
input: {
|
|
119
|
+
runAttempt?: number | null;
|
|
120
|
+
runLeaseToken?: string | null;
|
|
121
|
+
terminalContract?: DirectCompletedTerminalContract | null;
|
|
122
|
+
capabilities?: readonly RuntimeExecutionCapability[];
|
|
123
|
+
runtimeOrigin?: string | null;
|
|
124
|
+
} = {},
|
|
125
|
+
) {
|
|
126
|
+
return {
|
|
127
|
+
orgId: descriptor.orgId,
|
|
128
|
+
workflowId: descriptor.workflowId,
|
|
129
|
+
runId: descriptor.runId,
|
|
130
|
+
billingRunId: descriptor.billingRunId,
|
|
131
|
+
playName: descriptor.playName,
|
|
132
|
+
allowedSecrets: descriptor.allowedSecrets,
|
|
133
|
+
maxCreditsPerRun: descriptor.maxCreditsPerRun,
|
|
134
|
+
integrationMode: descriptor.integrationMode,
|
|
135
|
+
fixtureBehavior: descriptor.fixtureBehavior,
|
|
136
|
+
synthetic: descriptor.synthetic,
|
|
137
|
+
actorUserId: descriptor.actorUserId,
|
|
138
|
+
actorEmail: descriptor.actorEmail,
|
|
139
|
+
schedulerSchema: descriptor.schedulerSchema,
|
|
140
|
+
runAttempt: input.runAttempt,
|
|
141
|
+
runLeaseToken: input.runLeaseToken,
|
|
142
|
+
terminalContract: input.terminalContract,
|
|
143
|
+
capabilities: input.capabilities ?? descriptor.capabilities,
|
|
144
|
+
runtimeOrigin: input.runtimeOrigin,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export async function mintPlayRunAttemptRuntimeToken(input: {
|
|
149
|
+
descriptor: RuntimeAuthorityDescriptor;
|
|
150
|
+
runAttempt?: number | null;
|
|
151
|
+
runLeaseToken?: string | null;
|
|
152
|
+
terminalContract?: DirectCompletedTerminalContract | null;
|
|
153
|
+
capabilities?: readonly RuntimeExecutionCapability[];
|
|
154
|
+
runtimeOrigin?: string | null;
|
|
155
|
+
}): Promise<string> {
|
|
156
|
+
return await mintWorkflowExecutorToken(
|
|
157
|
+
runtimeAuthorityMintInput(input.descriptor, input),
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Reconstruct the smallest authority needed to settle compute billing for a
|
|
163
|
+
* terminal launch row written before runtimeAuthority became durable state.
|
|
164
|
+
*
|
|
165
|
+
* This is deliberately not a general legacy-token fallback. The caller may
|
|
166
|
+
* mint only billing.write, and every fact comes from the leased launch row
|
|
167
|
+
* selected by the scheduler rather than the worker's request body.
|
|
168
|
+
*/
|
|
169
|
+
export function requireComputeBillingDispatchRuntimeAuthority(
|
|
170
|
+
launch: Pick<
|
|
171
|
+
PlaySchedulerSubmitInput,
|
|
172
|
+
'orgId' | 'runId' | 'playName' | 'userId' | 'userEmail'
|
|
173
|
+
>,
|
|
174
|
+
): RuntimeAuthorityDescriptor {
|
|
175
|
+
const orgId = launch.orgId?.trim();
|
|
176
|
+
const runId = launch.runId?.trim();
|
|
177
|
+
const playName = launch.playName?.trim();
|
|
178
|
+
if (!orgId || !runId || !playName) {
|
|
179
|
+
throw new Error(
|
|
180
|
+
'Legacy compute-billing launch is missing orgId, runId, or playName.',
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
orgId,
|
|
186
|
+
// Scheduler envelopes use the workflow id as the durable run id.
|
|
187
|
+
workflowId: runId,
|
|
188
|
+
runId,
|
|
189
|
+
billingRunId: runId,
|
|
190
|
+
playName,
|
|
191
|
+
allowedSecrets: [],
|
|
192
|
+
maxCreditsPerRun: null,
|
|
193
|
+
integrationMode: null,
|
|
194
|
+
fixtureBehavior: null,
|
|
195
|
+
synthetic: false,
|
|
196
|
+
actorUserId: launch.userId?.trim() || null,
|
|
197
|
+
actorEmail: launch.userEmail?.trim() || null,
|
|
198
|
+
docflowEnabled: false,
|
|
199
|
+
capabilities: ['billing.write'],
|
|
200
|
+
};
|
|
201
|
+
}
|
|
@@ -59,3 +59,9 @@ export function isTestOnlyRuntime(): boolean {
|
|
|
59
59
|
if (process.env.VERCEL_ENV === 'production') return false;
|
|
60
60
|
return process.env.VERCEL_ENV === 'preview' || getRuntimeEnv() !== 'prod';
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
export function shouldEnableMarketingIntegrations(): boolean {
|
|
64
|
+
return getRuntimeEnv() === 'prod';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { isBuildContext } from '../observability/build-context';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
deployed,
|
|
3
|
+
type DeployedOperationContract,
|
|
4
|
+
} from '@deepline/deployed-contracts';
|
|
5
|
+
import type { RuntimeExecutionCapability } from './execution-capabilities';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* One declarative owner for the runtime action → authority relationship. The
|
|
9
|
+
* route still owns authentication and execution; callers can add an action in
|
|
10
|
+
* one obvious place and CI will prevent removing/changing an existing one.
|
|
11
|
+
*/
|
|
12
|
+
export const RUNTIME_OPERATION_CAPABILITIES = {
|
|
13
|
+
create_signed_artifact_url: 'artifact.read',
|
|
14
|
+
resolve_play: 'artifact.read',
|
|
15
|
+
create_signed_staged_file_url: 'file.read',
|
|
16
|
+
get_runtime_step_receipt: 'receipt.read',
|
|
17
|
+
get_runtime_step_receipts: 'receipt.read',
|
|
18
|
+
acquire_runtime_receipt_execution_lock: 'receipt.write',
|
|
19
|
+
release_runtime_receipt_execution_lock: 'receipt.write',
|
|
20
|
+
claim_runtime_step_receipt: 'receipt.write',
|
|
21
|
+
claim_runtime_step_receipts: 'receipt.write',
|
|
22
|
+
mark_runtime_step_receipt_running: 'receipt.write',
|
|
23
|
+
mark_runtime_step_receipts_running: 'receipt.write',
|
|
24
|
+
mark_runtime_step_receipts_queued: 'receipt.write',
|
|
25
|
+
complete_runtime_step_receipt: 'receipt.write',
|
|
26
|
+
complete_runtime_step_receipts: 'receipt.write',
|
|
27
|
+
release_runtime_step_receipt: 'receipt.write',
|
|
28
|
+
fail_runtime_step_receipt: 'receipt.write',
|
|
29
|
+
fail_runtime_step_receipts: 'receipt.write',
|
|
30
|
+
heartbeat_runtime_step_receipts: 'receipt.write',
|
|
31
|
+
skip_runtime_step_receipt: 'receipt.write',
|
|
32
|
+
ensure_sheet: 'sheet.write',
|
|
33
|
+
apply_row_updates: 'sheet.write',
|
|
34
|
+
create_db_session: 'db.session',
|
|
35
|
+
repair_runtime_storage_grants: 'sheet.write',
|
|
36
|
+
append_run_events: 'run.progress',
|
|
37
|
+
save_results: 'run.progress',
|
|
38
|
+
start_run: 'run.progress',
|
|
39
|
+
record_first_claim_latency: 'run.progress',
|
|
40
|
+
project_run_created: 'run.progress',
|
|
41
|
+
launch_play_async: 'run.child',
|
|
42
|
+
compute_billing_upsert: 'billing.write',
|
|
43
|
+
compute_billing_record_item: 'billing.write',
|
|
44
|
+
compute_billing_finalize: 'billing.write',
|
|
45
|
+
rate_state_acquire: 'rate.acquire',
|
|
46
|
+
rate_state_release: 'rate.acquire',
|
|
47
|
+
rate_state_penalize: 'rate.acquire',
|
|
48
|
+
get_runtime_traffic_policy: 'rate.acquire',
|
|
49
|
+
governor_budget_charge: 'budget.charge',
|
|
50
|
+
resolve_secret: 'secret.resolve',
|
|
51
|
+
} as const satisfies Readonly<Record<string, RuntimeExecutionCapability>>;
|
|
52
|
+
|
|
53
|
+
export const RUNTIME_OPERATION_CONTRACT: DeployedOperationContract =
|
|
54
|
+
deployed.operation({
|
|
55
|
+
id: 'runtime-api-actions',
|
|
56
|
+
actions: RUNTIME_OPERATION_CAPABILITIES,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export function runtimeOperationCapability(
|
|
60
|
+
action: string,
|
|
61
|
+
): RuntimeExecutionCapability | null {
|
|
62
|
+
return (
|
|
63
|
+
RUNTIME_OPERATION_CAPABILITIES[
|
|
64
|
+
action as keyof typeof RUNTIME_OPERATION_CAPABILITIES
|
|
65
|
+
] ?? null
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { deployed, readDeployedObject } from '@deepline/deployed-contracts';
|
|
2
|
+
|
|
3
|
+
export type RuntimeSandboxProviderId = 'daytona' | 'modal';
|
|
4
|
+
|
|
5
|
+
export type RuntimeSandboxRef = {
|
|
6
|
+
/** Internal normalized form; persisted writer markers are diagnostic only. */
|
|
7
|
+
schemaVersion: 1;
|
|
8
|
+
provider: RuntimeSandboxProviderId;
|
|
9
|
+
resourceId: string;
|
|
10
|
+
routingDomain: string | null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This ref lives in a durable suspension. Its provider and resource identity
|
|
15
|
+
* fence cleanup; its writer marker never decides whether a known sandbox can
|
|
16
|
+
* be reconciled by a different deployment.
|
|
17
|
+
*/
|
|
18
|
+
export const RUNTIME_SANDBOX_REF_CONTRACT = deployed.object({
|
|
19
|
+
id: 'runtime-sandbox-ref',
|
|
20
|
+
unknown: 'preserve',
|
|
21
|
+
fields: {
|
|
22
|
+
provider: deployed.openEnum(),
|
|
23
|
+
resourceId: deployed.string(),
|
|
24
|
+
routingDomain: deployed.json(),
|
|
25
|
+
schemaVersion: deployed.optional(deployed.diagnostic.number(), {
|
|
26
|
+
whenAbsent: 'diagnostic unavailable',
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export function readPersistedRuntimeSandboxRef(input: {
|
|
32
|
+
raw: unknown;
|
|
33
|
+
expectedSandboxId: string;
|
|
34
|
+
expectedProvider?: unknown;
|
|
35
|
+
}): RuntimeSandboxRef {
|
|
36
|
+
const invalid = () =>
|
|
37
|
+
new Error(
|
|
38
|
+
`Persisted Runtime Sandbox Ref is invalid or inconsistent for sandbox ${input.expectedSandboxId}.`,
|
|
39
|
+
);
|
|
40
|
+
let value: Record<string, unknown>;
|
|
41
|
+
try {
|
|
42
|
+
value = readDeployedObject(RUNTIME_SANDBOX_REF_CONTRACT, input.raw).value;
|
|
43
|
+
} catch {
|
|
44
|
+
throw invalid();
|
|
45
|
+
}
|
|
46
|
+
const provider = value.provider;
|
|
47
|
+
const resourceId =
|
|
48
|
+
typeof value.resourceId === 'string' ? value.resourceId.trim() : '';
|
|
49
|
+
const routingDomain = value.routingDomain;
|
|
50
|
+
if (
|
|
51
|
+
(provider !== 'daytona' && provider !== 'modal') ||
|
|
52
|
+
!resourceId ||
|
|
53
|
+
resourceId !== input.expectedSandboxId.trim() ||
|
|
54
|
+
(routingDomain !== null && typeof routingDomain !== 'string') ||
|
|
55
|
+
(typeof routingDomain === 'string' && !routingDomain.trim()) ||
|
|
56
|
+
(input.expectedProvider !== undefined &&
|
|
57
|
+
input.expectedProvider !== provider)
|
|
58
|
+
) {
|
|
59
|
+
throw invalid();
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
schemaVersion: 1,
|
|
63
|
+
provider,
|
|
64
|
+
resourceId,
|
|
65
|
+
routingDomain:
|
|
66
|
+
typeof routingDomain === 'string' ? routingDomain.trim() : null,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runtime-scheduler topology predicate shared by the app-side lane helpers
|
|
3
|
-
* (`
|
|
3
|
+
* (`packages/play-runtime/scheduler-backends/absurd-shared.ts`) and the runner
|
|
4
4
|
* backends (`runner-backends/backends/daytona-lifecycle.ts`).
|
|
5
5
|
*
|
|
6
6
|
* ONE distinction drives several guards: a run whose scheduler schema is the
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* production egress policy), while any other schema is an ISOLATED topology —
|
|
9
9
|
* a per-PR preview fleet or a per-worktree dev fleet running synthetic
|
|
10
10
|
* internal test plays. Keeping the predicate here (dependency-free) lets
|
|
11
|
-
*
|
|
11
|
+
* package code uses it without importing the app-side scheduler stack.
|
|
12
12
|
*/
|
|
13
13
|
export const PROD_DEFAULT_RUNTIME_SCHEDULER_SCHEMA = 'runtime_scheduler';
|
|
14
14
|
|
|
@@ -48,3 +48,15 @@ export function isIsolatedRuntimeSchedulerSchema(
|
|
|
48
48
|
const schema = schedulerSchema?.trim();
|
|
49
49
|
return Boolean(schema) && schema !== PROD_DEFAULT_RUNTIME_SCHEDULER_SCHEMA;
|
|
50
50
|
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* PostgreSQL LISTEN only improves wake-up latency; durable polling owns
|
|
54
|
+
* correctness. Isolated schemas deliberately share a small direct-connection
|
|
55
|
+
* budget across preview workers, so they use that polling path and leave
|
|
56
|
+
* direct sessions to the production topology.
|
|
57
|
+
*/
|
|
58
|
+
export function shouldUseRuntimeSchedulerDirectNotify(
|
|
59
|
+
schedulerSchema: string | null | undefined,
|
|
60
|
+
): boolean {
|
|
61
|
+
return !isIsolatedRuntimeSchedulerSchema(schedulerSchema);
|
|
62
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { createTelemetry } from '../observability/telemetry';
|
|
2
|
+
|
|
3
|
+
type PlayRuntimeTelemetryInput = {
|
|
4
|
+
phase: string;
|
|
5
|
+
status: string;
|
|
6
|
+
orgId?: string | null;
|
|
7
|
+
runId?: string | null;
|
|
8
|
+
playName?: string | null;
|
|
9
|
+
graphHash?: string | null;
|
|
10
|
+
triggerSource?: string | null;
|
|
11
|
+
ms?: number;
|
|
12
|
+
errorCode?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const playRuntimeTelemetry = createTelemetry({
|
|
16
|
+
service: 'deepline-api',
|
|
17
|
+
component: 'play-runtime',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
type PlayTelemetryLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
21
|
+
|
|
22
|
+
function stringField(
|
|
23
|
+
fields: Record<string, unknown>,
|
|
24
|
+
...keys: readonly string[]
|
|
25
|
+
): string | null {
|
|
26
|
+
for (const key of keys) {
|
|
27
|
+
const value = fields[key];
|
|
28
|
+
if (typeof value === 'string' && value.trim()) return value.trim();
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function emitPlayTelemetry(input: {
|
|
34
|
+
level: PlayTelemetryLevel;
|
|
35
|
+
event: string;
|
|
36
|
+
tag: string;
|
|
37
|
+
fields?: Record<string, unknown>;
|
|
38
|
+
error?: unknown;
|
|
39
|
+
}): void {
|
|
40
|
+
const fields = input.fields ?? {};
|
|
41
|
+
const telemetry = playRuntimeTelemetry.child({
|
|
42
|
+
context: {
|
|
43
|
+
orgId: stringField(fields, 'orgId', 'org_id'),
|
|
44
|
+
orgName: stringField(fields, 'orgName', 'org_name'),
|
|
45
|
+
requestId: stringField(fields, 'requestId', 'request_id'),
|
|
46
|
+
runId: stringField(fields, 'runId', 'run_id'),
|
|
47
|
+
workflowId: stringField(fields, 'workflowId', 'workflow_id', 'runId'),
|
|
48
|
+
playName: stringField(fields, 'playName', 'play_name'),
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
const options = { tag: input.tag };
|
|
52
|
+
if (input.level === 'error') {
|
|
53
|
+
void telemetry.error(input.event, input.error, fields, options);
|
|
54
|
+
} else {
|
|
55
|
+
void telemetry[input.level](input.event, fields, options);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Emit the stable play.runtime.span event consumed by Axiom dashboards.
|
|
61
|
+
* Domain fields stay unchanged while the shared telemetry envelope supplies
|
|
62
|
+
* consistent service, context, severity, and schema metadata.
|
|
63
|
+
*/
|
|
64
|
+
export function emitPlayRuntimeSpan(input: PlayRuntimeTelemetryInput): void {
|
|
65
|
+
emitPlayTelemetry({
|
|
66
|
+
level: 'info',
|
|
67
|
+
event: 'play.runtime.span',
|
|
68
|
+
tag: '[play.runtime.span]',
|
|
69
|
+
fields: {
|
|
70
|
+
orgId: input.orgId,
|
|
71
|
+
runId: input.runId,
|
|
72
|
+
workflowId: input.runId,
|
|
73
|
+
playName: input.playName,
|
|
74
|
+
phase: input.phase,
|
|
75
|
+
status: input.status,
|
|
76
|
+
graphHash: input.graphHash,
|
|
77
|
+
triggerSource: input.triggerSource,
|
|
78
|
+
ms: input.ms,
|
|
79
|
+
errorCode: input.errorCode,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function emitRecoveredSecretResolutionRetry(input: {
|
|
85
|
+
orgId: string;
|
|
86
|
+
runId?: string | null;
|
|
87
|
+
playName?: string | null;
|
|
88
|
+
requestId: string;
|
|
89
|
+
operationId: string;
|
|
90
|
+
attempt: number;
|
|
91
|
+
httpStatus: number;
|
|
92
|
+
}): void {
|
|
93
|
+
emitPlayTelemetry({
|
|
94
|
+
level: 'warn',
|
|
95
|
+
event: 'play.runtime.secret_resolution_retry_recovered',
|
|
96
|
+
tag: '[play.runtime.secret_resolution_retry_recovered]',
|
|
97
|
+
fields: {
|
|
98
|
+
orgId: input.orgId,
|
|
99
|
+
runId: input.runId,
|
|
100
|
+
workflowId: input.runId,
|
|
101
|
+
playName: input.playName,
|
|
102
|
+
requestId: input.requestId,
|
|
103
|
+
operationId: input.operationId,
|
|
104
|
+
attempt: input.attempt,
|
|
105
|
+
httpStatus: input.httpStatus,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
}
|
|
@@ -230,6 +230,8 @@ export type SandboxExecutionAdmission = {
|
|
|
230
230
|
leaseId: string;
|
|
231
231
|
/** Stable provider correlation for operation-first managed creates. */
|
|
232
232
|
providerOperationToken?: string | null;
|
|
233
|
+
/** Resume the existing durable provider operation before any new create. */
|
|
234
|
+
resumeExistingProviderOperation?: boolean;
|
|
233
235
|
}
|
|
234
236
|
| { kind: 'pre_code_deferred'; reason: SandboxPreCodeDeferralReason }
|
|
235
237
|
>;
|
|
@@ -293,6 +295,8 @@ export type SandboxExecutionLifecycle = {
|
|
|
293
295
|
leaseId: string;
|
|
294
296
|
/** Stable provider correlation for operation-first managed creates. */
|
|
295
297
|
providerOperationToken?: string | null;
|
|
298
|
+
/** Resume the existing durable provider operation before any new create. */
|
|
299
|
+
resumeExistingProviderOperation?: boolean;
|
|
296
300
|
}
|
|
297
301
|
| { kind: 'pre_code_deferred'; reason: SandboxPreCodeDeferralReason }
|
|
298
302
|
>;
|
package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts
CHANGED
|
@@ -180,6 +180,9 @@ function createRunnerCallbacks(input: {
|
|
|
180
180
|
return {
|
|
181
181
|
leaseId: outcome.leaseId,
|
|
182
182
|
providerOperationToken: outcome.providerOperationToken ?? null,
|
|
183
|
+
...(outcome.resumeExistingProviderOperation === true
|
|
184
|
+
? { resumeExistingProviderOperation: true }
|
|
185
|
+
: {}),
|
|
183
186
|
};
|
|
184
187
|
},
|
|
185
188
|
releaseSandboxCapacity: async (leaseId) => {
|
|
@@ -47,6 +47,13 @@ export type PlaySchedulerSubmitInput = {
|
|
|
47
47
|
asyncLaunchKey?: string | null;
|
|
48
48
|
asyncInvocationKey?: string | null;
|
|
49
49
|
asyncRequestFingerprint?: string | null;
|
|
50
|
+
/**
|
|
51
|
+
* Ephemeral proof carried only into atomic async-child admission. It is never
|
|
52
|
+
* persisted on the child launch; the child receives its own authority.
|
|
53
|
+
*/
|
|
54
|
+
asyncParentRunAttempt?: number | null;
|
|
55
|
+
asyncParentRunLeaseToken?: string | null;
|
|
56
|
+
asyncParentAttemptRequired?: boolean | null;
|
|
50
57
|
/** Full play ancestry for a scheduled child, including this play. */
|
|
51
58
|
asyncAncestryPlayIds?: string[] | null;
|
|
52
59
|
playId: string;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { cancelPostgresSchedulerRun } from './postgres';
|
|
2
|
+
import type {
|
|
3
|
+
PostgresSchedulerOptions,
|
|
4
|
+
PostgresSchedulerQueryClient,
|
|
5
|
+
} from './postgres';
|
|
6
|
+
import { ABSURD_PLAY_RUN_TASK } from './absurd-shared';
|
|
7
|
+
import { resolveRuntimeSchedulerSchemaEnv } from './runtime-scheduler-schema';
|
|
8
|
+
|
|
9
|
+
/** Bound deadline reconciliation just like Absurd's own cancellation sweep. */
|
|
10
|
+
export const ABSURD_CANCELLED_DEADLINE_RECONCILE_LIMIT = 100;
|
|
11
|
+
|
|
12
|
+
function quoteAbsurdTable(table: string): string {
|
|
13
|
+
return `"${table.replaceAll('"', '""')}"`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Project a play task cancelled by Absurd's indexed `max_delay` sweep into the
|
|
18
|
+
* scheduler's authoritative run state.
|
|
19
|
+
*
|
|
20
|
+
* The engine can cancel an overdue task before or after a worker claims its
|
|
21
|
+
* handler. A cancelled task has no handler path left to write the normal
|
|
22
|
+
* terminal state. This reconciler
|
|
23
|
+
* closes that gap: `cancelPostgresSchedulerRun` atomically writes the runtime
|
|
24
|
+
* terminal and its run-ledger outbox event, and is idempotent if a user cancel
|
|
25
|
+
* or a racing worker already terminalized the run. The next empty claim invokes
|
|
26
|
+
* it immediately after Absurd performs its bounded cancellation sweep.
|
|
27
|
+
*/
|
|
28
|
+
export async function reconcileAbsurdRuntimeMaxDelayCancellations(input: {
|
|
29
|
+
client: PostgresSchedulerQueryClient;
|
|
30
|
+
queue: string;
|
|
31
|
+
schedulerOptions?: Pick<PostgresSchedulerOptions, 'schema'>;
|
|
32
|
+
limit?: number;
|
|
33
|
+
}): Promise<{ reconciled: number; skipped: number }> {
|
|
34
|
+
const requestedLimit = Math.floor(
|
|
35
|
+
input.limit ?? ABSURD_CANCELLED_DEADLINE_RECONCILE_LIMIT,
|
|
36
|
+
);
|
|
37
|
+
const limit = Number.isFinite(requestedLimit)
|
|
38
|
+
? Math.max(
|
|
39
|
+
1,
|
|
40
|
+
Math.min(ABSURD_CANCELLED_DEADLINE_RECONCILE_LIMIT, requestedLimit),
|
|
41
|
+
)
|
|
42
|
+
: ABSURD_CANCELLED_DEADLINE_RECONCILE_LIMIT;
|
|
43
|
+
const taskTable = quoteAbsurdTable(`t_${input.queue}`);
|
|
44
|
+
const schedulerSchema = quoteAbsurdTable(
|
|
45
|
+
input.schedulerOptions?.schema?.trim() ||
|
|
46
|
+
resolveRuntimeSchedulerSchemaEnv() ||
|
|
47
|
+
'runtime_scheduler',
|
|
48
|
+
);
|
|
49
|
+
const cancelled = await input.client.query<{ run_id: string | null }>(
|
|
50
|
+
`
|
|
51
|
+
SELECT task.params ->> 'runId' AS run_id
|
|
52
|
+
FROM absurd.${taskTable} AS task
|
|
53
|
+
JOIN ${schedulerSchema}.runs AS run
|
|
54
|
+
ON run.run_id = task.params ->> 'runId'
|
|
55
|
+
AND run.status IN ('queued', 'running', 'waiting')
|
|
56
|
+
WHERE task.state = 'cancelled'
|
|
57
|
+
AND task.task_name = $1
|
|
58
|
+
AND task.cancellation ? 'max_delay'
|
|
59
|
+
AND task.cancel_at IS NOT NULL
|
|
60
|
+
AND task.cancelled_at >= task.cancel_at
|
|
61
|
+
ORDER BY task.cancelled_at ASC NULLS LAST, task.task_id ASC
|
|
62
|
+
LIMIT $2
|
|
63
|
+
`,
|
|
64
|
+
[ABSURD_PLAY_RUN_TASK, limit],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
let reconciled = 0;
|
|
68
|
+
let skipped = 0;
|
|
69
|
+
for (const row of cancelled.rows) {
|
|
70
|
+
const runId = row.run_id?.trim();
|
|
71
|
+
if (!runId) {
|
|
72
|
+
skipped += 1;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const didCancel = await cancelPostgresSchedulerRun(
|
|
76
|
+
input.client,
|
|
77
|
+
{
|
|
78
|
+
runId,
|
|
79
|
+
reason:
|
|
80
|
+
'Run did not start within its configured scheduler queue deadline.',
|
|
81
|
+
},
|
|
82
|
+
input.schedulerOptions,
|
|
83
|
+
);
|
|
84
|
+
if (didCancel) reconciled += 1;
|
|
85
|
+
else skipped += 1;
|
|
86
|
+
}
|
|
87
|
+
return { reconciled, skipped };
|
|
88
|
+
}
|