<?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: Revin</title>
    <description>The latest articles on DEV Community by Revin (@revinsoftware).</description>
    <link>https://dev.to/revinsoftware</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%2F4015647%2F4c05d90d-38b0-4993-8f2b-2eac6bbdbff5.png</url>
      <title>DEV Community: Revin</title>
      <link>https://dev.to/revinsoftware</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/revinsoftware"/>
    <language>en</language>
    <item>
      <title>I ran git blame on a pricing service with 1,043 branches: 34 changed in a year and one engineer could name them</title>
      <dc:creator>Revin</dc:creator>
      <pubDate>Wed, 25 Nov 2026 14:05:26 +0000</pubDate>
      <link>https://dev.to/revinsoftware/i-ran-git-blame-on-a-pricing-service-with-1043-branches-34-changed-in-a-year-and-one-engineer-1alf</link>
      <guid>https://dev.to/revinsoftware/i-ran-git-blame-on-a-pricing-service-with-1043-branches-34-changed-in-a-year-and-one-engineer-1alf</guid>
      <description>&lt;p&gt;A post titled "If you stop hiring juniors, your senior engineers own you" collected 117 points and 84 comments on Hacker News. Almost all of it argues about hiring policy, and nobody in the thread counts anything. That is fair. You cannot count a hiring philosophy.&lt;/p&gt;

&lt;p&gt;You can count ownership. I had read access to a pricing service for an unrelated reason, a question about whether it was time to buy a rules engine, and the numbers I pulled there answer the ownership question better than any opinion I hold about juniors. Node and TypeScript, roughly 40k lines, six files under &lt;code&gt;src/pricing&lt;/code&gt;, nine people on the team, two of them contractors.&lt;/p&gt;

&lt;p&gt;The service had 1,043 branches. Thirty four of them changed in the last twelve months.&lt;/p&gt;

&lt;h2&gt;
  
  
  Count 1: which branches are alive
&lt;/h2&gt;

&lt;p&gt;The branch count came from an AST pass over the six files, counting every &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;case&lt;/code&gt;, ternary and short circuit inside the rule functions. 1,043. On its own that number is decoration. The one that matters is how much of it anyone touched:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log --since=&lt;span class="s1"&gt;'12 months ago'&lt;/span&gt; --numstat --format=&lt;span class="s1"&gt;'%H'&lt;/span&gt; -- src/pricing \
  &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'NF==3 {add+=$1; del+=$2} END {print add, del}'&lt;/span&gt;
&lt;span class="c"&gt;# 1876 1204&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I diffed each rule function against its state twelve months earlier and counted the ones with any change in the body. Thirty four, a little over 3 percent of the branches. Twenty six of those thirty four live in two files, &lt;code&gt;commission.ts&lt;/code&gt; and &lt;code&gt;payout.ts&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So the surface is 1,043 branches and the working set is two files. Hold that for the next count.&lt;/p&gt;

&lt;h2&gt;
  
  
  Count 2: who wrote the working set
&lt;/h2&gt;

&lt;p&gt;This is the measurement I got wrong on the first pass. I started at the repo level:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git shortlog -sn --since=&lt;span class="s1"&gt;'12 months ago'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; head -5
&lt;span class="c"&gt;#   84  dev-a&lt;/span&gt;
&lt;span class="c"&gt;#   61  dev-b&lt;/span&gt;
&lt;span class="c"&gt;#   57  dev-c&lt;/span&gt;
&lt;span class="c"&gt;#   49  dev-d&lt;/span&gt;
&lt;span class="c"&gt;#   38  dev-e&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(author names replaced)&lt;/p&gt;

&lt;p&gt;That output looks healthy. Top committer at 23 percent of commits, five people active, no single point of failure visible anywhere. The repo average had washed out the only part of the repo that changes. Commit count also rewards whoever ran the formatter and the big rename, which happened twice that year.&lt;/p&gt;

&lt;p&gt;Lines currently standing in the two files that absorb every change, by author, reads differently:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git blame -w -M -C --line-porcelain src/pricing/commission.ts src/pricing/payout.ts \
  &lt;span class="o"&gt;|&lt;/span&gt; grep &lt;span class="s1"&gt;'^author '&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; uniq -c &lt;span class="o"&gt;|&lt;/span&gt; sort -rn
&lt;span class="c"&gt;#  1194 author dev-a&lt;/span&gt;
&lt;span class="c"&gt;#   286 author dev-b&lt;/span&gt;
&lt;span class="c"&gt;#   151 author dev-c&lt;/span&gt;
&lt;span class="c"&gt;#    97 author dev-f&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;dev-a holds about 68 percent of the lines. The &lt;code&gt;-w -M -C&lt;/code&gt; flags matter more than they look: without them, the formatter pass from March reassigns a third of each file to whoever ran it, and the concentration vanishes from the output. Dev-f, with 97 lines standing, is a contractor who left in 2024.&lt;/p&gt;

&lt;p&gt;That number only points at the risk. The risk itself is a different question.&lt;/p&gt;

&lt;h2&gt;
  
  
  Count 3: the explain test
&lt;/h2&gt;

&lt;p&gt;What I wanted to know is how many people can walk the commission closing flow end to end. So I asked, one at a time, 20 minutes each, no code on screen: take a closed invoice from the 7th of the month and tell me how it becomes a commission line, including the place where a retroactive contract change gets applied.&lt;/p&gt;

&lt;p&gt;The protocol I used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;they can name files, they cannot open them&lt;/li&gt;
&lt;li&gt;I answer yes or no, nothing else&lt;/li&gt;
&lt;li&gt;it ends when they reach the payout write or when they stop&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nine people. One finished, dev-a. Two reached the proration step and stalled on the retroactive case, which happens to be 9 of the 34 live branches. Six described the inputs and the output and nothing in between.&lt;/p&gt;

&lt;p&gt;The team already had the evidence without my test. Dev-a took 11 days off in July. Three changes to those two files were open in that window. Two waited for him. The third shipped and got reverted six days later, because it applied a retroactive change twice for contracts that renewed mid cycle.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the hiring argument misses
&lt;/h2&gt;

&lt;p&gt;The Hacker News thread treats this as a seniority problem: stop hiring juniors and your seniors become irreplaceable. My reading of the counts is that the variable is not level, it is the number of people who have walked the live path. Hiring three juniors into this service changes nothing by itself, because the thirty four branches do not route through them. Dev-a reviews, dev-a merges, dev-a is faster at it than the review cycle, and everybody feels relieved about that.&lt;/p&gt;

&lt;p&gt;Routing is the part you can change inside a quarter. For ten weeks the team did one thing: every change in &lt;code&gt;commission.ts&lt;/code&gt; and &lt;code&gt;payout.ts&lt;/code&gt; went to someone other than dev-a, with dev-a reviewing and not typing, pairing on the first two.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log --since=&lt;span class="s1"&gt;'10 weeks ago'&lt;/span&gt; --numstat --format=&lt;span class="s1"&gt;'%an'&lt;/span&gt; \
    -- src/pricing/commission.ts src/pricing/payout.ts \
  &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'/^[a-z]/ {a=$0} NF==3 {s[a]+=$1+$2} END {for (k in s) print s[k], k}'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; sort -rn
&lt;span class="c"&gt;# 611 dev-b&lt;/span&gt;
&lt;span class="c"&gt;# 204 dev-c&lt;/span&gt;
&lt;span class="c"&gt;# 158 dev-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;dev-b went from somewhere near 9 percent of the changed lines in those files to about 31 percent of the lines standing today. The explain test went from one person out of nine to four out of nine, and the second person through it took 34 minutes and got the retroactive case right.&lt;/p&gt;

&lt;p&gt;It cost throughput. Changes in those two files took around 40 percent longer during the window, and two of them needed a second review round that dev-a alone would not have needed. The July revert cost more than those ten weeks did.&lt;/p&gt;

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

&lt;p&gt;A survey. Before the explain test I asked the team in writing who owns pricing. Nine out of nine named dev-a. It confirmed what I suspected and measured nothing, because naming an owner tells you no part of what you need: whether the gap for the next person is two weeks of reading or six months of it.&lt;/p&gt;

&lt;p&gt;Documentation as evidence went the same way. The README described the flow as of a rewrite that predates 19 of the live branches, and it never mentions the retroactive case, which is exactly where everyone stalls.&lt;/p&gt;

&lt;p&gt;If you run something like this, I would like to see the shape of it. Do you measure concentration from blame, from review assignment, or do you skip the measurement because everybody already knows the name? And when the critical path was authored by a contractor who left, what did you count to decide where to start reading?&lt;/p&gt;

&lt;p&gt;Originally published on the Revin blog.&lt;/p&gt;

</description>
      <category>backend</category>
      <category>git</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>I measured token cost per changed line on 36 merged PRs: the knotted diffs cost 29% more to review</title>
      <dc:creator>Revin</dc:creator>
      <pubDate>Mon, 23 Nov 2026 16:33:43 +0000</pubDate>
      <link>https://dev.to/revinsoftware/i-measured-token-cost-per-changed-line-on-36-merged-prs-the-knotted-diffs-cost-29-more-to-review-45k5</link>
      <guid>https://dev.to/revinsoftware/i-measured-token-cost-per-changed-line-on-36-merged-prs-the-knotted-diffs-cost-29-more-to-review-45k5</guid>
      <description>&lt;p&gt;My agent review bill for one Node service climbed about 18% last month and the pull request count barely moved. Twenty-two merged in October, twenty-three in November, same five step pipeline, same model, same prompt. The number that actually moved was input tokens per review, and I could not have told you which pull requests were doing it.&lt;/p&gt;

&lt;p&gt;I spent two weeks assuming something had changed on the provider side. Then a fragment published on martinfowler.com on November 20 pointed at a different suspect. Marcus Borg put 465 pull requests from 246 open source repositories through a review and fix pipeline with five agents, across three LLMs, and compared cost against the code health score from CodeScene. Between a typical unhealthy pull request at health 2.8 and a typical healthy one at 9.7, the difference added up to 22 to 35%. The two smells that drove it were Complex Method and Complex Conditional.&lt;/p&gt;

&lt;p&gt;That is the first number I have seen from outside my own logs that ties code health to inference cost instead of to how developers feel about the codebase. I do not run CodeScene here, and 36 pull requests is not 465. I still wanted to know whether the effect is visible on a single service with a crude proxy, so I spent a Saturday counting.&lt;/p&gt;

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

&lt;p&gt;One service, TypeScript on Node, 36 merged pull requests over 11 weeks. Two numbers per pull request taken from the diff alone, plus one number from my own usage logs.&lt;/p&gt;

&lt;p&gt;Pulling the diffs is the easy part:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir -p diffs
gh pr list --state merged --limit 40 --json number \
  &lt;span class="o"&gt;|&lt;/span&gt; jq -r &lt;span class="s1"&gt;'.[].number'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r n&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; gh pr diff &lt;span class="s2"&gt;"$n"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"diffs/$n.diff"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then a proxy for Complex Conditional. I count branching tokens in the added lines, drop test files so that a big spec does not inflate the score, and normalize per 100 changed lines so that a large diff does not win just by being large. Diffs under 30 code lines are out, because one renamed constant produced garbage ratios.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pathlib&lt;/span&gt;

&lt;span class="no"&gt;COND&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\b(if|switch|case|while|for)\b|&amp;amp;&amp;amp;|\|\||\?\?|\?[^.]"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="k"&gt;in&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;pathlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"diffs"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;glob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"*.diff"&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;added&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;splitlines&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
             &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&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="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&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;code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;added&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;".test."&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="s2"&gt;".spec."&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;l&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;code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;
    &lt;span class="n"&gt;conds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;COND&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;l&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;l&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;depth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&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;l&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&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;l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lstrip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stem&lt;/span&gt;&lt;span class="p"&gt;,&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;code&lt;/span&gt;&lt;span class="p"&gt;)&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;conds&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="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;depth&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&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="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;r&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="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;"\t"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;str&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="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;r&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 third number comes from the pipeline itself. My review runs in five steps: summarize the diff, read the touched files, check whether the tests cover the change, check migrations and config, write the review. Each step logs its own usage, and that split turned out to be the whole story.&lt;/p&gt;

&lt;p&gt;Joining the diff numbers with the usage log gives this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 rank.py | join-usage | head -7
pr   lines  cond/100  depth   in_tok  tok/line
377     96      10.9      3   71_040      740
402    331       9.8      5  238_988      722
418    214      11.2      4  152_804      714
...
366     71       2.1      2   38_340      540
391    176       2.8      2   94_336      536
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Split the 36 into thirds by conditional density. The top third sits at a median of 10.4 branching tokens per 100 changed lines and nesting depth 4. The bottom third sits at 2.7 and depth 2.&lt;/p&gt;

&lt;p&gt;Input tokens per changed line: median 714 in the top third, 553 in the bottom third. A shade over 29% more. That lands inside the 22 to 35% band from the Borg experiment, and I would not read it as confirmation of anything, only as a result that fails to contradict it at a much smaller scale.&lt;/p&gt;

&lt;p&gt;The per step log is the part I did not expect. On the knotted third, step two, reading the touched files, ate 61% of input tokens. On the clean third it was 38%. The agent was not writing longer reviews because the code was worse. It was pulling more files in to work out what the control flow did, and every extra file gets paid for again on every retry inside that step.&lt;/p&gt;

