Commit Graph

4 Commits

Author SHA1 Message Date
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
7e8c2cc768 docs(phase89-b): Ring0 IO/time/thread inventory complete
Phase 89-B 完了: Ring0 候補の棚卸し調査

**調査結果**:
- fs 系: 243箇所 (read_to_string: 80+, write: 40+, File::open: 30+)
- io 系: 87箇所 (Write: 30+, Read: 20+, stdin: 10+)
- time 系: 143箇所 (Instant::now: 40+, Duration: 30+, elapsed: 25+)
- thread 系: 37箇所 (thread::sleep: 20+, thread::spawn: 10+)
- println! 残存: 1,948箇所 (Phase 89-A で 56箇所移行済み)

**成果物**:
- /tmp/ring0_*_inventory.txt 詳細リスト (計 510行)
- ring0-inventory.md 更新 (Section 3-7 追加)
- Phase 90 実装計画案 (A-E: 5段階、8-13時間予定)

**次のステップ**: Phase 90-A (fs 系移行)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 23:46:32 +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
268a56fdfe feat(box_factory): Phase 86 BoxFactory Priority normalization
Phase 86: BoxFactory Priority 正常化プロジェクト完了

目的:
- BoxFactory のデフォルトポリシーを BuiltinFirst から StrictPluginFirst に変更
- プラグイン版 StringBox/ArrayBox/MapBox が正常に使用できるよう正常化
- Phase 85 (Ring0/Ring1-Core 境界設計) の土台準備

実装内容:
1. ドキュメント作成
   - docs/development/current/main/factory_priority.md: 完全仕様文書化

2. コード修正 (1行のみ)
   - UnifiedBoxRegistry::new() が with_env_policy() を使用
   - デフォルトポリシーが StrictPluginFirst に変更

3. テスト追加 (5件, 全パス)
   - test_default_policy_is_strict_plugin_first: デフォルトポリシー確認
   - test_env_policy_override: 環境変数制御確認
   - test_reserved_type_protection: 予約型保護動作確認
   - test_plugin_override_with_env: 予約型 override 確認
   - test_non_reserved_plugin_priority: 非予約型プラグイン優先確認

効果:
-  プラグイン版 StringBox/ArrayBox/MapBox が正常に使用可能
-  core_required Box の予約名保護維持
-  環境変数による柔軟な制御が可能
-  テスト改善: 500→506 passed, 34→33 failed (+6 passed, -1 failed)

core_required Box リスト (暫定):
- Core value types: StringBox, IntegerBox, BoolBox, FloatBox, NullBox
- Core containers: ArrayBox, MapBox, ResultBox
- Core method indirection: MethodBox

環境変数:
- NYASH_BOX_FACTORY_POLICY: ポリシー選択 (default: strict_plugin_first)
- NYASH_USE_PLUGIN_BUILTINS: core_required override 許可
- NYASH_PLUGIN_OVERRIDE_TYPES: 個別 Box override 許可

Phase 85 準備:
- Ring0/Ring1-Core 境界設計の土台が整った
- ConsoleBox の扱いは Phase 85 で最終決定

完了条件:
-  factory_priority.md 作成完了
-  UnifiedBoxRegistry::new() 修正完了
-  デフォルトポリシー StrictPluginFirst 確定
-  テスト 5件追加・全パス
-  CURRENT_TASK.md 更新完了
-  Phase 85 README 準備完了

参考:
- 設計文書: docs/development/current/main/factory_priority.md
- Phase 85 計画: docs/private/roadmap2/phases/phase-85-ring0-runtime/README.md

🎉 Phase 86 完了!次は Phase 85 で Ring0/Ring1-Core 境界の文書化へ
2025-12-02 21:52:18 +09:00