<?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: dqj</title>
    <description>The latest articles on DEV Community by dqj (@dqj1998).</description>
    <link>https://dev.to/dqj1998</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%2F3699688%2F0672afbc-fb16-4578-b8ff-d16dc237c174.png</url>
      <title>DEV Community: dqj</title>
      <link>https://dev.to/dqj1998</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dqj1998"/>
    <language>en</language>
    <item>
      <title>From Engineering Philosophy to Product Shape: How We Assembled This Pipeline into PPTRunner</title>
      <dc:creator>dqj</dc:creator>
      <pubDate>Sat, 05 Dec 2026 14:21:34 +0000</pubDate>
      <link>https://dev.to/dqj1998/from-engineering-philosophy-to-product-shape-how-we-assembled-this-pipeline-into-pptrunner-573g</link>
      <guid>https://dev.to/dqj1998/from-engineering-philosophy-to-product-shape-how-we-assembled-this-pipeline-into-pptrunner-573g</guid>
      <description>&lt;p&gt;A deck lands on the app window. There is no upload bar, no account prompt, no queue position. The first launch already downloaded the model packs; after that the machine is the whole backend. Some minutes later there is an MP4 that plays on a phone, in a browser, and on a projector.&lt;br&gt;
That is the product we wanted to build, and this is the last article in the “10% AI, 90% deterministic code” series. Parts 1–5 covered the boundary, the prompt, the runtime, the parser, and the media pipeline. This one covers the unglamorous step that turns an architecture into something a person can double-click: assembly.&lt;br&gt;
The result is PPTRunner, a local desktop tool that converts existing PowerPoint decks into narrated videos. I will describe the architecture that did not survive, the five stages that did, the numbers we measure, and what local-first costs. The product name appears here for the first time because there is no longer any reason to hide it.&lt;/p&gt;
&lt;h2&gt;
  
  
  The architecture we abandoned
&lt;/h2&gt;

&lt;p&gt;The first design was the obvious one. A web app: upload the .pptx, let a planner agent decompose the job, run tools for parsing, narration, speech, and rendering on a GPU cluster, then return a download link.&lt;br&gt;
The appeal was real. No installer, no model download, no hardware matrix; jobs scaled horizontally, and the agent could “decide” batch sizes, retries, and voices.&lt;br&gt;
It died for four reasons, none of them ideological.&lt;br&gt;
The first was that the agent became the scheduler. A scheduler must be idempotent, bounded, and observable; a model choosing tools is none of those. Every retry is another sampling call, the same deck can produce a different plan tomorrow, and when a render fails at slide 61 the system cannot tell whether to re-run one unit or the job, because the decision lives in a context window. We were debugging a distributed system through a transcript.&lt;br&gt;
The second was data. Corporate decks are the least shareable documents in the building: unannounced financials, org charts, roadmaps, an unsigned legal slide. Uploading them so a cloud GPU can read them is not a feature; it is a compliance review. Local-first was the only way some customers could use the product at all.&lt;br&gt;
The third was latency. Rendering is the long pole, but upload and queue are what the user feels first: a 300 MB deck on hotel Wi-Fi, a cold container, a model download, a tool loop. Locally, parsing starts when the file lands.&lt;br&gt;
The fourth was cost shape. A render farm bills idle capacity and egress; a desktop app bills once and the user supplies the compute — a better fit for bursty use.&lt;br&gt;
The lesson was not “cloud bad, local good.” It was narrower: if a step can be expressed as a function with a schema, it should not get a model. If it needs judgment over unstructured text, it gets a model, with a closed output and a deterministic caller. That rule is what survived.&lt;/p&gt;
&lt;h2&gt;
  
  
  Five stages, one process
&lt;/h2&gt;

&lt;p&gt;The shipped architecture is a pipeline of five stages. Each stage reads artifacts, writes artifacts, and returns a typed result. The stages do not call each other through a conversation; they call each other through a manifest.&lt;br&gt;
&lt;strong&gt;Ingest.&lt;/strong&gt; Unzip the OOXML package; resolve &lt;code&gt;presentation.xml&lt;/code&gt;, layouts, masters, relationships, notes, and media into a normalized slide model with stable IDs, text runs, geometry, and images. No Office install, no LibreOffice subprocess.&lt;br&gt;
&lt;strong&gt;Plan.&lt;/strong&gt; Decide what each slide needs: which text is narration, which is title-only, where a section break belongs. Deterministic, except one small model call that proposes narration for slides with no notes. The proposal is text, never a control decision.&lt;br&gt;
&lt;strong&gt;Narrate.&lt;/strong&gt; The 10% stage. A local model turns a slide summary into spoken prose, or polishes an existing note. It gets a few hundred tokens of context, returns one string, and is validated against a length and language schema. It cannot choose voices, durations, or transitions.&lt;br&gt;
&lt;strong&gt;Synthesize.&lt;/strong&gt; Normalize pronunciation, synthesize each segment, trim silence, normalize loudness, write a WAV and its duration. The engine is local; the output is a cache entry keyed by text, language, voice, engine version, and normalizer version.&lt;br&gt;
&lt;strong&gt;Render and mux.&lt;/strong&gt; Lay out the slide, apply camera moves, highlights, and captions, stream frames into FFmpeg, encode with a probed hardware encoder or libx264, mux audio, verify with ffprobe.&lt;br&gt;
That is the whole product in one paragraph. The editor, preview, progress bar, and error badges are all views over the same manifest.&lt;br&gt;
The manifest is deliberately boring. A unit is an immutable value, not a mutable row every stage can edit. Each stage returns a new unit with a hash and provenance. If the hash matches, the next stage reuses the artifact without asking the model anything.&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="nd"&gt;@dataclass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frozen&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SlideUnit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;slide_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;source_hash&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;          &lt;span class="c1"&gt;# OOXML slide + layout + master + media&lt;/span&gt;
    &lt;span class="n"&gt;narration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;     &lt;span class="c1"&gt;# only the 10%: text, never control flow&lt;/span&gt;
    &lt;span class="n"&gt;narration_hash&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
    &lt;span class="n"&gt;audio_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;     &lt;span class="c1"&gt;# text + lang + voice + engine + normalizer&lt;/span&gt;
    &lt;span class="n"&gt;audio_path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
    &lt;span class="n"&gt;duration_s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
    &lt;span class="n"&gt;render_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;    &lt;span class="c1"&gt;# images + layout + camera + frame range&lt;/span&gt;
    &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Literal&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"pending"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"degraded"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"failed"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The contract makes incremental editing possible. Change a non-narrated title: &lt;code&gt;source_hash&lt;/code&gt; changes, &lt;code&gt;audio_key&lt;/code&gt; does not. Change a spoken sentence: exactly one &lt;code&gt;audio_key&lt;/code&gt; changes. Change the camera path: only &lt;code&gt;render_key&lt;/code&gt; changes. The UI just asks the manifest what is stale.&lt;/p&gt;

&lt;h2&gt;
  
  
  The scheduler is a state machine, not an agent
&lt;/h2&gt;

&lt;p&gt;The second design mistake we avoided was letting the model orchestrate the stages. The scheduler is ordinary code: a directed acyclic graph with per-unit retries, cancellation, and a budget.&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;run_stage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;SlideUnit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Stage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;JobContext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;SlideUnit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cache_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;unit&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;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&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;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cache&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="n"&gt;key&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;attempt&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max_attempts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;          &lt;span class="c1"&gt;# bounded, not "until it works"&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;artifact&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;        &lt;span class="c1"&gt;# pure function of inputs&lt;/span&gt;
            &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;artifact&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;artifact&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;Retryable&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;ctx&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;warn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"retry"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;stage&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="n"&gt;slide&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;slide_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                         &lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;backoff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;Fatal&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"failed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"degraded"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"retry budget exhausted"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two details matter more than the code.&lt;br&gt;
First, every failure is a value. A slide can be &lt;code&gt;degraded&lt;/code&gt;: system voice instead of the chosen voice, a caption instead of narration, silence with a fixed hold. The export finishes and the UI badges that slide. A pipeline that aborts a 96-slide job because one WAV is missing is not a product; it is a demo with a progress bar.&lt;br&gt;
Second, the scheduler never reads the model's prose to decide what happens next. The output is data: validate it against a schema, store it, move on. That is the difference between a local AI operator and an agent loop — one job, fixed input, fixed output, deterministic caller.&lt;br&gt;
Licensing follows the same rule: an expired or invalid license falls back to the watermarked export path. A watermark is annoying; being locked out of your own file is unacceptable.&lt;/p&gt;
&lt;h2&gt;
  
  
  What the user feels: editing one slide
&lt;/h2&gt;

&lt;p&gt;The architecture only earns its keep at the moment of an edit.&lt;br&gt;
A 96-slide deck, 18 minutes of narration, 30 fps. The user changes six words on slide 47. The deck is not re-parsed, 95 narrations are not rewritten, 95 audio clips are not re-synthesized, and 95% of the video is not re-encoded.&lt;br&gt;
What does happen: slide 47's source hash changes, one audio key misses, one TTS call runs, the timeline recomputes from that point, and one render unit is rebuilt at a keyframe boundary. The progress bar moves in seconds, not a spinner that promises forty minutes.&lt;br&gt;
The preview is not a separate renderer. It is the same layout code at a lower resolution, which is why what you see is what you export. Captions are generated from the same normalized text that went to the speech engine, so they cannot drift from the audio. The camera path is a list of keyframes, not a prompt.&lt;br&gt;
Local translation belongs here too. A Japanese or Chinese variant is a new language track, not a new project. Slide images and layout are shared; narration, audio, and captions have their own hashes. Editing an English slide does not invalidate the Japanese audio unless the user asks to re-translate it.&lt;/p&gt;
&lt;h2&gt;
  
  
  The numbers we hold ourselves to
&lt;/h2&gt;

&lt;p&gt;We could publish a single “it takes X minutes” number. It would be useless: the variables are the deck, the voice, the machine, and the encoder. So we publish the ledger, and the app calibrates an ETA on the machine it is running on.&lt;br&gt;
The arithmetic is not mysterious. Eighteen minutes of narration is 1,080 seconds, or 32,400 frames at 30 fps. At 1920×1080 RGB24, one frame is 6.22 MB, so a cold export pushes about 201 GB through the frame pipe. The audio is 48 kHz, 16-bit mono: ~96 KB per second, or roughly 104 MB. Those are format facts, not benchmarks.&lt;br&gt;
| Phase | Unit of work | Cache key | What dominates | What we watch |&lt;br&gt;
|---|---|---|---|---|&lt;br&gt;
| Ingest | one deck | package + slide XML + media | zip I/O, XML walk | peak RSS, parse time |&lt;br&gt;
| Narrate | one slide | structured summary + prompt version | model TTFT, tokens out | p50/p95 per slide, schema failures |&lt;br&gt;
| Synthesize | one segment | text + lang + voice + engine + normalizer | phonemization, vocoder | real-time factor, one-key invalidation |&lt;br&gt;
| Render | one render unit | images + layout + camera + frame range | rasterization, encode | frames/s, queue depth |&lt;br&gt;
| Mux/verify | one export | unit list + audio track | container copy | duration drift, stream count |&lt;br&gt;
The budgets are plain. Export must finish on a 16 GB machine with 10 GB free. Peak memory is bounded by the frame queue, not deck length. A one-slide edit re-synthesizes at most one segment. A cold export is interruptible and resumable without corrupting the output. Export must complete with the network cable pulled.&lt;br&gt;
The verification is a command, not a vibe:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ffprobe -v error -show_entries \
  &lt;span class="nv"&gt;format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;duration,size:stream=index,codec_type,codec_name,width,height,avg_frame_rate,pix_fmt \
  -of json final.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We compare the container duration with the timeline's last boundary, the stream count with the plan, the pixel format with &lt;code&gt;yuv420p&lt;/code&gt;, and the frame count with the sum of render units. If any disagree, the export is not “done”; it is a bug with a progress bar.&lt;/p&gt;

&lt;h2&gt;
  
  
  What local-first costs
&lt;/h2&gt;

&lt;p&gt;Local-first is not free, and the product page says so before the download starts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;First launch is online.&lt;/strong&gt; The model packs are about 6.2 GB, downloaded once and checked by SHA-256. Plan for 10 GB free and 16 GB of RAM; a discrete GPU helps, but CPU-only machines work with a longer ETA.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The platform matrix is narrow.&lt;/strong&gt; macOS 14 or later on Apple Silicon (M1 or later); no Intel Macs. Windows 10 version 19045 or later, or Windows 11.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The free tier is watermarked.&lt;/strong&gt; Free exports are 1080p with a PPTRunner watermark; paid licenses remove it. Planned prices are on the site but not on sale yet, and the Mac App Store version is still coming. Version 1.1 ships the narration editor, sample deck, preview, local translation, local speech, and MP4 export; the full project workflow is planned.
None of this is an apology. It is the bill for the architecture. If you need a browser tab and a 2 GB Chromebook, a cloud renderer is the right product. If the deck cannot leave the building, a 6.2 GB download is a bargain.
## The reveal: PPTRunner
So here it is.
&lt;strong&gt;PPTRunner&lt;/strong&gt; is a desktop app that turns an existing PowerPoint deck into a narrated video, locally. It reads .pptx directly, proposes narration with a local model, lets you edit every line, add camera focus, highlights, and captions, preview slide by slide, and export an MP4 with voice and subtitles in English, Japanese, or Simplified Chinese. Japanese speech runs in-process through VOICEVOX CORE; the rest is ordinary code.
The macOS build (Apple Silicon, direct download) is 1.1.0, signed and notarized, with built-in updates. Windows installs from the Microsoft Store and then runs offline. Both are distributed only through the official site; do not install from mirrors.
The pitch is not “AI makes your slides better.” It is narrower: the deck you already have becomes a video you can send, without uploading it, without a render queue, and without re-rendering everything when one sentence changes.
That is the product shape the series argued toward. The model is still 10%. The other 90% is the installer, the model download, the cache keys, the state machine, the error badges, the ETA, the license fallback, the updater, and the support inbox. Architecture is a promise. A product is the receipt.
## The last 10%
The first article opened with a claim: a local model should be an operator inside a deterministic system, not the brain of the system. Five articles later, the claim has a shape you can download.
The temptation at the end of a series is to summarize the philosophy and call it a product. We tried the opposite. The philosophy only matters if it survives a 96-slide deck, a 16 GB laptop, a corporate firewall, and a user who edits one sentence at 11 p.m. and expects the export to be done before the coffee.
The model writes the sentence. The rest is engineering. That was true in Part 1, and it is true in the shipped app.
---
&lt;em&gt;PPTRunner is a product of amiPro LLC. Download the current build at &lt;a href="https://pptrunner.com/en/download.html" rel="noopener noreferrer"&gt;pptrunner.com&lt;/a&gt;.&lt;/em&gt;
&lt;em&gt;Previously: &lt;a href="https://medium.com/@dqj1998/desktop-apps-keep-wiring-a-7b-model-into-every-control-path-115063626c2f" rel="noopener noreferrer"&gt;Part 1&lt;/a&gt;, &lt;a href="https://medium.com/@dqj1998/surgical-prompting-how-to-make-a-7b-local-model-never-break-your-schema-65b0a6d77e24" rel="noopener noreferrer"&gt;Part 2&lt;/a&gt;, &lt;a href="https://medium.com/@dqj1998/ollama-mlx-or-native-the-runtime-choice-that-decides-whether-on-device-ai-ships-3ab9be6d1bef" rel="noopener noreferrer"&gt;Part 3&lt;/a&gt;, &lt;a href="https://medium.com/@dqj1998/when-ai-meets-powerpoint-ooxml-parsing-and-the-local-model-at-the-edge-927906dab50e" rel="noopener noreferrer"&gt;Part 4&lt;/a&gt;, &lt;a href="https://medium.com/@dqj1998/the-deterministic-win-multilingual-tts-elastic-timelines-and-the-ffmpeg-export-nobody-sees-07dcf9286f63" rel="noopener noreferrer"&gt;Part 5&lt;/a&gt;.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://medium.com/@dqj1998/from-engineering-philosophy-to-product-shape-how-we-assembled-this-pipeline-into-pptrunner-e4b11483efe2" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>softwareengineering</category>
      <category>localfirst</category>
    </item>
    <item>
      <title>The Deterministic Win: Multilingual TTS, Elastic Timelines, and the FFmpeg Export Nobody Sees</title>
      <dc:creator>dqj</dc:creator>
      <pubDate>Fri, 04 Dec 2026 14:13:19 +0000</pubDate>
      <link>https://dev.to/dqj1998/the-deterministic-win-multilingual-tts-elastic-timelines-and-the-ffmpeg-export-nobody-sees-3kik</link>
      <guid>https://dev.to/dqj1998/the-deterministic-win-multilingual-tts-elastic-timelines-and-the-ffmpeg-export-nobody-sees-3kik</guid>
      <description>&lt;p&gt;&lt;em&gt;The model writes sentences. The pipeline decides how they are pronounced, when each slide leaves the screen, and how the file is encoded.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A 96-slide deck, two languages, one laptop, one Tuesday deadline. The first export looks fine. Then someone edits slide 47: six extra words, 2.3 seconds longer. The old pipeline re-renders the whole video, and forty minutes later the only visible change is a slightly different pause near the middle.&lt;/p&gt;

&lt;p&gt;That is the moment the project stops being an AI demo and becomes a media pipeline. Generating a sentence is the easy part. The hard part is turning text and images into a file that plays on a phone, in a browser, and on a projector — without redoing work that has not changed.&lt;/p&gt;

&lt;p&gt;This is the fifth article in the “10% AI, 90% deterministic code” series. Part 4 parsed the deck into a structured slide representation. This one starts after the words exist.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Three lanes, one boundary: the model supplies text; deterministic code owns pronunciation, timing, pixels, and the container.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Normalize before you synthesize
&lt;/h2&gt;

&lt;p&gt;A TTS engine is not a reader. It is a sampler over phonemes, and it will faithfully pronounce whatever byte sequence you give it. Written text is full of things that are not meant to be read aloud: &lt;code&gt;e.g.&lt;/code&gt;, &lt;code&gt;vs.&lt;/code&gt;, &lt;code&gt;FY26&lt;/code&gt;, &lt;code&gt;Q3&lt;/code&gt;, &lt;code&gt;62.4%&lt;/code&gt;, &lt;code&gt;$1.2M&lt;/code&gt;, &lt;code&gt;3–5 days&lt;/code&gt;, &lt;code&gt;README.md&lt;/code&gt;, &lt;code&gt;C++&lt;/code&gt;, &lt;code&gt;snake_case&lt;/code&gt;. Dates, phone numbers, ranges, and names behave differently in every language.&lt;/p&gt;

&lt;p&gt;Some engines accept SSML; many local engines accept only plain text. If normalization lives inside the engine, you cannot change engines without rewriting the content. Put it in front, as a deterministic, testable transformation.&lt;/p&gt;

&lt;p&gt;Protect what must not be touched first: URLs, emails, file paths, code spans, identifiers. Then apply ordered, language-specific rules. Order matters: expand &lt;code&gt;No.&lt;/code&gt; before &lt;code&gt;No. 5&lt;/code&gt; and you get the wrong sentence; strip punctuation before detecting a decimal and &lt;code&gt;3.5&lt;/code&gt; becomes &lt;code&gt;3 5&lt;/code&gt;.&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;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;

&lt;span class="no"&gt;PROTECTED&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"(https?://\S+|[\w.+-]+@[\w.-]+\.\w+|`[^`]+`|"&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\b[\w-]+/[\w./-]+\b|\b[A-Za-z]+_[A-Za-z0-9_]+\b)"&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;normalize&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="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lang&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&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="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;spans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;PROTECTED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spans&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;group&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"\x00{len(spans)-1}\x00"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&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="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;lang&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"en"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\bQ([1-4])\b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"quarter \1"&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;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"(\d+(?:\.\d+)?)%"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\1 percent"&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="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"(\d+)/(\d+)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\2分の\1"&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="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;original&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spans&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"\x00{i}\x00"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;original&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;text&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is deliberately small. English has heteronyms — “lead” is a metal or a verb, “read” is present or past — and Japanese counters and dates depend on context. A rule table gets most of the way. The residual is a legitimate place for a small model, but constrain it to a closed choice: &lt;code&gt;{"pronunciation": "led"}&lt;/code&gt;, never a rewrite of the sentence.&lt;/p&gt;

&lt;p&gt;Language belongs to the segment, not to a global setting. A Japanese voice reading an English acronym may be right for a product name and wrong for a full sentence. Store &lt;code&gt;lang&lt;/code&gt; per segment and pick the voice per language. VOICEVOX is a useful Japanese example: a local service, a WAV back, no script leaving the machine. The interface stays the same for a system voice, Piper, or another local engine: &lt;code&gt;synthesize(text, voice, speed) -&amp;gt; PCM&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Audio is a cache, not a side effect
&lt;/h2&gt;

&lt;p&gt;In an editor, synthesis is a build step. Each slide’s narration is an artifact with an identity, a duration, and a provenance record. The identity is a hash of everything that can change the sound:&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;audio_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;segment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;voice&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;segment&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"normalized_text"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"lang"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;segment&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"lang"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"voice"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;voice&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"engine"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'{engine["id"]}@{engine["version"]}'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"speed"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"rate"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;48000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"normalizer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"v3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sort_keys&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ensure_ascii&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&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;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&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;The normalizer version is in the key on purpose: fix a pronunciation rule and the affected clips must be invalidated. Change only slide 47’s text and only slide 47 gets a new key. Store 48 kHz PCM, trim leading and trailing silence, fade the edges, and normalize to a fixed loudness target — for speech, roughly -16 LUFS with a -1.5 dBTP ceiling. One quiet clip followed by a loud clip sounds broken even when every word is correct.&lt;/p&gt;

&lt;p&gt;Keep a manifest keyed by slide ID with the text, language, voice, key, duration, and path. It is the source of truth for the timeline and the next export. The diff is over normalized segments, not raw slide text: editing a title that is never narrated should not invalidate audio; editing a hidden note that is narrated should.&lt;/p&gt;

&lt;h2&gt;
  
  
  The timeline is a function of the audio
&lt;/h2&gt;

&lt;p&gt;Most first versions assign five seconds to every slide, synthesize, then stretch or squeeze the audio to fit. It works until a slide has a long explanation, a diagram needs silence, or a title needs a beat before the first word.&lt;/p&gt;

&lt;p&gt;Invert the dependency. The audio is the anchor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;visual_duration = max(min_hold, audio_duration + tail_padding)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A title card may need a minimum hold with no narration. A dense diagram may need more tail padding. A 22-second explanation gets 22 seconds, not five. The model never chooses a duration; it supplies words, and the words become samples.&lt;/p&gt;

&lt;p&gt;Round boundaries, not durations. Per-slide rounding accumulates: by slide 90 the video is a few frames ahead of the audio. Use cumulative time:&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;plan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;segments&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fps&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tail&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.35&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_hold&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;1.2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frames&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&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;s&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;segments&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;hold&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min_hold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"audio_seconds"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;tail&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;fps&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;hold&lt;/span&gt;
        &lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;fps&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;frames&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"slide"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"slide"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"start"&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="s2"&gt;"frames"&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="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;}&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;frames&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;fps&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Transitions are a separate budget. A 0.4-second crossfade overlaps two shots; it does not add 0.4 seconds. If it does, the video grows every time you add a transition and the narration drifts later and later. Keep a visual track and an audio track, and recompute transition handles from the new boundaries after an edit — a fixed overlap measured in frames will clip the first words of the new narration.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Edit one narration, and every downstream start time moves. The audio cache stays valid; only the affected visual range is rebuilt.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is what makes editing tolerable. A 2.3-second change on slide 47 shifts the start times of slides 48–96, but does not invalidate their audio. The timeline recomputes in milliseconds, and the export reuses every unchanged clip. The expensive part is not the arithmetic; it is not re-synthesizing 49 slides because one sentence changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stream frames; probe the encoder
&lt;/h2&gt;

&lt;p&gt;The naive export writes 54,000 PNGs to disk and then calls FFmpeg. It works for a demo and fails on a laptop: disk churn, inode pressure, a cleanup step that deletes the wrong folder, and no backpressure when the encoder falls behind.&lt;/p&gt;

&lt;p&gt;Stream the frames instead. Render one frame, write it to FFmpeg’s stdin, repeat. At 1080p30, RGB24 is about 187 MB/s; at 4K30, about 746 MB/s. That is a lot of bytes, but it is a bounded stream, not a growing folder. A queue of three to eight frames keeps memory flat while both renderer and encoder stay busy. An unbounded queue turns a slow encoder into an out-of-memory crash.&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;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Popen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s2"&gt;"ffmpeg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-f"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"rawvideo"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-pix_fmt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"rgb24"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"-s"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{w}x{h}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-r"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"30"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-i"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pipe:0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"-i"&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="s2"&gt;"-c:v"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;encoder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-pix_fmt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"yuv420p"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"-c:a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"aac"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-b:a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"192k"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-ar"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"48000"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"-movflags"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"+faststart"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-t"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{frames/30:.3f}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stdin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;PIPE&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;frame&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;render_frames&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# blocks: backpressure, not RAM growth&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hardware encoding is a probe, not a grep. The binary can list &lt;code&gt;h264_videotoolbox&lt;/code&gt;, &lt;code&gt;h264_nvenc&lt;/code&gt;, or &lt;code&gt;h264_qsv&lt;/code&gt; and still fail on this driver at this resolution. Encode one frame at the target size:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ffmpeg -f lavfi -i &lt;span class="nv"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;c&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;black:s=1920x1080:d=0.04 -frames:v 1 \
  -c:v h264_videotoolbox -pix_fmt yuv420p -f null -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exit zero means usable now. Cache the result for the session and re-probe after a GPU driver update. Quality flags are not portable: &lt;code&gt;-crf&lt;/code&gt; is libx264, NVENC uses &lt;code&gt;-cq&lt;/code&gt; or &lt;code&gt;-b:v&lt;/code&gt;, VideoToolbox uses &lt;code&gt;-q:v&lt;/code&gt; or a bitrate, QSV uses &lt;code&gt;-global_quality&lt;/code&gt;. A single “quality” slider that maps to all of them is a lie.&lt;/p&gt;

&lt;p&gt;Muxing details matter more than they look: &lt;code&gt;yuv420p&lt;/code&gt; for compatibility, &lt;code&gt;+faststart&lt;/code&gt; for playback before download, explicit &lt;code&gt;-t&lt;/code&gt; instead of &lt;code&gt;-shortest&lt;/code&gt;, 48 kHz audio, BT.709 tags for HD, and an &lt;code&gt;ffprobe&lt;/code&gt; check of duration, streams, pixel format, and frame count.&lt;/p&gt;

&lt;p&gt;The biggest optimization is not a faster encoder. It is not encoding the unchanged 95%. Slice the timeline into render units at hard cuts, never inside a crossfade. Each unit has a hash of its slide images, layout, transition parameters, and frame range. Unchanged units are reused; a changed unit is re-encoded and spliced at a keyframe. Concatenate with stream copy and mux the final audio:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ffmpeg -f concat -safe 0 -i units.txt -i narration.wav \
  -c:v copy -c:a aac -b:a 192k -ar 48000 \
  -movflags +faststart -t 1832.4 final.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every unit must use identical video parameters and start with a keyframe. MPEG-TS intermediates are more forgiving than MP4 when timestamps disagree. You cannot stream-copy a new frame into the middle of an H.264 file and expect every player to handle it; you can re-encode the affected unit and splice at a keyframe. The user experiences a 40-second export instead of a 40-minute one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Failure is a segment, not a crash
&lt;/h2&gt;

&lt;p&gt;A local pipeline meets machines you did not design for: a voice model that fails to load, a disk with 300 MB free, a GPU driver that disappears after sleep, a WAV with a missing channel. Make every unit a result: &lt;code&gt;Ok(artifact)&lt;/code&gt; or &lt;code&gt;Err(reason)&lt;/code&gt;. A failed slide gets a visible badge and a fallback — the system voice, silence with a caption, or a fixed hold. The export still finishes.&lt;/p&gt;

&lt;p&gt;Never show a spinner with no escape hatch. If hardware encoding fails, retry with &lt;code&gt;libx264&lt;/code&gt;. If TTS times out, keep the text and mark the slide unnarrated. If the disk is full, stop before writing a corrupt MP4 and say so.&lt;/p&gt;

&lt;p&gt;Test the deterministic parts hard: normalization tables per language, golden timeline JSON including rounding boundaries, a one-slide edit that invalidates exactly one cache key, a mux test with color bars and a tone, and an offline export. Do not assert exact TTS waveforms. They are not the contract. Assert the text that goes in, the duration that comes out, and the file that plays.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 10% is the sentence
&lt;/h2&gt;

&lt;p&gt;The model writes the sentence. That is genuinely useful: it turns a bullet list into something a human can listen to, without sending the deck to a server.&lt;/p&gt;

&lt;p&gt;Everything after that is the 90%: normalize, synthesize, cache, measure, place on a timeline, render frames, feed the encoder, mux, verify, and reuse what did not change. None of it is glamorous. All of it is testable. When it works, the user does not notice it at all — which is the point.&lt;/p&gt;

&lt;p&gt;A narrated deck is not a model output. It is media engineering that happens to contain model output. The deterministic win is an export that finishes, an edit that re-renders 40 seconds instead of 40 minutes, and a file that plays on the first try.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I’m building a local desktop tool that turns existing PowerPoint decks into narrated videos; this is the part that makes the export boring enough to trust.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Previously: &lt;a href="https://medium.com/@dqj1998/desktop-apps-keep-wiring-a-7b-model-into-every-control-path-115063626c2f" rel="noopener noreferrer"&gt;Part 1&lt;/a&gt;, &lt;a href="https://medium.com/@dqj1998/surgical-prompting-how-to-make-a-7b-local-model-never-break-your-schema-65b0a6d77e24" rel="noopener noreferrer"&gt;Part 2&lt;/a&gt;, &lt;a href="https://medium.com/@dqj1998/ollama-mlx-or-native-the-runtime-choice-that-decides-whether-on-device-ai-ships-3ab9be6d1bef" rel="noopener noreferrer"&gt;Part 3&lt;/a&gt;, &lt;a href="https://medium.com/@dqj1998/when-ai-meets-powerpoint-ooxml-parsing-and-the-local-model-at-the-edge-927906dab50e" rel="noopener noreferrer"&gt;Part 4&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://medium.com/@dqj1998/the-deterministic-win-multilingual-tts-elastic-timelines-and-the-ffmpeg-export-nobody-sees-07dcf9286f63" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>ffmpeg</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>When AI Meets PowerPoint: OOXML Parsing and the Local Model at the Edge</title>
      <dc:creator>dqj</dc:creator>
      <pubDate>Thu, 03 Dec 2026 15:30:46 +0000</pubDate>
      <link>https://dev.to/dqj1998/when-ai-meets-powerpoint-ooxml-parsing-and-the-local-model-at-the-edge-4df8</link>
      <guid>https://dev.to/dqj1998/when-ai-meets-powerpoint-ooxml-parsing-and-the-local-model-at-the-edge-4df8</guid>
      <description>&lt;p&gt;A 120-slide deck arrived on a Friday afternoon: revenue bridges, three-year projections, architecture diagrams, a table on slide 63 with more columns than the projector could show. The speaker notes were empty. Someone needed a narrated video by Monday.&lt;/p&gt;

&lt;p&gt;The obvious approach is to render every slide and ask a vision model to describe it. It demos well, until slide 47 says “FY26 gross margin: 62.4%” and the model writes “around 60%,” or worse, invents “63.1%.” On a board deck, that is not a rounding error. It is a credibility incident. And if the deck is confidential, uploading it is a second incident.&lt;/p&gt;

&lt;p&gt;The fix is an architectural boundary, not a better prompt. The format, layout graph, numbers, and export path stay deterministic. A small local model gets one narrow, reversible job: turn a structured summary into a sentence when a human left a gap.&lt;/p&gt;

&lt;p&gt;This is the fourth article in the “10% AI, 90% deterministic code” series. The first three covered control-plane design, constrained output, and runtime choice. This one moves to a real document: the &lt;code&gt;.pptx&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The file is a zip, not a picture
&lt;/h2&gt;

&lt;p&gt;Rename a &lt;code&gt;.pptx&lt;/code&gt; to &lt;code&gt;.zip&lt;/code&gt; and open it. You will not find a document, but a package of XML parts, relationships, and media:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Content_Types].xml
_rels/.rels
ppt/presentation.xml
ppt/_rels/presentation.xml.rels
ppt/slides/slide1.xml
ppt/slides/_rels/slide1.xml.rels
ppt/slideLayouts/slideLayout1.xml
ppt/slideMasters/slideMaster1.xml
ppt/theme/theme1.xml
ppt/notesSlides/notesSlide1.xml
ppt/media/image1.png
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is OOXML (ECMA-376 / ISO 29500). The important word is &lt;em&gt;package&lt;/em&gt;. &lt;code&gt;slide1.xml&lt;/code&gt; is not necessarily the first slide. Order lives in &lt;code&gt;ppt/presentation.xml&lt;/code&gt;, as slide IDs that point through relationships to parts. Parts copied from another deck may not follow slide order.&lt;/p&gt;

&lt;p&gt;That breaks many parsers: they iterate &lt;code&gt;slide1.xml&lt;/code&gt;, &lt;code&gt;slide2.xml&lt;/code&gt;, … and produce a plausible deck until someone checks slide 12.&lt;/p&gt;

&lt;p&gt;The package is a graph. A &lt;code&gt;.rels&lt;/code&gt; file maps IDs to targets: slide to layout, layout to master, master to theme, slide to notes and media. Resolve the graph; do not guess from filenames.&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;import&lt;/span&gt; &lt;span class="n"&gt;posixpath&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;zipfile&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;ZipFile&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;lxml&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;etree&lt;/span&gt;

&lt;span class="no"&gt;R&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"http://schemas.openxmlformats.org/officeDocument/2006/relationships"&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;)&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;etree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromstring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;)&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;rels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;base&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;posixpath&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dirname&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;rp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{base}/_rels/{posixpath.basename(part)}.rels"&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;r&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="s2"&gt;"Id"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&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="s2"&gt;"Type"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;posixpath&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;normpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;posixpath&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&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="s2"&gt;"Target"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&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;r&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rp&lt;/span&gt;&lt;span class="p"&gt;)&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;slide_parts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;pres&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ppt/presentation.xml"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;pr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;rels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ppt/presentation.xml"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;s&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="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{{{R}}}id"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&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;s&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pres&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;".//p:sldIdLst/p:sldId"&lt;/span&gt;&lt;span class="p"&gt;)&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;chain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;rels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;lp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;typ&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;sr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&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;typ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;endswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/slideLayout"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;rels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;mp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;typ&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;lr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&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;typ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;endswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/slideMaster"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;rels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mp&lt;/span&gt;&lt;span class="p"&gt;)&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;That is the unglamorous part, and it is also the part that has to be right. Everything downstream trusts this graph.&lt;/p&gt;

&lt;h2&gt;
  
  
  The inheritance chain is the document
&lt;/h2&gt;

&lt;p&gt;Most text is not fully specified on the slide. A title can inherit position from the layout, font from the master, and color from the theme. Bullet indentation and line spacing can come from higher up.&lt;/p&gt;

&lt;p&gt;Placeholders are matched by &lt;code&gt;idx&lt;/code&gt; and &lt;code&gt;type&lt;/code&gt;, not by reading order. If you parse only &lt;code&gt;slideN.xml&lt;/code&gt;, you will miss inherited geometry, apply the wrong font, or place a title at &lt;code&gt;(0, 0)&lt;/code&gt;. The slide will still “parse.” It will simply be wrong.&lt;/p&gt;

&lt;p&gt;Resolve each shape against the chain before handing it to the renderer or model:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Read the shape’s explicit properties.&lt;/li&gt;
&lt;li&gt;Find the matching placeholder in the layout.&lt;/li&gt;
&lt;li&gt;If a property is still missing, look in the master.&lt;/li&gt;
&lt;li&gt;Resolve theme colors, fonts, and effects last.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Coordinates are EMU. One inch is 914,400; a 16:9 slide is 12,192,000 × 6,858,000. Keep integers until the final conversion; early rounding drifts across grouped shapes.&lt;/p&gt;

&lt;p&gt;Text extraction is deceptively simple:&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="no"&gt;A&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"http://schemas.openxmlformats.org/drawingml/2006/main"&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;text_of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;paragraphs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&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;p&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;iter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{{{A}}}p"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;runs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;iter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{{{A}}}t"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;paragraphs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;runs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"\n"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;paragraphs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The hard part is not the string, but knowing which shape it belongs to, where that shape sits, whether it is a title, bullet, table cell, or chart label, and which part it came from.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build a slide IR, not a prompt
&lt;/h2&gt;

&lt;p&gt;The temptation is to serialize the XML into a model. Do not. XML is a transport format, not a context strategy: verbose, full of styling noise, and full of the numbers you do not want paraphrased.&lt;/p&gt;

&lt;p&gt;Build a small intermediate representation instead. One slide, one object:&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="nl"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;47&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"part"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ppt/slides/slide47.xml"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"FY26 margin bridge"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="nl"&gt;"blocks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
   &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"kind"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"bullets"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Volume +3.1 pts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Mix +1.8 pts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"Pricing +0.9 pts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"FX -1.4 pts"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"kind"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"table"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"rows"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Gross margin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"62.4%"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"58.9%"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="nl"&gt;"notes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice what is missing: pixels, prose, guesses. Every field is read from the package or resolved through inheritance. Every block points back to its part and shape ID, so a validator can prove where a sentence came from.&lt;/p&gt;

&lt;p&gt;This IR is the contract. Renderer, notes generator, and tests all consume it. The model never sees the original file, and never gets to invent a table cell.&lt;/p&gt;

&lt;h2&gt;
  
  
  The local model gets one narrow job
&lt;/h2&gt;

&lt;p&gt;The extractor fills almost everything: titles, bullets, tables, chart series, positions, existing notes. The gap is semantic — a slide has no notes, an image has no caption, a diagram needs one sentence of orientation.&lt;/p&gt;

&lt;p&gt;That is the 10%.&lt;/p&gt;

&lt;p&gt;For a missing note, the prompt is small: title, bullets, table deltas, chart labels, one line about any image. No full deck, no raw XML, no “world-class expert” preamble.&lt;/p&gt;

