Files
hakorune/src/runtime/core_services.rs

606 lines
17 KiB
Rust
Raw Normal View History

//! Phase 91: CoreServices 定義
//!
//! Ring1-Core: core_required Box の Service trait 群。
//! Phase 87 CoreBoxId の core_required (6個) 全てをカバー。
use crate::box_trait::NyashBox;
use crate::runtime::CoreBoxId;
use std::sync::Arc;
refactor(phase96.5): use文整理とコメント更新 - コード可読性向上 Phase 96.5完了 - コード整理とメンテナンス性向上 ### 変更内容 - ✅ use文をトップレベルに集約(10行削除) - ✅ コメント更新(Phase 96 → Phase 97) - ✅ テスト9/9 PASS(100%) ### use文整理 **Before**: 各メソッド内で重複import ```rust fn get(&self, arr: &dyn NyashBox, index: i64) -> Option<Box<dyn NyashBox>> { use crate::boxes::array::ArrayBox; // 重複 use crate::box_trait::IntegerBox; // 重複 // ... } ``` **After**: トップレベルで一度だけimport ```rust // トップレベル use crate::boxes::array::ArrayBox; use crate::boxes::map_box::MapBox; use crate::box_trait::{IntegerBox, StringBox, BoolBox}; fn get(&self, arr: &dyn NyashBox, index: i64) -> Option<Box<dyn NyashBox>> { // use不要!スッキリ! } ``` ### コメント更新 - IntegerBoxAdapter: "Phase 96 以降で実装" → "Phase 97 で実装予定(純粋関数型として実装)" - BoolBoxAdapter: "Phase 96 以降で実装" → "Phase 97 で実装予定(純粋関数型として実装)" ### 改善効果 - ✅ 可読性向上(use文の重複削除) - ✅ メンテナンス性向上(import一箇所集約) - ✅ コメント整合性(実際のPhase計画と一致) ### 削減統計 - use文: 10行削除 - コメント: 2箇所更新 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:30:26 +09:00
// Phase 96.5: Adapter実装で使用するBox型をトップレベルでimport
use crate::box_trait::{BoolBox, IntegerBox, StringBox};
refactor(phase96.5): use文整理とコメント更新 - コード可読性向上 Phase 96.5完了 - コード整理とメンテナンス性向上 ### 変更内容 - ✅ use文をトップレベルに集約(10行削除) - ✅ コメント更新(Phase 96 → Phase 97) - ✅ テスト9/9 PASS(100%) ### use文整理 **Before**: 各メソッド内で重複import ```rust fn get(&self, arr: &dyn NyashBox, index: i64) -> Option<Box<dyn NyashBox>> { use crate::boxes::array::ArrayBox; // 重複 use crate::box_trait::IntegerBox; // 重複 // ... } ``` **After**: トップレベルで一度だけimport ```rust // トップレベル use crate::boxes::array::ArrayBox; use crate::boxes::map_box::MapBox; use crate::box_trait::{IntegerBox, StringBox, BoolBox}; fn get(&self, arr: &dyn NyashBox, index: i64) -> Option<Box<dyn NyashBox>> { // use不要!スッキリ! } ``` ### コメント更新 - IntegerBoxAdapter: "Phase 96 以降で実装" → "Phase 97 で実装予定(純粋関数型として実装)" - BoolBoxAdapter: "Phase 96 以降で実装" → "Phase 97 で実装予定(純粋関数型として実装)" ### 改善効果 - ✅ 可読性向上(use文の重複削除) - ✅ メンテナンス性向上(import一箇所集約) - ✅ コメント整合性(実際のPhase計画と一致) ### 削減統計 - use文: 10行削除 - コメント: 2箇所更新 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:30:26 +09:00
use crate::boxes::array::ArrayBox;
use crate::boxes::map_box::MapBox;
/// StringBox Service trait
///
/// Phase 95: len のみ実装
pub trait StringService: Send + Sync {
fn len(&self, s: &str) -> i64;
}
/// IntegerBox Service trait
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
///
/// Phase 97: 純粋関数型(加算・減算・比較など)
pub trait IntegerService: Send + Sync {
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
/// 2つの整数を加算
fn add(&self, a: i64, b: i64) -> i64;
/// 2つの整数を減算
fn sub(&self, a: i64, b: i64) -> i64;
/// 2つの整数を乗算
fn mul(&self, a: i64, b: i64) -> i64;
/// 2つの整数を除算ゼロ除算はNone
fn div(&self, a: i64, b: i64) -> Option<i64>;
}
/// BoolBox Service trait
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
///
/// Phase 97: 純粋関数型(論理演算)
pub trait BoolService: Send + Sync {
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
/// 論理NOT
fn not(&self, value: bool) -> bool;
/// 論理AND
fn and(&self, a: bool, b: bool) -> bool;
/// 論理OR
fn or(&self, a: bool, b: bool) -> bool;
/// 論理XOR
fn xor(&self, a: bool, b: bool) -> bool;
}
/// ArrayBox Service trait
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
///
/// Phase 96: len/get/set/push 実装
pub trait ArrayService: Send + Sync {
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
/// 配列の要素数を取得
fn len(&self, arr: &dyn NyashBox) -> i64;
/// 指定インデックスの要素を取得
fn get(&self, arr: &dyn NyashBox, index: i64) -> Option<Box<dyn NyashBox>>;
/// 指定インデックスに要素を設定
fn set(&self, arr: &dyn NyashBox, index: i64, value: Box<dyn NyashBox>) -> Result<(), String>;
/// 配列の末尾に要素を追加
fn push(&self, arr: &dyn NyashBox, value: Box<dyn NyashBox>) -> Result<(), String>;
}
/// MapBox Service trait
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
///
/// Phase 96: size/has/get/set 実装
pub trait MapService: Send + Sync {
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
/// マップのサイズを取得
fn size(&self, map: &dyn NyashBox) -> i64;
/// キーが存在するか確認
fn has(&self, map: &dyn NyashBox, key: &str) -> bool;
/// 値を取得
fn get(&self, map: &dyn NyashBox, key: &str) -> Option<Box<dyn NyashBox>>;
/// 値を設定
fn set(&self, map: &dyn NyashBox, key: &str, value: Box<dyn NyashBox>) -> Result<(), String>;
}
/// ConsoleBox Service trait
///
/// Phase 95: println と print のみ実装
pub trait ConsoleService: Send + Sync {
fn println(&self, msg: &str);
fn print(&self, msg: &str);
}
/// CoreServices: core_required Box の集合
///
/// Phase 85 設計原則:
/// - core_required は必ず全て揃っていなければならない
/// - 起動時に全フィールドが初期化されていることを保証
///
/// Phase 87 CoreBoxId との対応:
/// - String → string
/// - Integer → integer
/// - Bool → bool
/// - Array → array
/// - Map → map
/// - Console → console
///
/// Phase 103: Optional化対応
/// - 各サービスは Option<Arc<dyn XyzService>> に変更
/// - ConsoleBox は必須Graceful Degradation原則
pub struct CoreServices {
pub string: Option<Arc<dyn StringService>>,
pub integer: Option<Arc<dyn IntegerService>>,
pub bool: Option<Arc<dyn BoolService>>,
pub array: Option<Arc<dyn ArrayService>>,
pub map: Option<Arc<dyn MapService>>,
pub console: Option<Arc<dyn ConsoleService>>,
}
impl std::fmt::Debug for CoreServices {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("CoreServices")
.field("string", &"StringService")
.field("integer", &"IntegerService")
.field("bool", &"BoolService")
.field("array", &"ArrayService")
.field("map", &"MapService")
.field("console", &"ConsoleService")
.finish()
}
}
impl CoreServices {
/// Phase 87 CoreBoxId の core_required (6個) を返す
///
/// Phase 87 CoreBoxId::is_core_required() と完全一致する。
pub fn required_ids() -> &'static [CoreBoxId] {
&[
CoreBoxId::String,
CoreBoxId::Integer,
CoreBoxId::Bool,
CoreBoxId::Array,
CoreBoxId::Map,
CoreBoxId::Console,
]
}
/// 全フィールドが初期化されているか検証
/// Phase 92 以降で各 Service の初期化を検証
pub fn ensure_initialized(&self) {
// Phase 91 では trait が空なので何もしない
// Phase 92 以降で各 Service の初期化を検証
}
}
// ============================================================================
// Phase 94: Adapter Pattern - Box → Service 変換
// ============================================================================
/// StringBox → StringService Adapter
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
///
/// Phase 95.5: 純粋関数設計
/// - Box を保持せず、純粋関数として実装
/// - len(s) → s.chars().count() (UTF-8 文字数)
/// - Phase 96 以降で substring(), concat() など追加予定
pub struct StringBoxAdapter;
impl StringBoxAdapter {
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
pub fn new() -> Self {
Self
}
}
impl StringService for StringBoxAdapter {
fn len(&self, s: &str) -> i64 {
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
// Phase 95.5: 文字列長を返すUTF-8 バイト数ではなく文字数)
s.chars().count() as i64
}
}
/// IntegerBox → IntegerService Adapter
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
///
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
/// Phase 97: 純粋関数型Box状態不要
pub struct IntegerBoxAdapter;
impl IntegerBoxAdapter {
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
pub fn new() -> Self {
Self
feat(phase93): with_core_from_registry implementation complete Phase 93 完了: UnifiedBoxRegistry 統合実装 & 起動パス統合 **実装内容**: - with_core_from_registry() 実装 - UnifiedBoxRegistry.has_type() で core Box の存在確認 - 不足時は CoreInitError::MissingService を返す - ダミー Service 実装で CoreServices を構築 - ダミー Service 実装を pub に - DummyStringService, DummyIntegerService 等を公開 - Phase 94 の実変換までの橋渡し - CoreServices::dummy() ヘルパー追加 - フォールバック用ダミー実装 - initialize_runtime() 実装(環境変数制御) - NYASH_USE_PLUGIN_HOST=1 で PluginHost 有効化 - 環境変数なしで従来通り動作(後方互換性) - selfhost に PluginHost 初期化追加 - CoreInitError 発生時は fail-fast - 既存ロジックは変更なし **Fail-Fast 設計**: - 起動時に core Box 不足を即座に検出 - CoreInitError で明示的なエラーメッセージ - デバッグ容易(ランタイムエラーではなく起動時エラー) **テスト結果**: - test_with_core_from_registry_missing_box 追加 - 7件全て成功 - ビルド成功(1分4秒) - 526 passed(既存36失敗は Phase 93 と無関係) **動作確認**: - 環境変数なし: 従来通り動作 ✅ - NYASH_USE_PLUGIN_HOST=1: PluginHost 初期化成功 ✅ - selfhost: fail-fast 動作確認済み ✅ **ドキュメント更新**: - Section 10 追加(77行) - 段階的展開戦略、Fail-Fast 設計を文書化 **次のステップ**: Phase 94 (実際の Box → Service 変換) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 08:42:45 +09:00
}
}
impl IntegerService for IntegerBoxAdapter {
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
fn add(&self, a: i64, b: i64) -> i64 {
a.saturating_add(b) // オーバーフロー対策
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
}
fn sub(&self, a: i64, b: i64) -> i64 {
a.saturating_sub(b) // アンダーフロー対策
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
}
fn mul(&self, a: i64, b: i64) -> i64 {
a.saturating_mul(b) // オーバーフロー対策
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
}
fn div(&self, a: i64, b: i64) -> Option<i64> {
if b == 0 {
None // ゼロ除算
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
} else {
Some(a / b)
}
}
}
/// BoolBox → BoolService Adapter
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
///
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
/// Phase 97: 純粋関数型Box状態不要
pub struct BoolBoxAdapter;
impl BoolBoxAdapter {
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
pub fn new() -> Self {
Self
}
}
impl BoolService for BoolBoxAdapter {
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
fn not(&self, value: bool) -> bool {
!value
}
fn and(&self, a: bool, b: bool) -> bool {
a && b
}
fn or(&self, a: bool, b: bool) -> bool {
a || b
}
fn xor(&self, a: bool, b: bool) -> bool {
a ^ b
}
}
/// ArrayBox → ArrayService Adapter
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
///
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
/// Phase 96: downcast パターンで複数インスタンス対応
pub struct ArrayBoxAdapter;
impl ArrayBoxAdapter {
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
pub fn new() -> Self {
Self
}
}
impl ArrayService for ArrayBoxAdapter {
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
fn len(&self, arr: &dyn NyashBox) -> i64 {
arr.as_any()
.downcast_ref::<ArrayBox>()
.map(|a| a.len() as i64)
.unwrap_or(0)
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
}
fn get(&self, arr: &dyn NyashBox, index: i64) -> Option<Box<dyn NyashBox>> {
let arr_box = arr.as_any().downcast_ref::<ArrayBox>()?;
let index_box = Box::new(IntegerBox::new(index));
Some(arr_box.get(index_box))
}
fn set(&self, arr: &dyn NyashBox, index: i64, value: Box<dyn NyashBox>) -> Result<(), String> {
let arr_box = arr
.as_any()
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
.downcast_ref::<ArrayBox>()
.ok_or("Not an ArrayBox")?;
let index_box = Box::new(IntegerBox::new(index));
arr_box.set(index_box, value);
Ok(())
}
fn push(&self, arr: &dyn NyashBox, value: Box<dyn NyashBox>) -> Result<(), String> {
let arr_box = arr
.as_any()
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
.downcast_ref::<ArrayBox>()
.ok_or("Not an ArrayBox")?;
arr_box.push(value);
Ok(())
}
}
/// MapBox → MapService Adapter
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
///
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
/// Phase 96: downcast パターンで複数インスタンス対応
pub struct MapBoxAdapter;
impl MapBoxAdapter {
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
pub fn new() -> Self {
Self
}
}
impl MapService for MapBoxAdapter {
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
fn size(&self, map: &dyn NyashBox) -> i64 {
map.as_any()
.downcast_ref::<MapBox>()
.map(|m| {
// MapBox::size() は Box<dyn NyashBox> を返すため、IntegerBox に変換
let size_box = m.size();
size_box
.as_any()
.downcast_ref::<IntegerBox>()
.map(|i| i.value)
.unwrap_or(0)
})
.unwrap_or(0)
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
}
fn has(&self, map: &dyn NyashBox, key: &str) -> bool {
let map_box = match map.as_any().downcast_ref::<MapBox>() {
Some(m) => m,
None => return false,
};
let key_box = Box::new(StringBox::new(key));
let result = map_box.has(key_box);
result
.as_any()
.downcast_ref::<BoolBox>()
.map(|b| b.value)
.unwrap_or(false)
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
}
fn get(&self, map: &dyn NyashBox, key: &str) -> Option<Box<dyn NyashBox>> {
let map_box = map.as_any().downcast_ref::<MapBox>()?;
let key_box = Box::new(StringBox::new(key));
Some(map_box.get(key_box))
}
fn set(&self, map: &dyn NyashBox, key: &str, value: Box<dyn NyashBox>) -> Result<(), String> {
let map_box = map
.as_any()
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
.downcast_ref::<MapBox>()
.ok_or("Not a MapBox")?;
let key_box = Box::new(StringBox::new(key));
map_box.set(key_box, value);
Ok(())
}
}
/// ConsoleBox → ConsoleService Adapter
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
///
/// Phase 95.5: Ring0 直結設計
/// - Box を保持せず、Ring0Context に直結
/// - println() → Ring0Context.log.info()
/// - print() → Ring0Context.io.stdout_write()
pub struct ConsoleBoxAdapter;
impl ConsoleBoxAdapter {
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
pub fn new() -> Self {
Self
}
}
impl ConsoleService for ConsoleBoxAdapter {
fn println(&self, msg: &str) {
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
// Phase 95.5: Ring0Context 経由でログ出力(自動改行)
use crate::runtime::ring0::get_global_ring0;
let ring0 = get_global_ring0();
ring0.log.info(msg);
}
fn print(&self, msg: &str) {
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
// Phase 95.5: Ring0Context 経由で stdout 出力(改行なし)
use crate::runtime::ring0::get_global_ring0;
let ring0 = get_global_ring0();
ring0.io.stdout_write(msg.as_bytes()).ok();
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_required_ids_consistency() {
let required = CoreServices::required_ids();
assert_eq!(required.len(), 6);
// Phase 87 CoreBoxId::is_core_required() と一致
for id in required {
assert!(id.is_core_required());
}
// 全ての core_required が含まれているか確認
assert!(required.contains(&CoreBoxId::String));
assert!(required.contains(&CoreBoxId::Integer));
assert!(required.contains(&CoreBoxId::Bool));
assert!(required.contains(&CoreBoxId::Array));
assert!(required.contains(&CoreBoxId::Map));
assert!(required.contains(&CoreBoxId::Console));
}
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
// Phase 95.5: Ring0 初期化ヘルパー(テスト用)
#[cfg(test)]
fn ensure_ring0_initialized() {
use crate::runtime::ring0::{default_ring0, GLOBAL_RING0};
use std::sync::Arc;
// 既に初期化済みなら何もしない
if GLOBAL_RING0.get().is_none() {
GLOBAL_RING0.set(Arc::new(default_ring0())).ok();
}
}
#[test]
fn test_console_service_println() {
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
// Phase 95.5: Ring0 初期化(安全な初期化)
ensure_ring0_initialized();
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
let adapter = ConsoleBoxAdapter::new();
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
// Phase 95.5: println を呼び出しRing0 経由、panic しないことを確認)
adapter.println("Test message from Ring0");
// 実際の出力検証は Phase 96 以降
}
#[test]
fn test_console_service_print() {
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
// Phase 95.5: Ring0 初期化(安全な初期化)
ensure_ring0_initialized();
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
let adapter = ConsoleBoxAdapter::new();
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
// Phase 95.5: print を呼び出しRing0 経由、panic しないことを確認)
adapter.print("No newline");
// 実際の出力検証は Phase 96 以降
}
#[test]
fn test_string_service_len() {
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
// Phase 95.5: 純粋関数なので Ring0 不要
let adapter = StringBoxAdapter::new();
// Phase 95: len を呼び出し
let length = adapter.len("Hello");
assert_eq!(length, 5);
// UTF-8 対応確認
let length_utf8 = adapter.len("こんにちは");
assert_eq!(length_utf8, 5); // 5文字バイト数は15
}
feat(phase95.5): Ring0統合完了 - Adapter整理とコード簡略化 Phase 95.5完全達成 - ConsoleService/StringService Ring0直結化 ### 実装成果 - ✅ ConsoleBoxAdapter Ring0直結(println → log.info, print → io.stdout_write) - ✅ StringBoxAdapter 純粋関数化(Box状態不要) - ✅ #[allow(dead_code)] 6→4箇所削減(2削除) - ✅ PluginHost初期化簡略化(存在確認のみ) - ✅ テスト14/14 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ConsoleBoxAdapter/StringBoxAdapter unit struct化 - src/runtime/plugin_host.rs: 初期化ロジック簡略化(create_box → has_type) - docs/development/current/main/core_boxes_design.md: Section 12追加 - CURRENT_TASK.md: Phase 95.5成果記録 ### 設計パターン確立 **2つのAdapterパターン**: 1. Ring0直結型(ConsoleService): OS API thin wrapper 2. 純粋関数型(StringService): Box状態不要 **将来実装方針**: - ArrayService/MapService: 状態管理必要 → Box保持 - IntegerService/BoolService: 純粋関数 → Box不要 ### 技術的成果 - Ring0統合完成(ログ経路統一: Ring0 → Ring1-Core → 実行パス) - コード簡略化(不要なinnerフィールド削除) - 設計明確化(Adapterの役割を2パターンに整理) - テスト容易性向上(Ring0モック可能) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96: ArrayService/MapService実装(downcastパターン) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:15:23 +09:00
#[test]
fn test_console_service_ring0_integration() {
// Phase 95.5: Ring0 初期化(安全な初期化)
ensure_ring0_initialized();
// ConsoleService 経由で出力Ring0 使用)
let adapter = ConsoleBoxAdapter::new();
adapter.println("Test message from Ring0");
adapter.print("No newline");
// panic しないことを確認
}
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
#[test]
fn test_array_service_basic_operations() {
use crate::box_trait::IntegerBox;
use crate::boxes::array::ArrayBox;
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
let arr = ArrayBox::new();
let adapter = ArrayBoxAdapter::new();
// push
let value = Box::new(IntegerBox::new(42));
adapter.push(&arr, value).unwrap();
// len
assert_eq!(adapter.len(&arr), 1);
// get
let result = adapter.get(&arr, 0).unwrap();
let int_box = result.as_any().downcast_ref::<IntegerBox>().unwrap();
assert_eq!(int_box.value, 42);
}
#[test]
fn test_array_service_set() {
use crate::box_trait::IntegerBox;
use crate::boxes::array::ArrayBox;
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
let arr = ArrayBox::new();
let adapter = ArrayBoxAdapter::new();
// push initial value
adapter.push(&arr, Box::new(IntegerBox::new(10))).unwrap();
// set
adapter.set(&arr, 0, Box::new(IntegerBox::new(20))).unwrap();
// verify
let result = adapter.get(&arr, 0).unwrap();
let int_box = result.as_any().downcast_ref::<IntegerBox>().unwrap();
assert_eq!(int_box.value, 20);
}
#[test]
fn test_map_service_basic_operations() {
use crate::box_trait::StringBox;
use crate::boxes::map_box::MapBox;
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
let map = MapBox::new();
let adapter = MapBoxAdapter::new();
// set
let value = Box::new(StringBox::new("Hello"));
adapter.set(&map, "key1", value).unwrap();
// has
assert!(adapter.has(&map, "key1"));
assert!(!adapter.has(&map, "key2"));
// get
let result = adapter.get(&map, "key1").unwrap();
let str_box = result.as_any().downcast_ref::<StringBox>().unwrap();
assert_eq!(str_box.value, "Hello");
// size
assert_eq!(adapter.size(&map), 1);
}
#[test]
fn test_map_service_multiple_keys() {
use crate::box_trait::{IntegerBox, StringBox};
use crate::boxes::map_box::MapBox;
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
let map = MapBox::new();
let adapter = MapBoxAdapter::new();
// set multiple keys
adapter
.set(&map, "name", Box::new(StringBox::new("Alice")))
.unwrap();
adapter
.set(&map, "age", Box::new(IntegerBox::new(25)))
.unwrap();
feat(phase96): ArrayService/MapService実装完了 - downcastパターン確立 Phase 96完全達成 - Ring1-Core層の主要Service実装完成 ### 実装成果 - ✅ ArrayService trait定義(len/get/set/push) - ✅ MapService trait定義(size/has/get/set) - ✅ ArrayBoxAdapter/MapBoxAdapter unit struct化 - ✅ downcastパターン実装(複数インスタンス対応) - ✅ #[allow(dead_code)] 4→2箇所(2削除) - ✅ テスト53/53 PASS(100%) ### 変更ファイル - src/runtime/core_services.rs: ArrayService/MapService実装(+134行) - src/runtime/plugin_host.rs: 初期化ロジック更新(+8/-12行) - docs/development/current/main/core_boxes_design.md: Section 13追加(+228行) ### 3つのAdapterパターン確立 1. **Ring0直結型**(ConsoleService): OS API thin wrapper 2. **純粋関数型**(StringService): Box状態不要 3. **downcast型**(ArrayService/MapService)⭐ NEW - unit struct + downcast_ref パターン - 複数インスタンス対応 - Rust idiomatic API(Option/Result) ### API設計 - ArrayService: Rust型(i64)引数、内部でBox変換 - MapService: Rust型(&str)引数、内部でBox変換 - 戻り値: Option/Result で型安全 ### 技術的成果 - 型安全性向上(downcast_ref によるコンパイル時検証) - コード簡略化(#[allow(dead_code)] 2削除) - 設計明確化(3パターンの使い分け確立) ### 削減統計 - #[allow(dead_code)]: 2箇所削除 - innerフィールド: 2個削除 - Box依存: 2箇所削除 ### 次のステップ Phase 96.5: use文整理とコメント更新 Phase 97: IntegerService/BoolService実装(#[allow(dead_code)] 完全削除) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:27:39 +09:00
// verify size
assert_eq!(adapter.size(&map), 2);
// verify values
let name = adapter.get(&map, "name").unwrap();
let name_str = name.as_any().downcast_ref::<StringBox>().unwrap();
assert_eq!(name_str.value, "Alice");
let age = adapter.get(&map, "age").unwrap();
let age_int = age.as_any().downcast_ref::<IntegerBox>().unwrap();
assert_eq!(age_int.value, 25);
}
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
#[test]
fn test_integer_service_operations() {
let adapter = IntegerBoxAdapter::new();
// add
assert_eq!(adapter.add(10, 20), 30);
assert_eq!(adapter.add(i64::MAX, 1), i64::MAX); // saturating
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
// sub
assert_eq!(adapter.sub(20, 10), 10);
assert_eq!(adapter.sub(i64::MIN, 1), i64::MIN); // saturating
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
// mul
assert_eq!(adapter.mul(5, 6), 30);
assert_eq!(adapter.mul(i64::MAX, 2), i64::MAX); // saturating
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
// div
assert_eq!(adapter.div(20, 5), Some(4));
assert_eq!(adapter.div(10, 3), Some(3)); // 整数除算
assert_eq!(adapter.div(10, 0), None); // ゼロ除算
feat(runtime): Phase 97 IntegerService/BoolService 完全実装 - #[allow(dead_code)] 100%根絶達成 ## Phase 97 完了項目 - ✅ IntegerService trait & Adapter実装(add/sub/mul/div, saturating算術) - ✅ BoolService trait & Adapter実装(not/and/or/xor) - ✅ #[allow(dead_code)] 6箇所→0箇所(100%削減完了) - ✅ 全13テストPASS(IntegerService 2テスト、BoolService 1テスト追加) ## 技術的成果 **3つのAdapterパターン確立完了**: 1. Ring0直結型: ConsoleService(OS API thin wrapper) 2. 純粋関数型: StringService, IntegerService, BoolService(stateless) 3. downcast型: ArrayService, MapService(複数インスタンス対応) **CoreServices完全実装**: - core_required 6個すべて実装完了 - String, Integer, Bool, Array, Map, Console **オーバーフロー対策**: - saturating_add/sub/mul でi64オーバーフロー安全 - div はゼロ除算でOption::None返却 ## 実装詳細 - src/runtime/core_services.rs: +74行(IntegerService/BoolService traits & impls) - src/runtime/plugin_host.rs: +2行(Integer/Bool初期化チェック) - docs/development/current/main/core_boxes_design.md: +256行(Section 14追加) ## Phase 85-97 総括 - Phase 85: 構造設計(CoreServices/PluginHost skeleton) - Phase 91-94: PluginHost実装 & 箱化モジュール化 - Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型) - Phase 96: ArrayService/MapService(downcast型) - Phase 96.5: コード整理(use文統合、コメント更新) - Phase 97: IntegerService/BoolService(純粋関数型) ✅ 完了 次: Phase 98(代表パス拡張 5-10箇所) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:41:16 +09:00
}
#[test]
fn test_bool_service_operations() {
let adapter = BoolBoxAdapter::new();
// not
assert_eq!(adapter.not(true), false);
assert_eq!(adapter.not(false), true);
// and
assert_eq!(adapter.and(true, true), true);
assert_eq!(adapter.and(true, false), false);
assert_eq!(adapter.and(false, false), false);
// or
assert_eq!(adapter.or(true, false), true);
assert_eq!(adapter.or(false, false), false);
// xor
assert_eq!(adapter.xor(true, false), true);
assert_eq!(adapter.xor(true, true), false);
assert_eq!(adapter.xor(false, false), false);
}
}