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:
David Snelling 2025-11-18 15:41:57 -08:00
parent 8dcf299fe7
commit f2f6a6c939
7 changed files with 276 additions and 28 deletions

View file

@ -121,9 +121,9 @@ describe('Brainy Batch Operations', () => {
const result = await brain.addMany({ items: entities })
// All should have vectors
// All should have vectors - v5.11.1: Need includeVectors
for (const id of result.successful) {
const entity = await brain.get(id)
const entity = await brain.get(id, { includeVectors: true })
expect(entity?.vector).toBeDefined()
expect(entity?.vector?.length).toBeGreaterThan(0)
}