deepline 0.3.532 → 0.3.533

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 (132) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +129 -62
  3. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/engine-suspension.ts +1 -0
  4. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/ports.ts +2 -0
  5. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/postgres-fence-adapter.ts +2 -1
  6. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +1 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +6 -0
  8. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +8 -0
  9. package/dist/cli/{auth-ZB3NN4E7.mjs → auth-2TZNPIJQ.mjs} +5 -5
  10. package/dist/cli/auth-KE6RFHUE.js +43 -0
  11. package/dist/cli/{billing-32EF4HJM.js → billing-HQYTRIV3.js} +79 -79
  12. package/dist/cli/{billing-5GGO7DQS.mjs → billing-LR4WJIHO.mjs} +6 -6
  13. package/dist/cli/{chunk-L5V5SLI7.js → chunk-274Y66HP.js} +2 -2
  14. package/dist/cli/{chunk-THQPLSJD.mjs → chunk-2TMNRF5R.mjs} +1 -1
  15. package/dist/cli/{chunk-S2HHY26V.mjs → chunk-2UYERVXF.mjs} +2 -2
  16. package/dist/cli/{chunk-FU4MMUGM.js → chunk-33SNTG5F.js} +16 -16
  17. package/dist/cli/{chunk-TS6XF2QP.js → chunk-352XVCGE.js} +5 -5
  18. package/dist/cli/{chunk-AOAXIJL2.mjs → chunk-3KQBV2CG.mjs} +3 -3
  19. package/dist/cli/{chunk-VWEDIFHT.mjs → chunk-3O3AL5RI.mjs} +4 -4
  20. package/dist/cli/{chunk-AQHMHYXX.js → chunk-425ERNBL.js} +44 -44
  21. package/dist/cli/{chunk-KQW27FSR.js → chunk-4CYNH47Y.js} +53 -53
  22. package/dist/cli/{chunk-JJSJ47CA.js → chunk-4UADZTU5.js} +22 -22
  23. package/dist/cli/{chunk-HR2RDDAC.js → chunk-4YP2YAIZ.js} +26 -26
  24. package/dist/cli/{chunk-NQDUXVBK.js → chunk-5XTXC45Z.js} +41 -41
  25. package/dist/cli/{chunk-7S3DJFW5.js → chunk-735ZOYQN.js} +11 -11
  26. package/dist/cli/{chunk-SMDX4BM5.js → chunk-A4JP6RPX.js} +2 -2
  27. package/dist/cli/{chunk-MHTKWZM3.js → chunk-B4ZNWXUW.js} +9 -9
  28. package/dist/cli/{chunk-GABQIZJR.mjs → chunk-BSI7UHQZ.mjs} +5 -5
  29. package/dist/cli/{chunk-NBIDYAN6.js → chunk-BWZHMWM5.js} +6 -6
  30. package/dist/cli/{chunk-B77ZRM6M.mjs → chunk-CANHB6DH.mjs} +2 -2
  31. package/dist/cli/{chunk-VZKCZO4J.mjs → chunk-CWIGRIIX.mjs} +3 -3
  32. package/dist/cli/{chunk-WU33X2QL.js → chunk-E4VWBU2E.js} +16 -16
  33. package/dist/cli/{chunk-BQ2KAFVQ.js → chunk-EYWES7F5.js} +3 -3
  34. package/dist/cli/{chunk-C6VCDDDD.mjs → chunk-G3GJ3IGU.mjs} +5 -5
  35. package/dist/cli/{chunk-T2QY36E3.mjs → chunk-G3RVDRYL.mjs} +1 -1
  36. package/dist/cli/{chunk-O7JU5GUR.js → chunk-HOTJSXLY.js} +5 -5
  37. package/dist/cli/{chunk-HREGFD2I.mjs → chunk-HPOVAUQF.mjs} +1 -1
  38. package/dist/cli/{chunk-VN432I4S.mjs → chunk-IETLUG4C.mjs} +1 -1
  39. package/dist/cli/{chunk-TFWREZYG.mjs → chunk-JZ7LJS3P.mjs} +6 -6
  40. package/dist/cli/{chunk-F2YLC4ZG.mjs → chunk-KKUOIVQO.mjs} +1 -1
  41. package/dist/cli/{chunk-2T7YE5UH.js → chunk-LTF2J3JM.js} +2 -2
  42. package/dist/cli/{chunk-VIC2MI4W.mjs → chunk-LZ3PBEQH.mjs} +2 -2
  43. package/dist/cli/{chunk-DSNTHXR7.mjs → chunk-LZMRCUVD.mjs} +2 -2
  44. package/dist/cli/{chunk-47UF3DDN.mjs → chunk-MKUYZ7LR.mjs} +1 -1
  45. package/dist/cli/{chunk-GBVTSWL3.js → chunk-MNAEALPG.js} +98 -98
  46. package/dist/cli/{chunk-W5KSUNTE.mjs → chunk-NFDYVMGC.mjs} +10 -10
  47. package/dist/cli/{chunk-CRWX26LR.mjs → chunk-NKVW552R.mjs} +1 -1
  48. package/dist/cli/{chunk-YM6JAKYP.mjs → chunk-NW736SOD.mjs} +2 -2
  49. package/dist/cli/{chunk-CSMLW5VE.js → chunk-O7RSUW75.js} +4 -4
  50. package/dist/cli/{chunk-6LBD6G6U.mjs → chunk-PIACHLYY.mjs} +2 -2
  51. package/dist/cli/{chunk-KEE57BF2.js → chunk-QZWURUBP.js} +7 -7
  52. package/dist/cli/{chunk-QZINISXP.js → chunk-R7YDZSN7.js} +3 -3
  53. package/dist/cli/{chunk-VHHD5D44.js → chunk-SVVUC3B4.js} +7 -7
  54. package/dist/cli/{chunk-4S3ONSLF.js → chunk-TU56J4OV.js} +13 -13
  55. package/dist/cli/{chunk-VCRCMK7M.mjs → chunk-USAQ42OG.mjs} +5 -5
  56. package/dist/cli/{chunk-EJLCIQA4.mjs → chunk-VKGNQC2S.mjs} +5 -5
  57. package/dist/cli/{chunk-H6OYTU2Y.js → chunk-VPQDKL5O.js} +6 -6
  58. package/dist/cli/{chunk-2ZGZBN6D.js → chunk-WF652G74.js} +14 -14
  59. package/dist/cli/{chunk-O2A4C4WP.mjs → chunk-XUX5KGCQ.mjs} +2 -2
  60. package/dist/cli/{chunk-RRCSFOF3.mjs → chunk-XZN3DBTP.mjs} +1 -1
  61. package/dist/cli/{chunk-3NUYO5QO.mjs → chunk-YZK5RSUL.mjs} +1 -1
  62. package/dist/cli/{chunk-64CEFPF4.js → chunk-ZH5HCAN3.js} +1 -1
  63. package/dist/cli/{csv-LM44ZFL3.mjs → csv-CJKKHGNQ.mjs} +4 -4
  64. package/dist/cli/{csv-4JBCPMEH.js → csv-MBSCHS4H.js} +13 -13
  65. package/dist/cli/{db-UVNXGK6L.js → db-45HNPCY3.js} +27 -27
  66. package/dist/cli/{db-IFJEGJ6M.mjs → db-EAFR6N45.mjs} +6 -6
  67. package/dist/cli/{describe-TWTOPGII.mjs → describe-IXW3LDGC.mjs} +18 -18
  68. package/dist/cli/describe-PYLZAVRI.js +50 -0
  69. package/dist/cli/{executions-3I6RU7AO.js → executions-SZAES2S4.js} +8 -8
  70. package/dist/cli/{executions-NEV2P5MX.mjs → executions-ZATZV7O6.mjs} +6 -6
  71. package/dist/cli/{feedback-NHO56EWZ.js → feedback-KXLF4GR4.js} +14 -14
  72. package/dist/cli/{feedback-IO5ZAWKK.mjs → feedback-NY63KEK2.mjs} +6 -6
  73. package/dist/cli/{git-MQISNZ5F.mjs → git-BSSSTR6N.mjs} +5 -5
  74. package/dist/cli/git-T5JTVBYZ.js +25 -0
  75. package/dist/cli/index.js +141 -141
  76. package/dist/cli/index.mjs +43 -43
  77. package/dist/cli/{legacy-noops-DNRJHNQB.mjs → legacy-noops-CYF6DJBF.mjs} +6 -6
  78. package/dist/cli/{legacy-noops-SLAQE7HN.js → legacy-noops-XQANGML3.js} +9 -9
  79. package/dist/cli/{monitors-NAX7SUAR.mjs → monitors-ABJVLWIP.mjs} +7 -7
  80. package/dist/cli/{monitors-JRNATYS2.js → monitors-F3PTNP45.js} +100 -100
  81. package/dist/cli/{org-34VCNPUD.mjs → org-BHF6Y5R7.mjs} +6 -6
  82. package/dist/cli/{org-BHOREX5D.js → org-WQAPZI5Q.js} +86 -86
  83. package/dist/cli/{pages-GB337AQG.js → pages-U3EJ2NPL.js} +18 -18
  84. package/dist/cli/{pages-ZWVHNJOE.mjs → pages-W4HWVJUG.mjs} +6 -6
  85. package/dist/cli/{play-DAUQ7OAO.js → play-2UHKONON.js} +317 -317
  86. package/dist/cli/{play-GJ7OEYSB.mjs → play-3T4X3ZKH.mjs} +18 -18
  87. package/dist/cli/{providers-KA2RKD6E.mjs → providers-2G2VTNDG.mjs} +6 -6
  88. package/dist/cli/{providers-W7QY5FUK.js → providers-LUK5LIUA.js} +9 -9
  89. package/dist/cli/{quickstart-D4DPUR7R.js → quickstart-76P6PGID.js} +6 -6
  90. package/dist/cli/{quickstart-7KOAL3BD.mjs → quickstart-XP4PJZ7N.mjs} +4 -4
  91. package/dist/cli/{run-AYJSQED7.mjs → run-ACIHA53A.mjs} +23 -23
  92. package/dist/cli/{run-QFVN2WUQ.js → run-S2KHGBCM.js} +41 -41
  93. package/dist/cli/search-5MD65V43.js +33 -0
  94. package/dist/cli/{search-MEE7OV2B.mjs → search-VFIJCUZL.mjs} +8 -8
  95. package/dist/cli/{search-output-G36JH6D6.mjs → search-output-2KFLZS5F.mjs} +4 -4
  96. package/dist/cli/{search-output-OW6UPOI6.js → search-output-GV7NNB4X.js} +6 -6
  97. package/dist/cli/{secrets-CJJQJUJC.js → secrets-KJSFEW2F.js} +15 -15
  98. package/dist/cli/{secrets-OFNYIJT6.mjs → secrets-MAQLBVC4.mjs} +6 -6
  99. package/dist/cli/sessions-FDMO7PAA.js +22 -0
  100. package/dist/cli/{sessions-B6VCVU4Z.mjs → sessions-G5MWNJ75.mjs} +6 -6
  101. package/dist/cli/{settings-PPFLSXDP.mjs → settings-MR6UFOK5.mjs} +13 -13
  102. package/dist/cli/{settings-H4Q524LF.js → settings-VXGRPFXP.js} +86 -86
  103. package/dist/cli/{setup-SJAM7XHR.js → setup-C74BRK7N.js} +50 -50
  104. package/dist/cli/{setup-WI3WDRRE.mjs → setup-ZOBXMONM.mjs} +10 -10
  105. package/dist/cli/{skills-QSRYGMG2.mjs → skills-4CG3MHOY.mjs} +8 -8
  106. package/dist/cli/skills-KRUL7QCT.js +37 -0
  107. package/dist/cli/tools-CGHOSCPS.js +57 -0
  108. package/dist/cli/{tools-RUC4ULAD.mjs → tools-YXCXZ4ZD.mjs} +17 -17
  109. package/dist/cli/update-S2TILEHZ.js +35 -0
  110. package/dist/cli/{update-DPWNL2UB.mjs → update-Z3C5W3I4.mjs} +10 -10
  111. package/dist/cli/{views-JP66QRA3.mjs → views-45B2FZQT.mjs} +6 -6
  112. package/dist/cli/{views-CVDVQALA.js → views-XGP2GZ52.js} +18 -18
  113. package/dist/cli/{workflow-JM6JUI7I.js → workflow-DWO35XHZ.js} +17 -17
  114. package/dist/cli/{workflow-MVTX2PY3.mjs → workflow-KQRWSNBH.mjs} +7 -7
  115. package/dist/index.js +9 -9
  116. package/dist/index.mjs +6 -6
  117. package/dist/install-integrity.json +104 -104
  118. package/dist/release.d.mts +1 -1
  119. package/dist/release.d.ts +1 -1
  120. package/dist/release.js +2 -2
  121. package/dist/release.mjs +1 -1
  122. package/dist/server.js +5 -5
  123. package/dist/server.mjs +3 -3
  124. package/package.json +1 -1
  125. package/dist/cli/auth-7YWTPQSQ.js +0 -43
  126. package/dist/cli/describe-AF73GGH6.js +0 -50
  127. package/dist/cli/git-AOKC6WL3.js +0 -25
  128. package/dist/cli/search-JVCK5AB4.js +0 -33
  129. package/dist/cli/sessions-DXN6BQ7Q.js +0 -22
  130. package/dist/cli/skills-6MNJK2VQ.js +0 -37
  131. package/dist/cli/tools-OT43MSZE.js +0 -57
  132. package/dist/cli/update-PHOSO3TL.js +0 -35
