@soulcraft/brainy 4.8.3 → 4.8.4
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.
|
@@ -1057,41 +1057,33 @@ export class FileSystemStorage extends BaseStorage {
|
|
|
1057
1057
|
* Get verbs by source
|
|
1058
1058
|
*/
|
|
1059
1059
|
async getVerbsBySource_internal(sourceId) {
|
|
1060
|
-
console.log(`[DEBUG] getVerbsBySource_internal called for sourceId: ${sourceId}`);
|
|
1061
|
-
console.log(`[DEBUG] verbsDir: ${this.verbsDir}`);
|
|
1062
1060
|
// Use the working pagination method with source filter
|
|
1063
1061
|
const result = await this.getVerbsWithPagination({
|
|
1064
1062
|
limit: 10000,
|
|
1065
1063
|
filter: { sourceId: [sourceId] }
|
|
1066
1064
|
});
|
|
1067
|
-
console.log(`[DEBUG] Found ${result.items.length} verbs for source ${sourceId}`);
|
|
1068
|
-
console.log(`[DEBUG] Total verb files found: ${result.totalCount}`);
|
|
1069
1065
|
return result.items;
|
|
1070
1066
|
}
|
|
1071
1067
|
/**
|
|
1072
1068
|
* Get verbs by target
|
|
1073
1069
|
*/
|
|
1074
1070
|
async getVerbsByTarget_internal(targetId) {
|
|
1075
|
-
console.log(`[DEBUG] getVerbsByTarget_internal called for targetId: ${targetId}`);
|
|
1076
1071
|
// Use the working pagination method with target filter
|
|
1077
1072
|
const result = await this.getVerbsWithPagination({
|
|
1078
1073
|
limit: 10000,
|
|
1079
1074
|
filter: { targetId: [targetId] }
|
|
1080
1075
|
});
|
|
1081
|
-
console.log(`[DEBUG] Found ${result.items.length} verbs for target ${targetId}`);
|
|
1082
1076
|
return result.items;
|
|
1083
1077
|
}
|
|
1084
1078
|
/**
|
|
1085
1079
|
* Get verbs by type
|
|
1086
1080
|
*/
|
|
1087
1081
|
async getVerbsByType_internal(type) {
|
|
1088
|
-
console.log(`[DEBUG] getVerbsByType_internal called for type: ${type}`);
|
|
1089
1082
|
// Use the working pagination method with type filter
|
|
1090
1083
|
const result = await this.getVerbsWithPagination({
|
|
1091
1084
|
limit: 10000,
|
|
1092
1085
|
filter: { verbType: [type] }
|
|
1093
1086
|
});
|
|
1094
|
-
console.log(`[DEBUG] Found ${result.items.length} verbs for type ${type}`);
|
|
1095
1087
|
return result.items;
|
|
1096
1088
|
}
|
|
1097
1089
|
/**
|
|
@@ -1105,12 +1097,10 @@ export class FileSystemStorage extends BaseStorage {
|
|
|
1105
1097
|
try {
|
|
1106
1098
|
// Get actual verb files first (critical for accuracy)
|
|
1107
1099
|
const verbFiles = await this.getAllShardedFiles(this.verbsDir);
|
|
1108
|
-
console.log(`[DEBUG] getAllShardedFiles returned ${verbFiles.length} files from ${this.verbsDir}`);
|
|
1109
1100
|
verbFiles.sort(); // Consistent ordering for pagination
|
|
1110
1101
|
// Use actual file count - don't trust cached totalVerbCount
|
|
1111
1102
|
// This prevents accessing undefined array elements
|
|
1112
1103
|
const actualFileCount = verbFiles.length;
|
|
1113
|
-
console.log(`[DEBUG] actualFileCount: ${actualFileCount}, startIndex: ${startIndex}, limit: ${limit}`);
|
|
1114
1104
|
// For large datasets, warn about performance
|
|
1115
1105
|
if (actualFileCount > 1000000) {
|
|
1116
1106
|
console.warn(`Very large verb dataset detected (${actualFileCount} verbs). Performance may be degraded. Consider database storage for optimal performance.`);
|
|
@@ -1182,12 +1172,8 @@ export class FileSystemStorage extends BaseStorage {
|
|
|
1182
1172
|
// Check sourceId filter
|
|
1183
1173
|
if (filter.sourceId) {
|
|
1184
1174
|
const sources = Array.isArray(filter.sourceId) ? filter.sourceId : [filter.sourceId];
|
|
1185
|
-
|
|
1186
|
-
if (!sources.includes(verbWithMetadata.sourceId)) {
|
|
1187
|
-
console.log(`[DEBUG] Verb ${verbWithMetadata.id} filtered out (sourceId mismatch)`);
|
|
1175
|
+
if (!sources.includes(verbWithMetadata.sourceId))
|
|
1188
1176
|
continue;
|
|
1189
|
-
}
|
|
1190
|
-
console.log(`[DEBUG] Verb ${verbWithMetadata.id} MATCHES source filter!`);
|
|
1191
1177
|
}
|
|
1192
1178
|
// Check targetId filter
|
|
1193
1179
|
if (filter.targetId) {
|
|
@@ -1969,67 +1955,34 @@ export class FileSystemStorage extends BaseStorage {
|
|
|
1969
1955
|
* Traverses all shard subdirectories (00-ff)
|
|
1970
1956
|
*/
|
|
1971
1957
|
async getAllShardedFiles(baseDir) {
|
|
1972
|
-
console.log(`[DEBUG] getAllShardedFiles called with baseDir: ${baseDir}`);
|
|
1973
|
-
console.log(`[DEBUG] Current working directory: ${process.cwd()}`);
|
|
1974
|
-
console.log(`[DEBUG] Resolved absolute path: ${path.resolve(baseDir)}`);
|
|
1975
1958
|
const allFiles = [];
|
|
1976
1959
|
try {
|
|
1977
|
-
// Check if directory exists
|
|
1978
|
-
try {
|
|
1979
|
-
const baseStat = await fs.promises.stat(baseDir);
|
|
1980
|
-
console.log(`[DEBUG] baseDir exists: ${baseStat.isDirectory() ? 'is directory' : 'is NOT directory'}`);
|
|
1981
|
-
}
|
|
1982
|
-
catch (statError) {
|
|
1983
|
-
console.log(`[DEBUG] baseDir stat failed: ${statError.message}`);
|
|
1984
|
-
if (statError.code === 'ENOENT') {
|
|
1985
|
-
console.log(`[DEBUG] baseDir does not exist, returning empty array`);
|
|
1986
|
-
return [];
|
|
1987
|
-
}
|
|
1988
|
-
throw statError;
|
|
1989
|
-
}
|
|
1990
1960
|
const shardDirs = await fs.promises.readdir(baseDir);
|
|
1991
|
-
console.log(`[DEBUG] Found ${shardDirs.length} entries in baseDir: ${JSON.stringify(shardDirs.slice(0, 10))}${shardDirs.length > 10 ? '...' : ''}`);
|
|
1992
|
-
let dirsProcessed = 0;
|
|
1993
|
-
let filesFound = 0;
|
|
1994
1961
|
for (const shardDir of shardDirs) {
|
|
1995
1962
|
const shardPath = path.join(baseDir, shardDir);
|
|
1996
1963
|
try {
|
|
1997
1964
|
const stat = await fs.promises.stat(shardPath);
|
|
1998
1965
|
if (stat.isDirectory()) {
|
|
1999
|
-
dirsProcessed++;
|
|
2000
|
-
console.log(`[DEBUG] Processing shard directory ${dirsProcessed}: ${shardDir}`);
|
|
2001
1966
|
const shardFiles = await fs.promises.readdir(shardPath);
|
|
2002
|
-
console.log(`[DEBUG] Found ${shardFiles.length} entries in ${shardDir}`);
|
|
2003
|
-
let jsonCount = 0;
|
|
2004
1967
|
for (const file of shardFiles) {
|
|
2005
1968
|
if (file.endsWith('.json')) {
|
|
2006
1969
|
allFiles.push(file);
|
|
2007
|
-
jsonCount++;
|
|
2008
|
-
filesFound++;
|
|
2009
1970
|
}
|
|
2010
1971
|
}
|
|
2011
|
-
console.log(`[DEBUG] Added ${jsonCount} .json files from ${shardDir} (total so far: ${filesFound})`);
|
|
2012
|
-
}
|
|
2013
|
-
else {
|
|
2014
|
-
console.log(`[DEBUG] Skipping non-directory entry: ${shardDir}`);
|
|
2015
1972
|
}
|
|
2016
1973
|
}
|
|
2017
1974
|
catch (shardError) {
|
|
2018
1975
|
// Skip inaccessible shard directories
|
|
2019
|
-
console.log(`[DEBUG] Error accessing shard ${shardDir}: ${shardError.message}`);
|
|
2020
1976
|
continue;
|
|
2021
1977
|
}
|
|
2022
1978
|
}
|
|
2023
|
-
console.log(`[DEBUG] getAllShardedFiles complete: processed ${dirsProcessed} directories, found ${allFiles.length} total .json files`);
|
|
2024
1979
|
// Sort for consistent ordering
|
|
2025
1980
|
allFiles.sort();
|
|
2026
1981
|
return allFiles;
|
|
2027
1982
|
}
|
|
2028
1983
|
catch (error) {
|
|
2029
|
-
console.log(`[DEBUG] getAllShardedFiles error: ${error.message}, code: ${error.code}`);
|
|
2030
1984
|
if (error.code === 'ENOENT') {
|
|
2031
1985
|
// Directory doesn't exist yet
|
|
2032
|
-
console.log(`[DEBUG] Directory does not exist, returning empty array`);
|
|
2033
1986
|
return [];
|
|
2034
1987
|
}
|
|
2035
1988
|
throw error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.4",
|
|
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",
|