@oh-my-pi/pi-mnemopi 18.11.1 → 18.11.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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [18.11.2] - 2026-10-16
6
+
7
+ ### Fixed
8
+
9
+ - Fixed `MNEMOPI_<LABEL>_WEIGHT` and `MNEMOPI_TIER<N>_WEIGHT` having no effect on recall ranking ([#13824](https://github.com/can1357/oh-my-pi/pull/13824) by [@sjawhar](https://github.com/sjawhar))
10
+
5
11
  ## [18.11.1] - 2026-10-15
6
12
 
7
13
  ### Fixed
@@ -56,8 +56,11 @@ export declare function scratchpadMaxItems(env?: Env): number;
56
56
  export declare function recencyHalflifeHours(env?: Env): number;
57
57
  export declare function tier2Days(env?: Env): number;
58
58
  export declare function tier3Days(env?: Env): number;
59
+ /** Recall-time score multiplier for an episodic row still at degradation tier 1. */
59
60
  export declare function tier1Weight(env?: Env): number;
61
+ /** Recall-time score multiplier for an episodic row degraded to tier 2. */
60
62
  export declare function tier2Weight(env?: Env): number;
63
+ /** Recall-time score multiplier for an episodic row degraded to tier 3 or beyond. */
61
64
  export declare function tier3Weight(env?: Env): number;
62
65
  export declare function degradeBatchSize(env?: Env): number;
63
66
  export declare function smartCompressEnabled(env?: Env): boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-mnemopi",
4
- "version": "18.11.1",
4
+ "version": "18.11.2",
5
5
  "description": "Local SQLite memory engine for omp agents",
6
6
  "homepage": "https://omp.sh",
7
7
  "author": {
@@ -42,10 +42,10 @@
42
42
  "fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
43
43
  },
44
44
  "dependencies": {
45
- "@oh-my-pi/pi-ai": "18.11.1",
46
- "@oh-my-pi/pi-catalog": "18.11.1",
47
- "@oh-my-pi/pi-natives": "18.11.1",
48
- "@oh-my-pi/pi-utils": "18.11.1"
45
+ "@oh-my-pi/pi-ai": "18.11.2",
46
+ "@oh-my-pi/pi-catalog": "18.11.2",
47
+ "@oh-my-pi/pi-natives": "18.11.2",
48
+ "@oh-my-pi/pi-utils": "18.11.2"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "fastembed": "3.0.0",
package/src/config.ts CHANGED
@@ -170,16 +170,19 @@ export function tier3Days(env: Env = process.env): number {
170
170
  return envInt("MNEMOPI_TIER3_DAYS", 180, env);
171
171
  }
172
172
 
173
+ /** Recall-time score multiplier for an episodic row still at degradation tier 1. */
173
174
  export function tier1Weight(env: Env = process.env): number {
174
175
  return envFloat("MNEMOPI_TIER1_WEIGHT", 1.0, env);
175
176
  }
176
177
 
178
+ /** Recall-time score multiplier for an episodic row degraded to tier 2. */
177
179
  export function tier2Weight(env: Env = process.env): number {
178
- return envFloat("MNEMOPI_TIER2_WEIGHT", 0.5, env);
180
+ return envFloat("MNEMOPI_TIER2_WEIGHT", 0.85, env);
179
181
  }
180
182
 
183
+ /** Recall-time score multiplier for an episodic row degraded to tier 3 or beyond. */
181
184
  export function tier3Weight(env: Env = process.env): number {
182
- return envFloat("MNEMOPI_TIER3_WEIGHT", 0.25, env);
185
+ return envFloat("MNEMOPI_TIER3_WEIGHT", 0.7, env);
183
186
  }
184
187
 
185
188
  export function degradeBatchSize(env: Env = process.env): number {
@@ -1,5 +1,17 @@
1
1
  import { popLoopPhase, pushLoopPhase, withLoopPhase } from "@oh-my-pi/pi-utils";
2
- import { normalizedRecallWeights, polyphonicRecallEnabled, temporalHalflifeHours } from "../../config";
2
+ import {
3
+ importedWeight,
4
+ inferredWeight,
5
+ normalizedRecallWeights,
6
+ polyphonicRecallEnabled,
7
+ statedWeight,
8
+ temporalHalflifeHours,
9
+ tier1Weight,
10
+ tier2Weight,
11
+ tier3Weight,
12
+ toolWeight,
13
+ unknownWeight,
14
+ } from "../../config";
3
15
  import { hasCjk, matchesWordForm } from "../../util/regex";
4
16
  import { embedQuery } from "../embeddings";
5
17
  import { mmrRerank } from "../mmr";
@@ -63,16 +75,33 @@ type RecallMmrItem = {
63
75
  readonly [key: string]: unknown;
64
76
  };
65
77
 
66
- const VERACITY_WEIGHTS: Record<string, number> = {
67
- stated: 1.0,
68
- true: 1.0,
69
- likely_true: 1.0,
70
- unknown: 0.8,
71
- inferred: 0.7,
72
- imported: 0.6,
73
- tool: 0.5,
74
- false: 0,
75
- };
78
+ /**
79
+ * Score multipliers for a candidate's stored `veracity` label and, for episodic
80
+ * rows, its degradation tier. Resolved once per {@link recall} from the
81
+ * `MNEMOPI_<LABEL>_WEIGHT` and `MNEMOPI_TIER<N>_WEIGHT` readers in `config.ts`,
82
+ * clamped at 0 like the hybrid weights so a negative value cannot rank a row
83
+ * below one labelled `false`; `true`, `likely_true` and `false` have no override.
84
+ */
85
+ interface TrustWeights {
86
+ readonly veracity: Readonly<Record<string, number>> & { readonly unknown: number };
87
+ readonly tiers: readonly [tier1: number, tier2: number, tier3: number];
88
+ }
89
+
90
+ function resolveTrustWeights(): TrustWeights {
91
+ return {
92
+ veracity: {
93
+ stated: Math.max(0, statedWeight()),
94
+ true: 1.0,
95
+ likely_true: 1.0,
96
+ unknown: Math.max(0, unknownWeight()),
97
+ inferred: Math.max(0, inferredWeight()),
98
+ imported: Math.max(0, importedWeight()),
99
+ tool: Math.max(0, toolWeight()),
100
+ false: 0,
101
+ },
102
+ tiers: [Math.max(0, tier1Weight()), Math.max(0, tier2Weight()), Math.max(0, tier3Weight())],
103
+ };
104
+ }
76
105
 
77
106
  /**
78
107
  * Default per-result content preview cap enforced by {@link recall}. Content
@@ -671,6 +700,7 @@ function scoreCandidate(
671
700
  queryTokens: readonly string[],
672
701
  queryGroups: readonly (readonly string[])[],
673
702
  weights: readonly [number, number, number],
703
+ trust: TrustWeights,
674
704
  options: RecallOptionsInternal,
675
705
  ): RecallResult | null {
676
706
  const content = asString(candidate.row.content);
@@ -714,11 +744,11 @@ function scoreCandidate(
714
744
  score *= 1 + temporalWeight * temporalScore;
715
745
  }
716
746
  const veracity = asString(candidate.row.veracity) || "unknown";
717
- const veracityWeight = VERACITY_WEIGHTS[veracity] ?? VERACITY_WEIGHTS.unknown ?? 0.8;
747
+ const veracityWeight = trust.veracity[veracity] ?? trust.veracity.unknown;
718
748
  const degradationTier = candidate.tierLabel === "episodic" ? asNumber(candidate.row.tier, 1) : undefined;
719
749
  if (candidate.tierLabel === "episodic") {
720
- const tierWeight = degradationTier === 1 ? 1 : degradationTier === 2 ? 0.85 : 0.7;
721
- score *= tierWeight;
750
+ const [tier1, tier2, tier3] = trust.tiers;
751
+ score *= degradationTier === 1 ? tier1 : degradationTier === 2 ? tier2 : tier3;
722
752
  }
723
753
  score *= veracityWeight * currentContentAdjustment(searchableContent, options.currentSensitive === true);
724
754
  const preview = clipRecallContent(content, options.contentPreviewChars ?? RECALL_CONTENT_PREVIEW_CHARS);
@@ -938,9 +968,10 @@ export async function recall(
938
968
  const tokens = expandedTokens(query, useSynonyms);
939
969
  const tokenGroups = expandedTokenGroups(query, useSynonyms);
940
970
  const candidates = collectMemoryCandidates(beam, query, topK, temporalOptions);
971
+ const trust = resolveTrustWeights();
941
972
  const scored: RecallResult[] = [];
942
973
  for (const candidate of candidates) {
943
- const result = scoreCandidate(candidate, tokens, tokenGroups, weights, temporalOptions);
974
+ const result = scoreCandidate(candidate, tokens, tokenGroups, weights, trust, temporalOptions);
944
975
  if (result !== null) scored.push(result);
945
976
  }
946
977
  scored.sort((left, right) => (right.score ?? 0) - (left.score ?? 0));