<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mohsen Seyedkazemi Ardebili</title>
    <description>The latest articles on DEV Community by Mohsen Seyedkazemi Ardebili (@mskazemi).</description>
    <link>https://dev.to/mskazemi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3997511%2Ff85584b3-05ee-47b7-b358-34484bbd147a.png</url>
      <title>DEV Community: Mohsen Seyedkazemi Ardebili</title>
      <link>https://dev.to/mskazemi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mskazemi"/>
    <language>en</language>
    <item>
      <title>Voice commands without an LLM: why a regex grammar still wins</title>
      <dc:creator>Mohsen Seyedkazemi Ardebili</dc:creator>
      <pubDate>Tue, 24 Nov 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/mskazemi/voice-commands-without-an-llm-why-a-regex-grammar-still-wins-2ln7</link>
      <guid>https://dev.to/mskazemi/voice-commands-without-an-llm-why-a-regex-grammar-still-wins-2ln7</guid>
      <description>&lt;p&gt;A dictation tool has to make one decision on every single utterance: &lt;strong&gt;is this text to type, or an instruction to carry out?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"undo that" → press Ctrl+Z&lt;/li&gt;
&lt;li&gt;"I want to undo that change" → type those words&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Get it wrong in one direction and your words get eaten. Get it wrong in the other and "undo that" appears in your email.&lt;/p&gt;

&lt;p&gt;In 2026 the fashionable answer is "send it to an LLM". In &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;YazSes&lt;/a&gt;, the offline dictation tool I work on, the answer is mostly a list of regular expressions, and I want to explain why I think that's the right default.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three tiers, cheapest first
&lt;/h2&gt;

&lt;p&gt;Every utterance goes through a classifier with three tiers:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tier 0: your macros.&lt;/strong&gt; An optional table you write yourself. It matches the &lt;em&gt;whole&lt;/em&gt; utterance exactly. Say "insert my signature" and get your email signature.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tier 1: the grammar.&lt;/strong&gt; A list of anchored regex patterns per language (English and Chinese today). Before matching, surrounding punctuation is stripped and the number words "one" to "ten" become digits, because Whisper writes "Undo three times." one day and "undo 3 times" the next.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;_add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;^undo(?:\s+that)?$&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IntentType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;EDIT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;undo&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;_add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;^go\s+to\s+line\s+(\d+)$&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IntentType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NAVIGATE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;go_to_line&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Tier 2: a small local model.&lt;/strong&gt; Optional, English only, off unless you point it at a local GGUF model file. It only gets a second look at utterances Tier 1 called dictation. If it fails or isn't confident, the utterance is typed as text.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F98frnzoq6c9wvh34gnrx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F98frnzoq6c9wvh34gnrx.png" alt="Macros, then an anchored grammar, then an optional local model, and anything unsure is typed" width="800" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The anchor is the whole trick
&lt;/h2&gt;

&lt;p&gt;Look at the &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt;. A command must be the &lt;em&gt;entire&lt;/em&gt; utterance. "undo that" matches. "I want to undo that change" doesn't, so it's typed.&lt;/p&gt;

&lt;p&gt;That one constraint does most of the work. People rarely say a bare command phrase in the middle of dictating prose, and when they say a command, they usually say &lt;em&gt;only&lt;/em&gt; the command. The anchor turns that habit into a rule.&lt;/p&gt;

&lt;p&gt;Some of what's in the English grammar:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;undo · undo that · undo 3 times · delete the last 3 words · save file · copy that · select all · new line · press enter · go to line 42 · page up · go to end of line · go to function main · run the tests · rename this to ... · new class called ...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When a command matches, a dispatcher turns it into keystrokes. "go to line 42" becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;action&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;go_to_line&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;injector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;inject_key_sequence&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ctrl+g&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;injector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;inject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;injector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;inject_key_sequence&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Return&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Those chords assume VS Code-style bindings. Different apps want different keys, and that is a never-ending part of the job.)&lt;/p&gt;

&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;p&gt;On a fixed set of 68 command phrases and 80 ordinary dictation lines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;all 68 phrases produced the expected action,&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;0%&lt;/strong&gt; of the dictation lines were mistaken for commands,&lt;/li&gt;
&lt;li&gt;a median of &lt;strong&gt;0.02 ms&lt;/strong&gt; per classification.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's a small, hand-built test set, not a field study, so read it as "the grammar does what it was designed to do" rather than "it never fails". But compare the cost profile with an LLM call: no model to load, no GPU, no latency anyone can feel, and the same answer every time for the same input. When it gets something wrong, I can read the pattern and see exactly why.&lt;/p&gt;

&lt;h2&gt;
  
  
  When you want to force it
&lt;/h2&gt;

&lt;p&gt;With one hotkey, YazSes decides automatically. If you'd rather be explicit, set a separate command key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[hotkey]&lt;/span&gt;
&lt;span class="py"&gt;command_key&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"..."&lt;/span&gt;   &lt;span class="c"&gt;# empty by default&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While you hold it, everything is treated as a command, phrases that don't match are dropped instead of typed, and the tray icon turns purple so you can see which mode you're in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3wptd1c1jjji1au1mkbi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3wptd1c1jjji1au1mkbi.jpg" alt="The tray icon turns purple in command mode" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Where "scratch that" lives
&lt;/h2&gt;

&lt;p&gt;You might expect "scratch that" to be in the grammar. It isn't. It's a separate feature (on by default) that deletes the last chunk of text YazSes itself typed, using backspaces. It needs to know exactly what was injected, which the grammar doesn't. And as post 9 in this series explains, "scratch that" in the &lt;em&gt;middle&lt;/em&gt; of a sentence is a different, much harder problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Your own commands
&lt;/h2&gt;

&lt;p&gt;Macros are where it becomes personal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yazses features &lt;span class="nb"&gt;enable &lt;/span&gt;macros
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="c"&gt;# ~/.config/yazses/macros.toml&lt;/span&gt;
&lt;span class="nn"&gt;[[macro]]&lt;/span&gt;
&lt;span class="py"&gt;trigger&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"insert my signature"&lt;/span&gt;
&lt;span class="py"&gt;type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"text"&lt;/span&gt;
&lt;span class="py"&gt;text&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Best regards,&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;Mohsen"&lt;/span&gt;

&lt;span class="nn"&gt;[[macro]]&lt;/span&gt;
&lt;span class="py"&gt;trigger&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"new python function"&lt;/span&gt;
&lt;span class="py"&gt;type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"snippet"&lt;/span&gt;
&lt;span class="py"&gt;snippet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"def ${cursor}():&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;    pass"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Placeholders like &lt;code&gt;${date}&lt;/code&gt;, &lt;code&gt;${time}&lt;/code&gt; and &lt;code&gt;${clipboard}&lt;/code&gt; are filled in when the macro runs, and &lt;code&gt;${cursor}&lt;/code&gt; in a snippet leaves the caret where you put it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I took away
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use the cheapest thing that can be right, and a model for the leftovers.&lt;/strong&gt; Most of the decision is structural, and structure is what regex is good at.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Anchor commands to the whole utterance.&lt;/strong&gt; It's one character on each end and it removes most false positives.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fail safe to typing.&lt;/strong&gt; If anything is unsure, type the words. A command typed as text is visible and easy to delete. Text silently run as a command is not.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Determinism is a feature.&lt;/strong&gt; Being able to read &lt;em&gt;why&lt;/em&gt; something matched matters a lot when the thing it does is press keys in someone's editor.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;YazSes is offline, open source (Apache-2.0) dictation: &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;github.com/MSKazemi/yazses&lt;/a&gt;. Macros and snippets: &lt;a href="https://github.com/MSKazemi/yazses/blob/main/docs/how-to/macros-and-snippets.md" rel="noopener noreferrer"&gt;how-to guide&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I wrote this with help from an AI assistant for drafting and editing; the design and opinions are mine, and I checked every example and number against the code.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>a11y</category>
      <category>productivity</category>
      <category>opensource</category>
    </item>
    <item>
      <title>"No wait, I meant...": when my self-correction feature ate people's sentences</title>
      <dc:creator>Mohsen Seyedkazemi Ardebili</dc:creator>
      <pubDate>Thu, 19 Nov 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/mskazemi/no-wait-i-meant-when-my-self-correction-feature-ate-peoples-sentences-kj7</link>
      <guid>https://dev.to/mskazemi/no-wait-i-meant-when-my-self-correction-feature-ate-peoples-sentences-kj7</guid>
      <description>&lt;p&gt;When you talk, you correct yourself. "Send it on Tuesday, no wait, Wednesday."&lt;/p&gt;

&lt;p&gt;A good dictation tool should type "Send it on Wednesday." So &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;YazSes&lt;/a&gt;, the offline dictation app I work on, has a filter for that. It listens for six correction phrases:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;no wait · delete that · scratch that · never mind · forget that · strike that&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When it hears one, it throws away what came before it and keeps what came after. It's on by default.&lt;/p&gt;

&lt;p&gt;Now try dictating this sentence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Delete that file when you are done."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The filter heard "delete that", rolled back, and typed:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"file when you are done."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Worse than a crash
&lt;/h2&gt;

&lt;p&gt;That's not a garbled transcript you'd notice at a glance. It's &lt;em&gt;fluent text you never said.&lt;/em&gt; If you're dictating an email quickly and not re-reading every line, it goes out like that.&lt;/p&gt;

&lt;p&gt;And it wasn't rare. These phrases are ordinary English. A few real examples from the test suite, with what got typed:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;You said&lt;/th&gt;
&lt;th&gt;It typed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;the no wait policy applies to walk-ins&lt;/td&gt;
&lt;td&gt;policy applies to walk-ins&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;she said no wait for the second batch&lt;/td&gt;
&lt;td&gt;for the second batch&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;the delete that button is confusing&lt;/td&gt;
&lt;td&gt;button is confusing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;they never mind the noise from the street&lt;/td&gt;
&lt;td&gt;the noise from the street&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That last one isn't just shorter. The meaning is gone. Every one of the six triggers destroyed normal prose in some sentence shape, and since the filter is on by default, this was every user.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: look at what's in front of the trigger
&lt;/h2&gt;

&lt;p&gt;The words &lt;em&gt;before&lt;/em&gt; a trigger tell you whether it's a correction or just a sentence. The fix came in three steps over a few releases, each one adding a kind of context that means "this is grammar, not a correction":&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Negations and verbs that govern the trigger&lt;/strong&gt; ("do &lt;em&gt;not&lt;/em&gt; delete that file", "you &lt;em&gt;should&lt;/em&gt; never mind the warning"). Plus: a trigger at the very &lt;em&gt;start&lt;/em&gt; of a sentence only counts if Whisper wrote pause punctuation after it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Articles, possessives, reporting verbs and copulas&lt;/strong&gt;, which make the trigger a noun or a quote rather than an instruction ("&lt;em&gt;the&lt;/em&gt; no wait policy", "&lt;em&gt;your&lt;/em&gt; delete that habit", "she &lt;em&gt;said&lt;/em&gt; no wait", "there &lt;em&gt;is&lt;/em&gt; no wait time").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Subject pronouns&lt;/strong&gt;, which make the trigger the sentence's own verb ("&lt;em&gt;they&lt;/em&gt; never mind the noise").&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frgde2l9guh3y8u523gja.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frgde2l9guh3y8u523gja.png" alt="The words before the trigger decide: noun, quote, or real correction" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The start-of-sentence rule is my favourite, because the comment explains the reasoning better than I can:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="c1"&gt;# At the very start there is nothing to roll back ...
# so the punctuation Whisper writes for the pause is the only signal, and the
# safe default is to require it. Without one the words are typed as spoken.
&lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;tuple&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.,;:!?…&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;_CJK_CLAUSE_PUNCTUATION&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;_CJK_SENTENCE_END&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"Scratch that, Wednesday" has a comma where you paused. "Scratch that itch" doesn't.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measure it in both directions
&lt;/h2&gt;

