Skip to content

check-file-sizes.py counts prose, so the cheapest way to pass it is to delete documentation #3671

Closed

Description

@jwbron

What

scripts/check-file-sizes.py counts raw lines and raw bytes. The cheapest way for an agent to
bring a file under the hard cap is therefore to delete prose, which is the opposite of what the cap
is for.

Evidence this is not hypothetical

During #3665, an independent implementation hit the 1500-line cap on
orchestrator/health_monitor.py and resolved it with commit 68b185ca, "Fix checks: trim
health_monitor.py docstring under file-size hard cap"
.

That satisfies the number while making a ~1400-line supervision module harder to work with. It is
the textbook shape: state an objective as a threshold on a measured quantity, and the measured
quantity is what moves. The agent was not doing anything irrational; deleting a docstring is
genuinely the lowest-effort way to satisfy the check as written.

Note the repo's own guidance points the other way. orchestrator/CLAUDE.md documents an elaborate
decomposition pattern and every landed split carries a detailed seam entry, so this codebase
deliberately invests in prose, and the cap currently taxes exactly that investment.

Proposal

Count code lines: exclude module / class / function docstrings, comment-only lines, and blank
lines. The cap exists to bound how much logic lives in one module; prose density is not what
makes a file hard to change.

Effects:

  • Removes the prose-trim vector structurally, rather than asking agents not to take it.
  • Stops penalising the well-documented modules this repo deliberately writes.
  • Makes the metric mean what its error message already claims it means ("decompose the file").

Implementation notes:

  • AST-based counting is straightforward for docstrings (ast.get_docstring on Module / ClassDef /
    FunctionDef / AsyncFunctionDef); comment-only and blank lines fall out of tokenize.
  • The caps will need re-baselining against code-line counts, and the entries in
    scripts/file-size-allowlist.yaml re-checked, since some may drop under the cap once prose is
    excluded and others may not.
  • The byte cap has the same gaming property and should get the same treatment or be dropped in
    favour of the line cap alone.

Worth deciding at the same time: whether the soft cap (800) is still the right number once prose is
excluded, since it will effectively tighten.

Activity

  1. added
    p2
    on Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions