Skip to content

Add a pre-commit / CI guardrail against runaway file sizes #1213

Open

Description

@nucleusjay

Summary

Repo has multiple .py files over 20k lines or close to it:

  • graphify/extract.py -- 11,657 lines
  • graphify/__main__.py -- ~4,800 lines (204KB)
  • graphify/llm.py -- ~2k lines (85KB)
  • graphify/callflow_html.py -- 81KB
  • graphify/export.py -- 57KB
  • graphify/detect.py -- 56KB
  • graphify/serve.py -- 55KB

Whatever the right answer is for #, the floor should at minimum stop the next file from growing to 11k lines silently.

Proposed fix

A pre-commit hook + matching CI step that fails if any tracked .py exceeds a threshold. Cheapest form:

- repo: local
  hooks:
    - id: max-python-file-size
      name: max python file size
      entry: python tools/check_file_size.py
      language: system
      types: [python]

Threshold suggestion: 2000 lines, with an explicit allowlist for files already over the limit so this doesn't immediately fail. The allowlist becomes the regression baseline -- files on it cannot grow, files off it cannot exceed the threshold.

Why now

The repo already uses pre-commit (.pre-commit-config.yaml exists), so the infrastructure cost is one new hook entry plus a ~20-line script. Effort is minutes; the payoff is bounding the worst case forever.

Surfaced during an external code review pass.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions