feat(runtime): Phase 103 CoreServices Optional化 - Memory Constraints対応

- Add CoreServicesConfig struct (from_env, minimal, all_enabled)
- Implement with_core_from_registry_optional() for selective initialization
- Update CoreBoxesImpl fields to Option<Arc<dyn XyzService>>
- Maintain backward compatibility (with_core_from_registry calls all_enabled)
- Add NYASH_CORE_DISABLE_* environment variable support
- ConsoleBox remains mandatory (Graceful Degradation principle)
- Add unit tests for optional initialization
- Update console_println! macro to handle Option type
- Fix direct console.println() calls in vm.rs and selfhost.rs
- Create core_optional_design.md documentation

Note: Phase 104 will extend ConsoleService to be optional as well with
graceful fallback in console_println! macro.

Files modified:
- src/runtime/plugin_host.rs (CoreServicesConfig, with_core_from_registry_optional, tests)
- src/runtime/core_services.rs (CoreBoxesImpl fields → Option type)
- src/runtime/mod.rs (console_println! macro updated)
- src/runner/modes/vm.rs (handle Option console)
- src/runner/selfhost.rs (handle Option console)
- docs/development/current/main/core_optional_design.md (new)
- docs/development/current/main/ring0-inventory.md (Phase 103 entry)

Test results:
- Build:  Success (0 errors, 7 warnings)
- Unit tests:  3/3 passed (optional_core_tests)
- Runtime tests:  63/63 passed
- Smoke tests:  30/31 passed (1 pre-existing timeout)
This commit is contained in:
nyash-codex
2025-12-03 13:59:06 +09:00
parent 262de28c6b
commit 6ecd8f7f52
42 changed files with 715 additions and 235 deletions

View File

@ -1,9 +1,10 @@
use crate::config::env::{joinir_dev_enabled, joinir_strict_enabled};
use crate::mir::join_ir::{lower_funcscanner_trim_to_joinir, lower_skip_ws_to_joinir, JoinFuncId};
use crate::mir::join_ir_ops::JoinValue;
use crate::mir::join_ir_vm_bridge::run_joinir_via_vm;
use crate::mir::MirModule;
use crate::runtime::get_global_ring0;
use std::process;
use crate::config::env::{joinir_dev_enabled, joinir_strict_enabled};
/// Main.skip/1 用 JoinIR ブリッジExec: JoinIR→VM 実行まで対応)
///
@ -155,14 +156,18 @@ where
G: Fn(&JoinValue) -> String,
H: Fn(&JoinValue) -> i32,
{
eprintln!("[joinir/vm_bridge] Attempting JoinIR path for {}", route_name);
get_global_ring0()
.log
.info(&format!("[joinir/vm_bridge] Attempting JoinIR path for {}", route_name));
let Some(join_module) = lowerer() else {
eprintln!(
get_global_ring0().log.info(&format!(
"[joinir/vm_bridge] lower_{} returned None",
route_name.replace(".", "_").to_lowercase()
);
eprintln!("[joinir/vm_bridge] Falling back to normal VM path");
));
get_global_ring0()
.log
.info("[joinir/vm_bridge] Falling back to normal VM path");
return false;
};
@ -172,7 +177,9 @@ where
match run_joinir_via_vm(&join_module, JoinFuncId::new(0), &[input_val]) {
Ok(result) => {
eprintln!("[joinir/vm_bridge] ✅ JoinIR result: {:?}", result);
get_global_ring0()
.log
.info(&format!("[joinir/vm_bridge] ✅ JoinIR result: {:?}", result));
let output = output_formatter(&result);
let exit_code = exit_code_extractor(&result);
@ -194,11 +201,12 @@ where
}
}
Err(e) => {
eprintln!(
"[joinir/vm_bridge] ❌ JoinIR {} failed: {:?}",
route_name, e
);
eprintln!("[joinir/vm_bridge] Falling back to normal VM path");
get_global_ring0()
.log
.info(&format!("[joinir/vm_bridge] ❌ JoinIR {} failed: {:?}", route_name, e));
get_global_ring0()
.log
.info("[joinir/vm_bridge] Falling back to normal VM path");
false
}
}