NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
catalog.h
Go to the documentation of this file.
1
5#pragma once
6
14#include <neograph/tool_set.h>
15
16#include <asio/awaitable.hpp>
17
18#include <functional>
19#include <cstddef>
20#include <memory>
21#include <optional>
22#include <stdexcept>
23#include <string>
24#include <string_view>
25#include <vector>
26
27namespace neograph::program {
28
29namespace detail {
30class CatalogRuntimeAccess;
31struct MaterializedProgram;
32}
33
34class ProgramStore;
35class RecordedBindingSet;
36struct RecordedCapabilityMaterialization;
37struct ProgramEvent;
38
39struct ProgramAdmission {
40 std::string owner_scope;
41 AdmissionProfile profile;
42 PolicySnapshot policy;
43 std::vector<DependencyReceipt> dependency_receipts;
44};
45
48class NEOGRAPH_PROGRAM_API ProgramAdmissionError final : public std::runtime_error,
50public:
51 explicit ProgramAdmissionError(std::vector<Diagnostic> diagnostics);
52
53 const std::vector<Diagnostic>& diagnostics() const noexcept;
54
55private:
56 std::vector<Diagnostic> diagnostics_;
57};
58
67class NEOGRAPH_PROGRAM_API EngineGenerationCache {
68public:
71 EngineGenerationCache& operator=(EngineGenerationCache&&) noexcept;
73 EngineGenerationCache& operator=(const EngineGenerationCache&) = delete;
75
76private:
77 struct Impl;
78 std::unique_ptr<Impl> impl_;
79
80 friend class ProgramCatalog;
81};
82
91 graph::NodeContext node_context;
92 ToolSet tools;
93 std::vector<CapabilityBindingReceipt> receipts;
94};
95
96using CatalogCapabilityBinder =
97 std::function<CatalogCapabilityBinding(const std::vector<ExecutableIdentity>&)>;
98
99struct CatalogConfig {
100 std::shared_ptr<ProgramStore> program_store;
101 RegistrySnapshot registry;
102 std::shared_ptr<EngineGenerationCache> engines;
103 std::string compiler_build_id;
104 CatalogCapabilityBinder capability_binder;
105 std::size_t worker_count = 1;
107 std::shared_ptr<const ModuleStore> module_store;
114 std::string host_identity;
122 std::string materialization_context_identity;
129 std::function<RecordedCapabilityMaterialization(const ProgramVersion&, const std::vector<ProgramEvent>&)>
130 recorded_capability_binder;
138 graph::FailureTextRedactor failure_text_redactor;
139};
140
141class NEOGRAPH_PROGRAM_API ProgramCatalog {
142public:
143 explicit ProgramCatalog(CatalogConfig config);
144 ProgramCatalog(ProgramCatalog&&) noexcept;
145 ProgramCatalog& operator=(ProgramCatalog&&) noexcept;
146 ProgramCatalog(const ProgramCatalog&) = delete;
147 ProgramCatalog& operator=(const ProgramCatalog&) = delete;
148 ~ProgramCatalog();
149
150 ProgramVersion admit(const ProgramBundle& bundle, ProgramAdmission admission);
155 ProgramVersion admit_composed(const ProgramBundle& bundle,
156 ProgramAdmission admission,
157 const ProgramComposition& composition);
158 std::optional<ProgramVersion> find_version(std::string_view id) const;
159 std::optional<ProgramVersion> find_version(std::string_view owner_scope,
160 std::string_view id) const;
161 std::optional<ProgramVersion> resolve_version(std::string_view owner_scope,
162 std::string_view id);
163 std::optional<ProgramVersion> resolve_version_with_binding(
164 std::string_view owner_scope, std::string_view id, CatalogCapabilityBinding binding);
165
167 MigrationPlan plan_migration(std::string_view owner_scope,
168 std::string_view source_version_id,
169 std::string_view target_version_id) const;
171 ProgramActivationResult activate(std::string_view owner_scope,
172 std::string_view version_id,
173 std::uint64_t expected_generation);
175 ProgramActivationResult rollback(std::string_view owner_scope,
176 std::string_view version_id,
177 std::uint64_t expected_generation);
178 std::optional<ProgramActivation>
179 activation(std::string_view owner_scope) const;
181 std::optional<ProgramActivationBinding>
182 active_binding(std::string_view owner_scope) const;
183 ProgramRetentionReport collect_retention(
184 std::string_view owner_scope,
185 const std::vector<std::string>& pinned_version_ids);
186
194 asio::awaitable<ProgramVersion> admit_async(ProgramBundle bundle, ProgramAdmission admission);
195 asio::awaitable<ProgramVersion> admit_composed_async(ProgramBundle bundle,
196 ProgramAdmission admission,
197 ProgramComposition composition);
198 asio::awaitable<std::optional<ProgramVersion>> find_version_async(std::string id) const;
199 asio::awaitable<std::optional<ProgramVersion>> find_version_async(std::string owner_scope,
200 std::string id) const;
201 asio::awaitable<std::optional<ProgramVersion>> resolve_version_async(std::string owner_scope,
202 std::string id);
203 asio::awaitable<std::optional<ProgramVersion>> resolve_version_with_binding_async(
204 std::string owner_scope, std::string id, CatalogCapabilityBinding binding);
205 asio::awaitable<MigrationPlan> plan_migration_async(std::string owner_scope,
206 std::string source_version_id,
207 std::string target_version_id) const;
208 asio::awaitable<ProgramActivationResult> activate_async(std::string owner_scope,
209 std::string version_id,
210 std::uint64_t expected_generation);
211 asio::awaitable<ProgramActivationResult> rollback_async(std::string owner_scope,
212 std::string version_id,
213 std::uint64_t expected_generation);
214 asio::awaitable<std::optional<ProgramActivation>> activation_async(std::string owner_scope) const;
215 asio::awaitable<std::optional<ProgramActivationBinding>> active_binding_async(
216 std::string owner_scope) const;
219 bool completes_inline() const noexcept;
220 asio::awaitable<ProgramRetentionReport> collect_retention_async(
221 std::string owner_scope, std::vector<std::string> pinned_version_ids);
222
223private:
224 // The bodies behind the public operations; each is awaited by the awaitable form and run to completion by the
225 // synchronous one. Arguments are by value so that nothing dangles across a suspension.
226 asio::awaitable<ProgramVersion> materialize_async(
227 ProgramBundle bundle, ProgramAdmission admission,
228 std::optional<CatalogCapabilityBinding> supplied_binding,
229 std::optional<ProgramVersion> expected_version, bool publish,
230 ExecutionGuarantee effective_execution_guarantee,
231 std::shared_ptr<const detail::MaterializedProgram>* isolated_materialization = nullptr);
232 asio::awaitable<std::optional<ProgramVersion>> resolve_version_impl_async(
233 std::string owner_scope, std::string id,
234 std::optional<CatalogCapabilityBinding> supplied_binding,
235 std::shared_ptr<const detail::MaterializedProgram>* isolated_materialization = nullptr);
236
237 struct Impl;
238 std::unique_ptr<Impl> impl_;
239
240 friend class detail::CatalogRuntimeAccess;
241};
242
243} // namespace neograph::program
Owner-scoped activation records for immutable Program versions.
Immutable Program admission and policy snapshots.
Copyable owner of a fixed collection of tools.
Definition tool_set.h:21
Marks an exception type as a configuration or definition verdict.
Process-local cache of fully linked Core generations.
Definition catalog.h:67
Also a graph::ConfigurationFailure (#364): inside a Core node it is NG.ConfigError,...
Definition catalog.h:49
Marker for exceptions that are configuration or definition verdicts (#364).
Graph engine type definitions: channels, edges, nodes, events, and control flow.
std::function< std::string(const NodeFailure &failure)> FailureTextRedactor
Decides the free text a failure record may carry (#364).
Definition types.h:592
Explicit compatibility plans between admitted Program versions.
Immutable, owner-scoped Program modules and bounded child composition.
Atomic storage of admitted Program bundles and versions.
Dependency injection context passed to nodes during construction.
Definition types.h:753
Exact host-resource receipt returned by the Catalog capability binder.
Definition catalog.h:90
Constructed only by the Catalog's trusted captured-capability registration.
Definition replay.h:109