fix(files): make generate export atomic at the directory level#167
Merged
Conversation
FileSystem::export_to_filesystem now stages the entire export tree in a sibling temporary directory and publishes it via a single atomic directory rename, instead of writing files directly into the target. A process interrupted mid-generate can no longer leave a partially written server directory (e.g. an index.ts re-exporting a tool file that was never written), since the target is left exactly as it was until every file has landed in staging. Also sweeps orphaned staging/displaced directories left behind by a killed prior run so they no longer accumulate indefinitely, and drops ExportOptions.overwrite, which had no production callers and only complicated the staging model. Closes #159
bug-ops
enabled auto-merge (squash)
July 9, 2026 18:52
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.
Summary
FileSystem::export_to_filesystemnow stages the entire export tree in a sibling temporary directory and publishes it via a single atomic directory rename, instead of writing files directly into the target directory.generate(e.g. killed) can no longer leave a partially written~/.claude/servers/{id}/directory — such as anindex.tsre-exporting a tool file that was never actually written, with zero detection outside theskillcode path.ExportOptions.overwrite, which had no production callers and only complicated the staging model with subtly-differentfs::copysemantics.Closes #159
Test plan
cargo +nightly fmt --checkcargo +stable clippy --all-targets --all-features --workspace -- -D warningscargo nextest run --all-features --workspace --no-fail-fast(729 passed)cargo test --doc --all-features --workspaceRUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspacecargo bench --no-run --profile bench-fast -p mcp-execution-files