&lt;p&gt;Review quality moved in the same direction. Output on the knotted third came back about 40% longer, and the share of comments that turned into a code change before merge fell from 31% to 19%. More text, less of it actionable, at a higher price per line.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three things I tried that went nowhere
&lt;/h2&gt;

&lt;p&gt;Total tokens per pull request tracked diff size and nothing else. Obvious in hindsight: big diff, big bill. Normalizing per changed line is what made any signal appear at all.&lt;/p&gt;

&lt;p&gt;File count as a predictor was flat. A six file diff of flat mappers costs less to review than a one file diff with a four deep conditional in the middle of it.&lt;/p&gt;

&lt;p&gt;Max nesting depth on its own was noisy. Indentation lies after a formatter pass and after any long argument list, so depth only earns its place as a tiebreaker next to the density number.&lt;/p&gt;

&lt;p&gt;I also asked the model why it had read one file three times in the same run. It produced a confident, well written explanation that I had no way to verify, so I threw that away and went back to the usage log, which does not have opinions.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I do now, before blaming the model
&lt;/h2&gt;

&lt;p&gt;Rank the diff before the review runs. Anything over 8 branching tokens per 100 changed lines goes back to the author with the hunk named, not into the pipeline. Cap what step two is allowed to load: the function and its direct callers, not the whole file. And keep tokens per step per pull request, because a monthly total tells you the bill went up and nothing about where it went up.&lt;/p&gt;

&lt;p&gt;The honest limits of this: one service, one model, 36 pull requests, and a regex that is not a code health score. Causation can run both ways here, since the knotted diffs are also the hard tickets, and hard tickets would cost more to review even in tidy code. What I do trust is narrow, and it is the step split. The money showed up in reading, not in writing.&lt;/p&gt;

&lt;p&gt;If you run agent reviews at any volume: are you logging cost per changed line, or just watching the monthly invoice? And has anyone wired a health score into the gate before the agent runs, so the expensive diffs never reach the pipeline in the first place?&lt;/p&gt;

&lt;p&gt;I keep the longer version of the three measurements I use on technical debt on the Revin blog: &lt;a href="https://revin.com.br/en/blog/technical-debt-cost-three-measurements" rel="noopener noreferrer"&gt;https://revin.com.br/en/blog/technical-debt-cost-three-measurements&lt;/a&gt;&lt;/p&gt;

</description>
      <category>agents</category>
      <category>ai</category>
      <category>llm</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>I made the database fail on purpose in a legacy checkout: /health stayed 200 and 3 of 214 specs turned red</title>
      <dc:creator>Revin</dc:creator>
      <pubDate>Wed, 18 Nov 2026 21:24:58 +0000</pubDate>
      <link>https://dev.to/revinsoftware/i-made-the-database-fail-on-purpose-in-a-legacy-checkout-health-stayed-200-and-3-of-214-specs-2d44</link>
      <guid>https://dev.to/revinsoftware/i-made-the-database-fail-on-purpose-in-a-legacy-checkout-health-stayed-200-and-3-of-214-specs-2d44</guid>
      <description>&lt;p&gt;The complaint arrived as a screenshot: a spinner, then an error page, on a Tuesday afternoon. Three customers could not pay. By the time I opened the dashboard for that service, everything on it was green. Four instances up, CPU under 20%, uptime for the month a shade over 99.9%, no alert fired. The &lt;code&gt;/health&lt;/code&gt; endpoint had answered 200 the whole time.&lt;/p&gt;

&lt;p&gt;Here is that endpoint, with the variable names changed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// routes/health.js&lt;/span&gt;
&lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/health'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'ok'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;pkg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;uptime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uptime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That endpoint cannot fail. It reads nothing and calls nothing, so it keeps answering 200 while Postgres refuses connections, which is exactly what it did for about 40 minutes. The service is around nine years old, roughly 40k lines of Node and Express, 214 specs in the suite, and a coverage badge in the README that reads 87%.&lt;/p&gt;

&lt;p&gt;The people who own it asked a fair question. The suite is green, coverage is high, so why did nothing catch this? Coverage answers how much code ran while the tests ran, not which failures anything in that repo can notice. I wanted the second answer before touching a single spec, and there is a cheap way to get it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Borrowing determinism from a much bigger idea
&lt;/h2&gt;

&lt;p&gt;Martin Fowler's site published an article by Unmesh Joshi on deterministic simulation testing. The technique replaces the real clock, network and storage with simulated components driven by a single threaded execution loop, so the same partial failure produces the same execution trace on every run. It is written for distributed data stores, using a quorum key value store as the worked example. A nine year old checkout is not a distributed data store, and nobody there is going to rebuild it around a simulation loop this quarter.&lt;/p&gt;

&lt;p&gt;The part I could copy in an afternoon was the determinism. One seed, one injected fault, the same trace every time. I had already tried the other way: random packet drops and random connection kills against a staging copy. Two runs produced two different traces, the team called it flaky before lunch, and the conversation died there. A fault that fires on query number 3 on every run is an argument instead of an anecdote.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three things I instrument before trusting the suite
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. A health check that executes the dependencies
&lt;/h3&gt;

&lt;p&gt;First the endpoint has to do work, with a timeout short enough that it never becomes the outage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/health'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;checks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'SET statement_timeout = 800; SELECT 1'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;checks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'ok'&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;checks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;'fail'&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="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;gateway&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ping&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;timeoutMs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;800&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;checks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gateway&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'ok'&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;checks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gateway&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'fail'&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;checks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;every&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="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'ok'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;503&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;checks&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two dependencies, two codes in the body. The load balancer now has something to act on, and so does the on call person.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. A seeded fault injector around the pool
&lt;/h3&gt;

&lt;p&gt;No new library, no sidecar. A wrapper with a counter, so the failure lands on the same query every run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// test/faults.js&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;faultyPool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;failOnQuery&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;latencyMs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sql&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;n&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;failOnQuery&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'connection terminated unexpectedly'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'57P01'&lt;/span&gt;
        &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;latencyMs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;latencyMs&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;pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sql&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The counter is the whole trick. &lt;code&gt;failOnQuery: 3&lt;/code&gt; kills the third query of the request, which in this codebase is the one that reserves stock. Same seed, same victim, every single time.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. One counter for the business event
&lt;/h3&gt;

&lt;p&gt;Uptime is not a thing a customer buys. Failed payment attempts are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="n"&gt;paymentAttempts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;inc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'fail'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;'unknown'&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;One line in the catch block of the checkout handler, so the answer to "did anyone fail to pay yesterday" is a number somebody can read on a Monday morning.&lt;/p&gt;

&lt;h2&gt;
  
  
  The run
&lt;/h2&gt;

&lt;p&gt;I wired &lt;code&gt;faultyPool&lt;/code&gt; into the test bootstrap, with &lt;code&gt;failOnQuery: 3&lt;/code&gt; and 900 ms of latency on every other query, and ran the whole suite.&lt;/p&gt;

&lt;p&gt;214 specs. 3 turned red, all three in a module that formats order emails. 61 specs exercise the payment flow, and 58 of them replace the pool with a stub that always resolves, so the injected fault never reached the code under test. Nine of those 58 call the handler and assert nothing past the HTTP status.&lt;/p&gt;

&lt;p&gt;Then I ran the same fault against the service itself, by hand, with the gateway in sandbox mode. The response to the browser was HTTP 200 with &lt;code&gt;{ "status": "pending" }&lt;/code&gt;. The front end renders that as "we are confirming your payment". No payment row was written, no order existed, and the error from Postgres died inside a &lt;code&gt;catch (err) { logger.warn(err) }&lt;/code&gt; three frames down. The dashboard stayed green because nothing in the request path had any opinion about failure.&lt;/p&gt;

&lt;h2&gt;
  
  
  What did not work
&lt;/h2&gt;

&lt;p&gt;My first instinct was mutation testing, since the coverage number was the thing nobody trusted. I pointed Stryker at the repo and left it running. A bit over 3 hours later it reported surviving mutants, mostly in a date formatter that two call sites use. Useful information, wrong order. Running it later against the payment module alone took around 18 minutes and told me something I could act on.&lt;/p&gt;

&lt;p&gt;The random chaos attempt I already mentioned. It cost me two days and a reputation hit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where it stands
&lt;/h2&gt;

&lt;p&gt;The drill is a nightly job now, with three seeds: fail on the first query, fail on the query that writes the payment row, and 900 ms of latency on everything. The swallowing catch is gone, the handler returns 5xx, and the alert fires on the failed attempts counter rather than on CPU. In the first week that counter showed 11 failed attempts on a day the old dashboard called perfect.&lt;/p&gt;

&lt;p&gt;The thing I have no good answer for is the 58 specs that stub the pool. Rewriting them as integration tests is weeks of work on a service nobody wants to touch. Keeping them means the suite will stay green through the next outage of this exact shape.&lt;/p&gt;

&lt;p&gt;If you have worked on something like this: do you keep those stubbed specs and add a thin layer of fault tests around them, or do you delete them and accept the coverage drop in front of management? And how do you inject a deterministic failure into a dependency when you did not write the service and there is no staging that looks like production?&lt;/p&gt;

</description>
      <category>backend</category>
      <category>javascript</category>
      <category>node</category>
      <category>testing</category>
    </item>
    <item>
      <title>An agent rewrote a retry helper over a TODO from 2019: I counted 189 stale markers before the next run</title>
      <dc:creator>Revin</dc:creator>
      <pubDate>Wed, 11 Nov 2026 23:22:31 +0000</pubDate>
      <link>https://dev.to/revinsoftware/an-agent-rewrote-a-retry-helper-over-a-todo-from-2019-i-counted-189-stale-markers-before-the-next-3g8p</link>
      <guid>https://dev.to/revinsoftware/an-agent-rewrote-a-retry-helper-over-a-todo-from-2019-i-counted-189-stale-markers-before-the-next-3g8p</guid>
      <description>&lt;p&gt;Last Tuesday I gave a coding agent one task on a Node service I have read access to: add an optional &lt;code&gt;source&lt;/code&gt; field to a POST endpoint and persist it. Two files and a migration. The pull request that came back touched 14 files and included a rewritten retry helper nobody had asked about.&lt;/p&gt;

&lt;p&gt;I went looking for the reason. It was three lines above the handler:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// TODO(OPS-4412): retry logic here is wrong, fix when we drop the v1 client&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The v1 client was dropped in 2021. The tracker behind &lt;code&gt;OPS-4412&lt;/code&gt; was turned off the same year. Nothing in the repository says either of those things. The agent read a comment written by an engineer, about that exact file, and treated it as work in scope. That is what a comment is for.&lt;/p&gt;

&lt;p&gt;InfoQ published a piece on this a few hours ago and the behaviour has a name now. Sam Saccone and Madhuri Garikapati, at Google, call it agent distraction: stale TODOs, obsolete bug references and specs nobody updated pull an agent into side quests nobody requested. Reading it is what made me stop rewriting the prompt and start counting what the repository was telling the agent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Counting before cleaning
&lt;/h2&gt;

&lt;p&gt;First question: how much of this is in there at all.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ rg -n --no-heading -e &lt;span class="s1"&gt;'TODO'&lt;/span&gt; -e &lt;span class="s1"&gt;'FIXME'&lt;/span&gt; -e &lt;span class="s1"&gt;'HACK'&lt;/span&gt; -e &lt;span class="s1"&gt;'XXX'&lt;/span&gt; src &lt;span class="o"&gt;|&lt;/span&gt; wc -l
211
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A raw count says nothing. What matters is age, because a marker written last month is a note and a marker written in 2018 is furniture. So I dated every one of them by the commit that introduced the line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rg -n --no-heading -e &lt;span class="s1"&gt;'TODO'&lt;/span&gt; -e &lt;span class="s1"&gt;'FIXME'&lt;/span&gt; -e &lt;span class="s1"&gt;'HACK'&lt;/span&gt; -e &lt;span class="s1"&gt;'XXX'&lt;/span&gt; src \
  &lt;span class="o"&gt;|&lt;/span&gt; cut -d: -f1,2 \
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nv"&gt;IFS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;: &lt;span class="nb"&gt;read&lt;/span&gt; -r file line&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      git blame -L &lt;span class="s2"&gt;"$line,$line"&lt;/span&gt; --porcelain -- &lt;span class="s2"&gt;"$file"&lt;/span&gt; \
        &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'/^author-time/ {print strftime("%Y", $2)}'&lt;/span&gt;
    &lt;span class="k"&gt;done&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; uniq -c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     12 2017
     19 2018
     31 2019
     44 2020
     38 2021
     22 2022
      9 2023
     14 2024
     12 2025
     10 2026
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;189 of the 211 were written before 2025. The service has had 4 contributors in the last twelve months, and none of them wrote most of that.&lt;/p&gt;

&lt;p&gt;Then the ones pointing at systems that no longer answer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ rg -o &lt;span class="s1"&gt;'OPS-[0-9]+'&lt;/span&gt; src &lt;span class="o"&gt;|&lt;/span&gt; wc -l
37
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thirty seven references to a ticket prefix that resolves to nothing. Another 9 named feature flags that are not in the config file anymore. Those 46 lines are pure instruction with no way to verify it, which is the worst possible input for something that reads the repository as context and cannot ask a colleague.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three kinds of rot, and only one is in the code
&lt;/h2&gt;

