Skip to content

feat(v0.44): define compiler intrinsics by binding provenance, not spelling (#1209) - #1250

Merged
SisyphusZheng merged 1 commit into
devfrom
v044/a10.1-intrinsic-provenance
Sep 2, 2026
Merged

feat(v0.44): define compiler intrinsics by binding provenance, not spelling (#1209)#1250
SisyphusZheng merged 1 commit into
devfrom
v044/a10.1-intrinsic-provenance

Conversation

@SisyphusZheng

Copy link
Copy Markdown
Member

Problem

Issue #1209 (umbrella #1155, Alpha.10). The compiler recognized intrinsics by identifier spelling: a third-party element function, an ambient declare function element, or a local class named OpenElement were silently admitted into the OE language grammar (proven at base SHA with a deno eval probe: BASELINE-ADMITS-FOREIGN). Three recognizers disagreed (compile.ts spelling, module-analysis dual-mode, plugin.ts substring).

Owner

Canonical owner: the bundler-neutral compiler semantic core (ADR-0148). This PR REMOVES the spelling recognizers and concentrates all admission/provenance in one model (createModuleIntrinsicBindings/resolveIntrinsic in module-analysis.ts). The plugin.ts substring prefilter remains only as a documented cheap perf gate, explicitly not a recognizer.

Before

Spelling-based admission; foreign/ambient/same-name bindings compiled; import injection papered over missing canonical imports.

After

Intrinsics are binding identities: canonical runtime named import from @openelement/element (or @openelement/app for defineIslandConfig), aliases followed. Bare/global/local/type-only/namespace/default/conflicting/re-export spellings are never admitted — ambiguous provenance fails closed with source-located OEC9027. Codegen follows aliases (extends <localName>). Generated modules strip the compile-time-only element/property bindings. The ui compile-decorators.ts impostor shim is deleted; @openelement/element gains @experimental runtime no-op element/property exports with a documented dual-use contract (inert when evaluated uncompiled; no runtime semantics; not a recognizer).

Why this is not a second semantic owner

Exactly one binding-resolution model used by compile/lowering, module analysis, and diagnostics; the no-op runtime exports are inert evaluation scaffolding, not recognition logic.

Evidence

  • 19 hostile provenance tests (new compiler-intrinsic-provenance.test.ts): all RED at base SHA, all GREEN after — canonical+aliased admission, third-party/local/ambient/shadowing/type-only/namespace/conflicting/re-export rejection, alias-following codegen, import stripping.
  • Fail-closed proven firing in production: mid-implementation the www build failed with exactly 10 OEC9027 diagnostics on the ui shim imports; after the dual-use resolution the same build is exit 0.
  • Gates (all exit 0): adapter-vite 730 passed; element+ui 245; app+create 108; benchmarks/v044; migration tool; fmt/lint/typecheck/arch/freeze-semantics/package-surface/interface:snapshot/export-files/docs:truth; www deno task build; FULL deno task test (1630 + 150 example tests, 0 failed).
  • Executed by a fresh kimi-code/k3-256k HIGH implementer session; two orchestrator-reviewed BLOCKED→repair rounds (scope expansion to generators/fixtures; ui dual-use architecture decision). Orchestrator independently re-verified: 139-file diff, shim deleted, no frozen ADR-0122 paths, hostile tests re-run green.

Scope / non-goals

No Vite/Rollup imports in semantic-core; no public compiler package; no re-export provenance resolution across modules (deliberate — single-module bundler-neutral analysis; fails closed with a clear diagnostic); desktop examples retain local shims (follow-up recorded on the issue).

Risk

User code relying on bare/ambient spellings now fails closed with OEC9027 — intended truth-closure breakage, pre-1.0. expected-program.json regen is position-metadata-only (program semantics byte-identical). Rollback: revert this commit.

…elling (#1209)

Alpha.10 truth closure: the compiler admitted intrinsics by identifier
spelling (getText === 'element'), letting foreign/ambient same-name
bindings into the OE grammar, with three disagreeing recognizers.

- one canonical intrinsic-binding model in the semantic core
  (createModuleIntrinsicBindings / resolveIntrinsic): module specifier +
  imported name, aliases followed; bare/global/local spellings never
  admit; type-only/namespace/default/conflicting/relative-re-export
  provenance fails closed with OEC9027
- compile.ts: every recognition site uses the model; import injection
  deleted; generated modules strip compile-time-only element/property
  bindings; codegen follows aliases
- plugin.ts prefilter documented as a non-recognizer; ambiguous
  provenance routes to the compiler boundary for fail-closed diagnostics
- element gains runtime no-op element/property exports (@experimental
  dual-use contract) so ui/www modules evaluate uncompiled; the ui
  compile-decorators impostor shim is deleted
- all declare-spelling fixtures/templates/www/examples/tools and the
  MDX generator + v0.44 codemod migrated to canonical imports
- 19 hostile provenance tests (RED at baseline) + 3 no-op contract tests

Implemented by fresh kimi-code/k3-256k HIGH session
(.agents/v044-kimi-implementer.md), packet A10.1 with two
orchestrator-reviewed repair rounds (scope expansion + ui dual-use
resolution). No frozen ADR-0122 paths touched. No publish, no tag.
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

APIError: Insufficient Balance

opencode session  |  github run

@SisyphusZheng
SisyphusZheng merged commit b80a4db into dev Sep 2, 2026
9 checks passed
@SisyphusZheng
SisyphusZheng deleted the v044/a10.1-intrinsic-provenance branch September 3, 2026 09:49
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