Commit Graph

6 Commits

Author SHA1 Message Date
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
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