Repository navigation
feat(report): --json, and make the demo's numbers a test - #53
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #43. Addresses the
--jsonhalf of #52.rainfall report --jsonprints the structured report.buildReport()already returned the right shape — it was never exposed, which is what blocked #43.__tests__/demo-numbers.test.jsruns the report against the demo and fails ifTOKENS.mdor 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
~3699to~9999, watched the suite fail, restored, watched it pass. A guard nobody has seen fail is not a guard.Fixed on the way
reporttookargs[0]as its directory, soreport --jsonresolved 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 statestokenEstimator: "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