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.

antigravity406agents116tech-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-01
It Worked Interactively but Went Silent Overnight — Making an Antigravity Agent Behave the Same in the Desktop and the CLI
An agent that runs perfectly in the Antigravity desktop app but does nothing when you schedule it through the CLI. This walks through absorbing the gap between interactive and unattended runs across four points — approvals, context, secrets, and runtime — with working code and a preflight check, so one definition behaves identically on both.
Agents & Manager2026-06-29
When Parallel Sub-Agents Fight Over One API's Rate Limit: A Shared Token Bucket That Caps the Aggregate
Run Antigravity 2.0 dynamic sub-agents in parallel and each one hits the same external API independently, pushing the aggregate rate over the limit and triggering cascades of 429s. Here is a shared token bucket that caps the aggregate proactively, with working code through a Redis version.
Agents & Manager2026-06-28
It Did Things I Never Asked For — Binding an Agent's Task Scope With a Contract
Ask it to fix a button color and you get a refactor, renames, and a dependency bump too. This is a scope problem, not a permission one. Here is a contract that stops at the scope boundary and asks.
📚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 →