Skip to content

feat(native): discover models natively behind the compiler engine switch - #995

Merged
kvlonge merged 3 commits into
mainfrom
feat/native-discovery-models
Oct 7, 2026
Merged

kvlonge merged 3 commits into
mainfrom
feat/native-discovery-models

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Why

Milestone M2 moves project discovery to Rust behind the compiler engine switch. This first increment makes the directory walk and SQL model files native, the largest discovery cost, while keeping output byte-identical to the Python engine. The default engine stays python.

Changes

  • New sqlbuild-discovery crate (between sqlbuild-config and sqlbuild-analysis): a parallel directory snapshot with Python's glob, symlink and part-by-part sort semantics, read_text-compatible reading (strict UTF-8, universal newlines, BOM kept), and native model files: header match and parse, header and output column locations, query, and D002 failures with Python's messages, lines and difflib suggestions.
  • sqlbuild-core: Python-compatible isalnum/\w/isspace/strip from a table generated by scripts/generate_python_char_table.py (Unicode 15.0, the CI Python), and a difflib.get_close_matches port.
  • compile_frontier accepts a native_stage. With SQLBUILD_COMPILER_ENGINE=native, discovery takes model files from Rust and every other collection still runs in Python. The native walk seeds the pass's directory snapshot, so later globs see the same tree.
  • Python runs instead when native cannot match it exactly: a different Unicode database, a non-UTF-8 project root, non-UTF-8 file names, Windows. An unreadable file is re-read by Python for its exact error.
  • Native discovery does not use the Python discovery fact cache.

Verification

  • make compiler-differential with native on Python 3.12: 106 projects identical; dense 3k (with and without custom rules) identical.
  • Engine-parity tests (crafted and 400 seeded model files, deferral cases, shared snapshot, full stage through the switch); isalnum and close-match oracles.
  • cargo test --workspace --all-features, clippy/fmt 1.98.0, make check-native-layering, make check-ci, make test.

…ngine switch

Add the sqlbuild-discovery crate with a parallel directory walk that keeps
Python's glob and sort semantics, and native reading and parsing of SQL model
files with Python's exact discovery messages, locations and ordering.
With SQLBUILD_COMPILER_ENGINE=native the discovery stage takes its model
files from the native walk; every other collection still runs in Python.
Native discovery skips the Python discovery fact cache.
…ctly

Run the Python path when the running Python's Unicode database differs from
the native character table or the project root is not UTF-8, and share the
native models walk with the pass's directory snapshot.
@kvlonge
kvlonge enabled auto-merge (squash) October 7, 2026 05:04
@kvlonge
kvlonge merged commit d4c7157 into main Oct 7, 2026
34 checks passed
@kvlonge
kvlonge deleted the feat/native-discovery-models branch October 7, 2026 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant