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.
Files changed (178) hide show
  1. package/dist/bundling-sources/sdk/src/plays/client-core.ts +45 -7
  2. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  3. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +36 -0
  4. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +155 -0
  5. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +7 -1
  6. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +2 -1
  7. package/dist/bundling-sources/shared_libs/play-runtime/durable-invocation-fence.ts +3 -1
  8. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +54 -1
  9. package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +12 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +13 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +56 -0
  12. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +21 -10
  13. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +1 -1
  14. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-progress-push.ts +1 -2
  15. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +1 -1
  16. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +9 -2
  17. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +31 -1
  18. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +74 -3
  19. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +226 -2
  20. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +41 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +5 -1
  22. package/dist/bundling-sources/shared_libs/play-runtime/runtime-app-transport.ts +374 -0
  23. package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +5 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/runtime-environment.ts +49 -9
  25. package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-oidc.ts +25 -3
  26. package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-profile.ts +12 -1
  27. package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-sandbox-credential.ts +338 -0
  28. package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-staging.ts +417 -0
  29. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +15 -0
  30. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +184 -11
  31. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +17 -3
  32. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-progress-registry.ts +9 -0
  33. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +18 -2
  34. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +176 -16
  35. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-attempt.ts +81 -0
  36. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-staging-journal.ts +708 -0
  37. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-staging-teardown.ts +160 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +4 -0
  39. package/dist/cli/{auth-TECJ27G3.mjs → auth-6ECHXOI4.mjs} +5 -5
  40. package/dist/cli/auth-VP7PMXKQ.js +43 -0
  41. package/dist/cli/{billing-PMKO73VG.mjs → billing-75NZYRXA.mjs} +8 -8
  42. package/dist/cli/{billing-ULZGAED6.js → billing-QRR7O6BD.js} +81 -81
  43. package/dist/cli/{chunk-K54BUQSK.js → chunk-463ZOO2L.js} +7 -7
  44. package/dist/cli/{chunk-L6C7C7IJ.js → chunk-4OXHLTCP.js} +1 -1
  45. package/dist/cli/{chunk-3GP52OHV.mjs → chunk-5S7MLAI7.mjs} +11 -11
  46. package/dist/cli/{chunk-7OQZZHZ4.js → chunk-5X4AUFYW.js} +7 -7
  47. package/dist/cli/{chunk-56JE475N.mjs → chunk-66XDYH5T.mjs} +2 -2
  48. package/dist/cli/{chunk-A2VCFBZN.mjs → chunk-7L6QNHUL.mjs} +1 -1
  49. package/dist/cli/{chunk-UOQUCFAK.js → chunk-APAHMCGR.js} +53 -53
  50. package/dist/cli/{chunk-UBKA33KY.mjs → chunk-BMCRTI6Z.mjs} +22 -1
  51. package/dist/cli/{chunk-WSOM3TY6.js → chunk-BOFCF4L7.js} +3 -3
  52. package/dist/cli/{chunk-SLWCXGKP.js → chunk-CJJ7JBM2.js} +16 -16
  53. package/dist/cli/{chunk-JM52ATUS.mjs → chunk-EHVFBD36.mjs} +1 -1
  54. package/dist/cli/{chunk-7WUMIRBV.js → chunk-EKF4DKUA.js} +5 -5
  55. package/dist/cli/{chunk-AGZRRHSB.js → chunk-EKZQ5LQO.js} +3 -3
  56. package/dist/cli/{chunk-5IDORX4E.mjs → chunk-EOO7OSS4.mjs} +4 -4
  57. package/dist/cli/{chunk-2PKZ3RUU.js → chunk-FS7XYDOF.js} +16 -16
  58. package/dist/cli/{chunk-Z2MO7FZG.js → chunk-HDKXSHGA.js} +53 -53
  59. package/dist/cli/{chunk-YRQWGWRJ.js → chunk-J6SVNKRP.js} +2 -2
  60. package/dist/cli/{chunk-QXI2W7YY.mjs → chunk-J74N375S.mjs} +4 -4
  61. package/dist/cli/{chunk-KLQ5CR77.js → chunk-KTOAJP4N.js} +6 -6
  62. package/dist/cli/{chunk-ZVAD65CF.mjs → chunk-MADTHS56.mjs} +1 -1
  63. package/dist/cli/{chunk-UMPCQ4EE.mjs → chunk-MSLXAVVK.mjs} +2 -2
  64. package/dist/cli/{chunk-JIZHGOZ5.js → chunk-N2TJJNCW.js} +96 -96
  65. package/dist/cli/{chunk-CS2AEAD6.mjs → chunk-N4TR6QRI.mjs} +1 -1
  66. package/dist/cli/{chunk-43ZERPGR.mjs → chunk-NA3J3F2Z.mjs} +1 -1
  67. package/dist/cli/{chunk-JQHJKARU.mjs → chunk-O3DDVP7Z.mjs} +1 -1
  68. package/dist/cli/{chunk-JUQESEJX.mjs → chunk-OKOXB3LY.mjs} +2 -2
  69. package/dist/cli/{chunk-FG5OZ5FB.js → chunk-PNF2ZU4R.js} +8 -8
  70. package/dist/cli/{chunk-KZJKRU24.mjs → chunk-PXIF74UJ.mjs} +4 -4
  71. package/dist/cli/{chunk-TUDYBF4Y.js → chunk-QQ3JJYE2.js} +14 -14
  72. package/dist/cli/{chunk-IGCSKXGK.mjs → chunk-RFV7PPLS.mjs} +3 -3
  73. package/dist/cli/{chunk-EQR5O2D2.js → chunk-RNSHCJME.js} +3 -3
  74. package/dist/cli/{chunk-PE3UHMMZ.js → chunk-RU5ROUFO.js} +5 -5
  75. package/dist/cli/{chunk-2RZHMCDL.js → chunk-SV2TEZ2M.js} +4 -4
  76. package/dist/cli/{chunk-P3MGNLZF.mjs → chunk-T4U245E4.mjs} +2 -2
  77. package/dist/cli/{chunk-7UC2UZYW.mjs → chunk-T7E3XEPG.mjs} +6 -6
  78. package/dist/cli/{chunk-LUNXREUI.js → chunk-TOE7LHEA.js} +6 -6
  79. package/dist/cli/{chunk-OWHQ4OG5.mjs → chunk-UJRN6YP6.mjs} +3 -3
  80. package/dist/cli/{chunk-XSUQAUG4.js → chunk-UR7JOSLT.js} +360 -300
  81. package/dist/cli/{chunk-KOD45UP5.mjs → chunk-V5NHEYU7.mjs} +5 -5
  82. package/dist/cli/{chunk-PSYGSXDS.mjs → chunk-VD2374K7.mjs} +1 -1
  83. package/dist/cli/{chunk-57LW4TGY.js → chunk-VL72UKNW.js} +26 -26
  84. package/dist/cli/{chunk-YAW7ET4P.mjs → chunk-VTDAJZIJ.mjs} +90 -30
  85. package/dist/cli/{chunk-AKLI4XSG.js → chunk-VVEMPC2I.js} +2 -2
  86. package/dist/cli/{chunk-L7O7AFSF.js → chunk-W6JTHVPF.js} +21 -21
  87. package/dist/cli/{chunk-MQ5YPD7K.mjs → chunk-WJUDAHIQ.mjs} +1 -1
  88. package/dist/cli/{chunk-XDVT3GOM.js → chunk-WSGXBROE.js} +22 -1
  89. package/dist/cli/{chunk-G7BB2VOC.js → chunk-XEBFJ2PH.js} +41 -41
  90. package/dist/cli/{chunk-WEVIUQGZ.mjs → chunk-Z6AUOV7D.mjs} +2 -2
  91. package/dist/cli/{chunk-BBFWIYAF.mjs → chunk-ZUOKIBLJ.mjs} +2 -2
  92. package/dist/cli/{chunk-C2V5U6HO.mjs → chunk-ZUQHQGC5.mjs} +5 -5
  93. package/dist/cli/{csv-VGSQ3JYE.js → csv-JXX2LXK5.js} +13 -13
  94. package/dist/cli/{csv-ACO5YC46.mjs → csv-RZJ4SOIL.mjs} +4 -4
  95. package/dist/cli/{db-CXNZOXGM.mjs → db-MUTT2NWI.mjs} +8 -8
  96. package/dist/cli/{db-QOUPHFFN.js → db-T2KJNONM.js} +29 -29
  97. package/dist/cli/{describe-J4O5GCJS.mjs → describe-K3UMAAVO.mjs} +19 -19
  98. package/dist/cli/describe-SEXUJLE4.js +50 -0
  99. package/dist/cli/describe-core.d.mts +2 -2
  100. package/dist/cli/describe-core.d.ts +2 -2
  101. package/dist/cli/{executions-YIECH2CL.js → executions-7HSLDRHR.js} +10 -10
  102. package/dist/cli/{executions-SJETRLXW.mjs → executions-PHS4R2OX.mjs} +8 -8
  103. package/dist/cli/{feedback-5BRCNERV.js → feedback-BJZRM637.js} +8 -8
  104. package/dist/cli/{feedback-GSAFFMF6.mjs → feedback-RWMDCIDF.mjs} +4 -4
  105. package/dist/cli/git-VNS7UQWN.js +25 -0
  106. package/dist/cli/{git-SF5XIGLU.mjs → git-YW6VHYZG.mjs} +5 -5
  107. package/dist/cli/index.js +137 -137
  108. package/dist/cli/index.mjs +40 -40
  109. package/dist/cli/{legacy-noops-5TBT4XC6.js → legacy-noops-2WUV2XD7.js} +8 -8
  110. package/dist/cli/{legacy-noops-TZA3CALE.mjs → legacy-noops-5UBSUPGG.mjs} +5 -5
  111. package/dist/cli/{monitors-XAYWJNSV.mjs → monitors-HWOQO3OK.mjs} +9 -9
  112. package/dist/cli/{monitors-XNB5YNC3.js → monitors-YZZRKSTG.js} +97 -97
  113. package/dist/cli/{org-2UYWJXG7.js → org-JY7HLHBA.js} +74 -74
  114. package/dist/cli/{org-S5VZL5KZ.mjs → org-NCXT6RB4.mjs} +8 -8
  115. package/dist/cli/{pages-ZQRRTZIT.js → pages-6ZOHXL6X.js} +20 -20
  116. package/dist/cli/{pages-NGVJO7PA.mjs → pages-QJO53QAT.mjs} +8 -8
  117. package/dist/cli/{play-3JNERHSC.mjs → play-SQRS7JN3.mjs} +20 -20
  118. package/dist/cli/{play-P3OYQ7JV.js → play-TAYGSR35.js} +336 -336
  119. package/dist/cli/{providers-27O6BOAP.mjs → providers-3IR3N5DT.mjs} +8 -8
  120. package/dist/cli/{providers-2FFGAPUR.js → providers-4Q5LOIQ5.js} +11 -11
  121. package/dist/cli/{quickstart-5G2UPKJV.js → quickstart-ITNUZENY.js} +6 -6
  122. package/dist/cli/{quickstart-B2EXIAU6.mjs → quickstart-KCZCYO6B.mjs} +4 -4
  123. package/dist/cli/{run-3QFXYV3Z.mjs → run-JCWRWDSK.mjs} +24 -24
  124. package/dist/cli/{run-2TGD7FAL.js → run-YQ57LMKN.js} +42 -42
  125. package/dist/cli/run-identity-HFYABUJS.js +31 -0
  126. package/dist/cli/{run-identity-MRNCEGV2.mjs → run-identity-MNRZS2N3.mjs} +9 -3
  127. package/dist/cli/{search-GXEEOMVD.mjs → search-FUM27HQP.mjs} +9 -9
  128. package/dist/cli/search-I425FRTK.js +32 -0
  129. package/dist/cli/{search-output-DMIJQTAA.mjs → search-output-EWEYT34M.mjs} +4 -4
  130. package/dist/cli/{search-output-I4RZPHU6.js → search-output-XAMWKRJH.js} +6 -6
  131. package/dist/cli/{secrets-MJMNRXZX.js → secrets-2IRRRZBL.js} +17 -17
  132. package/dist/cli/{secrets-DQI5YCS6.mjs → secrets-YTI4IAKR.mjs} +8 -8
  133. package/dist/cli/{sessions-HAUN3VYE.mjs → sessions-EFS4KUPF.mjs} +5 -5
  134. package/dist/cli/{sessions-QS74ZTRH.js → sessions-HWTRDXBQ.js} +6 -6
  135. package/dist/cli/{settings-VQBOS6VU.js → settings-FRVEIOKR.js} +80 -80
  136. package/dist/cli/{settings-E64HIUXW.mjs → settings-NTOO42DY.mjs} +13 -13
  137. package/dist/cli/{setup-KRW3JCJE.js → setup-6ZIOAE2V.js} +49 -49
  138. package/dist/cli/{setup-NRUG42F2.mjs → setup-PAVQPALX.mjs} +9 -9
  139. package/dist/cli/{skills-AHLZRTKZ.mjs → skills-3O3XTPUM.mjs} +7 -7
  140. package/dist/cli/skills-6ZNMO2PR.js +36 -0
  141. package/dist/cli/{tools-INRRIWOU.mjs → tools-7QSB65UL.mjs} +18 -18
  142. package/dist/cli/tools-DPV2JES6.js +57 -0
  143. package/dist/cli/update-Q5GUDEAW.js +34 -0
  144. package/dist/cli/{update-ETOWEJ7D.mjs → update-T6CYS5ZT.mjs} +9 -9
  145. package/dist/cli/{workflow-RUAYQK4D.js → workflow-4KMJBMGX.js} +19 -19
  146. package/dist/cli/{workflow-JT2DOSCJ.mjs → workflow-OMSXZ73T.mjs} +9 -9
  147. package/dist/{client-Cj3UqrCZ.d.ts → client-Bn8FwKGO.d.ts} +1 -1
  148. package/dist/{client-DSCTVVRj.d.mts → client-CfNRmjLK.d.mts} +1 -1
  149. package/dist/{client-core-dI4KTuWS.d.ts → client-core-B91EV0WS.d.ts} +19 -0
  150. package/dist/{client-core-B-8DTIN1.d.mts → client-core-BG8Cgrmk.d.mts} +19 -0
  151. package/dist/index.d.mts +3 -3
  152. package/dist/index.d.ts +3 -3
  153. package/dist/index.js +19 -19
  154. package/dist/index.mjs +8 -8
  155. package/dist/install-integrity.json +114 -108
  156. package/dist/plays/play-description.d.mts +1 -1
  157. package/dist/plays/play-description.d.ts +1 -1
  158. package/dist/plays/run-request.d.mts +1 -1
  159. package/dist/plays/run-request.d.ts +1 -1
  160. package/dist/plays/run-request.js +3 -3
  161. package/dist/plays/run-request.mjs +2 -2
  162. package/dist/release.d.mts +1 -1
  163. package/dist/release.d.ts +1 -1
  164. package/dist/release.js +2 -2
  165. package/dist/release.mjs +1 -1
  166. package/dist/server.d.mts +2 -2
  167. package/dist/server.d.ts +2 -2
  168. package/dist/server.js +7 -7
  169. package/dist/server.mjs +5 -5
  170. package/package.json +1 -1
  171. package/dist/cli/auth-32FRISRT.js +0 -43
  172. package/dist/cli/describe-DEXYQMBO.js +0 -50
  173. package/dist/cli/git-RDKLITUC.js +0 -25
  174. package/dist/cli/run-identity-G257GQED.js +0 -25
  175. package/dist/cli/search-YKTYDBCN.js +0 -32
  176. package/dist/cli/skills-PGVIJK6Q.js +0 -36
  177. package/dist/cli/tools-IXXN2RE4.js +0 -57
  178. package/dist/cli/update-QW4RV2UX.js +0 -34
