Repository navigation
refactor(native): split the native crate into a layered workspace - #983
Merged
Merged
Conversation
…versioned workspace The extension crate becomes the Python boundary crate of a Cargo workspace. The release version moves to the workspace package so every native crate shares it, and maturin, uv cache keys, release automation and fensu paths follow the new location.
…odule ProjectCatalog, CompactAnalysisJob, BindingPositions and ParsedRulesRequest become thin Python classes in bindings that wrap plain native models, and catalog mapping requests are converted from Python at the boundary. Method names, signatures, GIL release, panic handling and exception types are unchanged, so later crates can stay free of PyO3.
… panic boundary The constants used by more than one future crate and the PyO3-free panic catcher move to a dependency-free sqlbuild-core crate, with the panic tests. The Python crate keeps the named exception and guards, and the build identity now hashes every workspace crate.
…odel headers SQL scanning, the rules quote policy, model header tokenization and matching, static variable substitution and static reference extraction move with their tests to a polyglot-free sqlbuild-sqltext crate. Items other crates use become public; behaviour is unchanged.
Query analysis, the binding catalog, semantic validation and usage, column references, SQL tokens and SQL-test extraction, planning and rendering move with their tests and the function-name data to sqlbuild-analysis, the lowest crate that depends on polyglot. A test-support feature exposes one test-only helper to dependent crates' tests, and the workspace states the insertion-ordered JSON feature every crate already relied on.
… formatting Built-in rules, the rules engine and custom-rule host, SQL lint, quality checks, the formatter, rules configuration and the request models move with their tests to sqlbuild-rules. It owns the build identity script, which still hashes every workspace crate, so sqlbuild-python is left with only the PyO3 bindings.
…are the crates to fensu Items other crates use are reached through main entry points, models and types modules instead of helpers: the static reference type moves to types.rs, the rules dialect and the test-only built-in function list gain main entries, and the panic boundary splits into one entry per function with its message in constants. fensu now declares every workspace crate and its exceptions follow the moved files.
…s in check-ci The workspace declares its crates from the bottom up, and a check run by make check-ci fails when a crate depends on a later layer (resolving aliased workspace dependencies to their packages), when any crate other than sqlbuild-python reaches PyO3, or when a crate below sqlbuild-analysis reaches polyglot. It also fails when the workspace, pyproject and release-please versions differ, since the version is part of the build identity. crates/README.md documents the crates, the graph and the check.
Dependency features and release profiles live in the workspace Cargo.toml, so changing them left BUILD_IDENTITY and every cache keyed on it unchanged. The build script now hashes and watches the workspace manifest next to the lockfile and exports the hashed workspace files, which a test asserts.
kvlonge
enabled auto-merge (squash)
October 6, 2026 15:57
…pace-split # Conflicts: # Cargo.lock # crates/sqlbuild-rules/Cargo.toml
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 native code lived in one 46k-line crate that mixed text scanning, polyglot analysis, rules, lint and the PyO3 bindings. Clear crate boundaries come before moving more of the compiler to Rust: plain-Rust crates can be tested without Python, and dependencies stay one-way.
Changes
crates/sqlbuild-rules-nativeinto a workspace:sqlbuild-core(shared constants, panic boundary),sqlbuild-sqltext(lexical scanning, model headers, static substitution and references),sqlbuild-analysis(polyglot analysis, binding catalog, semantic validation, SQL tests),sqlbuild-rules(rules, lint, quality, formatting, config) andsqlbuild-python, the only PyO3 crate, still built assqlbuild._native.[workspace.package]; maturin, uv cache keys, release-please and fensu follow the new paths.make check-ciruns a layering check: no upward crate dependency, PyO3 only insqlbuild-python, no polyglot belowsqlbuild-analysis, and matching workspace, pyproject and release-please versions.Cargo.toml, so dependency feature and profile changes invalidate native caches.Verification
cargo test --workspace --all-features(113 tests), clippy, fmt.make check-ci, including fensu and the new layering tests._nativemodule surface matches main;sqb compile --json --manifest --dagon the waffle-shop example matches main apart from timings, with identical compiled files and DAG.