NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
compiler.h
Go to the documentation of this file.
1
5#pragma once
6
13
14#include <cstddef>
15#include <cstdint>
16#include <memory>
17#include <stdexcept>
18#include <string>
19#include <vector>
20
21namespace neograph::program {
22
23struct JavaScriptCompileLimits {
24 std::size_t memory_limit_bytes = 32u * 1024u * 1024u;
29 std::size_t max_stack_bytes = 512u * 1024u;
30 std::uint64_t max_interrupt_polls = 1'000'000u;
31 std::uint64_t max_wall_time_ms = 60'000u;
32 std::size_t max_generated_document_bytes = 16u * 1024u * 1024u;
33};
34
44 RunBudget minimum;
45 RunBudget maximum;
46
47 bool operator==(const ProgramBudgetBounds&) const = default;
48};
49
50struct ProgramCompilerConfig {
51 // Exact opaque build identity. It identifies Program normalization,
52 // closure, Core-parser, round-trip, and validator semantics together.
53 // Mandatory, nonempty UTF-8; do not synthesize from pointer/RTTI/process state.
54 std::string compiler_build_id;
55 // Applied only to SourceKind::JavaScript. Limits are host policy, not
56 // source-authored semantics; changing them requires a new build identity.
57 JavaScriptCompileLimits javascript;
63 std::string quickjs_release = std::string(ProgramSource::JAVASCRIPT_ENGINE_VERSION);
64 std::string quickjs_archive_digest =
65 std::string(ProgramSource::JAVASCRIPT_QUICKJS_ARCHIVE_DIGEST);
66 std::string quickjs_build_options =
67 std::string(ProgramSource::JAVASCRIPT_QUICKJS_BUILD_OPTIONS);
68 std::string javascript_profile = std::string(ProgramSource::JAVASCRIPT_PROFILE);
69 std::uint32_t javascript_profile_version = ProgramSource::JAVASCRIPT_PROFILE_VERSION;
70 std::uint32_t ng_api_version = ProgramSource::JAVASCRIPT_NG_API_VERSION;
76 bool require_acyclic = false;
83 bool echo_routes = false;
92 bool soundness_check = false;
94 std::size_t soundness_state_cap = 100000;
95};
96
99class NEOGRAPH_PROGRAM_API ProgramCompileError final : public std::runtime_error,
101public:
102 explicit ProgramCompileError(std::vector<Diagnostic> diagnostics);
103 const std::vector<Diagnostic>& diagnostics() const noexcept;
104
105private:
106 std::vector<Diagnostic> diagnostics_;
107};
108
109class NEOGRAPH_PROGRAM_API ProgramCompiler {
110public:
112 static constexpr std::uint32_t PROGRAM_SCHEMA_VERSION =
113 neograph::program::PROGRAM_SCHEMA_VERSION_V1;
114
115 ProgramCompiler(RegistrySnapshot registry, ProgramCompilerConfig config);
116 ProgramCompiler(ProgramCompiler&&) noexcept;
117 ProgramCompiler& operator=(ProgramCompiler&&) noexcept;
118 ProgramCompiler(const ProgramCompiler&) = delete;
119 ProgramCompiler& operator=(const ProgramCompiler&) = delete;
120 ~ProgramCompiler();
121
122 const std::string& compiler_build_id() const noexcept;
123 const std::string& registry_snapshot_fingerprint() const noexcept;
124 ProgramBundle compile(const ProgramSource& source) const;
130 ProgramBundle compile(const ProgramSource& source, const RunBudget& javascript_budget) const;
135 ProgramBundle compile(const ProgramSource& source,
136 const ProgramBudgetBounds& javascript_budget_bounds) const;
142 ProgramBundle compile(const ProgramSource& source,
143 const RunBudget& javascript_budget,
144 const ContractRecord& input_contract,
145 const ContractRecord& output_contract) const;
147 ProgramBundle compile(const ProgramSource& source, const ModuleResolution& resolution) const;
148
149private:
150 struct Impl;
151 std::unique_ptr<Impl> impl_;
152};
153
154} // namespace neograph::program
Immutable, content-addressed Program compilation artifacts.
Marks an exception type as a configuration or definition verdict.
Also a graph::ConfigurationFailure (#364): inside a Core node it is NG.ConfigError,...
Definition compiler.h:100
Marker for exceptions that are configuration or definition verdicts (#364).
Immutable, owner-scoped Program modules and bounded child composition.
Immutable executable registry snapshots for Program admission.
Immutable outcome of one Program run attempt.
Published Program source-schema version identifiers.
Result of resolving one module and its complete pinned dependency closure.
Definition module.h:111
Host-owned admissible runtime budget interval for a JavaScript Program.
Definition compiler.h:43