&lt;p&gt;A fix like this can easily overcorrect: make the filter so cautious it never fires, and you've "fixed" prose by breaking the feature. So I measured both:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Normal sentences destroyed: &lt;strong&gt;15 of 15 → 2 of 15&lt;/strong&gt; (after step 2)&lt;/li&gt;
&lt;li&gt;Real corrections missed: &lt;strong&gt;0 of 10 → 0 of 10&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both corpora ship as tests. I also deliberately &lt;em&gt;didn't&lt;/em&gt; treat "this" and "that" as signs of prose, because doing so broke a real correction already in the test set ("please do this strike that please do that").&lt;/p&gt;

&lt;p&gt;What remains is a known gap: a plural noun as the subject, like "children never mind the cold at all", still loses its first half. Those cases are pinned in a test that fails if the list changes &lt;em&gt;in either direction&lt;/em&gt;, so it's a visible limitation rather than a quiet one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The test that had frozen the bug
&lt;/h2&gt;

&lt;p&gt;Here's the part that surprised me.&lt;/p&gt;

&lt;p&gt;YazSes has a cross-platform contract: a set of input/output vectors that every implementation (the Python desktop app and an Android port in Kotlin) must agree on. One of the vectors covered this exact case:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"self-correction-trigger-inside-quote"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"input"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"he said never mind the cost and left"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"expected"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"the cost and left"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Its description said it documented "whatever the shipped behaviour is so both platforms agree."&lt;/p&gt;

&lt;p&gt;So the bug wasn't just untested. &lt;strong&gt;It was the specification.&lt;/strong&gt; A test someone wrote to pin current behaviour had pinned the defect, and any port that did the &lt;em&gt;right&lt;/em&gt; thing would have failed the contract. The fix changed the expected value to the whole sentence.&lt;/p&gt;

&lt;p&gt;A few releases later, those same vectors earned their keep: they caught the Kotlin port missing one of the new word lists. But only through a single word ("said") out of 33. One vector covering one word of a 33-word list is luck, not coverage. So now a dedicated test compares the Python and Kotlin word lists as sets.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I took away
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A text transform that can fail invisibly is the dangerous kind.&lt;/strong&gt; Fluent wrong text is worse than obvious garbage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fuzz with realistic prose that contains your trigger words.&lt;/strong&gt; "Never mind" and "delete that" are everywhere in normal English.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure a fix in both directions&lt;/strong&gt;: what it stops breaking, and what it stops doing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A "characterisation test" freezes behaviour, bugs included.&lt;/strong&gt; If a test's description says "whatever it does today", read the expected value as a question, not an answer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When two implementations share a list, compare the lists.&lt;/strong&gt; Don't hope an example happens to hit the missing entry.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;YazSes is offline, open source (Apache-2.0) dictation: &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;github.com/MSKazemi/yazses&lt;/a&gt;. The filter lives in &lt;a href="https://github.com/MSKazemi/yazses/blob/main/src/yazses/stt/filters/disfluency.py" rel="noopener noreferrer"&gt;&lt;code&gt;stt/filters/disfluency.py&lt;/code&gt;&lt;/a&gt; and the contract in &lt;a href="https://github.com/MSKazemi/yazses/tree/main/contract" rel="noopener noreferrer"&gt;&lt;code&gt;contract/&lt;/code&gt;&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I wrote this with help from an AI assistant for drafting and editing; the bug, the fix and the lessons are mine, and I checked every fact against the code, tests and changelog.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>testing</category>
      <category>nlp</category>
      <category>opensource</category>
    </item>
    <item>
      <title>A safety check is judged by how rarely it fires</title>
      <dc:creator>Mohsen Seyedkazemi Ardebili</dc:creator>
      <pubDate>Tue, 17 Nov 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/mskazemi/a-safety-check-is-judged-by-how-rarely-it-fires-1pn7</link>
      <guid>https://dev.to/mskazemi/a-safety-check-is-judged-by-how-rarely-it-fires-1pn7</guid>
      <description>&lt;p&gt;When you dictate into a terminal, a misheard word isn't a typo. It can be a command.&lt;/p&gt;

&lt;p&gt;So of course a dictation tool should have safety checks. "Are you sure you want to type &lt;code&gt;rm -rf&lt;/code&gt;?" Easy.&lt;/p&gt;

&lt;p&gt;What took me longer to learn is that &lt;strong&gt;a safety check has a cost every time it fires, including when it's right to.&lt;/strong&gt; And when it fires on something harmless, it does more damage than no check at all, because it teaches you to dismiss it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three guards that turned out to be one idea
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;YazSes&lt;/a&gt;, the offline dictation tool I work on, grew three guards over time, each built separately for a different symptom:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Command safety.&lt;/strong&gt; If the text about to be typed looks like a dangerous shell command (&lt;code&gt;rm -rf&lt;/code&gt;, &lt;code&gt;mkfs&lt;/code&gt;, &lt;code&gt;dd of=&lt;/code&gt;, a force-push, &lt;code&gt;curl ... | sh&lt;/code&gt;, a fork bomb: 13 patterns in all), hold it and ask.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Staged dictation.&lt;/strong&gt; Speak, review, then commit: bursts collect in a buffer instead of typing straight into a terminal or a source file, so a misheard word is caught before it lands.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No text target.&lt;/strong&gt; If the focused window has nowhere to type, don't fire keystrokes into the void. Put the text on the clipboard instead, so nothing you said is lost.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When I wrote them up together in a design record (&lt;a href="https://github.com/MSKazemi/yazses/blob/main/design/adr/adr-021-invest-in-error-cost.md" rel="noopener noreferrer"&gt;ADR-021&lt;/a&gt;), I noticed they're the same idea: &lt;em&gt;this text is about to go somewhere where being wrong is expensive.&lt;/em&gt; And they share the same risk, which the ADR names directly: becoming "an app that asks 'are you sure?' too often".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6ttv5ny7pkhc6gwrp1ku.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6ttv5ny7pkhc6gwrp1ku.png" alt="Three text-triggered guards collapsing into one destination-triggered question" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The rule
&lt;/h2&gt;

&lt;p&gt;So every guard is judged on &lt;strong&gt;how rarely it fires&lt;/strong&gt;, not on how much it catches. In practice that means two rules:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hold only on a specific, checkable signal. Never a heuristic.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first new guard built under this rule shows what that means. It catches long dictated numbers, like a card number or an ISBN, where Whisper probably misheard a digit. It would be easy to warn on "long numbers". Instead it fires only when &lt;em&gt;all&lt;/em&gt; of these hold:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the text is a bare digit string,&lt;/li&gt;
&lt;li&gt;it is 12 digits or longer,&lt;/li&gt;
&lt;li&gt;and it fails every checksum scheme (Luhn, ISBN-13, ISBN-10) whose length fits.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A house number never triggers it. A phone number never triggers it. A valid card number never triggers it. Only a number that &lt;em&gt;claims&lt;/em&gt; to be one of those formats and provably isn't.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Make letting it through one word.&lt;/strong&gt; When a guard does fire, releasing it costs you a single spoken word, not a dialog box hunt. And the command-safety and check-digit guards share the &lt;em&gt;same&lt;/em&gt; release word, so you learn one confirm phrase, not one per guard.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measure the firing rate before you ship
&lt;/h2&gt;

&lt;p&gt;The command-safety patterns were run against a corpus of 1,422 real dictations from my own use. They fired &lt;strong&gt;zero&lt;/strong&gt; times. That's the number I wanted: not "caught 100% of my test attacks" (any regex does that) but "never interrupted normal work".&lt;/p&gt;

&lt;p&gt;The check that taught me this rule the hard way was a different one. I had an experimental "cognitive load" gate: if you sound tired or rushed, slow down and confirm. In unit tests it computed its scores correctly. When I wired it into the real pipeline and replayed realistic bursts through it, &lt;strong&gt;it fired on nearly every one.&lt;/strong&gt; A guard that fires on everything is just a slower app. I reverted it, and it's still not wired in.&lt;/p&gt;

&lt;p&gt;The tests had passed. The tests proved it calculated. They didn't prove it was calibrated.&lt;/p&gt;

&lt;p&gt;One more lesson from the same pattern list: a &lt;code&gt;chmod -R 777&lt;/code&gt; pattern once shipped that could &lt;em&gt;never&lt;/em&gt; match, because the text is lower-cased before matching and the pattern had a capital &lt;code&gt;R&lt;/code&gt;. Nothing failed. It just silently didn't guard. Now a test checks that every pattern can fire on at least one example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Defaults follow the same logic
&lt;/h2&gt;

&lt;p&gt;Command safety, staged dictation and the check-digit guard are all &lt;strong&gt;off&lt;/strong&gt; by default, because they only matter for some people, and an interruption you didn't ask for is a cost. The no-text-target guard is &lt;strong&gt;on&lt;/strong&gt;, because typing letters into a window with no text field is never what you meant, and the fallback (put it on the clipboard) costs almost nothing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[cmdsafety]&lt;/span&gt;
&lt;span class="py"&gt;enabled&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

&lt;span class="nn"&gt;[staged]&lt;/span&gt;
&lt;span class="py"&gt;enabled&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

&lt;span class="nn"&gt;[checkdigit]&lt;/span&gt;
&lt;span class="py"&gt;enabled&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="py"&gt;schemes&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"luhn"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"isbn13"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"isbn10"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="py"&gt;min_digits&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;

&lt;span class="nn"&gt;[injection]&lt;/span&gt;
&lt;span class="py"&gt;target_guard&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"clipboard"&lt;/span&gt;   &lt;span class="c"&gt;# or "warn" / "off"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What I took away
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Every interruption has a price&lt;/strong&gt;, even a correct one. A dismissed guard costs attention and catches nothing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fire on a fact, not a feeling.&lt;/strong&gt; "Fails a checksum" is a fact. "Looks like a long number" is a feeling.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replay real input before you ship a gate&lt;/strong&gt;, and look at the firing rate. Passing tests prove the code runs, not that it's calibrated.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test that each rule &lt;em&gt;can&lt;/em&gt; fire.&lt;/strong&gt; A rule that can never match looks exactly like a rule that's working.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This applies far beyond voice: linters, CI gates, permission prompts, cookie banners. If people click through it without reading, it has already failed.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;YazSes is offline, open source (Apache-2.0) dictation for Linux, macOS and Windows: &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;github.com/MSKazemi/yazses&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I wrote this with help from an AI assistant for drafting and editing; the design, the measurements and the mistakes are mine, and I checked the facts against the code and ADR.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ux</category>
      <category>a11y</category>
      <category>python</category>
      <category>security</category>
    </item>
    <item>
      <title>Testing a speech app with no microphone, no network and no model</title>
      <dc:creator>Mohsen Seyedkazemi Ardebili</dc:creator>
      <pubDate>Thu, 12 Nov 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/mskazemi/testing-a-speech-app-with-no-microphone-no-network-and-no-model-1dj9</link>
      <guid>https://dev.to/mskazemi/testing-a-speech-app-with-no-microphone-no-network-and-no-model-1dj9</guid>
      <description>&lt;p&gt;A speech app sounds like the worst possible thing to unit-test. It needs a microphone, a speech model that is hundreds of megabytes, sometimes a GPU, and for some features a webcam.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;YazSes&lt;/a&gt; has none of those in its test suite. As of this week, &lt;code&gt;pytest --collect-only&lt;/code&gt; finds &lt;strong&gt;30,429 tests&lt;/strong&gt;, and the whole suite runs offline on a normal CI runner with no audio device and no model download. A new contributor can clone, run two commands, and see it go green:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uv &lt;span class="nb"&gt;sync
&lt;/span&gt;uv run python &lt;span class="nt"&gt;-m&lt;/span&gt; pytest tests/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's how, and the three tricks that keep it from lying.&lt;/p&gt;

&lt;h2&gt;
  
  
  The split: pure decisions, injected muscle
&lt;/h2&gt;

&lt;p&gt;Almost every feature is built as two modules:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pure (decides)&lt;/th&gt;
&lt;th&gt;Backend (does the heavy work)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;meeting/segmenter.py&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;meeting/silero_vad.py&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;gaze/zones.py&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;gaze/mediapipe_backend.py&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;recimport/align.py&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;recimport/diarizer.py&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The pure side imports nothing heavy. It takes the heavy thing as a parameter. The meeting segmenter, which decides where one utterance ends and the next begins, doesn't know what a voice-activity detector is. It takes a function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UtteranceSegmenter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...,&lt;/span&gt; &lt;span class="n"&gt;is_silent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Callable&lt;/span&gt;&lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ndarray&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;...):&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In production, &lt;code&gt;is_silent&lt;/code&gt; is a calibrated loudness check or Silero VAD. In a test, it's a lambda that returns whatever the test needs. The decision logic (drop leading silence, flush after enough trailing silence, never exceed the maximum length) gets tested exhaustively, in microseconds, with no audio at all.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5npbtgsqwtrw4c9hh2of.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5npbtgsqwtrw4c9hh2of.png" alt="Pure decision modules on the left take heavy backends on the right as parameters" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The backend side is thin and does one thing: load the model and answer the question. It's tested separately, mostly for "what happens when the model isn't there".&lt;/p&gt;

&lt;h2&gt;
  
  
  Trick 1: heavy imports go inside functions
&lt;/h2&gt;

&lt;p&gt;Optional backends are optional extras. Silero, for example, pulls in PyTorch. When I measured &lt;code&gt;pip install yazses[silero]&lt;/code&gt; it resolved to 25 packages and about 3 GB, mostly the CUDA stack. Nobody should download that to get dictation.&lt;/p&gt;

&lt;p&gt;So heavy imports live inside the function that needs them, and a missing extra degrades gracefully:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;silero_vad&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;load_silero_vad&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;warning&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;`silero` extra not installed (%s).&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;load_silero_vad&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;onnx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rules like this rot unless something enforces them. There's now a static test (on &lt;code&gt;main&lt;/code&gt;, in the next release) that parses every module a base install can import and fails if any of them imports an extra at module level.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trick 2: make dependencies disappear &lt;em&gt;before&lt;/em&gt; pytest starts
&lt;/h2&gt;

&lt;p&gt;One CI leg runs on FreeBSD, where &lt;code&gt;faster-whisper&lt;/code&gt;, &lt;code&gt;ctranslate2&lt;/code&gt; and friends have no wheels. Tests that touch the decoder should &lt;em&gt;skip&lt;/em&gt; there, not fail.&lt;/p&gt;

&lt;p&gt;Testing that locally used to mean a FreeBSD VM. Now there's a script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uv run python scripts/simulate-missing-deps.py &lt;span class="nt"&gt;--&lt;/span&gt; tests/ &lt;span class="nt"&gt;-q&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It makes those packages unimportable with a &lt;code&gt;sys.meta_path&lt;/code&gt; finder installed through a generated &lt;code&gt;sitecustomize&lt;/code&gt;, so the block is active before pytest collects a single file. It raises a real &lt;code&gt;ModuleNotFoundError&lt;/code&gt;, which means &lt;code&gt;pytest.importorskip&lt;/code&gt; and &lt;code&gt;except ImportError&lt;/code&gt; branches actually run. Mocking an import inside a fixture is too late; by then something has usually imported it already.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trick 3: fuzz the path to the keyboard
&lt;/h2&gt;

&lt;p&gt;The most dangerous code in a dictation app is the text path between the speech model and the keyboard. Whatever comes out of there gets &lt;em&gt;typed into someone's window&lt;/em&gt;. So that path, plus the config loader's promise that loading a config never raises, has coverage-guided fuzzing with &lt;a href="https://github.com/google/atheris" rel="noopener noreferrer"&gt;Atheris&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python fuzz/fuzz_text_pipeline.py &lt;span class="nt"&gt;-atheris_runs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;200000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A crash there is treated as a real bug, and the crashing input becomes a regression test.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this doesn't cover
&lt;/h2&gt;

&lt;p&gt;Honestly: the real microphone, the real model and the real window. Mocked tests can prove the logic is right. They can't prove a particular Wayland compositor accepts the keystrokes, or that a particular Windows app decodes them. Two other posts in this series (2 and 5) are about exactly that gap. For those, nothing replaces a person on a real machine running &lt;code&gt;yazses doctor&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I took away
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Put decisions where a fake can drive them.&lt;/strong&gt; If testing a rule needs a model, the rule is in the wrong module.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Optional" has to be enforced by a test&lt;/strong&gt;, or the first convenient top-level import makes it mandatory.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Simulate a missing dependency before collection, not in a fixture.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fuzz the code whose output is irreversible.&lt;/strong&gt; For us, that's text going into a window.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're building anything on top of a big model (speech, vision, an LLM), the same split works: keep the model behind a function signature, and test everything around it without it.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;YazSes is offline, open source (Apache-2.0) dictation: &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;github.com/MSKazemi/yazses&lt;/a&gt;. The suite runs in a few minutes on a laptop, and the &lt;a href="https://github.com/MSKazemi/yazses/blob/main/.github/CONTRIBUTING.md" rel="noopener noreferrer"&gt;contributing guide&lt;/a&gt; explains the layout.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I wrote this with help from an AI assistant for drafting and editing; the architecture and the opinions are mine, and I checked every fact against the repository.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>testing</category>
      <category>architecture</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Turning "nothing leaves the machine" into a test that fails the build</title>
      <dc:creator>Mohsen Seyedkazemi Ardebili</dc:creator>
      <pubDate>Fri, 06 Nov 2026 04:19:12 +0000</pubDate>
      <link>https://dev.to/mskazemi/turning-nothing-leaves-the-machine-into-a-test-that-fails-the-build-2hk</link>
      <guid>https://dev.to/mskazemi/turning-nothing-leaves-the-machine-into-a-test-that-fails-the-build-2hk</guid>
      <description>&lt;p&gt;"Your audio never leaves your machine."&lt;/p&gt;

&lt;p&gt;Lots of apps say something like that. &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;YazSes&lt;/a&gt;, the offline dictation tool I maintain, says it too. The question I eventually had to answer was: &lt;strong&gt;how would I know if it stopped being true?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not "is it true today". I believed it was. But a project with contributors, optional extras and a year of features doesn't stay the way you remember it. Someone adds a model downloader. Someone adds an update checker. Each one is reasonable, and each one is a hole in a sentence on the front page.&lt;/p&gt;

&lt;h2&gt;
  
  
  The promise was missing its exceptions
&lt;/h2&gt;

&lt;p&gt;The honest version of "nothing leaves the machine" was never "zero network code". An offline speech app still has to download a model once. It may check for updates if you ask. There's an optional feature that sends dictation to a &lt;em&gt;local&lt;/em&gt; LLM for clean-up. There's a remote-dictation mode where you explicitly forward text to another machine over SSH.&lt;/p&gt;

&lt;p&gt;So the real promise is: &lt;strong&gt;these specific paths exist, they do these specific things, and nothing else talks to the network.&lt;/strong&gt; That is a list. And a list can be tested.&lt;/p&gt;

&lt;p&gt;The list is written down in a design record (&lt;a href="https://github.com/MSKazemi/yazses/blob/main/design/adr/adr-019-egress-inventory-and-escalation.md" rel="noopener noreferrer"&gt;ADR-019&lt;/a&gt;). Every module that can reach the network is declared and classified:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fetch&lt;/strong&gt; paths only pull things in: a model, a release, a package index. They never send what you said.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Send&lt;/strong&gt; paths can transmit dictated text. There are exactly &lt;strong&gt;two&lt;/strong&gt;, and both are fenced:

&lt;ul&gt;
&lt;li&gt;the LLM clean-up path, which refuses anything that isn't a loopback address;&lt;/li&gt;
&lt;li&gt;the remote proxy, which only talks to the host you named on the command line.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some data may &lt;strong&gt;never&lt;/strong&gt; leave, whatever the user consents to: voiceprints, the local learning corpus, and audio captured from other people in a meeting.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fffbsko0oashaobvmg2i2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fffbsko0oashaobvmg2i2.png" alt="The privacy promise as a list: fetch paths, exactly two send paths, and data that never leaves" width="800" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The test
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;tests/test_egress_inventory.py&lt;/code&gt; walks every Python file under &lt;code&gt;src/yazses/&lt;/code&gt; with the &lt;code&gt;ast&lt;/code&gt; module and collects anything that looks like an outbound primitive:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Import&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;alias&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;_NETWORK_ROOTS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="nf"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ImportFrom&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;_NETWORK_ROOTS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;_NETWORK_ROOTS&lt;/code&gt; covers the usual suspects: &lt;code&gt;urllib&lt;/code&gt;, &lt;code&gt;http&lt;/code&gt;, &lt;code&gt;socket&lt;/code&gt;, &lt;code&gt;requests&lt;/code&gt;, &lt;code&gt;httpx&lt;/code&gt;, &lt;code&gt;aiohttp&lt;/code&gt;, &lt;code&gt;ftplib&lt;/code&gt;, &lt;code&gt;smtplib&lt;/code&gt;, &lt;code&gt;asyncio&lt;/code&gt;, &lt;code&gt;webbrowser&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then it compares what it found with what's declared, &lt;strong&gt;in both directions&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A module that uses the network but isn't declared fails the build. That catches the new downloader nobody registered.&lt;/li&gt;
&lt;li&gt;A module that's declared but no longer uses the network &lt;em&gt;also&lt;/em&gt; fails. That keeps the list from rotting into "things that used to be true".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And one line holds the central claim:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SEND&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;...That is a change to the project&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s central privacy claim &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;and needs an ADR, not a test edit.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The error message is aimed at the next contributor (or me, six months from now). If you need a third path that can send what the user said, that's a design decision, and the test tells you where to have it.&lt;/p&gt;

&lt;p&gt;There's also a test that the scan finds &lt;em&gt;something&lt;/em&gt;. A scanner that silently matches nothing is green forever.&lt;/p&gt;

&lt;h2&gt;
  
  
  It missed one. Then it got wider.
&lt;/h2&gt;

&lt;p&gt;The first version only looked at imports. It missed the SSH tunnel that carries remote dictation, because that module doesn't import &lt;code&gt;socket&lt;/code&gt; at all. It runs &lt;code&gt;ssh&lt;/code&gt; as a subprocess.&lt;/p&gt;

&lt;p&gt;So the scan grew a second pass for spawned programs: tool names inside a list literal, the shape of an &lt;code&gt;argv&lt;/code&gt;. Later passes added model loaders that download weights by name, a "open this in the browser" handoff, and code that reuses the shared release downloader. Each one came from asking the same question again: &lt;strong&gt;what can this scan still not see?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Today the inventory has more categories than just fetch and send: shell-outs, dependency installers, local-only IPC sockets. The "two paths that can send what you said" number has not changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it can't do
&lt;/h2&gt;

&lt;p&gt;A static scan finds the mechanisms someone thought of. It cannot find a mechanism nobody thought of. A dependency could open a socket from C code; a new library could phone home on import.&lt;/p&gt;

&lt;p&gt;So the docs also publish a check you can run yourself, which doesn't trust my scanner at all: run the app in a container with no network.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;--network&lt;/span&gt; none &lt;span class="nt"&gt;-v&lt;/span&gt; yazses-models:/home/yazses/.cache &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PWD&lt;/span&gt;&lt;span class="s2"&gt;:/data"&lt;/span&gt; ghcr.io/mskazemi/yazses transcribe jfk.wav
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That transcribes a file with networking switched off entirely (after the model has been downloaded once into the volume). If it works there, it doesn't need the network. (One related measurement from the ADR: with &lt;code&gt;HF_HUB_OFFLINE=1&lt;/code&gt;, a cached Whisper model loads in 1.9 seconds on a blackholed network. Without it, the load was still hanging after three minutes, because the Hugging Face library kept trying to reach the Hub.)&lt;/p&gt;

