Files
hakorune/CURRENT_TASK.md

280 lines
26 KiB
Markdown
Raw Normal View History

feat(hako_check): Phase 153 - Dead code detection revival (JoinIR version) Implement comprehensive dead code detection for hako_check with JoinIR integration, following Phase 133/134/152 box-based modularity pattern. ## Key Achievements 1. **Comprehensive Inventory** (`phase153_hako_check_inventory.md`): - Documented current hako_check architecture (872 lines) - Analyzed existing HC011/HC012 rules - Confirmed JoinIR-only pipeline (Phase 124) - Identified Phase 153 opportunities 2. **DeadCodeAnalyzerBox** (`rule_dead_code.hako`): - Unified HC019 rule (570+ lines) - Method-level + box-level dead code detection - DFS reachability from entrypoints - Text-based analysis (no MIR JSON dependency for MVP) - Heuristic-based false positive reduction 3. **CLI Integration** (`cli.hako`): - Added `--dead-code` flag for comprehensive mode - Added `--rules dead_code` for selective execution - Compatible with --format (text/json-lsp/dot) 4. **Test Infrastructure**: - HC019_dead_code test directory (ng/ok/expected.json) - `hako_check_deadcode_smoke.sh` with 4 test cases ## Technical Details - **Input**: Analysis IR (MapBox with methods/calls/boxes/entrypoints) - **Output**: HC019 diagnostics - **Algorithm**: Graph-based DFS reachability - **Pattern**: Box-based modular architecture - **No ENV vars**: CLI flags only ## Files Modified - NEW: docs/development/current/main/phase153_hako_check_inventory.md - NEW: tools/hako_check/rules/rule_dead_code.hako - MOD: tools/hako_check/cli.hako - NEW: tools/hako_check/tests/HC019_dead_code/ - NEW: tools/hako_check_deadcode_smoke.sh - MOD: CURRENT_TASK.md ## Next Steps - Phase 154+: MIR CFG integration for block-level detection - Phase 160+: Integration with .hako JoinIR/MIR migration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 14:19:48 +09:00
# Current Task
feat(joinir): Phase 215-2 ExprResult exit contract for Pattern 3 Implements Phase 215 Task 215-2: Wire expr_result exit line through ExitMeta → JoinInlineBoundary → ExitLine → MIR return for Pattern 3. ## Changes ### Fix 1: JoinIR Lowerer (loop_with_if_phi_if_sum.rs:312) - Changed `carrier_only()` → `with_expr_result(sum_final, exit_meta)` - Marks sum final value as expr_result for propagation ### Fix 2: Boundary Builder (pattern3_with_if_phi.rs:176-191) - Added `.with_expr_result(Some(expr_id))` to JoinInlineBoundaryBuilder - Passes expr_result to boundary for ExitLineReconnector ### Fix 3: Final Return (pattern3_with_if_phi.rs:195-219) - Changed from always returning Void to conditional return: - Expr-position loops: Return merge_result ValueId - Statement-position loops: Return Void - Matches Pattern 2 behavior ## Test Results Primary target: - phase212_if_sum_min.hako: RC=2 achieved ✅ Regression tests: - loop_if_phi.hako: RC=2 (existing behavior maintained) ✅ - Pattern 1/2/3 tests: All PASS ✅ ## Architecture Pattern 3 now follows the same ExprResult Exit Contract as Pattern 2: 1. JoinIR lowerer creates expr_result with `with_expr_result()` 2. Boundary builder passes expr_result with `.with_expr_result()` 3. Conversion pipeline returns merge result containing exit PHI ValueId 4. Pattern dispatcher conditionally returns expr_result or Void This enables: - Expr-position loops: Loop result propagates to caller - Statement-position loops: Loop updates variable_map only (returns Void) - Unified contract: Patterns 2 and 3 follow same expr_result flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-10 01:40:18 +09:00
このファイルは「いま何に集中しているか」と「次にやり得る候補」だけを書く軽量ビューだよ。
詳細なログや過去フェーズの記録は `docs/development/current/main/` 以下の各 `phase-*.md`
`docs/development/current/main/joinir-architecture-overview.md` を真実のソースとして扱うよ。
---
## 🎯 今フォーカスしているテーマ2025-12-12 時点のスナップショット)
### 0. ✅ Phase 43/245B Normalized JoinIR Infrastructure COMPLETE (Phase 26-45)
**完全サマリ**: [PHASE_43_245B_NORMALIZED_COMPLETION.md](docs/development/current/main/PHASE_43_245B_NORMALIZED_COMPLETION.md)
- **達成内容**:
- Structured→Normalized→MIR(direct) パイプライン確立
- P1/P2 + JsonParser (skip_ws/atoi/parse_number) 全対応
- Mode system (Phase 45), Capability system (Phase 44) 完成
- 937/937 tests PASS
- **主要コンポーネント**:
- JoinIrMode enum (StructuredOnly/NormalizedDev/NormalizedCanonical)
- ShapeCapabilityKind (P2CoreSimple/P2CoreSkipWs/P2CoreAtoi/P2MidParseNumber)
- CarrierRole (LoopState/ConditionOnly), CarrierInit
- DigitPos dual-value (is_digit_pos + digit_value)
- NumberAccumulation, Step scheduling, Exit PHI & Jump args
- **今後の拡張候補**(計画のみ):
- Phase 46+: Canonical set 拡張 (capability-based)
- Pattern3/4 Normalized 適用
- Selfhost loops 対応
### 0-B. JoinIR / ExprLowerer / Pattern24 + JsonParser `_parse_number` / DigitPos ラインPhase 230247-EX 完了)✅
- Pattern14while / break / ifPHI / continue P5(Trim) でループ lowering を JoinIR 経路に一本化。
- Phase 231/236/240-EX:
- Pattern2 の header / break 条件を ExprLowerer/ScopeManager 経由(対応パターンのみ)で本番導線化。
- ConditionEnv ベースの意味論と RC/JoinIR 構造が一致することをテストとカタログで確認済み。
- Phase 237238-EX:
- JsonParser/selfhost の条件パターンをカタログ化し、ExprLowerer/ScopeManager/ConditionEnv の責務境界を docs/README で固定。
- Phase 241242-EX:
- array_filter 系 3 FAIL を「構造で」解消hardcode `"sum"` チェック削除、CarrierInfo/ExitMeta 経由に統一)。
- Pattern3 ifsum / Pattern4 continue から legacy lowerer と by-name `"sum"`/`"count"` を完全削除。
- 複雑条件(`i % 2 == 1`)を ConditionPattern/if-sum lowerer で安全に扱えるよう整理Fail-Fast + テスト付き)。
- Phase 243244-EX:
- Pattern3/4 の公開 API を `can_lower + lower` の最小セットに整理し、内部 helper を箱の中に閉じた。
- `loop_pattern_detection` の classify() が代表ループを P1〜P4 に分類することをユニットテストで固定。
- Phase 245-EX / 245C:
- `_parse_number` のループについて、ループ変数 `p` の header/break 条件と `p = p + 1` 更新を Pattern2 + ExprLowerer 経路に載せて本番化。
- FunctionScopeCapture / CapturedEnv を拡張し、関数パラメータ(例: `s`, `len`)をループ条件/本体で読み取り専用なら CapturedEnv 経由で ConditionEnv に載せるようにした。
- これにより、`p < s.length()` のような header 条件や JsonParser 系ループでのパラメータ参照が、ExprLowerer/ScopeManager から安全に解決される。
- Phase 245B-IMPL:
- `_parse_number` 本体で `num_str = num_str + ch` を LoopState キャリアとして扱い、Program(JSON) フィクスチャ `jsonparser_parse_number_real` を Structured→Normalized→MIR(direct) で dev テスト固定(出力は num_str 文字列)。
- Phase 247-EX:
- DigitPos promotion を二重値化し、`digit_pos` から boolean carrier `is_digit_pos`ConditionOnlyと integer carrier `digit_value`LoopStateを生成。
- UpdateEnv で `digit_pos` 解決時に `digit_value` を優先し、NumberAccumulation`result = result * 10 + digit_pos`)と break 条件の両方で DigitPos パターンが安全に利用可能に。
- 現在: `cargo test --release --lib` で 931/931 テスト PASS既知 FAIL なし)。
- Phase 28-NORM-P2dev-only:
- Normalized JoinIR のミニ実装を Pattern1 に続き Pattern2 最小ケースまで拡張Structured→Normalized→Structured を比較)。
- 対応外の Structured JoinModule では normalize_pattern2_minimal が Fail-Fast するようガードを追加し、normalized_dev テストで固定。
- Phase 29-NORM-P2-APPLYdev-only:
- Phase 34 の break fixturei/acc/n の単純 break ループ)を Structured→Normalized→Structured の往復に通し、VM 実行結果が Structured 直経路と一致することを dev テストで固定。
- ガードは 3 パラメータまで緩和しつつ、DigitPos/Trim などの重いキャリアはまだ非対応のまま。
- Phase 30-NORM-P2-DEV-RUNdev-only:
- JoinIR runner に `NYASH_JOINIR_NORMALIZED_DEV_RUN=1` を追加し、Pattern1/2 ミニケースだけ Structured→Normalized→Structured を挟んで dev 実行できるようにした(`normalized_dev` + debug 限定。通常経路Structured→MIRは不変。
- Phase 31-NORM-JP-MINIdev-only:
- JsonParser 系のシンプルな P2 ループskip_whitespace ミニ fixtureを Structured→Normalized→Structured 経由でも実行し、runner dev スイッチの比較テストで Structured 直経路と一致することを固定。
- Phase 32-NORM-CANON-PREPdev-only:
- JoinIR→MIR ブリッジの入口を `bridge_joinir_to_mir` に一本化し、normalized_dev スイッチfeature + envで Structured→Normalized→Structured の dev roundtrip を切り替える準備を整えた。P1/P2/JP mini の比較テストも VM ブリッジ経路で追加。
- Phase 33-NORM-CANON-TESTdev-only:
- P1/P2Phase 34 break fixture/JsonParser skip_ws mini について、normalized_dev ON 時は shape_guard 経由で必ず Normalized roundtrip を通すようブリッジと runner を固めた。normalized_joinir_min.rs の runner/VM 比較テストを拡張し、Normalized が壊れたら dev スイートが必ず赤になるようにした(本番 CLI は従来どおり Structured→MIR
- Phase 34-NORM-ATOI-DEVdev-only:
- JsonParser `_atoi` ミニループdigit_pos→digit_value + NumberAccumulationを normalized_dev 経路に載せ、Structured↔Normalized↔Structured の VM 実行結果が一致することをフィクスチャテストで固定。`jsonparser_atoi_mini` を shape_guard で認識し、既定経路は引き続き Structured→MIR のまま。
- Phase 35-NORM-BRIDGE-MINIdev-only:
- P1/P2 ミニ + JsonParser skip_ws/atoi ミニを Normalized→MIR 直ブリッジで実行できるようにし、normalized_dev ON 時は Structured→Normalized→MIR復元なし経路との比較テストで結果一致を固定。既定経路Structured→MIRは不変。
- Phase 36-NORM-BRIDGE-DIRECTdev-only:
- Normalized ブリッジを direct 実装Normalized→MIRと Structured 再構成に分離し、shape_guard で P1/P2 ミニ + JsonParser skip_ws/atoi ミニだけ direct 経路に通すよう整理。非対応は `[joinir/normalized-bridge/fallback]` ログ付きで再構成に落とし、テストで direct/従来経路の VM 出力一致を固定。
- Phase 37-NORM-JP-REALdev-only:
- JsonParser `_skip_whitespace` 本体の P2 ループを Program(JSON) フィクスチャで Structured→Normalized→MIR(direct) に通し、Structured 直経路との VM 出力一致を比較するテストを追加。`extract_value``&&`/`||` を BinOp として扱えるようにし、Break パターンの param 推定を柔軟化して real 形状でも panic しないようにした。
- Phase 38-NORM-OBSdev-only:
- Normalized/JoinIR dev 経路のログカテゴリを `[joinir/normalized-bridge/*]` / `[joinir/normalized-dev/shape]` に統一し、`JOINIR_TEST_DEBUG` 下だけ詳細を出すよう静音化。Verifier/FailFast メッセージも shape/役割付きに整え、デバッグ観測性を上げつつ通常実行のノイズを減らした。
- Phase 43-Adev-only:
- JsonParser `_atoi` 本体の Program(JSON) フィクスチャを normalized_dev に追加し、Structured→Normalized→MIR(direct) と Structured→MIR の VM 出力を比較するテストで一致を固定(符号あり/なしの簡易パス対応。canonical 切替は後続フェーズ)。
- Phase 43-Cdev-only:
- JsonParser `_parse_number` 本体の Program(JSON) フィクスチャを normalized_dev に追加し、Structured→Normalized→MIR(direct) と Structured→MIR の VM 出力を比較するテストで一致を固定num_str は現状仕様のまま据え置き、P2-Mid の足慣らし)。
- **Phase 46-NORM-CANON-P2-MID実装済み✅ 2025-12-12**:
- P2-Mid パターン_atoi real, _parse_number realを canonical Normalized に昇格。
- Canonical set 拡張: P2-Coremini + skip_ws + atoi mini+ P2-Midatoi real + parse_number real
- JsonParser P2 ライン_skip_whitespace/_atoi/_parse_number全て canonical Normalized 化完了。
- P3/P4 Normalized 対応は NORM-P3/NORM-P4 フェーズで実施(今回スコープ外)。
- 937/937 tests PASS。
- **Phase 47-B/CP3 if-sum 拡張 + canonical 化 ✅ 2025-12-21**:
- フィクスチャ追加: `pattern3_if_sum_multi_min`sum+count/ `jsonparser_if_sum_min`JsonParser 簡約形)
- ShapeGuard: `Pattern3IfSumMulti` / `Pattern3IfSumJson` 追加、capability=P3IfSum、canonical set に P3 minimal/multi/json を追加
- Normalizer/Bridge: P3 if-sum minimal/multi/json を Structured→Normalized→MIR(direct) で dev A/B、canonical ルートでも常時 Normalized 経由
- テスト: normalized_joinir_min.rs に P3 if-sum multi/json の VM ブリッジ比較テスト追加Structured と一致)
- **Phase 45-NORM-MODE実装済み✅ 2025-12-12**:
- JoinIR モード一本化: バラバラだったフラグ/feature を `JoinIrMode` enum に集約StructuredOnly / NormalizedDev / NormalizedCanonical
- `current_joinir_mode()` でモード取得、bridge/runner で `normalized_dev_enabled()` → mode pattern matching に移行。
- Canonical P2-Core は mode 無視で常に Normalized→MIR(direct)、それ以外は mode に従う統一ルーティング。
- 937/937 tests PASS既存挙動完全保持のリファクタ
- **Phase 44-SHAPE-CAP実装済み✅ 2025-12-12**:
- Shape検出を capability-based に変更: `NormalizedDevShape``ShapeCapability` 抽象化層導入。
- `ShapeCapabilityKind` 4種: P2CoreSimple / P2CoreSkipWs / P2CoreAtoi / P2MidParseNumber。
- Shape-level (`is_canonical_shape`) と Capability-level (`is_p2_core_capability`) の二層 API でパターン拡張性を確保。
- 既存挙動完全保持canonical set: Pattern2Mini, skip_ws mini/real, atoi mini のまま、937/937 tests PASS。
### 1. いまコード側で意識しておきたいフォーカス
- **Phase 43/245B Normalized 完了** により JoinIR ループ基盤Pattern14 + ExprLowerer + ScopeManager + CapturedEnv + Normalized layerは一応の完成状態に入ったので、当面は:
- 既存パターン/箱の範囲内での **バグ修正・FailFast/invariant 追加・テスト強化** を優先する。
- JsonParser/selfhost への新しい適用や大きな仕様拡張は、docs 側で Phase 設計が固まってからコード側に持ち込む。
- 直近のコード側フォーカス候補:
- ~~Phase 246-EXコード~~: ✅ 完了_atoi Integration, Phase 43/245B の一部)
- Pattern14 / ExprLowerer / ScopeManager まわりで、by-name ハードコードやサイレントフォールバックが見つかった場合は、
CarrierInfo / ConditionEnv / Scope 情報を使って「構造で」直す。
### 2. 直近で意識しておきたい設計の芯
feat(joinir): Phase 215-2 ExprResult exit contract for Pattern 3 Implements Phase 215 Task 215-2: Wire expr_result exit line through ExitMeta → JoinInlineBoundary → ExitLine → MIR return for Pattern 3. ## Changes ### Fix 1: JoinIR Lowerer (loop_with_if_phi_if_sum.rs:312) - Changed `carrier_only()` → `with_expr_result(sum_final, exit_meta)` - Marks sum final value as expr_result for propagation ### Fix 2: Boundary Builder (pattern3_with_if_phi.rs:176-191) - Added `.with_expr_result(Some(expr_id))` to JoinInlineBoundaryBuilder - Passes expr_result to boundary for ExitLineReconnector ### Fix 3: Final Return (pattern3_with_if_phi.rs:195-219) - Changed from always returning Void to conditional return: - Expr-position loops: Return merge_result ValueId - Statement-position loops: Return Void - Matches Pattern 2 behavior ## Test Results Primary target: - phase212_if_sum_min.hako: RC=2 achieved ✅ Regression tests: - loop_if_phi.hako: RC=2 (existing behavior maintained) ✅ - Pattern 1/2/3 tests: All PASS ✅ ## Architecture Pattern 3 now follows the same ExprResult Exit Contract as Pattern 2: 1. JoinIR lowerer creates expr_result with `with_expr_result()` 2. Boundary builder passes expr_result with `.with_expr_result()` 3. Conversion pipeline returns merge result containing exit PHI ValueId 4. Pattern dispatcher conditionally returns expr_result or Void This enables: - Expr-position loops: Loop result propagates to caller - Statement-position loops: Loop updates variable_map only (returns Void) - Unified contract: Patterns 2 and 3 follow same expr_result flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-10 01:40:18 +09:00
- **Loop パターン空間**は有限で整理済み:
- P1: Simple While
- P2: Break
- P3: IfPHI単一/複数キャリア)
- P4: Continuethen/elsecontinue 正規化込み)
- P5: LoopBodyLocal 昇格Trim/JsonParser 用の部分適用)
- 「増やすべき」は新しい Pattern ではなく、既存 Pattern の前処理箱:
- BoolExprLowerer / ConditionEnv / LoopConditionScopeBox / LoopBodyCarrierPromoter /
TrimLoopHelper / ComplexAddendNormalizer / LoopBodyLocalEnv / UpdateEnv などで
条件式とキャリア更新を吸収し、Pattern14 は「ループ骨格」に専念させる方針。
- FailFast 原則:
- JoinIR 以外のループ lowering パスは存在しないLoopBuilder は削除済み)。
- 「わからないパターン」は必ず `[joinir/freeze]` 系の明示エラーにして、サイレントフォールバックはしない。
feat(llvm): Phase 134-A - mir_call.py unified 設計完成 681行の giant ファイルを機能別に分割し、箱化モジュール化を達成。 Changes: - NEW: src/llvm_py/mir_call_compat.py (120 lines) - JSON v0/v1 互換層を一元管理 - normalize_callee(), detect_format_version() - NEW: src/llvm_py/instructions/mir_call/ (7 files) - __init__.py: Canonical Dispatcher (lower_mir_call) - global_call.py: Global関数呼び出し (90 lines) - method_call.py: Boxメソッド呼び出し (175 lines) - constructor_call.py: Boxコンストラクタ (122 lines) - closure_call.py: Closure生成 (87 lines) - value_call.py: 動的関数値呼び出し (112 lines) - extern_call.py: 外部C ABI呼び出し (135 lines) - ARCHIVE: mir_call.py → mir_call_legacy.py Technical Achievements: ✅ mir_call.py: 681行 → 分割(各 80-175行、責務 明確) ✅ Phase 133 ConsoleLlvmBridge パターンを継承 ✅ NYASH_MIR_UNIFIED_CALL フラグ完全廃止 ✅ legacy dispatcher 削除(NotImplementedError 根治) ✅ JSON v0/v1 互換層を mir_call_compat.py に一元化 ✅ Fail-Fast 原則確立 ✅ テスト: 全 mir_call 関連テスト PASS Design Principles Inherited: - Phase 133 ConsoleLlvmBridge 箱化パターン継承 - Each module has clear responsibility - mir_call_compat.py で Phase 124+ v0削除が容易 - テスト分割で保守性大幅向上 Next Phase: Phase 134-B - StringBox bridge 分離(boxcall.py:130-282) Phase 134-C - CollectionBox bridge 分離(boxcall.py:325-375) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 12:06:34 +09:00
---
feat(joinir): Phase 215-2 ExprResult exit contract for Pattern 3 Implements Phase 215 Task 215-2: Wire expr_result exit line through ExitMeta → JoinInlineBoundary → ExitLine → MIR return for Pattern 3. ## Changes ### Fix 1: JoinIR Lowerer (loop_with_if_phi_if_sum.rs:312) - Changed `carrier_only()` → `with_expr_result(sum_final, exit_meta)` - Marks sum final value as expr_result for propagation ### Fix 2: Boundary Builder (pattern3_with_if_phi.rs:176-191) - Added `.with_expr_result(Some(expr_id))` to JoinInlineBoundaryBuilder - Passes expr_result to boundary for ExitLineReconnector ### Fix 3: Final Return (pattern3_with_if_phi.rs:195-219) - Changed from always returning Void to conditional return: - Expr-position loops: Return merge_result ValueId - Statement-position loops: Return Void - Matches Pattern 2 behavior ## Test Results Primary target: - phase212_if_sum_min.hako: RC=2 achieved ✅ Regression tests: - loop_if_phi.hako: RC=2 (existing behavior maintained) ✅ - Pattern 1/2/3 tests: All PASS ✅ ## Architecture Pattern 3 now follows the same ExprResult Exit Contract as Pattern 2: 1. JoinIR lowerer creates expr_result with `with_expr_result()` 2. Boundary builder passes expr_result with `.with_expr_result()` 3. Conversion pipeline returns merge result containing exit PHI ValueId 4. Pattern dispatcher conditionally returns expr_result or Void This enables: - Expr-position loops: Loop result propagates to caller - Statement-position loops: Loop updates variable_map only (returns Void) - Unified contract: Patterns 2 and 3 follow same expr_result flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-10 01:40:18 +09:00
## ✅ 最近まとまった大きな塊(超要約)
ここ半年くらいで終わっている主な塊だけをざっくり書くね。
細かいタスク・バグ票・議論は `docs/development/current/main/phase-*.md`
`docs/development/current/main/joinir-architecture-overview.md` に全部残っているので、必要になったときだけそちらを読む想定。
feat(joinir): Phase 215-2 ExprResult exit contract for Pattern 3 Implements Phase 215 Task 215-2: Wire expr_result exit line through ExitMeta → JoinInlineBoundary → ExitLine → MIR return for Pattern 3. ## Changes ### Fix 1: JoinIR Lowerer (loop_with_if_phi_if_sum.rs:312) - Changed `carrier_only()` → `with_expr_result(sum_final, exit_meta)` - Marks sum final value as expr_result for propagation ### Fix 2: Boundary Builder (pattern3_with_if_phi.rs:176-191) - Added `.with_expr_result(Some(expr_id))` to JoinInlineBoundaryBuilder - Passes expr_result to boundary for ExitLineReconnector ### Fix 3: Final Return (pattern3_with_if_phi.rs:195-219) - Changed from always returning Void to conditional return: - Expr-position loops: Return merge_result ValueId - Statement-position loops: Return Void - Matches Pattern 2 behavior ## Test Results Primary target: - phase212_if_sum_min.hako: RC=2 achieved ✅ Regression tests: - loop_if_phi.hako: RC=2 (existing behavior maintained) ✅ - Pattern 1/2/3 tests: All PASS ✅ ## Architecture Pattern 3 now follows the same ExprResult Exit Contract as Pattern 2: 1. JoinIR lowerer creates expr_result with `with_expr_result()` 2. Boundary builder passes expr_result with `.with_expr_result()` 3. Conversion pipeline returns merge result containing exit PHI ValueId 4. Pattern dispatcher conditionally returns expr_result or Void This enables: - Expr-position loops: Loop result propagates to caller - Statement-position loops: Loop updates variable_map only (returns Void) - Unified contract: Patterns 2 and 3 follow same expr_result flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-10 01:40:18 +09:00
- **LoopBuilder 削除ラインPhase 180 前後)**
- LoopBuilder を devonly → hard freeze → 物理削除まで完了。
- Loop lowering の SSOT を JoinIR に一本化。
- **LoopPattern / Router ラインPhase 170179, 244-EX**
feat(joinir): Phase 215-2 ExprResult exit contract for Pattern 3 Implements Phase 215 Task 215-2: Wire expr_result exit line through ExitMeta → JoinInlineBoundary → ExitLine → MIR return for Pattern 3. ## Changes ### Fix 1: JoinIR Lowerer (loop_with_if_phi_if_sum.rs:312) - Changed `carrier_only()` → `with_expr_result(sum_final, exit_meta)` - Marks sum final value as expr_result for propagation ### Fix 2: Boundary Builder (pattern3_with_if_phi.rs:176-191) - Added `.with_expr_result(Some(expr_id))` to JoinInlineBoundaryBuilder - Passes expr_result to boundary for ExitLineReconnector ### Fix 3: Final Return (pattern3_with_if_phi.rs:195-219) - Changed from always returning Void to conditional return: - Expr-position loops: Return merge_result ValueId - Statement-position loops: Return Void - Matches Pattern 2 behavior ## Test Results Primary target: - phase212_if_sum_min.hako: RC=2 achieved ✅ Regression tests: - loop_if_phi.hako: RC=2 (existing behavior maintained) ✅ - Pattern 1/2/3 tests: All PASS ✅ ## Architecture Pattern 3 now follows the same ExprResult Exit Contract as Pattern 2: 1. JoinIR lowerer creates expr_result with `with_expr_result()` 2. Boundary builder passes expr_result with `.with_expr_result()` 3. Conversion pipeline returns merge result containing exit PHI ValueId 4. Pattern dispatcher conditionally returns expr_result or Void This enables: - Expr-position loops: Loop result propagates to caller - Statement-position loops: Loop updates variable_map only (returns Void) - Unified contract: Patterns 2 and 3 follow same expr_result flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-10 01:40:18 +09:00
- LoopFeatures / LoopPatternKind / PatternRouter / PatternPipelineContext を整備。
- Pattern14 の検出・ルーティングを「構造ベースAST features」で統一関数名ベタ書き依存を除去
- Phase 244-EX で代表ループP1〜P4の classify() 結果をユニットテストで固定。
feat(joinir): Phase 215-2 ExprResult exit contract for Pattern 3 Implements Phase 215 Task 215-2: Wire expr_result exit line through ExitMeta → JoinInlineBoundary → ExitLine → MIR return for Pattern 3. ## Changes ### Fix 1: JoinIR Lowerer (loop_with_if_phi_if_sum.rs:312) - Changed `carrier_only()` → `with_expr_result(sum_final, exit_meta)` - Marks sum final value as expr_result for propagation ### Fix 2: Boundary Builder (pattern3_with_if_phi.rs:176-191) - Added `.with_expr_result(Some(expr_id))` to JoinInlineBoundaryBuilder - Passes expr_result to boundary for ExitLineReconnector ### Fix 3: Final Return (pattern3_with_if_phi.rs:195-219) - Changed from always returning Void to conditional return: - Expr-position loops: Return merge_result ValueId - Statement-position loops: Return Void - Matches Pattern 2 behavior ## Test Results Primary target: - phase212_if_sum_min.hako: RC=2 achieved ✅ Regression tests: - loop_if_phi.hako: RC=2 (existing behavior maintained) ✅ - Pattern 1/2/3 tests: All PASS ✅ ## Architecture Pattern 3 now follows the same ExprResult Exit Contract as Pattern 2: 1. JoinIR lowerer creates expr_result with `with_expr_result()` 2. Boundary builder passes expr_result with `.with_expr_result()` 3. Conversion pipeline returns merge result containing exit PHI ValueId 4. Pattern dispatcher conditionally returns expr_result or Void This enables: - Expr-position loops: Loop result propagates to caller - Statement-position loops: Loop updates variable_map only (returns Void) - Unified contract: Patterns 2 and 3 follow same expr_result flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-10 01:40:18 +09:00
- **Exit / Boundary / ValueId ラインPhase 172205**
- ExitMeta / ExitLineReconnector / JoinInlineBoundary(+Builder) / LoopHeaderPhiBuilder を箱化。
- JoinValueSpaceParam/Local 領域)+ PHI 契約 Verifier で ValueId 衝突と PHI 破損を根治。
- **P5(Trim/JsonParser) ラインPhase 171176, 173175, 190193**
- LoopBodyLocal 昇格パイプラインTrim, `_skip_whitespace`, `_parse_string` 簡易版)を構築。
- StringAppend / NumberAccumulation / Complex addend 正規化など、更新式まわりの箱を揃えた。
- **P3/P4 (IfPHI / Continue) 汎用化ラインPhase 195196, 212215, 220242-EX**
- multicarrier P3 の JoinIR 生成を整理し、ifsum 最小パターンを AST ベースで一般化sum+count まで無改造対応)。
- Pattern3/4 ifsum/continue lowerer を分離箱にして、legacy PoC lowerer と by-name ハードコード(`"sum"`, `"count"`)を削除。
- Pattern4CarrierAnalyzer を純粋な「キャリア解析箱」として仕上げ、continue 正規化・更新式解析をユニットテストで固定。
feat(joinir): Phase 215-2 ExprResult exit contract for Pattern 3 Implements Phase 215 Task 215-2: Wire expr_result exit line through ExitMeta → JoinInlineBoundary → ExitLine → MIR return for Pattern 3. ## Changes ### Fix 1: JoinIR Lowerer (loop_with_if_phi_if_sum.rs:312) - Changed `carrier_only()` → `with_expr_result(sum_final, exit_meta)` - Marks sum final value as expr_result for propagation ### Fix 2: Boundary Builder (pattern3_with_if_phi.rs:176-191) - Added `.with_expr_result(Some(expr_id))` to JoinInlineBoundaryBuilder - Passes expr_result to boundary for ExitLineReconnector ### Fix 3: Final Return (pattern3_with_if_phi.rs:195-219) - Changed from always returning Void to conditional return: - Expr-position loops: Return merge_result ValueId - Statement-position loops: Return Void - Matches Pattern 2 behavior ## Test Results Primary target: - phase212_if_sum_min.hako: RC=2 achieved ✅ Regression tests: - loop_if_phi.hako: RC=2 (existing behavior maintained) ✅ - Pattern 1/2/3 tests: All PASS ✅ ## Architecture Pattern 3 now follows the same ExprResult Exit Contract as Pattern 2: 1. JoinIR lowerer creates expr_result with `with_expr_result()` 2. Boundary builder passes expr_result with `.with_expr_result()` 3. Conversion pipeline returns merge result containing exit PHI ValueId 4. Pattern dispatcher conditionally returns expr_result or Void This enables: - Expr-position loops: Loop result propagates to caller - Statement-position loops: Loop updates variable_map only (returns Void) - Unified contract: Patterns 2 and 3 follow same expr_result flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-10 01:40:18 +09:00
このあたりが「JoinIR ループ基盤の芯」で、以降の Phase は JsonParser/selfhost の各ループへの適用フェーズ、という位置づけだよ。
feat(llvm): Phase 134-A - mir_call.py unified 設計完成 681行の giant ファイルを機能別に分割し、箱化モジュール化を達成。 Changes: - NEW: src/llvm_py/mir_call_compat.py (120 lines) - JSON v0/v1 互換層を一元管理 - normalize_callee(), detect_format_version() - NEW: src/llvm_py/instructions/mir_call/ (7 files) - __init__.py: Canonical Dispatcher (lower_mir_call) - global_call.py: Global関数呼び出し (90 lines) - method_call.py: Boxメソッド呼び出し (175 lines) - constructor_call.py: Boxコンストラクタ (122 lines) - closure_call.py: Closure生成 (87 lines) - value_call.py: 動的関数値呼び出し (112 lines) - extern_call.py: 外部C ABI呼び出し (135 lines) - ARCHIVE: mir_call.py → mir_call_legacy.py Technical Achievements: ✅ mir_call.py: 681行 → 分割(各 80-175行、責務 明確) ✅ Phase 133 ConsoleLlvmBridge パターンを継承 ✅ NYASH_MIR_UNIFIED_CALL フラグ完全廃止 ✅ legacy dispatcher 削除(NotImplementedError 根治) ✅ JSON v0/v1 互換層を mir_call_compat.py に一元化 ✅ Fail-Fast 原則確立 ✅ テスト: 全 mir_call 関連テスト PASS Design Principles Inherited: - Phase 133 ConsoleLlvmBridge 箱化パターン継承 - Each module has clear responsibility - mir_call_compat.py で Phase 124+ v0削除が容易 - テスト分割で保守性大幅向上 Next Phase: Phase 134-B - StringBox bridge 分離(boxcall.py:130-282) Phase 134-C - CollectionBox bridge 分離(boxcall.py:325-375) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 12:06:34 +09:00
- **Phase 43/245B Normalized JoinIRPhase 2645 完了)** ✅
- Structured→Normalized→MIR(direct) パイプライン確立
- Mode system (JoinIrMode) + Capability system (ShapeCapabilityKind)
- Pattern1/2 + JsonParser (_skip_whitespace, _atoi, _parse_number) 全対応
- 詳細: [PHASE_43_245B_NORMALIZED_COMPLETION.md](docs/development/current/main/PHASE_43_245B_NORMALIZED_COMPLETION.md)
feat(llvm): Phase 134-A - mir_call.py unified 設計完成 681行の giant ファイルを機能別に分割し、箱化モジュール化を達成。 Changes: - NEW: src/llvm_py/mir_call_compat.py (120 lines) - JSON v0/v1 互換層を一元管理 - normalize_callee(), detect_format_version() - NEW: src/llvm_py/instructions/mir_call/ (7 files) - __init__.py: Canonical Dispatcher (lower_mir_call) - global_call.py: Global関数呼び出し (90 lines) - method_call.py: Boxメソッド呼び出し (175 lines) - constructor_call.py: Boxコンストラクタ (122 lines) - closure_call.py: Closure生成 (87 lines) - value_call.py: 動的関数値呼び出し (112 lines) - extern_call.py: 外部C ABI呼び出し (135 lines) - ARCHIVE: mir_call.py → mir_call_legacy.py Technical Achievements: ✅ mir_call.py: 681行 → 分割(各 80-175行、責務 明確) ✅ Phase 133 ConsoleLlvmBridge パターンを継承 ✅ NYASH_MIR_UNIFIED_CALL フラグ完全廃止 ✅ legacy dispatcher 削除(NotImplementedError 根治) ✅ JSON v0/v1 互換層を mir_call_compat.py に一元化 ✅ Fail-Fast 原則確立 ✅ テスト: 全 mir_call 関連テスト PASS Design Principles Inherited: - Phase 133 ConsoleLlvmBridge 箱化パターン継承 - Each module has clear responsibility - mir_call_compat.py で Phase 124+ v0削除が容易 - テスト分割で保守性大幅向上 Next Phase: Phase 134-B - StringBox bridge 分離(boxcall.py:130-282) Phase 134-C - CollectionBox bridge 分離(boxcall.py:325-375) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 12:06:34 +09:00
---
feat(joinir): Phase 215-2 ExprResult exit contract for Pattern 3 Implements Phase 215 Task 215-2: Wire expr_result exit line through ExitMeta → JoinInlineBoundary → ExitLine → MIR return for Pattern 3. ## Changes ### Fix 1: JoinIR Lowerer (loop_with_if_phi_if_sum.rs:312) - Changed `carrier_only()` → `with_expr_result(sum_final, exit_meta)` - Marks sum final value as expr_result for propagation ### Fix 2: Boundary Builder (pattern3_with_if_phi.rs:176-191) - Added `.with_expr_result(Some(expr_id))` to JoinInlineBoundaryBuilder - Passes expr_result to boundary for ExitLineReconnector ### Fix 3: Final Return (pattern3_with_if_phi.rs:195-219) - Changed from always returning Void to conditional return: - Expr-position loops: Return merge_result ValueId - Statement-position loops: Return Void - Matches Pattern 2 behavior ## Test Results Primary target: - phase212_if_sum_min.hako: RC=2 achieved ✅ Regression tests: - loop_if_phi.hako: RC=2 (existing behavior maintained) ✅ - Pattern 1/2/3 tests: All PASS ✅ ## Architecture Pattern 3 now follows the same ExprResult Exit Contract as Pattern 2: 1. JoinIR lowerer creates expr_result with `with_expr_result()` 2. Boundary builder passes expr_result with `.with_expr_result()` 3. Conversion pipeline returns merge result containing exit PHI ValueId 4. Pattern dispatcher conditionally returns expr_result or Void This enables: - Expr-position loops: Loop result propagates to caller - Statement-position loops: Loop updates variable_map only (returns Void) - Unified contract: Patterns 2 and 3 follow same expr_result flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-10 01:40:18 +09:00
## 🧭 これからの候補(まだ「やる」とは決めていないメモ)
ここは「やることリスト」ではなく「今後やるとしたらこの辺」というメモだよ。
実際に着手するタイミングで、別途 Phase/タスクを切る想定。
1. ~~Phase 245Bコード~~: ✅ 完了Phase 43/245B の一部)
2. ~~Phase 246-EXコード~~: ✅ 完了Phase 43/245B の一部)
docs(joinir): Phase 48 - Normalized P4 (Continue) design Complete design documentation for Pattern4 (continue) Normalized support, extending unified Normalized infrastructure to all 4 loop patterns. Design documents: - phase48-norm-p4-design.md: Complete P4 Normalized design (380 lines) - Key insight: continue = immediate TailCallFn(loop_step, ...) (no new instruction!) - Infrastructure reuse: 95%+ from P2/P3 (only ContinueCheck step kind new) - Target loops prioritized: - ◎ _parse_array (skip whitespace) - PRIMARY (Phase 48-A) - ○ _parse_object (skip whitespace) - Extended - △ _unescape_string, _parse_string - Later - Control flow: ContinueCheck before Updates (skip processing early) - Same EnvLayout/ConditionEnv/CarrierInfo/ExitLine as P2/P3 - Implementation strategy: dev-only → canonical (proven approach) Architecture: - Unified Normalized for P1/P2/P3/P4 (all patterns same pipeline) - P4 uses loop_step(env, k_exit) skeleton (same as P2/P3) - continue semantics: TailCallFn = skip to next iteration (CPS natural fit) Benefits: - 95% infrastructure reuse from P2/P3 - No new JpInst needed (continue = existing TailCallFn) - Incremental rollout (dev → canonical) - Clear semantic: continue = immediate recursion Implementation roadmap: - Phase 48-A: Minimal continue (dev-only) - Phase 48-B: Extended patterns (multi-carrier) - Phase 48-C: Canonical promotion Updates: - joinir-architecture-overview.md: Added Phase 48 section - CURRENT_TASK.md: Phase 48 entry (Design Complete) - phase47-norm-p3-design.md: Minor formatting Status: Design phase complete (doc-only, no implementation yet) Next: Phase 48-A implementation (when requested)
2025-12-12 06:06:39 +09:00
3. **Phase 47-NORM-P3設計完了最小devdirect✅ 2025-12-12**: Pattern3 Normalized 設計
docs(joinir): Phase 47 - Normalized P3 (If-Sum) design Complete design for extending Normalized JoinIR to Pattern3 (if-sum) loops, reusing 90% of existing P2 infrastructure. Key insight: P3 already uses P2's Structured JoinIR foundation (Phase 220 ConditionEnv integration), so Normalized extension is straightforward. Design documents: - phase47-norm-p3-design.md: Complete P3 Normalized design - Infrastructure reuse analysis (ConditionEnv, CarrierInfo, ExitLine) - Representative loops identified (phase212_if_sum_min primary target) - StepScheduleBox extension (IfCond, ThenUpdates, ElseUpdates) - JpInst reuse (If instruction already exists) - Implementation strategy (dev-only → canonical) - File impact estimate (~365 lines, pure additive) - phase47-test-files-inventory.md: P3 test file catalog - 3 P3 test files analyzed - phase212_if_sum_min.hako: Single carrier (PRIMARY) - phase217_if_sum_multi_min.hako: Multi-carrier (sum + count) - phase218_json_if_sum_min.hako: Variable accumulation (sum + i) Architecture: - Unified Normalized for P1/P2/P3 (same pipeline) - Conditional updates only difference vs P2 - No P2 code changes needed (pure additive) Benefits: - 90% infrastructure reuse from P2 - Proven incremental rollout (dev → canonical) - Clear path to P4 (continue pattern) Implementation roadmap: - Phase 47-A: Minimal sum_count (dev-only) - Phase 47-B: array_filter (body-local + method calls) - Phase 47-C: Canonical promotion Updates: - joinir-architecture-overview.md: Added Phase 47 section - CURRENT_TASK.md: Updated Phase 47 entry (Design Complete) Status: Design phase complete, ready for implementation
2025-12-12 04:50:26 +09:00
- 設計詳細: [phase47-norm-p3-design.md](docs/development/current/main/phase47-norm-p3-design.md)
- P3 if-sum を Normalized JoinIR に載せる設計。P2 と同じ ConditionEnv/CarrierInfo/ExitLine インフラを再利用。
docs(joinir): Phase 48 - Normalized P4 (Continue) design Complete design documentation for Pattern4 (continue) Normalized support, extending unified Normalized infrastructure to all 4 loop patterns. Design documents: - phase48-norm-p4-design.md: Complete P4 Normalized design (380 lines) - Key insight: continue = immediate TailCallFn(loop_step, ...) (no new instruction!) - Infrastructure reuse: 95%+ from P2/P3 (only ContinueCheck step kind new) - Target loops prioritized: - ◎ _parse_array (skip whitespace) - PRIMARY (Phase 48-A) - ○ _parse_object (skip whitespace) - Extended - △ _unescape_string, _parse_string - Later - Control flow: ContinueCheck before Updates (skip processing early) - Same EnvLayout/ConditionEnv/CarrierInfo/ExitLine as P2/P3 - Implementation strategy: dev-only → canonical (proven approach) Architecture: - Unified Normalized for P1/P2/P3/P4 (all patterns same pipeline) - P4 uses loop_step(env, k_exit) skeleton (same as P2/P3) - continue semantics: TailCallFn = skip to next iteration (CPS natural fit) Benefits: - 95% infrastructure reuse from P2/P3 - No new JpInst needed (continue = existing TailCallFn) - Incremental rollout (dev → canonical) - Clear semantic: continue = immediate recursion Implementation roadmap: - Phase 48-A: Minimal continue (dev-only) - Phase 48-B: Extended patterns (multi-carrier) - Phase 48-C: Canonical promotion Updates: - joinir-architecture-overview.md: Added Phase 48 section - CURRENT_TASK.md: Phase 48 entry (Design Complete) - phase47-norm-p3-design.md: Minor formatting Status: Design phase complete (doc-only, no implementation yet) Next: Phase 48-A implementation (when requested)
2025-12-12 06:06:39 +09:00
- Phase 47-A: Minimal sum_countdev-onlyとして、`phase212_if_sum_min.hako` 相当の最小 if-sum ループを AST ベース lowerer + Structured→Normalized→Structured roundtripRunner 経路)+ Normalized→MIR(direct) で検証済み。
- Phase 47-B 以降: array_filter など body-local/MethodCall を含む P3 ループや canonical 昇格は今後の実装フェーズで扱う。
feat(joinir): Phase 53 - SELFHOST-NORM-DEV-EXPAND implementation Expanded selfhost dev Normalized target with 2 practical P2/P3 loop variations, strengthened structural signature axis, and implemented two-stage detection. Key Changes: 1. Documentation (phase49-selfhost-joinir-depth2-design.md +128 lines): - Added Phase 53 section with candidate selection rationale - Documented two-stage detector strategy (structural primary + dev-only name guard) - Defined structural axis strengthening (carrier count/type, branch patterns) 2. Fixtures (+210 lines): - selfhost_args_parse_p2.program.json (60 lines): P2 with String carrier + conditional branching - selfhost_stmt_count_p3.program.json (150 lines): P3 with 5 carriers + multi-branch if-else 3. Structured Builders (fixtures.rs +48 lines): - build_selfhost_args_parse_p2_structured_for_normalized_dev() - build_selfhost_stmt_count_p3_structured_for_normalized_dev() 4. ShapeGuard Two-Stage Detection (shape_guard.rs +80 lines): - Added SelfhostArgsParseP2/SelfhostStmtCountP3 to NormalizedDevShape enum - Implemented is_selfhost_args_parse_p2(): P2 core family + name guard - Implemented is_selfhost_stmt_count_p3(): 2-10 carrier check + name guard - Updated capability_for_shape() mappings 5. Bridge Integration (bridge.rs +8 lines, normalized.rs +10 lines): - Added shape handlers delegating to existing normalizers - Added roundtrip reconstruction handlers 6. Entry Point Registration (ast_lowerer/mod.rs +2 lines): - Registered selfhost_args_parse_p2/selfhost_stmt_count_p3 as LoopFrontend routes 7. Dev VM Comparison Tests (normalized_joinir_min.rs +40 lines): - normalized_selfhost_args_parse_p2_vm_bridge_direct_matches_structured() - normalized_selfhost_stmt_count_p3_vm_bridge_direct_matches_structured() 8. Test Context Fix (dev_env.rs): - Added thread-local test context depth counter - Fixed deadlock in nested test_ctx() calls via reentrant with_dev_env_if_unset() Structural Axis Growth: P2 family: - Carrier count: 1-3 (unchanged) - NEW: Type diversity (Integer/String mixed) - NEW: Conditional branching patterns (Eq-heavy comparisons) P3 family: - NEW: Carrier count upper bound: 2-10 (was 2-4) - NEW: Multi-branch if-else (5+ branches with nested structure) - NEW: Complex conditional patterns Test Results: - normalized_dev: 40/40 PASS (including 2 new tests) - lib regression: 939 PASS, 56 ignored - Existing behavior unchanged (normalized_dev feature-gated) Phase 53 Achievements: ✅ P2/P3 each gained 1 practical variation (2 total) ✅ Two-stage detection: structural primary + dev-only name guard ✅ Structural axis expanded: 4 axes (carrier count/type/Compare/branch patterns) ✅ All tests PASS, no regressions ✅ Test context deadlock fixed (0.04s for 29 tests) Files Modified: 14 files Lines Added: ~516 lines (net) Implementation: Pure additive (feature-gated) Next Phase (54+): - Accumulate 6+ loops per P2/P3 family - Achieve 5+ stable structural axes - Target < 5% false positive rate - Then shrink/remove name guard scope
2025-12-12 16:40:20 +09:00
4. **Phase 48-NORM-P4設計完了✅48-A/B/C canon 完了✅ 2025-12-12→2026-01-XX**: Pattern4 (continue) Normalized 設計+実装
docs(joinir): Phase 48 - Normalized P4 (Continue) design Complete design documentation for Pattern4 (continue) Normalized support, extending unified Normalized infrastructure to all 4 loop patterns. Design documents: - phase48-norm-p4-design.md: Complete P4 Normalized design (380 lines) - Key insight: continue = immediate TailCallFn(loop_step, ...) (no new instruction!) - Infrastructure reuse: 95%+ from P2/P3 (only ContinueCheck step kind new) - Target loops prioritized: - ◎ _parse_array (skip whitespace) - PRIMARY (Phase 48-A) - ○ _parse_object (skip whitespace) - Extended - △ _unescape_string, _parse_string - Later - Control flow: ContinueCheck before Updates (skip processing early) - Same EnvLayout/ConditionEnv/CarrierInfo/ExitLine as P2/P3 - Implementation strategy: dev-only → canonical (proven approach) Architecture: - Unified Normalized for P1/P2/P3/P4 (all patterns same pipeline) - P4 uses loop_step(env, k_exit) skeleton (same as P2/P3) - continue semantics: TailCallFn = skip to next iteration (CPS natural fit) Benefits: - 95% infrastructure reuse from P2/P3 - No new JpInst needed (continue = existing TailCallFn) - Incremental rollout (dev → canonical) - Clear semantic: continue = immediate recursion Implementation roadmap: - Phase 48-A: Minimal continue (dev-only) - Phase 48-B: Extended patterns (multi-carrier) - Phase 48-C: Canonical promotion Updates: - joinir-architecture-overview.md: Added Phase 48 section - CURRENT_TASK.md: Phase 48 entry (Design Complete) - phase47-norm-p3-design.md: Minor formatting Status: Design phase complete (doc-only, no implementation yet) Next: Phase 48-A implementation (when requested)
2025-12-12 06:06:39 +09:00
- 設計詳細: [phase48-norm-p4-design.md](docs/development/current/main/phase48-norm-p4-design.md)
- ターゲットループ決定: _parse_array skip whitespace◎ PRIMARY、_parse_object、_unescape_string/parse_string
- 設計骨格: `continue` = 即座の `TailCallFn(loop_step, ...)` (新命令不要)
- P1/P2/P3 と同じ `loop_step(env, k_exit)` 骨格に載せる
- インフラ再利用率: 95%+ (StepKind の ContinueCheck のみ追加)
feat(joinir): Phase 53 - SELFHOST-NORM-DEV-EXPAND implementation Expanded selfhost dev Normalized target with 2 practical P2/P3 loop variations, strengthened structural signature axis, and implemented two-stage detection. Key Changes: 1. Documentation (phase49-selfhost-joinir-depth2-design.md +128 lines): - Added Phase 53 section with candidate selection rationale - Documented two-stage detector strategy (structural primary + dev-only name guard) - Defined structural axis strengthening (carrier count/type, branch patterns) 2. Fixtures (+210 lines): - selfhost_args_parse_p2.program.json (60 lines): P2 with String carrier + conditional branching - selfhost_stmt_count_p3.program.json (150 lines): P3 with 5 carriers + multi-branch if-else 3. Structured Builders (fixtures.rs +48 lines): - build_selfhost_args_parse_p2_structured_for_normalized_dev() - build_selfhost_stmt_count_p3_structured_for_normalized_dev() 4. ShapeGuard Two-Stage Detection (shape_guard.rs +80 lines): - Added SelfhostArgsParseP2/SelfhostStmtCountP3 to NormalizedDevShape enum - Implemented is_selfhost_args_parse_p2(): P2 core family + name guard - Implemented is_selfhost_stmt_count_p3(): 2-10 carrier check + name guard - Updated capability_for_shape() mappings 5. Bridge Integration (bridge.rs +8 lines, normalized.rs +10 lines): - Added shape handlers delegating to existing normalizers - Added roundtrip reconstruction handlers 6. Entry Point Registration (ast_lowerer/mod.rs +2 lines): - Registered selfhost_args_parse_p2/selfhost_stmt_count_p3 as LoopFrontend routes 7. Dev VM Comparison Tests (normalized_joinir_min.rs +40 lines): - normalized_selfhost_args_parse_p2_vm_bridge_direct_matches_structured() - normalized_selfhost_stmt_count_p3_vm_bridge_direct_matches_structured() 8. Test Context Fix (dev_env.rs): - Added thread-local test context depth counter - Fixed deadlock in nested test_ctx() calls via reentrant with_dev_env_if_unset() Structural Axis Growth: P2 family: - Carrier count: 1-3 (unchanged) - NEW: Type diversity (Integer/String mixed) - NEW: Conditional branching patterns (Eq-heavy comparisons) P3 family: - NEW: Carrier count upper bound: 2-10 (was 2-4) - NEW: Multi-branch if-else (5+ branches with nested structure) - NEW: Complex conditional patterns Test Results: - normalized_dev: 40/40 PASS (including 2 new tests) - lib regression: 939 PASS, 56 ignored - Existing behavior unchanged (normalized_dev feature-gated) Phase 53 Achievements: ✅ P2/P3 each gained 1 practical variation (2 total) ✅ Two-stage detection: structural primary + dev-only name guard ✅ Structural axis expanded: 4 axes (carrier count/type/Compare/branch patterns) ✅ All tests PASS, no regressions ✅ Test context deadlock fixed (0.04s for 29 tests) Files Modified: 14 files Lines Added: ~516 lines (net) Implementation: Pure additive (feature-gated) Next Phase (54+): - Accumulate 6+ loops per P2/P3 family - Achieve 5+ stable structural axes - Target < 5% false positive rate - Then shrink/remove name guard scope
2025-12-12 16:40:20 +09:00
- **Phase 48-A実装minimal dev-only完了✅** / **Phase 48-B devJsonParser skip_ws continue完了✅**:
- P4 minimal フィクスチャ追加skip i==2 パターン、単一 carrier `acc` JsonParser continue skip_ws (array/object) フィクスチャを追加
- ShapeGuard: Pattern4ContinueMinimal + JsonParser continue 形状を検出
feat(joinir): Phase 48-A - P4 (continue) Normalized minimal implementation Pattern4 (continue) integration into Normalized JoinIR pipeline complete. Key changes: - P4 minimal fixture: skip i==2 pattern, single carrier (acc) - ShapeGuard: Pattern4ContinueMinimal detector (structure-based) - StepScheduleBox: ContinueCheck step (eval order: HeaderCond → ContinueCheck → Updates → Tail) - normalize_pattern4_continue_minimal(): Delegates to P2 (95% infrastructure reuse) - Tests: 4 integration tests (normalization/runner/VM Bridge comparison×2) Design validation: - P4 (continue) = reverse control flow of P2 (break) - Same loop_step(env, k_exit) skeleton - Same EnvLayout/ConditionEnv/CarrierInfo infrastructure - Only difference: evaluation order and control flow direction Architecture proof: - Normalized JoinIR successfully handles P1/P2/P3/P4 uniformly - Infrastructure reuse rate: 95%+ as designed Tests: 939/939 PASS (+1 from baseline 938, target exceeded!) Files modified: 10 files (~305 lines added, pure additive) - pattern4_continue_min.program.json (NEW +126 lines) - P4 fixture - fixtures.rs (+31 lines) - P4 fixture loader - shape_guard.rs (+60 lines) - Shape detection - step_schedule.rs (+18 lines) - Schedule + test - normalized.rs (+35 lines) - Normalization function - loop_with_break_minimal.rs (+4 lines) - ContinueCheck handler - bridge.rs (+5 lines) - VM bridge routing - ast_lowerer/mod.rs (+2 lines) - Function registration - normalized_joinir_min.rs (+84 lines) - Integration tests - CURRENT_TASK.md (+13 lines) - Phase 48-A completion Next steps: - Phase 48-B: Extended P4 (multi-carrier, complex continue) - Phase 48-C: Canonical promotion (always use Normalized for P4)
2025-12-12 06:31:13 +09:00
- StepScheduleBox: ContinueCheck step 追加(評価順序: HeaderCond → ContinueCheck → Updates → Tail
feat(joinir): Phase 53 - SELFHOST-NORM-DEV-EXPAND implementation Expanded selfhost dev Normalized target with 2 practical P2/P3 loop variations, strengthened structural signature axis, and implemented two-stage detection. Key Changes: 1. Documentation (phase49-selfhost-joinir-depth2-design.md +128 lines): - Added Phase 53 section with candidate selection rationale - Documented two-stage detector strategy (structural primary + dev-only name guard) - Defined structural axis strengthening (carrier count/type, branch patterns) 2. Fixtures (+210 lines): - selfhost_args_parse_p2.program.json (60 lines): P2 with String carrier + conditional branching - selfhost_stmt_count_p3.program.json (150 lines): P3 with 5 carriers + multi-branch if-else 3. Structured Builders (fixtures.rs +48 lines): - build_selfhost_args_parse_p2_structured_for_normalized_dev() - build_selfhost_stmt_count_p3_structured_for_normalized_dev() 4. ShapeGuard Two-Stage Detection (shape_guard.rs +80 lines): - Added SelfhostArgsParseP2/SelfhostStmtCountP3 to NormalizedDevShape enum - Implemented is_selfhost_args_parse_p2(): P2 core family + name guard - Implemented is_selfhost_stmt_count_p3(): 2-10 carrier check + name guard - Updated capability_for_shape() mappings 5. Bridge Integration (bridge.rs +8 lines, normalized.rs +10 lines): - Added shape handlers delegating to existing normalizers - Added roundtrip reconstruction handlers 6. Entry Point Registration (ast_lowerer/mod.rs +2 lines): - Registered selfhost_args_parse_p2/selfhost_stmt_count_p3 as LoopFrontend routes 7. Dev VM Comparison Tests (normalized_joinir_min.rs +40 lines): - normalized_selfhost_args_parse_p2_vm_bridge_direct_matches_structured() - normalized_selfhost_stmt_count_p3_vm_bridge_direct_matches_structured() 8. Test Context Fix (dev_env.rs): - Added thread-local test context depth counter - Fixed deadlock in nested test_ctx() calls via reentrant with_dev_env_if_unset() Structural Axis Growth: P2 family: - Carrier count: 1-3 (unchanged) - NEW: Type diversity (Integer/String mixed) - NEW: Conditional branching patterns (Eq-heavy comparisons) P3 family: - NEW: Carrier count upper bound: 2-10 (was 2-4) - NEW: Multi-branch if-else (5+ branches with nested structure) - NEW: Complex conditional patterns Test Results: - normalized_dev: 40/40 PASS (including 2 new tests) - lib regression: 939 PASS, 56 ignored - Existing behavior unchanged (normalized_dev feature-gated) Phase 53 Achievements: ✅ P2/P3 each gained 1 practical variation (2 total) ✅ Two-stage detection: structural primary + dev-only name guard ✅ Structural axis expanded: 4 axes (carrier count/type/Compare/branch patterns) ✅ All tests PASS, no regressions ✅ Test context deadlock fixed (0.04s for 29 tests) Files Modified: 14 files Lines Added: ~516 lines (net) Implementation: Pure additive (feature-gated) Next Phase (54+): - Accumulate 6+ loops per P2/P3 family - Achieve 5+ stable structural axes - Target < 5% false positive rate - Then shrink/remove name guard scope
2025-12-12 16:40:20 +09:00
- normalize_pattern4_continue_minimal()/jsonparser_*continue* を dev 正規化に配線P2 インフラを再利用)
- テスト完備: minimal + JsonParser continue の VM bridge 比較を normalized_dev スイートで固定
- **Phase 48-Ccanonical 昇格)完了✅**:
- P4 minimal + JsonParser skip_ws array/object を canonical set に追加env OFF でも Normalized→MIR(direct) を強制)
- Bridge/runner で Structured fallback を禁止、fail-fast 契約に統一
- canonical ルートと Structured 直経路の stdout 一致を比較するテストを追加
docs(joinir): Phase 47 - Normalized P3 (If-Sum) design Complete design for extending Normalized JoinIR to Pattern3 (if-sum) loops, reusing 90% of existing P2 infrastructure. Key insight: P3 already uses P2's Structured JoinIR foundation (Phase 220 ConditionEnv integration), so Normalized extension is straightforward. Design documents: - phase47-norm-p3-design.md: Complete P3 Normalized design - Infrastructure reuse analysis (ConditionEnv, CarrierInfo, ExitLine) - Representative loops identified (phase212_if_sum_min primary target) - StepScheduleBox extension (IfCond, ThenUpdates, ElseUpdates) - JpInst reuse (If instruction already exists) - Implementation strategy (dev-only → canonical) - File impact estimate (~365 lines, pure additive) - phase47-test-files-inventory.md: P3 test file catalog - 3 P3 test files analyzed - phase212_if_sum_min.hako: Single carrier (PRIMARY) - phase217_if_sum_multi_min.hako: Multi-carrier (sum + count) - phase218_json_if_sum_min.hako: Variable accumulation (sum + i) Architecture: - Unified Normalized for P1/P2/P3 (same pipeline) - Conditional updates only difference vs P2 - No P2 code changes needed (pure additive) Benefits: - 90% infrastructure reuse from P2 - Proven incremental rollout (dev → canonical) - Clear path to P4 (continue pattern) Implementation roadmap: - Phase 47-A: Minimal sum_count (dev-only) - Phase 47-B: array_filter (body-local + method calls) - Phase 47-C: Canonical promotion Updates: - joinir-architecture-overview.md: Added Phase 47 section - CURRENT_TASK.md: Updated Phase 47 entry (Design Complete) Status: Design phase complete, ready for implementation
2025-12-12 04:50:26 +09:00
5. JsonParser 残りループへの JoinIR 展開
feat(joinir): Phase 215-2 ExprResult exit contract for Pattern 3 Implements Phase 215 Task 215-2: Wire expr_result exit line through ExitMeta → JoinInlineBoundary → ExitLine → MIR return for Pattern 3. ## Changes ### Fix 1: JoinIR Lowerer (loop_with_if_phi_if_sum.rs:312) - Changed `carrier_only()` → `with_expr_result(sum_final, exit_meta)` - Marks sum final value as expr_result for propagation ### Fix 2: Boundary Builder (pattern3_with_if_phi.rs:176-191) - Added `.with_expr_result(Some(expr_id))` to JoinInlineBoundaryBuilder - Passes expr_result to boundary for ExitLineReconnector ### Fix 3: Final Return (pattern3_with_if_phi.rs:195-219) - Changed from always returning Void to conditional return: - Expr-position loops: Return merge_result ValueId - Statement-position loops: Return Void - Matches Pattern 2 behavior ## Test Results Primary target: - phase212_if_sum_min.hako: RC=2 achieved ✅ Regression tests: - loop_if_phi.hako: RC=2 (existing behavior maintained) ✅ - Pattern 1/2/3 tests: All PASS ✅ ## Architecture Pattern 3 now follows the same ExprResult Exit Contract as Pattern 2: 1. JoinIR lowerer creates expr_result with `with_expr_result()` 2. Boundary builder passes expr_result with `.with_expr_result()` 3. Conversion pipeline returns merge result containing exit PHI ValueId 4. Pattern dispatcher conditionally returns expr_result or Void This enables: - Expr-position loops: Loop result propagates to caller - Statement-position loops: Loop updates variable_map only (returns Void) - Unified contract: Patterns 2 and 3 follow same expr_result flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-10 01:40:18 +09:00
- `_parse_array` / `_parse_object` / `_unescape_string` / 本体 `_parse_string` など。
- 既存の P2/P3/P4P5 パイプラインをどこまで延ばせるかを docs 側で設計 → コード側はその設計に沿って小さく実装。
feat(joinir): Phase 53 - SELFHOST-NORM-DEV-EXPAND implementation Expanded selfhost dev Normalized target with 2 practical P2/P3 loop variations, strengthened structural signature axis, and implemented two-stage detection. Key Changes: 1. Documentation (phase49-selfhost-joinir-depth2-design.md +128 lines): - Added Phase 53 section with candidate selection rationale - Documented two-stage detector strategy (structural primary + dev-only name guard) - Defined structural axis strengthening (carrier count/type, branch patterns) 2. Fixtures (+210 lines): - selfhost_args_parse_p2.program.json (60 lines): P2 with String carrier + conditional branching - selfhost_stmt_count_p3.program.json (150 lines): P3 with 5 carriers + multi-branch if-else 3. Structured Builders (fixtures.rs +48 lines): - build_selfhost_args_parse_p2_structured_for_normalized_dev() - build_selfhost_stmt_count_p3_structured_for_normalized_dev() 4. ShapeGuard Two-Stage Detection (shape_guard.rs +80 lines): - Added SelfhostArgsParseP2/SelfhostStmtCountP3 to NormalizedDevShape enum - Implemented is_selfhost_args_parse_p2(): P2 core family + name guard - Implemented is_selfhost_stmt_count_p3(): 2-10 carrier check + name guard - Updated capability_for_shape() mappings 5. Bridge Integration (bridge.rs +8 lines, normalized.rs +10 lines): - Added shape handlers delegating to existing normalizers - Added roundtrip reconstruction handlers 6. Entry Point Registration (ast_lowerer/mod.rs +2 lines): - Registered selfhost_args_parse_p2/selfhost_stmt_count_p3 as LoopFrontend routes 7. Dev VM Comparison Tests (normalized_joinir_min.rs +40 lines): - normalized_selfhost_args_parse_p2_vm_bridge_direct_matches_structured() - normalized_selfhost_stmt_count_p3_vm_bridge_direct_matches_structured() 8. Test Context Fix (dev_env.rs): - Added thread-local test context depth counter - Fixed deadlock in nested test_ctx() calls via reentrant with_dev_env_if_unset() Structural Axis Growth: P2 family: - Carrier count: 1-3 (unchanged) - NEW: Type diversity (Integer/String mixed) - NEW: Conditional branching patterns (Eq-heavy comparisons) P3 family: - NEW: Carrier count upper bound: 2-10 (was 2-4) - NEW: Multi-branch if-else (5+ branches with nested structure) - NEW: Complex conditional patterns Test Results: - normalized_dev: 40/40 PASS (including 2 new tests) - lib regression: 939 PASS, 56 ignored - Existing behavior unchanged (normalized_dev feature-gated) Phase 53 Achievements: ✅ P2/P3 each gained 1 practical variation (2 total) ✅ Two-stage detection: structural primary + dev-only name guard ✅ Structural axis expanded: 4 axes (carrier count/type/Compare/branch patterns) ✅ All tests PASS, no regressions ✅ Test context deadlock fixed (0.04s for 29 tests) Files Modified: 14 files Lines Added: ~516 lines (net) Implementation: Pure additive (feature-gated) Next Phase (54+): - Accumulate 6+ loops per P2/P3 family - Achieve 5+ stable structural axes - Target < 5% false positive rate - Then shrink/remove name guard scope
2025-12-12 16:40:20 +09:00
6. **Phase 49-SELFHOST-NORM-DEPTH2設計・コードなし**: selfhost depth2 Normalized 設計フェーズ
- 設計詳細: [phase49-selfhost-joinir-depth2-design.md](docs/development/current/main/phase49-selfhost-joinir-depth2-design.md)
7. **Phase 50-SELFHOST-NORM-DEVdev-only完了✅ 2025-12-12**: selfhost 軽量 P2/P3 を dev Normalized パイプラインに載せる足慣らし
- 対象: `selfhost_token_scan_p2` / `selfhost_if_sum_p3`
- fixtures / ShapeGuard(Selfhost* 系) / VM bridge 比較テストまで整備し、Structured 直経路と一致を固定。
8. **Phase 51-SELFHOST-NORM-DEV-EXTENDdev-only完了✅ 2025-12-12**: selfhost 実戦寄り P2/P3 を dev Normalized に追加
- 対象: `selfhost_token_scan_p2_accum` / `selfhost_if_sum_p3_ext`
- Phase 50 と同導線で fixtures / shape / 比較テストを追加し、selfhost 断面で緑を維持。
9. **Phase 52-SELFHOST-SHAPE-STRUCT-SIGNATUREdev-only完了✅ 2025-12-12**: selfhost shape の構造シグネチャ育成
- selfhost P2/P3 を「構造一次判定→dev-only name ガード最終確定」の二段 detector に移行。
- 構造シグネチャの安定テストを追加し、name ガード撤去の足場を SSOT に固定。
10. **Phase 53-SELFHOST-NORM-DEV-EXPANDdev-only完了✅ 2025-12-12**: selfhost P2/P3 の実戦寄り形状を追加
- 対象追加: P2 `args_parse_p2` / P3 `stmt_count_p3`
- 構造一次判定carrier 数/型/Compare/branch→ dev-only name 最終確定の二段 detector を拡張。
- P3 carrier 上限を 210 に拡大し、複雑 if-else 形状を selfhost 群として取り込んだ。
- `normalized_dev` selfhost 断面/回帰テストが緑、既定挙動は不変。
feat(joinir): Phase 54 SELFHOST-SHAPE-GROWTH - 構造軸育成 + 偽陽性観測 Phase 53 成果を踏まえ、構造シグネチャ軸を 5+ に育て、 偽陽性観測テストで name ガード縮小準備を整えた。 方針変更: 新ループ追加 → 構造軸育成 + 偽陽性率測定に焦点変更 - 理由: Phase 53 で selfhost P2/P3 実戦パターン追加済み - 焦点: 既存ループに対する構造軸拡張 + 精度測定 主な成果: 1. 構造軸 5+ 達成: - carrier 数 - carrier 型 - Compare パターン - branch 構造 - NEW: Compare op 分布 (count_compare_ops ヘルパー) 2. 偽陽性観測テスト追加: - test_phase54_structural_axis_discrimination_p2() - test_phase54_structural_axis_discrimination_p3() 3. 重要な発見 - 偽陽性率 ~50%: - P2: selfhost P2 が正しく検出されず (name ガード依存) - P3: selfhost P3 が Pattern4ContinueMinimal と誤検出 (構造的類似性) - 結論: 構造判定のみでは分離不十分、name ガード必須と判明 変更内容: - shape_guard.rs (+80 lines): - count_compare_ops() 構造軸ヘルパー追加 - detect_shapes() pub 化 (テストから呼び出し可能に) - SelfhostVerifySchemaP2/SelfhostDetectFormatP3 enum 追加 (将来用) - normalized_joinir_min.rs (+110 lines): - 偽陽性観測テスト 2 個追加 (P2/P3 各1) - canonical shapes vs selfhost shapes 構造判定精度測定 - phase49 doc (+200 lines): - Phase 54 節完成版 - 偽陽性分析結果記録 - name ガード縮小方針明記 - enum 拡張対応: - bridge.rs (+8 lines) - normalized.rs (+8 lines) - ast_lowerer/mod.rs (+2 lines) 偽陽性観測結果 (2025-12-12): - P2 構造判定: selfhost P2 検出失敗 → name ガード必須 - P3 構造判定: selfhost P3 が Pattern4 と誤判定 → 構造的類似性問題 - 総合: 偽陽性率 ~50% → 構造軸 5 本では不十分 次フェーズ方針 (Phase 55+): - Phase 55-A: 条件複雑度軸追加 (BinOp/UnaryOp ネスト深度) - Phase 55-B: 算術パターン軸追加 (Mul/Sub/Div 出現パターン) - Phase 56: selfhost 実戦ループ追加 (6 本以上蓄積) - Phase 57: 誤判定率 < 5% 達成後に name ガード縮小開始 name ガード撤去条件 (Phase 57): - 構造軸 8+ 本確立 - selfhost P2/P3 各 6 本以上蓄積 - 誤判定率 < 5% 達成 - 複合的特徴量ベース判定実装 回帰テスト: ✅ 939 PASS, 0 FAIL (既存挙動不変) Files Modified: 8 files Lines Added: ~408 lines (net) Implementation: Pure additive (feature-gated) Phase 54 完了!構造軸育成・偽陽性観測基盤確立!
2025-12-12 17:12:58 +09:00
11. **Phase 54-SELFHOST-SHAPE-GROWTHdev-only完了✅ 2025-12-12**: 構造軸の育成と偽陽性観測フェーズ
- Phase 53 で実戦ループ追加済みのため、追加投入より先に構造判定精度の測定に集中。
- 構造シグネチャ軸を 5+ に拡張Compare op 分布などし、P2/P3 の偽陽性観測テストを追加。
- 結果: selfhost 群の構造判定だけでは分離が不十分(偽陽性率 ~50%。dev-only name ガードは当面必須と判断。
12. **Phase 55-SELFHOST-SHAPE-AXIS-EXPANDdev-only / 保留)**: 構造軸を可変 feature として拡張し誤判定を下げる足場
- Phase 5661 の Ownership-Relay ライン優先のため、selfhost shape 軸拡張は一旦保留。
- OwnershipAnalyzer 導入後に、scope 署名owned/carriers/captures/relayを新しい構造軸として合流させる。
13. **Phase 56-OWNERSHIP-RELAY-DESIGN完了✅ 2025-12-12**: Ownership-Relay アーキテクチャ設計 + インターフェース skeleton
- 設計詳細: [phase56-ownership-relay-design.md](docs/development/current/main/phase56-ownership-relay-design.md)
- コア定義: owned / carriers / captures / relay の 4 分類を明確化
- 不変条件: Ownership Uniqueness / Carrier Locality / Relay Propagation / Capture Read-Only
- Module 作成: `src/mir/join_ir/ownership/` - 責務は「解析のみ」
- 型定義: `ScopeId`, `ScopeOwnedVar`, `RelayVar`, `CapturedVar`, `OwnershipPlan`
- テスト: 3 つのユニットテスト追加empty plan / carriers filter / invariant verification
- 次: Phase 57 で OwnershipAnalyzer 実装dev-only
14. **Phase 57-OWNERSHIP-ANALYZER-DEV完了✅ 2025-12-12**: OwnershipPlan を生成する解析箱の実装
- `OwnershipAnalyzer` を追加し、ネスト含む reads/writes/owned を集計→ carriers/relay/captures を plan 化。
- 既存 fixturespattern2/3, jsonparser, selfhostで plan の回帰テストを追加。
- 設計詳細: [PHASE_57_SUMMARY.md](docs/development/current/main/PHASE_57_SUMMARY.md)
15. **Phase 58-OWNERSHIP-PLUMB-P2-DEV完了✅ 2025-12-12**: P2 conversion helper (dev-only)
- `plan_to_p2_inputs()` でOwnershipPlan→P2LoweringInputs変換
- Fail-Fast: relay_writes 未対応Phase 60で対応予定
- 5つのユニットテスト + 1つのintegrationテスト
- 設計詳細: [PHASE_58_SUMMARY.md](docs/development/current/main/PHASE_58_SUMMARY.md)
16. **Phase 59-OWNERSHIP-PLUMB-P3-DEV完了✅ 2025-12-12**: P3 conversion helper (dev-only)
- `plan_to_p3_inputs()` でOwnershipPlan→P3LoweringInputs変換P2と同構造
- Multi-carrier対応sum, count, 5+ carriers
- Fail-Fast: relay_writes 未対応Phase 60で対応予定
- 4つのユニットテスト + 2つのintegrationテスト
- 設計詳細: [PHASE_59_SUMMARY.md](docs/development/current/main/PHASE_59_SUMMARY.md)
17. **Phase 60-OWNERSHIP-RELAY-IMPL完了✅ 2025-12-12**: Relay support for P2/P3 (dev-only)
- `plan_to_p2_inputs_with_relay()` / `plan_to_p3_inputs_with_relay()` を追加単一hopのみ許可、multi-hopはFail-Fast
- P2 Break lowering を dev-only で ownership-with-relay に接続し、legacy 経路との VM 出力一致を比較テストで固定。
- shape_guard の selfhost family 分離を最小更新selfhost shapes 優先時の混線を遮断)。
18. **Phase 61-IFSUM-BREAK-STRUCTURAL完了✅ 2025-12-12**: if-sum + break を別箱で構造的に導入dev-only
- Break(P2) から P3 固有ロジックby-nameを撤去し、責務混線を解消。
- 新箱 `if_sum_break_pattern` を追加し、`return Var+Var` を含む if-sum+break を構造判定→Fail-Fast で lowering。
- OwnershipPlan を param order/carriers の SSOT に使い、carriers!=return vars の混線を遮断。
- 詳細: [PHASE_61_SUMMARY.md](docs/development/current/main/PHASE_61_SUMMARY.md)
19. **Phase 62-OWNERSHIP-P3-ROUTE-DESIGN次のフォーカス候補**: P3 本番ルートへ OwnershipPlan を渡す設計
- MIR→JoinIR の `pattern3_with_if_phi.rs` は OwnershipPlan を受け取らないため、AST-based ownership 解析の接続点を設計する。
- dev-only で段階接続し、legacy と stdout/exit 一致の比較で回帰を固定(既定挙動は不変)。
- 設計詳細: [phase62-ownership-p3-route-design.md](docs/development/current/main/phase62-ownership-p3-route-design.md)
20. **Phase 63-OWNERSHIP-AST-ANALYZER完了✅ 2025-12-12**: 本番 AST から OwnershipPlan を生成dev-only
- `AstOwnershipAnalyzer` を追加し、ASTNode から owned/relay/capture を plan 化analysis-only
- JSON v0 の “Local=rebind” ハックを排除fixture 専用のまま)。
- 詳細: [PHASE_63_SUMMARY.md](docs/development/current/main/PHASE_63_SUMMARY.md)
21. **Phase 64-OWNERSHIP-P3-PROD-PLUMB次のフォーカス候補**: 本番 P3(if-sum) ルートへ段階接続dev-only
- `pattern3_with_if_phi.rs` で OwnershipPlan を導入し、carrier set/inputs を SSOT 化するorder は exit_meta と整合チェックで段階移行)。
- Fail-Fast: multi-hop relay / carrier set 不一致 / owner 不在 write を拒否。
22. JoinIR Verify / 最適化まわり
feat(joinir): Phase 215-2 ExprResult exit contract for Pattern 3 Implements Phase 215 Task 215-2: Wire expr_result exit line through ExitMeta → JoinInlineBoundary → ExitLine → MIR return for Pattern 3. ## Changes ### Fix 1: JoinIR Lowerer (loop_with_if_phi_if_sum.rs:312) - Changed `carrier_only()` → `with_expr_result(sum_final, exit_meta)` - Marks sum final value as expr_result for propagation ### Fix 2: Boundary Builder (pattern3_with_if_phi.rs:176-191) - Added `.with_expr_result(Some(expr_id))` to JoinInlineBoundaryBuilder - Passes expr_result to boundary for ExitLineReconnector ### Fix 3: Final Return (pattern3_with_if_phi.rs:195-219) - Changed from always returning Void to conditional return: - Expr-position loops: Return merge_result ValueId - Statement-position loops: Return Void - Matches Pattern 2 behavior ## Test Results Primary target: - phase212_if_sum_min.hako: RC=2 achieved ✅ Regression tests: - loop_if_phi.hako: RC=2 (existing behavior maintained) ✅ - Pattern 1/2/3 tests: All PASS ✅ ## Architecture Pattern 3 now follows the same ExprResult Exit Contract as Pattern 2: 1. JoinIR lowerer creates expr_result with `with_expr_result()` 2. Boundary builder passes expr_result with `.with_expr_result()` 3. Conversion pipeline returns merge result containing exit PHI ValueId 4. Pattern dispatcher conditionally returns expr_result or Void This enables: - Expr-position loops: Loop result propagates to caller - Statement-position loops: Loop updates variable_map only (returns Void) - Unified contract: Patterns 2 and 3 follow same expr_result flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-10 01:40:18 +09:00
- すでに PHI/ValueId 契約は debug ビルドで検証しているので、
必要なら SSADFA や軽い最適化Loop invariant / Strength reductionを検討。
---
docs(phase170-d): Phase 170-D-impl-4 Completion - Tests and Documentation ## Summary Completed Phase 170-D-impl-4: Comprehensive documentation and test verification for LoopConditionScopeBox infrastructure. All four implementation phases (1-4) now complete with full modular Box-based architecture and thorough test coverage. ## Changes ### New Documentation - **phase170-d-impl-design.md** (1,356 lines): Comprehensive design document - Architecture overview and modular components - Detailed implementation summary for all 4 phases - Test results and verification procedures - Architecture decisions (Box Theory, Fail-Fast, Conservative Classification) - Future work for Phase 170-D-E and Phase 171+ ### Updated Documentation - **CURRENT_TASK.md**: Added Phase 170-D completion section - Full status overview - Completed work breakdown - Test verification results - Commit history - Architecture summary ## Implementation Status ### Phase 170-D-impl Complete Summary **Phase 170-D-impl-1** ✅ - LoopConditionScopeBox skeleton (220 lines) - CondVarScope enum and data structures - Public API design **Phase 170-D-impl-2** ✅ - Minimal analysis logic (317 lines) - Pure functions: extract_all_variables, is_outer_scope_variable - 12 comprehensive unit tests **Phase 170-D-impl-3** ✅ - Pattern 2/4 integration - Fail-Fast validation checks - 4 integration tests in loop_with_break_minimal.rs **Phase 170-D-impl-4** ✅ - Design documentation - Test verification and results - Architecture guide ### Module Structure ``` src/mir/loop_pattern_detection/ ├── mod.rs (201 lines) ├── loop_condition_scope.rs (220 lines) └── condition_var_analyzer.rs (317 lines) Total: 738 lines ``` ### Test Results ✅ Unit Tests: 16 total (12 in condition_var_analyzer + 4 in loop_with_break_minimal) ✅ Integration Tests: 2 verified (Pattern 2 accept/reject cases) ✅ Build: cargo build --release (0 errors, 50 warnings) ✅ Verification: NYASH_JOINIR_STRUCTURE_ONLY=1 tests pass ## Architecture Highlights - **Box Theory**: Clear separation of LoopConditionScopeBox (orchestration) and condition_var_analyzer (pure functions) - **Fail-Fast**: Early error detection before JoinIR generation - **Conservative Classification**: Defaults to LoopBodyLocal for unknown variables - **Reusable**: Pure functions independent and composition-friendly ## Future Work Phase 170-D-E: Advanced Patterns (Pattern 5+) - Support loop-body-local variables in conditions - Expanded scope heuristics - Selective pattern detection Phase 171: Condition Environment Integration - Tighter coupling with condition_to_joinir - Enhanced variable mapping 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:43:08 +09:00
feat(joinir): Phase 215-2 ExprResult exit contract for Pattern 3 Implements Phase 215 Task 215-2: Wire expr_result exit line through ExitMeta → JoinInlineBoundary → ExitLine → MIR return for Pattern 3. ## Changes ### Fix 1: JoinIR Lowerer (loop_with_if_phi_if_sum.rs:312) - Changed `carrier_only()` → `with_expr_result(sum_final, exit_meta)` - Marks sum final value as expr_result for propagation ### Fix 2: Boundary Builder (pattern3_with_if_phi.rs:176-191) - Added `.with_expr_result(Some(expr_id))` to JoinInlineBoundaryBuilder - Passes expr_result to boundary for ExitLineReconnector ### Fix 3: Final Return (pattern3_with_if_phi.rs:195-219) - Changed from always returning Void to conditional return: - Expr-position loops: Return merge_result ValueId - Statement-position loops: Return Void - Matches Pattern 2 behavior ## Test Results Primary target: - phase212_if_sum_min.hako: RC=2 achieved ✅ Regression tests: - loop_if_phi.hako: RC=2 (existing behavior maintained) ✅ - Pattern 1/2/3 tests: All PASS ✅ ## Architecture Pattern 3 now follows the same ExprResult Exit Contract as Pattern 2: 1. JoinIR lowerer creates expr_result with `with_expr_result()` 2. Boundary builder passes expr_result with `.with_expr_result()` 3. Conversion pipeline returns merge result containing exit PHI ValueId 4. Pattern dispatcher conditionally returns expr_result or Void This enables: - Expr-position loops: Loop result propagates to caller - Statement-position loops: Loop updates variable_map only (returns Void) - Unified contract: Patterns 2 and 3 follow same expr_result flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-10 01:40:18 +09:00
## 📎 このファイルの運用ルール(自分向けメモ)
- 過去フェーズの詳細な ToDo/Done リストは **CURRENT_TASK には書かない**
代わりに `docs/development/current/main/phase-*.md``joinir-architecture-overview.md` を SSOT として維持する。
feat(joinir): Phase 215-2 ExprResult exit contract for Pattern 3 Implements Phase 215 Task 215-2: Wire expr_result exit line through ExitMeta → JoinInlineBoundary → ExitLine → MIR return for Pattern 3. ## Changes ### Fix 1: JoinIR Lowerer (loop_with_if_phi_if_sum.rs:312) - Changed `carrier_only()` → `with_expr_result(sum_final, exit_meta)` - Marks sum final value as expr_result for propagation ### Fix 2: Boundary Builder (pattern3_with_if_phi.rs:176-191) - Added `.with_expr_result(Some(expr_id))` to JoinInlineBoundaryBuilder - Passes expr_result to boundary for ExitLineReconnector ### Fix 3: Final Return (pattern3_with_if_phi.rs:195-219) - Changed from always returning Void to conditional return: - Expr-position loops: Return merge_result ValueId - Statement-position loops: Return Void - Matches Pattern 2 behavior ## Test Results Primary target: - phase212_if_sum_min.hako: RC=2 achieved ✅ Regression tests: - loop_if_phi.hako: RC=2 (existing behavior maintained) ✅ - Pattern 1/2/3 tests: All PASS ✅ ## Architecture Pattern 3 now follows the same ExprResult Exit Contract as Pattern 2: 1. JoinIR lowerer creates expr_result with `with_expr_result()` 2. Boundary builder passes expr_result with `.with_expr_result()` 3. Conversion pipeline returns merge result containing exit PHI ValueId 4. Pattern dispatcher conditionally returns expr_result or Void This enables: - Expr-position loops: Loop result propagates to caller - Statement-position loops: Loop updates variable_map only (returns Void) - Unified contract: Patterns 2 and 3 follow same expr_result flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-10 01:40:18 +09:00
- CURRENT_TASK は「あくまで最新のフォーカスと次の候補だけ」に絞る。
目安として **このファイル自体は 2〜3画面程度〜300行以内** に収める。
- 新しい大フェーズを始めたら:
1. まず docs 配下に `phase-XXX-*.md` を書く。
2. CURRENT_TASK には「そのフェーズの一行要約」と「今のフォーカスかどうか」だけを書く。