deepline 0.3.583 → 0.4.0

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 (194) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +79 -36
  2. package/dist/bundling-sources/sdk/src/index.ts +2 -0
  3. package/dist/bundling-sources/sdk/src/release.ts +7 -3
  4. package/dist/bundling-sources/sdk/src/types.ts +37 -0
  5. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +22 -3
  6. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +94 -5
  7. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +66 -12
  8. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +10 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +6 -1
  10. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-tuple-recovery.ts +9 -3
  11. package/dist/bundling-sources/shared_libs/play-runtime/docflow-node-io.ts +86 -20
  12. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +17 -6
  13. package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +22 -6
  14. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +54 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/postgres-adapter.ts +2 -1
  16. package/dist/bundling-sources/shared_libs/play-runtime/row-failure-summary.ts +1 -0
  17. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +4 -1
  18. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +12 -3
  19. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +197 -19
  20. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-writer.ts +25 -1
  21. package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +5 -0
  22. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +73 -3
  23. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-wake-policy.ts +419 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +20 -6
  25. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +24 -0
  26. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-scope.ts +1 -1
  27. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +36 -19
  28. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +380 -51
  29. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +21 -10
  30. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +32 -0
  31. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +6 -0
  32. package/dist/bundling-sources/shared_libs/plays/deploy/api-client.ts +3 -1
  33. package/dist/bundling-sources/shared_libs/plays/deploy/run-deployment.ts +34 -4
  34. package/dist/bundling-sources/shared_libs/plays/docflow-recording-lint.ts +512 -0
  35. package/dist/bundling-sources/shared_libs/plays/docflow-requirement.ts +346 -0
  36. package/dist/bundling-sources/shared_libs/plays/docflow-rule-codes.ts +38 -0
  37. package/dist/bundling-sources/shared_libs/plays/docflow-unreached-reason.ts +42 -2
  38. package/dist/bundling-sources/shared_libs/plays/docflow.ts +223 -32
  39. package/dist/bundling-sources/shared_libs/plays/play-check-compact.ts +14 -1
  40. package/dist/bundling-sources/shared_libs/plays/run-result.ts +35 -0
  41. package/dist/cli/{agents-G344SPW2.mjs → agents-AHXB7N7Y.mjs} +4 -4
  42. package/dist/cli/{agents-ZPDXVPEE.js → agents-KBZ7OUZS.js} +33 -33
  43. package/dist/cli/{auth-V66RP2A6.mjs → auth-3CACO52T.mjs} +5 -5
  44. package/dist/cli/auth-UOHCO5K6.js +44 -0
  45. package/dist/cli/{billing-ROYUQF67.js → billing-5KXPGKMO.js} +105 -105
  46. package/dist/cli/{billing-BTMGZJCR.mjs → billing-TSTK63NB.mjs} +9 -9
  47. package/dist/cli/{chunk-ROWROMXD.mjs → chunk-2GWKBQJZ.mjs} +1 -1
  48. package/dist/cli/{chunk-VXEZKZU4.mjs → chunk-3DJMPID5.mjs} +11 -11
  49. package/dist/cli/{chunk-VH45GV3T.js → chunk-3ET6NRXP.js} +7 -3
  50. package/dist/cli/{chunk-43MKV6E4.mjs → chunk-3MWTAM3F.mjs} +3 -3
  51. package/dist/cli/{chunk-U6BTY4WS.mjs → chunk-4ANDW2OT.mjs} +1 -1
  52. package/dist/cli/{chunk-H4BYWEV5.js → chunk-4BSCSQ6I.js} +4 -4
  53. package/dist/cli/{chunk-ACS6BYE5.mjs → chunk-4UEXAMDU.mjs} +2 -2
  54. package/dist/cli/{chunk-QPN662ZP.js → chunk-5XGLDVSD.js} +100 -100
  55. package/dist/cli/{chunk-MFPHCUHK.js → chunk-7XXJJVSI.js} +5 -5
  56. package/dist/cli/{chunk-QGOHEJVJ.js → chunk-7ZCD7OPO.js} +5 -5
  57. package/dist/cli/{chunk-AXKFZIXC.mjs → chunk-AJJSKKH4.mjs} +2 -2
  58. package/dist/cli/{chunk-KSXBLXLV.mjs → chunk-BHF5UW34.mjs} +1 -1
  59. package/dist/cli/{chunk-AHQDUMDM.js → chunk-BO2TXH5Y.js} +20 -20
  60. package/dist/cli/{chunk-W5WLWRKL.mjs → chunk-BUC2TNF2.mjs} +2 -2
  61. package/dist/cli/{chunk-6GYGMWQV.js → chunk-BUUAFSSN.js} +68 -50
  62. package/dist/cli/{chunk-WUVDJSZE.js → chunk-C45E47KC.js} +23 -23
  63. package/dist/cli/{chunk-BUMCOVBP.js → chunk-D4R3AL4F.js} +5 -5
  64. package/dist/cli/{chunk-PVDP3AZY.mjs → chunk-DAZRIAXW.mjs} +4 -4
  65. package/dist/cli/{chunk-W3ECB7GC.js → chunk-DNOZQGJF.js} +3 -3
  66. package/dist/cli/{chunk-HYT5B2NL.js → chunk-DUL6UQ2T.js} +2 -2
  67. package/dist/cli/{chunk-P2YNTAGL.mjs → chunk-ES3S6UXR.mjs} +2 -2
  68. package/dist/cli/{chunk-K6GDSCFL.mjs → chunk-FDAYUP3M.mjs} +3 -3
  69. package/dist/cli/{chunk-23LYXVI4.js → chunk-FEVUIT2U.js} +6 -6
  70. package/dist/cli/{chunk-6S3OAJCJ.mjs → chunk-FSPEUU3V.mjs} +49 -6
  71. package/dist/cli/{chunk-2QIVGZKS.mjs → chunk-FZZMCVOS.mjs} +5 -5
  72. package/dist/cli/{chunk-73IZARR5.js → chunk-GHOB72U6.js} +13 -13
  73. package/dist/cli/{chunk-LVJAHM2I.mjs → chunk-GLYWRTEL.mjs} +3 -3
  74. package/dist/cli/{chunk-AXOQ2FMS.mjs → chunk-HNTIGYRT.mjs} +1 -1
  75. package/dist/cli/{chunk-C7UCDL2K.js → chunk-IGPHYKEJ.js} +41 -41
  76. package/dist/cli/{chunk-PULU5YGX.js → chunk-ISSYN3DJ.js} +20 -20
  77. package/dist/cli/{chunk-ZHIJA4MW.mjs → chunk-JKQPITEE.mjs} +54 -36
  78. package/dist/cli/{chunk-EHV52KUV.mjs → chunk-KMLACXI2.mjs} +7 -3
  79. package/dist/cli/{chunk-WAZR72D5.js → chunk-KQXACHYA.js} +26 -26
  80. package/dist/cli/{chunk-PGUK5VPC.js → chunk-LW2GKYZW.js} +2 -2
  81. package/dist/cli/{chunk-J54DMFV5.mjs → chunk-O2KSPI2M.mjs} +2 -2
  82. package/dist/cli/{chunk-CCC3NIYB.js → chunk-O6GT6JD7.js} +9 -9
  83. package/dist/cli/{chunk-DNYFNOWG.mjs → chunk-OCXWUWUI.mjs} +5 -5
  84. package/dist/cli/{chunk-MEAWK5G7.js → chunk-QKRDAJ3T.js} +53 -53
  85. package/dist/cli/{chunk-N5XRUZRS.js → chunk-QQESWF6D.js} +16 -16
  86. package/dist/cli/{chunk-2D5YISAL.js → chunk-REX5SUYU.js} +2 -2
  87. package/dist/cli/{chunk-RO2LTLJA.js → chunk-RXIQWG2N.js} +48 -48
  88. package/dist/cli/{chunk-VXDKL434.js → chunk-S33BN7GZ.js} +3 -3
  89. package/dist/cli/{chunk-72MEXMSH.mjs → chunk-SGRJJLNV.mjs} +1 -1
  90. package/dist/cli/{chunk-HOGRT5X6.mjs → chunk-TCNYSNVU.mjs} +1 -1
  91. package/dist/cli/{chunk-H7F3ROT3.mjs → chunk-TFPMVSGK.mjs} +2 -2
  92. package/dist/cli/{chunk-GFX6CDAB.mjs → chunk-V73WDQEA.mjs} +5 -5
  93. package/dist/cli/{chunk-LHD3HOYN.js → chunk-VYERVFGB.js} +49 -6
  94. package/dist/cli/{chunk-C233ZRNX.mjs → chunk-WBRSVML3.mjs} +4 -4
  95. package/dist/cli/{chunk-7AFTLM74.mjs → chunk-WW52ANX4.mjs} +2 -2
  96. package/dist/cli/{chunk-ZFJNIZHI.js → chunk-XZS35M3Y.js} +10 -10
  97. package/dist/cli/{chunk-YRNWA2IL.js → chunk-YNYHYL5C.js} +15 -15
  98. package/dist/cli/{chunk-JQT3SHXL.mjs → chunk-ZHE5E2WJ.mjs} +1 -1
  99. package/dist/cli/{chunk-N5RCXI3M.mjs → chunk-ZJ2H77VV.mjs} +5 -5
  100. package/dist/cli/{chunk-GQHZV7EQ.js → chunk-ZX6UVPGZ.js} +7 -7
  101. package/dist/cli/command-docs.js +2 -2
  102. package/dist/cli/command-docs.mjs +1 -1
  103. package/dist/cli/concurrent-runs-help-H5SZUA5J.js +22 -0
  104. package/dist/cli/{concurrent-runs-help-A2Y33OQ5.mjs → concurrent-runs-help-IYELSCHB.mjs} +6 -6
  105. package/dist/cli/{csv-PS74WVXE.mjs → csv-ENEC3APZ.mjs} +4 -4
  106. package/dist/cli/{csv-TKSR2LFV.js → csv-X6CP57R4.js} +13 -13
  107. package/dist/cli/{db-R6GOM4VC.js → db-6HLRSE2M.js} +27 -27
  108. package/dist/cli/{db-EXLBRZ7K.mjs → db-YGKRFK4T.mjs} +6 -6
  109. package/dist/cli/{describe-JJBXFPVQ.mjs → describe-4SGQEX7K.mjs} +18 -18
  110. package/dist/cli/describe-Q2OYHDVZ.js +50 -0
  111. package/dist/cli/describe-core.d.mts +2 -2
  112. package/dist/cli/describe-core.d.ts +2 -2
  113. package/dist/cli/{executions-474U7R3Y.js → executions-IC55YJ67.js} +8 -8
  114. package/dist/cli/{executions-5PEODJQG.mjs → executions-PO2IOSZ7.mjs} +6 -6
  115. package/dist/cli/{feedback-QUQVRDBD.mjs → feedback-6BUD5F4I.mjs} +6 -6
  116. package/dist/cli/{feedback-URTCAOXP.js → feedback-BCGQLZ5T.js} +14 -14
  117. package/dist/cli/git-5X3MLBIP.js +26 -0
  118. package/dist/cli/{git-AQF23KKU.mjs → git-IN4IBL2K.mjs} +5 -5
  119. package/dist/cli/index.js +148 -148
  120. package/dist/cli/index.mjs +47 -47
  121. package/dist/cli/{integrations-NMFOOSS4.js → integrations-R2Z2MDO3.js} +29 -29
  122. package/dist/cli/{integrations-5POBI72U.mjs → integrations-ZMGB6NQA.mjs} +7 -7
  123. package/dist/cli/{legacy-noops-6YVCOSFO.mjs → legacy-noops-GIC5OZKP.mjs} +6 -6
  124. package/dist/cli/{legacy-noops-V75T5LHV.js → legacy-noops-X4JPRPTJ.js} +9 -9
  125. package/dist/cli/{mcp-7WEYQ5V7.mjs → mcp-G4IRJIKK.mjs} +4 -4
  126. package/dist/cli/{mcp-N6GYXCUQ.js → mcp-USZKTVL2.js} +24 -24
  127. package/dist/cli/{monitors-TAK4M5Y4.mjs → monitors-SNFZPSCY.mjs} +7 -7
  128. package/dist/cli/{monitors-HW4H4PE5.js → monitors-T7LRP7OB.js} +100 -100
  129. package/dist/cli/{org-FULXOXNE.js → org-2L2ZZL2P.js} +121 -121
  130. package/dist/cli/{org-3C2RN36N.mjs → org-YTXLKW52.mjs} +6 -6
  131. package/dist/cli/{outcomes-4KRZL6OL.mjs → outcomes-CJWBIFTA.mjs} +6 -6
  132. package/dist/cli/{outcomes-O3HDQWGN.js → outcomes-O63F57JF.js} +14 -14
  133. package/dist/cli/{play-ZTRWUODW.mjs → play-6UWPUHC6.mjs} +331 -70
  134. package/dist/cli/{play-HA4RGX7T.js → play-T353SULJ.js} +930 -669
  135. package/dist/cli/{providers-FAKWWJE2.mjs → providers-LZABK2UW.mjs} +6 -6
  136. package/dist/cli/{providers-DXMKWBZN.js → providers-XORJH2VW.js} +9 -9
  137. package/dist/cli/{quickstart-YWGBTW77.mjs → quickstart-O4RF7J55.mjs} +4 -4
  138. package/dist/cli/{quickstart-MA74UPNI.js → quickstart-QBNUNPZR.js} +6 -6
  139. package/dist/cli/{run-4DXSGXRB.js → run-2CPMFC6W.js} +44 -44
  140. package/dist/cli/{run-QHCYMSBP.mjs → run-GBRPFC6P.mjs} +23 -23
  141. package/dist/cli/{search-N4ZOK5XX.mjs → search-G7TS7OFB.mjs} +7 -7
  142. package/dist/cli/search-M3AHFCKQ.js +32 -0
  143. package/dist/cli/{search-output-F2OYLVK2.mjs → search-output-BIIJRUCP.mjs} +4 -4
  144. package/dist/cli/{search-output-D5VAC52B.js → search-output-NRKLNWSD.js} +6 -6
  145. package/dist/cli/{secrets-LD4FVAQI.mjs → secrets-DN3XEZNH.mjs} +6 -6
  146. package/dist/cli/{secrets-3KETOTDS.js → secrets-FUXYSEL5.js} +15 -15
  147. package/dist/cli/{sessions-LPLI4Z4O.mjs → sessions-PMUTPCTT.mjs} +6 -6
  148. package/dist/cli/sessions-VMBMBGVJ.js +23 -0
  149. package/dist/cli/{settings-NCGPJG3Z.mjs → settings-N6GNS2KA.mjs} +12 -12
  150. package/dist/cli/{settings-NFBTCOMB.js → settings-ZDTWCQ6B.js} +85 -85
  151. package/dist/cli/{setup-NH6MRYXZ.mjs → setup-LJ3KWPSA.mjs} +9 -9
  152. package/dist/cli/{setup-ATBSUSH4.js → setup-PN5TSSJE.js} +49 -49
  153. package/dist/cli/{skills-ITPBPIXD.mjs → skills-7J42K6VC.mjs} +7 -7
  154. package/dist/cli/skills-CXDENBLF.js +37 -0
  155. package/dist/cli/{tools-2XZPR65V.mjs → tools-M3S6D6DA.mjs} +17 -17
  156. package/dist/cli/tools-WY2GMOC7.js +57 -0
  157. package/dist/cli/{update-VFB22FWO.mjs → update-XTVFG74E.mjs} +9 -9
  158. package/dist/cli/update-ZB2IBGXG.js +37 -0
  159. package/dist/cli/{views-WJUZOQM2.js → views-B4X2FWTF.js} +21 -21
  160. package/dist/cli/{views-MRN3HWTG.mjs → views-UFYRDO4X.mjs} +6 -6
  161. package/dist/cli/{workflow-Q4JFBTVH.js → workflow-I2RM2J2J.js} +17 -17
  162. package/dist/cli/{workflow-A6P7YV5W.mjs → workflow-ZLMS3PDE.mjs} +7 -7
  163. package/dist/{client-QznpkWrk.d.ts → client-2QWMJInp.d.ts} +1 -1
  164. package/dist/{client-CmG8MT0x.d.mts → client-7H8TXmLa.d.mts} +1 -1
  165. package/dist/{client-core-CY0jNW0e.d.mts → client-core-BraEuxbg.d.mts} +67 -4
  166. package/dist/{client-core-CXDqfeiB.d.ts → client-core-DRglY5xa.d.ts} +67 -4
  167. package/dist/index.d.mts +3 -3
  168. package/dist/index.d.ts +3 -3
  169. package/dist/index.js +9 -9
  170. package/dist/index.mjs +6 -6
  171. package/dist/install-integrity.json +125 -120
  172. package/dist/plays/bundle-play-file.mjs +5 -0
  173. package/dist/plays/play-description.d.mts +1 -1
  174. package/dist/plays/play-description.d.ts +1 -1
  175. package/dist/plays/run-request.d.mts +1 -1
  176. package/dist/plays/run-request.d.ts +1 -1
  177. package/dist/release.d.mts +3 -3
  178. package/dist/release.d.ts +3 -3
  179. package/dist/release.js +2 -2
  180. package/dist/release.mjs +1 -1
  181. package/dist/server.d.mts +2 -2
  182. package/dist/server.d.ts +2 -2
  183. package/dist/server.js +5 -5
  184. package/dist/server.mjs +3 -3
  185. package/package.json +1 -1
  186. package/dist/cli/auth-VU6VIPVY.js +0 -44
  187. package/dist/cli/concurrent-runs-help-6WUNDV77.js +0 -22
  188. package/dist/cli/describe-CA2FL2OS.js +0 -50
  189. package/dist/cli/git-WJ4V2B4T.js +0 -26
  190. package/dist/cli/search-V765JH2H.js +0 -32
  191. package/dist/cli/sessions-XC65OMDS.js +0 -23
  192. package/dist/cli/skills-4NQBTGOL.js +0 -37
  193. package/dist/cli/tools-ZVOFATX2.js +0 -57
  194. package/dist/cli/update-QME3KPOP.js +0 -37
