Commit Graph

16 Commits

Author SHA1 Message Date
dc90b96bb2 feat(phase114): FileIo trait 拡張 & メタデータ統一完成
Phase 113 で公開した .hako API は変更なく、内部実装を完全統一化。
FsApi(Ring0 stateless)と FileIo(Ring1 stateful)の設計を確立。

【実装内容】

Task 1: FileIo trait 拡張
- FileStat 構造体追加(is_file/is_dir/size)
- exists/stat/canonicalize メソッド追加(FileIo trait)

Task 2: Ring0FsFileIo 実装
- exists(): path を Ring0.fs で確認
- stat(): Ring0.fs.metadata() を FileStat に変換
- canonicalize(): Ring0.fs.canonicalize() を String に変換

Task 3: NoFsFileIo stub 実装
- exists() → false(全ファイルが「存在しない」扱い)
- stat() → Err(Unsupported)(FS 無効情報を返す)
- canonicalize() → Err(Unsupported)

Task 4: FileHandleBox 内部統一
- metadata_internal() を新規追加(FileIo::stat() ベース)
- is_file/is_dir/size を metadata_internal() 経由に統一
- Nyash 公開 API(ny_exists/ny_size/ny_isFile/ny_isDir)は変更なし

Task 5: テスト + ドキュメント
- Ring0FsFileIo: 5テスト(stat/exists/canonicalize)
- NoFsFileIo: 3テスト(exist/stat/canonicalize error)
- FileHandleBox: 5テスト(metadata_internal/exists/is_file/is_dir)
- すべてのテスト PASS

【設計原則確立】

FsApi ↔ FileIo の責務分担:
- FsApi (Ring0): Stateless(パスを毎回指定)
- FileIo (Ring1): Stateful(path を内部保持)
- FileHandleBox: FileIo::stat() で一元化

Profile 別動作:
- Default: 全機能正常動作
- NoFs: exists=false, stat/canonicalize は Unsupported エラー

【統計】
- 修正ファイル: 9ファイル
- 追加行: +432行、削除: -29行
- 新規テスト: 13個(全PASS)
- ビルド: SUCCESS

【効果】
- 内部実装が完全統一(二重実装・不一貫性排除)
- Phase 115+ での拡張(modified_time/permissions等)が容易に
- FsApi と FileIo の設計がクリアに確立

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 03:58:02 +09:00
99f57ef27d feat(phase113): FileHandleBox Nyash 公開 API 完成
FileHandleBox の内部メソッド(open/read/write/close/exists/size)を
Nyash (.hako) 側から「普通の Box メソッド」として使える形に完全公開

【実装内容】

Task 1: 公開 API 設計書完成
- phase113_filehandlebox_public_api.md 作成(380行完全仕様書)
- I/O メソッド: open(path, mode) / read() / write(text) / close()
- メタデータメソッド: exists() / size() / isFile() / isDir()
- Profile 別動作: Default (全機能) / NoFs (open で panic)

Task 2: Rust 側メソッド公開
- FileHandleBox に ny_* メソッド実装(8メソッド)
- BoxFactory 登録完了
- StringBox と同じ invoke_method() パターン採用

Task 3: .hako サンプル & テスト
- append_and_stat.hako サンプル作成(実用例)
- Rust ユニットテスト 6個(全メソッド + Profile カバレッジ)

Task 4: Profile 統合確認
- Default プロファイル: 全機能正常動作 
- NoFs プロファイル: open は panic、cascade disabled 
- Ring0Registry による自動無効化パターン確立 

Task 5: ドキュメント完全更新
- core_boxes_design.md: Section 16.1 追加(88行)
- ring0-inventory.md: Phase 113 エントリ追加(8行)
- CURRENT_TASK.md: Phase 113 完了マーク

【統計】
- 新規作成: 3ファイル(.md + .hako + factory)
- 修正: 6ファイル
- 追加行数: +210行
- テスト: 6個(全 PASS)
- ビルド: SUCCESS

【Phase 106-113 通算】
- 7フェーズ完成
- 33+17=50ファイル修正
- +1,350+210=+1,560行実装
- 設計書: 6つの大規模 markdown
- テスト: 33+6=39個全PASS
- 第1章完結状態に到達 

