iter form-a.1 (Tasks 6-12): milestone close

Second half of the form-a-default-authoring milestone-close iter
(Boss-decided strategy C, big-bang). All seven tasks DONE; cargo
test --workspace green at every per-task boundary.

T6 — Bench-driver suffix flip from .ail.json to .ail across 4
Python scripts + run.sh. compile_check.py + cross_lang.py exit 0.

T7 — Re-author e2e.rs raw-JSON-inspect tests:
- diff_detects_changed_def — derive sum.ail.json on-the-fly via
  `ail parse examples/sum.ail` into tempdir, then mutate + diff.
- borrow_own_demo_modes_are_metadata_only — same pattern.
- reuse_as_demo_under_rc_uses_inplace_rewrite — same pattern.
- render_parse_round_trip_canonical — RETIRED (subsumed by T1's
  cli_parse_then_render_then_parse_is_idempotent over whole corpus).
- ail_run_accepts_ail_source_with_same_stdout_as_ail_json —
  re-authored to derive hello.ail.json in a per-process tempdir
  from hello.ail via `ail parse`, then assert dual-form stdout.

T8 — Bulk-delete 156 non-carve-out .ail.json. Inventory:
8 .ail.json (carve-outs, alphabetical: broken_unbound + prelude
+ 3× test_22b2_* + 3× test_ct1_*) + 157 .ail. carve_out_inventory
test un-#[ignore]'d and green. Forward-pulled 20 repairs that the
T1-5 dispatch's recon missed (12 Group-B suffix + 5 Group-A
load_workspace + 3 ail_run sites). Also forward-pulled T9 Step 5
(schema_coverage corpus flip from .ail.json to .ail) to satisfy
T8's green-gate.

T9 — Retire obsolete roundtrip tests:
- print_then_parse_round_trips_every_fixture (round_trip.rs)
- every_ail_fixture_matches_its_json_counterpart (round_trip.rs)
- cli_render_then_parse_preserves_canonical_bytes_on_every_fixture
- Dead helpers: list_json_fixtures ×2, round_trip_one,
  strip_trailing_newlines.
Schema-coverage corpus already flipped in T8 (forward-pull).

T10 — DESIGN.md §"Roundtrip Invariant" (lines 2027-2109) restated
with parse-determinism + idempotency + CLI-pipeline-idempotency +
carve-out-anchor framing. Five surviving enforcement tests named.
§"Float literals" and §"Why anchored at top level" preserved.

T11 — §A4 doctrine edits: CLAUDE.md:5-6 + DESIGN.md:465-466.
Canonical form remains JSON-AST; authoring projection is .ail;
build derives JSON-AST in-process via ailang_surface::parse.

T12 — Milestone close:
- WhatsNew entry: user-facing language, lead with the change.
- Roadmap: [milestone] form-a struck [x] with closing note.
- Final inventory verified: 8 .ail.json + 157 .ail.
- Final cargo test --workspace: 557 passed, 0 failed, 3 ignored.
- bench/compile_check.py + bench/cross_lang.py: exit 0.

Test math: pre-iter 558 baseline + 3 new T1 tests = 561, − 1
(T7 retire) − 3 (T9 retire) = 557 final.

INDEX.md appended with the full iter summary covering T1-T12 (the
T1-5 commit at 77b28ad deferred the INDEX line to full-iter close).

