Memory files now reconcile to template, not just clean known fields: - normalize.py: rewrote from field-targeted cleanup to template-conformance — strips ANY key not in the template at every level (root/metadata/limits/status). Kills legacy orphans (old 'st' blocks, active_tasks, current_lines, max_lines) that field-targeted cleanup was blind to. Fixed _MEMORY_ROOT path (parents[3]) that silently skipped template loading in production. - memory_watcher.py: wired normalize_memory_file into both scan paths (check_and_rollover + on_modified) with a write-loop guard — drift now self-heals on every trigger, no manual run needed. - line_counter.py: stop writing current_lines (entry-count is the only metric). - LOCAL/OBSERVATIONS templates: removed line-count fields. Entry-count is the sole rollover metric, both files, all branches. 873 tests pass, seedgo 100%. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Tests
Pytest unit tests for MEMORY.
conftest.py— Shared fixtures (temp dirs, mocks, sample data).test_*.py— Test files. Standard tests cover JSON handler, CLI routing, and error resilience. Custom tests cover branch-specific domain logic.