Files
hakorune/docs/development/current/main/30-Backlog.md

286 lines
18 KiB
Markdown
Raw Normal View History

# Self Current Task — Backlog (main)
Status: Active
Scope: 「次にやる候補」を短く列挙するメモ。現状は `docs/development/current/main/10-Now.md` を入口にする。
Related:
- `docs/development/current/main/10-Now.md`
- `docs/development/current/main/DOCS_LAYOUT.md`
## 直近JoinIR/selfhost
feat(llvm/phi): Phase 277 P1 - fail-fast validation for PHI strict mode ## Summary Implemented fail-fast validation for PHI ordering and value resolution in strict mode. ## Changes ### P1-1: Strict mode for "PHI after terminator" - File: `src/llvm_py/phi_wiring/wiring.py::ensure_phi` - Behavior: `NYASH_LLVM_PHI_STRICT=1` → RuntimeError if PHI created after terminator - Default: Warning only (no regression) ### P1-2: Strict mode for "fallback 0" - File: `src/llvm_py/phi_wiring/wiring.py::wire_incomings` - Behavior: Strict mode forbids silent fallback to 0 (2 locations) - Location 1: Unresolvable incoming value - Location 2: Type coercion failure - Error messages point to next debug file: `llvm_builder.py::_value_at_end_i64` ### P1-3: Connect verify_phi_ordering() to execution path - File: `src/llvm_py/builders/function_lower.py` - Behavior: Verify PHI ordering after all instructions emitted - Debug mode: Shows "✅ All N blocks have correct PHI ordering" - Strict mode: Raises RuntimeError with block list if violations found ## Testing ✅ Test 1: strict=OFF - passes without errors ✅ Test 2: strict=ON - passes without errors (no violations in test fixtures) ✅ Test 3: debug mode - verify_phi_ordering() connected and running ## Scope - LLVM harness (Python) changes only - No new environment variables (uses existing 3 from Phase 277 P2) - No JoinIR/Rust changes (root fix is Phase 279) - Default behavior unchanged (strict mode opt-in) ## Next Steps - Phase 278: Remove deprecated env var support - Phase 279: Root fix - unify "2本のコンパイラ" pipelines 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-22 14:48:37 +09:00
- **Phase 277 P0/P1planned, docs+validation: PHI型推論ドキュメント整備 + PHI順序検証強化**
- 入口: `docs/development/current/main/phases/phase-277/README.md`
- 目的:
- Phase 275/276 で入った PHI 型推論の “導線/責務/SSOT” を docs に固定する
- PHI 配置順序PHI → non-PHI → terminator違反を fail-fast で検出しやすくする
- **Phase 278planned, cleanup: PHI旧環境変数の後方互換性削除**
- 目的: Phase 277 P2 で deprecated 扱いにした旧 env var を削除し、1セットに収束させる
- 入口: `docs/development/current/main/phases/phase-278/README.md`
- 実装ガイド: `docs/development/current/main/phases/phase-278/P0-INSTRUCTIONS.md`
- **Phase 279planned, impl: Type propagation pipeline SSOT 統一lifecycle / JoinIR / LLVM の二重化解消)**
- 目的: 型伝播Copy/BinOp/PHI/Compare など)の “順序/入口” を 1 本に固定し、経路差による二重バグを根絶する
- 入口: `docs/development/current/main/phases/phase-279/README.md`
- 実装ガイド: `docs/development/current/main/phases/phase-279/P0-INSTRUCTIONS.md`
- **Phase 272✅ complete: Pattern6/7 を Frag+emit_frag へ吸収(段階適用)**
- 目的: scan系 loop の CFG 構築を `Frag/ExitKind` 合成へ寄せ、pattern列挙の増殖を止める
- 完了: P0.1Pattern6✅ + P0.2Pattern7
- 入口: fixture/smoke を SSOT として固定Pattern6→Pattern7 の順で段階適用)
- 詳細: `phases/phase-272/README.md`
- **Phase 273planned, design-first: Pattern → Plan Extractorpure→ PlanLowerer で収束**
- 目的: pattern の裾広がりを止め、`Plan → Frag → emit_frag()` の本線へ一本化するterminator SSOT は維持)
- 相談メモ: `docs/development/current/main/investigations/phase-272-frag-plan-architecture-consult.md`
- 受け入れ(最小):
- extractor が builder を触らないID採番/PHI挿入禁止
- Plan 語彙を固定(`seq/if/loop/exit/effect/let`
- PlanLowerer が block/value/phi を作る唯一の箱になる
- **Phase 274active, design-first: Type SSOT Alignmentlocal + dynamic runtime**
- 入口SSOT: `docs/reference/language/types.md`
- P1✅完了: Rust VM が `TypeOp(Check/Cast)` を実行可能(`is/as` が動く)
- P2✅完了: LLVM ラインllvmlite harness`TypeOp` を SSOT に合わせる
- P3decision: truthiness / equality / compare / `+` の coercion を SSOT として固定(必要なら “仕様変更フェーズ” を追加)
- 詳細: `phases/phase-274/README.md`
- **Phase 270✅ 完了): JoinIR-only minimal loop SSOT**
- `apps/tests/phase270_p0_loop_min_const.hako` + VM smoke で “最小 const loop” を固定exit=3
- Pattern1 は test-only stub のため不適合 → Pattern9AccumConstLoopを橋渡しとして追加
- 詳細: `phases/phase-270/README.md`
feat(llvm/phi): Phase 277 P1 - fail-fast validation for PHI strict mode ## Summary Implemented fail-fast validation for PHI ordering and value resolution in strict mode. ## Changes ### P1-1: Strict mode for "PHI after terminator" - File: `src/llvm_py/phi_wiring/wiring.py::ensure_phi` - Behavior: `NYASH_LLVM_PHI_STRICT=1` → RuntimeError if PHI created after terminator - Default: Warning only (no regression) ### P1-2: Strict mode for "fallback 0" - File: `src/llvm_py/phi_wiring/wiring.py::wire_incomings` - Behavior: Strict mode forbids silent fallback to 0 (2 locations) - Location 1: Unresolvable incoming value - Location 2: Type coercion failure - Error messages point to next debug file: `llvm_builder.py::_value_at_end_i64` ### P1-3: Connect verify_phi_ordering() to execution path - File: `src/llvm_py/builders/function_lower.py` - Behavior: Verify PHI ordering after all instructions emitted - Debug mode: Shows "✅ All N blocks have correct PHI ordering" - Strict mode: Raises RuntimeError with block list if violations found ## Testing ✅ Test 1: strict=OFF - passes without errors ✅ Test 2: strict=ON - passes without errors (no violations in test fixtures) ✅ Test 3: debug mode - verify_phi_ordering() connected and running ## Scope - LLVM harness (Python) changes only - No new environment variables (uses existing 3 from Phase 277 P2) - No JoinIR/Rust changes (root fix is Phase 279) - Default behavior unchanged (strict mode opt-in) ## Next Steps - Phase 278: Remove deprecated env var support - Phase 279: Root fix - unify "2本のコンパイラ" pipelines 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-22 14:48:37 +09:00
- **Phase 271✅ 完了, docs-only: Bridge pattern 撤去条件SSOT**
- 対象: bridge pattern例: `Pattern9_AccumConstLoop`
- 目的: 「汎用化しない」「Frag 合成へ吸収して削除する」を SSOT 化
feat(llvm/phi): Phase 277 P1 - fail-fast validation for PHI strict mode ## Summary Implemented fail-fast validation for PHI ordering and value resolution in strict mode. ## Changes ### P1-1: Strict mode for "PHI after terminator" - File: `src/llvm_py/phi_wiring/wiring.py::ensure_phi` - Behavior: `NYASH_LLVM_PHI_STRICT=1` → RuntimeError if PHI created after terminator - Default: Warning only (no regression) ### P1-2: Strict mode for "fallback 0" - File: `src/llvm_py/phi_wiring/wiring.py::wire_incomings` - Behavior: Strict mode forbids silent fallback to 0 (2 locations) - Location 1: Unresolvable incoming value - Location 2: Type coercion failure - Error messages point to next debug file: `llvm_builder.py::_value_at_end_i64` ### P1-3: Connect verify_phi_ordering() to execution path - File: `src/llvm_py/builders/function_lower.py` - Behavior: Verify PHI ordering after all instructions emitted - Debug mode: Shows "✅ All N blocks have correct PHI ordering" - Strict mode: Raises RuntimeError with block list if violations found ## Testing ✅ Test 1: strict=OFF - passes without errors ✅ Test 2: strict=ON - passes without errors (no violations in test fixtures) ✅ Test 3: debug mode - verify_phi_ordering() connected and running ## Scope - LLVM harness (Python) changes only - No new environment variables (uses existing 3 from Phase 277 P2) - No JoinIR/Rust changes (root fix is Phase 279) - Default behavior unchanged (strict mode opt-in) ## Next Steps - Phase 278: Remove deprecated env var support - Phase 279: Root fix - unify "2本のコンパイラ" pipelines 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-22 14:48:37 +09:00
- 成果物:
- `docs/development/current/main/design/edgecfg-fragments.md``Bridge patterns撤去条件SSOT` に “bridge contract” テンプレを追加
- `Pattern9_AccumConstLoop` の撤去条件fixture/smoke/手順)を同セクションに明文化
- SSOT: `docs/development/current/main/design/edgecfg-fragments.md`
feat(llvm/phi): Phase 277 P1 - fail-fast validation for PHI strict mode ## Summary Implemented fail-fast validation for PHI ordering and value resolution in strict mode. ## Changes ### P1-1: Strict mode for "PHI after terminator" - File: `src/llvm_py/phi_wiring/wiring.py::ensure_phi` - Behavior: `NYASH_LLVM_PHI_STRICT=1` → RuntimeError if PHI created after terminator - Default: Warning only (no regression) ### P1-2: Strict mode for "fallback 0" - File: `src/llvm_py/phi_wiring/wiring.py::wire_incomings` - Behavior: Strict mode forbids silent fallback to 0 (2 locations) - Location 1: Unresolvable incoming value - Location 2: Type coercion failure - Error messages point to next debug file: `llvm_builder.py::_value_at_end_i64` ### P1-3: Connect verify_phi_ordering() to execution path - File: `src/llvm_py/builders/function_lower.py` - Behavior: Verify PHI ordering after all instructions emitted - Debug mode: Shows "✅ All N blocks have correct PHI ordering" - Strict mode: Raises RuntimeError with block list if violations found ## Testing ✅ Test 1: strict=OFF - passes without errors ✅ Test 2: strict=ON - passes without errors (no violations in test fixtures) ✅ Test 3: debug mode - verify_phi_ordering() connected and running ## Scope - LLVM harness (Python) changes only - No new environment variables (uses existing 3 from Phase 277 P2) - No JoinIR/Rust changes (root fix is Phase 279) - Default behavior unchanged (strict mode opt-in) ## Next Steps - Phase 278: Remove deprecated env var support - Phase 279: Root fix - unify "2本のコンパイラ" pipelines 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-22 14:48:37 +09:00
- **Phase 269 P1✅ 完了): Pattern8 を EdgeCFG で実装SSA を閉じる)**
- 方針: emission 入口で Frag 構築break/continue 無しなので `compose::loop_()` は使わず手配線)
feat(llvm/phi): Phase 277 P1 - fail-fast validation for PHI strict mode ## Summary Implemented fail-fast validation for PHI ordering and value resolution in strict mode. ## Changes ### P1-1: Strict mode for "PHI after terminator" - File: `src/llvm_py/phi_wiring/wiring.py::ensure_phi` - Behavior: `NYASH_LLVM_PHI_STRICT=1` → RuntimeError if PHI created after terminator - Default: Warning only (no regression) ### P1-2: Strict mode for "fallback 0" - File: `src/llvm_py/phi_wiring/wiring.py::wire_incomings` - Behavior: Strict mode forbids silent fallback to 0 (2 locations) - Location 1: Unresolvable incoming value - Location 2: Type coercion failure - Error messages point to next debug file: `llvm_builder.py::_value_at_end_i64` ### P1-3: Connect verify_phi_ordering() to execution path - File: `src/llvm_py/builders/function_lower.py` - Behavior: Verify PHI ordering after all instructions emitted - Debug mode: Shows "✅ All N blocks have correct PHI ordering" - Strict mode: Raises RuntimeError with block list if violations found ## Testing ✅ Test 1: strict=OFF - passes without errors ✅ Test 2: strict=ON - passes without errors (no violations in test fixtures) ✅ Test 3: debug mode - verify_phi_ordering() connected and running ## Scope - LLVM harness (Python) changes only - No new environment variables (uses existing 3 from Phase 277 P2) - No JoinIR/Rust changes (root fix is Phase 279) - Default behavior unchanged (strict mode opt-in) ## Next Steps - Phase 278: Remove deprecated env var support - Phase 279: Root fix - unify "2本のコンパイラ" pipelines 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-22 14:48:37 +09:00
- 完了: header に `i` の PHI を追加して SSA を閉じた(`i_current = phi [i_init, preheader], [i_next, step]`
- early-exit の `return false` は Return wire、`return true` は loop 後 AST に任せる
- Pattern8 の返り値は当面 `void`loop-statement 扱い)
feat(llvm/phi): Phase 277 P1 - fail-fast validation for PHI strict mode ## Summary Implemented fail-fast validation for PHI ordering and value resolution in strict mode. ## Changes ### P1-1: Strict mode for "PHI after terminator" - File: `src/llvm_py/phi_wiring/wiring.py::ensure_phi` - Behavior: `NYASH_LLVM_PHI_STRICT=1` → RuntimeError if PHI created after terminator - Default: Warning only (no regression) ### P1-2: Strict mode for "fallback 0" - File: `src/llvm_py/phi_wiring/wiring.py::wire_incomings` - Behavior: Strict mode forbids silent fallback to 0 (2 locations) - Location 1: Unresolvable incoming value - Location 2: Type coercion failure - Error messages point to next debug file: `llvm_builder.py::_value_at_end_i64` ### P1-3: Connect verify_phi_ordering() to execution path - File: `src/llvm_py/builders/function_lower.py` - Behavior: Verify PHI ordering after all instructions emitted - Debug mode: Shows "✅ All N blocks have correct PHI ordering" - Strict mode: Raises RuntimeError with block list if violations found ## Testing ✅ Test 1: strict=OFF - passes without errors ✅ Test 2: strict=ON - passes without errors (no violations in test fixtures) ✅ Test 3: debug mode - verify_phi_ordering() connected and running ## Scope - LLVM harness (Python) changes only - No new environment variables (uses existing 3 from Phase 277 P2) - No JoinIR/Rust changes (root fix is Phase 279) - Default behavior unchanged (strict mode opt-in) ## Next Steps - Phase 278: Remove deprecated env var support - Phase 279: Root fix - unify "2本のコンパイラ" pipelines 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-22 14:48:37 +09:00
- 補足DONE: static box の `this/me` は MethodCall 共通入口で static call に正規化済みPattern8 は現状 static box 文脈を対象外)
- 詳細: `phases/phase-269/README.md`
- **Phase 270+planned: Pattern6/7 への Frag 適用**
- Pattern6: Match scanindex_of 系)
- Pattern7: Split scansplit 系)
- 統一的なループ処理パターン確立
- Pattern 分岐削減
feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support ## Phase 146 P0: ANF Routing SSOT Unified **Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering **Changes**: - expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF) - post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper - contract.rs: Already had `CondLoweringFailed` out-of-scope reason **Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions ## Phase 146 P1: Compare Operator Support **Goal**: Enable ANF for condition expressions with Compare operators **Changes**: - joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1) - expr_lowerer_box.rs: PureOnly scope ANF support (L56-66) - execute_box.rs: Compare operator support (+122 lines) - `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()` - Extended `normalize_and_lower()` for Compare **Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions ## Phase 147 P0: Recursive Comparison ANF **Goal**: Extend recursive ANF to Compare operators **Changes**: - contract.rs: Added `AnfParentKind::Compare` variant - plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139) - Distinguishes Compare vs arithmetic BinaryOp **Benefits**: Enables recursive ANF for comparisons - `s.length() == 3` → `t = s.length(); if (t == 3)` ✅ - `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅ ## Implementation Summary **Files Modified** (9 files, +253 lines, -25 lines = +228 net): 1. src/config/env/joinir_dev.rs (+28 lines) 2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines) 3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines) 4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines) 5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines) 6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines) 7. CURRENT_TASK.md 8. docs/development/current/main/10-Now.md 9. docs/development/current/main/30-Backlog.md **Files Created** (7 files): - apps/tests/phase146_p0_if_cond_unified_min.hako - apps/tests/phase146_p1_if_cond_intrinsic_min.hako - tools/smokes/.../phase146_p0_if_cond_unified_vm.sh - tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh - tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh - docs/development/current/main/phases/phase-146/README.md **Acceptance Criteria**: ✅ All met - cargo build --release: PASS (0 errors, 0 warnings) - Phase 145 regressions: PASS (exit 12, 18, 5) - Phase 146 P0: PASS (exit 7) - Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1) **Architecture**: - SSOT: ANF routing only in `lower_expr_with_scope()` L54-84 - Box-First: Phase 145 `anf/` module extended - Legacy removed: post_if_post_k.rs unified with SSOT 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
- **収束方針SSOT案: Expr/Condition/Control の 3 箱分割**
- ExprLowererBox式SSOT: `AST(expr)``(prelude, value)`ANF含む。pure/impure/whitelist/strict を集約入口SSOT
- ConditionLowererBox条件→分岐SSOT: `AST(cond)``BranchPlan`。評価順は ExprLowererBox に委譲し、`&&/||` は制御語彙で扱う。
- ControlLowererBox制御SSOT: `StepNode/ControlTree` → JoinIR継続 + env`if/loop` を担当し、条件は ConditionLowererBox に委譲。
- **Phase 141 P2+planned: Call/MethodCalleffects + typing を分離して段階投入)**
- ねらい: pure/impure 境界を壊さずに、impure lowering を段階投入する。
- 前提DONE:
- Phase 141 P1.5: known intrinsic allowlist + available_inputs 3-source merge + diagnostics
- 受け入れ条件:
- out-of-scope は `Ok(None)` でフォールバック(既定挙動不変)
- effects の順序付けは SSOT で固定してから解禁by-name 増殖禁止)
- **Phase 144-anfplanned: impure 式導入の順序固定ANF**
- ねらい: `x + f(y)` 等の “pure + impure 混在” で評価順が仕様になる前に、ANF で順序固定を SSOT 化する
- 入口: `docs/development/current/main/phases/phase-144-anf/INSTRUCTIONS.md`
- 受け入れ条件:
- impure を lowering できない場合は `Ok(None)` でフォールバック(既定挙動不変)
- dev/strict では「順序固定の欠落」を Fail-Fast診断に順序ログを含める
- **Phase 143-loopvocab R0planned: Contract SSOT 抽出refactor P0 → modular components**
- 目的: loop_true_if_break_continue.rs を「検出/契約/変換」に分割し、P1/P2 での if分岐増殖を防ぐ
- 実装:
- 新ファイル: `src/mir/control_tree/normalized_shadow/common/loop_if_exit_contract.rs`
- `enum LoopIfExitThen { Break, Continue }`
- `struct LoopIfExitShape { has_else: bool, then: LoopIfExitThen, else_: Option<LoopIfExitThen>, cond_scope: ExprLoweringScope }`
- `enum OutOfScopeReason { NotLoopTrue, BodyNotSingleIf, ThenNotExit, ElseNotSupported, CondOutOfScope(...) }`
- Refactor: loop_true_if_break_continue.rs は「shape抽出 → lower」だけに縮退SSOT は contract側
- Tests: unit test を dedicated module へ分離test maintainability
- 受け入れ条件:
- cargo check ✅no errors
- P1/P2 での if分岐を防ぐcontract で決定性を保証)
- out-of-scope は `Ok(None)` で一貫(既定挙動不変)
- **Phase 143-loopvocab P1planned: continue 語彙追加**
- 対象: `loop(true) { if(cond_pure) continue }` を same lowering に通す
- 実装:
- LoopIfExitShape で `LoopIfExitThen::Continue` を許可
- JoinModule: if true → loop_step (continue semantics)
- Fixtures: `phase143_loop_true_if_continue_min.hako`
- Smoke: VM + LLVM EXE
- Out-of-scope は `Ok(None)` のまま
DONEPhase 143-loopvocab P2: else 対称化B-C / C-B
- 記録: `docs/development/current/main/10-Now.md`
- **Phase 143-loopvocab P3+planned: impure conditions 対応**
- 目的: `if(cond_impure) break/continue` を ANF/順序固定の上で段階投入する
- 方針: Phase 145-anf の契約hoist + left-to-rightを条件式にも適用
- **Phase 263+planned: Pattern2 LoopBodyLocal promotionseg**
- 目的: StageB compilebundle_resolver系で露出している Pattern2 `LoopBodyLocal(seg)` を受理し、quick の first FAIL を進める
- 受け入れ条件:
- 最小再現 fixture + smoke で固定(先に失敗を SSOT 化)
- Pattern2 が不成立のときは “部分続行” せず `Ok(None)` で fallback既定挙動不変
- **DONEPhase 263 P0.2: Pattern2 PromoteDecision API hardening**
- 入口SSOT: `src/mir/builder/control_flow/joinir/patterns/pattern2/api/`
- `PromoteDecision::{Promoted, NotApplicable, Freeze}``try_promote(...)` に参照点を収束Option揺れを撤去
- **Phase 264✅ 入口作成完了): EdgeCFG Fragment 入口作成design-first**
- **ステータス**: ✅ 入口作成完了(適用は次フェーズ)
- **実装内容**:
- `edgecfg/api/` フォルダに SSOT 入口作成
- `ExitKind`, `EdgeStub`, `Frag` の型定義
- `seq`, `if_`, `loop_`, `cleanup` のシグネチャ固定pub(crate)
- 最小ユニットテスト 3個
- ドキュメント連動edgecfg-fragments.md
- **制約遵守**:
- 既存 pattern6/7/8 未改変
- merge/EdgeCFG 未改変
- cargo test -p nyash-rust --lib --no-run 成功確認
- **次フェーズへの橋渡し**:
- Phase 265 で Pattern8 適用時に `compose::loop_` を実装
- 再利用確認後、pattern番号分岐を段階的に削減
- **Phase 265 P0✅ 完了): compose/verify 最小実装**
- **目的**: 入口SSOTの形を固める迷子防止
- **実装**:
- compose::loop_() 最小実装exit集合分類のみ、配線なし
- verify_frag_invariants() 最小実装(デバッグガード付き)
- compose::loop_() ユニットテスト 2個追加
- **制約**:
- Pattern8 未改変P0では触らない、偽Frag回避
- 配線ロジックは P1 以降
- **次**: Phase 265 P1 で配線ロジック + Pattern8適用
- **Phase 265 P1✅ 完了): compose 配線ロジック実装**
- **目的**: Frag/ExitKind の配線能力を BasicBlockId 層で証明
- **実装**:
- EdgeStub.target 追加Option<BasicBlockId>
- compose::loop_() 配線ロジックContinue → header, Break → after
- verify_frag_invariants() 配線契約検証
- test-only PoC5個のテスト: 既存2個更新 + 新規3個追加
- **配線契約**:
- Continue(loop_id) の EdgeStub.target = Some(header)
- Break(loop_id) の EdgeStub.target = Some(after)
- Normal/Return/Unwind の EdgeStub.target = None上位へ伝搬
- **制約**:
- MIR 命令生成なしFrag 層のみ)
- NormalizedShadow 未適用Phase 267 に繰り越し)
feat(edgecfg): Phase 265 P2 - seq/if_ 実装(wires/exits 分離) ## 目的 「解決済み配線(wires)」と「未解決 exit(exits)」を分離し、 Frag 合成の基本パターンを完成させる。 ## 実装内容 ### 1. Frag 構造体の変更 - `wires: Vec<EdgeStub>` フィールド追加 - 不変条件: - exits: target = None のみ(未配線、外へ出る exit) - wires: target = Some(...) のみ(配線済み、内部配線) ### 2. loop_() の wires 対応 - Break/Continue を exits から wires に移動 - P1 テスト 3個を wires 検証に更新 ### 3. seq(a, b) 実装 - a.Normal → b.entry を wires に追加(内部配線) - seq の exits[Normal] は b の Normal のみ - 新規テスト 2個追加 ### 4. if_(header, cond, t, e, join_frag) 実装 - シグネチャ変更: join: BasicBlockId → join_frag: Frag - t/e.Normal → join_frag.entry を wires に追加 - if の exits は join_frag.exits - 新規テスト 2個追加 ### 5. verify_frag_invariants() 強化 - wires/exits 分離契約の検証追加(警告のみ) - Err 化は Phase 266 で実施 ## テスト結果 - edgecfg::api: 13/13 PASS(frag 3 + compose 9 + verify 1) - 全 lib テスト: 1388/1388 PASS(退行なし) ## 核心的な設計判断 1. **wires/exits 分離**: - 問題: 解決済み配線と未解決 exit を混ぜると再配線バグ - 解決: 分離して不変条件を強化 - 効果: Phase 266 で wires を MIR terminator に落とすだけ 2. **if_ は join_frag 受け取り**: - 問題: join: BasicBlockId では「join block」か「join 以降」か曖昧 - 解決: join_frag: Frag で「join 以降」を明確化 - 効果: PHI 生成の柔軟性確保 3. **verify は警告のみ**: - P2 の役割: wires/exits 分離の証明に集中 - Phase 266 で MIR 生成時に厳格化 ## 次フェーズへの橋渡し - Phase 266: wires を MIR terminator に落とす - Phase 267: Pattern6/7/8 を Frag 化 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-21 16:47:47 +09:00
- **(✅ 完了Phase 265 P2: seq/if_ 実装wires/exits 分離)**
- **目的**: 「解決済み配線wires」と「未解決 exitexits」を分離し、Frag 合成の基本パターンを完成
- **完了内容**:
- Frag に `wires: Vec<EdgeStub>` 追加
- wires/exits 分離設計確立exits = target None, wires = target Some
- loop_() を wires 対応に更新
- seq(a, b) 実装a.Normal → wires
- if_(header, cond, t, e, join_frag) 実装t/e.Normal → wires
- verify 強化wires/exits 分離契約、警告のみ)
- 全テスト PASS13個: frag 3 + compose 9 + verify 1
- **設計判断**:
- wires/exits 分離で再配線バグ防止
- if_ は join_frag: Frag で「join 以降」を明確化
- verify は警告のみErr 化は Phase 266 の strict 版で段階導入)
- **次**: Phase 266 で MIR 命令生成 PoCemit_wires、Phase 267 で NormalizedShadow/JoinIR へ実適用
- **(✅ 完了Phase 266: wires → MIR terminator 生成(最小 PoC**
- **目的**: wires を MIR terminator に変換する最小 PoC を実装し、Phase 267 での本格適用に備える
- **完了内容**:
- emit.rs 作成emit_wires 実装 + unit test 4個
- verify_frag_invariants_strict() 追加(段階導入を壊さない)
- Jump/Return 対応Branch は Phase 267
- mod.rs 更新emit module エクスポート)
- 全テスト PASS1392 passed: 既存 1388 + 新規 4個
- **核心原則**:
- from ごとにグループ化して1本だけ許可1 block = 1 terminator 制約)
- Return は target=None を許可(意味を持たない)
- verify_frag_invariants() は変更なし警告のまま、strict 版を別名で用意)
- Phase 260 terminator 語彙ルールを厳守
- **設計判断**:
- from グループ化で terminator 上書きバグ防止
- Return は target 不要(呼び出し元に戻る)
- verify strict 版で段階導入を壊さない
- **次**: Phase 267 で JoinIR Pattern への適用
- **(✅ P0 完了Phase 267: BranchStub + emit_fragBranch の第一級化)**
- **目的**: Frag に Branch を第一級で追加し、wiresJump/Returnと同様に MIR terminator へ落とす入口を作る
- **完了内容P0**:
- `BranchStub` 追加 + `Frag.branches` 追加
- `compose::if_` が header→then/else の BranchStub を生成
- `emit_frag(function, frag)` を追加(`emit_wires` + `set_branch_with_edge_args`
- 1 block = 1 terminatorwire/branch の衝突)を Fail-Fast
- unit tests + `cargo test -p nyash-rust --lib` PASS
- **P1延期**:
- "層を跨がない実適用"は候補が抽象化層へ委譲済みのため、Phase 268 で体系的に適用する方針
- **詳細**: `docs/development/current/main/phases/phase-267/README.md`
- **(✅ 完了Phase 268: if_form.rs への Frag 適用 + entry edge-args SSOT化**
- **目的**: EdgeCFG Fragment を層を跨がずに実戦投入し、compose::if_() の edge-args を SSOT 化
- **完了内容P0**:
- emission/branch.rs に emit_conditional_edgecfg() 追加(薄いラッパー)
- if_form.rs を Frag+emit_frag 経由に変更emit_conditional + emit_jump を削除)
- emission 層経由で層が綺麗に保たれる
- **完了内容P1**:
- compose::if_() シグネチャ変更then_entry_args, else_entry_args 追加)
- emission/branch.rs から空 EdgeArgs を渡す
- EdgeCFG テスト更新compose.rs 2箇所、emit.rs 1箇所
- TODO コメント削除完了Phase 267 P2+ TODO 解消)
- **テスト結果**:
- cargo build --release: 成功
- cargo test --lib --release: 1444/1444 PASS
- quick smoke: 45/46 PASS既存状態維持
- **核心原則**:
- emission 層経由で Frag 構築を MirBuilder 層から分離
- SSOT 原則: compose::if_() は edge-args を内部生成しない
- **次**: Phase 269 で Pattern6/7/8 への Frag 適用 + fixture/smoke test
- **詳細**: `docs/development/current/main/phases/phase-268/README.md`
- **real-app loop regression の横展開VM + LLVM EXE**
- ねらい: 実コード由来ループを 1 本ずつ最小抽出して fixture/smoke で固定する(段階投入)。
2025-12-17 23:30:13 +09:00
- 現状: Phase 107find_balanced_array/object / json_cur 由来)まで固定済み。
- 次候補: JsonLoader/JsonCur から 1 本ずつfixture + integration smokeで増やす。
- **P5b “完全E2E”**escape skip の実ループを end-to-end で固定)
- 現状: Phase 94 で VM E2E まで固定済み。次は selfhost 実コード(`apps/selfhost-vm/json_loader.hako`)へ横展開して回帰を減らす。
- 入口: `docs/development/current/main/phases/phase-94/README.md`
- **制御の再帰合成docs-only → dev-only段階投入**
- ねらい: `loop/if` ネストの "構造" を SSOTControlTree/StepTreeで表せるようにする
- 注意: canonicalizer は観測/構造SSOTまでValueId/PHI配線は Normalized 側へ)
- 現状: Phase 119128if-only Normalized: reads/inputs/unknown-read/partial-assign keep/mergeまで完了
- ✅ 完了: Phase 129-Cpost-if を post_k continuation で表現)
- 入口: `docs/development/current/main/design/control-tree.md`
## 中期(ループ在庫の残り)
- **P5guard-bounded**: 大型ループを “小粒度” に割ってから取り込む(分割 or 新契約)
- **P6nested loops**: capability guard で Fail-Fast 維持しつつ、解禁時の契約を先に固定
## 中期(制御の表現力)
北極星: `docs/development/current/main/design/join-explicit-cfg-construction.md`
設計メモ: `docs/development/current/main/design/exception-cleanup-async.md`
- **catch/cleanupInvoke**
- 追加語彙を `Invoke(ok_edge, err_edge)` に絞って例外 edge を明示する(例外値は edge-args で運ぶ)。
- 実装タイミング: Phase 260edge-args terminator 収束)の P1〜P2 以降が推奨。
- **cleanup/defercleanup normalizer**
- Return/Throw/Break/Continue を cleanup に寄せる “脱出 edge 正規化” を箱化するfinally の後継としての cleanup
- 実装タイミング: catch/cleanup の次(例外 edge も含めて正規化するため)。
- **async/awaitstate machine lowering**
- CFG語彙に混ぜず、AsyncLowerBox で state machine 化してから MIR に落とす。
- 実装タイミング: finally/defer の後cancel/drop と cleanup の接続を先に固める)。
## ドキュメント運用
- 重複が出たら「設計 SSOTdesign」に集約し、Phaseログphasesは “何をやったか/検証したか” に限定する
- 調査ログinvestigationsは結論を SSOT に反映してから Historical 化する