Skip to content

feat(native): validate contracts natively behind the preview engine - #1054

Merged
kvlonge merged 6 commits into
mainfrom
feat/native-contracts
Oct 9, 2026
Merged

kvlonge merged 6 commits into
mainfrom
feat/native-contracts

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Why

M4f ports contract validation and K011 promotion conflicts to the native crate behind native-preview, with byte-identical diagnostics.

Changes

  • sqlbuild-analysis::contracts: K001-K006 and K011 (dynamic proof, promotion conflicts) in Python's order; types via the M4c type system. Python only resolves source locations.
  • CONTRACTS seam now also gates promotion_conflict_diagnostics. Python and shipped engines unchanged.
  • Deferral: unanswerable types or non-ASCII family names go to Python per model and are recorded (contracts/columns.py). None in the corpora; no D2 deviation. Uncached.
  • Tests: Rust units; one parity suite (7 dialects, promotion settings, deferrals); 7 failure-corpus cases; contract E2E case in test_native_type_system.py (three engines).

Changed expectations:

  • test_native_analysis_seams.py: contracts seam [None] -> [ANY] (a ContractValidationResult), new promotion seam [()]; kept feat(native): run semantic checks natively behind the preview engine #1050's semantic and analysis seams.
  • test_native_type_system.py: now runs native too and requires ≥1 native contract result that compared a typed column and 0 handbacks under preview, not "any native normalize answer" (contracts compare types in Rust now).
  • Parity minimums count only natively evaluated models: 800 evaluated (980 seen), 300 typed comparisons (371), 2,000 native diagnostics (2,599); codes only from native diagnostics.

Sabotage (temporary monkeypatch, removed): forcing every model to defer fails the parity gate (native 0 < 800) and both type-system E2E cases (0 typed comparisons, handbacks > 0). It exposed that handed-back models skipped Python's needs-evaluation check; fixed.

Native comparisons skip Python's type-parse debug log.

Verification

  • cargo test --workspace --all-features, clippy/fmt 1.99.0
  • Parity suite; seams, type system, fast_lineage/, semantic_checks, contract E2E
  • make compiler-differential (CI flags), -shipped; differential E2E
  • make test, make check-ci, hygiene

# Conflicts:
#	tests/e2e/src/sqlbuild/cli/commands/main/compile/test_native_analysis_seams.py
…mpared types

The type system E2E now requires at least one native contract result that compared a typed column and no handbacks under preview, so handing typed models back to Python fails it. The parity suite takes code coverage only from natively built diagnostics and counts a model as native only when it needed evaluation.
@kvlonge
kvlonge enabled auto-merge (squash) October 9, 2026 03:44
# Conflicts:
#	tests/e2e/src/sqlbuild/cli/commands/main/compile/test_native_analysis_seams.py
@kvlonge
kvlonge merged commit b930183 into main Oct 9, 2026
71 of 73 checks passed
@kvlonge
kvlonge deleted the feat/native-contracts branch October 9, 2026 06:21
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