foottrace 0.0.0-stage → 1.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 (196) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -2
  3. package/dist/esm/index.d.ts +27 -0
  4. package/dist/esm/index.js +12 -0
  5. package/dist/esm/lib/capture/freeze.d.ts +91 -0
  6. package/dist/esm/lib/capture/freeze.js +313 -0
  7. package/dist/esm/lib/capture/ownData.d.ts +18 -0
  8. package/dist/esm/lib/capture/ownData.js +35 -0
  9. package/dist/esm/lib/capture/valueKinds.d.ts +57 -0
  10. package/dist/esm/lib/capture/valueKinds.js +141 -0
  11. package/dist/esm/lib/ids/runtimeStageId.d.ts +173 -0
  12. package/dist/esm/lib/ids/runtimeStageId.js +193 -0
  13. package/dist/esm/lib/memory/EventLog.d.ts +105 -0
  14. package/dist/esm/lib/memory/EventLog.js +147 -0
  15. package/dist/esm/lib/memory/RecordFrame.d.ts +232 -0
  16. package/dist/esm/lib/memory/RecordFrame.js +295 -0
  17. package/dist/esm/lib/memory/SharedMemory.d.ts +46 -0
  18. package/dist/esm/lib/memory/SharedMemory.js +87 -0
  19. package/dist/esm/lib/memory/TransactionBuffer.d.ts +521 -0
  20. package/dist/esm/lib/memory/TransactionBuffer.js +946 -0
  21. package/dist/esm/lib/memory/admission.d.ts +81 -0
  22. package/dist/esm/lib/memory/admission.js +152 -0
  23. package/dist/esm/lib/memory/backtrack.d.ts +286 -0
  24. package/dist/esm/lib/memory/backtrack.js +456 -0
  25. package/dist/esm/lib/memory/commitLogUtils.d.ts +217 -0
  26. package/dist/esm/lib/memory/commitLogUtils.js +383 -0
  27. package/dist/esm/lib/memory/deltaEncoding.d.ts +66 -0
  28. package/dist/esm/lib/memory/deltaEncoding.js +121 -0
  29. package/dist/esm/lib/memory/equality.d.ts +93 -0
  30. package/dist/esm/lib/memory/equality.js +261 -0
  31. package/dist/esm/lib/memory/eventPosition.d.ts +18 -0
  32. package/dist/esm/lib/memory/eventPosition.js +1 -0
  33. package/dist/esm/lib/memory/honesty.d.ts +93 -0
  34. package/dist/esm/lib/memory/honesty.js +91 -0
  35. package/dist/esm/lib/memory/keyPaths.d.ts +125 -0
  36. package/dist/esm/lib/memory/keyPaths.js +226 -0
  37. package/dist/esm/lib/memory/logModel.d.ts +76 -0
  38. package/dist/esm/lib/memory/logModel.js +363 -0
  39. package/dist/esm/lib/memory/merge.d.ts +26 -0
  40. package/dist/esm/lib/memory/merge.js +51 -0
  41. package/dist/esm/lib/memory/pathOps.d.ts +118 -0
  42. package/dist/esm/lib/memory/pathOps.js +292 -0
  43. package/dist/esm/lib/memory/paths.d.ts +56 -0
  44. package/dist/esm/lib/memory/paths.js +60 -0
  45. package/dist/esm/lib/memory/placeholders.d.ts +39 -0
  46. package/dist/esm/lib/memory/placeholders.js +39 -0
  47. package/dist/esm/lib/memory/recordCommit.d.ts +45 -0
  48. package/dist/esm/lib/memory/recordCommit.js +60 -0
  49. package/dist/esm/lib/memory/scrub.d.ts +52 -0
  50. package/dist/esm/lib/memory/scrub.js +72 -0
  51. package/dist/esm/lib/memory/types.d.ts +209 -0
  52. package/dist/esm/lib/memory/types.js +9 -0
  53. package/dist/esm/lib/memory/utils.d.ts +73 -0
  54. package/dist/esm/lib/memory/utils.js +150 -0
  55. package/dist/esm/lib/memory/verbs.d.ts +333 -0
  56. package/dist/esm/lib/memory/verbs.js +426 -0
  57. package/dist/esm/lib/recorder/CommitRangeIndex.d.ts +147 -0
  58. package/dist/esm/lib/recorder/CommitRangeIndex.js +206 -0
  59. package/dist/esm/lib/slice/elementProvenance.d.ts +81 -0
  60. package/dist/esm/lib/slice/elementProvenance.js +189 -0
  61. package/dist/esm/lib/slice/forwardSliceForKey.d.ts +88 -0
  62. package/dist/esm/lib/slice/forwardSliceForKey.js +242 -0
  63. package/dist/esm/lib/slice/index.d.ts +26 -0
  64. package/dist/esm/lib/slice/index.js +25 -0
  65. package/dist/esm/lib/slice/keyIndex.d.ts +137 -0
  66. package/dist/esm/lib/slice/keyIndex.js +292 -0
  67. package/dist/esm/lib/slice/keyTimeline.d.ts +49 -0
  68. package/dist/esm/lib/slice/keyTimeline.js +112 -0
  69. package/dist/esm/lib/slice/keysReadSources.d.ts +51 -0
  70. package/dist/esm/lib/slice/keysReadSources.js +94 -0
  71. package/dist/esm/lib/slice/serialize.d.ts +78 -0
  72. package/dist/esm/lib/slice/serialize.js +277 -0
  73. package/dist/esm/lib/slice/sliceForKey.d.ts +40 -0
  74. package/dist/esm/lib/slice/sliceForKey.js +78 -0
  75. package/dist/esm/lib/slice/types.d.ts +567 -0
  76. package/dist/esm/lib/slice/types.js +24 -0
  77. package/dist/esm/lib/time-travel/axis.d.ts +119 -0
  78. package/dist/esm/lib/time-travel/axis.js +178 -0
  79. package/dist/esm/lib/time-travel/bundles.d.ts +77 -0
  80. package/dist/esm/lib/time-travel/bundles.js +135 -0
  81. package/dist/esm/lib/time-travel/chain.d.ts +93 -0
  82. package/dist/esm/lib/time-travel/chain.js +187 -0
  83. package/dist/esm/lib/time-travel/commitStops.d.ts +55 -0
  84. package/dist/esm/lib/time-travel/commitStops.js +201 -0
  85. package/dist/esm/lib/time-travel/index.d.ts +22 -0
  86. package/dist/esm/lib/time-travel/index.js +20 -0
  87. package/dist/esm/lib/time-travel/stateAt.d.ts +102 -0
  88. package/dist/esm/lib/time-travel/stateAt.js +152 -0
  89. package/dist/esm/lib/time-travel/tagStops.d.ts +72 -0
  90. package/dist/esm/lib/time-travel/tagStops.js +101 -0
  91. package/dist/esm/lib/time-travel/timeTravel.d.ts +70 -0
  92. package/dist/esm/lib/time-travel/timeTravel.js +359 -0
  93. package/dist/esm/lib/time-travel/types.d.ts +470 -0
  94. package/dist/esm/lib/time-travel/types.js +22 -0
  95. package/dist/esm/package.json +1 -0
  96. package/dist/esm/paths.d.ts +4 -0
  97. package/dist/esm/paths.js +4 -0
  98. package/dist/esm/write.d.ts +49 -0
  99. package/dist/esm/write.js +47 -0
  100. package/dist/index.js +67 -0
  101. package/dist/lib/capture/freeze.js +319 -0
  102. package/dist/lib/capture/ownData.js +40 -0
  103. package/dist/lib/capture/valueKinds.js +145 -0
  104. package/dist/lib/ids/runtimeStageId.js +209 -0
  105. package/dist/lib/memory/EventLog.js +151 -0
  106. package/dist/lib/memory/RecordFrame.js +299 -0
  107. package/dist/lib/memory/SharedMemory.js +91 -0
  108. package/dist/lib/memory/TransactionBuffer.js +950 -0
  109. package/dist/lib/memory/admission.js +158 -0
  110. package/dist/lib/memory/backtrack.js +462 -0
  111. package/dist/lib/memory/commitLogUtils.js +398 -0
  112. package/dist/lib/memory/deltaEncoding.js +127 -0
  113. package/dist/lib/memory/equality.js +265 -0
  114. package/dist/lib/memory/eventPosition.js +2 -0
  115. package/dist/lib/memory/honesty.js +94 -0
  116. package/dist/lib/memory/keyPaths.js +242 -0
  117. package/dist/lib/memory/logModel.js +371 -0
  118. package/dist/lib/memory/merge.js +55 -0
  119. package/dist/lib/memory/pathOps.js +308 -0
  120. package/dist/lib/memory/paths.js +66 -0
  121. package/dist/lib/memory/placeholders.js +42 -0
  122. package/dist/lib/memory/recordCommit.js +64 -0
  123. package/dist/lib/memory/scrub.js +77 -0
  124. package/dist/lib/memory/types.js +10 -0
  125. package/dist/lib/memory/utils.js +169 -0
  126. package/dist/lib/memory/verbs.js +443 -0
  127. package/dist/lib/recorder/CommitRangeIndex.js +210 -0
  128. package/dist/lib/slice/elementProvenance.js +194 -0
  129. package/dist/lib/slice/forwardSliceForKey.js +246 -0
  130. package/dist/lib/slice/index.js +42 -0
  131. package/dist/lib/slice/keyIndex.js +312 -0
  132. package/dist/lib/slice/keyTimeline.js +116 -0
  133. package/dist/lib/slice/keysReadSources.js +100 -0
  134. package/dist/lib/slice/serialize.js +285 -0
  135. package/dist/lib/slice/sliceForKey.js +82 -0
  136. package/dist/lib/slice/types.js +25 -0
  137. package/dist/lib/time-travel/axis.js +183 -0
  138. package/dist/lib/time-travel/bundles.js +143 -0
  139. package/dist/lib/time-travel/chain.js +192 -0
  140. package/dist/lib/time-travel/commitStops.js +205 -0
  141. package/dist/lib/time-travel/index.js +31 -0
  142. package/dist/lib/time-travel/stateAt.js +159 -0
  143. package/dist/lib/time-travel/tagStops.js +105 -0
  144. package/dist/lib/time-travel/timeTravel.js +363 -0
  145. package/dist/lib/time-travel/types.js +23 -0
  146. package/dist/paths.js +14 -0
  147. package/dist/types/index.d.ts +27 -0
  148. package/dist/types/lib/capture/freeze.d.ts +91 -0
  149. package/dist/types/lib/capture/ownData.d.ts +18 -0
  150. package/dist/types/lib/capture/valueKinds.d.ts +57 -0
  151. package/dist/types/lib/ids/runtimeStageId.d.ts +173 -0
  152. package/dist/types/lib/memory/EventLog.d.ts +105 -0
  153. package/dist/types/lib/memory/RecordFrame.d.ts +232 -0
  154. package/dist/types/lib/memory/SharedMemory.d.ts +46 -0
  155. package/dist/types/lib/memory/TransactionBuffer.d.ts +521 -0
  156. package/dist/types/lib/memory/admission.d.ts +81 -0
  157. package/dist/types/lib/memory/backtrack.d.ts +286 -0
  158. package/dist/types/lib/memory/commitLogUtils.d.ts +217 -0
  159. package/dist/types/lib/memory/deltaEncoding.d.ts +66 -0
  160. package/dist/types/lib/memory/equality.d.ts +93 -0
  161. package/dist/types/lib/memory/eventPosition.d.ts +18 -0
  162. package/dist/types/lib/memory/honesty.d.ts +93 -0
  163. package/dist/types/lib/memory/keyPaths.d.ts +125 -0
  164. package/dist/types/lib/memory/logModel.d.ts +76 -0
  165. package/dist/types/lib/memory/merge.d.ts +26 -0
  166. package/dist/types/lib/memory/pathOps.d.ts +118 -0
  167. package/dist/types/lib/memory/paths.d.ts +56 -0
  168. package/dist/types/lib/memory/placeholders.d.ts +39 -0
  169. package/dist/types/lib/memory/recordCommit.d.ts +45 -0
  170. package/dist/types/lib/memory/scrub.d.ts +52 -0
  171. package/dist/types/lib/memory/types.d.ts +209 -0
  172. package/dist/types/lib/memory/utils.d.ts +73 -0
  173. package/dist/types/lib/memory/verbs.d.ts +333 -0
  174. package/dist/types/lib/recorder/CommitRangeIndex.d.ts +147 -0
  175. package/dist/types/lib/slice/elementProvenance.d.ts +81 -0
  176. package/dist/types/lib/slice/forwardSliceForKey.d.ts +88 -0
  177. package/dist/types/lib/slice/index.d.ts +26 -0
  178. package/dist/types/lib/slice/keyIndex.d.ts +137 -0
  179. package/dist/types/lib/slice/keyTimeline.d.ts +49 -0
  180. package/dist/types/lib/slice/keysReadSources.d.ts +51 -0
  181. package/dist/types/lib/slice/serialize.d.ts +78 -0
  182. package/dist/types/lib/slice/sliceForKey.d.ts +40 -0
  183. package/dist/types/lib/slice/types.d.ts +567 -0
  184. package/dist/types/lib/time-travel/axis.d.ts +119 -0
  185. package/dist/types/lib/time-travel/bundles.d.ts +77 -0
  186. package/dist/types/lib/time-travel/chain.d.ts +93 -0
  187. package/dist/types/lib/time-travel/commitStops.d.ts +55 -0
  188. package/dist/types/lib/time-travel/index.d.ts +22 -0
  189. package/dist/types/lib/time-travel/stateAt.d.ts +102 -0
  190. package/dist/types/lib/time-travel/tagStops.d.ts +72 -0
  191. package/dist/types/lib/time-travel/timeTravel.d.ts +70 -0
  192. package/dist/types/lib/time-travel/types.d.ts +470 -0
  193. package/dist/types/paths.d.ts +4 -0
  194. package/dist/types/write.d.ts +49 -0
  195. package/dist/write.js +56 -0
  196. package/package.json +48 -4
