<?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: Jeremy Longshore</title>
    <description>The latest articles on DEV Community by Jeremy Longshore (@jeremy_longshore).</description>
    <link>https://dev.to/jeremy_longshore</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%2F3842419%2Ff5d02b54-daf0-4520-9aef-118fbd0c24ac.jpeg</url>
      <title>DEV Community: Jeremy Longshore</title>
      <link>https://dev.to/jeremy_longshore</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jeremy_longshore"/>
    <language>en</language>
    <item>
      <title>Versioned Scoring Rules for a Reproducible Published Index</title>
      <dc:creator>Jeremy Longshore</dc:creator>
      <pubDate>Mon, 23 Nov 2026 11:30:17 +0000</pubDate>
      <link>https://dev.to/jeremy_longshore/versioned-scoring-rules-for-a-reproducible-published-index-2ngm</link>
      <guid>https://dev.to/jeremy_longshore/versioned-scoring-rules-for-a-reproducible-published-index-2ngm</guid>
      <description>&lt;p&gt;If you publish a scored dataset every day, the scoring rule will change, and the first rerun after that change can quietly rewrite every date you already published. This is how I restructured a daily token price index so rules can change without touching history: keep the raw facts (facets, the attributes each seller reports about itself), version the rules as entries identified by a hash of their content, pin each date to the rulebook in force that day, and refuse overwrites.&lt;/p&gt;

&lt;p&gt;The dataset is STCI (the Standardized Token Cost Index), a daily index of what open-weight models (models whose weights anyone can download and host) cost per token across providers. It was first built in one day, as &lt;a href="https://startaitools.com/posts/stci-zero-to-v010-token-cost-index/" rel="noopener noreferrer"&gt;STCI Zero to v0.1.0&lt;/a&gt;. Each published day carries a verification hash, which makes the file tamper-evident: anyone can check that it has not been altered. That hash is the thing a careless rule change breaks.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem: a stored grade freezes yesterday's rule into the data
&lt;/h2&gt;

&lt;p&gt;The previous day's data showed one open-weight model priced 16.08x apart across endpoints (separately priced deployments of the same model). The spread record is in &lt;a href="https://startaitools.com/posts/same-model-different-price-open-weight-spread/" rel="noopener noreferrer"&gt;the 16.08x post&lt;/a&gt;. The obvious follow-up question was whether the cheap endpoints are cheap because they serve a lower precision (fewer bits per model weight). The first plan was to grade each endpoint A, B or C from the precision the provider reports, and write that grade into the daily file.&lt;/p&gt;

&lt;p&gt;Two read-only plan reviews (an ML review and a data-model review) rejected that plan before any code was written. Their reasons are the core of this post.&lt;/p&gt;

&lt;p&gt;The ML review attacked the input. Between 30 and 40 percent of endpoints report precision as the literal string &lt;code&gt;unknown&lt;/code&gt;. On the flagship example it was 19 of 50. Folding those into "Grade C" grades reporting hygiene, not tokens. The precision ladder is also wrong per model: fp8 is the native release precision for DeepSeek, gpt-oss ships mxfp4, and Kimi K2 ships int4. A rule like "fp8 means B" would penalize models for shipping exactly as their authors released them.&lt;/p&gt;

&lt;p&gt;The data-model review attacked the storage. A grade written at collection time is a frozen copy of whatever rule existed that morning. When the rule changes, you cannot recompute old grades, because the facts that produced them were thrown away. Your only options are to leave stale verdicts in place or to rewrite history.&lt;/p&gt;

&lt;p&gt;So the methodology doc now opens with one line: STCI measures; it does not judge.&lt;/p&gt;

&lt;h2&gt;
  
  
  The approach: four changes in methodology 2.1.0
&lt;/h2&gt;

&lt;p&gt;Methodology 2.1.0 shipped with four pieces. Each one closes a specific failure.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. A private, hashed snapshot of the raw facts
&lt;/h3&gt;

&lt;p&gt;For every model that clears the endpoint minimum, the collector keeps one row per priced endpoint: model id, provider, tag, quantization, context length, max completion tokens, sorted supported parameters, and the three prices as the source's own strings. Rows are written as canonical JSON (sorted keys, no spaces) to a private, git-ignored file per date. The file is never published. Its SHA-256 is.&lt;/p&gt;

&lt;p&gt;That split matters. The raw rows stay available for re-derivation. The public file commits to them through &lt;code&gt;endpoint_snapshot_sha256&lt;/code&gt;, so a later rerun can prove it started from the same facts.&lt;/p&gt;

&lt;p&gt;Uptime, throughput and latency move minute to minute, so they live in a separate &lt;code&gt;observed&lt;/code&gt; block that no hash covers and the public site never shows. If they were hashed, two honest runs a minute apart would disagree.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Facet cells instead of verdicts
&lt;/h3&gt;

&lt;p&gt;Per model, endpoints are cut into cells by three facets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;precision&lt;/strong&gt; as reported, with missing or &lt;code&gt;unknown&lt;/code&gt; as its own &lt;code&gt;undisclosed&lt;/code&gt; bucket, never folded into a named precision&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;context bucket&lt;/strong&gt;: &lt;code&gt;&amp;lt;=32k&lt;/code&gt;, &lt;code&gt;32-128k&lt;/code&gt;, &lt;code&gt;128k+&lt;/code&gt;, &lt;code&gt;1M+&lt;/code&gt;, or &lt;code&gt;unknown&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;tools&lt;/strong&gt;: true when the endpoint's supported parameters include &lt;code&gt;tools&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each cell reports &lt;code&gt;n&lt;/code&gt;, min, p25, median, p75, max and the p75/p25 ratio of the blended price. Below three endpoints the statistics are null and &lt;code&gt;n&lt;/code&gt; is still reported. A dated snapshot id such as a &lt;code&gt;-1017&lt;/code&gt; suffix is a different model from the undated id and is never pooled with it.&lt;/p&gt;

&lt;p&gt;None of this is a judgment. It is what the endpoints say about themselves, cut so a reader can compare like with like.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Rules as append-only, content-hashed entries
&lt;/h3&gt;

&lt;p&gt;Rules live in one append-only YAML file. As shipped, it holds a single entry:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;effective_from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-20"&lt;/span&gt;
    &lt;span class="na"&gt;view&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;disclosed_vs_undisclosed_precision&lt;/span&gt;
    &lt;span class="c1"&gt;# Precision values that count as undisclosed. Everything else a provider
&lt;/span&gt;    &lt;span class="c1"&gt;# reports (fp8, fp4, mxfp4, nvfp4, int4, bf16, fp16, ...) is disclosed.
&lt;/span&gt;    &lt;span class="na"&gt;undisclosed_values&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;undisclosed&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The entry is dated 2026-11-20, but a rule only enters the output from methodology 2.1.0, whose first date is 2026-11-21. The 2026-11-20 index itself runs under 2.0.0 and carries no rule id.&lt;/p&gt;

&lt;p&gt;There are no A/B/C grades in it. The only view is disclosed versus undisclosed precision, published per model as a pair of counts. The id of a rule is never typed by hand. It is computed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;canonical_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sort_keys&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;separators&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;","&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;rule_id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rule&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""SHA-256 over the canonical content of a rule (any rule_id key ignored)."""&lt;/span&gt;
    &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"rule_id"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;canonical_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The consequence is the point. Editing an entry changes its id. A published file that names a &lt;code&gt;rule_id&lt;/code&gt; can always be checked against the rules file, and a quietly edited rule shows up as a different id instead of passing as the old one. A test pins it: change &lt;code&gt;undisclosed_values&lt;/code&gt; to include &lt;code&gt;fp8&lt;/code&gt; and the id must differ.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. A verification hash that covers the new inputs, version-gated
&lt;/h3&gt;

&lt;p&gt;The verification hash keeps its 16-hex-character convention. For 2.1.0 and later it additionally covers the snapshot digest, the &lt;code&gt;rule_id&lt;/code&gt; in force, and the canonical spread output with every &lt;code&gt;observed&lt;/code&gt; block removed. For 2.0.0 dates the hash input is unchanged, so the recipe stays backward compatible and published hashes still verify. When the private snapshot file is present, the pipeline re-hashes it and refuses to run on a mismatch with the digest recorded in the spread file.&lt;/p&gt;

&lt;p&gt;That was the implementation that went up for review: 110 tests passing, 85 existing plus 25 new, including planted-fault tests for pooling dated with undated snapshots, folding unknown precision into a named one, an unhashed price change, and determinism.&lt;/p&gt;

&lt;h2&gt;
  
  
  What broke: the rerun that would have rewritten history
&lt;/h2&gt;

&lt;p&gt;The work ran through subagents. A Claude Opus 5.5 session orchestrated; a python-pro subagent implemented; a code-reviewer subagent reviewed the pull request. The reviewer reported a critical bug minutes after dispatch.&lt;/p&gt;

&lt;p&gt;The version gate in part 4 decided which hash recipe to use from the methodology version. But the pipeline always loaded the current methodology file. A forced rerun of 2026-11-19, a date already published under 2.0.0, would have loaded 2.1.0, taken the new hash path, and rewritten the published file with a new hash. Every reader holding the old hash would see a tampered file. The suite was green anyway: the end-to-end rerun test for an old date arrived only with the fix.&lt;/p&gt;

&lt;p&gt;This is the failure the whole design exists to prevent, and the first version still had it. Versioned rules are not enough if the code picks the rulebook by "whatever is current."&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: resolve the rulebook per date, then refuse overwrites
&lt;/h2&gt;

&lt;p&gt;The findings went back to the implementer. Two structural changes landed. First, a resolver maps each date to the rulebook that governed it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;ARCHIVED_RULEBOOKS&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="s2"&gt;"1.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"2026-03-06"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;# dates up to and including&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"2.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-20"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;resolve_methodology_path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target_date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data_dir&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="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;fixtures&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data_dir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="s2"&gt;"fixtures"&lt;/span&gt;
    &lt;span class="n"&gt;iso&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;target_date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isoformat&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;version&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;last_day&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;ARCHIVED_RULEBOOKS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;archived&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fixtures&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"methodology-{version}.yaml"&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;iso&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;last_day&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;archived&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exists&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;if&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"2.0.0"&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;iso&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-19"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;  &lt;span class="c1"&gt;# the gap before 2.0.0 started is not 2.0.0's&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;archived&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fixtures&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="s2"&gt;"methodology.yaml"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The resolver now drives the indexing pipeline, the index computation and the spread CLI. The methodology version comes from the resolved file, and facets, snapshot and rule id are skipped entirely before 2.1.0. Dates through 2026-03-06 resolve to 1.0.0, 2026-11-19 and 2026-11-20 to 2.0.0, and 2026-11-21 onward to the current 2.1.0 file. No index was published between 2026-03-07 and 2026-11-18, so the resolver sends those dates to the current file.&lt;/p&gt;

&lt;p&gt;Second, a guard for the case where someone forces a rulebook anyway:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_refuse_rulebook_change&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target_date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Never overwrite a published index computed under a different methodology."""&lt;/span&gt;
    &lt;span class="n"&gt;existing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data_dir&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="s2"&gt;"indices"&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{target_date}.json"&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;existing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exists&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;published&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;existing&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="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"methodology_version"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;resolved&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;indexer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;methodology&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"methodology_version"&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;published&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;published&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;resolved&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{existing} was published under methodology {published}, but {resolved} "&lt;/span&gt;
            &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"resolves for {target_date}; refusing to overwrite it"&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The resolver is the normal path. The guard is the backstop. A test constructs a pipeline with an explicit path to the 2.1.0 file, points it at a date published under 2.0.0, and asserts the run raises "refusing to overwrite". The same test then confirms the resolved pipeline runs fine.&lt;/p&gt;

&lt;p&gt;The test that would have caught the original bug now exists too. It runs the full pipeline on 2026-11-19 and asserts three things: the version is 2.0.0, neither &lt;code&gt;rule_id&lt;/code&gt; nor &lt;code&gt;endpoint_snapshot_sha256&lt;/code&gt; appears in the output, and the hash equals a golden value built from the 2.0.0 path before facets existed. It checks both with and without a spread file. The review fix also made the snapshot sort total (sorted canonical lines), made the digest-mismatch error name the file and the fix, and moved &lt;code&gt;observed&lt;/code&gt; out of the committed spread file into a git-ignored one. The suite went from 110 to 125.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not just store the grade and add a version column?
&lt;/h2&gt;

&lt;p&gt;It is the obvious approach. Store &lt;code&gt;grade = "B"&lt;/code&gt; plus &lt;code&gt;rule_version = 3&lt;/code&gt;, and when the rule changes, write new grades going forward.&lt;/p&gt;

&lt;p&gt;It fails the first time someone asks what an old date would score under the new rule. The facts that produced the old grade are gone, so the answer is unknowable. It also does nothing about the precision problem: a hypothetical "B" from the rejected plan for an fp8 DeepSeek endpoint would carry a judgment the reviews already showed was wrong, with no way to recompute it. And a version column is a label you trust, while a content-hashed &lt;code&gt;rule_id&lt;/code&gt; is a claim you can check. The same argument, applied to pipeline receipts, is in &lt;a href="https://startaitools.com/posts/stop-trusting-the-stored-claim/" rel="noopener noreferrer"&gt;when a gate should re-run the step instead of trusting its receipt&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Facets plus rule ids cost a private snapshot file and one more digest in the hash input. In exchange, a grade becomes a pure function over retained facts and a named rule, and old dates stay verifiable forever.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Store the grade plus a version column&lt;/th&gt;
&lt;th&gt;Store facets plus a content-hashed rule_id&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;What is written at collection time&lt;/td&gt;
&lt;td&gt;A grade such as "B" plus a rule_version number&lt;/td&gt;
&lt;td&gt;Raw endpoint facets in a private snapshot whose SHA-256 is published&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can an old date be re-scored under a new rule?&lt;/td&gt;
&lt;td&gt;No. The facts that produced the grade are gone&lt;/td&gt;
&lt;td&gt;Yes. The grade is a pure function of retained facts and a named rule&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What the version means&lt;/td&gt;
&lt;td&gt;A label you have to trust&lt;/td&gt;
&lt;td&gt;A claim you can check against the rules file&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Grades may still arrive. The plan sets the bar: an audited test that sends the same prompts through reference-precision and fp4 or undisclosed endpoints. That test has not been run. Until it is, the public site shows what the facets support, rows like "fp8 from $0.24 / fp4 from $0.12 / precision undisclosed from $0.20", next to the honest counterpoint that OpenRouter's 2026-11-11 test found no clear accuracy gap between fp16, fp8 and fp4 on one model. Methodology 2.1.0 first applies to 2026-11-21 data.&lt;/p&gt;

