deepline 0.3.484 → 0.3.485

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 (209) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +91 -30
  2. package/dist/bundling-sources/sdk/src/compat.ts +13 -0
  3. package/dist/bundling-sources/sdk/src/plays/client-core.ts +4 -1
  4. package/dist/bundling-sources/sdk/src/plays/run-request.ts +143 -9
  5. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  6. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +31 -4
  7. package/dist/bundling-sources/sdk/src/tool-calls.ts +1 -1
  8. package/dist/bundling-sources/sdk/src/types.ts +7 -1
  9. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-column-storage.ts +32 -3
  10. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +126 -41
  11. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +231 -25
  12. package/dist/bundling-sources/shared_libs/play-runtime/daytona-runtime-config.ts +9 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +130 -19
  14. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-registry.ts +105 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/execute-server-timing.ts +4 -2
  16. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +194 -56
  17. package/dist/bundling-sources/shared_libs/play-runtime/log-provenance.ts +11 -6
  18. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +3 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/ports.ts +2 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/postgres-adapter.ts +2 -1
  21. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +30 -0
  22. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +195 -2
  23. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +20 -1
  24. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-contract.ts +15 -0
  25. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +2 -2
  26. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +102 -23
  27. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/progress-sidecar.ts +9 -1
  28. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-control-transport.ts +25 -5
  29. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +133 -82
  30. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +58 -16
  31. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-sandbox-absence.ts +171 -0
  32. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-session-execution.ts +69 -0
  33. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +100 -40
  34. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +8 -0
  35. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +67 -9
  36. package/dist/bundling-sources/shared_libs/play-runtime/runtime-incident-drills.ts +5 -5
  37. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +6 -3
  38. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-errors.ts +14 -0
  39. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-writer.ts +87 -31
  40. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +18 -0
  41. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/index.ts +19 -0
  42. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +14 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +204 -6
  44. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +39 -0
  45. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +12 -1
  46. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +26 -0
  47. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-scope.ts +44 -15
  48. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +60 -11
  49. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +649 -38
  50. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +6 -1
  51. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +17 -0
  52. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +25 -33
  53. package/dist/bundling-sources/shared_libs/play-runtime/suspension.ts +12 -0
  54. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +21 -0
  55. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +1 -1
  56. package/dist/bundling-sources/shared_libs/plays/source-authoring-edition.ts +1 -1
  57. package/dist/cli/auth-ABZBH55L.js +43 -0
  58. package/dist/cli/{auth-EBFOTF7X.mjs → auth-OWMUENCU.mjs} +5 -5
  59. package/dist/cli/{billing-G2G3EF3I.js → billing-2FMNQGOX.js} +80 -80
  60. package/dist/cli/{billing-2ZOIMW5V.mjs → billing-JX4H3VFF.mjs} +7 -7
  61. package/dist/cli/{chunk-M4PG7FGC.js → chunk-2ILND7XX.js} +2 -2
  62. package/dist/cli/{chunk-WXRM3UC6.mjs → chunk-2ZEQ43B7.mjs} +3 -3
  63. package/dist/cli/{chunk-PU52JXKA.mjs → chunk-3DBW6C7M.mjs} +13 -4
  64. package/dist/cli/{chunk-4OVHIWE7.mjs → chunk-3DYU3JQN.mjs} +2 -2
  65. package/dist/cli/{chunk-QIDDTIVZ.js → chunk-3OF7NSGR.js} +322 -294
  66. package/dist/cli/{chunk-YWC5AN26.mjs → chunk-3Z24NKW7.mjs} +62 -34
  67. package/dist/cli/{chunk-RLLEH2SP.js → chunk-5DCQWQCP.js} +26 -26
  68. package/dist/cli/{chunk-DEXSQGXB.mjs → chunk-62PJ6PK7.mjs} +5 -5
  69. package/dist/cli/{chunk-6NPWXE32.mjs → chunk-676NZ7K4.mjs} +1 -1
  70. package/dist/cli/{chunk-FRD5WFT4.js → chunk-775AZTO7.js} +323 -247
  71. package/dist/cli/{chunk-4OEOM6GP.mjs → chunk-ACTUAZYP.mjs} +5 -5
  72. package/dist/cli/{chunk-ZOKM7DVA.js → chunk-AFADYKFE.js} +8 -8
  73. package/dist/cli/{chunk-GVAENVIG.js → chunk-AUQQVDAB.js} +110 -21
  74. package/dist/cli/{chunk-U7IJAGWB.js → chunk-BSKPQB2P.js} +7 -7
  75. package/dist/cli/chunk-C6QWRSMQ.js +42 -0
  76. package/dist/cli/{chunk-AK7UKQ5R.js → chunk-CSBMKHTV.js} +5 -5
  77. package/dist/cli/{chunk-YHA3EV3I.mjs → chunk-CW6TAQBF.mjs} +15 -4
  78. package/dist/cli/{chunk-UT4YMA2N.js → chunk-DMNVM34J.js} +5 -4
  79. package/dist/cli/{chunk-XZXIWPT3.mjs → chunk-E73JXJA3.mjs} +1 -1
  80. package/dist/cli/{chunk-5KNRQWHE.js → chunk-EC2CVPN5.js} +3 -3
  81. package/dist/cli/{chunk-IXWQOVNW.js → chunk-ECIXZNSW.js} +87 -76
  82. package/dist/cli/{chunk-LTZXLYKE.mjs → chunk-FJY6K3BG.mjs} +93 -17
  83. package/dist/cli/{chunk-TRLDJNVE.mjs → chunk-G5PI3RNT.mjs} +1 -1
  84. package/dist/cli/{chunk-WYUCDLVR.mjs → chunk-GHHJWCMD.mjs} +2 -1
  85. package/dist/cli/{chunk-FQK7BULS.js → chunk-HKGXGGIV.js} +1 -1
  86. package/dist/cli/{chunk-2AWYJXBX.js → chunk-IHMYIHF4.js} +5 -5
  87. package/dist/cli/{chunk-SD7QWZTV.mjs → chunk-INW22YP7.mjs} +1 -1
  88. package/dist/cli/{chunk-OWUZKXE7.mjs → chunk-J7EENGKJ.mjs} +1 -1
  89. package/dist/cli/{chunk-TIRSKEZH.mjs → chunk-JD6HKNKD.mjs} +1 -1
  90. package/dist/cli/{chunk-OHKKDPA5.js → chunk-JQXUWYWX.js} +13 -13
  91. package/dist/cli/{chunk-EACX7QXO.mjs → chunk-KZTNNLIL.mjs} +2 -2
  92. package/dist/cli/{chunk-7K5CWKKZ.mjs → chunk-L352NOE3.mjs} +2 -2
  93. package/dist/cli/{chunk-KGOC6HGI.js → chunk-L7IQ3DFH.js} +53 -53
  94. package/dist/cli/{chunk-4IOY2SCQ.js → chunk-LOX3BISD.js} +4 -4
  95. package/dist/cli/{chunk-6GRZEYSG.js → chunk-NKPTM7SK.js} +7 -7
  96. package/dist/cli/{chunk-VEVGM6B5.js → chunk-NLRTFJGH.js} +14 -14
  97. package/dist/cli/{chunk-UKM74PAA.js → chunk-NRNWPWBW.js} +37 -37
  98. package/dist/cli/{chunk-HNRELVCS.mjs → chunk-ONONSV2Q.mjs} +96 -7
  99. package/dist/cli/{chunk-CYWBAV5H.js → chunk-OW4OTEFF.js} +16 -16
  100. package/dist/cli/{chunk-5K5CAND4.mjs → chunk-RZE5I2XJ.mjs} +4 -4
  101. package/dist/cli/{chunk-3XQIVEAT.js → chunk-S3WQJ5VG.js} +3 -3
  102. package/dist/cli/{chunk-4SFC2XUF.mjs → chunk-SR6S4EYG.mjs} +5 -5
  103. package/dist/cli/{chunk-UWOY74RU.js → chunk-T4G2T5DS.js} +21 -21
  104. package/dist/cli/{chunk-TN2GW57M.mjs → chunk-TMCC7ORQ.mjs} +1 -1
  105. package/dist/cli/{chunk-HEI3BWIV.mjs → chunk-TSCUWWTM.mjs} +1 -1
  106. package/dist/cli/{chunk-DBJ62RAO.js → chunk-TVW6USSG.js} +3 -3
  107. package/dist/cli/{chunk-NW4QJE54.js → chunk-U6WEGDD3.js} +2 -2
  108. package/dist/cli/{chunk-V7JCMBLU.mjs → chunk-UPHXGZCE.mjs} +4 -4
  109. package/dist/cli/{chunk-C62NI2X6.js → chunk-UQ3LQ6IF.js} +5 -5
  110. package/dist/cli/{chunk-5GOG5ZGC.mjs → chunk-VZYTLWOM.mjs} +2 -2
  111. package/dist/cli/{chunk-AF7MOUZP.mjs → chunk-W33OL4F2.mjs} +2 -2
  112. package/dist/cli/{chunk-ZM2YPJQJ.js → chunk-XK5DMLZE.js} +5 -1
  113. package/dist/cli/{chunk-LJ5747UC.mjs → chunk-XRDXNAAY.mjs} +5 -1
  114. package/dist/cli/{chunk-YGN77QA5.mjs → chunk-YDA3PMKK.mjs} +3 -3
  115. package/dist/cli/{csv-S3CHUKI6.js → csv-HFEQPGNY.js} +13 -13
  116. package/dist/cli/{csv-NLWVWD3H.mjs → csv-OHF3Y5KB.mjs} +4 -4
  117. package/dist/cli/{db-OGRPAEEM.mjs → db-M456OUXD.mjs} +7 -7
  118. package/dist/cli/{db-WBSKMMOH.js → db-VLQKCYQS.js} +28 -28
  119. package/dist/cli/describe-CP35DZ5Z.js +49 -0
  120. package/dist/cli/{describe-FAD3Z7LN.mjs → describe-M6VXFYVL.mjs} +21 -21
  121. package/dist/cli/describe-core.d.mts +3 -3
  122. package/dist/cli/describe-core.d.ts +3 -3
  123. package/dist/cli/describe-core.js +4 -4
  124. package/dist/cli/describe-core.mjs +3 -3
  125. package/dist/cli/{executions-LYCL344R.mjs → executions-4FGRBPJF.mjs} +7 -7
  126. package/dist/cli/{executions-SOAZHCY4.js → executions-GKINJZI6.js} +9 -9
  127. package/dist/cli/{feedback-AVF6V7SV.mjs → feedback-D2WMGK3V.mjs} +4 -4
  128. package/dist/cli/{feedback-OROUPUNJ.js → feedback-ZH5K7WV7.js} +8 -8
  129. package/dist/cli/git-IDALMZDN.js +25 -0
  130. package/dist/cli/{git-J5N5M57H.mjs → git-OCIJ5ME4.mjs} +5 -5
  131. package/dist/cli/index.js +142 -139
  132. package/dist/cli/index.mjs +45 -42
  133. package/dist/cli/{legacy-noops-QAQMZMEG.js → legacy-noops-QNIVP7LO.js} +8 -8
  134. package/dist/cli/{legacy-noops-ENRRM7BL.mjs → legacy-noops-V6Q2X34P.mjs} +5 -5
  135. package/dist/cli/{monitors-CKQ65WRL.mjs → monitors-2USHTG5G.mjs} +8 -8
  136. package/dist/cli/{monitors-SFMQ5LFR.js → monitors-5DNK7W2K.js} +92 -92
  137. package/dist/cli/{org-3UNTDLT2.js → org-RPGM5AN4.js} +73 -73
  138. package/dist/cli/{org-K4UIEU5P.mjs → org-TL2YPYSE.mjs} +7 -7
  139. package/dist/cli/{pages-NKZTGB4C.js → pages-PNUKPFWV.js} +18 -18
  140. package/dist/cli/{pages-6GPGBIAH.mjs → pages-XDEW6EE3.mjs} +7 -7
  141. package/dist/cli/{play-BDEADESI.js → play-F5LHRKV5.js} +858 -632
  142. package/dist/cli/{play-62BEE7IX.mjs → play-WINNQ4HZ.mjs} +372 -146
  143. package/dist/cli/{providers-SXGP44GH.js → providers-BD4IS5U5.js} +10 -10
  144. package/dist/cli/{providers-X3CUWMFP.mjs → providers-PXGL3FRE.mjs} +7 -7
  145. package/dist/cli/{quickstart-XQ4426M4.js → quickstart-7LVF6HZF.js} +6 -6
  146. package/dist/cli/{quickstart-7LN22BKX.mjs → quickstart-XTH3UQWZ.mjs} +4 -4
  147. package/dist/cli/{run-XXSN3B5A.mjs → run-MBMUENR7.mjs} +26 -26
  148. package/dist/cli/{run-PBJ4ZJ4W.js → run-NH2BAWPA.js} +41 -41
  149. package/dist/cli/{search-M75VMADD.mjs → search-BMRWBV66.mjs} +8 -8
  150. package/dist/cli/search-R3MQJQMT.js +32 -0
  151. package/dist/cli/{search-output-F6HCFYEI.js → search-output-5NNT337U.js} +22 -16
  152. package/dist/cli/{search-output-NUQAKWDM.mjs → search-output-QKKRD4MF.mjs} +14 -8
  153. package/dist/cli/{secrets-J2H6V33R.mjs → secrets-AWEXBTJV.mjs} +7 -7
  154. package/dist/cli/{secrets-LRYY4QPE.js → secrets-KQSTOREN.js} +16 -16
  155. package/dist/cli/{sessions-YPF62CZE.js → sessions-DSPLZYCJ.js} +6 -6
  156. package/dist/cli/{sessions-IMT336UV.mjs → sessions-RO25Q67X.mjs} +5 -5
  157. package/dist/cli/{settings-35YYC5WA.js → settings-7JXIKNKI.js} +79 -79
  158. package/dist/cli/{settings-PDWVQIGH.mjs → settings-JMGXGK4Z.mjs} +12 -12
  159. package/dist/cli/{setup-UR7GOR7H.js → setup-5QFAQQRW.js} +47 -47
  160. package/dist/cli/{setup-DG5DISSE.mjs → setup-ZQZ47FHB.mjs} +9 -9
  161. package/dist/cli/skills-EDZXY7DV.js +33 -0
  162. package/dist/cli/{skills-U6NJD5J7.mjs → skills-W3H2DL56.mjs} +7 -7
  163. package/dist/cli/{tools-2HGEOELR.mjs → tools-2BZCVNBS.mjs} +19 -19
  164. package/dist/cli/tools-2EY2ETCZ.js +56 -0
  165. package/dist/cli/{update-FRAYBAHK.mjs → update-GAWYMGAW.mjs} +9 -9
  166. package/dist/cli/update-UKDQKNBY.js +33 -0
  167. package/dist/cli/{workflow-DDKVTF36.mjs → workflow-M6LLHQ2I.mjs} +8 -8
  168. package/dist/cli/{workflow-JKKLOMBX.js → workflow-ZPTDFPKW.js} +18 -18
  169. package/dist/{client-DJ3r8VQJ.d.mts → client-BkbDHRIg.d.mts} +1 -1
  170. package/dist/{client-JPSNljtj.d.ts → client-D3hVHXjK.d.ts} +1 -1
  171. package/dist/{client-core-3SJlNsKU.d.mts → client-core-BZoSMKcY.d.mts} +30 -15
  172. package/dist/{client-core-rCoQ5Xz3.d.ts → client-core-DUdVqO_m.d.ts} +30 -15
  173. package/dist/{compiler-manifest-gkO9ZkVg.d.mts → compiler-manifest-BFTwq1HI.d.mts} +1 -1
  174. package/dist/{compiler-manifest-gkO9ZkVg.d.ts → compiler-manifest-BFTwq1HI.d.ts} +1 -1
  175. package/dist/{errors-Cc92LKH-.d.ts → errors-c3pMsylw.d.ts} +1 -1
  176. package/dist/{errors-CeCCOKSA.d.mts → errors-w31ybrQM.d.mts} +1 -1
  177. package/dist/{index-DJQKdV76.d.ts → index-CQ-15-QL.d.ts} +1 -1
  178. package/dist/{index-DsqWJL3Q.d.mts → index-DvNtxucX.d.mts} +1 -1
  179. package/dist/index.d.mts +7 -7
  180. package/dist/index.d.ts +7 -7
  181. package/dist/index.js +10 -10
  182. package/dist/index.mjs +7 -7
  183. package/dist/install-integrity.json +117 -116
  184. package/dist/plays/bundle-play-file.d.mts +3 -3
  185. package/dist/plays/bundle-play-file.d.ts +3 -3
  186. package/dist/plays/bundle-play-file.mjs +2 -2
  187. package/dist/plays/play-description.d.mts +2 -2
  188. package/dist/plays/play-description.d.ts +2 -2
  189. package/dist/plays/run-request.d.mts +2 -2
  190. package/dist/plays/run-request.d.ts +2 -2
  191. package/dist/plays/run-request.js +12 -2
  192. package/dist/plays/run-request.mjs +11 -1
  193. package/dist/release.d.mts +1 -1
  194. package/dist/release.d.ts +1 -1
  195. package/dist/release.js +2 -2
  196. package/dist/release.mjs +1 -1
  197. package/dist/server.d.mts +4 -4
  198. package/dist/server.d.ts +4 -4
  199. package/dist/server.js +6 -6
  200. package/dist/server.mjs +4 -4
  201. package/package.json +1 -1
  202. package/dist/cli/auth-L5CSV3UO.js +0 -43
  203. package/dist/cli/chunk-KA2LNIUP.js +0 -33
  204. package/dist/cli/describe-UIAYCHWW.js +0 -49
  205. package/dist/cli/git-ATMWC27D.js +0 -25
  206. package/dist/cli/search-IGHLRLBD.js +0 -32
  207. package/dist/cli/skills-4U5WC4MJ.js +0 -33
  208. package/dist/cli/tools-PYJTQVVS.js +0 -56
  209. package/dist/cli/update-344OTRFM.js +0 -33
