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>
This commit is contained in:
nyash-codex
2025-12-15 18:49:08 +09:00
parent e8e4779942
commit d82c332a40
15 changed files with 186 additions and 70 deletions

View File

@ -24,6 +24,9 @@
- LLVM Python: PHI を落とす/上書きする経路を除去PHI SSOT を保護)
- JoinIR merge: exit PHI dst の allocator を function-level に統一ValueId 衝突を排除)
- debug-only: Exit PHI collision を早期検出する verifier を追加LLVM 実行時に壊れる前に Fail-Fast
- **Phase 133 完了**: Promoted carrier の `join_id` 解決Trimを SSOT に寄せて根治smoke は compile-only
- **Phase 134 完了**: Plugin loader best-effort loading決定的順序 + failure 集約 + 継続)を導入。
- **Phase 135 実装**: ConditionLoweringBox が allocator SSOT を無視して ValueId 衝突を起こす問題を根治(検証はローカルで実施)。
- **Phase 88 完了**: continue + 可変ステップi=i+const 差分)を dev-only fixture で固定、StepCalculator Box 抽出。
- **Phase 89 完了**: P0ContinueReturn detector+ P1lowering 実装)完了。
- **Phase 90 完了**: ParseStringComposite + `Null` literal + ContinueReturn同一値の複数 return-ifを dev-only fixture で固定。
@ -48,7 +51,21 @@
## 次の指示書(優先順位)
### P0: Docs 整備(数の増殖を止める
### P0: Phase 135 検証Trim fixture の `--verify` を緑に固定
目的:
- `apps/tests/phase133_json_skip_whitespace_min.hako` で発生していた MIR SSA 破綻ValueId 重複)を後戻りしない形で固定する。
やること:
1. `./target/release/hakorune --verify apps/tests/phase133_json_skip_whitespace_min.hako` が PASS することを確認
2. 必要なら integration smoke を追加quick は増やさない)
3. Phase 文書を更新: `docs/development/current/main/phases/phase-135/README.md`
受け入れ基準:
- `--verify` が PASS
- 既存の Phase 132/133/134 の integration smoke が退行しない
### P1: Docs 整備(数の増殖を止める)
**目的**: SSOT への集約と導線整備Phase 8690 の情報が散らばらない状態にする)