&lt;p&gt;The output is constrained at the decoder, not requested in the prompt. A JSON Schema or GBNF grammar allows one object with one string field:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root   ::= "{\"narration\":\"" sentence "\"}"
sentence ::= char{40,320}
char   ::= [^"\\\x00-\x1F] | "\\\"" | "\\\\"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;llama.cpp&lt;/code&gt;, the schema becomes a grammar, so the sampler cannot emit an unclosed quote or an extra key. The downstream parser needs no error handling for malformed JSON, because malformed JSON cannot be produced.&lt;/p&gt;

&lt;p&gt;But grammar-constrained decoding solves syntax, not truth. The validator still has to check semantics:&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;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;numeric_tokens&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="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\d+(?:\.\d+)?%?"&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="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;accept&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;narration&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;facts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;numeric_tokens&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;claimed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;numeric_tokens&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;narration&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;claimed&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;facts&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the note contains a number not in the IR, reject it. Retry once at lower temperature. If it fails again, fall back to a template: “This slide covers {title}. It contains {n} bullet points and a table with {rows} rows.” It is not elegant, but it is true and never blocks the export.&lt;/p&gt;

&lt;p&gt;The model is allowed to choose words. It is not allowed to choose facts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where vision actually helps
&lt;/h2&gt;

&lt;p&gt;A rendered slide is useful. A vision model reading it answers a narrower set of questions than most demos suggest.&lt;/p&gt;

&lt;p&gt;Use vision for semantics that are genuinely visual:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“This diagram shows a three-stage funnel from acquisition to renewal.”&lt;/li&gt;
&lt;li&gt;“The photo shows a warehouse floor with three picking zones.”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do not use vision for numbers, table cells, or body text. Those are in the IR; take values from the XML.&lt;/p&gt;

&lt;p&gt;A cheaper layer comes first: layout checks. Bounding boxes from resolved geometry flag shapes past the slide edge, overlapping the footer, or below minimum font size. Arithmetic, not inference, and no weights.&lt;/p&gt;

&lt;p&gt;Vision earns its keep on the residual: an uncaptioned diagram, an unlabelled photo, a chart titled “Q4” whose meaning is not obvious. One sentence per asset, constrained to visible content.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rendering is the hard deterministic part
&lt;/h2&gt;

&lt;p&gt;The renderer is where “no Office dependency” becomes a pile of edge cases.&lt;/p&gt;

&lt;p&gt;You need to handle:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DrawingML transforms.&lt;/strong&gt; Position, size, rotation, flip, group composition, crop. A group’s children are relative to the group’s transform, not the slide.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Theme resolution.&lt;/strong&gt; A color is a theme slot plus tint or shade; a font is a theme slot plus a script fallback.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Text layout.&lt;/strong&gt; Font metrics, line spacing, bullet indents, autofit, vertical anchoring.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Font fallback.&lt;/strong&gt; Embedded fonts may be absent, licensed, or subsetted. Different metrics reflow the text. Do not silently reflow a client’s slide: measure, clip, warn.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Images and effects.&lt;/strong&gt; Transparency, gradients, shadows, soft edges are optional in the spec and uneven in the wild.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You do not need all of DrawingML, only the subset your decks use plus a visible fallback. A gray “unsupported effect” placeholder is honest; a silently wrong render is not.&lt;/p&gt;

&lt;p&gt;Cache the render by a hash of slide XML, theme, and font set. A 100-slide preview should feel instant on second open. The cache key is a test fixture: if the hash changes, the output should change for a reason you can name.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pipeline
&lt;/h2&gt;

&lt;p&gt;Here is the whole system, with the boundary drawn where it belongs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.pptx ──▶ package + relationships ──▶ slide IR (facts + provenance)
                                         │
                 ┌───────────────────────┴───────────────────────┐
                 ▼                                               ▼
        deterministic renderer                            gap detector
                 │                                               │
                 ▼                                               ▼
        PNG + layout checks                               local LLM
                 │                                               │
                 ▼                                               ▼
        vision model (semantics)                          validator (facts)
                 └───────────────────────┬───────────────────────┘
                                         ▼
                                timeline / FFmpeg export
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every arrow into the model is optional. Every arrow out of the model passes through a validator. If the model is unavailable, the pipeline still produces a deck with extracted notes and a template for the gaps. That is the difference between a feature and a dependency.&lt;/p&gt;

&lt;h2&gt;
  
  
  Failure isolation and tests
&lt;/h2&gt;

&lt;p&gt;A parser meets files no one designed for: a deck zipped on a phone, a slide with 4,000 shapes, a corrupt relationship, a missing font, a merged-cell table that breaks your renderer. Treat each slide as a separate job: &lt;code&gt;Ok(slide)&lt;/code&gt; or &lt;code&gt;Err(reason)&lt;/code&gt;. One bad slide gets one visible badge, not a crashed app.&lt;/p&gt;

&lt;p&gt;Guard the package: reject path traversal, cap size and entry count, disable DTDs and external entities, keep targets inside the package.&lt;/p&gt;

&lt;p&gt;Then build a golden corpus. Thirty real decks beat three hundred spec-written tests: tables, groups, rotated text, RTL, CJK, embedded images, and one deck assembled at 2 a.m. Hash the IR and the PNG; any change is a diff. For the model, measure factuality, not BLEU: every number must appear in the IR, and the note must name the title. Run offline.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 10/90 split, in one sentence
&lt;/h2&gt;

&lt;p&gt;Deterministic code owns the package, graph, geometry, facts, render, validation, and export. The model owns one paragraph when a human left a gap, and one caption when an image has no words.&lt;/p&gt;

&lt;p&gt;That is not a compromise; it is the only division that survives a real deck, a real machine, no network, and a deadline.&lt;/p&gt;

&lt;p&gt;A missing note is a gap, not an emergency: the renderer can still render, the exporter can still export, and the model can fail without taking the product down.&lt;/p&gt;

&lt;p&gt;The best AI feature in a document tool is the one you can turn off and still have a document tool.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I’m building a local desktop tool that turns existing PowerPoint decks into narrated videos; the architecture above is the part that makes it boring enough to trust.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Previously: &lt;a href="https://medium.com/@dqj1998/desktop-apps-keep-wiring-a-7b-model-into-every-control-path-115063626c2f" rel="noopener noreferrer"&gt;Part 1&lt;/a&gt;, &lt;a href="https://medium.com/@dqj1998/surgical-prompting-how-to-make-a-7b-local-model-never-break-your-schema-65b0a6d77e24" rel="noopener noreferrer"&gt;Part 2&lt;/a&gt;, &lt;a href="https://medium.com/@dqj1998/ollama-mlx-or-native-the-runtime-choice-that-decides-whether-on-device-ai-ships-3ab9be6d1bef" rel="noopener noreferrer"&gt;Part 3&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://medium.com/@dqj1998/when-ai-meets-powerpoint-ooxml-parsing-and-the-local-model-at-the-edge-927906dab50e" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>softwareengineering</category>
      <category>spanish</category>
      <category>ooxml</category>
    </item>
    <item>
      <title>Ollama, MLX, or Native: The Runtime Choice That Decides Whether On-Device AI Ships</title>
      <dc:creator>dqj</dc:creator>
      <pubDate>Wed, 02 Dec 2026 08:41:30 +0000</pubDate>
      <link>https://dev.to/dqj1998/ollama-mlx-or-native-the-runtime-choice-that-decides-whether-on-device-ai-ships-4ai3</link>
      <guid>https://dev.to/dqj1998/ollama-mlx-or-native-the-runtime-choice-that-decides-whether-on-device-ai-ships-4ai3</guid>
      <description>&lt;p&gt;A seven-billion-parameter model answered in 280 milliseconds on my development machine. Two weeks later, the same feature took eleven seconds to produce its first token on a colleague's laptop, then crashed the app when the machine ran out of memory.&lt;/p&gt;

&lt;p&gt;Nothing was wrong with the model. The runtime was a separate process started with default settings on a machine with 8 GB of unified memory, while a video call held 2 GB. The app had no idea. It had sent an HTTP request to &lt;code&gt;localhost&lt;/code&gt; and waited, because that is what the tutorial did.&lt;/p&gt;

&lt;p&gt;That was the week I stopped treating "run a local model" as a line of setup code. Once you ship to people who did not choose their hardware, did not close their browser, and may not have admin rights, the runtime stops being an implementation detail. It becomes part of your installation, your crash surface, your security boundary, and your support burden.&lt;/p&gt;

&lt;p&gt;This post compares the three realistic ways to put a local model inside a desktop application, then describes the unglamorous machinery that makes the choice survivable: a hardware probe, a degradation ladder, and an offline contract.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This is Part 3 of the **Shipping On-Device AI&lt;/em&gt;* series. Part 1 argued that a local LLM should never be the "brain" of the system; Part 2 covered surgical prompting for small models. Originally published on &lt;a href="https://medium.com/@dqj1998/ollama-mlx-or-native-the-runtime-choice-that-decides-whether-on-device-ai-ships-3ab9be6d1bef" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;.*&lt;/p&gt;

&lt;h2&gt;
  
  
  The demo machine is not the product
&lt;/h2&gt;

&lt;p&gt;On a developer laptop, local inference looks like a library call. On a shipped desktop app, it looks like a distribution problem.&lt;/p&gt;

&lt;p&gt;You are choosing among constraints that have nothing to do with model quality:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Install size.&lt;/strong&gt; A quantized 7B model is roughly 4–5 GB. An 8B model at Q8 is closer to 8–9 GB. Users notice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hardware.&lt;/strong&gt; Apple Silicon shares memory between CPU and GPU. Windows machines have discrete VRAM, integrated graphics, or neither.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Permissions.&lt;/strong&gt; A per-user install cannot open a firewall port without a prompt and may be blocked from spawning a long-lived service.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Failure.&lt;/strong&gt; A model in your process can take your process down. A model beside it can leak an orphan that holds 6 GB until reboot.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Offline reality.&lt;/strong&gt; The documents that make local AI worth building—financial models, architecture diagrams, unreleased strategy—must never leave the machine.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Treat the model like a database engine, not a regex library: a large binary, a nontrivial startup cost, and a failure mode measured in gigabytes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three shapes of a runtime
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. The sidecar: Ollama or &lt;code&gt;llama.cpp&lt;/code&gt; over HTTP
&lt;/h3&gt;

&lt;p&gt;The most common setup is a local server. Ollama wraps &lt;code&gt;llama.cpp&lt;/code&gt; and exposes an HTTP API on &lt;code&gt;127.0.0.1:11434&lt;/code&gt;. You can also run &lt;code&gt;llama-server&lt;/code&gt; directly. Your app sends JSON and receives tokens.&lt;/p&gt;

&lt;p&gt;The appeal is real. The server is a separate process, so a model crash does not take down the UI. It is language-agnostic, can be updated independently, and users who already run Ollama share the same model cache.&lt;/p&gt;

&lt;p&gt;The costs show up in the field:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Port ownership.&lt;/strong&gt; &lt;code&gt;11434&lt;/code&gt; may already be in use. A fixed port turns into a support ticket; the app must allocate a free port and write it somewhere only the app can read.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Process lifecycle.&lt;/strong&gt; If the app crashes, who stops the server? If two copies launch, do they share a model or fight over memory?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Two installs.&lt;/strong&gt; You ship a runtime plus weights, and handle upgrades, partial downloads, proxy settings, and disk errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A local network surface.&lt;/strong&gt; A loopback HTTP server is reachable by every process running as that user. "Localhost only" is not authentication.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. The embedded library: link the engine
&lt;/h3&gt;

&lt;p&gt;The other extreme is to link the inference engine into the application: &lt;code&gt;llama.cpp&lt;/code&gt;/GGML as a dynamic library, Apple's MLX as a Swift or C++ dependency, or ONNX Runtime with a hardware execution provider.&lt;/p&gt;

&lt;p&gt;Now there is one process. No port, no orphan, no second installer. Weights can be memory-mapped from the app's own cache, and streaming goes through a callback instead of a socket. Startup can be lazy: the window appears immediately, and the model loads in a worker when the user opens the AI panel.&lt;/p&gt;

&lt;p&gt;The costs move rather than disappear:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Crash containment.&lt;/strong&gt; A bad kernel or an out-of-memory condition can terminate the whole app. You need a supervisor or a careful worker boundary if the feature must not take the editor down.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build complexity.&lt;/strong&gt; You ship per-architecture binaries, GPU backends, and their shared libraries. Code signing, hardened runtime, and notarization now cover all of them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Update coupling.&lt;/strong&gt; A one-line fix in the runtime means shipping the entire app, and on macOS another notarization cycle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory ownership.&lt;/strong&gt; The engine wants a large contiguous allocation and a KV cache that grows with context. Your UI framework wants to believe memory is plentiful.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The embedded path gives the best latency and the cleanest user experience. It also concentrates risk in the process the user is using.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The hybrid: embedded floor, sidecar ceiling
&lt;/h3&gt;

&lt;p&gt;The pattern that has worked best is not a compromise. It is a division of labour.&lt;/p&gt;

&lt;p&gt;Keep a small, always-available capability in-process: classification, short rewrites, embedding, a 1–3B model for interactive parts. Put heavy, optional 7–14B generation behind a runtime that can start on demand, stop when idle, and be replaced without touching the app binary.&lt;/p&gt;

&lt;p&gt;The UI does not know which one answered. Both sit behind the same interface, with the same cancellation, timeout, and error semantics. The runtime becomes swappable, which is also what lets you benchmark it honestly.&lt;/p&gt;

&lt;p&gt;The trade is risk: crash isolation and update speed versus latency and blast radius.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measure the right thing
&lt;/h2&gt;

&lt;p&gt;Tokens per second is the number everyone quotes and the number users feel least. What they feel is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Time to first token (TTFT).&lt;/strong&gt; Dominated by prompt processing and model load, not decode speed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;p95 latency under memory pressure.&lt;/strong&gt; The mean is fiction when the OS starts swapping.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Peak resident memory.&lt;/strong&gt; The number that decides whether the app survives a 16 GB machine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cold start.&lt;/strong&gt; The gap between clicking the feature and seeing the first character.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Thermal behaviour.&lt;/strong&gt; A fanless laptop can lose a third of its throughput.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The arithmetic is more useful than a leaderboard. For a transformer, the KV cache at FP16 is roughly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bytes per token = 2 × layers × kv_heads × head_dim × 2 bytes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a typical 8B model with 32 layers, 8 KV heads, and head dimension 128, that is about 128 KiB per token. At 8,192 tokens of context, the cache alone is around 1 GiB—before weights, activations, and the rest of the app. At 32,768 tokens it is roughly 4 GiB. Context length is not free, and it is the setting users change most casually.&lt;/p&gt;

&lt;p&gt;Weights scale with quantization. Q4_K_M is roughly 4.5–5 bits per weight; Q8_0 is roughly 8.5. For an 8B model that is about 4.5–5 GB versus 8–9 GB. The quality difference on short, constrained tasks is often small; the memory difference decides whether the feature ships on a 16 GB machine.&lt;/p&gt;

&lt;p&gt;This is why the first benchmark should run on the weakest supported machine, with a browser and a large document open. An idle 64 GB workstation tells you what the model can do. The weak machine tells you what the product can do.&lt;/p&gt;

&lt;h2&gt;
  
  
  A degradation ladder that is boring on purpose
&lt;/h2&gt;

&lt;p&gt;Graceful degradation is not a fallback message. It is a sequence of explicit, testable states, chosen before the user asks for anything.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 ┌───────────────────┐
   app start ───▶│  hardware probe   │──▶ cached tier (24 h)
                 └─────────┬─────────┘
                           │
        ┌──────────────────┼───────────────────┐
        ▼                  ▼                   ▼
   Tier A: GPU        Tier B: GPU         Tier C: CPU        Tier D
   Q8_0, 8k ctx       Q4_K_M, 4k ctx      Q4_K_M, 2k ctx     rules only
        │                  │                   │                │
        └──────────────────┴─────────┬─────────┴────────────────┘
                                     ▼
                         deterministic pipeline
                                     │
                    timeout / OOM / thermal / crash
                                     ▼
                         step down one tier, retry once
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tier A is for machines with headroom: discrete VRAM or a large unified-memory budget, enough for weights, KV cache, and the app. Tier B is the common laptop. Tier C is CPU-only or a tiny GPU budget, with a shorter context and a smaller model. Tier D runs no model and uses the deterministic rules that must exist anyway.&lt;/p&gt;

&lt;p&gt;The probe should be cheap, cached, and never block the first paint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;Tier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"A"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="s2"&gt;"B"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="s2"&gt;"C"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="s2"&gt;"D"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nc"&gt;GiB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1024&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;chooseTier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hw&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Hardware&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Tier&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;free&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;freeMemoryBytes&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;GiB&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;totalMemoryBytes&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;GiB&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// No usable accelerator: keep the context small or skip the model.&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;hw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hasMetal&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;hw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hasCuda&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;hw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hasVulkan&lt;/span&gt;&lt;span class="p"&gt;)&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;total&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;free&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;"C"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"D"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// Unified memory is shared with the OS, browser, and everything else.&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unified&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;free&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"A"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unified&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;free&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"B"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Discrete GPU: require weights + KV + headroom in VRAM.&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vramBytes&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;GiB&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"A"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vramBytes&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;GiB&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"B"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"C"&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;Two rules matter more than the thresholds. First, the probe must be allowed to say "no model". Rules-only is not a failure state; it is the floor that keeps the app useful on the worst machine. Second, never silently switch to a cloud API when the local tier is unavailable. That single "helpful" fallback breaks the privacy promise and is hard to walk back.&lt;/p&gt;

&lt;p&gt;For the sidecar path, pin the runtime to loopback, give it an ephemeral port, cap context explicitly, and authenticate even on localhost:&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;# The app allocates a free port and writes a per-session token to a 0600 file.&lt;/span&gt;
llama-server \
  --model &lt;span class="s2"&gt;"$MODEL_DIR/qwen2.5-7b-instruct-q4_k_m.gguf"&lt;/span&gt; \
  --host 127.0.0.1 \
  --port &lt;span class="s2"&gt;"$PORT"&lt;/span&gt; \
  --ctx-size 4096 \
  --n-gpu-layers 99 \
  --parallel 1 \
  --api-key &lt;span class="s2"&gt;"$(cat "&lt;/span&gt;&lt;span class="nv"&gt;$RUNTIME_TOKEN_FILE&lt;/span&gt;&lt;span class="s2"&gt;")"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;KEEP_ALIVE&lt;/code&gt; is a memory policy, not a convenience. An idle model that stays resident for an hour is an hour of memory the user cannot use. A model that unloads after five minutes costs a reload. Pick the number deliberately, and expose it as a setting for long sessions.&lt;/p&gt;

&lt;p&gt;The circuit breaker belongs around the call: time out at 30 seconds, step down one tier on an out-of-memory or thermal failure, and record the step so it survives a restart.&lt;/p&gt;

&lt;p&gt;A step-down must be visible. If the app quietly produces worse output at a smaller context, users will conclude the feature is unreliable. Show the active mode in the AI panel: "Local · balanced" or "Rules only · low memory."&lt;/p&gt;

&lt;h2&gt;
  
  
  The offline contract
&lt;/h2&gt;

&lt;p&gt;Local inference is often sold as a privacy feature. Privacy is not a property of where the model runs; it is a property of what the process is allowed to do.&lt;/p&gt;

&lt;p&gt;A local model that sends crash reports containing the prompt, or that falls back to a cloud endpoint when the local one fails, is not private. A localhost server without authentication is not a security boundary. A model downloaded from an unpinned URL is a supply-chain dependency.&lt;/p&gt;

&lt;p&gt;The contract I would write down before shipping:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Zero document egress.&lt;/strong&gt; No analytics, crash payloads, or feedback may contain document text, prompts, completions, or file names. Redact at the boundary.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No implicit cloud fallback.&lt;/strong&gt; If the local runtime is unavailable, degrade to rules or tell the user. Never route the document elsewhere silently.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bind to loopback with a token.&lt;/strong&gt; Prefer a Unix socket where the platform allows it. Treat every local process as untrusted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pin the weights.&lt;/strong&gt; Record the hash, quantization, and licence; verify on load. A model update is a product change, not a cache refresh.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make offline the default.&lt;/strong&gt; The app should work with the network disabled. Test that in CI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sign the runtime.&lt;/strong&gt; Sign and notarize an embedded library with the app; verify a sidecar's signature before launch.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On macOS, an unsigned helper is blocked by Gatekeeper; on Windows, endpoint security may quarantine it. Both look like "the AI feature is broken."&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would ship
&lt;/h2&gt;

&lt;p&gt;Developers who already run Ollama will appreciate a sidecar: shared models, familiar logs, independent updates. A consumer desktop product should embed the runtime, keep the model optional, and make the first-run download resumable and verifiable. If you have both workloads, split them.&lt;/p&gt;

&lt;p&gt;Whatever you choose, put the runtime behind an interface that can be replaced, and put the deterministic pipeline in front of it. The parser, the state machine, the file writer, and the export path must not depend on a token stream succeeding. The model is the 10% that makes the product feel intelligent. The other 90% is what makes it feel like software. The best local runtime is the one whose failure modes you designed for before the demo.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Read the original on &lt;a href="https://medium.com/@dqj1998/ollama-mlx-or-native-the-runtime-choice-that-decides-whether-on-device-ai-ships-3ab9be6d1bef" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;. Next in the series: how I benchmarked the same app across three tiers, and what the weakest laptop taught me.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>architecture</category>
      <category>programming</category>
    </item>
    <item>
      <title>Surgical Prompting: How to Make a 7B Local Model Never Break Your Schema</title>
      <dc:creator>dqj</dc:creator>
      <pubDate>Mon, 30 Nov 2026 01:26:09 +0000</pubDate>
      <link>https://dev.to/dqj1998/surgical-prompting-how-to-make-a-7b-local-model-never-break-your-schema-elm</link>
      <guid>https://dev.to/dqj1998/surgical-prompting-how-to-make-a-7b-local-model-never-break-your-schema-elm</guid>
      <description>&lt;p&gt;Prompt engineering will not save a 4-bit quantized model from hallucinating malformed JSON. Context minimalism, grammar-constrained decoding, and strict output contracts will.&lt;/p&gt;

&lt;p&gt;In Part 1 we drew a hard architectural boundary: deterministic code owns 90% of the pipeline — file parsing, state machines, timeline math — while the local model sits strictly as a leaf operator handling the 10% where no specification exists.&lt;/p&gt;

&lt;p&gt;We defined that leaf with a simple contract:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;AiOperator&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;I&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;O&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&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="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;buildPrompt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;I&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;             &lt;span class="c1"&gt;// built by code&lt;/span&gt;
  &lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Result&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;O&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ParseError&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// schema-checked&lt;/span&gt;
  &lt;span class="nf"&gt;fallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;I&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;O&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                     &lt;span class="c1"&gt;// rules, not retries&lt;/span&gt;
  &lt;span class="n"&gt;budget&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;timeoutMs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;maxTokens&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt; &lt;span class="p"&gt;}&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;That interface isolates failures. It does not prevent them.&lt;/p&gt;

