feat(selfhost): Phase 151 - ConsoleBox Selfhost Support

- Identify ConsoleBox registration issue: plugins registered but PluginBoxFactory can't find them
- Root cause: timing/initialization order between BoxFactoryRegistry and UnifiedBoxRegistry
- Solution: Add ConsoleBox builtin fallback for selfhost Stage-3 pipeline
- Implementation: Plugin-preferred, builtin as fallback
- Test results: 2/2 PASS (esc_dirname_smoke.hako, string_ops_basic.hako)

Modified files:
- src/box_factory/builtin_impls/console_box.rs (new, 35 lines)
- src/box_factory/builtin_impls/mod.rs (add console_box module)
- src/box_factory/builtin.rs (add ConsoleBox creation and box_types)
- CURRENT_TASK.md (Phase 151 completion)
- docs/development/current/main/phase151_consolebox_selfhost_support.md (implementation summary)

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-04 13:07:12 +09:00
parent 62808f9585
commit d70329e5df
8 changed files with 150 additions and 11 deletions

View File

@ -48,8 +48,10 @@ impl BoxFactory for BuiltinBoxFactory {
"ArrayBox" => builtin_impls::array_box::create(args),
"MapBox" => builtin_impls::map_box::create(args),
// Phase 125: ✅ DELETED - ConsoleBox is now plugin-only!
// See: plugins/nyash-console-plugin for current implementation
// Phase 125: Plugin-preferred, but builtin fallback for selfhost
// Primary: plugins/nyash-console-plugin
// Fallback: builtin implementation (Phase 151 selfhost support)
"ConsoleBox" => builtin_impls::console_box::create(args),
// Phase 15.5: Fallback support (auto/core-ro modes)
"FileBox" => builtin_impls::file_box::create(args),
@ -76,7 +78,8 @@ impl BoxFactory for BuiltinBoxFactory {
// Collections/common
"ArrayBox",
"MapBox",
// ConsoleBox: Phase 125 - Plugin-only (nyash-console-plugin)
// Phase 151: ConsoleBox builtin fallback for selfhost support
"ConsoleBox",
// Fallback support
"FileBox",
"FileHandleBox", // Phase 113

View File

@ -0,0 +1,33 @@
/*!
* Builtin ConsoleBox Implementation (Phase 151: Selfhost Support Fallback)
*
* ⚠️ PLUGIN-PREFERRED: nyash-console-plugin is the primary implementation
* 🎯 Phase 151: Builtin fallback added to support selfhost Stage-3 pipeline
*
* Context: When running through selfhost compiler, plugins may not be properly
* initialized, so we provide a builtin fallback to ensure ConsoleBox is available.
*/
use crate::box_factory::RuntimeError;
use crate::box_trait::NyashBox;
use crate::boxes::ConsoleBox;
/// Create builtin ConsoleBox instance
///
/// Primary: nyash-console-plugin
/// Fallback: This builtin implementation (selfhost support)
pub fn create(_args: &[Box<dyn NyashBox>]) -> Result<Box<dyn NyashBox>, RuntimeError> {
// Phase 151: Quiet fallback (no deprecation warning - this is intentional selfhost support)
Ok(Box::new(ConsoleBox::new()))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_builtin_console_box_creation() {
let result = create(&[]).unwrap();
assert!(result.as_any().downcast_ref::<ConsoleBox>().is_some());
}
}

View File

@ -17,7 +17,7 @@
// Phase 2.1-2.6: Delete these modules one by one
pub mod array_box; // DELETE: Phase 2.4 (plugin check)
pub mod bool_box; // DELETE: Phase 2.3 (plugin needed)
// Phase 125: console_box ✅ DELETED - Plugin-only (nyash-console-plugin)
pub mod console_box; // Phase 151: Builtin fallback for selfhost support (plugin-preferred)
pub mod integer_box; // DELETE: Phase 2.2 (plugin ready)
pub mod map_box; // DELETE: Phase 2.5 (plugin check)
pub mod string_box; // DELETE: Phase 2.1 (plugin ready)