deepline 0.3.545 → 0.3.547

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 (222) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +13 -0
  2. package/dist/bundling-sources/sdk/src/errors.ts +1 -1
  3. package/dist/bundling-sources/sdk/src/http-core.ts +41 -12
  4. package/dist/bundling-sources/sdk/src/index.ts +7 -1
  5. package/dist/bundling-sources/sdk/src/integrations.ts +17 -7
  6. package/dist/bundling-sources/sdk/src/play.ts +71 -0
  7. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  8. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +13 -4
  9. package/dist/bundling-sources/sdk/src/types.ts +33 -0
  10. package/dist/bundling-sources/shared_libs/integration-contracts/calendar-delegation.ts +7 -0
  11. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +2 -0
  12. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +1 -0
  13. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +21 -3
  14. package/dist/bundling-sources/shared_libs/play-data-plane/contracts.ts +5 -0
  15. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +17 -2
  16. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-contract.ts +27 -0
  17. package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +57 -5
  18. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +299 -52
  19. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +18 -1
  20. package/dist/bundling-sources/shared_libs/play-runtime/docflow-decision-tracker.ts +135 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/docflow-fail-open.ts +177 -0
  22. package/dist/bundling-sources/shared_libs/play-runtime/docflow-node-io.ts +99 -2
  23. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +16 -10
  24. package/dist/bundling-sources/shared_libs/play-runtime/fenced-call-diagnostics.ts +211 -0
  25. package/dist/bundling-sources/shared_libs/play-runtime/fleet-sandbox-sweep.ts +40 -3
  26. package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +19 -3
  27. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +18 -4
  28. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +441 -103
  29. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox-egress.ts +322 -0
  30. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +200 -64
  31. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +52 -14
  32. package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +65 -2
  33. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +5 -3
  34. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +53 -2
  35. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +206 -12
  36. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +18 -0
  37. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +68 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +11 -3
  39. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +30 -2
  40. package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +9 -1
  41. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +48 -0
  42. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +36 -2
  43. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +716 -51
  44. package/dist/bundling-sources/shared_libs/plays/docflow-decision-arms.ts +146 -0
  45. package/dist/bundling-sources/shared_libs/plays/docflow-flow-order.ts +94 -0
  46. package/dist/bundling-sources/shared_libs/plays/docflow-unreached-reason.ts +10 -1
  47. package/dist/bundling-sources/shared_libs/plays/docflow.ts +787 -117
  48. package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +8 -2
  49. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +41 -2
  50. package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +13 -0
  51. package/dist/bundling-sources/shared_libs/product-notifications/billing-sales.ts +25 -0
  52. package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +35 -1
  53. package/dist/bundling-sources/shared_libs/security/email-domain.ts +19 -0
  54. package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +58 -0
  55. package/dist/cli/auth-AC5277PI.js +43 -0
  56. package/dist/cli/{auth-VZAMAMFW.mjs → auth-WJEY4IDX.mjs} +6 -6
  57. package/dist/cli/{billing-ASZJDFH2.js → billing-IJITDDRQ.js} +99 -99
  58. package/dist/cli/{billing-DADQUQEZ.mjs → billing-PHJUDYF3.mjs} +11 -11
  59. package/dist/cli/{chunk-FB7UPZ6M.js → chunk-2AHY47SI.js} +3 -3
  60. package/dist/cli/{chunk-CJ7DBYEQ.js → chunk-2HPTLBNB.js} +8 -8
  61. package/dist/cli/{chunk-TI6DTURF.js → chunk-4WAM6TLD.js} +7 -1
  62. package/dist/cli/{chunk-LTCEZWPZ.mjs → chunk-56MEAGWA.mjs} +2 -2
  63. package/dist/cli/{chunk-YWTRCKGD.mjs → chunk-5SFHPMBY.mjs} +11 -11
  64. package/dist/cli/{chunk-D3SXB2NX.js → chunk-ABLTVG3J.js} +41 -41
  65. package/dist/cli/{chunk-KRW727W6.mjs → chunk-AEQ5VWZ5.mjs} +4 -4
  66. package/dist/cli/{chunk-Z7QM244Q.mjs → chunk-CKIRKYW7.mjs} +3 -3
  67. package/dist/cli/{chunk-2JHYYB3F.js → chunk-CSPHSNBW.js} +3 -3
  68. package/dist/cli/{chunk-OGQYAJSO.js → chunk-D6OIEH47.js} +5 -5
  69. package/dist/cli/{chunk-2HFSYH7V.mjs → chunk-DIUNDLSX.mjs} +2 -2
  70. package/dist/cli/{chunk-3M2QH3KA.mjs → chunk-DJI5CLLW.mjs} +22 -12
  71. package/dist/cli/{chunk-N4LADLCO.js → chunk-DZC7LMYM.js} +6 -6
  72. package/dist/cli/{chunk-CXETRZ3G.js → chunk-E2OIYPB4.js} +10 -10
  73. package/dist/cli/{chunk-Z4Y4BLW7.mjs → chunk-ECUD4QPD.mjs} +3 -3
  74. package/dist/cli/{chunk-2GJZLIKW.js → chunk-EITMD3A5.js} +1 -1
  75. package/dist/cli/{chunk-NAN3A4IF.mjs → chunk-ESCVHDNY.mjs} +5 -5
  76. package/dist/cli/{chunk-C6XYSTBW.js → chunk-FFBXLFKV.js} +1 -1
  77. package/dist/cli/{chunk-HLUNTJBO.mjs → chunk-FMQXAOVE.mjs} +4 -4
  78. package/dist/cli/{chunk-HXIR3VQL.mjs → chunk-FZHMNK6F.mjs} +7 -1
  79. package/dist/cli/{chunk-4NZ3OZNO.mjs → chunk-G6KW764N.mjs} +1 -1
  80. package/dist/cli/{chunk-LWPFMYSO.mjs → chunk-G6XTCG3J.mjs} +2 -2
  81. package/dist/cli/{chunk-NCX2JH2F.js → chunk-GIGAYLY6.js} +12 -12
  82. package/dist/cli/{chunk-BLYW6FFB.js → chunk-GJA2PRHJ.js} +2 -2
  83. package/dist/cli/{chunk-G5TV6WLV.js → chunk-GJOGFWX3.js} +20 -20
  84. package/dist/cli/{chunk-7MFATEUC.mjs → chunk-GPAWLXW3.mjs} +2 -2
  85. package/dist/cli/{chunk-DZTVDL2X.js → chunk-GZFZZQL4.js} +289 -268
  86. package/dist/cli/{chunk-XBYQZEUE.mjs → chunk-HARZ4AAX.mjs} +1 -1
  87. package/dist/cli/{chunk-QI57XUGA.js → chunk-HFIFKP3A.js} +5 -5
  88. package/dist/cli/{chunk-WP36UBRY.mjs → chunk-IGAK22XO.mjs} +1 -1
  89. package/dist/cli/{chunk-XMUPZINS.mjs → chunk-IKYN6PLO.mjs} +5 -5
  90. package/dist/cli/{chunk-HPX7LLAM.mjs → chunk-ITLZBDSR.mjs} +3 -3
  91. package/dist/cli/{chunk-QM7PHHYZ.js → chunk-IVFFCAV2.js} +44 -44
  92. package/dist/cli/{chunk-IYJO3RWR.js → chunk-K3GMDSUX.js} +5 -5
  93. package/dist/cli/{chunk-EK5C2R7S.js → chunk-L5J6UJ2X.js} +15 -15
  94. package/dist/cli/{chunk-EWA3M54M.mjs → chunk-L6QE2XVM.mjs} +1 -1
  95. package/dist/cli/{chunk-3NG43NXB.js → chunk-LMLSOHTU.js} +53 -53
  96. package/dist/cli/{chunk-7MHBJU73.js → chunk-MBQELFL7.js} +22 -22
  97. package/dist/cli/{chunk-Z7SXGOIQ.mjs → chunk-MF7PCM6C.mjs} +1 -1
  98. package/dist/cli/{chunk-DGKDCZGC.js → chunk-MO7TGNXB.js} +13 -13
  99. package/dist/cli/{chunk-7P72EGLK.mjs → chunk-MOZEAGSR.mjs} +1 -1
  100. package/dist/cli/{chunk-34UKDHRL.js → chunk-N63U5CRG.js} +26 -26
  101. package/dist/cli/{chunk-5YYWZ43J.js → chunk-NBYFQZ6O.js} +2 -2
  102. package/dist/cli/{chunk-CQBIO6HW.mjs → chunk-NURW5XH4.mjs} +1 -1
  103. package/dist/cli/{chunk-TQKHXMV3.js → chunk-OVYXYTEP.js} +16 -16
  104. package/dist/cli/{chunk-XGEUPU3L.mjs → chunk-PBMO36BP.mjs} +2 -2
  105. package/dist/cli/{chunk-4JQEAYN3.js → chunk-PVQCX6KQ.js} +55 -8
  106. package/dist/cli/{chunk-KYO2FICL.mjs → chunk-QLE3QKJ2.mjs} +5 -5
  107. package/dist/cli/{chunk-2FF3O2Y2.js → chunk-QU3K3IY6.js} +12 -12
  108. package/dist/cli/{chunk-HR5BT42R.js → chunk-REAFIEV5.js} +99 -99
  109. package/dist/cli/{chunk-Y3T5GWYK.mjs → chunk-RMCCB3XY.mjs} +55 -8
  110. package/dist/cli/{chunk-3TCHX7YK.mjs → chunk-RXRC2COC.mjs} +2 -2
  111. package/dist/cli/{chunk-YRQKRQDU.js → chunk-SAJWYN4B.js} +36 -26
  112. package/dist/cli/{chunk-JL5JU3LD.mjs → chunk-TNJG4ZPN.mjs} +3 -3
  113. package/dist/cli/{chunk-NZDZGK35.js → chunk-VNOQEDVC.js} +7 -7
  114. package/dist/cli/{chunk-2CBX43LP.mjs → chunk-VPF54TXQ.mjs} +5 -5
  115. package/dist/cli/{chunk-2HSZCQMT.mjs → chunk-WYT3H6JD.mjs} +1 -1
  116. package/dist/cli/{chunk-GWDPNOA7.mjs → chunk-XMBVHJPR.mjs} +29 -8
  117. package/dist/cli/{chunk-52C6W7FG.mjs → chunk-XNTDTAKC.mjs} +1 -1
  118. package/dist/cli/{chunk-ERLW6RPA.js → chunk-YURGAKI3.js} +2 -2
  119. package/dist/cli/{chunk-GFRJU2KB.js → chunk-YVKLF7RW.js} +2 -2
  120. package/dist/cli/{chunk-7JZ27AFH.mjs → chunk-Z2YGQZWV.mjs} +2 -2
  121. package/dist/cli/command-docs.js +2 -2
  122. package/dist/cli/command-docs.mjs +1 -1
  123. package/dist/cli/{concurrent-runs-help-YP7ALTDB.mjs → concurrent-runs-help-ZNGP563R.mjs} +7 -7
  124. package/dist/cli/concurrent-runs-help-ZYISYOQA.js +21 -0
  125. package/dist/cli/{csv-D5ITFSYI.mjs → csv-VAHQHYYV.mjs} +5 -5
  126. package/dist/cli/{csv-67WT5EGR.js → csv-X6D4ZELE.js} +14 -14
  127. package/dist/cli/{db-SZYBRFYG.mjs → db-4G4S2VOV.mjs} +8 -8
  128. package/dist/cli/{db-GZS76X7R.js → db-YA5ZGVEX.js} +33 -33
  129. package/dist/cli/{describe-YJ7ZLLLI.mjs → describe-EVXEM2S6.mjs} +20 -20
  130. package/dist/cli/describe-GYYSLZLV.js +50 -0
  131. package/dist/cli/describe-core.d.mts +4 -4
  132. package/dist/cli/describe-core.d.ts +4 -4
  133. package/dist/cli/describe-core.js +1 -1
  134. package/dist/cli/describe-core.mjs +1 -1
  135. package/dist/cli/{executions-O5USTYGL.js → executions-5YC7ABF6.js} +10 -10
  136. package/dist/cli/{executions-HMYGR32E.mjs → executions-HR6CTN5M.mjs} +8 -8
  137. package/dist/cli/{feedback-Z3NXWYUO.mjs → feedback-GEU5SPLR.mjs} +7 -7
  138. package/dist/cli/{feedback-RHLFDCRS.js → feedback-MJHSYLFF.js} +15 -15
  139. package/dist/cli/git-FZIQZNI4.js +25 -0
  140. package/dist/cli/{git-CLFKXELB.mjs → git-NPFF6QUS.mjs} +6 -6
  141. package/dist/cli/index.js +150 -150
  142. package/dist/cli/index.mjs +46 -46
  143. package/dist/cli/{integrations-TZ4QEQGV.js → integrations-YPHFI77G.js} +20 -18
  144. package/dist/cli/{integrations-FOACOBQB.mjs → integrations-Z7EGVBHF.mjs} +12 -10
  145. package/dist/cli/{legacy-noops-QRDOS33V.js → legacy-noops-246E3KKG.js} +10 -10
  146. package/dist/cli/{legacy-noops-6F6Y3BV7.mjs → legacy-noops-5IYCFWWX.mjs} +7 -7
  147. package/dist/cli/{mcp-UXRCWOZU.mjs → mcp-WUYGZXPI.mjs} +5 -5
  148. package/dist/cli/{mcp-ETMMDDGB.js → mcp-YTYTW67G.js} +25 -25
  149. package/dist/cli/{monitors-6XEWR46R.mjs → monitors-73DQKCU7.mjs} +27 -9
  150. package/dist/cli/{monitors-DITT7QTV.js → monitors-SA6ILD6Z.js} +121 -103
  151. package/dist/cli/{org-CVSSH73G.mjs → org-WVQRB2KX.mjs} +8 -8
  152. package/dist/cli/{org-4DE37X3L.js → org-X7ELDV7B.js} +90 -90
  153. package/dist/cli/{play-Y5NCHOKK.mjs → play-QI6V2EUQ.mjs} +296 -68
  154. package/dist/cli/{play-RH6P45CI.js → play-QTYOAJPE.js} +898 -670
  155. package/dist/cli/{providers-VHUHC4IZ.mjs → providers-DPVMVDS4.mjs} +8 -8
  156. package/dist/cli/{providers-DU42DLOL.js → providers-XXFLVREV.js} +11 -11
  157. package/dist/cli/{quickstart-XJ43JLEC.js → quickstart-33ISXQJU.js} +7 -7
  158. package/dist/cli/{quickstart-HJY5YYE5.mjs → quickstart-YWGNHULM.mjs} +5 -5
  159. package/dist/cli/{run-JXUS7QFI.js → run-BWHZXLTD.js} +46 -46
  160. package/dist/cli/{run-JAIXHVH7.mjs → run-J6FCAKQC.mjs} +26 -26
  161. package/dist/cli/search-JCWJX2XD.js +32 -0
  162. package/dist/cli/{search-RDMNM2AX.mjs → search-Z3UU3WBB.mjs} +9 -9
  163. package/dist/cli/{search-output-ZKTR3WTJ.mjs → search-output-OJYY4J7E.mjs} +5 -5
  164. package/dist/cli/{search-output-RKAM2HBH.js → search-output-YIPV74ME.js} +7 -7
  165. package/dist/cli/{secrets-TKFVMAYX.js → secrets-UXRJCEN4.js} +17 -17
  166. package/dist/cli/{secrets-WSW3FTF6.mjs → secrets-YZZN2WST.mjs} +8 -8
  167. package/dist/cli/{sessions-724BK6VP.mjs → sessions-ITCGPD7Z.mjs} +7 -7
  168. package/dist/cli/sessions-NA4SJH6Q.js +22 -0
  169. package/dist/cli/{settings-5LJZDAZU.js → settings-LAFYMILP.js} +87 -87
  170. package/dist/cli/{settings-YRC7J75G.mjs → settings-ZP2LSVNM.mjs} +14 -14
  171. package/dist/cli/{setup-2F3DBSOS.js → setup-4AL3XYM5.js} +50 -50
  172. package/dist/cli/{setup-STNPX5MK.mjs → setup-WEQAQSYC.mjs} +10 -10
  173. package/dist/cli/{skills-D5PK56FO.mjs → skills-NQH4HFW2.mjs} +8 -8
  174. package/dist/cli/skills-XZ4Y6SZ7.js +36 -0
  175. package/dist/cli/{tools-WOGWMBA3.mjs → tools-CXK2GSI4.mjs} +19 -19
  176. package/dist/cli/tools-WJQ6Y7E4.js +57 -0
  177. package/dist/cli/{update-PC6XSWMI.mjs → update-3ROF3Z75.mjs} +10 -10
  178. package/dist/cli/update-ZLRLTBRD.js +34 -0
  179. package/dist/cli/{views-IIHT4RYQ.mjs → views-AOUHVGV2.mjs} +8 -8
  180. package/dist/cli/{views-HLCLAPWN.js → views-XJFO5CEH.js} +23 -23
  181. package/dist/cli/{workflow-CCZ2A7DI.js → workflow-GY3DBHXX.js} +19 -19
  182. package/dist/cli/{workflow-HK4MZ7LK.mjs → workflow-KBS2QJK6.mjs} +9 -9
  183. package/dist/{client-DfdUc_MY.d.mts → client-D1uWA2Vc.d.mts} +1 -1
  184. package/dist/{client-BQ6yuSjM.d.ts → client-Hz7SsBXs.d.ts} +1 -1
  185. package/dist/{client-core-3GQ8WMuk.d.ts → client-core-D3Ad7Flt.d.ts} +554 -504
  186. package/dist/{client-core-ClsNRytk.d.mts → client-core-Db_e63Hb.d.mts} +554 -504
  187. package/dist/{compiler-manifest-BWFtsQIC.d.mts → compiler-manifest-BqwVrOri.d.mts} +73 -18
  188. package/dist/{compiler-manifest-BWFtsQIC.d.ts → compiler-manifest-BqwVrOri.d.ts} +73 -18
  189. package/dist/{errors-Lm9_vJHZ.d.ts → errors-BU8FB99X.d.mts} +2 -2
  190. package/dist/{errors-CwKXXtuu.d.mts → errors-DfVN_FUG.d.ts} +2 -2
  191. package/dist/{index-3vJ-V9yw.d.ts → index-BGnvtYGc.d.ts} +6 -1
  192. package/dist/{index-DjwsAt82.d.mts → index-DjZgwpGw.d.mts} +6 -1
  193. package/dist/index.d.mts +28 -8
  194. package/dist/index.d.ts +28 -8
  195. package/dist/index.js +65 -40
  196. package/dist/index.mjs +33 -8
  197. package/dist/install-integrity.json +137 -130
  198. package/dist/plays/bundle-play-file.d.mts +3 -3
  199. package/dist/plays/bundle-play-file.d.ts +3 -3
  200. package/dist/plays/bundle-play-file.mjs +640 -125
  201. package/dist/plays/play-description.d.mts +3 -3
  202. package/dist/plays/play-description.d.ts +3 -3
  203. package/dist/plays/run-request.d.mts +2 -2
  204. package/dist/plays/run-request.d.ts +2 -2
  205. package/dist/release.d.mts +1 -1
  206. package/dist/release.d.ts +1 -1
  207. package/dist/release.js +2 -2
  208. package/dist/release.mjs +1 -1
  209. package/dist/server.d.mts +4 -4
  210. package/dist/server.d.ts +4 -4
  211. package/dist/server.js +11 -11
  212. package/dist/server.mjs +5 -5
  213. package/package.json +1 -1
  214. package/dist/cli/auth-455MB4K6.js +0 -43
  215. package/dist/cli/concurrent-runs-help-GFWXOKF5.js +0 -21
  216. package/dist/cli/describe-ZRGYAEBT.js +0 -50
  217. package/dist/cli/git-RC4XDATD.js +0 -25
  218. package/dist/cli/search-O5VVMXII.js +0 -32
  219. package/dist/cli/sessions-3PWFWCHO.js +0 -22
  220. package/dist/cli/skills-RFOMVXIT.js +0 -36
  221. package/dist/cli/tools-CAO6EVUW.js +0 -57
  222. package/dist/cli/update-L4DQZY3G.js +0 -34
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Runner-internal diagnostics for an execution-fenced (execution-lock) Tool
3
+ * Call in a map batch: when the relay's response arrived, when the result was
4
+ * wrapped, when the call's receipt completion settled, and a watchdog when a
5
+ * response has waited too long for its completion.
6
+ *
7
+ * Platform telemetry, not run log: lines go to the runner's stderr as
8
+ * `[play-runner.fenced-call] {json}` (the `play-runner.*` diagnostic family),
9
+ * never to the customer-visible run log or its event store. Logging only:
10
+ * nothing here schedules, retries or decides; the watchdog timer is unref'd
11
+ * and cleared at settlement. Lines carry a receipt-key digest, the attempt
12
+ * and elapsed times only: no tool input, row key, dataset name or provider
13
+ * body.
14
+ *
15
+ * Bounded per runner context (one run attempt): response and settlement lines
16
+ * for the first `detailedCalls` fenced calls only; overdue warnings for any
17
+ * call, the first `overdueFirst` and then every `overdueEvery`th.
18
+ *
19
+ * Why: a fenced row post once stalled after its relay answered 200 and before
20
+ * its receipt was committed (PR #10713's first Preview run), with no runner
21
+ * line between the two. These lines place the next stall on one side of the
22
+ * wrap or the commit.
23
+ */
24
+
25
+ /** A response this long without its completion is logged as overdue. */
26
+ export const FENCED_CALL_COMPLETION_WATCHDOG_MS = 10_000;
27
+ /** Fenced calls per runner context whose response/settlement lines are kept. */
28
+ export const FENCED_CALL_DETAILED_CALLS = 50;
29
+ /** Overdue warnings kept before sampling. */
30
+ export const FENCED_CALL_OVERDUE_FIRST = 20;
31
+ /** After the first ones, every this-many-th overdue warning is kept. */
32
+ export const FENCED_CALL_OVERDUE_EVERY = 50;
33
+
34
+ export const FENCED_CALL_DIAGNOSTIC_PREFIX = '[play-runner.fenced-call]';
35
+
36
+ export type FencedCallDiagnosticEvent =
37
+ | 'fenced_call_relay_response'
38
+ | 'fenced_call_receipt_settled'
39
+ | 'fenced_call_completion_overdue';
40
+
41
+ export type FencedCallDiagnosticLine = {
42
+ event: FencedCallDiagnosticEvent;
43
+ level: 'info' | 'warn';
44
+ tool: string;
45
+ /** Short digest of the call's result receipt key; never the key itself. */
46
+ call_key_hash: string;
47
+ attempt: number;
48
+ /** Since the call entered the fenced dispatch on this runner. */
49
+ elapsed_ms: number;
50
+ /** Relay responses read so far for this call (retries re-send). */
51
+ responses: number;
52
+ /** Since the latest relay response; absent before the first one. */
53
+ since_response_ms?: number;
54
+ /** Whether the relay response had been turned into the call's result. */
55
+ wrapped: boolean;
56
+ /** Settlement only: whether the receipt completion was recorded. */
57
+ outcome?: 'recorded' | 'failed';
58
+ /**
59
+ * Settlement only: `call` when this call's own receipt write settled
60
+ * before it returned; `map` when the map owns the write and records it
61
+ * after this call returns; `none` for an always-fresh call with no receipt.
62
+ */
63
+ receipt_writer?: 'call' | 'map' | 'none';
64
+ /** Overdue only: overdue calls seen in this runner context, this included. */
65
+ overdue_seen?: number;
66
+ };
67
+
68
+ export type FencedCallDiagnostics = {
69
+ /** A new physical send left the runner; a pending watchdog is disarmed. */
70
+ dispatched(): void;
71
+ /** The relay's response body was read; logs and arms the watchdog. */
72
+ responseArrived(): void;
73
+ /** The response was wrapped into the call's result (before the commit). */
74
+ wrapped(): void;
75
+ /** The call's receipt completion settled; logs once and disarms. */
76
+ settled(outcome: 'recorded' | 'failed'): void;
77
+ };
78
+
79
+ export type FencedCallDiagnosticsBudget = {
80
+ /** Whether a new fenced call's response/settlement lines are kept. */
81
+ admitCall(): boolean;
82
+ /** Counts an overdue call and says whether its warning is kept. */
83
+ admitOverdue(): { keep: boolean; seen: number };
84
+ };
85
+
86
+ export function createFencedCallDiagnosticsBudget(
87
+ limits: {
88
+ detailedCalls?: number;
89
+ overdueFirst?: number;
90
+ overdueEvery?: number;
91
+ } = {},
92
+ ): FencedCallDiagnosticsBudget {
93
+ const detailedCalls = limits.detailedCalls ?? FENCED_CALL_DETAILED_CALLS;
94
+ const overdueFirst = limits.overdueFirst ?? FENCED_CALL_OVERDUE_FIRST;
95
+ const overdueEvery = limits.overdueEvery ?? FENCED_CALL_OVERDUE_EVERY;
96
+ let calls = 0;
97
+ let overdue = 0;
98
+ return {
99
+ admitCall() {
100
+ calls += 1;
101
+ return calls <= detailedCalls;
102
+ },
103
+ admitOverdue() {
104
+ overdue += 1;
105
+ return {
106
+ keep: overdue <= overdueFirst || overdue % overdueEvery === 0,
107
+ seen: overdue,
108
+ };
109
+ },
110
+ };
111
+ }
112
+
113
+ /** The runner's internal diagnostic sink: stderr, never the run log. */
114
+ export function writeFencedCallDiagnostic(
115
+ line: FencedCallDiagnosticLine,
116
+ ): void {
117
+ console.warn(`${FENCED_CALL_DIAGNOSTIC_PREFIX} ${JSON.stringify(line)}`);
118
+ }
119
+
120
+ export function startFencedCallDiagnostics(input: {
121
+ tool: string;
122
+ callKeyHash: string;
123
+ attempt: number;
124
+ receiptWriter: 'call' | 'map' | 'none';
125
+ budget: FencedCallDiagnosticsBudget;
126
+ log?: (line: FencedCallDiagnosticLine) => void;
127
+ watchdogMs?: number;
128
+ }): FencedCallDiagnostics {
129
+ const watchdogMs = input.watchdogMs ?? FENCED_CALL_COMPLETION_WATCHDOG_MS;
130
+ const log = input.log ?? writeFencedCallDiagnostic;
131
+ const detailed = input.budget.admitCall();
132
+ const startedAtMs = Date.now();
133
+ let responses = 0;
134
+ let lastResponseAtMs: number | null = null;
135
+ let wrapped = false;
136
+ let watchdog: ReturnType<typeof setTimeout> | null = null;
137
+ let settled = false;
138
+
139
+ const line = (
140
+ event: FencedCallDiagnosticEvent,
141
+ level: 'info' | 'warn',
142
+ nowMs: number,
143
+ ): FencedCallDiagnosticLine => ({
144
+ event,
145
+ level,
146
+ tool: input.tool,
147
+ call_key_hash: input.callKeyHash,
148
+ attempt: input.attempt,
149
+ elapsed_ms: Math.max(0, nowMs - startedAtMs),
150
+ responses,
151
+ ...(lastResponseAtMs === null
152
+ ? {}
153
+ : { since_response_ms: Math.max(0, nowMs - lastResponseAtMs) }),
154
+ wrapped,
155
+ });
156
+ const disarm = () => {
157
+ if (watchdog === null) return;
158
+ clearTimeout(watchdog);
159
+ watchdog = null;
160
+ };
161
+ const emit = (value: FencedCallDiagnosticLine): void => {
162
+ // A diagnostic must never fail the call it describes.
163
+ try {
164
+ log(value);
165
+ } catch {
166
+ // The sink owns its own failure reporting.
167
+ }
168
+ };
169
+
170
+ return {
171
+ dispatched() {
172
+ if (settled) return;
173
+ disarm();
174
+ },
175
+ responseArrived() {
176
+ if (settled) return;
177
+ responses += 1;
178
+ const nowMs = Date.now();
179
+ lastResponseAtMs = nowMs;
180
+ if (detailed) emit(line('fenced_call_relay_response', 'info', nowMs));
181
+ disarm();
182
+ watchdog = setTimeout(() => {
183
+ watchdog = null;
184
+ if (settled) return;
185
+ const admitted = input.budget.admitOverdue();
186
+ if (!admitted.keep) return;
187
+ emit({
188
+ ...line('fenced_call_completion_overdue', 'warn', Date.now()),
189
+ overdue_seen: admitted.seen,
190
+ });
191
+ }, watchdogMs);
192
+ (watchdog as { unref?: () => void }).unref?.();
193
+ },
194
+ wrapped() {
195
+ wrapped = true;
196
+ },
197
+ settled(outcome) {
198
+ if (settled) return;
199
+ settled = true;
200
+ disarm();
201
+ // A call that failed before any relay response is already reported by
202
+ // tool_call_failed; only a post-response settlement is news here.
203
+ if (!detailed || (outcome === 'failed' && responses === 0)) return;
204
+ emit({
205
+ ...line('fenced_call_receipt_settled', 'info', Date.now()),
206
+ outcome,
207
+ receipt_writer: input.receiptWriter,
208
+ });
209
+ },
210
+ };
211
+ }
@@ -44,6 +44,13 @@ export type FleetSandboxSweepAdapter = Readonly<{
44
44
  scope: FleetSandboxSweepScope;
45
45
  /** Minimum spacing between pass starts. */
46
46
  intervalMs: number;
47
+ /**
48
+ * Loop-driven owners only: spread passes across a fleet that boots
49
+ * together. Each interval is scaled by a random factor in
50
+ * [1 - jitterRatio, 1 + jitterRatio], and the first pass waits a random
51
+ * [0, 2 * jitterRatio * intervalMs]. In [0, 0.5]; absent: no jitter.
52
+ */
53
+ jitterRatio?: number;
47
54
  /**
48
55
  * One pass: enumerate, apply the provider's age, ownership and dry-run
49
56
  * policy, and terminate or restore cleanup for each dead sandbox. A
@@ -81,6 +88,18 @@ export function assertFleetSandboxSweepAdapters(
81
88
  `Fleet sandbox sweep for ${adapter.provider} needs a positive integer interval.`,
82
89
  );
83
90
  }
91
+ if (
92
+ adapter.jitterRatio !== undefined &&
93
+ !(
94
+ Number.isFinite(adapter.jitterRatio) &&
95
+ adapter.jitterRatio >= 0 &&
96
+ adapter.jitterRatio <= 0.5
97
+ )
98
+ ) {
99
+ throw new FleetSandboxSweepAdapterError(
100
+ `Fleet sandbox sweep for ${adapter.provider} needs a jitter ratio in [0, 0.5].`,
101
+ );
102
+ }
84
103
  if (adapter.scope === 'provider_inventory') {
85
104
  const support = runtimeSandboxProviderProfile(adapter.provider)
86
105
  .capabilities.orphanEnumeration;
@@ -116,17 +135,26 @@ export function createFleetSandboxSweep(input: {
116
135
  adapters: readonly FleetSandboxSweepAdapter[];
117
136
  /** Injected clock; read on every call so fake timers apply. */
118
137
  now?: () => number;
138
+ /** Injected uniform [0, 1) source for `jitterRatio`. */
139
+ random?: () => number;
119
140
  }): FleetSandboxSweep {
120
141
  assertFleetSandboxSweepAdapters(input.adapters);
121
142
  const now = input.now ?? (() => Date.now());
143
+ const random = input.random ?? Math.random;
144
+ const createdAtMs = now();
122
145
  const states: PassState[] = input.adapters.map((adapter) => ({
123
146
  adapter,
124
147
  running: null,
125
- nextDueAtMs: 0,
148
+ nextDueAtMs: adapter.jitterRatio
149
+ ? createdAtMs + 2 * adapter.jitterRatio * random() * adapter.intervalMs
150
+ : 0,
126
151
  }));
127
152
 
128
153
  const start = (state: PassState, startedAtMs: number): void => {
129
- state.nextDueAtMs = startedAtMs + state.adapter.intervalMs;
154
+ const jitter = state.adapter.jitterRatio ?? 0;
155
+ state.nextDueAtMs =
156
+ startedAtMs +
157
+ state.adapter.intervalMs * (1 + jitter * (2 * random() - 1));
130
158
  // The async wrapper turns a synchronous throw into a rejection, so it is
131
159
  // reported like any other failed pass and never reaches the next Adapter.
132
160
  const pass: Promise<void> = (async () => {
@@ -184,11 +212,20 @@ export function createFleetSandboxSweep(input: {
184
212
  /**
185
213
  * Timer-driven owner: run every Adapter's pass once now, then once per its
186
214
  * interval, skipping (and reporting) a tick whose previous pass still runs.
187
- * Timers are unref'd so the sweep never keeps a process alive.
215
+ * Timers are unref'd so the sweep never keeps a process alive. `jitterRatio`
216
+ * is loop-driven only: fixed timers would silently ignore it, so an Adapter
217
+ * that sets it is refused before any timer starts.
188
218
  */
189
219
  export function startFleetSandboxSweepTimers(input: {
190
220
  adapters: readonly FleetSandboxSweepAdapter[];
191
221
  }): { stop: () => void; sweep: FleetSandboxSweep } {
222
+ for (const adapter of input.adapters) {
223
+ if (adapter.jitterRatio !== undefined) {
224
+ throw new FleetSandboxSweepAdapterError(
225
+ `Fleet sandbox sweep for ${adapter.provider} sets jitterRatio, which timer-driven owners do not support.`,
226
+ );
227
+ }
228
+ }
192
229
  const sweep = createFleetSandboxSweep({ adapters: input.adapters });
193
230
  const intervals = input.adapters.map((adapter) => {
194
231
  const interval = setInterval(() => {
@@ -19,6 +19,14 @@ export {
19
19
  modalSandboxResourcesForPlay,
20
20
  } from './worker-api-types';
21
21
  export const MODAL_SANDBOX_MEMORY_MIB = 1024;
22
+ /**
23
+ * The Modal region every Play sandbox is created in: us-east (Virginia), next
24
+ * to the Fly iad receipt gateway, execution relay and workers it talks to.
25
+ * Unpinned, Modal places a sandbox anywhere: about 36% of Production Modal
26
+ * runs landed overseas (Europe, Israel), each sandbox-to-relay round trip
27
+ * 94-117 ms instead of 14-27 ms. A narrow region costs 1.75x Modal's base price.
28
+ */
29
+ export const MODAL_SANDBOX_REGIONS: readonly string[] = ['us-east'];
22
30
 
23
31
  export function isModalPreviewEvaluation(input: {
24
32
  runtimeSchedulerSchema: string | null | undefined;
@@ -92,6 +100,16 @@ function cidrAllowlist(raw: string | null | undefined): string[] | null {
92
100
  return values.length > 0 ? values : null;
93
101
  }
94
102
 
103
+ /** Production refuses a Modal sandbox without an outbound allowlist. */
104
+ export class ModalSandboxAllowlistRequiredError extends Error {
105
+ constructor() {
106
+ super(
107
+ 'DEEPLINE_DAYTONA_NETWORK_ALLOW_LIST is required for the Modal capacity fallback in production. Refusing to run customer code with unrestricted outbound network access.',
108
+ );
109
+ this.name = 'ModalSandboxAllowlistRequiredError';
110
+ }
111
+ }
112
+
95
113
  export function resolveModalSandboxNetworkPolicy(input: {
96
114
  runtimeSchedulerSchema: string | null | undefined;
97
115
  env?: NodeJS.ProcessEnv;
@@ -105,9 +123,7 @@ export function resolveModalSandboxNetworkPolicy(input: {
105
123
  env.NODE_ENV === 'production' &&
106
124
  !isIsolatedRuntimeSchedulerSchema(input.runtimeSchedulerSchema)
107
125
  ) {
108
- throw new Error(
109
- 'DEEPLINE_DAYTONA_NETWORK_ALLOW_LIST is required for the Modal capacity fallback in production. Refusing to run customer code with unrestricted outbound network access.',
110
- );
126
+ throw new ModalSandboxAllowlistRequiredError();
111
127
  }
112
128
  return { outboundCidrAllowlist };
113
129
  }
@@ -71,6 +71,7 @@ import {
71
71
  } from '../tool-http-errors';
72
72
  import {
73
73
  augmentSheetContractWithDatasetFields,
74
+ datasetDisplayColumnOrder,
74
75
  datasetWrittenColumnOrder,
75
76
  } from '../../play-data-plane/sheet-contract';
76
77
  import { nextWorkCounterInvocationSeq } from '../runtime-work-counters';
@@ -2506,10 +2507,21 @@ async function run(
2506
2507
  persistedRows: number;
2507
2508
  succeededRows: number;
2508
2509
  failedRows: number;
2509
- /** Stored column names in the order this run wrote them. */
2510
+ /** Stored column names in the order this run wrote them. Append-only. */
2510
2511
  columns?: string[];
2512
+ /** The dataset's sheet contract; its `columnOrder` leads the emitted order. */
2513
+ sheetContract?: PlaySheetContract;
2511
2514
  }
2512
2515
  >();
2516
+ // The order events carry: authored `columnOrder` first, then written order.
2517
+ // A permutation of the written set, so the ledger's longest list stays whole.
2518
+ const emittedDatasetColumns = (settlement: {
2519
+ columns?: string[];
2520
+ sheetContract?: PlaySheetContract;
2521
+ }): string[] =>
2522
+ settlement.sheetContract
2523
+ ? datasetDisplayColumnOrder(settlement.columns ?? [], settlement.sheetContract)
2524
+ : [...(settlement.columns ?? [])];
2513
2525
  const runtimeSheetAttemptKey = (input: {
2514
2526
  playName: string;
2515
2527
  runId: string;
@@ -2845,7 +2857,7 @@ async function run(
2845
2857
  failedRows: settlement.failedRows,
2846
2858
  complete: false,
2847
2859
  ...(settlement.columns?.length
2848
- ? { columns: settlement.columns }
2860
+ ? { columns: emittedDatasetColumns(settlement) }
2849
2861
  : {}),
2850
2862
  at: event.at,
2851
2863
  },
@@ -3069,6 +3081,7 @@ async function run(
3069
3081
  rows: items,
3070
3082
  existing: settlement.columns,
3071
3083
  });
3084
+ settlement.sheetContract = sheetContract;
3072
3085
  runtimeMapDatasetSettlements.set(datasetId, settlement);
3073
3086
  emitRunnerEvent(
3074
3087
  {
@@ -3084,7 +3097,7 @@ async function run(
3084
3097
  failedRows: 0,
3085
3098
  complete: false,
3086
3099
  ...(settlement.columns.length > 0
3087
- ? { columns: settlement.columns }
3100
+ ? { columns: emittedDatasetColumns(settlement) }
3088
3101
  : {}),
3089
3102
  // ADR 0019 dataset-grain row birth. These rows entered from
3090
3103
  // play-body code, so the only witnessed fact is how many arrived at
@@ -3463,6 +3476,7 @@ async function run(
3463
3476
  outputFields: input.outputFields,
3464
3477
  existing: settlement.columns,
3465
3478
  });
3479
+ settlement.sheetContract = sheetContract;
3466
3480
  runtimeMapDatasetSettlements.set(datasetId, settlement);
3467
3481
  emitWorkerLog(
3468
3482
  `[perf] runtime map persist table=${input.tableNamespace} rows=${input.rows.length} updated=${result.updated} accepted=${committedTerminalRows} stale=${staleKeys.size} elapsed_ms=${Date.now() - persistStartedAt}`,
@@ -3747,7 +3761,7 @@ async function run(
3747
3761
  failedRows: settlement.failedRows,
3748
3762
  complete: true,
3749
3763
  ...(settlement.columns?.length
3750
- ? { columns: settlement.columns }
3764
+ ? { columns: emittedDatasetColumns(settlement) }
3751
3765
  : {}),
3752
3766
  at: Date.now(),
3753
3767
  },