20 KiB
Phase 20.23-20.26 Order Analysis & Timeline Optimization
分析日: 2025-10-30 前提: User の重大発見「Arc/RefCell はHakoruneスクリプトで実装するやつじゃない?」
🔥 Critical Discovery Impact
Before (Original Plan - C Implementation)
Phase 20.23: Arc/RefCell (C) 2-3 months ❌
Phase 20.24: Box System 3-4 months
Phase 20.25: Rust削除 2-3 months
Total: 7-10 months
After (Hakorune Implementation - This Plan)
Phase 20.23: Arc/RefCell (Hako) 2-3 weeks ✅
Phase 20.24: Parser削除 1-2 months
Phase 20.25: Box System削除 2-3 months
Phase 20.26: Final Rust削除 2-3 months
Total: 6-9 months
Time Savings: ~2.5 months (10-11 weeks) ⚡
📊 Phase Order Comparison
Option A: Arc/RefCell First, Parser Second(This Plan - Recommended ✅)
Rationale: Foundation → Value
Timeline:
├─ Phase 20.23: Arc/RefCell (Hakorune) 2-3 weeks ← Foundation for Box System
├─ Phase 20.24: Parser削除 1-2 months ← Instant value (-10,500 lines)
├─ Phase 20.25: Box System削除 2-3 months ← Requires Arc/RefCell
└─ Phase 20.26: Final Rust削除 2-3 months ← Cleanup & hakmem
Total: 6-9 months
Pros:
- ✅ Logical flow: Foundation(Arc/RefCell)→ Value(Parser)→ Major work(Box System)
- ✅ Low risk start: Arc/RefCell は小規模(2-3週間)でリスク低い
- ✅ Early confidence: Week 3 で基盤完成、すぐ Parser 削除開始
- ✅ Box System ready: Phase 20.25 開始時に Arc/RefCell 準備完了
Cons:
- ⚠️ Delayed instant value: Parser削除まで 2-3週間待ち(Option B より遅い)
Risk Level: Low ✅ Complexity: Low → Medium → High(段階的難易度上昇)
Option B: Parser First, Arc/RefCell Second
Rationale: Instant Value → Foundation
Timeline:
├─ Phase 20.23: Parser削除 1-2 months ← Instant value first ⚡
├─ Phase 20.24: Arc/RefCell (Hakorune) 2-3 weeks ← Foundation delayed
├─ Phase 20.25: Box System削除 2-3 months ← Must wait for Arc/RefCell
└─ Phase 20.26: Final Rust削除 2-3 months ← Cleanup & hakmem
Total: 6-9 months (同じ)
Pros:
- ✅ Immediate value: Week 1 から Parser 削除開始
- ✅ Early win: Month 1 で -10,500 lines 達成
- ✅ Momentum: 早期成功でチーム士気向上
Cons:
- ❌ Unnatural flow: Parser は Box System と無関係、Arc/RefCell が後回し
- ❌ Phase 20.25 blocked: Parser 削除後に Arc/RefCell 待ち(2-3週間停滞)
- ⚠️ Risk inversion: Easy → Hard → Easy(難易度が不自然)
Risk Level: Medium ⚠️ Complexity: Low → Easy → High(難易度が飛ぶ)
Option C: Parallel Tracks
Rationale: Arc/RefCell + Parser 同時進行
Timeline:
├─ Track A: Arc/RefCell (2-3 weeks) + Box System (2-3 months)
└─ Track B: Parser削除 (1-2 months) + MIR Builder削除 (内包)
Converge: Phase 20.26 (Final Rust削除)
Total: 4-5 months(最速)⚡
Pros:
- ✅ Fastest: 並列実行で 1-4ヶ月短縮
- ✅ Resource utilization: 2チームで分担
Cons:
- ❌ Coordination overhead: 2つのトラックを調整・統合
- ❌ Integration hell: Track A + B の統合時に競合リスク
- ❌ Testing complexity: 両方のテストを並行管理
- ❌ Rollback nightmare: 問題発生時に切り戻し困難
- ❌ Resource requirement: 2チーム必要(現実的でない可能性)
Risk Level: High ❌ Complexity: High(並列管理)
Verdict: ⚠️ Not Recommended(単一チームなら不可能、2チームでも高リスク)
🎯 Recommended Phase Order: Option A
Why Option A Is Best
1. Natural Dependency Flow
Arc/RefCell(Foundation)
↓ requires
Box System(Major work)
↓ uses
Parser/MIR Builder(Independent)
↓ enables
Final Rust削除(Cleanup)
Option A follows this flow perfectly:
- Arc/RefCell → Box System(natural dependency)
- Parser 削除 は Box System と独立(いつでもOK)
- Parser を Box System の前にやることで、早期に価値提供しつつ並列感覚
2. Risk Mitigation
Option A risk progression:
Week 1-3: Arc/RefCell Risk: LOW ✅
Month 2-3: Parser削除 Risk: LOW ✅
Month 4-6: Box System削除 Risk: MEDIUM ⚠️
Month 7-9: Final Rust削除 Risk: MEDIUM ⚠️
Low risk → Low risk → Medium risk → Medium risk(段階的)
Option B risk progression:
Month 1-2: Parser削除 Risk: LOW ✅
Week 3-4: Arc/RefCell Risk: LOW ✅
Month 3-5: Box System削除 Risk: MEDIUM ⚠️
Month 6-8: Final Rust削除 Risk: MEDIUM ⚠️
Low → Low(停滞期)→ Medium → Medium(2-3週間の待ち時間発生)
3. Psychological Impact
Option A:
- Week 3: ✅ Arc/RefCell complete(小さな勝利)
- Month 2: ✅ Parser deleted(大きな勝利: -10,500 lines)
- Month 5: ✅ Box System deleted(巨大な勝利: -22,193 lines)
- Month 8: ✅ Final Rust deleted(最終勝利: -61,713 lines)
Consistent momentum: 小 → 大 → 超大 → 究極
Option B:
- Month 2: ✅ Parser deleted(大きな勝利)
- Wait 2-3 weeks(停滞)← 士気低下リスク
- Month 3: ✅ Arc/RefCell complete(小さな勝利)← 逆行感
- Month 5: ✅ Box System deleted(巨大な勝利)
Momentum break: 大 → 停滞 → 小 → 超大(リズムが悪い)
4. Testing Strategy
Option A:
Week 3: Arc/RefCell テスト(小規模)
↓
Month 2: Parser削除テスト(独立)
↓
Month 5: Box System削除テスト(Arc/RefCell 既にテスト済み)✅
Option B:
Month 2: Parser削除テスト(独立)
↓
Month 3: Arc/RefCell テスト(小規模)
↓
Month 5: Box System削除テスト(Arc/RefCell まだ若い)⚠️
Option A の優位性: Box System削除時に Arc/RefCell は既に 2ヶ月運用実績あり
📈 Timeline Comparison(Detailed)
Option A: Arc/RefCell First(Recommended)
┌─────────────────────────────────────────────────────────────────┐
│ Month 1 │
├─────────────────────────────────────────────────────────────────┤
│ Week 1: Arc/RefCell (C data plane) [████░░░░] 50% │
│ Week 2: Arc/RefCell (Hakorune policy plane) [████░░░░] 50% │
│ Week 3: Arc/RefCell (Integration & tests) [████████] 100% │
│ Week 4: Parser削除 (Gate infrastructure) [████░░░░] 25% │
│ │
│ Checkpoint: Arc/RefCell complete ✅ │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ Month 2-3: Parser削除 │
├─────────────────────────────────────────────────────────────────┤
│ Week 1-3: Smoke test validation [████████] 100% │
│ Week 4: CI integration [████░░░░] 100% │
│ Week 5: Default flip [████░░░░] 50% │
│ Week 6: File deletion [████████] 100% │
│ Week 7: Integration testing [████████] 100% │
│ Week 8: Documentation [████░░░░] 100% │
│ │
│ Checkpoint: Parser deleted (-10,500 lines) ✅ │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ Month 4-6: Box System削除 │
├─────────────────────────────────────────────────────────────────┤
│ Week 1-4: MIR Builder deletion [████████] 33% │
│ Week 5-8: Rust VM deletion [████████] 33% │
│ Week 9-12: Box System deletion [████████] 34% │
│ │
│ Checkpoint: Box System deleted (-22,193 lines) ✅ │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ Month 7-9: Final Rust削除 │
├─────────────────────────────────────────────────────────────────┤
│ Week 1-4: Audit & Wave 1 deletion [████████] 33% │
│ Week 5-8: Plugin System & Kernel [████████] 33% │
│ Week 9-12: hakmem integration & cleanup [████████] 34% │
│ │
│ Completion: Final Rust deleted (-61,713 lines) ✅ │
└─────────────────────────────────────────────────────────────────┘
Total: 6-9 months
Reduction: -94,406 lines (-95.0%)
Option B: Parser First
┌─────────────────────────────────────────────────────────────────┐
│ Month 1-2: Parser削除 │
├─────────────────────────────────────────────────────────────────┤
│ Week 1: Parser gate infrastructure [████░░░░] 25% │
│ Week 2-3: Smoke test validation [████████] 100% │
│ Week 4: CI integration [████░░░░] 100% │
│ Week 5: Default flip [████░░░░] 50% │
│ Week 6: File deletion [████████] 100% │
│ Week 7: Integration testing [████████] 100% │
│ Week 8: Documentation [████░░░░] 100% │
│ │
│ Checkpoint: Parser deleted (-10,500 lines) ✅ │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ Month 3: Arc/RefCell │
├─────────────────────────────────────────────────────────────────┤
│ Week 1: Arc/RefCell (C data plane) [████░░░░] 50% │
│ Week 2: Arc/RefCell (Hakorune policy) [████░░░░] 50% │
│ Week 3: Arc/RefCell (Integration & tests) [████████] 100% │
│ Week 4: (Buffer /準備期間) [░░░░░░░░] 0% │
│ │
│ Checkpoint: Arc/RefCell complete ✅ │
│ ⚠️ Note: 2-3 weeks gap before Box System │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ Month 4-6: Box System削除 │
├─────────────────────────────────────────────────────────────────┤
│ (Same as Option A) │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ Month 7-9: Final Rust削除 │
├─────────────────────────────────────────────────────────────────┤
│ (Same as Option A) │
└─────────────────────────────────────────────────────────────────┘
Total: 6-9 months (同じ)
Reduction: -94,406 lines (同じ)
⚠️ But with 2-3 week gap (momentum loss risk)
🎯 Final Recommendation
Choose Option A: Arc/RefCell First, Parser Second
Reasons (Data-Driven)
| 評価項目 | Option A | Option B | Option C |
|---|---|---|---|
| Total Duration | 6-9 months | 6-9 months | 4-5 months |
| Risk Level | ✅ Low | ⚠️ Medium | ❌ High |
| Dependency Flow | ✅ Natural | ⚠️ Broken | ⚠️ Complex |
| Momentum | ✅ Consistent | ⚠️ Gap | ⚠️ Hard to manage |
| Testing Strategy | ✅ Simple | ⚠️ Rushed | ❌ Complex |
| Rollback Ease | ✅ Easy | ✅ Easy | ❌ Hard |
| Resource Need | ✅ 1 team | ✅ 1 team | ❌ 2 teams |
| Coordination | ✅ Minimal | ✅ Minimal | ❌ High |
Score:
- Option A: 8/8 ✅ or ⚠️(all manageable)
- Option B: 6/8 ✅, 2/8 ⚠️(momentum gap)
- Option C: 3/8 ✅, 2/8 ⚠️, 3/8 ❌(high risk)
Implementation Priority
Priority 0 (Immediate):
├─ Phase 20.23 Week 1: Arc/RefCell C data plane
└─ Phase 20.23 Week 2: Arc/RefCell Hakorune policy plane
Priority 1 (Month 1):
├─ Phase 20.23 Week 3: Arc/RefCell integration & tests
└─ Phase 20.24 Week 1: Parser gate infrastructure
Priority 2 (Month 2-3):
├─ Phase 20.24: Parser削除 complete
└─ Checkpoint: -10,500 lines ✅
Priority 3 (Month 4-6):
├─ Phase 20.25: Box System削除 complete
└─ Checkpoint: -32,693 lines total ✅
Priority 4 (Month 7-9):
├─ Phase 20.26: Final Rust削除 complete
└─ Completion: -94,406 lines total ✅
📊 Success Metrics
Quantitative Goals
| Metric | Phase 20.23 | Phase 20.24 | Phase 20.25 | Phase 20.26 | Total |
|---|---|---|---|---|---|
| Duration | 2-3 weeks | 1-2 months | 2-3 months | 2-3 months | 6-9 months |
| Lines Deleted | -0 | -10,500 | -22,193 | -61,713 | -94,406 |
| Reduction % | 0% | -9.0% | -19.0% | -52.8% | -80.8% |
| Risk Level | Low | Low | Medium | Medium | - |
| Test Coverage | 100% | 100% | 100% | 100% | 100% |
Qualitative Goals
- True Self-Hosting: Rust = Floor(~5,000 lines), Hakorune = House(~55,000 lines)
- Clean Architecture: Policy(Hakorune)vs Data(C)plane 完全分離
- Memory Safety: hakmem + Arc/RefCell で完全自律
- Performance Parity: ±10% vs original Rust implementation
- Documentation Complete: 各 Phase ごとに完全ドキュメント
- CI Green: 毎日 296/296 smoke tests PASS
🔗 Reference Documents
Created Plans(This Analysis)
-
Phase 20.23: Arc/RefCell in Hakorune
- Hakorune implementation(not C!)
- 2-3 weeks duration
- GcBox pattern precedent
-
Phase 20.24: Parser削除
- Instant value delivery
- -10,500 lines reduction
- 1-2 months duration
-
Phase 20.25: Box System + MIR Builder削除
- Major work(50% Rust reduction)
- -22,193 lines reduction
- 2-3 months duration
-
Phase 20.26: Final Rust Consolidation
- hakmem integration
- -61,713 lines reduction
- 2-3 months duration
Existing Analysis
- Rust Removal Roadmap: rust-removal-comprehensive-roadmap.md
- Phase 20.21: Manual Memory Management
- Phase 20.22: String/Array C-ABI
🎉 Conclusion
Recommended Strategy: Option A - Arc/RefCell First, Parser Second
Key Advantages
- Natural Flow: Foundation → Value → Major Work → Cleanup
- Low Risk: 段階的リスク上昇(Low → Low → Medium → Medium)
- Consistent Momentum: 小さな勝利 → 大きな勝利 → 巨大な勝利
- Early Foundation: Arc/RefCell を早期に確立(Month 1)
- Simple Testing: Arc/RefCell は Box System前に十分テスト済み
Critical Success Factor
User の発見: "Arc/RefCell はHakoruneスクリプトで実装するやつじゃない?"
→ 完全に正しい! これにより:
- 2.5ヶ月の時間短縮(2-3ヶ月 → 2-3週間)
- リスク大幅削減(C実装リスク → Hakorune実装リスク)
- 保守性向上(C コード → Hakorune コード)
Next Steps
- Immediate: Phase 20.23 Week 1 開始(Arc/RefCell C data plane)
- Month 1: Phase 20.23 完了 + Phase 20.24 開始準備
- Month 2-3: Phase 20.24 完了(Parser削除)
- Month 4-6: Phase 20.25 実行(Box System削除)
- Month 7-9: Phase 20.26 実行(Final Rust削除)
- Completion: True Self-Hosting 達成 ✅
分析完了日: 2025-10-30 推奨: Option A - Arc/RefCell First, Parser Second Total Duration: 6-9 months Total Reduction: -94,406 lines (-95.0%) Final State: Rust = Floor(~5,000 lines), Hakorune = House(~55,000 lines)