<?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: Pavel Kazantsev 💎</title>
    <description>The latest articles on DEV Community by Pavel Kazantsev 💎 (@pavel_kkkkazantsev).</description>
    <link>https://dev.to/pavel_kkkkazantsev</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%2F4134503%2Ffa19808d-55bb-4682-9e96-cb3962636da8.PNG</url>
      <title>DEV Community: Pavel Kazantsev 💎</title>
      <link>https://dev.to/pavel_kkkkazantsev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pavel_kkkkazantsev"/>
    <language>en</language>
    <item>
      <title>I Thought a Git Commit Proved My Experiment Was Pre-Registered. It Didn't.</title>
      <dc:creator>Pavel Kazantsev 💎</dc:creator>
      <pubDate>Mon, 23 Nov 2026 15:46:18 +0000</pubDate>
      <link>https://dev.to/pavel_kkkkazantsev/i-thought-a-git-commit-proved-my-experiment-was-pre-registered-it-didnt-3j2g</link>
      <guid>https://dev.to/pavel_kkkkazantsev/i-thought-a-git-commit-proved-my-experiment-was-pre-registered-it-didnt-3j2g</guid>
      <description>&lt;p&gt;I found an old research draft that treated a local Git commit as proof that a hypothesis had existed before the data was examined.&lt;/p&gt;

&lt;p&gt;The repository had no commits.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1t7wlm35ye388ffgampe.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1t7wlm35ye388ffgampe.gif" alt="This is fine: a calm dog sitting in a room on fire" width="600" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That invalidated the provenance claim. It did not prove the proposed analysis was wrong. It meant I could not use chronology as evidence that the hypothesis preceded the analysis, so I removed the claimed result instead of trying to make the old story sound more rigorous.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbgcltz94lst9ud3uyqz1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbgcltz94lst9ud3uyqz1.png" alt="A local Git commit compared with a public, inspectable research evidence chain" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Git does and does not prove
&lt;/h2&gt;

&lt;p&gt;Git is excellent at recording content identity and ancestry. If two people have the same commit object, they can verify the tree, parent references, author identity fields, and commit message that created it. That is useful provenance.&lt;/p&gt;

&lt;p&gt;It is a weaker claim than a trustworthy wall-clock timestamp. Git accepts author and committer dates from environment variables. The official &lt;a href="https://git-scm.com/docs/git-commit" rel="noopener noreferrer"&gt;Git documentation&lt;/a&gt; describes &lt;code&gt;GIT_AUTHOR_DATE&lt;/code&gt; and &lt;code&gt;GIT_COMMITTER_DATE&lt;/code&gt; as inputs to commit creation. A locally created commit can preserve a plausible chronology without independently establishing 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;# Both timestamps are metadata supplied when the commit is created.&lt;/span&gt;
&lt;span class="nv"&gt;GIT_AUTHOR_DATE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"2024-01-01T00:00:00Z"&lt;/span&gt; \
&lt;span class="nv"&gt;GIT_COMMITTER_DATE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"2024-01-01T00:00:00Z"&lt;/span&gt; \
git commit -m &lt;span class="s2"&gt;"protocol"&lt;/span&gt;

&lt;span class="c"&gt;# The hash binds this content to those fields.&lt;/span&gt;
&lt;span class="c"&gt;# It does not ask an outside clock whether the date was true.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For this kind of claim, Git tracks the protocol's content. The other records establish its chronology and relationship to the data.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a defensible pre-registration has to show
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fup7qu816c1h9l2m9y0ni.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fup7qu816c1h9l2m9y0ni.png" alt="Four records in a defensible pre-registration: protocol, external timestamp, data boundary, and run record" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, write a protocol that can lose. “Test mean reversion” is a research direction. It is not a pre-registered hypothesis. The protocol needs the universe, feature definition, data range, execution timing, parameters, primary statistic, success rule, and kill rule.&lt;/p&gt;

&lt;p&gt;Second, anchor the exact protocol outside the researcher's machine. A public remote record, a signed release, an archival deposit, or a time-stamping service can create evidence another person can inspect. These mechanisms differ in strength.&lt;/p&gt;

&lt;p&gt;Third, define the data boundary. A protocol written today cannot make a dataset “unseen” if the researcher already explored it. Record the source, retrieval time, time cutoff, instrument universe, and hashes or IDs of the input files or queries. The confirmation period must start after that boundary.&lt;/p&gt;

&lt;p&gt;Finally, retain the run record: code revision, environment, raw output, derived metrics, and deviations. Without it, a reader cannot tell whether the reported result came from the frozen plan or a nearby variant.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvfdmprua0a54nahgay1b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvfdmprua0a54nahgay1b.png" alt="The required order: protocol, public anchor, unopened data boundary, recorded run, and scoped result" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A protocol should be machine-checkable
&lt;/h2&gt;

&lt;p&gt;The prose is for the reviewer. A small manifest is for the runner and for future me. It makes omissions and parameter changes visible in a diff.&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;"study_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"cross-sectional-reversal-v1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"hypothesis"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"A fixed reversal signal has positive net performance on the future window."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"data_boundary"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"declared vendor and endpoint"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"cutoff_utc"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-23T00:00:00Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"universe_rule"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"declared before retrieval"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"input_manifest_sha256"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;computed after retrieval&amp;gt;"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"primary_test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"metric"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"net annualised Sharpe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"minimum"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"cost_model"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"declared before the run"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"kill_rule"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"fail if the primary test does not pass"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"protocol_sha256"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;hash of this exact file&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;The placeholders show the boundary between the claim being fixed now and the evidence generated later. Filling a future hash or result before the run would defeat the point.&lt;/p&gt;

&lt;h2&gt;
  
  
  What public hosting adds
&lt;/h2&gt;

&lt;p&gt;Publishing a protocol in a public repository gives collaborators and readers a place to inspect its contents. Signed commits and protected references make silent rewriting harder. GitHub documents both &lt;a href="https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches" rel="noopener noreferrer"&gt;protected branches&lt;/a&gt; and rules that can &lt;a href="https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets" rel="noopener noreferrer"&gt;require signed commits or block force pushes&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;These settings strengthen a workflow without turning GitHub into a scientific registry. State exactly which evidence was used: a public commit, a signed tag, an archive deposit, a third-party timestamp, or some combination. Readers can then judge the remaining trust assumptions.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I can claim about the old study
&lt;/h2&gt;

&lt;p&gt;The old draft has a written protocol and a proposed analysis path. Its materials contain no verified public pre-registration artifact, demonstrated untouched confirmation window, or evidence package from which a reader can reproduce the reported statistic. I therefore do not treat it as a confirmed finding or use it as support for a trading decision.&lt;/p&gt;

&lt;p&gt;The next protocol needs a public anchor before its future data boundary opens. Its records should remain available whether the result is positive, negative, or empty.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://git-scm.com/docs/git-commit" rel="noopener noreferrer"&gt;Git documentation: commit identity and date environment variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches" rel="noopener noreferrer"&gt;GitHub documentation: protected branches&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets" rel="noopener noreferrer"&gt;GitHub documentation: signed commits and force-push rules&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>git</category>
      <category>testing</category>
      <category>machinelearning</category>
      <category>opensource</category>
    </item>
    <item>
      <title>I Asked a Local Vision Model 36 Questions About GTA VI. One Answer Broke the Contract.</title>
      <dc:creator>Pavel Kazantsev 💎</dc:creator>
      <pubDate>Thu, 19 Nov 2026 16:04:24 +0000</pubDate>
      <link>https://dev.to/pavel_kkkkazantsev/i-asked-a-local-vision-model-36-questions-about-gta-vi-one-answer-broke-the-contract-4i9g</link>
      <guid>https://dev.to/pavel_kkkkazantsev/i-asked-a-local-vision-model-36-questions-about-gta-vi-one-answer-broke-the-contract-4i9g</guid>
      <description>&lt;p&gt;I gave local Gemma 3 36 fixed visual questions about 12 screenshots from Rockstar's public GTA VI gallery.&lt;/p&gt;

&lt;p&gt;It got 31 right under exact matching.&lt;/p&gt;

&lt;p&gt;On one screenshot it returned &lt;code&gt;"blue"&lt;/code&gt; for a field whose contract accepted only &lt;code&gt;yes&lt;/code&gt;, &lt;code&gt;no&lt;/code&gt;, or &lt;code&gt;unclear&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The word fit the scene and was close to the expected &lt;code&gt;yes&lt;/code&gt;. It was still invalid input. A validator cannot infer whether an undocumented value is true, a colour label, or a malformed response.&lt;/p&gt;

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

&lt;p&gt;I used &lt;a href="https://www.rockstargames.com/VI/media/screenshots" rel="noopener noreferrer"&gt;Rockstar's public GTA VI screenshot gallery&lt;/a&gt;, not YouTube, walkthroughs, leaks, or player captures. I selected 12 screenshots across character, city, water, nightlife, and rural scenes. The public audit record holds source URLs, gallery labels, expected answers, and both model runs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2e2zi7ew3g0qsup3uaht.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2e2zi7ew3g0qsup3uaht.png" alt="Map of the twelve official Rockstar screenshots used in the audit" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The selection spans several scene types. It is documented, not random.&lt;/p&gt;

&lt;p&gt;Before inference, I wrote three binary labels for every screenshot: 24 facts that were present and 12 that were absent. The runner used local &lt;code&gt;gemma3:4b&lt;/code&gt; through Ollama at temperature 0. Every image received the same question format.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Answer each question from visible pixels only.
Return JSON exactly as:
{ "answers": { "id": "yes|no|unclear" } }

Use yes only when the frame visibly supports the statement,
no only when it visibly contradicts it, and unclear otherwise.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx5joq9i7k585lmlrnaep.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx5joq9i7k585lmlrnaep.png" alt="Question contract showing two present facts and one absent fact per screenshot, with only yes, no, or unclear allowed as output" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I did not alter the prompt after seeing an answer. The first run is the reported score. An immediate duplicate run did not change any answers; it does not create a better score.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faebzjtay7f6iiy75i80x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faebzjtay7f6iiy75i80x.png" alt="Protocol diagram from official source frames through a fixed claim sheet and prompt to item-level scoring" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  31 of 36 strict answers were correct
&lt;/h2&gt;

&lt;p&gt;The first run scored 31/36 under a strict rule: a response is correct only when it exactly matches the pre-labelled &lt;code&gt;yes&lt;/code&gt; or &lt;code&gt;no&lt;/code&gt;. The invalid value &lt;code&gt;blue&lt;/code&gt; was wrong, even though the question asked whether the scene had purple or blue lighting. A calling program needs exact values before it can branch on them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;strict_accuracy = count(run_1_answer === label) / 36
schema_validity = count(run_1_answer in {yes, no, unclear}) / 36
duplicate_run_agreement = count(run_1_answer === run_2_answer) / 36

# An "unclear" answer scores as wrong here:
# every question was labelled yes or no before inference.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwzkpqa8tzh3kdnh7f0s4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwzkpqa8tzh3kdnh7f0s4.png" alt="Strict scorecard: 31 of 36 correct, with 23 of 24 labelled-present facts and 8 of 12 labelled-absent facts answered correctly" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The duplicate run reproduced all 36 outputs, including the invalid enum. That does not make the first mistake safe to consume.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu73mr5lqlohqnw5om1e2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu73mr5lqlohqnw5om1e2.png" alt="Schema validator rejects blue, then a constrained retry returns yes while the original score stays 31 of 36" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A retry can recover an operational failure. It leaves the first-run score unchanged.&lt;/p&gt;

&lt;h2&gt;
  
  
  Absence was weaker in this sample
&lt;/h2&gt;

&lt;p&gt;On questions whose answer was &lt;code&gt;yes&lt;/code&gt;, the model was strictly correct 23/24 times. On questions whose answer was &lt;code&gt;no&lt;/code&gt;, it was correct 8/12 times. Three times it chose &lt;code&gt;unclear&lt;/code&gt; for an obvious absence. Once it answered &lt;code&gt;yes&lt;/code&gt; to a helmet that was not in the underwater scene.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F340s8uhay9nc9u24s64w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F340s8uhay9nc9u24s64w.png" alt="Breakdown of absent-object errors: eight correct no answers, three unclear answers, and one false yes" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Expected label&lt;/th&gt;
&lt;th&gt;Model response&lt;/th&gt;
&lt;th&gt;Why it failed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Blue or purple lighting: &lt;code&gt;yes&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;blue&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Schema violation. Semantically plausible, operationally unusable.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Motorcycle rider wears a helmet: &lt;code&gt;no&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;unclear&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Abstained despite the rider's uncovered head.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Woman with handgun is underwater: &lt;code&gt;no&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;unclear&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Abstained despite rain on a window and a vehicle interior.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Underwater diver wears a helmet: &lt;code&gt;no&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;yes&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Confused diving equipment with a helmet.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dog in the cash frame: &lt;code&gt;no&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;unclear&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Uncertainty replaced a clear negative answer.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A one-item retry with an explicit enum-only instruction returned &lt;code&gt;yes&lt;/code&gt;. The first-run score remains 31/36. A validator still needs to see the bad value and choose whether to retry, escalate, or fail closed.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I would use this in a product
&lt;/h2&gt;

&lt;p&gt;A content-moderation tool, game-search feature, or media-analysis agent should validate the output schema before it writes a fact into a record. It should also distinguish “object present” from “object absent.” The two tasks had visibly different behavior in this small run.&lt;/p&gt;

&lt;p&gt;Object presence, readable text, clothing attributes, and scene interpretation fail in different ways. An aggregate vision score hides that distinction.&lt;/p&gt;

&lt;h2&gt;
  
  
  What would make this a benchmark
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Two independent human reviewers and adjudication rules for every label.&lt;/li&gt;
&lt;li&gt;More screenshots from a declared sampling plan, including hard negatives.&lt;/li&gt;
&lt;li&gt;Several models, repeated runs, and model-version records.&lt;/li&gt;
&lt;li&gt;Per-class precision, recall, and an abstention policy fixed before the run.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This run used one quantized local model and twelve screenshots selected and labelled by one reviewer. There was no independent adjudication. The score does not compare models, predict gameplay performance, or measure a production vision system. It records one fixed local run and the validation controls a production integration would need.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb170jaz7bgz14ok5td91.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb170jaz7bgz14ok5td91.png" alt="Scope diagram separating what this fixed run supports from claims it cannot establish" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources and audit record
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/icesurf666/gta-vi-vision-audit" rel="noopener noreferrer"&gt;Reproducibility package on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.pkazantsev.com/writing/gta-vision-benchmark/screenshot-audit.json" rel="noopener noreferrer"&gt;Audit JSON: source URLs, fixed labels, both runs, and score calculation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.rockstargames.com/VI/media/screenshots" rel="noopener noreferrer"&gt;Rockstar Games: GTA VI official screenshot gallery&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The canonical version of this post is on &lt;a href="https://www.pkazantsev.com/writing/gta-vi-vision-audit/" rel="noopener noreferrer"&gt;my site&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>testing</category>
    </item>
    <item>
      <title>My ML Feature Used the Wrong Unit. The Threshold Was 400x Too Large.</title>
      <dc:creator>Pavel Kazantsev 💎</dc:creator>
      <pubDate>Fri, 13 Nov 2026 17:20:41 +0000</pubDate>
      <link>https://dev.to/pavel_kkkkazantsev/my-ml-feature-used-the-wrong-unit-the-threshold-was-400x-too-large-4add</link>
      <guid>https://dev.to/pavel_kkkkazantsev/my-ml-feature-used-the-wrong-unit-the-threshold-was-400x-too-large-4add</guid>
      <description>&lt;p&gt;The historical model and the live validator both calculated &lt;code&gt;large_share&lt;/code&gt;, the fraction of sweep volume in unusually large trades. Their definitions had diverged.&lt;/p&gt;

&lt;p&gt;The live code used the 75th percentile of per-second net aggressive volume as the cutoff for an individual trade. On the affected symbols, that threshold was 163–423 times too large. Almost no individual trade cleared it, so &lt;code&gt;large_share&lt;/code&gt; was near zero in 97% or more of live events.&lt;/p&gt;

&lt;p&gt;The public audit package includes the minimal reproducible fixture, the feature-contract checks, and the recorded aggregate results used here. It does not include the underlying market-data archive.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Evidence package:&lt;/strong&gt; &lt;a href="https://github.com/icesurf666/quant-research-notes/tree/main/studies/hfm-feature-contract-audit" rel="noopener noreferrer"&gt;open the feature-contract tests and frozen raw-replay summary on GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;For AAVEUSDT, the 75th percentile of individual trade quantity was 4.3 units. The 75th percentile of per-second NAV was 1,730 units. Both are volumes; they are not interchangeable.&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;large_thr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;percentile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dev&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"nav_abs"&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="mi"&gt;75&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# nav_abs: per-second net aggressive volume&lt;/span&gt;

&lt;span class="n"&gt;large_share&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;volume_of_trades_at_or_above&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;large_thr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;total_volume&lt;/span&gt;
&lt;span class="c1"&gt;# threshold is applied to individual trades&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The correct calibration comes from individual trade quantities. The repaired live path refuses to score a symbol when it lacks a matching calibration artifact.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three other feature contracts also differed
&lt;/h2&gt;

