# Phase 0: Execution Plan **Date:** 2026-07-27 **Status:** Complete **Deliverable:** Comprehensive execution plan for Makepad map codebase improvement --- ## Executive Summary This execution plan outlines a **30-week roadmap** to transform the Makepad map codebase from its current state (4.5/10 performance, 4.2/10 architecture, 66 bugs) to a production-ready state (8.9/10 performance, 8.5/10 architecture, < 5 bugs). **Total Estimated Effort:** 150 person-days (30 weeks × 5 days/week × 1 developer) **Team Size:** 2 developers recommended (15 weeks calendar time) **Budget:** $150,000 - $225,000 (assuming $1,000 - $1,500/day per developer) **Expected Outcomes:** - Performance: 4.5/10 → 8.9/10 (+98%) - Architecture: 4.2/10 → 8.5/10 (+102%) - Bug count: 66 → < 5 (-92%) - Code quality: 3/10 → 8/10 (+167%) - Test coverage: 20% → 80% (+300%) --- ## 1. Project Overview ### 1.1 Current State **Performance:** - Frame rate: 15-25 FPS during panning (target: 60 FPS) - Tile loading time: 3-5 seconds (target: < 1 second) - Memory usage: 1.5-2GB (target: < 500MB) - Label placement time: 200-500ms (target: < 50ms) - Geometry tessellation time: 100-300ms (target: < 20ms) **Architecture:** - 19 modules with complex interdependencies - 3 circular dependencies (critical issue) - God objects (NigigMapView with 20+ fields) - Massive files (geometry.rs: 1968 lines, style_json.rs: 3242 lines) - Maximum dependency depth: 7 levels **Bugs:** - 12 critical bugs (crashes, security vulnerabilities) - 23 high-priority bugs (performance issues, incorrect behavior) - 31 medium-priority bugs (minor issues, UX problems) **Code Quality:** - 14,182 lines of code across 19 modules - 20% test coverage - Inconsistent code style - Missing documentation ### 1.2 Target State **Performance:** - Frame rate: 60 FPS in all scenarios - Tile loading time: < 1 second - Memory usage: < 500MB - Label placement time: < 50ms - Geometry tessellation time: < 20ms **Architecture:** - 30+ modules with clear boundaries - 0 circular dependencies - No god objects (max 10 fields per struct) - No massive files (max 500 lines per file) - Maximum dependency depth: 3 levels **Bugs:** - 0 critical bugs - 0 high-priority bugs - < 5 medium-priority bugs **Code Quality:** - 20,000+ lines of code across 30+ modules (refactored + new tests) - 80% test coverage - Consistent code style (rustfmt) - Comprehensive documentation ### 1.3 Success Criteria **Performance Metrics:** - ✅ Frame rate ≥ 60 FPS in all scenarios - ✅ Tile loading time < 1 second (95th percentile) - ✅ Memory usage < 500MB (peak) - ✅ Label placement time < 50ms (95th percentile) - ✅ Geometry tessellation time < 20ms (95th percentile) **Architecture Metrics:** - ✅ 0 circular dependencies - ✅ Maximum dependency depth ≤ 3 levels - ✅ No files > 500 lines - ✅ No structs with > 10 fields - ✅ All modules have clear single responsibility **Quality Metrics:** - ✅ 0 critical bugs - ✅ 0 high-priority bugs - ✅ < 5 medium-priority bugs - ✅ Test coverage ≥ 80% - ✅ All public APIs documented **Delivery Metrics:** - ✅ Completed within 30 weeks - ✅ Within budget ($150,000 - $225,000) - ✅ No production incidents during refactoring - ✅ Zero downtime during deployment --- ## 2. Phase Breakdown ### 2.1 Phase 0: Assessment & Planning (Week 1) **Goal:** Understand current state, create detailed plan **Tasks:** 1. ✅ Create architecture documentation (ARCHITECTURE.md) 2. ✅ Create module dependency graph (DEPENDENCIES.md) 3. ✅ Create data flow diagrams (DATAFLOW.md) 4. ✅ Identify critical bugs (CRITICAL_BUGS.md) 5. ✅ Create performance baseline (PERFORMANCE_BASELINE.md) 6. ✅ Create execution plan (EXECUTION_PLAN.md) **Deliverables:** - ARCHITECTURE.md (completed) - DEPENDENCIES.md (completed) - DATAFLOW.md (completed) - CRITICAL_BUGS.md (completed) - PERFORMANCE_BASELINE.md (completed) - EXECUTION_PLAN.md (this document) **Estimated Effort:** 5 person-days **Status:** ✅ Complete --- ### 2.2 Phase 1: Critical Bug Fixes (Week 2-3) **Goal:** Fix all critical bugs to stabilize codebase **Tasks:** 1. Fix BUG-001: Race condition in tile loading - Add mutex to TileCache - Use Arc> for thread-safe access - Add tests for concurrent access - **Effort:** 2 days 2. Fix BUG-002: Memory leak in cache eviction - Free GPU resources on eviction - Add tests for memory cleanup - **Effort:** 1 day 3. Fix BUG-003: Missing error handling in HTTP requests - Add timeout to HTTP requests - Handle connection failures gracefully - Add tests for error scenarios - **Effort:** 2 days 4. Fix BUG-004: Integer overflow in tile coordinates - Use u64 for coordinate calculations - Add overflow checks - Add tests for edge cases - **Effort:** 1 day 5. Fix BUG-005: Use-after-free in geometry rendering - Add geometry validity checks - Use reference counting for geometry - Add tests for concurrent access - **Effort:** 2 days 6. Fix BUG-006: Deadlock in tile scheduler - Use lock ordering (scheduler before cache) - Add deadlock detection tests - **Effort:** 3 days 7. Fix BUG-007: Buffer overflow in MVT parser - Add bounds checking to all buffer accesses - Add fuzz tests for parser - **Effort:** 3 days 8. Fix BUG-008: Infinite loop in label placement - Add progress detection to placement algorithm - Add tests for pathological cases - **Effort:** 1 day 9. Fix BUG-009: Null pointer dereference in style application - Use Option