【設計原則確立】
- Ring0 → Ring1 FS API の完全統一
- Profile-aware 初期化(SSOT パターン)
- FileBox / FileHandleBox / Ring0 の非矛盾性設計
- .hako 入口から Rust 実装まで全導線完備

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 03:35:25 +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
acd1b54ef9 feat(phase110): FileHandleBox実装(ハンドルベース複数回アクセス)
Phase 110 完全実装完了:
- FileHandleBox struct で open → read/write → close の複数回アクセスをサポート
- 各インスタンスが独立した Ring0FsFileIo を保持
- Fail-Fast 原則:二重 open、close後アクセス、NoFsプロファイル全て即座にエラー
- RuntimeProfile 対応:Default で使用可能、NoFs で禁止

実装ファイル:
- src/boxes/file/handle_box.rs (新規, 450行)
- src/boxes/file/mod.rs (修正, export追加)

テスト: 7/7 PASS 
- test_filehandlebox_basic_write_read
- test_filehandlebox_double_open_error
- test_filehandlebox_closed_access_error
- test_filehandlebox_write_wrong_mode
- test_filehandlebox_multiple_writes
- test_filehandlebox_unsupported_mode
- test_filehandlebox_independent_instances

ドキュメント更新:
- core_boxes_design.md (Section 16 追加)
- ring0-inventory.md (Phase 110完了)
- CURRENT_TASK.md (Phase 110完了セクション)

設計原則:
- FileBox: ワンショット I/O(open/close隠蔽)
- FileHandleBox: ハンドルベース I/O(複数回アクセス対応)
- Ring0FsFileIo を内部で再利用

次フェーズ: Phase 111(append mode + metadata)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 20:28:33 +09:00
4ef3e7f56c 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>
2025-12-03 19:37:32 +09:00
f8790b13cc docs(phase 105): Logger Box Framework設計&ドキュメント整備
- Create logger_box_design.md: comprehensive Logger Box framework design
- Define 3 reference patterns (Lightweight/Structured/Contextual)
- Add pseudo-code examples for each pattern (reference only)
- Update logging_policy.md: add Logger Box reference
- Update hako_logging_design.md: Logger Box integration with Phase 104
- Update ring0-inventory.md: Phase 105 entry
- Update CURRENT_TASK.md: Phase 105 completion + Phase 106+ backlog

Design principles:
- Logger Box provides level-based logging (DEBUG/INFO/WARN/ERROR)
- Phase 105 scope: ConsoleBox output only
- Phase 106 scope: output redirection (FileBox/NetworkBox)
- Reference examples for documentation (execution testing Phase 106+)

This completes the structured logging framework design, building on
Phase 99 (logging policy), Phase 100-101 (Rust logging), Phase 104
(.hako patterns), and Phase 105.5 (console macro unification).
2025-12-03 14:33:04 +09:00
8203882a97 docs(phase 104): .hako側ロギング設計ガイド確立
- Add Section 4 (.hako側ロギング方針) to logging_policy.md
- Create hako_logging_design.md (comprehensive guide, 331 lines)
- Define 4 logging categories (user-facing/dev-debug/monitoring/internal Rust)
- Provide 3 logging box patterns (Lightweight/Structured/Contextual)
- Add best practices and anti-patterns with code examples
- Update ring0-inventory.md with Phase 104 entry
- Cross-reference documentation for consistency

This completes Phase 104: establishing user-facing logging guidelines
for Nyash applications, complementing Rust-side logging policy from
Phase 99-101.

Files modified:
- docs/development/current/main/logging_policy.md
- docs/development/current/main/hako_logging_design.md (new)
- docs/development/current/main/ring0-inventory.md

Related: Phase 99 (logging policy design), Phase 100-101 (Rust impl)
2025-12-03 14:07:01 +09:00
6ecd8f7f52 feat(runtime): Phase 103 CoreServices Optional化 - Memory Constraints対応
- Add CoreServicesConfig struct (from_env, minimal, all_enabled)
- Implement with_core_from_registry_optional() for selective initialization
- Update CoreBoxesImpl fields to Option<Arc<dyn XyzService>>
- Maintain backward compatibility (with_core_from_registry calls all_enabled)
- Add NYASH_CORE_DISABLE_* environment variable support
- ConsoleBox remains mandatory (Graceful Degradation principle)
- Add unit tests for optional initialization
- Update console_println! macro to handle Option type
- Fix direct console.println() calls in vm.rs and selfhost.rs
- Create core_optional_design.md documentation

Note: Phase 104 will extend ConsoleService to be optional as well with
graceful fallback in console_println! macro.

