deepline 0.3.491 → 0.3.493

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 (184) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +11 -5
  2. package/dist/bundling-sources/sdk/src/plays/run-request.ts +1 -0
  3. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  4. package/dist/bundling-sources/sdk/src/types.ts +6 -0
  5. package/dist/bundling-sources/shared_libs/monitors/fleets/verdict.ts +25 -9
  6. package/dist/bundling-sources/shared_libs/observability/queue-health.ts +9 -0
  7. package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
  8. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +54 -0
  9. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +5 -4
  10. package/dist/bundling-sources/shared_libs/play-runtime/crustdata-company-identify-batching.ts +162 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-reaper.ts +19 -3
  12. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +5 -3
  13. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-batching-registry.ts +2 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/receipt-sql.ts +17 -23
  15. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-modal-fallback.ts +28 -1
  16. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +293 -110
  17. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-placement-policy.ts +75 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +20 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +412 -59
  20. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +38 -10
  21. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +19 -11
  22. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-operation.ts +165 -12
  23. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-state-machine.ts +358 -0
  24. package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +104 -2
  25. package/dist/bundling-sources/shared_libs/product-notifications/configuration-draft.ts +7 -2
  26. package/dist/bundling-sources/shared_libs/product-notifications/configuration.ts +4 -0
  27. package/dist/bundling-sources/shared_libs/product-notifications/content.ts +13 -0
  28. package/dist/bundling-sources/shared_libs/product-notifications/email.ts +49 -10
  29. package/dist/bundling-sources/shared_libs/product-notifications/events.ts +22 -0
  30. package/dist/bundling-sources/shared_libs/product-notifications/slack-delivery.ts +6 -1
  31. package/dist/cli/{auth-FXAC472Y.mjs → auth-3NAY3AST.mjs} +5 -5
  32. package/dist/cli/auth-KYQLDI6V.js +43 -0
  33. package/dist/cli/{billing-PDOA3KZ3.js → billing-FSB4BBBO.js} +80 -80
  34. package/dist/cli/{billing-UM4LE33K.mjs → billing-SBWQCC7B.mjs} +7 -7
  35. package/dist/cli/{chunk-HSJK6EMU.mjs → chunk-2BRTYIAH.mjs} +23 -9
  36. package/dist/cli/{chunk-B2TXKEED.js → chunk-2H4OFVR5.js} +5 -5
  37. package/dist/cli/{chunk-BCKIBVEJ.js → chunk-2I7VN65H.js} +10 -10
  38. package/dist/cli/{chunk-LMG7O6XJ.mjs → chunk-2IHGVAGT.mjs} +2 -2
  39. package/dist/cli/{chunk-5KMGKG4B.js → chunk-2NGIBJM2.js} +8 -8
  40. package/dist/cli/{chunk-2MW6TGNZ.mjs → chunk-3QGUWB6E.mjs} +4 -4
  41. package/dist/cli/{chunk-ORKLMANE.mjs → chunk-4IJFQV3O.mjs} +1 -1
  42. package/dist/cli/{chunk-PIPEPCRL.mjs → chunk-4NIGNT7X.mjs} +1 -1
  43. package/dist/cli/{chunk-H6UIS36S.mjs → chunk-5DIZ2G74.mjs} +2 -2
  44. package/dist/cli/{chunk-TKLDKIJU.mjs → chunk-5JPKRDFC.mjs} +7 -5
  45. package/dist/cli/{chunk-FTXIJTV2.mjs → chunk-5WOPBX3H.mjs} +1 -1
  46. package/dist/cli/{chunk-KGJVDR4Q.mjs → chunk-67ZG7XZV.mjs} +3 -3
  47. package/dist/cli/{chunk-DUFRH43S.js → chunk-7HABWOMB.js} +261 -261
  48. package/dist/cli/{chunk-MN6DCV63.js → chunk-AGTXL6LZ.js} +5 -5
  49. package/dist/cli/{chunk-Q7G7CU4W.js → chunk-AWMCZAUR.js} +3 -3
  50. package/dist/cli/{chunk-HHTVRICE.js → chunk-C2MRDPA5.js} +17 -17
  51. package/dist/cli/{chunk-ONONSV2Q.mjs → chunk-DVQHG6AM.mjs} +1 -0
  52. package/dist/cli/{chunk-O3K22ZC7.js → chunk-DWJ4RXSA.js} +34 -11
  53. package/dist/cli/{chunk-MAM6ZOVS.mjs → chunk-DYP27IWC.mjs} +99 -24
  54. package/dist/cli/{chunk-NUOKAKZW.mjs → chunk-E5ILCMKQ.mjs} +1 -1
  55. package/dist/cli/{chunk-OLHWZM4A.mjs → chunk-EBAS3UT2.mjs} +6 -6
  56. package/dist/cli/{chunk-74H5OTRM.js → chunk-EFO5GVYS.js} +1 -1
  57. package/dist/cli/{chunk-X7YOVJBC.js → chunk-EYG336YV.js} +132 -57
  58. package/dist/cli/{chunk-YV4DP6KQ.mjs → chunk-GSC35TPZ.mjs} +2 -2
  59. package/dist/cli/{chunk-EPD7NSDJ.mjs → chunk-HLM2UFQ5.mjs} +13 -5
  60. package/dist/cli/{chunk-IG3GSBBE.js → chunk-HTUSTPP4.js} +32 -32
  61. package/dist/cli/{chunk-CFPFTS3A.mjs → chunk-IJJ6D5WL.mjs} +12 -12
  62. package/dist/cli/{chunk-TH7JLR5D.js → chunk-IJOHWGPF.js} +6 -6
  63. package/dist/cli/{chunk-RFSXXDH7.js → chunk-IOBPR2VO.js} +17 -17
  64. package/dist/cli/{chunk-HNG2U3IG.js → chunk-IOMEJKGK.js} +2 -2
  65. package/dist/cli/{chunk-A7ZMG2QZ.mjs → chunk-IRDYBMA7.mjs} +34 -11
  66. package/dist/cli/{chunk-ZEZ3CZ3X.js → chunk-JO2JZUBR.js} +3 -3
  67. package/dist/cli/{chunk-4IP5MLWU.js → chunk-JO5FFSR7.js} +6 -1
  68. package/dist/cli/{chunk-SJOHQ2WW.js → chunk-KCDZWS2B.js} +56 -56
  69. package/dist/cli/{chunk-CGDUFVNE.mjs → chunk-KGDDQMI7.mjs} +2 -2
  70. package/dist/cli/{chunk-OYJTLEB4.mjs → chunk-KKSKYZO4.mjs} +1 -1
  71. package/dist/cli/{chunk-TMAS3WH3.js → chunk-LGTZYI5B.js} +21 -21
  72. package/dist/cli/{chunk-SUMKWA53.js → chunk-MLEUOTEQ.js} +73 -59
  73. package/dist/cli/{chunk-3WRWPNHE.mjs → chunk-NALJJTPS.mjs} +5 -5
  74. package/dist/cli/{chunk-27MRSV6O.js → chunk-NPNAEPY4.js} +26 -26
  75. package/dist/cli/{chunk-AEKJZJ4R.js → chunk-NWIDPT7H.js} +4 -4
  76. package/dist/cli/{chunk-AUQQVDAB.js → chunk-PKV5CD3W.js} +1 -0
  77. package/dist/cli/{chunk-3FMU6F6E.js → chunk-QTPS5RLG.js} +15 -15
  78. package/dist/cli/{chunk-4OLXMJ2L.js → chunk-RLX5ZFNX.js} +8 -6
  79. package/dist/cli/{chunk-DEJIN4DF.mjs → chunk-SAW3FBCA.mjs} +5 -0
  80. package/dist/cli/{chunk-S4CYM4EC.mjs → chunk-SXD2EYAH.mjs} +6 -6
  81. package/dist/cli/{chunk-YNWET57Z.js → chunk-TIFRRLZT.js} +7 -7
  82. package/dist/cli/{chunk-6PMM7VJN.mjs → chunk-TNQOR6XQ.mjs} +1 -1
  83. package/dist/cli/{chunk-6UARNRXT.js → chunk-UCMY2SO2.js} +23 -15
  84. package/dist/cli/{chunk-X75ONMDJ.mjs → chunk-VFHIYWMC.mjs} +5 -5
  85. package/dist/cli/{chunk-ZX2FXZJN.js → chunk-WCZFCOMZ.js} +7 -7
  86. package/dist/cli/{chunk-IIO7UOVW.mjs → chunk-WTFI7BVH.mjs} +3 -3
  87. package/dist/cli/{chunk-I64PYCTB.js → chunk-XLE7KXE7.js} +2 -2
  88. package/dist/cli/{chunk-CRBBGKRH.js → chunk-XQX476QK.js} +14 -14
  89. package/dist/cli/{chunk-WCWVXN3R.mjs → chunk-Y3NN2UAF.mjs} +2 -2
  90. package/dist/cli/{chunk-3K4IAV7I.mjs → chunk-ZQH4TXM2.mjs} +2 -2
  91. package/dist/cli/{chunk-VC3SH4QW.mjs → chunk-ZVW7EWTC.mjs} +7 -7
  92. package/dist/cli/{chunk-QBOE5LEH.mjs → chunk-ZVXB7OU7.mjs} +1 -1
  93. package/dist/cli/command-docs.js +2 -2
  94. package/dist/cli/command-docs.mjs +1 -1
  95. package/dist/cli/{csv-IGPAPAES.js → csv-DKYZE2KM.js} +13 -13
  96. package/dist/cli/{csv-RNMQHECI.mjs → csv-XR22YQXT.mjs} +4 -4
  97. package/dist/cli/{db-CKMVVGXJ.mjs → db-EOKG36YN.mjs} +7 -7
  98. package/dist/cli/{db-32OXM3TO.js → db-RNYRTCMV.js} +28 -28
  99. package/dist/cli/describe-ICFXOQBW.mjs +50 -0
  100. package/dist/cli/describe-RS75I33X.js +50 -0
  101. package/dist/cli/describe-core.d.mts +2 -2
  102. package/dist/cli/describe-core.d.ts +2 -2
  103. package/dist/cli/describe-core.js +4 -4
  104. package/dist/cli/describe-core.mjs +3 -3
  105. package/dist/cli/{executions-S4M4JMCU.mjs → executions-3RAOACNS.mjs} +7 -7
  106. package/dist/cli/{executions-PCZS7B2M.js → executions-OBWPSWH7.js} +9 -9
  107. package/dist/cli/{feedback-FGUJVCBS.mjs → feedback-6EQRVBKF.mjs} +4 -4
  108. package/dist/cli/{feedback-6EGKPZ3U.js → feedback-6GPEUBLF.js} +8 -8
  109. package/dist/cli/getting-started.d.mts +12 -10
  110. package/dist/cli/getting-started.d.ts +12 -10
  111. package/dist/cli/getting-started.js +4 -2
  112. package/dist/cli/getting-started.mjs +3 -1
  113. package/dist/cli/{git-LR4ARG5H.mjs → git-CVQ24DTR.mjs} +5 -5
  114. package/dist/cli/git-DEFE4SSB.js +25 -0
  115. package/dist/cli/index.js +143 -143
  116. package/dist/cli/index.mjs +43 -43
  117. package/dist/cli/{legacy-noops-S37PJ7OJ.mjs → legacy-noops-QULJZYNH.mjs} +5 -5
  118. package/dist/cli/{legacy-noops-VX4JEQR6.js → legacy-noops-XPOATG5V.js} +8 -8
  119. package/dist/cli/{monitors-H3AX6CZG.mjs → monitors-AFT5YJPZ.mjs} +49 -9
  120. package/dist/cli/{monitors-ADASJI72.js → monitors-OJ4CMREE.js} +169 -129
  121. package/dist/cli/{org-ZRJ3C56J.js → org-RKT52CSL.js} +73 -73
  122. package/dist/cli/{org-D3F5LUDW.mjs → org-WHKNXANG.mjs} +7 -7
  123. package/dist/cli/{pages-PSHU366M.mjs → pages-EEAQFGVD.mjs} +7 -7
  124. package/dist/cli/{pages-5TKO3644.js → pages-SOE3R667.js} +18 -18
  125. package/dist/cli/{play-AUDDK7XB.mjs → play-LXFWHUBP.mjs} +147 -52
  126. package/dist/cli/{play-VDAETQDI.js → play-OTJJ4E4T.js} +661 -566
  127. package/dist/cli/{providers-IURPWRWD.js → providers-RU4HIAT3.js} +10 -10
  128. package/dist/cli/{providers-X7YMZSKQ.mjs → providers-U3CPKTMM.mjs} +7 -7
  129. package/dist/cli/{quickstart-6AGWVFNX.mjs → quickstart-75AO2AJC.mjs} +5 -5
  130. package/dist/cli/{quickstart-Y6GFXLDV.js → quickstart-N72IVA2Y.js} +13 -13
  131. package/dist/cli/{run-TG7J45NS.mjs → run-IGWFL6WH.mjs} +29 -28
  132. package/dist/cli/{run-TQFGOXNT.js → run-MMYES3IW.js} +44 -43
  133. package/dist/cli/search-EQURI7SZ.js +32 -0
  134. package/dist/cli/{search-3G4J2GC6.mjs → search-FIYESBLZ.mjs} +8 -8
  135. package/dist/cli/{search-output-NPZICK5C.js → search-output-2FXN4ZWD.js} +9 -6
  136. package/dist/cli/{search-output-ZGNHDCLL.mjs → search-output-3I5KSW36.mjs} +7 -4
  137. package/dist/cli/{secrets-KTTHT4ZG.js → secrets-HCZQ6JNP.js} +16 -16
  138. package/dist/cli/{secrets-EAWJBRUD.mjs → secrets-O7IUQ3VT.mjs} +7 -7
  139. package/dist/cli/{sessions-S4YVBPAW.js → sessions-5AYTT4IW.js} +6 -6
  140. package/dist/cli/{sessions-D4Q3LCEQ.mjs → sessions-KY7A3EZO.mjs} +5 -5
  141. package/dist/cli/{settings-BAK3VOWW.js → settings-P4VFYWJK.js} +80 -80
  142. package/dist/cli/{settings-JUORW6NL.mjs → settings-WSMRR2GS.mjs} +13 -13
  143. package/dist/cli/{setup-NJPHTW32.js → setup-J7CA3EJL.js} +57 -57
  144. package/dist/cli/{setup-AXFGCXJE.mjs → setup-YTVKVQC7.mjs} +13 -13
  145. package/dist/cli/skills-KKPEGLAR.js +36 -0
  146. package/dist/cli/{skills-SKJVDJEF.mjs → skills-W5WY764N.mjs} +10 -10
  147. package/dist/cli/tools-65Y4QTW6.js +57 -0
  148. package/dist/cli/{tools-63THJVJZ.mjs → tools-YECI6N3N.mjs} +20 -20
  149. package/dist/cli/{update-KSID5F74.mjs → update-BIFBIEII.mjs} +10 -10
  150. package/dist/cli/update-WDG7VFOW.js +34 -0
  151. package/dist/cli/{workflow-BLSMWBKW.js → workflow-D2TUFFH6.js} +18 -18
  152. package/dist/cli/{workflow-C4B54X2Z.mjs → workflow-XZVDNARC.mjs} +8 -8
  153. package/dist/{client-CQgGFxAH.d.ts → client-BDB_VbE4.d.ts} +1 -1
  154. package/dist/{client-B4R1scm2.d.mts → client-CNzJ1LTF.d.mts} +1 -1
  155. package/dist/{client-core-DMvHWjub.d.mts → client-core-CSv3DlPD.d.mts} +76 -5
  156. package/dist/{client-core-BUNjKBKq.d.ts → client-core-xEa9x3pl.d.ts} +76 -5
  157. package/dist/index.d.mts +3 -3
  158. package/dist/index.d.ts +3 -3
  159. package/dist/index.js +10 -10
  160. package/dist/index.mjs +7 -7
  161. package/dist/install-integrity.json +115 -114
  162. package/dist/plays/play-description.d.mts +1 -1
  163. package/dist/plays/play-description.d.ts +1 -1
  164. package/dist/plays/run-request.d.mts +1 -1
  165. package/dist/plays/run-request.d.ts +1 -1
  166. package/dist/plays/run-request.js +2 -2
  167. package/dist/plays/run-request.mjs +1 -1
  168. package/dist/release.d.mts +1 -1
  169. package/dist/release.d.ts +1 -1
  170. package/dist/release.js +2 -2
  171. package/dist/release.mjs +1 -1
  172. package/dist/server.d.mts +2 -2
  173. package/dist/server.d.ts +2 -2
  174. package/dist/server.js +6 -6
  175. package/dist/server.mjs +4 -4
  176. package/package.json +1 -1
  177. package/dist/cli/auth-QIDL3YCW.js +0 -43
  178. package/dist/cli/describe-67GMIEIO.js +0 -50
  179. package/dist/cli/describe-QR7I3VOF.mjs +0 -50
  180. package/dist/cli/git-PIH5Z5LN.js +0 -25
  181. package/dist/cli/search-VC43NUY7.js +0 -32
  182. package/dist/cli/skills-4NQZISNK.js +0 -36
  183. package/dist/cli/tools-BAHK33FQ.js +0 -57
  184. package/dist/cli/update-EMIGRGJ7.js +0 -34