@@ -24,6 +24,23 @@ import type { DaytonaDeleteRetryAuthorization } from '../runner-backends/backend
24
24
  import { hostname } from 'node:os';
25
25
  import { randomUUID } from 'node:crypto';
26
26
  import { setTimeout as sleep } from 'node:timers/promises';
27
+ import {
28
+ isRuntimeGatewayLaunchError,
29
+ readRuntimeGatewayLaunchPin,
30
+ RUNTIME_GATEWAY_PROFILE_READER_FIELD,
31
+ RUNTIME_GATEWAY_PROFILE_READER_REQUIRED_ERROR,
32
+ RUNTIME_GATEWAY_PROFILE_READER_FLAG,
33
+ RuntimeGatewayLaunchError,
34
+ } from '../runtime-gateway-profile';
35
+ import {
36
+ resolveRuntimeGatewayOidcSigningKey,
37
+ type RuntimeGatewayOidcSigningKey,
38
+ } from '../runtime-gateway-oidc';
39
+ import {
40
+ assertExecutorTokenCarriesRuntimeGatewayPin,
41
+ assertRuntimeGatewayAttemptStartable,
42
+ withRuntimeGatewayAttemptCredential,
43
+ } from './runtime-gateway-attempt';
27
44
  import { createRateLimitedRuntimeLogger } from '../../observability/runtime-console';
