Commit Graph

424 Commits

Author SHA1 Message Date
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
52c13e658d docs: Phase 106 FileBox provider_lock 整理(案B統一版)
- CoreBoxId に「必須」判定を集約(is_core_required / category)
- provider_lock は「登録・読む」のみにシンプル化
- PluginHost.with_core_from_registry() で FileBox provider チェック
- Ring0.FsApi 統合(案C)は Phase 107+ で実施
- 責務分離を明確化し設計品質向上

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

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

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

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

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

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

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

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

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

Test results:
- Build:  Success (0 errors, 7 warnings)
- Unit tests:  3/3 passed (optional_core_tests)
- Runtime tests:  63/63 passed
- Smoke tests:  30/31 passed (1 pre-existing timeout)
2025-12-03 13:59:06 +09:00
262de28c6b feat(ring0): Phase 102 MemApi Bridge Skeleton - StdMem実装
- Add StdMem struct (stdlib alloc/free based)
- Update default_ring0() to use StdMem instead of NoopMem
- Keep NoopMem for compatibility and testing
- Add unit tests for StdMem allocation/stats
- Update docs (phase-85-ring0-runtime/README.md, ring0-inventory.md)

Note: This is a skeleton implementation. Full MemStats tracking
(including freed size) will be added in Phase 102B with hakmem bridge.

Files modified:
- src/runtime/ring0/std_impls.rs
- src/runtime/ring0/mod.rs
- docs/development/current/main/phase-85-ring0-runtime/README.md
- docs/development/current/main/ring0-inventory.md
2025-12-03 13:42:05 +09:00
0c527dcd22 feat(runtime): Phase 101-A dev-debug ログの Ring0.log 統一 - 34箇所完了
## Phase 101-A 完了項目
-  llvm.rs: 13箇所([joinir/llvm], [parse/context]) → Ring0.log
-  loop_form.rs: [loopform] 系ログ → Ring0.log
-  loopform_builder.rs: 16箇所([loopform/prepare], [loopform/seal_phis]) → Ring0.log
-  loop_snapshot_merge.rs: 5箇所([Option C]) → Ring0.log
-  全テストPASS(ビルド成功)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 11:31:35 +09:00
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
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
7e8c2cc768 docs(phase89-b): Ring0 IO/time/thread inventory complete
Phase 89-B 完了: Ring0 候補の棚卸し調査

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

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

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

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 23:46:32 +09:00
42b09b3c1c feat(phase88): Ring0Context Skeleton implementation
Phase 88: OS API abstraction layer implementation

**Implementation**:
- Ring0Context module added (4 files)
  - mod.rs: Public API, global initialization (OnceLock)
  - traits.rs: MemApi, IoApi, TimeApi, LogApi trait definitions
  - std_impls.rs: std-based default implementations
  - errors.rs: IoError, TimeError type definitions

**Design Principles**:
- Ring0 knows nothing about Box
- Ring0 knows nothing about Nyash
- Pure OS API abstraction

**Global Initialization**:
- NyashRunner::new() initializes Ring0Context globally
- OnceLock ensures safe initialization (idempotent)

**Migration (2 paths)**:
- src/runner/selfhost.rs:27: eprintln! → ring0.log.error() (OOB strict)
- src/runner/selfhost.rs:177: eprintln! → ring0.log.error() (PyVM error)

**Tests**:
- 4 unit tests added (ring0 module)
- All tests passed
- Build successful (0 errors)

**Migration Status**:
- Migrated: 2/3,955 (0.05%)
- Remaining: 3,953 paths (Phase 89+)

**Files Changed**:
- src/runtime/ring0/mod.rs (new, 100 lines)
- src/runtime/ring0/traits.rs (new, 93 lines)
- src/runtime/ring0/std_impls.rs (new, 77 lines)
- src/runtime/ring0/errors.rs (new, 26 lines)
- src/runtime/mod.rs (Ring0Context export)
- src/runner/mod.rs (global initialization)
- src/runner/selfhost.rs (2 paths migrated)
- docs/development/current/main/ring0-inventory.md (Phase 88 status)

Phase 88 complete. Ready for Phase 89 (gradual migration).

🐱
2025-12-02 22:38:27 +09:00
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
268a56fdfe feat(box_factory): Phase 86 BoxFactory Priority normalization
Phase 86: BoxFactory Priority 正常化プロジェクト完了

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

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

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

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

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

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

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

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

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

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

🎉 Phase 86 完了!次は Phase 85 で Ring0/Ring1-Core 境界の文書化へ
2025-12-02 21:52:18 +09:00
7dbe0a682c feat(joinir): Phase 84-5 if_phi.rs レガシーフォールバック完全削除
Phase 84-4-B で Case D を 0件に削減完了したことにより、
if_phi.rs のレガシーフォールバックが完全に不要になったため削除。

主な変更:
- if_phi.rs 削除(339行)
- test_utils.rs 新規作成(テスト専用ユーティリティ分離、127行)
- lifecycle.rs: if_phi 呼び出し削除、Phase 84-5 安全ガード追加
- env.rs: phi_fallback_disabled() を常に true に変更
- テスト: A/B テスト → GenericTypeResolver 単独テストに変更

