Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(mentions): Hangul names end at a title, particle or copula suffix; KEY_FILES entries; placeholder CJK fixtures
garrytanb411ec7bdfc5
diff --git a/docs/architecture/key-files/core-utilities-1.md b/docs/architecture/key-files/core-utilities-1.mdindex 5512f84f7d..1db59b6661 100644--- a/docs/architecture/key-files/core-utilities-1.md+++ b/docs/architecture/key-files/core-utilities-1.md@@ -30,7 +30,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL- `src/core/dry-fix.ts` — `gbrain doctor --fix` engine. `autoFixDryViolations(fixes, {dryRun})` rewrites inlined rules to `> **Convention:** see [path](../path).` callouts via three shape-aware expanders (bullet / blockquote / paragraph). Five guards: working-tree-dirty (`getWorkingTreeStatus()` 3-state `'clean' | 'dirty' | 'not_a_repo'`), no-git-backup, inside-code-fence, already-delegated (40-line proximity, consistent with detector), ambiguous-multi-match, block-is-callout. `execFileSync` array args (no shell, no injection surface). EOF newline preserved. Safety primitives are in `src/core/skill-fix-gates.ts` (back-compat re-exports preserved). `MISSING_RULE_PATTERNS` INSERT pattern type lives alongside REPLACE patterns — same auto-fix entry point + git-safety gates, but places a canonical callout at a target offset (`after-h1-paragraph` only). First INSERT pattern is `brain_first`, auto-inserting `> **Convention:** see [conventions/brain-first.md](../../conventions/brain-first.md) for the lookup chain (search → query → get_page → external).` on any flagged SKILL.md whose verdict is `missing_brain_first`. Idempotent — re-runs detect the existing callout and skip.-- `src/core/enrichment-service.ts` — Global enrichment service: entity slug generation, tier auto-escalation, batch throttling. Write path is trust-gated: `enrichEntity` / `enrichEntities` / `extractAndEnrich` take `EnrichmentTrustOptions { trusted?, sourceId? }`; only an explicit `trusted: true` writes authoritative `people/` / `companies/` stubs. Anything else (undefined/false — fail-closed, mirroring `OperationContext.remote`) creates the stub with the extraction quarantine markers from `src/core/extraction-review.ts` and reports `quarantined: true` in `EnrichmentResult`. The ONLY sanctioned op surface is `extract_entities` (operations.ts), which grants `trusted` solely for `ctx.remote === false` callers passing `--trusted-extraction`.+- `src/core/enrichment-service.ts` — Global enrichment service: entity slug generation, tier auto-escalation, batch throttling. `slugifyEntity` keeps letters of every script (accents folded, NFC); before minting a page, `enrichEntity` reuses one at `legacyAsciiEntitySlug` (the old ASCII-only slug) only within the same source and only when that page's title names the entity, since the legacy slug is lossy. Write path is trust-gated: `enrichEntity` / `enrichEntities` / `extractAndEnrich` take `EnrichmentTrustOptions { trusted?, sourceId? }`; only an explicit `trusted: true` writes authoritative `people/` / `companies/` stubs. Anything else (undefined/false — fail-closed, mirroring `OperationContext.remote`) creates the stub with the extraction quarantine markers from `src/core/extraction-review.ts` and reports `quarantined: true` in `EnrichmentResult`. The ONLY sanctioned op surface is `extract_entities` (operations.ts), which grants `trusted` solely for `ctx.remote === false` callers passing `--trusted-extraction`.- `src/core/env-number.ts` — numeric env-var resolution with ONE shared warn-once memo. `resolveEnvNumber(varName, fallback, {unit?})` (positive numbers only; zero/negative/garbage → warn once + fallback), `resolveHoursEnv` (hours unit pre-applied), `warnOnceForEnv(varName, message)` for disabled-unless-set vars that need the same memo without the fallback shape (e.g. `GBRAIN_EXTRACTION_LAG_FAIL_PCT`). Lives in core because `source-health.ts` needs the hours resolver for the staleness ceiling while `doctor.ts` already imports FROM `source-health.ts` — reaching back would cycle, and duplicating would fork the memo so one bad var warns twice. `doctor.ts` re-exports it as `_resolveEnvNumber` for `sync.ts`'s dynamic import. `_resetEnvNumberWarnedForTests()` is a test seam.diff --git a/docs/architecture/key-files/entity-recall.md b/docs/architecture/key-files/entity-recall.mdindex fdfd207d9e..b59cf8735e 100644--- a/docs/architecture/key-files/entity-recall.md+++ b/docs/architecture/key-files/entity-recall.md@@ -5,6 +5,7 @@ subject, frontmatter alias or declared code) to that entity page, keeps thelinks current from `gbrain extract --stale`, and serves them on the `entity`card and `get_backlinks`. Guide: [entity recall](../../guides/entity-recall.md).+- `src/core/by-mention.ts` — the pure mention matcher plus its gazetteer. `buildGazetteer(engine, opts)` loads linkable entity titles and aliases per source (drops below-minimum, generic, ambiguous-first-word and colliding names, reported as `DroppedName`), keyed by lowercase first token and sorted longest-first. `findMentionedEntities(text, gazetteer, opts)` masks code with `stripCodeBlocks`, then picks the longest matching entry at each token (maximal munch), first mention per target only, skipping self-links and other sources unless `allowCrossSource` (an own-source twin wins). Word-run scripts match whole tokens; Han and Kana match character substrings. A Hangul name must start a word, keep its written spacing, and end at a non-Hangul character or an attached title/particle/copula suffix (`HANGUL_NAME_SUFFIX_RE`), so 지원에게 matches and 지원하는 does not ([measurement](../../designs/hangul-mention-boundaries.md)). `hashGazetteer` fingerprints entries plus a matcher-semantics version, so a matcher change re-scans resumed pages. `scanStaleMentions` is the read-only doctor scan for mention rows the current gazetteer no longer produces.- `src/core/mentions/policy.ts` — the one linkable-type resolver. `linkableTypesFor(pack, policy)`: `person`, `company`, `organization`, `entity` (`ALWAYS_LINKABLE_TYPES`, never removable) plus every pack type with `primitive: entity` and its type aliases (`product` excluded), adjusted by `mentions.entity_types` (`+type`/`type` adds, `-type` removes). `readMentionPolicy` reads `auto_link`, `mentions.auto_link`, `mentions.entity_types`, `mentions.ignore` (JSON array or comma list, `parseNameList`). `canonicalTypeOf` / `typeAliasPairs` map a stored type through the pack's type aliases (`untyped` for none); pairs are bound as two `text[]`. `loadSourcePack(engine, sourceId, {strict})` returns null on a resolution failure unless strict. Tests: `test/mentions-policy-aliases.test.ts`.- `src/core/mentions/aliases.ts` — derived names of an entity page. `titleSubject` (text after the last `: `), `declaredNames` (the `account code` / `also known as` / `a.k.a.` / `aka` / `short name` / `ticker` / `code name` parser shared with search's `aliasDeclarations`), `deriveEntityAliases` (subject `origin='subject'`, declarations `origin='declared'`, read from `publicBody`: private takes and facts fences stripped; a single-token declaration is `case_sensitive`). `aliasRejection`: under 4 characters, a generic word, or the first word of the page's own multi-word name. Rejections are returned for explain. Tests: `test/mentions-policy-aliases.test.ts`.- `src/core/mentions/pass.ts` — `runMentionPass(engine, {sourceId?, deadline?, signal?, beforePublish?})`, run by `extractStaleFromDB` (unmanaged) and `extractManagedStaleLinks` (managed, unless `mentions: false`). Per source: policy off → `disableSource` deletes plain mention links (`link_kind` null or `plain`; `typed_ner` stays), derived alias rows, saved entries and page state once and records `disabled`; a changed policy fingerprint (types, cross-source flag, ignore list) marks every page due; `refreshAliases` rewrites derived rows of entity pages whose `page_mention_state.alias_revision`/`alias_version` differ (revision-checked, coordinated write when managed) and removes them from pages that stopped being entities; `buildGazetteer({strict: true})` failing writes nothing and records `failed`; `saveEntries` diffs `mention_gazetteer_entries` under `pg_advisory_xact_lock`, bumps the source generation and marks due only pages linking to a removed target plus pages a mini-gazetteer of added names matches (ASCII names prefiltered with `LIKE` on lower-cased text, others scanned in JS; a first save marks the source due); `reconcileSource` scans due pages (no state row, or `mention_revision`/`mention_version` differ) in batches of 200 and publishes only when the source generations (`FOR SHARE`) and each page's `knowledge_revision` (`FOR SHARE`) are unchanged, writing link diffs (`addLinksBatch`, audit site `extract.mentions`) and page state in one transaction; then the status row gets state, pending count and `last_pass_at`. `writeDerivedAliases` / `writePageAliases` are import's and `reindex --aliases`' alias projection. `MENTION_EXTRACTOR_VERSION` and `ALIAS_DERIVATION_VERSION` are independent of `LINK_EXTRACTOR_VERSION_TS`. The scanned text is title, compiled truth and timeline; frontmatter `mention_ignore` names are skipped per page. Tests: `test/mentions-pass.test.ts`, `test/mentions-managed.test.ts`, `test/e2e/mentions-parity.test.ts`.diff --git a/docs/designs/hangul-mention-boundaries.md b/docs/designs/hangul-mention-boundaries.mdnew file mode 100644index 0000000000..9f2022ef48--- /dev/null+++ b/docs/designs/hangul-mention-boundaries.md@@ -0,0 +1,73 @@+# Hangul mention boundaries++The mention linker (`src/core/by-mention.ts`) matches a Hangul entity name only+when the name starts a word, keeps its written spacing, and ends at a+non-Hangul character or at a suffix that attaches to names: an optional title+or honorific (씨, 님, 대표, 선배 ...) followed by up to two particles or copula+forms (은, 에게서, 이었다, 야 ...). The exact lists live in+`HANGUL_NAME_TITLES` and `HANGUL_NAME_PARTICLES`.++So 지원이 왔다, 지원씨는 and 지원 대표가 link to an entity named 지원, while+지원하는 방법, 지원금 and 지원군 do not. Han and Kana names keep+character-substring matching, because those scripts do not separate words with+spaces.++## Measurement++The end rule replaced an earlier design with no end boundary at all. That+design reasoned that Korean particles attach directly to names, so any trailing+Hangul had to be allowed. The measurement below shows that this admitted+mostly word-internal false positives.++**Corpus.** 10,621 Korean Wikipedia paragraphs (KorQuAD 1.0 train and dev+contexts, 5.5M characters) plus 50,000 short Korean movie reviews (NSMC test+split, 1.8M characters). The reviews contribute informal, often unspaced text.+The corpora are public and are not committed here.++**Gazetteer.** 30 linkable titles: 20 common Korean given names, 5 full names,+3 two-syllable titles that are also common words, and 2 made-up company names.+Matches came from the real matcher (`buildGazetteer` on PGLite plus+`findMentionedEntities`), scanned one sentence at a time so every occurrence+counts.++**Labels.** gpt-6.1-sol labeled every match in context, assuming an entity with+that exact name exists:++- NAME: the string is used as a name.+- WORD: an ordinary word with the same spelling that stands as its own word,+ such as 우리 "we" or 지원 "support".+- INTERNAL: the string is only part of a longer word, such as 우리나라 or 지원하는.++| Matches (occurrences) | NAME | WORD | INTERNAL |+|---|---:|---:|---:|+| No end boundary (previous) | 74 | 1,536 | 1,041 |+| Suffix end rule (current) | 65 | 1,460 | 11 |++Without an end boundary, 39% of all Hangul matches (1,041 of 2,651) were+word-internal. The end rule removes 99% of them (1,030) and keeps 65 of 74 real+name mentions. Among NAME plus INTERNAL matches, precision rises from 7% to 86%.++**What the rule loses.** 9 of the 74 names are lost. Six come from unspaced+informal reviews, where the name runs straight into the next word (미래랑세주랑...).+The others carry a suffix outside the lists, such as `때문에` or a name followed+directly by a verb.++**What the rule keeps.** The 11 remaining INTERNAL matches are mostly a+romanized prefix (e지원) and 우리 측.++**What the rule cannot fix.** Homonyms (WORD) were 58% of matches before and+95% after, since most of what remains is the everyday word. A title that is+also an everyday word links wherever that word appears with normal spacing.+This is a property of the gazetteer, not of the boundary rule; on this+general-purpose corpus real names are rare. `gbrain extract mentions --explain+<name>` shows how a name was matched, and `mentions.ignore` stops a name from+linking.++**Matcher version.** `hashGazetteer` mixes a matcher-semantics version into the+resume fingerprint (`hangul-boundaries-v2`), so the next mention pass re-scans+pages instead of resuming with links from the old rule.++## Changelog++- 2026-10-05: measured the no-end-boundary design on a Korean corpus and added+ the title/particle/copula end rule.diff --git a/src/core/by-mention.ts b/src/core/by-mention.tsindex 36d04a6357..7173165fa8 100644--- a/src/core/by-mention.ts+++ b/src/core/by-mention.ts@@ -110,7 +110,7 @@ export function hashGazetteer(gazetteer: Gazetteer): string {for (const e of bucket) entries.push(`${e.source_id}\0${e.slug}\0${e.title}\0${e.tokens.join(' ')}\0${e.matchText ?? ''}${e.caseTokens ? `\0${e.caseTokens.join(' ')}` : ''}`);}// Matching semantics are part of the resume identity, not just DB contents.- return createHash('sha256').update('hangul-boundaries-v1\n').update(entries.sort().join('\n')).digest('hex').slice(0, 8);+ return createHash('sha256').update('hangul-boundaries-v2\n').update(entries.sort().join('\n')).digest('hex').slice(0, 8);}/** One row of the saved entry set the mention pass diffs (mention_gazetteer_entries). */@@ -666,10 +666,23 @@ function caseTokensOf(name: string): string[] {// Body-text scanner (pure)// ============================================================+/** Suffixes that may attach to a Hangul name: an optional title or honorific,+ * then up to two particles or copula forms (지원씨는, 지원에게서, 지원이었다).+ * Any other attached Hangul continues a longer word (지원하는, 지원금), which+ * was 99% of 1,041 word-internal matches on a Korean corpus while this suffix+ * set kept 65 of 74 real name mentions (docs/designs/hangul-mention-boundaries.md).+ */+const HANGUL_NAME_TITLES = '씨 님 오빠 언니 누나 선배 후배 선생님 선생 교수 대표 사장 회장 팀장 부장 과장 이사 의원 기자 작가 감독 측';+const HANGUL_NAME_PARTICLES = '이 가 은 는 을 를 의 에 에게 에게서 한테 한테서 께 께서 와 과 랑 이랑 도 만 로 으로 로서 으로서 로부터 으로부터 에서 부터 까지 처럼 보다 마저 조차 뿐 밖에 이나 이든 이라도 라도 이여 이며 이고 이다 입니다 이에요 예요 이었다 였다 이었던 였던 이라는 라는 이라고 라고 이란 이야 야 아';+const hangulAlternation = (words: string) => `(?:${words.split(' ').sort((a, b) => b.length - a.length).join('|')})`;+const HANGUL_NAME_SUFFIX_RE = new RegExp(+ `^${hangulAlternation(HANGUL_NAME_TITLES)}?${hangulAlternation(HANGUL_NAME_PARTICLES)}{0,2}(?![가-힣])`, 'u',+);+/** Korean uses word spaces; Han/Kana retain character-substring matching.* Validate each candidate before maximal-munch selection so an invalid longer- * phrase does not consume a valid shorter name. Do not require an end boundary:- * Korean particles attach directly to names (지원은, 지원에게).+ * phrase does not consume a valid shorter name. The name must start a word and+ * end at a non-Hangul character or an attached name suffix (above).*/function hasHangulMatchBoundary(text: string, tokens: ScannedToken[], start: number, entry: GazetteerEntry,@@ -678,9 +691,10 @@ function hasHangulMatchBoundary(const first = tokens[start]!;if (first.offset > 0 && /[가-힣]/u.test(text[first.offset - 1]!)) return false;const last = tokens[start + entry.tokens.length - 1]!;- const actual = text.slice(first.offset, last.offset + last.length).replace(/\s+/gu, ' ');+ const end = last.offset + last.length;+ const actual = text.slice(first.offset, end).replace(/\s+/gu, ' ');const expected = (entry.matchText ?? entry.tokens.join('')).trim().replace(/\s+/gu, ' ');- return actual === expected;+ return actual === expected && HANGUL_NAME_SUFFIX_RE.test(text.slice(end, end + 12));}/**diff --git a/test/by-mention-hangul.test.ts b/test/by-mention-hangul.test.tsindex 14afc6283f..7cf61a989e 100644--- a/test/by-mention-hangul.test.ts+++ b/test/by-mention-hangul.test.ts@@ -54,6 +54,16 @@ describe('Hangul mention boundaries', () => {expect(mentions(body)).toEqual(['people/jiwon']);});+ test.each(['지원씨는 왔다', '지원님께 드렸다', '지원에게서 받았다', '지원이었다', '지원아 가자', '지원 대표가 말했다', '지원대표가 말했다'])+ ('keeps attached honorifics, titles and copula forms: %s', body => {+ expect(mentions(body)).toEqual(['people/jiwon']);+ });++ test.each(['지원하는 방법', '지원금 신청', '지원군을 보냈다', '장인정신', '인하여 늦었다'])+ ('rejects a name that only starts a longer word: %s', body => {+ expect(mentions(body)).toEqual([]);+ });+test('matches an alias using alias spelling, not its canonical Latin title', () => {const body = '😀 아내와 만났다';const found = findMentionedEntities(body, gazetteer, opts);diff --git a/test/by-mention.test.ts b/test/by-mention.test.tsindex e893bea354..2a717ff254 100644--- a/test/by-mention.test.ts+++ b/test/by-mention.test.ts@@ -326,37 +326,37 @@ describe('findMentionedEntities — pure cases', () => {// ============================================================describe('findMentionedEntities — CJK cases', () => {- test('CJK single-name match — "纳瓦尔" in body → matched', () => {+ test('CJK single-name match — "艾例丝" in body → matched', () => {const g = gazetteerFromEntries([- { slug: 'people/naval', source_id: 'default', title: '纳瓦尔' },+ { slug: 'people/alice-example', source_id: 'default', title: '艾例丝' },]);- const mentions = findMentionedEntities('我最近读了纳瓦尔的书。', g, {+ const mentions = findMentionedEntities('我最近读了艾例丝的书。', g, {fromSlug: 'writing/post-1', fromSourceId: 'default',});expect(mentions).toHaveLength(1);- expect(mentions[0]!.slug).toBe('people/naval');- expect(mentions[0]!.name).toBe('纳瓦尔');+ expect(mentions[0]!.slug).toBe('people/alice-example');+ expect(mentions[0]!.name).toBe('艾例丝');});test('CJK multi-name — two different CJK entities in one body', () => {const g = gazetteerFromEntries([- { slug: 'people/naval', source_id: 'default', title: '纳瓦尔' },- { slug: 'people/shuang-xuetao', source_id: 'default', title: '双雪涛' },+ { slug: 'people/alice-example', source_id: 'default', title: '艾例丝' },+ { slug: 'people/bob-example', source_id: 'default', title: '鲍例布' },]);- const mentions = findMentionedEntities('纳瓦尔和双雪涛都是作家。', g, {+ const mentions = findMentionedEntities('艾例丝和鲍例布都是作家。', g, {fromSlug: 'writing/post-1', fromSourceId: 'default',});expect(mentions).toHaveLength(2);const slugs = mentions.map(m => m.slug);- expect(slugs).toContain('people/naval');- expect(slugs).toContain('people/shuang-xuetao');+ expect(slugs).toContain('people/alice-example');+ expect(slugs).toContain('people/bob-example');});test('CJK first-mention-only — repeated name → single link', () => {const g = gazetteerFromEntries([- { slug: 'people/naval', source_id: 'default', title: '纳瓦尔' },+ { slug: 'people/alice-example', source_id: 'default', title: '艾例丝' },]);- const mentions = findMentionedEntities('纳瓦尔说过。然后纳瓦尔又说过。', g, {+ const mentions = findMentionedEntities('艾例丝说过。然后艾例丝又说过。', g, {fromSlug: 'writing/post-1', fromSourceId: 'default',});expect(mentions).toHaveLength(1);@@ -364,19 +364,19 @@ describe('findMentionedEntities — CJK cases', () => {test('CJK self-link guard — entity page mentioning itself is skipped', () => {const g = gazetteerFromEntries([- { slug: 'people/naval', source_id: 'default', title: '纳瓦尔' },+ { slug: 'people/alice-example', source_id: 'default', title: '艾例丝' },]);- const mentions = findMentionedEntities('纳瓦尔是一位投资人。', g, {- fromSlug: 'people/naval', fromSourceId: 'default',+ const mentions = findMentionedEntities('艾例丝是一位投资人。', g, {+ fromSlug: 'people/alice-example', fromSourceId: 'default',});expect(mentions).toEqual([]);});test('CJK cross-source guard — entity in different source skipped', () => {const g = gazetteerFromEntries([- { slug: 'people/naval', source_id: 'team-b', title: '纳瓦尔' },+ { slug: 'people/alice-example', source_id: 'team-b', title: '艾例丝' },]);- const mentions = findMentionedEntities('纳瓦尔写了这本书。', g, {+ const mentions = findMentionedEntities('艾例丝写了这本书。', g, {fromSlug: 'writing/post-1', fromSourceId: 'team-a',});expect(mentions).toEqual([]);@@ -384,10 +384,10 @@ describe('findMentionedEntities — CJK cases', () => {test('CJK code-block stripping — CJK name inside ``` is skipped, outside matched', () => {const g = gazetteerFromEntries([- { slug: 'people/naval', source_id: 'default', title: '纳瓦尔' },+ { slug: 'people/alice-example', source_id: 'default', title: '艾例丝' },]);- // "纳瓦尔" only appears inside code block → should be skipped.- const body = '```\n纳瓦尔\n```\n只有代码块里面有。';+ // "艾例丝" only appears inside code block → should be skipped.+ const body = '```\n艾例丝\n```\n只有代码块里面有。';const mentions = findMentionedEntities(body, g, {fromSlug: 'writing/post-1', fromSourceId: 'default',});@@ -396,10 +396,10 @@ describe('findMentionedEntities — CJK cases', () => {test('CJK determinism — same output across 10 calls', () => {const g = gazetteerFromEntries([- { slug: 'people/naval', source_id: 'default', title: '纳瓦尔' },- { slug: 'people/shuang-xuetao', source_id: 'default', title: '双雪涛' },+ { slug: 'people/alice-example', source_id: 'default', title: '艾例丝' },+ { slug: 'people/bob-example', source_id: 'default', title: '鲍例布' },]);- const body = '纳瓦尔和双雪涛。纳瓦尔再说一次。';+ const body = '艾例丝和鲍例布。艾例丝再说一次。';const refs = new Set<string>();for (let i = 0; i < 10; i++) {const mentions = findMentionedEntities(body, g, {@@ -412,21 +412,21 @@ describe('findMentionedEntities — CJK cases', () => {test('CJK mixed body — CJK entity matched in body with ASCII around it', () => {const g = gazetteerFromEntries([- { slug: 'people/naval', source_id: 'default', title: '纳瓦尔' },+ { slug: 'people/alice-example', source_id: 'default', title: '艾例丝' },{ slug: 'companies/acme', source_id: 'default', title: 'Acme' },]);- const mentions = findMentionedEntities('Acme was founded by 纳瓦尔 in 2020.', g, {+ const mentions = findMentionedEntities('Acme was founded by 艾例丝 in 2020.', g, {fromSlug: 'writing/post-1', fromSourceId: 'default',});expect(mentions).toHaveLength(2);const slugs = mentions.map(m => m.slug);- expect(slugs).toContain('people/naval');+ expect(slugs).toContain('people/alice-example');expect(slugs).toContain('companies/acme');});test('CJK empty gazetteer — no false positives', () => {const g: Gazetteer = new Map();- const mentions = findMentionedEntities('纳瓦尔和双雪涛。', g, {+ const mentions = findMentionedEntities('艾例丝和鲍例布。', g, {fromSlug: 'writing/post-1', fromSourceId: 'default',});expect(mentions).toEqual([]);@@ -434,7 +434,7 @@ describe('findMentionedEntities — CJK cases', () => {test('CJK empty text → empty result', () => {const g = gazetteerFromEntries([- { slug: 'people/naval', source_id: 'default', title: '纳瓦尔' },+ { slug: 'people/alice-example', source_id: 'default', title: '艾例丝' },]);const mentions = findMentionedEntities('', g, {fromSlug: 'writing/post-1', fromSourceId: 'default',@@ -653,8 +653,8 @@ describe('tokenizer boundaries — marks and non-ASCII numerics', () => {expect(tokenizeForScan('㐀㐁').map(t => t.text)).toEqual(['㐀㐁']);expect(tokenizeTitle('㐀㐁')).toEqual(['㐀㐁']);// In-scope CJK is untouched: still char-level.- expect(tokenizeTitle('纳瓦尔')).toEqual(['纳', '瓦', '尔']);- expect(tokenizeForScan('纳瓦尔说').map(t => t.text)).toEqual(['纳', '瓦', '尔', '说']);+ expect(tokenizeTitle('艾例丝')).toEqual(['艾', '例', '丝']);+ expect(tokenizeForScan('艾例丝说').map(t => t.text)).toEqual(['艾', '例', '丝', '说']);});});@@ -837,16 +837,16 @@ describe('buildGazetteer — engine integration', () => {// CJK — engine-backed teststest('CJK entity with 2-char title enters gazetteer with char-level tokens', async () => {- await engine.putPage('people/naval', {- type: 'person', title: '纳瓦尔', compiled_truth: 'b', timeline: '', frontmatter: {},+ await engine.putPage('people/alice-example', {+ type: 'person', title: '艾例丝', compiled_truth: 'b', timeline: '', frontmatter: {},});const g = await buildGazetteer(engine);- // "纳瓦尔" tokenized as ["纳","瓦","尔"] → key is "纳"- expect(g.has('纳')).toBe(true);- const bucket = g.get('纳')!;+ // "艾例丝" tokenized as ["艾","例","丝"] → key is "艾"+ expect(g.has('艾')).toBe(true);+ const bucket = g.get('艾')!;expect(bucket.length).toBe(1);- expect(bucket[0]!.tokens).toEqual(['纳', '瓦', '尔']);- expect(bucket[0]!.slug).toBe('people/naval');+ expect(bucket[0]!.tokens).toEqual(['艾', '例', '丝']);+ expect(bucket[0]!.slug).toBe('people/alice-example');});test('CJK single-char title (cjkCharCount < 2) excluded from gazetteer', async () => {