--- 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:17:24.844367+00:00" relations: - target: b1ba1b27-d2bf-44f9-a1f5-0ace2017dc18 type: BUILDS_ON direction: incoming strength: 0.7 edge_id: 2adf60cc-84e8-4351-9ea0-1036983c39a1 - target: d0d1a325-a308-474a-baf7-6939a76a136b type: RELATED_TO direction: outgoing strength: 0.79 edge_id: ac0d00ea-f279-49b5-b186-b8c3cc4deffe - target: 9eb16f9f-c825-4233-b64f-d0acd140374a type: RELATED_TO direction: outgoing strength: 0.78 edge_id: 8d2b6329-8e85-4620-be9b-88805105c047 - target: 2d6f02bc-5a7c-404d-a566-36107aaaf6e6 type: RELATED_TO direction: outgoing strength: 0.95 edge_id: 98c0639e-a231-4e7c-bda6-42be7d45a091 - target: e301095c-7d4c-45d8-8352-9491e4ad6603 type: RELATED_TO direction: incoming strength: 0.9 edge_id: 1e0002c1-dc30-446e-bce3-f0a5e5b61663 - target: b1ba1b27-d2bf-44f9-a1f5-0ace2017dc18 type: FOLLOWS direction: outgoing strength: 0.9 edge_id: 19267562-3fd0-4213-987a-75bed0d644aa - target: dc6b6c6f-1319-47cf-a691-dd40751ff121 type: FOLLOWS direction: outgoing strength: 0.85 edge_id: 73c489ff-c7ae-4a73-9c8f-76b69b6ac4b2 --- # 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.