Repository navigation
feat(native): add core types, exact JSON emitter and config parsing - #992
Merged
Merged
Conversation
The emitter refuses integers beyond Python's 4300-digit string limit and values nested deeper than 128 levels instead of exhausting the stack. orjson is required at 3.11.7 or later, whose float layout the emitter reproduces, and a test pins that layout.
…L and project config reading Adds TOML loading that matches tomllib, rejecting TOML 1.1-only syntax, and typed project and local config readers for the fields discovery needs. Any native error defers to the Python loader. Internal oracle hooks compare both against Python on seeded and repository documents. Tables keep tomllib's order of first creation even when an implicit table is declared later, CRLF is normalized and a leading byte order mark is rejected as tomllib does. Container depth and dotted key length are bounded before parsing so deep documents are refused instead of exhausting the stack. tomllib's namespace rules are replayed over the parser events, so dotted keys into arrays of tables or declared tables, headers over dotted or inline tables, and extended inline tables are rejected as tomllib rejects them.
Composes saphyr-parser events into PyYAML's node graph and emulates the YAML 1.1 resolver and SafeConstructor, including merge keys, base-60 numbers, timestamps and duplicate-key handling. Constructs PyYAML or LibYAML handle differently defer to Python. Oracle tests compare against SafeLoader and CSafeLoader on seeded and repository documents. Literal and folded scalars are read by a port of PyYAML's block scalar scanner, cross-checked against the parser, so chomping matches PyYAML with or without a final line break. A leading byte order mark is skipped. Constructs the two PyYAML loaders read differently, such as tabs, '?' inside flow scalars and directives, are deferred, and the oracle tests require deferral wherever SafeLoader and CSafeLoader disagree. Shared nodes are built once, and construction depth plus a size budget proportional to the input bound alias and merge expansion. Property lookups use code positions computed once per document and mapping keys are hashed by Python equality, so large single-line flow collections load in linear time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Later native milestones need Rust building blocks that match Python exactly: identities and diagnostics, text positions, JSON text that equals
json.dumps/orjson byte for byte, and configuration reading that matchestomlliband PyYAML. This PR adds those foundations only. Nothing is wired into the compile path, and Python behaviour does not change.Changes
sqlbuild-core: passive identity, diagnostic and SQL value types;LineIndexpositions with Python universal-newline decoding; an exactjson.dumps/orjson emitter. The orjson floor rises to 3.11.7, whose float layout it reproduces.sqlbuild-configcrate:tomllib-compatible TOML (creation order, namespace rules, CRLF, TOML 1.1 rejection);_oracle_*hooks (not an API) and seeded oracles:Verification
cargo test --workspace --all-features; clippy-D warningsand fmt on 1.98.0;make check-native-layeringuv sync --all-extras --reinstall-package sqlbuild, then oracle tests and review repro scripts: no crash, no harmful mismatchmake test(11204 passed),make check-ci, public-repository scanner