feat(joinir): Phase 66 - Ownership-Relay Multihop Implementation (dev-only)

Phase 65設計に基づき、relay_path.len() > 1 を analysis/plan 層で受理するよう実装。

Key changes:
- plan_to_lowering.rs: relay_path.len() > 1 制限撤去 + 構造的 Fail-Fast 維持
  - relay_path.is_empty() → Err(loop relay は最低 1 hop)
  - relay_path[0] != plan.scope_id → Err(この scope が最初の hop)
  - relay.owner_scope == plan.scope_id → Err(relay と owned は排他)
  - owned_vars ∩ relay_writes ≠ ∅ → Err(同名は不変条件違反)

- ast_analyzer.rs: 3階層 multihop テスト追加
  - multihop_relay_detected_for_3_layer_nested_loops

Unit tests (plan_to_lowering):
- test_relay_multi_hop_accepted_in_with_relay
- test_relay_path_empty_rejected_in_with_relay
- test_relay_path_not_starting_at_plan_scope_rejected
- test_relay_owner_same_as_plan_scope_rejected
- test_owned_and_relay_same_name_rejected

Tests: normalized_dev 49/49 PASS, lib 947/947 PASS
Design: Analysis-only, no behavior change in production lowering

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-12 23:33:16 +09:00
parent ba68fb2bad
commit 5c75506dcc
4 changed files with 285 additions and 14 deletions

View File

@ -545,3 +545,39 @@ OwnershipPlan {
| **relay_path** | 内→外の順でrelayを経由するスコープIDのリストwriter自身とownerは含まない |
| **Exit PHI** | Owner loopの出口でrelay変数をmergeするPHI命令 |
| **Fail-Fast** | 不正なパターンを検出して即座にErrを返す設計方針 |
---
## Phase 66 Implementation Status
**Phase 66 Implementation (2025-12-12)**: ✅ **COMPLETED**
Phase 66では `plan_to_p2_inputs_with_relay` の multihop 受理ロジックを実装完了。
### 実装済みチェック
- [x] `plan_to_lowering.rs` の relay_path.len() > 1 制限撤去
- [x] 構造的 Fail-Fast ガード実装:
- [x] `relay_path.is_empty()` → Errloop relay は最低 1 hop
- [x] `relay_path[0] != plan.scope_id` → Errこの scope が最初の hop
- [x] `relay.owner_scope == plan.scope_id` → Errrelay と owned は排他)
- [x] `owned_vars ∩ relay_writes ≠ ∅` → Err同名は不変条件違反
- [x] ユニットテスト追加:
- [x] `test_relay_multi_hop_accepted_in_with_relay` (multihop 受理)
- [x] `test_relay_path_empty_rejected_in_with_relay`
- [x] `test_relay_path_not_starting_at_plan_scope_rejected`
- [x] `test_relay_owner_same_as_plan_scope_rejected`
- [x] `test_owned_and_relay_same_name_rejected`
- [x] `ast_analyzer.rs` に 3階層 multihop テスト追加:
- [x] `multihop_relay_detected_for_3_layer_nested_loops`
### 検証結果
- normalized_dev: 49/49 PASS
- lib tests: 947/947 PASS
- Zero regressions
### 次フェーズPhase 67
- 本番 lowering への multihop 完全対応boundary/exit PHI のmerge実装
- Merge relay テスト追加(複数 inner loop → 共通 owner