Repository navigation
feat(native): resolve declaration scopes natively behind a native-preview engine tier - #1006
Merged
Merged
Conversation
The new sqlbuild-scopes crate projects the scope builder's walked resources and declarations into the static scope index with the Python builder's record orders, duplicate and naming diagnostics and macro dependency usages, the lookup's canonical orders and repr-ordered groups, declaration visibility and the expected-model and tested-macro relationship grants. Any path Python would reject defers the stage.
… engine switch With the native engine, the scope index, its validation, relationship grants and the scope lookup are built by sqlbuild-scopes and materialised as the same Python records, orders and mappings. Python keeps the relationship-name extraction and every error message: an invalid index or a relationship fault raises exactly as before, and a project the native index cannot reproduce runs the Python stage. sqb scope uses the same path. The Python engine is unchanged.
The failure corpus gains scope cases: a duplicate scoped declaration, inaccessible local and scoped declarations, the first of two visibility errors, a test outside its relationship grants and a malformed expected model. A harness test compares a scoped project with expected-model and macro-test grants under both engines.
Move the PyO3 binding helpers into per-domain folders (analysis, boundary, discovery, rules, scopes, sqltext) and split the flat function module along the same lines. Function bodies are unchanged; only module paths and registration move.
Each native stage declares a shipped or preview tier in one registry. The native engine runs shipped stages only (discovery); native-preview adds stages still in development (declaration scopes). Preview keeps its own compiler, Rules and reuse stores. The per-PR differential compares python with native-preview on the full corpus and python with native on the seeds and failure corpus.
Under native-preview the declaration scope reads each model-mode SQL test's and scenario's __expected__<model> names with a native port of the Python top-level CTE scan, using the adapter's lexical rules. Any text Python would reject, or a non-ASCII character at a code position, defers that body to the Python extraction, so names and fault messages stay byte-identical.
…e Python version job
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
The compiler moves to Rust stage by stage. Declaration scopes are next. A stage should only become the shipped default after it passes its own flip gate, so stages still in development need a separate preview engine.
Changes
python(oracle),native(default; shipped stages: discovery) and opt-innative-preview(adds stages in development). Each stage declares its tier once inNATIVE_STAGE_TIERS. Preview keeps its own compiler, Rules and reuse stores.sqlbuild-scopescrate: the scope index with Python's record orders and diagnostics, lookup orders, visibility, relationship grants, and a dialect-aware scan of SQL tests and scenarios for expected models. Anything Python would reject, or a non-ASCII character at a code position, defers to Python. Undernative-preview,build_declaration_scopeandsqb scopeuse it. Error messages stay in Python.analysis,boundary,discovery,rules,scopes,sqltext) in a separate commit with no body changes.native-previewon the full corpus. A newcompiler-differential-shippedstep compares python withnativeon seeds and failures; the 3.13/3.14 job compares python withnative.Verification
cargo test,clippyandfmt(1.98.0),make check-native-layering,make check-ci,make test.compile,lineageandscopeCLI tests pass locally (performance budgets excepted on a loaded machine).make compiler-differentialwith render coverage: 144 identical. Shipped: 138 identical. Dense 3k: identical.