# Tasks: Configurable Belief State Logging **Spec**: `specs/006-configurable-belief-logs/spec.md` **Plan**: `specs/006-configurable-belief-logs/plan.md` **Status**: Completed ## Phase 1: Setup *Goal: Initialize project structure for logging.* - [x] T001 Ensure logs directory exists at `logs/` (relative to project root) ## Phase 2: Foundational *Goal: Define data models and infrastructure required for logging configuration.* - [x] T002 Define `LoggingConfig` model in `backend/src/core/config_models.py` - [x] T003 Update `GlobalSettings` model to include `logging` field in `backend/src/core/config_models.py` - [x] T004 Update `ConfigManager` to handle logging configuration persistence in `backend/src/core/config_manager.py` ## Phase 3: User Story 1 - Structured Belief State Logging *Goal: Implement the core "Belief State" logging logic with context managers.* *Priority: P1* **Independent Test**: Run `pytest backend/tests/test_logger.py` and verify `belief_scope` generates `[ID][Entry]`, `[ID][Action]`, and `[ID][Exit]` logs. - [x] T005 [US1] Create unit tests for belief state logging in `backend/tests/test_logger.py` - [x] T006 [US1] Implement `belief_scope` context manager in `backend/src/core/logger.py` - [x] T007 [US1] Implement log formatting and smart filtering (suppress Entry/Exit if disabled) in `backend/src/core/logger.py` ## Phase 4: User Story 2 - Configurable Logging Settings *Goal: Expose logging configuration to the user via API and UI.* *Priority: P2* **Independent Test**: Update settings via API/UI and verify log level changes (e.g., DEBUG logs appear) and file rotation is active. - [x] T008 [US2] Implement `configure_logger` function to apply settings (level, file, rotation) in `backend/src/core/logger.py` - [x] T009 [US2] Update settings API endpoint to handle `logging` updates in `backend/src/api/routes/settings.py` - [x] T010 [P] [US2] Add Logging configuration section (Level, File Path, Enable Belief State) to `frontend/src/pages/Settings.svelte` ## Final Phase: Polish & Cross-Cutting Concerns *Goal: Verify system stability and cleanup.* - [x] T011 Verify log rotation works by generating dummy logs (manual verification) - [x] T012 Ensure default configuration provides a sensible out-of-the-box experience ## Dependencies ```mermaid graph TD Setup[Phase 1: Setup] --> Foundational[Phase 2: Foundational] Foundational --> US1[Phase 3: US1 Belief State] US1 --> US2[Phase 4: US2 Configurable Settings] US2 --> Polish[Final Phase: Polish] ``` ## Parallel Execution Opportunities - **US2**: Frontend task (T010) can be implemented in parallel with Backend tasks (T008, T009) once the API contract is finalized. ## Implementation Strategy 1. **MVP**: Complete Phase 1, 2, and 3 to enable structured logging for the agent. 2. **Full Feature**: Complete Phase 4 to allow users to control the verbosity and storage.