Files
hakorune/src/box_factory/builtin.rs

87 lines
2.7 KiB
Rust
Raw Normal View History

/*!
🎉 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>
2025-09-24 11:43:11 +09:00
* Builtin Box Factory (Phase 15.5: Transitioning to "Everything is Plugin")
*
🎉 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>
2025-09-24 11:43:11 +09:00
* MIGRATION IN PROGRESS: Phase 15.5 Core Box Unification
* 🎯 Goal: Remove builtin priority, make all Boxes plugin-based
* 📋 Current: builtin > user > plugin (PROBLEMATIC)
* 🚀 Target: plugin > user > builtin_compat (Phase 1) plugin-only (Phase 3)
*
* Implementation Strategy:
* - Phase 0: Separate implementations to builtin_impls/ (easy deletion)
* - Phase 1: 🚧 Add strict_plugin_first policy + access guards
* - Phase 2: 🔄 Delete builtin_impls/ files one by one
* - Phase 3: Delete BuiltinBoxFactory entirely
*/
use super::BoxFactory;
use super::RuntimeError;
🎉 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>
2025-09-24 11:43:11 +09:00
use crate::box_trait::NyashBox;
// Separated implementations (Phase 0: ✅ Complete)
use super::builtin_impls;
/// Factory for builtin Box types
pub struct BuiltinBoxFactory;
impl BuiltinBoxFactory {
pub fn new() -> Self {
Self
}
}
impl BoxFactory for BuiltinBoxFactory {
fn create_box(
&self,
name: &str,
args: &[Box<dyn NyashBox>],
) -> Result<Box<dyn NyashBox>, RuntimeError> {
🎉 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>
2025-09-24 11:43:11 +09:00
// Phase 0: ✅ Route to separated implementations (easy deletion)
match name {
🎉 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>
2025-09-24 11:43:11 +09:00
// Phase 2.1-2.2: DELETE when plugins are confirmed working
"StringBox" => builtin_impls::string_box::create(args),
"IntegerBox" => builtin_impls::integer_box::create(args),
// Phase 2.3: DELETE when BoolBox plugin is created
"BoolBox" => builtin_impls::bool_box::create(args),
// Phase 2.4-2.5: DELETE when collection plugins confirmed
"ArrayBox" => builtin_impls::array_box::create(args),
"MapBox" => builtin_impls::map_box::create(args),
// Phase 2.6: DELETE LAST (critical for logging)
"ConsoleBox" => builtin_impls::console_box::create(args),
Phase 21.4 Complete: FileBox SSOT + Analyzer Stabilization (7 Tasks) ✅ Task 1: Fallback Guarantee (create_box failure → ring1/core-ro auto fallback) - Three-tier fallback system: plugin → builtin → core-ro - Mode control: auto/plugin-only/core-ro - New: src/box_factory/builtin_impls/file_box.rs - New: tools/test_filebox_fallback_smoke.sh ✅ Task 2: Provider Registration SSOT (static/dynamic/core-ro unified) - ProviderFactory trait with priority-based selection - Global registry PROVIDER_FACTORIES implementation - Priority: dynamic(100) > builtin(10) > core-ro(0) - New: src/boxes/file/builtin_factory.rs - New: tools/smoke_provider_modes.sh ✅ Task 3: FileBox Publication Unification - Verified: basic/file_box.rs already minimized (11 lines) - Perfect re-export pattern maintained ✅ Task 4: ENV Unification (FILEBOX_MODE/DISABLE_PLUGINS priority) - Removed auto-setting of NYASH_USE_PLUGIN_BUILTINS - Removed auto-setting of NYASH_PLUGIN_OVERRIDE_TYPES - Added deprecation warnings with migration guide - ENV hierarchy: DISABLE_PLUGINS > BOX_FACTORY_POLICY > FILEBOX_MODE ✅ Task 5: Error Log Visibility (Analyzer rule execution errors to stderr) - Added [rule/exec] logging before IR-based rule execution - Format: [rule/exec] HC012 (dead_static_box) <filepath> - VM errors now traceable via stderr output ✅ Task 6: Unnecessary Using Removal (14 rules Str alias cleanup) - Removed unused `using ... as Str` from 14 rule files - All rules use local _itoa() helper instead - 14 lines of dead code eliminated ✅ Task 7: HC017 Skip & TODO Documentation (UTF-8 support required) - Enhanced run_tests.sh with clear skip message - Added "Known Limitations" section to README.md - Technical requirements documented (3 implementation options) - Re-enable timeline: Phase 22 (Unicode Support Phase) 📊 Test Results: - Analyzer: 10 tests PASS, 1 skipped (HC017) - FileBox fallback: All 3 modes PASS - Provider modes: All 4 modes PASS - Build: Success (0 errors, 0 warnings) 🎯 Key Achievements: - 28 files modified/created - Three-Tier Fallback System (stability) - SSOT Provider Registry (extensibility) - ENV unification (operational clarity) - Error visibility (debugging efficiency) - Code cleanup (maintainability) - Comprehensive documentation (Phase 22 ready) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 17:04:21 +09:00
// Phase 15.5: Fallback support (auto/core-ro modes)
"FileBox" => builtin_impls::file_box::create(args),
🎉 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>
2025-09-24 11:43:11 +09:00
// Special: Keep vs Delete discussion needed
"NullBox" => builtin_impls::null_box::create(args),
// Leave other types to other factories (user/plugin)
_ => Err(RuntimeError::InvalidOperation {
message: format!("Unknown Box type: {}", name),
}),
}
}
fn box_types(&self) -> Vec<&str> {
vec![
// Primitive wrappers
"StringBox",
"IntegerBox",
"BoolBox",
// Collections/common
"ArrayBox",
"MapBox",
"ConsoleBox",
Phase 21.4 Complete: FileBox SSOT + Analyzer Stabilization (7 Tasks) ✅ Task 1: Fallback Guarantee (create_box failure → ring1/core-ro auto fallback) - Three-tier fallback system: plugin → builtin → core-ro - Mode control: auto/plugin-only/core-ro - New: src/box_factory/builtin_impls/file_box.rs - New: tools/test_filebox_fallback_smoke.sh ✅ Task 2: Provider Registration SSOT (static/dynamic/core-ro unified) - ProviderFactory trait with priority-based selection - Global registry PROVIDER_FACTORIES implementation - Priority: dynamic(100) > builtin(10) > core-ro(0) - New: src/boxes/file/builtin_factory.rs - New: tools/smoke_provider_modes.sh ✅ Task 3: FileBox Publication Unification - Verified: basic/file_box.rs already minimized (11 lines) - Perfect re-export pattern maintained ✅ Task 4: ENV Unification (FILEBOX_MODE/DISABLE_PLUGINS priority) - Removed auto-setting of NYASH_USE_PLUGIN_BUILTINS - Removed auto-setting of NYASH_PLUGIN_OVERRIDE_TYPES - Added deprecation warnings with migration guide - ENV hierarchy: DISABLE_PLUGINS > BOX_FACTORY_POLICY > FILEBOX_MODE ✅ Task 5: Error Log Visibility (Analyzer rule execution errors to stderr) - Added [rule/exec] logging before IR-based rule execution - Format: [rule/exec] HC012 (dead_static_box) <filepath> - VM errors now traceable via stderr output ✅ Task 6: Unnecessary Using Removal (14 rules Str alias cleanup) - Removed unused `using ... as Str` from 14 rule files - All rules use local _itoa() helper instead - 14 lines of dead code eliminated ✅ Task 7: HC017 Skip & TODO Documentation (UTF-8 support required) - Enhanced run_tests.sh with clear skip message - Added "Known Limitations" section to README.md - Technical requirements documented (3 implementation options) - Re-enable timeline: Phase 22 (Unicode Support Phase) 📊 Test Results: - Analyzer: 10 tests PASS, 1 skipped (HC017) - FileBox fallback: All 3 modes PASS - Provider modes: All 4 modes PASS - Build: Success (0 errors, 0 warnings) 🎯 Key Achievements: - 28 files modified/created - Three-Tier Fallback System (stability) - SSOT Provider Registry (extensibility) - ENV unification (operational clarity) - Error visibility (debugging efficiency) - Code cleanup (maintainability) - Comprehensive documentation (Phase 22 ready) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 17:04:21 +09:00
// Fallback support
"FileBox",
"NullBox",
]
}
fn is_builtin_factory(&self) -> bool {
true
}
}