deepline 0.3.546 → 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 (202) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +13 -0
  2. package/dist/bundling-sources/sdk/src/index.ts +7 -1
  3. package/dist/bundling-sources/sdk/src/integrations.ts +17 -7
  4. package/dist/bundling-sources/sdk/src/play.ts +71 -0
  5. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  6. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +13 -4
  7. package/dist/bundling-sources/sdk/src/types.ts +33 -0
  8. package/dist/bundling-sources/shared_libs/integration-contracts/calendar-delegation.ts +7 -0
  9. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +2 -0
  10. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +1 -0
  11. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +19 -1
  12. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +17 -2
  13. package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +57 -5
  14. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +295 -52
  15. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +10 -1
  16. package/dist/bundling-sources/shared_libs/play-runtime/docflow-decision-tracker.ts +135 -0
  17. package/dist/bundling-sources/shared_libs/play-runtime/docflow-fail-open.ts +177 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/docflow-node-io.ts +99 -2
  19. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +16 -10
  20. package/dist/bundling-sources/shared_libs/play-runtime/fenced-call-diagnostics.ts +211 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +52 -14
  22. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +21 -2
  23. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +18 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +68 -0
  25. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +11 -3
  26. package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +9 -1
  27. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +48 -0
  28. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +6 -1
  29. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +716 -51
  30. package/dist/bundling-sources/shared_libs/plays/docflow-decision-arms.ts +146 -0
  31. package/dist/bundling-sources/shared_libs/plays/docflow-flow-order.ts +94 -0
  32. package/dist/bundling-sources/shared_libs/plays/docflow-unreached-reason.ts +10 -1
  33. package/dist/bundling-sources/shared_libs/plays/docflow.ts +787 -117
  34. package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +8 -2
  35. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +6 -0
  36. package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +13 -0
  37. package/dist/bundling-sources/shared_libs/product-notifications/billing-sales.ts +25 -0
  38. package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +56 -0
  39. package/dist/cli/auth-AC5277PI.js +43 -0
  40. package/dist/cli/{auth-KFWG72AZ.mjs → auth-WJEY4IDX.mjs} +5 -5
  41. package/dist/cli/{billing-OQVOAZ4S.js → billing-IJITDDRQ.js} +96 -96
  42. package/dist/cli/{billing-MMZ336HO.mjs → billing-PHJUDYF3.mjs} +10 -10
  43. package/dist/cli/{chunk-TBWYZOSV.js → chunk-2AHY47SI.js} +3 -3
  44. package/dist/cli/{chunk-MXQP7CXZ.js → chunk-2HPTLBNB.js} +3 -3
  45. package/dist/cli/{chunk-TI6DTURF.js → chunk-4WAM6TLD.js} +7 -1
  46. package/dist/cli/{chunk-JARZ47OP.mjs → chunk-56MEAGWA.mjs} +2 -2
  47. package/dist/cli/{chunk-GYTSDSQD.mjs → chunk-5SFHPMBY.mjs} +11 -11
  48. package/dist/cli/{chunk-Z3UEBFIN.js → chunk-ABLTVG3J.js} +41 -41
  49. package/dist/cli/{chunk-LX2TC3HO.mjs → chunk-AEQ5VWZ5.mjs} +4 -4
  50. package/dist/cli/{chunk-MI7X6V6V.mjs → chunk-CKIRKYW7.mjs} +3 -3
  51. package/dist/cli/{chunk-2JHYYB3F.js → chunk-CSPHSNBW.js} +3 -3
  52. package/dist/cli/{chunk-IVWU7SJC.js → chunk-D6OIEH47.js} +5 -5
  53. package/dist/cli/{chunk-KUK7ARXA.mjs → chunk-DIUNDLSX.mjs} +2 -2
  54. package/dist/cli/{chunk-RO66FPTS.mjs → chunk-DJI5CLLW.mjs} +1 -1
  55. package/dist/cli/{chunk-LIJKRDDG.js → chunk-DZC7LMYM.js} +6 -6
  56. package/dist/cli/{chunk-UQJBV5PM.js → chunk-E2OIYPB4.js} +10 -10
  57. package/dist/cli/{chunk-JA633HRV.mjs → chunk-ECUD4QPD.mjs} +3 -3
  58. package/dist/cli/{chunk-VPERQ3U6.mjs → chunk-ESCVHDNY.mjs} +5 -5
  59. package/dist/cli/{chunk-JVOUQFHT.js → chunk-FFBXLFKV.js} +1 -1
  60. package/dist/cli/{chunk-3DUNNZB6.mjs → chunk-FMQXAOVE.mjs} +4 -4
  61. package/dist/cli/{chunk-HXIR3VQL.mjs → chunk-FZHMNK6F.mjs} +7 -1
  62. package/dist/cli/{chunk-PU3ZAG6V.mjs → chunk-G6KW764N.mjs} +1 -1
  63. package/dist/cli/{chunk-EEG46QZY.mjs → chunk-G6XTCG3J.mjs} +2 -2
  64. package/dist/cli/{chunk-EEJHB76U.js → chunk-GIGAYLY6.js} +12 -12
  65. package/dist/cli/{chunk-BLYW6FFB.js → chunk-GJA2PRHJ.js} +2 -2
  66. package/dist/cli/{chunk-H7Q5IDO3.js → chunk-GJOGFWX3.js} +20 -20
  67. package/dist/cli/{chunk-6Y5TU3R7.mjs → chunk-GPAWLXW3.mjs} +1 -1
  68. package/dist/cli/{chunk-5W4ENHWM.js → chunk-GZFZZQL4.js} +285 -264
  69. package/dist/cli/{chunk-P7A3H6G5.mjs → chunk-HARZ4AAX.mjs} +1 -1
  70. package/dist/cli/{chunk-MEGHIX4M.js → chunk-HFIFKP3A.js} +5 -5
  71. package/dist/cli/{chunk-LHE2TSV6.mjs → chunk-IGAK22XO.mjs} +1 -1
  72. package/dist/cli/{chunk-VTK3HGMN.mjs → chunk-IKYN6PLO.mjs} +5 -5
  73. package/dist/cli/{chunk-UREAIHUU.mjs → chunk-ITLZBDSR.mjs} +3 -3
  74. package/dist/cli/{chunk-6LG7MLJ2.js → chunk-IVFFCAV2.js} +44 -44
  75. package/dist/cli/{chunk-SYTWWVIQ.js → chunk-K3GMDSUX.js} +5 -5
  76. package/dist/cli/{chunk-WKHPLBJK.js → chunk-L5J6UJ2X.js} +15 -15
  77. package/dist/cli/{chunk-X5KOHDJN.mjs → chunk-L6QE2XVM.mjs} +1 -1
  78. package/dist/cli/{chunk-SH32HL7I.js → chunk-LMLSOHTU.js} +53 -53
  79. package/dist/cli/{chunk-JCWNF44W.js → chunk-MBQELFL7.js} +22 -22
  80. package/dist/cli/{chunk-Z7SXGOIQ.mjs → chunk-MF7PCM6C.mjs} +1 -1
  81. package/dist/cli/{chunk-F2VEFMU5.js → chunk-MO7TGNXB.js} +13 -13
  82. package/dist/cli/{chunk-7ZW67ME6.mjs → chunk-MOZEAGSR.mjs} +1 -1
  83. package/dist/cli/{chunk-5VNQMVCU.js → chunk-N63U5CRG.js} +26 -26
  84. package/dist/cli/{chunk-JCH4UNNS.js → chunk-NBYFQZ6O.js} +2 -2
  85. package/dist/cli/{chunk-BTFUAGHC.js → chunk-OVYXYTEP.js} +16 -16
  86. package/dist/cli/{chunk-J65HJCJO.mjs → chunk-PBMO36BP.mjs} +2 -2
  87. package/dist/cli/{chunk-F5YQXCP3.js → chunk-PVQCX6KQ.js} +50 -7
  88. package/dist/cli/{chunk-K2XELBPF.mjs → chunk-QLE3QKJ2.mjs} +5 -5
  89. package/dist/cli/{chunk-VAT2SXFF.js → chunk-QU3K3IY6.js} +12 -12
  90. package/dist/cli/{chunk-JYG4XZLT.js → chunk-REAFIEV5.js} +99 -99
  91. package/dist/cli/{chunk-5OEFXAKP.mjs → chunk-RMCCB3XY.mjs} +50 -7
  92. package/dist/cli/{chunk-HJR2DDJS.mjs → chunk-RXRC2COC.mjs} +2 -2
  93. package/dist/cli/{chunk-4AZLGNXV.js → chunk-SAJWYN4B.js} +4 -4
  94. package/dist/cli/{chunk-VXTTAYOT.mjs → chunk-TNJG4ZPN.mjs} +3 -3
  95. package/dist/cli/{chunk-PMDHY2YK.js → chunk-VNOQEDVC.js} +7 -7
  96. package/dist/cli/{chunk-GOOF7E2B.mjs → chunk-VPF54TXQ.mjs} +5 -5
  97. package/dist/cli/{chunk-2HSZCQMT.mjs → chunk-WYT3H6JD.mjs} +1 -1
  98. package/dist/cli/{chunk-OAKWSLKS.mjs → chunk-XMBVHJPR.mjs} +28 -7
  99. package/dist/cli/{chunk-7MY7KWJS.mjs → chunk-XNTDTAKC.mjs} +1 -1
  100. package/dist/cli/{chunk-5V7NZKGG.js → chunk-YURGAKI3.js} +2 -2
  101. package/dist/cli/{chunk-ND7SFRQL.js → chunk-YVKLF7RW.js} +2 -2
  102. package/dist/cli/{chunk-6FBDTYR2.mjs → chunk-Z2YGQZWV.mjs} +2 -2
  103. package/dist/cli/command-docs.js +2 -2
  104. package/dist/cli/command-docs.mjs +1 -1
  105. package/dist/cli/{concurrent-runs-help-C2O5YKQA.mjs → concurrent-runs-help-ZNGP563R.mjs} +6 -6
  106. package/dist/cli/concurrent-runs-help-ZYISYOQA.js +21 -0
  107. package/dist/cli/{csv-Z4DNGR54.mjs → csv-VAHQHYYV.mjs} +4 -4
  108. package/dist/cli/{csv-MJDNOIQJ.js → csv-X6D4ZELE.js} +13 -13
  109. package/dist/cli/{db-4RL2BNOF.mjs → db-4G4S2VOV.mjs} +7 -7
  110. package/dist/cli/{db-S5QVPK5E.js → db-YA5ZGVEX.js} +28 -28
  111. package/dist/cli/{describe-L4P5SZLQ.mjs → describe-EVXEM2S6.mjs} +19 -19
  112. package/dist/cli/describe-GYYSLZLV.js +50 -0
  113. package/dist/cli/describe-core.d.mts +4 -4
  114. package/dist/cli/describe-core.d.ts +4 -4
  115. package/dist/cli/{executions-MFZ2Z36O.js → executions-5YC7ABF6.js} +9 -9
  116. package/dist/cli/{executions-RR6O3XK5.mjs → executions-HR6CTN5M.mjs} +7 -7
  117. package/dist/cli/{feedback-EQBQ3ABB.mjs → feedback-GEU5SPLR.mjs} +6 -6
  118. package/dist/cli/{feedback-YDAG7VH2.js → feedback-MJHSYLFF.js} +14 -14
  119. package/dist/cli/git-FZIQZNI4.js +25 -0
  120. package/dist/cli/{git-YGLCCU35.mjs → git-NPFF6QUS.mjs} +5 -5
  121. package/dist/cli/index.js +146 -146
  122. package/dist/cli/index.mjs +45 -45
  123. package/dist/cli/{integrations-IQXYMRMW.js → integrations-YPHFI77G.js} +19 -17
  124. package/dist/cli/{integrations-FWYXSBHK.mjs → integrations-Z7EGVBHF.mjs} +11 -9
  125. package/dist/cli/{legacy-noops-U7LI7UXC.js → legacy-noops-246E3KKG.js} +9 -9
  126. package/dist/cli/{legacy-noops-I4YRIX5F.mjs → legacy-noops-5IYCFWWX.mjs} +6 -6
  127. package/dist/cli/{mcp-QJBMB6VS.mjs → mcp-WUYGZXPI.mjs} +4 -4
  128. package/dist/cli/{mcp-GX2UKKWU.js → mcp-YTYTW67G.js} +24 -24
  129. package/dist/cli/{monitors-Z6EGKYJP.mjs → monitors-73DQKCU7.mjs} +26 -8
  130. package/dist/cli/{monitors-WCJYINGX.js → monitors-SA6ILD6Z.js} +119 -101
  131. package/dist/cli/{org-NNHICBR2.mjs → org-WVQRB2KX.mjs} +7 -7
  132. package/dist/cli/{org-7SKG423N.js → org-X7ELDV7B.js} +89 -89
  133. package/dist/cli/{play-CXDFPJ7Z.mjs → play-QI6V2EUQ.mjs} +295 -67
  134. package/dist/cli/{play-4P4DTG3Q.js → play-QTYOAJPE.js} +897 -669
  135. package/dist/cli/{providers-VQLQ7DTR.mjs → providers-DPVMVDS4.mjs} +7 -7
  136. package/dist/cli/{providers-EE4TUE3O.js → providers-XXFLVREV.js} +10 -10
  137. package/dist/cli/{quickstart-RVXHK4WA.js → quickstart-33ISXQJU.js} +6 -6
  138. package/dist/cli/{quickstart-IYNJRB5G.mjs → quickstart-YWGNHULM.mjs} +4 -4
  139. package/dist/cli/{run-R3F34KU3.js → run-BWHZXLTD.js} +45 -45
  140. package/dist/cli/{run-VBQPPMEX.mjs → run-J6FCAKQC.mjs} +25 -25
  141. package/dist/cli/search-JCWJX2XD.js +32 -0
  142. package/dist/cli/{search-B7R62HX5.mjs → search-Z3UU3WBB.mjs} +8 -8
  143. package/dist/cli/{search-output-LNQQXIGZ.mjs → search-output-OJYY4J7E.mjs} +4 -4
  144. package/dist/cli/{search-output-LWHWEPOT.js → search-output-YIPV74ME.js} +6 -6
  145. package/dist/cli/{secrets-QBOZ7WTD.js → secrets-UXRJCEN4.js} +16 -16
  146. package/dist/cli/{secrets-NM3VAJLO.mjs → secrets-YZZN2WST.mjs} +7 -7
  147. package/dist/cli/{sessions-R5BSIJ4I.mjs → sessions-ITCGPD7Z.mjs} +6 -6
  148. package/dist/cli/sessions-NA4SJH6Q.js +22 -0
  149. package/dist/cli/{settings-POYWKNRD.js → settings-LAFYMILP.js} +86 -86
  150. package/dist/cli/{settings-S4PN7WLY.mjs → settings-ZP2LSVNM.mjs} +13 -13
  151. package/dist/cli/{setup-VHB4Z654.js → setup-4AL3XYM5.js} +49 -49
  152. package/dist/cli/{setup-PFLXVBTL.mjs → setup-WEQAQSYC.mjs} +9 -9
  153. package/dist/cli/{skills-W2TELEU7.mjs → skills-NQH4HFW2.mjs} +7 -7
  154. package/dist/cli/skills-XZ4Y6SZ7.js +36 -0
  155. package/dist/cli/{tools-M4FA6N3Y.mjs → tools-CXK2GSI4.mjs} +18 -18
  156. package/dist/cli/tools-WJQ6Y7E4.js +57 -0
  157. package/dist/cli/{update-W7LIHEA7.mjs → update-3ROF3Z75.mjs} +9 -9
  158. package/dist/cli/update-ZLRLTBRD.js +34 -0
  159. package/dist/cli/{views-KTVPV6UP.mjs → views-AOUHVGV2.mjs} +7 -7
  160. package/dist/cli/{views-DJXAGD7V.js → views-XJFO5CEH.js} +22 -22
  161. package/dist/cli/{workflow-NVZDJKH2.js → workflow-GY3DBHXX.js} +18 -18
  162. package/dist/cli/{workflow-LGKCRODX.mjs → workflow-KBS2QJK6.mjs} +8 -8
  163. package/dist/{client-Tp1LSULB.d.mts → client-D1uWA2Vc.d.mts} +1 -1
  164. package/dist/{client-CCyWJqAI.d.ts → client-Hz7SsBXs.d.ts} +1 -1
  165. package/dist/{client-core-BpYiYEfu.d.ts → client-core-D3Ad7Flt.d.ts} +554 -504
  166. package/dist/{client-core-D8eCZz3O.d.mts → client-core-Db_e63Hb.d.mts} +554 -504
  167. package/dist/{compiler-manifest-EBWEUj0b.d.ts → compiler-manifest-BqwVrOri.d.mts} +38 -18
  168. package/dist/{compiler-manifest-EBWEUj0b.d.mts → compiler-manifest-BqwVrOri.d.ts} +38 -18
  169. package/dist/{errors-CParKUQR.d.mts → errors-BU8FB99X.d.mts} +1 -1
  170. package/dist/{errors-Qt0OTA7_.d.ts → errors-DfVN_FUG.d.ts} +1 -1
  171. package/dist/{index-CoqDkIw0.d.ts → index-BGnvtYGc.d.ts} +6 -1
  172. package/dist/{index-BMUVCNp7.d.mts → index-DjZgwpGw.d.mts} +6 -1
  173. package/dist/index.d.mts +28 -8
  174. package/dist/index.d.ts +28 -8
  175. package/dist/index.js +64 -39
  176. package/dist/index.mjs +32 -7
  177. package/dist/install-integrity.json +133 -128
  178. package/dist/plays/bundle-play-file.d.mts +3 -3
  179. package/dist/plays/bundle-play-file.d.ts +3 -3
  180. package/dist/plays/bundle-play-file.mjs +620 -124
  181. package/dist/plays/play-description.d.mts +3 -3
  182. package/dist/plays/play-description.d.ts +3 -3
  183. package/dist/plays/run-request.d.mts +2 -2
  184. package/dist/plays/run-request.d.ts +2 -2
  185. package/dist/release.d.mts +1 -1
  186. package/dist/release.d.ts +1 -1
  187. package/dist/release.js +2 -2
  188. package/dist/release.mjs +1 -1
  189. package/dist/server.d.mts +4 -4
  190. package/dist/server.d.ts +4 -4
  191. package/dist/server.js +6 -6
  192. package/dist/server.mjs +4 -4
  193. package/package.json +1 -1
  194. package/dist/cli/auth-W32GMYND.js +0 -43
  195. package/dist/cli/concurrent-runs-help-6QT7ZR4W.js +0 -21
  196. package/dist/cli/describe-VLU2LUDJ.js +0 -50
  197. package/dist/cli/git-E6W44F5M.js +0 -25
  198. package/dist/cli/search-UUVFXZRA.js +0 -32
  199. package/dist/cli/sessions-K3PD73Q2.js +0 -22
  200. package/dist/cli/skills-QNE2EYT3.js +0 -36
  201. package/dist/cli/tools-3RLI4HGF.js +0 -57
  202. package/dist/cli/update-UT6KIW2W.js +0 -34