&lt;p&gt;The feature-parity audit found three other differences between training and live:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Historical contract&lt;/th&gt;
&lt;th&gt;Live defect&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;large_share&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Individual trade-size percentile&lt;/td&gt;
&lt;td&gt;Per-second NAV percentile&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;run_frac&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Longest consecutive trade run / trade count&lt;/td&gt;
&lt;td&gt;Buy-volume fraction&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pre_vel&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Direction-adjusted signed flow&lt;/td&gt;
&lt;td&gt;Unsigned volume&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;trailing_nav&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Direction-adjusted trailing flow&lt;/td&gt;
&lt;td&gt;Direction omitted&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4byvbbsuscbvs1w8lu1l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4byvbbsuscbvs1w8lu1l.png" alt="Four feature contracts differ between historical batch calculation and live streaming calculation" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;large_share&lt;/code&gt; defect was the main false-positive driver. In the first analytical triage of 14 October, fixing it alone reduced selected candidates from 40 to 5. Applying all four corrections left 2.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsm5bsc2mxav22h6njavw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsm5bsc2mxav22h6njavw.png" alt="Selected candidates fell from 40 under the broken implementation to 5 after the unit fix and 2 after all four feature-contract repairs" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Those are diagnostic counts from before the October raw-trade archive was recovered; two feature values were approximated in that first pass.&lt;/p&gt;

&lt;p&gt;We subsequently recovered Binance Futures &lt;code&gt;aggTrades&lt;/code&gt; for 6–14 October. The raw reconstruction keeps the recorded candidate timestamps and uses the matching frozen artifacts: V1 live for 6–13 October (13,786 candidates) and V2 full baseline for 14 October (895).&lt;/p&gt;

&lt;p&gt;It rebuilt the four affected feature families for 14,681 of 14,682 candidates. One LDOUSDT detection second was absent from the archive. The frozen artifacts reproduced recorded scores with a mean absolute difference of 1.04×10⁻⁶.&lt;/p&gt;

&lt;p&gt;The repaired features selected 52 candidates. Their raw five-second Binance markout averaged +8.67 bps. With a 10 bps round-trip fee assumption, that becomes −1.33 bps. No strategy was promoted.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4mlmtitv1gzmchrp8re7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4mlmtitv1gzmchrp8re7.png" alt="Raw trades rebuilt four corrected feature families for 14,681 of 14,682 recorded candidates. The 52 selected candidates averaged 8.67 bps before, and negative 1.33 bps after, a 10 bps fee assumption" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The raw archive resolves the four-feature reconstruction gap. A five-second Binance markout is a research measure. Candidate generation and the logged &lt;code&gt;nav_abs&lt;/code&gt; / &lt;code&gt;nav_overshoot&lt;/code&gt; convention remain fixed, so this is not an execution study.&lt;/p&gt;

&lt;h2&gt;
  
  
  Drift monitoring comes after parity
&lt;/h2&gt;

&lt;p&gt;A KS test can show that two feature distributions differ. It does not establish whether one implementation used individual trades while another used one-second aggregates.&lt;/p&gt;

&lt;p&gt;Before monitoring feature drift, run both implementations against the same recorded raw inputs:&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;for&lt;/span&gt; &lt;span class="n"&gt;fixture&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;recorded_sweeps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;historical&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;batch_features&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fixture&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;trades&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fixture&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;direction&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;live&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;streaming_features&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fixture&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;trades&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fixture&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;direction&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;historical&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;large_share&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;live&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;large_share&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;historical&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run_frac&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;live&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run_frac&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;historical&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pre_vel&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;live&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pre_vel&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;historical&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;trailing_nav&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;live&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;trailing_nav&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Record the threshold's unit, symbol, source period, and input hash beside the calibration artifact. Check feature parity before interpreting a model score.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part of the &lt;a href="https://www.pkazantsev.com/writing/hfm-research-origin/" rel="noopener noreferrer"&gt;HFM Research methodology series&lt;/a&gt;.&lt;/em&gt; &lt;/p&gt;

</description>
      <category>debugging</category>
      <category>machinelearning</category>
      <category>softwareengineering</category>
      <category>testing</category>
    </item>
    <item>
      <title>We Tested 12,720 Exit Rules. The Result Wasn't Validated.</title>
      <dc:creator>Pavel Kazantsev 💎</dc:creator>
      <pubDate>Sat, 07 Nov 2026 19:08:47 +0000</pubDate>
      <link>https://dev.to/pavel_kkkkazantsev/we-tested-12720-exit-rules-the-result-wasnt-validated-491c</link>
      <guid>https://dev.to/pavel_kkkkazantsev/we-tested-12720-exit-rules-the-result-wasnt-validated-491c</guid>
      <description>&lt;p&gt;HFM's exit simulator evaluated 12,720 configurations over 14,399 qualifying events across 15 crypto symbols. One selected configuration reported an average of +25.98 basis points per event after the simulator's 10 bps fee deduction. That is about 0.26% per event, enough to warrant a closer look.&lt;/p&gt;

&lt;p&gt;Removing one session changed the average to −3.69 bps. The exit search had also used the validation split. The archive contained summaries rather than the joint outcome record needed to test the whole search.&lt;/p&gt;

&lt;h2&gt;
  
  
  The configuration behind +25.98 bps
&lt;/h2&gt;

&lt;p&gt;The audited rule used a momentum exit: a 50 bps initial stop, a 60-second momentum window, a 30 bps reversal threshold, and a maximum hold of 600 seconds. The backtest covered September 2025 through September 2026. These are simulated outcomes with modeled fills and fees, not live-trading returns:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Audited configuration&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Qualifying events&lt;/td&gt;
&lt;td&gt;14,399 across 15 symbols&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mean net outcome per event&lt;/td&gt;
&lt;td&gt;+25.98 bps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Median net outcome per event&lt;/td&gt;
&lt;td&gt;−16.2 bps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Win rate&lt;/td&gt;
&lt;td&gt;34%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mean net outcome excluding 2025-10-10&lt;/td&gt;
&lt;td&gt;−3.69 bps&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The median event lost money, while a small part of the sample pulled the mean positive. The &lt;a href="https://www.pkazantsev.com/writing/backtest-day-block-t/" rel="noopener noreferrer"&gt;separate day-block audit&lt;/a&gt; treats the market session as the relevant unit: removing 10 October 2025 removed the positive event-level average. This is a sensitivity diagnostic. It does not justify discarding an inconvenient day and calling the remainder an unbiased estimate.&lt;/p&gt;

&lt;p&gt;These are statistics for the selected rule's events. They are not the best and median scores across all 12,720 configurations; the archived material available for this article does not establish that distribution.&lt;/p&gt;

&lt;h2&gt;
  
  
  12,720 rules used the same history
&lt;/h2&gt;

&lt;p&gt;The grid contained 240 fixed-stop configurations, 8,640 trailing stops, 1,680 break-even-plus-trail rules, and 2,160 momentum exits. Changing a stop or trailing distance did not produce an independent sample: every configuration was evaluated on the same history.&lt;/p&gt;

&lt;p&gt;A test of one rule specified in advance asks a different question from a test of a rule chosen after inspecting thousands. For the search, the null is that none of the candidates beats a specified benchmark. The &lt;a href="https://doi.org/10.1111/1468-0262.00152" rel="noopener noreferrer"&gt;Reality Check&lt;/a&gt; tests that family-level claim; testing only the selected column leaves out how it was selected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnvlcnp1xnn2rs7vsckgm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnvlcnp1xnn2rs7vsckgm.png" alt="Four exit-rule families totalling 12,720 searched rules" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The trailing-stop family alone contributed 8,640 configurations. Nearby settings can share trades and market shocks.&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;# A significance threshold, not an observed p-value.
&lt;/span&gt;&lt;span class="n"&gt;alpha&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;
&lt;span class="n"&gt;n_rules&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12_720&lt;/span&gt;
&lt;span class="n"&gt;per_rule_alpha&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;n_rules&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;per_rule_alpha&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# 3.93e-06
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 3.93×10⁻⁶ value is the per-test significance threshold for a 5% Bonferroni family-wise error bound, not a p-value measured in HFM. The bound does not require independent rules, but each input p-value must already handle dependence in the observations. Dividing alpha by 12,720 cannot repair a test that treats events from the same market session as independent.&lt;/p&gt;

&lt;h2&gt;
  
  
  VAL had already entered the search
&lt;/h2&gt;

&lt;p&gt;The event-score threshold came from development scores. That is a normal fitting step, but results on those development events are in-sample. The exit-rule search then used both DEV and VAL, including the September 2026 validation period. There was no remaining untouched split for the selected configuration.&lt;/p&gt;

&lt;p&gt;Reusing VAL is a separate problem from the number of exit rules. A Reality Check can address a documented candidate search under its assumptions without requiring a separate holdout. It does not make VAL independent again or automatically account for earlier decisions about event filters, models, and which experiments to pursue.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Split&lt;/th&gt;
&lt;th&gt;How it was used&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;DEV&lt;/td&gt;
&lt;td&gt;Fit the event-score threshold; included in the exit search&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;VAL, September 2026&lt;/td&gt;
&lt;td&gt;Included in exit selection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Untouched holdout&lt;/td&gt;
&lt;td&gt;None remained for final evaluation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkc744yfjk7o2hpq31yns.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkc744yfjk7o2hpq31yns.png" alt="DEV and VAL both contributed to exit selection; no untouched holdout remained" width="799" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the simulator lost the audit trail
&lt;/h2&gt;

&lt;p&gt;In &lt;code&gt;exit_sim3.py&lt;/code&gt;, every candidate produces an array of event outcomes. The grid's &lt;code&gt;add()&lt;/code&gt; helper sends that array to &lt;code&gt;stats()&lt;/code&gt; and keeps a dictionary of means, quantiles, win rate, and parameters. It does not keep the underlying array. Earlier, &lt;code&gt;load_pass_paths()&lt;/code&gt; has already dropped dates and symbols when it returns the numeric paths.&lt;/p&gt;

&lt;p&gt;We therefore could not tell from the summaries which rules made money on the same dates. Two rules can have similar means and standard deviations but very different joint behavior. A bootstrap of the maximum needs that joint record, with every candidate carried through the same resampled time blocks.&lt;/p&gt;

&lt;p&gt;Without the retained rule-level outcome matrix, we could not reproduce a search-aware test from the archived results alone. The source code can recompute outcomes from events, model artifacts, and prices; an instrumented rerun could restore the record if the original inputs and versions are recoverable. That reconstruction has not been performed here.&lt;/p&gt;

&lt;h2&gt;
  
  
  A proposed output contract for the rerun
&lt;/h2&gt;

&lt;p&gt;I would retain one row per event and candidate before computing summaries. The following is a proposed schema, not a change already implemented in HFM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;run_id, event_id, detected_at_utc, symbol, candidate_id,
candidate_net_bps, benchmark_net_bps

# run manifest:
# code revision + input hashes + model/threshold artifacts
# complete grid + benchmark policy + fees/fills + ranking objective
# expected calendar + missing-input checks + split-use history
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a concrete benchmark, this proposed rerun would use a fixed exit 600 seconds after the same entry, with no optimized stop or target. Both policies would use the same event cohort, price-path construction, and 10 bps fee deduction. The benchmark must be fixed before the rerun; it was not a documented comparison behind the original +25.98 bps figure.&lt;/p&gt;

&lt;p&gt;The objective here is mean excess bps per event, not portfolio return. Each event has equal weight; overlapping signals are evaluated as separate hypothetical trades, without pretending that each can receive the same live capital. For every calendar date and candidate, save the sum of event-level excess outcomes and the event count. Dates without signals contribute zero to both; missing market data must be flagged rather than treated as a no-signal day.&lt;/p&gt;

