debug: add comprehensive logging to trace VFS undefined names bug
- Add debug logging to VFS readdir() to show children and VFSDirent structure - Add debug logging to PathResolver.getChildren() to trace entity retrieval - Add debug logging to convertNounToEntity() to trace metadata extraction - Helps diagnose v4.8.4 VFS undefined names bug reported by Workshop team Ref: BRAINY_V4.8.4_VFS_UNDEFINED_NAMES_BUG.md
This commit is contained in:
parent
522cbfa93a
commit
4b980a46a8
3 changed files with 48 additions and 1 deletions
|
|
@ -573,6 +573,14 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
||||||
// v4.8.0: Storage adapters ALREADY extract standard fields to top-level!
|
// v4.8.0: Storage adapters ALREADY extract standard fields to top-level!
|
||||||
// Just read from top-level fields of HNSWNounWithMetadata
|
// Just read from top-level fields of HNSWNounWithMetadata
|
||||||
|
|
||||||
|
console.log(`[DEBUG convertNounToEntity] Converting noun ${noun.id}:`, {
|
||||||
|
nounMetadataKeys: noun.metadata ? Object.keys(noun.metadata) : [],
|
||||||
|
nounType: noun.type,
|
||||||
|
hasName: !!noun.metadata?.name,
|
||||||
|
hasPath: !!noun.metadata?.path,
|
||||||
|
hasVfsType: !!noun.metadata?.vfsType
|
||||||
|
})
|
||||||
|
|
||||||
// v4.8.0: Clean structure with standard fields at top-level
|
// v4.8.0: Clean structure with standard fields at top-level
|
||||||
const entity: Entity<T> = {
|
const entity: Entity<T> = {
|
||||||
id: noun.id,
|
id: noun.id,
|
||||||
|
|
@ -592,6 +600,13 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
||||||
metadata: noun.metadata as T
|
metadata: noun.metadata as T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`[DEBUG convertNounToEntity] Converted entity metadata:`, {
|
||||||
|
entityMetadataKeys: entity.metadata ? Object.keys(entity.metadata as any) : [],
|
||||||
|
metadata_name: (entity.metadata as any)?.name,
|
||||||
|
metadata_path: (entity.metadata as any)?.path,
|
||||||
|
metadata_vfsType: (entity.metadata as any)?.vfsType
|
||||||
|
})
|
||||||
|
|
||||||
return entity
|
return entity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,7 @@ export class PathResolver {
|
||||||
from: dirId,
|
from: dirId,
|
||||||
type: VerbType.Contains
|
type: VerbType.Contains
|
||||||
})
|
})
|
||||||
|
console.log(`[DEBUG PathResolver] getChildren(${dirId}): Found ${relations.length} Contains relations`)
|
||||||
|
|
||||||
const validChildren: VFSEntity[]= []
|
const validChildren: VFSEntity[]= []
|
||||||
const childNames = new Set<string>()
|
const childNames = new Set<string>()
|
||||||
|
|
@ -237,12 +238,24 @@ export class PathResolver {
|
||||||
// Fetch all child entities via relationships
|
// Fetch all child entities via relationships
|
||||||
for (const relation of relations) {
|
for (const relation of relations) {
|
||||||
const entity = await this.brain.get(relation.to)
|
const entity = await this.brain.get(relation.to)
|
||||||
|
console.log(`[DEBUG PathResolver] Retrieved entity ${relation.to}:`, {
|
||||||
|
exists: !!entity,
|
||||||
|
type: entity?.type,
|
||||||
|
hasMetadata: !!entity?.metadata,
|
||||||
|
metadataKeys: entity?.metadata ? Object.keys(entity.metadata) : [],
|
||||||
|
metadata_vfsType: entity?.metadata?.vfsType,
|
||||||
|
metadata_name: entity?.metadata?.name
|
||||||
|
})
|
||||||
|
|
||||||
if (entity && entity.metadata?.vfsType && entity.metadata?.name) {
|
if (entity && entity.metadata?.vfsType && entity.metadata?.name) {
|
||||||
validChildren.push(entity as VFSEntity)
|
validChildren.push(entity as VFSEntity)
|
||||||
childNames.add(entity.metadata.name)
|
childNames.add(entity.metadata.name)
|
||||||
|
} else {
|
||||||
|
console.log(`[DEBUG PathResolver] ❌ FILTERED OUT entity ${relation.to} - missing vfsType or name`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`[DEBUG PathResolver] Returning ${validChildren.length} valid children (filtered from ${relations.length})`)
|
||||||
// Update cache
|
// Update cache
|
||||||
this.parentCache.set(dirId, childNames)
|
this.parentCache.set(dirId, childNames)
|
||||||
return validChildren
|
return validChildren
|
||||||
|
|
|
||||||
|
|
@ -846,6 +846,20 @@ export class VirtualFileSystem implements IVirtualFileSystem {
|
||||||
|
|
||||||
// Get children
|
// Get children
|
||||||
let children = await this.pathResolver.getChildren(entityId)
|
let children = await this.pathResolver.getChildren(entityId)
|
||||||
|
console.log(`[DEBUG VFS] readdir(${path}): Found ${children.length} children`)
|
||||||
|
|
||||||
|
// Debug first child
|
||||||
|
if (children.length > 0) {
|
||||||
|
const firstChild = children[0]
|
||||||
|
console.log(`[DEBUG VFS] First child structure:`, {
|
||||||
|
id: firstChild.id,
|
||||||
|
type: firstChild.type,
|
||||||
|
metadataKeys: Object.keys(firstChild.metadata || {}),
|
||||||
|
metadata_name: firstChild.metadata?.name,
|
||||||
|
metadata_path: firstChild.metadata?.path,
|
||||||
|
metadata_vfsType: firstChild.metadata?.vfsType
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Apply filters
|
// Apply filters
|
||||||
if (options?.filter) {
|
if (options?.filter) {
|
||||||
|
|
@ -870,12 +884,17 @@ export class VirtualFileSystem implements IVirtualFileSystem {
|
||||||
|
|
||||||
// Return appropriate format
|
// Return appropriate format
|
||||||
if (options?.withFileTypes) {
|
if (options?.withFileTypes) {
|
||||||
return children.map(child => ({
|
const result = children.map(child => ({
|
||||||
name: child.metadata.name,
|
name: child.metadata.name,
|
||||||
path: child.metadata.path,
|
path: child.metadata.path,
|
||||||
type: child.metadata.vfsType,
|
type: child.metadata.vfsType,
|
||||||
entityId: child.id
|
entityId: child.id
|
||||||
} as VFSDirent))
|
} as VFSDirent))
|
||||||
|
console.log(`[DEBUG VFS] Returning ${result.length} VFSDirent items`)
|
||||||
|
if (result.length > 0) {
|
||||||
|
console.log(`[DEBUG VFS] First VFSDirent:`, result[0])
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
return children.map(child => child.metadata.name)
|
return children.map(child => child.metadata.name)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue