Skip to content

feat(compiler): add compiler engine switch and differential harness - #987

Merged
kvlonge merged 6 commits into
mainfrom
feat/compiler-differential-harness
Oct 6, 2026
Merged

kvlonge merged 6 commits into
mainfrom
feat/compiler-differential-harness

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Why

The native compiler rewrite needs a per-invocation engine switch and a gate proving both engines produce identical compile output. No stage is native yet, so native runs the Python stages through the new seam.

Changes

  • SQLBUILD_COMPILER_ENGINE (python default, or native) and a hidden --compiler-engine global option. Invalid values fail at parse time.
  • One compile_frontier seam with a CompilerStage enum around discovery, compile inputs and the compiled project. SQLBUILD_COMPILER_STAGE_CAPTURE_DIR dumps each stage in insertion order (only sets and compile memo maps are sorted).
  • compile --json reports compiler_engine; sqb debug shows it.
  • Native compiler, Rules (including the Rust bulk cache, now passed by Python) and lineage stores use -native-v1 paths; Python paths are unchanged. The resolved engine is in the reuse key, so unset and python share entries; the capture dir is excluded.
  • scripts/compiler_differential compares exit codes, normalised stdout/stderr, target/compiled, manifest, DAG, per-model fingerprints and stage captures. Every corpus entry declares an expected outcome (--expect success|failure:<CODE> for --project); any timeout fails.
  • Corpora: e2e fixtures, website examples, seeded projects, ~50 failure cases, dense projects with and without custom rules.
  • Per-PR Verify job (with stage captures) and a nightly dense 3k/10k workflow.

Verification

  • Unit: switch, override, cache namespacing, reuse key, capture ordering, harness options, corpus expectations, generator, failure corpus. Rust: configured cache path.
  • E2E: engine parity; store isolation for compile and sqb rules; perturbation detection; a broken project fails unless its failure is declared.
  • make compiler-differential with captures: 69 projects identical in 58s on 4 jobs.
  • make check-ci, Rust fmt/clippy/tests (1.98.0), fensu dupes, public-repository scan.

@kvlonge
kvlonge enabled auto-merge (squash) October 6, 2026 19:36
@kvlonge
kvlonge force-pushed the feat/compiler-differential-harness branch from 9f842c8 to 1efd351 Compare October 6, 2026 20:04
Select the compiler engine with SQLBUILD_COMPILER_ENGINE (python by
default, or native) or the hidden --compiler-engine global option. All
frontier stages run through one compile_frontier seam; the native engine
currently falls back to the Python stages. Compile JSON and sqb debug
report the engine, compile reuse keys include it, and the native engine
keeps its compiler, Rules and lineage stores in -native-v1 directories so
the Python stores stay untouched.
Compare exit codes, normalised stdout and stderr, the compiled tree,
manifest, DAG and per-model query fingerprints between two engines over
the e2e fixtures, website examples, seeded generated projects, a failure
corpus and dense projects, with optional per-stage captures.
itertools.count is not subscriptable at runtime before Python 3.13, so the
ClassVar annotation failed at import on 3.12.
@kvlonge
kvlonge force-pushed the feat/compiler-differential-harness branch from 2b6309e to f489772 Compare October 6, 2026 21:00
@kvlonge
kvlonge merged commit 94683ca into main Oct 6, 2026
65 of 67 checks passed
@kvlonge
kvlonge deleted the feat/compiler-differential-harness branch October 6, 2026 21:41
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