deepline 0.3.499 → 0.3.501
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/dist/bundling-sources/sdk/src/plays/client-core.ts +45 -7
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +36 -0
- package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +155 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +7 -1
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +2 -1
- package/dist/bundling-sources/shared_libs/play-runtime/durable-invocation-fence.ts +3 -1
- package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +54 -1
- package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +12 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +13 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +56 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +21 -10
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-progress-push.ts +1 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +9 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +31 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +74 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +226 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +41 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +5 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-app-transport.ts +374 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-environment.ts +49 -9
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-oidc.ts +25 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-profile.ts +12 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-sandbox-credential.ts +338 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-staging.ts +417 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +15 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +184 -11
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +17 -3
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-progress-registry.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +18 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +176 -16
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-attempt.ts +81 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-staging-journal.ts +708 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-staging-teardown.ts +160 -0
- package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +4 -0
- package/dist/cli/{auth-TECJ27G3.mjs → auth-6ECHXOI4.mjs} +5 -5
- package/dist/cli/auth-VP7PMXKQ.js +43 -0
- package/dist/cli/{billing-PMKO73VG.mjs → billing-75NZYRXA.mjs} +8 -8
- package/dist/cli/{billing-ULZGAED6.js → billing-QRR7O6BD.js} +81 -81
- package/dist/cli/{chunk-K54BUQSK.js → chunk-463ZOO2L.js} +7 -7
- package/dist/cli/{chunk-L6C7C7IJ.js → chunk-4OXHLTCP.js} +1 -1
- package/dist/cli/{chunk-3GP52OHV.mjs → chunk-5S7MLAI7.mjs} +11 -11
- package/dist/cli/{chunk-7OQZZHZ4.js → chunk-5X4AUFYW.js} +7 -7
- package/dist/cli/{chunk-56JE475N.mjs → chunk-66XDYH5T.mjs} +2 -2
- package/dist/cli/{chunk-A2VCFBZN.mjs → chunk-7L6QNHUL.mjs} +1 -1
- package/dist/cli/{chunk-UOQUCFAK.js → chunk-APAHMCGR.js} +53 -53
- package/dist/cli/{chunk-UBKA33KY.mjs → chunk-BMCRTI6Z.mjs} +22 -1
- package/dist/cli/{chunk-WSOM3TY6.js → chunk-BOFCF4L7.js} +3 -3
- package/dist/cli/{chunk-SLWCXGKP.js → chunk-CJJ7JBM2.js} +16 -16
- package/dist/cli/{chunk-JM52ATUS.mjs → chunk-EHVFBD36.mjs} +1 -1
- package/dist/cli/{chunk-7WUMIRBV.js → chunk-EKF4DKUA.js} +5 -5
- package/dist/cli/{chunk-AGZRRHSB.js → chunk-EKZQ5LQO.js} +3 -3
- package/dist/cli/{chunk-5IDORX4E.mjs → chunk-EOO7OSS4.mjs} +4 -4
- package/dist/cli/{chunk-2PKZ3RUU.js → chunk-FS7XYDOF.js} +16 -16
- package/dist/cli/{chunk-Z2MO7FZG.js → chunk-HDKXSHGA.js} +53 -53
- package/dist/cli/{chunk-YRQWGWRJ.js → chunk-J6SVNKRP.js} +2 -2
- package/dist/cli/{chunk-QXI2W7YY.mjs → chunk-J74N375S.mjs} +4 -4
- package/dist/cli/{chunk-KLQ5CR77.js → chunk-KTOAJP4N.js} +6 -6
- package/dist/cli/{chunk-ZVAD65CF.mjs → chunk-MADTHS56.mjs} +1 -1
- package/dist/cli/{chunk-UMPCQ4EE.mjs → chunk-MSLXAVVK.mjs} +2 -2
- package/dist/cli/{chunk-JIZHGOZ5.js → chunk-N2TJJNCW.js} +96 -96
- package/dist/cli/{chunk-CS2AEAD6.mjs → chunk-N4TR6QRI.mjs} +1 -1
- package/dist/cli/{chunk-43ZERPGR.mjs → chunk-NA3J3F2Z.mjs} +1 -1
- package/dist/cli/{chunk-JQHJKARU.mjs → chunk-O3DDVP7Z.mjs} +1 -1
- package/dist/cli/{chunk-JUQESEJX.mjs → chunk-OKOXB3LY.mjs} +2 -2
- package/dist/cli/{chunk-FG5OZ5FB.js → chunk-PNF2ZU4R.js} +8 -8
- package/dist/cli/{chunk-KZJKRU24.mjs → chunk-PXIF74UJ.mjs} +4 -4
- package/dist/cli/{chunk-TUDYBF4Y.js → chunk-QQ3JJYE2.js} +14 -14
- package/dist/cli/{chunk-IGCSKXGK.mjs → chunk-RFV7PPLS.mjs} +3 -3
- package/dist/cli/{chunk-EQR5O2D2.js → chunk-RNSHCJME.js} +3 -3
- package/dist/cli/{chunk-PE3UHMMZ.js → chunk-RU5ROUFO.js} +5 -5
- package/dist/cli/{chunk-2RZHMCDL.js → chunk-SV2TEZ2M.js} +4 -4
- package/dist/cli/{chunk-P3MGNLZF.mjs → chunk-T4U245E4.mjs} +2 -2
- package/dist/cli/{chunk-7UC2UZYW.mjs → chunk-T7E3XEPG.mjs} +6 -6
- package/dist/cli/{chunk-LUNXREUI.js → chunk-TOE7LHEA.js} +6 -6
- package/dist/cli/{chunk-OWHQ4OG5.mjs → chunk-UJRN6YP6.mjs} +3 -3
- package/dist/cli/{chunk-XSUQAUG4.js → chunk-UR7JOSLT.js} +360 -300
- package/dist/cli/{chunk-KOD45UP5.mjs → chunk-V5NHEYU7.mjs} +5 -5
- package/dist/cli/{chunk-PSYGSXDS.mjs → chunk-VD2374K7.mjs} +1 -1
- package/dist/cli/{chunk-57LW4TGY.js → chunk-VL72UKNW.js} +26 -26
- package/dist/cli/{chunk-YAW7ET4P.mjs → chunk-VTDAJZIJ.mjs} +90 -30
- package/dist/cli/{chunk-AKLI4XSG.js → chunk-VVEMPC2I.js} +2 -2
- package/dist/cli/{chunk-L7O7AFSF.js → chunk-W6JTHVPF.js} +21 -21
- package/dist/cli/{chunk-MQ5YPD7K.mjs → chunk-WJUDAHIQ.mjs} +1 -1
- package/dist/cli/{chunk-XDVT3GOM.js → chunk-WSGXBROE.js} +22 -1
- package/dist/cli/{chunk-G7BB2VOC.js → chunk-XEBFJ2PH.js} +41 -41
- package/dist/cli/{chunk-WEVIUQGZ.mjs → chunk-Z6AUOV7D.mjs} +2 -2
- package/dist/cli/{chunk-BBFWIYAF.mjs → chunk-ZUOKIBLJ.mjs} +2 -2
- package/dist/cli/{chunk-C2V5U6HO.mjs → chunk-ZUQHQGC5.mjs} +5 -5
- package/dist/cli/{csv-VGSQ3JYE.js → csv-JXX2LXK5.js} +13 -13
- package/dist/cli/{csv-ACO5YC46.mjs → csv-RZJ4SOIL.mjs} +4 -4
- package/dist/cli/{db-CXNZOXGM.mjs → db-MUTT2NWI.mjs} +8 -8
- package/dist/cli/{db-QOUPHFFN.js → db-T2KJNONM.js} +29 -29
- package/dist/cli/{describe-J4O5GCJS.mjs → describe-K3UMAAVO.mjs} +19 -19
- package/dist/cli/describe-SEXUJLE4.js +50 -0
- package/dist/cli/describe-core.d.mts +2 -2
- package/dist/cli/describe-core.d.ts +2 -2
- package/dist/cli/{executions-YIECH2CL.js → executions-7HSLDRHR.js} +10 -10
- package/dist/cli/{executions-SJETRLXW.mjs → executions-PHS4R2OX.mjs} +8 -8
- package/dist/cli/{feedback-5BRCNERV.js → feedback-BJZRM637.js} +8 -8
- package/dist/cli/{feedback-GSAFFMF6.mjs → feedback-RWMDCIDF.mjs} +4 -4
- package/dist/cli/git-VNS7UQWN.js +25 -0
- package/dist/cli/{git-SF5XIGLU.mjs → git-YW6VHYZG.mjs} +5 -5
- package/dist/cli/index.js +137 -137
- package/dist/cli/index.mjs +40 -40
- package/dist/cli/{legacy-noops-5TBT4XC6.js → legacy-noops-2WUV2XD7.js} +8 -8
- package/dist/cli/{legacy-noops-TZA3CALE.mjs → legacy-noops-5UBSUPGG.mjs} +5 -5
- package/dist/cli/{monitors-XAYWJNSV.mjs → monitors-HWOQO3OK.mjs} +9 -9
- package/dist/cli/{monitors-XNB5YNC3.js → monitors-YZZRKSTG.js} +97 -97
- package/dist/cli/{org-2UYWJXG7.js → org-JY7HLHBA.js} +74 -74
- package/dist/cli/{org-S5VZL5KZ.mjs → org-NCXT6RB4.mjs} +8 -8
- package/dist/cli/{pages-ZQRRTZIT.js → pages-6ZOHXL6X.js} +20 -20
- package/dist/cli/{pages-NGVJO7PA.mjs → pages-QJO53QAT.mjs} +8 -8
- package/dist/cli/{play-3JNERHSC.mjs → play-SQRS7JN3.mjs} +20 -20
- package/dist/cli/{play-P3OYQ7JV.js → play-TAYGSR35.js} +336 -336
- package/dist/cli/{providers-27O6BOAP.mjs → providers-3IR3N5DT.mjs} +8 -8
- package/dist/cli/{providers-2FFGAPUR.js → providers-4Q5LOIQ5.js} +11 -11
- package/dist/cli/{quickstart-5G2UPKJV.js → quickstart-ITNUZENY.js} +6 -6
- package/dist/cli/{quickstart-B2EXIAU6.mjs → quickstart-KCZCYO6B.mjs} +4 -4
- package/dist/cli/{run-3QFXYV3Z.mjs → run-JCWRWDSK.mjs} +24 -24
- package/dist/cli/{run-2TGD7FAL.js → run-YQ57LMKN.js} +42 -42
- package/dist/cli/run-identity-HFYABUJS.js +31 -0
- package/dist/cli/{run-identity-MRNCEGV2.mjs → run-identity-MNRZS2N3.mjs} +9 -3
- package/dist/cli/{search-GXEEOMVD.mjs → search-FUM27HQP.mjs} +9 -9
- package/dist/cli/search-I425FRTK.js +32 -0
- package/dist/cli/{search-output-DMIJQTAA.mjs → search-output-EWEYT34M.mjs} +4 -4
- package/dist/cli/{search-output-I4RZPHU6.js → search-output-XAMWKRJH.js} +6 -6
- package/dist/cli/{secrets-MJMNRXZX.js → secrets-2IRRRZBL.js} +17 -17
- package/dist/cli/{secrets-DQI5YCS6.mjs → secrets-YTI4IAKR.mjs} +8 -8
- package/dist/cli/{sessions-HAUN3VYE.mjs → sessions-EFS4KUPF.mjs} +5 -5
- package/dist/cli/{sessions-QS74ZTRH.js → sessions-HWTRDXBQ.js} +6 -6
- package/dist/cli/{settings-VQBOS6VU.js → settings-FRVEIOKR.js} +80 -80
- package/dist/cli/{settings-E64HIUXW.mjs → settings-NTOO42DY.mjs} +13 -13
- package/dist/cli/{setup-KRW3JCJE.js → setup-6ZIOAE2V.js} +49 -49
- package/dist/cli/{setup-NRUG42F2.mjs → setup-PAVQPALX.mjs} +9 -9
- package/dist/cli/{skills-AHLZRTKZ.mjs → skills-3O3XTPUM.mjs} +7 -7
- package/dist/cli/skills-6ZNMO2PR.js +36 -0
- package/dist/cli/{tools-INRRIWOU.mjs → tools-7QSB65UL.mjs} +18 -18
- package/dist/cli/tools-DPV2JES6.js +57 -0
- package/dist/cli/update-Q5GUDEAW.js +34 -0
- package/dist/cli/{update-ETOWEJ7D.mjs → update-T6CYS5ZT.mjs} +9 -9
- package/dist/cli/{workflow-RUAYQK4D.js → workflow-4KMJBMGX.js} +19 -19
- package/dist/cli/{workflow-JT2DOSCJ.mjs → workflow-OMSXZ73T.mjs} +9 -9
- package/dist/{client-Cj3UqrCZ.d.ts → client-Bn8FwKGO.d.ts} +1 -1
- package/dist/{client-DSCTVVRj.d.mts → client-CfNRmjLK.d.mts} +1 -1
- package/dist/{client-core-dI4KTuWS.d.ts → client-core-B91EV0WS.d.ts} +19 -0
- package/dist/{client-core-B-8DTIN1.d.mts → client-core-BG8Cgrmk.d.mts} +19 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +19 -19
- package/dist/index.mjs +8 -8
- package/dist/install-integrity.json +114 -108
- package/dist/plays/play-description.d.mts +1 -1
- package/dist/plays/play-description.d.ts +1 -1
- package/dist/plays/run-request.d.mts +1 -1
- package/dist/plays/run-request.d.ts +1 -1
- package/dist/plays/run-request.js +3 -3
- package/dist/plays/run-request.mjs +2 -2
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +7 -7
- package/dist/server.mjs +5 -5
- package/package.json +1 -1
- package/dist/cli/auth-32FRISRT.js +0 -43
- package/dist/cli/describe-DEXYQMBO.js +0 -50
- package/dist/cli/git-RDKLITUC.js +0 -25
- package/dist/cli/run-identity-G257GQED.js +0 -25
- package/dist/cli/search-YKTYDBCN.js +0 -32
- package/dist/cli/skills-PGVIJK6Q.js +0 -36
- package/dist/cli/tools-IXXN2RE4.js +0 -57
- package/dist/cli/update-QW4RV2UX.js +0 -34
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { resolveRuntimeAppTransport } from '../runtime-app-transport';
|
|
1
2
|
import {
|
|
2
3
|
terminalRuntimePerformanceFromStats,
|
|
3
4
|
normalizeTerminalRuntimePerformance,
|
|
4
5
|
normalizeTerminalRuntimePerformanceUnavailableReason,
|
|
5
6
|
} from '../terminal-runtime-performance';
|
|
6
7
|
import { escapeLiteral } from 'pg';
|
|
8
|
+
import { readRuntimeGatewayLaunchPin } from '../runtime-gateway-profile';
|
|
9
|
+
import { RUNTIME_GATEWAY_OIDC_MAX_AGE_SECONDS } from '../runtime-gateway-oidc';
|
|
10
|
+
import { runtimeGatewayCredentialScopeFromPin } from '../runtime-gateway-sandbox-credential';
|
|
11
|
+
import { ensureRuntimeGatewayStagingSchema } from './runtime-gateway-staging-journal';
|
|
7
12
|
import { assertWorkReceiptKeyMutable } from '../work-receipt-storage-contract';
|
|
8
13
|
import {
|
|
9
14
|
schedulerWorkReceiptClaimTransition,
|
|
@@ -2412,6 +2417,8 @@ export async function ensurePostgresSchedulerOnlineAdditiveExpansion(
|
|
|
2412
2417
|
client,
|
|
2413
2418
|
options,
|
|
2414
2419
|
);
|
|
2420
|
+
// A separate table that no shape check, marker, or admission path reads.
|
|
2421
|
+
await ensureRuntimeGatewayStagingSchema(client, { schema });
|
|
2415
2422
|
}
|
|
2416
2423
|
|
|
2417
2424
|
/** Deployment-owned v64 expansion; absent values retain legacy behavior. */
|
|
@@ -3591,6 +3598,9 @@ export async function ensurePostgresSchedulerSchema(
|
|
|
3591
3598
|
// not prove that every receipt/execution gateway can decode canonical IO
|
|
3592
3599
|
// rows. Convex owns the source record; this is its local gateway mirror.
|
|
3593
3600
|
await ensurePostgresSchedulerGatewayReaderFenceSchema(client, options);
|
|
3601
|
+
// App-hosted gateway staged-body custody. Not part of the scheduler
|
|
3602
|
+
// shape: readiness and admission never read it.
|
|
3603
|
+
await ensureRuntimeGatewayStagingSchema(client, { schema });
|
|
3594
3604
|
await client.query(`
|
|
3595
3605
|
CREATE INDEX IF NOT EXISTS ${quoteIdent(
|
|
3596
3606
|
`${schema}_integration_invocation_state_updated_idx`,
|
|
@@ -9921,6 +9931,13 @@ const POSTGRES_SCHEDULER_ATTEMPT_AUTHORITY_FIELDS = [
|
|
|
9921
9931
|
'runtimeTokenOrigin',
|
|
9922
9932
|
'runtimeBackend',
|
|
9923
9933
|
'runtimeAuthority',
|
|
9934
|
+
// Optional Runtime gateway pin; null on unpinned launches. The executor-token
|
|
9935
|
+
// issuer reads it to require the reader flag and add the pinned claims.
|
|
9936
|
+
'runtimeGatewayProfileId',
|
|
9937
|
+
'runtimeReceiptGatewayBaseUrl',
|
|
9938
|
+
'runtimeExecutionGatewayBaseUrl',
|
|
9939
|
+
'runtimeGatewayDeploymentId',
|
|
9940
|
+
'runtimeGatewayPinnedAtMs',
|
|
9924
9941
|
] as const;
|
|
9925
9942
|
|
|
9926
9943
|
export type PostgresSchedulerAttemptAuthority = Pick<
|
|
@@ -9999,6 +10016,120 @@ export async function readPostgresSchedulerAttemptAuthorityForLease(
|
|
|
9999
10016
|
return parsePostgresSchedulerAuthorityRow(result.rows[0]);
|
|
10000
10017
|
}
|
|
10001
10018
|
|
|
10019
|
+
/**
|
|
10020
|
+
* Why a renewal fence refused. Only `attempt_not_live` can clear by itself
|
|
10021
|
+
* (a stale heartbeat while the runner catches up after a network cut); every
|
|
10022
|
+
* other reason is definitive and the sandbox stops at once.
|
|
10023
|
+
*/
|
|
10024
|
+
export type RuntimeGatewayOidcRenewalRefusal =
|
|
10025
|
+
| 'attempt_not_found'
|
|
10026
|
+
| 'lease_mismatch'
|
|
10027
|
+
| 'scope_mismatch'
|
|
10028
|
+
| 'attempt_cancelled'
|
|
10029
|
+
| 'attempt_superseded'
|
|
10030
|
+
| 'attempt_not_live';
|
|
10031
|
+
|
|
10032
|
+
export type RuntimeGatewayOidcRenewalFence =
|
|
10033
|
+
| { allowed: true }
|
|
10034
|
+
| { allowed: false; reason: RuntimeGatewayOidcRenewalRefusal };
|
|
10035
|
+
|
|
10036
|
+
/**
|
|
10037
|
+
* Renewal fence for a sandbox's Runtime gateway OIDC credential. A sandbox may
|
|
10038
|
+
* renew only while its exact attempt still holds the live lease of a run
|
|
10039
|
+
* pinned to `deploymentId`: the attempt is current (no successor) and no
|
|
10040
|
+
* cancellation is recorded. Liveness is then proven per phase:
|
|
10041
|
+
*
|
|
10042
|
+
* - Detached: the run's `detached_runner` suspension names this attempt, the
|
|
10043
|
+
* detached wait has not passed its deadline, and the runner heartbeat is
|
|
10044
|
+
* fresh.
|
|
10045
|
+
* - Starting (before the worker persists the detach): the run is `running`
|
|
10046
|
+
* with no suspension, and the attempt's claim or runner heartbeat is younger
|
|
10047
|
+
* than one credential lifetime. The worker minted the first credential when
|
|
10048
|
+
* it claimed the attempt, so sandbox create and upload may outlast the
|
|
10049
|
+
* renewal threshold; a start that outlives a whole credential lifetime has
|
|
10050
|
+
* no live credential left to renew.
|
|
10051
|
+
*
|
|
10052
|
+
* A refusal names its reason, checked in this order: no such attempt, wrong
|
|
10053
|
+
* lease, wrong org or deployment (including an unpinned run), cancelled,
|
|
10054
|
+
* superseded, and otherwise not live. One statement reads all of them.
|
|
10055
|
+
*/
|
|
10056
|
+
export async function canRenewPostgresDetachedRunnerIdentity(
|
|
10057
|
+
client: PostgresSchedulerQueryClient,
|
|
10058
|
+
input: {
|
|
10059
|
+
runId: string;
|
|
10060
|
+
attempt: number;
|
|
10061
|
+
leaseToken: string;
|
|
10062
|
+
orgId: string;
|
|
10063
|
+
deploymentId: string;
|
|
10064
|
+
},
|
|
10065
|
+
options?: Pick<PostgresSchedulerOptions, 'schema'>,
|
|
10066
|
+
): Promise<RuntimeGatewayOidcRenewalFence> {
|
|
10067
|
+
const result = await client.query<{
|
|
10068
|
+
lease_matches: boolean;
|
|
10069
|
+
scope_matches: boolean;
|
|
10070
|
+
cancelled: boolean;
|
|
10071
|
+
superseded: boolean;
|
|
10072
|
+
live: boolean;
|
|
10073
|
+
}>(
|
|
10074
|
+
`
|
|
10075
|
+
SELECT
|
|
10076
|
+
coalesce(attempt.lease_token = $3, false) AS lease_matches,
|
|
10077
|
+
coalesce(
|
|
10078
|
+
run.org_id = $4
|
|
10079
|
+
AND coalesce(run.admission_json, run.launch_json)->>'runtimeGatewayDeploymentId' = $5,
|
|
10080
|
+
false
|
|
10081
|
+
) AS scope_matches,
|
|
10082
|
+
(
|
|
10083
|
+
run.status = 'cancelled'
|
|
10084
|
+
OR EXISTS (
|
|
10085
|
+
SELECT 1 FROM ${tableName('control', options)} AS cancellation
|
|
10086
|
+
WHERE cancellation.key = 'runtime_cancel:' || $1
|
|
10087
|
+
)
|
|
10088
|
+
) AS cancelled,
|
|
10089
|
+
EXISTS (
|
|
10090
|
+
SELECT 1 FROM ${tableName('attempts', options)} AS successor
|
|
10091
|
+
WHERE successor.run_id = attempt.run_id AND successor.attempt > attempt.attempt
|
|
10092
|
+
) AS superseded,
|
|
10093
|
+
coalesce(
|
|
10094
|
+
(
|
|
10095
|
+
run.status IN ('running', 'waiting')
|
|
10096
|
+
AND attempt.status IN ('running', 'waiting')
|
|
10097
|
+
AND run.suspension_json->>'kind' = 'detached_runner'
|
|
10098
|
+
AND run.suspension_json->'runnerAttempt' = to_jsonb($2::integer)
|
|
10099
|
+
AND run.wait_deadline > clock_timestamp()
|
|
10100
|
+
AND attempt.heartbeat_at > clock_timestamp() - interval '120 seconds'
|
|
10101
|
+
)
|
|
10102
|
+
OR (
|
|
10103
|
+
run.status = 'running'
|
|
10104
|
+
AND attempt.status IN ('claimed', 'running')
|
|
10105
|
+
AND (run.suspension_json IS NULL OR jsonb_typeof(run.suspension_json) = 'null')
|
|
10106
|
+
AND attempt.heartbeat_at > clock_timestamp() - make_interval(secs => $6::integer)
|
|
10107
|
+
),
|
|
10108
|
+
false
|
|
10109
|
+
) AS live
|
|
10110
|
+
FROM ${tableName('runs', options)} AS run
|
|
10111
|
+
JOIN ${tableName('attempts', options)} AS attempt USING (run_id)
|
|
10112
|
+
WHERE run.run_id = $1 AND attempt.attempt = $2
|
|
10113
|
+
`,
|
|
10114
|
+
[
|
|
10115
|
+
input.runId,
|
|
10116
|
+
input.attempt,
|
|
10117
|
+
input.leaseToken,
|
|
10118
|
+
input.orgId,
|
|
10119
|
+
input.deploymentId,
|
|
10120
|
+
RUNTIME_GATEWAY_OIDC_MAX_AGE_SECONDS,
|
|
10121
|
+
],
|
|
10122
|
+
);
|
|
10123
|
+
const row = result.rows[0];
|
|
10124
|
+
if (!row) return { allowed: false, reason: 'attempt_not_found' };
|
|
10125
|
+
if (!row.lease_matches) return { allowed: false, reason: 'lease_mismatch' };
|
|
10126
|
+
if (!row.scope_matches) return { allowed: false, reason: 'scope_mismatch' };
|
|
10127
|
+
if (row.cancelled) return { allowed: false, reason: 'attempt_cancelled' };
|
|
10128
|
+
if (row.superseded) return { allowed: false, reason: 'attempt_superseded' };
|
|
10129
|
+
if (!row.live) return { allowed: false, reason: 'attempt_not_live' };
|
|
10130
|
+
return { allowed: true };
|
|
10131
|
+
}
|
|
10132
|
+
|
|
10002
10133
|
/**
|
|
10003
10134
|
* Absurd scheduler backend: persist the vendored engine's task id on the run
|
|
10004
10135
|
* row after `spawn`. Idempotent (last write wins); a re-submit under the same
|
|
@@ -16241,13 +16372,7 @@ export async function finalizePostgresSchedulerComputeBilling(
|
|
|
16241
16372
|
runtimeResources: readonly unknown[],
|
|
16242
16373
|
runtimeApiOverride?: WorkerRuntimeApiContext,
|
|
16243
16374
|
): Promise<void> {
|
|
16244
|
-
const runtimeApi =
|
|
16245
|
-
runtimeApiOverride ??
|
|
16246
|
-
({
|
|
16247
|
-
baseUrl: runtimeApiBaseUrlFromLaunch(launch),
|
|
16248
|
-
executorToken: launch.executorToken,
|
|
16249
|
-
vercelProtectionBypassToken: launch.vercelProtectionBypassToken ?? null,
|
|
16250
|
-
} satisfies WorkerRuntimeApiContext);
|
|
16375
|
+
const runtimeApi = runtimeApiOverride ?? absurdDirectRuntimeApi(launch);
|
|
16251
16376
|
const ordinaryResources = runtimeResources.filter(
|
|
16252
16377
|
(resource) =>
|
|
16253
16378
|
!(
|
|
@@ -17160,11 +17285,16 @@ export function buildPostgresSchedulerRunnerContext(
|
|
|
17160
17285
|
launch.vercelProtectionBypassToken?.trim() ||
|
|
17161
17286
|
process.env.VERCEL_PROTECTION_BYPASS_TOKEN?.trim() ||
|
|
17162
17287
|
null;
|
|
17163
|
-
|
|
17164
|
-
|
|
17165
|
-
const
|
|
17166
|
-
|
|
17167
|
-
receiptGatewayBaseUrl
|
|
17288
|
+
// A pinned launch names its gateways; it never falls back to this worker's
|
|
17289
|
+
// configured Fly gateways. Partial or unknown pins throw here.
|
|
17290
|
+
const gatewayPin = readRuntimeGatewayLaunchPin(launch);
|
|
17291
|
+
const receiptGatewayBaseUrl = gatewayPin
|
|
17292
|
+
? gatewayPin.receiptGatewayBaseUrl
|
|
17293
|
+
: process.env.DEEPLINE_RUNTIME_RECEIPT_GATEWAY_URL?.trim() || null;
|
|
17294
|
+
const executionGatewayBaseUrl = gatewayPin
|
|
17295
|
+
? gatewayPin.executionGatewayBaseUrl
|
|
17296
|
+
: process.env.DEEPLINE_RUNTIME_EXECUTION_GATEWAY_URL?.trim() ||
|
|
17297
|
+
receiptGatewayBaseUrl;
|
|
17168
17298
|
const asyncAncestryPlayIds = launch.asyncAncestryPlayIds?.map((playId) =>
|
|
17169
17299
|
playId.trim(),
|
|
17170
17300
|
);
|
|
@@ -17186,6 +17316,14 @@ export function buildPostgresSchedulerRunnerContext(
|
|
|
17186
17316
|
baseUrl: runtimeApiBaseUrlFromLaunch(launch),
|
|
17187
17317
|
executionGatewayBaseUrl,
|
|
17188
17318
|
receiptGatewayBaseUrl,
|
|
17319
|
+
...(gatewayPin
|
|
17320
|
+
? {
|
|
17321
|
+
runtimeGatewayProfileId: gatewayPin.profile.id,
|
|
17322
|
+
runtimeGatewayDeploymentId: gatewayPin.deploymentId,
|
|
17323
|
+
runtimeGatewayCredentialScope:
|
|
17324
|
+
runtimeGatewayCredentialScopeFromPin(gatewayPin),
|
|
17325
|
+
}
|
|
17326
|
+
: {}),
|
|
17189
17327
|
vercelProtectionBypassToken,
|
|
17190
17328
|
runtimeTestFaultHeader: launch.runtimeTestFaultHeader ?? null,
|
|
17191
17329
|
preferredReceiptGatewayMachineId:
|
|
@@ -19346,10 +19484,26 @@ export async function loadPostgresSchedulerStoredArtifact(
|
|
|
19346
19484
|
function runtimeApiContextFromLaunch(
|
|
19347
19485
|
launch: PlaySchedulerSubmitInput,
|
|
19348
19486
|
): WorkerRuntimeApiContext {
|
|
19487
|
+
return absurdDirectRuntimeApi(launch);
|
|
19488
|
+
}
|
|
19489
|
+
|
|
19490
|
+
/**
|
|
19491
|
+
* The launch's primary token on the owner's direct transport: the app at the
|
|
19492
|
+
* launch's runtime API origin. A gateway-pinned token is refused loudly here
|
|
19493
|
+
* (`runtime_gateway_transport_unpinned`) instead of drawing a 403.
|
|
19494
|
+
*/
|
|
19495
|
+
function absurdDirectRuntimeApi(
|
|
19496
|
+
launch: PlaySchedulerSubmitInput,
|
|
19497
|
+
): WorkerRuntimeApiContext {
|
|
19498
|
+
const transport = resolveRuntimeAppTransport({
|
|
19499
|
+
caller: 'direct',
|
|
19500
|
+
launch,
|
|
19501
|
+
executorToken: launch.executorToken,
|
|
19502
|
+
});
|
|
19349
19503
|
return {
|
|
19350
|
-
baseUrl:
|
|
19504
|
+
baseUrl: transport.baseUrl,
|
|
19351
19505
|
executorToken: launch.executorToken,
|
|
19352
|
-
vercelProtectionBypassToken:
|
|
19506
|
+
vercelProtectionBypassToken: transport.vercelProtectionBypassToken,
|
|
19353
19507
|
};
|
|
19354
19508
|
}
|
|
19355
19509
|
|
|
@@ -26421,9 +26575,15 @@ export async function requestComputeBillingDispatchToken(input: {
|
|
|
26421
26575
|
'Compute-billing recovery requires a valid dispatch lease and DEEPLINE_INTERNAL_TOKEN.',
|
|
26422
26576
|
);
|
|
26423
26577
|
}
|
|
26424
|
-
|
|
26578
|
+
// Signed with the internal token, which is never pinned.
|
|
26579
|
+
const appBaseUrl = resolveRuntimeAppTransport({
|
|
26580
|
+
caller: 'direct',
|
|
26581
|
+
launch: input.launch,
|
|
26582
|
+
executorToken: internalToken,
|
|
26583
|
+
}).baseUrl;
|
|
26584
|
+
const url = `${appBaseUrl.replace(/\/$/, '')}/api/v2/internal/play-runtime/compute-billing-dispatch-token`;
|
|
26425
26585
|
const vercelProtectionHeaders = await vercelProtectionBypassHeaders({
|
|
26426
|
-
baseUrl:
|
|
26586
|
+
baseUrl: appBaseUrl,
|
|
26427
26587
|
token: input.launch.vercelProtectionBypassToken,
|
|
26428
26588
|
});
|
|
26429
26589
|
const response = await fetch(url, {
|
package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-attempt.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mintRuntimeGatewayAttemptOidcToken,
|
|
3
|
+
readExecutorTokenClaimsUnverified,
|
|
4
|
+
} from '../runtime-app-transport';
|
|
5
|
+
import {
|
|
6
|
+
assertRuntimeGatewayPinFresh,
|
|
7
|
+
readRuntimeGatewayLaunchPin,
|
|
8
|
+
RuntimeGatewayLaunchError,
|
|
9
|
+
type RuntimeGatewayLaunchFields,
|
|
10
|
+
type RuntimeGatewayLaunchPin,
|
|
11
|
+
} from '../runtime-gateway-profile';
|
|
12
|
+
import type { RuntimeGatewayOidcSigningKey } from '../runtime-gateway-oidc';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Worker-side checks for a pinned launch. Every function is a no-op (null)
|
|
16
|
+
* for unpinned launches, so the default path is unchanged.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Attempt start / resume: refuse an expired or unreadable pin loudly. */
|
|
20
|
+
export function assertRuntimeGatewayAttemptStartable(
|
|
21
|
+
launch: RuntimeGatewayLaunchFields,
|
|
22
|
+
nowMs: number,
|
|
23
|
+
): RuntimeGatewayLaunchPin | null {
|
|
24
|
+
const pin = readRuntimeGatewayLaunchPin(launch);
|
|
25
|
+
if (pin) assertRuntimeGatewayPinFresh(pin, nowMs);
|
|
26
|
+
return pin;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The app minted the primary executor token. For a pinned launch it must
|
|
31
|
+
* carry `runtime_gateway_deployment_id` equal to the pin; an older app that
|
|
32
|
+
* ignored the pin would otherwise hand the sandbox a token the pinned gateway
|
|
33
|
+
* refuses, or quietly route the run elsewhere. The signature is verified by
|
|
34
|
+
* the gateway on use; here only the claim's presence and value are checked.
|
|
35
|
+
*/
|
|
36
|
+
export function assertExecutorTokenCarriesRuntimeGatewayPin(
|
|
37
|
+
executorToken: string,
|
|
38
|
+
pin: RuntimeGatewayLaunchPin,
|
|
39
|
+
): void {
|
|
40
|
+
const claims = readExecutorTokenClaimsUnverified(executorToken);
|
|
41
|
+
if (
|
|
42
|
+
claims?.runtime_gateway_deployment_id !== pin.deploymentId ||
|
|
43
|
+
claims?.runtime_gateway_profile !== pin.profile.id
|
|
44
|
+
) {
|
|
45
|
+
throw new RuntimeGatewayLaunchError(
|
|
46
|
+
'runtime_gateway_executor_token_unpinned',
|
|
47
|
+
`The executor token for a launch pinned to ${pin.deploymentId} (${pin.profile.id}) does not carry the matching runtime gateway claims; the issuing app does not support Runtime gateway profiles.`,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The runner config a sandbox launch receives. Unpinned launches return the
|
|
54
|
+
* same object. Pinned launches re-check pin age and carry a fresh credential.
|
|
55
|
+
*/
|
|
56
|
+
export function withRuntimeGatewayAttemptCredential<
|
|
57
|
+
T extends { context: { runtimeGatewayOidcToken?: string | null } },
|
|
58
|
+
>(input: {
|
|
59
|
+
config: T;
|
|
60
|
+
launch: RuntimeGatewayLaunchFields;
|
|
61
|
+
runId: string;
|
|
62
|
+
attempt: number;
|
|
63
|
+
nowMs: number;
|
|
64
|
+
signingKey: () => RuntimeGatewayOidcSigningKey | null;
|
|
65
|
+
}): T {
|
|
66
|
+
const pin = assertRuntimeGatewayAttemptStartable(input.launch, input.nowMs);
|
|
67
|
+
if (!pin) return input.config;
|
|
68
|
+
return {
|
|
69
|
+
...input.config,
|
|
70
|
+
context: {
|
|
71
|
+
...input.config.context,
|
|
72
|
+
runtimeGatewayOidcToken: mintRuntimeGatewayAttemptOidcToken({
|
|
73
|
+
pin,
|
|
74
|
+
runId: input.runId,
|
|
75
|
+
attempt: input.attempt,
|
|
76
|
+
nowMs: input.nowMs,
|
|
77
|
+
signingKey: input.signingKey(),
|
|
78
|
+
}),
|
|
79
|
+
},
|
|
80
|
+
} as T;
|
|
81
|
+
}
|