Skip to content

Commit dd750b1

Browse files
authored
Merge branch 'main' into fix/rename-refusal-mv-hint
2 parents 92d44ab + 4d07a41 commit dd750b1

148 files changed

Lines changed: 7294 additions & 713 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/verify.yml‎

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,13 @@ jobs:
305305
if-no-files-found: warn
306306
retention-days: 30
307307
- name: Compare generated seeds and the failure corpus (python vs shipped native)
308-
run: make compiler-differential-shipped
308+
run: >-
309+
make compiler-differential-shipped
310+
COMPILER_DIFFERENTIAL_ARGS="--stage-captures --require-discovery-coverage
311+
--require-render-coverage"
309312
310313
compiler_differential_python_versions:
311-
name: Native discovery on Python ${{ matrix.python }}
314+
name: Native compiler on Python ${{ matrix.python }}
312315
needs: [changes, lockfile]
313316
if: needs.changes.outputs.compiler_differential == 'true'
314317
runs-on: ubuntu-24.04
@@ -351,9 +354,15 @@ jobs:
351354
uv run --no-sync python -m scripts.run_compiler_differential
352355
--engines python native-preview
353356
--corpus fixtures examples failures seeds --seeds 4 --jobs 4
357+
- name: Compare python with shipped native on the failure corpus and a few seeds
358+
env:
359+
PYTHONUNBUFFERED: "1"
360+
run: >-
361+
uv run --no-sync python -m scripts.run_compiler_differential
362+
--engines python native --corpus failures seeds --seeds 4 --jobs 4
354363
355364
native_discovery_windows:
356-
name: Native discovery on Windows
365+
name: Native compiler on Windows
357366
needs: [changes, lockfile]
358367
if: needs.changes.outputs.compiler_differential == 'true'
359368
runs-on: windows-2025
@@ -388,12 +397,22 @@ jobs:
388397
tests/integration/src/sqlbuild/compiler/discovery/test_native_yaml_oracle.py
389398
tests/integration/src/sqlbuild/compiler/discovery/test_native_toml_oracle.py
390399
-n auto --dist loadfile
391-
- name: Compile and build playground projects
400+
- name: Compile playground projects on the default and Python engines, and build
392401
run: |
393402
project="${RUNNER_TEMP}/waffle-shop"
403+
oracle="${RUNNER_TEMP}/waffle-shop-python"
394404
uv run --no-sync sqb playground "${project}"
405+
cp -r "${project}" "${oracle}"
395406
uv run --no-sync sqb --project-dir "${project}" --no-color compile
396-
SQLBUILD_COMPILER_ENGINE=python uv run --no-sync sqb --project-dir "${project}" --no-color compile
407+
SQLBUILD_COMPILER_ENGINE=python uv run --no-sync sqb --project-dir "${oracle}" --no-color compile
408+
diff -r "${oracle}/target/compiled" "${project}/target/compiled"
409+
if ! test -f "${project}/target/cache/compiler-native-v1/macro-calls.bin"; then
410+
echo "The default compile did not write the macro-call store; macro bridge debug log:"
411+
rm -rf "${oracle}/target"
412+
uv run --no-sync sqb --project-dir "${oracle}" --no-color --debug compile 2>&1 \
413+
| grep "macro_bridge" || true
414+
exit 1
415+
fi
397416
uv run --no-sync sqb --project-dir "${project}" --no-color build
398417
nodes="${RUNNER_TEMP}/python-nodes"
399418
uv run --no-sync sqb playground --template python_nodes "${nodes}"
@@ -561,15 +580,11 @@ jobs:
561580
strategy:
562581
fail-fast: false
563582
matrix:
564-
# Temporary: a one-model edit recompiles the edited model uncached until native
565-
# rendering becomes the default; tighten edit_max_ratio back to max_ratio then.
566583
include:
567584
- kind: dense
568585
max_ratio: "1.10"
569-
edit_max_ratio: "1.25"
570586
- kind: fresh
571587
max_ratio: "1.10"
572-
edit_max_ratio: "1.20"
573588
steps:
574589
- uses: actions/checkout@v4
575590
- name: Check out the comparison base
@@ -600,13 +615,11 @@ jobs:
600615
env:
601616
KIND: ${{ matrix.kind }}
602617
MAX_RATIO: ${{ matrix.max_ratio }}
603-
EDIT_MAX_RATIO: ${{ matrix.edit_max_ratio }}
604618
run: |
605619
uv run python -m scripts.compare_compile_performance \
606620
--kind "${KIND}" \
607621
--modes cold warm edit \
608622
--max-ratio "${MAX_RATIO}" \
609-
--edit-max-ratio "${EDIT_MAX_RATIO}" \
610623
--models 3000 \
611624
--base-root base \
612625
--base-python base/.venv/bin/python \

‎.release-please-manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.145.0"
2+
".": "0.147.0"
33
}

‎CHANGELOG.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## [0.147.0](https://github.com/chio-labs/sqlbuild/compare/v0.146.0...v0.147.0) (2026-10-09)
4+
5+
6+
### Features
7+
8+
* **native:** make native rendering the default compiler path ([#1043](https://github.com/chio-labs/sqlbuild/issues/1043)) ([95491e1](https://github.com/chio-labs/sqlbuild/commit/95491e1ed70afe8c834da7841297f7d9663699fc))
9+
* **native:** report SQL test and scenario errors natively ([#1046](https://github.com/chio-labs/sqlbuild/issues/1046)) ([0e87c96](https://github.com/chio-labs/sqlbuild/commit/0e87c96b2e940e025bf2bb771d48ee7f317eadb1))
10+
11+
## [0.146.0](https://github.com/chio-labs/sqlbuild/compare/v0.145.0...v0.146.0) (2026-10-08)
12+
13+
14+
### Features
15+
16+
* **native:** report reference extraction errors natively ([#1037](https://github.com/chio-labs/sqlbuild/issues/1037)) ([8dc2d1e](https://github.com/chio-labs/sqlbuild/commit/8dc2d1e203e3fd3a7cc411d9b4d583435ab911dc))
17+
318
## [0.145.0](https://github.com/chio-labs/sqlbuild/compare/v0.144.0...v0.145.0) (2026-10-08)
419

520

‎Cargo.lock‎

Lines changed: 14 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ python-boundary = "sqlbuild-python"
3737
polyglot-floor = "sqlbuild-analysis"
3838

3939
[workspace.package]
40-
version = "0.145.0"
40+
version = "0.147.0"
4141
edition = "2024"
4242
license = "Apache-2.0"
4343
publish = false

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ compiler-differential:
300300
$(COMPILER_DIFFERENTIAL_ARGS)
301301

302302
# python vs native-preview above covers every native stage; this keeps the shipped `native` default
303-
# covered on a bounded corpus.
303+
# (native discovery and rendering) covered on a bounded corpus.
304304
compiler-differential-shipped:
305305
env PYTHONUNBUFFERED=1 uv run python -m scripts.run_compiler_differential \
306306
--engines python native --corpus seeds failures \

‎crates/README.md‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ that can be tested and benchmarked with `cargo test` alone.
1111
| `sqlbuild-sqltext` | Lexical SQL text without polyglot: comment, quote and parenthesis scanning, the rules quote policy, model header tokenization and matching, static variable substitution, static reference extraction, and the general reference scan with table-function call arguments under each adapter's lexical rules. |
1212
| `sqlbuild-config` | Configuration file reading without Python: `tomllib`-compatible TOML, PyYAML `safe_load`-compatible YAML 1.1, and typed project and local config readers for the fields discovery needs. Errors carry their kind and position; YAML outside the supported subset is an `Unsupported` error. |
1313
| `sqlbuild-discovery` | Native project discovery and the only implementation of the model, SQL test, scenario, source and schema file collections and the declaration layout: the shared directory walk with Python's glob and sort semantics, file reading with Python's newline handling and read errors, and parsing of authored files with Python's exact discovery messages. Results are plain data the Python discovery facade materialises. |
14-
| `sqlbuild-scopes` | Declaration scopes: the scope index with Python's record orders and diagnostics, declaration visibility, relationship grants, the scope lookup groups, and the dialect-aware scan of SQL tests and scenarios for their expected models. Anything it cannot reproduce exactly defers to Python. |
14+
| `sqlbuild-scopes` | Declaration scopes: the scope index with Python's record orders and diagnostics, declaration visibility, relationship grants, the scope lookup groups, and the dialect-aware scan of SQL tests and scenarios for their expected models and top-level CTEs, with Python's scanner errors. Anything it cannot reproduce exactly defers to Python. |
1515
| `sqlbuild-model-config` | Model configuration: MODEL header columns and audits, `${...}` template expansion with its environment and context reads, and the template and macro presence scans over authored config values, all read through a trait over the caller's values. Anything it cannot reproduce exactly defers to Python, which also raises every model config error. |
1616
| `sqlbuild-render` | Native rendering: the macro call scanner (a byte-for-byte port of Python's), splicing of rendered calls with code-point spans, and the in-compile memo of recorded macro calls and their replayable events, which can carry results across compiles through the shared native store. Anything it cannot reproduce exactly defers to Python. |
1717
| `sqlbuild-attachments` | Compile attachments for tests, audits, sources, functions, scenarios and seeds: attached generic audit argument merge, raw and quoted argument rendering, and severity and run scope resolution. Anything it cannot reproduce exactly defers to Python, which also raises every attachment error. |
18-
| `sqlbuild-analysis` | SQL analysis over polyglot: SQL tokens, query analysis, the binding catalog, semantic validation and usage, column references, type normalization, and SQL-test extraction, planning and rendering. Type normalization defers to Python for anything it cannot reproduce exactly. |
18+
| `sqlbuild-analysis` | SQL analysis over polyglot: SQL tokens, query analysis, the binding catalog, semantic validation and usage, column references, type normalization, and SQL-test and scenario extraction, planning and rendering. Type normalization defers to Python for anything it cannot reproduce exactly. |
1919
| `sqlbuild-rules` | Built-in rules and the rules engine, the custom-rule host, SQL lint, quality checks and formatting, rules configuration and the request models. It also owns the build identity script. |
2020
| `sqlbuild-python` | The only PyO3 crate: the `_native` module, its Python classes and functions, conversions from Python objects, and the process allocator. |
2121

@@ -31,7 +31,7 @@ sqlbuild-python
3131
```
3232

3333
`sqlbuild-config` and `sqlbuild-model-config` do not depend on the crates below them today, and
34-
`sqlbuild-scopes` uses only `sqlbuild-sqltext`; their place in the order fixes which crates may
34+
`sqlbuild-scopes` uses only `sqlbuild-sqltext` and `sqlbuild-core`; their place in the order fixes which crates may
3535
use them. The JSON emitter
3636
lives in `sqlbuild-core` so that any layer can produce text that must equal Python's
3737
`json.dumps` output.
@@ -62,6 +62,15 @@ stages run natively:
6262
| `native` | The default: native stages that passed their flip gate (`shipped` tier). |
6363
| `native-preview` | Opt-in: shipped stages plus stages still in development (`preview` tier). |
6464

65+
The shipped tier covers discovery and rendering: declaration files and scopes, model config,
66+
reference extraction, the model loop, macro calls and the macro-call store, and attachments. SQL
67+
analysis, contracts, lineage, SQL-test glue and project assembly are still `preview`. A failing
68+
render raises its first error directly, as the Python stage would, and runs each macro call at
69+
most once; a divergence the bridge detects is reported as a native stage mismatch. Because the
70+
macro-call store is shipped, the
71+
[macro determinism contract](../website/src/content/docs/docs/concepts/macros.mdx) applies to
72+
every default compile; `SQLBUILD_COMPILER_ENGINE=python` runs every macro call each time.
73+
6574
Each native stage declares its tier once, in `NATIVE_STAGE_TIERS` in
6675
`src/sqlbuild/compiler/frontier/constants.py`. A stage moves from `preview` to `shipped` by
6776
changing that line, after its flip gate passes: a byte-identical real project, a green
@@ -70,8 +79,10 @@ its own compiler, Rules and compile-reuse stores, so preview output is never reu
7079

7180
`make compiler-differential` compares `python` with `native-preview` on the full per-PR corpus.
7281
`make compiler-differential-shipped` compares `python` with `native` on the generated seeds and
73-
the failure corpus, so the shipped default stays covered on its own. CI runs both, and compares
74-
`python` with `native` on Python 3.13 and 3.14 as well.
82+
the failure corpus, so the shipped default stays covered on its own; CI runs it with stage
83+
captures and requires full discovery and render coverage. CI runs both, compares `python` with
84+
`native` and `native-preview` on Python 3.13 and 3.14 as well, and on Windows checks that the
85+
default compiles a playground project to the same files as `python`.
7586

7687
## Working on the crates
7788

‎crates/sqlbuild-analysis/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ serde.workspace = true
2121
serde_json.workspace = true
2222
sha2.workspace = true
2323
sqlbuild-core.workspace = true
24+
sqlbuild-scopes.workspace = true
2425
sqlbuild-sqltext.workspace = true
2526

2627
[lints]

0 commit comments

Comments
 (0)