# Implementation Plan: Logging Reorganization and Automated Pruning ## Phase 1: Session Organization & Registry Foundation - [ ] Task: Initialize MMA Environment (Protocol: `activate_skill mma-orchestrator`) - [ ] Task: Implement `LogRegistry` to manage `log_registry.toml` - [ ] Define TOML schema for session metadata. - [ ] Create methods to register sessions and update whitelist status. - [ ] Task: Implement Session-Based Directory Creation - [ ] Create utility to generate Session IDs: `YYYYMMDD_HHMMSS[_Label]`. - [ ] Update logging initialization to create and use session sub-directories. - [ ] Task: Conductor - User Manual Verification 'Phase 1: Foundation' (Protocol in workflow.md) ## Phase 2: Pruning Logic & Heuristics - [ ] Task: Implement `LogPruner` Core Logic - [ ] Implement time-based filtering (older than 24h). - [ ] Implement size-based heuristic for "insignificance" (~2 KB). - [ ] Task: Implement Auto-Whitelisting Heuristics - [ ] Implement content scanning for `ERROR`, `WARNING`, `EXCEPTION`. - [ ] Implement complexity detection (message count > 10). - [ ] Task: Integrate Pruning into App Startup - [ ] Hook the pruner into `gui_2.py` startup sequence. - [ ] Ensure pruning runs asynchronously to prevent startup lag. - [ ] Task: Conductor - User Manual Verification 'Phase 2: Pruning' (Protocol in workflow.md) ## Phase 3: GUI Integration & Manual Control - [ ] Task: Add "Log Management" UI Panel - [ ] Display a list of recent sessions from the registry. - [ ] Add "Star/Unstar" toggle for manual whitelisting. - [ ] Task: Display Session Metrics in UI - [ ] Show size, message count, and status (Whitelisted/Pending Prune). - [ ] Task: Conductor - User Manual Verification 'Phase 3: GUI' (Protocol in workflow.md) ## Phase 4: Final Verification & Cleanup - [ ] Task: Comprehensive Integration Testing - [ ] Verify that empty old logs are deleted. - [ ] Verify that complex/error-filled old logs are preserved. - [ ] Task: Final Refactoring and Documentation - [ ] Ensure all new classes and methods follow project style. - [ ] Task: Conductor - User Manual Verification 'Phase 4: Final' (Protocol in workflow.md)