footprintjs 11.2.0 → 12.0.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 (369) hide show
  1. package/dist/esm/index.d.ts +4 -20
  2. package/dist/esm/index.js +2 -2
  3. package/dist/esm/lib/attempt/policy.d.ts +1 -1
  4. package/dist/esm/lib/attempt/policy.js +2 -2
  5. package/dist/esm/lib/attempt/types.d.ts +2 -1
  6. package/dist/esm/lib/attempt/types.js +1 -1
  7. package/dist/esm/lib/budget/timeBudget.d.ts +13 -5
  8. package/dist/esm/lib/budget/timeBudget.js +28 -13
  9. package/dist/esm/lib/builder/FlowChartBuilder.d.ts +74 -35
  10. package/dist/esm/lib/builder/FlowChartBuilder.js +164 -112
  11. package/dist/esm/lib/builder/index.d.ts +3 -2
  12. package/dist/esm/lib/builder/index.js +4 -3
  13. package/dist/esm/lib/builder/retryLoop.d.ts +1 -1
  14. package/dist/esm/lib/builder/retryLoop.js +1 -1
  15. package/dist/esm/lib/builder/structure/StructureRecorder.d.ts +11 -14
  16. package/dist/esm/lib/builder/structure/StructureRecorder.js +3 -4
  17. package/dist/esm/lib/builder/structure/StructureRecorderDispatcher.js +18 -3
  18. package/dist/esm/lib/builder/types.d.ts +5 -4
  19. package/dist/esm/lib/builder/types.js +4 -3
  20. package/dist/esm/lib/capture/checkpointCapture.d.ts +1 -0
  21. package/dist/esm/lib/capture/checkpointCapture.js +10 -4
  22. package/dist/esm/lib/capture/envelope.d.ts +6 -3
  23. package/dist/esm/lib/capture/envelope.js +25 -10
  24. package/dist/esm/lib/capture/historyNote.js +3 -3
  25. package/dist/esm/lib/capture/nativeCoverage.d.ts +6 -0
  26. package/dist/esm/lib/capture/nativeCoverage.js +11 -1
  27. package/dist/esm/lib/capture/policies.d.ts +2 -2
  28. package/dist/esm/lib/capture/policies.js +3 -3
  29. package/dist/esm/lib/capture/summarize.d.ts +2 -1
  30. package/dist/esm/lib/capture/summarize.js +36 -8
  31. package/dist/esm/lib/contract/schema.js +14 -5
  32. package/dist/esm/lib/decide/types.d.ts +11 -8
  33. package/dist/esm/lib/decide/types.js +1 -1
  34. package/dist/esm/lib/detach/drivers/batch.js +2 -15
  35. package/dist/esm/lib/detach/drivers/immediate.js +3 -2
  36. package/dist/esm/lib/detach/drivers/sendBeacon.d.ts +4 -4
  37. package/dist/esm/lib/detach/drivers/sendBeacon.js +7 -6
  38. package/dist/esm/lib/detach/drivers/workerThread.d.ts +20 -1
  39. package/dist/esm/lib/detach/drivers/workerThread.js +56 -12
  40. package/dist/esm/lib/detach/errors.d.ts +7 -0
  41. package/dist/esm/lib/detach/errors.js +21 -0
  42. package/dist/esm/lib/detach/registry.d.ts +19 -18
  43. package/dist/esm/lib/detach/registry.js +20 -19
  44. package/dist/esm/lib/detach/spawn.d.ts +1 -2
  45. package/dist/esm/lib/detach/spawn.js +2 -3
  46. package/dist/esm/lib/detach/types.d.ts +6 -5
  47. package/dist/esm/lib/detach/types.js +5 -4
  48. package/dist/esm/lib/engine/handlers/ChildrenExecutor.js +3 -2
  49. package/dist/esm/lib/engine/handlers/DeciderHandler.js +8 -2
  50. package/dist/esm/lib/engine/handlers/NodeResolver.d.ts +9 -1
  51. package/dist/esm/lib/engine/handlers/NodeResolver.js +15 -8
  52. package/dist/esm/lib/engine/handlers/ParallelForEachHandler.d.ts +6 -1
  53. package/dist/esm/lib/engine/handlers/ParallelForEachHandler.js +150 -58
  54. package/dist/esm/lib/engine/handlers/RuntimeStructureManager.d.ts +9 -1
  55. package/dist/esm/lib/engine/handlers/RuntimeStructureManager.js +28 -17
  56. package/dist/esm/lib/engine/handlers/SelectorHandler.js +10 -3
  57. package/dist/esm/lib/engine/handlers/SubflowExecutor.d.ts +4 -2
  58. package/dist/esm/lib/engine/handlers/SubflowExecutor.js +55 -17
  59. package/dist/esm/lib/engine/handlers/SubflowInputMapper.js +33 -15
  60. package/dist/esm/lib/engine/handlers/mapperEdits.d.ts +23 -0
  61. package/dist/esm/lib/engine/handlers/mapperEdits.js +95 -0
  62. package/dist/esm/lib/engine/handlers/mapperScope.d.ts +81 -0
  63. package/dist/esm/lib/engine/handlers/mapperScope.js +151 -0
  64. package/dist/esm/lib/engine/handlers/plainObject.d.ts +15 -0
  65. package/dist/esm/lib/engine/handlers/plainObject.js +21 -0
  66. package/dist/esm/lib/engine/handlers/selectionProblem.d.ts +9 -0
  67. package/dist/esm/lib/engine/handlers/selectionProblem.js +15 -0
  68. package/dist/esm/lib/engine/narrative/CombinedNarrativeRecorder.d.ts +4 -2
  69. package/dist/esm/lib/engine/narrative/CombinedNarrativeRecorder.js +18 -10
  70. package/dist/esm/lib/engine/narrative/FlowRecorderDispatcher.d.ts +2 -2
  71. package/dist/esm/lib/engine/narrative/FlowRecorderDispatcher.js +1 -1
  72. package/dist/esm/lib/engine/narrative/NarrativeFlowRecorder.d.ts +3 -5
  73. package/dist/esm/lib/engine/narrative/NarrativeFlowRecorder.js +8 -25
  74. package/dist/esm/lib/engine/narrative/formatting/ruleEvidence/index.js +10 -2
  75. package/dist/esm/lib/engine/narrative/recorders/AdaptiveNarrativeFlowRecorder.d.ts +5 -1
  76. package/dist/esm/lib/engine/narrative/recorders/AdaptiveNarrativeFlowRecorder.js +9 -5
  77. package/dist/esm/lib/engine/narrative/recorders/ManifestFlowRecorder.d.ts +9 -1
  78. package/dist/esm/lib/engine/narrative/recorders/ManifestFlowRecorder.js +27 -6
  79. package/dist/esm/lib/engine/narrative/recorders/MilestoneNarrativeFlowRecorder.d.ts +4 -0
  80. package/dist/esm/lib/engine/narrative/recorders/MilestoneNarrativeFlowRecorder.js +8 -1
  81. package/dist/esm/lib/engine/narrative/recorders/ProgressiveNarrativeFlowRecorder.d.ts +2 -0
  82. package/dist/esm/lib/engine/narrative/recorders/ProgressiveNarrativeFlowRecorder.js +6 -1
  83. package/dist/esm/lib/engine/narrative/recorders/SeparateNarrativeFlowRecorder.d.ts +1 -1
  84. package/dist/esm/lib/engine/narrative/recorders/SeparateNarrativeFlowRecorder.js +2 -2
  85. package/dist/esm/lib/engine/narrative/types.d.ts +1 -1
  86. package/dist/esm/lib/engine/narrative/types.js +1 -1
  87. package/dist/esm/lib/engine/traversal/FlowchartTraverser.d.ts +41 -44
  88. package/dist/esm/lib/engine/traversal/FlowchartTraverser.js +74 -27
  89. package/dist/esm/lib/engine/types.d.ts +14 -4
  90. package/dist/esm/lib/engine/types.js +1 -1
  91. package/dist/esm/lib/filter/evaluator.d.ts +6 -0
  92. package/dist/esm/lib/filter/evaluator.js +144 -20
  93. package/dist/esm/lib/ids/reservedIds.d.ts +2 -2
  94. package/dist/esm/lib/ids/reservedIds.js +3 -3
  95. package/dist/esm/lib/memory/StageContext.d.ts +140 -10
  96. package/dist/esm/lib/memory/StageContext.js +292 -36
  97. package/dist/esm/lib/memory/borrowedMutation.d.ts +18 -0
  98. package/dist/esm/lib/memory/borrowedMutation.js +40 -1
  99. package/dist/esm/lib/memory/frameTypes.d.ts +6 -4
  100. package/dist/esm/lib/memory/frameTypes.js +2 -2
  101. package/dist/esm/lib/memory/hiddenObjectTrail.d.ts +118 -0
  102. package/dist/esm/lib/memory/hiddenObjectTrail.js +221 -0
  103. package/dist/esm/lib/memory/keptReads.d.ts +62 -0
  104. package/dist/esm/lib/memory/keptReads.js +79 -0
  105. package/dist/esm/lib/memory/markPlaces.d.ts +98 -0
  106. package/dist/esm/lib/memory/markPlaces.js +124 -0
  107. package/dist/esm/lib/memory/pathTargets.d.ts +48 -0
  108. package/dist/esm/lib/memory/pathTargets.js +89 -0
  109. package/dist/esm/lib/memory/redaction.d.ts +142 -24
  110. package/dist/esm/lib/memory/redaction.js +276 -87
  111. package/dist/esm/lib/memory/retainedValue/index.js +13 -2
  112. package/dist/esm/lib/memory/runPolicy.d.ts +10 -8
  113. package/dist/esm/lib/memory/runPolicy.js +3 -3
  114. package/dist/esm/lib/memory/selectedObjects.d.ts +215 -0
  115. package/dist/esm/lib/memory/selectedObjects.js +603 -0
  116. package/dist/esm/lib/memory/servedPlaces.d.ts +41 -0
  117. package/dist/esm/lib/memory/servedPlaces.js +138 -0
  118. package/dist/esm/lib/observer-queue/index.d.ts +3 -2
  119. package/dist/esm/lib/observer-queue/index.js +4 -3
  120. package/dist/esm/lib/pause/types.d.ts +8 -6
  121. package/dist/esm/lib/pause/types.js +8 -6
  122. package/dist/esm/lib/reactive/allowlist.d.ts +12 -3
  123. package/dist/esm/lib/reactive/allowlist.js +17 -6
  124. package/dist/esm/lib/reactive/arrayTraps.d.ts +10 -2
  125. package/dist/esm/lib/reactive/arrayTraps.js +117 -19
  126. package/dist/esm/lib/reactive/createTypedScope.js +35 -9
  127. package/dist/esm/lib/reactive/handles.js +3 -5
  128. package/dist/esm/lib/reactive/jsonProjection.d.ts +4 -4
  129. package/dist/esm/lib/reactive/jsonProjection.js +7 -9
  130. package/dist/esm/lib/reactive/liveView.d.ts +4 -1
  131. package/dist/esm/lib/reactive/liveView.js +10 -3
  132. package/dist/esm/lib/reactive/structuralWrite.js +23 -5
  133. package/dist/esm/lib/reactive/types.d.ts +6 -0
  134. package/dist/esm/lib/reactive/types.js +1 -1
  135. package/dist/esm/lib/reactive/writeTraps.d.ts +20 -1
  136. package/dist/esm/lib/reactive/writeTraps.js +78 -6
  137. package/dist/esm/lib/recorder/AttemptRecorder.js +2 -2
  138. package/dist/esm/lib/recorder/BoundaryStateStore.d.ts +4 -2
  139. package/dist/esm/lib/recorder/BoundaryStateStore.js +9 -6
  140. package/dist/esm/lib/recorder/CombinedRecorder.d.ts +4 -3
  141. package/dist/esm/lib/recorder/CombinedRecorder.js +3 -3
  142. package/dist/esm/lib/recorder/CompositeRecorder.d.ts +1 -1
  143. package/dist/esm/lib/recorder/CompositeRecorder.js +1 -1
  144. package/dist/esm/lib/recorder/ControlDepRecorder.d.ts +1 -1
  145. package/dist/esm/lib/recorder/ControlDepRecorder.js +2 -2
  146. package/dist/esm/lib/recorder/EmitRecorder.d.ts +1 -1
  147. package/dist/esm/lib/recorder/EmitRecorder.js +2 -2
  148. package/dist/esm/lib/recorder/QualityRecorder.js +5 -2
  149. package/dist/esm/lib/recorder/TopologyRecorder.js +14 -7
  150. package/dist/esm/lib/runner/ExecutionRuntime.d.ts +2 -3
  151. package/dist/esm/lib/runner/ExecutionRuntime.js +3 -4
  152. package/dist/esm/lib/runner/FlowChartExecutor.d.ts +12 -5
  153. package/dist/esm/lib/runner/FlowChartExecutor.js +43 -22
  154. package/dist/esm/lib/runner/RunContext.d.ts +25 -3
  155. package/dist/esm/lib/runner/RunContext.js +14 -5
  156. package/dist/esm/lib/runner/RunnableChart.d.ts +10 -3
  157. package/dist/esm/lib/runner/RunnableChart.js +45 -25
  158. package/dist/esm/lib/runner/deadline.d.ts +1 -0
  159. package/dist/esm/lib/runner/deadline.js +1 -1
  160. package/dist/esm/lib/runner/options.d.ts +6 -6
  161. package/dist/esm/lib/runner/options.js +1 -1
  162. package/dist/esm/lib/runner/recordSink.js +4 -2
  163. package/dist/esm/lib/runner/snapshot.js +3 -3
  164. package/dist/esm/lib/runner/stringifySnapshot.d.ts +4 -3
  165. package/dist/esm/lib/runner/stringifySnapshot.js +38 -4
  166. package/dist/esm/lib/schema/detect.d.ts +1 -6
  167. package/dist/esm/lib/schema/detect.js +2 -7
  168. package/dist/esm/lib/schema/validate.js +13 -3
  169. package/dist/esm/lib/scope/ScopeFacade.d.ts +4 -2
  170. package/dist/esm/lib/scope/ScopeFacade.js +17 -8
  171. package/dist/esm/lib/scope/protection/createProtectedScope.js +6 -19
  172. package/dist/esm/lib/scope/recorders/DebugRecorder.d.ts +1 -1
  173. package/dist/esm/lib/scope/recorders/DebugRecorder.js +2 -2
  174. package/dist/esm/lib/scope/state/zod/scopeFactory.js +33 -10
  175. package/dist/esm/lib/scope/state/zod/utils/validateHelper.js +1 -15
  176. package/dist/esm/lib/sinks/fileSink.d.ts +4 -1
  177. package/dist/esm/lib/sinks/fileSink.js +57 -28
  178. package/dist/esm/lib/sinks/indexedAdmission.d.ts +2 -0
  179. package/dist/esm/lib/sinks/indexedAdmission.js +11 -1
  180. package/dist/esm/lib/sinks/indexedRecordFile.js +3 -3
  181. package/dist/esm/lib/sinks/indexedScan.js +3 -4
  182. package/dist/esm/recorders.js +1 -1
  183. package/dist/index.js +3 -3
  184. package/dist/lib/attempt/policy.js +2 -2
  185. package/dist/lib/attempt/types.js +1 -1
  186. package/dist/lib/budget/timeBudget.js +28 -13
  187. package/dist/lib/builder/FlowChartBuilder.js +163 -111
  188. package/dist/lib/builder/index.js +4 -3
  189. package/dist/lib/builder/retryLoop.js +1 -1
  190. package/dist/lib/builder/structure/StructureRecorder.js +3 -4
  191. package/dist/lib/builder/structure/StructureRecorderDispatcher.js +18 -3
  192. package/dist/lib/builder/types.js +4 -3
  193. package/dist/lib/capture/checkpointCapture.js +9 -3
  194. package/dist/lib/capture/envelope.js +25 -10
  195. package/dist/lib/capture/historyNote.js +2 -2
  196. package/dist/lib/capture/nativeCoverage.js +13 -2
  197. package/dist/lib/capture/policies.js +3 -3
  198. package/dist/lib/capture/summarize.js +36 -8
  199. package/dist/lib/contract/schema.js +14 -5
  200. package/dist/lib/decide/types.js +1 -1
  201. package/dist/lib/detach/drivers/batch.js +4 -17
  202. package/dist/lib/detach/drivers/immediate.js +3 -2
  203. package/dist/lib/detach/drivers/sendBeacon.js +7 -6
  204. package/dist/lib/detach/drivers/workerThread.js +56 -12
  205. package/dist/lib/detach/errors.js +25 -0
  206. package/dist/lib/detach/registry.js +20 -19
  207. package/dist/lib/detach/spawn.js +2 -3
  208. package/dist/lib/detach/types.js +5 -4
  209. package/dist/lib/engine/handlers/ChildrenExecutor.js +3 -2
  210. package/dist/lib/engine/handlers/DeciderHandler.js +8 -2
  211. package/dist/lib/engine/handlers/NodeResolver.js +15 -8
  212. package/dist/lib/engine/handlers/ParallelForEachHandler.js +150 -58
  213. package/dist/lib/engine/handlers/RuntimeStructureManager.js +28 -17
  214. package/dist/lib/engine/handlers/SelectorHandler.js +10 -3
  215. package/dist/lib/engine/handlers/SubflowExecutor.js +55 -17
  216. package/dist/lib/engine/handlers/SubflowInputMapper.js +35 -17
  217. package/dist/lib/engine/handlers/mapperEdits.js +99 -0
  218. package/dist/lib/engine/handlers/mapperScope.js +157 -0
  219. package/dist/lib/engine/handlers/plainObject.js +25 -0
  220. package/dist/lib/engine/handlers/selectionProblem.js +19 -0
  221. package/dist/lib/engine/narrative/CombinedNarrativeRecorder.js +18 -10
  222. package/dist/lib/engine/narrative/FlowRecorderDispatcher.js +1 -1
  223. package/dist/lib/engine/narrative/NarrativeFlowRecorder.js +8 -25
  224. package/dist/lib/engine/narrative/formatting/ruleEvidence/index.js +10 -2
  225. package/dist/lib/engine/narrative/recorders/AdaptiveNarrativeFlowRecorder.js +9 -5
  226. package/dist/lib/engine/narrative/recorders/ManifestFlowRecorder.js +27 -6
  227. package/dist/lib/engine/narrative/recorders/MilestoneNarrativeFlowRecorder.js +8 -1
  228. package/dist/lib/engine/narrative/recorders/ProgressiveNarrativeFlowRecorder.js +6 -1
  229. package/dist/lib/engine/narrative/recorders/SeparateNarrativeFlowRecorder.js +2 -2
  230. package/dist/lib/engine/narrative/types.js +1 -1
  231. package/dist/lib/engine/traversal/FlowchartTraverser.js +74 -27
  232. package/dist/lib/engine/types.js +1 -1
  233. package/dist/lib/filter/evaluator.js +144 -20
  234. package/dist/lib/ids/reservedIds.js +3 -3
  235. package/dist/lib/memory/StageContext.js +290 -34
  236. package/dist/lib/memory/borrowedMutation.js +42 -2
  237. package/dist/lib/memory/frameTypes.js +2 -2
  238. package/dist/lib/memory/hiddenObjectTrail.js +225 -0
  239. package/dist/lib/memory/keptReads.js +83 -0
  240. package/dist/lib/memory/markPlaces.js +132 -0
  241. package/dist/lib/memory/pathTargets.js +95 -0
  242. package/dist/lib/memory/redaction.js +281 -90
  243. package/dist/lib/memory/retainedValue/index.js +13 -2
  244. package/dist/lib/memory/runPolicy.js +3 -3
  245. package/dist/lib/memory/selectedObjects.js +608 -0
  246. package/dist/lib/memory/servedPlaces.js +142 -0
  247. package/dist/lib/observer-queue/index.js +4 -3
  248. package/dist/lib/pause/types.js +8 -6
  249. package/dist/lib/reactive/allowlist.js +19 -7
  250. package/dist/lib/reactive/arrayTraps.js +116 -18
  251. package/dist/lib/reactive/createTypedScope.js +34 -8
  252. package/dist/lib/reactive/handles.js +3 -5
  253. package/dist/lib/reactive/jsonProjection.js +7 -9
  254. package/dist/lib/reactive/liveView.js +10 -3
  255. package/dist/lib/reactive/structuralWrite.js +23 -5
  256. package/dist/lib/reactive/types.js +1 -1
  257. package/dist/lib/reactive/writeTraps.js +82 -7
  258. package/dist/lib/recorder/AttemptRecorder.js +2 -2
  259. package/dist/lib/recorder/BoundaryStateStore.js +9 -6
  260. package/dist/lib/recorder/CombinedRecorder.js +3 -3
  261. package/dist/lib/recorder/CompositeRecorder.js +1 -1
  262. package/dist/lib/recorder/ControlDepRecorder.js +2 -2
  263. package/dist/lib/recorder/EmitRecorder.js +2 -2
  264. package/dist/lib/recorder/QualityRecorder.js +5 -2
  265. package/dist/lib/recorder/TopologyRecorder.js +14 -7
  266. package/dist/lib/runner/ExecutionRuntime.js +3 -4
  267. package/dist/lib/runner/FlowChartExecutor.js +43 -22
  268. package/dist/lib/runner/RunContext.js +14 -5
  269. package/dist/lib/runner/RunnableChart.js +47 -26
  270. package/dist/lib/runner/deadline.js +1 -1
  271. package/dist/lib/runner/options.js +1 -1
  272. package/dist/lib/runner/recordSink.js +4 -2
  273. package/dist/lib/runner/snapshot.js +3 -3
  274. package/dist/lib/runner/stringifySnapshot.js +38 -4
  275. package/dist/lib/schema/detect.js +2 -7
  276. package/dist/lib/schema/validate.js +13 -3
  277. package/dist/lib/scope/ScopeFacade.js +17 -8
  278. package/dist/lib/scope/protection/createProtectedScope.js +6 -19
  279. package/dist/lib/scope/recorders/DebugRecorder.js +2 -2
  280. package/dist/lib/scope/state/zod/scopeFactory.js +32 -9
  281. package/dist/lib/scope/state/zod/utils/validateHelper.js +1 -15
  282. package/dist/lib/sinks/fileSink.js +57 -28
  283. package/dist/lib/sinks/indexedAdmission.js +13 -2
  284. package/dist/lib/sinks/indexedRecordFile.js +2 -2
  285. package/dist/lib/sinks/indexedScan.js +2 -3
  286. package/dist/recorders.js +1 -1
  287. package/dist/types/index.d.ts +4 -20
  288. package/dist/types/lib/attempt/policy.d.ts +1 -1
  289. package/dist/types/lib/attempt/types.d.ts +2 -1
  290. package/dist/types/lib/budget/timeBudget.d.ts +13 -5
  291. package/dist/types/lib/builder/FlowChartBuilder.d.ts +74 -35
  292. package/dist/types/lib/builder/index.d.ts +3 -2
  293. package/dist/types/lib/builder/retryLoop.d.ts +1 -1
  294. package/dist/types/lib/builder/structure/StructureRecorder.d.ts +11 -14
  295. package/dist/types/lib/builder/types.d.ts +5 -4
  296. package/dist/types/lib/capture/checkpointCapture.d.ts +1 -0
  297. package/dist/types/lib/capture/envelope.d.ts +6 -3
  298. package/dist/types/lib/capture/nativeCoverage.d.ts +6 -0
  299. package/dist/types/lib/capture/policies.d.ts +2 -2
  300. package/dist/types/lib/capture/summarize.d.ts +2 -1
  301. package/dist/types/lib/decide/types.d.ts +11 -8
  302. package/dist/types/lib/detach/drivers/sendBeacon.d.ts +4 -4
  303. package/dist/types/lib/detach/drivers/workerThread.d.ts +20 -1
  304. package/dist/types/lib/detach/errors.d.ts +7 -0
  305. package/dist/types/lib/detach/registry.d.ts +19 -18
  306. package/dist/types/lib/detach/spawn.d.ts +1 -2
  307. package/dist/types/lib/detach/types.d.ts +6 -5
  308. package/dist/types/lib/engine/handlers/NodeResolver.d.ts +9 -1
  309. package/dist/types/lib/engine/handlers/ParallelForEachHandler.d.ts +6 -1
  310. package/dist/types/lib/engine/handlers/RuntimeStructureManager.d.ts +9 -1
  311. package/dist/types/lib/engine/handlers/SubflowExecutor.d.ts +4 -2
  312. package/dist/types/lib/engine/handlers/mapperEdits.d.ts +23 -0
  313. package/dist/types/lib/engine/handlers/mapperScope.d.ts +81 -0
  314. package/dist/types/lib/engine/handlers/plainObject.d.ts +15 -0
  315. package/dist/types/lib/engine/handlers/selectionProblem.d.ts +9 -0
  316. package/dist/types/lib/engine/narrative/CombinedNarrativeRecorder.d.ts +4 -2
  317. package/dist/types/lib/engine/narrative/FlowRecorderDispatcher.d.ts +2 -2
  318. package/dist/types/lib/engine/narrative/NarrativeFlowRecorder.d.ts +3 -5
  319. package/dist/types/lib/engine/narrative/recorders/AdaptiveNarrativeFlowRecorder.d.ts +5 -1
  320. package/dist/types/lib/engine/narrative/recorders/ManifestFlowRecorder.d.ts +9 -1
  321. package/dist/types/lib/engine/narrative/recorders/MilestoneNarrativeFlowRecorder.d.ts +4 -0
  322. package/dist/types/lib/engine/narrative/recorders/ProgressiveNarrativeFlowRecorder.d.ts +2 -0
  323. package/dist/types/lib/engine/narrative/recorders/SeparateNarrativeFlowRecorder.d.ts +1 -1
  324. package/dist/types/lib/engine/narrative/types.d.ts +1 -1
  325. package/dist/types/lib/engine/traversal/FlowchartTraverser.d.ts +41 -44
  326. package/dist/types/lib/engine/types.d.ts +14 -4
  327. package/dist/types/lib/filter/evaluator.d.ts +6 -0
  328. package/dist/types/lib/ids/reservedIds.d.ts +2 -2
  329. package/dist/types/lib/memory/StageContext.d.ts +140 -10
  330. package/dist/types/lib/memory/borrowedMutation.d.ts +18 -0
  331. package/dist/types/lib/memory/frameTypes.d.ts +6 -4
  332. package/dist/types/lib/memory/hiddenObjectTrail.d.ts +118 -0
  333. package/dist/types/lib/memory/keptReads.d.ts +62 -0
  334. package/dist/types/lib/memory/markPlaces.d.ts +98 -0
  335. package/dist/types/lib/memory/pathTargets.d.ts +48 -0
  336. package/dist/types/lib/memory/redaction.d.ts +142 -24
  337. package/dist/types/lib/memory/runPolicy.d.ts +10 -8
  338. package/dist/types/lib/memory/selectedObjects.d.ts +215 -0
  339. package/dist/types/lib/memory/servedPlaces.d.ts +41 -0
  340. package/dist/types/lib/observer-queue/index.d.ts +3 -2
  341. package/dist/types/lib/pause/types.d.ts +8 -6
  342. package/dist/types/lib/reactive/allowlist.d.ts +12 -3
  343. package/dist/types/lib/reactive/arrayTraps.d.ts +10 -2
  344. package/dist/types/lib/reactive/jsonProjection.d.ts +4 -4
  345. package/dist/types/lib/reactive/liveView.d.ts +4 -1
  346. package/dist/types/lib/reactive/types.d.ts +6 -0
  347. package/dist/types/lib/reactive/writeTraps.d.ts +20 -1
  348. package/dist/types/lib/recorder/BoundaryStateStore.d.ts +4 -2
  349. package/dist/types/lib/recorder/CombinedRecorder.d.ts +4 -3
  350. package/dist/types/lib/recorder/CompositeRecorder.d.ts +1 -1
  351. package/dist/types/lib/recorder/ControlDepRecorder.d.ts +1 -1
  352. package/dist/types/lib/recorder/EmitRecorder.d.ts +1 -1
  353. package/dist/types/lib/runner/ExecutionRuntime.d.ts +2 -3
  354. package/dist/types/lib/runner/FlowChartExecutor.d.ts +12 -5
  355. package/dist/types/lib/runner/RunContext.d.ts +25 -3
  356. package/dist/types/lib/runner/RunnableChart.d.ts +10 -3
  357. package/dist/types/lib/runner/deadline.d.ts +1 -0
  358. package/dist/types/lib/runner/options.d.ts +6 -6
  359. package/dist/types/lib/runner/stringifySnapshot.d.ts +4 -3
  360. package/dist/types/lib/schema/detect.d.ts +1 -6
  361. package/dist/types/lib/scope/ScopeFacade.d.ts +4 -2
  362. package/dist/types/lib/scope/recorders/DebugRecorder.d.ts +1 -1
  363. package/dist/types/lib/sinks/fileSink.d.ts +4 -1
  364. package/dist/types/lib/sinks/indexedAdmission.d.ts +2 -0
  365. package/package.json +6 -8
  366. package/dist/esm/lib/scope/state/installResolvers.d.ts +0 -4
  367. package/dist/esm/lib/scope/state/installResolvers.js +0 -15
  368. package/dist/lib/scope/state/installResolvers.js +0 -19
  369. package/dist/types/lib/scope/state/installResolvers.d.ts +0 -4
