Repository navigation
fix: clone transcripts into the archive on APFS instead of copying - #196
Open
petrogurcak wants to merge 2 commits into
Open
petrogurcak wants to merge 2 commits into
petrogurcak wants to merge 2 commits into
Conversation
The archive mirrors every live transcript, so plain copies double their disk use (21 GB -> 42 GB on one machine). On APFS a clone shares blocks until either file changes, and the archive copy still survives when the harness deletes the original. Node cannot clone on macOS: COPYFILE_FICLONE silently falls back to a full copy and COPYFILE_FICLONE_FORCE throws ENOSYS (Node 24). cloneOrCopyFileSync uses `cp -c` (clonefile(2)) on darwin and falls back to fs.copyFileSync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MriYQJeeBh4Hb8g22gGuca
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MriYQJeeBh4Hb8g22gGuca
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
conversation-archivemirrors every live transcript in~/.claude/projects. While the original exists, the same bytes sit on disk twice. On my machine that was 21 GB + 21 GB, with the disk at 98 %.copyIfNeweralso re-copies active transcripts on every sync, so the cost grows with each session.Fix
cloneOrCopyFileSyncreplaces the fourfs.copyFileSynccalls (sync.tsand 3×indexer.ts). On macOS it clones withcp -c(clonefile(2)): the clone shares blocks with the original until either file changes, and it remains a separate, complete file when the harness later deletes the original. On other platforms, or if the clone fails (non-APFS volume), it falls back tofs.copyFileSync.Why not
fs.constants.COPYFILE_FICLONE: on macOS Node does not clone.COPYFILE_FICLONEsilently does a full copy andCOPYFILE_FICLONE_FORCEthrowsENOSYS(Node 24.7). Measured on a 1 GB file: Node FICLONE uses 1024 MB,cp -cuses ~4 MB.Verification
test/clone-copy.test.ts(4 tests). A mutation that drops thecp -ccall fails the test.syncarchived 41 transcripts with no errors. Replacing the existing duplicates with clones freed 22 GB.dist/mcp-server.jsis left out: it doesn't bundle these copy paths, and my local rebuild only produced unrelated bundler drift.🤖 Generated with Claude Code
https://claude.ai/code/session_01MriYQJeeBh4Hb8g22gGuca