&lt;h2&gt;
  
  
  What I took away
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A promise with unlisted exceptions is not testable.&lt;/strong&gt; Write the exceptions down first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compare sets in both directions.&lt;/strong&gt; "Nothing new appeared" and "nothing old disappeared" are both drift.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test that your detector detects.&lt;/strong&gt; An empty result is the most dangerous green.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Put the reasoning in the assertion message.&lt;/strong&gt; The person who trips it needs to know &lt;em&gt;why&lt;/em&gt; it exists, not just that it failed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Offer users a check that doesn't depend on your code.&lt;/strong&gt; "Run it with no network" beats "trust my test".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your app makes a privacy claim, try writing the list. You might find, like I did, that the sentence on your front page had exceptions you'd never written down.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;YazSes is offline, open source (Apache-2.0) dictation for Linux, macOS and Windows: &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;github.com/MSKazemi/yazses&lt;/a&gt;. The full inventory: &lt;a href="https://github.com/MSKazemi/yazses/blob/main/design/adr/adr-019-egress-inventory-and-escalation.md" rel="noopener noreferrer"&gt;ADR-019&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I wrote this with help from an AI assistant for drafting and editing; the design, the test and the opinions are mine, and I checked every fact against the code and the ADR.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>privacy</category>
      <category>python</category>
      <category>testing</category>
      <category>security</category>
    </item>
    <item>
      <title>SendInput said success. The app got a row of question marks.</title>
      <dc:creator>Mohsen Seyedkazemi Ardebili</dc:creator>
      <pubDate>Thu, 05 Nov 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/mskazemi/sendinput-said-success-the-app-got-a-row-of-question-marks-1ca7</link>
      <guid>https://dev.to/mskazemi/sendinput-said-success-the-app-got-a-row-of-question-marks-1ca7</guid>
      <description>&lt;p&gt;Here is a bug report I could not have found in a log file.&lt;/p&gt;

&lt;p&gt;I dictated a sentence on Windows. In Chrome it arrived perfectly. In a notes app, the same sentence arrived as the right &lt;em&gt;number&lt;/em&gt; of characters, every one of them wrong: rows of &lt;code&gt;?&lt;/code&gt;, or &lt;code&gt;-&lt;/code&gt;, or &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The code that typed both was identical. And in both cases, Windows told me it worked.&lt;/p&gt;

&lt;h2&gt;
  
  
  How text gets typed on Windows
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;YazSes&lt;/a&gt; is an offline dictation tool. After transcribing your speech, it has to type the text into whatever window has focus. On Windows the standard way is &lt;code&gt;SendInput&lt;/code&gt; with the &lt;code&gt;KEYEVENTF_UNICODE&lt;/code&gt; flag: instead of pressing physical keys, you send each character as a Unicode code point. Windows wraps it in a special virtual key called &lt;code&gt;VK_PACKET&lt;/code&gt; and delivers it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SendInput&lt;/code&gt; returns the number of events it inserted into the input stream. Inserted. Not "received correctly by the app". It has no idea what the receiving window does next.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two ways the receiver can break it
&lt;/h2&gt;

&lt;p&gt;Microsoft's own documentation describes two ways &lt;code&gt;VK_PACKET&lt;/code&gt; input goes wrong, and both are properties of the &lt;em&gt;receiving&lt;/em&gt; app, not the sender:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The window is an ANSI window.&lt;/strong&gt; Each character gets converted to the system's active ANSI code page. Anything that code page can't represent becomes &lt;code&gt;?&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A text service or input handler doesn't unpack &lt;code&gt;VK_PACKET&lt;/code&gt;.&lt;/strong&gt; It treats the packet as an ordinary key and runs it through the keyboard layout instead, which gives you whatever character that key happens to be.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxg9pu0v2u63negcucbnt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxg9pu0v2u63negcucbnt.png" alt="SendInput reports what the sender did; the receiving window decides what arrives" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Chromium handles &lt;code&gt;VK_PACKET&lt;/code&gt; carefully. So testing in a browser proves almost nothing about other apps. That is a sobering thought for anyone who tested their Windows input code by typing into Chrome. (I did.)&lt;/p&gt;

&lt;p&gt;To be honest about what I know: the symptom is real, I saw it on my own machine. &lt;strong&gt;Which&lt;/strong&gt; of the two causes applied in that app, I have not proven. I diagnosed it from the code and the docs, not from a debugger on the failing window.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I changed
&lt;/h2&gt;

&lt;p&gt;You can't fix someone else's window. But you can stop pretending you know whether it worked, and you can offer a path that doesn't depend on &lt;code&gt;VK_PACKET&lt;/code&gt; at all.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. A clipboard backend (opt-in).&lt;/strong&gt; Put the text on the clipboard as &lt;code&gt;CF_UNICODETEXT&lt;/code&gt;, send a real Ctrl+V, then restore whatever was on the clipboard before. Almost every app handles paste correctly, because paste is the thing users do all day.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;inject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;
    &lt;span class="n"&gt;user32&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;_load_clipboard_user32&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;kernel32&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;_load_kernel32&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;previous&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;_Clipboard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user32&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;previous&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;_read_unicode_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;kernel32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;_write_unicode_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;kernel32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_SETTLE_S&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_send_ctrl_v&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;# ...then the previous clipboard text is put back
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[injection]&lt;/span&gt;
&lt;span class="py"&gt;backend&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"clipboard"&lt;/span&gt;   &lt;span class="c"&gt;# typing stays the default&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While doing this I found that the &lt;code&gt;[injection] backend&lt;/code&gt; setting had been &lt;em&gt;ignored&lt;/em&gt; on Windows entirely: the platform layer hard-coded the typing injector. So "try the clipboard backend" would have silently done nothing. Fixed in the same release (v2.40.0).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. A diagnostic that names the receiver.&lt;/strong&gt; Instead of guessing which window misbehaves, ask it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yazses inject -d 5 --diagnose "hello"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get five seconds to click into the problem app. Then it types "hello" and reports the window class, whether Windows considers it a Unicode window (&lt;code&gt;IsWindowUnicode&lt;/code&gt;), and the active keyboard layout. If the window is ANSI, the cause is cause 1. If it's Unicode and still garbled, look at the input method.&lt;/p&gt;

&lt;h2&gt;
  
  
  The honest status
&lt;/h2&gt;

&lt;p&gt;What is verified on a real Windows machine: the symptom.&lt;/p&gt;

&lt;p&gt;What is &lt;strong&gt;not&lt;/strong&gt; yet verified on real Windows: that the clipboard backend fixes that particular app, and that &lt;code&gt;--diagnose&lt;/code&gt; gives the right verdict in the wild. The unit tests mock the Win32 calls. I don't have a Windows box I can debug on regularly. That is a real gap, and I'd rather say it here than have you discover it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I took away
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;"The API returned success" describes the sender.&lt;/strong&gt; Whether input arrives intact is decided by the receiver.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test against more than one receiver.&lt;/strong&gt; A browser is the most forgiving target there is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When you can't fix a failure, make it describe itself.&lt;/strong&gt; A diagnostic that prints the receiving window's properties turns a "it types garbage sometimes" report into one with a cause in it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're on Windows and have an app that garbles synthesized input, I would genuinely like the output of &lt;code&gt;yazses inject -d 5 --diagnose "hello"&lt;/code&gt; from it. &lt;a href="https://github.com/MSKazemi/yazses/issues/183" rel="noopener noreferrer"&gt;Issue #183&lt;/a&gt; is where Windows testing is collected.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;YazSes is an offline, open-source (Apache-2.0) dictation tool: &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;github.com/MSKazemi/yazses&lt;/a&gt;. Windows install: &lt;code&gt;winget install MSKazemi.YazSes&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I wrote this with help from an AI assistant for drafting and editing; the bug, the diagnosis and the conclusions are mine, and I checked the facts against the code, Microsoft's documentation and the release notes.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>windows</category>
      <category>python</category>
      <category>debugging</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Whisper typed its own prompt into my document</title>
      <dc:creator>Mohsen Seyedkazemi Ardebili</dc:creator>
      <pubDate>Tue, 03 Nov 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/mskazemi/whisper-typed-its-own-prompt-into-my-document-589c</link>
      <guid>https://dev.to/mskazemi/whisper-typed-its-own-prompt-into-my-document-589c</guid>
      <description>&lt;p&gt;If you use &lt;code&gt;faster-whisper&lt;/code&gt; or &lt;code&gt;openai-whisper&lt;/code&gt; with an &lt;code&gt;initial_prompt&lt;/code&gt;, try this sometime. Record two seconds of a fan, or a keyboard, or nothing in particular, loud enough to pass whatever loudness check you have. Transcribe it.&lt;/p&gt;

&lt;p&gt;There is a decent chance you get your prompt back.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;YazSes&lt;/a&gt;, the offline dictation tool I work on, the built-in prompt is one short sentence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;BUILTIN_PROMPT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The app is called YazSes.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is there so Whisper spells the app's name right. And on a noisy burst with no speech in it, Whisper would sometimes transcribe it as... "The app is called YazSes." Typed straight into whatever window you had open. (&lt;a href="https://github.com/MSKazemi/yazses/issues/598" rel="noopener noreferrer"&gt;#598&lt;/a&gt; has the details.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this happens
&lt;/h2&gt;

&lt;p&gt;Whisper treats &lt;code&gt;initial_prompt&lt;/code&gt; as if it were the text that came just before the audio. My working explanation (a hypothesis, not something I have proven inside the model) is that when the audio carries no words, the easiest thing for the decoder to produce is the text it was just shown. Loud noise is the worst case: a quiet clip gets dropped by the energy gate before Whisper sees it, but a loud one gets through.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the obvious fix doesn't work
&lt;/h2&gt;

&lt;p&gt;Whisper reports a &lt;code&gt;no_speech_prob&lt;/code&gt; for each segment. Surely you just drop segments where it is high?&lt;/p&gt;

&lt;p&gt;I measured it, with the &lt;code&gt;small&lt;/code&gt;, &lt;code&gt;base.en&lt;/code&gt; and &lt;code&gt;tiny.en&lt;/code&gt; models on synthetic noise bursts (white, brown and low-frequency noise and clicks, half a second to three seconds). On the echoes, &lt;code&gt;no_speech_prob&lt;/code&gt; ranged from &lt;strong&gt;0.43 to 0.97&lt;/strong&gt;. On a public-domain speech sample it was &lt;strong&gt;0.02 to 0.27&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Two problems with cutting on that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;faster-whisper's default &lt;code&gt;no_speech_threshold&lt;/code&gt; is 0.6. Every echo between 0.43 and 0.6 sails straight through the default settings.&lt;/li&gt;
&lt;li&gt;The gap between 0.27 and 0.43 comes from one speech sample and some synthetic noise. I would not bet a user's words on a cutoff placed inside a gap that narrow, measured that thinly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And it wasn't only the built-in prompt. A personal vocabulary list came back too: "Ydotool, ydotool, Mohsen, Wayland." Whatever you prime the model with is what it reaches for when there is nothing to hear.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: ask a different model
&lt;/h2&gt;

