MEDIUM: Remove dead/vestigial code modules #36

Open
opened 2026-02-20 14:46:56 +02:00 by Koko210 · 0 comments
Owner

Problem

Several modules contain dead code that adds maintenance burden, confuses new readers, and clutters the codebase:

1. bot/command_router.py (~30 lines) — Vestigial

Its only function returns mood state. ALL actual command routing happens in bot.py's on_message() handler. This module serves no purpose and is misleading (the name suggests it handles routing but it does not).

2. bot/utils/gpu_router.py (~180 lines) — Unused

Provides sophisticated GPU load-balancing utilities, but nothing in the codebase calls them. Actual GPU routing uses simpler inline functions in llm.py that read globals.PREFER_AMD_GPU directly. The entire module appears to be dead code.

3. bot/utils/context_manager.py — Dead response_type branching

Accepts a response_type parameter (e.g., 'dm_response', 'voice_response', 'autonomous') but returns IDENTICAL context for every type. The branching code is dead — every branch does the same thing. Either remove the parameter and simplify, or implement the intended differentiation.

4. bot/commands/actions.py (75 lines) — Deprecated but still called

All functions (set_mood, reset_mood, force_sleep, wake_up) log deprecation warnings, but are still actively imported and called by the autonomous system (bot/utils/autonomous.py). Either:

  • Remove the deprecation warnings since they're still in use
  • Or complete the migration to the new system and stop calling them

Proposed Solution

  1. Delete bot/command_router.py entirely; remove any imports
  2. Delete bot/utils/gpu_router.py; verify no imports exist
  3. Simplify context_manager.py: remove the response_type parameter and dead branches
  4. For actions.py: either remove deprecation warnings or complete the migration

Impact

  • Risk: Very Low (verify no imports before deleting)
  • Effort: Low (grep for imports, delete/simplify)
  • Benefit: Cleaner codebase, less confusion, fewer lines to maintain

Verification Steps

  • grep -r 'command_router' bot/ to find imports
  • grep -r 'gpu_router' bot/ to find imports
  • grep -r 'response_type' bot/ to audit usage
  • grep -r 'from commands.actions' bot/ to find callers
## Problem Several modules contain dead code that adds maintenance burden, confuses new readers, and clutters the codebase: ### 1. bot/command_router.py (~30 lines) — Vestigial Its only function returns mood state. ALL actual command routing happens in bot.py's on_message() handler. This module serves no purpose and is misleading (the name suggests it handles routing but it does not). ### 2. bot/utils/gpu_router.py (~180 lines) — Unused Provides sophisticated GPU load-balancing utilities, but nothing in the codebase calls them. Actual GPU routing uses simpler inline functions in llm.py that read globals.PREFER_AMD_GPU directly. The entire module appears to be dead code. ### 3. bot/utils/context_manager.py — Dead response_type branching Accepts a response_type parameter (e.g., 'dm_response', 'voice_response', 'autonomous') but returns IDENTICAL context for every type. The branching code is dead — every branch does the same thing. Either remove the parameter and simplify, or implement the intended differentiation. ### 4. bot/commands/actions.py (75 lines) — Deprecated but still called All functions (set_mood, reset_mood, force_sleep, wake_up) log deprecation warnings, but are still actively imported and called by the autonomous system (bot/utils/autonomous.py). Either: - Remove the deprecation warnings since they're still in use - Or complete the migration to the new system and stop calling them ## Proposed Solution 1. Delete bot/command_router.py entirely; remove any imports 2. Delete bot/utils/gpu_router.py; verify no imports exist 3. Simplify context_manager.py: remove the response_type parameter and dead branches 4. For actions.py: either remove deprecation warnings or complete the migration ## Impact - Risk: Very Low (verify no imports before deleting) - Effort: Low (grep for imports, delete/simplify) - Benefit: Cleaner codebase, less confusion, fewer lines to maintain ## Verification Steps - grep -r 'command_router' bot/ to find imports - grep -r 'gpu_router' bot/ to find imports - grep -r 'response_type' bot/ to audit usage - grep -r 'from commands.actions' bot/ to find callers
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Koko210/miku-discord#36