# Phase 20.17 — Full Self‑Hosting (Freeze v1) Goal - Hakorune compiler is built by Hakorune itself (Stage‑N by Stage‑(N‑1)). - Freeze v1 of language spec, MIR(JSON v0) schema, minimal stdlib/ABI. - Rust remains a thin kernel (ABI/OS/HostHandle); no language semantics. 削減%は指標にしない。 - 開発作業の主戦場は `lang/` 配下(Nyash 側)。Rust は hako ABI で接続し、必要最小限の修正(不具合/境界整備)に限定。 Scope - Selfhost line only (Fronts+Compiler+CoreVM). Rust line stays unchanged by default (gated). - No feature expansion; only correctness, diagnostics stabilization, and fail‑fast. - Runner は Core 直行(JSON→Interpreter)を既定にし、Ny ラッパー(NyVmDispatcher.run)は TTL の互換経路に留める。 Acceptance Criteria - Selfhost build - Stage 0 (Rust) builds Stage 1 (Hakorune compiler AOT/EXE) - Stage 1 builds Stage 2 (same sources) with identical outputs (hash or canonical diff) - Optionally Stage 2 builds Stage 3 for extra confidence (time‑boxed) - Spec/ABI freeze - MIR(JSON v0) fields and meaning are fixed and documented - Core diagnostics use stable tags; smokes cover success/negative - Exit semantics - Numeric return maps to process exit code under Core route - Non‑numeric return prints stable line; rc=0 only in Direct path - Quick/integration profiles - Gate off by default. With opt‑in gates, quick selfhost canaries are green; integration set is ≥95% pass. Gates (default OFF) - HAKO_SELFHOST=1 (alias NYASH_SELFHOST=1): enable selfhost route - HAKO_GATE_C_CORE=1: force Gate‑C → Core VM direct - HAKO_RUNNER_USE_SCRIPT_EXE=1: allow runner_front adopt to select selfhost route Notes - Strictness is at boundaries. Unknown keys in JSON/payload fail fast with stable tags. - Rollback is gate removal; kernels stay intact. - Strategy reference: `../FROZEN_TOOLCHAIN_STRATEGY.md` - ABI 境界(hako ABI)は最小仕様(呼出規約/型/例外/戻り/所有)を安定化。変更は gate/TTL 配下で段階導入。 Progress (to date) - Gate‑C(Core) numeric rc symmetry fixed(file/pipe、plugins on/off 代表OK) - HKI(kni.*)正/負 canary が quick curated で緑(console/time/fs) - Prelude STRICT(DeclOnly)を DFS/AST/unified の全経路に配線(決定的 Fail‑Fast) - S2(strict) 既定ON。Emitter は ValueId 再番号・順序固定・単一パスで決定化済み - Core mir_call: Array/Map の代表メソッド(size/push/pop/get/set/len)と負例タグが固定化 - Selfhost runner: nyvm(Core) 直行へ強制。Ny ラッパー経路の `Unknown module function: NyVmDispatcher.run/1` を回避。 - MIR(JSON v0) Reader: unary(unop)/params/Constructor/Const のネスト表現に対応。自己ホスト最小ケースで未定義レジスタの使用を解消。 - Selfhost 最小スモーク(emit→parse→execute)が PASS(quick, opt‑in)。 Next - Self‑hosting の完了を最優先(S0→S1→S2 の確認強化、代表題材の拡充) - 自己ホスト emit‑only 経路(child→親)の first‑line JSON 捕捉をスモークで固定。 - hakorune‑vm → CoreBridge の委譲収束(重複を削減、TTLコメント整備) - HKI の負例タグ(代表ケース)の対称性チェックを docs/smokes に反映 - Optional/Bang(CallAttrs/Result統一)は 20.18 に延期(本フェーズは設計メモのみ)