fix: set verb.source/target to entity UUID instead of NounType
relate() was setting verb.source = fromEntity.type (a NounType like "concept") instead of the entity UUID. Cortex's graph index indexes by verb.source, so lookups by UUID found nothing — causing in-session reads to return 0 results. Also fixes: - PathResolver calling private getIdsFromChunks() → public getIds() - Plugin auto-detection removed; cortex loads only via explicit config - GraphVerb types accept number timestamps and sourceId/targetId aliases - Dead autoDetect() method removed from PluginRegistry - In-session regression tests added for getRelations after relate()
This commit is contained in:
parent
0ec3d85c39
commit
932fb9520b
6 changed files with 31 additions and 48 deletions
|
|
@ -1488,14 +1488,14 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
|||
vector: relationVector,
|
||||
sourceId: params.from,
|
||||
targetId: params.to,
|
||||
source: fromEntity.type,
|
||||
target: toEntity.type,
|
||||
source: params.from,
|
||||
target: params.to,
|
||||
verb: params.type,
|
||||
type: params.type,
|
||||
weight: params.weight ?? 1.0,
|
||||
metadata: params.metadata as any,
|
||||
metadata: params.metadata,
|
||||
createdAt: Date.now()
|
||||
} as any
|
||||
}
|
||||
|
||||
// Execute atomically with transaction system
|
||||
await this.transactionManager.executeTransaction(async (tx) => {
|
||||
|
|
@ -6694,15 +6694,14 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
|||
*/
|
||||
private async loadPlugins(): Promise<void> {
|
||||
// plugins config:
|
||||
// undefined (default) → auto-detect installed plugins
|
||||
// false → no plugins, skip auto-detection
|
||||
// [] → no plugins, skip auto-detection
|
||||
// ['@soulcraft/cortex'] → load only these, no auto-detection
|
||||
// undefined (default) → no auto-detection (safe default)
|
||||
// false → no auto-detection
|
||||
// [] → no auto-detection
|
||||
// ['@soulcraft/cortex'] → load only these explicitly listed packages
|
||||
// Note: plugins registered via brain.use() are always activated regardless of config
|
||||
const pluginConfig = this.config.plugins
|
||||
if (pluginConfig === false) {
|
||||
// Explicitly disabled — no plugins
|
||||
} else if (Array.isArray(pluginConfig)) {
|
||||
// Explicit list: only register the specified packages, no auto-detection
|
||||
if (Array.isArray(pluginConfig) && pluginConfig.length > 0) {
|
||||
// Explicit list: import and register the specified packages
|
||||
for (const pkg of pluginConfig) {
|
||||
try {
|
||||
const mod = await import(pkg)
|
||||
|
|
@ -6714,9 +6713,6 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
|||
// Package not found — skip
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Default: auto-detect known plugins
|
||||
await this.pluginRegistry.autoDetect()
|
||||
}
|
||||
|
||||
// Create plugin context
|
||||
|
|
|
|||
|
|
@ -291,15 +291,15 @@ export interface GraphVerb {
|
|||
service?: string // Multi-tenancy support - which service created this verb
|
||||
|
||||
// Additional properties used in the codebase
|
||||
source?: string // Alias for sourceId
|
||||
target?: string // Alias for targetId
|
||||
source?: string // Entity UUID (same as sourceId, for graphTypes compatibility)
|
||||
target?: string // Entity UUID (same as targetId, for graphTypes compatibility)
|
||||
verb?: string // Alias for type
|
||||
data?: Record<string, any> // Additional flexible data storage
|
||||
embedding?: Vector // Alias for vector
|
||||
|
||||
// Timestamp and creator properties
|
||||
createdAt?: { seconds: number; nanoseconds: number } // When the verb was created
|
||||
updatedAt?: { seconds: number; nanoseconds: number } // When the verb was last updated
|
||||
createdAt?: number | { seconds: number; nanoseconds: number } // When the verb was created
|
||||
updatedAt?: number | { seconds: number; nanoseconds: number } // When the verb was last updated
|
||||
createdBy?: { augmentation: string; version: string } // Information about what created this verb
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,29 +84,6 @@ export class PluginRegistry {
|
|||
this.plugins.set(plugin.name, plugin)
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-detect known plugins by attempting dynamic import.
|
||||
* Additional package names can be passed for third-party plugins.
|
||||
*/
|
||||
async autoDetect(additionalPackages: string[] = []): Promise<void> {
|
||||
const packages = [
|
||||
'@soulcraft/cortex',
|
||||
'@soulcraft/brainy-cortex', // deprecated — backward compat
|
||||
...additionalPackages
|
||||
]
|
||||
|
||||
for (const pkg of packages) {
|
||||
try {
|
||||
const mod = await import(pkg)
|
||||
const plugin: BrainyPlugin = mod.default || mod
|
||||
if (plugin && typeof plugin.activate === 'function' && plugin.name) {
|
||||
this.plugins.set(plugin.name, plugin)
|
||||
}
|
||||
} catch {
|
||||
// Package not installed — skip silently
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate all registered plugins.
|
||||
|
|
|
|||
|
|
@ -369,12 +369,14 @@ export interface GraphNoun {
|
|||
*/
|
||||
export interface GraphVerb {
|
||||
id: string // Unique identifier for the verb
|
||||
source: string // ID of the source noun
|
||||
target: string // ID of the target noun
|
||||
source: string // Entity UUID of the source noun
|
||||
target: string // Entity UUID of the target noun
|
||||
sourceId?: string // Alias for source (coreTypes compatibility)
|
||||
targetId?: string // Alias for target (coreTypes compatibility)
|
||||
label?: string // Optional descriptive label
|
||||
verb: VerbType // Type of relationship
|
||||
createdAt: Timestamp // When the verb was created
|
||||
updatedAt: Timestamp // When the verb was last updated
|
||||
createdAt: Timestamp | number // When the verb was created
|
||||
updatedAt: Timestamp | number // When the verb was last updated
|
||||
createdBy: CreatorMetadata // Information about what created this verb
|
||||
service?: string // Multi-tenancy support - which service created this verb
|
||||
data?: Record<string, any> // Additional flexible data storage
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ export class PathResolver {
|
|||
try {
|
||||
// Direct O(log n) query to roaring bitmap index
|
||||
// This queries the 'path' field in VFS entity metadata
|
||||
const ids = await metadataIndex.getIdsFromChunks('path', path)
|
||||
const ids = await metadataIndex.getIds('path', path)
|
||||
|
||||
if (ids.length === 0) {
|
||||
this.metadataIndexMisses++
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue