<?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: Aleksandr Argunov</title>
    <description>The latest articles on DEV Community by Aleksandr Argunov (@argbetech).</description>
    <link>https://dev.to/argbetech</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%2F3790326%2Fdbb58c79-3080-4d9a-9a8e-710ca86c39b3.jpg</url>
      <title>DEV Community: Aleksandr Argunov</title>
      <link>https://dev.to/argbetech</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/argbetech"/>
    <language>en</language>
    <item>
      <title>Seven DDEV workflow wins, and what a rollback actually restores</title>
      <dc:creator>Aleksandr Argunov</dc:creator>
      <pubDate>Sun, 29 Nov 2026 10:44:00 +0000</pubDate>
      <link>https://dev.to/argbetech/seven-ddev-workflow-wins-and-what-a-rollback-actually-restores-31lc</link>
      <guid>https://dev.to/argbetech/seven-ddev-workflow-wins-and-what-a-rollback-actually-restores-31lc</guid>
      <description>&lt;p&gt;I originally used Trellis, Bedrock and Sage for WordPress development. I set up a Docker Compose environment without Vagrant, and it was a little cumbersome. Now I'm using DDEV, and I love how much of the local environment it manages.&lt;/p&gt;

&lt;p&gt;DDEV runs the local environment. Bedrock manages project layout and dependencies. Sage or a block theme decides how pages are built. Trellis handles infrastructure and deployment, and also offers &lt;a href="https://roots.io/trellis/docs/local-development/" rel="noopener noreferrer"&gt;local development with Lima&lt;/a&gt;. These tools can be combined.&lt;/p&gt;

&lt;h2&gt;
  
  
  The commands and settings, with their limits
&lt;/h2&gt;

&lt;p&gt;These landed across &lt;a href="https://ddev.com/blog/release-v1-25-4/" rel="noopener noreferrer"&gt;DDEV 1.25.4 (September 2)&lt;/a&gt; and &lt;a href="https://ddev.com/blog/release-v1-25-5/" rel="noopener noreferrer"&gt;1.25.5 (October 26)&lt;/a&gt;. That's 54 days apart: 28 left in September, then 26 in October. The gap isn't how long the work took, since DDEV says 1.25.5 shipped early for PHP security fixes.&lt;/p&gt;

&lt;p&gt;The start and restart flags were checked against &lt;code&gt;--help&lt;/code&gt; on &lt;a href="https://ddev.com/blog/release-v1-25-5/" rel="noopener noreferrer"&gt;DDEV 1.25.5&lt;/a&gt;. They weren't run against a live project. These are separate examples, not a script to run in order.&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;# Fill a brand-new database volume from a snapshot (name or path required).&lt;/span&gt;
&lt;span class="c"&gt;# Database type and version must match. This does not replace an existing database.&lt;/span&gt;
ddev start &lt;span class="nt"&gt;--seed-snapshot&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;mysnapshot

&lt;span class="c"&gt;# Throw the database away and start over.&lt;/span&gt;
&lt;span class="c"&gt;# Takes a snapshot first unless you add --omit-snapshot. Asks first unless you add -y.&lt;/span&gt;
ddev start &lt;span class="nt"&gt;--reset-database&lt;/span&gt;

&lt;span class="c"&gt;# Restart only the services you name. A service name is required.&lt;/span&gt;
ddev restart &lt;span class="nt"&gt;-s&lt;/span&gt; redis

&lt;span class="c"&gt;# Open the rebuilt TUI.&lt;/span&gt;
ddev tui

&lt;span class="c"&gt;# Use your own SSH agent in the containers. Support depends on your Docker provider.&lt;/span&gt;
ddev config global &lt;span class="nt"&gt;--ssh-agent-upstream&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;host

&lt;span class="c"&gt;# Share through a configured tunnel provider; the output includes a QR code.&lt;/span&gt;
ddev share
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restarting &lt;code&gt;web&lt;/code&gt; restarts the whole project, including optional services that were started; see the &lt;a href="https://docs.ddev.com/en/stable/users/usage/commands/" rel="noopener noreferrer"&gt;command reference&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ddev.com/blog/release-v1-25-5/" rel="noopener noreferrer"&gt;Global hooks&lt;/a&gt; live in &lt;code&gt;~/.ddev/global_config.yaml&lt;/code&gt;. They run before a project's own hooks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;hooks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;post-start&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;exec-host&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;echo&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;a&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;global&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;hook&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;ran'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A project opts out with &lt;code&gt;skip_global_hooks: true&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What each tool restores
&lt;/h2&gt;

&lt;p&gt;I still like Bedrock's Composer approach a lot. Plugins are listed in &lt;code&gt;composer.json&lt;/code&gt;, and &lt;a href="https://getcomposer.org/doc/01-basic-usage.md#installing-with-composer-lock" rel="noopener noreferrer"&gt;the lock file pins their versions&lt;/a&gt;. DDEV has Composer built in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ddev composer &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the same committed lock file, that installs the same dependency versions. It doesn't reproduce the database or uploads.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;You want back&lt;/th&gt;
&lt;th&gt;What restores it&lt;/th&gt;
&lt;th&gt;What it leaves alone&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Composer-managed plugins&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;composer.lock&lt;/code&gt; and &lt;code&gt;composer install&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Plugins added or updated by hand, database, content&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Your local database&lt;/td&gt;
&lt;td&gt;&lt;a href="https://ddev.com/blog/ddev-snapshots/" rel="noopener noreferrer"&gt;A DDEV snapshot&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Your code, and anything on a server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A deployed code release&lt;/td&gt;
&lt;td&gt;&lt;a href="https://roots.io/trellis/docs/deployments/" rel="noopener noreferrer"&gt;Trellis release and rollback&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Database and content changes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The theme decides the Site Editor
&lt;/h2&gt;

&lt;p&gt;The Site Editor follows the theme type, not DDEV or Trellis.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;a href="https://developer.wordpress.org/themes/getting-started/what-is-a-theme/" rel="noopener noreferrer"&gt;native block theme&lt;/a&gt; uses HTML templates and &lt;code&gt;theme.json&lt;/code&gt;, and gives you the Site Editor.&lt;/li&gt;
&lt;li&gt;Custom blocks can use React, scaffolded as a plugin with &lt;a href="https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/" rel="noopener noreferrer"&gt;&lt;code&gt;npx @wordpress/create-block&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://roots.io/sage/" rel="noopener noreferrer"&gt;Sage&lt;/a&gt; gives you Blade, Acorn, Vite and Tailwind, with HMR that includes editor styles. It isn't a full Site Editor block theme by default.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For deployment, &lt;a href="https://roots.io/trellis/docs/deployments/" rel="noopener noreferrer"&gt;Trellis&lt;/a&gt; provisions with Ansible and deploys with releases and rollback. Otherwise use your host's workflow, because &lt;a href="https://docs.ddev.com/en/stable/users/topics/hosting/" rel="noopener noreferrer"&gt;DDEV hosting is still experimental&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Native WordPress keeps getting stronger. DDEV makes working with it a pleasure again.&lt;/p&gt;

&lt;p&gt;The maintained version, with the full comparison table, is on &lt;a href="https://argbe.tech/blog/ddev-bedrock-sage-trellis-wordpress?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=ddev-bedrock-sage-trellis-wordpress" rel="noopener noreferrer"&gt;argbe.tech&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>php</category>
      <category>docker</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Your form looks labelled. Here's what an AI agent reads instead</title>
      <dc:creator>Aleksandr Argunov</dc:creator>
      <pubDate>Sat, 28 Nov 2026 18:06:00 +0000</pubDate>
      <link>https://dev.to/argbetech/your-form-looks-labelled-heres-what-an-ai-agent-reads-instead-4kac</link>
      <guid>https://dev.to/argbetech/your-form-looks-labelled-heres-what-an-ai-agent-reads-instead-4kac</guid>
      <description>&lt;p&gt;A form can look labelled and still hand an agent a nameless box.&lt;/p&gt;

&lt;p&gt;Here's a small script that shows it. It builds a sample page and prints an accessibility snapshot, with JavaScript on and then off. Use a Bash or Zsh terminal with Node installed.&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="nb"&gt;mkdir &lt;/span&gt;agent-check &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;agent-check
npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
npm &lt;span class="nb"&gt;install &lt;/span&gt;playwright@1.60.0
npx playwright &lt;span class="nb"&gt;install &lt;/span&gt;chromium

&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; page.html &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
&amp;lt;!doctype html&amp;gt;
&amp;lt;meta charset="utf-8"&amp;gt;
&amp;lt;title&amp;gt;Acme Dog Beds&amp;lt;/title&amp;gt;
&amp;lt;h1 id="pitch"&amp;gt;&amp;lt;/h1&amp;gt;
&amp;lt;script&amp;gt;pitch.textContent = 'Dog beds from €49'&amp;lt;/script&amp;gt;
&amp;lt;form&amp;gt;
  &amp;lt;span&amp;gt;Email&amp;lt;/span&amp;gt; &amp;lt;input type="email"&amp;gt;
  &amp;lt;label&amp;gt;Dog's name &amp;lt;input type="text"&amp;gt;&amp;lt;/label&amp;gt;
  &amp;lt;button&amp;gt;Book a fitting&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; check.mjs &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
import { chromium } from 'playwright'

const browser = await chromium.launch()
for (const javaScriptEnabled of [true, false]) {
  const context = await browser.newContext({ javaScriptEnabled })
  const page = await context.newPage()
  await page.goto(process.argv[2])
  console.log(`--- JavaScript &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;javaScriptEnabled&lt;/span&gt;&lt;span class="p"&gt; ? &lt;/span&gt;&lt;span class="s1"&gt;'on'&lt;/span&gt;&lt;span class="p"&gt; &lt;/span&gt;:&lt;span class="p"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'off'&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="sh"&gt; ---`)
  console.log(await page.locator('body').ariaSnapshot())
  await context.close()
}
await browser.close()
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;node check.mjs &lt;span class="s2"&gt;"file://&lt;/span&gt;&lt;span class="nv"&gt;$PWD&lt;/span&gt;&lt;span class="s2"&gt;/page.html"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run this and you get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;--- JavaScript on ---
- heading "Dog beds from €49" [level=1]
- text: Email
- textbox
- text: Dog's name
- textbox "Dog's name"
- button "Book a fitting"
--- JavaScript off ---
- heading [level=1]
- text: Email
- textbox
- text: Dog's name
- textbox "Dog's name"
- button "Book a fitting"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read the two &lt;code&gt;textbox&lt;/code&gt; lines. A person sees "Email" beside the first field. In the tree it has no name, because a &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; next to an input isn't a label. W3C shows &lt;a href="https://www.w3.org/WAI/tutorials/forms/labels/" rel="noopener noreferrer"&gt;labels linked by matching &lt;code&gt;for&lt;/code&gt; and &lt;code&gt;id&lt;/code&gt; values, or wrapped around the control&lt;/a&gt;. Wrap it here and the line becomes &lt;code&gt;textbox "Email"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then read the headings. With JavaScript off, the pitch and the price are gone.&lt;/p&gt;

&lt;p&gt;This output is an &lt;a href="https://playwright.dev/docs/aria-snapshots" rel="noopener noreferrer"&gt;accessibility snapshot in YAML&lt;/a&gt;. &lt;a href="https://github.com/microsoft/playwright-mcp" rel="noopener noreferrer"&gt;Playwright MCP&lt;/a&gt; also lets agents read structured accessibility snapshots without needing screenshots. It's one way a browser agent reads a page.&lt;/p&gt;

&lt;p&gt;Point it at a site you own:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node check.mjs https://yoursite.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look for words that vanish in the second half, and any &lt;code&gt;- textbox&lt;/code&gt; with no name after it. Each page loads in a fresh browser context, without your login. The script doesn't click through a form or inspect fields revealed later. The output above comes from the sample page, using Playwright &lt;code&gt;1.60.0&lt;/code&gt;.&lt;/p&gt;

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

&lt;p&gt;That script helps with two of six checks. Here's the whole scorecard to test your website with an AI agent. It's my rubric, not a standard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://argbe.tech/blog/test-website-with-ai-agent?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=test-website-with-ai-agent" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fru95m77yqimblzs0fuds.jpg" alt="A blank scorecard titled &amp;quot;Can an AI agent use your website?&amp;quot; with six rows and empty pass and fail boxes: AI says what you sell, The right crawlers get in, Works without JavaScript, Price in two clicks, The agent finishes the task, Every form field has a label. Below the rows are empty fields for site and task, and a score out of six." width="800" height="944"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI says what you sell.&lt;/strong&gt; Ask an AI chat what your company sells and who it's for. Compare the answer with your homepage. Record the model, date, prompt and whether it visited the site. A correct description doesn't prove it can use the site.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The right crawlers get in.&lt;/strong&gt; robots.txt can say yes while your firewall says no, so check both:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-L&lt;/span&gt; https://yoursite.com/robots.txt
curl &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-L&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; /dev/null &lt;span class="nt"&gt;-w&lt;/span&gt; &lt;span class="s1"&gt;'%{http_code}\n'&lt;/span&gt; &lt;span class="nt"&gt;-A&lt;/span&gt; &lt;span class="s1"&gt;'GPTBot'&lt;/span&gt; https://yoursite.com/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;GPTBot&lt;/code&gt; with the crawler you chose. A &lt;code&gt;403&lt;/code&gt; means this request was refused, but doesn't establish why. A &lt;code&gt;200&lt;/code&gt; doesn't prove the real crawler gets in. Check your CDN's bot settings and verified crawler requests in its logs too.&lt;/p&gt;