28
45
  import {
29
46
  ABSURD_WAKE_CHANNEL,
@@ -300,7 +317,11 @@ import {
300
317
  } from './absurd-shared';
301
318
  import { DIRECT_COMPLETED_TERMINAL_CONTRACT } from './terminal-contract';
302
319
  import { runnerReadiness } from './runner-push';
303
- import { runtimeApiBaseUrlFromLaunch } from './runtime-api-origin';
320
+ import {
321
+ resolveRuntimeAppTransport,
322
+ RuntimeAppTransportError,
323
+ type RuntimeAppTransport,
324
+ } from '../runtime-app-transport';
304
325
  import { shouldTerminalizeSandboxCapacityRejection } from '../launch-source-policy';
305
326
  import {
306
327
  ABSURD_CANCELLED_DEADLINE_RECONCILE_LIMIT,
@@ -810,6 +831,13 @@ export type AbsurdRuntimeWorkerDeps = {
810
831
  onComputeSessionInitialized?: () => void;
811
832
  onRuntimeTrafficPolicy?: (policy: RuntimeTrafficPolicy) => void;
812
833
  }) => Promise<string>;
834
+ /**
835
+ * Signing key for pinned runs' sandbox OIDC credential. The production Host
836
+ * reads the secret env once; absent means this worker refuses pinned runs.
837
+ */
838
+ runtimeGatewayOidcSigningKey?: () => RuntimeGatewayOidcSigningKey | null;
839
+ /** Wall clock for Runtime gateway pin age and credential issue time. */
840
+ runtimeGatewayNowMs?: () => number;
813
841
  /** This worker's release lane id. Seam so tests can drive the belt-and-
814
842
  * suspenders lane-mismatch guard without mutating process env. Defaults to
815
843
  * `currentAbsurdReleaseId()`. */
@@ -916,6 +944,10 @@ function buildDefaultDeps(absurd: Absurd): AbsurdRuntimeWorkerDeps {
916
944
  const configuredRuntimeBackend = normalizePlayRuntimeBackend(
917
945
  process.env.DEEPLINE_PLAY_RUNNER_BACKEND || 'daytona',
918
946
  );
947
+ const resolvedRuntimeGatewayOidcSigningKey =
948
+ resolveRuntimeGatewayOidcSigningKey(process.env);
949
+ const runtimeGatewayOidcSigningKey = () =>
950
+ resolvedRuntimeGatewayOidcSigningKey;
919
951
  return {
920
952
  ...createAbsurdRuntimeTerminalProjectionDeps({
921
953
  runWithClient: (fn, trace) =>
@@ -929,8 +961,31 @@ function buildDefaultDeps(absurd: Absurd): AbsurdRuntimeWorkerDeps {
929
961
  runtimeSandboxPlacementPolicyId
930
962
  ? resolveRuntimeSandboxPlacementBackend(runtimeSandboxPlacementPolicyId)
931
963
  : resolvePlayRunnerBackend(backendId),
932
- runtimeApiFromLaunch: absurdRuntimeApiFromLaunch,
964
+ // A pinned attempt token is accepted only inside its deployment's
965
+ // gateway, so this worker's own app calls for that attempt go through the
966
+ // pinned receipt gateway. Unpinned launches keep the direct transport.
967
+ createProgressReporter: (launch, producerAttempt) =>
968
+ createPostgresSchedulerProgressReporter({
969
+ launch,
970
+ durableLogMode: 'direct_worker',
971
+ producerAttempt,
972
+ transport: resolveRuntimeAppTransport({
973
+ caller: 'worker',
974
+ launch,
975
+ signingKey: runtimeGatewayOidcSigningKey,
976
+ }),
977
+ }),
978
+ runtimeApiFromLaunch: (launch) =>
979
+ absurdRuntimeApiFromLaunch(
980
+ launch,
981
+ resolveRuntimeAppTransport({
982
+ caller: 'worker',
983
+ launch,
984
+ signingKey: runtimeGatewayOidcSigningKey,
985
+ }),
986
+ ),
933
987
  mintAttemptExecutorToken: requestAttemptExecutorToken,
988
+ runtimeGatewayOidcSigningKey,
934
989
  deleteRuntimeSandbox: (sandboxId) =>
935
990
  deleteDaytonaSandboxById({
936
991
  sandboxId,
@@ -1071,7 +1126,15 @@ export async function requestAttemptExecutorToken(input: {
1071
1126
  'DEEPLINE_INTERNAL_TOKEN is required to mint an attempt executor token.',
1072
1127
  );
1073
1128
  }
1074
- const url = `${runtimeApiBaseUrlFromLaunch(input.launch).replace(/\/$/, '')}${PLAY_RUNTIME_ATTEMPT_EXECUTOR_TOKEN_PATH}`;
1129
+ // The internal token is never pinned: this call goes straight to the app.
1130
+ const appTransport = resolveRuntimeAppTransport({
1131
+ caller: 'direct',
1132
+ launch: input.launch,
1133
+ executorToken: internalToken,
1134
+ });
1135
+ const url = `${appTransport.baseUrl.replace(/\/$/, '')}${PLAY_RUNTIME_ATTEMPT_EXECUTOR_TOKEN_PATH}`;
1136
+ // Throws for a partial or unknown pin before any request is made.
1137
+ const gatewayPin = readRuntimeGatewayLaunchPin(input.launch);
1075
1138
  const traceId = randomUUID();
1076
1139
  const startedAt = performance.now();
1077
1140
  console.info('[runtime-attempt-token.request_started]', {
@@ -1085,7 +1148,7 @@ export async function requestAttemptExecutorToken(input: {
1085
1148
  let response: Response;
1086
1149
  try {
1087
1150
  response = await fetchWithVercelProtectionBypass({
1088
- baseUrl: runtimeApiBaseUrlFromLaunch(input.launch),
1151
+ baseUrl: appTransport.baseUrl,
1089
1152
  token:
1090
1153
  input.launch.vercelProtectionBypassToken ??
1091
1154
  process.env.VERCEL_PROTECTION_BYPASS_TOKEN ??
@@ -1109,6 +1172,15 @@ export async function requestAttemptExecutorToken(input: {
1109
1172
  ...(input.initializeComputeSession
1110
1173
  ? { initializeComputeSession: true }
1111
1174
  : {}),
1175
+ // Pinned launches only: this worker reads the gateway pin. The app
1176
+ // refuses a pinned launch without it (409), so an older worker
1177
+ // fails loudly instead of running on its configured gateways.
1178
+ ...(gatewayPin
1179
+ ? {
1180
+ [RUNTIME_GATEWAY_PROFILE_READER_FIELD]:
1181
+ RUNTIME_GATEWAY_PROFILE_READER_FLAG,
1182
+ }
1183
+ : {}),
1112
1184
  // Expand-before-enable rollout fence. An old worker never sends this,
1113
1185
  // so a newly deployed app cannot activate direct terminal reduction
1114
1186
  // before the owning Fly lane has the cleanup controller.
@@ -1175,6 +1247,15 @@ export async function requestAttemptExecutorToken(input: {
1175
1247
  response.headers.get('x-request-id') ??
1176
1248
  null,
1177
1249
  });
1250
+ if (
1251
+ response.status === 409 &&
1252
+ body?.error === RUNTIME_GATEWAY_PROFILE_READER_REQUIRED_ERROR
1253
+ ) {
1254
+ throw new RuntimeGatewayLaunchError(
1255
+ RUNTIME_GATEWAY_PROFILE_READER_REQUIRED_ERROR,
1256
+ `The app refused an executor token for pinned run ${input.launch.runId}: the request did not advertise Runtime gateway profile support.`,
1257
+ );
1258
+ }
1178
1259
  if (code === 'RUNTIME_SCHEDULER_CAPACITY') {
1179
1260
  throw new AttemptExecutorTokenCapacityError(
1180
1261
  capacitySource,
@@ -1198,6 +1279,9 @@ export async function requestAttemptExecutorToken(input: {
1198
1279
  response.headers.get('x-request-id') ??
1199
1280
  null,
1200
1281
  });
1282
+ if (gatewayPin) {
1283
+ assertExecutorTokenCarriesRuntimeGatewayPin(body.executorToken, gatewayPin);
1284
+ }
1201
1285
  if (
1202
1286
  input.initializeComputeSession === true &&
1203
1287
  body.computeSessionInitialized?.sessionId === input.launch.runId &&
@@ -3194,6 +3278,14 @@ async function executeAbsurdAttemptAdapter(
3194
3278
  );
3195
3279
  }
3196
3280
  }
3281
+ // A pinned run starts or resumes only on a fresh pin. A live detached
3282
+ // runner adopted here keeps its sandbox and existing pin.
3283
+ if (!isDetachedRecovery) {
3284
+ assertRuntimeGatewayAttemptStartable(
3285
+ launch,
3286
+ deps.runtimeGatewayNowMs?.() ?? Date.now(),
3287
+ );
3288
+ }
3197
3289
  return deps.mintAttemptExecutorToken({
3198
3290
  launch,
3199
3291
  attempt: generation,
@@ -3351,6 +3443,13 @@ async function executeAbsurdAttemptAdapter(
3351
3443
  throw error;
3352
3444
  }
3353
3445
  let forceTerminalSalvage = false;
3446
+ let forcedTerminalReason: string | undefined;
3447
+ if (isRuntimeGatewayLaunchError(error)) {
3448
+ // Deterministic: a retry cannot repair the pin, and falling back to the
3449
+ // configured gateways would silently drop it.
3450
+ forceTerminalSalvage = true;
3451
+ forcedTerminalReason = error.code;
3452
+ }
3354
3453
  if (error instanceof AttemptExecutorTokenUnavailableError) {
3355
3454
  // Throws DeferTask while inside the wall-clock bound; returns only when
3356
3455
  // the bound is exhausted and this attempt must write the terminal.
@@ -3421,6 +3520,7 @@ async function executeAbsurdAttemptAdapter(
3421
3520
  error,
3422
3521
  detachedRecovery: isDetachedRecovery,
3423
3522
  force: forceTerminalSalvage,
3523
+ ...(forcedTerminalReason ? { forcedTerminalReason } : {}),
3424
3524
  });
3425
3525
  throw error;
3426
3526
  } finally {
@@ -4054,6 +4154,7 @@ async function executeAssignedAbsurdAttempt(input: {
4054
4154
  const heartbeatSilenceMs = resolveRunnerHeartbeatSilenceMs(
4055
4155
  launch.runtimeTestFaultHeader,
4056
4156
  );
4157
+
4057
4158
  return {
4058
4159
  runnerConfig: {
4059
4160
  ...baseRunnerConfig,
@@ -4208,8 +4309,18 @@ async function executeAssignedAbsurdAttempt(input: {
4208
4309
  });
4209
4310
  }
4210
4311
  }
4312
+ const cleanupExecutorToken = runnerConfig.context.executorToken;
4211
4313
  const runtimeStateCleanup = releaseAbsurdAttemptRuntimeState({
4212
4314
  config: runnerConfig,
4315
+ // Without an attempt token there is nothing to authenticate; a pinned
4316
+ // run then fails loudly in cleanupRuntimeApiContext instead.
4317
+ transport: cleanupExecutorToken
4318
+ ? resolveRuntimeAppTransport({
4319
+ caller: 'worker',
4320
+ launch: { ...launch, executorToken: cleanupExecutorToken },
4321
+ signingKey: () => deps.runtimeGatewayOidcSigningKey?.() ?? null,
4322
+ })
4323
+ : undefined,
4213
4324
  runId,
4214
4325
  runAttempt: generation,
4215
4326
  resources: attemptResources,
@@ -4392,6 +4503,17 @@ async function executeAssignedAbsurdAttempt(input: {
4392
4503
  );
4393
4504
  }
4394
4505
  backendExecutions += 1;
4506
+ // Each sandbox launch of a pinned run re-checks the pin's age and gets
4507
+ // its own short-lived edge credential; the watchdog renews it from
4508
+ // there. Unpinned launches use runnerConfig unchanged.
4509
+ const sandboxLaunchConfig = withRuntimeGatewayAttemptCredential({
4510
+ config: runnerConfig,
4511
+ launch,
4512
+ runId,
4513
+ attempt: generation,
4514
+ nowMs: deps.runtimeGatewayNowMs?.() ?? Date.now(),
4515
+ signingKey: () => deps.runtimeGatewayOidcSigningKey?.() ?? null,
4516
+ });
4395
4517
  // Read the policy while preparing durable billing state, then enforce
4396
4518
  // it at the existing pre-create barrier. Observe both outcomes now so
4397
4519
  // a failed read cannot become an unhandled rejection during setup.
@@ -5016,7 +5138,7 @@ async function executeAssignedAbsurdAttempt(input: {
5016
5138
  const outcome = await sandboxRuns.execute({
5017
5139
  attempt: { runId, number: generation },
5018
5140
  authority: { fenceId: leaseToken },
5019
- launch: runnerConfig,
5141
+ launch: sandboxLaunchConfig,
5020
5142
  mode:
5021
5143
  runnerConfig.checkpoint === null ||
5022
5144
  runnerConfig.checkpoint === undefined
@@ -5319,6 +5441,13 @@ async function releaseFailedTerminalAttempt(
5319
5441
  input.generation,
5320
5442
  ),
5321
5443
  },
5444
+ // The primary launch token is never pinned: the owner sends a pinned
5445
+ // run's release to the app directly, not to a gateway that refuses it.
5446
+ transport: resolveRuntimeAppTransport({
5447
+ caller: 'worker',
5448
+ launch: input.launch,
5449
+ signingKey: () => null,
5450
+ }),
5322
5451
  runId: input.runId,
5323
5452
  runAttempt: input.generation,
5324
5453
  resources,
@@ -5914,7 +6043,37 @@ type RuntimeCleanupApiContext = Parameters<
5914
6043
 
5915
6044
  function cleanupRuntimeApiContext(
5916
6045
  config: Pick<PlayRunnerExecutionConfig, 'context'>,
6046
+ transport?: RuntimeAppTransport,
5917
6047
  ): RuntimeCleanupApiContext {
6048
+ // A pinned run's gateway accepts only a credentialed, pinned attempt
6049
+ // token; the owner decides (pinned gateway with a minted credential, or the
6050
+ // app directly for an unpinned primary token). Unpinned runs are unchanged.
6051
+ if (config.context.runtimeGatewayCredentialScope) {
6052
+ if (!transport) {
6053
+ throw new RuntimeAppTransportError(
6054
+ `cleanup for pinned run ${config.context.runId} has no resolved app transport.`,
6055
+ );
6056
+ }
6057
+ const viaGateway = transport.kind === 'pinned_gateway';
6058
+ return {
6059
+ executorToken: config.context.executorToken,
6060
+ baseUrl: transport.baseUrl,
6061
+ vercelProtectionBypassToken: transport.vercelProtectionBypassToken,
6062
+ ...(transport.fetch ? { fetch: transport.fetch } : {}),
6063
+ orgId: config.context.orgId,
6064
+ playName: config.context.playName,
6065
+ runId: config.context.runId,
6066
+ userEmail: config.context.userEmail,
6067
+ dbSessionStrategy: viaGateway
6068
+ ? 'gateway_only'
6069
+ : config.context.dbSessionStrategy,
6070
+ preloadedDbSessions: viaGateway
6071
+ ? undefined
6072
+ : config.context.preloadedDbSessions,
6073
+ postgresSessionUnwrapKey:
6074
+ config.context.postgresSessionUnwrapKey ?? config.context.executorToken,
6075
+ };
6076
+ }
5918
6077
  const gatewayBaseUrl = config.context.receiptGatewayBaseUrl?.trim();
5919
6078
  return {
5920
6079
  executorToken: config.context.executorToken,
@@ -5958,6 +6117,8 @@ type RuntimeSheetAttemptResource = {
5958
6117
  */
5959
6118
  async function releaseRuntimeSheetAttemptResources(input: {
5960
6119
  config: Pick<PlayRunnerExecutionConfig, 'context'>;
6120
+ /** Required for a pinned run (`cleanupRuntimeApiContext`). */
6121
+ transport?: RuntimeAppTransport;
5961
6122
  runId: string;
5962
6123
  runAttempt: number;
5963
6124
  resources: readonly unknown[];
@@ -5965,7 +6126,7 @@ async function releaseRuntimeSheetAttemptResources(input: {
5965
6126
  const orgId = input.config.context.orgId;
5966
6127
  const playName = input.config.context.playName;
5967
6128
  if (!orgId || !playName) return 0;
5968
- const context = cleanupRuntimeApiContext(input.config);
6129
+ const context = cleanupRuntimeApiContext(input.config, input.transport);
5969
6130
  const sheetResults = await Promise.allSettled(
5970
6131
  runtimeSheetAttemptResources(input.resources).map(
5971
6132
  async (resource) =>
@@ -6065,6 +6226,8 @@ function runtimeSheetAttemptResources(
6065
6226
 
6066
6227
  async function releaseAbsurdAttemptRuntimeState(input: {
6067
6228
  config: PlayRunnerExecutionConfig;
6229
+ /** Required for a pinned run (`cleanupRuntimeApiContext`). */
6230
+ transport?: RuntimeAppTransport;
6068
6231
  runId: string;
6069
6232
  runAttempt: number;
6070
6233
  /** THIS generation's recorded resources — sheet/receipt lease release stays
@@ -6131,7 +6294,7 @@ async function releaseAbsurdAttemptRuntimeState(input: {
6131
6294
  const orgId = input.config.context.orgId;
6132
6295
  const playName = input.config.context.playName;
6133
6296
  if (!orgId || !playName) return;
6134
- const context = cleanupRuntimeApiContext(input.config);
6297
+ const context = cleanupRuntimeApiContext(input.config, input.transport);
6135
6298
  try {
6136
6299
  const [receiptRelease, sheetRelease] = await Promise.allSettled([
6137
6300
  releaseRuntimeWorkReceipts(context, {
@@ -6302,6 +6465,9 @@ async function salvageAbsurdFinalAttemptTerminal(input: {
6302
6465
  /** A wall-clock bound, not the engine attempt count, requires the terminal
6303
6466
  * now (executor-token outage past its bound). */
6304
6467
  force?: boolean;
6468
+ /** Named deterministic failure that forces the terminal (e.g. an expired
6469
+ * Runtime gateway pin). Absent keeps the executor-token outage wording. */
6470
+ forcedTerminalReason?: string;
6305
6471
  }): Promise<void> {
6306
6472
  const attempt = input.ctx.attempt;
6307
6473
  const maxAttempts = input.ctx.maxAttempts;
@@ -6324,9 +6490,11 @@ async function salvageAbsurdFinalAttemptTerminal(input: {
6324
6490
  const failedResult: PlayRunnerResult = {
6325
6491
  status: 'failed',
6326
6492
  error:
6327
- input.force && attempt < maxAttempts
6328
- ? `absurd play-run task exhausted its executor-token outage bound on engine attempt ${attempt}/${maxAttempts}: ${message}`
6329
- : `absurd play-run task failed on its final engine attempt (${attempt}/${maxAttempts}): ${message}`,
6493
+ input.force && input.forcedTerminalReason
6494
+ ? `absurd play-run task failed terminally (${input.forcedTerminalReason}) on engine attempt ${attempt}/${maxAttempts}: ${message}`
6495
+ : input.force && attempt < maxAttempts
6496
+ ? `absurd play-run task exhausted its executor-token outage bound on engine attempt ${attempt}/${maxAttempts}: ${message}`
6497
+ : `absurd play-run task failed on its final engine attempt (${attempt}/${maxAttempts}): ${message}`,
6330
6498
  logs: [],
6331
6499
  stats: {},
6332
6500
  steps: [],
@@ -8393,8 +8561,13 @@ async function processPostgresSchedulerComputeBillingJob(input: {
8393
8561
  attemptCount: input.job.attemptCount,
8394
8562
  schedulerSchema: input.schedulerOptions.schema ?? null,
8395
8563
  });
8564
+ // A compute-billing dispatch token is never pinned to a gateway.
8396
8565
  const runtimeApi = {
8397
- baseUrl: runtimeApiBaseUrlFromLaunch(launch),
8566
+ baseUrl: resolveRuntimeAppTransport({
8567
+ caller: 'direct',
8568
+ launch,
8569
+ executorToken,
8570
+ }).baseUrl,
8398
8571
  executorToken,
8399
8572
  vercelProtectionBypassToken: launch.vercelProtectionBypassToken ?? null,
8400
8573
  };
@@ -34,7 +34,11 @@ import {
34
34
  withRuntimeSchedulerClient,
35
35
  type RuntimeSchedulerPoolOptions,
36
36
  } from './postgres-pool';
37
- import { runtimeApiBaseUrlFromLaunch } from './runtime-api-origin';
37
+ import {
38
+ resolveRuntimeAppTransport,
39
+ runtimeAppTransportContextFields,
40
+ type RuntimeAppTransport,
41
+ } from '../runtime-app-transport';
38
42
  import {
39
43
  ABSURD_DEV_RELEASE_PREFIX,
40
44
  ABSURD_PROD_DEFAULT_SCHEMA,
@@ -658,16 +662,26 @@ export function absurdRunnerTerminalEventName(
658
662
  return `runner-terminal:${runId}:${runnerAttempt}`;
659
663
  }
660
664
 
661
- /** Build the worker→app runtime API context (ledger + billing callbacks). */
665
+ /**
666
+ * Build the worker→app runtime API context (ledger + billing callbacks) on
667
+ * a transport from `resolveRuntimeAppTransport`. Absent, the launch's direct
668
+ * transport, which refuses a gateway-pinned token loudly.
669
+ */
662
670
  export function absurdRuntimeApiFromLaunch(
663
671
  launch: PlaySchedulerSubmitInput,
672
+ transport: RuntimeAppTransport = resolveRuntimeAppTransport({
673
+ caller: 'direct',
674
+ launch,
675
+ executorToken: launch.executorToken,
676
+ }),
664
677
  ): WorkerRuntimeApiContext {
665
678
  return {
666
- baseUrl: runtimeApiBaseUrlFromLaunch(launch),
679
+ baseUrl: transport.baseUrl,
667
680
  executorToken: launch.executorToken,
668
681
  integrationMode: launch.integrationMode ?? null,
669
682
  vercelProtectionBypassToken: launch.vercelProtectionBypassToken ?? null,
670
683
  runtimeTestFaultHeader: launch.runtimeTestFaultHeader ?? null,
684
+ ...runtimeAppTransportContextFields(transport),
671
685
  };
672
686
  }
673
687
 
@@ -1,3 +1,4 @@
1
+ import type { RuntimeAppTransport } from '../runtime-app-transport';
1
2
  import type { PlaySchedulerSubmitInput } from '../scheduler-backend';
2
3
  import type { PlayRunnerResult } from '../protocol';
3
4
  import {
@@ -110,6 +111,11 @@ export async function projectGatewayRunnerTerminalProgress(input: {
110
111
  }
111
112
 
112
113
  export function createGatewayProgressRegistry(options?: {
114
+ /** The gateway's app transport for a launch (`resolveRuntimeAppTransport`,
115
+ * caller `in_gateway`); absent is the launch's direct transport. */
116
+ appTransportForLaunch?: (
117
+ launch: PlaySchedulerSubmitInput,
118
+ ) => RuntimeAppTransport;
113
119
  createReporter?: (
114
120
  launch: PlaySchedulerSubmitInput,
115
121
  attempt: number,
@@ -133,6 +139,9 @@ export function createGatewayProgressRegistry(options?: {
133
139
  isCurrentAttempt,
134
140
  attemptAlreadyVerified,
135
141
  initialLiveLogTotalCount,
142
+ ...(options?.appTransportForLaunch
143
+ ? { transport: options.appTransportForLaunch(launch) }
144
+ : {}),
136
145
  }));
137
146
 
138
147
  return {
@@ -55,7 +55,11 @@ import {
55
55
  } from '../step-progress';
56
56
  import type { PlayConditionCounts } from '../cell-provenance';
57
57
  import { readRuntimeSheetRowOutcomeCounts } from '../runtime-api';
58
- import { runtimeApiBaseUrlFromLaunch } from './runtime-api-origin';
58
+ import {
59
+ resolveRuntimeAppTransport,
60
+ runtimeAppTransportContextFields,
61
+ type RuntimeAppTransport,
62
+ } from '../runtime-app-transport';
59
63
 
60
64
  // Patterns mirrored from runner events — they parse
61
65
  // the same Node play-runner log stream.
@@ -438,6 +442,9 @@ export function createPostgresSchedulerProgressReporter(input: {
438
442
  * folded terminal patch for a durable scheduler outbox instead of posting
439
443
  * it synchronously. */
440
444
  publishStatusUpdate?: (update: RuntimeStatusUpdate) => Promise<void>;
445
+ /** The caller's app transport (`resolveRuntimeAppTransport`); absent is
446
+ * the direct transport of the launch, refused for a pinned token. */
447
+ transport?: RuntimeAppTransport;
441
448
  }): PostgresSchedulerProgressReporter {
442
449
  const launch = input.launch;
443
450
  const durableLogMode = input.durableLogMode ?? 'progress_reporter';
@@ -453,10 +460,18 @@ export function createPostgresSchedulerProgressReporter(input: {
453
460
  };
454
461
  const orderedNodes = buildOrderedNodeList(launch.contractSnapshot);
455
462
  const mapNodeLookup = buildMapNodeLookup(launch.contractSnapshot);
463
+ const transport =
464
+ input.transport ??
465
+ resolveRuntimeAppTransport({
466
+ caller: 'direct',
467
+ launch,
468
+ executorToken: launch.executorToken,
469
+ });
456
470
  const runtimeApi = {
457
- baseUrl: runtimeApiBaseUrlFromLaunch(launch),
471
+ baseUrl: transport.baseUrl,
458
472
  executorToken: launch.executorToken,
459
473
  vercelProtectionBypassToken: launch.vercelProtectionBypassToken ?? null,
474
+ ...runtimeAppTransportContextFields(transport),
460
475
  };
461
476
  const publishStatusUpdate =
462
477
  input.publishStatusUpdate ??
@@ -1910,6 +1925,7 @@ export const createDirectWorkerProgressReporter = (input: {
1910
1925
  attemptAlreadyVerified?: boolean;
1911
1926
  initialLiveLogTotalCount?: number;
1912
1927
  publishStatusUpdate?: (update: RuntimeStatusUpdate) => Promise<void>;
1928
+ runtimeApiFetch?: typeof fetch;
1913
1929
  }) =>
1914
1930
  createPostgresSchedulerProgressReporter({
1915
1931
  ...input,