@soulcraft/brainy 0.51.1 → 0.52.0

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.
@@ -0,0 +1,377 @@
1
+ import { cosineDistance } from '../utils/distance.js';
2
+ /**
3
+ * Default configuration for the Intelligent Verb Scoring augmentation
4
+ */
5
+ export const DEFAULT_VERB_SCORING_CONFIG = {
6
+ enableSemanticScoring: true,
7
+ enableFrequencyAmplification: true,
8
+ enableTemporalDecay: true,
9
+ temporalDecayRate: 0.01, // 1% decay per day
10
+ minWeight: 0.1,
11
+ maxWeight: 1.0,
12
+ baseConfidence: 0.5,
13
+ learningRate: 0.1
14
+ };
15
+ /**
16
+ * Intelligent Verb Scoring Cognition Augmentation
17
+ *
18
+ * Automatically generates intelligent weight and confidence scores for verb relationships
19
+ * using semantic analysis, frequency patterns, and temporal factors.
20
+ */
21
+ export class IntelligentVerbScoring {
22
+ constructor(config = {}) {
23
+ this.name = 'intelligent-verb-scoring';
24
+ this.description = 'Automatically generates intelligent weight and confidence scores for verb relationships';
25
+ this.enabled = false; // Off by default as requested
26
+ this.relationshipStats = new Map();
27
+ this.isInitialized = false;
28
+ this.config = { ...DEFAULT_VERB_SCORING_CONFIG, ...config };
29
+ }
30
+ async initialize() {
31
+ if (this.isInitialized)
32
+ return;
33
+ this.isInitialized = true;
34
+ }
35
+ async shutDown() {
36
+ this.relationshipStats.clear();
37
+ this.isInitialized = false;
38
+ }
39
+ async getStatus() {
40
+ return this.enabled && this.isInitialized ? 'active' : 'inactive';
41
+ }
42
+ /**
43
+ * Set reference to the BrainyData instance for accessing graph data
44
+ */
45
+ setBrainyInstance(instance) {
46
+ this.brainyInstance = instance;
47
+ }
48
+ /**
49
+ * Main reasoning method for generating intelligent verb scores
50
+ */
51
+ reason(query, context) {
52
+ if (!this.enabled) {
53
+ return {
54
+ success: false,
55
+ data: { inference: 'Augmentation is disabled', confidence: 0 },
56
+ error: 'Intelligent verb scoring is disabled'
57
+ };
58
+ }
59
+ return {
60
+ success: true,
61
+ data: {
62
+ inference: 'Intelligent verb scoring active',
63
+ confidence: 1.0
64
+ }
65
+ };
66
+ }
67
+ infer(dataSubset) {
68
+ return {
69
+ success: true,
70
+ data: dataSubset
71
+ };
72
+ }
73
+ executeLogic(ruleId, input) {
74
+ return {
75
+ success: true,
76
+ data: true
77
+ };
78
+ }
79
+ /**
80
+ * Generate intelligent weight and confidence scores for a verb relationship
81
+ *
82
+ * @param sourceId - ID of the source entity
83
+ * @param targetId - ID of the target entity
84
+ * @param verbType - Type of the relationship
85
+ * @param existingWeight - Existing weight if any
86
+ * @param metadata - Additional metadata about the relationship
87
+ * @returns Computed weight and confidence scores
88
+ */
89
+ async computeVerbScores(sourceId, targetId, verbType, existingWeight, metadata) {
90
+ if (!this.enabled || !this.brainyInstance) {
91
+ return {
92
+ weight: existingWeight ?? 0.5,
93
+ confidence: this.config.baseConfidence,
94
+ reasoning: ['Intelligent scoring disabled']
95
+ };
96
+ }
97
+ const reasoning = [];
98
+ let weight = existingWeight ?? 0.5;
99
+ let confidence = this.config.baseConfidence;
100
+ try {
101
+ // Get relationship key for statistics
102
+ const relationKey = `${sourceId}-${verbType}-${targetId}`;
103
+ // Update relationship statistics
104
+ this.updateRelationshipStats(relationKey, weight, metadata);
105
+ // Apply semantic scoring if enabled
106
+ if (this.config.enableSemanticScoring) {
107
+ const semanticScore = await this.calculateSemanticScore(sourceId, targetId);
108
+ if (semanticScore !== null) {
109
+ weight = this.blendScores(weight, semanticScore, 0.3);
110
+ confidence = Math.min(confidence + semanticScore * 0.2, 1.0);
111
+ reasoning.push(`Semantic similarity: ${semanticScore.toFixed(3)}`);
112
+ }
113
+ }
114
+ // Apply frequency amplification if enabled
115
+ if (this.config.enableFrequencyAmplification) {
116
+ const frequencyBoost = this.calculateFrequencyBoost(relationKey);
117
+ weight = this.blendScores(weight, frequencyBoost, 0.2);
118
+ if (frequencyBoost > 0.5) {
119
+ confidence = Math.min(confidence + 0.1, 1.0);
120
+ reasoning.push(`Frequency boost: ${frequencyBoost.toFixed(3)}`);
121
+ }
122
+ }
123
+ // Apply temporal decay if enabled
124
+ if (this.config.enableTemporalDecay) {
125
+ const temporalFactor = this.calculateTemporalFactor(relationKey);
126
+ weight *= temporalFactor;
127
+ reasoning.push(`Temporal factor: ${temporalFactor.toFixed(3)}`);
128
+ }
129
+ // Apply learning adjustments
130
+ const learningAdjustment = this.calculateLearningAdjustment(relationKey);
131
+ weight = this.blendScores(weight, learningAdjustment, this.config.learningRate);
132
+ // Clamp values to configured bounds
133
+ weight = Math.max(this.config.minWeight, Math.min(this.config.maxWeight, weight));
134
+ confidence = Math.max(0, Math.min(1, confidence));
135
+ reasoning.push(`Final weight: ${weight.toFixed(3)}, confidence: ${confidence.toFixed(3)}`);
136
+ return { weight, confidence, reasoning };
137
+ }
138
+ catch (error) {
139
+ console.warn('Error computing verb scores:', error);
140
+ return {
141
+ weight: existingWeight ?? 0.5,
142
+ confidence: this.config.baseConfidence,
143
+ reasoning: [`Error in scoring: ${error}`]
144
+ };
145
+ }
146
+ }
147
+ /**
148
+ * Calculate semantic similarity between two entities using their embeddings
149
+ */
150
+ async calculateSemanticScore(sourceId, targetId) {
151
+ try {
152
+ if (!this.brainyInstance?.storage)
153
+ return null;
154
+ // Get noun embeddings from storage
155
+ const sourceNoun = await this.brainyInstance.storage.getNoun(sourceId);
156
+ const targetNoun = await this.brainyInstance.storage.getNoun(targetId);
157
+ if (!sourceNoun?.vector || !targetNoun?.vector)
158
+ return null;
159
+ // Calculate cosine similarity (1 - distance)
160
+ const distance = cosineDistance(sourceNoun.vector, targetNoun.vector);
161
+ return Math.max(0, 1 - distance);
162
+ }
163
+ catch (error) {
164
+ console.warn('Error calculating semantic score:', error);
165
+ return null;
166
+ }
167
+ }
168
+ /**
169
+ * Calculate frequency-based boost for repeated relationships
170
+ */
171
+ calculateFrequencyBoost(relationKey) {
172
+ const stats = this.relationshipStats.get(relationKey);
173
+ if (!stats || stats.count <= 1)
174
+ return 0.5;
175
+ // Logarithmic scaling: more occurrences = higher weight, but with diminishing returns
176
+ const boost = Math.log(stats.count + 1) / Math.log(10); // Log base 10
177
+ return Math.min(boost, 1.0);
178
+ }
179
+ /**
180
+ * Calculate temporal decay factor based on recency
181
+ */
182
+ calculateTemporalFactor(relationKey) {
183
+ const stats = this.relationshipStats.get(relationKey);
184
+ if (!stats)
185
+ return 1.0;
186
+ const daysSinceLastSeen = (Date.now() - stats.lastSeen.getTime()) / (1000 * 60 * 60 * 24);
187
+ const decayFactor = Math.exp(-this.config.temporalDecayRate * daysSinceLastSeen);
188
+ return Math.max(0.1, decayFactor); // Minimum 10% of original weight
189
+ }
190
+ /**
191
+ * Calculate learning-based adjustment using historical patterns
192
+ */
193
+ calculateLearningAdjustment(relationKey) {
194
+ const stats = this.relationshipStats.get(relationKey);
195
+ if (!stats || stats.count <= 1)
196
+ return 0.5;
197
+ // Use moving average of weights as learned baseline
198
+ return Math.max(0, Math.min(1, stats.averageWeight));
199
+ }
200
+ /**
201
+ * Update relationship statistics for learning
202
+ */
203
+ updateRelationshipStats(relationKey, weight, metadata) {
204
+ const now = new Date();
205
+ const existing = this.relationshipStats.get(relationKey);
206
+ if (existing) {
207
+ // Update existing stats
208
+ existing.count++;
209
+ existing.totalWeight += weight;
210
+ existing.averageWeight = existing.totalWeight / existing.count;
211
+ existing.lastSeen = now;
212
+ }
213
+ else {
214
+ // Create new stats entry
215
+ this.relationshipStats.set(relationKey, {
216
+ count: 1,
217
+ totalWeight: weight,
218
+ averageWeight: weight,
219
+ lastSeen: now,
220
+ firstSeen: now
221
+ });
222
+ }
223
+ }
224
+ /**
225
+ * Blend two scores using a weighted average
226
+ */
227
+ blendScores(score1, score2, weight2) {
228
+ const weight1 = 1 - weight2;
229
+ return score1 * weight1 + score2 * weight2;
230
+ }
231
+ /**
232
+ * Get current configuration
233
+ */
234
+ getConfig() {
235
+ return { ...this.config };
236
+ }
237
+ /**
238
+ * Update configuration
239
+ */
240
+ updateConfig(newConfig) {
241
+ this.config = { ...this.config, ...newConfig };
242
+ }
243
+ /**
244
+ * Get relationship statistics (for debugging/monitoring)
245
+ */
246
+ getRelationshipStats() {
247
+ return new Map(this.relationshipStats);
248
+ }
249
+ /**
250
+ * Clear relationship statistics
251
+ */
252
+ clearStats() {
253
+ this.relationshipStats.clear();
254
+ }
255
+ /**
256
+ * Provide feedback to improve future scoring
257
+ * This allows the system to learn from user corrections or validation
258
+ *
259
+ * @param sourceId - Source entity ID
260
+ * @param targetId - Target entity ID
261
+ * @param verbType - Relationship type
262
+ * @param feedbackWeight - The corrected/validated weight (0-1)
263
+ * @param feedbackConfidence - The corrected/validated confidence (0-1)
264
+ * @param feedbackType - Type of feedback ('correction', 'validation', 'enhancement')
265
+ */
266
+ async provideFeedback(sourceId, targetId, verbType, feedbackWeight, feedbackConfidence, feedbackType = 'correction') {
267
+ if (!this.enabled)
268
+ return;
269
+ const relationKey = `${sourceId}-${verbType}-${targetId}`;
270
+ const existing = this.relationshipStats.get(relationKey);
271
+ if (existing) {
272
+ // Apply feedback with learning rate
273
+ const newWeight = existing.averageWeight * (1 - this.config.learningRate) +
274
+ feedbackWeight * this.config.learningRate;
275
+ // Update the running average with feedback
276
+ existing.totalWeight = (existing.totalWeight * existing.count + feedbackWeight) / (existing.count + 1);
277
+ existing.averageWeight = existing.totalWeight / existing.count;
278
+ existing.count += 1;
279
+ existing.lastSeen = new Date();
280
+ if (this.brainyInstance?.loggingConfig?.verbose) {
281
+ console.log(`Feedback applied for ${relationKey}: ${feedbackType}, ` +
282
+ `old weight: ${existing.averageWeight.toFixed(3)}, ` +
283
+ `feedback: ${feedbackWeight.toFixed(3)}, ` +
284
+ `new weight: ${newWeight.toFixed(3)}`);
285
+ }
286
+ }
287
+ else {
288
+ // Create new entry with feedback as initial data
289
+ this.relationshipStats.set(relationKey, {
290
+ count: 1,
291
+ totalWeight: feedbackWeight,
292
+ averageWeight: feedbackWeight,
293
+ lastSeen: new Date(),
294
+ firstSeen: new Date()
295
+ });
296
+ }
297
+ }
298
+ /**
299
+ * Get learning statistics for monitoring and debugging
300
+ */
301
+ getLearningStats() {
302
+ const relationships = Array.from(this.relationshipStats.entries());
303
+ const totalRelationships = relationships.length;
304
+ const feedbackCount = relationships.reduce((sum, [, stats]) => sum + stats.count, 0);
305
+ // Calculate average confidence (approximated from weight patterns)
306
+ const averageWeight = relationships.reduce((sum, [, stats]) => sum + stats.averageWeight, 0) / totalRelationships || 0;
307
+ const averageConfidence = Math.min(averageWeight + 0.2, 1.0); // Heuristic: confidence typically higher than weight
308
+ // Get top relationships by count
309
+ const topRelationships = relationships
310
+ .map(([key, stats]) => ({
311
+ relationship: key,
312
+ count: stats.count,
313
+ averageWeight: stats.averageWeight
314
+ }))
315
+ .sort((a, b) => b.count - a.count)
316
+ .slice(0, 10);
317
+ return {
318
+ totalRelationships,
319
+ averageConfidence,
320
+ feedbackCount,
321
+ topRelationships
322
+ };
323
+ }
324
+ /**
325
+ * Export learning data for backup or analysis
326
+ */
327
+ exportLearningData() {
328
+ const data = {
329
+ config: this.config,
330
+ stats: Array.from(this.relationshipStats.entries()).map(([key, stats]) => ({
331
+ relationship: key,
332
+ ...stats,
333
+ firstSeen: stats.firstSeen.toISOString(),
334
+ lastSeen: stats.lastSeen.toISOString()
335
+ })),
336
+ exportedAt: new Date().toISOString(),
337
+ version: '1.0'
338
+ };
339
+ return JSON.stringify(data, null, 2);
340
+ }
341
+ /**
342
+ * Import learning data from backup
343
+ */
344
+ importLearningData(jsonData) {
345
+ try {
346
+ const data = JSON.parse(jsonData);
347
+ if (data.version !== '1.0') {
348
+ console.warn('Learning data version mismatch, importing anyway');
349
+ }
350
+ // Update configuration if provided
351
+ if (data.config) {
352
+ this.config = { ...this.config, ...data.config };
353
+ }
354
+ // Import relationship statistics
355
+ if (data.stats && Array.isArray(data.stats)) {
356
+ for (const stat of data.stats) {
357
+ if (stat.relationship) {
358
+ this.relationshipStats.set(stat.relationship, {
359
+ count: stat.count || 1,
360
+ totalWeight: stat.totalWeight || stat.averageWeight || 0.5,
361
+ averageWeight: stat.averageWeight || 0.5,
362
+ firstSeen: new Date(stat.firstSeen || Date.now()),
363
+ lastSeen: new Date(stat.lastSeen || Date.now()),
364
+ semanticSimilarity: stat.semanticSimilarity
365
+ });
366
+ }
367
+ }
368
+ }
369
+ console.log(`Imported learning data: ${this.relationshipStats.size} relationships`);
370
+ }
371
+ catch (error) {
372
+ console.error('Failed to import learning data:', error);
373
+ throw new Error(`Failed to import learning data: ${error}`);
374
+ }
375
+ }
376
+ }
377
+ //# sourceMappingURL=intelligentVerbScoring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intelligentVerbScoring.js","sourceRoot":"","sources":["../../src/augmentations/intelligentVerbScoring.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAwBrD;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAuB;IAC7D,qBAAqB,EAAE,IAAI;IAC3B,4BAA4B,EAAE,IAAI;IAClC,mBAAmB,EAAE,IAAI;IACzB,iBAAiB,EAAE,IAAI,EAAE,mBAAmB;IAC5C,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,GAAG;IACd,cAAc,EAAE,GAAG;IACnB,YAAY,EAAE,GAAG;CAClB,CAAA;AAcD;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IAUjC,YAAY,SAAsC,EAAE;QAT3C,SAAI,GAAG,0BAA0B,CAAA;QACjC,gBAAW,GAAG,yFAAyF,CAAA;QAChH,YAAO,GAAG,KAAK,CAAA,CAAC,8BAA8B;QAGtC,sBAAiB,GAAmC,IAAI,GAAG,EAAE,CAAA;QAE7D,kBAAa,GAAG,KAAK,CAAA;QAG3B,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,2BAA2B,EAAE,GAAG,MAAM,EAAE,CAAA;IAC7D,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,aAAa;YAAE,OAA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jC,IAAI,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;oBAC9B,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;wBACtB,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE;4BAC5C,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC;4BACtB,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,aAAa,IAAI,GAAG;4BAC1D,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,GAAG;4BACxC,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;4BACjD,QAAQ,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;4BAC/C,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;yBAC5C,CAAC,CAAA;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,2BAA2B,IAAI,CAAC,iBAAiB,CAAC,IAAI,gBAAgB,CAAC,CAAA;QACrF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAA;YACvD,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,EAAE,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC;CACF"}
@@ -288,6 +288,58 @@ export interface BrainyDataConfig {
288
288
  prefetchStrategy?: 'conservative' | 'moderate' | 'aggressive';
289
289
  };
