NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
runtime_instruction.h
Go to the documentation of this file.
1
2#pragma once
3
4#include <neograph/context_store.h>
7
8#include <cstdint>
9#include <functional>
10#include <memory>
11#include <optional>
12#include <string>
13#include <string_view>
14#include <vector>
15
16namespace neograph::program {
17
18struct RuntimeDeveloperInstructionData {
19 std::string owner_scope;
20 std::string source_run_id;
21 std::string feed_id;
22 std::uint64_t sequence = 0;
23 std::optional<std::string> predecessor_record_id;
24 std::int64_t submitted_at_ms = 0;
25 std::string text;
26 json payload = json::object();
27 std::vector<std::string> requested_capabilities;
28 std::vector<std::string> requested_effects;
29};
30
32class NEOGRAPH_PROGRAM_API RuntimeDeveloperInstruction final {
33public:
34 static constexpr std::uint32_t STORAGE_SCHEMA_VERSION = 1;
35 static RuntimeDeveloperInstruction create(RuntimeDeveloperInstructionData data);
36 static RuntimeDeveloperInstruction parse(std::string_view stored_bytes);
37
38 const RuntimeDeveloperInstructionData& data() const noexcept;
39 const std::string& id() const noexcept;
40 std::string serialize_canonical() const;
41
42private:
43 struct Impl;
44 explicit RuntimeDeveloperInstruction(std::shared_ptr<const Impl> impl);
45 std::shared_ptr<const Impl> impl_;
46};
47
48enum class RuntimeInstructionAction : std::uint8_t {
49 SatisfiedInPlace,
50 Rejected,
51 ReplaceAtHandoff,
52 MigrateGraph,
53};
54
55NEOGRAPH_PROGRAM_API std::string_view to_string(RuntimeInstructionAction action) noexcept;
56NEOGRAPH_PROGRAM_API RuntimeInstructionAction runtime_instruction_action_from_string(
57 std::string_view value);
58
59struct RuntimeInstructionDecisionData {
60 std::string instruction_id;
61 std::string source_run_id;
62 std::string expected_lineage_head_id;
63 std::string policy_identity;
64 RuntimeInstructionAction action = RuntimeInstructionAction::Rejected;
65 std::string target_program_version_id;
66 std::string target_run_id;
67 std::string reason;
68};
69
71class NEOGRAPH_PROGRAM_API RuntimeInstructionDecision final {
72public:
73 static constexpr std::uint32_t STORAGE_SCHEMA_VERSION = 1;
74 static RuntimeInstructionDecision create(RuntimeInstructionDecisionData data);
75 static RuntimeInstructionDecision parse(std::string_view stored_bytes);
76
77 const RuntimeInstructionDecisionData& data() const noexcept;
78 const std::string& id() const noexcept;
79 std::string serialize_canonical() const;
80
81private:
82 struct Impl;
83 explicit RuntimeInstructionDecision(std::shared_ptr<const Impl> impl);
84 std::shared_ptr<const Impl> impl_;
85};
86
87using RuntimeInstructionPlanner = std::function<RuntimeInstructionDecisionData(
89 const ProgramRunLineage&,
90 const ProgramRunGeneration&)>;
91
92struct RuntimeInstructionPlan {
93 RuntimeHistoryRecord history_record;
95 ContextArtifact decision_artifact;
96};
97
98struct RuntimeInstructionControllerConfig {
99 std::shared_ptr<DurableContextStore> context_store;
100 std::shared_ptr<ProgramTransitionStore> transitions;
101 std::shared_ptr<ProgramCatalog> catalog;
102 RuntimeInstructionPlanner planner;
103};
104
106class NEOGRAPH_PROGRAM_API RuntimeInstructionController final {
107public:
108 explicit RuntimeInstructionController(RuntimeInstructionControllerConfig config);
109
110 RuntimeInstructionPlan submit_and_plan(
111 const RuntimeDeveloperInstruction& instruction,
112 const std::optional<std::string>& expected_history_head_id);
113
114 ProgramHandle apply_replacement(
115 const RuntimeInstructionDecision& decision,
116 ProgramRuntime& runtime,
118 RunInvocation invocation,
119 std::shared_ptr<ProgramEventSink> events = {}) const;
120
121 ProgramHandle apply_graph_migration(
122 const RuntimeInstructionDecision& decision,
123 ProgramRuntime& runtime,
124 const ProgramHandle& source,
125 std::shared_ptr<ProgramEventSink> events = {}) const;
126
127private:
128 RuntimeInstructionControllerConfig config_;
129};
130
131} // namespace neograph::program
Admission and process-local materialization of immutable Programs.
Immutable context material.
One immutable, content-addressed line in the authoritative RAW history feed.
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
Host-owned bridge from durable developer input to existing transition APIs.
Immutable host decision over one exact active generation.
Execution service for admitted immutable Programs.
Exact completed JavaScript checkpoint coordinate selected by the host.
Definition replacement.h:26
One owner-scoped Program request.
Definition invocation.h:115