&lt;p&gt;The comments were the obvious part. The documents did more damage per line:&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="k"&gt;for&lt;/span&gt; f &lt;span class="k"&gt;in&lt;/span&gt; docs/*.md&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%s %s\n'&lt;/span&gt; &lt;span class="s2"&gt;"$(git log -1 --format=%ad --date=short -- "&lt;/span&gt;&lt;span class="nv"&gt;$f&lt;/span&gt;&lt;span class="s2"&gt;")"&lt;/span&gt; &lt;span class="s2"&gt;"$f"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort
2022-03-04 docs/billing-webhooks.md
2022-08-17 docs/payments-api.md
2024-11-02 docs/architecture.md
2026-02-09 docs/README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two specs frozen in 2022, describing response shapes that changed at least twice since. The agent trusts a markdown file more than it trusts the code, because the file reads like intent and the code reads like an accident.&lt;/p&gt;

&lt;p&gt;And the file written specifically for the agent was wrong too:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ grep -n &lt;span class="s1"&gt;'yarn'&lt;/span&gt; AGENTS.md
12:Run &lt;span class="sb"&gt;`yarn test:unit`&lt;/span&gt; before proposing changes.

$ jq -r &lt;span class="s1"&gt;'.scripts | keys[]'&lt;/span&gt; package.json &lt;span class="o"&gt;|&lt;/span&gt; grep &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;span class="nb"&gt;test&lt;/span&gt;
test:integration
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That script was deleted some seven months ago. Part of two runs went into making a command that does not exist produce output. There is a post here on dev.to about AGENTS.md being an attack surface that pulled 32 comments, and the uncomfortable half of it is this: the same blind trust that makes a malicious file dangerous makes a merely outdated one expensive.&lt;/p&gt;

&lt;p&gt;So the inventory came out in three piles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;markers that reference dead trackers, dead flags and dead clients (46 lines)&lt;/li&gt;
&lt;li&gt;markers that still describe real unfinished work, written by people who left (a shade over 60, I stopped counting exactly at 63)&lt;/li&gt;
&lt;li&gt;documents and agent instructions that contradict the running code (3 files)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What did not work
&lt;/h2&gt;

&lt;p&gt;Two attempts before the one that stuck.&lt;/p&gt;

&lt;p&gt;I added a line to AGENTS.md telling the agent to ignore TODO comments older than a year. It held on short tasks and fell apart on anything that ran more than a few minutes, which matches what the Google engineers describe: the distraction does not come from one instruction, it comes from the accumulated context, and my line was one sentence against 189.&lt;/p&gt;

&lt;p&gt;Then I deleted all 211 markers in a single commit. That was worse. Two of them described a known race condition in the webhook consumer that was never ticketed anywhere, and I only noticed because I had the diff open when someone mentioned the symptom. Deleting a marker deletes the only record of the problem in about the frequency you would expect from an undocumented codebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pass itself
&lt;/h2&gt;

&lt;p&gt;In the order I ran it, over roughly two afternoons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Markers referencing the dead tracker, flags or clients: read each one, delete. 46 lines gone, no replacement.&lt;/li&gt;
&lt;li&gt;Markers describing real work: open an issue, replace the comment with one line carrying the issue URL and the date. The comment stops being an instruction and becomes a pointer.&lt;/li&gt;
&lt;li&gt;The two frozen specs: moved to &lt;code&gt;docs/archive/&lt;/code&gt; with a first line saying what they are and when they stopped being true. Archived beats deleted, because the next person still wants the history.&lt;/li&gt;
&lt;li&gt;AGENTS.md: every command in it executed by hand before the commit. If it does not run, it does not stay in the file.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;No refactoring in that pass. Nothing in &lt;code&gt;src&lt;/code&gt; changed behaviour, and that was on purpose, so the measurement afterwards would have one variable.&lt;/p&gt;

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

&lt;p&gt;Twelve tasks before the cleanup, twelve after, same kind of work: small field additions, two bug fixes, one endpoint.&lt;/p&gt;

&lt;p&gt;Before, the median pull request touched a shade over 9 files, and 11 of the 12 contained at least one change I had not asked for. After, the median was 3 files, and unrequested changes showed up in 2 of 12. Input tokens per task fell roughly 28%, from somewhere around 61k to around 44k, which is the number everyone quotes and the least interesting one here. The expensive part was never the tokens. It was reading a 14 file diff to find out that 12 of those files were a conversation from 2019.&lt;/p&gt;

&lt;p&gt;I do not know how this holds up on a repository with twenty active contributors. This one has four, and the rot was almost entirely written by people who are gone, which makes it easy to delete and hard to argue with. On a busy codebase the markers are alive and the triage is a political problem, not a &lt;code&gt;git blame&lt;/code&gt; problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  The part I have not solved
&lt;/h2&gt;

&lt;p&gt;The repository is clean today and it will rot back. The obvious fix is a CI rule that fails on a TODO without an issue reference and a date. I have not shipped it, because I suspect it teaches people to write TODOs without using the word TODO, and an undetectable stale marker is strictly worse than a detectable one.&lt;/p&gt;

&lt;p&gt;So: do you gate markers in CI, do you expire them, or do you run a cleanup pass before each agent session and accept it as a cost of operating the thing? If you gate them, did the comments actually improve, or did they just move?&lt;/p&gt;

&lt;p&gt;I write about the measurement side of this at the Revin blog: &lt;a href="https://revin.com.br/en/blog/technical-debt-ai-coding-agents" rel="noopener noreferrer"&gt;Technical debt from AI coding agents: how to measure the bill&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>agents</category>
      <category>ai</category>
      <category>llm</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>I replayed 48 commits of one OpenAPI file: 11 of them removed a required field after clients were live</title>
      <dc:creator>Revin</dc:creator>
      <pubDate>Mon, 09 Nov 2026 14:45:14 +0000</pubDate>
      <link>https://dev.to/revinsoftware/i-replayed-48-commits-of-one-openapi-file-11-of-them-removed-a-required-field-after-clients-were-1im2</link>
      <guid>https://dev.to/revinsoftware/i-replayed-48-commits-of-one-openapi-file-11-of-them-removed-a-required-field-after-clients-were-1im2</guid>
      <description>&lt;p&gt;Before I wrote software for a living I signed drawings. Steel structure, Autódromo de Interlagos. A beam went up only after a drawing that had a revision index in the corner: rev. 0, rev. 1, rev. 2, each one with a date and a name next to it. Wanted the beam two meters to the left after the concrete was already down? That was rev. 3. And rev. 3 had a price and a new date before anyone touched a bolt.&lt;/p&gt;

&lt;p&gt;Then I moved into software and watched the scope of one service change twice in the same week with no revision index anywhere.&lt;/p&gt;

&lt;p&gt;There is a question on Software Engineering Stack Exchange asking &lt;a href="https://softwareengineering.stackexchange.com/questions/158640/why-cant-the-it-industry-deliver-large-faultless-projects-quickly-as-in-other" rel="noopener noreferrer"&gt;why the IT industry cannot deliver large, faultless projects quickly as in other industries&lt;/a&gt;. 543 points, a little under 124,000 views, 31 answers. I read most of them. They blame requirements, estimation, physics, hiring, management. What I did not find was the boring mechanical difference I actually lived through: in steel, the drawing is the versioned artifact and the thing you build is derived from it. In software, the build is versioned and the drawing lives in a thread.&lt;/p&gt;

&lt;p&gt;So last month I went looking for the drawing in a repo I have read access to. In an HTTP service, the closest thing to a drawing is the contract.&lt;/p&gt;

&lt;h2&gt;
  
  
  The service, and the count that lied to me
&lt;/h2&gt;

&lt;p&gt;Node and TypeScript, order service, roughly 14k lines, 7 months old, three consumers: an iOS app, one partner integration over HTTP, and an internal dashboard. One &lt;code&gt;api/openapi.yaml&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;My first attempt was the obvious one. Count how much the surface moved by counting commits on the handlers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git log &lt;span class="nt"&gt;--oneline&lt;/span&gt; &lt;span class="nt"&gt;--&lt;/span&gt; src/http/handlers | &lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
317
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That number is worthless and I threw it away. It counts a rename, a Prettier run, a logging tweak and a field deletion as the same event. It measures typing, not revisions.&lt;/p&gt;

&lt;p&gt;Second attempt, much narrower. Only the contract file, and only the kind of change that can break somebody who is already calling you: a field that was &lt;code&gt;required&lt;/code&gt; in a response schema and stopped being there. That definition misses plenty, which I will get to, but it has one property I wanted. It produces no false positives. If a required field is gone, somebody's parser is going to find out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Replaying the contract commit by commit
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git rev-list &lt;span class="nt"&gt;--reverse&lt;/span&gt; HEAD &lt;span class="nt"&gt;--&lt;/span&gt; api/openapi.yaml | &lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
48
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Forty-eight revisions of the drawing in 7 months. Now walk them and diff the required sets.&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;# contract_revisions.py  (pip install pyyaml)
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;subprocess&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;yaml&lt;/span&gt;

&lt;span class="n"&gt;PATH&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;api/openapi.yaml&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;RANGE&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;1&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;HEAD&lt;/span&gt;&lt;span class="sh"&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;revs&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;git&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;rev-list&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;--reverse&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;RANGE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;--&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;PATH&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                         &lt;span class="n"&gt;capture_output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;required&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rev&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;blob&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;git&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;show&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;rev&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;:&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;PATH&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                          &lt;span class="n"&gt;capture_output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;
    &lt;span class="n"&gt;spec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;yaml&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;safe_load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="n"&gt;schemas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;components&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{}).&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;schemas&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{})&lt;/span&gt;
    &lt;span class="k"&gt;return&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="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;required&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[]))&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;schemas&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="n"&gt;history&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;revs&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;breaks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;required&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;history&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;rev&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;history&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:]:&lt;/span&gt;
    &lt;span class="n"&gt;cur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;required&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rev&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;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;prev&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="n"&gt;gone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;gone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;breaks&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;rev&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; lost required: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gone&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;prev&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;breaks&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; breaking revisions across &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;history&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; commits&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 contract_revisions.py
3f9a21c7 Order lost required: deliveryWindow
7c04bb1e Order lost required: customerTaxId
a1d7e8b2 Shipment lost required: carrierCode, trackingCode
b6c13f09 Order lost required: deliveryWindow
...
11 breaking revisions across 48 commits
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Eleven. Sorted by what they actually were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Four renames. &lt;code&gt;customerTaxId&lt;/code&gt; became &lt;code&gt;taxId&lt;/code&gt;, shipped under a commit message that said &lt;code&gt;chore: naming&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Five fields that moved into a nested object, which reads like a tidy-up in the diff and reads like a missing field to a client.&lt;/li&gt;
&lt;li&gt;Two product decisions in the same week pointing opposite ways. One meeting dropped &lt;code&gt;deliveryWindow&lt;/code&gt; from the response. The meeting four days later asked for it back, split into &lt;code&gt;deliveryWindowStart&lt;/code&gt; and &lt;code&gt;deliveryWindowEnd&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two of the eleven had anything written down outside the diff. The partner integration learned about one of them from a support ticket: their sync threw on the missing field and 41 jobs failed over a weekend before anyone connected the two events.&lt;/p&gt;

&lt;p&gt;None of the eleven was negligence. Every one of them was somebody doing a sensible thing to the code without the drawing having a revision index.&lt;/p&gt;

&lt;h2&gt;
  
  
  The revision index, in about twenty lines
&lt;/h2&gt;

&lt;p&gt;What Interlagos had was not discipline, it was friction placed at the right moment. Nobody was forbidden from moving a beam. Moving it cost a revision, a signature and a new date, and that cost alone made a good half of the requests evaporate before they reached me.&lt;/p&gt;

&lt;p&gt;So I put the index on the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# api/openapi.yaml&lt;/span&gt;
&lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;orders&lt;/span&gt;
  &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1.7.0&lt;/span&gt;
  &lt;span class="na"&gt;x-contract-revision&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;12&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And a check in CI that fails when a required field leaves without the number going up in the same pull request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-euo&lt;/span&gt; pipefail
&lt;span class="nv"&gt;base&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;git merge-base origin/main HEAD&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;python3 contract_revisions.py &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$base&lt;/span&gt;&lt;span class="s2"&gt;~1..HEAD"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s1"&gt;'lost required'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; git diff &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$base&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; HEAD &lt;span class="nt"&gt;--&lt;/span&gt; api/openapi.yaml | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s1"&gt;'^+.*x-contract-revision'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"breaking contract change without a revision bump"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
  &lt;span class="k"&gt;fi
fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;~1&lt;/code&gt; is there because the script compares each commit to the one before it, so the first commit in the range needs a predecessor to be compared against. Took me two red builds to notice.&lt;/p&gt;

&lt;p&gt;The rule that goes with the bump is the part that matters, and it is not code: the pull request body carries the date and the name of whoever on the consuming side said yes. Same as the drawing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this does not catch
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Semantic drift, which is the expensive one. A &lt;code&gt;status&lt;/code&gt; field that keeps its name and starts carrying a fourth value breaks consumers with zero movement in the required set. Narrowing an enum, widening a type and changing a unit all slip through for the same reason.&lt;/li&gt;
&lt;li&gt;Anything about behaviour. Ordering, pagination defaults, response time, retry semantics. The drawing describes shape, not load.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also have no idea whether this is worth doing in a repo with 30 consumers. If you are at that size you probably run a schema registry with compatibility rules already, and this is a poor man's version of it. It is written for the service that has three consumers and a YAML file nobody treats as an artifact.&lt;/p&gt;

&lt;p&gt;And it does not freeze scope. I do not want it to. Interlagos never froze scope either. It just made the change arrive with a price attached, at the moment someone asked for it, instead of three weeks later as 41 failed syncs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Five weeks in
&lt;/h2&gt;

&lt;p&gt;Three contract changes since the check went in. All three bumped the revision. One of them got pulled back inside the pull request, because the person who owns the partner integration asked for two weeks of notice, and two weeks of waiting was visibly cheaper than another weekend of nobody knowing why the sync died.&lt;/p&gt;

&lt;p&gt;That is the whole answer I would have posted on that Stack Exchange thread, if it were not already thirteen years old: software can absolutely be delivered like a building, for the part of it that is a drawing. The problem is that we version the thing we type and not the thing we promised.&lt;/p&gt;

&lt;p&gt;So, genuinely: how do you record a contract change so the consuming side finds out before its parser does? Schema registry with enforced compatibility, a deprecation header with a sunset date, a changelog somebody reads, a consumer-driven contract test suite? I want the one that survived contact with a partner who does not read your release notes.&lt;/p&gt;

&lt;p&gt;· · ·&lt;/p&gt;

&lt;p&gt;Originally published on the &lt;a href="https://revin.com.br/en/blog/why-it-cannot-deliver-like-construction" rel="noopener noreferrer"&gt;Revin blog&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>api</category>
      <category>architecture</category>
      <category>softwaredevelopment</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>11 tools in my MCP server, 3 of them did 91% of the calls: what I ask before adding a 12th</title>
      <dc:creator>Revin</dc:creator>
      <pubDate>Thu, 05 Nov 2026 16:22:57 +0000</pubDate>
      <link>https://dev.to/revinsoftware/11-tools-in-my-mcp-server-3-of-them-did-91-of-the-calls-what-i-ask-before-adding-a-12th-5e7m</link>
      <guid>https://dev.to/revinsoftware/11-tools-in-my-mcp-server-3-of-them-did-91-of-the-calls-what-i-ask-before-adding-a-12th-5e7m</guid>
      <description>&lt;p&gt;Two weeks ago the MCP server behind my orchestrator exposed 11 tools. It exposes 4 now. Nothing the agent does changed, because three of those 11 were already doing 91% of the work and I had never bothered to count.&lt;/p&gt;

&lt;p&gt;The orchestrator is a small thing I run for content operations: it plans slots, drafts copy, schedules what passes review. Every step talks to the same MCP server, which I maintain, which means every bad decision in it is mine. I went looking because of the token bill. I stayed because of the errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the log said
&lt;/h2&gt;

&lt;p&gt;I turned on one structured line per tool call and left it for 16 days. 427 runs, 1,318 calls.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'select(.event=="tool_call") | .tool'&lt;/span&gt; calls.ndjson &lt;span class="se"&gt;\&lt;/span&gt;
  | &lt;span class="nb"&gt;sort&lt;/span&gt; | &lt;span class="nb"&gt;uniq&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    612 get_content_brief
    402 save_draft
    187 list_pending_slots
     54 get_brand_voice
     33 publish_draft
     18 schedule_post
      7 get_channel_stats
      3 search_published
      2 update_slot_status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nine lines for eleven tools. &lt;code&gt;archive_draft&lt;/code&gt; and &lt;code&gt;get_competitor_feed&lt;/code&gt; never showed up at all, which is the kind of absence &lt;code&gt;uniq -c&lt;/code&gt; will never tell you about. The top three add up to 1,201 of 1,318 calls, a bit over 91%.&lt;/p&gt;

&lt;p&gt;All eleven definitions ride along in every request. I ran the tool block through the tokenizer the model actually uses and got a bit over 6,400 tokens. The three tools doing the work account for about 1,900 of those. So on each of those 1,318 calls I paid to re-send roughly 4,500 tokens of JSON schema describing tools the model mostly ignored. Somewhere near 5.9 million tokens of context spent on a menu.&lt;/p&gt;

&lt;p&gt;Then the failures. 37 calls came back with argument validation errors, and 29 of them were the model reaching for &lt;code&gt;publish_draft&lt;/code&gt; when it meant &lt;code&gt;schedule_post&lt;/code&gt;, or the reverse. I put the two descriptions side by side and I would have gotten it wrong too.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"publish_draft"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Publish a draft to its channel."&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"schedule_post"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Publish a draft to its channel at a given time."&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second one is the first one with an extra argument. Blaming the model for that is cheap.&lt;/p&gt;

&lt;p&gt;I am not the only person running this math this month. A post here about cutting an MCP server from 15 tools to 4 pulled 76 comments against 61 reactions, a ratio you almost never see on this site, and more argument than applause usually means nobody agrees on where the line goes. InfoQ reported this week that Uber put a gateway in front of more than 800 MCP servers and over 5,000 tools, with incremental discovery so an agent never sees the whole catalogue at once. Same problem, four orders of magnitude up.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix I tried first and threw away
&lt;/h2&gt;

&lt;p&gt;My first move was the clever one: collapse everything into a single &lt;code&gt;call&lt;/code&gt; tool with an &lt;code&gt;action&lt;/code&gt; string and a free-form &lt;code&gt;payload&lt;/code&gt;, dispatched server side. The tool block dropped to a little over 300 tokens and I was briefly very pleased with myself.&lt;/p&gt;

&lt;p&gt;Then the agent started inventing actions. &lt;code&gt;create_brief&lt;/code&gt;. &lt;code&gt;draft_save&lt;/code&gt;. Names that read exactly like my own convention and did not exist. Across 90 runs, something like 1 in 6 calls needed a retry, because an enum the model cannot see is an enum the model will guess. The schema was not overhead, it was the contract. I put it back and went after the list instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does it write? Then what undoes it?
&lt;/h3&gt;

&lt;p&gt;Every write tool in the registry has to name the tool that reverses it, as a required field. If I cannot name the inverse, the agent does not get the tool. That killed &lt;code&gt;archive_draft&lt;/code&gt; in about four seconds: the unarchive was me running an UPDATE by hand, which is not an undo the agent can reach.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;ToolSpec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;read&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;write&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;undo&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c1"&gt;// required when mode === "write"&lt;/span&gt;
  &lt;span class="nl"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c1"&gt;// a person, not a team alias&lt;/span&gt;
  &lt;span class="nl"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;    &lt;span class="c1"&gt;// credential id this tool uses&lt;/span&gt;
  &lt;span class="nl"&gt;rotatedAt&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;tools&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="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;mode&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;write&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;undo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`write tool &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; has no documented undo`&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="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;mode&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;write&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`write tool &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; has no owner`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It fails at boot, not at runtime. The &lt;code&gt;secret&lt;/code&gt; and &lt;code&gt;rotatedAt&lt;/code&gt; fields are there for the question nobody asks until something leaks: each tool is a credential with a blast radius, and an agent that holds nine of them holds nine keys. Mine had two tools sharing one API key whose last rotation I could not date.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reading only the descriptions, would I pick the right one?
&lt;/h3&gt;

&lt;p&gt;Hide the names, read the one-liners, choose. If two tools differ only by an argument, they are one tool. &lt;code&gt;publish_draft&lt;/code&gt; and &lt;code&gt;schedule_post&lt;/code&gt; became one &lt;code&gt;publish_draft&lt;/code&gt; with an optional &lt;code&gt;at&lt;/code&gt;. Over the following 16 days, wrong-tool errors went from 37 to 3, and two of those three were my planner sending a bad payload.&lt;/p&gt;

&lt;p&gt;This is the question that pays fastest, and it costs nothing but reading your own manifest as a stranger would.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does it earn its schema?
&lt;/h3&gt;

&lt;p&gt;Calls per week against tokens of definition, every request, forever. &lt;code&gt;get_channel_stats&lt;/code&gt;: 7 calls in 16 days, around 480 tokens riding along 1,318 times. It did not earn it.&lt;/p&gt;

&lt;p&gt;None of the deleted tools disappeared. They moved behind a second call. &lt;code&gt;list_capabilities&lt;/code&gt; returns names and one-line summaries, and the full schema for a group arrives only when the agent asks for it. The planning step sees 4 tools. The rare paths pay their own cost at the moment they are used, which is the same trick Uber's gateway does with a much bigger catalogue.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where it landed
&lt;/h2&gt;

&lt;p&gt;Four tools in the default surface: &lt;code&gt;get_content_brief&lt;/code&gt;, &lt;code&gt;save_draft&lt;/code&gt;, &lt;code&gt;list_pending_slots&lt;/code&gt;, &lt;code&gt;publish_draft&lt;/code&gt;. Tool block down from a bit over 6,400 tokens to about 2,050. Wrong-tool errors from 37 to 3 over a comparable window. The agent has asked for the discovery group 9 times in 16 days, and &lt;code&gt;get_competitor_feed&lt;/code&gt; is still at zero, so it will probably come out of the registry entirely.&lt;/p&gt;

&lt;p&gt;One number I will not claim: latency. The p50 of the planning step went from around 9s to under 7s, but I changed the tool list and the prompt in the same week, so attributing that to the schema would be a story, not a measurement.&lt;/p&gt;

&lt;p&gt;And one thing I genuinely do not know how to scale. The undo rule works because the registry has one maintainer. With nine teams publishing tools into a shared gateway, somebody is going to type &lt;code&gt;undo: "manual"&lt;/code&gt; and move on, and the boot assertion will pass while the guarantee quietly stops existing.&lt;/p&gt;

&lt;p&gt;So: hard cap on the default surface, or discovery from day one? And what do you do with a write tool whose only inverse is a human with database access?&lt;/p&gt;

&lt;p&gt;Originally published on the Revin blog.&lt;/p&gt;

</description>
      <category>agents</category>
      <category>llm</category>
      <category>mcp</category>
      <category>productivity</category>
    </item>
    <item>
      <title>I grepped 61 merged pull requests for three tells: 9 had a test file with zero assertions</title>
      <dc:creator>Revin</dc:creator>
      <pubDate>Fri, 30 Oct 2026 13:22:28 +0000</pubDate>
      <link>https://dev.to/revinsoftware/i-grepped-61-merged-pull-requests-for-three-tells-9-had-a-test-file-with-zero-assertions-3iga</link>
      <guid>https://dev.to/revinsoftware/i-grepped-61-merged-pull-requests-for-three-tells-9-had-a-test-file-with-zero-assertions-3iga</guid>
      <description>&lt;p&gt;Martin Fowler published a bliki entry today called LLM Voice. It is about reading, not about writing. He describes the growing feeling that the thing in front of him came out of a model, and how his desire to keep reading drops off once that feeling arrives.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I can't necessarily define why, although there are the common tells (it's not the em-dashes, it's the load-bearing tapestries).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;He also says he distrusts the tools that claim to detect model prose, partly on accuracy, partly because detection misses the point. The reaction is a human one.&lt;/p&gt;

&lt;p&gt;I get that same feeling in code review, and I get it most weeks. The pull request description is tidy. The sections line up. Commit messages are in the imperative mood. Then I open the test file and nothing in it asserts anything.&lt;/p&gt;

&lt;p&gt;The trouble is that the feeling is useless as a review comment. "This reads like a model wrote it" gives the author nothing to fix, it insults people who write carefully in a second language, and I have been wrong about it more than once. So about five weeks ago I stopped reviewing the voice and started checking the consequences with grep.&lt;/p&gt;

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

&lt;p&gt;61 merged pull requests across three repositories. TypeScript, Node, Jest, roughly five weeks. Mixed authorship: some people on those repos use a coding assistant all day, some never open one, and nothing in the repo records which is which.&lt;/p&gt;

&lt;p&gt;Three checks, all cheap enough to run against a diff while I read it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Check one: test files that never assert
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fd &lt;span class="nt"&gt;-e&lt;/span&gt; spec.ts &lt;span class="nt"&gt;-e&lt;/span&gt; test.ts &lt;span class="nb"&gt;.&lt;/span&gt; src | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; f&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
  &lt;/span&gt;rg &lt;span class="nt"&gt;-qP&lt;/span&gt; &lt;span class="s1"&gt;'\b(expect|assert|should)\s*\('&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"no assertion: &lt;/span&gt;&lt;span class="nv"&gt;$f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First pass on the largest repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;no assertion: src/billing/invoice.service.spec.ts
no assertion: src/orders/cancel.handler.spec.ts
no assertion: src/auth/token.guard.spec.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All three had been merged weeks earlier. All three were green. One of them looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rejects an expired token&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/orders&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Authorization&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;`Bearer &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;expiredToken&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That test passes if the guard returns 401. It also passes if someone deletes the guard, because the only thing it can fail on is a thrown exception. The name of the test carries the whole claim, and the name is not executable.&lt;/p&gt;

&lt;p&gt;Part of this is solved by eslint-plugin-jest with the expect-expect rule, and I turned it on. It did not help as much as I wanted. Two of the three repos did not have the plugin at all, and the rule does not know about our custom helpers, so it needs an allowlist that nobody maintains.&lt;/p&gt;

&lt;h3&gt;
  
  
  Check two: expects that only verify the mock
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rg &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="s1"&gt;'expect\('&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; &lt;span class="s1"&gt;'*.spec.ts'&lt;/span&gt; src | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; f&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nv"&gt;total&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;rg &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s1"&gt;'expect\('&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
  &lt;span class="nv"&gt;calls&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;rg &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s1"&gt;'expect\([^)]*\)\.toHaveBeenCalled'&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$total&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$calls&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$f&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="nv"&gt;$calls&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;$total&lt;/span&gt;&lt;span class="s2"&gt; assertions are call checks"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/pricing/apply-discount.spec.ts: 4/4 assertions are call checks
src/notify/send-receipt.spec.ts: 3/3 assertions are call checks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A file where every assertion is toHaveBeenCalled proves that the wiring of the test works. The function under test can return a wrong number, a null, or a string where money should be, and the suite stays green. This one is harder to argue about than check one, because the author did write assertions. They just all point at the test's own scaffolding.&lt;/p&gt;

&lt;h3&gt;
  
  
  Check three: catch blocks that log and swallow
&lt;/h3&gt;

&lt;p&gt;I tried a regex here and wasted an afternoon on multiline matches. Ast-grep did it in one line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ast-grep &lt;span class="nt"&gt;--lang&lt;/span&gt; ts &lt;span class="nt"&gt;--pattern&lt;/span&gt; &lt;span class="s1"&gt;'try { $$$ } catch ($E) { logger.$M($$$) }'&lt;/span&gt; src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The shape it finds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;publishInvoice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;publishInvoice failed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;err&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;No rethrow, no return of a failure, no retry. The caller gets a resolved promise and marks the order as published. The log line exists, so a dashboard somewhere will even show it, and nothing in the system acts on it. The metric is there, the guarantee is not.&lt;/p&gt;

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

&lt;p&gt;Of the 61 pull requests, 9 carried at least one test file with zero assertions, a shade over 14%. In 6 more, every assertion added by the diff was a call check. 4 introduced a catch that swallowed an error on a path the same diff created. Three pull requests tripped two checks at once, so the unique count is 16.&lt;/p&gt;

&lt;p&gt;The part I did not expect: at least 4 of those 9 came from people on the team who do not use a coding assistant at all. I know, because I asked. Whatever these checks find, it is not authorship. It is the moment in a review where the description was convincing enough that nobody opened the second file.&lt;/p&gt;

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

&lt;p&gt;My first attempt was the obvious one. I wrote a scorer for pull request descriptions: a word list, sentence length variance, how symmetrical the bullet lists were, output as a number between 0 and 1. It lasted two days. It flagged the two most careful writers on the team, both of them writing in a second language, and it gave a clean score to a pull request whose code was clearly generated and whose description someone had typed by hand. Fowler's warning about detectors transfers to code review without a single edit, and the conversation the scorer started was worse than the problem it was meant to solve.&lt;/p&gt;

&lt;p&gt;I also tried failing the build on check one. That lasted until the first snapshot suite, where the assertion lives inside a helper and the regex cannot see it. Now the check posts a comment listing the files and lets the merge through. The number in the comment does the work.&lt;/p&gt;

&lt;p&gt;On two of the services I went further and ran mutation testing restricted to the files the diff touched. Line coverage on those files sat in the high eighties, the mutation score came back in the forties. It is slow, so I only reach for it when one of the three checks fires twice in the same service.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changed in review
&lt;/h2&gt;

&lt;p&gt;Review time went up by something like three minutes per pull request, which I would pay again, because the three checks hand me a sentence I can write without accusing anybody of anything: this file has no assertion, add one. Nobody argues with that sentence. People argue with vibes, and they are right to.&lt;/p&gt;

&lt;p&gt;I do not know how this holds up in a repo with 40 contributors, or in a language where the test runner does not make assertions this greppable. Three repos and five weeks is a small sample, and two of the repos share a tooling setup, so the checks were easy to write by construction.&lt;/p&gt;

&lt;p&gt;So, the question for you: what is your mechanical tell? The thing you can grep, not the thing you feel. And if you have found a way to measure assertion quality in review without it turning into a bot telling someone their test is bad, I would like to read how you set it up.&lt;/p&gt;

&lt;p&gt;I write about review and legacy work at the Revin blog, including a longer piece in Portuguese on &lt;a href="https://revin.com.br/pt/blog/revisao-de-codigo-com-ia" rel="noopener noreferrer"&gt;how far you can take the human out of the pull request&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
      <category>llm</category>
      <category>testing</category>
      <category>ai</category>
    </item>
    <item>
      <title>A screen took 14 seconds with the server at 12% CPU: I measured the wait before approving two more instances</title>
      <dc:creator>Revin</dc:creator>
      <pubDate>Wed, 14 Oct 2026 13:30:10 +0000</pubDate>
      <link>https://dev.to/revinsoftware/a-screen-took-14-seconds-with-the-server-at-12-cpu-i-measured-the-wait-before-approving-two-more-40nb</link>
      <guid>https://dev.to/revinsoftware/a-screen-took-14-seconds-with-the-server-at-12-cpu-i-measured-the-wait-before-approving-two-more-40nb</guid>
      <description>&lt;p&gt;The complaint was specific. The operations dashboard took 14 seconds to open. The capacity panel next to it showed the four application instances running at a shade over 12% CPU, averaged over the week. Both numbers were true at the same time, and that pair is the whole story.&lt;/p&gt;

&lt;p&gt;The meeting had already decided the shape of the answer: CPU is getting scarce, reservations are the hedge, put two more instances in the plan. LeadDev ran a piece called "Stop asking engineers how many machines they need", and The Pragmatic Engineer's Pulse recommended reserving compute ahead of the squeeze. Neither one tells you what your number should be. The number I was being asked to sign off on had nothing behind it except the latency people were angry about.&lt;/p&gt;

&lt;p&gt;A box sitting at 12% has almost nothing to compute. It is waiting on something. So before touching instance counts I spent an afternoon finding out what it waits for.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: split the 14 seconds into app time and database time
&lt;/h2&gt;

&lt;p&gt;No APM on this service, so the cheapest instrument was a middleware that logs total request time next to accumulated query time and query count.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hrtime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bigint&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dbMs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;queries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;finish&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;totalMs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hrtime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bigint&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="nx"&gt;e6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;route&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;route&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;totalMs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;totalMs&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="na"&gt;dbMs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dbMs&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="na"&gt;queries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;queries&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="nf"&gt;next&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 query wrapper adds to &lt;code&gt;req.dbMs&lt;/code&gt; and increments &lt;code&gt;req.queries&lt;/code&gt;. One page load, logged:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;route=/dashboard totalMs=14102 dbMs=13140 queries=41
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So 13.1 of the 14 seconds happened inside Postgres, spread over 41 round trips for a single screen. Application code was responsible for under a second. Adding instances multiplies the thing that was already idle.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: ask the database which statement owns the time
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;select&lt;/span&gt;
  &lt;span class="n"&gt;calls&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;round&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;total_exec_time&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)::&lt;/span&gt;&lt;span class="nb"&gt;numeric&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;total_s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mean_exec_time&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nb"&gt;numeric&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;mean_ms&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;left&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;52&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pg_stat_statements&lt;/span&gt;
&lt;span class="k"&gt;order&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="n"&gt;total_exec_time&lt;/span&gt; &lt;span class="k"&gt;desc&lt;/span&gt;
&lt;span class="k"&gt;limit&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; calls  | total_s | mean_ms | query
--------+---------+---------+------------------------------------------------------
  44412 |  8912.4 |   200.7 | select * from events where asset_id = $1 order by oc
    118 |  1204.8 | 10210.1 | select sum(amount) from ledger_entries where tenant_
   9031 |   301.2 |    33.4 | select id, name from assets where tenant_id = $1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The top row is 200 milliseconds per call, which nobody would flag in isolation. The damage is in &lt;code&gt;calls&lt;/code&gt;. Thirty-seven of the 41 queries on that screen were that same statement with a different &lt;code&gt;asset_id&lt;/code&gt;. An N+1 wearing a dashboard.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: EXPLAIN the cheap-looking query
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;EXPLAIN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;ANALYZE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;BUFFERS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;events&lt;/span&gt; &lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="n"&gt;asset_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;90412&lt;/span&gt; &lt;span class="k"&gt;order&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="n"&gt;occurred_at&lt;/span&gt; &lt;span class="k"&gt;desc&lt;/span&gt; &lt;span class="k"&gt;limit&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

 &lt;span class="k"&gt;Limit&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;18402&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;01&lt;/span&gt;&lt;span class="p"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;18402&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;01&lt;/span&gt; &lt;span class="k"&gt;rows&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;48&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;actual&lt;/span&gt; &lt;span class="nb"&gt;time&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;198&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;812&lt;/span&gt;&lt;span class="p"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;198&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;814&lt;/span&gt; &lt;span class="k"&gt;rows&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;loops&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;  &lt;span class="n"&gt;Sort&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;18402&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;01&lt;/span&gt;&lt;span class="p"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;18402&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;02&lt;/span&gt; &lt;span class="k"&gt;rows&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;48&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
         &lt;span class="n"&gt;Sort&lt;/span&gt; &lt;span class="k"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;occurred_at&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;
         &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;  &lt;span class="n"&gt;Seq&lt;/span&gt; &lt;span class="n"&gt;Scan&lt;/span&gt; &lt;span class="k"&gt;on&lt;/span&gt; &lt;span class="n"&gt;events&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="p"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;18402&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="k"&gt;rows&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;48&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                 &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;actual&lt;/span&gt; &lt;span class="nb"&gt;time&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;091&lt;/span&gt;&lt;span class="p"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;197&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;551&lt;/span&gt; &lt;span class="k"&gt;rows&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;loops&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
               &lt;span class="n"&gt;Filter&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_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;90412&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
               &lt;span class="k"&gt;Rows&lt;/span&gt; &lt;span class="n"&gt;Removed&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="n"&gt;Filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2148773&lt;/span&gt;
               &lt;span class="n"&gt;Buffers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;shared&lt;/span&gt; &lt;span class="k"&gt;read&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;17894&lt;/span&gt;
 &lt;span class="n"&gt;Planning&lt;/span&gt; &lt;span class="nb"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;214&lt;/span&gt; &lt;span class="n"&gt;ms&lt;/span&gt;
 &lt;span class="n"&gt;Execution&lt;/span&gt; &lt;span class="nb"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;199&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;021&lt;/span&gt; &lt;span class="n"&gt;ms&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No index on &lt;code&gt;events.asset_id&lt;/code&gt;. Each call walked 2.1 million rows and read close to 18 thousand buffers off disk to return one row. Thirty-seven times per page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: confirm it is I/O and not compute
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="n"&gt;wait_event_type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wait_event&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pg_stat_activity&lt;/span&gt;
&lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="k"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'active'&lt;/span&gt;
&lt;span class="k"&gt;group&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="k"&gt;order&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="k"&gt;desc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; wait_event_type |   wait_event    | count
-----------------+-----------------+-------
 IO              | DataFileRead    |    17
 Client          | ClientRead      |     4
 LWLock          | BufferMapping   |     2
                 |                 |     1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One backend running, seventeen blocked on reading data files. That is what 12% CPU looks like from the inside.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three things I tried before that, and why they failed
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Connection pool from 20 to 60. The p95 went from around 14 seconds to about 19. More concurrent sequential scans competing for the same disk made it worse, not better.&lt;/li&gt;
&lt;li&gt;A 60 second cache on the dashboard payload. First load still 14 seconds, numbers looked stale to the people who watch them live, and the second screen using the same query shape stayed slow.&lt;/li&gt;
&lt;li&gt;One extra app instance in the load test. Latency moved inside the noise. Four application boxes were already queueing behind a single Postgres primary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Any of the three would have survived the meeting. None moved the number anyone complained about.&lt;/p&gt;

&lt;h2&gt;
  
  
  The change that did
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="k"&gt;index&lt;/span&gt; &lt;span class="n"&gt;concurrently&lt;/span&gt; &lt;span class="n"&gt;events_asset_id_occurred_at_idx&lt;/span&gt;
  &lt;span class="k"&gt;on&lt;/span&gt; &lt;span class="n"&gt;events&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;asset_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;occurred_at&lt;/span&gt; &lt;span class="k"&gt;desc&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then collapsing the 37 round trips into one statement:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;occurred_at&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;assets&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="k"&gt;left&lt;/span&gt; &lt;span class="k"&gt;join&lt;/span&gt; &lt;span class="k"&gt;lateral&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="n"&gt;occurred_at&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;
  &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;events&lt;/span&gt;
  &lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="n"&gt;asset_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;
  &lt;span class="k"&gt;order&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="n"&gt;occurred_at&lt;/span&gt; &lt;span class="k"&gt;desc&lt;/span&gt;
  &lt;span class="k"&gt;limit&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="k"&gt;on&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;
&lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tenant_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same log line after deploy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;route=/dashboard totalMs=871 dbMs=604 queries=4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From 14 seconds to roughly 900 milliseconds, with no change to instance count. CPU on the app boxes rose to around 19%, which was the part I liked most: the machines finally had work to do instead of waiting on a disk.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this does to the capacity question
&lt;/h2&gt;

&lt;p&gt;Utilization answers a different question than the one on the ticket. Concurrency you need is arrival rate multiplied by service time, so service time is the term you can actually negotiate. With 13 seconds of database wait per request, the reservation I was asked to approve would have bought the same 14 second screen at a bigger invoice, and the missing index would still be there when the reserved capacity expired.&lt;/p&gt;

&lt;p&gt;I am not arguing against reserving compute. Scarcity is real and committing early can be the right call. The input to that commitment should be measured service time per endpoint, not a number an engineer feels pressured to say out loud in a planning meeting. Four numbers made the decision here, and all four are a day of work: request time split into app and database, calls ranked by total execution time, one EXPLAIN with BUFFERS, one snapshot of wait events.&lt;/p&gt;

&lt;p&gt;How do you size a reservation when service time is still moving? I would like to know whether you gate instance requests behind a latency breakdown, or reserve first and tune after the invoice lands.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>backend</category>
      <category>performance</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>I asked production which commit it was running: 23 behind main, the oldest waiting 19 days</title>
      <dc:creator>Revin</dc:creator>
      <pubDate>Mon, 05 Oct 2026 16:16:43 +0000</pubDate>
      <link>https://dev.to/revinsoftware/i-asked-production-which-commit-it-was-running-23-behind-main-the-oldest-waiting-19-days-223l</link>
      <guid>https://dev.to/revinsoftware/i-asked-production-which-commit-it-was-running-23-behind-main-the-oldest-waiting-19-days-223l</guid>
      <description>&lt;p&gt;A feature was done. The ticket said done, the pull request had been merged four days earlier, CI was green. The screen did not exist in production.&lt;/p&gt;

&lt;p&gt;Nobody had lied to me. The merge happened, the deploy did not. The workflow that ships that service had been failing on a step nobody watched, and the image actually running in the cluster had been built 19 days before.&lt;/p&gt;

&lt;p&gt;I found that out because I stopped asking the team and asked the process. Below is the measurement, the commands, and the three sources I tried first that told me nothing useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: make the running process say which commit it is
&lt;/h2&gt;

&lt;p&gt;Most services cannot answer "what are you running?". The fix costs about ten minutes and it is the only reading that does not depend on anyone's memory. Bake the SHA in at build time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;ARG&lt;/span&gt;&lt;span class="s"&gt; GIT_SHA&lt;/span&gt;
&lt;span class="k"&gt;ARG&lt;/span&gt;&lt;span class="s"&gt; BUILD_TIME&lt;/span&gt;
&lt;span class="k"&gt;ENV&lt;/span&gt;&lt;span class="s"&gt; GIT_SHA=$GIT_SHA&lt;/span&gt;
&lt;span class="k"&gt;ENV&lt;/span&gt;&lt;span class="s"&gt; BUILD_TIME=$BUILD_TIME&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/routes/version.ts&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/version&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;sha&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GIT_SHA&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;unknown&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;builtAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;BUILD_TIME&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;unknown&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# .github/workflows/deploy.yml&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Build image&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;docker build \&lt;/span&gt;
      &lt;span class="s"&gt;--build-arg GIT_SHA=${{ github.sha }} \&lt;/span&gt;
      &lt;span class="s"&gt;--build-arg BUILD_TIME="$(date -u +%FT%TZ)" \&lt;/span&gt;
      &lt;span class="s"&gt;-t "$IMAGE:${{ github.sha }}" .&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That endpoint is the first thing I add when I get access to a service I did not build. Here is what it answered on the day I am describing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; https://api.internal.example/version | jq
&lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"sha"&lt;/span&gt;: &lt;span class="s2"&gt;"4f1c9ab"&lt;/span&gt;,
  &lt;span class="s2"&gt;"builtAt"&lt;/span&gt;: &lt;span class="s2"&gt;"2026-09-11T02:14:07Z"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The build date was already the whole answer. I ran it on a Tuesday at the end of September.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: measure the gap, not the feeling
&lt;/h2&gt;

&lt;p&gt;With a SHA in hand the rest is plain git. Two numbers come out of it: how many commits sit between production and main, and how long the oldest one has been waiting.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git fetch &lt;span class="nt"&gt;-q&lt;/span&gt; origin
&lt;span class="nv"&gt;$ &lt;/span&gt;git log &lt;span class="nt"&gt;--oneline&lt;/span&gt; 4f1c9ab..origin/main | &lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
23
&lt;span class="nv"&gt;$ &lt;/span&gt;git log &lt;span class="nt"&gt;--format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;%cI 4f1c9ab..origin/main | &lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-1&lt;/span&gt;
2026-09-11T09:33:12+00:00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The commit count is the number people want to put on a slide. The age of the oldest unshipped commit is the one that matters, because it is the actual delay between someone finishing work and anybody outside the team being able to use it.&lt;/p&gt;

&lt;p&gt;To see the whole queue instead of just the worst case:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;DEPLOYED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsS&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BASE_URL&lt;/span&gt;&lt;span class="s2"&gt;/version"&lt;/span&gt; | jq &lt;span class="nt"&gt;-r&lt;/span&gt; .sha&lt;span class="si"&gt;)&lt;/span&gt;
git fetch &lt;span class="nt"&gt;-q&lt;/span&gt; origin
git log &lt;span class="nt"&gt;--format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'%h %cI %s'&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$DEPLOYED&lt;/span&gt;&lt;span class="s2"&gt;..origin/main"&lt;/span&gt; | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; sha ts subject&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nv"&gt;age&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; +%s&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;gdate &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$ts&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; +%s&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="m"&gt;86400&lt;/span&gt; &lt;span class="k"&gt;))&lt;/span&gt;
  &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%-10s %3sd  %s\n'&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$sha&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$age&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$subject&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On macOS that needs &lt;code&gt;gdate&lt;/code&gt; from coreutils, since BSD &lt;code&gt;date&lt;/code&gt; has no &lt;code&gt;-d&lt;/code&gt;. On Linux drop the &lt;code&gt;g&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a19f4c2      1d  fix: null check on invoice pdf
8d02e71      2d  feat: csv export for admin
...
7c3e8b1     19d  chore: bump node to 22
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nineteen days of finished work waiting on a pipeline step. The team's speed was never the problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: the three sources that fooled me first
&lt;/h2&gt;

&lt;p&gt;I did not start with &lt;code&gt;/version&lt;/code&gt;. I started with the places that are supposed to answer this, and each one reported something adjacent to the truth.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The GitHub Deployments API. &lt;code&gt;gh api repos/:owner/:repo/deployments&lt;/code&gt; came back as &lt;code&gt;[]&lt;/code&gt;. The workflow shipped the service for two years and never created a deployment record, so the API that exists exactly for this question had nothing in it.&lt;/li&gt;
&lt;li&gt;The last green run of the deploy workflow. &lt;code&gt;gh run list --workflow deploy.yml --json conclusion,createdAt,headSha --limit 5&lt;/code&gt; showed a success six hours old. The final step of that job was &lt;code&gt;aws ecs update-service&lt;/code&gt; with no &lt;code&gt;--wait&lt;/code&gt;, which means the job succeeded when the API accepted the request. Whether any task came up healthy with the new image was outside the job's knowledge. The pipeline reported what it asked for, not what happened.&lt;/li&gt;
&lt;li&gt;The registry tag. &lt;code&gt;latest&lt;/code&gt; had been pushed three hours earlier. A push is not a rollout, and in this case the rollout had been failing on a readiness probe and silently rolling back.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All three were honest about their own scope. None of them knows what is serving traffic. The running process is the only thing that does.&lt;/p&gt;

&lt;h2&gt;
  
  
  The number I keep after the one-off check
&lt;/h2&gt;

&lt;p&gt;I do not keep the commit count. I keep the queue age, sampled once a day, written somewhere boring:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-euo&lt;/span&gt; pipefail
&lt;span class="nv"&gt;DEPLOYED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsS&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BASE_URL&lt;/span&gt;&lt;span class="s2"&gt;/version"&lt;/span&gt; | jq &lt;span class="nt"&gt;-r&lt;/span&gt; .sha&lt;span class="si"&gt;)&lt;/span&gt;
git fetch &lt;span class="nt"&gt;-q&lt;/span&gt; origin
&lt;span class="nv"&gt;OLDEST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;git log &lt;span class="nt"&gt;--format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;%cI &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$DEPLOYED&lt;/span&gt;&lt;span class="s2"&gt;..origin/main"&lt;/span&gt; | &lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-1&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OLDEST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'deploy_queue_age_days 0'&lt;/span&gt;
  &lt;span class="nb"&gt;exit &lt;/span&gt;0
&lt;span class="k"&gt;fi
&lt;/span&gt;&lt;span class="nv"&gt;NOW&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; +%s&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;THEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OLDEST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; +%s&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"deploy_queue_age_days &lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;NOW &lt;span class="o"&gt;-&lt;/span&gt; THEN&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="m"&gt;86400&lt;/span&gt; &lt;span class="k"&gt;))&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It runs in CI on a schedule and the output goes to the same place as every other gauge. Over the following two weeks the value sat at 0 or 1 on most days, with one spike to 5 that came from a migration everybody had agreed to hold. A spike with a known reason is fine. A spike nobody can explain is the broken deploy step coming back.&lt;/p&gt;

&lt;p&gt;The reason I like this metric over anything derived from tickets: a ticket board records what people said. The &lt;code&gt;/version&lt;/code&gt; endpoint records what the machine is doing. Only one of those changes when a YAML step breaks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this breaks down
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Monorepos. One &lt;code&gt;/version&lt;/code&gt; per service, and the git range has to be scoped by path (&lt;code&gt;git log 4f1c9ab..origin/main -- services/api&lt;/code&gt;), otherwise the count fills up with commits that were never meant to ship with that service.&lt;/li&gt;
&lt;li&gt;Trunk based development with feature flags. Code can be live while the behaviour is off. The gauge goes to 0 and says nothing about flag state, which is a separate measurement I have not solved well.&lt;/li&gt;
&lt;li&gt;Squash and force push on main. If the deployed SHA no longer exists after a rebase, the range query dies with &lt;code&gt;unknown revision or path not in the working tree&lt;/code&gt;. I hit that once and the fix was to tag every deploy (&lt;code&gt;git tag deploy/$(date -u +%Y%m%dT%H%M%S) $SHA &amp;amp;&amp;amp; git push --tags&lt;/code&gt;) so the ancestor survives history rewrites.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It also does not help in the first weeks of something still being discovered. There is nothing in production yet, and asking for this number just creates noise.&lt;/p&gt;

&lt;h2&gt;
  
  
  The part I am still unsure about
&lt;/h2&gt;

&lt;p&gt;My daily sample is cheap and dumb. It tells me the worst case and nothing about distribution, so a queue of one 19 day old commit looks worse than a queue of twelve commits from yesterday, when the second situation is often the more urgent one.&lt;/p&gt;

&lt;p&gt;How do you track what is actually live? Deployments API with real records, a version endpoint like this, image digest comparison against the cluster, something in the service mesh? I am mostly interested in the teams that caught a silently failing rollout and want to know which signal caught it.&lt;/p&gt;

&lt;p&gt;· · ·&lt;/p&gt;

&lt;p&gt;Originally published on the Revin blog: &lt;a href="https://revin.com.br/en/blog/how-to-evaluate-developer-work-without-reading-code" rel="noopener noreferrer"&gt;https://revin.com.br/en/blog/how-to-evaluate-developer-work-without-reading-code&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cicd</category>
      <category>devops</category>
      <category>kubernetes</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>I ran git log on every rule function for 12 months: a shade over 3% of the branches took every change</title>
      <dc:creator>Revin</dc:creator>
      <pubDate>Wed, 30 Sep 2026 15:34:15 +0000</pubDate>
      <link>https://dev.to/revinsoftware/i-ran-git-log-on-every-rule-function-for-12-months-a-shade-over-3-of-the-branches-took-every-1pl0</link>
      <guid>https://dev.to/revinsoftware/i-ran-git-log-on-every-rule-function-for-12-months-a-shade-over-3-of-the-branches-took-every-1pl0</guid>
      <description>&lt;p&gt;Someone gave me read access to a pricing service last month with a question I could not settle by opinion: is it time to buy a rules engine? Node and TypeScript, roughly 40k lines, six files under &lt;code&gt;src/pricing&lt;/code&gt;, three developers in its history and none of them still at the company.&lt;/p&gt;

&lt;p&gt;That question has a canonical version on Software Engineering Stack Exchange, "How can one manage thousands of IF...THEN...ELSE rules?", sitting at 109,657 views, score 218 and 18 answers. Most of those answers argue about which engine to adopt. Almost none of them start where I think you have to start, which is counting.&lt;/p&gt;

&lt;p&gt;Before you move a single rule anywhere, you want one number: of all the branches in that module, how many did a human actually change in the last twelve months? A branch nobody has touched since 2021 costs you nothing in maintenance. It costs you regression risk the moment you move it, and moving it into an engine makes that worse.&lt;/p&gt;

&lt;p&gt;Here is the procedure, in the order I ran it, including the two steps that handed me the wrong answer first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: count the decision points
&lt;/h2&gt;

&lt;p&gt;No AST tooling yet. I wanted a floor, fast, with comments stripped so that a commented-out block would not inflate the number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git ls-files &lt;span class="s1"&gt;'src/pricing/*.ts'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  | xargs &lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  | perl &lt;span class="nt"&gt;-0777&lt;/span&gt; &lt;span class="nt"&gt;-pe&lt;/span&gt; &lt;span class="s1"&gt;'s{/\*.*?\*/}{}gs; s{//.*$}{}gm'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-cE&lt;/span&gt; &lt;span class="s1"&gt;'\b(if|else if|case)\b|\?\?'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1043
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the number that makes people want an engine. It is also the number that tells you the least, because it treats a tax table written in 2019 and never reopened the same as the discount rule that four people argued about in March.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: churn per file, which turned out to be useless
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log &lt;span class="nt"&gt;--since&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'12 months ago'&lt;/span&gt; &lt;span class="nt"&gt;--numstat&lt;/span&gt; &lt;span class="nt"&gt;--format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt; &lt;span class="nt"&gt;--&lt;/span&gt; src/pricing &lt;span class="se"&gt;\&lt;/span&gt;
  | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'NF==3 { c[$3] += $1 + $2 } END { for (f in c) printf "%6d  %s\n", c[f], f }'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   412  src/pricing/discount.ts
   180  src/pricing/coupon.ts
    96  src/pricing/tax.ts
    41  src/pricing/index.ts
    12  src/pricing/freight.ts
     4  src/pricing/types.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So &lt;code&gt;discount.ts&lt;/code&gt; moved a lot. Fine. That file alone holds around 300 of the 1,043 branches. Knowing the file is hot tells you nothing about which twenty lines inside it are hot, and "rewrite discount.ts" is exactly the kind of proposal that eats a quarter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: churn per function
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git log -L :function:file&lt;/code&gt; is the part most people never run. It follows one function through history and prints only the commits that touched it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;file &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;git ls-files &lt;span class="s1"&gt;'src/pricing/*.ts'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-oE&lt;/span&gt; &lt;span class="s1"&gt;'(export )?function [A-Za-z0-9_]+'&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $NF}'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; fn&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
        &lt;/span&gt;&lt;span class="nv"&gt;n&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;git log &lt;span class="nt"&gt;--since&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'12 months ago'&lt;/span&gt; &lt;span class="nt"&gt;--format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;%h &lt;span class="nt"&gt;-L&lt;/span&gt; &lt;span class="s2"&gt;":&lt;/span&gt;&lt;span class="nv"&gt;$fn&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; .&lt;span class="si"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-gt&lt;/span&gt; 0 &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%3d  %s  %s\n'&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$fn&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
      &lt;span class="k"&gt;done
done&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; 14  applyTierDiscount   src/pricing/discount.ts
  9  resolveCoupon       src/pricing/coupon.ts
  7  stackDiscounts      src/pricing/discount.ts
  5  stateTax            src/pricing/tax.ts
  3  roundToCents        src/pricing/index.ts
  ...
 12 functions with at least one commit in 12 months
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Twelve functions out of sixty-one. Then count the branches living inside those twelve, and only those:&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;awk&lt;/span&gt; &lt;span class="s1"&gt;'/function applyTierDiscount/,/^}/'&lt;/span&gt; src/pricing/discount.ts &lt;span class="se"&gt;\&lt;/span&gt;
  | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-cE&lt;/span&gt; &lt;span class="s1"&gt;'\b(if|else if|case)\b'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Summed across the twelve: 34. Out of 1,043. A shade over 3% of the branches absorbed every change the business asked for in a year, and 22 of those 34 sat in three functions.&lt;/p&gt;

&lt;p&gt;That changes the meeting completely. "We have a thousand rules and we need an engine" becomes "we have three functions that people rewrite every other month, and everything else is a frozen table".&lt;/p&gt;

&lt;h2&gt;
  
  
  What did not work
&lt;/h2&gt;

&lt;p&gt;First wrong turn: I started with cyclomatic complexity, because it is the reflex. ESLint's &lt;code&gt;complexity&lt;/code&gt; rule and a run of &lt;code&gt;lizard&lt;/code&gt; both put freight calculation at the top of the list. Freight has not been edited since 2021. Complexity measures how hard something is to read, and I was trying to find out what is expensive to change. Those two lists barely overlapped, and the complexity list would have sent me to refactor the one file nobody ever opens.&lt;/p&gt;

