|
NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
|
Abstract interface for checkpoint persistence backends. More...
#include <checkpoint.h>
Public Member Functions | |
| virtual void | clear_writes (const std::string &, const std::string &) |
| Discard pending writes for a parent checkpoint once its successor super-step has been fully committed. | |
| virtual void | delete_thread (const std::string &thread_id) |
| Delete all checkpoints for a thread. | |
| virtual std::vector< PendingWrite > | get_writes (const std::string &, const std::string &) |
| Load all pending writes attached to a parent checkpoint. | |
| virtual std::vector< Checkpoint > | list (const std::string &thread_id, int limit=100) |
| List checkpoints for a thread, ordered by timestamp (newest first). | |
| virtual std::optional< Checkpoint > | load_by_id (const std::string &id) |
| Load a checkpoint by its unique ID. | |
| virtual std::optional< Checkpoint > | load_latest (const std::string &thread_id) |
| Load the most recent checkpoint for a thread. | |
| virtual void | put_writes (const std::string &, const std::string &, const PendingWrite &) |
| Record a successful node execution within an in-progress super-step. | |
| virtual void | save (const Checkpoint &cp) |
| Save a checkpoint. | |
Abstract interface for checkpoint persistence backends.
Implement this to store checkpoints in databases, files, or other storage systems. The engine uses this interface for save/load operations.
The put_writes / get_writes / clear_writes family lets the engine record each successful node execution within a super-step, so partial fan-out failures can be resumed without re-running siblings. Custom stores MAY leave the default no-op implementations in place — the engine degrades gracefully to "full super-step replay" semantics, matching the behavior of NeoGraph before this feature existed.
Durability requirement: put_writes must be durable by the time it returns (flushed to whatever backend the store wraps), because the engine calls state.apply_writes only after put_writes succeeds.
Individual ops are atomic; cross-op sequencing is the caller's responsibility. Every backend in-tree (InMemoryCheckpointStore mutex-guards each call; PostgresCheckpointStore / SqliteCheckpointStore use per-call transactions) guarantees that a single save_checkpoint / load_latest / put_writes / delete_thread call observes a consistent snapshot — no torn reads, no half-applied writes. They do NOT serialize sequences of calls for the same thread_id. Concurrent runs against the same thread_id therefore exhibit last-writer-wins on save_checkpoint and last-saver visibility on subsequent load_latest — see GraphEngine's class-level Thread safety section for the engine- side contract. Backend authors implementing this interface MUST preserve the per-call-atomic invariant; callers needing cross-op atomicity (e.g. compare-and-set on the latest checkpoint) must wrap the relevant call sequence behind their own external mutex, or use the engine's cancel_token to drain in-flight runs before issuing an admin op.
CheckpointStoreCore — 5 sync mandatory virtualsAsyncCheckpointStore — async peer mixin (optional)PendingWritesCheckpointStore — pending-writes mixin The current monolithic shape is kept for back-compat. New backends should override at least one of (sync, async) per method to avoid infinite recursion. Definition at line 207 of file checkpoint.h.
|
inlinevirtual |
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 in neograph::graph::InMemoryCheckpointStore, neograph::graph::PostgresCheckpointStore, and neograph::graph::SqliteCheckpointStore.
Definition at line 318 of file checkpoint.h.
|
virtual |
Delete all checkpoints for a thread.
| thread_id | Thread identifier to delete. |
Reimplemented in neograph::graph::InMemoryCheckpointStore, neograph::graph::PostgresCheckpointStore, and neograph::graph::SqliteCheckpointStore.
|
inlinevirtual |
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 in neograph::graph::InMemoryCheckpointStore, neograph::graph::PostgresCheckpointStore, and neograph::graph::SqliteCheckpointStore.
Definition at line 303 of file checkpoint.h.
|
virtual |
List checkpoints for a thread, ordered by timestamp (newest first).
| thread_id | Thread identifier. |
| limit | Maximum number of checkpoints to return (default: 100). |
Reimplemented in neograph::graph::InMemoryCheckpointStore, neograph::graph::PostgresCheckpointStore, and neograph::graph::SqliteCheckpointStore.
|
virtual |
Load a checkpoint by its unique ID.
| id | Checkpoint UUID. |
Reimplemented in neograph::graph::InMemoryCheckpointStore, neograph::graph::PostgresCheckpointStore, and neograph::graph::SqliteCheckpointStore.
|
virtual |
Load the most recent checkpoint for a thread.
| thread_id | Thread identifier. |
Reimplemented in neograph::graph::InMemoryCheckpointStore, neograph::graph::PostgresCheckpointStore, and neograph::graph::SqliteCheckpointStore.
|
inlinevirtual |
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 in neograph::graph::InMemoryCheckpointStore, neograph::graph::PostgresCheckpointStore, and neograph::graph::SqliteCheckpointStore.
Definition at line 289 of file checkpoint.h.
|
virtual |
Save a checkpoint.
| cp | The checkpoint to persist. |
Reimplemented in neograph::graph::InMemoryCheckpointStore, neograph::graph::PostgresCheckpointStore, and neograph::graph::SqliteCheckpointStore.