Repository navigation
Dictation: the rules that decide which spoken words to clean up, matching iOS word for word (pure and tested; nothing runs them yet) - #2937
Merged
Conversation
…hing iOS word for word (pure and tested; nothing runs them yet)
kitlangton
added a commit
that referenced
this pull request
Nov 27, 2026
A new Lab, off by default, takes ums, repeats, false starts, and spoken corrections out of English dictations on a Mac with the cleanup tagger the iPhone app ships. The model can only remove words that were heard, and the guard from #2937 refuses any removal that is not a known disfluency. - The stage runs after the corrections and before the Apple Intelligence pass or the mode's rewrite, never for another language, the Verbatim style, numbers alone, or typed text. - The 26 MB model downloads through Hex's own HTTPS the first time a dictation starts with the Lab on, and is unpacked only when its size and SHA-256 match the pin, by a zip reader that refuses paths outside the package. - Core ML runs it on the CPU, one warm copy on its own thread, with a 150 ms budget. A missing, late, or failing model pastes the words as heard and History says why.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dictation gets the rules for cleaning up what was said (ums, repeats, false starts, spoken corrections), as pure Rust that matches the iOS app word for word.
Nothing runs it yet: no model, no setting, no change to what Hex pastes. This is the part that decides which words may go and writes what is left, so the next step only has to add the model.
💡 Why
The iOS app already cleans up dictation with a small tagger and a guard that keeps names, numbers and content words. Desktop needs the same decisions, and they have to stay the same on both. They are also the part worth testing hardest, and they need no model to test.
🆕 What is here (all in
src/dictation/cleanup/)🚦 How it ships: it doesn't yet. The module is unused outside its tests, and the build expects that.
📊 Proof
The fourth row is new: the reference pipeline has no guard, so
fixtures/guard_reference.swiftcompiles the real iOS guard and writes its decisions for the 137 sentences at both recorded probability sets, for seeded random markings, and for 45 sentences picked to reach every rule.Seeded property tests: rendering deletions never adds a word (4,000 random plans, including emoji, ellipses and letters whose capital is two letters); nothing to delete gives the transcript back byte for byte; the guard removes only words still proposed above the threshold; undoing one edit puts back its words and no others; the desktop policy never removes a word iOS keeps.
39 tests, all new.
👀 Read:
guard.rs, thePolicystruct and its four desktop switches, since those are the only rules that are not a port. Two things to know: a word said only twice ("Never, ever, ever") is still cut to one, and taking a proposal away can change what happens to its neighbours (the guard judges runs of words), so the property proved is "only proposed words go", not "fewer proposals means fewer deletions".nix/package.nixgains four lines so the Nix check can read the iOS fixtures. The rest is routine.Step 3 of the dictation cleanup plan · no user reports · the guard reference is regenerated with the two commands at the top of
guard_reference.swiftwhenever the iOS guard changesChecks run
python3 scripts/code-shape.py --check: passescargo clippy --locked --bin hex -- -D warnings: cleanscripts/check dictation::cleanup: 39 passedscripts/check(fmt, code-shape, Nix pins, clippy on all targets, every test): 4,027 run, 4,022 passed. The 5 that failed are outside this change (audio effect holds, local API timestamps and processing, onboarding motion, router timing), failed on timing while the machine was busy, and all 5 pass when rerun on their own.