deepline 0.3.502 → 0.3.504

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 (211) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +26 -0
  2. package/dist/bundling-sources/sdk/src/index.ts +1 -0
  3. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  4. package/dist/bundling-sources/sdk/src/types.ts +9 -0
  5. package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +35 -0
  6. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +1 -1
  7. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-public-aliases.ts +13 -0
  8. package/dist/bundling-sources/shared_libs/monitors/starter-templates.ts +0 -8
  9. package/dist/bundling-sources/shared_libs/observability/dlq.ts +174 -0
  10. package/dist/bundling-sources/shared_libs/observability/queue-health.ts +9 -0
  11. package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
  12. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/activity-observation.ts +20 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +62 -2
  15. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +667 -62
  16. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +55 -0
  17. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +20 -2
  18. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +46 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-invocation-fence.ts +80 -4
  20. package/dist/bundling-sources/shared_libs/play-runtime/fixture-egress-fetch.ts +95 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +292 -45
  22. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +15 -0
  23. package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +3 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/play-http-request.ts +7 -3
  25. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-semantics.ts +31 -1
  26. package/dist/bundling-sources/shared_libs/play-runtime/post-code-recovery-policy.ts +231 -0
  27. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +4 -0
  28. package/dist/bundling-sources/shared_libs/play-runtime/run-ending-event.ts +55 -0
  29. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +126 -0
  30. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +38 -1
  31. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +2 -9
  32. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +51 -19
  33. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/local-process.ts +9 -4
  34. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +2 -0
  35. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +2 -0
  36. package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +12 -1
  37. package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +3 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/runtime-incident-drills.ts +42 -0
  39. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +7 -0
  40. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +26 -1
  41. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +13 -0
  42. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-deadline-reconciliation.ts +53 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +631 -19
  44. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/durable-run-inventory.ts +719 -0
  45. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/durable-run-sql.ts +206 -0
  46. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/latest-cache-result.ts +83 -0
  47. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +1432 -157
  48. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +61 -0
  49. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +29 -8
  50. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-queue-health.ts +27 -2
  51. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +45 -0
  52. package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +18 -0
  53. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +129 -14
  54. package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +2 -0
  55. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +10 -1
  56. package/dist/cli/{auth-EFHLOVG4.mjs → auth-3L5AA5AX.mjs} +5 -5
  57. package/dist/cli/auth-UPK4IIIN.js +43 -0
  58. package/dist/cli/{billing-Q5XKEYPP.mjs → billing-E7EASVPO.mjs} +19 -12
  59. package/dist/cli/{billing-SKT2VE34.js → billing-HOGXVE2V.js} +92 -85
  60. package/dist/cli/{chunk-L5CTJY74.mjs → chunk-22OCKCYS.mjs} +2 -2
  61. package/dist/cli/{chunk-YWOQYYYS.mjs → chunk-2ABRDH3B.mjs} +2 -2
  62. package/dist/cli/{chunk-IL666WJE.js → chunk-2W77YCKH.js} +5 -5
  63. package/dist/cli/{chunk-2MVIS2UI.mjs → chunk-3MLFFWDM.mjs} +2 -2
  64. package/dist/cli/{chunk-HMZF2CSP.mjs → chunk-4CC67XH5.mjs} +2 -2
  65. package/dist/cli/{chunk-NXVYLX3F.mjs → chunk-5CHBIJIM.mjs} +10 -6
  66. package/dist/cli/chunk-5LUF4LAR.mjs +209 -0
  67. package/dist/cli/{chunk-JL6H4H3G.js → chunk-5Z6EULD5.js} +6 -6
  68. package/dist/cli/{chunk-32YQBJON.js → chunk-67OI26OE.js} +7 -7
  69. package/dist/cli/{chunk-LA3UYRVZ.js → chunk-6JNBMTCZ.js} +1 -1
  70. package/dist/cli/{chunk-DYHTXGLX.js → chunk-6SMR7LU7.js} +2 -2
  71. package/dist/cli/{chunk-OFBLT2LQ.mjs → chunk-7F4OEHQK.mjs} +1 -1
  72. package/dist/cli/{chunk-DRBD4IYQ.mjs → chunk-7MJYZ33I.mjs} +2 -6
  73. package/dist/cli/{chunk-UOANF3DR.js → chunk-7P2QVMBP.js} +26 -7
  74. package/dist/cli/{chunk-GINKIZ7S.js → chunk-A6LA42JY.js} +16 -16
  75. package/dist/cli/{chunk-FVM4PS5Q.js → chunk-BN5VKY4X.js} +25 -12
  76. package/dist/cli/{chunk-Z2H7OQ6E.mjs → chunk-BTWUNKKX.mjs} +2 -2
  77. package/dist/cli/{chunk-R5F7JXT4.mjs → chunk-BX45XMXZ.mjs} +2 -2
  78. package/dist/cli/{chunk-NKLM4J4X.mjs → chunk-DEAJVQEG.mjs} +1 -1
  79. package/dist/cli/{chunk-JFBJLNBI.js → chunk-FISP4LCK.js} +53 -53
  80. package/dist/cli/{chunk-OEUMXKR5.js → chunk-FTRVCIGC.js} +26 -26
  81. package/dist/cli/{chunk-YL2CCF6T.mjs → chunk-GGBXNQCR.mjs} +4 -4
  82. package/dist/cli/{chunk-YPTZJ7LO.js → chunk-GJ2DA35C.js} +100 -17
  83. package/dist/cli/{chunk-2S2F6YSI.js → chunk-GRAGUYIE.js} +41 -41
  84. package/dist/cli/{chunk-2JS3H6H6.mjs → chunk-HUX5DZO6.mjs} +3 -3
  85. package/dist/cli/{chunk-4CCMD7QM.mjs → chunk-IGNQKOWT.mjs} +32 -15
  86. package/dist/cli/{chunk-WKFAX2K7.js → chunk-IPAMOMGP.js} +21 -21
  87. package/dist/cli/{chunk-SAW3FBCA.mjs → chunk-ITJ7NB2D.mjs} +6 -0
  88. package/dist/cli/{chunk-Q3NM6ZL3.js → chunk-JPR2546F.js} +23 -21
  89. package/dist/cli/{chunk-X5MGQ7UT.js → chunk-KCKAFTPY.js} +10 -10
  90. package/dist/cli/{chunk-TAK3MVXY.js → chunk-KGUGNEKL.js} +284 -267
  91. package/dist/cli/{chunk-OVZOMSH2.js → chunk-LHXYCZYO.js} +8 -8
  92. package/dist/cli/{chunk-QOJBRCAS.js → chunk-MJTK6Q3G.js} +3 -3
  93. package/dist/cli/{chunk-MYUISF3P.mjs → chunk-MLMWM5DV.mjs} +5 -5
  94. package/dist/cli/{chunk-JO5FFSR7.js → chunk-NTLBZUHD.js} +6 -0
  95. package/dist/cli/{chunk-MP5QY4A2.mjs → chunk-NZ7Z7WNM.mjs} +2 -2
  96. package/dist/cli/{chunk-HIVRCTDR.mjs → chunk-OX2D6BG4.mjs} +20 -1
  97. package/dist/cli/{chunk-YDXEXVBV.js → chunk-QKKU2FH4.js} +7 -7
  98. package/dist/cli/{chunk-3KEZVGGV.mjs → chunk-QOLX2O2S.mjs} +4 -4
  99. package/dist/cli/{chunk-JFUXUSKB.mjs → chunk-R2VZVHJP.mjs} +15 -2
  100. package/dist/cli/chunk-R7J7CJPZ.js +209 -0
  101. package/dist/cli/{chunk-XMKUJ44Z.js → chunk-SMSQVRHE.js} +5 -5
  102. package/dist/cli/{chunk-54QXWK3C.mjs → chunk-SVFTZTCI.mjs} +1 -1
  103. package/dist/cli/{chunk-FWDAEWCD.js → chunk-TMQUMILM.js} +19 -23
  104. package/dist/cli/{chunk-TFFJ2PRN.mjs → chunk-UFYJTRSF.mjs} +98 -15
  105. package/dist/cli/{chunk-EUWRKWT4.js → chunk-UJMBG5JU.js} +5 -4
  106. package/dist/cli/{chunk-DKAMCJIT.js → chunk-USTJEEND.js} +17 -13
  107. package/dist/cli/{chunk-AJL2Q6IQ.js → chunk-UXQQPMYO.js} +2 -2
  108. package/dist/cli/{chunk-7ZYSXSJJ.mjs → chunk-VJVJWZ6I.mjs} +5 -5
  109. package/dist/cli/{chunk-JLYDLK6X.js → chunk-WBIDPDKJ.js} +3 -3
  110. package/dist/cli/{chunk-QNELA7SX.js → chunk-WZSFIJMG.js} +53 -53
  111. package/dist/cli/{chunk-NZXB27TP.mjs → chunk-XHZSPMNC.mjs} +4 -4
  112. package/dist/cli/{chunk-W5CHE5Q2.mjs → chunk-Y6XKCEPK.mjs} +1 -1
  113. package/dist/cli/{chunk-4WTC5SSN.mjs → chunk-Y7VEHKID.mjs} +10 -8
  114. package/dist/cli/{chunk-3MJSWVQ2.mjs → chunk-YOQ2NNDO.mjs} +2 -1
  115. package/dist/cli/{chunk-ZNB6GR3P.mjs → chunk-Z6FXUDIL.mjs} +1 -1
  116. package/dist/cli/command-docs.d.mts +2 -1
  117. package/dist/cli/command-docs.d.ts +2 -1
  118. package/dist/cli/command-docs.js +6 -2
  119. package/dist/cli/command-docs.mjs +5 -1
  120. package/dist/cli/{csv-OXGSCV75.js → csv-2XWGPITO.js} +13 -13
  121. package/dist/cli/{csv-6AEPKKCO.mjs → csv-433JEHLQ.mjs} +4 -4
  122. package/dist/cli/{db-K3KRK4CZ.mjs → db-K747DH43.mjs} +6 -6
  123. package/dist/cli/{db-6NVHDUZY.js → db-PJJMD4VH.js} +27 -27
  124. package/dist/cli/describe-OYS7LZJD.js +49 -0
  125. package/dist/cli/{describe-P3ZJS7TQ.mjs → describe-VEDDYW4P.mjs} +20 -20
  126. package/dist/cli/describe-core.d.mts +8 -4
  127. package/dist/cli/describe-core.d.ts +8 -4
  128. package/dist/cli/describe-core.js +4 -4
  129. package/dist/cli/describe-core.mjs +3 -3
  130. package/dist/cli/{executions-2C2FFG52.js → executions-HM5T72H6.js} +8 -8
  131. package/dist/cli/{executions-I7XW6WWK.mjs → executions-JWRX3XCT.mjs} +6 -6
  132. package/dist/cli/{feedback-47B57A5Y.js → feedback-34UG4BO3.js} +8 -8
  133. package/dist/cli/{feedback-RSTNBJAI.mjs → feedback-MNSIA63Y.mjs} +4 -4
  134. package/dist/cli/git-5YQJSJFR.js +25 -0
  135. package/dist/cli/{git-3G5AFKBT.mjs → git-ZKEOXV3A.mjs} +5 -5
  136. package/dist/cli/index.js +144 -142
  137. package/dist/cli/index.mjs +44 -42
  138. package/dist/cli/{legacy-noops-NQ262TKL.mjs → legacy-noops-5M4T4ZVT.mjs} +5 -5
  139. package/dist/cli/{legacy-noops-P665PBG4.js → legacy-noops-YXSI4FVU.js} +8 -8
  140. package/dist/cli/{monitors-KUPZODZS.mjs → monitors-C65OC4AW.mjs} +7 -7
  141. package/dist/cli/{monitors-IPWAD7LS.js → monitors-O25GDOYE.js} +95 -95
  142. package/dist/cli/{org-WFC3N672.js → org-2GSPLY2A.js} +72 -72
  143. package/dist/cli/{org-ZCQGEM3L.mjs → org-ZRMG5NS2.mjs} +6 -6
  144. package/dist/cli/{pages-N5BNC67L.js → pages-45DPADK6.js} +18 -18
  145. package/dist/cli/{pages-VE66IU7B.mjs → pages-TZZUFBRO.mjs} +6 -6
  146. package/dist/cli/{play-EIMDIAJB.mjs → play-3D7HH273.mjs} +138 -226
  147. package/dist/cli/{play-NKIRJSKX.js → play-RCGMND6X.js} +454 -542
  148. package/dist/cli/{providers-XU3AGY2F.js → providers-3N3ECMTY.js} +9 -9
  149. package/dist/cli/{providers-KDTJ63ED.mjs → providers-PSAKV6CJ.mjs} +6 -6
  150. package/dist/cli/{quickstart-TXFXUODF.mjs → quickstart-2A35SMGC.mjs} +4 -4
  151. package/dist/cli/{quickstart-OSCHOSXU.js → quickstart-6R6AIXM6.js} +6 -6
  152. package/dist/cli/{run-ODGML35U.mjs → run-F3TLDGUO.mjs} +25 -25
  153. package/dist/cli/{run-ET2KVTPK.js → run-F6ZXTASZ.js} +44 -44
  154. package/dist/cli/{search-DK67K6PR.mjs → search-CZLCY3D2.mjs} +7 -7
  155. package/dist/cli/search-R5VEWJO2.js +32 -0
  156. package/dist/cli/{search-output-6SOKQTCW.mjs → search-output-MQTSTLN5.mjs} +5 -5
  157. package/dist/cli/{search-output-KXP4FA62.js → search-output-R5XDNILW.js} +7 -7
  158. package/dist/cli/{secrets-C6SYTMU7.mjs → secrets-D3GF4B2Z.mjs} +6 -6
  159. package/dist/cli/{secrets-WPS6NMNK.js → secrets-DCJYHDSY.js} +15 -15
  160. package/dist/cli/{sessions-PXVOH34X.mjs → sessions-QGEQ2UYZ.mjs} +5 -5
  161. package/dist/cli/{sessions-IP562J5Z.js → sessions-Z4JYJSDP.js} +6 -6
  162. package/dist/cli/{settings-FBUQGYVJ.mjs → settings-G7QEXA4N.mjs} +11 -11
  163. package/dist/cli/{settings-SUDUIVMY.js → settings-UVXXAT4A.js} +78 -78
  164. package/dist/cli/{setup-I5H6IOEY.js → setup-5I42W7D4.js} +49 -49
  165. package/dist/cli/{setup-JSIMTR73.mjs → setup-QHJU3DUI.mjs} +9 -9
  166. package/dist/cli/{skills-FJQ3LX6N.mjs → skills-5LRF4UKX.mjs} +7 -7
  167. package/dist/cli/skills-FB6TV52O.js +36 -0
  168. package/dist/cli/tools-L2364RPA.js +56 -0
  169. package/dist/cli/{tools-IGBK4BVE.mjs → tools-PUT6STVG.mjs} +18 -18
  170. package/dist/cli/{update-7MTT6F5K.mjs → update-CJ2GA64X.mjs} +9 -9
  171. package/dist/cli/update-ESYJGYVZ.js +34 -0
  172. package/dist/cli/{workflow-PM2J2OU3.mjs → workflow-HVEWRTXD.mjs} +7 -7
  173. package/dist/cli/{workflow-UX3ZX6BQ.js → workflow-O67MEBCP.js} +17 -17
  174. package/dist/{client-Bn8FwKGO.d.ts → client-CIwenMFS.d.ts} +1 -1
  175. package/dist/{client-CfNRmjLK.d.mts → client-DYAfJpaN.d.mts} +1 -1
  176. package/dist/{client-core-B91EV0WS.d.ts → client-core-CRjtyMAI.d.ts} +25 -2
  177. package/dist/{client-core-BG8Cgrmk.d.mts → client-core-DlzP8vEs.d.mts} +25 -2
  178. package/dist/{compiler-manifest-DlXDyndN.d.mts → compiler-manifest-DaJrA2KV.d.mts} +1 -1
  179. package/dist/{compiler-manifest-DlXDyndN.d.ts → compiler-manifest-DaJrA2KV.d.ts} +1 -1
  180. package/dist/{errors-BtriA2ld.d.mts → errors-BKnSYueU.d.mts} +1 -1
  181. package/dist/{errors-DmcLykM7.d.ts → errors-KLga4bLr.d.ts} +1 -1
  182. package/dist/{index-DI0sR_fX.d.mts → index-C-8AFpWy.d.mts} +1 -1
  183. package/dist/{index--Jw-slHY.d.ts → index-C5nAZ-VS.d.ts} +1 -1
  184. package/dist/index.d.mts +7 -7
  185. package/dist/index.d.ts +7 -7
  186. package/dist/index.js +9 -9
  187. package/dist/index.mjs +6 -6
  188. package/dist/install-integrity.json +125 -116
  189. package/dist/plays/bundle-play-file.d.mts +3 -3
  190. package/dist/plays/bundle-play-file.d.ts +3 -3
  191. package/dist/plays/bundle-play-file.mjs +12 -5
  192. package/dist/plays/play-description.d.mts +2 -2
  193. package/dist/plays/play-description.d.ts +2 -2
  194. package/dist/plays/run-request.d.mts +2 -2
  195. package/dist/plays/run-request.d.ts +2 -2
  196. package/dist/release.d.mts +1 -1
  197. package/dist/release.d.ts +1 -1
  198. package/dist/release.js +2 -2
  199. package/dist/release.mjs +1 -1
  200. package/dist/server.d.mts +4 -4
  201. package/dist/server.d.ts +4 -4
  202. package/dist/server.js +5 -5
  203. package/dist/server.mjs +3 -3
  204. package/package.json +1 -1
  205. package/dist/cli/auth-VM3IKP5F.js +0 -43
  206. package/dist/cli/describe-JOUAXXPE.js +0 -49
  207. package/dist/cli/git-OPKIC6JQ.js +0 -25
  208. package/dist/cli/search-6U54Y3OK.js +0 -32
  209. package/dist/cli/skills-VHININXC.js +0 -36
  210. package/dist/cli/tools-XMBMHVKF.js +0 -56
  211. package/dist/cli/update-H7JVW43I.js +0 -34
