Skip to content

feat(native): resolve declaration contexts and references natively in the preview model loop - #1012

Merged
kvlonge merged 4 commits into
mainfrom
feat/native-model-loop
Oct 7, 2026
Merged

kvlonge merged 4 commits into
mainfrom
feat/native-model-loop

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Why

The preview engine still resolves each model's declarations in Python. Working out which enums,
constants and macros a model can see, and finding its @enum/@const references, is lookup and
text-scanning work that the native scope index and SQL scanner can do without changing results.

Changes

  • Register a preview-tier native stage, model_loop, for the model compile loop.
  • Classify each indexed consumer's declaration context natively from the scope lookup (global,
    private, local, inherited and relationship-granted declarations) and build the same Python
    context objects. Unindexed paths, and path targets the scope query reads as qualified
    identities, keep the Python resolver and its errors.
  • Scan the @enum/@const references of every model in one native batch using Python's quote,
    comment and dollar-quote rules. Values are still rendered in Python; malformed references,
    unclosed text, Unicode word boundaries, unknown names and render errors fall back to the
    Python expansion, which reports the exact error.
  • Native context classification runs inside the compiler panic boundary.
  • Native model config mismatches now raise the shared NativeStageMismatchError.
  • Stage captures can omit declared dataclass fields, keeping the native context handle out of
    the compiler differential.

Verification

  • make compiler-differential and make compiler-differential-shipped identical; compiler
    differential e2e tests pass.
  • Seeded parity tests for declaration contexts and 3,000 generated SQL strings; CLI parity tests
    for folder-private references and a model folder containing :.
  • make check-ci, make test, Rust clippy, fmt and workspace tests.

@kvlonge
kvlonge enabled auto-merge (squash) October 7, 2026 20:48
@kvlonge
kvlonge force-pushed the feat/native-model-loop branch from 67933b4 to 805afc8 Compare October 7, 2026 21:38
@kvlonge
kvlonge force-pushed the feat/native-model-loop branch from 805afc8 to 7a14a99 Compare October 7, 2026 22:19
@kvlonge
kvlonge merged commit b5a2453 into main Oct 7, 2026
37 checks passed
@kvlonge
kvlonge deleted the feat/native-model-loop branch October 7, 2026 23:03
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