<?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: Affan Shaik</title>
    <description>The latest articles on DEV Community by Affan Shaik (@affan_shaik).</description>
    <link>https://dev.to/affan_shaik</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%2F4198266%2F83c2ec24-bdce-4482-bd9f-294dd8bdd9e3.png</url>
      <title>DEV Community: Affan Shaik</title>
      <link>https://dev.to/affan_shaik</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/affan_shaik"/>
    <language>en</language>
    <item>
      <title>I broke an online shop 42 times to see if free AI models can find the root cause</title>
      <dc:creator>Affan Shaik</dc:creator>
      <pubDate>Mon, 16 Nov 2026 18:53:04 +0000</pubDate>
      <link>https://dev.to/affan_shaik/i-broke-an-online-shop-42-times-to-see-if-free-ai-models-can-find-the-root-cause-3djn</link>
      <guid>https://dev.to/affan_shaik/i-broke-an-online-shop-42-times-to-see-if-free-ai-models-can-find-the-root-cause-3djn</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff5ls9s7tup5cqkkx4gvx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff5ls9s7tup5cqkkx4gvx.png" alt=" " width="800" height="336"&gt;&lt;/a&gt;&lt;br&gt;
When a website breaks, the error rarely shows up where the problem started. A checkout page times out because the payment service is slow, because a network link is dropping packets. Engineers dig through metrics, traces and logs until they find the one thing that actually broke: the &lt;strong&gt;root cause&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Everyone wants AI to do this job. I wanted to know how well free AI models really do it, and what evidence they actually use. So I built &lt;strong&gt;Rootline&lt;/strong&gt;, an open benchmark that costs $0 to run.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Break it.&lt;/strong&gt; I run the &lt;a href="https://opentelemetry.io/docs/demo/" rel="noopener noreferrer"&gt;OpenTelemetry Demo&lt;/a&gt;, a real microservice web shop under steady load, and break it on purpose in 14 different ways: payment errors, memory leaks, lock contention, slow shipping, network latency, packet loss, connection resets and more. There are also normal runs with nothing broken, as a control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Freeze it.&lt;/strong&gt; For each incident, I save ten minutes of metrics, traces and logs around the fault.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ask the AI.&lt;/strong&gt; The same frozen evidence goes to three free models: &lt;strong&gt;gpt-oss-120b&lt;/strong&gt; (on Groq's free tier), &lt;strong&gt;Qwen3 8B&lt;/strong&gt; and &lt;strong&gt;Gemma 3 4B&lt;/strong&gt; (on a free Kaggle GPU). Every line of evidence has an ID, and every answer has to cite the IDs it relied on.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Score it.&lt;/strong&gt; Each answer is checked for the right service, the right kind of fault, the right layer (network or application), and whether the cited evidence actually exists.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's 42 incidents × 4 kinds of evidence × 3 models = &lt;strong&gt;504 scored runs&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hardware part
&lt;/h2&gt;

&lt;p&gt;I wanted to know if emulated network faults are a fair stand-in for real ones. So two &lt;strong&gt;Arduino UNO Q&lt;/strong&gt; boards became part of the shop: one carried real payment traffic over Wi-Fi, the other could flood the Wi-Fi channel. Overnight, fully unattended, the controller cut the radio for 30 seconds, crowded the channel and turned the transmit power down, then took snapshots.&lt;/p&gt;

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

&lt;p&gt;The headline is negative, and I'm reporting it that way:&lt;/p&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;Exact root cause (combined evidence)&lt;/th&gt;
&lt;th&gt;Average confidence&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;gpt-oss-120b&lt;/td&gt;
&lt;td&gt;9.5%&lt;/td&gt;
&lt;td&gt;84%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gemma 3 4B&lt;/td&gt;
&lt;td&gt;4.8%&lt;/td&gt;
&lt;td&gt;88%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Qwen3 8B&lt;/td&gt;
&lt;td&gt;2.4%&lt;/td&gt;
&lt;td&gt;95%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb8pbqhgt4vk6sopyh3q9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb8pbqhgt4vk6sopyh3q9.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
A few things stood out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Very confident, mostly wrong.&lt;/strong&gt; All three models said they were 84–95% sure on average. If you trusted the confidence number, you would be misled.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nothing was ever "nothing".&lt;/strong&gt; On the healthy runs, with no fault at all, every model still claimed something was broken, in every single answer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A layer answer can be a habit.&lt;/strong&gt; Gemma answered "application problem" on all 42 incidents, so its good score on application faults isn't a skill.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The caller gets the blame.&lt;/strong&gt; On broken network links, the best model usually named the service making the call (checkout) instead of the service at the other end (payment), which is what I'd decided in advance to count as correct. Counting either end raises its score from 9.5% to 16.7%. One scoring rule changes the story a lot.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;More evidence didn't help.&lt;/strong&gt; Giving the model metrics, traces and logs together did not beat logs or metrics alone. With a fixed prompt size, more breadth means less depth.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Some faults barely leave a trace.&lt;/strong&gt; I built a check that measures whether each fault actually shows up in its own data. The real Wi-Fi outages showed up clearly. Some emulated faults, like connection resets on a link that keeps one connection open, barely showed up at all, and no model can diagnose what the evidence doesn't show.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a &lt;strong&gt;pilot&lt;/strong&gt;: 42 incidents gives wide error bars, and neither of my two pre-stated hypotheses reached significance. It's a starting point, not a verdict on AI for operations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Everything is open
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🌐 &lt;strong&gt;Website&lt;/strong&gt; with every incident you can replay: &lt;a href="https://flotrpy.github.io/RootLine/" rel="noopener noreferrer"&gt;https://flotrpy.github.io/RootLine/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;📄 &lt;strong&gt;Report (PDF):&lt;/strong&gt; &lt;a href="https://flotrpy.github.io/RootLine/rootline-v0.1.pdf" rel="noopener noreferrer"&gt;https://flotrpy.github.io/RootLine/rootline-v0.1.pdf&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;📊 &lt;strong&gt;Dataset&lt;/strong&gt; (snapshots, labels, all 504 answers): &lt;a href="https://huggingface.co/datasets/Flotrpy/rootline" rel="noopener noreferrer"&gt;https://huggingface.co/datasets/Flotrpy/rootline&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💻 &lt;strong&gt;Code:&lt;/strong&gt; &lt;a href="https://github.com/Flotrpy/RootLine" rel="noopener noreferrer"&gt;https://github.com/Flotrpy/RootLine&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🔖 &lt;strong&gt;DOI:&lt;/strong&gt; &lt;a href="https://doi.org/10.5281/zenodo.24270040" rel="noopener noreferrer"&gt;https://doi.org/10.5281/zenodo.24270040&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Clone the repo, run &lt;code&gt;make data &amp;amp;&amp;amp; make reproduce&lt;/code&gt;, and every table and chart rebuilds from the published runs.&lt;/p&gt;

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

&lt;p&gt;For v0.2: stronger versions of the faults that left no trace, more healthy runs, asking models for both the symptom and the cause, and testing whether hiding service names changes their answers.&lt;/p&gt;

&lt;p&gt;If you work on observability or AI for operations, I'd love feedback. Open an issue or tell me what you would test next.&lt;/p&gt;

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

&lt;p&gt;Check out more details at:  &lt;a href="https://github.com/Flotrpy/RootLine" rel="noopener noreferrer"&gt;https://github.com/Flotrpy/RootLine&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>devops</category>
      <category>observability</category>
    </item>
    <item>
      <title>I wanted to see which subsea cable my packets cross. The cloud couldn't trace, and the database put Helsinki in Phoenix</title>
      <dc:creator>Affan Shaik</dc:creator>
      <pubDate>Thu, 05 Nov 2026 00:19:20 +0000</pubDate>
      <link>https://dev.to/affan_shaik/i-wanted-to-see-which-subsea-cable-my-packets-cross-the-cloud-couldnt-trace-and-the-database-put-4e9o</link>
      <guid>https://dev.to/affan_shaik/i-wanted-to-see-which-subsea-cable-my-packets-cross-the-cloud-couldnt-trace-and-the-database-put-4e9o</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsmsgmed5h545n6jgn5ci.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsmsgmed5h545n6jgn5ci.png" alt=" " width="800" height="370"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;The idea&lt;/strong&gt;&lt;br&gt;
When you open a website, your data passes through a dozen routers, a few ISPs, maybe a cable on the ocean floor, and several countries with their own data laws. None of that is visible. My pitch was:&lt;/p&gt;

&lt;p&gt;Trace packets from your own computer, work out which networks, countries, and subsea cables they cross, check the route against data-sovereignty laws like GDPR, and draw it live on a 3D Earth.&lt;/p&gt;

&lt;p&gt;The constraints: cost $0, use only open data, and say clearly what is measured and what is guessed.&lt;/p&gt;

&lt;p&gt;Live demo: packetpulse-eta.vercel.app Code, data and tests: &lt;a href="https://dev.tourl"&gt;github.com/Flotrpy/PacketPulse&lt;br&gt;
&lt;/a&gt;&lt;br&gt;
Scoping it down so it was buildable&lt;br&gt;
&lt;strong&gt;Measurement:&lt;/strong&gt; plain traceroute (ICMP/UDP with rising TTL), written from scratch in Go with raw sockets. Traceroute never sees a cable or a country; everything past the IP addresses and round-trip times is inference.&lt;br&gt;
&lt;strong&gt;Data:&lt;/strong&gt; only free sources. TeleGeography's submarine cable map (690 cables), iptoasn (~580k IP ranges), DB-IP Lite City, Natural Earth borders, PeeringDB, AWS/GCP region prefixes, and a hand-curated law directory.&lt;br&gt;
&lt;strong&gt;Laws:&lt;/strong&gt; a small compliance engine with profiles like "EU personal data stays in the EEA or adequate countries" (GDPR Chapter V) or "Indian payment data stays in India" (RBI).&lt;br&gt;
&lt;strong&gt;Hosting:&lt;/strong&gt; free tiers only. Render runs the Go backend, Vercel serves the globe.&lt;br&gt;
&lt;strong&gt;Iteration 1:&lt;/strong&gt; the server can't trace, and shouldn't&lt;br&gt;
The obvious design: the user types a website, the server runs the traceroute, the globe draws it.&lt;/p&gt;

&lt;p&gt;The first deploy came back with this in the health check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"tracing"&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Render's containers can't open raw ICMP sockets, so traceroute is impossible there. My development sandbox could trace, but its network let only 2 hops through.&lt;/p&gt;

&lt;p&gt;Even if it had worked, it would have been the wrong trace. A path from a data centre in Oregon tells you nothing about your path.&lt;/p&gt;

&lt;p&gt;Lesson: sometimes the platform limit is pointing at a design flaw.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Iteration 2:&lt;/strong&gt; a small agent on your computer&lt;br&gt;
The fix was to split the work:&lt;/p&gt;

&lt;p&gt;The globe stays in the browser.&lt;br&gt;
A small agent, ppagent, runs on your computer and long-polls the server for trace jobs.&lt;br&gt;
You click Trace on the website. Your agent traces from your network and public IP and posts the raw result back.&lt;br&gt;
The server does all the enrichment (geolocation, ASNs, cables, compliance), so the agent stays tiny and needs no data files.&lt;br&gt;
On Windows, the first real run printed one line and quit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;level=ERROR msg="trace failed" target=C:\Users\affan\Downloads\ppagent.exe
  err="
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;... target must be a hostname or IP address"&lt;br&gt;
The program received its own path as an argument, treated it as a website to trace, failed, and exited. The agent now ignores its own path and skips anything that isn't a hostname or IP. Setup on Windows is now one line in an Administrator PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;irm&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;packetpulse&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;onrender&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;download&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ppagent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ps1&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;iex&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lesson: the first run on someone else's machine is the real test.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Iteration 3:&lt;/strong&gt; 1.1.1.1 is in Australia (it isn't)&lt;br&gt;
With the agent working, the first trace to 1.1.1.1 drew an arc from the US to Australia. The IP database lists Cloudflare's address under its registered location. But 1.1.1.1 is anycast: it answers from whichever site is closest, and it replied in about 3 ms.&lt;/p&gt;

&lt;p&gt;Physics settles it. Light in fiber covers about 204 km per millisecond, so a 3 ms round trip means the server is at most about 300 km away. Every router location already had to pass this check. The destination didn't, so I added it.&lt;/p&gt;

&lt;p&gt;Lesson: a free, exact constraint (the speed of light) beats any database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Iteration 4:&lt;/strong&gt; the trace crossed the Atlantic, but no cable showed up&lt;br&gt;
This was the real test. I traced from New Jersey to a server in Helsinki. The latency clearly jumped across the ocean, but the globe showed no subsea cable.&lt;/p&gt;

&lt;p&gt;Here is the actual trace, with what the GeoIP database said about each router:&lt;/p&gt;

&lt;p&gt;Hop Router                          RTT    Database says&lt;br&gt;
2   lo0-100.NWRKNJ-…verizon-gni.net   4.9 ms     Newark, US&lt;br&gt;
6   ewr-bb2-link.ip.twelve99.net    6.6 ms     nothing&lt;br&gt;
7   kbn-bb6-link.ip.twelve99.net    105.9 ms   Solna, SE&lt;br&gt;
9   hls-b4-link.ip.twelve99.net 94.7 ms    Warsaw, PL&lt;br&gt;
11  hetzner-ic-….twelve99-cust.net    102.4 ms   Phoenix, US&lt;br&gt;
14  hel1-speed.hetzner.com          104.8 ms   Helsinki, FI&lt;br&gt;
Three things went wrong.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The router just before the ocean had no location. Hop 6 is the crossing point, but the database didn't know it, so the segment into hop 7 was "unknown". The router name knew, though: Arelion (Telia) names routers with city codes. ewr is Newark, kbn is København, hls is Helsinki, adm is Amsterdam. Some of these weren't in my lookup table. I added them, plus OVH, Hetzner and Verizon codes, and gaps are now bridged from the last router that does have a location.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Phoenix. The database put a Helsinki interconnect in Arizona, which produced two fake "subsea" segments (Stockholm → Phoenix → Helsinki). The RTT check passed it, because 102 ms is plenty of time to reach Phoenix from New Jersey. What it didn't check was the path. Two new rules:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Path check: source → previous router → this router must all fit inside the RTT.&lt;br&gt;
Detour check: if the route goes somewhere and comes straight back, the timings have to pay for the extra distance. Stockholm → Phoenix → Helsinki with almost no added RTT doesn't.&lt;br&gt;
As a side benefit, RTT noise is handled better by using the lowest RTT seen at this hop or any later one. Slow ICMP replies only ever add delay, and the path to a later hop passes through this one.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;No cable lands in both countries. The matcher only considered cables with a landing in both endpoint countries. Traffic often lands in the UK or Ireland and continues overland, so now cables landing elsewhere on the far continent count too, with distant landings weighted down.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The result:&lt;/p&gt;

&lt;p&gt;**                          Before          After**&lt;br&gt;
Hop 6 (ewr)           unlocated         Newark&lt;br&gt;
Hop 7 (kbn)           Solna                 Copenhagen&lt;br&gt;
Hop 11                    Phoenix           dropped&lt;br&gt;
Subsea segments       2 fake ones (via Phoenix) 1: Newark → Copenhagen&lt;br&gt;
Cable   none    Havfrue/AEC-2 (Wall Township, NJ → Blaabjerg, DK)&lt;br&gt;
Newark → Copenhagen is 6,200 km, so the fastest possible round trip is about 61 ms. The measured jump is 99 ms, which is typical once you add real cable routing and equipment. Havfrue/AEC-2 lands about 50 km from where the trace started, which is what the ranking rewards. This exact trace is now a regression test in the repo.&lt;/p&gt;

&lt;p&gt;Lesson: test on a real trace, not the example you built the code around. My test fixture was Mumbai → Marseille over Tata's network, whose router names I'd already taught it.&lt;/p&gt;

&lt;p&gt;Iteration 5: what data is it, and is that legal?&lt;br&gt;
Knowing the route is half the question. The other half is what is on it. Classifying traffic by reading packets is out of scope (and creepy), so traffic is tagged at ingestion from rules on what's already known: destination host, port, network, cloud provider, and an app label from the agent.&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="nl"&gt;"data_classification"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"labels"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"payment_system_data"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"rules"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="nl"&gt;"rule_ids"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"india-payment-gateways"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The compliance engine then walks the route point by point. For the recorded trace from Mumbai (Jio 5G) to AWS Frankfurt, tagged payment_system_data, the RBI profile raises an alert at the German destination, with the law, the entry time, and a suggested fix ("terminate payment flows in India: use AWS ap-south-1"). If the location is uncertain, as with the Jeddah cable landing in that example, the alert is marked suspected instead.&lt;/p&gt;

&lt;p&gt;Iteration 6: making the globe look like Earth&lt;br&gt;
The first globe was a blue dot-matrix sphere. It looked fine as a demo, but not like a real place. The current one uses satellite imagery lit by the real sun for the current time. Day and night, city lights, clouds and the glint on the oceans are all computed in one shader, with a few lines of solar maths (declination plus the equation of time).&lt;/p&gt;

&lt;p&gt;The paths are the performance part. Every hop-to-hop segment is an instance of one ribbon mesh, so 1,000 paths draw in 6 draw calls, and a live latency update for one path uploads about 600 bytes.&lt;/p&gt;

&lt;p&gt;What I'd tell myself at the start&lt;br&gt;
Ask where the measurement happens before building it. The cloud couldn't trace, and the trace that mattered was never going to come from the cloud anyway.&lt;br&gt;
Physics is your best validator. The speed of light in fiber rejected Australia and Phoenix for free. Databases are hints.&lt;br&gt;
Router names are better geolocation than databases. Network operators name routers with airport and city codes, and those beat the free databases on backbone hops.&lt;br&gt;
Check the path, not the point. Each location can look plausible on its own while the route through it is impossible.&lt;br&gt;
Test on real traces from real networks. A 14-hop trace from a home connection found more bugs than any fixture I wrote.&lt;br&gt;
Honest limits&lt;br&gt;
Everything past the IPs is inferred. Cable names come with probabilities. "Havfrue/AEC-2" is the best fit, not an observation, and I have no ground truth for which cable a packet actually used.&lt;br&gt;
Geolocation is city-level at best. Some routers stay unlocated, and a few wrong locations will still pass the checks.&lt;br&gt;
Traceroute sees only the forward path, and networks can hide hops (MPLS tunnels, filtered ICMP).&lt;br&gt;
The compliance verdicts are a model, not legal advice. The law directory is informational.&lt;br&gt;
Small sample. The subsea fixes were driven by one real transatlantic trace (now a regression test) plus a handful of runs to London, Amsterdam and Roubaix. The Windows agent has been run on one machine.&lt;br&gt;
Free hosting. The server sleeps after 15 minutes and keeps traces in memory, so the first visit is slow and restarts clear the globe.&lt;br&gt;
&lt;strong&gt;Try it&lt;br&gt;
On Windows, open PowerShell as Administrator and run:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;irm&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;packetpulse&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;onrender&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;download&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ppagent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ps1&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;iex&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then open packetpulse-eta.vercel.app and click London or Helsinki under Across the Atlantic. Traces need an agent token; the README explains how to run your own server with Docker in two commands.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.tourl"&gt;git clone https://github.com/Flotrpy/PacketPulse&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; PacketPulse
docker build -t packetpulse .
docker run --rm -p 8080:8080 -e &lt;span class="nv"&gt;PACKETPULSE_ADMIN_TOKENS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"me:$(openssl rand -hex 24)"&lt;/span&gt; packetpulse
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS and Linux agents, the API, and how the cable detection works are all in the README.&lt;/p&gt;

&lt;p&gt;Feedback is very welcome, especially from anyone who runs a backbone network and can tell me which cable my packets actually took.&lt;/p&gt;

</description>
      <category>networking</category>
      <category>go</category>
      <category>webgl</category>
      <category>opensource</category>
    </item>
    <item>
      <title>I tried to replace CFD with a diffusion model. A lookup table beat it, and that's what made it work</title>
      <dc:creator>Affan Shaik</dc:creator>
      <pubDate>Sat, 31 Oct 2026 15:03:19 +0000</pubDate>
      <link>https://dev.to/affan_shaik/i-tried-to-replace-cfd-with-a-diffusion-model-a-lookup-table-beat-it-and-thats-what-made-it-work-2k5g</link>
      <guid>https://dev.to/affan_shaik/i-tried-to-replace-cfd-with-a-diffusion-model-a-lookup-table-beat-it-and-thats-what-made-it-work-2k5g</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Update (Nov 1):&lt;/strong&gt; I re-checked everything with an independent solver (XFOIL) and real wind-tunnel data. The headline numbers below were judged by NeuralFoil and don't fully hold up. Between grid points, the method still clearly beats the lookup. See "Update: independent checks" near the end. Paper: &lt;a href="https://zenodo.org/records/23851806" rel="noopener noreferrer"&gt;https://zenodo.org/records/23851806&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The idea
&lt;/h2&gt;
&lt;/blockquote&gt;

&lt;p&gt;Designing aerodynamic shapes for EVs or delivery drones means running CFD (computational fluid dynamics) for every shape change, and serious runs can take days. My pitch was:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Train a diffusion model constrained by the Navier-Stokes equations to instantly generate and optimize surface geometries in real time, based on live wind-tunnel or flight telemetry.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The constraints: &lt;strong&gt;cost $0&lt;/strong&gt;, start building now, and base every design decision on a set of 18 research papers.&lt;/p&gt;

&lt;p&gt;Code, data and every result: &lt;strong&gt;&lt;a href="https://github.com/Flotrpy/airfoil-diffusion" rel="noopener noreferrer"&gt;github.com/Flotrpy/airfoil-diffusion&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Scoping it down so it was buildable
&lt;/h2&gt;

&lt;p&gt;Full Navier-Stokes CFD at zero cost isn't realistic, so the first plan shrank the problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Shapes:&lt;/strong&gt; 2-D wing sections (airfoils) for a small delivery drone, described by 11 numbers (a CST/Bernstein parameterisation, following the Airbus diffusion paper).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Solver:&lt;/strong&gt; &lt;a href="https://github.com/peterdsharpe/NeuralFoil" rel="noopener noreferrer"&gt;NeuralFoil&lt;/a&gt;, a fast neural stand-in for XFOIL. It is &lt;em&gt;not&lt;/em&gt; Navier-Stokes, and I say so throughout.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regime:&lt;/strong&gt; Reynolds number 2×10⁵ to 3.5×10⁵, angle of attack 0–10°.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The task:&lt;/strong&gt; given a flight condition and a target lift and drag, propose an airfoil. A &lt;strong&gt;hit&lt;/strong&gt; means NeuralFoil confirms lift within 1% and drag within 5% (the tolerances from Geng et al.).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compute:&lt;/strong&gt; everything in plain NumPy (no PyTorch) on a free 2-CPU cloud sandbox.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The dataset is 12,000 random airfoils × 44 flight conditions ≈ 350k labelled examples, split &lt;em&gt;by airfoil&lt;/em&gt;, so the test shapes were never seen in training.&lt;/p&gt;

&lt;h2&gt;
  
  
  Iteration 1: diffusion loses to a lookup table
&lt;/h2&gt;

&lt;p&gt;I trained a conditional DDPM (the Airbus architecture) and compared it against a boring baseline: &lt;strong&gt;find the nearest airfoil in the training set and return it.&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dataset&lt;/th&gt;
&lt;th&gt;Diffusion, 1 sample&lt;/th&gt;
&lt;th&gt;Lookup&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1,000 airfoils&lt;/td&gt;
&lt;td&gt;2%&lt;/td&gt;
&lt;td&gt;30%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6,000 airfoils&lt;/td&gt;
&lt;td&gt;7%&lt;/td&gt;
&lt;td&gt;56%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12,000 airfoils&lt;/td&gt;
&lt;td&gt;10%&lt;/td&gt;
&lt;td&gt;75%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;More data helped both, but diffusion never caught up. My own Phase 1 gate failed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; always run the dumb baseline. A lookup table over a dense dataset is a strong inverse-design method.&lt;/p&gt;

&lt;h2&gt;
  
  
  Iterations 2–4: stop generating from scratch
&lt;/h2&gt;

&lt;p&gt;Instead of throwing away the lookup, I built on top of it with &lt;strong&gt;retrieve → refine → verify&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Retrieve&lt;/strong&gt; the nearest training airfoils.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Refine&lt;/strong&gt; them by gradient descent on a small MLP surrogate of the solver (optionally after a light diffusion "warm start").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verify&lt;/strong&gt; every candidate with NeuralFoil; each check counts against the budget.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flnhg4yyw3w08p757g7ge.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flnhg4yyw3w08p757g7ge.png" alt="How the pipeline went from losing to a lookup table to beating it" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first version won at 10 and 100 tries but &lt;em&gt;lost&lt;/em&gt; on the first try (57% vs 75%). It kept "fixing" airfoils that were already correct.&lt;/p&gt;

&lt;p&gt;Adding a gate ("leave it alone if the surrogate says it's already a hit") only got to a tie. &lt;strong&gt;The surrogate's error was about as big as the 1% tolerance&lt;/strong&gt;, so it couldn't tell hits from misses.&lt;/p&gt;

&lt;p&gt;The fix that worked was almost embarrassingly simple. The targets sit on the same (Re, angle) grid as the training data, and NeuralFoil had &lt;em&gt;already scored every training airfoil at those exact conditions&lt;/em&gt;. So the gate reads the stored result instead of guessing: zero error, a free bias correction for the surrogate, and no extra solver calls.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvkpe0wex4bvls6gsji35.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvkpe0wex4bvls6gsji35.png" alt="Final pipeline vs. the lookup" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The gate passed: 83% / 97% / 99% vs the lookup's 75% / 91% / 98%.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then came the uncomfortable result: &lt;strong&gt;with diffusion switched off, the same pipeline scored 93% on the first try.&lt;/strong&gt; A strength sweep on validation data agreed: no diffusion beat every diffusion setting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Iteration 5: the realistic test, between grid points
&lt;/h2&gt;

&lt;p&gt;Real telemetry doesn't arrive on a neat grid. Between the grid points, the lookup falls apart and the stored-result trick has nothing to read.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzp981pkvo2nu1ntej2yy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzp981pkvo2nu1ntej2yy.png" alt="Off-grid results" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lookup:&lt;/strong&gt; 1% on the first try, 16% within 10.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retrieve-refine-verify:&lt;/strong&gt; ~50% on the first try, 98% within 10.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Iteration 7&lt;/strong&gt; interpolates each retrieved airfoil's stored results from the 4 surrounding grid points. That estimate is ~3.5× more accurate than the surrogate and lifts the first try to &lt;strong&gt;58%&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Iteration 6: making diffusion physics-aware
&lt;/h2&gt;

&lt;p&gt;Back to the original idea: a &lt;em&gt;constrained&lt;/em&gt; diffusion model. I fine-tuned it with a PIDM-style loss (the surrogate's lift/drag of each denoised shape must match the request), balanced against the normal denoising loss with ConFIG gradient combining. All of it is hand-written backprop in NumPy, checked against finite differences.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffe4vvs88ivjuq3elgbxe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffe4vvs88ivjuq3elgbxe.png" alt="Phase 2 effect" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The physics error of generated shapes fell ~30%. Diffusion alone improved modestly, most clearly off-grid (10% → 18% on one sample, 58% → 70% within 10). It still trails direct surrogate polishing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Update: independent checks
&lt;/h2&gt;

&lt;p&gt;A commenter pointed out that a surrogate whose error matches the tolerance turns optimization into noise. The same problem turned out to apply one level up, to the solver itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;XFOIL re-check.&lt;/strong&gt; XFOIL played no part in training or selection. On the final designs, NeuralFoil and XFOIL disagree by a median of 0.014 in CL (about 2–3%), which is more than my 1% tolerance.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Targets&lt;/th&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;NeuralFoil, 1%/5%&lt;/th&gt;
&lt;th&gt;XFOIL, 1%/5%&lt;/th&gt;
&lt;th&gt;XFOIL, 5%/10%&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;On-grid&lt;/td&gt;
&lt;td&gt;Lookup, 1st try&lt;/td&gt;
&lt;td&gt;75%&lt;/td&gt;
&lt;td&gt;15%&lt;/td&gt;
&lt;td&gt;62%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;On-grid&lt;/td&gt;
&lt;td&gt;Pipeline, best of 10&lt;/td&gt;
&lt;td&gt;96%&lt;/td&gt;
&lt;td&gt;13%&lt;/td&gt;
&lt;td&gt;65%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Off-grid&lt;/td&gt;
&lt;td&gt;Lookup, 1st try&lt;/td&gt;
&lt;td&gt;1%&lt;/td&gt;
&lt;td&gt;2%&lt;/td&gt;
&lt;td&gt;25%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Off-grid&lt;/td&gt;
&lt;td&gt;Pipeline, best of 10&lt;/td&gt;
&lt;td&gt;97%&lt;/td&gt;
&lt;td&gt;22%&lt;/td&gt;
&lt;td&gt;73%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;On the grid, the pipeline's edge disappears under XFOIL. Between grid points, the realistic case for telemetry, it holds at about 3× the lookup.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real wind-tunnel data.&lt;/strong&gt; I used 100 measured points from the UIUC Low-Speed Airfoil Tests (85 airfoils, Re 1.8–3.6×10⁵). XFOIL on the &lt;em&gt;actual tested airfoils&lt;/em&gt; misses the measurements by a median of 0.076 in CL and 11% in CD, so 1% agreement with a tunnel isn't realistic at this Reynolds number. Scored by XFOIL, the pipeline's designs come much closer to the measured targets than the lookup's (83% vs 55% within 5%/10% on the first try).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3-D wing.&lt;/strong&gt; I built a tapered drone wing from 3 sections, each at least 10% thick for a spar. Section drag fell 6–10%, and XFOIL confirms about 10% at the root and tip. Whole-wing best L/D went from 19.5 to 20.0 in AeroSandbox, but AeroSandbox uses NeuralFoil inside, so that number isn't independent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; a model trained and judged by the same fast solver can look far more accurate than it is. Always check with a second judge.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd tell myself at the start
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Beat the baseline before celebrating the model.&lt;/strong&gt; The lookup table was the most important experiment in the project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your stand-in solver must be more accurate than your tolerance&lt;/strong&gt;, or every gate and filter built on it is noise.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reuse what you've already paid for.&lt;/strong&gt; Stored solver results gave an exact gate and a free bias correction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test the realistic case.&lt;/strong&gt; On-grid numbers looked great; off-grid is where the method actually earns its keep.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Report the ablation that hurts.&lt;/strong&gt; Diffusion turned out to be optional here, and that's useful to know.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Honest limits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;NeuralFoil labels the data and picks the designs. Against XFOIL the 1% CL tolerance isn't met (see the update above); a RANS/Navier-Stokes check is still missing.&lt;/li&gt;
&lt;li&gt;Mostly 2-D sections. The 3-D wing test uses a simple model and only one structural rule (spar depth).&lt;/li&gt;
&lt;li&gt;100 targets per test set and one run each, so there are no error bars. Differences of a few points are noise.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&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/Flotrpy/airfoil-diffusion
&lt;span class="nb"&gt;cd &lt;/span&gt;airfoil-diffusion
pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt
python scripts/01_make_dataset.py &lt;span class="nt"&gt;--n-airfoils&lt;/span&gt; 12000
python scripts/03_train_diffusion.py &lt;span class="nt"&gt;--steps&lt;/span&gt; 200000 &lt;span class="nt"&gt;--width&lt;/span&gt; 128
python scripts/07_refine_eval.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All the numbers in this post are in &lt;a href="https://github.com/Flotrpy/airfoil-diffusion/blob/main/docs/blog/results.csv" rel="noopener noreferrer"&gt;&lt;code&gt;docs/blog/results.csv&lt;/code&gt;&lt;/a&gt; and &lt;code&gt;results/*.json&lt;/code&gt;. Feedback is very welcome, especially from anyone with access to a real CFD solver.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>python</category>
      <category>engineering</category>
    </item>
    <item>
      <title>Zod vs Valibot vs a Handwritten Type Guard: Same Rules, Different Results</title>
      <dc:creator>Affan Shaik</dc:creator>
      <pubDate>Fri, 30 Oct 2026 03:16:24 +0000</pubDate>
      <link>https://dev.to/affan_shaik/zod-vs-valibot-vs-a-handwritten-type-guard-same-rules-different-results-mf3</link>
      <guid>https://dev.to/affan_shaik/zod-vs-valibot-vs-a-handwritten-type-guard-same-rules-different-results-mf3</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftjmo05shwcoyms95tmng.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftjmo05shwcoyms95tmng.png" alt=" " width="800" height="336"&gt;&lt;/a&gt;&lt;br&gt;
TypeScript types disappear when your code runs. So anything that comes from outside your program (an API response, a form, a JSON file) needs a runtime check before you can trust it.&lt;/p&gt;

&lt;p&gt;I wrote that check three ways: a handwritten type guard, Zod, and Valibot. Then I ran all three against the same 41 test inputs. By the end of this post you'll know:&lt;/p&gt;

&lt;p&gt;why "max 100 characters" gave two different answers for the same string,&lt;br&gt;
how one import line made a Zod bundle 5× bigger,&lt;br&gt;
what each approach costs in bundle size and speed,&lt;br&gt;
and which one I'd pick for which job.&lt;br&gt;
Everything here comes from a repo you can clone and rerun. Every number below was produced by its scripts.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Flotrpy" rel="noopener noreferrer"&gt;
        Flotrpy
      &lt;/a&gt; / &lt;a href="https://github.com/Flotrpy/validator-showdown" rel="noopener noreferrer"&gt;
        validator-showdown
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Same data, same rules, three TypeScript validators. A handwritten guard vs Zod vs Valibot, tested side by side with 30+ fixtures, pass/fail results, bundle-size comparison.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;⚔️ Validator Showdown&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Same data. Same rules. Three validators. One of them almost lets 102 characters through a 100-character limit.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A handwritten type guard vs Zod vs Valibot, run side by side on the same fixtures, with pass/fail results, bundle sizes, and a runtime benchmark.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/Flotrpy/validator-showdown/actions/workflows/ci.yml" rel="noopener noreferrer"&gt;&lt;img src="https://github.com/Flotrpy/validator-showdown/actions/workflows/ci.yml/badge.svg" alt="CI"&gt;&lt;/a&gt;
&lt;a href="https://github.com/Flotrpy/validator-showdown/tsconfig.json" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/b5a6d8987c7b2df75e8f265cbd77573bdec14f2716c3abce3bcd345d35b5622c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f547970655363726970742d7374726963742d3331373843363f6c6f676f3d74797065736372697074266c6f676f436f6c6f723d7768697465" alt="TypeScript"&gt;&lt;/a&gt;
&lt;a href="https://github.com/Flotrpy/validator-showdown/package.json" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/c52329e090188828581154d5f74bd797b8a0304d977ea65d71eca67611ef549b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6e6f64652d25334525334432302e31392d3333393933333f6c6f676f3d6e6f64652e6a73266c6f676f436f6c6f723d7768697465" alt="Node"&gt;&lt;/a&gt;
&lt;a href="https://github.com/Flotrpy/validator-showdown/LICENSE" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/07a7d0169027aac6d7a0bfa8964dfef5fbc40d5a2075cabb3d8bc67e17be3451/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d79656c6c6f772e737667" alt="License: MIT"&gt;&lt;/a&gt;
&lt;br&gt;
&lt;a href="https://zod.dev" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/8012c7fa2c2e8521ae510b038baba1b01878791e47ec129a1529d773c293dc8d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5a6f642d342d3345363742313f6c6f676f3d7a6f64266c6f676f436f6c6f723d7768697465" alt="Zod"&gt;&lt;/a&gt;
&lt;a href="https://valibot.dev" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/65837dc329a7598ec0d5e60ca38fe10c0f24474af17843da8d509101287a5ed3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f56616c69626f742d312d463541363233" alt="Valibot"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/Flotrpy/validator-showdown/results/RESULTS.md" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/d8aacb544ea34abc1c9cbaee649265b619da124dc86c262fe3fb14f6332e0189/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636865636b732d3132332532463132332532307061737365642d627269676874677265656e" alt="checks"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://vitest.dev" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/0b5458009751dcaf2df7d06e01a0688fb3ccf8959065c8cb168e9b24fd06f427/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f746573746564253230776974682d5669746573742d3645394631383f6c6f676f3d766974657374266c6f676f436f6c6f723d7768697465" alt="Vitest"&gt;&lt;/a&gt;
&lt;a href="https://github.com/Flotrpy/validator-showdown/.github/workflows/ci.yml" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/3bd2135411e30ecabede7337b422e5e84b99554bced0cc6cfad8e1601adfd0f7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72756e732532306f6e2d57696e646f77732532302537432532306d61634f532532302537432532304c696e75782d696e666f726d6174696f6e616c" alt="Windows | macOS | Linux"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;The problem: TypeScript types vanish at runtime&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;TypeScript checks your code, not your data. This compiles without a single warning:&lt;/p&gt;
&lt;div class="highlight highlight-source-ts notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;interface&lt;/span&gt; &lt;span class="pl-smi"&gt;User&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt;
  &lt;span class="pl-c1"&gt;name&lt;/span&gt;: &lt;span class="pl-smi"&gt;string&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
  &lt;span class="pl-c1"&gt;age&lt;/span&gt;: &lt;span class="pl-smi"&gt;number&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
&lt;span class="pl-kos"&gt;}&lt;/span&gt;

&lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-s1"&gt;user&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-c1"&gt;JSON&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-en"&gt;parse&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-s"&gt;'{"name": 42, "age": "old"}'&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt; &lt;span class="pl-k"&gt;as&lt;/span&gt; &lt;span class="pl-smi"&gt;User&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
&lt;span class="pl-s1"&gt;user&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-c1"&gt;name&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-en"&gt;toUpperCase&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt; &lt;span class="pl-c"&gt;// 💥 TypeError at runtime&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;After compilation, &lt;code&gt;interface User&lt;/code&gt; is gone. The JavaScript that actually runs has no idea what a &lt;code&gt;User&lt;/code&gt; is. Anything that crosses a boundary (an API response, a form, a file, &lt;code&gt;localStorage&lt;/code&gt;) is &lt;code&gt;unknown&lt;/code&gt; until something checks it at runtime.&lt;/p&gt;
&lt;p&gt;So I wrote that check…&lt;/p&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Flotrpy/validator-showdown" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;The problem: TypeScript types vanish at runtime&lt;br&gt;
This compiles with zero warnings:&lt;/p&gt;

&lt;p&gt;interface User {&lt;br&gt;
  name: string;&lt;br&gt;
  age: number;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;const user = JSON.parse('{"name": 42, "age": "old"}') as User;&lt;br&gt;
user.name.toUpperCase(); // TypeError at runtime&lt;br&gt;
The as User is a promise to the compiler, not a check. After compilation, interface User is gone. The JavaScript that runs has no idea what a User is.&lt;/p&gt;

&lt;p&gt;The fix is a type guard: a function that checks the value at runtime and tells TypeScript what it found.&lt;/p&gt;

&lt;p&gt;function isUser(input: unknown): input is User {&lt;br&gt;
  // runtime checks go here&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;if (isUser(data)) {&lt;br&gt;
  data.name; // TypeScript now knows this is a string&lt;br&gt;
}&lt;br&gt;
The contract all three validators must follow&lt;br&gt;
interface User {&lt;br&gt;
  id: string;&lt;br&gt;
  name: string;            // 1-100 UTF-16 code units&lt;br&gt;
  age: number;             // integer, 18-120&lt;br&gt;
  role: "admin" | "user";&lt;br&gt;
  tags: string[];&lt;br&gt;
  profile: { bio: string; active: boolean };&lt;br&gt;
}&lt;br&gt;
The extra rules:&lt;/p&gt;

&lt;p&gt;Extra keys are rejected, both at the top level and inside profile.&lt;br&gt;
No coercion. The string "25" is not a valid age.&lt;br&gt;
Input is plain JSON data: what JSON.parse gives you.&lt;br&gt;
Every validator exports the same function: isUser(input: unknown): input is User.&lt;/p&gt;

&lt;p&gt;The three contenders&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Handwritten guard: plain TypeScript, no library
export function isUser(input: unknown): input is User {
if (!isPlainObject(input) || !hasExactKeys(input, USER_KEYS)) return false;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;return (&lt;br&gt;
    typeof input.id === "string" &amp;amp;&amp;amp;&lt;br&gt;
    isValidName(input.name) &amp;amp;&amp;amp;      // 1 &amp;lt;= name.length &amp;lt;= 100&lt;br&gt;
    isValidAge(input.age) &amp;amp;&amp;amp;        // Number.isInteger, 18-120&lt;br&gt;
    isValidRole(input.role) &amp;amp;&amp;amp;&lt;br&gt;
    isStringArray(input.tags) &amp;amp;&amp;amp;&lt;br&gt;
    isValidProfile(input.profile)   // exact keys, bio string, active boolean&lt;br&gt;
  );&lt;br&gt;
}&lt;br&gt;
hasExactKeys uses Object.keys() and Object.hasOwn(). That's how it rejects extra keys.&lt;/p&gt;

&lt;p&gt;It has no dependencies and nothing new to learn. The catch is that the User interface and the guard are two separate things, and only tests keep them in sync.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Zod
import * as z from "zod";&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;export const UserSchema = z.strictObject({&lt;br&gt;
  id: z.string(),&lt;br&gt;
  name: z.string().refine((name) =&amp;gt; name.length &amp;gt;= 1 &amp;amp;&amp;amp; name.length &amp;lt;= 100),&lt;br&gt;
  age: z.int().min(18).max(120),&lt;br&gt;
  role: z.enum(["admin", "user"]),&lt;br&gt;
  tags: z.array(z.string()),&lt;br&gt;
  profile: z.strictObject({ bio: z.string(), active: z.boolean() }),&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;export function isUser(input: unknown): input is User {&lt;br&gt;
  return UserSchema.safeParse(input).success;&lt;br&gt;
}&lt;br&gt;
z.strictObject rejects unknown keys. Here the schema is the source of truth, and z.infer gives you the type for free.&lt;/p&gt;

&lt;p&gt;You might be wondering why name uses .refine() instead of .min(1).max(100). Hold that thought.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Valibot
import * as v from "valibot";&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;export const UserSchema = v.strictObject({&lt;br&gt;
  id: v.string(),&lt;br&gt;
  name: v.pipe(v.string(), v.minLength(1), v.maxLength(100)),&lt;br&gt;
  age: v.pipe(v.number(), v.integer(), v.minValue(18), v.maxValue(120)),&lt;br&gt;
  role: v.picklist(["admin", "user"]),&lt;br&gt;
  tags: v.array(v.string()),&lt;br&gt;
  profile: v.strictObject({ bio: v.string(), active: v.boolean() }),&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;export function isUser(input: unknown): input is User {&lt;br&gt;
  return v.is(UserSchema, input);&lt;br&gt;
}&lt;br&gt;
It's the same idea as Zod, but built from small functions you pipe together instead of chained methods. v.is() is a built-in type guard.&lt;/p&gt;

&lt;p&gt;Small trick worth stealing: both schema files include a compile-time check, Expect, User&amp;gt;&amp;gt;. If a schema drifts away from the User type, tsc fails. I tested it by changing tags to numbers, and the build broke right away.&lt;/p&gt;

&lt;p&gt;The surprise: how long is an emoji?&lt;br&gt;
"Name must be at most 100 characters" sounds like one rule. It's really a question: what counts as a character?&lt;/p&gt;

&lt;p&gt;JavaScript strings are stored as UTF-16, an encoding where most characters take one 16-bit "code unit". An emoji like 😀 takes two. string.length counts those code units:&lt;/p&gt;

&lt;p&gt;"a".length;                          // 1&lt;br&gt;
"😀".length;                         // 2&lt;br&gt;
"😀".repeat(51).length;              // 102  &amp;lt;- over the limit&lt;br&gt;
Array.from("😀".repeat(51)).length;  // 51   &amp;lt;- Unicode code points&lt;br&gt;
My contract says 1-100 UTF-16 code units, so 51 emoji (102 units) must be rejected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgoegupezbiztmlzmxt4x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgoegupezbiztmlzmxt4x.png" alt=" " width="799" height="264"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Here's what each length check did with it:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Bar chart: string.length counts 102 UTF-16 units and rejects the name; Zod's built-in max counts 51 code points and accepts it. A dashed line marks the limit of 100.&lt;/p&gt;

&lt;p&gt;Zod's built-in z.string().max(100) counts Unicode code points, not UTF-16 code units. It sees 51, not 102, and lets the name through. Valibot's v.maxLength(100) and my handwritten guard both use string.length, see 102, and reject it.&lt;/p&gt;

&lt;p&gt;Zod isn't wrong here. Counting code points is arguably closer to what a human means by "character". But it isn't my contract. If a database column or another service downstream counts UTF-16 units, those 51 emoji become a bug that only shows up in production.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;The fix is to say exactly what I mean:&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
name: z.string().refine((name) =&amp;gt; name.length &amp;gt;= 1 &amp;amp;&amp;amp; name.length &amp;lt;= 100),&lt;br&gt;
With that, all three agree. Two fixtures guard this edge: name 50 emoji (exactly 100 units, valid) and name 51 emoji (102 units, invalid). One test also pins down Zod's built-in behavior, so I'll know if it ever changes.&lt;/p&gt;

&lt;p&gt;Lesson: when two libraries have a rule with the same name, they don't always mean the same thing. Test the boundary with an emoji.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test results: 123 out of 123&lt;/strong&gt;&lt;br&gt;
There are 41 fixtures in one shared file. Each has a name, an input, the expected answer, and a one-line reason:&lt;/p&gt;

&lt;p&gt;{&lt;br&gt;
  name: "name 51 emoji",&lt;br&gt;
  group: "emoji",&lt;br&gt;
  input: userWith({ name: "😀".repeat(51) }),&lt;br&gt;
  expected: false,&lt;br&gt;
  why: "51 emoji is only 51 code points but 102 UTF-16 code units, over the limit.",&lt;br&gt;
}&lt;br&gt;
They cover valid users, age boundaries (17, 18, 120, 121, 18.5), name boundaries (0, 1, 100, 101 characters), the emoji cases, wrong types, missing fields, bad roles, bad tags, extra keys (including a sneaky &lt;strong&gt;proto&lt;/strong&gt; key created by JSON.parse), and non-objects like null and arrays.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs8qmcto0fx8el9pbjyli.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs8qmcto0fx8el9pbjyli.png" alt=" " width="799" height="302"&gt;&lt;/a&gt;&lt;br&gt;
npm run compare runs every fixture through every validator and prints a color-coded table:&lt;/p&gt;

&lt;p&gt;| Fixture               | Expected | Handwritten | Zod  | Valibot | Note |&lt;br&gt;
| name 50 emoji         | valid    | PASS        | PASS | PASS    |      |&lt;br&gt;
| name 51 emoji         | invalid  | PASS        | PASS | PASS    |      |&lt;br&gt;
| age as string         | invalid  | PASS        | PASS | PASS    |      |&lt;br&gt;
| extra &lt;strong&gt;proto&lt;/strong&gt; key   | invalid  | PASS        | PASS | PASS    |      |&lt;br&gt;
...&lt;br&gt;
123/123 checks passed (41 fixtures x 3 validators)&lt;br&gt;
No disagreements: all validators gave the same answer on every fixture.&lt;br&gt;
Group           Fixtures   Handwritten  Zod Valibot&lt;br&gt;
valid           3          ✅ 3/3  ✅ 3/3 ✅ 3/3&lt;br&gt;
age         5          ✅ 5/5  ✅ 5/5 ✅ 5/5&lt;br&gt;
name            4          ✅ 4/4  ✅ 4/4 ✅ 4/4&lt;br&gt;
emoji           2          ✅ 2/2  ✅ 2/2 ✅ 2/2&lt;br&gt;
types           7          ✅ 7/7  ✅ 7/7 ✅ 7/7&lt;br&gt;
missing         4          ✅ 4/4  ✅ 4/4 ✅ 4/4&lt;br&gt;
role            3          ✅ 3/3  ✅ 3/3 ✅ 3/3&lt;br&gt;
tags            3          ✅ 3/3  ✅ 3/3 ✅ 3/3&lt;br&gt;
extra-keys  4          ✅ 4/4  ✅ 4/4 ✅ 4/4&lt;br&gt;
non-object  6          ✅ 6/6  ✅ 6/6 ✅ 6/6&lt;br&gt;
I tested the table itself too. When I swapped Zod back to the built-in .max(100), the script printed 122/123 checks passed, flagged the name 51 emoji row as DISAGREE, and exited with an error. The safety net works.&lt;/p&gt;

&lt;p&gt;On top of the fixtures, Vitest (the test runner) runs 478 tests in six files. That includes a check that no validator mutates its input: every input stays deep-equal after validation and still works when deeply frozen.&lt;/p&gt;

&lt;p&gt;Bundle size: what does one isUser cost?&lt;br&gt;
I bundled each validator on its own with esbuild for the browser as ESM (ECMAScript modules, the standard import/export format), minified it, then compressed it with gzip and Brotli:&lt;/p&gt;

&lt;p&gt;Bar chart of gzipped bundle size: Handwritten 434 B, Zod 26.5 kB, Valibot 1.9 kB.&lt;/p&gt;

&lt;p&gt;Validator   Minified    Gzip      Brotli&lt;br&gt;
Handwritten   832 B         434 B     379 B&lt;br&gt;
Zod           90.6 kB   26.5 kB   23.5 kB&lt;br&gt;
Valibot           5.8 kB    1.9 kB    1.7 kB&lt;br&gt;
This is standalone cost only. Each row is one schema and nothing else. In a real app you pay for the library once and every extra schema is cheap, so don't read this as "Zod costs 26 kB per form".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk3jgi14wmin0h103nyik.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk3jgi14wmin0h103nyik.png" alt=" " width="799" height="263"&gt;&lt;/a&gt;&lt;br&gt;
The import line that cost 364 kB&lt;br&gt;
My first measurement had Zod at 454.3 kB minified. The culprit was one line:&lt;/p&gt;

&lt;p&gt;import { z } from "zod";   // pulls in everything&lt;br&gt;
import * as z from "zod";  // what the Zod docs recommend&lt;br&gt;
Bar chart: import { z } from "zod" bundles to 454.3 kB minified; import * as z from "zod" bundles to 90.6 kB.&lt;/p&gt;

&lt;p&gt;Same schema, same build settings, 5× smaller. The namespace import lets esbuild tree-shake Zod, meaning it drops the parts my schema never uses. Both measurements are in the repo's git history.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Runtime benchmark&lt;/strong&gt;&lt;br&gt;
npm run bench calls each isUser in a tight loop. It warms up first so V8's JIT (just-in-time compiler) can optimize the code, then takes 25 samples of 20,000 calls and reports the median nanoseconds per call:&lt;/p&gt;

&lt;p&gt;Two bar charts on the same scale. Valid input: Handwritten 172.2 ns, Zod 612.3 ns, Valibot 1,435.3 ns. Invalid input: Handwritten 79.4 ns, Zod 1,635 ns, Valibot 765.6 ns.&lt;/p&gt;

&lt;p&gt;Validator   Valid input Invalid input&lt;br&gt;
Handwritten 172.2 ns    79.4 ns&lt;br&gt;
Zod         612.3 ns    1,635 ns&lt;br&gt;
Valibot         1,435.3 ns  765.6 ns&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I noticed:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The handwritten guard won both. That makes sense, since it does nothing extra.&lt;br&gt;
Zod was faster than Valibot on valid input but slower on invalid input. My guess is that safeParse builds a detailed error object even when all I want is true or false.&lt;br&gt;
Smallest bundle ≠ fastest runtime. Valibot had the smallest library bundle but the slowest valid-input time.&lt;br&gt;
⚠️ This is a microbenchmark, not a universal ranking. It's one small schema, on one machine (Node 22, Linux), with tiny inputs. CPU, JIT warmup, input shape, and library versions all move these numbers. Every result is under 2 microseconds per call, which is fast enough for almost any app. Run it on your own machine before you believe it.&lt;/p&gt;

&lt;p&gt;One more difference: inherited keys&lt;br&gt;
All three agree on JSON data. Outside that domain, they don't.&lt;/p&gt;

&lt;p&gt;const input = Object.assign(Object.create({ inherited: true }), validUser());&lt;br&gt;
This object has an extra key on its prototype, which JSON.parse can never produce. My guard accepts it because Object.keys() only sees own keys. Zod and Valibot reject it because they walk keys with for...in, which includes inherited ones.&lt;/p&gt;

&lt;p&gt;Neither is wrong for JSON input. But "strict object" doesn't mean exactly the same thing in every library, and I only know because I wrote a test for it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You Try it:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;git clone &lt;a href="https://github.com/Flotrpy/validator-showdown.git" rel="noopener noreferrer"&gt;https://github.com/Flotrpy/validator-showdown.git&lt;/a&gt;&lt;br&gt;
cd validator-showdown&lt;br&gt;
npm install&lt;br&gt;
npm run verify&lt;br&gt;
npm run verify runs lint, type checking, all tests, and the comparison table. CI (continuous integration, which runs the checks automatically on every push) runs it on Windows, macOS, and Linux with Node 20, 22, and 24.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0z7h03a828h9asqwqb44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0z7h03a828h9asqwqb44.png" alt=" " width="800" height="506"&gt;&lt;/a&gt;&lt;br&gt;
What I learned&lt;br&gt;
A rule with the same name isn't always the same rule. One fixture with 51 emoji showed me that.&lt;br&gt;
Read your library's definition of "length". Code points and UTF-16 code units are different contracts.&lt;br&gt;
How you import matters as much as what you import. One line was the difference between 454 kB and 91 kB.&lt;br&gt;
Small bundle and fast runtime are different goals. Measure both.&lt;br&gt;
Generated docs stay honest. The results, bundle, and benchmark tables in the repo's README are written by scripts, and CI fails if they go stale.&lt;br&gt;
Which validator do you reach for, and have you ever been bitten by a string length check? Tell me in the comments. I read every one.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>programming</category>
      <category>performance</category>
    </item>
    <item>
      <title>Where most memory tools help your agent remember more, mnemoa helps it forget what no longer belongs.</title>
      <dc:creator>Affan Shaik</dc:creator>
      <pubDate>Fri, 23 Oct 2026 00:53:02 +0000</pubDate>
      <link>https://dev.to/affan_shaik/where-most-memory-tools-help-your-agent-remember-more-mnemoa-helps-it-forget-what-no-longer-43jc</link>
      <guid>https://dev.to/affan_shaik/where-most-memory-tools-help-your-agent-remember-more-mnemoa-helps-it-forget-what-no-longer-43jc</guid>
      <description>&lt;h1&gt;
  
  
  I built *&lt;em&gt;mnemoa *&lt;/em&gt; to keep AI coding instructions from going stale.
&lt;/h1&gt;

&lt;p&gt;*&lt;em&gt;mnemoa *&lt;/em&gt; is built to make coding agents forget: it finds the stale, redundant and contradictory lines in AGENTS.md, CLAUDE.md and other instruction files, so they can be deleted rather than piled on.&lt;/p&gt;

&lt;p&gt;Coding agents rely on files like &lt;code&gt;AGENTS.md&lt;/code&gt;, &lt;code&gt;CLAUDE.md&lt;/code&gt;, and project plans to understand a codebase. Over time, those files can get long, repeat rules already enforced by tools, and point to paths or commands that no longer exist.&lt;/p&gt;

&lt;p&gt;I built &lt;strong&gt;mnemoa&lt;/strong&gt; to help keep that repo memory small, accurate, and useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;p&gt;*&lt;em&gt;mnemoa *&lt;/em&gt; scans a repository’s agent instruction files and plans. It checks for issues such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instructions that are too long or consume too much always-loaded context&lt;/li&gt;
&lt;li&gt;Broken paths, symbols, and commands&lt;/li&gt;
&lt;li&gt;Plans that have drifted from the code&lt;/li&gt;
&lt;li&gt;Rules that a formatter, linter, or other tool could enforce instead&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It can also create a prune plan showing what it would remove or move, along with the estimated token cost before and after. You can review the diff before applying it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea behind “promote, then forget”
&lt;/h2&gt;

&lt;p&gt;Some instructions describe rules that tools can already enforce. *&lt;em&gt;mnemoa *&lt;/em&gt; can help turn those rules into checks, such as EditorConfig settings, Cargo lints, Ruff settings, ast-grep rules, or pre-commit hooks. It records the promotion in a ledger, so the instruction can leave the context file without losing track of why it existed.&lt;/p&gt;

&lt;p&gt;The goal is to keep useful guidance available while reducing repetition and stale instructions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Offline by default
&lt;/h2&gt;

&lt;p&gt;*&lt;em&gt;mnemoa *&lt;/em&gt; is written in Rust and runs deterministic checks locally. The optional LLM feature can help draft rules, but it is disabled by default. You can use the CLI, run the optional HTTP API, or connect through the Python SDK.&lt;/p&gt;

&lt;p&gt;It models how seven coding agents load instruction files: Claude Code, Codex, Cursor, Copilot, Kiro, Cline, and Gemini.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;Install from the repository and scan a project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--path&lt;/span&gt; crates/mnemoa-cli
mnemoa scan &lt;span class="nb"&gt;.&lt;/span&gt;
mnemoa forget
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;mnemoa forget&lt;/code&gt; shows a dry-run plan. To apply the changes after reviewing them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mnemoa forget &lt;span class="nt"&gt;--apply&lt;/span&gt; &lt;span class="nt"&gt;--yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The project also includes a GitHub Action for running scans and drift checks in CI.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I’d like feedback on
&lt;/h2&gt;

&lt;p&gt;I’d especially like to hear how *&lt;em&gt;mnemoa *&lt;/em&gt; handles real instruction files: which findings are useful, which ones are noisy, and what kinds of repo drift it should catch next.&lt;/p&gt;

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

</description>
      <category>ai</category>
      <category>programming</category>
      <category>database</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
