de-rust phase-0: archive Rust LLVM backend to archive/rust-llvm-backend (RESTORE documented); defaults unaffected

This commit is contained in:
nyash-codex
2025-11-09 01:00:43 +09:00
parent 024a4fecb7
commit 5d2cd5bad0
37 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,35 @@
# DeRust Gap Analysis (Phase 21.9)
This memo enumerates gaps to execute Phase1/2 tasks safely.
## hv1_inline → Parity
- JSON support: ensure compare/branch/jump/phi/mir_call minimal are covered.
- Parity canaries: phase2037/* (flow), phase2170/* (state).
- Env guard: consider `HAKO_VERIFY_DISABLE_INLINE=1` for hard optout (optional).
## TLV Codec → C shim
- Minimal C API: tlv_encode(buf,len, out_ptr, out_len) / tlv_decode(...)
- FFI wrapper in Rust; map errors to Result.
- Tests: roundtrip on byte arrays; malformed inputs; size limits.
## MIR Interpreter (Rust) — Diagnostic mode
- Keep as fallback/diagnostic; Primary = Hakovm.
- Ensure boxcall/mir_call minimal parity for sample set.
- Gate via env to avoid accidental use in primary flows.
## LLVM Wrapper → Hako/C Harness
- Keep Python llvmlite primary until Hako IR is mature.
- Hako wrapper CLI to drive harness with env (`NYASH_LLVM_USE_HARNESS=1`).
- Tests: small endtoend const/ret and simple branch; IR dump gate remains.
## Resolver/Using SSOT (Hako First)
- Runner policy and HakoCheck strip/order unified; document precedence.
- Strict profiles disallow pathliteral using.
## FileBox Core → C (later)
- Small C layer for readonly (Analyzer) and read/write (dev) under caps; Rust shim remains.
## Acceptance Summary
- Build: cargo build (default) green.
- Smokes: quick/core green; parity canaries pass.
- Docs: roadmap + plan page + restore steps present.

View File

@ -16,11 +16,21 @@ Purpose: reduce Rust surface (nonplugin) while keeping correctness and revers
- TLV codec → C shim (FFI) with thin Rust wrapper.
- LLVM wrapper → Hako/C harness (Python stays primary until Hako IR is ready).
Deliverables & Tests
- hv1_inline: parity canaries = phase2037/flow + phase2170/state; add `HAKO_VERIFY_DISABLE_INLINE` opt-out (optional).
- TLV C shim: roundtrip tests (encode→decode) on representative payloads; FFI error mapping spec.
- MIR interpreter: keep as diagnostic path; parity sample set (const/binop/compare/branch/jump/ret/phi/mir_call minimal).
- LLVM wrapper: unify CLI entry; ensure `NYASH_LLVM_USE_HARNESS=1` path stays green.
### Phase 2 — Core Thinning (24 months)
- Plugin loader thin C wrapper (dlopen/dlsym), unify host ABI.
- Basic boxes (Array/Map/File) small C core (handlebased), keep Rust shim.
- Resolver/Using: SSOT in Hako; runner uses shared policy.
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 pathliteral using in strict profiles.
### Phase 3 — Longhaul (36 months)
- Python llvmlite → Hako IR builder + C ABI.
- Parser/MIR builder fully Hakofirst; Rust becomes fallback.
@ -36,3 +46,8 @@ Purpose: reduce Rust surface (nonplugin) while keeping correctness and revers
2) Add phase docs (docs/private/roadmap/phases/phase-21.9/PLAN.md).
3) Keep CI/dev instructions intact (no build break when features=none).
## 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 optin.
- Docs: keep RESTORE steps for any archived parts; small diffs, easy rollback.