10e6a15552
refactor: unify string helpers and pattern2 derived slot
2025-12-28 13:22:02 +09:00
0269fc2ed4
Reduce build warnings
2025-12-28 01:34:46 +09:00
0d6229d5a2
Stabilize joinir tests and env guards
2025-12-27 17:41:30 +09:00
2e99b14e24
phase-29y.1: add lifecycle pilot plumbing (ABI shim, rc pass skeleton, root summary)
2025-12-27 02:07:10 +09:00
606e236d6d
fix(phase-285): restore weak_basic_llvm + complete LLVM detection/quick SSOT
2025-12-26 16:32:37 +09:00
86dfa30abe
chore(joinir): Phase 286C-5 Step 3 - Remove unused imports
...
Ran `cargo fix --allow-dirty --lib` to automatically remove unused imports
across the codebase. This cleanup is standard maintenance and improves code
hygiene.
**Files Modified**:
- instruction_rewriter.rs: Removed 6 unused imports
- block_remapper::remap_block_id
- LoweringDecision
- ParameterBindingBox
- propagate_value_type_for_inst (2 occurrences)
- apply_remapped_terminator
- PhiAdjustment, ParameterBinding from scan_box
- Other files: Minor unused import cleanup (12 files total)
**No Functional Changes**: Pure cleanup, all tests expected to pass.
Phase 286C-5 progress: 3/4 steps complete
Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-25 05:18:06 +09:00
f740e6542f
feat(phase285): Complete weak reference implementation (VM + LLVM harness)
...
Phase 285LLVM-1.1 to 1.4 + weak reference infrastructure:
**LLVM Harness** (Phase 285LLVM-1.x):
- 285LLVM-1.1: User Box registration & debug output
- 285LLVM-1.2: WeakRef basic operations (identity deferred)
- 285LLVM-1.3: InstanceBox field access (getField/setField)
- 285LLVM-1.4: print Handle resolution (type tag propagation)
**VM Runtime** (nyash_kernel):
- FFI functions: nyrt_weak_new, nyrt_weak_to_strong, nyrt_weak_drop
(crates/nyash_kernel/src/lib.rs: +209 lines)
- WeakRef plugin invoke support
(crates/nyash_kernel/src/plugin/invoke.rs: +250 lines)
- weak_handles.rs: WeakRef handle registry (NEW)
**LLVM Python Backend**:
- WeakRef instruction lowering (weak.py: NEW)
- Entry point integration (entry.py: +93 lines)
- Instruction lowering (instruction_lower.py: +13 lines)
- LLVM harness runner script (tools/run_llvm_harness.sh: NEW)
**MIR & Runtime**:
- WeakRef emission & validation
- MIR JSON export for weak instructions
- Environment variable support (NYASH_WEAK_*, HAKO_WEAK_*)
**Documentation**:
- CLAUDE.md: Phase 285 completion notes
- LANGUAGE_REFERENCE_2025.md: Weak reference syntax
- 10-Now.md & 30-Backlog.md: Phase 285 status updates
Total: +864 lines, 24 files changed
SSOT: docs/reference/language/lifecycle.md
Related: Phase 285W-Syntax-0, Phase 285W-Syntax-0.1
2025-12-25 00:11:34 +09:00
80f3403049
refactor(config): Phase 286A/B/287 - Config system consolidation
...
Phase 286A: Macro environment variable consolidation
- src/config/env/macro_flags.rs: NYASH_MACRO_* flags centralized
- Removed duplicate ny_compiler_* functions (keep in selfhost_flags.rs)
- Fixed deprecation warning logic (return None when env var not set)
- Updated callers: src/macro/{ctx,engine,macro_box,macro_box_ny,mod}.rs
Phase 286B: Box Factory environment variable consolidation
- src/config/env/box_factory_flags.rs: NYASH_BOX_FACTORY_* flags centralized
- Updated callers: src/box_factory/mod.rs, src/runtime/plugin_loader*.rs
Phase 287: Config Catalog implementation
- src/config/env/catalog.rs: New catalog for all config modules
Fixes:
- Type mismatches: Added .unwrap_or(false) for Option<bool> returns (7 locations)
- Deprecation warnings: Fixed macro_toplevel_allow() & macro_box_child_runner() logic
- Module organization: Added module declarations in src/config/env.rs
Note: Files force-added with git add -f due to .gitignore env/ pattern
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-24 08:43:48 +09:00
ab76e39036
feat(parser): Phase 285A1.4 & A1.5 - Weak field sugar + Parser hang fix
...
A1.4: Add sugar syntax `public weak parent` ≡ `public { weak parent }`
A1.5: Fix parser hang on unsupported `param: Type` syntax
Key changes:
- A1.4: Extend visibility parser to handle weak modifier (fields.rs)
- A1.5: Shared helper `parse_param_name_list()` with progress-zero detection
- A1.5: Fix 6 vulnerable parameter parsing loops (methods, constructors, functions)
- Tests: Sugar syntax (OK/NG), parser hang (timeout-based)
- Docs: lifecycle.md, EBNF.md, phase-285a1-boxification.md
Additional changes:
- weak() builtin implementation (handlers/weak.rs)
- Leak tracking improvements (leak_tracker.rs)
- Documentation updates (lifecycle, types, memory-finalization, etc.)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-24 07:44:50 +09:00
7c9f453fc6
refactor(mir): phase261 p0 enforce edge-args writer ssot (verify + sync)
2025-12-21 08:32:04 +09:00
6d73fc3404
feat(llvm): Phase 97 Box/Policy refactoring complete
...
Box化完了:
- CallRoutePolicyBox: Call routing SSoT
- PrintArgMarshallerBox: Print marshalling SSoT
- TypeFactsBox: Type propagation SSoT
- PhiSnapshotPolicyBox: PHI contract SSoT
- PluginErrorContext: Structured error reporting
📋 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 04:14:26 +09:00
65763c1ed6
feat(llvm): Phase 97 - Call/PHI/Plugin強化 + リファクタリング準備
...
## 概要
LLVM backend のCall処理、PHI wiring、Plugin loader を強化。
次のリファクタリング(箱化モジュール化)のための準備も含む。
## 変更内容
### LLVM Call処理強化
- `mir_call/__init__.py`: Call ルーティングロジック改善
- `mir_call/global_call.py`: print処理の marshal強化
- `mir_call/method_call.py`: メソッド呼び出し処理改善
- `boxcall.py`: BoxCall処理改善
### PHI処理強化
- `phi_manager.py`: PHI管理改善
- `phi_wiring/wiring.py`: PHI配線ロジック強化(+17行)
- `phi_wiring/tagging.py`: Type tagging改善
- `resolver.py`: Value解決ロジック強化(+34行)
### Copy伝播
- `copy.py`: Copy命令のType tag伝播追加(+10行)
### Plugin loader強化
- `library.rs`: エラー出力改善、[plugin/missing]ログ追加(+34行)
- fail-fast強化
### テスト
- `phase97_json_loader_escape_llvm_exe.sh`: Phase 97 E2Eテスト追加
- `phase97_next_non_ws_llvm_exe.sh`: Phase 97 E2Eテスト追加
### その他
- `nyash_kernel/lib.rs`: Kernel側の改善(+23行)
## 統計
- 14ファイル変更
- +256行 / -53行 = +203 net
## 次のリファクタリング準備
以下の箇所がリファクタリング対象として識別済み:
1. Call ルーティング箱の明文化
2. print の marshal 箱
3. TypeFacts/Tagging 箱の一本化
4. PHI Snapshot 契約のSSOT
5. Plugin loader のエラー出力統合
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 03:51:03 +09:00
ccd2342376
feat(plugin_loader): Phase 134 P0 - Best-effort plugin loading (continue on failures)
2025-12-15 17:00:51 +09:00
af6f95cd4b
Phase 33 NORM canon test: enforce normalized dev route for P1/P2/JP mini
2025-12-11 20:54:33 +09:00
8e3b55ddec
feat(joinir): Phase 224-C - MethodCallLowerer with argument support
...
- Add StringIndexOf to CoreMethodId (arity=1, return IntegerBox)
- Extend MethodCallLowerer to handle methods with arguments
- Add arity checking against CoreMethodId metadata
- Recursive argument lowering via lower_value_expression
- 8 unit tests PASS (indexOf, substring, arity mismatch)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 18:19:14 +09:00
250555bfc0
feat(joinir): Phase 224-B - MethodCallLowerer + CoreMethodId extension
...
- Extend CoreMethodId with is_pure(), allowed_in_condition(), allowed_in_init()
- New MethodCallLowerer box for metadata-driven MethodCall lowering
- Integrate MethodCall handling in condition_lowerer
- P0: Zero-argument methods (length) supported
- Design principle: NO method name hardcoding, CoreMethodId metadata only
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 17:59:24 +09:00
440f8646b1
feat(joinir): Phase 183 LoopBodyLocal role separation + test fixes
...
Phase 183 Implementation:
- Added is_var_used_in_condition() helper for AST variable detection
- Implemented LoopBodyLocal filtering in TrimLoopLowerer
- Created 4 test files for P1/P2 patterns
- Added 5 unit tests for variable detection
Test Fixes:
- Fixed test_is_outer_scope_variable_pinned (BasicBlockId import)
- Fixed test_pattern2_accepts_loop_param_only (literal node usage)
Refactoring:
- Unified pattern detection documentation
- Consolidated CarrierInfo initialization
- Documented LoopScopeShape construction paths
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-08 23:43:26 +09:00
e328be0307
Phase 122.5-126完了:ConsoleBox 品質改善・最適化・統合
...
## 実装成果(Phase 122.5-126)
### Phase 122.5: nyash.toml method_id 修正
- println method_id を 2 → 1 に統一(log と同じ)
- TypeRegistry slot 400 との整合性確保
### Phase 123: ConsoleBox WASM/非WASM コード統一化
- マクロ define_console_impl! による重複排除
- 67行削減(27.3% 削減達成)
- ビルド成功・全テストパス
### Phase 124: VM Method Dispatch 統一化
- TypeRegistry ベースの統一ディスパッチ (dispatch_by_slot)
- String/Array/ConsoleBox を一元化
- 100行削減、メソッド解決の高速化
### Phase 125: 削除:deprecated builtin ConsoleBox
- src/box_factory/builtin_impls/console_box.rs 削除
- Plugin-only 移行で "Everything is Plugin" 実現
- 52行削減
### Phase 126: ドキュメント統合
- consolebox_complete_guide.md (27KB統合マスター)
- core_boxes_design/logging_policy/hako_logging_design 更新
- ~750行の navigation・cross-reference 改善
## 数値成果
- **総コード削減**: 219行
- **新規ドキュメント**: 1ファイル (+27KB)
- **更新ドキュメント**: 6ファイル (+~750行)
- **テスト**: Phase 120 representative tests ✅ PASS
- **ビルド**: Zero errors
## 設計原則の完全実現
✅ println/log エイリアス統一(Phase 122)
✅ WASM/非WASM 統一化(Phase 123)
✅ TypeRegistry 統合(Phase 124)
✅ Plugin-only 移行(Phase 125)
✅ ドキュメント統合(Phase 126)
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-04 06:02:03 +09:00
024a09c15b
feat(core): Phase 122 ConsoleBox.println / log unification
...
## Phase 122: ConsoleBox.println / log の統一 (完了)
### 概要
ConsoleBox.printlnをlogのエイリアスとしてVM/TypeRegistryレベルで統一。
Phase 120で発見されたesc_dirname_smoke.hakoの「Unknown method 'println'」
エラーを完全解消。
### 完了タスク
- ✅ TypeRegistry修正: printlnをlogのエイリアス(slot 400)として追加
- ✅ ConsoleBox実装: printlnメソッドのラッパ追加
- ✅ VM Method Dispatch: ConsoleBox専用ハンドラ追加
- ✅ Plugin設定: nyash.tomlにprintln (method_id 2)追加
- ✅ ドキュメント更新: 3ファイル(hako_logging/logging_policy/core_boxes)
### 実装詳細
#### 1. TypeRegistry (src/runtime/type_registry.rs)
```rust
const CONSOLE_METHODS: &[MethodEntry] = &[
MethodEntry { name: "log", arity: 1, slot: 400 },
MethodEntry { name: "warn", arity: 1, slot: 401 },
MethodEntry { name: "error", arity: 1, slot: 402 },
MethodEntry { name: "clear", arity: 0, slot: 403 },
// Phase 122: println は log のエイリアス
MethodEntry { name: "println", arity: 1, slot: 400 },
];
```
#### 2. ConsoleBox (src/boxes/console_box.rs)
- WASM/非WASM両方にprintln()メソッド追加
- 内部的にlog()に委譲
#### 3. VM Method Dispatch (src/backend/mir_interpreter/handlers/calls/method.rs)
- ConsoleBox専用ハンドラ追加
- log/println/warn/error/clearをサポート
- args配列の正しい処理(len > 1時はargs[1]を使用)
#### 4. Plugin設定 (nyash.toml)
- ConsoleBox.methodsにprintln追加(method_id=2)
- method_id整合性: log=1, println=2
### テスト結果
- ✅ esc_dirname_smoke.hako実行成功
- 旧エラー: "Unknown method 'println'" ← **完全解消**
- 新出力: `[Console LOG] dir1/dir2`
### Phase 120問題解決
**Phase 120ベースラインでの課題**:
- ❌ esc_dirname_smoke.hako: ConsoleBox.println未実装
**Phase 122での解決**:
- ✅ TypeRegistryレベルでprintln→log正規化
- ✅ 全経路(JSON v0/selfhost/通常VM)で一貫性保証
### ファイル構成
**新規作成**:
- docs/development/current/main/phase122_consolebox_println_unification.md
**修正**:
- src/runtime/type_registry.rs (+5行)
- src/boxes/console_box.rs (+14行, WASM/非WASM両対応)
- src/backend/mir_interpreter/handlers/calls/method.rs (+60行)
- nyash.toml (+1メソッド定義)
- docs/development/current/main/hako_logging_design.md (+40行)
- docs/development/current/main/logging_policy.md (+30行)
- docs/development/current/main/core_boxes_design.md (+20行)
### 技術的成果
- **Alias First原則**: VM/TypeRegistryレベルで正規化
- **Phase 120連携**: ベースライン確立→問題発見→根本解決
- **全経路統一**: selfhost/JSON v0/通常VMすべてで動作
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-04 05:16:06 +09:00
0a49a9c897
refactor(phase112): Ring0 Service Registry コード改善
...
Phase 112 実装後のコード品質向上として4つの改善を実施
【改善1】NoFsApi エラーメッセージの定数化
- NOFS_ERROR_MSG 定数を定義して一元管理
- 5箇所の重複メッセージを1つの定数参照に統一
- タイポリスク低減・保守性向上
【改善2】Ring0Registry の build_with_fs() 抽出
- build_default() と build_no_fs() の重複(14行)を削除
- 新規ヘルパーメソッド build_with_fs(fs: Arc<dyn FsApi>) を追加
- build() メソッドを2行の match 式に簡潔化
- 将来の profile 追加時の拡張性向上
【改善3】NoFsApi テスト追加
- 7つの新規テストを追加(全 FsApi メソッドをカバー)
- test_nofs_api_read_to_string
- test_nofs_api_read
- test_nofs_api_write_all
- test_nofs_api_append_all
- test_nofs_api_exists
- test_nofs_api_metadata
- test_nofs_api_canonicalize
- テストカバレッジ大幅向上
【改善4】unsafe dealloc ヘルパー化
- unsafe_dealloc(ptr, size) ヘルパー関数を追加
- 3箇所の unsafe dealloc 呼び出しを統一
- コード可読性向上・unsafe 領域最小化
【統計】
- 2ファイル修正(+77行, -40行)
- テスト: 19 passed(既存12 + 新規7)
- ビルド: SUCCESS
【効果】
- コード重複削減(14行削除)
- テストカバレッジ向上(NoFsApi 全メソッドテスト化)
- 保守性向上(定数一元管理)
- 可読性向上(build() メソッド簡潔化)
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-04 03:18:49 +09:00
04f476d6b4
feat(phase112): Ring0 Service Registry統一化実装完了
...
Ring0 初期化を Ring0Registry::build(profile) に集約し、プロファイル対応を統一化
【実装内容】
- Task 2: Ring0Registry struct + build(profile) メソッド実装
- RuntimeProfile::Default → StdFs を使用
- RuntimeProfile::NoFs → NoFsApi を使用
- build_default()/build_no_fs() の内部メソッド分離
- Task 3: NoFsApi struct 実装(FsApi trait)
- すべてのファイルシステム操作を「disabled」として失敗させる
- read/write/append/metadata/canonicalize が IoError を返す
- exists() は false を返す
- 49行の新規実装
- Task 4: initialize_runtime() SSOT パターン確認
- env 読み込み → RuntimeProfile::from_env()
- Ring0Context 構築 → Ring0Registry::build(profile)
- グローバル登録 → init_global_ring0()
- 唯一の責務分離を確立
- Task 5: PluginHost/FileBox/FileHandleBox からの Ring0 統合
- Ring0.fs = NoFsApi の場合、すべての上位層が自動的に disabled
- 特別なロジック不要(カスケード disabled パターン)
- Task 6: ドキュメント更新
- core_boxes_design.md: Section 17 追加(88行)
- ring0-inventory.md: Phase 112 エントリ追加(16行)
- CURRENT_TASK.md: Phase 106-112 完了表更新
- phase112_ring0_registry_design.md: 完全設計書(426行)
【統計】
- 8ファイル修正(+261行, -30行)
- 3つの新テスト追加(Ring0Registry関連)
- test_ring0_registry_default_profile
- test_ring0_registry_nofs_profile
- test_default_ring0_uses_registry
- cargo build --release: SUCCESS
- 全テスト PASS
【設計原則確立】
- Ring0Registry factory pattern で profile-aware 実装選択を一本化
- NoFsApi による自動 disabled により、上位層の特別処理を排除
- initialize_runtime() が唯一の env 読み込み入口として SSOT 確立
- 将来の profile 追加(TestMock/Sandbox/ReadOnly/Embedded等)が容易に
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-03 22:19:24 +09:00
fce7555e46
feat(phase111): FileHandleBox append+metadata実装(修正案統合版)
...
Task 2: FsApi / Ring0FsFileIo 拡張
- FsApi trait に append_all(path, data) メソッド追加
- StdFsApi で append_all() を std::fs::OpenOptions で実装
- Ring0FsFileIo に mode を保持、write() で truncate/append を切り替え
- Ring0FsFileIo に内部 metadata() ヘルパ追加(FsApi.metadata() 呼び出し)
Task 3: FileHandleBox API 実装
- open(path, mode) で "r"/"w"/"a" 3モードをサポート
- write_all() で read-only mode チェック
- 内部 Rust API:size / exists / is_file / is_dir メソッド実装
(NyashBox 公開は Phase 112+ に延期)
Task 5: テスト + ドキュメント
- 4つの新テスト PASS:
- test_filehandlebox_append_mode(write→append→内容確認)
- test_filehandlebox_metadata_size(size() 取得)
- test_filehandlebox_metadata_is_file(is_file()/is_dir())
- test_filehandlebox_write_readonly_error("r"で write 拒否)
統計:
- 9ファイル修正(+316行, -35行)
- 4つの新テスト追加(既存15テスト全PASS)
- cargo build --release: SUCCESS
- 11個のチェックリスト: ✅ ALL PASS
次フェーズ(Phase 112-114)の backlog も指示書で整理済み
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-03 21:30:47 +09:00
20f978fdf9
refactor: Phase 109後のコード整理・改善(セットA/B/C完全実装)
...
全セット実装で総95行の純削減を達成(190削除, 95追加)
## Set A: Quick Wins (55行削減)
- FileBox caps check を check_write_capability() ヘルパーに統一
- is_required_in() から冗長な local variable 削除
- 未使用の CoreServicesConfig::from_env() 削除
## Set B: Architecture Refinement (65行削減)
- provider_lock の責務を「登録」のみに限定(init_* メソッド削除)
- PluginHost を initialization hub に統一
- profile-aware provider 初期化を一元化
- Default/NoFs の両 profile に対応
- FileBox::new() を Result-based に改善(Fail-Fast)
- delete()/copy() デッドコード削除(実装なし)
- PluginRegistry skeleton 削除(Phase 92 未実装プレースホルダ)
## Set C: Future-Proofing (+36行, 46追加/10削除)
- RuntimeProfile ドキュメント大幅拡充
- 現在のプロファイル(Default, NoFs)の詳細説明
- 将来のプロファイル(TestMock, Sandbox, ReadOnly, Embedded)を明示
- PluginHost::new_skeleton() 削除
## 設計改善
1. **責務分離の明確化**:
- provider_lock: 登録のみ (set/get)
- PluginHost: initialization hub (profile-aware setup)
- initialize_runtime: env読み込みのみ
2. **Fail-Fast 原則の強化**:
- FileBox provider missing → 即座にエラー(Default profile)
- new() でパニック vs try_new() で Result
3. **将来への足がかり**:
- Profile システムは拡張可能に設計
- TestMock/Sandbox/ReadOnly/Embedded への対応準備完了
テスト:
- 既存テスト: 25/25 PASS ✅
- ビルド: SUCCESS ✅
ファイル変更:
- src/boxes/file/mod.rs (-58)
- src/runtime/core_box_ids.rs (-6)
- src/runtime/mod.rs (-23)
- src/runtime/plugin_host.rs (-90)
- src/runtime/provider_lock.rs (-62)
- src/runtime/runtime_profile.rs (+46)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-03 19:58:50 +09:00
4ef3e7f56c
feat(phase109): RuntimeProfile設計で FileBox を条件付き optional に
...
Phase 109 完全実装完了:
- RuntimeProfile enum (Default, NoFs) で profile 制御
- CoreBoxId.is_required_in(profile) で条件付き required/optional
- initialize_runtime() で env 読み込み責務を一元化(修正1)
- NoFsFileIo スタブで no-fs プロファイルでの FileBox 無効化(修正2)
- Logger/ConsoleService は no-fs でも有効と明示(修正2)
- Profile 拡張予定(TestMock/Sandbox/ReadOnly/Embedded)を予約(修正3)
実装ファイル:
- src/runtime/runtime_profile.rs (新規)
- src/providers/ring1/file/nofs_fileio.rs (新規)
- src/runtime/core_box_ids.rs (修正)
- src/runtime/plugin_host.rs (修正)
- src/runtime/provider_lock.rs (修正)
- docs 更新
テスト: Phase 109 11/11 PASS ✅
ビルド: cargo build --release SUCCESS ✅
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-03 19:37:32 +09:00
61dc4dec9b
feat(filebox): Phase 108 FileBox write/write_all implementation
...
Implement write functionality for FileBox following Phase 108 specification,
completing the read/write pipeline via Ring0.FsApi.
## Implementation Summary
### Task 2: FsApi / Ring0FsFileIo write implementation
- Added write() method to FileIo trait
- Implemented write() in Ring0FsFileIo (truncate mode via Ring0.FsApi.write_all)
- Updated FileCaps to { read: true, write: true } for standard profile
- Added write() stub to CoreRoFileIo (returns Unsupported)
### Task 3: FileBox write/write_all implementation
- Updated FileBox.write_all() to delegate to provider.write()
- Updated FileBox.write() to convert content to text and call provider.write()
- UTF-8 conversion via String::from_utf8_lossy (text-oriented design)
- Returns "OK" on success, "Error: ..." on failure
### Task 4: Test coverage
- Round-trip test (write → read): ✅ PASS
- Truncate mode verification: ✅ PASS
- Write without open error: ✅ PASS
- Read-only provider rejection: ✅ PASS
- Auto-registration test updated: ✅ PASS
### Task 5: Documentation updates
- phase107_fsapi_fileio_bridge.md: Added Phase 108 section
- core_boxes_design.md: Updated Ring0.FsApi relationship section
- CURRENT_TASK.md: Added Phase 108 completion entry
## Design Decisions (from phase108_filebox_write_semantics.md)
- **Write mode**: truncate (overwrite existing file each time)
- **Text-oriented**: UTF-8 conversion via from_utf8_lossy
- **Append mode**: Planned for Phase 109+
- **Error handling**: FileError::Io for failures, Fail-Fast on caps.write=false
## Test Results
```
cargo test --release --lib filebox
test result: ok. 5 passed; 0 failed; 1 ignored
```
All FileBox tests pass, including Phase 107 compatibility tests.
## Pipeline Complete
```
FileBox.write(content)
↓
FileBox.write_all(buf)
↓
provider.write(text) ← Ring0FsFileIo implementation
↓
Ring0.FsApi.write_all()
↓
std::fs::write()
```
## Next Steps (Backlog)
- Phase 109: minimal/no-fs profile
- Phase 110: FileHandleBox (multiple files simultaneously)
- Phase 111: append mode implementation
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-03 18:40:33 +09:00
0fd4962e4c
feat(Ring0): Phase 107 - Ring0.FsApi FileIo integration complete
...
Implementation Summary:
Phase 107 establishes FileBox as a unified layer over Ring0.FsApi
Completed Tasks:
- Task 1: FsApi SSOT review and documentation
- Task 2: FileIo designed as FsApi wrapper
- Task 3: Ring0FsFileIo implementation added
- Task 4: Fail-Fast integration verified
- Task 5: Documentation integration complete
Key Changes:
1. New File: src/providers/ring1/file/ring0_fs_fileio.rs
- Ring0.FsApi-based FileIo implementation
- Stateful wrapper (open/read/close)
- UTF-8 handling via read_to_string()
- One-file-at-a-time semantics (tested)
2. provider_lock.rs:
- Added init_default_filebox_provider()
- Auto-registration helper for Ring0FsFileIo
3. plugin_host.rs:
- with_core_from_registry_optional() auto-registers default provider
- Plugin priority maintained (debug logging)
- Phase 106 MissingService check still active (Fail-Fast preserved)
4. Documentation:
- phase107_fsapi_fileio_bridge.md: Complete design doc
- phase106_filebox_design_revised.md: Phase 107 integration notes
- core_boxes_design.md: Layer diagram and principles
Design Decisions:
- UTF-8 handling: read_to_string() for text-focused use cases
- One file at a time: open() returns Err if already open
- Plugin priority: init_default_filebox_provider() fails gracefully
Test Results:
- cargo build --release: SUCCESS
- plugin_host tests: 11 passed
- ring0_fs_fileio tests: 4 passed
Next Steps (Phase 108+):
- minimal/no-fs profile support
- write operations
- multi-file handle support
2025-12-03 18:16:49 +09:00
66479f921d
feat(phase106): FileBox provider_lock整理 & Fail-Fast強化(案B統一版)
...
Task 1: CoreBoxId.category() 修正
- File を CoreRequired 側に移動(L126)
- テスト期待値修正(L371)
- Phase 106 intent コメント更新(L107-115)
Task 2: provider_lock API 確認
- 変更なし(既存の set/get API をそのまま使用)
- get_filebox_provider_strict() は追加しない(シンプルに保つ)
Task 3: FileBox SSOT コメント追加
- L5-7 に責務明示コメント追加
Task 4: PluginHost に FileBox provider チェック追加
- with_core_from_registry_optional() に Phase 106 チェック追加(L158-167)
- test_with_core_from_registry_filebox_required() 追加(L413-445)
- 既存テスト2件を FileBox provider 初期化対応(L301-321, L323-351)
- test_with_core_from_registry_missing_box() をエラーメッセージ拡張(L386-410)
Task 5: ドキュメント更新
- core_boxes_design.md に Phase 106 セクション追加(L248-265)
- 責務分離原則・Ring0.FsApi 延期を明記
完了条件:
✅ ビルド成功(cargo build --release)
✅ テスト全PASS(cargo test --lib runtime: 64 passed; 0 failed)
✅ 指示書の実装チェックリスト全て completed
2025-12-03 17:55:26 +09:00
6ecd8f7f52
feat(runtime): Phase 103 CoreServices Optional化 - Memory Constraints対応
...
- Add CoreServicesConfig struct (from_env, minimal, all_enabled)
- Implement with_core_from_registry_optional() for selective initialization
- Update CoreBoxesImpl fields to Option<Arc<dyn XyzService>>
- Maintain backward compatibility (with_core_from_registry calls all_enabled)
- Add NYASH_CORE_DISABLE_* environment variable support
- ConsoleBox remains mandatory (Graceful Degradation principle)
- Add unit tests for optional initialization
- Update console_println! macro to handle Option type
- Fix direct console.println() calls in vm.rs and selfhost.rs
- Create core_optional_design.md documentation
Note: Phase 104 will extend ConsoleService to be optional as well with
graceful fallback in console_println! macro.
Files modified:
- src/runtime/plugin_host.rs (CoreServicesConfig, with_core_from_registry_optional, tests)
- src/runtime/core_services.rs (CoreBoxesImpl fields → Option type)
- src/runtime/mod.rs (console_println! macro updated)
- src/runner/modes/vm.rs (handle Option console)
- src/runner/selfhost.rs (handle Option console)
- docs/development/current/main/core_optional_design.md (new)
- docs/development/current/main/ring0-inventory.md (Phase 103 entry)
Test results:
- Build: ✅ Success (0 errors, 7 warnings)
- Unit tests: ✅ 3/3 passed (optional_core_tests)
- Runtime tests: ✅ 63/63 passed
- Smoke tests: ✅ 30/31 passed (1 pre-existing timeout)
2025-12-03 13:59:06 +09:00
262de28c6b
feat(ring0): Phase 102 MemApi Bridge Skeleton - StdMem実装
...
- Add StdMem struct (stdlib alloc/free based)
- Update default_ring0() to use StdMem instead of NoopMem
- Keep NoopMem for compatibility and testing
- Add unit tests for StdMem allocation/stats
- Update docs (phase-85-ring0-runtime/README.md, ring0-inventory.md)
Note: This is a skeleton implementation. Full MemStats tracking
(including freed size) will be added in Phase 102B with hakmem bridge.
Files modified:
- src/runtime/ring0/std_impls.rs
- src/runtime/ring0/mod.rs
- docs/development/current/main/phase-85-ring0-runtime/README.md
- docs/development/current/main/ring0-inventory.md
2025-12-03 13:42:05 +09:00
44c6ca9585
chore(runtime): Phase 98.5 Arc 完全修飾パス簡略化 & コメント統一
...
## 修正内容
**src/runtime/mod.rs** (4箇所):
- use文: std::sync::OnceLock → std::sync::{Arc, OnceLock}
- Line 64: OnceLock<std::sync::Arc<...>> → OnceLock<Arc<...>>
- Line 68: std::sync::Arc::new(...) → Arc::new(...)
- Line 72/80: 戻り値型で std::sync::Arc → Arc に統一
**src/runner/modes/vm.rs** (1箇所):
- Line 589: コメント統一 "println" → "eprintln"(実装に合わせる)
## 効果
- 可読性向上: std::sync:: プレフィックス4箇所削除
- 一貫性向上: console_println! マクロの説明と実装を統一
- 追加依存なし、機能変更なし
## テスト結果
✅ cargo build --release: 成功
✅ cargo test --lib runtime::core_services: 11 passed
🧹 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-03 11:17:41 +09:00
7bcb7ec596
feat(runtime): Phase 98 ConsoleService 代表パス拡張 - 7箇所置き換え完了
...
## Phase 98 完了項目
- ✅ println!/eprintln! 7箇所 → ConsoleService 経由に移行
- ✅ console_println! マクロ追加(Graceful Degradation パターン)
- ✅ try_get_core_plugin_host() 追加(安全なアクセサー)
- ✅ 全テストPASS(core_services: 11, plugin_host: 7)
## 置き換え箇所(7箇所)
**selfhost/child.rs** (3箇所):
- spawn失敗エラー
- タイムアウトメッセージ(stdout/stderr)
**core_bridge.rs** (2箇所):
- DUMP書き込みエラー
- DUMP_MUT書き込みエラー
**vm.rs** (1箇所):
- RC(return code)出力
**selfhost/json.rs** (2箇所, オプション達成):
- PyVM MIR JSON emit エラー
- PyVM 使用ログ(verbose時)
## 技術的成果
**Graceful Degradation パターン確立**:
- PluginHost 初期化前: eprintln! フォールバック
- PluginHost 初期化後: ConsoleService 使用(Ring0直結)
- Fail-Fast原則との整合性: 出力先選択のみ動的
**実装インフラ**:
- src/runtime/mod.rs: console_println! マクロ & try_get_core_plugin_host()
- 既存の get_core_plugin_host() は panic! 保持(Fail-Fast)
## 統計
- 置き換え完了: 7箇所(全体の約2%)
- 残り候補: 約359箇所(Phase 99以降)
- テスト: ビルド成功、全ユニットテストPASS
## ドキュメント
- docs/development/current/main/core_boxes_design.md: Section 15 追加(128行)
- 実装パターン、設計判断、テスト結果を完全記録
## Phase 85-98 総括
- Phase 85-94: 構造設計 & 箱化モジュール化
- Phase 95.5: StringService/ConsoleService(Ring0直結型・純粋関数型)
- Phase 96-96.5: ArrayService/MapService(downcast型)& コード整理
- Phase 97: IntegerService/BoolService(純粋関数型、#[allow(dead_code)] 根絶)
- Phase 98: ConsoleService 実用拡大(7箇所)✅ 完了
次: Phase 99(CoreServices 完全統合、残り約359箇所の段階的移行)
🎊 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-03 11:04:58 +09:00
04dceb6bc0
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
8995fd151d
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
81a5a04eb7
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
1108a61533
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
e74694d08b
feat(phase95): CoreServices実用化 - Console/String Service実装完了
...
Phase 95完全達成 - Ring1-Core層の実際のService実装
### 実装成果
- ✅ ConsoleService::println/print 実装
- ✅ StringService::len 実装(UTF-8文字数対応)
- ✅ global accessor 実装(get_core_plugin_host)
- ✅ 代表パス切り替え(selfhost.rs)
- ✅ テスト13/13 PASS(100%)
### 変更ファイル
- src/runtime/core_services.rs: Service API定義、Adapter実装、テスト追加(+79行)
- src/runtime/mod.rs: global accessor実装(+18行)
- src/runtime/plugin_host.rs: Debug impl追加(+3行)
- src/runner/selfhost.rs: ConsoleService経由に切り替え(+5行)
- docs/development/current/main/core_boxes_design.md: Phase 95文書化(+118行)
### 技術的成果
- Ring0 → Ring1-Core → 実行パス の三層構造確立
- 型安全なService経由アクセス実現
- UTF-8完全対応(文字数カウント)
- global accessorパターン統一(Ring0と同じOnceLock)
### Bug修正
- PluginHost Debug impl追加
- PluginHost.optional型修正(Send + Sync追加)
- CoreServices Debug impl実装
### 次のステップ
Phase 95.5: Ring0統合とAdapter整理(#[allow(dead_code)]削除)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-03 09:57:38 +09:00
f4144a22a6
feat(phase94): Box→Service conversion with actual registry integration
...
Phase 94完全達成 - UnifiedBoxRegistryから実際のBoxを取得してServiceに変換
### 実装成果
- ✅ 6個のAdapter実装(StringBox/Integer/Bool/Array/Map/Console)
- ✅ Dummy実装完全削除(38行削減)
- ✅ Fail-Fast原則徹底(フォールバック削除)
- ✅ テスト7/7 PASS(100%)
### 変更ファイル
- src/runtime/core_services.rs: 6個のAdapter実装(+93行)
- src/runtime/plugin_host.rs: 実際のBox取得ロジック(+54行)、Dummy削除(-17行)
- src/runtime/mod.rs: フォールバック削除(-8行)
### 技術的成果
- Box<dyn NyashBox>を直接保持(型安全性確保)
- registry.create_box()で実際のBoxインスタンス取得
- BuiltinBoxFactory登録でcore_required Boxes提供
### 次のステップ
Phase 95: Service traitメソッド実装(Console/String/Array/Map)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-03 09:14:49 +09:00
b3de4cac4b
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
2f54e64d27
feat(phase92): UnifiedBoxRegistry integration roadmap complete
...
Phase 92 完了: UnifiedBoxRegistry 統合の導線作り
**実装内容**:
- CoreServices::required_ids() 実装
- Phase 87 CoreBoxId の core_required (6個) を返す
- is_core_required() との整合性を型レベルで保証
- CoreInitError enum 追加
- MissingService, RegistryEmpty, InvalidServiceType
- Display + std::error::Error trait 実装
- PluginHost::with_core_from_registry() skeleton
- Phase 93 で実装予定(todo!() でプレースホルダー)
- initialize_runtime() 接続ポイント決定
- Ring0Context と UnifiedBoxRegistry を橋渡し
**Phase 87 整合性**:
- required_ids() が is_core_required() と完全一致
- テストで整合性を検証
**テスト結果**:
- 3件追加(全て合格)
- test_required_ids_consistency
- test_core_init_error_display
- test_with_core_from_registry_todo (should_panic)
- ビルド成功
- 既存テストに影響なし
**ドキュメント更新**:
- Section 9 追加(113行)
- ensure_initialized() 呼び出し場所決定(4箇所)
- Phase 93 実装計画明記
**次のステップ**: Phase 93 (with_core_from_registry 実装 & 起動パス統合)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-03 07:57:21 +09:00
3d253056bd
feat(phase91): PluginHost/CoreServices skeleton complete
...
Phase 91 完了: Ring1-Core 構造の明確化
**実装内容**:
- CoreServices 定義(6つの Service trait)
- StringService, IntegerService, BoolService
- ArrayService, MapService, ConsoleService
- PluginHost 構造体(Ring0 ⇔ CoreServices 橋渡し)
- NyashPlugin trait(プラグインシステム標準IF)
- PluginRegistry skeleton
**Phase 87 整合性**:
- CoreServices は core_required (6個) を完全カバー
- String, Integer, Bool, Array, Map, Console
- CoreBoxId との対応表をドキュメント化
**設計原則確立**:
- Ring1-Core 構造明確化
- core_required は必ず揃う(型レベル保証)
- Fail-Fast 設計(ensure_initialized)
- 既存影響ゼロ(新規ファイルのみ)
**テスト結果**:
- 5件追加(全て合格)
- ビルド成功
- 既存テストに影響なし
**次のステップ**: Phase 92 (UnifiedBoxRegistry との統合)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-03 07:43:08 +09:00
4e2e45a79d
feat(phase90): Ring0Context fs/time/thread migration complete
...
Phase 90 完了: IO/fs/time/thread 系の Ring0 移行
**Phase 90-A: fs 系移行(7箇所)**
- FsApi trait 追加(6メソッド)
- StdFs 実装(std::fs ベース)
- IoError 拡張(4バリアント追加)
- 移行: strip.rs(4), dispatch.rs(1), mod.rs(3)
**Phase 90-B: io 系移行**
- Phase 88 完了済み(スキップ)
**Phase 90-C: time 系移行(3箇所)**
- TimeApi に elapsed() 追加
- 移行: selfhost_exe.rs(1), io.rs(1), plugin_loader_unified.rs(1)
**Phase 90-D: thread 系移行(2箇所)**
- ThreadApi trait 追加(sleep メソッド)
- StdThread 実装
- 移行: global_hooks.rs(1), plugin_loader_unified.rs(1)
**Phase 90-E: 統合テスト**
- ビルド成功(6 warnings, 0 errors)
- テスト: 522/554 passed (94.2%)
- 退行なし
**実装成果**:
- Ring0Context 拡張: fs, thread フィールド追加
- 総移行: 12箇所(fs: 7, time: 3, thread: 2)
- 移行率: fs(2.9%), time(2.1%), thread(5.4%)
**次のステップ**: Phase 91 (PluginHost/CoreServices skeleton)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-03 06:14:57 +09:00
a01110e791
feat(phase89-a): Ring0Context logs migration - 56 locations
...
Phase 89-A 完了: println!/eprintln! → ring0.log.* 移行
**実装内容**:
- 環境変数制御: NYASH_RING0_LOG_LEVEL (DEBUG/INFO/WARN/ERROR)
- selfhost.rs: 24箇所移行 (error:14, warn:2, info:5, debug:3)
- vm.rs: 32箇所移行 (error:5, warn:4, info:2, debug:21)
**実装効果**:
- 総移行箇所: 56箇所 (目標: 10-15箇所 → 373%達成)
- 累計進捗: 58/3,955箇所 (1.47%)
- テスト結果: 521 passed; 33 failed (変化なし)
**次のステップ**: Phase 89-B (IO/time 棚卸し)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-02 23:27:41 +09:00
42b09b3c1c
feat(phase88): Ring0Context Skeleton implementation
...
Phase 88: OS API abstraction layer implementation
**Implementation**:
- Ring0Context module added (4 files)
- mod.rs: Public API, global initialization (OnceLock)
- traits.rs: MemApi, IoApi, TimeApi, LogApi trait definitions
- std_impls.rs: std-based default implementations
- errors.rs: IoError, TimeError type definitions
**Design Principles**:
- Ring0 knows nothing about Box
- Ring0 knows nothing about Nyash
- Pure OS API abstraction
**Global Initialization**:
- NyashRunner::new() initializes Ring0Context globally
- OnceLock ensures safe initialization (idempotent)
**Migration (2 paths)**:
- src/runner/selfhost.rs:27: eprintln! → ring0.log.error() (OOB strict)
- src/runner/selfhost.rs:177: eprintln! → ring0.log.error() (PyVM error)
**Tests**:
- 4 unit tests added (ring0 module)
- All tests passed
- Build successful (0 errors)
**Migration Status**:
- Migrated: 2/3,955 (0.05%)
- Remaining: 3,953 paths (Phase 89+)
**Files Changed**:
- src/runtime/ring0/mod.rs (new, 100 lines)
- src/runtime/ring0/traits.rs (new, 93 lines)
- src/runtime/ring0/std_impls.rs (new, 77 lines)
- src/runtime/ring0/errors.rs (new, 26 lines)
- src/runtime/mod.rs (Ring0Context export)
- src/runner/mod.rs (global initialization)
- src/runner/selfhost.rs (2 paths migrated)
- docs/development/current/main/ring0-inventory.md (Phase 88 status)
Phase 88 complete. Ready for Phase 89 (gradual migration).
🐱 ✨
2025-12-02 22:38:27 +09:00
8cd9729375
feat(runtime): Phase 87 CoreBoxId/CoreMethodId 箱化完了
...
ハードコード文字列から型安全な enum への箱化により、
Box名・メソッド名管理を完全にコンパイル時検証可能に。
主な実装:
- CoreBoxId enum 定義(19個)
- core_required: 6個(String, Integer, Bool, Array, Map, Console)
- core_optional: 9個(Float, Null, File, Path, Regex, Math, Time, Json, Toml)
- 特殊型: 4個(Function, Result, Method, Missing)
- CoreMethodId enum 定義(30個)
- 各 Box のメソッドを型安全に管理
- 引数数、戻り値型情報を統合
- is_reserved_type() を CoreBoxId ベースにリファクタリング
- infer_boxcall_return_type() を CoreMethodId ベースに改良(75行 → 25行、67%削減)
検証結果:
- テスト: ✅ 11/11 passed(新規追加)
- ビルド: ✅ 成功(0エラー)
- 型安全性: ✅ タイポ不可能
効果:
- SSOT 確立(src/runtime/core_box_ids.rs に一元化)
- コンパイル時検証(実行時エラー → コンパイルエラー)
- 保守性向上(変更箇所の一元化)
- IDE 支援(enum 補完可能)
ドキュメント:
- core_boxes_design.md 作成(Phase 87 完全仕様)
- Phase 85 README 更新(Phase 87 セクション追加)
Phase 15.5「Everything is Plugin」アーキテクチャ基盤完成
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-02 22:22:32 +09:00
8633224061
JoinIR/SSA/Stage-3: sync CURRENT_TASK and dev env
2025-12-01 11:10:46 +09:00
f9d100ce01
chore: Phase 25.1 完了 - LoopForm v2/Stage1 CLI/環境変数削減 + Phase 26-D からの変更
...
Phase 25.1 完了成果:
- ✅ LoopForm v2 テスト・ドキュメント・コメント完備
- 4ケース(A/B/C/D)完全テストカバレッジ
- 最小再現ケース作成(SSAバグ調査用)
- SSOT文書作成(loopform_ssot.md)
- 全ソースに [LoopForm] コメントタグ追加
- ✅ Stage-1 CLI デバッグ環境構築
- stage1_cli.hako 実装
- stage1_bridge.rs ブリッジ実装
- デバッグツール作成(stage1_debug.sh/stage1_minimal.sh)
- アーキテクチャ改善提案文書
- ✅ 環境変数削減計画策定
- 25変数の完全調査・分類
- 6段階削減ロードマップ(25→5、80%削減)
- 即時削除可能変数特定(NYASH_CONFIG/NYASH_DEBUG)
Phase 26-D からの累積変更:
- PHI実装改善(ExitPhiBuilder/HeaderPhiBuilder等)
- MIRビルダーリファクタリング
- 型伝播・最適化パス改善
- その他約300ファイルの累積変更
🎯 技術的成果:
- SSAバグ根本原因特定(条件分岐内loop変数変更)
- Region+next_iパターン適用完了(UsingCollectorBox等)
- LoopFormパターン文書化・テスト化完了
- セルフホスティング基盤強化
Co-Authored-By: Claude <noreply@anthropic.com >
Co-Authored-By: ChatGPT <noreply@openai.com >
Co-Authored-By: Task Assistant <task@anthropic.com >
2025-11-21 06:25:17 +09:00
d3cbc71c9b
feat(mir): Phase 25.1f完了 - Conservative PHI + ControlForm観測レイヤー
...
🎉 Conservative PHI Box理論による完全SSA構築
**Phase 7-B: Conservative PHI実装**
- 片方branchのみ定義変数に対応(emit_void使用)
- 全変数にPHI生成(Conservative Box理論)
- Stage-1 resolver全テスト緑化(3/3 PASS)
**Phase 25.1f: ControlForm観測レイヤー**
- LoopShape/IfShape/ControlForm構造定義
- Loop/If統一インターフェース実装
- debug_dump/debug_validate機能追加
- NYASH_CONTROL_FORM_TRACE環境変数対応
**主な変更**:
- src/mir/builder/phi.rs: Conservative PHI実装
- src/mir/control_form.rs: ControlForm構造(NEW)
- src/mir/loop_builder.rs: LoopForm v2デフォルト化
**テスト結果**:
✅ mir_stage1_using_resolver_min_fragment_verifies
✅ mir_stage1_using_resolver_full_collect_entries_verifies
✅ mir_parserbox_parse_program2_harness_parses_minimal_source
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
Co-Authored-By: ChatGPT <chatgpt@openai.com >
2025-11-18 18:56:35 +09:00
757b0fcfc9
feat(mir/builder): implement BoxCompilationContext for structural metadata isolation
...
箱理論の完璧な実装!各static boxコンパイルを独立したコンテキストで実行。
設計:
- BoxCompilationContext: variable_map, value_origin_newbox, value_types を箱化
- MirBuilder: compilation_context: Option<BoxCompilationContext> フィールド追加
- context swap: lower_static_method_as_function 開始/終了時に std::mem::swap
- 自動クリーンアップ: スコープ終了でコンテキスト破棄
実装:
1. src/mir/builder/context.rs: BoxCompilationContext構造体定義(テスト付き)
2. src/mir/builder.rs: compilation_contextフィールド追加、既存フィールドにコメント追加
3. src/mir/builder/lifecycle.rs: 各static boxでコンテキスト作成・破棄
4. src/mir/builder/builder_calls.rs: lower_static_method_as_functionでcontext swap
5. src/mir/builder/decls.rs, exprs.rs: 古いmanual clear()削除
効果:
✅ グローバル状態汚染を構造的に不可能化
✅ 各static boxが完全に独立したコンテキストでコンパイル
✅ 既存コード変更なし(swap技法で完全後方互換性)
✅ StageBArgsBox ValueId(21)エラー完全解決
箱理論的評価: 🟢 95点
- 明示的な境界: 各boxのコンテキストが物理的に分離
- 汚染不可能: 前の箱の状態が構造的に残らない
- 戻せる: コンテキスト差し替えで簡単ロールバック
- 美しい設計: スコープベースのリソース管理
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-17 11:28:18 +09:00
82b6c4e834
Phase 25.1b: VM undefined-value diagnostics and builder SSA helpers
2025-11-17 03:19:03 +09:00
eadde8d1dd
fix(mir/builder): use function-local ValueId throughout MIR builder
...
Phase 25.1b: Complete SSA fix - eliminate all global ValueId usage in function contexts.
Root cause: ~75 locations throughout MIR builder were using global value
generator (self.value_gen.next()) instead of function-local allocator
(f.next_value_id()), causing SSA verification failures and runtime
"use of undefined value" errors.
Solution:
- Added next_value_id() helper that automatically chooses correct allocator
- Fixed 19 files with ~75 occurrences of ValueId allocation
- All function-context allocations now use function-local IDs
Files modified:
- src/mir/builder/utils.rs: Added next_value_id() helper, fixed 8 locations
- src/mir/builder/builder_calls.rs: 17 fixes
- src/mir/builder/ops.rs: 8 fixes
- src/mir/builder/stmts.rs: 7 fixes
- src/mir/builder/emission/constant.rs: 6 fixes
- src/mir/builder/rewrite/*.rs: 10 fixes
- + 13 other files
Verification:
- cargo build --release: SUCCESS
- Simple tests with NYASH_VM_VERIFY_MIR=1: Zero undefined errors
- Multi-parameter static methods: All working
Known remaining: ValueId(22) in Stage-B (separate issue to investigate)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-17 00:48:18 +09:00