Files modified:
- src/runtime/plugin_host.rs (CoreServicesConfig, with_core_from_registry_optional, tests)
- src/runtime/core_services.rs (CoreBoxesImpl fields → Option type)
- src/runtime/mod.rs (console_println! macro updated)
- src/runner/modes/vm.rs (handle Option console)
- src/runner/selfhost.rs (handle Option console)
- docs/development/current/main/core_optional_design.md (new)
- docs/development/current/main/ring0-inventory.md (Phase 103 entry)

Test results:
- Build:  Success (0 errors, 7 warnings)
- Unit tests:  3/3 passed (optional_core_tests)
- Runtime tests:  63/63 passed
- Smoke tests:  30/31 passed (1 pre-existing timeout)
2025-12-03 13:59:06 +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
0c527dcd22 feat(runtime): Phase 101-A dev-debug ログの Ring0.log 統一 - 34箇所完了
## Phase 101-A 完了項目
-  llvm.rs: 13箇所([joinir/llvm], [parse/context]) → Ring0.log
-  loop_form.rs: [loopform] 系ログ → Ring0.log
-  loopform_builder.rs: 16箇所([loopform/prepare], [loopform/seal_phis]) → Ring0.log
-  loop_snapshot_merge.rs: 5箇所([Option C]) → Ring0.log
-  全テストPASS(ビルド成功)

## 置き換え箇所(34箇所)

**llvm.rs**(13箇所):
- [joinir/llvm] JoinIR 実験パスログ(12箇所)
- [parse/context] プリロードファイルリスト(1箇所)

**loop_form.rs**(複数箇所):
- [loopform] 基本ログ
- [loopform/condition] 条件式処理
- [loopform/writes] 変数書き込み収集

**loopform_builder.rs**(16箇所):
- [loopform/prepare] 構造準備
- [loopform/seal_phis] PHI シーリング処理

**loop_snapshot_merge.rs**(5箇所):
- [Option C] Exit PHI 分類
- [Option C] 変数解析

## 技術的成果
- Ring0.log で dev-debug ログを一元管理
- stderr の cleanness 向上(ユーザー向けメッセージのみ)
- 環境に応じた出力制御が可能(NYASH_LOOPFORM_DEBUG等)
- Phase 99-100 で確立した 3層設計を実装レベルで完成

## 実装パターン
```rust
// Before
eprintln!("[loopform] variable_map: {:?}", map);

// After
crate::runtime::get_global_ring0().log.debug(&format!(
    "[loopform] variable_map: {:?}", map
));
```

## 統計
- Phase 98: 7箇所(ConsoleService)
- Phase 100: 29箇所(ConsoleService)
- Phase 101-A: 34箇所(Ring0.log)
- **合計**: 70箇所で統一(ConsoleService/Ring0.log)
- 残り: ~905箇所(test含む)

## ドキュメント更新
- logging_policy.md: Section 7-A 追加(Phase 101-A 実装記録)
- ring0-inventory.md: Category 2 更新(dev-debug 進捗反映)
- CURRENT_TASK.md: Phase 85 セクション追記

## Phase 85-101-A 総括
- Phase 95.5-97: CoreServices 6個完全実装(String/Integer/Bool/Array/Map/Console)
- Phase 98-98.5: ConsoleService 代表パス拡張(7箇所)
- Phase 99: ログ/出力ポリシー確定(3層設計文書化)
- Phase 100: user-facing 出力の ConsoleService 化(29箇所)
- Phase 101-A: dev-debug ログの Ring0.log 統一(34箇所) 

次: Phase 101-B(internal/test ログの整理、別検討)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 12:25:32 +09:00
7cf11fbc5c feat(runtime): Phase 100 user-facing 出力の ConsoleService 完全統一 - 29箇所完了
## Phase 100 完了項目
-  selfhost.rs: 6箇所 → console_println!
-  llvm.rs: 23箇所(主要メッセージ) → console_println!
-  全テストPASS(core_services: 11, plugin_host: 7)
-  ドキュメント更新完了

## 置き換え箇所(29箇所)

**selfhost.rs**(6箇所):
- Line 57: CoreInitError 出力
- Lines 194/363/418/519/570: Result 出力

**llvm.rs**(23箇所、ユーザー向けメッセージのみ):
- エラーメッセージ(): ファイル読み込み、using/parse エラー
- 成功メッセージ(📊): MIR コンパイル成功
- LLVM/harness 関連エラー
- 実行結果出力
- Mock LLVM メッセージ

