Skip to content

feat(report): --json, and make the demo's numbers a test - #53

Merged
murffious merged 1 commit into
mainfrom
feat/report-json
Sep 15, 2026
Merged

murffious merged 1 commit into
mainfrom
feat/report-json

Conversation

@murffious

Copy link
Copy Markdown
Contributor

Closes #43. Addresses the --json half of #52.

rainfall report --json prints the structured report. buildReport() already returned the right shape — it was never exposed, which is what blocked #43.

__tests__/demo-numbers.test.js runs the report against the demo and fails if TOKENS.md or the README quote figures the tool no longer produces — digest, both file counts, both token totals, both multiples, plus a guard on the specific stale values so a partial update can't pass.

Verified by breaking it: changed ~3699 to ~9999, watched the suite fail, restored, watched it pass. A guard nobody has seen fail is not a guard.

Fixed on the way

report took args[0] as its directory, so report --json resolved the root to a folder named --json — every mapped file came back missing, every number came back zero, and it reported savings on nothing at all with no error.

A reporting tool that silently reports zeroes is worse than one that crashes, because the output still looks like an answer.

Still open

Token counts remain bytes ÷ 4, a prose heuristic that runs low for code. The JSON now states tokenEstimator: "bytes/4" so the estimate is legible rather than implied. Real tokenizer vs. documented error bar stays in #52.

81 tests.

🤖 Generated with Claude Code

Closes #43. Addresses the --json half of #52.

`rainfall report --json` prints the structured report. buildReport() already
returned the right shape; it was never exposed, which is what blocked #43 —
comparing committed numbers to live ones meant scraping formatted text.

__tests__/demo-numbers.test.js now runs the report against the demo and fails if
TOKENS.md or the README quote figures the tool no longer produces. It checks the
digest, both file counts, both token totals and both multiples, and separately
guards the specific stale values so a partial update cannot pass.

Verified by breaking it: set ~3699 to ~9999 in TOKENS.md, watched the suite fail,
restored, watched it pass. A guard nobody has seen fail is not a guard.

This closes the gap that let TOKENS.md sit at 19 files / ~4977 tokens / 6.9x
while the truth was 17 / ~3699 / 5.1x — in a file titled "real, reproducible",
in a package whose whole argument is documentation that fails the build when it
stops being true. It took someone asking to notice. Now it does not.

FIXED ON THE WAY

`report` took args[0] as its directory, so `report --json` resolved the root to a
folder named "--json": every mapped file came back missing and every number came
back zero. It reported 5.1x savings on nothing at all, with no error. Flags are
skipped when picking the directory now, and a test asserts the counts are
non-zero when a flag is passed.

Worth noting the shape of that one: a reporting tool that silently reports
zeroes is worse than one that crashes, because the output still looks like an
answer.

STILL OPEN

Token counts remain `bytes ÷ 4` — a prose heuristic that runs low for source
code. The JSON now states `tokenEstimator: "bytes/4"` so the estimate is legible
rather than implied. Choosing a real tokenizer, or documenting the error bar
permanently, stays in #52.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@murffious
murffious merged commit e846981 into main Sep 15, 2026
1 check passed
@murffious
murffious deleted the feat/report-json branch September 15, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Guard TOKENS.md against drift in CI — it went stale and nothing caught it

1 participant