検証結果:
- Case D: 0件(完全解消継続)
- Tests: 498 passed(Phase 84-4: 497 から +1)

Phase 84 プロジェクト完全達成: 15件 → 0件(100%削減)
純削減: 220行

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 21:09:15 +09:00
21505b8b41 docs: Phase 84 インデックス更新 - Phase 84-4 完了反映
Phase 84-4 完了に伴う更新:
- Case D: 15件 → 0件(100%完全解決)
- Phase 84-4-B 実装完了を反映
- Phase 84-4-C 不要(BoxCall 経路で解決)
- 型推論システムの完全箱化達成マーク

次のステップ: Phase 84-5(if_phi.rs 削除)
2025-12-02 20:32:08 +09:00
8a948988d1 docs: Phase 84-4 完了報告書 - Case D 100%完全解決達成
Phase 84-4-B の驚きの成果を記録:
- Case D: 4件 → 0件(予想 1件 を大幅超過)
- Phase 84-4-C(Await)不要(BoxCall 経路で解決)
- 型推論システムの完全箱化達成

Phase 84 全体の成果:
- 15件 → 0件(100%削減)
- 型生成・型伝播・型統合の 3層構造完成
- レガシーフォールバック削除準備完了
2025-12-02 20:30:22 +09:00
c5abf62350 docs(phase84): Add Phase 84-3 analysis and Phase 84-4 recommendations
Task agent investigation results after Phase 84-3 completion.

Remaining 4 Case D analysis:
- test_lowering_await_expression: await construct
- mir_lowering_of_qmark_propagate: QMark (?) construct
- mir_stage1_cli_emit_program_min_*: Stage1Cli type inference (2 tests)

Root cause (unified): BoxCall/Await/QMark return types not registered in value_types

Phase 84-4 implementation recommendations:
- Phase 84-4-A: dev fallback (0.5 days) - immediate unblock
- Phase 84-4-B: BoxCall type registration (1-2 days) - solves 3 cases
- Phase 84-4-C: Await type special handling (0.5 days) - solves 1 case

Documents added:
- phase84-3-summary.md: Reduction results and Phase 84-4 recommendations
- phase84-3-remaining-4-analysis.md: Detailed analysis of each test
- phase84-4-implementation-recommendation.md: Implementation guide with code examples
- phase84-index.md: Phase 84 overall index and roadmap
- phase84-3-final-report.md: Complete report with executive summary

Cumulative results:
- Phase 82: 12 cases
- Phase 84-2: 9 cases (25% reduction)
- Phase 84-3: 4 cases (56% reduction)
- Total: 67% reduction achieved (12 → 4)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 20:18:13 +09:00
4ef5eec162 feat(mir): Phase 84-2 CopyTypePropagator for Copy chain type propagation
- Add CopyTypePropagator box (ChatGPT Pro design) for fixed-point
  Copy instruction type propagation
- Integrate into lifecycle.rs before return type inference
- Case D reduced from 12 to 9 (25% reduction)

Implementation:
- src/mir/phi_core/copy_type_propagator.rs: New box with fixed-point loop
- src/mir/phi_core/mod.rs: Add module export
- src/mir/builder/lifecycle.rs: Call propagator before return inference

Test results:
- Baseline: 494 passed, 33 failed (was 489/34)
- Case D: 9 remaining (from 12)
- Unit tests: 4/4 passed

Remaining 9 Case D breakdown:
- GroupA: Loop Edge Copy (7 cases) - PHI incoming needs Copy trace
- GroupB: Multi-level PHI (2 cases) - Recursive PHI resolution needed

Phase 84-3 will address GroupA with Edge Copy tracing in GenericTypeResolver.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 19:37:01 +09:00
0771945735 docs: Add Phase 84 Case D detailed analysis
Task先生による残り15件のCase D詳細分析レポート。

## 主要発見

**根本原因**: Const命令の型アノテーション欠如(58-67%)
- Integer/Bool/Float/Null/Void定数が型登録されていない
- String定数は既に実装済み

## 分類

- GroupA: Const命令型アノテーション欠如(14-16件、58-67%)
- GroupB: Copy命令型伝播不足(6-8件、25-33%)
- GroupC: PHI命令型推論不足(4-6件、17-25%)
- GroupD: その他の命令型(2-4件)

## Phase 84-1 推奨

`src/mir/builder/emission/constant.rs` に5行追加で90%削減可能。

## ドキュメント

- phase84-case-d-detailed-analysis.md: 全24件の詳細分析
- phase84-case-d-summary.md: エグゼクティブサマリー

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 18:37:36 +09:00
e656958033 feat(env): Phase 71-73 - SSA fix + Stage-3 ENV consolidation
## Phase 71-SSA: StageBDriverBox birth warning 解消
- Fixed false-positive dev verify warning for static boxes
- StageBDriverBox is a static box, so it doesn't follow NewBox→birth pattern
- Modified lifecycle.rs to skip StageBDriverBox from birth() requirement

## Phase 73-A: Stage-3 legacy ENV 統一化
- Consolidated NYASH_PARSER_STAGE3 and HAKO_PARSER_STAGE3 → NYASH_FEATURES=stage3
- Updated 20 test files (46 direct replacements)
- Special handling for parser_stage3.rs compat layer and mir_static_main_args_loop.rs
- All test files now use unified NYASH_FEATURES=stage3