@@ -205,7 +205,7 @@ export const SDK_RELEASE = {
205
205
  // getters keep their established compatibility behavior.
206
206
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
207
207
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
208
- version: '0.3.532',
208
+ version: '0.3.533',
209
209
  updateSummary: {
210
210
  introducedIn: '0.3.90',
211
211
  summary:
@@ -714,6 +714,16 @@ const authoredStepContext = new AsyncLocalStorage<{
714
714
  invocationId?: string;
715
715
  }>();
716
716
  const toolExecutionOverrides = new AsyncLocalStorage<{ force: boolean }>();
717
+ /**
718
+ * `ctx.runSteps` passes each `runIf` leg to `ctx.step` with a receipt gate
719
+ * keyed by the leg's body. Unless the run's checkpoint already holds the
720
+ * step, the gate evaluates the condition inside the step: after its
721
+ * occurrence and boundary are allocated, in its authored scope and work
722
+ * window. False means the step returns its body's value without reading or
723
+ * writing its receipt. Module-private, so `ctx.step` gains no public
724
+ * parameter.
725
+ */
726
+ const runStepsReceiptGates = new WeakMap<object, () => Promise<boolean>>();
717
727
 
718
728
  /**
719
729
  * Diagnostic split of one direct tool call, recorded only in the existing
@@ -13450,45 +13460,63 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
13450
13460
  ),
13451
13461
  });
13452
13462
  }
13453
- const runStep = async () =>
13454
- options?.checkpointSteps
13455
- ? await this.step(
13456
- stepPath.join('.'),
13457
- async () =>
13458
- await this.executeStepProgramStep(
13459
- step,
13460
- currentRow,
13461
- index,
13462
- stepPath,
13463
- undefined,
13464
- stageExecution,
13465
- options,
13466
- ),
13467
- {
13468
- semanticKey: stableDigest(
13469
- stableStringify({
13470
- index,
13471
- input: currentRow,
13472
- stepPath,
13473
- }),
13474
- ),
13475
- ...(step.staleAfterSeconds !== undefined
13476
- ? { staleAfterSeconds: step.staleAfterSeconds }
13477
- : options?.defaultStaleAfterSeconds !== undefined
13478
- ? {
13479
- staleAfterSeconds: options.defaultStaleAfterSeconds,
13480
- }
13481
- : {}),
13482
- },
13483
- )
13484
- : await this.executeStepProgramStep(
13485
- step,
13486
- currentRow,
13463
+ const runStep = async () => {
13464
+ if (!options?.checkpointSteps) {
13465
+ return await this.executeStepProgramStep(
13466
+ step,
13467
+ currentRow,
13468
+ index,
13469
+ stepPath,
13470
+ undefined,
13471
+ stageExecution,
13472
+ );
13473
+ }
13474
+ // Set by the receipt gate below, so the body reuses the decision
13475
+ // instead of evaluating the condition a second time.
13476
+ let decision: { shouldRun: boolean } | undefined;
13477
+ const body = async () =>
13478
+ await this.executeStepProgramStep(
13479
+ step,
13480
+ currentRow,
13481
+ index,
13482
+ stepPath,
13483
+ undefined,
13484
+ stageExecution,
13485
+ decision ? { ...options, decision } : options,
13486
+ );
13487
+ const conditional = step.resolver;
13488
+ if (isRuntimeConditionalStepResolver(conditional)) {
13489
+ // A `runIf` leg the row does not take returns its declared else
13490
+ // value and runs nothing. Its receipt read and write were serial
13491
+ // gateway requests at the end of every waterfall row, so it skips
13492
+ // them. It stays a step: the same occurrence and boundary, the same
13493
+ // events, and its condition evaluated in the step's scope.
13494
+ runStepsReceiptGates.set(body, async () => {
13495
+ // Truthiness, as the body tests it: a condition that returns
13496
+ // nothing skips its leg.
13497
+ decision = {
13498
+ shouldRun: Boolean(await conditional.when(currentRow, index)),
13499
+ };
13500
+ return decision.shouldRun;
13501
+ });
13502
+ }
13503
+ return await this.step(stepPath.join('.'), body, {
13504
+ semanticKey: stableDigest(
13505
+ stableStringify({
13487
13506
  index,
13507
+ input: currentRow,
13488
13508
  stepPath,
13489
- undefined,
13490
- stageExecution,
13491
- );
13509
+ }),
13510
+ ),
13511
+ ...(step.staleAfterSeconds !== undefined
13512
+ ? { staleAfterSeconds: step.staleAfterSeconds }
13513
+ : options?.defaultStaleAfterSeconds !== undefined
13514
+ ? {
13515
+ staleAfterSeconds: options.defaultStaleAfterSeconds,
13516
+ }
13517
+ : {}),
13518
+ });
13519
+ };
13492
13520
  let value: unknown;
13493
13521
  try {
13494
13522
  value = await runStep();
@@ -13620,7 +13648,11 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
13620
13648
  path: string[],
13621
13649
  previousCell?: PreviousCell,
13622
13650
  stageExecution?: { skipped: boolean },
13623
- options?: { defaultStaleAfterSeconds?: number | null },
13651
+ options?: {
13652
+ defaultStaleAfterSeconds?: number | null;
13653
+ /** A `runIf` decision the caller already evaluated for this row. */
13654
+ decision?: { shouldRun: boolean };
13655
+ },
13624
13656
  ): Promise<unknown> {
13625
13657
  const resolver = step.resolver;
13626
13658
  const store = rowContext.getStore();
@@ -13650,7 +13682,9 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
13650
13682
  }