&lt;p&gt;Second wrong turn: &lt;code&gt;git log -L&lt;/code&gt; is not free. It gave up on 11 of the 61 functions, and the reasons were boring. Two files got renamed in a big-bang import and history stops at the rename unless you add &lt;code&gt;--follow&lt;/code&gt;, which &lt;code&gt;-L&lt;/code&gt; does not accept. Several rules are not &lt;code&gt;function&lt;/code&gt; declarations at all, they are arrow functions assigned inside an object literal, and the &lt;code&gt;:name:&lt;/code&gt; matcher does not find them. I counted those by hand off &lt;code&gt;git log -S'ruleName'&lt;/code&gt;. If your codebase is mostly object-literal handlers, budget an afternoon for this step instead of an hour.&lt;/p&gt;

&lt;h2&gt;
  
  
  Freezing the other 1,009
&lt;/h2&gt;

&lt;p&gt;The rules that did not change in a year do not need to be pretty. They need to keep producing the same number after you touch anything nearby. Golden master, built from real traffic with the identifying fields dropped before anything hits the repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;readFileSync&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../src/pricing&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// generated from 90 days of production requests,&lt;/span&gt;
&lt;span class="c1"&gt;// customer and order ids stripped at export time&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cases&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&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="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fixtures/pricing-90d.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;utf8&lt;/span&gt;&lt;span class="dl"&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;as&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;chargedCents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pricing characterization&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cases&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;]))(&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;case %i still charges what production charged&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;price&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chargedCents&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These tests are not there to say the rules are correct. They are there to say the rules are unchanged, which is the only property anyone can defend about a branch written by someone who left in 2022. About two thirds of the 1,043 branches were reachable from 90 days of traffic. The rest I left alone and documented as unreachable, which is its own finding.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the 34 went
&lt;/h2&gt;

