Skip to content

Count repository statistics in Flow, published to the README by CI - #200

Merged
godofecht merged 4 commits into
mainfrom
feat/repo-stats
Aug 5, 2026
Merged

godofecht merged 4 commits into
mainfrom
feat/repo-stats

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Summary

The README carried hand-maintained figures that had drifted badly: it claimed ~38,000 lines against an actual 171,889 across 1,868 tracked files. This replaces them with a block regenerated from tracked files by CI, plus shields badges that read the emitted JSON so they refresh without anyone touching markup.

The counter of record is scripts/tools/repo_stats/main.flow. Flow cannot spawn processes yet, so scripts/update_repo_stats.sh runs git and leaves the output for the Flow program to read; everything after that (parsing, counting, JSON and Markdown emission) happens in Flow.

Nothing would otherwise prove the Flow port agrees with scripts/update_repo_stats.py, so the shim diffs the two on every run and fails loudly on divergence rather than publishing wrong numbers.

Defects fixed along the way

  • The counter only compiled under --lenient, which suppressed genuine type errors alongside the spurious pointer-cast ones. Casting between a byte pointer and string is now accepted by the type checker: they share a representation in the C backend, and FFI code needs the conversion.
  • Flow and Python disagreed on rounding and thousands separators, so the two implementations produced different README text.
  • The revision walk called HEAD^, which fails on the shallow clone actions/checkout produces by default. The workflow now uses fetch-depth: 0 and the walk is bounded.
  • The shim's timeout used SIGALRM, which a process blocked in a syscall can ignore indefinitely. It now uses timeout -k with a polling SIGKILL fallback, so a stuck binary cannot hang CI.

Test plan

  • scripts/update_repo_stats.py output verified byte-identical against the previous implementation (JSON and Markdown)
  • scripts/update_repo_stats.py --check passes, confirming deterministic output
  • scripts/tools/repo_stats/main.flow transpiles under the strict type checker and compiles with clang
  • tests/unit/test_pointer_string_casts.py (4 new tests, including the negative case)
  • test_units.py, test_strict_lambda_types.py, test_rt_safety.py — 63 passed
  • CI is the first environment that can actually execute the Flow binary; the cross-check fails the job rather than committing bad numbers if it diverges

Made with Cursor

godofecht and others added 4 commits August 5, 2026 20:04
The README carried hand-maintained figures that had drifted badly: it
claimed ~38,000 lines against an actual 169,242. Replace them with a
block regenerated from tracked files, plus shields badges that read the
emitted JSON so they refresh without touching markup.

The counter of record is scripts/tools/repo_stats/main.flow. Flow cannot
spawn processes yet, so update_repo_stats.sh runs git and leaves the
output for it to read. Nothing would otherwise prove the Flow port agrees
with scripts/update_repo_stats.py, so the shim diffs the two on every run
and fails loudly on divergence rather than publishing wrong numbers.

Casting between a byte pointer and string is now accepted by the type
checker. They share a representation in the C backend, and FFI code needs
the conversion; without it this program only compiled under --lenient,
which suppressed real type errors along with the spurious ones.

Co-authored-by: Cursor <[email protected]>
The Flow counter and the Python reference have to agree byte for byte,
and they once did not: Flow truncated where Python rounds, so a badge
read 72.5k against a README saying 72.6k. Nothing caught it, because
neither implementation had tests over its formatting.

Cover the rounding boundaries, the whole-component matching in `under`
that keeps src/flowers out of src/flow, and the README marker contract
that every refresh depends on.

Co-authored-by: Cursor <[email protected]>
Recount against current main so the PR stays mergeable and the README
numbers match the tree being merged.

Co-authored-by: Cursor <[email protected]>
@godofecht
godofecht merged commit db96cba into main Aug 5, 2026
14 checks passed
@godofecht
godofecht deleted the feat/repo-stats branch August 5, 2026 19:07
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.

1 participant