## 意図的に除外(Phase 101 対象)
- llvm.rs の `[joinir/llvm]`, `[parse/context]` デバッグログ
- hack_check: .hako アプリ(Nyash言語の ConsoleBox 経由)
- bench.rs: テスト・性能表示(dev-debug)
- mir.rs: 内部 MIR ダンプ(dev-debug)

## 技術的成果
- selfhost/LLVM runner のユーザー向けメッセージを ConsoleService に統一
- Phase 99 で確立したログ/出力ポリシーを実装レベルで実現
- デバッグログとユーザー向け出力の明確な分離
- Graceful Degradation パターンの実用確認

## 統計
- Phase 98: 7箇所
- Phase 100: 29箇所
- **合計**: 36箇所で ConsoleService 経由に移行完了
- 残り user-facing: ~330箇所(Phase 101-102 で段階的拡張)

## ドキュメント更新
- logging_policy.md: Section 7 追加(Phase 100 実装完了記録)
- ring0-inventory.md: Category 1 更新(Phase 100 進捗反映)
- CURRENT_TASK.md: Phase 85 セクション追記

## Phase 85-100 総括
- Phase 95.5-97: CoreServices 6個完全実装(String/Integer/Bool/Array/Map/Console)
- Phase 98-98.5: ConsoleService 代表パス拡張(7箇所)
- Phase 99: ログ/出力ポリシー確定(3層設計文書化)
- Phase 100: user-facing 出力の ConsoleService 化(29箇所) 

次: Phase 101(dev-debug/test/internal 出力の整理、Ring0.log 活用)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 11:55:14 +09:00
c181aeac4d docs(runtime): Phase 99 ログ/出力ポリシー確定 - 3層設計の文書化完成
## Phase 99 完了項目(ドキュメント設計フェーズ)
-  logging_policy.md 新規作成(312行)
-  ring0-inventory.md 更新(455行)
-  core_boxes_design.md Section 15.6-A 追記(+58行)
-  CURRENT_TASK.md Phase 85 セクション更新

## 確定した3層ログ/出力設計

【Ring0.log】(OS API層)
- 用途: ランタイム/OS内部ログ
- 対象: 開発者向けデバッグ・計測・内部状態
- API: ring0.log.debug/info/warn/error(...)

【ConsoleService】(Box層・ユーザー向け)
- 用途: CLIの直接的な出力(ユーザー向けメッセージ)
- 対象: エンドユーザー
- アクセス: console_println! マクロ

【素のprintln!/eprintln!】(制限用途)
- 用途: テスト・一時デバッグのみ限定
- テスト内: 約299箇所そのまま許可
- 本番経路: 撤退すべき

## println!/eprintln! 残件分類(1477箇所)
- user-facing: ~366箇所(HIGH)→ console_println!
- dev-debug: TBD(MEDIUM)→ Ring0.log or dev_* macros
- test: ~299箇所(LOW)→ そのまま許可
- internal: ~812箇所(TBD)

## 設計の価値
- **コード変更なし**: リスク最小(ドキュメントのみ)
- **後工程の基盤**: Phase 100-101で残り~366箇所を片付け可能
- **Fail-Fast原則**: マクロ方針でエラーメッセージは確実に出力
- **段階的移行**: Graceful Degradation パターンで初期化前後を対応

## 新規ドキュメント構成
logging_policy.md:
  - Section 1: 3層の役割分担
  - Section 2: Macroポリシー
  - Section 3: テスト内println!の扱い
  - Section 4: 完全統合の完了条件
  - Section 5: 設計原則
  - Section 6: 関連ドキュメント

ring0-inventory.md:
  - Section 1: Ring0.log利用状況
  - Section 2: println! 残件分類(4カテゴリ)
  - Section 3: Ring0.log活用計画
  - Section 4-8: 配布状況・ロードマップ・コマンド・履歴・成功基準

## AI協働開発の成功例
- 設計と実装の分離(Phase 99=設計、Phase 100+=実装)
- 段階的アプローチ(80/20ルール:完璧より進捗)
- ドキュメント優先(コードより先に設計を固める)

## Phase 85-99 総括
- Phase 95.5: StringService/ConsoleService実装
- Phase 96-96.5: ArrayService/MapService & コード整理
- Phase 97: IntegerService/BoolService(#[allow(dead_code)] 根絶)
- Phase 98-98.5: ConsoleService代表パス拡張(7箇所)
- Phase 99: ログ/出力ポリシー確定(設計フェーズ) 

次: Phase 100-101(user-facing移行、~366箇所段階的実装)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 11:31:35 +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
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