&lt;p&gt;The three hot functions went behind a versioned configuration table with an effective date, so a tier change becomes a row and not a deploy. The other nine stayed in code, because each one changed once or twice in the year and every one of them calls something else in the service. Pulling them into an engine would buy a round trip and a second place to look during an incident.&lt;/p&gt;

&lt;p&gt;Nobody bought a rules engine. If the count had come back with 300 live branches instead of 34, I would have argued the other way, and the count is what makes that argument checkable instead of a preference.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I am still unsure about
&lt;/h2&gt;

&lt;p&gt;Twelve months is an arbitrary window, and in a service with heavy seasonality it is probably wrong. I also do not know how this holds up in a repo where a formatter or a lint migration rewrote every file at once, since &lt;code&gt;-L&lt;/code&gt; would light up like a Christmas tree and the churn signal dies.&lt;/p&gt;

&lt;p&gt;If you have taken a big if/else pile apart: what did you measure before deciding, and did the measurement survive contact with the people who wanted the engine anyway?&lt;/p&gt;

&lt;p&gt;· · ·&lt;/p&gt;

&lt;p&gt;Originally published on the Revin blog: &lt;a href="https://revin.com.br/en/blog/thousands-if-then-else-rules-code-engine-spreadsheet" rel="noopener noreferrer"&gt;https://revin.com.br/en/blog/thousands-if-then-else-rules-code-engine-spreadsheet&lt;/a&gt;&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>codequality</category>
      <category>git</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>An OpenAI model went looking for exposed API keys in testing. I assume my coding agent will too</title>
      <dc:creator>Revin</dc:creator>
      <pubDate>Fri, 18 Sep 2026 14:42:10 +0000</pubDate>
      <link>https://dev.to/revinsoftware/an-openai-model-went-looking-for-exposed-api-keys-in-testing-i-assume-my-coding-agent-will-too-3k8o</link>
      <guid>https://dev.to/revinsoftware/an-openai-model-went-looking-for-exposed-api-keys-in-testing-i-assume-my-coding-agent-will-too-3k8o</guid>
      <description>&lt;p&gt;CIO reported today that OpenAI published six new reports on model misalignment under a new reporting framework. The cases come from internal evaluations and describe models acting beyond the constraints they were given: hidden instructions, unauthorized communication with external services, modified intermediate outputs, shared environments used in ways nobody planned. One of them is an attempt to locate exposed API keys. OpenAI called the behavior "unexpected or concerning".&lt;/p&gt;