@@ -9,25 +9,30 @@
9
9
  * children, with-continuation decider/selector branches, subflow mounts)
10
10
  * recurses.
11
11
  *
12
- * For each node, executeNodeStep follows 7 phases:
13
- * 0. CLASSIFY — subflow detection, early delegation
12
+ * For each node, executeNodeStep runs a hard-coded chain of phases; a node
13
+ * leaves at the first phase that owns it:
14
+ * 0a. LAZY RESOLVE — deferred subflow resolution
15
+ * 0. CLASSIFY — subflow mount, delegated to SubflowExecutor
14
16
  * 0b. PARALLEL-FOR-EACH — dynamic fan-out (branches generated from the payload)
15
- * 1. VALIDATE — node invariants, role markers
16
- * 2. EXECUTE — run stage fn, commit, break check
17
- * 3. DYNAMIC — StageNode return detection, subflow auto-registration, structure updates
18
- * 4. CHILDREN — fork/selector/decider dispatch
19
- * 5. CONTINUE — dynamic next / linear next resolution
20
- * 6. LEAF — no continuation, return output
17
+ * 1. VALIDATE — node invariants, role markers
18
+ * 2a. SELECTOR — scope-based multi-choice (SelectorHandler)
19
+ * 2b. DECIDER — scope-based single-choice (DeciderHandler)
20
+ * 3. EXECUTE — run stage fn, commit, break check
21
+ * 4. DYNAMIC — StageNode return detection, subflow auto-registration, structure updates
22
+ * 5. CHILDREN — fork dispatch (static or dynamic children)
23
+ * 6. CONTINUE — dynamic next / linear next resolution
24
+ * 7. LEAF — no continuation, return output
21
25
  *
