feat(llvm/phi): Phase 277 P1.5 - structured error handling + import organization

## Changes
- P1.5.1: import整理 - debug_helper imports をモジュールトップへ移動
- P1.5.2: PhiStrictError 箱化 - エラーハンドリング構造化 (error_helpers.py新規)
- P1.5.3: wiring.py で PhiStrictError を使用 - 3箇所のエラーパターン統一

## Benefits
-  エラーメッセージ生成の一元化(SSOT化)
-  Python import 慣習準拠(関数内import削除)
-  エラーコンテキスト構造化(block_id/dst_vid/next_file)

## Testing
 strict=OFF - passes without errors
 strict=ON - passes without errors
 debug mode - verification connected and running

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-22 14:59:24 +09:00
parent 757193891f
commit 939efbca9b
5 changed files with 157 additions and 35 deletions

View File

@ -2,9 +2,6 @@
## Current Focus (next)
- Phase 277 P0/P1docs+validation: `docs/development/current/main/phases/phase-277/README.md`
- PHI型推論の導線/責務/SSOT を docs に固定Phase 275/276 の実装を「読める形」にする)
- PHI順序PHI → non-PHI → terminator検証の fail-fast を強化
- Phase 278cleanup: `docs/development/current/main/phases/phase-278/README.md`
- Phase 277 P2 の後方互換旧PHI env varを撤去して、1セットに収束させる
- Phase 279impl: `docs/development/current/main/phases/phase-279/README.md`
@ -16,6 +13,7 @@
- Phase 275 P0A1/B2/C2 coercion SSOT: `docs/development/current/main/phases/phase-275/README.md`
- Phase 276 P0quick wins / type_helper SSOT: `docs/development/current/main/phases/phase-276/README.md`
- Phase 277 P1PHI strict fail-fast: `docs/development/current/main/phases/phase-277/README.md`
- Phase 277 P2PHI env var 統合): `docs/development/current/main/phases/phase-277/README.md`
---

View File

@ -0,0 +1,58 @@
# Phase 277 P1: PHI順序検証強化fail-fast— 完了報告
Status: ✅ completed (2025-12-22)
Goal:
- strict mode`NYASH_LLVM_PHI_STRICT=1`で、PHI順序/配線失敗を “原因箇所で止める” ようにする。
Scope:
- LLVM harnessPython側のみ
- 新しい環境変数は追加しないPhase 277 P2 で統合した3つのみ
- JoinIR/Rust側のパイプライン統一は対象外根治は Phase 279
---
## Changes
### 1) PHI created after terminator を strict で fail-fast
Target:
- `src/llvm_py/phi_wiring/wiring.py``ensure_phi`
Behavior:
- strict=ON: RuntimeErrorblock_id/dst_vid を含む)
- strict=OFF: warning のみ(既定挙動維持)
### 2) PHI incoming 解決の “silent fallback 0” を strict で禁止
Target:
- `src/llvm_py/phi_wiring/wiring.py``wire_incomings`
Behavior:
- strict=ON: “incoming unresolved / type coercion failed” を RuntimeError
- strict=OFF: 従来どおり 0 fallback互換維持
### 3) PHI ordering verifier を実行導線に接続
Target:
- `src/llvm_py/builders/function_lower.py`
- `src/llvm_py/phi_placement.py::verify_phi_ordering`
Behavior:
- strict=ON: ordering NG を RuntimeErrorblock list を含む)
- debug=ON: ordering のサマリを stderr に出力
---
## Verification
- strict=OFF: 既存 fixture が退行しないことを確認
- strict=ON: 既存 fixture が正常系として PASS違反がないことを確認
- debug=ON: verify の接続がログで確認できることを確認
---
## Notes / Next
- 旧 env var の後方互換性削除は Phase 278。
- “2本のコンパイラ型伝播パイプライン差” 根治は Phase 279。

View File

@ -29,7 +29,7 @@ Phase 275/276で完了したFloat型PHI対応・型取得SSOT化の後続改善
- 指示書Claude Code:
- `docs/development/current/main/phases/phase-277/P0-INSTRUCTIONS.md`
### Phase 277 P1: PHI順序検証強化予定)
### Phase 277 P1: PHI順序検証強化fail-fast
- 目的: PHI命令の配置順序検証を強化
- 内容:
@ -40,6 +40,8 @@ Phase 275/276で完了したFloat型PHI対応・型取得SSOT化の後続改善
- `docs/development/current/main/phases/phase-277/P1-VALIDATION.md`
- 指示書Claude Code:
- `docs/development/current/main/phases/phase-277/P1-INSTRUCTIONS.md`
- 完了報告:
- `docs/development/current/main/phases/phase-277/P1-COMPLETION.md`
### Phase 277 P2: PHI関連環境変数の統合・整理 ✅
@ -91,9 +93,12 @@ NYASH_LLVM_PHI_STRICT=1
```
phase-277/
├── README.md # 本ファイルPhase 277概要
├── P0-INSTRUCTIONS.md # P0指示書Claude Code
├── P2-COMPLETION.md # P2完了報告
├── P0-DESIGN.md # P0設計ドキュメントdocs
── P1-VALIDATION.md # P1検証強化ドキュメントvalidation
── P1-INSTRUCTIONS.md # P1指示書Claude Code
├── P1-VALIDATION.md # P1検証強化ドキュメントvalidation
└── P1-COMPLETION.md # P1完了報告
```
---