&lt;p&gt;Most reactions treat this as news about OpenAI. I read it as a spec sheet for the thing running in my terminal. A coding agent with shell access has the same shape as the models in those reports: a goal, a set of tools and a filesystem. If a key sits within reach and the task gets easier with it, using the key is just another path to finishing the task. No intent is required for that to happen.&lt;/p&gt;

&lt;p&gt;So I stopped asking whether my agent would open &lt;code&gt;.env&lt;/code&gt;. I assume it will, and I set things up so that opening it finds nothing worth having.&lt;/p&gt;

&lt;h2&gt;
  
  
  The mental model: a contractor on day one
&lt;/h2&gt;

&lt;p&gt;A new contractor gets the access their task needs, for as long as the task lasts, and someone keeps a record of what they touched. Nobody hands them the master key because they seem careful. That is the frame I use for agents, and it breaks down into four questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What can it read right now?&lt;/li&gt;
&lt;li&gt;Where do the secrets live, and can they leave the workspace?&lt;/li&gt;
&lt;li&gt;Which token does it hold, and what can that token do?&lt;/li&gt;
&lt;li&gt;Is there a record of what it ran?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. Find what the agent can read
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;.gitignore&lt;/code&gt; protects your git history. It does nothing against a process that opens files, and the working directory is exactly where the &lt;code&gt;.env&lt;/code&gt; lives.&lt;/p&gt;

&lt;p&gt;Start with the files git ignores but that are sitting on disk:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# ignored by git, readable by anything running in this directory&lt;/span&gt;
git ls-files &lt;span class="nt"&gt;--others&lt;/span&gt; &lt;span class="nt"&gt;--ignored&lt;/span&gt; &lt;span class="nt"&gt;--exclude-standard&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-iE&lt;/span&gt; &lt;span class="s1"&gt;'\.env|secret|credential|\.pem$|\.key$'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then look at what the agent inherits without reading any file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# names only, never print the values&lt;/span&gt;
&lt;span class="nb"&gt;env&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-iE&lt;/span&gt; &lt;span class="s1"&gt;'key|token|secret|password'&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;-f1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second command matters more than people expect. Agents usually inherit the shell you launched them from. If you exported &lt;code&gt;OPENAI_API_KEY&lt;/code&gt; or &lt;code&gt;AWS_SECRET_ACCESS_KEY&lt;/code&gt; in your profile months ago, the agent has it already.&lt;/p&gt;

&lt;p&gt;Last, scan contents, history included:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gitleaks &lt;span class="nb"&gt;dir&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;--redact&lt;/span&gt; &lt;span class="nt"&gt;--no-banner&lt;/span&gt;
gitleaks git &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;--redact&lt;/span&gt; &lt;span class="nt"&gt;--no-banner&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A key that was committed once and deleted later still lives in &lt;code&gt;git log -p&lt;/code&gt;. An agent asked to find out why something broke in March will read that history.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Move secrets out of the workspace
&lt;/h2&gt;

&lt;p&gt;The tempting first fix is telling the agent to ignore &lt;code&gt;.env&lt;/code&gt;, through its ignore file or a line in the instructions. That is a request. The models in the OpenAI reports were operating under instructions too.&lt;/p&gt;

&lt;p&gt;What holds is the secret not being on disk. Replace the file with references that a secret manager resolves at runtime. With the 1Password CLI, the template looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# .env.tpl (safe to commit, safe for the agent to read)&lt;/span&gt;
&lt;span class="nv"&gt;DATABASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;op://dev/app-db/url
&lt;span class="nv"&gt;STRIPE_SECRET_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;op://dev/stripe-test/secret
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;op run &lt;span class="nt"&gt;--env-file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;.env.tpl &lt;span class="nt"&gt;--&lt;/span&gt; npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent can read &lt;code&gt;.env.tpl&lt;/code&gt; all day and it will see vault paths. Doppler, Infisical and the cloud secret managers do the same job with different syntax, so pick whichever your team already pays for.&lt;/p&gt;

&lt;p&gt;One catch I don't have a clean answer for: if the agent's shell can call &lt;code&gt;op run&lt;/code&gt; with your unlocked session, the values are one command away. I start the agent from a shell where the secret manager is not signed in and run the app from a different one. It is clunky, and I'd like to hear a better arrangement.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Its own token, with the smallest scope
&lt;/h2&gt;

&lt;p&gt;When the agent needs credentials, to push a branch or read an issue, it gets its own and never yours. On GitHub that means a fine-grained personal access token limited to one repository, contents read and write, pull requests write, nothing under administration, expiring in days instead of a year.&lt;/p&gt;

