af6f95cd4b
Phase 33 NORM canon test: enforce normalized dev route for P1/P2/JP mini
2025-12-11 20:54:33 +09:00
0a49a9c897
refactor(phase112): Ring0 Service Registry コード改善
...
Phase 112 実装後のコード品質向上として4つの改善を実施
【改善1】NoFsApi エラーメッセージの定数化
- NOFS_ERROR_MSG 定数を定義して一元管理
- 5箇所の重複メッセージを1つの定数参照に統一
- タイポリスク低減・保守性向上
【改善2】Ring0Registry の build_with_fs() 抽出
- build_default() と build_no_fs() の重複(14行)を削除
- 新規ヘルパーメソッド build_with_fs(fs: Arc<dyn FsApi>) を追加
- build() メソッドを2行の match 式に簡潔化
- 将来の profile 追加時の拡張性向上
【改善3】NoFsApi テスト追加
- 7つの新規テストを追加(全 FsApi メソッドをカバー)
- test_nofs_api_read_to_string
- test_nofs_api_read
- test_nofs_api_write_all
- test_nofs_api_append_all
- test_nofs_api_exists
- test_nofs_api_metadata
- test_nofs_api_canonicalize
- テストカバレッジ大幅向上
【改善4】unsafe dealloc ヘルパー化
- unsafe_dealloc(ptr, size) ヘルパー関数を追加
- 3箇所の unsafe dealloc 呼び出しを統一
- コード可読性向上・unsafe 領域最小化
【統計】
- 2ファイル修正(+77行, -40行)
- テスト: 19 passed(既存12 + 新規7)
- ビルド: SUCCESS
【効果】
- コード重複削減(14行削除)
- テストカバレッジ向上(NoFsApi 全メソッドテスト化)
- 保守性向上(定数一元管理)
- 可読性向上(build() メソッド簡潔化)
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-04 03:18:49 +09:00
04f476d6b4
feat(phase112): Ring0 Service Registry統一化実装完了
...
Ring0 初期化を Ring0Registry::build(profile) に集約し、プロファイル対応を統一化
【実装内容】
- Task 2: Ring0Registry struct + build(profile) メソッド実装
- RuntimeProfile::Default → StdFs を使用
- RuntimeProfile::NoFs → NoFsApi を使用
- build_default()/build_no_fs() の内部メソッド分離
- Task 3: NoFsApi struct 実装(FsApi trait)
- すべてのファイルシステム操作を「disabled」として失敗させる
- read/write/append/metadata/canonicalize が IoError を返す
- exists() は false を返す
- 49行の新規実装
- Task 4: initialize_runtime() SSOT パターン確認
- env 読み込み → RuntimeProfile::from_env()
- Ring0Context 構築 → Ring0Registry::build(profile)
- グローバル登録 → init_global_ring0()
- 唯一の責務分離を確立
- Task 5: PluginHost/FileBox/FileHandleBox からの Ring0 統合
- Ring0.fs = NoFsApi の場合、すべての上位層が自動的に disabled
- 特別なロジック不要(カスケード disabled パターン)
- Task 6: ドキュメント更新
- core_boxes_design.md: Section 17 追加(88行)
- ring0-inventory.md: Phase 112 エントリ追加(16行)
- CURRENT_TASK.md: Phase 106-112 完了表更新
- phase112_ring0_registry_design.md: 完全設計書(426行)
【統計】
- 8ファイル修正(+261行, -30行)
- 3つの新テスト追加(Ring0Registry関連)
- test_ring0_registry_default_profile
- test_ring0_registry_nofs_profile
- test_default_ring0_uses_registry
- cargo build --release: SUCCESS
- 全テスト PASS
【設計原則確立】
- Ring0Registry factory pattern で profile-aware 実装選択を一本化
- NoFsApi による自動 disabled により、上位層の特別処理を排除
- initialize_runtime() が唯一の env 読み込み入口として SSOT 確立
- 将来の profile 追加(TestMock/Sandbox/ReadOnly/Embedded等)が容易に
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-03 22:19:24 +09:00
262de28c6b
feat(ring0): Phase 102 MemApi Bridge Skeleton - StdMem実装
...
- Add StdMem struct (stdlib alloc/free based)
- Update default_ring0() to use StdMem instead of NoopMem
- Keep NoopMem for compatibility and testing
- Add unit tests for StdMem allocation/stats
- Update docs (phase-85-ring0-runtime/README.md, ring0-inventory.md)
Note: This is a skeleton implementation. Full MemStats tracking
(including freed size) will be added in Phase 102B with hakmem bridge.
Files modified:
- src/runtime/ring0/std_impls.rs
- src/runtime/ring0/mod.rs
- docs/development/current/main/phase-85-ring0-runtime/README.md
- docs/development/current/main/ring0-inventory.md
2025-12-03 13:42:05 +09:00
4e2e45a79d
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 >
2025-12-03 06:14:57 +09:00
42b09b3c1c
feat(phase88): Ring0Context Skeleton implementation
...
Phase 88: OS API abstraction layer implementation
**Implementation**:
- Ring0Context module added (4 files)
- mod.rs: Public API, global initialization (OnceLock)
- traits.rs: MemApi, IoApi, TimeApi, LogApi trait definitions
- std_impls.rs: std-based default implementations
- errors.rs: IoError, TimeError type definitions
**Design Principles**:
- Ring0 knows nothing about Box
- Ring0 knows nothing about Nyash
- Pure OS API abstraction
**Global Initialization**:
- NyashRunner::new() initializes Ring0Context globally
- OnceLock ensures safe initialization (idempotent)
**Migration (2 paths)**:
- src/runner/selfhost.rs:27: eprintln! → ring0.log.error() (OOB strict)
- src/runner/selfhost.rs:177: eprintln! → ring0.log.error() (PyVM error)
**Tests**:
- 4 unit tests added (ring0 module)
- All tests passed
- Build successful (0 errors)
**Migration Status**:
- Migrated: 2/3,955 (0.05%)
- Remaining: 3,953 paths (Phase 89+)
**Files Changed**:
- src/runtime/ring0/mod.rs (new, 100 lines)
- src/runtime/ring0/traits.rs (new, 93 lines)
- src/runtime/ring0/std_impls.rs (new, 77 lines)
- src/runtime/ring0/errors.rs (new, 26 lines)
- src/runtime/mod.rs (Ring0Context export)
- src/runner/mod.rs (global initialization)
- src/runner/selfhost.rs (2 paths migrated)
- docs/development/current/main/ring0-inventory.md (Phase 88 status)
Phase 88 complete. Ready for Phase 89 (gradual migration).
🐱 ✨
2025-12-02 22:38:27 +09:00