footprintjs 14.0.0 → 14.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/AGENTS.md +2 -0
  2. package/README.md +2 -0
  3. package/dist/declared-attempts.js +34 -0
  4. package/dist/esm/declared-attempts.d.ts +4 -0
  5. package/dist/esm/declared-attempts.js +30 -0
  6. package/dist/esm/explain.d.ts +8 -0
  7. package/dist/esm/explain.js +64 -0
  8. package/dist/esm/index.d.ts +7 -1
  9. package/dist/esm/index.js +5 -1
  10. package/dist/esm/lib/attempt/declared.d.ts +9 -0
  11. package/dist/esm/lib/attempt/declared.js +153 -0
  12. package/dist/esm/lib/attempt/evidence.d.ts +2 -0
  13. package/dist/esm/lib/attempt/evidence.js +11 -1
  14. package/dist/esm/lib/attempt/outsideInputNames.d.ts +4 -0
  15. package/dist/esm/lib/attempt/outsideInputNames.js +54 -0
  16. package/dist/esm/lib/attempt/types.d.ts +36 -0
  17. package/dist/esm/lib/attempt/types.js +1 -1
  18. package/dist/esm/lib/builder/FlowChartBuilder.d.ts +27 -42
  19. package/dist/esm/lib/builder/FlowChartBuilder.js +45 -60
  20. package/dist/esm/lib/builder/namedDeclarations.d.ts +22 -0
  21. package/dist/esm/lib/builder/namedDeclarations.js +69 -0
  22. package/dist/esm/lib/builder/typedFlowChart.js +10 -3
  23. package/dist/esm/lib/builder/types.d.ts +8 -0
  24. package/dist/esm/lib/builder/types.js +1 -1
  25. package/dist/esm/lib/capture/absentEntries.js +24 -5
  26. package/dist/esm/lib/capture/explainCoverage.d.ts +62 -0
  27. package/dist/esm/lib/capture/explainCoverage.js +215 -0
  28. package/dist/esm/lib/capture/explainIdentity.d.ts +17 -0
  29. package/dist/esm/lib/capture/explainIdentity.js +50 -0
  30. package/dist/esm/lib/capture/explainOptions.d.ts +3 -0
  31. package/dist/esm/lib/capture/explainOptions.js +10 -0
  32. package/dist/esm/lib/capture/explainWitness.d.ts +24 -0
  33. package/dist/esm/lib/capture/explainWitness.js +31 -0
  34. package/dist/esm/lib/capture/historyData.d.ts +1 -0
  35. package/dist/esm/lib/capture/historyData.js +3 -1
  36. package/dist/esm/lib/capture/nativeCoverage.d.ts +4 -0
  37. package/dist/esm/lib/capture/nativeCoverage.js +8 -1
  38. package/dist/esm/lib/detach/boundary.d.ts +6 -0
  39. package/dist/esm/lib/detach/boundary.js +10 -0
  40. package/dist/esm/lib/detach/drivers/sendBeacon.js +4 -2
  41. package/dist/esm/lib/detach/drivers/workerThread.js +4 -2
  42. package/dist/esm/lib/detach/spawn.d.ts +3 -2
  43. package/dist/esm/lib/detach/spawn.js +6 -4
  44. package/dist/esm/lib/engine/executionResults.d.ts +21 -0
  45. package/dist/esm/lib/engine/executionResults.js +2 -0
  46. package/dist/esm/lib/engine/graph/StageNode.d.ts +4 -0
  47. package/dist/esm/lib/engine/graph/StageNode.js +26 -1
  48. package/dist/esm/lib/engine/graph/prefixNodeTree.d.ts +1 -1
  49. package/dist/esm/lib/engine/graph/prefixNodeTree.js +3 -2
  50. package/dist/esm/lib/engine/handlers/NodeResolver.d.ts +1 -1
  51. package/dist/esm/lib/engine/handlers/NodeResolver.js +11 -9
  52. package/dist/esm/lib/engine/handlers/ParallelForEachHandler.d.ts +1 -1
  53. package/dist/esm/lib/engine/handlers/ParallelForEachHandler.js +13 -8
  54. package/dist/esm/lib/engine/handlers/ResumeEntry.d.ts +1 -1
  55. package/dist/esm/lib/engine/handlers/ResumeEntry.js +7 -3
  56. package/dist/esm/lib/engine/handlers/RuntimeStructureManager.js +5 -1
  57. package/dist/esm/lib/engine/handlers/StageRunner.js +3 -1
  58. package/dist/esm/lib/engine/handlers/SubflowExecutor.d.ts +1 -1
  59. package/dist/esm/lib/engine/handlers/SubflowExecutor.js +45 -8
  60. package/dist/esm/lib/engine/handlers/handoff/fanout.js +4 -2
  61. package/dist/esm/lib/engine/handlers/handoff/input.js +7 -3
  62. package/dist/esm/lib/engine/handlers/mapperScope.js +10 -2
  63. package/dist/esm/lib/engine/handlers/outputHandoff.d.ts +1 -1
  64. package/dist/esm/lib/engine/handlers/outputHandoff.js +18 -4
  65. package/dist/esm/lib/engine/handlers/servedSubflowResults.d.ts +6 -4
  66. package/dist/esm/lib/engine/handlers/servedSubflowResults.js +43 -6
  67. package/dist/esm/lib/engine/narrative/CombinedNarrativeRecorder.d.ts +1 -1
  68. package/dist/esm/lib/engine/traversal/FlowchartTraverser.d.ts +1 -1
  69. package/dist/esm/lib/engine/traversal/FlowchartTraverser.js +10 -15
  70. package/dist/esm/lib/engine/traversal/continuationHop.d.ts +41 -0
  71. package/dist/esm/lib/engine/traversal/continuationHop.js +10 -0
  72. package/dist/esm/lib/engine/types.d.ts +12 -21
  73. package/dist/esm/lib/engine/types.js +2 -2
  74. package/dist/esm/lib/memory/StageContext.d.ts +18 -28
  75. package/dist/esm/lib/memory/StageContext.js +102 -138
  76. package/dist/esm/lib/memory/frameTypes.d.ts +2 -0
  77. package/dist/esm/lib/memory/frameTypes.js +1 -1
  78. package/dist/esm/lib/memory/retainedValue/index.d.ts +2 -1
  79. package/dist/esm/lib/memory/retainedValue/index.js +3 -2
  80. package/dist/esm/lib/memory/stageCallLifetime.d.ts +8 -0
  81. package/dist/esm/lib/memory/stageCallLifetime.js +26 -0
  82. package/dist/esm/lib/memory/stageOutsideInputs.d.ts +9 -0
  83. package/dist/esm/lib/memory/stageOutsideInputs.js +54 -0
  84. package/dist/esm/lib/memory/stageReadKeys.d.ts +7 -0
  85. package/dist/esm/lib/memory/stageReadKeys.js +17 -0
  86. package/dist/esm/lib/memory/stageSnapshot.d.ts +49 -0
  87. package/dist/esm/lib/memory/stageSnapshot.js +100 -0
  88. package/dist/esm/lib/reactive/arrayTraps.d.ts +1 -1
  89. package/dist/esm/lib/reactive/arrayTraps.js +50 -19
  90. package/dist/esm/lib/reactive/createTypedScope.js +46 -16
  91. package/dist/esm/lib/reactive/liveView.d.ts +6 -2
  92. package/dist/esm/lib/reactive/liveView.js +26 -8
  93. package/dist/esm/lib/reactive/nestedReads.d.ts +1 -1
  94. package/dist/esm/lib/reactive/nestedReads.js +7 -6
  95. package/dist/esm/lib/reactive/types.d.ts +2 -0
  96. package/dist/esm/lib/reactive/types.js +1 -1
  97. package/dist/esm/lib/reactive/writeTraps.d.ts +3 -2
  98. package/dist/esm/lib/reactive/writeTraps.js +12 -8
  99. package/dist/esm/lib/recorder/AttemptRecorder.d.ts +82 -0
  100. package/dist/esm/lib/recorder/AttemptRecorder.js +24 -7
  101. package/dist/esm/lib/recorder/ControlDepRecorder.d.ts +1 -1
  102. package/dist/esm/lib/recorder/attemptMetricRows.js +22 -1
  103. package/dist/esm/lib/recorder/attemptMetrics.d.ts +4 -1
  104. package/dist/esm/lib/recorder/attemptMetrics.js +19 -6
  105. package/dist/esm/lib/recorder/attemptMetricsTypes.d.ts +5 -0
  106. package/dist/esm/lib/recorder/attemptMetricsTypes.js +1 -1
  107. package/dist/esm/lib/recorder/attemptOTel.js +22 -12
  108. package/dist/esm/lib/runner/ExecutionRuntime.d.ts +11 -7
  109. package/dist/esm/lib/runner/ExecutionRuntime.js +50 -7
  110. package/dist/esm/lib/runner/FlowChartExecutor.d.ts +1 -0
  111. package/dist/esm/lib/runner/FlowChartExecutor.js +10 -4
  112. package/dist/esm/lib/runner/RunLease.d.ts +1 -0
  113. package/dist/esm/lib/runner/RunLease.js +4 -1
  114. package/dist/esm/lib/runner/RunnableChart.d.ts +10 -5
  115. package/dist/esm/lib/runner/RunnableChart.js +105 -25
  116. package/dist/esm/lib/runner/attach.js +4 -2
  117. package/dist/esm/lib/runner/captureHistory.js +2 -2
  118. package/dist/esm/lib/runner/describeChart.d.ts +25 -0
  119. package/dist/esm/lib/runner/describeChart.js +145 -0
  120. package/dist/esm/lib/runner/nativeClosure/record.js +2 -2
  121. package/dist/esm/lib/runner/options.d.ts +2 -0
  122. package/dist/esm/lib/runner/options.js +6 -1
  123. package/dist/esm/lib/runner/resume.js +4 -2
  124. package/dist/esm/lib/runner/snapshot.js +15 -6
  125. package/dist/esm/lib/scope/ScopeFacade.d.ts +8 -2
  126. package/dist/esm/lib/scope/ScopeFacade.js +32 -17
  127. package/dist/esm/lib/scope/runtime.d.ts +3 -0
  128. package/dist/esm/lib/scope/runtime.js +9 -1
  129. package/dist/esm/lib/sinks/fileSink.d.ts +17 -1
  130. package/dist/esm/lib/sinks/fileSink.js +136 -67
  131. package/dist/esm/lib/sinks/indexedAdmission.d.ts +6 -1
  132. package/dist/esm/lib/sinks/indexedAdmission.js +30 -7
  133. package/dist/esm/lib/sinks/indexedIO.js +4 -2
  134. package/dist/esm/lib/sinks/indexedRecordFile.js +29 -108
  135. package/dist/esm/lib/sinks/indexedScan.js +3 -9
  136. package/dist/esm/lib/sinks/indexedSession.d.ts +29 -0
  137. package/dist/esm/lib/sinks/indexedSession.js +105 -0
  138. package/dist/esm/lib/sinks/publishedRecordFile.d.ts +40 -0
  139. package/dist/esm/lib/sinks/publishedRecordFile.js +106 -0
  140. package/dist/esm/lib/sinks/publishedRecordIndex.d.ts +8 -0
  141. package/dist/esm/lib/sinks/publishedRecordIndex.js +98 -0
  142. package/dist/esm/lib/sinks/publishedRecordRows.d.ts +13 -0
  143. package/dist/esm/lib/sinks/publishedRecordRows.js +188 -0
  144. package/dist/esm/lib/sinks/publishedRecordSelection.d.ts +21 -0
  145. package/dist/esm/lib/sinks/publishedRecordSelection.js +69 -0
  146. package/dist/esm/lib/sinks/publishedRecordWriter.d.ts +49 -0
  147. package/dist/esm/lib/sinks/publishedRecordWriter.js +237 -0
  148. package/dist/esm/sinks.d.ts +5 -0
  149. package/dist/esm/sinks.js +3 -1
  150. package/dist/explain.js +69 -0
  151. package/dist/index.js +10 -3
  152. package/dist/lib/attempt/declared.js +158 -0
  153. package/dist/lib/attempt/evidence.js +13 -2
  154. package/dist/lib/attempt/outsideInputNames.js +59 -0
  155. package/dist/lib/attempt/types.js +1 -1
  156. package/dist/lib/builder/FlowChartBuilder.js +59 -74
  157. package/dist/lib/builder/namedDeclarations.js +74 -0
  158. package/dist/lib/builder/typedFlowChart.js +10 -3
  159. package/dist/lib/builder/types.js +1 -1
  160. package/dist/lib/capture/absentEntries.js +24 -5
  161. package/dist/lib/capture/explainCoverage.js +220 -0
  162. package/dist/lib/capture/explainIdentity.js +57 -0
  163. package/dist/lib/capture/explainOptions.js +15 -0
  164. package/dist/lib/capture/explainWitness.js +37 -0
  165. package/dist/lib/capture/historyData.js +3 -1
  166. package/dist/lib/capture/nativeCoverage.js +8 -1
  167. package/dist/lib/detach/boundary.js +15 -0
  168. package/dist/lib/detach/drivers/sendBeacon.js +4 -2
  169. package/dist/lib/detach/drivers/workerThread.js +4 -2
  170. package/dist/lib/detach/spawn.js +6 -4
  171. package/dist/lib/engine/executionResults.js +3 -0
  172. package/dist/lib/engine/graph/StageNode.js +28 -2
  173. package/dist/lib/engine/graph/prefixNodeTree.js +3 -2
  174. package/dist/lib/engine/handlers/NodeResolver.js +11 -9
  175. package/dist/lib/engine/handlers/ParallelForEachHandler.js +13 -8
  176. package/dist/lib/engine/handlers/ResumeEntry.js +7 -3
  177. package/dist/lib/engine/handlers/RuntimeStructureManager.js +5 -1
  178. package/dist/lib/engine/handlers/StageRunner.js +3 -1
  179. package/dist/lib/engine/handlers/SubflowExecutor.js +44 -7
  180. package/dist/lib/engine/handlers/handoff/fanout.js +4 -2
  181. package/dist/lib/engine/handlers/handoff/input.js +7 -3
  182. package/dist/lib/engine/handlers/mapperScope.js +10 -2
  183. package/dist/lib/engine/handlers/outputHandoff.js +18 -4
  184. package/dist/lib/engine/handlers/servedSubflowResults.js +45 -7
  185. package/dist/lib/engine/traversal/FlowchartTraverser.js +13 -18
  186. package/dist/lib/engine/traversal/continuationHop.js +14 -0
  187. package/dist/lib/engine/types.js +2 -2
  188. package/dist/lib/memory/StageContext.js +117 -153
  189. package/dist/lib/memory/frameTypes.js +1 -1
  190. package/dist/lib/memory/retainedValue/index.js +3 -2
  191. package/dist/lib/memory/stageCallLifetime.js +31 -0
  192. package/dist/lib/memory/stageOutsideInputs.js +62 -0
  193. package/dist/lib/memory/stageReadKeys.js +21 -0
  194. package/dist/lib/memory/stageSnapshot.js +105 -0
  195. package/dist/lib/reactive/arrayTraps.js +49 -18
  196. package/dist/lib/reactive/createTypedScope.js +46 -16
  197. package/dist/lib/reactive/liveView.js +28 -9
  198. package/dist/lib/reactive/nestedReads.js +7 -6
  199. package/dist/lib/reactive/types.js +1 -1
  200. package/dist/lib/reactive/writeTraps.js +12 -8
  201. package/dist/lib/recorder/AttemptRecorder.js +23 -6
  202. package/dist/lib/recorder/attemptMetricRows.js +22 -1
  203. package/dist/lib/recorder/attemptMetrics.js +22 -7
  204. package/dist/lib/recorder/attemptMetricsTypes.js +1 -1
  205. package/dist/lib/recorder/attemptOTel.js +21 -11
  206. package/dist/lib/runner/ExecutionRuntime.js +50 -7
  207. package/dist/lib/runner/FlowChartExecutor.js +10 -4
  208. package/dist/lib/runner/RunLease.js +4 -1
  209. package/dist/lib/runner/RunnableChart.js +105 -25
  210. package/dist/lib/runner/attach.js +3 -1
  211. package/dist/lib/runner/captureHistory.js +2 -2
  212. package/dist/lib/runner/describeChart.js +150 -0
  213. package/dist/lib/runner/nativeClosure/record.js +2 -2
  214. package/dist/lib/runner/options.js +6 -1
  215. package/dist/lib/runner/resume.js +4 -2
  216. package/dist/lib/runner/snapshot.js +15 -6
  217. package/dist/lib/scope/ScopeFacade.js +31 -16
  218. package/dist/lib/scope/runtime.js +12 -2
  219. package/dist/lib/sinks/fileSink.js +140 -68
  220. package/dist/lib/sinks/indexedAdmission.js +34 -8
  221. package/dist/lib/sinks/indexedIO.js +4 -2
  222. package/dist/lib/sinks/indexedRecordFile.js +28 -107
  223. package/dist/lib/sinks/indexedScan.js +2 -8
  224. package/dist/lib/sinks/indexedSession.js +109 -0
  225. package/dist/lib/sinks/publishedRecordFile.js +110 -0
  226. package/dist/lib/sinks/publishedRecordIndex.js +103 -0
  227. package/dist/lib/sinks/publishedRecordRows.js +192 -0
  228. package/dist/lib/sinks/publishedRecordSelection.js +75 -0
  229. package/dist/lib/sinks/publishedRecordWriter.js +241 -0
  230. package/dist/sinks.js +6 -2
  231. package/dist/types/declared-attempts.d.ts +4 -0
  232. package/dist/types/explain.d.ts +8 -0
  233. package/dist/types/index.d.ts +7 -1
  234. package/dist/types/lib/attempt/declared.d.ts +9 -0
  235. package/dist/types/lib/attempt/evidence.d.ts +2 -0
  236. package/dist/types/lib/attempt/outsideInputNames.d.ts +4 -0
  237. package/dist/types/lib/attempt/types.d.ts +36 -0
  238. package/dist/types/lib/builder/FlowChartBuilder.d.ts +27 -42
  239. package/dist/types/lib/builder/namedDeclarations.d.ts +22 -0
  240. package/dist/types/lib/builder/types.d.ts +8 -0
  241. package/dist/types/lib/capture/explainCoverage.d.ts +62 -0
  242. package/dist/types/lib/capture/explainIdentity.d.ts +17 -0
  243. package/dist/types/lib/capture/explainOptions.d.ts +3 -0
  244. package/dist/types/lib/capture/explainWitness.d.ts +24 -0
  245. package/dist/types/lib/capture/historyData.d.ts +1 -0
  246. package/dist/types/lib/capture/nativeCoverage.d.ts +4 -0
  247. package/dist/types/lib/detach/boundary.d.ts +6 -0
  248. package/dist/types/lib/detach/spawn.d.ts +3 -2
  249. package/dist/types/lib/engine/executionResults.d.ts +21 -0
  250. package/dist/types/lib/engine/graph/StageNode.d.ts +4 -0
  251. package/dist/types/lib/engine/graph/prefixNodeTree.d.ts +1 -1
  252. package/dist/types/lib/engine/handlers/NodeResolver.d.ts +1 -1
  253. package/dist/types/lib/engine/handlers/ParallelForEachHandler.d.ts +1 -1
  254. package/dist/types/lib/engine/handlers/ResumeEntry.d.ts +1 -1
  255. package/dist/types/lib/engine/handlers/SubflowExecutor.d.ts +1 -1
  256. package/dist/types/lib/engine/handlers/outputHandoff.d.ts +1 -1
  257. package/dist/types/lib/engine/handlers/servedSubflowResults.d.ts +6 -4
  258. package/dist/types/lib/engine/narrative/CombinedNarrativeRecorder.d.ts +1 -1
  259. package/dist/types/lib/engine/traversal/FlowchartTraverser.d.ts +1 -1
  260. package/dist/types/lib/engine/traversal/continuationHop.d.ts +41 -0
  261. package/dist/types/lib/engine/types.d.ts +12 -21
  262. package/dist/types/lib/memory/StageContext.d.ts +18 -28
  263. package/dist/types/lib/memory/frameTypes.d.ts +2 -0
  264. package/dist/types/lib/memory/retainedValue/index.d.ts +2 -1
  265. package/dist/types/lib/memory/stageCallLifetime.d.ts +8 -0
  266. package/dist/types/lib/memory/stageOutsideInputs.d.ts +9 -0
  267. package/dist/types/lib/memory/stageReadKeys.d.ts +7 -0
  268. package/dist/types/lib/memory/stageSnapshot.d.ts +49 -0
  269. package/dist/types/lib/reactive/arrayTraps.d.ts +1 -1
  270. package/dist/types/lib/reactive/liveView.d.ts +6 -2
  271. package/dist/types/lib/reactive/nestedReads.d.ts +1 -1
  272. package/dist/types/lib/reactive/types.d.ts +2 -0
  273. package/dist/types/lib/reactive/writeTraps.d.ts +3 -2
  274. package/dist/types/lib/recorder/AttemptRecorder.d.ts +82 -0
  275. package/dist/types/lib/recorder/ControlDepRecorder.d.ts +1 -1
  276. package/dist/types/lib/recorder/attemptMetrics.d.ts +4 -1
  277. package/dist/types/lib/recorder/attemptMetricsTypes.d.ts +5 -0
  278. package/dist/types/lib/runner/ExecutionRuntime.d.ts +11 -7
  279. package/dist/types/lib/runner/FlowChartExecutor.d.ts +1 -0
  280. package/dist/types/lib/runner/RunLease.d.ts +1 -0
  281. package/dist/types/lib/runner/RunnableChart.d.ts +10 -5
  282. package/dist/types/lib/runner/describeChart.d.ts +25 -0
  283. package/dist/types/lib/runner/options.d.ts +2 -0
  284. package/dist/types/lib/scope/ScopeFacade.d.ts +8 -2
  285. package/dist/types/lib/scope/runtime.d.ts +3 -0
  286. package/dist/types/lib/sinks/fileSink.d.ts +17 -1
  287. package/dist/types/lib/sinks/indexedAdmission.d.ts +6 -1
  288. package/dist/types/lib/sinks/indexedSession.d.ts +29 -0
  289. package/dist/types/lib/sinks/publishedRecordFile.d.ts +40 -0
  290. package/dist/types/lib/sinks/publishedRecordIndex.d.ts +8 -0
  291. package/dist/types/lib/sinks/publishedRecordRows.d.ts +13 -0
  292. package/dist/types/lib/sinks/publishedRecordSelection.d.ts +21 -0
  293. package/dist/types/lib/sinks/publishedRecordWriter.d.ts +49 -0
  294. package/dist/types/sinks.d.ts +5 -0
  295. package/package.json +30 -3
