phase: 20.49 COMPLETE; 20.50 Flow+String minimal reps; 20.51 selfhost v0/v1 minimal (Option A/B); hv1-inline binop/unop/copy; docs + run_all + CURRENT_TASK -> 21.0

This commit is contained in:
nyash-codex
2025-11-06 15:41:52 +09:00
parent 2dc370223d
commit 77d4fd72b3
1658 changed files with 6288 additions and 2612 deletions

View File

@ -1,36 +1,61 @@
Source Extensions Policy — .nyash vs .hako (Interim)
Source Extensions Policy — .hako と .nyash の等価性Phase 20.47
Intent
- Keep development stable while Hakorune VM (v1 Dispatcher/IR/φ) is brought up.
- Avoid crosscontamination between frontends; converge at MIR.
- 拡張子が異なるだけで、言語は 1 つ(.hako / .nyash は等価)。
- using は言語中立な“テキスト・プレリュード統合”に一本化してからパーサへ渡す。
Execution Mapping (current)
- .nyash → Nyash VM (Rust): NyashParser → MIR → VM. Full runtime/plugins path.
- .hako → Hakorune VM (v1): JSON v1 Dispatcher/IR/φbringup coverage; guarded extern.
- verify (MIR v1) → Hakorune primary, Core fallback for diagnosis.
Execution Mapping (unified)
- .hako / .nyash → using のテキスト統合merge_prelude_text Nyash Parser → MIR → VM 実行。
- verify (MIR v1) → hv1 早期経路NYASH_VERIFY_JSON + HAKO_VERIFY_V1_FORCE_HAKOVM=1
Resolver/Include/Normalize
- Using: unify to textmerge (merge_prelude_text). AST prelude merge is retired.
- Include: languagelevel unsupported; quick profile treats include as ERROR. Preinclude is testharness onlyverify の include fallback は撤去済み)。
- Normalize (inline/dev): CRLF→LF, redundant `; }` trimmed, tolerant `local` at line head in Hakorune inline drivers.
- Using: 常にテキスト統合。AST プレリュード統合は任意(プロファイルによる)。
- 拡張子の扱い: .hako を優先、.nyash を次点(両方探索)。
- using.paths 既定: apps, lib, ., lang/srcnyash.toml/hakorune.toml
- Include: 言語としては非推奨quick は ERROR。必要時のみ preinclude スクリプトを使用。
- Normalizeinline/dev: CRLF→LF、冗長 `; }` の最小削除、先頭 `local` の互換補助 等。
FailFast Guards
- Hako in Nyash VM: rejected by default (FailFast). Toggle: `HAKO_FAIL_FAST_ON_HAKO_IN_NYASH_VM=0` for dev only.
- Extern (Hako provider): `HAKO_V1_EXTERN_PROVIDER=1`; optional CABI tag/bridge with `HAKO_V1_EXTERN_PROVIDER_C_ABI=1` (default OFF).
FailFast Guards / Profiles
- FailFast: 既定OFF。`HAKO_FAIL_FAST_ON_HAKO_IN_NYASH_VM=1` のときのみ Hako 風ソースを Nyash VM 経路で拒否(診断用)。
- Profiles:
- dev/ci: using 有効。AST マージ 既定ON。相対パス using は許容。
- prod: using は名前解決のみalias/modules。相対パス using は ERROR。`NYASH_USING_PROFILE=prod`
- ExternHako provider: `HAKO_V1_EXTERN_PROVIDER=1`(開発時ガード)、`HAKO_V1_EXTERN_PROVIDER_C_ABI=1`(任意タグ)。
Why two extensions now?
- Same language intent, but different stability constraints at the frontend boundary:
- .hako through NyashParser caused parse/timeout/alias issues historically.
- We intentionally stopped that path and direct .hako to Hakorune VM while it matures.
Why two extensions?
- 言語は 1 つ。拡張子が異なるだけ(歴史的理由)。解決は等価で、.hako を優先・.nyash を次点で探索する。
Migration Plan (phased)
1) P2: IR iteration complete; φ table robust; dispatcher loop scanfree; extern canaries PASS without harness shim.
2) P3: verify default → Hakorune (Core fallback); document toggles and remove adhoc heuristics.
3) Prep: introduce stable Nyash→MIR v1 emit route to feed Hakorune VM when (and if) we want .nyash on hv1.
4) Deprecation: warn on `.nyash` (optin), then FailFast once hv1 parity is sufficient; remove legacy code in a later phase.
Migration Plan
- 本ドキュメントの時点で統一完了Phase 20.47)。以降は代表拡張/ハードニングを Phase 21.x で進める。
Best Practices (now)
- Prefer alias/modules over path using; avoid include in source.
- Keep quotes ASCII (`"`); avoid trailing semicolons before `}`.
- For verify, pass JSON via env (`NYASH_VERIFY_JSON`) and parse last numeric line as rc.
- Inline-cドライバは alias のみで構成include 不要)。
- パス using ではなく、nyash.toml/hakorune.toml の [modules]/[using.paths]/[aliases]/workspace を活用。
- ソース内 include は避ける(必要時は preinclude を使ってテキスト展開)。
- verify JSON env`NYASH_VERIFY_JSON`)経由で渡し、末尾数値を rc として評価。
Quick Example (alias using)
```
using selfhost.vm.entry as MiniVmEntryBox
static box Main { method main(args) {
// alias 解決の確認(静的メソッド呼び出し)
local _s = MiniVmEntryBox.int_to_str(0)
return 0
} }
```
実行quick プロファイル、dev 想定):
`bash tools/smokes/v2/run.sh --profile quick --filter 'phase2047/using_alias_selfhost_vm_entry_canary_vm.sh'`
Nested Prelude Example
```
using selfhost.vm.hakorune-vm.json_v1_reader as JsonV1ReaderBox
static box Main { method main(args) {
local seg = JsonV1ReaderBox.get_block0_instructions('{"schema_version":"1.0","functions":[{"name":"main","blocks":[{"id":0,"instructions":[]}]}]}')
return seg == "" ? 0 : 1
} }
```
実行:
`bash tools/smokes/v2/run.sh --profile quick --filter 'phase2047/using_alias_nested_prelude_json_v1_reader_canary_vm.sh'`
Notes (this pass)
- StageB emit の安定化: inline コンパイラ無効化と失敗時 tail 出力で原因を可視化。
- hv1 inline の拡張: const/compare/branch/jump/phi/extern最小を実装。