NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
harness_program_store.h
1#pragma once
2
3#include <neograph/api.h>
4#include <neograph/json.h>
5#include <neograph/mcp/harness_program_translator.h>
9
10#include <cstdint>
11#include <memory>
12#include <optional>
13#include <string>
14#include <string_view>
15
16namespace neograph::mcp {
17
18class HarnessRecordStore;
19
28class NEOGRAPH_HARNESS_API HarnessProgramArtifactRecord {
29public:
30 static constexpr std::uint32_t STORAGE_SCHEMA_VERSION = 2;
31
32 static HarnessProgramArtifactRecord create(std::string artifact_id,
33 std::string owner_scope,
34 program::ProgramBundle bundle,
35 program::ProgramVersion version,
36 HarnessInvocationTemplate invocation_template,
37 json projection);
38 static HarnessProgramArtifactRecord parse(const json& stored);
39
40 const std::string& artifact_id() const noexcept;
41 const std::string& owner_scope() const noexcept;
42 const program::ProgramBundle& bundle() const noexcept;
43 const program::ProgramVersion& version() const noexcept;
44 const HarnessInvocationTemplate& invocation_template() const noexcept;
45 json projection() const;
46
47 json serialize() const;
48
49private:
50 struct Impl;
51 explicit HarnessProgramArtifactRecord(std::shared_ptr<const Impl> impl);
52 std::shared_ptr<const Impl> impl_;
53};
54
62class NEOGRAPH_HARNESS_API HarnessProgramRunRecord {
63public:
64 static constexpr std::uint32_t STORAGE_SCHEMA_VERSION = 2;
65
66 static HarnessProgramRunRecord create(const HarnessProgramArtifactRecord& artifact,
68 json projection);
69 static HarnessProgramRunRecord parse(const json& stored);
70
71 const std::string& artifact_id() const noexcept;
72 const std::string& owner_scope() const noexcept;
73 const program::ProgramRunRecord& run_record() const noexcept;
74 const program::RunInvocation& invocation() const noexcept;
75 json projection() const;
76 void validate_artifact(const HarnessProgramArtifactRecord& artifact) const;
77 json serialize() const;
78
79private:
80 struct Impl;
81 explicit HarnessProgramRunRecord(std::shared_ptr<const Impl> impl);
82 std::shared_ptr<const Impl> impl_;
83};
84
91class NEOGRAPH_HARNESS_API HarnessProgramAdapterStore {
92public:
93 virtual ~HarnessProgramAdapterStore() = default;
94
95 virtual std::shared_ptr<program::ProgramTransitionStore>
96 bind_program_transitions(HarnessProgramArtifactRecord artifact) = 0;
97
99 virtual std::optional<HarnessProgramRunRecord>
100 resolve_program_run(std::string_view owner_scope, std::string_view run_id) const = 0;
101};
102
108class NEOGRAPH_HARNESS_API HarnessContractRunStore {
109public:
110 virtual ~HarnessContractRunStore() = default;
111
112 virtual void save_contract_run(const HarnessProgramArtifactRecord& artifact,
113 const program::ProgramRunRecord& run_record,
114 const program::ContractRun& contract_run) = 0;
115 virtual std::optional<program::ContractRun>
116 load_contract_run(const HarnessProgramArtifactRecord& artifact,
117 const program::ProgramRunRecord& run_record) const = 0;
118};
119
121NEOGRAPH_HARNESS_API std::shared_ptr<HarnessProgramAdapterStore>
122require_harness_program_adapter_store(const std::shared_ptr<HarnessRecordStore>& records);
123
131class NEOGRAPH_HARNESS_API HarnessBoundedProgramStore final : public program::SyncProgramStore {
132public:
133 HarnessBoundedProgramStore(std::shared_ptr<HarnessRecordStore> records,
134 std::string artifact_id,
135 std::string owner_scope,
136 HarnessInvocationTemplate invocation_template,
137 json projection);
139
141 HarnessBoundedProgramStore& operator=(const HarnessBoundedProgramStore&) = delete;
144
145 void publish_admitted_sync(const program::ProgramBundle& bundle,
146 const program::ProgramVersion& version) override;
147 std::optional<program::ProgramBundle> get_bundle_sync(std::string_view id) const override;
148 std::optional<program::ProgramVersion> get_version_sync(std::string_view id) const override;
149 std::optional<program::ProgramBundle>
150 get_bundle_sync(std::string_view owner_scope, std::string_view id) const override;
151 std::optional<program::ProgramVersion>
152 get_version_sync(std::string_view owner_scope, std::string_view id) const override;
153
155 std::optional<HarnessProgramArtifactRecord> load_artifact() const;
156
157private:
158 struct Impl;
159 std::unique_ptr<Impl> impl_;
160};
161
163class NEOGRAPH_HARNESS_API HarnessBoundedProgramJournal final : public program::ProgramJournal {
164public:
165 HarnessBoundedProgramJournal(std::shared_ptr<program::ProgramTransitionStore> transitions,
166 std::string owner_scope);
168
169 std::optional<program::ProgramJournalRecord> latest(std::string_view run_id) const override;
170 program::JournalAppendResult compare_append(
171 std::string_view expected_previous_id,
172 program::ProgramJournalRecord record) override;
173
174private:
175 struct Impl;
176 std::unique_ptr<Impl> impl_;
177};
178
179} // namespace neograph::mcp
NEOGRAPH_API export/import macro for shared-library builds.
ProgramJournal compatibility view backed exclusively by ProgramTransitionStore CAS.
One-artifact ProgramStore view over HarnessRecordStore.
std::optional< HarnessProgramArtifactRecord > load_artifact() const
Owner-scoped strict load.
Optional durable boundary for the Harness contract state associated with a canonical Program run.
Temporary PR7–PR12 Harness alias/binding factory.
virtual std::optional< HarnessProgramRunRecord > resolve_program_run(std::string_view owner_scope, std::string_view run_id) const =0
Wrong-owner lookups are indistinguishable from absence.
Strict P2 compatibility record for one Harness artifact alias.
Strict adapter wrapper for one canonical ProgramRunRecord.
Durable-boundary state machine for one implementation attempt.
Definition contract.h:194
Deep-owned, content-addressed run snapshot used for reconnect and CAS publication.
Definition run_record.h:119
Base of a ProgramStore whose backend is synchronous: the in-memory store, SQLite and PostgreSQL.
Definition store.h:123
Thin C++ RAII wrapper around yyjson with nlohmann-compatible API.
Frozen implementation contracts and fail-closed verification evidence.
Atomic storage of admitted Program bundles and versions.
Immutable input and budget selected during Harness translation, before the admitted ProgramVersion an...
Deep-owned stored journal value.
Definition journal.h:62
One owner-scoped Program request.
Definition invocation.h:115
Atomic owner-scoped Program transition publication.