NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
sqlite_checkpoint.h File Reference

SQLite-backed CheckpointStore — single-file persistence for embedded and single-process deployments. More...

#include <neograph/api.h>
#include <neograph/graph/checkpoint.h>
#include <memory>
#include <mutex>
#include <string>
Include dependency graph for sqlite_checkpoint.h:

Go to the source code of this file.

Classes

class  neograph::graph::SqliteCheckpointStore
 Persistent CheckpointStore backed by a SQLite database file. More...
 

Detailed Description

SQLite-backed CheckpointStore — single-file persistence for embedded and single-process deployments.

Mirrors PostgresCheckpointStore's schema and semantics so swapping the backend is a one-line change at the call site:

auto store = std::make_shared<SqliteCheckpointStore>("/var/lib/neograph.db");

vs. the Postgres variant:

auto store = std::make_shared<PostgresCheckpointStore>( "postgresql://user:pass@host/db");

Both implement the same CheckpointStore interface with identical dedup behaviour: channel values are stored once per (thread, channel, version) triple via INSERT ... ON CONFLICT DO NOTHING. The schema uses the same neograph_* table prefix so a sqlite_dump → psql import migration path is conceivable (though not implemented).

When to pick SQLite over Postgres

SQLite wins when:

  • The deployment is single-process (no multi-host coordination).
  • The target is embedded / edge / a desktop CLI tool — no DB server to provision.
  • Operational simplicity beats raw concurrency: SQLite serialises writers but is faster than Postgres for low-throughput durable state because there's no network hop.

Postgres wins when multiple agent processes share state, when checkpoint volume is high enough that WAL + fsync cost matters, or when an external operator wants to inspect/manage state with their existing PG tooling.

Concurrency

The connection is wrapped in a mutex; every public method holds it for the duration of its work. SQLite's own thread-safety mode is set to "serialized" by default in libsqlite3, so this mutex is belt-and- suspenders against concurrent statement preparation. WAL journal mode is enabled at construction so reads don't block other reads.

Definition in file sqlite_checkpoint.h.