|
NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
|
In-memory checkpoint store for testing and single-process use. More...
#include <checkpoint.h>
Public Member Functions | |
| size_t | blob_count () const |
| Number of distinct channel-value blobs currently held (test helper). | |
| void | clear_writes (const std::string &thread_id, const std::string &parent_checkpoint_id) override |
| Discard pending writes for a parent checkpoint once its successor super-step has been fully committed. | |
| void | delete_thread (const std::string &thread_id) override |
| Delete all checkpoints for a thread. | |
| std::vector< PendingWrite > | get_writes (const std::string &thread_id, const std::string &parent_checkpoint_id) override |
| Load all pending writes attached to a parent checkpoint. | |
| std::vector< Checkpoint > | list (const std::string &thread_id, int limit=100) override |
| List checkpoints for a thread, ordered by timestamp (newest first). | |
| std::optional< Checkpoint > | load_by_id (const std::string &id) override |
| Load a checkpoint by its unique ID. | |
| std::optional< Checkpoint > | load_latest (const std::string &thread_id) override |
| Load the most recent checkpoint for a thread. | |
| size_t | pending_writes_count (const std::string &thread_id, const std::string &parent_checkpoint_id) const |
| Get the number of pending writes for a parent checkpoint (test helper). | |
| void | put_writes (const std::string &thread_id, const std::string &parent_checkpoint_id, const PendingWrite &write) override |
| Record a successful node execution within an in-progress super-step. | |
| void | save (const Checkpoint &cp) override |
| Save a checkpoint. | |
| size_t | size () const |
| Get the total number of stored checkpoints (test helper). | |
In-memory checkpoint store for testing and single-process use.
Stores checkpoints in memory using std::map. Thread-safe via mutex. Not suitable for production use where persistence across restarts is needed.
Channel values are deduplicated internally by (thread_id, channel, version) — every write bumps Channel::version, so the same value at the same version across multiple checkpoints is stored exactly once. In a typical run only one or two channels change per super-step, so a 1000-step session pays roughly (channels + steps) × value_size instead of channels × steps × value_size.
The dedup is purely an internal storage optimization: callers always receive (and pass in) Checkpoints whose channel_values carry full inline data. Engine code, tests, and migration paths are unaffected.
Persistent CheckpointStore implementations are encouraged to apply the same pattern in their own backends (e.g. a (channel, version) → blob table referenced from a (checkpoint_id, channel) → version table) to get the same on-disk savings.
Definition at line 361 of file checkpoint.h.
| size_t neograph::graph::InMemoryCheckpointStore::blob_count | ( | ) | const |
Number of distinct channel-value blobs currently held (test helper).
Use this to verify dedup: writing N identical-state checkpoints leaves blob_count() at one entry per channel, not N × channels.
|
overridevirtual |
Discard pending writes for a parent checkpoint once its successor super-step has been fully committed.
Called by the engine after the new super-step checkpoint has been durably saved, so pending writes are never cleared while still being the only record of a node's output.
| thread_id | Thread identifier. |
| parent_checkpoint_id | Checkpoint whose pending writes to clear. |
Reimplemented from neograph::graph::CheckpointStore.
|
overridevirtual |
Delete all checkpoints for a thread.
| thread_id | Thread identifier to delete. |
Reimplemented from neograph::graph::CheckpointStore.
|
overridevirtual |
Load all pending writes attached to a parent checkpoint.
Called by the engine on resume to skip already-completed tasks. Default implementation returns an empty vector.
| thread_id | Thread identifier. |
| parent_checkpoint_id | Checkpoint whose pending writes to load. |
Reimplemented from neograph::graph::CheckpointStore.
|
overridevirtual |
List checkpoints for a thread, ordered by timestamp (newest first).
| thread_id | Thread identifier. |
| limit | Maximum number of checkpoints to return (default: 100). |
Reimplemented from neograph::graph::CheckpointStore.
|
overridevirtual |
Load a checkpoint by its unique ID.
| id | Checkpoint UUID. |
Reimplemented from neograph::graph::CheckpointStore.
|
overridevirtual |
Load the most recent checkpoint for a thread.
| thread_id | Thread identifier. |
Reimplemented from neograph::graph::CheckpointStore.
|
overridevirtual |
Record a successful node execution within an in-progress super-step.
Called by the engine immediately after a node returns successfully and before its writes are applied to the shared GraphState. The parent_checkpoint_id anchors the pending write to the super-step boundary it was produced under.
Default implementation is a no-op so custom stores keep working; such stores fall back to "full super-step replay" on resume.
| thread_id | Thread identifier. |
| parent_checkpoint_id | Checkpoint marking the start of the in-progress super-step. |
| write | The pending write record to persist. |
Reimplemented from neograph::graph::CheckpointStore.
|
overridevirtual |
Save a checkpoint.
| cp | The checkpoint to persist. |
Reimplemented from neograph::graph::CheckpointStore.
| size_t neograph::graph::InMemoryCheckpointStore::size | ( | ) | const |
Get the total number of stored checkpoints (test helper).