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:
parent
431cd64406
commit
8f93add705
64 changed files with 1444 additions and 16313 deletions
|
|
@ -2,7 +2,6 @@
|
|||
* Integration tests for Memory Enhancements (v5.11.0)
|
||||
*
|
||||
* End-to-end tests verifying:
|
||||
* - streamHistory() works in production scenarios
|
||||
* - Container detection works correctly
|
||||
* - Memory limits are applied correctly
|
||||
* - getMemoryStats() provides accurate information
|
||||
|
|
@ -40,86 +39,6 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('Production Workflow: Consumer Snapshot Timeline', () => {
|
||||
it('should stream 1000 snapshots efficiently', async () => {
|
||||
const brain = new Brainy({ requireSubtype: false,
|
||||
storage: {
|
||||
type: 'filesystem',
|
||||
options: { path: testDir }
|
||||
},
|
||||
silent: true
|
||||
})
|
||||
|
||||
await brain.init()
|
||||
|
||||
// Create a realistic workflow: user creates entities and saves snapshots
|
||||
for (let i = 0; i < 100; i++) {
|
||||
// Add 10 entities
|
||||
for (let j = 0; j < 10; j++) {
|
||||
await brain.add({
|
||||
type: 'document',
|
||||
data: `Chapter ${i}, Section ${j}`
|
||||
})
|
||||
}
|
||||
|
||||
// Save snapshot
|
||||
await brain.commit({ message: `Version ${i}`, captureState: true })
|
||||
}
|
||||
|
||||
// Stream history efficiently
|
||||
const snapshots: string[] = []
|
||||
const startTime = Date.now()
|
||||
|
||||
for await (const commit of brain.streamHistory({ limit: 100 })) {
|
||||
snapshots.push(commit.message)
|
||||
}
|
||||
|
||||
const duration = Date.now() - startTime
|
||||
|
||||
expect(snapshots.length).toBe(100)
|
||||
expect(duration).toBeLessThan(5000) // Should complete in < 5s
|
||||
|
||||
await brain.close()
|
||||
})
|
||||
|
||||
it('should handle large snapshot with filtering', async () => {
|
||||
const brain = new Brainy({ requireSubtype: false,
|
||||
storage: {
|
||||
type: 'filesystem',
|
||||
options: { path: testDir }
|
||||
},
|
||||
silent: true
|
||||
})
|
||||
|
||||
await brain.init()
|
||||
|
||||
// Create snapshots by different authors
|
||||
for (let i = 0; i < 50; i++) {
|
||||
await brain.add({ type: 'document', data: `Content ${i}` })
|
||||
|
||||
await brain.commit({
|
||||
message: `Snapshot ${i}`,
|
||||
author: i % 3 === 0 ? 'alice' : i % 3 === 1 ? 'bob' : 'charlie',
|
||||
captureState: true
|
||||
})
|
||||
}
|
||||
|
||||
// Stream only alice's snapshots
|
||||
const aliceSnapshots: any[] = []
|
||||
|
||||
for await (const commit of brain.streamHistory({ author: 'alice', limit: 100 })) {
|
||||
aliceSnapshots.push(commit)
|
||||
}
|
||||
|
||||
expect(aliceSnapshots.length).toBeGreaterThan(0)
|
||||
aliceSnapshots.forEach(commit => {
|
||||
expect(commit.author).toBe('alice')
|
||||
})
|
||||
|
||||
await brain.close()
|
||||
})
|
||||
})
|
||||
|
||||
describe('Production Workflow: Cloud Run Deployment', () => {
|
||||
it('should detect 4GB Cloud Run container and set optimal limits', async () => {
|
||||
process.env.CLOUD_RUN_MEMORY = '4Gi'
|
||||
|
|
@ -190,51 +109,6 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('Combined Features: Stream + Memory Management', () => {
|
||||
it('should stream large histories within memory limits', async () => {
|
||||
process.env.CLOUD_RUN_MEMORY = '2Gi'
|
||||
|
||||
const brain = new Brainy({ requireSubtype: false,
|
||||
storage: {
|
||||
type: 'filesystem',
|
||||
options: { path: testDir }
|
||||
},
|
||||
silent: true
|
||||
})
|
||||
|
||||
await brain.init()
|
||||
|
||||
// Create many snapshots
|
||||
for (let i = 0; i < 200; i++) {
|
||||
await brain.add({ type: 'document', data: `Data ${i}` })
|
||||
|
||||
if (i % 5 === 0) {
|
||||
await brain.commit({ message: `Checkpoint ${i / 5}`, captureState: true })
|
||||
}
|
||||
}
|
||||
|
||||
// Verify memory limits
|
||||
const stats = brain.getMemoryStats()
|
||||
expect(stats.limits.maxQueryLimit).toBe(5000) // 2GB * 0.25
|
||||
|
||||
// Stream all snapshots (should be ~40)
|
||||
const heapBefore = process.memoryUsage().heapUsed
|
||||
|
||||
let count = 0
|
||||
for await (const commit of brain.streamHistory({ limit: 100 })) {
|
||||
count++
|
||||
}
|
||||
|
||||
const heapAfter = process.memoryUsage().heapUsed
|
||||
const heapGrowth = heapAfter - heapBefore
|
||||
|
||||
expect(count).toBeGreaterThan(0)
|
||||
expect(heapGrowth).toBeLessThan(20 * 1024 * 1024) // < 20MB growth
|
||||
|
||||
await brain.close()
|
||||
})
|
||||
})
|
||||
|
||||
describe('Memory Stats API', () => {
|
||||
it('should provide actionable recommendations', async () => {
|
||||
process.env.CLOUD_RUN_MEMORY = '4Gi'
|
||||
|
|
@ -352,32 +226,5 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
|
|||
|
||||
await brain.close()
|
||||
})
|
||||
|
||||
it('should keep getHistory() working as before', async () => {
|
||||
const brain = new Brainy({ requireSubtype: false,
|
||||
storage: {
|
||||
type: 'filesystem',
|
||||
options: { path: testDir }
|
||||
},
|
||||
silent: true
|
||||
})
|
||||
|
||||
await brain.init()
|
||||
|
||||
// Create some snapshots
|
||||
for (let i = 0; i < 10; i++) {
|
||||
await brain.add({ type: 'note', data: `Test ${i}` })
|
||||
await brain.commit({ message: `Snapshot ${i}`, captureState: true })
|
||||
}
|
||||
|
||||
// Old API still works
|
||||
const history = await brain.getHistory({ limit: 10 })
|
||||
|
||||
expect(history.length).toBe(10)
|
||||
expect(history[0]).toHaveProperty('hash')
|
||||
expect(history[0]).toHaveProperty('message')
|
||||
|
||||
await brain.close()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue