feat: implement decision logging system with context snapshots #18

Merged
jihoson merged 2 commits from feature/issue-17-decision-logging into main 2026-02-04 15:54:11 +09:00
Collaborator

Summary

Implements comprehensive decision logging system for audit trail and evolution feedback (Issue #17).

  • Database schema with decision_logs table
  • DecisionLogger class with full CRUD operations
  • Automatic logging in main trading loop
  • 100% test coverage for decision_logger.py (9 new tests)
  • ⚠️ Context snapshot uses L1-L2 layers (L3-L7 pending Context Tree implementation in #15)

Changes

Database (src/db.py)

  • Add decision_logs table with comprehensive schema
  • Indexes on timestamp, reviewed status, and confidence
  • JSON storage for context_snapshot and input_data

Decision Logger (src/logging/decision_logger.py)

  • log_decision() - Store decisions with context
  • get_unreviewed_decisions() - Query high-confidence unreviewed decisions
  • mark_reviewed() - Update review status and notes
  • update_outcome() - Track P&L and accuracy
  • get_losing_decisions() - Find high-confidence losses for evolution
  • get_decision_by_id() - Retrieve specific decisions

Integration (src/main.py)

  • Initialize DecisionLogger in run() function
  • Log all decisions in trading_cycle()
  • Capture L1 (price, volume) and L2 (balance, P&L) context
  • Ready for L3-L7 integration when Context Tree is available

Tests (tests/test_decision_logger.py)

  • 9 comprehensive tests covering all methods
  • 100% coverage of decision_logger.py
  • All 63 tests passing

Test Plan

  • All existing tests pass (63/63)
  • New decision logger tests pass (9/9)
  • 100% coverage on decision_logger.py
  • Linting passes (ruff)
  • Type checking passes (mypy --strict)

Closes #17
Depends on #15 for full L1-L7 context tree integration.

## Summary Implements comprehensive decision logging system for audit trail and evolution feedback (Issue #17). - ✅ Database schema with decision_logs table - ✅ DecisionLogger class with full CRUD operations - ✅ Automatic logging in main trading loop - ✅ 100% test coverage for decision_logger.py (9 new tests) - ⚠️ Context snapshot uses L1-L2 layers (L3-L7 pending Context Tree implementation in #15) ## Changes ### Database (src/db.py) - Add decision_logs table with comprehensive schema - Indexes on timestamp, reviewed status, and confidence - JSON storage for context_snapshot and input_data ### Decision Logger (src/logging/decision_logger.py) - log_decision() - Store decisions with context - get_unreviewed_decisions() - Query high-confidence unreviewed decisions - mark_reviewed() - Update review status and notes - update_outcome() - Track P&L and accuracy - get_losing_decisions() - Find high-confidence losses for evolution - get_decision_by_id() - Retrieve specific decisions ### Integration (src/main.py) - Initialize DecisionLogger in run() function - Log all decisions in trading_cycle() - Capture L1 (price, volume) and L2 (balance, P&L) context - Ready for L3-L7 integration when Context Tree is available ### Tests (tests/test_decision_logger.py) - 9 comprehensive tests covering all methods - 100% coverage of decision_logger.py - All 63 tests passing ## Test Plan - All existing tests pass (63/63) - New decision logger tests pass (9/9) - 100% coverage on decision_logger.py - Linting passes (ruff) - Type checking passes (mypy --strict) ## Related Issues Closes #17 Depends on #15 for full L1-L7 context tree integration.
agentson added 2 commits 2026-02-04 15:47:14 +09:00
- Add decision_logs table to database schema
- Create decision logger module with comprehensive logging
- Prepare for decision tracking and audit trail

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
feat: integrate decision logger with main trading loop
Some checks failed
CI / test (pull_request) Has been cancelled
6eee11bb03
- Add DecisionLogger to main.py trading cycle
- Log all decisions with context snapshot (L1-L2 layers)
- Capture market data and balance info in context
- Add comprehensive tests (9 tests, 100% coverage)
- All tests passing (63 total)

Implements issue #17 acceptance criteria:
-  decision_logs table with proper schema
-  DecisionLogger class with all required methods
-  Automatic logging in trading loop
-  Tests achieve 100% coverage of decision_logger.py
- ⚠️  Context snapshot uses L1-L2 data (L3-L7 pending issue #15)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
agentson force-pushed feature/issue-17-decision-logging from 6eee11bb03 to 2f9efdad64 2026-02-04 15:48:04 +09:00 Compare
jihoson merged commit 2a80030ceb into main 2026-02-04 15:54:11 +09:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#18