# Phase 15.1 — Self-Hosting AOT-Plan to MIR13 (Nyash-first)
Scope: Extend Phase 15 (Self-Hosting Ny → MIR → VM/JIT) with a small, safe subphase that keeps VM/JIT primary, and prepares a future AOT pipeline by introducing:
- Nyash scripts that perform AOT preflight analysis across `using` trees
- A stable AOT-Plan JSON schema (functions, externs, exports, type hints, link units)
- A compiler-side importer that lowers AOT-Plan → MIR13 skeletons (no object code yet)
Avoid: deep AOT emission/linking, cross-platform toolchain work, or scope creep beyond planning and MIR13 import.
## Phase 15 Goals (context)
- VM-first correctness; JIT as compiler-only, not required for AOT deliverables
- Risk: plan schema churn → Guard: v1 frozen; add `extensions` map for future keys
---
## Consultation Notes (Gemini / Claude)
Prompts used:
- Gemini: "Phase 15 self-hosting goals (VM-first/JIT-compiler-only). Propose a 2-week 15.1 scope to add Nyash-driven AOT preflight that outputs a stable AOT plan JSON, plus a MIR13 importer—no object emission. Include milestones, acceptance criteria, and guardrails to prevent scope creep. Keep implementation incremental and observable."
- Claude: "Given an existing Ny parser and using-resolution, design a minimal AOT planning pipeline as Ny scripts that produces a plan.json (functions/externs/exports/units). Define the MIR13 importer requirements and tests ensuring VM/JIT behavior remains canonical. Provide risks, do-not-do list, and minimal telemetry."
Key takeaways aligned into this document:
- Keep 15.1 as a planning/import phase with strong do-not-do
- Make plan JSON stable and small; let importer be skeletal
- Add clear smokes and counters; avoid new runtime semantics
## Acceptance Criteria
-`tools/aot_plan` can analyze a small project with `using` and emit deterministic JSON
- Importer can read that JSON and construct MIR13 module(s) without panics
- VM runs those modules and matches expected string/number results for trivial bodies
- Events present when enabled; counters reflect plan/import activity; no AOT emit performed