20namespace neograph::program {
22struct ProgramSynthesisProposalData {
23 std::string owner_scope;
24 std::string lineage_id;
25 std::string parent_run_id;
26 std::optional<std::string> instruction_id;
27 std::optional<ProgramSource> source;
28 std::vector<std::string> requested_capabilities;
29 std::vector<std::string> requested_effects;
30 RunBudget requested_budget;
31 std::int64_t created_at_ms = 0;
37 static constexpr std::uint32_t STORAGE_SCHEMA_VERSION = 1;
41 const ProgramSynthesisProposalData& data()
const noexcept;
42 const ProgramSource& source()
const noexcept;
43 const std::string& id()
const noexcept;
44 std::string serialize_canonical()
const;
49 std::shared_ptr<const Impl> impl_;
52struct ProgramSynthesisReservationData {
53 std::string proposal_id;
54 std::string lineage_id;
55 std::string source_lineage_head_id;
56 std::string reserved_lineage_head_id;
57 RunBudget source_remaining;
58 RunBudget remaining_after_reservation;
64 static constexpr std::uint32_t STORAGE_SCHEMA_VERSION = 1;
68 const ProgramSynthesisReservationData& data()
const noexcept;
69 const std::string& id()
const noexcept;
70 std::string serialize_canonical()
const;
75 std::shared_ptr<const Impl> impl_;
78struct ProgramSynthesisReceiptData {
79 std::string proposal_id;
80 std::string reservation_id;
81 std::string bundle_id;
82 std::string program_version_id;
83 std::string policy_snapshot_fingerprint;
86struct ProgramSynthesisSemanticDecision {
87 std::string validator_identity;
88 std::string contract_identity;
89 bool accepted =
false;
90 json evidence = json::object();
93struct ProgramSynthesisValidationReceiptData {
94 std::string proposal_id;
95 std::string reservation_id;
96 std::string bundle_id;
97 std::string validator_identity;
98 std::string contract_identity;
99 bool accepted =
false;
100 std::string evidence_digest;
106 static constexpr std::uint32_t STORAGE_SCHEMA_VERSION = 1;
110 const ProgramSynthesisValidationReceiptData& data()
const noexcept;
111 const std::string& id()
const noexcept;
112 std::string serialize_canonical()
const;
117 std::shared_ptr<const Impl> impl_;
120NEOGRAPH_PROGRAM_API
void validate_program_synthesis_validation_evidence(
122 const json& evidence);
126 :
public std::runtime_error {
131 const json& evidence()
const noexcept;
138class NEOGRAPH_PROGRAM_API ProgramSynthesisReceipt final {
140 static constexpr std::uint32_t STORAGE_SCHEMA_VERSION = 1;
141 static ProgramSynthesisReceipt create(ProgramSynthesisReceiptData data);
142 static ProgramSynthesisReceipt parse(std::string_view stored_bytes);
144 const ProgramSynthesisReceiptData& data() const noexcept;
145 const std::
string&
id() const noexcept;
146 std::
string serialize_canonical() const;
150 explicit ProgramSynthesisReceipt(std::shared_ptr<const Impl> impl);
151 std::shared_ptr<const Impl> impl_;
154using ProgramSynthesisReservationResolver =
156using ProgramSynthesisAdmissionResolver =
158 const ProgramBundle&,
160using ProgramSynthesisSemanticValidator =
162 const ProgramBundle&,
170struct ProgramSynthesisGatewayConfig {
171 std::shared_ptr<ProgramCompiler> compiler;
172 std::shared_ptr<ProgramCatalog> catalog;
173 ProgramSynthesisReservationResolver reserve;
174 ProgramSynthesisAdmissionResolver admission;
175 std::size_t max_source_bytes = 1024 * 1024;
177 ProgramSynthesisSemanticValidator validate_semantics;
178 std::size_t max_semantic_evidence_bytes = 1024 * 1024;
183struct ProgramSynthesisResult {
184 ProgramSynthesisReservation reservation;
185 ProgramBundle bundle;
186 ProgramSynthesisValidationReceipt validation;
187 json validation_evidence;
188 ProgramVersion version;
189 ProgramSynthesisReceipt receipt;
197 std::string owner_scope;
198 std::string parent_run_id;
199 std::string parent_program_version_id;
200 std::string parent_policy_fingerprint;
201 std::string lineage_id;
202 std::string expected_lineage_head_id;
203 std::string template_identity;
204 std::string reviewed_source_identity;
205 std::string semantic_validator_identity;
206 std::string semantic_contract_identity;
207 std::vector<std::string> allowed_capabilities;
208 std::vector<std::string> allowed_effects;
209 RunBudget child_budget_ceiling;
212 std::size_t max_source_bytes = 1024 * 1024;
213 std::size_t max_sealed_modules = 16;
223 static constexpr std::uint32_t STORAGE_SCHEMA_VERSION = 1;
227 const std::string& id()
const noexcept;
228 std::string serialize_canonical()
const;
233 std::shared_ptr<const Impl> impl_;
238 ProgramVersion version;
244struct ProgramChildSynthesisAuthorizationData {
245 std::string proposal_id;
246 std::string grant_id;
247 std::string parent_run_record_id;
248 std::string parent_generation_id;
249 std::string registry_fingerprint;
250 std::string semantic_validator_identity;
251 std::string semantic_contract_identity;
252 std::string lineage_id;
253 std::string source_lineage_head_id;
254 RunBudget parent_remaining;
255 RunBudget child_budget;
259class NEOGRAPH_PROGRAM_API ProgramChildSynthesisAuthorization;
262NEOGRAPH_PROGRAM_API ProgramChildSynthesisAuthorization
274 static constexpr std::uint32_t STORAGE_SCHEMA_VERSION = 1;
275 const ProgramChildSynthesisAuthorizationData& data()
const noexcept;
276 const std::string& id()
const noexcept;
277 std::string serialize_canonical()
const;
282 std::shared_ptr<const Impl> impl_;
289NEOGRAPH_PROGRAM_API
void validate_program_child_synthesis_reservation(
293struct ProgramChildSynthesisResult {
295 ProgramSynthesisResult synthesis;
298class NEOGRAPH_PROGRAM_API ProgramChildSynthesisError final :
public std::runtime_error {
300 ProgramChildSynthesisError(std::string code, std::string message);
301 const std::string& code() const noexcept;
307class ProgramChildSynthesisRecord;
331 ProgramSynthesisResult synthesize_impl(
334 ProgramSynthesisGatewayConfig config_;
ExecutionGuarantee
The lowest recoverability/integrity class reachable through an executable closure.
Admission and process-local materialization of immutable Programs.
Read-only preflight evidence, not a compile debit, child binding, or spawn permission.
friend NEOGRAPH_PROGRAM_API ProgramChildSynthesisAuthorization authorize_program_child_synthesis(const ProgramSynthesisProposal &, const ProgramChildSynthesisGrant &, const ProgramChildSynthesisParent &)
Pure, fail-closed validation before reservation, compilation, or admission.
Stored grants are evidence only; recovery must reselect them through host policy.
Immutable identity of one admitted topology generation in a run lineage.
Immutable content-addressed head of one stable run lineage.
Deep-owned, content-addressed run snapshot used for reconnect and CAS publication.
Enforces reserve -> compile -> semantic validate -> admit.
asio::awaitable< ProgramChildSynthesisRecord > continue_child_async(ProgramChildSynthesisRecord record, std::function< asio::awaitable< void >(const ProgramChildSynthesisRecord &)> publish) const
The same stages for a caller that cannot block (#557): publish is awaited, and so is the catalog's ad...
ProgramChildSynthesisRecord continue_child(ProgramChildSynthesisRecord record, const std::function< void(const ProgramChildSynthesisRecord &)> &publish) const
Continue a durably reserved request; publish must CAS each stage before returning.
ProgramChildSynthesisResult synthesize_child(const ProgramSynthesisProposal &proposal, const ProgramChildSynthesisGrant &grant, const ProgramChildSynthesisParent &parent) const
Checked child path; never treats a proposal or returned receipt as authority.
Immutable non-executable request to compile one sealed JavaScript successor.
Host evidence that one nonrenewable dynamic-compile unit was debited.
Typed fail-closed result of a completed semantic validation.
Immutable evidence that host-owned semantic validation ran before admission.
Immutable run-generation identity and lineage budget heads.
Pure versioned Program source compiler.
Immutable outcome of one Program run attempt.
Canonical immutable snapshot of one owner-scoped Program run.
Host-authored grant for one reviewed template instantiation and parent head.
Host-loaded snapshots; no identity or budget is taken from Program input.
NEOGRAPH_PROGRAM_API ProgramChildSynthesisAuthorization authorize_program_child_synthesis(const ProgramSynthesisProposal &proposal, const ProgramChildSynthesisGrant &grant, const ProgramChildSynthesisParent &parent)
Pure, fail-closed validation before reservation, compilation, or admission.
std::function< ProgramSynthesisReservation(const ProgramSynthesisProposal &, const ProgramChildSynthesisAuthorization &)> ProgramChildSynthesisReservationResolver
Atomically debit against authorization.data().source_lineage_head_id, or fail.
NEOGRAPH_PROGRAM_API std::string program_synthesis_source_identity(const ProgramSource &source)
Identity of the complete sealed source, including imports and module bytes.