feat: brain.get() metadata-only optimization - Phase 2 (testing)
Fixed convertMetadataToEntity() to properly extract custom metadata fields
using same destructuring pattern as baseStorage.getNoun(). This ensures
metadata is correctly populated in metadata-only entities.
Test Updates:
- Fixed unit tests to add { includeVectors: true } where vectors are checked
- Created comprehensive brain.get() optimization tests (11 tests, all passing)
- Created VFS performance integration tests
- Fixed invalid NounType references (NounType.Place → NounType.Location)
- Adjusted performance expectations for MemoryStorage (10%+ vs 75%+ for FS)
Files Updated:
- src/brainy.ts: Fixed convertMetadataToEntity() destructuring
- tests/unit/brainy-get-optimization.test.ts: New comprehensive tests
- tests/unit/brainy/get.test.ts: Added includeVectors where needed
- tests/unit/brainy/batch-operations.test.ts: Added includeVectors
- tests/unit/brainy/update.test.ts: Added includeVectors
- tests/unit/brainy/add.test.ts: Added includeVectors (3 tests)
- tests/brainy-3.test.ts: Added includeVectors
This commit is contained in:
parent
8dcf299fe7
commit
f2f6a6c939
7 changed files with 276 additions and 28 deletions
|
|
@ -139,17 +139,18 @@ describe('Brainy.update()', () => {
|
|||
type: 'thing'
|
||||
}))
|
||||
|
||||
const original = await brain.get(id)
|
||||
// v5.11.1: Need includeVectors to check vectors
|
||||
const original = await brain.get(id, { includeVectors: true })
|
||||
const originalVector = original!.vector
|
||||
|
||||
|
||||
// Act - Update with new data triggers re-embedding
|
||||
await brain.update({
|
||||
id,
|
||||
data: 'Completely different text content'
|
||||
})
|
||||
|
||||
|
||||
// Assert
|
||||
const updated = await brain.get(id)
|
||||
const updated = await brain.get(id, { includeVectors: true })
|
||||
expect(updated).not.toBeNull()
|
||||
// Vector should be different after re-embedding
|
||||
expect(updated!.vector).not.toEqual(originalVector)
|
||||
|
|
|
|||
Reference in a new issue