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.
@@ -6,24 +6,35 @@
6
6
  * (`pause/record.ts` · `CHECKPOINT_VERSION` / `decodeCheckpoint`), and
7
7
  * detaches it with one `structuredClone`.
8
8
  *
9
- * Clone resilience lives beside it. The JSON-safe contract governs what
10
- * CONSUMERS put into a checkpoint (pauseData, shared state) — but the
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
- * - `sanitizeDiagnosticBags` — replace non-cloneable diagnostic values with
20
- * marker strings (`'[non-serializable: function]'`) so the pause survives.
21
- * - `describeCheckpointCloneFailure` — when the clone STILL fails after
22
- * sanitization (the non-cloneable lives in consumer-owned data, e.g.
23
- * `pauseData`), name the offending checkpoint field(s) and point at the
24
- * JSON-safe contract instead of letting a naked `DataCloneError` escape.
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
- * Both run ONLY on the clone-failure path of a pause — never on the hot path.
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. Pause is not a hot path; the
58
- * clone cost is irrelevant.
63
+ * must never share structure with the engine.
59
64
  *
60
- * On clone failure the diagnostic bags are sanitized (the live engine bags
61
- * are never touched) and the clone retried; if the retry STILL fails, the
62
- * violation is in consumer-owned data (realistically `pauseData` — a function
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`). Empty `{}` for root-level pauses.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "footprintjs",
3
- "version": "9.43.0",
3
+ "version": "9.44.0",
4
4
  "description": "Explainable backend flows — automatic causal traces, decision evidence, and MCP tool generation for AI agents",
5
5
  "license": "MIT",
6
6
  "author": "Sanjay Krishna Anbalagan",