36717cad4f
docs: update Now/INDEX for Phase 129-B join_k as-last
2025-12-18 07:54:16 +09:00
088122df71
docs: update Now/INDEX for Phase 127 DONE and Phase 129 next
2025-12-18 07:28:30 +09:00
d74f77d2ed
docs: Phase 128 DONE
2025-12-18 07:08:32 +09:00
9aedc19413
docs: add Phase 127 entry (planned)
2025-12-18 06:55:29 +09:00
b195e8bad9
docs: Phase 126 DONE (available_inputs wired)
...
- AvailableInputsCollectorBox: function params + CapturedEnv SSOT
- EnvLayout.inputs: reads ∩ available_inputs (deterministic)
- Reads-only inputs resolution実装完了(dev-only)
- Regression: 1165 tests PASS, Phase 121-125/118 smokes PASS
- 次: Phase 127 TBD
2025-12-18 06:46:43 +09:00
d7c77e1046
docs: Phase 125 P2-P5 DONE (structure-only, P3 pending)
...
Phase 125 P2-P5 完了:
- EnvLayout (writes + inputs) 導入
- Return(Variable) 解決拡張(writes or inputs)
- Fail-Fast with hint(構造化エラー)
- Unit tests: 18/18 PASS
- Integration smoke: PASS
- Regression: Phase 121-124, 118 維持
Next: Phase 125 P3 (available_inputs wiring)
- routing.rs / lowering.rs で available_inputs を配線
- SSOT: function params + CapturedEnv
Ref: docs/development/current/main/phases/phase-125/README.md
2025-12-18 06:33:03 +09:00
7eeeb588e4
docs: add Phase 125 entry (planned)
2025-12-18 06:28:39 +09:00
d044af1fbc
docs: Phase 124 DONE
...
Phase 124 完了:
- reads facts SSOT 化(StepTreeFacts/Contract に追加)
- Return(Variable) from env (writes) サポート(dev-only)
- env マッピング(変数名 → ValueId)を writes から生成
- extract_variables_from_ast() で Variable 抽出を SSOT 化
- Fail-Fast 原則(env に無い Variable はエラー)
- Unit tests: 1159 PASS (including test_return_variable_from_env)
- Integration smoke: PASS (phase124_if_only_return_var_vm.sh)
- 回帰確認: Phase 121/123/118 全て PASS
- 10-Now.md 更新(Phase 124 完了、Phase 125 計画追加)
2025-12-18 06:10:17 +09:00
4f0ffae70d
docs: Phase 123 DONE
...
Updates documentation to reflect Phase 123 completion.
**Updates**:
1. `docs/development/current/main/phases/phase-123/README.md`:
- Marked all success criteria as complete
- Added comprehensive DONE section with implementation details
- Documented key design decisions (graceful degradation, fail-fast, box-first)
- Added verification commands and next steps (Phase 124)
2. `docs/development/current/main/10-Now.md`:
- Moved Phase 123 from "Next" to "2025-12-18: Phase 123 完了"
- Added Phase 123 summary (Return literal, If minimal compare, graceful degradation)
- Updated "Next" to Phase 124 (Normalized reads facts + Return(Variable))
3. `docs/development/current/main/01-JoinIR-Selfhost-INDEX.md`:
- Added Phase 123 entry: "Normalized semantics (Return literal + If minimal compare, dev-only)"
**Phase 123 Summary**:
- P0: Docs complete, scope frozen ✅
- P1: Return(Integer literal) working ✅
- P2: Return(Variable) returns Ok(None) (graceful degradation) ✅
- P3: If(minimal compare) generates correct JoinIR ✅
- P4: Integration smoke passing ✅
- P5: Docs updated ✅
**Verification**:
- Unit tests: 8 passed
- Integration smoke: PASS
- Legacy tests: Still passing (graceful degradation confirmed)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 05:50:29 +09:00
51ed137339
docs: Phase 123 plan (if-only normalized semantics)
2025-12-18 05:29:34 +09:00
c92154966c
docs: add Phase 122 entry (planned)
2025-12-18 04:48:53 +09:00
2a53f87d10
docs: Phase 121 DONE (StepTree→Normalized shadow parity for if-only)
2025-12-18 04:40:53 +09:00
9d5e58305e
docs: Phase 120 DONE
2025-12-18 04:19:48 +09:00
708accc853
docs: Phase 119 DONE
2025-12-18 04:09:47 +09:00
5091cda9cb
docs: Phase 118 DONE (loop+if merge parity)
2025-12-18 03:43:16 +09:00
2c7f5f7a5e
docs: Phase 117 DONE
...
Phase 117: if-only nested-if + call merge parity completed.
**Documentation**:
- docs/development/current/main/phases/phase-117/README.md (complete)
- docs/development/current/main/10-Now.md (updated with Phase 117 entry)
- docs/development/current/main/01-JoinIR-Selfhost-INDEX.md (added Phase 117 to index)
**Phase 117 Summary**:
- Verified nested if-only (inner if + outer else) with call merge
- Pattern: 3 call sites (f(1), f(2), f(3)) merge to single variable
- VM/LLVM EXE parity: both produce identical output "2\n3\n4"
- Regression: Phase 116 maintained
**Technical Details**:
- JoinIR Pattern3 (if-only) nested structure validation
- Call merge across nested control flow
- PHI node generation for nested branches
- LLVM EXE plugin integration (StringBox, IntegerBox, ConsoleBox)
**Next Steps**:
Phase 118+ will address more complex nested patterns (if-else nested, loop-if combinations).
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 02:55:14 +09:00
8440550b2f
docs: Phase 116 DONE
...
Phase 116 完了ドキュメント化
## 更新内容
### Phase 116 README
- 背景: LLVM fragile pattern(keep+call merge)
- 実装内容: fixture, VM smoke, LLVM EXE smoke
- 検証コマンド
- 技術的詳細: JoinIR Pattern 1, PHI接続
- Lessons Learned: Box-First原則, Fail-Fast原則
### 10-Now.md
- Phase 116 完了エントリ追加
- 入口: `docs/development/current/main/phases/phase-116/README.md`
### 01-JoinIR-Selfhost-INDEX.md
- Phase 116 を JoinIR Phase リストに追加
- 番号の重複を修正(18-27に整理)
## 成果物
✅ 片側元値保持、片側call結果のmergeパターンをVM/LLVM両方で固定
✅ output_validator.sh, llvm_exe_runner.sh 活用で統一的なテスト基盤
✅ 回帰防止: Phase 115 維持確認
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 02:39:44 +09:00
0a29f1443e
test: Phase 115 if-only call result merge parity (VM + LLVM EXE)
...
Phase 115実装 - if分岐内での関数呼び出し結果をマージするパターンを固定
**実装内容**:
- Fixture: phase115_if_only_call_merge_min.hako (expected: 2, 3)
- if/else両分岐で関数呼び出し f() の結果を変数 v に代入
- if後にマージされた v を使用(LLVM EXE でのPHI node生成を検証)
- VM smoke: phase115_if_only_call_merge_vm.sh
- NYASH_DISABLE_PLUGINS=1 HAKO_JOINIR_STRICT=1 で実行
- LLVM EXE smoke: phase115_if_only_call_merge_llvm_exe.sh
- llvm_exe_runner.sh を利用した標準パリティ検証
**検証結果**:
- VM test: PASS ✅
- LLVM EXE test: PASS ✅
- Phase 114 regression: PASS ✅
**箱化モジュール化の観点**:
- 単一責任: 各smokeは1パターンのみ検証(call result merge)
- 分離: VM/LLVM EXEで独立したテスト(llvm_exe_runner.sh経由)
- Fail-Fast: HAKO_JOINIR_STRICT=1 で不正な制御フローを即座に検出
**関連**:
- Phase 103: If-Only基本パリティ(制御フロー基礎)
- Phase 113: If-Only部分代入パリティ(変数マージ)
- Phase 114: If-Only return+post パリティ(early returnとpost-if文)
- Phase 115: If-Only call result merge パリティ(関数呼び出し結果マージ) ← 今回
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 02:32:08 +09:00
80be814fa4
test: Phase 114 if-only return+post parity (VM + LLVM EXE)
...
Phase 114 validates that if-only lowering correctly handles cases with:
- Early return in the if-only branch
- Post-if statements that execute on the else path
- Different return values from each path
Fixture: apps/tests/phase114_if_only_return_then_post_min.hako
- Expected output: 7\n2
- f(1): condition true → early return 7
- f(0): condition false → x=1+1=2, return 2
Testing:
- VM backend: phase114_if_only_return_then_post_vm.sh ✅
- LLVM EXE backend: phase114_if_only_return_then_post_llvm_exe.sh ✅
- Regression: Phase 103/113 maintained ✅
Implementation: No new code required - validates existing if-only
exit line routing and post-if statement processing.
Documentation:
- docs/development/current/main/phases/phase-114/README.md
- Updated: 10-Now.md, 01-JoinIR-Selfhost-INDEX.md
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 02:18:57 +09:00
70fe0da549
docs: Phase 113 if-only partial assign parity
...
- Create phases/phase-113/README.md (background, fixed pattern, verification)
- Update 10-Now.md with Phase 113 completion
- Update 01-JoinIR-Selfhost-INDEX.md with Phase 113 entry
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 01:58:56 +09:00
7829b23cf4
docs: note Phase 110-112 control_tree status
...
- Update 10-Now.md with Phase 112 completion
- Note: StepTree capability guard (strict-only) implemented
- Note: Default behavior unchanged, only affects HAKO_JOINIR_STRICT=1
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 01:39:06 +09:00
a27e3ce908
docs: Phase 109 DONE
...
- Create phases/phase-109/README.md
- Update 10-Now.md with completion report
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-17 23:45:55 +09:00
6a21382d44
docs: add Phase 107 to Now/INDEX and backlog
2025-12-17 23:15:57 +09:00
712e1ad755
docs: update Phase104 status and JoinIR map
2025-12-17 21:47:37 +09:00
950560a3d9
test(joinir): Phase 104 read_digits loop(true) parity
2025-12-17 18:29:27 +09:00
a5cec824c2
docs: Phase 103 DONE (if-only parity smokes)
2025-12-17 17:41:10 +09:00
935d475882
docs: Phase 103 plan (if-only parity baseline)
2025-12-17 17:39:12 +09:00
733b4fa950
docs: Phase 102 entry (real-app regression smokes)
2025-12-17 16:57:15 +09:00
61c9d7929c
docs: Phase 100 P2.1 - LLVM EXE parity for mutable accumulator
...
- Update phases/phase-100/README.md with LLVM EXE smoke note
- Update 10-Now.md with P2.1 short report
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 06:31:21 +09:00
682fc11f7c
docs: Phase 100 P1 pinned receiver integration tests complete
...
- Update docs/development/current/main/phases/phase-100/README.md
* Document P1 implementation and pinned receiver example
- Update docs/development/current/main/10-Now.md
* Add Phase 100 P1 completion short report
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-17 05:43:54 +09:00
692d44da62
docs: Phase 100 rollout plan (Pinned then mutable carrier)
2025-12-17 05:18:09 +09:00
8ab95666c8
docs: Phase 100 pinned read-only captures plan
2025-12-17 05:03:07 +09:00
90a8f1650d
docs: Phase 99 notes and indices
...
Trim/escape実コード寄り強化の記録:
- phase-96: 3ケース追記
- phase-95: 末尾バックスラッシュ扱い追記
- phase-99: 新規README作成
- 10-Now.md: Phase 99短報追加
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 04:26:23 +09:00
6d73fc3404
feat(llvm): Phase 97 Box/Policy refactoring complete
...
Box化完了:
- CallRoutePolicyBox: Call routing SSoT
- PrintArgMarshallerBox: Print marshalling SSoT
- TypeFactsBox: Type propagation SSoT
- PhiSnapshotPolicyBox: PHI contract SSoT
- PluginErrorContext: Structured error reporting
📋 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 04:14:26 +09:00
1a0d9ce8a0
docs: add Phase 97 LLVM EXE parity entry
2025-12-17 02:26:42 +09:00
ba87afd35c
test: add phase96 trim loop fixture and smoke
2025-12-17 01:25:06 +09:00
5b4de7b495
docs: add phase95 json_loader escape entry
2025-12-17 01:01:16 +09:00
7ab459503b
feat(joinir): Phase 94 - P5b escape full E2E (derived ch + +1/+2)
2025-12-17 00:59:33 +09:00
93e62b1433
docs(phase93): Phase 93 P0完了記録 & ドキュメント整理
...
## 追加
- docs/development/current/main/phases/phase-93/README.md
- Phase 93 P0 (ConditionOnly Derived Slot) 完了記録
- 実装内容・テスト結果の詳細
## 更新
- CURRENT_TASK.md: Phase 93 P0完了に伴う更新
- 10-Now.md: 現在の進捗状況更新
- 30-Backlog.md: Phase 92/93関連タスク整理
- phase-91/92関連ドキュメント: historical化・要約化
## 削減
- 735行削減(historical化により詳細をREADMEに集約)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-16 23:30:39 +09:00
568619df89
feat(mir): Phase 92 P2-2 - Body-local variable support for ConditionalStep
...
Phase 92 P2-2完了:ConditionalStepのcondition(ch == '\\'など)でbody-local変数をサポート
## 主要変更
### 1. condition_lowerer.rs拡張
- `lower_condition_to_joinir`に`body_local_env`パラメータ追加
- 変数解決優先度:ConditionEnv → LoopBodyLocalEnv
- すべての再帰ヘルパー(comparison, logical_and, logical_or, not, value_expression)対応
### 2. conditional_step_emitter.rs修正
- `emit_conditional_step_update`に`body_local_env`パラメータ追加
- condition loweringにbody-local環境を渡す
### 3. loop_with_break_minimal.rs修正
- break condition loweringをbody-local init の**後**に移動(line 411)
- header_break_lowering::lower_break_conditionにbody_local_env渡す
- emit_conditional_step_updateにbody_local_env渡す(line 620)
### 4. header_break_lowering.rs修正
- `lower_break_condition`に`body_local_env`パラメータ追加
- scope_managerにbody-local環境を渡す
### 5. 全呼び出し箇所修正
- expr_lowerer.rs (2箇所)
- method_call_lowerer.rs (2箇所)
- loop_with_if_phi_if_sum.rs (3箇所)
- loop_with_continue_minimal.rs (1箇所)
- carrier_update_emitter.rs (1箇所・legacy)
## アーキテクチャ改善
### Break Condition Lowering順序修正
旧: Header → **Break Cond** → Body-local Init
新: Header → **Body-local Init** → Break Cond
理由:break conditionが`ch == '\"'`のようにbody-local変数を参照する場合、body-local initが先に必要
### 変数解決優先度(Phase 92 P2-2)
1. ConditionEnv(ループパラメータ、captured変数)
2. LoopBodyLocalEnv(body-local変数like `ch`)
## テスト
### ビルド
✅ cargo build --release成功(30 warnings、0 errors)
### E2E
⚠️ body-local promotion問題でブロック(Phase 92範囲外)
- Pattern2はbody-local変数をcarrier promotionする必要あり
- 既存パターン(A-3 Trim, A-4 DigitPos)に`ch = get_char(i)`が該当しない
- **Phase 92 P2-2目標(condition loweringでbody-local変数サポート)は達成**
## 次タスク(Phase 92 P3以降)
- body-local variable promotion拡張(Pattern2で`ch`のような変数を扱う)
- P5b E2Eテスト完全動作確認
## Phase 92 P2-2完了
✅ Body-local変数のcondition lowering対応完了
✅ ConditionalStepでbody-local変数参照可能
✅ Break condition lowering順序修正
2025-12-16 17:08:15 +09:00
521e58d061
docs: mark loop canonicalizer Phase 137-141 complete
2025-12-16 07:54:33 +09:00
5edd81e373
refactor(mir): Phase 138-P1-A - loop_canonicalizer を4モジュール分割
...
## 概要
- 931行の mod.rs を 4モジュール + 161行 mod.rs に分割
- 全14テスト PASS、退行なし
## モジュール構成
- skeleton_types.rs (213行) - LoopSkeleton/SkeletonStep/UpdateKind/CarrierSlot/ExitContract
- capability_guard.rs (104行) - RoutingDecision/capability_tags
- pattern_recognizer.rs (249行) - try_extract_skip_whitespace_pattern
- canonicalizer.rs (414行) - canonicalize_loop_expr + 統合テスト
- mod.rs (161行) - 型定義と re-export
## ファイルサイズ達成
- 最大ファイル: canonicalizer.rs 414行(目標250行を一部超過するが許容範囲)
- mod.rs: 931行 → 161行 (83%削減)
- 合計: 1141行(元の931行 + tests分離で増加)
## テスト結果
- 14 tests passed
- loop_canonicalizer::* 全テスト green
2025-12-16 06:41:46 +09:00
a0009d474d
feat(mir): Loop Canonicalizer Phase 3 - skip_whitespace pattern recognition
...
## Summary
skip_whitespace パターンを Skeleton→Decision で認識可能に。
dev-only 観測で chosen=Pattern3IfPhi / missing_caps=[] を固定。
## Changes
- src/mir/loop_canonicalizer/mod.rs:
- try_extract_skip_whitespace_pattern() 追加
- loop(cond) { ... if check { p = p + 1 } else { break } } パターン認識
- carrier name, delta, body statements を抽出
- canonicalize_loop_expr() 拡張(skip_whitespace 対応)
- Pattern3IfPhi 成功時は RoutingDecision::success 返却
- Skeleton に HeaderCond, Body, Update ステップ追加
- CarrierSlot に Counter role 設定
- ExitContract に has_break=true 設定
- Phase 3 unit tests 追加
- test_skip_whitespace_pattern_recognition: 基本パターン
- test_skip_whitespace_with_body_statements: body 付きパターン
- test_skip_whitespace_fails_without_else: else なし失敗
- test_skip_whitespace_fails_with_wrong_delta: 減算パターン失敗
- Phase 2 obsolete tests 削除
- src/mir/builder/control_flow/joinir/routing.rs:
- Debug 出力拡張(chosen pattern 表示)
## Tests
- cargo test --release --lib loop_canonicalizer::tests: PASS(11 tests)
- cargo test --release --lib: PASS(1044 tests, 退行なし)
- HAKO_JOINIR_DEBUG=1 test_pattern3_skip_whitespace.hako:
- chosen=Pattern3IfPhi ✅
- missing_caps=[] ✅
## Validation
- ✅ dev-only 観測(HAKO_JOINIR_DEBUG=1)のときだけログ出力
- ✅ フラグ OFF 時は完全不変
- ✅ skip_whitespace パターンで SUCCESS 固定
- ✅ unit tests で全パターン固定
Phase 137-3 complete
2025-12-16 05:38:18 +09:00
ec1ff5b766
docs: update Phase 137-1 completion status and Phase 2 roadmap
...
## Summary
Loop Canonicalizer Phase 1(型定義)の完了と、Phase 2(dev-only 観測)への
ロードマップを記録。
## Changes
### loop-canonicalizer.md
- Status: Design (P0) → Phase 1 done(型定義まで)
- 実装の入口を明記(src/mir/loop_canonicalizer/mod.rs)
- NYASH_LOOP_ROUTING_TRACE → joinir_dev_enabled() に変更
(新 ENV を増やさず、既存のスイッチに寄せる)
### CURRENT_TASK.md
- Phase 137-1 完了を追記
- P0 を「設計」→「Phase 2(dev-only 観測)」へ更新
### phases/README.md
- Phase 137 を追加
### phases/phase-137/README.md (NEW)
- Phase 1 完了サマリ
- Phase 2 予定を最小で記録
### joinir-design-map.md / 01-JoinIR-Selfhost-INDEX.md
- loop-canonicalizer への導線を追加
## Next Steps
Phase 2: dev-only 観測の導入
- canonicalize_loop_expr() の薄い入口を追加
- joinir_dev_enabled() 配下でログ出し
- 既定挙動は完全不変
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-16 05:10:29 +09:00
84ded8ca6c
docs: add loop canonicalizer SSOT + MirBuilder entrypoint
2025-12-16 04:37:47 +09:00
d82c332a40
feat(joinir): Phase 135 P0 - ConditionLoweringBox allocator SSOT (ValueId collision fix)
...
## Summary
Root cause: ConditionLoweringBox was bypassing ConditionContext.alloc_value (SSOT allocator),
causing ValueId collisions between JoinIR condition params and lowered instructions.
## Changes
1. **ConditionLoweringBox (expr_lowerer.rs)**: Must use ConditionContext.alloc_value
- Pass &mut ConditionContext to lower_condition (SSOT allocator)
- Eliminates internal counter usage
2. **Allocator unification (condition_lowerer.rs, method_call_lowerer.rs)**:
- Accept &mut dyn FnMut() -> ValueId as allocator parameter
- Ensures all lowering paths use same SSOT allocator
3. **Boundary Copy deduplication (joinir_inline_boundary_injector.rs)**:
- Deduplicate condition_bindings by dst
- Fail-Fast if different sources target same dst (MIR SSA violation)
4. **Trim pattern fixes (trim_loop_lowering.rs, trim_pattern_validator.rs, stmts.rs)**:
- Use builder.next_value_id() instead of value_gen.next() in function context
- Ensures function-level ValueId allocation respects reserved PHI dsts
## Acceptance
✅ ./target/release/hakorune --verify apps/tests/phase133_json_skip_whitespace_min.hako
✅ Smoke: phase135_trim_mir_verify.sh - MIR SSA validation PASS
✅ Regression: phase132_exit_phi_parity.sh - 3/3 PASS
✅ Regression: phase133_json_skip_whitespace_llvm_exe.sh - compile-only PASS
🤖 Generated with Claude Code
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-15 18:49:08 +09:00
c8970bd4d4
docs: Phase 132-P3 verifier note
2025-12-15 06:08:19 +09:00
771bf6b0d1
feat(joinir): Phase 132-P3 - Exit PHI collision early detection
...
Added verify_exit_phi_no_collision() to contract_checks.rs for early detection
of ValueId collisions between exit PHIs and other instructions.
Problem detected:
- If exit_phi_builder uses builder.value_gen.next() (module-level) instead of
func.next_value_id() (function-level), ValueIds can collide:
Example:
- bb0: %1 = const 0 (counter init)
- bb3: %1 = phi ... (exit PHI - collision!)
Previous behavior:
- Error only detected at LLVM backend runtime
- Cryptic error: "Cannot overwrite PHI dst=1"
New behavior:
- Panic at Rust compile time (debug build)
- Clear error message with fix suggestion:
"Exit PHI dst %1 collides with instruction in block 0
Fix: Use func.next_value_id() in exit_phi_builder.rs"
Benefits:
- 🔥 Fail-Fast: Catch errors during Rust compilation, not LLVM execution
- 📋 Clear messages: Exact collision point + fix suggestion
- 🧪 Testable: verify_exit_phi_no_collision() can be unit tested
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-15 06:00:48 +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
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