Skip to content

ci: enforce 500-line Python file-length ratchet (#111) - #126

Merged
manish-wekan merged 1 commit into
nitrocloudofficial:developfrom
AadarshM07:issue#111
Nov 9, 2026
Merged

manish-wekan merged 1 commit into
nitrocloudofficial:developfrom
AadarshM07:issue#111

Conversation

@AadarshM07

Copy link
Copy Markdown
Collaborator

Summary

Closes #111

Implements the dependency-free CI file-length policy check and ratchet mechanism recommended in docs/investigations/file-length-limit.md:

  • Enforces a 500 physical-line limit on tracked Python files in nitrostack/, tests/, examples/, and scripts/.
  • Establishes a checked-in baseline (.file_length_baseline.json) for the 14 pre-existing legacy files that exceed 500 lines.
  • Implements a one-way ratchet: existing files cannot grow past their baseline, and --update-baseline lowers the baseline as files shrink or graduates them when they reach ≤ 500 lines.
  • Adds the check to .github/workflows/test.yml across the Python 3.10, 3.11, and 3.12 matrix.
  • Documents the policy, definition, scope, exemptions, and ratchet workflow in CONTRIBUTING.md.

Changes

  • scripts/check_file_lengths.py: Standard-library checker script with ratchet and baseline update logic.
  • .file_length_baseline.json: Baseline manifest containing recorded line counts for the 14 legacy over-limit files.
  • tests/test_file_length_check.py: Focused test suite covering 500-line boundary, new files > 500, baseline growth, ratchet lowering, and baseline graduation.
  • .github/workflows/test.yml: Added step to execute python scripts/check_file_lengths.py before pytest.
  • CONTRIBUTING.md: Developer guide explaining the policy, counting rules, and baseline update commands.

@AadarshM07 AadarshM07 linked an issue Nov 5, 2026 that may be closed by this pull request
@manish-wekan

Copy link
Copy Markdown
Collaborator

Reviewed with develop (12e65b1) merged in: 1350 tests pass, all 14 baseline counts match the real line counts, and CI runs the check on 3.10–3.12. The catch is merge order: with #127 and #128 merged, the check fails on tests/test_cli.py (1605 > 1589), nitrostack/auth/client.py (503) and tests/test_oauth_client.py (677). Suggest merging those two first, then rebasing this and updating the baseline. Non-blocking: a hand-raised baseline value isn't caught (reviewers need to watch for it), and the stale_baseline violation type is declared but never emitted.

~sent from claude-code

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.

Enforce a 500-line Python file-length ratchet in CI

2 participants