Skip to content

[FEAT] back SpaceDO filesystem with Cloudflare Artifacts#405

Merged
karishnu merged 3 commits into
stagingfrom
feat/artifacts-filesystem
Jul 22, 2026
Merged

[FEAT] back SpaceDO filesystem with Cloudflare Artifacts#405
karishnu merged 3 commits into
stagingfrom
feat/artifacts-filesystem

Conversation

@karishnu

@karishnu karishnu commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

SpaceDO gives each app an isolated, git-backed workspace running entirely on the Workers runtime. Previously, the workspace depended on Durable Object-local filesystem state, with no durable remote source of truth for an app’s committed history.

This PR makes Cloudflare Artifacts the durable, git-compatible source of truth for each app while preserving SpaceDO’s existing filesystem API.

How it works

The Artifacts-backed filesystem implements the same FileSystem interface used by the rest of SpaceDO. It combines:

  • Writable overlay: An in-memory filesystem containing active edits, hydrated files, and local git objects.
  • Base snapshot: A read-only index of the current Artifacts branch.
  • Whiteouts: Tombstones that prevent deleted base files from reappearing.
flowchart LR
  A[Artifacts repository] -->|fetch branch| B[Local git object store]
  B --> C[Read-only base index]
  C -->|hydrate on demand| D[Writable in-memory overlay]
  D -->|commit and push| A
Loading

Reads and hydration

Point reads first check the writable overlay. If a file exists only in the base snapshot, its blob is read from the local git object store and hydrated into the overlay.

Deleted base files remain hidden through whiteouts.

The filesystem provides two readiness levels:

  • ready() ensures the Artifacts snapshot is loaded and indexed.
  • whenFullyMaterialized() hydrates every visible base file into the overlay.

Full materialization happens before whole-tree operations such as commits, deploys, rollbacks, recursive listings, searches, and workspace statistics.

Writes and deletes

  • Writes and edits are applied to the overlay.
  • Writing a previously deleted path clears its whiteout.
  • Deleting a base file records a whiteout.
  • Directory deletion and moves whiteout all affected base descendants.
  • Copy and move operations hydrate base-only sources before modifying them.

Cold-start recovery

The live filesystem and local git repository are in memory. When a SpaceDO instance starts:

  1. It restores the app’s persisted Artifacts remote URL from Durable Object storage.
  2. It fetches the app’s branch into the in-memory git repository.
  3. It walks the fetched commit tree to rebuild the base index.
  4. It hydrates files into the working tree as they are accessed.

An Artifacts repository with no commits is valid and represents an empty base. Until the first commit, the filesystem behaves as a normal writable in-memory workspace.

Artifacts synchronization

Artifacts synchronization manages repository provisioning, authentication, fetches, and pushes.

This PR improves synchronization reliability through:

  • Durable remote discovery: The Artifacts remote URL is persisted in Durable Object storage and reused after cold starts.
  • Serialized pushes: Concurrent commits and deploys within one SpaceDO cannot race each other.
  • Bounded retries: Stale-ref and concurrent-update failures are retried with backoff.
  • Token refresh: Write tokens are cached and refreshed before expiration.
  • Best-effort failure handling: Sync errors are logged and returned as failures instead of causing commit or deployment RPCs to throw.

ARTIFACTS is a required binding. There is no local-only git fallback.

Local development and tests must provide an ARTIFACTS binding.

Commit, deploy, preview, and rollback

  • Commit: Materializes the complete tree, creates a git commit, and mirrors the branch to Artifacts.
  • Deploy: Builds from the complete overlay-aware filesystem before pushing the commit.
  • Preview: Uses the correct filesystem when assembling deployment files, including files restored from Artifacts.
  • Rollback: Fetches Artifacts before resolving the target commit, allowing rollback even when the current SpaceDO has never held that commit locally.
  • Internal paths: /.git and /.afs are excluded from user-visible listings, deployment bundles, and rollback trees.