290
290
  };
291
+ /**
292
+ * Intelligent verb scoring configuration
293
+ * Automatically generates weight and confidence scores for verb relationships
294
+ * Off by default - enable by setting enabled: true
295
+ */
296
+ intelligentVerbScoring?: {
297
+ /**
298
+ * Whether to enable intelligent verb scoring
299
+ * Default: false (off by default)
300
+ */
301
+ enabled?: boolean;
302
+ /**
303
+ * Enable semantic proximity scoring based on entity embeddings
304
+ * Default: true
305
+ */
306
+ enableSemanticScoring?: boolean;
307
+ /**
308
+ * Enable frequency-based weight amplification
309
+ * Default: true
310
+ */
311
+ enableFrequencyAmplification?: boolean;
312
+ /**
313
+ * Enable temporal decay for weights
314
+ * Default: true
315
+ */
316
+ enableTemporalDecay?: boolean;
317
+ /**
318
+ * Decay rate per day for temporal scoring (0-1)
319
+ * Default: 0.01 (1% decay per day)
320
+ */
321
+ temporalDecayRate?: number;
322
+ /**
323
+ * Minimum weight threshold
324
+ * Default: 0.1
325
+ */
326
+ minWeight?: number;
327
+ /**
328
+ * Maximum weight threshold
329
+ * Default: 1.0
330
+ */
331
+ maxWeight?: number;
332
+ /**
333
+ * Base confidence score for new relationships
334
+ * Default: 0.5
335
+ */
336
+ baseConfidence?: number;
337
+ /**
338
+ * Learning rate for adaptive scoring (0-1)
339
+ * Default: 0.1
340
+ */
341
+ learningRate?: number;
342
+ };
291
343
  }
