footprintjs 9.43.0 → 9.44.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/dist/esm/lib/engine/handlers/SubflowExecutor.js +14 -18
- package/dist/esm/lib/engine/handlers/servedSubflowResults.d.ts +3 -2
- package/dist/esm/lib/engine/handlers/servedSubflowResults.js +4 -3
- package/dist/esm/lib/pause/record.d.ts +28 -14
- package/dist/esm/lib/pause/record.js +29 -17
- package/dist/esm/lib/pause/types.d.ts +23 -38
- package/dist/esm/lib/pause/types.js +9 -6
- package/dist/esm/lib/runner/FlowChartExecutor.d.ts +3 -0
- package/dist/esm/lib/runner/FlowChartExecutor.js +4 -1
- package/dist/esm/lib/runner/checkpoint.d.ts +35 -30
- package/dist/esm/lib/runner/checkpoint.js +47 -162
- package/dist/lib/engine/handlers/SubflowExecutor.js +14 -18
- package/dist/lib/engine/handlers/servedSubflowResults.js +4 -3
- package/dist/lib/pause/record.js +29 -17
- package/dist/lib/pause/types.js +9 -6
- package/dist/lib/runner/FlowChartExecutor.js +4 -1
- package/dist/lib/runner/checkpoint.js +47 -162
- package/dist/types/lib/engine/handlers/servedSubflowResults.d.ts +3 -2
- package/dist/types/lib/pause/record.d.ts +28 -14
- package/dist/types/lib/pause/types.d.ts +23 -38
- package/dist/types/lib/runner/FlowChartExecutor.d.ts +3 -0
- package/dist/types/lib/runner/checkpoint.d.ts +35 -30
- package/package.json +1 -1
|
@@ -6,24 +6,35 @@
|
|
|
6
6
|
* (`pause/record.ts` · `CHECKPOINT_VERSION` / `decodeCheckpoint`), and
|
|
7
7
|
* detaches it with one `structuredClone`.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* execution tree's diagnostic bags (`logs`/`errors`/`metrics`/`evals`) accept
|
|
12
|
-
* ANY value at write time without cloning (`$debug`/`$error`/`$metric`/`$eval`
|
|
13
|
-
* route through `DiagnosticCollector`, which stores raw references). A
|
|
14
|
-
* `$debug`'d function in any stage of a pausing run would make the
|
|
15
|
-
* whole-checkpoint clone throw `DataCloneError` — swallowing the pause. That
|
|
16
|
-
* violates the library's error-isolation grain (observability side-bags never
|
|
17
|
-
* abort traversal anywhere else), so:
|
|
9
|
+
* LEAN (format 2). The checkpoint holds what `resume()` reads and the pause's
|
|
10
|
+
* own record, nothing else:
|
|
18
11
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
12
|
+
* read by resume the cursor (`pausedStageId`, `subflowPath`, `pausedBy`),
|
|
13
|
+
* the state (`sharedState`, and `subflowStates` — one capture
|
|
14
|
+
* per subflow ON the pause path), the counters
|
|
15
|
+
* (`executionCount`, `visitCounts` — one entry per stage id),
|
|
16
|
+
* the waiting siblings (`pendingPauses`), the redaction names
|
|
17
|
+
* (`redactionMarks`), the link (`pausedExecution`);
|
|
18
|
+
* the record `pauseData` (the question), `invokerStageId`, `pausedAt`.
|
|
25
19
|
*
|
|
26
|
-
*
|
|
20
|
+
* So its size is the state's and the chart's, never the run's length. Format 1
|
|
21
|
+
* also carried the whole execution tree and the finished subflows' results —
|
|
22
|
+
* the run's served record, which no resume read and which grew with every
|
|
23
|
+
* finished iteration (`bench/checkpoint-size.ts`: 19.3 MB after 60 agent
|
|
24
|
+
* turns whose resumable state — root plus captures — is 0.13 MB; the tree
|
|
25
|
+
* alone was 97%). That record is `getSnapshot()`'s. Pinned:
|
|
26
|
+
* test/lib/pause/checkpoint-size.test.ts.
|
|
27
|
+
*
|
|
28
|
+
* THE LAW holds: the checkpoint keeps REAL values — no redaction policy ever
|
|
29
|
+
* touches it (it is what the resumed run computes on); the marks travel as
|
|
30
|
+
* NAMES only.
|
|
31
|
+
*
|
|
32
|
+
* The JSON-safe contract governs what CONSUMERS put into a checkpoint
|
|
33
|
+
* (`pauseData`, shared state). A value `structuredClone` refuses can only come
|
|
34
|
+
* from them — shared state is cloned at every commit, so a function never
|
|
35
|
+
* reaches it, and no diagnostic bag is carried — so a failed clone becomes a
|
|
36
|
+
* DESCRIPTIVE contract error naming the field (`describeCheckpointCloneFailure`)
|
|
37
|
+
* instead of a naked `DataCloneError`.
|
|
27
38
|
*/
|
|
28
39
|
import type { FlowchartTraverser } from '../engine/traversal/FlowchartTraverser.js';
|
|
29
40
|
import type { FlowchartCheckpoint, PauseSignal, RedactionMarks } from '../pause/types.js';
|
|
@@ -36,7 +47,7 @@ export interface PausedRun {
|
|
|
36
47
|
readonly redactionMarks?: RedactionMarks;
|
|
37
48
|
}
|
|
38
49
|
/**
|
|
39
|
-
* Build a fully DETACHED checkpoint from a caught PauseSignal.
|
|
50
|
+
* Build a fully DETACHED, lean checkpoint from a caught PauseSignal.
|
|
40
51
|
*
|
|
41
52
|
* Every field is deep-copied via one `structuredClone` of the assembled
|
|
42
53
|
* checkpoint, because the raw pieces alias live engine state:
|
|
@@ -45,27 +56,21 @@ export interface PausedRun {
|
|
|
45
56
|
* but (copy-on-write, 9.29.0) every later generation shares its
|
|
46
57
|
* unchanged subtrees, so a checkpoint that aliased it would alias the
|
|
47
58
|
* resumed run's state too.
|
|
48
|
-
* - `executionTree` nodes are fresh, but their `logs`/`errors`/`metrics`/
|
|
49
|
-
* `evals`/`stageReads`/`flowMessages` fields reference live
|
|
50
|
-
* `DiagnosticCollector` bags that keep accumulating on same-executor
|
|
51
|
-
* resume.
|
|
52
59
|
* - `subflowStates` values are shallow copies whose NESTED objects alias
|
|
53
60
|
* subflow memory, and they get seeded back into live runtimes on resume.
|
|
54
|
-
* - `subflowResults` values stay referenced by the traverser's results map.
|
|
55
61
|
*
|
|
56
62
|
* The checkpoint is persisted by contract ("store in Redis/Postgres") — it
|
|
57
|
-
* must never share structure with the engine.
|
|
58
|
-
* clone cost is irrelevant.
|
|
63
|
+
* must never share structure with the engine.
|
|
59
64
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* can never reach shared state: the record's clone at commit refuses it) and a
|
|
64
|
-
* DESCRIPTIVE contract error names the offending checkpoint field(s).
|
|
65
|
+
* The state is read straight off the root runtime's store — no snapshot is
|
|
66
|
+
* built (a snapshot would build the execution tree and copy the commit log,
|
|
67
|
+
* work proportional to the run's length, only to throw both away).
|
|
65
68
|
*
|
|
66
69
|
* Subflow scope capture (`subflowStates`) survives ONLY on the signal — the
|
|
67
70
|
* nested runtimes are GC'd as the stack unwinds. Promoting it onto the
|
|
68
71
|
* checkpoint here lets cross-executor resume restore pre-pause subflow
|
|
69
|
-
* scope (e.g. an Agent's `scope.history`).
|
|
72
|
+
* scope (e.g. an Agent's `scope.history`). The signal captures a subflow only
|
|
73
|
+
* as it bubbles through that subflow's boundary, so the keys are exactly the
|
|
74
|
+
* pause path's. Empty `{}` for root-level pauses.
|
|
70
75
|
*/
|
|
71
76
|
export declare function buildPauseCheckpoint(signal: PauseSignal, traverser: FlowchartTraverser<any, any>, run: PausedRun): FlowchartCheckpoint;
|
package/package.json
CHANGED