Skip to content

refactor: move discovery, compile inputs, assembly and the compile pipeline into the native driver - #1094

Merged
kvlonge merged 26 commits into
mainfrom
feat/native-compile-driver
Oct 13, 2026
Merged

kvlonge merged 26 commits into
mainfrom
feat/native-compile-driver

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Why

Phase 1 of the Rust-hosted migration (CHI-589): Rust owns the compile sequence and the static compiler logic; Python stays only for user code, adapters and the executor. This milestone moves the remaining compile orchestration into the native driver and ports several compiler packages, deleting the Python they replace.

Changes

  • Native compile driver now also discovers project inputs, builds compile inputs, assembles compiled projects, and runs the compile-and-plan pipeline used by plan/build/run. Python stages that remain are called by module path.
  • Native discovery records (no Python row conversion), DAG artifact, compile manifest (written bytes unchanged), column lineage, fingerprint storage SQL/decoding, SQL quote/comment scanning for reference resolution, audit-gate and hook-read edges, and static Python literal scans (literal SQL calls, decorator locations, rename string locations).
  • handled_native_errors entries for existing try/except blocks that now wrap native entry points; no Python fallback runs in any of them.
  • Movable Python: 137,187 → 130,215 lines.

Verification

  • Compiler differential: 371/371 projects, no golden changes (two Python-oracle goldens drop per-model proof records because the oracle hook moved; compiler output is unchanged).
  • sqb compile output identical to main on a generated 1k-model project and a private project, cold and one-model edit.
  • make test (one timing-flaky launcher comparison fixed to ignore phase durations), make check-ci, hygiene scan, independent review with no findings.

Build the static DAG JSON in sqlbuild-analysis from plain inputs the
binding reads off the compiled project views and the discovered Python
node graph, reproducing dataclasses.asdict, the None and empty-field
pruning and json.dumps(indent=2) byte for byte. The compile driver and
sqb dag call it directly; the Python artifact builder is removed.
Parse the dedented function source with the ruff parser under CPython's tree shape and ast.walk order, and delete the Python ast scan. Python keeps inspect.getsourcelines and textwrap.dedent.
Resource diagnostics find the @udf decorator's line and UTF-8 byte column in Rust instead of calling back into a Python ast locator, which is deleted.
sqb rename and sqb mv read project Python string constants with the ruff parser in CPython's ast.walk order and positions, and match them with Python re IGNORECASE semantics in Rust. The Python ast and regex scan is deleted; Python keeps reading the files.
The dbt-style manifest is built in Rust and returned as a NativeManifest whose contents() are the exact bytes json.dumps(manifest, indent=2) + "\n" produced; encoding errors still raise from the writer. Python passes only hook identities, the plan output and the generation timestamp. The Python manifest builders are removed.
Native discovery builds the Python discovery model objects directly, and the
compile driver calls the native discoverers. The Python payload conversion
layer (discovery/_helpers/native), the pure file-walk wrappers in
filesystem/core.py, the YAML path and scenario helpers, and the
payload-returning bindings are removed. Discoverers that import or run user
code stay in Python.
…rence resolution

The planner's reference resolution scans with a native SqlCodeScanner at Python string offsets, mirroring the generic and dialect rules of the deleted Python sql_analysis scanning helpers and their main wrappers.
Schema validation without a shared catalog now returns diagnostic rows from one native call that validates, maps and positions them, replacing the Python JSON response parsing and the validate_sql_with_schemas_json binding.
resolve_binding_column and is_polyglot_available have no callers.
The planner's attached-audit gate edges and hook-read edges come from the native explicit-reference graph logic, which now keeps each edge's audit and target as Python did. The Python fixed-point and hook-edge implementations are deleted; Python only collects the project facts.
build_native_project_graph only returned project.lineage_graph; its callers now read the attribute.
@kvlonge
kvlonge enabled auto-merge (squash) October 13, 2026 00:33
@kvlonge
kvlonge merged commit 2904c77 into main Oct 13, 2026
40 checks passed
@kvlonge
kvlonge deleted the feat/native-compile-driver branch October 13, 2026 01:51
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