Strategic Improvement
** sw-memory.sh is 2240 lines (2nd largest script after sw-loop.sh which has issue #779). Decompose into focused modules: lib/memory-capture.sh (failure pattern recording), lib/memory-query.sh (pattern retrieval), lib/memory-cleanup.sh (retention/archival), lib/cost-tracking.sh (budget/spend). Improves maintainability, testability, and follows AGI criterion of reducing monolithic structures.
Acceptance Criteria
- lib/memory-capture.sh created (<400 lines): capture_failure_pattern, emit_learning_event, validate_pattern
- lib/memory-query.sh created (<400 lines): query_patterns, find_similar_failures, get_success_rate
- lib/memory-cleanup.sh created (<300 lines): archive_old_patterns, enforce_retention, vacuum_db
- lib/cost-tracking.sh created (<400 lines): record_cost, check_budget, get_spending_report
- sw-memory.sh becomes thin router (<200 lines) sourcing libs
- All existing memory tests pass, add 20+ new tests for lib functions
- Backwards compatible: all CLI commands work unchanged
- Platform health next scan shows sw-memory.sh <300 lines
Context
- Priority: ** P6
- Complexity: ** standard
- Generated by: Strategic Intelligence Agent
- Strategy alignment: ** P6: Platform Self-Improvement (AGI-Level Readiness)
Strategic Improvement
** sw-memory.sh is 2240 lines (2nd largest script after sw-loop.sh which has issue #779). Decompose into focused modules: lib/memory-capture.sh (failure pattern recording), lib/memory-query.sh (pattern retrieval), lib/memory-cleanup.sh (retention/archival), lib/cost-tracking.sh (budget/spend). Improves maintainability, testability, and follows AGI criterion of reducing monolithic structures.
Acceptance Criteria
Context