Milestone [Form-A as the default authoring surface] structurally
closed. The compile-time-embed carve-out (prelude.ail.json) is
the subject of the queued follow-up milestone [Prelude embed:
Form-A as compile-time source]. audit-form-a runs as the next
dispatch.
This commit is contained in:
2026-05-13 11:31:39 +02:00
parent 9332d1e155
commit 9fdc4cacff
173 changed files with 551 additions and 6645 deletions
+117 -71
View File
@@ -406,48 +406,12 @@ fn std_list_stress_1000_element_folds() {
);
}
/// Iter 15e: `ail render | ail parse` round-trips canonical bytes.
/// Property protected: the CLI's `render` is the exact inverse of
/// `parse`, not the older human-pretty form. Regression of this
/// would mean piping `render` into `parse` no longer yields a
/// re-loadable module — a contract the help text now claims.
///
/// Picks `std_either.ail.json` (richest fixture: 2-type-var data,
/// 3-type-var fn, recursive ctors irrelevant) but the round-trip
/// test in `ailang-surface` covers all 25 fixtures structurally.
/// This test specifically exercises the CLI shell pipeline.
#[test]
fn render_parse_round_trip_canonical() {
let manifest_dir = env!("CARGO_MANIFEST_DIR");
let workspace = Path::new(manifest_dir).parent().unwrap().parent().unwrap();
let src = workspace.join("examples").join("std_either.ail.json");
let original = std::fs::read(&src).expect("read fixture");
let render = Command::new(ail_bin())
.args(["render", src.to_str().unwrap()])
.output()
.expect("run ail render");
assert!(render.status.success(), "ail render failed");
let tmp = std::env::temp_dir().join(format!("ailang_render_e2e_{}.ail", std::process::id()));
std::fs::write(&tmp, &render.stdout).expect("write rendered ail");
let parsed = Command::new(ail_bin())
.args(["parse", tmp.to_str().unwrap()])
.output()
.expect("run ail parse");
assert!(parsed.status.success(), "ail parse failed on rendered output");
let mut round = parsed.stdout;
while round.last() == Some(&b'\n') {
round.pop();
}
let mut orig = original;
while orig.last() == Some(&b'\n') {
orig.pop();
}
assert_eq!(orig, round, "render | parse must produce canonical bytes");
}
// Retired iter form-a.1 T7: `render_parse_round_trip_canonical` raw-read
// `std_either.ail.json` for the byte-roundtrip. The property it pinned
// (CLI render→parse byte-roundtrip) is now pinned across the entire
// `.ail` corpus by `cli_parse_then_render_then_parse_is_idempotent` in
// `crates/ail/tests/roundtrip_cli.rs` (added in T1), which is strictly
// stronger (whole-corpus vs. one-fixture).
/// Iter 16a: nested constructor patterns. Property protected:
/// `ailang_core::desugar` flattens `Cons a (Cons b _)` to a chain of
@@ -698,12 +662,33 @@ fn nested_let_rec_demo() {
fn diff_detects_changed_def() {
let manifest_dir = env!("CARGO_MANIFEST_DIR");
let workspace = Path::new(manifest_dir).parent().unwrap().parent().unwrap();
let src_a = workspace.join("examples").join("sum.ail.json");
// Variant: load sum.ail.json, mutate the `then` branch (1 instead of 0)
// Form-A migration (iter form-a.1): derive the canonical JSON-AST
// from `sum.ail` via `ail parse` rather than reading a pre-existing
// `sum.ail.json` (which no longer exists post-iter). The variant is
// produced by mutating the parsed AST and writing it back as a JSON
// tempfile; `ail diff` runs against the two JSON tempfiles.
let tmp_a = std::env::temp_dir().join(format!(
"ailang_diff_src_{}.ail.json",
std::process::id()
));
let parse_status = Command::new(ail_bin())
.args([
"parse",
workspace.join("examples").join("sum.ail").to_str().unwrap(),
"-o",
tmp_a.to_str().unwrap(),
])
.status()
.expect("ail parse failed to run");
assert!(parse_status.success(), "ail parse failed on sum.ail");
let src_a = tmp_a.clone();
// Variant: load the derived JSON, mutate the `then` branch (1 instead of 0)
// in the `sum` definition. `main` stays bit-identical.
let raw = std::fs::read(&src_a).expect("read sum.ail.json");
let mut module: serde_json::Value = serde_json::from_slice(&raw).expect("parse sum.ail.json");
let raw = std::fs::read(&src_a).expect("read derived sum.ail.json");
let mut module: serde_json::Value =
serde_json::from_slice(&raw).expect("parse derived sum.ail.json");
{
let defs = module
.get_mut("defs")
@@ -1305,13 +1290,30 @@ fn unreachable_demo() {
/// wrappers, and the binary prints `3` then `6`.
#[test]
fn borrow_own_demo_modes_are_metadata_only() {
// Sanity-check (2): the on-disk JSON contains `param_modes`
// Sanity-check (2): the canonical JSON contains `param_modes`
// tokens for both fns. If the schema regressed and the field
// were dropped, this would fail before the binary even runs.
//
// Form-A migration (iter form-a.1): derive the JSON via `ail parse`
// on `borrow_own_demo.ail` rather than reading a pre-existing
// `.ail.json` (deleted post-iter).
let manifest_dir = env!("CARGO_MANIFEST_DIR");
let workspace = Path::new(manifest_dir).parent().unwrap().parent().unwrap();
let json_path = workspace.join("examples").join("borrow_own_demo.ail.json");
let json = std::fs::read_to_string(&json_path).expect("read borrow_own_demo.ail.json");
let tmp_json = std::env::temp_dir().join(format!(
"ailang_borrow_own_demo_{}.ail.json",
std::process::id()
));
let parse_status = Command::new(ail_bin())
.args([
"parse",
workspace.join("examples").join("borrow_own_demo.ail").to_str().unwrap(),
"-o",
tmp_json.to_str().unwrap(),
])
.status()
.expect("ail parse failed to run");
assert!(parse_status.success(), "ail parse failed on borrow_own_demo.ail");
let json = std::fs::read_to_string(&tmp_json).expect("read derived borrow_own_demo.ail.json");
assert!(
json.contains("\"param_modes\":[\"borrow\"]"),
"expected `param_modes:[\"borrow\"]` in canonical JSON; the schema for `(borrow T)` regressed"
@@ -1359,7 +1361,7 @@ fn eq_demo() {
#[test]
fn alloc_rc_produces_same_stdout_as_gc() {
// Pick a fixture with non-trivial allocation: list-building + match.
let example = "list.ail.json";
let example = "list.ail";
let stdout_gc = build_and_run_with_alloc(example, "gc");
let stdout_rc = build_and_run_with_alloc(example, "rc");
assert_eq!(stdout_gc, stdout_rc, "alloc=rc must match alloc=gc");
@@ -1405,8 +1407,26 @@ fn clone_demo_is_identity_in_18c1() {
fn reuse_as_demo_under_rc_uses_inplace_rewrite() {
let manifest_dir = env!("CARGO_MANIFEST_DIR");
let workspace = Path::new(manifest_dir).parent().unwrap().parent().unwrap();
let json_path = workspace.join("examples").join("reuse_as_demo.ail.json");
let json = std::fs::read_to_string(&json_path).expect("read reuse_as_demo.ail.json");
let ail_path = workspace.join("examples").join("reuse_as_demo.ail");
// Form-A migration (iter form-a.1): derive the canonical JSON-AST
// via `ail parse` on `reuse_as_demo.ail` rather than reading a
// pre-existing `.ail.json` (deleted post-iter).
let tmp_json = std::env::temp_dir().join(format!(
"ailang_reuse_as_demo_{}.ail.json",
std::process::id()
));
let parse_status = Command::new(ail_bin())
.args([
"parse",
ail_path.to_str().unwrap(),
"-o",
tmp_json.to_str().unwrap(),
])
.status()
.expect("ail parse failed to run");
assert!(parse_status.success(), "ail parse failed on reuse_as_demo.ail");
let json = std::fs::read_to_string(&tmp_json).expect("read derived reuse_as_demo.ail.json");
assert!(
json.contains("\"t\":\"reuse-as\""),
"expected `\"t\":\"reuse-as\"` in canonical JSON; the schema for `(reuse-as ...)` regressed"
@@ -1422,8 +1442,10 @@ fn reuse_as_demo_under_rc_uses_inplace_rewrite() {
// (5) Inspect the rc IR text. We re-lower via the codegen API
// directly so the assertion runs without depending on the
// filesystem layout of `ail build`'s tmpdir.
let ws = ailang_core::load_workspace(&json_path).expect("load workspace");
// filesystem layout of `ail build`'s tmpdir. Use the
// extension-dispatching `ailang_surface::load_workspace` so
// the `.ail` entry is accepted.
let ws = ailang_surface::load_workspace(&ail_path).expect("load workspace");
let mut lifted_modules = std::collections::BTreeMap::new();
for (mname, m) in &ws.modules {
let desugared = ailang_core::desugar::desugar_module(m);
@@ -1496,7 +1518,7 @@ fn reuse_as_demo_under_rc_uses_inplace_rewrite() {
/// invariant: stdout must be byte-identical to the `gc` build.
#[test]
fn alloc_rc_matches_gc_on_std_list_demo() {
let example = "std_list_demo.ail.json";
let example = "std_list_demo.ail";
let stdout_gc = build_and_run_with_alloc(example, "gc");
let stdout_rc = build_and_run_with_alloc(example, "rc");
assert_eq!(
@@ -1531,7 +1553,7 @@ fn alloc_rc_matches_gc_on_std_list_demo() {
/// this iter.
#[test]
fn alloc_rc_emits_dec_for_unique_let_bound_box() {
let example = "rc_box_drop.ail.json";
let example = "rc_box_drop.ail";
let stdout_gc = build_and_run_with_alloc(example, "gc");
let stdout_rc = build_and_run_with_alloc(example, "rc");
assert_eq!(stdout_gc.trim(), "42");
@@ -1557,7 +1579,7 @@ fn alloc_rc_emits_dec_for_unique_let_bound_box() {
/// the dec path itself.
#[test]
fn alloc_rc_recursive_list_sum() {
let example = "rc_list_drop.ail.json";
let example = "rc_list_drop.ail";
let stdout_gc = build_and_run_with_alloc(example, "gc");
let stdout_rc = build_and_run_with_alloc(example, "rc");
assert_eq!(stdout_gc.trim(), "15");
@@ -1602,7 +1624,7 @@ fn alloc_rc_recursive_list_sum() {
/// pattern-binder dec.
#[test]
fn alloc_rc_borrow_only_recursive_list_drop() {
let example = "rc_list_drop_borrow.ail.json";
let example = "rc_list_drop_borrow.ail";
let stdout_gc = build_and_run_with_alloc(example, "gc");
let stdout_rc = build_and_run_with_alloc(example, "rc");
assert_eq!(stdout_gc.trim(), "11");
@@ -1622,7 +1644,7 @@ fn alloc_rc_borrow_only_recursive_list_drop() {
let manifest_dir = env!("CARGO_MANIFEST_DIR");
let workspace = Path::new(manifest_dir).parent().unwrap().parent().unwrap();
let json_path = workspace.join("examples").join(example);
let ws = ailang_core::load_workspace(&json_path).expect("load workspace");
let ws = ailang_surface::load_workspace(&json_path).expect("load workspace");
let mut lifted_modules = std::collections::BTreeMap::new();
for (mname, m) in &ws.modules {
let desugared = ailang_core::desugar::desugar_module(m);
@@ -1684,7 +1706,7 @@ fn alloc_rc_borrow_only_recursive_list_drop() {
/// `drop_<m>_Pair` call against `p`.
#[test]
fn alloc_rc_partial_drop_skips_moved_keeps_wildcarded() {
let example = "pat_extract_partial_drop.ail.json";
let example = "pat_extract_partial_drop.ail";
let stdout_gc = build_and_run_with_alloc(example, "gc");
let stdout_rc = build_and_run_with_alloc(example, "rc");
assert_eq!(stdout_gc.trim(), "6");
@@ -1698,7 +1720,7 @@ fn alloc_rc_partial_drop_skips_moved_keeps_wildcarded() {
let manifest_dir = env!("CARGO_MANIFEST_DIR");
let workspace = Path::new(manifest_dir).parent().unwrap().parent().unwrap();
let json_path = workspace.join("examples").join(example);
let ws = ailang_core::load_workspace(&json_path).expect("load workspace");
let ws = ailang_surface::load_workspace(&json_path).expect("load workspace");
let mut lifted_modules = std::collections::BTreeMap::new();
for (mname, m) in &ws.modules {
let desugared = ailang_core::desugar::desugar_module(m);
@@ -1774,7 +1796,7 @@ fn alloc_rc_partial_drop_skips_moved_keeps_wildcarded() {
/// that ANY drop fires.
#[test]
fn alloc_rc_own_param_dec_at_fn_return() {
let example = "rc_own_param_drop.ail.json";
let example = "rc_own_param_drop.ail";
let stdout_gc = build_and_run_with_alloc(example, "gc");
let stdout_rc = build_and_run_with_alloc(example, "rc");
assert_eq!(stdout_gc.trim(), "11");
@@ -1788,7 +1810,7 @@ fn alloc_rc_own_param_dec_at_fn_return() {
let manifest_dir = env!("CARGO_MANIFEST_DIR");
let workspace = Path::new(manifest_dir).parent().unwrap().parent().unwrap();
let json_path = workspace.join("examples").join(example);
let ws = ailang_core::load_workspace(&json_path).expect("load workspace");
let ws = ailang_surface::load_workspace(&json_path).expect("load workspace");
let mut lifted_modules = std::collections::BTreeMap::new();
for (mname, m) in &ws.modules {
let desugared = ailang_core::desugar::desugar_module(m);
@@ -1891,7 +1913,7 @@ fn alloc_rc_own_param_dec_at_fn_return() {
/// capacity).
#[test]
fn alloc_rc_drop_iterative_handles_million_cell_list() {
let example = "rc_drop_iterative_long_list.ail.json";
let example = "rc_drop_iterative_long_list.ail";
let stdout_gc = build_and_run_with_alloc(example, "gc");
let stdout_rc = build_and_run_with_alloc(example, "rc");
assert_eq!(stdout_rc.trim(), "1");
@@ -1910,11 +1932,11 @@ fn alloc_rc_drop_iterative_handles_million_cell_list() {
/// dispatch.
#[test]
fn iter18e_drop_iterative_emits_worklist_body_no_self_recursion() {
let example = "rc_drop_iterative_long_list.ail.json";
let example = "rc_drop_iterative_long_list.ail";
let manifest_dir = env!("CARGO_MANIFEST_DIR");
let workspace = Path::new(manifest_dir).parent().unwrap().parent().unwrap();
let json_path = workspace.join("examples").join(example);
let ws = ailang_core::load_workspace(&json_path).expect("load workspace");
let ws = ailang_surface::load_workspace(&json_path).expect("load workspace");
let mut lifted_modules = std::collections::BTreeMap::new();
for (mname, m) in &ws.modules {
let desugared = ailang_core::desugar::desugar_module(m);
@@ -1987,11 +2009,11 @@ fn iter18e_drop_iterative_emits_worklist_body_no_self_recursion() {
/// of any on-disk fixture changes.
#[test]
fn iter18e_no_annotation_keeps_recursive_drop_body() {
let example = "rc_drop_iterative_long_list.ail.json";
let example = "rc_drop_iterative_long_list.ail";
let manifest_dir = env!("CARGO_MANIFEST_DIR");
let workspace = Path::new(manifest_dir).parent().unwrap().parent().unwrap();
let json_path = workspace.join("examples").join(example);
let ws = ailang_core::load_workspace(&json_path).expect("load workspace");
let ws = ailang_surface::load_workspace(&json_path).expect("load workspace");
// Mutate every TypeDef in every module to clear the annotation.
let mut modules = std::collections::BTreeMap::new();
for (mname, m) in &ws.modules {
@@ -2066,7 +2088,7 @@ fn iter18e_no_annotation_keeps_recursive_drop_body() {
/// regression coverage — see CLAUDE.md "Bug fixes — TDD, always".
#[test]
fn alloc_rc_pattern_bind_in_implicit_fn_does_not_dec_borrowed_children() {
let example = "rc_pin_recurse_implicit.ail.json";
let example = "rc_pin_recurse_implicit.ail";
let stdout_gc = build_and_run_with_alloc(example, "gc");
let stdout_rc = build_and_run_with_alloc(example, "rc");
assert_eq!(stdout_gc.trim(), "0");
@@ -2294,7 +2316,7 @@ fn alloc_rc_let_binder_for_implicit_returning_app_does_not_drop() {
/// the arm-close drop. Output matches `--alloc=gc` (`0`).
#[test]
fn alloc_rc_let_alias_of_implicit_param_does_not_dec_borrowed_children() {
let example = "rc_let_alias_implicit_param.ail.json";
let example = "rc_let_alias_implicit_param.ail";
let stdout_gc = build_and_run_with_alloc(example, "gc");
let stdout_rc = build_and_run_with_alloc(example, "rc");
assert_eq!(stdout_gc.trim(), "0");
@@ -2524,11 +2546,35 @@ fn ail_check_accepts_ail_source() {
/// counterpart. Guards against the surface→core dispatch silently
/// rewriting the loaded `Module` (e.g. losing imports, dropping defs,
/// re-ordering fields) — the binary semantics must be form-agnostic.
///
/// Form-A migration (iter form-a.1): only the eight carve-out fixtures
/// keep `.ail.json` form on disk post-iter. To preserve the dual-form
/// property test, derive a parallel `.ail.json` in a tempdir from
/// `hello.ail` via `ail parse`, then build and run both forms.
#[test]
fn ail_run_accepts_ail_source_with_same_stdout_as_ail_json() {
let ail_path = workspace_root().join("examples/hello.ail");
let json_path = workspace_root().join("examples/hello.ail.json");
assert!(ail_path.is_file());
// The loader name-checks the module name against the file stem, so
// the derived JSON must be named `hello.ail.json` even in the temp
// location. Use a per-process tempdir to avoid races.
let tmpdir = std::env::temp_dir().join(format!(
"ailang_dual_form_{}",
std::process::id()
));
std::fs::create_dir_all(&tmpdir).unwrap();
let json_path = tmpdir.join("hello.ail.json");
let parse_status = Command::new(ail_bin())
.args([
"parse",
ail_path.to_str().unwrap(),
"-o",
json_path.to_str().unwrap(),
])
.status()
.expect("ail parse failed to run");
assert!(parse_status.success(), "ail parse failed on hello.ail");
assert!(json_path.is_file());
let build_and_capture = |src: &Path| -> Vec<u8> {