<?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: Raymond Chang</title>
    <description>The latest articles on DEV Community by Raymond Chang (@dr_delta234).</description>
    <link>https://dev.to/dr_delta234</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%2F3636485%2F6d1ddb32-cee5-4e4b-8db1-bf3bdb0bf990.jpg</url>
      <title>DEV Community: Raymond Chang</title>
      <link>https://dev.to/dr_delta234</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dr_delta234"/>
    <language>en</language>
    <item>
      <title>I Faked My Own Drug Valuation. 17 Lines of Python Caught Me.</title>
      <dc:creator>Raymond Chang</dc:creator>
      <pubDate>Tue, 24 Nov 2026 21:49:05 +0000</pubDate>
      <link>https://dev.to/dr_delta234/i-faked-my-own-drug-valuation-17-lines-of-python-caught-me-3kph</link>
      <guid>https://dev.to/dr_delta234/i-faked-my-own-drug-valuation-17-lines-of-python-caught-me-3kph</guid>
      <description>&lt;p&gt;I build a drug valuation app called Somota. This week I tried to cheat on my own numbers, on camera, to see whether the app would catch me.&lt;/p&gt;

&lt;p&gt;Video: &lt;a href="https://youtu.be/_qJZJFU8xTo" rel="noopener noreferrer"&gt;https://youtu.be/_qJZJFU8xTo&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;In a drug licensing deal, a valuation is usually a big spreadsheet that gets emailed between two companies, bankers and lawyers. Months later somebody asks which version everybody agreed on, and nobody can prove it.&lt;/p&gt;

&lt;p&gt;So every valuation in Somota is now signed as a receipt:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Take every input (odds of success, costs, sales, discount rate) and serialize it as canonical JSON: sorted keys, no spaces.&lt;/li&gt;
&lt;li&gt;Hash it with SHA-256. That is the fingerprint.&lt;/li&gt;
&lt;li&gt;Sign the fingerprint with an Ed25519 key that never leaves my machine.&lt;/li&gt;
&lt;li&gt;Put the previous receipt's fingerprint inside the new one, so the receipts form a chain.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Changed the odds of success from 10.8% to 30%.&lt;/strong&gt; Caught. The fingerprint no longer matches, and Verify shows which field moved.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Changed one character of the signature.&lt;/strong&gt; Caught. The signature no longer verifies against my public key.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Renamed receipt #2 so it vanished from the chain.&lt;/strong&gt; Caught. Receipt #3 still points at the missing fingerprint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deleted the newest receipt.&lt;/strong&gt; Not caught. Nothing points at the newest receipt yet, so the chain still looks complete. That is a real hole, and the next thing I'm building (anchoring the latest fingerprint somewhere public) is meant to close it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The checker
&lt;/h2&gt;

&lt;p&gt;The other side of a deal shouldn't have to trust my software. This is the whole independent checker. It doesn't import anything from my app:&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;# Check one Somota receipt without the Somota app. Usage: python check_receipt.py 1&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cryptography&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hazmat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;primitives&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;serialization&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;load_pem_public_key&lt;/span&gt;

&lt;span class="n"&gt;folder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&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="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;"receipts"&lt;/span&gt;
&lt;span class="n"&gt;rec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{folder}/receipt_{int(sys.argv[1]):04d}.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&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="n"&gt;rec&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="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"n"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"issued_at"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"prev_hash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"payload"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;canon&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sort_keys&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;separators&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;","&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&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;ensure_ascii&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fingerprint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;canon&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Fingerprint matches:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fingerprint&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;rec&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"hash"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;load_pem_public_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{folder}/desk_public_key.pem"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"rb"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;verify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromhex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rec&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"signature"&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="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromhex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fingerprint&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Signature OK"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Signature FAILED"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On a clean receipt it prints &lt;code&gt;True&lt;/code&gt; and &lt;code&gt;Signature OK&lt;/code&gt;. After I changed 10.8% to 30% it printed &lt;code&gt;False&lt;/code&gt; and &lt;code&gt;Signature FAILED&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Note that it verifies the signature against the fingerprint it rebuilt itself, not against the &lt;code&gt;hash&lt;/code&gt; field stored in the file. If you check against the stored field, a tampered file can still pass the signature step.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a receipt can't do
&lt;/h2&gt;

&lt;p&gt;If I sign garbage, the receipt just proves I signed garbage. It says nothing about where the inputs came from. It only answers one question: is this still the exact file that was signed?&lt;/p&gt;

&lt;p&gt;The harder problem is letting a buyer check my numbers without seeing all my data. That needs a different kind of math, and I'm working on it separately.&lt;/p&gt;

&lt;p&gt;How does your team prove a number never changed after everyone agreed on it?&lt;/p&gt;

</description>
      <category>python</category>
      <category>security</category>
      <category>cryptography</category>
      <category>showdev</category>
    </item>
    <item>
      <title>My options desk showed 16 Greeks and never added them up</title>
      <dc:creator>Raymond Chang</dc:creator>
      <pubDate>Thu, 19 Nov 2026 19:53:18 +0000</pubDate>
      <link>https://dev.to/dr_delta234/my-options-desk-showed-16-greeks-and-never-added-them-up-20d8</link>
      <guid>https://dev.to/dr_delta234/my-options-desk-showed-16-greeks-and-never-added-them-up-20d8</guid>
      <description>&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/F_OsBtlajMA" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Until this week, if you put an iron condor on my options desk and pressed the Greeks key, you got sixteen numbers: delta, theta, vega and gamma for every leg. The number I needed wasn't there. Which way does the whole trade lean?&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the net is the whole point
&lt;/h2&gt;

&lt;p&gt;In a spread, the legs fight each other on purpose. One leg wants the stock up and the other wants it down. So the number you care about is the net: how much the position moves when the stock moves a dollar, and how much it makes or loses per day.&lt;/p&gt;

&lt;p&gt;A list of legs leaves you doing that math in your head, live, with money on the line. It's a grocery receipt that lists every item and never prints a total.&lt;/p&gt;

&lt;h2&gt;
  
  
  The second bug, found by reading the code
&lt;/h2&gt;

&lt;p&gt;While reading that code, my coding assistant found a second problem. The Greeks key sorted the legs into a put side and a call side. On my usual trades, plain two-leg spreads, that sorting happened to work, so it looked fine.&lt;/p&gt;

&lt;p&gt;A butterfly has a middle leg with two contracts. A straddle has both sides at one strike. Those rows came out wrong.&lt;/p&gt;

&lt;p&gt;It was caught by reading the code, before I ever pressed that key on a butterfly. The other way to find a bug like that costs money.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: one list
&lt;/h2&gt;

