Files
hakorune/docs/private/roadmap/phases/phase-20.17

Phase 20.17 — Full SelfHosting (Freeze v1)

Goal

  • Hakorune compiler is built by Hakorune itself (StageN by Stage(N1)).
  • 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 failfast.
  • 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 (timeboxed)
  • 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
    • Nonnumeric return prints stable line; rc=0 only in Direct path
  • Quick/integration profiles
    • Gate off by default. With optin 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 GateC → 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)

  • GateC(Core) numeric rc symmetry fixedfile/pipe、plugins on/off 代表OK
  • HKIkni.*)正/負 canary が quick curated で緑console/time/fs
  • Prelude STRICTDeclOnlyを DFS/AST/unified の全経路に配線(決定的 FailFast
  • 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: unaryunop/params/Constructor/Const のネスト表現に対応。自己ホスト最小ケースで未定義レジスタの使用を解消。
  • Selfhost 最小スモークemit→parse→executeが PASSquick, optin

Next

  • Selfhosting の完了を最優先S0→S1→S2 の確認強化、代表題材の拡充)
  • 自己ホスト emitonly 経路child→親の firstline JSON 捕捉をスモークで固定。
  • hakorunevm → CoreBridge の委譲収束重複を削減、TTLコメント整備
  • HKI の負例タグ(代表ケース)の対称性チェックを docs/smokes に反映
  • Optional/BangCallAttrs/Result統一は 20.18 に延期(本フェーズは設計メモのみ)