@@ -1,3 +1,4 @@
1
+ import { randomUUID } from 'node:crypto';
1
2
  import {
2
3
  isPlayRunRecoveryError,
3
4
  PLAY_RUN_RECOVERY_DEFER_POLICY,
@@ -87,7 +88,17 @@ export async function transitionPreCodePlayRunRecovery(input: {
87
88
  'remained unavailable before customer execution began through the bounded recovery horizon. ' +
88
89
  'No customer code was started; inspect and redrive this run after the dependency is healthy.',
89
90
  logs: [],
90
- stats: {},
91
+ stats: {
92
+ runtimeWorkCounters: {
93
+ logicalCalls: 0,
94
+ providerRequests: 0,
95
+ provider429s: 0,
96
+ },
97
+ runtimeWorkCounterSegment: {
98
+ invocationSeq: 1,
99
+ segmentId: randomUUID(),
100
+ },
101
+ },
91
102
  steps: [],
92
103
  checkpoint: input.checkpoint,
93
104
  tableNamespace: null,
@@ -17,6 +17,7 @@ import { normalizeTableNamespace } from '../../plays/row-identity';
17
17
  import { PlayStepLifecycleTracker } from '../step-lifecycle-tracker';
18
18
  import { isDurableDirectRunnerLog } from '../log-provenance';
19
19
  import {
20
+ isRunnerProgressAttemptSupersededResponse,
20
21
  updateRunStatusViaAppRuntime,
21
22
  type RuntimeStatusUpdate,
22
23
  } from '../app-runtime-api';
@@ -508,6 +509,12 @@ export function createPostgresSchedulerProgressReporter(input: {
508
509
  status: 'running' | 'completed' | 'failed';
509
510
  force: boolean;
510
511
  required: boolean;
512
+ /**
513
+ * Live progress asks Run Ledger intake to fence on this attempt. Any
514
+ * finalize of a runner result is not live: it is designed to land after
515
+ * the terminal, so a merged upload that includes one is not live either.
516
+ */
517
+ liveProgress: boolean;
511
518
  terminalLogReplay: TerminalLogReplayPayload | null;
512
519
  waiters: Array<{
513
520
  resolve: () => void;
@@ -532,6 +539,7 @@ export function createPostgresSchedulerProgressReporter(input: {
532
539
  : (current?.status ?? next.status),
533
540
  force: next.force || current?.force === true,
534
541
  required: next.required || current?.required === true,
542
+ liveProgress: next.liveProgress && current?.liveProgress !== false,
535
543
  terminalLogReplay:
536
544
  next.terminalLogReplay ?? current?.terminalLogReplay ?? null,
537
545
  waiters: [...(current?.waiters ?? []), waiter],
@@ -648,6 +656,7 @@ export function createPostgresSchedulerProgressReporter(input: {
648
656
  ? { liveLogBatchOffset: nextLogTotalCount - nextLogs.length }
649
657
  : {}),
650
658
  liveLogProducerAttempt: producerAttempt,
659
+ ...(request.liveProgress ? { liveProgress: true } : {}),
651
660
  datasetLifecycleEvents: nextDatasetLifecycleEvents,
652
661
  activityObservations: nextActivityObservations,
653
662
  workCounters: nextWorkCounters,
@@ -657,11 +666,24 @@ export function createPostgresSchedulerProgressReporter(input: {
657
666
  }
658
667
  request.waiters.forEach(({ resolve }) => resolve());
659
668
  } catch (error) {
669
+ // Keep observations for a later unfenced finalize either way.
660
670
  requeueProgressEvents({
661
671
  datasetLifecycleEvents: nextDatasetLifecycleEvents,
662
672
  activityObservations: nextActivityObservations,
663
673
  });
664
674
  workCountersDirty = true;
675
+ if (isRunnerProgressAttemptSupersededResponse(error)) {
676
+ // Intake's commit-time fence found this attempt no longer
677
+ // current, as the read above would have a moment later. Settle
678
+ // the live upload like that branch does instead of failing a
679
+ // required flush: the terminal tail carries any in-flight lines.
680
+ console.info('[postgres-scheduler.progress_attempt_superseded]', {
681
+ runId: launch.runId,
682
+ attempt: producerAttempt ?? null,
683
+ });
684
+ request.waiters.forEach(({ resolve }) => resolve());
685
+ continue;
686
+ }
665
687
  console.warn('[postgres-scheduler.progress_flush_failed]', {
666
688
  runId: launch.runId,
667
689
  error: error instanceof Error ? error.message : String(error),
@@ -685,6 +707,7 @@ export function createPostgresSchedulerProgressReporter(input: {
685
707
  status?: 'running' | 'completed' | 'failed';
686
708
  required?: boolean;
687
709
  terminalLogReplay?: TerminalLogReplayPayload | null;
710
+ liveProgress?: boolean;
688
711
  }): Promise<void> => {
689
712
  const force = input?.force === true;
690
713
  const status = input?.status ?? 'running';
@@ -732,6 +755,7 @@ export function createPostgresSchedulerProgressReporter(input: {
732
755
  force,
733
756
  required,
734
757
  terminalLogReplay: input?.terminalLogReplay ?? null,
758
+ liveProgress: input?.liveProgress !== false,
735
759
  },
736
760
  { resolve, reject },
737
761
  );
@@ -1744,6 +1768,8 @@ export function createPostgresSchedulerProgressReporter(input: {
1744
1768
  await flush({
1745
1769
  force: true,
1746
1770
  status,
1771
+ // Only the gateway's per-request ingest finalizes without a result.
1772
+ liveProgress: result == null,
1747
1773
  required:
1748
1774
  options.required === true ||
1749
1775
  status === 'completed' ||
@@ -32,9 +32,18 @@ export function acquireRateScopeSql(
32
32
  const refillRate = `CASE WHEN ${minimumRateSql} IS NULL
33
33
  THEN h.refill_per_sec
34
34
  ELSE GREATEST(h.refill_per_sec, ${minimumRateSql}) END`;
35
+ // A supported throttle ceiling is learned capacity, not a cold discovery
36
+ // seed. Recover quickly up to it, then test higher capacity with fresh,
37
+ // bounded gentle probes rather than repeating the cold doubling cycle.
38
+ const fastRecovery = unknownProvider
39
+ ? `(${refillRate} < ${DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS}
40
+ AND (h.rate_throttle_ceiling_rps IS NULL
41
+ OR ${refillRate} < h.rate_throttle_ceiling_rps))`
42
+ : 'FALSE';
35
43
  const recoveryRate = unknownProvider
36
- ? `CASE WHEN ${refillRate} < ${DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS}
37
- THEN LEAST(${DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS}, ${refillRate} * 2)
44
+ ? `CASE WHEN ${fastRecovery}
45
+ THEN LEAST(${DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS}, ${refillRate} * 2,
46
+ COALESCE(h.rate_throttle_ceiling_rps, ${DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS}))
38
47
  ELSE ((${refillRate})::numeric + ${UNKNOWN_PROVIDER_PROBE_STEP_RPS})::float8 END`
39
48
  : `${refillRate} * (1 + ${AIMD_ADDITIVE_STEP_FRACTION})`;
40
49
  // Success counts are already applied once by the feedback writer. Measure
@@ -68,10 +77,10 @@ export function acquireRateScopeSql(
68
77
  // interval at 4/8 RPS waits through additional clean sends unnecessarily.
69
78
  // Above that seed, preserve the slower productive/sparse observation window.
70
79
  const backpressuredRecoveryInterval = unknownProvider
71
- ? `CASE WHEN ${refillRate} >= ${DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS}
72
- THEN CASE WHEN ${productiveRecovery} THEN ${AIMD_RECOVERY_STEP_MS}
73
- ELSE ${sparseRecoveryInterval} END
74
- ELSE LEAST(${floorRecoveryInterval}, CEIL(1000.0 / ${refillRate})) END`
80
+ ? `CASE WHEN ${fastRecovery}
81
+ THEN LEAST(${floorRecoveryInterval}, CEIL(1000.0 / ${refillRate}))
82
+ ELSE CASE WHEN ${productiveRecovery} THEN ${AIMD_RECOVERY_STEP_MS}
83
+ ELSE ${sparseRecoveryInterval} END END`
75
84
  : `${AIMD_RECOVERY_STEP_MS}`;
76
85
  // A local no-progress pause remains active after the provider's shorter
77
86
  // Retry-After. Only time beyond every outstanding dispatch/hold is idle.
@@ -85,7 +94,7 @@ export function acquireRateScopeSql(
85
94
  const recoverySuccess = probeBaselineSupported
86
95
  ? `(${successesParameter}::int > 0 OR (
87
96
  h.seen_backpressure
88
- AND (${!unknownProvider} OR ${refillRate} < ${DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS})
97
+ AND (${!unknownProvider} OR ${fastRecovery})
89
98
  AND h.rate_probe_started_at_ms >= h.last_ramp_at_ms
90
99
  AND h.rate_probe_started_at_ms >= h.rate_observation_started_at_ms
91
100
  AND h.rate_successes > h.rate_probe_successes_at_ramp
@@ -116,7 +125,7 @@ export function acquireRateScopeSql(
116
125
  return `provider_hold_rows AS (
117
126
  SELECT * FROM ${table} WHERE bucket_id = $1 FOR UPDATE
118
127
  ), provider_hold AS (
119
- SELECT h.*,
128
+ SELECT h.*, ${fastRecovery} AS fast_recovery,
120
129
  ${postHoldProbeDue} AS post_hold_probe_due,
121
130
  ${pendingRecoveryWaitMs} AS pending_recovery_wait_ms,
122
131
  GREATEST(CASE WHEN ${postHoldProbeDue} THEN 1.0 ELSE 0.0 END, LEAST(
@@ -149,23 +158,23 @@ export function updateRateScopeSql(
149
158
  table: string,
150
159
  unknownProvider = false,
151
160
  probeBaselineSupported = true,
161
+ includeGovernorSnapshot = false,
152
162
  ): string {
153
163
  // Keep the throttle epoch's productive evidence while measuring each upward
154
164
  // probe from a new counter baseline. Losing the earlier useful work would
155
165
  // turn an exploratory rejection into a zero-progress failure.
156
166
  const recoveredObservation = `${unknownProvider} AND ph.seen_backpressure
157
- AND ph.refill_per_sec < ${DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS}
167
+ AND ph.fast_recovery
158
168
  AND ph.next_refill_per_sec >= ${DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS}`;
159
169
  const probedObservation = `${unknownProvider} AND ph.seen_backpressure
160
- AND ph.refill_per_sec >= ${DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS}
170
+ AND NOT ph.fast_recovery
161
171
  AND ph.next_refill_per_sec > ph.refill_per_sec`;
162
172
  const floorRampedObservation = `${unknownProvider} AND ph.seen_backpressure
163
- AND ph.refill_per_sec < ${DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS}
173
+ AND ph.fast_recovery
164
174
  AND ph.next_refill_per_sec > ph.refill_per_sec`;
165
175
  const knownRampedObservation = `${!unknownProvider} AND ph.seen_backpressure
166
176
  AND ph.next_refill_per_sec > ph.refill_per_sec`;
167
- const idleFloorObservation = `${unknownProvider} AND ph.observation_was_idle
168
- AND ph.refill_per_sec < ${DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS}`;
177
+ const idleFloorObservation = `ph.observation_was_idle AND ph.fast_recovery`;
169
178
  const rebaseProbe =
170
179
  'ph.rate_probe_started_at_ms < ph.last_ramp_at_ms OR ph.rate_probe_started_at_ms < COALESCE(ph.rate_observation_started_at_ms, 0) OR ph.rate_probe_successes_at_ramp > ph.rate_successes';
171
180
  return `updated_scope AS (
@@ -219,7 +228,13 @@ export function updateRateScopeSql(
219
228
  ELSE ph.rate_recovery_interval_ms END,
220
229
  rate_throttle_ceiling_rps = CASE
221
230
  WHEN (SELECT granted FROM grant_calc) > 0
222
- AND ph.rate_observation_started_at_ms IS NULL THEN NULL
231
+ AND ph.rate_observation_started_at_ms IS NULL
232
+ -- Compare successful work with its measured epoch, not the raw count
233
+ -- or Retry-After. Sparse/failed discovery still takes the cold path.
234
+ AND NOT (${unknownProvider} AND ph.rate_throttle_ceiling_rps IS NOT NULL
235
+ AND ph.rate_successes * 1000.0
236
+ / GREATEST(${AIMD_RECOVERY_STEP_MS}, ph.rate_recovery_interval_ms)
237
+ >= ph.rate_throttle_ceiling_rps) THEN NULL
223
238
  ELSE ph.rate_throttle_ceiling_rps END,
224
239
  next_dispatch_at_ms = CASE WHEN (SELECT granted FROM grant_calc) > 0 THEN
225
240
  (SELECT first_at_ms FROM schedule_calc)
@@ -229,6 +244,20 @@ export function updateRateScopeSql(
229
244
  FROM provider_hold ph CROSS JOIN now_value nv
230
245
  WHERE h.bucket_id = $1
231
246
  RETURNING h.bucket_id, h.rate_observation_started_at_ms, h.rate_successes,
232
- h.rate_recovery_interval_ms, h.seen_backpressure
247
+ h.rate_recovery_interval_ms, h.seen_backpressure${
248
+ includeGovernorSnapshot
249
+ ? `,
250
+ ph.refill_per_sec AS previous_refill_per_sec,
251
+ ph.rate_successes AS previous_rate_successes,
252
+ ph.rate_observation_started_at_ms AS previous_observation_started_at_ms,
253
+ ph.rate_recovery_interval_ms AS previous_recovery_interval_ms,
254
+ ph.rate_throttle_ceiling_rps AS previous_throttle_ceiling_rps,
255
+ ph.fast_recovery, ph.tokens_after_refill,
256
+ h.refill_per_sec, h.tokens, h.rate_throttle_ceiling_rps,
257
+ ${probeBaselineSupported ? 'h.rate_probe_started_at_ms, h.rate_probe_successes_at_ramp' : 'NULL::bigint AS rate_probe_started_at_ms, NULL::bigint AS rate_probe_successes_at_ramp'},
258
+ h.last_ramp_at_ms, h.refilled_at_ms, h.next_dispatch_at_ms,
259
+ h.retry_at_ms, h.cool_until_ms`
260
+ : ''
261
+ }
233
262
  )`;
234
263
  }
@@ -1,6 +1,7 @@
1
1
  import type {
2
2
  PlayRunnerRateStateAcquireInput,
3
3
  PlayRunnerRateStateAcquireResult,
4
+ PlayRunnerRateStateGovernorSnapshot,
4
5
  PlayRunnerRateStateConcurrencyGrant,
5
6
  PlayRunnerRateStatePenalizeInput,
6
7
  PlayRunnerRateStateReleaseInput,
@@ -10,7 +11,6 @@ import type {
10
11
  import {
11
12
  DEFAULT_ADVISORY_PROVIDER_MAX_RPS,
12
13
  DEFAULT_UNKNOWN_PROVIDER_COLD_START_RPS,
13
- DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS,
14
14
  DEFAULT_UNKNOWN_PROVIDER_MIN_RPS,
15
15
  PROVIDER_AIMD_COOLDOWN_CAP_MS,
16
16
  type PacingRule,
@@ -1019,6 +1019,8 @@ function acquireResultOf(
1019
1019
  }
1020
1020
 
1021
1021
  type RateStateAcquireInput = PlayRunnerRateStateAcquireInput & {
1022
+ /** Server-selected telemetry only; never accepted from an untrusted body. */
1023
+ includeGovernorSnapshot?: boolean;
1022
1024
  nowMs?: number;
1023
1025
  /**
1024
1026
  * Server-resolved identity of the run asking (see
@@ -1029,6 +1031,41 @@ type RateStateAcquireInput = PlayRunnerRateStateAcquireInput & {
1029
1031
  requesterId?: string | null;
1030
1032
  };
1031
1033
 
1034
+ /** Selected diagnostic only: no additional read or state mutation. */
1035
+ function governorSnapshotSelectSql(
1036
+ input: RateStateAcquireInput,
1037
+ concurrency: boolean,
1038
+ ): string {
1039
+ if (!input.includeGovernorSnapshot) return '';
1040
+ return `,
1041
+ (SELECT jsonb_build_object(
1042
+ 'previousRefillPerSecond', previous_refill_per_sec,
1043
+ 'previousRateSuccesses', previous_rate_successes,
1044
+ 'previousObservationStartedAtMs', previous_observation_started_at_ms,
1045
+ 'previousRecoveryIntervalMs', previous_recovery_interval_ms,
1046
+ 'previousThrottleCeilingRps', previous_throttle_ceiling_rps,
1047
+ 'fastRecovery', fast_recovery,
1048
+ 'tokensAfterRefill', tokens_after_refill,
1049
+ 'refillPerSecond', refill_per_sec,
1050
+ 'tokens', tokens,
1051
+ 'rateSuccesses', rate_successes,
1052
+ 'observationStartedAtMs', rate_observation_started_at_ms,
1053
+ 'recoveryIntervalMs', rate_recovery_interval_ms,
1054
+ 'throttleCeilingRps', rate_throttle_ceiling_rps,
1055
+ 'probeStartedAtMs', rate_probe_started_at_ms,
1056
+ 'probeSuccessesAtRamp', rate_probe_successes_at_ramp,
1057
+ 'lastRampAtMs', last_ramp_at_ms,
1058
+ 'refilledAtMs', refilled_at_ms,
1059
+ 'nextDispatchAtMs', next_dispatch_at_ms,
1060
+ 'retryAtMs', retry_at_ms,
1061
+ 'coolUntilMs', cool_until_ms,
1062
+ 'seenBackpressure', seen_backpressure,
1063
+ 'activeConcurrency', ${concurrency ? '(SELECT active_count FROM concurrency_context)' : 'NULL::int'},
1064
+ 'freeConcurrency', ${concurrency ? '(SELECT free FROM free_slots)' : 'NULL::int'},
1065
+ 'concurrencyLimit', ${concurrency ? '(SELECT MIN(max_concurrency) FROM limits)' : 'NULL::int'}
1066
+ ) FROM updated_scope) AS governor_snapshot`;
1067
+ }
1068
+
1032
1069
  /**
1033
1070
  * Fair-share identity for a rate-state acquire. A provider bucket can be shared
1034
1071
  * by many runs (and, for a fleet-managed credential, many organizations), so
@@ -1406,6 +1443,7 @@ async function acquirePureRate(
1406
1443
  scheduled_at_ms: Array<string | number> | null;
1407
1444
  reservation_ids: string[] | null;
1408
1445
  effective_rps: string | number;
1446
+ governor_snapshot?: PlayRunnerRateStateGovernorSnapshot | null;
1409
1447
  }>(
1410
1448
  client,
1411
1449
  (probeBaselineSupported) => `
@@ -1595,7 +1633,7 @@ async function acquirePureRate(
1595
1633
  GREATEST(1, FLOOR(MIN(next_refill_per_sec) / 100.0))::bigint AS burst_size
1596
1634
  FROM refreshed
1597
1635
  ),
1598
- ${updateRateScopeSql(scopeHoldTableName(input), unknownProvider, probeBaselineSupported)},
1636
+ ${updateRateScopeSql(scopeHoldTableName(input), unknownProvider, probeBaselineSupported, input.includeGovernorSnapshot === true)},
1599
1637
  updated AS (
1600
1638
  UPDATE ${bucketTableName(input)} b
1601
1639
  SET
@@ -1692,7 +1730,7 @@ async function acquirePureRate(
1692
1730
  WHERE bucket_id = $1 AND rule_id = ANY($2::text[])),
1693
1731
  (SELECT retry_at_ms FROM provider_hold)
1694
1732
  ) AS claimed_retry_at_ms,
1695
- (SELECT COALESCE(MIN(new_refill_per_sec), 0) FROM updated) AS effective_rps,
1733
+ (SELECT COALESCE(MIN(new_refill_per_sec), 0) FROM updated) AS effective_rps${governorSnapshotSelectSql(input, false)},
1696
1734
  CASE
1697
1735
  WHEN (SELECT granted FROM grant_calc) > 0 THEN ARRAY(
1698
1736
  SELECT
@@ -1813,6 +1851,9 @@ async function acquirePureRate(
1813
1851
  reservationIds: granted > 0 ? reservationIds : [],
1814
1852
  scheduledAtMs,
1815
1853
  effectiveRequestsPerSecond,
1854
+ ...(input.includeGovernorSnapshot && row.governor_snapshot
1855
+ ? { governorSnapshot: row.governor_snapshot }
1856
+ : {}),
1816
1857
  coolUntilMs,
1817
1858
  claimedRetryAtMs,
1818
1859
  };
@@ -1989,6 +2030,7 @@ async function grantWithConcurrency(
1989
2030
  concurrency_grants: unknown[] | null;
1990
2031
  scheduled_at_ms: Array<string | number> | null;
1991
2032
  effective_rps: string | number;
2033
+ governor_snapshot?: PlayRunnerRateStateGovernorSnapshot | null;
1992
2034
  }>(
1993
2035
  `
1994
2036
  WITH now_value AS (
@@ -2248,7 +2290,7 @@ async function grantWithConcurrency(
2248
2290
  GREATEST(1, FLOOR(MIN(next_refill_per_sec) / 100.0))::bigint AS burst_size
2249
2291
  FROM refreshed
2250
2292
  ),
2251
- ${updateRateScopeSql(scopeHoldTableName(input), unknownProvider, probeBaselineSupported)},
2293
+ ${updateRateScopeSql(scopeHoldTableName(input), unknownProvider, probeBaselineSupported, input.includeGovernorSnapshot === true)},
2252
2294
  updated AS (
2253
2295
  UPDATE ${bucketTableName(input)} b
2254
2296
  SET
@@ -2371,7 +2413,7 @@ async function grantWithConcurrency(
2371
2413
  WHERE bucket_id = $1 AND rule_id = ANY($2::text[])),
2372
2414
  (SELECT retry_at_ms FROM provider_hold)
2373
2415
  ) AS claimed_retry_at_ms,
2374
- (SELECT COALESCE(MIN(new_refill_per_sec), 0) FROM updated) AS effective_rps,
2416
+ (SELECT COALESCE(MIN(new_refill_per_sec), 0) FROM updated) AS effective_rps${governorSnapshotSelectSql(input, true)},
2375
2417
  CASE
2376
2418
  WHEN (SELECT granted FROM grant_calc) > 0 THEN ARRAY(
2377
2419
  SELECT
@@ -2539,6 +2581,9 @@ async function grantWithConcurrency(
2539
2581
  reservationIds: granted > 0 ? leaseIds : [],
2540
2582
  scheduledAtMs,
2541
2583
  effectiveRequestsPerSecond,
2584
+ ...(input.includeGovernorSnapshot && row.governor_snapshot
2585
+ ? { governorSnapshot: row.governor_snapshot }
2586
+ : {}),
2542
2587
  coolUntilMs,
2543
2588
  claimedRetryAtMs,
2544
2589
  };
@@ -2628,10 +2673,10 @@ export async function validatePostgresRateStatePermit(
2628
2673
  }
2629
2674
 
2630
2675
  /**
2631
- * Space unknown-provider sends after app preparation, where network/charge
2632
- * delays can collapse previously spaced permits. The existing scope remains
2633
- * the only learner; this internal rule row stores only the physical cadence.
2634
- * Legacy/uninitialized and declared scopes retain hold-only validation.
2676
+ * Space unknown-provider and backpressured declared-provider sends after app
2677
+ * preparation, where network/charge delays can collapse spaced permits. The
2678
+ * existing scope remains the only learner; this internal rule row stores only
2679
+ * the physical cadence. Uninitialized and pristine declared scopes stay hold-only.
2635
2680
  */
2636
2681
  export async function claimPostgresProviderDispatch(
2637
2682
  client: PostgresSchedulerQueryClient,
@@ -2662,7 +2707,10 @@ export async function claimPostgresProviderDispatch(
2662
2707
  SELECT h.retry_at_ms, h.cool_until_ms, h.seen_backpressure,
2663
2708
  CASE WHEN EXISTS (
2664
2709
  SELECT 1 FROM ${bucketTableName(input)} b
2665
- WHERE b.bucket_id = h.bucket_id AND b.rule_id = 'default:provider-scope'
2710
+ WHERE b.bucket_id = h.bucket_id AND (
2711
+ b.rule_id = 'default:provider-scope'
2712
+ OR (h.seen_backpressure AND b.rule_id <> '${PHYSICAL_DISPATCH_RULE_ID}')
2713
+ )
2666
2714
  ) THEN h.refill_per_sec ELSE NULL END AS physical_rps
2667
2715
  FROM ${scopeHoldTableName(input)} h WHERE h.bucket_id = $1
2668
2716
  FOR SHARE OF h
@@ -3615,13 +3663,14 @@ async function penalizeRateStateStatements(
3615
3663
  SELECT h.*,
3616
3664
  COALESCE(h.refill_per_sec, 1) AS refill_before,
3617
3665
  -- A productive unknown-provider probe establishes useful capacity.
3666
+ -- Successful work proves useful capacity even below the discovery seed.
3618
3667
  -- Preserve 90% of its target instead of discarding half after each
3619
3668
  -- exploratory overshoot. Failed or sparse probes keep the stronger
3620
3669
  -- decrease and no-progress policy. Prefer the attempt's active rules.
3621
3670
  -- Early app feedback carries no rules: only an exclusively unknown
3622
3671
  -- durable seed can select this policy, not an obsolete default row
3623
3672
  -- beside declared operation rows.
3624
- h.unknown_provider AND h.refill_per_sec >= ${DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS}
3673
+ h.unknown_provider
3625
3674
  AND h.rate_successes >= ${DEFAULT_UNKNOWN_PROVIDER_COLD_START_RPS}
3626
3675
  AS productive_unknown_probe,
3627
3676
  GREATEST(h.retry_at_ms, COALESCE($5::bigint, nv.now_ms + $2::bigint)) AS deadline,