## Phase 72-73: ENV inventory documented
- Created phase72-73-env-inventory.md with complete usage analysis
- Identified 113 direct ENV reads requiring SSOT consolidation
- Prioritized Phase 72 (JoinIR EXPERIMENT SSOT) and Phase 73 (Stage-3 cleanup)

## Phase 74-SSA: Minimal reproduction for static box delegation
- Created parser_box_minimal.hako and ssa_static_delegation_min.hako
- Investigated spawn failure in selfhost compiler (arguments too long)
- Root cause: NYASH_NY_COMPILER_EMIT_ONLY=1 defaults to emit-only mode

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 12:36:28 +09:00
4b3eb6b3a9 feat(phase71-ssa): SSA undef 完全解消達成!(4件→0件)
## Phase 71-SSA SSA undef 削減 完全達成!

### 🎉 成果
- **SSA undef**: 4件 → **0件** (100%解消!)
- **所要時間**: 約2時間 (Task先生調査 + 実装 + 検証)
- **修正ファイル**: 3ファイル (.hako実装のみ、MIR/SSAビルダー不変)

### 🔍 根本原因 (Task先生による徹底分析)
**ValueId(272) = StringHelpers.starts_with_kw/3 の戻り値**
- static boxの委譲でValueIdマッピング失敗
- 引数パラメータ設定ログが一切出力されず
- 別関数の戻り値ValueIdが誤って引数として参照される

### 🛠️ 修正内容

**修正1: ParserStringUtilsBox.trim (Quick Win)**
- L76: `StringHelpers.skip_ws` → `ParserStringUtilsBox.skip_ws`
- 効果: SSA undef 4件 → 2件
- 副次効果: Main._parse_number/ParserBox.parse_block2 消滅

**修正2: ParserCommonUtilsBox.trim (修正案A)**
- L50-69: 委譲を廃止、直接実装に変更
- FuncScannerBox.trimの成功パターンを適用

**修正3: ParserBox.trim (修正案A)**
- L81-98: 委譲を廃止、直接実装に変更
- 効果: 残り2件のSSA undef完全解消

###  検証結果
```bash
grep -c 'ssa-undef-debug' logs/selfhost/stageb_20251202_111409_2674670.log
# 出力: 0 ← 🎉 完全解消!
```

### 📊 SSA undef 推移
| フェーズ | 件数 | 詳細 |
|---------|------|------|
| Phase 71初回 | 4件 | trim×2, _parse_number, parse_block2 |
| Quick Win後 | 2件 | trim×2 (予想外: 他2件消滅) |
| 修正案A後 | **0件** | 🎉 **完全解消!** |

### 🎯 残存課題 (次フェーズ)
1. dev verify警告: 1件 (StageBDriverBox birth)
2. Program JSON未出力: extract_ok=0 (rc=0だが行なし)

### 💡 重要な教訓
- static boxの委譲は危険 (ValueIdマッピング失敗)
- 静的呼び出し (BoxName.method) が SSA-friendly
- 成功パターン (FuncScannerBox.trim) の積極活用

### 📝 ドキュメント
- 詳細レポート: phase71-ssa-trim-fix-20251202.md
- Task先生分析: ValueId(272)特定、修正案A-C提案

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 11:16:01 +09:00
13ce9e6888 docs(phase71): Phase 71 初回観測完了 - SSA/selfhost 根本原因特定
## Phase 71 観測成果 (2025-12-02)

###  完了項目
- Phase 70完了直後にPhase 71代表パス実行成功
- RAW観測レイヤ活用成功 (707K log)
- SSA undef根本原因特定 (4件)
- dev verify問題特定 (1件)
- JoinIR/プラグイン正常動作確認

### 🔍 特定した根本原因

**SSA undef (4件)**:
1. ParserCommonUtilsBox.trim/1 - ValueId(272)未定義
2. ParserBox.trim/1 - ValueId(272)未定義
3. Main._parse_number/1 - ValueId(12)未定義
4. ParserBox.parse_block2/2 - ValueId(440)未定義

**dev verify警告 (1件)**:
- StageBDriverBox NewBox直後にbirth()未呼び出し

**重要な気づき**:
- JoinIR経路は正常動作 (問題なし)
- プラグイン初期化は成功 (問題なし)
- 真の問題はSSA/Stage-B MIR生成時のValueId未定義

### 📊 実行結果
```
rc_stageb=0        (Stage-B実行成功)
extract_ok=0       (Program JSON抽出失敗)
Program JSON行: 0件 (emit失敗)
```

### 📝 ドキュメント追加
- phase71-findings-20251202.md: 詳細観測レポート
- CURRENT_TASK.md L112-128: Phase 71完了記録

### 🎯 次のステップ
Phase 71-SSA-debugへ引き継ぎ:
- trim系関数 SSA undef修正 (4件 → 0件)
- StageBDriverBox birth警告解消 (1件 → 0件)
- Program JSON emit復活 (0件 → 1件以上)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 10:19:07 +09:00
5afc331754 docs(phi_core): Phase 70 完全達成!Trio 完全削除 (~1,443行)
## Phase 70 実装完了

