Third docwriter mission (combined). Pure rustdoc additions, no
API or behaviour change.
ailang-codegen (113 LOC of doc):
- Crate root: intra-doc links (emit_ir, lower_workspace,
CodegenError::MissingEntryMain) + precondition note (both
entry points assume type-checked input).
- /// on CodegenError + every variant, naming AST trigger.
- /// on emit_ir and lower_workspace (single vs multi-module
split, cross-linked).
ail CLI (49 LOC of doc):
- Module-level //! expanded from 5 lines to full subcommand
list with one-liners (11 subcommands verified against Cmd
enum), clang-on-PATH note, design-intent paragraph.
Verification: cargo doc --no-deps zero warnings (also under
RUSTDOCFLAGS='-D rustdoc::broken_intra_doc_links'); build green;
tests 64/64 + 3 ignored doctests green. Diff is 100% doc lines
(verified by filtering).
Findings (not fixed; orchestrator-deferred):
- CodegenError::Internal is one catch-all variant for ~30
invariant-violation sites; splitting would help test
ergonomics but is out of doc scope.
- emit_ir synthesises a Workspace with root_dir="."; harmless
today, surfaces if codegen ever reads root_dir.
Process note: my brief said the CLI had 9 subcommands; agent
found and documented 11. Useful counter-pressure on orchestrator
sloppiness — recorded in JOURNAL.
Workspace-wide rustdoc invariant (DESIGN.md item 6) now
load-bearing across all four crates. Docwriter shifts from
sweep to maintenance mode going forward.
Next: 14a (polymorphic list_map using Iter-13a parameterised
ADTs) is unblocked.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Second docwriter mission. Pure rustdoc additions (no API or
behaviour change) across the typechecker crate:
- builtins.rs: module root expanded; EffectOpSig (struct + 3
fields) and install() got /// strings.
- diagnostic.rs: Severity (+ both variants), Diagnostic (+
severity/code/message fields) and the error/with_def/with_ctx
helpers got /// strings; super:: link rewritten to crate::.
- lib.rs: CheckError + every variant, to_diagnostic, CheckedModule
(+ symbols), check, Env (+ globals/effect_ops/types/
module_globals/current_module), CtorRef (+ type_name) got ///
strings; crate-root prose upgraded with intra-doc link to
check_module.
Verification: cargo doc --no-deps zero warnings; cargo build
--workspace green; cargo test --workspace 64/64 + 3 ignored
doctests green. Diff is 188 LOC, all in /// or //! lines (verified
by filtering).
Findings (not fixed; orchestrator-deferred):
- Env is pub but only privately constructable.
- CheckError::CtorArity and ::ArityMismatch share the public
diagnostic code "arity-mismatch" by design.
- Diagnostic / Severity reachable via two paths because the
diagnostic module is pub.
JOURNAL.md updated with the Iter 13e entry. 13f (ailang-codegen
+ ail) and 14a (List a rewrite) remain queued.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds ailang-docwriter to /agents/ — a recurring role for keeping
crate-, module-, and pub-item-level rustdoc accurate. First mission:
ailang-core. Crate root, every module root, every pub item documented;
intra-doc links throughout; Iter-13a additions (TypeDef.vars, Type::Con.args)
get an explicit backwards-compat note. Two stale broken-link warnings in
ailang-check fixed in passing. cargo doc --no-deps now warning-free across
the workspace; promoted to verification invariant 6 in DESIGN.md.
DESIGN.md: removes "No parameterised ADTs" from the gap list,
adds an entry under "what is supported" that names the per-use-
site substitution scheme and the `llvm_type(Type::Var)` hard-error
defence. Smoke-test list extended with `box.ail.json` and
`maybe_int.ail.json`. Boundary snapshot moved from "end of Iter 12"
to "end of Iter 13".
JOURNAL.md: single Iter 13 entry covering 13a/b/c. Records the
hash-invariant regression test, the architect-flagged debt I
deliberately did not touch (poly-fn-as-value asymmetry, builtins
triple-source, `synth_arg_type` shortcuts on If/Match), the
KISS observation that 13b's "no mono-queue for types" was the
right call, and the process note that this was the first iter
worked strictly through `/agents/` after the role pin in 3df943d.
Plan iteration 14 queued: list_map-as-`List a` rewrite, GC/arena,
poly-fn-as-value.
Closes the gap between Iter 13a (parameterised ADTs in the
checker) and end-to-end execution. ADT ctor code stays inlined at
every use site — no mono-queue for types, no new symbols — but
LLVM field types are now derived per use site via substitution.
`CtorRef` gains `type_vars: Vec<String>` so use sites can identify
which fields reference rigid vars. `cref.fields` (precomputed
LLVM strings) is documented as monomorphic-only and read past for
parameterised ADTs.
`lower_ctor`: derives a `BTreeMap<String, Type>` substitution from
`synth_arg_type` of each arg via `unify_for_subst`, then maps every
`ail_field` through `apply_subst_to_type` + `llvm_type` for the
per-store types. Monomorphic ADTs hit the original fast path.
`lower_match`: builds `arm_subst` from `s_ail.args` ↔ `cref.type_vars`,
substitutes through each `cref.ail_fields[idx]`, and uses the
substituted type both for the LLVM `load` AND as the AILang slot
of the local — so a downstream `unbox(b)` sees `b: Int`, not
`b: a`.
`synth_arg_type` for `Term::Ctor`: returns concrete type-args
derived from the ctor's term-args. Vars left unpinned (e.g. `None`
for `Maybe a`) fall back to `Type::unit()`.
`llvm_type(Type::Var)` now hard-errors. Earlier this silently
fell through to `ptr` (the ADT-via-ptr fallback), producing
garbage IR. Failing loudly here surfaces missed substitutions in
the test suite.
Two e2e tests (`box.ail.json`, `maybe_int.ail.json`) cover ctor
lower with substituted field types and match-arm field
substitution. 64 tests green; clippy clean (two pre-existing
warnings untouched). Hash invariant holds.
Out of scope per agent assignment: poly-fn-as-value, higher-rank
polymorphism, DESIGN/JOURNAL updates (deferred to 13c).
Adds an explicit "My role: orchestrator" section so the discipline
doesn't drift across sessions. Three concrete contracts:
- What I do myself (planning, design, JOURNAL/DESIGN) vs. what gets
delegated (implementation, testing, debugging, architectural
drift review). Trivial mechanical edits stay inline.
- Authority over /agents/: I may add, edit, retire, or replace agent
definitions when orchestration needs change, with the change going
through git like any other code.
- When NOT to delegate: direct user questions, single judgement
calls, and cases where context is already loaded.
Triggered by a session where I quietly took over implementer work
on Iter 13a instead of routing it through ailang-implementer.
Adds type parameters to ADTs. `TypeDef` gets a `vars: Vec<String>` and
`Type::Con` gets an `args: Vec<Type>`, both `skip_serializing_if =
"Vec::is_empty"` so canonical-JSON hashes of every pre-13a definition
stay bit-identical (regression test in `hash::tests`).
Checker:
- `check_type_def` installs `td.vars` as rigid vars while validating
ctor field types — `Cons(a, List a)` now resolves both occurrences
of `a` and the recursive `List a` use.
- `check_type_well_formed` accepts `Type::Con { name, args }` only
when the type is in scope and `args.len()` matches its declared
arity; primitives stay zero-arg.
- `Term::Ctor` synth instantiates `td.vars` with fresh metavars, so
`MkBox(42)` synthesises to `Box<$m0>` and unifies field types
through the surrounding context.
- `type_check_pattern` substitutes the scrutinee's concrete type-args
through ctor field types, so a `MkBox(x)` arm against a `Box<Int>`
scrutinee binds `x : Int`.
- `check_fn` validates declared param/return types via
`check_type_well_formed` so arity mismatches on parameterised
ADTs surface before the body is checked.
`unify`, `occurs`, `Subst::apply`, `substitute_rigids`, and codegen's
`unify_for_subst` / `apply_subst_to_type` recurse into `args`.
Pretty-print:
- `type_to_string` renders `Box<Int>` for parameterised cons.
- `def_block`/`manifest` carry the `[a b ...]` vars list.
Three new check unit tests cover ctor instantiation at a concrete
arg, the polymorphic-`unbox` round trip at two distinct
instantiations, and arity mismatch on `Box<Int, Bool>`. All 62 tests
green; clippy clean (two pre-existing warnings untouched). Hashes
db33f57cb329935e (sum) and b082192bd0c99202 (IntList) verified
unchanged.
Codegen still synthesises `Type::Con` with `args: vec![]` from
`Term::Ctor` — full ADT monomorphisation lands in 13b.
DESIGN.md:
- "What is not (yet) supported" updated for end-of-Iter-12 boundary:
parameterised ADTs replace HM-inside-bodies as the headline gap;
polymorphism limitations (direct-call-only, no higher-rank) are
spelled out so future me doesn't trip over them.
- "What is supported" gains the polymorphism + monomorphisation
bullet, with the descriptor scheme written out.
- Smoke-test list extended with poly_id and poly_apply.
JOURNAL.md: Iter 12a/b retrospective. Notes the metavar-encoding
choice (Type::Var{name:"$m<n>"} vs new variant) and why the
codegen-side type tracker was preferable to a typechecker
sidetable for now. Architecture self-check confirms the language
is now usable for poly-flavoured programs over primitives. Plan 13:
parameterised ADTs as the natural next step (without them, generic
map remains hand-monomorphised).
Iter 12c was originally to include a polymorphic map rewrite —
dropped because parameterised ADTs are the prerequisite. The two
new examples (poly_id, poly_apply, both already in 12b) cover the
real e2e proof.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Polymorphic defs are now actually emitted: each unique instantiation
gets its own specialised LLVM fn, mangled @ail_<m>_<def>__<descriptor>.
The typechecker's Forall instantiations from Iter 12a now have a real
backend.
Strategy:
- Pass 1 of lower_workspace splits fn-typed defs into mono and poly:
module_user_fns keeps LLVM-typed FnSig only for monomorphic fns;
module_polymorphic_fns holds the full FnDef for poly defs;
module_def_ail_types is a unified AILang-type lookup for both.
- Direct calls to poly defs (current-module or qualified cross-module)
flow through lower_polymorphic_call: it derives the type
substitution from the actual arg AILang types, mangles the symbol,
and queues (def, subst) for specialisation.
- emit_module drains the queue after the regular defs. Each entry
produces a specialised FnDef with rigid vars substituted in both
the type and the body (incl. Lam param/ret annotations), then
emits via the existing emit_fn pipeline. The synthetic name embeds
the descriptor; standard mangling produces the right symbol.
Codegen-side type tracking:
- locals tuple grew from (name, ssa, llvm_type) to 4-tuple with
ail_type. Updated all 6 push sites: fn entry, Let, match-ctor field,
match-open-arm, lambda capture (cap_meta also extended), lambda
param.
- CtorRef gained ail_fields parallel to fields, used by match-arm
bindings to inherit AILang types.
- New synth_arg_type / synth_with_extras: a small recursive walker
that derives the AILang type of an expression in the current scope.
Used at poly call sites for arg-type inference. The `extras`
parameter shadows locals during Let recursion without &mut self.
Helpers added:
- derive_substitution(vars, params, arg_tys): unifies the param
shapes against the actual args, binding rigid vars; reports
unbound vars as an internal error.
- apply_subst_to_type / apply_subst_to_term: substitute rigid vars
throughout a Type or Term (the Term variant only matters for Lam,
the only Term arm carrying types).
- descriptor_for_subst / type_descriptor: stable identifier-safe
name suffix. `Int → I`, `Bool → B`, `Unit → U`, `Str → S`, ADT
`Foo → FFoo`, `Fn → Fn_<...>__r_<ret>`. So `id__I` for id at Int,
`apply__I_I` for apply at (Int, Int).
- builtin_ail_type / builtin_effect_op_ret: AILang types for the
builtin operators and effect ops, used by the codegen-side type
tracker.
Examples + tests:
- examples/poly_id.ail.json: id used at Int (42) and Bool (true).
Output: 42 / true. Two specialised fns + adapters + static
closures get emitted (visible in the IR).
- examples/poly_apply.ail.json: apply(succ, 41) == 42. Exercises
the harder case where one of the polymorphic params is itself
a function value — the closure-pair ABI survives substitution.
- crates/ail/tests/e2e.rs: polymorphic_id_at_int_and_bool and
polymorphic_apply_with_fn_param.
Tests: 58/58 (was 56/56). Hash invariant holds: sum.ail.json keeps
db33f57cb329935e / d9a916a0ed10a3d3.
Limitations (known, deferred):
- Polymorphic fns can only be DIRECTLY called. Passing a poly fn as
a value (let f = id in f(42)) fails — resolve_top_level_fn looks
in module_user_fns which doesn't include poly defs. Adding this
needs per-instantiation closure-pair globals.
- No higher-rank polymorphism: a polymorphic arg passed to another
polymorphic call (apply(id, 42)) trips the simple unify_for_subst
which doesn't recurse into Forall. Acceptable for the MVP.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Polymorphism is now opt-in via Type::Forall at top-level def types.
Implementation is the textbook ML rule: peel the Forall when checking
the def body, instantiate fresh metavars at every use site, unify.
Mechanics:
- New Subst struct + unify(): standard occurs-check unification, with
effects compared as a set.
- Metavars encoded inside the existing Type::Var as Type::Var{name:
"$m<id>"}. The "$" prefix can't collide with source-level identifiers,
so the AST schema stays untouched and existing module hashes don't
shift (verified: sum.ail.json keeps db33f57cb329935e / d9a916a0ed10a3d3).
- check_fn peels an outer Forall and installs the rigid vars in
Env.rigid_vars, where check_type_well_formed accepts them. Inner
forall vars unify only with themselves.
- Term::Var lookup runs maybe_instantiate on the resolved type, so
polymorphic globals get fresh metavars at each occurrence. Two
use sites of the same `id` get independent ($m0)→$m0 and ($m1)→$m1
shapes — no bleed.
- All expect_eq calls inside synth replaced with unify; expect_eq is
still used for the App-arity / etc. structural checks where no
metavars can appear.
Constraints kept tight on purpose:
- Const types may not be Forall (rejected outright).
- Forall in ADT field positions still rejected.
- No higher-rank polymorphism: App's callee can be Forall (defensive
instantiate) but the body doesn't introduce new quantifiers.
- No let-generalisation of lambdas — all polymorphism is at top-level
defs only.
Codegen still rejects Forall types, so polymorphic programs typecheck
but don't yet compile. Iter 12b adds monomorphisation.
Tests: 14/14 (was 10/10) — added polymorphic_id_def_typechecks,
polymorphic_id_can_be_used_at_int_and_bool,
polymorphic_id_consistency_is_enforced, polymorphic_apply_with_two_vars.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Four small cleanups, no semantic change. Workspace is now clippy-
clean (default lints):
- ailang-check: collapse `if-same-then-else` for primitive vs ADT
type lookup into one branch via a local boolean.
- ailang-codegen: iterate `all_strings.values()` directly instead of
`for (_mname, entries) in &all_strings`.
- ailang-codegen: drop `import_map` parameter from `collect_captures`
— was threaded speculatively through every recursive call but
never read.
- ailang-codegen: `s.len()` instead of `s.as_bytes().len()` in
c_byte_len (the warning predates Iter 6).
Tests: 52 still green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
examples/sort.ail.json: insertion sort over IntList. Defines `insert
:: Int -> IntList -> IntList` and `sort :: IntList -> IntList`
recursively, plus print_list using Iter 10's seq. Sorts an 11-element
input and prints `1 1 2 3 3 4 5 5 5 6 9` one-per-line.
Validates that the language handles deeper ADT recursion + branching
(if + <=) + ctor construction + IO sequencing without surprises.
Wrote, typechecked, ran first try.
The Iter 11 plan called for polymorphism, but on reflection the right
move was one more validation cycle before disturbing the pipeline.
Polymorphism is now queued explicitly as Iter 12 (12a typechecker
substitution, 12b codegen monomorphisation, 12c docs + generic
example).
Tests: 52 green (was 51). New e2e `insertion_sort_orders_list`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds `Term::Seq { lhs, rhs }` (serde tag "seq") as a first-class
AST node for sequencing effectful expressions. Equivalent in
behaviour to `let _ = lhs in rhs`, but the dedicated node gives the
pretty-printer and diagnostics a cleaner shape and surfaces the
intent ("run for effect, then yield rhs") to future tooling.
Typecheck: lhs must be Unit; rhs's type is the result; effects
accumulate.
Codegen: lower lhs (drop SSA), lower rhs (return).
Capture / deps walkers: recurse into both sides.
Refactored examples/list_map.ail.json's print_list to use seq
instead of `let _ = ...`. Output unchanged (2/4/6).
Hash stability: existing examples without Term::Seq serialise
bit-identical; only list_map.ail.json's hashes changed (deliberate
refactor).
Tests: 51 green (was 50). New unit test
`ailang_check::tests::seq_lhs_must_be_unit` covers the type-error
path; existing list_map e2e covers the happy path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
DESIGN.md:
- CLI block: add `ail run`.
- Smoke-test list: add list_map.ail.json (the dogfood example).
JOURNAL: append Iter 9 entry covering the dogfood result, two
friction points surfaced (single-arg fn-type pretty-print parens;
absence of a sequencing operator), the `ail run` CLI helper, and a
ranked Iter 10 plan with three candidates (polymorphism, `;`, GC).
Tentative pick is (2) `;` next, (1) polymorphism for Iter 11.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Iter 9a — dogfood. examples/list_map.ail.json exercises everything
Iter 1-8 shipped in one program: ADTs (IntList = Nil | Cons Int IntList),
recursive fns over the ADT (map_int, print_list), pattern matching with
nested Var fields, a closure (`\\x. x * 2`, no captures), fn-typed
parameters, IO effects propagating through recursion, and `let`-
sequencing of an effectful sub-expression inside a match arm.
Result: nothing broke. The full pipeline (typecheck → IR emit →
clang → run) produces "2\\n4\\n6\\n". The language is now sufficient
for "small but real" programs.
Iter 9b — `ail run`. Convenience subcommand that builds into a
tempdir and executes, propagating the binary's exit code. Equivalent
to `ail build && ./bin` in one step. Build logic factored out of
`Cmd::Build` into a shared `build_to` helper used by both Build and
Run.
Tests: 50 green (was 49). New e2e `list_map_doubles_then_prints`.
No test for `ail run` itself — the existing build_and_run helper in
e2e.rs already exercises the same build+exec sequence path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
DESIGN.md:
- Term schema: add `ctor`, `match`, `lam` rows. The schema fragment is
now exhaustive for the supported language; prior versions silently
dropped Iter 3/Iter 8 additions.
- "What is not (yet) supported": closures-with-capture moves out of
pending. New positive bullet for anonymous lambdas. Polymorphism
added as an explicit pending bullet (Forall is parseable but not
inferred). Smoke-test list extended with closure.ail.json.
JOURNAL: append Iter 8 entry covering both 8a (closure-pair ABI) and
8b (Term::Lam + capture). Includes the rationale for skipping TIR
(KISS won — `synth` already provides enough type info), the closure-
conversion sketch, hash stability check (existing examples produce
the same fn hashes pre vs post Iter 8), and the Iter 9 plan with
two candidates ranked.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds anonymous functions to AILang. A lambda value is constructed by
malloc'ing an env struct that holds its captured locals, plus a
closure pair `{ thunk_ptr, env_ptr }` (Iter 8a's ABI). The lambda's
body lifts to a top-level thunk `@ail_<m>_<def>_lam<id>(ptr %env,
params...)` that unpacks captures back into named locals before
running.
AST: new Term::Lam { params, paramTypes, retType, effects, body }.
Serde tag is "lam"; existing modules (no Lam) serialize identically,
so all current hashes stay stable.
Pretty-printer: renders `(\\ (x: T ...) -> R . body)`.
Typecheck (ailang-check): a lambda's type is the declared Type::Fn.
Body's effect set must be a subset of declared effects (no row
polymorphism). Constructing a lambda is pure — only calling it picks
up the declared effects, via the existing App branch.
Codegen (ailang-codegen):
- collect_captures: free-var walk; excludes builtins, current-module
top-level fns, and qualified names.
- lower_lambda: per-fn lam counter, save/restore emitter state, emit
thunk into a deferred queue (flushed after the parent fn), pack env
+ closure pair on heap, register the resulting closure-pair SSA in
the sidetable so subsequent indirect calls find it.
- Capture sigs propagate: a fn-typed capture keeps its FnSig in the
thunk's sidetable so `f(args)` inside the body still indirect-calls.
- Env layout: 8 bytes per capture (typed load/store reads only the
needed bytes; padding wasted but uniform).
Tests: 49 green (was 48). New examples/closure.ail.json + e2e
`closure_captures_let_n` exercises `let n = 3 in apply(\\x. x + n, 39)`
end-to-end and asserts the binary prints 42.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Every fn-value is now a `ptr` to a closure pair `{ ptr thunk, ptr env }`,
not a raw fn-pointer. Top-level fns get an auto-generated adapter
`@ail_<m>_<f>_adapter(ptr %_env, params...)` that ignores env and
forwards to the real fn, plus a static closure constant
`@ail_<m>_<f>_clos = { @adapter, null }`. References to a fn as a
value return the closure-pair address.
Indirect calls now GEP the thunk + env slots, load both, and call
`thunk(env, args...)`. Direct calls to statically-known callees stay
on the original fast path (no adapter).
This is the ABI groundwork for Iter 8b lambdas: a captured-env closure
will reuse the same value shape, just with a non-null env produced by
malloc.
Tests: 48 still green. IR snapshots refreshed (every fn now carries an
adapter + static closure pair). Iter 7's hof.ail.json prints 42
unchanged — `apply(inc, 41)` now hands `@ail_hof_inc_clos` to apply,
which unpacks and indirect-calls as designed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Top-level fn names are now usable as values, fn-typed parameters can
be called as `f(args)`. KISS slice of "closures + HOFs + TIR": no
TIR, no heap, no ABI shift — that bundle stays in Iter 8 where
closure-with-capture and lambdas land together.
Codegen:
- Type::Fn lowers to LLVM `ptr`; sig travels via a per-fn-body
`ssa_fn_sigs` sidetable on `Emitter`.
- Term::Var falls through to `resolve_top_level_fn` when the name is
not a local; emits `@ail_<m>_<def>` and registers the sig.
- Term::App splits: static callee (builtin / current-module / qualified)
keeps the existing direct path; otherwise lower the callee, look up
the sig, emit indirect `call <ret> (<param-tys>) %fn(args...)`.
- emit_fn registers fn-typed params in the sidetable on entry.
- If branches propagate a fn-pointer sig to their phi when both arms
match.
Typechecker: unchanged. It already accepted `synth(callee)` against
Type::Fn; the only blocker was codegen rejecting non-Var callees.
Tests: 48 green (was 47). New `examples/hof.ail.json` and e2e
`higher_order_apply_inc` exercise `apply(inc, 41) == 42` end-to-end.
DESIGN.md: "What is not (yet) supported" rewritten — closures-with-
capture and lambdas remain pending, first-class fn-refs added as
positive bullet. Smoke-test list extended with `hof.ail.json`.
JOURNAL.md: Iter 7 entry with rationale, scope choice, architecture
self-check, Iter 8 plan.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- ail deps now filters builtins, fn params, and let/match-pattern
bindings. New value_names() in ailang-check::builtins is the single
source of truth shared with the typechecker install path. walk_term
threads a scope set; qualified `prefix.def` refs pass through.
- check_in_workspace returns Vec<CheckError>; check_workspace
accumulates body diagnostics across defs and modules. Pass-1
(top-level symbol table) and per-module type-def setup stay
fail-fast — corrupt env would taint later diagnostics.
- DESIGN.md "What the MVP is NOT" was lying (ADTs, strings landed
in Iter 2/3). Renamed to "What is not (yet) supported" and split
into "not yet" + supported/smoke-tested. JOURNAL Iter 6 entry
records the architecture self-check.
Tests: 47 green (was 44). +2 deps filter tests in e2e,
+1 multi-diagnose test in ailang-check workspace integration.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Finishes the project-wide English convention:
- CLAUDE.md (the user opted in to translate it too).
- examples/hello.ail.json: "Hallo, AILang." -> "Hello, AILang.".
- E2E test assertion and IR snapshot for hello regenerated to match.
- DESIGN.md "Project language: English" section: the previous
CLAUDE.md exception is dropped.
After this commit, no German remains in any committed file
(grep -P '[äöüÄÖÜß]' is empty across .rs / .md / .json / .ll).
Verified: cargo test --workspace passes (44/44).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Make English the project-wide language: all comments, string literals,
CLI help text, design docs, journal, agent prompts, and README. Only
CLAUDE.md (the user's own instruction file) stays German, and the live
conversation between user and Claude continues in German.
Adds a new "Project language: English" section to docs/DESIGN.md as
the durable convention. No logic changes — translation only. Four
internal error strings in the typechecker were retranslated; no
test asserts on their wording.
Verified: cargo test --workspace passes (44/44).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
JOURNAL bekommt fehlenden Iter-5d-Eintrag und Iter-5-Architektur-
Review-Notiz mit Iter-6-Plan (Aufräumarbeiten). DESIGN.md korrigiert
zwei Drifts vom Architekt-Befund: @main ist i32 (C-/LLVM-ABI), nicht
i64; String-Globals tragen Hint @.str_<modul>_<hint>_<idx>.
Vier Tooling-Subkommandos können jetzt auf dem ganzen Workspace
arbeiten. Default bleibt single-modul (Rückwärtskompat). Manifest
listet alphabetisch nach (modul, name) mit module-Feld; describe
nimmt Punktnotation ws_lib.add an, ambig-Erkennung fallback;
deps gibt Cross-Module-Edges {from_module,from_def,to_module,to_def}
aus, Effekt-Ops separat; diff vergleicht workspace-übergreifend mit
added/removed/changed/unchanged_modules und nested Sub-Diff pro
changed_module. Helper diff_def_lists wird von Single- und
Workspace-Diff geteilt.
Symbol-Mangling-Schema einheitlich auf @ail_<modul>_<def> umgestellt
(auch für Single-Modul-Programme), String-Globals als
@.str_<modul>_<idx>. main bleibt LLVM-/C-ABI-Eintrittspunkt und ist
ein Trampoline auf @ail_<entry>_main. lower_workspace emittiert eine
einzige .ll für den ganzen Workspace, alphabetisch nach Modulname,
Cross-Module-Calls über Import-Map aufgelöst. ail build / ail emit-ir
laufen jetzt durch den Workspace-Pfad. IR-Snapshots regeneriert,
neuer ws_main-Snapshot. E2E-Test workspace_build_runs_imported_fn
prüft, dass das Binary die importierte Funktion korrekt aufruft.
Schuld #19 (source_filename) durch einheitliches <entry>.ail-Schema
geschlossen.
Neue API check_workspace(&Workspace) -> Vec<Diagnostic>; check_module
hebt das Modul intern in einen Trivial-Workspace. Term::Var mit genau
einem Punkt im Namen ist ein qualifizierter Verweis <prefix>.<def>,
aufgelöst über Import-Map (alias-oder-modulname → echter Modulname).
Drei neue Diagnostic-Codes: unknown-module, unknown-import,
invalid-def-name. ail check lädt jetzt immer via load_workspace;
Loader-Fehler werden im JSON-Modus zu strukturierten Diagnostics
(module-not-found, module-cycle, …). DESIGN.md und JOURNAL.md
dokumentieren die Konvention. Hash-Stabilität: alle ir_snapshot_*-
Tests bitidentisch grün, kein neuer AST-Knoten.
Architekt-Befund umgesetzt: Iter-4-Eintrag dokumentiert die drei
Sub-Commits (4a/4b/4c), den Test-Stand von 28, das Schließen der
Iter-2-Block-Tracking-Schuld und die zwei neuen Schulden
(single-shot check_module, hartkodiertes source_filename).
Iter-5-Plan steht: Modulsystem zuerst, Multi-Diagnose-Refactor danach.
Vier Snapshots in crates/ail/tests/snapshots/ (sum, max3, hello, list)
sichern den erzeugten LLVM-IR. Test-Helper normalisiert target triple
und trailing whitespace, sonst byte-für-byte-Vergleich. Update via
UPDATE_SNAPSHOTS=1 cargo test ir_snapshot_. Mismatch erzeugt eine
.actual-Datei mit dem aktuellen Output für Diff-Inspektion.
ail diff <a> <b> [--json] vergleicht zwei Module strukturell per
Def-Hash. Vier Kategorien (added/removed/changed/unchanged),
alphabetisch sortiert, deterministisches JSON-Schema. Exit 1 bei
Unterschieden, Exit 0 bei Identität — skript-tauglich. Kein
Typcheck-Zwang, damit man auch kaputte Module diffen kann. Helper
def_name/def_kind in ailang-core für stabile Def-Identität.
Neue Top-Level-API check_module(&Module) -> Vec<Diagnostic> in
ailang-check, plus stabile Codes (unbound-var, type-mismatch,
arity-mismatch, non-exhaustive-match, unknown-ctor-in-pattern,
duplicate-def, …). CLI bekommt --json-Flag für maschinenlesbares
Output, Exit 1 bei Errors. Text-Modus unverändert. E2E-Test
check_json_unbound_var sichert das Format ab.
Vier spezialisierte Agent-Definitionen (implementer, architect, tester,
debugger) im sichtbaren agents/-Verzeichnis. DESIGN.md erweitert um den
Abschnitt "Projekt-Ökosystem" — AILang ist Sprache + CLI + Examples +
Agents + Doku + Tests gleichermaßen. JOURNAL hält den Workflow-Wechsel
auf Orchestrator-Modus fest und ordnet Iteration 4 neu.
- AST: Def::Type mit Ctors; Term::Ctor (Konstruktion) und Term::Match
mit Arm/Pattern. Patterns: Wild, Var, Lit, Ctor { ctor, fields } —
Sub-Patterns im MVP auf Var/Wild beschränkt.
- Typchecker: Type-Registry, ctor_index für O(1)-Resolution, Pattern-
Bindings, Exhaustiveness-Check gegen volle Konstruktormenge plus
Negativ-Tests.
- Codegen: Boxed-Heap-Layout via malloc; Tag in Offset 0, Felder ab
Offset 8 in 8-Byte-Slots. Match lowert zu load tag + switch + Phi
am Join. Default-Block ist unreachable, wenn vom Typchecker geprüft.
- examples/list.ail.json: rekursive Int-Liste mit sum_list via match.
E2E-Test + Exhaustiveness-Tests. 19/19 Tests grün.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Codegen: current_block-Tracking ersetzt die Heuristik im phi-Lowering;
verschachtelte if-Ausdrücke produzieren jetzt korrekte LLVM IR.
examples/max3.ail.json + Test schützt gegen Regression.
- Strings: Lit::Str / Type Str / io/print_str Effekt-Op; Strings sind im
MVP immutable Konstanten. examples/hello.ail.json als zweiter E2E-Test.
- CLI: --json für manifest und builtins; neuer deps-Subcommand listet
statische Symbol-Referenzen pro Definition. Effekt-Ops mit Prefix
effect: markiert.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Erste lauffähige Iteration. examples/sum.ail.json wird zu nativem Binary
kompiliert und druckt 55 (Summe 1..10) als End-to-End-Test.
Architektur:
- ailang-core: hashbares JSON-AST + canonical-form + pretty-printer
- ailang-check: monomorpher HM-Subset + Effekt-Set-Tracking
- ailang-codegen: LLVM-IR-Text-Emitter (kein libllvm-link)
- ail: CLI mit check/manifest/render/describe/emit-ir/build/builtins
Designentscheidungen sind in docs/DESIGN.md dokumentiert; der Verlauf
in docs/JOURNAL.md.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>