deepline 0.3.545 → 0.3.547

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 (222) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +13 -0
  2. package/dist/bundling-sources/sdk/src/errors.ts +1 -1
  3. package/dist/bundling-sources/sdk/src/http-core.ts +41 -12
  4. package/dist/bundling-sources/sdk/src/index.ts +7 -1
  5. package/dist/bundling-sources/sdk/src/integrations.ts +17 -7
  6. package/dist/bundling-sources/sdk/src/play.ts +71 -0
  7. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  8. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +13 -4
  9. package/dist/bundling-sources/sdk/src/types.ts +33 -0
  10. package/dist/bundling-sources/shared_libs/integration-contracts/calendar-delegation.ts +7 -0
  11. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +2 -0
  12. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +1 -0
  13. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +21 -3
  14. package/dist/bundling-sources/shared_libs/play-data-plane/contracts.ts +5 -0
  15. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +17 -2
  16. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-contract.ts +27 -0
  17. package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +57 -5
  18. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +299 -52
  19. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +18 -1
  20. package/dist/bundling-sources/shared_libs/play-runtime/docflow-decision-tracker.ts +135 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/docflow-fail-open.ts +177 -0
  22. package/dist/bundling-sources/shared_libs/play-runtime/docflow-node-io.ts +99 -2
  23. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +16 -10
  24. package/dist/bundling-sources/shared_libs/play-runtime/fenced-call-diagnostics.ts +211 -0
  25. package/dist/bundling-sources/shared_libs/play-runtime/fleet-sandbox-sweep.ts +40 -3
  26. package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +19 -3
  27. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +18 -4
  28. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +441 -103
  29. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox-egress.ts +322 -0
  30. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +200 -64
  31. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +52 -14
  32. package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +65 -2
  33. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +5 -3
  34. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +53 -2
  35. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +206 -12
  36. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +18 -0
  37. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +68 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +11 -3
  39. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +30 -2
  40. package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +9 -1
  41. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +48 -0
  42. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +36 -2
  43. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +716 -51
  44. package/dist/bundling-sources/shared_libs/plays/docflow-decision-arms.ts +146 -0
  45. package/dist/bundling-sources/shared_libs/plays/docflow-flow-order.ts +94 -0
  46. package/dist/bundling-sources/shared_libs/plays/docflow-unreached-reason.ts +10 -1
  47. package/dist/bundling-sources/shared_libs/plays/docflow.ts +787 -117
  48. package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +8 -2
  49. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +41 -2
  50. package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +13 -0
  51. package/dist/bundling-sources/shared_libs/product-notifications/billing-sales.ts +25 -0
  52. package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +35 -1
  53. package/dist/bundling-sources/shared_libs/security/email-domain.ts +19 -0
  54. package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +58 -0
  55. package/dist/cli/auth-AC5277PI.js +43 -0
  56. package/dist/cli/{auth-VZAMAMFW.mjs → auth-WJEY4IDX.mjs} +6 -6
  57. package/dist/cli/{billing-ASZJDFH2.js → billing-IJITDDRQ.js} +99 -99
  58. package/dist/cli/{billing-DADQUQEZ.mjs → billing-PHJUDYF3.mjs} +11 -11
  59. package/dist/cli/{chunk-FB7UPZ6M.js → chunk-2AHY47SI.js} +3 -3
  60. package/dist/cli/{chunk-CJ7DBYEQ.js → chunk-2HPTLBNB.js} +8 -8
  61. package/dist/cli/{chunk-TI6DTURF.js → chunk-4WAM6TLD.js} +7 -1
  62. package/dist/cli/{chunk-LTCEZWPZ.mjs → chunk-56MEAGWA.mjs} +2 -2
  63. package/dist/cli/{chunk-YWTRCKGD.mjs → chunk-5SFHPMBY.mjs} +11 -11
  64. package/dist/cli/{chunk-D3SXB2NX.js → chunk-ABLTVG3J.js} +41 -41
  65. package/dist/cli/{chunk-KRW727W6.mjs → chunk-AEQ5VWZ5.mjs} +4 -4
  66. package/dist/cli/{chunk-Z7QM244Q.mjs → chunk-CKIRKYW7.mjs} +3 -3
  67. package/dist/cli/{chunk-2JHYYB3F.js → chunk-CSPHSNBW.js} +3 -3
  68. package/dist/cli/{chunk-OGQYAJSO.js → chunk-D6OIEH47.js} +5 -5
  69. package/dist/cli/{chunk-2HFSYH7V.mjs → chunk-DIUNDLSX.mjs} +2 -2
  70. package/dist/cli/{chunk-3M2QH3KA.mjs → chunk-DJI5CLLW.mjs} +22 -12
  71. package/dist/cli/{chunk-N4LADLCO.js → chunk-DZC7LMYM.js} +6 -6
  72. package/dist/cli/{chunk-CXETRZ3G.js → chunk-E2OIYPB4.js} +10 -10
  73. package/dist/cli/{chunk-Z4Y4BLW7.mjs → chunk-ECUD4QPD.mjs} +3 -3
  74. package/dist/cli/{chunk-2GJZLIKW.js → chunk-EITMD3A5.js} +1 -1
  75. package/dist/cli/{chunk-NAN3A4IF.mjs → chunk-ESCVHDNY.mjs} +5 -5
  76. package/dist/cli/{chunk-C6XYSTBW.js → chunk-FFBXLFKV.js} +1 -1
  77. package/dist/cli/{chunk-HLUNTJBO.mjs → chunk-FMQXAOVE.mjs} +4 -4
  78. package/dist/cli/{chunk-HXIR3VQL.mjs → chunk-FZHMNK6F.mjs} +7 -1
  79. package/dist/cli/{chunk-4NZ3OZNO.mjs → chunk-G6KW764N.mjs} +1 -1
  80. package/dist/cli/{chunk-LWPFMYSO.mjs → chunk-G6XTCG3J.mjs} +2 -2
  81. package/dist/cli/{chunk-NCX2JH2F.js → chunk-GIGAYLY6.js} +12 -12
  82. package/dist/cli/{chunk-BLYW6FFB.js → chunk-GJA2PRHJ.js} +2 -2
  83. package/dist/cli/{chunk-G5TV6WLV.js → chunk-GJOGFWX3.js} +20 -20
  84. package/dist/cli/{chunk-7MFATEUC.mjs → chunk-GPAWLXW3.mjs} +2 -2
  85. package/dist/cli/{chunk-DZTVDL2X.js → chunk-GZFZZQL4.js} +289 -268
  86. package/dist/cli/{chunk-XBYQZEUE.mjs → chunk-HARZ4AAX.mjs} +1 -1
  87. package/dist/cli/{chunk-QI57XUGA.js → chunk-HFIFKP3A.js} +5 -5
  88. package/dist/cli/{chunk-WP36UBRY.mjs → chunk-IGAK22XO.mjs} +1 -1
  89. package/dist/cli/{chunk-XMUPZINS.mjs → chunk-IKYN6PLO.mjs} +5 -5
  90. package/dist/cli/{chunk-HPX7LLAM.mjs → chunk-ITLZBDSR.mjs} +3 -3
  91. package/dist/cli/{chunk-QM7PHHYZ.js → chunk-IVFFCAV2.js} +44 -44
  92. package/dist/cli/{chunk-IYJO3RWR.js → chunk-K3GMDSUX.js} +5 -5
  93. package/dist/cli/{chunk-EK5C2R7S.js → chunk-L5J6UJ2X.js} +15 -15
  94. package/dist/cli/{chunk-EWA3M54M.mjs → chunk-L6QE2XVM.mjs} +1 -1
  95. package/dist/cli/{chunk-3NG43NXB.js → chunk-LMLSOHTU.js} +53 -53
  96. package/dist/cli/{chunk-7MHBJU73.js → chunk-MBQELFL7.js} +22 -22
  97. package/dist/cli/{chunk-Z7SXGOIQ.mjs → chunk-MF7PCM6C.mjs} +1 -1
  98. package/dist/cli/{chunk-DGKDCZGC.js → chunk-MO7TGNXB.js} +13 -13
  99. package/dist/cli/{chunk-7P72EGLK.mjs → chunk-MOZEAGSR.mjs} +1 -1
  100. package/dist/cli/{chunk-34UKDHRL.js → chunk-N63U5CRG.js} +26 -26
  101. package/dist/cli/{chunk-5YYWZ43J.js → chunk-NBYFQZ6O.js} +2 -2
  102. package/dist/cli/{chunk-CQBIO6HW.mjs → chunk-NURW5XH4.mjs} +1 -1
  103. package/dist/cli/{chunk-TQKHXMV3.js → chunk-OVYXYTEP.js} +16 -16
  104. package/dist/cli/{chunk-XGEUPU3L.mjs → chunk-PBMO36BP.mjs} +2 -2
  105. package/dist/cli/{chunk-4JQEAYN3.js → chunk-PVQCX6KQ.js} +55 -8
  106. package/dist/cli/{chunk-KYO2FICL.mjs → chunk-QLE3QKJ2.mjs} +5 -5
  107. package/dist/cli/{chunk-2FF3O2Y2.js → chunk-QU3K3IY6.js} +12 -12
  108. package/dist/cli/{chunk-HR5BT42R.js → chunk-REAFIEV5.js} +99 -99
  109. package/dist/cli/{chunk-Y3T5GWYK.mjs → chunk-RMCCB3XY.mjs} +55 -8
  110. package/dist/cli/{chunk-3TCHX7YK.mjs → chunk-RXRC2COC.mjs} +2 -2
  111. package/dist/cli/{chunk-YRQKRQDU.js → chunk-SAJWYN4B.js} +36 -26
  112. package/dist/cli/{chunk-JL5JU3LD.mjs → chunk-TNJG4ZPN.mjs} +3 -3
  113. package/dist/cli/{chunk-NZDZGK35.js → chunk-VNOQEDVC.js} +7 -7
  114. package/dist/cli/{chunk-2CBX43LP.mjs → chunk-VPF54TXQ.mjs} +5 -5
  115. package/dist/cli/{chunk-2HSZCQMT.mjs → chunk-WYT3H6JD.mjs} +1 -1
  116. package/dist/cli/{chunk-GWDPNOA7.mjs → chunk-XMBVHJPR.mjs} +29 -8
  117. package/dist/cli/{chunk-52C6W7FG.mjs → chunk-XNTDTAKC.mjs} +1 -1
  118. package/dist/cli/{chunk-ERLW6RPA.js → chunk-YURGAKI3.js} +2 -2
  119. package/dist/cli/{chunk-GFRJU2KB.js → chunk-YVKLF7RW.js} +2 -2
  120. package/dist/cli/{chunk-7JZ27AFH.mjs → chunk-Z2YGQZWV.mjs} +2 -2
  121. package/dist/cli/command-docs.js +2 -2
  122. package/dist/cli/command-docs.mjs +1 -1
  123. package/dist/cli/{concurrent-runs-help-YP7ALTDB.mjs → concurrent-runs-help-ZNGP563R.mjs} +7 -7
  124. package/dist/cli/concurrent-runs-help-ZYISYOQA.js +21 -0
  125. package/dist/cli/{csv-D5ITFSYI.mjs → csv-VAHQHYYV.mjs} +5 -5
  126. package/dist/cli/{csv-67WT5EGR.js → csv-X6D4ZELE.js} +14 -14
  127. package/dist/cli/{db-SZYBRFYG.mjs → db-4G4S2VOV.mjs} +8 -8
  128. package/dist/cli/{db-GZS76X7R.js → db-YA5ZGVEX.js} +33 -33
  129. package/dist/cli/{describe-YJ7ZLLLI.mjs → describe-EVXEM2S6.mjs} +20 -20
  130. package/dist/cli/describe-GYYSLZLV.js +50 -0
  131. package/dist/cli/describe-core.d.mts +4 -4
  132. package/dist/cli/describe-core.d.ts +4 -4
  133. package/dist/cli/describe-core.js +1 -1
  134. package/dist/cli/describe-core.mjs +1 -1
  135. package/dist/cli/{executions-O5USTYGL.js → executions-5YC7ABF6.js} +10 -10
  136. package/dist/cli/{executions-HMYGR32E.mjs → executions-HR6CTN5M.mjs} +8 -8
  137. package/dist/cli/{feedback-Z3NXWYUO.mjs → feedback-GEU5SPLR.mjs} +7 -7
  138. package/dist/cli/{feedback-RHLFDCRS.js → feedback-MJHSYLFF.js} +15 -15
  139. package/dist/cli/git-FZIQZNI4.js +25 -0
  140. package/dist/cli/{git-CLFKXELB.mjs → git-NPFF6QUS.mjs} +6 -6
  141. package/dist/cli/index.js +150 -150
  142. package/dist/cli/index.mjs +46 -46
  143. package/dist/cli/{integrations-TZ4QEQGV.js → integrations-YPHFI77G.js} +20 -18
  144. package/dist/cli/{integrations-FOACOBQB.mjs → integrations-Z7EGVBHF.mjs} +12 -10
  145. package/dist/cli/{legacy-noops-QRDOS33V.js → legacy-noops-246E3KKG.js} +10 -10
  146. package/dist/cli/{legacy-noops-6F6Y3BV7.mjs → legacy-noops-5IYCFWWX.mjs} +7 -7
  147. package/dist/cli/{mcp-UXRCWOZU.mjs → mcp-WUYGZXPI.mjs} +5 -5
  148. package/dist/cli/{mcp-ETMMDDGB.js → mcp-YTYTW67G.js} +25 -25
  149. package/dist/cli/{monitors-6XEWR46R.mjs → monitors-73DQKCU7.mjs} +27 -9
  150. package/dist/cli/{monitors-DITT7QTV.js → monitors-SA6ILD6Z.js} +121 -103
  151. package/dist/cli/{org-CVSSH73G.mjs → org-WVQRB2KX.mjs} +8 -8
  152. package/dist/cli/{org-4DE37X3L.js → org-X7ELDV7B.js} +90 -90
  153. package/dist/cli/{play-Y5NCHOKK.mjs → play-QI6V2EUQ.mjs} +296 -68
  154. package/dist/cli/{play-RH6P45CI.js → play-QTYOAJPE.js} +898 -670
  155. package/dist/cli/{providers-VHUHC4IZ.mjs → providers-DPVMVDS4.mjs} +8 -8
  156. package/dist/cli/{providers-DU42DLOL.js → providers-XXFLVREV.js} +11 -11
  157. package/dist/cli/{quickstart-XJ43JLEC.js → quickstart-33ISXQJU.js} +7 -7
  158. package/dist/cli/{quickstart-HJY5YYE5.mjs → quickstart-YWGNHULM.mjs} +5 -5
  159. package/dist/cli/{run-JXUS7QFI.js → run-BWHZXLTD.js} +46 -46
  160. package/dist/cli/{run-JAIXHVH7.mjs → run-J6FCAKQC.mjs} +26 -26
  161. package/dist/cli/search-JCWJX2XD.js +32 -0
  162. package/dist/cli/{search-RDMNM2AX.mjs → search-Z3UU3WBB.mjs} +9 -9
  163. package/dist/cli/{search-output-ZKTR3WTJ.mjs → search-output-OJYY4J7E.mjs} +5 -5
  164. package/dist/cli/{search-output-RKAM2HBH.js → search-output-YIPV74ME.js} +7 -7
  165. package/dist/cli/{secrets-TKFVMAYX.js → secrets-UXRJCEN4.js} +17 -17
  166. package/dist/cli/{secrets-WSW3FTF6.mjs → secrets-YZZN2WST.mjs} +8 -8
  167. package/dist/cli/{sessions-724BK6VP.mjs → sessions-ITCGPD7Z.mjs} +7 -7
  168. package/dist/cli/sessions-NA4SJH6Q.js +22 -0
  169. package/dist/cli/{settings-5LJZDAZU.js → settings-LAFYMILP.js} +87 -87
  170. package/dist/cli/{settings-YRC7J75G.mjs → settings-ZP2LSVNM.mjs} +14 -14
  171. package/dist/cli/{setup-2F3DBSOS.js → setup-4AL3XYM5.js} +50 -50
  172. package/dist/cli/{setup-STNPX5MK.mjs → setup-WEQAQSYC.mjs} +10 -10
  173. package/dist/cli/{skills-D5PK56FO.mjs → skills-NQH4HFW2.mjs} +8 -8
  174. package/dist/cli/skills-XZ4Y6SZ7.js +36 -0
  175. package/dist/cli/{tools-WOGWMBA3.mjs → tools-CXK2GSI4.mjs} +19 -19
  176. package/dist/cli/tools-WJQ6Y7E4.js +57 -0
  177. package/dist/cli/{update-PC6XSWMI.mjs → update-3ROF3Z75.mjs} +10 -10
  178. package/dist/cli/update-ZLRLTBRD.js +34 -0
  179. package/dist/cli/{views-IIHT4RYQ.mjs → views-AOUHVGV2.mjs} +8 -8
  180. package/dist/cli/{views-HLCLAPWN.js → views-XJFO5CEH.js} +23 -23
  181. package/dist/cli/{workflow-CCZ2A7DI.js → workflow-GY3DBHXX.js} +19 -19
  182. package/dist/cli/{workflow-HK4MZ7LK.mjs → workflow-KBS2QJK6.mjs} +9 -9
  183. package/dist/{client-DfdUc_MY.d.mts → client-D1uWA2Vc.d.mts} +1 -1
  184. package/dist/{client-BQ6yuSjM.d.ts → client-Hz7SsBXs.d.ts} +1 -1
  185. package/dist/{client-core-3GQ8WMuk.d.ts → client-core-D3Ad7Flt.d.ts} +554 -504
  186. package/dist/{client-core-ClsNRytk.d.mts → client-core-Db_e63Hb.d.mts} +554 -504
  187. package/dist/{compiler-manifest-BWFtsQIC.d.mts → compiler-manifest-BqwVrOri.d.mts} +73 -18
  188. package/dist/{compiler-manifest-BWFtsQIC.d.ts → compiler-manifest-BqwVrOri.d.ts} +73 -18
  189. package/dist/{errors-Lm9_vJHZ.d.ts → errors-BU8FB99X.d.mts} +2 -2
  190. package/dist/{errors-CwKXXtuu.d.mts → errors-DfVN_FUG.d.ts} +2 -2
  191. package/dist/{index-3vJ-V9yw.d.ts → index-BGnvtYGc.d.ts} +6 -1
  192. package/dist/{index-DjwsAt82.d.mts → index-DjZgwpGw.d.mts} +6 -1
  193. package/dist/index.d.mts +28 -8
  194. package/dist/index.d.ts +28 -8
  195. package/dist/index.js +65 -40
  196. package/dist/index.mjs +33 -8
  197. package/dist/install-integrity.json +137 -130
  198. package/dist/plays/bundle-play-file.d.mts +3 -3
  199. package/dist/plays/bundle-play-file.d.ts +3 -3
  200. package/dist/plays/bundle-play-file.mjs +640 -125
  201. package/dist/plays/play-description.d.mts +3 -3
  202. package/dist/plays/play-description.d.ts +3 -3
  203. package/dist/plays/run-request.d.mts +2 -2
  204. package/dist/plays/run-request.d.ts +2 -2
  205. package/dist/release.d.mts +1 -1
  206. package/dist/release.d.ts +1 -1
  207. package/dist/release.js +2 -2
  208. package/dist/release.mjs +1 -1
  209. package/dist/server.d.mts +4 -4
  210. package/dist/server.d.ts +4 -4
  211. package/dist/server.js +11 -11
  212. package/dist/server.mjs +5 -5
  213. package/package.json +1 -1
  214. package/dist/cli/auth-455MB4K6.js +0 -43
  215. package/dist/cli/concurrent-runs-help-GFWXOKF5.js +0 -21
  216. package/dist/cli/describe-ZRGYAEBT.js +0 -50
  217. package/dist/cli/git-RC4XDATD.js +0 -25
  218. package/dist/cli/search-O5VVMXII.js +0 -32
  219. package/dist/cli/sessions-3PWFWCHO.js +0 -22
  220. package/dist/cli/skills-RFOMVXIT.js +0 -36
  221. package/dist/cli/tools-CAO6EVUW.js +0 -57
  222. package/dist/cli/update-L4DQZY3G.js +0 -34
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Records which arm each drawn decision took, at run time.
3
+ *
4
+ * A decision box's observation settles with its computed value (`isEnterprise
5
+ * = false`); the branch statement acting on it is ordinary code. The arm is
6
+ * named by the first bound box the run reports next that the decision can
7
+ * reach, per the pure rule in `../plays/docflow-decision-arms`. The
8
+ * tracker holds each settled decision until such a box arrives, then hands the
9
+ * caller what to record: the arm, its target, and this attempt's per-arm counts
10
+ * (bounded by the drawn arms, so the state stays fixed-size however often a
11
+ * loop re-decides).
12
+ *
13
+ * Keyed by the diagram object, so an inline child play's decisions resolve
14
+ * only against its own diagram's boxes.
15
+ */
16
+ import type { PlayDocflow } from '../plays/docflow';
17
+ import {
18
+ docflowDecisionArmPlans,
19
+ resolveDocflowDecisionArm,
20
+ } from '../plays/docflow-decision-arms';
21
+ import {
22
+ DOCFLOW_NODE_IO_LIMITS,
23
+ type PlayDocflowNodeDecision,
24
+ } from './docflow-node-io';
25
+
26
+ export type DocflowDecisionResolved<Settled> = {
27
+ decisionId: string;
28
+ settled: Settled;
29
+ decision: PlayDocflowNodeDecision;
30
+ /** First time this attempt took this arm of this decision. */
31
+ firstForArm: boolean;
32
+ };
33
+
34
+ type ArmCount = { arm: string; to: string; count: number };
35
+
36
+ export class DocflowDecisionTracker<Settled> {
37
+ private readonly pending = new WeakMap<
38
+ PlayDocflow,
39
+ Map<string, Settled>
40
+ >();
41
+ private readonly counts = new WeakMap<
42
+ PlayDocflow,
43
+ Map<string, ArmCount[]>
44
+ >();
45
+
46
+ /** Whether `nodeId` is a decision whose arm this tracker can record. */
47
+ tracks(docflow: PlayDocflow, nodeId: string): boolean {
48
+ return docflowDecisionArmPlans(docflow).has(nodeId);
49
+ }
50
+
51
+ /**
52
+ * A decision box settled. A newer settlement of the same box replaces an
53
+ * unresolved older one: only the latest invocation's arm is knowable.
54
+ */
55
+ settle(docflow: PlayDocflow, decisionId: string, settled: Settled): void {
56
+ if (!this.tracks(docflow, decisionId)) return;
57
+ let pending = this.pending.get(docflow);
58
+ if (!pending) {
59
+ pending = new Map();
60
+ this.pending.set(docflow, pending);
61
+ }
62
+ pending.set(decisionId, settled);
63
+ }
64
+
65
+ /**
66
+ * A bound box was reached. Returns every pending decision it names an arm
67
+ * for, and forgets the ones it proves unresolvable.
68
+ */
69
+ reach(
70
+ docflow: PlayDocflow,
71
+ nodeId: string,
72
+ ): DocflowDecisionResolved<Settled>[] {
73
+ const pending = this.pending.get(docflow);
74
+ if (!pending || pending.size === 0) return [];
75
+ const plans = docflowDecisionArmPlans(docflow);
76
+ const resolved: DocflowDecisionResolved<Settled>[] = [];
77
+ for (const [decisionId, settled] of [...pending]) {
78
+ const plan = plans.get(decisionId);
79
+ if (!plan) {
80
+ pending.delete(decisionId);
81
+ continue;
82
+ }
83
+ const outcome = resolveDocflowDecisionArm(plan, nodeId);
84
+ if (outcome.kind === 'unrelated') continue;
85
+ pending.delete(decisionId);
86
+ if (outcome.kind === 'unresolvable') continue;
87
+ const arm = boundedText(outcome.arm.label);
88
+ const to = boundedText(outcome.arm.to);
89
+ let byDecision = this.counts.get(docflow);
90
+ if (!byDecision) {
91
+ byDecision = new Map();
92
+ this.counts.set(docflow, byDecision);
93
+ }
94
+ const counts = byDecision.get(decisionId) ?? [];
95
+ const existing = counts.find(
96
+ (entry) => entry.arm === arm && entry.to === to,
97
+ );
98
+ if (existing) existing.count += 1;
99
+ else if (counts.length < DOCFLOW_NODE_IO_LIMITS.maxDecisionArms) {
100
+ counts.push({ arm, to, count: 1 });
101
+ }
102
+ byDecision.set(decisionId, counts);
103
+ resolved.push({
104
+ decisionId,
105
+ settled,
106
+ decision: {
107
+ arm,
108
+ to,
109
+ counts: counts.map((entry) => ({ ...entry })),
110
+ },
111
+ firstForArm: !existing,
112
+ });
113
+ }
114
+ return resolved;
115
+ }
116
+ }
117
+
118
+ const utf8 = new TextEncoder();
119
+
120
+ /** Trim to the preview string bound without splitting a UTF-8 sequence. */
121
+ export function boundedText(
122
+ value: string,
123
+ maxBytes: number = DOCFLOW_NODE_IO_LIMITS.maxStringBytes,
124
+ ): string {
125
+ if (utf8.encode(value).byteLength <= maxBytes) return value;
126
+ let out = '';
127
+ let bytes = 0;
128
+ for (const char of value) {
129
+ const size = utf8.encode(char).byteLength;
130
+ if (bytes + size > maxBytes - 3) break;
131
+ out += char;
132
+ bytes += size;
133
+ }
134
+ return `${out}…`;
135
+ }
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Docflow tracking is display-only, so it must never change what a Play does.
3
+ *
4
+ * Every compiler-injected observation funnels through
5
+ * {@link runDocflowObservationFailOpen}, which guarantees by construction:
6
+ *
7
+ * - `execute` runs exactly once, synchronously, in the caller's turn;
8
+ * - its return value (the same object, the same Promise instance) or its
9
+ * throw reaches the Play unchanged;
10
+ * - no tracking stage (start/capture, decision arms, completion, failure,
11
+ * fault reporting) can throw into the Play or leave an unhandled rejection.
12
+ *
13
+ * A tracking stage that throws is counted and reported to the caller's
14
+ * `onFault`, which must itself be bounded (see `DocflowTrackingFaultCounter`).
15
+ */
16
+
17
+ export type DocflowTrackingFaultStage =
18
+ /** Validating the node id, capturing inputs, emitting `started`. */
19
+ | 'start'
20
+ /** Recording a decision's arm (tracker, decision log line). */
21
+ | 'decision'
22
+ /** Previewing outputs and emitting `completed`. */
23
+ | 'complete'
24
+ /** Previewing the error and emitting `failed`. */
25
+ | 'fail'
26
+ /** A compiler-injected `__deeplineDocflowHit` marker. */
27
+ | 'hit';
28
+
29
+ export type DocflowObservationSettlement<T> = {
30
+ complete(result: T): void;
31
+ fail(error: unknown): void;
32
+ };
33
+
34
+ export type DocflowTrackingFaultReporter = (
35
+ stage: DocflowTrackingFaultStage,
36
+ error: unknown,
37
+ ) => void;
38
+
39
+ /** Runs `stage`, routing anything it throws to `onFault` (which cannot throw). */
40
+ export function guardDocflowTracking(
41
+ stage: DocflowTrackingFaultStage,
42
+ onFault: DocflowTrackingFaultReporter,
43
+ body: () => void,
44
+ ): void {
45
+ try {
46
+ body();
47
+ } catch (error) {
48
+ reportFaultSafely(onFault, stage, error);
49
+ }
50
+ }
51
+
52
+ function reportFaultSafely(
53
+ onFault: DocflowTrackingFaultReporter,
54
+ stage: DocflowTrackingFaultStage,
55
+ error: unknown,
56
+ ): void {
57
+ try {
58
+ onFault(stage, error);
59
+ } catch {
60
+ // The reporter is the last line: nothing it does may reach the Play.
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Observe one authored statement without changing it. `begin` runs before the
66
+ * statement (capture + `started`) and returns how to settle the observation,
67
+ * or null to skip tracking; a throw from it is a fault and the statement still
68
+ * runs, untracked.
69
+ */
70
+ export function runDocflowObservationFailOpen<T>(
71
+ execute: () => T | Promise<T>,
72
+ begin: () => DocflowObservationSettlement<T> | null,
73
+ onFault: DocflowTrackingFaultReporter,
74
+ ): T | Promise<T> {
75
+ let settlement: DocflowObservationSettlement<T> | null = null;
76
+ try {
77
+ settlement = begin();
78
+ } catch (error) {
79
+ reportFaultSafely(onFault, 'start', error);
80
+ settlement = null;
81
+ }
82
+ if (!settlement) return execute();
83
+ const settle = settlement;
84
+
85
+ let result: T | Promise<T>;
86
+ try {
87
+ result = execute();
88
+ } catch (error) {
89
+ guardDocflowTracking('fail', onFault, () => settle.fail(error));
90
+ throw error;
91
+ }
92
+ // Only a native Promise is observed asynchronously: calling `.then` on an
93
+ // authored thenable would run authored code the uninstrumented Play never
94
+ // ran. The derived promise's handlers cannot throw, so it never rejects.
95
+ if (isNativePromise(result)) {
96
+ try {
97
+ void result.then(
98
+ (value) =>
99
+ guardDocflowTracking('complete', onFault, () =>
100
+ settle.complete(value),
101
+ ),
102
+ (error: unknown) =>
103
+ guardDocflowTracking('fail', onFault, () => settle.fail(error)),
104
+ );
105
+ } catch (error) {
106
+ // A Promise subclass with a throwing `then`.
107
+ reportFaultSafely(onFault, 'complete', error);
108
+ }
109
+ return result;
110
+ }
111
+ const value = result;
112
+ guardDocflowTracking('complete', onFault, () => settle.complete(value));
113
+ return result;
114
+ }
115
+
116
+ /** `instanceof` reads the prototype, which a hostile Proxy can make throw. */
117
+ function isNativePromise(value: unknown): value is Promise<unknown> {
118
+ try {
119
+ return value instanceof Promise;
120
+ } catch {
121
+ return false;
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Bounded fault reporting: the first fault of each stage and then powers of
127
+ * two, each carrying the running count, so a hot loop whose observation keeps
128
+ * failing reports O(log n) lines. Lines never carry values, messages, or
129
+ * inputs (they may hold secrets): only the stage, node id and error class.
130
+ */
131
+ export class DocflowTrackingFaultCounter {
132
+ private readonly counts = new Map<DocflowTrackingFaultStage, number>();
133
+ total = 0;
134
+
135
+ constructor(
136
+ private readonly write: (line: string) => void,
137
+ private readonly identity: () => Record<string, unknown> = () => ({}),
138
+ ) {}
139
+
140
+ record(
141
+ stage: DocflowTrackingFaultStage,
142
+ nodeId: unknown,
143
+ error: unknown,
144
+ ): void {
145
+ this.total += 1;
146
+ const count = (this.counts.get(stage) ?? 0) + 1;
147
+ this.counts.set(stage, count);
148
+ if ((count & (count - 1)) !== 0) return;
149
+ let identity: Record<string, unknown> = {};
150
+ try {
151
+ identity = this.identity();
152
+ } catch {
153
+ identity = {};
154
+ }
155
+ this.write(
156
+ JSON.stringify({
157
+ event: 'docflow_tracking_fault',
158
+ stage,
159
+ node_id:
160
+ typeof nodeId === 'string' ? nodeId.slice(0, 128) : typeof nodeId,
161
+ error_class: docflowFaultErrorClass(error),
162
+ stage_fault_count: count,
163
+ total_fault_count: this.total,
164
+ ...identity,
165
+ }),
166
+ );
167
+ }
168
+ }
169
+
170
+ function docflowFaultErrorClass(error: unknown): string {
171
+ try {
172
+ if (error instanceof Error) return error.name.slice(0, 64) || 'Error';
173
+ } catch {
174
+ return 'unknown';
175
+ }
176
+ return error === null ? 'null' : typeof error;
177
+ }
@@ -11,8 +11,29 @@ export const DOCFLOW_NODE_IO_LIMITS = {
11
11
  maxStringBytes: 256,
12
12
  maxPhaseBytes: 2_000,
13
13
  maxErrorBytes: 512,
14
+ /** Arms counted on one decision's recorded outcome. */
15
+ maxDecisionArms: 16,
16
+ /**
17
+ * Invocations of one box observed per attempt before sampling. A box inside
18
+ * a loop (or a helper called per item) is invoked once per item; past this
19
+ * many, only power-of-two invocations are observed, so a run writes
20
+ * O(log n) observations per box however many items it processes.
21
+ */
22
+ maxObservedInvocationsPerNode: 16,
14
23
  } as const;
15
24
 
25
+ /**
26
+ * Whether the `ordinal`-th (1-based) invocation of one box in one attempt is
27
+ * observed: every one up to the limit, then only powers of two. Display-only:
28
+ * an unobserved invocation still runs, untracked.
29
+ */
30
+ export function isDocflowInvocationObserved(ordinal: number): boolean {
31
+ return (
32
+ ordinal <= DOCFLOW_NODE_IO_LIMITS.maxObservedInvocationsPerNode ||
33
+ (Number.isSafeInteger(ordinal) && (ordinal & (ordinal - 1)) === 0)
34
+ );
35
+ }
36
+
16
37
  export type PlayDocflowNodeValuePreview =
17
38
  | { kind: 'null' }
18
39
  | { kind: 'scalar'; value: string | number | boolean }
@@ -70,12 +91,42 @@ export type PlayDocflowNodeIoState = {
70
91
  inputsTruncated?: boolean;
71
92
  outputsTruncated?: boolean;
72
93
  error?: string | null;
94
+ /**
95
+ * The arm a DECISION box took, recorded by the runtime when the run reached
96
+ * the first bound box on that arm (`../plays/docflow-decision-arms`).
97
+ * Optional and reader-first: absent on non-decision boxes, on runs from
98
+ * runtimes that predate it, and when the graph names no single arm.
99
+ */
100
+ decision?: PlayDocflowNodeDecision;
101
+ };
102
+
103
+ /** One decision box's recorded outcome. Fixed size: bounded by its drawn arms. */
104
+ export type PlayDocflowNodeDecision = {
105
+ /** The drawn edge label of the arm taken by this invocation. */
106
+ arm: string;
107
+ /** That edge's target node id. */
108
+ to: string;
109
+ /**
110
+ * How often each arm was taken by this attempt, when the decision ran more
111
+ * than once (a loop or repeated helper call). One entry per drawn arm taken.
112
+ */
113
+ counts?: Array<{ arm: string; to: string; count: number }>;
73
114
  };
74
115
 
75
116
  type PreviewOptions = {
76
117
  redactor?: Pick<SecretRedactionContext, 'redactRegisteredSecrets'>;
77
118
  };
78
119
 
120
+ type CapturePreviewOptions = PreviewOptions & {
121
+ /**
122
+ * Replaces a captured root with a plain-data view before it is traversed and
123
+ * previewed: runtime-owned values (a tool result) expose their data through
124
+ * getters the previewer never invokes on authored values. Must not throw;
125
+ * a throw makes the capture unavailable.
126
+ */
127
+ projectRoot?: (value: unknown) => unknown;
128
+ };
129
+
79
130
  const utf8Encoder = new TextEncoder();
80
131
  const PLAY_DATASET_BRAND = Symbol.for('deepline.play.dataset');
81
132
  const MAX_CONVEX_PREVIEW_KEY_LENGTH = 1_024;
@@ -356,6 +407,13 @@ export function buildPlayDocflowNodeIoPreviewMap(
356
407
  return { values: previews, truncated };
357
408
  }
358
409
 
410
+ /**
411
+ * One step of a captured path (`input.crm_owner`), read the way the step's
412
+ * own optional read would: a field the value does not have, or a field of a
413
+ * null or undefined value, is `undefined` (the run did not provide it), not
414
+ * a failed read. Only a getter, or a read that throws, fails (`ok: false`,
415
+ * captured as `access_error`).
416
+ */
359
417
  function readDataProperty(
360
418
  value: unknown,
361
419
  property: PropertyKey,
@@ -363,6 +421,7 @@ function readDataProperty(
363
421
  ok: boolean;
364
422
  value?: unknown;
365
423
  } {
424
+ if (value === null || value === undefined) return { ok: true, value: undefined };
366
425
  if (
367
426
  (typeof value !== 'object' || value === null) &&
368
427
  typeof value !== 'function'
@@ -383,12 +442,13 @@ function readDataProperty(
383
442
  } catch {
384
443
  return { ok: false };
385
444
  }
386
- return { ok: false };
445
+ // Not there at all: the run did not provide it.
446
+ return { ok: true, value: undefined };
387
447
  }
388
448
 
389
449
  export function buildPlayDocflowNodeInputPreviewMap(
390
450
  captures: readonly PlayDocflowNodeInputCapture[],
391
- options: PreviewOptions = {},
451
+ options: CapturePreviewOptions = {},
392
452
  ): { values: PlayDocflowNodeIoPreviewMap; truncated: boolean } {
393
453
  const values: PlayDocflowNodeIoPreviewMap = {};
394
454
  let truncated = false;
@@ -397,6 +457,7 @@ export function buildPlayDocflowNodeInputPreviewMap(
397
457
  let available = true;
398
458
  try {
399
459
  current = capture.readRoot();
460
+ if (options.projectRoot) current = options.projectRoot(current);
400
461
  } catch {
401
462
  available = false;
402
463
  }
@@ -602,6 +663,7 @@ export function normalizePlayDocflowNodeIoState(
602
663
  };
603
664
  const inputs = normalizeMap(value.inputs);
604
665
  const outputs = normalizeMap(value.outputs);
666
+ const decision = normalizePlayDocflowNodeDecision(value.decision);
605
667
  const error =
606
668
  typeof value.error === 'string'
607
669
  ? buildPlayDocflowNodeErrorPreview(value.error)
@@ -623,5 +685,40 @@ export function normalizePlayDocflowNodeIoState(
623
685
  ...(value.inputsTruncated === true ? { inputsTruncated: true } : {}),
624
686
  ...(value.outputsTruncated === true ? { outputsTruncated: true } : {}),
625
687
  ...(error !== undefined ? { error } : {}),
688
+ ...(decision ? { decision } : {}),
626
689
  };
627
690
  }
691
+
692
+ /**
693
+ * Bounded copy of a recorded decision, or undefined when the value is not one.
694
+ * Unknown keys are dropped: the state is fixed-size by contract.
695
+ */
696
+ export function normalizePlayDocflowNodeDecision(
697
+ value: unknown,
698
+ ): PlayDocflowNodeDecision | undefined {
699
+ if (!isRecord(value)) return undefined;
700
+ const text = (raw: unknown): string | null =>
701
+ typeof raw === 'string' && raw.trim()
702
+ ? truncateUtf8(raw.trim(), DOCFLOW_NODE_IO_LIMITS.maxStringBytes)
703
+ : null;
704
+ const arm = text(value.arm);
705
+ const to = text(value.to);
706
+ if (!arm || !to) return undefined;
707
+ const counts = Array.isArray(value.counts)
708
+ ? value.counts
709
+ .slice(0, DOCFLOW_NODE_IO_LIMITS.maxDecisionArms)
710
+ .flatMap((entry) => {
711
+ if (!isRecord(entry)) return [];
712
+ const entryArm = text(entry.arm);
713
+ const entryTo = text(entry.to);
714
+ const count =
715
+ typeof entry.count === 'number' && Number.isSafeInteger(entry.count)
716
+ ? entry.count
717
+ : -1;
718
+ return entryArm && entryTo && count >= 0
719
+ ? [{ arm: entryArm, to: entryTo, count }]
720
+ : [];
721
+ })
722
+ : undefined;
723
+ return { arm, to, ...(counts?.length ? { counts } : {}) };
724
+ }
@@ -52,19 +52,23 @@ export const DURABLE_RUNS_ROLLOUT = {
52
52
  * request when the relay's acknowledgement covers exactly those writes.
53
53
  *
54
54
  * Skew-safe both ways: an older relay ignores the plan (the runner writes as
55
- * before) and a newer relay without a plan relays untouched. Lands off and
56
- * flips in a rollout PR after every relay serves the reader. Off stops new
57
- * plans; rows already committed are ordinary immutable receipts.
55
+ * before) and a newer relay without a plan relays untouched. On since the
56
+ * runtime speed rollout flip: the relay reader shipped in #10000 and is in
57
+ * the Production release. On the execution relay this also selects the
58
+ * finish commit lanes ({heavy 1, light 2}). Off again stops new plans and
59
+ * restores the relay's ordinary commit lanes; rows already committed are
60
+ * ordinary immutable receipts.
58
61
  */
59
- finishInExecute: false,
62
+ finishInExecute: true,
60
63
  /**
61
64
  * A direct policy-0 tool call reads the result receipt it would claim in
62
65
  * the same request as its operation slots (one fixed batch of direct keys),
63
66
  * instead of a second read after the operation answer. Off: the call reads
64
- * exactly as before. Reader-only, so safe in either direction; lands off so
65
- * the flag-off build stays byte-identical to main.
67
+ * exactly as before. Reader-only, so safe in either direction. On since the
68
+ * runtime speed rollout flip (with `localPermitReadThrough`); off again
69
+ * restores the second read.
66
70
  */
67
- toolResultCompanionRead: false,
71
+ toolResultCompanionRead: true,
68
72
  /**
69
73
  * Local-permit read-through: a warm policy-0 direct call whose dispatch
70
74
  * capacity is already on hand sends its receipt keys (#10008's slots and its
@@ -72,10 +76,12 @@ export const DURABLE_RUNS_ROLLOUT = {
72
76
  * reading first. The relay executes only when every key reads empty; any
73
77
  * record (a pre-binding one included) falls back to the ordinary #10027
74
78
  * classification, and a fresh invocation never uses read-through. Never
75
- * offered with a legacy operation key. Off keeps today's read on every call.
76
- * Lands off.
79
+ * offered with a legacy operation key. Requires `finishInExecute`. An older
80
+ * relay refuses the named action (403 route not allowed) before any work, and
81
+ * the runner then reads for itself on that relay. On since the runtime speed
82
+ * rollout flip; off again keeps the runner's own read on every call.
77
83
  */
78
- localPermitReadThrough: false,
84
+ localPermitReadThrough: true,
79
85
  /**
80
86
  * #10002: one Node process materializes the payload and then becomes the
81
87
  * runtime watchdog (two Node starts instead of three). Off: the established