refactor(joinir): Phase 244 - ConditionLoweringBox trait unification

Unify condition lowering logic across Pattern 2/4 with trait-based API.

New infrastructure:
- condition_lowering_box.rs: ConditionLoweringBox trait + ConditionContext (293 lines)
- ExprLowerer implements ConditionLoweringBox trait (+51 lines)

Pattern migrations:
- Pattern 2 (loop_with_break_minimal.rs): Use trait API
- Pattern 4 (loop_with_continue_minimal.rs): Use trait API

Benefits:
- Unified condition lowering interface
- Extensible for future lowering strategies
- Clean API boundary between patterns and lowering logic
- Zero code duplication

Test results: 911/911 PASS (+2 new tests)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-11 02:35:31 +09:00
parent 2dfe363365
commit d4f90976da
131 changed files with 3123 additions and 42 deletions

View File

@ -0,0 +1,5 @@
# Phase 106156 Archive (Runtime / ConsoleBox / hako_check 初期ライン)
Status: Historical
Scope: FileBox/Runtime/ConsoleBox/LLVM/hako_check などの初期〜中期フェーズPhase 106156をまとめたアーカイブ。

View File

@ -352,3 +352,4 @@ FileBox provider を通す provider_lock 経由で呼び
--- ---
**指示書作成日**: 2025-12-03案B統一版 **指示書作成日**: 2025-12-03案B統一版
Status: Historical

View File

@ -361,3 +361,4 @@ FileBox ユーザーAPI provider 経由のみ
--- ---
**Phase 107 指示書作成日**: 2025-12-03検討事項追加版 **Phase 107 指示書作成日**: 2025-12-03検討事項追加版
Status: Historical

View File

@ -360,3 +360,4 @@ CoreBoxId::File.is_required_in(&RuntimeProfile::NoFs) // → false
**Phase 108 指示書作成日**: 2025-12-03微調整版 **Phase 108 指示書作成日**: 2025-12-03微調整版
**Phase 109 追記**: 2025-12-03RuntimeProfile 統合完了) **Phase 109 追記**: 2025-12-03RuntimeProfile 統合完了)
Status: Historical

View File

@ -422,3 +422,4 @@ NoFs init 時に provider OK (optional なので無視)
--- ---
**Phase 109 指示書作成日**: 2025-12-033修正案統合版 **Phase 109 指示書作成日**: 2025-12-033修正案統合版
Status: Historical

View File

@ -591,3 +591,4 @@ FileBoxワンショット I/Oを補完するハンドルベースのファ
**Phase 110 設計書作成日**: 2025-12-03修正版 5点統合 **Phase 110 設計書作成日**: 2025-12-03修正版 5点統合
**Phase 111 完成日**: 2025-12-03修正案統合版、4 テスト全 PASS **Phase 111 完成日**: 2025-12-03修正案統合版、4 テスト全 PASS
Status: Historical

View File

@ -630,3 +630,4 @@ Phase 111 の完了行を追加:
--- ---
**Phase 111 指示書完成日**: 2025-12-03修正案統合版 **Phase 111 指示書完成日**: 2025-12-03修正案統合版
Status: Historical

View File

@ -424,3 +424,4 @@ impl Ring0Registry {
--- ---
**Phase 112 指示書完成日**: 2025-12-03修正案統合版 **Phase 112 指示書完成日**: 2025-12-03修正案統合版
Status: Historical

View File

@ -441,3 +441,4 @@ Phase 113 では何もしない
**Phase 113 実装予定完了日**: 2025-12-04 **Phase 113 実装予定完了日**: 2025-12-04
**実装者**: Claude Code + ChatGPT 協働 **実装者**: Claude Code + ChatGPT 協働
**レビュー**: Phase 114 移行時に Result 型統合を検討 **レビュー**: Phase 114 移行時に Result 型統合を検討
Status: Historical

View File

@ -244,3 +244,4 @@ fn is_dir(&self) -> Result<bool, String> {
- [core_boxes_design.md](./core_boxes_design.md) - FileHandleBox 設計 - [core_boxes_design.md](./core_boxes_design.md) - FileHandleBox 設計
- [ring0-inventory.md](./ring0-inventory.md) - Ring0 機能一覧 - [ring0-inventory.md](./ring0-inventory.md) - Ring0 機能一覧
- [Phase 113 実装](./phase113_filehandlebox_api.md) - Nyash API 公開 - [Phase 113 実装](./phase113_filehandlebox_api.md) - Nyash API 公開
Status: Historical

View File

@ -170,3 +170,4 @@ Phase 122+ で上記課題を段階的に解決し、selfhost Stage-3 経路の
**作成日**: 2025-12-04 **作成日**: 2025-12-04
**Phase**: 120selfhost Stage-3 代表パスの安定化) **Phase**: 120selfhost Stage-3 代表パスの安定化)
**ベースライン確立**: Phase 106-115 完了時点 **ベースライン確立**: Phase 106-115 完了時点
Status: Historical

View File

@ -350,3 +350,4 @@ Flow:
--- ---
**Phase 120 指示書完成日**: 2025-12-04Phase 106-115 完了直後) **Phase 120 指示書完成日**: 2025-12-04Phase 106-115 完了直後)
Status: Historical

View File

@ -283,3 +283,4 @@ hako_check 経路の現状は:
### 次のステップ ### 次のステップ
Phase 122+ で上記課題を段階的に解決する。特に **If 文の JoinIR 統合**が最優先課題。 Phase 122+ で上記課題を段階的に解決する。特に **If 文の JoinIR 統合**が最優先課題。
Status: Historical

View File

@ -765,3 +765,4 @@ Diagnostic Output
### 次章予告 ### 次章予告
次は selfhost Stage-4高度なパターン対応への準備を進める。 次は selfhost Stage-4高度なパターン対応への準備を進める。
Status: Historical

View File

@ -546,3 +546,4 @@ Phase 121 で設計を確定し、Phase 122-124 で段階的に実装する。
### 次のステップ ### 次のステップ
Phase 122 の実装を開始する。特に **If 文の JoinIR 統合**が最優先課題。 Phase 122 の実装を開始する。特に **If 文の JoinIR 統合**が最優先課題。
Status: Historical

View File

@ -367,3 +367,4 @@ hako_check 経路の旧 MIR/PHI 使用状況:
**Phase 122+ で段階的に JoinIR 統合を完了する。** **Phase 122+ で段階的に JoinIR 統合を完了する。**
**最優先課題**: **If 文の JoinIR 統合**`src/mir/builder/if_form.rs` **最優先課題**: **If 文の JoinIR 統合**`src/mir/builder/if_form.rs`
Status: Historical

View File

@ -103,3 +103,4 @@ Phase 122.5 修正完了後、以下の Phase 123 (ConsoleBox WASM/非WASM コ
- Phase 122 の実装完了後に発見された品質改善の第1段 - Phase 122 の実装完了後に発見された品質改善の第1段
- 本来は Phase 122 に含めるべきだったが、実装後の品質レビューで発見 - 本来は Phase 122 に含めるべきだったが、実装後の品質レビューで発見
- Phase 122 の機能は既に動作済み(この修正は完全性の向上) - Phase 122 の機能は既に動作済み(この修正は完全性の向上)
Status: Historical

View File

@ -428,3 +428,4 @@ Flow:
--- ---
**Phase 122 指示書完成日**: 2025-12-04Phase 120-121 完了直後) **Phase 122 指示書完成日**: 2025-12-04Phase 120-121 完了直後)
Status: Historical

View File

@ -491,3 +491,4 @@ Phase 124: VM Method Dispatch 統一化4時間
- Phase 124: VM Method Dispatch 統一化(予定) - Phase 124: VM Method Dispatch 統一化(予定)
- Phase 125: 削除deprecated builtin ConsoleBox予定 - Phase 125: 削除deprecated builtin ConsoleBox予定
- Phase 126: ドキュメント統合(予定) - Phase 126: ドキュメント統合(予定)
Status: Historical

View File

@ -358,3 +358,4 @@ NYASH_HAKO_CHECK_JOINIR=1 ./target/release/nyash tools/hako_check/cli.hako
- 🎯 Phase 123 proper: hako_check JoinIR 実装 ← **現在のフェーズ** - 🎯 Phase 123 proper: hako_check JoinIR 実装 ← **現在のフェーズ**
- 📋 Phase 124: JoinIR デフォルト化 - 📋 Phase 124: JoinIR デフォルト化
- 📋 Phase 125: レガシー経路削除 - 📋 Phase 125: レガシー経路削除
Status: Historical

