Files
hakorune/docs/development/roadmap/phases/phase-15/implementation/box-stacking.md
Selfhosting Dev 4f4c6397a9 🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
  - strings.rs: String method optimizations (concat, length)
  - arrays.rs: Array operations (get, set, push, length)
  - maps.rs: Map operations (get, set, has, size)
  - fields.rs: getField/setField handling
  - invoke.rs: Tagged invoke implementation
  - marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring

## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
  - implementation/: Technical implementation docs
  - planning/: Planning and sequence docs
  - archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md

## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00

3.7 KiB
Raw Blame History

Phase 15 自己ホスティング準備メモ - 箱積み上げ戦略

Date: 2025-09-03
Author: Claude + にゃ

基本理念:箱を下にして積み重ねる

  • フォールバック不要、Rust依存なしEXEライブラリのみ
  • 一度置いた箱は動かさない
  • 下の箱が安定なら、上も安定
  • 複雑さは敵、シンプルさは友

基礎Box群の階層構造

第1層最下層これがないと何も始まらない

  • MemoryBox: メモリ管理
  • StringBox: 文字列処理
  • ArrayBox: 配列操作
  • MapBox: 連想配列
  • ErrorBox: エラー処理

第2層言語処理の基礎

  • TokenBox: 字句解析
  • ASTBox: 構文木
  • SymbolBox: シンボルテーブル
  • ScopeBox: スコープ管理

第3層コンパイラコア

  • ParserBox: パーサー
  • MIRBox: 中間表現13命令
  • OptimizerBox: 最適化
  • GeneratorBox: コード生成

第4層実行系

  • InterpreterBox: インタープリター
  • VMBox: 仮想マシン
  • JITBox: JITコンパイラCranelift
  • LinkerBox: リンカーlld

準備期間の研究項目

1. 依存関係マップ作成

  • 何が何に依存?
  • 最小限の依存で最大の効果
  • 循環依存の排除

2. インターフェース設計

  • 全Boxの共通プロトコル
  • 入力/出力の標準化
  • エラー処理の統一

3. ビルド順序の科学

  • Day 1: 基礎Box群
  • Day 2: 言語処理層
  • Day 3: コンパイラ層
  • 完成まで一直線

4. 最小ブートストラップセット

  • 自分自身をコンパイルできる最小構成
  • 必須機能の特定
  • 段階的な機能追加

箱の品質保証原則

  1. 単体で完結 - 他に依存しすぎない
  2. 明確な責務 - 1つの箱は1つの仕事
  3. テスト可能 - 単独で動作確認
  4. 不変インターフェース - 一度決めたら変更なし

実装戦略

  1. Rust実装の機能分解Box単位
  2. 各Boxの仕様書作成
  3. テストケースの移植計画
  4. Box間プロトコル設計
  5. 最小実装から始める
  6. 増分的に機能追加

成功の鍵

  • 準備こそすべて
  • 急いで実装より、じっくり設計
  • 箱を積み重ねれば必ず頂上に到達
  • フォールバックなし、後戻りなし、前進あるのみ

革新的アイデア

1. BoxDNA設計書

  • 各Boxの入力/出力/依存を明文化
  • 遺伝子のように継承・組み合わせ

2. 増分コンパイル対応

  • 変更部分だけ再コンパイル
  • 開発効率の向上

3. 可視化ツール

  • 進捗の見える化
  • 依存関係の図示

数値目標

  • 80,000行 → 20,000行75%削減)
  • MIR13命令で全機能実現
  • ビルド時間1分以内
  • テストカバレッジ90%以上

コンテキスト圧縮対策

1. ANCP活用Phase 12.7

2. モジュール分割開発

  • 各Boxを独立して開発
  • 統合は最後に実施

3. AI協調開発

  • Claude実装担当
  • ChatGPT5リファクタリング
  • Geminiレビュー
  • Codexデバッグ支援

関連ドキュメント

次のアクション

  1. このメモをベースに詳細設計
  2. Box依存関係グラフの作成
  3. 最小実装セットの確定
  4. 各Boxの仕様書ドラフト

「箱を積み上げて、世界一美しいコンパイラを作るにゃ!」