feat(8.0)!: delete fork/branch/commit/history/versions — superseded by the Db API

The COW version-control surface (fork, branches, checkout, commit,
getHistory/streamHistory, asOfCommit, brain.versions) is gone, along with
its subsystems: src/versioning/, the COW object store (CommitLog,
CommitObject, RefManager, TreeObject), HistoricalStorageAdapter, and the
TypeAwareHNSWIndex path it kept alive. The Db API (now/transact/asOf/
with/persist/restore) is the one versioning model in 8.0.

Survivors and replacements:
- BlobStorage survives (the VFS stores file content through it), relocated
  to src/storage/blobStorage.ts with binaryDataCodec.ts; its adapter
  interface is now BlobStoreAdapter, slimmed to the consumed surface
  (write/read/has/delete/getMetadata + MIME-aware compression policy).
- brain.migrate() backup branches are replaced by persist-before-migrate:
  MigrateOptions.backupTo persists a hard-link snapshot of the current
  generation before any transform runs; MigrationResult.backupPath reports
  it, and brain.restore(path) brings it back wholesale.
- CLI: cow.ts (fork/branch/checkout/history/migrate) is replaced by
  snapshot.ts — snapshot <path>, restore <path>, history (tx-log),
  generation.
- New public read API: brain.transactionLog({limit}) exposes the reified
  tx-log (generation/timestamp/meta, newest first) that backs the CLI
  history command; TxLogEntry is exported.

Tests: superseded suites deleted; fork/commit blocks excised from shared
suites; BlobStorage tests relocated + reworked against the slimmed store;
migration tests now prove the backupTo snapshot/restore round trip; new
transactionLog coverage in db-mvcc.
This commit is contained in:
David Snelling 2026-06-10 15:22:47 -07:00
parent 431cd64406
commit 8f93add705
64 changed files with 1444 additions and 16313 deletions

View file

@ -104,8 +104,11 @@ export class VirtualFileSystem implements IVirtualFileSystem {
private get blobStorage() {
// TypeScript doesn't know about blobStorage on storage, use type assertion
const storage = this.brain['storage'] as any
if (!storage || !('blobStorage' in storage)) {
throw new Error('BlobStorage not available. Requires COW-enabled storage adapter.')
if (!storage?.blobStorage) {
throw new Error(
'BlobStorage not available. The storage adapter must run ' +
'initializeBlobStorage() before the VFS is used (brain.init() does this).'
)
}
return storage.blobStorage
}
@ -437,9 +440,13 @@ export class VirtualFileSystem implements IVirtualFileSystem {
existingId = null
}
// Detect MIME type BEFORE the blob write so the store's auto-compression
// policy can skip zstd for already-compressed media (JPEG, MP4, ZIP, …).
const mimeType = mimeDetector.detectMimeType(name, buffer)
// Unified blob storage for ALL files (no size-based branching)
// Store in BlobStorage (content-addressable, auto-deduplication, streaming)
const blobHash = await this.blobStorage.write(buffer)
// Store in BlobStorage (content-addressable, auto-deduplication)
const blobHash = await this.blobStorage.write(buffer, { mimeType })
// Get blob metadata (size, compression info)
const blobMetadata = await this.blobStorage.getMetadata(blobHash)
@ -448,12 +455,9 @@ export class VirtualFileSystem implements IVirtualFileSystem {
type: 'blob',
hash: blobHash,
size: buffer.length,
compressed: blobMetadata?.compressed
compressed: blobMetadata ? blobMetadata.compression !== 'none' : undefined
}
// Detect MIME type (using comprehensive MimeTypeDetector)
const mimeType = mimeDetector.detectMimeType(name, buffer)
// Create metadata
const metadata: VFSMetadata = {
path,
@ -2716,11 +2720,6 @@ export class VirtualFileSystem implements IVirtualFileSystem {
return results
}
/**
* Get all versions of a file (semantic versioning)
*/
createReadStream(path: string, options?: ReadStreamOptions): NodeJS.ReadableStream {
// Lazy import to avoid circular dependencies
const { VFSReadStream } = require('./streams/VFSReadStream.js')