&lt;p&gt;Saving the sum and count preserves the event-weighted objective when days contain different numbers of signals. The bootstrap sketch below centers each candidate under a zero-mean excess-outcome null, then resamples whole date blocks jointly. Resampling the raw positive-mean outcomes would retain the observed advantage instead of imposing that null; see the least-favorable-null discussion in &lt;a href="https://www.ine.es/GS_FILES/DocTrabajo/art_doctr022012.pdf" rel="noopener noreferrer"&gt;the INE review of predictive-ability tests&lt;/a&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="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="c1"&gt;# Proposed event-mean test; not an HFM test result.
# daily_sum: dates x candidates, summed excess bps for each date.
# daily_count: events per date, shared cohort across all candidates.
&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;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;asarray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;daily_sum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;asarray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;daily_count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;float&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;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ndim&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="ow"&gt;and&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;shape&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],)&lt;/span&gt;
&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&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="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&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="o"&gt;&amp;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="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isfinite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isfinite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;assert &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="nf"&gt;assert &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="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="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;mean_excess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;axis&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="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;observed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mean_excess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;centered&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;n&lt;/span&gt;&lt;span class="p"&gt;[:,&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;mean_excess&lt;/span&gt;  &lt;span class="c1"&gt;# zero excess per event
&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;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;default_rng&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;block_len&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2_000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;  &lt;span class="c1"&gt;# illustrative, not calibrated for HFM
&lt;/span&gt;&lt;span class="n"&gt;n_days&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;n_blocks&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_days&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;block_len&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="n"&gt;block_len&lt;/span&gt;
&lt;span class="n"&gt;null_max&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;null_max&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;starts&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;integers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n_days&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;n_blocks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;starts&lt;/span&gt;&lt;span class="p"&gt;[:,&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;arange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;block_len&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;n_days&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ravel&lt;/span&gt;&lt;span class="p"&gt;()[:&lt;/span&gt;&lt;span class="n"&gt;n_days&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;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;sum&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="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;
    &lt;span class="n"&gt;null_max&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;centered&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;axis&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="o"&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;idx&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="n"&gt;null_max&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;asarray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;null_max&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;p_hat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;count_nonzero&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;null_max&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;observed&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;B&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;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1cix78xcsp0au9cxn4tx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1cix78xcsp0au9cxn4tx.png" alt="Max-statistic bootstrap diagram for the proposed event-weighted objective" width="800" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code is an unstudentized, Reality-Check-style illustration for the proposed event-level objective, not a validated test implementation. The block-length rule, replication count, and stationarity and dependence assumptions still need checking. &lt;a href="https://doi.org/10.1198/073500105000000063" rel="noopener noreferrer"&gt;Hansen's SPA&lt;/a&gt; uses studentization and a different, data-dependent construction of the null distribution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which correction answers which question?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Question&lt;/th&gt;
&lt;th&gt;Appropriate starting point&lt;/th&gt;
&lt;th&gt;What it controls&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Can any pre-specified rule be called significant?&lt;/td&gt;
&lt;td&gt;Holm or Bonferroni&lt;/td&gt;
&lt;td&gt;Family-wise error; valid under arbitrary dependence between tests, given valid input p-values&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;How many discoveries can we tolerate in a broad screen?&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://doi.org/10.1111/j.2517-6161.1995.tb02031.x" rel="noopener noreferrer"&gt;Benjamini–Hochberg&lt;/a&gt; under its assumptions; Benjamini–Yekutieli under arbitrary dependence&lt;/td&gt;
&lt;td&gt;False discovery rate, not the chance the best rule is real&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Did the best rule from a time-series search beat a benchmark?&lt;/td&gt;
&lt;td&gt;Search-aware block bootstrap, Reality Check, or SPA&lt;/td&gt;
&lt;td&gt;A family-level comparison with the benchmark, accounting for time dependence under the method's assumptions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;FDR fits a screen that reports many discoveries. This exit-rule audit instead asks whether any candidate beats its chosen benchmark. Even rejection of the family null would establish evidence for at least one candidate, not the future profitability of a particular configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the result was not promoted
&lt;/h2&gt;

&lt;p&gt;The audit did not establish +25.98 bps as an edge ready for trading. Its positive mean depended on one session, the selected rule had no untouched final split, and the archived summaries could not support a test of the candidate family. The execution audit also identified optimistic fill assumptions, outside the statistical correction discussed here.&lt;/p&gt;

&lt;p&gt;Before considering promotion, I would require the versioned outcome record above, a defined benchmark and ranking criterion, and an evaluation period that had not informed development. The candidate would have to be fixed before opening that period, then checked with a capital-constrained execution model. No rerun or new holdout result is reported here.&lt;/p&gt;




&lt;p&gt;Part of the &lt;a href="https://www.pkazantsev.com/writing/hfm-research-origin/" rel="noopener noreferrer"&gt;HFM Research methodology series&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>quant</category>
      <category>statistics</category>
      <category>trading</category>
      <category>python</category>
    </item>
    <item>
      <title>I Went Looking for the Dead Internet in My RAG. I Found a Bad Experiment.</title>
      <dc:creator>Pavel Kazantsev 💎</dc:creator>
      <pubDate>Tue, 03 Nov 2026 08:36:33 +0000</pubDate>
      <link>https://dev.to/pavel_kkkkazantsev/i-went-looking-for-the-dead-internet-in-my-rag-i-found-a-bad-experiment-1cjh</link>
      <guid>https://dev.to/pavel_kkkkazantsev/i-went-looking-for-the-dead-internet-in-my-rag-i-found-a-bad-experiment-1cjh</guid>
      <description>&lt;p&gt;I removed duplicate sources from a RAG benchmark and watched held-out accuracy fall from 10 of 20 tasks to 5 of 20. The tempting conclusion was that source deduplication made retrieval worse.&lt;/p&gt;

&lt;p&gt;The audit found another change hiding in the comparison. Lexical top-k supplied roughly five documents; the collapse policy often supplied one or two. The run changed source diversity and the evidence budget together, so the accuracy drop could not identify a provenance effect.&lt;/p&gt;

&lt;p&gt;With a fixed-budget control, root-aware retrieval recovered the primary record and accuracy returned to 10 of 20. It did not improve further. That correction became the point of this investigation: retrieval correctness and answer correctness are different measurements, and an apparent result can disappear when the control is fair.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Removing duplicate sources appeared to halve accuracy, but the comparison also reduced the evidence budget.&lt;/li&gt;
&lt;li&gt;Under the corrected control, root-aware retrieval recovered primary records without improving answer accuracy.&lt;/li&gt;
&lt;li&gt;A 15-case real-world pilot validated the provenance pipeline, not retrieval effectiveness. V2 will test adversarial cases.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Part 1 corrects a misleading synthetic result and validates a provenance-capture and evaluation pipeline on real sources. Part 2 will test whether provenance-aware retrieval changes answers when the evidence actually conflicts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjqocb3fy1f9cuyrg7fjv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjqocb3fy1f9cuyrg7fjv.png" alt="Many browser pages trace back to one illuminated source record. Editorial illustration, not evidence." width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The part of the "dead internet" idea worth testing
&lt;/h2&gt;

&lt;p&gt;The phrase "dead internet" is associated with a 2021 forum post, &lt;em&gt;Dead Internet Theory: Most of the Internet Is Fake&lt;/em&gt;. &lt;a href="https://www.livescience.com/technology/artificial-intelligence/what-is-the-dead-internet-conspiracy" rel="noopener noreferrer"&gt;Contemporary reporting traces the popular term to that thread&lt;/a&gt;. Its broad version bundles together bots, manufactured engagement, algorithms, and a claim that real human activity has become marginal.&lt;/p&gt;

&lt;p&gt;That claim is too broad for this experiment. A traffic statistic cannot establish who wrote a page, whether a claim is true, or whether people have stopped participating online.&lt;/p&gt;

&lt;p&gt;For RAG, a systems problem remains. &lt;a href="https://www.imperva.com/resources/resource-library/reports/2025-bad-bot-report/" rel="noopener noreferrer"&gt;Imperva's 2025 report&lt;/a&gt; estimated that automation represented 51% of the web traffic it observed in 2024. The category includes useful crawlers and malicious bots, so it cannot count a "fake internet."&lt;/p&gt;

&lt;p&gt;For retrieval, a smaller question is enough: how many independent source roots support the evidence in context?&lt;/p&gt;

&lt;p&gt;Repeated documents can reach an index through a documented syndication chain, a press release, a scrape, a summary, or a generated rewrite. The causes differ. The failure is the same when repetition reaches the model as apparent corroboration.&lt;/p&gt;

&lt;p&gt;The wider theory also tends to mix four questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Did a human or an automated client make the request?&lt;/li&gt;
&lt;li&gt;Was the page written by a person, copied, or generated?&lt;/li&gt;
&lt;li&gt;Where did the claim originate?&lt;/li&gt;
&lt;li&gt;Does the claim have enough support to warrant an answer?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They require different evidence. This experiment addresses the third question, provenance. It does not diagnose the web as a whole.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I mean by a source root
&lt;/h2&gt;

&lt;p&gt;A source root is an information lineage, not a hostname. One root can include a public primary record and several documented syndications. One publisher can contain several independent roots.&lt;/p&gt;

&lt;p&gt;I assign a root only when the relationship has evidence: a canonical link, a syndication notice, an explicit citation, or a documented editorial relationship. Near-identical phrasing is useful for discovery, but it does not prove copying. Treating a similarity score as provenance would create a confident-looking field from an unverified assumption.&lt;/p&gt;

&lt;h2&gt;
  
  
  The system
&lt;/h2&gt;

&lt;p&gt;The implementation keeps evidence capture, retrieval, generation, and scoring separate. Otherwise one &lt;code&gt;provenance_aware&lt;/code&gt; switch can quietly change the candidate pool, context length, answer rule, and source metadata at once.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdwqbmufyukftjaiudjc7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdwqbmufyukftjaiudjc7.png" alt="Evidence capture, fixed-budget retrieval, generation, and evaluation are separate stages in the pipeline." width="800" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Evidence capture saves the public and canonical URLs, timestamp, HTTP status, extracted text, hash, and documented relation. Retrieval selects documents under a defined budget. Generation receives document text, IDs, roots, and roles, but never an expected stance or fixture label. Evaluation checks the returned stance, citation IDs, and retrieval trace.&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;candidates&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lexical_retrieve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pool&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;root_aware_fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;candidates&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fixed_prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;audit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expected_stance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;pool=50&lt;/code&gt; is important. Collapsing sources only after a top-five cutoff cannot recover a primary record that was ranked sixth. Candidate grouping has to happen before the context budget is spent.&lt;/p&gt;

&lt;h2&gt;
  
  
  The result that fooled me
&lt;/h2&gt;

&lt;p&gt;I built a 60-task synthetic fixture with known source roots. The first comparison looked clean: lexical top-k got 10 of 20 held-out tasks right; a root-collapse policy got 5 of 20.&lt;/p&gt;

&lt;p&gt;The comparison was not clean. Root collapse sometimes returned one or two documents where lexical top-k returned five. Both variables changed, so the first run cannot attribute its regression to source grouping alone.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Held-out synthetic control, k = 5&lt;/th&gt;
&lt;th&gt;Correct&lt;/th&gt;
&lt;th&gt;Mean documents&lt;/th&gt;
&lt;th&gt;Primary-record recall&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Lexical top-k&lt;/td&gt;
&lt;td&gt;10 / 20&lt;/td&gt;
&lt;td&gt;4.25&lt;/td&gt;
&lt;td&gt;20%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Post-top-k collapse&lt;/td&gt;
&lt;td&gt;5 / 20&lt;/td&gt;
&lt;td&gt;1.15&lt;/td&gt;
&lt;td&gt;20%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Root-aware fill&lt;/td&gt;
&lt;td&gt;10 / 20&lt;/td&gt;
&lt;td&gt;4.25&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Conflict-preserving fill&lt;/td&gt;
&lt;td&gt;10 / 20&lt;/td&gt;
&lt;td&gt;4.25&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fogsfatw0swe62mpj34t4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fogsfatw0swe62mpj34t4.png" alt="A three-column comparison: lexical top-k and root-aware fill preserve five document slots, while post-top-k collapse leaves a mean of 1.15 documents. The latter changes source diversity and evidence budget at once." width="800" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The original collapse policy spent fewer evidence slots. Root-aware fill chooses roots from a larger pool, then restores the intended document budget.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;With the budget fixed, root-aware fill recovered the primary record and retained the deterministic accuracy of lexical top-k. It did not improve accuracy. The remaining slots still let the answer rule count repeated stances.&lt;/p&gt;

&lt;p&gt;The original drop measured a policy that also shrank the prompt. It did not isolate the effect of source grouping.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why keep the synthetic fixture?
&lt;/h2&gt;

&lt;p&gt;The fixture isolates a retrieval mechanism that is hard to control on public pages. It contains 60 tasks across duplicate dilution, true repetition, conflicting roots, and satire stripped of its context. Each category has ten development tasks and five held-out tasks.&lt;/p&gt;

&lt;p&gt;The publishers and documents are fictional because the fixture needs declared roots and known answers without claiming to measure the open web. The first experiment uses a deterministic stance aggregator, making the intervention inspectable. It also exposes a limitation: recovering a primary record does not automatically improve the final answer if the aggregator still counts every retained document equally.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftwrwxfo8qdxfeoppcavl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftwrwxfo8qdxfeoppcavl.png" alt="Held-out false-dilution fixture trace: lexical top-five returns five mirror documents from one root and misses the primary specification; root-aware fill includes the primary while retaining five document slots." width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A concrete held-out fixture trace. It demonstrates a retrieval change, not a real-world effectiveness result.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Fixtures cannot show whether the pipeline works on public pages, so I collected a separate real-data pilot.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 15-case real pilot
&lt;/h2&gt;

&lt;p&gt;The pilot contains 15 NASA-to-Phys.org syndication chains. Every accepted case has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a public NASA record;&lt;/li&gt;
&lt;li&gt;a Phys.org page whose snapshot explicitly says &lt;code&gt;Provided by NASA&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;timestamped HTML, extracted text, a canonical URL, HTTP status, and a SHA-256 content hash;&lt;/li&gt;
&lt;li&gt;a graph edge supported by the documented syndication marker.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Similar language never counted as proof of dependence. If the source relationship was undocumented, the case did not enter the slice.&lt;/p&gt;

&lt;p&gt;Gemma 3 4B and Qwen 2.5 7B independently labelled document roles. They disagreed enough that I did not use their votes as ground truth. Final roles came from the explicit record type and syndication marker; model annotations remain in the corpus as machine annotations. This is a machine-adjudicated pilot, not a human-verified dataset.&lt;/p&gt;

&lt;p&gt;I ran both models on the same 15 questions under four conditions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;primary-only;&lt;/li&gt;
&lt;li&gt;primary plus the documented dependent copy;&lt;/li&gt;
&lt;li&gt;root-aware;&lt;/li&gt;
&lt;li&gt;conflict-preserving root-aware.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The prompt, seed, decoding settings, evidence ordering, retrieval trace, and raw responses were saved for every run. Neither model received the expected answer or a stance label in its prompt.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What V1 actually found&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;15 source chains · 2 local models · 120 retained responses&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Gemma 3 4B and Qwen 2.5 7B each returned the correct stance for all 15 cases in every condition. Citation-ID validity changed when the dependent copy was present. The slice has one root and positive support in every case, so it validates provenance capture and evaluation plumbing. It does not test whether root-aware retrieval prevents a real answer error.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Both models answered all 15 questions correctly in every condition.&lt;/p&gt;

&lt;p&gt;Every accepted chain has one source root and supports one positive claim, so root-aware retrieval reduces to primary-only. The slice has no false assertion or contradictory root to resolve.&lt;/p&gt;

&lt;p&gt;The citation trace moved:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Primary-only valid citation IDs&lt;/th&gt;
&lt;th&gt;With dependent copy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Gemma 3 4B&lt;/td&gt;
&lt;td&gt;3 / 15&lt;/td&gt;
&lt;td&gt;6 / 15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Qwen 2.5 7B&lt;/td&gt;
&lt;td&gt;12 / 15&lt;/td&gt;
&lt;td&gt;10 / 15&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

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

&lt;p&gt;Those are exploratory counts, not a model ranking. Citation-ID validity only says whether the returned ID was present in supplied context. It does not establish that the cited document supports the answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  The V1 confound, stated plainly
&lt;/h2&gt;

&lt;p&gt;There is a second limit on the V1 comparison. Adding the dependent page changes the context from one document to two, and Ollama's recorded prompt-token count changes in every model-case pair.&lt;/p&gt;

&lt;p&gt;The citation results are descriptive because the comparison cannot isolate source dependence from the extra context. V2 will block an evaluation unless each paired case has equal document and prompt-token budgets.&lt;/p&gt;

&lt;p&gt;The real corpus also has a ceiling effect. Primary-reference recall is 100% by construction in the one-root conditions, and root concentration is 1.0 because every selected context belongs to one lineage. These measurements confirm that the policy did what it was asked to do. They also explain why the pilot cannot support an accuracy claim.&lt;/p&gt;

&lt;h2&gt;
  
  
  Metrics worth keeping separate
&lt;/h2&gt;

&lt;p&gt;Correctness is useful, but it can hide the failure that changed. A model may preserve a correct stance while losing the primary record, naming a citation ID that was never in context, or becoming impossible to audit after a page changes.&lt;/p&gt;

&lt;p&gt;I would report at least these outcomes for a larger corpus:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;answer stance;&lt;/li&gt;
&lt;li&gt;primary-reference recall;&lt;/li&gt;
&lt;li&gt;root concentration;&lt;/li&gt;
&lt;li&gt;citation validity;&lt;/li&gt;
&lt;li&gt;contradiction coverage;&lt;/li&gt;
&lt;li&gt;false-claim adoption.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A single combined score would hide which part failed. The unit for a future comparison is the source case, not the generated response. Paired accuracy deltas, bootstrap intervals, and an exact sign test make sense only after enough independent held-out cases survive the admission gate.&lt;/p&gt;

&lt;p&gt;For production, I would retain this trace beside every retrieved chunk:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;document_id · canonical_url · publisher · publication_date
retrieved_at · content_hash · source_root · source_role
claim_relation · dependency_evidence
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Candidate selection, source weighting, and conflict handling should stay separate. A source root can come from a documented origin or explicit citation evidence. It cannot come from cosine similarity alone.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a reader can verify today
&lt;/h2&gt;

&lt;p&gt;The public release supports artifact verification, not a byte-for-byte end-to-end rerun. It contains public URLs, hashes, annotations, the run manifest, the paired-budget audit, and 120 raw model responses. It deliberately excludes third-party HTML and extracted page text.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/icesurf666/rag-provenance-lab.git
&lt;span class="nb"&gt;cd &lt;/span&gt;rag-provenance-lab
python3 &lt;span class="nt"&gt;-m&lt;/span&gt; venv .venv &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt; .venv/bin/activate
pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s1"&gt;'.[test]'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nv"&gt;PYTHONPATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;src pytest &lt;span class="nt"&gt;-q&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;a href="https://github.com/icesurf666/rag-provenance-lab/blob/main/REPRODUCIBILITY.md" rel="noopener noreferrer"&gt;reproducibility guide&lt;/a&gt; explains that boundary. The &lt;a href="https://github.com/icesurf666/rag-provenance-lab/blob/main/reports/V1_PAIRED_BUDGET_AUDIT.json" rel="noopener noreferrer"&gt;paired-budget audit&lt;/a&gt; records all 30 unequal model-case pairs; the &lt;a href="https://github.com/icesurf666/rag-provenance-lab/blob/main/data/public/v1/v1_raw_model_responses.jsonl" rel="noopener noreferrer"&gt;raw responses&lt;/a&gt;, &lt;a href="https://github.com/icesurf666/rag-provenance-lab/blob/main/data/public/v1/v1_run_manifest.json" rel="noopener noreferrer"&gt;run manifest&lt;/a&gt;, and &lt;a href="https://github.com/icesurf666/rag-provenance-lab/blob/main/reports/REAL_PILOT_RESULTS.md" rel="noopener noreferrer"&gt;recorded results&lt;/a&gt; are public.&lt;/p&gt;

&lt;h2&gt;
  
  
  A real retrieval failure outside this pilot
&lt;/h2&gt;

&lt;p&gt;In May 2024, Google AI Overviews advised users to add glue to pizza sauce. &lt;a href="https://apnews.com/article/33060569d6cc01abe6c63d21665330d8" rel="noopener noreferrer"&gt;Associated Press reported&lt;/a&gt; that the answer traced back to a satirical Reddit comment, and &lt;a href="https://blog.google/products-and-platforms/products/search/ai-overviews-update-may-2024/" rel="noopener noreferrer"&gt;Google later published its response&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The incident shows a retrieval failure: the words reached the system while the sentence that explained their status did not. It cannot estimate a dead web or the prevalence of AI-generated content.&lt;/p&gt;

&lt;h2&gt;
  
  
  What comes next: V2 — when provenance changes the answer
&lt;/h2&gt;

&lt;p&gt;V1 is complete as a pipeline validation. V2 will test the effectiveness question it leaves open: can source provenance prevent a model from accepting a repeated false claim when a correct primary record is available?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjw53hwd56evy1qtcjj15.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjw53hwd56evy1qtcjj15.png" alt="V1 contains fifteen one-root NASA to Phys.org positive cases and validates capture, traces, and paired execution. V2 is planned to test corrections, stale copies, satire, conflicts, and independent corroboration under fixed budgets." width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;V1 and V2 answer different questions. This diagram describes a planned V2 protocol, not results.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The next corpus will include corrections alongside persistent stale copies, satire retold as fact, contradictory evidence, genuinely independent corroboration, and conflicts within one source lineage. The target is 40 to 60 quality-gated real cases with documented provenance, snapshots, hashes, independent machine annotations, and adjudication.&lt;/p&gt;

&lt;p&gt;Every case that passes the gate will stay in the evaluation set. V2 will include cases where both policies are correct, both are wrong, lexical retrieval wins, and root-aware retrieval wins. Selecting only later success stories would turn the corpus into a demonstration instead of an experiment.&lt;/p&gt;

&lt;p&gt;Gemma and Qwen will run pre-specified paired conditions with equal document and prompt-token budgets. Document-order permutations will be assigned before outcomes are inspected. The result may show an improvement, a regression, or no material effect.&lt;/p&gt;

&lt;p&gt;Until V2 exists, a claim that root-aware retrieval improves real-world answer accuracy would be premature.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/icesurf666/rag-provenance-lab" rel="noopener noreferrer"&gt;RAG Provenance Lab repository&lt;/a&gt; contains the public V1 code, artifact-verification materials, model outputs, run manifests, and the protocol. It distinguishes artifact verification from end-to-end reproduction: third-party page snapshots and extracted text are not distributed in the public release.&lt;/p&gt;

</description>
      <category>rag</category>
      <category>ai</category>
      <category>machinelearning</category>
      <category>python</category>
    </item>
    <item>
      <title>I Tested 7 Crypto Models. The Best Signal Failed the Cost Test.</title>
      <dc:creator>Pavel Kazantsev 💎</dc:creator>
      <pubDate>Fri, 30 Oct 2026 09:17:47 +0000</pubDate>
      <link>https://dev.to/pavel_kkkkazantsev/i-tested-7-crypto-models-the-best-signal-failed-the-cost-test-2maa</link>
      <guid>https://dev.to/pavel_kkkkazantsev/i-tested-7-crypto-models-the-best-signal-failed-the-cost-test-2maa</guid>
      <description>&lt;p&gt;Huber regression had the strongest predictive ranking in my crypto model comparison: mean out-of-sample Spearman IC &lt;strong&gt;+0.055&lt;/strong&gt;. Its selected trades nevertheless averaged &lt;strong&gt;−7.74 basis points after modeled costs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The tree model with the least negative result was an XGBoost configuration at −1.73 bps. Its uncertainty interval crossed zero. LightGBM was close behind at −1.93 bps. Neither result establishes a profitable strategy.&lt;/p&gt;

&lt;p&gt;Those numbers came only after an uncomfortable discovery: the first version of the backtest had a boundary leak and treated gaps in price history as consecutive bars. We fixed both and reran the comparison.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Research status:&lt;/strong&gt; this is exploratory, retrospective research on history already examined in earlier work. Prices are OHLC proxies, costs are assumed, the universe was selected retrospectively, and there is no executable portfolio P&amp;amp;L. It is not an independent holdout or a live-trading result.&lt;/p&gt;

&lt;h2&gt;
  
  
  Signal is not a strategy
&lt;/h2&gt;

&lt;p&gt;The question began with three features: 1-, 5-, and 20-bar log returns on 15-minute Bybit perpetual candles. Could a model use them to rank the next return? Could a trading rule survive costs?&lt;/p&gt;

&lt;p&gt;An information coefficient, or IC, describes rank correlation between a score and the future return. To assess a trading rule, we also need to know how often it trades, what each trade earns and what execution costs.&lt;/p&gt;

&lt;p&gt;Here IC is one Spearman correlation pooled across available symbol-bar observations per fold, then averaged equally across folds. It is not a daily cross-sectional IC; pooled correlations can reflect differences between symbols as well as within-symbol ranking. We did not estimate an IC confidence interval in this run.&lt;/p&gt;

&lt;p&gt;Why can the rankings differ? IC uses all scored observations to ask about ordering. The trading result uses only observations beyond a model-specific threshold, assigns a direction and subtracts costs. A model can rank the whole panel well yet select a less rewarding set of extreme scores. The two statistics also weight observations differently, so this experiment does not isolate a single cause of the gap.&lt;/p&gt;

&lt;p&gt;An earlier OLS study reported 4,218 trades and +5.45 bps mean net using a fixed 12 bps round-trip assumption and a fixed ±12 bps signal threshold. Its bootstrap implementation also had a bug: repeated sampled days were discarded. The reported interval could not be relied on. A positive number did not answer whether another model, evaluated under the same rules, would do better.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seven candidates, one historical protocol
&lt;/h2&gt;

&lt;p&gt;The original comparison used reversal, OLS, Ridge, Huber and constrained LightGBM. I later added XGBoost and CatBoost as a &lt;strong&gt;post-hoc&lt;/strong&gt; extension. The seven configurations share the same time splits, universe, features available to learned models, signal-selection rule and modeled costs. The reversal baseline uses only the one-bar feature.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Data:&lt;/strong&gt; 16 Bybit USDT perpetuals; 15-minute bars; symbols enter as data becomes available. Selecting this universe retrospectively creates survivorship risk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evaluation:&lt;/strong&gt; six expanding walk-forward folds, 2022 H1 through 2024 H2; training starts in 2021.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Target:&lt;/strong&gt; next-bar close-to-close return in bps. The model and scaler are fitted on training data only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Signal:&lt;/strong&gt; a long or short when the score exceeds the 99th percentile of its own training score magnitude in either direction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Economics:&lt;/strong&gt; next-bar open-to-close return, less modeled round-trip costs of 13, 15 or 19 bps by liquidity tier.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The cost assumption is 5.5 bps taker fee per side plus 1, 2 or 4 bps assumed slippage per side. These are inputs to the historical proxy, not measured historical fees or fills.&lt;/p&gt;

&lt;p&gt;The threshold helps make differently scaled scores comparable, but it does not force models to trade equally often in the evaluation period. Models may select different symbols and dates, so their mean per-trade returns are not returns on an equally allocated portfolio.&lt;/p&gt;

&lt;p&gt;The tree configurations are fixed and untuned here; they use different algorithms and regularization. This is a comparison of seven configurations, not a universal ranking of model families.&lt;/p&gt;

&lt;p&gt;The later boosters each use 200 trees, depth 4 and learning rate 0.03. XGBoost uses &lt;code&gt;min_child_weight=2000&lt;/code&gt;, L1=1 and L2=10; CatBoost uses L2=10. Ridge uses a strong fixed &lt;code&gt;alpha=1,000,000&lt;/code&gt; on standardized features, so its effective regularization changes relative to the growing training sample. A different tuning budget could change the ranking.&lt;/p&gt;

&lt;h2&gt;
  
  
  Five equations and one timing problem
&lt;/h2&gt;

&lt;p&gt;For bar close &lt;code&gt;C[t]&lt;/code&gt; and open &lt;code&gt;O[t]&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;features:    x[t, k] = log(C[t] / C[t-k]), k ∈ {1, 5, 20}
train label: y[t]    = 10,000 × (C[t+1] / C[t] − 1)
threshold:   q       = 99th percentile of |training score|
signal:      s[t]    = +1 if score &amp;gt; q; −1 if score &amp;lt; −q; else 0
trade net:   p[t]    = s[t] × 10,000 × (C[t+1] / O[t+1] − 1) − cost
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last equation applies to selected trades only. A basis point is 0.01% of position notional.&lt;/p&gt;

&lt;p&gt;The model learns close-to-close returns, while the economic proxy measures the next candle's open-to-close move. The next open can occur before a system reacts to a confirmed close, so the OHLC price does not establish that a trade could have filled there.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fp938wbvcoil2ouftzzwt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fp938wbvcoil2ouftzzwt.png" alt="Illustrative timeline showing the candle boundary, confirmation, model decision and proxy exit" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The timing diagram is illustrative, not a measured latency distribution. A later bid/ask observation does not establish that an order filled.&lt;/p&gt;

&lt;h2&gt;
  
  
  The corrected results
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Mean fold IC&lt;/th&gt;
&lt;th&gt;Trade-weighted net / trade&lt;/th&gt;
&lt;th&gt;95% block interval, bps&lt;/th&gt;
&lt;th&gt;Trades&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;XGBoost*&lt;/td&gt;
&lt;td&gt;+0.012&lt;/td&gt;
&lt;td&gt;−1.73 bps&lt;/td&gt;
&lt;td&gt;[−7.41, +3.63]&lt;/td&gt;
&lt;td&gt;10,885&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LightGBM&lt;/td&gt;
&lt;td&gt;+0.012&lt;/td&gt;
&lt;td&gt;−1.93 bps&lt;/td&gt;
&lt;td&gt;[−7.64, +3.65]&lt;/td&gt;
&lt;td&gt;11,006&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CatBoost*&lt;/td&gt;
&lt;td&gt;+0.011&lt;/td&gt;
&lt;td&gt;−5.73 bps&lt;/td&gt;
&lt;td&gt;[−11.54, +0.83]&lt;/td&gt;
&lt;td&gt;11,341&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ridge&lt;/td&gt;
&lt;td&gt;+0.044&lt;/td&gt;
&lt;td&gt;−7.14 bps&lt;/td&gt;
&lt;td&gt;[−14.34, −0.76]&lt;/td&gt;
&lt;td&gt;12,685&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Huber&lt;/td&gt;
&lt;td&gt;+0.055&lt;/td&gt;
&lt;td&gt;−7.74 bps&lt;/td&gt;
&lt;td&gt;[−15.34, −0.88]&lt;/td&gt;
&lt;td&gt;12,487&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OLS&lt;/td&gt;
&lt;td&gt;+0.036&lt;/td&gt;
&lt;td&gt;−9.82 bps&lt;/td&gt;
&lt;td&gt;[−16.00, −4.42]&lt;/td&gt;
&lt;td&gt;12,461&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;One-bar reversal&lt;/td&gt;
&lt;td&gt;+0.040&lt;/td&gt;
&lt;td&gt;−12.55 bps&lt;/td&gt;
&lt;td&gt;[−18.39, −6.48]&lt;/td&gt;
&lt;td&gt;11,497&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;XGBoost and CatBoost were added after the first run. “Out-of-sample” means out of each fold's fitting window, not a clean final holdout. IC values are descriptive means, not claims of statistical significance.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fus12mp69cc6w9i8lvyg4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fus12mp69cc6w9i8lvyg4.png" alt="Mean IC versus modeled net per trade for the seven candidates" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Net is weighted by the number of trades. Averaging the six fold-level means instead gives LightGBM −3.09 bps: another valid summary, but a different weighting. Neither measure is portfolio return.&lt;/p&gt;

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

&lt;p&gt;Intervals use 2,000 resamples of 10-calendar-day blocks. All trades within a sampled day stay together; the same days are sampled for each model. Fitted models and selected trades stay fixed during resampling; the models are not refitted. The intervals do not account for model selection or multiple comparisons. The XGBoost and LightGBM intervals crossing zero neither prove profit nor rule it out. The 0.20 bps difference between their point estimates is not a basis for declaring a winner.&lt;/p&gt;

&lt;h2&gt;
  
  
  Look inside the average
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F40gho29r59c7qekzpgmd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F40gho29r59c7qekzpgmd.png" alt="Mean net bps per trade in each of six half-year folds" width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;LightGBM's fold means range from −12.49 to +4.29 bps. Its three positive half-years are small beside its two largest negative ones. All seven configurations lose in 2022 H2 under these assumptions. This is regime sensitivity, not a clean prediction of what happens next.&lt;/p&gt;

&lt;p&gt;The day-block bootstrap gives an exploratory LightGBM-minus-OLS interval of [+3.71, +12.90] bps per trade. The models select different trades, the research is post-selection, and this interval is not adjusted for testing multiple candidates. It is not proof that LightGBM generally beats OLS.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens when positions share capital?
&lt;/h2&gt;

&lt;p&gt;The table weights each trade equally. A model that selects many simultaneous markets may look different when those positions have to share capital. In a separate post-hoc portfolio proxy, we divide 1× gross notional equally among selected symbols on each active bar. The proxy enters at the next open, exits at the following close and pays the same modeled round-trip costs. It holds cash when there is no valid selected signal.&lt;/p&gt;

&lt;p&gt;With the original in-sample threshold, the mean daily additive proxy is −53.68 bps for LightGBM and −54.62 bps for XGBoost. LightGBM has the less negative number under this aggregation, reversing their per-trade ordering. The paired 10-day block-bootstrap interval for XGBoost minus LightGBM is [−14.95, +11.59] bps per day: it includes zero.&lt;/p&gt;

&lt;h2&gt;
  
  
  Does the threshold matter?
&lt;/h2&gt;

&lt;p&gt;The original 99th percentile comes from predictions on the same observations used to fit each model. For a sensitivity check, we fit another model on the first 80% of each outer training window, purge labels crossing the boundary, and calculate the percentile on the remaining 20%. We then refit on the full outer training window before evaluating the next fold. Refitting can change score scale; this is one post-hoc chronological split, not a tuned or independently validated rule.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fth2snj6px3h75rnvzm4a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fth2snj6px3h75rnvzm4a.png" alt="Mean daily additive portfolio proxy under two threshold methods for seven models" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the training-holdout threshold, the mean daily additive proxy changes to −80.98 bps for LightGBM and −79.67 bps for XGBoost. Their ordering switches again. The paired interval for XGBoost minus LightGBM is [−12.15, +13.46] bps per day, again including zero. Both intervals use 2,000 resamples and common 10-day blocks. Models are not refitted, the historical period was already examined, and the intervals are not adjusted for multiple comparisons.&lt;/p&gt;

&lt;p&gt;These numbers sum bar-level bps by next-bar entry day and divide by all calendar days, including days in cash. Notional resets to 1× whenever a signal is active; returns are not compounded. The proxy omits funding, impact, order-book depth, margin, liquidation and changing equity. Missing or invalid symbol-bars are treated as unavailable signals, and equal gross notional is not equal risk. This is not an executable portfolio backtest.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cost cliff
&lt;/h2&gt;

&lt;p&gt;For the original five candidates, I held signals fixed and scaled the assumed fee plus slippage:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0kcuz6kohc6eenvr6lmj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0kcuz6kohc6eenvr6lmj.png" alt="Sensitivity to assumed transaction costs for the original five candidates" width="800" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;LightGBM's selected trades averaged &lt;strong&gt;+16.15 bps gross proxy&lt;/strong&gt; and &lt;strong&gt;18.08 bps modeled cost&lt;/strong&gt;. At half the assumed cost, net is +7.11 bps; at baseline, −1.93; at twice the cost, −20.01. The break-even multiplier is about &lt;code&gt;16.15 / 18.08 = 0.89&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That number is an arithmetic result for this historical trade set; it does not establish an obtainable fee quote. The sensitivity scales both fees and slippage, keeps the trades fixed, and does not model queueing, market impact or latency. XGBoost and CatBoost are not included in this cost chart.&lt;/p&gt;

&lt;p&gt;To put the units in context: on a hypothetical $10,000 position, one basis point is $1. The LightGBM averages correspond to roughly $16.15 gross proxy, $18.08 assumed costs and −$1.93 net per selected trade. These are scaled averages, not cash flows from a funded account; actual position sizes, simultaneous trades and fills are not modeled in that calculation.&lt;/p&gt;

&lt;p&gt;With 5- and 20-day bootstrap blocks, LightGBM's intervals still cross zero: approximately [−7.86, +3.83] and [−7.88, +3.80] bps. Other dependence assumptions could produce different intervals.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two bugs that changed the experiment
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The train/test boundary.&lt;/strong&gt; The first script selected training rows by timestamp but constructed their targets using the next row. A final training row could therefore use a price from the evaluation period. The corrected split requires each training label to finish by the evaluation boundary. A regression test changes future prices and verifies that training data does not change.&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;# Bar timestamps denote bar opens; label_end is the next bar's close.
&lt;/span&gt;&lt;span class="n"&gt;train&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;panel&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;panel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ts&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;train_start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;panel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;label_end&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;eval_start&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="n"&gt;eval_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;panel&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;panel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ts&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;eval_start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;panel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;label_end&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;eval_end&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compare the end of the label with the evaluation boundary, not just the timestamp on the feature row. This rule matches this next-bar target; longer holding periods or overlapping labels need their own purge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Missing bars.&lt;/strong&gt; A row shift is not necessarily a 15-minute shift. The corrected run requires 20 consecutive historical intervals and one consecutive future interval. Across loaded history it detected 1,631 gaps and excluded 34,587 rows, including warm-up and incomplete outcomes. The downloadable result lists exclusions and full-file hashes by symbol.&lt;/p&gt;

&lt;p&gt;The old +5.45 bps OLS estimate and this rerun changed both the threshold and cost convention. We cannot attribute their difference to costs alone. We can say that the earlier positive result did not carry over to the new decision and cost contract.&lt;/p&gt;

&lt;h2&gt;
  
  
  What would change my mind?
&lt;/h2&gt;

&lt;p&gt;An executable-price simulation with point-in-time universe rules, realistic order sizing and a portfolio risk model could change this assessment. So could a genuinely new period.&lt;/p&gt;

&lt;p&gt;If you are building a similar comparison, keep three questions separate:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Can the score rank returns?&lt;/strong&gt; Compare models on the same untouched time windows, and state whether the IC is pooled or cross-sectional.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Does the decision rule survive costs?&lt;/strong&gt; Freeze the threshold, timing, sizing and fee assumptions; report gross and net results together.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Would the portfolio have been executable?&lt;/strong&gt; Check simultaneous exposure, missing data, available liquidity and actual decision-to-order timing. An OHLC open is not a fill.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This experiment answers the first two only under its stated historical assumptions. It does not establish the third.&lt;/p&gt;

&lt;p&gt;We have frozen seven fitted candidates for a prospective shadow period from 1 November 2026 to 1 February 2027 UTC, with LightGBM versus OLS as the primary comparison. As of 30 October 2026, that period had not started. It uses the same exchange and local infrastructure, so it is independent &lt;strong&gt;in time&lt;/strong&gt;, not an external audit. A separate observer will record post-decision bid/ask references with at least 500 ms delay and mark missed windows; the quotes are not guaranteed fills.&lt;/p&gt;

&lt;p&gt;Before the prospective test, we checked public Bybit top-of-book snapshots during a short window on 29 October 2026, 14:30–18:00 UTC. The collector recorded 224 confirmed symbol-bars across 16 markets; 222 had a retained bid/ask snapshot. Median quoted spread across the snapshots was 1.06 bps. On our host clock, the median confirmed-candle receipt was 724 ms after the scheduled boundary. This is a small pre-forward diagnostic: quotes can precede a decision, local clock error affects the delay, and no order was sent. It does not measure actual execution. &lt;a href="https://www.pkazantsev.com/writing/lgbm-vs-linear-crypto/pre-forward-quote-diagnostic.json" rel="noopener noreferrer"&gt;Diagnostic summary&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Separately, between 18:57 and 18:59 UTC on 29 October, we submitted five 0.001 BTCUSDT market-order round trips to Bybit's &lt;strong&gt;demo&lt;/strong&gt; environment. In the first, simulated fills were 80,851.8 USDT on entry and 80,845.9 on exit; fees totalled 0.08893374 USDT. All five closed with a loss of between 0.08730960 and 0.10012708 USDT including fees and the price move while holding each position. The &lt;a href="https://www.pkazantsev.com/writing/lgbm-vs-linear-crypto/demo-execution-series.json" rel="noopener noreferrer"&gt;anonymized records&lt;/a&gt; include pre-entry quotes and execution timestamps. This short, one-symbol demo sample contains no model signals: it is not a representative cost estimate, evidence of live fills, or validation of the historical backtest.&lt;/p&gt;

&lt;p&gt;A separate demo-only pilot is configured to attempt at most one 0.001 BTCUSDT round trip per primary model on eligible forward signals, sequentially on a shared account. It can stop for manual review, and connectivity failures can leave a demo position open. Signals can be missed, and the two trades are neither paired nor a statistically useful comparison. Demo fills are simulated; they cannot establish live execution. The pilot does not change the primary shadow protocol.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.pkazantsev.com/writing/lgbm-vs-linear-crypto/historical-corrected-bundle.zip" rel="noopener noreferrer"&gt;Download the research code and results&lt;/a&gt; · &lt;a href="https://www.pkazantsev.com/writing/lgbm-vs-linear-crypto/reproduce.txt" rel="noopener noreferrer"&gt;Reproduction instructions&lt;/a&gt;. We reran all seven models from the extracted bundle using the original files and reproduced the reported aggregates. The bundle includes a public-API downloader and a semantic fingerprint of the original candle slice, including missing timestamps. We separately verified all 140,255 BTC rows and 1 January 2024 for all 16 markets (96 bars each); the other 15 markets have not yet been independently downloaded in full. The downloader stops if the data available from Bybit do not match.&lt;/p&gt;

&lt;p&gt;References: &lt;a href="https://proceedings.neurips.cc/paper_files/paper/2017/hash/6449f44a102fde848669bdd9eb6b76fa-Abstract.html" rel="noopener noreferrer"&gt;LightGBM paper&lt;/a&gt;, &lt;a href="https://arxiv.org/abs/1603.02754" rel="noopener noreferrer"&gt;XGBoost paper&lt;/a&gt;, &lt;a href="https://proceedings.neurips.cc/paper_files/paper/2018/hash/14491b756b3a51daac41c24863285549-Abstract.html" rel="noopener noreferrer"&gt;CatBoost paper&lt;/a&gt;, and &lt;a href="https://scikit-learn.org/stable/auto_examples/applications/plot_cyclical_feature_engineering.html" rel="noopener noreferrer"&gt;scikit-learn's time-aware cross-validation example&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>python</category>
      <category>crypto</category>
      <category>datascience</category>
    </item>
    <item>
      <title>My test suite had 216 passing tests. It was lying to me.</title>
      <dc:creator>Pavel Kazantsev 💎</dc:creator>
      <pubDate>Mon, 26 Oct 2026 14:58:44 +0000</pubDate>
      <link>https://dev.to/pavel_kkkkazantsev/216-tests-passed-my-python-validator-still-returned-a-false-pass-3j1a</link>
      <guid>https://dev.to/pavel_kkkkazantsev/216-tests-passed-my-python-validator-still-returned-a-false-pass-3j1a</guid>
      <description>&lt;p&gt;An audit found a nested JSON false PASS in a replay-versus-live trace comparator. The local fix is recursive and type-aware; CSV equality remains deliberately unverified without provenance.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;[1]&lt;/code&gt; and &lt;code&gt;[true]&lt;/code&gt; are different JSON values. My Python comparator said they were equal.&lt;/p&gt;

&lt;p&gt;It returned:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"state"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"PASS"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"deterministic_parity_verified"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"findings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That result came from a tool I built to compare a historical replay with a live-style decision pipeline. The point was to find the first recorded difference in features, model scores, decisions, configuration, or input evidence. A strict &lt;code&gt;PASS&lt;/code&gt; was supposed to be the strongest possible result.&lt;/p&gt;

&lt;p&gt;It was wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  The false PASS, reduced to five lines
&lt;/h2&gt;

&lt;p&gt;The audit input was deliberately boring:&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;baseline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;
&lt;span class="n"&gt;candidate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&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;Both values were valid JSON-like input. Both traces had matching metadata and input hashes. The public recorder wrote them, the parser read them, and the old CLI certified them.&lt;/p&gt;

&lt;p&gt;The underlying Python behavior is legal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="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="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;           &lt;span class="c1"&gt;# True
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;x&lt;/span&gt;&lt;span class="sh"&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="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;x&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="c1"&gt;# True
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My comparator was asking the wrong question. Scalars went through type-aware logic, but nested lists and dictionaries eventually reached ordinary Python equality. For application code, that can be convenient. For a parity checker, it erases a recorded type difference.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before / after: the same trace pair
&lt;/h2&gt;

&lt;p&gt;I reran the preserved pre-fix source snapshot against this trace shape. It returned a verified strict &lt;code&gt;PASS&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="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"state"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"PASS"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"deterministic_parity_verified"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"findings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The public synthetic fixture now runs through the current CLI. This is the actual output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ hfm-parity diff --baseline examples/nested_values/baseline.jsonl \
    --candidate examples/nested_values/candidate.jsonl \
    --output parity-demo.html --json-output parity-demo.json
FAIL: mode=strict; not-verified; aligned=1; findings=1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The JSON report identifies the leaf, its classification, and the recorded values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"state"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"FAIL"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"deterministic_parity_verified"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"first_divergence"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"event_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"evt-001"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"stage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"features"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"field"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"payload[0]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"classification"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"FEATURE_TYPE_MISMATCH"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"baseline"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"candidate"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fixture, source code, and regression tests are public in &lt;a href="https://github.com/icesurf666/hfm-parity-lab/tree/main/examples/nested_values" rel="noopener noreferrer"&gt;HFM Parity Lab&lt;/a&gt;. It is synthetic by design: it proves a regression boundary, not a historical market measurement.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz0g0xbsopy0ivqeykcf8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz0g0xbsopy0ivqeykcf8.png" alt="Before and after the nested type-mismatch fix" width="799" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The pre-fix &lt;code&gt;PASS&lt;/code&gt; was reproduced from the preserved source snapshot; the current &lt;code&gt;FAIL&lt;/code&gt; is generated by the public synthetic fixture. The fixture demonstrates a regression boundary, not a historical market measurement.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why 216 tests did not catch it
&lt;/h2&gt;

&lt;p&gt;The candidate had 216 Python tests when the second audit supplied the nested counterexample. The scalar integer defect was fixed. Clean wheel and source installs worked. The CLI, MCP demo, Ruff, mypy, and frontend build passed.&lt;/p&gt;

&lt;p&gt;The gap was structural: the tests covered scalar numeric semantics, but not the same semantics at every JSON leaf. More happy-path tests would not have made that contract explicit.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the tool is intended to compare
&lt;/h2&gt;

&lt;p&gt;Backtests and live pipelines often disagree for reasons that are annoyingly ordinary. A feature was defined differently. A model version changed. A timestamp uses a different clock. An event came from a different source. The final BUY/HOLD decision is usually too late in the chain to explain much.&lt;/p&gt;

&lt;p&gt;I built a trace comparator called HFM Parity Lab around a narrower question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Given two recorded executions, what is the first observable difference, and do we have enough evidence to say the executions are comparable?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Each JSONL trace records run metadata plus event-level fields: an event ID, stage, features, timestamps, input hash, model score, decision, and optional state hash. The engine aligns &lt;code&gt;event.id + stage&lt;/code&gt;, then returns &lt;code&gt;PASS&lt;/code&gt;, &lt;code&gt;FAIL&lt;/code&gt;, &lt;code&gt;NOT_COMPARABLE&lt;/code&gt;, or &lt;code&gt;UNVERIFIABLE&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Strict mode is for two runs that claim to reproduce the same thing. Regression mode is for deliberate old-versus-new comparisons. Regression mode can report agreement, but it never certifies strict parity.&lt;/p&gt;

&lt;h2&gt;
  
  
  The first audit found other failures too
&lt;/h2&gt;

&lt;p&gt;The first independent audit began with 87 passing tests and found nine problems. These three are the easiest to reproduce.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Large integers were converted to floats
&lt;/h3&gt;

&lt;p&gt;The first comparison helper turned numbers into &lt;code&gt;float&lt;/code&gt; values before comparison.&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="mi"&gt;9007199254740993&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;9007199254740992&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Past &lt;code&gt;2**53&lt;/code&gt;, IEEE-754 doubles cannot represent every integer. The initial engine could call those values equal and return a verified strict &lt;code&gt;PASS&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The fix compares integers exactly. An integer and a float are a type mismatch even when their values look equal; tolerance applies only when both values are floats. The repaired scalar tests cover values far beyond the floating-point range.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Matching event IDs could hide a different market
&lt;/h3&gt;

&lt;p&gt;Two traces might both include &lt;code&gt;evt-17&lt;/code&gt;, while one came from BTC and the other from ETH. The initial strict comparison did not treat &lt;code&gt;symbol&lt;/code&gt;, &lt;code&gt;venue&lt;/code&gt;, or &lt;code&gt;data_source&lt;/code&gt; as part of the identity contract.&lt;/p&gt;

&lt;p&gt;That makes event alignment look more meaningful than it is.&lt;/p&gt;

&lt;p&gt;Strict mode now returns &lt;code&gt;NOT_COMPARABLE&lt;/code&gt; for declared identity mismatches. It also needs a data source, input hashes on aligned events, an actual output to compare, and a model version when model scores exist. Missing evidence returns &lt;code&gt;UNVERIFIABLE&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There is a practical difference between "I did not see a mismatch" and "the traces contain enough evidence to verify parity." A useful tool needs both answers.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The MCP output limit was per value, not per response
&lt;/h3&gt;

&lt;p&gt;The first MCP formatter shortened nested values one at a time, then built the response. That did not constrain the total payload. The remediation report recorded a roughly 10 MB input yielding about 17.7 MB from one comparison call.&lt;/p&gt;

&lt;p&gt;For a local agent tool, that is enough to flood a context window with repeated evidence.&lt;/p&gt;

&lt;p&gt;The current implementation limits the whole response, preserves totals, labels truncation, and drops detail in a deterministic order. Its tests measure the actual structured plus text payload received by an MCP client as well as the formatting helper.&lt;/p&gt;

&lt;p&gt;The audit also found recorder/parser disagreement, event reordering that could pass, missing provenance that looked like agreement, and a report viewer that could not open the external JSON it documented.&lt;/p&gt;

&lt;h2&gt;
  
  
  The P0 repair
&lt;/h2&gt;

&lt;p&gt;The fix walks JSON-like values recursively and keeps the type explicit at every path: null, boolean, integer, float, string, array, object, or missing.&lt;/p&gt;

&lt;p&gt;That makes the rules identical at the root and inside a container:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;[1]&lt;/code&gt; versus &lt;code&gt;[true]&lt;/code&gt; is a mismatch;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;{ "x": 1 }&lt;/code&gt; versus &lt;code&gt;{ "x": 1.0 }&lt;/code&gt; is a mismatch;&lt;/li&gt;
&lt;li&gt;null and a missing key are distinct;&lt;/li&gt;
&lt;li&gt;tolerance applies only to finite float-versus-float values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In compact form, the contract is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;same(path) = same_json_type(a, b) ∧ compare_by_type(a, b)

integers: exact
floats:   finite(a, b) ∧ |a - b| ≤ ε
arrays:   same length ∧ same(index) for every index
objects:  same keys ∧ same(key) for every key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;em&gt;The comparison checks type before value at every nested path. Float tolerance applies only when both recorded values are floats.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is a specification. Its purpose is to make the important bit reviewable: a convenient host-language equality operator never gets to silently redefine the verification contract.&lt;/p&gt;

&lt;p&gt;The regression coverage takes those cases through the public recorder, JSONL reader, CLI, and a real stdio MCP process. The local suite is now 242 Python tests; Ruff, strict mypy, package builds, clean-wheel installation, frontend tests, and the frontend build also pass.&lt;/p&gt;

&lt;p&gt;That is a precise claim about the known failure: the local release candidate no longer certifies those nested type differences as strict parity.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSV onboarding and verdict strength
&lt;/h2&gt;

&lt;p&gt;The same candidate adds a small CSV Quick Compare path. A developer maps identity columns, stages, features, types, and units from two CSV logs; the existing trace engine then aligns and compares them. It does not import raw exchange data or introduce a second diff engine.&lt;/p&gt;

&lt;p&gt;The important limitation is deliberate: equal CSV rows normally cannot establish matching code, configuration, model, input snapshot, or clock domain. An equal comparison therefore stays &lt;code&gt;UNVERIFIABLE&lt;/code&gt; unless that provenance is supplied. A mismatch remains useful evidence of a difference.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffubv749zezi2j9zt9jxo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffubv749zezi2j9zt9jxo.png" alt="Verdict ladder distinguishing a mismatch from missing evidence and verified strict parity" width="799" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A useful tool does not turn absent evidence into agreement. It says what the supplied records can and cannot support.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A test technique worth reusing
&lt;/h2&gt;

&lt;p&gt;For any validator that can return a strong success result, write inputs that contradict the result by construction. For a JSON comparator, that means testing each rule at the root and inside objects and arrays:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;True&lt;/code&gt; versus &lt;code&gt;1&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;1&lt;/code&gt; versus &lt;code&gt;1.0&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;a missing key versus &lt;code&gt;null&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;a value just inside and just outside float tolerance;&lt;/li&gt;
&lt;li&gt;identical event IDs with different declared provenance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes the guarantee concrete enough to attack. The repository is public; the reported 242 local tests and quality gates are useful evidence, not an independent correctness proof.&lt;/p&gt;

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

&lt;p&gt;The repository includes only synthetic examples; it does not contain HFM market data or a trading system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/icesurf666/hfm-parity-lab.git
&lt;span class="nb"&gt;cd &lt;/span&gt;hfm-parity-lab &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; python &lt;span class="nt"&gt;-m&lt;/span&gt; venv .venv &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;source&lt;/span&gt; .venv/bin/activate
pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; hfm-parity demo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That writes a synthetic HTML and JSON report. The &lt;a href="https://github.com/icesurf666/hfm-parity-lab/blob/main/tests/test_nested_values.py" rel="noopener noreferrer"&gt;nested-value regression tests&lt;/a&gt; cover the false-PASS class described here; the &lt;a href="https://github.com/icesurf666/hfm-parity-lab#readme" rel="noopener noreferrer"&gt;README&lt;/a&gt; has the trace format and CSV workflow.&lt;/p&gt;

</description>
      <category>python</category>
      <category>testing</category>
      <category>debugging</category>
      <category>devtools</category>
    </item>
    <item>
      <title>I Let an LLM Agent Search for Trading Strategies. A Simple Heuristic Beat It.</title>
      <dc:creator>Pavel Kazantsev 💎</dc:creator>
      <pubDate>Tue, 20 Oct 2026 18:22:17 +0000</pubDate>
      <link>https://dev.to/pavel_kkkkazantsev/i-let-an-llm-agent-search-for-trading-strategies-a-simple-heuristic-beat-it-10k2</link>
      <guid>https://dev.to/pavel_kkkkazantsev/i-let-an-llm-agent-search-for-trading-strategies-a-simple-heuristic-beat-it-10k2</guid>
      <description>&lt;p&gt;I gave DeepSeek V3 forty chances to find a profitable trading strategy.&lt;/p&gt;

&lt;p&gt;A simple heuristic found +52% net. The LLM's early proposals lost money. After fixing three silent bugs the agent surfaced, it improved — then optimized its way to +123.7%, a number that didn't survive scrutiny. Here's what happened across four rounds.&lt;/p&gt;

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

&lt;p&gt;In earlier posts in this series I tested &lt;a href="https://dev.to/pavel_kkkkazantsev/my-crypto-backtest-had-a-sharpe-of-134-then-i-added-trading-costs-5718"&gt;six dead-simple strategies&lt;/a&gt; and &lt;a href="https://dev.to/pavel_kkkkazantsev/three-crypto-edges-three-different-killers-1i6o"&gt;three more sophisticated edges&lt;/a&gt; — all killed by fees, adverse selection, or data leakage. What survived was a backtest harness: point-in-time universe, walk-forward, trading costs, out-of-sample scoring only. Same rules for every strategy, no exceptions. I put an agent in front of it.&lt;/p&gt;

&lt;p&gt;A proposal is a typed JSON object:&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Proposal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;        &lt;span class="c1"&gt;# "reversal" | "factor_residual" | "momentum"
&lt;/span&gt;    &lt;span class="n"&gt;bar_size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;      &lt;span class="c1"&gt;# "15m" | "1h" | "1d"
&lt;/span&gt;    &lt;span class="n"&gt;lookback&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;      &lt;span class="c1"&gt;# days
&lt;/span&gt;    &lt;span class="n"&gt;holding_period&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;
    &lt;span class="n"&gt;entry_threshold&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;

&lt;span class="c1"&gt;# The agent loop
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;agent_loop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n_rounds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ScoredProposal&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
    &lt;span class="n"&gt;history&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ScoredProposal&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n_rounds&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;build_prompt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;history&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c1"&gt;# what failed, what survived
&lt;/span&gt;        &lt;span class="n"&gt;json_str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                  &lt;span class="c1"&gt;# DeepSeek V3 via OpenRouter
&lt;/span&gt;        &lt;span class="n"&gt;proposal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parse_proposal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json_str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;verdict&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;harness&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;proposal&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;       &lt;span class="c1"&gt;# walk-forward over 451 symbols, 76 windows
&lt;/span&gt;        &lt;span class="n"&gt;history&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ScoredProposal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;proposal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verdict&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;history&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent never touches the scoring. It proposes; the same judge that every hand-built strategy went through decides. There is no way for it to talk its way to a good number.&lt;/p&gt;

&lt;p&gt;I also kept a heuristic proposer alongside it: samples the space randomly, occasionally perturbs the current best. It is not purely random — the perturbation step is local optimization — but it needs no model and costs nothing. Both the heuristic and the agent ran for the same 40 evaluation rounds. That baseline turned out to matter a lot.&lt;/p&gt;

&lt;h2&gt;
  
  
  Round one: the model lost to the heuristic
&lt;/h2&gt;

&lt;p&gt;The first LLM run was worse than the heuristic search.&lt;/p&gt;

&lt;p&gt;DeepSeek had the right instinct — it leaned toward factor-residual reversion on daily bars (buy coins whose recent return lagged the cross-sectional average, hold for ~30 days), which was the only corner that remained promising in this run. But it picked short lookbacks and fast rebalances:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;factor_residual/1d/lb30/reb15   -23.7%   reject
factor_residual/1d/lb20/reb10   -44.4%   reject
reversal/15m/lb5/reb2           -99.1%   reject
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Meanwhile the heuristic had stumbled into &lt;code&gt;factor_residual/1d/lb60/reb30&lt;/code&gt;: about +52% net, positive in most out-of-sample windows, tiny turnover. The model landed one step away from the edge and picked the wrong side of it. Right family, wrong calibration. The heuristic beat it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bugs the harness caught
&lt;/h2&gt;

&lt;p&gt;Before I wrote the model off, something more useful turned up.&lt;/p&gt;

&lt;p&gt;Several proposals came back with zero turnover and zero return. Not negative — flat. The strategy had never opened a position. The three bugs had the same symptom: a flat book, zero turnover, no crash, and no error message. Just silence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bug 1: Momentum's volatility window was scaled wrong.&lt;/strong&gt;&lt;br&gt;
The signal normalized by a 96-bar trailing volatility. On 15-minute data that is one day — fine. On daily bars it is 96 days, longer than the formation window, so the signal never became valid.&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;# Bug: hardcoded window ignores bar size
&lt;/span&gt;&lt;span class="n"&gt;vol_window&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;96&lt;/span&gt;

&lt;span class="c1"&gt;# Fix: scale to timeframe; floor of 5 bars avoids a 1-bar window on daily
&lt;/span&gt;&lt;span class="n"&gt;BAR_MINUTES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;15m&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1h&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1d&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1440&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;vol_window&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&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="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;96&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;BAR_MINUTES&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;bar_size&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;
&lt;span class="c1"&gt;# 15m → 96 bars (one day)  |  1h → 24 bars  |  1d → max(5,1) = 5 days
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Bug 2: Lookback could exceed the formation window.&lt;/strong&gt;&lt;br&gt;
The agent proposed a 100-day lookback on a 90-day formation window. Fix: clamp the lookback to what is actually available.&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;lookback&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;proposal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lookback&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;formation_window&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;&lt;strong&gt;Bug 3: The rebalance grid starved itself.&lt;/strong&gt;&lt;br&gt;
The wrapper refreshed positions on a fixed grid from bar zero: bar 0, bar 40, bar 80. If the signal only came alive around bar 90, every refresh point landed in the warmup period. A holding period of 40 was dead while 30 and 45 traded — non-monotonic results that mean "bug", not "no edge".&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;# Bug: grid anchored at bar 0
&lt;/span&gt;&lt;span class="n"&gt;rebalance_bars&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n_bars&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;holding_period&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Fix: anchor at first live bar
&lt;/span&gt;&lt;span class="n"&gt;first_live&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;warmup_length&lt;/span&gt;
&lt;span class="n"&gt;rebalance_bars&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;first_live&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n_bars&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;holding_period&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;None of these were crashes. Each returned a flat book with no error. That is exactly why a harness should fail loudly when a strategy that is meant to trade has zero turnover. Treating "no position" as a valid zero-return result would have buried all three.&lt;/p&gt;

&lt;h2&gt;
  
  
  Round two: it maps the edge
&lt;/h2&gt;

&lt;p&gt;With the space cleaned up, I reran the LLM agent. This time it clustered on factor-residual daily and swept the lookback itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;factor_residual/1d/lb70/reb35   +67.1%
factor_residual/1d/lb50/reb25   +65.9%
factor_residual/1d/lb40/reb20    +6.5%
factor_residual/1d/lb30/reb15   -26.6%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;The model drew the line itself. Long lookback positive, short lookback negative, and it found the boundary from feedback alone — no knowledge of what the heuristic had found. Right family, right direction, just needed a clean space to work in.&lt;/p&gt;

&lt;p&gt;So is the edge real? Not established.&lt;/p&gt;

&lt;p&gt;Across lookbacks from 40 to 80 days with monthly rebalance it stays net positive, roughly +46% to +84% over the backtest period. (The edge map above shows lb40 at only +6.5% because that sweep used a faster reb20 rebalance — different configuration, same lookback.) Positive in four of five years, down hard in 2023. Survives a pessimistic 30 bps per side. Annualized Sharpe around 0.9. A label-permutation null — which scrambles which coin gets which cross-sectional residual, testing whether the ranking actually carries signal — puts it at p = 0.048, right at the edge of significant.&lt;/p&gt;

&lt;p&gt;A promising but unconfirmed lead. The parameters and family were selected on these same results, so the p-value doesn't account for the full search process. Not a confirmed strategy — the backtest window is used up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Round three: a better optimizer, a bigger number
&lt;/h2&gt;

&lt;p&gt;I wrapped the model in a hybrid proposer — the LLM picks the family and timeframe, but on alternating turns it sweeps the lookback and rebalance around the current best.&lt;/p&gt;

&lt;p&gt;It found a peak at a 50-day lookback with monthly rebalance: &lt;strong&gt;+123.7% net&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;(Round 2 showed lb50 at +65.9% with reb25. Same lookback, different rebalance, and now optimizing both jointly — that's where the extra 60 points came from. Also the best of 35 configs, not the average.)&lt;/p&gt;

&lt;p&gt;This is a trap, and one column gives it away:&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;Round 3 (argmax)&lt;/th&gt;
&lt;th&gt;Round 4 (ensemble)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Net return&lt;/td&gt;
&lt;td&gt;+123.7%&lt;/td&gt;
&lt;td&gt;+75.8%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;% positive OOS windows&lt;/td&gt;
&lt;td&gt;58%&lt;/td&gt;
&lt;td&gt;62%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bootstrap worst case&lt;/td&gt;
&lt;td&gt;−55%&lt;/td&gt;
&lt;td&gt;−9%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bootstrap positive (20 runs)*&lt;/td&gt;
&lt;td&gt;16/20&lt;/td&gt;
&lt;td&gt;18/20&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

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

&lt;p&gt;&lt;em&gt;* 20 bootstrap runs is preliminary; treat the positive-run counts as directional, not precise.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Magnitude doubled. Breadth barely moved.&lt;/p&gt;

&lt;p&gt;You can inflate magnitude by picking better parameters. Breadth doesn't work that way. It didn't move.&lt;/p&gt;

&lt;p&gt;Here's the problem with reporting the best of 35 configs: even if none of them had any real edge, random variation across 35 tries would still produce one winner. A deflated Sharpe helps, but only for the search you tell it about. The reported 0.70 used this local 7×5 Round 3 grid: N = 35. It did not include the earlier LLM rounds, the heuristic search, the family/timeframe choice, or the debugging runs that led to the grid. Nor are these 35 independent tests: nearby lookbacks produce highly correlated variants of the same signal.&lt;/p&gt;

&lt;p&gt;So 0.70 is not a fully search-corrected significance claim. It is a local-grid diagnostic — and even under that friendlier accounting it missed the project's 0.95 qualification threshold. The honest conclusion is simpler: the best configuration did not establish significance. A broader accounting of the search would make the evidence weaker, not stronger.&lt;/p&gt;

&lt;h2&gt;
  
  
  Round four: I hadn't used my own tools
&lt;/h2&gt;

&lt;p&gt;Overfitting has known cures. I hadn't reached for any of them.&lt;/p&gt;

&lt;p&gt;Stop picking a winner. Average the whole plateau instead.&lt;/p&gt;

&lt;p&gt;I took all factor-residual configs on daily bars with lookback between 40 and 80 — the range where the sign stayed consistent — and averaged them without picking a winner.&lt;/p&gt;

&lt;p&gt;The plateau range itself came from inspecting these same results, so it doesn't fully eliminate selection bias. But it does reduce sensitivity to any single lucky configuration. The +75.8% is less sensitive to one lucky setting, but it is still an in-sample research result, not independent confirmation of alpha.&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;# Plateau: family=factor_residual, bar=1d, lookback in [40..80]
# Range chosen where sign was consistent — but still data-derived, not pre-specified.
&lt;/span&gt;&lt;span class="n"&gt;plateau&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;
           &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;family&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;factor_residual&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
           &lt;span class="ow"&gt;and&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;bar_size&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1d&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
           &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&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;lookback&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;ensemble_signal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;plateau&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;axis&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I equal-weighted the factor-residual signal across lookbacks from 40 to 80 days, one combined strategy, monthly rebalance.&lt;/p&gt;

&lt;p&gt;Result: +75.8% net, annualized Sharpe 0.61, positive in 62% of windows. That is not a significance claim. A rough calculation using five annual observations puts the t-statistic at about 1.4, before any search correction. The 30-day holds also make adjacent walk-forward windows overlap. So 62% positive windows is a useful breadth check, not 76 independent confirmations.&lt;/p&gt;

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

&lt;p&gt;Both configurations target the same hypothesized signal. The ensemble is less exposed to one lucky (lb, reb) combination; that is all the bootstrap difference shows.&lt;/p&gt;

&lt;h2&gt;
  
  
  The point
&lt;/h2&gt;

&lt;p&gt;I did not build an AI that finds alpha.&lt;/p&gt;

&lt;p&gt;I built a cheap agent with the right instinct and the wrong calibration. The harness exposed three silent bugs because a flat book looked flat. The optimizer then used the cleaned-up space to add 60 percentage points to a backtest number. The ensemble made the remaining signal less tied to one parameter choice, but did not turn it into proof.&lt;/p&gt;

&lt;p&gt;Three things I'd take from this:&lt;/p&gt;

&lt;p&gt;Run a heuristic baseline first. Until the search space was clean, it beat the model. Don't skip it just because the LLM reasons better.&lt;/p&gt;

&lt;p&gt;The agent is only as honest as the thing that scores it. The judge comes first. The proposer is easy to swap out.&lt;/p&gt;

&lt;p&gt;Once the proposer can optimize, it will. Watch breadth, not magnitude. And when you can average the plateau instead of picking the best config, do it — the gap between +124% and +76% was entirely parameter sensitivity.&lt;/p&gt;

&lt;p&gt;Give a language model a truthful referee and a constrained enough space, and it can find a corner worth inspecting. It will not necessarily beat a simple heuristic, especially if the search space has silent bugs. Once it can optimize, expect a number larger than the evidence warrants unless you correct for the search.&lt;/p&gt;

&lt;p&gt;The referee is the part that matters.&lt;/p&gt;

</description>
      <category>python</category>
      <category>testing</category>
      <category>datascience</category>
      <category>ai</category>
    </item>
    <item>
      <title>14,399 Backtest Events Gave Me t = 8.20. Equal-Weighting Days Gave 1.66</title>
      <dc:creator>Pavel Kazantsev 💎</dc:creator>
      <pubDate>Fri, 16 Oct 2026 16:40:42 +0000</pubDate>
      <link>https://dev.to/pavel_kkkkazantsev/14399-backtest-events-gave-me-t-820-equal-weighting-days-gave-166-2hg7</link>
      <guid>https://dev.to/pavel_kkkkazantsev/14399-backtest-events-gave-me-t-820-equal-weighting-days-gave-166-2hg7</guid>
      <description>&lt;p&gt;A crypto-perpetual breakout simulation produced 14,399 events across 15 symbols from September 2025 to September 2026. Mean net return was &lt;strong&gt;+25.98 bps&lt;/strong&gt; per event, with a naive event-level t-statistic of &lt;strong&gt;+8.20&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But the result depended heavily on how observations were weighted. Returns were concentrated in a small number of market sessions, something the aggregate statistic did not reveal.&lt;/p&gt;

&lt;p&gt;Pooled over events, the mean is positive. Per day, it is negative. The gap is entirely Oct 10.&lt;/p&gt;

&lt;h2&gt;
  
  
  Same events, different unit of analysis
&lt;/h2&gt;

&lt;p&gt;I grouped events by calendar day, computed one mean event return per day, then ran a one-sample t-test on those 365 daily means:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;event-level:  t = mean(event returns) / (sd / √N)
               = +25.98 / (380.2 / √14,399)  =  +8.20

day-level:    t = mean(daily means)   / (sd / √N)
               = −4.67  / (53.82 / √365)     =  −1.66
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are different estimands. The first weights every event equally; the second weights every trading day equally. The sign reversal does not prove the naive SE was wrong — it shows that the result is sensitive to the weighting choice, which is reason enough to report both. The second is a diagnostic, not a replacement for clustered standard errors or a block bootstrap. For any strategy that fires multiple times a day on correlated moves, it's a useful sanity check.&lt;/p&gt;

&lt;h2&gt;
  
  
  The day behind the result
&lt;/h2&gt;

&lt;p&gt;October 10, 2025 accounted for most of the positive event-level return. DOTUSDT traded between $0.94 and $4.29 during a market-wide flash crash. ATOMUSDT also experienced extreme price dislocations. Whether the simulated trades could have been executed at those prices is unclear. The simulation's 434 events that day averaged &lt;strong&gt;+981 bps&lt;/strong&gt;. Remove that one day and the event-level mean changes from +25.98 to &lt;strong&gt;−3.69 bps&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The median event lost −16.2 bps. Win rate was 34%. The maximum event return was +8,756 bps. The top 1% of events were enough to flip the mean. Only one day made it positive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl9zpf75h3g57x6bq9tlp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl9zpf75h3g57x6bq9tlp.png" alt="Aggregate results: all events +25.98 bps, without Oct 10 −3.69 bps, Oct 10 alone +981 bps across 434 events" width="799" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;October 10, 2025 contributed 434 of 14,399 events, but those events averaged +981 bps. Removing that one day changes the event-level mean from +25.98 to −3.69 bps.&lt;/em&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Statistic&lt;/th&gt;
&lt;th&gt;Unit / N&lt;/th&gt;
&lt;th&gt;Mean net&lt;/th&gt;
&lt;th&gt;SD&lt;/th&gt;
&lt;th&gt;t-stat&lt;/th&gt;
&lt;th&gt;Note&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Naive t-test&lt;/td&gt;
&lt;td&gt;14,399 events&lt;/td&gt;
&lt;td&gt;+25.98 bps&lt;/td&gt;
&lt;td&gt;380.2 bps&lt;/td&gt;
&lt;td&gt;+8.20&lt;/td&gt;
&lt;td&gt;Assumes independent events&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Daily diagnostic&lt;/td&gt;
&lt;td&gt;365 days&lt;/td&gt;
&lt;td&gt;−4.67 bps&lt;/td&gt;
&lt;td&gt;53.8 bps&lt;/td&gt;
&lt;td&gt;−1.66&lt;/td&gt;
&lt;td&gt;Two-sided p ≈ 0.098&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sensitivity: without Oct 10&lt;/td&gt;
&lt;td&gt;364 days&lt;/td&gt;
&lt;td&gt;−7.37 bps&lt;/td&gt;
&lt;td&gt;14.9 bps&lt;/td&gt;
&lt;td&gt;−9.42&lt;/td&gt;
&lt;td&gt;Post-hoc; exposes concentration&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Event-level SD is 380 bps; day-level SD is 54 bps — a 7× collapse. Both t-stats use the same formula (mean / SE), but they're measuring different dispersions. The event-level SE is tiny because N=14,399; the day-level SE is larger because the daily means are themselves variable, and one day (Oct 10, mean +981 bps) inflates both the event-level mean and the day-level SD in opposite directions.&lt;/p&gt;

&lt;p&gt;The sensitivity row is not a confirmatory result. Removing an outlier and calling the rerun clean is p-hacking. It is there to show how much of the claim rests on one day.&lt;/p&gt;

&lt;h2&gt;
  
  
  The diagnostic
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;scipy&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;stats&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;day_block_t&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;returns_bps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ndarray&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timestamps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Series&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Equal-weighted daily diagnostic for event returns.

    Groups events by calendar day, computes the mean return per day,
    and tests whether the distribution of daily means differs from zero.

    This changes the unit of analysis from event to trading day.
    It is NOT a cluster-robust standard error for the event-level mean.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;returns_bps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;asarray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;returns_bps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;days&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Series&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timestamps&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;D&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to_numpy&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;returns_bps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;days&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;returns_bps and timestamps must have equal length&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isfinite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;returns_bps&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;all&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;returns_bps must be finite&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;frame&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;return_bps&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;returns_bps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;day&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;days&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="n"&gt;daily&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;groupby&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;day&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;return_bps&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;daily&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;at least two trading days are required&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;t_stat&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ttest_1samp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;daily&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;popmean&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="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;n_events&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;n_days&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;daily&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;daily_mean_bps&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;daily&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mean&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="c1"&gt;# input already in bps
&lt;/span&gt;        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;t_stat&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t_stat&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;p_value&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_value&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;daily&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;daily&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;# keep the series — inspect it, don't trust the summary
&lt;/span&gt;    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Usage
&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;day_block_t&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event_returns_bps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event_timestamps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Event-level t = &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;event_returns_bps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mean&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;event_returns_bps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;std&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ddof&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="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event_returns_bps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Day-level   t = &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;t_stat&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;  (N=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;n_days&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; days)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# Event-level t = +8.20
# Day-level   t = -1.6579  (N=365 days)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep the daily series in the result. A t-statistic is one number; the series shows where the result is coming from.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspecting the concentration
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;

&lt;span class="n"&gt;daily&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;daily&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;  &lt;span class="c1"&gt;# already in bps
&lt;/span&gt;
&lt;span class="n"&gt;fig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;colors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;#ef4444&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="nf"&gt;else &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;#4ade80&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;#f87171&lt;/span&gt;&lt;span class="sh"&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;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;daily&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;daily&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="n"&gt;daily&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;axhline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;#6b7280&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;linewidth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set_xlabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Trading day&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set_ylabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Daily mean return (bps)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set_title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Daily mean return — &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;n_days&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; days, t = &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;t_stat&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Flag days &amp;gt; 3σ
&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;daily&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;daily&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;std&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;outliers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;daily&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;daily&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;std&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;idx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;outliers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;annotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; bps&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;daily&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="nf"&gt;get_loc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                &lt;span class="n"&gt;xytext&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;textcoords&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;offset points&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;ha&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;center&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fontsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;#ef4444&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tight_layout&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Leave-one-day-out
&lt;/h2&gt;

&lt;p&gt;Removing October 10 explicitly is post-hoc. The full diagnostic runs the same removal for all 365 days and plots t-stat vs dropped day.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fykslt2tyw8ix421vza48.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fykslt2tyw8ix421vza48.png" alt="Leave-one-day-out t-stat plot. 364 days cluster near −1.5. October 10 is the single outlier: dropping it moves t from −1.66 to −9.42." width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;LOO diagnostic across all 365 trading days. Dropping any day other than Oct 10 barely moves the t-stat (−1.3 to −1.8 range). Dropping Oct 10 alone moves it to −9.42. One spike, standing alone — concentration, not fat tails.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If several days had moved the t-stat materially, the process would be fat-tailed and the right test would be a week-block bootstrap. That's not what happened here: one day, one event cluster, and it's gone when you drop Oct 10.&lt;/p&gt;

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

&lt;p&gt;There is no single correct return series. If capital is allocated to a portfolio, construct portfolio returns. If the estimand is per-event alpha, preserve that estimand and use an estimator that accounts for dependence: clustered standard errors, a block bootstrap, or HAC/Newey–West where it applies.&lt;/p&gt;

&lt;p&gt;Nor is deleting October 10 a valid way to obtain a clean p-value. The primary result keeps every day. The removal is explicitly a post-hoc sensitivity analysis: it tells us how fragile the claim is, not what a pre-specified experiment would have concluded.&lt;/p&gt;

&lt;p&gt;The daily t-test still assumes independence across days. It does not automatically account for serial correlation, which is another reason it is a diagnostic rather than the final inference procedure.&lt;/p&gt;

&lt;p&gt;The 14,399 events weren't 14,399 independent observations. Most of the positive return came from 434 events on a single day. The naive t-stat didn't reveal that concentration. The daily breakdown did.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part of the &lt;a href="https://www.pkazantsev.com/writing/hfm-research-origin/" rel="noopener noreferrer"&gt;HFM Research methodology series&lt;/a&gt; — six things we found when we audited our own backtest results.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>statistics</category>
      <category>python</category>
      <category>machinelearning</category>
      <category>datascience</category>
    </item>
    <item>
      <title>I Built an AI That Checks Whether Digital Products Deliver What They Promise</title>
      <dc:creator>Pavel Kazantsev 💎</dc:creator>
      <pubDate>Tue, 13 Oct 2026 20:17:51 +0000</pubDate>
      <link>https://dev.to/pavel_kkkkazantsev/i-built-an-ai-that-checks-whether-digital-products-deliver-what-they-promise-4nf2</link>
      <guid>https://dev.to/pavel_kkkkazantsev/i-built-an-ai-that-checks-whether-digital-products-deliver-what-they-promise-4nf2</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-week2-2026-10-12"&gt;Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  I Built an AI That Checks Whether Digital Products Deliver What They Promise
&lt;/h1&gt;

&lt;p&gt;A digital-product listing can promise “48 pages”, “A4 and US Letter editions”, and “debt repayment worksheets.” Then the customer opens the ZIP and finds something else.&lt;/p&gt;

&lt;p&gt;For a small seller, that turns into refunds, support messages, rough reviews, and the awful feeling that you missed something obvious. PromiseDiff is a local-first pre-publish check for Etsy, Gumroad, template, and educational-PDF sellers.&lt;/p&gt;

&lt;p&gt;Paste in the listing. Upload the actual PDF or ZIP. PromiseDiff shows what the files can back up, what they contradict, and what they simply cannot prove.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The rule I cared about most:&lt;/strong&gt; missing text is not a failure. A measured mismatch is a contradiction; a claim the files cannot prove is just unverified.&lt;/p&gt;

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

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

&lt;p&gt;Every claim gets one of four plain outcomes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;SUPPORTED&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The supplied evidence supports this exact promise.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;CONTRADICTED&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A reproducible check established a conflicting fact.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;UNVERIFIED&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The files do not establish the claim. Missing evidence is not a contradiction.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;OUT_OF_SCOPE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The claim needs a capability the MVP cannot test.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Every result keeps the method and the evidence that led to it.&lt;/p&gt;

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

&lt;p&gt;For example, a page-count claim is deterministic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Listing: “The main PDF contains exactly 48 pages.”
File:    budget_planner_A4.pdf → 48 pages
Result:  SUPPORTED — DETERMINISTIC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;“Includes debt repayment worksheets” is different. A PDF might call that page a “Loan Balance Reduction Tracker.” Here Gemma looks at the extracted text, but PromiseDiff only accepts the result after checking the suggested filename, page, and quote against the actual PDF.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzyoyehxy75kli9qewz5k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzyoyehxy75kli9qewz5k.png" alt="The verification flow combines direct measurement with semantic evidence" width="799" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;The demo uses a real 48-page A4 Budget Planner PDF. Nothing is mocked.&lt;/p&gt;

&lt;p&gt;I used &lt;a href="https://github.com/icesurf666/progress-cut" rel="noopener noreferrer"&gt;ProgressCut&lt;/a&gt; to cut the screen recording down to a short walkthrough.&lt;/p&gt;

&lt;p&gt;The listing promises:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The main PDF contains exactly 48 pages.
Includes both A4 and US Letter PDF editions.
Contains monthly budget review worksheets.
Includes savings goal trackers.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The upload only has the A4 edition. PromiseDiff confirms the page count, flags the missing US Letter version, and lets the seller open the evidence or export the report as Markdown.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F044a4a0yk9l655phxv23.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F044a4a0yk9l655phxv23.gif" alt="A short PromiseDiff walkthrough, recorded and cut with ProgressCut" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How I built it
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Why a hybrid system instead of “ask the model”?
&lt;/h3&gt;

&lt;p&gt;Some questions have a simple answer; others need interpretation.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Question&lt;/th&gt;
&lt;th&gt;Correct tool&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;How many PDF pages exist?&lt;/td&gt;
&lt;td&gt;PyMuPDF metadata&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Is this page actually A4?&lt;/td&gt;
&lt;td&gt;PDF geometry with a 3-point tolerance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Does a listed file exist?&lt;/td&gt;
&lt;td&gt;Complete file inventory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Does “Loan Balance Reduction Tracker” plausibly satisfy a debt-repayment claim?&lt;/td&gt;
&lt;td&gt;Gemma plus validated quotation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Asking a language model to count pages is slower and worse than reading the PDF metadata. But keyword search alone will not reliably connect “debt repayment” and “loan balance reduction.” So each tool only gets the jobs it can support with evidence.&lt;/p&gt;

&lt;p&gt;The rule is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;missing evidence != contradiction
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm80696fodwn5xo4zbpfg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm80696fodwn5xo4zbpfg.png" alt="A model citation must pass the evidence gate before it can support a claim" width="799" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the document is scanned, the claim scope is ambiguous, a citation points to a nonexistent page, or a quote does not occur in extracted text, the answer is &lt;code&gt;UNVERIFIED&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architecture and safety
&lt;/h3&gt;

&lt;p&gt;It is a small React + FastAPI app. The verification-flow diagram above shows how the pieces connect.&lt;/p&gt;

&lt;p&gt;Uploads are untrusted, so the backend puts tight boundaries around them: size, PDF count, total pages, extracted text, ZIP ratio, file types, and expanded ZIP size. It rejects traversal paths, duplicate entries, encrypted PDFs, nested archives, and corrupt files. The original upload is never saved.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkzr0pk0535i18umh5dbw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkzr0pk0535i18umh5dbw.png" alt="The upload boundary rejects unsafe archives before analysis" width="799" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The model work is deliberately kept small:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Gemma extracts structured promises from the listing.&lt;/li&gt;
&lt;li&gt;Python validates source quotations and normalizes measurable claims.&lt;/li&gt;
&lt;li&gt;Local retrieval selects compact, potentially relevant PDF excerpts.&lt;/li&gt;
&lt;li&gt;Gemma evaluates semantic correspondence in batch.&lt;/li&gt;
&lt;li&gt;Evidence validation checks filename, page, and exact quote before serialization.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why does open innovation matter?
&lt;/h2&gt;

&lt;p&gt;Many sellers are working on unpublished material: course notes, templates, client downloads, and draft listings. With the local setup, Ollama keeps the listing text and extracted PDF text on the seller’s machine.&lt;/p&gt;

&lt;p&gt;Open-weight Gemma also makes this affordable for a small operation. A local run has no per-audit third-party API bill, although someone still pays for the hardware or hosting. Sellers can repeat the same check before every release without handing their draft material to another service.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reproducible benchmark, including a failure
&lt;/h2&gt;

&lt;p&gt;I made ten independently labelled synthetic PDF cases and ran them through the same local API the UI uses. The runner saves the raw responses and timings in &lt;code&gt;benchmark/results.json&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exact-label accuracy = correct labels / total cases = 9 / 10 = 90%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fawlzkit8rrktrvyvx51b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fawlzkit8rrktrvyvx51b.png" alt="Nine benchmark cases matched their expected labels; one paraphrase stayed unverified" width="799" height="413"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;xychart-beta
  title "Exact classification by category (10 synthetic cases)"
  x-axis [Supported, Contradicted, Unverified, OutOfScope]
  y-axis "Correct cases" 0 --&amp;gt; 4
  bar [3, 2, 3, 1]&lt;/code&gt;&lt;/pre&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;th&gt;Caveat&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Exact-label accuracy&lt;/td&gt;
&lt;td&gt;90% (9/10)&lt;/td&gt;
&lt;td&gt;Tiny synthetic evaluation, not a generalization claim.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Contradiction precision&lt;/td&gt;
&lt;td&gt;100% (2/2)&lt;/td&gt;
&lt;td&gt;Both measured failures were page/dimension facts.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Contradiction recall&lt;/td&gt;
&lt;td&gt;100% (2/2)&lt;/td&gt;
&lt;td&gt;Same small set.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supported recall&lt;/td&gt;
&lt;td&gt;75% (3/4)&lt;/td&gt;
&lt;td&gt;One semantic paraphrase was conservatively left unverified.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Median API latency&lt;/td&gt;
&lt;td&gt;2.11 s&lt;/td&gt;
&lt;td&gt;Local Gemma on this machine.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mean API latency&lt;/td&gt;
&lt;td&gt;3.50 s&lt;/td&gt;
&lt;td&gt;Prompt-injection case took 13.81 s.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The miss is the useful bit. The listing said &lt;strong&gt;debt repayment worksheet&lt;/strong&gt; and the PDF said &lt;strong&gt;Loan Balance Reduction Tracker&lt;/strong&gt;. The model did not have strong enough evidence to connect them, so PromiseDiff returned &lt;code&gt;UNVERIFIED&lt;/code&gt; instead of pretending it knew. That is a limitation to fix, not a result to hide.&lt;/p&gt;

&lt;h2&gt;
  
  
  Known limitations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The benchmark is small and synthetic. It is not a claim about every kind of seller PDF.&lt;/li&gt;
&lt;li&gt;Scanned documents without extractable text can still receive metadata checks, but semantic claims remain unverified.&lt;/li&gt;
&lt;li&gt;The current retrieval can miss paraphrases. In the benchmark, “debt repayment worksheet” and “Loan Balance Reduction Tracker” stayed unverified rather than becoming a false positive.&lt;/li&gt;
&lt;li&gt;Public deployments should isolate PDF processing with strict resource limits.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I would build next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Better paraphrase retrieval before semantic evaluation.&lt;/li&gt;
&lt;li&gt;Seller feedback on which promise types produce the most costly mistakes.&lt;/li&gt;
&lt;li&gt;Batch release audits and version-to-version diffs.&lt;/li&gt;
&lt;li&gt;Isolated PDF processing for public deployments.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/icesurf666/PromiseDiff" rel="noopener noreferrer"&gt;PromiseDiff source code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The repository has the local setup, real example PDF, test commands, security notes, and benchmark runner.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prize categories
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Best Use of Gemma&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
      <category>gemma</category>
      <category>opensource</category>
    </item>
    <item>
      <title>I Tested 58 Trading Hypotheses. 48 Failed. Here’s the Framework That Killed Them.</title>
      <dc:creator>Pavel Kazantsev 💎</dc:creator>
      <pubDate>Fri, 09 Oct 2026 14:53:19 +0000</pubDate>
      <link>https://dev.to/pavel_kkkkazantsev/i-tested-58-trading-hypotheses-48-failed-heres-the-framework-that-killed-them-1poe</link>
      <guid>https://dev.to/pavel_kkkkazantsev/i-tested-58-trading-hypotheses-48-failed-heres-the-framework-that-killed-them-1poe</guid>
      <description>&lt;p&gt;58 hypotheses went in. 48 were rejected, 9 remained promising, and 1 could not be evaluated because the required data was unavailable.&lt;/p&gt;

&lt;p&gt;None of the 9 earned the label "edge." They earned the right to be tested further.&lt;/p&gt;

&lt;p&gt;Some ideas should die before a backtest is ever run. The rest should face the cheapest falsification test first. A hypothesis that cannot answer "who pays us?" and "why does this persist?" is not a hypothesis. It is a guess with a Python file attached.&lt;/p&gt;

&lt;p&gt;The kill pipeline that processed all 58, in the order most ideas die:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hypothesis idea
    ↓
cost filter        (does it survive fees and turnover at all?)
    ↓
robustness check   (is the result a plateau or a lucky parameter?)
    ↓
null benchmark     (does it beat a structure-preserving random version?)
    ↓
untouched holdout  (does it hold on a year it never saw?)
    ↓
contamination audit (is the result real or did the code lie to me?)
    ↓
survived research → forward / shadow validation → capital
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each gate catches a different type of false alpha. A strategy can clear the first four and die on the fifth. Passing all five is not a green light. It is permission to start collecting forward data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpo85kaonmubsvqtv7i28.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpo85kaonmubsvqtv7i28.png" alt="Full kill pipeline — from hypothesis through five gates to locked capital" width="800" height="620"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Gate 1: costs
&lt;/h2&gt;

&lt;p&gt;The most common way a backtest looks good: skip costs. Cross-sectional reversal on 15-minute Bybit bars had a gross Sharpe of 7 to 13, positive in 80%+ of out-of-sample windows. The gross effect was clearly present before costs. At taker fees, rebalancing every bar, trading costs ran 5 to 10 times the size of the raw edge. After costs, zero out of 76 out-of-sample windows remained positive.&lt;/p&gt;

&lt;p&gt;I tried entry/exit thresholds, hysteresis, coarser timeframes, slower rebalancing. No plateau anywhere near break-even. Adjacent parameter settings swung from +45% to −60%.&lt;/p&gt;

&lt;p&gt;Run the cost test before you believe the signal, not after.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsw2pd6n8hzhpydq0g2bw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsw2pd6n8hzhpydq0g2bw.png" alt="Before costs: Sharpe 7–13, 80%+ OOS positive. After costs: 0/76 windows positive" width="800" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Gate 2: robustness
&lt;/h2&gt;

&lt;p&gt;Daily momentum had one configuration that returned +97% net at taker fees. The lookback sweep: l=7 gave +33%, l=10 gave −23%, l=14 gave +97%, l=21 gave +35%. No plateau. The +97% was a lucky draw from a jagged surface.&lt;/p&gt;

&lt;p&gt;Half the return came from the 2021 bull alone. 2022 was negative. A strategy that only makes money in bull markets and loses in bear is more consistent with market beta than neutral alpha.&lt;/p&gt;

&lt;p&gt;One good result on a swept parameter is not evidence. The whole surface needs to hold up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqywzn80nl2eada0p8fiq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqywzn80nl2eada0p8fiq.png" alt="Momentum lookback sweep: l=7 +33%, l=10 -23%, l=14 +97%, l=21 +35% — no plateau" width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Gate 3: null benchmark
&lt;/h2&gt;

&lt;p&gt;Funding carry looked strong in development: +48.6% net over 4.5 years, Sharpe 1.17. Before trusting it, I ran a null test: scramble which coin's funding the strategy reads, keep everything else identical. The scrambled version returned +28%.&lt;/p&gt;

&lt;p&gt;More than half the return was the structural funding premium: exposure to perpetual market mechanics rather than signal-driven selection. The selection component showed evidence beyond this null in development (empirical permutation p=0.024), but it was much smaller than the headline return implied.&lt;/p&gt;

&lt;p&gt;Before believing the result, ask whether a random version of the signal would also make money.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsol5j9xz7qnu9jk21hvb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsol5j9xz7qnu9jk21hvb.png" alt="Funding carry +48.6% vs scrambled null +28%, selection component +20.6%, p=0.024" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Gate 4: untouched holdout
&lt;/h2&gt;

&lt;p&gt;The lockbox is a date range fixed in advance, never touched until a single opening event. No research, no tuning, no plotting inside that range until development is complete.&lt;/p&gt;

&lt;p&gt;Funding carry passed development and validation. The lockbox was a 12-month period (2025-09 to 2026-09), sealed from day one. The frozen strategy made −0.5% on it. The premium that paid from 2021 to 2024 was absent in the lockbox year. One year of absence is not a permanent verdict. It is exactly the kind of regime dependence the lockbox is designed to expose early.&lt;/p&gt;

&lt;p&gt;Once a lockbox is opened, it is burned. Any further confirmation requires a new, still-unseen date range. Development results are hypotheses, and only sealed, untouched data can confirm them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F37fjbx5u2o4oqf7tw296.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F37fjbx5u2o4oqf7tw296.png" alt="Timeline 2021–2026: dev period +48.6%, lockbox 2025-09 to 2026-09 returned -0.5%" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Gate 5: contamination audit
&lt;/h2&gt;

&lt;p&gt;One BTC funding-trend hypothesis had a development t-stat of 2.6. The 1,248 events had 72-hour holding periods, so observations were heavily overlapping. The Newey-West corrected t-stat fell from 2.6 to 1.07, removing the apparent statistical evidence from that test. A real-looking result from a real-looking test, broken by one statistical assumption.&lt;/p&gt;

&lt;p&gt;On a separate project, a football prediction model passed closing-line value (CLV) validation with +152bps, 95% CI excluded zero. A five-check forensic audit found two contaminated features. Four of five checks failed. The metric that reported the good result was the last place to look for the error.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz75s53wsykhdgntvam70.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz75s53wsykhdgntvam70.png" alt="1,248 overlapping 72h events, OLS t-stat 2.6 drops to 1.07 after Newey-West NW-9 correction" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the 58 actually died
&lt;/h2&gt;

&lt;p&gt;Each hypothesis is assigned to the first decisive failure that stopped further evaluation. Some failed more than one check.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Kill gate&lt;/th&gt;
&lt;th&gt;Count&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Costs&lt;/td&gt;
&lt;td&gt;~20&lt;/td&gt;
&lt;td&gt;Price MR: gross Sharpe 7–13, net negative&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Robustness&lt;/td&gt;
&lt;td&gt;~10&lt;/td&gt;
&lt;td&gt;Daily momentum: +97% was one lucky lookback&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Null benchmark&lt;/td&gt;
&lt;td&gt;~8&lt;/td&gt;
&lt;td&gt;Funding carry null still returned +28%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Holdout / fresh OOS&lt;/td&gt;
&lt;td&gt;~7&lt;/td&gt;
&lt;td&gt;Funding carry −0.5% on sealed year; agent ensemble −35% OOS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No detectable signal / other rejection&lt;/td&gt;
&lt;td&gt;~3&lt;/td&gt;
&lt;td&gt;New-listing cohort: corr≈0, null p=0.94&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Total rejected&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;48&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data unavailable&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Required data unavailable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remaining PROMISING&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;Passed development and validation gates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Benjamini–Hochberg (BH) significant at FDR=0.05&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Independent mechanisms&lt;/td&gt;
&lt;td&gt;4–5&lt;/td&gt;
&lt;td&gt;roughly 4–5 distinct economic bets&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;9 survivors does not mean 9 strategies. Several share the same economic mechanism with different entry filters. 8 Benjamini–Hochberg (BH) significant hypotheses at FDR=0.05 collapse to roughly 4–5 independent bets on market structure by economic mechanism.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fog0gpwz829ps7qqpjel3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fog0gpwz829ps7qqpjel3.png" alt="58 → 48 killed + 9 promising + 1 unavailable → 8 BH-significant → 4–5 independent mechanisms" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The uncomfortable failures
&lt;/h2&gt;

&lt;p&gt;Two cases that took longer than they should have.&lt;/p&gt;

&lt;p&gt;An LLM-generated factor-residual ensemble showed +76% in development, Sharpe 0.6, tuned over multiple iterations. On a fresh holdout it reversed to −35%. The development result held inside the data it was tuned on. The fresh holdout showed what the agent had actually learned: the development period.&lt;/p&gt;

&lt;p&gt;In a funding carry reproduction audit a month after the original publication, the holdout result changed from −0.5% to +1.3%. Same code, same data cache, fingerprints matched. I still do not have a clean explanation. I published the discrepancy table rather than quietly resolving it. I scrutinized the original negative result far less than I would have scrutinized a positive one. Negative results get a lower evidentiary standard by default. They should not.&lt;/p&gt;

&lt;h2&gt;
  
  
  What survived
&lt;/h2&gt;

&lt;p&gt;A handful of hypotheses passed enough gates to justify forward validation. They are currently shadow-deployed: signals recorded in real time, parameters locked, no capital.&lt;/p&gt;

&lt;p&gt;None of them earned the right to be trusted based on the backtest. The backtest is permission to collect more data, not permission to trade.&lt;/p&gt;

&lt;p&gt;The specific signals are not published here. Forward validation is ongoing and the gate has not been reached.&lt;/p&gt;

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

&lt;p&gt;Before trusting any strategy result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ ] Realistic costs included from the start, not added after
[ ] Parameter robustness: result holds over adjacent settings (plateau, not spike)
[ ] Null benchmark: structure-preserving random version loses
[ ] Untouched holdout: a date range sealed before any research on that data
[ ] Contamination audit: no look-ahead, no survivorship, no feature leakage
[ ] Forward validation: signals collected in real time, parameters locked
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Costs and robustness killed roughly half of the 58 before a holdout was needed. Run the cheap gates first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdw9de57fmgkll91ne17g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdw9de57fmgkll91ne17g.png" alt="Research kill checklist: 6 gates from costs to forward validation" width="800" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The real lesson
&lt;/h2&gt;

&lt;p&gt;A high kill rate is not evidence that the pipeline is good. But a research process that rarely kills its own ideas is one I would distrust.&lt;/p&gt;

&lt;p&gt;48 of 58 died. If the kill rate were much lower, I would not trust the process.&lt;/p&gt;




&lt;p&gt;More experiments, engineering notes and quantitative research at pkazantsev.com&lt;/p&gt;

</description>
      <category>python</category>
      <category>trading</category>
      <category>datascience</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Green Tests, Broken Architecture: Four Models Review TypeScript Diffs</title>
      <dc:creator>Pavel Kazantsev 💎</dc:creator>
      <pubDate>Tue, 06 Oct 2026 10:20:38 +0000</pubDate>
      <link>https://dev.to/pavel_kkkkazantsev/green-tests-broken-architecture-four-models-review-typescript-diffs-16ge</link>
      <guid>https://dev.to/pavel_kkkkazantsev/green-tests-broken-architecture-four-models-review-typescript-diffs-16ge</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/kaggle-2026-09-23"&gt;Kaggle Benchmarking Challenge&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In ProgressCut, it is possible to write a change that works, passes a narrow test, and still violates a boundary I care about. A renderer can reach for Electron directly. A recovery record can be overwritten halfway through a write. An exported filename can escape its session folder.&lt;/p&gt;

&lt;p&gt;Those are review problems. I made a small benchmark to see how four models review short TypeScript diffs against explicit architecture rules.&lt;/p&gt;

&lt;p&gt;Three models got exactly &lt;strong&gt;0.949&lt;/strong&gt;. Each failed for a completely different reason.&lt;/p&gt;

&lt;p&gt;The public Kaggle task contains 13 compact synthetic diffs. Each has an expected APPROVE or BLOCK verdict, a violated invariant where applicable, and a requirement to cite evidence from the diff.&lt;/p&gt;

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

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

&lt;p&gt;This is a deliberately narrow review exercise:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Can a model reject a functionally plausible change when it violates an explicit repository invariant?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The diffs are synthetic and small. They are based on rules from ProgressCut, a local-first Electron application, but expose no private screenshots, sessions or unreleased code.&lt;/p&gt;

&lt;p&gt;The six rules under test:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;engine-no-node&lt;/code&gt;: algorithm code cannot import Node or platform APIs.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;domain-no-runtime-deps&lt;/code&gt;: domain types have no runtime-library dependency.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;renderer-no-electron&lt;/code&gt;: UI reaches native capabilities only through a narrow bridge.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;atomic-recovery-write&lt;/code&gt;: recovery metadata is written to a temporary file, then renamed.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;exact-render-duration&lt;/code&gt;: FFmpeg output is capped at the selected story duration.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;safe-output-path&lt;/code&gt;: an export cannot escape the configured session directory.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Seven changes should be blocked and six should be approved. The approval cases sit close to the violations: a renderer may call a typed bridge, but may not import Electron; &lt;code&gt;resolve()&lt;/code&gt; plus a path-boundary check is acceptable, while &lt;code&gt;join(outputDir, userName)&lt;/code&gt; is not.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the score works
&lt;/h2&gt;

&lt;p&gt;Each case is worth one point, split across three deterministic checks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;case score = (correct verdict + correct violated rule + grounded evidence) / 3
benchmark score = mean(case scores)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For an approved change, &lt;code&gt;rule_id&lt;/code&gt; must be &lt;code&gt;none&lt;/code&gt;. A reviewer has to recognize when a change satisfies a rule, not merely spot its vocabulary.&lt;/p&gt;

&lt;p&gt;I ran the unchanged task once per model through Kaggle's benchmark runner. Every model received the same rules and diff. The scorer is deterministic; no LLM judges another LLM.&lt;/p&gt;

&lt;h2&gt;
  
  
  Models Tested
&lt;/h2&gt;

&lt;p&gt;I used a small, deliberately mixed set from four providers, including the coding-focused Qwen3 Coder. This is not a claim of market coverage; it is a way to compare different review failure modes under the same prompt and scorer.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Score&lt;/th&gt;
&lt;th&gt;Server runtime&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Gemini 3.7 Flash&lt;/td&gt;
&lt;td&gt;1.000&lt;/td&gt;
&lt;td&gt;10m 48s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claude Sonnet 5&lt;/td&gt;
&lt;td&gt;0.949&lt;/td&gt;
&lt;td&gt;32.9s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GPT-5.4 mini&lt;/td&gt;
&lt;td&gt;0.949&lt;/td&gt;
&lt;td&gt;14.2s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Qwen3 Coder 480B&lt;/td&gt;
&lt;td&gt;0.949&lt;/td&gt;
&lt;td&gt;3m 29s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Findings
&lt;/h2&gt;

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

&lt;p&gt;I had no baseline for whether 0.95 was good or bad, so the number alone told me little. With 13 cases, one third-point miss accounts for the whole gap. The failures were more informative than the scores.&lt;/p&gt;

&lt;p&gt;The three &lt;code&gt;0.949&lt;/code&gt; scores have the same arithmetic: twelve full points and one third-point case. They do not mean the same thing in practice.&lt;/p&gt;

&lt;h3&gt;
  
  
  Claude
&lt;/h3&gt;

&lt;p&gt;For a direct &lt;code&gt;import { shell } from "electron"&lt;/code&gt; inside the renderer, Claude returned:&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;"decision"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"BLOCK"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"rule_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"placeholder"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"evidence"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"placeholder"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The verdict was right, but the response was unusable for automated enforcement. I cannot tell from this run whether the placeholders came from the model or its structured-output path. Either way, an agent pipeline needs schema validation and a retry or fallback path.&lt;/p&gt;

&lt;h3&gt;
  
  
  GPT-5.4 mini
&lt;/h3&gt;

&lt;p&gt;The safe version resolves the destination and verifies a separator-bounded prefix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;outputDir&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;destination&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;requestedName&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="nx"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;}${&lt;/span&gt;&lt;span class="nx"&gt;sep&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="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Invalid export path&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;writeFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;GPT-5.4 mini blocked it anyway, arguing that the guard was unsafe. The benchmark expects approval: the guard also rejects the directory itself, which is conservative but not an escape route. This is a real review-agent failure mode: treating a stricter policy as a vulnerability.&lt;/p&gt;

&lt;h3&gt;
  
  
  Qwen
&lt;/h3&gt;

&lt;p&gt;Qwen blocked a renderer function that takes a &lt;code&gt;DesktopBridge&lt;/code&gt; and calls &lt;code&gt;bridge.openFile(path)&lt;/code&gt;. Its explanation said the bridge ultimately uses Electron APIs.&lt;/p&gt;

&lt;p&gt;The bridge may eventually call Electron APIs, but the renderer does not receive Electron itself. Judging the rule from the call graph rather than the declared import boundary quietly changes its meaning.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the perfect score does not mean
&lt;/h2&gt;

&lt;p&gt;Gemini's 1.000 is a result on 13 hand-written examples. It does not establish that Gemini is the best code reviewer, will enforce arbitrary policy, or is safe to run without tests and human review.&lt;/p&gt;

&lt;p&gt;The task has obvious limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;one repository style and six named invariants;&lt;/li&gt;
&lt;li&gt;synthetic diffs rather than a history of production pull requests;&lt;/li&gt;
&lt;li&gt;no multi-file reasoning, tool use or test execution;&lt;/li&gt;
&lt;li&gt;one run per model, so no variance estimate;&lt;/li&gt;
&lt;li&gt;no analysis of cost or token usage.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a seed benchmark. Every failure can be inspected and reproduced.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would measure next
&lt;/h2&gt;

&lt;p&gt;The next version needs held-out fixtures and harder near-misses: indirect imports, unrelated noisy edits, an atomic write with bad cleanup, and path guards that look safe but accept sibling prefixes. I would also run repeated trials and report schema compliance separately from architecture reasoning.&lt;/p&gt;

&lt;p&gt;I would not reduce an AI review to one confidence score. In a real merge gate, I want separate signals for the policy verdict, the structured response, the cited evidence and the deterministic check.&lt;/p&gt;

&lt;p&gt;If the response is malformed, its policy decision should not be accepted. When a rule has a deterministic check, that check wins. The model reviews; deterministic logic makes the final decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Benchmark
&lt;/h2&gt;

&lt;p&gt;The public leaderboard is &lt;a href="https://www.kaggle.com/benchmarks/pavelkazantsev7776/architecture-aware-typescript-code-review/versions/1" rel="noopener noreferrer"&gt;Architecture-Aware TypeScript Code Review on Kaggle&lt;/a&gt;. The underlying &lt;a href="https://www.kaggle.com/benchmarks/tasks/pavelkazantsev7776/safe-typescript-change-review-benchmark/1" rel="noopener noreferrer"&gt;Safe TypeScript Change Review task&lt;/a&gt; and the &lt;a href="https://github.com/icesurf666/progress-cut/tree/main/experiments/kaggle-safe-typescript-patches" rel="noopener noreferrer"&gt;task source and report generator&lt;/a&gt; are public too.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>kagglechallenge</category>
      <category>ai</category>
      <category>machinelearning</category>
    </item>
  </channel>
</rss>
