Skip to content

Commit 1e859da

Browse files
ahrzbclaude
authored andcommitted
docs: name the training-set round-trip invariant as the standing gate
fit + transform on the training set == the original query with __THIS__ pointing at the training set. Free (the training set is the oracle input), and it survives every loop: today DuckDB plays transform via serving_sql; when infer lands, the same assertion gates the real serving path end-to-end. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 1bbed5f commit 1e859da

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

docs/superpowers/specs/2026-07-29-sql-projection-marginalization-design.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,21 @@ module *interprets* is read through a pydantic view that validates shape at
197197
the read site — a DuckDB format change fails as one named "AST shape drift"
198198
error, not a `KeyError` mid-walk.
199199

200-
## The bulletproof gate
200+
## The bulletproof gate: the training-set round-trip invariant
201201

202-
DuckDB-vs-DuckDB differential — no inference code anywhere, both sides at
203-
`threads = 1` (the only setting where the oracle's own float window
202+
The standing invariant, for this loop and every one after it:
203+
204+
> **fit + transform, applied to the training set, must be bit-equal to
205+
> running the original query with `__THIS__` pointing at the training set.**
206+
207+
It is free — the training set itself is the oracle input, so no expected
208+
values are ever written by hand — and it survives every future widening:
209+
today "transform" is played by DuckDB executing `serving_sql` against the
210+
fitted params; when `infer`/`infer_batch` land, the same assertion runs
211+
through the real serving path (Confit) and gates the wiring end-to-end.
212+
213+
Concretely, DuckDB-vs-DuckDB differential — no inference code anywhere, both
214+
sides at `threads = 1` (the only setting where the oracle's own float window
204215
aggregation is bit-deterministic):
205216

206217
```python

packages/sql-transform/sql_transform/_projection_test.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
"""SQLProjection tests: the DuckDB-vs-DuckDB differential gate.
2-
3-
The bulletproof property: for any accepted projection, running the original
4-
SQL over the training table must be bit-exact with running the rewritten
5-
``serving_sql`` joined against the fitted params — both executed by DuckDB,
6-
the oracle. No inference code is involved anywhere.
1+
"""SQLProjection tests: the training-set round-trip invariant.
2+
3+
The standing invariant for this loop and every one after it: fit + transform,
4+
applied to the training set, must be bit-equal to running the original SQL
5+
with ``__THIS__`` pointing at the training set. It is free — the training set
6+
is the oracle input, so no expected values are written by hand. Today
7+
"transform" is played by DuckDB executing ``serving_sql`` against the fitted
8+
params; when ``infer``/``infer_batch`` land, the same assertion runs through
9+
the real serving path and gates the wiring end-to-end.
710
"""
811

912
import inspect

0 commit comments

Comments
 (0)