deepline 0.3.527 → 0.3.529

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 (147) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +197 -207
  3. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +5 -0
  4. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +66 -1
  5. package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +156 -161
  6. package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +56 -1
  7. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/contracts.ts +11 -1
  8. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +36 -6
  9. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +35 -5
  10. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-start-admission.ts +12 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +1 -0
  12. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +16 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +26 -5
  14. package/dist/bundling-sources/shared_libs/play-runtime/runtime-telemetry.ts +129 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +6 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-claim-loop-timing.ts +145 -0
  17. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +48 -5
  18. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +475 -101
  19. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +13 -5
  20. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +30 -1
  21. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +43 -16
  22. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +105 -13
  23. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/result-receipt-policy.ts +10 -1
  24. package/dist/cli/auth-P7M7SXM5.js +43 -0
  25. package/dist/cli/{auth-LRMMQFJ4.mjs → auth-V7A6TU4G.mjs} +5 -5
  26. package/dist/cli/{billing-WZZDXVRJ.mjs → billing-5VBUYPWW.mjs} +6 -6
  27. package/dist/cli/{billing-M76MMWZB.js → billing-XF6SAA5Y.js} +79 -79
  28. package/dist/cli/{chunk-HB3YUHEL.js → chunk-2GV54JFN.js} +44 -44
  29. package/dist/cli/{chunk-ETXQZGQU.js → chunk-4722FTYU.js} +16 -16
  30. package/dist/cli/{chunk-AXFHQWGA.mjs → chunk-4A4OQMJX.mjs} +1 -1
  31. package/dist/cli/{chunk-66YLAQ2X.js → chunk-4BKE63Q7.js} +26 -26
  32. package/dist/cli/{chunk-UKOG6PCB.mjs → chunk-5NZEA2YV.mjs} +1 -1
  33. package/dist/cli/{chunk-JEIGNX3G.mjs → chunk-6XZIXDLC.mjs} +5 -5
  34. package/dist/cli/{chunk-RGL2YGJZ.js → chunk-7RTDSHMB.js} +2 -2
  35. package/dist/cli/{chunk-2A6IRSE6.js → chunk-7SRZTSHU.js} +5 -5
  36. package/dist/cli/{chunk-7DPWGAOU.js → chunk-7Z3ZXSOX.js} +3 -3
  37. package/dist/cli/{chunk-JSEISVAZ.js → chunk-AP7DNG6D.js} +4 -4
  38. package/dist/cli/{chunk-P5ZU5ZHA.mjs → chunk-BOWZ3OOU.mjs} +1 -1
  39. package/dist/cli/{chunk-YUYDP2EG.js → chunk-BRQDN67G.js} +6 -6
  40. package/dist/cli/{chunk-VV2AFJ3I.mjs → chunk-C2WTS7WY.mjs} +5 -5
  41. package/dist/cli/{chunk-GIRMVMXP.mjs → chunk-DKX5CGTG.mjs} +1 -1
  42. package/dist/cli/{chunk-OXHY3LD3.js → chunk-DPGPXARU.js} +53 -53
  43. package/dist/cli/{chunk-JSVHBJE2.mjs → chunk-E7CN5GEM.mjs} +2 -2
  44. package/dist/cli/{chunk-KDFUQRVU.mjs → chunk-ETCGTKLF.mjs} +1 -1
  45. package/dist/cli/{chunk-UJHS2O5O.mjs → chunk-EW33RCLA.mjs} +3 -3
  46. package/dist/cli/{chunk-OLSATEDQ.js → chunk-FCNSJHED.js} +6 -6
  47. package/dist/cli/{chunk-YKPMIJJ2.mjs → chunk-FWC47SCG.mjs} +2 -2
  48. package/dist/cli/{chunk-VTXBV4AX.mjs → chunk-FXHKNZM2.mjs} +1 -1
  49. package/dist/cli/{chunk-MMM2WMTF.mjs → chunk-G4SYSUDB.mjs} +5 -5
  50. package/dist/cli/{chunk-HA2J2OAS.mjs → chunk-GPU4ULMY.mjs} +10 -10
  51. package/dist/cli/{chunk-3L2DNG5X.js → chunk-H2JAXOPP.js} +11 -11
  52. package/dist/cli/{chunk-QKY3H3HA.mjs → chunk-HV4UKMBB.mjs} +4 -4
  53. package/dist/cli/{chunk-QKKT5G4K.mjs → chunk-K55VBSCA.mjs} +3 -3
  54. package/dist/cli/{chunk-EOL7PXLW.js → chunk-KAI64HV7.js} +7 -7
  55. package/dist/cli/{chunk-YJ4YVFXC.js → chunk-KSUWW26I.js} +13 -13
  56. package/dist/cli/{chunk-XI47UAVU.js → chunk-L3J7IAYE.js} +9 -9
  57. package/dist/cli/{chunk-R6IWWPY7.js → chunk-M47I47FK.js} +14 -14
  58. package/dist/cli/{chunk-E4TEZE62.mjs → chunk-NDVCVFZW.mjs} +2 -2
  59. package/dist/cli/{chunk-UAQ7ZWRP.js → chunk-NVH6ULDP.js} +22 -22
  60. package/dist/cli/{chunk-M45S7JAY.mjs → chunk-NVSMSP2J.mjs} +2 -2
  61. package/dist/cli/{chunk-SRQQAUXN.js → chunk-OA4FI5ZM.js} +2 -2
  62. package/dist/cli/{chunk-NVII3RWQ.mjs → chunk-PAAREIKG.mjs} +2 -2
  63. package/dist/cli/{chunk-5YR6CDJ2.mjs → chunk-PJDYY5JL.mjs} +6 -6
  64. package/dist/cli/{chunk-LHMHUA5D.js → chunk-PNWBODCB.js} +7 -7
  65. package/dist/cli/{chunk-C7A44BZ7.js → chunk-QTQWPSAK.js} +3 -3
  66. package/dist/cli/{chunk-MIL5YDKZ.mjs → chunk-R62Z4INU.mjs} +2 -2
  67. package/dist/cli/{chunk-YSDPYQBH.js → chunk-RWY2QLJ4.js} +41 -41
  68. package/dist/cli/{chunk-XYG4IOJK.js → chunk-TEFO5AS2.js} +98 -98
  69. package/dist/cli/{chunk-ZHY7AY5V.js → chunk-UMCEXTRM.js} +16 -16
  70. package/dist/cli/{chunk-77VNC2KF.mjs → chunk-XE4PQE2O.mjs} +1 -1
  71. package/dist/cli/{chunk-OKRBGXDI.js → chunk-XEZSORKG.js} +5 -5
  72. package/dist/cli/{chunk-3PQDEBO6.js → chunk-XZ6OY3BH.js} +1 -1
  73. package/dist/cli/{chunk-2L3HVEBM.mjs → chunk-Y4P6XJHU.mjs} +1 -1
  74. package/dist/cli/{chunk-RMCKTV4R.mjs → chunk-YVJJEMNQ.mjs} +1 -1
  75. package/dist/cli/{chunk-HQZLTK3P.js → chunk-ZEIN5YJS.js} +2 -2
  76. package/dist/cli/{chunk-RTPLRMEB.mjs → chunk-ZULLXAJJ.mjs} +5 -5
  77. package/dist/cli/{chunk-4YN7DZEA.mjs → chunk-ZYMX7KZE.mjs} +2 -2
  78. package/dist/cli/{csv-FEFNXZF7.mjs → csv-IHLVHG35.mjs} +4 -4
  79. package/dist/cli/{csv-IRP6VT7Q.js → csv-VEKMGGOE.js} +13 -13
  80. package/dist/cli/{db-Y5VNPNRD.js → db-NTFFISQG.js} +27 -27
  81. package/dist/cli/{db-IHECMWZ3.mjs → db-RKLVYARP.mjs} +6 -6
  82. package/dist/cli/{describe-XCVC2WLL.mjs → describe-62ELB5DZ.mjs} +18 -18
  83. package/dist/cli/describe-JXOGKT6C.js +50 -0
  84. package/dist/cli/{executions-3FWZYUJV.mjs → executions-5BMZW4C7.mjs} +6 -6
  85. package/dist/cli/{executions-QH3KJ6MA.js → executions-X7NMKMXW.js} +8 -8
  86. package/dist/cli/{feedback-BGHWMOLH.js → feedback-RDN5O4AT.js} +14 -14
  87. package/dist/cli/{feedback-F3OZXOPM.mjs → feedback-UHHWCIFD.mjs} +6 -6
  88. package/dist/cli/{git-RWPH3D75.mjs → git-3M33GKOW.mjs} +5 -5
  89. package/dist/cli/git-7VZGGIGZ.js +25 -0
  90. package/dist/cli/index.js +141 -141
  91. package/dist/cli/index.mjs +43 -43
  92. package/dist/cli/{legacy-noops-5ADSTBJ5.mjs → legacy-noops-7RVRPF5B.mjs} +6 -6
  93. package/dist/cli/{legacy-noops-G6CYD5LM.js → legacy-noops-ENKN6JU4.js} +9 -9
  94. package/dist/cli/{monitors-AFNAU3A2.mjs → monitors-FJPDMUQ6.mjs} +7 -7
  95. package/dist/cli/{monitors-VZCBZO26.js → monitors-YOWDFGIR.js} +100 -100
  96. package/dist/cli/{org-X4QRYBC4.js → org-4GBLI75H.js} +86 -86
  97. package/dist/cli/{org-JVLYTU24.mjs → org-H24LOZAC.mjs} +6 -6
  98. package/dist/cli/{pages-VELKZKBL.mjs → pages-BKM2D6BV.mjs} +6 -6
  99. package/dist/cli/{pages-YMM4KBW5.js → pages-WWVLYB5K.js} +18 -18
  100. package/dist/cli/{play-MIY6BYRB.mjs → play-M3CSYH3A.mjs} +18 -18
  101. package/dist/cli/{play-J7DEBHI7.js → play-TXHKCG6B.js} +317 -317
  102. package/dist/cli/{providers-2H3W3W7G.mjs → providers-EW5WTMTX.mjs} +6 -6
  103. package/dist/cli/{providers-TOUB7Y2A.js → providers-XL4SNFHU.js} +9 -9
  104. package/dist/cli/{quickstart-LHY2LN3P.js → quickstart-AFQ5MCDL.js} +6 -6
  105. package/dist/cli/{quickstart-GKAS5265.mjs → quickstart-SZSLS553.mjs} +4 -4
  106. package/dist/cli/{run-QCAVDPE5.js → run-MOFHGYSN.js} +41 -41
  107. package/dist/cli/{run-KYGNOWYD.mjs → run-TWXFNH6U.mjs} +23 -23
  108. package/dist/cli/{search-YPGAIFDX.mjs → search-2SW4V4IR.mjs} +8 -8
  109. package/dist/cli/search-V2AGWRLO.js +33 -0
  110. package/dist/cli/{search-output-ASELNQ2U.js → search-output-CJGRPJYD.js} +6 -6
  111. package/dist/cli/{search-output-OOC3VK4T.mjs → search-output-I6DNYXNT.mjs} +4 -4
  112. package/dist/cli/{secrets-VJ4XYSMZ.mjs → secrets-4XXLR6QO.mjs} +6 -6
  113. package/dist/cli/{secrets-KX3TQB4R.js → secrets-SD43HSLX.js} +15 -15
  114. package/dist/cli/{sessions-KUN7H7E5.mjs → sessions-7G32HW5R.mjs} +6 -6
  115. package/dist/cli/sessions-FIRDFPIZ.js +22 -0
  116. package/dist/cli/{settings-JKFYZ2IT.mjs → settings-HSYRY2L5.mjs} +13 -13
  117. package/dist/cli/{settings-5NIF4BU7.js → settings-SYEBDDDJ.js} +86 -86
  118. package/dist/cli/{setup-MYV3IHPS.js → setup-VTWCVCTK.js} +50 -50
  119. package/dist/cli/{setup-5AX3TN6G.mjs → setup-XZVBPKZK.mjs} +10 -10
  120. package/dist/cli/{skills-JLS4CINQ.mjs → skills-OMPEUMRT.mjs} +8 -8
  121. package/dist/cli/skills-RUY7CION.js +37 -0
  122. package/dist/cli/tools-KLIW7G6T.js +57 -0
  123. package/dist/cli/{tools-VBYKD3MJ.mjs → tools-UEDNJI4G.mjs} +17 -17
  124. package/dist/cli/{update-QWAIVJRI.mjs → update-4YVCUSSI.mjs} +10 -10
  125. package/dist/cli/update-FDUZRKKU.js +35 -0
  126. package/dist/cli/{views-TBWGZAVZ.mjs → views-4FP4AJQ2.mjs} +6 -6
  127. package/dist/cli/{views-ZW56JZB5.js → views-ZCCSKWMP.js} +18 -18
  128. package/dist/cli/{workflow-X7UQPJMQ.mjs → workflow-A2D5FALP.mjs} +7 -7
  129. package/dist/cli/{workflow-EKSZST6M.js → workflow-SM4OD4VJ.js} +17 -17
  130. package/dist/index.js +9 -9
  131. package/dist/index.mjs +6 -6
  132. package/dist/install-integrity.json +105 -104
  133. package/dist/release.d.mts +1 -1
  134. package/dist/release.d.ts +1 -1
  135. package/dist/release.js +2 -2
  136. package/dist/release.mjs +1 -1
  137. package/dist/server.js +5 -5
  138. package/dist/server.mjs +3 -3
  139. package/package.json +1 -1
  140. package/dist/cli/auth-C7BBYIQD.js +0 -43
  141. package/dist/cli/describe-MNJVJHRE.js +0 -50
  142. package/dist/cli/git-MDOHEW5J.js +0 -25
  143. package/dist/cli/search-G67CEHR7.js +0 -33
  144. package/dist/cli/sessions-QILPX4XQ.js +0 -22
  145. package/dist/cli/skills-NG32XTZI.js +0 -37
  146. package/dist/cli/tools-OZG3V77R.js +0 -57
  147. package/dist/cli/update-YL5WVSKU.js +0 -35
@@ -29,7 +29,10 @@ import {
29
29
  failPostgresSchedulerScheduledChildWaits,
30
30
  type PostgresSchedulerWorkerOnceResult,
31
31
  } from './postgres';
32
- import { createAbsurdForRuntimeScheduler } from './absurd-pool';
32
+ import {
33
+ createAbsurdForRuntimeScheduler,
34
+ type AbsurdSchedulerQueryObserver,
35
+ } from './absurd-pool';
33
36
  import {
34
37
  withRuntimeSchedulerClient,
35
38
  type RuntimeSchedulerPoolOptions,
@@ -539,11 +542,16 @@ const absurdLog: Log = {
539
542
  export function createAbsurdRuntimeClient(
540
543
  poolOptions: RuntimeSchedulerPoolOptions,
541
544
  queueName: string = ABSURD_RUNS_QUEUE,
545
+ observer?: AbsurdSchedulerQueryObserver,
542
546
  ): Absurd {
543
- return createAbsurdForRuntimeScheduler(poolOptions, {
544
- queueName,
545
- log: absurdLog,
546
- });
547
+ return createAbsurdForRuntimeScheduler(
548
+ poolOptions,
549
+ {
550
+ queueName,
551
+ log: absurdLog,
552
+ },
553
+ observer,
554
+ );
547
555
  }
548
556
 
549
557
  const absurdReadyPromises = new Map<string, Promise<void>>();
@@ -25,7 +25,11 @@ export type PlayRunRecoveryOutcome =
25
25
  reason: string;
26
26
  deferCount: number;
27
27
  deadlineAtMs: number | null;
28
+ /** Whole milliseconds until the retry; `delaySeconds` is the same. */
29
+ delayMs: number;
28
30
  delaySeconds: number;
31
+ /** Compiled start pacing: not counted toward the defer budget. */
32
+ paced?: true;
29
33
  }
30
34
  | {
31
35
  kind: 'exhausted';
@@ -53,6 +57,7 @@ export async function transitionPreCodePlayRunRecovery(input: {
53
57
  return { kind: 'not_recoverable' };
54
58
  }
55
59
  const decision = input.error.decision;
60
+ const pacingDelayMs = input.error.pacingDelayMs;
56
61
  const recovery = await deferPostgresSchedulerAttemptForRecovery(
57
62
  input.client,
58
63
  {
@@ -71,17 +76,41 @@ export async function transitionPreCodePlayRunRecovery(input: {
71
76
  horizonMs: PLAY_RUN_RECOVERY_DEFER_POLICY.horizonMs,
72
77
  deferBaseMs: PLAY_RUN_RECOVERY_DEFER_POLICY.deferBaseSeconds * 1_000,
73
78
  deferMaxMs: PLAY_RUN_RECOVERY_DEFER_POLICY.deferMaxSeconds * 1_000,
79
+ ...(pacingDelayMs !== undefined
80
+ ? {
81
+ pacingDelayMs,
82
+ pacingHorizonMs:
83
+ PLAY_RUN_RECOVERY_DEFER_POLICY.startPacingHorizonMs,
84
+ pacingBackoffDivisor:
85
+ PLAY_RUN_RECOVERY_DEFER_POLICY.startPacingBackoffDivisor,
86
+ pacingBackoffMaxMs:
87
+ PLAY_RUN_RECOVERY_DEFER_POLICY.startPacingBackoffMaxMs,
88
+ }
89
+ : {}),
74
90
  },
75
91
  input.schedulerOptions,
76
92
  );
77
93
  if (recovery.deferred && recovery.deferCount !== null) {
94
+ // Past the pacing horizon the store counted this defer on the outage
95
+ // ladder, so it requeues after the ladder's delay, not the pacing delay.
96
+ // A paced defer uses the store's delay, which may be the backoff floor
97
+ // for how long the run has been paced rather than the requested delay.
98
+ const paced =
99
+ pacingDelayMs !== undefined &&
100
+ recovery.paced === true &&
101
+ recovery.pacingDelayMs !== undefined;
102
+ const delayMs = paced
103
+ ? (recovery.pacingDelayMs as number)
104
+ : recoveryDeferDelaySeconds(recovery.deferCount) * 1_000;
78
105
  return {
79
106
  kind: 'deferred',
80
107
  dependency: decision.dependency,
81
108
  reason: decision.reason,
82
109
  deferCount: recovery.deferCount,
83
110
  deadlineAtMs: recovery.deadlineAtMs,
84
- delaySeconds: recoveryDeferDelaySeconds(recovery.deferCount),
111
+ delayMs,
112
+ delaySeconds: delayMs / 1_000,
113
+ ...(paced ? { paced: true as const } : {}),
85
114
  };
86
115
  }
87
116
  if (recovery.exhausted) {
@@ -37,6 +37,10 @@ import type {
37
37
  import type { PlaySchedulerSubmitInput } from '../scheduler-backend';
38
38
  import type { DocflowObservationRecord } from '../docflow-observation';
39
39
  import { runtimeWorkCountersFromStats } from '../runtime-work-counters';
40
+ import {
41
+ durableReplayRefusalFromRunLogLine,
42
+ emitPlayRunReplayRefusal,
43
+ } from '../runtime-telemetry';
40
44
  import {
41
45
  buildPlayRunLedgerEventsFromStatusPatch,
42
46
  createEmptyPlayRunLedgerSnapshot,
@@ -764,6 +768,22 @@ export function createPostgresSchedulerProgressReporter(input: {
764
768
  void flush({ force }).catch(() => undefined);
765
769
  };
766
770
 
771
+ /** Re-emit runner replay refusals to this process's shipped log stream. */
772
+ const forwardReplayRefusal = (
773
+ line: string,
774
+ attempt: number | null | undefined = producerAttempt,
775
+ ) => {
776
+ const refusal = durableReplayRefusalFromRunLogLine(line);
777
+ if (!refusal) return;
778
+ emitPlayRunReplayRefusal({
779
+ orgId: launch.orgId ?? null,
780
+ runId: launch.runId,
781
+ playName: launch.playName ?? null,
782
+ attempt: attempt ?? null,
783
+ refusal,
784
+ });
785
+ };
786
+
767
787
  const appendLiveLog = (
768
788
  line: string,
769
789
  context?: unknown,
@@ -1469,6 +1489,7 @@ export function createPostgresSchedulerProgressReporter(input: {
1469
1489
  logEvent.entryId,
1470
1490
  logEvent.metadata,
1471
1491
  );
1492
+ forwardReplayRefusal(rawLine);
1472
1493
  }
1473
1494
  markMapStartedFromLog(rawLine);
1474
1495
  markMapStartedFromPerfLog(rawLine);
@@ -1758,6 +1779,27 @@ export function createPostgresSchedulerProgressReporter(input: {
1758
1779
  reconcileTerminalMapProgressFromSheetOutcomes();
1759
1780
  }
1760
1781
  const status = options.status ?? 'running';
1782
+ const terminalReplayAttempt =
1783
+ options.terminalLogProducerAttempt ?? producerAttempt;
1784
+ const terminalLogReplay =
1785
+ options.skipTerminalLogReplay || !Array.isArray(result?.logs)
1786
+ ? null
1787
+ : terminalReplayPayloadForMode({
1788
+ resultLogs: result.logs,
1789
+ resultLogContexts: result.logContexts,
1790
+ resultLogMetadata: result.logMetadata,
1791
+ resultLogIds: result.logIds,
1792
+ durableLogMode,
1793
+ liveLogs,
1794
+ liveLogContexts,
1795
+ liveLogsTotalCount,
1796
+ replayAllTerminalLogs: options.replayAllTerminalLogs === true,
1797
+ producerAttempt: terminalReplayAttempt,
1798
+ });
1799
+ // A detached runner that streamed no events delivers its refusals here.
1800
+ for (const line of terminalLogReplay?.lines ?? []) {
1801
+ forwardReplayRefusal(line, terminalReplayAttempt);
1802
+ }
1761
1803
  await flush({
1762
1804
  force: true,
1763
1805
  status,
@@ -1767,22 +1809,7 @@ export function createPostgresSchedulerProgressReporter(input: {
1767
1809
  options.required === true ||
1768
1810
  status === 'completed' ||
1769
1811
  status === 'failed',
1770
- terminalLogReplay:
1771
- options.skipTerminalLogReplay || !Array.isArray(result?.logs)
1772
- ? null
1773
- : terminalReplayPayloadForMode({
1774
- resultLogs: result.logs,
1775
- resultLogContexts: result.logContexts,
1776
- resultLogMetadata: result.logMetadata,
1777
- resultLogIds: result.logIds,
1778
- durableLogMode,
1779
- liveLogs,
1780
- liveLogContexts,
1781
- liveLogsTotalCount,
1782
- replayAllTerminalLogs: options.replayAllTerminalLogs === true,
1783
- producerAttempt:
1784
- options.terminalLogProducerAttempt ?? producerAttempt,
1785
- }),
1812
+ terminalLogReplay,
1786
1813
  });
1787
1814
  };
1788
1815
 
@@ -9533,6 +9533,13 @@ export type PostgresSchedulerRecoveryDeferral = {
9533
9533
  exhausted: boolean;
9534
9534
  deferCount: number | null;
9535
9535
  deadlineAtMs: number | null;
9536
+ /** The pacing request was honoured: uncounted, after its own delay. */
9537
+ paced?: true;
9538
+ /**
9539
+ * Paced only: the delay the run was requeued with, the requested pacing
9540
+ * delay or the backoff floor for how long the run has been paced, if longer.
9541
+ */
9542
+ pacingDelayMs?: number;
9536
9543
  };
9537
9544
 
9538
9545
  /**
@@ -9959,7 +9966,8 @@ export async function resumePostgresSchedulerRun(
9959
9966
  absurd_task_id = task_spawn.task_id,
9960
9967
  recovery_json = coalesce(runs.recovery_json, '{}'::jsonb) - ARRAY[
9961
9968
  'postCode', 'version', 'kind', 'dependency', 'reason', 'deferCount',
9962
- 'deadlineAtMs', 'nextRetryAtMs', 'updatedAtMs', 'exhaustedAtMs'
9969
+ 'deadlineAtMs', 'nextRetryAtMs', 'updatedAtMs', 'exhaustedAtMs',
9970
+ 'pacedSinceMs'
9963
9971
  ]::text[],
9964
9972
  launch_json = runs.launch_json || jsonb_build_object(
9965
9973
  'resumeEpoch', task_spawn.epoch,
@@ -10367,9 +10375,40 @@ export async function deferPostgresSchedulerAttemptForRecovery(
10367
10375
  /** Must match the scheduler's actual DeferTask policy for observability. */
10368
10376
  deferBaseMs?: number;
10369
10377
  deferMaxMs?: number;
10378
+ /**
10379
+ * Compiled start pacing: requeue after exactly this delay. The defer count
10380
+ * is left as it is and the horizon is not started (an existing deadline is
10381
+ * kept), so contention for a bucket that keeps granting can never exhaust
10382
+ * the outage budget.
10383
+ */
10384
+ pacingDelayMs?: number;
10385
+ /**
10386
+ * Required with pacingDelayMs. The first paced defer records
10387
+ * `pacedSinceMs`; once this long has passed since it, the defer is counted
10388
+ * on the outage ladder instead, so pacing alone cannot hold a run forever.
10389
+ */
10390
+ pacingHorizonMs?: number;
10391
+ /**
10392
+ * Required with pacingDelayMs. A run paced for T since `pacedSinceMs` is
10393
+ * requeued after at least min(T / pacingBackoffDivisor,
10394
+ * pacingBackoffMaxMs), so a run that keeps losing the bucket backs off
10395
+ * instead of retrying every few seconds for the whole horizon.
10396
+ */
10397
+ pacingBackoffDivisor?: number;
10398
+ pacingBackoffMaxMs?: number;
10370
10399
  },
10371
10400
  options?: Pick<PostgresSchedulerOptions, 'schema'>,
10372
10401
  ): Promise<PostgresSchedulerRecoveryDeferral> {
10402
+ if (
10403
+ input.pacingDelayMs !== undefined &&
10404
+ (input.pacingHorizonMs === undefined ||
10405
+ input.pacingBackoffDivisor === undefined ||
10406
+ input.pacingBackoffMaxMs === undefined)
10407
+ ) {
10408
+ throw new Error(
10409
+ `Paced pre-code defer for ${input.runId}/${input.attempt} needs a pacing horizon and backoff.`,
10410
+ );
10411
+ }
10373
10412
  const initialDeadlineAtMs = input.nowMs + input.horizonMs;
10374
10413
  const noCodeWorkCounterDigest = createHash('sha256')
10375
10414
  .update(`${input.runId}\u0000${input.attempt}\u0000pre-code`)
@@ -10401,6 +10440,8 @@ export async function deferPostgresSchedulerAttemptForRecovery(
10401
10440
  work_counters_recorded: boolean;
10402
10441
  defer_count: string | null;
10403
10442
  deadline_at_ms: string | null;
10443
+ paced: boolean | null;
10444
+ paced_delay_ms: string | null;
10404
10445
  }>(
10405
10446
  `
10406
10447
  WITH ${runtimeSandboxCustodyLocksSql('run.run_id = $1', options)}, candidate AS (
@@ -10415,13 +10456,38 @@ export async function deferPostgresSchedulerAttemptForRecovery(
10415
10456
  AND attempts.lease_token = $3
10416
10457
  AND attempts.status IN ('claimed', 'running', 'waiting')
10417
10458
  AND runs.status IN ('queued', 'running', 'waiting')
10459
+ ), pacing AS (
10460
+ -- A pacing request is honoured only within the pacing horizon of the
10461
+ -- run's first paced defer; past it, this defer is counted below.
10462
+ SELECT run_id,
10463
+ recovery_json,
10464
+ CASE WHEN $16::bigint IS NULL
10465
+ THEN (recovery_json ->> 'pacedSinceMs')::bigint
10466
+ ELSE coalesce((recovery_json ->> 'pacedSinceMs')::bigint, $7::bigint)
10467
+ END AS paced_since_ms,
10468
+ $16::bigint IS NOT NULL
10469
+ AND $7::bigint < coalesce(
10470
+ (recovery_json ->> 'pacedSinceMs')::bigint,
10471
+ $7::bigint
10472
+ ) + $17::bigint AS paced
10473
+ FROM candidate
10418
10474
  ), computed AS (
10419
10475
  SELECT run_id,
10420
- coalesce((recovery_json ->> 'deferCount')::integer, 0) + 1
10476
+ paced,
10477
+ paced_since_ms,
10478
+ coalesce((recovery_json ->> 'deferCount')::integer, 0)
10479
+ + CASE WHEN paced THEN 0 ELSE 1 END
10421
10480
  AS defer_count,
10422
- coalesce((recovery_json ->> 'deadlineAtMs')::bigint, $4::bigint)
10423
- AS deadline_at_ms
10424
- FROM candidate
10481
+ coalesce(
10482
+ (recovery_json ->> 'deadlineAtMs')::bigint,
10483
+ CASE WHEN NOT paced THEN $4::bigint END
10484
+ ) AS deadline_at_ms,
10485
+ -- A run paced for T waits at least min(T / divisor, max).
10486
+ CASE WHEN paced THEN greatest(
10487
+ $16::bigint,
10488
+ least($19::bigint, ($7::bigint - paced_since_ms) / $18::bigint)
10489
+ ) END AS paced_delay_ms
10490
+ FROM pacing
10425
10491
  ), open_circuit AS (
10426
10492
  INSERT INTO ${tableName(POSTGRES_SCHEDULER_DEPENDENCY_CIRCUITS_TABLE, options)} AS circuit (
10427
10493
  dependency, state, open_until_ms, probe_until_ms, probe_token, last_reason, updated_at
@@ -10452,7 +10518,7 @@ export async function deferPostgresSchedulerAttemptForRecovery(
10452
10518
  AND attempts.attempt = $2
10453
10519
  AND attempts.lease_token = $3
10454
10520
  AND computed.defer_count <= $6
10455
- AND $7::bigint < computed.deadline_at_ms
10521
+ AND (computed.paced OR $7::bigint < computed.deadline_at_ms)
10456
10522
  RETURNING attempts.run_id
10457
10523
  ), requeued_run AS (
10458
10524
  UPDATE ${tableName('runs', options)} AS runs
@@ -10467,14 +10533,22 @@ export async function deferPostgresSchedulerAttemptForRecovery(
10467
10533
  'dependency', $8::text,
10468
10534
  'reason', $9::text,
10469
10535
  'deferCount', computed.defer_count,
10470
- 'deadlineAtMs', computed.deadline_at_ms,
10471
10536
  'nextRetryAtMs',
10472
- $7::bigint + least(
10473
- $13::numeric,
10474
- $12::numeric * power(2::numeric, computed.defer_count - 1)
10475
- )::bigint,
10537
+ $7::bigint + CASE WHEN computed.paced THEN computed.paced_delay_ms ELSE
10538
+ least(
10539
+ $13::numeric,
10540
+ $12::numeric * power(2::numeric, computed.defer_count - 1)
10541
+ )::bigint
10542
+ END,
10476
10543
  'updatedAtMs', $7::bigint
10477
- ),
10544
+ ) || CASE
10545
+ -- A paced first defer has no horizon to record.
10546
+ WHEN computed.deadline_at_ms IS NULL THEN '{}'::jsonb
10547
+ ELSE jsonb_build_object('deadlineAtMs', computed.deadline_at_ms)
10548
+ END || CASE
10549
+ WHEN computed.paced_since_ms IS NULL THEN '{}'::jsonb
10550
+ ELSE jsonb_build_object('pacedSinceMs', computed.paced_since_ms)
10551
+ END,
10478
10552
  updated_at = now()
10479
10553
  FROM computed
10480
10554
  JOIN deferred_attempt ON deferred_attempt.run_id = computed.run_id
@@ -10530,7 +10604,9 @@ export async function deferPostgresSchedulerAttemptForRecovery(
10530
10604
  ) AS work_counters_recorded,
10531
10605
  EXISTS (SELECT 1 FROM open_circuit) AS circuit_opened,
10532
10606
  (SELECT defer_count::text FROM computed LIMIT 1) AS defer_count,
10533
- (SELECT deadline_at_ms::text FROM computed LIMIT 1) AS deadline_at_ms
10607
+ (SELECT deadline_at_ms::text FROM computed LIMIT 1) AS deadline_at_ms,
10608
+ (SELECT paced FROM computed LIMIT 1) AS paced,
10609
+ (SELECT paced_delay_ms::text FROM computed LIMIT 1) AS paced_delay_ms
10534
10610
  `,
10535
10611
  [
10536
10612
  input.runId,
@@ -10552,6 +10628,10 @@ export async function deferPostgresSchedulerAttemptForRecovery(
10552
10628
  input.deferMaxMs ?? 300_000,
10553
10629
  noCodeWorkCounterEventId,
10554
10630
  stableStringify({ events: [noCodeWorkCounterEvent] }),
10631
+ input.pacingDelayMs ?? null,
10632
+ input.pacingHorizonMs ?? null,
10633
+ input.pacingBackoffDivisor ?? null,
10634
+ input.pacingBackoffMaxMs ?? null,
10555
10635
  ],
10556
10636
  );
10557
10637
  const row = result.rows[0];
@@ -10570,11 +10650,23 @@ export async function deferPostgresSchedulerAttemptForRecovery(
10570
10650
  }
10571
10651
  const deferCount = row.defer_count ? Number(row.defer_count) : null;
10572
10652
  const deadlineAtMs = row.deadline_at_ms ? Number(row.deadline_at_ms) : null;
10653
+ const pacingDelayMs =
10654
+ row.paced === true && row.paced_delay_ms !== null
10655
+ ? Number(row.paced_delay_ms)
10656
+ : null;
10657
+ if (row.paced === true && !Number.isSafeInteger(pacingDelayMs)) {
10658
+ throw new Error(
10659
+ `Paced pre-code defer for ${input.runId}/${input.attempt} returned no requeue delay.`,
10660
+ );
10661
+ }
10573
10662
  return {
10574
10663
  deferred: row.deferred,
10575
10664
  exhausted: !row.deferred,
10576
10665
  deferCount: Number.isSafeInteger(deferCount) ? deferCount : null,
10577
10666
  deadlineAtMs: Number.isSafeInteger(deadlineAtMs) ? deadlineAtMs : null,
10667
+ ...(row.paced === true
10668
+ ? { paced: true as const, pacingDelayMs: pacingDelayMs as number }
10669
+ : {}),
10578
10670
  };
10579
10671
  }
10580
10672
 
@@ -19,6 +19,13 @@ export function resolveToolCallResultReceiptPolicy(input: {
19
19
  force: boolean;
20
20
  /** Historical local contexts may have no durable result store. */
21
21
  canStoreResult?: boolean;
22
+ /**
23
+ * The logical call's occurrence index was reserved with its operation slot
24
+ * (#10027), so the forced result receipt is keyed in its own namespace.
25
+ * A receipt in the older namespace was numbered in tool-layer entry order,
26
+ * proves no occurrence, and is never reused for such a call.
27
+ */
28
+ occurrenceBound?: boolean;
22
29
  }): { resultReceiptKey: string; force: boolean } {
23
30
  if (!input.resultReceiptKey.trim()) {
24
31
  throw new Error('Tool Call result policy requires a result receipt key.');
@@ -39,7 +46,9 @@ export function resolveToolCallResultReceiptPolicy(input: {
39
46
  orgId: input.orgId,
40
47
  toolId: input.toolId,
41
48
  receiptKey: input.resultReceiptKey,
42
- invocationIdentity: `forced-result:${input.runId}:${input.logicalCallId}`,
49
+ invocationIdentity: input.occurrenceBound
50
+ ? `forced-result:reserved-v1:${input.runId}:${input.logicalCallId}`
51
+ : `forced-result:${input.runId}:${input.logicalCallId}`,
43
52
  }),
44
53
  force: false,
45
54
  };
@@ -0,0 +1,43 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+ var _chunkDPGPXARUjs = require('./chunk-DPGPXARU.js');
18
+ require('./chunk-KAI64HV7.js');
19
+ require('./chunk-7Z3ZXSOX.js');
20
+ require('./chunk-AP7DNG6D.js');
21
+ require('./chunk-T2N3B7IQ.js');
22
+ require('./chunk-XNYIZMNQ.js');
23
+ require('./chunk-SQWET4SL.js');
24
+ require('./chunk-XZ6OY3BH.js');
25
+ require('./chunk-OG64RBAC.js');
26
+ require('./chunk-COGTRVWW.js');
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ exports.EXIT_WORKSPACE_MISMATCH = _chunkDPGPXARUjs.EXIT_WORKSPACE_MISMATCH; exports.authStatusLine = _chunkDPGPXARUjs.authStatusLine; exports.clearPendingClaim = _chunkDPGPXARUjs.clearPendingClaim; exports.clearSatisfiedPendingClaim = _chunkDPGPXARUjs.clearSatisfiedPendingClaim; exports.handleRegister = _chunkDPGPXARUjs.handleRegister; exports.handleStatus = _chunkDPGPXARUjs.handleStatus; exports.handleWait = _chunkDPGPXARUjs.handleWait; exports.httpJson = _chunkDPGPXARUjs.httpJson; exports.readPendingAuthClaim = _chunkDPGPXARUjs.readPendingAuthClaim; exports.readStatusBanner = _chunkDPGPXARUjs.readStatusBanner; exports.registerAuthCommands = _chunkDPGPXARUjs.registerAuthCommands; exports.reportApprovalLinkShown = _chunkDPGPXARUjs.reportApprovalLinkShown; exports.reportSetupCompleted = _chunkDPGPXARUjs.reportSetupCompleted; exports.resolvePendingAuthClaimForResume = _chunkDPGPXARUjs.resolvePendingAuthClaimForResume; exports.statusBannerLine = _chunkDPGPXARUjs.statusBannerLine;
@@ -14,14 +14,14 @@ import {
14
14
  reportSetupCompleted,
15
15
  resolvePendingAuthClaimForResume,
16
16
  statusBannerLine
17
- } from "./chunk-QKKT5G4K.mjs";
18
- import "./chunk-JSVHBJE2.mjs";
19
- import "./chunk-77VNC2KF.mjs";
20
- import "./chunk-P5ZU5ZHA.mjs";
17
+ } from "./chunk-K55VBSCA.mjs";
18
+ import "./chunk-E7CN5GEM.mjs";
19
+ import "./chunk-XE4PQE2O.mjs";
20
+ import "./chunk-BOWZ3OOU.mjs";
21
21
  import "./chunk-QNHHZ63P.mjs";
22
22
  import "./chunk-DLIRSHV6.mjs";
23
23
  import "./chunk-ZPGGW27Q.mjs";
24
- import "./chunk-RMCKTV4R.mjs";
24
+ import "./chunk-YVJJEMNQ.mjs";
25
25
  import "./chunk-WZYKRD7T.mjs";
26
26
  import "./chunk-KRD6H754.mjs";
27
27
  export {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  DeeplineClient
3
- } from "./chunk-4YN7DZEA.mjs";
3
+ } from "./chunk-ZYMX7KZE.mjs";
4
4
  import {
5
5
  iterateCursorPages,
6
6
  requireBillingIdempotencyKey
7
- } from "./chunk-2L3HVEBM.mjs";
7
+ } from "./chunk-Y4P6XJHU.mjs";
8
8
  import "./chunk-L2VKAASU.mjs";
9
9
  import "./chunk-FKD3KL5Q.mjs";
10
10
  import "./chunk-PSX3WHIH.mjs";
@@ -22,9 +22,9 @@ import {
22
22
  openInBrowser,
23
23
  printCommandEnvelope,
24
24
  shouldEmitJson
25
- } from "./chunk-JSVHBJE2.mjs";
26
- import "./chunk-77VNC2KF.mjs";
27
- import "./chunk-P5ZU5ZHA.mjs";
25
+ } from "./chunk-E7CN5GEM.mjs";
26
+ import "./chunk-XE4PQE2O.mjs";
27
+ import "./chunk-BOWZ3OOU.mjs";
28
28
  import {
29
29
  AuthError,
30
30
  ConfigError
@@ -33,7 +33,7 @@ import "./chunk-DLIRSHV6.mjs";
33
33
  import {
34
34
  DeeplineError
35
35
  } from "./chunk-ZPGGW27Q.mjs";
36
- import "./chunk-RMCKTV4R.mjs";
36
+ import "./chunk-YVJJEMNQ.mjs";
37
37
  import "./chunk-WZYKRD7T.mjs";
38
38
  import "./chunk-KRD6H754.mjs";
39
39