claude-memory/graph/solutions/migration-script-default-to-named-graph-memory-transfer-5fb6b3.md
2026-03-01 16:17:24 -06:00

2.7 KiB

id type title tags importance confidence created updated relations
5fb6b3c0-cc6a-4baa-8552-8d2731379b0b solution Migration Script: Default-to-Named-Graph Memory Transfer
cognitive-memory
migration
multi-graph
python
script
solution
0.85 0.8 2026-03-01T22:16:44.476551+00:00 2026-03-01T22:17:24.844367+00:00
target type direction strength edge_id
b1ba1b27-d2bf-44f9-a1f5-0ace2017dc18 BUILDS_ON incoming 0.7 2adf60cc-84e8-4351-9ea0-1036983c39a1
target type direction strength edge_id
d0d1a325-a308-474a-baf7-6939a76a136b RELATED_TO outgoing 0.79 ac0d00ea-f279-49b5-b186-b8c3cc4deffe
target type direction strength edge_id
9eb16f9f-c825-4233-b64f-d0acd140374a RELATED_TO outgoing 0.78 8d2b6329-8e85-4620-be9b-88805105c047
target type direction strength edge_id
2d6f02bc-5a7c-404d-a566-36107aaaf6e6 RELATED_TO outgoing 0.95 98c0639e-a231-4e7c-bda6-42be7d45a091
target type direction strength edge_id
e301095c-7d4c-45d8-8352-9491e4ad6603 RELATED_TO incoming 0.9 1e0002c1-dc30-446e-bce3-f0a5e5b61663
target type direction strength edge_id
b1ba1b27-d2bf-44f9-a1f5-0ace2017dc18 FOLLOWS outgoing 0.9 19267562-3fd0-4213-987a-75bed0d644aa
target type direction strength edge_id
dc6b6c6f-1319-47cf-a691-dd40751ff121 FOLLOWS outgoing 0.85 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.