&lt;p&gt;The fix is to stop asking Whisper whether there was speech, and ask an independent detector &lt;em&gt;before&lt;/em&gt; decoding.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;faster-whisper&lt;/code&gt; already bundles &lt;a href="https://github.com/snakers4/silero-vad" rel="noopener noreferrer"&gt;Silero VAD&lt;/a&gt;, so it costs no new dependency. Before a burst is decoded, YazSes asks Silero whether it holds any speech. If Silero positively says no, the burst is discarded and logged as &lt;code&gt;discard_reason = "no_speech"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9x70t0g5h8mcewrel5u1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9x70t0g5h8mcewrel5u1.png" alt="Energy gate, then Silero VAD; only a positive 'no speech' discards the burst" width="800" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The most important design decision is the direction it fails in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;holds_no_speech&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;audio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sample_rate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;detector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Detector&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;True only when the detector *positively* found no speech. Never raises.

    ``None`` from the detector (unavailable, wrong sample rate) and any exception both
    read as &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cannot tell&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;, which is ``False``: the burst is decoded.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;verdict&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;detector&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;_default_detector&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="n"&gt;audio&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sample_rate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# noqa: BLE001 - a gate must never break dictation
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;verdict&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It &lt;strong&gt;fails open&lt;/strong&gt;. If Silero can't run, can't load, or gets audio at the wrong rate, the burst is decoded exactly as before. Think about the costs: a phantom sentence is annoying and you delete it. Silently swallowing words the user actually said is much worse, because they may not notice until later. A gate that guards against the small error must never cause the big one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing the threshold
&lt;/h2&gt;

&lt;p&gt;Silero's default speech threshold is 0.5. I used &lt;strong&gt;0.3&lt;/strong&gt;, and here is the evidence, including its limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I cut 22 single-word bursts from the public-domain JFK speech sample and made 27 seeded noise bursts.&lt;/li&gt;
&lt;li&gt;At 0.3: 0 words dropped, 0 noise bursts passed.&lt;/li&gt;
&lt;li&gt;At 0.5: 2 quiet words were lost.&lt;/li&gt;
&lt;li&gt;With a crude "whisper" proxy (random-phase audio), 3 of 22 words were lost at 0.3.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is synthetic audio and a small set. I have &lt;strong&gt;not&lt;/strong&gt; measured it on real whispered, accented or dysarthric speech, and those are exactly the users a dictation tool should care about most. So the check is skipped in the modes built for them: whispered/low-effort mode, the dysfluency-friendly mode and the quiet sotto-voce channel. It can also be turned off:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[accessibility]&lt;/span&gt;
&lt;span class="py"&gt;speech_presence_check&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;   &lt;span class="c"&gt;# the default since v2.43.2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What I took away
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Loudness can't tell a person from a fan.&lt;/strong&gt; An energy gate is a first filter, not a speech detector.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't ask the model that is failing whether it is failing.&lt;/strong&gt; Its own &lt;code&gt;no_speech_prob&lt;/code&gt; let echoes through at default settings. A second, independent model that never saw the prompt answers the question more cleanly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decide which way a gate should fail before you write it.&lt;/strong&gt; Then write the test for the failure, not just the happy path.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you run Whisper with a prompt in any app (meeting notes, voice notes, subtitles), check what it returns on two seconds of loud noise. It takes a minute and you may be surprised.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;The fix shipped in YazSes v2.43.2 (&lt;a href="https://github.com/MSKazemi/yazses/blob/main/docs/releases/v2.43.2.md" rel="noopener noreferrer"&gt;release notes&lt;/a&gt;). YazSes is offline, open source and Apache-2.0: &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;github.com/MSKazemi/yazses&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I wrote this with help from an AI assistant for drafting and editing; the bug, the measurements and the design choices are mine, and I checked every fact against the code and release notes.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>ai</category>
      <category>opensource</category>
    </item>
    <item>
      <title>My dictation app typed words I never said. The silence gate was quieter than my room.</title>
      <dc:creator>Mohsen Seyedkazemi Ardebili</dc:creator>
      <pubDate>Thu, 29 Oct 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/mskazemi/my-dictation-app-typed-words-i-never-said-the-silence-gate-was-quieter-than-my-room-26d0</link>
      <guid>https://dev.to/mskazemi/my-dictation-app-typed-words-i-never-said-the-silence-gate-was-quieter-than-my-room-26d0</guid>
      <description>&lt;p&gt;One afternoon my own dictation tool started typing sentences I had not said.&lt;/p&gt;

&lt;p&gt;Not garbage. Fluent, confident, plausible English. If you have used Whisper, you may already know where this is going.&lt;/p&gt;

&lt;h2&gt;
  
  
  Whisper does not do "nothing"
&lt;/h2&gt;

&lt;p&gt;Speech models like Whisper are trained to produce text. Hand one a clip of an empty room, and it will very often give you words anyway, a phrase it has seen a thousand times, or something that sounds like a polite closing line. This is well known, and the usual defence is simple: &lt;strong&gt;don't send it silence&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;YazSes&lt;/a&gt; (an offline hold-to-talk dictation tool I maintain) the first defence is an energy gate. When you release the key, it computes the mean absolute level of the recording. If that is below a threshold, the clip is dropped and Whisper never sees it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[accessibility]&lt;/span&gt;
&lt;span class="py"&gt;vad_threshold&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;   &lt;span class="c"&gt;# the default&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My own config said &lt;code&gt;0.0005&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;My room's noise floor, measured, was around &lt;code&gt;0.0039&lt;/code&gt;. The gate sat almost eight times &lt;em&gt;below&lt;/em&gt; the room. Every time I pressed the key without speaking, or paused before talking, the fan and the street went straight through to Whisper, and Whisper wrote me some prose.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb6aw1rdq6w9uisfe67pl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb6aw1rdq6w9uisfe67pl.png" alt="The energy gate: speech, room noise, and where a threshold must sit" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Three things that went wrong at once
&lt;/h2&gt;

&lt;p&gt;It is tempting to blame "a bad config value". But three separate things had to fail for me to &lt;em&gt;not notice&lt;/em&gt; for a while.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The value was below the noise.&lt;/strong&gt; I don't actually know how &lt;code&gt;0.0005&lt;/code&gt; got into my config. It does not matter much. Any threshold that is not measured against the room it runs in is a guess.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The warning that should have caught it was silent.&lt;/strong&gt; &lt;code&gt;yazses doctor --mic&lt;/code&gt; measured the room and compared it with the threshold. In exactly this case, it printed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[OK] Mic level: ambient 0.0010 under vad_threshold 0.0005
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read that twice. 0.0010 is not under 0.0005.&lt;/p&gt;

