From 99ac901894bb81ad61b52d422f43cf30f07b6813 Mon Sep 17 00:00:00 2001 From: David Snelling Date: Thu, 13 Nov 2025 14:54:11 -0800 Subject: [PATCH] fix: excludeVFS now only excludes VFS infrastructure entities (v5.7.12) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRITICAL BUG: Workshop team reported excludeVFS: true was excluding extracted entities (concepts/people) even though they should be included. ## Problem excludeVFS was too aggressive - it excluded entities with ANY VFS-related metadata (vfsPath, importedFrom, importIds). This incorrectly excluded extracted entities just because they had metadata showing where they came from. Example: - Excel file "Characters.xlsx" → isVFSEntity: true, vfsType: 'file' ✅ EXCLUDE - Extracted concept "Gandalf" → has vfsPath metadata ❌ Was excluded (BUG!) Should be included because isVFSEntity and vfsType are NOT set ## Root Cause (src/brainy.ts:1357-1359) Old code: ```typescript if (params.excludeVFS === true) { filter.vfsType = { exists: false } // Too simple! } ``` This only checked vfsType field existence, but the real issue was that it didn't properly distinguish between: - VFS infrastructure entities (files/folders) → SHOULD exclude - Extracted entities with import metadata → SHOULD include ## Fix (src/brainy.ts:1360-1389) New code checks TWO conditions (both must be true to INCLUDE entity): 1. isVFSEntity is NOT true (missing or false) 2. vfsType is NOT 'file' or 'directory' (missing or different value) This properly excludes ONLY: - Entities with isVFSEntity: true (explicitly marked as VFS) - Entities with vfsType: 'file' or 'directory' (actual VFS files/folders) And INCLUDES: - Extracted entities (concepts, people, etc) even if they have vfsPath/importedFrom/importIds ## Impact BEFORE v5.7.12: - ❌ Extracted concepts excluded from results - ❌ Workshop UI showing empty concept lists - ❌ excludeVFS unusable for filtering VFS files AFTER v5.7.12: - ✅ Extracted concepts INCLUDED in results - ✅ Only VFS files/folders excluded - ✅ Workshop UI can show concepts with excludeVFS: true Resolves critical Workshop production bug for brain.import() workflows. Related: brain.find(), brain.import(), VirtualFileSystem --- src/brainy.ts | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/brainy.ts b/src/brainy.ts index 5f75e671..e990a069 100644 --- a/src/brainy.ts +++ b/src/brainy.ts @@ -1352,10 +1352,40 @@ export class Brainy implements BrainyInterface { if (params.where) Object.assign(filter, params.where) if (params.service) filter.service = params.service - // v4.7.0: excludeVFS helper for cleaner UX - // Use vfsType field (more semantic than isVFS) + // v5.7.12: excludeVFS helper - ONLY exclude VFS infrastructure entities + // Bug fix: Previously excluded entities with ANY vfsType field + // Now ONLY excludes entities with isVFSEntity: true OR vfsType: 'file'/'directory' + // This allows extracted entities (concepts/people/etc) to be included even if they + // have vfsPath metadata showing where they were imported from if (params.excludeVFS === true) { - filter.vfsType = { exists: false } + // Build filter: EXCLUDE WHERE (isVFSEntity == true) OR (vfsType IN ['file', 'directory']) + // Implementation: INCLUDE WHERE (isVFSEntity missing/false) AND (vfsType missing/not file or directory) + const existingFilter = { ...filter } + filter = { + allOf: [ + existingFilter, + { + // Only include entities WITHOUT isVFSEntity: true + anyOf: [ + { isVFSEntity: { exists: false } }, + { isVFSEntity: { ne: true } } + ] + }, + { + // Only include entities WITHOUT vfsType: 'file' or 'directory' + // Since VFS files ALWAYS have vfsType set, we check it's missing OR not file/dir + anyOf: [ + { vfsType: { exists: false } }, + { + allOf: [ + { vfsType: { ne: 'file' } }, + { vfsType: { ne: 'directory' } } + ] + } + ] + } + ] + } } if (params.type) {