deepline 0.3.551 → 0.3.552

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 (167) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +23 -0
  2. package/dist/bundling-sources/sdk/src/http-core.ts +6 -2
  3. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  4. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +58 -29
  5. package/dist/bundling-sources/shared_libs/monitors/package.json +2 -0
  6. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-upstream-identity.ts +80 -13
  7. package/dist/bundling-sources/shared_libs/monitors/tamradar-countries.ts +285 -0
  8. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +144 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +137 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +14 -2
  11. package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +20 -16
  12. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +47 -14
  13. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +48 -3
  14. package/dist/bundling-sources/shared_libs/play-runtime/runtime-constants.ts +9 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +32 -10
  16. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +37 -7
  17. package/dist/cli/{auth-E7BH4GMJ.mjs → auth-KVSBJZOX.mjs} +5 -5
  18. package/dist/cli/auth-MMNVWATX.js +43 -0
  19. package/dist/cli/{billing-OXKU462W.mjs → billing-54RHFEBI.mjs} +19 -12
  20. package/dist/cli/{billing-DNQAZGX7.js → billing-FQREA7UA.js} +105 -98
  21. package/dist/cli/{chunk-5VVSEU67.js → chunk-3FD5EQ62.js} +6 -6
  22. package/dist/cli/{chunk-WKBHUB6R.js → chunk-45PVGZST.js} +99 -99
  23. package/dist/cli/{chunk-COGREZAO.js → chunk-4MK42735.js} +44 -44
  24. package/dist/cli/{chunk-T2B5BVZE.js → chunk-4NQF6KJ3.js} +13 -13
  25. package/dist/cli/{chunk-V6SCP4B7.mjs → chunk-4TALT2M3.mjs} +1 -1
  26. package/dist/cli/{chunk-C4CUZH57.js → chunk-4UUR4TCH.js} +2 -2
  27. package/dist/cli/{chunk-PM7MO62Y.mjs → chunk-57VZVF5D.mjs} +3 -3
  28. package/dist/cli/{chunk-VTGG2RT3.js → chunk-634ZDA3F.js} +1 -1
  29. package/dist/cli/{chunk-E64HFB4L.mjs → chunk-6O5HOODW.mjs} +11 -11
  30. package/dist/cli/{chunk-GGB3JYCW.mjs → chunk-6PRW5UBA.mjs} +2 -2
  31. package/dist/cli/{chunk-GVYLCCKN.mjs → chunk-6RZOWL2V.mjs} +1 -1
  32. package/dist/cli/{chunk-POLUE7D5.js → chunk-6YCA5NKJ.js} +7 -7
  33. package/dist/cli/{chunk-5LUF4LAR.mjs → chunk-6ZORHRKB.mjs} +1 -0
  34. package/dist/cli/{chunk-PPSDCN6C.js → chunk-77AAAGVB.js} +2 -2
  35. package/dist/cli/{chunk-UDXULACQ.js → chunk-7IKQKKNX.js} +3 -3
  36. package/dist/cli/{chunk-2ZYRBMQM.js → chunk-ADRC5I3R.js} +22 -22
  37. package/dist/cli/{chunk-2UXDHFSF.mjs → chunk-AQWQ2BFX.mjs} +1 -1
  38. package/dist/cli/{chunk-D6M5HFBB.mjs → chunk-AWJPDPMA.mjs} +1 -1
  39. package/dist/cli/{chunk-CLRAANWH.mjs → chunk-AZQ264ID.mjs} +1 -1
  40. package/dist/cli/{chunk-NMWGZD6Y.js → chunk-BAIST2BR.js} +26 -26
  41. package/dist/cli/{chunk-5S6PHKRV.mjs → chunk-DJ2JDK4O.mjs} +1 -1
  42. package/dist/cli/{chunk-MNSTCJMX.mjs → chunk-EOPEYCY7.mjs} +3 -3
  43. package/dist/cli/{chunk-HEHVGEZV.mjs → chunk-EUPVF4SU.mjs} +5 -5
  44. package/dist/cli/{chunk-3G6QZACZ.js → chunk-F2LH7TGF.js} +15 -15
  45. package/dist/cli/{chunk-BIIJATTX.mjs → chunk-FTJLJCE5.mjs} +1 -1
  46. package/dist/cli/{chunk-XYE5XPGF.js → chunk-G4O75EXF.js} +9 -9
  47. package/dist/cli/{chunk-Z2FIOG3V.js → chunk-GKYAYLRI.js} +12 -12
  48. package/dist/cli/{chunk-3KYBDAR3.js → chunk-HO3XK3R7.js} +5 -5
  49. package/dist/cli/{chunk-FOTGUFVK.mjs → chunk-HYC4MKGK.mjs} +2 -2
  50. package/dist/cli/{chunk-44I675YK.js → chunk-IDVVIXPJ.js} +41 -41
  51. package/dist/cli/{chunk-ZCDKE4UH.js → chunk-IHRKLXZN.js} +5 -5
  52. package/dist/cli/{chunk-6PWJKMFQ.mjs → chunk-IYSTRCLX.mjs} +4 -4
  53. package/dist/cli/{chunk-CQ6JYQSW.js → chunk-JWUAX6OP.js} +10 -10
  54. package/dist/cli/{chunk-W2ZWQUHT.js → chunk-MF2GHZDO.js} +2 -2
  55. package/dist/cli/{chunk-LPJPCGT3.js → chunk-PFO3ISXA.js} +26 -15
  56. package/dist/cli/{chunk-W425ERWN.mjs → chunk-PTVD2GVQ.mjs} +5 -5
  57. package/dist/cli/{chunk-5IL7SC45.mjs → chunk-QAORXEY3.mjs} +2 -2
  58. package/dist/cli/{chunk-RE5MJBEV.mjs → chunk-QILKGXYF.mjs} +2 -2
  59. package/dist/cli/{chunk-VWLHRZFG.mjs → chunk-QPKH23EC.mjs} +4 -4
  60. package/dist/cli/{chunk-7DOQ3OEX.mjs → chunk-QX7LFGJR.mjs} +1 -1
  61. package/dist/cli/{chunk-3T65J5RG.mjs → chunk-QY3ZNU6Z.mjs} +2 -2
  62. package/dist/cli/{chunk-PACD5DGC.js → chunk-RBEUVDZF.js} +10 -6
  63. package/dist/cli/{chunk-4OMAGJ6U.js → chunk-RQZQVFCJ.js} +2 -2
  64. package/dist/cli/{chunk-MR5LTVHD.js → chunk-S46HWQKO.js} +53 -53
  65. package/dist/cli/{chunk-44KSACJW.mjs → chunk-S5S355UY.mjs} +2 -2
  66. package/dist/cli/{chunk-QM6Y6S4E.js → chunk-SHLFOPD6.js} +5 -5
  67. package/dist/cli/{chunk-MXGA6JFI.mjs → chunk-U7QRMBIY.mjs} +2 -2
  68. package/dist/cli/{chunk-R7J7CJPZ.js → chunk-V436Z54K.js} +1 -0
  69. package/dist/cli/{chunk-ZDQFBJPO.js → chunk-VQALXEXO.js} +19 -19
  70. package/dist/cli/{chunk-7WQNWJQW.mjs → chunk-WE5HES3H.mjs} +5 -5
  71. package/dist/cli/{chunk-54EEYLTF.js → chunk-WLN3SUIA.js} +3 -3
  72. package/dist/cli/{chunk-7RSIFA72.js → chunk-XVB7V4N7.js} +16 -16
  73. package/dist/cli/{chunk-I4VKGNAQ.mjs → chunk-YJHE3O5M.mjs} +5 -5
  74. package/dist/cli/{chunk-4D3WIZST.mjs → chunk-YLTMXJFC.mjs} +7 -3
  75. package/dist/cli/{chunk-ZMNGZ6XS.mjs → chunk-Z5TSLLOW.mjs} +19 -8
  76. package/dist/cli/{chunk-S7IZWGUA.mjs → chunk-ZIAXDBXX.mjs} +2 -2
  77. package/dist/cli/command-docs.js +3 -3
  78. package/dist/cli/command-docs.mjs +2 -2
  79. package/dist/cli/concurrent-runs-help-FQAIHKKC.js +21 -0
  80. package/dist/cli/{concurrent-runs-help-C6L6I5OR.mjs → concurrent-runs-help-Q4KPAUJX.mjs} +6 -6
  81. package/dist/cli/{csv-SYSDXFEM.mjs → csv-2PTVDNO6.mjs} +4 -4
  82. package/dist/cli/{csv-QMF4FWE7.js → csv-F5VAGX4K.js} +13 -13
  83. package/dist/cli/{db-Q7HURWRZ.mjs → db-IEDXAUF7.mjs} +6 -6
  84. package/dist/cli/{db-YSHPPA4H.js → db-Z3OIUFMM.js} +27 -27
  85. package/dist/cli/{describe-YGMQBV44.mjs → describe-QDANCTS3.mjs} +18 -18
  86. package/dist/cli/describe-VUTT5ZKU.js +50 -0
  87. package/dist/cli/describe-core.d.mts +2 -2
  88. package/dist/cli/describe-core.d.ts +2 -2
  89. package/dist/cli/{executions-MWBC5TAW.js → executions-H6H5655J.js} +8 -8
  90. package/dist/cli/{executions-G7U3VUXN.mjs → executions-R3LP74QN.mjs} +6 -6
  91. package/dist/cli/{feedback-SD55OY6H.js → feedback-VFOUR66B.js} +14 -14
  92. package/dist/cli/{feedback-GMHIFLBJ.mjs → feedback-WL3MRVT5.mjs} +6 -6
  93. package/dist/cli/git-ETB3GH3K.js +25 -0
  94. package/dist/cli/{git-HPE45OPD.mjs → git-YX2J4GCI.mjs} +5 -5
  95. package/dist/cli/index.js +147 -147
  96. package/dist/cli/index.mjs +46 -46
  97. package/dist/cli/{integrations-2W4MGIQR.mjs → integrations-5ZK5KLVP.mjs} +7 -7
  98. package/dist/cli/{integrations-HFKVBY6G.js → integrations-E2JZYKHS.js} +15 -15
  99. package/dist/cli/{legacy-noops-SXVNDEXN.js → legacy-noops-3VW4IJTH.js} +9 -9
  100. package/dist/cli/{legacy-noops-GZYKNU2Z.mjs → legacy-noops-SMN3GSXY.mjs} +6 -6
  101. package/dist/cli/{mcp-PJRHQHHU.js → mcp-UQV2K4EW.js} +24 -24
  102. package/dist/cli/{mcp-BWA6KULG.mjs → mcp-V6MGCYAG.mjs} +4 -4
  103. package/dist/cli/{monitors-SYQKCATO.mjs → monitors-GGKS5W6M.mjs} +7 -7
  104. package/dist/cli/{monitors-K2WSI6CR.js → monitors-R3BBDCRC.js} +100 -100
  105. package/dist/cli/{org-YQ2CR32B.js → org-GRYVMNSW.js} +88 -88
  106. package/dist/cli/{org-5KD7X7IA.mjs → org-Z37NGJV4.mjs} +6 -6
  107. package/dist/cli/{play-SZXY2F2S.js → play-2MVO27VO.js} +319 -319
  108. package/dist/cli/{play-TTMABJEI.mjs → play-MDWPR4XG.mjs} +18 -18
  109. package/dist/cli/{providers-YDHCTZAF.js → providers-2AACRUZH.js} +9 -9
  110. package/dist/cli/{providers-GQIOMRQO.mjs → providers-AKDYFZJZ.mjs} +6 -6
  111. package/dist/cli/{quickstart-BNYOXQXG.js → quickstart-H6IV3PV3.js} +6 -6
  112. package/dist/cli/{quickstart-PHSSMKCA.mjs → quickstart-QDGRJFZY.mjs} +4 -4
  113. package/dist/cli/{run-GFIAZXVL.js → run-2634REDK.js} +43 -43
  114. package/dist/cli/{run-74C3C75C.mjs → run-RTSQNGRD.mjs} +23 -23
  115. package/dist/cli/{search-3SWUB7KX.mjs → search-6AOJ4XPP.mjs} +7 -7
  116. package/dist/cli/search-VTW2YNBS.js +32 -0
  117. package/dist/cli/{search-output-K2SWHVHQ.mjs → search-output-6ADMTOU5.mjs} +4 -4
  118. package/dist/cli/{search-output-6JF3S4TP.js → search-output-S5ODBL5E.js} +6 -6
  119. package/dist/cli/{secrets-2SAKLH2H.js → secrets-LHCIIHMT.js} +15 -15
  120. package/dist/cli/{secrets-2M4XWEKE.mjs → secrets-TFIFBFB3.mjs} +6 -6
  121. package/dist/cli/sessions-CJ4FJ2WB.js +22 -0
  122. package/dist/cli/{sessions-A64BCXTO.mjs → sessions-WHBVUHVW.mjs} +6 -6
  123. package/dist/cli/{settings-HV64WIJF.js → settings-CP4FVK2W.js} +85 -85
  124. package/dist/cli/{settings-SVGEC3FI.mjs → settings-EBONWL5C.mjs} +12 -12
  125. package/dist/cli/{setup-EDC3NEJ3.mjs → setup-I5AZE3IU.mjs} +9 -9
  126. package/dist/cli/{setup-FHXOLQGQ.js → setup-LFGHTNLQ.js} +49 -49
  127. package/dist/cli/skills-R7EBXREW.js +36 -0
  128. package/dist/cli/{skills-3HGHZMXB.mjs → skills-W76AO5XE.mjs} +7 -7
  129. package/dist/cli/{tools-P2QS6A6Q.mjs → tools-7IJHGF6W.mjs} +17 -17
  130. package/dist/cli/tools-V7U2BDXM.js +57 -0
  131. package/dist/cli/update-4COPZETK.js +34 -0
  132. package/dist/cli/{update-552BYQM4.mjs → update-GFOPZTHY.mjs} +9 -9
  133. package/dist/cli/{views-PA25NAE3.js → views-BPL2TQJ4.js} +21 -21
  134. package/dist/cli/{views-LD5HXJYY.mjs → views-D4NX4SBG.mjs} +6 -6
  135. package/dist/cli/{workflow-LDYFGBYP.mjs → workflow-YXP42FUI.mjs} +7 -7
  136. package/dist/cli/{workflow-FIDBUQV6.js → workflow-ZYNAUCKC.js} +17 -17
  137. package/dist/{client-t9HZAkFD.d.ts → client-Bf3IpUKN.d.ts} +1 -1
  138. package/dist/{client-DuDFiJDU.d.mts → client-CyXGrO4D.d.mts} +1 -1
  139. package/dist/{client-core-CJRzLanv.d.ts → client-core-BWd0lX0Z.d.ts} +17 -0
  140. package/dist/{client-core-DydMQOft.d.mts → client-core-BxsLnXlm.d.mts} +17 -0
  141. package/dist/index.d.mts +3 -3
  142. package/dist/index.d.ts +3 -3
  143. package/dist/index.js +9 -9
  144. package/dist/index.mjs +6 -6
  145. package/dist/install-integrity.json +119 -118
  146. package/dist/plays/play-description.d.mts +1 -1
  147. package/dist/plays/play-description.d.ts +1 -1
  148. package/dist/plays/run-request.d.mts +1 -1
  149. package/dist/plays/run-request.d.ts +1 -1
  150. package/dist/release.d.mts +1 -1
  151. package/dist/release.d.ts +1 -1
  152. package/dist/release.js +2 -2
  153. package/dist/release.mjs +1 -1
  154. package/dist/server.d.mts +2 -2
  155. package/dist/server.d.ts +2 -2
  156. package/dist/server.js +5 -5
  157. package/dist/server.mjs +3 -3
  158. package/package.json +1 -1
  159. package/dist/cli/auth-B4PI7GVY.js +0 -43
  160. package/dist/cli/concurrent-runs-help-JEFQZTJI.js +0 -21
  161. package/dist/cli/describe-PXTSBJTL.js +0 -50
  162. package/dist/cli/git-I3JV7IGH.js +0 -25
  163. package/dist/cli/search-2RRRF4LW.js +0 -32
  164. package/dist/cli/sessions-SBH27JNW.js +0 -22
  165. package/dist/cli/skills-Y3SRLOYD.js +0 -36
  166. package/dist/cli/tools-OFYPUPUV.js +0 -57
  167. package/dist/cli/update-SOUSCLB7.js +0 -34
@@ -1990,5 +1990,149 @@
1990
1990
  "runTimeoutMs": 5400000,
1991
1991
  "failureAlert": "github_workflow_run",
1992
1992
  "domainReportRequired": true
1993
+ },
1994
+ {
1995
+ "id": "convex.ledger-shadow-journal-drain",
1996
+ "name": "Ledger shadow journal writer drain",
1997
+ "scheduler": "convex_scheduled_action",
1998
+ "cadence": "runAfter(0) when a shadow book's writer lease is taken; lease-owned continuation and linger hops",
1999
+ "source": "packages/convex/ledgerJournalWriter.ts",
2000
+ "locator": "drainWriter",
2001
+ "purpose": "Apply a shadow book's journal writer turns (inert: runs only on shadow books, and only while the shadow ceiling is above 0 or a dev/Preview harness forces it).",
2002
+ "successDefinition": "The drain applies its turns under its writer lease epoch and idles, hands over, or is fenced by a newer epoch.",
2003
+ "failureDefinition": "The native scheduled action fails; the writer lease watch restarts the drain at the next epoch.",
2004
+ "runTimeoutMs": 600000,
2005
+ "timezone": "UTC",
2006
+ "owner": "billing",
2007
+ "criticality": "reporting",
2008
+ "startGraceMs": 120000,
2009
+ "failureAlert": "convex_native_scheduled_function",
2010
+ "domainReportRequired": true
2011
+ },
2012
+ {
2013
+ "id": "convex.ledger-shadow-journal-watch",
2014
+ "name": "Ledger shadow journal writer lease watch",
2015
+ "scheduler": "convex_scheduled_mutation",
2016
+ "cadence": "runAfter at each drain epoch's lease end plus the watch grace",
2017
+ "source": "packages/convex/ledgerJournalWriter.ts",
2018
+ "locator": "watchWriterLease",
2019
+ "purpose": "Restart a shadow book's writer drain whose action died (inert: shadow books only, ceiling 0).",
2020
+ "successDefinition": "The watch re-arms for a live lease, ends for a released or superseded epoch, or takes the lapsed lease over at the next epoch.",
2021
+ "failureDefinition": "The native scheduled mutation fails; the next append or lease request takes the lapsed lease over.",
2022
+ "runTimeoutMs": 60000,
2023
+ "timezone": "UTC",
2024
+ "owner": "billing",
2025
+ "criticality": "reporting",
2026
+ "startGraceMs": 120000,
2027
+ "failureAlert": "convex_native_scheduled_function",
2028
+ "domainReportRequired": true
2029
+ },
2030
+ {
2031
+ "id": "convex.ledger-shadow-journal-page-sweep",
2032
+ "name": "Ledger shadow journal slot page settle and carry sweep",
2033
+ "scheduler": "convex_scheduled_mutation",
2034
+ "cadence": "runAt each slot page's window end plus the settle delay; carried tickets runAt the settle plus the carry window",
2035
+ "source": "packages/convex/ledgerJournalPages.ts",
2036
+ "locator": "settleSlotPage",
2037
+ "purpose": "Settle each shadow book's slot page once and return its carried tickets' reserve (inert: shadow books only, ceiling 0).",
2038
+ "successDefinition": "The page closes with its spend and appends its totals once, or is skipped as already closed or rescheduled as early.",
2039
+ "failureDefinition": "The native scheduled mutation fails; the writer's page watchdog schedules the settle again at its next org sweep.",
2040
+ "runTimeoutMs": 60000,
2041
+ "timezone": "UTC",
2042
+ "owner": "billing",
2043
+ "criticality": "reporting",
2044
+ "startGraceMs": 120000,
2045
+ "failureAlert": "convex_native_scheduled_function",
2046
+ "domainReportRequired": true
2047
+ },
2048
+ {
2049
+ "id": "convex.ledger-shadow-follower-drain",
2050
+ "name": "Ledger shadow follower drain",
2051
+ "scheduler": "convex_scheduled_action",
2052
+ "cadence": "runAfter(0) when an organization's follower lease is taken; lease-owned continuation while a pending row is due within the linger",
2053
+ "source": "packages/convex/ledgerJournalShadow.ts",
2054
+ "locator": "drainShadowFollower",
2055
+ "purpose": "Compare each due shadowed call with main's reservation (read in a query), finalize its immutable diff row and apply main's terminal fact to its shadow async hold, or back the row off (inert: shadow books only, shadow ceiling 0).",
2056
+ "successDefinition": "Every due pending row of the organization is finalized or backed off, and the drain continues, lingers or releases its lease with one timer for the next due row.",
2057
+ "failureDefinition": "The native scheduled action fails; the follower lease watch takes the lapsed lease over at the next epoch, and the orphan sweep requests a drain for overdue rows.",
2058
+ "runTimeoutMs": 600000,
2059
+ "timezone": "UTC",
2060
+ "owner": "billing",
2061
+ "criticality": "reporting",
2062
+ "startGraceMs": 120000,
2063
+ "failureAlert": "convex_native_scheduled_function",
2064
+ "domainReportRequired": true
2065
+ },
2066
+ {
2067
+ "id": "convex.ledger-shadow-follower-watch",
2068
+ "name": "Ledger shadow follower lease watch",
2069
+ "scheduler": "convex_scheduled_mutation",
2070
+ "cadence": "runAfter at each follower drain epoch's lease end plus the watch grace",
2071
+ "source": "packages/convex/ledgerJournalShadow.ts",
2072
+ "locator": "watchFollowerLease",
2073
+ "purpose": "Restart an organization's follower drain whose action died with due rows left (inert: shadow books only, shadow ceiling 0).",
2074
+ "successDefinition": "The watch re-arms for a live lease, ends for a superseded or idle one, or takes the lapsed lease over at the next epoch.",
2075
+ "failureDefinition": "The native scheduled mutation fails; the next shadow admit or the orphan sweep requests a drain.",
2076
+ "runTimeoutMs": 60000,
2077
+ "timezone": "UTC",
2078
+ "owner": "billing",
2079
+ "criticality": "reporting",
2080
+ "startGraceMs": 120000,
2081
+ "failureAlert": "convex_native_scheduled_function",
2082
+ "domainReportRequired": true
2083
+ },
2084
+ {
2085
+ "id": "convex.ledger-shadow-orphan-sweep",
2086
+ "name": "Ledger shadow follower orphan sweep",
2087
+ "scheduler": "convex_scheduled_mutation",
2088
+ "cadence": "runAfter(0) from the shared operations API run action, one bounded pass (no cron until the approved activation)",
2089
+ "source": "packages/convex/ledgerJournalShadow.ts",
2090
+ "locator": "sweepOrphanFollowers",
2091
+ "purpose": "Request one follower drain for each organization whose pending rows are overdue with no live drain (inert: refuses while the shadow ceiling is 0).",
2092
+ "successDefinition": "One bounded page of overdue rows is read and each organization without a live drain gets exactly one drain request.",
2093
+ "failureDefinition": "The native scheduled mutation fails; overdue rows stay pending (no money moves) until the next pass.",
2094
+ "runTimeoutMs": 60000,
2095
+ "timezone": "UTC",
2096
+ "owner": "billing",
2097
+ "criticality": "reporting",
2098
+ "startGraceMs": 120000,
2099
+ "failureAlert": "convex_native_scheduled_function",
2100
+ "domainReportRequired": true
2101
+ },
2102
+ {
2103
+ "id": "convex.ledger-shadow-diff-retention",
2104
+ "name": "Ledger shadow diff retention",
2105
+ "scheduler": "convex_scheduled_mutation",
2106
+ "cadence": "runAfter(0) from the shared operations API run action; self-continued while pages come back full, bounded per pass (no cron until the approved activation)",
2107
+ "source": "packages/convex/ledgerJournalShadowOps.ts",
2108
+ "locator": "sweepDiffRetention",
2109
+ "purpose": "Delete shadow diff rows finalized more than 30 days ago (inert: refuses while the shadow ceiling is 0).",
2110
+ "successDefinition": "Expired diff rows are deleted in bounded pages until a short page or the pass bound.",
2111
+ "failureDefinition": "The native scheduled mutation fails; expired rows remain until the next pass.",
2112
+ "runTimeoutMs": 60000,
2113
+ "timezone": "UTC",
2114
+ "owner": "billing",
2115
+ "criticality": "reporting",
2116
+ "startGraceMs": 120000,
2117
+ "failureAlert": "convex_native_scheduled_function",
2118
+ "domainReportRequired": true
2119
+ },
2120
+ {
2121
+ "id": "convex.ledger-shadow-journal-retention",
2122
+ "name": "Ledger shadow journal retention",
2123
+ "scheduler": "convex_scheduled_action",
2124
+ "cadence": "runAfter(0) from the shared operations API run action; the pass continues itself from its book cursor until every shadow book is visited (no cron until the approved activation)",
2125
+ "source": "packages/convex/ledgerJournalShadowOps.ts",
2126
+ "locator": "sweepJournalRetention",
2127
+ "purpose": "Delete shadow journal rows of calls closed past retention (7 days, and never before the follower's last check), only for books whose probes find expired rows, in bounded rounds; never a book's funding, books, writer lease, fence or floor (inert: refuses while the shadow ceiling is 0).",
2128
+ "successDefinition": "Every shadow book is probed once per pass, and each book with expired rows is retained within the per-book round bound; unfinished books are reported.",
2129
+ "failureDefinition": "The native scheduled action fails; expired rows remain until the next pass.",
2130
+ "runTimeoutMs": 600000,
2131
+ "timezone": "UTC",
2132
+ "owner": "billing",
2133
+ "criticality": "reporting",
2134
+ "startGraceMs": 120000,
2135
+ "failureAlert": "convex_native_scheduled_function",
2136
+ "domainReportRequired": true
1993
2137
  }
1994
2138
  ]
@@ -1610,6 +1610,22 @@ export async function reconcileNodeRuntimeMapResultsWithPersistedSheet(input: {
1610
1610
  offset: number;
1611
1611
  rowMode: 'all' | 'output';
1612
1612
  }) => Promise<Record<string, unknown>[]>;
1613
+ /**
1614
+ * Keys this run committed as visible terminal rows, in commit order.
1615
+ * Overlapping runs of one Play share the dataset, and a later run's
1616
+ * admission or write moves a row's ownership to itself. Run-scoped reads
1617
+ * then omit that row; these keys let finalization return it and prove each
1618
+ * missing row was finished by another run rather than lost.
1619
+ */
1620
+ committedRowKeys?: readonly string[];
1621
+ /**
1622
+ * Finished (enriched or failed) rows for the keys, whichever run owns them,
1623
+ * or null when the reader cannot answer (an older runtime API). Null keeps
1624
+ * the shortfall a failure.
1625
+ */
1626
+ readCommittedTerminalRows?: (
1627
+ keys: string[],
1628
+ ) => Promise<readonly CommittedTerminalRow[] | null>;
1613
1629
  log?: (line: string) => void;
1614
1630
  }): Promise<Record<string, unknown>[]> {
1615
1631
  if (
@@ -1634,6 +1650,25 @@ export async function reconcileNodeRuntimeMapResultsWithPersistedSheet(input: {
1634
1650
  }
1635
1651
 
1636
1652
  if (persistedRows.length < input.expectedRows) {
1653
+ const committed = await readCommittedRowsAcrossRuns(input);
1654
+ if (committed && committed.takenOverRows > 0) {
1655
+ if (
1656
+ committed.unfinishedKeys === 0 &&
1657
+ committed.rows.length >= input.expectedRows
1658
+ ) {
1659
+ input.log?.(
1660
+ `Runtime sheet finalization recovered ctx.dataset("${input.mapName}") ` +
1661
+ `with ${committed.takenOverRows} committed row(s) another run of this dataset now owns; ` +
1662
+ `${persistedRows.length}/${input.expectedRows} terminal persisted row(s) are still owned by ` +
1663
+ `run ${input.runId ?? 'unknown'}.`,
1664
+ );
1665
+ return committed.rows;
1666
+ }
1667
+ input.log?.(
1668
+ `Runtime sheet finalization found ${committed.takenOverRows} committed row(s) of ctx.dataset("${input.mapName}") ` +
1669
+ `finished by another run; ${committed.unfinishedKeys} committed row(s) have no finished row.`,
1670
+ );
1671
+ }
1637
1672
  throw new Error(
1638
1673
  `Runtime sheet finalization mismatch for ctx.dataset("${input.mapName}"): ` +
1639
1674
  `expected ${input.expectedRows} terminal persisted row(s), saw ${persistedRows.length}; ` +
@@ -1653,6 +1688,68 @@ export async function reconcileNodeRuntimeMapResultsWithPersistedSheet(input: {
1653
1688
  return input.currentRows;
1654
1689
  }
1655
1690
 
1691
+ export type CommittedTerminalRow = {
1692
+ key: string;
1693
+ data: Record<string, unknown>;
1694
+ inputIndex?: number;
1695
+ ownedByOtherRun: boolean;
1696
+ };
1697
+
1698
+ // Each answer carries full row bodies; keep one gateway response small.
1699
+ const RUNTIME_SHEET_TAKEOVER_KEY_BATCH = 100;
1700
+
1701
+ /**
1702
+ * Every committed row in one list: rows this run still owns stay in input
1703
+ * order, and each row another run took over keeps its commit slot (its input
1704
+ * position in this run is not stored once the owner changes).
1705
+ */
1706
+ async function readCommittedRowsAcrossRuns(input: {
1707
+ committedRowKeys?: readonly string[];
1708
+ readCommittedTerminalRows?: (
1709
+ keys: string[],
1710
+ ) => Promise<readonly CommittedTerminalRow[] | null>;
1711
+ }): Promise<{
1712
+ rows: Record<string, unknown>[];
1713
+ takenOverRows: number;
1714
+ unfinishedKeys: number;
1715
+ } | null> {
1716
+ if (!input.committedRowKeys || !input.readCommittedTerminalRows) return null;
1717
+ const keys = [...new Set(input.committedRowKeys.filter(Boolean))];
1718
+ const byKey = new Map<string, CommittedTerminalRow>();
1719
+ for (
1720
+ let offset = 0;
1721
+ offset < keys.length;
1722
+ offset += RUNTIME_SHEET_TAKEOVER_KEY_BATCH
1723
+ ) {
1724
+ const page = keys.slice(offset, offset + RUNTIME_SHEET_TAKEOVER_KEY_BATCH);
1725
+ const rows = await input.readCommittedTerminalRows(page);
1726
+ if (rows === null) return null;
1727
+ const requested = new Set(page);
1728
+ for (const row of rows) {
1729
+ if (requested.has(row.key)) byKey.set(row.key, row);
1730
+ }
1731
+ }
1732
+ const slots = keys.flatMap((key) => {
1733
+ const row = byKey.get(key);
1734
+ return row ? [row] : [];
1735
+ });
1736
+ const ownedInInputOrder = slots
1737
+ .filter((row) => !row.ownedByOtherRun)
1738
+ .sort(
1739
+ (left, right) =>
1740
+ (left.inputIndex ?? Number.MAX_SAFE_INTEGER) -
1741
+ (right.inputIndex ?? Number.MAX_SAFE_INTEGER),
1742
+ );
1743
+ let nextOwned = 0;
1744
+ return {
1745
+ rows: slots.map((row) =>
1746
+ row.ownedByOtherRun ? row.data : ownedInInputOrder[nextOwned++]!.data,
1747
+ ),
1748
+ takenOverRows: slots.length - ownedInInputOrder.length,
1749
+ unfinishedKeys: keys.length - slots.length,
1750
+ };
1751
+ }
1752
+
1656
1753
  export function resolveToolRuntimeTimeoutMs(
1657
1754
  toolId: string,
1658
1755
  requestedTimeoutMs?: number,
@@ -12219,6 +12316,46 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
12219
12316
  currentRows: results,
12220
12317
  failedRowCount: resumedPendingRowsOnly ? 0 : visibleFailedRows.length,
12221
12318
  rowMode: finalizationRowMode,
12319
+ // When the resumed frame recorded superseded rows, restoreCompletedRows
12320
+ // already kept only keys this run still owned at that wake; the
12321
+ // others became reused inputs and left expectedRows. Takeovers after
12322
+ // that restore (or on a frame without superseded rows) remain here
12323
+ // and must be proven finished by another run.
12324
+ committedRowKeys: [
12325
+ ...previouslyCompletedRowKeys,
12326
+ ...visibleCompletedRows.map((row) => row.key),
12327
+ ],
12328
+ readCommittedTerminalRows:
12329
+ this.#options.baseUrl &&
12330
+ this.#options.executorToken &&
12331
+ this.#options.playName &&
12332
+ this.#options.runId
12333
+ ? async (keys) => {
12334
+ const result = await readRuntimeSheetDatasetRowKeys(
12335
+ {
12336
+ baseUrl: this.#options.baseUrl!,
12337
+ executorToken: this.#options.executorToken!,
12338
+ dbSessionStrategy: this.#options.dbSessionStrategy,
12339
+ playName: this.#options.playName!,
12340
+ userEmail: this.#options.userEmail,
12341
+ runId: this.#options.runId!,
12342
+ },
12343
+ {
12344
+ tableNamespace: resolvedTableNamespace,
12345
+ runId: this.#options.runId!,
12346
+ keys,
12347
+ rowMode: 'terminalRowsAnyRun',
12348
+ },
12349
+ );
12350
+ // An older runtime API answers an unknown mode as an
12351
+ // `output` read of this run's own keys; only an echoed mode
12352
+ // carries rows from every run.
12353
+ return result.rowMode === 'terminalRowsAnyRun' &&
12354
+ Array.isArray(result.rows)
12355
+ ? result.rows
12356
+ : null;
12357
+ }
12358
+ : undefined,
12222
12359
  log: (line) => this.runtimeLog(line),
12223
12360
  readPersistedRows: async (readInput) => {
12224
12361
  if (
@@ -150,7 +150,7 @@ export const DURABLE_RUNS_ROLLOUT = {
150
150
  * not a scalar, or a placeholder reused without an explicit cast, keeps the
151
151
  * multi-trip path. Off: unchanged.
152
152
  */
153
- rateStateSingleTripTransactions: true,
153
+ rateStateSingleTripTransactions: false,
154
154
  /**
155
155
  * Collapse a warm rate-state acquire to as few requests as its transactions
156
156
  * allow (needs `rateStateSingleTripTransactions`). The concurrency grant
@@ -166,7 +166,19 @@ export const DURABLE_RUNS_ROLLOUT = {
166
166
  * row locks and errors; any statement that cannot be rendered keeps the
167
167
  * previous path. Off: unchanged.
168
168
  */
169
- rateStateCollapsedAcquire: true,
169
+ rateStateCollapsedAcquire: false,
170
+ /**
171
+ * Organizations whose concurrency-bearing rate-state acquires send the scope
172
+ * lock and grant as one request (the `rateStateCollapsedAcquire` path) while
173
+ * the two switches above are off. The acquire's requester must be
174
+ * `org:<id>` for a listed id. Narrower than turning the switches on: for a
175
+ * listed org, pure-rate acquires and the in-acquire observation fold stay
176
+ * multi-trip, as do every other requester and every call without one
177
+ * (releases, penalties). Both paths take the same locks in the same order, so
178
+ * a listed org can share a provider bucket with unlisted ones. Empty: no
179
+ * change.
180
+ */
181
+ rateStateOneRequestOrgIds: [] as readonly string[],
170
182
  /**
171
183
  * While a detached runner waits for the park acknowledgement, it issues the
172
184
  * read-only startup lookups its static plan names (tool metadata and
@@ -217,7 +217,7 @@ export const EXPERIMENT_SWITCHES = {
217
217
  RH: {
218
218
  perRun: false,
219
219
  summary:
220
- "Run status route holds a watch snapshot with waitForTerminalMs until the run is terminal, bounded. E3 and the SDK's RUN_WATCH_SERVER_WAIT_MS need it: without RH the SDK setting would poll with no delay.",
220
+ "Run status route holds a watch snapshot with waitForTerminalMs until the run is terminal, bounded. E3 needs it. The SDK asks for the hold (RUN_WATCH_SERVER_WAIT_MS) and keeps its own poll cadence unless the response carries `x-deepline-run-watch-hold: applied`. Also on, per organization, when the caller's `runtime-fast-launch` rollout grants it.",
221
221
  constants: [
222
222
  {
223
223
  file: 'apps/deepline-api/src/app/api/v2/runs/[runId]/route.ts',
@@ -225,11 +225,12 @@ export const EXPERIMENT_SWITCHES = {
225
225
  },
226
226
  ],
227
227
  reason:
228
- 'read route: GET /api/v2/runs/{runId} does not read the launch, so it has no run-carried override.',
228
+ "read route: GET /api/v2/runs/{runId} does not read the launch, so it has no run-carried override. It is org-gated instead: the authenticated caller organization's cached `runtime-fast-launch` rollout decision turns it on.",
229
229
  },
230
230
  E3: {
231
231
  perRun: false,
232
- summary: 'Run watch reads the Postgres terminal first.',
232
+ summary:
233
+ "Run watch reads the Postgres terminal first. Also on, per organization, inside an RH hold when the caller's `runtime-fast-launch` rollout grants it.",
233
234
  constants: [
234
235
  {
235
236
  file: 'apps/deepline-api/src/app/api/v2/runs/[runId]/route.ts',
@@ -237,7 +238,7 @@ export const EXPERIMENT_SWITCHES = {
237
238
  },
238
239
  ],
239
240
  reason:
240
- 'read route: GET /api/v2/runs/{runId} does not read the launch, so it has no run-carried override.',
241
+ "read route: GET /api/v2/runs/{runId} does not read the launch, so it has no run-carried override. It is org-gated instead: the authenticated caller organization's cached `runtime-fast-launch` rollout decision turns it on.",
241
242
  },
242
243
  CAR: {
243
244
  perRun: false,
@@ -277,40 +278,37 @@ export const EXPERIMENT_SWITCHES = {
277
278
  'module-load time: shapes the checker program an instance builds once.',
278
279
  },
279
280
  C3: {
280
- perRun: false,
281
- summary: 'Durable typecheck verdicts.',
281
+ perRun: true,
282
+ summary:
283
+ "Durable typecheck and source verdicts (admission): the run's source check reads and writes R2 verdicts keyed by checker fingerprint and full input (source verdicts per workspace). Responses are identical either way, but a timing A/B is confounded on a warm instance: an R2 hit seeds the process-wide typecheck result cache, and once an off run has built a program the typecheck skips R2. Measure C3 on cold instances.",
282
284
  constants: [
283
285
  {
284
286
  file: 'apps/deepline-api/src/lib/plays/typecheck-verdict-store.ts',
285
287
  name: 'DURABLE_TYPECHECK_VERDICTS',
286
288
  },
287
289
  ],
288
- reason:
289
- "shared cache: one run's verdict writes would warm the other arm, so a per-run A/B is confounded.",
290
290
  },
291
291
  C4: {
292
- perRun: false,
293
- summary: 'Launch credential check without the checker.',
292
+ perRun: true,
293
+ summary:
294
+ 'Launch credential check loaded without the checker (TS-free module; admission).',
294
295
  constants: [
295
296
  {
296
297
  file: 'apps/deepline-api/src/lib/plays/launch-credential-check.ts',
297
298
  name: 'LAUNCH_CREDENTIAL_CHECK_WITHOUT_CHECKER',
298
299
  },
299
300
  ],
300
- reason:
301
- 'module-load time: selects which credential-check module the instance loads and keeps.',
302
301
  },
303
302
  C5: {
304
- perRun: false,
305
- summary: 'Start the source-verdict read during route admission.',
303
+ perRun: true,
304
+ summary:
305
+ 'With C3, start the source-verdict read during route admission, after auth (run route). C5=1 without C3=1 is refused.',
306
306
  constants: [
307
307
  {
308
308
  file: 'apps/deepline-api/src/lib/plays/play-source-verdicts.ts',
309
309
  name: 'EARLY_SOURCE_VERDICT_READ',
310
310
  },
311
311
  ],
312
- reason:
313
- 'shared cache: reads the durable verdict cache that the other arm writes; also starts while auth runs, before the header is authorized.',
314
312
  },
315
313
  E4: {
316
314
  perRun: false,
@@ -454,6 +452,12 @@ export function parseExperimentSwitchesHeader(
454
452
  }
455
453
  overrides[perRunId] = match[2] === '1';
456
454
  }
455
+ // C5 reads the durable store C3 provides; alone it would do nothing.
456
+ if (overrides.C5 === true && overrides.C3 !== true) {
457
+ throw new ExperimentSwitchesHeaderError(
458
+ 'Experiment switch "C5" needs "C3=1" in the same header (the early read uses the durable verdict store).',
459
+ );
460
+ }
457
461
  return overrides;
458
462
  }
459
463
 
@@ -288,7 +288,10 @@ import {
288
288
  } from '../app-runtime-api';
289
289
  import { RUNTIME_CAPACITY_POLICY } from '../runtime-capacity-policy';
290
290
  import { RUNTIME_RELIABILITY_POLICY } from '../runtime-reliability-policy';
291
- import { RUNNER_GATEWAY_CONNECTION_RETRY_BUDGET_MS } from '../runtime-constants';
291
+ import {
292
+ RUNNER_GATEWAY_CONNECTION_RETRY_BUDGET_MS,
293
+ RUNNER_GATEWAY_SCHEDULER_UNAVAILABLE_RETRY_BUDGET_MS,
294
+ } from '../runtime-constants';
292
295
 
293
296
  const playRuntimeRequire = createRequire(`${process.cwd()}/package.json`);
294
297
  const moduleRuntime = playRuntimeRequire('module') as {
@@ -587,6 +590,32 @@ function isRetryableRuntimeControlStatus(status: number): boolean {
587
590
  );
588
591
  }
589
592
 
593
+ /**
594
+ * The gateway's declared answer while its scheduler DB breaker is open or a
595
+ * scheduler DB call fails as unavailable. Only retry-safe (read) lookups wait
596
+ * it out, and the next attempt may land on a healthy gateway instance.
597
+ */
598
+ function isRunnerGatewaySchedulerUnavailableResponse(
599
+ response: Response,
600
+ ): boolean {
601
+ return (
602
+ response.status === 503 &&
603
+ response.headers.get('x-deepline-error-code') ===
604
+ 'RUNTIME_SCHEDULER_UNAVAILABLE'
605
+ );
606
+ }
607
+
608
+ /** 100 ms, 250 ms, then 1 s growing by 1 s per attempt up to 8 s. */
609
+ function runnerRuntimeControlRetryDelayMs(retryAttempt: number): number {
610
+ return (
611
+ RUNNER_RUNTIME_CONTROL_RETRY_DELAYS_MS[retryAttempt - 1] ??
612
+ Math.min(
613
+ 8_000,
614
+ 1_000 * (retryAttempt - RUNNER_RUNTIME_CONTROL_RETRY_DELAYS_MS.length),
615
+ )
616
+ );
617
+ }
618
+
590
619
  async function sleepRunnerRuntimeControlRetry(ms: number): Promise<void> {
591
620
  await new Promise<void>((resolve) => setTimeout(resolve, ms));
592
621
  }
@@ -758,14 +787,24 @@ export async function fetchRunnerRuntimeControl(input: {
758
787
  respondedAttempts += 1;
759
788
  if (
760
789
  input.retrySafe &&
761
- respondedAttempts < RUNNER_RUNTIME_CONTROL_MAX_ATTEMPTS &&
762
790
  isRetryableRuntimeControlStatus(response.status)
763
791
  ) {
764
- await response.text().catch(() => '');
765
- await sleepImpl(
766
- RUNNER_RUNTIME_CONTROL_RETRY_DELAYS_MS[respondedAttempts - 1] ?? 250,
767
- );
768
- continue;
792
+ const delayMs = runnerRuntimeControlRetryDelayMs(respondedAttempts);
793
+ // A declared scheduler-breaker 503 outlasts three quick attempts, so it
794
+ // keeps retrying within its own wall-clock budget, then fails loudly.
795
+ const schedulerOutageRetryAllowed =
796
+ !input.init.signal?.aborted &&
797
+ isRunnerGatewaySchedulerUnavailableResponse(response) &&
798
+ Date.now() - startedAt + delayMs <=
799
+ RUNNER_GATEWAY_SCHEDULER_UNAVAILABLE_RETRY_BUDGET_MS;
800
+ if (
801
+ respondedAttempts < RUNNER_RUNTIME_CONTROL_MAX_ATTEMPTS ||
802
+ schedulerOutageRetryAllowed
803
+ ) {
804
+ await response.text().catch(() => '');
805
+ await sleepImpl(delayMs);
806
+ continue;
807
+ }
769
808
  }
770
809
  // `fetch()` resolves once headers arrive. Leaving the body for callers
771
810
  // means this attempt's timeout signal can fire during `response.json()`
@@ -797,13 +836,7 @@ export async function fetchRunnerRuntimeControl(input: {
797
836
  const retryAttempt = responseReceived
798
837
  ? respondedAttempts
799
838
  : noResponseAttempts;
800
- const delayMs =
801
- RUNNER_RUNTIME_CONTROL_RETRY_DELAYS_MS[retryAttempt - 1] ??
802
- Math.min(
803
- 8_000,
804
- 1_000 *
805
- (retryAttempt - RUNNER_RUNTIME_CONTROL_RETRY_DELAYS_MS.length),
806
- );
839
+ const delayMs = runnerRuntimeControlRetryDelayMs(retryAttempt);
807
840
  const outageRetryAllowed =
808
841
  !responseReceived &&
809
842
  (timeoutSignal.aborted || isRunnerGatewayNoResponseError(error)) &&
@@ -10929,15 +10929,27 @@ export function createRuntimeSheetDatasetPageReader(input: {
10929
10929
  };
10930
10930
  }
10931
10931
 
10932
+ export type RuntimeSheetDatasetRowKeysResult = {
10933
+ keys: string[];
10934
+ /** Present only for `terminalRowsAnyRun`, together with the echoed mode. */
10935
+ rows?: Array<{
10936
+ key: string;
10937
+ data: Record<string, unknown>;
10938
+ inputIndex?: number;
10939
+ ownedByOtherRun: boolean;
10940
+ }>;
10941
+ rowMode?: 'terminalRowsAnyRun';
10942
+ };
10943
+
10932
10944
  export async function readRuntimeSheetDatasetRowKeys(
10933
10945
  context: RuntimeApiContext & { playName: string },
10934
10946
  input: {
10935
10947
  tableNamespace: string;
10936
10948
  runId: string;
10937
10949
  keys: string[];
10938
- rowMode?: 'output' | 'all' | 'terminalAnyRun';
10950
+ rowMode?: 'output' | 'all' | 'terminalAnyRun' | 'terminalRowsAnyRun';
10939
10951
  },
10940
- ): Promise<{ keys: string[] }> {
10952
+ ): Promise<RuntimeSheetDatasetRowKeysResult> {
10941
10953
  if (context.dbSessionStrategy === 'gateway_only') {
10942
10954
  return await postRuntimeApi(context, {
10943
10955
  action: 'runtime_sheet_read_row_keys',
@@ -10950,7 +10962,9 @@ export async function readRuntimeSheetDatasetRowKeys(
10950
10962
  ),
10951
10963
  ];
10952
10964
  if (keys.length === 0) {
10953
- return { keys: [] };
10965
+ return input.rowMode === 'terminalRowsAnyRun'
10966
+ ? { keys: [], rows: [], rowMode: 'terminalRowsAnyRun' }
10967
+ : { keys: [] };
10954
10968
  }
10955
10969
  const session = requireRuntimePostgresSession(
10956
10970
  await getRuntimeDbSession(
@@ -10967,6 +10981,37 @@ export async function readRuntimeSheetDatasetRowKeys(
10967
10981
  },
10968
10982
  ),
10969
10983
  );
10984
+ if (input.rowMode === 'terminalRowsAnyRun') {
10985
+ // Finished rows for the requested keys, whichever run owns them now. A
10986
+ // later run's admission or write moves a row to itself, so run-scoped
10987
+ // reads omit it; finalization uses these rows to return what the earlier
10988
+ // run committed. Pending or running rows are absent: an unfinished
10989
+ // takeover is not a result. The response echoes the mode because an older
10990
+ // reader answers an unknown mode as an `output` read of the caller's keys.
10991
+ const terminalRows = await withRuntimePostgres(session, async (client) => {
10992
+ const { rows: matchedRows } = await client.query<Record<string, unknown>>(
10993
+ `SELECT *
10994
+ FROM ${sheetTable(session)}
10995
+ WHERE _key = ANY($1::text[])
10996
+ AND _status IN ('enriched', 'failed')`,
10997
+ [keys],
10998
+ );
10999
+ return matchedRows;
11000
+ });
11001
+ return {
11002
+ keys: terminalRows.map((raw) => String(raw._key)),
11003
+ rows: terminalRows.map((raw) => {
11004
+ const { data, inputIndex } = mapRuntimePostgresRow({ raw });
11005
+ return {
11006
+ key: String(raw._key),
11007
+ data,
11008
+ ...(typeof inputIndex === 'number' ? { inputIndex } : {}),
11009
+ ownedByOtherRun: raw._run_id !== input.runId,
11010
+ };
11011
+ }),
11012
+ rowMode: 'terminalRowsAnyRun',
11013
+ };
11014
+ }
10970
11015
  const rows = await withRuntimePostgres(session, async (client) => {
10971
11016
  if (input.rowMode === 'terminalAnyRun') {
10972
11017
  const { rows: matchedRows } = await client.query<{ _key: string }>(
@@ -33,6 +33,15 @@ export const SANDBOX_NETWORK_CUT_MAX_MS = 11 * 60_000;
33
33
  export const RUNNER_GATEWAY_CONNECTION_RETRY_BUDGET_MS =
34
34
  SANDBOX_NETWORK_CUT_MAX_MS + 60_000;
35
35
 
36
+ /**
37
+ * How long the runner keeps retrying a retry-safe runtime-control lookup that
38
+ * the gateway answers with 503 `RUNTIME_SCHEDULER_UNAVAILABLE` (its scheduler
39
+ * DB breaker is open). On 2026-11-19 one gateway instance held its breaker open
40
+ * for about 55 seconds; three attempts 350 ms apart turned that into terminal
41
+ * runs. This outlasts such an episode several times over, then fails loudly.
42
+ */
43
+ export const RUNNER_GATEWAY_SCHEDULER_UNAVAILABLE_RETRY_BUDGET_MS = 3 * 60_000;
44
+
36
45
  /**
37
46
  * Runner timeout includes setup, cleanup, and billing headroom after the
38
47
  * user-code runtime cap.