fix: CRITICAL systemic VFS metadata bug across ALL storage adapters (v4.7.4)

CRITICAL BUG FIX - Workshop Team Unblocked!

This hotfix resolves a systemic bug affecting ALL 7 storage adapters that
caused VFS queries to return empty results even when data existed.

Bug Pattern: `if (!metadata) continue` in getNouns()/getVerbs()
Impact: VFS queries returned empty arrays despite 577 relationships existing
Root Cause: Storage adapters skipped entities if metadata file read returned null

Fixes:
- storage: Fix metadata skip bug in 12 locations across 7 adapters
  (TypeAware, Memory, FileSystem, GCS, S3, R2, OPFS, Azure)
- neural: Fix SmartExtractor weighted score threshold (28 failures → 4)
- neural: Fix PatternSignal priority ordering
- api: Fix Brainy.relate() weight parameter not returned

Test Results:
- TypeAwareStorageAdapter: 17/17 passing (was 7 failures)
- SmartExtractor: 42/46 passing (was 28 failures)
- Neural clustering: 3/3 passing
- Brainy.relate(): 20/20 passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
David Snelling 2025-10-27 14:23:46 -07:00
parent c75bbb9ba4
commit e06edb7d52
15 changed files with 287 additions and 144 deletions

View file

@ -1686,11 +1686,11 @@ export class OPFSStorage extends BaseStorage {
const noun = await this.getNoun_internal(id)
if (noun) {
// Load metadata for filtering and combining
// FIX v4.7.4: Don't skip nouns without metadata - metadata is optional in v4.0.0
const metadata = await this.getNounMetadata(id)
if (!metadata) continue
// Apply filters if provided
if (options.filter) {
if (options.filter && metadata) {
// Filter by noun type
if (options.filter.nounType) {
const nounTypes = Array.isArray(options.filter.nounType)
@ -1730,7 +1730,7 @@ export class OPFSStorage extends BaseStorage {
vector: [...noun.vector],
connections: new Map(noun.connections),
level: noun.level || 0,
metadata: metadata
metadata: (metadata || {}) as NounMetadata // Empty if none
}
items.push(nounWithMetadata)
@ -1819,11 +1819,12 @@ export class OPFSStorage extends BaseStorage {
const hnswVerb = await this.getVerb_internal(id)
if (hnswVerb) {
// Load metadata for filtering and combining
// FIX v4.7.4: Don't skip verbs without metadata - metadata is optional in v4.0.0
// Core fields (verb, sourceId, targetId) are in HNSWVerb itself
const metadata = await this.getVerbMetadata(id)
if (!metadata) continue
// Apply filters if provided
if (options.filter) {
if (options.filter && metadata) {
// Filter by verb type
// v4.0.0: verb field is in HNSWVerb structure (NOT in metadata)
if (options.filter.verbType) {
@ -1888,7 +1889,7 @@ export class OPFSStorage extends BaseStorage {
verb: hnswVerb.verb,
sourceId: hnswVerb.sourceId,
targetId: hnswVerb.targetId,
metadata: metadata
metadata: (metadata || {}) as VerbMetadata // Empty if none
}
items.push(verbWithMetadata)