feat(phase109): RuntimeProfile設計で FileBox を条件付き optional に

Phase 109 完全実装完了:
- RuntimeProfile enum (Default, NoFs) で profile 制御
- CoreBoxId.is_required_in(profile) で条件付き required/optional
- initialize_runtime() で env 読み込み責務を一元化(修正1)
- NoFsFileIo スタブで no-fs プロファイルでの FileBox 無効化(修正2)
- Logger/ConsoleService は no-fs でも有効と明示(修正2)
- Profile 拡張予定(TestMock/Sandbox/ReadOnly/Embedded)を予約(修正3)

実装ファイル:
- src/runtime/runtime_profile.rs (新規)
- src/providers/ring1/file/nofs_fileio.rs (新規)
- src/runtime/core_box_ids.rs (修正)
- src/runtime/plugin_host.rs (修正)
- src/runtime/provider_lock.rs (修正)
- docs 更新

テスト: Phase 109 11/11 PASS 
ビルド: cargo build --release SUCCESS 

🤖 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 19:37:32 +09:00
parent 2eda4bc86b
commit 4ef3e7f56c
12 changed files with 634 additions and 53 deletions

View File

@ -1,2 +1,3 @@
pub mod core_ro;
pub mod ring0_fs_fileio;
pub mod nofs_fileio; // Phase 109: NoFs profile stub

View File

@ -0,0 +1,98 @@
//! Phase 109: NoFs profile FileIo stub
//!
//! Provides a stub FileIo implementation that returns errors for all operations.
//! Used when FileBox is disabled in no-fs runtime profile.
use crate::boxes::file::provider::{FileCaps, FileError, FileIo, FileResult};
/// Phase 109: No-filesystem FileIo stub
///
/// Returns Unsupported errors for all operations.
/// Used in NoFs runtime profile where FileBox is disabled.
///
/// # Design
///
/// - caps(): Returns read=false, write=false
/// - All operations: Return FileError::Unsupported with clear message
///
/// # Logger/ConsoleService availability (Phase 109 Modification 2)
///
/// ✅ Still available in NoFs profile:
/// - Ring0.log (OS abstraction layer - panic/exit final output)
/// - ConsoleBox (language-level console - stdout/stderr)
/// - Core required boxes (String/Integer/Bool/Array/Map/Console)
///
/// ❌ Disabled in NoFs profile:
/// - FileBox (filesystem-dependent)
/// - Optional boxes (Regex/Time/JSON - future: profile-controlled)
pub struct NoFsFileIo;
impl FileIo for NoFsFileIo {
fn caps(&self) -> FileCaps {
FileCaps {
read: false,
write: false,
}
}
fn open(&self, _path: &str) -> FileResult<()> {
Err(FileError::Unsupported)
}
fn read(&self) -> FileResult<String> {
Err(FileError::Unsupported)
}
fn write(&self, _text: &str) -> FileResult<()> {
Err(FileError::Unsupported)
}
fn close(&self) -> FileResult<()> {
Err(FileError::Unsupported)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_nofs_fileio_caps() {
let fileio = NoFsFileIo;
let caps = fileio.caps();
assert!(!caps.read, "NoFsFileIo should report read=false");
assert!(!caps.write, "NoFsFileIo should report write=false");
}
#[test]
fn test_nofs_fileio_open_unsupported() {
let fileio = NoFsFileIo;
let result = fileio.open("/tmp/test.txt");
assert!(result.is_err());
assert!(result.unwrap_err().to_string().contains("unsupported"));
}
#[test]
fn test_nofs_fileio_read_unsupported() {
let fileio = NoFsFileIo;
let result = fileio.read();
assert!(result.is_err());
assert!(result.unwrap_err().to_string().contains("unsupported"));
}
#[test]
fn test_nofs_fileio_write_unsupported() {
let fileio = NoFsFileIo;
let result = fileio.write("test");
assert!(result.is_err());
assert!(result.unwrap_err().to_string().contains("unsupported"));
}
#[test]
fn test_nofs_fileio_close_unsupported() {
let fileio = NoFsFileIo;
let result = fileio.close();
assert!(result.is_err());
assert!(result.unwrap_err().to_string().contains("unsupported"));
}
}