ANTIGRAVITY LABJP
Articles/Agents & Manager
Agents & Manager/2026-07-01Advanced

When the Tech-Debt Score Drops but the Same Files Keep Breaking — Field Notes on Instrumenting Fan-in and Churn

Letting Antigravity's architecture agent score technical debt is not enough — bugs often recur in the same files after refactoring. Here is how we instrumented the fan-in times churn that static complexity misses, and reconciled the score against real incidents.

antigravity435agents129tech-debtcode-analysisrefactoring8dependency-mapping

Premium Article

The score got healthier, but the fires stayed in the same place

On one project I had Antigravity's architecture agent score technical debt, then worked down the list from the top. Average cyclomatic complexity dropped, and the "critical" files in the report steadily thinned out. On paper, the codebase was getting healthier.

Yet the file names lined up in the month-end incident review barely changed. The recurring failures were landing in files with low scores — the supposedly clean ones.

After seeing that gap clearly once, I stopped letting static complexity alone decide the refactoring order. The score is a necessary signal, but on its own it does not tell you where things actually break. Here are the notes on how I measured that blind spot and filled it, with the code I actually used.

Why complexity scores miss the target

Cyclomatic and cognitive complexity capture how hard a file is to read the moment you open it. Deeply nested, branch-heavy functions really are more accident-prone. No argument there.

The problem is that complexity says nothing about how often a file will be touched, or how many modules a change ripples into. A complex function that is rarely edited keeps running quietly in its complexity. Meanwhile a file that looks simple but gets rewritten weekly and is referenced by many modules produces a small tear on every change. That is where the incidents happen.

Real risk correlates far more strongly with the product of change frequency (churn) and inbound references (fan-in) than with complexity itself. Neither of those falls out of static analysis alone. One lives in Git history, the other in the dependency graph. The score we hand the agent needs both baked in from the start.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Why cyclomatic complexity can fall without incidents falling, plus code that redefines hotspots as fan-in multiplied by churn
A reconciliation harness that measures how well the agent's debt ranking actually captures the files that incidents touched
An operational recipe for correcting the agent's refactoring order with incident history instead of trusting the static score
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Agents & Manager2026-07-15
The File Is Right There in ls, and Your Agent Still Can't Open It
The agent says the file does not exist. Your terminal says it does. After three days of blaming cloud sync, the answer turned out to be that one voiced consonant mark was never a single character. Detection script and a three-layer gate included.
Agents & Manager2026-07-08
Measuring the Rework Rate of What You Delegate to Agents: Drawing Delegation Boundaries with Numbers, Not Instinct
How much should you hand to an agent? I drew that line by instinct for a long time. Here is a practical way to compute a per-category rework rate from your git history and redraw the delegation boundary with numbers, with working code.
Agents & Manager2026-07-05
Protecting Your Agent Stack's Known-Good State with a Single Lockfile — Change-Budget Design for an Era of Simultaneously Moving Parts
When the IDE build, CLI, model, and dependencies all move at once, you can no longer tell which one caused a regression. Here is a change-budget design that pins your known-good state to one lockfile, with working code and operational logs.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →