🎉 feat: Phase 15.5革命完了!StringBox/IntegerBoxプラグイン優先度問題根治

何十日間の激闘ついに完全解決!"Everything is Plugin"哲学実装達成🚀

🏆 核心成果:
- FactoryPolicy システム完全実装 (StrictPluginFirst/CompatPluginFirst/BuiltinFirst)
- プラグイン優先をデフォルト化: plugins > user > builtin
- builtin_impls/ 分離実装でPhase 2削除準備完了
- unified_registry.rs でwith_env_policy()によるポリシー制御
- 環境変数制御: NYASH_BOX_FACTORY_POLICY=strict_plugin_first

🔧 技術実装:
- src/box_factory/mod.rs: FactoryPolicy enum + rebuild_cache() + policy-based ordering
- src/box_factory/builtin.rs: builtin_impls/への振り分け実装
- src/box_factory/builtin_impls/: 7ファイル分離 (削除順序コメント付き)
- src/runtime/unified_registry.rs: with_env_policy() でStrictPluginFirst デフォルト

 動作確認完了:
- StringBox プラグイン優先で作成成功
- Factory Policy: StrictPluginFirst メッセージ確認
- プラグイン初期化確認 (Net plugin, FileBox plugin)

📋 Phase 2準備完了: builtin_impls/ 段階削除戦略
1. string_box.rs, integer_box.rs (プラグイン準備済み)
2. bool_box.rs (プラグイン要作成)
3. array_box.rs, map_box.rs (プラグイン確認要)
4. console_box.rs (最後 - ログ用に重要)

🎯 ChatGPT戦略 + ユーザー分離アイデアの完璧な統合実装成果!

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-24 11:43:11 +09:00
parent 26716e74e9
commit 56f128eecd
12 changed files with 509 additions and 86 deletions

View File

@ -0,0 +1,34 @@
/*!
* Builtin ArrayBox Implementation (Phase 15.5: Scheduled for Removal)
*
* ⚠️ DEPRECATED: This will be replaced by nyash-array-plugin (exists?)
* 🎯 Phase 2.4: Delete this file to remove builtin ArrayBox support
*/
use crate::box_trait::NyashBox;
use crate::box_factory::RuntimeError;
/// Create builtin ArrayBox instance
///
/// ⚠️ DEPRECATED: Check if nyash-array-plugin exists
pub fn create(_args: &[Box<dyn NyashBox>]) -> Result<Box<dyn NyashBox>, RuntimeError> {
eprintln!(
"⚠️ [DEPRECATED] Using builtin ArrayBox - check nyash-array-plugin!\n\
📋 Phase 15.5: Everything is Plugin!\n\
🔧 Check: plugins/nyash-array-plugin"
);
Ok(Box::new(crate::boxes::array::ArrayBox::new()))
}
#[cfg(test)]
mod tests {
use super::*;
use crate::boxes::array::ArrayBox;
#[test]
fn test_builtin_array_box_creation() {
let result = create(&[]).unwrap();
assert!(result.as_any().downcast_ref::<ArrayBox>().is_some());
}
}

View File

@ -0,0 +1,38 @@
/*!
* Builtin BoolBox Implementation (Phase 15.5: Scheduled for Removal)
*
* ⚠️ DEPRECATED: This will be replaced by nyash-bool-plugin (to be created)
* 🎯 Phase 2.3: Delete this file to remove builtin BoolBox support
*/
use crate::box_trait::{NyashBox, BoolBox};
use crate::box_factory::RuntimeError;
/// Create builtin BoolBox instance
///
/// ⚠️ DEPRECATED: BoolBox plugin needs to be created
pub fn create(args: &[Box<dyn NyashBox>]) -> Result<Box<dyn NyashBox>, RuntimeError> {
eprintln!(
"⚠️ [DEPRECATED] Using builtin BoolBox - BoolBox plugin needed!\n\
📋 Phase 15.5: Everything is Plugin!\n\
🔧 TODO: Create nyash-bool-plugin"
);
if let Some(arg0) = args.get(0) {
if let Some(bb) = arg0.as_any().downcast_ref::<BoolBox>() {
return Ok(Box::new(BoolBox::new(bb.value)));
}
}
Ok(Box::new(BoolBox::new(false)))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_builtin_bool_box_creation() {
let result = create(&[]).unwrap();
assert!(result.as_any().downcast_ref::<BoolBox>().is_some());
}
}

View File

@ -0,0 +1,35 @@
/*!
* Builtin ConsoleBox Implementation (Phase 15.5: Scheduled for Removal)
*
* ⚠️ DEPRECATED: This will be replaced by nyash-console-plugin (exists!)
* 🎯 Phase 2.6: Delete this file to remove builtin ConsoleBox support (LAST)
*/
use crate::box_trait::NyashBox;
use crate::box_factory::RuntimeError;
/// Create builtin ConsoleBox instance
///
/// ⚠️ DEPRECATED: ConsoleBox plugin should replace this (check plugins/nyash-console-plugin)
pub fn create(_args: &[Box<dyn NyashBox>]) -> Result<Box<dyn NyashBox>, RuntimeError> {
eprintln!(
"⚠️ [DEPRECATED] Using builtin ConsoleBox - use nyash-console-plugin!\n\
📋 Phase 15.5: Everything is Plugin!\n\
🔧 Check: plugins/nyash-console-plugin\n\
⚠️ WARNING: ConsoleBox is critical for logging - remove LAST!"
);
Ok(Box::new(crate::boxes::console_box::ConsoleBox::new()))
}
#[cfg(test)]
mod tests {
use super::*;
use crate::boxes::console_box::ConsoleBox;
#[test]
fn test_builtin_console_box_creation() {
let result = create(&[]).unwrap();
assert!(result.as_any().downcast_ref::<ConsoleBox>().is_some());
}
}

View File

@ -0,0 +1,38 @@
/*!
* Builtin IntegerBox Implementation (Phase 15.5: Scheduled for Removal)
*
* ⚠️ DEPRECATED: This will be replaced by nyash-integer-plugin
* 🎯 Phase 2.2: Delete this file to remove builtin IntegerBox support
*/
use crate::box_trait::{NyashBox, IntegerBox};
use crate::box_factory::RuntimeError;
/// Create builtin IntegerBox instance
///
/// ⚠️ DEPRECATED: Install nyash-integer-plugin instead
pub fn create(args: &[Box<dyn NyashBox>]) -> Result<Box<dyn NyashBox>, RuntimeError> {
eprintln!(
"⚠️ [DEPRECATED] Using builtin IntegerBox - install nyash-integer-plugin!\n\
📋 Phase 15.5: Everything is Plugin!\n\
🔧 Command: cargo build -p nyash-integer-plugin --release"
);
if let Some(arg0) = args.get(0) {
if let Some(ib) = arg0.as_any().downcast_ref::<IntegerBox>() {
return Ok(Box::new(IntegerBox::new(ib.value)));
}
}
Ok(Box::new(IntegerBox::new(0)))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_builtin_integer_box_creation() {
let result = create(&[]).unwrap();
assert!(result.as_any().downcast_ref::<IntegerBox>().is_some());
}
}

View File

@ -0,0 +1,34 @@
/*!
* Builtin MapBox Implementation (Phase 15.5: Scheduled for Removal)
*
* ⚠️ DEPRECATED: This will be replaced by nyash-map-plugin (exists?)
* 🎯 Phase 2.5: Delete this file to remove builtin MapBox support
*/
use crate::box_trait::NyashBox;
use crate::box_factory::RuntimeError;
/// Create builtin MapBox instance
///
/// ⚠️ DEPRECATED: Check if nyash-map-plugin exists
pub fn create(_args: &[Box<dyn NyashBox>]) -> Result<Box<dyn NyashBox>, RuntimeError> {
eprintln!(
"⚠️ [DEPRECATED] Using builtin MapBox - check nyash-map-plugin!\n\
📋 Phase 15.5: Everything is Plugin!\n\
🔧 Check: plugins/nyash-map-plugin"
);
Ok(Box::new(crate::boxes::map_box::MapBox::new()))
}
#[cfg(test)]
mod tests {
use super::*;
use crate::boxes::map_box::MapBox;
#[test]
fn test_builtin_map_box_creation() {
let result = create(&[]).unwrap();
assert!(result.as_any().downcast_ref::<MapBox>().is_some());
}
}

