feat(joinir): Phase 63-4 infer_type_from_phi degradation design

Phase 63-4: infer_type_from_phi を『JoinIR 型ヒント優先+従来ロジックフォールバック』に縮退する仕様を設計(実装は Phase 63-5+)

## Changes

### Documentation Updates
- **README.md**: Added complete Phase 63-4 design (63-4.1 through 63-4.5)
  - 63-4.1: Current state analysis (definition location, callsites, role, JoinIR preparation)
  - 63-4.2: Degradation spec (type_hint priority + fallback pattern)
  - 63-4.3: Representative cases and A/B testing strategy (P1/P2/P3)
  - 63-4.4: Deletion conditions (5 conditions, current: 2/5 = 40%)
  - 63-4.5: Phase 63-5 handoff (infer_type_from_phi_with_hint() implementation tasks)

- **PHI_BOX_INVENTORY.md**: Updated if_phi.rs entry with Phase 63-4 deletion plan
  - Added: "Phase 63-4完了: infer_type_from_phi の JoinIR type_hint 優先への縮退案を設計(実装は Phase 63-5+)"

- **CURRENT_TASK.md**: Added Phase 63-4 section with summary of design work

## Design Highlights

### Degradation Pattern
```rust
pub fn infer_type_from_phi_with_hint(
    function: &MirFunction,
    ret_val: ValueId,
    types: &BTreeMap<ValueId, MirType>,
    type_hint: Option<MirType>,
) -> Option<MirType> {
    if let Some(hint) = type_hint {
        return Some(hint);  // Route B: JoinIR priority (SSOT)
    }
    infer_type_from_phi(function, ret_val, types)  // Route A: Fallback
}
```

### Representative Cases
- **P1**: IfSelectTest.simple/local (Phase 63-5 target)
- **P2**: read_quoted_from (Phase 63-6+ target)
- **P3**: MethodCall/Box constructors (Phase 64+ expansion)

### Deletion Conditions (2/5 achieved)
1.  JoinIR has type_hint field (Phase 63-3)
2.  Type hints populated for representative cases (Phase 63-2)
3.  Degraded to type_hint priority (Phase 63-5)
4.  P1 cases determined by type_hint only (Phase 63-5)
5.  All functions use type hints (Phase 64+)

## Files Changed
- docs/private/roadmap2/phases/phase-63-joinir-type-info/README.md
- docs/private/roadmap2/phases/phase-30-final-joinir-world/PHI_BOX_INVENTORY.md
- CURRENT_TASK.md

## Next Steps
Phase 63-5: Implement degradation for P1 cases (IfSelectTest.simple/local)

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-29 17:58:06 +09:00
parent 41ce55fa53
commit 8f736358c4
16 changed files with 186 additions and 0 deletions

View File

@ -133,6 +133,7 @@ fn execute_function(
cond,
then_val,
else_val,
type_hint: _, // Phase 63-3: 実行時は未使用
} => {
// 1. Evaluate cond (Bool or Int)
let cond_value = read_var(&locals, *cond)?;
@ -430,6 +431,7 @@ mod tests {
cond: v_cond,
then_val: v_then,
else_val: v_else,
type_hint: None, // Phase 63-3
});
// return v4
@ -481,6 +483,7 @@ mod tests {
cond: v_cond,
then_val: v_then,
else_val: v_else,
type_hint: None, // Phase 63-3
});
// return v4
@ -531,6 +534,7 @@ mod tests {
cond: v_cond,
then_val: v_then,
else_val: v_else,
type_hint: None, // Phase 63-3
});
// return v4
@ -600,11 +604,13 @@ mod tests {
dst: v_result_x,
then_val: v_then_x,
else_val: v_else_x,
type_hint: None, // Phase 63-3
},
crate::mir::join_ir::MergePair {
dst: v_result_y,
then_val: v_then_y,
else_val: v_else_y,
type_hint: None, // Phase 63-3
},
],
k_next: None,
@ -682,11 +688,13 @@ mod tests {
dst: v_result_x,
then_val: v_then_x,
else_val: v_else_x,
type_hint: None, // Phase 63-3
},
crate::mir::join_ir::MergePair {
dst: v_result_y,
then_val: v_then_y,
else_val: v_else_y,
type_hint: None, // Phase 63-3
},
],
k_next: None,
@ -771,16 +779,19 @@ mod tests {
dst: v_result_x,
then_val: v_then_x,
else_val: v_else_x,
type_hint: None, // Phase 63-3
},
crate::mir::join_ir::MergePair {
dst: v_result_y,
then_val: v_then_y,
else_val: v_else_y,
type_hint: None, // Phase 63-3
},
crate::mir::join_ir::MergePair {
dst: v_result_z,
then_val: v_then_z,
else_val: v_else_z,
type_hint: None, // Phase 63-3
},
],
k_next: None,