Skip to content

Split the sandfs library out of the command - #167

Merged
lydakis merged 2 commits into
mainfrom
claude/project-thread-wdmsae
Oct 26, 2026
Merged

lydakis merged 2 commits into
mainfrom
claude/project-thread-wdmsae

Conversation

@lydakis

@lydakis lydakis commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Everything the sandfs command does moves into a new sandfs crate with a typed API, so a program (Graft first) can mount, fork, list changes and update workspaces without sandfs installed. sandfs-cli becomes argument parsing and printing over it. Nothing changes for people running sandfs.

What moved

crates/sandfs-cli/src/{copy,fs,git,github,host,mcp,nfs,nfsserve,persist,server,shell,store,update} moved unchanged (git mv) to crates/sandfs/src/. The command logic that lived in the CLI's main.rs is now crates/sandfs/src/ops.rs, returning values instead of printing. main.rs keeps clap and the output formats.

Public API (core API change)

sandfs::handle_relaunch(prefix: &[&str])      // first thing in main

impl sandfs::Home {
    fn locate() -> Result<Home>;               // $SANDFS_HOME, XDG, ~/.local/share/sandfs
    fn at(root: impl AsRef<Path>) -> Result<Home>;  // a home of the program's choosing
    fn root(&self) -> &Path;
    fn find(&self, workspace: &str) -> Result<String>;
    fn mount(&self, source: &str, dir: &Path, &MountOptions) -> Result<Mounted>;
    fn fork(&self, from: &str, dir: Option<&Path>, &ForkOptions) -> Result<Forked>;
    fn changes(&self, workspace: &str, &ChangesOptions) -> Result<Changes>;
    fn update(&self, workspace: &str, source: Option<&str>) -> Result<Updated>;
    fn workspaces(&self) -> Result<Vec<WorkspaceInfo>>;
    fn unmount(&self, workspace: &str) -> Result<()>;
    fn remove(&self, name: &str, unmount: bool) -> Result<()>;
    fn clean(&self) -> Result<Vec<Cleaned>>;
    fn serve_mcp(&self, workspace: &str, &ServeOptions) -> Result<()>;
    fn shell(&self, workspace: &str, network: bool, command: &[OsString]) -> Result<i32>;
}

Options (all Default): MountOptions { name, read_only, foreground }, ForkOptions { name, read_only, branch, foreground }, ChangesOptions { paths, since, copy_to, force }, ServeOptions { name, read_only }.
Results: Mounted { name, dir }, Forked { name, from, dir }, Changes { changes: Vec<Change { kind, path }>, held_back, git_settings }, Updated, WorkspaceInfo { name, source, mounted }, Cleaned { repository, outcome: Deleted | Shrunk | Kept }, and ChangeKind re-exported from sandfs-core.

Running the program again

sandfs used to run sandfs daemon, sandfs shell-exec and sandfs git-fsmonitor (hidden commands) to serve mounts, confine a shell on macOS and answer git's file monitor. It now runs the current program with the embedder's prefix first: sandfs passes &[], so its commands are unchanged; Graft passes &["sandfs"] and gets run as gft sandfs daemon --serve. handle_relaunch serves those runs and exits, or returns. The git fsmonitor hook written into git mounts carries the prefix words too. Both the mount process and the hook are given SANDFS_HOME, so a home from Home::at reaches them.

Checks

  • cargo fmt --check, workspace clippy -D warnings (also --no-default-features and aarch64-apple-darwin), cargo doc, cargo package -p sandfs.
  • cargo test -p sandfs -p sandfs-cli: 122 unit, 15 CLI, 34 mount tests, 1 doctest.
  • crates/sandfs/examples/embed.rs is a program with its own commands that mounts a fork of a folder, writes to it, lists changes and deletes it; run on Linux, its mount was served by embed sandfs daemon --serve.
  • Build sandfs in: no sandfs to install graft#4 builds on this branch and passes its whole workflow with no sandfs installed.

CI runs -p sandfs in clippy, tests and the no-default-features build; release.yml's nfsserve license path follows the move. Changelog has an Unreleased entry.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CboUL9BU7nvDEZKfQBSkkq

Everything the command does moves into a new `sandfs` crate with a typed API
(`sandfs::Home` and its methods), so programs can mount, fork, list changes and
update workspaces without running `sandfs`. sandfs-cli becomes argument parsing
and printing over it. A program that embeds sandfs calls
`sandfs::handle_relaunch(prefix)` first in `main`, and sandfs runs it again,
with that prefix, to serve mounts, answer git's file monitor and confine shells.
Nothing changes for `sandfs` users.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01CboUL9BU7nvDEZKfQBSkkq
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T03:15:25.294121Z 1de05f7 New commits
🔒 Security Review ✅ Completed 2026-10-26T03:17:32.849156Z 1de05f7 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lydakis
lydakis merged commit 3fefc8a into main Oct 26, 2026
23 checks passed
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.

2 participants