NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
migration.h
Go to the documentation of this file.
1
5#pragma once
6
7#include <neograph/api.h>
9
10#include <cstdint>
11#include <memory>
12#include <optional>
13#include <string>
14#include <string_view>
15#include <vector>
16
17namespace neograph::program {
18
25enum class StoredArtifactClassification : std::uint8_t {
26 Translated,
27 DrainOnly,
28 Rejected,
29};
30
32enum class StoredArtifactKind : std::uint8_t {
33 LegacyCoreDefinition,
34 LegacyProgramVersion,
35};
36
44 StoredArtifactClassification classification = StoredArtifactClassification::Rejected;
45 bool allows_new_publication = false;
46 bool allows_new_run = false;
47 bool requires_legacy_runtime = false;
48 std::string diagnostic_code;
49 StoredArtifactKind kind = StoredArtifactKind::LegacyCoreDefinition;
50
51 bool operator==(const StoredArtifactClassificationRule&) const = default;
52};
53
54NEOGRAPH_PROGRAM_API void to_json(json& value, const StoredArtifactClassificationRule& rule);
55NEOGRAPH_PROGRAM_API void from_json(const json& value, StoredArtifactClassificationRule& rule);
56NEOGRAPH_PROGRAM_API std::string_view to_string(
57 StoredArtifactClassification classification) noexcept;
58NEOGRAPH_PROGRAM_API StoredArtifactClassification stored_artifact_classification_from_string(
59 std::string_view value);
60NEOGRAPH_PROGRAM_API std::string_view to_string(StoredArtifactKind kind) noexcept;
61NEOGRAPH_PROGRAM_API StoredArtifactKind stored_artifact_kind_from_string(std::string_view value);
62
63enum class MigrationCompatibility : std::uint8_t {
69 DrainOnly,
73 Blocked,
74
75 // Source-compatible names retained for callers of the early P4 API. A
76 // mismatch is fail-closed and therefore maps to Blocked.
77 Compatible = ForkCompatible,
78 OwnerMismatch = 5,
79 CompilerMismatch = 6,
80 RegistryMismatch = 7,
81 MaterializationMismatch = 8,
82};
83
85enum class MigrationDimension : std::uint8_t {
86 Channels,
87 Continuation,
88 PendingInput,
89 PendingEffect,
90 Retry,
91 Cancellation,
92 Interrupt,
93 Budget,
94 Authority,
95 Checkpoint,
96 Journal,
97 Effects,
98 Caches,
99 Output,
101 Compiler,
102 Registry,
103 Materialization,
104 Contract,
105 Recovery,
107 Schema,
108 Reducers,
109 Barriers,
110 PendingWork,
111 PendingEvents,
112 Subscriptions,
113 Resume,
114 NodeLocal,
115 Reconciliation,
116 TerminalOutput,
117 CheckpointLineage,
118};
119
122 MigrationDimension dimension = MigrationDimension::Continuation;
123 std::string code;
124 std::string message;
125 json source = json::object();
126 json target = json::object();
127
128 bool operator==(const MigrationDiagnostic&) const;
129};
130
133 MigrationDimension dimension = MigrationDimension::Continuation;
134 std::string rule;
135 json source = json::object();
136 json target = json::object();
137
138 bool operator==(const MigrationMapping&) const;
139};
140
144
145struct MigrationPlanData {
146 std::string source_version_id;
147 std::string target_version_id;
148 std::string owner_scope;
149 MigrationCompatibility compatibility = MigrationCompatibility::Compatible;
150 std::vector<std::string> blockers;
151 std::vector<MigrationDiagnostic> diagnostics;
152 std::vector<MigrationMapping> mappings;
153};
161class NEOGRAPH_PROGRAM_API MigrationPlan final {
162public:
163 static constexpr std::uint32_t STORAGE_SCHEMA_VERSION = 2;
164 static constexpr std::uint32_t PREVIOUS_STORAGE_SCHEMA_VERSION = 1;
170 static constexpr std::uint32_t LEGACY_STORAGE_SCHEMA_VERSION = 0;
171 static MigrationPlan create(MigrationPlanData data);
176 static MigrationPlan between(const ProgramVersion& source, const ProgramVersion& target);
182 static MigrationPlan between(const ProgramVersion& source,
183 const ProgramBundle& source_bundle,
184 const ProgramVersion& target,
185 const ProgramBundle& target_bundle);
186 static MigrationPlan parse(std::string_view stored_bytes);
187
188 const std::string& source_version_id() const noexcept;
189 const std::string& target_version_id() const noexcept;
190 const std::string& owner_scope() const noexcept;
191 MigrationCompatibility compatibility() const noexcept;
192 const std::vector<std::string>& blockers() const noexcept;
193 const std::vector<MigrationDiagnostic>& diagnostics() const noexcept;
194 const std::vector<MigrationMapping>& mappings() const noexcept;
195 bool is_compatible() const noexcept;
197 bool semantically_matches(const MigrationPlan& expected) const noexcept;
198 const std::string& id() const noexcept;
199 std::string serialize_canonical() const;
200
201private:
202 struct Impl;
203 explicit MigrationPlan(std::shared_ptr<const Impl> impl);
204 std::shared_ptr<const Impl> impl_;
205};
206
207NEOGRAPH_PROGRAM_API std::string_view to_string(MigrationCompatibility compatibility) noexcept;
208NEOGRAPH_PROGRAM_API MigrationCompatibility migration_compatibility_from_string(std::string_view value);
209NEOGRAPH_PROGRAM_API std::string_view to_string(MigrationDimension dimension) noexcept;
210NEOGRAPH_PROGRAM_API MigrationDimension migration_dimension_from_string(std::string_view value);
211
212} // namespace neograph::program
NEOGRAPH_API export/import macro for shared-library builds.
Immutable proof of whether an admitted run may move to another version.
Definition migration.h:161
static MigrationPlan between(const ProgramVersion &source, const ProgramBundle &source_bundle, const ProgramVersion &target, const ProgramBundle &target_bundle)
Builds a field-level proof from the admitted bundles.
static MigrationPlan between(const ProgramVersion &source, const ProgramVersion &target)
Builds a conservative version-only proof.
MigrationDimension
Contract dimension covered by a migration proof or rejection.
Definition migration.h:85
@ Compiler
Additional dimensions are appended to preserve persisted ordering.
StoredArtifactClassification
Classification of a retained legacy source artifact at the authoring cutover boundary.
Definition migration.h:25
StoredArtifactKind
Stored source families to which the cutover rules apply.
Definition migration.h:32
@ OperatorReconciliation
A human/operator must reconcile durable state before migration.
@ NewRunsOnly
The version is admitted for new invocations only; pinned runs drain.
@ ForkCompatible
The exact source checkpoint may be projected to the target version.
Stable, machine-readable evidence for one migration dimension.
Definition migration.h:121
Narrow, explicit mapping retained for a compatible migration dimension.
Definition migration.h:132
Explicit policy result; adapters must not infer a compiler from JSON shape.
Definition migration.h:43
Immutable stored binding between a Program bundle and admission receipts.