Editor synchronization fixes

This PR also fixes live editor updates emitted by the Think agent:

  • Generated file contents now appear when selected. File updates use the slash-stripped paths expected by the UI, such as src/App.tsx.
  • Deleted files disappear immediately. Deletes emit a dedicated file_deleted WebSocket message instead of an empty file write.
  • Commit and rollback updates refresh editor state. The editor file tree remains consistent with the restored workspace.

@ask-bonk

ask-bonk Bot commented Jul 16, 2026

Copy link
Copy Markdown

Model not found: cloudflare-ai-gateway/google-ai-studio/gemini-3-pro-preview. Did you mean: openai/o3-pro, workers-ai/@cf/google/gemma-3-12b-it, anthropic/claude-3-5-haiku?

github run

@ask-bonk

ask-bonk Bot commented Jul 16, 2026

Copy link
Copy Markdown

@karishnu Bonk workflow failed. Check the logs for details.

View workflow run · To retry, trigger Bonk again.

@karishnu
karishnu force-pushed the feat/artifacts-filesystem branch from a596bbc to 1a5823f Compare July 17, 2026 09:33
@ask-bonk

ask-bonk Bot commented Jul 17, 2026

Copy link
Copy Markdown

Model not found: cloudflare-ai-gateway/google-ai-studio/gemini-3-pro-preview. Did you mean: openai/o3-pro, workers-ai/@cf/google/gemma-3-12b-it, anthropic/claude-3-5-haiku?

github run

@ask-bonk

ask-bonk Bot commented Jul 17, 2026

Copy link
Copy Markdown

Model not found: cloudflare-ai-gateway/google-ai-studio/gemini-3-pro-preview. Did you mean: openai/o3-pro, workers-ai/@cf/google/gemma-3-12b-it, anthropic/claude-3-5-haiku?

github run

karishnu added 3 commits July 20, 2026 16:13
Add ArtifactsFileSystem, an overlay FileSystem over WorkspaceFileSystem with an Artifacts branch as read-only base. Hybrid hydration: instant index, on-demand + eager blob materialization, whiteout tombstones.

Route all SpaceDO file reads/writes/deletes/mkdir/patch through this.fs; gate commit/deploy/rollback on full materialization; exclude /.git and /.afs from deploy bundles and rollback trees.

Add git-objects.ts (iso-git object plumbing) and artifacts-sync.ts (push/fetch); remove superseded git-pack.ts and git-smart-http.ts.

Add a shared FileSystem + git-on-FS contract suite run against WorkspaceFileSystem and ArtifactsFileSystem via an FsHarnessDO test binding.
- Make ARTIFACTS mandatory in SpaceDO; drop the local-only overlay fallback and require a base source in ArtifactsFileSystem (empty base still supported).

- Mirror think file writes under slash-stripped paths so content shows on click in the editor pane.

- Add end-to-end file_deleted websocket message and stop treating delete as a write tool, so deleted files are removed from the file list live.
@karishnu
karishnu force-pushed the feat/artifacts-filesystem branch from 82c72e3 to f7e3123 Compare July 22, 2026 08:04
@ask-bonk

ask-bonk Bot commented Jul 22, 2026

Copy link
Copy Markdown

Model not found: cloudflare-ai-gateway/google-ai-studio/gemini-3-pro-preview. Did you mean: openai/o3-pro, workers-ai/@cf/google/gemma-3-12b-it, anthropic/claude-3-5-haiku?

github run

@karishnu karishnu changed the title [FEAT][WIP] back SpaceDO filesystem with Cloudflare Artifacts [FEAT] back SpaceDO filesystem with Cloudflare Artifacts Jul 22, 2026
@karishnu
karishnu changed the base branch from feat/reasoning-trace-ui to staging July 22, 2026 08:19
@karishnu
karishnu merged commit 16d53b2 into staging Jul 22, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant