deepline 0.3.552 → 0.3.554

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 (323) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +107 -12
  2. package/dist/bundling-sources/sdk/src/compat.ts +239 -87
  3. package/dist/bundling-sources/sdk/src/config.ts +113 -2
  4. package/dist/bundling-sources/sdk/src/errors.ts +2 -0
  5. package/dist/bundling-sources/sdk/src/http-core.ts +118 -8
  6. package/dist/bundling-sources/sdk/src/index.ts +2 -0
  7. package/dist/bundling-sources/sdk/src/integrations.ts +6 -4
  8. package/dist/bundling-sources/sdk/src/play.ts +3 -0
  9. package/dist/bundling-sources/sdk/src/plays/run-request.ts +1 -1
  10. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  11. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +8 -1
  12. package/dist/bundling-sources/sdk/src/tool-calls.ts +2 -1
  13. package/dist/bundling-sources/sdk/src/tool-failure-hint.ts +104 -0
  14. package/dist/bundling-sources/sdk/src/types.ts +9 -1
  15. package/dist/bundling-sources/shared_libs/integration-contracts/billing-entitlements.ts +4 -2
  16. package/dist/bundling-sources/shared_libs/integration-contracts/billing-plan-skus.ts +25 -0
  17. package/dist/bundling-sources/shared_libs/monitors/action-actor.ts +2 -0
  18. package/dist/bundling-sources/shared_libs/monitors/billing/credit-recovery.ts +58 -4
  19. package/dist/bundling-sources/shared_libs/monitors/billing/policy-builders.ts +8 -0
  20. package/dist/bundling-sources/shared_libs/monitors/billing/pricing.ts +11 -0
  21. package/dist/bundling-sources/shared_libs/monitors/billing/types.ts +13 -0
  22. package/dist/bundling-sources/shared_libs/monitors/deactivation-reasons.ts +103 -5
  23. package/dist/bundling-sources/shared_libs/monitors/fleets/converge-admission.ts +133 -0
  24. package/dist/bundling-sources/shared_libs/monitors/fleets/fence-attention.ts +165 -0
  25. package/dist/bundling-sources/shared_libs/monitors/fleets/fence-release.ts +726 -0
  26. package/dist/bundling-sources/shared_libs/monitors/fleets/fence-walk.ts +274 -0
  27. package/dist/bundling-sources/shared_libs/monitors/fleets/issues.ts +1 -0
  28. package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +28 -0
  29. package/dist/bundling-sources/shared_libs/monitors/fleets/provider-bulk-wait.ts +126 -0
  30. package/dist/bundling-sources/shared_libs/monitors/fleets/shared-payload.ts +189 -0
  31. package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +28 -0
  32. package/dist/bundling-sources/shared_libs/monitors/inbound-publish-key.ts +4 -0
  33. package/dist/bundling-sources/shared_libs/monitors/inventory-counter-errors.ts +25 -0
  34. package/dist/bundling-sources/shared_libs/monitors/org-monitor-limits.ts +65 -0
  35. package/dist/bundling-sources/shared_libs/monitors/package.json +9 -0
  36. package/dist/bundling-sources/shared_libs/monitors/provider-callback-verification.ts +152 -1
  37. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +6 -0
  38. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-capability.ts +390 -10
  39. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-errors.ts +34 -0
  40. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-identity-claims.ts +66 -30
  41. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-state.ts +30 -0
  42. package/dist/bundling-sources/shared_libs/monitors/provider-resource-failure.ts +26 -3
  43. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +41 -13
  44. package/dist/bundling-sources/shared_libs/monitors/signal-radars/raw-receipt-causes.ts +219 -0
  45. package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +21 -10
  46. package/dist/bundling-sources/shared_libs/monitors/starter-templates.ts +13 -0
  47. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +6 -0
  48. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-integrations.ts +13 -0
  49. package/dist/bundling-sources/shared_libs/observability/dlq.ts +1 -1
  50. package/dist/bundling-sources/shared_libs/observability/log-metadata.ts +5 -3
  51. package/dist/bundling-sources/shared_libs/observability/queue-health.ts +10 -1
  52. package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
  53. package/dist/bundling-sources/shared_libs/observability/redaction.ts +24 -1
  54. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +168 -41
  55. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +1 -2
  56. package/dist/bundling-sources/shared_libs/play-data-plane/preview-r2-oidc.ts +188 -0
  57. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +170 -16
  58. package/dist/bundling-sources/shared_libs/play-data-plane/runtime-sheet-storage-contract.ts +5 -0
  59. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +68 -2
  60. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +444 -39
  61. package/dist/bundling-sources/shared_libs/play-runtime/ctx-fetch-caller-deadline.ts +200 -0
  62. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +6 -0
  63. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +21 -1
  64. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +3 -2
  65. package/dist/bundling-sources/shared_libs/play-runtime/durable-summary-events.ts +70 -2
  66. package/dist/bundling-sources/shared_libs/play-runtime/durable-tool-identity.ts +3 -3
  67. package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +16 -0
  68. package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +72 -0
  69. package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +1 -0
  70. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +7 -1
  71. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +62 -0
  72. package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +74 -3
  73. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +31 -3
  74. package/dist/bundling-sources/shared_libs/play-runtime/play-http-request.ts +6 -0
  75. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +8 -0
  76. package/dist/bundling-sources/shared_libs/play-runtime/query-result-dataset.ts +19 -0
  77. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +39 -2
  78. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +9 -1
  79. package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +33 -0
  80. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-contract.ts +24 -0
  81. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +254 -44
  82. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +87 -6
  83. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +241 -10
  84. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox-egress.ts +161 -14
  85. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +16 -3
  86. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-compression.ts +37 -0
  87. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +9 -0
  88. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +259 -52
  89. package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +13 -0
  90. package/dist/bundling-sources/shared_libs/play-runtime/runtime-constants.ts +30 -0
  91. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +62 -1
  92. package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +36 -0
  93. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-transition.ts +36 -0
  94. package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +206 -2
  95. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +42 -0
  96. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +185 -64
  97. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-slot-ledger.ts +157 -0
  98. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +110 -2
  99. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-listener-hint.ts +323 -0
  100. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/executor-attempt-standing.ts +72 -0
  101. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-storage.ts +23 -4
  102. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-workspace-purge.ts +199 -0
  103. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +632 -66
  104. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +517 -16
  105. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +1 -1
  106. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-value-storage.ts +9 -0
  107. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +599 -2
  108. package/dist/bundling-sources/shared_libs/play-runtime/secret-resolution-retry-policy.ts +26 -1
  109. package/dist/bundling-sources/shared_libs/play-runtime/startup-read-tool-ids.ts +60 -0
  110. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +51 -0
  111. package/dist/bundling-sources/shared_libs/play-runtime/tool-call-retry-facts.ts +2 -0
  112. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +113 -3
  113. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +5 -7
  114. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +2 -0
  115. package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +3 -0
  116. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +40 -5
  117. package/dist/bundling-sources/shared_libs/plays/deploy/api-client.ts +3 -0
  118. package/dist/bundling-sources/shared_libs/plays/deploy/control-plane-types.ts +16 -0
  119. package/dist/bundling-sources/shared_libs/plays/deploy/run-deployment.ts +10 -41
  120. package/dist/bundling-sources/shared_libs/plays/extension-bridge.ts +33 -0
  121. package/dist/bundling-sources/shared_libs/plays/row-identity.ts +18 -1
  122. package/dist/bundling-sources/shared_libs/plays/tool-execution-error.ts +108 -0
  123. package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +14 -0
  124. package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +171 -0
  125. package/dist/bundling-sources/shared_libs/product-notifications/events.ts +27 -1
  126. package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +9 -24
  127. package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +178 -5
  128. package/dist/bundling-sources/shared_libs/security/signup-email-dns-screen.ts +148 -0
  129. package/dist/bundling-sources/shared_libs/tool-execution-error.ts +108 -0
  130. package/dist/cli/{auth-KVSBJZOX.mjs → auth-HJUNW7T2.mjs} +8 -7
  131. package/dist/cli/auth-SP6SKZJZ.js +44 -0
  132. package/dist/cli/{billing-FQREA7UA.js → billing-4TSA5HEC.js} +297 -161
  133. package/dist/cli/{billing-54RHFEBI.mjs → billing-SJYRJAQ2.mjs} +197 -61
  134. package/dist/cli/{chunk-4MK42735.js → chunk-2HMN5H54.js} +215 -130
  135. package/dist/cli/{chunk-UBKA33KY.mjs → chunk-2MGZAI54.mjs} +17 -0
  136. package/dist/cli/{chunk-EOPEYCY7.mjs → chunk-2ORPFQUA.mjs} +18 -18
  137. package/dist/cli/{chunk-RQZQVFCJ.js → chunk-2OVHNHCF.js} +2 -2
  138. package/dist/cli/{chunk-QX7LFGJR.mjs → chunk-33WRQSQ2.mjs} +1874 -91
  139. package/dist/cli/{chunk-UPMRIVZB.js → chunk-3IKGZ4CG.js} +74 -13
  140. package/dist/cli/{chunk-EUPVF4SU.mjs → chunk-3Z4VFCXO.mjs} +8 -8
  141. package/dist/cli/{chunk-GKYAYLRI.js → chunk-4DOFGIEJ.js} +27 -31
  142. package/dist/cli/{chunk-4TALT2M3.mjs → chunk-52Q5KETX.mjs} +69 -3
  143. package/dist/cli/{chunk-RBEUVDZF.js → chunk-5CYZHOKI.js} +249 -107
  144. package/dist/cli/{chunk-LX35AXTN.mjs → chunk-5TYLSS4Q.mjs} +6 -6
  145. package/dist/cli/{chunk-IYSTRCLX.mjs → chunk-62AUAWQV.mjs} +4 -4
  146. package/dist/cli/{chunk-ZIAXDBXX.mjs → chunk-62HWJXST.mjs} +17 -21
  147. package/dist/cli/{chunk-QY3ZNU6Z.mjs → chunk-6EXOAT6T.mjs} +2 -2
  148. package/dist/cli/{chunk-EITMD3A5.js → chunk-6VLFQZK6.js} +8 -8
  149. package/dist/cli/{chunk-ADRC5I3R.js → chunk-7OWI736E.js} +30 -30
  150. package/dist/cli/{chunk-NURW5XH4.mjs → chunk-ASB47RXJ.mjs} +1 -1
  151. package/dist/cli/{chunk-PTVD2GVQ.mjs → chunk-B6HO2XWH.mjs} +13 -13
  152. package/dist/cli/{chunk-YJHE3O5M.mjs → chunk-BOZAP2EM.mjs} +141 -56
  153. package/dist/cli/chunk-BVXIGOBZ.js +32 -0
  154. package/dist/cli/{chunk-XDVT3GOM.js → chunk-CFJFUVX2.js} +18 -1
  155. package/dist/cli/{chunk-WE5HES3H.mjs → chunk-D6Z6POKE.mjs} +151 -43
  156. package/dist/cli/{chunk-AZQ264ID.mjs → chunk-DSKSFFK2.mjs} +1 -1
  157. package/dist/cli/{chunk-SHLFOPD6.js → chunk-DUBXUAAO.js} +5 -5
  158. package/dist/cli/{chunk-V436Z54K.js → chunk-E2G2DNAB.js} +3 -1
  159. package/dist/cli/{chunk-HO3XK3R7.js → chunk-E74KGKFZ.js} +8 -8
  160. package/dist/cli/{chunk-77AAAGVB.js → chunk-ECHKAC7M.js} +2 -2
  161. package/dist/cli/{chunk-KWSH5T7K.js → chunk-EN5NHCCQ.js} +21 -21
  162. package/dist/cli/{chunk-6RZOWL2V.mjs → chunk-F7CMRKSK.mjs} +1 -1
  163. package/dist/cli/{chunk-JWUAX6OP.js → chunk-FBAFX43W.js} +11 -11
  164. package/dist/cli/{chunk-AQWQ2BFX.mjs → chunk-FXQ3JKE3.mjs} +1 -1
  165. package/dist/cli/{chunk-QPKH23EC.mjs → chunk-GA2M3G3Y.mjs} +5 -5
  166. package/dist/cli/{chunk-G4O75EXF.js → chunk-GHT2NDL7.js} +18 -18
  167. package/dist/cli/{chunk-MF2GHZDO.js → chunk-GRZENGNE.js} +2 -2
  168. package/dist/cli/{chunk-4UUR4TCH.js → chunk-IVZKMJUK.js} +1875 -92
  169. package/dist/cli/{chunk-FTJLJCE5.mjs → chunk-KVBQY4ST.mjs} +3 -3
  170. package/dist/cli/{chunk-S5S355UY.mjs → chunk-KZHBDMGF.mjs} +12 -12
  171. package/dist/cli/{chunk-BBTKAASQ.js → chunk-LFQJW4S2.js} +42 -1
  172. package/dist/cli/{chunk-6ZORHRKB.mjs → chunk-LRZGS6RZ.mjs} +2 -0
  173. package/dist/cli/{chunk-2WFPHBR4.js → chunk-LY5MMXFF.js} +47 -29
  174. package/dist/cli/{chunk-BAIST2BR.js → chunk-M7STM3MZ.js} +36 -36
  175. package/dist/cli/{chunk-SL6MYJYM.js → chunk-MJTVX4QK.js} +35 -35
  176. package/dist/cli/{chunk-45PVGZST.js → chunk-OPTV7D2V.js} +508 -361
  177. package/dist/cli/{chunk-PFO3ISXA.js → chunk-OVEYWO4H.js} +174 -129
  178. package/dist/cli/{chunk-BGBJV26E.mjs → chunk-PC2FTUCP.mjs} +4 -4
  179. package/dist/cli/{chunk-WLN3SUIA.js → chunk-PQQMPUCZ.js} +3 -3
  180. package/dist/cli/{chunk-HYC4MKGK.mjs → chunk-Q7ACILL2.mjs} +5 -5
  181. package/dist/cli/{chunk-CBV7AKWM.js → chunk-R6DZ6NQ2.js} +5 -5
  182. package/dist/cli/{chunk-57VZVF5D.mjs → chunk-RBBTCYQB.mjs} +3 -3
  183. package/dist/cli/{chunk-F2LH7TGF.js → chunk-RTHMGSZX.js} +21 -21
  184. package/dist/cli/{chunk-YLTMXJFC.mjs → chunk-S6W6SJ6E.mjs} +158 -16
  185. package/dist/cli/chunk-STXDSVQZ.mjs +32 -0
  186. package/dist/cli/{chunk-WEHCBH5R.mjs → chunk-TGUQET3O.mjs} +67 -6
  187. package/dist/cli/{chunk-IHRKLXZN.js → chunk-TJ6HLN56.js} +5 -5
  188. package/dist/cli/{chunk-3FD5EQ62.js → chunk-TOO3YM5N.js} +6 -7
  189. package/dist/cli/{chunk-QILKGXYF.mjs → chunk-UBBYHB2B.mjs} +2 -2
  190. package/dist/cli/{chunk-6PRW5UBA.mjs → chunk-UC4BDZKI.mjs} +299 -69
  191. package/dist/cli/{chunk-634ZDA3F.js → chunk-UNNOZKRT.js} +1 -1
  192. package/dist/cli/{chunk-IDVVIXPJ.js → chunk-UOT7HPBH.js} +41 -41
  193. package/dist/cli/{chunk-6YCA5NKJ.js → chunk-UYCZFQYQ.js} +12 -12
  194. package/dist/cli/{chunk-7IKQKKNX.js → chunk-VIUUTEHY.js} +90 -24
  195. package/dist/cli/{chunk-Z5TSLLOW.mjs → chunk-VLO5NFH2.mjs} +63 -18
  196. package/dist/cli/{chunk-U7QRMBIY.mjs → chunk-VQ75KX7G.mjs} +5 -5
  197. package/dist/cli/{chunk-4NQF6KJ3.js → chunk-VV4XGZ24.js} +13 -13
  198. package/dist/cli/{chunk-FSIVF2SI.mjs → chunk-VZGLIK5U.mjs} +1 -1
  199. package/dist/cli/{chunk-S46HWQKO.js → chunk-W6CZDTIR.js} +69 -69
  200. package/dist/cli/{chunk-XVB7V4N7.js → chunk-WL7P32PI.js} +161 -53
  201. package/dist/cli/{chunk-DJ2JDK4O.mjs → chunk-XD3MFTHA.mjs} +1 -1
  202. package/dist/cli/{chunk-GGGAEVCX.mjs → chunk-XFZX6FNM.mjs} +40 -22
  203. package/dist/cli/{chunk-AWJPDPMA.mjs → chunk-XU6QNM4D.mjs} +1 -1
  204. package/dist/cli/{chunk-QAORXEY3.mjs → chunk-YCOGPOUX.mjs} +6 -7
  205. package/dist/cli/{chunk-VQALXEXO.js → chunk-YQKCH4R7.js} +348 -118
  206. package/dist/cli/{chunk-6O5HOODW.mjs → chunk-YY55NYAH.mjs} +207 -60
  207. package/dist/cli/{chunk-JL2OTMSG.mjs → chunk-Z3A2S3QM.mjs} +41 -0
  208. package/dist/cli/command-docs.js +3 -3
  209. package/dist/cli/command-docs.mjs +2 -2
  210. package/dist/cli/{concurrent-runs-help-Q4KPAUJX.mjs → concurrent-runs-help-O3Q5IPLF.mjs} +9 -8
  211. package/dist/cli/concurrent-runs-help-ZFRZWX5V.js +22 -0
  212. package/dist/cli/{csv-F5VAGX4K.js → csv-4ZQ2RATI.js} +16 -15
  213. package/dist/cli/{csv-2PTVDNO6.mjs → csv-Y3BFPEM6.mjs} +7 -6
  214. package/dist/cli/{db-IEDXAUF7.mjs → db-3JYY4JNN.mjs} +17 -17
  215. package/dist/cli/{db-Z3OIUFMM.js → db-VEIFS4M7.js} +45 -45
  216. package/dist/cli/describe-EVJ4MFVU.mjs +50 -0
  217. package/dist/cli/describe-FG625QPF.js +50 -0
  218. package/dist/cli/describe-core.d.mts +3 -3
  219. package/dist/cli/describe-core.d.ts +3 -3
  220. package/dist/cli/describe-core.js +7 -7
  221. package/dist/cli/describe-core.mjs +6 -6
  222. package/dist/cli/{executions-H6H5655J.js → executions-HPZXOOVX.js} +12 -12
  223. package/dist/cli/{executions-R3LP74QN.mjs → executions-PCXZKEHM.mjs} +10 -10
  224. package/dist/cli/{feedback-WL3MRVT5.mjs → feedback-Y6VKZNY6.mjs} +9 -8
  225. package/dist/cli/{feedback-VFOUR66B.js → feedback-ZKFHFVL6.js} +17 -16
  226. package/dist/cli/git-RUBMALLH.js +26 -0
  227. package/dist/cli/{git-YX2J4GCI.mjs → git-UMPR2QYC.mjs} +8 -7
  228. package/dist/cli/index.js +170 -158
  229. package/dist/cli/index.mjs +60 -48
  230. package/dist/cli/{integrations-E2JZYKHS.js → integrations-3GQCTRTF.js} +23 -27
  231. package/dist/cli/{integrations-5ZK5KLVP.mjs → integrations-V3TM6XAB.mjs} +15 -19
  232. package/dist/cli/{legacy-noops-SMN3GSXY.mjs → legacy-noops-JZBUD7ZE.mjs} +9 -8
  233. package/dist/cli/{legacy-noops-3VW4IJTH.js → legacy-noops-VYCO7NGW.js} +12 -11
  234. package/dist/cli/{mcp-UQV2K4EW.js → mcp-4OIWTCE6.js} +121 -48
  235. package/dist/cli/{mcp-V6MGCYAG.mjs → mcp-PH4KZ76P.mjs} +100 -27
  236. package/dist/cli/{monitors-R3BBDCRC.js → monitors-E2A6VPBY.js} +221 -186
  237. package/dist/cli/{monitors-GGKS5W6M.mjs → monitors-SSMGIDGX.mjs} +58 -23
  238. package/dist/cli/org-SFDKSK5D.mjs +2289 -0
  239. package/dist/cli/org-WUDZGWBT.js +2289 -0
  240. package/dist/cli/outcomes-QT7LQBPK.mjs +2865 -0
  241. package/dist/cli/outcomes-Y7SZTLSL.js +2865 -0
  242. package/dist/cli/{play-MDWPR4XG.mjs → play-EK7KSFPL.mjs} +376 -106
  243. package/dist/cli/{play-2MVO27VO.js → play-GDNHCRRR.js} +1150 -880
  244. package/dist/cli/{providers-AKDYFZJZ.mjs → providers-FVZLRXAU.mjs} +10 -10
  245. package/dist/cli/{providers-2AACRUZH.js → providers-ZKOSECLV.js} +13 -13
  246. package/dist/cli/{quickstart-H6IV3PV3.js → quickstart-KSDKIXYD.js} +9 -8
  247. package/dist/cli/{quickstart-QDGRJFZY.mjs → quickstart-UJZ6PIQV.mjs} +7 -6
  248. package/dist/cli/{run-RTSQNGRD.mjs → run-E7MZ7P35.mjs} +35 -33
  249. package/dist/cli/{run-2634REDK.js → run-PD2BBG6S.js} +55 -53
  250. package/dist/cli/run-identity-LMLFMACS.js +31 -0
  251. package/dist/cli/{run-identity-MRNCEGV2.mjs → run-identity-MAZ7ANH5.mjs} +9 -3
  252. package/dist/cli/search-TKSPTPHA.js +32 -0
  253. package/dist/cli/{search-6AOJ4XPP.mjs → search-VTFUFTOY.mjs} +11 -11
  254. package/dist/cli/{search-output-S5ODBL5E.js → search-output-G2AGDCOY.js} +13 -12
  255. package/dist/cli/{search-output-6ADMTOU5.mjs → search-output-PFVXQCWA.mjs} +10 -9
  256. package/dist/cli/{secrets-TFIFBFB3.mjs → secrets-7CIMEMX7.mjs} +11 -11
  257. package/dist/cli/{secrets-LHCIIHMT.js → secrets-BCOQ4U7U.js} +20 -20
  258. package/dist/cli/sessions-4CO556VD.js +23 -0
  259. package/dist/cli/{sessions-WHBVUHVW.mjs → sessions-IUCQZEF7.mjs} +9 -8
  260. package/dist/cli/{settings-EBONWL5C.mjs → settings-KZN62UQK.mjs} +16 -16
  261. package/dist/cli/{settings-CP4FVK2W.js → settings-REL4736M.js} +89 -89
  262. package/dist/cli/{setup-I5AZE3IU.mjs → setup-2P7OG3OU.mjs} +22 -24
  263. package/dist/cli/{setup-LFGHTNLQ.js → setup-2XIVBBCS.js} +62 -64
  264. package/dist/cli/skills-JYT5DEY6.js +37 -0
  265. package/dist/cli/{skills-W76AO5XE.mjs → skills-VIGNDJKI.mjs} +10 -9
  266. package/dist/cli/tools-NTVUQ2TG.js +57 -0
  267. package/dist/cli/{tools-7IJHGF6W.mjs → tools-W3QT5EJY.mjs} +24 -24
  268. package/dist/cli/{update-GFOPZTHY.mjs → update-GZVBVMY3.mjs} +14 -11
  269. package/dist/cli/update-TWJZPUZM.js +37 -0
  270. package/dist/cli/{views-D4NX4SBG.mjs → views-BOGEH424.mjs} +47 -49
  271. package/dist/cli/{views-BPL2TQJ4.js → views-TOLJNLSV.js} +62 -64
  272. package/dist/cli/{workflow-ZYNAUCKC.js → workflow-ENWFRK5M.js} +23 -23
  273. package/dist/cli/{workflow-YXP42FUI.mjs → workflow-VDG2FDQV.mjs} +13 -13
  274. package/dist/{client-CyXGrO4D.d.mts → client-B8f7RNF8.d.mts} +1 -1
  275. package/dist/{client-Bf3IpUKN.d.ts → client-C5TgXmJQ.d.ts} +1 -1
  276. package/dist/{client-core-BxsLnXlm.d.mts → client-core-SLLGBTht.d.mts} +268 -23
  277. package/dist/{client-core-BWd0lX0Z.d.ts → client-core-p0sOxnkl.d.ts} +268 -23
  278. package/dist/{compiler-manifest-BqwVrOri.d.ts → compiler-manifest-D_zZEh9Q.d.mts} +70 -5
  279. package/dist/{compiler-manifest-BqwVrOri.d.mts → compiler-manifest-D_zZEh9Q.d.ts} +70 -5
  280. package/dist/{errors-BU8FB99X.d.mts → errors-CZCrBFrQ.d.mts} +1 -1
  281. package/dist/{errors-DfVN_FUG.d.ts → errors-DsUkLrdZ.d.ts} +1 -1
  282. package/dist/{index-BGnvtYGc.d.ts → index-B6RTOZGC.d.ts} +1 -1
  283. package/dist/{index-DjZgwpGw.d.mts → index-DeOVrEmX.d.mts} +1 -1
  284. package/dist/index.d.mts +7 -7
  285. package/dist/index.d.ts +7 -7
  286. package/dist/index.js +66 -55
  287. package/dist/index.mjs +25 -14
  288. package/dist/install-integrity.json +163 -144
  289. package/dist/plays/bundle-play-file.d.mts +3 -3
  290. package/dist/plays/bundle-play-file.d.ts +3 -3
  291. package/dist/plays/bundle-play-file.mjs +23 -4
  292. package/dist/plays/csv-data-input.js +3 -3
  293. package/dist/plays/csv-data-input.mjs +2 -2
  294. package/dist/plays/play-description.d.mts +2 -2
  295. package/dist/plays/play-description.d.ts +2 -2
  296. package/dist/plays/run-request.d.mts +2 -2
  297. package/dist/plays/run-request.d.ts +2 -2
  298. package/dist/plays/run-request.js +4 -4
  299. package/dist/plays/run-request.mjs +3 -3
  300. package/dist/release.d.mts +1 -1
  301. package/dist/release.d.ts +1 -1
  302. package/dist/release.js +2 -2
  303. package/dist/release.mjs +1 -1
  304. package/dist/server.d.mts +4 -4
  305. package/dist/server.d.ts +4 -4
  306. package/dist/server.js +15 -13
  307. package/dist/server.mjs +9 -7
  308. package/package.json +1 -1
  309. package/dist/cli/auth-MMNVWATX.js +0 -43
  310. package/dist/cli/chunk-AID3OYVJ.js +0 -8
  311. package/dist/cli/chunk-OVDNJAJN.mjs +0 -8
  312. package/dist/cli/concurrent-runs-help-FQAIHKKC.js +0 -21
  313. package/dist/cli/describe-QDANCTS3.mjs +0 -50
  314. package/dist/cli/describe-VUTT5ZKU.js +0 -50
  315. package/dist/cli/git-ETB3GH3K.js +0 -25
  316. package/dist/cli/org-GRYVMNSW.js +0 -1282
  317. package/dist/cli/org-Z37NGJV4.mjs +0 -1282
  318. package/dist/cli/run-identity-G257GQED.js +0 -25
  319. package/dist/cli/search-VTW2YNBS.js +0 -32
  320. package/dist/cli/sessions-CJ4FJ2WB.js +0 -22
  321. package/dist/cli/skills-R7EBXREW.js +0 -36
  322. package/dist/cli/tools-V7U2BDXM.js +0 -57
  323. package/dist/cli/update-4COPZETK.js +0 -34