&lt;p&gt;If you wire a 4-bit quantized 7B or 8B model into &lt;code&gt;AiOperator&lt;/code&gt; and ask it politely to "return valid JSON", your &lt;code&gt;fallback()&lt;/code&gt; path will fire on 15% to 30% of production runs. Small models wrap JSON in markdown fences, invent extra keys, truncate mid-object when they hit &lt;code&gt;maxTokens&lt;/code&gt;, or drift into conversational filler ("Sure! Here is your rewritten note:").&lt;/p&gt;

&lt;p&gt;On a local machine you cannot fix this by scaling up to a 70B frontier model. You fix it at the input boundary and at the decoding layer. This is Part 2 of the 10% AI, 90% Deterministic Code series: how to treat a small local model not as a conversational partner, but as a constrained text-transformation kernel.&lt;/p&gt;

&lt;p&gt;Context Minimalism: Stop Dumping the Whole Document&lt;/p&gt;

&lt;p&gt;The most common mistake in local-first desktop apps is treating a 7B model's context window like a free scratchpad. Developers serialize an entire document, the user history, and ten rules into a 4,000-token prompt, then ask the model to transform a three-line bullet list.&lt;/p&gt;

&lt;p&gt;Every unnecessary input token extracts two penalties:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Prefill latency. On shared LPDDR memory (68–100 GB/s), processing 4,000 tokens of prompt before generating a single output token burns 1.5 to 3 seconds — blowing your interaction budget before decode even starts.&lt;/li&gt;
&lt;li&gt;Attention dilution. Small quantized models suffer severe recall degradation when instructions are buried under thousands of tokens of raw structural noise.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The fix is context minimalism. Your deterministic upstream code already parsed the file. Do not throw that structure away by feeding raw XML or full-document dumps into the model. Slice the payload down to the exact atomic unit required for the leaf operation — a single slide, a single paragraph, or a single function block — and strip everything the model cannot act on.&lt;/p&gt;

&lt;p&gt;What developers usually send (~1,800 tokens):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Here is the full presentation outline so far: [1,500 tokens of previous slides...]
Now look at Slide 4 raw XML/Markdown:
Title: Q3 Latency Audit
Bullets:
- P99 jumped 140ms -&amp;gt; 410ms
- Root cause: unindexed lookup in session_store
- Fix: added composite index, deployed Tuesday
Metadata: layout=TwoColumn, font=Inter, slideIndex=4, totalSlides=18
Please rewrite these bullets into natural spoken narration for a training video...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What the leaf operator actually needs (~160 tokens):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Task: Convert technical slide bullets into concise, natural spoken narration.
Rules:
- Expand symbols ("-&amp;gt;" to "to", "P99" to "ninety-ninth percentile").
- Add [pause] markers between distinct ideas.
- Keep under 60 words. Do not invent facts.
Input:
Title: Q3 Latency Audit
Bullets:
- P99 jumped 140ms -&amp;gt; 410ms
- Root cause: unindexed lookup in session_store
- Fix: added composite index, deployed Tuesday
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By cutting input context by 90%, Time-To-First-Token drops from seconds to roughly 120 milliseconds, and the model's attention stays locked on the transformation rule.&lt;/p&gt;

&lt;p&gt;Grammar-Constrained Decoding: Make Invalid Syntax Impossible&lt;/p&gt;

&lt;p&gt;Prompting a small model to "output strictly valid JSON" is asking it to use probability distributions to simulate a parser. Eventually, probability loses.&lt;/p&gt;

&lt;p&gt;Modern local inference engines (llama.cpp, MLX, Ollama, Outlines) solve this at the sampler level via grammar-constrained decoding, using GBNF grammars or compiled JSON Schemas. Instead of letting the model sample across its entire vocabulary (32,000 to 128,000 tokens) and hoping it picks a closing brace instead of a conversational sign-off, the runtime masks the logits at every single decoding step. Any token that would violate your schema is assigned a probability of −∞ before sampling occurs.&lt;/p&gt;