@@ -185,6 +185,7 @@ import { BoundedBatchFunction } from './bounded-batch-function';
185
185
  import {
186
186
  jsonByteLengthUpTo,
187
187
  RUNNER_TERMINAL_PUSH_MAX_BODY_BYTES,
188
+ RUNTIME_SHEET_START_MAX_RESPONSE_ROWS,
188
189
  RUNTIME_SHEET_START_TARGET_BODY_BYTES,
189
190
  } from './output-size-limits';
190
191
  import {
@@ -876,11 +877,54 @@ function normalizeRuntimeUserEmail(
876
877
  return email ? email : null;
877
878
  }
878
879
 
880
+ export const RUNTIME_SHEET_START_INSERTED_COUNT_HEADER =
881
+ 'x-deepline-runtime-sheet-start-inserted';
882
+ export const RUNTIME_SHEET_START_SKIPPED_COUNT_HEADER =
883
+ 'x-deepline-runtime-sheet-start-skipped';
884
+
885
+ type RuntimeSheetStartAdmissionCounts = {
886
+ inserted: number;
887
+ skipped: number;
888
+ };
889
+
890
+ function readRuntimeSheetStartAdmissionCounts(
891
+ response: Response,
892
+ action: RuntimeApiActionRequest['action'],
893
+ ): RuntimeSheetStartAdmissionCounts | undefined {
894
+ if (action !== 'runtime_sheet_start_with_intent') return undefined;
895
+ const insertedHeader = response.headers.get(
896
+ RUNTIME_SHEET_START_INSERTED_COUNT_HEADER,
897
+ );
898
+ const skippedHeader = response.headers.get(
899
+ RUNTIME_SHEET_START_SKIPPED_COUNT_HEADER,
900
+ );
901
+ if (
902
+ insertedHeader === null ||
903
+ skippedHeader === null ||
904
+ !/^\d+$/.test(insertedHeader) ||
905
+ !/^\d+$/.test(skippedHeader)
906
+ ) {
907
+ return undefined;
908
+ }
909
+ const inserted = Number(insertedHeader);
910
+ const skipped = Number(skippedHeader);
911
+ if (
912
+ !Number.isSafeInteger(inserted) ||
913
+ inserted < 0 ||
914
+ !Number.isSafeInteger(skipped) ||
915
+ skipped < 0
916
+ ) {
917
+ return undefined;
918
+ }
919
+ return { inserted, skipped };
920
+ }
921
+
879
922
  class RuntimeApiResponseTooLargeError extends Error {
880
923
  constructor(
881
924
  readonly action: RuntimeApiActionRequest['action'],
882
925
  readonly limitBytes: number,
883
926
  readonly observedBytes: number,
927
+ readonly admissionCounts?: RuntimeSheetStartAdmissionCounts,
884
928
  ) {
885
929
  super(
886
930
  `Runtime API ${action} response exceeds the ${limitBytes} byte decoded-body budget (observed at least ${observedBytes} bytes).`,
@@ -911,6 +955,7 @@ async function readRuntimeApiResponseJson(input: {
911
955
  input.action,
912
956
  limitBytes,
913
957
  declaredLength,
958
+ readRuntimeSheetStartAdmissionCounts(input.response, input.action),
914
959
  );
915
960
  }
916
961
  if (!input.response.body) return null;
@@ -928,6 +973,7 @@ async function readRuntimeApiResponseJson(input: {
928
973
  input.action,
929
974
  limitBytes,
930
975
  nextBytes,
976
+ readRuntimeSheetStartAdmissionCounts(input.response, input.action),
931
977
  );
932
978
  }
933
979
  chunks.push(value);
@@ -7452,6 +7498,89 @@ function runtimeSheetStartRequestBytes(input: {
7452
7498
  return { bytes: measurement.bytes, exceeded: measurement.exceeded };
7453
7499
  }
7454
7500
 
7501
+ type RuntimeSheetAdmissionPageRunner = (
7502
+ operation: () => Promise<PrepareRuntimeSheetResult>,
7503
+ ) => Promise<PrepareRuntimeSheetResult>;
7504
+
7505
+ async function postRuntimeSheetStartPageWithAdaptiveResponseLimit(
7506
+ context: RuntimeApiContext,
7507
+ input: RuntimeSheetDatasetStartInput,
7508
+ runPage: RuntimeSheetAdmissionPageRunner = (operation) => operation(),
7509
+ ): Promise<PrepareRuntimeSheetResult[]> {
7510
+ const request: RuntimeApiActionRequest = {
7511
+ action:
7512
+ input.stableWriteIntent === true
7513
+ ? 'runtime_sheet_start_with_intent'
7514
+ : 'runtime_sheet_start',
7515
+ input: { ...input, playInput: undefined, pendingRerunAdmission: true },
7516
+ };
7517
+ const preparedBodyJson = JSON.stringify(
7518
+ prepareRetainedPlayPipelinesForTransport(request),
7519
+ );
7520
+ try {
7521
+ return [
7522
+ await runPage(() =>
7523
+ postRuntimeApi<PrepareRuntimeSheetResult>(
7524
+ context,
7525
+ request,
7526
+ preparedBodyJson,
7527
+ ),
7528
+ ),
7529
+ ];
7530
+ } catch (error) {
7531
+ if (
7532
+ !(error instanceof RuntimeApiResponseTooLargeError) ||
7533
+ error.action !== 'runtime_sheet_start_with_intent' ||
7534
+ input.stableWriteIntent !== true ||
7535
+ !error.admissionCounts ||
7536
+ input.rows.length <= 1
7537
+ ) {
7538
+ throw error;
7539
+ }
7540
+
7541
+ // The gateway committed this stable intent before its oversized response
7542
+ // reached the runner. Replay the same attempt in smaller row groups; the
7543
+ // persisted identity makes these admissions idempotent, and the response
7544
+ // headers preserve the counts from the committed full-page operation.
7545
+ const splitAt = Math.floor(input.rows.length / 2);
7546
+ const inputOffset = Math.max(0, Math.floor(input.inputOffset ?? 0));
7547
+ const left = await postRuntimeSheetStartPageWithAdaptiveResponseLimit(
7548
+ context,
7549
+ { ...input, rows: input.rows.slice(0, splitAt) },
7550
+ runPage,
7551
+ );
7552
+ const leftLast = left.at(-1);
7553
+ if (!leftLast) {
7554
+ throw new Error('Runtime sheet response split produced no left page.');
7555
+ }
7556
+ const right = await postRuntimeSheetStartPageWithAdaptiveResponseLimit(
7557
+ context,
7558
+ {
7559
+ ...input,
7560
+ inputOffset: inputOffset + splitAt,
7561
+ ...(leftLast.writeVersion != null
7562
+ ? { writeVersion: leftLast.writeVersion }
7563
+ : {}),
7564
+ rows: input.rows.slice(splitAt),
7565
+ },
7566
+ runPage,
7567
+ );
7568
+ const results = [...left, ...right];
7569
+ const [first, ...rest] = results;
7570
+ if (!first) {
7571
+ throw new Error('Runtime sheet response split produced no pages.');
7572
+ }
7573
+ return [
7574
+ {
7575
+ ...first,
7576
+ inserted: error.admissionCounts.inserted,
7577
+ skipped: error.admissionCounts.skipped,
7578
+ },
7579
+ ...rest.map((result) => ({ ...result, inserted: 0, skipped: 0 })),
7580
+ ];
7581
+ }
7582
+ }
7583
+
7455
7584
  async function startRuntimeSheetDatasetViaGateway(
7456
7585
  context: RuntimeApiContext,
7457
7586
  input: RuntimeSheetDatasetStartInput,
@@ -7467,98 +7596,127 @@ async function startRuntimeSheetDatasetViaGateway(
7467
7596
  // that duplicate payload from both sizing and every actual page request.
7468
7597
  input: { ...pageInput, playInput: undefined, pendingRerunAdmission: true },
7469
7598
  });
7470
- const completeRequest = request(input);
7471
- if (
7472
- !runtimeSheetStartRequestBytes({
7473
- request: completeRequest,
7474
- limitBytes: RUNTIME_SHEET_START_REQUEST_MAX_BYTES,
7475
- }).exceeded
7476
- ) {
7477
- return await postRuntimeApi<PrepareRuntimeSheetResult>(
7478
- context,
7479
- completeRequest,
7480
- );
7481
- }
7482
-
7483
7599
  const requestInput: RuntimeSheetDatasetStartInput = {
7484
7600
  ...input,
7485
- attemptId: input.attemptId?.trim() || runtimeSheetStartIntentId(input),
7601
+ ...(input.stableWriteIntent === true
7602
+ ? {
7603
+ attemptId:
7604
+ input.attemptId?.trim() || runtimeSheetStartIntentId(input),
7605
+ }
7606
+ : {}),
7486
7607
  pendingRerunAdmission: true,
7487
7608
  };
7488
- // Keep every page under the app-function ingress ceiling while preserving
7489
- // the stable write intent, rerun admission, and attempt fence.
7609
+ const completeRequest = request(requestInput);
7610
+ const pageResults: PrepareRuntimeSheetResult[] = [];
7611
+ const startedAt = Date.now();
7612
+ const requestBodyFits = !runtimeSheetStartRequestBytes({
7613
+ request: completeRequest,
7614
+ limitBytes: RUNTIME_SHEET_START_REQUEST_MAX_BYTES,
7615
+ }).exceeded;
7616
+ const shouldPage =
7617
+ (input.stableWriteIntent === true &&
7618
+ input.rows.length > RUNTIME_SHEET_START_MAX_RESPONSE_ROWS) ||
7619
+ !requestBodyFits;
7620
+ const pageRequestInput: RuntimeSheetDatasetStartInput =
7621
+ shouldPage && input.stableWriteIntent !== true
7622
+ ? {
7623
+ ...requestInput,
7624
+ attemptId:
7625
+ input.attemptId?.trim() || runtimeSheetStartIntentId(input),
7626
+ }
7627
+ : requestInput;
7490
7628
  const inputOffset = Math.max(0, Math.floor(input.inputOffset ?? 0));
7491
7629
  const continuationInput: RuntimeSheetDatasetStartInput = {
7492
- ...requestInput,
7630
+ ...pageRequestInput,
7493
7631
  inputOffset,
7494
7632
  rows: [],
7495
7633
  };
7496
- const emptyRequestBytes = runtimeSheetStartRequestBytes({
7497
- request: request(continuationInput),
7498
- limitBytes: RUNTIME_SHEET_START_REQUEST_MAX_BYTES,
7499
- });
7500
- if (emptyRequestBytes.exceeded) {
7501
- throw new Error(
7502
- `Runtime sheet start metadata exceeds the ${RUNTIME_SHEET_START_REQUEST_MAX_BYTES}-byte app request budget before row data is included.`,
7503
- );
7504
- }
7505
- // Leave space for fields returned by the first page and sent on continuation.
7506
- const rowPageBudgetBytes =
7507
- RUNTIME_SHEET_START_REQUEST_MAX_BYTES - emptyRequestBytes.bytes - 4 * 1024;
7508
- if (rowPageBudgetBytes < 1) {
7509
- throw new Error(
7510
- 'Runtime sheet start metadata leaves no room for a row in the app request budget.',
7634
+ if (!shouldPage) {
7635
+ pageResults.push(
7636
+ ...(await postRuntimeSheetStartPageWithAdaptiveResponseLimit(
7637
+ context,
7638
+ requestInput,
7639
+ )),
7511
7640
  );
7512
- }
7513
-
7514
- const pageResults: PrepareRuntimeSheetResult[] = [];
7515
- let pageInput = continuationInput;
7516
- const startedAt = Date.now();
7517
- for await (const page of iteratePlayDatasetInputPages(input.rows, {
7518
- maxPageBytes: rowPageBudgetBytes,
7519
- estimateRowBytes: (row) => {
7520
- const measured = jsonByteLengthUpTo(
7521
- row,
7522
- RUNTIME_SHEET_START_REQUEST_MAX_BYTES,
7523
- );
7524
- return measured.bytes + 1;
7525
- },
7526
- })) {
7527
- const nextInput: RuntimeSheetDatasetStartInput = {
7528
- ...pageInput,
7529
- rows: page.rows,
7530
- inputOffset: inputOffset + page.offset,
7531
- };
7532
- const pageRequest = request(nextInput);
7533
- const pageBytes = runtimeSheetStartRequestBytes({
7534
- request: pageRequest,
7641
+ } else {
7642
+ // Keep every page under the app-function ingress ceiling while preserving
7643
+ // the stable write intent, rerun admission, and attempt fence.
7644
+ const emptyRequestBytes = runtimeSheetStartRequestBytes({
7645
+ request: request(continuationInput),
7535
7646
  limitBytes: RUNTIME_SHEET_START_REQUEST_MAX_BYTES,
7536
7647
  });
7537
- if (pageBytes.exceeded) {
7648
+ if (emptyRequestBytes.exceeded) {
7538
7649
  throw new Error(
7539
- `A runtime sheet start page exceeds the ${RUNTIME_SHEET_START_REQUEST_MAX_BYTES}-byte app request budget.`,
7650
+ `Runtime sheet start metadata exceeds the ${RUNTIME_SHEET_START_REQUEST_MAX_BYTES}-byte app request budget before row data is included.`,
7540
7651
  );
7541
7652
  }
7542
- const result = await postRuntimeApi<PrepareRuntimeSheetResult>(
7543
- context,
7544
- pageRequest,
7545
- );
7546
- pageResults.push(result);
7547
- pageInput = {
7548
- ...nextInput,
7549
- attemptId: result.attemptId ?? nextInput.attemptId,
7550
- attemptOwnerRunId:
7551
- result.attemptOwnerRunId ?? nextInput.attemptOwnerRunId,
7552
- attemptExpiresAt: result.attemptExpiresAt ?? nextInput.attemptExpiresAt,
7553
- attemptSeq: result.attemptSeq ?? nextInput.attemptSeq,
7554
- writeVersion: result.writeVersion ?? nextInput.writeVersion,
7555
- };
7653
+ // Leave space for fields returned by the first page and sent on continuation.
7654
+ const rowPageBudgetBytes =
7655
+ RUNTIME_SHEET_START_REQUEST_MAX_BYTES -
7656
+ emptyRequestBytes.bytes -
7657
+ 4 * 1024;
7658
+ if (rowPageBudgetBytes < 1) {
7659
+ throw new Error(
7660
+ 'Runtime sheet start metadata leaves no room for a row in the app request budget.',
7661
+ );
7662
+ }
7663
+
7664
+ let pageInput = continuationInput;
7665
+ for await (const page of iteratePlayDatasetInputPages(input.rows, {
7666
+ ...(input.stableWriteIntent === true
7667
+ ? { pageSize: RUNTIME_SHEET_START_MAX_RESPONSE_ROWS }
7668
+ : {}),
7669
+ maxPageBytes: rowPageBudgetBytes,
7670
+ estimateRowBytes: (row) => {
7671
+ const measured = jsonByteLengthUpTo(
7672
+ row,
7673
+ RUNTIME_SHEET_START_REQUEST_MAX_BYTES,
7674
+ );
7675
+ return measured.bytes + 1;
7676
+ },
7677
+ })) {
7678
+ const nextInput: RuntimeSheetDatasetStartInput = {
7679
+ ...pageInput,
7680
+ rows: page.rows,
7681
+ inputOffset: inputOffset + page.offset,
7682
+ };
7683
+ const pageRequest = request(nextInput);
7684
+ const pageBytes = runtimeSheetStartRequestBytes({
7685
+ request: pageRequest,
7686
+ limitBytes: RUNTIME_SHEET_START_REQUEST_MAX_BYTES,
7687
+ });
7688
+ if (pageBytes.exceeded) {
7689
+ throw new Error(
7690
+ `A runtime sheet start page exceeds the ${RUNTIME_SHEET_START_REQUEST_MAX_BYTES}-byte app request budget.`,
7691
+ );
7692
+ }
7693
+ const results = await postRuntimeSheetStartPageWithAdaptiveResponseLimit(
7694
+ context,
7695
+ nextInput,
7696
+ );
7697
+ pageResults.push(...results);
7698
+ const result = results.at(-1);
7699
+ if (!result) {
7700
+ throw new Error('Runtime sheet start page returned no result.');
7701
+ }
7702
+ pageInput = {
7703
+ ...nextInput,
7704
+ attemptId: result.attemptId ?? nextInput.attemptId,
7705
+ attemptOwnerRunId:
7706
+ result.attemptOwnerRunId ?? nextInput.attemptOwnerRunId,
7707
+ attemptExpiresAt: result.attemptExpiresAt ?? nextInput.attemptExpiresAt,
7708
+ attemptSeq: result.attemptSeq ?? nextInput.attemptSeq,
7709
+ writeVersion: result.writeVersion ?? nextInput.writeVersion,
7710
+ };
7711
+ }
7556
7712
  }
7557
7713
 
7558
7714
  if (pageResults.length === 0) {
7559
- return await postRuntimeApi<PrepareRuntimeSheetResult>(
7560
- context,
7561
- request(continuationInput),
7715
+ pageResults.push(
7716
+ ...(await postRuntimeSheetStartPageWithAdaptiveResponseLimit(
7717
+ context,
7718
+ continuationInput,
7719
+ )),
7562
7720
  );
7563
7721
  }
7564
7722
  if (pageResults.length === 1) return pageResults[0]!;
@@ -7716,6 +7874,11 @@ export async function* startRuntimeSheetDatasetPages(
7716
7874
  pendingRerunAdmission: true,
7717
7875
  }),
7718
7876
  ) as RuntimeSheetStartMetadata;
7877
+ if (input.stableWriteIntent === true) {
7878
+ frozenMetadata.attemptId = normalizeRuntimeSheetAttemptId(
7879
+ frozenMetadata.attemptId ?? runtimeSheetStartIntentId(input),
7880
+ );
7881
+ }
7719
7882
  const tableNamespace = frozenMetadata.tableNamespace;
7720
7883
  const includePreviousCells = frozenMetadata.includePreviousCells === true;
7721
7884
  const previousCellsBudgetBytes = frozenMetadata.previousCellsBudgetBytes;
@@ -7739,7 +7902,11 @@ export async function* startRuntimeSheetDatasetPages(
7739
7902
  ) + rowBytes;
7740
7903
  const pages: RuntimeSheetStartTransportPage[] = [];
7741
7904
  let duplicateRows = 0;
7742
- if (fullBytes <= RUNNER_TERMINAL_PUSH_MAX_BODY_BYTES) {
7905
+ if (
7906
+ fullBytes <= RUNNER_TERMINAL_PUSH_MAX_BODY_BYTES &&
7907
+ (input.stableWriteIntent !== true ||
7908
+ rowsJson.length <= RUNTIME_SHEET_START_MAX_RESPONSE_ROWS)
7909
+ ) {
7743
7910
  // Keep every previously transportable admission as one transaction, with
7744
7911
  // its existing receiver-side deduplication and optional response fields.
7745
7912
  pages.push({ rowsJson });
@@ -7815,6 +7982,14 @@ export async function* startRuntimeSheetDatasetPages(
7815
7982
  if (page.rowsJson.length === 0) page.inputOffset = inputOffset + index;
7816
7983
  pageBytes += bytes + (page.rowsJson.length > 0 ? 1 : 0);
7817
7984
  page.rowsJson.push(serialized);
7985
+ if (
7986
+ input.stableWriteIntent === true &&
7987
+ page.rowsJson.length >= RUNTIME_SHEET_START_MAX_RESPONSE_ROWS
7988
+ ) {
7989
+ pages.push(page);
7990
+ page = { rowsJson: [] };
7991
+ pageBytes = framingBytes;
7992
+ }
7818
7993
  }
7819
7994
  if (page.rowsJson.length > 0) pages.push(page);
7820
7995
  if (pages.length === 0) {
@@ -7826,7 +8001,8 @@ export async function* startRuntimeSheetDatasetPages(
7826
8001
 
7827
8002
  let writeVersion = frozenMetadata.writeVersion;
7828
8003
  let membershipCapture: boolean | undefined;
7829
- for (const [index, page] of pages.entries()) {
8004
+ let admittedPageCount = 0;
8005
+ for (const page of pages) {
7830
8006
  const pageMetadata = {
7831
8007
  ...frozenMetadata,
7832
8008
  ...(page.inputOffset !== undefined
@@ -7847,47 +8023,54 @@ export async function* startRuntimeSheetDatasetPages(
7847
8023
  'Runtime sheet start page exceeded its preflight body budget.',
7848
8024
  );
7849
8025
  }
7850
- const request = JSON.parse(preparedBodyJson) as Extract<
7851
- RuntimeApiActionRequest,
7852
- { action: RuntimeSheetStartAction }
7853
- >;
7854
- const result = await runPage(() =>
7855
- postRuntimeApi<PrepareRuntimeSheetResult>(
7856
- context,
7857
- request,
7858
- preparedBodyJson,
8026
+ const pageInput: RuntimeSheetDatasetStartInput = {
8027
+ ...pageMetadata,
8028
+ rows: page.rowsJson.map(
8029
+ (serialized) => JSON.parse(serialized) as Record<string, unknown>,
7859
8030
  ),
8031
+ };
8032
+ const results = await postRuntimeSheetStartPageWithAdaptiveResponseLimit(
8033
+ context,
8034
+ pageInput,
8035
+ runPage,
7860
8036
  );
7861
8037
  page.rowsJson.length = 0;
7862
- if (includePreviousCells) {
7863
- assertDatasetAdmissionHistory(result, previousCellsBudgetBytes);
7864
- }
7865
- if (pages.length > 1) {
7866
- const admittedVersion = result.writeVersion;
8038
+ for (const result of results) {
8039
+ if (includePreviousCells) {
8040
+ assertDatasetAdmissionHistory(result, previousCellsBudgetBytes);
8041
+ }
7867
8042
  if (
7868
- typeof admittedVersion !== 'number' ||
7869
- !Number.isSafeInteger(admittedVersion) ||
7870
- admittedVersion <= 0 ||
7871
- (writeVersion != null && result.writeVersion !== writeVersion) ||
7872
- normalizeTableNamespace(result.tableNamespace) !==
7873
- normalizeTableNamespace(tableNamespace) ||
7874
- (result.attemptId !== undefined &&
7875
- result.attemptId !== frozenMetadata.attemptId) ||
7876
- (result.attemptOwnerRunId !== undefined &&
7877
- result.attemptOwnerRunId !== attemptOwnerRunId) ||
7878
- (result.attemptSeq !== undefined && result.attemptSeq !== attemptSeq) ||
7879
- (index > 0 && result.membershipCapture !== membershipCapture)
8043
+ (input.stableWriteIntent === true || pages.length > 1) &&
8044
+ admittedPageCount > 0
7880
8045
  ) {
7881
- throw new Error(
7882
- 'Runtime sheet admission pages disagree on their write intent or identity.',
7883
- );
8046
+ const admittedVersion = result.writeVersion;
8047
+ if (
8048
+ typeof admittedVersion !== 'number' ||
8049
+ !Number.isSafeInteger(admittedVersion) ||
8050
+ admittedVersion <= 0 ||
8051
+ (writeVersion != null && result.writeVersion !== writeVersion) ||
8052
+ normalizeTableNamespace(result.tableNamespace) !==
8053
+ normalizeTableNamespace(tableNamespace) ||
8054
+ (result.attemptId !== undefined &&
8055
+ result.attemptId !== frozenMetadata.attemptId) ||
8056
+ (result.attemptOwnerRunId !== undefined &&
8057
+ result.attemptOwnerRunId !== attemptOwnerRunId) ||
8058
+ (result.attemptSeq !== undefined &&
8059
+ result.attemptSeq !== attemptSeq) ||
8060
+ result.membershipCapture !== membershipCapture
8061
+ ) {
8062
+ throw new Error(
8063
+ 'Runtime sheet admission pages disagree on their write intent or identity.',
8064
+ );
8065
+ }
7884
8066
  }
7885
- writeVersion = result.writeVersion;
8067
+ if (result.writeVersion != null) writeVersion = result.writeVersion;
8068
+ membershipCapture = result.membershipCapture;
8069
+ admittedPageCount += 1;
8070
+ yield admittedPageCount === 1 && duplicateRows > 0
8071
+ ? { ...result, skipped: result.skipped + duplicateRows }
8072
+ : result;
7886
8073
  }
7887
- membershipCapture = result.membershipCapture;
7888
- yield index === 0 && duplicateRows > 0
7889
- ? { ...result, skipped: result.skipped + duplicateRows }
7890
- : result;
7891
8074
  }
7892
8075
  }
7893
8076
 
@@ -19,6 +19,7 @@ export const RUNTIME_SANDBOX_PLACEMENT_POLICIES = {
19
19
  daytonaThenModalV1: 'daytona_then_modal@1',
20
20
  daytonaModalCanaryV1: 'daytona_modal_canary@1',
21
21
  modalOnlyV1: 'modal_only@1',
22
+ modalThenDaytonaV1: 'modal_then_daytona@1',
22
23
  } as const;
23
24
 
24
25
  /** Deployment-scoped policy selection for an isolated runtime lane. */
@@ -169,6 +170,40 @@ const MODAL_ONLY_V1: RuntimeSandboxPlacementPolicy = {
169
170
  cleanupProviders: [RUNTIME_SANDBOX_PROVIDERS.modal],
170
171
  };
171
172
 
173
+ /**
174
+ * Modal first, for when Daytona is unhealthy. It runs on the Daytona lane and
175
+ * artifact, so switching the default needs no new worker. Daytona is used only
176
+ * when the Modal sandbox create fails, before any Play code started. A create
177
+ * that timed out may still produce a Modal sandbox; that sandbox is recorded as
178
+ * a cleanup obligation and never runs the Play. Any later Modal failure stays
179
+ * on Modal.
180
+ */
181
+ const MODAL_THEN_DAYTONA_V1: RuntimeSandboxPlacementPolicy = {
182
+ id: RUNTIME_SANDBOX_PLACEMENT_POLICIES.modalThenDaytonaV1,
183
+ compatibilityRuntimeBackend: PLAY_RUNTIME_BACKENDS.daytona,
184
+ providers: [
185
+ RUNTIME_SANDBOX_PROVIDERS.modal,
186
+ RUNTIME_SANDBOX_PROVIDERS.daytona,
187
+ ],
188
+ transitions: [
189
+ {
190
+ from: RUNTIME_SANDBOX_PROVIDERS.modal,
191
+ to: RUNTIME_SANDBOX_PROVIDERS.daytona,
192
+ stage: 'acquisition',
193
+ reasons: ['provider_capacity_exhausted'],
194
+ },
195
+ ],
196
+ requiredCredentialEnv: [
197
+ 'DAYTONA_API_KEY',
198
+ 'MODAL_TOKEN_ID',
199
+ 'MODAL_TOKEN_SECRET',
200
+ ],
201
+ cleanupProviders: [
202
+ RUNTIME_SANDBOX_PROVIDERS.daytona,
203
+ RUNTIME_SANDBOX_PROVIDERS.modal,
204
+ ],
205
+ };
206
+
172
207
  export const RUNTIME_SANDBOX_PLACEMENT_POLICY_CATALOG: Readonly<
173
208
  Record<RuntimeSandboxPlacementPolicyId, RuntimeSandboxPlacementPolicy>
174
209
  > = {
@@ -178,6 +213,8 @@ export const RUNTIME_SANDBOX_PLACEMENT_POLICY_CATALOG: Readonly<
178
213
  [RUNTIME_SANDBOX_PLACEMENT_POLICIES.daytonaModalCanaryV1]:
179
214
  DAYTONA_MODAL_CANARY_V1,
180
215
  [RUNTIME_SANDBOX_PLACEMENT_POLICIES.modalOnlyV1]: MODAL_ONLY_V1,
216
+ [RUNTIME_SANDBOX_PLACEMENT_POLICIES.modalThenDaytonaV1]:
217
+ MODAL_THEN_DAYTONA_V1,
181
218
  };
182
219
 
183
220
  export function resolveRuntimeSandboxPlacementPolicy(
@@ -214,6 +251,44 @@ export function runtimeSandboxPlacementPolicyForBackend(
214
251
  return null;
215
252
  }
216
253
 
254
+ /**
255
+ * The policy a default launch on `backend` writes: one with no explicit
256
+ * policy, preview namespace or internal placement pin. `operatorDefaultId` is
257
+ * the stored operator switch (`deepline-admin runtime placement set`). It
258
+ * replaces the backend's policy only for the backend that policy runs on, so a
259
+ * Modal-first value does not touch local or Modal-backend launches.
260
+ */
261
+ export function resolveDefaultRuntimeSandboxPlacementPolicy(
262
+ backend: PlayRuntimeBackendId,
263
+ operatorDefaultId?: RuntimeSandboxPlacementPolicyId | null,
264
+ ): RuntimeSandboxPlacementPolicy | null {
265
+ if (operatorDefaultId) {
266
+ const policy = resolveRuntimeSandboxPlacementPolicy(operatorDefaultId);
267
+ if (policy.compatibilityRuntimeBackend === backend) return policy;
268
+ }
269
+ return runtimeSandboxPlacementPolicyForBackend(backend);
270
+ }
271
+
272
+ /**
273
+ * The policy ids an operator may store as the default for `backend`. The
274
+ * frozen `daytona_only@1` compatibility policy is excluded: new launches must
275
+ * not write it, or its retirement would never finish.
276
+ */
277
+ export function operatorDefaultRuntimeSandboxPlacementPolicyIds(
278
+ backend: PlayRuntimeBackendId,
279
+ ): readonly RuntimeSandboxPlacementPolicyId[] {
280
+ return runtimeSandboxPlacementPoliciesForBackend(backend)
281
+ .filter((policy) => policy !== DAYTONA_ONLY_V1)
282
+ .map((policy) => policy.id);
283
+ }
284
+
285
+ /** Whether this build knows `id`. Older or newer releases may not. */
286
+ export function isKnownRuntimeSandboxPlacementPolicyId(
287
+ id: string,
288
+ ): id is RuntimeSandboxPlacementPolicyId {
289
+ return Object.hasOwn(RUNTIME_SANDBOX_PLACEMENT_POLICY_CATALOG, id.trim());
290
+ }
291
+
217
292
  export function runtimeSandboxPlacementPoliciesForBackend(
218
293
  backend: PlayRuntimeBackendId,
219
294
  ): readonly RuntimeSandboxPlacementPolicy[] {
@@ -102,6 +102,7 @@ import {
102
102
  } from '../runner-backends/backends/daytona';
103
103
  import {
104
104
  isRuntimeSandboxCanaryProduction,
105
+ isKnownRuntimeSandboxPlacementPolicyId,
105
106
  resolveLaunchRuntimeSandboxPlacementPolicy,
106
107
  selectRuntimeSandboxCanary,
107
108
  } from '../runtime-sandbox-placement-policy';
@@ -2724,6 +2725,25 @@ async function prepareAbsurdAttempt(input: {
2724
2725
  );
2725
2726
  const runnablePlacementPolicies =
2726
2727
  runtimeSandboxPlacementPoliciesRunnableByWorker(configuredBackend);
2728
+ const storedPlacementPolicyId =
2729
+ launch.runtimeSandboxPlacementPolicyId?.trim();
2730
+ if (
2731
+ storedPlacementPolicyId &&
2732
+ !isKnownRuntimeSandboxPlacementPolicyId(storedPlacementPolicyId)
2733
+ ) {
2734
+ // A newer app release wrote a policy this worker release does not
2735
+ // know (workers behind the app, or rolled back). Park the run for a
2736
+ // worker that knows it instead of spending its attempts.
2737
+ console.error('[absurd-runtime.worker] unknown_placement_policy', {
2738
+ runId: input.runId,
2739
+ runtimeSandboxPlacementPolicyId: storedPlacementPolicyId,
2740
+ workerReleaseId: input.deps.currentReleaseId(),
2741
+ });
2742
+ throw new DeferTask(
2743
+ `Runtime sandbox placement policy "${storedPlacementPolicyId}" is unknown to this worker release. Deploy a worker release that knows it, or clear the operator default for new runs.`,
2744
+ 30,
2745
+ );
2746
+ }
2727
2747
  const launchPlacementPolicy = resolveLaunchRuntimeSandboxPlacementPolicy({
2728
2748
  runtimeBackend: launchBackend,
2729
2749
  runtimeSandboxPlacementPolicyId: launch.runtimeSandboxPlacementPolicyId,