292
344
  export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
293
345
  index: HNSWIndex | HNSWIndexOptimized;
@@ -321,6 +373,7 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
321
373
  private remoteServerConfig;
322
374
  private serverSearchConduit;
323
375
  private serverConnection;
376
+ private intelligentVerbScoring;
324
377
  private distributedConfig;
325
378
  private configManager;
326
379
  private partitioner;
@@ -406,6 +459,30 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
406
459
  * Apply changes using full scan method (fallback for storage adapters without change log support)
407
460
  */
408
461
  private applyChangesFromFullScan;
462
+ /**
463
+ * Provide feedback to the intelligent verb scoring system for learning
464
+ * This allows the system to learn from user corrections or validation
465
+ *
466
+ * @param sourceId - Source entity ID
467
+ * @param targetId - Target entity ID
468
+ * @param verbType - Relationship type
469
+ * @param feedbackWeight - The corrected/validated weight (0-1)
470
+ * @param feedbackConfidence - The corrected/validated confidence (0-1)
471
+ * @param feedbackType - Type of feedback ('correction', 'validation', 'enhancement')
472
+ */
473
+ provideFeedbackForVerbScoring(sourceId: string, targetId: string, verbType: string, feedbackWeight: number, feedbackConfidence?: number, feedbackType?: 'correction' | 'validation' | 'enhancement'): Promise<void>;
474
+ /**
475
+ * Get learning statistics from the intelligent verb scoring system
476
+ */
477
+ getVerbScoringStats(): any;
478
+ /**
479
+ * Export learning data from the intelligent verb scoring system
480
+ */
481
+ exportVerbScoringLearningData(): string | null;
482
+ /**
483
+ * Import learning data into the intelligent verb scoring system
484
+ */
485
+ importVerbScoringLearningData(jsonData: string): void;
409
486
  /**
410
487
  * Get the current augmentation name if available
411
488
  * This is used to auto-detect the service performing data operations
@@ -12,6 +12,7 @@ import { matchesMetadataFilter } from './utils/metadataFilter.js';
12
12
  import { MetadataIndexManager } from './utils/metadataIndex.js';
13
13
  import { NounType, VerbType } from './types/graphTypes.js';
14
14
  import { createServerSearchAugmentations } from './augmentations/serverSearchAugmentations.js';
15
+ import { IntelligentVerbScoring } from './augmentations/intelligentVerbScoring.js';
15
16
  import { augmentationPipeline } from './augmentationPipeline.js';
16
17
  import { prepareJsonForVectorization, extractFieldFromJson } from './utils/jsonProcessing.js';
17
18
  import { DistributedConfigManager, HashPartitioner, OperationalModeFactory, DomainDetector, HealthMonitor } from './distributed/index.js';
@@ -69,6 +70,7 @@ export class BrainyData {
69
70
  this.remoteServerConfig = null;
70
71
  this.serverSearchConduit = null;
71
72
  this.serverConnection = null;
73
+ this.intelligentVerbScoring = null;
72
74
  // Distributed mode properties
73
75
  this.distributedConfig = null;
74
76
  this.configManager = null;
@@ -198,6 +200,11 @@ export class BrainyData {
198
200
  }
199
201
  // Initialize search cache with final configuration
200
202
  this.searchCache = new SearchCache(finalSearchCacheConfig);
203
+ // Initialize intelligent verb scoring if enabled
204
+ if (config.intelligentVerbScoring?.enabled) {
205
+ this.intelligentVerbScoring = new IntelligentVerbScoring(config.intelligentVerbScoring);
206
+ this.intelligentVerbScoring.enabled = true;
207
+ }
201
208
  }
202
209
  /**
203
210
  * Check if the database is in read-only mode and throw an error if it is
@@ -542,6 +549,48 @@ export class BrainyData {
542
549
  throw error;
543
550
  }
544
551
  }
552
+ /**
553
+ * Provide feedback to the intelligent verb scoring system for learning
554
+ * This allows the system to learn from user corrections or validation
555
+ *
556
+ * @param sourceId - Source entity ID
557
+ * @param targetId - Target entity ID
558
+ * @param verbType - Relationship type
559
+ * @param feedbackWeight - The corrected/validated weight (0-1)
560
+ * @param feedbackConfidence - The corrected/validated confidence (0-1)
561
+ * @param feedbackType - Type of feedback ('correction', 'validation', 'enhancement')
562
+ */
563
+ async provideFeedbackForVerbScoring(sourceId, targetId, verbType, feedbackWeight, feedbackConfidence, feedbackType = 'correction') {
564
+ if (this.intelligentVerbScoring?.enabled) {
565
+ await this.intelligentVerbScoring.provideFeedback(sourceId, targetId, verbType, feedbackWeight, feedbackConfidence, feedbackType);
566
+ }
567
+ }
568
+ /**
569
+ * Get learning statistics from the intelligent verb scoring system
570
+ */
571
+ getVerbScoringStats() {
572
+ if (this.intelligentVerbScoring?.enabled) {
573
+ return this.intelligentVerbScoring.getLearningStats();
574
+ }
575
+ return null;
576
+ }
577
+ /**
578
+ * Export learning data from the intelligent verb scoring system
579
+ */
580
+ exportVerbScoringLearningData() {
581
+ if (this.intelligentVerbScoring?.enabled) {
582
+ return this.intelligentVerbScoring.exportLearningData();
583
+ }
584
+ return null;
585
+ }
586
+ /**
587
+ * Import learning data into the intelligent verb scoring system
588
+ */
589
+ importVerbScoringLearningData(jsonData) {
590
+ if (this.intelligentVerbScoring?.enabled) {
591
+ this.intelligentVerbScoring.importLearningData(jsonData);
592
+ }
593
+ }
545
594
  /**
546
595
  * Get the current augmentation name if available
547
596
  * This is used to auto-detect the service performing data operations
@@ -765,6 +814,13 @@ export class BrainyData {
765
814
  }
766
815
  }
767
816
  }
817
+ // Initialize intelligent verb scoring augmentation if enabled
818
+ if (this.intelligentVerbScoring) {
819
+ await this.intelligentVerbScoring.initialize();
820
+ this.intelligentVerbScoring.setBrainyInstance(this);
821
+ // Register with augmentation pipeline
822
+ augmentationPipeline.register(this.intelligentVerbScoring);
823
+ }
768
824
  this.isInitialized = true;
769
825
  this.isInitializing = false;
770
826
  // Start real-time updates if enabled
@@ -2540,6 +2596,28 @@ export class BrainyData {
2540
2596
  vector: verbVector,
2541
2597
  connections: new Map()
2542
2598
  };
2599
+ // Apply intelligent verb scoring if enabled and weight/confidence not provided
2600
+ let finalWeight = options.weight;
2601
+ let finalConfidence;
2602
+ let scoringReasoning = [];
2603
+ if (this.intelligentVerbScoring?.enabled && (!options.weight || options.weight === 0.5)) {
2604
+ try {
2605
+ const scores = await this.intelligentVerbScoring.computeVerbScores(sourceId, targetId, verbType, options.weight, options.metadata);
2606
+ finalWeight = scores.weight;
2607
+ finalConfidence = scores.confidence;
2608
+ scoringReasoning = scores.reasoning;
2609
+ if (this.loggingConfig?.verbose && scoringReasoning.length > 0) {
2610
+ console.log(`Intelligent verb scoring for ${sourceId}-${verbType}-${targetId}:`, scoringReasoning);
2611
+ }
2612
+ }
2613
+ catch (error) {
2614
+ if (this.loggingConfig?.verbose) {
2615
+ console.warn('Error in intelligent verb scoring:', error);
2616
+ }
2617
+ // Fall back to original weight
2618
+ finalWeight = options.weight;
2619
+ }
2620
+ }
2543
2621
  // Create complete verb metadata separately
2544
2622
  const verbMetadata = {
2545
2623
  sourceId: sourceId,
@@ -2548,7 +2626,12 @@ export class BrainyData {
2548
2626
  target: targetId,
2549
2627
  verb: verbType,
2550
2628
  type: verbType, // Set the type property to match the verb type
2551
- weight: options.weight,
2629
+ weight: finalWeight,
2630
+ confidence: finalConfidence, // Add confidence to metadata
2631
+ intelligentScoring: scoringReasoning.length > 0 ? {
2632
+ reasoning: scoringReasoning,
2633
+ computedAt: new Date().toISOString()
2634
+ } : undefined,
2552
2635
  createdAt: timestamp,
2553
2636
  updatedAt: timestamp,
2554
2637
  createdBy: getAugmentationVersion(service),