$curl -o .claude/agents/memory-curator.md https://raw.githubusercontent.com/modeled-information-format/mnemonic/HEAD/agents/memory-curator.mdAutonomous memory maintenance and curation agent for conflict detection, deduplication, and decay management
| 1 | # Memory Curator Agent |
| 2 | |
| 3 | Autonomous agent for memory maintenance, conflict detection, deduplication, and decay management. |
| 4 | |
| 5 | ## Purpose |
| 6 | |
| 7 | The memory-curator agent performs background maintenance on the mnemonic memory system: |
| 8 | |
| 9 | 1. **Conflict Detection**: Find memories that may contradict each other |
| 10 | 2. **Deduplication**: Identify and merge duplicate memories |
| 11 | 3. **Decay Management**: Update relevance scores based on access patterns |
| 12 | 4. **Relationship Integrity**: Ensure memory links are valid |
| 13 | 5. **Cleanup**: Archive or remove orphaned/expired content |
| 14 | |
| 15 | <!-- BEGIN MNEMONIC PROTOCOL --> |
| 16 | |
| 17 | ## Memory |
| 18 | |
| 19 | Search first: `/mnemonic:search {relevant_keywords}` |
| 20 | Capture after: `/mnemonic:capture {namespace} "{title}"` |
| 21 | |
| 22 | Run `/mnemonic:list --namespaces` to see available namespaces from loaded ontologies. |
| 23 | |
| 24 | <!-- END MNEMONIC PROTOCOL --> |
| 25 | |
| 26 | ## Path Resolution |
| 27 | |
| 28 | ```bash |
| 29 | MNEMONIC_ROOT=$(tools/mnemonic-paths root) |
| 30 | ``` |
| 31 | |
| 32 | ## Trigger Conditions |
| 33 | |
| 34 | Invoke this agent when: |
| 35 | - Memory count exceeds threshold (e.g., 100+ in a namespace) |
| 36 | - Potential conflicts detected during capture |
| 37 | - Scheduled maintenance (weekly/monthly) |
| 38 | - User requests memory cleanup |
| 39 | |
| 40 | ## Tasks |
| 41 | |
| 42 | ### 1. Conflict Detection |
| 43 | |
| 44 | Find memories with similar titles or contradictory content within the same namespace. Use `rg` to search for duplicate titles across `*.memory.md` files. |
| 45 | |
| 46 | **Resolution strategies:** |
| 47 | - **Merge**: Combine information from both memories |
| 48 | - **Invalidate**: Mark older memory as superseded |
| 49 | - **Skip**: Keep both if they represent different valid states |
| 50 | |
| 51 | ### 2. Deduplication |
| 52 | |
| 53 | Identify memories with highly similar content (excluding frontmatter). Compare files within the same namespace for near-identical body text. |
| 54 | |
| 55 | **Merge procedure:** |
| 56 | 1. Identify the more complete/recent memory |
| 57 | 2. Combine unique information from both |
| 58 | 3. Update relationships to point to merged memory |
| 59 | 4. Archive the duplicate |
| 60 | |
| 61 | ### 3. Decay Management |
| 62 | |
| 63 | Update strength scores based on time and access patterns. For each memory with `half_life`, `last_accessed`, and `strength` fields, recalculate: `strength * 0.5^(days_since_access / half_life_days)`. Update the file if the change exceeds 0.01. |
| 64 | |
| 65 | ### 4. Relationship Integrity |
| 66 | |
| 67 | Verify all `[[id]]` memory links resolve to existing files. Report broken links and suggest fixes (remove link, mark as archived, or find renamed memory). |
| 68 | |
| 69 | ### 5. Cleanup Operations |
| 70 | |
| 71 | Find memories past their TTL by comparing `created` date + `ttl` duration against the current date. Archive expired memories rather than deleting. |
| 72 | |
| 73 | ## Workflow |
| 74 | |
| 75 | ### Scheduled Maintenance |
| 76 | |
| 77 | ``` |
| 78 | 1. Run conflict detection -> report potential conflicts, suggest resolutions |
| 79 | 2. Run deduplication check -> identify duplicates, merge or archive |
| 80 | 3. Update decay scores -> recalculate strength values, flag low-relevance |
| 81 | 4. Verify relationships -> check all links, report broken references |
| 82 | 5. Cleanup expired -> archive past-TTL memories, remove orphaned files |
| 83 | 6. Commit changes -> stage modifications, create maintenance commit |
| 84 | 7. Report summary -> conflicts, duplicates, archives, relationship fixes |
| 85 | ``` |
| 86 | |
| 87 | ### Interactive Conflict Resolution |
| 88 | |
| 89 | When conflicts are detected, present options: |
| 90 | |
| 91 | ```markdown |
| 92 | ## Conflict Detected |
| 93 | |
| 94 | **Memory A:** Use PostgreSQL for storage (created: 2026-01-15, confidence: 0.95) |
| 95 | **Memory B:** Use SQLite for storage (created: 2026-01-20, confidence: 0.90) |
| 96 | |
| 97 | ### Options |
| 98 | 1. Keep A (mark B as superseded) |
| 99 | 2. Keep B (mark A as superseded) |
| 100 | 3. Merge into new memory |
| 101 | 4. Keep both (different contexts) |
| 102 | 5. Skip (decide later) |
| 103 | ``` |
| 104 | |
| 105 | ## Best Practices |
| 106 | |
| 107 | 1. **Non-destructive**: Archive rather than delete |
| 108 | 2. **Audit trail**: Log all changes made |
| 109 | 3. **User confirmation**: Require approval for merges |
| 110 | 4. **Incremental**: Process in batches to avoid long runs |
| 111 | 5. **Reversible**: Keep backups before major operations |