Skip to content

chore(quality): measure file-size budgets in code lines, enforce via make loc-check - #551

Merged
padak merged 2 commits into
mainfrom
chore/file-size-budget-code-lines
Aug 2, 2026
Merged

chore(quality): measure file-size budgets in code lines, enforce via make loc-check#551
padak merged 2 commits into
mainfrom
chore/file-size-budget-code-lines

Conversation

@padak

@padak padak commented Aug 2, 2026

Copy link
Copy Markdown
Member

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.


Open in Devin Review

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 2 potential issues.

Open in Devin Review

Comment thread scripts/check_file_size.py Outdated
Comment thread CONTRIBUTING.md Outdated
…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
padak force-pushed the chore/file-size-budget-code-lines branch from 365b7f6 to dcf613b Compare August 2, 2026 08:53
…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.
@padak
padak merged commit d19e3b3 into main Aug 2, 2026
4 checks passed
@padak
padak deleted the chore/file-size-budget-code-lines branch August 2, 2026 09:15
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