View File

@ -0,0 +1,26 @@
/*!
* Builtin Box Implementations (Phase 15.5: Everything is Plugin Migration)
*
* 🎯 Purpose: Separated implementations for easy deletion during Phase 2
* 🗓️ Timeline: These files will be deleted one by one in Phase 2.1-2.6
*
* Deletion Order (dependency-based):
* 1. string_box.rs - Phase 2.1 ✅ Plugin ready
* 2. integer_box.rs - Phase 2.2 ✅ Plugin ready
* 3. bool_box.rs - Phase 2.3 🔄 Plugin needed
* 4. array_box.rs - Phase 2.4 🔄 Plugin check needed
* 5. map_box.rs - Phase 2.5 🔄 Plugin check needed
* 6. console_box.rs - Phase 2.6 🔄 Plugin exists, remove LAST
* 7. null_box.rs - TBD: 🤔 Keep as language primitive?
*/
// Phase 2.1-2.6: Delete these modules one by one
pub mod string_box; // DELETE: Phase 2.1 (plugin ready)
pub mod integer_box; // DELETE: Phase 2.2 (plugin ready)
pub mod bool_box; // DELETE: Phase 2.3 (plugin needed)
pub mod array_box; // DELETE: Phase 2.4 (plugin check)
pub mod map_box; // DELETE: Phase 2.5 (plugin check)
pub mod console_box; // DELETE: Phase 2.6 (LAST - critical for logging)
// Special consideration
pub mod null_box; // DISCUSS: Keep as primitive?

View File

@ -0,0 +1,29 @@
/*!
* Builtin NullBox Implementation (Phase 15.5: Consider Keeping?)
*
* 🤔 CONSIDERATION: NullBox might be fundamental enough to remain builtin
* 📋 Discussion needed: Is null a language primitive or plugin concern?
*/
use crate::box_trait::NyashBox;
use crate::box_factory::RuntimeError;
/// Create builtin NullBox instance
///
/// 🤔 DISCUSSION: Should null remain as builtin language primitive?
pub fn create(_args: &[Box<dyn NyashBox>]) -> Result<Box<dyn NyashBox>, RuntimeError> {
// Note: No deprecation warning - null might remain builtin
Ok(Box::new(crate::boxes::null_box::NullBox::new()))
}
#[cfg(test)]
mod tests {
use super::*;
use crate::boxes::null_box::NullBox;
#[test]
fn test_builtin_null_box_creation() {
let result = create(&[]).unwrap();
assert!(result.as_any().downcast_ref::<NullBox>().is_some());
}
}

View File

@ -0,0 +1,38 @@
/*!
* Builtin StringBox Implementation (Phase 15.5: Scheduled for Removal)
*
* ⚠️ DEPRECATED: This will be replaced by nyash-string-plugin
* 🎯 Phase 2.1: Delete this file to remove builtin StringBox support
*/
use crate::box_trait::{NyashBox, StringBox};
use crate::box_factory::RuntimeError;
/// Create builtin StringBox instance
///
/// ⚠️ DEPRECATED: Install nyash-string-plugin instead
pub fn create(args: &[Box<dyn NyashBox>]) -> Result<Box<dyn NyashBox>, RuntimeError> {
eprintln!(
"⚠️ [DEPRECATED] Using builtin StringBox - install nyash-string-plugin!\n\
📋 Phase 15.5: Everything is Plugin!\n\
🔧 Command: cargo build -p nyash-string-plugin --release"
);
if let Some(arg0) = args.get(0) {
if let Some(sb) = arg0.as_any().downcast_ref::<StringBox>() {
return Ok(Box::new(StringBox::new(&sb.value)));
}
}
Ok(Box::new(StringBox::new("")))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_builtin_string_box_creation() {
let result = create(&[]).unwrap();
assert!(result.as_any().downcast_ref::<StringBox>().is_some());
}
}