Files
Mainline/docs/LEGACY_CODE_INDEX.md
David Gwilliam 5762d5e845 refactor(cleanup): Remove 4,500 lines of dead code (Phase 1 legacy cleanup)
- Delete engine/emitters.py (25 lines, unused Protocol definitions)
- Delete engine/beautiful_mermaid.py (4,107 lines, unused Mermaid ASCII renderer)
- Delete engine/pipeline_viz.py (364 lines, unused visualization module)
- Delete tests/test_emitters.py (orphaned test file)
- Remove introspect_pipeline_viz() method and references from engine/pipeline.py
- Add comprehensive legacy code analysis documentation in docs/

Phase 1 of legacy code cleanup: 0 risk, 100% safe to remove.
All tests pass (521 passing tests, 9 fewer due to test_emitters.py removal).
No regressions or breaking changes.
2026-03-16 20:33:04 -07:00

4.7 KiB

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

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

/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
  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 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