fix: combine vector and metadata in getNoun/getVerb internal methods
Fixed critical bug in 2-file architecture where getNoun_internal() and getVerb_internal() only returned vector data without metadata, causing brain.get() to return null despite data being correctly saved. Changes: - Updated all 5 storage adapters (GCS, S3, FileSystem, Memory, OPFS) - Fixed getNoun_internal() to fetch and combine vector + metadata - Fixed getVerb_internal() to fetch and combine vector + metadata - Added metadata field to HNSWVerb interface for consistency The 2-file architecture now works correctly for both read and write operations.
This commit is contained in:
parent
30063d440a
commit
cb1e37c0e8
6 changed files with 140 additions and 30 deletions
|
|
@ -1048,9 +1048,23 @@ export class S3CompatibleStorage extends BaseStorage {
|
|||
|
||||
/**
|
||||
* Get a noun from storage (internal implementation)
|
||||
* Combines vector data from getNode() with metadata from getNounMetadata()
|
||||
*/
|
||||
protected async getNoun_internal(id: string): Promise<HNSWNoun | null> {
|
||||
return this.getNode(id)
|
||||
// Get vector data (lightweight)
|
||||
const node = await this.getNode(id)
|
||||
if (!node) {
|
||||
return null
|
||||
}
|
||||
|
||||
// Get metadata (entity data in 2-file system)
|
||||
const metadata = await this.getNounMetadata(id)
|
||||
|
||||
// Combine into complete noun object
|
||||
return {
|
||||
...node,
|
||||
metadata: metadata || {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1507,9 +1521,23 @@ export class S3CompatibleStorage extends BaseStorage {
|
|||
|
||||
/**
|
||||
* Get a verb from storage (internal implementation)
|
||||
* Combines vector data from getEdge() with metadata from getVerbMetadata()
|
||||
*/
|
||||
protected async getVerb_internal(id: string): Promise<HNSWVerb | null> {
|
||||
return this.getEdge(id)
|
||||
// Get vector data (lightweight)
|
||||
const edge = await this.getEdge(id)
|
||||
if (!edge) {
|
||||
return null
|
||||
}
|
||||
|
||||
// Get metadata (relationship data in 2-file system)
|
||||
const metadata = await this.getVerbMetadata(id)
|
||||
|
||||
// Combine into complete verb object
|
||||
return {
|
||||
...edge,
|
||||
metadata: metadata || {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue