deepline 0.3.534 → 0.3.536

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 (235) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +254 -147
  2. package/dist/bundling-sources/sdk/src/index.ts +4 -0
  3. package/dist/bundling-sources/sdk/src/plays/local-file-discovery.ts +27 -1
  4. package/dist/bundling-sources/sdk/src/plays/run-request.ts +16 -5
  5. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  6. package/dist/bundling-sources/sdk/src/types.ts +2 -23
  7. package/dist/bundling-sources/shared_libs/integration-contracts/monitor-fleet-contract.ts +26 -14
  8. package/dist/bundling-sources/shared_libs/integration-contracts/monitor-input-contract.ts +33 -8
  9. package/dist/bundling-sources/shared_libs/monitors/fleets/count-drift-alert.ts +121 -0
  10. package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +8 -0
  11. package/dist/bundling-sources/shared_libs/monitors/fleets/plan.ts +14 -82
  12. package/dist/bundling-sources/shared_libs/monitors/package.json +1 -0
  13. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +4 -4
  14. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +0 -26
  15. package/dist/bundling-sources/shared_libs/play-runtime/activity-observation.ts +36 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +21 -31
  17. package/dist/bundling-sources/shared_libs/play-runtime/call-requeue-state-machine.ts +420 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +727 -102
  19. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +26 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/durable-retry-policy.ts +624 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +12 -10
  22. package/dist/bundling-sources/shared_libs/play-runtime/durable-summary-events.ts +3 -1
  23. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +71 -2
  24. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +60 -1
  25. package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +2 -0
  26. package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +1 -0
  27. package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +372 -10
  28. package/dist/bundling-sources/shared_libs/play-runtime/memory-ledger.ts +15 -2
  29. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +21 -0
  30. package/dist/bundling-sources/shared_libs/play-runtime/prebuilt-result-quality.ts +1 -1
  31. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +6 -0
  32. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/fixture-capacity-simulator.ts +1 -0
  33. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/gradient2-concurrency-controller.ts +41 -0
  34. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-capacity-policy.ts +6 -0
  35. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-concurrency-policy.ts +9 -0
  36. package/dist/bundling-sources/shared_libs/play-runtime/provider-no-progress.ts +6 -2
  37. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +17 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +2 -2
  39. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +5 -2
  40. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-tool-hooks.ts +63 -3
  41. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +7 -0
  42. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-compute-usage.ts +31 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +6 -0
  44. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +26 -1
  45. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-scope.ts +11 -4
  46. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +73 -18
  47. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +169 -2
  48. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +26 -4
  49. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +90 -49
  50. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +136 -30
  51. package/dist/bundling-sources/shared_libs/plays/launch/input-contract.ts +13 -1
  52. package/dist/bundling-sources/shared_libs/plays/local-file-discovery.ts +68 -1
  53. package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +63 -13
  54. package/dist/bundling-sources/shared_libs/product-notifications/configuration-draft.ts +57 -1
  55. package/dist/bundling-sources/shared_libs/product-notifications/configuration.ts +22 -9
  56. package/dist/cli/auth-6XQKFOLG.js +43 -0
  57. package/dist/cli/{auth-MHQYIMVX.mjs → auth-KCTCUO7P.mjs} +7 -7
  58. package/dist/cli/{billing-YQLNP4S5.js → billing-4VBGZ3CT.js} +273 -112
  59. package/dist/cli/{billing-LX2PSBJ4.mjs → billing-OOJHKLNS.mjs} +185 -24
  60. package/dist/cli/{chunk-DGKTHWWH.js → chunk-2B4IOGFD.js} +406 -382
  61. package/dist/cli/{chunk-MQORQ7WL.js → chunk-2FCSUOYN.js} +55 -55
  62. package/dist/cli/{chunk-T2N3B7IQ.js → chunk-2GJZLIKW.js} +8 -8
  63. package/dist/cli/{chunk-6IFZPEJE.mjs → chunk-2YWJS76L.mjs} +1 -1
  64. package/dist/cli/{chunk-E7TP25I2.mjs → chunk-3PCYV6ZJ.mjs} +2 -2
  65. package/dist/cli/{chunk-LGRZCHKC.js → chunk-4E5JXZ3W.js} +18 -20
  66. package/dist/cli/{chunk-R4RG4FV5.mjs → chunk-4KWD3MX2.mjs} +13 -10
  67. package/dist/cli/{chunk-SUWTLXCV.js → chunk-6BBGUQJJ.js} +67 -146
  68. package/dist/cli/{chunk-JBBJDFUJ.js → chunk-6VUGBQZQ.js} +5 -5
  69. package/dist/cli/{chunk-2P3NVX65.mjs → chunk-AB2GBOD4.mjs} +40 -27
  70. package/dist/cli/{chunk-62SOZ67Y.mjs → chunk-ANUKBZ6W.mjs} +475 -11
  71. package/dist/cli/{chunk-MG6YL4M7.mjs → chunk-BASLYGXK.mjs} +101 -77
  72. package/dist/cli/{chunk-SQWET4SL.js → chunk-BBTKAASQ.js} +2 -1
  73. package/dist/cli/{chunk-NRO3NTVO.js → chunk-CBV7AKWM.js} +5 -5
  74. package/dist/cli/{chunk-RH3YRMUY.js → chunk-CIDN5K23.js} +1 -1
  75. package/dist/cli/{chunk-QNHHZ63P.mjs → chunk-CQBIO6HW.mjs} +1 -1
  76. package/dist/cli/{chunk-2KHUFWTK.js → chunk-CQDQNZGH.js} +42 -37
  77. package/dist/cli/{chunk-UWNVFAFN.js → chunk-CWSLUNA6.js} +33 -33
  78. package/dist/cli/{chunk-5FXMEEF4.mjs → chunk-CXTW7SRW.mjs} +67 -146
  79. package/dist/cli/{chunk-O53LHONF.mjs → chunk-DA2I2M7D.mjs} +2 -2
  80. package/dist/cli/{chunk-EYXUAJAU.mjs → chunk-DQHUJMCL.mjs} +5 -5
  81. package/dist/cli/{chunk-7GFR5Y4J.mjs → chunk-DUYAMLOC.mjs} +1 -1
  82. package/dist/cli/{chunk-OMVVHX4U.mjs → chunk-E24UGPGG.mjs} +13 -15
  83. package/dist/cli/{chunk-STR5LXK4.mjs → chunk-FSIVF2SI.mjs} +1 -1
  84. package/dist/cli/{chunk-KJVY7V2X.mjs → chunk-GF32SBST.mjs} +1 -1
  85. package/dist/cli/{chunk-AK622KIG.mjs → chunk-GHLDCLSC.mjs} +1 -1
  86. package/dist/cli/{chunk-A6HNT4EE.js → chunk-GTVZKY3F.js} +2 -2
  87. package/dist/cli/{chunk-BXIUZM5N.mjs → chunk-HAJQGP5V.mjs} +2 -2
  88. package/dist/cli/{chunk-6CEUQYMB.js → chunk-HWDKRN7L.js} +3 -3
  89. package/dist/cli/{chunk-5YAJGRWB.js → chunk-IPVRMYWT.js} +7 -7
  90. package/dist/cli/{chunk-ZPGGW27Q.mjs → chunk-JL2OTMSG.mjs} +1 -0
  91. package/dist/cli/{chunk-WR4WETRU.mjs → chunk-JUHDJNSI.mjs} +4 -4
  92. package/dist/cli/{chunk-TQH3533L.mjs → chunk-KPQHUVYW.mjs} +5 -5
  93. package/dist/cli/{chunk-V7SCRUFQ.js → chunk-KWYGWO4Y.js} +9 -6
  94. package/dist/cli/{chunk-DZS4JC7I.js → chunk-LDGZFDUB.js} +2 -2
  95. package/dist/cli/{chunk-EGTUOYYG.js → chunk-LN6RXDTB.js} +523 -59
  96. package/dist/cli/{chunk-DQ5ADV2J.mjs → chunk-LZXZQPA2.mjs} +4 -1
  97. package/dist/cli/{chunk-MYSKWJMA.js → chunk-MSP4DTSD.js} +13 -13
  98. package/dist/cli/{chunk-BNH4Y35W.mjs → chunk-OLH2PHMC.mjs} +2 -2
  99. package/dist/cli/{chunk-NNAE7E23.mjs → chunk-OUDTOMZC.mjs} +7 -9
  100. package/dist/cli/{chunk-GESIFFQX.mjs → chunk-OVX3Q5Q3.mjs} +1 -1
  101. package/dist/cli/{chunk-ENCA6O2D.mjs → chunk-PNY3BWHP.mjs} +2 -2
  102. package/dist/cli/{chunk-KSA2XE4T.js → chunk-Q4MNUOS4.js} +316 -303
  103. package/dist/cli/{chunk-GTXSUPCJ.js → chunk-Q5CXV3E3.js} +2 -2
  104. package/dist/cli/{chunk-VAG5YKP6.mjs → chunk-RVSSQPQO.mjs} +1 -1
  105. package/dist/cli/{chunk-VE7ZPLN2.js → chunk-SLPJ3LXI.js} +22 -22
  106. package/dist/cli/{chunk-IX45S5VC.js → chunk-TX5TUHJN.js} +17 -19
  107. package/dist/cli/{chunk-IF75RD6U.js → chunk-U2LVWCTD.js} +18 -6
  108. package/dist/cli/{chunk-ZS2WHWWL.js → chunk-UNDLNT3V.js} +1 -1
  109. package/dist/cli/{chunk-NDFNBJGL.js → chunk-VBDZIMWD.js} +26 -26
  110. package/dist/cli/{chunk-GVGQ6NZW.js → chunk-W7AEIGZR.js} +41 -41
  111. package/dist/cli/{chunk-WDNRPZED.mjs → chunk-WC5M3JXE.mjs} +2 -2
  112. package/dist/cli/{chunk-C374C22Y.js → chunk-WOQO3GV4.js} +14 -11
  113. package/dist/cli/{chunk-MQX363YF.js → chunk-XBAH3TKU.js} +5 -5
  114. package/dist/cli/{chunk-BDWZBMGV.mjs → chunk-XJD2GYUP.mjs} +5 -5
  115. package/dist/cli/{chunk-XRZJKHUA.mjs → chunk-XVZRJJDS.mjs} +4 -4
  116. package/dist/cli/{chunk-TVINIDHB.js → chunk-Y2NTPYGS.js} +17 -17
  117. package/dist/cli/{chunk-6GTGWZJG.mjs → chunk-YBMHOH6H.mjs} +4 -4
  118. package/dist/cli/{chunk-TG2UB3A5.mjs → chunk-YRLAUGQY.mjs} +3 -3
  119. package/dist/cli/{chunk-FKD3KL5Q.mjs → chunk-Z2XA6YU4.mjs} +10 -5
  120. package/dist/cli/{chunk-KXQCUX3X.mjs → chunk-Z7UIOGW4.mjs} +3 -3
  121. package/dist/cli/{chunk-HCD36BP6.js → chunk-ZEV2Y56V.js} +44 -44
  122. package/dist/cli/{chunk-MI6ZP7XI.mjs → chunk-ZG7BOECV.mjs} +18 -6
  123. package/dist/cli/{chunk-XBK6WCVA.js → chunk-ZILSRDIN.js} +8 -8
  124. package/dist/cli/{chunk-B2AS3R5W.js → chunk-ZISEH7OL.js} +16 -16
  125. package/dist/cli/{chunk-HPJAE6PP.js → chunk-ZZ4MF2GI.js} +6 -6
  126. package/dist/cli/command-docs.js +2 -2
  127. package/dist/cli/command-docs.mjs +1 -1
  128. package/dist/cli/{csv-U3M2G76R.js → csv-2V2DIFNG.js} +15 -15
  129. package/dist/cli/{csv-4ID4E5W3.mjs → csv-P3HLK4GO.mjs} +6 -6
  130. package/dist/cli/{db-IHAQIKEQ.js → db-MREAQVW6.js} +36 -36
  131. package/dist/cli/{db-LHX5BBCZ.mjs → db-ZYOY3QRQ.mjs} +9 -9
  132. package/dist/cli/describe-IKZFOADR.mjs +49 -0
  133. package/dist/cli/describe-WW3OQRLP.js +49 -0
  134. package/dist/cli/describe-core.d.mts +3 -3
  135. package/dist/cli/describe-core.d.ts +3 -3
  136. package/dist/cli/describe-core.js +5 -5
  137. package/dist/cli/describe-core.mjs +4 -4
  138. package/dist/cli/{executions-CJ5LV23G.js → executions-H5IJ7QSQ.js} +11 -11
  139. package/dist/cli/{executions-UJ6JZUL5.mjs → executions-KTSY5M34.mjs} +9 -9
  140. package/dist/cli/{feedback-TGUBVGRP.js → feedback-724QK3Z5.js} +16 -16
  141. package/dist/cli/{feedback-YGTPJBRJ.mjs → feedback-WWJRIXEU.mjs} +8 -8
  142. package/dist/cli/git-PHYRD56H.js +25 -0
  143. package/dist/cli/{git-3DOTQHJO.mjs → git-R5VRG7X6.mjs} +7 -7
  144. package/dist/cli/index.js +151 -157
  145. package/dist/cli/index.mjs +51 -57
  146. package/dist/cli/{legacy-noops-BHEHVFHI.js → legacy-noops-C6GDEGPU.js} +11 -11
  147. package/dist/cli/{legacy-noops-RBBYRVLG.mjs → legacy-noops-PWZ5XLAO.mjs} +8 -8
  148. package/dist/cli/{monitors-XECKLAXA.js → monitors-VAVQ4WCE.js} +125 -122
  149. package/dist/cli/{monitors-5AJCG6IV.mjs → monitors-WQSKMHAP.mjs} +19 -16
  150. package/dist/cli/{org-DOBAIYWG.js → org-CWWRWXZQ.js} +89 -89
  151. package/dist/cli/{org-ZAAIEZKB.mjs → org-MAL4QPVF.mjs} +9 -9
  152. package/dist/cli/{play-KLYRMQPF.mjs → play-ILW6MSNG.mjs} +174 -80
  153. package/dist/cli/{play-E74VN6B7.js → play-WJOWK5PQ.js} +690 -596
  154. package/dist/cli/{providers-XTQXV5LB.mjs → providers-4V2NMLZZ.mjs} +9 -9
  155. package/dist/cli/{providers-APZ6SOSK.js → providers-W662ANCH.js} +12 -12
  156. package/dist/cli/{quickstart-S6WN6NWW.js → quickstart-BW6EBUYX.js} +8 -8
  157. package/dist/cli/{quickstart-X7RHHQCH.mjs → quickstart-C22BR743.mjs} +6 -6
  158. package/dist/cli/{run-3YLIJJ57.js → run-KW7KW4FX.js} +50 -53
  159. package/dist/cli/{run-TZPBBSPX.mjs → run-SPAU5IMW.mjs} +31 -34
  160. package/dist/cli/search-HLE54W5G.js +32 -0
  161. package/dist/cli/{search-VLHE2CMZ.mjs → search-XPC75HLM.mjs} +10 -11
  162. package/dist/cli/{search-output-73BYB7UE.mjs → search-output-JKYJSEPM.mjs} +6 -6
  163. package/dist/cli/{search-output-GCT7PQIT.js → search-output-VJYE7USJ.js} +8 -8
  164. package/dist/cli/{secrets-RLOTGKQZ.mjs → secrets-OJG73GXQ.mjs} +9 -9
  165. package/dist/cli/{secrets-J6CEKXKQ.js → secrets-YB57KGSB.js} +18 -18
  166. package/dist/cli/{sessions-7HZ7OZ62.mjs → sessions-7ZL37BW4.mjs} +8 -8
  167. package/dist/cli/sessions-VEBYZIEU.js +22 -0
  168. package/dist/cli/{settings-WRV5XEZC.js → settings-A7DD2ZYE.js} +88 -89
  169. package/dist/cli/{settings-72K5YCIS.mjs → settings-RKSQB7FA.mjs} +15 -16
  170. package/dist/cli/{setup-KQFY6WT4.mjs → setup-NXDUTITY.mjs} +11 -12
  171. package/dist/cli/{setup-QVXWT2EQ.js → setup-S3K5YU62.js} +51 -52
  172. package/dist/cli/skills-NVQ744CN.js +36 -0
  173. package/dist/cli/{skills-C3K3E473.mjs → skills-VMFAIDO6.mjs} +9 -10
  174. package/dist/cli/{tools-4A2OH6MB.mjs → tools-52NTHBSJ.mjs} +20 -21
  175. package/dist/cli/tools-SBDUL3WB.js +56 -0
  176. package/dist/cli/update-HHVFZPCV.js +34 -0
  177. package/dist/cli/{update-BS6USKPR.mjs → update-SAKBEKMV.mjs} +11 -12
  178. package/dist/cli/{views-WB6GFTRX.mjs → views-ACRV7MD6.mjs} +54 -10
  179. package/dist/cli/{views-4NZGAXHL.js → views-C3GJOBDG.js} +66 -22
  180. package/dist/cli/{workflow-2D4WX55R.mjs → workflow-CS22E7TC.mjs} +10 -10
  181. package/dist/cli/{workflow-L2QTQZYV.js → workflow-ZNWCZEGN.js} +20 -20
  182. package/dist/{client-DoUVSkqC.d.mts → client-BlLYQDNo.d.mts} +1 -1
  183. package/dist/{client-DQm56zMs.d.ts → client-DSQlkIDO.d.ts} +1 -1
  184. package/dist/{client-core-C7KkUIE_.d.ts → client-core-CDwapXy5.d.ts} +167 -108
  185. package/dist/{client-core-CPlwsC1Q.d.mts → client-core-rX7n2H8U.d.mts} +167 -108
  186. package/dist/{compiler-manifest-DsxsQP-T.d.mts → compiler-manifest-BHNC4RL-.d.mts} +58 -21
  187. package/dist/{compiler-manifest-DsxsQP-T.d.ts → compiler-manifest-BHNC4RL-.d.ts} +58 -21
  188. package/dist/{errors-qdJUVQ3g.d.mts → errors-D7sPXrvB.d.mts} +1 -1
  189. package/dist/{errors-Bk5h1D-C.d.ts → errors-lhtIWG5Z.d.ts} +1 -1
  190. package/dist/{index-bL66eHYz.d.ts → index-CQTBHXHr.d.ts} +1 -1
  191. package/dist/{index-PaupwX1B.d.mts → index-NaDZq2xf.d.mts} +1 -1
  192. package/dist/index.d.mts +7 -7
  193. package/dist/index.d.ts +7 -7
  194. package/dist/index.js +15 -15
  195. package/dist/index.mjs +11 -11
  196. package/dist/install-integrity.json +131 -132
  197. package/dist/monitor-fleet-contract.d.mts +17 -11
  198. package/dist/monitor-fleet-contract.d.ts +17 -11
  199. package/dist/monitor-fleet-contract.js +3 -3
  200. package/dist/monitor-fleet-contract.mjs +2 -2
  201. package/dist/monitor-input-contract.js +2 -2
  202. package/dist/monitor-input-contract.mjs +1 -1
  203. package/dist/plays/bundle-play-file.d.mts +3 -3
  204. package/dist/plays/bundle-play-file.d.ts +3 -3
  205. package/dist/plays/bundle-play-file.mjs +67 -3
  206. package/dist/plays/csv-data-input.js +3 -3
  207. package/dist/plays/csv-data-input.mjs +2 -2
  208. package/dist/plays/play-description.d.mts +2 -2
  209. package/dist/plays/play-description.d.ts +2 -2
  210. package/dist/plays/run-request.d.mts +2 -2
  211. package/dist/plays/run-request.d.ts +2 -2
  212. package/dist/plays/run-request.js +3 -3
  213. package/dist/plays/run-request.mjs +2 -2
  214. package/dist/release.d.mts +1 -1
  215. package/dist/release.d.ts +1 -1
  216. package/dist/release.js +2 -2
  217. package/dist/release.mjs +1 -1
  218. package/dist/server.d.mts +4 -4
  219. package/dist/server.d.ts +4 -4
  220. package/dist/server.js +12 -12
  221. package/dist/server.mjs +6 -6
  222. package/package.json +1 -1
  223. package/dist/cli/auth-UP2RGPI6.js +0 -43
  224. package/dist/cli/chunk-5LZ5VSOK.mjs +0 -405
  225. package/dist/cli/chunk-D3J2Y2BP.js +0 -405
  226. package/dist/cli/describe-CI4MREFF.mjs +0 -50
  227. package/dist/cli/describe-IVTSD7ST.js +0 -50
  228. package/dist/cli/git-R3W25XIF.js +0 -25
  229. package/dist/cli/pages-FUOSF6BE.mjs +0 -266
  230. package/dist/cli/pages-TLC2N6L7.js +0 -266
  231. package/dist/cli/search-NB5CBALV.js +0 -33
  232. package/dist/cli/sessions-SFCZSB77.js +0 -22
  233. package/dist/cli/skills-WIJEHVLA.js +0 -37
  234. package/dist/cli/tools-VMMERMLO.js +0 -57
  235. package/dist/cli/update-54WZQDTS.js +0 -35
