9.5 KiB
PHASE 2.7: CLEANUP & CONSOLIDATION PLAN
Project Context
Project: TrinityCore PlayerBot Module - Phase 2 Refactoring Branch: playerbot-dev Date: 2025-10-06 Status: Phase 2.1-2.6 Complete, Phase 2.7 In Progress
Completion Status
- Phase 2.1: BehaviorManager (COMPLETE)
- Phase 2.4: 4 Managers Refactored (COMPLETE)
- Phase 2.5: IdleStrategy Observer Pattern (COMPLETE)
- Phase 2.6: 53 Integration Tests (COMPLETE)
Objective
Remove all temporary debug logging, debug counters, and temporary documentation files to prepare the codebase for production deployment following CLAUDE.md quality requirements.
CLAUDE.md Compliance
- ✅ NO SHORTCUTS - Review every file completely
- ✅ COMPLETE CLEANUP - Remove all debug artifacts
- ✅ MAINTAIN QUALITY - Preserve important operational logging
- ✅ MODULE-ONLY - Only touch src/modules/Playerbot/ files
- ✅ TEST AFTER CLEANUP - Verify compilation
Codebase Analysis
Total Files: 614 C++ files in src/modules/Playerbot/
Total TODO Comments: 309 occurrences across 46 files
Comment Lines: 26,021 occurrences (includes copyright headers)
CATEGORY 1: Excessive Debug Logging
Files with TC_LOG_ERROR Debug Abuse
1.1 HIGH PRIORITY - Remove Debug Logging
File: src/modules/Playerbot/AI/Strategy/IdleStrategy.cpp
- Lines: 74-79, 94-98
- Issue: Using TC_LOG_ERROR for normal debug tracing with static counter
- Action: Remove debug counter and convert to TC_LOG_DEBUG
- Before:
static uint32 debugCounter = 0;
if (++debugCounter % 50 == 0)
{
TC_LOG_ERROR("module.playerbot", "🔎 IdleStrategy::IsActive() for bot {} - _active={}, hasGroup={}, result={}",
ai->GetBot()->GetName(), active, hasGroup, result);
}
- After:
// Remove entirely - normal operation, not an error
File: src/modules/Playerbot/scripts/PlayerbotWorldScript.cpp
- Lines: 24-27, 34-60, 63, 66
- Issue: "=== DEBUG:" logging throughout with TC_LOG_ERROR
- Action: Remove all "=== DEBUG:" logging and debugCounter
- Count: ~20 debug log statements to remove
File: src/modules/Playerbot/Account/BotAccountMgr.cpp
- Lines: 231, 727, 736, 748, 798, 825-826, 832
- Issue: "=== CLAUDE DEBUG:" logging for email generation
- Action: Remove all CLAUDE DEBUG logging
- Count: 8 debug log statements to remove
File: src/modules/Playerbot/Group/GroupInvitationHandler.cpp
- Lines: 795, 798, 802, 806, 814-817
- Issue: "FOLLOW FIX DEBUG PATH2:" logging
- Action: Remove debug path logging, keep normal operational logs
- Count: 7 debug log statements to remove
File: src/modules/Playerbot/Movement/LeaderFollowBehavior.cpp
- Lines: 179-180, 239-243, 313-318
- Issue: Emoji-heavy debug logging with TC_LOG_ERROR
- Action: Convert to TC_LOG_DEBUG, remove emojis, reduce frequency
- Count: ~10 debug log statements to clean
File: src/modules/Playerbot/PlayerbotModule.cpp
- Lines: 33, 152, 156, 159, 247-252
- Issue: "=== CLAUDE DEBUG:" logging
- Action: Remove CLAUDE DEBUG logs, keep important initialization logs
- Count: 6 debug log statements to remove
1.2 Logging Guidelines
KEEP:
- TC_LOG_INFO for important operational events (startup, shutdown, major state changes)
- TC_LOG_DEBUG for actual debugging (controlled by log level)
- TC_LOG_WARN for recoverable issues
- TC_LOG_ERROR for actual errors that require attention
REMOVE:
- TC_LOG_ERROR used for normal debug tracing
- Emoji-heavy logging (🔎, ===, 🎬, etc.)
- "DEBUG:", "CLAUDE DEBUG:", "EXECUTION MARKER:", etc.
- Static counter variables used only for debug frequency control
CATEGORY 2: Debug Counter Variables
Files with Debug Counters to Remove
| File | Variable | Lines | Purpose |
|---|---|---|---|
| BotAI.cpp | entryCounter | Various | Debug trace counter |
| BotAI.cpp | activeStrategiesDebugCounter | Various | Strategy debug counter |
| BotAI.cpp | debugStrategyCounter | Various | Strategy debug counter |
| IdleStrategy.cpp | debugCounter | 75, 94 | IsActive() frequency control |
| BotSpawner.cpp | updateCounter | Various | Update frequency logging |
| LeaderFollowBehavior.cpp | behaviorCounter | 313 | UpdateFollowBehavior frequency |
| PlayerbotWorldScript.cpp | debugCounter | 34 | OnUpdate debug counter |
| PlayerbotWorldScript.cpp | logCounter | 74 | Periodic logging counter |
| BotSession.cpp | debugUpdateCounter | Various | Session update counter |
| PlayerbotModuleAdapter.cpp | logCounter | Various | Module log counter |
Total Debug Counters: ~10 variables across 7 files
Action: Remove all static debug counter variables and their associated logging
CATEGORY 3: Temporary Documentation Files
Files to DELETE
AI_UPDATE_DEBUG_PATCH.txt
AI_UPDATE_ROOT_CAUSE_FOUND.md
CONFIG_FIX_VERIFICATION.md
HANDOVER.md (if temporary - verify first)
nul (empty file artifact)
Total: 4-5 temporary files
Files to KEEP
PHASE_2_1_COMPLETE.md
PHASE_2_2_COMPLETE.md
PHASE_2_3_COMPLETE.md
PHASE_2_4_COMPLETE.md
PHASE_2_5_COMPLETE.md
PHASE_2_6_INTEGRATION_TESTS_COMPLETE.md
PHASE_2_7_CLEANUP.md (planning docs)
PHASE_2_8_DOCUMENTATION.md
PLAYERBOT_REFACTORING_MASTER_PLAN.md
PLAYERBOT_ARCHITECTURE.md
PLAYERBOT_USER_GUIDE.md
... (all substantive documentation)
CATEGORY 4: TODO Comments Analysis
TODO Distribution (309 occurrences across 46 files)
High Priority TODOs (Legitimate future work):
- DemonHunter Specialization files: 53 TODOs each (106 total)
- InteractionManager files: 26 TODOs each (78 total)
- Various game systems: ~125 remaining
Action Strategy:
- KEEP all legitimate TODOs for future features
- REMOVE Phase 2 placeholder TODOs like:
- "TODO: Implement proper wandering" (if already done)
- "TODO: Add idle actions" (if already added)
- "TODO: Fix this debug code" (cleanup artifacts)
No mass TODO removal - Each TODO should be evaluated individually in future cleanup passes
CATEGORY 5: Commented Code
Commented Code Strategy
DO NOT perform automated commented code removal in this phase.
Future Manual Review Needed:
- Large blocks of commented implementation code
- Old algorithm alternatives
- Debug code sections
KEEP:
- Copyright headers (standard practice)
- Explanatory comments (documentation)
- Intentionally disabled features with explanation
CLEANUP EXECUTION PLAN
Phase 1: High-Priority Debug Log Removal (This Phase)
Files:
src/modules/Playerbot/AI/Strategy/IdleStrategy.cppsrc/modules/Playerbot/scripts/PlayerbotWorldScript.cppsrc/modules/Playerbot/Account/BotAccountMgr.cppsrc/modules/Playerbot/Group/GroupInvitationHandler.cppsrc/modules/Playerbot/Movement/LeaderFollowBehavior.cppsrc/modules/Playerbot/PlayerbotModule.cpp
Expected Impact:
- ~60 debug log statements removed
- ~10 debug counter variables removed
- ~200 lines of code removed
- Cleaner logs in production
Phase 2: Temporary Documentation Deletion
Files:
- Delete: AI_UPDATE_DEBUG_PATCH.txt
- Delete: AI_UPDATE_ROOT_CAUSE_FOUND.md
- Delete: CONFIG_FIX_VERIFICATION.md
- Delete: nul
- Verify HANDOVER.md (delete if temporary)
Phase 3: Compilation Verification
Steps:
- Build with CMake
- Verify no compilation errors
- Run integration tests from Phase 2.6
- Verify runtime behavior unchanged
SUCCESS CRITERIA
Quantitative Metrics
- Debug log statements removed: 60+
- Debug counter variables removed: 10
- Temporary files deleted: 4-5
- Lines of code removed: 200+
- Compilation: SUCCESS
- Tests passing: 53/53 integration tests
Qualitative Metrics
- No TC_LOG_ERROR for normal operations
- All remaining logs have clear purpose
- No debug counter variables
- Clean log output in production
- Documentation is substantive only
RISK ASSESSMENT
Low Risk Changes
- Removing debug log statements (no functional impact)
- Removing debug counter variables (only used for logging)
- Deleting temporary documentation files
Testing Required
- Compile verification
- Integration test pass
- Runtime log verification
Rollback Plan
- Git commit before cleanup
- Can revert if issues found
NEXT STEPS
Immediate (This Phase)
- Clean up 6 high-priority files
- Remove debug logging
- Delete temporary documentation
- Verify compilation
- Create PHASE_2_7_COMPLETE.md
Future Cleanup Phases
- Review remaining TODO comments (309 occurrences)
- Remove commented code blocks (manual review)
- Consolidate remaining debug counters
- Final production-ready polish
IMPLEMENTATION NOTES
Logging Conversion Examples
Before (Debug abuse):
TC_LOG_ERROR("module.playerbot", "=== DEBUG: Some trace message ===");
After (Proper level):
TC_LOG_DEBUG("module.playerbot", "Some trace message");
Before (Emoji abuse):
TC_LOG_ERROR("module.playerbot", "🔎🎬✅ Bot {} state={}", name, state);
After (Professional):
TC_LOG_DEBUG("module.playerbot", "Bot {} state={}", name, state);
Counter Removal Example
Before:
static uint32 debugCounter = 0;
if (++debugCounter % 100 == 0)
{
TC_LOG_ERROR("module.playerbot", "Debug trace #{}", debugCounter);
}
After:
// Remove entirely, or convert to proper debug logging if needed
TC_LOG_TRACE("module.playerbot", "Trace information");
DOCUMENT STATUS
- Version: 1.0
- Status: Planning Complete
- Next: Execute Phase 1 cleanup
- Author: Claude (Code Review AI)
- Date: 2025-10-06