diff --git a/docs/development/current/main/01-JoinIR-Selfhost-INDEX.md b/docs/development/current/main/01-JoinIR-Selfhost-INDEX.md index d4bdd95a..adfa9808 100644 --- a/docs/development/current/main/01-JoinIR-Selfhost-INDEX.md +++ b/docs/development/current/main/01-JoinIR-Selfhost-INDEX.md @@ -96,17 +96,19 @@ JoinIR の箱構造と責務、ループ/if の lowering パターンを把握 - `docs/development/current/main/phases/phase-128/README.md` 31. Phase 129: Materialize join_k continuation + LLVM parity(P1-C done) - `docs/development/current/main/phases/phase-129/README.md` -32. Phase 104: loop(true) break-only digits(VM + LLVM EXE) +32. Phase 130: if-only Normalized small expr/assign(PLAN) + - `docs/development/current/main/phases/phase-130/README.md` +33. Phase 104: loop(true) break-only digits(VM + LLVM EXE) - `docs/development/current/main/phases/phase-104/README.md` -33. Phase 107: json_cur find_balanced_* depth scan(VM + LLVM EXE) +34. Phase 107: json_cur find_balanced_* depth scan(VM + LLVM EXE) - `docs/development/current/main/phases/phase-107/README.md` -34. Phase 108: Pattern2 policy router SSOT(入口の薄さを固定) +35. Phase 108: Pattern2 policy router SSOT(入口の薄さを固定) - `docs/development/current/main/phases/phase-108/README.md` -35. Phase 109: error_tags hints SSOT(Fail-Fast + hint の語彙固定) +36. Phase 109: error_tags hints SSOT(Fail-Fast + hint の語彙固定) - `docs/development/current/main/phases/phase-109/README.md` -36. MIR Builder(Context 分割の入口) +37. MIR Builder(Context 分割の入口) - `src/mir/builder/README.md` -37. Scope/BindingId(shadowing・束縛同一性の段階移行) +38. Scope/BindingId(shadowing・束縛同一性の段階移行) - `docs/development/current/main/phase73-scope-manager-design.md` - `docs/development/current/main/PHASE_74_SUMMARY.md` - `docs/development/current/main/PHASE_75_SUMMARY.md` @@ -114,9 +116,9 @@ JoinIR の箱構造と責務、ループ/if の lowering パターンを把握 - `docs/development/current/main/phase78-bindingid-promoted-carriers.md` - `docs/development/current/main/phase80-bindingid-p3p4-plan.md`(P3/P4 への配線計画) - `docs/development/current/main/phase81-pattern2-exitline-contract.md`(promoted carriers の ExitLine 契約検証) -31. Boxification feedback(Phase 78–85 の振り返りと Phase 86 推奨) +39. Boxification feedback(Phase 78–85 の振り返りと Phase 86 推奨) - `docs/development/current/main/phase78-85-boxification-feedback.md` -32. Phase 86: Carrier Init Builder + Error Tags ✅ +40. Phase 86: Carrier Init Builder + Error Tags ✅ - **Status**: COMPLETE (2025-12-13) - **Modules**: - `src/mir/builder/control_flow/joinir/merge/carrier_init_builder.rs` (+8 tests) diff --git a/docs/development/current/main/10-Now.md b/docs/development/current/main/10-Now.md index f849fdb6..627bd2ef 100644 --- a/docs/development/current/main/10-Now.md +++ b/docs/development/current/main/10-Now.md @@ -18,13 +18,12 @@ - Unit tests: 1155/1155 PASS - 入口: `docs/development/current/main/phases/phase-129/README.md` -## Next: Phase 130+(Loop patterns / Complex RHS) +## Next: Phase 130(if-only Normalized small expr/assign) -**Phase 130以降の展開** -- Loop patterns の Normalized lowering -- Assign(complex expr) RHS 対応 -- Nested if 対応 -- 詳細は Phase 129 README の "Related Phases" 参照 +**Phase 130: if-only Normalized “Small Expr/Assign” Expansion(dev-only)** +- 目的: post_k 内の最小 post-if 計算(`x = x + 3; return x`)を Normalized で通す(PHI禁止) +- 入口: `docs/development/current/main/phases/phase-130/README.md` +- 受け入れ: Phase 130 VM + LLVM EXE smokes + Phase 129/128 回帰が green ## 2025-12-18:Phase 127 完了 ✅ diff --git a/docs/development/current/main/30-Backlog.md b/docs/development/current/main/30-Backlog.md index e02e6e2b..34b1e786 100644 --- a/docs/development/current/main/30-Backlog.md +++ b/docs/development/current/main/30-Backlog.md @@ -8,6 +8,10 @@ Related: ## 直近(JoinIR/selfhost) +- **Phase 130(if-only Normalized small expr/assign)** + - ねらい: loop に行く前に if-only Normalized を “実用” に寄せる(post_k 内の最小計算 `x = x + 3; return x`) + - 入口: `docs/development/current/main/phases/phase-130/README.md` + - **real-app loop regression の横展開(VM + LLVM EXE)** - ねらい: 実コード由来ループを 1 本ずつ最小抽出して fixture/smoke で固定する(段階投入)。 - 現状: Phase 107(find_balanced_array/object / json_cur 由来)まで固定済み。 diff --git a/docs/development/current/main/phases/phase-130/README.md b/docs/development/current/main/phases/phase-130/README.md new file mode 100644 index 00000000..d53f3cc4 --- /dev/null +++ b/docs/development/current/main/phases/phase-130/README.md @@ -0,0 +1,87 @@ +# Phase 130: if-only Normalized “Small Expr/Assign” Expansion (dev-only) + +Status: PLAN (P0–P3) +Scope: if-only Normalized(StepTree → Normalized shadow pipeline) +Related: +- Entry: `docs/development/current/main/10-Now.md` +- Phase 129 (join_k/post_k): `docs/development/current/main/phases/phase-129/README.md` +- ControlTree SSOT: `docs/development/current/main/design/control-tree.md` + +## Goal + +Increase usefulness of the if-only Normalized path without touching loop lowering yet: + +- Enable minimal post-if computation (`x = x + 3`) and returns via env. +- Keep **PHI禁止**: merge via env + continuations only. +- Keep **dev-only** and **既定挙動不変**: unmatched shapes fall back (strict can Fail-Fast for fixtures). + +## Non-Goals + +- No loops (Loop/Break/Continue still rejected by capability guard). +- No general expression lowering (start with one narrow shape only). +- No new env vars (use existing `joinir_dev_enabled()` / `joinir_strict_enabled()`). + +## Work Items (P0–P3) + +### P0: Fixtures + Smokes (VM + LLVM EXE) + +Add a “post-if update then return” fixture that forces post_k to execute and tests env updates: + +- New fixture: `apps/tests/phase130_if_only_post_if_add_min.hako` + - Case A: `flag=1` → expected `5` + - Case B: `flag=0` → expected `4` + - Output: `5\n4` +- Smokes (integration): + - `tools/smokes/v2/profiles/integration/apps/phase130_if_only_post_if_add_vm.sh` + - `tools/smokes/v2/profiles/integration/apps/phase130_if_only_post_if_add_llvm_exe.sh` + - Use `output_validator.sh` numeric-line assertion. + - LLVM EXE smoke uses `llvm_exe_runner.sh` + plugin gating. + +Acceptance: +- `phase130_*_vm.sh` PASS +- `phase130_*_llvm_exe.sh` PASS (SKIP allowed only if LLVM prerequisites missing; plugin prerequisites should be satisfied via existing runner) + +### P1: Assign(Variable) minimal + +Support `x = y` inside post_k (and/or inside branches) for if-only: + +- Only local variables (no field/property assign). +- RHS must resolve from env (`writes` or `inputs`). +- strict: unsupported shapes → `freeze_with_hint("phase130/assign/var/unsupported", ...)`. + +### P2: Assign(Add) minimal for integers + +Support `x = x + ` (exact shape) in post_k: + +- Strictly `Var + IntLiteral` with `lhs_var == dst_var` (no commutation, no general binop). +- Type: integer only (string concat stays out-of-scope; Fail-Fast under strict). + +### P3: Verifier tightening (env writes-only discipline) + +Add a structural check to ensure env updates only target `writes` fields: + +- In Normalized emission, any “env update” must update a field that exists in `EnvLayout.writes`. +- Writing to an `inputs` field is prohibited (strict Fail-Fast). + +## Verification + +Commands: + +```bash +cargo test --lib + +# New Phase 130 smokes +bash tools/smokes/v2/profiles/integration/apps/phase130_if_only_post_if_add_vm.sh +bash tools/smokes/v2/profiles/integration/apps/phase130_if_only_post_if_add_llvm_exe.sh + +# Regressions (minimum) +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 +bash tools/smokes/v2/profiles/integration/apps/phase128_if_only_partial_assign_normalized_vm.sh +``` + +## Notes + +- Phase 130 intentionally stays “if-only” to keep the change-set small and correctness-focused. +- Loop lowering in Normalized is a separate phase; do not mix scopes. +