ANTIGRAVITY LABJP
Articles/Tips & Best Practices
Tips & Best Practices/2026-07-18Advanced

When the JSDoc an AI Wrote Quietly Stopped Matching the Code: Field Notes on Measuring Documentation Drift

AI-generated JSDoc gets written once, looks authoritative, and is then trusted and left to rot. Field notes on hashing function signatures to detect staleness, tracking a drift rate, and fixing only the blocks that actually diverged.

antigravity436jsdoc2documentation8measurement3typescript27tips37

Premium Article

During a pull request review, I found a function whose @param no longer matched its actual arguments. The parameters had been folded into an options object months earlier, but the JSDoc still described the old flat signature.

What made it worse was that this documentation had been AI-generated, not hand-written. The prose was clean, it even carried an @example, and it read as authoritative. That was exactly why another developer had trusted it, called the function with the old shape, and only discovered the mismatch at runtime.

Hand-written docs rot too. But we read hand-written docs with a healthy skepticism. AI-generated documentation is thorough and well-formatted, so it earns trust it hasn't necessarily kept.

As an indie developer, I write the code, fix the docs, and later trust them enough to call the function — all the same person. Even so, I've trusted an AI-polished @param without thinking and carried an old argument shape forward into the implementation more than once. These are field notes on measuring and closing that gap — the documentation that grows stale while looking confident.

Why I started with measurement, not regeneration

My first instinct when I hit this was to regenerate all JSDoc on a schedule. That does not work.

Regeneration rewrites the prose you already reviewed, every time. A careful caveat a human added, or an @example that was polished after generation, gets washed into different wording on the next pass. The diffs become enormous and reviewers lose the thread of what actually changed. Documentation quality didn't rise — the trustworthiness of the change history fell with it.

What I needed wasn't to rewrite everything. It was to name the specific blocks where the code and the documentation had diverged. And to do that, divergence first has to be observable as a number.

Defining drift: bind a signature hash to each doc block

The classic way documentation goes stale is that a function's external shape — parameter names, types, the exceptions it throws — changes, while that function's doc block is never touched.

So for each public symbol, I store a hash of "the signature as it stood when the documentation was last modified." On the next scan, if the current signature hash disagrees with the stored value and the doc block itself is unchanged, that's drift.

The signature includes only what the documentation describes: parameter names, parameter types, the return type, and the exceptions the body throws. A change to the internal logic alone is not drift. @param and @returns describe the external shape, not the implementation details.

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
A ts-morph script (runs as-is) that hashes function signatures to mechanically detect when documentation has drifted from the code
A single drift-rate number that separates documentation you can trust from documentation that has quietly rotted
An operational gate that fixes only the drifted blocks instead of regenerating whole files, keeping diffs reviewable
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

Tips2026-04-20
When Antigravity-Generated Code Floods You With TypeScript Errors: A Systematic Fix
Antigravity AI generates TypeScript errors at scale when context is missing. Learn the root causes and how to prevent them with custom rules and proper type context sharing.
AI Tools2026-03-26
Antigravity × AI-Powered Documentation — Build an Automated Doc Generation Pipeline from Your Codebase
Learn how to build an automated documentation pipeline using Antigravity's AI agents. From JSDoc/TSDoc parsing to Markdown output and CI/CD integration, this guide covers practical workflows for keeping your docs in sync with code.
Tips2026-06-20
Keeping Scheduled Runs Reproducible: Pinning the Antigravity CLI Version to Tame Behavior Drift
The Go-based Antigravity CLI is now available to everyone, and updates are landing at a quick pace. When a CLI baked into your automation upgrades underneath you, a single morning's job can behave differently. Here is how I keep things reproducible — pinning the binary, recording its identity in each run's log, and rolling upgrades forward one job at a time — drawn from running four sites on an overnight schedule.
📚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 →