&lt;p&gt;The names do different jobs: OpenAI separates &lt;a href="https://developers.openai.com/api/docs/bots" rel="noopener noreferrer"&gt;&lt;code&gt;GPTBot&lt;/code&gt; for training from &lt;code&gt;OAI-SearchBot&lt;/code&gt; for search&lt;/a&gt;, and Anthropic separates &lt;a href="https://support.claude.com/en/articles/8896518-does-anthropic-crawl-data-from-the-web-and-how-can-site-owners-block-the-crawler" rel="noopener noreferrer"&gt;&lt;code&gt;ClaudeBot&lt;/code&gt; from &lt;code&gt;Claude-SearchBot&lt;/code&gt;&lt;/a&gt; in the same way. &lt;a href="https://blog.cloudflare.com/content-independence-day-no-ai-crawl-without-compensation/" rel="noopener noreferrer"&gt;Cloudflare announced default blocking for AI crawlers in July 2025&lt;/a&gt;, with &lt;a href="https://www.cloudflare.com/press-releases/2025/cloudflare-just-changed-how-ai-crawlers-scrape-the-internet-at-large/" rel="noopener noreferrer"&gt;new domains asked whether to allow them&lt;/a&gt;. Check the actual settings on your site.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Works without JavaScript.&lt;/strong&gt; It's a fallback check for crawlers that don't run JavaScript. It isn't an agent simulation, since browser tools run a real browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Price in two clicks.&lt;/strong&gt; More than two clicks from the homepage is a fail. That's my cutoff for this card, not a universal usability rule. Record the path. If you have no public price, pick another target, such as the quote form, before you start.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The agent finishes the task.&lt;/strong&gt; Give an agent your main task and count the steps until it finishes or gives up. In Claude Code, &lt;code&gt;claude mcp add playwright npx @playwright/mcp@latest&lt;/code&gt; adds a browser. Tell it where to stop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Go to https://yoursite.com.
Your task: book a call for next Tuesday.
Do not pay. Do not send the final form. Stop one step before.
List every step you took and every place you got stuck.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it reaches the stopping point, record "reached final step; submission untested". To test completion, use a test environment where submission is allowed and verify the result. Write down each time a person stepped in, and why. A required &lt;a href="https://help.openai.com/en/articles/11752874-chatgpt-agent" rel="noopener noreferrer"&gt;confirmation before a sensitive action&lt;/a&gt; doesn't, by itself, mean the site failed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Every form field has a label.&lt;/strong&gt; Check all fields along the task path, including ones revealed later. The script helps spot nameless controls on the page it loads; it isn't a complete audit.&lt;/p&gt;

&lt;p&gt;Mark each row pass, fail or untested, with the evidence beside it. The total counts passes, not the severity of a problem. Crawler access, HTML fallback and form labels can fail for different reasons.&lt;/p&gt;

&lt;p&gt;A blank card to copy, with an evidence field for each row, is in &lt;a href="https://argbe.tech/blog/test-website-with-ai-agent?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=test-website-with-ai-agent" rel="noopener noreferrer"&gt;the article on argbe.tech&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>testing</category>
      <category>a11y</category>
    </item>
    <item>
      <title>One typo, two results: testing how typed a CLI really is for coding agents</title>
      <dc:creator>Aleksandr Argunov</dc:creator>
      <pubDate>Fri, 27 Nov 2026 14:27:00 +0000</pubDate>
      <link>https://dev.to/argbetech/one-typo-two-results-testing-how-typed-a-cli-really-is-for-coding-agents-32nf</link>
      <guid>https://dev.to/argbetech/one-typo-two-results-testing-how-typed-a-cli-really-is-for-coding-agents-32nf</guid>
      <description>&lt;p&gt;Smarter models need fewer words and stricter tools. But a typed CLI is only typed where its schema reaches.&lt;/p&gt;

&lt;p&gt;Here's that gap in two commands. Both use &lt;a href="https://blog.cloudflare.com/cloudflare-cf-cli-launch/" rel="noopener noreferrer"&gt;Cloudflare's &lt;code&gt;cf&lt;/code&gt; CLI&lt;/a&gt;, which is generated from its API schema. Both are dry runs. You need Node and no Cloudflare login. The zone ID is a placeholder, and the version is pinned because &lt;code&gt;cf&lt;/code&gt; is an open beta.&lt;/p&gt;

&lt;h2&gt;
  
  
  A wrong letter in a flag
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx &lt;span class="nt"&gt;--yes&lt;/span&gt; cf@1.0.0-beta.27 dns records list &lt;span class="nt"&gt;--dry-run&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-z&lt;/span&gt; 023e105f4ecef8ad9ca31a8372d0c353 &lt;span class="nt"&gt;--type&lt;/span&gt; AAA
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run this and you get help text, then exit code 1 and this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌ Error
│ Invalid values:
│ Argument: type, Given: "AAA", Choices: "A", "AAAA", "CAA", "CERT", "CNAME",
│ "DNSKEY", "DS", "HTTPS", "LOC", "MX", "NAPTR", "NS", "OPENPGPKEY", "PTR",
│ "SMIMEA", "SRV", "SSHFP", "SVCB", "TLSA", "TXT", "URI"
└
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An agent gets the mistake and the valid values in one message.&lt;/p&gt;

&lt;h2&gt;
  
  
  The same letter in a body
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;cf dns records create&lt;/code&gt; has no &lt;code&gt;--type&lt;/code&gt; flag. Pass one and you get &lt;code&gt;Unknown arguments&lt;/code&gt;. It takes a JSON body instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx &lt;span class="nt"&gt;--yes&lt;/span&gt; cf@1.0.0-beta.27 dns records create &lt;span class="nt"&gt;--dry-run&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-z&lt;/span&gt; 023e105f4ecef8ad9ca31a8372d0c353 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--body&lt;/span&gt; &lt;span class="s1"&gt;'{"type":"AAA","name":"test","content":"192.0.2.1"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run this and you get exit code 0. The typo stays in the request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"cf dns records create"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"method"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"pathParams"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"zone-id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"023e105f4ecef8ad9ca31a8372d0c353"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"query"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"bodyKind"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"body"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"AAA"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"192.0.2.1"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ask the CLI why:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx &lt;span class="nt"&gt;--yes&lt;/span&gt; cf@1.0.0-beta.27 schema dns records create
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output ends with &lt;code&gt;"hasRequestBody": true&lt;/code&gt; and &lt;code&gt;"requestBodyFields": []&lt;/code&gt;. There are no body fields to check. The API may still refuse &lt;code&gt;AAA&lt;/code&gt;, but a dry run can't tell you. &lt;code&gt;cf zones create --dry-run&lt;/code&gt; with no domain name passes the same way.&lt;/p&gt;

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

&lt;p&gt;Pass one bad value to a dry run of any tool you give an agent.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It stops and lists the valid values: that argument is typed.&lt;/li&gt;
&lt;li&gt;It goes through: that argument is still on you.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This shows refusals, not results. It doesn't show that agents finish more tasks with types. That takes the same task, run both ways, and counted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why bother: prose can only ask
&lt;/h2&gt;

&lt;p&gt;A CLAUDE.md rule asks. Claude Code's docs say Claude treats these files as &lt;a href="https://code.claude.com/docs/en/memory" rel="noopener noreferrer"&gt;"context, not enforced configuration"&lt;/a&gt;. To block an action, they point to a hook.&lt;/p&gt;

&lt;p&gt;Setup keeps moving down a layer, from prose into types. Four other things moved with it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instructions shrink.&lt;/strong&gt; &lt;a href="https://github.com/anthropics/skills/blob/main/skills/claude-api/shared/prompt-audit.md" rel="noopener noreferrer"&gt;Anthropic's prompt audit guidance&lt;/a&gt; says current Claude models follow instructions more literally, so stale rules get obeyed. Claude Code's docs recommend &lt;a href="https://code.claude.com/docs/en/memory" rel="noopener noreferrer"&gt;under 200 lines per CLAUDE.md&lt;/a&gt; and moving procedures into skills. &lt;code&gt;/doctor prompt-audit&lt;/code&gt; flags rules written for older models.&lt;/p&gt;

&lt;p&gt;A &lt;a href="https://arxiv.org/abs/2602.11988v3" rel="noopener noreferrer"&gt;study by Gloaguen, Mündler-Sasahara, Müller, Raychev and Vechev&lt;/a&gt; found context files raised inference cost by over 20% on average and didn't generally improve task success. That's an average over the agents and tasks they tested, not proof your file hurts your model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Skills load on demand.&lt;/strong&gt; &lt;a href="https://agentskills.io/specification" rel="noopener noreferrer"&gt;The open spec&lt;/a&gt; keeps only the name and description in context at startup, and recommends a body under 500 lines. &lt;a href="https://agentskills.io/skill-creation/best-practices" rel="noopener noreferrer"&gt;Its guide&lt;/a&gt; asks one question of each line: "Would the agent get this wrong without this instruction?"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MCP goes stateless.&lt;/strong&gt; The &lt;a href="https://blog.modelcontextprotocol.io/posts/2026-07-28/" rel="noopener noreferrer"&gt;2026-07-28 spec&lt;/a&gt; retired the &lt;code&gt;initialize&lt;/code&gt; exchange and the &lt;code&gt;Mcp-Session-Id&lt;/code&gt; header. Each request describes itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Before 2026-07-28
POST /mcp
Mcp-Session-Id: 4f9c2e1a-…

# Since 2026-07-28
POST /mcp
MCP-Protocol-Version: 2026-07-28
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your application can still keep state. Old servers don't upgrade themselves.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Plugins ship it together.&lt;/strong&gt; &lt;a href="https://agent-plugins.org/" rel="noopener noreferrer"&gt;Agent Plugins 1.0&lt;/a&gt; puts skills and MCP servers in one folder for &lt;a href="https://agent-plugins.org/compatible-clients" rel="noopener noreferrer"&gt;Codex, Cursor, Copilot and VS Code&lt;/a&gt;. Claude Code has &lt;a href="https://code.claude.com/docs/en/plugins-reference" rel="noopener noreferrer"&gt;its own format&lt;/a&gt;. Install and permissions still differ by client.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Agent Plugins 1.0        Claude Code
my-plugin/               my-plugin/
├── plugin.json          ├── .claude-plugin/plugin.json
├── skills/              ├── skills/
└── mcp.json             └── .mcp.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  My rule of thumb
&lt;/h2&gt;

&lt;p&gt;A CLI for tools on your machine, MCP for anything that needs auth, audit or many users.&lt;/p&gt;

&lt;p&gt;It has holes. &lt;code&gt;cf&lt;/code&gt; logs in and calls remote services. MCP can &lt;a href="https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/stdio" rel="noopener noreferrer"&gt;run locally over stdio&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6uurnvqomr11skle9gkx.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6uurnvqomr11skle9gkx.gif" alt="Agent setup in 2026: five before-and-after rows for instructions, skills, CLIs, MCP and plugins." width="760" height="950"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Less prose, more types.&lt;/p&gt;

&lt;p&gt;The maintained version, with every source, is &lt;a href="https://argbe.tech/blog/coding-agent-instructions-typed-tools?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=coding-agent-instructions-typed-tools" rel="noopener noreferrer"&gt;on argbe.tech&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>mcp</category>
      <category>cli</category>
      <category>claudecode</category>
    </item>
    <item>
      <title>Same cron line, different picker: AI agent vs workflow in YAML</title>
      <dc:creator>Aleksandr Argunov</dc:creator>
      <pubDate>Thu, 26 Nov 2026 07:37:00 +0000</pubDate>
      <link>https://dev.to/argbetech/same-cron-line-different-picker-ai-agent-vs-workflow-in-yaml-122j</link>
      <guid>https://dev.to/argbetech/same-cron-line-different-picker-ai-agent-vs-workflow-in-yaml-122j</guid>
      <description>&lt;p&gt;Most AI agents are a CI pipeline with one LLM call in the middle. That's my opinion, not a survey. Putting that pipeline on cron doesn't change what it is.&lt;/p&gt;

&lt;p&gt;Six terms get mixed up here. What separates them is who picks the next step.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh8fc49xj3nfjckew0zds.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh8fc49xj3nfjckew0zds.gif" alt="Six rows, one question: who picks the next step? Chat: you. Workflow: your code. Agent and always-on agent: the model. Swarm: a lead agent. Agentic system: it depends." width="720" height="900"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Term&lt;/th&gt;
&lt;th&gt;Who picks the next step&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AI chat&lt;/td&gt;
&lt;td&gt;You&lt;/td&gt;
&lt;td&gt;You paste a Vite build error, get a fix and decide what to try next&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agentic workflow&lt;/td&gt;
&lt;td&gt;Your code&lt;/td&gt;
&lt;td&gt;A GitHub Actions or Azure Pipelines job calls the model in one step&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agent&lt;/td&gt;
&lt;td&gt;The model&lt;/td&gt;
&lt;td&gt;It reads files, runs bash, edits code and decides when it's done&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Always-on agent&lt;/td&gt;
&lt;td&gt;The model&lt;/td&gt;
&lt;td&gt;A schedule or a new GitHub issue wakes it, and no person starts the run&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agent swarm&lt;/td&gt;
&lt;td&gt;A lead agent&lt;/td&gt;
&lt;td&gt;It hands research, frontend, backend and review to specialists&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agentic system&lt;/td&gt;
&lt;td&gt;Depends on the wiring&lt;/td&gt;
&lt;td&gt;CI runs the checks, an agent fixes what fails, and you approve the merge&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The workflow and agent split is &lt;a href="https://www.anthropic.com/research/building-effective-agents" rel="noopener noreferrer"&gt;Anthropic's&lt;/a&gt;. Workflows follow predefined code paths. Agents direct their own process and tool use. Anthropic also uses "agentic systems" as the umbrella for both, so a system doesn't need every row. The swarm row is the &lt;a href="https://claude.com/resources/articles/multi-agent-coordination-patterns" rel="noopener noreferrer"&gt;orchestrator-subagent&lt;/a&gt; shape. Multi-agent is wider, and not every pattern has a lead.&lt;/p&gt;

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

&lt;p&gt;Both files are GitHub Actions sketches. Checkout, secrets and the scripts are left out, and neither file has been run.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Your YAML picks every step.&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;schedule&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;cron&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*/30&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*'&lt;/span&gt;
&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;fix&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./scripts/read-log.sh&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./scripts/ask-model-for-patch.sh&lt;/span&gt; &lt;span class="c1"&gt;# the one LLM call&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm test&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./scripts/open-pr.sh&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can read the order before it runs. If &lt;code&gt;npm test&lt;/code&gt; fails, the job fails and &lt;code&gt;open-pr.sh&lt;/code&gt; doesn't run.&lt;/p&gt;

