[PR #1440] [MERGED] fix(long-term-memory): match one-syllable Korean names across particles (1.4.46) #1463

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

📋 Pull Request Information

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

Base: staging ← Head: fix(long-term-memory)/1438-korean-one-syllable-names


📝 Commits (3)

  • 249c663 fix(long-term-memory): match one-syllable Korean names with particles in BM25 recall (#1438)
  • c1f0edc chore(long-term-memory): release 1.4.46 (#1438)
  • 2be1ff3 fix(long-term-memory): keep a bare-name-only BM25 index searchable (#1438)

📊 Changes

17 files changed (+196 additions, -89 deletions)

View changed files

➕ artifacts/long-term-memory-1.4.46.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 (+4 -0)
📝 packages/long-term-memory/manifest.json (+3 -3)
📝 packages/long-term-memory/server.mjs (+36 -36)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/bm25.ts (+43 -7)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/chunking.ts (+3 -2)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/hangul-lexical.ts (+13 -0)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/retrieval.ts (+7 -2)
📝 scripts/build-feature-packages.mjs (+1 -1)
📝 tests/long-term-memory-index-keys.regression.ts (+49 -1)
📝 tests/long-term-memory-routes.regression.ts (+1 -1)

📄 Description

Linked issue

Closes #1438

Why this change

A one-syllable Korean character or persona name such as 린 never matched across particles in recall. A memory that says 린이 웃었다 was not found for 린은 뭐 했지?. There were two reasons:

  • BM25 skips every one-character token, so a bare 린 was never indexed or searched.
  • Particle stripping deliberately keeps at least two syllables. So 린이, 린은 and 린에게 stayed three unrelated terms.

That two-syllable floor stays. Lowering it everywhere would merge ordinary words such as 나는 → 나 and 그는 → 그. Instead, a word may drop to one syllable only when it is a known name.

What changed

 rebuild → buildLtmBm25Index(chunks)
+  names = ltmHangulNameSyllables(chunks)    one-syllable Hangul words in `character` titles (NFC)
   for each chunk
-    tokenizeLtmText(text)
+    tokenizeLtmText(text, names)

 retrieveLongTermMemory
-  searchLtmBm25(index.bm25, query, { allowedChunks })
+  searchLtmBm25(index.bm25, query, { allowedChunks,
+    nameSyllables: ltmHangulNameSyllables(all index.metadata.chunks) })   same names as the index

 tokenizeLtmText(text, names?)
   for each token
+    name = hangulNameSyllable(token, names)  token is the name alone, or name + one particle
+    if name: push name                       its final consonant allows (린이 린은 린을 린에게 린으로)
+                                             alias only, not counted in document length
     if token is one character: skip
     push token, particle-stripped stem (two-syllable floor unchanged), Hangul bigram
  • hangul-lexical.ts adds hangulNameSyllable. It reuses the existing final-consonant particle rule, so 린는 and 린로 don't fold. stripHangulParticle is unchanged.
  • bm25.ts adds ltmHangulNameSyllables and a names argument to tokenizeLtmText, and searchLtmBm25 gets an optional nameSyllables.
    • A ponytail: comment records the known limit: a name that exists only in Engine, with no character memory yet, is not seen.
    • Persona profiles are character notes, so they count.
  • retrieval.ts builds the names from every character chunk, not only the allowed ones. That way the query and the stored index always use the same names.
  • chunking.ts: CURRENT_LTM_CHUNK_FORMAT_VERSION goes from 5 to 6, so stored recall indexes rebuild once and pick up the aliases.
    • A character note's title is already part of every chunk hash, so adding or renaming a character later rebuilds the index with no new invalidation.
  • long-term-memory 1.4.46: CHANGELOG entry, version, manifest, rebuilt server.mjs, artifact and catalog entries.
    • The release note was reworded at land after local review. It no longer says that "any particle" works, and it says "character memory" as the app does.

Not in this PR, as the issue's Minimal fix says:

  • The keyword lane. BM25 alone brings the memory into fused recall.
  • Names that exist only in Engine.
  • Subject identity in subject-identity.ts. It still refuses one-syllable names during extraction.

Package and security impact

  • Affected package IDs: long-term-memory
  • Engine compatibility impact: none
  • New or changed permissions/entrypoints: none
  • Restart, storage, update, or uninstall impact:
    • Storage: each vault rebuilds its recall index (recall.json) once after the update, through the existing locked freshness check. Embeddings are reused by text hash, so the rebuild re-embeds nothing. Notes are not touched.
    • Scores: queries without a one-syllable name score exactly as before, because aliases don't change document lengths and the regression checks this.
    • Merge danger: two-way door. Rolling back rebuilds the index once more at format 5. The blast radius is lexical recall in vaults whose character titles contain one-syllable Hangul words.
    • Known broadness, from the approved plan: every one-syllable word in a multi-word title counts as a name. For example, a title 그 남자 makes 그는 match 그를. This only adds low-weight lexical candidates.

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

These checks were run by the coding agent, not by a person. Engine checkout 2039583ca, Node v24.15.0.

  • The #1295 block in tests/long-term-memory-index-keys.regression.ts gains a #1438 case. Its fixtures are a character chunk titled 린, the memories 린이 웃었다, 린에게 반지를 줬다 and 린, 괜찮아?, the unrelated 나는 시장에 갔다, and a second index without the character chunk. It checks:
    • 린은 뭐 했지?, 린을 and 린 each find all three 린 memories.
    • 린는 and 나를 find nothing.
    • Without the character chunk, nothing is found, which is today's behavior.
    • Document lengths are the same with and without the name.
  • Before: on the unfixed source, searchLtmBm25 returns [] for 린은 뭐 했지? against those memories.
    After: the test exits 0.
  • A temporary probe called retrieveLongTermMemory with BM25 only and recalled exactly the three 린 memories. The probe is not committed.
  • On the source commit, these passed: test-ltm.sh index-keys, runtime and routes (which asserts format version 6), plus reconciliation-recall, local-characters, storage, branch-recall and candidate-reconciliation.
  • On release HEAD c1f0edc69, these all passed:
    • A package rebuild, which left the tree clean, so the committed outputs match the source.
    • test-fast.sh (npm run check, git diff --check) and typecheck-packages long-term-memory.
    • test-catalog-lanes, validate-package-locales, validate-catalog and catalog-release-notes.
    • test-ltm.sh index-keys, runtime and routes, plus reconciliation-recall.
  • Not done: a live retest in Engine with a 린 character, and test-ltm.sh installation for the 1.4.46 artifact. Hosted CI runs the full Long-Term Memory regression list.

Documentation impact

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

UI evidence (if applicable)

None. Nothing changes on screen.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Text search now recognizes one-syllable Korean character names in memory titles, both alone and with supported particles. Other endings and unrelated one-syllable words are not included.
  • Improvements
    • Existing vaults rebuild the recall index once to apply the updated search behavior.

🔄 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/1440 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `fix(long-term-memory)/1438-korean-one-syllable-names` --- ### 📝 Commits (3) - [`249c663`](https://github.com/Pasta-Devs/Marinara-Agents/commit/249c663975ecf72f959436ea1d5807104858c9ec) fix(long-term-memory): match one-syllable Korean names with particles in BM25 recall (#1438) - [`c1f0edc`](https://github.com/Pasta-Devs/Marinara-Agents/commit/c1f0edc69a45860d1ddb7ba75a1232033506a6b3) chore(long-term-memory): release 1.4.46 (#1438) - [`2be1ff3`](https://github.com/Pasta-Devs/Marinara-Agents/commit/2be1ff34a65be105d89b14e7e80e7dc985bfefdc) fix(long-term-memory): keep a bare-name-only BM25 index searchable (#1438) ### 📊 Changes **17 files changed** (+196 additions, -89 deletions) <details> <summary>View changed files</summary> ➕ `artifacts/long-term-memory-1.4.46.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` (+4 -0) 📝 `packages/long-term-memory/manifest.json` (+3 -3) 📝 `packages/long-term-memory/server.mjs` (+36 -36) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/bm25.ts` (+43 -7) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/chunking.ts` (+3 -2) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/hangul-lexical.ts` (+13 -0) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/retrieval.ts` (+7 -2) 📝 `scripts/build-feature-packages.mjs` (+1 -1) 📝 `tests/long-term-memory-index-keys.regression.ts` (+49 -1) 📝 `tests/long-term-memory-routes.regression.ts` (+1 -1) </details> ### 📄 Description ## Linked issue Closes #1438 ## Why this change A one-syllable Korean character or persona name such as 린 never matched across particles in recall. A memory that says 린이 웃었다 was not found for 린은 뭐 했지?. There were two reasons: - BM25 skips every one-character token, so a bare 린 was never indexed or searched. - Particle stripping deliberately keeps at least two syllables. So 린이, 린은 and 린에게 stayed three unrelated terms. That two-syllable floor stays. Lowering it everywhere would merge ordinary words such as 나는 → 나 and 그는 → 그. Instead, a word may drop to one syllable only when it is a known name. ## What changed ```diff rebuild → buildLtmBm25Index(chunks) + names = ltmHangulNameSyllables(chunks) one-syllable Hangul words in `character` titles (NFC) for each chunk - tokenizeLtmText(text) + tokenizeLtmText(text, names) retrieveLongTermMemory - searchLtmBm25(index.bm25, query, { allowedChunks }) + searchLtmBm25(index.bm25, query, { allowedChunks, + nameSyllables: ltmHangulNameSyllables(all index.metadata.chunks) }) same names as the index tokenizeLtmText(text, names?) for each token + name = hangulNameSyllable(token, names) token is the name alone, or name + one particle + if name: push name its final consonant allows (린이 린은 린을 린에게 린으로) + alias only, not counted in document length if token is one character: skip push token, particle-stripped stem (two-syllable floor unchanged), Hangul bigram ``` - `hangul-lexical.ts` adds `hangulNameSyllable`. It reuses the existing final-consonant particle rule, so 린는 and 린로 don't fold. `stripHangulParticle` is unchanged. - `bm25.ts` adds `ltmHangulNameSyllables` and a `names` argument to `tokenizeLtmText`, and `searchLtmBm25` gets an optional `nameSyllables`. - A `ponytail:` comment records the known limit: a name that exists only in Engine, with no character memory yet, is not seen. - Persona profiles are `character` notes, so they count. - `retrieval.ts` builds the names from every character chunk, not only the allowed ones. That way the query and the stored index always use the same names. - `chunking.ts`: `CURRENT_LTM_CHUNK_FORMAT_VERSION` goes from 5 to 6, so stored recall indexes rebuild once and pick up the aliases. - A character note's title is already part of every chunk hash, so adding or renaming a character later rebuilds the index with no new invalidation. - `long-term-memory` 1.4.46: CHANGELOG entry, version, manifest, rebuilt `server.mjs`, artifact and catalog entries. - The release note was reworded at land after local review. It no longer says that "any particle" works, and it says "character memory" as the app does. Not in this PR, as the issue's Minimal fix says: - **The keyword lane.** BM25 alone brings the memory into fused recall. - **Names that exist only in Engine.** - **Subject identity in `subject-identity.ts`.** It still refuses one-syllable names during extraction. ## Package and security impact - Affected package IDs: `long-term-memory` - Engine compatibility impact: none - New or changed permissions/entrypoints: none - Restart, storage, update, or uninstall impact: - **Storage:** each vault rebuilds its recall index (`recall.json`) once after the update, through the existing locked freshness check. Embeddings are reused by text hash, so the rebuild re-embeds nothing. Notes are not touched. - **Scores:** queries without a one-syllable name score exactly as before, because aliases don't change document lengths and the regression checks this. - **Merge danger:** two-way door. Rolling back rebuilds the index once more at format 5. The blast radius is lexical recall in vaults whose character titles contain one-syllable Hangul words. - **Known broadness, from the approved plan:** every one-syllable word in a multi-word title counts as a name. For example, a title 그 남자 makes 그는 match 그를. This only adds low-weight lexical candidates. ## 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 These checks were run by the coding agent, not by a person. Engine checkout `2039583ca`, Node `v24.15.0`. - The #1295 block in `tests/long-term-memory-index-keys.regression.ts` gains a #1438 case. Its fixtures are a character chunk titled 린, the memories 린이 웃었다, 린에게 반지를 줬다 and 린, 괜찮아?, the unrelated 나는 시장에 갔다, and a second index without the character chunk. It checks: - 린은 뭐 했지?, 린을 and 린 each find all three 린 memories. - 린는 and 나를 find nothing. - Without the character chunk, nothing is found, which is today's behavior. - Document lengths are the same with and without the name. - **Before:** on the unfixed source, `searchLtmBm25` returns `[]` for 린은 뭐 했지? against those memories. **After:** the test exits 0. - A temporary probe called `retrieveLongTermMemory` with BM25 only and recalled exactly the three 린 memories. The probe is not committed. - On the source commit, these passed: `test-ltm.sh index-keys`, `runtime` and `routes` (which asserts format version 6), plus `reconciliation-recall`, `local-characters`, `storage`, `branch-recall` and `candidate-reconciliation`. - On release HEAD `c1f0edc69`, these all passed: - A package rebuild, which left the tree clean, so the committed outputs match the source. - `test-fast.sh` (`npm run check`, `git diff --check`) and `typecheck-packages long-term-memory`. - `test-catalog-lanes`, `validate-package-locales`, `validate-catalog` and `catalog-release-notes`. - `test-ltm.sh index-keys`, `runtime` and `routes`, plus `reconciliation-recall`. - Not done: a live retest in Engine with a 린 character, and `test-ltm.sh installation` for the 1.4.46 artifact. Hosted CI runs the full Long-Term Memory regression list. ## Documentation impact - [ ] No documentation changes needed - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation ## UI evidence (if applicable) None. Nothing changes on screen. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Text search now recognizes one-syllable Korean character names in memory titles, both alone and with supported particles. Other endings and unrelated one-syllable words are not included. * **Improvements** * Existing vaults rebuild the recall index once to apply the updated search behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-21 05:11:45 +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#1463
No description provided.