@@ -1,10 +1,14 @@
1
1
  import { sha256Hex, stableStringify } from '../plays/row-identity';
2
2
  import type { CallFreshnessMetadata } from '../plays/tool-result-types';
3
- import type { RuntimeStepReceipt } from './ctx-types';
3
+ import type {
4
+ PublishLatestCacheResultInput,
5
+ RuntimeStepReceipt,
6
+ } from './ctx-types';
4
7
  import {
5
8
  COMPLETED_RECEIPT_CACHE_INSERT_LEASE_ID,
6
9
  type DurableReceiptExecutionStore,
7
10
  } from './durable-receipt-execution';
11
+ import { DURABLE_RUNS_ROLLOUT } from './durable-runs-rollout';
8
12
  import { assertNoSecretTaint } from './secret-capability';
9
13
  import {
10
14
  deserializeToolExecuteResult,
@@ -14,7 +18,7 @@ import {
14
18
  serializeToolExecuteResult,
15
19
  } from './tool-result';
16
20
 
17
- type CompletedCall = {
21
+ export type CompletedCall = {
18
22
  completedAt: number;
19
23
  value?: unknown;
20
24
  /** Reuse a result already stored by its canonical receipt without copying it. */
@@ -25,7 +29,145 @@ type CompletedCall = {
25
29
  type FreshnessStore = Pick<
26
30
  DurableReceiptExecutionStore,
27
31
  'enabled' | 'get' | 'complete'
28
- >;
32
+ > &
33
+ Partial<
34
+ Pick<DurableReceiptExecutionStore, 'getMany' | 'publishLatestCacheResult'>
35
+ >;
36
+
37
+ /** Shape tag of a newest shared result entry (`ctx:{org}:cache:v1:*`). */
38
+ export const LATEST_CACHE_RESULT_KIND = 'latest_cache_result' as const;
39
+
40
+ /**
41
+ * The request's newest shared result entry. Every Play and edition that
42
+ * computes the same semantic key reads and publishes the same entry.
43
+ */
44
+ export function latestCacheResultKey(
45
+ orgId: string,
46
+ semanticKey: string,
47
+ ): string {
48
+ return `ctx:${orgId}:cache:v1:${sha256Hex(semanticKey)}`;
49
+ }
50
+
51
+ /**
52
+ * Semantic identity of a tool read: org, request, credential identity and
53
+ * action version. Edition-11 freshness and older-edition shared reads both
54
+ * use this exact function so their shared entries are the same key.
55
+ */
56
+ export function toolReadSemanticKey(input: {
57
+ orgId: string | null | undefined;
58
+ toolId: string;
59
+ input: Record<string, unknown>;
60
+ authScope: string | null;
61
+ actionVersion: string;
62
+ }): string {
63
+ return stableStringify({
64
+ kind: 'tool',
65
+ orgId: input.orgId,
66
+ toolId: input.toolId,
67
+ input: input.input,
68
+ authScope: input.authScope,
69
+ actionVersion: input.actionVersion,
70
+ });
71
+ }
72
+
73
+ /**
74
+ * Read a `ctx:{org}:cache:v1:*` entry. The receiver stamped `recordedAtMs`.
75
+ * Unknown fields are ignored and an unknown `kind` is a miss, so a newer
76
+ * writer can never break this reader.
77
+ */
78
+ export function parseLatestCacheResult(
79
+ receipt: RuntimeStepReceipt | null,
80
+ ): CompletedCall | null {
81
+ if (!receipt || !['completed', 'skipped'].includes(receipt.status)) {
82
+ return null;
83
+ }
84
+ const output = receipt.output;
85
+ if (!output || typeof output !== 'object' || Array.isArray(output)) {
86
+ return null;
87
+ }
88
+ const entry = output as Record<string, unknown>;
89
+ if (entry.kind !== LATEST_CACHE_RESULT_KIND) return null;
90
+ const recordedAtMs = entry.recordedAtMs;
91
+ const hasInlineValue = 'value' in entry;
92
+ const valueReceiptKey =
93
+ typeof entry.valueReceiptKey === 'string'
94
+ ? entry.valueReceiptKey.trim()
95
+ : '';
96
+ const undefinedValue = entry.undefinedValue === true;
97
+ if (
98
+ typeof recordedAtMs !== 'number' ||
99
+ !Number.isSafeInteger(recordedAtMs) ||
100
+ recordedAtMs < 0 ||
101
+ hasInlineValue === Boolean(valueReceiptKey) ||
102
+ (undefinedValue && entry.value !== null)
103
+ ) {
104
+ throw new Error('Invalid shared latest cache result.');
105
+ }
106
+ return {
107
+ completedAt: recordedAtMs,
108
+ ...(undefinedValue
109
+ ? { value: null, undefinedValue: true as const }
110
+ : valueReceiptKey
111
+ ? { valueReceiptKey }
112
+ : { value: entry.value }),
113
+ };
114
+ }
115
+
116
+ /**
117
+ * The stored form of a completed call. A relay-published tool result is
118
+ * referenced by its canonical result receipt instead of copied.
119
+ */
120
+ export function completedCallForResult(
121
+ value: unknown,
122
+ completedAt: number,
123
+ /** The receipt that stored this exact result, when the caller knows it. */
124
+ storedResultReceiptKey?: string,
125
+ ): CompletedCall {
126
+ const relayReference = isToolExecuteResult(value)
127
+ ? relayPublishedToolResultReference(value)
128
+ : null;
129
+ const resultReceiptKey =
130
+ isToolExecuteResult(value) && relayReference
131
+ ? storedResultReceiptKey?.trim() ||
132
+ value._metadata.execution.resultReceiptKey?.trim() ||
133
+ value._metadata.execution.receiptKey?.trim() ||
134
+ ''
135
+ : '';
136
+ if (relayReference && !resultReceiptKey) {
137
+ throw new Error(
138
+ 'Referenced freshness result has no canonical result receipt identity.',
139
+ );
140
+ }
141
+ return {
142
+ completedAt,
143
+ ...(value === undefined
144
+ ? { value: null, undefinedValue: true as const }
145
+ : resultReceiptKey
146
+ ? { valueReceiptKey: resultReceiptKey }
147
+ : {
148
+ value: isToolExecuteResult(value)
149
+ ? serializeToolExecuteResult(value)
150
+ : value,
151
+ }),
152
+ };
153
+ }
154
+
155
+ /** The `publish_latest_cache_result` output; the receiver stamps the time. */
156
+ export function latestCacheResultOutput(
157
+ call: CompletedCall,
158
+ ): PublishLatestCacheResultInput['output'] {
159
+ const { completedAt: _completedAt, ...result } = call;
160
+ return { kind: LATEST_CACHE_RESULT_KIND, ...result };
161
+ }
162
+
163
+ /** Errors throw; null, undefined and declared-empty results are not shared. */
164
+ function sharesLatestResult<T>(
165
+ value: T,
166
+ sharesResult: ((value: T) => boolean) | undefined,
167
+ ): boolean {
168
+ if (value === undefined || value === null) return false;
169
+ return sharesResult ? sharesResult(value) : true;
170
+ }
29
171
 
30
172
  function completedCall(
31
173
  receipt: RuntimeStepReceipt | null,
@@ -59,8 +201,10 @@ function completedCall(
59
201
 
60
202
  /**
61
203
  * Operation recovery is run-local. Reusable results are a separate completed
62
- * cache. Adjacent partitions bound lookup, while admission checks actual age.
63
- * A concurrent miss executes independently and publishes its own operation.
204
+ * cache: the request's newest shared result (any policy may reuse it while it
205
+ * is young enough), then this policy's adjacent partitions. Admission checks
206
+ * actual age. A concurrent miss executes independently and publishes its own
207
+ * operation.
64
208
  */
65
209
  export async function executeWithFreshnessReceipt<T>(input: {
66
210
  semanticKey: string;
@@ -72,11 +216,26 @@ export async function executeWithFreshnessReceipt<T>(input: {
72
216
  store: FreshnessStore;
73
217
  execute: () => Promise<T>;
74
218
  completedAt?: (value: T) => number | undefined;
219
+ /**
220
+ * False keeps an empty or unsuccessful result out of the shared latest
221
+ * cache. Run history and bucket reuse are unchanged.
222
+ */
223
+ sharesResult?: (value: T) => boolean;
224
+ /**
225
+ * An operator refresh (`--refresh-cache`) of a read whose authored policy
226
+ * reuses results. Its effective policy is 0, so it reuses nothing, but its
227
+ * live result still becomes the request's newest shared result. Callers
228
+ * set it only for reusable-capable reads; writes, live observations and
229
+ * an authored 0 never publish.
230
+ */
231
+ publishLatestOnRefresh?: true;
75
232
  onOutcome: (value: T, metadata: CallFreshnessMetadata) => T;
76
233
  withHydration: <Result>(
77
234
  read: (
78
- measure?: (receipt: RuntimeStepReceipt | null) => void,
235
+ measure?: (receipts: readonly (RuntimeStepReceipt | null)[]) => void,
79
236
  ) => Promise<Result>,
237
+ /** Manifest byte price of the bodies this turn is about to read. */
238
+ options?: { expectedBytes?: number; receiptKeys?: number },
80
239
  ) => Promise<Result>;
81
240
  now?: () => number;
82
241
  }): Promise<T> {
@@ -85,21 +244,93 @@ export async function executeWithFreshnessReceipt<T>(input: {
85
244
  'Durable operation recovery is unavailable in this runtime.',
86
245
  );
87
246
  }
247
+ if (
248
+ input.publishLatestOnRefresh &&
249
+ (input.effectiveStaleAfterSeconds !== 0 ||
250
+ input.requestedStaleAfterSeconds === 0)
251
+ ) {
252
+ throw new Error(
253
+ 'Only a refreshed read whose authored policy reuses results publishes on refresh.',
254
+ );
255
+ }
88
256
  const now = input.now ?? Date.now;
89
- const cachePrefix = `ctx:${input.orgId}:freshness:${sha256Hex(input.semanticKey)}`;
257
+ const semanticHash = sha256Hex(input.semanticKey);
258
+ const cachePrefix = `ctx:${input.orgId}:freshness:${semanticHash}`;
259
+ const latestCacheKey = latestCacheResultKey(input.orgId, input.semanticKey);
90
260
  const operationKey = `ctx:${input.orgId}:freshness:operation:${sha256Hex(
91
261
  stableStringify({ runId: input.runId, invocationId: input.invocationId }),
92
262
  )}`;
93
263
  const read = (key: string) =>
94
264
  input.withHydration(async (measure) => {
95
265
  const receipt = await input.store.get(key);
96
- measure?.(receipt);
266
+ measure?.([receipt]);
97
267
  return completedCall(receipt);
98
268
  });
269
+ const readMany = (keys: readonly string[], expectedBytes?: number) =>
270
+ input.withHydration(
271
+ async (measure) => {
272
+ const getMany = input.store.getMany;
273
+ const receipts = getMany
274
+ ? await getMany([...keys]).then((byKey) =>
275
+ keys.map((key) => byKey.get(key) ?? null),
276
+ )
277
+ : await Promise.all(keys.map((key) => input.store.get(key)));
278
+ measure?.(receipts);
279
+ return receipts;
280
+ },
281
+ {
282
+ receiptKeys: keys.length,
283
+ ...(expectedBytes !== undefined ? { expectedBytes } : {}),
284
+ },
285
+ );
286
+ /**
287
+ * Reusable candidates in priority order. Their manifests come first: a
288
+ * miss or a losing priority never transfers a body. Age lives inside the
289
+ * body (`completedAt`, `recordedAtMs`), so every terminal candidate is then
290
+ * hydrated together in one more read. Hydrating only the first one would
291
+ * need a further read whenever it is too old, which main never pays.
292
+ */
293
+ const readCandidates = async (
294
+ keys: readonly string[],
295
+ manifests: readonly (RuntimeStepReceipt | null)[] | null,
296
+ ): Promise<(RuntimeStepReceipt | null)[]> => {
297
+ if (keys.length === 0) return [];
298
+ // A store without batch reads has no manifest presentation.
299
+ if (!manifests) return readMany(keys);
300
+ const terminal = (receipt: RuntimeStepReceipt | null) =>
301
+ receipt !== null && ['completed', 'skipped'].includes(receipt.status);
302
+ const bodiless = keys.filter(
303
+ (_key, index) =>
304
+ terminal(manifests[index]!) && manifests[index]!.output === undefined,
305
+ );
306
+ if (bodiless.length === 0) {
307
+ // A store that ignores `hydrateOutput: false` (an older gateway or a
308
+ // batch shared with a full read) already returned the bodies. Price
309
+ // them; never read them again.
310
+ const withBodies = manifests.filter(
311
+ (receipt) => terminal(receipt) && receipt!.output !== undefined,
312
+ );
313
+ if (withBodies.length > 0) {
314
+ await input.withHydration(async (measure) => {
315
+ measure?.(withBodies);
316
+ });
317
+ }
318
+ return [...manifests];
319
+ }
320
+ const expectedBytes = bodiless.reduce((total, key) => {
321
+ const bytes = manifests[keys.indexOf(key)]?.outputByteLength;
322
+ return total + (Number.isSafeInteger(bytes) ? bytes! : 0);
323
+ }, 0);
324
+ const hydrated = await readMany(bodiless, expectedBytes);
325
+ return keys.map((key, index) => {
326
+ const at = bodiless.indexOf(key);
327
+ return at === -1 ? manifests[index]! : (hydrated[at] ?? null);
328
+ });
329
+ };
99
330
  const readReferencedResult = (key: string) =>
100
331
  input.withHydration(async (measure) => {
101
332
  const receipt = await input.store.get(key);
102
- measure?.(receipt);
333
+ measure?.([receipt]);
103
334
  if (
104
335
  !receipt ||
105
336
  !['completed', 'skipped'].includes(receipt.status) ||
@@ -165,9 +396,6 @@ export async function executeWithFreshnessReceipt<T>(input: {
165
396
  return stored;
166
397
  };
167
398
 
168
- const recovered = await read(operationKey);
169
- if (recovered) return outcome(recovered, 'operation_recovery');
170
-
171
399
  const ttl = input.effectiveStaleAfterSeconds;
172
400
  const admissionTime = now();
173
401
  const currentPartition =
@@ -176,17 +404,46 @@ export async function executeWithFreshnessReceipt<T>(input: {
176
404
  ttl === null
177
405
  ? `${cachePrefix}:reusable:indefinite`
178
406
  : `${cachePrefix}:reusable:${ttl}:${currentPartition}`;
179
-
180
- if (ttl !== 0) {
181
- const candidates =
182
- ttl === null
183
- ? [reusableKey]
407
+ // The request's newest shared result first, then this policy's buckets.
408
+ const candidateKeys =
409
+ ttl === 0
410
+ ? []
411
+ : ttl === null
412
+ ? [latestCacheKey, reusableKey]
184
413
  : [
414
+ latestCacheKey,
185
415
  reusableKey,
186
416
  `${cachePrefix}:reusable:${ttl}:${currentPartition! - 1}`,
187
417
  ];
188
- for (const key of candidates) {
189
- const cached = await read(key);
418
+
419
+ // One stage: this run's own operation (with its body, so recovery needs no
420
+ // second read) beside the candidates' manifests. Own-run recovery still
421
+ // wins whenever it exists.
422
+ const [operation, candidateManifests] = await Promise.allSettled([
423
+ read(operationKey),
424
+ candidateKeys.length > 0 && input.store.getMany
425
+ ? input.store
426
+ .getMany([...candidateKeys], { hydrateOutput: false })
427
+ .then((byKey) => candidateKeys.map((key) => byKey.get(key) ?? null))
428
+ : Promise.resolve(null),
429
+ ]);
430
+ if (operation.status === 'rejected') throw operation.reason;
431
+ if (operation.value) return outcome(operation.value, 'operation_recovery');
432
+ if (candidateManifests.status === 'rejected') {
433
+ throw candidateManifests.reason;
434
+ }
435
+
436
+ if (ttl !== 0) {
437
+ const [latest, ...buckets] = await readCandidates(
438
+ candidateKeys,
439
+ candidateManifests.value,
440
+ );
441
+ const reusable = [
442
+ () => parseLatestCacheResult(latest ?? null),
443
+ ...buckets.map((receipt) => () => completedCall(receipt ?? null)),
444
+ ];
445
+ for (const parse of reusable) {
446
+ const cached = parse();
190
447
  if (!cached) continue;
191
448
  const age = now() - cached.completedAt;
192
449
  if (age < 0 || (ttl !== null && age >= ttl * 1000)) continue;
@@ -201,32 +458,7 @@ export async function executeWithFreshnessReceipt<T>(input: {
201
458
  if (!Number.isSafeInteger(completedAt) || completedAt < 0) {
202
459
  throw new Error('Freshness call returned an invalid completion time.');
203
460
  }
204
- const relayReference = isToolExecuteResult(value)
205
- ? relayPublishedToolResultReference(value)
206
- : null;
207
- const resultReceiptKey =
208
- isToolExecuteResult(value) && relayReference
209
- ? value._metadata.execution.resultReceiptKey?.trim() ||
210
- value._metadata.execution.receiptKey?.trim() ||
211
- ''
212
- : '';
213
- if (relayReference && !resultReceiptKey) {
214
- throw new Error(
215
- 'Referenced freshness result has no canonical result receipt identity.',
216
- );
217
- }
218
- const completed: CompletedCall = {
219
- completedAt,
220
- ...(value === undefined
221
- ? { value: null, undefinedValue: true as const }
222
- : resultReceiptKey
223
- ? { valueReceiptKey: resultReceiptKey }
224
- : {
225
- value: isToolExecuteResult(value)
226
- ? serializeToolExecuteResult(value)
227
- : value,
228
- }),
229
- };
461
+ const completed = completedCallForResult(value, completedAt);
230
462
 
231
463
  // Recover this exact operation even if reusable publication fails afterwards.
232
464
  await publish(operationKey, completed);
@@ -241,6 +473,21 @@ export async function executeWithFreshnessReceipt<T>(input: {
241
473
  : `${cachePrefix}:reusable:${ttl}:${completionPartition}`;
242
474
  await publish(resultKey, completed);
243
475
  }
476
+ // A refresh publishes only the newest shared result, not a policy bucket.
477
+ if (
478
+ (ttl !== 0 || input.publishLatestOnRefresh === true) &&
479
+ DURABLE_RUNS_ROLLOUT.sharedReadCacheWrites &&
480
+ input.store.publishLatestCacheResult &&
481
+ sharesLatestResult(value, input.sharesResult)
482
+ ) {
483
+ // The receiver stamps the time and keeps only the newer entry. An
484
+ // older receiver reports `unavailable`; either outcome is final.
485
+ await input.store.publishLatestCacheResult({
486
+ key: latestCacheKey,
487
+ runId: input.runId,
488
+ output: latestCacheResultOutput(completed),
489
+ });
490
+ }
244
491
  // Each overlapping miss owns its live result even if the immutable receipt
245
492
  // insert loses to a sibling. The stored winner is for later recovery.
246
493
  return outcome(completed, 'executed', { value });
@@ -343,6 +343,11 @@ export type WorkflowRunExecutionTokenClaims =
343
343
  scheduler_schema?: string;
344
344
  /** Scheduler generation that owns durable writes for this execution leg. */
345
345
  run_attempt?: number;
346
+ /**
347
+ * `runs resume` epoch this execution leg belongs to; absent means the
348
+ * run's first epoch. Minted from the leased launch, never the runner.
349
+ */
350
+ resume_epoch?: number;
346
351
  /** Opaque scheduler lease nonce bound to this exact execution leg. */
347
352
  run_lease_token?: string;
348
353
  /**
@@ -676,6 +681,10 @@ function isValidWorkflowClaimsShape(
676
681
  (claims.run_lease_token === undefined ||
677
682
  (typeof claims.run_lease_token === 'string' &&
678
683
  claims.run_lease_token.length > 0)) &&
684
+ (claims.resume_epoch === undefined ||
685
+ (typeof claims.resume_epoch === 'number' &&
686
+ Number.isSafeInteger(claims.resume_epoch) &&
687
+ claims.resume_epoch > 0)) &&
679
688
  (claims.terminal_contract === undefined ||
680
689
  typeof claims.terminal_contract === 'string') &&
681
690
  (claims.runtime_origin === undefined ||
@@ -784,6 +793,7 @@ export async function mintWorkflowRunExecutionToken(input: {
784
793
  actorEmail?: string | null;
785
794
  schedulerSchema?: string | null;
786
795
  runAttempt?: number | null;
796
+ resumeEpoch?: number | null;
787
797
  runLeaseToken?: string | null;
788
798
  terminalContract?: DirectCompletedTerminalContract | null;
789
799
  capabilities?: readonly RuntimeExecutionCapability[];
@@ -876,6 +886,11 @@ export async function mintWorkflowRunExecutionToken(input: {
876
886
  input.runAttempt >= 0
877
887
  ? { run_attempt: input.runAttempt }
878
888
  : {}),
889
+ ...(typeof input.resumeEpoch === 'number' &&
890
+ Number.isSafeInteger(input.resumeEpoch) &&
891
+ input.resumeEpoch > 0
892
+ ? { resume_epoch: input.resumeEpoch }
893
+ : {}),
879
894
  ...(input.runLeaseToken?.trim()
880
895
  ? { run_lease_token: input.runLeaseToken.trim() }
881
896
  : {}),
@@ -87,6 +87,9 @@ export const PLAY_LAUNCH_ENVELOPE_FIELD_ROLES: {
87
87
  runtimeGatewayPinnedAtMs: 'detail',
88
88
  arrayInputTerminalRetirementSupported: 'detail',
89
89
  arrayInputTerminalProjectionOrigin: 'detail',
90
+ runScopedKeys: 'detail',
91
+ resumeEpoch: 'detail',
92
+ resumeEpochFirstAttempt: 'detail',
90
93
  runtimeTokenOrigin: 'detail',
91
94
  baseUrl: 'detail',
92
95
  coordinatorUrl: 'detail',
@@ -31,8 +31,12 @@ function loadSafeFetch(): Promise<SafeFetchModule> {
31
31
  return safeFetchModule;
32
32
  }
33
33
 
34
- function isUnsafeOutboundUrlError(error: unknown): boolean {
35
- return error instanceof Error && error.name === 'UnsafeOutboundUrlError';
34
+ function isNonRetryableEgressError(error: unknown): boolean {
35
+ return (
36
+ error instanceof Error &&
37
+ (error.name === 'UnsafeOutboundUrlError' ||
38
+ error.name === 'FixtureEgressFetchError')
39
+ );
36
40
  }
37
41
 
38
42
  export class CtxFetchTimeoutError extends Error {
@@ -347,7 +351,7 @@ export async function sendPlayHttpRequest(input: {
347
351
  if (init.signal?.aborted) {
348
352
  throw init.signal.reason ?? error;
349
353
  }
350
- if (isUnsafeOutboundUrlError(error)) {
354
+ if (isNonRetryableEgressError(error)) {
351
355
  throw error;
352
356
  }
353
357
  const message = error instanceof Error ? error.message : String(error);
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  EXPLICIT_FRESHNESS_PLAY_AUTHORING_THRESHOLD,
3
+ REQUEST_DIGEST_CALL_SLOT_PLAY_AUTHORING_THRESHOLD,
3
4
  normalizePlayAuthoringContractEdition,
4
5
  playToolListGetterMode,
5
6
  playCsvDatasetRowIdentity,
@@ -16,6 +17,13 @@ export type PlayRuntimeFetchHttpFailureSemantics =
16
17
  export type PlayRuntimeFreshnessSemantics =
17
18
  | 'legacy_bucket'
18
19
  | 'actual_age_with_operation_recovery';
20
+ /**
21
+ * How concurrent durable calls that share an authored id in one scope get
22
+ * their invocation slot. `call_order` numbers them by start order;
23
+ * `request_digest` numbers them only among calls with the same request, so a
24
+ * resume that starts them in another order cannot swap recorded results.
25
+ */
26
+ export type PlayRuntimeCallSlotIdentity = 'call_order' | 'request_digest';
19
27
 
20
28
  /**
21
29
  * Immutable worker-side projection of the semantics pinned by a Play artifact.
@@ -41,6 +49,7 @@ export type PlayRuntimeSemantics = Readonly<{
41
49
  receiptIdentityEdition: PlayAuthoringContractEdition | null;
42
50
  }>;
43
51
  freshness: PlayRuntimeFreshnessSemantics;
52
+ callSlotIdentity: PlayRuntimeCallSlotIdentity;
44
53
  inlineChild: Readonly<{
45
54
  /**
46
55
  * Whether a scalar child may rely solely on its execution-time
@@ -61,7 +70,11 @@ export type PlayRuntimeSemantics = Readonly<{
61
70
 
62
71
  type PlayRuntimeSemanticsTemplate = Omit<
63
72
  PlayRuntimeSemantics,
64
- 'authoringContractEdition' | 'freshness' | 'tools' | 'datasets'
73
+ | 'authoringContractEdition'
74
+ | 'freshness'
75
+ | 'callSlotIdentity'
76
+ | 'tools'
77
+ | 'datasets'
65
78
  > & { tools: Omit<PlayRuntimeSemantics['tools'], 'listGetters'> };
66
79
 
67
80
  function definePlayRuntimeSemantics(
@@ -78,6 +91,11 @@ function definePlayRuntimeSemantics(
78
91
  EXPLICIT_FRESHNESS_PLAY_AUTHORING_THRESHOLD
79
92
  ? 'actual_age_with_operation_recovery'
80
93
  : 'legacy_bucket',
94
+ callSlotIdentity:
95
+ semantics.authoringContractEdition >=
96
+ REQUEST_DIGEST_CALL_SLOT_PLAY_AUTHORING_THRESHOLD
97
+ ? 'request_digest'
98
+ : 'call_order',
81
99
  inlineChild: Object.freeze({ ...semantics.inlineChild }),
82
100
  tools: Object.freeze({
83
101
  ...semantics.tools,
@@ -227,6 +245,18 @@ const PLAY_RUNTIME_SEMANTICS_BY_AUTHORING = {
227
245
  tools: { nativeBatchResponse: 'logical_response' },
228
246
  slackHitl: WEEK_LONG_SLACK_HITL_SEMANTICS,
229
247
  },
248
+ 12: {
249
+ ...PLAINTEXT_SECRET_SEMANTICS,
250
+ fetch: {
251
+ httpFailure: 'throw_typed_error',
252
+ persistHttpFailure: false,
253
+ // Request-digest call slots do not create another fetch receipt identity.
254
+ receiptIdentityEdition: FETCH_RECEIPT_IDENTITIES.typedHttpFailure,
255
+ },
256
+ inlineChild: { runtimeOnly: true },
257
+ tools: { nativeBatchResponse: 'logical_response' },
258
+ slackHitl: WEEK_LONG_SLACK_HITL_SEMANTICS,
259
+ },
230
260
  } satisfies Record<PlayAuthoringContractEdition, PlayRuntimeSemanticsTemplate>;
231
261
 
232
262
  const PLAY_RUNTIME_SEMANTICS = Object.fromEntries(