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.
- package/LICENSE +21 -0
- package/README.md +73 -2
- package/dist/esm/index.d.ts +27 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/lib/capture/freeze.d.ts +91 -0
- package/dist/esm/lib/capture/freeze.js +313 -0
- package/dist/esm/lib/capture/ownData.d.ts +18 -0
- package/dist/esm/lib/capture/ownData.js +35 -0
- package/dist/esm/lib/capture/valueKinds.d.ts +57 -0
- package/dist/esm/lib/capture/valueKinds.js +141 -0
- package/dist/esm/lib/ids/runtimeStageId.d.ts +173 -0
- package/dist/esm/lib/ids/runtimeStageId.js +193 -0
- package/dist/esm/lib/memory/EventLog.d.ts +105 -0
- package/dist/esm/lib/memory/EventLog.js +147 -0
- package/dist/esm/lib/memory/RecordFrame.d.ts +232 -0
- package/dist/esm/lib/memory/RecordFrame.js +295 -0
- package/dist/esm/lib/memory/SharedMemory.d.ts +46 -0
- package/dist/esm/lib/memory/SharedMemory.js +87 -0
- package/dist/esm/lib/memory/TransactionBuffer.d.ts +521 -0
- package/dist/esm/lib/memory/TransactionBuffer.js +946 -0
- package/dist/esm/lib/memory/admission.d.ts +81 -0
- package/dist/esm/lib/memory/admission.js +152 -0
- package/dist/esm/lib/memory/backtrack.d.ts +286 -0
- package/dist/esm/lib/memory/backtrack.js +456 -0
- package/dist/esm/lib/memory/commitLogUtils.d.ts +217 -0
- package/dist/esm/lib/memory/commitLogUtils.js +383 -0
- package/dist/esm/lib/memory/deltaEncoding.d.ts +66 -0
- package/dist/esm/lib/memory/deltaEncoding.js +121 -0
- package/dist/esm/lib/memory/equality.d.ts +93 -0
- package/dist/esm/lib/memory/equality.js +261 -0
- package/dist/esm/lib/memory/eventPosition.d.ts +18 -0
- package/dist/esm/lib/memory/eventPosition.js +1 -0
- package/dist/esm/lib/memory/honesty.d.ts +93 -0
- package/dist/esm/lib/memory/honesty.js +91 -0
- package/dist/esm/lib/memory/keyPaths.d.ts +125 -0
- package/dist/esm/lib/memory/keyPaths.js +226 -0
- package/dist/esm/lib/memory/logModel.d.ts +76 -0
- package/dist/esm/lib/memory/logModel.js +363 -0
- package/dist/esm/lib/memory/merge.d.ts +26 -0
- package/dist/esm/lib/memory/merge.js +51 -0
- package/dist/esm/lib/memory/pathOps.d.ts +118 -0
- package/dist/esm/lib/memory/pathOps.js +292 -0
- package/dist/esm/lib/memory/paths.d.ts +56 -0
- package/dist/esm/lib/memory/paths.js +60 -0
- package/dist/esm/lib/memory/placeholders.d.ts +39 -0
- package/dist/esm/lib/memory/placeholders.js +39 -0
- package/dist/esm/lib/memory/recordCommit.d.ts +45 -0
- package/dist/esm/lib/memory/recordCommit.js +60 -0
- package/dist/esm/lib/memory/scrub.d.ts +52 -0
- package/dist/esm/lib/memory/scrub.js +72 -0
- package/dist/esm/lib/memory/types.d.ts +209 -0
- package/dist/esm/lib/memory/types.js +9 -0
- package/dist/esm/lib/memory/utils.d.ts +73 -0
- package/dist/esm/lib/memory/utils.js +150 -0
- package/dist/esm/lib/memory/verbs.d.ts +333 -0
- package/dist/esm/lib/memory/verbs.js +426 -0
- package/dist/esm/lib/recorder/CommitRangeIndex.d.ts +147 -0
- package/dist/esm/lib/recorder/CommitRangeIndex.js +206 -0
- package/dist/esm/lib/slice/elementProvenance.d.ts +81 -0
- package/dist/esm/lib/slice/elementProvenance.js +189 -0
- package/dist/esm/lib/slice/forwardSliceForKey.d.ts +88 -0
- package/dist/esm/lib/slice/forwardSliceForKey.js +242 -0
- package/dist/esm/lib/slice/index.d.ts +26 -0
- package/dist/esm/lib/slice/index.js +25 -0
- package/dist/esm/lib/slice/keyIndex.d.ts +137 -0
- package/dist/esm/lib/slice/keyIndex.js +292 -0
- package/dist/esm/lib/slice/keyTimeline.d.ts +49 -0
- package/dist/esm/lib/slice/keyTimeline.js +112 -0
- package/dist/esm/lib/slice/keysReadSources.d.ts +51 -0
- package/dist/esm/lib/slice/keysReadSources.js +94 -0
- package/dist/esm/lib/slice/serialize.d.ts +78 -0
- package/dist/esm/lib/slice/serialize.js +277 -0
- package/dist/esm/lib/slice/sliceForKey.d.ts +40 -0
- package/dist/esm/lib/slice/sliceForKey.js +78 -0
- package/dist/esm/lib/slice/types.d.ts +567 -0
- package/dist/esm/lib/slice/types.js +24 -0
- package/dist/esm/lib/time-travel/axis.d.ts +119 -0
- package/dist/esm/lib/time-travel/axis.js +178 -0
- package/dist/esm/lib/time-travel/bundles.d.ts +77 -0
- package/dist/esm/lib/time-travel/bundles.js +135 -0
- package/dist/esm/lib/time-travel/chain.d.ts +93 -0
- package/dist/esm/lib/time-travel/chain.js +187 -0
- package/dist/esm/lib/time-travel/commitStops.d.ts +55 -0
- package/dist/esm/lib/time-travel/commitStops.js +201 -0
- package/dist/esm/lib/time-travel/index.d.ts +22 -0
- package/dist/esm/lib/time-travel/index.js +20 -0
- package/dist/esm/lib/time-travel/stateAt.d.ts +102 -0
- package/dist/esm/lib/time-travel/stateAt.js +152 -0
- package/dist/esm/lib/time-travel/tagStops.d.ts +72 -0
- package/dist/esm/lib/time-travel/tagStops.js +101 -0
- package/dist/esm/lib/time-travel/timeTravel.d.ts +70 -0
- package/dist/esm/lib/time-travel/timeTravel.js +359 -0
- package/dist/esm/lib/time-travel/types.d.ts +470 -0
- package/dist/esm/lib/time-travel/types.js +22 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/paths.d.ts +4 -0
- package/dist/esm/paths.js +4 -0
- package/dist/esm/write.d.ts +49 -0
- package/dist/esm/write.js +47 -0
- package/dist/index.js +67 -0
- package/dist/lib/capture/freeze.js +319 -0
- package/dist/lib/capture/ownData.js +40 -0
- package/dist/lib/capture/valueKinds.js +145 -0
- package/dist/lib/ids/runtimeStageId.js +209 -0
- package/dist/lib/memory/EventLog.js +151 -0
- package/dist/lib/memory/RecordFrame.js +299 -0
- package/dist/lib/memory/SharedMemory.js +91 -0
- package/dist/lib/memory/TransactionBuffer.js +950 -0
- package/dist/lib/memory/admission.js +158 -0
- package/dist/lib/memory/backtrack.js +462 -0
- package/dist/lib/memory/commitLogUtils.js +398 -0
- package/dist/lib/memory/deltaEncoding.js +127 -0
- package/dist/lib/memory/equality.js +265 -0
- package/dist/lib/memory/eventPosition.js +2 -0
- package/dist/lib/memory/honesty.js +94 -0
- package/dist/lib/memory/keyPaths.js +242 -0
- package/dist/lib/memory/logModel.js +371 -0
- package/dist/lib/memory/merge.js +55 -0
- package/dist/lib/memory/pathOps.js +308 -0
- package/dist/lib/memory/paths.js +66 -0
- package/dist/lib/memory/placeholders.js +42 -0
- package/dist/lib/memory/recordCommit.js +64 -0
- package/dist/lib/memory/scrub.js +77 -0
- package/dist/lib/memory/types.js +10 -0
- package/dist/lib/memory/utils.js +169 -0
- package/dist/lib/memory/verbs.js +443 -0
- package/dist/lib/recorder/CommitRangeIndex.js +210 -0
- package/dist/lib/slice/elementProvenance.js +194 -0
- package/dist/lib/slice/forwardSliceForKey.js +246 -0
- package/dist/lib/slice/index.js +42 -0
- package/dist/lib/slice/keyIndex.js +312 -0
- package/dist/lib/slice/keyTimeline.js +116 -0
- package/dist/lib/slice/keysReadSources.js +100 -0
- package/dist/lib/slice/serialize.js +285 -0
- package/dist/lib/slice/sliceForKey.js +82 -0
- package/dist/lib/slice/types.js +25 -0
- package/dist/lib/time-travel/axis.js +183 -0
- package/dist/lib/time-travel/bundles.js +143 -0
- package/dist/lib/time-travel/chain.js +192 -0
- package/dist/lib/time-travel/commitStops.js +205 -0
- package/dist/lib/time-travel/index.js +31 -0
- package/dist/lib/time-travel/stateAt.js +159 -0
- package/dist/lib/time-travel/tagStops.js +105 -0
- package/dist/lib/time-travel/timeTravel.js +363 -0
- package/dist/lib/time-travel/types.js +23 -0
- package/dist/paths.js +14 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/lib/capture/freeze.d.ts +91 -0
- package/dist/types/lib/capture/ownData.d.ts +18 -0
- package/dist/types/lib/capture/valueKinds.d.ts +57 -0
- package/dist/types/lib/ids/runtimeStageId.d.ts +173 -0
- package/dist/types/lib/memory/EventLog.d.ts +105 -0
- package/dist/types/lib/memory/RecordFrame.d.ts +232 -0
- package/dist/types/lib/memory/SharedMemory.d.ts +46 -0
- package/dist/types/lib/memory/TransactionBuffer.d.ts +521 -0
- package/dist/types/lib/memory/admission.d.ts +81 -0
- package/dist/types/lib/memory/backtrack.d.ts +286 -0
- package/dist/types/lib/memory/commitLogUtils.d.ts +217 -0
- package/dist/types/lib/memory/deltaEncoding.d.ts +66 -0
- package/dist/types/lib/memory/equality.d.ts +93 -0
- package/dist/types/lib/memory/eventPosition.d.ts +18 -0
- package/dist/types/lib/memory/honesty.d.ts +93 -0
- package/dist/types/lib/memory/keyPaths.d.ts +125 -0
- package/dist/types/lib/memory/logModel.d.ts +76 -0
- package/dist/types/lib/memory/merge.d.ts +26 -0
- package/dist/types/lib/memory/pathOps.d.ts +118 -0
- package/dist/types/lib/memory/paths.d.ts +56 -0
- package/dist/types/lib/memory/placeholders.d.ts +39 -0
- package/dist/types/lib/memory/recordCommit.d.ts +45 -0
- package/dist/types/lib/memory/scrub.d.ts +52 -0
- package/dist/types/lib/memory/types.d.ts +209 -0
- package/dist/types/lib/memory/utils.d.ts +73 -0
- package/dist/types/lib/memory/verbs.d.ts +333 -0
- package/dist/types/lib/recorder/CommitRangeIndex.d.ts +147 -0
- package/dist/types/lib/slice/elementProvenance.d.ts +81 -0
- package/dist/types/lib/slice/forwardSliceForKey.d.ts +88 -0
- package/dist/types/lib/slice/index.d.ts +26 -0
- package/dist/types/lib/slice/keyIndex.d.ts +137 -0
- package/dist/types/lib/slice/keyTimeline.d.ts +49 -0
- package/dist/types/lib/slice/keysReadSources.d.ts +51 -0
- package/dist/types/lib/slice/serialize.d.ts +78 -0
- package/dist/types/lib/slice/sliceForKey.d.ts +40 -0
- package/dist/types/lib/slice/types.d.ts +567 -0
- package/dist/types/lib/time-travel/axis.d.ts +119 -0
- package/dist/types/lib/time-travel/bundles.d.ts +77 -0
- package/dist/types/lib/time-travel/chain.d.ts +93 -0
- package/dist/types/lib/time-travel/commitStops.d.ts +55 -0
- package/dist/types/lib/time-travel/index.d.ts +22 -0
- package/dist/types/lib/time-travel/stateAt.d.ts +102 -0
- package/dist/types/lib/time-travel/tagStops.d.ts +72 -0
- package/dist/types/lib/time-travel/timeTravel.d.ts +70 -0
- package/dist/types/lib/time-travel/types.d.ts +470 -0
- package/dist/types/paths.d.ts +4 -0
- package/dist/types/write.d.ts +49 -0
- package/dist/write.js +56 -0
- package/package.json +48 -4
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* bundles.ts — reading a log whose rows are not typed yet.
|
|
4
|
+
*
|
|
5
|
+
* WHY THIS FILE EXISTS. A LIVE snapshot hands time travel real
|
|
6
|
+
* {@link CommitBundle}s. A STORED recording hands it parsed JSON, and a
|
|
7
|
+
* careful consumer will not claim that what came back off disk is a
|
|
8
|
+
* `CommitBundle` — so it either casts (a lie with a comment on it) or cannot
|
|
9
|
+
* call the library at all. Since 9.18.0 the source takes `readonly unknown[]`
|
|
10
|
+
* and the narrowing happens here, per row, at the one place that actually
|
|
11
|
+
* reads one.
|
|
12
|
+
*
|
|
13
|
+
* A row that is not a bundle becomes a GAP rather than an exception: it KEEPS
|
|
14
|
+
* ITS INDEX — so every `commitIdx` in the axis still addresses the same
|
|
15
|
+
* position — contributes no state, gets no stop, and is reported with its
|
|
16
|
+
* index and a reason. One corrupt row in a stored recording loses that row,
|
|
17
|
+
* not the recording.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.readLog = exports.isCommitBundle = exports.bundleRefusal = exports.readTree = exports.isPlainish = void 0;
|
|
21
|
+
const verbs_js_1 = require("../memory/verbs.js");
|
|
22
|
+
/**
|
|
23
|
+
* The stand-in a gap leaves at its index: a commit that belongs to no stage
|
|
24
|
+
* and carries nothing.
|
|
25
|
+
*
|
|
26
|
+
* It is NOT invented evidence — every field is the empty value, and an id-less
|
|
27
|
+
* bundle is a shape the log already has (a root-context commit made before any
|
|
28
|
+
* stage ran). `commitStops` gives it no stop for exactly that reason, the fold
|
|
29
|
+
* folds nothing from it, and `changedSince` reads no keys off it. What it does
|
|
30
|
+
* is hold the index, so the arithmetic downstream never has to know.
|
|
31
|
+
*/
|
|
32
|
+
const GAP_BUNDLE = Object.freeze({
|
|
33
|
+
stage: '',
|
|
34
|
+
stageId: '',
|
|
35
|
+
runtimeStageId: '',
|
|
36
|
+
trace: Object.freeze([]),
|
|
37
|
+
redactedPaths: Object.freeze([]),
|
|
38
|
+
overwrite: Object.freeze({}),
|
|
39
|
+
updates: Object.freeze({}),
|
|
40
|
+
});
|
|
41
|
+
/** A plain object — not null, not an array, not a primitive. */
|
|
42
|
+
function isPlainish(value) {
|
|
43
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
44
|
+
}
|
|
45
|
+
exports.isPlainish = isPlainish;
|
|
46
|
+
/**
|
|
47
|
+
* Read a source's `executionTree` as an {@link ExecutionTree}, or as absent.
|
|
48
|
+
*
|
|
49
|
+
* The tree is only ever WALKED for mount ids (`subflowId` + `runtimeStageId`
|
|
50
|
+
* on each node), so the honest narrowing a reader can do is "a plain object";
|
|
51
|
+
* anything else — a stored field that came back as a string, a number, an
|
|
52
|
+
* array — is read as no tree at all, which sends `commitStops` down the same
|
|
53
|
+
* shape-heuristic path a log handed over without its tree already takes.
|
|
54
|
+
*/
|
|
55
|
+
function readTree(value) {
|
|
56
|
+
return isPlainish(value) ? value : undefined;
|
|
57
|
+
}
|
|
58
|
+
exports.readTree = readTree;
|
|
59
|
+
/**
|
|
60
|
+
* Why `row` cannot be read as a commit bundle, or `undefined` when it can.
|
|
61
|
+
*
|
|
62
|
+
* DELIBERATELY LENIENT — but exactly as lenient as the readers are. It checks
|
|
63
|
+
* what the fold, the axis and `changedSince` actually touch:
|
|
64
|
+
*
|
|
65
|
+
* - `runtimeStageId` must be a string — the axis keys on it.
|
|
66
|
+
* - `trace` must be an ARRAY, and it must be PRESENT. It is the one field
|
|
67
|
+
* every reader WALKS (`applySmartMerge` iterates it verb by verb;
|
|
68
|
+
* `changedSince` reads its paths), so a row without one is not a bundle the
|
|
69
|
+
* fold can survive — it is the crash a gap exists to prevent. `CommitBundle`
|
|
70
|
+
* declares it required, so no live log is affected.
|
|
71
|
+
* - `updates` / `overwrite`, when present, must be plain objects. They are
|
|
72
|
+
* read only AT THE PATHS THE TRACE NAMES, so an absent one is harmless and
|
|
73
|
+
* is tolerated, exactly as the fold tolerates an absent `redactedPaths`.
|
|
74
|
+
*
|
|
75
|
+
* Being stricter than that — demanding `stage`, `stageId`, `idx` — would
|
|
76
|
+
* reject hand-built logs that have folded correctly since 9.17.0, which is a
|
|
77
|
+
* compatibility break dressed up as validation.
|
|
78
|
+
*/
|
|
79
|
+
function bundleRefusal(row) {
|
|
80
|
+
if (!isPlainish(row)) {
|
|
81
|
+
return `not an object (${row === null ? 'null' : Array.isArray(row) ? 'array' : typeof row})`;
|
|
82
|
+
}
|
|
83
|
+
if (typeof row.runtimeStageId !== 'string') {
|
|
84
|
+
return `runtimeStageId is ${row.runtimeStageId === undefined ? 'missing' : `a ${typeof row.runtimeStageId}`}, not a string`;
|
|
85
|
+
}
|
|
86
|
+
if (!Array.isArray(row.trace)) {
|
|
87
|
+
return `trace is ${row.trace === undefined ? 'missing' : `a ${typeof row.trace}`}, not an array`;
|
|
88
|
+
}
|
|
89
|
+
if (row.updates !== undefined && !isPlainish(row.updates))
|
|
90
|
+
return 'updates is not a plain object';
|
|
91
|
+
if (row.overwrite !== undefined && !isPlainish(row.overwrite))
|
|
92
|
+
return 'overwrite is not a plain object';
|
|
93
|
+
// The four verbs are the contract (9.27.0). The replay's switch used to
|
|
94
|
+
// treat anything else as `merge` — a silent coercion of a row a foreign
|
|
95
|
+
// producer got wrong; the readers now refuse it (`UnknownVerbError`), and
|
|
96
|
+
// this reader turns the same refusal into a gap that says which row.
|
|
97
|
+
for (let i = 0; i < row.trace.length; i++) {
|
|
98
|
+
const entry = row.trace[i];
|
|
99
|
+
const verb = isPlainish(entry) ? entry.verb : undefined;
|
|
100
|
+
if (!(0, verbs_js_1.isVerb)(verb)) {
|
|
101
|
+
return `trace[${i}].verb is ${verb === undefined ? 'missing' : JSON.stringify(verb)}, not ${verbs_js_1.VERBS.join(' | ')}`;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
exports.bundleRefusal = bundleRefusal;
|
|
107
|
+
/** `true` when `row` can be read as a {@link CommitBundle}. */
|
|
108
|
+
function isCommitBundle(row) {
|
|
109
|
+
return bundleRefusal(row) === undefined;
|
|
110
|
+
}
|
|
111
|
+
exports.isCommitBundle = isCommitBundle;
|
|
112
|
+
/** Nothing to read — shared, so the clean path allocates nothing extra. */
|
|
113
|
+
const NO_GAPS = Object.freeze([]);
|
|
114
|
+
/**
|
|
115
|
+
* Read an unvalidated array as a commit log.
|
|
116
|
+
*
|
|
117
|
+
* The clean case (a live snapshot, or a stored recording that round-tripped
|
|
118
|
+
* intact) returns the SAME array reference and no gaps: nothing is copied,
|
|
119
|
+
* nothing is allocated, and the fold behaves byte for byte as it did in
|
|
120
|
+
* 9.17.0. Only a log with a refused row is rebuilt, and only to keep the
|
|
121
|
+
* indices aligned.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const { log, gaps } = readLog(JSON.parse(stored).commitLog);
|
|
126
|
+
* gaps; // [{ index: 3, reason: 'not an object (null)' }]
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
function readLog(raw) {
|
|
130
|
+
if (!raw || raw.length === 0)
|
|
131
|
+
return { log: [], gaps: NO_GAPS };
|
|
132
|
+
let gaps;
|
|
133
|
+
for (let i = 0; i < raw.length; i++) {
|
|
134
|
+
const reason = bundleRefusal(raw[i]);
|
|
135
|
+
if (reason !== undefined)
|
|
136
|
+
(gaps ??= []).push({ index: i, reason });
|
|
137
|
+
}
|
|
138
|
+
if (!gaps)
|
|
139
|
+
return { log: raw, gaps: NO_GAPS };
|
|
140
|
+
const log = raw.map((row) => (isCommitBundle(row) ? row : GAP_BUNDLE));
|
|
141
|
+
return { log, gaps: Object.freeze(gaps) };
|
|
142
|
+
}
|
|
143
|
+
exports.readLog = readLog;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* chain.ts — reading a pause/resume as ONE axis.
|
|
4
|
+
*
|
|
5
|
+
* WHY THIS FILE EXISTS. A pause and its resume produce TWO snapshots. On a
|
|
6
|
+
* cross-executor resume (the checkpoint was persisted and a fresh executor
|
|
7
|
+
* picked it up) the second run gets a fresh runtime: its `commitLog` starts at
|
|
8
|
+
* index 0 and holds only the post-resume commits, and its `initialState` is
|
|
9
|
+
* the state at the pause. Two logs, two disjoint axes — so a reader scrubbing
|
|
10
|
+
* a resumed run saw only the second half unless the application had kept the
|
|
11
|
+
* paused snapshot and stitched the halves itself. Every application that
|
|
12
|
+
* pauses would write that stitching, and none of them own the arithmetic.
|
|
13
|
+
*
|
|
14
|
+
* THE HONEST BIT, up front: COMMIT INDICES ARE RUN-LOCAL. There is no global
|
|
15
|
+
* index across a chain and this file does not invent one — `commitIdx` and
|
|
16
|
+
* `lastCommitIdx` keep indexing their own source, and every stop carries the
|
|
17
|
+
* {@link Stop.sourceIdx} they belong to. The cursor's STEPS are what run
|
|
18
|
+
* across the whole chain.
|
|
19
|
+
*
|
|
20
|
+
* AND THE REFUSAL: a chain that is not ordered, or whose legs are not from one
|
|
21
|
+
* lineage, is REFUSED rather than guessed at. The record carries TWO signals
|
|
22
|
+
* and this file reads both:
|
|
23
|
+
*
|
|
24
|
+
* - The execution index the engine stamps into every `runtimeStageId` —
|
|
25
|
+
* globally monotonic per run and, deliberately, NOT reset on resume. So a
|
|
26
|
+
* later leg's first execution index must be past the earlier leg's last, and
|
|
27
|
+
* no stage may appear in two legs. This catches a backwards chain, a fresh
|
|
28
|
+
* run (which restarts at 0) and a same-executor resume (whose one snapshot
|
|
29
|
+
* already holds both halves).
|
|
30
|
+
* - The later leg's `initialState`. On a resume the fresh runtime is seeded
|
|
31
|
+
* from the checkpoint, so that base IS the state at the pause — and the
|
|
32
|
+
* state the earlier legs FOLD TO must deep-equal it. This is what catches a
|
|
33
|
+
* leg from some OTHER lineage whose indices merely happen to be higher: the
|
|
34
|
+
* counters line up by accident, the state never does.
|
|
35
|
+
*
|
|
36
|
+
* A chart identity or a lineage id is NOT on the record, so nothing here
|
|
37
|
+
* pretends to check one. And where the state signal is not on the record
|
|
38
|
+
* either — a leg recorded before 9.17 carries no `initialState`; an earlier
|
|
39
|
+
* leg with no base folds `'log-only'`; a leg with unreadable rows folds an
|
|
40
|
+
* incomplete state — that check is SKIPPED, not faked: the chain then rests on
|
|
41
|
+
* the index checks alone, and every fold's `basis` still says what it stood
|
|
42
|
+
* on. That degradation is documented on `refuseChain`, on `timeTravel`'s
|
|
43
|
+
* `@throws`, and in the README.
|
|
44
|
+
*/
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.refuseChain = exports.spanOf = void 0;
|
|
47
|
+
const valueKinds_js_1 = require("../capture/valueKinds.js");
|
|
48
|
+
const runtimeStageId_js_1 = require("../ids/runtimeStageId.js");
|
|
49
|
+
const utils_js_1 = require("../memory/utils.js");
|
|
50
|
+
const stateAt_js_1 = require("./stateAt.js");
|
|
51
|
+
/** The execution-index span of one leg, read off its `runtimeStageId`s. */
|
|
52
|
+
function spanOf(log) {
|
|
53
|
+
let first;
|
|
54
|
+
let last;
|
|
55
|
+
const ids = new Set();
|
|
56
|
+
for (const bundle of log) {
|
|
57
|
+
const id = bundle.runtimeStageId;
|
|
58
|
+
if (!id)
|
|
59
|
+
continue;
|
|
60
|
+
ids.add(id);
|
|
61
|
+
const { executionIndex } = (0, runtimeStageId_js_1.parseRuntimeStageId)(id);
|
|
62
|
+
if (Number.isNaN(executionIndex))
|
|
63
|
+
continue;
|
|
64
|
+
if (first === undefined || executionIndex < first)
|
|
65
|
+
first = executionIndex;
|
|
66
|
+
if (last === undefined || executionIndex > last)
|
|
67
|
+
last = executionIndex;
|
|
68
|
+
}
|
|
69
|
+
return { first, last, ids };
|
|
70
|
+
}
|
|
71
|
+
exports.spanOf = spanOf;
|
|
72
|
+
/**
|
|
73
|
+
* Structural equality of two folded states, ignoring the paths the log was
|
|
74
|
+
* redacted at.
|
|
75
|
+
*
|
|
76
|
+
* The fold reproduces `'REDACTED'` wherever the engine scrubbed a write, while
|
|
77
|
+
* the checkpoint that seeded the resumed leg holds the real value — so those
|
|
78
|
+
* paths CANNOT agree, and are not asked to. Everything else is decided by the
|
|
79
|
+
* ONE equality law (`memory/equality.ts · deepEqual`, every value kind compared
|
|
80
|
+
* as the record holds it; 9.44.2 — this walk had a law of its own, which held
|
|
81
|
+
* any two RegExps, Errors or buffers equal). Both sides are copies of one
|
|
82
|
+
* record, so an opaque value compares as `'copies'`. Only the containers above
|
|
83
|
+
* a redacted path are walked here.
|
|
84
|
+
*/
|
|
85
|
+
function sameState(a, b, redacted, path) {
|
|
86
|
+
if (!redactedBelow(path, redacted))
|
|
87
|
+
return (0, utils_js_1.deepEqual)(a, b, 'copies');
|
|
88
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
89
|
+
if (a.length !== b.length)
|
|
90
|
+
return false;
|
|
91
|
+
return a.every((item, i) => sameState(item, b[i], redacted, path === '' ? String(i) : `${path}${utils_js_1.DELIM}${i}`));
|
|
92
|
+
}
|
|
93
|
+
const plain = (v) => v !== null && typeof v === 'object' && !Array.isArray(v) && (0, valueKinds_js_1.kindOf)(v) === 'plain';
|
|
94
|
+
if (!plain(a) || !plain(b))
|
|
95
|
+
return (0, utils_js_1.deepEqual)(a, b, 'copies');
|
|
96
|
+
const present = (o) => Object.keys(o).filter((k) => o[k] !== undefined);
|
|
97
|
+
const leftKeys = present(a);
|
|
98
|
+
const rightKeys = new Set(present(b));
|
|
99
|
+
if (leftKeys.length !== rightKeys.size || !leftKeys.every((k) => rightKeys.has(k)))
|
|
100
|
+
return false;
|
|
101
|
+
return leftKeys.every((k) => {
|
|
102
|
+
const childPath = path === '' ? k : `${path}${utils_js_1.DELIM}${k}`;
|
|
103
|
+
return redacted.has(childPath) || sameState(a[k], b[k], redacted, childPath);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/** Is `path`, or a path below it, one the log was redacted at? */
|
|
107
|
+
function redactedBelow(path, redacted) {
|
|
108
|
+
if (redacted.size === 0)
|
|
109
|
+
return false;
|
|
110
|
+
if (path === '')
|
|
111
|
+
return true;
|
|
112
|
+
for (const r of redacted)
|
|
113
|
+
if (r === path || r.startsWith(`${path}${utils_js_1.DELIM}`))
|
|
114
|
+
return true;
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Check that `legs` really are one run read in order, and say why not.
|
|
119
|
+
*
|
|
120
|
+
* Returns the refusal message, or `undefined` when the chain is sound. Three
|
|
121
|
+
* distinct failures, because they are three different mistakes, checked in
|
|
122
|
+
* this order:
|
|
123
|
+
*
|
|
124
|
+
* - REPEATED STAGE — one `runtimeStageId` appears in two legs. Ids are unique
|
|
125
|
+
* within a run, so a repeat means the same execution was recorded twice: a
|
|
126
|
+
* same-executor resume, whose snapshot ALREADY holds the whole log and needs
|
|
127
|
+
* no chaining, is the usual cause.
|
|
128
|
+
* - OUT OF ORDER — a later leg's first execution index is not past the earlier
|
|
129
|
+
* leg's last. Either the sources were handed over backwards, or the second
|
|
130
|
+
* is not a continuation at all (a fresh run restarts the counter at 0, so an
|
|
131
|
+
* unrelated snapshot fails here rather than silently interleaving).
|
|
132
|
+
* - WRONG LINEAGE — leg k's `initialState` is not the state legs 0..k-1 fold
|
|
133
|
+
* to. On a resume the later leg is seeded from the checkpoint, so its base
|
|
134
|
+
* IS the state at the pause; a leg that begins anywhere else is from some
|
|
135
|
+
* other run, however its indices happen to line up.
|
|
136
|
+
*
|
|
137
|
+
* THE LINEAGE CHECK RUNS ONLY WHERE THE RECORD ALLOWS IT, and is skipped —
|
|
138
|
+
* never faked — otherwise: leg k must carry an `initialState` (a recording
|
|
139
|
+
* made before 9.17 has none), and the fold of the legs before it must stand on
|
|
140
|
+
* a real base (`basis: 'initial+log'`) with no unreadable rows (`skipped`
|
|
141
|
+
* absent) — a log-only or gapped fold is not a state a real base may be held
|
|
142
|
+
* against. On such a chain the two index checks are the whole defence, and
|
|
143
|
+
* `foldLegs`' leg rule then CONTINUES the fold across the seam, which is the
|
|
144
|
+
* right state for a real resume and is what `basis` reports. Paths the log
|
|
145
|
+
* was redacted at are excluded from the comparison: the fold holds
|
|
146
|
+
* `'REDACTED'` there and the checkpoint holds the value.
|
|
147
|
+
*/
|
|
148
|
+
function refuseChain(legs) {
|
|
149
|
+
if (legs.length === 0)
|
|
150
|
+
return 'timeTravel: a chain needs at least one source, got an empty array.';
|
|
151
|
+
const spans = legs.map((leg) => spanOf(leg.log));
|
|
152
|
+
const seen = new Map();
|
|
153
|
+
for (const [i, span] of spans.entries()) {
|
|
154
|
+
for (const id of span.ids) {
|
|
155
|
+
const earlier = seen.get(id);
|
|
156
|
+
if (earlier !== undefined) {
|
|
157
|
+
return (`timeTravel: sources ${earlier} and ${i} both record '${id}'. A runtimeStageId is unique ` +
|
|
158
|
+
'within a run, so these are not two legs of one run — a same-executor resume already ' +
|
|
159
|
+
'carries the whole log in ONE snapshot and must not be chained with the paused one.');
|
|
160
|
+
}
|
|
161
|
+
seen.set(id, i);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
let previous;
|
|
165
|
+
for (const [i, span] of spans.entries()) {
|
|
166
|
+
if (span.first === undefined || span.last === undefined)
|
|
167
|
+
continue;
|
|
168
|
+
if (previous && span.first <= previous.last) {
|
|
169
|
+
return (`timeTravel: source ${i} starts at execution index ${span.first}, which is not past ` +
|
|
170
|
+
`source ${previous.idx}'s last (${previous.last}). Chain the sources in run order, and ` +
|
|
171
|
+
'only sources from ONE lineage — the engine never resets the execution counter across a ' +
|
|
172
|
+
'resume, so a fresh run restarting at 0 is a different run, not a continuation.');
|
|
173
|
+
}
|
|
174
|
+
previous = { idx: i, last: span.last };
|
|
175
|
+
}
|
|
176
|
+
for (let k = 1; k < legs.length; k++) {
|
|
177
|
+
const base = legs[k].base;
|
|
178
|
+
if (!base || typeof base !== 'object')
|
|
179
|
+
continue; // no signal on the record — documented degradation
|
|
180
|
+
const before = (0, stateAt_js_1.foldLegs)(legs, k - 1, Number.POSITIVE_INFINITY);
|
|
181
|
+
if (before.basis !== 'initial+log' || before.skipped)
|
|
182
|
+
continue; // not a state a real base can be held to
|
|
183
|
+
if (!sameState(before.state, base, new Set(before.redactedPaths), '')) {
|
|
184
|
+
return (`timeTravel: source ${k}'s initialState is not the state source ${k - 1} folds to. On a resume ` +
|
|
185
|
+
"the later leg's initialState IS the state at the pause, so a leg that begins anywhere else is " +
|
|
186
|
+
'not from one lineage — a different chart, or another run of this one — even when its execution ' +
|
|
187
|
+
'indices happen to be higher.');
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
exports.refuseChain = refuseChain;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* commitStops — the one strategy foottrace ships.
|
|
4
|
+
*
|
|
5
|
+
* One stop per executed stage, in execution order, plus `'start'` / `'end'`
|
|
6
|
+
* bookends. It is the only stop grammar the substrate itself knows: the engine
|
|
7
|
+
* stamps one `runtimeStageId` per executed stage, and an empty commit is a
|
|
8
|
+
* deliberate cursor stop, not noise. Richer vocabularies (milestones, turns,
|
|
9
|
+
* tool calls) belong to the consumer that owns them — they plug in through
|
|
10
|
+
* `TimeTravelStrategy`, they do not go here.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.commitStopsStrategy = exports.commitStops = void 0;
|
|
14
|
+
const runtimeStageId_js_1 = require("../ids/runtimeStageId.js");
|
|
15
|
+
const commitLogUtils_js_1 = require("../memory/commitLogUtils.js");
|
|
16
|
+
/**
|
|
17
|
+
* Every `runtimeStageId` in the execution tree that the engine marked as a
|
|
18
|
+
* subflow mount. Authoritative, as is a bundle's recorded `phase: 'exit'`
|
|
19
|
+
* (9.39.0) — a mount with a merge-back records its exit as a continuation. A
|
|
20
|
+
* mount without one has a single bundle, its own (no `phase`), so only the
|
|
21
|
+
* tree names it. Only a log written before 9.39.0 AND handed over without its
|
|
22
|
+
* tree falls back to the legacy inference (`inferLegacyPhases`).
|
|
23
|
+
*/
|
|
24
|
+
function mountIdsFrom(tree) {
|
|
25
|
+
const ids = new Set();
|
|
26
|
+
if (!tree)
|
|
27
|
+
return ids;
|
|
28
|
+
const work = [tree];
|
|
29
|
+
while (work.length > 0) {
|
|
30
|
+
const node = work.pop();
|
|
31
|
+
if (node.subflowId && node.runtimeStageId)
|
|
32
|
+
ids.add(node.runtimeStageId);
|
|
33
|
+
if (node.next)
|
|
34
|
+
work.push(node.next);
|
|
35
|
+
if (node.children)
|
|
36
|
+
work.push(...node.children);
|
|
37
|
+
}
|
|
38
|
+
return ids;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Derive one stop per executed stage from a recorded commit log.
|
|
42
|
+
*
|
|
43
|
+
* **One stop per `runtimeStageId`.** A stage can commit MORE than one bundle:
|
|
44
|
+
* a subflow mount commits its output-mapping bundle and then its EXIT; a
|
|
45
|
+
* parallel fork child is committed by the stage funnel and again by the
|
|
46
|
+
* fan-out (its REPEAT), and siblings interleave. The writer names each
|
|
47
|
+
* continuation on its bundle (`phase: 'exit' | 'repeat'`, 9.39.0), so the
|
|
48
|
+
* grouping is read, never inferred: the axis shows the stage ONCE, at its
|
|
49
|
+
* first commit ({@link buildCommitIndex}), which keeps `runtimeStageId → stop`
|
|
50
|
+
* one-to-one — the property `jumpTo` and marks depend on. The FIRST bundle per
|
|
51
|
+
* `runtimeStageId` is the stage's own and never carries a `phase`; a stage
|
|
52
|
+
* whose bundles include an `'exit'` is a `'mount'`. A continuation is normally empty
|
|
53
|
+
* (the first commit released the staging buffer); one that carries a write is
|
|
54
|
+
* folded where it sits in the log, which is when it happened.
|
|
55
|
+
*
|
|
56
|
+
* **Stops PARTITION the log.** A stop's range runs from its own first commit
|
|
57
|
+
* up to (and including) the last commit before the NEXT stop begins —
|
|
58
|
+
* `lastCommitIdx`. Every bundle therefore belongs to exactly one stop, nothing
|
|
59
|
+
* is orphaned, and `stateAt(stop)` is precisely the state that existed just
|
|
60
|
+
* before the next stop's stage started. Folding through `commitIdx` instead
|
|
61
|
+
* would silently drop a mount's output mapping.
|
|
62
|
+
*
|
|
63
|
+
* **Bookends.** `'start'` is the position before the first commit — the fold
|
|
64
|
+
* base, which no commit index can otherwise address. `'end'` is "the run is
|
|
65
|
+
* over"; it folds the whole log, the same as the last stage's stop, because
|
|
66
|
+
* "after the last stage" and "the run finished" are the same state asked as
|
|
67
|
+
* two different questions.
|
|
68
|
+
*
|
|
69
|
+
* An EMPTY log yields NO stops at all — not two bookends around nothing. A
|
|
70
|
+
* cursor with nowhere to stand says so (`Move.reason === 'empty'`).
|
|
71
|
+
*
|
|
72
|
+
* **THE SHAPE IS A CONTRACT (9.18.0).** For a non-empty log the result is
|
|
73
|
+
* `[start, …stages, end]` — `'start'` first, `'end'` last, one stop per
|
|
74
|
+
* executed stage between them, in execution order — and for an empty log it
|
|
75
|
+
* is `[]`. A strategy that COMPOSES this one (keep some stages, drop the rest)
|
|
76
|
+
* rests on that shape; it is pinned by `test/lib/time-travel/`, and
|
|
77
|
+
* {@link splitAxis} is the one guard that reads it — a composer calls that, or
|
|
78
|
+
* {@link filterStops} which calls it, instead of writing its own.
|
|
79
|
+
*/
|
|
80
|
+
function commitStops(commitLog, executionTree, subflowResults) {
|
|
81
|
+
if (commitLog.length === 0)
|
|
82
|
+
return [];
|
|
83
|
+
// No tree? The snapshot's `subflowResults` still keys every mount EXECUTION
|
|
84
|
+
// by its runtimeStageId (9.39.0) — the mapper-less mounts whose one bundle
|
|
85
|
+
// carries no `phase` (fork / selector children, lazy mounts, `parallelForEach`
|
|
86
|
+
// branches) included.
|
|
87
|
+
const mountIds = executionTree ? mountIdsFrom(executionTree) : mountKeysOf(subflowResults);
|
|
88
|
+
const phases = phasesOf(commitLog, executionTree !== undefined);
|
|
89
|
+
// First commit of each distinct runtimeStageId, in execution order — the
|
|
90
|
+
// one index every reader shares (`buildCommitIndex`).
|
|
91
|
+
// A subflow's `inputMapper` seed is not one of the subflow's stages: it is
|
|
92
|
+
// the MOUNT's commit, made before any of them ran. It gets no stop of its
|
|
93
|
+
// own; it belongs to the `'start'` bookend, which is where a reader looks
|
|
94
|
+
// for "the input this chart began with" anyway. See {@link seedCommits}.
|
|
95
|
+
const seeds = seedCommits(commitLog, executionTree);
|
|
96
|
+
const firsts = [];
|
|
97
|
+
for (const [id, i] of (0, commitLogUtils_js_1.buildCommitIndex)(commitLog))
|
|
98
|
+
if (id && i >= seeds)
|
|
99
|
+
firsts.push(i);
|
|
100
|
+
const exits = new Set();
|
|
101
|
+
for (let i = seeds; i < commitLog.length; i++)
|
|
102
|
+
if (phases[i] === 'exit')
|
|
103
|
+
exits.add(commitLog[i].runtimeStageId);
|
|
104
|
+
const stops = [
|
|
105
|
+
{
|
|
106
|
+
step: 0,
|
|
107
|
+
runtimeStageId: '',
|
|
108
|
+
commitIdx: -1,
|
|
109
|
+
// Covers the subflow input seed, when the log opens with one.
|
|
110
|
+
lastCommitIdx: (firsts.length > 0 ? firsts[0] : commitLog.length) - 1,
|
|
111
|
+
stageId: '',
|
|
112
|
+
label: 'Run start',
|
|
113
|
+
kind: 'start',
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
for (let g = 0; g < firsts.length; g++) {
|
|
117
|
+
const first = firsts[g];
|
|
118
|
+
const bundle = commitLog[first];
|
|
119
|
+
// Partition boundary: everything up to the next stage's first commit.
|
|
120
|
+
const last = g + 1 < firsts.length ? firsts[g + 1] - 1 : commitLog.length - 1;
|
|
121
|
+
stops.push({
|
|
122
|
+
step: stops.length,
|
|
123
|
+
runtimeStageId: bundle.runtimeStageId,
|
|
124
|
+
commitIdx: first,
|
|
125
|
+
lastCommitIdx: last,
|
|
126
|
+
stageId: bundle.stageId,
|
|
127
|
+
subflowPath: (0, runtimeStageId_js_1.parseRuntimeStageId)(bundle.runtimeStageId).subflowPath,
|
|
128
|
+
label: bundle.stage || bundle.stageId || bundle.runtimeStageId,
|
|
129
|
+
kind: mountIds.has(bundle.runtimeStageId) || exits.has(bundle.runtimeStageId) ? 'mount' : 'commit',
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
stops.push({
|
|
133
|
+
step: stops.length,
|
|
134
|
+
runtimeStageId: '',
|
|
135
|
+
commitIdx: commitLog.length - 1,
|
|
136
|
+
lastCommitIdx: commitLog.length - 1,
|
|
137
|
+
stageId: '',
|
|
138
|
+
label: 'Run end',
|
|
139
|
+
kind: 'end',
|
|
140
|
+
});
|
|
141
|
+
return stops;
|
|
142
|
+
}
|
|
143
|
+
exports.commitStops = commitStops;
|
|
144
|
+
/** The per-execution mount keys of a snapshot's `subflowResults` (`'#'` keys; path keys skipped). */
|
|
145
|
+
function mountKeysOf(subflowResults) {
|
|
146
|
+
const ids = new Set();
|
|
147
|
+
if (subflowResults === null || typeof subflowResults !== 'object')
|
|
148
|
+
return ids;
|
|
149
|
+
for (const key of Object.keys(subflowResults))
|
|
150
|
+
if ((0, runtimeStageId_js_1.isExecutionKey)(key))
|
|
151
|
+
ids.add(key);
|
|
152
|
+
return ids;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The phase of every bundle: as RECORDED when the log records any (9.39.0+).
|
|
156
|
+
* A log that records none is either free of continuations (nothing to read)
|
|
157
|
+
* or older than the field: with its execution tree the tree names the mounts,
|
|
158
|
+
* so nothing is inferred; without it, the one legacy reader infers what
|
|
159
|
+
* 9.38.0 inferred (`inferLegacyPhases`) — a stored recording keeps its axis.
|
|
160
|
+
*/
|
|
161
|
+
function phasesOf(commitLog, haveTree) {
|
|
162
|
+
if ((0, commitLogUtils_js_1.recordsPhases)(commitLog))
|
|
163
|
+
return commitLog.map((bundle) => bundle.phase);
|
|
164
|
+
return haveTree ? [] : (0, commitLogUtils_js_1.inferLegacyPhases)(commitLog);
|
|
165
|
+
}
|
|
166
|
+
/** `commitStops` as a {@link TimeTravelStrategy} — the default for `timeTravel`. */
|
|
167
|
+
exports.commitStopsStrategy = { stopsFor: commitStops };
|
|
168
|
+
/**
|
|
169
|
+
* How many commits at the head of a log are a subflow's input seed — 0 on a
|
|
170
|
+
* run's own log. The seed is `history[0]` of the subflow's log, committed by
|
|
171
|
+
* the MOUNT before any of the subflow's stages ran:
|
|
172
|
+
*
|
|
173
|
+
* - since R13 it carries the mount's runtimeStageId — and a mount's stage
|
|
174
|
+
* address (the id before `#`) IS the subflow path of every stage in the
|
|
175
|
+
* log it opens (`sub#2` opens `sub/in#3`; `outer/sub#5` opens
|
|
176
|
+
* `outer/sub/in#6`), which no stage of that log can be;
|
|
177
|
+
* - through 9.33.0 it carried `''`, which is still read the same way, so an
|
|
178
|
+
* old recording keeps its axis.
|
|
179
|
+
*
|
|
180
|
+
* A log that holds ONLY the seed (the subflow committed no stage — it paused
|
|
181
|
+
* or failed first) has no stage to compare with; the execution tree's root
|
|
182
|
+
* stands in for it: a subflow's tree is rooted at one of its own stages,
|
|
183
|
+
* whose id carries the same subflow path. Without a tree such a log reads as
|
|
184
|
+
* one stop.
|
|
185
|
+
*/
|
|
186
|
+
function seedCommits(commitLog, executionTree) {
|
|
187
|
+
const head = commitLog[0]?.runtimeStageId;
|
|
188
|
+
if (head === undefined)
|
|
189
|
+
return 0;
|
|
190
|
+
if (head === '') {
|
|
191
|
+
let n = 0;
|
|
192
|
+
while (n < commitLog.length && commitLog[n].runtimeStageId === '')
|
|
193
|
+
n++;
|
|
194
|
+
return n;
|
|
195
|
+
}
|
|
196
|
+
let next = 1;
|
|
197
|
+
while (next < commitLog.length && commitLog[next].runtimeStageId === head)
|
|
198
|
+
next++;
|
|
199
|
+
const address = (0, runtimeStageId_js_1.stageIdOf)(head);
|
|
200
|
+
if (next >= commitLog.length) {
|
|
201
|
+
const rootId = executionTree?.id;
|
|
202
|
+
return typeof rootId === 'string' && (0, runtimeStageId_js_1.isWithinSubflow)(rootId, address) ? next : 0;
|
|
203
|
+
}
|
|
204
|
+
return (0, runtimeStageId_js_1.parseRuntimeStageId)(commitLog[next].runtimeStageId).subflowPath === address ? next : 0;
|
|
205
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* time-travel/ — the reader's cursor over a finished trace.
|
|
4
|
+
*
|
|
5
|
+
* Time travel here is READ-TIME: a cursor over a Trace that has already
|
|
6
|
+
* happened, with a Fold at each stop. It is not the Walker and never becomes a
|
|
7
|
+
* second live cursor — nothing in this folder can move, re-run or mutate an
|
|
8
|
+
* execution.
|
|
9
|
+
*
|
|
10
|
+
* See README.md for the five laws, the strategy seam, and a worked example of
|
|
11
|
+
* every export.
|
|
12
|
+
*
|
|
13
|
+
* DAG position: memory ← time-travel (plus `ids/runtimeStageId`, the
|
|
14
|
+
* zero-dependency id grammar).
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.timeTravel = exports.tagStops = exports.stateAt = exports.commitStopsStrategy = exports.commitStops = exports.isCommitBundle = exports.splitAxis = exports.filterStops = void 0;
|
|
18
|
+
var axis_js_1 = require("./axis.js");
|
|
19
|
+
Object.defineProperty(exports, "filterStops", { enumerable: true, get: function () { return axis_js_1.filterStops; } });
|
|
20
|
+
Object.defineProperty(exports, "splitAxis", { enumerable: true, get: function () { return axis_js_1.splitAxis; } });
|
|
21
|
+
var bundles_js_1 = require("./bundles.js");
|
|
22
|
+
Object.defineProperty(exports, "isCommitBundle", { enumerable: true, get: function () { return bundles_js_1.isCommitBundle; } });
|
|
23
|
+
var commitStops_js_1 = require("./commitStops.js");
|
|
24
|
+
Object.defineProperty(exports, "commitStops", { enumerable: true, get: function () { return commitStops_js_1.commitStops; } });
|
|
25
|
+
Object.defineProperty(exports, "commitStopsStrategy", { enumerable: true, get: function () { return commitStops_js_1.commitStopsStrategy; } });
|
|
26
|
+
var stateAt_js_1 = require("./stateAt.js");
|
|
27
|
+
Object.defineProperty(exports, "stateAt", { enumerable: true, get: function () { return stateAt_js_1.stateAt; } });
|
|
28
|
+
var tagStops_js_1 = require("./tagStops.js");
|
|
29
|
+
Object.defineProperty(exports, "tagStops", { enumerable: true, get: function () { return tagStops_js_1.tagStops; } });
|
|
30
|
+
var timeTravel_js_1 = require("./timeTravel.js");
|
|
31
|
+
Object.defineProperty(exports, "timeTravel", { enumerable: true, get: function () { return timeTravel_js_1.timeTravel; } });
|