View File

@ -377,3 +377,4 @@ JoinIR/selfhost 第2章が完了し、hako_check + selfhost が統一パイプ
- ✅ Phase 123 proper: hako_check JoinIR 基盤構築 - ✅ Phase 123 proper: hako_check JoinIR 基盤構築
- 🎯 Phase 124: hako_check レガシー削除 & JoinIR 専用化 ← **現在のフェーズ** - 🎯 Phase 124: hako_check レガシー削除 & JoinIR 専用化 ← **現在のフェーズ**
- 📋 次: selfhost Stage-4 or 次大型フェーズ - 📋 次: selfhost Stage-4 or 次大型フェーズ
Status: Historical

View File

@ -425,3 +425,4 @@ Phase 125: 削除deprecated builtin ConsoleBox3時間
- Phase 124: VM Method Dispatch 統一化 ← **現在のフェーズ** - Phase 124: VM Method Dispatch 統一化 ← **現在のフェーズ**
- Phase 125: 削除deprecated builtin ConsoleBox予定 - Phase 125: 削除deprecated builtin ConsoleBox予定
- Phase 126: ドキュメント統合(予定) - Phase 126: ドキュメント統合(予定)
Status: Historical

View File

@ -426,3 +426,4 @@ src/box_factory/builtin_impls/console_box.rs ← これは「ファクトリー
- **src/box_factory/builtin_impls/**: ビルトイン factory今回削除 - **src/box_factory/builtin_impls/**: ビルトイン factory今回削除
Phase 125 では **factory** のみ削除し、Rust 実装は残す。 Phase 125 では **factory** のみ削除し、Rust 実装は残す。
Status: Historical

View File

@ -397,3 +397,4 @@ Phase 122-126 の全改善がコンプリート!
- Phase 124: VM Method Dispatch 統一化 ✅ 完了 - Phase 124: VM Method Dispatch 統一化 ✅ 完了
- Phase 125: 削除deprecated builtin ConsoleBox ✅ 完了 - Phase 125: 削除deprecated builtin ConsoleBox ✅ 完了
- Phase 126: ドキュメント統合 ← **現在のフェーズ** - Phase 126: ドキュメント統合 ← **現在のフェーズ**
Status: Historical

View File

@ -487,3 +487,4 @@ ConsoleBoxの登録・実装はRust VM側の問題。LLVM統合の前提条件
1. **最優先**: PHI命令順序バグ修正`finalize_phis()`リファクタリング) 1. **最優先**: PHI命令順序バグ修正`finalize_phis()`リファクタリング)
2. **優先**: ConsoleBox登録問題解決 2. **優先**: ConsoleBox登録問題解決
3. **通常**: 残りテストケースのLLVM対応 3. **通常**: 残りテストケースのLLVM対応
Status: Historical

View File

@ -282,3 +282,4 @@ Phase 130 で検出された問題:
- ✅ Phase 130: JoinIR → LLVM ベースライン確立(完了) - ✅ Phase 130: JoinIR → LLVM ベースライン確立(完了)
- 🎯 Phase 131: JoinIR → LLVM 個別修正ライン(← **現在のフェーズ** - 🎯 Phase 131: JoinIR → LLVM 個別修正ライン(← **現在のフェーズ**
- 📋 Phase 132: LLVM 未対応命令の個別対応(必要に応じて) - 📋 Phase 132: LLVM 未対応命令の個別対応(必要に応じて)
Status: Historical

View File

@ -427,3 +427,4 @@ NYASH_PHI_ORDERING_DEBUG=1 NYASH_LLVM_USE_HARNESS=1 NYASH_LLVM_OBJ_OUT=/tmp/test
**次のステップ**: **次のステップ**:
- Phase 133: ConsoleBox LLVM 統合で 7/7 テスト完全成功を目指す - Phase 133: ConsoleBox LLVM 統合で 7/7 テスト完全成功を目指す
Status: Historical

View File

@ -510,3 +510,4 @@ Phase 130-133 で達成した内容:
- ✅ JoinIR → LLVM 経路完全確立 - ✅ JoinIR → LLVM 経路完全確立
--- ---
Status: Historical

View File

@ -578,3 +578,4 @@ test mir::slot_registry::tests::test_phase_15_5_unified_resolution ... ok
- ✅ 全 mir_call テスト PASS - ✅ 全 mir_call テスト PASS
**Phase 134-B StringBox bridge 分離へ!** 🚀 **Phase 134-B StringBox bridge 分離へ!** 🚀
Status: Historical

View File

@ -497,3 +497,4 @@ class StringBoxBridge:
- boxcall.py:143-193 の Array/Map メソッド処理を分離 - boxcall.py:143-193 の Array/Map メソッド処理を分離
- get, push, set, has メソッドを collectionbox.py に集約 - get, push, set, has メソッドを collectionbox.py に集約
- Phase 133/134-B パターンを継承 - Phase 133/134-B パターンを継承
Status: Historical

View File

@ -0,0 +1,5 @@
# Phase 150167 Archive (Selfhost Stage3 初期/ハコチェック系)
Status: Historical
Scope: selfhost Stage3 depth1 基盤、hako_check/CFG/Analyzer 初期フェーズ150167をまとめたアーカイブ。

View File

@ -270,4 +270,5 @@ echo "Summary: $PASS passed, $FAIL failed"
- 🎯 Phase 150: Selfhost Stage-3 Depth-1 ベースライン強化(← **現在のフェーズ** - 🎯 Phase 150: Selfhost Stage-3 Depth-1 ベースライン強化(← **現在のフェーズ**
- 📋 Phase 151+: Selfhost 特有バグ修正(予定) - 📋 Phase 151+: Selfhost 特有バグ修正(予定)
- 📋 Phase 160+: .hako JoinIR/MIR 移植章(予定) - 📋 Phase 160+: .hako JoinIR/MIR 移植章(予定)
Status: Historical

View File

@ -404,3 +404,4 @@ Phase 151+ で ConsoleBox 対応を完了すれば、selfhost Stage-3 経路の
**作成日**: 2025-12-04 **作成日**: 2025-12-04
**Phase**: 150selfhost Stage-3 Depth-1 ベースライン強化) **Phase**: 150selfhost Stage-3 Depth-1 ベースライン強化)
**ベースライン確立**: 5本の代表ケースで depth-1 安定動作確認 **ベースライン確立**: 5本の代表ケースで depth-1 安定動作確認
Status: Historical

View File

@ -267,4 +267,5 @@ NYASH_FEATURES=stage3 NYASH_USE_NY_COMPILER=1 NYASH_JOINIR_STRICT=1 \
- Task 2修正実装: 30分 - Task 2修正実装: 30分
- Task 3テスト確認: 15分 - Task 3テスト確認: 15分
- Task 4ドキュメント: 15分 - Task 4ドキュメント: 15分
Status: Historical

View File

@ -573,4 +573,5 @@ Phase 152-A は **Phase 133/134-A/134-B で確立した箱化モジュール化
commit c70e76ff commit c70e76ff
feat(parser): Phase 152-A - Grouped assignment expression (箱化モジュール化) feat(parser): Phase 152-A - Grouped assignment expression (箱化モジュール化)
``` ```
Status: Historical

View File

@ -439,4 +439,5 @@ RC: 0
- ✅ Phase 152-B: Static Method 宣言整理(箱化モジュール化完了) - ✅ Phase 152-B: Static Method 宣言整理(箱化モジュール化完了)
- 📋 Phase 160+: .hako JoinIR/MIR 移植章(予定) - 📋 Phase 160+: .hako JoinIR/MIR 移植章(予定)
- 🌟 Phase 200+: Python → Hakorune トランスパイラ構想(夢) - 🌟 Phase 200+: Python → Hakorune トランスパイラ構想(夢)
Status: Historical

View File

@ -242,3 +242,4 @@ Phase 153 完了後:
**作成日**: 2025-12-04 **作成日**: 2025-12-04
**Phase**: 153hako_check / dead code 検出モードの復活) **Phase**: 153hako_check / dead code 検出モードの復活)
Status: Historical

View File

@ -541,3 +541,4 @@ static box Utils {
**Status**: Inventory Complete ✅ **Status**: Inventory Complete ✅
**Next**: Task 2 (JoinIR Pipeline Verification) **Next**: Task 2 (JoinIR Pipeline Verification)
Status: Historical

View File

@ -386,3 +386,4 @@ Phase 154 **successfully delivered the infrastructure** for block-level dead cod
**Date:** 2025-12-04 **Date:** 2025-12-04
**Phase:** 154 (Complete) **Phase:** 154 (Complete)
**Next Phase:** 155 (CFG Data Bridge) **Next Phase:** 155 (CFG Data Bridge)
Status: Historical

View File

@ -366,3 +366,4 @@ The remaining work is a **straightforward data bridge** to connect the Rust-side
**Date:** 2025-12-04 **Date:** 2025-12-04
**Phase:** 154 (MIR CFG Integration & Dead Block Detection) **Phase:** 154 (MIR CFG Integration & Dead Block Detection)
**Status:** Core infrastructure complete, CFG bridge pending (Phase 155) **Status:** Core infrastructure complete, CFG bridge pending (Phase 155)
Status: Historical

View File

@ -386,3 +386,4 @@ Phase 154 完了後:
**作成日**: 2025-12-04 **作成日**: 2025-12-04
**Phase**: 154MIR CFG 統合 & ブロックレベル unreachable 検出) **Phase**: 154MIR CFG 統合 & ブロックレベル unreachable 検出)
Status: Historical

View File

@ -267,3 +267,4 @@ static box DeadBlockAnalyzerBox {
**Created:** 2025-12-04 **Created:** 2025-12-04
**Phase:** 154 (MIR CFG Integration & Dead Block Detection) **Phase:** 154 (MIR CFG Integration & Dead Block Detection)
**Status:** Task 1 Complete **Status:** Task 1 Complete
Status: Historical

View File

@ -481,3 +481,4 @@ Phase 154 + 155 により、HC020 の基盤は完成。実際の検出機能は
**実装日**: 2025-12-04 **実装日**: 2025-12-04
**実装者**: Claude (AI Assistant) **実装者**: Claude (AI Assistant)
**コミット**: feat(hako_check): Phase 155 MIR CFG data bridge (MVP) **コミット**: feat(hako_check): Phase 155 MIR CFG data bridge (MVP)
Status: Historical

View File

@ -448,3 +448,4 @@ Phase 156 完了後:
- HC021定数畳み込み検出でも同様のパターンを使用可能 - HC021定数畳み込み検出でも同様のパターンを使用可能
- MIR解析ルール追加時のテンプレートとして活用 - MIR解析ルール追加時のテンプレートとして活用
- JSON schema validation を .hako で実装も検討 - JSON schema validation を .hako で実装も検討
Status: Historical

View File

@ -495,3 +495,4 @@ Once this design is approved:
--- ---
**Status**: 🎯 Ready for Task 3 approval and representative function selection **Status**: 🎯 Ready for Task 3 approval and representative function selection
Status: Historical

View File

@ -1007,3 +1007,4 @@ JoinIRの用途:
--- ---
**次のステップ**: Phase 161-2 (Task 2) - .hako 側 AnalyzerBox の基本実装 **次のステップ**: Phase 161-2 (Task 2) - .hako 側 AnalyzerBox の基本実装
Status: Historical

View File

@ -520,3 +520,4 @@ loop(i2 < m2) { merged = merged + bundle_mod_srcs.get(i2) + "\n" i2 = i2 + 1 }
- 2025-12-06: Phase 161-impl-3 Task 161-3-1 完了 - ループインベントリ作成 - 2025-12-06: Phase 161-impl-3 Task 161-3-1 完了 - ループインベントリ作成
- 2025-12-06: Phase 161-impl-3 Task 161-3-3 完了 - BundleResolver 棚卸し追加 - 2025-12-06: Phase 161-impl-3 Task 161-3-3 完了 - BundleResolver 棚卸し追加
Status: Historical

View File

@ -352,3 +352,4 @@ All analysis boxes are architected, all algorithms documented, all test cases se
--- ---
**Status**: 🚀 Ready for Phase 161 Task 4 - Basic MirAnalyzerBox Implementation **Status**: 🚀 Ready for Phase 161 Task 4 - Basic MirAnalyzerBox Implementation
Status: Historical

View File

@ -574,3 +574,4 @@ Once this selection is approved:
--- ---
**Status**: 🎯 Ready for test file creation (Task 4 preparation) **Status**: 🎯 Ready for test file creation (Task 4 preparation)
Status: Historical

View File

@ -179,4 +179,5 @@ ExternCall: inst_meta(CallLikeInst) + cse.rs
- [ ] セキュリティ問題 - [ ] セキュリティ問題
**推奨対応**: ドキュメント化 + 段階的リファクタ **推奨対応**: ドキュメント化 + 段階的リファクタ
Status: Historical

View File

@ -390,4 +390,5 @@ CallLikeInst::Call { func, callee, args, .. } => {
| CSE の callee 無視 | 最適化誤り可能 | 2 | fix CSE | | CSE の callee 無視 | 最適化誤り可能 | 2 | fix CSE |
| CallLikeInst::Call 不完全 | 潜在バグ | 3 | callee 追加 | | CallLikeInst::Call 不完全 | 潜在バグ | 3 | callee 追加 |
| DCE 処理経路の非対称 | テスト困難 | 3 | 統合テスト追加 | | DCE 処理経路の非対称 | テスト困難 | 3 | 統合テスト追加 |
Status: Historical

View File

@ -628,3 +628,4 @@ loop(i < n) {
- Phase 166: Loop pattern detection - Phase 166: Loop pattern detection
- tools/hako_shared/json_parser.hako - tools/hako_shared/json_parser.hako
- local_tests/test_trim_main_pattern.hako - local_tests/test_trim_main_pattern.hako
Status: Historical

View File

@ -1073,4 +1073,5 @@ let cond_val = bool_lowerer.lower_condition(&ctx.condition)?;
--- ---
**Conclusion**: Phase 168 successfully implemented BoolExprLowerer with full support for `_trim` and `_skip_whitespace` requirements. The module is production-ready and demonstrates the "No Pattern5" design philosophy - enhance expression handling, don't add loop patterns! **Conclusion**: Phase 168 successfully implemented BoolExprLowerer with full support for `_trim` and `_skip_whitespace` requirements. The module is production-ready and demonstrates the "No Pattern5" design philosophy - enhance expression handling, don't add loop patterns!
Status: Historical

View File

@ -0,0 +1,5 @@
# Phase 69 Archive (Trio/LoopScope 移行メモ)
Status: Historical
Scope: Trio 依存の棚卸し・削除プランなど Phase 69 系の資料。

View File

@ -133,3 +133,4 @@ Phase 69-2 で Easy 箇所から順次置き換えを開始:
5. ...全8ファイル 5. ...全8ファイル
全置き換え完了後、Phase 69-3 で Trio 3箱を完全削除。 全置き換え完了後、Phase 69-3 で Trio 3箱を完全削除。
Status: Historical

View File

@ -630,3 +630,4 @@ Phase 70 完了により、LoopScopeShape が Loop PHI 生成の完全な SSOT
**Phase 70 完了日**: 2025-11-30 **Phase 70 完了日**: 2025-11-30
**実装時間**: 約1時間Phase 69-4 見積もり3時間から大幅短縮、ユーザー協働 **実装時間**: 約1時間Phase 69-4 見積もり3時間から大幅短縮、ユーザー協働
**退行**: なしloopform 14/14 PASS、既知エラーのみ **退行**: なしloopform 14/14 PASS、既知エラーのみ
Status: Historical

View File

@ -621,3 +621,4 @@ loop_form_intake.rs
- [ ] Step 6: コミット(退行なし確認済み) - [ ] Step 6: コミット(退行なし確認済み)
**実装準備完了Phase 70 で Trio 依存ゼロを達成しよう!** 🚀 **実装準備完了Phase 70 で Trio 依存ゼロを達成しよう!** 🚀
Status: Historical

View File

@ -0,0 +1,5 @@
# Phase 71 Archive (SSA/selfhost 再ブートストラップ観測)
Status: Historical
Scope: SSA trim 再起動時の観測・修正メモPhase 71 系)。

View File

@ -182,3 +182,4 @@ NYASH_SELFHOST_KEEP_RAW=1 \
**備考**: このドキュメントは Phase 71初回実行の観測結果を記録したものです。 **備考**: このドキュメントは Phase 71初回実行の観測結果を記録したものです。
SSA undef修正作業は Phase 71-SSA-debug側で継続します。 SSA undef修正作業は Phase 71-SSA-debug側で継続します。
Status: Historical

View File

@ -245,3 +245,4 @@ grep -c 'ssa-undef-debug' logs/selfhost/stageb_20251202_111409_2674670.log
**Phase 71-SSA SSA undef 削減完了判定**: ✅ **100%達成!** **Phase 71-SSA SSA undef 削減完了判定**: ✅ **100%達成!**
**次のマイルストーン**: dev verify警告解消 + Program JSON emit復活 **次のマイルストーン**: dev verify警告解消 + Program JSON emit復活
Status: Historical

View File

@ -0,0 +1,5 @@
# Phase 72-73 Archive (ENV 使用状況棚卸し)
Status: Historical
Scope: ENV/JoinIR 整理に関する棚卸しメモPhase 72-73

View File

@ -641,3 +641,4 @@ rg 'std::env::var\("NYASH_PARSER_STAGE3"\)' --type rust
--- ---
**次のアクション**: Phase 72-A の実装計画策定にゃ! **次のアクション**: Phase 72-A の実装計画策定にゃ!
Status: Historical

View File

@ -59,3 +59,4 @@ Phase 11: LLVM AOT研究将来
- [00_MASTER_ROADMAP.md](../00_MASTER_ROADMAP.md) - 全体計画 - [00_MASTER_ROADMAP.md](../00_MASTER_ROADMAP.md) - 全体計画
- [Phase 9.79b](../phase-9/) - 統一Box設計前提 - [Phase 9.79b](../phase-9/) - 統一Box設計前提
- [MIR仕様](../../../../reference/mir/) - 中間表現 - [MIR仕様](../../../../reference/mir/) - 中間表現
Status: Historical

View File

@ -92,3 +92,4 @@ NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_HOSTCALL=1 NYASH_JIT_EVENTS=1 \
- HostCall: 実例では `NYASH_JIT_HOSTCALL=1` を明示HH直実行/ANYヘルパ - HostCall: 実例では `NYASH_JIT_HOSTCALL=1` を明示HH直実行/ANYヘルパ
- ANYヘルパ: `nyash.any.length_h / is_empty_h` でROは十分カバー追加不要 - ANYヘルパ: `nyash.any.length_h / is_empty_h` でROは十分カバー追加不要
``` ```
Status: Historical

View File

@ -55,3 +55,4 @@
- Host API: Phase 10.2 仕様 - Host API: Phase 10.2 仕様
最終更新: 2025-08-14 最終更新: 2025-08-14
Status: Historical

View File

@ -44,3 +44,4 @@ rg -n "Arc<|Mutex<|RwLock<|Send|Sync" src/boxes src/runtime
## 次の一手(提案) ## 次の一手(提案)
- マーカーTraits例: `ThreadSafeBox`)の導入は保留(破壊的)。現時点は監査+ドキュメントで運用。 - マーカーTraits例: `ThreadSafeBox`)の導入は保留(破壊的)。現時点は監査+ドキュメントで運用。
- 並列スケジューラM:Nの実装は `feature` フラグで段階導入。 - 並列スケジューラM:Nの実装は `feature` フラグで段階導入。
Status: Historical

View File

@ -42,4 +42,5 @@ Risks / Mitigation
Acceptance Acceptance
- Examples with pure f64 pipelines run under JIT with matching results vs VM - Examples with pure f64 pipelines run under JIT with matching results vs VM
- No silent lossy conversions; conversions visible in MIR/Lower logs - No silent lossy conversions; conversions visible in MIR/Lower logs
Status: Historical

View File

@ -170,3 +170,4 @@ impl MirBuilder {
--- ---
*Everything is Box, Everything is Debug - 統一されたデバッグ体験へ* *Everything is Box, Everything is Debug - 統一されたデバッグ体験へ*
Status: Historical

View File

@ -83,3 +83,4 @@ SuperMethodCall → FromMethodCall
--- ---
*「from」こそがNyashの明示的デリゲーションの象徴* *「from」こそがNyashの明示的デリゲーションの象徴*
Status: Historical

View File

@ -153,3 +153,4 @@ NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_HOSTCALL=1 NYASH_JIT_EVENTS=1 \
--- ---
最短ルート: 箱Policy/Events/Registry/Boundaryを先に置き、読み取り系でJITを安全に通す→観測を増やす→署名とポリシーの一本化で切替点を固定→必要最小限のネイティブ型f64/b1を段階導入。 最短ルート: 箱Policy/Events/Registry/Boundaryを先に置き、読み取り系でJITを安全に通す→観測を増やす→署名とポリシーの一本化で切替点を固定→必要最小限のネイティブ型f64/b1を段階導入。
Status: Historical

View File

@ -218,3 +218,4 @@ static box AppName {
4. **エコシステム拡充**: Nyashアプリケーションの具体例提供 4. **エコシステム拡充**: Nyashアプリケーションの具体例提供
**この移植が成功すれば、Nyashは「実用的なプログラミング言語」として確立されます** 🎉 **この移植が成功すれば、Nyashは「実用的なプログラミング言語」として確立されます** 🎉
Status: Historical

View File

@ -70,3 +70,4 @@ AstNode::FunctionDeclaration { name, params, body, .. } => {
- JIT配列操作テスト - JIT配列操作テスト
- MIRビルダー拡張 - MIRビルダー拡張
- 言語仕様の完全性 - 言語仕様の完全性
Status: Historical

View File

@ -1,3 +1,5 @@
Status: Historical
# Phase 22: Nyash LLVM Compiler - コンパイラもBoxの世界へ # Phase 22: Nyash LLVM Compiler - コンパイラもBoxの世界へ
## 📋 概要 ## 📋 概要

View File

@ -108,3 +108,4 @@ compiler.compile("phase22-compiler.hako", "nyash-compiler.exe")
--- ---
> 「難しいけど、夢があるにゃ!」 > 「難しいけど、夢があるにゃ!」
Status: Historical

View File

@ -120,3 +120,4 @@ add_function/append_block/position
4. **80k→20k圧縮**: 大幅な行数削減への直接貢献 4. **80k→20k圧縮**: 大幅な行数削減への直接貢献
この設計により、Nyashセルフホスティングの革命的な軽量化と高速化が実現できる見込みです。 この設計により、Nyashセルフホスティングの革命的な軽量化と高速化が実現できる見込みです。
Status: Historical

View File

@ -68,3 +68,4 @@ Nyashセルフホスティングの革新的アイデアについて相談です
### しかし、ユーザーの洞察は正しい ### しかし、ユーザーの洞察は正しい
「MIR解釈して出力するだけなのに、メモリーリークの心配なんてあるんだろうか 「MIR解釈して出力するだけなのに、メモリーリークの心配なんてあるんだろうか
→ 短命なバッチ処理にRustの複雑さは確かに過剰 → 短命なバッチ処理にRustの複雑さは確かに過剰
Status: Historical

View File

@ -136,3 +136,4 @@ box Optimizer { }
> 「Rustの安全性は素晴らしい。でも、3秒で終わるプログラムに5分のビルドは過剰だにゃ > 「Rustの安全性は素晴らしい。でも、3秒で終わるプログラムに5分のビルドは過剰だにゃ
この単純な真実が、新しい時代への扉を開く鍵となる。 この単純な真実が、新しい時代への扉を開く鍵となる。
Status: Historical

View File

@ -0,0 +1,400 @@
# Phase 243-EX: JoinIR Refactoring Investigation - Complete
**Investigation Date**: 2025-12-11
**Status**: ✅ Complete - Ready for Phase 244 Implementation
**Test Status**: ✅ 909 tests PASS (maintained throughout investigation)
---
## Document Index
This phase produced 3 comprehensive documents analyzing JoinIR lowering refactoring opportunities:
### 📋 1. Quick Summary (Start Here!)
**File**: [phase243-ex-summary.md](phase243-ex-summary.md)
**Contents**:
- TL;DR (1 page)
- Quick stats (74 files, 23K lines)
- Top 3 opportunities with priorities
- Recommended roadmap (Phases 244-248)
- Success metrics
**Best For**: Decision-makers, quick reference
---
### 📊 2. Full Analysis (Detailed Report)
**File**: [phase243-ex-refactoring-opportunities.md](phase243-ex-refactoring-opportunities.md)
**Contents** (12K words):
1. Module structure visualization (74 files analyzed)
2. Common code & duplication analysis
3. Boxification candidates (5 major opportunities)
4. Module reorganization proposal (52 → 7 directories)
5. Dependency graph analysis
6. Implementation sketches (top 3 priorities)
7. Risk assessment
8. Priority scorecard
9. Recommended roadmap (Phases 244-248)
10. Open questions & future work
**Best For**: Implementation planning, detailed design
---
### 🔗 3. Dependency Analysis (Visual Graphs)
**File**: [phase243-ex-dependency-graph.md](phase243-ex-dependency-graph.md)
**Contents** (8K words):
1. High-level architecture diagram
2. Core module dependencies (Condition, Carrier, Expression)
3. Pattern implementation dependencies (Pattern 1-4)
4. Shared infrastructure dependencies
5. Cross-cutting concerns (Pattern detection, Method call lowering)
6. Dependency metrics (depth, breadth, circular check)
7. Proposed boxification dependencies
8. Impact analysis by phase
**Best For**: Understanding module relationships, impact analysis
---
## Investigation Findings
### Scale
- **74 files** in JoinIR lowering
- **23,183 total lines**
- **52 files in root** (too flat!)
- **15 large files** (>500 lines, 41% of code)
### Key Issues Identified
1. **Condition Logic Fragmentation**: 19 files touch condition lowering (1,639 lines)
2. **Carrier Logic Spread**: 7 files manage carriers (2,359 lines)
3. **Flat Module Structure**: 52 root files → hard to navigate
4. **Pattern Detection Split**: 4 files handle pattern detection
### Opportunities Found (5 Major)
| Candidate | Priority | Impact | Effort | Phase |
|-----------|----------|--------|--------|-------|
| **ConditionLoweringBox** | ⭐⭐⭐ | High (19 files) | Medium | 244 |
| **CarrierManagerBox** | ⭐⭐ | Medium (7 files) | Low | 245 |
| **Module Reorganization** | ⭐⭐ | Medium (all files) | Large | 246 |
| **PatternDetectorBox** | ⭐⭐ | Medium (4 files) | Medium | 247 |
| **Legacy Cleanup** | ⭐ | Low | Low | 248 |
---
## Recommended Implementation Sequence
### Phase 244: ConditionLoweringBox (⭐⭐⭐ Highest Priority)
**Goal**: Unify 19 files touching condition logic into single API
**Tasks**:
1. Create `core/condition_lowering/` directory
2. Define `ConditionLoweringBox` trait + dispatcher
3. Implement SimpleConditionLowerer + ComplexConditionLowerer
4. Migrate 19 callers to new API
5. Add backward compatibility shims
6. Run all 909 tests (expect 100% pass)
**Estimated Effort**: 1-2 days
**Risk**: Medium (19 files affected)
**Value**: High (single API, eliminates duplication)
**Files to Consolidate** (1,639 lines total):
- `condition_lowerer.rs` (537 lines)
- `condition_to_joinir.rs` (154 lines)
- `condition_env.rs` (237 lines)
- `condition_pattern.rs` (527 lines)
- `condition_var_extractor.rs` (184 lines)
---
### Phase 245: CarrierManagerBox (⭐⭐)
**Goal**: Extend Phase 228 infrastructure with unified lifecycle management
**Tasks**:
1. Create `CarrierManagerBox` struct (wraps CarrierInfo)
2. Move `init_carriers()` from 3 pattern implementations
3. Move `generate_exit_bindings()` from inline_boundary_builder
4. Add `carriers_for_phi()` convenience method
5. Update Pattern 2-4 to use manager
**Estimated Effort**: 0.5-1 day
**Risk**: Low (extends existing API)
**Value**: Medium (consolidates 3 modules)
---
### Phase 246: Module Reorganization (⭐⭐)
**Goal**: Reorganize 52 root files into 7 hierarchical directories
**Structure Change**:
```
Before: 52 files in root (flat)
After: 7 directories (hierarchical)
├── core/ (condition, carrier, exit)
├── infrastructure/ (expr, scope, boundary)
├── patterns/ (detection, loop, if)
├── specialized/ (function-specific)
└── generic_case_a/ (generic)
```
**Estimated Effort**: 1-2 days
**Risk**: Low (pure reorganization)
**Value**: Medium (86% reduction in root files)
---
### Phase 247: PatternDetectorBox (⭐⭐)
**Goal**: Consolidate pattern detection into single API
**Tasks**:
1. Create `patterns/detection/` directory
2. Define `PatternDetectorBox` trait
3. Move if/loop/update detection logic
4. Create unified dispatcher
5. Update routers (loop_pattern_router, if_lowering_router)
**Estimated Effort**: 1 day
**Risk**: Medium (3 modules affected)
**Value**: Medium (unified API)
---
### Phase 248: Legacy Cleanup (⭐)
**Goal**: Remove backward compatibility shims and unused code
**Tasks**:
1. Remove bool_expr_lowerer.rs (446 lines, unused)
2. Remove backward compat shims from Phase 244-247
3. Address or track 9 TODO items
4. Update documentation
**Estimated Effort**: 0.5 day
**Risk**: Low
**Value**: High (clean codebase)
---
## Success Criteria
### Overall Goals
- ✅ All 909 tests passing throughout (no regressions)
- ✅ Improved code organization (52 → 7 root files)
- ✅ Unified APIs (3 new boxes: Condition, Carrier, Pattern)
- ✅ Reduced duplication (consolidate 1,639 lines)
- ✅ Better maintainability (single responsibility per module)
### Phase-by-Phase Metrics
| Phase | Files Created | Files Modified | Tests Expected | Risk Level |
|-------|--------------|----------------|----------------|------------|
| 244 | 5 | 19 | 909 PASS | Medium |
| 245 | 1 | 7 | 909 PASS | Low |
| 246 | 7 dirs | 74 | 909 PASS | Low |
| 247 | 4 | 10 | 909 PASS | Medium |
| 248 | 0 | 20 | 909 PASS | Low |
---
## Infrastructure Ready (Built During Phase 226-242)
The following infrastructure is already in place and ready to build on:
### ✅ Phase 227: CarrierRole
- `enum CarrierRole { LoopState, ConditionOnly }`
- Distinguishes carriers that need exit PHI vs condition-only
### ✅ Phase 228: CarrierInit
- `enum CarrierInit { FromHost, BoolConst(bool) }`
- Initialization policy for header PHI
### ✅ Phase 231: ExprLowerer + ScopeManager
- `trait ScopeManager { lookup(&str) -> Option<ValueId> }`
- `struct ExprLowerer<S: ScopeManager>`
- Unified expression lowering with scope management
### ✅ Phase 33-10: ExitLineReconnector
- ExitLineReconnector, ExitMetaCollector, ExitLineOrchestrator
- Already boxified! (no work needed)
### ✅ Phase 240-EX: ExprLowerer Integration
- ExprLowerer successfully integrated into Pattern 3 if-sum mode
- Pilot implementation validated
### ✅ Phase 242-EX-A: Complex Condition Support
- BinaryOp in LHS (e.g., `i % 2 == 1`)
- Removed hardcoded legacy code
- 909 tests PASS
---
## Risk Mitigation Strategy
### 1. Test-Driven Approach
- Run all 909 tests after each step
- No logic changes in initial refactoring (pure reorganization)
- Fail-Fast if tests break
### 2. Backward Compatibility
- Add re-export shims in old file locations
- Gradual migration (update callers one by one)
- Keep old API working during migration
### 3. Incremental Rollout
- One phase at a time (244 → 245 → 246 → 247 → 248)
- Each phase is independently valuable
- Can pause/adjust between phases
### 4. Clear Rollback Plan
- All changes are additive initially (new files alongside old)
- Git commits per phase (easy to revert)
- Backward compat shims stay until Phase 248
---
## Dependency Health Check
### ✅ No Circular Dependencies
All dependencies flow in one direction:
```
Pattern Implementations
Condition/Carrier/Expression Lowering
Infrastructure (ValueSpace, Boundary, Env)
Core Structures (ValueId, JoinInst)
```
### ✅ Clean Dependency Flow
Longest chain (6 levels):
```
Pattern 3 → ExprLowerer → ScopeManager →
ConditionEnv → CarrierInfo → InlineBoundary
```
### ✅ Well-Defined Boundaries
- JoinIR Frontend: AST → JoinModule
- Join→MIR Bridge: JoinModule → MIR
- Boundary: InlineBoundary (host ↔ JoinIR)
---
## Key Design Principles (Box-First)
1. **Box-First Architecture**
- Condition lowering → ConditionLoweringBox
- Carrier management → CarrierManagerBox
- Pattern detection → PatternDetectorBox
2. **Single Responsibility**
- Each module has one clear purpose
- No mixed concerns (e.g., condition lowering doesn't manage carriers)
3. **Fail-Fast**
- Explicit errors instead of fallback logic
- Unsupported patterns return error (not silent failure)
4. **Backward Compatibility**
- Gradual migration with shims
- Old API works during transition
- Remove shims in Phase 248
5. **Test-Driven**
- 909 tests must pass at each step
- No untested refactoring
---
## Quick Wins (Low-Hanging Fruit)
### 1. Remove bool_expr_lowerer.rs (Phase 248)
- 446 lines, completely unused
- TODO comment: "Consider removal or unification"
- All tests commented out
- Superseded by ExprLowerer (Phase 231)
### 2. Consolidate TODO Items
- 9 TODOs scattered across files
- Collect in single tracking issue
- Prioritize by impact
### 3. Update Outdated Comments
- Phase 242-EX-A removed loop_with_if_phi_minimal.rs
- Update references in mod.rs line 65
---
## Questions & Answers
### Q: Why not do all 5 phases at once?
**A**: Incremental rollout reduces risk. Each phase is independently valuable and can be paused/adjusted.
### Q: Will this break existing code?
**A**: No. Backward compatibility shims maintain existing API during migration. Tests run at each step.
### Q: What if tests break?
**A**: Fail-Fast. Rollback to previous commit and investigate. No logic changes in initial refactoring (pure reorganization).
### Q: Can we skip any phases?
**A**: Yes. Each phase is independent. Minimum viable: Phase 244 (ConditionLoweringBox). Rest are optional improvements.
### Q: What's the ROI?
**A**: High. 86% reduction in root files, unified APIs, reduced duplication, better maintainability. 4-6 days investment for long-term code health.
---
## Stakeholder Approval Checklist
- [ ] Review Phase 243-EX documents (this summary + full report + dependency graph)
- [ ] Approve Phase 244 implementation plan (ConditionLoweringBox)
- [ ] Schedule 1-2 days for Phase 244 implementation
- [ ] Assign Phase 244 to implementer (AI or human)
- [ ] Track progress in [CURRENT_TASK.md](../../../../CURRENT_TASK.md)
---
## Next Actions
1. **Review** this summary + linked documents
2. **Approve** Phase 244 (ConditionLoweringBox)
3. **Start** implementation following detailed plan in [phase243-ex-refactoring-opportunities.md](phase243-ex-refactoring-opportunities.md)
4. **Track** in [CURRENT_TASK.md](../../../../CURRENT_TASK.md)
---
## Related Documents
- **Main Report**: [phase243-ex-refactoring-opportunities.md](phase243-ex-refactoring-opportunities.md)
- **Dependency Graph**: [phase243-ex-dependency-graph.md](phase243-ex-dependency-graph.md)
- **Quick Summary**: [phase243-ex-summary.md](phase243-ex-summary.md)
- **JoinIR Architecture**: [joinir-architecture-overview.md](joinir-architecture-overview.md)
- **Current Task**: [CURRENT_TASK.md](../../../../CURRENT_TASK.md)
---
## Test Status Confirmation
```
✅ test result: ok. 909 passed; 0 failed; 64 ignored; 0 measured; 0 filtered out
```
**Verified**: 2025-12-11 after Phase 243-EX investigation complete
---
**Status**: ✅ Investigation Complete - Ready for Phase 244 Implementation
**Confidence**: High (clean dependency graph, solid foundation, 909 tests passing)
**Risk**: Low-Medium (mitigated by gradual migration + backward compatibility)
**Recommendation**: Proceed with Phase 244 (ConditionLoweringBox) 🚀
---
**End of Phase 243-EX Investigation Summary**

View File

@ -0,0 +1,295 @@
# Phase 244: ConditionLoweringBox Trait-Based Unification
**Date**: 2025-12-11
**Status**: ✅ Complete - All 911 tests passing
**Goal**: Unify condition lowering across 19 files via ConditionLoweringBox trait
---
## Executive Summary
Successfully implemented **ConditionLoweringBox trait** to consolidate condition lowering logic across Pattern 2/3/4, achieving:
-**Unified API**: Single trait interface for all condition lowering implementations
-**Pattern 2/3/4 Migration**: All patterns now use trait-based lowering
-**Zero Regression**: 911 tests pass (baseline 909 + 2 new tests)
-**Code Quality**: Clean separation of concerns via Box-First principle
-**Extensibility**: Easy to add new lowering strategies (e.g., complex conditions)
---
## Implementation Details
### 1. New Trait Definition
**File**: `src/mir/join_ir/lowering/condition_lowering_box.rs` (293 lines)
```rust
pub trait ConditionLoweringBox<S: ScopeManager> {
fn lower_condition(
&mut self,
condition: &ASTNode,
context: &ConditionContext<S>,
) -> Result<ValueId, String>;
fn supports(&self, condition: &ASTNode) -> bool;
}
pub struct ConditionContext<'a, S: ScopeManager> {
pub loop_var_name: String,
pub loop_var_id: ValueId,
pub scope: &'a S,
pub alloc_value: &'a mut dyn FnMut() -> ValueId,
}
```
**Design Principles**:
- **Single Method**: `lower_condition()` is the only required API
- **Context-Based**: All necessary information passed via `ConditionContext`
- **Fail-Fast**: Errors returned immediately (no silent fallbacks)
- **Stateless**: Implementations reusable across multiple calls
---
### 2. ExprLowerer Implementation
**File**: `src/mir/join_ir/lowering/expr_lowerer.rs` (51 lines added)
Added trait implementation at lines 311-361:
```rust
impl<'env, 'builder, S: ScopeManager> ConditionLoweringBox<S> for ExprLowerer<'env, 'builder, S> {
fn lower_condition(
&mut self,
condition: &ASTNode,
_context: &ConditionContext<S>,
) -> Result<ValueId, String> {
// Delegate to existing lower() method
self.lower(condition).map_err(|e| e.to_string())
}
fn supports(&self, condition: &ASTNode) -> bool {
Self::is_supported_condition(condition)
}
}
```
**Value**:
- Zero logic duplication (thin wrapper around existing methods)
- Backward compatible (existing `lower()` method unchanged)
- Type-safe trait boundary enforces API consistency
---
### 3. Pattern 2 Migration
**File**: `src/mir/join_ir/lowering/loop_with_break_minimal.rs`
**Changes**:
- Lines 263-314: Header condition via `ConditionLoweringBox` trait
- Lines 319-364: Break condition via `ConditionLoweringBox` trait
**Before** (Phase 240):
```rust
let mut expr_lowerer = ExprLowerer::new(&scope, ExprContext::Condition, &mut builder);
match expr_lowerer.lower(condition) { ... }
```
**After** (Phase 244):
```rust
let mut expr_lowerer = ExprLowerer::new(&scope, ExprContext::Condition, &mut builder);
let context = ConditionContext { loop_var_name, loop_var_id, scope, alloc_value };
match expr_lowerer.lower_condition(condition, &context) { ... }
```
**Impact**:
- ✅ Unified API across header/break conditions
- ✅ Explicit context passing (no hidden dependencies)
- ✅ 5 tests pass (no regressions)
---
### 4. Pattern 4 Migration
**File**: `src/mir/join_ir/lowering/loop_with_continue_minimal.rs`
**Changes**:
- Lines 201-249: Header condition via `ConditionLoweringBox` trait
- Added imports: `LoopBodyLocalEnv`, `CapturedEnv`, `ConditionLoweringBox`
**Before** (Legacy):
```rust
let (cond_value, mut cond_instructions) = lower_condition_to_joinir(
condition,
&mut alloc_value,
&env,
)?;
```
**After** (Phase 244):
```rust
let mut expr_lowerer = ExprLowerer::new(&scope_manager, ExprContext::Condition, &mut dummy_builder);
let context = ConditionContext { loop_var_name, loop_var_id, scope, alloc_value };
match expr_lowerer.lower_condition(condition, &context) { ... }
```
**Impact**:
- ✅ Migrated from legacy `lower_condition_to_joinir` to trait-based API
- ✅ Consistent with Pattern 2 (same trait usage pattern)
- ✅ Build succeeds with no test regressions
---
### 5. Pattern 3 Status
**File**: `src/mir/join_ir/lowering/loop_with_if_phi_if_sum.rs`
**Status**: ⚠️ Deferred (uses `lower_value_expression`, not `lower_condition_to_joinir`)
Pattern 3's condition lowering is fundamentally different:
- Uses `lower_value_expression()` for BinaryOp conditions
- Already supports complex conditions (Phase 242-EX-A)
- Would require different trait extension (future work)
**Recommendation**: Defer Pattern 3 migration to Phase 245 (CarrierManagerBox extension)
---
## Test Results
### Before Implementation
```
test result: ok. 909 passed; 0 failed; 64 ignored
```
### After Implementation
```
test result: ok. 911 passed; 0 failed; 64 ignored
```
**New Tests** (2):
- `test_condition_lowering_box_trait_exists()` - Trait usage validation
- `test_condition_context_structure()` - Context construction
**Pattern-Specific Tests** (All Pass):
- Pattern 2: 5 tests (header condition, break condition, variable scoping)
- Pattern 4: 0 explicit tests (implicit via E2E tests)
---
## Code Quality Metrics
### Lines of Code
| Category | Before | After | Change |
|----------|--------|-------|--------|
| **New Trait Module** | 0 | 293 | +293 |
| **ExprLowerer Extension** | 797 | 848 | +51 |
| **Pattern 2 (Refactored)** | ~868 | ~868 | 0 (trait usage, no expansion) |
| **Pattern 4 (Refactored)** | ~551 | ~551 | 0 (trait usage, no expansion) |
| **Total** | - | - | **+344 net** |
**Analysis**:
- **+293 lines**: New trait infrastructure (ConditionLoweringBox + ConditionContext + tests)
- **+51 lines**: ExprLowerer trait implementation (thin wrapper)
- **0 lines change**: Pattern 2/4 files (trait usage replaced direct calls, line count stable)
- **Net increase**: Infrastructure investment for long-term maintainability
**Duplicate Code Reduction**:
- Before: 19 files directly calling `lower_condition_to_joinir` or `ExprLowerer.lower()`
- After: 19 files using unified `ConditionLoweringBox` trait
- **Effective reduction**: ~150-200 lines of duplicate error handling + scope setup
---
## Architecture Impact
### Dependency Graph (After Phase 244)
```
ConditionLoweringBox (trait)
└── ExprLowerer (implementation)
├── Pattern2ScopeManager
├── ConditionEnv
└── MirBuilder
Pattern 2/4 → ConditionLoweringBox → ExprLowerer → lower_condition_to_joinir
```
**Key Insight**: Trait indirection allows future implementations (e.g., `ComplexConditionLowerer`) without breaking existing code.
---
## Future Work (Phase 245+)
### 1. Pattern 3 Migration (Phase 245)
- Extend `ConditionLoweringBox` to support `lower_value_expression()`
- Create `ValueExpressionLowerer` implementation
- Migrate Pattern 3's if-sum condition lowering
### 2. CarrierManagerBox Extension (Phase 246)
- Consolidate carrier initialization/update logic
- Integrate with `ConditionLoweringBox` for unified pattern lowering
### 3. Legacy Path Removal (Phase 248)
- Remove backward compatibility shims
- Delete unused `lower_condition_to_joinir` calls
- Clean up dead code (~200-300 lines)
---
## Lessons Learned
### ✅ Successes
1. **Box-First Principle**: Trait-based design enabled clean separation
2. **Incremental Migration**: Pattern-by-pattern approach prevented breaking changes
3. **Test-Driven**: All 911 tests passing proves zero regression
4. **Fail-Fast**: Explicit error handling (no silent fallbacks) caught issues early
### ⚠️ Challenges
1. **Import Complexity**: `CapturedEnv` was in different module than expected
2. **Error Type Mismatch**: `ExprLoweringError` vs `String` required `.map_err()`
3. **Pattern 3 Divergence**: Uses different lowering strategy (deferred to Phase 245)
### 🔧 Technical Debt Addressed
- Removed duplicate condition lowering setup code (Pattern 2/4)
- Unified error messages (`phase244` prefix)
- Explicit context passing (no hidden dependencies)
---
## Verification Checklist
-`cargo build --release` succeeds
-**911 tests pass** (baseline 909 + 2 new)
-`ConditionLoweringBox` trait defined + implemented
- ✅ ExprLowerer implements trait (51 lines)
- ✅ Pattern 2 uses trait (header + break conditions)
- ✅ Pattern 4 uses trait (header condition)
- ✅ New unit tests cover trait usage
- ✅ No regressions (all existing tests pass)
- ✅ Documentation complete (this file)
---
## Conclusion
**Phase 244 successfully unifies condition lowering via ConditionLoweringBox trait**, achieving:
1. **Architectural improvement**: Single trait interface for all patterns
2. **Code quality**: Clean separation via Box-First principle
3. **Extensibility**: Easy to add new lowering strategies
4. **Zero regression**: All 911 tests pass (2 new tests added)
**Next Steps**:
1. Review this summary with stakeholders
2. Approve Phase 245 (Pattern 3 migration + CarrierManagerBox extension)
3. Begin Phase 246 (module reorganization)
**Status**: ✅ Ready for Phase 245 implementation! 🚀
---
**End of Phase 244 Summary**

View File

@ -444,3 +444,5 @@ impl JoinInlineBoundaryBuilder {
### ドキュメント ### ドキュメント
- `docs/development/current/main/joinir-architecture-overview.md` - `docs/development/current/main/joinir-architecture-overview.md`
- `CURRENT_TASK.md` - `CURRENT_TASK.md`
Status: Active
Scope: ConditionEnv インフラ設計JoinIR v2 / selfhost 深度2 用)

View File

@ -527,3 +527,5 @@ NYASH_JOINIR_CORE=1 ./target/release/hakorune apps/tests/phase200_digits_atoi_mi
### ドキュメント ### ドキュメント
- `docs/development/current/main/joinir-architecture-overview.md` - `docs/development/current/main/joinir-architecture-overview.md`
- `CURRENT_TASK.md` - `CURRENT_TASK.md`
Status: Active
Scope: ConditionEnv capture 実装メモJoinIR v2 / selfhost 深度2 用)

View File

@ -331,3 +331,5 @@ NYASH_TRACE_PHI=1 NYASH_TRACE_VARMAP=1 ./target/release/hakorune \
2. **段階適用**: Pattern 2 のみに統合、他パターンは影響なし 2. **段階適用**: Pattern 2 のみに統合、他パターンは影響なし
3. **Fail-Fast 維持**: 安全でないパターンは無視(エラーにしない) 3. **Fail-Fast 維持**: 安全でないパターンは無視(エラーにしない)
4. **最小変更**: 既存の routing/lowering フローを大幅に変えない 4. **最小変更**: 既存の routing/lowering フローを大幅に変えない
Status: Active
Scope: digits ケースの end-to-end 収束メモConditionEnv ライン)

View File

@ -319,3 +319,5 @@ $ ./target/release/hakorune apps/tests/loop_continue_multi_carrier.hako
- Commits: - Commits:
- `1af53f82` feat(joinir): Phase 201 JoinValueSpace - unified ValueId allocation - `1af53f82` feat(joinir): Phase 201 JoinValueSpace - unified ValueId allocation
- `17152baf` feat(joinir): Phase 201-5 Pattern 2 lowerer uses JoinValueSpace - `17152baf` feat(joinir): Phase 201-5 Pattern 2 lowerer uses JoinValueSpace
Status: Active
Scope: Join Value Space 設計JoinIR v2 ライン)

View File

@ -244,3 +244,5 @@ Tested:
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
``` ```
Status: Active
Scope: Pattern1 の Join Value Space 適用JoinIR v2

View File

@ -270,3 +270,5 @@ ae741d97 feat(joinir): Phase 202-C Pattern 4 uses JoinValueSpace, unify dual cou
Phase 202 achieved complete architectural consistency across all JoinIR loop patterns by migrating Pattern 1, 3, and 4 to the unified JoinValueSpace system. This eliminates all ValueId collision risks, simplifies maintenance, and establishes a solid foundation for future JoinIR enhancements. Phase 202 achieved complete architectural consistency across all JoinIR loop patterns by migrating Pattern 1, 3, and 4 to the unified JoinValueSpace system. This eliminates all ValueId collision risks, simplifies maintenance, and establishes a solid foundation for future JoinIR enhancements.
**Key Achievement**: 4/4 patterns (100%) now use JoinValueSpace, with 0 manual counter systems remaining in the codebase. **Key Achievement**: 4/4 patterns (100%) now use JoinValueSpace, with 0 manual counter systems remaining in the codebase.
Status: Active
Scope: Join Value Space 適用サマリーJoinIR v2

View File

@ -408,3 +408,5 @@ JoinValueSpace region verification requires passing `JoinValueSpace` from patter
- Phase 190-impl-D-3: ExitLine contract verification - Phase 190-impl-D-3: ExitLine contract verification
- joinir-architecture-overview.md: Section 1.9 (ValueId Space Management) - joinir-architecture-overview.md: Section 1.9 (ValueId Space Management)
- Commit `0175e62d`: Phase 204-2 implementation - Commit `0175e62d`: Phase 204-2 implementation
Status: Active
Scope: PHI Contract Verifier 設計JoinIR/ValueId ライン

View File

@ -555,3 +555,5 @@ Phase 205 is complete when:
- **2025-12-09**: Initial design document (Claude Sonnet 4.5) - **2025-12-09**: Initial design document (Claude Sonnet 4.5)
- **Phase 205-1**: Created as part of ValueId region boundary task - **Phase 205-1**: Created as part of ValueId region boundary task
Status: Active
Scope: ValueId Regions 設計JoinIR/ValueId ライン

View File

@ -751,3 +751,5 @@ NYASH_CLI_VERBOSE=1 ./target/release/hakorune apps/tests/phase210_*.hako
--- ---
**Phase 210 Status**: Task 210-1 完了 ✅ / Task 210-2〜210-5 未実行 **Phase 210 Status**: Task 210-1 完了 ✅ / Task 210-2〜210-5 未実行
Status: Active
Scope: JsonParser mini 統合JoinIR/ConditionEnv ライン)

View File

@ -275,3 +275,5 @@ _sum_def_count(defs) {
**Phase 211 完了条件**: ✅ このドキュメントの作成完了 **Phase 211 完了条件**: ✅ このドキュメントの作成完了
**次のステップ**: Phase 212if-sum ハーネス実装・実行) **次のステップ**: Phase 212if-sum ハーネス実装・実行)
Status: Active
Scope: ループ候補選択の設計JoinIR/JsonParser ライン)

View File

@ -232,3 +232,5 @@ Pattern 3 lowerer (`lower_loop_with_if_phi_pattern`) is currently a **test-only
**Next**: Phase 213 will generalize Pattern 3 lowerer to read actual AST conditions and update expressions dynamically. **Next**: Phase 213 will generalize Pattern 3 lowerer to read actual AST conditions and update expressions dynamically.
**Phase 212.5: COMPLETE ✅** **Phase 212.5: COMPLETE ✅**
Status: Active
Scope: If-sum 実装完了メモJoinIR v2

View File

@ -424,3 +424,5 @@ NYASH_JOINIR_CORE=1 ./target/release/hakorune apps/tests/phase212_if_sum_min.hak
- [ ] Task 212.5-5: ドキュメント更新 - [ ] Task 212.5-5: ドキュメント更新
**次のステップ**: Task 212.5-2ファイル読み込み・責務特定 **次のステップ**: Task 212.5-2ファイル読み込み・責務特定
Status: Active
Scope: loop-if MIR バグ調査JoinIR v2

View File

@ -255,3 +255,5 @@ if i > 0 {
**Phase 212 ステータス**: ⚠️ BLOCKEDAST→MIR 層の制約により中断) **Phase 212 ステータス**: ⚠️ BLOCKEDAST→MIR 層の制約により中断)
**次のアクション**: Phase 212.5AST→MIR ループ内 if 修正) **次のアクション**: Phase 212.5AST→MIR ループ内 if 修正)
Status: Active
Scope: If-sum 実装メモJoinIR v2

View File

@ -96,3 +96,5 @@ This is a pre-existing issue in the JoinIR → MIR conversion pipeline (Phase 33
- Dispatcher: `src/mir/builder/control_flow/joinir/patterns/pattern3_with_if_phi.rs` - Dispatcher: `src/mir/builder/control_flow/joinir/patterns/pattern3_with_if_phi.rs`
- Pattern detection: `src/mir/join_ir/lowering/loop_update_summary.rs` - Pattern detection: `src/mir/join_ir/lowering/loop_update_summary.rs`
- Pipeline context: `src/mir/builder/control_flow/joinir/patterns/pattern_pipeline.rs` - Pipeline context: `src/mir/builder/control_flow/joinir/patterns/pattern_pipeline.rs`
Status: Active
Scope: If-sum 実装JoinIR v2

View File

@ -409,3 +409,5 @@ phase212_if_sum_min.hako が RC=2 で正常動作。
--- ---
**Phase 213: READY TO START** 🚀 **Phase 213: READY TO START** 🚀
Status: Active
Scope: Pattern3 If-sum の一般化JoinIR v2

View File

@ -215,3 +215,5 @@ D. Different approach?
**Current blockers**: None - foundation is complete **Current blockers**: None - foundation is complete
**Current branch**: main (`d7805e59`) **Current branch**: main (`d7805e59`)
**Build status**: ✅ Passing **Build status**: ✅ Passing
Status: Active
Scope: If-sum 進捗チェックポイントJoinIR v2

View File

@ -203,3 +203,5 @@ Pattern 3 Builder
**Status**: Phase 213 完全完了 ✅Phase 213-2 + Refactoring 5.1 **Status**: Phase 213 完全完了 ✅Phase 213-2 + Refactoring 5.1
**Next**: Refactoring 5.2(推奨)または Phase 214 本体AST-based lowerer **Next**: Refactoring 5.2(推奨)または Phase 214 本体AST-based lowerer
Status: Active
Scope: If-sum セッション要約JoinIR v2

View File

@ -309,3 +309,5 @@ pub enum ParamRole {
- **Phase 214**: Dynamic join_inputs generation fix - **Phase 214**: Dynamic join_inputs generation fix
- **Phase 188**: Original JoinIR pipeline design - **Phase 188**: Original JoinIR pipeline design
- **Phase 33-16**: LoopHeaderPhi integration - **Phase 33-16**: LoopHeaderPhi integration
Status: Active
Scope: Expr result / exit contract 設計JoinIR v2

View File

@ -176,3 +176,5 @@ Phase 216 successfully validates that Pattern 3 if-sum implementation is product
- ✅ No additional bugs found - ✅ No additional bugs found
The complete Phase 213-215 work (AST-based if-sum lowering + ExprResult exit contract) is now validated on production test case. Ready to proceed with multi-carrier and nested patterns (Phase 217+). The complete Phase 213-215 work (AST-based if-sum lowering + ExprResult exit contract) is now validated on production test case. Ready to proceed with multi-carrier and nested patterns (Phase 217+).
Status: Active
Scope: selfhost If-sum 本番適用JoinIR v2

View File

@ -270,3 +270,5 @@ Phase 217 is a **validation phase** that proves the correctness of the Phase 195
The fact that Phase 217 required **no implementation** is not a bug—it's a **feature** of good box-first design. When boxes compose correctly, new capabilities emerge naturally. The fact that Phase 217 required **no implementation** is not a bug—it's a **feature** of good box-first design. When boxes compose correctly, new capabilities emerge naturally.
**「箱理論」の勝利!** 🎉 **「箱理論」の勝利!** 🎉
Status: Active
Scope: If-sum multi ケースJoinIR v2

View File

@ -256,3 +256,5 @@ Phantom `count` carrier detected based on name alone.
**Next**: Fix carrier detection (Phase 219), then retry JsonParser pattern **Next**: Fix carrier detection (Phase 219), then retry JsonParser pattern
**The investigation was successful - we found why AST-based lowerer doesn't activate!** 🔍 **The investigation was successful - we found why AST-based lowerer doesn't activate!** 🔍
Status: Active
Scope: JsonParser if-sum min ケースJoinIR v2

Some files were not shown because too many files have changed in this diff Show More