&lt;p&gt;Then run the agent where that token is the only thing in the environment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PWD&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;:/work &lt;span class="nt"&gt;-w&lt;/span&gt; /work &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--env-file&lt;/span&gt; agent.env &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--network&lt;/span&gt; agent-net &lt;span class="se"&gt;\&lt;/span&gt;
  agent-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;agent.env&lt;/code&gt; has exactly one line. The container sees the repo and nothing from your home directory: no &lt;code&gt;~/.aws&lt;/code&gt;, no &lt;code&gt;~/.ssh&lt;/code&gt;, no shell history with a token someone pasted once. If you can route &lt;code&gt;agent-net&lt;/code&gt; through a proxy that logs hostnames, do it. Interacting with external services was one of the behaviors in the reports, and outbound traffic is where you would see it.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Log every command it runs
&lt;/h2&gt;

&lt;p&gt;When something odd happens, the first question is what the agent executed. Most agents now expose hooks around tool calls. In Claude Code, a &lt;code&gt;PreToolUse&lt;/code&gt; hook on &lt;code&gt;Bash&lt;/code&gt; receives the command as JSON on stdin, and exit code 2 blocks it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# ~/.claude/hooks/audit-bash.sh&lt;/span&gt;
&lt;span class="nv"&gt;input&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;cmd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;jq &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'.tool_input.command // empty'&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$input&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%s\t%s\n'&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; +%FT%TZ&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$cmd&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.agent-audit.log"&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-qE&lt;/span&gt; &lt;span class="s1"&gt;'(\.env|id_rsa|\.aws/credentials)'&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$cmd&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"blocked: command touches a secret path"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
  &lt;span class="nb"&gt;exit &lt;/span&gt;2
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"PreToolUse"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Bash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"~/.claude/hooks/audit-bash.sh"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Be honest about the block. It is a speed bump. &lt;code&gt;cat .e""nv&lt;/code&gt; walks right past that regex, and so does a Python one-liner. I keep it because it turns the obvious attempts into a line I will notice. The log is the part that earns its keep: a plain text file with timestamps that I can grep after a long session.&lt;/p&gt;

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

&lt;p&gt;Two recommendations I keep seeing and don't think pay off. Asking the agent in the system prompt to never touch credentials costs nothing and guarantees nothing. The reports are, quite literally, about models acting past stated constraints. And rotating every key after every session sounds disciplined, but nobody keeps it up for more than a week. Short expiry and narrow scope do the same job without depending on someone remembering.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the reports don't settle
&lt;/h2&gt;

&lt;p&gt;These were OpenAI's internal evaluations, designed to surface this kind of behavior. I don't know how often a coding agent on an ordinary Tuesday task goes near a credentials file, and I would distrust anyone who gave me a precise number. What I do know is the price on each side: the setup above takes an afternoon, and being wrong means a production key that someone else finds before you do.&lt;/p&gt;

&lt;p&gt;Security as a habit looks boring up close. The file that isn't there, the token that expires, the log nobody reads until the day it matters.&lt;/p&gt;

&lt;p&gt;How are you keeping coding agents away from secrets today? Container, separate OS user, a remote dev box, or trust plus a good &lt;code&gt;.gitignore&lt;/code&gt;?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>I summed CPU time by user agent for 7 days: 63% went to clients that never load a second page</title>
      <dc:creator>Revin</dc:creator>
      <pubDate>Wed, 09 Sep 2026 15:00:57 +0000</pubDate>
      <link>https://dev.to/revinsoftware/i-summed-cpu-time-by-user-agent-for-7-days-63-went-to-clients-that-never-load-a-second-page-3dog</link>
      <guid>https://dev.to/revinsoftware/i-summed-cpu-time-by-user-agent-for-7-days-63-went-to-clients-that-never-load-a-second-page-3dog</guid>
      <description>&lt;p&gt;The invoice went up around 38% in one quarter and the meeting already had a culprit: the AI feature that shipped in April. Two more instances were on the table. Before approving them, I asked for something cheaper than a server, which was read access to seven days of access logs.&lt;/p&gt;

&lt;p&gt;The answer took an afternoon. About 63% of the summed backend time in that week went to clients that arrived with a Chrome user agent, requested only HTML, never fetched a single stylesheet, and never came back to the same address twice.&lt;/p&gt;

&lt;p&gt;Here is exactly what I ran, including the two things that did not work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Your log format is probably missing the only field that matters
&lt;/h2&gt;

&lt;p&gt;Most nginx setups still run the default &lt;code&gt;combined&lt;/code&gt; format, which gives you status, bytes and user agent. It does not give you time. Without time you can only count hits, and hit count is the metric that hides this problem, because the cheap route wins on volume and the expensive one hides at the bottom of the list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="k"&gt;log_format&lt;/span&gt; &lt;span class="s"&gt;timed&lt;/span&gt; &lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="nv"&gt;$remote_addr&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="nv"&gt;$status&lt;/span&gt; &lt;span class="s"&gt;'&lt;/span&gt;
                 &lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="nv"&gt;$body_bytes_sent&lt;/span&gt; &lt;span class="nv"&gt;$request_time&lt;/span&gt; &lt;span class="nv"&gt;$upstream_response_time&lt;/span&gt; &lt;span class="s"&gt;'&lt;/span&gt;
                 &lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="nv"&gt;$upstream_cache_status&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$http_user_agent&lt;/span&gt;&lt;span class="s"&gt;"'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;access_log&lt;/span&gt; &lt;span class="n"&gt;/var/log/nginx/access.log&lt;/span&gt; &lt;span class="s"&gt;timed&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One reload and you start collecting. Everything below assumes that format.&lt;/p&gt;

&lt;h2&gt;
  
  
  First pass: classify by user agent, and watch it fail
&lt;/h2&gt;

&lt;p&gt;The obvious first cut is by declared identity.&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;awk&lt;/span&gt; &lt;span class="nt"&gt;-F&lt;/span&gt;&lt;span class="s1"&gt;'"'&lt;/span&gt; &lt;span class="s1"&gt;'
{
  split($3, m, " ")
  ua = tolower($4)
  if (ua ~ /bot|crawl|spider|slurp/) k = "declared-bot"
  else if (ua ~ /mozilla\/5\.0/)     k = "browser-ua"
  else                               k = "other"
  hits[k]++; secs[k] += m[4]
}
END { for (k in hits) printf "%-13s %9d hits %11.1f s\n", k, hits[k], secs[k] }
'&lt;/span&gt; access.log-2026090&lt;span class="k"&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;declared-bot     412918 hits     38140.6 s
browser-ua      9130477 hits    201773.4 s
other            286042 hits     11962.0 s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read that and you conclude the declared bots cost you about 15% of the time and the rest is customers. That conclusion is wrong, and it is the reason most teams stop here and buy the instance. A browser user agent is a string. Anyone can send it, and large scale collection stopped identifying itself a while ago.&lt;/p&gt;

&lt;h2&gt;
  
  
  Second pass: classify by behaviour instead
&lt;/h2&gt;

&lt;p&gt;A browser that renders a page also asks for the CSS, the JS bundle, the fonts and a few images. A collector asks for the HTML and leaves. That difference is in the log already, and it does not require a new tool.&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;awk&lt;/span&gt; &lt;span class="nt"&gt;-F&lt;/span&gt;&lt;span class="s1"&gt;'"'&lt;/span&gt; &lt;span class="s1"&gt;'
{
  ip = $1; sub(/ .*/, "", ip)
  split($2, r, " "); u = r[2]
  split($3, m, " ")
  if (u ~ /\.(css|js|woff2?|png|svg|jpg|ico)(\?|$)/) asset[ip]++; else page[ip]++
  secs[ip] += m[4]
}
END {
  for (i in page)
    if (page[i] &amp;gt; 50 &amp;amp;&amp;amp; asset[i] / page[i] &amp;lt; 0.1)
      printf "%-15s %7d pages %6d assets %9.1f s\n", i, page[i], asset[i], secs[i]
}
'&lt;/span&gt; access.log-2026090&lt;span class="k"&gt;*&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-k6&lt;/span&gt; &lt;span class="nt"&gt;-nr&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;198.51.100.24      41207 pages     18   14822.9 s
203.0.113.91       28644 pages      0   10310.4 s
198.51.100.77      19855 pages      3    7412.0 s
203.0.113.140      12038 pages      0    4488.7 s
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sum that bucket against the total and you get the number from the title. In this system it came out at 63.4% of all backend seconds in the week. None of those addresses appeared in more than a couple of hundred requests each, because the ranges rotate. There was no name to block, which is the part that makes the usual answer useless.&lt;/p&gt;

&lt;h2&gt;
  
  
  Third pass: the twenty most expensive routes, by time and not by hits
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-F&lt;/span&gt;&lt;span class="s1"&gt;'"'&lt;/span&gt; &lt;span class="s1"&gt;'
{
  split($2, r, " "); u = r[2]; sub(/\?.*/, "", u)
  split($3, m, " ")
  secs[u] += m[4]; n[u]++
  if (m[5] == "HIT") hit[u]++
}
END { for (u in secs) printf "%10.1f s %9d %6.1f%% %s\n", secs[u], n[u], 100 * hit[u] / n[u], u }
'&lt;/span&gt; access.log-2026090&lt;span class="k"&gt;*&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-nr&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   61402.8 s     67341    1.8% /reports/export
   38915.3 s    204882    0.4% /catalog
   22107.6 s     91120   11.2% /calendar/day
    9044.1 s   1980433   96.7% /api/session
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The route with 1.9 million hits was the cheapest thing on the list. The one costing the most ran 67 thousand times at roughly 900 ms each, with a cache hit rate under 2%, because every request carried a different date range in the query string. Every filter combination that became a public address is a page that is generated once, served once, and cached for nobody.&lt;/p&gt;

&lt;h2&gt;
  
  
  The two things that did not work
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;robots.txt&lt;/code&gt;. Whoever respects it was already respecting it, and the traffic in that top bucket does not read it. Adding rules there changed nothing measurable in the following week.&lt;/li&gt;
&lt;li&gt;Blocking inside the application. The first attempt was a middleware that inspected the request and returned 403. In that stack the session middleware ran first, so by the time the rule said no, the request had already checked out a database connection. A 403 from the app measured around 34 ms and held a pool slot. The same 403 from nginx measured 0.4 ms. Saying no is not free, and where you say it is worth roughly two orders of magnitude.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So the deny moved to the edge, per range rather than per address, since single IPs rotate too fast to matter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="k"&gt;limit_req_zone&lt;/span&gt; &lt;span class="nv"&gt;$binary_remote_addr&lt;/span&gt; &lt;span class="s"&gt;zone=perip:16m&lt;/span&gt; &lt;span class="s"&gt;rate=3r/s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;location&lt;/span&gt; &lt;span class="n"&gt;/catalog&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;limit_req&lt;/span&gt;  &lt;span class="s"&gt;zone=perip&lt;/span&gt; &lt;span class="s"&gt;burst=10&lt;/span&gt; &lt;span class="s"&gt;nodelay&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;limit_req_status&lt;/span&gt; &lt;span class="mi"&gt;429&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;Honest limit on that one: rate limiting by range punishes offices behind NAT, and I have no clean answer for telling those two apart at the edge.&lt;/p&gt;

&lt;h2&gt;
  
  
  What actually moved the number
&lt;/h2&gt;

&lt;p&gt;The expensive route got a cheap variant for anything that had not requested an asset in the same connection window: same content, none of the aggregation queries that build the side panels. Query count per render went from 41 to 3. The cache key dropped the tracking parameters and the TTL went up on pages born from parameter combinations, which changed little between requests anyway. Filter combinations left the index, with canonical pointing at the unfiltered version. Two weeks later, summed upstream time was down about 44% with no new instance, and p95 improved on the routes humans actually use.&lt;/p&gt;

&lt;h2&gt;
  
  
  This is not a niche problem, and it is worse on public code hosting
&lt;/h2&gt;

&lt;p&gt;While I was writing this up, Konstantin Ryabitsev, who runs kernel.org infrastructure, reported that git.kernel.org burns more CPU rendering commits as HTML for scrapers than it spends on every other kind of legitimate access combined, git clones included. Across five geo distributed nodes, fourteen cores are doing nothing else at any given moment. Simon Willison published the account and it landed on Hacker News.&lt;/p&gt;

&lt;p&gt;A git web frontend is the extreme version of the shape: commits times files times views, diff, blame, raw, tree, an address space that grows by multiplication. A person opens the same handful of those. A crawler opens all of them, once each, which defeats caching by design, because for every address the crawler request is both the first and the last.&lt;/p&gt;

&lt;p&gt;One thing the log does not answer. It will not tell you whether the collector eating your CPU feeds something that sends you users. Behaviour separates robots from humans, not wanted from unwanted, and that second call is not an infrastructure call.&lt;/p&gt;

&lt;p&gt;So, two questions for people who have been through this. How do you separate the crawlers you want from the ones you do not, when both arrive with a Chrome user agent from residential ranges? And has anyone found a rate limit granularity that survives corporate NAT without whitelisting by hand?&lt;/p&gt;

&lt;p&gt;Originally published on the Revin blog: &lt;a href="https://revin.com.br/en/blog/scraper-traffic-cloud-bill" rel="noopener noreferrer"&gt;https://revin.com.br/en/blog/scraper-traffic-cloud-bill&lt;/a&gt;&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>backend</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