###  完了タスク(6/6)

**70-1**: loop_form_intake.rs Trio 使用削除
- 29行 → 2行(27行削減、85%削減)
- LocalScopeInspectorBox / LoopVarClassBox imports 削除
- 二重分類問題解消(LoopScopeShape が SSOT)

**70-2**: loop_to_join.rs 呼び出し側修正
- var_classes 引数削除
- Trio 依存ゼロ達成

**70-3**: 中間テスト
- loopform 14/14 PASS 
- 退行なし確認

**70-4**: phi_core/mod.rs 公開面削除(ユーザー実施)
- pub mod 3箇所削除

**70-5**: Trio 本体3ファイル削除(ユーザー実施)
- loop_var_classifier.rs: 578行
- loop_exit_liveness.rs: 414行
- local_scope_inspector.rs: 361行

**70-6**: 最終テスト・ドキュメント
- 498 passed, loopform 全 PASS 
- Phase 70 完了記録追加

### 📊 削減実績

**合計削減**: **~1,443行**(Phase 69-4 見込み通り)

**ファイル別**:
- Trio 定義3ファイル: 1,353行削除
- loop_form_intake.rs: 27行削減
- phi_core/mod.rs: pub mod 3箇所削除

### 🎯 達成内容

**1. 二重分類問題解消** 
- Before: intake_loop_form() + LoopScopeShape で2回分類
- After: LoopScopeShape のみで1回分類(SSOT 確立)

**2. Trio 依存完全排除** 
- 外部依存: 2箇所 → 0箇所
- Trio 本体: 完全削除

**3. LoopScopeShape SSOT 確立** 
- 変数分類: LoopScopeShape.pinned / carriers
- Exit liveness: LoopScopeShape.exit_live
- 定義追跡: LoopScopeShape.variable_definitions

### 🎊 Phase 48-6 設計の完全達成

**Phase 48-6 目標**: Trio を builder.rs のみに封じ込める
**Phase 70 達成**: Trio 完全削除(封じ込めから削除への昇華)

**進化の完結**:
1. Phase 25.1: Option C 実装(Trio 誕生)
2. Phase 48-4: LoopScopeShape 実装(Trio 代替)
3. Phase 48-6: Trio を builder.rs に封じ込め
4. Phase 69-3: MIR 決定性修正(BTreeSet 化)
5. Phase 69-4: Trio 削除準備完了
6. **Phase 70: Trio 完全削除** 🎉

### 🧪 テスト結果

- loopform: 14/14 PASS 
- 全体: 498 passed; 43 failed(既知エラーのみ、新規エラーなし)

### 📝 変更ファイル

**削除**:
- src/mir/phi_core/loop_var_classifier.rs (578行)
- src/mir/phi_core/loop_exit_liveness.rs (414行)
- src/mir/phi_core/local_scope_inspector.rs (361行)

**修正**:
- src/mir/join_ir/lowering/loop_form_intake.rs
- src/mir/join_ir/lowering/loop_to_join.rs
- src/mir/phi_core/mod.rs

**ドキュメント**:
- docs/development/current/main/phase69-4-trio-deletion-plan.md

### 🚀 Phase 69-70 合計削減

**~1,485行削減**:
- Phase 69-2: 42行(inspector 引数削除)
- Phase 70: 1,443行(Trio 完全削除)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 09:45:54 +09:00
2ea0f2a202 Remove Trio boxes and tidy loop scope warnings 2025-11-30 11:46:14 +09:00
ea120dc9b1 docs(phi_core): Phase 69-4 完全達成!Trio 削除準備完了
## 変更内容

### docs/development/current/main/phase69-4-trio-deletion-plan.md
- Phase 69-4.3: json_v0_bridge Trio 依存設計完了記録
  - 二重分類問題発見(変数分類が2回実行されている無駄)
  - Gap ゼロ確認(LoopScopeShape が Trio 完全カバー)
  - 最小変更設計(14行→2行、85%削減)
- Phase 69-4.4: Trio 削除条件固定完了記録
  - 6ステップ削除手順確定(合計3時間見積もり)
  - 安全性保証(退行防止策・ロールバック計画)
  - 削除完了条件(5項目の明確な基準)
- Phase 69-4.5: Phase 70 橋渡し完了記録
  - 実装パッケージ完備(設計・手順・Checklist)
  - Phase 70 開始条件すべて満たした
- まとめセクション更新
  - Phase 69-4 完全達成宣言
  - Phase 69 合計削減見込み ~1,485行
  - Phase 48-6 設計の完全勝利(進化の歴史)

## Phase 69-4 完了サマリー

### 達成タスク(5/5完了)
-  69-4.1: Trio callsite 棚卸し(Task agent)
-  69-4.2: phi_core 公開面削減方針明文化
-  69-4.3: json_v0_bridge Trio 依存設計
-  69-4.4: Trio 削除条件固定
-  69-4.5: Phase 70 橋渡し

### 成果物
- 📄 全体計画: phase69-4-trio-deletion-plan.md (完成)
- 📄 詳細設計: phase69-4.3-trio-to-loopscope-migration.md (20KB)
- 📋 TODO マーカー: src/mir/phi_core/mod.rs (L33-40)

