Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
docs(facts): CJK fact subjects need a literal slug or a delimiter (#6620)
garrytan3e52f332c294
diff --git a/docs/guides/facts-relink.md b/docs/guides/facts-relink.mdindex fe947861f1..46b5dc459b 100644--- a/docs/guides/facts-relink.md+++ b/docs/guides/facts-relink.md@@ -31,6 +31,21 @@ not. Pass `infer_entity: false` to skip inference for one call.Page imports work the same way, and a fact extracted from an entity page withno other name in it belongs to that page.+### CJK subjects need a literal slug or a delimiter++Chinese, Japanese and Korean text has no spaces between words, so write-time+inference and relink's free tiers cannot tell where an unspaced name ends.+They link a CJK subject only from its literal page slug followed by a space or+punctuation. Unspaced natural-name inference is unsupported: name the page+with `--entity` (or `entity`) instead. Relink's model tier also needs the name+set off by a space or punctuation.++| Fact text | Free inference |+|---|---|+| `people/王小明 负责项目。` | links `people/王小明` |+| `people/王小明负责项目。` | no link |+| `王小明负责项目。` | no link |+Turn write-time inference off with `gbrain config set facts.entity_inferenceoff`. That does not undo earlier links, and it does not affect `gbrain factsrelink`.diff --git a/test/facts-subject-infer.test.ts b/test/facts-subject-infer.test.tsindex c67e4b50d1..eddc1eae6d 100644--- a/test/facts-subject-infer.test.ts+++ b/test/facts-subject-infer.test.ts@@ -5,6 +5,8 @@* isolation. Synthetic data only.*/import { describe, test, expect, beforeAll, afterAll } from 'bun:test';+import { readFileSync } from 'node:fs';+import { join } from 'node:path';import { PGLiteEngine } from '../src/core/pglite-engine.ts';import { importFromContent } from '../src/core/import-file.ts';import {@@ -229,6 +231,23 @@ describe('literal Unicode subject slugs (#6620)', () => {});});+describe('#6620: the facts guide documents CJK subject inference as it behaves', () => {+ test('every row of the guide\'s CJK table has the stated outcome', async () => {+ const guide = readFileSync(join(import.meta.dir, '..', 'docs', 'guides', 'facts-relink.md'), 'utf8');+ const section = guide.slice(guide.indexOf('### CJK subjects'));+ const rows = [...section.matchAll(/^\| `([^`]+)` \| (?:links `([^`]+)`|no link) \|$/gm)];+ expect(rows.length).toBeGreaterThanOrEqual(3);+ await page('people/王小明', 'Literal CJK Example', 'person');+ try {+ for (const [, fact, slug] of rows) {+ expect({ fact, slug: (await inferFactSubject(engine, 'default', { fact: fact!, mode: 'write' })).slug }).toEqual({ fact, slug: slug ?? null });+ }+ } finally {+ await engine.executeRaw(`DELETE FROM pages WHERE slug = 'people/王小明'`);+ }+ });+});+describe('inferFactSubject scope', () => {test('a remote caller never infers a private page', async () => {const r = await inferFactSubject(engine, 'default', { fact: 'Dana Private-Example is relocating', mode: 'write', excludePrivate: true });