&lt;p&gt;Unconstrained sampling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Logits ─► Softmax ─► Sample ("Sure" / "```

json" / "{") ─► Hope parse() succeeds


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Grammar-constrained sampling:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
text
Logits ─► Apply Schema Mask (only "{" is legal at pos 0) ─► Softmax ─► Sample ("{")


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The model literally cannot emit a markdown fence, an unescaped quote, or an undeclared field. Syntax errors drop from ~20% to 0%. Here is what that schema looks like in practice for our narration operator:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "additionalProperties": false,
  "required": ["spoken_script", "estimated_seconds"],
  "properties": {
    "spoken_script": {
      "type": "string",
      "minLength": 10,
      "maxLength": 450
    },
    "estimated_seconds": {
      "type": "integer",
      "minimum": 3,
      "maximum": 45
    }
  }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Notice &lt;code&gt;additionalProperties: false&lt;/code&gt; and &lt;code&gt;maxLength: 450&lt;/code&gt;. Grammar constraints do not just enforce valid JSON; they enforce bounding invariants. Even if the model wants to ramble, the grammar forces it to close the string and emit the terminal &lt;code&gt;}&lt;/code&gt; well inside your &lt;code&gt;maxTokens&lt;/code&gt; budget.&lt;/p&gt;

&lt;p&gt;The Surgical Prompt Pattern: Constrain Semantics, Not Syntax&lt;/p&gt;

&lt;p&gt;Once grammar-constrained decoding owns the syntax, your prompt no longer needs bloated formatting warnings ("DO NOT include markdown backticks! NEVER explain your answer!"). You can spend 100% of your prompt tokens on semantic precision.&lt;/p&gt;

&lt;p&gt;For small models (7B/8B), zero-shot abstract instructions produce an inconsistent register. Two-shot examples paired with explicit negative constraints consistently outperform long paragraphs of prose instructions. Here is the production template for the &lt;code&gt;buildPrompt&lt;/code&gt; method in our &lt;code&gt;AiOperator&lt;/code&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
ts
function buildNarrationPrompt(slide: StructuredSlide): string {
  return `Convert structured slide bullets into spoken narration for a technical walkthrough.

Constraints:
- Speak directly to the listener; sound calm and concise.
- Normalize symbols and acronyms for text-to-speech (e.g., "-&amp;gt;" becomes "to", "100ms" becomes "100 milliseconds").
- Insert [pause] where a speaker naturally takes a breath.
- Never extrapolate beyond the provided bullets.

Example Input:
Title: Cache Invalidation
Bullets:
- TTL set to 300s
- Stale reads observed during deploy
- Switched to event-driven purge

Example Output:
{"spoken_script": "Let's look at cache invalidation. [pause] Previously, our time-to-live was set to 300 seconds, which caused stale reads during deployments. [pause] To fix this, we switched to an event-driven purge.", "estimated_seconds": 12}

Target Input:
Title: ${slide.title}
Bullets:
${slide.bullets.map(b =&amp;gt; `- ${b}`).join('\n')}

Target Output:`;
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Look closely at what this template achieves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Zero formatting overhead. The grammar engine guarantees the JSON structure; the few-shot example simply primes the token distribution for the exact field names and pacing.&lt;/li&gt;
&lt;li&gt;TTS-ready normalization. By demonstrating how TTL becomes time-to-live and where &lt;code&gt;[pause]&lt;/code&gt; lands, the 7B model handles domain-specific phonetic cleanup that regex rules struggle with — while downstream deterministic code splits on &lt;code&gt;[pause]&lt;/code&gt; to inject exact silence frames.&lt;/li&gt;
&lt;li&gt;Low temperature (0.15–0.25). You are not writing fiction. Low temperature keeps the model hugging the high-probability path demonstrated in your example.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Putting It Together: When Grammar Meets Fallback&lt;/p&gt;

&lt;p&gt;Even with 0% syntax errors, a local model can still fail semantically or hit a hardware wall — for instance, if a user triggers the pipeline while exporting a 4K video and the GPU stalls past &lt;code&gt;timeoutMs: 3000&lt;/code&gt;. Because syntax is guaranteed by the grammar layer and execution is bounded by the operator contract, your &lt;code&gt;parse()&lt;/code&gt; and &lt;code&gt;fallback()&lt;/code&gt; implementations stay trivial:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
ts
const NarrationOperator: AiOperator&amp;lt;StructuredSlide, NarrationResult&amp;gt; = {
  name: 'polish-speaker-notes',
  budget: { timeoutMs: 3000, maxTokens: 250 },
  buildPrompt: buildNarrationPrompt,

  parse(raw: string): Result&amp;lt;NarrationResult, ParseError&amp;gt; {
    // Syntax is guaranteed by GBNF/JSON Schema; check semantic invariants.
    const data = JSON.parse(raw) as NarrationResult;
    if (data.spoken_script.trim().length &amp;lt; 10) {
      return Err({ reason: 'empty_generation' });
    }
    return Ok(data);
  },

  fallback(slide: StructuredSlide): NarrationResult {
    // Deterministic rule: join raw bullets cleanly so downstream TTS never blocks.
    const joined = [slide.title, ...slide.bullets].join('. [pause] ');
    return {
      spoken_script: joined,
      estimated_seconds: Math.max(4, Math.ceil(joined.split(' ').length / 2.5)),
    };
  },
};


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Look at what happens in both outcomes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Happy path (96% of runs). In under 600 ms, the 7B model transforms terse technical bullets into natural, TTS-friendly prose wrapped in guaranteed-valid JSON.&lt;/li&gt;
&lt;li&gt;Degraded path (4% of runs). If the laptop is thermal-throttling or the model outputs an empty string, &lt;code&gt;fallback()&lt;/code&gt; deterministically stitches the slide title and bullets with &lt;code&gt;[pause]&lt;/code&gt; tokens in 0.01 ms. The downstream speech synthesizer and timeline aligner never know the difference.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Surgical Checklist&lt;/p&gt;

&lt;p&gt;Before shipping any local prompt in a desktop app, run it through four checks:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Did you slice the input? Never pass raw file formats or multi-page history into a leaf operator. Pass only the minimal typed struct.&lt;/li&gt;
&lt;li&gt;Is the grammar enforced at the sampler? If your code relies on regexes to strip ```

json blocks, you are patching a decoding problem at the wrong layer.&lt;/li&gt;
&lt;li&gt;Are bounds encoded in the schema? Set &lt;code&gt;maxLength&lt;/code&gt; and &lt;code&gt;additionalProperties: false&lt;/code&gt; so the model cannot exhaust your &lt;code&gt;maxTokens&lt;/code&gt; budget mid-field.&lt;/li&gt;
&lt;li&gt;Is the fallback good enough to ship? Your deterministic fallback is not an error message — it is a valid, degraded product output.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What's Next&lt;/p&gt;

&lt;p&gt;We now have a leaf operator that runs fast and never breaks its schema. That raises the next practical engineering question: how do you actually ship that runtime to users?&lt;/p&gt;

&lt;p&gt;Asking non-technical desktop users to install Python, configure CUDA, or run terminal commands is a non-starter. In Part 3 we will look at the packaging and runtime trade-offs — comparing external local daemons (like Ollama) against embedded inference engines (llama.cpp / MLX), and designing hardware detection that degrades gracefully on a five-year-old thin laptop.&lt;/p&gt;




&lt;p&gt;The author is a systems engineer building local-first desktop software. This series is Part 2 of 6, and this post was originally published on Medium — the canonical version and the rest of the series live there: &lt;a href="https://medium.com/@dqj1998/surgical-prompting-how-to-make-a-7b-local-model-never-break-your-schema-65b0a6d77e24" rel="noopener noreferrer"&gt;https://medium.com/@dqj1998/surgical-prompting-how-to-make-a-7b-local-model-never-break-your-schema-65b0a6d77e24&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>localllm</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>The Anti-Consensus: Why Your Local LLM Should Never Be the "Brain" of Your System</title>
      <dc:creator>dqj</dc:creator>
      <pubDate>Sat, 28 Nov 2026 02:41:06 +0000</pubDate>
      <link>https://dev.to/dqj1998/the-anti-consensus-why-your-local-llm-should-never-be-the-brain-of-your-system-k5p</link>
      <guid>https://dev.to/dqj1998/the-anti-consensus-why-your-local-llm-should-never-be-the-brain-of-your-system-k5p</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally published on Medium: &lt;a href="https://medium.com/@dqj1998/desktop-apps-keep-wiring-a-7b-model-into-every-control-path-115063626c2f" rel="noopener noreferrer"&gt;https://medium.com/@dqj1998/desktop-apps-keep-wiring-a-7b-model-into-every-control-path-115063626c2f&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Desktop apps keep wiring a 7B model into every control path. Here is the physics — and the 10% AI / 90% deterministic code architecture that survives production.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Every new desktop app pitch this year ships the same diagram: a small language model in the center, arrows fanning out to every feature — parsing, planning, formatting, error recovery — all routed through the same few billion parameters. It demos beautifully. It ships badly.&lt;/p&gt;

&lt;p&gt;This is the first article in a six-part series on &lt;strong&gt;10% AI, 90% deterministic code&lt;/strong&gt;: how to use on-device models hard, but held small. No product tour, no trend forecast — just the engineering constraints that force the architecture, and the architecture that survives contact with real users.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Ceiling Is Physics, Not Parameter Count
&lt;/h2&gt;

&lt;p&gt;The first thing to internalize: token throughput on the edge is a memory-bandwidth problem, not a model-quality problem.&lt;/p&gt;

&lt;p&gt;Every decoded token streams the active weights (plus the KV cache) from memory once. The back-of-envelope:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;theoretical tok/s ≈ memory bandwidth (GB/s) ÷ active weights (GB)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A 7B model at 4-bit quantization is roughly 4 GB of active weights. Back-of-envelope numbers, measured against hardware classes rather than lab queens:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Hardware class&lt;/th&gt;
&lt;th&gt;Bandwidth&lt;/th&gt;
&lt;th&gt;Theoretical&lt;/th&gt;
&lt;th&gt;Realistic sustained&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Thin laptop, shared LPDDR&lt;/td&gt;
&lt;td&gt;68–100 GB/s&lt;/td&gt;
&lt;td&gt;17–25 tok/s&lt;/td&gt;
&lt;td&gt;8–14 tok/s while the UI composites&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mid-tier unified memory&lt;/td&gt;
&lt;td&gt;200–400 GB/s&lt;/td&gt;
&lt;td&gt;50–100 tok/s&lt;/td&gt;
&lt;td&gt;30–60 tok/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12 GB discrete GPU&lt;/td&gt;
&lt;td&gt;270–500 GB/s&lt;/td&gt;
&lt;td&gt;65–125 tok/s&lt;/td&gt;
&lt;td&gt;45–90 tok/s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three multipliers turn those numbers into a wall:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Prefill is not free.&lt;/strong&gt; A 4k-token context can cost seconds of prompt processing on low-end silicon — before a single output token appears. Every tool call, every "here is the whole document" paste pays it again.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent loops multiply.&lt;/strong&gt; A five-step plan is five × (prefill + decode). A 15 tok/s model behind a four-step loop is a 12-second feature.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Thermals subtract.&lt;/strong&gt; Thin chassis downclock sustained decode within minutes. The number you benchmarked at minute one is not the number your user gets at minute five.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Meanwhile, direct manipulation UI has a hard budget: under ~100 ms feels instant, under ~1 s keeps flow, beyond that users reach for the window close button. &lt;strong&gt;A model call lives at 500 ms to 5 s.&lt;/strong&gt; That is not a gap you close with prompt engineering. It is a gap you design around: the model cannot sit inside the interaction loop, and it certainly cannot sit inside the control loop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deterministic Contracts: Draw the Boundary First
&lt;/h2&gt;

&lt;p&gt;The fix is not "use the model less." It is to decide, before writing code, which tasks carry a &lt;strong&gt;specification&lt;/strong&gt; — and give every spec-bearing task to deterministic code.&lt;/p&gt;

&lt;p&gt;Tasks that must be owned by code, because a spec exists and a machine can check compliance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;File format parsing&lt;/strong&gt; — a zip container is a zip container; XML either validates or it does not.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State machine transitions&lt;/strong&gt; — draft → rendering → exported is a graph with legal edges, not a vibe.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Timeline alignment&lt;/strong&gt; — frame counts, audio anchors, transition overlap are arithmetic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Container/muxing and streaming封装&lt;/strong&gt; — bitstreams have layouts; readers are unforgiving.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tasks where the model earns its 10%, because no spec exists and variance is acceptable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Semantic compression&lt;/strong&gt; — "what is this slide really about" has no ground truth format.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unstructured text polish&lt;/strong&gt; — dry bullets → spoken prose, where different-but-good is fine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Colloquial rewrite&lt;/strong&gt; — register and rhythm are exactly what a small model is good at.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The boundary as code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Spec-bearing stages stay deterministic: pure, testable.&lt;/span&gt;
&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;DeterministicStage&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;I&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;O&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&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="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;I&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Result&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;O&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SpecError&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// The model appears only as a leaf, with four mandatory fields.&lt;/span&gt;
&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;AiOperator&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;I&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;O&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&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="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;buildPrompt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;I&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// built by code&lt;/span&gt;
  &lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Result&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;O&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ParseError&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// schema-checked&lt;/span&gt;
  &lt;span class="nf"&gt;fallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;I&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;O&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;           &lt;span class="c1"&gt;// rules, not retries&lt;/span&gt;
  &lt;span class="n"&gt;budget&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;timeoutMs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;maxTokens&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// A pipeline is a graph; AI operators are leaves, never hubs.&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;Stage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;DeterministicStage&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;AiOperator&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the two non-negotiables: &lt;code&gt;parse&lt;/code&gt; (the model's output is untrusted input, validated like any other external payload) and &lt;code&gt;fallback&lt;/code&gt; (failure resolves to a deterministic result, never to a retry loop).&lt;/p&gt;

&lt;h2&gt;
  
  
  Two Architectures, One Deadline
&lt;/h2&gt;

&lt;p&gt;The alternative to a deterministic pipeline with AI leaves is the end-to-end agent: one model, one context window, all control flow. Both ship. Only one is maintainable:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Property&lt;/th&gt;
&lt;th&gt;End-to-end agent&lt;/th&gt;
&lt;th&gt;Deterministic pipeline + AI leaves&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Testability&lt;/td&gt;
&lt;td&gt;Prompt-dependent; tests flake with temperature&lt;/td&gt;
&lt;td&gt;90% of the graph has golden tests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fault isolation&lt;/td&gt;
&lt;td&gt;Any token can break any feature&lt;/td&gt;
&lt;td&gt;Failure confined to one leaf with a fallback&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Latency variance&lt;/td&gt;
&lt;td&gt;Seconds, effectively unbounded&lt;/td&gt;
&lt;td&gt;Bounded by per-leaf budgets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reproducibility&lt;/td&gt;
&lt;td&gt;Same input, different output&lt;/td&gt;
&lt;td&gt;Byte-identical except at AI leaves&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Debugging&lt;/td&gt;
&lt;td&gt;Re-read the transcript, guess&lt;/td&gt;
&lt;td&gt;Binary-search the graph&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Data flow through the pipeline looks like this — note that the model sits &lt;em&gt;beside&lt;/em&gt; the main path, not on it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 ┌──────────────────────────────────────────────┐
  .pptx file ──▶ │ parse container (deterministic)              │
                 │ build slide tree (deterministic)             │
                 │ extract text/tables/notes (deterministic)    │
                 └───────────────┬──────────────────────────────┘
                                 │ structured summary (typed)
                 ┌───────────────▼──────────────────────────────┐
                 │ local AI operator                            │
                 │  prompt built by code ──▶ model ──▶ schema   │
                 │  on timeout/error ──▶ deterministic fallback │
                 └───────────────┬──────────────────────────────┘
                                 │ polished notes (untrusted,
                                 │                schema-checked)
                 ┌───────────────▼──────────────────────────────┐
                 │ align timeline (arithmetic)                  │
                 │ render / encode (deterministic)              │
                 │ package output (deterministic)               │
                 └───────────────┬──────────────────────────────┘
                                 ▼
                          output artifact
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If any box on the main path fails, you get a reproducible bug report. If the AI leaf fails, you get the fallback output and a log line. Nothing upstream stops, nothing downstream corrupts state.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the 10/90 Split Looks Like in Config
&lt;/h2&gt;

&lt;p&gt;Boundaries enforced only by convention decay. Make the pipeline data, and the boundary becomes reviewable in a diff:&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="nl"&gt;"pipeline"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"document-pipeline"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"stages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deterministic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"parse-container"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deterministic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"build-structure"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ai"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"polish-speaker-notes"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"input"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"structured-slide-summary"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"constraints"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;"timeoutMs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;"maxTokens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;420&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;"temperature"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"onFailure"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"use-extracted-text"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deterministic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"align-timeline"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deterministic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"render-and-mux"&lt;/span&gt; &lt;span class="p"&gt;}&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;Three numbers do most of the work. &lt;code&gt;timeoutMs: 3000&lt;/code&gt; converts a hung model into a fallback. &lt;code&gt;maxTokens: 420&lt;/code&gt; caps worst-case decode time at that bandwidth math from the first section. &lt;code&gt;temperature: 0.2&lt;/code&gt; keeps retries from wandering. The deterministic stages carry no budgets at all — they either return or they throw a reproducible error.&lt;/p&gt;

&lt;h2&gt;
  
  
  Five Failure Modes of the All-Brain Design
&lt;/h2&gt;

&lt;p&gt;Teams that wire the model into every path meet the same five failures, in roughly this order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Retry storms.&lt;/strong&gt; Model output fails validation → retry → longer prompt → more prefill → more thermals. The failure mode is quadratic, and it hits exactly when the machine is already slow.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Heisenbugs.&lt;/strong&gt; Because control flow depends on sampled tokens, the same input can take different paths on different runs. "Works on my machine" becomes "works on my machine, sometimes."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flaky test suites.&lt;/strong&gt; Deterministic code gets regression tests; agent code gets… vibes checks. Coverage silently rots on the paths users hit most.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt drift across versions.&lt;/strong&gt; A model swap or a reworded system prompt changes behavior in every feature at once, with no call site to grep.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Spec leakage.&lt;/strong&gt; Eventually someone lets model output drive a state transition — "the model said the export finished" — and now a bitstream bug can rewrite your state machine.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;None of these are model-quality problems. Bigger models make them rarer, not absent. They are boundary problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 10/90 Checklist
&lt;/h2&gt;

&lt;p&gt;Before any task gets routed to the model, ask four questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Does a spec exist for it?&lt;/strong&gt; Yes → deterministic code. End of discussion.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Can code validate the output?&lt;/strong&gt; If you cannot write a schema, you cannot safely consume the result.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is there a deterministic fallback?&lt;/strong&gt; If failure means "ask the model again," you have built a retry loop, not an architecture.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is it inside the interaction path?&lt;/strong&gt; If the user is waiting on a drag, a click, or a keystroke, the answer is no.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The rule of thumb: &lt;strong&gt;the model gets ~10% of the code paths and 100% of the ambiguity.&lt;/strong&gt; It shines exactly where a spec is missing — and nowhere else.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;That was the philosophy. The next five articles get progressively more concrete: how to constrain a small model's output so the &lt;code&gt;parse&lt;/code&gt; step never fails (grammar-constrained decoding and context minimalism); how to package an inference runtime so it degrades gracefully on a five-year-old laptop; then three articles on a concrete target — reading real documents, synthesizing speech, and assembling the whole pipeline into a video — before the final piece shows the system it all adds up to.&lt;/p&gt;

&lt;p&gt;If you have shipped local-LLM features that regressed exactly this way, you already know why the boundary comes first.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;The author is a systems engineer building local-first desktop software. This series is Part 1 of 6.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>architecture</category>
    </item>
    <item>
      <title>The Trust Reset</title>
      <dc:creator>dqj</dc:creator>
      <pubDate>Tue, 24 Nov 2026 03:14:13 +0000</pubDate>
      <link>https://dev.to/dqj1998/the-trust-reset-46eg</link>
      <guid>https://dev.to/dqj1998/the-trust-reset-46eg</guid>
      <description>&lt;p&gt;For twenty years, the implicit contract of business software was simple. You rent capability, the vendor handles the plumbing, and everyone agrees not to look too closely at the plumbing. That contract is being renegotiated right now, and the reason is AI.&lt;/p&gt;

&lt;p&gt;Every SaaS product you already pay for is racing to add a model somewhere in the request path. Summarization, classification, retrieval, agentic actions that can read your documents and write to your systems. The features are genuinely useful. They also mean that a growing share of your company's data and decision-making now flows through code you cannot read, running on infrastructure you cannot see, changing on a schedule you do not control.&lt;/p&gt;

&lt;p&gt;That is the shift. Network services are entering an era where they can no longer be assumed trustworthy by default. Not because vendors are malicious, but because the attack surface has changed shape faster than the assurance mechanisms around it.&lt;/p&gt;

&lt;p&gt;This is not a prediction about a single breach. It is a structural argument about where compute should live, and what that means for anyone who builds or buys software.&lt;/p&gt;

&lt;p&gt;Why AI Features Broke the Old Assumptions&lt;/p&gt;

&lt;p&gt;Traditional SaaS had a reasonably well-understood security model. You authenticated, you got a scoped token, the vendor ran deterministic code, and the same input produced the same output. You could reason about what a service did. You could test it. You could read a SOC 2 report and form a rough opinion about the operational posture.&lt;/p&gt;

&lt;p&gt;AI features break several of those assumptions at once.&lt;/p&gt;

&lt;p&gt;First, the boundary of data flow moves. A prompt assembled from your records, your documents, and your internal context leaves your perimeter and lands in a third party's inference pipeline. Whether that data is logged, retained, used for training, or replicated across regions is often described in a policy document rather than enforced by an architecture you can verify.&lt;/p&gt;

&lt;p&gt;Second, the behavior is non-deterministic. The same request can produce different outputs, and more importantly, the same request can produce different classes of behavior when the model behind an endpoint is swapped. Silent model upgrades are now routine. A vendor ships a better model on Tuesday and your carefully validated workflow behaves differently on Wednesday, with no changelog entry that maps to the difference you observed.&lt;/p&gt;

&lt;p&gt;Third, and most consequentially, AI features are being given agency. An assistant that can call tools, read a database, send email, or open a pull request is an assistant that can be manipulated into doing so. Prompt injection is not a bug that gets patched once. It is an entire class of vulnerability that arises from the fundamental design of language models: instructions and data arrive through the same channel, and the model has no reliable way to tell them apart. Any system that puts untrusted text in front of a model with privileges is exposed, and the mitigations available today reduce risk rather than eliminate it.&lt;/p&gt;

&lt;p&gt;Fourth, the supply chain got deeper. A modern AI feature may involve a foundation model provider, a hosting provider, an orchestration framework, a vector database, a set of plugins, and an SDK that pulls in a few hundred transitive dependencies. Each link is a potential point of compromise, and the composite system is far harder to audit than any individual piece.&lt;/p&gt;

&lt;p&gt;None of this means AI in SaaS is unusable. It means the trust model has to change. You can no longer extend blanket trust to a network service because it has a logo and a compliance certificate. You have to assume that some fraction of your external dependencies will fail, be compromised, or quietly change behavior, and design accordingly.&lt;/p&gt;

&lt;p&gt;What "Untrusted by Default" Actually Costs You&lt;/p&gt;

&lt;p&gt;The practical consequence of untrusted network services is not that you stop using them. It is that the blast radius of every external dependency becomes a first-order design concern.&lt;/p&gt;

&lt;p&gt;Consider what a compromised or misbehaving AI endpoint can reach in a typical integration. It sees the prompt, which means it sees whatever context your application stuffed into it. It may hold long-lived credentials for downstream systems. It may write into a ticketing system, a CRM, or a code repository. It may be the thing that decides whether a transaction looks fraudulent or a contract clause looks risky.&lt;/p&gt;

&lt;p&gt;When that endpoint is a black box over the network, your options for containment are limited to the controls you built around it: scoped credentials, egress filtering, output validation, human review. Those controls are necessary, and most teams underinvest in them, but they are fundamentally compensating controls. They manage the risk of an architecture you did not choose.&lt;/p&gt;

&lt;p&gt;There is a different option, and it is becoming practical again: own the compute that runs the model.&lt;/p&gt;

&lt;p&gt;The Case for Local, Hardware-Backed IT and AI&lt;/p&gt;

&lt;p&gt;Running inference on hardware you control is not a new idea. It was the default before cloud economics made renting irresistible. What is new is that the capability gap between a frontier API and a model you can run yourself has narrowed enough that the trade-off has flipped for a meaningful set of workloads.&lt;/p&gt;

&lt;p&gt;When the model runs on a box in your rack, or on a workstation under a desk, several things change at once.&lt;/p&gt;

&lt;p&gt;Data residency becomes an architectural fact rather than a contractual promise. Prompts, documents, embeddings, and outputs do not leave your network. There is no retention policy to interpret because there is no third party retaining anything.&lt;/p&gt;

&lt;p&gt;Versioning becomes deterministic. You deploy a specific model artifact with a known hash, and it stays that model until you deliberately change it. No silent upgrades. No behavior drift introduced by someone else's release schedule. For regulated workflows and for any system where reproducibility matters, this is not a nice-to-have.&lt;/p&gt;

&lt;p&gt;Availability decouples from the network. A local inference node keeps working when the WAN is down, when a provider has an outage, when an API rate limit kicks in at the worst possible moment, or when a vendor changes terms and pulls a feature you built on.&lt;/p&gt;

&lt;p&gt;Auditability improves. You can inspect what the model is, log every request and response at the point of execution, and reason about the full path from input to output without a vendor's cooperation.&lt;/p&gt;

&lt;p&gt;And the security posture simplifies in a way that is easy to underestimate. A local appliance has a small, enumerable attack surface that you own end to end. It does not have a multi-tenant blast radius. It does not expose your prompts to a shared inference pool. It fails in ways you can observe.&lt;/p&gt;

&lt;p&gt;The objection for the last several years was capability. Local models were not good enough for real work. That objection is now much weaker.&lt;/p&gt;

&lt;p&gt;Open Models Crossed the Threshold&lt;/p&gt;

&lt;p&gt;The open-weight ecosystem has moved from "impressive for a demo" to "good enough for production" across a wide band of tasks. The drivers are cumulative rather than a single breakthrough.&lt;/p&gt;

&lt;p&gt;Open-weight model families now cover the full range from small, fast models that fit on a single consumer GPU or a laptop accelerator up to large models that run on a modest multi-GPU node. The quality of the mid-tier has improved dramatically, and the mid-tier is where most enterprise work actually lives: classification, extraction, summarization, retrieval-augmented question answering, structured output generation, code assistance, and tool calling.&lt;/p&gt;

&lt;p&gt;Quantization and efficient inference runtimes have compressed hardware requirements without the catastrophic quality loss that used to make this a compromise. Techniques that were research curiosities two years ago are now default deployment options.&lt;/p&gt;

&lt;p&gt;Fine-tuning and adapter training have become accessible. A team with a few thousand labeled examples and a single machine can specialize a mid-sized open model to outperform a much larger general model on a narrow task. That is often the right answer anyway: a smaller model tuned for your domain, running locally, with predictable cost and no data egress.&lt;/p&gt;

&lt;p&gt;The tooling matured. Serving frameworks, structured output enforcement, evaluation harnesses, and observability layers for local inference are now mature enough that a competent platform team can operate them without a research lab.&lt;/p&gt;

&lt;p&gt;Put together, the calculus is straightforward. For a large and growing set of workloads, you can get comparable quality, better privacy, deterministic behavior, and lower marginal cost by running open models on hardware you own.&lt;/p&gt;

&lt;p&gt;What a Hardware-First Stack Looks Like&lt;/p&gt;

&lt;p&gt;Going local does not mean replacing your entire cloud footprint with a server closet. It means tiering your workloads by sensitivity and criticality, and moving the ones that matter most onto infrastructure you control.&lt;/p&gt;

&lt;p&gt;A practical architecture has a few recognizable components.&lt;/p&gt;

&lt;p&gt;A local inference node, sized to your workload, running an open-weight model artifact you have pinned and versioned. Treat the model like any other deployable: hash it, sign it, track it in a registry, and roll it out deliberately.&lt;/p&gt;

&lt;p&gt;A gateway layer in front of it that handles authentication, rate limiting, prompt logging, and output validation. This is where you enforce policy, and it is the piece most teams skip when they move fast.&lt;/p&gt;

&lt;p&gt;An evaluation harness that runs a fixed suite of representative tasks against every model change before it reaches users. If you cannot measure a regression, you will ship one.&lt;/p&gt;

&lt;p&gt;A retrieval layer with your data staying inside the perimeter, so the model's context never has to leave to be useful.&lt;/p&gt;

&lt;p&gt;A fallback path. Local does not mean infallible. Plan for the node to be unavailable and degrade gracefully rather than failing open.&lt;/p&gt;

&lt;p&gt;And a security model for the box itself. A local appliance is not automatically secure. It needs patching, network segmentation, least-privilege credentials for any tools it can call, and monitoring. The advantage is that all of this is within your control rather than a clause in someone else's contract.&lt;/p&gt;

&lt;p&gt;The Honest Trade-offs&lt;/p&gt;

&lt;p&gt;This argument is not that on-premise AI is free of downsides. It is not.&lt;/p&gt;

&lt;p&gt;Capital expenditure replaces operating expenditure. You buy capacity up front and carry depreciation instead of a monthly bill that scales with usage. For steady, predictable workloads this is often cheaper. For spiky ones it is not.&lt;/p&gt;

&lt;p&gt;You take on operational burden. Someone has to manage the hardware, the drivers, the runtimes, the model updates, and the monitoring. This is real work, and pretending otherwise is how these projects fail.&lt;/p&gt;

&lt;p&gt;There is a capability gap at the very top. The largest frontier models still do things that open models do not do as well. If your workload genuinely requires that last increment of reasoning quality, you will keep using an external API for it. That is fine. The point is to make that a deliberate, scoped decision rather than a default for everything.&lt;/p&gt;

&lt;p&gt;And the threat model shifts rather than disappears. You still have supply chain risk in model weights and Python packages. You still have insiders. You still have to secure the endpoint. Owning the hardware removes one class of dependency; it does not remove all of them.&lt;/p&gt;

&lt;p&gt;Where to Start&lt;/p&gt;

&lt;p&gt;Do not start with a mandate to move everything. Start with an inventory.&lt;/p&gt;

&lt;p&gt;List the places where AI touches your most sensitive data or your most consequential decisions. Rank them by what a compromise or a silent behavior change would cost you. Then look at the top of that list and ask a simple question: does this workload actually need a frontier model, or does it need a good enough model that never leaves the building?&lt;/p&gt;

&lt;p&gt;In most organizations, a surprising number of items fall into the second bucket. Document processing. Internal search. Code review assistance. Log triage. Contract clause extraction. Ticket routing. These are tasks where a tuned open model running locally is competitive, and where the privacy and determinism benefits are worth more than the marginal quality difference.&lt;/p&gt;

&lt;p&gt;Move those first. Build the operational muscle on workloads where a mistake is recoverable. Establish the evaluation harness, the model registry, and the gateway while the stakes are low, so that when you move the sensitive workloads you already know how to run them.&lt;/p&gt;

&lt;p&gt;The Strategic Point&lt;/p&gt;

&lt;p&gt;The uncomfortable truth about the current moment is that AI has made network services less trustworthy at exactly the time when dependence on them has increased. That is a bad combination, and it will not resolve itself through better vendor promises.&lt;/p&gt;

&lt;p&gt;The organizations that come out ahead will be the ones that treat external AI as a convenience, not a foundation. They will keep the sensitive, the regulated, and the critical on hardware they control, running models they have pinned and tested, behind gateways they can inspect. They will use the frontier APIs for what frontier APIs are uniquely good at, and they will be able to turn them off without turning off the business.&lt;/p&gt;

&lt;p&gt;Hardware is back in the conversation for a reason. The models got good enough, the runtimes got efficient enough, and the trust model for network services got bad enough that owning the compute is no longer nostalgia. It is a security posture.&lt;/p&gt;

&lt;p&gt;The question is not whether you can afford to run AI locally. For a growing share of your workload, the better question is whether you can afford not to.&lt;/p&gt;

&lt;p&gt;Read the full story: &lt;a href="https://medium.com/p/84ebf34d22e1" rel="noopener noreferrer"&gt;https://medium.com/p/84ebf34d22e1&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>architecture</category>
      <category>automation</category>
    </item>
    <item>
      <title>The Maturity Ladder: Four Levels from Assisted to Integrated</title>
      <dc:creator>dqj</dc:creator>
      <pubDate>Mon, 23 Nov 2026 13:18:31 +0000</pubDate>
      <link>https://dev.to/dqj1998/the-maturity-ladder-four-levels-from-assisted-to-integrated-1fb0</link>
      <guid>https://dev.to/dqj1998/the-maturity-ladder-four-levels-from-assisted-to-integrated-1fb0</guid>
      <description>&lt;p&gt;&lt;em&gt;Parts 1 to 3 rebuilt the unit, the roles, and the clock. This part answers the only question a large enterprise actually asks: where do we start, and what breaks if we start in the wrong place.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Parts 1 through 3 made a case. A case is not a migration plan.&lt;/p&gt;

&lt;p&gt;We argued that the bottleneck moved from code production to contextual judgment; that the atom of delivery should become one engineer surrounded by three roles with specific prohibitions; and that a sixty-minute pipeline should run inside an eight-to-twelve-week PI rather than against it. Every one of those claims is structural. None of them tells a company with a hundred engineers on a release train how to get from here to there without losing a quarter.&lt;/p&gt;

&lt;p&gt;That omission matters, because the first honest response to the ANTcell argument from anyone running SAFe at scale is not "is this right?" It is "can I turn the train around while it is moving?" The answer is no, and the whitepaper is explicit: do not overturn the Agile Release Train in a single move. The PI is the mechanism that synchronizes dozens of teams around shared milestones, forces dependencies into the open, and gives a business a cadence it can plan against. Remove it before you have something to put underneath and you have not made the organization fast. You have made it directionless.&lt;/p&gt;

&lt;p&gt;This part is about sequencing. The four levels below are not a menu of options and not a maturity badge for a slide deck. They are a dependency order: each level is the prerequisite for the one above it. The useful property of a dependency order is that skipping a level fails in a predictable way. You can name the failure before you see it. That is what makes the ladder worth writing down.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four levels, not four programs
&lt;/h2&gt;

&lt;p&gt;The whitepaper proposes four stages from Ad Hoc to Integrated. Read them as a sequence of interfaces becoming machine-checkable, not as a sequence of tools being installed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Level 1 — Ad Hoc.&lt;/strong&gt; The organization looks familiar: traditional Scrum teams, engineers using Copilot or ChatGPT on their own initiative. The engineering action is unglamorous and non-negotiable — introduce a single enterprise private LLM access gateway, and establish a code-security and compliance audit baseline. What this buys is not speed. It is visibility. Before Level 1, model use is shadow infrastructure: you cannot audit what you cannot see, and you cannot govern code whose provenance is a browser tab. Every later level runs on this gateway. An organization that skips it is building on a tool nobody owns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Level 2 — Assisted.&lt;/strong&gt; The standard two-week sprint stays. AI becomes explicit in the places where generation is cheap and checkable: requirement decomposition and unit tests. Two engineering actions define this level — build an internal RAG context library over the organization's own code and documents, and stand up a preliminary sandbox for automated verification. The sprint is not the enemy here; abolishing it before the context layer exists would only remove the coordination humans still need. What changes is the supply of context. Organizational knowledge stops being a rumor carried by senior engineers and becomes something a system can retrieve. Concede the obvious limitation: if you measure this level by story points and lines of code, you have reinstated the velocity hallucination from Part 1 with better tooling. The measure that matters is whether the sandbox catches what synthesis gets wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Level 3 — Explicit Roles.&lt;/strong&gt; Now the topology actually changes. Inside the train, core functional modules are piloted as single-person units, and the three roles from Part 2 are formally decoupled. The engineering actions match the organizational ones: appoint a dedicated Supporter and AI Helper, and replace the user-story tree as the delivery standard with Schema-based contracts. This is the hardest level to do honestly, because it is the easiest to fake. You can grant the titles in an afternoon. What cannot be granted in an afternoon is the platform that makes contracts checkable, and the prohibitions that stop the Supervisor from reaching into decomposition and the Supporter from becoming the engineer's evaluator. Without those, Level 3 is three new managers where there was one. The test, carried over from Part 2, is whether the prohibitions survive contact with a deadline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Level 4 — Integrated.&lt;/strong&gt; The end state is an ecosystem, not an org chart: a platform capability base, a swarm of ANTcell micro-units, and the PI as the macro timebox. The engineering action is to achieve full automated telemetry of the sixty-minute pipeline — and to redirect the IP iteration toward upgrading the global rule set and the platform itself. Notice what the outer clock is doing here. It has stopped coordinating individual work and started maintaining the substrate. That is the mature form of the two-speed architecture from Part 3: the PI keeps buying alignment, while the cells keep buying proof, and the platform is what both stand on. Sixty minutes is now a measured loop, not an aspiration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why skipping a level fails predictably
&lt;/h2&gt;

&lt;p&gt;The value of the ladder is not the destination. It is the diagnosis.&lt;/p&gt;

&lt;p&gt;Skip Level 1 and go straight to a RAG context library, and you have built retrieval over unaudited code, queried through models nobody approved. The characteristic failure is a security or compliance incident, not slowness — it arrives without warning precisely because the governance baseline was the thing you omitted.&lt;/p&gt;

&lt;p&gt;Skip Level 2 and appoint roles directly, and the Supporter degenerates into a human search engine because there is no context layer to consult. The AI Helper coaches a practice with no sandbox to calibrate against. The engineer receives authority without a verification substrate — which is the failure Part 2 already named: not a cell, an under-supported person. It fails as understaffing always does, with the names changed.&lt;/p&gt;

&lt;p&gt;Skip Level 3 and buy the sixty-minute pipeline first, and you get the failure Part 3 warned about in different words: an organization writing contracts faster than it understands its own system, automating its misunderstandings at machine speed. The diffs arrive quickly, in volume, and no one can certify them, because the independent judge was never given a boundary to judge against.&lt;/p&gt;

&lt;p&gt;In each case the failure is not a surprise. It is the signature of the missing prerequisite. That is why sequencing beats heroics here. An organization can survive an ambitious plan executed in the right order; it cannot survive the correct end state installed in the wrong one.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the ladder is actually measuring
&lt;/h2&gt;

&lt;p&gt;It is tempting to read the four levels as a tooling checklist — gateway, RAG, roles, pipeline. That is the surface. Underneath, three things are moving at once.&lt;/p&gt;

&lt;p&gt;The first is the governance of the model: from invisible personal use, to a sanctioned gateway, to a sandbox with deterministic checks, to a rule set that accumulates automatically. The second is the substrate of coordination: from people talking to people, to people retrieving from a shared context, to systems verifying a Schema contract, to telemetry that needs no meeting at all. The third is the unit of accountability: from a five-to-eleven-person team, to an AI-assisted team, to an engineered cell with one accountable engineer, to a swarm of such cells inside a PI envelope.&lt;/p&gt;

&lt;p&gt;Read together, these are one movement described three ways. Each level converts one more interface from a social agreement into an assertion. The contract from Part 3 is the hinge: it is the point where "team A will wait for team B" becomes "this change fails to compile unless the schema holds." The ladder counts how many of those conversions the organization has actually made.&lt;/p&gt;

&lt;p&gt;Narrow the claim, because this is where maturity models usually become propaganda. The ladder is a pattern, not a stage gate. Organizations do not move as a single body. A train can run a Level 3 cell inside a Level 2 portfolio, and a gateway can exist while half the company still works at Ad Hoc. Use the ladder as a per-workstream diagnostic — look at what is breaking and infer the level you are really at — not as a badge for the org chart. The moment it becomes a badge, people will claim Level 4 and keep Level 1 behavior.&lt;/p&gt;

&lt;h2&gt;
  
  
  The carriage and the motor
&lt;/h2&gt;

&lt;p&gt;The whitepaper closes where the series began, with the original purpose of agile: self-organization and fast feedback as an answer to bureaucracy and uncertainty. Somewhere in the last decade, scaled agile became, in many organizations, a heavy machine for coordinating people. The AI-Native era is not an argument for a more powerful motor on that carriage. It is an argument for rethinking the vehicle.&lt;/p&gt;

&lt;p&gt;But here is the concession that has to sit beside that sentence. You do not get to redesign the vehicle while it is carrying a hundred people at speed. The ladder is how you pull over, change the chassis, and keep moving. The PI buys order and stability for business alignment; the cell buys the fast release of individual engineering creativity. Neither replaces the other. What the conclusion proposes is their fusion, stated as a mechanism with three parts: individual judgment as the fulcrum, decoupled support as the guardrails, and the two-speed loop as the rhythm.&lt;/p&gt;

&lt;p&gt;That is a forecast about the next decade, and forecasts are not facts. The actionable part is the mechanism. You can tell tomorrow whether judgment sits with the engineer, whether the three roles are structurally prevented from taking it back, and whether the fast loop is producing durable rules. You cannot tell whether a decade agrees with you.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this closes
&lt;/h2&gt;

&lt;p&gt;The four parts now form one argument. Part 1 moved the bottleneck and showed why a topology priced by headcount cannot absorb a resource priced at zero. Part 2 rebuilt the unit on the new bottleneck: one engineer, three roles, three prohibitions. Part 3 rebuilt the clock around it: the PI for direction, the sixty-minute pipeline for proof, the contract as the seam. Part 4 puts them in order.&lt;/p&gt;

&lt;p&gt;The order is the part enterprises will use: govern the model, supply the context, decouple the roles, then automate the clock. The fast clock is the last thing you get, not the first. Organizations that buy the sixty-minute pipeline before they have contracts to compile are not accelerating; they are generating work in progress, which is exactly where Part 1 began.&lt;/p&gt;

&lt;p&gt;So start at the level your governance is actually at, not the level your ambitions are at. Move a module, not the train. Let the rule set accumulate before you scale it. Then, when the platform can verify what it produces, let the swarm in.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;The ladder is a dependency order, not a menu: Ad Hoc, Assisted, Explicit Roles, Integrated — govern the model, supply the context, decouple the roles, automate the clock. Skip a rung and the failure is characteristic rather than random, which means you can diagnose where you really stand by looking at what is breaking.&lt;/p&gt;

&lt;p&gt;Fuse the two systems instead of choosing between them. Keep the PI for alignment. Put authority where the judgment sits, surround it with roles that cannot take it back, and let a contract carry intent down to a loop that proves it in an hour.&lt;/p&gt;

&lt;p&gt;A bigger motor will not save the carriage. But neither will a new chassis installed at full speed. The ladder is the sequence that lets you change the vehicle and keep moving — which is the whole argument, from the bottleneck to the maturity ladder.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part 4 of 4 in AI-Native, Deconstructed: From SAFe Incrementalism to the ANTcell Rewrite.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Read the full story: &lt;a href="https://medium.com/p/af9a3fdd2b62" rel="noopener noreferrer"&gt;https://medium.com/p/af9a3fdd2b62&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>architecture</category>
      <category>automation</category>
    </item>
    <item>
      <title>Two Clocks: A 12-Week PI Around a 60-Minute Pipeline</title>
      <dc:creator>dqj</dc:creator>
      <pubDate>Sun, 22 Nov 2026 14:31:20 +0000</pubDate>
      <link>https://dev.to/dqj1998/two-clocks-a-12-week-pi-around-a-60-minute-pipeline-40hf</link>
      <guid>https://dev.to/dqj1998/two-clocks-a-12-week-pi-around-a-60-minute-pipeline-40hf</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 2 ended with a unit of delivery that can produce three candidate implementations in an hour. This part is about the organization that plans in quarters — and why the two are not in conflict.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Part 1 diagnosed a specific failure: the individual end generates fast, the organization integrates slowly, and work in progress piles up at the seam. The diagnosis named the seam but did not redesign it. Part 2 rebuilt the unit on one side of that seam — one engineer, three surrounding roles, authority where the judgment sits. This part rebuilds the other side: the clock the organization runs on.&lt;/p&gt;

&lt;p&gt;The instinct after reading Parts 1 and 2 is to conclude that the twelve-week PI is the problem. A cell that can synthesize, test, and decide in an hour makes a quarterly planning cycle look like bureaucratic dead weight. That conclusion is tempting and wrong. It confuses two questions that were never the same question, and it would delete the one mechanism that keeps a hundred fast cells pointed in a common direction.&lt;/p&gt;

&lt;p&gt;The PI and the sixty-minute pipeline are two clocks. They run at different rates because they answer different questions. The mistake is not having both. The mistake is asking either to do the other's job.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two questions, two clocks
&lt;/h2&gt;

&lt;p&gt;The outer clock asks: &lt;em&gt;are we building the right thing?&lt;/em&gt; It runs on eight-to-twelve-week Program Increments. It is the ART's timebox for portfolio alignment, business milestone validation, and enterprise-level integration. Its unit is a train of many teams moving together.&lt;/p&gt;

&lt;p&gt;The inner clock asks: &lt;em&gt;are we building it right, and can we prove it?&lt;/em&gt; It runs on a roughly sixty-minute loop inside a single cell. Its unit is one engineer with a platform and a contract.&lt;/p&gt;

&lt;p&gt;These are not a slow version and a fast version of the same activity. They are different activities. The outer clock chooses direction and allocates intent. The inner clock produces and verifies a bounded change. A system needs both. An organization that runs only the inner clock gets fast, well-built things that no one wanted. An organization that runs only the outer clock gets the review queue Part 1 described — correct priorities, nothing shipped.&lt;/p&gt;

&lt;p&gt;The pathologies of the last decade come from making one clock answer both questions. SAFe put fine-grained task coordination inside the PI, and the PI, built for alignment, buckled under coordination. The cell puts direction-setting inside the sprint, and the sprint, built for execution, buckled under ambition. The two-speed architecture is the admission that a clock is a control mechanism tuned to one timescale, and a control mechanism tuned to two timescales controls neither.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the twelve-week clock is actually buying
&lt;/h2&gt;

&lt;p&gt;Concede this before touching it: the PI is not ceremony for its own sake. For a large enterprise it is the only mechanism that synchronizes dozens of teams around shared milestones, forces dependencies into the open, and creates a stable cadence that a business can plan against. Its eight-to-twelve weeks are not slowness. They are the granularity at which portfolio decisions are actually reversible — you cannot re-point a hundred teams weekly without producing the churn that "agile at scale" was supposed to eliminate.&lt;/p&gt;

&lt;p&gt;The error is asking that clock to manage &lt;em&gt;throughput&lt;/em&gt;. The PI was never good at it, and attaching AI to it did not make it better. When a model makes synthesis nearly free, asking a quarterly planning event to coordinate individual implementation steps is like routing each heartbeat through a calendar app. The result is the velocity hallucination: story points inflate locally, the ART board fills with red dependency lines, and nothing crosses the integration gate faster.&lt;/p&gt;

&lt;p&gt;Narrow the claim. The PI should keep its eight-to-twelve weeks, its alignment, and its milestones. What it gives up is the fine-grained coordination it was never structured to perform. Once the inner clock absorbs execution, the outer clock can go back to being an alignment instrument — which is what it was good at all along.&lt;/p&gt;

&lt;h2&gt;
  
  
  The inner clock: four stages in one hour
&lt;/h2&gt;

&lt;p&gt;The micro-pipeline is the replacement for the two-week iteration inside the team. It is not a compressed sprint; a sprint compressed to an hour is still a sprint, with the same ceremonies scaled down to the point of absurdity. It is a different loop with four stages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Contract compilation.&lt;/strong&gt; Before synthesis begins, the input and output schema and the irreversible constraints are made explicit. This is where the Supervisor's boundary from Part 2 becomes machine-readable. The contract is not documentation; it is the thing that will be checked. A change that cannot be stated as a contract is not a candidate for the micro-pipeline — it is still a judgment call for the outer clock.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parallel synthesis.&lt;/strong&gt; The platform explores several implementation paths and their test suites concurrently. This is the capability that made the bottleneck move in the first place, now pointed at a bounded problem. Where a team once serialized one approach through a sprint, a cell tries three within the hour. The engineer's job is not to write the candidate but to hold the space in which candidates are generated and be ready to decide between them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Independent judge.&lt;/strong&gt; A sandbox, deterministic tests, and the engineer's contextual judgment jointly decide whether the change is real. The word that matters is &lt;em&gt;independent&lt;/em&gt;: the judge is structurally separate from the generator. Part 2 argued the engineer cannot be left alone with a model that lies fluently. The same logic applies here — if the system that proposes a change also certifies it, you have not built a gate, you have built a rubber stamp.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Durable rules.&lt;/strong&gt; Every failure and every fix is precipitated into a system-level rule: a test, a schema constraint, an automated check. This is the AI Helper's work made concrete, and it is the stage that compounds. The pipeline is not merely fast; it is ratcheted. The class of error that cost an hour this week becomes impossible next week. Run it for a quarter and the loop does not just repeat — it gets harder to fail.&lt;/p&gt;

&lt;p&gt;Sixty minutes is not a productivity target. It is a feedback boundary: the maximum latency between an intent becoming a contract and a verified change existing. Tune it, but do not worship it. A loop that takes ninety minutes and produces a durable rule is worth more than a sixty-minute loop that produces an unreviewable diff.&lt;/p&gt;

&lt;h2&gt;
  
  
  The red line that breaks PI planning
&lt;/h2&gt;

&lt;p&gt;The most fragile artifact in a traditional PI Planning event is the dependency red line on the ART planning board. It marks a place where one team must wait for another — a handshake across an organizational boundary, scheduled by humans, renegotiated when either side slips. These lines are fragile because they encode waiting as a social agreement, and social agreements are the first thing to fail under load.&lt;/p&gt;

&lt;p&gt;ANTcell does not abolish the underlying coupling. Coupling is real; two systems that share a schema must agree. What it changes is the &lt;em&gt;substrate&lt;/em&gt; of the agreement. The AI Capability Platform supplies standardized model APIs, agent sandboxes, and a retrieval layer over the organization's own context. Architects push API contracts downward. A dependency that used to be a cross-team meeting becomes a contract check that runs when a change is compiled.&lt;/p&gt;

&lt;p&gt;The red lines do not vanish; they become assertions. This is the concrete answer to the coordination problem Part 1 left open. Cross-team waiting is replaced by platform verification, and verification is cheap in a way that human scheduling never is. A contract violation is found in a minute by a system that never sleeps, rather than in a sync meeting two weeks later.&lt;/p&gt;

&lt;p&gt;Concede the dependency: this only works with the platform from Part 2 underneath it. Without standardized contracts and a real context layer, you have not degraded waiting into verification — you have merely moved the waiting to a place with no owner. The platform is not an accessory to the two-speed architecture. It is the material the inner clock is cut from.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the clocks nest instead of collide
&lt;/h2&gt;

&lt;p&gt;The two clocks are not competing for the same time. They are nested: the sixty-minute loop runs continuously inside the twelve-week envelope, like a heartbeat inside a season.&lt;/p&gt;

&lt;p&gt;The seam between them is the contract. The outer clock sets intent, boundaries, and milestones; the inner clock explores within those boundaries and returns verified change. The Supervisor owns the "what" at the outer timescale; the engineer owns the "how" at the inner one. Neither has to attend the other's meetings. The contract carries the intent down, and the verified result carries evidence back up.&lt;/p&gt;

&lt;p&gt;This is why the architecture is stable. Each clock is allowed to be good at one thing. The PI does not need to know which of three candidates won an hour; it needs to know that the increment's milestones were met. The cell does not need to attend portfolio sync; it needs a boundary clear enough to compile against. When the interface between them is a schema instead of a status meeting, both clocks run at their natural rate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the fast clock must stop
&lt;/h2&gt;

&lt;p&gt;The claim is narrower than "the PI is obsolete."&lt;/p&gt;

&lt;p&gt;The sixty-minute loop is for work that is bounded and contractible. Decisions that are irreversible, cross-organizational, physical, or regulatory still belong to the outer clock — you cannot compile your way out of a compliance review or a hardware recall. The inner clock accelerates execution inside a direction; it does not choose the direction, and a cell that quietly starts choosing direction has become a very fast local optimizer pointed wherever it likes.&lt;/p&gt;

&lt;p&gt;Two failure modes follow. Run the inner clock without the outer and you ship well-built irrelevance at speed. Keep the outer clock's ceremonies inside the inner one — the daily standup, the two-week estimation poker Part 1 called out — and you have a sixty-minute pipeline interrupted every fifteen minutes by a meeting designed for a nine-person team. The architecture fails from either side: too little alignment or too much ceremony.&lt;/p&gt;

&lt;p&gt;And the outer clock's red lines exist for a reason. Some coupling is genuine, and collapsing it into an assertion only works if the assertion is correct. An organization that writes contracts faster than it understands its own system will automate its misunderstandings at machine speed. The durable-rule stage is what catches this over time — but only if the rules are allowed to accumulate, which means only if the platform and the roles from Part 2 are actually in place.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this sets up
&lt;/h2&gt;

&lt;p&gt;None of this can be installed by reorganizing the calendar. A two-speed architecture needs a platform mature enough to verify contracts, roles mature enough to hold boundaries without reaching inside them, and engineers mature enough to exercise judgment when the platform hands them three candidates. That sequencing is the subject of Part 4: the four-level path from Ad Hoc to Integrated, and why skipping a level fails in a predictable way rather than a surprising one.&lt;/p&gt;

&lt;p&gt;The short version is that the fast clock is the last thing you get, not the first. Organizations that buy the sixty-minute pipeline before they have the contracts to compile are not accelerating. They are generating WIP — which is where this series began.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;The twelve-week PI and the sixty-minute pipeline are not a conflict to be resolved. They are a control system with two timescales: one that decides whether the work is worth doing, one that decides whether it was done right. The first belongs to the ART; the second belongs to the cell; the contract between them is the seam that lets each run at its own rate.&lt;/p&gt;

&lt;p&gt;Do not ask the PI to manage throughput. Do not ask the cell to choose direction. Replace cross-team waiting with platform verification, precipitate every failure into a rule, and let the outer clock keep the order it was always good at buying.&lt;/p&gt;

&lt;p&gt;One slow clock for direction. One fast clock for proof. A contract between them. That is the two-speed architecture — and it works precisely because neither clock is asked to be the other.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part 3 of 4 in AI-Native, Deconstructed: From SAFe Incrementalism to the ANTcell Rewrite.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>architecture</category>
      <category>automation</category>
    </item>
    <item>
      <title>The Cell, Not the Team: Three Roles That Make One Engineer Accountable</title>
      <dc:creator>dqj</dc:creator>
      <pubDate>Sat, 21 Nov 2026 14:08:54 +0000</pubDate>
      <link>https://dev.to/dqj1998/the-cell-not-the-team-three-roles-that-make-one-engineer-accountable-jkf</link>
      <guid>https://dev.to/dqj1998/the-cell-not-the-team-three-roles-that-make-one-engineer-accountable-jkf</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 1 ended with a unit of delivery the size of one person. This is the part where that person stops being a heroic exception and becomes a safe default.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Part 1 argued that the atomic unit of delivery has moved. When synthesis becomes nearly free, the scarce input is no longer the person-hour that writes the change but the judgment that decides whether it should exist. A structure whose every interface is priced by headcount cannot absorb a resource priced at zero, so the bottleneck moved downstream into verification and the org chart stayed where it was.&lt;/p&gt;

&lt;p&gt;That leaves an uncomfortable question, and it is not a motivational one. If the unit of delivery is now a single engineer carrying end-to-end responsibility, what has to be true for that to be &lt;em&gt;safe&lt;/em&gt;? Not faster. Safe. Because a lone engineer with a model and a repository is not a smaller team; it is a different object with different failure modes, and you cannot make it safe by asking it to be brave.&lt;/p&gt;

&lt;p&gt;This part answers that question. The answer is three roles around a cell, and the property that makes them work is not their job descriptions. It is what each one is structurally forbidden from doing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The axiom rewrite
&lt;/h2&gt;

&lt;p&gt;ANTcell — AI-Native Team Cell — starts from a different first principle than the incrementalists. It does not ask how to make a five-to-eleven-person team more productive with AI. It asks what the team was &lt;em&gt;for&lt;/em&gt;, and whether the reason still holds.&lt;/p&gt;

&lt;p&gt;The team was the atom because one engineer could not hold frontend craft, a distributed backend, quality engineering, and operations in the same head. Under an AI Capability Platform — standardized model APIs, agent sandboxes, and a retrieval layer over the organization's own context — that constraint softens. The platform can supply conventions, failure history, and candidate implementations on demand. The engineer's job shifts from &lt;em&gt;producing&lt;/em&gt; the change to &lt;em&gt;deciding&lt;/em&gt; among changes the platform makes cheap to produce.&lt;/p&gt;

&lt;p&gt;So the unit of delivery becomes one engineer with the authority to decide. Not a hero engineer selected for exceptional breadth — that would just be the old constraint with better recruiting. An ordinary engineer, made sufficient by a platform and made safe by a structure around them.&lt;/p&gt;

&lt;p&gt;This is the part skeptics usually stop at. One person, end to end, with real authority. That sounds like an accountability improvement until you remember why accountability was diluted in the first place: a single person cannot hold business intent, the whole technical context, &lt;em&gt;and&lt;/em&gt; the discipline of working with a model that confidently hallucinates. Give one person all three and you have not created a cell. You have created a bottleneck with a name badge.&lt;/p&gt;

&lt;p&gt;The three roles exist to solve that. They do not assist the engineer by taking work off their desk. They surround the engineer with the three things no individual can supply to themselves — and, critically, each is barred from becoming the thing the engineer is accountable for.&lt;/p&gt;

&lt;h2&gt;
  
  
  Unbundling what "team" was doing
&lt;/h2&gt;

&lt;p&gt;Part 1 separated three jobs that the word "team" had fused: the unit of delivery, the unit of accountability, and the unit of coordination. AI attacks the first, demands the second shrink, and turns the third into a platform problem. The three roles are the organizational answer to that separation.&lt;/p&gt;

&lt;p&gt;Each role maps to one thing the engineer cannot provide for themselves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What the change must mean&lt;/strong&gt; — intent, semantic boundary, acceptance gate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What the surrounding system will accept&lt;/strong&gt; — global technical context, governance constraints, organizational memory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How to work with a model that is wrong with confidence&lt;/strong&gt; — pairing, context engineering, hallucination control, and the conversion of every failure into a rule.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The mistake to avoid is treating these as advisors. Advisors can be ignored, and an ignored advisor is accountability theater. These roles are &lt;em&gt;owners&lt;/em&gt;: each holds one boundary that the engineer cannot cross alone, and none can cross into the engineer's decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  Supervisor: the intent and the boundary
&lt;/h2&gt;

&lt;p&gt;The Supervisor owns business intent, the semantic boundary of the work, and the acceptance gate. In return for owning "what," the Supervisor gives up "how." They do not decompose the work into micro-tasks and they do not choose the technical approach.&lt;/p&gt;

&lt;p&gt;That prohibition is the whole design. In SAFe, the Product Manager and Product Owner functions have drifted toward managing the backlog at fine granularity — a queue of small, pre-digested items that the team pulls and executes. That made sense when the expensive act was producing the item and the scarce resource was the team's capacity to pull it. Once production is cheap, fine-grained decomposition becomes the bottleneck: you are paying a human to pre-chew work that a platform can explore three ways in an hour, and you are stripping the engineer of exactly the judgment you claimed the new unit was for.&lt;/p&gt;

&lt;p&gt;The Supervisor sets the boundary and then is structurally unable to reach inside it. Acceptance is a gate, not a stream of instructions. If the Supervisor finds themselves specifying &lt;em&gt;how&lt;/em&gt; the work gets done, the cell has reverted to a capacity queue with a faster generator attached — which is the failure Part 1 already described.&lt;/p&gt;

&lt;h2&gt;
  
  
  Supporter: the living dictionary, not the manager
&lt;/h2&gt;

&lt;p&gt;The Supporter is the interface between the engineer and the complexity of the organization. They hold the global technical context, the governance constraints, and the accumulated memory of why the system is shaped the way it is. The whitepaper's metaphor is a &lt;em&gt;living dictionary&lt;/em&gt;: when the engineer needs to know which unwritten rule a change will violate, the Supporter is where that answer lives.&lt;/p&gt;

&lt;p&gt;The structural constraint here is sharper than in the other two roles. The Supporter must not be the engineer's performance supervisor. Coaching and evaluation are decoupled by design.&lt;/p&gt;

&lt;p&gt;This is not a soft, cultural preference. It is an information-flow requirement. If the person who holds the technical context also writes your review, then asking "why is this service shaped this way?" is no longer a neutral query — it is an admission on a performance record. The engineer will stop asking, the platform will be fed incomplete context, and the whole advantage of a context-rich cell evaporates. You cannot get the benefit of a living dictionary from a person the engineer has learned not to consult.&lt;/p&gt;

&lt;p&gt;SAFe's Team Lead or Architect often carries both technical guidance and administrative reporting. That concentration was tolerable when the lead was coordinating eleven people and the engineer's judgment was a small part of throughput. It is not tolerable when the engineer's judgment is &lt;em&gt;the&lt;/em&gt; throughput. The same role that was a convenience becomes a tax on the only scarce input in the system.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI Helper: the discipline, not the ceremony
&lt;/h2&gt;

&lt;p&gt;The third role is the one with no clean SAFe ancestor. The AI Helper owns the human-AI practice itself: pairing with the engineer, tuning context and prompts, controlling hallucination, and — the part that compounds — converting each incident into a deterministic rule so the same failure cannot recur.&lt;/p&gt;

&lt;p&gt;The closest SAFe role is the Scrum Master or Agile Coach, and the comparison is instructive. That role facilitates process in the abstract: ceremonies, retros, flow. It was designed for a world where the main risk was poor coordination between people. The AI Helper is designed for a world where the main risk is a confident, plausible, wrong artifact entering the codebase, and where the fix for today's hallucination should become tomorrow's automated check.&lt;/p&gt;

&lt;p&gt;Where the Scrum Master asks "is the process healthy?", the AI Helper asks "which failures have we made impossible to repeat?" The output of the role is not a smoother meeting. It is a growing set of durable rules — a test, a schema constraint, a gate — that permanently removes a class of error. This is the engineering of the new bottleneck, not facilitation of the old one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the separation is the mechanism
&lt;/h2&gt;

&lt;p&gt;At this point it is tempting to read the three roles as a renaming exercise: call the PO a Supervisor, call the Architect a Supporter, call the Coach an AI Helper, and declare the transformation complete. That would produce exactly the structure Part 1 criticizes — the same container with new labels.&lt;/p&gt;

&lt;p&gt;What makes it more than relabeling is that each role is defined by a &lt;em&gt;prohibition&lt;/em&gt; as much as a duty:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Supervisor cannot decompose the work.&lt;/li&gt;
&lt;li&gt;The Supporter cannot evaluate the engineer.&lt;/li&gt;
&lt;li&gt;The AI Helper cannot own the delivery decision.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remove the prohibitions and you have not decentralized anything. You have three managers where there was one. Keep them and you have a structure where the engineer holds authority, the three surrounding roles hold the three things no single person should hold alone, and none of them can quietly take the decision back.&lt;/p&gt;

&lt;p&gt;This is what the whitepaper calls cognitive protection. It is not protection from hard work. It is protection from the specific ways a judging mind gets corrupted: being told what to think, being afraid to ask, or being left alone with a tool that lies fluently. Each role neutralizes one of those. Together they make the cell a safe default instead of a heroic exception.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the old roles were buying
&lt;/h2&gt;

&lt;p&gt;A critique that concedes nothing is not worth reading. The PM, the Architect, and the Coach exist for real reasons: someone must own intent, someone must hold the system's memory, someone must coach the practice. None of those functions is imaginary, and an organization that simply deletes them will rediscover them within a quarter under different names.&lt;/p&gt;

&lt;p&gt;ANTcell does not delete them. It re-slices them along the boundary that now matters — intent versus context versus practice — and it separates evaluation from enablement, which the old structure fused. That is a genuine change in the topology of authority, not a vocabulary change.&lt;/p&gt;

&lt;p&gt;But it is also easy to fake. Adopt the three titles, keep the reporting lines, leave the Supervisor decomposing work into tickets and the Supporter writing reviews, and you have changed the org chart's labels while preserving its behavior. The test is not what the roles are called. It is whether the three prohibitions survive contact with a deadline.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this does not work
&lt;/h2&gt;

&lt;p&gt;The claim is narrower than "teams are obsolete."&lt;/p&gt;

&lt;p&gt;A cell needs a platform underneath it: a standardized model API, an agent sandbox, and a retrieval layer over the organization's real context. Without that substrate, the single engineer is not made sufficient — they are simply under-supported, and the arrangement fails as understaffing always does. It also needs an engineer who can actually exercise judgment; the model does not supply that, and no amount of tooling converts an engineer who needs pre-digested tasks into one who owns a boundary.&lt;/p&gt;

&lt;p&gt;And it does not abolish what a team buys beyond delivery: fault isolation, on-call redundancy, a hiring surface, psychological safety for junior engineers, the informal learning of two people looking at one problem. Part 1 conceded all of that and still holds it. The re-slicing touches the three jobs the old team fused; it does not claim to replace every reason humans work near each other.&lt;/p&gt;

&lt;p&gt;Finally, this is not a reorganization you execute in a quarter. The platform prerequisites and the role separation have to mature together, and organizations that jump to the labels without the substrate get the worst of both structures. That sequencing is the subject of Part 4.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why one engineer can hold what nine dilute
&lt;/h2&gt;

&lt;p&gt;Accountability dilutes with size. A team of nine that owns an outcome owns it collectively, which at 3 a.m. means no single person owns the decision to ship or roll back. Adding a model to that team increases the supply of candidate decisions without changing who is permitted to make one — the exact configuration that produces a review queue.&lt;/p&gt;

&lt;p&gt;A cell reverses this. The engineer has the authority to decide because the three surrounding roles have taken the three things they could not safely hold alone, and the platform has made the verification cheap enough that one person can actually check the decision. The span of what one person can personally validate has expanded; the structure is what lets them use it.&lt;/p&gt;

&lt;p&gt;That is the argument in one sentence: the cell is not a smaller team, it is a team whose three non-delivery functions have been pulled out and given their own owners, so that the remaining person can be accountable for something real.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this sets up
&lt;/h2&gt;

&lt;p&gt;None of this works on a stopwatch unless the clock is designed. A cell that can produce three candidates an hour still sits inside an organization that plans in eight-to-twelve-week increments. Part 3 is about that mismatch — why the twelve-week PI and the sixty-minute pipeline are not in conflict but are two halves of one control system, and how standardized contracts replace cross-team waiting with platform verification.&lt;/p&gt;

&lt;p&gt;Part 4 is the part enterprises will actually use: the four-level maturity path from Assisted to Integrated, and why skipping a level fails in a predictable way rather than an unpredictable one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;The single engineer is not a staffing optimization. It is the consequence of taking the cost structure from Part 1 seriously: when synthesis is nearly free and judgment is scarce, you put authority where the judgment is, and you build a structure around that person that supplies what they cannot supply themselves and forbids anyone from taking the decision back.&lt;/p&gt;

&lt;p&gt;Three roles. Three prohibitions. One engineer who can be held accountable for something a team of nine only owns in the abstract. That is the cell, and it is why the unit is not the team.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part 2 of 4 in AI-Native, Deconstructed: From SAFe Incrementalism to the ANTcell Rewrite.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>architecture</category>
      <category>automation</category>
    </item>
    <item>
      <title>The Cell, Not the Team: Three Roles That Make One Engineer Accountable</title>
      <dc:creator>dqj</dc:creator>
      <pubDate>Sat, 21 Nov 2026 14:03:45 +0000</pubDate>
      <link>https://dev.to/dqj1998/the-cell-not-the-team-three-roles-that-make-one-engineer-accountable-3hkg</link>
      <guid>https://dev.to/dqj1998/the-cell-not-the-team-three-roles-that-make-one-engineer-accountable-3hkg</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 1 ended with a unit of delivery the size of one person. This is the part where that person stops being a heroic exception and becomes a safe default.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Part 1 argued that the atomic unit of delivery has moved. When synthesis becomes nearly free, the scarce input is no longer the person-hour that writes the change but the judgment that decides whether it should exist. A structure whose every interface is priced by headcount cannot absorb a resource priced at zero, so the bottleneck moved downstream into verification and the org chart stayed where it was.&lt;/p&gt;

&lt;p&gt;That leaves an uncomfortable question, and it is not a motivational one. If the unit of delivery is now a single engineer carrying end-to-end responsibility, what has to be true for that to be &lt;em&gt;safe&lt;/em&gt;? Not faster. Safe. Because a lone engineer with a model and a repository is not a smaller team; it is a different object with different failure modes, and you cannot make it safe by asking it to be brave.&lt;/p&gt;

&lt;p&gt;This part answers that question. The answer is three roles around a cell, and the property that makes them work is not their job descriptions. It is what each one is structurally forbidden from doing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The axiom rewrite
&lt;/h2&gt;

&lt;p&gt;ANTcell — AI-Native Team Cell — starts from a different first principle than the incrementalists. It does not ask how to make a five-to-eleven-person team more productive with AI. It asks what the team was &lt;em&gt;for&lt;/em&gt;, and whether the reason still holds.&lt;/p&gt;

&lt;p&gt;The team was the atom because one engineer could not hold frontend craft, a distributed backend, quality engineering, and operations in the same head. Under an AI Capability Platform — standardized model APIs, agent sandboxes, and a retrieval layer over the organization's own context — that constraint softens. The platform can supply conventions, failure history, and candidate implementations on demand. The engineer's job shifts from &lt;em&gt;producing&lt;/em&gt; the change to &lt;em&gt;deciding&lt;/em&gt; among changes the platform makes cheap to produce.&lt;/p&gt;

&lt;p&gt;So the unit of delivery becomes one engineer with the authority to decide. Not a hero engineer selected for exceptional breadth — that would just be the old constraint with better recruiting. An ordinary engineer, made sufficient by a platform and made safe by a structure around them.&lt;/p&gt;

&lt;p&gt;This is the part skeptics usually stop at. One person, end to end, with real authority. That sounds like an accountability improvement until you remember why accountability was diluted in the first place: a single person cannot hold business intent, the whole technical context, &lt;em&gt;and&lt;/em&gt; the discipline of working with a model that confidently hallucinates. Give one person all three and you have not created a cell. You have created a bottleneck with a name badge.&lt;/p&gt;

&lt;p&gt;The three roles exist to solve that. They do not assist the engineer by taking work off their desk. They surround the engineer with the three things no individual can supply to themselves — and, critically, each is barred from becoming the thing the engineer is accountable for.&lt;/p&gt;

&lt;h2&gt;
  
  
  Unbundling what "team" was doing
&lt;/h2&gt;

&lt;p&gt;Part 1 separated three jobs that the word "team" had fused: the unit of delivery, the unit of accountability, and the unit of coordination. AI attacks the first, demands the second shrink, and turns the third into a platform problem. The three roles are the organizational answer to that separation.&lt;/p&gt;

&lt;p&gt;Each role maps to one thing the engineer cannot provide for themselves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What the change must mean&lt;/strong&gt; — intent, semantic boundary, acceptance gate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What the surrounding system will accept&lt;/strong&gt; — global technical context, governance constraints, organizational memory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How to work with a model that is wrong with confidence&lt;/strong&gt; — pairing, context engineering, hallucination control, and the conversion of every failure into a rule.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The mistake to avoid is treating these as advisors. Advisors can be ignored, and an ignored advisor is accountability theater. These roles are &lt;em&gt;owners&lt;/em&gt;: each holds one boundary that the engineer cannot cross alone, and none can cross into the engineer's decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  Supervisor: the intent and the boundary
&lt;/h2&gt;

&lt;p&gt;The Supervisor owns business intent, the semantic boundary of the work, and the acceptance gate. In return for owning "what," the Supervisor gives up "how." They do not decompose the work into micro-tasks and they do not choose the technical approach.&lt;/p&gt;

&lt;p&gt;That prohibition is the whole design. In SAFe, the Product Manager and Product Owner functions have drifted toward managing the backlog at fine granularity — a queue of small, pre-digested items that the team pulls and executes. That made sense when the expensive act was producing the item and the scarce resource was the team's capacity to pull it. Once production is cheap, fine-grained decomposition becomes the bottleneck: you are paying a human to pre-chew work that a platform can explore three ways in an hour, and you are stripping the engineer of exactly the judgment you claimed the new unit was for.&lt;/p&gt;

&lt;p&gt;The Supervisor sets the boundary and then is structurally unable to reach inside it. Acceptance is a gate, not a stream of instructions. If the Supervisor finds themselves specifying &lt;em&gt;how&lt;/em&gt; the work gets done, the cell has reverted to a capacity queue with a faster generator attached — which is the failure Part 1 already described.&lt;/p&gt;

&lt;h2&gt;
  
  
  Supporter: the living dictionary, not the manager
&lt;/h2&gt;

&lt;p&gt;The Supporter is the interface between the engineer and the complexity of the organization. They hold the global technical context, the governance constraints, and the accumulated memory of why the system is shaped the way it is. The whitepaper's metaphor is a &lt;em&gt;living dictionary&lt;/em&gt;: when the engineer needs to know which unwritten rule a change will violate, the Supporter is where that answer lives.&lt;/p&gt;

&lt;p&gt;The structural constraint here is sharper than in the other two roles. The Supporter must not be the engineer's performance supervisor. Coaching and evaluation are decoupled by design.&lt;/p&gt;

&lt;p&gt;This is not a soft, cultural preference. It is an information-flow requirement. If the person who holds the technical context also writes your review, then asking "why is this service shaped this way?" is no longer a neutral query — it is an admission on a performance record. The engineer will stop asking, the platform will be fed incomplete context, and the whole advantage of a context-rich cell evaporates. You cannot get the benefit of a living dictionary from a person the engineer has learned not to consult.&lt;/p&gt;

&lt;p&gt;SAFe's Team Lead or Architect often carries both technical guidance and administrative reporting. That concentration was tolerable when the lead was coordinating eleven people and the engineer's judgment was a small part of throughput. It is not tolerable when the engineer's judgment is &lt;em&gt;the&lt;/em&gt; throughput. The same role that was a convenience becomes a tax on the only scarce input in the system.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI Helper: the discipline, not the ceremony
&lt;/h2&gt;

&lt;p&gt;The third role is the one with no clean SAFe ancestor. The AI Helper owns the human-AI practice itself: pairing with the engineer, tuning context and prompts, controlling hallucination, and — the part that compounds — converting each incident into a deterministic rule so the same failure cannot recur.&lt;/p&gt;

&lt;p&gt;The closest SAFe role is the Scrum Master or Agile Coach, and the comparison is instructive. That role facilitates process in the abstract: ceremonies, retros, flow. It was designed for a world where the main risk was poor coordination between people. The AI Helper is designed for a world where the main risk is a confident, plausible, wrong artifact entering the codebase, and where the fix for today's hallucination should become tomorrow's automated check.&lt;/p&gt;

&lt;p&gt;Where the Scrum Master asks "is the process healthy?", the AI Helper asks "which failures have we made impossible to repeat?" The output of the role is not a smoother meeting. It is a growing set of durable rules — a test, a schema constraint, a gate — that permanently removes a class of error. This is the engineering of the new bottleneck, not facilitation of the old one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the separation is the mechanism
&lt;/h2&gt;

&lt;p&gt;At this point it is tempting to read the three roles as a renaming exercise: call the PO a Supervisor, call the Architect a Supporter, call the Coach an AI Helper, and declare the transformation complete. That would produce exactly the structure Part 1 criticizes — the same container with new labels.&lt;/p&gt;

&lt;p&gt;What makes it more than relabeling is that each role is defined by a &lt;em&gt;prohibition&lt;/em&gt; as much as a duty:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Supervisor cannot decompose the work.&lt;/li&gt;
&lt;li&gt;The Supporter cannot evaluate the engineer.&lt;/li&gt;
&lt;li&gt;The AI Helper cannot own the delivery decision.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remove the prohibitions and you have not decentralized anything. You have three managers where there was one. Keep them and you have a structure where the engineer holds authority, the three surrounding roles hold the three things no single person should hold alone, and none of them can quietly take the decision back.&lt;/p&gt;

&lt;p&gt;This is what the whitepaper calls cognitive protection. It is not protection from hard work. It is protection from the specific ways a judging mind gets corrupted: being told what to think, being afraid to ask, or being left alone with a tool that lies fluently. Each role neutralizes one of those. Together they make the cell a safe default instead of a heroic exception.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the old roles were buying
&lt;/h2&gt;

&lt;p&gt;A critique that concedes nothing is not worth reading. The PM, the Architect, and the Coach exist for real reasons: someone must own intent, someone must hold the system's memory, someone must coach the practice. None of those functions is imaginary, and an organization that simply deletes them will rediscover them within a quarter under different names.&lt;/p&gt;

&lt;p&gt;ANTcell does not delete them. It re-slices them along the boundary that now matters — intent versus context versus practice — and it separates evaluation from enablement, which the old structure fused. That is a genuine change in the topology of authority, not a vocabulary change.&lt;/p&gt;

&lt;p&gt;But it is also easy to fake. Adopt the three titles, keep the reporting lines, leave the Supervisor decomposing work into tickets and the Supporter writing reviews, and you have changed the org chart's labels while preserving its behavior. The test is not what the roles are called. It is whether the three prohibitions survive contact with a deadline.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this does not work
&lt;/h2&gt;

&lt;p&gt;The claim is narrower than "teams are obsolete."&lt;/p&gt;

&lt;p&gt;A cell needs a platform underneath it: a standardized model API, an agent sandbox, and a retrieval layer over the organization's real context. Without that substrate, the single engineer is not made sufficient — they are simply under-supported, and the arrangement fails as understaffing always does. It also needs an engineer who can actually exercise judgment; the model does not supply that, and no amount of tooling converts an engineer who needs pre-digested tasks into one who owns a boundary.&lt;/p&gt;

&lt;p&gt;And it does not abolish what a team buys beyond delivery: fault isolation, on-call redundancy, a hiring surface, psychological safety for junior engineers, the informal learning of two people looking at one problem. Part 1 conceded all of that and still holds it. The re-slicing touches the three jobs the old team fused; it does not claim to replace every reason humans work near each other.&lt;/p&gt;

&lt;p&gt;Finally, this is not a reorganization you execute in a quarter. The platform prerequisites and the role separation have to mature together, and organizations that jump to the labels without the substrate get the worst of both structures. That sequencing is the subject of Part 4.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why one engineer can hold what nine dilute
&lt;/h2&gt;

&lt;p&gt;Accountability dilutes with size. A team of nine that owns an outcome owns it collectively, which at 3 a.m. means no single person owns the decision to ship or roll back. Adding a model to that team increases the supply of candidate decisions without changing who is permitted to make one — the exact configuration that produces a review queue.&lt;/p&gt;

&lt;p&gt;A cell reverses this. The engineer has the authority to decide because the three surrounding roles have taken the three things they could not safely hold alone, and the platform has made the verification cheap enough that one person can actually check the decision. The span of what one person can personally validate has expanded; the structure is what lets them use it.&lt;/p&gt;

&lt;p&gt;That is the argument in one sentence: the cell is not a smaller team, it is a team whose three non-delivery functions have been pulled out and given their own owners, so that the remaining person can be accountable for something real.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this sets up
&lt;/h2&gt;

&lt;p&gt;None of this works on a stopwatch unless the clock is designed. A cell that can produce three candidates an hour still sits inside an organization that plans in eight-to-twelve-week increments. Part 3 is about that mismatch — why the twelve-week PI and the sixty-minute pipeline are not in conflict but are two halves of one control system, and how standardized contracts replace cross-team waiting with platform verification.&lt;/p&gt;

&lt;p&gt;Part 4 is the part enterprises will actually use: the four-level maturity path from Assisted to Integrated, and why skipping a level fails in a predictable way rather than an unpredictable one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;The single engineer is not a staffing optimization. It is the consequence of taking the cost structure from Part 1 seriously: when synthesis is nearly free and judgment is scarce, you put authority where the judgment is, and you build a structure around that person that supplies what they cannot supply themselves and forbids anyone from taking the decision back.&lt;/p&gt;

&lt;p&gt;Three roles. Three prohibitions. One engineer who can be held accountable for something a team of nine only owns in the abstract. That is the cell, and it is why the unit is not the team.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part 2 of 4 in AI-Native, Deconstructed: From SAFe Incrementalism to the ANTcell Rewrite.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>architecture</category>
      <category>automation</category>
    </item>
    <item>
      <title>Tuning Search You Can Trust: Offline Replay, Ablation, and Cross-Validation for a Browser Extension</title>
      <dc:creator>dqj</dc:creator>
      <pubDate>Mon, 16 Nov 2026 15:24:17 +0000</pubDate>
      <link>https://dev.to/dqj1998/tuning-search-you-can-trust-offline-replay-ablation-and-cross-validation-for-a-browser-extension-3o8o</link>
      <guid>https://dev.to/dqj1998/tuning-search-you-can-trust-offline-replay-ablation-and-cross-validation-for-a-browser-extension-3o8o</guid>
      <description>&lt;p&gt;&lt;em&gt;How SpotRecall measures every ranking change on real browsing data — with an offline replay that produces exactly the ranking the extension ships.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;The previous three posts described what changed in SpotRecall 1.3.1's search: a steeper rank-fusion curve, script-based language detection for Han-only queries, and a set of small precision signals. This post is about how those changes were chosen — and why I trust the numbers.&lt;/p&gt;

&lt;p&gt;SpotRecall is a private, on-device browser recall extension. That creates an unusual evaluation problem. The two most important inputs to its ranking — Chrome's on-device Translator and the extension's own vector store — exist only inside a running browser. You cannot import them into a unit test. Yet tuning a ranking means trying many variations, and a full browser round-trip per variation is far too slow.&lt;/p&gt;

&lt;p&gt;The solution was to split evaluation into two steps: capture once in the real browser, then replay offline as many times as needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step one: capture in real Chrome
&lt;/h2&gt;

&lt;p&gt;A capture script drives the built extension in real Chrome, using &lt;code&gt;puppeteer-core&lt;/code&gt; and a dedicated profile kept inside the eval folder. It:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;imports a SpotRecall backup (here, 1,088 records of my own browsing history);&lt;/li&gt;
&lt;li&gt;waits for the embedding model and downloads the translation models (Chrome only downloads them after a user gesture, which the script simulates with a click);&lt;/li&gt;
&lt;li&gt;for every labeled query, records the translation in &lt;strong&gt;every&lt;/strong&gt; English/Japanese/Chinese direction, the vector-search results for every resulting text, and the live ranking the extension actually shows.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Recording every direction, not only the ones production uses, is deliberate. It lets the offline step evaluate &lt;em&gt;other&lt;/em&gt; language-detection strategies without another browser run. The script translates from Chinese and from Japanese even when production would pick only one, so the replay can compare "pick one" against "translate from both."&lt;/p&gt;

&lt;h2&gt;
  
  
  Step two: replay offline with production code
&lt;/h2&gt;

&lt;p&gt;The replay runs in Node, in seconds. Crucially, it does not reimplement the ranking. It imports the same modules the extension ships: language detection, the BM25 index, fusion, record priors, and deduplication.&lt;/p&gt;

&lt;p&gt;That required one architectural choice early on: every piece of ranking logic is a &lt;strong&gt;pure function&lt;/strong&gt; with its parameters passed in, and the extension's service worker only does the I/O around it. The fusion parameters live in one object that both the extension and the eval import.&lt;/p&gt;

&lt;p&gt;With that in place, the replay supports several modes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run eval:fusion -- --backup …                        # production vs baseline, per tag
npm run eval:fusion -- --backup … --ablation             # each improvement alone and stacked
npm run eval:fusion -- --backup … --cv                   # 2-fold: tune on half, test on the other
npm run eval:fusion -- --backup … --grid                 # parameter sweep
npm run eval:fusion -- --backup … --bookmarked-backfill  # worst case for title-only records
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Parity as a design goal
&lt;/h2&gt;

&lt;p&gt;An offline replay is only useful if it reproduces the real thing. So the replay reports parity: for each query, does the offline top ten match the live top ten captured from the browser? The target is &lt;code&gt;top-10 identical: n/n&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Reaching it took two details worth sharing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fresh service-worker code on every run.&lt;/strong&gt; A reused Chrome profile keeps a cached copy of the extension's previous service-worker script. Extension pages load the new build, but the background worker can keep running the old one. The capture script now clears the profile's service-worker cache before each launch. The records live in IndexedDB and are untouched; the extension simply registers its worker again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Identical tokens in Node and Chrome.&lt;/strong&gt; SpotRecall tokenizes text with &lt;code&gt;Intl.Segmenter&lt;/code&gt;, which handles Japanese and Chinese word boundaries. But Node and Chrome ship different ICU builds, and they segment punctuation inside words differently — &lt;code&gt;Amazon.co.jp&lt;/code&gt; is one segment in one engine and three in the other. 1.3.1 re-splits every word-like segment on punctuation and symbols, so both engines produce exactly the same tokens.&lt;/p&gt;

&lt;p&gt;That second fix pays off beyond evaluation. The extension stores a snapshot of its keyword index, and with ICU-independent tokens that snapshot stays consistent across Chrome updates. Because the token format changed, the release bumps the snapshot key and clears the old snapshot automatically to reclaim its space.&lt;/p&gt;

&lt;p&gt;With both in place, every number in this series was measured on a replay that matches the live extension query for query.&lt;/p&gt;

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

&lt;p&gt;A few dozen labeled queries is a realistic budget for a personal project. It is also small enough to overfit easily. Each query in the set carries a tag: &lt;code&gt;xling&lt;/code&gt; (cross-lingual), &lt;code&gt;same&lt;/code&gt; (same language), &lt;code&gt;kanji&lt;/code&gt; (Han-only Japanese), or &lt;code&gt;bookmark&lt;/code&gt; (title-only targets). A change was accepted only if it held up on three checks at once:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;per tag&lt;/strong&gt;, so a gain on one kind of query does not hide a loss on another;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;in the worst case&lt;/strong&gt;, a simulation where every backfilled bookmark also receives the bookmark boost, as it would in a bookmark-heavy profile;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;under 2-fold cross-validation&lt;/strong&gt;: tune on half of the queries, measure on the other half, then swap.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The third check made the most visible difference. The grid search's best parameters scored well on the queries they were tuned on. On held-out queries, they did not beat the shipped values. So the shipped values are the ones that generalized, not the ones that topped the grid.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ablation: each improvement, stacked
&lt;/h2&gt;

&lt;p&gt;Measured on 54 mixed Chinese, Japanese, and English queries, every number live-identical:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Baseline&lt;/strong&gt; (k=3, translations ×0.7, trimmed vector lists): MRR 0.803, Hit@1 38, Hit@10 53, worst-case MRR 0.770.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;+ Han character hints, ambiguous Han translated from both zh and ja:&lt;/strong&gt; MRR 0.809, Hit@1 38, Hit@10 54, worst case 0.787.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;+ title-only records ×0.5 unless they match every term of a variant:&lt;/strong&gt; MRR &lt;strong&gt;0.828&lt;/strong&gt;, Hit@1 39, Hit@10 54, worst case &lt;strong&gt;0.826&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The average gains are steady rather than dramatic. The worst-case column shows the larger effect: the configuration most exposed to title-only noise improved the most.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ideas that did not meet the bar
&lt;/h2&gt;

&lt;p&gt;The rule is only meaningful if it sometimes says no. Two promising ideas were tested and set aside:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Dropping the keyword lists of low-coverage translations.&lt;/strong&gt; It helped Han-only Japanese queries, made cross-lingual ones worse, and was unstable across the two folds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A recency prior.&lt;/strong&gt; Favoring recently visited pages sounds natural for a recall tool, but it pushed down old bookmarks that users keep precisely because they matter.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both remain easy to revisit. The harness makes trying them again a single command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Working with an AI pair
&lt;/h2&gt;

&lt;p&gt;As with the rest of this series, the work was done with an AI pair. In this release, that meant the capture script, the replay, and the ablation and cross-validation modes could be built and rerun quickly — a full parameter sweep takes seconds.&lt;/p&gt;

&lt;p&gt;Speed is the easy part. What makes it trustworthy is a fixed acceptance rule and a parity check that does not depend on anyone's judgment in the moment. When a cheap iteration loop proposes a better-looking number, the rule decides whether it ships.&lt;/p&gt;

&lt;h2&gt;
  
  
  Privacy, by construction
&lt;/h2&gt;

&lt;p&gt;The labels for this evaluation describe my own browsing, so they are treated like the data they are. The labeled-query file and all backups are git-ignored and never enter the repository. The repository contains only an example labels file that shows the format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[{ "query": "…", "match": ["url:&amp;lt;regex&amp;gt;", "title:&amp;lt;regex&amp;gt;"], "tag": "xling" }]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Anyone can run the same loop on their own SpotRecall backup, locally.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scope and limits
&lt;/h2&gt;

&lt;p&gt;Fifty-four queries on one person's 1,088-page history is a methodology demonstration, not a benchmark. The trends are what matter: which changes hold up across query types, in the worst case, and on held-out queries.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;When part of your system only runs in a browser, capture its outputs once and replay everything else with production code. Make the replay prove parity with the live system. Then tune against a rule that includes held-out data — and let that rule, rather than the best-looking cell of a grid, decide what ships.&lt;/p&gt;

&lt;p&gt;SpotRecall is open source under AGPL-3.0. &lt;a href="https://spotrecall.com/" rel="noopener noreferrer"&gt;spotrecall.com&lt;/a&gt; · &lt;a href="https://github.com/dqj1998/SpotRecall" rel="noopener noreferrer"&gt;source on GitHub&lt;/a&gt; · &lt;a href="https://chromewebstore.google.com/detail/lfdjmifmmmimonedmclkpckjebmcabcg" rel="noopener noreferrer"&gt;install from the Chrome Web Store&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is Post 14 in &lt;em&gt;Building SpotRecall&lt;/em&gt;, and the final post in Season 3: sharper, measured search.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>testing</category>
      <category>opensource</category>
      <category>buildinpublic</category>
    </item>
  </channel>
</rss>
