# iter emit-ir-staticlib — `ail emit-ir --emit=staticlib` (M1 fieldtest spec_gap#2) **Date:** 2026-05-18 **Started from:** 03493c9b316038f6bfe7f86678457bfa223451a5 **Status:** DONE **Tasks completed:** 4 of 4 ## Summary Resolves M1 fieldtest [spec_gap]#2 ("no public path emits the staticlib IR though Decision 5 makes IR readability a first-class LLM affordance") by adding `--emit=staticlib` to `ail emit-ir`, symmetric with the M1-shipped `ail build --emit=staticlib`. A one-line codegen convenience `lower_workspace_staticlib(ws)` (mirroring `lower_workspace`) routes through the M1-audited, unchanged `Target::StaticLib` forwarder-emission path; the CLI arm gains an `emit: String` clap field (symmetric with `Cmd::Build`'s) and a zero-export guard byte-identical to `build_staticlib`'s. DESIGN.md is *widened* (never narrowed) with a present-tense affordance sentence in §"Embedding ABI (M1)" and a synopsis correction that also fixes a pre-existing M1 omission for `ail build --emit=staticlib`. No new doc pin (architecture decision): the new E2E file pins the behaviour; the existing `docs_honesty_pin` (5 tests) confirmed non-regressed. ## Per-task notes - iter emit-ir-staticlib.1: codegen — added `pub fn lower_workspace_staticlib` in `ailang-codegen/src/lib.rs` between `lower_workspace` and `lower_workspace_inner`; delegates to `lower_workspace_inner(ws, Gc, Target::StaticLib)`. `cargo build -p ailang-codegen` clean. - iter emit-ir-staticlib.2: CLI — RED-first E2E file `crates/ail/tests/emit_ir_staticlib_cli.rs` (3 tests), observed RED "1 passed; 2 failed" exactly as predicted; added `emit` clap field to `Cmd::EmitIr`, destructured it in the arm, branched the lowering call with the byte-identical zero-export guard (Steps 3+4 honoured as a single compile unit — no cargo between the E0027 window). GREEN: 3 passed; `embed_staticlib_cli` 2 passed (build-side symmetry, no regression). - iter emit-ir-staticlib.3: DESIGN.md — added the present-tense `--emit=staticlib` affordance sentence after the M1 export snippet; synopsis: both `emit-ir` and `build` lines gained `[--emit=staticlib]` (the `build` correction discharges a pre-existing M1 current-state-honesty gap). `docs_honesty_pin` 5/5 green — no new pin, no regression. - iter emit-ir-staticlib.4: regression gate — `ail` suite 186 passed / 0 failed; workspace `TOTAL_PASSED=626` = pre-iter 623 + 3 (exactly the new tests, no pre-existing test lost); scope check clean (only the 4 in-scope paths). ## Concerns (none) ## Known debt (none — scoped feature fully closed; no fixture minted, no doc pin added, all by explicit plan decision.) ## Blocked detail (none) ## Files touched - `crates/ailang-codegen/src/lib.rs` — `lower_workspace_staticlib` convenience - `crates/ail/src/main.rs` — `Cmd::EmitIr` `emit` clap field + arm branch + zero-export guard - `crates/ail/tests/emit_ir_staticlib_cli.rs` — new, 3 E2E tests (positive forwarder-IR / zero-export guard / default-exe regression) - `docs/DESIGN.md` — §"Embedding ABI (M1)" affordance sentence + CLI synopsis (both lines) ## Stats bench/orchestrator-stats/2026-05-18-iter-emit-ir-staticlib.json