NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
replacement.h
Go to the documentation of this file.
1
5#pragma once
6
7#include <neograph/api.h>
9
10#include <asio/awaitable.hpp>
11#include <cstdint>
12#include <memory>
13#include <string>
14#include <string_view>
15
16namespace neograph::program {
17
18class ProgramJavaScriptCommandJournalEntry;
19class ProgramHandle;
20class ProgramRuntime;
21class ProgramRunGeneration;
22class ProgramRunLineage;
23class ProgramRunRecord;
24
27 std::string source_run_id;
28 std::string source_journal_head;
29 std::string command_coordinate_id;
30 std::string command_entry_id;
31
32 bool operator==(const ExactProgramHandoffReference&) const = default;
33};
34
38 json value;
39};
40
45class NEOGRAPH_PROGRAM_API ProgramHandoff final {
46public:
47 ProgramHandoff(const ProgramHandoff&) = delete;
48 ProgramHandoff& operator=(const ProgramHandoff&) = delete;
49 ProgramHandoff(ProgramHandoff&& other) noexcept;
50 ProgramHandoff& operator=(ProgramHandoff&& other) noexcept;
52
53 const ExactProgramHandoffReference& reference() const;
54 json value() const;
55 asio::awaitable<ExactProgramHandoff> wait_async() const;
56 explicit operator bool() const noexcept;
57
58private:
59 struct Impl;
60 explicit ProgramHandoff(std::shared_ptr<Impl> impl) noexcept;
61 static asio::awaitable<ExactProgramHandoff> wait_async_with_impl(
62 std::shared_ptr<Impl> impl);
63 void consume() noexcept;
64
65 std::shared_ptr<Impl> impl_;
66
67 friend class ProgramHandle;
68 friend class ProgramRuntime;
69};
70
71struct ProgramReplacementReceiptData {
72 std::string owner_scope;
73 std::string lineage_id;
74 std::uint64_t source_generation = 0;
75 std::string source_generation_id;
76 std::string source_lineage_head_id;
77 std::string source_run_id;
78 std::string source_run_record_id;
79 std::string source_journal_head;
80 std::string source_program_version_id;
81 std::string source_bundle_id;
82 std::string checkpoint_coordinate_id;
83 std::string checkpoint_entry_id;
84 std::string handoff_value_identity;
85 std::uint64_t target_generation = 0;
86 std::string target_run_id;
87 std::string target_program_version_id;
88 std::string target_bundle_id;
89 std::string target_input_identity;
90 std::string target_invocation_id;
91 std::string target_binding_fingerprint;
92 std::string target_initial_run_record_id;
93 std::string target_initial_journal_head;
94};
95
96NEOGRAPH_PROGRAM_API std::string program_replacement_handoff_identity(const json& value);
97NEOGRAPH_PROGRAM_API std::string program_replacement_input_identity(const json& value);
98
100class NEOGRAPH_PROGRAM_API ProgramReplacementReceipt final {
101public:
102 static constexpr std::uint32_t STORAGE_SCHEMA_VERSION = 1;
103
104 explicit ProgramReplacementReceipt(ProgramReplacementReceiptData data);
105 static ProgramReplacementReceipt parse(std::string_view stored_bytes);
106
107 const std::string& id() const noexcept;
108 const std::string& owner_scope() const noexcept;
109 const std::string& lineage_id() const noexcept;
110 std::uint64_t source_generation() const noexcept;
111 const std::string& source_generation_id() const noexcept;
112 const std::string& source_lineage_head_id() const noexcept;
113 const std::string& source_run_id() const noexcept;
114 const std::string& source_run_record_id() const noexcept;
115 const std::string& source_journal_head() const noexcept;
116 const std::string& source_program_version_id() const noexcept;
117 const std::string& source_bundle_id() const noexcept;
118 const std::string& checkpoint_coordinate_id() const noexcept;
119 const std::string& checkpoint_entry_id() const noexcept;
120 const std::string& handoff_value_identity() const noexcept;
121 std::uint64_t target_generation() const noexcept;
122 const std::string& target_run_id() const noexcept;
123 const std::string& target_program_version_id() const noexcept;
124 const std::string& target_bundle_id() const noexcept;
125 const std::string& target_input_identity() const noexcept;
126 const std::string& target_invocation_id() const noexcept;
127 const std::string& target_binding_fingerprint() const noexcept;
128 const std::string& target_initial_run_record_id() const noexcept;
129 const std::string& target_initial_journal_head() const noexcept;
130
131 bool matches_handoff(const json& value) const;
132 bool matches_target_input(const json& value) const;
133 std::string serialize_canonical() const;
134
135private:
136 struct Impl;
137 explicit ProgramReplacementReceipt(std::shared_ptr<const Impl> impl);
138 std::shared_ptr<const Impl> impl_;
139};
140
143 const ProgramRunGeneration& predecessor,
144 const ProgramRunLineage& previous_lineage,
145 const ProgramRunRecord& source,
146 const ProgramJavaScriptCommandJournalEntry& checkpoint,
147 const ProgramRunGeneration& successor,
148 const ProgramRunLineage& next_lineage,
149 const ProgramRunRecord& target) noexcept;
150
152NEOGRAPH_PROGRAM_API RunBudget program_replacement_remaining_budget(
153 const ProgramRunRecord& source,
154 const ProgramRunLineage& source_lineage,
155 std::int64_t transition_time_ms) noexcept;
156
157} // namespace neograph::program
NEOGRAPH_API export/import macro for shared-library builds.
Move-only host lease holding a source generator at an exact durable checkpoint.
Definition replacement.h:45
Immutable, content-addressed command-journal value.
Immutable evidence of one host-admitted same-lineage generation transition.
Immutable identity of one admitted topology generation in a run lineage.
Definition lineage.h:102
Immutable content-addressed head of one stable run lineage.
Definition lineage.h:150
Deep-owned, content-addressed run snapshot used for reconnect and CAS publication.
Definition run_record.h:119
NEOGRAPH_PROGRAM_API RunBudget program_replacement_remaining_budget(const ProgramRunRecord &source, const ProgramRunLineage &source_lineage, std::int64_t transition_time_ms) noexcept
Charges elapsed wall time before a successor receives the lineage remainder.
NEOGRAPH_PROGRAM_API bool is_valid_program_replacement_transition(const ProgramRunGeneration &predecessor, const ProgramRunLineage &previous_lineage, const ProgramRunRecord &source, const ProgramJavaScriptCommandJournalEntry &checkpoint, const ProgramRunGeneration &successor, const ProgramRunLineage &next_lineage, const ProgramRunRecord &target) noexcept
Shared fail-closed validator used by every atomic transition backend.
Immutable outcome of one Program run attempt.
Exact completed JavaScript checkpoint coordinate selected by the host.
Definition replacement.h:26
An exact durable handoff reference together with its deeply owned value.
Definition replacement.h:36