# Legacy Code Analysis - Document Index This directory contains comprehensive analysis of legacy and dead code in the Mainline codebase. ## Quick Start **Start here:** [LEGACY_CLEANUP_CHECKLIST.md](./LEGACY_CLEANUP_CHECKLIST.md) This document provides step-by-step instructions for removing dead code in three phases: - **Phase 1**: Safe removals (~4,500 lines, zero risk) - **Phase 2**: Audit required (~14,000 lines) - **Phase 3**: Future migration plan ## Available Documents ### 1. LEGACY_CLEANUP_CHECKLIST.md (Action-Oriented) **Purpose**: Step-by-step cleanup procedures with verification commands **Contains**: - Phase 1: Safe deletions with verification commands - Phase 2: Audit procedures for display backends - Phase 3: Future removal planning - Testing procedures after cleanup - Rollback procedures **Start reading if you want to**: Execute cleanup immediately ### 2. LEGACY_CODE_ANALYSIS.md (Detailed Technical) **Purpose**: Comprehensive technical analysis with risk assessments **Contains**: - Executive summary - Marked deprecated modules (scroll.py, render.py, layers.py) - Completely unused modules (emitters.py, beautiful_mermaid.py, pipeline_viz.py) - Unused display backends - Test file analysis - Technical debt patterns - Cleanup strategy across 4 phases - Key metrics and statistics **Start reading if you want to**: Understand the technical details ## Key Findings Summary ### Dead Code Identified: ~9,000 lines #### Category 1: UNUSED (Safe to delete immediately) - **engine/emitters.py** (25 lines) - Unused Protocol definitions - **engine/beautiful_mermaid.py** (4,107 lines) - Unused Mermaid ASCII renderer - **engine/pipeline_viz.py** (364 lines) - Unused visualization module - **tests/test_emitters.py** - Orphaned test file **Total**: ~4,500 lines with ZERO risk #### Category 2: DEPRECATED BUT ACTIVE (Keep for now) - **engine/scroll.py** (156 lines) - Legacy rendering orchestration - **engine/render.py** (274 lines) - Legacy font/gradient rendering - **engine/layers.py** (272 lines) - Legacy layer/effect rendering **Total**: ~700 lines (still used for backwards compatibility) #### Category 3: QUESTIONABLE (Consider removing) - **engine/animation.py** (340 lines) - Unused animation system **Total**: ~340 lines (abandoned experimental code) #### Category 4: POTENTIALLY UNUSED (Requires audit) - **engine/display/backends/pygame.py** (9,185 bytes) - **engine/display/backends/kitty.py** (5,305 bytes) **Total**: ~14,000 bytes (check if presets use them) ## File Paths ### Recommended for Deletion (Phase 1) ``` /home/dietpi/src/Mainline/engine/emitters.py /home/dietpi/src/Mainline/engine/beautiful_mermaid.py /home/dietpi/src/Mainline/engine/pipeline_viz.py /home/dietpi/src/Mainline/tests/test_emitters.py ``` ### Keep for Now (Legacy Backwards Compatibility) ``` /home/dietpi/src/Mainline/engine/scroll.py /home/dietpi/src/Mainline/engine/render.py /home/dietpi/src/Mainline/engine/layers.py ``` ### Requires Audit (Phase 2) ``` /home/dietpi/src/Mainline/engine/display/backends/pygame.py /home/dietpi/src/Mainline/engine/display/backends/kitty.py ``` ## Recommended Reading Order 1. **First**: This file (overview) 2. **Then**: LEGACY_CLEANUP_CHECKLIST.md (if you want to act immediately) 3. **Or**: LEGACY_CODE_ANALYSIS.md (if you want to understand deeply) ## Key Statistics | Metric | Value | |--------|-------| | Total Dead Code | ~9,000 lines | | Safe to Remove (Phase 1) | ~4,500 lines | | Conditional Removals (Phase 2) | ~3,800 lines | | Legacy But Active (Phase 3) | ~700 lines | | Risk Level (Phase 1) | NONE | | Risk Level (Phase 2) | LOW | | Risk Level (Phase 3) | MEDIUM | ## Action Items ### Immediate (Phase 1 - 0 Risk) - [ ] Delete engine/emitters.py - [ ] Delete tests/test_emitters.py - [ ] Delete engine/beautiful_mermaid.py - [ ] Delete engine/pipeline_viz.py - [ ] Clean up pipeline.py introspection methods ### Short Term (Phase 2 - Low Risk) - [ ] Audit pygame backend usage - [ ] Audit kitty backend usage - [ ] Decide on animation.py ### Future (Phase 3 - Medium Risk) - [ ] Plan scroll.py migration - [ ] Consolidate render.py/layers.py - [ ] Deprecate legacy adapters ## How to Execute Cleanup See [LEGACY_CLEANUP_CHECKLIST.md](./LEGACY_CLEANUP_CHECKLIST.md) for: - Exact deletion commands - Verification procedures - Testing procedures - Rollback procedures ## Questions? Refer to the detailed analysis documents: - For specific module details: LEGACY_CODE_ANALYSIS.md - For how to delete: LEGACY_CLEANUP_CHECKLIST.md - For verification commands: LEGACY_CLEANUP_CHECKLIST.md (Phase 1 section) --- **Analysis Date**: March 16, 2026 **Codebase**: Mainline (Pipeline Architecture) **Legacy Code Found**: ~9,000 lines **Safe to Remove Now**: ~4,500 lines