Important
PREVIEW ONLY This package is provided as a preview for feedback only. APIs are unstable and the design is subject to change.
Suitable for experiments, exploration and prototypes. It is NOT suitable for production use at this time.
The specification under docs/ is forward-looking — read it for
intent, not as description of the code today.
Durable Object SQLite-backed virtual filesystem for Cloudflare Workspace.
This package exposes a JavaScript module, not a CLI. It bundles three layers that can be used independently:
- A
Databasewrapper around Durable Object SQL storage plusinitializeSchemafor thevfs_*tables. - Filesystem primitives under
src/fs/*(mkdir,writeFile,readFile,rm,readdir,stat,lstat,chmod,find,ls,grep,symlink,readlink,gc,watch) operating on aDatabase. SQLiteWorkspaceProvider, a@platformatic/vfsadapter that composes those primitives into a node-shaped filesystem (fd table, positionalreadSync/writeSync,watchSync, symlinks). This is whatwsdmounts via FUSE.- Sync protocol building blocks operating on the same
Database:applyChanges,stageBlob,materialiseChange,coalesceChanges,fetchChanges,fetchObjects,hasObjects,pushObjects,buildManifest,currentRev,compareChangeCursors,readWatermark/writeWatermark,assertAppliedPushCursor, andDEFAULT_IGNORE/isIgnored. The wire wiring lives in@cloudflare/workspace-rpc.
Minimal DO-side usage — initialize the schema; the Database becomes the handle every other helper takes:
import { Database, initializeSchema } from "@cloudflare/dofs";
export class WorkspaceDO extends DurableObject {
private readonly db: Database;
constructor(ctx: DurableObjectState, env: Env) {
super(ctx, env);
this.db = new Database(ctx.storage);
initializeSchema(this.db, Date.now);
}
}The
src/fs/*primitives (mkdir,writeFile,readFile,rm,readdir,stat,find,ls,grep,symlink,readlink,gc,watch) are not re-exported from the package root yet — they are consumed in-tree bySQLiteWorkspaceProviderand by the syncapplyChangespath. On the node side, instantiateSQLiteWorkspaceProvider(the@platformatic/vfsadapter) for a familiar node:fs-shaped surface; this is what@cloudflare/workspace-wsdmounts via FUSE. A higher-level DO-sideWorkspaceclass with thefs/shell/push/pullsurface described in../../docs/README.mdis still future work.
Databasewrapper around Durable Object SQL storage in place.- Schema initialization for the documented
vfs_*tables (FS and sync) implemented and split intoschema/core.ts+schema/sync.ts. incrementRev()shared sequencer in place. FS writes stamp the returned value intovfs_nodes.revand pass it tosync/changes.tsfor tombstones.SQLiteTestStorage(backed bynode:sqlite) available from./testingfor unit tests against a real in-memory database;RecordingStorageavailable from the package root for workerd-safe schema assertions.- All filesystem primitives listed above are implemented and unit-tested.
SQLiteWorkspaceProvider(the@platformatic/vfsadapter) implemented and exported from the package entrypoint; consumed by@cloudflare/workspace-wsd.- Buffered-write surface for the FUSE driver:
createFileSync,writeRangeSync,truncateFileSync,readRangeSync,chmodSync,openWriteBufferSync,openWriteBufferForCreateSync, andreleaseWriteBufferSyncon the provider. The driver opens a buffer on FUSE create/open, mutates it through subsequent writes and truncates, and commits chunks in one transaction at release time. Reads against the same database see the buffered bytes immediately. - Content-addressed blob cache:
readFile,readRangeSync,provider.readFileSync, and the partial-chunk read-modify-write helper share a per-DatabaseLRU keyed byvfs_blob_bytes.hash. Repeated reads of dedup'd chunks (a file of zeroes, a re-used package payload) skip SQLite after the first fetch. - Sync protocol building blocks implemented and exported; the typed RPC surface on top of them lives in
@cloudflare/workspace-rpc.