prep.3 — Kernel-tier modules (kernel: true) + param-in restriction #33

Closed
opened 2026-05-28 13:42:23 +02:00 by Brummel · 0 comments
Owner

Third iteration of the kernel-extension-mechanics arc, terminal step. Depends on prep.1 (type-scoped lookup feeds into kernel-tier resolution) and prep.2 (Term::New uses param-in for arg-type checking).

Goal. Generalise the existing single-name hardcoded prelude auto-injection (loader.rs:98-108 + workspace.rs:308-311, 467, 2655) into a flag-driven multi-module mechanism. Add a closed-set type-parameter restriction for TypeDefs.

Scope (from spec § Iteration prep.3):

  • Schema additions in ailang-core/src/ast.rs: Module.kernel: bool (skip_serializing_if=is_false), TypeDef.param_in: BTreeMap<String, BTreeSet<TypeName>> (skip when empty).
  • Form-A surface: (kernel) module-header attribute, (param-in (var t1 t2 ...)) TypeDef attribute.
  • Workspace-load: kernel-tier auto-injection from all kernel: true modules. Prelude gains kernel: true as code-path migration (observable behaviour unchanged — prelude_free_fns.rs regression test stays green).
  • Generic checker enforcement of param-in on Type::Con resolution.
  • New diagnostic: ParamNotInRestrictedSet. WorkspaceLoadError::ReservedModuleName repurposed (any built-in kernel module name reserved, not specifically prelude).
  • New crates/ailang-kernel-stub/ crate as the minimal ratifying fixture (one parametric TypeDef with param-in, one trivial new). Stub exercises the mechanism without domain content.
  • Drift pins: module_kernel_flag_round_trips, typedef_param_in_round_trips, basic stub-module round-trip.
  • Workspace-load tests: auto-import without explicit (import ...) declaration; explicit-import-overrides-auto-import precedence.

Spec: docs/specs/2026-05-28-kernel-extension-mechanics.md § Iteration prep.3.

Whitepaper: design/models/kernel-extensions.md § 3. Kernel-tier modules + § 4. param-in restriction.

Third iteration of the `kernel-extension-mechanics` arc, terminal step. Depends on prep.1 (type-scoped lookup feeds into kernel-tier resolution) and prep.2 (Term::New uses param-in for arg-type checking). **Goal.** Generalise the existing single-name hardcoded prelude auto-injection (loader.rs:98-108 + workspace.rs:308-311, 467, 2655) into a flag-driven multi-module mechanism. Add a closed-set type-parameter restriction for TypeDefs. **Scope (from spec § Iteration prep.3):** - Schema additions in `ailang-core/src/ast.rs`: `Module.kernel: bool` (skip_serializing_if=is_false), `TypeDef.param_in: BTreeMap<String, BTreeSet<TypeName>>` (skip when empty). - Form-A surface: `(kernel)` module-header attribute, `(param-in (var t1 t2 ...))` TypeDef attribute. - Workspace-load: kernel-tier auto-injection from all `kernel: true` modules. Prelude gains `kernel: true` as code-path migration (observable behaviour unchanged — `prelude_free_fns.rs` regression test stays green). - Generic checker enforcement of `param-in` on `Type::Con` resolution. - New diagnostic: `ParamNotInRestrictedSet`. `WorkspaceLoadError::ReservedModuleName` repurposed (any built-in kernel module name reserved, not specifically `prelude`). - New `crates/ailang-kernel-stub/` crate as the minimal ratifying fixture (one parametric TypeDef with `param-in`, one trivial `new`). Stub exercises the mechanism without domain content. - Drift pins: `module_kernel_flag_round_trips`, `typedef_param_in_round_trips`, basic stub-module round-trip. - Workspace-load tests: auto-import without explicit `(import ...)` declaration; explicit-import-overrides-auto-import precedence. **Spec:** docs/specs/2026-05-28-kernel-extension-mechanics.md § Iteration prep.3. **Whitepaper:** design/models/kernel-extensions.md § 3. Kernel-tier modules + § 4. param-in restriction.
Brummel added this to the kernel-extension-mechanics milestone 2026-05-28 13:42:23 +02:00
Brummel added the feature label 2026-05-28 13:42:23 +02:00
Sign in to join this conversation.