@@ -125,6 +125,11 @@ export interface ToolCallRequest {
125
125
  input: Record<string, unknown>;
126
126
  timeoutMs?: number;
127
127
  receiptWaitMs?: number;
128
+ /**
129
+ * The call's own retry policy (`ctx.tools.execute({ retry })`). A call
130
+ * that sets it never joins a native provider batch, so the policy applies.
131
+ */
132
+ retry?: import('../plays/authoring-contract').PlayToolCallRetryPolicy;
128
133
  tableNamespace?: string;
129
134
  rowKey?: string | null;
130
135
  description?: string;
@@ -1167,6 +1172,17 @@ export interface ContextOptions {
1167
1172
  requiresExecutionFence?: boolean;
1168
1173
  providerServerErrorReplay?: 'idempotent_key' | 'read_safe' | 'never';
1169
1174
  } | null>;
1175
+ /**
1176
+ * The action's effect and the Durable retry policy snapshot this attempt
1177
+ * read with the tool's metadata (attempt start, never per call). Absent or
1178
+ * null (an app that predates the policy): the call never parks. A missing or invalid stored policy resolves to the
1179
+ * compiled defaults with warnings.
1180
+ */
1181
+ getToolDurableRetryContext?: (toolId: string) => Promise<{
1182
+ effect: 'read' | 'write' | 'destructive' | null;
1183
+ writeIdempotency: 'idempotent_write' | 'non_idempotent_write' | null;
1184
+ policy: import('./durable-retry-policy').DurableRetryPolicySnapshot;
1185
+ } | null>;
1170
1186
  getToolActionCacheVersion?: (toolId: string) => Promise<string> | string;
1171
1187
  /**
1172
1188
  * Source-declared older action identities that remain safe to read. They
@@ -1381,6 +1397,16 @@ export interface PlayCheckpoint {
1381
1397
  providerRetryCursors?: Record<string, ProviderRetryCursor>;
1382
1398
  /** First provider hold per credential scope, retained across durable resumes. */
1383
1399
  providerNoProgressStartedAtMsByScope?: Record<string, number>;
1400
+ /**
1401
+ * Requeue state of calls parked after their in-call retries were spent,
1402
+ * keyed by the call's durable receipt identity. Owned by
1403
+ * `call-requeue-state-machine.ts`; terminal calls are removed. Optional:
1404
+ * older checkpoints have none and older runners ignore it.
1405
+ */
1406
+ callRequeueStates?: Record<
1407
+ string,
1408
+ import('./call-requeue-state-machine').CallRequeueRecord
1409
+ >;
1384
1410
  /** Waterfall batches that have completed: key = `${toolName}:${provider}`, value = results array. */
1385
1411
  completedBatches: Record<string, BatchResult[]>;
1386
1412
  /** Tool call batches that have completed: key = toolId, value = sparse row-cache-key -> result map. */
@@ -0,0 +1,624 @@
1
+ /**
2
+ * The Durable retry policy: what a Play call does after a retryable failure,
3
+ * per error class. It is live-tunable control-plane data (Convex
4
+ * `durableRetryPolicyVersions`), versioned, and read as a snapshot at
5
+ * admission and at each park decision, never per call. A missing or invalid
6
+ * stored policy falls back to `COMPILED_DURABLE_RETRY_POLICY`, loudly.
7
+ *
8
+ * Reader-first and additive: a stored policy may carry classes or fields this
9
+ * build does not know (a newer writer); they are ignored and reported. A class
10
+ * the stored policy omits takes its compiled default. Never repurpose a class
11
+ * or field name; add a new one.
12
+ *
13
+ * This module is pure (no I/O) so the Convex store, the admin route, the CLI
14
+ * and the runtime validate with the same code.
15
+ */
16
+ import { PROVIDER_NO_PROGRESS_MAX_MS } from './provider-no-progress';
17
+
18
+ /**
19
+ * The closed set of error classes. Adding one is additive: older readers
20
+ * ignore it, and the classifier that emits it ships before any policy uses it.
21
+ */
22
+ export const DURABLE_RETRY_ERROR_CLASSES = [
23
+ /** Deepline refused before any provider dispatch (billing plane, limiter,
24
+ * capacity, connect-before-send). Provably not processed. */
25
+ 'never_sent',
26
+ /** Provider 502/503/504. */
27
+ 'provider_unavailable',
28
+ /** Provider 500: the provider may have processed the request. */
29
+ 'provider_ambiguous_500',
30
+ /** The request was sent and no answer arrived in time. */
31
+ 'timeout_after_send',
32
+ /** Provider 429. In-call pacing stays with the provider pacer. */
33
+ 'rate_limit_429',
34
+ /** Workspace balance cannot fund the call (402). */
35
+ 'billing_insufficient_credits',
36
+ /** Workspace monthly spending cap reached (402). */
37
+ 'billing_monthly_cap',
38
+ ] as const;
39
+
40
+ export type DurableRetryErrorClass =
41
+ (typeof DURABLE_RETRY_ERROR_CLASSES)[number];
42
+
43
+ /**
44
+ * Which writes may be resent (reads follow `eligibility.reads`):
45
+ * - `never`: no write is resent.
46
+ * - `idempotency_key`: only a write that sent a stable idempotency key the
47
+ * provider honors.
48
+ * - `idempotent_write`: an `idempotent_write` action (upsert, assert, update,
49
+ * set, patch, put, move, delete, add-if-absent; generic HTTP by method), or
50
+ * a write that sent an honored key.
51
+ * - `all`: every write, one-shot creates and sends included.
52
+ *
53
+ * Founder decision (2026-11-14): `all` is the default for every class that
54
+ * resends, provider 5xx included, with the duplicate risk accepted
55
+ * (timeout_after_send does not resend at all by default). After an ambiguous 5xx a one-shot write may apply twice (a second
56
+ * HubSpot object, a second Slack message). Narrow it live per class with
57
+ * `deepline-admin durable-retry-policy set` (`idempotent_write`,
58
+ * `idempotency_key` or `never`).
59
+ */
60
+ export const DURABLE_RETRY_WRITE_ELIGIBILITY = [
61
+ 'never',
62
+ 'idempotency_key',
63
+ 'idempotent_write',
64
+ 'all',
65
+ ] as const;
66
+ export type DurableRetryEligibility =
67
+ (typeof DURABLE_RETRY_WRITE_ELIGIBILITY)[number];
68
+
69
+ export type DurableRetryClassRule = {
70
+ /** Resends inside one call before it parks or fails. 1 means no resend. */
71
+ inCall: {
72
+ maxAttempts: number;
73
+ baseDelayMs: number;
74
+ maxDelayMs: number;
75
+ /** 0 to 1: each delay is scaled by 1 ± jitterRatio. */
76
+ jitterRatio: number;
77
+ /**
78
+ * Optional, read for `rate_limit_429` only: how long in-call provider
79
+ * pacing waits without a successful response before the call is retried
80
+ * durably. Absent is PROVIDER_NO_PROGRESS_MAX_MS (10 minutes).
81
+ */
82
+ noProgressMs?: number;
83
+ };
84
+ park: {
85
+ enabled: boolean;
86
+ /** Wait before the nth requeue; the last step repeats. */
87
+ ladderMs: number[];
88
+ /**
89
+ * Kill after this many parks in a row that end in the same class again.
90
+ * null: only the window bounds it.
91
+ */
92
+ consecutiveFailureLimit: number | null;
93
+ };
94
+ /**
95
+ * Overall wall-clock window from the first park. Past it, the original error
96
+ * reaches the Play. Extensions are entered in order on a fixed schedule;
97
+ * only this call's own history counts, never other calls in the run.
98
+ */
99
+ window: {
100
+ initialMs: number;
101
+ extensionsMs: number[];
102
+ };
103
+ eligibility: {
104
+ reads: boolean;
105
+ writes: DurableRetryEligibility;
106
+ };
107
+ };
108
+
109
+ /**
110
+ * No format number: the document only grows by optional classes and fields,
111
+ * which older readers ignore (runtime compatibility contract).
112
+ */
113
+ export type DurableRetryPolicy = {
114
+ classes: Record<DurableRetryErrorClass, DurableRetryClassRule>;
115
+ };
116
+
117
+ const SECOND = 1_000;
118
+ const MINUTE = 60 * SECOND;
119
+ const HOUR = 60 * MINUTE;
120
+ const DAY = 24 * HOUR;
121
+
122
+ /** 2, 4, 8, 16, 32, 60 minutes, then 60 minutes per requeue. */
123
+ const STANDARD_LADDER_MS = [
124
+ 2 * MINUTE,
125
+ 4 * MINUTE,
126
+ 8 * MINUTE,
127
+ 16 * MINUTE,
128
+ 32 * MINUTE,
129
+ 60 * MINUTE,
130
+ ];
131
+
132
+ /**
133
+ * 12 h, extended to 18 h and then 24 h on a fixed schedule, per call. Covers the hour-long QuickEnrich outage (2026-11-13) and the
134
+ * multi-hour BILLING_UNAVAILABLE bursts (2026-11-12 06:00–09:00Z, about 5,400
135
+ * calls) with margin, without holding a stuck run longer than a day.
136
+ */
137
+ const STANDARD_WINDOW = {
138
+ initialMs: 12 * HOUR,
139
+ extensionsMs: [6 * HOUR, 6 * HOUR],
140
+ };
141
+
142
+ const NO_PARK: DurableRetryClassRule['park'] = {
143
+ enabled: false,
144
+ ladderMs: [2 * MINUTE],
145
+ consecutiveFailureLimit: null,
146
+ };
147
+
148
+ /**
149
+ * The compiled defaults: the policy whenever the stored one is missing or
150
+ * invalid. Every class that resends resends every write
151
+ * (`eligibility.writes: 'all'`); see `DURABLE_RETRY_WRITE_ELIGIBILITY` for
152
+ * the accepted duplicate risk. timeout_after_send is off: no park, no resend.
153
+ */
154
+ export const COMPILED_DURABLE_RETRY_POLICY: DurableRetryPolicy = {
155
+ classes: {
156
+ never_sent: {
157
+ inCall: {
158
+ maxAttempts: 5,
159
+ baseDelayMs: 1 * SECOND,
160
+ maxDelayMs: 5 * SECOND,
161
+ jitterRatio: 0.2,
162
+ },
163
+ park: {
164
+ enabled: true,
165
+ ladderMs: STANDARD_LADDER_MS,
166
+ consecutiveFailureLimit: null,
167
+ },
168
+ window: STANDARD_WINDOW,
169
+ eligibility: { reads: true, writes: 'all' },
170
+ },
171
+ provider_unavailable: {
172
+ inCall: {
173
+ maxAttempts: 3,
174
+ baseDelayMs: 2 * SECOND,
175
+ maxDelayMs: 30 * SECOND,
176
+ jitterRatio: 0.2,
177
+ },
178
+ park: {
179
+ enabled: true,
180
+ ladderMs: STANDARD_LADDER_MS,
181
+ consecutiveFailureLimit: null,
182
+ },
183
+ window: STANDARD_WINDOW,
184
+ eligibility: { reads: true, writes: 'all' },
185
+ },
186
+ provider_ambiguous_500: {
187
+ inCall: {
188
+ maxAttempts: 3,
189
+ baseDelayMs: 2 * SECOND,
190
+ maxDelayMs: 30 * SECOND,
191
+ jitterRatio: 0.2,
192
+ },
193
+ park: {
194
+ enabled: true,
195
+ ladderMs: STANDARD_LADDER_MS,
196
+ consecutiveFailureLimit: 6,
197
+ },
198
+ window: STANDARD_WINDOW,
199
+ eligibility: { reads: true, writes: 'all' },
200
+ },
201
+ // Founder decision (2026-11-14): no retries on a timeout after the
202
+ // request was sent, for reads or writes. Defined so it stays explicit and
203
+ // can be turned on live; a connect that never sent stays in never_sent.
204
+ timeout_after_send: {
205
+ inCall: {
206
+ maxAttempts: 1,
207
+ baseDelayMs: 2 * SECOND,
208
+ maxDelayMs: 30 * SECOND,
209
+ jitterRatio: 0.2,
210
+ },
211
+ park: {
212
+ enabled: false,
213
+ ladderMs: STANDARD_LADDER_MS,
214
+ consecutiveFailureLimit: 6,
215
+ },
216
+ window: STANDARD_WINDOW,
217
+ eligibility: { reads: false, writes: 'never' },
218
+ },
219
+ rate_limit_429: {
220
+ // In-call pacing stays with the existing provider pacer; this class
221
+ // decides what happens once that pacing gives up (after noProgressMs
222
+ // without a successful response).
223
+ inCall: {
224
+ maxAttempts: 8,
225
+ baseDelayMs: 1 * SECOND,
226
+ maxDelayMs: 30 * SECOND,
227
+ jitterRatio: 0.2,
228
+ noProgressMs: PROVIDER_NO_PROGRESS_MAX_MS,
229
+ },
230
+ park: {
231
+ enabled: true,
232
+ ladderMs: STANDARD_LADDER_MS,
233
+ consecutiveFailureLimit: null,
234
+ },
235
+ // A 429 may extend longest: daily provider quotas reset within 24 h.
236
+ window: {
237
+ initialMs: 12 * HOUR,
238
+ extensionsMs: [6 * HOUR, 6 * HOUR, 12 * HOUR, 12 * HOUR],
239
+ },
240
+ eligibility: { reads: true, writes: 'all' },
241
+ },
242
+ billing_insufficient_credits: {
243
+ inCall: {
244
+ maxAttempts: 1,
245
+ baseDelayMs: 1 * SECOND,
246
+ maxDelayMs: 1 * SECOND,
247
+ jitterRatio: 0,
248
+ },
249
+ park: {
250
+ enabled: true,
251
+ // The ladder rechecks billing admission; nothing wakes it earlier yet.
252
+ ladderMs: [15 * MINUTE, 1 * HOUR, 4 * HOUR],
253
+ consecutiveFailureLimit: 3,
254
+ },
255
+ window: { initialMs: 3 * DAY, extensionsMs: [] },
256
+ eligibility: { reads: true, writes: 'all' },
257
+ },
258
+ billing_monthly_cap: {
259
+ inCall: {
260
+ maxAttempts: 1,
261
+ baseDelayMs: 1 * SECOND,
262
+ maxDelayMs: 1 * SECOND,
263
+ jitterRatio: 0,
264
+ },
265
+ park: {
266
+ enabled: true,
267
+ ladderMs: [1 * HOUR, 4 * HOUR, 12 * HOUR],
268
+ consecutiveFailureLimit: 3,
269
+ },
270
+ window: { initialMs: 3 * DAY, extensionsMs: [] },
271
+ eligibility: { reads: true, writes: 'all' },
272
+ },
273
+ },
274
+ };
275
+
276
+ /**
277
+ * Policy fields that are stored and validated but not applied yet, so an
278
+ * operator who tunes them sees why nothing changed. Remove an entry in the
279
+ * change that wires it.
280
+ */
281
+ export const DURABLE_RETRY_POLICY_FIELDS_NOT_YET_APPLIED: Readonly<
282
+ Record<string, string>
283
+ > = {
284
+ 'classes.*.inCall.maxAttempts':
285
+ 'In-call retries still follow the runtime retry policy (tool-execute-retry-policy.ts).',
286
+ 'classes.*.inCall.baseDelayMs':
287
+ 'In-call backoff still follows the runtime retry policy.',
288
+ 'classes.*.inCall.maxDelayMs':
289
+ 'In-call backoff still follows the runtime retry policy.',
290
+ 'classes.timeout_after_send':
291
+ 'A provider HTTP 504 or a transport timeout not proven to be before send is timeout_after_send.',
292
+ 'classes.*.inCall.noProgressMs':
293
+ 'Read for rate_limit_429 only; other classes ignore it.',
294
+ };
295
+
296
+ /** Bounds a stored policy must respect; outside them it is rejected whole. */
297
+ export const DURABLE_RETRY_POLICY_LIMITS = {
298
+ // A fenced call's park segment must stay within the gateway's ladder
299
+ // ceiling (EXECUTION_GATEWAY_MAX_LOGICAL_ATTEMPT).
300
+ inCallMaxAttempts: 32,
301
+ inCallMaxDelayMs: 5 * MINUTE,
302
+ ladderMaxSteps: 20,
303
+ ladderStepMinMs: 30 * SECOND,
304
+ ladderStepMaxMs: 24 * HOUR,
305
+ windowMaxMs: 14 * DAY,
306
+ consecutiveFailureLimitMax: 100,
307
+ } as const;
308
+
309
+ export type DurableRetryPolicyValidation =
310
+ | { ok: true; policy: DurableRetryPolicy; notices: string[] }
311
+ | { ok: false; errors: string[] };
312
+
313
+ function isRecord(value: unknown): value is Record<string, unknown> {
314
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
315
+ }
316
+
317
+ function intIn(
318
+ errors: string[],
319
+ path: string,
320
+ value: unknown,
321
+ min: number,
322
+ max: number,
323
+ ): number {
324
+ if (
325
+ typeof value !== 'number' ||
326
+ !Number.isSafeInteger(value) ||
327
+ value < min ||
328
+ value > max
329
+ ) {
330
+ errors.push(`${path} must be a whole number from ${min} to ${max}.`);
331
+ return min;
332
+ }
333
+ return value;
334
+ }
335
+
336
+ function validateClassRule(
337
+ errors: string[],
338
+ notices: string[],
339
+ path: string,
340
+ raw: unknown,
341
+ ): DurableRetryClassRule {
342
+ const limits = DURABLE_RETRY_POLICY_LIMITS;
343
+ if (!isRecord(raw)) {
344
+ errors.push(`${path} must be an object.`);
345
+ return COMPILED_DURABLE_RETRY_POLICY.classes.never_sent;
346
+ }
347
+ for (const key of Object.keys(raw)) {
348
+ if (!['inCall', 'park', 'window', 'eligibility'].includes(key)) {
349
+ notices.push(`${path}.${key} is not known to this build; ignored.`);
350
+ }
351
+ }
352
+ const inCall = isRecord(raw.inCall) ? raw.inCall : {};
353
+ if (!isRecord(raw.inCall)) errors.push(`${path}.inCall must be an object.`);
354
+ const maxAttempts = intIn(
355
+ errors,
356
+ `${path}.inCall.maxAttempts`,
357
+ inCall.maxAttempts,
358
+ 1,
359
+ limits.inCallMaxAttempts,
360
+ );
361
+ const baseDelayMs = intIn(
362
+ errors,
363
+ `${path}.inCall.baseDelayMs`,
364
+ inCall.baseDelayMs,
365
+ 0,
366
+ limits.inCallMaxDelayMs,
367
+ );
368
+ const maxDelayMs = intIn(
369
+ errors,
370
+ `${path}.inCall.maxDelayMs`,
371
+ inCall.maxDelayMs,
372
+ 0,
373
+ limits.inCallMaxDelayMs,
374
+ );
375
+ if (maxDelayMs < baseDelayMs) {
376
+ errors.push(`${path}.inCall.maxDelayMs must be at least baseDelayMs.`);
377
+ }
378
+ const jitterRatio = inCall.jitterRatio;
379
+ if (
380
+ typeof jitterRatio !== 'number' ||
381
+ !Number.isFinite(jitterRatio) ||
382
+ jitterRatio < 0 ||
383
+ jitterRatio > 1
384
+ ) {
385
+ errors.push(`${path}.inCall.jitterRatio must be a number from 0 to 1.`);
386
+ }
387
+ const noProgressMs =
388
+ inCall.noProgressMs === undefined
389
+ ? undefined
390
+ : intIn(
391
+ errors,
392
+ `${path}.inCall.noProgressMs`,
393
+ inCall.noProgressMs,
394
+ limits.ladderStepMinMs,
395
+ limits.ladderStepMaxMs,
396
+ );
397
+
398
+ const park = isRecord(raw.park) ? raw.park : {};
399
+ if (!isRecord(raw.park)) errors.push(`${path}.park must be an object.`);
400
+ if (typeof park.enabled !== 'boolean') {
401
+ errors.push(`${path}.park.enabled must be a boolean.`);
402
+ }
403
+ const ladder = Array.isArray(park.ladderMs) ? park.ladderMs : [];
404
+ if (
405
+ !Array.isArray(park.ladderMs) ||
406
+ ladder.length < 1 ||
407
+ ladder.length > limits.ladderMaxSteps
408
+ ) {
409
+ errors.push(
410
+ `${path}.park.ladderMs must list 1 to ${limits.ladderMaxSteps} waits.`,
411
+ );
412
+ }
413
+ const ladderMs = ladder.map((step, index) =>
414
+ intIn(
415
+ errors,
416
+ `${path}.park.ladderMs[${index}]`,
417
+ step,
418
+ limits.ladderStepMinMs,
419
+ limits.ladderStepMaxMs,
420
+ ),
421
+ );
422
+ const consecutive = park.consecutiveFailureLimit;
423
+ const consecutiveFailureLimit =
424
+ consecutive === null
425
+ ? null
426
+ : intIn(
427
+ errors,
428
+ `${path}.park.consecutiveFailureLimit`,
429
+ consecutive,
430
+ 1,
431
+ limits.consecutiveFailureLimitMax,
432
+ );
433
+ const window = isRecord(raw.window) ? raw.window : {};
434
+ if (!isRecord(raw.window)) errors.push(`${path}.window must be an object.`);
435
+ const initialMs = intIn(
436
+ errors,
437
+ `${path}.window.initialMs`,
438
+ window.initialMs,
439
+ limits.ladderStepMinMs,
440
+ limits.windowMaxMs,
441
+ );
442
+ const extensions = Array.isArray(window.extensionsMs)
443
+ ? window.extensionsMs
444
+ : [];
445
+ if (!Array.isArray(window.extensionsMs)) {
446
+ errors.push(`${path}.window.extensionsMs must be a list.`);
447
+ }
448
+ const extensionsMs = extensions.map((step, index) =>
449
+ intIn(
450
+ errors,
451
+ `${path}.window.extensionsMs[${index}]`,
452
+ step,
453
+ limits.ladderStepMinMs,
454
+ limits.windowMaxMs,
455
+ ),
456
+ );
457
+ if (
458
+ initialMs + extensionsMs.reduce((sum, step) => sum + step, 0) >
459
+ limits.windowMaxMs
460
+ ) {
461
+ errors.push(
462
+ `${path}.window may not exceed ${limits.windowMaxMs} ms in total.`,
463
+ );
464
+ }
465
+ // A wait longer than the whole window could never run: the call would end
466
+ // its retries at that park instead (like a schedule-to-close timeout).
467
+ const windowTotalMs =
468
+ initialMs + extensionsMs.reduce((sum, step) => sum + step, 0);
469
+ ladderMs.forEach((step, index) => {
470
+ if (
471
+ Number.isFinite(step) &&
472
+ Number.isFinite(windowTotalMs) &&
473
+ step > windowTotalMs
474
+ ) {
475
+ errors.push(
476
+ `${path}.park.ladderMs[${index}] is longer than the class window (${windowTotalMs} ms) and could never run.`,
477
+ );
478
+ }
479
+ });
480
+
481
+ const eligibility = isRecord(raw.eligibility) ? raw.eligibility : {};
482
+ if (!isRecord(raw.eligibility)) {
483
+ errors.push(`${path}.eligibility must be an object.`);
484
+ }
485
+ if (typeof eligibility.reads !== 'boolean') {
486
+ errors.push(`${path}.eligibility.reads must be a boolean.`);
487
+ }
488
+ const writes = DURABLE_RETRY_WRITE_ELIGIBILITY.find(
489
+ (value) => value === eligibility.writes,
490
+ );
491
+ if (!writes) {
492
+ errors.push(
493
+ `${path}.eligibility.writes must be one of ${DURABLE_RETRY_WRITE_ELIGIBILITY.join(', ')}.`,
494
+ );
495
+ }
496
+
497
+ return {
498
+ inCall: {
499
+ maxAttempts,
500
+ baseDelayMs,
501
+ maxDelayMs,
502
+ jitterRatio: typeof jitterRatio === 'number' ? jitterRatio : 0,
503
+ ...(noProgressMs !== undefined ? { noProgressMs } : {}),
504
+ },
505
+ park: {
506
+ enabled: park.enabled === true,
507
+ ladderMs,
508
+ consecutiveFailureLimit,
509
+ },
510
+ window: { initialMs, extensionsMs },
511
+ eligibility: {
512
+ reads: eligibility.reads === true,
513
+ writes: writes ?? 'never',
514
+ },
515
+ };
516
+ }
517
+
518
+ /**
519
+ * Validate a stored or proposed policy. An unknown class or field is a notice,
520
+ * not an error (a newer writer). An omitted class takes its compiled default
521
+ * and is reported. Anything out of bounds rejects the whole policy.
522
+ */
523
+ export function validateDurableRetryPolicy(
524
+ raw: unknown,
525
+ ): DurableRetryPolicyValidation {
526
+ const errors: string[] = [];
527
+ const notices: string[] = [];
528
+ if (!isRecord(raw))
529
+ return { ok: false, errors: ['policy must be an object.'] };
530
+ for (const key of Object.keys(raw)) {
531
+ if (key !== 'classes') {
532
+ notices.push(`${key} is not known to this build; ignored.`);
533
+ }
534
+ }
535
+ const rawClasses = isRecord(raw.classes) ? raw.classes : null;
536
+ if (!rawClasses) errors.push('classes must be an object.');
537
+ const known = new Set<string>(DURABLE_RETRY_ERROR_CLASSES);
538
+ for (const key of Object.keys(rawClasses ?? {})) {
539
+ if (!known.has(key)) {
540
+ notices.push(`classes.${key} is not known to this build; ignored.`);
541
+ }
542
+ }
543
+ const classes = {} as Record<DurableRetryErrorClass, DurableRetryClassRule>;
544
+ for (const errorClass of DURABLE_RETRY_ERROR_CLASSES) {
545
+ const rule = rawClasses?.[errorClass];
546
+ if (rule === undefined) {
547
+ notices.push(
548
+ `classes.${errorClass} is absent; the compiled default applies.`,
549
+ );
550
+ classes[errorClass] = COMPILED_DURABLE_RETRY_POLICY.classes[errorClass];
551
+ continue;
552
+ }
553
+ classes[errorClass] = validateClassRule(
554
+ errors,
555
+ notices,
556
+ `classes.${errorClass}`,
557
+ rule,
558
+ );
559
+ }
560
+ if (errors.length > 0) return { ok: false, errors };
561
+ return {
562
+ ok: true,
563
+ policy: { classes },
564
+ notices,
565
+ };
566
+ }
567
+
568
+ /** A policy snapshot as the runtime holds it, with where it came from. */
569
+ export type DurableRetryPolicySnapshot = {
570
+ policy: DurableRetryPolicy;
571
+ /** The stored sequence, or null for the compiled defaults. */
572
+ sequence: number | null;
573
+ source: 'stored' | 'compiled_default';
574
+ /** Why the compiled defaults were used, or notices about the stored one. */
575
+ warnings: string[];
576
+ };
577
+
578
+ /**
579
+ * Resolve the policy a run uses. A missing or invalid stored policy falls back
580
+ * to the compiled defaults and says so; the caller must log `warnings`.
581
+ */
582
+ export function resolveDurableRetryPolicy(
583
+ stored: { sequence: number; policyJson: string } | null,
584
+ ): DurableRetryPolicySnapshot {
585
+ if (!stored) {
586
+ return {
587
+ policy: COMPILED_DURABLE_RETRY_POLICY,
588
+ sequence: null,
589
+ source: 'compiled_default',
590
+ warnings: ['No stored Durable retry policy; using compiled defaults.'],
591
+ };
592
+ }
593
+ let parsed: unknown;
594
+ try {
595
+ parsed = JSON.parse(stored.policyJson);
596
+ } catch {
597
+ return {
598
+ policy: COMPILED_DURABLE_RETRY_POLICY,
599
+ sequence: null,
600
+ source: 'compiled_default',
601
+ warnings: [
602
+ `Stored Durable retry policy version ${stored.sequence} is not JSON; using compiled defaults.`,
603
+ ],
604
+ };
605
+ }
606
+ const validation = validateDurableRetryPolicy(parsed);
607
+ if ('errors' in validation) {
608
+ return {
609
+ policy: COMPILED_DURABLE_RETRY_POLICY,
610
+ sequence: null,
611
+ source: 'compiled_default',
612
+ warnings: [
613
+ `Stored Durable retry policy version ${stored.sequence} is invalid; using compiled defaults.`,
614
+ ...validation.errors,
615
+ ],
616
+ };
617
+ }
618
+ return {
619
+ policy: validation.policy,
620
+ sequence: stored.sequence,
621
+ source: 'stored',
622
+ warnings: validation.notices,
623
+ };
624
+ }
@@ -47,17 +47,19 @@ export const DURABLE_RUNS_ROLLOUT = {
47
47
  sharedReadCacheWrites: true,
48
48
  /**
49
49
  * A provider's 5xx is retried inside the attempt with exponential backoff
50
- * and jitter, sending the same provider idempotency key, but only for an
51
- * action that is classified for it (`retry.providerServerErrorReplay` of
52
- * `idempotent_key` or `read_safe`, or `retrySafeTransientHttp`). A write,
53
- * upsert, create or send, a paid call whose 5xx is ambiguous after
54
- * dispatch, and any unclassified action is never resent. Only successes are
55
- * final for the classified actions. The runner decides; the gateway
56
- * previous-outcome check only validates the recorded outcome.
50
+ * and jitter, sending the same provider idempotency key. Owner rule
51
+ * (2026-11-16): every action retries, writes and unclassified actions
52
+ * included, because at-least-once is worth more than a lost write. Not
53
+ * retried: an action that declares `retry.providerServerErrorReplay:
54
+ * 'never'`, a model's own invalid answer (`model_output`), and any timeout
55
+ * (a transport failure or a 504), since a timeout is never retried. Only
56
+ * successes are final. The runner decides; the gateway previous-outcome
57
+ * check only validates the recorded outcome.
57
58
  *
58
- * Known limit: a provider that ignores idempotency keys may still apply a
59
- * classified write twice if its classification is wrong, so a new replaying
60
- * action needs review (`tests/fixtures/provider-server-error-replay.json`).
59
+ * Known limit, accepted by the owner: a provider that ignores idempotency
60
+ * keys may apply a write twice when its 5xx came after it applied the
61
+ * write. There is no exactly-once claim; an action whose duplicate would
62
+ * be unacceptable declares `never`.
61
63
  * Each call is retried at most twice (3 sends), a provider Retry-After wait
62
64
  * is capped at 30 s, and the retries never charge the run-wide retry
63
65
  * budget. Off again stops new retries; a call already retried keeps its