@@ -8,11 +8,13 @@
8
8
  * as a wake hint, and one exact timer for the next due row. There is
9
9
  * deliberately no worker fleet polling cadence.
10
10
  */
11
+ import { RUN_SCHEDULER_OUTBOX_EVENT_TYPE } from '../run-event-catalog';
11
12
  import { isIsolatedRuntimeSchedulerSchema } from '../runtime-scheduler-topology';
12
13
  import {
13
14
  dispatchRunLedgerOutboxToLedgerBatchOnceWithClientScope,
14
15
  postgresSchedulerNotifyChannel,
15
16
  readPostgresSchedulerOutboxAdmissionHints,
17
+ readPostgresSchedulerOutboxDueRuns,
16
18
  readPostgresSchedulerOutboxNextDueAt,
17
19
  postgresSchedulerInlineCreatedProjectionLease,
18
20
  type PostgresSchedulerOptions,
@@ -131,6 +133,8 @@ export type RunLedgerOutboxRecoveryDeps = {
131
133
  parallelism?: number;
132
134
  /** Fast polling is used only when the topology intentionally has no LISTEN session. */
133
135
  notifyUnavailableSafetyWakeMs?: number;
136
+ /** One global claim, global clock read or bounded pass, by what asked for it. */
137
+ onGlobalDiscovery?: (trigger: string) => void;
134
138
  now?: () => number;
135
139
  setTimer?: (callback: () => void, delayMs: number) => RecoveryTimer;
136
140
  clearTimer?: (timer: RecoveryTimer) => void;
@@ -204,21 +208,17 @@ function notificationRunId(payload: string): string | undefined {
204
208
  }
205
209
  }
206
210
 
207
- /**
208
- * Start a bounded, work-conserving recovery controller from injected seams.
209
- * Subscription happens before the first database scan, so a terminal commit
210
- * cannot slip between startup scan and listener registration.
211
- */
212
- export function startRunLedgerOutboxRecovery(
213
- deps: RunLedgerOutboxRecoveryDeps,
214
- ): RunLedgerOutboxRecoveryController {
215
- const now = deps.now ?? Date.now;
216
- const setTimer = deps.setTimer ?? setTimeout;
217
- const clearTimer = deps.clearTimer ?? clearTimeout;
218
- const logger = deps.logger ?? console;
211
+ function notificationIsAdmission(payload: string): boolean {
212
+ try {
213
+ const message = JSON.parse(payload) as { eventType?: unknown } | null;
214
+ return message?.eventType === RUN_SCHEDULER_OUTBOX_EVENT_TYPE.runCreated;
215
+ } catch {
216
+ return false;
217
+ }
218
+ }
219
+
220
+ function recoverySlots(deps: RunLedgerOutboxRecoveryDeps) {
219
221
  const requestedParallelism = Math.floor(deps.parallelism ?? 1);
220
- const notifyUnavailableSafetyWakeMs =
221
- deps.notifyUnavailableSafetyWakeMs ?? NOTIFY_UNAVAILABLE_SAFETY_WAKE_MS;
222
222
  const parallelism = Number.isFinite(requestedParallelism)
223
223
  ? Math.max(
224
224
  1,
@@ -243,6 +243,25 @@ export function startRunLedgerOutboxRecovery(
243
243
  1,
244
244
  parallelism - observabilityParallelism,
245
245
  );
246
+ return { parallelism, observabilityParallelism, lifecycleParallelism };
247
+ }
248
+
249
+ /**
250
+ * Start a bounded, work-conserving recovery controller from injected seams.
251
+ * Subscription happens before the first database scan, so a terminal commit
252
+ * cannot slip between startup scan and listener registration.
253
+ */
254
+ export function startRunLedgerOutboxRecovery(
255
+ deps: RunLedgerOutboxRecoveryDeps,
256
+ ): RunLedgerOutboxRecoveryController {
257
+ const now = deps.now ?? Date.now;
258
+ const setTimer = deps.setTimer ?? setTimeout;
259
+ const clearTimer = deps.clearTimer ?? clearTimeout;
260
+ const logger = deps.logger ?? console;
261
+ const notifyUnavailableSafetyWakeMs =
262
+ deps.notifyUnavailableSafetyWakeMs ?? NOTIFY_UNAVAILABLE_SAFETY_WAKE_MS;
263
+ const { parallelism, observabilityParallelism, lifecycleParallelism } =
264
+ recoverySlots(deps);
246
265
  let observabilityRequested = false;
247
266
  let closed = false;
248
267
  let requested = false;
@@ -265,6 +284,8 @@ export function startRunLedgerOutboxRecovery(
265
284
  let unsubscribeNotify: (() => void) | undefined;
266
285
  let unsubscribeState: (() => void) | undefined;
267
286
  let requestDrain: (reason: string, runId?: string) => void = () => undefined;
287
+ // What the next global claim should be attributed to.
288
+ let globalTrigger = 'unknown';
268
289
  const lifecycleRunHints = new Set<string>();
269
290
  const observabilityRunHints = new Set<string>();
270
291
  const hasRequests = () =>
@@ -279,6 +300,7 @@ export function startRunLedgerOutboxRecovery(
279
300
  // claim must still rediscover their clocks.
280
301
  hints.clear();
281
302
  dueClockKnownLane = null;
303
+ globalTrigger = 'overflow';
282
304
  return false;
283
305
  };
284
306
  const takeRunHint = (hints: Set<string>) => {
@@ -381,6 +403,7 @@ export function startRunLedgerOutboxRecovery(
381
403
  dueClockKnownLane = null;
382
404
  requested = true;
383
405
  observabilityRequested = !!deps.dispatchObservabilityOnce;
406
+ globalTrigger = reason;
384
407
  lifecycleRunHints.clear();
385
408
  observabilityRunHints.clear();
386
409
  } else {
@@ -480,6 +503,7 @@ export function startRunLedgerOutboxRecovery(
480
503
  lane: Exclude<ReturnType<typeof dueClockLane>, null>,
481
504
  ): Promise<void> => {
482
505
  let dueAt: Date | null;
506
+ deps.onGlobalDiscovery?.('due_clock');
483
507
  try {
484
508
  dueAt = await deps.readNextDueAt(lane === 'both' ? undefined : lane);
485
509
  } catch (error) {
@@ -632,8 +656,11 @@ export function startRunLedgerOutboxRecovery(
632
656
  origin: LifecycleOrigin = runId === undefined
633
657
  ? 'global'
634
658
  : 'producer_hint',
659
+ trigger?: string,
635
660
  ) => {
636
661
  const id = Symbol();
662
+ if (runId === undefined)
663
+ deps.onGlobalDiscovery?.(trigger ?? globalTrigger);
637
664
  if (
638
665
  !observability &&
639
666
  origin === 'global' &&
@@ -760,7 +787,7 @@ export function startRunLedgerOutboxRecovery(
760
787
  pendingObservability.size < observabilityParallelism &&
761
788
  pending.size < parallelism
762
789
  )
763
- launch(true);
790
+ launch(true, undefined, 'global', 'refill');
764
791
  observabilityRefill = false;
765
792
  }
766
793
  if (refill) {
@@ -929,6 +956,457 @@ export function startRunLedgerOutboxRecovery(
929
956
  };
930
957
  }
931
958
 
959
+ /** Process switch for Bounded Discovery. Temporary; deleted after the soak. */
960
+ export const RUN_LEDGER_BOUNDED_DISCOVERY_ENV =
961
+ 'DEEPLINE_RUN_LEDGER_BOUNDED_DISCOVERY';
962
+ export const BOUNDED_DISCOVERY_INTERVAL_MS = 30_000;
963
+ export const BOUNDED_DISCOVERY_LISTEN_DOWN_INTERVAL_MS = 5_000;
964
+ export const BOUNDED_DISCOVERY_PAGE_LIMIT = 1_000;
965
+ export const BOUNDED_DISCOVERY_MAX_RUN_HINTS = 10_000;
966
+ export const BOUNDED_DISCOVERY_MAX_RUN_TIMERS = 10_000;
967
+ export const BOUNDED_DISCOVERY_TIMER_FLOOR_MS = 1_000;
968
+ const BOUNDED_DISCOVERY_ORDINARY_TURN = 4;
969
+
970
+ /** Explicit opt-in applies to both Production and isolated Preview. */
971
+ export function runLedgerBoundedDiscoveryEnabled(
972
+ env: NodeJS.ProcessEnv,
973
+ ): boolean {
974
+ return env[RUN_LEDGER_BOUNDED_DISCOVERY_ENV]?.trim() === 'true';
975
+ }
976
+
977
+ export type RunLedgerOutboxBoundedDiscoveryDeps =
978
+ RunLedgerOutboxRecoveryDeps & {
979
+ /** Hints and timers dropped at their bounds since the last report. */
980
+ onDiscoveryOverflow?: (dropped: number) => void;
981
+ readDueRuns: (input: {
982
+ afterRunId: string | null;
983
+ limit: number;
984
+ }) => Promise<{
985
+ rows: {
986
+ runId: string;
987
+ searchOnly: boolean;
988
+ dueAt: Date;
989
+ admission: boolean;
990
+ }[];
991
+ cursor: string | null;
992
+ }>;
993
+ };
994
+
995
+ type BoundedHintLane = 'admission' | 'lifecycle' | 'observability';
996
+
997
+ /**
998
+ * Bounded Discovery: a periodic page of due runs replaces every whole-outbox
999
+ * scan, and every claim names a run. Hints and timers grant nothing (the row
1000
+ * lease decides) and may all be lost, because the next passes rebuild them.
1001
+ */
1002
+ export function startBoundedRunLedgerOutboxRecovery(
1003
+ deps: RunLedgerOutboxBoundedDiscoveryDeps,
1004
+ ): RunLedgerOutboxRecoveryController {
1005
+ const listenDownIntervalMs =
1006
+ deps.notifyUnavailableSafetyWakeMs ??
1007
+ BOUNDED_DISCOVERY_LISTEN_DOWN_INTERVAL_MS;
1008
+ const now = deps.now ?? Date.now;
1009
+ const setTimer = deps.setTimer ?? setTimeout;
1010
+ const clearTimer = deps.clearTimer ?? clearTimeout;
1011
+ const logger = deps.logger ?? console;
1012
+ const { parallelism, observabilityParallelism, lifecycleParallelism } =
1013
+ recoverySlots(deps);
1014
+ const hints: Record<BoundedHintLane, Set<string>> = {
1015
+ admission: new Set(),
1016
+ lifecycle: new Set(),
1017
+ observability: new Set(),
1018
+ };
1019
+ // `${lane}:${runId}` to due time. One timer serves the earliest.
1020
+ const runDueMs = new Map<string, number>();
1021
+ const work = new Set<Promise<void>>();
1022
+ const inFlightStartedAt = new Map<number, number>();
1023
+ const inFlight = { lifecycle: 0, observability: 0 };
1024
+ const wave = {
1025
+ completed: 0,
1026
+ attempted: 0,
1027
+ projected: 0,
1028
+ retrying: 0,
1029
+ blocked: 0,
1030
+ };
1031
+ let closed = false;
1032
+ let cursor: string | null = null;
1033
+ let dropped = 0;
1034
+ let claimTurns = 0;
1035
+ let nextDispatchId = 0;
1036
+ let lastDispatchSettledAt: number | null = null;
1037
+ let claimFailures = 0;
1038
+ let discoveryFailures = 0;
1039
+ let cooldownUntilMs: number | null = null;
1040
+ let cooldownTimer: RecoveryTimer | null = null;
1041
+ let discoveryTimer: RecoveryTimer | null = null;
1042
+ let discoveryTimerAtMs: number | null = null;
1043
+ let runTimer: RecoveryTimer | null = null;
1044
+ let runTimerAtMs: number | null = null;
1045
+ let discovery: Promise<void> | null = null;
1046
+ let rerunReason: string | null = null;
1047
+ // The last pass found work and more pages remain in this cursor cycle.
1048
+ let continuationPending = false;
1049
+ let hubLease: PgNotifyHubLease | null = null;
1050
+ let unsubscribeNotify: (() => void) | undefined;
1051
+ let unsubscribeState: (() => void) | undefined;
1052
+
1053
+ const listenerIsAvailable = () => hubLease?.hub.state() === 'listening';
1054
+
1055
+ const addHint = (lane: BoundedHintLane, runId: string) => {
1056
+ if (closed) return;
1057
+ if (lane === 'lifecycle' && hints.admission.has(runId)) return;
1058
+ if (lane === 'admission') hints.lifecycle.delete(runId);
1059
+ const set = hints[lane];
1060
+ if (set.has(runId)) return;
1061
+ // The outbox row holds the truth, so the next passes restore a drop.
1062
+ if (set.size >= BOUNDED_DISCOVERY_MAX_RUN_HINTS) dropped += 1;
1063
+ else set.add(runId);
1064
+ };
1065
+ const takeHint = (lane: BoundedHintLane) => {
1066
+ const runId = hints[lane].values().next().value;
1067
+ if (runId !== undefined) hints[lane].delete(runId);
1068
+ return runId;
1069
+ };
1070
+
1071
+ const armRunTimer = (dueMs: number): void => {
1072
+ // The floor means a past-due leased head cannot spin this timer.
1073
+ const atMs = Math.max(dueMs, now() + BOUNDED_DISCOVERY_TIMER_FLOOR_MS);
1074
+ if (runTimerAtMs !== null && runTimerAtMs <= atMs) return;
1075
+ if (runTimer) clearTimer(runTimer);
1076
+ runTimerAtMs = atMs;
1077
+ runTimer = setTimer(fireRunTimer, Math.min(MAX_TIMEOUT_MS, atMs - now()));
1078
+ runTimer.unref?.();
1079
+ };
1080
+ const fireRunTimer = (): void => {
1081
+ runTimer = null;
1082
+ runTimerAtMs = null;
1083
+ let earliest = Infinity;
1084
+ for (const [key, dueMs] of runDueMs) {
1085
+ if (dueMs <= now()) {
1086
+ runDueMs.delete(key);
1087
+ const separator = key.indexOf(':');
1088
+ addHint(
1089
+ key.slice(0, separator) as BoundedHintLane,
1090
+ key.slice(separator + 1),
1091
+ );
1092
+ } else earliest = Math.min(earliest, dueMs);
1093
+ }
1094
+ if (Number.isFinite(earliest)) armRunTimer(earliest);
1095
+ pump();
1096
+ };
1097
+ const setRunDue = (lane: BoundedHintLane, runId: string, dueMs: number) => {
1098
+ if (closed) return;
1099
+ const key = `${lane}:${runId}`;
1100
+ const known = runDueMs.get(key);
1101
+ if (
1102
+ known === undefined &&
1103
+ runDueMs.size >= BOUNDED_DISCOVERY_MAX_RUN_TIMERS
1104
+ ) {
1105
+ dropped += 1;
1106
+ return;
1107
+ }
1108
+ runDueMs.set(key, Math.min(known ?? Infinity, dueMs));
1109
+ armRunTimer(dueMs);
1110
+ };
1111
+
1112
+ const track = (promise: Promise<void>) => {
1113
+ const tracked: Promise<void> = promise.finally(() => work.delete(tracked));
1114
+ work.add(tracked);
1115
+ };
1116
+
1117
+ /** Any claim that comes back empty learns only that run's own clock. */
1118
+ const readRunClock = async (
1119
+ lane: 'lifecycle' | 'observability',
1120
+ runId: string,
1121
+ ): Promise<void> => {
1122
+ try {
1123
+ const dueAt = await deps.readNextDueAt(lane, runId);
1124
+ if (dueAt) setRunDue(lane, runId, dueAt.getTime());
1125
+ } catch (error) {
1126
+ // Discovery covers this run; hold no failure state for one clock.
1127
+ logger.warn('[run-ledger-outbox.recovery_retry]', {
1128
+ stage: 'run_due',
1129
+ error: error instanceof Error ? error.message : String(error),
1130
+ });
1131
+ }
1132
+ };
1133
+
1134
+ const reportWave = () => {
1135
+ if (wave.attempted > 0) {
1136
+ logger.info('[run-ledger-outbox.recovery_wave]', {
1137
+ reason: 'bounded_discovery',
1138
+ parallelism,
1139
+ attempted: wave.attempted,
1140
+ projected: wave.projected,
1141
+ retrying: wave.retrying,
1142
+ blocked: wave.blocked,
1143
+ });
1144
+ }
1145
+ wave.completed = wave.attempted = wave.projected = 0;
1146
+ wave.retrying = wave.blocked = 0;
1147
+ };
1148
+
1149
+ const enterCooldown = (error: unknown): void => {
1150
+ claimFailures += 1;
1151
+ const delayMs = listenerIsAvailable()
1152
+ ? boundedFailureDelayMs(claimFailures)
1153
+ : listenDownIntervalMs;
1154
+ logger.warn('[run-ledger-outbox.recovery_retry]', {
1155
+ stage: 'dispatch',
1156
+ delayMs,
1157
+ error: error instanceof Error ? error.message : String(error),
1158
+ });
1159
+ if (closed || cooldownUntilMs !== null) return;
1160
+ cooldownUntilMs = now() + delayMs;
1161
+ cooldownTimer = setTimer(() => {
1162
+ cooldownTimer = null;
1163
+ cooldownUntilMs = null;
1164
+ discover('recovery_error_retry');
1165
+ pump();
1166
+ }, delayMs);
1167
+ cooldownTimer.unref?.();
1168
+ };
1169
+
1170
+ const claim = async (lane: BoundedHintLane, runId: string): Promise<void> => {
1171
+ const observability = lane === 'observability';
1172
+ const slot = observability ? 'observability' : 'lifecycle';
1173
+ const id = nextDispatchId++;
1174
+ inFlight[slot] += 1;
1175
+ inFlightStartedAt.set(id, now());
1176
+ try {
1177
+ const result = await (observability
1178
+ ? deps.dispatchObservabilityOnce!(runId)
1179
+ : deps.dispatchOnce('admission_first', runId));
1180
+ if (result.retrying > 0) {
1181
+ logger.warn('[run-ledger-outbox.recovery_retry]', {
1182
+ stage: 'projection',
1183
+ retrying: result.retrying,
1184
+ });
1185
+ } else claimFailures = 0;
1186
+ wave.completed += 1;
1187
+ wave.attempted += result.attempted;
1188
+ wave.projected += result.projected;
1189
+ wave.retrying += result.retrying;
1190
+ wave.blocked += result.failed;
1191
+ // Continue the run until a claim is empty: only then is its clock known,
1192
+ // including a retry this claim just committed.
1193
+ if (result.attempted > 0) addHint(slot, runId);
1194
+ else if (!closed) track(readRunClock(slot, runId));
1195
+ } catch (error) {
1196
+ addHint(lane, runId);
1197
+ enterCooldown(error);
1198
+ } finally {
1199
+ inFlight[slot] -= 1;
1200
+ inFlightStartedAt.delete(id);
1201
+ lastDispatchSettledAt = now();
1202
+ if (
1203
+ wave.completed >= parallelism ||
1204
+ (wave.completed > 0 && inFlightStartedAt.size === 0)
1205
+ )
1206
+ reportWave();
1207
+ pump();
1208
+ }
1209
+ };
1210
+
1211
+ /** Admission first; every fourth claim serves ordinary work so it cannot starve. */
1212
+ const nextLifecycleHint = (): {
1213
+ lane: BoundedHintLane;
1214
+ runId: string;
1215
+ } | null => {
1216
+ claimTurns += 1;
1217
+ const order: BoundedHintLane[] =
1218
+ claimTurns % BOUNDED_DISCOVERY_ORDINARY_TURN === 0
1219
+ ? ['lifecycle', 'admission']
1220
+ : ['admission', 'lifecycle'];
1221
+ for (const lane of order) {
1222
+ const runId = takeHint(lane);
1223
+ if (runId !== undefined) return { lane, runId };
1224
+ }
1225
+ return null;
1226
+ };
1227
+
1228
+ function pump(): void {
1229
+ if (closed || cooldownUntilMs !== null) return;
1230
+ while (
1231
+ inFlight.observability < observabilityParallelism &&
1232
+ hints.observability.size > 0
1233
+ ) {
1234
+ track(claim('observability', takeHint('observability')!));
1235
+ }
1236
+ while (
1237
+ inFlight.lifecycle < lifecycleParallelism &&
1238
+ hints.admission.size + hints.lifecycle.size > 0
1239
+ ) {
1240
+ const next = nextLifecycleHint()!;
1241
+ track(claim(next.lane, next.runId));
1242
+ }
1243
+ continueDiscovery();
1244
+ }
1245
+
1246
+ /**
1247
+ * A backlog larger than one page must not wait on the interval while slots
1248
+ * idle. The cursor only advances, so this ends with the cycle at the latest.
1249
+ */
1250
+ function continueDiscovery(): void {
1251
+ if (
1252
+ !continuationPending ||
1253
+ discovery ||
1254
+ Object.values(hints).some(
1255
+ (set) => set.size >= BOUNDED_DISCOVERY_MAX_RUN_HINTS / 2,
1256
+ )
1257
+ )
1258
+ return;
1259
+ continuationPending = false;
1260
+ discover('continuation');
1261
+ }
1262
+
1263
+ const armDiscovery = (delayMs: number, reason: string): void => {
1264
+ if (closed) return;
1265
+ if (discoveryTimer) clearTimer(discoveryTimer);
1266
+ discoveryTimerAtMs = now() + delayMs;
1267
+ discoveryTimer = setTimer(() => {
1268
+ discoveryTimer = null;
1269
+ discoveryTimerAtMs = null;
1270
+ if (!listenerIsAvailable()) attachNotifyHub();
1271
+ discover(reason);
1272
+ }, delayMs);
1273
+ discoveryTimer.unref?.();
1274
+ };
1275
+ const discoveryIntervalMs = () =>
1276
+ listenerIsAvailable()
1277
+ ? BOUNDED_DISCOVERY_INTERVAL_MS
1278
+ : listenDownIntervalMs;
1279
+
1280
+ const discoveryPass = async (): Promise<void> => {
1281
+ let page: Awaited<ReturnType<typeof deps.readDueRuns>>;
1282
+ try {
1283
+ page = await deps.readDueRuns({
1284
+ afterRunId: cursor,
1285
+ limit: BOUNDED_DISCOVERY_PAGE_LIMIT,
1286
+ });
1287
+ } catch (error) {
1288
+ // Hints already held keep draining; only discovery backs off.
1289
+ discoveryFailures += 1;
1290
+ rerunReason = null;
1291
+ continuationPending = false;
1292
+ const delayMs = Math.min(
1293
+ boundedFailureDelayMs(discoveryFailures),
1294
+ listenerIsAvailable() ? Infinity : discoveryIntervalMs(),
1295
+ );
1296
+ logger.warn('[run-ledger-outbox.recovery_retry]', {
1297
+ stage: 'discovery',
1298
+ delayMs,
1299
+ error: error instanceof Error ? error.message : String(error),
1300
+ });
1301
+ armDiscovery(delayMs, 'recovery_error_retry');
1302
+ return;
1303
+ }
1304
+ if (closed) return;
1305
+ discoveryFailures = 0;
1306
+ cursor = page.cursor;
1307
+ continuationPending = page.cursor !== null && page.rows.length > 0;
1308
+ for (const row of page.rows) {
1309
+ const lane: BoundedHintLane = row.searchOnly
1310
+ ? 'observability'
1311
+ : row.admission
1312
+ ? 'admission'
1313
+ : 'lifecycle';
1314
+ if (row.dueAt.getTime() <= now()) addHint(lane, row.runId);
1315
+ else setRunDue(lane, row.runId, row.dueAt.getTime());
1316
+ }
1317
+ if (dropped > 0) {
1318
+ logger.warn('[run-ledger-outbox.bounded_discovery_overflow]', {
1319
+ dropped,
1320
+ });
1321
+ deps.onDiscoveryOverflow?.(dropped);
1322
+ dropped = 0;
1323
+ }
1324
+ armDiscovery(discoveryIntervalMs(), 'interval');
1325
+ pump();
1326
+ };
1327
+
1328
+ // Single-flight. A cooldown's expiry always discovers, so it owns the next pass.
1329
+ function discover(reason: string): void {
1330
+ if (closed || cooldownUntilMs !== null) return;
1331
+ if (discovery) {
1332
+ // Its snapshot may predate whatever asked; run once more after it.
1333
+ rerunReason = reason;
1334
+ return;
1335
+ }
1336
+ deps.onGlobalDiscovery?.(`bounded_${reason}`);
1337
+ discovery = discoveryPass().finally(() => {
1338
+ discovery = null;
1339
+ const again = rerunReason;
1340
+ rerunReason = null;
1341
+ if (again !== null) discover(again);
1342
+ else continueDiscovery();
1343
+ });
1344
+ }
1345
+
1346
+ function attachNotifyHub(): void {
1347
+ if (closed || hubLease) return;
1348
+ const lease = deps.acquireNotifyHub();
1349
+ if (!lease) return;
1350
+ hubLease = lease;
1351
+ unsubscribeNotify = lease.hub.subscribe((payload) => {
1352
+ const runId = notificationRunId(payload);
1353
+ if (runId === undefined) {
1354
+ discover('postgres_notify');
1355
+ return;
1356
+ }
1357
+ addHint(
1358
+ notificationIsAdmission(payload) ? 'admission' : 'lifecycle',
1359
+ runId,
1360
+ );
1361
+ if (deps.dispatchObservabilityOnce) addHint('observability', runId);
1362
+ pump();
1363
+ });
1364
+ unsubscribeState = lease.hub.subscribeState((state) => {
1365
+ if (state === 'listening') {
1366
+ discover('listener_connected');
1367
+ return;
1368
+ }
1369
+ const atMs = now() + listenDownIntervalMs;
1370
+ if (discoveryTimerAtMs !== null && discoveryTimerAtMs > atMs)
1371
+ armDiscovery(listenDownIntervalMs, 'interval');
1372
+ });
1373
+ }
1374
+
1375
+ // Subscribe first, so a commit cannot slip between the first page and LISTEN.
1376
+ attachNotifyHub();
1377
+ discover('startup');
1378
+
1379
+ return {
1380
+ wake: (reason = 'external_safety_wake') => discover(reason),
1381
+ notifyState: () => hubLease?.hub.state() ?? 'unavailable',
1382
+ drainHealth: () => {
1383
+ let oldest: number | null = null;
1384
+ for (const startedAt of inFlightStartedAt.values()) {
1385
+ if (oldest === null || startedAt < oldest) oldest = startedAt;
1386
+ }
1387
+ return {
1388
+ inFlightDispatches: inFlightStartedAt.size,
1389
+ oldestInFlightStartedAt: oldest,
1390
+ lastDispatchSettledAt,
1391
+ };
1392
+ },
1393
+ close: async () => {
1394
+ if (closed) return;
1395
+ closed = true;
1396
+ for (const timer of [discoveryTimer, runTimer, cooldownTimer]) {
1397
+ if (timer) clearTimer(timer);
1398
+ }
1399
+ for (const set of Object.values(hints)) set.clear();
1400
+ runDueMs.clear();
1401
+ unsubscribeNotify?.();
1402
+ unsubscribeState?.();
1403
+ await discovery;
1404
+ await Promise.all(work);
1405
+ hubLease?.release();
1406
+ },
1407
+ };
1408
+ }
1409
+
932
1410
  /**
933
1411
  * Latency budget for the inline `run.created` attempt made by an admitting
934
1412
  * process after its Runtime Postgres commit. The whole attempt (claim, token,
@@ -1188,6 +1666,10 @@ export function startRunLedgerOutboxRecoveryController(input: {
1188
1666
  useDirectNotify?: boolean;
1189
1667
  /** Observation hook for acknowledged rows (lag metrics). */
1190
1668
  onDelivered?: (deliveries: readonly RunLedgerOutboxDeliveredRow[]) => void;
1669
+ /** Per-run claims from bounded pages. Never honored for isolated schemas. */
1670
+ boundedDiscovery?: boolean;
1671
+ onGlobalDiscovery?: RunLedgerOutboxRecoveryDeps['onGlobalDiscovery'];
1672
+ onDiscoveryOverflow?: RunLedgerOutboxBoundedDiscoveryDeps['onDiscoveryOverflow'];
1191
1673
  }): RunLedgerOutboxRecoveryController {
1192
1674
  const schedulerOptions = input.schedulerOptions ?? {};
1193
1675
  const environment = input.environment ?? 'production';
@@ -1233,7 +1715,10 @@ export function startRunLedgerOutboxRecoveryController(input: {
1233
1715
  },
1234
1716
  schedulerOptions,
1235
1717
  );
1236
- return startRunLedgerOutboxRecovery({
1718
+ const deps: RunLedgerOutboxRecoveryDeps = {
1719
+ ...(input.onGlobalDiscovery
1720
+ ? { onGlobalDiscovery: input.onGlobalDiscovery }
1721
+ : {}),
1237
1722
  acquireNotifyHub: () =>
1238
1723
  input.useDirectNotify === false
1239
1724
  ? null
@@ -1270,6 +1755,22 @@ export function startRunLedgerOutboxRecoveryController(input: {
1270
1755
  runId,
1271
1756
  }),
1272
1757
  ),
1758
+ };
1759
+ if (!input.boundedDiscovery) return startRunLedgerOutboxRecovery(deps);
1760
+ return startBoundedRunLedgerOutboxRecovery({
1761
+ ...deps,
1762
+ notifyUnavailableSafetyWakeMs: isIsolatedRuntimeSchedulerSchema(
1763
+ schedulerOptions.schema,
1764
+ )
1765
+ ? ISOLATED_NOTIFY_UNAVAILABLE_SAFETY_WAKE_MS
1766
+ : BOUNDED_DISCOVERY_LISTEN_DOWN_INTERVAL_MS,
1767
+ ...(input.onDiscoveryOverflow
1768
+ ? { onDiscoveryOverflow: input.onDiscoveryOverflow }
1769
+ : {}),
1770
+ readDueRuns: (page) =>
1771
+ withRuntimeSchedulerClient(input.poolOptions, (client) =>
1772
+ readPostgresSchedulerOutboxDueRuns(client, page, schedulerOptions),
1773
+ ),
1273
1774
  });
1274
1775
  }
1275
1776
 
@@ -1,7 +1,7 @@
1
1
  import type { PlaySchedulerSubmitInput } from '../scheduler-backend';
2
2
 
3
3
  const RUNTIME_EXECUTION_RECOVERY_DEPLOYMENT_HOST_RE =
4
- /^deepline(?:-api-[a-z0-9]+|-(?!api-)[a-z0-9]+)-aero-team-0f650658\.vercel\.app$/;
4
+ /^deepline(?:-api-[a-z0-9]+|-(?!api-)[a-z0-9]+|-api-r2-oidc-preview-[a-z0-9]{9})-aero-team-0f650658\.vercel\.app$/;
5
5
 
6
6
  /** A recovery reader must remain on one immutable, Deepline-owned app build. */
7
7
  export function isImmutableRuntimeExecutionRecoveryOrigin(
@@ -146,6 +146,15 @@ function receiptValueBindings(input: { orgId: string; receiptKey: string }): {
146
146
  };
147
147
  }
148
148
 
149
+ /** Every receipt value one workspace owns. */
150
+ export function runtimeReceiptValueOrgStoragePrefix(orgId: string): string {
151
+ const { orgBinding } = receiptValueBindings({
152
+ orgId: requiredNonempty(orgId, 'orgId'),
153
+ receiptKey: '',
154
+ });
155
+ return `runtime/receipt-values/v1/${orgBinding}/`;
156
+ }
157
+
149
158
  export function runtimeReceiptValueStorageKey(input: {
150
159
  orgId: string;
151
160
  receiptKey: string;