NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
neograph::graph::CheckpointCoordinator Class Reference

Per-run coordinator for checkpoint lifecycle operations. More...

#include <coordinator.h>

Public Member Functions

 CheckpointCoordinator (std::shared_ptr< CheckpointStore > store, std::string thread_id, std::shared_ptr<::neograph::HookRuntime > hook_runtime={}, CheckpointHookContext hook_context={}, std::shared_ptr< sp::NativeArchive > native_archive={}, std::shared_ptr< detail::SubgraphWriteJournal > native_journal={})
 
void clear_pending_writes (const std::string &parent_cp_id) const
 Drop the pending-writes log for a parent cp after its super-step has been successfully committed.
 
asio::awaitable< Checkpoint > commit_super_step_async (const GraphState &state, const std::string &current_node, const std::vector< std::string > &next_nodes, int step, const std::string &parent_id, const BarrierState &barrier_state, const json &metadata=json()) const
 Persist one completed super-step, settle the prior pending-write bucket, and return the exact deeply owned checkpoint only after both succeed.
 
bool enabled () const noexcept
 
ResumeContext load_for_resume () const
 Load the latest checkpoint + all pending writes attached to it.
 
asio::awaitable< ResumeContext > load_for_resume_async () const
 Async peer of load_for_resume (Sem 3.7.5).
 
asio::awaitable< ResumeContext > load_for_resume_by_id_async (std::string checkpoint_id) const
 Load one exact checkpoint and its pending writes by ID.
 
void record_pending_write (const std::string &parent_cp_id, const std::string &task_id, const std::string &task_path, const std::string &node_name, const NodeResult &nr, int step) const
 Durably record a completed node's writes under parent_cp_id.
 
bool records_pending_writes (const std::string &parent_cp_id) const noexcept
 True when record_pending_write[_async] would store something: the coordinator is enabled and the step is anchored to a committed parent checkpoint.
 
std::string save_super_step (const GraphState &state, const std::string &current_node, const std::vector< std::string > &next_nodes, CheckpointPhase phase, int step, const std::string &parent_id, const BarrierState &barrier_state) const
 Write a super-step snapshot.
 
asio::awaitable< std::string > save_super_step_async (const GraphState &state, const std::string &current_node, const std::vector< std::string > &next_nodes, CheckpointPhase phase, int step, const std::string &parent_id, const BarrierState &barrier_state, const json &metadata) const
 Internal extension used by subgraph execution to persist its cumulative write journal without changing CheckpointCoordinator's object layout.
 

Detailed Description

Per-run coordinator for checkpoint lifecycle operations.

Value type; construct one at the top of execute_graph and let it go out of scope when the run ends. Holds no state beyond the store handle + thread_id.

Definition at line 121 of file coordinator.h.

Constructor & Destructor Documentation

◆ CheckpointCoordinator()

neograph::graph::CheckpointCoordinator::CheckpointCoordinator ( std::shared_ptr< CheckpointStore >  store,
std::string  thread_id,
std::shared_ptr<::neograph::HookRuntime >  hook_runtime = {},
CheckpointHookContext  hook_context = {},
std::shared_ptr< sp::NativeArchive >  native_archive = {},
std::shared_ptr< detail::SubgraphWriteJournal >  native_journal = {} 
)
Parameters
storeCheckpoint store (may be nullptr — everything is a no-op).
thread_idPer-run thread identifier (may be empty — same effect).

Member Function Documentation

◆ clear_pending_writes()

void neograph::graph::CheckpointCoordinator::clear_pending_writes ( const std::string &  parent_cp_id) const

Drop the pending-writes log for a parent cp after its super-step has been successfully committed.

Ordering matters: callers must have called save_super_step for a fresh cp BEFORE invoking this. Clearing before saving would lose data if a crash landed between the two calls.

◆ enabled()

bool neograph::graph::CheckpointCoordinator::enabled ( ) const
inlinenoexcept
Returns
True iff a non-null store is wired up AND thread_id is non-empty.

Definition at line 135 of file coordinator.h.

◆ load_for_resume()

ResumeContext neograph::graph::CheckpointCoordinator::load_for_resume ( ) const

Load the latest checkpoint + all pending writes attached to it.

Computes the phase-adjusted start step: before / node_interrupt re-enter AT cp.step (the node hadn't finished yet), after / completed advance by +1 (routing already happened).

◆ load_for_resume_async()

asio::awaitable< ResumeContext > neograph::graph::CheckpointCoordinator::load_for_resume_async ( ) const

Async peer of load_for_resume (Sem 3.7.5).

Uses load_latest_async + get_writes_async on the store so the resume path doesn't block the io_context's worker.

◆ load_for_resume_by_id_async()

asio::awaitable< ResumeContext > neograph::graph::CheckpointCoordinator::load_for_resume_by_id_async ( std::string  checkpoint_id) const

Load one exact checkpoint and its pending writes by ID.

Unlike load_for_resume_async(), this never consults the latest checkpoint. A found checkpoint must belong to this coordinator's thread; a mismatch is rejected before a ResumeContext is returned.

◆ record_pending_write()

void neograph::graph::CheckpointCoordinator::record_pending_write ( const std::string &  parent_cp_id,
const std::string &  task_id,
const std::string &  task_path,
const std::string &  node_name,
const NodeResult &  nr,
int  step 
) const

Durably record a completed node's writes under parent_cp_id.

Must be called BEFORE the writes are applied to GraphState — a crash between record and apply leaves a replayable log that makes resume idempotent.

◆ records_pending_writes()

bool neograph::graph::CheckpointCoordinator::records_pending_writes ( const std::string &  parent_cp_id) const
inlinenoexcept

True when record_pending_write[_async] would store something: the coordinator is enabled and the step is anchored to a committed parent checkpoint.

Hot callers test this first, so a run without checkpointing does not build a coroutine frame per node just to return.

Definition at line 143 of file coordinator.h.

◆ save_super_step()

std::string neograph::graph::CheckpointCoordinator::save_super_step ( const GraphState &  state,
const std::string &  current_node,
const std::vector< std::string > &  next_nodes,
CheckpointPhase  phase,
int  step,
const std::string &  parent_id,
const BarrierState &  barrier_state 
) const

Write a super-step snapshot.

Returns
The new checkpoint id, or empty string when disabled.

The documentation for this class was generated from the following file: