chore(quality): measure file-size budgets in code lines, enforce via make loc-check - #551
Merged
Merged
Conversation
…make loc-check The CONTRIBUTING.md file-size budgets were counted in raw LOC and checked by eye at review time. Raw LOC taxes exactly what this codebase does deliberately well -- long rationale-carrying docstrings that keep it navigable for humans and for the AI agents working in it -- so the metric pushed toward less explanation. The gap is not marginal: version_service.py is 1252 lines but 705 lines of code (36% prose). Budgets are now measured in CODE LINES: docstrings (via AST, so only the bare leading string of a module/class/function) and comments (via tokenize) are free. A string ASSIGNED to a name -- a SQL block, a template, the CHANGELOG tables -- is data, is counted, and cannot hide content behind a triple quote. `make loc-check` enforces it and runs in `make check` and CI. Seven modules already exceeded their hard ceiling even measured this way, so a plain blocking gate would have been red on arrival -- and a gate that is red on arrival gets disabled, not fixed. Instead six files are grandfathered in scripts/file_size_baseline.json at their current size and may only shrink; new oversized modules and growth of existing debt both fail. changelog.py and commands/context.py are exempt outright: both are documentation payloads that happen to live in .py files (context.py is a single 1607-line AGENT_CONTEXT string), and a ceiling on them would only push prose out of the repo. No version bump -- internal tooling only, no CLI behavior change.
padak
force-pushed
the
chore/file-size-budget-code-lines
branch
from
August 2, 2026 08:53
365b7f6 to
dcf613b
Compare
…cited numbers Both from Devin review of #551. The report excluded a file when its BASENAME was in _EXEMPT, while the gate matches the full package-relative path. commands/changelog.py therefore printed as "exempt" although main() measures it -- the report promised a budget the build does not honour. It now calls _is_exempt() like the gate, with a regression test asserting the two agree exactly. The rationale numbers were measured on a pre-rebase tree and cited frozen_dist.py, which lives in a different PR and does not exist here. Replaced with figures from this tree (version_service.py 1252/705, constants.py 574/190) plus a pointer to `make loc-report` so the doc does not go stale again.
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.
The CONTRIBUTING.md file-size budgets were counted in raw LOC and checked by
eye at review time. Raw LOC taxes exactly what this codebase does deliberately
well -- long rationale-carrying docstrings that keep it navigable for humans
and for the AI agents working in it -- so the metric pushed toward less
explanation. The gap is not marginal: version_service.py is 1252 lines but 705
lines of code (36% prose).
Budgets are now measured in CODE LINES: docstrings (via AST, so only the bare
leading string of a module/class/function) and comments (via tokenize) are
free. A string ASSIGNED to a name -- a SQL block, a template, the CHANGELOG
tables -- is data, is counted, and cannot hide content behind a triple quote.
make loc-checkenforces it and runs inmake checkand CI. Seven modulesalready exceeded their hard ceiling even measured this way, so a plain
blocking gate would have been red on arrival -- and a gate that is red on
arrival gets disabled, not fixed. Instead six files are grandfathered in
scripts/file_size_baseline.json at their current size and may only shrink;
new oversized modules and growth of existing debt both fail. changelog.py and
commands/context.py are exempt outright: both are documentation payloads that
happen to live in .py files (context.py is a single 1607-line AGENT_CONTEXT
string), and a ceiling on them would only push prose out of the repo.
No version bump -- internal tooling only, no CLI behavior change.