From 2b9f5bcd1f53af99c7dec7793ebc95a3d4a6729a Mon Sep 17 00:00:00 2001 From: David Snelling Date: Mon, 27 Oct 2025 15:51:14 -0700 Subject: [PATCH] fix(brainy): correct convertNounToEntity() to read from top-level fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v4.8.0 storage adapters extract standard fields to top-level, but convertNounToEntity() was still reading from metadata. Fixed to read directly from top-level fields: - type (was noun in metadata) - service, createdAt, updatedAt - confidence, weight, data, createdBy Results: - Fixed 22 failing tests (47 → 25) - Test pass rate: 96.7% (972/1005) - Type filtering tests: 8/8 passing - Brainy API tests: mostly passing Remaining: 25 failures in neural/storage/performance tests (need investigation) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/brainy.ts | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/src/brainy.ts b/src/brainy.ts index 0570650d..138e1d59 100644 --- a/src/brainy.ts +++ b/src/brainy.ts @@ -570,37 +570,26 @@ export class Brainy implements BrainyInterface { * - metadata contains ONLY custom user fields */ private async convertNounToEntity(noun: any): Promise> { - // Extract ALL standard fields and user metadata - const { - noun: nounType, - service, - createdAt, - updatedAt, - data: _data, - confidence, - weight, - createdBy, - // Everything else is custom user metadata - ...customMetadata - } = noun.metadata || {} + // v4.8.0: Storage adapters ALREADY extract standard fields to top-level! + // Just read from top-level fields of HNSWNounWithMetadata // v4.8.0: Clean structure with standard fields at top-level const entity: Entity = { id: noun.id, vector: noun.vector, - type: (nounType as NounType) || NounType.Thing, + type: noun.type || NounType.Thing, // Standard fields at top-level (v4.8.0) - confidence: confidence as number | undefined, - weight: weight as number | undefined, - createdAt: (createdAt as number) || Date.now(), - updatedAt: (updatedAt as number) || Date.now(), - service: service as string | undefined, - data: _data, - createdBy, + confidence: noun.confidence, + weight: noun.weight, + createdAt: noun.createdAt || Date.now(), + updatedAt: noun.updatedAt || Date.now(), + service: noun.service, + data: noun.data, + createdBy: noun.createdBy, - // ONLY custom user fields in metadata - metadata: customMetadata as T + // ONLY custom user fields in metadata (v4.8.0: already separated by storage adapter) + metadata: noun.metadata as T } return entity