14#include <asio/awaitable.hpp>
26namespace neograph::graph {
232 virtual std::optional<Checkpoint>
load_latest(
const std::string& thread_id);
239 virtual std::optional<Checkpoint>
load_by_id(
const std::string&
id);
247 virtual std::vector<Checkpoint>
list(
const std::string& thread_id,
262 virtual asio::awaitable<void> save_async(
const Checkpoint& cp);
263 virtual asio::awaitable<std::optional<Checkpoint>>
264 load_latest_async(
const std::string& thread_id);
265 virtual asio::awaitable<std::optional<Checkpoint>>
266 load_by_id_async(
const std::string&
id);
267 virtual asio::awaitable<std::vector<Checkpoint>>
268 list_async(
const std::string& thread_id,
int limit = 100);
269 virtual asio::awaitable<void>
270 delete_thread_async(
const std::string& thread_id);
305 const std::string& ) {
return {}; }
319 const std::string& ) {}
325 virtual asio::awaitable<void> put_writes_async(
326 const std::string& thread_id,
327 const std::string& parent_checkpoint_id,
329 virtual asio::awaitable<std::vector<PendingWrite>> get_writes_async(
330 const std::string& thread_id,
331 const std::string& parent_checkpoint_id);
332 virtual asio::awaitable<void> clear_writes_async(
333 const std::string& thread_id,
334 const std::string& parent_checkpoint_id);
364 std::optional<Checkpoint>
load_latest(
const std::string& thread_id)
override;
365 std::optional<Checkpoint>
load_by_id(
const std::string&
id)
override;
366 std::vector<Checkpoint>
list(
const std::string& thread_id,
367 int limit = 100)
override;
371 const std::string& parent_checkpoint_id,
374 const std::string& thread_id,
375 const std::string& parent_checkpoint_id)
override;
377 const std::string& parent_checkpoint_id)
override;
397 const std::string& parent_checkpoint_id)
const;
415 mutable std::mutex mutex_;
416 std::map<std::string, std::vector<Checkpoint>> by_thread_;
417 std::map<std::string, Checkpoint> by_id_;
421 std::map<std::tuple<std::string, std::string, uint64_t>, json> blobs_;
423 std::map<std::pair<std::string, std::string>, std::vector<PendingWrite>> pending_;
NEOGRAPH_API export/import macro for shared-library builds.
CheckpointPhase
Phase at which a Checkpoint was produced.
@ After
Saved just after an interrupt_after node completed.
@ Before
Saved just before an interrupt_before node fires.
@ Updated
Saved by update_state() injecting state externally.
NEOGRAPH_API const char * to_string(CheckpointPhase phase)
Canonical wire / log string for a CheckpointPhase.
NEOGRAPH_API CheckpointPhase parse_checkpoint_phase(std::string_view s)
Parse a phase string back to the enum.
constexpr std::uint32_t CHECKPOINT_SCHEMA_VERSION
Current Checkpoint layout version.
Abstract interface for checkpoint persistence backends.
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 std::vector< PendingWrite > get_writes(const std::string &, const std::string &)
Load all pending writes attached to a parent checkpoint.
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.
virtual std::optional< Checkpoint > load_by_id(const std::string &id)
Load a checkpoint by its unique ID.
virtual void delete_thread(const std::string &thread_id)
Delete all checkpoints for a thread.
virtual std::vector< Checkpoint > list(const std::string &thread_id, int limit=100)
List checkpoints for a thread, ordered by timestamp (newest first).
In-memory checkpoint store for testing and single-process use.
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 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::optional< Checkpoint > load_latest(const std::string &thread_id) override
Load the most recent checkpoint for a thread.
size_t blob_count() const
Number of distinct channel-value blobs currently held (test helper).
std::optional< Checkpoint > load_by_id(const std::string &id) override
Load a checkpoint by its unique ID.
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.
std::vector< Checkpoint > list(const std::string &thread_id, int limit=100) override
List checkpoints for a thread, ordered by timestamp (newest first).
size_t size() const
Get the total number of stored checkpoints (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 save(const Checkpoint &cp) override
Save a checkpoint.
Exception thrown from inside a node to trigger a dynamic breakpoint.
Graph engine type definitions: channels, edges, nodes, events, and control flow.
Serialized snapshot of graph execution state at a single super-step.
std::string thread_id
Conversation/session identifier.
static std::string generate_id()
Generate a new UUID v4 string.
int64_t step
Super-step number.
int64_t timestamp
Unix epoch milliseconds.
CheckpointPhase interrupt_phase
Phase at which this cp was produced.
std::map< std::string, std::set< std::string > > barrier_state
Per-barrier accumulator: each entry maps a declared barrier node to the set of upstreams that have si...
json channel_versions
Per-channel version counters.
std::string current_node
Node that was active at checkpoint time.
std::string parent_id
Previous checkpoint ID (for time-travel chain).
json metadata
User-defined metadata.
json channel_values
Serialized channel data.
std::uint32_t schema_version
Layout version of this record.
std::vector< std::string > next_nodes
Nodes to execute on resume.
std::string id
Unique checkpoint ID (UUID v4).
Successful node writes recorded within an in-progress super-step.
std::string task_id
Deterministic per-execution ID (survives replay).
std::string node_name
Node that produced these writes.
int64_t step
Super-step number this write belongs to.
json writes
Serialized ChannelWrite vector (json array of {channel, value}).
std::string task_path
Human-readable path, e.g. "s3:executor_2" or "s3:send[0]:searcher".
json command
Serialized optional Command, or null if the node didn't emit one.
json sends
Serialized Send vector (json array of {target_node, input}); empty if none.
int64_t timestamp
Unix epoch milliseconds at record time.