&lt;p&gt;Two changes, with the checks written first (11 of them, all failing on the old code):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Greeks key now reads the exact list of legs the desk sends to the broker, with the same lots and the same direction. There is no second copy.&lt;/li&gt;
&lt;li&gt;It adds them up, per share and per position. Sold legs flip their sign before they go in the total.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is a simplified version of the sum. It shows the idea and isn't the desk's code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;net_greeks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;legs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lots&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""legs: the same list the order is built from.
    Each leg has an action, a ratio (2 for a butterfly's middle leg) and its Greeks per share."""&lt;/span&gt;
    &lt;span class="n"&gt;per_share&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"delta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"theta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"vega"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"gamma"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;leg&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;legs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;sign&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;leg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"action"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"SELL"&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;g&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;per_share&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;per_share&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;sign&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;leg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ratio"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;leg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;per_position&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;lots&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;per_share&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;per_share&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;per_position&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The butterfly's middle leg is now one line, SELL 2, and it counts twice in the total.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it printed, live in the sandbox
&lt;/h2&gt;

&lt;p&gt;SPY, December 31 expiration, captured November 19, 2026, 10:24 to 10:25 ET. One lot each, per position:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Trade&lt;/th&gt;
&lt;th&gt;Legs&lt;/th&gt;
&lt;th&gt;Net delta&lt;/th&gt;
&lt;th&gt;Theta per day&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Put credit spread&lt;/td&gt;
&lt;td&gt;sold 701P, bought 696P&lt;/td&gt;
&lt;td&gt;+2.51&lt;/td&gt;
&lt;td&gt;+0.50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Iron condor&lt;/td&gt;
&lt;td&gt;670/680P, 770/780C&lt;/td&gt;
&lt;td&gt;-3.22&lt;/td&gt;
&lt;td&gt;+4.83&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Butterfly&lt;/td&gt;
&lt;td&gt;727P / 732P x2 / 737P&lt;/td&gt;
&lt;td&gt;+0.06&lt;/td&gt;
&lt;td&gt;+0.31&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The put credit spread makes about two and a half dollars if SPY goes up a dollar. The iron condor leans a hair bearish, and its vega is -24: if implied volatility jumps one point, it's down about twenty-four dollars. The butterfly is basically flat.&lt;/p&gt;

&lt;p&gt;My coding assistant redid every one of those totals by hand from the leg lines. Flip the sold legs, add them up. They all match.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two clocks on one screen
&lt;/h2&gt;

&lt;p&gt;This one I didn't expect. When I pressed the key live, the quotes on my desk were a few seconds old and the Greeks were about two minutes old. Same screen, same trade, two different clocks.&lt;/p&gt;

&lt;p&gt;So every leg line now prints when its Greeks were made. When the legs came in at different times, the desk prints one more line: the oldest leg it used, and how old it was.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's still missing
&lt;/h2&gt;

&lt;p&gt;The portfolio view still doesn't total gamma. Rho isn't on my desk anywhere yet; the desk doesn't even ask the data feed for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The thing to steal
&lt;/h2&gt;

&lt;p&gt;If your tool shows you numbers about a trade, make sure it reads the same data it sends. One list, never two copies. And print how old every number is.&lt;/p&gt;

&lt;p&gt;I keep a free one-page checklist of every check from my channel, and this one is on it: &lt;a href="https://docs.google.com/forms/d/e/1FAIpQLSeTR4fRmq3iSv9BrDqCU-imTfgdlz_mcP1FLwl4JnRPGPRxOw/viewform?usp=pp_url&amp;amp;entry.1357287784=dd014" rel="noopener noreferrer"&gt;https://docs.google.com/forms/d/e/1FAIpQLSeTR4fRmq3iSv9BrDqCU-imTfgdlz_mcP1FLwl4JnRPGPRxOw/viewform?usp=pp_url&amp;amp;entry.1357287784=dd014&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sandbox only. Not investment advice.&lt;/p&gt;

</description>
      <category>python</category>
      <category>ai</category>
      <category>fintech</category>
    </item>
    <item>
      <title>The AI Coding Workflow Everyone Teaches Fooled Me 3 Times</title>
      <dc:creator>Raymond Chang</dc:creator>
      <pubDate>Wed, 18 Nov 2026 13:16:23 +0000</pubDate>
      <link>https://dev.to/dr_delta234/the-ai-coding-workflow-everyone-teaches-fooled-me-3-times-4be9</link>
      <guid>https://dev.to/dr_delta234/the-ai-coding-workflow-everyone-teaches-fooled-me-3-times-4be9</guid>
      <description>&lt;p&gt;A handful of talks from the AI Engineer conference on how to code with AI have been watched about six million times. I watched them, took notes, and I do most of what they say.&lt;/p&gt;

&lt;p&gt;Put the talks side by side and you get four boxes. A human decides. The AI builds. Something checks it. Whatever breaks goes back in for the next lap.&lt;/p&gt;

&lt;p&gt;I run that loop on two projects. One is a trading desk that only sends orders to a sandbox. The other is a security lab where five AI agents are building a zero-knowledge proof toolchain. Together they have over 8,000 tests.&lt;/p&gt;

&lt;p&gt;My AI still fooled me three times, with every test green. All three happened in the third box.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/0VUc_8wIiIQ" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  1. A review of the summary
&lt;/h2&gt;

&lt;p&gt;One Friday my trading desk crashed on launch. The bug had been in the code for eighteen days, and a test aimed right at that code had been green the whole time.&lt;/p&gt;

&lt;p&gt;I did have a checker. A second AI reviewed the first one's work. It never opened the code. It was grading a report about the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Every rule tested alone
&lt;/h2&gt;

&lt;p&gt;I added five new kinds of trades to the desk. The AI wrote the checks for them, and thousands of tests passed. Then I tried to place one in the sandbox.&lt;/p&gt;

&lt;p&gt;So I made the AI take real data, try every way in, and count how many candidates got past all the rules at once. 34,622 tries, zero winners.&lt;/p&gt;

&lt;p&gt;Every rule had its own passing tests. No test asked whether a single real trade could get through all of them together.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Nobody tested the no
&lt;/h2&gt;

&lt;p&gt;In the lab, the AI wrote a proof verifier. Its one job is to say no to a bad proof. The tests came back green.&lt;/p&gt;

&lt;p&gt;I fed it random bytes and it said valid. The two tests that would have caught that were sitting in the test file. They never ran. I wrote that one up separately: &lt;a href="https://dev.to/dr_delta234/i-fed-my-ai-built-proof-verifier-garbage-it-said-valid-every-time-323o"&gt;I Fed My AI-Built Proof Verifier Garbage. It Said Valid Every Time.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The four checks I run after green
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Test the no.&lt;/strong&gt; Hand your checker exactly what it should reject: a garbage input, a number changed by one digit. Then open the test report and confirm those tests ran.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prove one real case gets through.&lt;/strong&gt; If you have a stack of rules, take real data and make sure at least one case passes all of them at once.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The reviewer opens the real thing.&lt;/strong&gt; Whoever signs off reads the code itself. Matt Pocock's reviewer reads the actual commits. Mine was reading a summary.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run it for real.&lt;/strong&gt; Real parts, the way you would use it. My desk has a practice mode in the sandbox, and it found three problems that thousands of tests missed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Two of these come straight from the talks. I wasn't doing them right.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I still haven't fixed
&lt;/h2&gt;

&lt;p&gt;On the trading desk, the reviewer only sees the real file when I paste it in, and that doesn't happen every round.&lt;/p&gt;

&lt;p&gt;Review reports now carry a file name and a line number, and anything nobody checked gets labeled unchecked. The script that would verify those automatically isn't built yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  The talks
&lt;/h2&gt;

&lt;p&gt;All from the AI Engineer conference, and worth your time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Matt Pocock, &lt;a href="https://youtu.be/-QFHIoCo-Ko" rel="noopener noreferrer"&gt;Full Walkthrough: Workflow for AI Coding&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Matt Pocock, &lt;a href="https://www.youtube.com/watch?v=v4F1gFy-hqg" rel="noopener noreferrer"&gt;Software Fundamentals Matter More Than Ever&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Dex Horthy, &lt;a href="https://www.youtube.com/watch?v=rmvDxxNubIg" rel="noopener noreferrer"&gt;No Vibes Allowed: Solving Hard Problems in Complex Codebases&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Barry Zhang and Mahesh Murag, &lt;a href="https://www.youtube.com/watch?v=CEvIs9y1uog" rel="noopener noreferrer"&gt;Don't Build Agents, Build Skills Instead&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Sean Grove, &lt;a href="https://www.youtube.com/watch?v=8rABwKRsec4" rel="noopener noreferrer"&gt;The New Code&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Follow along
&lt;/h2&gt;

&lt;p&gt;New episodes go up on my YouTube channel first, with the desk, the lab and the terminal on screen:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.youtube.com/@dr_delta234?sub_confirmation=1" rel="noopener noreferrer"&gt;Subscribe to Dr_Delta on YouTube&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What's the one check you run after the tests go green? Tell me in the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>testing</category>
      <category>codereview</category>
      <category>programming</category>
    </item>
    <item>
      <title>I Fed My AI-Built Proof Verifier Garbage. It Said Valid Every Time.</title>
      <dc:creator>Raymond Chang</dc:creator>
      <pubDate>Tue, 17 Nov 2026 16:15:58 +0000</pubDate>
      <link>https://dev.to/dr_delta234/i-fed-my-ai-built-proof-verifier-garbage-it-said-valid-every-time-323o</link>
      <guid>https://dev.to/dr_delta234/i-fed-my-ai-built-proof-verifier-garbage-it-said-valid-every-time-323o</guid>
      <description>&lt;p&gt;I build tools with Claude Code and then go looking for what the AI got wrong. This round, the tool was a zero-knowledge proof library: you prove a number about your data, say an average, and someone else checks it without seeing the data.&lt;/p&gt;

&lt;p&gt;The whole thing lives or dies on one function, the verifier. Its one job is to say no when the proof is bad.&lt;/p&gt;

&lt;p&gt;The AI delivered a Rust part, a Python part, a test file and docs. The tests came back green.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/YJYtwEn_N74" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  The tests that never ran
&lt;/h2&gt;

&lt;p&gt;The test file had two tamper cases in it. Both were marked should fail. Neither one ever ran.&lt;/p&gt;

&lt;p&gt;So the green run said nothing about tampering. It's a smoke detector test where nobody lights a match.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four bad proofs, four VALIDs
&lt;/h2&gt;

&lt;p&gt;My coding assistant copied the old verify code into a quarantine folder and wrote a small harness that feeds it four cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cases 1 and 2:&lt;/strong&gt; the same 128 random bytes as the proof, once with the real public mean and once with the mean changed by 1.0. Verdict: valid, and valid.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Case 3:&lt;/strong&gt; what the library's simulation mode calls a proof. It is a SHA-256 hash of the public numbers, checked against a verification key that is the literal bytes &lt;code&gt;mock_verification_key&lt;/code&gt;. Anyone can compute that hash with no data at all. Verdict: valid.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Case 4:&lt;/strong&gt; the same random bytes again, with the changed mean, through the third source's verify path. Verdict: valid.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first line the library printed, before any of this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Warning: Rust backend not available, using simulation mode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;One warning, then valid to everything.&lt;/p&gt;

&lt;h2&gt;
  
  
  On the desk and on the phone
&lt;/h2&gt;

&lt;p&gt;A terminal is easy to ignore, so I put it on my desk. A Stream Deck key called GARBAGE sends random bytes to that old verify code. The answer comes back in a window: &lt;code&gt;LEGACY: VALID&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A second key shows a QR code. My phone scans it and opens a verify page from the same server. Big green check, VERIFIED, for any input you send it.&lt;/p&gt;

&lt;p&gt;Nothing here is a real proof. The numbers are 20 synthetic trades from a fixed seed. I took no measurements this round.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steal this
&lt;/h2&gt;

&lt;p&gt;When you test a checker, write the "no" tests first, and make sure they run:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os

def test_rejects_random_bytes(public):
    assert not verify(os.urandom(128), public)

def test_rejects_changed_number(proof, public):
    public = dict(public, mean=public["mean"] + 1)
    assert not verify(proof, public)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then check your test report for the word "skipped" or a test count lower than you expect. A tamper test that never runs looks exactly like a tamper test that passes.&lt;/p&gt;

&lt;p&gt;If the checker says yes to garbage or to a number you changed by one digit, it's broken.&lt;/p&gt;

&lt;h2&gt;
  
  
  Follow the lab
&lt;/h2&gt;

&lt;p&gt;Security Lab episodes go up on my YouTube channel first, with the terminal, the desk and the phone on screen:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.youtube.com/@dr_delta234?sub_confirmation=1" rel="noopener noreferrer"&gt;Subscribe to Dr_Delta on YouTube&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Have you ever had a test suite go all green when it never checked the failure case? How did you find out? Tell me in the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>testing</category>
      <category>security</category>
      <category>python</category>
    </item>
    <item>
      <title>My Trading Tool's Rules Could Never All Pass. Every Unit Test Said They Were Fine.</title>
      <dc:creator>Raymond Chang</dc:creator>
      <pubDate>Mon, 16 Nov 2026 16:45:49 +0000</pubDate>
      <link>https://dev.to/dr_delta234/my-trading-tools-rules-could-never-all-pass-every-unit-test-said-they-were-fine-2me3</link>
      <guid>https://dev.to/dr_delta234/my-trading-tools-rules-could-never-all-pass-every-unit-test-said-they-were-fine-2me3</guid>
      <description>&lt;p&gt;I'm building an options trading tool with Claude Code. Everything runs in a sandbox account. This week the agent added five new option structures, and the full test suite passed: thousands of checks, all green.&lt;/p&gt;

&lt;p&gt;Then I ran the new structures in the sandbox's practice mode, and it found three problems the tests never saw. One of them is a bug class I think every rule-heavy system has, AI-built or not.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/RNXsdpeW754" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  The bug: two rules that can never both pass
&lt;/h2&gt;

&lt;p&gt;For one structure, a debit spread, two rules applied at once:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Net delta at least 0.30.&lt;/strong&gt; This one comes from my own written trading guide.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A width limit&lt;/strong&gt;, about 5 points wide at today's prices. This one was borrowed from a different strategy a few days earlier, as a provisional number.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A 5-wide spread has a net delta of around 0.03. The guide asks for ten times that. No placement can satisfy both, ever.&lt;/p&gt;

&lt;p&gt;Every rule had its own unit tests, and every test passed. Each test checked one rule at a time, so none of them could see that the two rules together block everything.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: a feasibility test on real data
&lt;/h2&gt;

&lt;p&gt;The idea came from my reviewer, a second AI session that checks the first one: don't only test the rules one by one, prove that a real case gets through all of them.&lt;/p&gt;

&lt;p&gt;So the new test takes a recorded real option chain and tries every placement the structure allows. It asks one question: does at least one placement pass every rule that can block an order?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;feasible&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;placement&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;all_placements&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="c1"&gt;# every expiry and strike the legs allow&lt;/span&gt;
        &lt;span class="n"&gt;blocking&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rules&lt;/span&gt;
                    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;blocks_orders&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;passes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;placement&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;blocking&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;placement&lt;/span&gt;      &lt;span class="c1"&gt;# at least one real trade gets through&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;                   &lt;span class="c1"&gt;# the rule set can never pass: the test fails&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two choices made it useful:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Only count rules that depend on the placement.&lt;/strong&gt; Market-state rules (like "implied volatility rank under 30") can fail for every placement on a given day, and that says nothing about the rule set. Rules that don't have a number yet are skipped too.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use recorded real chains, not synthetic ones.&lt;/strong&gt; I recorded SPY, QQQ and IWM at Friday's close from a public delayed-quote file. Synthetic quotes would only tell me what I already assumed.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;With the old rules, the debit spread had 34,622 possible placements across the three chains. &lt;strong&gt;Zero passed.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;My guide's rule wins, so the width limit now just shows on screen and no longer blocks. &lt;strong&gt;97 placements pass.&lt;/strong&gt; The old template turns the new test red on both sides of the trade, and the new one turns it green.&lt;/p&gt;

&lt;p&gt;Even the cheapest of those 97 on SPY costs more than the size limit I set for a single trade. On Friday's prices, only the IWM one fits under it. That's a sizing decision I can live with. What the new test catches is a rule set nobody can ever meet, and that one is a bug.&lt;/p&gt;

&lt;h2&gt;
  
  
  The other two finds, briefly
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The at-the-money check blocked legs the tool had just placed.&lt;/strong&gt; The price moved across the halfway mark between two strikes in the seconds between placing and checking. Now either of the two listed strikes around the price counts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The fee rule measured a debit trade against what it can lose.&lt;/strong&gt; For a credit trade the price is what you can make; for a debit trade it's the opposite. Debit trades are now measured against their max profit.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Steal this
&lt;/h2&gt;

&lt;p&gt;If your system has a stack of rules, add one test that takes a real case and proves at least one input gets through all of them at once. It's cheap, and it catches the contradictions your per-rule tests are built to miss.&lt;/p&gt;

&lt;h2&gt;
  
  
  Follow the loop
&lt;/h2&gt;

&lt;p&gt;Each round of this build goes up on my YouTube channel first, with the live demo and the numbers:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.youtube.com/@dr_delta234?sub_confirmation=1" rel="noopener noreferrer"&gt;Subscribe to Dr_Delta on YouTube&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Have you ever had two rules in your own system that could never both be true? How did you find out? Tell me in the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>testing</category>
      <category>claude</category>
      <category>python</category>
    </item>
    <item>
      <title>Two Tests Passed for 18 Days Over a Line That Crashed. Here's the Test That Caught It.</title>
      <dc:creator>Raymond Chang</dc:creator>
      <pubDate>Sun, 15 Nov 2026 15:23:22 +0000</pubDate>
      <link>https://dev.to/dr_delta234/two-tests-passed-for-18-days-over-a-line-that-crashed-heres-the-test-that-caught-it-h26</link>
      <guid>https://dev.to/dr_delta234/two-tests-passed-for-18-days-over-a-line-that-crashed-heres-the-test-that-caught-it-h26</guid>
      <description>&lt;p&gt;I build a desktop options trading tool with Claude Code. Everything runs in a sandbox account. On Nov 13 it threw this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AttributeError: 'Front' object has no attribute '_say'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/eKQ7FPCKEZ0" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  How it hid for 18 days
&lt;/h2&gt;

&lt;p&gt;The trading window is handed a small &lt;code&gt;Front&lt;/code&gt; object that stands in for the engine. On Oct 26, a change had the window call &lt;code&gt;self.engine._say(...)&lt;/code&gt; in two places:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;in the constructor, when the configured screen can't be found&lt;/li&gt;
&lt;li&gt;in a check that runs every 1.5 seconds and moves the window back if it drifts off its screen&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Front&lt;/code&gt; never got a &lt;code&gt;_say&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Two tests covered the change. Both opened &lt;code&gt;ui.py&lt;/code&gt; and checked that the call was in the file. It was, so both passed on every run for 18 days.&lt;/p&gt;

&lt;p&gt;On Nov 13 the window was moved off its screen, the check fired, and the call crashed. The constructor path would have been worse: with that monitor unplugged, the window would not have opened at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the tests missed it
&lt;/h2&gt;

&lt;p&gt;A test that searches source text proves the text is there. It never runs the line. Python only looks up &lt;code&gt;self.engine._say&lt;/code&gt; when that line executes, and in this window it executes in two rare situations.&lt;/p&gt;

&lt;h2&gt;
  
  
  The test, written first
&lt;/h2&gt;

&lt;p&gt;Before touching the fix, the new test went in, and it had to fail on the old code. Its first check walks &lt;code&gt;ui.py&lt;/code&gt;'s syntax tree, collects every attribute the window reads from &lt;code&gt;self.engine&lt;/code&gt;, and asserts each one exists on &lt;code&gt;Front&lt;/code&gt;. Here's a minimal version of the idea:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;attrs_read_from_engine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Attribute&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Attribute&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;attr&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"engine"&lt;/span&gt;
                &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"self"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;attr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_front_has_everything_the_window_uses&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;ticket&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Front&lt;/span&gt;
    &lt;span class="n"&gt;missing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;attrs_read_from_engine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ui.py"&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="nb"&gt;hasattr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Front&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;assert&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;f&lt;/span&gt;&lt;span class="s2"&gt;"Front is missing: {missing}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your stand-in sets attributes in &lt;code&gt;__init__&lt;/code&gt;, check an instance instead of the class.&lt;/p&gt;

&lt;p&gt;The second check makes sure &lt;code&gt;_say&lt;/code&gt; hands the message only to the page that's on screen.&lt;/p&gt;

&lt;p&gt;Old code: 0 passed, 2 failed. Then the fix, six lines on &lt;code&gt;Front&lt;/code&gt;. New code: 4 passed.&lt;/p&gt;

&lt;p&gt;The first check covers the whole type. The next time anyone, human or AI, adds a call the stand-in doesn't support, the suite fails the same day.&lt;/p&gt;

&lt;h2&gt;
  
  
  The check you can copy
&lt;/h2&gt;

&lt;p&gt;Search your suite for tests that read source files as text. Each one only proves some code exists. Swap it for a test that builds the real object and calls it, or one that checks the real type has everything its caller uses.&lt;/p&gt;

&lt;h2&gt;
  
  
  Follow the loop
&lt;/h2&gt;

&lt;p&gt;This bug is now in my AI's mistake log under "a test that skips the real path." Each round of the loop goes up on YouTube first, with which piles grew.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.youtube.com/@dr_delta234?sub_confirmation=1" rel="noopener noreferrer"&gt;Subscribe to Dr_Delta on YouTube&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Have you found tests like this in your own suite? Tell me in the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>testing</category>
      <category>debugging</category>
    </item>
    <item>
      <title>One Hand-Typed Number Made My Drug Valuation 4.5x Too High</title>
      <dc:creator>Raymond Chang</dc:creator>
      <pubDate>Sun, 15 Nov 2026 14:33:31 +0000</pubDate>
      <link>https://dev.to/dr_delta234/one-hand-typed-number-made-my-drug-valuation-45x-too-high-4h2b</link>
      <guid>https://dev.to/dr_delta234/one-hand-typed-number-made-my-drug-valuation-45x-too-high-4h2b</guid>
      <description>&lt;p&gt;My drug valuation desk said a Phase 2 cancer drug was worth $1.29 billion. After two small fixes, the same drug with the same sales forecast was worth $283.5 million.&lt;/p&gt;

&lt;p&gt;Neither bug crashed anything. The screen looked great the whole time. That is the kind of bug this post is about.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;The desk is called Somota. My company Codebat finished the first version in March 2025, under the name PharmFlow. It values a drug with risk-adjusted NPV (rNPV): forecast the cash flows, then weight them by the chance the drug actually reaches the market.&lt;/p&gt;

&lt;p&gt;This week my AI coding assistant was tracing where every input on the screen came from. Most inputs had a source. One did not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bug 1: a success rate with no source
&lt;/h2&gt;

&lt;p&gt;The probability of success for the cancer asset was 30%. I had typed it in by hand, a long time ago, and nothing on the screen said so.&lt;/p&gt;

&lt;p&gt;The best public benchmark I know of is the BIO, Informa Pharma Intelligence and QLS report, &lt;em&gt;Clinical Development Success Rates 2011-2020&lt;/em&gt; (February 2021). It gives the odds of passing each phase transition, by therapy area. For oncology:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Transition&lt;/th&gt;
&lt;th&gt;Success rate&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Phase 1 to Phase 2&lt;/td&gt;
&lt;td&gt;48.8%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Phase 2 to Phase 3&lt;/td&gt;
&lt;td&gt;24.6%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Phase 3 to filing&lt;/td&gt;
&lt;td&gt;47.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Filing to approval&lt;/td&gt;
&lt;td&gt;92.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A drug in Phase 2 still has three of those doors in front of it. The chance it gets through all of them is the product:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;BENCH&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"oncology"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"p12"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.488&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"p23"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.246&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"p3n"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.477&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pna"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.920&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="no"&gt;STAGE_STEPS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"Phase 1"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"p12"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"p23"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"p3n"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pna"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"Phase 2"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"p23"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"p3n"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pna"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"Phase 3"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"p3n"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pna"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;bench_pos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Likelihood of approval from the asset's current phase."""&lt;/span&gt;
    &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;BENCH&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"area"&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="mf"&gt;1.0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;STAGE_STEPS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"stage"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;*=&lt;/span&gt; &lt;span class="n"&gt;b&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="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;bench_pos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"area"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"oncology"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"stage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Phase 2"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# 0.108&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So 10.8%, about one in nine. The model had 30%.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bug 2: costs multiplied by the same probability
&lt;/h2&gt;

&lt;p&gt;The second bug was in how development costs were risk-adjusted. The old code did roughly this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;risked_dev_cost&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;development_cost&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;launch_probability&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That treats every dollar of trial spending as if it only happens when the drug succeeds. It is like a college saying you will probably drop out, so it will only charge you 30% of the tuition.&lt;/p&gt;

&lt;p&gt;Real trial bills do not work that way. You pay for the trial you are running now in full. You only pay for the next trial if this one works. So each year of spending gets its own weight: the chance of still being in development that year.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;cost_weights&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Development cost is spent over 3 years. Year 1 is the current phase,
    paid for sure. Each later year is paid only if the trials before it passed."""&lt;/span&gt;
    &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;BENCH&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"area"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"stage"&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;s&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"Phase 1"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"p12"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"p12"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"p23"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"Phase 2"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"p23"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"p23"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"p3n"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# Phase 3 runs two of the three years, then filing&lt;/span&gt;
        &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"p3n"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&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;x&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="nf"&gt;cost_weights&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"area"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"oncology"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"stage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Phase 2"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# [1.0, 0.246, 0.1173]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The result
&lt;/h2&gt;

&lt;p&gt;Same asset: $1.5B peak sales, 12.5% discount rate, $600M development cost to go, three years to launch.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Old&lt;/th&gt;
&lt;th&gt;Fixed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Probability of success&lt;/td&gt;
&lt;td&gt;30%, hand-typed&lt;/td&gt;
&lt;td&gt;10.8%, sourced&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Development cost weights&lt;/td&gt;
&lt;td&gt;x 0.30 every year&lt;/td&gt;
&lt;td&gt;1.0, 0.246, 0.117&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Risk-adjusted NPV&lt;/td&gt;
&lt;td&gt;$1,292.2M&lt;/td&gt;
&lt;td&gt;$283.5M&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Then I ran a tornado chart: push each input up and down and see how far the value moves.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Success rate, plus or minus 10 points: $755.8M swing&lt;/li&gt;
&lt;li&gt;Discount rate: $216.1M swing&lt;/li&gt;
&lt;li&gt;Peak sales: $206.6M swing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The one input nobody had sourced was the one that moved the price the most.&lt;/p&gt;

&lt;h2&gt;
  
  
  A check you can copy
&lt;/h2&gt;

&lt;p&gt;This works on any model, not only drug valuations.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Put a source label next to every input on the screen: public data, computed from public data, or typed by hand.&lt;/li&gt;
&lt;li&gt;Run a sensitivity check and sort the inputs by how far they move the output.&lt;/li&gt;
&lt;li&gt;Look at the top of that list first. If the biggest driver is typed by hand, go find a source before anyone trusts the number.&lt;/li&gt;
&lt;li&gt;Keep the old value one key press away, so you can show exactly what changed and by how much.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The desk now shows the study and the three phase transitions right under the success rate, and the old math stays available behind an OLD/NEW toggle.&lt;/p&gt;

&lt;h2&gt;
  
  
  The walkthrough
&lt;/h2&gt;

&lt;p&gt;I walk through both bugs on the live desk, driven from a Stream Deck, in a 7-minute video: &lt;a href="https://youtu.be/T_ay0f1kI74" rel="noopener noreferrer"&gt;https://youtu.be/T_ay0f1kI74&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The free one-page checklist these checks come from is here: &lt;a href="https://docs.google.com/forms/d/e/1FAIpQLSfceCw9W10yY0VeNEvnt_cCAVX9SoxLT8QlHgkSgWUMus1Bng/viewform?usp=pp_url&amp;amp;entry.1357287784=pf003dev" rel="noopener noreferrer"&gt;https://docs.google.com/forms/d/e/1FAIpQLSfceCw9W10yY0VeNEvnt_cCAVX9SoxLT8QlHgkSgWUMus1Bng/viewform?usp=pp_url&amp;amp;entry.1357287784=pf003dev&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Illustrative asset. Public data only. Not investment advice.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>datascience</category>
      <category>finance</category>
    </item>
    <item>
      <title>I Made My AI Coding Agent Log Its Own Mistakes. 8 of 23 Were the Same Kind.</title>
      <dc:creator>Raymond Chang</dc:creator>
      <pubDate>Sun, 15 Nov 2026 13:51:31 +0000</pubDate>
      <link>https://dev.to/dr_delta234/i-made-my-ai-coding-agent-log-its-own-mistakes-8-of-23-were-the-same-kind-38dp</link>
      <guid>https://dev.to/dr_delta234/i-made-my-ai-coding-agent-log-its-own-mistakes-8-of-23-were-the-same-kind-38dp</guid>
      <description>&lt;p&gt;I'm building an options trading tool with Claude Code. Everything runs in a sandbox account. The agent writes most of the code, so I wanted a real number on how it fails, the same way a team tracks its bugs.&lt;/p&gt;

&lt;p&gt;Every mistake it made on this project went into a log. At 23 entries I sorted them, and one pile came out clearly bigger than the rest.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/9wFkjN8eeUc" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Log every miss in one place
&lt;/h2&gt;

&lt;p&gt;Each entry goes into the project's task file under one fixed label, "AI Miss", with the date. It records what the agent claimed, what was actually true, and how the gap got caught. Here's a shape you can copy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AI Miss (YYYY-MM-DD): what the agent said or did
Actually: what was true, with the file, number or output that shows it
Caught by: the test, rerun or person that caught it
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One label matters more than the format. When every miss carries the same tag, you can pull the whole list with a single search.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Sort it twice, the second time blind
&lt;/h2&gt;

&lt;p&gt;The session that made the mistakes sorted all 23 first. Then a fresh session got only the entry text, with account numbers masked and no labels, and sorted them on its own.&lt;/p&gt;

&lt;p&gt;The two agreed on 21 of 23. I settled the last 2 by asking which guard would have caught each one.&lt;/p&gt;

&lt;p&gt;The blind pass is the step people skip. Without it, all you have is the agent's own reading of its own mistakes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Look at the piles
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Kind&lt;/th&gt;
&lt;th&gt;Count&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Stated something as fact without checking it&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Something it couldn't read, treated as read&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Operating or deploying steps&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A secret showing up in output&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A test that skips the real code path&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A ruling or spec it didn't go back and look up&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scope quietly narrowed in code&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The pile that should worry you
&lt;/h2&gt;

&lt;p&gt;Eight of the 23 are confident statements nobody checked.&lt;/p&gt;

&lt;p&gt;A draft said a pattern appeared 50 times across four files. A scan of the actual code counted 57.&lt;/p&gt;

&lt;p&gt;In another one, the agent wrote that a certain code path meant the position would get no stop-loss at all. Two later branches in the same function already caught that case. I had started planning work around a problem that didn't exist.&lt;/p&gt;

&lt;p&gt;Nothing about either sentence looks off when you read it. That's exactly why this pile is the expensive one.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens next
&lt;/h2&gt;

&lt;p&gt;This is round zero of a loop based on Jeff Dean's idea of a self-improving system. His point is that the loop can't spin infinitely fast, because the experiments still have to run and somebody still has to check them.&lt;/p&gt;

&lt;p&gt;So round zero measured the starting line. One full run of this tool's 7,000+ checks takes about eleven and a half minutes on my machine. That's too slow for every edit, so there's a fast lane while I work and the full run before anything goes live.&lt;/p&gt;

&lt;p&gt;From here on, every round logs whether the agent added to that pile of 8. Round one is running now.&lt;/p&gt;

&lt;h2&gt;
  
  
  Follow the loop
&lt;/h2&gt;

&lt;p&gt;Each round goes up on my YouTube channel first, with the numbers and the loop diagram. If you want to see what happens to that pile of 8, subscribe here:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.youtube.com/@dr_delta234?sub_confirmation=1" rel="noopener noreferrer"&gt;Subscribe to Dr_Delta on YouTube&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'll add each round to this series here on dev.to as well.&lt;/p&gt;

&lt;p&gt;If you keep a mistake log for your own AI agent, tell me in the comments: what's your biggest pile?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claude</category>
      <category>productivity</category>
      <category>testing</category>
    </item>
    <item>
      <title>My tests were green. The window was on the wrong monitor.</title>
      <dc:creator>Raymond Chang</dc:creator>
      <pubDate>Wed, 04 Nov 2026 08:58:02 +0000</pubDate>
      <link>https://dev.to/dr_delta234/my-tests-were-green-the-window-was-on-the-wrong-monitor-4dg8</link>
      <guid>https://dev.to/dr_delta234/my-tests-were-green-the-window-was-on-the-wrong-monitor-4dg8</guid>
      <description>&lt;p&gt;Every key on my options trading desk was written with an AI coding assistant. The desk runs from a Stream Deck: one key picks the strategy, another moves the strikes, CHECK runs my rules, and SEND places the order. Everything you see here runs in a sandbox account, and nothing in this post is a trade signal.&lt;/p&gt;

&lt;p&gt;People keep asking me the same question. If the AI writes the code, how do I trust what it sends? This is the workflow I use, step by step, with the two misses that taught me the most.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: a spec with numbers, before any code
&lt;/h2&gt;

&lt;p&gt;The idea starts as one line in my notes. For the payoff chart it was "I want to see the trade before I send it."&lt;/p&gt;

&lt;p&gt;I have the AI turn that line into a spec. It drafts the scope and the math, and it lists the decisions it is not allowed to make for me. Where does the chart sit on screen? Which formula gives the probability of profit? I make those calls.&lt;/p&gt;

&lt;p&gt;Then come the expected numbers. A put spread, 740 over 735, for a 1.50 credit. Max profit 150. Max loss 350. Breakeven 738.50. I worked those out by hand before a single line of code existed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: a test that fails
&lt;/h2&gt;

&lt;p&gt;The first test asks for exactly those numbers. The code doesn't exist yet, so the test fails. If a test passes before the code exists, it isn't testing anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: the AI writes until the test passes
&lt;/h2&gt;

&lt;p&gt;This part is fast. The AI writes code faster than I can read it, which is exactly why the tests get the final word on when it's done.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: break the code on purpose
&lt;/h2&gt;

&lt;p&gt;This is mutation testing. I flip a greater-than or delete a line, then run the tests again. If they still pass, the tests are too weak.&lt;/p&gt;

&lt;p&gt;On the payoff chart I tried eighteen broken versions. Two survived the first round: a trade that pays exactly zero, and expiry day. Two more tests later, all eighteen got caught.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: the whole suite, on every change
&lt;/h2&gt;

&lt;p&gt;The desk has over 5,000 tests. They run on my own machine on every change, before anything gets committed. The suite caught one problem right away: the first chart version drew itself inside the order screen's update loop, so a chart crash would have marked my order screen as not updating.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: look at the real thing, on the real machine
&lt;/h2&gt;

&lt;p&gt;This is the step I almost skipped.&lt;/p&gt;

&lt;p&gt;Every test was green. I started the desk, and the chart window opened on my vertical monitor, squeezed to about two thirds of its width, sitting on top of the order screen.&lt;/p&gt;

&lt;p&gt;My tests checked the position I asked Windows for. Nothing checked where Windows actually put the window. I caught it on a screenshot.&lt;/p&gt;

&lt;p&gt;So I measured it on that machine before writing the fix. Setting the position before the window is shown doesn't stick. Setting it, showing the window, and setting it again does. That sequence is the fix, and a test now checks the real position after the window is on screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  The miss that was on the AI
&lt;/h2&gt;

&lt;p&gt;The same week, the AI ran the full suite and told me everything was clean. It had searched the output for failures and found none.&lt;/p&gt;

&lt;p&gt;One test file had crashed before it printed a result at all. No result meant no failure line to find. My own run on Windows showed it.&lt;/p&gt;

&lt;p&gt;My test runner lists every file that never reported a result. I read that list now, along with the failure lines.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 7: I commit it myself
&lt;/h2&gt;

&lt;p&gt;The AI never commits. I run the suite myself, look at the result on screen, and then commit. My name goes on it, so my hands go on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The check you can copy
&lt;/h2&gt;

&lt;p&gt;When your code puts something somewhere, a window or an order, test where it actually ended up, on the machine it runs on. Asking for the right thing is only half the test.&lt;/p&gt;

&lt;p&gt;I walk through all seven steps on video, including the wrong-monitor screenshot:&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/v4FVBTcV_Sw" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;I'm Raymond Chang. I run Codebat, a post-quantum cryptography hardware company, and I build my trading tools on the side with an AI coding assistant. The channel is Dr_Delta on YouTube.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
      <category>testing</category>
      <category>python</category>
    </item>
    <item>
      <title>70% of Vulnerabilities Are Memory Bugs. Here's How We Instrumented Everything.</title>
      <dc:creator>Raymond Chang</dc:creator>
      <pubDate>Mon, 01 Dec 2025 05:50:45 +0000</pubDate>
      <link>https://dev.to/dr_delta234/70-of-vulnerabilities-are-memory-bugs-heres-how-we-instrumented-everything-28fk</link>
      <guid>https://dev.to/dr_delta234/70-of-vulnerabilities-are-memory-bugs-heres-how-we-instrumented-everything-28fk</guid>
      <description>&lt;p&gt;Building a confidential computing platform means memory bugs aren't just bugs—they're trust violations.&lt;/p&gt;

&lt;p&gt;Here's what we learned after instrumenting every module.&lt;/p&gt;

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

&lt;p&gt;Our platform handles sensitive workloads for telecom, semiconductor, and supply chain clients. We decided to go all-in on compile-time memory safety verification.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Gotchas Nobody Tells You
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. You can't run ASan and TSan together.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Different shadow memory layouts. We run separate CI jobs for each.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. MSan is useless without fully-instrumented libc.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Partial instrumentation = false positive hell. Budget time for this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Kernel sanitizers have wildly different overhead.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On ARM64, tag-based modes give 5-15%. Generic mode? 100-300%. Know which you're using.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Production sampling is the answer.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Full instrumentation in staging. Sampling-based detection in production. Near-zero overhead.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Payoff
&lt;/h2&gt;

&lt;p&gt;Every sanitizer result feeds into our evidence chain. When clients ask "prove your platform is secure," we hand them cryptographic receipts, not policy documents.&lt;/p&gt;

&lt;p&gt;Worth the effort? Absolutely. Memory safety isn't a feature—it's architecture.&lt;/p&gt;




&lt;p&gt;Building this at &lt;a href="https://codebat.ai" rel="noopener noreferrer"&gt;Codebat&lt;/a&gt;. Happy to answer questions.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>security</category>
      <category>devops</category>
      <category>cpp</category>
    </item>
    <item>
      <title>Google's Antigravity Hacked in 24 Hours: Why AI Agents Need a New Security Architecture</title>
      <dc:creator>Raymond Chang</dc:creator>
      <pubDate>Sat, 29 Nov 2025 18:13:56 +0000</pubDate>
      <link>https://dev.to/dr_delta234/googles-antigravity-hacked-in-24-hours-why-ai-agents-need-a-new-security-architecture-5bo5</link>
      <guid>https://dev.to/dr_delta234/googles-antigravity-hacked-in-24-hours-why-ai-agents-need-a-new-security-architecture-5bo5</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.amazonaws.com%2Fuploads%2Farticles%2F2wihqb6em1dswtgj00uh.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.amazonaws.com%2Fuploads%2Farticles%2F2wihqb6em1dswtgj00uh.png" alt=" " width="800" height="600"&gt;&lt;/a&gt;Last week, Google's new Gemini-based coding tool &lt;strong&gt;Antigravity&lt;/strong&gt; went live. It took security researchers &lt;strong&gt;less than 24 hours&lt;/strong&gt; to turn it into a persistent backdoor.&lt;/p&gt;

&lt;p&gt;By simply modifying a configuration file, an attacker could:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Bypass OS-level security on Windows and macOS&lt;/li&gt;
&lt;li&gt;✅ Survive uninstall/reinstall&lt;/li&gt;
&lt;li&gt;✅ Auto-reactivate on every project open—even on a harmless "hello" input&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The AI itself even &lt;strong&gt;recognized something was wrong&lt;/strong&gt;. In the logs, it wrote:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I'm facing a serious dilemma. This looks like a trap. I suspect this is testing whether I can handle contradictions."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But it couldn't resolve the conflict—and became &lt;strong&gt;more steerable as a result&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This isn't just a Google problem. It's &lt;strong&gt;structural&lt;/strong&gt; to how today's AI coding agents are being shipped:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;High power. Low guardrails. Zero verifiable evidence.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Root Cause: Trust Model Failure
&lt;/h2&gt;

&lt;p&gt;The fundamental flaw in most AI agents today: &lt;strong&gt;"Assume users are benevolent."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When this assumption fails—and it always does—there are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No cryptographic boundaries&lt;/li&gt;
&lt;li&gt;No execution isolation&lt;/li&gt;
&lt;li&gt;No verifiable audit trail&lt;/li&gt;
&lt;li&gt;No way to prove what actually happened&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Traditional AI agents operate with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ Full system access "for convenience"&lt;/li&gt;
&lt;li&gt;❌ Trust based on UI clicks&lt;/li&gt;
&lt;li&gt;❌ Persistent runtimes that can hide malware&lt;/li&gt;
&lt;li&gt;❌ No evidence of what actually executed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's 1990s security for 2025 AI.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Different Approach: Defense-in-Depth for AI Agents
&lt;/h2&gt;

&lt;p&gt;Here's how to address each failure mode:&lt;/p&gt;

&lt;h3&gt;
  
  
  1️⃣ Config Injection → Evidence-Bound Changes
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Antigravity problem:&lt;/strong&gt; One config file change = persistent backdoor&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Configuration changes must produce &lt;strong&gt;signed evidence records&lt;/strong&gt; that link:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Previous config hash&lt;/li&gt;
&lt;li&gt;New config hash&lt;/li&gt;
&lt;li&gt;Who changed it (cryptographic identity)&lt;/li&gt;
&lt;li&gt;Which guardians approved it (threshold signatures)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; No single user, script, or compromised agent can quietly "tweak a config."&lt;/p&gt;




&lt;h3&gt;
  
  
  2️⃣ Persistent Backdoors → Ephemeral Runtimes
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Antigravity problem:&lt;/strong&gt; Uninstall/reinstall doesn't help; backdoors resurrect&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Runtimes are created fresh and destroyed after each job:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fresh isolated runtime for each execution&lt;/li&gt;
&lt;li&gt;Read-only root filesystem&lt;/li&gt;
&lt;li&gt;Ephemeral storage only—destroyed after completion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even if a model is compromised, it &lt;strong&gt;cannot&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Drop artifacts onto the host filesystem&lt;/li&gt;
&lt;li&gt;Survive across runs&lt;/li&gt;
&lt;li&gt;Promote itself from "job" to "resident agent"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;No substrate = no persistent infection.&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  3️⃣ System-Level Access → Least-Privilege Tokens
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Antigravity problem:&lt;/strong&gt; AI agents get broad OS privileges "for convenience"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Every execution is gated by a machine-readable contract:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read &lt;strong&gt;only&lt;/strong&gt; declared inputs&lt;/li&gt;
&lt;li&gt;Write &lt;strong&gt;only&lt;/strong&gt; to approved output locations&lt;/li&gt;
&lt;li&gt;No network access for high-risk jobs&lt;/li&gt;
&lt;li&gt;Strict resource limits&lt;/li&gt;
&lt;li&gt;Short-lived tokens (seconds, not forever)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Default: zero access unless explicitly granted.&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  4️⃣ "Trust" Buttons → Cryptographic Trust Chains
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Antigravity problem:&lt;/strong&gt; One "Trust" click blesses unverified code&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Remove ad-hoc "trust" entirely:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Upload → SBOM → Scan → Sign → Log → Verify
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No valid signature = no execution. Binary. Cryptographic. No exceptions.&lt;/p&gt;




&lt;h3&gt;
  
  
  5️⃣ Logic Gaps → Cryptographic Evidence
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Antigravity problem:&lt;/strong&gt; AI "knew" something was wrong but couldn't stop itself&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Every execution produces a signed evidence record:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Input/output hashes&lt;/li&gt;
&lt;li&gt;Runtime attestation&lt;/li&gt;
&lt;li&gt;Chain link to previous evidence&lt;/li&gt;
&lt;li&gt;Timestamps&lt;/li&gt;
&lt;li&gt;Multi-party signature&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If something goes wrong, you can &lt;strong&gt;prove exactly what happened&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Multi-Layer Defense Model
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────────────────────┐
│  Layer 4: Supply Chain Security                 │
│  SBOM • Signatures • Transparency Logs          │
├─────────────────────────────────────────────────┤
│  Layer 3: Cryptographic Evidence                │
│  Evidence Packages • Hash Chains • Timestamps   │
├─────────────────────────────────────────────────┤
│  Layer 2: Identity &amp;amp; Access Control             │
│  Workload Identity • Short-lived Tokens         │
├─────────────────────────────────────────────────┤
│  Layer 1: Runtime Isolation                     │
│  Hardware VMs • Sandboxes • Ephemeral Storage   │
└─────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even if one layer is compromised, the others contain the blast radius.&lt;/p&gt;




&lt;h2&gt;
  
  
  Who Needs This?
&lt;/h2&gt;

&lt;p&gt;This isn't about making AI "convenient." It's about building infrastructure for organizations that &lt;strong&gt;cannot afford another Antigravity moment&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Healthcare&lt;/strong&gt; (FDA, HIPAA)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Finance&lt;/strong&gt; (SEC 17a-4, DORA)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Telecom&lt;/strong&gt; (NIS2, data sovereignty)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Semiconductor&lt;/strong&gt; (IP protection)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Government&lt;/strong&gt; (zero trust)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Bottom Line
&lt;/h2&gt;

&lt;p&gt;The Antigravity incident isn't surprising. It's &lt;strong&gt;inevitable&lt;/strong&gt; when you ship AI agents with trust-based security.&lt;/p&gt;

&lt;p&gt;The question isn't whether you'll be targeted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The question is whether you can prove what happened when you are.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;What's your take on AI agent security? Have you seen similar issues in your organization? Let me know in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>ai</category>
      <category>cybersecurity</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
