NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
checkpoint.h
Go to the documentation of this file.
1
9#pragma once
10
11#include <neograph/api.h>
14
15#include <asio/awaitable.hpp>
16
17#include <cstdint>
18
19#include <memory>
20#include <optional>
21#include <mutex>
22#include <map>
23#include <set>
24#include <vector>
25#include <unordered_set>
26#include <unordered_map>
27#include <string_view>
28#include <chrono>
29#include <functional>
30
31namespace neograph::graph {
32class NativeGraphCheckpoint;
33struct NodeResult;
34struct ChannelWrite;
35namespace detail {
36class ManagedBudgetJournalAccess;
39NEOGRAPH_API std::uint64_t blocking_checkpoint_hops() noexcept;
42NEOGRAPH_API asio::awaitable<void> run_on_blocking_pool(std::function<void()> work);
43} // namespace detail
44
50class NEOGRAPH_API ManagedBudgetDeadlineClockUnavailable final : public std::runtime_error,
52public:
54};
55
61class NEOGRAPH_API SynchronousCheckpointStoreUnavailable final : public std::runtime_error,
63public:
65};
66
67struct ManagedBudgetLeaseScope {
68 std::string owner_scope;
69 std::string thread_id;
70 std::string storage_thread_id;
71 std::string graph_identity;
72 std::uint64_t original_ceiling = 0;
73 std::optional<std::int64_t> original_deadline_ticks;
74 std::string deadline_clock_identity;
75};
76
78class NEOGRAPH_API OwnedManagedBudgetLease final {
79public:
80 const ManagedBudgetLeaseScope& scope() const noexcept;
81 const std::string& actor_id() const noexcept;
82 const std::string& bank_generation() const noexcept;
83 std::uint64_t revision() const noexcept;
84 std::string head_checkpoint_id() const;
85 std::string head_commitment() const;
86 const std::string& execution_thread_id() const noexcept;
87 const std::string& execution_storage_thread_id() const noexcept;
88private:
89 struct Impl;
90 explicit OwnedManagedBudgetLease(std::shared_ptr<Impl> impl);
91 std::shared_ptr<Impl> impl_;
92 friend class detail::ManagedBudgetJournalAccess;
93};
94
96class NEOGRAPH_API ManagedBudgetEffectReceipt final {
97public:
99 bool active() const noexcept;
100 const std::string& effect_id() const;
101 std::uint64_t claim_amount() const;
102 const std::string& request_digest() const;
103private:
104 struct Impl;
105 explicit ManagedBudgetEffectReceipt(std::shared_ptr<const Impl> impl);
106 std::shared_ptr<const Impl> impl_;
107 friend class detail::ManagedBudgetJournalAccess;
108};
109
123// Unsigned + fixed-width: schema versions are non-negative and a
124// platform-variable `int` width is wrong for a value persisted to
125// disk and round-tripped through JSON. Old `int` left the door open
126// to a `-1` sentinel value that wasn't documented anywhere.
127// v3 (#91): pending-write records may carry a "mode" field ("overwrite").
128// Absent means Reduce, so a v2 blob loads unchanged — same tolerant shape as the
129// v1 -> v2 barrier_state addition. Nothing rejects an older version on read; the
130// number records what the writer was capable of.
131// v4 (#235): child checkpoints may carry the cumulative subgraph write journal
132// in metadata. Standalone checkpoints remain readable as before; resuming a
133// captured subgraph from an older checkpoint fails explicitly because an
134// arbitrary custom reducer cannot reconstruct its historical deltas.
135constexpr std::uint32_t CHECKPOINT_SCHEMA_VERSION = 4;
136
143enum class CheckpointPhase {
144 Before,
145 After,
146 Completed,
148 Updated
149};
150
156NEOGRAPH_API const char* to_string(CheckpointPhase phase);
157
163NEOGRAPH_API CheckpointPhase parse_checkpoint_phase(std::string_view s);
164
174 std::string id;
175 std::string thread_id;
181 std::string parent_id;
182 std::string current_node;
187 std::vector<std::string> next_nodes;
188 CheckpointPhase interrupt_phase = CheckpointPhase::Completed;
198 std::map<std::string, std::set<std::string>> barrier_state;
199 json metadata;
201 std::shared_ptr<const NativeGraphCheckpoint> native_history;
202 std::shared_ptr<const std::vector<ChannelWrite>> native_subgraph_writes;
203 int64_t step;
204 int64_t timestamp;
211 std::uint32_t schema_version = CHECKPOINT_SCHEMA_VERSION;
212
217 static NEOGRAPH_API std::string generate_id();
218};
219
220NEOGRAPH_API std::string managed_budget_checkpoint_commitment(const Checkpoint& checkpoint);
221NEOGRAPH_API bool checkpoint_channel_blob_eligible(const json& channel);
222NEOGRAPH_API json checkpoint_storage_shape(const Checkpoint& checkpoint);
223NEOGRAPH_API void restore_checkpoint_storage_shape(Checkpoint& checkpoint, const json& shape,
224 const std::map<std::string, json>& blobs);
225
243 std::string task_id;
244 std::string task_path;
245 std::string node_name;
246 json writes;
247 json command;
248 json sends;
249 int64_t step;
250 int64_t timestamp;
251 std::shared_ptr<const NodeResult> native_result;
252};
253
255NEOGRAPH_API json checkpoint_storage_metadata(const Checkpoint& checkpoint);
256NEOGRAPH_API void restore_checkpoint_storage_envelope(Checkpoint& checkpoint);
257
265class NEOGRAPH_API CheckpointStoreCore {
266public:
267 virtual ~CheckpointStoreCore() = default;
268
269 virtual void save(const Checkpoint& cp) = 0;
270 virtual std::optional<Checkpoint> load_latest(const std::string& thread_id) = 0;
271 virtual std::optional<Checkpoint> load_by_id(const std::string& id) = 0;
272 virtual std::vector<Checkpoint> list(const std::string& thread_id,
273 int limit = 100) = 0;
274 virtual void delete_thread(const std::string& thread_id) = 0;
275
278 virtual bool requires_managed_budget(const std::string& thread_id);
279 virtual std::shared_ptr<OwnedManagedBudgetLease> acquire_managed_budget_lease(
280 const ManagedBudgetLeaseScope& scope, const std::string& expected_checkpoint_id,
281 const std::string& expected_checkpoint_commitment);
282 virtual ManagedBudgetEffectReceipt begin_managed_budget_effect(
283 const std::shared_ptr<OwnedManagedBudgetLease>& lease, const std::string& effect_id,
284 std::uint64_t exact_claim_amount, const std::string& prepared_request_digest);
285 virtual void settle_managed_budget_effect(const std::shared_ptr<OwnedManagedBudgetLease>& lease,
286 const ManagedBudgetEffectReceipt& effect, sp::runtime::Result genuine_outcome,
287 const UsageAccumulator::AuthoritySnapshot& authority);
288 virtual void publish_managed_budget_checkpoint(
289 const std::shared_ptr<OwnedManagedBudgetLease>& lease, const Checkpoint& checkpoint);
290 virtual void release_managed_budget_lease(const std::shared_ptr<OwnedManagedBudgetLease>& lease);
292 virtual bool retains_native_checkpoint() const noexcept { return false; }
293 virtual void publish_managed_budget_fork(
294 const Checkpoint& authenticated_source, const Checkpoint& genuine_shared_bank_fork);
295};
296
303class NEOGRAPH_API AsyncCheckpointStore {
304public:
305 virtual ~AsyncCheckpointStore() = default;
306
307 virtual asio::awaitable<void> save_async(const Checkpoint& cp) = 0;
308 virtual asio::awaitable<std::optional<Checkpoint>>
309 load_latest_async(const std::string& thread_id) = 0;
310 virtual asio::awaitable<std::optional<Checkpoint>>
311 load_by_id_async(const std::string& id) = 0;
312 virtual asio::awaitable<std::vector<Checkpoint>>
313 list_async(const std::string& thread_id, int limit = 100) = 0;
314 virtual asio::awaitable<void>
315 delete_thread_async(const std::string& thread_id) = 0;
316
317 virtual asio::awaitable<bool> requires_managed_budget_async(std::string thread_id);
318 virtual asio::awaitable<std::shared_ptr<OwnedManagedBudgetLease>> acquire_managed_budget_lease_async(
319 ManagedBudgetLeaseScope scope, std::string expected_checkpoint_id,
320 std::string expected_checkpoint_commitment);
321 virtual asio::awaitable<ManagedBudgetEffectReceipt> begin_managed_budget_effect_async(
322 std::shared_ptr<OwnedManagedBudgetLease> lease, std::string effect_id,
323 std::uint64_t exact_claim_amount, std::string prepared_request_digest);
324 virtual asio::awaitable<void> settle_managed_budget_effect_async(
325 std::shared_ptr<OwnedManagedBudgetLease> lease, ManagedBudgetEffectReceipt effect,
326 sp::runtime::Result genuine_outcome, UsageAccumulator::AuthoritySnapshot authority);
327 virtual asio::awaitable<void> publish_managed_budget_checkpoint_async(
328 std::shared_ptr<OwnedManagedBudgetLease> lease, Checkpoint checkpoint);
329 virtual asio::awaitable<void> release_managed_budget_lease_async(
330 std::shared_ptr<OwnedManagedBudgetLease> lease);
331 virtual bool retains_native_checkpoint() const noexcept { return false; }
332 virtual asio::awaitable<void> publish_managed_budget_fork_async(
333 Checkpoint authenticated_source, Checkpoint genuine_shared_bank_fork);
334};
335
340public:
341 virtual ~PendingWritesCheckpointStore() = default;
342
343 virtual void put_writes(const std::string& thread_id,
344 const std::string& parent_checkpoint_id,
345 const PendingWrite& write) = 0;
346 virtual std::vector<PendingWrite> get_writes(
347 const std::string& thread_id,
348 const std::string& parent_checkpoint_id) = 0;
349 virtual void clear_writes(const std::string& thread_id,
350 const std::string& parent_checkpoint_id) = 0;
351};
352
400class NEOGRAPH_API CheckpointStore {
401public:
402 virtual ~CheckpointStore() = default;
403
404 // ── Sync API ────────────────────────────────────────────────────────
405 //
406 // Legacy sync facade. Override sync operations or explicitly adapt a
407 // native AsyncCheckpointStore. Missing sync operations fail explicitly;
408 // async defaults offload sync-only backends to a bounded worker pool.
409
417 virtual void save(const Checkpoint& cp);
418
427 virtual std::optional<Checkpoint> load_latest(const std::string& thread_id);
428
434 virtual std::optional<Checkpoint> load_by_id(const std::string& id);
435
443 virtual std::vector<Checkpoint> list(const std::string& thread_id,
444 int limit = 100);
445
450 virtual void delete_thread(const std::string& thread_id);
451
452 // Async defaults offload the matching synchronous operation instead of
453 // blocking the caller's Asio executor. Async-native stores should override
454 // these methods to avoid the blocking pool entirely.
455
456 virtual asio::awaitable<void> save_async(const Checkpoint& cp);
457 virtual asio::awaitable<std::optional<Checkpoint>>
458 load_latest_async(const std::string& thread_id);
459 virtual asio::awaitable<std::optional<Checkpoint>>
460 load_by_id_async(const std::string& id);
461 virtual asio::awaitable<std::vector<Checkpoint>>
462 list_async(const std::string& thread_id, int limit = 100);
463 virtual asio::awaitable<void>
464 delete_thread_async(const std::string& thread_id);
465
466 // ── Pending writes (fine-grained progress log) ──────────────────────
467
483 virtual void put_writes(const std::string& /*thread_id*/,
484 const std::string& /*parent_checkpoint_id*/,
485 const PendingWrite& /*write*/) {}
486
497 virtual std::vector<PendingWrite> get_writes(
498 const std::string& /*thread_id*/,
499 const std::string& /*parent_checkpoint_id*/) { return {}; }
500
512 virtual void clear_writes(const std::string& /*thread_id*/,
513 const std::string& /*parent_checkpoint_id*/) {}
514
515 // Async peers for the pending-writes API. Each defaults to calling
516 // the matching sync method (which itself is a no-op for stores that
517 // don't override it), so existing custom stores keep working.
518
519 virtual asio::awaitable<void> put_writes_async(
520 const std::string& thread_id,
521 const std::string& parent_checkpoint_id,
522 const PendingWrite& write);
523 virtual asio::awaitable<std::vector<PendingWrite>> get_writes_async(
524 const std::string& thread_id,
525 const std::string& parent_checkpoint_id);
526 virtual asio::awaitable<void> clear_writes_async(
527 const std::string& thread_id,
528 const std::string& parent_checkpoint_id);
529
535 virtual bool requires_managed_budget(const std::string& thread_id);
536 virtual asio::awaitable<bool> requires_managed_budget_async(std::string thread_id);
537
538 virtual std::shared_ptr<OwnedManagedBudgetLease> acquire_managed_budget_lease(
539 const ManagedBudgetLeaseScope& scope, const std::string& expected_checkpoint_id,
540 const std::string& expected_checkpoint_commitment);
541 virtual asio::awaitable<std::shared_ptr<OwnedManagedBudgetLease>> acquire_managed_budget_lease_async(
542 ManagedBudgetLeaseScope scope, std::string expected_checkpoint_id,
543 std::string expected_checkpoint_commitment);
544 virtual ManagedBudgetEffectReceipt begin_managed_budget_effect(
545 const std::shared_ptr<OwnedManagedBudgetLease>& lease, const std::string& effect_id,
546 std::uint64_t exact_claim_amount, const std::string& prepared_request_digest);
547 virtual asio::awaitable<ManagedBudgetEffectReceipt> begin_managed_budget_effect_async(
548 std::shared_ptr<OwnedManagedBudgetLease> lease, std::string effect_id,
549 std::uint64_t exact_claim_amount, std::string prepared_request_digest);
550 virtual void settle_managed_budget_effect(const std::shared_ptr<OwnedManagedBudgetLease>& lease,
551 const ManagedBudgetEffectReceipt& effect, sp::runtime::Result genuine_outcome,
552 const UsageAccumulator::AuthoritySnapshot& authority);
553 virtual asio::awaitable<void> settle_managed_budget_effect_async(
554 std::shared_ptr<OwnedManagedBudgetLease> lease, ManagedBudgetEffectReceipt effect,
555 sp::runtime::Result genuine_outcome, UsageAccumulator::AuthoritySnapshot authority);
556 virtual void publish_managed_budget_checkpoint(
557 const std::shared_ptr<OwnedManagedBudgetLease>& lease, const Checkpoint& checkpoint);
558 virtual asio::awaitable<void> publish_managed_budget_checkpoint_async(
559 std::shared_ptr<OwnedManagedBudgetLease> lease, Checkpoint checkpoint);
560 virtual void release_managed_budget_lease(const std::shared_ptr<OwnedManagedBudgetLease>& lease);
561 virtual asio::awaitable<void> release_managed_budget_lease_async(
562 std::shared_ptr<OwnedManagedBudgetLease> lease);
564 virtual bool retains_native_checkpoint() const noexcept { return false; }
565 virtual void publish_managed_budget_fork(
566 const Checkpoint& authenticated_source, const Checkpoint& genuine_shared_bank_fork);
567 virtual asio::awaitable<void> publish_managed_budget_fork_async(
568 Checkpoint authenticated_source, Checkpoint genuine_shared_bank_fork);
569};
570
584NEOGRAPH_API std::shared_ptr<CheckpointStore>
585adapt_checkpoint_store(std::shared_ptr<CheckpointStoreCore> core);
586
592NEOGRAPH_API std::shared_ptr<CheckpointStore>
593adapt_async_checkpoint_store(std::shared_ptr<AsyncCheckpointStore> backend);
594
619class NEOGRAPH_API InMemoryCheckpointStore : public CheckpointStore {
620public:
621 void save(const Checkpoint& cp) override;
622 std::optional<Checkpoint> load_latest(const std::string& thread_id) override;
623 std::optional<Checkpoint> load_by_id(const std::string& id) override;
624 std::vector<Checkpoint> list(const std::string& thread_id,
625 int limit = 100) override;
626 void delete_thread(const std::string& thread_id) override;
627
628 // The exact in-memory concrete type has no I/O boundary, so its async
629 // operations stay on the caller executor instead of paying a legacy
630 // blocking-pool handoff for each mutex-protected map operation. Derived
631 // stores retain the base fallback unless they explicitly override async.
632 asio::awaitable<void> save_async(const Checkpoint& cp) override;
633 asio::awaitable<std::optional<Checkpoint>>
634 load_latest_async(const std::string& thread_id) override;
635 asio::awaitable<std::optional<Checkpoint>>
636 load_by_id_async(const std::string& id) override;
637 asio::awaitable<std::vector<Checkpoint>>
638 list_async(const std::string& thread_id, int limit = 100) override;
639 asio::awaitable<void>
640 delete_thread_async(const std::string& thread_id) override;
641
642 void put_writes(const std::string& thread_id,
643 const std::string& parent_checkpoint_id,
644 const PendingWrite& write) override;
645 std::vector<PendingWrite> get_writes(
646 const std::string& thread_id,
647 const std::string& parent_checkpoint_id) override;
648 void clear_writes(const std::string& thread_id,
649 const std::string& parent_checkpoint_id) override;
650
651 asio::awaitable<void> put_writes_async(
652 const std::string& thread_id,
653 const std::string& parent_checkpoint_id,
654 const PendingWrite& write) override;
655 asio::awaitable<std::vector<PendingWrite>> get_writes_async(
656 const std::string& thread_id,
657 const std::string& parent_checkpoint_id) override;
658 asio::awaitable<void> clear_writes_async(
659 const std::string& thread_id,
660 const std::string& parent_checkpoint_id) override;
661
662 bool requires_managed_budget(const std::string& thread_id) override;
663 asio::awaitable<bool> requires_managed_budget_async(std::string thread_id) override;
664 std::shared_ptr<OwnedManagedBudgetLease> acquire_managed_budget_lease(
665 const ManagedBudgetLeaseScope& scope, const std::string& expected_checkpoint_id,
666 const std::string& expected_checkpoint_commitment) override;
667 ManagedBudgetEffectReceipt begin_managed_budget_effect(
668 const std::shared_ptr<OwnedManagedBudgetLease>& lease, const std::string& effect_id,
669 std::uint64_t exact_claim_amount, const std::string& prepared_request_digest) override;
670 void settle_managed_budget_effect(const std::shared_ptr<OwnedManagedBudgetLease>& lease,
671 const ManagedBudgetEffectReceipt& effect, sp::runtime::Result genuine_outcome,
672 const UsageAccumulator::AuthoritySnapshot& authority) override;
673 void publish_managed_budget_checkpoint(
674 const std::shared_ptr<OwnedManagedBudgetLease>& lease, const Checkpoint& checkpoint) override;
675 void release_managed_budget_lease(const std::shared_ptr<OwnedManagedBudgetLease>& lease) override;
676 bool retains_native_checkpoint() const noexcept override { return true; }
677 void publish_managed_budget_fork(
678 const Checkpoint& authenticated_source, const Checkpoint& genuine_shared_bank_fork) override;
679
680 // The managed-budget operations run on the calling thread, as the checkpoint operations above do: this store
681 // is memory, so there is nothing to wait for and no worker thread to hand them to. A single-thread build has
682 // none, and the engine runs a budgeted graph on this store there.
683 asio::awaitable<std::shared_ptr<OwnedManagedBudgetLease>> acquire_managed_budget_lease_async(
684 ManagedBudgetLeaseScope scope, std::string expected_checkpoint_id,
685 std::string expected_checkpoint_commitment) override;
686 asio::awaitable<ManagedBudgetEffectReceipt> begin_managed_budget_effect_async(
687 std::shared_ptr<OwnedManagedBudgetLease> lease, std::string effect_id,
688 std::uint64_t exact_claim_amount, std::string prepared_request_digest) override;
689 asio::awaitable<void> settle_managed_budget_effect_async(
690 std::shared_ptr<OwnedManagedBudgetLease> lease, ManagedBudgetEffectReceipt effect,
691 sp::runtime::Result genuine_outcome, UsageAccumulator::AuthoritySnapshot authority) override;
692 asio::awaitable<void> publish_managed_budget_checkpoint_async(
693 std::shared_ptr<OwnedManagedBudgetLease> lease, Checkpoint checkpoint) override;
694 asio::awaitable<void> release_managed_budget_lease_async(
695 std::shared_ptr<OwnedManagedBudgetLease> lease) override;
696 asio::awaitable<void> publish_managed_budget_fork_async(
697 Checkpoint authenticated_source, Checkpoint genuine_shared_bank_fork) override;
698
703 size_t size() const;
704
711 size_t blob_count() const;
712
716 size_t pending_writes_count(const std::string& thread_id,
717 const std::string& parent_checkpoint_id) const;
718
719private:
725 Checkpoint split_blobs_locked(Checkpoint cp);
726
733 Checkpoint join_blobs_locked(Checkpoint cp) const;
734
735 mutable std::mutex mutex_;
736 std::map<std::string, std::vector<Checkpoint>> by_thread_;
737 std::map<std::string, Checkpoint> by_id_;
741 std::map<std::tuple<std::string, std::string, uint64_t>, json> blobs_;
742 // Keyed by (thread_id, parent_checkpoint_id) → ordered list of pending writes
743 std::map<std::pair<std::string, std::string>, std::vector<PendingWrite>> pending_;
744 std::unordered_set<std::string> managed_budget_obligations_;
745 std::unordered_map<std::string, json> managed_budget_journals_;
746 std::map<std::tuple<std::string, std::string, std::string>, json> managed_budget_effects_;
747 std::map<std::tuple<std::string, std::string, std::string>, sp::runtime::Result> managed_budget_results_;
748 struct ManagedBudgetBranchHead {
749 std::string financial_storage_thread_id;
750 std::string execution_thread_id;
751 std::string checkpoint_id;
752 std::string commitment;
753 std::shared_ptr<const NativeGraphCheckpoint> native_history;
754 bool valid = true;
755 };
756 const ManagedBudgetBranchHead& authenticate_managed_budget_branch_locked(
757 const Checkpoint& source, const std::string& commitment) const;
758 void validate_managed_budget_execution_locked(
759 const std::shared_ptr<OwnedManagedBudgetLease>& lease, const json& head) const;
760 std::unordered_map<std::string, ManagedBudgetBranchHead> managed_budget_branch_heads_;
761};
762
763} // namespace neograph::graph
NEOGRAPH_API export/import macro for shared-library builds.
CheckpointPhase
Phase at which a Checkpoint was produced.
Definition checkpoint.h:143
@ 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 std::uint64_t blocking_checkpoint_hops() noexcept
How many operations of a synchronous checkpoint store have been handed to the pool of worker threads ...
NEOGRAPH_API std::shared_ptr< CheckpointStore > adapt_async_checkpoint_store(std::shared_ptr< AsyncCheckpointStore > backend)
Explicit sync facade for an async-native backend.
NEOGRAPH_API json checkpoint_storage_metadata(const Checkpoint &checkpoint)
Preserve the complete durable provider-state envelope without changing store schemas.
NEOGRAPH_API std::shared_ptr< CheckpointStore > adapt_checkpoint_store(std::shared_ptr< CheckpointStoreCore > core)
Adapt split checkpoint capabilities to the legacy engine contract.
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.
Definition checkpoint.h:135
Canonical coroutine contract for a native async backend.
Definition checkpoint.h:303
Mandatory synchronous operations for a sync-only backend.
Definition checkpoint.h:265
virtual bool requires_managed_budget(const std::string &thread_id)
A persistent denial obligation, never authority to spend or restore.
virtual bool retains_native_checkpoint() const noexcept
Storage retention only; never currency or native replay authority.
Definition checkpoint.h:292
Abstract interface for checkpoint persistence backends.
Definition checkpoint.h:400
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...
Definition checkpoint.h:512
virtual std::vector< PendingWrite > get_writes(const std::string &, const std::string &)
Load all pending writes attached to a parent checkpoint.
Definition checkpoint.h:497
virtual bool retains_native_checkpoint() const noexcept
Describes real local C++ custody, not a financial admission/grant.
Definition checkpoint.h:564
virtual std::optional< Checkpoint > load_latest(const std::string &thread_id)
Load the most recently saved checkpoint for a thread.
virtual bool requires_managed_budget(const std::string &thread_id)
Whether this trusted checkpoint namespace/thread has ever held an active standalone managed bank.
virtual void put_writes(const std::string &, const std::string &, const PendingWrite &)
Record a successful node execution within an in-progress super-step.
Definition checkpoint.h:483
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, most recently saved first, one entry per ID; the first entry is load_l...
Marks an exception type as a configuration or definition verdict.
In-memory checkpoint store for testing and single-process use.
Definition checkpoint.h:619
bool retains_native_checkpoint() const noexcept override
Describes real local C++ custody, not a financial admission/grant.
Definition checkpoint.h:676
bool requires_managed_budget(const std::string &thread_id) override
Whether this trusted checkpoint namespace/thread has ever held an active standalone managed bank.
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 recently saved 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, most recently saved first, one entry per ID; the first entry is load_l...
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.
A managed model-token budget with a deadline binds the deadline to the clock it counts on,...
Definition checkpoint.h:51
Actual write-ahead claim, bound to one original generation and owned actor.
Definition checkpoint.h:96
Exception thrown from inside a node to trigger a dynamic breakpoint.
Definition types.h:200
Store-issued ownership; JSON or an archived observation cannot create it.
Definition checkpoint.h:78
Optional fine-grained pending-writes capability.
Definition checkpoint.h:339
A checkpoint store that is not asynchronous (it implements CheckpointStoreCore, or a CheckpointStore ...
Definition checkpoint.h:62
Marker for exceptions that are configuration or definition verdicts (#364).
Graph engine type definitions: channels, edges, nodes, events, and control flow.
Serialized snapshot of graph execution state at a single super-step.
Definition checkpoint.h:173
std::string thread_id
Conversation/session identifier.
Definition checkpoint.h:175
int64_t step
Super-step number.
Definition checkpoint.h:203
int64_t timestamp
Unix epoch milliseconds.
Definition checkpoint.h:204
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...
Definition checkpoint.h:198
json channel_versions
The engine does not set this field.
Definition checkpoint.h:180
std::string current_node
Node that was active at checkpoint time.
Definition checkpoint.h:182
std::string parent_id
Previous checkpoint ID (for time-travel chain).
Definition checkpoint.h:181
json metadata
User-defined metadata.
Definition checkpoint.h:199
json channel_values
Serialized channel data.
Definition checkpoint.h:176
static NEOGRAPH_API std::string generate_id()
Generate a new UUID v4 string.
std::vector< std::string > next_nodes
Nodes to execute on resume.
Definition checkpoint.h:187
std::shared_ptr< const NativeGraphCheckpoint > native_history
Original trusted C++ custody only; never reconstructed from checkpoint JSON.
Definition checkpoint.h:201
std::string id
Unique checkpoint ID (UUID v4).
Definition checkpoint.h:174
Successful node writes recorded within an in-progress super-step.
Definition checkpoint.h:242
std::string task_id
Deterministic per-execution ID (survives replay).
Definition checkpoint.h:243
std::string node_name
Node that produced these writes.
Definition checkpoint.h:245
int64_t step
Super-step number this write belongs to.
Definition checkpoint.h:249
json writes
Serialized ChannelWrite vector (json array of {channel, value}).
Definition checkpoint.h:246
std::string task_path
Human-readable path, e.g. "s3:executor_2" or "s3:send[0]:searcher".
Definition checkpoint.h:244
json command
Serialized optional Command, or null if the node didn't emit one.
Definition checkpoint.h:247
json sends
Serialized Send vector (json array of {target_node, input}); empty if none.
Definition checkpoint.h:248
int64_t timestamp
Unix epoch milliseconds at record time.
Definition checkpoint.h:250