Skip to content

Python bindings for a general-purpose sandbox filesystem - #23

Merged
lydakis merged 9 commits into
mainfrom
claude/sandfs-review-modernize-i0v7lr
Oct 18, 2026
Merged

lydakis merged 9 commits into
mainfrom
claude/sandfs-review-modernize-i0v7lr

Conversation

@lydakis

@lydakis lydakis commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Before: the sandfs Python package was the 0.3 design (bash-like shell, host bridge, Python executor, adapters, policies), and the Rust core was shaped around code: git mounts as the headline, exact-string edits, symlinks, diff().

After: sandfs is a thin PyO3 binding over the Rust core, built with maturin as abi3 wheels. The core is a sandbox filesystem for files of any kind, with code as one use case. A harness mounts any data as a source, forks a workspace per attempt in O(1), and reads back which files changed.

base = sandfs.Workspace()
base.mount("/reports", sandfs.DirSource("./reports"))
base.mount("/tickets", MyApiSource())          # any object with list(path) and read(path)
attempt = base.fork()
attempt.write("/reports/chart.png", png_bytes)
attempt.changes()                              # [Change(path='/reports/chart.png', kind='added')]

How:

  • Bindings (crates/sandfs-py):
    • Workspace.mount(path, source) accepts DirSource, MemorySource, GitSource, or a Python object implementing the sandfs.Source protocol (list(path) -> Iterable[DirEntry], read(path) -> bytes | str).
    • Core errors map to built-in exceptions, plus VersionMismatch.
    • Every core call releases the GIL. A Python source takes the GIL back only while its own code runs.
  • Core API changes (these affect the MCP and CLI PRs):
    • Workspace::diff is renamed Workspace::changes, and the module diff.rs is now change.rs.
    • Removed Workspace::edit, edit_versioned, Edit and Error::EditFailed. Text edits belong in the MCP crate, built from read and write_versioned.
    • Removed Kind::Symlink, symlink, read_link and link following. DirSource and GitSource skip symlinks.
    • Metadata.size is now a u64. stat reads a file once when its source left the size out, so FUSE can report every size.
    • MemorySource::insert(path, data, executable: bool).
  • Git stays as the optional sandfs-git source crate.
  • Removed: the whole 0.3 Python package and its tests.
  • Release: wheels go through PyO3/maturin-action for Linux, macOS and Windows, plus an sdist and trusted publishing. Every action in the release workflow is pinned to a full commit SHA.
  • Docs: README, roadmap and AGENTS.md are rewritten for the general-purpose framing.

Tests: cargo test --workspace and uv run pytest. The new tests cover Python sources (laziness, a cache shared across forks, errors, threads), binary files, sources that leave sizes out, and skipped symlinks.

🤖 Generated with Claude Code

https://claude.ai/code/session_011n3CeYLRrtNT8XX5NMX8iB

sandfs.Workspace wraps sandfs-core through a PyO3 extension (crates/sandfs-py)
built by maturin: git, host-directory and in-memory mounts, fork, diff, reads,
writes with expected_version, exact-string edits, and file operations. Core
errors map to built-in exceptions, plus VersionMismatch and EditFailed. Reads
release the GIL so git fetches don't block other threads.

The release workflow now builds abi3 wheels for Linux, macOS and Windows plus
an sdist; CI installs a Rust toolchain before building the package.

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

chatgpt-codex-connector Bot commented Oct 18, 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-18T21:18:10.632522Z d6979e8 New commits
🔒 Security Review ✅ Completed 2026-10-18T21:19:08.830494Z d6979e8 New commits

Security findings

Advisory findings (1)

ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2b566b8fc9

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/sandfs-py/src/lib.rs Resolved
Comment thread crates/sandfs-py/src/lib.rs Resolved
Comment thread crates/sandfs-py/src/lib.rs Resolved
The package is now only the Workspace bindings. The shell, host bridge,
Python executor, policies, storage adapters, hooks, search index and CLI
are dropped along with their tests, as planned in the roadmap; 0.3 stays
in git history. README, AGENTS.md and the package metadata describe the
three primitives instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_011n3CeYLRrtNT8XX5NMX8iB
@lydakis lydakis changed the title Add Python bindings for the Rust workspace core Replace the Python package with bindings for the Rust workspace core Oct 18, 2026

lydakis commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

@codex review

This PR now also removes the 0.3 pure-Python modules (6d4bb2f), so please review the current head.


Generated by Claude Code

…edits

Add Workspace::edit_versioned to the core so the version guard is checked
against the file an edit actually changes, after following a final symlink.
The Python binding uses it inside py.detach, since editing an unread git file
can fetch it from a remote. Workspace.move's docstring now says the
destination must not exist, which is what the core does.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_011n3CeYLRrtNT8XX5NMX8iB
@lydakis lydakis mentioned this pull request Oct 18, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 21403e4a9d

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/sandfs-py/src/lib.rs Resolved
Writes, mkdir, symlink, remove, copy, move and mount can all resolve a
symlink or list a directory from a source, and a git source may fetch from
a remote, so none of them should hold the GIL.

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a2537cb28

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/sandfs-py/src/lib.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 208171c904

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread .github/workflows/release.yml Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 208171c904

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pyproject.toml Resolved
Comment thread crates/sandfs-py/src/lib.rs Resolved
Comment thread sandfs/_core.pyi Resolved
sandfs is for files of any kind, and code is one use case. The core keeps
the three primitives and drops what only code needed:

- Sources are open: Workspace.mount(path, source) takes DirSource,
  MemorySource, GitSource or any Python object with list(path) and
  read(path). mount_git, mount_dir and mount_files are gone.
- Exact-string edits leave the core (Workspace::edit, edit_versioned,
  Edit, Error::EditFailed); the MCP crate builds them from read and a
  versioned write.
- Symlinks are gone (Kind::Symlink, symlink, read_link, link following).
  DirSource and GitSource skip them.
- stat always returns a size, reading the file once when a source left
  it out, so a FUSE mount can report every file's size.
- The git source stays as an optional source crate.

Tests: cargo test --workspace, uv run pytest (Python sources, binary
files, unsized sources, skipped symlinks).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_011n3CeYLRrtNT8XX5NMX8iB
@lydakis lydakis changed the title Replace the Python package with bindings for the Rust workspace core Python bindings for a general-purpose sandbox filesystem Oct 18, 2026
"Diff" is code vocabulary, and the call returns changed files, not a
patch. Workspace::diff becomes Workspace::changes in the core and the
Python bindings; the core module diff.rs becomes change.rs.

Tests: cargo test --workspace, uv run pytest.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_011n3CeYLRrtNT8XX5NMX8iB
The release workflow publishes with PyPI trusted publishing, so every
action in it is pinned to a reviewed commit instead of a moving tag.
MemorySource construction now runs with the GIL released like the other
source constructors, and its stub asks for the dict the binding accepts.

Tests: uv run pytest, cargo test --workspace.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_011n3CeYLRrtNT8XX5NMX8iB
@lydakis
lydakis merged commit 4058651 into main Oct 18, 2026
6 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