NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
sqlite_checkpoint.h
Go to the documentation of this file.
1
45#pragma once
46
47#include <neograph/api.h>
49#include <memory>
50#include <mutex>
51#include <string>
52
53// Forward-declare so this header doesn't drag the sqlite3 C header
54// into every TU that includes it.
55struct sqlite3;
56
57namespace neograph::graph {
58
66class NEOGRAPH_API SqliteCheckpointStore : public CheckpointStore {
67public:
70 explicit SqliteCheckpointStore(const std::string& db_path);
71
72 ~SqliteCheckpointStore() override;
73
74 // sqlite3* is a unique resource — no copying or moving.
76 SqliteCheckpointStore& operator=(const SqliteCheckpointStore&) = delete;
77
78 void save(const Checkpoint& cp) override;
79 std::optional<Checkpoint> load_latest(const std::string& thread_id) override;
80 std::optional<Checkpoint> load_by_id(const std::string& id) override;
81 std::vector<Checkpoint> list(const std::string& thread_id,
82 int limit = 100) override;
83 void delete_thread(const std::string& thread_id) override;
84
85 void put_writes(const std::string& thread_id,
86 const std::string& parent_checkpoint_id,
87 const PendingWrite& write) override;
88 std::vector<PendingWrite> get_writes(
89 const std::string& thread_id,
90 const std::string& parent_checkpoint_id) override;
91 void clear_writes(const std::string& thread_id,
92 const std::string& parent_checkpoint_id) override;
93
97
102 size_t blob_count();
103
104private:
105 void ensure_schema();
106 void exec_ddl(const char* sql);
107
110 sqlite3* db_ = nullptr;
111 std::mutex db_mutex_;
112};
113
114} // namespace neograph::graph
NEOGRAPH_API export/import macro for shared-library builds.
Checkpoint system for graph execution state persistence and time-travel.
Abstract interface for checkpoint persistence backends.
Definition checkpoint.h:207
Persistent CheckpointStore backed by a SQLite database file.
void save(const Checkpoint &cp) override
Save a checkpoint.
void delete_thread(const std::string &thread_id) override
Delete all checkpoints for a thread.
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.
SqliteCheckpointStore(const std::string &db_path)
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 drop_schema()
Drop all neograph_* tables and recreate them.
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.
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...
size_t blob_count()
Number of distinct channel-value blobs currently held.
std::optional< Checkpoint > load_latest(const std::string &thread_id) override
Load the most recent checkpoint for a thread.
Serialized snapshot of graph execution state at a single super-step.
Definition checkpoint.h:83
Successful node writes recorded within an in-progress super-step.
Definition checkpoint.h:140