feat(memsync): key memory sync by project fingerprint, not local path#5
Open
mja00 wants to merge 1 commit into
Open
feat(memsync): key memory sync by project fingerprint, not local path#5mja00 wants to merge 1 commit into
mja00 wants to merge 1 commit into
Conversation
Mirror directories are now keyed by a machine-independent fingerprint (normalized git remote URL, then root-commit SHA, then the path fallback for non-git dirs) instead of Claude's path-derived directory name, so the same repo checked out at different paths on different machines syncs and merges. Real project paths are recovered from the cwd in Claude's session transcripts, and a per-PC .state/index.json maps localHash to key. Legacy path-keyed layouts auto-migrate on upgrade, union-merging collisions. The foreground daemon now logs startup and sync activity so it no longer looks hung.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
claude-memsynckeyed the sync repo by Claude's per-project directory name, which is the project's absolute path with separators replaced by dashes (-Users-me-code-foo). That name differs per machine, so a repo checked out at/Users/me/code/fooon one machine and/home/me/repos/fooon another was seen as two separate projects and their memories never merged. This was previously documented as the "same paths required" limitation.Solution
Key the mirror by a machine-independent fingerprint instead of the local path:
g-<hash>— normalizedoriginremote URL (all ofgit@github.com:Acme/app.git,https://github.com/acme/app,…/app.gitcollapse to one key)r-<hash>— git root-commit SHA, when the repo has no remote (with a shallow-clone guard)The Claude side stays keyed by its local dir name; a new
internal/projectpackage resolves each project's real path from thecwdClaude records in its session transcripts, derives the key, and keeps a per-PC~/.claudesync/.state/index.json(gitignored) mapping localHash ↔ key. Reconcile/copy/remove and inbound propagation are now key-addressed. Projects synced from another machine but not yet opened locally materialize lazily on first open.Migration: the first run after upgrading auto-migrates existing path-keyed mirror dirs to fingerprint keys, union-merging any that collapse to the same key via the existing
claude-memmergedriver. Both machines must be upgraded for a project's divergent histories to converge. This is a pre-1.0 on-disk layout change → minor version bump.Also: the foreground
rundaemon now logs startup and sync activity — previously it was silent, which read as a hang.Verification
go build ./... && go vet ./... && gofmt -l . && go test ./...all cleang-key with a unionedMEMORY.md; a legacy path-keyed remote dir migrates and merges on upgrade