feat(runtime): Phase 98 ConsoleService 代表パス拡張 - 7箇所置き換え完了
## Phase 98 完了項目 - ✅ println!/eprintln! 7箇所 → ConsoleService 経由に移行 - ✅ console_println! マクロ追加(Graceful Degradation パターン) - ✅ try_get_core_plugin_host() 追加(安全なアクセサー) - ✅ 全テストPASS(core_services: 11, plugin_host: 7) ## 置き換え箇所(7箇所) **selfhost/child.rs** (3箇所): - spawn失敗エラー - タイムアウトメッセージ(stdout/stderr) **core_bridge.rs** (2箇所): - DUMP書き込みエラー - DUMP_MUT書き込みエラー **vm.rs** (1箇所): - RC(return code)出力 **selfhost/json.rs** (2箇所, オプション達成): - PyVM MIR JSON emit エラー - PyVM 使用ログ(verbose時) ## 技術的成果 **Graceful Degradation パターン確立**: - PluginHost 初期化前: eprintln! フォールバック - PluginHost 初期化後: ConsoleService 使用(Ring0直結) - Fail-Fast原則との整合性: 出力先選択のみ動的 **実装インフラ**: - src/runtime/mod.rs: console_println! マクロ & try_get_core_plugin_host() - 既存の get_core_plugin_host() は panic! 保持(Fail-Fast) ## 統計 - 置き換え完了: 7箇所(全体の約2%) - 残り候補: 約359箇所(Phase 99以降) - テスト: ビルド成功、全ユニットテストPASS ## ドキュメント - docs/development/current/main/core_boxes_design.md: Section 15 追加(128行) - 実装パターン、設計判断、テスト結果を完全記録 ## Phase 85-98 総括 - Phase 85-94: 構造設計 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96-96.5: ArrayService/MapService(downcast型)& コード整理 - Phase 97: IntegerService/BoolService(純粋関数型、#[allow(dead_code)] 根絶) - Phase 98: ConsoleService 実用拡大(7箇所)✅ 完了 次: Phase 99(CoreServices 完全統合、残り約359箇所の段階的移行) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -19,7 +19,8 @@ pub fn canonicalize_module_json(input: &str) -> Result<String, String> {
|
||||
if let Ok(path) = env::var("HAKO_DEBUG_NYVM_BRIDGE_DUMP") {
|
||||
if !path.trim().is_empty() {
|
||||
if let Err(e) = fs::write(&path, input.as_bytes()) {
|
||||
eprintln!("[bridge/dump] write error: {}", e);
|
||||
// Phase 98: ConsoleService if available, otherwise eprintln
|
||||
crate::console_println!("[bridge/dump] write error: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -50,7 +51,8 @@ pub fn canonicalize_module_json(input: &str) -> Result<String, String> {
|
||||
if let Ok(path) = env::var("HAKO_DEBUG_NYVM_BRIDGE_DUMP_MUT") {
|
||||
if !path.trim().is_empty() {
|
||||
if let Err(e) = fs::write(&path, output.as_bytes()) {
|
||||
eprintln!("[bridge/dump-mut] write error: {}", e);
|
||||
// Phase 98: ConsoleService if available, otherwise eprintln
|
||||
crate::console_println!("[bridge/dump-mut] write error: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ pub fn run_ny_program_capture_json(
|
||||
envs: &[(&str, &str)],
|
||||
) -> Option<String> {
|
||||
use std::process::Command;
|
||||
|
||||
let mut cmd = Command::new(exe);
|
||||
// Phase 25.1b: Use selfhost compiler env (enables using/file resolution for compiler.hako)
|
||||
crate::runner::child_env::apply_selfhost_compiler_env(&mut cmd);
|
||||
@ -32,7 +33,8 @@ pub fn run_ny_program_capture_json(
|
||||
let out = match crate::runner::modes::common_util::io::spawn_with_timeout(cmd, timeout_ms) {
|
||||
Ok(o) => o,
|
||||
Err(e) => {
|
||||
eprintln!("[selfhost-child] spawn failed: {}", e);
|
||||
// Phase 98: ConsoleService if available, otherwise eprintln
|
||||
crate::console_println!("[selfhost-child] spawn failed: {}", e);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
@ -46,13 +48,15 @@ pub fn run_ny_program_capture_json(
|
||||
.chars()
|
||||
.take(500)
|
||||
.collect::<String>();
|
||||
eprintln!(
|
||||
// Phase 98: ConsoleService if available, otherwise eprintln
|
||||
crate::console_println!(
|
||||
"[selfhost-child] timeout after {} ms; stdout(head)='{}'",
|
||||
timeout_ms,
|
||||
head.replace('\n', "\\n")
|
||||
);
|
||||
if !err_head.is_empty() {
|
||||
eprintln!(
|
||||
// Phase 98: ConsoleService if available, otherwise eprintln
|
||||
crate::console_println!(
|
||||
"[selfhost-child] stderr(head)='{}'",
|
||||
err_head.replace('\n', "\\n")
|
||||
);
|
||||
|
||||
@ -35,11 +35,13 @@ pub fn run_pyvm_module(module: &MirModule, label: &str) -> Option<i32> {
|
||||
if let Err(e) =
|
||||
crate::runner::mir_json_emit::emit_mir_json_for_harness_bin(module, &mir_json_path)
|
||||
{
|
||||
eprintln!("❌ PyVM MIR JSON emit error: {}", e);
|
||||
// Phase 98: ConsoleService if available, otherwise eprintln
|
||||
crate::console_println!("❌ PyVM MIR JSON emit error: {}", e);
|
||||
return None;
|
||||
}
|
||||
if crate::config::env::cli_verbose() {
|
||||
eprintln!(
|
||||
// Phase 98: ConsoleService if available, otherwise eprintln
|
||||
crate::console_println!(
|
||||
"[Bridge] using PyVM ({}) → {}",
|
||||
label,
|
||||
mir_json_path.display()
|
||||
|
||||
@ -586,7 +586,12 @@ impl NyashRunner {
|
||||
|
||||
// Quiet mode: suppress "RC:" output for JSON-only pipelines
|
||||
if !quiet_pipe {
|
||||
println!("RC: {}", exit_code);
|
||||
// Phase 98: ConsoleService if available, otherwise println
|
||||
if let Some(host) = crate::runtime::try_get_core_plugin_host() {
|
||||
host.core.console.println(&format!("RC: {}", exit_code));
|
||||
} else {
|
||||
println!("RC: {}", exit_code);
|
||||
}
|
||||
}
|
||||
if std::env::var("NYASH_EMIT_MIR_TRACE")
|
||||
.ok()
|
||||
|
||||
Reference in New Issue
Block a user