brain-memory 0.1.0-beta.34 → 0.1.0-beta.36

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/src/scorer.js CHANGED
@@ -7,6 +7,8 @@
7
7
  * by external tools.
8
8
  */
9
9
 
10
+ const { trustFactor } = require('./provenance');
11
+
10
12
  /**
11
13
  * Compute the effective (decayed) strength of a memory.
12
14
  *
@@ -407,9 +409,14 @@ function rankMemories(memories, relevanceFn, options = {}) {
407
409
  const sources = options.relevanceFloor != null
408
410
  ? scored.filter((m) => m.relevance >= options.relevanceFloor)
409
411
  : scored;
412
+ // Source strength is damped by origin trust: a clique of co-tagged
413
+ // low-trust memories (planted writes auto-link via tag_overlap edges)
414
+ // must not self-amplify past trusted memories through activation alone.
410
415
  const scoredSummary = sources.map((m) => ({
411
416
  id: m.id,
412
- score: 0.55 * m.relevance + 0.30 * m.decayed_strength + 0.15 * m.recency_bonus,
417
+ score:
418
+ (0.55 * m.relevance + 0.30 * m.decayed_strength + 0.15 * m.recency_bonus) *
419
+ trustFactor(m.origin),
413
420
  }));
414
421
 
415
422
  const bonuses = computeSpreadingActivationBatch(
@@ -446,12 +453,16 @@ function rankMemories(memories, relevanceFn, options = {}) {
446
453
  if (mem.context_match > 0) extras.contextMatch = mem.context_match;
447
454
  if (mem.salience != null) extras.salience = mem.salience;
448
455
 
456
+ // Origin trust multiplies the composite: trust bounds entrenchment and
457
+ // volume, not relevance — a clearly more relevant low-trust memory can
458
+ // still win, but it can't win on bulk. Missing origin weighs as the
459
+ // memorize default, so legacy memories keep their relative order.
449
460
  const score = fin(computeRecallScore(
450
461
  mem.relevance,
451
462
  mem.decayed_strength,
452
463
  mem.recency_bonus,
453
464
  extras
454
- ));
465
+ )) * trustFactor(mem.origin);
455
466
 
456
467
  return {
457
468
  ...mem,