&lt;p&gt;The full rules live in 000-docs (the repo's numbered folder of dated records) as the &lt;a href="https://github.com/jeremylongshore/stci-standard-inference-token-cost-index/blob/main/000-docs/022-DR-STND-stci-methodology-2-1-facets.md" rel="noopener noreferrer"&gt;methodology 2.1.0 facets doc&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Also shipped
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The public site now renders per-precision "from" prices per spread row, falling back to the cheapest endpoint's precision for 2.0.0 files.&lt;/li&gt;
&lt;li&gt;The site gained a methodology section titled "What a grade is and is not".&lt;/li&gt;
&lt;li&gt;The publish script allow-lists the published keys and refuses any document containing per-endpoint fields. See &lt;a href="https://startaitools.com/posts/publish-derived-data-from-an-allow-list/" rel="noopener noreferrer"&gt;how that allow-list publishing works&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;New JSON schema for the spread file, including the additive &lt;code&gt;rule_id&lt;/code&gt; and &lt;code&gt;endpoint_snapshot_sha256&lt;/code&gt; fields.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Use this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Write raw facets to a canonical, hashed snapshot at collection time, and compute any grade later as a view over that snapshot plus a named rule.&lt;/li&gt;
&lt;li&gt;Give every rule an id equal to the SHA-256 of its canonical content, keep the rules file append-only, and record the id in each file published under the new methodology.&lt;/li&gt;
&lt;li&gt;Resolve the rulebook as of the date being computed, add a golden-hash rerun test for an old date, and make the pipeline refuse to overwrite a file whose recorded methodology version differs from the resolved one.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How do you version a scoring rule without changing old results?
&lt;/h3&gt;

&lt;p&gt;Keep the raw facts and compute each grade later as a view over them. Each rule lives in an append-only file, and its id is the SHA-256 of its canonical content, so editing a rule changes its id instead of passing as the old one. Every file published under 2.1.0 or later records the rule_id in force.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do you keep a rerun of a published dataset reproducible?
&lt;/h3&gt;

&lt;p&gt;Resolve the rulebook from the date being computed, not from whichever methodology file is current. Add a golden-hash rerun test for an old date, so the hash must equal a fixed value. Make the pipeline refuse to overwrite a file whose recorded methodology version differs from the resolved one. A code review caught the version of this bug that would have rewritten a file already published under 2.0.0.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should a published dataset store grades or raw facts?
&lt;/h3&gt;

&lt;p&gt;Store the raw facts. A grade written at collection time is a frozen copy of whatever rule existed that morning, and once the facts are discarded it cannot be recomputed under a new rule. A version column labels a grade you have to trust, while a content-hashed rule_id is a claim you can check. The cost is a private snapshot file and one more digest in the hash input.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/same-model-different-price-open-weight-spread/" rel="noopener noreferrer"&gt;The 16.08x price spread for one open-weight model that raised the grading question&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/stci-zero-to-v010-token-cost-index/" rel="noopener noreferrer"&gt;How the token cost index was first built&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/publish-derived-data-from-an-allow-list/" rel="noopener noreferrer"&gt;Publishing derived data from an allow-list so no raw field leaks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>dataengineering</category>
      <category>reproducibility</category>
      <category>architecture</category>
      <category>testing</category>
    </item>
    <item>
      <title>OpenRouter Price Spread: One Open-Weight Model Spans 16.08x</title>
      <dc:creator>Jeremy Longshore</dc:creator>
      <pubDate>Sat, 21 Nov 2026 12:40:30 +0000</pubDate>
      <link>https://dev.to/jeremy_longshore/openrouter-price-spread-one-open-weight-model-spans-1608x-1emn</link>
      <guid>https://dev.to/jeremy_longshore/openrouter-price-spread-one-open-weight-model-spans-1608x-1emn</guid>
      <description>&lt;p&gt;If you quote, benchmark or budget an open-weight model by one price per model, one number is standing in for a spread of sellers and serving precisions. This post shows how wide that hidden spread was on one day, how to measure it with an open daily price index, and what to print beside any price so a reader can judge it.&lt;/p&gt;

&lt;p&gt;A model name is not a price. OpenRouter, a marketplace that resells many providers' model APIs, lists the same open weights from many providers. Each provider runs one or more endpoints (a separately priced deployment of the model) and sets its own rate. A per-model price, whether an average or a pick, collapses those rates into one number.&lt;/p&gt;

&lt;p&gt;The measurement comes from the Standardized Token Cost Index (STCI), an open daily price index for model tokens. Its first run under STCI methodology 2.0.0 (the methodology, from here on), on 2026-11-19, found the most-listed model to be &lt;code&gt;deepseek/deepseek-v4.1-flash-1017&lt;/code&gt;: 50 endpoints from 41 providers. Its blended price (input and output rates combined into one per-token rate, weighting output 3:1) runs from $0.12 to $1.95 per 1M tokens. That is a 16.08x spread.&lt;/p&gt;

&lt;p&gt;The cheapest of those endpoints, from a provider called Ambient, serves the model at fp4. fp4 is 4-bit floating-point weights, a more heavily quantized serving format than fp8 (8-bit). The JSON calls this field &lt;code&gt;quantization&lt;/code&gt;; mxfp4 is another 4-bit variant. So the cheapest token may be a different grade of the same model than the median one.&lt;/p&gt;

&lt;p&gt;The widest model in the run is a different one. &lt;code&gt;deepseek/deepseek-v4.1-flash&lt;/code&gt; has 39 endpoints and a 34.82x max/min ratio. Both figures matter, because the widest spread and the most listings are different questions. The 16.08x case answers the second.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do open-weight model prices differ between providers?
&lt;/h2&gt;

&lt;p&gt;Each provider sets its own rate for the same model weights, and providers do not all serve those weights at the same precision. For the most-listed model, the cheapest of 50 endpoints served fp4 while most endpoints that reported a precision served fp8. For this model, the lowest price and a lower precision coincide. The data does not show that precision explains the whole spread.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the per-model spread record contains
&lt;/h2&gt;

&lt;p&gt;The collector fetches each open-weight model's per-provider endpoint list. For every model with positive prices, it records the endpoint and provider counts, the min, p25, median, p75 and max blended prices, the max/min and p75/p25 ratios, the serving-precision mix, and the cheapest endpoint with its precision. Models with fewer than four priced endpoints are not reported.&lt;/p&gt;

&lt;p&gt;The record for the most-listed model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"model_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek/deepseek-v4.1-flash-1017"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"endpoints"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"providers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;41&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"min_blended"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.1212&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"p25_blended"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.3904&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"median_blended"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.55&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"p75_blended"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.8912&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"max_blended"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"max_min_ratio"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;16.08&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"p75_p25_ratio"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2.28&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"quantization_mix"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"fp4"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"fp8"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"mxfp4"&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="nl"&gt;"unknown"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;19&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"cheapest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"provider"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Ambient"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"quantization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"fp4"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"blended"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.1212&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things in that record change how the price should be quoted.&lt;/p&gt;

&lt;p&gt;First, 19 of 50 endpoints (38%) report no precision. The precision mix is incomplete before any analysis begins.&lt;/p&gt;

&lt;p&gt;Second, 23 of the 31 endpoints that report a precision are fp8. For this model, fp8 is the most common known precision.&lt;/p&gt;

&lt;p&gt;Third, the cheapest endpoint is one of six fp4 endpoints. Its blended price of 0.1212 is under a quarter of the 0.55 median. For this model, quoting the cheapest figure means quoting an fp4 price without saying so.&lt;/p&gt;

&lt;p&gt;Hypothetical, not a record from the run: a team benchmarks against the cheapest endpoint, then budgets against the median. The benchmark and the budget may now describe different grades of the same token.&lt;/p&gt;

&lt;h2&gt;
  
  
  Spread across 57 OpenRouter open-weight models
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://startaitools.com/posts/stci-zero-to-v010-token-cost-index/" rel="noopener noreferrer"&gt;STCI&lt;/a&gt; also publishes headline indexes from the same listings. In this run, 480 listings became 344 eligible ones. The other 136 were excluded by rule, not by a list of model IDs: 92 batch variants (their rates attach to the base model), 19 aliases, 17 free variants and 8 routers.&lt;/p&gt;

&lt;p&gt;The spread covers 57 models (those with at least four priced endpoints), with zero fetch errors. The run summary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"models_measured"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;57&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"fetch_errors"&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="nl"&gt;"median_max_min_ratio"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2.53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"median_p75_p25_ratio"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.31&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"widest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"model_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek/deepseek-v4.1-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"max_min_ratio"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;34.82&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"endpoints"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;39&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"most_endpoints"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"model_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek/deepseek-v4.1-flash-1017"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"endpoints"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"providers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;41&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"max_min_ratio"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;16.08&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;Across those 57 models, the median max/min ratio is 2.53x and the median p75/p25 ratio is 1.31x. The typical model's endpoints run about two and a half times from cheapest to dearest, and the middle half of them sit within about 1.3x. Max/min is sensitive to a single outlier endpoint, and the quartile ratio is not. For the most-listed model, the max of $1.95 sits well above the p75 of $0.89, while its p75/p25 ratio is 2.28x. Quote the quartile ratio beside the max/min.&lt;/p&gt;

&lt;p&gt;The headline indexes compress the same listings into single numbers. STCI-ALL is $6.00 per 1M blended across all 344 eligible listings. STCI-FRONTIER is $12.04 across 9 models, STCI-EFFICIENT is $1.05 across 9, and STCI-OPEN is $2.05 across 23. Each is one number for a group of models, and none shows how far apart the prices inside one model are.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not quote the cheapest price or one index
&lt;/h2&gt;

&lt;p&gt;Two approaches look reasonable. Each fails in a specific way.&lt;/p&gt;

&lt;p&gt;Publishing the cheapest listed price per model is the first. It is what a budget spreadsheet wants. It also selects one endpoint out of 50, and for the most-listed model that endpoint is the fp4 one. The spread record keeps the cheapest endpoint with its precision. That min is a range bound, labeled with its grade, not the model's price.&lt;/p&gt;

&lt;p&gt;A headline index is the second. It answers a trend question, and it cannot answer a question about one model, because it is one number over a group of models (344 for STCI-ALL).&lt;/p&gt;

&lt;h2&gt;
  
  
  What the spread does not measure
&lt;/h2&gt;

&lt;p&gt;The methodology states its limits. They matter for any quote built on it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It measures listed prices, not prices paid. Subsidized or negotiated rates are invisible to it. A reported-price panel is the planned remedy, not something that has shipped.&lt;/li&gt;
&lt;li&gt;It has one source. OpenRouter supplies both the prices and the endpoint list.&lt;/li&gt;
&lt;li&gt;Endpoints are weighted equally. Usage weighting needs reported volumes the methodology does not yet have.&lt;/li&gt;
&lt;li&gt;The 3:1 output-to-input blend is an assumption. It is stated, not measured.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The spread also has a cost. It adds about 60 requests per day to one public endpoint.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verification, and what the hash does not prove
&lt;/h2&gt;

&lt;p&gt;The test suite passes: 77 tests, 12 of them new in &lt;code&gt;tests/test_methodology_v2.py&lt;/code&gt;. The run's verification hash, &lt;code&gt;3b422aefd8c603c8&lt;/code&gt;, reproduced on a second dry run. A matching hash shows the output is repeatable from the same inputs. It does not show that the listed prices were correct when they were fetched.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to run it for a date
&lt;/h2&gt;

&lt;p&gt;Run the three commands in the order the methodology lists them, with the same date each time. They fetch live listings, so running them today will not reproduce the 2026-11-19 figures; the raw observations are not published.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python -m services.collector.pipeline --date 2026-11-19
python -m services.collector.spread --date 2026-11-19
python -m services.indexer.pipeline --date 2026-11-19
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The spread lands at &lt;code&gt;data/spread/2026-11-19.json&lt;/code&gt;. The public JSON built from this file goes through an allow-list, covered &lt;a href="https://startaitools.com/posts/publish-derived-data-from-an-allow-list/" rel="noopener noreferrer"&gt;the day before&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Publish the spread beside the price, not instead of it. A price line should carry the min, median and max, the endpoint and provider counts, the precision mix and the precision of the cheapest endpoint. A max/min ratio above the run's 2.53x median is the signal to put that range up front. Models with fewer than four priced endpoints are not reported, so a missing model says nothing about how tight its spread is.&lt;/p&gt;

&lt;p&gt;The methodology, the code and the first run's spread file are in the repository, which keeps its older name: &lt;a href="https://github.com/jeremylongshore/stci-standard-inference-token-cost-index" rel="noopener noreferrer"&gt;https://github.com/jeremylongshore/stci-standard-inference-token-cost-index&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Also shipped
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;CI (merged with the methodology change): Playwright 1.57.0 refused to install Chromium on &lt;code&gt;ubuntu-latest&lt;/code&gt;, which now resolves to 26.04. The browser jobs are pinned to &lt;code&gt;ubuntu-24.04&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How do you measure the price spread for an open-weight model?
&lt;/h3&gt;

&lt;p&gt;The collector fetches each open-weight model's per-provider endpoint list and records the min, p25, median, p75 and max blended prices, the max/min and p75/p25 ratios, and the serving-precision mix. Models with fewer than four priced endpoints are not reported. The spread for a given day is written to a dated JSON file under data/spread/.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should you quote the cheapest endpoint price for an open-weight model?
&lt;/h3&gt;

&lt;p&gt;In the first run, quoting the cheapest figure for the most-listed model meant quoting an fp4 price without saying so, and if your quality bar is fp8, it is the wrong number to budget with. The cheapest endpoint for deepseek/deepseek-v4.1-flash-1017 was Ambient at fp4, with a blended price of 0.1212 against a 0.55 median. Publish the min, median and max together, with the endpoint and provider counts, the precision mix and the cheapest endpoint's precision.&lt;/p&gt;

&lt;h3&gt;
  
  
  What does the spread not measure?
&lt;/h3&gt;

&lt;p&gt;It measures listed prices, not prices paid, so subsidized or negotiated rates are invisible to it. It has one source, OpenRouter, which supplies both the prices and the endpoint list. Endpoints are weighted equally, and usage weighting needs reported volumes the methodology does not yet have. The 3:1 output-to-input blend is an assumption, stated but not measured.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Run the three commands above for one date and read &lt;code&gt;data/spread/&amp;lt;date&amp;gt;.json&lt;/code&gt; for any model you plan to quote.&lt;/li&gt;
&lt;li&gt;Quote each price with its min, median and max, its endpoint and provider counts, and its precision mix. If a model's max/min ratio is above the run's 2.53x median, lead with the range.&lt;/li&gt;
&lt;li&gt;If your quality bar is fp8, check the cheapest endpoint's precision before budgeting with it; for the most-listed model it was fp4. The spread record does not give an fp8 price, so pull the per-provider endpoint list and filter it by precision before you quote.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Previous day: the STCI site publishes derived JSON from an allow-list so raw licensed fields cannot leak. &lt;a href="https://startaitools.com/posts/publish-derived-data-from-an-allow-list/" rel="noopener noreferrer"&gt;Read it&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;January 2026: STCI v0.1.0, the first token cost index build. &lt;a href="https://startaitools.com/posts/stci-zero-to-v010-token-cost-index/" rel="noopener noreferrer"&gt;Read it&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>llmpricing</category>
      <category>openweightmodels</category>
      <category>openrouter</category>
      <category>quantization</category>
    </item>
    <item>
      <title>Check If a Cron Job Is Running: Grep Matches Your Own Job</title>
      <dc:creator>Jeremy Longshore</dc:creator>
      <pubDate>Wed, 18 Nov 2026 11:30:19 +0000</pubDate>
      <link>https://dev.to/jeremy_longshore/check-if-a-cron-job-is-running-grep-matches-your-own-job-5198</link>
      <guid>https://dev.to/jeremy_longshore/check-if-a-cron-job-is-running-grep-matches-your-own-job-5198</guid>
      <description>&lt;h2&gt;
  
  
  How do I check if a cron job is already running without matching your own job?
&lt;/h2&gt;

&lt;p&gt;Walk &lt;code&gt;/proc&lt;/code&gt; for your own ancestors before you call a collision. Build the chain up from the shell that runs the check, then classify every process whose command line mentions the job: an ancestor means you are the job, so do the work; a sibling means a genuine collision, so let it finish or accept the duplicate row.&lt;/p&gt;

&lt;p&gt;A scheduled job that checks whether it is already running can match its own process tree (the chain of processes the job starts) and conclude that a competing run owns the work. Reading &lt;code&gt;/proc&lt;/code&gt;, the Linux filesystem that holds one directory per running process, for your own ancestors settles it: an ancestor match means you are the job, a sibling match means a genuine collision.&lt;/p&gt;

&lt;p&gt;That near miss came out of an agent run that nearly handed the night's work to a process that did not exist. The rule that settled it was older than the run, already written down in a project note after an earlier instance. Here is the near miss, the running check that caused it, and the rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cron job is a chain of processes, not one process
&lt;/h2&gt;

&lt;p&gt;The nightly compile on this box is not a plain script. A scheduler (cron) fires a shell, that shell runs a Python entry script, the entry script runs a bash wrapper, and the wrapper runs the agent that does the actual work, wrapped in a timeout and a pseudo-terminal helper (&lt;code&gt;script&lt;/code&gt;) so its output is captured. Every stage stays alive while the run works.&lt;/p&gt;

&lt;p&gt;An unattended job on this box has to get two things right: what it is looking at, and what it is about to touch. The second half is written up for the cron that mirrors this blog to a sister site at 4am in &lt;a href="https://startaitools.com/posts/git-plumbing-unattended-cron-shared-checkout/" rel="noopener noreferrer"&gt;Git Plumbing for an Unattended Cron on a Shared Checkout&lt;/a&gt;: the same unattended shape, landing a file into a checkout that interactive sessions also use, where the porcelain commands fail and plumbing does not.&lt;/p&gt;

&lt;p&gt;So the nightly is a chain of about ten processes. When the run asks whether a nightly already owns this window, a window being one night's slice of work, the truthful answer is yes, and the interesting part is who. The check it reached for was the obvious one, a grep over the process table for the job name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# The check as written.&lt;/span&gt;
ps -eo cmd &lt;span class="o"&gt;|&lt;/span&gt; grep teamkb-compile

&lt;span class="c"&gt;# The same check with the detail that shows who owns what. Run later in the&lt;/span&gt;
&lt;span class="c"&gt;# day, from a second run.&lt;/span&gt;
ps -eo pid,ppid,lstart,etimes,cmd &lt;span class="o"&gt;|&lt;/span&gt; grep -iE &lt;span class="s1"&gt;'teamkb-compile|nightly-entry|claude -p'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What the ps grep returned
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2418556 2418553 Mon Nov 16 03:30:00 2026  1939 /bin/sh -c PATH=... TEAMKB_COMPILE_TIMEOUT=4500 /home/jeremy/bin/teamkb-compile-daily.sh &amp;gt;&amp;gt; ... 2&amp;gt;&amp;amp;1
2418573 2418556 Mon Nov 16 03:30:00 2026  1939 python3 /home/jeremy/.local/lib/teamkb-compile/current/nightly-entry.py
2449252 2418573 Mon Nov 16 03:59:02 2026   198 bash /home/jeremy/.local/lib/teamkb-compile/releases/1a6a5f474c64b3c6edc3790e9da261030bc0ad6a/teamkb-compile-daily.sh
2449332 2449252 Mon Nov 16 03:59:02 2026   197 /usr/bin/timeout --kill-after=10s 4500 script -e -q -a -c /home/jeremy/.local/bin/claude -p '/teamkb-compile 2026-11-14 2026-11-15 --auto' ...
2449333 2449332 Mon Nov 16 03:59:02 2026   197 script -e -q -a -c /home/jeremy/.local/bin/claude -p '/teamkb-compile 2026-11-14 2026-11-15 --auto' ...
2449334 2449333 Mon Nov 16 03:59:02 2026   197 sh -c /home/jeremy/.local/bin/claude -p '/teamkb-compile 2026-11-14 2026-11-15 --auto' ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every line of that listing is an ancestor of the shell that ran the check. There is no competing process in it.&lt;/p&gt;

&lt;p&gt;The bare listing does not say that. It is six lines with the job's name in the command column and two different start times, which reads like a nightly from an earlier window plus a second one that started later. Only the parent column gives the chain away, and only if you trace it by hand. The run summary from that morning puts it plainly:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;ps -eo cmd | grep teamkb-compile matched my &lt;em&gt;own&lt;/em&gt; invocation and read exactly like 'a sibling nightly already owns this window' - I was about to stand down and let it run.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The nightly session had said so at 09:32, before it checked anything. The line that settled it reads:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Important find - the nightly for this exact date is already running (cron-launched, same window/mode). Checking its progress before I write anything.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It was about to hand the window to itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  The ancestor walk through /proc
&lt;/h2&gt;

&lt;p&gt;The decisive check is cheap. Walk up from your own PID through the parent chain in &lt;code&gt;/proc&lt;/code&gt;, and then ask where the matching process sits in that chain.&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;echo&lt;/span&gt; &lt;span class="s2"&gt;"--- my ancestor chain ---"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;P&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$$&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$P"&lt;/span&gt; != &lt;span class="s2"&gt;"1"&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="o"&gt;[&lt;/span&gt; -n &lt;span class="s2"&gt;"$P"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nv"&gt;L&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;/usr/bin/tr &lt;span class="s1"&gt;'\0'&lt;/span&gt; &lt;span class="s1"&gt;' '&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; /proc/&lt;span class="nv"&gt;$P&lt;/span&gt;/cmdline 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null &lt;span class="o"&gt;|&lt;/span&gt; /usr/bin/cut -c1-160&lt;span class="o"&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;"$P :: $L"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;P&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;/usr/bin/awk &lt;span class="s1"&gt;'{print $4}'&lt;/span&gt; /proc/&lt;span class="nv"&gt;$P&lt;/span&gt;/stat 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; -z &lt;span class="s2"&gt;"$P"&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;break&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2459099 :: /usr/bin/zsh -c source /home/jeremy/.claude/shell-snapshots/snapshot-zsh-1794823149094-1xifn3.sh ...
2449335 :: /home/jeremy/.local/bin/claude -p /teamkb-compile 2026-11-14 2026-11-15 --auto --mcp-config ...
2449334 :: sh -c /home/jeremy/.local/bin/claude -p '/teamkb-compile 2026-11-14 2026-11-15 --auto' ...
2449333 :: script -e -q -a -c /home/jeremy/.local/bin/claude -p '/teamkb-compile 2026-11-14 2026-11-15 --auto' ...
2449332 :: /usr/bin/timeout --kill-after=10s 4500 script -e -q -a -c ...
2449252 :: bash /home/jeremy/.local/lib/teamkb-compile/releases/1a6a5f474c64b3c6edc3790e9da261030bc0ad6a/teamkb-compile-daily.sh
2418573 :: python3 /home/jeremy/.local/lib/teamkb-compile/current/nightly-entry.py
2418556 :: /bin/sh -c PATH=... /home/jeremy/bin/teamkb-compile-daily.sh &amp;gt;&amp;gt; /home/jeremy/.local/state/teamkb-compile-daily/cron.log 2&amp;gt;&amp;amp;1
2418553 :: /usr/sbin/CRON -f -P
3194076 :: /usr/sbin/cron -f -P
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two compile sessions ran on this box that morning, and they hit the same trap about half an hour apart. The listing above is the retry session's ps check at 10:02Z and the walk below is the same session's ancestor walk at 10:03Z, the one running the 2026-11-14 target after the previous attempt hit its deadline. The quotes that follow are from the nightly session at 09:32Z, which was running the 2026-11-15 window and reached the same false positive about half an hour earlier.&lt;/p&gt;

&lt;p&gt;The chain ends in the scheduler. Every process between the scheduler and the shell running the check is an ancestor of that shell, so the walk does not find a competing run. It finds the chain of processes the run in question belongs to, and everything above the check is the job's own machinery.&lt;/p&gt;

&lt;p&gt;The project's memory file already carried the rule, written after an earlier instance of the same bug. Before concluding that a nightly is running, walk your own ancestor chain and ask whether the matching process is an ancestor of you or a sibling. An ancestor means you are the nightly, there is no collision, and you must do the compile yourself. A sibling means a genuine collision, and you let it finish or accept the duplicate row.&lt;/p&gt;

&lt;p&gt;The rule was already written down, and the nightly session went looking for it. Two minutes later its log reads:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The watcher fired - but the memory's decisive check is the ancestor walk, not ps. Doing that now, plus reading the resolution.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Less than a minute later:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Ancestor walk is decisive - I &lt;em&gt;am&lt;/em&gt; the nightly. nightly-entry.py -&amp;gt; teamkb-compile-daily.sh -&amp;gt; timeout -&amp;gt; script -&amp;gt; claude -p '/teamkb-compile 2026-11-15 2026-11-16 --auto' -&amp;gt; me. The ps grep matched my own invocation - the documented false-positive.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That same nightly session went on to claim the receipts (a machine-written record proving a step really ran) for that night's capture file, and the claim held. They came from the capture tool that run was configured with: 19 of 19 hash-matched, 0 unattributed. That is the proof the work happened rather than being deferred to a phantom.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ancestor or sibling
&lt;/h2&gt;

&lt;p&gt;Here is the classification, written so the liveness check can carry 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;# My own ancestor chain, as a space-separated PID list.&lt;/span&gt;
&lt;span class="c"&gt;# Field 4 of /proc/$PID/stat is the parent, unless the command name in&lt;/span&gt;
&lt;span class="c"&gt;# parentheses holds a space. The awk read below is the one that ran on&lt;/span&gt;
&lt;span class="c"&gt;# 2026-11-16. The robust read takes the field after the last ')':&lt;/span&gt;
&lt;span class="c"&gt;#   PPID=$(/usr/bin/sed -E 's/^.*\) [A-Za-z] ([0-9]+).*/\1/' "/proc/$PID/stat")&lt;/span&gt;
&lt;span class="nv"&gt;ANC&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nv"&gt;P&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$$&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; -n &lt;span class="s2"&gt;"$P"&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="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$P"&lt;/span&gt; != &lt;span class="s2"&gt;"1"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;ANC&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$ANC $P"&lt;/span&gt;
  &lt;span class="nv"&gt;P&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;/usr/bin/awk &lt;span class="s1"&gt;'{print $4}'&lt;/span&gt; /proc/&lt;span class="nv"&gt;$P&lt;/span&gt;/stat 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;[&lt;/span&gt; -z &lt;span class="s2"&gt;"$P"&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;break&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="c"&gt;# Every process whose command line mentions the job, minus the grep itself.&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; pid &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;ps -eo &lt;span class="nv"&gt;pid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;,cmd= &lt;span class="o"&gt;|&lt;/span&gt; grep -F &lt;span class="s1"&gt;'teamkb-compile'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -v &lt;span class="s1"&gt;' grep '&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'{print $1}'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;" $ANC "&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
    *&lt;span class="s2"&gt;" $pid "&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;"ancestor $pid : I am the job, do the work"&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&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;"sibling  $pid : genuine collision, wait or accept the duplicate"&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;esac&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The decision fits in two rows:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Where the match sits&lt;/th&gt;
&lt;th&gt;What it means&lt;/th&gt;
&lt;th&gt;What the job does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Ancestor of the shell running the check&lt;/td&gt;
&lt;td&gt;The check is running inside the job, so the job is the caller&lt;/td&gt;
&lt;td&gt;Do the work now&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sibling of that shell&lt;/td&gt;
&lt;td&gt;A second copy of the scheduled job is genuinely in flight&lt;/td&gt;
&lt;td&gt;Let it finish and write the row, or accept the duplicate row&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One caveat on reading &lt;code&gt;/proc/$PID/stat&lt;/code&gt;. Field 4 is the parent, but field 2 is the executable name in parentheses and it can hold spaces and parentheses of its own. A space alone shifts every later field for an awk read, and the parentheses are why the robust read takes the field after the last ')'. The walk above used the awk read, which is what ran on 2026-11-16; the sed read in the comment is the one to copy when a command name holds spaces.&lt;/p&gt;

&lt;p&gt;Two outcomes, and they are not close in weight. An ancestor means the check is running inside the job, so the job is the caller and the caller does the work. Anything that is not an ancestor, a second copy of the scheduled job in flight or a leftover from an older run, is a collision to respect, and the window belongs to it until it writes its own row.&lt;/p&gt;

&lt;p&gt;The sibling case carries a decision inside it, and the decision is yours rather than the rule's. Let the competing run finish and write the row, or let both run and accept that two rows exist for one date. What the classification rules out is the third option, where the caller quietly exits and nobody writes anything at all.&lt;/p&gt;

&lt;p&gt;That third option is a helper that has become a gate. The general form of that defect is in &lt;a href="https://startaitools.com/posts/the-sidecar-must-never-block-the-deliverable/" rel="noopener noreferrer"&gt;A Sidecar Fault Should Not Block the Main Deliverable&lt;/a&gt;: a background helper that sits on the main path and blocks the output it exists to support. Here the helper is the liveness check and the deliverable is the verified row, so a check that cannot prove a collision must not close the window.&lt;/p&gt;

&lt;p&gt;The walk has to run from inside the job, in a shell that descends from the job's own process tree. &lt;code&gt;$$&lt;/code&gt; is the PID of the shell that runs the check, so the chain starts at the check and climbs to the agent, then to the scheduler. Run the same script from an interactive terminal and every match comes back a sibling, which is the honest answer for a process outside the job.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not the obvious approach
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why not exclude my own PID?&lt;/strong&gt; The matches are not you, they are your ancestors. The listing above holds six PIDs and not one of them is the PID of the shell running the check, so &lt;code&gt;grep -v $$&lt;/code&gt; leaves all six behind with the same blind spot as the original check.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why not trust the lock?&lt;/strong&gt; The compile lock was held, and that fact was true and useless. A lock answers "is a holder present", and the holder was the caller's own ancestor tree. The lock has no way to say "held by me", because from the lock's side the holder is a PID and the caller is a different PID.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why not match on a unique run id?&lt;/strong&gt; Changing the string does not change the shape of the problem. The wrapper builds every stage of the tree from the same text, so a run id in that text lands in the command line of every stage, the way the job name lands there now. The grep would find your own ancestors again under a different name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why not ask the scheduler?&lt;/strong&gt; Cron does not track its children. From outside, the process table holds a set of PIDs with a start time, which is the same evidence the grep already gave.&lt;/p&gt;

&lt;p&gt;The class of mistake is not new on this box. A burn-in watchdog latched onto a phantom io spike on a healthy stack, and the rule that came out of it is in &lt;a href="https://startaitools.com/posts/do-not-blindly-restart/" rel="noopener noreferrer"&gt;Do Not Blindly Restart&lt;/a&gt;: classify the signal before you act on it, and let the unknown path stay the safe path. Here the action is not a restart but a stand down, and the signal is a name match on the job's own ancestor tree.&lt;/p&gt;

&lt;h2&gt;
  
  
  What closes a window: the verified row
&lt;/h2&gt;

&lt;p&gt;The other half of this failure is what counts as done. A date closes only on its own verified row, not on the fact that memories landed or that a row exists for a neighbouring date. The dispatcher recomputes the pending set every night as the known pending dates minus the ones with a verified row for that date and mode, a mode being the run mode the session was launched in, then sends the night's target first and the sorted remainder after it. A date with no verified row is retried every night until it verifies, and one failing date does not block the next one.&lt;/p&gt;

&lt;p&gt;That is why the pending queue already carried the 2026-11-14 target, with a seven-day lookback. It had been killed at its 3000s deadline and left pending: the attempt that ran on the night of 2026-11-15 was the one that died, and its target was 2026-11-14. The retry session that did the ancestor walk was itself the in-flight job for that target, started at 03:59:02. When the false positive nearly ended that session early, the target would have had neither a verified row nor a second attempt, so it would have come back the next night anyway.&lt;/p&gt;

&lt;p&gt;Two rows for one date and zero rows for one date are not the same problem. A duplicate row is noise that somebody has to reconcile. A missing row is a date with no evidence that it ran at all, and the dispatcher keeps offering it back.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the false positive cost
&lt;/h2&gt;

&lt;p&gt;The rule exists because this was not the first time. On 2026-11-16 the false positive cost about two minutes and a watcher set up for a job that did not exist. It was never acted on: the walk came before the session gave the window away. On 2026-11-03 the same mistake parked a run for about 25 minutes watching itself, and nearly produced a duplicate row for 2026-11-02.&lt;/p&gt;

&lt;p&gt;MiniMax M3 and MiniMax M3.1 Flash ran the two nightly compile sessions on this machine, and the false positive happened in both. The sharp moment was not an argument between a human and a model. It was a session correcting its own earlier conclusion. The nightly session decided a competing nightly owned the window and was about to stand down; the ancestor walk inverted that a couple of minutes later, and the same session did the work it had been about to hand to a phantom job.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How do I check whether a cron job is already running without matching my own job?
&lt;/h3&gt;

&lt;p&gt;Walk your own ancestors in &lt;code&gt;/proc&lt;/code&gt; and classify each match by where it sits in that chain. Build the chain from the shell that runs the check (&lt;code&gt;$$&lt;/code&gt;) upward through the parent field of &lt;code&gt;/proc/$PID/stat&lt;/code&gt;, then compare it against every process whose command line mentions the job. A matching process that is an ancestor of the checker means the checker is running inside the job, so you are the job and you do the work. A matching process that is a sibling means a second copy is genuinely in flight, so you let it finish or accept the duplicate row.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I find the parent PID of a process on Linux?
&lt;/h3&gt;

&lt;p&gt;Field 4 of &lt;code&gt;/proc/$PID/stat&lt;/code&gt; holds the parent PID, and reading it repeatedly from &lt;code&gt;$$&lt;/code&gt; builds the chain of ancestors up to the scheduler. Field 2 is the executable name in parentheses and it can hold spaces and parentheses of its own. A space alone shifts every later field for an awk read, and the parentheses are why a robust read takes the field after the last &lt;code&gt;)&lt;/code&gt;. The ancestor walk above uses that chain to decide whether a matching process is an ancestor or a sibling.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does the process grep match my own cron job?
&lt;/h3&gt;

&lt;p&gt;Because the job is a chain of processes and every stage stays alive while the run works. On this box the chain is cron, a shell, &lt;code&gt;nightly-entry.py&lt;/code&gt;, the &lt;code&gt;teamkb-compile-daily.sh&lt;/code&gt; wrapper, &lt;code&gt;timeout&lt;/code&gt;, &lt;code&gt;script&lt;/code&gt;, and the agent process, and the job name shows up in the command line of every stage below the scheduler. A grep for the job name therefore returns the job's own machinery, which reads exactly like a competing run. Excluding your own PID does not fix it, because the matches are your ancestors and not the shell running the check.&lt;/p&gt;

&lt;h3&gt;
  
  
  What should the job do when the check finds a sibling process?
&lt;/h3&gt;

&lt;p&gt;Let the competing run finish and write the row, or let both run and accept that two rows exist for one date. What the classification rules out is the third option, where the caller quietly exits and nobody writes anything at all.&lt;/p&gt;

&lt;h3&gt;
  
  
  When is a nightly window actually done?
&lt;/h3&gt;

&lt;p&gt;A date closes only on its own verified row. A neighbouring date's row, a memory saying the run happened, or a lock being held are all weaker evidence than the row itself. The dispatcher recomputes the pending set every night, so a date with no verified row is retried until it verifies, and one failing date does not block the next one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Also shipped
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A backlog defect found while compiling: 116 candidates stuck in status='inbox', 106 of them captured 2026-07-16 and ten more scattered since. They are re-processed nightly (107 rejected plus 6 flagged that night) and never clear, because a rejected capture has no terminal state. A tracked task already covers it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Use this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Replace the string match in your cron job's liveness check with a walk of your own ancestors in &lt;code&gt;/proc&lt;/code&gt;. A matching process that is an ancestor of the checker means the checker is the job.&lt;/li&gt;
&lt;li&gt;Decide from the classification and not from the process count. Ancestor means do the work now. Sibling means let it finish or accept the duplicate row.&lt;/li&gt;
&lt;li&gt;Treat a window as open until its own verified row exists. A neighbouring date's row, a memory saying it ran, or a lock being held are all weaker evidence than the row itself.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://startaitools.com/posts/do-not-blindly-restart/" rel="noopener noreferrer"&gt;Do Not Blindly Restart: Designing a Self-Healing Watchdog That Stays Honest&lt;/a&gt;: a burn-in watchdog that latched onto a phantom io spike on a healthy stack.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://startaitools.com/posts/git-plumbing-unattended-cron-shared-checkout/" rel="noopener noreferrer"&gt;Git Plumbing for an Unattended Cron on a Shared Checkout&lt;/a&gt;: the plumbing an unattended job needs before it touches shared state.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://startaitools.com/posts/the-sidecar-must-never-block-the-deliverable/" rel="noopener noreferrer"&gt;A Sidecar Fault Should Not Block the Main Deliverable&lt;/a&gt;: a helper that fails in the background must not stall the work it supports.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cicd</category>
      <category>devops</category>
      <category>automation</category>
      <category>debugging</category>
    </item>
    <item>
      <title>CI Check Passes Without Reading What It Claims to Check</title>
      <dc:creator>Jeremy Longshore</dc:creator>
      <pubDate>Wed, 18 Nov 2026 11:30:16 +0000</pubDate>
      <link>https://dev.to/jeremy_longshore/ci-check-passes-without-reading-what-it-claims-to-check-23a4</link>
      <guid>https://dev.to/jeremy_longshore/ci-check-passes-without-reading-what-it-claims-to-check-23a4</guid>
      <description>&lt;p&gt;Three of our checks gave the wrong answer on the same day, and one rule fixes all three: a check has to say what it looked at, and what it looked at has to be the real thing. A check on how much input each helper script reads answered PASS while the nine Perl helper scripts it was supposed to check went unread. A screenshot scanner reported green while its plugin did nothing. One test environment rejected a correct plugin, because the machine it ran on was not set up like a normal install.&lt;/p&gt;

&lt;p&gt;If you trust a passing check to have looked at the thing it claims to check, the three failures below are worth your time. Each one is a different kind of check: one that reads files, one that reads a folder, and one that reads the environment it runs in.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does a CI check pass without reading what it claims to check?
&lt;/h2&gt;

&lt;p&gt;A CI (continuous integration) check can pass without reading what it claims to check because nothing required the verdict to name the files it opened. One check matched only shell scripts, so it printed PASS over a corpus (the set of files the check covered) of one git hook, and a coverage reporter that checks whether each gate ran had to call that gate UNPROVEN.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;What it set out to do&lt;/th&gt;
&lt;th&gt;What it actually did&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Gate C42&lt;/td&gt;
&lt;td&gt;Make sure each shipped runtime script limits how much input it reads before it stores or sorts it&lt;/td&gt;
&lt;td&gt;Matched shell only, so it never opened the Perl helpers and printed PASS over a corpus of one git hook&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Screenshot scanner&lt;/td&gt;
&lt;td&gt;Read the screenshots the plugin wrote into the folder it resolved&lt;/td&gt;
&lt;td&gt;Resolved &lt;code&gt;~/Pictures&lt;/code&gt;, one level above the folder Omasnap writes into, so the inbox was always empty&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rig first-run hook&lt;/td&gt;
&lt;td&gt;Make a first run look like a new plugin user&lt;/td&gt;
&lt;td&gt;Wiped &lt;code&gt;~/.local/state/omarchy&lt;/code&gt; and took the current-theme state with it, so the render's QML warnings came from first-party code&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Three checks that gave the wrong answer
&lt;/h2&gt;

&lt;p&gt;Our desktop plugins are built for Omarchy, an opinionated Arch Linux desktop setup. Their helper scripts run on a timer and read the user's home directory, so a CI gate in our shared contributor tooling makes sure each helper limits how much input it reads before it stores or sorts it. That gate is numbered C42. Its verdicts are PASS, WARN, and SKIP for nothing to check.&lt;/p&gt;

&lt;h3&gt;
  
  
  The gate that scanned one file and answered PASS
&lt;/h3&gt;

&lt;p&gt;Its file selector matched shell only: the &lt;code&gt;.sh&lt;/code&gt; and &lt;code&gt;.bash&lt;/code&gt; extensions, and any file whose first line was a shell shebang (the &lt;code&gt;#!&lt;/code&gt; line that names the interpreter). It missed the &lt;code&gt;.pl&lt;/code&gt; and &lt;code&gt;.pm&lt;/code&gt; extensions and any Perl shebang. A sibling gate in the same lane (the shared contributor tooling that ships inside each plugin) had already been widened to match a Perl shebang, &lt;a href="https://startaitools.com/posts/a-path-is-not-proof-of-identity/" rel="noopener noreferrer"&gt;and this one was not&lt;/a&gt;. The screenshot scanner the rule was written for, &lt;code&gt;bin/capture-conveyor-scan&lt;/code&gt;, had been rewritten in Perl, so the selector never opened it. The gate's own header comment cites that file as the reason the rule exists.&lt;/p&gt;

&lt;p&gt;The verdict was a PASS over a corpus of one git hook. The plugin fleet's &lt;a href="https://startaitools.com/posts/the-lane-that-reviewed-nothing/" rel="noopener noreferrer"&gt;coverage reporter called the gate UNPROVEN&lt;/a&gt;, and that call is the only reason the fiction broke.&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;# Before: shell only. A Perl helper never matched the selector, so the gate&lt;/span&gt;
&lt;span class="c"&gt;# answered PASS over a corpus of one git hook.&lt;/span&gt;
gate_tree_files &lt;span class="s1"&gt;'\.(sh|bash)$'&lt;/span&gt;
gate_tree_files &lt;span class="s1"&gt;'(^|/)[^./]+$'&lt;/span&gt; &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 rel&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;first&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;/usr/bin/head -n1 &lt;span class="s2"&gt;"$GATE_TREE_DIR/$rel"&lt;/span&gt; 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;"$first"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; \#\!*sh*&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%s\n'&lt;/span&gt; &lt;span class="s2"&gt;"$rel"&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;esac&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="c"&gt;# After: shell or Perl, matched by extension or by shebang.&lt;/span&gt;
gate_tree_files &lt;span class="s1"&gt;'\.(sh|bash|pl|pm)$'&lt;/span&gt;
gate_tree_files &lt;span class="s1"&gt;'(^|/)[^./]+$'&lt;/span&gt; &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 rel&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;first&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;/usr/bin/head -n1 &lt;span class="s2"&gt;"$GATE_TREE_DIR/$rel"&lt;/span&gt; 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;"$first"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; \#\!*sh*&lt;span class="o"&gt;|&lt;/span&gt;\#\!*perl*&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%s\n'&lt;/span&gt; &lt;span class="s2"&gt;"$rel"&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;esac&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The runtime helpers are extensionless, so the selector cannot be an extension list alone. A file is in scope when its name ends in &lt;code&gt;.sh&lt;/code&gt;, &lt;code&gt;.bash&lt;/code&gt;, &lt;code&gt;.pl&lt;/code&gt; or &lt;code&gt;.pm&lt;/code&gt;, or when its first line is a shell or Perl shebang. Dev tooling stays out. &lt;code&gt;scripts/&lt;/code&gt;, &lt;code&gt;tests/&lt;/code&gt;, &lt;code&gt;e2e/&lt;/code&gt; and &lt;code&gt;.github/&lt;/code&gt; never run on a user's machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  The scanner whose fixture agreed with the code
&lt;/h3&gt;

&lt;p&gt;The second failure sat in a proof rig (an isolated container that renders a plugin and records what it saw). Omarchy takes screenshots with Omasnap, which writes into &lt;code&gt;~/Pictures/Screenshots&lt;/code&gt;. The scanner resolved the folder from &lt;code&gt;OMARCHY_SCREENSHOT_DIR&lt;/code&gt;, then &lt;code&gt;XDG_PICTURES_DIR&lt;/code&gt;, then &lt;code&gt;user-dirs.dirs&lt;/code&gt;, then &lt;code&gt;~/Pictures&lt;/code&gt;. On a stock install that last fallback lands one level above the folder screenshots actually go into, so the inbox was always empty.&lt;/p&gt;

&lt;p&gt;The rig fixture seeded &lt;code&gt;~/Pictures&lt;/code&gt; and asserted that the resolved directory ended in &lt;code&gt;/Pictures&lt;/code&gt;. Both halves were true, the plugin did nothing, and the receipt (a machine-written record proving a step really ran) said green.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight perl"&gt;&lt;code&gt;&lt;span class="c1"&gt;# After: the folder is resolved in Omasnap's own order.&lt;/span&gt;
&lt;span class="k"&gt;sub&lt;/span&gt; &lt;span class="nf"&gt;screenshot_directory&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="k"&gt;my&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;qw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;OMASNAP_SCREENSHOT_DIR&lt;/span&gt; &lt;span class="no"&gt;OMARCHY_SCREENSHOT_DIR&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;my&lt;/span&gt; &lt;span class="nv"&gt;$value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$ENV&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$value&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$value&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="s1"&gt;''&lt;/span&gt; &lt;span class="k"&gt;unless&lt;/span&gt; &lt;span class="nv"&gt;$home_usable&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;my&lt;/span&gt; &lt;span class="nv"&gt;$conf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;read_pinned_config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"$config_home/omasnap"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'omasnap.conf'&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="n"&gt;defined&lt;/span&gt; &lt;span class="nv"&gt;$conf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;my&lt;/span&gt; &lt;span class="nv"&gt;$configured&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;omasnap_output_directory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$conf&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="nv"&gt;$configured&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;defined&lt;/span&gt; &lt;span class="nv"&gt;$configured&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;my&lt;/span&gt; &lt;span class="nv"&gt;$user_dirs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;read_pinned_config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$config_home&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'user-dirs.dirs'&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="n"&gt;defined&lt;/span&gt; &lt;span class="nv"&gt;$user_dirs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;my&lt;/span&gt; &lt;span class="nv"&gt;$pictures&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;user_dirs_pictures&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$user_dirs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"$pictures/Screenshots"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;defined&lt;/span&gt; &lt;span class="nv"&gt;$pictures&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"$home/Pictures/Screenshots"&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 folder is now resolved in Omasnap's own order, and two details in that order matter. The &lt;code&gt;XDG_PICTURES_DIR&lt;/code&gt; environment variable is gone, because neither Omasnap nor Qt reads it. The &lt;code&gt;omasnap.conf&lt;/code&gt; step was added on purpose: Omasnap reads its own config between the environment and its default, so skipping it would reproduce the empty inbox for anyone who set a directory there. &lt;code&gt;user-dirs.dirs&lt;/code&gt; is read the way Qt reads it, so an unquoted absolute path works.&lt;/p&gt;

&lt;h3&gt;
  
  
  The rig that deleted the state it was measuring
&lt;/h3&gt;

&lt;p&gt;The third failure is the one that looks most like a defect in the plugin under test, and it is not one. The live first-run hook, the script that wipes the machine to fake a new plugin user, deletes &lt;code&gt;~/.local/state/omarchy&lt;/code&gt; and its cache directory. That wipe also removed the current-theme state every Omarchy install carries. On the rig upgraded to current Omarchy (74de104, Qt 6.12), the first-party image-picker and lock plugins log QML warnings, and the render refuses every live run.&lt;/p&gt;

&lt;p&gt;The warnings came from first-party code, not from the plugin under test. The render was right to refuse.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rm -rf &lt;span class="s2"&gt;"$HOME/.local/state/omarchy"&lt;/span&gt; &lt;span class="s2"&gt;"$HOME/.cache/omarchy"&lt;/span&gt;
mkdir -p &lt;span class="s2"&gt;"$HOME/.local/state/omarchy"&lt;/span&gt; &lt;span class="s2"&gt;"$HOME/.config/omarchy/plugins"&lt;/span&gt;
&lt;span class="c"&gt;# A first-run plugin user still has an Omarchy theme. Restore the three&lt;/span&gt;
&lt;span class="c"&gt;# entries omarchy-theme-set writes.&lt;/span&gt;
&lt;span class="nv"&gt;current&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$HOME/.local/state/omarchy/current"&lt;/span&gt;
mkdir -p &lt;span class="s2"&gt;"$current"&lt;/span&gt;
ln -nsf /root/omarchy/themes/tokyo-night &lt;span class="s2"&gt;"$current/theme"&lt;/span&gt;
&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'tokyo-night\n'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"$current/theme.name"&lt;/span&gt;
ln -nsf &lt;span class="s2"&gt;"$current/theme/backgrounds/0-liftoff.webp"&lt;/span&gt; &lt;span class="s2"&gt;"$current/background"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That fix had a fork in it, and Claude Opus 5 5 took the branch we agreed with. The render refused every run because the test rig's isolated home had none of the theme state a normal install carries. The options were to seed that state, or to narrow the QML warning filter to the plugin's own paths. The change seeded the state, and wrote down why: a plugin can also cause a warning inside a first-party component it calls, so a filter scoped to your own paths would hide a real defect.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rule: say what you looked at, and look at the real thing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Name the corpus.&lt;/strong&gt; A PASS names every file it read, by language. The gate ends its verdict with that list, and it refuses to count a file it could not open.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An empty corpus is a skip.&lt;/strong&gt; If the selector matched nothing, the gate reports SKIP and says why. Before the fix, an empty corpus and a clean corpus printed the same word, and no reader could tell them apart. &lt;a href="https://startaitools.com/posts/the-skip-that-counted-as-a-pass/" rel="noopener noreferrer"&gt;The lane runner used to fold SKIP into the pass column, and that gap was closed first&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A fixture must not agree with the code.&lt;/strong&gt; The scanner's rig seeded &lt;code&gt;~/Pictures&lt;/code&gt; and asserted that the resolved directory ended in &lt;code&gt;/Pictures&lt;/code&gt;. The code and the fixture agreed, and the application never writes there. The fix went into the resolution order, so the scanner follows whatever the user configured.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The environment has to be the real one.&lt;/strong&gt; The rig's first-run hook deleted the state every install carries, and a correct render refused a correct plugin. The fix was to seed the state a normal install has. Narrowing the warning filter to the plugin's own paths would have hidden a real defect, because a plugin can also cause a warning inside a first-party component it calls.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A zero exit code is not a success.&lt;/strong&gt; A zero exit status says the tool ran. It does not say the tool did the thing you asked.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# The analyzer's first output line names the language it analyzed. A file it&lt;/span&gt;
&lt;span class="c"&gt;# could not open prints nothing at all, and an unopened file is never counted&lt;/span&gt;
&lt;span class="c"&gt;# as scanned.&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;"${RESULT%%$'\n'*}"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
  &lt;span class="s2"&gt;"LANG perl"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;  SCANNED_PERL+=&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"$REL"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="s2"&gt;"LANG shell"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; SCANNED_SHELL+=&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"$REL"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  *&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;continue&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;esac&lt;/span&gt;

&lt;span class="nv"&gt;SCANNED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;${#SCANNED_SHELL[@]}&lt;/span&gt; + &lt;span class="nv"&gt;${#SCANNED_PERL[@]}&lt;/span&gt; &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; SCANNED &lt;span class="o"&gt;==&lt;/span&gt; 0 &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  gate_skip &lt;span class="s2"&gt;"no shipped shell or Perl runtime file to scan (scripts/, tests/, e2e/ and .github/ are excluded as dev tooling)"&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="nv"&gt;CORPUS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;${#SCANNED_SHELL[@]}&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 0 &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nv"&gt;CORPUS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"shell: $(corpus_names "&lt;/span&gt;&lt;span class="nv"&gt;${SCANNED_SHELL[@]}&lt;/span&gt;&lt;span class="s2"&gt;")"&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;${#SCANNED_PERL[@]}&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 0 &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  CORPUS+=&lt;span class="s2"&gt;"${CORPUS:+; }Perl: $(corpus_names "&lt;/span&gt;&lt;span class="nv"&gt;${SCANNED_PERL[@]}&lt;/span&gt;&lt;span class="s2"&gt;")"&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;

gate_pass &lt;span class="s2"&gt;"scanned $SCANNED shipped runtime file(s) ($CORPUS); each budgets local input before buffering or sorting"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last clause has its own shape, and it is the one most likely to bite a team. Desk Transition, the display-layout plugin, drives Hyprland through a helper script. Hyprland 0.57 reads a Lua config, so &lt;code&gt;hyprctl dispatch focusmonitor X&lt;/code&gt; is a Lua syntax error there, which is why the helper sends the Lua form of a dispatch first and the classic form second. On that release the &lt;code&gt;keyword&lt;/code&gt; command no longer exists, the server answers "unknown request", and hyprctl still exits 0. The old helper read that as a successful display change that never happened.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# The shipped helper runs under `set -euo pipefail`, so the status of the&lt;/span&gt;
&lt;span class="c"&gt;# pipeline below is hyprctl's status and not head's.&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -euo pipefail

&lt;span class="c"&gt;# Run hyprctl once. Succeeds only on the exact reply "ok" with exit status 0,&lt;/span&gt;
&lt;span class="c"&gt;# and remembers the first line of whatever it printed for the failure note.&lt;/span&gt;
hypr_ok&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;local&lt;/span&gt; out &lt;span class="nv"&gt;rc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
  &lt;span class="nv"&gt;out&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$(timeout 6s hyprctl "&lt;/span&gt;&lt;span class="nv"&gt;$@&lt;/span&gt;&lt;span class="s2"&gt;" 2&amp;gt;&amp;amp;1 | head -c 2048)"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nv"&gt;rc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
  &lt;span class="nv"&gt;LAST_REPLY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${out%%$'\n'*}"&lt;/span&gt;
  &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$rc"&lt;/span&gt; -eq 0 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="s2"&gt;"$out"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"ok"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The helper turns that into its own exit codes, so a caller can tell the failures apart: exit 1 when Hyprland refused the change, exit 2 when the named output is not an active output, and exit 3 when there was nothing to arrange.&lt;/p&gt;

&lt;p&gt;Success needs a positive answer, not just a quiet status. Quiet Queue, the notification plugin, had the same shape. Its Do Not Disturb read now trusts only exit status 0 with output matching exactly on or off. Anything else, a shell that is not ready, a timeout, odd text, is unknown, and unknown is never off. While the state is unknown the helper keeps the session record, refuses to start or end a session, and a start it cannot verify restores the off it read.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not the obvious approach
&lt;/h2&gt;

&lt;p&gt;The obvious fix for the gate is to shell out to Perl. Run &lt;code&gt;perl -c&lt;/code&gt; on every candidate helper and let the interpreter judge the file. That is a better gate, and the wrong one here, because the vendored lane ships inside the plugin and cannot take a runtime dependency on Perl being installed. The shipped helpers already run Perl on the user's machine, where the interpreter arrives with the base git package. The lane runs on contributor and CI machines instead, and it cannot assume what is installed there. The Perl rules went into the analyzer we already run, as pattern rules over the source text, and the gate stayed a WARN rather than a block, because a maintainer can confirm a bounded producer the regex cannot see.&lt;/p&gt;

&lt;p&gt;The second obvious fix is to scan more: drop the exclusions and check the whole tree, scripts and tests included. The gate's own scope comment records that holding dev tooling to the runtime's threat model produced false positives on every plugin, since dev tooling never runs on a user's machine. The scope stayed shipped runtime files.&lt;/p&gt;

&lt;p&gt;The third obvious fix for the screenshot scanner was to change the fixture: seed &lt;code&gt;~/Pictures/Screenshots&lt;/code&gt; in the test, point the scanner at that folder and assert it finds the files. The old resolution order honoured &lt;code&gt;OMARCHY_SCREENSHOT_DIR&lt;/code&gt; and &lt;code&gt;XDG_PICTURES_DIR&lt;/code&gt;, so that would have made the test green and left the bug in place, because the bug is that the code and the fixture agreed on a path the application never uses.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it was verified, and what it cost
&lt;/h2&gt;

&lt;p&gt;Verification is where a receipt earns the name. The gate suite ran 328 of 328, the reporters 18 of 18, integration 10 of 10, and the bash lint and pre-commit hooks were clean.&lt;/p&gt;

&lt;p&gt;The cases for this one gate say more than the totals do. Of the 12 cases that exercise it, 10 fail against the gate on master. They cover a vacuous PASS on a Perl file, a PASS on an empty corpus, and a PASS with no corpus named. The other 2 are shell severity cases, and they pass on both versions, which is how we know the shell rules did not change under us. Six deliberate mutations of the gate are each caught by a specific mutation test case, so they are not passing by accident.&lt;/p&gt;

&lt;p&gt;Two results matter most. The new gate passes all nine shipped Perl helper scripts across the plugin fleet and names each one, so a reader can see what was opened. And deleting one line, the readdir budget from a copy of the real scanner, flips that file to a WARN at the sort, citing the loop line. The gate can still fail.&lt;/p&gt;

&lt;p&gt;Only the gate's change is verified in detail here. The scanner's fix shipped with 63 of 63 tests, Model.js at 100 percent coverage under c8, mutation at 97.79 percent, three clean race runs and no osv-scanner advisories. The rig fix shipped with the pit-wall and bazaar live runs passing on the upgraded rig, every fetch returning rc=0 with a body and no QML warnings, the unit suite at 16 of 16 and the contracts clean.&lt;/p&gt;

&lt;p&gt;The cost was coverage having to notice. Until a coverage reporter called the gate UNPROVEN, nine shipped Perl helper scripts went unread by the gate that exists to read them, and every run printed PASS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Also shipped
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Desk Transition's helper sends the Lua form of a dispatch first and the classic form second, so one helper serves both releases of Hyprland. On 0.57 the classic form is parsed as Lua and errors, which is why the new form goes first.&lt;/li&gt;
&lt;li&gt;Quiet Queue's panel shows DND STATE UNKNOWN and dims every row while the state is unknown.&lt;/li&gt;
&lt;li&gt;The Foundry panel builds its start command from the helper's own resolved location, because the plugin installer puts nothing on PATH and the panel had been printing a command that could not run.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How the work went
&lt;/h2&gt;

&lt;p&gt;This post's main thread was carried by Claude Opus 5 5: six sessions, 1175 minutes, in intent-os, the internal operations and documentation repository, with 114 failure-to-fix moments and no course corrections from the human. MiniMax M3 and Claude Sonnet 5 ran the rest of the day's work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Make every check print the corpus it opened, file by file, and report a skip when it opened nothing. The reference implementation is the C42 gate: &lt;a href="https://github.com/jeremylongshore/contributing-clanker/blob/master/skills/contribute/scripts/gates/c42-omarchy-local-resource-budget.sh" rel="noopener noreferrer"&gt;https://github.com/jeremylongshore/contributing-clanker/blob/master/skills/contribute/scripts/gates/c42-omarchy-local-resource-budget.sh&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Point the fixture at the path the application really uses, and run the check where the application really runs, so neither the code and its fixture nor the check and the application can agree on something false.&lt;/li&gt;
&lt;li&gt;Require a positive answer before recording success. An exit code of zero says the tool ran; a reply of "ok" says the tool did what you asked.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How do I make a CI check report the files it actually scanned?
&lt;/h3&gt;

&lt;p&gt;The gate ends its verdict with the list of files it covered, by language. A file it could not open prints nothing at all, and an unopened file is never counted as scanned.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should a check that found nothing report a pass or a skip?
&lt;/h3&gt;

&lt;p&gt;A skip, and the gate has to say why. Before the fix, an empty corpus and a clean corpus printed the same word, and no reader could tell them apart.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I stop a test fixture from agreeing with the code?
&lt;/h3&gt;

&lt;p&gt;Seed the path the application really uses, and assert against that, not against the path the code happens to read. The scanner's rig seeded &lt;code&gt;~/Pictures&lt;/code&gt; and asserted the resolved directory ended in &lt;code&gt;/Pictures&lt;/code&gt;, so both halves were true while the plugin did nothing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is exit code 0 enough to record a success?
&lt;/h3&gt;

&lt;p&gt;No. A zero exit status says the tool ran. It does not say the tool did the thing you asked. On Hyprland 0.57 the &lt;code&gt;keyword&lt;/code&gt; command no longer exists, the server answers "unknown request", and hyprctl still exits 0, so success needs a positive answer rather than a quiet status.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/the-skip-that-counted-as-a-pass/" rel="noopener noreferrer"&gt;What a Skipped Check Is Worth in CI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/the-lane-that-reviewed-nothing/" rel="noopener noreferrer"&gt;Every Check Should Report What It Did Not Look At&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/a-path-is-not-proof-of-identity/" rel="noopener noreferrer"&gt;A Path Is Not Proof of Identity&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cicd</category>
      <category>testing</category>
      <category>debugging</category>
      <category>devops</category>
    </item>
    <item>
      <title>45-Minute Pipeline Timeout: Count Passes, Not Payload Size</title>
      <dc:creator>Jeremy Longshore</dc:creator>
      <pubDate>Mon, 16 Nov 2026 11:41:06 +0000</pubDate>
      <link>https://dev.to/jeremy_longshore/45-minute-pipeline-timeout-count-passes-not-payload-size-20nb</link>
      <guid>https://dev.to/jeremy_longshore/45-minute-pipeline-timeout-count-passes-not-payload-size-20nb</guid>
      <description>&lt;p&gt;A scheduled multi-agent writing pipeline runs against a 45-minute wall-clock ceiling, and this post hands you the three numbers worth measuring, the reason shrinking each request did not help, and the evidence that the simple pipeline is the weaker writer. Three runs in one day's telemetry hit that ceiling and timed out, so the obvious lever was to make every model request smaller.&lt;/p&gt;

&lt;p&gt;We trimmed the context and ran one reviewer fewer. Token volume fell about 70 percent, and the run still timed out.&lt;/p&gt;

&lt;p&gt;That mismatch is the finding. The payload did not order the outcomes. The sequence was how many agent passes ran and how slow each one was.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the pipeline costs
&lt;/h2&gt;

&lt;p&gt;Here is one week of seven posts, measured in the run's own request logs by Claude Opus 5.5, the model that ran the session, working inside intent-os (the company's internal operations and documentation repo):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Tokens&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cache re-reads&lt;/td&gt;
&lt;td&gt;196.5M&lt;/td&gt;
&lt;td&gt;the same context sent again, billed at about a tenth of the normal input price&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cache writes&lt;/td&gt;
&lt;td&gt;7.8M&lt;/td&gt;
&lt;td&gt;the first time that context is stored&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Output&lt;/td&gt;
&lt;td&gt;0.9M&lt;/td&gt;
&lt;td&gt;what the models actually wrote&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7 posts&lt;/td&gt;
&lt;td&gt;~205M&lt;/td&gt;
&lt;td&gt;about $105, about $15 each&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A cache re-read is the same context sent to the model again on a later request. A cache write is the first time that context is stored. The API bills a re-read at roughly a tenth of the normal input price, which is why a pipeline that resends the same context over and over is dominated by them.&lt;/p&gt;

&lt;p&gt;About $15 per post at Claude API prices for that week, and one post a day at that rate is roughly $450 a month. That week is not the same set of runs as the table below, and the two sets of numbers do not line up: the table's four rows carry roughly 220M to 245M tokens between them, against about 205M for the whole week. Two caveats on that number. The $105 includes a couple of failed attempts, and my own chat ran on Opus in the same windows, so the telemetry cannot separate it out. $15 is the upper end, not the floor.&lt;/p&gt;

&lt;p&gt;The shape of the bill matters more than the total. 196.5M of those tokens are cache re-reads, and each post re-reads a huge context about 100 to 170 times. Only 0.9M of those 205M tokens were output. The pipeline is re-reading the same context over and over.&lt;/p&gt;

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

&lt;p&gt;Before and after, from the same day's telemetry:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Run&lt;/th&gt;
&lt;th&gt;Setup&lt;/th&gt;
&lt;th&gt;Avg context per request&lt;/th&gt;
&lt;th&gt;Total tokens&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;02:00&lt;/td&gt;
&lt;td&gt;old, MiniMax&lt;/td&gt;
&lt;td&gt;179k&lt;/td&gt;
&lt;td&gt;104M&lt;/td&gt;
&lt;td&gt;timed out&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;04:00 slot, started 04:18&lt;/td&gt;
&lt;td&gt;old, MiniMax&lt;/td&gt;
&lt;td&gt;142k&lt;/td&gt;
&lt;td&gt;76M&lt;/td&gt;
&lt;td&gt;timed out&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;canary&lt;/td&gt;
&lt;td&gt;trimmed, MiniMax&lt;/td&gt;
&lt;td&gt;140k&lt;/td&gt;
&lt;td&gt;30M (writer + 2 reviewers)&lt;/td&gt;
&lt;td&gt;timed out at 45 min, nearly finished&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Opus runs&lt;/td&gt;
&lt;td&gt;old, Claude Opus 5.5&lt;/td&gt;
&lt;td&gt;155-214k&lt;/td&gt;
&lt;td&gt;11-35M&lt;/td&gt;
&lt;td&gt;landed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Read the third row and the fourth row together. The trimmed canary carried the smallest context per request of the four and still died at the ceiling. The Opus runs that landed, on the old and fatter setup, carried the fattest requests of any run that landed, up to 214k against the canary's 140k. Context size did not order the outcomes. Those two rows differ in three ways at once, model, trimming and agent count, so read the pair as a correlation and not as a controlled comparison. The landed runs spent 11M to 35M tokens, and the canary that missed the ceiling spent 30M, inside that same band. Token volume does not predict the timeout cleanly. A 30M run missed while a 35M run landed, and the two largest runs, 76M and 104M, both missed.&lt;/p&gt;

&lt;p&gt;What the trim removed was the repo's ambient CLAUDE.md instruction files and its MCP servers, the external tools an agent can call. The writer's own brief stayed, and so did the skill. The writer runs fine without them. The skill loaded, the reviewer agents ran, the post and its sign-offs were written, and the session log has it reaching the site build before the ceiling killed it. So the context the writer was carrying was not what made the post, although whether the trimmed writer writes as well is not measured yet.&lt;/p&gt;

&lt;p&gt;One caveat I want on the record. The canary also ran two reviewers instead of the full set, so the drop from 104M to 30M mixes three effects: fewer agents, smaller requests, and fewer tool-call rounds, because the MCP servers the trim removed are what agents call out to. I cannot split them from that row alone. All three buy cost, and the two that removed work, the reviewer pass and the MCP tool rounds, also buy wall time. The request-size effect was negligible at this scale and cannot be separated from them in this row. What it does settle is the ceiling. The trimmed run did less and still missed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the wall clock went, and why the timeout survived
&lt;/h2&gt;

&lt;p&gt;Per-pass timing is the number a deadline cares about. It is not a sum of request durations, because the wall clock also carries tool calls, file reads, and the handoff from one agent to the next.&lt;/p&gt;

&lt;p&gt;The blocks below are the measurement, not the pipeline's internals. One row per model request, one aggregation over those rows, and one script to shuffle posts for a blind read. What each row has to carry matters more than the exact script.&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;# Time a phase by wrapping the phase, not by summing request logs inside it.&lt;/span&gt;
phase_time &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  : &lt;span class="s2"&gt;"${PHASE_LOG:?set PHASE_LOG}"&lt;/span&gt;
  &lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="nv"&gt;phase&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$1"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;shift&lt;/span&gt;
  &lt;span class="kd"&gt;local&lt;/span&gt; start end &lt;span class="nv"&gt;rc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
  &lt;span class="nv"&gt;start&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;date +%s&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="s2"&gt;"$@"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nv"&gt;rc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
  &lt;span class="nv"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;date +%s&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'{"phase":"%s","rc":%d,"wall_s":%d}\n'&lt;/span&gt; \
    &lt;span class="s2"&gt;"$phase"&lt;/span&gt; &lt;span class="s2"&gt;"$rc"&lt;/span&gt; &lt;span class="s2"&gt;"$((end - start))"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"$PHASE_LOG"&lt;/span&gt;
  &lt;span class="nb"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$rc&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the aggregation that turns those per-pass rows into the deadline number:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# The deadline number: sum the per-pass wall time, not the request rows.&lt;/span&gt;
jq -s &lt;span class="s1"&gt;'map(.wall_s) | add as $total
       | {passes: length, total_wall_s: $total,
          ceiling_s: 2700, over: ($total &amp;gt; 2700)}'&lt;/span&gt; &lt;span class="s2"&gt;"$PHASE_LOG"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the request-level view beside 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;# Input rows are one per model request: phase, ctx_tokens, in_tokens, out_tokens,&lt;/span&gt;
&lt;span class="c"&gt;# wall_s. The output is one row per pass.&lt;/span&gt;
&lt;span class="c"&gt;# in_tokens is billed input, cache reads and writes included; ctx_tokens is the&lt;/span&gt;
&lt;span class="c"&gt;# context window the request carried.&lt;/span&gt;
jq -s &lt;span class="s1"&gt;'group_by(.phase)
  | map({
      phase:     .[0].phase,
      calls:     length,
      avg_ctx_k: ((map(.ctx_tokens) | add / length) / 1000 | floor),
      total_tok: (map(.in_tokens + .out_tokens) | add)
    })'&lt;/span&gt; requests.jsonl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three numbers, three different questions. One of them is the volume (&lt;code&gt;total_tok&lt;/code&gt;, the billed input plus the output). Another is the size of a single request (&lt;code&gt;avg_ctx_k&lt;/code&gt;). The third is the number of passes, which is the number of rows this jq emits, one row per pass. Each row carries &lt;code&gt;calls&lt;/code&gt;, the model requests inside that pass, and the log records a pass as a &lt;code&gt;phase&lt;/code&gt;. The pass count is not the deadline number. It is the multiplier: the deadline number is the sum of the per-pass wall times, which is the pass count times the average of them. Collapse those into a single "token count" column and a cost problem starts looking like a latency problem, which is backwards.&lt;/p&gt;

&lt;p&gt;An optimistic upper bound on what fits under the ceiling:&lt;br&gt;
&lt;/p&gt;

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

&lt;span class="n"&gt;call_rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&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;line&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"requests.jsonl"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;latencies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"wall_s"&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;c&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;call_rows&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;   &lt;span class="c1"&gt;# one entry per model call&lt;/span&gt;

&lt;span class="n"&gt;ceiling_s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;45&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;
&lt;span class="n"&gt;p50&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;statistics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;median&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;latencies&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"model calls        {len(call_rows)}"&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="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"p50 call           {p50:.0f}s"&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="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"model time         {sum(latencies):.0f}s of a {ceiling_s}s ceiling"&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="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"affordable calls   {int(ceiling_s // p50)} at p50"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"affordable calls" is an optimistic upper bound, not the answer. It divides the ceiling by the median call time, so it ignores tool calls, file reads and handoffs, and it flatters you. It is neither the pass count nor the request size. Cutting a request from 142k to 140k on its own would have left the count of calls in the sequence exactly where it was. The canary's volume line fell anyway, because the trim also dropped a reviewer pass, and it still missed the ceiling. Dropping one reviewer agent removes one whole pass from the sequence, and it removes all of that pass's calls, tool calls, file reads and handoff with them, not a fraction of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not the obvious approach
&lt;/h2&gt;

&lt;p&gt;The obvious approach has two halves. I shipped one and costed the other.&lt;/p&gt;

&lt;p&gt;The first half is the one I spent a month circling. Shrink every request. The trim moved the cost axis, 104M tokens down to 30M, and most of that drop was doing less rather than sending less. Against the 04:18 run, per-request context barely moved, from 142k to 140k, while the reviewer pass and the tool rounds the MCP servers provided went away. That row cannot split the three effects further. What the canary does settle is the other direction. Doing less, in context, in agents and in tool rounds, still missed the ceiling. Shrinking the requests on their own is untested here, because the trim removed the tool-call layer along with the context.&lt;/p&gt;

&lt;p&gt;The second half is the one I did not ship. Cut the agents. If three or four passes time out and one pass fits, run one writer again. That was the July and August configuration, the one that produced the summer posts. The obvious version of that argument stops at "the summer setup was simpler". It needed a quality check before I would act on it, so I ran one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The blind comparison
&lt;/h2&gt;

&lt;p&gt;Twenty posts, ten from each era, drawn at random and shuffled, with the dates and the era hidden.&lt;br&gt;
&lt;/p&gt;

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

&lt;span class="n"&gt;posts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"posts.json"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;       &lt;span class="c1"&gt;# body, date, system&lt;/span&gt;
&lt;span class="n"&gt;rng&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20261114&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;summer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;posts&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"system"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"summer"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;recent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;posts&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"system"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"multi-agent"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;sample&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rng&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;summer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;rng&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;recent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;rng&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;shuffle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"judges.jsonl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"w"&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;judges&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"key.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"w"&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;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;judges&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"p{i:02d}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"body"&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="s2"&gt;"\n"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"p{i:02d}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                              &lt;span class="s2"&gt;"system"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"system"&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="s2"&gt;"\n"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The judges got an id and a body with no title on it. The date and which system wrote it went into a separate file they never saw. The twenty, ten from each era, were sampled at random and then shuffled, so nothing about their order or their era leaked either. Two judges scored every post, one as a senior engineer reading as an outsider, one as a demanding tech-publication editor. Their per-post scores never differed by more than one point, which is what makes the aggregate worth reading.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measure&lt;/th&gt;
&lt;th&gt;Summer, simple&lt;/th&gt;
&lt;th&gt;Recent, multi-agent&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Overall (both judges averaged)&lt;/td&gt;
&lt;td&gt;3.00&lt;/td&gt;
&lt;td&gt;3.75&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Posts scoring 4 or higher&lt;/td&gt;
&lt;td&gt;1 of 10&lt;/td&gt;
&lt;td&gt;8 of 10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No filler / padding&lt;/td&gt;
&lt;td&gt;2.30&lt;/td&gt;
&lt;td&gt;3.40&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sounds like a real person&lt;/td&gt;
&lt;td&gt;3.10&lt;/td&gt;
&lt;td&gt;2.80&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Median length&lt;/td&gt;
&lt;td&gt;2,270 words&lt;/td&gt;
&lt;td&gt;1,860 words&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Voice-lint flags per post&lt;/td&gt;
&lt;td&gt;4.4&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One thing the judges could have felt without being told: the two arms differ in length, and the summer posts are the longer ones. The multi-agent pipeline is the better writer. Overall it scores 3.75 against 3.00, and the gap is not marginal: 8 of 10 posts score 4 or higher against 1 of 10. A voice linter that only sees the text flags 0.2 issues per post on the multi-agent output against 4.4 on the summer output, a factor of 22. The one scored dimension where the simple setup wins is "sounds like a real person", 3.10 against 2.80, and its posts also run longer, 2,270 words against 1,860.&lt;/p&gt;

&lt;p&gt;So the simple and fast configuration is also the weaker one. Cutting the classifier, the fact-checker, and the consistency checkers would have made the run fit inside the ceiling, because those three checkers are three of the four passes. That is a hypothesis and not a measurement, and it is the hypothesis a later one-pass run would have to test. The blind comparison is what stopped me from taking it. The two arms differ in three ways at once, agents per post, the instructions the writer was given, and the default model, so the quality gap does not belong to the agent count alone. The agent count is still the lever that moves the wall clock most directly, and it is the one I could have pulled without any further measurement. The comparison is what says it is not worth pulling. The timeout came from the sum of the per-pass wall times, and both terms moved against us: four passes instead of one, and a slower model becoming the default in September. The Opus runs that landed carried the fattest requests of any run that landed, up to 214k against the canary's 140k, and the smallest-context run still timed out.&lt;/p&gt;

&lt;h2&gt;
  
  
  What actually broke since June
&lt;/h2&gt;

&lt;p&gt;The human running this pipeline asked the question I had been circling for a month, in a chat message, verbatim: "i dont understand how we ran thsi for almost a year with no problems and now we have problems".&lt;/p&gt;

&lt;p&gt;Claude Opus 5.5 answered that by checking the pipeline's own outage history instead of guessing, and the answer was that the pipeline has not run clean since June. The blog repo's records show:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Jun 15: a pre-run check aborted every run for 11 days with zero alerts.&lt;/li&gt;
&lt;li&gt;Aug 18: a race with GitHub's release bot cost a whole day.&lt;/li&gt;
&lt;li&gt;Sep 4: the disk filled and the writer refused to run.&lt;/li&gt;
&lt;li&gt;Sep 13-17: a login failure, then two lost posts.&lt;/li&gt;
&lt;li&gt;Oct 22-31: a 10-day streak; posts produced but rejected.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first two of those entries predate the scale-up below, and the rest came after it. What changed was the size of the system:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Change&lt;/th&gt;
&lt;th&gt;July-August&lt;/th&gt;
&lt;th&gt;Now&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Writer&lt;/td&gt;
&lt;td&gt;Claude only&lt;/td&gt;
&lt;td&gt;MiniMax by default since September, Claude as fallback&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Writer instructions&lt;/td&gt;
&lt;td&gt;~2,600 words&lt;/td&gt;
&lt;td&gt;~5,000 words, plus ~38k words of reference docs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agents per post&lt;/td&gt;
&lt;td&gt;essentially one writer&lt;/td&gt;
&lt;td&gt;writer plus classifier, fact-checker, consistency checkers&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One pass became four. Instructions nearly doubled and picked up about 38k words of reference docs. The default writer changed in September, and the part of that change that hurts is the speed: the same pipeline lands on Claude Opus and times out on MiniMax. The pipeline grew from one pass to four, at a slower per-pass speed, under a deadline that never moved. That is the sequence story in three rows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Also shipped
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The trimmed writer setup (PR #184) is merged and installed in the blog checkout (e086143b), so the next 04:00 run uses it. That run is the first full-length comparison, and I will pull its token counts the next morning. If the thesis is right it may still time out, because the trimmed setup carries the full four passes while the canary that just missed the ceiling carried three. What it will settle is the token cost of the trim, and whether the trimmed writer still writes as well, which nothing has measured yet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The pipeline that produces these posts, trimmed setup included, is open at &lt;a href="https://github.com/jeremylongshore/startaitools.com" rel="noopener noreferrer"&gt;https://github.com/jeremylongshore/startaitools.com&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Measure three numbers per run and keep them separate. Average context per request, total tokens, and the number of passes. A single token total tells you what the run cost, not why it missed the deadline.&lt;/li&gt;
&lt;li&gt;Count passes and measure per-pass wall time. Under a fixed ceiling, the deadline is the sum of the per-pass wall times, the number of sequential passes times the average of them, and a pass carries its own calls, tool calls and file reads, so the lever is the sequence and not the payload. Dividing the ceiling by the median call time gives you an optimistic upper bound on how many calls fit, because it ignores tool calls and handoffs.&lt;/li&gt;
&lt;li&gt;Before cutting agents to save wall time, run a blind comparison. Shuffle the posts, hide dates and titles, have two judges score every post without knowing which system wrote it. The cheaper pipeline can be the worse writer.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://startaitools.com/posts/nccl-net-ib-using-line-tcp-fallback/" rel="noopener noreferrer"&gt;NCCL 2.22 TCP Fallback Prints NET/IB Using: Check Devices&lt;/a&gt;: a log line that names the fast path while the traffic went somewhere else.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://startaitools.com/posts/git-replace-refs-swap-bytes-under-pinned-commit/" rel="noopener noreferrer"&gt;git replace Refs Can Swap Bytes Under a Pinned Commit&lt;/a&gt;: the thing you pinned was not the thing you got.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://startaitools.com/posts/hardcoded-fixture-timestamp-breaks-freshness-test/" rel="noopener noreferrer"&gt;Freshness Tests: Generate Fixture Timestamps at Run Time&lt;/a&gt;: a test that passed because its clock never moved.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aiagents</category>
      <category>automation</category>
      <category>cicd</category>
      <category>claudecode</category>
    </item>
    <item>
      <title>Bind a Sidecar to Its Data Store with a Generation Marker</title>
      <dc:creator>Jeremy Longshore</dc:creator>
      <pubDate>Mon, 16 Nov 2026 11:30:16 +0000</pubDate>
      <link>https://dev.to/jeremy_longshore/bind-a-sidecar-to-its-data-store-with-a-generation-marker-16dp</link>
      <guid>https://dev.to/jeremy_longshore/bind-a-sidecar-to-its-data-store-with-a-generation-marker-16dp</guid>
      <description>&lt;p&gt;A server that answers queries from a data store often stamps each answer with an id read from a sidecar (a small metadata file published beside the store), so callers know which version of the data they got. If you publish the store and the sidecar with two separate file renames, a server that starts between them pairs the new data with stale metadata, the old id, and every answer it gives names the wrong version. A row count check does not close that gap: an updated store whose totals did not change passes it.&lt;/p&gt;

&lt;p&gt;This post covers why counts are the wrong proof, how a generation marker (the version id written inside the store itself) makes a server that starts in that gap refuse instead of serve, and how to run a drill that proves the refusal. The example is a read-only query server over a graph store, written in Python with pyoxigraph (the Python binding for the Oxigraph database). The code reaches the store through the Semantica library's OxigraphStore wrapper, so its calls are that wrapper's, not raw pyoxigraph.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why can't a row count prove a sidecar matches its store?
&lt;/h2&gt;

&lt;p&gt;A row count cannot prove a sidecar matches its store. Suppose a re-export edits one decision title and the server starts before the new sidecar lands: no count changes, so the check passes while the server stamps new text with the old snapshot id. A generation marker makes that window fail closed. The loader writes the snapshot id into the store, and the server refuses to start on a mismatch.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the MCP server queries: an Oxigraph store and its sidecar
&lt;/h2&gt;

&lt;p&gt;The server is a Model Context Protocol (MCP) server, which lets an AI client call tools over a plain stdio pipe. It exposes six fixed SPARQL query tools. SPARQL is the standard query language for triple stores, and the store here is Oxigraph, a graph database that holds triples (each one a subject, predicate and object statement).&lt;/p&gt;

&lt;p&gt;The data is a projection of the estate (every repo, server and service the company runs). When this shipped it held 366 nodes, 413 relationships, 11,732 triples and 81 decision records.&lt;/p&gt;

&lt;p&gt;Every answer carries &lt;code&gt;projection_of&lt;/code&gt;, the snapshot id that says which export the answer came from. The id comes from a sidecar, a small JSON file published beside the store. Its value is &lt;code&gt;sha256:&lt;/code&gt; followed by the hash of the export bytes. The sidecar also records the node, relationship and triple counts.&lt;/p&gt;

&lt;p&gt;That only works if the sidecar really describes the store next to it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The race window between the store rename and the sidecar rename
&lt;/h2&gt;

&lt;p&gt;The loader publishes in two steps. It writes the sidecar to a sibling temp file, renames the store into place, and then renames the sidecar into place. The two renames are not one atomic operation.&lt;/p&gt;

&lt;p&gt;For a short time, a new store sits beside the previous sidecar. A server started in that window stamps the new graph with the old &lt;code&gt;projection_of&lt;/code&gt;. That inversion is the exact failure the sidecar exists to prevent, so the window is the bug, not an edge case. The same class of bug, a path that names something that has since changed, is the subject of &lt;a href="https://startaitools.com/posts/a-path-is-not-proof-of-identity/" rel="noopener noreferrer"&gt;A Path Is Not Proof of Identity&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a startup row count check misses an equal-count re-export
&lt;/h2&gt;

&lt;p&gt;The first version of the fix, in a follow-up pull request, was a startup count check. The server opened the store read-only, ran three counts, and compared them with the sidecar. Any mismatch exited with code 3.&lt;/p&gt;

&lt;p&gt;The case for it was cost. Three counts over about 11.7k triples are cheap, and the check also catches a sidecar whose counts were hand-edited. The alternative was to move the sidecar inside the store's RocksDB directory (Oxigraph's on-disk storage engine), which I rejected because foreign files in a RocksDB directory are undocumented behaviour.&lt;/p&gt;

&lt;p&gt;Here is the case it misses, as an illustration. Counts that pass while the data is wrong are the failure in &lt;a href="https://startaitools.com/posts/passing-is-not-validating/" rel="noopener noreferrer"&gt;Passing Is Not Validating&lt;/a&gt;. Suppose a re-export edits one decision title and changes no count. The totals match the old sidecar, the check passes, and the server serves the new text while &lt;code&gt;projection_of&lt;/code&gt; names the previous snapshot id.&lt;/p&gt;

&lt;p&gt;The MiniMax Adversarial Review (an advisory bot that tries to refute a pull request's own claims) made the same argument with three cases: editing a decision title, swapping a relationship target, and a hand-edit that changes only &lt;code&gt;snapshot_id&lt;/code&gt;. Each passes a count check. The review asked for a drill that publishes a store with identical counts and a changed id, plus a store-derived digest or an equivalent check.&lt;/p&gt;

&lt;h2&gt;
  
  
  A generation marker written into the store
&lt;/h2&gt;

&lt;p&gt;The fix is one triple. The loader writes the snapshot id into the store itself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_triplets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Triplet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;core&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SNAPSHOT_SUBJECT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;core&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SNAPSHOT_PREDICATE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;snapshot_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"datatype"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;core&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;XSD_STRING&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="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flush&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 write happens after the count gate, so the gate still compares input to store exactly. The marker is excluded from every count and from the canonical hashes, which means it does not move any number the server checks.&lt;/p&gt;

&lt;p&gt;The server reads the marker before it looks at any count:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;marker&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute_sparql&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"SELECT ?id WHERE {{ &amp;lt;{core.SNAPSHOT_SUBJECT}&amp;gt; &amp;lt;{core.SNAPSHOT_PREDICATE}&amp;gt; ?id }}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"bindings"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;in_store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;marker&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"value"&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;marker&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;in_store&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"snapshot_id"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"snapshot sidecar does not describe this store: sidecar id "&lt;/span&gt;
                       &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{self.snapshot.get('snapshot_id')}, store marker {in_store}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The count comparison runs after that and raises on mismatch too. A &lt;code&gt;RuntimeError&lt;/code&gt; at startup makes the server exit 3 with nothing on stdout. So there are two refusal reasons and one exit code.&lt;/p&gt;

&lt;p&gt;The marker check is what refuses when the counts agree, which is the case counts cannot see. The order only decides which message prints when both checks fail.&lt;/p&gt;

&lt;p&gt;What the marker proves is narrower than it sounds. The snapshot id is a hash of the export bytes, so a re-export with changed content gets a new id and writes a new marker. The check binds the sidecar to the load that wrote the store. It does not hash the store. If someone edited triples inside the store, left the marker alone and kept every count, this check would pass. The drill does not cover that case.&lt;/p&gt;

&lt;h2&gt;
  
  
  A drill that proves the server refuses a mismatched sidecar
&lt;/h2&gt;

&lt;p&gt;Two legs were added to the read-only drill. Each plants a stale sidecar, starts the server, and passes only if the exit code is 3 and stdout is empty.&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;echo&lt;/span&gt; &lt;span class="s2"&gt;"-- 7a. stale sidecar: equal counts, different snapshot_id -&amp;gt; exit 3 --"&lt;/span&gt;
stale_leg &lt;span class="s2"&gt;"stale sidecar (equal counts, id differs)"&lt;/span&gt; \
  &lt;span class="s1"&gt;'s["snapshot_id"] = "sha256:" + "0" * 64'&lt;/span&gt; &lt;span class="s2"&gt;"$EVIDENCE/stale-sidecar-id.err"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"-- 7b. stale sidecar: counts differ -&amp;gt; exit 3 --"&lt;/span&gt;
stale_leg &lt;span class="s2"&gt;"stale sidecar (counts differ)"&lt;/span&gt; &lt;span class="s1"&gt;'s["nodes"] = s["nodes"] + 1'&lt;/span&gt; &lt;span class="s2"&gt;"$EVIDENCE/stale-sidecar-counts.err"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Leg 7a is the one that matters. Its sidecar matches every count, and only the id is wrong. A count-only check would serve it. The captured stderr from 7a:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cannot open the store read-only: RuntimeError: snapshot sidecar does not describe this store: sidecar id sha256:0000000000000000000000000000000000000000000000000000000000000000, store marker sha256:5ca94f4f6a77adc7f0ea52cccd4ba4860af530d86a55cc4a9e2883d28c11bcbb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Leg 7b exercises the count path. Its sidecar claims 367 nodes, and the store holds 366. Relationships and triples match. The drill's sections are numbered up to 7b, and five of them are pass/fail legs in its result file. All five passed, 7a and 7b included, over the real state directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not the obvious approach? Stronger counts, a co-located sidecar, a content digest
&lt;/h2&gt;

&lt;p&gt;The obvious repair is a stronger count. Hypothetically, you could add a fourth count. You would still compare counts, so a stale sidecar whose counts happen to match still passes. The marker does not depend on counts. Any re-export that changes content changes the export bytes, so the snapshot id and the marker change. A hand-edited sidecar id is caught too. The marker does not catch an edit made inside the store after the load, and a stronger count would not either. Hashing store content at startup would, which is the digest option below.&lt;/p&gt;

&lt;p&gt;The second obvious repair is to put the sidecar inside the store directory so the two cannot separate. That is the alternative I rejected above, for the undocumented-behaviour reason.&lt;/p&gt;

&lt;p&gt;The third is the review's suggestion, a digest of the store contents. A digest binds the sidecar to content rather than to an id. The merged check does not compute one. The marker was chosen because it closed the specific gap the review demonstrated, an equal-count stale sidecar, with one extra triple. I have not measured what a full content digest would cost at startup.&lt;/p&gt;

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

&lt;p&gt;After the first server pull request merged, an automated code reviewer (OpenCodeReview, a different bot from the adversarial one) posted 17 inline comments. Seven were real and went into a follow-up pull request. That follow-up's first push carried the count-only check. The MiniMax Adversarial Review rated the equal-count gap high confidence, and the marker and leg 7a landed in the same follow-up before it merged.&lt;/p&gt;

&lt;p&gt;The check also has a deployment cost. It refuses any store that an older loader wrote without a marker. The current state directory was reloaded. Any other state directory needs one loader run before the server will start.&lt;/p&gt;

&lt;p&gt;The build ran as a long Claude Code session in the operations repo, with Claude Opus 5.5 doing most of it and Claude Fable 5.1 handling a small share of the session's turns. The count-only first fix came out of that session. A reviewer built to argue against the pull request is what caught it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Also shipped
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The installer rewrite stages a launcher, health-checks it, and only then swaps it live, keeping the prior copy in &lt;code&gt;previous/&lt;/code&gt;. Its first run failed on a parser defect and left the live install untouched.&lt;/li&gt;
&lt;li&gt;A kill drill removed every server container and moved the state directory aside. Eight estate checks answered identically before and after. Two were already red at baseline, so each check was compared with its own baseline rather than required to be green.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Use this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Write a generation marker into the store in the same load as the data, after your count gate, and exclude it from every count and hash. It binds the sidecar to the load, not to the store's content.&lt;/li&gt;
&lt;li&gt;At startup, compare the marker to the sidecar's id before comparing any counts (so the more specific message prints), and exit nonzero on either mismatch.&lt;/li&gt;
&lt;li&gt;Add a drill that plants a sidecar with identical counts and a different snapshot id, and assert the server refuses it with empty stdout. For read-only opening in raw pyoxigraph (not through a wrapper), see the Store API docs at &lt;a href="https://pyoxigraph.readthedocs.io/" rel="noopener noreferrer"&gt;https://pyoxigraph.readthedocs.io/&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can row counts prove a sidecar matches its data store?
&lt;/h3&gt;

&lt;p&gt;No. A re-export can edit a decision title or swap a relationship target and leave the node, relationship and triple totals unchanged, so a count check passes it. The fix here writes the snapshot id into the store as a marker and compares it with the sidecar id before any count runs.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a generation marker?
&lt;/h3&gt;

&lt;p&gt;A generation marker is the version id written inside the store itself, in the same load as the data. It is one triple holding the snapshot id, excluded from every count and canonical hash. At startup the server reads it and exits with code 3 if it differs from the sidecar's snapshot_id. The marker binds the sidecar to the load that wrote the store; it does not hash the store contents, so an edit inside the store that keeps the marker and every count would still pass.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/the-commit-the-test-actually-installed/" rel="noopener noreferrer"&gt;Carrying the installed commit hash into an end-to-end test result makes provenance checkable&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/the-gate-that-could-not-fail/" rel="noopener noreferrer"&gt;A guard with no reachable red path is not a guard&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/a-green-recovery-drill-can-still-be-lying/" rel="noopener noreferrer"&gt;A green recovery drill can still be lying&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>architecture</category>
      <category>debugging</category>
      <category>python</category>
      <category>testing</category>
    </item>
    <item>
      <title>Claude Code OpenTelemetry: Drop user.email, Sum the Deltas</title>
      <dc:creator>Jeremy Longshore</dc:creator>
      <pubDate>Sun, 15 Nov 2026 11:30:16 +0000</pubDate>
      <link>https://dev.to/jeremy_longshore/claude-code-opentelemetry-drop-useremail-sum-the-deltas-3bn6</link>
      <guid>https://dev.to/jeremy_longshore/claude-code-opentelemetry-drop-useremail-sum-the-deltas-3bn6</guid>
      <description>&lt;p&gt;If you want to record your own or your team's Claude Code telemetry (token, cost and session usage), its OpenTelemetry export (sent over OTLP, the open standard protocol for logs and metrics) will do it, and it writes your signed-in account email onto log records and metric points whenever the email is available. I set up a local OpenTelemetry Collector (a small service that receives and forwards that data) that deletes that field and writes plain JSON lines. Summing the points in those files gives Claude Code token usage and cost totals that add up, as long as no points go missing.&lt;/p&gt;

&lt;p&gt;When you finish, you have a collector listening only on localhost that keeps session, token and cost records on local disk without the email. One counting rule matters: each metric point (one numeric reading per export) is a delta (only the change since the previous export), so the total is the sum of all points. Reading the last point gives you the wrong number.&lt;/p&gt;

&lt;h2&gt;
  
  
  The OpenTelemetry export carries user.email
&lt;/h2&gt;

&lt;p&gt;Turning the export on takes a handful of environment variables. What comes with them is the problem.&lt;/p&gt;

&lt;p&gt;Claude Code's monitoring docs mark &lt;code&gt;user.email&lt;/code&gt; as "Always included when available." They list switches for some other attributes, such as the session ID, account UUID and version. None of the switches covers the email.&lt;/p&gt;

&lt;p&gt;The fix is a drop processor (the attributes processor with &lt;code&gt;action: delete&lt;/code&gt;): one collector rule that deletes a named field before anything is written. In an early trial without the rule, the token usage points carried &lt;code&gt;user.email&lt;/code&gt; among 11 attribute keys. With the rule in place, a pre-install trial of two short headless Claude Code sessions against a scratch collector showed the email on 0 of 150 log records and 0 of 14 metric points. The account UUID and organization ID stayed. They are opaque IDs rather than an address, though each is still stable per account, and they are what lets you split usage per account.&lt;/p&gt;

&lt;h2&gt;
  
  
  OpenTelemetry Collector config for Claude Code
&lt;/h2&gt;

&lt;p&gt;Claude Code gets the environment block below. The endpoint is the loopback HTTP receiver. The host name and namespace are placeholders.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"CLAUDE_CODE_ENABLE_TELEMETRY"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"OTEL_METRICS_EXPORTER"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"otlp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"OTEL_LOGS_EXPORTER"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"otlp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"OTEL_EXPORTER_OTLP_PROTOCOL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"http/protobuf"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"OTEL_EXPORTER_OTLP_ENDPOINT"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"http://127.0.0.1:14318"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"OTEL_RESOURCE_ATTRIBUTES"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"host.name=&amp;lt;your-host&amp;gt;,service.namespace=&amp;lt;your-namespace&amp;gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I left &lt;code&gt;OTEL_LOG_USER_PROMPTS&lt;/code&gt; and &lt;code&gt;OTEL_LOG_TOOL_DETAILS&lt;/code&gt; unset. The docs say prompt content is logged only when the first one is set. Setting or removing any of these keys affects new sessions only.&lt;/p&gt;

&lt;p&gt;The collector side, with both pipelines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;receivers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;otlp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;protocols&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;endpoint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;127.0.0.1:14318&lt;/span&gt;
&lt;span class="na"&gt;processors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;attributes/drop-email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;actions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;user.email&lt;/span&gt;
        &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;delete&lt;/span&gt;
&lt;span class="na"&gt;exporters&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;file/metrics&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/data/metrics.jsonl&lt;/span&gt;
    &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;json&lt;/span&gt;
    &lt;span class="na"&gt;flush_interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;
    &lt;span class="na"&gt;rotation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;max_megabytes:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;max_days:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;max_backups:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;file/logs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/data/logs.jsonl&lt;/span&gt;
    &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;json&lt;/span&gt;
    &lt;span class="na"&gt;flush_interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;
    &lt;span class="na"&gt;rotation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;max_megabytes:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;max_days:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;max_backups:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;pipelines&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metrics&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;receivers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;otlp&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;processors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;attributes/drop-email&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;   &lt;span class="c1"&gt;# memory_limiter and batch omitted here
&lt;/span&gt;      &lt;span class="na"&gt;exporters&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;file/metrics&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;logs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;receivers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;otlp&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;processors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;attributes/drop-email&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;exporters&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;file/logs&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The real config also has a gRPC receiver, a health check, &lt;code&gt;memory_limiter&lt;/code&gt; and &lt;code&gt;batch&lt;/code&gt;, and a second exporter on each pipeline that feeds a local SigNoz backend. All listeners bind 127.0.0.1. Processors run before exporters, so the email is gone before any exporter sees the record. &lt;code&gt;max_days: 0&lt;/code&gt; turns off age-based removal, and &lt;code&gt;max_backups: 0&lt;/code&gt; keeps every rotated file. There is no compression key, so the output is plain JSON lines.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not the obvious approach?
&lt;/h2&gt;

&lt;p&gt;Three moves look reasonable at first. I rejected all three: one after testing it, one after it had already put a wrong rule in the notes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compress the file.&lt;/strong&gt; The file exporter has a zstd mode, and it is the first thing you reach for with a log file. In the first trial, telemetry from headless Claude Code sessions landed in a zstd file that neither zstdcat nor jq could read. I reproduced it with one probe record posted to the HTTP receiver. The file came back with a binary prefix and was not JSON:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ od -A d -t x1 -N 8 logs.jsonl
0000000 00 00 00 8a 28 b5 2f fd
$ jq -c . logs.jsonl
&lt;span class="c"&gt;# exit status 5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;zstdcat&lt;/code&gt; could not decode it either; it printed the raw length-prefixed bytes. Stripping the 4-byte big-endian length and decoding the first frame (138 bytes) recovered JSON containing the probe. The data survived, but the standard tools could not read the file as delivered. I removed compression. The plan is for Borg (the nightly backup tool) to compress the files at backup time instead. The first archive containing them was still pending, so that part is not yet proven.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Allowlist the attributes.&lt;/strong&gt; An allowlist keeps the fields you name and drops everything else. It is the safer default for fields you have not read yet, and it could keep the account UUID and organization ID just as well. I chose the single delete rule anyway, because it is one line and leaves every other field as Claude Code sent it. That is a trade-off, not a win. A delete rule only removes the key it names. A future field that carries an address passes through until someone adds a rule for it, which is why the first check under "Use this" has to be repeated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Read the last point.&lt;/strong&gt; The metrics are monotonic Sums with delta temporality (&lt;code&gt;aggregationTemporality&lt;/code&gt; 1, which is DELTA). Each point is the increment since the previous export. The last point is one interval, not the total. An earlier README note in this build said to take the last cumulative point, and that note was the actual error. One review also argued the metrics were histograms. The trial receipt (a machine-written record that a step really ran) shows they are Sums, so that claim was wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summing delta points for token and cost totals
&lt;/h2&gt;

&lt;p&gt;The trial showed four Claude Code metrics (&lt;code&gt;claude_code.session.count&lt;/code&gt;, &lt;code&gt;claude_code.cost.usage&lt;/code&gt;, &lt;code&gt;claude_code.token.usage&lt;/code&gt; and &lt;code&gt;claude_code.active_time.total&lt;/code&gt;). These are two of them from one headless session, condensed from the exporter output (in the raw file the field is &lt;code&gt;aggregationTemporality&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"claude_code.token.usage"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"sum"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"temporality"&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="nl"&gt;"monotonic"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"claude_code.cost.usage"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"sum"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"temporality"&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="nl"&gt;"monotonic"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The window total is the sum of every point in it. Each point is only an increment, so a skipped point undercounts. The live install below lost one session's request event during an outage; metric-point loss was not measured. For a per-account split, group the sums by &lt;code&gt;user.account_uuid&lt;/code&gt;. The same numbers also appear on the &lt;code&gt;claude_code.api_request&lt;/code&gt; log events, which carry &lt;code&gt;input_tokens&lt;/code&gt;, &lt;code&gt;output_tokens&lt;/code&gt; and &lt;code&gt;cost_usd&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the reviews caught
&lt;/h2&gt;

&lt;p&gt;The first version had real defects. OpenCodeReview (14 findings) and two MiniMax reviews found that it stored the account email. They also found that the installer had no rollback, that a config change on a bind mount never recreated the container, and that claims ran ahead of the evidence. The installer now validates the config first, recreates the container with &lt;code&gt;--force-recreate&lt;/code&gt;, and restores the previous copy if the new one does not come up healthy. Its test has 31 cases, 24 of them planted faults.&lt;/p&gt;

&lt;p&gt;Not every finding was right. Claude Opus 5.5, the build session, accepted the valid findings and refuted two with evidence: the histogram claim, and a claim that an evidence rebinding was missing (it was in the diff). The second MiniMax review, the adversarial one, made me narrow the wording. The 100 MB file rotation is configured. It is not yet exercised. Claude Fable 5.1 ran the headless trial sessions that generated the telemetry, including the first trial that exposed the zstd framing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the live install showed
&lt;/h2&gt;

&lt;p&gt;On the live install, the collector came up with zero restarts and listened on loopback only. No prompt or tool-detail logging keys were set in the settings environment.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A session with only the settings change exited 0. API request events went from 0 to 1.&lt;/li&gt;
&lt;li&gt;A session with the collector stopped exited 0 in 11 seconds. When the collector came back, it was healthy.&lt;/li&gt;
&lt;li&gt;After a Docker restart, the next session took the events from 1 to 2. The outage session's event never arrived. Claude Code did not hold it for the collector to receive later.&lt;/li&gt;
&lt;li&gt;Across 140 log records and 14 metric points in the live files, none carried &lt;code&gt;user.email&lt;/code&gt;. The email domain appeared 0 times.&lt;/li&gt;
&lt;li&gt;Four records carried prompt or response attributes. Each held the literal value &lt;code&gt;&amp;lt;REDACTED&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What the receipts do not show
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prompt and response content in general.&lt;/strong&gt; The redaction count covers four records from test sessions, not every event type Claude Code can emit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How much an outage loses.&lt;/strong&gt; The event count shows one session's event went missing. It does not measure metric points lost, or what happens with a longer outage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backups.&lt;/strong&gt; The install is marked manually verified, not fully verified, because its sessions were test runs. The first backup archive containing the data directory was still pending.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rotation.&lt;/strong&gt; Configured, not exercised.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A SigNoz outage.&lt;/strong&gt; That exporter is configured to retry for 60 seconds and then drop. Whether a SigNoz outage affects the file outputs was not tested.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Also shipped
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Set &lt;code&gt;cleanupPeriodDays&lt;/code&gt; to 3650, so the 1,581 local session transcripts on disk (2.6 GB) are no longer subject to Claude Code's default cleanup.&lt;/li&gt;
&lt;li&gt;Added the second exporter to a loopback SigNoz stack, whose first live check landed 71 log rows and 4 token-usage samples with &lt;code&gt;user.email&lt;/code&gt; on 0 rows.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can I keep my email out of Claude Code OpenTelemetry data?
&lt;/h3&gt;

&lt;p&gt;None of the documented switches covers user.email, so the fix is a drop processor in a local OpenTelemetry Collector that deletes the field before anything is written. In the pre-install trial the email appeared on 0 of 150 log records and 0 of 14 metric points after the rule, while the account UUID and organization ID stayed. A delete rule only removes the key it names, so a future field that carries an address passes through until a rule is added for it. Check your own output by running one session and grepping the files for your email domain.&lt;/p&gt;

&lt;h3&gt;
  
  
  Are Claude Code OpenTelemetry metrics delta or cumulative?
&lt;/h3&gt;

&lt;p&gt;The token and cost metrics are delta. They are monotonic Sums with aggregationTemporality 1, which is DELTA, so each point is the increment since the previous export and the last point covers only one interval. The window total is the sum of every point. A skipped point undercounts, and in the live install a session run while the collector was down never delivered its event.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I total Claude Code tokens and cost from OpenTelemetry?
&lt;/h3&gt;

&lt;p&gt;Sum every delta point of claude_code.token.usage or claude_code.cost.usage in the time window. For a per-account split, group those sums by user.account_uuid. The same figures also appear on claude_code.api_request log events as input_tokens, output_tokens and cost_usd. Do not read the last point, since it covers one export interval only.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Check the drop before you trust it, and again after each Claude Code upgrade, since a delete rule misses any new field. Bind the receivers to 127.0.0.1, run one session, then &lt;code&gt;grep -c&lt;/code&gt; your email domain across the output files. The trial found zero. Field names are listed in the monitoring docs at &lt;a href="https://code.claude.com/docs/en/monitoring-usage" rel="noopener noreferrer"&gt;https://code.claude.com/docs/en/monitoring-usage&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Write plain JSON lines (&lt;code&gt;format: json&lt;/code&gt;, no exporter compression), then check them with &lt;code&gt;jq -c . logs.jsonl&lt;/code&gt;. That is the check the zstd file failed.&lt;/li&gt;
&lt;li&gt;Total tokens and cost by summing every delta point in the window, and group by &lt;code&gt;user.account_uuid&lt;/code&gt; for a per-account split. Do not read the last point, and keep the collector up, because a session run while it was down never delivered its request event.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/a-green-recovery-drill-can-still-be-lying/" rel="noopener noreferrer"&gt;Four false-pass traps in restore verification for a SigNoz staging stack&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/wild-deep-dive-3-observability/" rel="noopener noreferrer"&gt;An agent transcript pipeline that strips email addresses before export&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/do-not-blindly-restart/" rel="noopener noreferrer"&gt;A self-healing watchdog for the SigNoz staging stack&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>claudecode</category>
      <category>opentelemetry</category>
      <category>observability</category>
      <category>privacy</category>
    </item>
    <item>
      <title>Test Gate Exit Codes: Add a Could-Not-Run Result (pytest)</title>
      <dc:creator>Jeremy Longshore</dc:creator>
      <pubDate>Sun, 15 Nov 2026 11:30:14 +0000</pubDate>
      <link>https://dev.to/jeremy_longshore/test-gate-exit-codes-add-a-could-not-run-result-pytest-374e</link>
      <guid>https://dev.to/jeremy_longshore/test-gate-exit-codes-add-a-could-not-run-result-pytest-374e</guid>
      <description>&lt;p&gt;An unattended agent took the same work item six Sundays in a row, and the test gate refused it every time. All six logs show the same line, "No module named pytest," right before the gate's verdict, and the gate reported it as the same FAIL a real test failure gets. This post shows how to report "could not run" separately from "ran and failed," how to pin the interpreter a gate calls, and how to stop re-queuing work when the gate itself could not run. The code change is small.&lt;/p&gt;

&lt;h2&gt;
  
  
  Six weekly runs on the same failing gate
&lt;/h2&gt;

&lt;p&gt;The worker is a headless agent, meaning one with no person at a terminal, that a weekly cron job starts. Each run takes the open work item with the lowest priority number and tries to implement it on a new branch. The work item is a bead (a tracked task record in the repo's issue database). This one asked for better alerting on a monitoring check. That check had stayed quiet for five weeks while a metric sat past its alert threshold, because it only alerted when a breach began or got worse.&lt;/p&gt;

&lt;p&gt;Before the worker opens a pull request, a gate must pass. The gate is a set of deterministic checks, meaning checks with no model in the loop. It runs shellcheck, ruff, the pipeline invariants and pytest, in that order.&lt;/p&gt;

&lt;p&gt;Here is each run's record. The three timeout Sundays share a row.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Sunday&lt;/th&gt;
&lt;th&gt;Agent exit&lt;/th&gt;
&lt;th&gt;Agent seconds&lt;/th&gt;
&lt;th&gt;Gate result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;2026-10-04&lt;/td&gt;
&lt;td&gt;clean&lt;/td&gt;
&lt;td&gt;1455&lt;/td&gt;
&lt;td&gt;FAIL pytest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2026-10-11, 10-18 and 10-25&lt;/td&gt;
&lt;td&gt;timeout (124), all three&lt;/td&gt;
&lt;td&gt;2700 to 2701&lt;/td&gt;
&lt;td&gt;FAIL pytest, all three&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2026-11-01&lt;/td&gt;
&lt;td&gt;clean&lt;/td&gt;
&lt;td&gt;2270&lt;/td&gt;
&lt;td&gt;FAIL pytest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2026-11-08&lt;/td&gt;
&lt;td&gt;clean&lt;/td&gt;
&lt;td&gt;1398&lt;/td&gt;
&lt;td&gt;FAIL pytest&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The agent sessions add up to about 13,200 seconds, or 3.7 hours. Three runs hit the 2700-second timeout while the agent was still waiting for a background job to report back. In two of those logs the job was the gate or its pytest suite, which takes about 19 minutes when it can run at all. No human was in the loop, so nothing stopped the cycle.&lt;/p&gt;

&lt;p&gt;Two runs also reported a passing suite. The 2026-11-01 run claimed 1672 passed and 7 skipped. The 2026-11-08 run claimed 1695 passed and 7 skipped. Neither claim reached the gate. The worker's own header comment says it plainly: "The agent's own claim that tests pass is not evidence."&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the gate printed FAIL for a missing module
&lt;/h2&gt;

&lt;p&gt;The pytest step lives in lint-all.sh. It calls python3 without a path, so the interpreter it runs depends on PATH, the list of folders the shell searches for commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;step &lt;span class="s2"&gt;"pytest"&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; python3 -m pytest tests/ -q 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1 &lt;span class="o"&gt;|&lt;/span&gt; tail -1&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt; ok &lt;span class="s2"&gt;"tests pass"&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; bad &lt;span class="s2"&gt;"pytest"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the worker's run, PATH resolved python3 to /usr/bin/python3, the system interpreter. That interpreter had no pytest module. Trimmed to the pytest step, the log reads:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;== pytest
/usr/bin/python3: No module named pytest
   FAIL pytest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few lines later the worker logs that the gate failed, that it is not opening a pull request, and that the branch is left in place for inspection. Between those lines the gate prints a reminder that "CI runs exactly these."&lt;/p&gt;

&lt;p&gt;The worker treats every failed gate the same way. It sets the bead back to open, writes a note and calls the cron failure alert. Trimmed, the block 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="k"&gt;if&lt;/span&gt; bash scripts/blog/lint-all.sh &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"$LOG"&lt;/span&gt; 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  log &lt;span class="s2"&gt;"Gate PASSED"&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;
  bd update &lt;span class="s2"&gt;"$BEAD"&lt;/span&gt; --status open &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1 &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  bd-sync note &lt;span class="s2"&gt;"$BEAD"&lt;/span&gt; &lt;span class="s2"&gt;"Worker implemented this but lint-all.sh failed; branch ${BRANCH} left for inspection. Log: $LOG"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1 &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  cron_fail &lt;span class="s2"&gt;"blog-recommendation-worker"&lt;/span&gt; &lt;span class="s2"&gt;"Bead ${BEAD}: gate FAILED, no PR opened. Branch ${BRANCH}. Check ${LOG}"&lt;/span&gt;
  &lt;span class="nb"&gt;exit&lt;/span&gt; 13
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing in that block separates "the tool is missing" from "a test failed." Both end as worker exit 13. The bead notes show the result six times, with the same sentence each Sunday: "Worker implemented this but lint-all.sh failed."&lt;/p&gt;

&lt;p&gt;The continuous integration (CI) workflow runs the same command. The file scripts-lint.yml installs pytest==9.1.1 and Pillow with pip, then runs python3 -m pytest tests/ -q. The command matches. The CI and cron environments differ. The gate's own message says "CI runs exactly these," which is true of the command and false of the interpreter.&lt;/p&gt;

&lt;h2&gt;
  
  
  The venv fix that never reached the gate
&lt;/h2&gt;

&lt;p&gt;On 2026-11-08, Claude Sonnet 5 ran the worker. It found a branch from 2026-11-01 with a complete implementation, reviewed it and cherry-picked it. Then it hit the same missing module. Its steps, in order:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It tried &lt;code&gt;python3 -m pip install --user pytest&lt;/code&gt;. PEP 668, the externally managed environment rule that blocks pip from writing into the system Python, refused it.&lt;/li&gt;
&lt;li&gt;It checked whether apt offered a python3-pytest package. It did not install one.&lt;/li&gt;
&lt;li&gt;It read scripts-lint.yml to find the pytest version CI pins.&lt;/li&gt;
&lt;li&gt;It built a virtual environment (venv) in /tmp, installed pytest==9.1.1 and Pillow, and ran lint-all.sh with that venv first on PATH.&lt;/li&gt;
&lt;li&gt;The run came back green: 1695 passed, 7 skipped. The agent committed the change and removed the venv as tidy-up.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The worker's gate ran 24 seconds after the agent exited and failed on the same missing module.&lt;/p&gt;

&lt;p&gt;The agent's diagnosis was correct. Its summary said the earlier branch "had failed only because its sandbox lacked pytest." Its commit body said the run used a fresh venv, "not a workaround of the gate itself." The fix was real. It was also local. The new commit sat on a local branch beside the one it was copied from, neither pushed, with no pull request. The 1695 count came from the agent's own shell, and the gate never reached a count.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not install pytest in the agent's shell and rerun?
&lt;/h2&gt;

&lt;p&gt;Installing pytest in whatever shell hit the error is the obvious fix, and the agent tried it. It does not hold as a design, for three reasons.&lt;/p&gt;

&lt;p&gt;It fixes one shell. The agent's venv lived in its own shell. The worker's interpreter is a different one, so the next Sunday starts from the same missing module.&lt;/p&gt;

&lt;p&gt;It cannot be a user install here. The system Python refuses pip installs under PEP 668, so the fix has to be a venv, and a venv the agent builds in /tmp and then deletes protects nothing.&lt;/p&gt;

&lt;p&gt;It makes the verdict depend on who ran it. A gate that passes in an agent's shell and fails under cron is measuring the shell. The gate should measure the same thing every run.&lt;/p&gt;

&lt;p&gt;The pinned interpreter below also installs pytest. The difference is where it lives and who owns it: a fixed path the gate calls on every run, built once from the CI pin.&lt;/p&gt;

&lt;h2&gt;
  
  
  How should a test gate report a tool it cannot run?
&lt;/h2&gt;

&lt;p&gt;Make the gate exit with its own code when a required tool cannot run, and make the caller branch on that code. In the worker's failing runs, a missing pytest module printed the same FAIL as a real test failure, and the worker turned both into exit 13. The proposed change calls a pinned interpreter by absolute path, has the gate exit 69 when it cannot import pytest, and has the worker treat 69 as a separate outcome.&lt;/p&gt;

&lt;p&gt;I would make three changes. None of them is in the repo. The first is a pinned interpreter for the gate. The second is a distinct gate exit code for "could not run." The third is a worker branch that reads that code instead of collapsing it. The sketch below shows all three, as a shape and not a tested patch.&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;# Sketch only, not in the repo.&lt;/span&gt;
&lt;span class="c"&gt;# In lint-all.sh: pin the interpreter and name the failure.&lt;/span&gt;
&lt;span class="nv"&gt;GATE_PY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/opt/blog-gate/venv/bin/python3"&lt;/span&gt;  &lt;span class="c"&gt;# a path you choose, built with the CI pytest pin&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; ! &lt;span class="s2"&gt;"$GATE_PY"&lt;/span&gt; -c &lt;span class="s1"&gt;'import pytest'&lt;/span&gt; 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null&lt;span class="o"&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;"GATE COULD NOT RUN: $GATE_PY cannot import pytest"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
  &lt;span class="nb"&gt;exit&lt;/span&gt; 69  &lt;span class="c"&gt;# EX_UNAVAILABLE in sysexits.h; real test failures still go through bad() and exit 1&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"$GATE_PY"&lt;/span&gt; -m pytest tests/ -q 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1 &lt;span class="o"&gt;|&lt;/span&gt; tail -1&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt; ok &lt;span class="s2"&gt;"tests pass"&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; bad &lt;span class="s2"&gt;"pytest"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# In the worker: read the gate's status instead of collapsing it.&lt;/span&gt;
bash scripts/blog/lint-all.sh &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"$LOG"&lt;/span&gt; 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1
&lt;span class="nv"&gt;gate_rc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$gate_rc"&lt;/span&gt; -eq 69 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="c"&gt;# park the bead with one "gate could not run" note and one alert&lt;/span&gt;
  &lt;span class="nb"&gt;exit&lt;/span&gt; 15  &lt;span class="c"&gt;# 11 through 14 and 64 already mean other things in this worker&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$gate_rc"&lt;/span&gt; -ne 0 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="c"&gt;# the existing code-failure path: reopen, note, alert&lt;/span&gt;
  &lt;span class="nb"&gt;exit&lt;/span&gt; 13
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The gate's exit code is the part the worker can act on, and only if the worker reads it. Today the worker collapses every non-zero gate result into 13. With the split, 13 means a gate ran and found a problem, and 69 from the gate means it never ran.&lt;/p&gt;

&lt;p&gt;On 69, the worker should not reopen the bead as though the code had failed. I would set the bead to a status other than open (the picker only takes open beads), write one note with the words "gate could not run," and alert once. The bead goes back to open when someone fixes the environment, not when the calendar says Sunday.&lt;/p&gt;

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

&lt;p&gt;Six Sundays produced about 13,200 agent-seconds, six identical notes on one bead and six calls to the failure alert. The bead went back to open after the last run. The finished work sits on two local branches, never pushed, with no pull request.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Give the gate its own pinned interpreter. Build a venv at a fixed path, install the pytest version CI pins, and call that Python by absolute path instead of python3 from PATH.&lt;/li&gt;
&lt;li&gt;Exit with a separate code when a required tool cannot be imported, and make the caller branch on it. A could-not-run result should park the work item with one note and one alert, not reopen it for the next run.&lt;/li&gt;
&lt;li&gt;Rerun the gate from the cron environment before you trust an agent's green result. Start with the gate block in &lt;a href="https://github.com/jeremylongshore/startaitools.com/blob/master/scripts/blog/blog-recommendation-worker.sh" rel="noopener noreferrer"&gt;scripts/blog/blog-recommendation-worker.sh&lt;/a&gt;, since that is where the reopen happens.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Why does a cron job say No module named pytest when CI runs the same command?
&lt;/h3&gt;

&lt;p&gt;The cron worker's gate runs python3 from PATH, which resolved to /usr/bin/python3, a system interpreter with no pytest module. CI installs pytest==9.1.1 and Pillow with pip before running the same command, so the command matches and the environment does not.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why not just install pytest and rerun the gate?
&lt;/h3&gt;

&lt;p&gt;The agent's venv lived in its own shell, so the worker's interpreter would still lack pytest the next Sunday. On this machine, PEP 668 blocks user installs into the system Python, which leaves a venv as the only path. A gate that passes in an agent's shell and fails under cron is measuring the shell.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does pip refuse to install pytest into the system Python?
&lt;/h3&gt;

&lt;p&gt;PEP 668 is the rule that blocks pip from writing into the system Python. In the worker's run, &lt;code&gt;python3 -m pip install --user pytest&lt;/code&gt; was refused under it. That leaves a venv as the only path on this machine, and the agent deleted its venv in /tmp after the run.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/the-status-nothing-could-write-to/" rel="noopener noreferrer"&gt;Six Systems Reporting Nothing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/the-gate-that-could-not-fail/" rel="noopener noreferrer"&gt;Make the Guard Prove It Can Fail&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/the-lane-that-reviewed-nothing/" rel="noopener noreferrer"&gt;Every Check Should Report What It Did Not Look At&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aiagents</category>
      <category>testing</category>
      <category>cicd</category>
      <category>automation</category>
    </item>
    <item>
      <title>MCP structuredContent: Claude Code Drops Your Text Blocks</title>
      <dc:creator>Jeremy Longshore</dc:creator>
      <pubDate>Sat, 14 Nov 2026 11:30:15 +0000</pubDate>
      <link>https://dev.to/jeremy_longshore/mcp-structuredcontent-claude-code-drops-your-text-blocks-7ja</link>
      <guid>https://dev.to/jeremy_longshore/mcp-structuredcontent-claude-code-drops-your-text-blocks-7ja</guid>
      <description>&lt;p&gt;If you build an MCP server, the instructions you write into the text of a tool result may never reach the model.&lt;br&gt;
MCP (Model Context Protocol) lets an AI app such as Claude Code call tools on a server you run. A tool result can carry plain text and a JSON object called &lt;code&gt;structuredContent&lt;/code&gt;, and the app decides which of the two the model reads.&lt;br&gt;
This post shows how to check what the app actually hands the model, how to put your instructions where they will arrive, and how to stop a test harness from hiding a tool call the app refused.&lt;/p&gt;

&lt;p&gt;It is for anyone who ships or tests an MCP server used from more than one AI app.&lt;/p&gt;

&lt;p&gt;We found this in a read-only MCP server that answers questions about a team's Discord history.&lt;br&gt;
Its text carried the rules the model is meant to follow, plus a one-line summary and a line saying so when nothing was found. Its JSON carried the messages.&lt;br&gt;
When we checked, Claude Code, Anthropic's coding agent, gave the model the JSON and dropped the text.&lt;br&gt;
Our evals (scripted prompts that grade the model's tool calls and answers) still passed.&lt;/p&gt;
&lt;h2&gt;
  
  
  The spec lets a host treat structuredContent and text as equivalent
&lt;/h2&gt;

&lt;p&gt;The MCP specification's Tools section covers structured content. It says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For backwards compatibility, a tool that returns structured content SHOULD also return the serialized JSON in a TextContent block.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That lets a host (the AI app that runs the model) treat the two channels as equivalent.&lt;br&gt;
Our server did not send a copy. Its text was different material from its JSON.&lt;br&gt;
It carried framing (the rules, the summary line, the empty-result line) that the JSON did not.&lt;br&gt;
When we checked, Claude Code treated the JSON as the result and dropped the text.&lt;/p&gt;
&lt;h2&gt;
  
  
  What Claude Code kept from a structuredContent result
&lt;/h2&gt;

&lt;p&gt;We confirmed this three ways.&lt;br&gt;
The first was Claude Code's minified client code, which we read directly. The branch that matters looks like this:&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="k"&gt;if&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;structuredContent&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Re&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;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Re&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;content&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="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;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s2"&gt;"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="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;_&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;structuredContent&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;When a result has structuredContent, the filter removes every block whose &lt;code&gt;type&lt;/code&gt; is &lt;code&gt;"text"&lt;/code&gt;, and the JSON goes in its place.&lt;br&gt;
This is client behaviour we observed. It is not a documented contract.&lt;/p&gt;

&lt;p&gt;The second check was the raw &lt;code&gt;claude -p&lt;/code&gt; stream of an eval run. Every successful tool_result was the JSON.&lt;br&gt;
The third was the deployed server reached through its production connection, which also gave the model JSON only.&lt;/p&gt;
&lt;h2&gt;
  
  
  What got lost, and why the evals passed
&lt;/h2&gt;

&lt;p&gt;The server shows each message as a card in apps that draw them, and its rules are named constants in the server code: DATA_RULE, NAME_RULE and CARD_RULE.&lt;br&gt;
Under that filter, the model lost DATA_RULE (13 sites), NAME_RULE, CARD_RULE, every lead line (the one-line summary above a result) such as a count of open messages between you and a named person, and every nothing-found line.&lt;/p&gt;

&lt;p&gt;The data survived.&lt;br&gt;
Each card object carried id, where, author, at, text and url.&lt;br&gt;
Citations and the injection cases still passed. They passed on the model's defaults and the eval's own system prompt, not on the server's rules.&lt;br&gt;
A passing eval told us the data arrived. It did not tell us the rules did.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What the tool result carried&lt;/th&gt;
&lt;th&gt;Where it lived&lt;/th&gt;
&lt;th&gt;Reached the model (as observed)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Rules (DATA_RULE, NAME_RULE, CARD_RULE), lead lines, nothing-found lines&lt;/td&gt;
&lt;td&gt;Text block&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Messages (id, where, author, at, text, url)&lt;/td&gt;
&lt;td&gt;structuredContent JSON&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Why the eval showed find_messages twice
&lt;/h2&gt;

&lt;p&gt;We found the lost rules while chasing a repeated call.&lt;br&gt;
The eval runner (the script that sends each case to the model and prints its tool calls) printed my_queue, then find_messages, then find_messages again.&lt;br&gt;
It read as the server making the model search twice, so we started a fix in the server code.&lt;/p&gt;

&lt;p&gt;The raw stream showed something else.&lt;br&gt;
The model named find_messages without the MCP server prefix (&lt;code&gt;mcp__&amp;lt;server&amp;gt;__&lt;/code&gt;).&lt;br&gt;
Claude Code refused it with &lt;code&gt;No such tool available: find_messages&lt;/code&gt;.&lt;br&gt;
The model then called the prefixed name, &lt;code&gt;mcp__&amp;lt;server&amp;gt;__find_messages&lt;/code&gt;. There is no server-side retry.&lt;/p&gt;

&lt;p&gt;The runner's transcript printer had stripped the prefix, so the refused call and the real one printed the same.&lt;br&gt;
We dropped the server-side change once the stream was clear.&lt;/p&gt;
&lt;h2&gt;
  
  
  The fix: a note field inside structuredContent
&lt;/h2&gt;

&lt;p&gt;The fix has two parts.&lt;br&gt;
The first is a &lt;code&gt;note&lt;/code&gt; field holding the result text with the per-message lines removed, because each of those restates a message object the structured view already carries.&lt;br&gt;
The second changes &lt;code&gt;reply()&lt;/code&gt;, the one helper that builds a result.&lt;br&gt;
It keeps the text block for hosts that read it, and writes the same framing into structuredContent.&lt;br&gt;
It also takes an error flag, so error results use the same path.&lt;/p&gt;

&lt;p&gt;This is the first version of the change (the doc comment is omitted):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;-const reply = (view: View, text: string) =&amp;gt; ({ content: [{ type: "text" as const, text }], structuredContent: view });&lt;/span&gt;
&lt;span class="gi"&gt;+export const note = (text: string) =&amp;gt; text.split("\n").filter((l) =&amp;gt; !l.startsWith("- ")).join("\n");&lt;/span&gt;
&lt;span class="gi"&gt;+const reply = (view: Record&amp;lt;string, unknown&amp;gt;, text: string, isError = false) =&amp;gt; ({ content: [{ type: "text" as const, text }], structuredContent: { ...view, note: note(text) }, ...(isError ? { isError: true as const } : {}) });&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That first &lt;code&gt;note()&lt;/code&gt; was too blunt, and review caught it before merge.&lt;br&gt;
Stripping every line that starts with "- " assumed the structured view always carries the same data.&lt;br&gt;
It does not. The &lt;code&gt;start_here&lt;/code&gt; tool lists channel ids as "- " lines, and the view leaves them out unless detail is requested. Glossary terms, trends and FAQ items had the same gap.&lt;br&gt;
Indented message lines in the catch-up tool slipped past the filter too, so those reached the model twice.&lt;/p&gt;

&lt;p&gt;The merged &lt;code&gt;note()&lt;/code&gt; drops only lines in the message shape (where, author, date, quoted text, url) at any indentation, plus an indented continuation under one. Every other list stays.&lt;br&gt;
A further commit before merge let the pattern accept the bracketed flags the timeline tool appends after each url.&lt;br&gt;
Probed on the dev host after the narrowing, the &lt;code&gt;start_here&lt;/code&gt; note carried 9 channel id lines while the view's channel list was empty, and the catch-up note ran 878 characters against 4,551 of text.&lt;br&gt;
The &lt;code&gt;reply()&lt;/code&gt; line is the same in both versions.&lt;/p&gt;

&lt;p&gt;The sync tool (the owner-only tool that adds a Discord server) had four inline returns that skipped this path.&lt;br&gt;
Two of them carried instructions the model never saw: "Which server? The bot is in: ..." and "Discord asked to wait Ns; call sync again after that."&lt;br&gt;
Both now go through &lt;code&gt;reply()&lt;/code&gt;. For example:&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;// before&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;content&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;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"text"&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`Which server? The bot is in: ${list}.`&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;structuredContent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;needs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"guild_id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;servers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;live&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// after&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;reply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;needs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"guild_id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;servers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;live&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sb"&gt;`Which server? The bot is in: ${list}.`&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;A unit guard now checks that every structured result takes this path.&lt;br&gt;
The card view ignores &lt;code&gt;note&lt;/code&gt;, so the cards are unchanged.&lt;/p&gt;
&lt;h2&gt;
  
  
  Two obvious alternatives we did not take
&lt;/h2&gt;

&lt;p&gt;The obvious alternative is to drop structuredContent and return text only.&lt;br&gt;
The cards are drawn from the structured data, so that would cost the card in every host that draws one.&lt;br&gt;
The fix keeps the structured result and puts the framing beside the data.&lt;/p&gt;

&lt;p&gt;The other obvious alternative is to follow the spec's SHOULD literally and make the text block a serialized copy of the JSON.&lt;br&gt;
That makes the two channels agree, and it deletes the framing from both.&lt;br&gt;
The rules have to live somewhere the model reads, and the structured result is the one place this host passed through.&lt;/p&gt;
&lt;h2&gt;
  
  
  Flagging bare-name MCP tool calls in eval output
&lt;/h2&gt;

&lt;p&gt;The runner printed a rejected call the same way it printed an accepted one.&lt;br&gt;
The transcript code moved from the runner to the grader, where it has no side effects and can be unit tested.&lt;br&gt;
A Claude call whose name lacks the server prefix now prints as &lt;code&gt;&amp;lt;name&amp;gt;?&lt;/code&gt;.&lt;br&gt;
The grader matches on the tool name, so that call no longer counts as the expected tool.&lt;br&gt;
A case cannot pass on a call the host rejected.&lt;/p&gt;

&lt;p&gt;Same eval case (&lt;code&gt;call-prep-nobody&lt;/code&gt;), one run after the change:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PASS  call-prep-nobody  [5s]
      calls: my_queue({"person":"Zelda"}) -&amp;gt; find_messages?({"query":"Zelda"}) -&amp;gt; find_messages({"query":"Zelda"})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The case still passes here, because the model's second, prefixed call is the one the grader counts.&lt;br&gt;
Two of three runs showed this miscall. The third went from my_queue straight to find_messages.&lt;br&gt;
Zelda is a seeded fixture name.&lt;/p&gt;

&lt;h2&gt;
  
  
  Eval results around the note field fix
&lt;/h2&gt;

&lt;p&gt;The numbers in this section were taken on the first version of &lt;code&gt;note()&lt;/code&gt; plus the greeting budget, before the narrowing. After the narrowing, the full suite passed 27 of 27 and the greeting case passed 4 of 4, and we did not re-measure token use.&lt;/p&gt;

&lt;p&gt;With CARD_RULE reaching the model, the no-card greeting followed it and grew.&lt;br&gt;
It ran 295 to 317 characters, which failed the 300 character cap on the greeting-quiet case (a check that the greeting stays short) in 2 of 4 runs.&lt;br&gt;
On main, the same case passed 4 of 4. We measured by setting the change aside on the same dev host.&lt;/p&gt;

&lt;p&gt;The follow-up change gives the no-card branch an explicit budget: "under 200 characters in all, nothing else, since the card would have shown the rest."&lt;br&gt;
The eval cap is unchanged.&lt;br&gt;
Across six runs after that change, the case passed 6 of 6.&lt;br&gt;
Answers ran from 140 to 230 characters, so the top of that range sits above the 200 budget.&lt;/p&gt;

&lt;p&gt;In the raw stream, the my_queue, find_messages and start_here results each carried the rule text in &lt;code&gt;note&lt;/code&gt;.&lt;br&gt;
The full suite passed 27 of 27 in 58 seconds, and the unit suite passed 228 checks, 5 of them new.&lt;br&gt;
Token use stayed flat. The run after the fix used 136 input tokens (345,046 from cache) and 12,159 output tokens.&lt;br&gt;
A baseline run on main used 144 input tokens (326,910 from cache) and 12,664 output tokens.&lt;/p&gt;

&lt;h2&gt;
  
  
  A second runner: the same evals through Codex
&lt;/h2&gt;

&lt;p&gt;The same eval suite also runs through OpenAI's Codex CLI, because a server meant for more than one AI app should be measured on more than one.&lt;br&gt;
That run came before the note field, and its first pass found a grader bug. Codex wrote couldn’t with a curly apostrophe, and the "says" patterns only matched the straight one, so two correct answers failed.&lt;br&gt;
Claude never hit it because it types straight quotes.&lt;br&gt;
The grader now normalizes curly quotes in phrase checks.&lt;/p&gt;

&lt;p&gt;That run tested the grader. It says nothing about which channel Codex hands the model.&lt;br&gt;
Of 27 cases, 23 ran before an outer time limit cut the rest off, and 17 of those passed.&lt;br&gt;
Of the six failures, three were per-case timeouts, two were the quote bug, and one was a behaviour difference: Codex answers a bare "Hi" without calling &lt;code&gt;start_here&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is not verified
&lt;/h2&gt;

&lt;p&gt;We did not verify the note field on claude.ai web, claude.ai desktop, or Codex. The environment that ran the checks after the fix was not the one that ran the Codex suite, and it could not reach any of the three. The Codex run above predates the note field.&lt;br&gt;
The text channel is still intact for any host that reads it.&lt;br&gt;
We have no measurement of what those other hosts send the model.&lt;/p&gt;

&lt;p&gt;The spec leaves hosts room to pick either channel, so do not assume the text block reaches the model.&lt;br&gt;
Check the raw stream of a run, and read the structured content section of the specification as the contract to design against, not as a promise about any one host: &lt;a href="https://modelcontextprotocol.io/specification/2025-06-18/server/tools#structured-content" rel="noopener noreferrer"&gt;https://modelcontextprotocol.io/specification/2025-06-18/server/tools#structured-content&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Why does Claude Code drop the text in an MCP tool result?
&lt;/h3&gt;

&lt;p&gt;When a tool result carries structuredContent, Claude Code, as observed at the time of our check, keeps the JSON and removes every text block. The minified client code we read filters out text blocks whenever structuredContent is present. This is observed behaviour, not a documented contract, so check the raw stream of your own runs.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I check what the model actually receives from an MCP tool call?
&lt;/h3&gt;

&lt;p&gt;Run one eval case with the raw stream turned on and check each tool_result. If the tool_result is the JSON alone and a rule you need is not in it, the rule never reached the model. The eval runner's transcript printer is not enough on its own, because it stripped the server prefix and printed a rejected call the same as an accepted one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does the MCP spec require a text block when a tool returns structuredContent?
&lt;/h3&gt;

&lt;p&gt;The MCP Tools section says a tool that returns structured content SHOULD also return the serialized JSON in a TextContent block, for backwards compatibility. That lets a host treat the two channels as equivalent, so the spec leaves hosts room to pick either one. Do not assume the text block reaches the model, and treat the structured content section of the spec as the contract to design against, not a promise about any one host.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Run one eval case with the raw stream on and check each tool_result. If the tool_result is the JSON alone and a rule you need is not in it, the rule never reached the model.&lt;/li&gt;
&lt;li&gt;When a result carries structuredContent, put model-facing framing in a field inside it (a note field works), and keep the text block for hosts that read it.&lt;/li&gt;
&lt;li&gt;Have the eval runner print a bare-name or otherwise rejected tool call as a miscall, and make sure a case cannot pass on it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/pin-the-eval-dataset-sha256-digest-from-the-caller/" rel="noopener noreferrer"&gt;Pin the Eval Dataset With a SHA-256 Digest From the Caller&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/the-api-is-the-real-boundary/" rel="noopener noreferrer"&gt;MCP Server Auth: The API Is the Real Boundary&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/when-green-ci-proves-nothing/" rel="noopener noreferrer"&gt;Green CI Proves Nothing: Why Your Tests Gate Zero Calls&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>mcp</category>
      <category>claudecode</category>
      <category>evals</category>
      <category>aiagents</category>
    </item>
    <item>
      <title>Secret Scanner False Positives From Whitespace Stripping</title>
      <dc:creator>Jeremy Longshore</dc:creator>
      <pubDate>Sat, 14 Nov 2026 11:30:13 +0000</pubDate>
      <link>https://dev.to/jeremy_longshore/secret-scanner-false-positives-from-whitespace-stripping-4ia5</link>
      <guid>https://dev.to/jeremy_longshore/secret-scanner-false-positives-from-whitespace-stripping-4ia5</guid>
      <description>&lt;p&gt;A secret scanner has to catch keys that a line break has cut in two. The fast way to do that is to delete every whitespace character and run the key patterns on what is left. The catch is that deleting whitespace also glues the end of one word to the start of the next. A clean document can then look like it leaks a credential. This post is for anyone who maintains a secret scanner, a data loss prevention (DLP) rule set, or another detector that normalizes text before it matches.&lt;/p&gt;

&lt;p&gt;By the end of this post you will have the rule that fixed it and the reason each piece exists. You will also have a checklist of test cases to write, and watch fail, before you trust the fix.&lt;/p&gt;

&lt;h2&gt;
  
  
  Whitespace stripping creates false API key matches
&lt;/h2&gt;

&lt;p&gt;The scanner in question checks text for credentials before a team knowledge base accepts it. Its main pass reads one line at a time. Split-key evasion, meaning a key broken across a line break so a per-line scan never sees all of it, needs a second pass over a flattened copy of the text.&lt;/p&gt;

&lt;p&gt;The flattened copy that caused the trouble was the one with every whitespace character removed. One of its regex patterns covers API keys. It looks for &lt;code&gt;sk-&lt;/code&gt; followed by at least twenty letters and digits. The word &lt;code&gt;Task-&lt;/code&gt; ends in exactly those three characters. Strip the spaces that follow it, and the following words land right where the key pattern expects its body.&lt;/p&gt;

&lt;p&gt;The test file for this change uses that exact shape: a sentence beginning "Task-Based Gameplay improves player feedback and progression", followed by a newline and an unrelated sentence. Before the fix, the scanner raised a false positive, a generic API key match. The same thing happens with &lt;code&gt;risk-&lt;/code&gt; and &lt;code&gt;desk-&lt;/code&gt; followed by ordinary words, because each one ends in the same letters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Map stripped matches back to source spans
&lt;/h2&gt;

&lt;p&gt;The fix keeps the stripped match, but it does not trust it. Every stripped match is checked against the original text before it counts.&lt;/p&gt;

&lt;p&gt;First, the scanner keeps a map from each character in the stripped view back to its UTF-16 offset in the source. The map is the only way to answer "what did this match look like before whitespace was removed?" The existing input cap bounds the map and each source slice:&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;// Preserve UTF-16 offsets into the original source. Validate the source token&lt;/span&gt;
&lt;span class="c1"&gt;// before applying the fragment-prefix guard, so a genuine line-wrapped key&lt;/span&gt;
&lt;span class="c1"&gt;// attached to an identifier remains visible. The existing input cap bounds&lt;/span&gt;
&lt;span class="c1"&gt;// the map and each source slice.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;stripped&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;mappedWhitespace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;offsets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stripped&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;offsets&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Second, the scanner re-runs the canonical pattern on the original span, after joining only the whitespace runs that contain a line break or a Unicode line separator:&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="cm"&gt;/** Join padded line wraps, retaining purely horizontal whitespace runs. */&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;joinLineWraps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;+/&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;space&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="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;\&lt;span class="n"&gt;r&lt;/span&gt;\&lt;span class="n"&gt;n&lt;/span&gt;\&lt;span class="n"&gt;u2028&lt;/span&gt;\&lt;span class="n"&gt;u2029&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="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;space&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;space&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;Horizontal spaces survive. A word space stays a word space, so &lt;code&gt;Task-Based Gameplay&lt;/code&gt; does not turn into one long token. A real line wrap, even one padded with indentation, is joined, so a key split across lines comes back together.&lt;/p&gt;

&lt;p&gt;Third, the decision itself. The callback below runs for each candidate found in the stripped view (source comments trimmed here). Only the generic key pattern sets &lt;code&gt;requiresSourceToken&lt;/code&gt;, so only its candidates reach the source check:&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pattern&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;match&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="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;acceptedContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pattern&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;offsets&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="kc"&gt;false&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="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;pattern&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;requiresSourceToken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&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;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;offsets&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&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;end&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;offsets&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&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="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;start&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&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;source&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;joinLineWraps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="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="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="nf"&gt;firstCountedMatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pattern&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&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="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!/&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;A&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Za&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;z&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="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&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="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 logic reads in two steps. If the joined source starts with a real key prefix, the match is accepted, even when the greedy stripped match ran on into following prose. If it does not, the candidate survives only when the character before it is not an ASCII letter. That is what stops the suffix of &lt;code&gt;task-&lt;/code&gt; from becoming a key. A newline is not a letter, so a newline counts as a boundary. The scanner does not look backward through it.&lt;/p&gt;

&lt;p&gt;The joining runs only on the slice of source that one candidate covers. The check does not rebuild the whole document, so the cost of each decision follows the length of the match, not the length of the file.&lt;/p&gt;

&lt;p&gt;Rejected candidates also have to stop consuming the text. A rejected match can eat the first letters of a later, real prefix. So the walker resumes one character past the rejected match's start, not at its end:&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;sourceAccepted&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;walker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lastIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without that line, one false match can hide a true key that starts a few characters later. The test suite has a case for exactly that: a false &lt;code&gt;Task-&lt;/code&gt; match, followed by a real split key on the next line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'sk-'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'TESTONLY'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&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;hasApiKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="nf"&gt;scanForSecrets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;match&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;match&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patternId&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'generic-api-key'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'finds a later real prefix even when an earlier rejected match consumes its first letters'&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;=&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;prose&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Task-Based Gameplay improves player feedback and progression'&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;hasApiKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${prose}\nThe credential is ${key.slice(0, 12)}\n${key.slice(12)}`&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;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&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 controls (test cases with a known right answer) are the part I would copy first. Each boundary case became a failing test before the next change was written. Two of the four prose cases are shown:&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="n"&gt;it&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="p"&gt;[&lt;/span&gt;
  &lt;span class="s1"&gt;'Task-Based Gameplay improves player feedback and progression'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s1"&gt;'risk-level classification needs careful handling'&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="s1"&gt;'does not manufacture a key inside prose: %s'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prose&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;scanForSecrets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${prose}\nNext section covers evaluation.`&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;toEqual&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;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pair that with positive controls, because a rule that only rejects is easy to write. The suite splits a real test key across a newline and expects a finding after an empty prefix, after &lt;code&gt;key:&lt;/code&gt;, after a tab, and after an opening parenthesis. It does the same with an indented continuation line. The hardest positive case puts the split key directly against an identifier:&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="s1"&gt;'detects a real split key directly adjacent to an identifier'&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;=&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;hasApiKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`identifier${key.slice(0, 12)}\n${key.slice(12)}`&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;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&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;Each of those cases is a guard against a specific way the fix could go wrong. The prose controls catch over-matching. The split-key controls catch over-rejecting. The identifier control catches a rule that is too strict about what may sit before a prefix.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not the obvious approaches
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Drop the stripped view.&lt;/strong&gt; The view exists to catch split keys, and the positive controls depend on it. Removing it would make the prose false positives disappear by also removing the detection the scanner exists for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Require a word boundary before &lt;code&gt;sk-&lt;/code&gt;.&lt;/strong&gt; This was the first real attempt: a predecessor-character check. It rejected the prose, but it missed a real split key sitting directly against an identifier, and it still accepted wrapped prose that should have been rejected. The boundary rule alone was not enough. The source-span check is what handles the identifier case.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Look backward through the newline.&lt;/strong&gt; A prose line could end with a word that looks like it might continue onto the next line. Looking back through the line break would let that unrelated text hide a credential on the next line. The fix treats newlines as hard boundaries and does not try to guess soft-wrapped words.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Apply the same rule to every pattern.&lt;/strong&gt; Most patterns do not need the source check. Only the generic API key pattern opts into the source-token check. The env and Slack patterns got a separate line-wrap-only view, because the fully stripped view let short fragments after an assignment join into secret-shaped values. That split was its own change.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the verification showed
&lt;/h2&gt;

&lt;p&gt;The main change landed as one squash commit. Its final local gates recorded 4,457 tests passing with five optional skips, and 38 added controls: 33 for the scanner and five for the policy code that consumes its results. Hosted CI passed on the exact head of that change.&lt;/p&gt;

&lt;p&gt;The companion change for the env and Slack patterns added the line-wrap-only view. Whitespace runs containing a line feed, a carriage return, or a Unicode line separator are joined, including wrap padding. Horizontal-only runs stay intact. That change added 34 new scanner cases, and 18 of them failed on the prior implementation. After repair, all 34 passed, along with four policy-consumer controls.&lt;/p&gt;

&lt;p&gt;The local totals come from the agent that ran them. The pull request body labels them an unreviewed Codex execution attestation, and says plainly that they are not a human-owner signoff. Merges waited for hosted CI on the exact head.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four attempts, each forced by a failing control
&lt;/h2&gt;

&lt;p&gt;The rule above was the fourth version. A Codex agent wrote the changes, and a configured automated review on the pull request pushed back three times. Each pushback named a concrete case, and each case became failing controls before the next attempt. The squash commit message records all four.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attempt one: guard the prefix.&lt;/strong&gt; Four prose regressions failed before this fix. It rejected a match whose prefix followed a letter, and it resumed rejected candidates one character past their start. The &lt;code&gt;Task-&lt;/code&gt; and &lt;code&gt;risk-&lt;/code&gt; sentences went quiet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attempt two: validate at the source span.&lt;/strong&gt; Review showed the predecessor-character check missed a real split key attached to an identifier, and still accepted wrapped prose. Both review cases failed against attempt one. The design changed here: the scanner began re-running the pattern on the original span. Four more padding cases failed until the wrap joining treated both sides of a line break the same way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attempt three: keep horizontal fragments.&lt;/strong&gt; The source check was now too strict. A key broken up with spaces or tabs on one line no longer matched. Six horizontal controls failed. The fix accepts a valid line-wrapped source token first, then falls back to the letter guard for standalone fragments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attempt four: stop looking backward through newlines.&lt;/strong&gt; The letter guard scanned backward past a line break, so unrelated prose on the previous line could hide a fragmented key at the start of the next one. Two line-start key controls failed. Newlines became hard boundaries.&lt;/p&gt;

&lt;p&gt;The human role in that loop was owning the boundary rule (a letter immediately before a fragment excludes it, and a newline is a boundary) and merging only on hosted CI. The controls are the record of what each attempt got wrong. They are also what let the final rule be checked without trusting the agent's own summary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Source-span checks for Heroku UUID context
&lt;/h2&gt;

&lt;p&gt;A third change that day applied the source-first rule to a different failure. The Heroku pattern matches a UUID only when credential words such as key or token appear nearby. After whitespace collapsing or decoding, a UUID could borrow those words from an unrelated line. Detection now evaluates context at the original source occurrence: the lines the match spans, or an immediately preceding credential label or assignment. Only the Heroku pattern opts into this context check. Its new controls cover unrelated lines in either direction, explicit preceding labels, and an earlier unrelated UUID followed by a later associated one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;p&gt;The limits are stated in the change. Line-wrap joining is a heuristic. A fragmented key attached directly to a letter on the same line can go unrecognized unless its line-wrapped source token matches. In the other direction, ambiguous soft-wrapped prose such as &lt;code&gt;ta&lt;/code&gt; followed by a new line starting &lt;code&gt;sk-&lt;/code&gt; stays flagged on purpose, because prose on the previous line must never suppress a credential. Arbitrary horizontal obfuscation of env and Slack tokens is outside what this view promises. The Heroku context association shipped separately, and it is a deterministic association rule, not semantic verification of a credential. The scanner also decodes base64 and hex blobs, and it stops after 64 unique decodes. That budget caps recall: a blob seen without context, followed by 63 other accepted unique decodes, can go unreported when it reappears later under a label. No per-occurrence recall is claimed beyond that budget.&lt;/p&gt;

&lt;p&gt;The change is in &lt;a href="https://github.com/jeremylongshore/bobs-big-brain-registrar/pull/447" rel="noopener noreferrer"&gt;PR #447 in bobs-big-brain-registrar&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Why does my secret scanner flag prose like "Task-Based Gameplay" as an API key?
&lt;/h3&gt;

&lt;p&gt;Deleting all whitespace joins the end of "Task-" to the next word, and the generic API key pattern matches "sk-" followed by at least twenty letters and digits. The same thing happens with "risk-" and "desk-". Checking each match against the original text rejects these false positives.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I detect an API key split across lines without flagging ordinary prose?
&lt;/h3&gt;

&lt;p&gt;Keep an offset map from the stripped text back to the source, and join only whitespace runs that contain a line break or a Unicode line separator. Re-run the key pattern on that original span and accept it when the joined text starts with a key prefix. Otherwise, accept it only when the character before it is not an ASCII letter. This is a heuristic, so a fragmented key attached to a letter on the same line can go unrecognized unless its line-wrapped source token matches.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why must a rejected match restart the search one character later?
&lt;/h3&gt;

&lt;p&gt;A rejected match can consume the first letters of a real key prefix that starts a few characters later. Resuming the search from the rejected match's start plus one keeps that key visible. The post's test suite covers a false "Task-" match followed by a split key on the next line.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Before you trust a normalizing detector, write one failing control per boundary: a match after a letter, a match after a newline, and an identifier sitting directly before a split key.&lt;/li&gt;
&lt;li&gt;When a match comes from a stripped view, map its offsets back to the source, join only line-wrap whitespace, and re-run the canonical pattern there. Accept it when the joined source starts with a key prefix. Otherwise accept it only when the character before it is not an ASCII letter.&lt;/li&gt;
&lt;li&gt;When a candidate is rejected, resume the search at the candidate's start plus one, so an overlapping real prefix is not hidden by the false one.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/squash-merge-breaks-gitleaksignore-fingerprint/" rel="noopener noreferrer"&gt;gitleaks: Allowlist the Squash Commit in .gitleaksignore&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/disclosure-gate-reject-pii-at-source/" rel="noopener noreferrer"&gt;Reject PII at the Source: A Disclosure Gate at Intake&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>debugging</category>
      <category>testing</category>
      <category>typescript</category>
      <category>aiagents</category>
    </item>
    <item>
      <title>Erasure Requests: Model Provider Cleanup From Reservations</title>
      <dc:creator>Jeremy Longshore</dc:creator>
      <pubDate>Tue, 03 Nov 2026 12:02:12 +0000</pubDate>
      <link>https://dev.to/jeremy_longshore/erasure-requests-model-provider-cleanup-from-reservations-51dh</link>
      <guid>https://dev.to/jeremy_longshore/erasure-requests-model-provider-cleanup-from-reservations-51dh</guid>
      <description>&lt;p&gt;When a product has to honor an erasure request, the cleanup obligation owed to a hosted model provider has to come from what was possibly sent, not from what we can prove was sent. We had it derived from the wrong signal, and the two directions of that failure were not equally bad: one asks a vendor for a cleanup of data it never received, the other can leave personal data sitting at a vendor outside our control.&lt;/p&gt;

&lt;p&gt;What follows is the rule that replaced it, the SQL condition that implements it, a reversible migration (a database change you can roll back) that installs it, and a regression module that reproduces both defects.&lt;/p&gt;

&lt;p&gt;The product here is an onboarding system. Its assessment path sends applicant data to a hosted model provider to score assessments, and its reply interpreter uses the same provider. When a person asks to be erased, the system computes a handoff list: the external parties that now owe a cleanup because they may hold that person's data. The model provider is one entry on that list, written as &lt;code&gt;model_provider&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Our own database holds narrower evidence about a provider call than it does about a row. We record that we reserved a request before sending it, and we record that a provider call consumed requests. Between those two records sits the part we cannot resolve: whether a reserved request that never completed actually crossed to the vendor. Any obligation we owe that vendor has to be derived from the wider of the two records, the reservation rather than the consumption count, because the two ways of getting it wrong cost very different amounts.&lt;/p&gt;

&lt;h2&gt;
  
  
  The old rule asked only whether a run row existed
&lt;/h2&gt;

&lt;p&gt;The old rule lived in a catalog module (the Python file that generates the erasure function's SQL), inside the SQL body of the function that builds the handoff list. It looked like this:&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;IF&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assessments_assessmentrun&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;WHERE&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;application_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;ANY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v_apps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
    &lt;span class="n"&gt;v_handoffs&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;v_handoffs&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;'model_provider'&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;-- what the model provider kept of a request, if anything&lt;/span&gt;
  &lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="k"&gt;IF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Any assessment run row at all for the erased person's applications was enough. No column was compared. The query could not tell a run that consumed a provider call from a run that was created and then refused before a call was ever made.&lt;/p&gt;

&lt;p&gt;Both defects came out of that one line, and they point in opposite directions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;False positive.&lt;/strong&gt; An assessment refused on suspension produced a run row and no provider call. The old rule still reported &lt;code&gt;model_provider&lt;/code&gt;. The vendor owed nothing, and it would have been asked to clean up data it never received.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;False negative.&lt;/strong&gt; A person's inbound reply can be reserved for interpretation by the provider while no assessment run exists for them. The legacy predicate found no run row, so the entry was omitted. The provider might have received the reply, and nobody would have asked it to drop anything.&lt;/p&gt;

&lt;p&gt;Neither defect is something you find by reading the SQL twice. The condition looks conservative, and conservative is the right instinct here. It is just conservative in the wrong place: careful about the row's existence, careless about the request's fate.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do I derive a model provider cleanup obligation?
&lt;/h2&gt;

&lt;p&gt;We derive it from what was possibly sent, not from what we can prove was sent. A reserved provider call counts as evidence of disclosure even when the call never completed, because an unfinished run is not evidence of absence. An abandoned call is the harder case, because there the run exists and did not finish, and the reason is that the provider's side of the call is not something our database can resolve. When a run is refused before anything is reserved, no handoff is owed.&lt;/p&gt;

&lt;p&gt;The new predicate lives in &lt;code&gt;erasure/catalog.py&lt;/code&gt; as &lt;code&gt;MODEL_PROVIDER_HANDOFF&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;MODEL_PROVIDER_HANDOFF&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"""EXISTS (SELECT 1 FROM public.assessments_assessmentinvocation i
             WHERE i.application_id = ANY(v_apps) AND i.reserved_requests &amp;gt; 0)
     OR EXISTS (SELECT 1 FROM public.assessments_assessmentrun r
                WHERE r.application_id = ANY(v_apps) AND r.requests_used &amp;gt; 0)
     OR EXISTS (SELECT 1 FROM public.correspondence_replyinterpretation i
                WHERE i.application_id = ANY(v_apps) AND i.reserved_requests &amp;gt; 0)"""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three signal sources and two different columns:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Signal&lt;/th&gt;
&lt;th&gt;Column&lt;/th&gt;
&lt;th&gt;What it establishes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Assessment invocation (assessment and clarification rounds)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;reserved_requests &amp;gt; 0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A provider call was reserved. A possible disclosure, even if the call never completed.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Assessment run&lt;/td&gt;
&lt;td&gt;&lt;code&gt;requests_used &amp;gt; 0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A provider call consumed requests. A confirmed disclosure.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reply interpretation&lt;/td&gt;
&lt;td&gt;&lt;code&gt;reserved_requests &amp;gt; 0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Reply-interpretation provider work was reserved. A possible disclosure.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The rule now reads, as recorded in the internal launch plan: a queued or suspension-refused run that reserved nothing and recorded nothing owes no model provider handoff. Positive assessment and clarification reservations, recorded assessment requests and reply interpretation reservations keep the handoff, including abandoned calls whose provider outcome is uncertain. Reply-only calls count even without an assessment run.&lt;/p&gt;

&lt;p&gt;The inversion that matters is that a reservation became a first-class signal instead of an implementation detail. Previously a provider call surfaced only as an assessment run row. The reservation was always recorded and the old rule never looked at it. Now the rule reads that column, so the ambiguous middle (reserved, then interrupted, then abandoned) is answered from a recorded number instead of inferred from the mere existence of a run row.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not count only confirmed calls, or ask the provider?
&lt;/h2&gt;

&lt;p&gt;The obvious fix is to count only confirmed calls: drop the reservation checks, keep &lt;code&gt;requests_used &amp;gt; 0&lt;/code&gt;, and let the ambiguous cases fall on the floor. It removes the false positive entirely and the query gets shorter.&lt;/p&gt;

&lt;p&gt;It also creates a silent false negative, and that is the bad trade. A call that was reserved and then interrupted leaves no confirmed record, but the provider may have received it. The absence of a finished run is not evidence of absence of disclosure. When the evidence is missing rather than negative, the only safe reading is that a disclosure is possible, and a possible disclosure still creates a cleanup obligation.&lt;/p&gt;

&lt;p&gt;The other obvious approach is to ask the provider. Read the vendor's logs for the person's identifiers and use the answer. That makes the vendor a runtime dependency of an erasure request, it assumes the vendor can match our identifiers to what it received, and it assumes the vendor keeps logs long enough to answer. None of those hold in general, and the cost when they do not hold is the person's data still sitting there.&lt;/p&gt;

&lt;p&gt;So the obligation is deliberately a superset of confirmed disclosures, and we accept the false positive the new rule keeps. That false positive costs a message to a vendor and some noise in our own logs. The false negative can cost a person their right to be forgotten.&lt;/p&gt;

&lt;p&gt;One more reason the set has to lean wide: we do not get to know what the provider does with a request after we send it. Retention, training and logging on their side, if they happen at all, happen outside our database. Our own records tell us a request was reserved for sending, and a confirmed call (&lt;code&gt;requests_used &amp;gt; 0&lt;/code&gt;) tells us the provider consumed it. Neither tells us it kept anything. The reservation is our evidence that it might have gone out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing it without rewriting history
&lt;/h2&gt;

&lt;p&gt;The change ships as a reversible migration, &lt;code&gt;erasure/migrations/0008_model_handoff_evidence.py&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="s2"&gt;"""9kg.73: queued or refused model work alone creates no provider cleanup obligation.

Reservations remain conservative evidence of possible disclosure, including abandoned calls
and reply interpretation without an assessment run. Reinstall both erasure functions without
rewriting rows, signed records, function ownership or grants.
"""&lt;/span&gt;

&lt;span class="c1"&gt;# imports elided&lt;/span&gt;

&lt;span class="no"&gt;LEGACY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"EXISTS (SELECT 1 FROM public.assessments_assessmentrun r WHERE r.application_id = ANY(v_apps))"&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;install&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;schema_editor&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="n"&gt;reverse&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="c1"&gt;# retention and existing lookups elided&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;replay&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;statement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;catalog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;erase_sql&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;retention&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;existing&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;replay&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;replay&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;statement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;catalog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MODEL_PROVIDER_HANDOFF&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="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"unexpected model handoff definition"&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;reverse&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;statement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;statement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;catalog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MODEL_PROVIDER_HANDOFF&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;LEGACY&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;schema_editor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;statement&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# forwards, backwards and the Migration class elided&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things are worth pulling out of that file.&lt;/p&gt;

&lt;p&gt;The loop runs over both function variants, the normal erasure and the restore replay. The two have to carry the same rule, because a restored database can bring back rows for a person erased after the backup, and the replay re-runs the erasure against those rows. What a restore leaves behind is covered in &lt;a href="https://startaitools.com/posts/database-restore-does-not-undo-outward-effects/" rel="noopener noreferrer"&gt;A Database Restore Does Not Undo Sent Email or Envelopes&lt;/a&gt;. If replay derived the entry differently, the replay would answer a different question than the erasure it replays.&lt;/p&gt;

&lt;p&gt;The count check keeps the installed SQL and the catalog in agreement. The function body is generated from the catalog, so the migration asserts that the new predicate appears exactly once in the generated statement. A later edit that drops the clause or duplicates it fails the migration instead of shipping a function that quietly disagrees with the source it came from.&lt;/p&gt;

&lt;p&gt;The reverse path swaps the new predicate back to the legacy one, which is what makes the migration reversible. The old rule is carried in the file as a constant, so reversing is a substitution instead of a guess. Ownership, grants, historical rows and signed erasure records survive the reinstall, so no signed record is rewritten.&lt;/p&gt;

&lt;p&gt;Nothing else moved. Provider activation, rate limits and token policy are untouched.&lt;/p&gt;

&lt;h2&gt;
  
  
  The regression that reproduces both defects
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;tests/test_erasure_model_handoffs.py&lt;/code&gt; landed at 150 lines with four test functions in it. The first of them covers the asymmetry in a single body:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@pytest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parametrize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"replay"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"erase"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"replay"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@pytest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parametrize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"called"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"refused"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"provider-called"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_9kg_73_a_suspended_assessment_owes_no_provider_handoff_but_a_real_call_does&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;monkeypatch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;decided&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;replay&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;called&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;called&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;assessed&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;monkeypatch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;valid&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;assert&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"succeeded"&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"calls"&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="k"&gt;assert&lt;/span&gt; &lt;span class="nc"&gt;AssessmentInvocation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;queued&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;monkeypatch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;valid&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;settings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CATALYST_ASSESSMENT_MODEL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"none"&lt;/span&gt;
        &lt;span class="nf"&gt;run_worker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;refresh_from_db&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"refused"&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"calls"&lt;/span&gt;&lt;span class="p"&gt;]&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;assert&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nc"&gt;AssessmentInvocation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;closer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;grant&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="nf"&gt;staff&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="s2"&gt;"model-erasure-closer"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"close_application"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;closure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close_application&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;closer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"closed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Synthetic erasure regression"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"model_provider"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;handoffs&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;committed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;replay&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;called&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;called&lt;/code&gt; parameter doubles as the expected answer, which is why the last line can assert &lt;code&gt;is called&lt;/code&gt; instead of branching on it. The &lt;code&gt;refused&lt;/code&gt; branch builds the case that used to produce the false positive. Setting the model to &lt;code&gt;none&lt;/code&gt; is the suspension condition, so the worker runs, the run is refused and the fake provider records zero calls. The &lt;code&gt;provider-called&lt;/code&gt; branch is the control, where a real call happened and the handoff is owed. The &lt;code&gt;closure.close_application&lt;/code&gt; call closes the application through the staff closure helper before the erasure runs. The second function, &lt;code&gt;test_9kg_73_reply_only_model_reservations_keep_the_provider_handoff&lt;/code&gt;, covers the false negative. It builds a reply interpretation that reserved provider work, in an application with no assessment run, and asserts across both erasure paths that the handoff appears when something was reserved and stays absent when the reservation count is zero.&lt;/p&gt;

&lt;p&gt;The third test covers the ambiguous middle, the case the old predicate could not tell apart from a run that reserved nothing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@pytest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parametrize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"started"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"abandoned"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_9kg_73_an_uncertain_reserved_call_still_owes_provider_cleanup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;privileged_reset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;decided&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="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;reserved_run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&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="k"&gt;assert&lt;/span&gt; &lt;span class="s2"&gt;"model_provider"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;handoffs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;privileged_reset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A call that was reserved and then started or abandoned still owes a model provider cleanup, because the provider's side of that call is not something our database can resolve.&lt;/p&gt;

&lt;p&gt;The fourth function, &lt;code&gt;test_9kg_73_both_functions_reverse_and_reapply_without_changing_rows_or_grants&lt;/code&gt;, reverses the migration and reapplies it, then checks that the rows, the function ownership and the grants survive the reinstall.&lt;/p&gt;

&lt;p&gt;The helper three of the four tests call is what ties the two paths together. It runs the installed &lt;code&gt;catalyst_erase&lt;/code&gt; function for the normal path and the installed &lt;code&gt;catalyst_erase_replay&lt;/code&gt; function for the restore path, so whichever path is under test is held to the same rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;

&lt;p&gt;The eight-case regression, the module's first eight cases, four from the suspended-assessment matrix and four from the reply-only matrix, reproduced both defects before the change: 4 expected failures and 4 passing controls, in 30.32 seconds. Making the guard prove it can fail before trusting that it passed is the same rule as in &lt;a href="https://startaitools.com/posts/the-gate-that-could-not-fail/" rel="noopener noreferrer"&gt;Make the Guard Prove It Can Fail&lt;/a&gt;. After the fix, all 15 focused checks passed in 102.60 seconds. The coverage included actual worker and fake-provider cases, both erasure paths, uncertain calls, reversal and reapplication with exact row, function and grant preservation, the installed SQL checked against the catalog, schema inventory and model synchronization, and the existing complete erasure-reversal check.&lt;/p&gt;

&lt;p&gt;Ruff, formatting, Markdown, document index and diff checks pass. Neither a live provider nor a production database took part in this change or in its tests, and nothing is deployed yet, so no vendor ever received one of these cleanup requests. Full CI was the merge gate, and the change is merged.&lt;/p&gt;

&lt;p&gt;Deployment and the live handover to the new version remain separate open work. The internal launch plan and the approved migration set in &lt;code&gt;tests/test_database.py&lt;/code&gt; were updated with the change, so the next person reads the rule instead of rediscovering which signal was wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  Also shipped
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A sibling fix from the same day (&lt;a href="https://github.com/intent-solutions-io/catalyst-onboarding-v2/pull/178" rel="noopener noreferrer"&gt;PR #178&lt;/a&gt;) requires restore-recovery evidence to be timestamped at or after the current transaction's start, not just to carry a matching transaction ID, so a rebuilt cluster cannot reuse an old transaction ID as fresh authorization.&lt;/li&gt;
&lt;li&gt;Restore replay now matches normalized inbound senders against the signed erasure record (&lt;a href="https://github.com/intent-solutions-io/catalyst-onboarding-v2/pull/177" rel="noopener noreferrer"&gt;PR #177&lt;/a&gt;), so restoring a backup cannot resurrect inbound mail and intake counters for a person erased after that backup was taken.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Use this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Derive any obligation to ask an external party to delete data from what was possibly sent, not from the existence of a row. A reservation you wrote before the call is the evidence that a request might have reached the vendor, and a refusal that reserved nothing is evidence that nothing did.&lt;/li&gt;
&lt;li&gt;Give the delete path and the restore path the same predicate, then test both against the installed functions. A restore that replays an erasure with a different rule answers a different question than the erasure it replays.&lt;/li&gt;
&lt;li&gt;Carry the old predicate in the migration as a constant, assert the new one appears exactly once in the generated SQL, and reverse by substitution. A signed erasure record is never rewritten, and a catalog edit cannot ship a function that disagrees with its own source.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The change is in &lt;a href="https://github.com/intent-solutions-io/catalyst-onboarding-v2/pull/179" rel="noopener noreferrer"&gt;catalyst-onboarding-v2 PR #179&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is the difference between a reserved provider call and a confirmed one?
&lt;/h3&gt;

&lt;p&gt;A reservation is the record your system writes before it sends the request, so the request may have reached the provider. A confirmed disclosure is the record that requests were consumed. A call that was reserved and then started or abandoned still owes a cleanup, because the provider's side of that call is not something your database can resolve.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why not count only confirmed provider calls?
&lt;/h3&gt;

&lt;p&gt;Counting only confirmed calls removes the false positive and shortens the query, but it creates a silent false negative: an interrupted call leaves no confirmed record while the provider may have received it. Asking the provider instead makes the vendor a runtime dependency of an erasure request, and none of those assumptions hold in general. So the obligation is deliberately a superset of confirmed disclosures.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I test that an erasure derives the right cleanup set?
&lt;/h3&gt;

&lt;p&gt;Parametrize the case over both erasure paths and over whether the provider was actually called, so the parameter doubles as the expected answer. Cover the false negative with a reply interpretation that reserved provider work, and the ambiguous middle with a call reserved and then started or abandoned. Assert against the installed functions, so the path under test and the restore path are held to the same rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/database-restore-does-not-undo-outward-effects/" rel="noopener noreferrer"&gt;A Database Restore Does Not Undo Sent Email or Envelopes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/a-green-recovery-drill-can-still-be-lying/" rel="noopener noreferrer"&gt;A Green Recovery Drill Can Still Be Lying&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/working-is-not-proven/" rel="noopener noreferrer"&gt;Every Claim Needs a Shipped Source and an Executable Proof&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>architecture</category>
      <category>testing</category>
      <category>debugging</category>
    </item>
    <item>
      <title>A Database Restore Does Not Undo Sent Email or Envelopes</title>
      <dc:creator>Jeremy Longshore</dc:creator>
      <pubDate>Tue, 03 Nov 2026 11:30:13 +0000</pubDate>
      <link>https://dev.to/jeremy_longshore/a-database-restore-does-not-undo-sent-email-or-envelopes-nh3</link>
      <guid>https://dev.to/jeremy_longshore/a-database-restore-does-not-undo-sent-email-or-envelopes-nh3</guid>
      <description>&lt;p&gt;Restore a database to last night's backup and the rows go back in time. The email your app sent at 2 a.m. does not. Neither does the e-signature envelope it created, the mailbox password it rotated or the message it appended to a Sent folder. The restored app has no memory of any of them, so it can do them again: a second contract envelope to the same signer, a duplicate confirmation email to the same applicant.&lt;/p&gt;

&lt;p&gt;This post covers a three-part pattern for that problem. First, a registry: every function that calls an outside service, tagged with how a restore recovers it. Second, a test that reads the source code and fails the build when that registry and the code disagree. Third, for an effect nothing reads back and the review does not close, a check after the restore that asks the outside service what it created since the backup.&lt;/p&gt;

&lt;p&gt;The app here is an onboarding system. It sends mail over SMTP and through Django's mailer, creates and distributes agreements through Documenso (a self-hosted e-signature service), writes to a mailbox host, appends to IMAP folders and calls LLM agents. It also keeps an effect journal (an append-only log of outward actions, the side effects a rollback cannot reach, kept outside the database). After a restore, a post-restore review reads that journal and the providers, then decides whether to lift the restore hold (release the restored system for normal use).&lt;/p&gt;

&lt;h2&gt;
  
  
  What a restore forgets
&lt;/h2&gt;

&lt;p&gt;The journal only helps if it covers every effect. Before this work, that coverage was a hand-written claim in a design document, written after a code review. Nothing checked it.&lt;/p&gt;

&lt;p&gt;A hand-written list of covered effects drifts in one direction. Code adds a new provider call. Nobody updates the list. The list still reads as complete, and the next restore drill passes because the drill never exercises the new call. &lt;a href="https://startaitools.com/posts/a-green-recovery-drill-can-still-be-lying/" rel="noopener noreferrer"&gt;A Green Recovery Drill Can Still Be Lying&lt;/a&gt; covers other ways a restore check reports green.&lt;/p&gt;

&lt;p&gt;That is the failure mode to design against. The restore itself is fine. The claim about what the restore can recover is the part that rots.&lt;/p&gt;

&lt;h2&gt;
  
  
  The registry: one recovery class per function and family
&lt;/h2&gt;

&lt;p&gt;The fix starts with a data file, &lt;code&gt;workflow/effects.py&lt;/code&gt;. It registers 40 functions, two of them markers rather than effects, grouped in seven families: journal writes, SMTP, Django mail, Documenso writes, mailbox host writes, IMAP appends and model runs.&lt;/p&gt;

&lt;p&gt;Each function gets one class for each family it touches, plus a reason. Six classes make up the recovery vocabulary:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;journaled_before:&lt;/strong&gt; a journal entry is written and fsynced before the effect becomes a fact. Restrictive effects (such as a staff deactivation or an access revocation) are prepared this way. If that write fails, only the erasure and custody records refuse the effect; see below.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;journaled_after:&lt;/strong&gt; the entry is written on commit, once the effect is a fact. A crash can lose it, but it can never invent an effect.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;provider_read:&lt;/strong&gt; no entry. A named post-restore function reads the effect back at the provider.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;checked_before:&lt;/strong&gt; no entry. The action reads the provider before it writes, so a repeated run is idempotent: it finds the effect and skips it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;covered_by_review:&lt;/strong&gt; nothing reads it back. The post-restore review closes what the effect handed out, such as every live confirmation, password-setup and withdrawal link.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;marker:&lt;/strong&gt; an entry about the journal itself, such as the restore point. Not an effect.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Three entries copied from the registry as the first PR shipped it show the shape. The &lt;code&gt;gap&lt;/code&gt; on the first one comes back below.&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="s2"&gt;"agreements.handlers:CreateAgreement.call"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"documenso"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Site&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;PROVIDER_READ&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"a restored instance's envelope is read by id, or found by its external key"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;by&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;READ_ENVELOPES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"9kg.76"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s2"&gt;"agreements.handlers:DistributeAgreement.call"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"documenso"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Site&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;CHECKED_BEFORE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"re-reads the envelope and skips one already PENDING"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;by&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"agreements.handlers:DistributeAgreement.call"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s2"&gt;"agreements.keystore:destroy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"journal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Site&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;JOURNALED_BEFORE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"custody key destruction, appended before the unlink"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"custody_key_destroyed"&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 key is the module plus the function's qualified name. The value maps a family to a &lt;code&gt;Site&lt;/code&gt;. The &lt;code&gt;by&lt;/code&gt; field names the function responsible for recovery, so a reviewer can follow the claim to code instead of trusting a sentence.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Site&lt;/code&gt; is a frozen dataclass, copied from the registry with its comments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@dataclass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frozen&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Site&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;cls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;why&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;kinds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;tuple&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="c1"&gt;# journal kinds written (the journal family only)&lt;/span&gt;
    &lt;span class="n"&gt;via&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;  &lt;span class="c1"&gt;# the registered function whose journal entry covers a provider or model call&lt;/span&gt;
    &lt;span class="n"&gt;by&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;  &lt;span class="c1"&gt;# the function that reads the effect back, checks it first, or closes it in the review&lt;/span&gt;
    &lt;span class="n"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;  &lt;span class="c1"&gt;# the bead for a known uncovered part&lt;/span&gt;
    &lt;span class="n"&gt;after&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;tuple&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="c1"&gt;# kinds of a journaled-before site written after the effect&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;gap&lt;/code&gt; field matters more than it looks. It lets the registry admit an uncovered effect without lying about it, and it must carry a tracked-task ID. The &lt;code&gt;after&lt;/code&gt; field lists kinds a journaled_before site writes once the effect is done, such as an outcome record, and the test checks it names some but not all of that site's kinds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not a runtime decorator?
&lt;/h2&gt;

&lt;p&gt;The obvious design is a decorator: mark each effectful function &lt;code&gt;@effect("smtp")&lt;/code&gt; and check coverage at runtime. The PR chose call-site discovery instead, for two reasons.&lt;/p&gt;

&lt;p&gt;First, discovery needs no change to application code. The registry is data and the test is static.&lt;/p&gt;

&lt;p&gt;Second, a decorator only knows about functions somebody remembered to decorate. That is the same failure as the hand-written list, moved into the source. Discovery reads the code and finds the provider call whether or not anyone thought to mark it. A new &lt;code&gt;send_mail&lt;/code&gt; with no registry entry fails the build.&lt;/p&gt;

&lt;h2&gt;
  
  
  The test: find every outward call with &lt;code&gt;ast&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;tests/test_effect_registry.py&lt;/code&gt; parses every source file into an abstract syntax tree with &lt;a href="https://docs.python.org/3/library/ast.html" rel="noopener noreferrer"&gt;Python's &lt;code&gt;ast&lt;/code&gt; module&lt;/a&gt; and builds a map of &lt;code&gt;{function: {family: calls}}&lt;/code&gt;. Its import resolver handles module imports, aliases, relative imports and by-name imports, because &lt;code&gt;from django.core.mail import send_mail as sm&lt;/code&gt; is still a mail call.&lt;/p&gt;

&lt;p&gt;It has nine test functions. The first three check the registry against the source, and the fourth checks that the scanner knows every provider write method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test_9kg62_every_function_with_an_effect_is_registered_and_no_registration_is_stale(sites)
test_9kg62_each_class_matches_what_the_function_does(sites)
test_9kg62_every_journal_kind_has_a_writer_and_each_restrictive_kind_is_prepared(sites)
test_9kg62_the_scanner_knows_every_write_method_of_each_provider_client()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Of the other five, four test the scanner on synthetic source (import spellings, kind resolution, lookalike calls, an unreviewed outward module). One checks the real code against the outward-module allow-list.&lt;/p&gt;

&lt;p&gt;Between them, the tests fail when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a function with an effect is unregistered, an entry is stale, or the family is wrong;&lt;/li&gt;
&lt;li&gt;the class does not match the calls the function makes;&lt;/li&gt;
&lt;li&gt;a journaled_before entry is written after the provider call it precedes in the same function;&lt;/li&gt;
&lt;li&gt;a checked_before action writes before it reads;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;by&lt;/code&gt; or &lt;code&gt;via&lt;/code&gt; is missing, or &lt;code&gt;gap&lt;/code&gt; is not a tracked-task ID;&lt;/li&gt;
&lt;li&gt;a journal kind does not resolve to a literal, a constant or a literal caller argument;&lt;/li&gt;
&lt;li&gt;the provider client has a write method the scanner does not know;&lt;/li&gt;
&lt;li&gt;any module outside a reviewed allow-list of twelve imports a network or process module, or writes, moves or removes a file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last two are the drift guards for the scanner itself. If someone adds a new write method to the Documenso client, the scanner has no rule for it, and the fourth test fails until a human teaches it. If a thirteenth module starts opening sockets or deleting files, the allow-list test fails.&lt;/p&gt;

&lt;p&gt;The ordering rule is the least obvious one. "Journaled before" is only true if the journal write precedes the provider call in source order. Here is the idea, reduced to a hypothetical sketch (not the shipped code):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Hypothetical reduction of the ordering check.&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;first_call_line&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;lines&lt;/span&gt; &lt;span class="o"&gt;=&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="n"&gt;lineno&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&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;isinstance&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="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Call&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nf"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;journal_at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;first_call_line&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;is_journal_write&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;provider_at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;first_call_line&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;is_provider_call&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;journal_at&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;provider_at&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;journal_at&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;provider_at&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This only decides order inside one function. Order across functions is not checked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verifying the AST test with hand mutations
&lt;/h2&gt;

&lt;p&gt;A static test that passes on day one proves nothing about whether it can fail. The same rule for a CI gate is in &lt;a href="https://startaitools.com/posts/the-gate-that-could-not-fail/" rel="noopener noreferrer"&gt;Make the Guard Prove It Can Fail&lt;/a&gt;. So the verification was mutation by hand: break the code or the registry on purpose, one change at a time, and confirm the intended test catches it.&lt;/p&gt;

&lt;p&gt;The registry test and the repository's test-selection test together ran 28 passed, 0 failed. Then 21 hand mutations, each caught by the test meant to catch it. The first round of twelve covered a dropped site, a stale entry, the wrong class, the wrong kind, a bad &lt;code&gt;via&lt;/code&gt;, a missing &lt;code&gt;via&lt;/code&gt;, a dropped family, a marker that was really a record, an undeclared kind, a restrictive kind never prepared, an empty reason and an injected unregistered send.&lt;/p&gt;

&lt;p&gt;The second round of nine: a dropped Django mail site, a missing reader, an absent &lt;code&gt;by&lt;/code&gt;, a non-task &lt;code&gt;gap&lt;/code&gt;, a removed erasure completion caller, &lt;code&gt;FileCopy&lt;/code&gt; writing before it reads, the &lt;code&gt;send_begun&lt;/code&gt; journal write moved after SMTP, a dynamic journal kind and a removed staff-role prepare. Separately from the 21, an injected module with outward calls was also caught.&lt;/p&gt;

&lt;h2&gt;
  
  
  What writing the registry and its QA pass found
&lt;/h2&gt;

&lt;p&gt;The first version of the registry was incomplete, and a separate QA agent pass (static reading only) showed it. That pass returned seven findings. Five were fixed in the PR. One was filed as a tracked task and one was partly fixed. The PR's own list of five findings, below, draws on both the writing and the QA pass and only partly overlaps the QA agent's seven. Each one says what happened to it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Three applicant mails were missing (fixed).&lt;/strong&gt; The contact confirmation, the password setup and the withdrawal link go through &lt;a href="https://docs.djangoproject.com/en/stable/topics/email/" rel="noopener noreferrer"&gt;Django's mailer&lt;/a&gt;, not the app's correspondence transport. The first version of the registry missed all three. Django mail is its own family in the registry. The post-restore review covers them by superseding every live link they carry.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;FileCopy&lt;/code&gt; was misclassified (fixed).&lt;/strong&gt; It was registered as read back by the Sent-folder reader. That reader skips filed copies. What &lt;code&gt;FileCopy&lt;/code&gt; actually does is search the Sent folder before it files, so it is now checked_before, with an order check behind it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The revocation's host calls are outside the journal (registered as covered_by_review).&lt;/strong&gt; Password rotation and forwarder removal run before the transaction that prepares the revocation entry. The review's revocation round covers them, so they are registered covered_by_review.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A failed restrictive prepare does not stop its effect (recorded, not changed).&lt;/strong&gt; The failure is logged, counted and refused at readiness. Only the erasure and custody records refuse their effect outright. This was recorded, not changed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A second envelope after a restore had no coverage at all (filed, then closed by a follow-up PR).&lt;/strong&gt; An agreement created and distributed after the backup has no row once you restore. Nothing read its envelope. The external key is random, so the restored system would create a new agreement and distribute a second envelope to the same signer. The registry could only mark this as a gap, because a runtime fix did not belong in a test-only PR.&lt;/p&gt;

&lt;p&gt;That last one was the main finding. Writing and reviewing the registry forced every function through the question "who reads this back?", and for envelopes created after the backup the honest answer was "nobody". The test could not fail on this. It could only carry the gap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing the gap with a bounded Documenso envelope listing
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://github.com/intent-solutions-io/catalyst-onboarding-v2/pull/119" rel="noopener noreferrer"&gt;follow-up PR&lt;/a&gt; added an unknown-envelope scan to the post-restore Documenso read, &lt;code&gt;agreements.restore.read_envelopes&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It lists the Documenso team's envelopes from every template, newest first, back to one hour before the backup's start, so a template the restored tables do not know is covered too. Any envelope with the app's key shape (&lt;code&gt;ag_&lt;/code&gt; plus 32 hex characters) that no restored agreement or envelope attempt names, by envelope id or external key, opens one review item. The item is keyed by a digest of the envelope id, and the raw id is stored in neither the item nor its audit event. It carries the application only when exactly one verified applicant is a signer.&lt;/p&gt;

&lt;p&gt;The listing is bounded by a configured page limit (the PR's risk note puts it at 20 pages of 100). If it hits that limit before reaching the backup's start, it reports &lt;code&gt;incomplete:listing_limit&lt;/code&gt;, and any status other than &lt;code&gt;ok&lt;/code&gt; refuses to lift the restore hold. A truncated listing is treated as incomplete, never as clean. The registry entry's &lt;code&gt;gap&lt;/code&gt; was then removed, as the task's acceptance required. That PR's targeted run was 82 passed. The gap is closed in code, pending the provider check described below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not journal every create instead?
&lt;/h2&gt;

&lt;p&gt;The alternative was a journal entry per envelope create. The listing won for two reasons. It already existed for reconciliation, so no new write path. And it finds a create whose journal append was lost, which a journal entry cannot do by definition.&lt;/p&gt;

&lt;p&gt;Envelopes without the app's key shape belong to another writer on the same Documenso team and are ignored. The cost of that team-wide listing is volume: another writer's envelopes count toward the page limit. Hitting it fails closed until the system's operator raises the limit or resolves the items by hand.&lt;/p&gt;

&lt;h2&gt;
  
  
  Known blind spots
&lt;/h2&gt;

&lt;p&gt;The test's docstring lists its own blind spots:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;receivers held in attributes or reached through &lt;code&gt;getattr&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;a database write that should be journaled and is not;&lt;/li&gt;
&lt;li&gt;whether a named reader actually reads what the entry says.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The ordering check also works only inside one function, as noted above.&lt;/p&gt;

&lt;p&gt;Documenso's real behaviour is also unverified. Its list ordering, default status filter and field names are not confirmed against the installed version, so the scan checks order itself and never trusts a page count. A canary against the real provider is where that gets settled. Resolving an unknown envelope is currently by the operator's note alone, and whether a note is enough is the operator's call.&lt;/p&gt;

&lt;p&gt;The test is brittle by design. Rename an effectful function, add a provider write method or add a file-writing module and the build fails until someone reviews the change. That is intended: a failing build is the moment the hand-written list used to go stale silently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Also shipped
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;code&gt;journal-ship&lt;/code&gt; service copies the effect journal off the production host, so the journal survives the host it describes. It runs with &lt;code&gt;network_mode: none&lt;/code&gt; because it only reads and writes files (&lt;a href="https://github.com/intent-solutions-io/catalyst-onboarding-v2/pull/123" rel="noopener noreferrer"&gt;PR #123&lt;/a&gt;, 239 passed in its targeted run).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Use this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;List every function in your app that calls a provider (mail, e-signature, payments, mailbox APIs) and give it a recovery class for each provider it touches, plus the name of the function that recovers it.&lt;/li&gt;
&lt;li&gt;Write a static test that discovers those calls from source, including aliased and relative imports, and fails on any call it can resolve that the registry has not classified; then mutate it by hand until each failure mode has been caught once.&lt;/li&gt;
&lt;li&gt;For an effect that nothing reads back and the review does not close, add a post-restore provider listing with a time floor just before the backup's start and a page limit, make a truncated listing keep the restore hold in place, and confirm the provider's list behaviour against the real service.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The registry and its AST test are in &lt;a href="https://github.com/intent-solutions-io/catalyst-onboarding-v2/pull/117" rel="noopener noreferrer"&gt;catalyst-onboarding-v2 PR #117&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is an effect journal?
&lt;/h3&gt;

&lt;p&gt;An effect journal is an append-only log of outward actions, kept outside the database. After a restore, a post-restore review reads that journal and the providers, then decides whether to lift the restore hold.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do you stop a restored app from repeating an email or envelope?
&lt;/h3&gt;

&lt;p&gt;Give every function that calls an outside service one recovery class per provider family in a registry, and name the function that recovers it. A checked_before action reads the provider before it writes, so a repeated run finds the effect and skips it. Where nothing reads an effect back and the review does not close it, a bounded provider listing looks for envelopes the restored database does not name.&lt;/p&gt;

&lt;h3&gt;
  
  
  How can a test catch an effect nobody registered?
&lt;/h3&gt;

&lt;p&gt;An AST test parses every source file, follows aliased and relative imports, and fails the build when a function with an effect is unregistered, stale or in the wrong class. It was checked with 21 hand mutations, each caught by the test meant to catch it. It still cannot see receivers held in attributes or reached through getattr.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/working-is-not-proven/" rel="noopener noreferrer"&gt;Every Claim Needs a Shipped Source and an Executable Proof&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/the-drills-passed-reality-did-not/" rel="noopener noreferrer"&gt;The Drills Passed. Reality Did Not.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://startaitools.com/posts/rehearse-before-production-catches-what-tests-cant/" rel="noopener noreferrer"&gt;Rehearse the deploy, not the test suite&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>testing</category>
      <category>python</category>
      <category>architecture</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
