2025-11-09 00:57:10 +09:00
# De‑ Rust Roadmap (Phase 21.9+)
Purpose: reduce Rust surface (non‑ plugin) while keeping correctness and reversibility. Make Hakorune (Hako) the primary host for parsing/building/executing; keep Rust for kernel/ABI/thin wrappers.
## Phases
### Phase 0 — Archive (low risk)
- Target: Rust LLVM backend (src/backend/llvm) — deprecated in favor of Python llvmlite.
- Action: move to `archive/rust-llvm-backend/` with a clear RESTORE.md.
- Acceptance: `cargo build --release` (default features) remains green; quick smokes green.
- Revert: `git mv archive/rust-llvm-backend/llvm src/backend/` .
2025-11-09 15:11:18 +09:00
### Phase 1 — Parser/MIR Hako‑ first( 22.0)
- Make Hako the primary for Parser/MIR; Rust builder becomes fallback.
- Verify quick canaries green under registry; keep hv1 inline parity.
### Phase 2 — TLV C shim & Resolver SSOT( 22.1)
- TLV codec to C shim (+ Rust FFI); Resolver/Using SSOT in Hako shared by runner/analyzer.
2025-11-09 00:57:10 +09:00
2025-11-09 01:00:43 +09:00
Deliverables & Tests
2025-11-09 15:11:18 +09:00
- 22.0: registry builder default ON; hv1直列 green; Core/Interpreter is diagnostic.
- 22.1: TLV round‑ trip smokes; Using SSOT parity between runner/analyzer.
2025-11-09 01:00:43 +09:00
2025-11-09 15:11:18 +09:00
### Phase 3 — Core Thinning I( 22.2, 2– 4 months)
- Plugin loader thin C wrapper (dlopen/dlsym) and basic boxes C core; Rust shim remains.
2025-11-09 00:57:10 +09:00
2025-11-09 01:00:43 +09:00
SSOT for Using/Resolver (summary)
- Resolution order: modules (nyash.toml) → relative path inference → not found (warn) with verbose details.
- Analyzer/HakoCheck follows the same order; runner shares policy helpers. No path‑ literal using in strict profiles.
2025-11-09 15:11:18 +09:00
### Phase 4 — Long‑ haul( 22.3, 3– 6 months)
2025-11-09 00:57:10 +09:00
- Python llvmlite → Hako IR builder + C ABI.
- Parser/MIR builder fully Hako‑ first; Rust becomes fallback.
- NyKernel minimal C runtime (BoxCall dispatcher + collections + file).
2025-11-09 15:11:18 +09:00
### Phase 21.10 — LLVM Line Unification (SSOT + crate probe)
- SSOT builder (`tools/ny_mir_builder.sh` ) selects backend by env; crate path opt‑ in.
- Add crate S3 canaries (ternary/map/print); defaults unchanged.
### Phase 21.11 — Flip default to crate (ny-llvmc)
- Make crate default when available; llvmlite becomes opt‑ in.
- S3 reps run via crate in quick; legacy remains available.
### Phase 21.12 — Hako Native LLVM Builder (bootstrap)
- Experimental native (Hako→LLVM C API) path for minimal EXE.
- Behind `NYASH_LLVM_BACKEND=native` toggle; no default impact.
### Phase 21.13 — llvmlite deprecation (default off)
- Remove llvmlite from auto paths; keep explicit toggle + optional CI job.
### Phase 21.14 — Optimization & Perf Harness
- Perf harness + PHI invariants; optimize hot paths; publish numbers.
2025-11-09 00:57:10 +09:00
## Principles
- Guard everything by env/features; defaults unchanged.
- Keep changes reversible (small diffs, RESTORE docs, fallbacks).
- Test gates: quick smokes + representative hv1/hakovm parity.
## Today (suggested)
2025-11-09 15:11:18 +09:00
1) Lock 22.0 (Parser/MIR Hako‑ first) — builder registryを既定ON、quickが緑。
2) Prepare 22.1 (TLV C shim & Resolver SSOT) — I/F草案と最小スモーク。
3) LLVM統一( 21.10– 21.14) は並行で準備、切替は22.x完了後に本格実施。
2025-11-09 00:57:10 +09:00
2025-11-09 01:00:43 +09:00
## Test Strategy (gates)
- Quick: tools/smokes/v2/profiles/quick/core/* (phase2037 flow, phase2170 state) — green.
- Verify routing: HAKO_VERIFY_PRIMARY=hakovm (default); hv1_inline perf path parity (env toggles only).
- Build: `cargo build --release` (default features); LLVM paths are opt‑ in.
- Docs: keep RESTORE steps for any archived parts; small diffs, easy rollback.