@@ -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
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Runner-internal diagnostics for an execution-fenced (execution-lock) Tool
3
+ * Call in a map batch: when the relay's response arrived, when the result was
4
+ * wrapped, when the call's receipt completion settled, and a watchdog when a
5
+ * response has waited too long for its completion.
6
+ *
7
+ * Platform telemetry, not run log: lines go to the runner's stderr as
8
+ * `[play-runner.fenced-call] {json}` (the `play-runner.*` diagnostic family),
9
+ * never to the customer-visible run log or its event store. Logging only:
10
+ * nothing here schedules, retries or decides; the watchdog timer is unref'd
11
+ * and cleared at settlement. Lines carry a receipt-key digest, the attempt
12
+ * and elapsed times only: no tool input, row key, dataset name or provider
13
+ * body.
14
+ *
15
+ * Bounded per runner context (one run attempt): response and settlement lines
16
+ * for the first `detailedCalls` fenced calls only; overdue warnings for any
17
+ * call, the first `overdueFirst` and then every `overdueEvery`th.
18
+ *
19
+ * Why: a fenced row post once stalled after its relay answered 200 and before
20
+ * its receipt was committed (PR #10713's first Preview run), with no runner
21
+ * line between the two. These lines place the next stall on one side of the
22
+ * wrap or the commit.
23
+ */
24
+
25
+ /** A response this long without its completion is logged as overdue. */
26
+ export const FENCED_CALL_COMPLETION_WATCHDOG_MS = 10_000;
27
+ /** Fenced calls per runner context whose response/settlement lines are kept. */
28
+ export const FENCED_CALL_DETAILED_CALLS = 50;
29
+ /** Overdue warnings kept before sampling. */
30
+ export const FENCED_CALL_OVERDUE_FIRST = 20;
31
+ /** After the first ones, every this-many-th overdue warning is kept. */
32
+ export const FENCED_CALL_OVERDUE_EVERY = 50;
33
+
34
+ export const FENCED_CALL_DIAGNOSTIC_PREFIX = '[play-runner.fenced-call]';
35
+
36
+ export type FencedCallDiagnosticEvent =
37
+ | 'fenced_call_relay_response'
38
+ | 'fenced_call_receipt_settled'
39
+ | 'fenced_call_completion_overdue';
40
+
41
+ export type FencedCallDiagnosticLine = {
42
+ event: FencedCallDiagnosticEvent;
43
+ level: 'info' | 'warn';
44
+ tool: string;
45
+ /** Short digest of the call's result receipt key; never the key itself. */
46
+ call_key_hash: string;
47
+ attempt: number;
48
+ /** Since the call entered the fenced dispatch on this runner. */
49
+ elapsed_ms: number;
50
+ /** Relay responses read so far for this call (retries re-send). */
51
+ responses: number;
52
+ /** Since the latest relay response; absent before the first one. */
53
+ since_response_ms?: number;
54
+ /** Whether the relay response had been turned into the call's result. */
55
+ wrapped: boolean;
56
+ /** Settlement only: whether the receipt completion was recorded. */
57
+ outcome?: 'recorded' | 'failed';
58
+ /**
59
+ * Settlement only: `call` when this call's own receipt write settled
60
+ * before it returned; `map` when the map owns the write and records it
61
+ * after this call returns; `none` for an always-fresh call with no receipt.
62
+ */
63
+ receipt_writer?: 'call' | 'map' | 'none';
64
+ /** Overdue only: overdue calls seen in this runner context, this included. */
65
+ overdue_seen?: number;
66
+ };
67
+
68
+ export type FencedCallDiagnostics = {
69
+ /** A new physical send left the runner; a pending watchdog is disarmed. */
70
+ dispatched(): void;
71
+ /** The relay's response body was read; logs and arms the watchdog. */
72
+ responseArrived(): void;
73
+ /** The response was wrapped into the call's result (before the commit). */
74
+ wrapped(): void;
75
+ /** The call's receipt completion settled; logs once and disarms. */
76
+ settled(outcome: 'recorded' | 'failed'): void;
77
+ };
78
+
79
+ export type FencedCallDiagnosticsBudget = {
80
+ /** Whether a new fenced call's response/settlement lines are kept. */
81
+ admitCall(): boolean;
82
+ /** Counts an overdue call and says whether its warning is kept. */
83
+ admitOverdue(): { keep: boolean; seen: number };
84
+ };
85
+
86
+ export function createFencedCallDiagnosticsBudget(
87
+ limits: {
88
+ detailedCalls?: number;
89
+ overdueFirst?: number;
90
+ overdueEvery?: number;
91
+ } = {},
92
+ ): FencedCallDiagnosticsBudget {
93
+ const detailedCalls = limits.detailedCalls ?? FENCED_CALL_DETAILED_CALLS;
94
+ const overdueFirst = limits.overdueFirst ?? FENCED_CALL_OVERDUE_FIRST;
95
+ const overdueEvery = limits.overdueEvery ?? FENCED_CALL_OVERDUE_EVERY;
96
+ let calls = 0;
97
+ let overdue = 0;
98
+ return {
99
+ admitCall() {
100
+ calls += 1;
101
+ return calls <= detailedCalls;
102
+ },
103
+ admitOverdue() {
104
+ overdue += 1;
105
+ return {
106
+ keep: overdue <= overdueFirst || overdue % overdueEvery === 0,
107
+ seen: overdue,
108
+ };
109
+ },
110
+ };
111
+ }
112
+
113
+ /** The runner's internal diagnostic sink: stderr, never the run log. */
114
+ export function writeFencedCallDiagnostic(
115
+ line: FencedCallDiagnosticLine,
116
+ ): void {
117
+ console.warn(`${FENCED_CALL_DIAGNOSTIC_PREFIX} ${JSON.stringify(line)}`);
118
+ }
119
+
120
+ export function startFencedCallDiagnostics(input: {
121
+ tool: string;
122
+ callKeyHash: string;
123
+ attempt: number;
124
+ receiptWriter: 'call' | 'map' | 'none';
125
+ budget: FencedCallDiagnosticsBudget;
126
+ log?: (line: FencedCallDiagnosticLine) => void;
127
+ watchdogMs?: number;
128
+ }): FencedCallDiagnostics {
129
+ const watchdogMs = input.watchdogMs ?? FENCED_CALL_COMPLETION_WATCHDOG_MS;
130
+ const log = input.log ?? writeFencedCallDiagnostic;
131
+ const detailed = input.budget.admitCall();
132
+ const startedAtMs = Date.now();
133
+ let responses = 0;
134
+ let lastResponseAtMs: number | null = null;
135
+ let wrapped = false;
136
+ let watchdog: ReturnType<typeof setTimeout> | null = null;
137
+ let settled = false;
138
+
139
+ const line = (
140
+ event: FencedCallDiagnosticEvent,
141
+ level: 'info' | 'warn',
142
+ nowMs: number,
143
+ ): FencedCallDiagnosticLine => ({
144
+ event,
145
+ level,
146
+ tool: input.tool,
147
+ call_key_hash: input.callKeyHash,
148
+ attempt: input.attempt,
149
+ elapsed_ms: Math.max(0, nowMs - startedAtMs),
150
+ responses,
151
+ ...(lastResponseAtMs === null
152
+ ? {}
153
+ : { since_response_ms: Math.max(0, nowMs - lastResponseAtMs) }),
154
+ wrapped,
155
+ });
156
+ const disarm = () => {
157
+ if (watchdog === null) return;
158
+ clearTimeout(watchdog);
159
+ watchdog = null;
160
+ };
161
+ const emit = (value: FencedCallDiagnosticLine): void => {
162
+ // A diagnostic must never fail the call it describes.
163
+ try {
164
+ log(value);
165
+ } catch {
166
+ // The sink owns its own failure reporting.
167
+ }
168
+ };
169
+
170
+ return {
171
+ dispatched() {
172
+ if (settled) return;
173
+ disarm();
174
+ },
175
+ responseArrived() {
176
+ if (settled) return;
177
+ responses += 1;
178
+ const nowMs = Date.now();
179
+ lastResponseAtMs = nowMs;
180
+ if (detailed) emit(line('fenced_call_relay_response', 'info', nowMs));
181
+ disarm();
182
+ watchdog = setTimeout(() => {
183
+ watchdog = null;
184
+ if (settled) return;
185
+ const admitted = input.budget.admitOverdue();
186
+ if (!admitted.keep) return;
187
+ emit({
188
+ ...line('fenced_call_completion_overdue', 'warn', Date.now()),
189
+ overdue_seen: admitted.seen,
190
+ });
191
+ }, watchdogMs);
192
+ (watchdog as { unref?: () => void }).unref?.();
193
+ },
194
+ wrapped() {
195
+ wrapped = true;
196
+ },
197
+ settled(outcome) {
198
+ if (settled) return;
199
+ settled = true;
200
+ disarm();
201
+ // A call that failed before any relay response is already reported by
202
+ // tool_call_failed; only a post-response settlement is news here.
203
+ if (!detailed || (outcome === 'failed' && responses === 0)) return;
204
+ emit({
205
+ ...line('fenced_call_receipt_settled', 'info', Date.now()),
206
+ outcome,
207
+ receipt_writer: input.receiptWriter,
208
+ });
209
+ },
210
+ };
211
+ }