@@ -101,6 +101,8 @@ export interface SerializedPipelineStructure {
101
101
  * `retryAttempts`: `.tag()` is chained AFTER `onStageAdded` fires.
102
102
  */
103
103
  tags?: readonly string[];
104
+ /** Public names of outside inputs this stage declares, absent when undeclared. */
105
+ outsideInputs?: readonly string[];
104
106
  /**
105
107
  * STRUCTURE-ONLY: for a fork/selector/decider branch, the downstream stage
106
108
  * id its convergence `next` edge points to, instead of the shared next-stage
@@ -147,6 +149,8 @@ export interface FlowChartSpec {
147
149
  touches?: string;
148
150
  /** Declared tags on this stage, as-is (see `SerializedPipelineStructure.tags`). */
149
151
  tags?: readonly string[];
152
+ /** Public names of outside inputs declared on this stage. */
153
+ outsideInputs?: readonly string[];
150
154
  }
151
155
  /**
152
156
  * Options-bag argument shape for the `flowChart()` factory.
@@ -195,6 +199,8 @@ export interface FlowChartOptions {
195
199
  * recording carries its own milestones. See `FlowChartBuilder.tag`.
196
200
  */
197
201
  tags?: readonly string[];
202
+ /** Public names of outside inputs the chart's first stage takes. */
203
+ outsideInputs?: readonly string[];
198
204
  }
