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
@@ -0,0 +1,7 @@
1
+ import type { StageSnapshot } from './frameTypes.js';
2
+ /**
3
+ * Return the distinct tracked read names on a stage, in lexical order.
4
+ * Works on live snapshots and reopened records. Old records can only report
5
+ * the names they retained. Read tracking set to off reports an empty list.
6
+ */
7
+ export declare function readKeysOf(stage: Pick<StageSnapshot, 'stageReads' | 'undefinedReadKeys'>): string[];
@@ -0,0 +1,49 @@
1
+ import type { AttemptRecord, AttemptSummary, LateWrite } from '../attempt/types.js';
2
+ import { type SourceReadCounter } from '../capture/sourceReadCounts.js';
3
+ import type { StageAttention } from './attention.js';
4
+ import type { DiagnosticCollector } from './DiagnosticCollector.js';
5
+ import type { StageSnapshot } from './frameTypes.js';
6
+ import type { RedactionRule } from './redaction.js';
7
+ type SnapshotFrame = {
8
+ readonly stageId: string;
9
+ readonly runtimeStageId: string;
10
+ readonly stageName: string;
11
+ readonly isDecider: boolean;
12
+ readonly isFork: boolean;
13
+ readonly description?: string;
14
+ readonly subflowId?: string;
15
+ readonly debug: Pick<DiagnosticCollector, 'logContext' | 'errorContext' | 'metricContext' | 'evalContext' | 'flowMessages'>;
16
+ readonly readSources?: {
17
+ readonly observing: boolean;
18
+ };
19
+ readonly captureClosureTracking?: boolean;
20
+ };
21
+ type SnapshotLinks<Frame> = {
22
+ readonly next?: Frame;
23
+ readonly children?: readonly Frame[];
24
+ };
25
+ /** Read retained frame data at the point it is used, including through pending-write projection. */
26
+ export type StageSnapshotInputs<Frame> = {
27
+ sourceReadCounter(frame: Frame): Pick<SourceReadCounter, 'snapshot'> | undefined;
28
+ sourceInvocations(frame: Frame): number;
29
+ closureInvocations(frame: Frame): {
30
+ readonly count: number;
31
+ } | undefined;
32
+ retainedWrites(frame: Frame): Readonly<Record<string, {
33
+ readonly value: unknown;
34
+ }>>;
35
+ stageReads(frame: Frame): Readonly<Record<string, unknown>>;
36
+ unsetNestedReads(frame: Frame): ReadonlyMap<string, {
37
+ readonly path: readonly string[];
38
+ readonly key: string;
39
+ }> | undefined;
40
+ attempts(frame: Frame): readonly AttemptRecord[] | undefined;
41
+ attemptSummary(frame: Frame): AttemptSummary | undefined;
42
+ lateWrites(frame: Frame): readonly LateWrite[] | undefined;
43
+ attemptsDropped(frame: Frame): number;
44
+ attention(frame: Frame): Pick<StageAttention, 'snapshot'> | undefined;
45
+ };
46
+ export declare function buildStageSnapshotTree<Frame extends SnapshotLinks<Frame>>(rootFrame: Frame, redaction: RedactionRule | undefined, project: (frame: Frame, rule: RedactionRule | undefined) => StageSnapshot): StageSnapshot;
47
+ /** This frame's fields, before the execution walk links its successors. */
48
+ export declare function buildStageSnapshot<Frame extends SnapshotFrame>(frame: Frame, inputs: StageSnapshotInputs<Frame>, rule: RedactionRule | undefined): StageSnapshot;
49
+ export {};
@@ -87,4 +87,4 @@ export declare function arrayProxyAt(sink: WriteSink, path: readonly string[], c
87
87
  * what `getCurrent` returns now.
88
88
  * @returns Proxied array with copy-on-write semantics
89
89
  */
90
- export declare function createArrayProxy<T>(getCurrent: () => T[], commit: (newArray: T[]) => void, name?: string, captured?: T[], readMember?: MemberReader): T[];
90
+ export declare function createArrayProxy<T>(getCurrent: () => T[], commit: (newArray: T[]) => void, name?: string, captured?: T[], readMember?: MemberReader, onNestedReadGap?: () => void): T[];
@@ -63,7 +63,10 @@ export declare function liveObject(raw: Record<string, unknown>, current: unknow
63
63
  * path — through the parent's {@link cachedMember} — and only THAT step
64
64
  * differs per factory (the cycle policy).
65
65
  */
66
- export declare function liveGetTrap(live: () => Record<string, unknown>, segments: readonly string[], child: (value: unknown, path: string[]) => unknown, members: MemberCache, readMember?: MemberReader): ProxyHandler<object>['get'];
66
+ export declare function liveGetTrap(live: () => Record<string, unknown>, segments: readonly string[], child: (value: unknown, path: string[]) => unknown, members: MemberCache, readMember?: MemberReader, onNestedReadGap?: () => void): ProxyHandler<object>['get'];
67
+ type DescriptorTrap = NonNullable<ProxyHandler<object>['getOwnPropertyDescriptor']>;
68
+ /** Descriptors expose a value or accessor outside the member reader. Preserve the descriptor and proxy invariants. */
69
+ export declare function observeDescriptor(read: DescriptorTrap, onNestedReadGap?: () => void): DescriptorTrap;
67
70
  /**
68
71
  * The three inspection traps (`in`, `Object.keys`, descriptors) answered from
69
72
  * the live object. The one Proxy invariant that could bite — a non-extensible
@@ -75,4 +78,5 @@ export declare function liveGetTrap(live: () => Record<string, unknown>, segment
75
78
  * the only descriptor the invariant accepts; any other live descriptor is
76
79
  * reported configurable.
77
80
  */
78
- export declare function liveInspectionTraps(live: () => object): Pick<ProxyHandler<object>, 'has' | 'ownKeys' | 'getOwnPropertyDescriptor'>;
81
+ export declare function liveInspectionTraps(live: () => object, onNestedReadGap?: () => void): Pick<ProxyHandler<object>, 'has' | 'ownKeys' | 'getOwnPropertyDescriptor'>;
82
+ export {};
@@ -8,4 +8,4 @@ export type MemberReader = (path: readonly string[], parent: object) => unknown;
8
8
  * a path-aware scope read may fall back to a root value the member expression
9
9
  * did not read. No sibling scan is needed.
10
10
  */
11
- export declare function memberReader(currentRoot: () => unknown, rootKey: string, read: (segments: readonly string[]) => unknown): MemberReader;
11
+ export declare function memberReader(currentRoot: () => unknown, rootKey: string, read: (segments: readonly string[]) => unknown, onGap?: () => void): MemberReader;
@@ -194,6 +194,8 @@ export type TypedScope<T extends object = Record<string, unknown>> = T & ScopeMe
194
194
  export interface ReactiveOptions {
195
195
  /** Optional path-aware read port. Supplied by the built-in factory only when requested by run policy. */
196
196
  readNested?: (segments: readonly string[]) => unknown;
197
+ /** Reports when the path-aware scope returns data it cannot observe at member granularity. */
198
+ onNestedReadGap?: () => void;
197
199
  /**
198
200
  * Pipeline break function — injected by StageRunner after scope creation.
199
201
  * Accepts an optional reason string that propagates to `FlowBreakEvent`
@@ -22,6 +22,7 @@ import { type MemberReader } from './nestedReads.js';
22
22
  export interface WriteSink {
23
23
  /** Optional tracked real-member read; all internal live/inspection reads stay silent. */
24
24
  readonly readMember?: MemberReader;
25
+ readonly onNestedReadGap?: () => void;
25
26
  /** The value at `path`, as it stands NOW (read-your-writes; never a tracked read). */
26
27
  readAt(path: readonly string[]): unknown;
27
28
  /** Put an already-unwrapped `value` at `path`. The sink chooses the verb. */
@@ -43,14 +44,14 @@ export interface RootKeyTarget {
43
44
  * sink knows that; the traps do not. Every write drops the key's cached child
44
45
  * proxy (`cache`), so the next read is built over the new value.
45
46
  */
46
- export declare function rootKeySink(target: RootKeyTarget, readSilent: (key: string) => unknown, rootKey: string, cache: Pick<MemberCache, 'delete'>, readNested?: (segments: readonly string[]) => unknown): WriteSink;
47
+ export declare function rootKeySink(target: RootKeyTarget, readSilent: (key: string) => unknown, rootKey: string, cache: Pick<MemberCache, 'delete'>, readNested?: (segments: readonly string[]) => unknown, onNestedReadGap?: () => void): WriteSink;
47
48
  /**
48
49
  * WHY: a write inside an array element is an array write — it rebuilds the
49
50
  * owning array immutably and hands the WHOLE new array to the array proxy's
50
51
  * commit, the funnel `push` already uses. `path` is measured from the
51
52
  * element; `[]` is the element slot itself.
52
53
  */
53
- export declare function elementSink(getCurrent: () => unknown[], commit: (next: unknown[]) => void, index: number, arrayName?: string, forWrite?: () => unknown[], readMember?: MemberReader): WriteSink;
54
+ export declare function elementSink(getCurrent: () => unknown[], commit: (next: unknown[]) => void, index: number, arrayName?: string, forWrite?: () => unknown[], readMember?: MemberReader, onNestedReadGap?: () => void): WriteSink;
54
55
  /**
55
56
  * WHY one set trap: the assigned value is taken as a VALUE here (a handle
56
57
  * becomes what it stands for, `handles.ts`; nothing else is copied — the
@@ -34,6 +34,7 @@ export declare class AttemptRecorder implements FlowRecorder {
34
34
  decisions: AttemptDecisionRow[];
35
35
  };
36
36
  aggregate(supplied?: AttemptQuery): Promise<AttemptAggregate>;
37
+ private readAggregate;
37
38
  private readStored;
38
39
  toSnapshot(): {
39
40
  name: string;
@@ -127,6 +128,87 @@ export declare class AttemptRecorder implements FlowRecorder {
127
128
  }[];
128
129
  }[];
129
130
  };
131
+ /** Export admitted OTLP metrics and their storage accounting after reload. */
132
+ toStoredOTel(supplied?: AttemptQuery): Promise<{
133
+ metrics: {
134
+ resourceMetrics: {
135
+ resource: {
136
+ attributes: never[];
137
+ };
138
+ scopeMetrics: {
139
+ scope: {
140
+ name: string;
141
+ };
142
+ metrics: ({
143
+ name: string;
144
+ unit: string;
145
+ description: string;
146
+ histogram: {
147
+ aggregationTemporality: number;
148
+ dataPoints: {
149
+ attributes: {
150
+ key: string;
151
+ value: {
152
+ stringValue: string;
153
+ };
154
+ }[];
155
+ startTimeUnixNano: string;
156
+ timeUnixNano: string;
157
+ count: string;
158
+ sum: number;
159
+ explicitBounds: number[];
160
+ bucketCounts: string[];
161
+ exemplars: {
162
+ traceId?: string | undefined;
163
+ asDouble: number;
164
+ timeUnixNano: string;
165
+ filteredAttributes: {
166
+ key: string;
167
+ value: {
168
+ stringValue: string;
169
+ };
170
+ }[];
171
+ }[];
172
+ }[];
173
+ };
174
+ sum?: undefined;
175
+ } | {
176
+ name: string;
177
+ unit: string;
178
+ sum: {
179
+ aggregationTemporality: number;
180
+ isMonotonic: boolean;
181
+ dataPoints: {
182
+ attributes: {
183
+ key: string;
184
+ value: {
185
+ stringValue: string;
186
+ };
187
+ }[];
188
+ startTimeUnixNano: string;
189
+ timeUnixNano: string;
190
+ asDouble: number;
191
+ exemplars: {
192
+ asDouble: number;
193
+ traceId?: string | undefined;
194
+ timeUnixNano: string;
195
+ filteredAttributes: {
196
+ key: string;
197
+ value: {
198
+ stringValue: string;
199
+ };
200
+ }[];
201
+ }[];
202
+ }[];
203
+ };
204
+ description?: undefined;
205
+ histogram?: undefined;
206
+ })[];
207
+ }[];
208
+ }[];
209
+ };
210
+ storage: AttemptStorageStats;
211
+ }>;
130
212
  /** Clear completed local projections; active/paused evidence and bounded ownership survive executor auto-clear. */
131
213
  clear(): void;
132
214
  }
@@ -181,7 +181,7 @@ export declare class ControlDepRecorder implements FlowRecorder {
181
181
  capture?: {
182
182
  version: 1;
183
183
  runId: string;
184
- control: "captured" | "partial";
184
+ control: "partial" | "captured";
185
185
  } | undefined;
186
186
  name: string;
187
187
  };
@@ -1,7 +1,10 @@
1
- import type { AttemptAggregate, AttemptMetricRef, AttemptRow, AttemptStorageStats, PhysicalAttemptRow } from './attemptMetricsTypes.js';
1
+ import type { AttemptAggregate, AttemptFailureProvenance, AttemptMetricRef, AttemptRow, AttemptStorageStats, PhysicalAttemptRow } from './attemptMetricsTypes.js';
2
2
  export declare const attemptRowKey: (row: AttemptRow) => string;
3
3
  export declare const logicalKey: (runId: string, series: string, attempt: number) => string;
4
4
  export declare const seriesKey: (runId: string, series: string) => string;
5
+ export declare const latestAttemptRows: (rows: readonly AttemptRow[]) => AttemptRow[];
6
+ /** A legacy category is usable, but its origin was never recorded. */
7
+ export declare function failureProvenance(row: PhysicalAttemptRow): AttemptFailureProvenance | undefined;
5
8
  export declare function reference(row: PhysicalAttemptRow): AttemptMetricRef;
6
9
  export declare function worst(rows: readonly PhysicalAttemptRow[], limit: number): AttemptMetricRef[];
7
10
  export declare function aggregateAttempts(rows: readonly AttemptRow[], exemplars: number, storage: AttemptStorageStats): AttemptAggregate;
@@ -2,6 +2,8 @@
2
2
  import type { AttemptId } from 'foottrace';
3
3
  import type { RetryLoopCall, RetryLoopDecision } from '../attempt/retryLoopTypes.js';
4
4
  import type { AttemptCategory, AttemptEffect, AttemptKind, AttemptNext, AttemptOutcome, AttemptReason } from '../attempt/types.js';
5
+ /** How the recorded failure category was obtained. Older rows may lack this fact. */
6
+ export type AttemptFailureProvenance = 'declared' | 'classified' | 'unknown';
5
7
  export interface AttemptMetricRef {
6
8
  readonly id: AttemptId;
7
9
  readonly series: string;
@@ -15,6 +17,7 @@ export interface AttemptMetricRef {
15
17
  readonly durationMs: number;
16
18
  readonly outcome: AttemptOutcome;
17
19
  readonly category?: AttemptCategory;
20
+ readonly provenance?: AttemptFailureProvenance;
18
21
  readonly next: AttemptNext;
19
22
  readonly reason: AttemptReason;
20
23
  }
@@ -69,6 +72,8 @@ export interface AttemptStats {
69
72
  readonly byKind: Record<AttemptKind, number>;
70
73
  readonly byOutcome: Record<AttemptOutcome, number>;
71
74
  readonly byCategory: Record<AttemptCategory, number>;
75
+ /** A breakdown for each category present in the result. */
76
+ readonly byCategoryProvenance: Readonly<Partial<Record<AttemptCategory, Readonly<Record<AttemptFailureProvenance, number>>>>>;
72
77
  readonly retries: number;
73
78
  readonly seriesRetried: number;
74
79
  readonly gaveUp: number;
@@ -13,6 +13,7 @@ import type { CommitBundle, CommitValuesMode, LogAddress, LogOutcome, Meta } fro
13
13
  import type { RecordSink, WriteProvenanceMode } from 'foottrace/write';
14
14
  import { EventLog, SharedMemory } from 'foottrace/write';
15
15
  import type { RunCorrelation } from '../attempt/types.js';
16
+ import type { ExplainCapture, ExplainCaptureFactory, ExplainCaptureNote } from '../capture/explainCoverage.js';
16
17
  import type { RecordSinkStats } from '../capture/sinkStats.js';
17
18
  import type { FanoutCollections } from '../capture/subflowHandoff.js';
18
19
  export type { RecordSinkStats } from '../capture/sinkStats.js';
@@ -69,8 +70,8 @@ export type RuntimeSnapshot = {
69
70
  * snapshot carries a DIFFERENT runId than the paused run's snapshot.
70
71
  */
71
72
  readonly runId: string;
72
- /** Opt-in native observation; root log and current leg only, never durable storage. */
73
- readonly capture?: NativeCaptureObservation;
73
+ /** Opt-in current-leg evidence, never a durable storage receipt. */
74
+ readonly capture?: NativeCaptureObservation | ExplainCaptureNote;
74
75
  /** Opt-in native work counts; terminal unverified observations never authorize complete capture. */
75
76
  readonly captureExtent?: NativeCaptureExtent;
76
77
  /** Opt-in ordered native occurrences. Unknown ownership has no record; never infer observed-empty. */
@@ -175,13 +176,16 @@ export declare class ExecutionRuntime {
175
176
  /** @internal Current native leg's runtime bank; each scope captures its own stage view. */
176
177
  runFrame?: RunFrame;
177
178
  readSources?: EngineReadSourceCapture;
178
- /** Present only for the current opted-in root leg. Never inherited by a subflow runtime. */
179
+ /** Current native log and leg. A mounted child begins its own v3 observation. */
179
180
  capture?: NativeCapture;
180
181
  captureExtent?: NativeExtent;
181
- beginCapture(runId: string, extent?: boolean): NativeCapture;
182
+ beginCapture(runId: string, extent?: boolean, explanation?: ExplainCaptureFactory): NativeCapture;
182
183
  /** A reused log cannot be retrofitted or relabelled as the new leg's base. */
183
184
  resumeReadSources(runId: string): void;
184
185
  captureSnapshot(to: number, control?: CaptureChannelStatus, redact?: boolean): NativeCaptureObservation | undefined;
186
+ /** The v3 wire note is a served memory view. Stored capture and checkpoints keep their strict codecs. */
187
+ explainSnapshot(control?: CaptureChannelStatus, redact?: boolean): ExplainCaptureNote | undefined;
188
+ finishChildExplanation(status: 'completed' | 'paused' | 'failed' | 'cancelled', broken?: boolean, error?: unknown): void;
185
189
  globalStore: SharedMemory;
186
190
  /**
187
191
  * Parallel redacted mirror of `globalStore`. Populated by every commit that
@@ -218,6 +222,7 @@ export declare class ExecutionRuntime {
218
222
  readonly address?: LogAddress;
219
223
  readonly unavailable?: SourceLimitation;
220
224
  readonly historyOmitted?: boolean;
225
+ readonly explain?: ExplainCapture;
221
226
  });
222
227
  /**
223
228
  * A fresh root frame for this runtime — `globalStore`, `executionHistory`,
@@ -280,9 +285,8 @@ export declare class ExecutionRuntime {
280
285
  * resume (resumption must replay against the real values, not
281
286
  * '[REDACTED]').
282
287
  *
283
- * Other fields (`executionTree`, `commitLog`) are the same either way —
284
- * the commit log is already redacted at write-time, and the execution
285
- * tree only carries structural metadata.
288
+ * The commit log and stage tree use the same retention rules in both views.
289
+ * The stage tree checks the current rule for previously unset reads.
286
290
  *
287
291
  * `initialState` is the actual frozen pre-run base, served through the same
288
292
  * state rule as the mirror seed and a record sink's opened entry. Read the
@@ -296,6 +296,7 @@ export declare class FlowChartExecutor<TOut = any, TScope = any> {
296
296
  * for observable detach prefer `detachAndJoinLater` + `.wait().catch()`.
297
297
  */
298
298
  detachAndForget(driver: import('../detach/types.js').DetachDriver, child: import('../builder/types.js').FlowChart, input?: unknown): void;
299
+ private activeExplainCapture;
299
300
  /**
300
301
  * The executor-owned narrative view; `.map(e => e.text)` for flat strings.
301
302
  * `enableNarrative(options)` configures this view. Attaching a flow recorder
@@ -8,5 +8,6 @@ export declare class RunLease {
8
8
  private readonly runnerId;
9
9
  private active?;
10
10
  constructor(runnerId: string);
11
+ owns(runId: string): boolean;
11
12
  acquire(): RunAdmission;
12
13
  }
@@ -19,6 +19,11 @@ export interface ChartOpenAPIOptions {
19
19
  description?: string;
20
20
  path?: string;
21
21
  }
22
+ /** Mermaid generation options. */
23
+ export interface ChartMermaidOptions {
24
+ /** Draw eagerly mounted subflows as nested subgraphs. Defaults to false. */
25
+ expandSubflows?: boolean;
26
+ }
22
27
  /** MCP tool description — shape required by the Model Context Protocol spec. */
23
28
  export interface MCPToolDescription {
24
29
  name: string;
@@ -49,7 +54,7 @@ export interface RunnableFlowChart<TOut = any, TScope = any> extends FlowChart<T
49
54
  /** Generate MCP tool description from chart metadata. Cached. */
50
55
  toMCPTool(): MCPToolDescription;
51
56
  /** Generate a Mermaid flowchart diagram string from the chart's node graph. */
52
- toMermaid(): string;
57
+ toMermaid(options?: ChartMermaidOptions): string;
53
58
  /**
54
59
  * The slowest this chart can take, from its declared retry policies — `timeBudget(chart, options)`. Checks
55
60
  * against the chart's declared `.budget(ms)` unless `options.budgetMs` is given.
@@ -57,10 +62,10 @@ export interface RunnableFlowChart<TOut = any, TScope = any> extends FlowChart<T
57
62
  timeBudget(options?: TimeBudgetOptions): TimeBudgetReport;
58
63
  }
59
64
  /**
60
- * The node graph from `root` as Mermaid `flowchart TD` text — the one walker behind `chart.toMermaid()` and
61
- * `FlowChartBuilder · toMermaid`. Each node is declared once, labelled with its name (a `"` written `#quot;`), and
62
- * every edge is drawn; a loop-ref stub draws its back-edge and is never declared. Ids are sanitised to
63
- * `[A-Za-z0-9_]`; when two ids sanitise alike, the later one gets `_2`, `_3`, … so no node is dropped.
65
+ * Draw the default `flowchart TD` from a chart root. Declare each node once and draw every edge.
66
+ * A loop-reference stub points to the first placement of its target ID, as the engine's loop lookup does.
67
+ * Labels escape quotes as `#quot;`.
68
+ * IDs use `[A-Za-z0-9_]`; collisions get `_2`, `_3`, and so on in encounter order.
64
69
  */
65
70
  export declare function chartToMermaid(root: StageNode): string;
66
71
  /**
@@ -0,0 +1,25 @@
1
+ import type { FlowChart } from '../builder/types.js';
2
+ import type { RunnableFlowChart } from './RunnableChart.js';
3
+ /** One declared subflow placement, with a chart-local path suitable for a documentation index. */
4
+ export interface ChartMount {
5
+ readonly subflowId: string;
6
+ readonly subflowName: string;
7
+ /** Slash-separated mount IDs from the chart being described. */
8
+ readonly subflowPath: string;
9
+ readonly isLazy: boolean;
10
+ /** Entry stage of an eagerly mounted chart, when its structure is present. */
11
+ readonly entryStageId?: string;
12
+ /** Description declared on the mount or its eager entry stage. */
13
+ readonly description?: string;
14
+ }
15
+ /**
16
+ * List mount placements in graph order, descending into each eager mount.
17
+ * Lazy mounts appear without resolving them. Runtime fan-out creates its branches during a run.
18
+ */
19
+ export declare function listMounts(chart: Pick<FlowChart, 'buildTimeStructure'>): readonly ChartMount[];
20
+ /**
21
+ * Generate a Markdown README for one built chart. The drawing uses the chart's
22
+ * default Mermaid export. Stage and loop details describe this chart, with eager
23
+ * child charts represented by their mounts. No stage or lazy resolver is called.
24
+ */
25
+ export declare function describeChart(chart: Pick<RunnableFlowChart, 'buildTimeStructure' | 'description' | 'toMermaid'>): string;
@@ -8,6 +8,7 @@
8
8
  import type { Meta } from 'foottrace';
9
9
  import type { RunCorrelation } from '../attempt/types.js';
10
10
  import type { FlowChart } from '../builder/types.js';
11
+ import type { ExplainCaptureFactory } from '../capture/explainCoverage.js';
11
12
  import { type SubflowCaptureOptions, type SubflowCapturePort } from '../capture/subflowCapability.js';
12
13
  import type { ResumeEntry } from '../engine/handlers/ResumeEntry.js';
13
14
  import type { ScopeFactory, StreamHandlers } from '../engine/types.js';
@@ -101,6 +102,7 @@ export interface ExecutorArgs<TOut, TScope> {
101
102
  /** The record sink, resolved and checked at construction (10.1, P6). */
102
103
  sink?: ResolvedRecordSink;
103
104
  captureCoverage?: boolean;
105
+ explainCapture?: ExplainCaptureFactory;
104
106
  captureExtent?: boolean;
105
107
  captureClosure?: boolean;
106
108
  }
@@ -1,4 +1,5 @@
1
- import type { AttemptContext, AttemptError, CallOptions, RetryPolicy, RunCorrelation } from '../attempt/types.js';
1
+ import type { DeclaredFailureOwner } from '../attempt/declared.js';
2
+ import type { AttemptContext, AttemptError, CallOptions, DeclaredWrite, RetryPolicy, RunCorrelation } from '../attempt/types.js';
2
3
  import type { FlowChart } from '../builder/types.js';
3
4
  import type { DetachDriver, DetachHandle } from '../detach/types.js';
4
5
  import type { ExecutionEnv } from '../engine/types.js';
@@ -163,6 +164,11 @@ export declare class ScopeFacade {
163
164
  * ```
164
165
  */
165
166
  getAttempt(): AttemptContext;
167
+ /** @internal For the optional declared-attempts entry point. */
168
+ declaredFailureOwner(): DeclaredFailureOwner & {
169
+ readonly context: StageContext;
170
+ sealScope(): void;
171
+ };
166
172
  /**
167
173
  * A call to an outside system, made inside this stage — `scope.$call(target, fn, policy?)` (design §3.6, P2).
168
174
  * `fn` runs on the attempt runner under `policy` (none = ONE attempt, still recorded: a single call is evidence
@@ -335,7 +341,7 @@ export declare class ScopeFacade {
335
341
  getValueAt(path: string[], key?: string): unknown;
336
342
  setValue(key: string, value: unknown, shouldRedact?: boolean, description?: string): void;
337
343
  /** Path-aware writes share recording, redaction and lifetime policy with flat writes. */
338
- setValueAt(path: string[], key: string, value: unknown, shouldRedact?: boolean, description?: string): void;
344
+ setValueAt(path: string[], key: string, value: unknown, shouldRedact?: boolean, description?: string, declared?: readonly DeclaredWrite[]): void;
339
345
  updateValue(key: string, value: unknown, description?: string): void;
340
346
  /** Path-aware merges use the same write funnel as replacements. */
341
347
  updateValueAt(path: string[], key: string, value: unknown, description?: string): void;
@@ -65,6 +65,9 @@ export declare function requireScopeRuntime(scope: unknown, message?: string): R
65
65
  /** @internal decide()/select() asked outside a stage: name THEM, not the custom-factory migration. */
66
66
  export declare function requireDecisionScopeRuntime(scope: unknown): Readonly<ScopeRuntime>;
67
67
  export declare function registerNativeCaptureTarget(target: object, context: object): void;
68
+ /** The built-in path-aware proxy owns this capability, not the facade it wraps. */
69
+ export declare function registerNativeNestedScope(scope: object, context: object): void;
70
+ export declare function hasNativeNestedScope(scope: unknown, context: object): boolean;
68
71
  /** @internal Run identity is independent from opt-in capture observation. */
69
72
  export declare function registerNativeRunTarget(target: object, context: object): void;
70
73
  export declare function hasNativeCaptureTarget(target: object, context: object): boolean;
@@ -41,7 +41,7 @@
41
41
  * empty object, `undefined` disappears. A record of plain JSON values reads back exactly (`readRecordFile` →
42
42
  * `readStoredRecord`); for richer values, bring an adapter with a richer encoding.
43
43
  */
44
- import type { RecordSink } from 'foottrace/write';
44
+ import type { RecordEntry, RecordSink } from 'foottrace/write';
45
45
  import type { CaptureHistoryOptions } from '../capture/historyTypes.js';
46
46
  /** The default cap on a record file: 64 MiB. */
47
47
  export declare const DEFAULT_FILE_SINK_MAX_BYTES: number;
@@ -51,6 +51,8 @@ export declare const DEFAULT_FILE_SINK_MAX_ENTRY_BYTES: number;
51
51
  export declare const DEFAULT_FILE_SINK_MAX_QUEUED_BYTES: number;
52
52
  /** The default bound on `flush()`: 10 s. */
53
53
  export declare const DEFAULT_FILE_SINK_FLUSH_TIMEOUT_MS = 10000;
54
+ /** How far past `maxBytes` a CLOSING entry may still go, so a full file can say how the run ended: 64 KiB. */
55
+ export declare const CLOSE_RESERVE_BYTES: number;
54
56
  /** `fileSink`'s options — every resource the sink can spend, bounded. */
55
57
  export interface FileSinkOptions {
56
58
  /**
@@ -114,6 +116,20 @@ export interface FileSink extends RecordSink, Pick<CaptureHistoryOptions, 'ackno
114
116
  * ```
115
117
  */
116
118
  export declare function fileSink(path: string, options?: FileSinkOptions): FileSink;
119
+ /** @internal Index observation never owns the writer's descriptor. */
120
+ export interface FileSinkIndex {
121
+ write(entry: RecordEntry, offset: number, bytes: Uint8Array): () => void;
122
+ omit(entry: RecordEntry, reason: 'too-large' | 'unavailable'): void;
123
+ }
124
+ /** @internal An indexed writer creates a fresh file and seals it on this descriptor. */
125
+ export declare function createFileSink(path: string, options?: FileSinkOptions, index?: FileSinkIndex): {
126
+ sink: FileSink;
127
+ finalize: <T>(inspect: (descriptor: number) => Promise<T>) => Promise<T>;
128
+ };
129
+ /** Write all of `buffer` at `position` (asynchronously, as many writes as it takes); `wrote` is how much went out. */
130
+ export declare function writeAt(fd: number, buffer: Uint8Array, position: number, done: (error: Error | null, wrote: number) => void): void;
131
+ /** `work`, or a rejection naming the bound once `ms` passed — the work goes on, nobody waits for it. */
132
+ export declare function withTimeout<T>(work: Promise<T>, ms: number, message: string, abort?: () => void): Promise<T>;
117
133
  /** A record file read back: every parsed line, and every line that could not be. */
118
134
  export interface RecordFile {
119
135
  /** The parsed entries, in file order — untrusted input for `readStoredRecord` (`foottrace`). */
@@ -3,11 +3,16 @@ export declare class IndexedRefusal extends Error {
3
3
  readonly reason: IndexedRecordFileReason;
4
4
  constructor(reason: IndexedRecordFileReason);
5
5
  }
6
+ export declare function invalidIndexedData(): never;
7
+ export declare function validIndexedAudience(value: unknown): value is string;
8
+ export declare const MAX_PUBLISHED_VIEW_BYTES: number;
6
9
  /** A stored line's text. Bytes that are not UTF-8 are corrupt data (`'invalid-data'`), never an I/O problem. */
7
10
  export declare function indexedText(bytes: Uint8Array): string;
11
+ /** JSON syntax is an admission failure once the bytes have been read. */
12
+ export declare function indexedJson(text: string): unknown;
8
13
  /** An index key, not a source-ID or record codec. Canonical record admission remains in Foottrace. */
9
14
  export declare function indexedAddress(value: unknown): string;
10
- export declare function indexedLimits(options: IndexedRecordFileOptions): IndexedLimits;
15
+ export declare function indexedLimits(options: IndexedRecordFileOptions, published?: boolean): IndexedLimits;
11
16
  export declare function refused(error: unknown): {
12
17
  readonly status: 'unknown';
13
18
  readonly reason: IndexedRecordFileReason;
@@ -0,0 +1,29 @@
1
+ import type { LogAddress } from 'foottrace';
2
+ import { fileIdentity } from './indexedIO.js';
3
+ import type { IndexedLimits, IndexedRecordUnknown } from './indexedTypes.js';
4
+ export type IndexedFileIdentity = ReturnType<typeof fileIdentity>;
5
+ export type IndexedReadStats = {
6
+ preparationBytes: number;
7
+ scopeBytes: number;
8
+ readCalls: number;
9
+ };
10
+ export type IndexedReadContext = {
11
+ readonly signal?: AbortSignal;
12
+ };
13
+ /** Own one payload descriptor during preparation, reads, cancellation and close. */
14
+ export declare function openIndexedSession<T, R>(path: string, limits: IndexedLimits, prepare: (fd: number, identity: IndexedFileIdentity, signal: AbortSignal, stats: IndexedReadStats) => Promise<T>, reader: (fd: number, identity: string, prepared: T, session: ReturnType<typeof indexedSession>) => R): Promise<{
15
+ readonly status: 'ready';
16
+ readonly reader: R;
17
+ } | IndexedRecordUnknown>;
18
+ declare function indexedSession(fd: number, identity: string, limits: IndexedLimits, stats: IndexedReadStats): {
19
+ stats: () => Readonly<{
20
+ preparationBytes: number;
21
+ scopeBytes: number;
22
+ readCalls: number;
23
+ }>;
24
+ count: (bytes: number) => number;
25
+ submitted: () => number;
26
+ read<T>(address: LogAddress, context: IndexedReadContext | undefined, work: (key: string, signal: AbortSignal) => Promise<T>): Promise<T | IndexedRecordUnknown>;
27
+ close(): Promise<void>;
28
+ };
29
+ export {};
@@ -0,0 +1,40 @@
1
+ import { type FoldedState, type LogAddress } from 'foottrace';
2
+ import { type IndexedReadContext, type IndexedReadStats } from './indexedSession.js';
3
+ import type { IndexedRecordUnknown } from './indexedTypes.js';
4
+ import { type PublishedOmissionReason } from './publishedRecordRows.js';
5
+ import { type PublishedRecordFileOptions } from './publishedRecordSelection.js';
6
+ import type { PublishedRecordFile } from './publishedRecordWriter.js';
7
+ export interface PublishedScopeResult {
8
+ readonly status: 'loaded';
9
+ /** All selected ranges and native rows were admitted. Foottrace still owns native completion. */
10
+ readonly coverage: 'whole';
11
+ readonly entries: readonly unknown[];
12
+ }
13
+ export interface PublishedStateResult {
14
+ readonly status: 'loaded';
15
+ readonly coverage: 'prefix' | 'whole';
16
+ readonly state: FoldedState;
17
+ /** Genuine pause closing positions visible in the selected prefix. */
18
+ readonly pauses: readonly number[];
19
+ }
20
+ export interface PublishedRecordUnknown extends IndexedRecordUnknown {
21
+ /** Distinct reasons from this authorized selection. Directory positions remain private. */
22
+ readonly omissions?: readonly {
23
+ readonly reason: PublishedOmissionReason;
24
+ }[];
25
+ }
26
+ export interface PublishedRecordReader {
27
+ readScope(address: LogAddress, context?: IndexedReadContext): Promise<PublishedScopeResult | PublishedRecordUnknown>;
28
+ readState(address: LogAddress, throughCommit: number, context?: IndexedReadContext): Promise<PublishedStateResult | PublishedRecordUnknown>;
29
+ close(): Promise<void>;
30
+ }
31
+ export type PublishedRecordFileResult = {
32
+ readonly status: 'ready';
33
+ readonly reader: PublishedRecordReader;
34
+ /** Physical I/O is for the trusted host. Serve only results from the reader. */
35
+ readonly diagnostics: {
36
+ readonly stats: Readonly<IndexedReadStats>;
37
+ };
38
+ } | PublishedRecordUnknown;
39
+ /** Open an authorized local publication. The trusted host supplies the independent binding, never the sidecar. */
40
+ export declare function openPublishedRecordFile(dataPath: string, indexPath: string, publication: PublishedRecordFile, options: PublishedRecordFileOptions): Promise<PublishedRecordFileResult>;
@@ -0,0 +1,8 @@
1
+ import { type PublishedRecordFile, type PublishedRecordIndex } from './publishedRecordWriter.js';
2
+ /** Copy the independent publication binding supplied by the authoritative host catalog. */
3
+ export declare function readPublication(value: PublishedRecordFile, audience: string): PublishedRecordFile;
4
+ /**
5
+ * Admit the private directory against an independently resolved publication and a pinned payload.
6
+ * The host authorizes its audience before calling. Selection still requires explicit scope admission.
7
+ */
8
+ export declare function decodePublishedRecordIndex(bytes: Uint8Array, publication: PublishedRecordFile, payloadIdentity: PublishedRecordFile['payload']): PublishedRecordIndex;
@@ -0,0 +1,13 @@
1
+ import type { RecordEntry } from 'foottrace/write';
2
+ import type { IndexedLimits } from './indexedTypes.js';
3
+ import type { PublishedRecordRange } from './publishedRecordWriter.js';
4
+ export type PublishedOmissionReason = 'too-large' | 'unavailable' | 'invalid-data' | 'stale';
5
+ type RowLimits = Pick<IndexedLimits, 'maxScopeBytes' | 'maxEntries' | 'maxEntryBytes'>;
6
+ export declare function readPublishedRows(fd: number, scope: string, ranges: readonly PublishedRecordRange[], limits: RowLimits, signal: AbortSignal, count: (bytes: number) => void, submitted: () => void, stopAt?: number): Promise<{
7
+ readonly status: 'loaded';
8
+ readonly rows: readonly RecordEntry[];
9
+ } | {
10
+ readonly status: 'omitted';
11
+ readonly reasons: readonly PublishedOmissionReason[];
12
+ }>;
13
+ export {};