&lt;p&gt;The warning only fired when the room was "not silent", and "silent" was judged against a &lt;em&gt;fixed&lt;/em&gt; floor of 0.002 that had nothing to do with my gate. So for any threshold below 0.002, the warning was switched off across exactly the band where it was needed. The one check designed for this situation reported success. (Fixed back in v2.25.1. It now says, plainly, that silence will pass the gate and be transcribed as invented words.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. The calibrator measured the wrong thing.&lt;/strong&gt; There was a &lt;code&gt;mic-level&lt;/code&gt; command to pick a threshold for you. It recorded &lt;em&gt;one&lt;/em&gt; clip and assumed you were speaking in it. If you weren't, it calibrated to the room. In four empty-room recordings it measured 0.0036 to 0.0050 and recommended 0.002 to 0.0025: below the noise, every single time.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to calibrate a gate properly
&lt;/h2&gt;

&lt;p&gt;The fix is boring, and that is the point.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Measure the room and the voice separately.&lt;/strong&gt; Since v2.36.0, &lt;code&gt;yazses mic-level&lt;/code&gt; records a few seconds of silence first, then a few seconds of you talking. Now there are two numbers, and the gate must sit between them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_MIN_THRESHOLD&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;room&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# comfortably above the room
&lt;/span&gt;&lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;speech&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;                       &lt;span class="c1"&gt;# comfortably below your voice
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Refuse when the numbers are too close.&lt;/strong&gt; If &lt;code&gt;hi &amp;lt; lo&lt;/code&gt;, the voice and the room are less than 3x apart. At that point any threshold you pick will either let noise through or eat quiet words. The honest output is not a number. It is "I can't calibrate this, move the mic or lower the gain." So it refuses.&lt;/p&gt;

&lt;p&gt;That 3x is not tuned, by the way. It falls out of the two margins (1.5 / 0.5). For reference, across 1,646 real dictation events, speech had a median level of 0.0394 and clips that passed the gate but produced no text had a median of 0.0069, about 5.7x apart. Plenty of room, &lt;em&gt;if&lt;/em&gt; you measure it.&lt;/p&gt;

&lt;p&gt;The next release goes one step further (already on &lt;code&gt;main&lt;/code&gt;): it aims the gate at twice the room level instead of halfway between room and voice, and it refuses recordings that are too short to say anything (under one second of room or two seconds of speech). That came from a bug report that &lt;code&gt;mic-level --set&lt;/code&gt; picked a different threshold on every run.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I took away
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A threshold is meaningless without the noise it is meant to reject.&lt;/strong&gt; Measure the noise, in place, on the real device.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One sample cannot tell you whether anyone spoke in it.&lt;/strong&gt; If your calibration depends on the user doing something, record that something separately.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When two measurements are too close, refuse.&lt;/strong&gt; A confident wrong number is worse than "I can't".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test your warnings in the case they exist for.&lt;/strong&gt; My warning was fine in every case except the one it was written for.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you dictate with Whisper (any tool, not just mine) and you see phantom text, check your silence gate before you blame the model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yazses mic-level          &lt;span class="c"&gt;# measures room, then voice, and suggests a threshold&lt;/span&gt;
yazses mic-level &lt;span class="nt"&gt;--set&lt;/span&gt;    &lt;span class="c"&gt;# writes it to your config&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;em&gt;YazSes is offline, open source (Apache-2.0), and runs on Linux, macOS and Windows: &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;github.com/MSKazemi/yazses&lt;/a&gt;. How the gate works in detail: &lt;a href="https://github.com/MSKazemi/yazses/blob/main/docs/how-to/silent-audio-discarding.md" rel="noopener noreferrer"&gt;silent audio discarding&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I wrote this with help from an AI assistant for drafting and editing; the incident, the numbers and the conclusions are mine, and I checked each fact against the code and changelog.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>linux</category>
      <category>debugging</category>
    </item>
    <item>
      <title>Can an AI agent's decision produce a verifiable receipt? An architecture proposal</title>
      <dc:creator>Mohsen Seyedkazemi Ardebili</dc:creator>
      <pubDate>Wed, 28 Oct 2026 00:45:01 +0000</pubDate>
      <link>https://dev.to/mskazemi/can-an-ai-agents-decision-produce-a-verifiable-receipt-an-architecture-proposal-12do</link>
      <guid>https://dev.to/mskazemi/can-an-ai-agents-decision-produce-a-verifiable-receipt-an-architecture-proposal-12do</guid>
      <description>&lt;p&gt;Explore how Jev and NovaFabric could support verifiable AI agent decision receipts, policy checks, and replayable execution evidence. This is a research proposal, not a shipped integration.&lt;/p&gt;

&lt;p&gt;Imagine an AI agent working on a data-processing task.&lt;/p&gt;

&lt;p&gt;At some point, it decides to upload a file to an external endpoint. The operation succeeds, and the workflow continues.&lt;/p&gt;

&lt;p&gt;Six months later, someone asks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why did the agent decide to upload that file?&lt;/li&gt;
&lt;li&gt;What information was available when the decision was made?&lt;/li&gt;
&lt;li&gt;Which model evaluated the action?&lt;/li&gt;
&lt;li&gt;Was the action authorized?&lt;/li&gt;
&lt;li&gt;Can we verify the original record without trusting the running system?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A successful HTTP response cannot answer those questions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What if every important AI-agent decision could produce a verifiable receipt?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a research direction I'm exploring around two technologies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://typesafe.ai/blog/introducing-system-one-models-and-jev" rel="noopener noreferrer"&gt;&lt;strong&gt;Jev&lt;/strong&gt;&lt;/a&gt;, a System One model from TypeSafe AI designed for fast, structured decisions.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/MSKazemi/novafabric" rel="noopener noreferrer"&gt;&lt;strong&gt;NovaFabric&lt;/strong&gt;&lt;/a&gt;, an open-source system I've been developing to capture, replay, compare, and verify AI-agent execution evidence.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The idea is not to connect two APIs and call it an integration.&lt;/p&gt;

&lt;p&gt;It's to investigate how we might preserve the evidence behind an AI decision so that engineers, researchers, and auditors can inspect it later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Current status:&lt;/strong&gt; This is an architectural proposal. The Jev integration described here has not been shipped or benchmarked, and there is no announced partnership with TypeSafe AI.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Why Jev is interesting
&lt;/h2&gt;

&lt;p&gt;Many AI-agent decisions don't require an essay.&lt;/p&gt;

&lt;p&gt;An agent might need to answer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is this tool call consistent with the assigned task?&lt;/li&gt;
&lt;li&gt;Which risk category best describes an operation?&lt;/li&gt;
&lt;li&gt;Does this answer satisfy a particular evaluation criterion?&lt;/li&gt;
&lt;li&gt;Does a delegated action appear to exceed the original task?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Traditional LLMs can answer these questions, but generating explanatory text is not always the right interface.&lt;/p&gt;

&lt;p&gt;TypeSafe AI's Jev exposes three useful primitives:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Primitive&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Choice&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Select from predefined options&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Score&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Evaluate something against a defined rubric&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Noul&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Return a probability for a yes/no proposition&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For example, we might ask Jev whether an agent's proposed file transfer appears unrelated to its assigned task.&lt;/p&gt;

&lt;p&gt;But there is a critical distinction:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A model's probability is not proof that an action is safe, unsafe, or authorized.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is a signal that must be evaluated against real outcomes and combined with independently enforced rules.&lt;/p&gt;

&lt;p&gt;That's where the next part becomes interesting.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. What NovaFabric adds
&lt;/h2&gt;

&lt;p&gt;NovaFabric focuses on something different from model inference: preserving agent execution evidence.&lt;/p&gt;

&lt;p&gt;Its central artifact is a &lt;strong&gt;Run Capsule&lt;/strong&gt;, a portable directory containing recorded execution information from supported capture surfaces.&lt;/p&gt;

&lt;p&gt;Depending on the workload, that includes model calls, tool calls, execution traces, environment information, and provenance.&lt;/p&gt;

&lt;p&gt;NovaFabric supports structural comparison and scoped replay. Capsules can also be cryptographically sealed using an operator-configured key, making later modifications detectable.&lt;/p&gt;

&lt;p&gt;If you want to try the verification side today, this tutorial walks through it end to end: &lt;a href="https://novafabric.ai/docs/tutorials/prove-a-run-to-an-auditor/" rel="noopener noreferrer"&gt;Verify a sealed AI agent run for an auditor, offline&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This matters because an AI decision has two distinct questions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Was the judgment useful or correct?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That requires evaluation against evidence and outcomes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is the archived decision record unchanged?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That can be checked using cryptographic integrity mechanisms, subject to their trust assumptions.&lt;/p&gt;

&lt;p&gt;These are different problems. We should not confuse them.&lt;/p&gt;

&lt;p&gt;For more background, see my arXiv preprint:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://arxiv.org/abs/2609.12582" rel="noopener noreferrer"&gt;&lt;strong&gt;NovaFabric: Tamper-Evident, Replayable Evidence for Autonomous AI Agent Runs&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. The idea: a Decision Witness
&lt;/h2&gt;

&lt;p&gt;I'm considering an optional component called a &lt;strong&gt;Decision Witness&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Think of it as a versioned record that connects an agent action with the information used to assess and authorize it.&lt;/p&gt;

&lt;p&gt;A proposed record could contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An identifier for the tool call or agent action.&lt;/li&gt;
&lt;li&gt;The model and version used for an assessment.&lt;/li&gt;
&lt;li&gt;The question template and relevant input digest.&lt;/li&gt;
&lt;li&gt;The model's structured output and probability distribution.&lt;/li&gt;
&lt;li&gt;The applicable policy and authorization result.&lt;/li&gt;
&lt;li&gt;Human approval information, when relevant.&lt;/li&gt;
&lt;li&gt;A reference to the captured execution evidence.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's an illustrative schema:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"schema_version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"decision-witness/0.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"event_ref"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tool-call-42"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"assessment"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"provider"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"typesafe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"model_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;pinned-jev-version&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"question_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"off_task_transfer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"noul"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"probability"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.87&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"policy_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"outbound-policy-v3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"outcome"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"review_required"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"human_approval"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"pending"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"origin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"observed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"evidence_ref"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"sha256:&amp;lt;digest&amp;gt;"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;This is a hypothetical design example, not an implemented NovaFabric schema or a real Jev response. The probability is illustrative.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The important feature isn't the number &lt;code&gt;0.87&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It's the ability to revisit the evidence, policy, and decision that accompanied it.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. How could the architecture work?
&lt;/h2&gt;

&lt;p&gt;A possible architecture:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwno4vlrnkbxozk7pqctl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwno4vlrnkbxozk7pqctl.png" alt="Conceptual architecture of the proposed Decision Witness: an agent action is validated and minimized, optionally assessed by Jev as an advisory signal, then passed through a deterministic policy gate and human approval, recorded as a Decision Witness in a NovaFabric evidence record, and used for replay, diff and verify" width="800" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Conceptual architecture: proposed, not implemented. Policy decides; Jev only advises; the witness records both.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The exact enforcement boundary matters.&lt;/p&gt;

&lt;p&gt;Jev would not be allowed to override identity permissions, data policies, or hard authorization constraints.&lt;/p&gt;

&lt;p&gt;A policy engine would remain responsible for those checks.&lt;/p&gt;

&lt;p&gt;The Decision Witness would preserve the observed assessment and policy outcome. For post-run assessments, a separately linked attestation would avoid silently modifying an already sealed capsule.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Four experiments I'd like to explore
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Experiment A: Detect unusual agent behavior
&lt;/h3&gt;

&lt;p&gt;Take a collection of recorded agent tool calls, including benign and suspicious scenarios.&lt;/p&gt;

&lt;p&gt;Run a Jev-based assessment in shadow mode.&lt;/p&gt;

&lt;p&gt;Compare it against deterministic rules and NovaFabric's existing experimental security/provenance anomaly detector.&lt;/p&gt;

&lt;p&gt;Research questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does Jev identify useful semantic anomalies that structural detection misses?&lt;/li&gt;
&lt;li&gt;How many false alarms does it produce?&lt;/li&gt;
&lt;li&gt;How does its performance change across agent tasks and tool types?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Experiment B: A fast evaluation judge
&lt;/h3&gt;

&lt;p&gt;Could Jev act as an additional judge for agent outputs?&lt;/p&gt;

&lt;p&gt;For example, use rubric-based scores to evaluate whether an agent's output satisfies specific requirements.&lt;/p&gt;

&lt;p&gt;Compare Jev against existing numerical, rule-based, and LLM-based judges.&lt;/p&gt;

&lt;p&gt;The interesting question isn't just which judge is faster.&lt;/p&gt;

&lt;p&gt;It's whether the scores remain useful and calibrated across different tasks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Experiment C: Replay recorded decisions
&lt;/h3&gt;

&lt;p&gt;Suppose a decision was captured today.&lt;/p&gt;

&lt;p&gt;Three months later, the underlying model has changed.&lt;/p&gt;

&lt;p&gt;Can we replay the &lt;strong&gt;recorded response&lt;/strong&gt; without calling the model again, then separately compare it with a new model evaluation?&lt;/p&gt;

&lt;p&gt;This would help distinguish the historical decision from a new assessment.&lt;/p&gt;

&lt;p&gt;It would not prove that the model itself is deterministic.&lt;/p&gt;

&lt;h3&gt;
  
  
  Experiment D: Multi-agent delegation
&lt;/h3&gt;

&lt;p&gt;Imagine several agents working across machines or organizations.&lt;/p&gt;

&lt;p&gt;One agent delegates a task to another, which then invokes a tool.&lt;/p&gt;

&lt;p&gt;Could we record the delegation chain, assess unusual handoffs, and determine whether authorization remained within the delegated scope?&lt;/p&gt;

&lt;p&gt;I think this is particularly interesting for distributed and multi-agent AI systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. How should we evaluate these ideas?
&lt;/h2&gt;

&lt;p&gt;Before claiming that Jev improves agent safety or reliability, I'd want to run controlled experiments.&lt;/p&gt;

&lt;p&gt;Useful measurements would include:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dimension&lt;/th&gt;
&lt;th&gt;Measurement&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Detection quality&lt;/td&gt;
&lt;td&gt;Precision, recall, PR-AUC&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;False alarms&lt;/td&gt;
&lt;td&gt;False-positive rate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Probability quality&lt;/td&gt;
&lt;td&gt;Brier score, calibration error&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Performance&lt;/td&gt;
&lt;td&gt;p50/p95/p99 latency&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;Cost per 1,000 evaluations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Robustness&lt;/td&gt;
&lt;td&gt;Behavior under model/version changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Privacy&lt;/td&gt;
&lt;td&gt;Data exposed to the external assessment provider&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reproducibility&lt;/td&gt;
&lt;td&gt;Recorded decision playback and verification&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;An independent Jev evaluation is also relevant:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://arxiv.org/abs/2609.37647" rel="noopener noreferrer"&gt;&lt;strong&gt;Evaluating and Benchmarking the System One Model Jev&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The authors benchmark Jev across 37 datasets and report results that depend on the task and, for some binary decisions, the chosen threshold.&lt;/p&gt;

&lt;p&gt;That's a useful reminder that structured probabilities still require careful evaluation.&lt;/p&gt;

&lt;p&gt;For a research prototype, I'd begin with &lt;strong&gt;offline shadow-mode assessment&lt;/strong&gt; rather than live enforcement.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. A question for the developer community
&lt;/h2&gt;

&lt;p&gt;I think we're reaching a point where recording only an AI agent's final output will not be enough for many applications.&lt;/p&gt;

&lt;p&gt;We need better ways to inspect not just &lt;strong&gt;what an agent did&lt;/strong&gt;, but also the recorded assessments and authorization decisions surrounding its actions.&lt;/p&gt;

&lt;p&gt;I'm particularly interested in feedback on three questions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. What should a verifiable AI decision receipt contain?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Would you preserve complete inputs, hashes, model versions, policy decisions, confidence distributions, or something else?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Where would this be most useful?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AI coding agents, autonomous infrastructure operations, financial workflows, multi-agent systems, scientific pipelines, or another area?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Would you start with historical decision analysis or real-time policy assistance?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;My current preference is historical analysis and shadow-mode evaluation first, then carefully measured runtime integration.&lt;/p&gt;

&lt;p&gt;I'd be interested to hear how other developers would approach the problem, including reasons this architecture might not work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Projects and research references
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;NovaFabric&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Website: &lt;a href="https://novafabric.ai/" rel="noopener noreferrer"&gt;https://novafabric.ai/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Open-source repository: &lt;a href="https://github.com/MSKazemi/novafabric" rel="noopener noreferrer"&gt;https://github.com/MSKazemi/novafabric&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Documentation: &lt;a href="https://novafabric.ai/docs/" rel="noopener noreferrer"&gt;https://novafabric.ai/docs/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Archived software release: &lt;a href="https://zenodo.org/records/23652607" rel="noopener noreferrer"&gt;https://zenodo.org/records/23652607&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Research papers&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NovaFabric preprint: &lt;a href="https://arxiv.org/abs/2609.12582" rel="noopener noreferrer"&gt;https://arxiv.org/abs/2609.12582&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Independent Jev benchmarking paper: &lt;a href="https://arxiv.org/abs/2609.37647" rel="noopener noreferrer"&gt;https://arxiv.org/abs/2609.37647&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Jev&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TypeSafe AI introduction: &lt;a href="https://typesafe.ai/blog/introducing-system-one-models-and-jev" rel="noopener noreferrer"&gt;https://typesafe.ai/blog/introducing-system-one-models-and-jev&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Documentation: &lt;a href="https://docs.typesafe.ai/introduction" rel="noopener noreferrer"&gt;https://docs.typesafe.ai/introduction&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;About the author&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'm Mohsen Seyedkazemi Ardebili, working on AI-agent systems, reproducibility, infrastructure, and verifiable execution evidence.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/MSKazemi" rel="noopener noreferrer"&gt;https://github.com/MSKazemi&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;AI disclosure: This article was drafted with AI assistance. It presents a research proposal, not a completed integration or experimental result.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>architecture</category>
      <category>security</category>
    </item>
    <item>
      <title>The tool that said yes and did nothing: ydotool 0.1.8 exits 0 when it refuses</title>
      <dc:creator>Mohsen Seyedkazemi Ardebili</dc:creator>
      <pubDate>Tue, 27 Oct 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/mskazemi/the-tool-that-said-yes-and-did-nothing-ydotool-018-exits-0-when-it-refuses-2fm</link>
      <guid>https://dev.to/mskazemi/the-tool-that-said-yes-and-did-nothing-ydotool-018-exits-0-when-it-refuses-2fm</guid>
      <description>&lt;p&gt;For about ten and a half hours on 24 September, my dictation app typed nothing at all on Ubuntu under Wayland.&lt;/p&gt;

&lt;p&gt;You held the key, you spoke, the speech was transcribed correctly, and then... nothing landed in the window. No error in the log. The health check printed &lt;code&gt;[OK] Injection: ydotool&lt;/code&gt;. The tests were green.&lt;/p&gt;

&lt;p&gt;This is the story of that bug, because the lesson in it applies to almost every program that shells out to another program.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some context
&lt;/h2&gt;

&lt;p&gt;I work on &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;YazSes&lt;/a&gt;, an open-source, offline hold-to-talk dictation tool. You hold a key, talk, release, and the text is typed into whatever app has focus. On Wayland you cannot just "send keystrokes" to another window the way you can on X11, so one common route is &lt;a href="https://github.com/ReimuNotMoe/ydotool" rel="noopener noreferrer"&gt;ydotool&lt;/a&gt;, which writes events to a virtual &lt;code&gt;uinput&lt;/code&gt; keyboard.&lt;/p&gt;

&lt;p&gt;The catch: &lt;strong&gt;there are two ydotools.&lt;/strong&gt; Version 1.x and version 0.1.x share a name and a purpose, but they are different command-line tools. And distributions did not all move at the same pace. As of today (I checked Launchpad and sources.debian.org on 2026-10-22):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Distribution&lt;/th&gt;
&lt;th&gt;ydotool version&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Ubuntu 22.04, 24.04&lt;/td&gt;
&lt;td&gt;0.1.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Debian 11, 12&lt;/td&gt;
&lt;td&gt;0.1.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ubuntu 26.04, Debian testing&lt;/td&gt;
&lt;td&gt;1.0.4&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;YazSes only spoke 1.x.&lt;/p&gt;

&lt;h2&gt;
  
  
  How a correct fix broke things
&lt;/h2&gt;

&lt;p&gt;The bug did not come from a careless change. It came from a &lt;em&gt;correct&lt;/em&gt; one.&lt;/p&gt;

&lt;p&gt;In v2.39.0 I taught the socket discovery to find &lt;code&gt;/tmp/.ydotool_socket&lt;/code&gt;, which is where the 0.1.8 daemon listens. Before that, on Ubuntu, ydotool was simply never selected, and YazSes used another backend that worked fine.&lt;/p&gt;

&lt;p&gt;After the fix, ydotool became reachable. It is first in the backend order. So on Ubuntu it pushed aside a path that worked and took over, speaking 1.x syntax to a 0.1.8 binary.&lt;/p&gt;

&lt;p&gt;Three command lines were now wrong:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ydotool type -d 6 -H 6&lt;/code&gt; was refused. 0.1.x uses &lt;code&gt;--key-delay&lt;/code&gt; and has no hold time.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ydotool key 29:1 47:1 47:0 29:0&lt;/code&gt; (Ctrl+V as raw keycodes): 0.1.x wants symbolic names.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ydotool key 97:0&lt;/code&gt;, a "release any stuck modifier" guard that ran after every dictation, typed the digit &lt;code&gt;9&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why nothing noticed
&lt;/h2&gt;

&lt;p&gt;Here is the part that matters. When 0.1.8 refuses an option, it does this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ydotool type -d 6 -H 6 "hello"
error: unrecognised option '-d'
$ echo $?
0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It prints an error and &lt;strong&gt;exits 0&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;My code ran it with &lt;code&gt;subprocess.run(..., check=True)&lt;/code&gt;. &lt;code&gt;check=True&lt;/code&gt; only raises on a non-zero exit code. So no exception, so the clipboard fallback never ran, so nothing was logged, so the health check (which asked "is ydotool there and does it run?") said OK.&lt;/p&gt;

&lt;p&gt;Every layer was telling the truth about what it was asked. Nobody was asking whether text reached the window.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fa4nd0v6f64wuqyc9zh1q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fa4nd0v6f64wuqyc9zh1q.png" alt="Every layer told the truth about what it was asked: exit 0, no exception, no fallback, doctor OK, nothing typed" width="800" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It gets better. 0.1.8's &lt;code&gt;key&lt;/code&gt; command has no error path for unknown names at all. It types the first letter of whatever you gave it. I measured this by grabbing the virtual keyboard device and counting events:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;You send&lt;/th&gt;
&lt;th&gt;0.1.8 types&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Return&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;r&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Escape&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;e&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;space&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;s&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;KEY_BACKSPACE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;k&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;29:1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So "new line" would have typed &lt;code&gt;r&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;Two changes, released in v2.40.0 the same evening.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Stop trusting the exit code.&lt;/strong&gt; The output is classified instead. 0.1.8 writes normal progress messages to stderr ("Key delay was set to 6 milliseconds"), so not every line on stderr is an error, but an explicit error is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_classify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;returncode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;YdotoolCliError&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;The exception for this result, or None when it succeeded.

    0.1.8 writes ordinary progress to stderr (&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;notice: Using ydotoold backend&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;,
    &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Key delay was set to 6 milliseconds.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;), so only an explicit error is an error.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;low&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;marker&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;low&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;marker&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;_OPTION_ERROR_MARKERS&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;YdotoolOptionError&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;: error:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;low&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;returncode&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;YdotoolCliError&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now a refused command raises, and the fallback backend runs like it was always supposed to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Detect the dialect, and only send what it understands.&lt;/strong&gt; YazSes probes which ydotool it is talking to and keeps an allowlist of key names that were &lt;em&gt;measured&lt;/em&gt; to work on 0.1.8. Anything else raises and goes to the fallback, instead of typing a random first letter. &lt;code&gt;yazses doctor&lt;/code&gt; now says "ydotool 0.1.x" or "ydotool 1.x" instead of a bare OK.&lt;/p&gt;

&lt;p&gt;And there is a regression test with an honest name: &lt;code&gt;test_an_option_error_is_a_failure_even_though_ydotool_exits_zero&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I took away
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;An exit code is a claim, not evidence.&lt;/strong&gt; It tells you what the tool &lt;em&gt;thinks&lt;/em&gt; happened. When a subprocess is the last step before something the user sees, read its stderr, and if you possibly can, measure the effect itself. For keyboard injection, that meant grabbing the uinput device and counting events. For your tool it might be "read the file back" or "query the API you just wrote to".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Making something reachable makes it load-bearing.&lt;/strong&gt; My socket fix was right. But it promoted a backend from "never used on Ubuntu" to "first choice on Ubuntu", and I verified the probe, not the backend. If a change widens where code runs, test the code in its new home.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Health check: OK" should name what it checked.&lt;/strong&gt; "ydotool found" and "text arrives in the window" are very different sentences. Only one of them was being said.&lt;/p&gt;

&lt;p&gt;If you maintain anything that wraps &lt;code&gt;ydotool&lt;/code&gt;, &lt;code&gt;xdotool&lt;/code&gt;, &lt;code&gt;wtype&lt;/code&gt; or similar, I'd love to hear how you verify that input actually landed. That is still the hardest part of this whole project.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;YazSes is an offline, open-source (Apache-2.0) dictation tool for Linux, macOS and Windows: &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;github.com/MSKazemi/yazses&lt;/a&gt;. The full fix is in the &lt;a href="https://github.com/MSKazemi/yazses/blob/main/docs/releases/v2.40.0.md" rel="noopener noreferrer"&gt;v2.40.0 release notes&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I wrote this with help from an AI assistant for drafting and editing; the bug, the fix, the measurements and the opinions are mine, and I checked every fact against the code and release notes.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>python</category>
      <category>debugging</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Anatomy of an offline dictation pipeline: where the time actually goes</title>
      <dc:creator>Mohsen Seyedkazemi Ardebili</dc:creator>
      <pubDate>Thu, 22 Oct 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/mskazemi/anatomy-of-an-offline-dictation-pipeline-where-the-time-actually-goes-18nf</link>
      <guid>https://dev.to/mskazemi/anatomy-of-an-offline-dictation-pipeline-where-the-time-actually-goes-18nf</guid>
      <description>&lt;p&gt;This is the first post in a series about the parts of offline voice dictation that turned out to be harder than they looked. Most of the series is about bugs: the subtle kind, where every check is green and the user still gets the wrong text. But first, a map.&lt;/p&gt;

&lt;p&gt;The project is &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;YazSes&lt;/a&gt;. You hold a key, speak, let go, and your words are typed into whatever app has focus: editor, terminal, browser, chat. Speech recognition runs on your own CPU. No account, no API key, and no audio leaves the machine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxaip9p9t5x5jiog0ab4o.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxaip9p9t5x5jiog0ab4o.jpg" alt="YazSes recording: the tray icon turns green and rings appear at the cursor" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The nine stages
&lt;/h2&gt;

&lt;p&gt;When you &lt;strong&gt;press&lt;/strong&gt; the key, audio starts going into a buffer in memory. Nothing is written to disk. When you &lt;strong&gt;release&lt;/strong&gt; it, that burst goes through nine stages:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Hotkey&lt;/strong&gt;: the press and release events (Right Alt on Linux, Right Option on macOS, Right Ctrl on Windows by default).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capture&lt;/strong&gt;: the audio buffer itself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Silence gate&lt;/strong&gt;: is this clip loud enough to contain speech at all? If not, drop it. (Post 3 of this series is about what happens when this is set wrong.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Padding&lt;/strong&gt;: a short silent lead-in is added before decoding, so Whisper doesn't clip your first word.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Speech-to-text&lt;/strong&gt;: &lt;a href="https://github.com/SYSTRAN/faster-whisper" rel="noopener noreferrer"&gt;faster-whisper&lt;/a&gt; on the CPU, quantised to int8. Default model: &lt;code&gt;base.en&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clean-up&lt;/strong&gt;: strips Whisper artefacts like &lt;code&gt;[BLANK_AUDIO]&lt;/code&gt; and stray leading punctuation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disfluency filter&lt;/strong&gt;: removes fillers, de-duplicates repeated words, and rolls back self-corrections like "no wait".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Command or dictation?&lt;/strong&gt;: "undo that" should press Ctrl+Z, not type the words "undo that". A regex grammar decides, in well under a millisecond.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inject&lt;/strong&gt;: type the text into the focused window, by whatever means the OS allows.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Where the time goes
&lt;/h2&gt;

&lt;p&gt;I assumed I'd have to optimise half of these. I measured instead.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzf994k9ntudbc8jvkgnt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzf994k9ntudbc8jvkgnt.png" alt="The dictation pipeline, coloured by measured cost" width="800" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On my laptop (an i7-1370P, int8 on CPU, 30 utterances with a median length of 7.3 seconds), speech-to-text with &lt;code&gt;base.en&lt;/code&gt; took a median of &lt;strong&gt;1,561 ms&lt;/strong&gt;. Every other stage &lt;em&gt;combined&lt;/em&gt; had a median of &lt;strong&gt;0.29 ms&lt;/strong&gt;. Speech-to-text is &lt;strong&gt;99.98%&lt;/strong&gt; of the processing time of a burst.&lt;/p&gt;

&lt;p&gt;So the filters, the command grammar and the injector are not worth tuning for speed. The only latency setting that matters is which model you run.&lt;/p&gt;

&lt;p&gt;That made the design question simple. Instead of tuning, offer choices:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Engine&lt;/th&gt;
&lt;th&gt;Word error rate (LibriSpeech test-clean, 200 utterances)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Parakeet TDT 0.6B v2 (optional)&lt;/td&gt;
&lt;td&gt;2.06%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Whisper &lt;code&gt;small.en&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;2.66%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Moonshine base (optional)&lt;/td&gt;
&lt;td&gt;3.17%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Whisper &lt;code&gt;large-v3&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;3.23%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Whisper &lt;code&gt;base.en&lt;/code&gt; (default)&lt;/td&gt;
&lt;td&gt;4.01%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two honest caveats on that table. The confidence intervals overlap, so "Parakeet beats large-v3" is not established by it. And large-v3 loses mostly on &lt;em&gt;insertions&lt;/em&gt; (words that weren't spoken), not on recognising what was said. The full method is in &lt;a href="https://github.com/MSKazemi/yazses/blob/main/docs/benchmarks.md" rel="noopener noreferrer"&gt;docs/benchmarks.md&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The optional engines are not installed by default, because they are big. You turn one on when you want it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yazses features &lt;span class="nb"&gt;enable &lt;/span&gt;stt-parakeet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If an engine you configured is missing, YazSes logs a warning and falls back to faster-whisper instead of refusing to start. (Post 12 is about the day that fallback hid a real bug.)&lt;/p&gt;

&lt;h2&gt;
  
  
  The hard part is the last stage
&lt;/h2&gt;

&lt;p&gt;Speech recognition is the expensive stage. It is not the &lt;em&gt;hard&lt;/em&gt; one. The hard one is stage 9: getting text into someone else's window.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;macOS&lt;/strong&gt;: &lt;code&gt;CGEventKeyboardSetUnicodeString&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Windows&lt;/strong&gt;: &lt;code&gt;SendInput&lt;/code&gt; with &lt;code&gt;KEYEVENTF_UNICODE&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linux on X11&lt;/strong&gt;: &lt;code&gt;xdotool&lt;/code&gt; works.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linux on Wayland&lt;/strong&gt;: there is deliberately no general way for one app to type into another. YazSes probes, in order: &lt;code&gt;ydotool&lt;/code&gt; (a virtual keyboard through &lt;code&gt;uinput&lt;/code&gt;), &lt;code&gt;wtype&lt;/code&gt;, the desktop portal's RemoteDesktop interface, and the clipboard as a last resort.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every one of those has failure modes where the API reports success and the user gets nothing, or gets garbage. Posts 2 and 5 are two of those stories.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why offline at all?
&lt;/h2&gt;

&lt;p&gt;Partly privacy. What you dictate is often the most private text you write: messages, notes, half-formed ideas. But also reliability: it works on a train, it works when a service is down, and it has no per-minute cost. On a modern laptop CPU, small Whisper models are fast enough that you don't need the cloud for this.&lt;/p&gt;

&lt;p&gt;"Nothing leaves the machine" is easy to say. Post 6 is about how the project turns that sentence into a test that fails the build.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rest of the series
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Anatomy of an offline dictation pipeline &lt;em&gt;(this post)&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;The tool that said yes and did nothing&lt;/li&gt;
&lt;li&gt;My silence gate was quieter than my room&lt;/li&gt;
&lt;li&gt;Whisper typed its own prompt into my document&lt;/li&gt;
&lt;li&gt;SendInput said success. The app got question marks.&lt;/li&gt;
&lt;li&gt;Turning "nothing leaves the machine" into a test&lt;/li&gt;
&lt;li&gt;Testing a speech app with no microphone, network or model&lt;/li&gt;
&lt;li&gt;A guard is judged by how rarely it fires&lt;/li&gt;
&lt;li&gt;"No wait, I meant...": when self-correction ate my sentences&lt;/li&gt;
&lt;li&gt;Voice commands without an LLM&lt;/li&gt;
&lt;li&gt;Offline meeting transcripts with speaker labels&lt;/li&gt;
&lt;li&gt;The update button that uninstalled a feature&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you want to try it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Linux&lt;/span&gt;
bash &amp;lt;&lt;span class="o"&gt;(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/MSKazemi/yazses/main/install.sh&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;# macOS (Apple Silicon)&lt;/span&gt;
brew tap MSKazemi/yazses &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; brew trust MSKazemi/yazses &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; brew &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--cask&lt;/span&gt; yazses
&lt;span class="c"&gt;# Windows&lt;/span&gt;
winget &lt;span class="nb"&gt;install &lt;/span&gt;MSKazemi.YazSes
&lt;span class="c"&gt;# Any OS with Python 3.11+&lt;/span&gt;
pipx &lt;span class="nb"&gt;install &lt;/span&gt;yazses
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Linux is the most tested platform. macOS and Windows are labelled preview, and reports from real machines help more than anything else.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;YazSes is open source under Apache-2.0: &lt;a href="https://github.com/MSKazemi/yazses" rel="noopener noreferrer"&gt;github.com/MSKazemi/yazses&lt;/a&gt;. The architecture reference, with the measurements above: &lt;a href="https://github.com/MSKazemi/yazses/blob/main/docs/architecture.md" rel="noopener noreferrer"&gt;docs/architecture.md&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I wrote this with help from an AI assistant for drafting and editing; the project, the measurements and the opinions are mine, and I checked every number against the repository.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>linux</category>
      <category>opensource</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Find where two AI agent runs diverged</title>
      <dc:creator>Mohsen Seyedkazemi Ardebili</dc:creator>
      <pubDate>Sat, 10 Oct 2026 09:41:50 +0000</pubDate>
      <link>https://dev.to/mskazemi/find-where-two-ai-agent-runs-diverged-55fp</link>
      <guid>https://dev.to/mskazemi/find-where-two-ai-agent-runs-diverged-55fp</guid>
      <description>&lt;p&gt;Your agent gave one answer yesterday and a different one today. Same code, same input file, a different decision. Before you can fix anything you need to know where the two runs parted ways. Did the prompt change, did the model reply change, or did something after the model call change?&lt;/p&gt;

&lt;p&gt;This tutorial is for engineers who run agents in Python and want to answer that from two recorded runs instead of from memory. You will capture two runs as &lt;a href="https://novafabric.ai/docs/architecture/run-capsule/" rel="noopener noreferrer"&gt;Run Capsules&lt;/a&gt;, compare them with &lt;code&gt;nova diff&lt;/code&gt;, read which model call changed, and turn the same comparison into a CI gate. Every command and output below was captured from the released &lt;code&gt;novafabric 0.104.0&lt;/code&gt;. Long paths and skipped lines are marked with &lt;code&gt;…&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What you need
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Python 3.12 or newer (the package declares &lt;code&gt;Requires-Python: &amp;gt;=3.12&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;pip install novafabric openai&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;examples/blackbox_demo/&lt;/code&gt; directory from the public &lt;a href="https://github.com/MSKazemi/novafabric" rel="noopener noreferrer"&gt;MSKazemi/novafabric&lt;/a&gt; repository, copied into an empty working directory. Run every command from that working directory.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No API key and no hosted model are involved. The example ships a small OpenAI-compatible mock server on &lt;code&gt;127.0.0.1:9099&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The scenario
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;agent.py&lt;/code&gt; reads a payment-service config, asks a model for one recommended change, and writes the answer to &lt;code&gt;outputs/decision.json&lt;/code&gt;. The mock server answers in one of two ways, chosen by a request header the agent sends: a risky answer (disable rate limiting) or a safe one (reduce &lt;code&gt;max_connections&lt;/code&gt;). That gives you two runs whose behaviour differs for a known reason, so you can check that the diff points at the right place.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: start the mock model
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python blackbox_demo/mock_llm_server.py &amp;amp;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;sk-demo-no-key-needed
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;OPENAI_BASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;http://127.0.0.1:9099
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;NOVAFABRIC_SUGGEST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: capture the first run
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;nova capture&lt;/code&gt; wraps the command with no code changes. Model calls from Python workloads are recorded automatically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ nova capture -- python blackbox_demo/agent.py --mode bad
✓ Capsule written: …/.novafabric/capsules/01M4FBTQ7FVQEZBWQGFD2RVTW2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep the capsule path in a variable (your run IDs will differ):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;BAD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/.novafabric/capsules/01M4FBTQ7FVQEZBWQGFD2RVTW2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: capture the second run
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ nova capture -- python blackbox_demo/agent.py --mode fixed
✓ Capsule written: …/.novafabric/capsules/01M4FBVEZDG7XVBYJBB9WD6Q8D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: diff the two runs
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ nova diff "$BAD" "$FIXED"
  changed=3  added=0  removed=0

Model calls:
  ~ call at span 5fef2505ba0bd78e
Outputs:
  ~ outputs/decision.json
  ~ outputs/stdout.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three items changed (&lt;code&gt;~&lt;/code&gt;): one model call and two output files. Nothing was added or removed. For the machine-readable record, add &lt;code&gt;--output-format json&lt;/code&gt;; the model-call pair reports &lt;code&gt;request_changed: false&lt;/code&gt; and &lt;code&gt;response_changed: true&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to read it
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;aligned: 1&lt;/code&gt;&lt;/strong&gt;: the diff paired the one model call in each run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;request_changed: false&lt;/code&gt;, &lt;code&gt;response_changed: true&lt;/code&gt;&lt;/strong&gt;: the agent sent the same request both times and got a different reply. The runs diverged at the model's answer, not in your prompt-building code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;environment.changes: []&lt;/code&gt;&lt;/strong&gt;: no recorded environment difference to chase.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;outputs&lt;/code&gt;&lt;/strong&gt;: both files changed downstream of that reply.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 5: use it as a CI gate
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;--assert-no-regressions&lt;/code&gt; makes &lt;code&gt;nova diff&lt;/code&gt; exit 1 when it finds &lt;strong&gt;any&lt;/strong&gt; structural change between the two runs, including added or removed calls. Comparing a run with itself exits 0. On GitHub Actions, &lt;code&gt;--output-format github-annotation&lt;/code&gt; prints one annotation per change.&lt;/p&gt;

&lt;p&gt;Read the gate for what it is: it answers "did anything change?", not "did it get worse?". A safer answer fails it just as a riskier one does, as it did here.&lt;/p&gt;

&lt;h3&gt;
  
  
  What this does not do
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It does not judge the change.&lt;/strong&gt; The diff is structural: it tells you which call and which files differ, not whether the new behaviour is better.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Any difference counts.&lt;/strong&gt; Against a live model, two runs of the same prompt can return different text, and the gate fails on that too.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic model-call capture is for Python workloads.&lt;/strong&gt; Other clients go through &lt;code&gt;nova api-proxy&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sealing is opt-in&lt;/strong&gt; and was not used here. The capsule format is pre-1.0.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full version, with every command output, the replay section and the CI examples, is on the original page: &lt;a href="https://novafabric.ai/blog/find-where-two-agent-runs-diverged/" rel="noopener noreferrer"&gt;https://novafabric.ai/blog/find-where-two-agent-runs-diverged/&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://novafabric.ai/blog/find-where-two-agent-runs-diverged/" rel="noopener noreferrer"&gt;novafabric.ai&lt;/a&gt;. NovaFabric is open source (Apache-2.0) and pre-1.0: &lt;a href="https://github.com/MSKazemi/novafabric" rel="noopener noreferrer"&gt;github.com/MSKazemi/novafabric&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>debugging</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
