18d56d5b88
refactor(joinir): Box-First cleanup - trace unification + SSOT + Fail-Fast
...
## Changes
### 1. eprintln! to trace.rs unification
**File**: src/mir/builder/control_flow/joinir/routing.rs
- Replaced direct eprintln! with trace::trace().routing()
- Box-First principle: Log responsibility centralized in trace.rs
- Enables filtering via HAKO_JOINIR_DEBUG=1
### 2. Priority field removal (SSOT)
**File**: src/mir/builder/control_flow/joinir/patterns/router.rs
- Removed #[allow(dead_code)] priority field
- Array order is SSOT (Single Source of Truth) for pattern priority
- Pattern try order: Pattern5 → Pattern4 → Pattern3 → Pattern1 → Pattern2
- Eliminated dead code warning
### 3. catch_unwind removal (Fail-Fast)
**File**: src/mir/builder/control_flow/joinir/routing_legacy_binding.rs
- Removed catch_unwind + Ok(None) silent error swallowing
- Fail-Fast principle: Panics propagate explicitly
- Enables early detection of panic sources
## Verification
✅ Build: cargo build --release (0 errors)
✅ Tests: 71 JoinIR tests all PASS
✅ VM: /tmp/p1_return_i.hako → Result: 3
✅ LLVM: /tmp/p1_return_i.hako → Mock exit code: 0
## Design Principles Applied
- **Box-First**: Log responsibility → trace.rs
- **SSOT**: Array order defines priority (no redundant field)
- **Fail-Fast**: Explicit failures, no silent error swallowing
## Statistics
- 3 files changed
- 53 deletions, 28 insertions
- Net: -25 lines (code reduction)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-15 03:27:47 +09:00
447d4ea246
feat(llvm): Phase 132 - Pattern 1 exit value parity fix + Box-First refactoring
...
## Phase 132: Exit PHI Value Parity Fix
### Problem
Pattern 1 (Simple While) returned 0 instead of final loop variable value (3)
- VM: RC: 3 ✅ (correct)
- LLVM: Result: 0 ❌ (wrong)
### Root Cause (Two Layers)
1. **JoinIR/Boundary**: Missing exit_bindings → ExitLineReconnector not firing
2. **LLVM Python**: block_end_values snapshot dropping PHI values
### Fix
**JoinIR** (simple_while_minimal.rs):
- Jump(k_exit, [i_param]) passes exit value
**Boundary** (pattern1_minimal.rs):
- Added LoopExitBinding with carrier_name="i", role=LoopState
- Enables ExitLineReconnector to update variable_map
**LLVM** (block_lower.py):
- Use predeclared_ret_phis for reliable PHI filtering
- Protect builder.vmap PHIs from overwrites (SSOT principle)
### Result
- ✅ VM: RC: 3
- ✅ LLVM: Result: 3
- ✅ VM/LLVM parity achieved
## Phase 132-Post: Box-First Refactoring
### Rust Side
**JoinModule::require_function()** (mod.rs):
- Encapsulate function search logic
- 10 lines → 1 line (90% reduction)
- Reusable for Pattern 2-5
### Python Side
**PhiManager Box** (phi_manager.py - new):
- Centralized PHI lifecycle management
- 47 lines → 8 lines (83% reduction)
- SSOT: builder.vmap owns PHIs
- Fail-Fast: No silent overwrites
**Integration**:
- LLVMBuilder: Added phi_manager
- block_lower.py: Delegated to PhiManager
- tagging.py: Register PHIs with manager
### Documentation
**New Files**:
- docs/development/architecture/exit-phi-design.md
- docs/development/current/main/investigations/phase132-llvm-exit-phi-wrong-result.md
- docs/development/current/main/phases/phase-132/
**Updated**:
- docs/development/current/main/10-Now.md
- docs/development/current/main/phase131-3-llvm-lowering-inventory.md
### Design Principles
- Box-First: Logic encapsulated in classes/methods
- SSOT: Single Source of Truth (builder.vmap for PHIs)
- Fail-Fast: Early explicit failures, no fallbacks
- Separation of Concerns: 3-layer architecture
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-15 03:17:31 +09:00
a955dd6b18
feat(llvm): Phase 131-15 - print/concat segfault 根治修正
...
## P1-1/P1-2: TypeFacts 優先化
- binop.py: operand facts が dst_type ヒントより優先
- mir_json_emit.rs: Unknown 時に dst_type を出さない
- function_lower.py: value_types を metadata から読み込み
## P2: handle concat 統一(根治)
- print シグネチャ修正: i64(i64) → void(i8*)
- Mixed concat を handle ベースに統一:
- concat_si/concat_is → concat_hh
- box.from_i64 で integer を handle 化
- Everything is Box 哲学に統一
- legacy 関数は互換性のために保持
## 結果
- ✅ print("Result: " + 3) → Result: 3
- ✅ segfault 解消
- ✅ Everything is Box 統一
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-15 01:36:34 +09:00
7f57a1bb05
feat(llvm): Phase 131-13/14 - MIR JSON順序修正 & 2パスsnapshot解決
...
## Phase 131-13: MIR JSON 命令順序修正
- copy 遅延ロジック削除(~80行)
- MIR の def→use 順序をそのまま出力(SSOT)
- PHI 先頭集約のみ維持
## Phase 131-14: jump-only block 2パス snapshot 解決
- Pass A: jump-only block はメタ記録のみ
- Pass B: resolve_jump_only_snapshots() で CFG ベース解決
- path compression で連鎖を効率的に解決
- サイクル検出で Fail-Fast
## 結果
- ✅ STRICT モードでエラーなし
- ✅ bb7 が bb5 の snapshot を正しく継承
- ✅ ループが正しく動作(1, 2 出力確認)
- ⚠️ print/concat で segfault(別問題、次Phase)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-15 00:39:43 +09:00
eb70dfc5bb
refactor(llvm): Phase 131-12-P2 - block_end_values SSOT 化(WIP)
...
## 実装内容
- get_end_values() API 追加
- _value_at_end_i64() を snapshot-only に変更
- def_blocks 即時更新
- PHI incoming を snapshot から取得
## 発見された問題
- 同一ブロック内の def→use が predecessor snapshot を見てしまう
- これは次フェーズで resolve_cur / resolve_incoming 分離で修正
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-14 21:55:44 +09:00
7dfd6ff1d9
feat(llvm): Phase 131-11-H/12 - ループキャリアPHI型修正 & vmap snapshot SSOT
...
## Phase 131-11-H: ループキャリアPHI型修正
- PHI生成時に初期値(entry block)の型のみ使用
- backedge の値を型推論に使わない(循環依存回避)
- NYASH_CARRIER_PHI_DEBUG=1 でトレース
## Phase 131-12-P0: def_blocks 登録 & STRICT エラー化
- safe_vmap_write() で PHI 上書き保護
- resolver miss を STRICT でエラー化(フォールバック 0 禁止)
- def_blocks 自動登録
## Phase 131-12-P1: vmap_cur スナップショット実装
- DeferredTerminator 構造体(block, term_ops, vmap_snapshot)
- Pass A で vmap_cur をスナップショット
- Pass C でスナップショット復元(try-finally)
- STRICT モード assert
## 結果
- ✅ MIR PHI型: Integer(正しい)
- ✅ VM: Result: 3
- ✅ vmap snapshot 機構: 動作確認
- ⚠️ LLVM: Result: 0(別のバグ、次Phase で調査)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-14 21:28:41 +09:00
413504d6de
feat(mir): Phase 131-11-F - MIR JSON metadata 出力実装
...
## 実装内容
- mir_json_emit.rs に function-level metadata 追加
- PHI 命令に dst_type ヒント追加
- v0/v1 両 emitter で実装
## 成果物
- ✅ metadata.value_types を JSON に出力
- ✅ PHI dst_type を metadata から取得
- ✅ ビルド成功(0 エラー)
## JSON 出力例
```json
{
"functions": [{
"metadata": {
"value_types": {
"1": "i64",
"3": "i64"
}
}
}]
}
```
## 既知の問題(Phase 131-11-E 再調査必要)
- MIR dump で PHI が String 型のまま
- Phase 131-11-E の TypeFacts 分離が完全に動作していない可能性
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 19:34:02 +09:00
29d96b94e6
fix(test): Phase 131-11-E テスト修正 - is_infinite_loop 初期化追加
...
## 問題
- src/mir/loop_pattern_detection/tests.rs でビルドエラー
- `LoopFeatures` に `is_infinite_loop` フィールドが欠けていた
## 修正
- classify_body() で `is_infinite_loop: false` を追加
- テストでは通常ループ(finite loop)を想定
## 検証
- ✅ ビルド成功
- ✅ Case C MIR: `%3: Integer = phi [%2, bb0], [%8, bb7]`
- ✅ Case C VM: `Result: 3`
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 19:02:18 +09:00
d3b3bf5372
feat(mir): Phase 131-11-E - TypeFacts/TypeDemands 分離(SSOT)
...
## 実装内容
### 1) Rust MIR Builder (ops.rs + lifecycle.rs)
- OperandTypeClass で型分類(String/Integer/Unknown)
- BinOp 型推論: Integer + Unknown → Integer
- lifecycle.rs に repropagate_binop_types() パス追加
- PHI 型解決後に BinOp 型を再計算
### 2) JSON Emission (mir_json_emit.rs)
- 結果ベースの dst_type 発行に変更
- Integer → "i64", String → {kind: handle, box_type: StringBox}
### 3) Python LLVM Backend (binop.py)
- dst_type を確実な情報として使用
- dst_type != None なら優先して処理
## 結果
- ✅ MIR: PHI/BinOp が Integer として正しく型付け
- ✅ VM: `Result: 3` (正しい出力)
- ✅ JSON: `dst_type: "i64"` を発行
- ❓ LLVM: 別の codegen 問題の可能性あり
## SSOT 設計達成
- TypeFacts(事実): 定義命令から推論
- TypeDemands(要求): 使用箇所の coercion で吸収
- 後方伝播なし: Fail-Fast に統一
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-14 18:55:05 +09:00
4b87b6cc88
docs: ドキュメント配置ルール(SSOT)確立
...
## 追加内容
- CLAUDE.md にドキュメント配置ルール(SSOT)セクション追加
- DOCS_LAYOUT.md (SSOT): 置き場所ルール定義
- phases/README.md: Phase ドキュメント説明
- design/README.md: 設計図ドキュメント説明
- investigations/README.md: 調査ログ説明
## ルール概要
1. **Phase 文書** → phases/phase-<N>/
2. **設計図** → design/
3. **調査ログ** → investigations/ (結論を 10-Now/20-Decisions に反映)
## 導線
- CLAUDE.md で概要説明
- DOCS_LAYOUT.md で詳細定義(SSOT)
- 各フォルダ README で参照方法
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-14 18:27:24 +09:00
e4678585d5
feat(joinir): Phase 131-11-D - InfiniteEarlyExit lowering 完成(VM成功)
...
## 修正内容
- k_exit が counter_exit を返す(const_0 ではなく)
- ExitMeta に counter を登録
- instruction_rewriter: loop_var を carrier_inputs に追加
## 結果
- Case C (llvm_stage3_loop_only): VM outputs `Result: 3` ✅
- exit PHI が正しく生成
- variable_map が正しく更新
## 検証
```bash
./target/release/hakorune apps/tests/llvm_stage3_loop_only.hako
# Result: 3
```
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-14 17:06:20 +09:00
233a49d902
feat(joinir): Phase 131-11 A-C - InfiniteEarlyExit パターン追加(検出部分)
...
## Step A: Feature Detection
- LoopPatternKind::InfiniteEarlyExit (Pattern 5) 追加
- LoopFeatures::is_infinite_loop フィールド追加
- detect_infinite_loop() で loop(true) 検出
## Step B: Classification Logic
- classify() を更新: Pattern 5 を Pattern 4 より優先
- Pattern 4 を狭化: has_continue && !has_break のみ
- 誤ルーティング完全除去
## Step C: Pattern Module
- pattern5_infinite_early_exit.rs 新規作成
- Fail-Fast 設計: 超狭い shape guard
- lowering はスケルトン(Phase 131-11-D で実装)
## 動作確認
- Pattern 5 正常検出 ✅
- Shape guards 動作(1 break, 1 continue, 1 carrier)✅
- Pattern 4 誤ルーティング回避 ✅
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-14 09:59:34 +09:00
e1d706d2e0
docs(phase131): Case C 調査完了 - InfiniteEarlyExit パターン追加方針
...
## 根本原因解明
- loop(true) が Pattern4 に誤ルーティング
- Pattern4 は BinaryOp 比較を期待、boolean literal で失敗
## 解決方針
- 新パターン InfiniteEarlyExit 追加(Pattern 2 拡張ではなく)
- classify() の優先度修正
- Shape guard で最小受理(break+continue 各1箇所)
## 作成ドキュメント
- case-c-infinite-loop-analysis.md (13KB詳細分析)
- phase131-11-case-c-summary.md (4KBサマリー)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-14 09:47:23 +09:00
18bf35e6d4
fix(llvm): Phase 131-10 - Smart console.log routing(Segfault修正)
...
## 問題
- Integer値をi8*ポインタに変換 → Segfault(Exit 139)
## 解決策
- String literal → nyash.console.log(i8*)
- Integer/Handle → nyash.console.log_handle(i64)
## 結果
- Case B (loop_min_while): LLVM outputs `0,1,2` ✅
- VM/LLVM完全パリティ達成
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-14 09:19:00 +09:00
bfe047840b
fix(mir): Phase 131-9 - PHI 型推論修正(String→Integer)
...
Phase 131-9: MIR PHI 型推論バグ修正
問題:
- PHI が String 型として推論される
- 結果: 0,01,011(文字列連結)
- 期待: 0,1,2(整数 increment)
根本原因:
- PHI emission 時に circular dependency
- latch incoming value が PHI 型を継承
- 使用側(print)の型要求で String に
修正:
- src/mir/builder/lifecycle.rs (+75 lines):
- Global PHI Type Inference Pass 追加
- PHI 型を incoming values から再推論
- PhiTypeResolver を再利用
MIR 変化:
- Before: %3: String = phi [%2, bb0], [%12, bb7]
- After: %3: Integer = phi [%2, bb0], [%12, bb7]
テスト結果:
- Rust VM: 0,01,011 → 0,1,2 ✅ 完璧!
- LLVM: Segfault(別バグ、Phase 131-10 で対応)
箱化モジュール化:
- ✅ PhiTypeResolver 再利用
- ✅ 単一責任: PHI 型補正のみ
- ✅ Debug flag: NYASH_PHI_GLOBAL_DEBUG=1
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-14 08:30:54 +09:00
cf4d98ed08
fix(llvm): Phase 131-8 - ExternCall argument handling 修正
...
Phase 131-8: ExternCall が PHI 値を正しく受け取るように修正
問題:
- ExternCall が resolve_ptr() を使用
- PHI 値は local vmap にない → null を返す
- 結果: console.log が常に 0 を出力
修正:
- src/llvm_py/instructions/externcall.py:
- resolve_ptr() → resolve_i64_strict() に統一
- 他の命令(binop, compare, copy)と同じ resolver を使用
テスト結果:
- Before: 0,0,0
- After: 0,01,011 (PHI 値が正しく渡る!)
- Case A: ✅ 退行なし (exit code 42)
新規発見(スコープ外):
- MIR 型推論バグ: %3 が String 型として扱われる
- 出力が 0,1,2 ではなく 0,01,011(文字列連結)
- → Rust frontend の問題(Phase 131-9 候補)
箱化モジュール化:
- ✅ resolve_i64_strict() に統一
- ✅ Value resolution vs Type conversion の責務分離
- ✅ 構造的解決
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-14 08:02:23 +09:00
22753f8cc3
fix(llvm): Phase 131-7 - Multi-pass vmap sync 修正(Branch bug 解消)
...
Phase 131-7: Multi-pass block lowering の vmap sync バグ修正
問題:
- Pass A (body instructions) が vmap_cur に値を保存
- Pass C (deferred terminators) が builder.vmap を参照
- → Pass A の値が Pass C に届かない
- → Branch condition が 0 に fallback → 無限ループ
修正:
- src/llvm_py/builders/block_lower.py (lines 237-248):
- PHI-only フィルタを削除
- 全ての値を global vmap に sync
変更ファイル:
- src/llvm_py/builders/block_lower.py: vmap sync 修正
- src/llvm_py/instructions/controlflow/branch.py: trace logging 追加
- src/llvm_py/instructions/unop.py: trace logging 追加
- src/llvm_py/llvm_builder.py: debug helpers 追加
- src/llvm_py/phi_wiring/wiring.py: trace logging 追加
- src/runner/modes/common_util/exec.rs: Python stdout 転送
結果:
- ✅ Branch bug 修正: ループが正しく終了
- ✅ 出力: 無限ループ → 3回で停止
- ❌ 新 bug 発見: ExternCall が null を受け取る(PHI 値の代わりに)
Next: Phase 131-8 (ExternCall argument handling 修正)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-14 07:38:21 +09:00
35db1f8d78
docs(phase131): Phase 131-6 根治調査完了 - MIR正常/LLVM壊れてる確定
...
Phase 131-6 根治調査: SSA Dominance 診断完了
確定結果:
- ✅ MIR は正しい(SSA 形式完璧、use-before-def なし)
- ✅ Rust VM は正常(0,1,2 を出力して停止)
- ❌ LLVM backend が壊れている(0 を無限に出力)
根本原因特定:
- 場所: src/llvm_py/llvm_builder.py の finalize_phis() (lines 601-735)
- 問題: PHI incoming value wiring が壊れている
- 疑わしいコード: lines 679-681 の self-carry logic
- 結果: PHI %3 が常に初期値 0 を返す → ループカウンタ増えない
テスト結果:
- Simple Add: VM ✅ 1, LLVM ✅ 1 (PASS)
- Loop Min While: VM ✅ 0,1,2, LLVM ❌ 0 forever (BUG)
- Phase 87 Min: VM ✅ 42, LLVM ✅ 42 (PASS)
新規ドキュメント:
- phase131-6-ssa-dominance-diagnosis.md: 完全な診断結果
- phase131-6-next-steps.md: 修正戦略と実装チェックリスト
- phase131-3-llvm-lowering-inventory.md: 更新済み
Next: Phase 131-7 (finalize_phis 修正)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 07:03:38 +09:00
1510dcb7d8
fix(llvm): Phase 131-6 調査 - TAG-RUN 3バグ発見(1修正/1部分/1未修正)
...
Phase 131-6: Infinite Loop Bug 調査完了
発見したバグ(3件):
1. Bug #1 : Copy-to-PHI 命令(SSA 違反)✅ 修正完了
- instruction_rewriter.rs: PHI destination への Copy をスキップ
2. Bug #2 : Type Inference 混同(String vs Integer)⚠️ 部分修正
- binop.py: force_string ロジック削除
3. Bug #3 : SSA Dominance Violation ❌ 未修正
- MIR builder が定義前に値を使用(根本問題)
変更ファイル:
- src/mir/builder/control_flow/joinir/merge/instruction_rewriter.rs:
- Lines 428-443: header PHI への Copy スキップ追加
- src/llvm_py/instructions/binop.py:
- Lines 128-159: force_string 削除、Phase 131-6 コメント追加
- docs/development/current/main/phase131-3-llvm-lowering-inventory.md:
- 3バグの詳細追記
テスト結果:
- Case A/B2: ✅ 退行なし
- Case B: ❌ infinite loop 継続(Bug #3 が原因)
- Simple Add: ❌ 0 を出力(期待: 1)
Next: Phase 131-6 続き - MIR SSA dominance 根治
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-14 06:52:50 +09:00
9e76173c99
fix(llvm): Phase 131-5 完了 - TAG-LINK 修正(ExternCall symbol mapping)
...
Phase 131-5: ExternCall Symbol Mapping 修正
問題:
- Case B (loop_min_while.hako) が TAG-LINK で失敗
- エラー: undefined reference to `nyash_console_log`
根本原因:
- Python harness が dot → underscore 変換を実行
(`nyash.console.log` → `nyash_console_log`)
- NyKernel は `nyash.console.log` をエクスポート
(ELF format では dot が有効)
修正:
- src/llvm_py/instructions/externcall.py から変換ロジックを削除(-4 lines)
- Symbol 名は NyKernel exports と完全一致
変更ファイル:
- src/llvm_py/instructions/externcall.py:
- 不要な dot→underscore 変換削除
- ELF symbol 仕様のコメント追加
テスト結果:
- Case B LINK: ❌ →✅ (修正成功)
- Case B RUN: ❌ (新 TAG-RUN: infinite loop)
- Case A/B2: ✅ (退行なし)
箱化モジュール化:
- ✅ SSOT 達成: NyKernel exports を信頼
- ✅ クリーンな修正: 不要コード削除のみ
- 推奨: NyKernel symbol naming convention ドキュメント化
Next: Phase 131-6 (TAG-RUN 修正 - infinite loop)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 06:25:42 +09:00
73613dcef0
feat(llvm): Phase 131-4 P1 完了 - PHI ordering 修正(multi-pass architecture)
...
Phase 131-4 P1: PHI After Terminator Bug 修正
問題:
- LLVM IR で PHI が terminator の後に出現(LLVM invariant 違反)
- Case B (loop_min_while.hako) が TAG-EMIT で失敗
修正:
- Multi-pass block lowering architecture 実装:
- Pass A: non-terminator instructions のみ emit
- Pass B: PHI finalization(block head に確実に配置)
- Pass C: deferred terminators を最後に emit
変更ファイル:
- src/llvm_py/builders/block_lower.py (~40行):
- lower_blocks() で terminator を defer
- lower_terminators() 新設(Pass C)
- _deferred_terminators dict で管理
- src/llvm_py/builders/function_lower.py (3行):
- Pass 順序更新: A→B→C
- src/llvm_py/instructions/ret.py (5行):
- _disable_phi_synthesis flag で Pass C 中の PHI 生成を抑制
テスト結果:
- Case B EMIT: ❌ →✅ (修正成功)
- Case B LINK: ❌ (新 TAG-LINK: undefined nyash_console_log)
- Case A/B2: ✅ (退行なし)
箱化モジュール化:
- ✅ Multi-pass で責務分離
- ✅ Flag mechanism で構造的制御
- ✅ ハードコード禁止原則遵守
Next: Phase 131-5 (TAG-LINK 修正)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 06:12:31 +09:00
5709026812
docs(phase131): Phase 131-3 完了 - LLVM lowering 棚卸し(3ケース)
...
Phase 131-3 完了: MIR→LLVM lowering 棚卸し
テスト結果マトリックス:
- Case A (phase87_llvm_exe_min.hako): ✅ PASS (baseline)
- Case B (loop_min_while.hako): ❌ TAG-EMIT (PHI after terminator)
- Case B2 (print(42) simple): ✅ PASS (BoxCall works)
- Case C (llvm_stage3_loop_only.hako): ❌ TAG-EMIT (JoinIR pattern gap)
Critical Bugs:
1. Bug #1 : PHI After Terminator (Case B)
- 原因: function_lower.py が terminator を PHI より先に emit
- 修正: 4-pass block emission (2-3h)
2. Bug #2 : JoinIR Pattern Gap (Case C)
- 原因: loop(true) { break } パターンが JoinIR 未対応
- 修正: Pattern 5 設計・実装 (3-4h)
Next Actions:
- P1 (推奨): PHI ordering 修正 → 80% のループを有効化
- P2: JoinIR Pattern 5 → infinite loop 対応
ドキュメント:
- phase131-3-llvm-lowering-inventory.md: 詳細棚卸し結果
- phase87-selfhost-llvm-exe-line.md: LLVM IR parsing error 追記
- CURRENT_TASK.md: phase131-3 参照追加
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 05:55:21 +09:00
e912ef9134
docs(phase131): SSOT整備 - VM入口/env var/次の入口を1箇所に固定
...
Phase 131 SSOT 整備完了:
1) VM Box 解決の入口SSOT(phase131-2-box-resolution-map.md)
- 📍 入口3行を先頭に追記(handle_new_box/UnifiedRegistry/BoxFactoryRegistry)
- NYASH_VM_FAST を bench/profile-only 特例と明記
2) 環境変数のSSOTを1箇所へ(environment-variables.md)
- ## LLVM Build Pipeline セクション新設(14変数)
- phase87 の Environment Variables セクションを参照リンクに置き換え
- 重複表を削除、SSOTドキュメントへの導線確立
3) 次の開発の入口を明確化(CURRENT_TASK.md)
- P1(Loop Canonicalizer): 🔶 設計待ち(外部検討中)
- P2(JoinIR / Selfhost depth-2): ✅ 実装可能
- 次に触るSSOTを1行で指定:
- Loop系: joinir-architecture-overview.md
- VM Box系: phase131-2-box-resolution-map.md
Impact:
- 迷子防止: 各領域のSSOTが1行で分かる
- 重複削減: env var 表を environment-variables.md に集約
- 状態明確化: P1/P2 の「設計待ち/実装可能」が一目瞭然
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 05:27:39 +09:00
05c5021147
docs(phase131): LLVM SSOT強化 + ConsoleBox調査完了 + Phase86-90要約
...
Phase 131-1 完了: LLVM exe line SSOT 強化
- phase87-selfhost-llvm-exe-line.md に 4セクション追加(+300行)
- 環境変数リファレンス(14変数)
- 成功/失敗基準(exit code 0/1/2/3)
- コンパイラモード説明(harness vs crate)
- デバッグセクション拡張
- "1コマンドで再現" 可能な状態を確立
Phase 131-2 完了: ConsoleBox 問題調査
- VM の 3重登録経路を特定(BoxFactoryRegistry/UnifiedRegistry/Builtin)
- LLVM backend は Phase 133 で解決済み
- 3つのドキュメント作成:
- phase131-2-consolebox-investigation.md(詳細調査)
- phase131-2-summary.md(エグゼクティブサマリ)
- phase131-2-box-resolution-map.md(Box 解決マップ)
Phase 86-90 完了: Loop frontends 要約
- phase86-90-loop-frontends-summary.md 追加
- Pattern4/ContinueReturn/ParseStringComposite の経緯を1枚に集約
- INDEX から導線追加
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 05:24:31 +09:00
2a18a66154
feat(joinir): Phase Next - parse_array/object 同型 fixture
...
## 実ループ制御構造の抽出
- parse_array_min.program.json (n=10 → acc=6)
- parse_object_min.program.json (n=10 → acc=7)
## 既存パターン再利用
- ContinueReturn lowering 活用(新規 lowering 不要)
- 優れたモジュール再利用の実証
## Tests
- +4 tests (ParseArray 2本 + ParseObject 2本)
- +1 test fixed (Phase 88 error message 更新)
- normalized_dev: 64→69 passed (+5)
## 箱化評価
- 単一責任: ✅
- 境界明確: ✅ (SSOT)
- 再利用性: ✅ (既存パターン活用)
- テスト容易性: ✅
- SSOT: ✅ (dev_fixtures.rs)
## レガシー探索
- デッドコード: なし
- 重複コード: なし
- クリーンな状態維持
Impact:
- 実ループ寄せの基盤確立
- モジュール設計の成功実証
- 技術的負債ゼロ
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 04:09:46 +09:00
df57d3d320
refactor(joinir): Refactor-A+B - Null literal + ContinueReturn 一般化
...
## Refactor-A: Null literal 対応
- expr.rs に "Null" case 追加
- ConstValue::Null → JoinValue::Unit マッピング
## Refactor-B: ContinueReturn 一般化
- 複数 return-if 許可(同値のみ)
- json_values_equal() ヘルパー追加
- Fail-Fast: 異なる値は即エラー
## Fixtures & Tests
- null_literal_min.program.json (return null)
- continue_return_multi_min.program.json (複数 return null)
- +1 test (vm_bridge 検証)
Impact:
- normalized_dev: 63→64 passed (+1)
- lib: 993 passed (回帰なし)
- 箱化スコア: 5/5 (全項目満点)
- 実ループ(_parse_array/_parse_object) 準備完了
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 04:01:05 +09:00
45add0f5d3
feat(joinir): Phase 90 P0 - ParseStringComposite pattern
...
## Composite Pattern
- Continue(escape i+=2) + EarlyReturn(close quote)
- parse_string_composite_pattern.rs (50行、continue_return 再利用)
- 89% コード削減(450行→50行)
## Shape Detection
- BinOp Add const 2 検出(escape 特徴)
- LoopStepInspector 活用(Phase 89 リファクタ成果)
## SSOT Integration
- dev_fixtures.rs に登録
- StepCalculator 再利用(Phase 89-2 成果)
## Tests
- +2 tests (vm_bridge + 期待値 n=10→acc=5)
- normalized_dev: 61→63 passed
- lib: 993 passed (回帰なし)
Impact:
- Reuse over Duplication 実践
- Phase 89 リファクタ成果の完全活用
- 箱化原則 5/5 遵守
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 03:36:45 +09:00
70ceec1e3e
refactor(joinir): Phase 89 リファクタリング - 1) LoopStepInspector共通化
...
変更内容:
- 新規ファイル: loop_step_inspector.rs (純関数ヘルパー集合)
- has_select_instruction(): Select 命令検出
- has_compare_instruction(): Compare 命令検出
- count_conditional_jumps(): 条件付き Jump のカウント
- has_tail_call(): tail call 検出
- has_reasonable_param_count(): パラメータ数妥当性チェック
- shape_guard.rs を Inspector 使用に変更
- is_pattern4_continue_minimal(): 重複ロジック削減
- is_pattern_continue_return_minimal(): 重複ロジック削減
メリット:
- 散在していた検出ロジックを1箇所で管理
- detector 間で重複コード削減
- 単一責任の原則に準拠
- テスト容易性向上(単体テスト付き)
テスト結果:
- lib tests: 993 passed (回帰なし)
- normalized_dev tests: 61 passed / 1 failed (ベースライン維持)
- loop_step_inspector 単体テスト: +5 (新規)
Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 03:16:32 +09:00
90c45e544b
refactor(joinir): Phase 89 リファクタリング - 3) Frontend再帰探索
...
変更内容:
- Break/Continue/Return 検出を再帰的探索に変更
- has_break_in_loop_body(): top-level If のみ → 再帰的探索
- has_continue_in_loop_body(): top-level If のみ → 再帰的探索
- has_return_in_loop_body(): top-level If のみ → 再帰的探索
- ネストした If/Block 内のステートメントも検出可能に
- ヘルパー関数追加:
- has_break_recursive()
- has_continue_recursive()
- has_return_recursive()
理由:
- Phase 90+ で合成形パターン(ネストした If/Block)に対応する準備
- 現状では top-level のみチェックしているため、深い階層で誤判定の可能性
影響範囲:
- loop_frontend_binding.rs のルーティングロジック
- Phase 90 の合成形パターンで正確な検出が可能に
テスト結果:
- lib tests: 993 passed (回帰なし)
- normalized_dev tests: 61 passed / 1 failed (ベースライン維持)
Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 03:13:05 +09:00
98a0b8396f
refactor(joinir): Phase 89 リファクタリング - 2) ShapeCapability分類修正
...
変更内容:
- 新規 capability 追加: P4ContinueEarlyReturn
- Continue + Early Return 専用の capability
- P4ContinueSkipWs と明確に分離
- PatternContinueReturnMinimal のマッピング修正
- P4ContinueSkipWs → P4ContinueEarlyReturn に変更
- is_p2_core_capability に P4ContinueEarlyReturn を追加
理由:
- P4ContinueSkipWs は「Continue のみ」のパターン
- PatternContinueReturnMinimal は「Continue + Early Return」の合成形
- 将来の拡張時に混乱を避けるため、今のうちに分離
テスト結果:
- lib tests: 993 passed (回帰なし)
- normalized_dev tests: 61 passed / 1 failed (ベースライン維持)
Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 03:09:16 +09:00
6bcc70e07e
refactor(joinir): Phase 89 リファクタリング - 5) fixture名SSOT化
...
変更内容:
- 新規ファイル: src/mir/join_ir/normalized/dev_fixtures.rs (SSOT)
- NormalizedDevFixture enum で fixture 名・パス・ルーティング統一管理
- ALL_DEV_FIXTURES 配列で一覧化
- fixture_content() / load_and_lower() ヘルパー実装
- FunctionRoute を route.rs に分離
- ast_lowerer/route.rs 新規作成
- resolve_function_route() を route.rs に移動
- dev fixtures を SSOT から自動登録
- fixtures.rs を簡潔化
- 4つの builder 関数を SSOT 呼び出しに変更
- 散在していた include_str! パスを削除
メリット:
- typo・不一致によるルーティングミスを防止
- 新しい fixture 追加時は1箇所のみ変更
- 責務の明確化(route.rs / dev_fixtures.rs)
テスト結果:
- lib tests: 993 passed (回帰なし)
- normalized_dev tests: 61 passed / 1 failed (ベースライン維持)
Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 03:07:53 +09:00
5b5f3b55d4
docs: Phase 88-89 完了 + Phase 90 P0 追加
...
## CURRENT_TASK.md
- Phase 88-89 完了を反映
- Phase 90 P0 追加(_parse_string 合成 fixture)
- P1/P2 候補を Phase 91/92 に繰り上げ
- 最終更新: 2025-12-14
## 10-Now.md
- Phase 88 到達点を追記(continue + 可変ステップ)
- Phase 89 P0/P1 到達点を追記(ContinueReturn detector + lowering)
- 未検証の断定は書かない(dev-only fixture で固定、と明記)
Impact:
- 正確な進捗記録
- Phase 90 の明確な方針(fixture → detector → lowering)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 02:31:39 +09:00
730a80f33f
feat(joinir): Phase 89 P1 - ContinueReturn lowering implementation
...
## ContinueReturn 独立箱
- continue_return_pattern.rs (457行)
- Continue + Early Return の JoinIR lowering
- StepCalculator 再利用(3箇所)
- Fail-Fast 原則徹底(5箇所検証)
## Dispatcher 配線
- mod.rs: LoopPattern::ContinueReturn 対応
- allowlist: pattern_continue_return_minimal 追加
## Fixture & Tests
- fixtures.rs: build_pattern_continue_return_min
- shapes.rs: +2 tests (vm_bridge + 期待値 n=10→acc=4)
Impact:
- normalized_dev: 61 passed (+2)
- lib tests: 993 passed (回帰なし)
- 箱化原則:単一責任・境界明確・再利用性高
Next: Phase 90 - _parse_string 合成 fixture
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 02:02:47 +09:00
39affbf00d
refactor(joinir): Phase 89-2 - StepCalculator Box extraction
...
Extract step increment logic from Continue pattern into reusable Box:
New Module:
- step_calculator.rs (161 lines)
- extract_linear_increment(): Detect i + const patterns
- calculate_step_difference(): Compute step delta
- 6 comprehensive unit tests (100% coverage)
Changes:
- continue_pattern.rs: Use StepCalculator instead of local function
- Removed extract_add_i_const() (20 lines)
- Cleaner separation of concerns
- mod.rs: Register step_calculator module
Benefits:
- Reusability: Available for ContinueReturn and future patterns
- Testability: Independent pure functions with unit tests
- Extensibility: Easy to add i *= 2 support later
- SSOT: Single source of truth for step increment logic
Code Metrics:
- continue_pattern.rs: 321 → 305 lines (5% reduction)
- New tests: +6 (993 total passed)
- Complexity: Reduced (pure function extraction)
Tests: 993 passed (no regression)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 01:49:45 +09:00
6d61e8f578
refactor(joinir): Phase 89-1 - Continue pattern error message enhancement
...
Improve error messages in Continue pattern lowering for better debugging:
Changes:
- Missing 'i' increment: Add Expected/Found/Hint format
- Invalid step increment form: Include JSON debug output
- Invalid 'then' branch step: Include JSON debug output
- Missing accumulator update: Add Expected/Found/Hint format
Benefits:
- 50% reduction in debug turnaround time (estimated)
- Clear actionable hints for users
- Explicit Expected vs Found comparison
Tests: 987 passed (no regression)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 01:46:51 +09:00
4e3fc4ad49
feat(joinir): Phase 89 P0 - Continue + Early Return pattern detector
...
## Pattern4 Detector 締め
- is_pattern4_continue_minimal() を厳しく
- Select 必須 + conditional Jump exactly 1
- loop 内 return を P4 と誤認しない
## 新パターン箱
- LoopPattern::ContinueReturn enum 追加
- has_return_in_loop_body() helper 追加
- Fail-Fast: UnimplementedPattern error
## Normalized-dev 統合
- NormalizedDevShape::PatternContinueReturnMinimal
- detector: Select + conditional Jumps >= 2
- canonical には入れない(dev-only)
## Documentation
- 10-Now.md, CURRENT_TASK.md 更新
Impact:
- 987 lib tests PASS
- 60 normalized_dev tests PASS
- Pattern4 誤爆防止
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 00:59:58 +09:00
b578eb7a65
test(joinir): Phase 88 - Fail-Fast validation for non-const i update
...
- Add test: rejects_non_const_then_i_update
- Validates that continue pattern requires `i = i + const` form
- Ensures Fail-Fast behavior for unsupported step patterns
Impact:
- 60 normalized_dev tests PASS (+1)
- Fail-Fast 仕様固定(非 const の i 更新を拒否)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 00:38:47 +09:00
b71a18495d
feat(joinir): Phase 88 - Pattern4 continue + variable step increment
...
Continue Pattern 拡張:
- then側の i=i+const 差分加算 + acc更新を許可
- continue_pattern.rs:193 で可変ステップ検出
Dev Router 許可:
- ast_lowerer/mod.rs:92 で normalized_dev feature時に新パターンを有効化
Fixtures & Tests:
- jsonparser_unescape_string_step2_min fixture追加(submodule)
- normalized_joinir_min.rs に shape テスト追加
- shapes.rs に expected shape 定義
Documentation:
- joinir-architecture-overview.md に Phase 88 到達点を追記
Impact:
- Pattern4 continue + 可変インクリメント(i+=1 or i+=2)対応
- _unescape_string 制御構造の土台確立
- normalized_dev tests PASS
Next: _unescape_string 残り複合ループ対応
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 00:29:56 +09:00
8a8c90fc74
docs(joinir): Phase 86 SSOT 追記完了 + Phase 88 準備
...
Phase 86 SSOT 追記(P0 完了):
- 10-Now.md: carrier_init_builder / error_tags 確立を追記
- CURRENT_TASK.md: P0→P1 繰り上げ、Done 節追加
Phase 88 準備:
- nyash_kernel/lib.rs: AOT 実行器で Ring0Context 初期化
- nyash.toml: プラグインパス正規化(plugins/...)
- auto_detect.conf: integration タイムアウト 120秒に延長
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-14 00:05:16 +09:00
cd12a2569e
feat(llvm): Phase 87 - LLVM exe line SSOT + integration smoke
...
Established single pipeline for .hako → executable generation.
SSOT: tools/build_llvm.sh
- Standard procedure: build_llvm.sh input.hako -o output_exe
- Prerequisites: llvm-config-18, llvmlite, LLVM features enabled
- Pipeline: .hako → MIR → LLVM IR → .o → executable
New files:
- docs: phase87-selfhost-llvm-exe-line.md (SSOT procedure doc)
* Full troubleshooting guide (llvm-config, llvmlite, linking)
* Advanced usage (custom output, debugging, performance notes)
* Anti-patterns documentation (no duplication/fragmentation)
- fixture: apps/tests/phase87_llvm_exe_min.hako (5 lines, return 42)
- smoke: integration/apps/phase87_llvm_exe_min.sh
* Exit code verification (stdout-independent testing)
* SKIP if LLVM unavailable (graceful degradation)
* Integration profile only (not in quick)
- index: 10-Now.md, 01-JoinIR-Selfhost-INDEX.md (Phase 87 entries)
- task: CURRENT_TASK.md (Phase 74-87 status update)
Integration smoke: demonstrates full pipeline
- Build: .hako → .o → exe (successful ✅ )
- Runtime: Ring0 initialization issue (known limitation, out of scope)
Quick profile: unchanged (integration only, per policy)
Policy: No duplicate build paths, SSOT maintained
987/987 tests PASS (production stable)
2025-12-13 22:51:13 +09:00
4df66e44d7
docs(joinir): clarify ValueId worlds and routing vs fallback
...
架構 overview の矛盾解消:
- ValueId の 3 つの世界を明文化(JoinIR/MIR/PHI dst)
- routing/fallback 語彙を不変条件に統合(Section 0.1 と整合)
- 章番号重複を解消(見出し参照へ統一)
Changes:
- Section 1: Added ValueId worlds clarification, routing/fallback definitions
- Removed duplicate section numbers (5, 6, 3 duplicates → renamed/unnumbered)
- Total: +25 lines, -7 lines (net +18)
No specification changes, readability improvements only
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-13 22:40:24 +09:00
7dbc894629
docs(joinir): Phase 86 到達点 - Carrier init builder + Error tags SSOT
...
Phase 74-86 成果を SSOT docs に反映:
- 10-Now.md: Phase 86 achievements summary
- INDEX: carrier_init_builder, error_tags modules documented
- architecture-overview: SSOT module references added
Impact: 987/987 tests, +13 unit tests, 2 new SSOT modules
Modules: carrier_init_builder.rs, error_tags.rs
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-13 22:37:56 +09:00
f858a5fbd0
docs: archive CURRENT_TASK and add lightweight view
2025-12-13 22:21:04 +09:00
33f03d9775
refactor(joinir): Phase 86 - Carrier init builder, debug migration, error tags
...
P1: Carrier Initialization Builder (HIGH) ✅
- New module: carrier_init_builder.rs (197 lines, 8 tests)
- Refactored loop_header_phi_builder.rs (-34 lines)
- Centralized CarrierInit value generation (SSOT)
- Eliminates scattered match patterns across header PHI, exit line
- Consistent debug output: [carrier_init_builder] format
- Net: -34 lines of duplicated logic
P2: Remaining DebugOutputBox Migration (QUICK) ✅
- Migrated carrier_info.rs::record_promoted_binding()
- Uses DebugOutputBox for JOINIR_DEBUG checks
- Maintains JOINIR_TEST_DEBUG override for test diagnostics
- Consistent log formatting: [context/category] message
- Net: +3 lines (SSOT migration)
P3: Error Message Centralization (LOW) ✅
- New module: error_tags.rs (136 lines, 5 tests)
- Migrated 3 error sites:
* ownership/relay:runtime_unsupported (plan_validator.rs)
* joinir/freeze (control_flow/mod.rs)
* (ExitLine errors were debug messages, not returns)
- Centralized error tag generation (freeze, exit_line_contract, ownership_relay_unsupported, etc.)
- Net: +133 lines (SSOT module + tests)
Total changes:
- New files: carrier_init_builder.rs (197), error_tags.rs (136)
- Modified: 6 files
- Production code: +162 lines (SSOT investment)
- Tests: 987/987 PASS (982→987, +5 new tests)
- Phase 81 ExitLine: 2/2 PASS
- Zero compilation errors/warnings
Benefits:
✅ Single Responsibility: Each helper has one concern
✅ Testability: 13 new unit tests (8 carrier init, 5 error tags)
✅ Consistency: Uniform debug/error formatting
✅ SSOT: Centralized CarrierInit and error tag generation
✅ Discoverability: Easy to find all error types
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-13 21:48:02 +09:00
624245b63c
docs(joinir): Phase 78-85 Boxification Feedback Report
...
Comprehensive analysis of boxification patterns effectiveness.
Key Findings:
- Overall: Exceptional success ⭐ ⭐ ⭐ ⭐ ⭐ (24/25 avg rating)
- Net code reduction: -1,388 lines (Phase 78-79: -530L, Phase 85: -858L)
- 4 new Boxes: PromotedBindingRecorder, Detector/Recorder, BindingMapProvider, DebugOutputBox
- 28 new unit tests, 974/974 PASS maintained
Box Ratings (out of 25):
- PromotedBindingRecorder: 24/25 (67% wiring reduction)
- Detector/Recorder: 24/25 (60% code reduction, SRP)
- BindingMapProvider: 23/25 (80% cfg reduction)
- DebugOutputBox: 21/25 (centralized debug output)
Phase 86 Recommendations:
- GO: Carrier Initialization Builder (HIGH, 2-3h, -100L)
- GO: Remaining DebugOutputBox Migration (QUICK, 30m)
- GO: Error Message Centralization (LOW, 1-2h)
- NO-GO: Detector/Promoter Pipeline (over-abstraction risk)
- NO-GO: ScopeManager Lookup Variants (premature)
Lessons Learned:
- Single Responsibility principle validated
- Testability-first approach successful
- Low migration cost (1-2h per phase)
- Zero production risk (all dev-only/backward-compatible)
Report: phase78-85-boxification-feedback.md (~1,200 lines)
Updated: INDEX, Now, architecture-overview (Phase 85 links)
2025-12-13 21:32:35 +09:00
dd58b8bbe2
tests(normalized): split normalized_joinir_min into modules
2025-12-13 19:40:24 +09:00
8c2bc45be6
refactor(joinir): Phase 85 - Quick wins: loop_patterns removal, DebugOutputBox, dead_code audit
...
Quick Win 1: Remove loop_patterns_old.rs (COMPLETED)
- Deleted obsolete legacy loop pattern dispatcher (914 lines)
- All patterns (Break/Continue/Simple) now in modular loop_patterns/ system
- Moved helper functions (has_break_in_loop_body, has_continue_in_loop_body) to analysis.rs
- Updated loop_frontend_binding.rs to remove fallback
- Verified zero regressions: 974/974 lib tests PASS
Quick Win 2: DebugOutputBox consolidation (COMPLETED)
- New module: src/mir/join_ir/lowering/debug_output_box.rs (170 lines)
- Centralized debug output management with automatic HAKO_JOINIR_DEBUG checking
- Refactored 4 files to use DebugOutputBox:
- condition_env.rs: 3 scattered checks → 3 Box calls
- carrier_binding_assigner.rs: 1 check → 1 Box call
- scope_manager.rs: 3 checks → 3 Box calls
- analysis.rs: Updated lower_loop_with_if_meta to use new pattern system
- Benefits: Consistent formatting, centralized control, zero runtime cost when disabled
- Added 4 unit tests for DebugOutputBox
Quick Win 3: Dead code directive audit (COMPLETED)
- Audited all 40 #[allow(dead_code)] directives in lowering/
- Findings: All legitimate (Phase utilities, future placeholders, API completeness)
- No unsafe removals needed
- Categories:
- Phase 192 utilities (whitespace_check, entry_builder): Public API with tests
- Phase 231 placeholders (expr_lowerer): Explicitly marked future use
- Const helpers (value_id_ranges): API completeness
- Loop metadata (loop_update_summary): Future phase fields
Result: Net -858 lines, improved code clarity, zero regressions
Tests: 974/974 PASS (gained 4 from DebugOutputBox tests)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-13 19:25:11 +09:00
2dc5ccecec
docs(joinir): Phase 84 - Glossary + debug flag documentation
...
Phase 84 最小化実装:
- 0.1 用語セクション拡張: SSOT, Fail-Fast 追加
- デバッグフラグ新セクション: HAKO_JOINIR_DEBUG 推奨化、後方互換説明
- Phase 82-83 統合後の状態反映
Not included (Phase 84 後回し):
- Duplicate heading consolidation
- Phase 74-81 comprehensive summary section
次: 箱化モジュール化 + レガシー削除調査
2025-12-13 19:06:53 +09:00
9e32807a96
refactor(joinir): Phase 82-83 - Debug flag SSOT + Fallback verification
...
Phase 82: Centralized JoinIR debug flag reading
- Added is_joinir_debug() SSOT function in joinir_flags.rs
- Replaced 16 direct env::var() calls across 8 files
- Updated docs to recommend HAKO_JOINIR_DEBUG (NYASH_ deprecated)
- Backward compat: Both env vars work
Phase 83: Verified promoted carrier fallback behavior
- Confirmed NO fallback to name-based lookup for DigitPos/Trim
- Documented fallback expectations in Phase 80/81 docs
- Added verification commands and expected output
Changes:
- src/config/env/joinir_flags.rs: +187 lines (new SSOT module)
- 8 files: env var reads → is_joinir_debug() calls
- 3 docs: HAKO_JOINIR_DEBUG examples + fallback sections
- 1 summary doc: phase82-83-debug-flag-ssot-summary.md
Tests: 970/970 lib PASS, 58/58 normalized_dev PASS
Impact: Dev-only (zero production changes)
2025-12-13 19:01:14 +09:00
3ff032ead5
docs(joinir): link Phase 81 ExitLine contract SSOT
...
Phase 81 完了を受けて docs リンク追加:
- 01-JoinIR-Selfhost-INDEX.md: Phase 81 entry
- 10-Now.md: Phase 81 status update
- joinir-architecture-overview.md: Phase 81 ExitLine contract verification section
Phase 74-81 complete: BindingId migration + ExitLine contract verified
2025-12-13 18:46:07 +09:00