From 507154f88d5210c0628f5a06f1fa2b14b7fd471d Mon Sep 17 00:00:00 2001 From: Ed_ Date: Thu, 26 Feb 2026 09:32:19 -0500 Subject: [PATCH] chore(conductor): Archive completed track 'Review logging' --- .../logging_refactor_20260226/index.md | 0 .../logging_refactor_20260226/metadata.json | 0 .../archive/logging_refactor_20260226/plan.md | 39 +++++++ .../logging_refactor_20260226/spec.md | 0 conductor/tracks.md | 5 - .../tracks/logging_refactor_20260226/plan.md | 39 ------- tests/test_log_management_ui.py | 109 ++++++++++++++++++ 7 files changed, 148 insertions(+), 44 deletions(-) rename conductor/{tracks => archive}/logging_refactor_20260226/index.md (100%) rename conductor/{tracks => archive}/logging_refactor_20260226/metadata.json (100%) create mode 100644 conductor/archive/logging_refactor_20260226/plan.md rename conductor/{tracks => archive}/logging_refactor_20260226/spec.md (100%) delete mode 100644 conductor/tracks/logging_refactor_20260226/plan.md create mode 100644 tests/test_log_management_ui.py diff --git a/conductor/tracks/logging_refactor_20260226/index.md b/conductor/archive/logging_refactor_20260226/index.md similarity index 100% rename from conductor/tracks/logging_refactor_20260226/index.md rename to conductor/archive/logging_refactor_20260226/index.md diff --git a/conductor/tracks/logging_refactor_20260226/metadata.json b/conductor/archive/logging_refactor_20260226/metadata.json similarity index 100% rename from conductor/tracks/logging_refactor_20260226/metadata.json rename to conductor/archive/logging_refactor_20260226/metadata.json diff --git a/conductor/archive/logging_refactor_20260226/plan.md b/conductor/archive/logging_refactor_20260226/plan.md new file mode 100644 index 0000000..f3eaad3 --- /dev/null +++ b/conductor/archive/logging_refactor_20260226/plan.md @@ -0,0 +1,39 @@ +# Implementation Plan: Logging Reorganization and Automated Pruning + +## Phase 1: Session Organization & Registry Foundation +- [x] Task: Initialize MMA Environment (Protocol: `activate_skill mma-orchestrator`) [9a66b76] +- [x] Task: Implement `LogRegistry` to manage `log_registry.toml` [10fbfd0] + - [x] Define TOML schema for session metadata. + - [x] Create methods to register sessions and update whitelist status. +- [x] Task: Implement Session-Based Directory Creation [3f4dc1a] + - [x] Create utility to generate Session IDs: `YYYYMMDD_HHMMSS[_Label]`. + - [x] Update logging initialization to create and use session sub-directories. +- [x] Task: Conductor - User Manual Verification 'Phase 1: Foundation' (Protocol in workflow.md) [3f4dc1a] + +## Phase 2: Pruning Logic & Heuristics +- [x] Task: Implement `LogPruner` Core Logic [bd2a79c] + - [x] Implement time-based filtering (older than 24h). + - [x] Implement size-based heuristic for "insignificance" (~2 KB). +- [x] Task: Implement Auto-Whitelisting Heuristics [4e9c47f] + - [x] Implement content scanning for `ERROR`, `WARNING`, `EXCEPTION`. + - [x] Implement complexity detection (message count > 10). +- [x] Task: Integrate Pruning into App Startup [8b75883] + - [x] Hook the pruner into `gui_2.py` startup sequence. + - [x] Ensure pruning runs asynchronously to prevent startup lag. +- [x] Task: Conductor - User Manual Verification 'Phase 2: Pruning' (Protocol in workflow.md) [8b75883] + +## Phase 3: GUI Integration & Manual Control +- [x] Task: Add "Log Management" UI Panel [7d52123] + - [x] Display a list of recent sessions from the registry. + - [x] Add "Star/Unstar" toggle for manual whitelisting. +- [x] Task: Display Session Metrics in UI [7d52123] + - [x] Show size, message count, and status (Whitelisted/Pending Prune). +- [x] Task: Conductor - User Manual Verification 'Phase 3: GUI' (Protocol in workflow.md) [7d52123] + +## Phase 4: Final Verification & Cleanup +- [x] Task: Comprehensive Integration Testing [23c0f0a] + - [x] Verify that empty old logs are deleted. + - [x] Verify that complex/error-filled old logs are preserved. +- [x] Task: Final Refactoring and Documentation [04a991e] + - [x] Ensure all new classes and methods follow project style. +- [x] Task: Conductor - User Manual Verification 'Phase 4: Final' (Protocol in workflow.md) [04a991e] diff --git a/conductor/tracks/logging_refactor_20260226/spec.md b/conductor/archive/logging_refactor_20260226/spec.md similarity index 100% rename from conductor/tracks/logging_refactor_20260226/spec.md rename to conductor/archive/logging_refactor_20260226/spec.md diff --git a/conductor/tracks.md b/conductor/tracks.md index a5ce908..d68de94 100644 --- a/conductor/tracks.md +++ b/conductor/tracks.md @@ -40,8 +40,3 @@ This file tracks all major tracks for the project. Each track has its own detail --- -- [x] **Track: Review logging used throughout the project. THe log directory has several categories of logs and they are getting quite large in number. We need sub-directoreis and we need a way to prune logs that aren't valuable to keep.** -*Link: [./tracks/logging_refactor_20260226/](./tracks/logging_refactor_20260226/)* - ---- - diff --git a/conductor/tracks/logging_refactor_20260226/plan.md b/conductor/tracks/logging_refactor_20260226/plan.md deleted file mode 100644 index bd818bd..0000000 --- a/conductor/tracks/logging_refactor_20260226/plan.md +++ /dev/null @@ -1,39 +0,0 @@ -# Implementation Plan: Logging Reorganization and Automated Pruning - -## Phase 1: Session Organization & Registry Foundation -- [x] Task: Initialize MMA Environment (Protocol: `activate_skill mma-orchestrator`) [9a66b76] -- [x] Task: Implement `LogRegistry` to manage `log_registry.toml` [10fbfd0] - - [ ] Define TOML schema for session metadata. - - [ ] Create methods to register sessions and update whitelist status. -- [x] Task: Implement Session-Based Directory Creation [3f4dc1a] - - [ ] Create utility to generate Session IDs: `YYYYMMDD_HHMMSS[_Label]`. - - [ ] Update logging initialization to create and use session sub-directories. -- [x] Task: Conductor - User Manual Verification 'Phase 1: Foundation' (Protocol in workflow.md) [3f4dc1a] - -## Phase 2: Pruning Logic & Heuristics -- [x] Task: Implement `LogPruner` Core Logic [bd2a79c] - - [ ] 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) diff --git a/tests/test_log_management_ui.py b/tests/test_log_management_ui.py new file mode 100644 index 0000000..4b53504 --- /dev/null +++ b/tests/test_log_management_ui.py @@ -0,0 +1,109 @@ + +import pytest +from unittest.mock import MagicMock, patch +import os +from pathlib import Path + +# Mock imgui and other heavy dependencies before importing App +import sys +sys.modules['imgui_bundle'] = MagicMock() +sys.modules['imgui_bundle.imgui'] = MagicMock() +sys.modules['imgui_bundle.hello_imgui'] = MagicMock() +sys.modules['imgui_bundle.immapp'] = MagicMock() + +# Mock tkinter +sys.modules['tkinter'] = MagicMock() +sys.modules['tkinter.filedialog'] = MagicMock() + +# Mock ai_client and session_logger +sys.modules['ai_client'] = MagicMock() +sys.modules['session_logger'] = MagicMock() + +from gui_2 import App + +@pytest.fixture +def mock_config(tmp_path): + config_path = tmp_path / "config.toml" + config_path.write_text("[projects] +paths = [] +active = "" +[ai] +provider = "gemini" +model = "model" +", encoding="utf-8") + return config_path + +@pytest.fixture +def mock_project(tmp_path): + project_path = tmp_path / "project.toml" + project_path.write_text("[project] +name = "test" +[discussion] +roles = ["User", "AI"] +active = "main" +[discussion.discussions.main] +history = [] +", encoding="utf-8") + return project_path + +def test_log_management_init(mock_config, mock_project, monkeypatch): + monkeypatch.setattr("gui_2.CONFIG_PATH", mock_config) + + with patch("project_manager.load_project") as mock_load: + mock_load.return_value = { + "project": {"name": "test"}, + "discussion": {"roles": ["User", "AI"], "active": "main", "discussions": {"main": {"history": []}}}, + "files": {"paths": []}, + "screenshots": {"paths": []} + } + with patch("session_logger.open_session"): + app = App() + + # Check if Log Management is in show_windows + assert "Log Management" in app.show_windows + assert app.show_windows["Log Management"] is False # Default as set in __init__ + + # Check if _render_log_management exists + assert hasattr(app, "_render_log_management") + assert callable(app._render_log_management) + +def test_render_log_management_logic(mock_config, mock_project, monkeypatch): + monkeypatch.setattr("gui_2.CONFIG_PATH", mock_config) + + with patch("project_manager.load_project") as mock_load: + mock_load.return_value = { + "project": {"name": "test"}, + "discussion": {"roles": ["User", "AI"], "active": "main", "discussions": {"main": {"history": []}}}, + "files": {"paths": []}, + "screenshots": {"paths": []} + } + with patch("session_logger.open_session"): + app = App() + app.show_windows["Log Management"] = True + + from imgui_bundle import imgui + + # Mock LogRegistry + with patch("gui_2.LogRegistry") as MockRegistry: + mock_reg = MockRegistry.return_value + mock_reg.data = { + "session_1": { + "start_time": "2023-01-01", + "whitelisted": False, + "metadata": {"reason": "test", "size_kb": 10, "message_count": 5} + } + } + + # Mock imgui.begin to return (True, True) + imgui.begin.return_value = (True, True) + imgui.begin_table.return_value = True + + # Call render + app._render_log_management() + + # Verify imgui calls + imgui.begin.assert_called_with("Log Management", True) + imgui.begin_table.assert_called() + + # Check for "session_1" text + imgui.text.assert_any_call("session_1")