&lt;h2&gt;
  
  
  The agent
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# The model picks what to read, edit and rerun.&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;schedule&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;cron&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*/30&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*'&lt;/span&gt;
&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;fix&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./scripts/run-agent.sh "Fix the failing test. Open a PR. Don't merge."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;run-agent.sh&lt;/code&gt; stands for whatever agent you run. &lt;a href="https://code.claude.com/docs/en/how-claude-code-works" rel="noopener noreferrer"&gt;Claude Code&lt;/a&gt;, for example, documents a loop of running the suite, reading the error, editing and rerunning.&lt;/p&gt;

&lt;p&gt;The cron line didn't change. The picker did.&lt;/p&gt;

&lt;p&gt;The transition that moves is the one after the failure. In the first file, nothing comes next. In the second, the model chooses: another file, another edit, another test run, or stop.&lt;/p&gt;

&lt;p&gt;Retries don't settle it. Write a retry loop in YAML and your code still picks.&lt;/p&gt;

&lt;p&gt;The second file needs something the first doesn't: a way to end. Anthropic suggests &lt;a href="https://www.anthropic.com/research/building-effective-agents" rel="noopener noreferrer"&gt;stopping conditions, such as a maximum number of iterations&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scheduled agent vs workflow on cron
&lt;/h2&gt;

&lt;p&gt;Something always starts a run. That's a separate choice from who picks the steps.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What starts the run&lt;/th&gt;
&lt;th&gt;Your code picks each step&lt;/th&gt;
&lt;th&gt;The model picks each step&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;You&lt;/td&gt;
&lt;td&gt;A job you trigger by hand&lt;/td&gt;
&lt;td&gt;A task you give a coding agent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A schedule&lt;/td&gt;
&lt;td&gt;The first YAML&lt;/td&gt;
&lt;td&gt;The second YAML, or a cloud scheduled task&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;An event&lt;/td&gt;
&lt;td&gt;A YAML job on a new issue&lt;/td&gt;
&lt;td&gt;An agent woken by a GitHub event you configured&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Interval limits differ. GitHub's &lt;a href="https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax" rel="noopener noreferrer"&gt;shortest scheduled interval is 5 minutes&lt;/a&gt;. Claude Code's &lt;a href="https://code.claude.com/docs/en/routines" rel="noopener noreferrer"&gt;cloud scheduled tasks&lt;/a&gt;, formerly routines, are in research preview and reject anything more often than hourly. So 30 minutes works in the YAML above and not there.&lt;/p&gt;

&lt;h2&gt;
  
  
  One repo, three answers
&lt;/h2&gt;

&lt;p&gt;Take a Next.js repo. No product gives you this flow by being named. You wire it from CI, an agent and &lt;a href="https://vercel.com/docs/git" rel="noopener noreferrer"&gt;Vercel's Git integration&lt;/a&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Who picks&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Run the checks&lt;/td&gt;
&lt;td&gt;Your code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Read the failure, fix it&lt;/td&gt;
&lt;td&gt;The model&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Approve the merge&lt;/td&gt;
&lt;td&gt;You&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deploy&lt;/td&gt;
&lt;td&gt;Your code&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Let the agent propose the patch, and require your approval before merge. An agent picking the next step doesn't mean it picks every step.&lt;/p&gt;

&lt;p&gt;Anthropic's advice is to &lt;a href="https://www.anthropic.com/research/building-effective-agents" rel="noopener noreferrer"&gt;find the simplest solution and add complexity only when needed&lt;/a&gt;. It also notes that agentic systems often trade latency and cost for better task performance. That can mean the left column.&lt;/p&gt;

&lt;p&gt;Strip the AI names and it's stuff we've had for years.&lt;/p&gt;

&lt;p&gt;The maintained version, with all six terms in full and the sources: &lt;a href="https://argbe.tech/blog/ai-agent-vs-workflow?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=ai-agent-vs-workflow" rel="noopener noreferrer"&gt;Is your AI agent a CI pipeline?&lt;/a&gt; How the loop itself works is in &lt;a href="https://argbe.tech/blog/ai-agent-harness?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=ai-agent-vs-workflow" rel="noopener noreferrer"&gt;What is an AI agent harness?&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devops</category>
      <category>githubactions</category>
      <category>programming</category>
    </item>
    <item>
      <title>Pele vs Mermaid benchmark: 347x warm, 14x to 20x on first render</title>
      <dc:creator>Aleksandr Argunov</dc:creator>
      <pubDate>Tue, 24 Nov 2026 06:23:00 +0000</pubDate>
      <link>https://dev.to/argbetech/pele-vs-mermaid-benchmark-347x-warm-14x-to-20x-on-first-render-20dj</link>
      <guid>https://dev.to/argbetech/pele-vs-mermaid-benchmark-347x-warm-14x-to-20x-on-first-render-20dj</guid>
      <description>&lt;p&gt;&lt;a href="https://pele.run/" rel="noopener noreferrer"&gt;Pele's site&lt;/a&gt; says up to 500× faster than Mermaid.js, and gives no method on the page. So here's a measured one: 347× once warm, 14.7× on the first render. Swap the order the two renderers run in, and that second number becomes 19.9×.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://argbe.tech/blog/pele-vs-mermaid-first-render-benchmark?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=pele-vs-mermaid-first-render-benchmark" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftkl5fur5ek1fovfnq0s8.gif" alt="Animated score of Pele against Mermaid.js in Chrome. A wall of small orange Pele renders fills up around one large Mermaid diagram, which finishes last." width="720" height="900"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pele is the open source renderer from Obsidian, credited to kepano. It replaced Mermaid in &lt;a href="https://obsidian.md/changelog/2026-10-22-desktop-v1.15.0/" rel="noopener noreferrer"&gt;Obsidian 1.15.0 early access&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Method
&lt;/h2&gt;

&lt;p&gt;Measured Nov 3, 2026, on an Apple M1 Pro. Headless Chrome 156.0.8078.48 through &lt;a href="https://playwright.dev/" rel="noopener noreferrer"&gt;Playwright&lt;/a&gt;, &lt;a href="https://cdn.jsdelivr.net/npm/pele@1.13.0/dist/pele.js" rel="noopener noreferrer"&gt;Pele 1.13.0&lt;/a&gt;, &lt;a href="https://cdn.jsdelivr.net/npm/mermaid@12.2.0/dist/mermaid.min.js" rel="noopener noreferrer"&gt;Mermaid 12.2.0&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sample:&lt;/strong&gt; one diagram, the flowchart on &lt;a href="https://pele.run/" rel="noopener noreferrer"&gt;pele.run&lt;/a&gt;, on five fresh pages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;First render:&lt;/strong&gt; one Pele render, then one Mermaid render, each ending with &lt;code&gt;host.innerHTML = svg&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Warm:&lt;/strong&gt; 3,000 Pele renders, then 150 Mermaid renders. The window is the median of the last 100 Mermaid renders. The test counts Pele renders inside it, because one is too quick for &lt;code&gt;performance.now()&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Timing starts after both scripts load and stops once the SVG is in the DOM. It excludes download, script parse and paint. It says nothing about the code cache on repeat visits, other diagram types, other browsers or slower machines.&lt;/p&gt;

&lt;h2&gt;
  
  
  The five saved runs
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Run&lt;/th&gt;
&lt;th&gt;Pele first (ms)&lt;/th&gt;
&lt;th&gt;Mermaid first (ms)&lt;/th&gt;
&lt;th&gt;Ratio&lt;/th&gt;
&lt;th&gt;Gap (ms)&lt;/th&gt;
&lt;th&gt;Mermaid warm (ms)&lt;/th&gt;
&lt;th&gt;Warm count&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;17.5&lt;/td&gt;
&lt;td&gt;190.7&lt;/td&gt;
&lt;td&gt;10.9×&lt;/td&gt;
&lt;td&gt;173.2&lt;/td&gt;
&lt;td&gt;34.0&lt;/td&gt;
&lt;td&gt;339&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;12.3&lt;/td&gt;
&lt;td&gt;176.7&lt;/td&gt;
&lt;td&gt;14.4×&lt;/td&gt;
&lt;td&gt;164.4&lt;/td&gt;
&lt;td&gt;34.6&lt;/td&gt;
&lt;td&gt;347&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;11.6&lt;/td&gt;
&lt;td&gt;170.4&lt;/td&gt;
&lt;td&gt;14.7×&lt;/td&gt;
&lt;td&gt;158.8&lt;/td&gt;
&lt;td&gt;33.8&lt;/td&gt;
&lt;td&gt;370&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;11.3&lt;/td&gt;
&lt;td&gt;174.6&lt;/td&gt;
&lt;td&gt;15.5×&lt;/td&gt;
&lt;td&gt;163.3&lt;/td&gt;
&lt;td&gt;33.2&lt;/td&gt;
&lt;td&gt;374&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;11.8&lt;/td&gt;
&lt;td&gt;183.5&lt;/td&gt;
&lt;td&gt;15.6×&lt;/td&gt;
&lt;td&gt;171.7&lt;/td&gt;
&lt;td&gt;33.2&lt;/td&gt;
&lt;td&gt;324&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Median&lt;/td&gt;
&lt;td&gt;11.8&lt;/td&gt;
&lt;td&gt;176.7&lt;/td&gt;
&lt;td&gt;14.7×&lt;/td&gt;
&lt;td&gt;164.4&lt;/td&gt;
&lt;td&gt;33.8&lt;/td&gt;
&lt;td&gt;347&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That's about 0.1 ms per warm Pele render: 34.6 / 347. &lt;a href="https://pele.run/" rel="noopener noreferrer"&gt;pele.run's table&lt;/a&gt; lists 0.05–0.3 ms for Pele and 6–82 ms for Mermaid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/obsidianmd/pele/blob/main/scripts/bench-mermaid.mjs" rel="noopener noreferrer"&gt;Pele's own benchmark&lt;/a&gt; also sets &lt;code&gt;innerHTML&lt;/code&gt;. Drop insertion on Pele's side only and the median count reads 769. That isn't a fair score, since Mermaid's window still includes insertion. It shows about half of a warm Pele render is DOM work.&lt;/p&gt;

&lt;h2&gt;
  
  
  The first-render ratio moves
&lt;/h2&gt;

&lt;p&gt;A rerun on the same machine and Chrome version gave 346× warm and 14.3× on first render, with a 173.1 ms gap. The machine was busy: one-minute load ranged from 4.3 to 16.4.&lt;/p&gt;

&lt;p&gt;Then the order alternated across 20 fresh pages:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Goes first&lt;/th&gt;
&lt;th&gt;Pele (ms)&lt;/th&gt;
&lt;th&gt;Mermaid (ms)&lt;/th&gt;
&lt;th&gt;Ratio&lt;/th&gt;
&lt;th&gt;Gap (ms)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pele&lt;/td&gt;
&lt;td&gt;11.9&lt;/td&gt;
&lt;td&gt;165.9&lt;/td&gt;
&lt;td&gt;14.0×&lt;/td&gt;
&lt;td&gt;154&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mermaid&lt;/td&gt;
&lt;td&gt;8.4&lt;/td&gt;
&lt;td&gt;166.4&lt;/td&gt;
&lt;td&gt;19.9×&lt;/td&gt;
&lt;td&gt;158&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Mermaid barely moves. Pele loses about 3.5 ms when it goes first. The test doesn't show why, and the plain HTML file below runs Pele first and still gets a median of 19.1×.&lt;/p&gt;

&lt;p&gt;Across these sets the ratio sat between 14× and 20×. The gap stayed between 154 and 173 ms. Quote the gap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run it on your own diagram
&lt;/h2&gt;

&lt;p&gt;Save as &lt;code&gt;bench.html&lt;/code&gt;, swap in your diagram and open it in Chrome.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!doctype html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"host"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;pre&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"out"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;running…&lt;span class="nt"&gt;&amp;lt;/pre&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://cdn.jsdelivr.net/npm/pele@1.13.0/dist/pele.global.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://cdn.jsdelivr.net/npm/mermaid@12.2.0/dist/mermaid.min.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"module"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`flowchart TD
  A[Mermaid text] --&amp;gt; B{Flowchart?}
  B -- Yes --&amp;gt; C[Pele]
  B -- No --&amp;gt; D[Mermaid]
  C --&amp;gt; E([SVG])
  D --&amp;gt; E`&lt;/span&gt; &lt;span class="c1"&gt;// swap in your own diagram&lt;/span&gt;

    &lt;span class="nx"&gt;mermaid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;startOnLoad&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;securityLevel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;pelePut&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;host&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pele&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;svg&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mermaidPut&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;host&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;mermaid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;m&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nx"&gt;svg&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;median&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nf"&gt;pelePut&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;peleFirst&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;
    &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;mermaidPut&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mermaidFirst&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;pelePut&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;times&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;k&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="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;mermaidPut&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nx"&gt;times&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;slot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;median&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;times&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="c1"&gt;// One Pele render is too quick to time alone, so count how many fit in one Mermaid render.&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;warm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;slot&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;pelePut&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nx"&gt;warm&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`first render: Pele &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;peleFirst&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFixed&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="s2"&gt; ms, Mermaid &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;mermaidFirst&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFixed&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="s2"&gt; ms, &lt;/span&gt;&lt;span class="p"&gt;${(&lt;/span&gt;&lt;span class="nx"&gt;mermaidFirst&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;peleFirst&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toFixed&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="s2"&gt;x
warm: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;warm&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; Pele renders in one &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;slot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFixed&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="s2"&gt; ms Mermaid render`&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One run on the same M1 Pro, headless:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;first render: Pele 8.7 ms, Mermaid 167.9 ms, 19.3x
warm: 379 Pele renders in one 33.4 ms Mermaid render
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Render at build instead
&lt;/h2&gt;

&lt;p&gt;If your diagrams don't change in the browser, you can skip both client renderers. Pele's &lt;code&gt;render()&lt;/code&gt; runs in plain Node:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// npm i pele@1.13.0, then node build.mjs&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;writeFileSync&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;render&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pele&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;svg&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`flowchart TD
  A[Mermaid text] --&amp;gt; B{Flowchart?}
  B -- Yes --&amp;gt; C[Pele]
  B -- No --&amp;gt; D[Mermaid]
  C --&amp;gt; E([SVG])
  D --&amp;gt; E`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;diagram.svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;svg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;svg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;characters,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;undefined&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;no DOM&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;DOM&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: &lt;code&gt;3611 characters, no DOM&lt;/code&gt;. That's 1.1 kB gzipped. Mermaid's SVG for the same diagram, from Chrome, is 75 kB, or 18 kB gzipped. In plain Node, Mermaid throws &lt;code&gt;document is not defined&lt;/code&gt;, so a build needs &lt;a href="https://github.com/mermaid-js/mermaid-cli" rel="noopener noreferrer"&gt;mermaid-cli&lt;/a&gt;, with Puppeteer as a peer dependency.&lt;/p&gt;

&lt;p&gt;Node's SVG isn't byte-identical to Chrome's, which is 3,645 characters. Check it with your own fonts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Size
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;gzip -9&lt;/code&gt; of the published single-file bundles: &lt;a href="https://cdn.jsdelivr.net/npm/pele@1.13.0/dist/pele.js" rel="noopener noreferrer"&gt;Pele&lt;/a&gt; 273,493 bytes, &lt;a href="https://cdn.jsdelivr.net/npm/mermaid@12.2.0/dist/mermaid.min.js" rel="noopener noreferrer"&gt;Mermaid&lt;/a&gt; 1,566,733 bytes. That's 1,293,240 apart. &lt;a href="https://pele.run/" rel="noopener noreferrer"&gt;pele.run&lt;/a&gt; lists 230 kB. Your bundler and cache change what transfers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before you swap
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://pele.run/compatibility" rel="noopener noreferrer"&gt;Pele's compatibility page&lt;/a&gt; targets Mermaid 12.1.0 syntax, and says "Node positions, spacing, and edge paths differ from Mermaid." HTML labels, Mermaid themes, ZenUML and JavaScript &lt;code&gt;click&lt;/code&gt; callbacks are all listed as unsupported or ignored.&lt;/p&gt;

&lt;p&gt;Two quick checks with Mermaid at &lt;code&gt;securityLevel: 'loose'&lt;/code&gt;: an &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; in a label survives in Mermaid's SVG, while Pele keeps the word and drops the image. And &lt;code&gt;%%{init: {"theme":"forest"}}%%&lt;/code&gt; puts &lt;code&gt;#cde498&lt;/code&gt; in Mermaid's SVG, and not in Pele's.&lt;/p&gt;

&lt;p&gt;The maintained version, with which number applies to which kind of page, is on &lt;a href="https://argbe.tech/blog/pele-vs-mermaid-first-render-benchmark?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=pele-vs-mermaid-first-render-benchmark" rel="noopener noreferrer"&gt;argbe.tech&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>performance</category>
      <category>svg</category>
    </item>
    <item>
      <title>A nested loop does not always quadruple: Big O in the kitchen</title>
      <dc:creator>Aleksandr Argunov</dc:creator>
      <pubDate>Sat, 21 Nov 2026 18:34:00 +0000</pubDate>
      <link>https://dev.to/argbetech/a-nested-loop-does-not-always-quadruple-big-o-in-the-kitchen-eca</link>
      <guid>https://dev.to/argbetech/a-nested-loop-does-not-always-quadruple-big-o-in-the-kitchen-eca</guid>
      <description>&lt;p&gt;Double the cabbages and kimchi takes twice the work, with the same number of leaves per cabbage. Here, the work quadruples when both inputs double.&lt;/p&gt;

&lt;p&gt;Salting kimchi is &lt;code&gt;O(n × m)&lt;/code&gt;: &lt;code&gt;n&lt;/code&gt; cabbages, &lt;code&gt;m&lt;/code&gt; leaves each. Count the work, double one input, then divide by the original count. Compare that with two sequential loops for lasagne and a loop of binary searches for biryani.&lt;/p&gt;

&lt;p&gt;The biryani loop counts worst-case shelf probes; it doesn't search a real shelf. Save this as &lt;code&gt;kitchen-counts.mjs&lt;/code&gt; and run &lt;code&gt;node kitchen-counts.mjs&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;lasagne&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&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;let&lt;/span&gt; &lt;span class="nx"&gt;work&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;work&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="c1"&gt;// brown n batches of meat&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;work&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="c1"&gt;// then whisk m ladles of milk&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;work&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;biryani&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&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;let&lt;/span&gt; &lt;span class="nx"&gt;work&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="c1"&gt;// each of n spices&lt;/span&gt;
        &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&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="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="nx"&gt;work&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="c1"&gt;// halve a shelf of m jars&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;work&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;kimchi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&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;let&lt;/span&gt; &lt;span class="nx"&gt;work&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="c1"&gt;// each of n cabbages&lt;/span&gt;
        &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;work&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="c1"&gt;// salt each of m leaves&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;work&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;compareInputs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;work&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;base&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;times&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`×&lt;/span&gt;&lt;span class="p"&gt;${(&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toFixed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;n only&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nf"&gt;times&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;m only&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nf"&gt;times&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;both&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nf"&gt;times&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;m&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;compareInputs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lasagne&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;lasagne&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;compareInputs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;biryani&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;biryani&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;compareInputs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;kimchi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;kimchi&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lasagne 20 n only ×1.50 m only ×1.50 both ×2.00
biryani 70 n only ×2.00 m only ×1.14 both ×2.29
kimchi 200 n only ×2.00 m only ×2.00 both ×4.00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Swap in your own loops. Orders and line items behave like cabbages and leaves. So ask which input actually grows before you rewrite anything.&lt;/p&gt;

&lt;p&gt;Sedgewick and Wayne's &lt;a href="https://algs4.cs.princeton.edu/14analysis/" rel="noopener noreferrer"&gt;DoublingRatio&lt;/a&gt; doubles the input and compares running times. Counting operations keeps the machine out of it. Big O can't tell a slow pleat from a fast one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The ten dishes
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fauqwy6tqf1qtid7r6nd0.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fauqwy6tqf1qtid7r6nd0.gif" alt="Animated Big O cheat sheet of ten dishes, from a stir-fry's direct lookup to sushi's permutations. Three multipliers apply if both inputs double." width="760" height="950"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dish&lt;/th&gt;
&lt;th&gt;Big O&lt;/th&gt;
&lt;th&gt;Pattern&lt;/th&gt;
&lt;th&gt;Count&lt;/th&gt;
&lt;th&gt;Double the input&lt;/th&gt;
&lt;th&gt;Multiplier&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Stir-fry&lt;/td&gt;
&lt;td&gt;&lt;code&gt;O(1)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Direct lookup&lt;/td&gt;
&lt;td&gt;1 reach, 5 bowls&lt;/td&gt;
&lt;td&gt;1 reach, 10 bowls&lt;/td&gt;
&lt;td&gt;×1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hand-pulled noodles&lt;/td&gt;
&lt;td&gt;&lt;code&gt;O(log n)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Doubling loop&lt;/td&gt;
&lt;td&gt;8 folds, 256 strands&lt;/td&gt;
&lt;td&gt;9 folds, 512 strands&lt;/td&gt;
&lt;td&gt;+1 fold&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dumplings&lt;/td&gt;
&lt;td&gt;&lt;code&gt;O(n)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Single loop&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;×2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lasagne&lt;/td&gt;
&lt;td&gt;&lt;code&gt;O(n + m)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Sequential loops&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;40 (both)&lt;/td&gt;
&lt;td&gt;×2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Biryani&lt;/td&gt;
&lt;td&gt;&lt;code&gt;O(n log m)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Loop + binary search&lt;/td&gt;
&lt;td&gt;70 looks&lt;/td&gt;
&lt;td&gt;160 looks (both)&lt;/td&gt;
&lt;td&gt;×2.29&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cheese board&lt;/td&gt;
&lt;td&gt;&lt;code&gt;O(n log n)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Divide and conquer&lt;/td&gt;
&lt;td&gt;17 comparisons, 8 cheeses&lt;/td&gt;
&lt;td&gt;49 comparisons, 16 cheeses&lt;/td&gt;
&lt;td&gt;×2.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kimchi&lt;/td&gt;
&lt;td&gt;&lt;code&gt;O(n × m)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Nested loop&lt;/td&gt;
&lt;td&gt;200&lt;/td&gt;
&lt;td&gt;800 (both)&lt;/td&gt;
&lt;td&gt;×4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pizza&lt;/td&gt;
&lt;td&gt;&lt;code&gt;O(n²)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Triangular loop&lt;/td&gt;
&lt;td&gt;45 pairs, 10 toppings&lt;/td&gt;
&lt;td&gt;190 pairs, 20 toppings&lt;/td&gt;
&lt;td&gt;×4.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Burger&lt;/td&gt;
&lt;td&gt;&lt;code&gt;O(2ⁿ)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Branching recursion&lt;/td&gt;
&lt;td&gt;1,024, 10 extras&lt;/td&gt;
&lt;td&gt;1,048,576, 20 extras&lt;/td&gt;
&lt;td&gt;×1,024&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sushi&lt;/td&gt;
&lt;td&gt;&lt;code&gt;O(n!)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Permutations&lt;/td&gt;
&lt;td&gt;3,628,800, 10 pieces&lt;/td&gt;
&lt;td&gt;2,432,902,008,176,640,000, 20 pieces&lt;/td&gt;
&lt;td&gt;×670 billion&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Cheese board counts worst-case merge sort comparisons (&lt;a href="https://ocw.mit.edu/courses/6-1200j-mathematics-for-computer-science-spring-2024/1FNT1pqfHkqCM0hCRYhxyTdft3NSBvoU-_transcript.pdf" rel="noopener noreferrer"&gt;MIT&lt;/a&gt;). Biryani counts worst-case probes on a sorted shelf with random access and constant-cost comparisons: 10 spices, 100 jars initially. The GIF's ×2.3 uses the &lt;code&gt;n log₂ m&lt;/code&gt; formula; whole probes give ×2.29. Stir-fry uses a known spot; hash lookup is only expected &lt;code&gt;O(1)&lt;/code&gt; (&lt;a href="https://ocw.mit.edu/courses/6-006-introduction-to-algorithms-fall-2011/pages/lecture-notes/" rel="noopener noreferrer"&gt;MIT 6.006&lt;/a&gt;). Sushi counts orders of distinct pieces.&lt;/p&gt;

&lt;p&gt;If you count sushi in JavaScript, use &lt;code&gt;BigInt&lt;/code&gt;. From 19 pieces, the count passes &lt;code&gt;Number.MAX_SAFE_INTEGER&lt;/code&gt; (&lt;a href="https://oeis.org/A000142" rel="noopener noreferrer"&gt;factorials&lt;/a&gt;). &lt;a href="https://argbe.tech/blog/javascript-number-precision-ids?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=big-o-notation-kitchen" rel="noopener noreferrer"&gt;Past that, large numbers can round with no error&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The noodles have prior art. &lt;a href="https://www.je-lks.org/ojs/index.php/Je-LKS_EN/article/download/1399/1028/" rel="noopener noreferrer"&gt;Luisa Mich and Daniel Berry&lt;/a&gt; taught complexity through noodle making in 2018.&lt;/p&gt;

&lt;h2&gt;
  
  
  What doubling doesn't tell you
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One ratio isn't a class.&lt;/strong&gt; Merge sort gives ×2.9 from 8 to 16 items, and ×2.22 from 1,024 to 2,048. Pizza gives ×4.2 at 10 toppings and ×4.002 at 1,000. &lt;a href="https://www.cs.cmu.edu/~mgormley/courses/ml-primer/bigO.html" rel="noopener noreferrer"&gt;Big O is an upper bound on growth&lt;/a&gt;, not a fixed multiplier. Compare a few doublings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explosions need a smaller step.&lt;/strong&gt; Burgers give ×1,024 from 10 to 20 extras, and ×1,048,576 from 20 to 40. The multiplier grows with the input. So add one instead. An 11th extra gives ×2. An 11th sushi piece gives ×11.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The kitchen is a model.&lt;/strong&gt; Every fold counts the same here, however hard the real stretch is. If leaves per cabbage vary, sum the leaves. Dishes are teaching devices, not timed recipes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Options aren't work until someone tries them.&lt;/strong&gt; Printing all 1,024 burgers as ten-bit masks takes 10,240 characters. That's more work than the count suggests. Serving one sushi order is the opposite. Trying all 3,628,800 is factorial. The chef serves one, from experience.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The maintained version, with every dish in full and the sources: &lt;a href="https://argbe.tech/blog/big-o-notation-kitchen?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=big-o-notation-kitchen" rel="noopener noreferrer"&gt;Big O in ten dishes&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Same message, four fates: SQS, SNS, Kafka and Redis Pub/Sub when a worker crashes</title>
      <dc:creator>Aleksandr Argunov</dc:creator>
      <pubDate>Fri, 20 Nov 2026 10:52:00 +0000</pubDate>
      <link>https://dev.to/argbetech/same-message-four-fates-sqs-sns-kafka-and-redis-pubsub-when-a-worker-crashes-3o1b</link>
      <guid>https://dev.to/argbetech/same-message-four-fates-sqs-sns-kafka-and-redis-pubsub-when-a-worker-crashes-3o1b</guid>
      <description>&lt;p&gt;Every broker delivers when nothing breaks. So compare them on the crash.&lt;/p&gt;

&lt;p&gt;SQS = a take-a-number ticket. SNS = a group text. Kafka = a tape recorder. Redis Pub/Sub = live radio.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://argbe.tech/blog/sqs-sns-kafka-redis-failure-modes?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=sqs-sns-kafka-redis-failure-modes" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3r1zgblsdcvtkkh13m0r.gif" alt="Animated grid titled Same message. Four fates. SQS, SNS, Kafka and Redis Pub/Sub, drawn as a ticket, group text, tape recorder and radio, act out four failure cases." width="760" height="950"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The grid
&lt;/h2&gt;

&lt;p&gt;Kafka here means ordinary consumer groups. Share groups get their own section below.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Case&lt;/th&gt;
&lt;th&gt;SQS&lt;/th&gt;
&lt;th&gt;SNS&lt;/th&gt;
&lt;th&gt;Kafka&lt;/th&gt;
&lt;th&gt;Redis Pub/Sub&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Who gets it&lt;/td&gt;
&lt;td&gt;Competing workers; standard can duplicate&lt;/td&gt;
&lt;td&gt;Every matching subscription&lt;/td&gt;
&lt;td&gt;Each subscribed group; one owner per partition&lt;/td&gt;
&lt;td&gt;Matching subscribers connected now&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A worker dies&lt;/td&gt;
&lt;td&gt;Undeleted message becomes visible after timeout&lt;/td&gt;
&lt;td&gt;Retryable delivery failures get retries&lt;/td&gt;
&lt;td&gt;Resumes from committed offsets&lt;/td&gt;
&lt;td&gt;No replay&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It keeps failing&lt;/td&gt;
&lt;td&gt;DLQ with a redrive policy&lt;/td&gt;
&lt;td&gt;Subscription DLQ for failed delivery, if configured&lt;/td&gt;
&lt;td&gt;Your code decides&lt;/td&gt;
&lt;td&gt;Nothing to retry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It arrives twice&lt;/td&gt;
&lt;td&gt;Standard can; FIFO deduplicates sends within its window and scope&lt;/td&gt;
&lt;td&gt;Standard can; FIFO deduplicates publishes within its window and scope&lt;/td&gt;
&lt;td&gt;Uncommitted work can repeat&lt;/td&gt;
&lt;td&gt;No redelivery; overlapping subscriptions can duplicate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nobody listening&lt;/td&gt;
&lt;td&gt;Retained up to 14 days, default 4&lt;/td&gt;
&lt;td&gt;Standard keeps nothing for later subscribers&lt;/td&gt;
&lt;td&gt;Replay while records remain retained&lt;/td&gt;
&lt;td&gt;Gone&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Sources: &lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html" rel="noopener noreferrer"&gt;SQS visibility&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/quotas-messages.html" rel="noopener noreferrer"&gt;SQS quotas&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html" rel="noopener noreferrer"&gt;SQS DLQ&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/sns/latest/dg/sns-message-filtering.html" rel="noopener noreferrer"&gt;SNS filtering&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/sns/latest/dg/sns-message-delivery-retries.html" rel="noopener noreferrer"&gt;SNS retries&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/sns/latest/dg/sns-dead-letter-queues.html" rel="noopener noreferrer"&gt;SNS DLQ&lt;/a&gt;, &lt;a href="https://kafka.apache.org/42/design/design/" rel="noopener noreferrer"&gt;Kafka design&lt;/a&gt;, &lt;a href="https://redis.io/docs/latest/develop/pubsub/" rel="noopener noreferrer"&gt;Redis Pub/Sub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;SNS retries cover delivery, not your work. Once SNS receives an HTTP endpoint's &lt;a href="https://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.prepare.html" rel="noopener noreferrer"&gt;success response&lt;/a&gt;, a later worker crash doesn't trigger a retry. When delivery retries run out, SNS &lt;a href="https://docs.aws.amazon.com/sns/latest/dg/sns-message-delivery-retries.html" rel="noopener noreferrer"&gt;discards the message&lt;/a&gt; unless a dead-letter queue is attached.&lt;/p&gt;

&lt;p&gt;SNS FIFO can &lt;a href="https://docs.aws.amazon.com/sns/latest/dg/fifo-message-archiving-replay.html" rel="noopener noreferrer"&gt;archive and replay&lt;/a&gt; when configured. Kafka replay also has limits: deletion and &lt;a href="https://kafka.apache.org/42/design/design/" rel="noopener noreferrer"&gt;compaction&lt;/a&gt; can remove history.&lt;/p&gt;

&lt;h2&gt;
  
  
  Crash on both sides of the side effect
&lt;/h2&gt;

&lt;p&gt;Say the handler charges a card, without idempotency or a durable handoff. Crash it before the charge, then after the charge succeeds.&lt;/p&gt;

&lt;p&gt;For after-work acknowledgement, the crash happens &lt;strong&gt;before deletion or offset commit&lt;/strong&gt;. For before-work acknowledgement, the commit or HTTP success has already been accepted. Assume a healthy broker and retained messages still eligible for recovery.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Setup&lt;/th&gt;
&lt;th&gt;Crash before the charge&lt;/th&gt;
&lt;th&gt;Crash after the charge succeeds&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SQS, delete after work&lt;/td&gt;
&lt;td&gt;Eligible for retry after timeout&lt;/td&gt;
&lt;td&gt;Eligible for retry; charge may repeat&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kafka consumer group, commit after work&lt;/td&gt;
&lt;td&gt;Re-read on recovery&lt;/td&gt;
&lt;td&gt;Re-read on recovery; charge may repeat&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kafka consumer group, commit before work&lt;/td&gt;
&lt;td&gt;Skipped on recovery; charge missed&lt;/td&gt;
&lt;td&gt;Skipped on recovery; charge already made&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SNS to HTTP, success received before work&lt;/td&gt;
&lt;td&gt;No retry for this crash; charge missed&lt;/td&gt;
&lt;td&gt;No retry for this crash; charge already made&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Redis Pub/Sub, one subscription&lt;/td&gt;
&lt;td&gt;No replay; charge missed&lt;/td&gt;
&lt;td&gt;No replay; charge already made&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These are failure traces inferred from &lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html" rel="noopener noreferrer"&gt;SQS&lt;/a&gt;, &lt;a href="https://kafka.apache.org/42/design/design/" rel="noopener noreferrer"&gt;Kafka&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.prepare.html" rel="noopener noreferrer"&gt;SNS&lt;/a&gt; and &lt;a href="https://redis.io/docs/latest/develop/pubsub/" rel="noopener noreferrer"&gt;Redis&lt;/a&gt; docs, not live broker tests. They show recovery paths, not guaranteed charge counts. Expiration, dead-letter routing or further failures can prevent completion.&lt;/p&gt;

&lt;p&gt;Acknowledge before the work, and a crash can lose it. Acknowledge after, and a crash can repeat it. Kill your worker at both points to check your handler.&lt;/p&gt;

&lt;p&gt;For the charge, reuse a payment-provider idempotency key on retries, within its retention rules (&lt;a href="https://docs.stripe.com/api/idempotent_requests" rel="noopener noreferrer"&gt;Stripe's example&lt;/a&gt;). Writing a local "done" flag after charging leaves the same crash window. Kafka transactions can coordinate Kafka outputs and offsets; an &lt;a href="https://kafka.apache.org/42/design/design/" rel="noopener noreferrer"&gt;external payment still needs cooperation from the payment system&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  SQS FIFO, long-running jobs and the 12-hour limit
&lt;/h2&gt;

&lt;p&gt;An SQS FIFO queue can still run your job twice. Its &lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/designing-for-outage-recovery-scenarios.html" rel="noopener noreferrer"&gt;deduplication window&lt;/a&gt; of 5 minutes covers repeated sends with the same deduplication ID, within the configured &lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SetQueueAttributes.html" rel="noopener noreferrer"&gt;queue or message-group scope&lt;/a&gt;. It doesn't prevent redelivery after a visibility timeout. SNS FIFO has its own &lt;a href="https://docs.aws.amazon.com/sns/latest/dg/fifo-message-dedup.html" rel="noopener noreferrer"&gt;five-minute window and topic or message-group scope&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;That matters for long AI agent runs. The visibility timeout has a ceiling of &lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/best-practices-processing-messages-timely-manner.html" rel="noopener noreferrer"&gt;12 hours from SQS receiving the &lt;code&gt;ReceiveMessage&lt;/code&gt; request&lt;/a&gt;. Extending it doesn't reset that. Once it expires, another worker can receive the undeleted message while the first may still be going. FIFO also blocks further receives for that group while messages are in flight.&lt;/p&gt;

&lt;p&gt;For long jobs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Call &lt;code&gt;ChangeMessageVisibility&lt;/code&gt; as a heartbeat while the work runs.&lt;/li&gt;
&lt;li&gt;Split the work before the ceiling. AWS suggests smaller steps or Step Functions. Keep progress outside the queue.&lt;/li&gt;
&lt;li&gt;Put an idempotency key on each side effect.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Kafka's answer changed
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Setup&lt;/th&gt;
&lt;th&gt;A record that keeps failing&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Ordinary consumer group&lt;/td&gt;
&lt;td&gt;Your code decides.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Share group, 4.2&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://kafka.apache.org/42/configuration/broker-configs/#group.share.delivery.count.limit" rel="noopener noreferrer"&gt;&lt;code&gt;group.share.delivery.count.limit&lt;/code&gt;&lt;/a&gt; caps attempts: default 5, range 2 to 10. That isn't a DLQ.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Share group, 4.4&lt;/td&gt;
&lt;td&gt;Configurable DLQs. Enable &lt;code&gt;share.version=2&lt;/code&gt; and set the group's &lt;code&gt;errors.deadletterqueue.topic.name&lt;/code&gt; (&lt;a href="https://kafka.apache.org/44/getting-started/upgrade/" rel="noopener noreferrer"&gt;Apache&lt;/a&gt;).&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That topic name must use the configured prefix, &lt;code&gt;dlq.&lt;/code&gt; by default. Auto-creation is off by default: create the topic and set its &lt;code&gt;errors.deadletterqueue.group.enable=true&lt;/code&gt;, or enable cluster auto-creation. The DLQ stores metadata by default. Set the group's &lt;code&gt;errors.deadletterqueue.copy.record.enable=true&lt;/code&gt; to include the original record (&lt;a href="https://kafka.apache.org/44/getting-started/upgrade/" rel="noopener noreferrer"&gt;Apache&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Different clocks
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Clock&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SQS retention&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/quotas-messages.html" rel="noopener noreferrer"&gt;4 days by default, 14 at most&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SQS visibility timeout&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html" rel="noopener noreferrer"&gt;30 seconds by default, 12 hours per receive at most&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SQS FIFO deduplication&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/designing-for-outage-recovery-scenarios.html" rel="noopener noreferrer"&gt;5 minutes&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SNS FIFO deduplication&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/sns/latest/dg/fifo-message-dedup.html" rel="noopener noreferrer"&gt;5 minutes&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SNS retries to SQS or Lambda&lt;/td&gt;
&lt;td&gt;&lt;a href="https://docs.aws.amazon.com/sns/latest/dg/sns-message-delivery-retries.html" rel="noopener noreferrer"&gt;100,015 attempts over 23 days for retryable delivery errors&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kafka share-group delivery limit&lt;/td&gt;
&lt;td&gt;&lt;a href="https://kafka.apache.org/42/configuration/broker-configs/#group.share.delivery.count.limit" rel="noopener noreferrer"&gt;5 attempts by default&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  How to pick
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Jobs that must survive a crash go on SQS.&lt;/li&gt;
&lt;li&gt;Long AI agent runs too, with a heartbeat and checkpoints.&lt;/li&gt;
&lt;li&gt;One event for many services goes to SNS, often fanned out into SQS queues.&lt;/li&gt;
&lt;li&gt;History you want to replay lives in Kafka.&lt;/li&gt;
&lt;li&gt;For order per customer, use &lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues-understanding-logic.html" rel="noopener noreferrer"&gt;SQS FIFO message groups&lt;/a&gt;, or a &lt;a href="https://kafka.apache.org/42/design/design/" rel="noopener noreferrer"&gt;Kafka key that consistently maps to one partition&lt;/a&gt;. The handler must preserve that order. Moving a failed FIFO message to a &lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html" rel="noopener noreferrer"&gt;DLQ can break it&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Live updates you can afford to miss, like typing indicators, fit Redis Pub/Sub. If you need them kept, use &lt;a href="https://redis.io/docs/latest/develop/data-types/streams/" rel="noopener noreferrer"&gt;Redis Streams&lt;/a&gt;, with durability determined by persistence and replication settings.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every broker works on a good day. Pick the one whose bad day you can live with.&lt;/p&gt;

&lt;p&gt;The maintained article is &lt;a href="https://argbe.tech/blog/sqs-sns-kafka-redis-failure-modes?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=sqs-sns-kafka-redis-failure-modes" rel="noopener noreferrer"&gt;on argbe.tech&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>kafka</category>
      <category>aws</category>
      <category>redis</category>
      <category>architecture</category>
    </item>
    <item>
      <title>A RAG answer can cite every sentence and still be wrong: a script to reproduce it</title>
      <dc:creator>Aleksandr Argunov</dc:creator>
      <pubDate>Thu, 19 Nov 2026 07:49:00 +0000</pubDate>
      <link>https://dev.to/argbetech/a-rag-answer-can-cite-every-sentence-and-still-be-wrong-a-script-to-reproduce-it-4804</link>
      <guid>https://dev.to/argbetech/a-rag-answer-can-cite-every-sentence-and-still-be-wrong-a-script-to-reproduce-it-4804</guid>
      <description>&lt;p&gt;Every sentence was cited. The answer was still wrong.&lt;/p&gt;

&lt;p&gt;Ask a company AI whether you can refund a customer after last month's exception. It finds the contract, quotes the 30-day rule and says no, with a citation. The exception sits in an email it never searched.&lt;/p&gt;

&lt;p&gt;Here's that failure as a script you can run. It has no API key, no model and no embeddings. The refund is a made-up example.&lt;/p&gt;

&lt;p&gt;I framed the post as “&lt;a href="https://www.linkedin.com/posts/aleksandr-argunov_rag-aiagents-llm-share-7522522871798116352-Ox_B" rel="noopener noreferrer"&gt;RAG in 2023 vs 2026&lt;/a&gt;”: search once versus check and search again. The dates are shorthand. &lt;a href="https://www.anthropic.com/research/contextual-retrieval" rel="noopener noreferrer"&gt;Anthropic's Contextual Retrieval&lt;/a&gt; already combined hybrid search and reranking in 2024.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://argbe.tech/blog/adaptive-hybrid-rag-loop?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=adaptive-hybrid-rag-loop" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F977g3ez3b5fv0ilntkf5.gif" alt="A poster compares searching once with a loop. One search answers no and misses the exception. The six-step loop finds the email on its second round and answers yes, with citations." width="760" height="950"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The script
&lt;/h2&gt;

&lt;p&gt;Save this as &lt;code&gt;rag_loop.py&lt;/code&gt;. It uses only Python's standard library, with &lt;a href="https://www.sqlite.org/fts5.html" rel="noopener noreferrer"&gt;SQLite's FTS5&lt;/a&gt; enabled for BM25 search. Python 3.9 and 3.15 print the same output.&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="c1"&gt;# Synthetic data. BM25 and the permission filter are real (SQLite FTS5).
# The check and the answers are keyword rules, so no model or API is needed.
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sqlite3&lt;/span&gt;

&lt;span class="n"&gt;MAX_ROUNDS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;

&lt;span class="n"&gt;DOCS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;  &lt;span class="c1"&gt;# id, source, who may read it, text
&lt;/span&gt;    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;contract-s4&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;contract&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;all&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Section 4 Refunds. Customers may request a refund within 30 days of purchase.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;contract-s9&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;contract&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;all&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Section 9 Renewals. Renewal notice is due 30 days before the term ends.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ticket-118&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ticket&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;all&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Acme asked for a refund on day 41. Waiting on finance. No decision yet.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;email-1012&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;email&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;finance&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;12 October. Finance director approved a one-time refund exception for Acme.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sqlite3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;:memory:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;db&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;CREATE VIRTUAL TABLE docs USING fts5(id UNINDEXED, source UNINDEXED, readers UNINDEXED, text)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;executemany&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;INSERT INTO docs VALUES (?, ?, ?, ?)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;DOCS&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;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# The permission filter sits inside the query, so every repeat search gets it too.
&lt;/span&gt;    &lt;span class="n"&gt;sql&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;SELECT id, text, readers FROM docs
             WHERE docs MATCH ? AND source = ? AND readers IN (&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;all&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;, ?)
             ORDER BY bm25(docs) LIMIT ?&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;hits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&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;sql&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; OR &lt;/span&gt;&lt;span class="sh"&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;words&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;fetchall&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;readers&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;all&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;role&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;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;readers&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;permission leak&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;hits&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;proven&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;proof&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# shortcut: a keyword rule stands in for the model. Ask a model here in a real system.
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;doc_id&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;doc_id&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;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;hits&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="ow"&gt;in&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;lower&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;w&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;proof&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&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;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;loop&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;  customer=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; role=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;needs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  &lt;span class="c1"&gt;# sources to try in order, search words, words that count as proof
&lt;/span&gt;        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;rule&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;contract&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;refund&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;days&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;refund&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;30 days&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;exception&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ticket&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;email&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;drive&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;refund&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;exception&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;approved&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()]),&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;queues&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;need&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spec&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="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;need&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;spec&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;needs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;queues&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;exception&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;  &lt;span class="c1"&gt;# The single search never looks for the exception.
&lt;/span&gt;    &lt;span class="n"&gt;limit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;MAX_ROUNDS&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;loop&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&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="n"&gt;limit&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;need&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;proof&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;needs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&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;need&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;evidence&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;queues&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;need&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;
            &lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;queues&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;need&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;pop&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="n"&gt;hits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hit&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="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;hit&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;  round &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;need&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; -&amp;gt; &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;hit&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="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;hit&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;nothing&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&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;found&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;proven&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;proof&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
                &lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;need&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;found&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;needs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;

    &lt;span class="n"&gt;missing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;need&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;need&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;needs&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;need&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;missing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;reply&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Yes. &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; has an approved exception to the 30-day limit. [&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;rule&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;] [&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;exception&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;]&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;reply&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Partly. The limit is 30 days. [&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;rule&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;] Could not confirm: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;missing&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&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;reply&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;No. Refunds end 30 days after purchase. [&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;rule&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;]&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;cited&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc_id&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;doc_id&lt;/span&gt; &lt;span class="ow"&gt;in&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="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;\[([\w-]+)\]&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reply&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;  answer: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;reply&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;  cited: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;yes&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;cited&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;no&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;  sufficient: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;no&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;missing&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;yes&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;  rounds: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;A. Search once&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Acme&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;finance&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;loop&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;B. Loop&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Acme&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;finance&lt;/span&gt;&lt;span class="sh"&gt;"&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;C. Loop, no permission to read that email&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Acme&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;support&lt;/span&gt;&lt;span class="sh"&gt;"&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;D. Loop, no exception exists&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Globex&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;finance&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 rag_loop.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A. Search once
  customer=Acme role=finance
  round 1: rule -&amp;gt; contract: ['contract-s4', 'contract-s9']
  answer: No. Refunds end 30 days after purchase. [contract-s4]
  cited: yes  sufficient: no  rounds: 1/1

B. Loop
  customer=Acme role=finance
  round 1: rule -&amp;gt; contract: ['contract-s4', 'contract-s9']
  round 1: exception -&amp;gt; ticket: ['ticket-118']
  round 2: exception -&amp;gt; email: ['email-1012']
  answer: Yes. Acme has an approved exception to the 30-day limit. [contract-s4] [email-1012]
  cited: yes  sufficient: yes  rounds: 2/3

C. Loop, no permission to read that email
  customer=Acme role=support
  round 1: rule -&amp;gt; contract: ['contract-s4', 'contract-s9']
  round 1: exception -&amp;gt; ticket: ['ticket-118']
  round 2: exception -&amp;gt; email: nothing
  round 3: exception -&amp;gt; drive: nothing
  answer: Partly. The limit is 30 days. [contract-s4] Could not confirm: exception.
  cited: yes  sufficient: no  rounds: 3/3

D. Loop, no exception exists
  customer=Globex role=finance
  round 1: rule -&amp;gt; contract: ['contract-s4', 'contract-s9']
  round 1: exception -&amp;gt; ticket: ['ticket-118']
  round 2: exception -&amp;gt; email: ['email-1012']
  round 3: exception -&amp;gt; drive: nothing
  answer: Partly. The limit is 30 days. [contract-s4] Could not confirm: exception.
  cited: yes  sufficient: no  rounds: 3/3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The search and permission filter execute in SQLite. Source order, sufficiency and answers are fixed rules. This reproduces control flow, not retrieval quality. &lt;code&gt;cited: yes&lt;/code&gt; only checks that cited IDs appeared in retrieved results; it doesn't check whether they support the answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  What each run tests
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A: missing source.&lt;/strong&gt; &lt;code&gt;cited: yes&lt;/code&gt; and &lt;code&gt;sufficient: no&lt;/code&gt; on the same line. A citation doesn't prove the answer is complete. A reranker won't help, because &lt;a href="https://docs.voyageai.com/docs/reranker" rel="noopener noreferrer"&gt;it scores the documents you give it&lt;/a&gt;. It can't add the missing email.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B: bounded repeat.&lt;/strong&gt; The ticket mentions the refund but holds no decision. So the next round searches email, finds it and stops at round 2 of 3.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C: permission limit.&lt;/strong&gt; The filter is inside the SQL, so the repeat search gets it too. The email never comes back, and the answer names what's missing. The role is a fixture; in production, derive it from authenticated identity. &lt;a href="https://learn.microsoft.com/en-us/azure/search/search-document-level-access-overview" rel="noopener noreferrer"&gt;Enforce access at the search&lt;/a&gt;, and again when a source document is opened.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;D: no answer exists.&lt;/strong&gt; Search returns the Acme email for Globex. The check doesn't count it. The &lt;code&gt;for&lt;/code&gt; loop ends at the cap, so the question can't spin forever. A real loop also needs time and token limits, enforced in code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Now break it
&lt;/h2&gt;

&lt;p&gt;Add this line to &lt;code&gt;DOCS&lt;/code&gt;, after the approval email:&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="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;email-1020&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;email&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;finance&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;20 October. Finance director withdrew the Acme refund exception.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run B now prints this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  round 2: exception -&amp;gt; email: ['email-1020', 'email-1012']
  answer: Yes. Acme has an approved exception to the 30-day limit. [contract-s4] [email-1012]
  cited: yes  sufficient: yes  rounds: 2/3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The withdrawal ranks first. The answer still says yes. Every sentence is cited, and the answer is wrong again.&lt;/p&gt;

&lt;p&gt;The check only asks whether an approval exists. A real one also asks whether it applies, whether that person could approve it, and whether it still stands. So test on conflicting versions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this stops
&lt;/h2&gt;

&lt;p&gt;The script exercises keyword search, a deliberately weak sufficiency check, and a round cap. It doesn't test vector retrieval, reranking or exact-ID matching. The full design adds contextual chunks, query planning, hybrid search and reranking. &lt;a href="https://research.google/blog/unlocking-dependable-responses-with-gemini-enterprise-agent-platforms-agentic-rag/" rel="noopener noreferrer"&gt;Google's agentic RAG framework&lt;/a&gt; treats sufficient context as its own check.&lt;/p&gt;

&lt;p&gt;For a real benchmark, keep the synthetic cases and replace the fixed routing, keyword checks and canned answers. Compare vector-only retrieval, hybrid, hybrid plus reranking, and a capped loop. Log how much required evidence reaches the top results, answer correctness, tokens and wall time.&lt;/p&gt;

&lt;p&gt;I wouldn't build the whole loop on day one. A simple lookup should skip it. Start with hybrid search and a reranker, measure on real questions, and add planning or a second round only where that test set fails.&lt;/p&gt;

&lt;p&gt;The maintained article, with all six steps and the models I'd benchmark for each, is &lt;a href="https://argbe.tech/blog/adaptive-hybrid-rag-loop?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=adaptive-hybrid-rag-loop" rel="noopener noreferrer"&gt;on argbe.tech&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>rag</category>
      <category>ai</category>
      <category>python</category>
      <category>testing</category>
    </item>
    <item>
      <title>TypeScript checker benchmark: 309 errors or none, on the same repo</title>
      <dc:creator>Aleksandr Argunov</dc:creator>
      <pubDate>Tue, 17 Nov 2026 14:08:00 +0000</pubDate>
      <link>https://dev.to/argbetech/typescript-checker-benchmark-309-errors-or-none-on-the-same-repo-lne</link>
      <guid>https://dev.to/argbetech/typescript-checker-benchmark-309-errors-or-none-on-the-same-repo-lne</guid>
      <description>&lt;p&gt;Run five TypeScript checkers on a fresh clone of date-fns and you get the same 309 errors. Run &lt;code&gt;bun check&lt;/code&gt; and you get none. Same commit, same package.&lt;/p&gt;

&lt;p&gt;Six new checkers appeared in 14 days. Their own benchmarks report up to &lt;a href="https://github.com/oxc-project/tsrs/blob/1578291bf13c1a747557c79d6927a459a87fb0f1/bench/RESULTS.md" rel="noopener noreferrer"&gt;11.4× over TypeScript 7&lt;/a&gt;. The best independent number is &lt;a href="https://github.com/danfry1/ts-checker-bench/blob/main/results/2026-10-19-apple-m5-darwin/report.md" rel="noopener noreferrer"&gt;5.8× on VS Code&lt;/a&gt;. So here's a smaller test that looks at diagnostics first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Independent numbers so far
&lt;/h2&gt;

&lt;p&gt;Against TypeScript 7.0.2, at default threads:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Checker&lt;/th&gt;
&lt;th&gt;type-fest&lt;/th&gt;
&lt;th&gt;Outline&lt;/th&gt;
&lt;th&gt;VS Code&lt;/th&gt;
&lt;th&gt;NestJS app&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;tsrs&lt;/td&gt;
&lt;td&gt;4.3×&lt;/td&gt;
&lt;td&gt;5.6×&lt;/td&gt;
&lt;td&gt;5.8×&lt;/td&gt;
&lt;td&gt;3.64×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;bun check&lt;/td&gt;
&lt;td&gt;5.7×&lt;/td&gt;
&lt;td&gt;3.7×&lt;/td&gt;
&lt;td&gt;3.3×&lt;/td&gt;
&lt;td&gt;1.79×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;tsc-ts&lt;/td&gt;
&lt;td&gt;4.5×&lt;/td&gt;
&lt;td&gt;3.7×&lt;/td&gt;
&lt;td&gt;2.2×&lt;/td&gt;
&lt;td&gt;not run&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;tsc-rs&lt;/td&gt;
&lt;td&gt;3.3×&lt;/td&gt;
&lt;td&gt;2.5×&lt;/td&gt;
&lt;td&gt;2.4×&lt;/td&gt;
&lt;td&gt;2.46×&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The first three columns are &lt;a href="https://github.com/danfry1/ts-checker-bench/blob/main/results/2026-10-19-apple-m5-darwin/report.md" rel="noopener noreferrer"&gt;Daniel Fry's run&lt;/a&gt;, on an Apple M5, Oct 19. The last is &lt;a href="https://github.com/AiHub-Ecosystem/aihub-be/blob/7b9aeaa82bb7b4bb631094609e604c2697923948/docs/research/typescript-type-checker-options.md" rel="noopener noreferrer"&gt;AIHUB BE's run&lt;/a&gt;, on a 4-vCPU GitHub runner, Oct 21. In Fry's VS Code run, tsrs falls from 5.8× to 4.2× at four threads and 3.2× at one. It also reports 10 extra errors against 7.0.2, because it tracks 7.1-dev.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;Retest date: Nov 3, 2026. Machine: Apple M1 Pro, 10 CPUs, 16 GiB, macOS 27.0.1, AC power, Node v26.13.0. It wasn't idle: 1-minute load ranged from 6.5 to 28.7. ts-r, tsc-haxe and tsz weren't tested.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"checkers"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"private"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"ts702"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm:typescript@7.0.2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"ts71beta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm:typescript@7.1.0-beta"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"tsc-rs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0.8.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"tsc-ts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0.1.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"tsrs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0.20.1-ts7.1.0-beta"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"bun"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.4.4"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--ignore-scripts&lt;/span&gt; &lt;span class="nt"&gt;--no-audit&lt;/span&gt; &lt;span class="nt"&gt;--no-fund&lt;/span&gt;
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;node_modules/bun &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; node install.js&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$PWD&lt;/span&gt;/node_modules
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  309 errors, or none
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/date-fns/date-fns.git &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;date-fns
git checkout a9739fb3e538
pnpm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--ignore-scripts&lt;/span&gt; &lt;span class="nt"&gt;--frozen-lockfile&lt;/span&gt;
&lt;span class="nv"&gt;$C&lt;/span&gt;/ts702/bin/tsc &lt;span class="nt"&gt;-p&lt;/span&gt; pkgs/core &lt;span class="nt"&gt;--noEmit&lt;/span&gt; &lt;span class="nt"&gt;--pretty&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"exit &lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nv"&gt;$C&lt;/span&gt;/.bin/bun check &lt;span class="nt"&gt;-p&lt;/span&gt; pkgs/core &lt;span class="nt"&gt;--no-script&lt;/span&gt; &lt;span class="nt"&gt;--no-pretty&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"exit &lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pkgs/core/scripts/build/fp.ts(10,43): error TS6305: Output file '&amp;lt;repo&amp;gt;/pkgs/docs/.ts/src/index.d.ts' has not been built from source file '&amp;lt;repo&amp;gt;/pkgs/docs/src/index.ts'.
... 309 diagnostics in total ...
exit 1
✓ No type errors in 1,695 files [394.05ms]
exit 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Checker&lt;/th&gt;
&lt;th&gt;Errors&lt;/th&gt;
&lt;th&gt;Exit&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;TypeScript 7.0.2&lt;/td&gt;
&lt;td&gt;309&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TypeScript 7.1 beta&lt;/td&gt;
&lt;td&gt;309&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;tsc-rs 0.8.0&lt;/td&gt;
&lt;td&gt;309&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;tsc-ts 0.1.0&lt;/td&gt;
&lt;td&gt;309&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;tsrs 0.20.1&lt;/td&gt;
&lt;td&gt;309&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;bun check 1.4.4&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The five tsc-style outputs hash the same once the clone path is removed. Of the 309, 307 are TS6305. &lt;code&gt;bun check --help&lt;/code&gt; says references are followed "and nothing has to be built first". After &lt;code&gt;tsc -b&lt;/code&gt; with 7.0.2, all six exit 0. bun check counts 1,695 files and 7.0.2 counts 2,287, and this run didn't reconcile them.&lt;/p&gt;

&lt;p&gt;The root is worse. &lt;code&gt;tsc -p . --extendedDiagnostics&lt;/code&gt; prints &lt;code&gt;Files: 0&lt;/code&gt;, because the root config has &lt;code&gt;"include": []&lt;/code&gt; and only references. All five exit 0.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seeded errors
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;test-d/seeded-error.ts&lt;/code&gt; in type-fest at &lt;a href="https://github.com/sindresorhus/type-fest/tree/b550b410e13ff6bf9e1467b863b6ebd120e70781" rel="noopener noreferrer"&gt;b550b410e13f&lt;/a&gt;:&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;const&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;three&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;missing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nope&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All six report the same four lines: TS2322, TS2322, TS2345 and TS2339. The exit code splits. 7.0.2 and bun check exit 1. The 7.1 beta, tsc-rs, tsc-ts and tsrs exit 2. &lt;a href="https://github.com/AiHub-Ecosystem/aihub-be/blob/7b9aeaa82bb7b4bb631094609e604c2697923948/docs/research/typescript-type-checker-options.md" rel="noopener noreferrer"&gt;AIHUB BE saw the same split&lt;/a&gt;. A CI rule on one exact code won't survive a switch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Timings
&lt;/h2&gt;

&lt;p&gt;Through &lt;code&gt;/usr/bin/time -l&lt;/code&gt;, rotating order, 1 warm-up, median of 7. One thread is &lt;code&gt;--singleThreaded&lt;/code&gt;, or &lt;code&gt;--threads=1&lt;/code&gt; for bun. date-fns ran as &lt;code&gt;-p pkgs/core&lt;/code&gt;, after &lt;code&gt;tsc -b&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Checker&lt;/th&gt;
&lt;th&gt;type-fest, one thread&lt;/th&gt;
&lt;th&gt;date-fns, one thread&lt;/th&gt;
&lt;th&gt;date-fns, default&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;TypeScript 7.0.2&lt;/td&gt;
&lt;td&gt;25.10 s (1.0×)&lt;/td&gt;
&lt;td&gt;1.19 s (1.0×)&lt;/td&gt;
&lt;td&gt;0.72 s (1.0×)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TypeScript 7.1 beta&lt;/td&gt;
&lt;td&gt;14.28 s (1.8×)&lt;/td&gt;
&lt;td&gt;1.01 s (1.2×)&lt;/td&gt;
&lt;td&gt;0.65 s (1.1×)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;tsc-rs&lt;/td&gt;
&lt;td&gt;6.96 s (3.6×)&lt;/td&gt;
&lt;td&gt;0.71 s (1.7×)&lt;/td&gt;
&lt;td&gt;0.40 s (1.8×)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;tsc-ts&lt;/td&gt;
&lt;td&gt;8.33 s (3.0×)&lt;/td&gt;
&lt;td&gt;0.84 s (1.4×)&lt;/td&gt;
&lt;td&gt;0.40 s (1.8×)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;tsrs&lt;/td&gt;
&lt;td&gt;7.90 s (3.2×)&lt;/td&gt;
&lt;td&gt;0.32 s (3.7×)&lt;/td&gt;
&lt;td&gt;0.20 s (3.7×)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;bun check&lt;/td&gt;
&lt;td&gt;5.28 s (4.8×)&lt;/td&gt;
&lt;td&gt;0.70 s (1.7×)&lt;/td&gt;
&lt;td&gt;0.27 s (2.7×)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Load during those columns ranged from 6.5 to 14.3. These are rough numbers from one busy machine.&lt;/p&gt;

&lt;p&gt;Don't cite type-fest at default threads from this run. bun check read 12.1× with load between 20.4 and 28.7. A rerun stopped after four samples and read 22.9×, with 7.0.2 between 17.55 s and 83.79 s. The cause wasn't isolated. Fry's 5.7× on an M5 is the better number.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three checks for your own repo
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Read &lt;code&gt;Files:&lt;/code&gt; from &lt;code&gt;--extendedDiagnostics&lt;/code&gt;. A pass on zero files is not a pass.&lt;/li&gt;
&lt;li&gt;Seed errors. Compare the lines and the exit code with your current checker.&lt;/li&gt;
&lt;li&gt;Time the whole step on an idle machine, at default threads and at one thread. A checker can't speed up a code generator it doesn't run.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Pin the version you tested. In two weeks, tsc-ts went from reporting 7.0.2 to reporting 7.1.0-beta.&lt;/p&gt;

&lt;p&gt;The claimed numbers for every project, with their conditions, are in &lt;a href="https://argbe.tech/blog/typescript-type-checker-benchmarks?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=typescript-type-checker-benchmarks" rel="noopener noreferrer"&gt;the maintained article&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>rust</category>
      <category>performance</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why I have my orchestrator compact at 100K tokens</title>
      <dc:creator>Aleksandr Argunov</dc:creator>
      <pubDate>Mon, 16 Nov 2026 20:12:00 +0000</pubDate>
      <link>https://dev.to/argbetech/why-i-have-my-orchestrator-compact-at-100k-tokens-39mg</link>
      <guid>https://dev.to/argbetech/why-i-have-my-orchestrator-compact-at-100k-tokens-39mg</guid>
      <description>&lt;p&gt;Claude Opus 5.5 &lt;a href="https://platform.claude.com/docs/en/models/opus-5-5/overview" rel="noopener noreferrer"&gt;has a 1M token context window&lt;/a&gt;. I keep every agent under 100K anyway. Past 200K a slight drift sets in.&lt;/p&gt;

&lt;p&gt;These are personal observations, not measured thresholds.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://argbe.tech/blog/agent-context-compaction-100k?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=agent-context-compaction-100k" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5u4t96rqsnf24bcs9jex.gif" alt="Animation of one agent session. Token slices fill a glass column, the context window, then a press squeezes them into one summary. Ten labelled terms surround it." width="760" height="950"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The orchestrator is the weak point
&lt;/h2&gt;

&lt;p&gt;When a subagent drifts, you can get a weaker answer back. When the orchestrator drifts, that drift can spread through its briefs.&lt;/p&gt;

&lt;p&gt;Claude Code's subagents normally &lt;a href="https://code.claude.com/docs/en/sub-agents" rel="noopener noreferrer"&gt;start with a fresh, isolated context window&lt;/a&gt;. Forks inherit the parent conversation instead. A fresh subagent gets its task through the orchestrator's brief. Without the history, it may miss a constraint the brief dropped.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compact before the window fills
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://claude.com/resources/articles/using-claude-code-session-management-and-1m-context" rel="noopener noreferrer"&gt;Anthropic's session guide&lt;/a&gt; warns that growing context can hurt performance. Claude Code summarizes automatically near the window's limit. The guide recommends compacting earlier and saying what comes next.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/context
/compact focus on the auth refactor, drop the test debugging
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://code.claude.com/docs/en/commands" rel="noopener noreferrer"&gt;&lt;code&gt;/context&lt;/code&gt;&lt;/a&gt; shows what's filling the window. The &lt;code&gt;/compact&lt;/code&gt; line is the guide's own example. Codex has &lt;a href="https://learn.chatgpt.com/docs/developer-commands?surface=cli" rel="noopener noreferrer"&gt;&lt;code&gt;/compact&lt;/code&gt;&lt;/a&gt; too.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.trychroma.com/research/context-rot" rel="noopener noreferrer"&gt;Chroma's Kelly Hong, Anton Troynikov and Jeff Huber&lt;/a&gt; evaluated 18 LLMs in July 2025. Performance "grows increasingly unreliable as input length grows". The models included GPT-4.1 and Claude 4, not Opus 5.5. Neither source draws a line at 100K or 200K.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the cache fixes
&lt;/h2&gt;

&lt;p&gt;For 100K input tokens on Opus 5.5, using &lt;a href="https://platform.claude.com/docs/en/build-with-claude/prompt-caching" rel="noopener noreferrer"&gt;API prices checked on November 3, 2026&lt;/a&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Billed as&lt;/th&gt;
&lt;th&gt;Per million tokens&lt;/th&gt;
&lt;th&gt;100K tokens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Uncached input&lt;/td&gt;
&lt;td&gt;$4&lt;/td&gt;
&lt;td&gt;$0.40&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cache write, 5 minutes&lt;/td&gt;
&lt;td&gt;$5&lt;/td&gt;
&lt;td&gt;$0.50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cache write, 1 hour&lt;/td&gt;
&lt;td&gt;$8&lt;/td&gt;
&lt;td&gt;$0.80&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cache hit&lt;/td&gt;
&lt;td&gt;$0.20&lt;/td&gt;
&lt;td&gt;$0.02&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each amount is the listed rate multiplied by one tenth. These are input costs only; output and tool charges are excluded. They are not subscription prices. Other models have other multipliers.&lt;/p&gt;

&lt;p&gt;The hit is 0.05× the input price, and it doesn't buy room. &lt;a href="https://platform.claude.com/docs/en/build-with-claude/context-windows" rel="noopener noreferrer"&gt;Anthropic's words&lt;/a&gt;: "prompt caching changes what you pay for those tokens, not whether they count."&lt;/p&gt;

&lt;p&gt;Compaction also rewrites the history. &lt;a href="https://platform.claude.com/docs/en/build-with-claude/prompt-caching" rel="noopener noreferrer"&gt;Hits need 100 percent identical prompt segments&lt;/a&gt;, so the unchanged start can still hit, and the rewritten part can't. &lt;a href="https://www.microsoft.com/en-us/research/publication/benchmarking-long-horizon-agent-context-compaction-with-compactionbench/" rel="noopener noreferrer"&gt;CompactionBench&lt;/a&gt;, from Microsoft researchers, lists "disrupting prefix-cache reuse" among the problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  What compaction can lose
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ampcode.com/news/handoff" rel="noopener noreferrer"&gt;Amp removed compaction&lt;/a&gt; on October 23, 2025 and replaced it with Handoff. It calls compaction lossy: the agent decides what survives in the summary. Compacting early still carries that risk. A constraint you stated early can disappear.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test the number
&lt;/h2&gt;

&lt;p&gt;This comparison has not been run for this article.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pick one fixed task and repo snapshot. Keep the same exact model and effort.&lt;/li&gt;
&lt;li&gt;Write a list of constraints. State them only at the start of the session.&lt;/li&gt;
&lt;li&gt;Prepare and save starting contexts at 50K, 100K and 200K. Check the size with &lt;a href="https://code.claude.com/docs/en/commands" rel="noopener noreferrer"&gt;&lt;code&gt;/context&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Compare runs from each saved context before and after &lt;code&gt;/compact&lt;/code&gt;. Restore the repo snapshot before each run. Repeat each comparison.&lt;/li&gt;
&lt;li&gt;Score tests passed and constraints kept.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;task,model,effort,input_tokens,compacted,run,tests_passed,constraints_kept
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the API, log &lt;a href="https://platform.claude.com/docs/en/build-with-claude/prompt-caching" rel="noopener noreferrer"&gt;&lt;code&gt;input_tokens&lt;/code&gt;, &lt;code&gt;cache_read_input_tokens&lt;/code&gt; and &lt;code&gt;cache_creation_input_tokens&lt;/code&gt;&lt;/a&gt;. Those separate uncached input from cache reads and writes.&lt;/p&gt;

&lt;p&gt;The maintained article, with all ten context terms and what each does to the budget, is &lt;a href="https://argbe.tech/blog/agent-context-compaction-100k?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=agent-context-compaction-100k" rel="noopener noreferrer"&gt;on argbe.tech&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>agents</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Weight-space programming at 50 forward passes: Qwen hit 48.1%, Gemma 7.0%</title>
      <dc:creator>Aleksandr Argunov</dc:creator>
      <pubDate>Sat, 14 Nov 2026 06:46:00 +0000</pubDate>
      <link>https://dev.to/argbetech/weight-space-programming-at-50-forward-passes-qwen-hit-481-gemma-70-a3c</link>
      <guid>https://dev.to/argbetech/weight-space-programming-at-50-forward-passes-qwen-hit-481-gemma-70-a3c</guid>
      <description>&lt;p&gt;GPT-6 Astra edited &lt;a href="https://rikiyat.github.io/blog/weight-space-programming/" rel="noopener noreferrer"&gt;131,072 of Qwen3.5-0.8B's weights&lt;/a&gt; with no training. Its MATH-500 score went from 7.9% to 48.1%. On the same budget of 50 forward passes, Gemma 3 270M went from 6.8% to 7.0%.&lt;/p&gt;

&lt;p&gt;It fixed a bug. It did not teach math.&lt;/p&gt;

&lt;p&gt;The work is by Rikiya Takehi, Jayden Teoh, Alex Zhang and Omar Khattab at MIT CSAIL, published Nov 2, 2026. The logs are public, so you can check the numbers without running a model.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pull the numbers
&lt;/h2&gt;

&lt;p&gt;Run this and you get the score and the share of answers cut at the token limit, for each Qwen run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;base&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://raw.githubusercontent.com/RikiyaT/lm_understand-logs/main/exp8_math
&lt;span class="k"&gt;for &lt;/span&gt;run &lt;span class="k"&gt;in &lt;/span&gt;unedited p10c p25c p50c&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
  &lt;/span&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$base&lt;/span&gt;&lt;span class="s2"&gt;/eval/&lt;/span&gt;&lt;span class="nv"&gt;$run&lt;/span&gt;&lt;span class="s2"&gt;/merged.json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    | jq &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="nt"&gt;--arg&lt;/span&gt; run &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$run&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s1"&gt;'[$run, .math500.acc, .math500.cut_share]'&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;["unedited",0.079,0.93]
["p10c",0.1235,0.8725]
["p25c",0.141,0.8635]
["p50c",0.481,0.3305]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The matched-budget table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;a href="https://github.com/RikiyaT/lm_understand-logs/blob/main/exp8_math/eval/RESULTS_excerpt.md" rel="noopener noreferrer"&gt;Forward passes&lt;/a&gt;&lt;/th&gt;
&lt;th&gt;Qwen MATH-500&lt;/th&gt;
&lt;th&gt;Qwen cut at token limit&lt;/th&gt;
&lt;th&gt;Gemma MATH-500&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Unedited&lt;/td&gt;
&lt;td&gt;7.9%&lt;/td&gt;
&lt;td&gt;93.0%&lt;/td&gt;
&lt;td&gt;6.8%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;12.3%&lt;/td&gt;
&lt;td&gt;87.2%&lt;/td&gt;
&lt;td&gt;7.6%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;25&lt;/td&gt;
&lt;td&gt;14.1%&lt;/td&gt;
&lt;td&gt;86.4%&lt;/td&gt;
&lt;td&gt;7.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;50&lt;/td&gt;
&lt;td&gt;48.1%&lt;/td&gt;
&lt;td&gt;33.1%&lt;/td&gt;
&lt;td&gt;7.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One pass is up to 512 generated answers or 1,024 texts read for Qwen. Gemma's generation pass is larger, at 2,048.&lt;/p&gt;

&lt;p&gt;Limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each budget is one run, and each run chose a different edit. The &lt;a href="https://github.com/RikiyaT/lm_understand-logs/tree/main/exp8_math" rel="noopener noreferrer"&gt;10-pass run&lt;/a&gt; changed 30 matrices. The 25-pass run zeroed one attention head. The 50-pass run edited 64 MLP columns in each of layers 15 and 19.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/RikiyaT/lm_understand-logs/blob/main/exp8_math/gemma_followup/README.md" rel="noopener noreferrer"&gt;Gemma's setup differs&lt;/a&gt;: no thinking mode, 8,192 tokens, temperature 1.0 and format-agnostic grading. Read the columns separately.&lt;/li&gt;
&lt;li&gt;The Gemma gain isn't established. &lt;a href="https://github.com/RikiyaT/lm_understand-logs/blob/main/exp8_math/eval/RESULTS_excerpt.md" rel="noopener noreferrer"&gt;Four other runs&lt;/a&gt;, told a stricter grading rule, scored 6.1% to 6.7% on the same scale.&lt;/li&gt;
&lt;li&gt;No model was rerun for this post. &lt;a href="https://huggingface.co/RikiyaT/Qwen3.5-0.8B-weight-space-programming" rel="noopener noreferrer"&gt;akhaliq's re-run of the 50-pass checkpoint&lt;/a&gt; got 51.0% with 31.6% cut off. Its base-model check was a 25-problem smoke test.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The edit
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/RikiyaT/lm_understand-logs/tree/main/exp8_math" rel="noopener noreferrer"&gt;The rules&lt;/a&gt; banned backward passes, autograd, optimizers and iterative fitting. Astra had a CPU Python kernel over the weights and could only run the model through the forward-pass tool.&lt;/p&gt;

&lt;p&gt;The arithmetic: 2 layers × 64 columns × 1,024 = 131,072 weights. Against a nominal 0.8 billion, that's 0.016384%. &lt;a href="https://rikiyat.github.io/blog/weight-space-programming/" rel="noopener noreferrer"&gt;The report&lt;/a&gt; rounds it to 0.016%.&lt;/p&gt;

&lt;p&gt;Astra traced the loops to one direction written by those MLPs, then subtracted it. A &lt;a href="https://arxiv.org/abs/2308.10248" rel="noopener noreferrer"&gt;steering vector&lt;/a&gt; works on the same idea at inference time, by adding a contrast direction to activations. Here the direction went into the weights. On &lt;a href="https://news.ycombinator.com/item?id=50347685" rel="noopener noreferrer"&gt;Hacker News, yurimo&lt;/a&gt;, who says part of their research is in weight-space learning, reads the fix as close to that established technique.&lt;/p&gt;

&lt;h2&gt;
  
  
  Split the gain
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://rikiyat.github.io/blog/weight-space-programming/" rel="noopener noreferrer"&gt;From the same table&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;93.0 − 33.1 = 59.9 points fewer answers cut off.&lt;/li&gt;
&lt;li&gt;48.1 − 7.9 = 40.2 points more answers correct.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those compare shares, so they don't show which answers changed. &lt;a href="https://github.com/RikiyaT/lm_understand-logs/blob/main/exp8_math/runs/p50c/final_answer.md" rel="noopener noreferrer"&gt;Astra's confirmation run&lt;/a&gt; gets closer, on 1,152 held-out practice problems: 579 answers went from wrong to right, and 576 of them had been cut off. Accuracy on finished answers didn't change. Those are Astra's own numbers, on practice data.&lt;/p&gt;

&lt;p&gt;Gemma has no such bug. &lt;a href="https://github.com/RikiyaT/lm_understand-logs/blob/main/exp8_math/gemma_followup/README.md" rel="noopener noreferrer"&gt;Only 8.5% of its answers&lt;/a&gt; reach its limit, and Astra found ordinary arithmetic and algebra errors.&lt;/p&gt;

&lt;p&gt;You can split any score jump this way. Count the answers cut off at the limit first, then compare only the ones that finished.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check the brief
&lt;/h2&gt;

&lt;p&gt;Astra was told what to look for, as one example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$base&lt;/span&gt;&lt;span class="s2"&gt;/runs/p50c/turns/t001/prompt.txt"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="s2"&gt;"if the model often fails[^.]*&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if the model often fails because it repeats itself and never finishes, finding and fixing what drives that repetition counts.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That brief runs to 10,315 bytes. It names no layer or direction. Astra still needed &lt;a href="https://github.com/RikiyaT/lm_understand-logs/tree/main/exp8_math" rel="noopener noreferrer"&gt;158 turns, 80 Python runs and 20.3 hours&lt;/a&gt;, including a 4.7-hour wait when the model could not be reached. &lt;a href="https://huggingface.co/Qwen/Qwen3.5-0.8B" rel="noopener noreferrer"&gt;Qwen's model card&lt;/a&gt; also warns this model is prone to thinking loops.&lt;/p&gt;

&lt;h2&gt;
  
  
  The limit
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://rikiyat.github.io/blog/weight-space-programming/" rel="noopener noreferrer"&gt;The authors write&lt;/a&gt; that editing could remove an obstacle hiding an ability, but could not add one the model lacked. In experiments 5 and 6, Astra wrote small game networks from scratch, so that limit is about language models that already exist. A third of Qwen's answers still hit the limit.&lt;/p&gt;

&lt;p&gt;My reading, not theirs: one AI can now debug another. Teaching it something new still takes training.&lt;/p&gt;

&lt;p&gt;The maintained version, with the chart and the comment thread, is &lt;a href="https://argbe.tech/blog/weight-space-programming-looping-fix?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=weight-space-programming-looping-fix" rel="noopener noreferrer"&gt;on argbe.tech&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>ai</category>
      <category>llm</category>
      <category>testing</category>
    </item>
    <item>
      <title>How I route agent tasks across five models, and when I skip the orchestrator</title>
      <dc:creator>Aleksandr Argunov</dc:creator>
      <pubDate>Mon, 09 Nov 2026 18:17:00 +0000</pubDate>
      <link>https://dev.to/argbetech/how-i-route-agent-tasks-across-five-models-and-when-i-skip-the-orchestrator-1ne3</link>
      <guid>https://dev.to/argbetech/how-i-route-agent-tasks-across-five-models-and-when-i-skip-the-orchestrator-1ne3</guid>
      <description>&lt;p&gt;I use Astra and Opus side by side, picked by task. The rest run as subagents. The biggest difference is speed. On a subscription, Astra and Sol take ages to finish the work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://x.com/bijanbowen/status/2114289895137313184" rel="noopener noreferrer"&gt;Bijan Bowen put it in two lines on X&lt;/a&gt;, October 25, 2026. GPT-6.x models = left brain. Claude 5.5 models = right brain. The metaphor is Bijan's. It isn't science. The split below is mine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://argbe.tech/blog/choosing-models-for-agent-tasks?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=choosing-models-for-agent-tasks" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgolbw4gqdvm95xefac5e.gif" alt="Poster titled Left brain, Right brain. A maze-drawn brain splits GPT models on the left from Claude models on the right. A light runs faster on the Claude side. Task lists sit below." width="720" height="900"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The split
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;th&gt;What I give it&lt;/th&gt;
&lt;th&gt;The catch&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;GPT-6 Astra&lt;/td&gt;
&lt;td&gt;Side by side with Opus&lt;/td&gt;
&lt;td&gt;Coding, code review and debugging, data analytics, math, plans and specs, long runs that stay on the plan, orchestration even better than Opus&lt;/td&gt;
&lt;td&gt;Painfully slow. Needs a detailed prompt, then it can beat Opus.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GPT-6.1 Sol&lt;/td&gt;
&lt;td&gt;Subagent only&lt;/td&gt;
&lt;td&gt;Computer and browser use, read-only MCP calls, structured output&lt;/td&gt;
&lt;td&gt;Takes ages on a subscription.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GPT-6.1 Terra on Fast&lt;/td&gt;
&lt;td&gt;Subagent only&lt;/td&gt;
&lt;td&gt;Gathering and preparing data, finding things in a big repo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claude Opus 5.5&lt;/td&gt;
&lt;td&gt;Side by side with Astra&lt;/td&gt;
&lt;td&gt;UX/UI and design, writing, coding where the code looks more human, repo-wide refactors, orchestration&lt;/td&gt;
&lt;td&gt;Gets your goal from a poor or wrong prompt. Orchestration is almost as good as Astra's, and much faster.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claude Sonnet 5.5&lt;/td&gt;
&lt;td&gt;A very strong subagent&lt;/td&gt;
&lt;td&gt;The same subagent jobs as Sol and Terra, and design&lt;/td&gt;
&lt;td&gt;Computer use is weaker than Sol. Design is clearly weaker than Opus.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Model names are from &lt;a href="https://developers.openai.com/api/docs/guides/latest-model" rel="noopener noreferrer"&gt;OpenAI's guide&lt;/a&gt; and &lt;a href="https://platform.claude.com/docs/en/models/opus-5-5/overview" rel="noopener noreferrer"&gt;Anthropic's overview&lt;/a&gt;. The ratings are my experience as of October 2026, not a benchmark.&lt;/p&gt;

&lt;p&gt;This is routing, not a capability list. OpenAI pitches Terra for "visual reasoning, precise computer use, and clear, natural writing." I keep computer use on Sol. Read-only comes from the tools and permissions you allow, not from the model.&lt;/p&gt;

&lt;h2&gt;
  
  
  Speed depends on what you measure
&lt;/h2&gt;

&lt;p&gt;My subscription experience has a counterpoint. &lt;a href="https://www.vals.ai/benchmarks/terminal-bench-2-1" rel="noopener noreferrer"&gt;Vals AI's archived Terminal-Bench 2.1 results&lt;/a&gt;, updated October 1, 2026, list Astra at 4m34s per test and Opus 5.5 at 6m23s. Both used Terminus 2. That reverses my speed ranking, but measures terminal tasks rather than my subscription sessions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developers.openai.com/api/docs/guides/latest-model" rel="noopener noreferrer"&gt;Fast mode&lt;/a&gt; is separate from the model and its reasoning effort. Record all three when comparing speed.&lt;/p&gt;

&lt;h2&gt;
  
  
  When I prefer one tailored agent
&lt;/h2&gt;

&lt;p&gt;For building several features, one tailored agent beats an orchestrator with subagents. That's my judgment, not a rule for every task.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://claude.com/resources/articles/building-agents-when-to-fold-subagents-into-your-main-agent-loop" rel="noopener noreferrer"&gt;Anthropic's Diane Sarkis&lt;/a&gt; reports a similar enterprise pattern: one agent with skills often improved quality, cost and latency. One customer saw roughly 2x faster runtime. That isn't a controlled comparison of feature development.&lt;/p&gt;

&lt;p&gt;Subagents hand back summaries. Each handoff can lose detail. Anthropic still uses subagents for verification, parallel work and separate permissions.&lt;/p&gt;

&lt;p&gt;I still orchestrate when the tasks are related, like gathering info or preparing data. There it's much more efficient.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test it on your own tasks
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://claude.com/resources/articles/building-agents-when-to-fold-subagents-into-your-main-agent-loop" rel="noopener noreferrer"&gt;Anthropic suggests starting with 10 golden examples&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pick that many of your real tasks. Run each through one single-agent design and one orchestrated design.&lt;/li&gt;
&lt;li&gt;Hold the model, effort, client and speed tier fixed while comparing designs.&lt;/li&gt;
&lt;li&gt;Run each task more than once to catch inconsistent results.&lt;/li&gt;
&lt;li&gt;Check which tasks flipped, not only the winner. Add wall time and total tokens, so the speed gap has a number.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Log one line per run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;task,design,model,effort,client,speed_tier,run,completed,wall_time,total_tokens
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The maintained article is &lt;a href="https://argbe.tech/blog/choosing-models-for-agent-tasks?utm_source=devto&amp;amp;utm_medium=syndication&amp;amp;utm_campaign=choosing-models-for-agent-tasks" rel="noopener noreferrer"&gt;on argbe.tech&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>agents</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