@@ -0,0 +1,57 @@
1
+ /**
2
+ * valueKinds.ts — what KIND of value a record holds: the one classifier.
3
+ *
4
+ * WHY. Committed state is what survives `structuredClone` (an engine invariant), so the values a
5
+ * record holds are the kinds the clone keeps. Two laws need the kind, and both ask here:
6
+ *
7
+ * - what counts as a CHANGE (`memory/equality.ts · deepEqual`): two values are equal when a record
8
+ * holds the same thing for both, compared kind by kind. Until 9.44.2 only Date, Map and Set had a
9
+ * kind; a RegExp, an Error, a boxed number, a buffer, a DataView or a Blob was compared as an
10
+ * object with no own keys — equal to any other of its kind — so replacing one committed no row
11
+ * and live state kept the old value;
12
+ * - what a served record must COPY (`capture/freeze.ts · freezeRecord` / `serveRecord`):
13
+ * `Object.freeze` seals only the kinds whose content is their own properties ({@link SEALABLE}).
14
+ *
15
+ * A leaf: imports nothing (`capture/` is L0, below `memory/`).
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * kindOf(new Date(0)); // 'date'
20
+ * kindOf(new (class Point { x = 1 })()); // 'plain' — its clone is a plain object
21
+ * kindOf(new Blob(['a'])); // 'opaque' — its clone keeps content this library cannot read
22
+ * SEALABLE.date; // false — setTime writes a slot Object.freeze cannot reach
23
+ * ```
24
+ */
25
+ /** Every kind a record can hold. */
26
+ export type ValueKind =
27
+ /** An object the clone keeps as its own enumerable keys — a class instance included. */
28
+ 'plain' | 'array' | 'date' | 'regexp' | 'map' | 'set' | 'error'
29
+ /** A boxed primitive: `new Number(1)`, `new String('a')`, `new Boolean(true)`, `Object(1n)`. */
30
+ | 'boxed'
31
+ /** An `ArrayBuffer` (a `SharedArrayBuffer` too: shared memory is out of contract for state). */
32
+ | 'buffer'
33
+ /** A typed array or a `DataView`. */
34
+ | 'view'
35
+ /** Any other object the clone keeps as itself (a Blob, a File, a `DOMException`): content unread here. */
36
+ | 'opaque';
37
+ /**
38
+ * Does `Object.freeze` seal every part of a value of this kind? True only where the content is the
39
+ * value's own properties (or a slot nothing can write). A `Record`, so a new kind does not compile
40
+ * until it is decided here.
41
+ */
42
+ export declare const SEALABLE: {
43
+ readonly [K in ValueKind]: boolean;
44
+ };
45
+ /**
46
+ * The kind of an object, as a record holds it. A plain object or an array — the bulk of state —
47
+ * costs one `Array.isArray` and one `getPrototypeOf`; a built-in a tag and one brand-checked read.
48
+ * The brand is the value's own slot, so a subclass (a `Map` subclass is a `'map'`, Node's `Buffer` a
49
+ * `'view'`) and a value from another realm land on their kind.
50
+ *
51
+ * Any other object is classified by WHAT ITS CLONE IS, once per prototype: a class instance comes
52
+ * back a plain object (`'plain'`), a fake built-in (`Object.create(Date.prototype)`, or a class whose
53
+ * `Symbol.toStringTag` says `'Date'`) comes back `{}` (`'plain'`), and a host object comes back as
54
+ * itself (`'opaque'`). A prototype whose instance the clone refuses is `'opaque'` — remembered too:
55
+ * it cannot be held, and its commit will refuse it.
56
+ */
57
+ export declare function kindOf(value: object): ValueKind;
@@ -0,0 +1,141 @@
1
+ /**
2
+ * valueKinds.ts — what KIND of value a record holds: the one classifier.
3
+ *
4
+ * WHY. Committed state is what survives `structuredClone` (an engine invariant), so the values a
5
+ * record holds are the kinds the clone keeps. Two laws need the kind, and both ask here:
6
+ *
7
+ * - what counts as a CHANGE (`memory/equality.ts · deepEqual`): two values are equal when a record
8
+ * holds the same thing for both, compared kind by kind. Until 9.44.2 only Date, Map and Set had a
9
+ * kind; a RegExp, an Error, a boxed number, a buffer, a DataView or a Blob was compared as an
10
+ * object with no own keys — equal to any other of its kind — so replacing one committed no row
11
+ * and live state kept the old value;
12
+ * - what a served record must COPY (`capture/freeze.ts · freezeRecord` / `serveRecord`):
13
+ * `Object.freeze` seals only the kinds whose content is their own properties ({@link SEALABLE}).
14
+ *
15
+ * A leaf: imports nothing (`capture/` is L0, below `memory/`).
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * kindOf(new Date(0)); // 'date'
20
+ * kindOf(new (class Point { x = 1 })()); // 'plain' — its clone is a plain object
21
+ * kindOf(new Blob(['a'])); // 'opaque' — its clone keeps content this library cannot read
22
+ * SEALABLE.date; // false — setTime writes a slot Object.freeze cannot reach
23
+ * ```
24
+ */
25
+ /**
26
+ * Does `Object.freeze` seal every part of a value of this kind? True only where the content is the
27
+ * value's own properties (or a slot nothing can write). A `Record`, so a new kind does not compile
28
+ * until it is decided here.
29
+ */
30
+ export const SEALABLE = /* @__PURE__ */ Object.freeze({
31
+ plain: true,
32
+ array: true,
33
+ boxed: true,
34
+ date: false, // setTime & co. write its time value
35
+ regexp: false, // compile() rewrites source and flags, even on a frozen one
36
+ map: false, // set / delete / clear
37
+ set: false, // add / delete / clear
38
+ error: false, // V8's own `stack` accessor writes through a frozen error
39
+ buffer: false, // its bytes, through any view; transfer() detaches it
40
+ view: false, // index writes, set, fill, sort, copyWithin …
41
+ opaque: false, // content this library cannot read — never assumed sealed
42
+ });
43
+ /** What a brand check returns, when it does not throw, for a value without the slot. */
44
+ const NOT_BRAND = Symbol('not the brand');
45
+ /**
46
+ * A built-in kind is known by its BRAND — an internal slot only the real thing has — never by its
47
+ * prototype: `Object.create(RegExp.prototype)` is not a RegExp (its clone is `{}`), and reading
48
+ * `source` from it throws. The candidate comes from `Object.prototype.toString` (one call), then ONE
49
+ * brand-checked read confirms it; a value that fails it is classified by its clone instead.
50
+ */
51
+ const BRANDS =
52
+ /* @__PURE__ */ brandTable();
53
+ function brandTable() {
54
+ const getter = (proto, key) => {
55
+ const get = proto && Object.getOwnPropertyDescriptor(proto, key)?.get;
56
+ return get ? (value) => get.call(value) : undefined;
57
+ };
58
+ const global = globalThis;
59
+ const isError = Error.isError;
60
+ const rows = [
61
+ ['Date', 'date', (value) => Date.prototype.getTime.call(value)],
62
+ ['RegExp', 'regexp', getter(RegExp.prototype, 'source')],
63
+ ['Map', 'map', getter(Map.prototype, 'size')],
64
+ ['Set', 'set', getter(Set.prototype, 'size')],
65
+ // An error's tag comes from its own [[ErrorData]] slot: no Error prototype carries a toStringTag. Where
66
+ // the brand check `Error.isError` is missing (Node 22), a tag a getter supplies is therefore a spoof.
67
+ ['Error', 'error', (value) => ((isError ? isError(value) : untagged(value)) ? true : NOT_BRAND)],
68
+ ['Number', 'boxed', (value) => Number.prototype.valueOf.call(value)],
69
+ ['String', 'boxed', (value) => String.prototype.valueOf.call(value)],
70
+ ['Boolean', 'boxed', (value) => Boolean.prototype.valueOf.call(value)],
71
+ ['BigInt', 'boxed', (value) => (global.BigInt?.prototype).valueOf.call(value)],
72
+ ['ArrayBuffer', 'buffer', getter(ArrayBuffer.prototype, 'byteLength')],
73
+ ['SharedArrayBuffer', 'buffer', getter(global.SharedArrayBuffer?.prototype, 'byteLength')],
74
+ ];
75
+ const table = new Map();
76
+ for (const [name, kind, check] of rows)
77
+ if (check)
78
+ table.set(`[object ${name}]`, { kind, check });
79
+ return table;
80
+ }
81
+ /** No `Symbol.toStringTag` on the value or its prototypes: its tag came from a slot. */
82
+ function untagged(value) {
83
+ return value[Symbol.toStringTag] === undefined;
84
+ }
85
+ /** The kind of a built-in value, by its brand — `undefined` for anything else. */
86
+ function builtinKind(value) {
87
+ if (ArrayBuffer.isView(value))
88
+ return 'view'; // a brand check of its own: [[ViewedArrayBuffer]]
89
+ const brand = BRANDS.get(Object.prototype.toString.call(value));
90
+ if (brand === undefined)
91
+ return undefined;
92
+ try {
93
+ return brand.check(value) === NOT_BRAND ? undefined : brand.kind;
94
+ }
95
+ catch {
96
+ return undefined; // the prototype without the slot
97
+ }
98
+ }
99
+ /** Prototypes classified by a probe clone of their first instance (see {@link kindOf}). */
100
+ const PROBED = new WeakMap();
101
+ /**
102
+ * The kind of an object, as a record holds it. A plain object or an array — the bulk of state —
103
+ * costs one `Array.isArray` and one `getPrototypeOf`; a built-in a tag and one brand-checked read.
104
+ * The brand is the value's own slot, so a subclass (a `Map` subclass is a `'map'`, Node's `Buffer` a
105
+ * `'view'`) and a value from another realm land on their kind.
106
+ *
107
+ * Any other object is classified by WHAT ITS CLONE IS, once per prototype: a class instance comes
108
+ * back a plain object (`'plain'`), a fake built-in (`Object.create(Date.prototype)`, or a class whose
109
+ * `Symbol.toStringTag` says `'Date'`) comes back `{}` (`'plain'`), and a host object comes back as
110
+ * itself (`'opaque'`). A prototype whose instance the clone refuses is `'opaque'` — remembered too:
111
+ * it cannot be held, and its commit will refuse it.
112
+ */
113
+ export function kindOf(value) {
114
+ if (Array.isArray(value))
115
+ return 'array';
116
+ const proto = Object.getPrototypeOf(value);
117
+ if (proto === Object.prototype || proto === null)
118
+ return 'plain';
119
+ return builtinKind(value) ?? PROBED.get(proto) ?? probe(value, proto);
120
+ }
121
+ function probe(value, proto) {
122
+ let kind;
123
+ try {
124
+ const clone = structuredClone(value);
125
+ kind = clone === null || typeof clone !== 'object' ? 'opaque' : kindOfClone(clone);
126
+ }
127
+ catch {
128
+ kind = 'opaque';
129
+ }
130
+ PROBED.set(proto, kind);
131
+ return kind;
132
+ }
133
+ /** The kind of a CLONE — a value of this realm, so its prototype or its brand decides it. */
134
+ function kindOfClone(clone) {
135
+ if (Array.isArray(clone))
136
+ return 'array';
137
+ const proto = Object.getPrototypeOf(clone);
138
+ if (proto === Object.prototype || proto === null)
139
+ return 'plain';
140
+ return builtinKind(clone) ?? 'opaque';
141
+ }
@@ -0,0 +1,173 @@
1
+ /**
2
+ * runtimeStageId — unique identifier for each execution step during traversal.
3
+ *
4
+ * Format: [subflowPath/]stageId#executionIndex
5
+ *
6
+ * Components:
7
+ * stageId — stable node ID from the builder ('call-llm', 'seed')
8
+ * executionIndex — monotonic counter incremented per stage execution (0, 1, 2...)
9
+ * subflowPath — optional path for subflow stages ('sf-tools', 'sf-outer/sf-inner')
10
+ *
11
+ * Properties:
12
+ * - Unique within a run (executionIndex never repeats)
13
+ * - Execution-ordered (sort by executionIndex = execution order)
14
+ * - Human-readable ('sf-tools/execute-tool-calls#8')
15
+ * - Parseable (split on '#' for stageId and index, split stageId on '/' for subflow path)
16
+ *
17
+ * Naming-collision warning
18
+ * ────────────────────────
19
+ * The parsed-output `.stageId` field below is the LOCAL form (segment
20
+ * after the last '/'). This is NOT the same as `spec.id` / `node.id`
21
+ * for subflow-nested stages, which carry the FULL prefixed form
22
+ * (`'sf-tools/execute-tool-calls'`). To compare safely, use
23
+ * `splitStageId(spec.id)` to decompose the prefixed form the same
24
+ * way `parseRuntimeStageId` decomposes a runtimeStageId.
25
+ *
26
+ * @example
27
+ * ```
28
+ * buildRuntimeStageId('call-llm', 5) // 'call-llm#5'
29
+ * buildRuntimeStageId('execute-tool-calls', 8, 'sf-tools') // 'sf-tools/execute-tool-calls#8'
30
+ * buildRuntimeStageId('validate', 3, 'sf-outer/sf-inner') // 'sf-outer/sf-inner/validate#3'
31
+ * ```
32
+ *
33
+ * ## The one owner (F7, 9.37.0)
34
+ *
35
+ * This module is the ONE place the grammar is spelled. Every reader asks it —
36
+ * `isExecutionKey`, `stageIdOf`, `subflowPathOf`, `subflowSegmentsOf`,
37
+ * `lastSegmentOf`, `isWithinSubflow` — and every composer joins through
38
+ * `joinPath` / `buildRuntimeStageId`; no other file splits on `#` or `/`.
39
+ * It builds, parses and reads ids, and imports nothing: it is the record's
40
+ * (C6). The delimiters are RESERVED (RFC 3986 §2.2 style): the engine's id
41
+ * doors refuse them in user-authored ids through ONE function,
42
+ * `reservedIds.ts · refuseReservedId`, which reads them here — so
43
+ * last-delimiter parsing is sound by construction rather than by hope. Stores
44
+ * and the prefixer never refuse — they hold runtime ids and prefixed ids,
45
+ * which carry the delimiters on purpose.
46
+ */
47
+ /** Separates subflow path segments from each other and from the stage id. */
48
+ export declare const PATH_DELIMITER = "/";
49
+ /** Separates the (prefixed) stage id from the execution index. */
50
+ export declare const EXECUTION_DELIMITER = "#";
51
+ declare const RUNTIME_STAGE_ID: unique symbol;
52
+ declare const EXECUTION_INDEX: unique symbol;
53
+ declare const COMMIT_IDX: unique symbol;
54
+ /** A `[subflowPath/]stageId#executionIndex` string the grammar produced. Assignable to `string`. */
55
+ export type RuntimeStageId = string & {
56
+ readonly [RUNTIME_STAGE_ID]: true;
57
+ };
58
+ /** The run-global, monotonic position of one stage execution (the `#N`). Assignable to `number`. */
59
+ export type ExecutionIndex = number & {
60
+ readonly [EXECUTION_INDEX]: true;
61
+ };
62
+ /** A bundle's position in a commit log (`bundle.idx`). Assignable to `number`. */
63
+ export type CommitIdx = number & {
64
+ readonly [COMMIT_IDX]: true;
65
+ };
66
+ /**
67
+ * Build a runtimeStageId from its components.
68
+ *
69
+ * Note: The traverser does NOT use the subflowPath parameter — node.id already
70
+ * includes the subflow prefix from the builder. This parameter exists for external
71
+ * consumers constructing IDs from parsed components (round-trip via parseRuntimeStageId).
72
+ */
73
+ export declare function buildRuntimeStageId(stageId: string, executionIndex: number, subflowPath?: string): RuntimeStageId;
74
+ /**
75
+ * Parse a runtimeStageId into its components.
76
+ *
77
+ * IMPORTANT — naming collision: the returned `stageId` is the LOCAL
78
+ * form (the segment between the last '/' and the '#'). This is NOT
79
+ * the same as `spec.id` or `node.id` for subflow-nested stages,
80
+ * which contain the FULL prefixed form.
81
+ *
82
+ * parseRuntimeStageId('sf-tools/execute-tool-calls#8').stageId
83
+ * // → 'execute-tool-calls' (LOCAL)
84
+ *
85
+ * node.id // (post-mount, in a spec that contains subflows)
86
+ * // → 'sf-tools/execute-tool-calls' (FULL prefixed)
87
+ *
88
+ * To compare these two safely, use `splitStageId(node.id)` to get
89
+ * the local form, OR reconstruct the full form via
90
+ * `(subflowPath ? subflowPath + '/' : '') + stageId`.
91
+ */
92
+ export declare function parseRuntimeStageId(runtimeStageId: string): {
93
+ stageId: string;
94
+ executionIndex: ExecutionIndex;
95
+ subflowPath: string | undefined;
96
+ };
97
+ /**
98
+ * Decompose a (possibly prefixed) stage id into its components.
99
+ *
100
+ * Use this when you have an id WITHOUT the `#N` execution suffix and
101
+ * need the local stage name and/or the subflow path. Common sources
102
+ * of such ids:
103
+ * - `spec.id` (post-mount the id includes any subflow prefix)
104
+ * - `CommitBundle.stageId` (post-mount id)
105
+ * - `node.id` from xyflow nodes built off the spec
106
+ * - the segment of `runtimeStageId` BEFORE the `#` (use
107
+ * `parseRuntimeStageId` directly for full runtimeStageId strings)
108
+ *
109
+ * Mirrors the decomposition `parseRuntimeStageId` performs on the
110
+ * stageId portion of a runtimeStageId, so the two helpers stay in
111
+ * lockstep on naming and behavior.
112
+ *
113
+ * @example
114
+ * splitStageId('sf-tools/execute-tool-calls')
115
+ * // → { localStageId: 'execute-tool-calls', subflowPath: 'sf-tools' }
116
+ *
117
+ * splitStageId('execute-tool-calls')
118
+ * // → { localStageId: 'execute-tool-calls', subflowPath: undefined }
119
+ *
120
+ * splitStageId('sf-outer/sf-inner/validate')
121
+ * // → { localStageId: 'validate', subflowPath: 'sf-outer/sf-inner' }
122
+ */
123
+ export declare function splitStageId(prefixedStageId: string): {
124
+ localStageId: string;
125
+ subflowPath: string | undefined;
126
+ };
127
+ /**
128
+ * True when `key` names one EXECUTION (`…#N`) rather than a stage or a subflow
129
+ * path. Its presence alone decides: the delimiter is reserved in every
130
+ * user-authored id (`reservedIds.ts · refuseReservedId`), so only the grammar
131
+ * puts it there.
132
+ *
133
+ * Asked where a map is keyed by both — `subflowResults` is dual-keyed by
134
+ * subflow path AND by mount runtimeStageId.
135
+ */
136
+ export declare function isExecutionKey(key: string): boolean;
137
+ /**
138
+ * The FULL (subflow-prefixed) stage id of a runtimeStageId — everything before
139
+ * the last `#`, i.e. what `node.id` / `CommitBundle.stageId` hold. A string
140
+ * with no `#` is returned whole.
141
+ *
142
+ * @example stageIdOf('sf-tools/execute#8') // 'sf-tools/execute'
143
+ */
144
+ export declare function stageIdOf(runtimeStageId: string): string;
145
+ /** The execution index of a runtimeStageId, or `NaN` when it carries none. */
146
+ export declare function executionIndexOf(runtimeStageId: string): number;
147
+ /**
148
+ * The subflow path a runtimeStageId executes in (`'sf-a/sf-b'`), or
149
+ * `undefined` at the top level. Reads the stage-id part, so it agrees with
150
+ * `splitStageId(stageIdOf(rid)).subflowPath`.
151
+ */
152
+ export declare function subflowPathOf(runtimeStageId: string): string | undefined;
153
+ /** The subflow path of a runtimeStageId as segments (`['sf-a', 'sf-b']`); `[]` at the top level. */
154
+ export declare function subflowSegmentsOf(runtimeStageId: string): string[];
155
+ /** The non-empty segments of a subflow path or prefixed id (`'a//b/'` → `['a', 'b']`). */
156
+ export declare function pathSegments(path: string): string[];
157
+ /** The last segment of a path or prefixed id (`'sf-a/sf-b'` → `'sf-b'`); the whole string when it has none. */
158
+ export declare function lastSegmentOf(path: string): string;
159
+ /** Join path segments with the grammar's delimiter (`joinPath('sf', 'stage')` → `'sf/stage'`). */
160
+ export declare function joinPath(...segments: readonly string[]): string;
161
+ /** True when the (prefixed) id `id` sits INSIDE the subflow at `path` — at any depth below it. */
162
+ export declare function isWithinSubflow(id: string, path: string): boolean;
163
+ /**
164
+ * Shared mutable counter for execution index.
165
+ * Passed by reference to child traversers (subflows) so they
166
+ * continue the global numbering instead of restarting at 0.
167
+ */
168
+ export interface ExecutionCounter {
169
+ value: number;
170
+ }
171
+ /** Create a new execution counter starting at 0. */
172
+ export declare function createExecutionCounter(): ExecutionCounter;
173
+ export {};
@@ -0,0 +1,193 @@
1
+ /**
2
+ * runtimeStageId — unique identifier for each execution step during traversal.
3
+ *
4
+ * Format: [subflowPath/]stageId#executionIndex
5
+ *
6
+ * Components:
7
+ * stageId — stable node ID from the builder ('call-llm', 'seed')
8
+ * executionIndex — monotonic counter incremented per stage execution (0, 1, 2...)
9
+ * subflowPath — optional path for subflow stages ('sf-tools', 'sf-outer/sf-inner')
10
+ *
11
+ * Properties:
12
+ * - Unique within a run (executionIndex never repeats)
13
+ * - Execution-ordered (sort by executionIndex = execution order)
14
+ * - Human-readable ('sf-tools/execute-tool-calls#8')
15
+ * - Parseable (split on '#' for stageId and index, split stageId on '/' for subflow path)
16
+ *
17
+ * Naming-collision warning
18
+ * ────────────────────────
19
+ * The parsed-output `.stageId` field below is the LOCAL form (segment
20
+ * after the last '/'). This is NOT the same as `spec.id` / `node.id`
21
+ * for subflow-nested stages, which carry the FULL prefixed form
22
+ * (`'sf-tools/execute-tool-calls'`). To compare safely, use
23
+ * `splitStageId(spec.id)` to decompose the prefixed form the same
24
+ * way `parseRuntimeStageId` decomposes a runtimeStageId.
25
+ *
26
+ * @example
27
+ * ```
28
+ * buildRuntimeStageId('call-llm', 5) // 'call-llm#5'
29
+ * buildRuntimeStageId('execute-tool-calls', 8, 'sf-tools') // 'sf-tools/execute-tool-calls#8'
30
+ * buildRuntimeStageId('validate', 3, 'sf-outer/sf-inner') // 'sf-outer/sf-inner/validate#3'
31
+ * ```
32
+ *
33
+ * ## The one owner (F7, 9.37.0)
34
+ *
35
+ * This module is the ONE place the grammar is spelled. Every reader asks it —
36
+ * `isExecutionKey`, `stageIdOf`, `subflowPathOf`, `subflowSegmentsOf`,
37
+ * `lastSegmentOf`, `isWithinSubflow` — and every composer joins through
38
+ * `joinPath` / `buildRuntimeStageId`; no other file splits on `#` or `/`.
39
+ * It builds, parses and reads ids, and imports nothing: it is the record's
40
+ * (C6). The delimiters are RESERVED (RFC 3986 §2.2 style): the engine's id
41
+ * doors refuse them in user-authored ids through ONE function,
42
+ * `reservedIds.ts · refuseReservedId`, which reads them here — so
43
+ * last-delimiter parsing is sound by construction rather than by hope. Stores
44
+ * and the prefixer never refuse — they hold runtime ids and prefixed ids,
45
+ * which carry the delimiters on purpose.
46
+ */
47
+ /** Separates subflow path segments from each other and from the stage id. */
48
+ export const PATH_DELIMITER = '/';
49
+ /** Separates the (prefixed) stage id from the execution index. */
50
+ export const EXECUTION_DELIMITER = '#';
51
+ /**
52
+ * Build a runtimeStageId from its components.
53
+ *
54
+ * Note: The traverser does NOT use the subflowPath parameter — node.id already
55
+ * includes the subflow prefix from the builder. This parameter exists for external
56
+ * consumers constructing IDs from parsed components (round-trip via parseRuntimeStageId).
57
+ */
58
+ export function buildRuntimeStageId(stageId, executionIndex, subflowPath) {
59
+ const prefix = subflowPath ? `${subflowPath}${PATH_DELIMITER}` : '';
60
+ return `${prefix}${stageId}${EXECUTION_DELIMITER}${executionIndex}`;
61
+ }
62
+ /**
63
+ * Parse a runtimeStageId into its components.
64
+ *
65
+ * IMPORTANT — naming collision: the returned `stageId` is the LOCAL
66
+ * form (the segment between the last '/' and the '#'). This is NOT
67
+ * the same as `spec.id` or `node.id` for subflow-nested stages,
68
+ * which contain the FULL prefixed form.
69
+ *
70
+ * parseRuntimeStageId('sf-tools/execute-tool-calls#8').stageId
71
+ * // → 'execute-tool-calls' (LOCAL)
72
+ *
73
+ * node.id // (post-mount, in a spec that contains subflows)
74
+ * // → 'sf-tools/execute-tool-calls' (FULL prefixed)
75
+ *
76
+ * To compare these two safely, use `splitStageId(node.id)` to get
77
+ * the local form, OR reconstruct the full form via
78
+ * `(subflowPath ? subflowPath + '/' : '') + stageId`.
79
+ */
80
+ export function parseRuntimeStageId(runtimeStageId) {
81
+ const hashIdx = runtimeStageId.lastIndexOf(EXECUTION_DELIMITER);
82
+ if (hashIdx === -1) {
83
+ return { stageId: runtimeStageId, executionIndex: 0, subflowPath: undefined };
84
+ }
85
+ const beforeHash = runtimeStageId.slice(0, hashIdx);
86
+ const executionIndex = parseInt(runtimeStageId.slice(hashIdx + 1), 10);
87
+ const lastSlash = beforeHash.lastIndexOf(PATH_DELIMITER);
88
+ if (lastSlash === -1) {
89
+ return { stageId: beforeHash, executionIndex, subflowPath: undefined };
90
+ }
91
+ return {
92
+ stageId: beforeHash.slice(lastSlash + 1),
93
+ executionIndex,
94
+ subflowPath: beforeHash.slice(0, lastSlash),
95
+ };
96
+ }
97
+ /**
98
+ * Decompose a (possibly prefixed) stage id into its components.
99
+ *
100
+ * Use this when you have an id WITHOUT the `#N` execution suffix and
101
+ * need the local stage name and/or the subflow path. Common sources
102
+ * of such ids:
103
+ * - `spec.id` (post-mount the id includes any subflow prefix)
104
+ * - `CommitBundle.stageId` (post-mount id)
105
+ * - `node.id` from xyflow nodes built off the spec
106
+ * - the segment of `runtimeStageId` BEFORE the `#` (use
107
+ * `parseRuntimeStageId` directly for full runtimeStageId strings)
108
+ *
109
+ * Mirrors the decomposition `parseRuntimeStageId` performs on the
110
+ * stageId portion of a runtimeStageId, so the two helpers stay in
111
+ * lockstep on naming and behavior.
112
+ *
113
+ * @example
114
+ * splitStageId('sf-tools/execute-tool-calls')
115
+ * // → { localStageId: 'execute-tool-calls', subflowPath: 'sf-tools' }
116
+ *
117
+ * splitStageId('execute-tool-calls')
118
+ * // → { localStageId: 'execute-tool-calls', subflowPath: undefined }
119
+ *
120
+ * splitStageId('sf-outer/sf-inner/validate')
121
+ * // → { localStageId: 'validate', subflowPath: 'sf-outer/sf-inner' }
122
+ */
123
+ export function splitStageId(prefixedStageId) {
124
+ const lastSlash = prefixedStageId.lastIndexOf(PATH_DELIMITER);
125
+ if (lastSlash === -1) {
126
+ return { localStageId: prefixedStageId, subflowPath: undefined };
127
+ }
128
+ return {
129
+ localStageId: prefixedStageId.slice(lastSlash + 1),
130
+ subflowPath: prefixedStageId.slice(0, lastSlash),
131
+ };
132
+ }
133
+ /**
134
+ * True when `key` names one EXECUTION (`…#N`) rather than a stage or a subflow
135
+ * path. Its presence alone decides: the delimiter is reserved in every
136
+ * user-authored id (`reservedIds.ts · refuseReservedId`), so only the grammar
137
+ * puts it there.
138
+ *
139
+ * Asked where a map is keyed by both — `subflowResults` is dual-keyed by
140
+ * subflow path AND by mount runtimeStageId.
141
+ */
142
+ export function isExecutionKey(key) {
143
+ return key.includes(EXECUTION_DELIMITER);
144
+ }
145
+ /**
146
+ * The FULL (subflow-prefixed) stage id of a runtimeStageId — everything before
147
+ * the last `#`, i.e. what `node.id` / `CommitBundle.stageId` hold. A string
148
+ * with no `#` is returned whole.
149
+ *
150
+ * @example stageIdOf('sf-tools/execute#8') // 'sf-tools/execute'
151
+ */
152
+ export function stageIdOf(runtimeStageId) {
153
+ const hashIdx = runtimeStageId.lastIndexOf(EXECUTION_DELIMITER);
154
+ return hashIdx === -1 ? runtimeStageId : runtimeStageId.slice(0, hashIdx);
155
+ }
156
+ /** The execution index of a runtimeStageId, or `NaN` when it carries none. */
157
+ export function executionIndexOf(runtimeStageId) {
158
+ const hashIdx = runtimeStageId.lastIndexOf(EXECUTION_DELIMITER);
159
+ return hashIdx === -1 ? NaN : Number.parseInt(runtimeStageId.slice(hashIdx + 1), 10);
160
+ }
161
+ /**
162
+ * The subflow path a runtimeStageId executes in (`'sf-a/sf-b'`), or
163
+ * `undefined` at the top level. Reads the stage-id part, so it agrees with
164
+ * `splitStageId(stageIdOf(rid)).subflowPath`.
165
+ */
166
+ export function subflowPathOf(runtimeStageId) {
167
+ return splitStageId(stageIdOf(runtimeStageId)).subflowPath;
168
+ }
169
+ /** The subflow path of a runtimeStageId as segments (`['sf-a', 'sf-b']`); `[]` at the top level. */
170
+ export function subflowSegmentsOf(runtimeStageId) {
171
+ const path = subflowPathOf(runtimeStageId);
172
+ return path === undefined ? [] : path.split(PATH_DELIMITER);
173
+ }
174
+ /** The non-empty segments of a subflow path or prefixed id (`'a//b/'` → `['a', 'b']`). */
175
+ export function pathSegments(path) {
176
+ return path.split(PATH_DELIMITER).filter((s) => s.length > 0);
177
+ }
178
+ /** The last segment of a path or prefixed id (`'sf-a/sf-b'` → `'sf-b'`); the whole string when it has none. */
179
+ export function lastSegmentOf(path) {
180
+ return path.slice(path.lastIndexOf(PATH_DELIMITER) + 1);
181
+ }
182
+ /** Join path segments with the grammar's delimiter (`joinPath('sf', 'stage')` → `'sf/stage'`). */
183
+ export function joinPath(...segments) {
184
+ return segments.join(PATH_DELIMITER);
185
+ }
186
+ /** True when the (prefixed) id `id` sits INSIDE the subflow at `path` — at any depth below it. */
187
+ export function isWithinSubflow(id, path) {
188
+ return id.startsWith(`${path}${PATH_DELIMITER}`);
189
+ }
190
+ /** Create a new execution counter starting at 0. */
191
+ export function createExecutionCounter() {
192
+ return { value: 0 };
193
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * EventLog — Time-travel snapshot storage for flowchart execution
3
+ *
4
+ * Like git history: stores commit bundles (diffs), not full snapshots.
5
+ *
6
+ * THE RECORD IS IMMUTABLE FROM `record` (F3, ruling R3). Every bundle is deep-frozen as it is
7
+ * recorded — the bundle, `overwrite` and `updates` at every depth, the trace and each row, the
8
+ * row's `readKeys`, `redactedPaths`, `tags`, `untrackedSources` — so a holder of a snapshot can no
9
+ * longer rewrite the history every later answer is folded from: an assignment into a bundle throws
10
+ * a `TypeError` in strict code. Safe because nothing outside the log holds a bundle's containers:
11
+ * the log's payload is the commit's own copy (`recordCommit` hands it the output of
12
+ * `scrubPatch`), and live state, the redacted mirror and write retention each take their own copy
13
+ * (`verbs.ts · foldRows` detaches, `StageContext · retainedForm` clones) — pinned by
14
+ * test/lib/memory/property/record-reachability.property.test.ts.
15
+ *
16
+ * What `Object.freeze` cannot seal — a Date's time, a Map's or Set's entries, a buffer's bytes, a
17
+ * RegExp, an Error's stack — is never handed out to a reader (9.44.2): `record` remembers that a
18
+ * bundle holds such a value (`capture/freeze.ts · freezeRecord`), and `list()` — like the public
19
+ * snapshot, `runner/snapshot.ts · servedSnapshot` — serves that bundle as a copy of its open paths
20
+ * (`serveRecord`, mapped at its first serve): fresh frozen containers down to each such value, a
21
+ * fresh copy of it, every other part the log's own. A reader edits only its own copy; every later
22
+ * serve reads the record as recorded. `recorded()` is the engine's own, unserved read. Named holes: an object hung on an array EXPANDO (arrays are walked
23
+ * by index — the `'indices'` walk, which keeps the freeze inside its budget; an expando is out of
24
+ * contract for state) and a `SharedArrayBuffer` (every copy shares its memory). A frozen RegExp's
25
+ * `lastIndex` is read-only, so a `/g` or `/y` regex read from a bundle throws when `exec` or
26
+ * `replace` advance it.
27
+ */
28
+ import type { EmitSourcePosition, LogAddress } from './eventPosition.js';
29
+ import type { CommitBundle } from './types.js';
30
+ export declare class EventLog {
31
+ /** Base snapshot BEFORE the first stage mutates anything. */
32
+ private base;
33
+ /** Ordered list of commit bundles. */
34
+ private steps;
35
+ private sourceAddress?;
36
+ private sourceAddressRetired;
37
+ constructor(initialMemory: any);
38
+ /**
39
+ * The fold BASE — the state as it stood before the first commit.
40
+ *
41
+ * This is the other half of the commit log: bundles are DIFFS, so a log
42
+ * alone cannot reconstruct state that was seeded before the run (an
43
+ * executor `initialContext`, `defaultValuesForContext`, a resume's
44
+ * `checkpoint.sharedState`, a subflow's `inputMapper` seed). Travelling
45
+ * with the log — `RuntimeSnapshot.initialState` — is what lets an OFFLINE
46
+ * consumer fold; without it the honest answer is a partial one
47
+ * (`stateAt`'s `basis: 'log-only'`).
48
+ *
49
+ * Returns a fresh detached clone on every call — the caller owns it.
50
+ */
51
+ getInitialState(): any;
52
+ /**
53
+ * Reconstructs the full state at any given step.
54
+ * Replays commits from the beginning — O(n) but low memory footprint.
55
+ *
56
+ * INDEX CONVENTION — `stepIdx` is EXCLUSIVE: `materialise(3)` folds commits
57
+ * 0, 1 and 2. `stateAt(source, commitIdx)` (foottrace) folds the
58
+ * same log but its `commitIdx` is INCLUSIVE, because a reader's cursor asks
59
+ * "the state AT this stop", which must include that stop's own commit. Two
60
+ * folds over one log with opposite conventions: check which one you hold.
61
+ *
62
+ * One clone of the base per call, then every bundle replayed INTO that
63
+ * private copy (`applySmartMergeInto` — the live commit's copy-on-write law
64
+ * below the root, 9.29.0, so the fold and the live state agree at every
65
+ * path). The result is the caller's: it shares nothing with the base or
66
+ * the log.
67
+ *
68
+ * @deprecated Since 9.33.0 — use `stateAt` from `foottrace`, which folds the same log
69
+ * from the same base (`RuntimeSnapshot.initialState`) and says how it was derived (`basis`).
70
+ * Nothing in the library calls this; it stays for one minor and is then removed. Mind the
71
+ * index: `materialise(n)` folds commits `0..n-1`, `stateAt(source, n - 1)` the same commits.
72
+ */
73
+ materialise(stepIdx?: number): any;
74
+ /**
75
+ * Persists a commit bundle for a finished stage, and FREEZES it (see the module doc): the bundle
76
+ * is stamped with its position, then deep-frozen, then appended. The engine hands it a bundle
77
+ * built for the log alone; a caller of this class (`foottrace/write`) hands over a bundle it
78
+ * will no longer edit — its own object is the one frozen.
79
+ */
80
+ record(bundle: CommitBundle): void;
81
+ /**
82
+ * Every recorded commit bundle, AS SERVED (9.44.2): a new array each call; a bundle freezing sealed
83
+ * whole is the log's own (frozen) object, one holding a Date, Map, buffer … is a copy of its open
84
+ * paths (`capture/freeze.ts · serveRecord`) — the reader's own, so no edit reaches the log.
85
+ */
86
+ list(): CommitBundle[];
87
+ /**
88
+ * @internal The bundles as the log holds them — each frozen, NOT served — in a new array, so a holder's
89
+ * `splice` reaches only its own. For the engine's own snapshot (`ExecutionRuntime · getSnapshot`, which
90
+ * a subflow mount takes once per mount), so the run serves nothing; a reader is served by `list()` and
91
+ * `getSnapshot().commitLog`. A known open door (CHANGELOG 9.44.2): a holder of these bundles can still
92
+ * edit a Date, Map or buffer inside them.
93
+ */
94
+ recorded(): CommitBundle[];
95
+ /** Number of recorded commits. */
96
+ get length(): number;
97
+ /** Immutable identity of this log, absent until the engine binds it. */
98
+ get address(): LogAddress | undefined;
99
+ /** @internal Bind once; resuming the same log must not rename its earlier positions. */
100
+ bindAddress(logRunId: string, drillPath: readonly string[]): void;
101
+ /** O(1) source-time capture. No counter, observer bookkeeping, or future commit prediction. */
102
+ capturePosition(runId: string): EmitSourcePosition | undefined;
103
+ /** Wipes history (useful for test resets). */
104
+ clear(): void;
105
+ }