Skip to content

Postprocessor compatibility audit for Mandarin (CHN-30 / #501 COMP-01)

Status: audit of main at 6edac14c, 2026-10-16; findings F1–F6 and the transcript/injection audit (§5) updated 2026-10-21 on branch feat/501-cjk-compat. §3 lists what is fixed and what is open. Evidence is file:line against that commit; every "Chinese result" cell was produced by running synthetic text through the real pipeline, not inferred from reading (tests/test_cjk_pipeline_vectors.py). This is the filled-in matrix that surface-support-matrix.md leaves as a template.

Refresh (2026-11-06, main at 6cd4a27f, branch r1107t-cjk-postprocess): the default-on set was re-derived from Config() and is unchanged: no text transform has become default-on since the audit, and tests/test_cjk_pipeline_vectors.py still drives every vector through the shipped defaults. The §1 decision column now records the fixes of §3. The opt-in transforms of §2 were run over the issue's test strings for the first time (tests/test_cjk_optin_transforms.py). Meeting minutes now size a Mandarin window in tokens rather than English characters (F10), and the minutes fallback merge no longer puts a space between Mandarin sentences (F11). Transcript outputs are pinned byte for byte, including the meeting relabel round trip (tests/test_cjk_meeting_outputs.py). Still model-free: no ASR, LLM or desktop was run.

Follow-up (2026-11-27): findings F12 to F16 in §3 fix opt-in surfaces that were not audited before (staged dictation, Punch-In, Prosody Ink, prosodic punctuation, word counts, field-aware shaping). Model-free (tests/test_cjk_review_surfaces.py).

Current follow-up (2026-10-29): The fixed findings below describe landed model-free code, but no real ASR/desktop evidence was performed as part of this audit. The MCP configuration propagation defect (F6) was fixed by 8523d472 on 2026-10-21, before this note was written (see F6). The optional-transform risk and notes token-budget concerns are broken down in community tasks and release gates.

Classes. CJK-safe — leaves Han text and full-width punctuation alone. ASCII/space-dependent — assumes whitespace-delimited words or ASCII punctuation. Language-specific — an English (or other) lexical rule that is inert or wrong for Mandarin.

How "default-on" was decided. Config() was instantiated and every enabled flag read. The only default-on text steps in the dictation path are: the STT segment join, clean_text, the disfluency filter, the command classifier + revise parser, and continuation spacing. Everything else in the daemon's transform chain ships off.

1. Default-on transforms (the live dictation path, in pipeline order)

# Step Evidence Default Assumption Class Chinese result (probed) Decision Vector
1 STT segment join " ".join(seg.text.strip() …) (3 sites: batch, word-timestamp, streaming window) src/yazses/stt/faster_whisper.py:204, :240, :252 on segments are space-separated words ASCII/space-dependent A multi-segment Han result gets a space at every segment seam: 你好,世界。 今天测试。 F5 — fixed (cjk.join_pieces) test_han_segments_are_not_joined_with_a_space
2 clean_text: strip, drop blank artefacts, strip leading [\s.…] src/yazses/postprocess/cleaner.py:3, :8, :10 on ASCII . and … (U+2026) are the only leading noise CJK-safe Unchanged on every identity vector. Leading …… (two U+2026) is stripped, same as English …; a leading 。 or , is kept. keep identity set
3 Vocabulary correction src/yazses/core/daemon.py:2653 → src/yazses/postprocess/vocab_correct.py:172 off ([stt] vocab_correction, config.py SttConfig) whitespace tokens (t.split(), :188) not audited here no-op while off CJK-safe (probed 2026-11-06): no Han vector changes. A Latin term separated by spaces inside Han is corrected (我用 PyTorc 训练 → 我用 PyTorch 训练); one glued to Han (我用Kubernets部署) is one whitespace token and is left alone — a miss, not a corruption test_vocabulary_correction_*
4 Hallucination guard src/yazses/core/daemon.py:2685 → src/yazses/postprocess/hallucination.py:31 off _norm keeps only [a-z0-9 ], so Han characters are erased before matching Language-specific (English ghost list + loop test) Before the fix, 我们 thanks for watching 然后 was dropped whole. Fixed in this change: Han-bearing text is never judged a ghost phrase or loop (hallucination.py:42, :69). Pure-Latin behaviour is unchanged. A Chinese ghost list / Chinese loop test is a separate, measured task. test_guard_*
5 Disfluency filter — Rule A fillers src/yazses/stt/filters/disfluency.py:57, :254-340; regex :284-285 on (config.py:313) English filler list, \b anchors, ASCII , consumed Language-specific (inert on Han) with one ASCII-dependent defect Mandarin 嗯/呃 are not in the list and survive (by design — no destructive default). An English filler inside a Han sentence is removed but only the ASCII comma is consumed: Uh,我们开始吧 → ,我们开始吧; 我觉得,um,很好 → 我觉得,,很好. F3 — fixed (contract 7.1.0) test_english_filler_*
6 Disfluency Rule B — 2-gram dedup disfluency.py:60, :346-366 on whitespace tokens ASCII/space-dependent Inert on unspaced Han (one token). Normalises \n and runs of space to single spaces for all text (' '.join(text.split())), identical to English. keep; note only zh-two-gram-repeat
7 Disfluency Rule C — self-correction triggers disfluency.py:66, :499-561 on English trigger phrases; sentence boundary is ASCII ./!/? (:544-546); word boundary via isalnum (:510) Language-specific + ASCII-dependent boundary Chinese phrases are not triggers (我说不用了算了 untouched). With an English trigger inside Han text the prior sentence is lost because 。 is not a boundary: 我今天很忙。 scratch that 我很闲 → 我很闲 (English keeps the earlier sentence). F4 — fixed (contract 7.1.0) test_english_correction_phrase_*
8 Disfluency tail: collapse double spaces disfluency.py:69 on ASCII spaces CJK-safe 你好 世界 → 你好 世界 (collapses, never inserts); U+3000 is treated as whitespace by split() in step 6 and becomes " " keep; note only —
9 Command classifier + revise parser src/yazses/core/daemon.py:2934 (parse_revise), :2855 (classify); grammar [commands] language, config.py:433 on per-language grammar (en, zh) Language-specific (a zh grammar exists) None of the identity vectors was classified as a command under either stt.language. Command grammar correctness is its own track (tests/test_chinese_command_grammar.py). out of scope here identity set
10 Continuation spacing src/yazses/postprocess/spacing.py:32, :51-63; wired at src/yazses/core/daemon.py:3228; window default config.py:259 (30 s) on a burst follows another word; closing punctuation is ASCII/Persian only ASCII/space-dependent Every second burst within 30 s gets a leading space: 今天测试。 → 今天测试。. A full-width closer is not in the suppression set: ,然后 → ,然后. F1, F2 — fixed (previous_tail; contract 7.1.0, contract/vectors/spacing.json) test_second_han_burst_*, test_burst_opening_with_a_fullwidth_comma_*
11 Inject log line len(text.split()) "words" src/yazses/core/daemon.py:2719 on whitespace words ASCII/space-dependent (log only) Reports a Han run as 1 word. Metadata only; no behaviour depends on it. Fixed (2026-11-27, F15: cjk.count_words) test_count_words_*

Not a postprocessor but the same assumption, tracked separately (CHN-R05 in risk-register.md, COMP-04): meeting/quality.py::tokenize() counts each Han character as one quality unit (6ac8f152), and store.live_word_count() reaches it through a script-aware join (tests/test_meeting_cjk_word_count.py). The minutes token budget is F10.

2. Opt-in transforms that touch the text (all off by default)

Probed 2026-11-06. ITN (itn/normalize.py), symbols (symbols/lookup.py), unit conversion (convert/units.py), temporal resolution (temporal/resolve.py), the article fixer (gec/guard.py), diacritic restoration (diacritize/restore.py), semantic line breaks (sembr/breaks.py), delimiter auto-pairing (autopair/balance.py) and mid-utterance self-repair (selfrepair/repair.py) were each run over twelve Han vectors (the issue's three test strings, full-width quotes, brackets and enumeration commas, ¥, ℃, a URL, an ellipsis). None changed a character (tests/test_cjk_optin_transforms.py). That makes them CJK-safe on these inputs; it does not mean they do anything useful for Mandarin (most are English lexical rules and are simply inert).

Step Evidence Class Note
Spoken punctuation src/yazses/postprocess/voice_punctuation.py:39-51 (\b + English phrases) Language-specific, ASCII output Inert on Han text that holds no English punctuation word. Probed 2026-11-06 (not pinned by a test, because another branch is changing this module): an English mark word spoken between Han clauses becomes an ASCII mark and the space before the next clause stays — 你好 comma 世界 period → 你好, 世界.; 我说 question mark → 我说?. A mark word glued to Han is not matched (你好comma世界 is unchanged, because a Han character is a \w character and there is no \b). No Han character is lost. Full-width output and a Chinese spoken-punctuation table are feature work.
Prosody Ink src/yazses/postprocess/prosody.py::annotate (text.split() aligned by index to word timings) ASCII/space-dependent Whisper word timestamps for Mandarin are not whitespace tokens, so token/word alignment does not hold. Excluded for text holding CJK (F14).
Phonetic corrector src/yazses/postprocess/phonetic.py:52 ([^a-z] key) Language-specific Latin sound keys only; inert on Han.
LLM cleanup src/yazses/postprocess/llm_cleanup.py:124-141 (critical-token guard) not audited Off; token guard is whitespace-token based.
Han script normaliser src/yazses/postprocess/han_script.py:121-135 CJK-specific Off until [stt] chinese_script is set; no-op without Han (contains_han). Wired in the STT factory and, since F6, in the file-transcription engine builder (recimport/pipeline.py::_build_engine).
Persian normaliser src/yazses/postprocess/persian_text.py Language-specific Gated by [stt] language; inert otherwise.
Streaming injection src/yazses/config.py:287 (StreamingConfig, off), src/yazses/stt/streaming.py:192 (_common_prefix) CJK-safe by construction Character prefix, not word prefix. Not run end to end here.
Daemon chain, the rest (translit, markup, styleguard, safeglyph, redaction, compute, corrdict, smartpaste, fieldaware) each enabled=False not audited Each ships dormant (AGENTS.md rule 2). Not run with Han text yet.

3. Findings

ID Where Defect State
F1 postprocess/spacing.py A leading space is inserted between consecutive Han bursts. Only the previous burst's last character can say whether the seam is Han–Han, and continuation_prefix did not receive it. Fixed. Optional previous_tail argument. core/daemon.py records _last_dictation_tail wherever it records _last_dictation_monotonic. The seam rule is postprocess/cjk.py::needs_space. Contract 7.1.0 (spacing.json).
F2 postprocess/spacing.py Full-width closers ,。!?;:、)」』》 were not in _NO_LEADING_SPACE_BEFORE. Fixed. Any CJK punctuation mark suppresses the separator, opening marks included, because a full-width glyph carries its own spacing. Contract 7.1.0.
F3 stt/filters/disfluency.py Rule A Filler removal consumed only the ASCII comma. This needs an English filler inside Mandarin text, which Whisper in zh mode rarely emits, so it is low frequency. Fixed. A trailing , or 、 is consumed with the filler. A leading filler's full-width mark is stripped. A dangling final full-width clause mark is tidied. The _CJK_* sets are separate, so the code-identifier guards are untouched. Contract 7.1.0 (disfluency.json).
F4 stt/filters/disfluency.py Rule C The rollback boundary recognised only ASCII . ! ?. Fixed. 。!? are boundaries with or without a following space. The trigger clause's own full-width mark is consumed. Contract 7.1.0.
F5 stt/faster_whisper.py (transcribe, transcribe_words, decode_window) Segments were joined with " " regardless of script. Fixed (cjk.join_pieces). Not verified against a real model: no Whisper weights were run, so how often a real Mandarin hold-to-talk burst decodes to two or more segments is not measured.
F6 recimport/pipeline.py File transcription built a bare FasterWhisperEngine and never applied [stt] chinese_script. Fixed for yazses transcribe (8f0edff1) and for yazses meeting recover: stt= is threaded through recover_meeting → finalize_meeting → transcribe_file. Live meetings already used the daemon's factory-wrapped engine. The MCP transcribe tool is fixed too (8523d472, 2026-10-21): mcp/server.py passed the whole Config as the recimport section, so the tool decoded with small.en in English whatever [recimport] and [stt] said. It now passes config.recimport and stt=config.stt, and transcribe_file raises TypeError on a whole Config. Tests: tests/test_file_transcription_honours_the_config.py (test_mcp_transcribe_* prove model, language, device and precision reach the decoder, and test_mcp_diarize_* that the diarize argument reaches the diarizer; test_chinese_script_wraps_the_file_engine proves the chinese_script wrapper at _build_engine, which the MCP path uses). Not covered: no test calls the MCP tool with [stt] chinese_script set, and no real model was run.
F8 recimport/align.py, recimport/subtitles.py, meeting/notes.py, meeting/store.py::live_text Per-character Mandarin word tokens were re-joined with " " (你 好 , 世 界) in utterances, JSON words and captions. Captions were measured in code points and broken only at spaces. A long Mandarin turn could not be split for the notes window. Fixed. See §5.
F9 inject/unicode.py, inject/ydotool.py The XKB/uinput path raised on the first character the layout lacks, but only after typing everything before it. The clipboard fallback then typed the prefix a second time (YazSes YazSes 版本). Fixed. The whole burst is resolved before the first keystroke. See §5.
F7 postprocess/hallucination.py Han text erased by _norm, so a real sentence could be dropped as a ghost phrase or loop. Fixed (opt-in guard).
F12 staged/buffer.py::join_chunks Two staged Mandarin bursts were joined with a space, unlike the same bursts typed directly. Fixed (2026-11-27): cjk.needs_space.
F13 postprocess/punch_in.py Spans were whitespace words, so a Han clause was one span and a partial respeak could replace all of it. Fixed (2026-11-27): cjk.break_units, one unit per character. A respeak that ends in 。 can still place that mark inside the clause, as a trailing . does in English; --dry-run shows it.
F14 postprocess/prosody.py::annotate, prosodypunct/apply.py Pause timings were matched to the wrong tokens, paragraph breaks and ASCII marks could land in Han text. Excluded (2026-11-27): text holding CJK is returned unchanged. Pause formatting for Mandarin needs character-level alignment and measurement.
F15 core/daemon.py (staged counts, inject log), cli.py staged commit, staged/buffer.py::describe, wordgoal/tracker.py split() counted a Han clause as one word. Fixed (2026-11-27): cjk.count_words.
F16 fieldaware/profile.py::apply_profile A search field kept a trailing 。. Fixed (2026-11-27).
F10 meeting/notes.py (window_turns, _split_long_text, batch_partials, line_overhead_chars) The minutes window was sized with CHARS_PER_TOKEN = 3.0, an English ratio. With the shipped 4096/1024 context that is 8,616 characters, and 8,616 Han characters fit the 2,872 tokens left for transcript only if a tokenizer packs three Han characters into one token. Past that, llama.cpp raises (the window is skipped) or clips max_tokens (the JSON is cut off). Fixed (2026-11-06). notes.budget_len charges each CJK character its UTF-8 length in tokens (3, or 4 for an astral extension): an upper bound for any tokenizer whose tokens each cover at least one byte (byte-level BPE, SentencePiece with byte fallback). Text without CJK costs exactly len(text), Hypothesis-checked. A bound, not a measurement: no model's Mandarin token rate was measured, so Mandarin windows are likely smaller than they need to be (about 950 Han characters at the defaults); that costs extra map calls, not content. tests/test_meeting_notes_cjk_budget.py.
F11 meeting/notes.py::_merge_partials The lossless fallback used when a reduce call fails joined window summaries with " ", so two Mandarin summaries read 会议讨论了进度。 决定下周发布。. Fixed (2026-11-06): cjk.join_pieces, which is " ".join for text without CJK.

4. What this audit did not do

  • No audio, no Whisper weights, no real transcripts, no minutes LLM. All text is synthetic.
  • No platform injection (COMP-06..09 need a human on each OS/session).
  • vocab_correct was skipped in the first pass and probed on 2026-11-06 (row 3).
  • Nine opt-in transforms of section 2 were run on 2026-11-06; the rest are classified from code.
  • No native speaker reviewed the spacing convention (a Han–Latin seam keeps its space) or the disfluency expectations (我觉得,um,很好 → 我觉得,很好).

5. File transcription, Meeting Mode and injection (2026-10-21)

Every fix uses one rule, src/yazses/postprocess/cjk.py (pure, stdlib only). It is built so that text holding no CJK character takes exactly the old code path, and tests/test_cjk_text.py checks that property with Hypothesis.

Surface Evidence Before After Vector
Word tokens of a zh decode faster-whisper 1.2.1 Tokenizer.split_to_word_tokens splits zh/ja/th/lo/my/yue on code points, not spaces YazSes came back as Yaz, Ses. Once stripped, the no-space signal was lost stt/faster_whisper.py::_glued_words regroups by each raw token's leading whitespace. Han–Han pairs stay separate tokens. It runs only for those decode languages (info.language) test_cjk_transcripts.py::test_mandarin_word_tokens_come_back_as_written
Diarized utterances recimport/align.py::merge_utterances 你 好 , 世 界 join_pieces test_diarized_utterances_join_han_words_without_spaces
SRT/VTT segments recimport/subtitles.py::merge_word_timestamps 你 好, 世 界。…, with the budget counted in code points join_pieces, with the budget counted in display columns (Han = 2) test_caption_segment_*
Caption wrapping recimport/subtitles.py::wrap_caption A Han caption had no space to break at, so it stayed one 80-column line Broken between characters (cjk.break_units), never before , or after 「 test_mandarin_caption_is_wrapped_between_characters
Every renderer recimport/render.py md/txt/srt/vtt/json Inherited the faults above Han text intact in all five formats test_every_renderer_keeps_the_han_text_intact
Meeting quality counts (COMP-04) meeting/quality.py::tokenize Already Han-aware since 6ac8f152 Unchanged test_meeting_quality_counts_han_characters_not_whitespace_runs
Live transcript join meeting/store.py::live_text Lines joined with " " join_pieces test_live_text_joins_mandarin_lines_without_a_space
Notes window split meeting/notes.py::_split_long_text A Mandarin turn has no whitespace, so it was returned whole at any length Split between characters within the budget test_notes_window_splits_a_long_mandarin_turn_within_budget
Portal keysyms inject/keysyms.py::char_to_keysym Already correct One keysym per code point (0x01000000 + cp), astral planes included; now pinned by a test test_cjk_injection.py::test_portal_*
Windows SendInput, macOS Quartz platform/windows/injector.py::_utf16_units, platform/macos/injector.py::_utf16_chunks Already correct Surrogate pairs are sent whole and never split across a chunk; now pinned for Han test_windows_*, test_macos_*
XKB/uinput and the ydotool mixed path inject/unicode.py, inject/ydotool.py::_inject_mixed The prefix was typed, then the injector raised, then the clipboard pasted the whole burst UnicodeInjector._plan and ensure_producible resolve every character before typing test_linux_fallback_types_a_mixed_han_burst_exactly_once
Every renderer, byte for byte (2026-11-06) recimport/render.py, meeting/store.py::relabel, live_markdown_line — Traditional Han text, a Han speaker name, SRT/VTT timestamps and the JSON fields are exact; meeting relabel re-renders from transcript.json with merged speakers and a Han rename without inserting a space test_cjk_meeting_outputs.py
Minutes window and merge (2026-11-06) meeting/notes.py English characters-per-token; " ".join of summaries F10, F11 test_meeting_notes_cjk_budget.py

Not fixed, recorded:

  • srpace/schedule.py (opt-in) splits only at ASCII punctuation followed by a space, so Mandarin is typed as one unpaced chunk. No character is changed. Pacing it needs a reading rate for Chinese screen readers, which nobody has measured here.
  • Interruptible Proofreading (opt-in) counts text.split() words, so a barge-in on Mandarin replaces from the start of the unspaced run, not from the character being read.
  • yazses tune --retranscribe builds a bare Whisper engine, so its re-transcription is not converted to [stt] chinese_script.
  • The coach and learning analytics tokenise [a-z0-9'] and see no Han text.
  • Spoken punctuation (opt-in) turns an English mark word between Han clauses into an ASCII mark and keeps the space (§2). Recorded, not changed: another branch owns voice_punctuation.py.
  • COMP-06..09 (injection on real X11, Wayland, macOS and Windows sessions) need a person on each platform. Nothing here is hardware evidence.