feat(llvm): Phase 97 - Call/PHI/Plugin強化 + リファクタリング準備

## 概要
LLVM backend のCall処理、PHI wiring、Plugin loader を強化。
次のリファクタリング(箱化モジュール化)のための準備も含む。

## 変更内容

### LLVM Call処理強化
- `mir_call/__init__.py`: Call ルーティングロジック改善
- `mir_call/global_call.py`: print処理の marshal強化
- `mir_call/method_call.py`: メソッド呼び出し処理改善
- `boxcall.py`: BoxCall処理改善

### PHI処理強化
- `phi_manager.py`: PHI管理改善
- `phi_wiring/wiring.py`: PHI配線ロジック強化(+17行)
- `phi_wiring/tagging.py`: Type tagging改善
- `resolver.py`: Value解決ロジック強化(+34行)

### Copy伝播
- `copy.py`: Copy命令のType tag伝播追加(+10行)

### Plugin loader強化
- `library.rs`: エラー出力改善、[plugin/missing]ログ追加(+34行)
- fail-fast強化

### テスト
- `phase97_json_loader_escape_llvm_exe.sh`: Phase 97 E2Eテスト追加
- `phase97_next_non_ws_llvm_exe.sh`: Phase 97 E2Eテスト追加

### その他
- `nyash_kernel/lib.rs`: Kernel側の改善(+23行)

## 統計
- 14ファイル変更
- +256行 / -53行 = +203 net

## 次のリファクタリング準備
以下の箇所がリファクタリング対象として識別済み:
1. Call ルーティング箱の明文化
2. print の marshal 箱
3. TypeFacts/Tagging 箱の一本化
4. PHI Snapshot 契約のSSOT
5. Plugin loader のエラー出力統合

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-17 03:51:03 +09:00
parent 1a0d9ce8a0
commit 65763c1ed6
14 changed files with 256 additions and 53 deletions

View File

@ -2,6 +2,7 @@ use super::specs;
use super::util::dbg_on;
use super::PluginLoaderV2;
use crate::bid::{BidError, BidResult};
use crate::config::env::env_bool;
use crate::config::nyash_toml_v2::LibraryDefinition;
use crate::runtime::get_global_ring0;
use libloading::{Library, Symbol};
@ -11,6 +12,10 @@ use std::sync::Arc;
pub(super) fn load_all_plugins(loader: &PluginLoaderV2) -> BidResult<()> {
let config = loader.config.as_ref().ok_or(BidError::PluginError)?;
// Strict mode policy (SSOT): reuse JoinIR strict flag to avoid env-var sprawl.
// - strict=0: Phase 134 best-effort load (continue on failure)
// - strict=1: Fail-Fast on first plugin/library load error
let strict = env_bool("HAKO_JOINIR_STRICT");
// Phase 134 P0: Best-effort loading
// Failures don't stop the entire load process
@ -24,8 +29,11 @@ pub(super) fn load_all_plugins(loader: &PluginLoaderV2) -> BidResult<()> {
for (lib_name, lib_def) in lib_items {
match load_plugin(loader, lib_name, lib_def) {
Ok(()) => loaded_count += 1,
Err(_) => {
Err(e) => {
failed_count += 1;
if strict {
return Err(e);
}
// Log already printed by load_plugin, continue
}
}
@ -38,8 +46,11 @@ pub(super) fn load_all_plugins(loader: &PluginLoaderV2) -> BidResult<()> {
for (plugin_name, root) in plugin_items {
match load_plugin_from_root(loader, plugin_name, root) {
Ok(()) => loaded_count += 1,
Err(_) => {
Err(e) => {
failed_count += 1;
if strict {
return Err(e);
}
// Log already printed by load_plugin_from_root, continue
}
}
@ -82,7 +93,24 @@ pub(super) fn load_plugin(
}
}
}
let lib_path = lib_path.unwrap_or_else(|| base.to_path_buf());
let lib_path = match lib_path {
Some(path) => path,
None => {
let mut attempted = candidates
.iter()
.map(|p| p.display().to_string())
.collect::<Vec<_>>();
attempted.sort();
attempted.dedup();
get_global_ring0().log.error(&format!(
"[plugin/missing] {}: no existing file for configured path='{}' (attempted={})",
lib_name,
base.display(),
attempted.join(", ")
));
return Err(BidError::PluginError);
}
};
if dbg_on() {
get_global_ring0().log.debug(&format!(
"[PluginLoaderV2] load_plugin: lib='{}' path='{}'",