@@ -150,6 +150,8 @@ import type {
150
150
  PlaysActivityResponse,
151
151
  PlayDetail,
152
152
  PlayCostEstimateResult,
153
+ PlayStepValuesResult,
154
+ PlayCheckIssue,
153
155
  PlayCheckResult,
154
156
  PlayRunResult,
155
157
  PlayRunStart,
@@ -4597,7 +4599,26 @@ export class DeeplineClient {
4597
4599
  sourceFiles?: Record<string, string>;
4598
4600
  artifact: Record<string, unknown>;
4599
4601
  importedPlayDependencies?: PlayCompilerManifest[];
4602
+ /**
4603
+ * What the manifest is for. Absent means `publish`. `run_file` (a local
4604
+ * `plays run --file`) is never refused for a missing diagram.
4605
+ */
4606
+ purpose?: 'publish' | 'run_file';
4600
4607
  }): Promise<PlayCompilerManifest> {
4608
+ return (await this.compilePlayManifestWithIssues(input)).compilerManifest;
4609
+ }
4610
+
4611
+ /**
4612
+ * {@link compilePlayManifest}, plus the structured check issues the compile
4613
+ * produced, so a publishing client can show the same warnings `plays check`
4614
+ * shows. `issues` is empty from a server that does not return them.
4615
+ */
4616
+ async compilePlayManifestWithIssues(
4617
+ input: Parameters<DeeplineClient['compilePlayManifest']>[0],
4618
+ ): Promise<{
4619
+ compilerManifest: PlayCompilerManifest;
4620
+ issues: PlayCheckIssue[];
4621
+ }> {
4601
4622
  const retryDelays = COMPILE_MANIFEST_RETRY_DELAYS_MS.slice(
4602
4623
  0,
4603
4624
  Math.max(0, this.config.maxRetries),
@@ -4606,8 +4627,17 @@ export class DeeplineClient {
4606
4627
  try {
4607
4628
  const response = await this.http.post<{
4608
4629
  compilerManifest: PlayCompilerManifest;
4630
+ issues?: unknown;
4609
4631
  }>('/api/v2/plays/compile-manifest', input);
4610
- return requireCompileManifestResponse(response, input.name);
4632
+ return {
4633
+ compilerManifest: requireCompileManifestResponse(
4634
+ response,
4635
+ input.name,
4636
+ ),
4637
+ issues: Array.isArray(response?.issues)
4638
+ ? (response.issues as PlayCheckIssue[])
4639
+ : [],
4640
+ };
4611
4641
  } catch (error) {
4612
4642
  const delayMs = retryDelays[attempt];
4613
4643
  if (delayMs === undefined || !isTransientCompileManifestError(error)) {
@@ -4675,7 +4705,8 @@ export class DeeplineClient {
4675
4705
  }
4676
4706
 
4677
4707
  /**
4678
- * Register an already-bundled play artifact and start a run from it.
4708
+ * Start a run from an already-bundled play artifact, as `plays run --file`
4709
+ * does: the run registers the artifact; no draft revision is saved.
4679
4710
  *
4680
4711
  * SDK and CLI packaging wrappers use this low-level run method for file-based Plays.
4681
4712
  * Local bundling must produce the runtime artifact first.
@@ -4693,32 +4724,24 @@ export class DeeplineClient {
4693
4724
  force?: boolean;
4694
4725
  forceToolRefresh?: boolean;
4695
4726
  }): Promise<PlayRunStart> {
4727
+ // A run of source, like `deepline plays run --file`: compiled for a run
4728
+ // (a missing diagram only warns) and registered by the run itself, never
4729
+ // saved as a draft revision, which publishing rules govern.
4696
4730
  const compilerManifest =
4697
4731
  input.compilerManifest ??
4698
4732
  (await this.compilePlayManifest({
4733
+ purpose: 'run_file',
4699
4734
  name: input.name,
4700
4735
  sourceCode: input.sourceCode,
4701
4736
  sourceFiles: input.sourceFiles,
4702
4737
  artifact: input.artifact,
4703
4738
  }));
4704
- const registeredArtifact = await this.registerPlayArtifact({
4705
- name: input.name,
4706
- sourceCode: input.sourceCode,
4707
- sourceFiles: input.sourceFiles,
4708
- description: input.description,
4709
- artifact: input.artifact,
4710
- compilerManifest,
4711
- publish: false,
4712
- });
4713
- if (!registeredArtifact.artifactStorageKey) {
4714
- throw new Error(
4715
- 'registerPlayArtifact did not return an artifactStorageKey.',
4716
- );
4717
- }
4718
4739
 
4719
4740
  return this.startPlayRun({
4720
4741
  name: input.name,
4721
- artifactStorageKey: registeredArtifact.artifactStorageKey,
4742
+ sourceCode: input.sourceCode,
4743
+ ...(input.sourceFiles ? { sourceFiles: input.sourceFiles } : {}),
4744
+ runtimeArtifact: input.artifact,
4722
4745
  description: input.description,
4723
4746
  compilerManifest,
4724
4747
  ...(input.input ? { input: input.input } : {}),
@@ -4732,9 +4755,10 @@ export class DeeplineClient {
4732
4755
  }
4733
4756
 
4734
4757
  /**
4735
- * Register a bundled play artifact and start a run from the live revision.
4758
+ * Start a run from a bundled play artifact, as `plays run --file` does: the
4759
+ * run registers the artifact; no draft revision is saved.
4736
4760
  *
4737
- * This method wraps {@link registerPlayArtifact} and {@link startPlayRun}.
4761
+ * This method wraps {@link compilePlayManifest} and {@link startPlayRun}.
4738
4762
  * Packaging wrappers use this method for file-based Plays.
4739
4763
  * Pass the returned ID to {@link getPlayStatus}.
4740
4764
  * The method returns the same durable `{ result }` object that `deepline run` saves when it completes.
@@ -4786,36 +4810,24 @@ export class DeeplineClient {
4786
4810
  if (!artifact) {
4787
4811
  throw new Error('submitPlay requires a bundled play artifact.');
4788
4812
  }
4813
+ // A run of source, like `deepline plays run --file`: compiled for a run
4814
+ // (a missing diagram only warns) and registered by the run itself, never
4815
+ // saved as a draft revision, which publishing rules govern.
4789
4816
  const compilerManifest =
4790
4817
  options?.compilerManifest ??
4791
4818
  (await this.compilePlayManifest({
4819
+ purpose: 'run_file',
4792
4820
  name,
4793
4821
  sourceCode,
4794
4822
  sourceFiles: options?.sourceFiles,
4795
4823
  artifact,
4796
4824
  }));
4797
4825
 
4798
- const registeredArtifact = await this.registerPlayArtifact({
4799
- name,
4800
- sourceCode,
4801
- sourceFiles: options?.sourceFiles,
4802
- description: options?.description,
4803
- artifact,
4804
- compilerManifest,
4805
- publish: false,
4806
- });
4807
- if (!registeredArtifact.artifactStorageKey) {
4808
- throw new Error(
4809
- 'registerPlayArtifact did not return an artifactStorageKey.',
4810
- );
4811
- }
4812
-
4813
4826
  return this.startPlayRun({
4814
4827
  name,
4815
- artifactStorageKey: registeredArtifact.artifactStorageKey,
4816
4828
  sourceCode,
4829
+ ...(options?.sourceFiles ? { sourceFiles: options.sourceFiles } : {}),
4817
4830
  description: options?.description,
4818
- staticPipeline: registeredArtifact.staticPipeline ?? null,
4819
4831
  artifactHash:
4820
4832
  typeof artifact.artifactHash === 'string'
4821
4833
  ? artifact.artifactHash
@@ -7033,6 +7045,37 @@ export class DeeplineClient {
7033
7045
  return this.http.get(`/api/v2/plays/${encodeURIComponent(name)}/cost`);
7034
7046
  }
7035
7047
 
7048
+ /**
7049
+ * One diagram step's recorded values (bounded input/output previews,
7050
+ * status, attempt) for at most 50 named runs of a Play. Every run is
7051
+ * answered once, in order: `found: false` when it is not this Play's run,
7052
+ * `value: null` when it never settled at the step. Read-only.
7053
+ */
7054
+ async getPlayStepValues(input: {
7055
+ playName: string;
7056
+ /** The step id as the diagram draws it (`docflow:` optional). */
7057
+ node: string;
7058
+ runIds: readonly string[];
7059
+ }): Promise<PlayStepValuesResult> {
7060
+ const node = input.node.trim();
7061
+ if (!node) throw new Error('getPlayStepValues requires a node.');
7062
+ if (node.length > 300)
7063
+ throw new Error('getPlayStepValues node must be at most 300 characters.');
7064
+ const runIds = [
7065
+ ...new Set(input.runIds.map((runId) => runId.trim()).filter(Boolean)),
7066
+ ];
7067
+ if (runIds.length === 0)
7068
+ throw new Error('getPlayStepValues requires at least one run id.');
7069
+ if (runIds.length > 50)
7070
+ throw new Error(
7071
+ `getPlayStepValues reads at most 50 runs per request; got ${runIds.length}.`,
7072
+ );
7073
+ const params = new URLSearchParams({ node, runIds: runIds.join(',') });
7074
+ return this.http.get(
7075
+ `/api/v2/plays/${encodeURIComponent(input.playName)}/step-values?${params}`,
7076
+ );
7077
+ }
7078
+
7036
7079
  /** Read one trigger inventory page without loading run histories. */
7037
7080
  async listPlayTriggerInventory(options?: { cursor?: string }): Promise<{
7038
7081
  page: Array<{
@@ -365,6 +365,8 @@ export type {
365
365
  StartPlayRunRequest,
366
366
  PlayCostEstimate,
367
367
  PlayCostEstimateResult,
368
+ PlayStepValue,
369
+ PlayStepValuesResult,
368
370
  PlayListItem,
369
371
  PlaysActivityResponse,
370
372
  CustomerDbQueryResult,
@@ -205,11 +205,15 @@ 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.583',
208
+ // 0.4.0 is the first CLI the server refuses a Play without a `@mermaid`
209
+ // diagram for (PLAY_DIAGRAM_REQUIRED_FROM_CLI_RELEASE in
210
+ // apps/deepline-api/src/lib/plays/diagram-requirement.ts); older CLIs are
211
+ // only warned.
212
+ version: '0.4.0',
209
213
  updateSummary: {
210
- introducedIn: '0.3.90',
214
+ introducedIn: '0.4.0',
211
215
  summary:
212
- 'Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.',
216
+ 'Publishing a Play now requires a `@mermaid` diagram that binds its steps, so every run records what each step read and produced; `deepline plays check` shows what is missing and how to add it. Local `deepline plays run --file` still runs without one.',
213
217
  },
214
218
  packageCapabilities: {
215
219
  updatePreferences: 1,
@@ -1520,6 +1520,43 @@ export interface PlayRunListItem {
1520
1520
  };
1521
1521
  }
1522
1522
 
1523
+ /** One step's recorded values in one run (`getPlayStepValues`). */
1524
+ export interface PlayStepValue {
1525
+ status: 'completed' | 'failed';
1526
+ attempt: number;
1527
+ /** Bounded previews of what the step read, by name. */
1528
+ inputs: Record<string, unknown> | null;
1529
+ /** Bounded previews of what the step produced, by name. */
1530
+ outputs: Record<string, unknown> | null;
1531
+ inputsTruncated: boolean;
1532
+ outputsTruncated: boolean;
1533
+ error: string | null;
1534
+ }
1535
+
1536
+ /** `GET /api/v2/plays/:name/step-values`: one step across named runs. */
1537
+ export interface PlayStepValuesResult {
1538
+ playName: string;
1539
+ /** The step id as asked. */
1540
+ nodeId: string;
1541
+ /** The id the step's values are recorded under (`docflow:<id>`). */
1542
+ observedNodeId: string;
1543
+ /**
1544
+ * Every asked run once, in order. `found: false`: not a run of this Play.
1545
+ * `value: null`: the run never settled at the step. `recorded: false`: the
1546
+ * run recorded no step values at all, so it is unknown whether it reached
1547
+ * the step (absent from servers that predate it).
1548
+ */
1549
+ runs: Array<
1550
+ | { runId: string; found: false }
1551
+ | {
1552
+ runId: string;
1553
+ found: true;
1554
+ value: PlayStepValue | null;
1555
+ recorded?: boolean;
1556
+ }
1557
+ >;
1558
+ }
1559
+
1523
1560
  /** One run's outcome at one diagram step (`runs.list` with `steps`). */
1524
1561
  export interface PlayRunStepSummary {
1525
1562
  /** Diagram node id. */
@@ -319,9 +319,9 @@
319
319
  "locator": "schedule:",
320
320
  "owner": "platform",
321
321
  "criticality": "maintenance",
322
- "purpose": "Reconcile completed PR Preview Machines and release capacity only after the per-app lease fence allows it. Its named-estate lane plans every named Preview estate (eval reuse keys, runtime up preview branch lanes, one-off namespaces) with `bun scripts/fly-preview-estate-lifecycle.ts --report --named-reclaim-plan` and, only on a workflow_dispatch with reclaim_named_estates=true, scales at most 8 planned estates per pass (interrupted reclaims first, then reclaimable estates idle 24 h by lease, release or reclaim evidence) to zero through the claimed runtime-preview-namespace.yml scale-to-zero, recording the start and lane app before the seam, retiring the release lane and recording reclaimed history; scheduled passes only report it. Each pass also returns the deeplinev1/load PlanetScale branch to its parked size when no Customer Workload Suite run is active on load-tests/framework, in case a load test's own teardown never ran.",
323
- "successDefinition": "Fly inventory is reconciled and eligible terminal/closed PR capacity is released; every named estate is classified without a read failure, and a dispatched named reclaim leaves each target at zero Machines with its release lane retired and reclaimed history written. No eligible app or estate is a valid no-op. The load database is parked, a change toward that size is in flight, or an active Customer Workload Suite run on load-tests/framework may be holding it.",
324
- "failureDefinition": "Inventory, lease resolution, scale-down, or empty-app cleanup fails or is ambiguous; a named-estate Fly or authority read fails; a named reclaim is refused inside its claim (active owner, used since discovery, ownership or lane-app refusal) or any role keeps a Machine; or any named reclaim is incomplete (started but its release lane was never retired), which fails every pass until a dispatch finishes it; or reading or parking the load database fails.",
322
+ "purpose": "Reconcile completed PR Preview Machines and release capacity only after the per-app lease fence allows it. Its named-estate lane plans every named Preview estate (eval reuse keys, runtime up preview branch lanes, one-off namespaces) with `bun scripts/fly-preview-estate-lifecycle.ts --report --named-reclaim-plan` and, only on a workflow_dispatch with reclaim_named_estates=true, scales at most 8 planned estates per pass (interrupted reclaims first, then reclaimable estates idle 24 h by lease, release or reclaim evidence) to zero through the claimed runtime-preview-namespace.yml scale-to-zero, recording the start and lane app before the seam, retiring the release lane and recording reclaimed history; scheduled passes only report it. Each pass is also the only thing that parks the deeplinev1/load PlanetScale branch: `load-database.ts park` returns it to its parked size once no Customer Workload Suite load_test run is queued, waiting or running on any branch and the last one ended 2 hours ago, unless LOAD_DATABASE_HOLD_UNTIL holds it until a fixed time.",
323
+ "successDefinition": "Fly inventory is reconciled and eligible terminal/closed PR capacity is released; every named estate is classified without a read failure, and a dispatched named reclaim leaves each target at zero Machines with its release lane retired and reclaimed history written. No eligible app or estate is a valid no-op. The load database is parked or a change toward that size is in flight, or the pass logged what keeps it at full size: LOAD_DATABASE_HOLD_UNTIL, a load_test run not yet ended, or the 2 hours after the last one.",
324
+ "failureDefinition": "Inventory, lease resolution, scale-down, or empty-app cleanup fails or is ambiguous; a named-estate Fly or authority read fails; a named reclaim is refused inside its claim (active owner, used since discovery, ownership or lane-app refusal) or any role keeps a Machine; or any named reclaim is incomplete (started but its release lane was never retired), which fails every pass until a dispatch finishes it; or reading the Customer Workload Suite's runs, the hold or the load database fails, or requesting its park fails.",
325
325
  "startGraceMs": 600000,
326
326
  "runTimeoutMs": 3600000,
327
327
  "failureAlert": "github_workflow_run",
@@ -418,6 +418,25 @@
418
418
  "failureAlert": "github_workflow_run",
419
419
  "domainReportRequired": true
420
420
  },
421
+ {
422
+ "id": "github.production-vercel-oidc-probe",
423
+ "name": "Production Vercel OIDC probe",
424
+ "workflowEvents": ["schedule"],
425
+ "scheduler": "github_actions",
426
+ "cadence": "23 * * * *",
427
+ "timezone": "UTC",
428
+ "source": ".github/workflows/production-vercel-oidc-probe.yml",
429
+ "locator": "schedule:",
430
+ "owner": "platform",
431
+ "criticality": "operational",
432
+ "purpose": "Every hour, from main, exchange the Production GitHub OIDC token for a Vercel token and GET the main and Slack agent projects, the team and the main project's system bypass list, logging each HTTP status, x-vercel-id and error.code. Read-only; catches OIDC permission drift before a Production release does.",
433
+ "successDefinition": "The OIDC exchange succeeds and the project and team reads return 200. The system bypass read is reported and is required only once BYPASS_READ_REQUIRED is true.",
434
+ "failureDefinition": "The OIDC exchange fails, a project or team read returns anything but 200, a required bypass read fails, or the pass exceeds its 10-minute timeout.",
435
+ "startGraceMs": 1800000,
436
+ "runTimeoutMs": 600000,
437
+ "failureAlert": "github_workflow_run",
438
+ "domainReportRequired": true
439
+ },
421
440
  {
422
441
  "id": "github.tamradar-dev-account-cleanup",
423
442
  "name": "TamRadar Dev Account Cleanup",
@@ -3,6 +3,7 @@ import {
3
3
  RUN_EVENT_TERMINAL_KIND_VALUES,
4
4
  } from './run-event-catalog';
5
5
  import { prepareRetainedPlayPipelinesForTransport } from '../plays/execution-pipeline';
6
+ import { isImmutableRuntimeExecutionRecoveryOrigin } from './scheduler-backends/runtime-api-origin';
6
7
  import { createWriteStream } from 'node:fs';
7
8
  import { createHash, randomUUID } from 'node:crypto';
8
9
  import {
@@ -222,7 +223,10 @@ type RuntimeApiRequest =
222
223
  action: 'create_db_session';
223
224
  } & CreateDbSessionRequest)
224
225
  | {
225
- action: 'append_run_events' | 'project_run_events';
226
+ action:
227
+ | 'append_run_events'
228
+ | 'project_run_events'
229
+ | 'project_run_events_prefixed';
226
230
  playId: string;
227
231
  events: PlayRunLedgerIngressEvent[];
228
232
  /** Live progress only: intake commits while this attempt is current. */
@@ -838,7 +842,8 @@ function isRetryableAppRuntimeResponse(input: {
838
842
  // response on a replay-safe action is an intermediary failure.
839
843
  if (
840
844
  (input.action === 'append_run_events' ||
841
- input.action === 'project_run_events') &&
845
+ input.action === 'project_run_events' ||
846
+ input.action === 'project_run_events_prefixed') &&
842
847
  isVercelSecurityCheckpointResponse(input)
843
848
  ) {
844
849
  return true;
@@ -878,6 +883,61 @@ function isRetryableAppRuntimeResponse(input: {
878
883
  return isRetryableAppRuntimeResponseStatus(input.status);
879
884
  }
880
885
 
886
+ const OLDER_RECEIVER_UNSUPPORTED_ACTION_ERRORS = new Set([
887
+ 'Unsupported runtime action capability scope.',
888
+ 'Unsupported runtime data-plane action.',
889
+ 'Unsupported action: project_run_events_prefixed',
890
+ ]);
891
+
892
+ /**
893
+ * An app that predates `project_run_events_prefixed` refuses it before any
894
+ * side effect: at its capability layer (403) or its exhaustive action check
895
+ * (400). The receipt is retained and retried after a newer app promotes; it
896
+ * never falls back to the single-fact action, which would prove a multi-fact
897
+ * receipt as one fact.
898
+ */
899
+ export function isOlderReceiverPrefixedProjectionRefusal(input: {
900
+ status: number;
901
+ body: string;
902
+ }): boolean {
903
+ if (input.status !== 400 && input.status !== 403) return false;
904
+ // `detail` is the summarized message; a raw response is JSON.
905
+ let error: unknown = input.body.trim();
906
+ try {
907
+ const parsed = JSON.parse(input.body) as unknown;
908
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
909
+ error = (parsed as { error?: unknown }).error;
910
+ } catch {
911
+ // Not JSON: keep the summarized message.
912
+ }
913
+ return (
914
+ typeof error === 'string' &&
915
+ OLDER_RECEIVER_UNSUPPORTED_ACTION_ERRORS.has(error)
916
+ );
917
+ }
918
+
919
+ /**
920
+ * A receipt of more than one outbox fact reaches a mutable receiver only as
921
+ * `project_run_events_prefixed`, whose name fences out apps that cannot prove
922
+ * a prefix. An immutable receiver advertised its own support and keeps the
923
+ * established action.
924
+ */
925
+ export function runLedgerProjectionAction(input: {
926
+ baseUrl: string;
927
+ outboxFacts: number;
928
+ }): 'project_run_events' | 'project_run_events_prefixed' {
929
+ if (input.outboxFacts <= 1) return 'project_run_events';
930
+ let origin: string;
931
+ try {
932
+ origin = new URL(input.baseUrl).origin;
933
+ } catch {
934
+ return 'project_run_events_prefixed';
935
+ }
936
+ return isImmutableRuntimeExecutionRecoveryOrigin(origin)
937
+ ? 'project_run_events'
938
+ : 'project_run_events_prefixed';
939
+ }
940
+
881
941
  /**
882
942
  * The rate-state store's tables are not migrated yet. A server that names this
883
943
  * code calls the response retryable, but the rate-state backend owns that retry
@@ -1162,6 +1222,7 @@ function isRetryableAppRuntimeAction(
1162
1222
  // Classification remains replay-safe for the durable outbox even though
1163
1223
  // projectRunEventsViaAppRuntime disables in-process transport retries.
1164
1224
  action === 'project_run_events' ||
1225
+ action === 'project_run_events_prefixed' ||
1165
1226
  action === 'apply_row_updates' ||
1166
1227
  action === 'compute_billing_finalize' ||
1167
1228
  action === 'compute_billing_record_item' ||
@@ -1794,7 +1855,9 @@ async function postAppRuntimeApiAttempts<TResponse>(
1794
1855
  if (context.probeConnection && context.onResponseMeta)
1795
1856
  void runtimeApiConnectionProbe(baseUrl);
1796
1857
  const fastRunLedgerBypass =
1797
- body.action === 'append_run_events' || body.action === 'project_run_events';
1858
+ body.action === 'append_run_events' ||
1859
+ body.action === 'project_run_events' ||
1860
+ body.action === 'project_run_events_prefixed';
1798
1861
  const vercelHeaders = fastRunLedgerBypass
1799
1862
  ? null
1800
1863
  : await vercelProtectionBypassHeaders({
@@ -2991,6 +3054,8 @@ export async function projectRunEventsViaAppRuntime(
2991
3054
  * receiver advertised.
2992
3055
  */
2993
3056
  frozenIngressReceipt?: boolean;
3057
+ /** Outbox facts this receipt carries; above one selects the fenced action at a mutable receiver. */
3058
+ outboxFacts?: number;
2994
3059
  },
2995
3060
  ): Promise<void> {
2996
3061
  const provableFacts =
@@ -3005,6 +3070,10 @@ export async function projectRunEventsViaAppRuntime(
3005
3070
  `A ${input.deliveryPrefixFacts}-fact Run Ledger receipt needs a receiver that proves that many; this one advertised ${context.runLedgerTerminalBacklogFacts ?? 'none'}.`,
3006
3071
  );
3007
3072
  }
3073
+ const projectionAction = runLedgerProjectionAction({
3074
+ baseUrl: context.baseUrl,
3075
+ outboxFacts: input.outboxFacts ?? 1,
3076
+ });
3008
3077
  const batches = partitionRunEventsForAppRuntime(input.events);
3009
3078
  const receiptBatch = runLedgerReceiptBatchIndex(batches);
3010
3079
  for (const [index, events] of batches.entries()) {
@@ -3043,16 +3112,36 @@ export async function projectRunEventsViaAppRuntime(
3043
3112
  retryPolicy: 'none' as const,
3044
3113
  onResponseMeta(meta: RuntimeApiResponseMeta) {
3045
3114
  context.onResponseMeta?.(meta);
3046
- if (meta.action === 'project_run_events') responseMeta = meta;
3115
+ if (meta.action === projectionAction) responseMeta = meta;
3047
3116
  },
3048
3117
  };
3049
3118
  const requestStartedAt = Date.now();
3050
3119
  try {
3051
3120
  await postAppRuntimeApi(deliveryContext, {
3052
- action: 'project_run_events',
3121
+ action: projectionAction,
3053
3122
  ...request,
3054
3123
  });
3055
3124
  } catch (error) {
3125
+ if (projectionAction === 'project_run_events_prefixed') {
3126
+ if (
3127
+ error instanceof AppRuntimeApiResponseError &&
3128
+ isOlderReceiverPrefixedProjectionRefusal({
3129
+ status: error.status,
3130
+ body: error.detail,
3131
+ })
3132
+ ) {
3133
+ throw new AppRuntimeApiResponseError({
3134
+ action: 'project_run_events_prefixed',
3135
+ status: 503,
3136
+ code: 'RUN_LEDGER_PREFIX_RECEIPT_UNAVAILABLE',
3137
+ requestId: error.requestId,
3138
+ retryable: true,
3139
+ detail:
3140
+ 'The serving app predates prefixed Run Ledger receipts; the receipt is retained for retry.',
3141
+ });
3142
+ }
3143
+ throw error;
3144
+ }
3056
3145
  if (
3057
3146
  !(error instanceof AppRuntimeApiResponseError) ||
3058
3147
  !isLegacyProjectRunCreatedUnsupportedActionResponse({
@@ -5854,7 +5854,12 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
5854
5854
  if (!this.#options.getRuntimeStepReceipts) return null;
5855
5855
  return (await this.getRuntimeStepReceipts([key])).get(key) ?? null;
5856
5856
  }
5857
- const receipt = await this.#options.getRuntimeStepReceipt({ key });
5857
+ const expectedOutputBytes =
5858
+ this.runtimeReceiptHydrationGate.measuredOutputBytesPerKey();
5859
+ const receipt = await this.#options.getRuntimeStepReceipt({
5860
+ key,
5861
+ ...(expectedOutputBytes === undefined ? {} : { expectedOutputBytes }),
5862
+ });
5858
5863
  if (receipt && typeof receipt.key === 'string' && receipt.key.trim()) {
5859
5864
  return {
5860
5865
  ...receipt,
@@ -6527,13 +6532,37 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
6527
6532
 
6528
6533
  private async getRuntimeStepReceipts(
6529
6534
  keys: string[],
6530
- options?: { hydrateOutput?: boolean },
6535
+ options?: {
6536
+ hydrateOutput?: boolean;
6537
+ /**
6538
+ * Known decoded output sizes, usually from a manifest read. They size
6539
+ * the read batches so one request never asks for hundreds of bodies.
6540
+ */
6541
+ expectedOutputBytes?: ReadonlyMap<string, number>;
6542
+ },
6531
6543
  ): Promise<Map<string, RuntimeStepReceipt>> {
6532
6544
  const uniqueKeys = [
6533
6545
  ...new Set(keys.map((key) => key.trim()).filter(Boolean)),
6534
6546
  ];
6535
6547
  if (uniqueKeys.length === 0) return new Map();
6536
6548
  const getReceipts = this.#options.getRuntimeStepReceipts;
6549
+ const hydrate = options?.hydrateOutput !== false;
6550
+ const knownOutputBytes = hydrate ? options?.expectedOutputBytes : undefined;
6551
+ // A full read without a manifest size is priced at what this run's reads
6552
+ // have actually measured, so page-sized bodies batch small and tiny ones
6553
+ // keep large batches.
6554
+ const learnedOutputBytes = hydrate
6555
+ ? this.runtimeReceiptHydrationGate.measuredOutputBytesPerKey()
6556
+ : undefined;
6557
+ const expectedOutputBytes =
6558
+ knownOutputBytes || learnedOutputBytes !== undefined
6559
+ ? new Map(
6560
+ uniqueKeys.flatMap((key) => {
6561
+ const bytes = knownOutputBytes?.get(key) ?? learnedOutputBytes;
6562
+ return bytes === undefined ? [] : [[key, bytes] as const];
6563
+ }),
6564
+ )
6565
+ : undefined;
6537
6566
  const receipts = getReceipts
6538
6567
  ? await this.dispatchChunkedRuntimeReceiptRequest(uniqueKeys, (chunk) =>
6539
6568
  getReceipts({
@@ -6541,6 +6570,13 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
6541
6570
  ...(options?.hydrateOutput === false
6542
6571
  ? { hydrateOutput: false }
6543
6572
  : {}),
6573
+ ...(expectedOutputBytes && expectedOutputBytes.size > 0
6574
+ ? {
6575
+ expectedOutputBytes: chunk.map((key) =>
6576
+ expectedOutputBytes.get(key),
6577
+ ),
6578
+ }
6579
+ : {}),
6544
6580
  }),
6545
6581
  )
6546
6582
  : await Promise.all(
@@ -7397,6 +7433,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7397
7433
  );
7398
7434
  let expectedReadBackBytes = 0;
7399
7435
  let hasExactReadBackBytes = true;
7436
+ const readBackBytesByKey = new Map<string, number>();
7400
7437
  for (const key of incompleteKeys) {
7401
7438
  const receipt = completionInputByKey.get(key);
7402
7439
  if (!receipt) {
@@ -7405,21 +7442,23 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7405
7442
  }
7406
7443
  const measured =
7407
7444
  this.runtimeStepReceiptCompletionOutputBytes.get(receipt);
7408
- if (measured !== undefined) {
7409
- expectedReadBackBytes += measured;
7410
- continue;
7411
- }
7445
+ let bytes = 0;
7412
7446
  if (receipt.outputRef) {
7413
- expectedReadBackBytes += runtimeMapJsonByteLength(receipt.outputRef);
7414
- continue;
7447
+ bytes = receipt.outputRef.byteLength;
7448
+ } else if (measured !== undefined) {
7449
+ bytes = measured;
7450
+ } else if (receipt.output !== undefined && receipt.output !== null) {
7451
+ bytes = runtimeMapJsonByteLength(receipt.output);
7415
7452
  }
7416
- if (receipt.output === undefined || receipt.output === null) continue;
7417
- expectedReadBackBytes += runtimeMapJsonByteLength(receipt.output);
7453
+ expectedReadBackBytes += bytes;
7454
+ readBackBytesByKey.set(key, bytes);
7418
7455
  }
7419
7456
  const readBackMs = await this.withRuntimeReceiptHydrationTurn(
7420
7457
  async (turn) => {
7421
7458
  const readBackStartedAt = Date.now();
7422
- const latest = await this.getRuntimeStepReceipts(incompleteKeys);
7459
+ const latest = await this.getRuntimeStepReceipts(incompleteKeys, {
7460
+ expectedOutputBytes: readBackBytesByKey,
7461
+ });
7423
7462
  const readBackMs = Math.max(0, Date.now() - readBackStartedAt);
7424
7463
  // Hold the parsed values until they have been copied into the
7425
7464
  // caller's completion map. `runtimeStepReceiptPayloadBytes` measures
@@ -7488,8 +7527,12 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7488
7527
  }
7489
7528
  let latest: Map<string, RuntimeStepReceipt>;
7490
7529
  try {
7530
+ // Recovery decides from status and lease ownership only. A manifest
7531
+ // carries both; reading bodies here re-fetched every output just
7532
+ // written, at the moment the store was already failing.
7491
7533
  latest = await this.getRuntimeStepReceipts(
7492
7534
  receipts.map((receipt) => receipt.key),
7535
+ { hydrateOutput: false },
7493
7536
  );
7494
7537
  } catch {
7495
7538
  return;
@@ -20668,9 +20711,20 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
20668
20711
  0,
20669
20712
  )
20670
20713
  : undefined;
20714
+ const expectedOutputBytes = hasBoundedManifests
20715
+ ? new Map(
20716
+ terminalReceiptKeys.map((receiptKey) => [
20717
+ receiptKey,
20718
+ manifests.get(receiptKey)?.outputByteLength ?? 0,
20719
+ ]),
20720
+ )
20721
+ : undefined;
20671
20722
  return await this.withRuntimeReceiptHydrationTurn(
20672
20723
  async (turn) => {
20673
- const receipts = await this.getRuntimeStepReceipts(keysToHydrate);
20724
+ const receipts = await this.getRuntimeStepReceipts(
20725
+ keysToHydrate,
20726
+ expectedOutputBytes ? { expectedOutputBytes } : undefined,
20727
+ );
20674
20728
  // A fresh shared entry may name its canonical result receipt.
20675
20729
  // Read those in one batch before the turn is measured.
20676
20730
  const nowMs = Date.now();
@@ -250,6 +250,11 @@ export interface GetRuntimeStepReceiptInput {
250
250
  key: string;
251
251
  /** Read the bounded receipt manifest, not its output body. */
252
252
  hydrateOutput?: boolean;
253
+ /**
254
+ * In-process hint: the decoded output size a full read expects, usually from
255
+ * an earlier manifest. It sizes read batches only and never crosses the wire.
256
+ */
257
+ expectedOutputBytes?: number;
253
258
  }
254
259
 
255
260
  export interface ClaimRuntimeStepReceiptInput {
@@ -310,6 +315,11 @@ export interface GetRuntimeStepReceiptsInput {
310
315
  keys: string[];
311
316
  /** Read bounded manifests first; hydrate terminal outputs in a later turn. */
312
317
  hydrateOutput?: boolean;
318
+ /**
319
+ * In-process hint parallel to `keys`: each full read's expected decoded
320
+ * output size. It sizes read batches only and never crosses the wire.
321
+ */
322
+ expectedOutputBytes?: readonly (number | undefined)[];
313
323
  }
314
324
 
315
325
  export interface ClaimRuntimeStepReceiptsInput {
@@ -376,7 +376,12 @@ export function gatewayMachineConfig(input: {
376
376
  restart: machine.restart,
377
377
  stop_config: machine.stop_config,
378
378
  metrics: machine.metrics,
379
- services: machine.services,
379
+ services:
380
+ input.profile === 'production' &&
381
+ input.role === 'execution' &&
382
+ input.metadata[RUNTIME_GATEWAY_AUTOSCALED_METADATA_KEY] === '1'
383
+ ? machine.services.map((service) => ({ ...service, autostart: false }))
384
+ : machine.services,
380
385
  metadata: input.metadata,
381
386
  };
382
387
  }