feat(phase90): Ring0Context fs/time/thread migration complete

Phase 90 完了: IO/fs/time/thread 系の Ring0 移行

**Phase 90-A: fs 系移行(7箇所)**
- FsApi trait 追加(6メソッド)
- StdFs 実装(std::fs ベース)
- IoError 拡張(4バリアント追加)
- 移行: strip.rs(4), dispatch.rs(1), mod.rs(3)

**Phase 90-B: io 系移行**
- Phase 88 完了済み(スキップ)

**Phase 90-C: time 系移行(3箇所)**
- TimeApi に elapsed() 追加
- 移行: selfhost_exe.rs(1), io.rs(1), plugin_loader_unified.rs(1)

**Phase 90-D: thread 系移行(2箇所)**
- ThreadApi trait 追加(sleep メソッド)
- StdThread 実装
- 移行: global_hooks.rs(1), plugin_loader_unified.rs(1)

**Phase 90-E: 統合テスト**
- ビルド成功(6 warnings, 0 errors)
- テスト: 522/554 passed (94.2%)
- 退行なし

**実装成果**:
- Ring0Context 拡張: fs, thread フィールド追加
- 総移行: 12箇所(fs: 7, time: 3, thread: 2)
- 移行率: fs(2.9%), time(2.1%), thread(5.4%)

**次のステップ**: Phase 91 (PluginHost/CoreServices skeleton)

🤖 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-03 06:14:57 +09:00
parent 7e8c2cc768
commit 4e2e45a79d
12 changed files with 265 additions and 28 deletions

View File

@ -4,6 +4,7 @@
//! Box 名・Nyash 型を一切知らない。
use super::errors::{IoError, TimeError};
use std::path::{Path, PathBuf};
use std::time::SystemTime;
/// メモリ APIPhase 88: noop、将来 hakmem 接続)
@ -45,6 +46,9 @@ pub trait TimeApi: Send + Sync {
/// モノトニック時刻取得(高精度タイマー用)
fn monotonic_now(&self) -> Result<std::time::Instant, TimeError>;
/// 経過時間取得 (Phase 90-C)
fn elapsed(&self, start: std::time::Instant) -> std::time::Duration;
}
/// ログレベル
@ -81,3 +85,39 @@ pub trait LogApi: Send + Sync {
self.log(LogLevel::Error, msg);
}
}
/// ファイルシステムメタデータ
#[derive(Debug, Clone)]
pub struct FsMetadata {
pub is_file: bool,
pub is_dir: bool,
pub len: u64,
}
/// ファイルシステム API (Phase 90-A)
pub trait FsApi: Send + Sync {
/// ファイルを文字列として読み込む
fn read_to_string(&self, path: &Path) -> Result<String, IoError>;
/// ファイルをバイト列として読み込む
fn read(&self, path: &Path) -> Result<Vec<u8>, IoError>;
/// ファイルに書き込む
fn write_all(&self, path: &Path, data: &[u8]) -> Result<(), IoError>;
/// パスが存在するか確認
fn exists(&self, path: &Path) -> bool;
/// ファイルメタデータを取得
fn metadata(&self, path: &Path) -> Result<FsMetadata, IoError>;
/// パスを正規化
fn canonicalize(&self, path: &Path) -> Result<PathBuf, IoError>;
}
/// スレッド API (Phase 90-D)
pub trait ThreadApi: Send + Sync {
/// 指定時間スリープ
fn sleep(&self, duration: std::time::Duration);
// spawn は Phase 91 以降で追加予定
}