58 std::uint64_t observed = 0, std::uint64_t maximum = 0,
59 std::string error_path = {},
60 std::optional<ModelError> rejected_model = {})
162 enum class Kind : std::uint8_t {
174 bool boolean =
false;
217 std::string_view
source() const noexcept {
240 ParsedJson() =
default;
241 ParsedJson(
const ParsedJson&) =
delete;
242 ParsedJson& operator=(
const ParsedJson&) =
delete;
243 ParsedJson(ParsedJson&&) =
delete;
244 ParsedJson& operator=(ParsedJson&&) =
delete;
246 std::shared_ptr<const std::string> source_;
274 std::uint32_t expected_version, std::string path = {},
315 std::string path = {});
325 std::string path = {});
335 std::string path = {});
Result<T, E> — either holds a T or an E, never both.
Definition result.hpp:76
std::string_view source() const noexcept
Returns the complete owned source.
Definition schema_json.hpp:217
friend runtime::Result< std::shared_ptr< const ParsedJson >, PersistenceError > parse_json(std::string_view json, const DecodeLimits &limits)
Parses one complete UTF-8 JSON value into an owning immutable document.
const JsonValue & root() const noexcept
Returns the root node.
Definition schema_json.hpp:213
std::string_view raw(const JsonValue &value) const noexcept
Returns the original byte slice for a node from this parse.
@ OutputLimitExceeded
Definition note_transform.hpp:63
@ LimitExceeded
A configured import resource limit was exceeded.
Definition dawproject_import.hpp:50
@ ModelRejected
The assembled Project violates a model invariant.
Definition dawproject_import.hpp:49
runtime::Result< std::string, PersistenceError > canonicalize_json(const JsonValue &value)
Serializes a DOM value as deterministic JSON with sorted object keys.
runtime::Result< std::uint32_t, PersistenceError > parse_u32_number(const JsonValue &value, std::string path={})
Parses an integral JSON number representable as uint32_t.
PersistenceErrorCode
Stable category for a JSON, schema, quota, migration, or model rejection.
Definition schema_json.hpp:23
runtime::Result< const JsonValue *, PersistenceError > validate_exact_envelope(const JsonValue &value, std::string_view expected_type, std::uint32_t expected_version, std::string path={}, PersistenceErrorCode failure_code=PersistenceErrorCode::InvalidSchema)
Validates an exact extension or migration envelope.
runtime::Result< std::int64_t, PersistenceError > parse_canonical_i64_string(const JsonValue &value, std::string path={})
Parses a canonical decimal signed integer stored as a JSON string.
runtime::Result< std::uint64_t, PersistenceError > parse_canonical_u64_string(const JsonValue &value, std::string path={})
Parses a canonical decimal unsigned integer stored as a JSON string.
std::string quote_json_string(std::string_view value)
Quotes and escapes a byte sequence as a JSON string token.
runtime::Result< StructuralPreflightSuccess, PersistenceError > preflight_timeline_structure(std::string_view json, const DecodeLimits &limits)
Performs an allocation-light, schema-aware Timeline quota scan.
runtime::Result< std::shared_ptr< const ParsedJson >, PersistenceError > parse_json(std::string_view json, const DecodeLimits &limits={})
Parses one complete UTF-8 JSON value into an owning immutable document.
@ MigrationPathMissing
Registered migrations do not connect source to target.
Definition schema_json.hpp:34
@ InvalidSchema
A schema identity, envelope, or codec contract is invalid.
Definition schema_json.hpp:31
@ InvalidJson
JSON syntax or document shape is invalid.
Definition schema_json.hpp:24
@ MissingField
A required schema field is absent.
Definition schema_json.hpp:28
@ MigrationFailed
A migration returned or produced invalid output.
Definition schema_json.hpp:35
@ InvalidNumber
A numeric value is malformed or out of range.
Definition schema_json.hpp:30
@ UnsupportedStructuralType
Structural preflight encountered an unknown typed envelope.
Definition schema_json.hpp:32
@ UnexpectedType
A JSON value has the wrong kind.
Definition schema_json.hpp:29
@ UnsupportedSchemaVersion
No supported decoder version accepts the envelope.
Definition schema_json.hpp:33
@ InvalidUtf8
A required string is not valid UTF-8.
Definition schema_json.hpp:25
@ DuplicateKey
An object repeats a member name.
Definition schema_json.hpp:26
@ String
Definition schema_registry.hpp:35
@ Boolean
Definition schema_registry.hpp:31
@ Array
Definition schema_registry.hpp:37
@ Object
Definition schema_registry.hpp:36
Definition program_compiler.hpp:18
Result<T, E> — success / failure union for fallible operations.
Parser, migration, opaque-payload, and Timeline structure quotas.
Definition schema_json.hpp:78
std::size_t max_take_lanes
Maximum take lanes across all tracks.
Definition schema_json.hpp:126
std::size_t max_automation_lanes
Maximum automation lanes across all tracks.
Definition schema_json.hpp:116
std::size_t max_automation_points
Maximum automation points across all lanes.
Definition schema_json.hpp:118
std::size_t max_sequences
Maximum project sequences.
Definition schema_json.hpp:102
std::size_t max_total_values
Maximum total DOM values.
Definition schema_json.hpp:84
std::size_t max_audio_loop_tags
Maximum loop tags across all assets.
Definition schema_json.hpp:100
static DecodeLimits web_defaults() noexcept
Returns tighter ceilings suitable for memory-constrained web runtimes.
std::size_t max_notes
Maximum note events across all note content.
Definition schema_json.hpp:108
std::size_t max_device_placements
Maximum device placements across all tracks.
Definition schema_json.hpp:114
std::size_t max_chord_scale_events
Maximum chord/scale events.
Definition schema_json.hpp:140
std::size_t max_string_bytes
Maximum decoded bytes in one string or key.
Definition schema_json.hpp:90
std::size_t max_macro_controls
Maximum macro controls across all tracks.
Definition schema_json.hpp:122
std::size_t max_tracks
Maximum tracks across all sequences.
Definition schema_json.hpp:104
std::size_t max_takes
Maximum takes across all take lanes.
Definition schema_json.hpp:128
std::size_t max_modulation_routes
Maximum modulation routes across all tracks.
Definition schema_json.hpp:124
std::size_t max_representations
Maximum alternate asset representations.
Definition schema_json.hpp:112
std::size_t max_audio_loop_points
Maximum loop slice points across all assets.
Definition schema_json.hpp:98
std::size_t max_slots
Maximum launch slots across all scenes.
Definition schema_json.hpp:138
std::size_t max_object_members
Maximum members in one JSON object.
Definition schema_json.hpp:88
std::size_t max_dynamics_events
Maximum dynamics events.
Definition schema_json.hpp:142
std::size_t max_clips
Maximum clips across all tracks.
Definition schema_json.hpp:106
std::size_t max_depth
Maximum JSON container nesting depth.
Definition schema_json.hpp:82
std::size_t max_modulators
Maximum modulators across all tracks.
Definition schema_json.hpp:120
std::size_t max_opaque_bytes
Maximum raw bytes retained by one opaque envelope.
Definition schema_json.hpp:92
std::size_t max_regions
Maximum sequence regions.
Definition schema_json.hpp:134
std::size_t max_groove_steps
Maximum groove-template steps.
Definition schema_json.hpp:144
std::size_t max_array_elements
Maximum elements in one JSON array.
Definition schema_json.hpp:86
std::size_t max_input_bytes
Maximum complete input size.
Definition schema_json.hpp:80
std::size_t max_migration_steps
Maximum adjacent migration callbacks per value.
Definition schema_json.hpp:94
std::size_t max_markers
Maximum sequence markers.
Definition schema_json.hpp:132
std::size_t max_locators
Maximum asset locators.
Definition schema_json.hpp:110
std::size_t max_midi_lane_points
Maximum controller points across all lanes.
Definition schema_json.hpp:148
std::size_t max_midi_lanes
Maximum controller/expression lanes across all MIDI content.
Definition schema_json.hpp:146
std::size_t max_scenes
Maximum launch scenes.
Definition schema_json.hpp:136
std::size_t max_assets
Maximum media assets in one project.
Definition schema_json.hpp:96
std::size_t max_take_comp_segments
Maximum take-comp segments across all lanes.
Definition schema_json.hpp:130
Pair-like owning member of a JSON object.
Definition schema_json.hpp:201
std::string first
Decoded object key.
Definition schema_json.hpp:202
JsonValue second
Owning object value.
Definition schema_json.hpp:203
Owning JSON DOM node with source byte bounds.
Definition schema_json.hpp:160
std::vector< JsonObjectMember > object
Decoded key/value pairs when kind is Object.
Definition schema_json.hpp:180
const JsonValue * find(std::string_view key) const noexcept
Finds an exact member on an object.
std::size_t end
Exclusive source byte offset.
Definition schema_json.hpp:184
std::string scalar
Decoded string or original number spelling.
Definition schema_json.hpp:176
std::size_t begin
Inclusive source byte offset.
Definition schema_json.hpp:182
Kind
JSON value category.
Definition schema_json.hpp:162
@ Null
JSON null.
Definition schema_json.hpp:163
std::vector< JsonValue > array
Child values when kind is Array.
Definition schema_json.hpp:178
Kind kind
Value category.
Definition schema_json.hpp:172
Structured persistence failure.
Definition schema_json.hpp:46
PersistenceError(PersistenceErrorCode error_code, std::size_t offset=0, std::uint64_t observed=0, std::uint64_t maximum=0, std::string error_path={}, std::optional< ModelError > rejected_model={})
Constructs a structured persistence error from stage-specific details.
Definition schema_json.hpp:57
std::optional< ModelError > model_error
Underlying ModelRejected detail.
Definition schema_json.hpp:69
std::uint64_t actual
Observed size or count for a quota failure.
Definition schema_json.hpp:66
std::size_t byte_offset
Source byte offset, when available.
Definition schema_json.hpp:65
std::uint64_t limit
Configured ceiling for a quota failure.
Definition schema_json.hpp:67
std::string path
JSON Pointer-like path to the rejected value.
Definition schema_json.hpp:68
PersistenceErrorCode code
Failure category.
Definition schema_json.hpp:64
PersistenceError()=default
Constructs an InvalidJson error with no source location.
Empty success value returned by structural preflight.
Definition schema_json.hpp:278