spec: canonical type names — step-7 cleanup (header, migration disambig, drop stale history note)

This commit is contained in:
2026-05-11 00:39:42 +02:00
parent 8068be27a1
commit 949785c3aa
+2 -13
View File
@@ -1,6 +1,6 @@
# Canonical Type Names — Module-Scoped Qualification — Design Spec
**Date:** 2026-05-10 (revised twice: once on 2026-05-10, again on 2026-05-11 after user clarification on module-scoped semantics)
**Date:** 2026-05-10 (revised iteratively through 2026-05-11; see git log of this file for the revision sequence)
**Status:** Draft — awaiting user spec review
**Authors:** Brummel (orchestrator) + Claude
@@ -85,7 +85,7 @@ The milestone decomposes into four iterations.
| Iter | Scope |
|------|-------|
| **ct.1** | `.ail.json` schema validator at `load_workspace` (the rule above) + one-time migration. The migration is targeted: a workspace-walker tool (small Rust binary or test-driven script under `crates/ail/src/bin/`) reads every `.ail.json` under `examples/`, finds bare cross-module Type::Con names (i.e. bare names that don't resolve to a local type def in the same file), looks up the qualified form via the import graph, rewrites in place. Files with only intra-module refs are unchanged. Single bulk commit for the rewritten fixtures. The validator also rejects *qualified* class-name fields (`InstanceDef.class`, `SuperclassRef.class`, `Constraint.class`) — those stay bare per the Out-of-scope note. |
| **ct.1** | `.ail.json` schema validator at `load_workspace` (the rule above) + one-time migration. The migration is targeted: a workspace-walker tool (small Rust binary or test-driven script under `crates/ail/src/bin/`) reads every `.ail.json` under `examples/`, finds bare cross-module Type::Con names (i.e. bare names that don't resolve to a local type def in the same file), looks up the qualified form via the import graph (using the same first-match-in-imports-order disambiguation rule the existing imports-fallback uses, so the rewrite never silently changes which type a fixture resolves to), rewrites in place. Files with only intra-module refs are unchanged. Single bulk commit for the rewritten fixtures. The validator also rejects *qualified* class-name fields (`InstanceDef.class`, `SuperclassRef.class`, `Constraint.class`) — those stay bare per the Out-of-scope note. |
| **ct.2** | Remove obsolete typechecker mechanisms that papered over bare cross-module refs: `Pattern::Ctor`'s imports-fallback (iter 15a, ~`crates/ailang-check/src/lib.rs:2486-2521`) and `Term::Ctor`'s synth imports-fallback (iter 23.1.3, ~lib.rs:1979-2025). Both become unreachable because bare-non-primitive type-name reaches them only when local (direct lookup succeeds) — never as a stale cross-module ref. **`qualify_local_types` (iter 15a, ~lib.rs:1848) STAYS** — it correctly handles the cross-boundary translation when a cross-module fn signature is pulled into the current module's typecheck context. Under the new rule it becomes more prominent (called uniformly at every cross-module fn-lookup boundary, where today it runs only at the Term::Var prefix-qualified path); this iter audits its call sites for consistency. |
| **ct.3** | Remove obsolete codegen + mono mechanisms: `lookup_ctor_by_type`'s imports-fallback (iter 23.1.4) and `apply_per_module_ctor_index_overlay` in mono (iter 23.2 fix `84dcc46`). The codegen `lower_workspace_inner` implicit-prelude import_map entry (iter 23.2.4 fix `be882c4`) STAYS — fn-name resolution for mono symbols, not Type::Con names. |
| **ct.4** | DESIGN.md amendments + JOURNAL migration entry + re-baseline of hash-pinned regression tests that touched cross-module-ref fixtures + IR snapshot refresh (where affected). Form-B prose round-trip test extended to cover the qualifier-trim-on-print behaviour for intra-module refs. |
@@ -353,14 +353,3 @@ imports-fallback) becomes an explicit schema violation; the new form
(bare = local, qualified = cross-module) is unambiguous and
verifiable at load time.
## Note on the previous spec revision
A first draft of this spec (committed at `b6a8404`) proposed
qualifying *every* non-primitive Type::Con inline, even within
intra-module references. The user's clarification on 2026-05-11
(noting that `bench_mono_dispatch.ail.json` already has the module
qualifier at the file top and references within are bare) led to
this revised approach. The file IS the module-context unit; bare
references within make sense because the surrounding `"name"` field
disambiguates them. The qualification requirement applies only at
the cross-module boundary, where ambiguity actually exists.