13651
13683
 
13652
13684
  if (isRuntimeConditionalStepResolver(resolver)) {
13653
- const shouldRun = await resolver.when(currentRow, index);
13685
+ const shouldRun = options?.decision
13686
+ ? options.decision.shouldRun
13687
+ : await resolver.when(currentRow, index);
13654
13688
  // ADR 0019: the per-row branch this evaluator selected, written onto the
13655
13689
  // cell the decision governs. `run`/`else` is the runtime's own vocabulary
13656
13690
  // for a `runIf` conditional — the only per-row branch construct the
@@ -17999,6 +18033,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
17999
18033
  run: () => T | Promise<T>,
18000
18034
  options?: RuntimeStepOptions,
18001
18035
  ): Promise<T> {
18036
+ const readsReceipt = runStepsReceiptGates.get(run);
18002
18037
  if (!rowContext.getStore()) this.assertRowAdmissionOpen();
18003
18038
  this.assertNoPendingDurableSuspension();
18004
18039
  validatePlayAuthoringField('ctx.step.id', key);
@@ -18064,6 +18099,37 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
18064
18099
  const boundaryId = this.durableBoundaryId(
18065
18100
  `step-${scope}:${normalizedKey}${explicitStepScope ? `:${explicitStepScope}` : ''}${boundarySuffix}`,
18066
18101
  );
18102
+ // The step's own work: the call positions and sleeps it takes. A `runIf`
18103
+ // gate runs in the same capture before the receipt read, so the
18104
+ // condition's calls and sleeps count as the step's, as they did when the
18105
+ // condition ran at the start of the step's body.
18106
+ const callAdvances = new Map<string, number>();
18107
+ // Sleeps the gate's condition took on this attempt. The step's recorded
18108
+ // count includes them; a receipt recovered after the gate counts them
18109
+ // already, so recovery advances only the rest.
18110
+ let conditionSleeps = 0;
18111
+ const inStepWindow = async <R>(work: () => R | Promise<R>): Promise<R> =>
18112
+ rowStore?.replayCallIndexes
18113
+ ? await rowContext.run(
18114
+ {
18115
+ ...rowStore,
18116
+ replayStepCaptures: [
18117
+ ...(rowStore.replayStepCaptures ?? []),
18118
+ callAdvances,
18119
+ ],
18120
+ },
18121
+ work,
18122
+ )
18123
+ : await work();
18124
+ const checkpointedStep = () => {
18125
+ const existing = assertKnownResolvedBoundary(
18126
+ boundaryId,
18127
+ this.checkpoint.resolvedBoundaries?.[boundaryId],
18128
+ );
18129
+ return existing?.kind === 'step' && 'output' in existing
18130
+ ? existing
18131
+ : null;
18132
+ };
18067
18133
  const advanceRecoveredSleepCursor = async (
18068
18134
  receipt?: RuntimeStepReceipt,
18069
18135
  ) => {
@@ -18078,15 +18144,13 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
18078
18144
  : receipt?.runId === this.currentReceiptOwnerRunId
18079
18145
  ? ((await this.readStepSleepCount(boundaryId)) ?? 0)
18080
18146
  : 0;
18081
- if (Number.isSafeInteger(sleepCount) && sleepCount > 0)
18082
- this.sleepBoundaryIndex += sleepCount;
18147
+ const remaining = sleepCount - Math.min(conditionSleeps, sleepCount);
18148
+ if (Number.isSafeInteger(remaining) && remaining > 0)
18149
+ this.sleepBoundaryIndex += remaining;
18083
18150
  };
18084
18151
  const executeStep = async (): Promise<T> => {
18085
- const existing = assertKnownResolvedBoundary(
18086
- boundaryId,
18087
- this.checkpoint.resolvedBoundaries?.[boundaryId],
18088
- );
18089
- if (existing?.kind === 'step' && 'output' in existing) {
18152
+ const existing = checkpointedStep();
18153
+ if (existing) {
18090
18154
  this.runtimeLog(
18091
18155
  `ctx.step(${normalizedKey}): recovered result from checkpoint`,
18092
18156
  );
@@ -18095,19 +18159,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
18095
18159
  }
18096
18160
 
18097
18161
  const sleepBoundaryIndexBefore = this.sleepBoundaryIndex;
18098
- const callAdvances = new Map<string, number>();
18099
- const output = rowStore?.replayCallIndexes
18100
- ? await rowContext.run(
18101
- {
18102
- ...rowStore,
18103
- replayStepCaptures: [
18104
- ...(rowStore.replayStepCaptures ?? []),
18105
- callAdvances,
18106
- ],
18107
- },
18108
- run,
18109
- )
18110
- : await run();
18162
+ const output = await inStepWindow(run);
18111
18163
  assertJsonSerializableStepOutput(normalizedKey, output);
18112
18164
  // A caught durable suspension is still the invocation's outcome. Never
18113
18165
  // publish an enclosing step fallback that would make a later resume skip
@@ -18115,7 +18167,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
18115
18167
  this.assertNoPendingDurableSuspension();
18116
18168
  const sleepCount = rowStore?.replayCallIndexes
18117
18169
  ? (callAdvances.get('sleep:legacy') ?? 0)
18118
- : this.sleepBoundaryIndex - sleepBoundaryIndexBefore;
18170
+ : this.sleepBoundaryIndex - sleepBoundaryIndexBefore + conditionSleeps;
18119
18171
  if (sleepCount > 0 && this.durableDirectToolResultsBackedByReceipts) {
18120
18172
  await this.persistStepSleepCount(boundaryId, sleepCount);
18121
18173
  }
@@ -18151,6 +18203,18 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
18151
18203
  ...(freshnessPolicy ? { invocationId: boundaryId } : {}),
18152
18204
  },
18153
18205
  async () => {
18206
+ // A step this run's checkpoint already holds is recovered as any
18207
+ // step is, without evaluating its condition again.
18208
+ if (readsReceipt && !checkpointedStep()) {
18209
+ const gateSleepStart = this.sleepBoundaryIndex;
18210
+ const takesReceipt = await inStepWindow(readsReceipt);
18211
+ // A row counts its own sleeps, as `executeStep` does: the shared
18212
+ // cursor also moves for sleeps in concurrent rows.
18213
+ conditionSleeps = rowStore?.replayCallIndexes
18214
+ ? (callAdvances.get('sleep:legacy') ?? 0)
18215
+ : this.sleepBoundaryIndex - gateSleepStart;
18216
+ if (!takesReceipt) return await executeStep();
18217
+ }
18154
18218
  if (freshnessPolicy) {
18155
18219
  const semanticKey = stableStringify({
18156
18220
  operation: 'step',
@@ -18188,7 +18252,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
18188
18252
  return {
18189
18253
  output: value === undefined ? null : value,
18190
18254
  undefinedOutput: value === undefined,
18191
- sleepCount: this.sleepBoundaryIndex - before,
18255
+ sleepCount:
18256
+ this.sleepBoundaryIndex - before + conditionSleeps,
18192
18257
  completedAt:
18193
18258
  (boundary?.kind === 'step'
18194
18259
  ? boundary.completedAt
@@ -18197,7 +18262,9 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
18197
18262
  },
18198
18263
  onOutcome: (value, freshness) => {
18199
18264
  if (freshness.source !== 'executed') {
18200
- this.sleepBoundaryIndex += value.sleepCount;
18265
+ this.sleepBoundaryIndex +=
18266
+ value.sleepCount -
18267
+ Math.min(conditionSleeps, value.sleepCount);
18201
18268
  }
18202
18269
  return value;
18203
18270
  },
@@ -97,6 +97,7 @@ export function createPlayRunAttemptSuspensionJob(ports: {
97
97
  const resumed = await ports.store.resumeAfterPark({
98
98
  claim: input.attempt,
99
99
  suspension: input.suspension,
100
+ checkpoint: engineOutcome.checkpoint,
100
101
  });
101
102
  if (resumed.kind === 'fence_lost') {
102
103
  return { kind: 'fence_lost', stage: 'resume' };
@@ -53,6 +53,8 @@ export type PlayRunAttemptStore = {
53
53
  resumeAfterPark(input: {
54
54
  claim: PlayRunAttemptClaim;
55
55
  suspension: PlayExecutionSuspension;
56
+ /** Omission preserves the stored checkpoint for older callers. */
57
+ checkpoint?: unknown;
56
58
  }): Promise<
57
59
  | { kind: 'resumed'; lifecycle: PlayRunAttemptLifecycle }
58
60
  | { kind: 'fence_lost' }
@@ -169,13 +169,14 @@ export function createPostgresPlayRunAttemptStore(input: {
169
169
  ? { kind: 'parked', lifecycle: parked }
170
170
  : { kind: 'fence_lost' };
171
171
  },
172
- async resumeAfterPark({ claim, suspension }) {
172
+ async resumeAfterPark({ claim, suspension, checkpoint }) {
173
173
  const resumed = await markPostgresSchedulerAttemptRunning(
174
174
  input.client,
175
175
  {
176
176
  runId: claim.runId,
177
177
  attempt: claim.number,
178
178
  leaseToken: claim.fenceId,
179
+ checkpoint,
179
180
  preserveHeartbeatAt: suspension.kind === 'detached_runner',
180
181
  },
181
182
  options,
@@ -4747,6 +4747,7 @@ async function executeAssignedAbsurdAttempt(input: {
4747
4747
  runId,
4748
4748
  attempt: generation,
4749
4749
  leaseToken,
4750
+ checkpoint,
4750
4751
  preserveHeartbeatAt: suspension.kind === 'detached_runner',
4751
4752
  },
4752
4753
  options,
@@ -8469,6 +8469,8 @@ export async function markPostgresSchedulerAttemptRunning(
8469
8469
  leaseToken: string;
8470
8470
  /** Detached runner liveness is renewed only by the sandbox gateway. */
8471
8471
  preserveHeartbeatAt?: boolean;
8472
+ /** Persist the resolved wake before admission can defer this attempt. */
8473
+ checkpoint?: unknown;
8472
8474
  },
8473
8475
  options?: Pick<PostgresSchedulerOptions, 'schema'>,
8474
8476
  ): Promise<PostgresSchedulerLifecycleOutboxEvent | null> {
@@ -8505,6 +8507,7 @@ export async function markPostgresSchedulerAttemptRunning(
8505
8507
  running_run AS (
8506
8508
  UPDATE ${tableName('runs', options)} AS target
8507
8509
  SET status = 'running',
8510
+ checkpoint_json = COALESCE($6::jsonb, target.checkpoint_json),
8508
8511
  suspension_json = CASE
8509
8512
  WHEN $5::boolean AND target.suspension_json ->> 'kind' = 'detached_runner'
8510
8513
  THEN target.suspension_json ELSE NULL END,
@@ -8544,6 +8547,9 @@ export async function markPostgresSchedulerAttemptRunning(
8544
8547
  input.leaseToken,
8545
8548
  outboxEventId,
8546
8549
  input.preserveHeartbeatAt === true,
8550
+ input.checkpoint === undefined
8551
+ ? null
8552
+ : stringifyPostgresJson(input.checkpoint),
8547
8553
  ],
8548
8554
  );
8549
8555
  const row = running.rows[0];
@@ -1475,6 +1475,11 @@ export type RuntimeSandboxCapacityTestEvidence = {
1475
1475
  hasComputeIntent: boolean;
1476
1476
  recordedResources: number;
1477
1477
  firstAcquiredAtMs: number | null;
1478
+ /** Optional for older Preview readers; separates readiness from later work. */
1479
+ lastAcquiredAtMs?: number | null;
1480
+ /** Last durable signal acceptance, not a client-side offer timestamp. */
1481
+ lastSignalAtMs?: number | null;
1482
+ firstDeleteConfirmedAtMs?: number | null;
1478
1483
  lastDeleteConfirmedAtMs: number | null;
1479
1484
  };
1480
1485
  };
@@ -1566,6 +1571,9 @@ export async function readRuntimeSandboxCapacityTestEvidence(
1566
1571
  AND NULLIF(resource->>'sandboxId', '') IS NOT NULL),
1567
1572
  'computeJobStatus', (SELECT status FROM ${schema}."compute_billing_jobs_v2" AS job WHERE job.run_id = owned_run.run_id),
1568
1573
  'firstAcquiredAtMs', (SELECT floor(extract(epoch FROM min(provider_created_at)) * 1000)::bigint FROM owned_operations),
1574
+ 'lastAcquiredAtMs', (SELECT floor(extract(epoch FROM max(provider_created_at)) * 1000)::bigint FROM owned_operations),
1575
+ 'lastSignalAtMs', (SELECT floor(extract(epoch FROM max(signal.created_at)) * 1000)::bigint FROM ${schema}."signals" AS signal WHERE signal.run_id = owned_run.run_id),
1576
+ 'firstDeleteConfirmedAtMs', (SELECT floor(extract(epoch FROM min(delete_confirmed_at)) * 1000)::bigint FROM owned_operations),
1569
1577
  'lastDeleteConfirmedAtMs', (SELECT floor(extract(epoch FROM max(delete_confirmed_at)) * 1000)::bigint FROM owned_operations)
1570
1578
  ) FROM owned_run)
1571
1579
  ) AS evidence`,
@@ -14,14 +14,14 @@ import {
14
14
  reportSetupCompleted,
15
15
  resolvePendingAuthClaimForResume,
16
16
  statusBannerLine
17
- } from "./chunk-AOAXIJL2.mjs";
18
- import "./chunk-S2HHY26V.mjs";
19
- import "./chunk-VN432I4S.mjs";
20
- import "./chunk-47UF3DDN.mjs";
17
+ } from "./chunk-3KQBV2CG.mjs";
18
+ import "./chunk-2UYERVXF.mjs";
19
+ import "./chunk-IETLUG4C.mjs";
20
+ import "./chunk-MKUYZ7LR.mjs";
21
21
  import "./chunk-QNHHZ63P.mjs";
22
22
  import "./chunk-DLIRSHV6.mjs";
23
23
  import "./chunk-ZPGGW27Q.mjs";
24
- import "./chunk-3NUYO5QO.mjs";
24
+ import "./chunk-YZK5RSUL.mjs";
25
25
  import "./chunk-WZYKRD7T.mjs";
26
26
  import "./chunk-KRD6H754.mjs";
27
27
  export {
@@ -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 _chunk4CYNH47Yjs = require('./chunk-4CYNH47Y.js');
18
+ require('./chunk-QZWURUBP.js');
19
+ require('./chunk-EYWES7F5.js');
20
+ require('./chunk-O7RSUW75.js');
21
+ require('./chunk-T2N3B7IQ.js');
22
+ require('./chunk-XNYIZMNQ.js');
23
+ require('./chunk-SQWET4SL.js');
24
+ require('./chunk-ZH5HCAN3.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 = _chunk4CYNH47Yjs.EXIT_WORKSPACE_MISMATCH; exports.authStatusLine = _chunk4CYNH47Yjs.authStatusLine; exports.clearPendingClaim = _chunk4CYNH47Yjs.clearPendingClaim; exports.clearSatisfiedPendingClaim = _chunk4CYNH47Yjs.clearSatisfiedPendingClaim; exports.handleRegister = _chunk4CYNH47Yjs.handleRegister; exports.handleStatus = _chunk4CYNH47Yjs.handleStatus; exports.handleWait = _chunk4CYNH47Yjs.handleWait; exports.httpJson = _chunk4CYNH47Yjs.httpJson; exports.readPendingAuthClaim = _chunk4CYNH47Yjs.readPendingAuthClaim; exports.readStatusBanner = _chunk4CYNH47Yjs.readStatusBanner; exports.registerAuthCommands = _chunk4CYNH47Yjs.registerAuthCommands; exports.reportApprovalLinkShown = _chunk4CYNH47Yjs.reportApprovalLinkShown; exports.reportSetupCompleted = _chunk4CYNH47Yjs.reportSetupCompleted; exports.resolvePendingAuthClaimForResume = _chunk4CYNH47Yjs.resolvePendingAuthClaimForResume; exports.statusBannerLine = _chunk4CYNH47Yjs.statusBannerLine;