35 lines
1.5 KiB
Markdown
35 lines
1.5 KiB
Markdown
---
|
|
id: 5fb6b3c0-cc6a-4baa-8552-8d2731379b0b
|
|
type: solution
|
|
title: "Migration Script: Default-to-Named-Graph Memory Transfer"
|
|
tags: [cognitive-memory, migration, multi-graph, python, script, solution]
|
|
importance: 0.85
|
|
confidence: 0.8
|
|
created: "2026-03-01T22:16:44.476551+00:00"
|
|
updated: "2026-03-01T22:16:44.476551+00:00"
|
|
---
|
|
|
|
# Memory Migration Script: Default to Named Project Graphs
|
|
|
|
## Location
|
|
`/mnt/NV2/Development/cognitive-memory/scripts/migrate-memories.py`
|
|
|
|
## Problem
|
|
Memories accumulated in the default cognitive-memory graph without project-level separation. Needed a way to migrate them into named project graphs based on tag matching.
|
|
|
|
## Solution
|
|
Standalone Python script (`migrate-memories.py`) that migrates memories from the default cognitive-memory graph to named project graphs.
|
|
|
|
### Key Features
|
|
- **Tag-based classification**: routes memories to target graphs by matching tags
|
|
- **Flags**: `--dry-run`, `--no-git`, `--cleanup-overlaps`
|
|
- **File operations**: moves/copies `.md` files, updates `_index.json`, `_embeddings.json`, `_state.json` in both source and target
|
|
- **Edge handling**: classifies edges as migrate vs orphan, strips cross-graph edge references from frontmatter
|
|
- **Overlap detection**: memories tagged for multiple projects are COPIED (not moved) to each target graph; tracked in `_migration_overlaps.json`
|
|
- **Idempotent**: safe to re-run
|
|
- **Atomic JSON writes**: via `tempfile + os.replace()`
|
|
- **Git auto-commit**: commits changes after successful migration
|
|
|
|
## Git Commit
|
|
Committed as `11a046f`, closes Gitea issues #4, #5, #6.
|