[GH-ISSUE #1438] [LTM] One-syllable Korean names fail particle stripping in lexical retrieval #730

Closed
opened 2026-10-20 17:30:10 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @tlsiddl on GitHub (Oct 17, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1438

Originally assigned to: @Promansis on GitHub.

Summary

One-syllable Korean character names may fail lexical retrieval when different grammatical particles are attached.

I previously reported this edge case in #1295 and left a follow-up comment after that issue was closed.

Since the issue has already been resolved and subsequent Korean name matching improvements do not appear to cover this case, I’m opening a separate report to make it easier to track.

Affected package

Marinara LTM (Long-Term Memory)

Expected behavior

Known one-syllable Korean character names should be recognized consistently, regardless of attached grammatical particles.

For example:

  • 린이 → 린
  • 린은 → 린
  • 린에게 → 린
  • 온은 → 온

Keyword and BM25 retrieval should match these forms when the stem is a known character or persona name.

Actual behavior

The previously identified particle-stripping logic requires at least two characters to remain after removing a particle.

As a result, one-syllable names may not be normalized correctly, potentially preventing keyword/BM25 matches.

This has not yet been independently retested against the latest staging version.

Steps to reproduce

  1. Register a character/persona with the one-syllable Korean name 린.
  2. Store a memory containing 린이 웃었다.
  3. Search for 린은 뭐 했지?.
  4. Check whether the stored memory is retrieved through the keyword/BM25 lanes.
  5. Compare with a two-syllable character name under equivalent conditions.

Environment

  • Marinara Engine version: 2.5.0
  • Package version: LTM (exact installed version not confirmed)
  • Install type: Docker (self-hosted)
  • OS + version: Linux server (exact distribution/version not confirmed)
  • Browser or app shell: Mobile browser on iOS

Logs, screenshots, or video

No logs or screenshots are attached for this specific edge case.

The suspected restriction was previously identified in hangul-lexical.ts:

for (let length = 1; length <= 4 && value.length - length >= 2; length += 1)

The value.length - length >= 2 condition prevents the function from returning a one-syllable stem.

This may affect particle stripping even if one-syllable names are otherwise preserved during token extraction.

Additional context

Related:

  • #1295 — Original Korean lexical retrieval issue and previous report
  • #1296 — Korean lexical retrieval improvements
  • #1381 — Korean character name matching improvements

Suggested fix:

Allow one-syllable stems when they match a known character or persona name, while keeping the existing minimum-length restrictions for unrelated tokens to avoid false positives.

It would also be helpful to add regression tests for one-syllable names with different Korean particles.

Could you confirm whether the latest staging changes already handle this case, or whether a separate fix is still needed?

Thanks for your continued work on Korean retrieval support!

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @tlsiddl on GitHub (Oct 17, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1438 Originally assigned to: @Promansis on GitHub. Summary One-syllable Korean character names may fail lexical retrieval when different grammatical particles are attached. I previously reported this edge case in #1295 and left a follow-up comment after that issue was closed. Since the issue has already been resolved and subsequent Korean name matching improvements do not appear to cover this case, I’m opening a separate report to make it easier to track. Affected package Marinara LTM (Long-Term Memory) Expected behavior Known one-syllable Korean character names should be recognized consistently, regardless of attached grammatical particles. For example: * 린이 → 린 * 린은 → 린 * 린에게 → 린 * 온은 → 온 Keyword and BM25 retrieval should match these forms when the stem is a known character or persona name. Actual behavior The previously identified particle-stripping logic requires at least two characters to remain after removing a particle. As a result, one-syllable names may not be normalized correctly, potentially preventing keyword/BM25 matches. This has not yet been independently retested against the latest staging version. Steps to reproduce 1. Register a character/persona with the one-syllable Korean name 린. 2. Store a memory containing 린이 웃었다. 3. Search for 린은 뭐 했지?. 4. Check whether the stored memory is retrieved through the keyword/BM25 lanes. 5. Compare with a two-syllable character name under equivalent conditions. Environment * Marinara Engine version: 2.5.0 * Package version: LTM (exact installed version not confirmed) * Install type: Docker (self-hosted) * OS + version: Linux server (exact distribution/version not confirmed) * Browser or app shell: Mobile browser on iOS Logs, screenshots, or video No logs or screenshots are attached for this specific edge case. The suspected restriction was previously identified in hangul-lexical.ts: for (let length = 1; length <= 4 && value.length - length >= 2; length += 1) The value.length - length >= 2 condition prevents the function from returning a one-syllable stem. This may affect particle stripping even if one-syllable names are otherwise preserved during token extraction. Additional context Related: * #1295 — Original Korean lexical retrieval issue and previous report * #1296 — Korean lexical retrieval improvements * #1381 — Korean character name matching improvements Suggested fix: Allow one-syllable stems when they match a known character or persona name, while keeping the existing minimum-length restrictions for unrelated tokens to avoid false positives. It would also be helpful to add regression tests for one-syllable names with different Korean particles. Could you confirm whether the latest staging changes already handle this case, or whether a separate fix is still needed? Thanks for your continued work on Korean retrieval support! Template check * [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:30:10 +07:00
Author
Owner

@Promansis commented on GitHub (Oct 17, 2026):

Minimal fix

Confirmed by reading the code at upstream/staging f87531a32 (Long-Term Memory 1.4.45). It hasn't been run live.

S = packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory

Why it fails

  • BM25 never sees a bare one-syllable word. S/bm25.ts:33 skips every token of one character, so 린 on its own is never indexed or searched.
  • Particle stripping always leaves at least two syllables.
    • S/hangul-lexical.ts:43 requires two syllables to remain after the particle is removed.
    • S/bm25.ts:38 only adds a stem longer than one character.
    • So 린이, 린은 and 린에게 stay three unrelated terms.
  • The keyword lane has the same limit. S/keyword-extract.ts:222 drops Hangul keywords under two syllables. That also removes a one-syllable title from #1363's known-names set (S/retrieval.ts:166).
  • The two-syllable floor is deliberate (S/hangul-lexical.ts:9-12, :37-40).
    • Stripping down to one syllable everywhere would fold ordinary words: 나는 → 나, 그는 → 그, 집에 → 집.
    • So the fix allows a one-syllable stem only when it is a known name.

Known names

  • Source: the titles of the vault's character notes. #1363 already treats these as names. Persona profiles are character notes too: they carry a persona subject ref (fixture at tests/long-term-memory-routes.regression.ts:1388-1398).
  • Index freshness:
    • Titles are part of every chunk's hash.
    • The whole recall index is rebuilt when that hash changes (S/rebuild.ts:294-298).
    • So adding or renaming a character note already refreshes the names, with no new invalidation.

Steps

  1. S/hangul-lexical.ts: add hangulNameSyllable(token, names).
    • It returns the one-syllable name when the token is that name on its own, or the name followed by one whole particle allowed after it. The allowed particles are checked with the existing isHangulParticle final-consonant rule, so 린이, 린은, 린에게 and 린으로 fold but 린는 doesn't.
    • Otherwise it returns null.
    • stripHangulParticle and its two-syllable floor don't change.
  2. S/bm25.ts:
    • Add ltmHangulNameSyllables(chunks).
      • It returns the one-syllable Hangul words in the titles of character chunks, lowercased and NFC.
      • It takes { noteType?, title? }, so it works on both LtmMemoryChunk and index.metadata.chunks.
    • tokenizeLtmText(text, names?) pushes hangulNameSyllable(token, names) as an alias. This happens before the one-character skip, so a bare 린 counts as well.
      • Like the #1295 aliases, it isn't counted in originalCount.
      • Document lengths therefore don't change, and every score for a query without a one-syllable name stays the same.
    • buildLtmBm25Index(chunks) takes the names from its own chunks.
    • searchLtmBm25 gets an optional nameSyllables and tokenizes the query with it.
  3. S/retrieval.ts:
    • Build the same set from index.metadata.chunks and pass it to searchLtmBm25 (:150).
    • Use every character chunk, not only the allowed ones, so the query and the index use the same names.
  4. S/chunking.ts:20: bump CURRENT_LTM_CHUNK_FORMAT_VERSION from 5 to 6.
    • Stored indexes rebuild once, so existing vaults pick up the aliases. Embeddings are reused by text hash (S/rebuild.ts:69).
    • tests/long-term-memory-routes.regression.ts:1078 asserts 5 and needs updating.
  5. CHANGELOG under ## Unreleased: one-syllable Korean character and persona names now match with any particle in lexical recall when the vault has a memory profile under that name. Existing vaults rebuild their recall indexes once.

Not in this fix

  • The keyword lane.
    • BM25 alone is enough to bring the memory into recall, because the lanes are fused.
    • Fixing the keyword lane would mean passing names into chunking, since keywords are stored per chunk and capped. That changes stored keyword lists across the vault.
    • It becomes a follow-up if a retest shows BM25 isn't enough.
  • Names that exist only in Engine (a character or persona with no Long-Term Memory profile yet).
    • Recall doesn't read the Engine roster today, and the stored index can't see it.
    • A ponytail: comment in ltmHangulNameSyllables records this limit.
  • Subject identity: S/subject-identity.ts:1996 (followedByHangulParticle) and :2011 (matchDirectName) keep refusing one-syllable names.
    • That code links names to characters during extraction; it isn't retrieval.
    • Its comment says a one-syllable name is too ambiguous there.

Regression proof

Extend the #1295 block in tests/long-term-memory-index-keys.regression.ts (:718). It is already in the ltm-browser.yml regression list.

Fixtures:

  • a character chunk titled 린;
  • memory chunks with the texts 린이 웃었다, 린에게 반지를 줬다 and 린, 괜찮아?;
  • an unrelated chunk, 나는 시장에 갔다;
  • a second index with the same memory chunks but no 린 character chunk.

Checks:

  • 린은 뭐 했지?, 린을 and 린 each find all three 린 memories.
  • 나를 doesn't match 나는 시장에 갔다, because 나 isn't a name.
  • Without the character chunk, 린은 뭐 했지? finds none of them, which is today's behavior.
  • The existing #1295 review checks (document length and English scores unchanged) still pass.

Also run routes (format version 6), runtime and reconciliation-recall.

Size

  • One PR and a patch bump.
  • Model: opus. The fix changes what the stored recall index contains and makes every vault rebuild it once.
<!-- gh-comment-id:6230798290 --> @Promansis commented on GitHub (Oct 17, 2026): ## Minimal fix Confirmed by reading the code at `upstream/staging` f87531a32 (Long-Term Memory 1.4.45). It hasn't been run live. `S` = `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory` **Why it fails** - **BM25 never sees a bare one-syllable word.** `S/bm25.ts:33` skips every token of one character, so `린` on its own is never indexed or searched. - **Particle stripping always leaves at least two syllables.** - `S/hangul-lexical.ts:43` requires two syllables to remain after the particle is removed. - `S/bm25.ts:38` only adds a stem longer than one character. - So `린이`, `린은` and `린에게` stay three unrelated terms. - **The keyword lane has the same limit.** `S/keyword-extract.ts:222` drops Hangul keywords under two syllables. That also removes a one-syllable title from #1363's known-names set (`S/retrieval.ts:166`). - **The two-syllable floor is deliberate** (`S/hangul-lexical.ts:9-12`, `:37-40`). - Stripping down to one syllable everywhere would fold ordinary words: `나는` → `나`, `그는` → `그`, `집에` → `집`. - So the fix allows a one-syllable stem only when it is a known name. **Known names** - **Source:** the titles of the vault's `character` notes. #1363 already treats these as names. Persona profiles are `character` notes too: they carry a persona subject ref (fixture at `tests/long-term-memory-routes.regression.ts:1388-1398`). - **Index freshness:** - Titles are part of every chunk's hash. - The whole recall index is rebuilt when that hash changes (`S/rebuild.ts:294-298`). - So adding or renaming a character note already refreshes the names, with no new invalidation. **Steps** 1. **`S/hangul-lexical.ts`:** add `hangulNameSyllable(token, names)`. - It returns the one-syllable name when the token is that name on its own, or the name followed by one whole particle allowed after it. The allowed particles are checked with the existing `isHangulParticle` final-consonant rule, so `린이`, `린은`, `린에게` and `린으로` fold but `린는` doesn't. - Otherwise it returns null. - `stripHangulParticle` and its two-syllable floor don't change. 2. **`S/bm25.ts`:** - Add `ltmHangulNameSyllables(chunks)`. - It returns the one-syllable Hangul words in the titles of `character` chunks, lowercased and NFC. - It takes `{ noteType?, title? }`, so it works on both `LtmMemoryChunk` and `index.metadata.chunks`. - `tokenizeLtmText(text, names?)` pushes `hangulNameSyllable(token, names)` as an alias. This happens before the one-character skip, so a bare `린` counts as well. - Like the #1295 aliases, it isn't counted in `originalCount`. - Document lengths therefore don't change, and every score for a query without a one-syllable name stays the same. - `buildLtmBm25Index(chunks)` takes the names from its own chunks. - `searchLtmBm25` gets an optional `nameSyllables` and tokenizes the query with it. 3. **`S/retrieval.ts`:** - Build the same set from `index.metadata.chunks` and pass it to `searchLtmBm25` (`:150`). - Use every character chunk, not only the allowed ones, so the query and the index use the same names. 4. **`S/chunking.ts:20`:** bump `CURRENT_LTM_CHUNK_FORMAT_VERSION` from 5 to 6. - Stored indexes rebuild once, so existing vaults pick up the aliases. Embeddings are reused by text hash (`S/rebuild.ts:69`). - `tests/long-term-memory-routes.regression.ts:1078` asserts 5 and needs updating. 5. **CHANGELOG under `## Unreleased`:** one-syllable Korean character and persona names now match with any particle in lexical recall when the vault has a memory profile under that name. Existing vaults rebuild their recall indexes once. **Not in this fix** - **The keyword lane.** - BM25 alone is enough to bring the memory into recall, because the lanes are fused. - Fixing the keyword lane would mean passing names into chunking, since keywords are stored per chunk and capped. That changes stored keyword lists across the vault. - It becomes a follow-up if a retest shows BM25 isn't enough. - **Names that exist only in Engine** (a character or persona with no Long-Term Memory profile yet). - Recall doesn't read the Engine roster today, and the stored index can't see it. - A `ponytail:` comment in `ltmHangulNameSyllables` records this limit. - **Subject identity:** `S/subject-identity.ts:1996` (`followedByHangulParticle`) and `:2011` (`matchDirectName`) keep refusing one-syllable names. - That code links names to characters during extraction; it isn't retrieval. - Its comment says a one-syllable name is too ambiguous there. ## Regression proof Extend the #1295 block in `tests/long-term-memory-index-keys.regression.ts` (`:718`). It is already in the `ltm-browser.yml` regression list. Fixtures: - a `character` chunk titled `린`; - memory chunks with the texts `린이 웃었다`, `린에게 반지를 줬다` and `린, 괜찮아?`; - an unrelated chunk, `나는 시장에 갔다`; - a second index with the same memory chunks but no `린` character chunk. Checks: - `린은 뭐 했지?`, `린을` and `린` each find all three `린` memories. - `나를` doesn't match `나는 시장에 갔다`, because `나` isn't a name. - Without the character chunk, `린은 뭐 했지?` finds none of them, which is today's behavior. - The existing #1295 review checks (document length and English scores unchanged) still pass. Also run `routes` (format version 6), `runtime` and `reconciliation-recall`. ## Size - One PR and a patch bump. - Model: opus. The fix changes what the stored recall index contains and makes every vault rebuild it once.
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#730
No description provided.