Don't instrument a guess
Today started with a vanity feature and ended with real infrastructure. The vanity feature was Rocky's idea, which I almost approved: a little "AI cost" badge on every blog post, showing what the post cost to make. Cute. Very on-brand for a notebook called "real receipts."
I killed it. Not because the badge is bad — because the numbers would have been fake. There was no meter behind them, just a ledger I'd maintain by hand. A receipt you fill out yourself isn't a receipt.
The better version fell out of that rejection: if I want real numbers, the AI has to do a real job first. So the blog got its first real AI feature — "Ask the notebook," a widget that answers reader questions from my published posts, powered by Vercel's AI Gateway. And once the Gateway had a job, the retrieval got serious too: keyword matching upgraded to vector search on Neon Postgres, with a build-time script that re-embeds the posts on every deploy.
WHAT I TRIED
- Spec'ing a per-post "AI cost" badge computed from a hand-maintained token ledger.
- Scrapping it in favor of giving the AI Gateway a real role on the site first, so the numbers would be metered instead of guessed.
- Building "Ask the notebook": grounded Q&A over the published posts, citations on every answer, strict "say when you don't know" rules.
- Moving retrieval from keyword overlap to Neon pgvector, vectors re-syncing from published posts on every deploy.
WHAT WORKED
- The rejection. The badge goes from fake to real the moment there's metered usage behind it — now there is, tagged per request in the Gateway dashboard.
- The grounding contract: excerpts in the prompt, citations on the answer, honest fallback when nothing matches. Tested live with real questions.
- The Neon wiring shape: read-only role and pooled connection for the site's queries, write access only at build time. Boring in the best way.
WHAT FLOPPED
- Codex hit its usage limit mid-build and the work had to wait out the reset window. The 5-hour clock is real.
- The Neon–Vercel "integration" turned out not to be connected to the project at all — the first deploy synced zero vectors and I only caught it in the build logs. Also discovered I have two Neon accounts, which explained the confusion.
- My first instinct (the hand-rolled ledger) would have shipped fake numbers with real confidence. Glad it got killed before it got built.
THE LESSON
Don't instrument a guess. If the number isn't measured, it's decoration — and decoration with a dollar sign is worse than no number at all. Build the thing, give it a real job, then measure it. The badge is still coming. This time it'll be true.