[PR #1253] [MERGED] fix(long-term-memory): 1.4.9 — bound per-lane recall scoring (#1250) #1368

Closed
opened 2026-10-21 05:09:53 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Agents/pull/1253
Author: @Promansis
Created: 10/7/2026
Status: ✅ Merged
Merged: 10/7/2026
Merged by: @Promansis

Base: staging ← Head: fix(long-term-memory)/1250-bounded-recall-scoring


📝 Commits (2)

  • 9686828 fix(long-term-memory): 1.4.9 — bound per-lane recall scoring (#1250)
  • 44105ef fix(long-term-memory): escape persisted keyword keys in recall matching (#1250)

📊 Changes

16 files changed (+176 additions, -91 deletions)

View changed files

➕ artifacts/long-term-memory-1.4.9.zip (+0 -0)
📝 catalog/catalog.json (+6 -6)
📝 catalog/notes.json (+6 -6)
📝 catalog/v2/catalog.json (+6 -6)
📝 catalog/v2/notes.json (+6 -6)
📝 catalog/v3/catalog.json (+6 -6)
📝 catalog/v3/notes.json (+6 -6)
📝 packages/long-term-memory/CHANGELOG.md (+5 -0)
📝 packages/long-term-memory/manifest.json (+3 -3)
📝 packages/long-term-memory/server.mjs (+43 -43)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/keyword-index.ts (+16 -2)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/ranking.ts (+2 -3)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/retrieval.ts (+2 -3)
📝 scripts/build-feature-packages.mjs (+1 -1)
📝 tests/long-term-memory-index-keys.regression.ts (+51 -0)
📝 tests/long-term-memory-runtime.regression.ts (+17 -0)

📄 Description

Pull request

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #1250

Why this change

Recall ranking was not bounded per lane, so the ranking contract broke in three ways:

  • An unbounded raw BM25 score was added on top of the fused score, so a deep lexical hit could outrank the best hit of a higher-weighted lane (balanced: semantic 0.6 beaten by lexical 0.3).
  • The keyword lane normalized against its own top hit, so a weak fuzzy match (keyword king matching inside looking) reached full keyword relevance.
  • As a result, the same threshold value meant different things per style, lane and vault size.

What changed

  • packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/ranking.ts — removed the unbounded rawScoreBoost; fused score and lane scores now use only the bounded per-lane score.
  • .../retrieval.ts and .../keyword-index.ts — the keyword lane raw score is now min(1, score / LTM_KEYWORD_MAX_SCORE) (exact-phrase ceiling) instead of score / topHit, and fuzzy keyword containment requires whole-token or word-boundary matches.
  • packages/long-term-memory/CHANGELOG.md, manifest.json, server.mjs, artifacts/long-term-memory-1.4.9.zip, catalog lanes and notes.json — version 1.4.9 with a changelog entry; package, artifact and catalogs rebuilt from source.
  • scripts/build-feature-packages.mjs — long-term-memory version 1.4.8 → 1.4.9.
  • Regressions: tests/long-term-memory-index-keys.regression.ts (fusion probes across styles, unbounded-raw invariant, keyword substring negative, fuzzy ceiling) and tests/long-term-memory-runtime.regression.ts (partial keyword match stays below the full keyword weight).
  • Review repair: keyword-index.ts now escapes regex metacharacters in persisted keyword keys before building the containment pattern, so a corrupted or foreign index key cannot make recall throw.

Package and security impact

  • Affected package IDs: long-term-memory
  • Engine compatibility impact: none (engine range and Capability API unchanged: >=2.4.1 <4.0.0, API 1.6)
  • New or changed permissions/entrypoints: none
  • Restart, storage, update, or uninstall impact: none; recall ranking only

Validation

  • node scripts/validate-catalog.mjs passes locally
  • git diff --check passes locally
  • Rebuilt every affected manifest, payload, artifact, and catalog entry
  • Installed or updated the affected package through Marinara Engine
  • Checked supported modes, restart behavior, and uninstall cleanup
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Before the fix: the balanced probe put the top vector hit (cosine 0.85) last behind ten BM25 hits (raw 18), and searchLtmKeywordIndex returned keyword:fuzzy:king at score 1.6136 for the query "I was looking for the map".
  • After the fix, on the pushed SHA: test-ltm.sh index-keys, test-ltm.sh runtime, test-ltm.sh source-task, and tests/long-term-memory-reconciliation-recall.regression.ts pass locally.
  • Review repair regression: a persisted cobalt( keyword key threw SyntaxError: Invalid regular expression ... Unterminated group before the escape; the regression now passes.
  • Repository gates pass locally: npm run check, npm run typecheck:packages, npm run test:security, node scripts/test-catalog-lanes.mjs, validate-package-locales, validate-package-locale-keys, validate-catalog, catalog-generatedat-determinism, catalog-release-notes, vendored-engine, git diff --check.
  • Rebuild provenance: node scripts/build-feature-packages.mjs long-term-memory produced the manifest, server.mjs, artifact ZIP and catalog entries committed here.
  • Not run: Engine install/browser lifecycle suites (not affected by server-side scoring); hosted CI runs on this SHA.

Documentation impact

  • No documentation changes needed
  • Updated this README catalog and package guidance
  • Updated linked Marinara Engine documentation

UI evidence (if applicable)

Not applicable: server-side recall scoring change.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Agents/pull/1253 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `fix(long-term-memory)/1250-bounded-recall-scoring` --- ### 📝 Commits (2) - [`9686828`](https://github.com/Pasta-Devs/Marinara-Agents/commit/96868284bf3d85b25e2f234d6864cc8ca8d8cff2) fix(long-term-memory): 1.4.9 — bound per-lane recall scoring (#1250) - [`44105ef`](https://github.com/Pasta-Devs/Marinara-Agents/commit/44105ef4c0f52de0bd53433b56a9d0c3387890e8) fix(long-term-memory): escape persisted keyword keys in recall matching (#1250) ### 📊 Changes **16 files changed** (+176 additions, -91 deletions) <details> <summary>View changed files</summary> ➕ `artifacts/long-term-memory-1.4.9.zip` (+0 -0) 📝 `catalog/catalog.json` (+6 -6) 📝 `catalog/notes.json` (+6 -6) 📝 `catalog/v2/catalog.json` (+6 -6) 📝 `catalog/v2/notes.json` (+6 -6) 📝 `catalog/v3/catalog.json` (+6 -6) 📝 `catalog/v3/notes.json` (+6 -6) 📝 `packages/long-term-memory/CHANGELOG.md` (+5 -0) 📝 `packages/long-term-memory/manifest.json` (+3 -3) 📝 `packages/long-term-memory/server.mjs` (+43 -43) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/keyword-index.ts` (+16 -2) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/ranking.ts` (+2 -3) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/retrieval.ts` (+2 -3) 📝 `scripts/build-feature-packages.mjs` (+1 -1) 📝 `tests/long-term-memory-index-keys.regression.ts` (+51 -0) 📝 `tests/long-term-memory-runtime.regression.ts` (+17 -0) </details> ### 📄 Description # Pull request > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #1250 ## Why this change Recall ranking was not bounded per lane, so the ranking contract broke in three ways: - An unbounded raw BM25 score was added on top of the fused score, so a deep lexical hit could outrank the best hit of a higher-weighted lane (balanced: semantic 0.6 beaten by lexical 0.3). - The keyword lane normalized against its own top hit, so a weak fuzzy match (keyword `king` matching inside `looking`) reached full keyword relevance. - As a result, the same threshold value meant different things per style, lane and vault size. ## What changed - `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/ranking.ts` — removed the unbounded `rawScoreBoost`; fused score and lane scores now use only the bounded per-lane score. - `.../retrieval.ts` and `.../keyword-index.ts` — the keyword lane raw score is now `min(1, score / LTM_KEYWORD_MAX_SCORE)` (exact-phrase ceiling) instead of `score / topHit`, and fuzzy keyword containment requires whole-token or word-boundary matches. - `packages/long-term-memory/CHANGELOG.md`, `manifest.json`, `server.mjs`, `artifacts/long-term-memory-1.4.9.zip`, catalog lanes and `notes.json` — version 1.4.9 with a changelog entry; package, artifact and catalogs rebuilt from source. - `scripts/build-feature-packages.mjs` — long-term-memory version 1.4.8 → 1.4.9. - Regressions: `tests/long-term-memory-index-keys.regression.ts` (fusion probes across styles, unbounded-raw invariant, keyword substring negative, fuzzy ceiling) and `tests/long-term-memory-runtime.regression.ts` (partial keyword match stays below the full keyword weight). - Review repair: `keyword-index.ts` now escapes regex metacharacters in persisted keyword keys before building the containment pattern, so a corrupted or foreign index key cannot make recall throw. ## Package and security impact - Affected package IDs: `long-term-memory` - Engine compatibility impact: none (engine range and Capability API unchanged: `>=2.4.1 <4.0.0`, API 1.6) - New or changed permissions/entrypoints: none - Restart, storage, update, or uninstall impact: none; recall ranking only ## Validation <!-- These are human tasks. Never tick a box for a check that was not actually performed. --> - [ ] `node scripts/validate-catalog.mjs` passes locally - [ ] `git diff --check` passes locally - [ ] Rebuilt every affected manifest, payload, artifact, and catalog entry - [ ] Installed or updated the affected package through Marinara Engine - [ ] Checked supported modes, restart behavior, and uninstall cleanup - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Before the fix: the balanced probe put the top vector hit (cosine 0.85) last behind ten BM25 hits (raw 18), and `searchLtmKeywordIndex` returned `keyword:fuzzy:king` at score 1.6136 for the query "I was looking for the map". - After the fix, on the pushed SHA: `test-ltm.sh index-keys`, `test-ltm.sh runtime`, `test-ltm.sh source-task`, and `tests/long-term-memory-reconciliation-recall.regression.ts` pass locally. - Review repair regression: a persisted `cobalt(` keyword key threw `SyntaxError: Invalid regular expression ... Unterminated group` before the escape; the regression now passes. - Repository gates pass locally: `npm run check`, `npm run typecheck:packages`, `npm run test:security`, `node scripts/test-catalog-lanes.mjs`, `validate-package-locales`, `validate-package-locale-keys`, `validate-catalog`, `catalog-generatedat-determinism`, `catalog-release-notes`, `vendored-engine`, `git diff --check`. - Rebuild provenance: `node scripts/build-feature-packages.mjs long-term-memory` produced the manifest, `server.mjs`, artifact ZIP and catalog entries committed here. - Not run: Engine install/browser lifecycle suites (not affected by server-side scoring); hosted CI runs on this SHA. ## Documentation impact - [ ] No documentation changes needed - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation ## UI evidence (if applicable) Not applicable: server-side recall scoring change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-21 05:09:53 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Agents#1368
No description provided.