@soulcraft/brainy 4.5.0 → 4.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/brainy.js CHANGED
@@ -846,6 +846,13 @@ export class Brainy {
846
846
  if (params.service) {
847
847
  filter.service = params.service;
848
848
  }
849
+ // v4.5.1: Exclude VFS relationships by default (same pattern as brain.find())
850
+ // VFS relationships have metadata.isVFS = true
851
+ // Only include VFS relationships if explicitly requested
852
+ if (params.includeVFS !== true) {
853
+ filter.metadata = filter.metadata || {};
854
+ filter.metadata.isVFS = { notEquals: true };
855
+ }
849
856
  // Fetch from storage with pagination at storage layer (efficient!)
850
857
  const result = await this.storage.getVerbs({
851
858
  pagination: {
@@ -266,6 +266,16 @@ export interface GetRelationsParams {
266
266
  * Only return relationships belonging to this service.
267
267
  */
268
268
  service?: string;
269
+ /**
270
+ * Include VFS relationships (v4.5.1)
271
+ *
272
+ * By default, getRelations() excludes VFS relationships (since v4.4.0).
273
+ * Set this to true when you need to traverse VFS structure.
274
+ *
275
+ * @default false
276
+ * @since v4.5.1
277
+ */
278
+ includeVFS?: boolean;
269
279
  }
270
280
  /**
271
281
  * Batch add parameters
@@ -135,7 +135,8 @@ export class PathResolver {
135
135
  // Get all relationships where parentId contains other entities
136
136
  const relations = await this.brain.getRelations({
137
137
  from: parentId,
138
- type: VerbType.Contains
138
+ type: VerbType.Contains,
139
+ includeVFS: true // v4.5.1: Required to see VFS relationships
139
140
  });
140
141
  // Find the child with matching name
141
142
  for (const relation of relations) {
@@ -159,7 +160,8 @@ export class PathResolver {
159
160
  // Production-ready: Use graph relationships (VFS creates these in mkdir/writeFile)
160
161
  const relations = await this.brain.getRelations({
161
162
  from: dirId,
162
- type: VerbType.Contains
163
+ type: VerbType.Contains,
164
+ includeVFS: true // v4.5.1: Required to see VFS relationships
163
165
  });
164
166
  const validChildren = [];
165
167
  const childNames = new Set();
@@ -106,9 +106,10 @@ export class VirtualFileSystem {
106
106
  if (existing.length > 1) {
107
107
  console.warn(`⚠️ Found ${existing.length} root entities! Using first one, consider cleanup.`);
108
108
  // Sort by creation time - use oldest root (most likely to have children)
109
+ // v4.5.2: FIX - createdAt is at entity level, not metadata level!
109
110
  existing.sort((a, b) => {
110
- const aTime = a.metadata?.createdAt || a.metadata?.modified || 0;
111
- const bTime = b.metadata?.createdAt || b.metadata?.modified || 0;
111
+ const aTime = a.createdAt || a.metadata?.modified || 0;
112
+ const bTime = b.createdAt || b.metadata?.modified || 0;
112
113
  return aTime - bTime;
113
114
  });
114
115
  }
@@ -330,7 +331,8 @@ export class VirtualFileSystem {
330
331
  await this.brain.relate({
331
332
  from: parentId,
332
333
  to: existingId,
333
- type: VerbType.Contains
334
+ type: VerbType.Contains,
335
+ metadata: { isVFS: true } // v4.5.1: Mark as VFS relationship
334
336
  });
335
337
  }
336
338
  }
@@ -347,7 +349,8 @@ export class VirtualFileSystem {
347
349
  await this.brain.relate({
348
350
  from: parentId,
349
351
  to: entity,
350
- type: VerbType.Contains
352
+ type: VerbType.Contains,
353
+ metadata: { isVFS: true } // v4.5.1: Mark as VFS relationship
351
354
  });
352
355
  // Update path resolver cache
353
356
  await this.pathResolver.createPath(path, entity);
@@ -612,7 +615,8 @@ export class VirtualFileSystem {
612
615
  await this.brain.relate({
613
616
  from: parentId,
614
617
  to: entity,
615
- type: VerbType.Contains
618
+ type: VerbType.Contains,
619
+ metadata: { isVFS: true } // v4.5.1: Mark as VFS relationship
616
620
  });
617
621
  }
618
622
  // Update path resolver cache
@@ -1410,7 +1414,12 @@ export class VirtualFileSystem {
1410
1414
  // Add to new parent
1411
1415
  if (newParentPath && newParentPath !== '/') {
1412
1416
  const newParentId = await this.pathResolver.resolve(newParentPath);
1413
- await this.brain.relate({ from: newParentId, to: entityId, type: VerbType.Contains });
1417
+ await this.brain.relate({
1418
+ from: newParentId,
1419
+ to: entityId,
1420
+ type: VerbType.Contains,
1421
+ metadata: { isVFS: true } // v4.5.1: Mark as VFS relationship
1422
+ });
1414
1423
  }
1415
1424
  }
1416
1425
  // Update the entity
@@ -1475,7 +1484,12 @@ export class VirtualFileSystem {
1475
1484
  const parentPath = this.getParentPath(destPath);
1476
1485
  if (parentPath && parentPath !== '/') {
1477
1486
  const parentId = await this.pathResolver.resolve(parentPath);
1478
- await this.brain.relate({ from: parentId, to: newEntity, type: VerbType.Contains });
1487
+ await this.brain.relate({
1488
+ from: parentId,
1489
+ to: newEntity,
1490
+ type: VerbType.Contains,
1491
+ metadata: { isVFS: true } // v4.5.1: Mark as VFS relationship
1492
+ });
1479
1493
  }
1480
1494
  // Update path cache
1481
1495
  await this.pathResolver.createPath(destPath, newEntity);
@@ -1562,7 +1576,8 @@ export class VirtualFileSystem {
1562
1576
  await this.brain.relate({
1563
1577
  from: parentId,
1564
1578
  to: entity,
1565
- type: VerbType.Contains
1579
+ type: VerbType.Contains,
1580
+ metadata: { isVFS: true } // v4.5.1: Mark as VFS relationship
1566
1581
  });
1567
1582
  // Update path resolver cache
1568
1583
  await this.pathResolver.createPath(path, entity);
@@ -1732,7 +1747,8 @@ export class VirtualFileSystem {
1732
1747
  await this.brain.relate({
1733
1748
  from: fromEntityId,
1734
1749
  to: toEntityId,
1735
- type: type // Convert string to VerbType
1750
+ type: type, // Convert string to VerbType
1751
+ metadata: { isVFS: true } // v4.5.1: Mark as VFS relationship
1736
1752
  });
1737
1753
  // Invalidate caches for both paths
1738
1754
  this.invalidateCaches(from);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "4.5.0",
3
+ "version": "4.5.2",
4
4
  "description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. 31 nouns × 40 verbs for infinite expressiveness.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",