|
NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
|
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 ¤t_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 ¤t_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 ¤t_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. | |
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.
| 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 = {} |
||
| ) |
| store | Checkpoint store (may be nullptr — everything is a no-op). |
| thread_id | Per-run thread identifier (may be empty — same effect). |
| 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.
|
inlinenoexcept |
Definition at line 135 of file coordinator.h.
| 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).
| 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.
| 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.
| 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.
|
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.
| 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.