Skip to content

chore: pin the counts quoted in prose to the generated figures - #9

Merged
Magic-Man-us merged 2 commits into
mainfrom
chore/pin-counts
Aug 29, 2026
Merged

chore: pin the counts quoted in prose to the generated figures#9
Magic-Man-us merged 2 commits into
mainfrom
chore/pin-counts

Conversation

@Magic-Man-us

Copy link
Copy Markdown
Owner

Cargo.toml claimed 6,365 public functions across 71 modules. Both halves named the wrong thing: 6,365 is functions plus methods, and 71 is the public top-level count, not the module count. It is 4,124 functions across 295 modules. That string is what crates.io renders, and a published version's description cannot be edited — 0.2.0 is stuck with the wrong one, 0.3.0 won't be.

Why a checker rather than a generator

Two files already derive counts, and CI already keeps both current:

derived by counts
docs/MODULE_MAP.md gen_module_map.py 295 modules, 4,124 fns, 2,241 methods
bindings/python/COVERAGE.md generate.py 4,149 fns / 4,086 bound, 2,277 methods / 2,254 bound

They disagree, correctly — the map counts a macro-generated item once because it appears once in source; the generator counts what it emitted, so unit_ctor! shows up as its thirty constructors. check_counts.py therefore pins each claim to whichever file owns it, instead of forcing one number everywhere.

Prose is checked, not rewritten: the sentence around a figure usually has to change with it, and a machine can't write that sentence.

Also corrected

  • bindings/python/README.md — "296 modules" → 295 (296 is the file count, which includes src/lib.rs).
  • pyproject.toml — "4,000+ validated functions" → the 4,086 the generator actually bound.

Deliberately left alone

README.md:39's "20,200 functions" is llvm-cov's function-coverage denominator, which counts generic instantiations and private functions. Different metric, correctly stated.

Verified

19 claims pass. Three negative controls, each confirmed to fail:

wrong number in prose      -> Cargo.toml:5: says 9,999 but map_functions is 4,124
generated figure changes   -> Cargo.toml:5: says 6,365 but map_functions is 4,200
claim deleted entirely     -> Cargo.toml: no text matching '...' -- the sentence moved

The third matters most: a checker that silently passes when its target disappears is worse than no checker.

Cargo.toml claimed 6,365 public functions across 71 modules. 6,365 is the
sum of the map's functions and methods, and 71 is the public top-level
count, not the module count -- so both halves named the wrong thing. It is
4,124 functions across 295 modules. That string is what crates.io renders
and cannot be edited once a version is published.

check_counts.py reads the two files that already derive counts and are
already kept current by CI -- docs/MODULE_MAP.md and the generator's
COVERAGE.md -- and checks every hand-written figure against whichever of
them owns it. The two disagree by design: the map counts a macro-generated
item once, the generator counts what it emitted.

Also corrects "296 modules" to 295 in the bindings README, and replaces
"4,000+ validated functions" in pyproject.toml with the 4,086 the
generator actually bound.
Copilot AI lite review requested due to automatic review settings August 29, 2026 18:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes correctly align quoted figures with the generated sources and add CI enforcement, with only minor robustness/wording nits noted.

Pull request overview

Adds an automated checker that verifies numeric counts quoted in prose (e.g., Cargo.toml, Python metadata, READMEs) against the two generated “source of truth” documents, and updates the currently incorrect quoted figures so published package descriptions don’t drift.

Changes:

  • Introduces tools/check_counts.py to validate prose-quoted counts against docs/MODULE_MAP.md and bindings/python/COVERAGE.md.
  • Updates package metadata prose to the correct generated figures (Rust crate description and Python package description).
  • Adds the new count-check step to the main CI workflow.
File summaries
File Description
tools/check_counts.py New checker to pin prose-quoted counts to generated figures and fail CI on drift/missing claims.
Cargo.toml Fixes crates.io-rendered description counts to match docs/MODULE_MAP.md.
bindings/python/README.md Corrects the quoted module count in the “What is not bound” prose.
bindings/python/pyproject.toml Pins the Python package description to the bound function count.
.github/workflows/ci.yml Runs the new quoted-count checker in CI.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tools/check_counts.py
Comment on lines +32 to +34
def read(rel: str) -> str:
with open(os.path.join(ROOT, rel), encoding="utf-8") as fh:
return fh.read()
Comment thread .github/workflows/ci.yml
Comment on lines +93 to +97
# The counts quoted in Cargo.toml, pyproject.toml and the READMEs are
# written by hand from the two generated files above. This pins them
# to those files, so a library that grows fails the build instead of
# shipping a stale figure to a registry, where the description of a
# published version cannot be edited.
crates-release.yml was 46 comment lines against 48 of YAML. What is left
is the two things reading the file cannot tell you: the trusted publisher
is keyed to this filename, and the dispatch input exists for tags older
than the file.
@Magic-Man-us
Magic-Man-us merged commit edaa714 into main Aug 29, 2026
7 checks passed
@Magic-Man-us
Magic-Man-us deleted the chore/pin-counts branch August 29, 2026 21:43
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.

2 participants