NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
bundle.h
Go to the documentation of this file.
1
5#pragma once
6
10
11#include <cstdint>
12#include <memory>
13#include <optional>
14#include <string>
15#include <string_view>
16#include <vector>
17
18namespace neograph::program {
19
20namespace detail {
21class ProgramBundleAccess;
22}
23
29enum class ExecutionGuarantee : std::uint8_t {
30 Strict,
31 Recorded,
32 Unmanaged,
33};
34
35NEOGRAPH_PROGRAM_API std::string_view to_string(ExecutionGuarantee guarantee) noexcept;
36NEOGRAPH_PROGRAM_API ExecutionGuarantee execution_guarantee_from_string(std::string_view value);
37NEOGRAPH_PROGRAM_API std::uint8_t execution_guarantee_rank(ExecutionGuarantee guarantee) noexcept;
38
39enum class ExecutableKind { Node, Reducer, Condition, Provider, Tool, Imported };
40
41NEOGRAPH_PROGRAM_API std::string_view to_string(ExecutableKind kind) noexcept;
42NEOGRAPH_PROGRAM_API ExecutableKind executable_kind_from_string(std::string_view value);
43
44struct ExecutableIdentity {
45 ExecutableKind kind = ExecutableKind::Node;
46 std::string name;
47 std::string semantic_version;
48 std::string implementation_digest;
49
50 bool operator==(const ExecutableIdentity&) const = default;
51};
52
53struct ContractRecord {
54 std::uint32_t schema_version = 1;
55 json schema = json::object();
56};
57
65NEOGRAPH_PROGRAM_API void validate_contract_schema(const ContractRecord& contract,
66 std::string_view path = "$schema");
67NEOGRAPH_PROGRAM_API void validate_contract_value(
68 const json& value,
69 const ContractRecord& contract,
70 std::string_view subject = "Program contract value",
71 std::string_view path = "$");
72
73struct OrchestrationPlanRecord {
74 std::uint32_t schema_version = 1;
75 json plan = json::object();
76};
77
78struct SealedCoreDefinition {
79 static constexpr std::uint32_t STORAGE_SCHEMA_VERSION = 1;
80
81 std::string name;
82 std::string definition_hash;
83 json definition = json::object();
84};
88NEOGRAPH_PROGRAM_API std::string sealed_core_definition_hash(const json& definition);
93NEOGRAPH_PROGRAM_API std::string core_compiled_plan_identity(
94 const SealedCoreDefinition& definition,
95 std::string_view compiler_build_id,
96 std::string_view registry_snapshot_fingerprint,
97 const std::vector<ExecutableIdentity>& executable_closure);
98
99struct CorePlanIdentity {
100 std::string name;
101 std::string compiled_plan_identity;
102
103 bool operator==(const CorePlanIdentity&) const = default;
104};
105
106struct CapabilityEffectClosure {
107 std::vector<std::string> capabilities;
108 std::vector<std::string> effects;
109
110 bool operator==(const CapabilityEffectClosure&) const = default;
111};
112
113struct BudgetRequirement {
114 std::string resource;
115 std::uint64_t minimum = 0;
116 std::uint64_t maximum = 0;
117
118 bool operator==(const BudgetRequirement&) const = default;
119};
120
131 static_cast<SourceKind>(255);
132 std::string source_hash;
137 std::optional<ProgramSource> control_source;
138 std::string canonical_program_hash;
139 std::string compiler_build_id;
140 std::uint32_t program_schema_version = 1;
141 std::string registry_snapshot_fingerprint;
142 std::string module_dependency_merkle_root;
144 std::vector<ModuleCoordinate> module_coordinates;
145 ContractRecord input_contract;
146 ContractRecord output_contract;
147 OrchestrationPlanRecord orchestration_plan;
148 std::vector<SealedCoreDefinition> sealed_core_definitions;
149 std::vector<CorePlanIdentity> core_plan_identities;
150 CapabilityEffectClosure capability_effect_closure;
152 ExecutionGuarantee execution_guarantee = ExecutionGuarantee::Strict;
153 std::vector<ExecutableIdentity> executable_registry_identities;
154 std::vector<BudgetRequirement> declared_budget_requirements;
155 std::vector<SourceMapEntry> source_map;
156 std::vector<Diagnostic> diagnostics;
159};
160
161class NEOGRAPH_PROGRAM_API ProgramBundle {
162public:
163 static constexpr std::uint32_t STORAGE_SCHEMA_VERSION = 1;
164
165 explicit ProgramBundle(ProgramBundleData data);
166 static ProgramBundle parse(std::string_view stored_bytes);
167
168 const std::string& id() const noexcept;
169 SourceKind source_kind() const noexcept;
170 const std::string& source_hash() const noexcept;
172 std::optional<ProgramSource> control_source() const;
173 const std::string& canonical_program_hash() const noexcept;
174 const std::string& compiler_build_id() const noexcept;
175 std::uint32_t program_schema_version() const noexcept;
176 const std::string& registry_snapshot_fingerprint() const noexcept;
177 const std::string& module_dependency_merkle_root() const noexcept;
178 const JavaScriptRuntimeIdentity& javascript_runtime() const noexcept;
179 const std::vector<ModuleCoordinate>& module_coordinates() const noexcept;
180 ContractRecord input_contract() const;
181 ContractRecord output_contract() const;
182 OrchestrationPlanRecord orchestration_plan() const;
184 const ProgramPlan& typed_orchestration_plan() const;
185 std::vector<SealedCoreDefinition> sealed_core_definitions() const;
186 const std::vector<CorePlanIdentity>& core_plan_identities() const noexcept;
187 const CapabilityEffectClosure& capability_effect_closure() const noexcept;
188 ExecutionGuarantee execution_guarantee() const noexcept;
189 const std::vector<ExecutableIdentity>& executable_registry_identities() const noexcept;
190 const std::vector<BudgetRequirement>& declared_budget_requirements() const noexcept;
191 const std::vector<SourceMapEntry>& source_map() const noexcept;
193 std::vector<Diagnostic> diagnostics() const;
200 std::vector<Diagnostic> compile_diagnostics() const;
201 std::string serialize_canonical() const;
202
203private:
204 friend class detail::ProgramBundleAccess;
205 struct Impl;
206 ProgramBundle(ProgramBundleData data, std::optional<std::vector<Diagnostic>> compiled);
207 explicit ProgramBundle(std::shared_ptr<const Impl> impl);
208 std::shared_ptr<const Impl> impl_;
209};
210
211} // namespace neograph::program
NEOGRAPH_PROGRAM_API std::string core_compiled_plan_identity(const SealedCoreDefinition &definition, std::string_view compiler_build_id, std::string_view registry_snapshot_fingerprint, const std::vector< ExecutableIdentity > &executable_closure)
Returns the deterministic Core compiled-plan identity for a sealed definition and the exact executabl...
NEOGRAPH_PROGRAM_API void validate_contract_schema(const ContractRecord &contract, std::string_view path="$schema")
Validate the Program-v1 JSON Schema subset retained by a contract.
NEOGRAPH_PROGRAM_API std::string sealed_core_definition_hash(const json &definition)
Returns the v1 content identity required by SealedCoreDefinition::definition_hash.
ExecutionGuarantee
The lowest recoverability/integrity class reachable through an executable closure.
Definition bundle.h:29
Capability identity plus a single prepared, owned operation contract.
Definition provider.h:387
Abstract base class for tools that agents can call.
Definition tool.h:114
Immutable operation graph.
Definition plan.h:168
Immutable content-addressed coordinates for reusable Program modules.
Typed immutable orchestration plans used by ProgramRuntime.
Deeply owned, immutable Program source values.
SourceKind
Source identity carried by Program values.
Definition source.h:24
Exact identity of the private JavaScript frontend.
Definition source.h:58
Mutable construction input.
Definition bundle.h:129
SourceKind source_kind
Required; invalid sentinel rejects omission.
Definition bundle.h:130
std::optional< ProgramSource > control_source
Retained source for the opt-in JavaScript yielded-command controller.
Definition bundle.h:137
ExecutionGuarantee execution_guarantee
Exact weakest guarantee in the compiler-derived executable/control closure.
Definition bundle.h:152
std::vector< ModuleCoordinate > module_coordinates
Exact module coordinates represented by the dependency receipts.
Definition bundle.h:144
JavaScriptRuntimeIdentity javascript_runtime
Present for JavaScript bundles; omitted for non-JavaScript sources.
Definition bundle.h:158