Skip to content

[REFACTOR] applyMigration helper split + non-canonical-file copy#10

Open
gradyzhuo wants to merge 1 commit into
mainfrom
feat/memory-migration-helpers
Open

[REFACTOR] applyMigration helper split + non-canonical-file copy#10
gradyzhuo wants to merge 1 commit into
mainfrom
feat/memory-migration-helpers

Conversation

@gradyzhuo
Copy link
Copy Markdown
Member

Summary

Splits the memory-migration logic into smaller, documented helpers and expands what gets carried across when an env's memory dir is migrated between shared and isolated layouts.

  • applyMigration now walks every entry under sourceDir:
    • MEMORY.md is special-cased — wrapped as a fragment via the new writeMigrationFragment so the agent picks it up on the next orrery_memory_read and consolidates it without clobbering dest's MEMORY.md.
    • Everything else (user-curated .md files, subdirectories, existing fragments) is copied with skip-existing semantics so dest's existing files are never overwritten.
  • writeMigrationFragment records the source content as a migrate-action fragment with id/peer/timestamp/action frontmatter under destDir/fragments/.
  • copyTreeSkipExisting recursively copies a tree while preserving destination collisions.
  • Source dir is left untouched (non-destructive, reversible if user switches back).

Test plan

  • swift test143 tests pass (134 baseline + 9 new in MemoryMigrationTests):
    • merge=false is a no-op
    • MEMORY.md from source becomes a fragment in dest
    • Non-canonical .md files copy to dest when missing
    • Existing dest files preserved on collision
    • Subdirectories recursively migrated
    • Existing fragments preserved (skip-existing on fragments dir)

🤖 Generated with Claude Code

Factors the memory-migration logic into smaller, doc-commented helpers:
- `applyMigration` now walks every entry under sourceDir, special-casing
  MEMORY.md (wrapped as a fragment via the new `writeMigrationFragment`)
  and copying everything else with skip-existing semantics.
- New `writeMigrationFragment` records the source content as a migrate-
  action fragment under destDir/fragments/.
- New `copyTreeSkipExisting` recursively copies a tree while preserving
  any pre-existing destination files.

Adds MemoryMigrationTests covering: merge=false no-op, MEMORY.md becomes
a fragment, non-canonical files copy when missing, and existing files
preserved on collision.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant