Layered summary language correction
Applies to newly generated layered-summary snippets and layer merges. The other memory systems and existing saved snippets are unchanged.
Behavior
- Resolve the requested language using the existing session preference, current story text, and world-language fallback.
- Generate a snippet and check its language once using the local text detector.
- When a detectable language differs from the resolved target, request one rewrite with the same configured model. Preserve facts, numbers, relationships, and original names. This correction disables provider retries and model fallback.
- Accept the rewrite without checking its language again, even if it is still different. If correction fails or yields no usable text, keep the first draft.
No LLM call is needed for the check itself. Matching language, unresolved auto, and undetectable short/name-only text skip correction. This is best effort, not a guarantee of language purity. Existing usage logging and billing apply to model calls, including the optional correction.
This does not regenerate historical English snippets or clear memory. The main story generation path is not changed.
Automated regression checks
pnpm --filter @yumina/shared build
pnpm --filter @yumina/server exec tsx --test src/lib/summary-language.test.ts src/lib/summaryception-core.test.ts
pnpm build
pnpm typecheckThe focused tests cover a successful correction, accepting a still-wrong second response, failed/empty correction fallback, no call for matching/ambiguous text, English names inside Chinese, an explicit English target, and both layered call sites using the bounded correction wrapper.
Optional development-model evaluation
Use synthetic Chinese story text and existing English snippets as prior context. Select auto or an explicit Chinese summary language and compact a new snippet. Verify that an English first draft causes at most one correction request, that names and facts survive, and that the saved text equals the correction when one is returned. Repeat for a layer merge. Force an empty or failed correction with a mock provider and verify that the original snippet is saved without a failed-job retry loop. Never rely on a real model producing the wrong language deterministically.
The automated tests use mocked generation; they do not establish a real-model language correction success rate.