199
205
  export type FlowChart<TOut = any, TScope = any> = {
200
206
  root: StageNode<TOut, TScope>;
@@ -227,6 +233,8 @@ export type SimplifiedParallelSpec<TOut = any, TScope = any> = {
227
233
  touches?: StageTouches;
228
234
  /** Declared tags for this fork child — each child's bundle carries its own. */
229
235
  tags?: readonly string[];
236
+ /** Public names of outside inputs this fork child takes. */
237
+ outsideInputs?: readonly string[];
230
238
  };
231
239
  export type ExecOptions = {
232
240
  defaults?: unknown;
@@ -0,0 +1,62 @@
1
+ import type { LogAddress } from 'foottrace';
2
+ import type { CaptureChannelStatus, NativeCaptureNote } from './nativeCoverage.js';
3
+ import type { EngineReadSources } from './readSources.js';
4
+ import type { FanoutCollections } from './subflowHandoff.js';
5
+ type Mode = 'full' | 'summary' | 'delta' | 'reads-prefix' | 'on' | 'off' | 'unknown';
6
+ type Status = 'collected' | 'disabled' | 'partial' | 'failed' | 'unknown';
7
+ export type ExplainCaptureReason = 'redacted' | 'budget-exhausted' | 'capture-failed' | 'missing-evidence' | 'missing-child' | 'unsupported-scope' | 'worker-boundary' | 'transport-boundary' | 'interval-incomplete' | 'unverified';
8
+ declare const channels: readonly ["reads", "writes", "commitWrites", "writePrefixes", "nestedReads", "readSources", "inputHandoff", "outputHandoff", "fanoutHandoff", "attention", "control"];
9
+ type Channel = (typeof channels)[number];
10
+ declare const handoffs: readonly ["inputHandoff", "outputHandoff", "fanoutHandoff"];
11
+ type ChannelNote = Readonly<{
12
+ mode: Mode;
13
+ status: Status;
14
+ reasons: readonly ExplainCaptureReason[];
15
+ }>;
16
+ /** Memory-only observations for one admitted native log segment. */
17
+ export interface ExplainCaptureNote {
18
+ readonly version: 3;
19
+ readonly scope: 'log';
20
+ readonly runId: string;
21
+ readonly logAddress: LogAddress;
22
+ readonly commits: {
23
+ readonly from: number;
24
+ readonly to: number;
25
+ };
26
+ readonly boundary: NativeCaptureNote['boundary'];
27
+ readonly persistence: 'memory-only';
28
+ readonly channels: Readonly<Record<Channel, ChannelNote>>;
29
+ }
30
+ type GapStatus = Exclude<Status, 'collected' | 'disabled'>;
31
+ interface Switches {
32
+ readonly nestedReads: boolean;
33
+ readonly readSources: boolean;
34
+ readonly inputHandoff: boolean;
35
+ readonly outputHandoff: boolean;
36
+ readonly fanoutHandoff: boolean;
37
+ }
38
+ export type ExplainCaptureFactory = (switches: Switches) => ExplainCapture;
39
+ export declare function createExplainCapture(switches: Switches): ExplainCapture;
40
+ /** @internal Bounded fixed-vocabulary facts, accumulated at the native owners of this log. */
41
+ export declare class ExplainCapture {
42
+ private readonly switches;
43
+ private readonly observations;
44
+ private readonly observedHandoffs;
45
+ private untrackedNestedRead;
46
+ /** One gap per log, regardless of how many stages or doors expose the values. */
47
+ readonly noteUntrackedNestedRead: () => void;
48
+ constructor(switches: Switches);
49
+ fork(): ExplainCapture;
50
+ mark(channel: Channel, reason: ExplainCaptureReason, status?: GapStatus): void;
51
+ privacy(write: boolean, nested?: boolean): void;
52
+ boundary(reason: 'worker-boundary' | 'transport-boundary' | 'missing-child'): void;
53
+ handoff(channel: (typeof handoffs)[number], descriptor: {
54
+ readonly limitations: readonly string[];
55
+ } | undefined): void;
56
+ snapshot(note: NativeCaptureNote, sources: EngineReadSources | undefined, fanout: FanoutCollections | undefined, control: CaptureChannelStatus, serving: Readonly<{
57
+ redact: boolean;
58
+ activePrivacy: boolean;
59
+ hideFailureStage: boolean;
60
+ }>): ExplainCaptureNote;
61
+ }
62
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { LogAddress } from 'foottrace';
2
+ import type { ExplainCaptureNote } from './explainCoverage.js';
3
+ interface IdentityRedaction {
4
+ isInert(): boolean;
5
+ retainBoundary<T>(record: T, placeholder?: string): T;
6
+ }
7
+ /** A live policy limits every enabled channel, even for a log that has already ended. */
8
+ export declare function applyExplainPrivacy(note: ExplainCaptureNote): ExplainCaptureNote;
9
+ /** A served v3 note is only useful while its entire bound identity is visible. */
10
+ export declare function hidesExplainIdentity(rule: IdentityRedaction | undefined, runId: string, logAddress: LogAddress): boolean;
11
+ export declare function hidesExplainFailureStage(rule: IdentityRedaction | undefined, stage: Readonly<{
12
+ runId: string;
13
+ runtimeStageId: string;
14
+ }> | undefined): boolean;
15
+ /** A parent can acquire another privacy mark after a child finished. Keep its category but not the stage. */
16
+ export declare function redactLateExplainFailureStage(note: ExplainCaptureNote, rule: IdentityRedaction | undefined): ExplainCaptureNote;
17
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { ExplainCaptureFactory } from './explainCoverage.js';
2
+ export declare function markExplainOptions<T extends object>(options: T, factory: ExplainCaptureFactory): T;
3
+ export declare function explainOptionsFor(options: object): ExplainCaptureFactory | undefined;
@@ -0,0 +1,24 @@
1
+ import type { LogAddress } from 'foottrace';
2
+ import type { NativeCapture, NativeCaptureNote } from './nativeCoverage.js';
3
+ export interface ExplainCaptureWitness {
4
+ readonly logAddress: LogAddress;
5
+ readonly runId: string;
6
+ readonly commits: {
7
+ readonly from: number;
8
+ readonly to: number;
9
+ };
10
+ readonly boundary: NativeCaptureNote['boundary']['status'];
11
+ readonly source: 'live';
12
+ }
13
+ /**
14
+ * Get the native witness for an exact served snapshot or mounted subflow's
15
+ * `treeContext`. The engine associates this evidence with the live record.
16
+ * Copies and saved records do not carry that association.
17
+ */
18
+ export declare function captureWitnessOf(record: object): ExplainCaptureWitness | undefined;
19
+ /** Bind the engine's own capture facts to the object that serves this log. */
20
+ export declare function rememberCaptureWitness(record: {
21
+ readonly logAddress?: LogAddress;
22
+ }, capture: NativeCapture | undefined, to: number): void;
23
+ /** A redacted view of the same log can carry its existing admitted witness. */
24
+ export declare function shareCaptureWitness(source: object, served: object): void;
@@ -11,6 +11,7 @@ export declare function historyFailureReason(error: unknown, boundary: 'evidence
11
11
  /** @internal Preparation may retain object undefined before privacy; history keeps ordinary JSON omission. */
12
12
  export interface HistoryDataCopyOptions {
13
13
  readonly onOmitted?: (path: readonly string[]) => void;
14
+ readonly onCopiedObject?: (value: Record<string, unknown>, path: readonly string[]) => void;
14
15
  readonly preserveObjectUndefined?: boolean;
15
16
  }
16
17
  /** @internal Copy bounded inert data without invoking accessors, toJSON or application coercion. */
@@ -1,5 +1,6 @@
1
1
  import type { LogAddress } from 'foottrace';
2
2
  import type { TerminalFailureContext } from '../errors/terminalFailure.js';
3
+ import type { ExplainCapture } from './explainCoverage.js';
3
4
  /** @internal Shared observation vocabularies; producer, types and checkpoint reader use the same values. */
4
5
  export declare const CAPTURE_RETENTION_MODES: readonly ["full", "summary", "off", "unknown"];
5
6
  export declare const CAPTURE_COMMIT_VALUE_MODES: readonly ["full", "delta", "unknown"];
@@ -62,9 +63,12 @@ export declare class NativeCapture {
62
63
  readonly runId: string;
63
64
  readonly logAddress: LogAddress;
64
65
  readonly from: number;
66
+ explanation?: ExplainCapture;
67
+ noteBoundary(reason: 'worker-boundary' | 'transport-boundary' | 'missing-child'): void;
65
68
  private readonly gaps;
66
69
  private boundary;
67
70
  private readonly modes;
71
+ get boundaryStatus(): NativeCaptureNote['boundary']['status'];
68
72
  constructor(runId: string, logAddress: LogAddress, from: number, modes: NativeCaptureNote['modes']);
69
73
  limit(gap: CaptureLimitation): void;
70
74
  end(status: NativeCaptureNote['boundary']['status'], failure?: TerminalFailureContext): void;
@@ -0,0 +1,6 @@
1
+ export type DetachBoundaryReason = 'worker-boundary' | 'transport-boundary' | 'missing-child';
2
+ export interface DetachBoundaryObserver {
3
+ noteBoundary(reason: DetachBoundaryReason): void;
4
+ }
5
+ export declare function markDetachBoundary<T extends object>(driver: T, reason: Exclude<DetachBoundaryReason, 'missing-child'>): T;
6
+ export declare function detachBoundary(driver: object): DetachBoundaryReason;
@@ -25,6 +25,7 @@
25
25
  * safe across re-entrant detach calls
26
26
  */
27
27
  import type { FlowChart } from '../builder/types.js';
28
+ import { type DetachBoundaryObserver } from './boundary.js';
28
29
  import type { DetachDriver, DetachHandle } from './types.js';
29
30
  /** Reset the counter for tests — never call from production code. */
30
31
  export declare function _resetSpawnCounterForTests(): void;
@@ -45,7 +46,7 @@ export declare function _resetSpawnCounterForTests(): void;
45
46
  * parent's `runtimeStageId` from a stage caller, or `'__executor__'`
46
47
  * from a bare-executor caller.
47
48
  */
48
- export declare function detachAndJoinLater(driver: DetachDriver, child: FlowChart, input: unknown, sourcePrefix: string): DetachHandle;
49
+ export declare function detachAndJoinLater(driver: DetachDriver, child: FlowChart, input: unknown, sourcePrefix: string, observer?: DetachBoundaryObserver): DetachHandle;
49
50
  /**
50
51
  * Same as `detachAndJoinLater` but discards the handle. Use when the
51
52
  * caller doesn't care about the result and doesn't need to await — e.g.,
@@ -60,6 +61,6 @@ export declare function detachAndJoinLater(driver: DetachDriver, child: FlowChar
60
61
  * state (the driver does that). They just go unobserved unless something
61
62
  * else (a recorder, logging) is wired to surface them.
62
63
  */
63
- export declare function detachAndForget(driver: DetachDriver, child: FlowChart, input: unknown, sourcePrefix: string): void;
64
+ export declare function detachAndForget(driver: DetachDriver, child: FlowChart, input: unknown, sourcePrefix: string, observer?: DetachBoundaryObserver): void;
64
65
  /** The name a late detach is recorded under: the child chart's root id — a name, never its input. */
65
66
  export declare function detachKey(child: FlowChart): string;
@@ -0,0 +1,21 @@
1
+ import type { FlowchartCheckpoint } from '../pause/types.js';
2
+ export type NodeResultType = {
3
+ id: string;
4
+ result: unknown;
5
+ isError?: boolean;
6
+ };
7
+ export type BranchResult = {
8
+ result: string | Error;
9
+ isError: boolean;
10
+ };
11
+ export type BranchResults = {
12
+ [branchId: string]: BranchResult;
13
+ };
14
+ export type TraversalResult = BranchResults | string | Error;
15
+ /** Returned by run()/resume() when execution pauses. */
16
+ export type PausedResult = {
17
+ readonly paused: true;
18
+ readonly checkpoint: FlowchartCheckpoint;
19
+ };
20
+ /** Full return type of FlowChartExecutor.run() and resume(). */
21
+ export type ExecutorResult = TraversalResult | PausedResult;
@@ -108,6 +108,8 @@ export type StageNode<TOut = any, TScope = any> = {
108
108
  * branch-segment marker. See `FlowChartBuilder.tag`.
109
109
  */
110
110
  tags?: readonly string[];
111
+ /** Public names declared by the author for this stage's outside inputs. */
112
+ outsideInputs?: readonly string[];
111
113
  /** When true, this stage can pause execution (PausableHandler pattern). */
112
114
  isPausable?: boolean;
113
115
  /** Resume function — called instead of fn when resuming a paused stage. */
@@ -150,3 +152,5 @@ export type StageNode<TOut = any, TScope = any> = {
150
152
  * Safely handles proxy objects (e.g., Zod scope) that may throw on property access.
151
153
  */
152
154
  export declare function isStageNodeReturn(output: unknown): output is StageNode;
155
+ /** Shallow spread semantics, with outside-input evidence taken only from an own data slot. */
156
+ export declare function copyStageNode<N extends StageNode>(node: N): N;
@@ -22,5 +22,5 @@
22
22
  * `child.branchId ?? child.id`. The input is never mutated (each node is a
23
23
  * shallow clone).
24
24
  */
25
- import type { StageNode } from './StageNode.js';
25
+ import { type StageNode } from './StageNode.js';
26
26
  export declare function prefixNodeTree<N extends StageNode<any, any>>(node: N, prefix: string): N;
@@ -5,7 +5,7 @@
5
5
  * - Find nodes by ID via recursive depth-first search (for back-edge/loop support)
6
6
  * - Resolve subflow reference nodes to actual subflow structures
7
7
  */
8
- import type { StageNode } from '../graph/StageNode.js';
8
+ import { type StageNode } from '../graph/StageNode.js';
9
9
  import type { HandlerDeps } from '../types.js';
10
10
  export declare class NodeResolver<TOut = any, TScope = any> {
11
11
  private deps;
@@ -1,5 +1,5 @@
1
1
  import type { StageContext } from '../../memory/StageContext.js';
2
- import type { StageNode } from '../graph/StageNode.js';
2
+ import { type StageNode } from '../graph/StageNode.js';
3
3
  import type { TraversalContext } from '../narrative/types.js';
4
4
  import type { BranchChart, HandlerDeps } from '../types.js';
5
5
  import type { ChildrenExecutor } from './ChildrenExecutor.js';
@@ -63,7 +63,7 @@
63
63
  */
64
64
  import type { PendingPause } from '../../pause/types.js';
65
65
  import { PauseSignal } from '../../pause/types.js';
66
- import type { StageNode } from '../graph/StageNode.js';
66
+ import { type StageNode } from '../graph/StageNode.js';
67
67
  /**
68
68
  * A parallel sibling's pause, queued at the level of its fan-out: raised
69
69
  * again there once the resumed child's chain ends (see {@link raiseQueuedPause}).
@@ -1,5 +1,5 @@
1
1
  import type { StageContext } from '../../memory/StageContext.js';
2
- import type { StageNode } from '../graph/StageNode.js';
2
+ import { type StageNode } from '../graph/StageNode.js';
3
3
  import type { TraversalContext } from '../narrative/types.js';
4
4
  import type { HandlerDeps, ReturnedSubflowDefinition, SubflowResult, SubflowTraverserFactory } from '../types.js';
5
5
  import type { BreakFlag } from './types.js';
@@ -27,7 +27,7 @@ export declare class OutputHandoff {
27
27
  private stopWrites?;
28
28
  constructor(parent: LogAddress, child: LogAddress, runtimeStageId: string, cutoff: number, rule: RedactionRule | undefined);
29
29
  /** Observe ordinary root gets on the fallback state copy, never arbitrary returned values. */
30
- view(state: Record<string, unknown>, explicitOutput: boolean): Record<string, unknown>;
30
+ view(state: Record<string, unknown>, explicitOutput: boolean, noteEscape?: () => void): Record<string, unknown>;
31
31
  watchWrites(context: StageContext): void;
32
32
  private read;
33
33
  private spend;
@@ -18,14 +18,16 @@
18
18
  * as ONE substituted result.
19
19
  */
20
20
  import type { SubflowCapturePort } from '../../capture/subflowCapability.js';
21
- import type { SubflowResult } from '../types.js';
21
+ import type { RedactionRule } from '../../memory/redaction.js';
22
+ import type { IExecutionRuntime, SubflowResult } from '../types.js';
23
+ export declare function rememberSubflowCapture(result: SubflowResult, runtime: IExecutionRuntime): void;
22
24
  /** Remember the served (mirror) state of a subflow result. Absent without a policy. */
23
25
  export declare function rememberRedactedSubflowState(result: SubflowResult, state: Record<string, unknown>): void;
24
26
  /**
25
- * The `subflowResults` record a snapshot serves. Plain: the traverser's own
26
- * records, as they are. Redacted: each result that remembers a mirror is
27
+ * The `subflowResults` record a snapshot serves. Both views apply the live
28
+ * policy to explain notes. Redacted: each result that remembers a mirror is
27
29
  * served as a copy whose `globalContext` IS that mirror — one copy per raw
28
30
  * result, so a mount's two keys still point at one object — and a result
29
31
  * without a mirror (no policy) is served as itself.
30
32
  */
31
- export declare function servedSubflowResults(results: ReadonlyMap<string, SubflowResult>, redact: boolean, capture?: SubflowCapturePort): Record<string, SubflowResult>;
33
+ export declare function servedSubflowResults(results: ReadonlyMap<string, SubflowResult>, redact: boolean, capture?: SubflowCapturePort, redaction?: RedactionRule, explainEnabled?: boolean): Record<string, SubflowResult>;
@@ -183,7 +183,7 @@ export declare class CombinedNarrativeRecorder implements CombinedRecorder {
183
183
  runtimeStageId?: string | undefined;
184
184
  stepNumber?: number | undefined;
185
185
  subflowId?: string | undefined;
186
- direction?: "exit" | "entry" | undefined;
186
+ direction?: "entry" | "exit" | undefined;
187
187
  key?: string | undefined;
188
188
  }[];
189
189
  };
@@ -381,7 +381,7 @@ export declare class FlowchartTraverser<TOut = any, TScope = any> {
381
381
  * Build an O(1) ID→node map from the root graph.
382
382
  * Used by NodeResolver to avoid repeated DFS on every loopTo() call.
383
383
  * Iterative worklist (no recursion) so arbitrarily long chains index fully;
384
- * the `map.has` guard handles cyclic refs. First-visited node wins per ID —
384
+ * the `map.has` guard handles cyclic refs. First concrete node wins per ID —
385
385
  * worklist order matches the old recursive pre-order (children, then next).
386
386
  * Dynamic subflows and lazy-resolved nodes are added to stageMap at runtime but not to this map —
387
387
  * those use the DFS fallback in NodeResolver.
@@ -0,0 +1,41 @@
1
+ import type { StageContext } from '../../memory/StageContext.js';
2
+ import type { StageNode } from '../types.js';
3
+ /**
4
+ * Trampoline brand — marks a continuation hop returned by `executeNodeStep`
5
+ * to the driver loop in `executeNode`. Internal engine symbol so a stage's own
6
+ * return value (which can be any object) can never be mistaken for a hop.
7
+ */
8
+ export declare const CONTINUE_HOP: unique symbol;
9
+ /**
10
+ * A flat continuation — "execute this node next, in this context" — returned
11
+ * by `executeNodeStep` for every TAIL continuation (linear `next`, loop
12
+ * edges, dynamic next, dynamic-subflow re-entry, no-continuation decider
13
+ * dispatch). The driver loop in `executeNode` consumes hops iteratively:
14
+ * `current = hop; continue;` — so neither the call stack nor the retained
15
+ * promise chain grows with chain length or loop iterations.
16
+ */
17
+ export interface ContinuationHop<TOut = any, TScope = any> {
18
+ readonly [CONTINUE_HOP]: true;
19
+ readonly node: StageNode<TOut, TScope>;
20
+ readonly context: StageContext;
21
+ readonly branchPath: string | undefined;
22
+ /**
23
+ * Present when the hop is a decider's branch dispatch (decider without its
24
+ * own `next`). The driver records it so a PauseSignal thrown anywhere in
25
+ * the continued chain still gets the decider stamped as its invoker —
26
+ * exactly what the recursive dispatch's catch used to do.
27
+ */
28
+ readonly invokerStamp?: InvokerStamp;
29
+ /**
30
+ * Present when the hop follows a LOOP edge (a back-reference resolved by
31
+ * `ContinuationResolver`). A decider's branch frame hands such a hop back
32
+ * to its decider when the target is not a node the frame ran, so the loop
33
+ * re-enters at the target's own level — flat, never one frame per pass.
34
+ */
35
+ readonly loop?: true;
36
+ }
37
+ /** Pause-invoker context recorded by the driver for flat decider dispatches. */
38
+ export interface InvokerStamp {
39
+ readonly invokerStageId: string;
40
+ }
41
+ export declare function isContinuationHop<TOut, TScope>(value: unknown): value is ContinuationHop<TOut, TScope>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * types.ts — All type definitions for the engine library.
2
+ * types.ts — Type definitions and re-exports for the engine library.
3
3
  *
4
4
  * Centralizes type definitions to avoid circular dependencies.
5
5
  * Every handler receives HandlerDeps (the DI bag) instead of importing the traverser.
@@ -10,6 +10,7 @@ import type { FlowControlType, FlowMessage } from '../memory/frameTypes.js';
10
10
  import type { NativeMappingBinding } from '../memory/RunFrame.js';
11
11
  import type { StageContext } from '../memory/StageContext.js';
12
12
  import type { ScopeProtectionMode } from '../scope/protection/types.js';
13
+ import type { TraversalResult } from './executionResults.js';
13
14
  import type { StageNode } from './graph/StageNode.js';
14
15
  import type { QueuedPause, ResumeEntry } from './handlers/ResumeEntry.js';
15
16
  import type { IControlFlowNarrative } from './narrative/types.js';
@@ -248,6 +249,8 @@ export interface SubflowMountOptions<TParentScope = any, TSubflowInput = any, TS
248
249
  * ```
249
250
  */
250
251
  tags?: readonly string[];
252
+ /** Public names of outside inputs the mount itself takes. Inner stages declare their own. */
253
+ outsideInputs?: readonly string[];
251
254
  }
252
255
  export interface SubflowResult {
253
256
  subflowId: string;
@@ -266,6 +269,7 @@ export interface SubflowResult {
266
269
  /** Native source book for this invocation's own log. Memory observation only; no parent receipt applies. */
267
270
  readonly fanoutCollections?: import('../capture/subflowHandoff.js').FanoutCollections;
268
271
  readonly readSources?: import('../capture/readSources.js').EngineReadSources;
272
+ readonly capture?: import('../capture/explainCoverage.js').ExplainCaptureNote;
269
273
  /** Identity of the local history, not its parent's log. */
270
274
  readonly logAddress?: LogAddress;
271
275
  /**
@@ -391,6 +395,10 @@ export interface IExecutionRuntime {
391
395
  };
392
396
  /** @internal O(1) observation of the native log's most recently landed handoff commit. */
393
397
  lastHandoffCommit?(): CommitBundle | undefined;
398
+ /** @internal Serve this runtime's own log note. Child control has no matching acknowledgement. */
399
+ explainSnapshot?(control?: undefined, redact?: boolean): import('../capture/explainCoverage.js').ExplainCaptureNote | undefined;
400
+ /** @internal Close the child observation without changing legacy notes or storage. */
401
+ finishChildExplanation?(status: 'completed' | 'paused' | 'failed' | 'cancelled', broken?: boolean, error?: unknown): void;
394
402
  /**
395
403
  * A fresh root frame on this runtime — its store, its log, the run's policy
396
404
  * and mirror (`ExecutionRuntime.newRoot`). `SubflowExecutor` swaps a
@@ -576,26 +584,7 @@ export interface RuntimeStructureMetadata {
576
584
  isLoopReference?: boolean;
577
585
  streamId?: string;
578
586
  }
579
- export type NodeResultType = {
580
- id: string;
581
- result: unknown;
582
- isError?: boolean;
583
- };
584
- export type BranchResult = {
585
- result: string | Error;
586
- isError: boolean;
587
- };
588
- export type BranchResults = {
589
- [branchId: string]: BranchResult;
590
- };
591
- export type TraversalResult = BranchResults | string | Error;
592
- /** Returned by run()/resume() when execution pauses. */
593
- export type PausedResult = {
594
- readonly paused: true;
595
- readonly checkpoint: import('../pause/types.js').FlowchartCheckpoint;
596
- };
597
- /** Full return type of FlowChartExecutor.run() and resume(). */
598
- export type ExecutorResult = TraversalResult | PausedResult;
587
+ export type { BranchResult, BranchResults, ExecutorResult, NodeResultType, PausedResult, TraversalResult, } from './executionResults.js';
599
588
  export interface SerializedPipelineNode {
600
589
  name: string;
601
590
  id: string;
@@ -639,6 +628,8 @@ export interface SerializedPipelineNode {
639
628
  * Absent when the stage declares none.
640
629
  */
641
630
  tags?: readonly string[];
631
+ /** Public names of outside inputs declared on this stage. */
632
+ outsideInputs?: readonly string[];
642
633
  }
643
634
  /** Alias for SerializedPipelineNode used as full structure */
644
635
  export type SerializedPipelineStructure = SerializedPipelineNode & {
@@ -13,7 +13,7 @@
13
13
  */
14
14
  import type { CommitPhase, EmitSourcePosition, UntrackedSource } from 'foottrace';
15
15
  import type { EventLog, SharedMemory } from 'foottrace/write';
16
- import type { AttemptContext, AttemptRecord, AttemptSummary, LateWrite } from '../attempt/types.js';
16
+ import type { AttemptContext, AttemptRecord, AttemptSummary, DeclaredWrite, DeclaredWriteObserver, LateWrite } from '../attempt/types.js';
17
17
  import type { NativeCapture } from '../capture/nativeCoverage.js';
18
18
  import type { NativeExtent } from '../capture/nativeExtent/collector.js';
19
19
  import type { EngineReadSourceCapture } from '../capture/readSources.js';
@@ -58,7 +58,7 @@ export declare class StageContext {
58
58
  private policy;
59
59
  /** The emitting frame's logical leg, never the mutable executor's current leg. */
60
60
  private emitRunId?;
61
- /** The native root-log collector; copied to same-log frames, never child runtimes. */
61
+ /** The native log collector, shared by frames in this log and segment. */
62
62
  capture?: NativeCapture;
63
63
  captureExtent?: NativeExtent;
64
64
  /** Source coverage, shared only by frames of this runtime. */
@@ -122,15 +122,10 @@ export declare class StageContext {
122
122
  private _pendingWrites?;
123
123
  /** Tracks user-level reads (pre-namespace) for the memory view. */
124
124
  private _stageReads;
125
- /**
126
- * The `_stageReads` keys that were read at a NESTED path (`getValue(path,
127
- * key)` with a non-empty `path`). Only the engine reads that way — the
128
- * facade reads roots — so these are not user reads and the borrowed-read
129
- * guard skips them by this marker, never by guessing from a dot in the key
130
- * (a user's top-level key may itself contain one). Lazily created; the
131
- * facade path never allocates it.
132
- */
125
+ /** The borrowed-read guard skips actual nested reads. A literal root key can contain a dot. */
133
126
  private _nestedReads?;
127
+ /** Original addresses for retained unset reads whose slots spell a nested path. */
128
+ private unsetNestedReads?;
134
129
  /** Which reads this frame has already kept: a read is kept once for each object a key holds (`keptReads.ts`). */
135
130
  private readonly keptReads;
136
131
  /**
@@ -225,6 +220,10 @@ export declare class StageContext {
225
220
  /** Value-free, execution-local observation of successfully staged write addresses. */
226
221
  private _stagedWriteObserver?;
227
222
  private _writeBoundaryObserver?;
223
+ /** Only the active native stage body may start or stage a dispatch. */
224
+ get declaredInvocationOpen(): boolean;
225
+ endDeclaredAttemptInvocation(): void;
226
+ useDeclaredWrites(observer: DeclaredWriteObserver): void;
228
227
  /** @internal Observe one mapper's writes without changing the record's encoding or reads. */
229
228
  observeStagedWrites(observer: (path: readonly string[]) => void, boundary?: (phase: 'committing' | 'landed') => void): () => void;
230
229
  constructor(runId: string, name: string, stageId: string, sharedMemory: SharedMemory, branchId?: string, eventLog?: EventLog, isDecider?: boolean);
@@ -366,7 +365,7 @@ export declare class StageContext {
366
365
  patch(path: string[], key: string, value: unknown, shouldRedact?: boolean): RedactionVerdict;
367
366
  set(path: string[], key: string, value: unknown): void;
368
367
  merge(path: string[], key: string, value: unknown, shouldRedact?: boolean): RedactionVerdict;
369
- setObject(path: string[], key: string, value: unknown, shouldRedact?: boolean, description?: string, operationOverride?: 'set' | 'delete'): RedactionVerdict;
368
+ setObject(path: string[], key: string, value: unknown, shouldRedact?: boolean, description?: string, operationOverride?: 'set' | 'delete', declared?: readonly DeclaredWrite[]): RedactionVerdict;
370
369
  updateObject(path: string[], key: string, value: unknown, description?: string, shouldRedact?: boolean): RedactionVerdict;
371
370
  setRoot(key: string, value: unknown): void;
372
371
  /** Root-level (un-namespaced) write — the subflow seed and merge-back path. */
@@ -446,10 +445,7 @@ export declare class StageContext {
446
445
  copyOfSelected(copy: unknown, value: unknown): void;
447
446
  /** What every tracked read keeps, once the value is in hand and its verdict known (see {@link getValue}). */
448
447
  private retainRead;
449
- /**
450
- * Keep what this read saw in {@link _stageReads}: once for each object a root key holds, not once for
451
- * each read of it. The rule, why it holds and what it leaves alone are in `keptReads.ts`.
452
- */
448
+ /** Retain what the read saw once per root object, as described in `keptReads.ts`. */
453
449
  private keepOnce;
454
450
  /**
455
451
  * How many tracked reads of this frame read a value the run's rule selects
@@ -590,9 +586,9 @@ export declare class StageContext {
590
586
  * context via `leaf.createNext`) never re-use a committed context.
591
587
  * - A USER handle held past its stage is a different matter: its writes
592
588
  * would land in a buffer nothing ever commits. That refusal lives on the
593
- * scope tier (`ScopeFacade`, sealed by the commit observer — 9.22.0),
594
- * because the frame's re-usability is exactly what the engine paths
595
- * above need.
589
+ * scope tier (`ScopeFacade`, sealed at the commit stamp for declared
590
+ * writes, otherwise by the commit observer). The engine paths above
591
+ * still need a reusable frame.
596
592
  * - `_stageWrites` / `_stageReads` are NOT released — `snapshotSelf()`
597
593
  * reads them post-run for the execution-tree snapshot.
598
594
  */
@@ -704,13 +700,7 @@ export declare class StageContext {
704
700
  get hasKeylessEffect(): boolean;
705
701
  /** Where this execution's call records are reported — the engine sets it before the stage runs. */
706
702
  useAttemptReporter(report: ((record: AttemptRecord, structuredError: StructuredErrorInfo | undefined) => void) | undefined): void;
707
- /**
708
- * The signal the calls of stage attempt `stageAttempt` run under besides its own (P2): aborted when that attempt is
709
- * over — however it ended — and when the frame commits, so no call outlives the attempt that made it (no
710
- * background retry, no wait, no listener left on the run's signal). Already aborted after the commit.
711
- */
712
703
  callsEndedSignal(stageAttempt: number): AbortSignal;
713
- /** End the calls of `stageAttempt` (every attempt's when `undefined`) — `reason` when the attempt's signal gave one. */
714
704
  private endCalls;
715
705
  /** The next call's ordinal within stage attempt `stageAttempt`, 1-based (`attempt/call.ts · callSeries`). */
716
706
  nextCallOrdinal(stageAttempt: number): number;
@@ -718,8 +708,9 @@ export declare class StageContext {
718
708
  * A call's (or an observed) attempt record: kept beside the stage's own attempts — the first
719
709
  * {@link MAX_CALL_RECORDS}, the rest counted — and reported to the run's `onAttempt` either way. Like the stage's
720
710
  * records, NOT cleared by {@link discardStaged}: a failed attempt's calls are evidence too.
711
+ * Only the native reporter can pair a retained row with the attempt whose callback began.
721
712
  */
722
- reportCallAttempt(record: AttemptRecord, structuredError: StructuredErrorInfo | undefined, evidence?: Readonly<Record<string, unknown>>): void;
713
+ reportCallAttempt(record: AttemptRecord, structuredError: StructuredErrorInfo | undefined, evidence?: Readonly<Record<string, unknown>>, nativeCallStarted?: boolean): void;
723
714
  /**
724
715
  * Create (or return) this context's linked successor.
725
716
  *
@@ -751,9 +742,8 @@ export declare class StageContext {
751
742
  iteration?: number;
752
743
  }): void;
753
744
  getStageId(): string;
754
- getSnapshot(): StageSnapshot;
755
- /** Snapshot of THIS context's own fields — `next`/`children` are filled
756
- * in by the iterative walk in `getSnapshot`. */
745
+ getSnapshot(redaction?: RedactionRule | undefined): StageSnapshot;
746
+ /** Keep the existing prototype slot pinned by the read-authority key checks. */
757
747
  private snapshotSelf;
758
748
  }
759
749
  export declare const observeOwnedContext: (owner: unknown) => boolean | undefined;
@@ -95,6 +95,8 @@ export type StageSnapshot = {
95
95
  * `'full'` (default), {@link ReadSummaryMarker}s under `'summary'`, absent
96
96
  * under `'off'`. */
97
97
  stageReads?: Record<string, unknown>;
98
+ /** Read names whose retained value is undefined. JSON keeps this list when it omits the map entries. */
99
+ undefinedReadKeys?: readonly string[];
98
100
  /** Native source-read totals across all attempts, only with an owned source book. No values or names. */
99
101
  readSourceCounts?: SourceReadCounts;
100
102
  /** Number of native stage-function entries, independent of read retention and ownership-list budgets. */
@@ -5,7 +5,8 @@ import { type RedactionVerdict } from '../redactionValues.js';
5
5
  * The form of a value the engine RETAINS (reads and writes retention):
6
6
  * the placeholder beats every dial; a field-level scrub happens before the
7
7
  * dial sees the value; a clear value is summarized or cloned as the dial
8
- * says. Callers handle `undefined` before asking.
8
+ * says. Read retention preserves `undefined` for clear and field verdicts
9
+ * before calling this helper. Write retention also passes undefined values here.
9
10
  */
10
11
  export declare function retainedForm(verdict: RedactionVerdict, value: unknown, mode: ReadTrackingMode | WriteTrackingMode, summarize: (value: unknown) => unknown): unknown;
11
12
  /**
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The signal the calls of stage attempt `stageAttempt` run under besides its own (P2): aborted when that attempt is
3
+ * over — however it ended — and when the frame commits, so no call outlives the attempt that made it (no
4
+ * background retry, no wait, no listener left on the run's signal). Already aborted after the commit.
5
+ */
6
+ export declare function callEndSignal(ended: Map<number, AbortController>, stageAttempt: number, committed: boolean): AbortSignal;
7
+ /** End the calls of `stageAttempt` (every attempt's when `undefined`) — `reason` when the attempt's signal gave one. */
8
+ export declare function endCallsFor(ended: Map<number, AbortController>, stageAttempt: number | undefined, reason?: unknown): void;
@@ -0,0 +1,9 @@
1
+ import type { OutsideInputs } from 'foottrace';
2
+ import type { StageContext } from './StageContext.js';
3
+ export declare function setDeclaredOutsideInputs(frame: StageContext, declared: readonly string[] | undefined): void;
4
+ /** Called before each native attempt invokes host work. A stage retry does not erase the earlier starts. */
5
+ export declare function noteNativeCallStarted(frame: StageContext): void;
6
+ /** Only a native callback's own row in the existing attempt budget can supply a target. */
7
+ export declare function recordNativeCallTarget(frame: StageContext, target: string): void;
8
+ export declare function outsideInputStamp(frame: StageContext): OutsideInputs | undefined;
9
+ export declare function clearOutsideInputs(frame: StageContext): void;