From b2af9fb297513e014d1a30a60f7d9eddbf8c5320 Mon Sep 17 00:00:00 2001 From: nyash-codex Date: Thu, 18 Dec 2025 08:18:20 +0900 Subject: [PATCH] docs: update normalized_shadow references and Phase 129 status --- .../current/main/01-JoinIR-Selfhost-INDEX.md | 2 +- docs/development/current/main/10-Now.md | 1 + .../current/main/design/control-tree.md | 13 ++++-- .../current/main/phases/phase-121/README.md | 6 +-- .../current/main/phases/phase-122/README.md | 2 +- .../current/main/phases/phase-129/README.md | 45 ++++++++----------- 6 files changed, 35 insertions(+), 34 deletions(-) diff --git a/docs/development/current/main/01-JoinIR-Selfhost-INDEX.md b/docs/development/current/main/01-JoinIR-Selfhost-INDEX.md index e7adcd94..fa2e41c8 100644 --- a/docs/development/current/main/01-JoinIR-Selfhost-INDEX.md +++ b/docs/development/current/main/01-JoinIR-Selfhost-INDEX.md @@ -94,7 +94,7 @@ JoinIR の箱構造と責務、ループ/if の lowering パターンを把握 - `docs/development/current/main/phases/phase-127/README.md` 30. Phase 128: if-only Normalized partial-assign keep/merge(dev-only) - `docs/development/current/main/phases/phase-128/README.md` -31. Phase 129: Materialize join_k continuation + LLVM parity(P1 in progress) +31. Phase 129: Materialize join_k continuation + LLVM parity(P1-B done, P2 in progress) - `docs/development/current/main/phases/phase-129/README.md` 32. Phase 104: loop(true) break-only digits(VM + LLVM EXE) - `docs/development/current/main/phases/phase-104/README.md` diff --git a/docs/development/current/main/10-Now.md b/docs/development/current/main/10-Now.md index b49044f1..a688b038 100644 --- a/docs/development/current/main/10-Now.md +++ b/docs/development/current/main/10-Now.md @@ -4,6 +4,7 @@ **Phase 129: Materialize join_k continuation(dev-only)** - 現状: Phase 129-B で join_k “if-as-last” を実体化(then/else は TailCall(join_k)) +- 補足: `src/mir/control_tree/normalized_shadow/` は責務分離済み(`if_as_last_join_k.rs` / `normalized_verifier.rs` / `parity_contract.rs` / `dev_pipeline.rs` など) - 残り: post-if(`if { x=2 }; return x`)を post_k continuation で表現(join_k → post_k の tailcall) - 入口: `docs/development/current/main/phases/phase-129/README.md` diff --git a/docs/development/current/main/design/control-tree.md b/docs/development/current/main/design/control-tree.md index 7b893e9c..8b056c5f 100644 --- a/docs/development/current/main/design/control-tree.md +++ b/docs/development/current/main/design/control-tree.md @@ -162,11 +162,18 @@ StepTree は capability を“宣言”し、未対応は **Fail-Fast(dev-only - 責務: "if-only に限定" チェック、capability 拒否理由の SSOT - Unsupported capability の明示的列挙(Loop / Break / Continue 等) -**`normalized_shadow/parity.rs`**: -- 責務: router/既存経路との比較(dev ログ / strict fail-fast) +**`normalized_shadow/parity_contract.rs`**: +- 責務: router/既存経路との契約比較(dev ログ / strict fail-fast) - 比較対象: 出口契約(`exits`)と writes の一致(最小で壊れにくい) - strict mode では `freeze_with_hint` でエラー(hint 必須) +**`normalized_shadow/normalized_verifier.rs`**: +- 責務: 生成された Normalized `JoinModule` の構造検証(strict で Fail-Fast) +- 例: env 引数個数、JoinFunction の形、tail-call 形式など + +**`normalized_shadow/dev_pipeline.rs`**: +- 責務: dev/strict の入口を一本化(capability guard → shadow lowering → parity/verify) + ### Parity検証(最小セット) **比較対象**(値の一致まではやらない): @@ -258,7 +265,7 @@ StepTree は capability を“宣言”し、未対応は **Fail-Fast(dev-only - 責務: capability チェック(変更なし) - Unsupported capability の SSOT(Loop/Break/Continue) -**`normalized_shadow/parity.rs`**: +**`normalized_shadow/normalized_verifier.rs`**: - 責務: 構造検証(関数数/継続数/tail-call 形式/env 引数) - strict 時: 生成失敗で `freeze_with_hint` - 実行器があれば RC 比較も可能(オプション) diff --git a/docs/development/current/main/phases/phase-121/README.md b/docs/development/current/main/phases/phase-121/README.md index 22b66995..b9342a55 100644 --- a/docs/development/current/main/phases/phase-121/README.md +++ b/docs/development/current/main/phases/phase-121/README.md @@ -154,10 +154,10 @@ Phase 121 is complete. Future work: ## Known Limitations -- **Stub implementation**: Returns empty JoinModule (contract check only) +- **Phase 121 scope**: contract parity(exits/writes)までを固定(値の一致や JoinModule の実行は対象外) - **If-only scope**: Loops/breaks/continues rejected - **No value comparison**: Only contracts compared (exits/writes) -- **LLVM test incomplete**: Harness configuration needed (VM tests validate core) +- **JoinModule emission**: Phase 122+ で段階的に追加(Phase 121 自体は parity の足場) ## Files Modified @@ -165,7 +165,7 @@ Phase 121 is complete. Future work: - `src/mir/control_tree/normalized_shadow/mod.rs` - `src/mir/control_tree/normalized_shadow/contracts.rs` - `src/mir/control_tree/normalized_shadow/builder.rs` -- `src/mir/control_tree/normalized_shadow/parity.rs` +- `src/mir/control_tree/normalized_shadow/parity_contract.rs` - `tools/smokes/v2/profiles/integration/apps/phase121_shadow_if_only_vm.sh` - `tools/smokes/v2/profiles/integration/apps/phase121_shadow_if_only_llvm_exe.sh` diff --git a/docs/development/current/main/phases/phase-122/README.md b/docs/development/current/main/phases/phase-122/README.md index 865058ca..635b96c4 100644 --- a/docs/development/current/main/phases/phase-122/README.md +++ b/docs/development/current/main/phases/phase-122/README.md @@ -60,7 +60,7 @@ ✅ **完了** - commit \`cc1a0946b\`(P2-P3 統合) **変更**: -- \`src/mir/control_tree/normalized_shadow/parity.rs\` +- \`src/mir/control_tree/normalized_shadow/normalized_verifier.rs\` - \`verify_normalized_structure()\` 追加 - \`src/mir/builder/calls/lowering.rs\` - Phase 122 検証呼び出し追加 diff --git a/docs/development/current/main/phases/phase-129/README.md b/docs/development/current/main/phases/phase-129/README.md index a5ec9dd6..0c73147a 100644 --- a/docs/development/current/main/phases/phase-129/README.md +++ b/docs/development/current/main/phases/phase-129/README.md @@ -79,7 +79,7 @@ join_k(env_phi): ## Implementation Plan -### P0: LLVM EXE smoke for Phase 128 ✅ +### P0: LLVM EXE parity baseline (Phase 128) ✅ - Add `phase128_if_only_partial_assign_normalized_llvm_exe.sh` - Verify VM+LLVM parity for Phase 128 baseline @@ -87,29 +87,21 @@ join_k(env_phi): **Status**: DONE (commit e7ad3d31b) -### P1: Materialize join_k Continuation +### P1-B: Materialize join_k (if-as-last) ✅ -**Target**: `src/mir/control_tree/normalized_shadow/builder.rs` +**Target**: +- `src/mir/control_tree/normalized_shadow/if_as_last_join_k.rs` +- orchestrator: `src/mir/control_tree/normalized_shadow/builder.rs` +- structure verification: `src/mir/control_tree/normalized_shadow/normalized_verifier.rs` +- contract parity: `src/mir/control_tree/normalized_shadow/parity_contract.rs` -**Changes**: -1. **lower_if_node**: Generate join_k function - - Create JoinFunction with env parameter - - then: `TailCall(join_k, env_then)` - - else: `TailCall(join_k, env_else)` - - join_k body: process post-if statements +**What is supported**: +- if-only, and the `if` is the last statement (Phase 129-B) +- then/else: TailCall(join_k) with env argument (PHI禁止) -2. **verify_normalized_structure**: Add join_k checks - - If exists → join_k exists (by name or structure) - - then/else end with TailCall (not Ret) - - join_k has params (env fields) - - No PHI instructions anywhere +**Status**: DONE (Phase 129-B: fixture + VM smoke PASS) -**Acceptance**: -- `cargo test --lib` PASS -- Phase 128 VM smoke PASS -- Phase 129 LLVM EXE smoke PASS (new fixture) - -### P2: Post-If Return Var Fixture +### P2: Post-if support (return-var) 🔜 **New fixture**: `apps/tests/phase129_if_only_post_if_return_var_min.hako` ```hako @@ -122,9 +114,9 @@ x=1; flag=1; if flag==1 { x=2 }; print(x); return "OK" - `NYASH_JOINIR_DEV=1 HAKO_JOINIR_STRICT=1` - Verify join_k continuation works -**Acceptance**: -- VM smoke PASS -- join_k actually used (not fallback path) +**Status**: +- Fixture + VM smoke exist. +- Not yet guaranteed to run through Normalized join_k path (can still fall back). ### P3: Documentation @@ -136,7 +128,8 @@ x=1; flag=1; if flag==1 { x=2 }; print(x); return "OK" - ✅ P0: Phase 128 LLVM EXE smoke passes - ✅ P1-B: join_k materialized for if-as-last (then/else tail-call join_k) - ✅ P1-B: verify_normalized_structure enforces join_k tailcall + PHI禁止 -- [ ] P2: Phase 129 fixture + VM smoke passes +- ✅ P2 (setup): fixture + VM smoke exist +- [ ] P2 (behavior): post-if path runs via Normalized (no fallback) - [ ] P3: Documentation updated - [ ] Regression: phase103, phase118, phase128 all PASS - [ ] `cargo test --lib` PASS @@ -147,10 +140,10 @@ x=1; flag=1; if flag==1 { x=2 }; print(x); return "OK" # Unit tests cargo test --lib -# Smoke tests +# Smoke tests (baseline) bash tools/smokes/v2/profiles/integration/apps/phase128_if_only_partial_assign_normalized_vm.sh bash tools/smokes/v2/profiles/integration/apps/phase128_if_only_partial_assign_normalized_llvm_exe.sh -bash tools/smokes/v2/profiles/integration/apps/phase129_if_only_post_if_return_var_vm.sh +bash tools/smokes/v2/profiles/integration/apps/phase129_join_k_as_last_vm.sh # Regression bash tools/smokes/v2/profiles/integration/apps/phase103_if_only_llvm_exe.sh