### 削減見込み
- **~1,443行**(Trio 3箱 + 使用箇所)
  - 定義ファイル: 1,353行
  - loop_form_intake.rs: 14行 → 2行(12行削減)
  - loop_snapshot_merge.rs: ~60行削減
  - 呼び出し側: ~18行削減

### Phase 70 実装準備
-  6ステップ削除手順確定
-  Before/After コード例完備
-  3段階ロールバック計画
-  Checklist コピペ用完備

## 重要な発見

### 1. 二重分類問題
現在、変数分類が2回実行されている無駄を発見:
- intake_loop_form() で分類 ← 削除対象
- LoopScopeShape::from_loop_form() で再度分類 ← 正解

### 2. Gap ゼロ
LoopScopeShape は Trio 全機能をカバー済み:
- LocalScopeInspectorBox → variable_definitions 
- LoopVarClassBox → classify_all() 
- LoopExitLivenessBox → exit_live 

### 3. 最小変更
loop_form_intake.rs の 14行を 2行に削減可能(85%削減)

## Phase 48-6 設計の完全勝利

進化の軌跡:
1. Phase 25.1: Option C 実装(Trio 誕生)
2. Phase 48-4: LoopScopeShape 実装(Trio 代替)
3. Phase 48-6: Trio を builder.rs に封じ込め
4. Phase 69-3: MIR 決定性修正(BTreeSet 化)
5. **Phase 69-4: Trio 削除準備完了**
6. **Phase 70: Trio 完全削除**(予定)

設計哲学: 代替実装 → 可視性制御 → 設計固め → 安全削除

## 次のステップ

Phase 70 実装開始準備完了!
- 見積もり: 3時間
- 削減見込み: ~1,443行
- Checklist: phase69-4-trio-deletion-plan.md 参照

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 10:10:45 +09:00
375bb66b41 feat(phi_core): Phase 69-4.2 Trio公開面削減方針明文化
## 変更内容

### src/mir/phi_core/mod.rs
- Trio Legacy Boxes (3箱) の削除方針をコメント追加
  - LoopVarClassBox (578行)
  - LoopExitLivenessBox (414行)
  - LocalScopeInspectorBox (361行)
- 外部依存2箇所を明記:
  1. loop_form_intake.rs (~30行)
  2. loop_snapshot_merge.rs (~60行)
- TODO(Phase 70) マーカー設置(削減見込み ~1,443行)

### docs/development/current/main/phase69-4-trio-deletion-plan.md
- Phase 69-4 全体計画文書作成
- Phase 69-4.1: Trio callsite 棚卸し結果記録 
- Phase 69-4.2: phi_core 公開面削減完了記録 
- Phase 69-4.3-5: 未実施タスク整理 

## Phase 69-4.2 達成内容

**達成**:
-  Trio 削除計画の明文化
-  外部依存箇所の記録
-  Phase 70 削除条件の TODO 化

**未達成(Phase 70 で実施)**:
-  pub 公開除去(外部依存残存のため継続)
-  phi_core 内部化(LoopScopeShape 移行後に実現)

## 次のステップ

Phase 69-4.3: json_v0_bridge の Trio 依存を LoopScopeShape に寄せる設計

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 10:01:49 +09:00
58c5d8c9bc feat(joinir): Phase 66-68 GenericTypeResolver + JoinIR First Chapter Wrap
Phase 66: P3-C ジェネリック型推論箱化
- generic_type_resolver.rs 新設 (180行)
  - is_generic_method(): ArrayBox.get/pop/first/last, MapBox.get 判定
  - resolve_from_phi(): PHI解析によるジェネリック型推論
- TypeHintPolicy::is_p3c_target() 追加
  - P1/P2/P3-A/P3-B 以外を P3-C 候補として判定

Phase 67: P3-C 実利用への一歩
- phase67_generic_type_resolver.rs テスト追加 (3テスト)
- lifecycle.rs に P3-C 経路フック追加
  - GenericTypeResolver を P3-C 対象関数で優先使用
- A/B テストで旧経路との一致確認 (11 tests PASS)

Phase 68: JoinIR First Chapter Wrap (ドキュメント整理)
- 68-1: phase-30 README.md に Section 9 追加 (JoinIR 第1章完了サマリー)
- 68-2: README.md に JoinIR status セクション追加
- 68-3: CURRENT_TASK.md スリム化 (351→132行, 62%削減)
- 68-4: PHI_BOX_INVENTORY.md に Phase 66-67 完了セクション追加

Phase 69-1: Trio 棚卸し
- phase69-1-trio-inventory.md 作成
- Trio 使用箇所の完全棚卸し完了 (削減見込み 457-707行)

🐱 JoinIR 第1章完了!4つの柱確立:
- Structure (LoopForm)
- Scope (LoopScopeShape)
- JoinIR (Select/IfMerge/Loop)
- Type Hints (P1-P3-C)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 08:54:18 +09:00
0c23bc0788 docs: Phase 61-5 If PHI 棚卸し完了
Phase 61-5: If PHI 残りパターン棚卸しと削減計画策定

New docs:
- phase61-5-3-if-phi-priority-table.md: P1/P2/P3 優先度表
  - P1: 18関数(薄いラッパー削除候補)
  - P2: 5関数(JoinIR 拡張統合候補)
  - P3: 3関数(型システム統合待ち)

