Class InMemoryCheckpointStore

In-memory ICheckpointStore implementation.

All checkpoints are stored in a Map keyed by checkpoint id. Scans are O(n) over the number of stored checkpoints — acceptable for test workloads; a production store should use indexed secondary keys (runId, graphId).

Example

const store = new InMemoryCheckpointStore();
await store.save(checkpoint);
const restored = await store.latest(runId);

Implements

Constructors

Methods

  • Load a checkpoint for the given runId.

    When nodeId is supplied, returns the most recent checkpoint for that specific node within the run. When nodeId is omitted, returns the most recent checkpoint for the run regardless of node (equivalent to latest(runId)).

    Parameters

    • runId: string

      The graph run identifier.

    • Optional nodeId: string

      Optional node filter.

    Returns Promise<null | Checkpoint>

    The matching checkpoint, or null when none exists.

  • Create a new run branching from an existing checkpoint.

    The operation deep-clones the source checkpoint, assigns a fresh runId and checkpoint id, applies any patchState overrides, persists the new checkpoint, and returns the new runId.

    Parameters

    • checkpointId: string

      The checkpoint to fork from.

    • Optional patchState: Partial<GraphState<unknown, unknown, unknown>>

      Optional partial GraphState overrides applied after cloning.

    Returns Promise<string>

    The new runId for the forked run.