feat(phase94): Box→Service conversion with actual registry integration
Phase 94完全達成 - UnifiedBoxRegistryから実際のBoxを取得してServiceに変換 ### 実装成果 - ✅ 6個のAdapter実装(StringBox/Integer/Bool/Array/Map/Console) - ✅ Dummy実装完全削除(38行削減) - ✅ Fail-Fast原則徹底(フォールバック削除) - ✅ テスト7/7 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: 6個のAdapter実装(+93行) - src/runtime/plugin_host.rs: 実際のBox取得ロジック(+54行)、Dummy削除(-17行) - src/runtime/mod.rs: フォールバック削除(-8行) ### 技術的成果 - Box<dyn NyashBox>を直接保持(型安全性確保) - registry.create_box()で実際のBoxインスタンス取得 - BuiltinBoxFactory登録でcore_required Boxes提供 ### 次のステップ Phase 95: Service traitメソッド実装(Console/String/Array/Map) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -59,31 +59,20 @@ pub use unified_registry::{
|
||||
// Use unified plugin loader (formerly v2)
|
||||
// pub use plugin_loader::{PluginLoaderV2 as PluginLoader, get_global_loader_v2 as get_global_loader}; // legacy
|
||||
|
||||
/// Runtime 初期化(Phase 93: 実装完了)
|
||||
/// Runtime 初期化(Phase 94: Fail-Fast 実装完了)
|
||||
///
|
||||
/// 環境変数 NYASH_USE_PLUGIN_HOST=1 で PluginHost を有効化。
|
||||
/// Phase 94: フォールバック削除 - 常に実際の Box を使用
|
||||
pub fn initialize_runtime(ring0: std::sync::Arc<Ring0Context>) -> Result<plugin_host::PluginHost, CoreInitError> {
|
||||
use crate::box_factory::UnifiedBoxRegistry;
|
||||
use crate::box_factory::builtin::BuiltinBoxFactory;
|
||||
|
||||
let registry = UnifiedBoxRegistry::with_env_policy();
|
||||
let mut registry = UnifiedBoxRegistry::with_env_policy();
|
||||
|
||||
// Phase 93: 環境変数で有効化(段階的展開)
|
||||
let use_plugin_host = std::env::var("NYASH_USE_PLUGIN_HOST")
|
||||
.ok()
|
||||
.and_then(|v| if v == "1" { Some(()) } else { None })
|
||||
.is_some();
|
||||
// Phase 94: BuiltinBoxFactory を登録して core_required Boxes を提供
|
||||
registry.register(std::sync::Arc::new(BuiltinBoxFactory::new()));
|
||||
|
||||
if use_plugin_host {
|
||||
let plugin_host = plugin_host::PluginHost::with_core_from_registry(ring0, ®istry)?;
|
||||
plugin_host.ensure_core_initialized();
|
||||
Ok(plugin_host)
|
||||
} else {
|
||||
// フォールバック(Phase 94 で削除予定)
|
||||
let core = core_services::CoreServices::dummy();
|
||||
Ok(plugin_host::PluginHost {
|
||||
ring0,
|
||||
core,
|
||||
optional: std::collections::HashMap::new(),
|
||||
})
|
||||
}
|
||||
// Phase 94: 常に実際の Box → Service 変換を使用(Fail-Fast原則)
|
||||
let plugin_host = plugin_host::PluginHost::with_core_from_registry(ring0, ®istry)?;
|
||||
plugin_host.ensure_core_initialized();
|
||||
Ok(plugin_host)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user