- phase61-5.4-next-phase-candidates.md: Phase 61-6 削減候補(3個)
  - Wave 1: set_if_context 削除(11行)、dev フラグ削除(15行)
  - Wave 2: A/B テスト削除(50行)
  - 合計削減見込み: 76行

- phase61-5-summary.md: Phase 61-5 全体サマリー
  - JoinIR カバー率: 完全28.6% + 部分57.1% = 85.7%
  - Phase 61-6 実装準備完了

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 15:57:14 +09:00
3af98964ed feat(joinir): Phase P2-P4 Loop Pattern boxification
- P2: Create loop_patterns/ module structure
  - common.rs: shared helpers (ParsedProgram, LoopContext, etc.)
  - simple.rs: generic loop lowering
  - filter.rs, print_tokens.rs: delegate to simple
  - break_pattern.rs, continue_pattern.rs: new modules

- P3: Create LoopFrontendBinding layer
  - Separate function name detection from pattern lowering
  - detect_loop_pattern() for pattern classification

- P4: Break/Continue pattern migration
  - Move Break/Continue handling from loop_patterns_old.rs
  - Add LoopPattern::Break and LoopPattern::Continue variants

- Design: 3-layer architecture
  - LoopFrontendBinding: function name → LoopPattern
  - loop_patterns: LoopPattern → JoinIR
  - Bridge/VM: Box semantics

All 56 JoinIR tests pass.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 09:04:18 +09:00
fd83903f87 feat(joinir): Phase P1 If Handler boxification - 40% code reduction
## Summary
Refactored loop-internal If statement handling into a boxified module
structure, achieving 154-line reduction (40%) from stmt_handlers.rs
with zero regression.

## Implementation
- Created if_in_loop/ module (9 files, ~480 lines)
  - pattern.rs: IfInLoopPattern enum (5 variants)
  - lowering/{empty,single_var_then,single_var_both,conditional_effect,unsupported}.rs
- Replaced lower_if_stmt_in_loop() (154 lines) with lower_if_stmt_in_loop_boxified()
- Made StatementEffect pub(crate) for module visibility

## Pattern Classification
1. Empty: condition-only check (no side effects)
2. SingleVarThen: if { x = a } → x = cond ? a : x
3. SingleVarBoth: if { x = a } else { x = b } → x = cond ? a : b
4. ConditionalEffect: if pred(v) { acc.push(v) } (filter pattern)
5. Unsupported: complex cases (Phase 54+)

## Test Results
 56 JoinIR tests PASSED (0 failed, 0 regression)
 Build successful (1m 02s)
 Improved maintainability (easier to add new patterns)

## Files Changed
- src/mir/join_ir/frontend/ast_lowerer/
  - if_in_loop/ (9 new files)
  - mod.rs (+2 lines: module + pub use)
  - stmt_handlers.rs (-154 lines: 40% reduction)
- CURRENT_TASK.md (+5 lines: Phase P1 記録)
- docs/development/refactoring/p1-if-handler-boxification-plan.md (new)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 07:20:56 +09:00
588129db65 feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論
**Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring
呼び出しを通すことに成功。

## 主要変更

### 1. MethodCall 構造追加 (34-6.1)
- `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines)
  - 構造: `{ dst, receiver, method, args }`
  - 設計原則: JoinIR は構造のみ、意味論は MIR レベル

### 2. extract_value 更新 (34-6.2)
- `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines)
  - receiver/args を extract_value で再帰処理
  - ダミー Const(0) 削除 → 本物の MethodCall 生成
  - cond 処理修正: ValueId(0) ハードコード → extract_value で取得

### 3. JoinIR→MIR 変換実装 (34-6.3)
- `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines)
- `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines)
- `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines)

### 4. テスト更新 (34-6.4)
- `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造
- `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用
- テスト成功: v="hello", at=3 → "hel" 

## 成果

-  テスト全通過(1 passed; 0 failed)
-  設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル
-  Phase 33-10 原則との整合性: Method でも同じ原則適用

**ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
51ff558904 feat(phase32): L-2.1 Stage-1 UsingResolver JoinIR integration + cleanup
Phase 32 L-2.1 complete implementation:

1. Stage-1 UsingResolver main line JoinIR connection
   - CFG-based LoopForm construction for resolve_for_source/5
   - LoopToJoinLowerer integration with handwritten fallback
   - JSON snapshot tests 6/6 PASS

2. JoinIR/VM Bridge improvements
   - Simplified join_ir_vm_bridge.rs dispatch logic
   - Enhanced json.rs serialization
   - PHI core boxes cleanup (local_scope_inspector, loop_exit_liveness, loop_var_classifier)

3. Stage-1 CLI enhancements
   - Extended args.rs, groups.rs, mod.rs for new options
   - Improved stage1_bridge module (args, env, mod)
   - Updated stage1_cli.hako

4. MIR builder cleanup
   - Simplified if_form.rs control flow
   - Removed dead code from loop_builder.rs
   - Enhanced phi_merge.rs

5. Runner module updates
   - json_v0_bridge/lowering.rs improvements
   - dispatch.rs, selfhost.rs, modes/vm.rs cleanup

6. Documentation updates
   - CURRENT_TASK.md, AGENTS.md
   - Various docs/ updates

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 10:17:37 +09:00
466e636af6 Span trace utilities and runner source hint 2025-11-24 14:17:02 +09:00
3d5979c78e refactor(joinir): Phase 27.9 - Modular separation of join_ir.rs into directory structure
Phase 27.9 で join_ir.rs (~1,336行) を以下のモジュール構造に分離:

## 新規ディレクトリ構造:
```
src/mir/join_ir/
├── mod.rs                           # 型定義・共通ユーティリティ (~330行)
└── lowering/
    ├── mod.rs                       # lowering インターフェース
    ├── min_loop.rs                  # lower_min_loop_to_joinir (~140行)
    ├── skip_ws.rs                   # skip_ws lowering 3関数 (~390行)
    └── funcscanner_trim.rs          # trim lowering (~480行)
```

## 技術的変更:
- **型定義統一**: JoinFuncId, JoinInst, JoinModule 等を mod.rs に集約
- **lowering 分離**: 3つの lowering 関数を個別モジュールに移動
- **後方互換性**: pub use で lowering 関数を re-export(既存コード影響なし)
- **削除**: src/mir/join_ir.rs (旧単一ファイル)

## テスト結果:
- **385 passed** (+1 from 384)
- **9 failed** (-1 from 10)
- **ビルド成功**: 0 errors, 18 warnings (変化なし)

## 効果:
- **保守性向上**: 1,336行 → 4ファイル(各300-500行)で可読性向上
- **モジュール境界明確化**: 型定義 vs lowering 実装の責務分離
- **将来の拡張容易**: 新 lowering 関数追加が簡単に

Phase 27.8 で実装した MIR 自動解析 lowering の基盤整備完了。

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 16:49:49 +09:00
8750186e55 chore: Phase 26-H セッション完了 - 全ドキュメント更新
Phase 26-H 完了内容:
 JoinIR 型定義実装(src/mir/join_ir.rs)
 MIR → JoinIR 自動変換実装(lower_min_loop_to_joinir)
 自動変換テスト実装(mir_joinir_min_auto_lowering)
 PHI/Loop箱 → JoinIR 移行対応表追加(loopform_ssot.md)

ドキュメント更新:
- Phase 27 JoinIR タスク計画追加
- Phase 26-H タスク完了記録
- 各種 README 更新(進捗反映)
- CURRENT_TASK.md 更新

コミット統計: $(git status --short | wc -l) files changed

次のステップ: Phase 27 一般化 MIR → JoinIR 変換
2025-11-23 05:53:27 +09:00
9a5cec394c docs(loopform): PHI/Loop箱→JoinIR移行対応表追加
実装内容:
- loopform_ssot.md に Phase 26-H 以降の移行戦略追加
- 全17箱の将来的な扱いを3カテゴリに分類:
  🔄 JoinIR に吸収(6箱): Header/Exit/Snapshot系
   削除候補(4箱): PhiBuilder/IfPhi/LoopPhi系
   残す(7箱): 前処理/検証/ユーティリティ系

移行戦略:
- Phase 27: 一般化 MIR → JoinIR 変換実装
- Phase 28: JoinIR 実行器実装(VM/LLVM)
- Phase 29: レガシー PHI 箱の段階的削除

これで「今の箱が最終的にどう片付くか」一目瞭然!🎉
2025-11-23 04:52:37 +09:00
2692eafbbf feat(mir): Phase 26-H JoinIR型定義実装完了 - ChatGPT設計
## 実装内容(Step 1-3 完全達成)

### Step 1: src/mir/join_ir.rs 型定義追加
- **JoinFuncId / JoinContId**: 関数・継続ID型
- **JoinFunction**: 関数(引数 = φノード)
- **JoinInst**: Call/Jump/Ret/Compute 最小命令セット
- **MirLikeInst**: 算術・比較命令ラッパー
- **JoinModule**: 複数関数保持コンテナ
- **単体テスト**: 型サニティチェック追加

### Step 2: テストケース追加
- **apps/tests/joinir_min_loop.hako**: 最小ループ+breakカナリア
- **src/tests/mir_joinir_min.rs**: 手書きJoinIR構築テスト
  - MIR → JoinIR手動構築で型妥当性確認
  - #[ignore] で手動実行専用化
  - NYASH_JOINIR_EXPERIMENT=1 トグル制御

### Step 3: 環境変数トグル実装
- **NYASH_JOINIR_EXPERIMENT=1**: 実験モード有効化
- **デフォルト挙動**: 既存MIR/LoopForm経路のみ(破壊的変更なし)
- **トグルON時**: JoinIR手書き構築テスト実行

## Phase 26-H スコープ遵守
 型定義のみ(変換ロジックは未実装)
 最小限の命令セット
 Debug 出力で妥当性確認
 既存パイプライン無影響

## テスト結果
```
$ NYASH_JOINIR_EXPERIMENT=1 cargo test --release mir_joinir_min_manual_construction -- --ignored --nocapture
[joinir/min] MIR module compiled, 3 functions
[joinir/min] JoinIR module constructed:
[joinir/min]  JoinIR型定義は妥当(Phase 26-H)
test result: ok. 1 passed; 0 failed
```

## JoinIR理論の実証
- **φノード = 関数引数**: `fn loop_step(i, k_exit)`
- **merge = join関数**: 分岐後の合流点
- **ループ = 再帰関数**: `loop_step` 自己呼び出し
- **break = 継続呼び出し**: `k_exit(i)`

## 次フェーズ (Phase 27.x)
- LoopForm v2 → JoinIR 自動変換実装
- break/continue ハンドリング
- Exit PHI の JoinIR 引数化

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: ChatGPT <noreply@openai.com>
2025-11-23 04:10:12 +09:00
948f22a03a feat(phi): Phase 26-F-2 - 箱理論による責務分離(IfBodyLocalMergeBox新設)
**箱理論による問題解決**:
-  問題: LoopVarClassBox(ループスコープ分析)とif-merge処理が混在
-  解決: if-merge専用箱を新設して責務分離

**新箱: IfBodyLocalMergeBox**:
- 責務: if-merge専用のbody-local φ候補決定
- ロジック:
  - 両腕に存在する変数を検出
  - pre_ifと比較して値が変わった変数のみ
  - empty elseは空リスト返す
- 特徴: LocalScopeInspector不要、LoopVarClassBox不使用

**変更ファイル**:
- src/mir/phi_core/if_body_local_merge.rs: 新規作成(IfBodyLocalMergeBox)
- src/mir/phi_core/phi_builder_box.rs: IfBodyLocalMergeBox使用に切り替え
- src/mir/phi_core/body_local_phi_builder.rs: filter_if_merge_candidates()削除
- src/mir/loop_builder.rs: BodyLocalPhiBuilder setup削除
- src/mir/phi_core/mod.rs: if_body_local_merge追加

**テスト結果**:
- Passed: 353→354 (+1) 
- Failed: 14→14 (退行なし)

**既知の問題**:
- domination error依然残存(%48 in bb48 from bb52)
- 次フェーズで調査・修正予定

技術詳細:
- ChatGPT箱理論分析による設計
- A案ベースのシンプル実装
- 責務明確化: ループスコープ分析 vs if-merge専用処理
2025-11-22 11:03:21 +09:00
cbe6bf0140 feat(phi): Phase 26-F Step 1 & 3 - BodyLocal if-merge統合(WIP - 過剰フィルタリング発生中)
Step 1完了:
- body_local_phi_builder.rs: filter_if_merge_candidates() API追加
- pre_if/then_end/else_end_opt/reachable_preds受け取り
- LoopVarClassBox使用して変数分類

Step 3完了:
- loop_builder.rs: BodyLocalPhiBuilder作成・PhiBuilderBoxに設定
- phi_builder_box.rs: IfPhiContext拡張・set_body_local_filter()実装
- compute_modified_names_if()でフィルタリング適用

**問題**: LocalScopeInspectorBox空のため全候補フィルタリング(0 candidates)

技術詳細:
- inspector定義記録なし → classify誤判定 → 全変数BodyLocalInternal扱い
- テスト結果: bb54/bb52→bb38/bb36/bb32(ブロック番号変化=PHI生成影響あり)
- mir_stage1_using_resolver_modules_map_continue_break_with_lookup_verifies: PASS
- mir_stage1_using_resolver_resolve_with_modules_map_verifies: FAIL(domination error残存)

次のステップ:
1. filter_if_merge_candidates()単純実装(inspector不要)
2. または変数定義トラッキング実装
3. ChatGPT相談推奨
2025-11-22 09:05:31 +09:00
7812c3d4c1 feat(phi): Phase 25.1 - BTreeMap移行 (21ファイル、80%決定性達成)
## 修正内容

### Core MIR/PHI (5ファイル)
- builder.rs: variable_map, value_types, value_origin_newbox
- context.rs: 3つのマップ
- loop_builder.rs: 3箇所
- loop_snapshot_manager.rs: snapshot マップ
- loop_snapshot_merge.rs: 2箇所

### MIR関連 (4ファイル)
- function.rs: FunctionMetadata.value_types
- resolver.rs: CalleeResolverBox
- guard.rs: CalleeGuardBox
- loop_common.rs: apply_increment_before_continue

### JSON Bridge (5ファイル)
- json_v0_bridge/lowering.rs
- json_v0_bridge/lowering/expr.rs
- json_v0_bridge/lowering/if_else.rs
- json_v0_bridge/lowering/merge.rs
- json_v0_bridge/lowering/try_catch.rs
- json_v0_bridge/mod.rs

### Printer & Providers (4ファイル)
- printer.rs, printer_helpers.rs
- host_providers/mir_builder.rs
- backend/mir_interpreter/handlers/extern_provider.rs

### Tests (3ファイル)
- phi_core/conservative.rs
- tests/json_program_loop.rs
- tests/mir_stage1_using_resolver_verify.rs (2テスト有効化)

## テスト結果
- mir_stage1_using_resolver_resolve_with_modules_map_verifies: 80%成功率
- 完全な決定性は未達成 (HashMap 86箇所、HashSet 63箇所が残存)

🐱 Generated with Claude Code
2025-11-22 05:33:40 +09:00