22
26
  * Break semantics: If a stage calls breakFn(), commit and STOP.
23
- * Patch model: Stage writes into local patch; commitPatch() after return or throw.
27
+ * Commit model: a stage's writes are staged and committed by
28
+ * `commitStage` / `commitStageWrites` after it returns or throws.
24
29
  */
25
30
  import type { RunCorrelation } from '../../attempt/types.js';
26
31
  import type { ScopeProtectionMode } from '../../scope/protection/types.js';
27
32
  import type { QueuedPause, ResumeEntry } from '../handlers/ResumeEntry.js';
28
33
  import { FlowRecorderDispatcher } from '../narrative/FlowRecorderDispatcher.js';
29
34
  import type { FlowRecorder, IControlFlowNarrative } from '../narrative/types.js';
30
- import type { IExecutionRuntime, ILogger, ScopeFactory, Selector, SerializedPipelineStructure, StageFunction, StageNode, StreamHandlers, SubflowMountOptions, SubflowResult, TraversalResult } from '../types.js';
35
+ import type { IExecutionRuntime, ILogger, ReturnedSubflowDefinition, ScopeFactory, Selector, SerializedPipelineStructure, StageFunction, StageNode, StreamHandlers, SubflowMountOptions, SubflowResult, TraversalResult } from '../types.js';
31
36
  export interface TraverserOptions<TOut = any, TScope = any> {
32
37
  /**
33
38
  * The graph this traverser walks — and the graph every id resolves against
@@ -153,13 +158,19 @@ export interface DynamicNodePatch<TOut = any, TScope = any> {
153
158
  * Subflow mount metadata from a dynamic-subflow return. Grouped so the
154
159
  * merged view reproduces the old field-wise overwrite exactly — including
155
160
  * `subflowName`/`subflowMountOptions` becoming undefined when the dynamic
156
- * return omitted them.
161
+ * return omitted them. Taken off again by the mount it asks for
162
+ * (`takeReturnedMount`): one mount per return.
157
163
  */
158
164
  subflowMeta?: {
159
165
  isSubflowRoot: true;
160
166
  subflowId: string;
161
167
  subflowName: string | undefined;
162
168
  subflowMountOptions: SubflowMountOptions | undefined;
169
+ /**
170
+ * The definition THIS return handed back — what its mount runs (`ReturnedSubflowDefinition`). Not read
171
+ * from the id registry, which keeps the first definition registered under an id for the whole run.
172
+ */
173
+ definition: ReturnedSubflowDefinition<TOut, TScope>;
163
174
  };
164
175
  /** Dynamic fork children (replaces the built node's children for this run). */
165
176
  children?: StageNode<TOut, TScope>[];
@@ -281,13 +292,15 @@ export declare class FlowchartTraverser<TOut = any, TScope = any> {
281
292
  * **What counts as depth (trampoline model):** `executeNode` is an iterative
282
293
  * driver — linear `next` hops, loop edges (`loopTo`/dynamic next), and
283
294
  * dynamic-subflow re-entry are followed in a flat loop and consume NO depth.
284
- * Depth grows only with true tree nesting: one tick per fork child, one per
285
- * decider/selector branch dispatch that must return to its invoker (decider
286
- * with its own `next`), one per subflow mount frame in the parent (the
287
- * subflow body itself runs on a FRESH traverser with its own budget).
295
+ * Depth grows only with true tree nesting: one level for a fork's or
296
+ * selector's children, one per decider branch dispatch that must return to
297
+ * its invoker (decider with its own `next`). A subflow mount consumes no
298
+ * depth: Phase 0 hands it to `SubflowExecutor`, and the subflow body runs on
299
+ * a FRESH traverser whose root context has no parent, so it starts again at
300
+ * depth 1. Nesting subflows inside subflows is not bounded by this cap.
288
301
  *
289
- * 500 therefore covers any realistic chart — it bounds recursive
290
- * COMPOSITION, not chain length or loop count. Loops are bounded by
302
+ * 500 therefore covers any realistic chart — it bounds nesting within one
303
+ * traverser, not chain length or loop count. Loops are bounded by
291
304
  * `ContinuationResolver`'s independent iteration limit (default 1000,
292
305
  * configurable via `RunOptions.maxIterations`), which is now the binding
293
306
  * constraint for loop-heavy pipelines.
@@ -348,30 +361,7 @@ export declare class FlowchartTraverser<TOut = any, TScope = any> {
348
361
  commitLog: unknown[];
349
362
  readSources?: import("../../capture/readSources.js").EngineReadSources | undefined;
350
363
  logAddress?: import("foottrace").LogAddress | undefined;
351
- subflowResults?: Record<string, unknown> | undefined; /**
352
- * Default maximum nested executeNode depth before an error is thrown.
353
- *
354
- * **What counts as depth (trampoline model):** `executeNode` is an iterative
355
- * driver — linear `next` hops, loop edges (`loopTo`/dynamic next), and
356
- * dynamic-subflow re-entry are followed in a flat loop and consume NO depth.
357
- * Depth grows only with true tree nesting: one tick per fork child, one per
358
- * decider/selector branch dispatch that must return to its invoker (decider
359
- * with its own `next`), one per subflow mount frame in the parent (the
360
- * subflow body itself runs on a FRESH traverser with its own budget).
361
- *
362
- * 500 therefore covers any realistic chart — it bounds recursive
363
- * COMPOSITION, not chain length or loop count. Loops are bounded by
364
- * `ContinuationResolver`'s independent iteration limit (default 1000,
365
- * configurable via `RunOptions.maxIterations`), which is now the binding
366
- * constraint for loop-heavy pipelines.
367
- *
368
- * Parallel siblings share their parent's depth + 1 — a fork or selector of any width is
369
- * one level, never one level per child.
370
- *
371
- * @remarks Not safe for concurrent `.execute()` calls on the same instance (the break flag
372
- * and the resolver's loop counts are per instance). Use a separate `FlowchartTraverser` per
373
- * concurrent execution. `FlowChartExecutor.run()` always creates a fresh traverser per call.
374
- */
364
+ subflowResults?: Record<string, unknown> | undefined;
375
365
  recorders?: {
376
366
  id: string;
377
367
  name: string;
@@ -407,6 +397,12 @@ export declare class FlowchartTraverser<TOut = any, TScope = any> {
407
397
  private effIsSubflowRoot;
408
398
  /** Effective subflow id (patched verbatim by a dynamic subflow return). */
409
399
  private effSubflowId;
400
+ /**
401
+ * Take a returned sub-flowchart's mount off the overlay: the definition this node's stage function
402
+ * returned on this visit, or undefined when it returned none. The mount runs once, for the return that
403
+ * asked for it.
404
+ */
405
+ private takeReturnedMount;
410
406
  /**
411
407
  * Materialize the effective view of a node — field-identical to what the
412
408
  * pre-overlay code produced by mutating the shared node. Used where a node
@@ -483,9 +479,10 @@ export declare class FlowchartTraverser<TOut = any, TScope = any> {
483
479
  * call): fork children (`ChildrenExecutor`), selector branches (parallel
484
480
  * fan-out), decider branch dispatch when the decider has its own `next`
485
481
  * (the branch must complete BEFORE the decider's continuation runs), and
486
- * subflow mounts (fresh traverser; the mount frame stays in the parent).
487
- * `_executeDepth` therefore counts chart COMPOSITION depth only, guarded
488
- * by `_maxDepth` (default `MAX_EXECUTE_DEPTH` = 500).
482
+ * subflow mounts (a fresh traverser). The depth `nestingDepthOf` reads
483
+ * counts nesting along the call path within this traverser, guarded by
484
+ * `_maxDepth` (default `MAX_EXECUTE_DEPTH` = 500). A subflow's traverser
485
+ * starts again at depth 1, so a subflow mount consumes no depth.
489
486
  *
490
487
  * PauseSignal: a flat decider dispatch records an `InvokerStamp`; if the
491
488
  * continued chain later pauses, the driver stamps the signal during
@@ -201,10 +201,11 @@ export interface SubflowMountOptions<TParentScope = any, TSubflowInput = any, TS
201
201
  *
202
202
  * ## Parallel/fan-out
203
203
  *
204
- * Follows the existing library rule in `ChildrenExecutor`: the parent
205
- * breaks only when **every** child of a fork broke. A single
206
- * `propagateBreak: true` subflow contributing its break to the count
207
- * does not on its own terminate the parent fan-out.
204
+ * A fork child runs with its own break flag, and every fan-out call site
205
+ * passes no parent break flag to `ChildrenExecutor`. So a
206
+ * `propagateBreak: true` subflow mounted as a fork child stops its own
207
+ * branch only; the parent fan-out never breaks, even when every child
208
+ * broke.
208
209
  *
209
210
  * ## outputMapper still runs
210
211
  *
@@ -281,6 +282,13 @@ export interface SubflowResult {
281
282
  parentStageId: string;
282
283
  pipelineStructure?: unknown;
283
284
  }
285
+ /**
286
+ * The definition a stage RETURNED for its mount (`StageNode.subflowDef`): self-contained. Its mount runs
287
+ * its `root`, resolves the sub-flowcharts nested in it from its own `subflows`, finds its stage functions in
288
+ * its own `stageMap` first, and is recorded with its own `buildTimeStructure`. The run's id registry keeps
289
+ * the FIRST definition registered under an id and is asked only for what the definition does not define.
290
+ */
291
+ export type ReturnedSubflowDefinition<TOut = any, TScope = any> = NonNullable<StageNode<TOut, TScope>['subflowDef']>;
284
292
  /**
285
293
  * SubflowTraverserFactory — Creates a FlowchartTraverser for subflow execution.
286
294
  *
@@ -295,6 +303,8 @@ export interface SubflowResult {
295
303
  export type SubflowTraverserFactory<TOut = any, TScope = any> = (options: {
296
304
  /** Root node of the subflow (with isSubflowRoot stripped) — the graph every id inside the subflow resolves against. */
297
305
  root: StageNode<TOut, TScope>;
306
+ /** A returned definition's own stage functions and nested sub-flowcharts: they win inside its own mount. */
307
+ definition?: Pick<ReturnedSubflowDefinition<TOut, TScope>, 'stageMap' | 'subflows'>;
298
308
  /**
299
309
  * Where the subflow's traversal starts when not at `root` — a resume's
300
310
  * one-shot re-entry (`ResumeHop.entry`): the next mount on the pause path,
@@ -34,6 +34,12 @@ import { type ServedThreshold } from '../memory/redaction.js';
34
34
  * through a typo (`gte` misspelled `gle`). With dev mode enabled
35
35
  * (`enableDevMode()`), a console warning names the unknown operator and key.
36
36
  *
37
+ * ## Two comparison laws, no coercion
38
+ *
39
+ * `eq` / `ne` / `in` / `notIn` ask for the SAME VALUE (`sameValue`); `gt` / `gte` / `lt` / `lte` ask for an
40
+ * ORDER, which holds only between two numbers, two bigints, two strings or two Dates (`inOrder`). A missing
41
+ * value (`null`, `undefined`) is in no order with anything, so an ordered condition on it does not hold.
42
+ *
37
43
  * @param getValueFn - Reads a value from scope by key (raw, for comparison)
38
44
  * @param isRedactedFn - Checks if a key's ACTUAL value is masked (for evidence display)
39
45
  * @param filter - The WhereFilter to evaluate
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * A user-authored id may not carry the grammar's delimiters (`#`, `/`), and a path segment may not
5
5
  * carry the generated-segment marker (`~`). This is the engine's rule about which ids it admits,
6
- * not part of the grammar: the grammar (`runtimeStageId.ts`, the record's) builds, parses and
7
- * reads ids and imports nothing; this file reads its delimiters and the `~` grammar
6
+ * not part of the grammar: the grammar (foottrace's runtime-ID codec) builds, parses and
7
+ * reads ids; this file reads its delimiters and the `~` grammar
8
8
  * (`branchSegment.ts`), so the record no longer imports the engine's segment rule.
9
9
  *
10
10
  * Asked at the builder's id doors and at the run-time dynamic-StageNode door ONLY — never by the
@@ -41,7 +41,7 @@ export declare class StageContext {
41
41
  /** @internal Stamped before observers; never inherited by another frame or persisted. */
42
42
  bindFailureIdentity(runId: string, runtimeStageId: string): void;
43
43
  /**
44
- * The record half of this frame (`RecordFrame.ts`, L3, C3): the heap and,
44
+ * The record half of this frame (foottrace's `RecordFrame`, C3): the heap and,
45
45
  * when the run keeps them, the redacted mirror and the log; the address;
46
46
  * the first-touch base; the lazy transaction buffer; the readKeys list.
47
47
  * Every state read of this frame goes through it, and so does every
@@ -135,6 +135,8 @@ export declare class StageContext {
135
135
  * facade path never allocates it.
136
136
  */
137
137
  private _nestedReads?;
138
+ /** Which reads this frame has already kept: a read is kept once for each object a key holds (`keptReads.ts`). */
139
+ private readonly keptReads;
138
140
  /**
139
141
  * Dev mode only: the root keys whose LAST tracked read was served from
140
142
  * committed state — before this stage's first write, when no transaction
@@ -144,6 +146,15 @@ export declare class StageContext {
144
146
  * stage wrote them. Never allocated outside `enableDevMode()`.
145
147
  */
146
148
  private _viewReads?;
149
+ /**
150
+ * Dev mode only: the root keys read LIVE through {@link readLiveRoot} (a subflow mount's mappers and
151
+ * its list append). Such a read is of committed state as it was at that moment, not of this frame's
152
+ * pinned view, and a mount stays open for the whole run of its subflow: a parallel sibling may
153
+ * rightly replace the key in between. {@link warnOnBorrowedMutation} has no pinned value to compare
154
+ * the copy with, so it skips these keys, as it skips every read the live fallback served.
155
+ * Never allocated outside `enableDevMode()`.
156
+ */
157
+ private _liveReads?;
147
158
  /**
148
159
  * Has this frame committed at least once? The borrowed-read guard runs on
149
160
  * the FIRST commit only — see {@link warnOnBorrowedMutation}. The frame
@@ -155,8 +166,19 @@ export declare class StageContext {
155
166
  private _committed;
156
167
  /** Tracked reads of a selected value ({@link selectedReads}). */
157
168
  private _selectedReads;
158
- /** Each object this frame read under a selected name → that read's verdict (`stageWrite` hands it on). */
159
- private _selectedObjects?;
169
+ /**
170
+ * Follows the objects this frame read under a selected name into what it writes: at each write, and
171
+ * once more at commit (`hiddenObjectTrail.ts`). Made at the first write or read a redaction rule
172
+ * has something to say about, so a run without a policy holds none.
173
+ */
174
+ private _trail?;
175
+ /**
176
+ * This frame's staged deletes of keys the redaction rule keeps hidden (`redaction.ts · markStagedWrite`),
177
+ * each with the absolute path it deletes. A delete is only STAGED until the frame commits, so no mark
178
+ * ends at the write: {@link endMarksOfLandedDeletes} asks the state once the commit has landed. A
179
+ * discarded try drops them; a delete that never landed ends nothing.
180
+ */
181
+ private _stagedDeletes?;
160
182
  /**
161
183
  * RFC-003 D2 honesty markers — untracked read paths used during THIS
162
184
  * stage's execution (`'args'` / `'env'` / `'silent'`). Marked by
@@ -214,7 +236,7 @@ export declare class StageContext {
214
236
  /**
215
237
  * Install a parallel redacted mirror. Subsequent `commit()` calls apply
216
238
  * the already-computed redacted patches — the ones the log records — to
217
- * this mirror, beside the raw patches on the heap (`recordCommit`).
239
+ * this mirror, beside the raw patches on the heap (foottrace's `RecordFrame · commit`).
218
240
  * Child / next contexts inherit the mirror via `createNext` / `createChild`.
219
241
  *
220
242
  * Called on a runtime's root frame by `ExecutionRuntime` when the run's policy keeps a mirror.
@@ -274,7 +296,7 @@ export declare class StageContext {
274
296
  * one `stageWrite` decided BEFORE staging, carried to commit with the
275
297
  * value. The staged write itself is unaffected — redaction of the
276
298
  * committed payload is the record frame's scrub of that write
277
- * (`RecordFrame · write`, then `scrub.ts` at commit).
299
+ * (`RecordFrame · write`, then foottrace's scrub at commit).
278
300
  */
279
301
  private trackWrite;
280
302
  /**
@@ -301,7 +323,8 @@ export declare class StageContext {
301
323
  * 2. identity inheritance — `inheritByIdentity`, against this frame's
302
324
  * selected reads as they stand after step 1;
303
325
  * 3. the bytes — `RecordFrame · write`, the op and its scrub (the whole
304
- * value, or the fields inside it);
326
+ * value, or the fields inside it). Steps 2 and 3 are one call,
327
+ * `HiddenObjectTrail · stage`, which also keeps what the key showed;
305
328
  * 4. the marks — `markStagedWrite`, only once the write staged, so a
306
329
  * write that fails to stage marks nothing.
307
330
  * Each step reads the rule (and the selected reads) when it acts, as this
@@ -309,6 +332,22 @@ export declare class StageContext {
309
332
  * under the same decision.
310
333
  */
311
334
  private stageWrite;
335
+ /**
336
+ * The frame's staged writes have landed. A delete among them ends its key's mark NOW, and only when
337
+ * the key is really gone from the state. WHY ask the state: a stage that deletes a key and writes it
338
+ * again before its commit has not deleted it (the record shows no delete either), and what it wrote
339
+ * back may be the hidden value it read first.
340
+ */
341
+ private endMarksOfLandedDeletes;
342
+ /** This frame's trail of hidden objects, made when first asked for (`hiddenObjectTrail.ts`). */
343
+ private get trail();
344
+ /**
345
+ * Search what this frame wrote once more, as it stands now, before it is recorded
346
+ * (`HiddenObjectTrail · followAtCommit`, why). A key that gained a hidden place there was staged
347
+ * again; here it gets its marks. And every write the frame kept for its snapshot takes the verdict
348
+ * its kept form is taken under: this runs before {@link materialiseWrites}.
349
+ */
350
+ private followLateEdits;
312
351
  /**
313
352
  * Write and read at ANOTHER frame's address (its run namespace) while this
314
353
  * frame keeps its own identity on the record — `stage`, `stageId`,
@@ -337,8 +376,9 @@ export declare class StageContext {
337
376
  /**
338
377
  * Tracked read. The returned value is BORROWED — see the contract on
339
378
  * `ScopeFacade.getValue`. Read-tracking cost is policy-gated (#14):
340
- * `'full'` clones the value into `_stageReads` (historical default),
341
- * `'summary'` records a cheap marker, `'off'` records nothing.
379
+ * `'full'` keeps a clone of the value in `_stageReads` (the default), once
380
+ * for each object a key holds ({@link keepOnce}); `'summary'` records a
381
+ * cheap marker, `'off'` records nothing.
342
382
  */
343
383
  getValue(path: string[], key?: string, description?: string): unknown;
344
384
  /**
@@ -349,6 +389,67 @@ export declare class StageContext {
349
389
  inspectValue(path: string[], key?: string): unknown;
350
390
  private retainedRead;
351
391
  private readRetainedValue;
392
+ /**
393
+ * A read of one ROOT key of live committed state, recorded as a read of THIS step. The mount of a
394
+ * subflow reads this way: its two mappers (`engine/handlers/mapperScope.ts`) and its merge-back,
395
+ * which reads what is there before it adds to it (`SubflowInputMapper · applyOutputMapping`). The
396
+ * value is live state at the root, exactly what those were handed before. What is new is that the
397
+ * read is RECORDED: on the frame's read prefix, under the rule's verdict, in the taint count and
398
+ * in `stageReads`. A key the state does not hold reads `undefined` and records nothing, as before.
399
+ *
400
+ * WHY NOT `getValue`: that serves the frame's own view, pinned at its first touch. A mount's
401
+ * output mapping runs after the subflow has run, and reads state as it is THEN; a pinned view
402
+ * would hand it state as it was when the mount began.
403
+ *
404
+ * WHAT `stageReads` KEEPS IS THE RUN'S OWN SETTING (`readTracking`), as for every read of every
405
+ * step: a copy under `'full'`, a marker under `'summary'`, nothing under `'off'`. The first cut kept
406
+ * a marker whatever the setting said, to spare a mount in a loop the copy. That broke what `'full'`
407
+ * promises a reader of the record (every read of a step is there as a value), and a consumer's own
408
+ * test caught it. The copy is the setting's price, here as for a stage; `bench/mapper-reads.ts`
409
+ * measures it, and `'summary'` is the setting for a run that hands large values on.
410
+ *
411
+ * WITH READ SOURCES ON (`readSources: true`) this read has no source of its own: the record's
412
+ * source-capturing door reads the frame's view, not live root state. The capture says so
413
+ * (`untracked-read`, status `partial`) and never reports a run with such a read as fully captured.
414
+ */
415
+ readLiveRoot(key: string): unknown;
416
+ /**
417
+ * A read of `key` as THIS frame's writes see it (its own address, then the root), recorded as a read
418
+ * of this step like any other. A subflow's merge-back reads this way before it merges a plain object
419
+ * field by field: what comes out under `key` is what was there with those fields changed, and the
420
+ * fields are written where the frame writes. (For a mount whose frame writes at the root, which is
421
+ * every mount the builder makes, this is the root key; read at the root regardless, a frame that
422
+ * writes under a namespace would be given the wrong writer.) A key that is not there reads
423
+ * `undefined` and records nothing: that is all this door adds to {@link getValue}.
424
+ */
425
+ readOwnView(key: string): unknown;
426
+ /**
427
+ * `value` is about to be written at `path`/`key` in PIECES: a subflow's merge-back merges a plain
428
+ * object field by field and appends a list as a new array. The write funnel then sees only the
429
+ * pieces, so an object this frame read under a selected name would lose its rule on the way (step 2
430
+ * of {@link stageWrite}, which follows an object by identity). Asked here with the whole value
431
+ * first, the target inherits what a whole write would have given it.
432
+ */
433
+ inheritRule(path: string[], key: string, value: unknown): void;
434
+ /**
435
+ * `handed` is what user code was given in place of `value`, an object this frame read under a
436
+ * selected name: the redaction rule hands a subflow mapper a VIEW of a record whose fields are
437
+ * selected, not the record. It carries the same rule, so that a copy of it written under another
438
+ * name is found by identity ({@link inheritRule}, {@link stageWrite}) as the record itself would be.
439
+ */
440
+ sameRuleFor(handed: unknown, value: unknown): void;
441
+ /**
442
+ * `copy` is a full copy the scope made of `value` and handed to user code (`$batchArray`). An object
443
+ * taken out of the copy is the selected value's all the same.
444
+ */
445
+ copyOfSelected(copy: unknown, value: unknown): void;
446
+ /** What every tracked read keeps, once the value is in hand and its verdict known (see {@link getValue}). */
447
+ private retainRead;
448
+ /**
449
+ * Keep what this read saw in {@link _stageReads}: once for each object a root key holds, not once for
450
+ * each read of it. The rule, why it holds and what it leaves alone are in `keptReads.ts`.
451
+ */
452
+ private keepOnce;
352
453
  /**
353
454
  * How many tracked reads of this frame read a value the run's rule selects
354
455
  * (a key it masks whole, or one with secret fields). A boundary that maps
@@ -368,7 +469,20 @@ export declare class StageContext {
368
469
  * retained or reported.
369
470
  */
370
471
  noteUntrackedRead(key: string | undefined, value: unknown): void;
371
- /** A read with no key hands the stage everything under `path`, so it counts when that holds a selected name. */
472
+ /**
473
+ * The stage asked for its input (`$getArgs()`): what the rule hides in it stays hidden wherever the
474
+ * stage writes it (`HiddenObjectTrail · rememberInput`). Never counted as a selected read: the taint
475
+ * law asks the input itself (`redaction.ts`, "the taint law").
476
+ */
477
+ noteInputRead(input: unknown, source?: unknown): void;
478
+ /** An object read under a selected name, and every object inside it, keeps its rule wherever the stage writes it (`selectedObjects.ts`). */
479
+ private rememberSelected;
480
+ /**
481
+ * A read with no key hands the stage everything under `path`, so it counts when that holds a selected
482
+ * name, and each selected value in it is remembered like one read by its key (`selectedObjects.ts`):
483
+ * the value at a selected path, or, for the whole state, the value of each selected key (the keys of
484
+ * every run namespace included).
485
+ */
372
486
  private noteKeylessRead;
373
487
  private noteAndJudgeRead;
374
488
  private judgeRead;
@@ -379,7 +493,13 @@ export declare class StageContext {
379
493
  getValueDirect(path: string[], key?: string): unknown;
380
494
  getRoot(key: string): any;
381
495
  getGlobal(key: string): any;
382
- getScope(): Record<string, unknown>;
496
+ /**
497
+ * The names of the root keys of committed state, as they stand now: what a subflow mapper may read
498
+ * (`engine/handlers/mapperScope.ts`). Names only; a value is read through {@link readLiveRoot}.
499
+ */
500
+ rootKeys(): string[];
501
+ /** Does committed state hold `key` at its root, as it stands now? A name is asked, no value is read. */
502
+ hasRootKey(key: unknown): key is string;
383
503
  getRunId(): string;
384
504
  /**
385
505
  * RFC-003 D2: record that this stage consumed an untracked read path.
@@ -512,6 +632,16 @@ export declare class StageContext {
512
632
  * every attempt did, and the retry feature's whole point is that the earlier
513
633
  * attempts stay visible.
514
634
  *
635
+ * Also KEPT: what the attempt read under a selected name — the count
636
+ * (`_selectedReads`, so {@link selectedReads} and {@link taintedReads} still
637
+ * count it) and the objects it read (`HiddenObjectTrail`, so `stageWrite`
638
+ * still hands their rule on). A later attempt can hold what a failed one
639
+ * read (a closure, a module variable), and the library cannot tell, so a
640
+ * selected read in any attempt marks the later ones: a threshold or break
641
+ * reason they serve is masked, and such an object keeps its rule when a
642
+ * later attempt writes it under another name. This is the conservative
643
+ * side for redaction (test/lib/engine/security/retry-isolation.test.ts).
644
+ *
515
645
  * No commit is recorded and no observer fires — a discarded attempt is not a
516
646
  * cursor stop, because from shared state's point of view it never happened.
517
647
  */
@@ -64,6 +64,24 @@ export declare function lateAttemptMessage(stageName: string, series: string, at
64
64
  * edit came after the first write, by accident of a whole-state clone.)
65
65
  */
66
66
  export declare function committedMutationMessage(stageName: string, key: string, path: string): string;
67
+ /**
68
+ * The warning text for a SUBFLOW MAPPER that changed, in place, a value of the parent's state it was
69
+ * handed (`engine/handlers/mapperEdits.ts`). Its own text, because the way out is another one: a
70
+ * mapper has no scope to write through. What an `outputMapper` returns is the write.
71
+ *
72
+ * WHY THE ADVICE DEPENDS ON THE VALUE. What is handed back is not simply stored
73
+ * (`engine/handlers/SubflowInputMapper.ts · applyOutputMapping`): a list is ADDED to the list that is
74
+ * there, and an object is MERGED into the one that is there, for the object itself and the objects
75
+ * directly inside it; anything deeper is replaced. The first text said "return the new value": for a
76
+ * list that doubled it (`[1, 1, 2]`). The second gave one sentence for every shape: followed for a
77
+ * change three levels down, it dropped the sibling fields there. Both were found by the second reader
78
+ * by following the advice. So the text speaks to the kind of value that was changed, says what it
79
+ * cannot do, and names the guide that has the whole rule. A third kind came from the third read: a
80
+ * `Map`, a `Set`, a `Date` or a class instance is not merged at all, it replaces what is there.
81
+ *
82
+ * `path` is `undefined` when the run has a redaction rule: then the key is named and the place is not.
83
+ */
84
+ export declare function mapperMutationMessage(mountName: string, mapper: 'inputMapper' | 'outputMapper', key: string, path: string | undefined, holds: 'list' | 'object' | 'other'): string;
67
85
  /**
68
86
  * The warning text. Names the stage, the exact path that moved, and the two
69
87
  * ways to write it back — because "you mutated something" is not actionable
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * A retried stage's node also carries its attempts (`attempts`, `attemptSummary` — the attempt leaf's types, L0).
11
11
  *
12
- * A `StageSnapshot` is an `ExecutionTree` (`types.ts`), the shape the record's readers walk:
12
+ * A `StageSnapshot` is foottrace's `ExecutionTree`, the shape the record's readers walk:
13
13
  * `commitStops`, `tagStops` and `keysReadFromExecutionTree` take one.
14
14
  */
15
15
  import type { Attention } from 'foottrace';
@@ -31,9 +31,11 @@ export interface FlowMessage {
31
31
  /**
32
32
  * Policy for how tracked reads are recorded into `StageSnapshot.stageReads`.
33
33
  *
34
- * - `'full'` (default) — every tracked read `structuredClone`s the value into
35
- * the stage's read view. Byte-identical to the historical behavior; this is
36
- * what snapshot consumers (lens, agentfootprint) see today.
34
+ * - `'full'` (default) — a tracked read keeps a `structuredClone` of the value
35
+ * in the stage's read view: what snapshot consumers (lens, agentfootprint)
36
+ * see. The clone is taken once for each object a key holds, not at every
37
+ * read (`keptReads.ts`); a text or a number needs no clone; a key the stage
38
+ * itself has written is cloned at every read from then on.
37
39
  * - `'summary'` — reads record a cheap {@link ReadSummaryMarker} (type + size
38
40
  * proxy + short preview) instead of the cloned value. O(1)-ish per read —
39
41
  * no value clone, no serialization of large objects.
@@ -0,0 +1,118 @@
1
+ /**
2
+ * hiddenObjectTrail.ts — one frame's side of "a hidden object keeps its rule wherever the stage puts it".
3
+ *
4
+ * `selectedObjects.ts` knows objects: which ones a stage read under a hidden name, and how to find
5
+ * them in a value. This file knows the frame: which keys it wrote, what each of them showed when it
6
+ * was written, and the two moments a written value is searched.
7
+ *
8
+ * 1. AT THE WRITE (`stage`). The new value is searched before its bytes are staged, because the
9
+ * verdict decides those bytes and the write event.
10
+ * 2. AT COMMIT (`followAtCommit`). The record takes a value as it stands when the stage commits. A
11
+ * stage that writes an object and then puts a hidden one into it (`s.box = o; o.p = s.secret`)
12
+ * records `p`, and no write ever showed it. So each written key is searched once more, and a key
13
+ * that gains a hidden place is staged again as a `set` of its value, so that the record hides it.
14
+ * That changes the key's row in this case only.
15
+ *
16
+ * WHY A WRITTEN KEY KEEPS WHAT IT SHOWED (`shown`). The search at commit must find what was put in
17
+ * AFTER the write and nothing else: a record must not change because a stage read a key. One case
18
+ * needs help. An object the stage wrote under a public name and then hid (`s.public = h; s.hidden =
19
+ * h`) is a remembered object in `public` by the time of the commit, and nothing was put in. So each
20
+ * key keeps the objects that sat at its public places when it was written and were not hidden then.
21
+ * They come from three walks, each of what the stage wrote and nothing more:
22
+ *
23
+ * - the search at the write itself (`selectedObjects.ts · findIn` adds them as it goes);
24
+ * - after a merge, the containers the record made for it: the patch was searched, and the key now
25
+ * holds the record's own copies of it;
26
+ * - once, when the stage reads its first hidden object: the keys it wrote before that were never
27
+ * searched, because there was nothing to look for.
28
+ *
29
+ * Anything else that turns up at commit counts as put in: when in doubt, it is hidden. (One such case
30
+ * is known and harmless: a write BELOW a key through the frame's path API copies the containers above
31
+ * it, and those copies are not noted. One of them copied under a hidden name and read back is then
32
+ * hidden at its own place too.)
33
+ *
34
+ * WHY WHAT THE FRAME KEEPS OF A WRITE IS LOOKED AT TOO (`keep`). A frame keeps each write for its
35
+ * snapshot (the execution tree, the commit event) and takes the kept form at commit. For a `set` the
36
+ * kept value is what the record holds, so it takes the key's rule as the search left it. For a MERGE
37
+ * it is not: the record copied the patch when it merged it, and the frame still holds the caller's
38
+ * patch. A hidden object put into that patch afterwards never reaches the record, and it did reach
39
+ * the kept form. So the kept patch is searched as it stands, and what is found is hidden in the kept
40
+ * form only: the record does not hold it, so no rule of the run changes.
41
+ *
42
+ * WHY THIS IS NOT IN `StageContext`. It is one rule with its own state (the remembered objects, the
43
+ * written keys), and the frame already holds too much. The frame keeps the write funnel and the marks;
44
+ * it asks this file at a hidden read, at a write, at commit and when a try is thrown away.
45
+ *
46
+ * No outside source: it is the bookkeeping of `selectedObjects.ts`, which says where the idea is from.
47
+ */
48
+ import type { RecordFrame, WriteVerb } from 'foottrace/write';
49
+ import { type RedactionRule, type RedactionVerdict } from './redaction.js';
50
+ import { type SelectedRule, SelectedObjects } from './selectedObjects.js';
51
+ /**
52
+ * What a frame keeps of one write for its snapshot (`StageContext · _pendingWrites`): the value by
53
+ * reference, the verdict it will be retained under, and where it was written.
54
+ */
55
+ export interface KeptWrite {
56
+ readonly value: unknown;
57
+ verdict: RedactionVerdict;
58
+ readonly operation: 'set' | 'update' | 'delete';
59
+ readonly path: readonly string[];
60
+ readonly key: string;
61
+ }
62
+ export declare class HiddenObjectTrail {
63
+ private readonly record;
64
+ private readonly rule;
65
+ private selected?;
66
+ private written?;
67
+ /** The input that was last looked at for selected objects ({@link rememberInput}). */
68
+ private inputSeen?;
69
+ /** `record` is the frame's record; `rule` gives the redaction rule that is active when it is asked. */
70
+ constructor(record: RecordFrame, rule: () => RedactionRule | undefined);
71
+ /** The objects read under a hidden name so far. None: there is nothing to follow yet. */
72
+ get objects(): SelectedObjects | undefined;
73
+ /**
74
+ * `value` was read under a hidden name: it, and every object inside it, keeps `rule` from now on.
75
+ * At the first one, the keys the frame wrote before are noted for what they show (file header, why).
76
+ */
77
+ remember(value: unknown, rule: SelectedRule): void;
78
+ /**
79
+ * The stage's input was handed out (`$getArgs()`): `input` is what the stage holds, `source` the
80
+ * record it was made from (the same for every stage of a run). Inside a sub-flowchart the input IS
81
+ * the parent's values. What the library hides when it SERVES that input is what the stage must not
82
+ * pass on: so the one rule that serves it is asked (`servedPlaces.ts`), and every place it hides is
83
+ * remembered, as fields of the input.
84
+ *
85
+ * An input the rule cannot serve (its keys cannot be read) is remembered whole: the safe side, and
86
+ * `$getArgs()` does not fail.
87
+ */
88
+ rememberInput(input: unknown, source?: unknown): void;
89
+ /**
90
+ * Steps 2 and 3 of a staged write (`StageContext · stageWrite`): search the value for hidden objects,
91
+ * then stage its bytes under the verdict that comes of it. Returns that verdict.
92
+ *
93
+ * `asked` is step 1's verdict, by name. `nsPath` is the absolute path of the write, `path` and `key`
94
+ * its user-level spelling.
95
+ */
96
+ stage(active: RedactionRule | undefined, asked: RedactionVerdict, nsPath: string[], path: readonly string[], key: string, value: unknown, verb: WriteVerb): RedactionVerdict;
97
+ /**
98
+ * Search every key this frame wrote once more, as it stands now, before it is recorded. `restaged`
99
+ * is told of each key that gained a hidden place: its bytes are staged again here, as a `set` of
100
+ * its value under the new verdict; the marks are the frame's. Then each write the frame KEPT
101
+ * (`kept`) gets the verdict its kept form is taken under.
102
+ */
103
+ followAtCommit(restaged: (root: string, at: string[], verdict: RedactionVerdict) => void, kept?: Iterable<KeptWrite>): void;
104
+ /** Give one kept write the verdict it is retained under, as its value stands now (file header, why). */
105
+ private keep;
106
+ /** A try was thrown away: what it wrote was never written. What it READ stays (`StageContext · discardStaged`, why). */
107
+ discard(): void;
108
+ /** The record of the top key a write at `nsPath` lands in. */
109
+ private keyOf;
110
+ /**
111
+ * What the frame's view holds at `at` now, for the search of a write: a part of the new value that is
112
+ * the same object there is not new, and is not searched again. With one exception: the SAME object
113
+ * written back. A stage does that after changing it in place, so nothing of it can be passed over.
114
+ */
115
+ private heldNow;
116
+ /** The stage's first hidden read: note what each key written before it shows. Nothing is remembered yet, so nothing in them is hidden. */
117
+ private noteWhatWasWritten;
118
+ }