docs(8.0): consistency-model concept + snapshots guide — Db API replaces branching docs

This commit is contained in:
David Snelling 2026-06-11 08:37:26 -07:00
parent e5feae4104
commit cc8037db10
23 changed files with 1053 additions and 1871 deletions

View file

@ -142,26 +142,30 @@ await brain.init() // Required!
await brain.vfs.writeFile(...) // Now this works
```
## Fork Support
## Snapshot Support
VFS works seamlessly with Brainy's Copy-on-Write (COW) fork feature:
VFS files are ordinary entities, so they participate fully in the 8.0 Db
API: a persisted snapshot contains every VFS file, and a snapshot opened
with `Brainy.load()` serves VFS reads at the snapshot's state:
```javascript
const brain = new Brainy({ storage: { type: 'memory' } })
const brain = new Brainy({ storage: { type: 'filesystem', rootDirectory: './data' } })
await brain.init()
// Create files in parent
// Create files
await brain.vfs.writeFile('/config.json', '{"version": 1}')
// Fork inherits parent's files
const fork = await brain.fork('experiment')
const files = await fork.vfs.readdir('/') // Sees parent's config.json!
// Snapshot the whole store (VFS files included)
const pin = brain.now()
await pin.persist('/backups/with-vfs')
await pin.release()
// Fork modifications are isolated
await fork.vfs.writeFile('/test.txt', 'Fork only')
await brain.vfs.readdir('/') // Parent doesn't see test.txt
// Later changes never touch the snapshot
await brain.vfs.writeFile('/config.json', '{"version": 2}')
```
See [Snapshots & Time Travel](../guides/snapshots-and-time-travel.md).
## FAQ
### Q: Do I need to call `vfs.init()` anymore?
@ -177,7 +181,7 @@ await brain.vfs.readdir('/') // Parent doesn't see test.txt
**A:** Yes, VFS configuration is passed through `brain.init()` config. The VFS-specific options are applied during auto-initialization.
### Q: Does this work with all storage adapters?
**A:** Yes! VFS auto-initialization works with all storage adapters: Memory, FileSystem, OPFS, S3, R2, Azure Blob, and Google Cloud Storage.
**A:** Yes! VFS auto-initialization works with both shipped adapters (FileSystem and Memory) and any plugin-provided storage adapter.
### Q: What if I need multiple VFS instances?
**A:** Each Brainy instance has its own VFS. Create multiple Brainy instances if you need multiple VFS instances.
@ -187,4 +191,4 @@ await brain.vfs.readdir('/') // Parent doesn't see test.txt
- [VFS Quick Start](./QUICK_START.md) - 5-minute setup guide
- [VFS API Guide](./VFS_API_GUIDE.md) - Complete API reference
- [Common Patterns](./COMMON_PATTERNS.md) - Best practices and patterns
- [Instant Fork](../features/instant-fork.md) - VFS + Copy-on-Write
- [Snapshots & Time Travel](../guides/snapshots-and-time-travel.md) - Backups and point-in-time reads