Files
hakorune/docs/development/current/main/ring0-inventory.md
nyash-codex 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

63 lines
2.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Ring0 Inventory初回棚卸しメモ
このドキュメントは、Phase 85-ring0-runtime のための「Ring0 候補呼び出し」の棚卸しメモだよ。
ここでは Task 調査で分かった概況だけをまとめておき、詳細な一覧化や移行は後続フェーズで扱う。
---
## 1. println!/eprintln! 呼び出し
- `println!` / `eprintln!` の合計呼び出し回数: **3,955 回**
- デバッグログ/一時ログ/ユーザ向けメッセージが混在している。
- Ring0 の `LogApi` / `Console` 相当として、最優先で整理したい対象。
- 方針メモ:
- 将来的には `Ring0Context.log` / `Ring0Context.io` 経由に寄せる。
- 代表パスselfhost/hack_check/VM/LLVM`println!/eprintln!` から段階的に移行する。
---
## 2. Box / プラグイン / カーネル実装の数
- `src/boxes`: 34 Box
- `plugins/`: 22 プラグイン
- `crates/nyash_kernel`: 12 カーネル実装
ざっくり分類案Phase 85 時点の暫定):
- core_required:
- StringBox, IntegerBox, BoolBox, ArrayBox, MapBox, ConsoleBox など、言語の基本型+コンソール。
- core_optional:
- FileBox, PathBox, RegexBox, MathBox, TimeBox, JsonBox, TomlBox など、標準ユーティリティ系。
- selfhost_required:
- Stage1CliBox, AotCompilerBox, MirJsonBuilderBox など、selfhost/Stage1 ライン専用。
- user_plugin:
- P2P, HTTP, GUI, Python 連携 等の外部拡張。
※ 正確な一覧とファイルパスは、後続フェーズで Box 定義ファイルを機械的に列挙して作る。
---
## 3. Factory Priority 問題Phase 15.5 の再確認)
- 現状の Factory Priority が `BuiltinFirst`(ビルトイン優先)となっている箇所があり、
- プラグインで上書きしたいケースでも、ビルトイン版が優先されてしまう。
- これは:
- 「core_required な Box」と「user_plugin を使って差し替えたい Box」の境界が曖昧なことの副作用でもある。
- 方針メモ:
- Ring1-core の整理と合わせて、Factory Priority を
- core_required は常にビルトイン
- core_optional / user_plugin は設定やプロファイルで切り替え可能
に整理していく。
---
## 4. 今後の棚卸しタスクTODO メモ)
- `std::fs` / `File::open` / `std::io::stdin` などの呼び出し地点を一覧化。
- `SystemTime::now` / `Instant::now` / `thread::sleep` など時間・スレッド系 API の呼び出し地点を一覧化。
- hakmem / nyrt 経由の低レベル API 呼び出しalloc/free など)を一覧化。
- 代表パスselfhost/hack_check/VM/LLVMのみを対象にした「最小 Ring0 呼び出しセット」を定義する。
これらは Phase 8687 で Ring0Context に寄せていくための下準備だよ。