Skip to content

Enforce the file-length rule and delete its empty baseline - #4062

Merged
anth-volk merged 2 commits into
masterfrom
file-length-enforce
Oct 27, 2026
Merged

anth-volk merged 2 commits into
masterfrom
file-length-enforce

Conversation

@anth-volk

@anth-volk anth-volk commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #4053

Top pull request of a stack of five, on #4061. Only the bottom pull request of a stack runs full CI; CI complete fails here by design.

Update, 2026-10-27: metric tier

Anthony decided today to register api.quality.file-length in the metric tier instead of mechanical: the rule fails when a file's line count crosses a threshold, which is what docs/engineering/skills/rules-registry.md calls the metric tier. The second commit:

  • sets tier = "metric";
  • gives [rule.proof] the metric fields in place of bad_fixture and good_fixture: below_fixture (good_tree.toml, every file exactly at its limit), above_fixture (bad_tree.toml, every file one line over), threshold = 800 and the same test. threshold holds one number, so it names the 800-line source-file limit; the same fixtures also cover the 1,500-line limit for test code. The fixtures and the proof test are unchanged;
  • regenerates docs/generated/rules.md (the rule moves from the mechanical row to the metric row) and updates the changelog fragment.

Against origin/file-length-cloud-run-deploy-tests, python -m scripts.rules guard passes, so the metric proof fields validate. The file-length guard and test_repository_has_no_violations fail there only because master has the 805-line policyengine_api/services/report_output_service.py, which #4066 splits. With #4066 merged in, every quality guard and all 142 rules-tool tests pass.

What this changes

#4056, #4059 and #4061 split the five files that were over their limit, so rules/baselines/file-length.txt lists nothing. This pull request makes api.quality.file-length enforced without it:

  • rules/registry.toml: status goes from ratcheted to enforced; the [rule.baseline] table (count = 0) and the comment recording the ratcheted start are removed. The rule never had a [rule.downgrade] record: the rules tool requires one only when a rule moves to advisory or doc-only, so there is none to remove. The Alembic revision exception stays.
  • rules/baselines/file-length.txt: deleted.
  • docs/engineering/skills/file-length.md: the baseline section now says the rule is enforced and has no baseline.
  • docs/generated/rules.md and the Rules block in AGENTS.md: regenerated. The rule moves from the ratcheted list to the enforced rules.
  • changelog.d/file-length-enforce.changed.md.

The file-length guard needs no change: with no [rule.baseline] it tolerates no file, so any tracked Python file over its limit fails it. Its tests already cover a registry without a baseline (test_unlisted_oversized_file_fails).

Testing

  • python scripts/run_quality_guards.py: all guards pass, including file-length. With an 801-line module staged temporarily, file-length failed and named it: policyengine_api/file_length_probe.py has 801 lines, over the 800-line limit for source files.
  • python -m scripts.rules guard --base-ref file-length-cloud-run-deploy-tests: pass (moving from ratcheted to enforced needs no downgrade reason); python -m scripts.rules render: no changes after regenerating; python -m unittest discover -s scripts/rules/tests -t .: 142 pass, including the 10 file-length tests.
  • ruff format --check ., ruff check .: pass.
  • uv lock --check: pass.
  • pytest tests/unit/test_ci_complete_gate.py tests/unit/test_locked_test_environments.py tests/unit/test_alembic_skill.py: 28 passed. No Python code changes here; the make test paths passed (3,445) on Split the Cloud Run deployment script tests under the file-length limit #4061.
  • # noqa comments: 94 before and after; type: ignore/pyright: ignore: 9 before and after.

Environment variables

None. No workflow, image or deployment file changed.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.83%. Comparing base (2bce077) to head (4963752).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4062       +/-   ##
===========================================
+ Coverage   50.75%   87.83%   +37.08%     
===========================================
  Files         254      270       +16     
  Lines       14634    16057     +1423     
  Branches     2339     2626      +287     
===========================================
+ Hits         7427    14104     +6677     
+ Misses       6580     1284     -5296     
- Partials      627      669       +42     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anth-volk
anth-volk force-pushed the file-length-enforce branch 2 times, most recently from cf86585 to 49f68b3 Compare October 27, 2026 14:49
@anth-volk
anth-volk force-pushed the file-length-enforce branch 2 times, most recently from c4140ed to debdc13 Compare October 27, 2026 16:31
Base automatically changed from file-length-cloud-run-deploy-tests to master October 27, 2026 16:51
anth-volk and others added 2 commits October 27, 2026 20:51
No Python file is over its api.quality.file-length limit any more, so the
rule moves from ratcheted to enforced, its [rule.baseline] table and the
empty rules/baselines/file-length.txt are removed, and the skills doc says
the rule has no baseline. The rule has no downgrade record to remove: the
rules tool needs one only when a rule is weakened.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rule fails when a file's line count crosses a threshold, which is the
registry's metric tier (rules-registry.md: "A number crosses a threshold"),
not the mechanical tier it was added in. Anthony decided on 2026-10-27 to
move it. Its proof already tests both sides of the limit: a file exactly
at its limit passes and one a line over fails. The proof now names those
fixtures as below_fixture and above_fixture, with threshold = 800, the
source-file limit; the same fixtures also cover the 1,500-line limit for
test code. The fixtures themselves are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk force-pushed the file-length-enforce branch from debdc13 to 4963752 Compare October 27, 2026 16:51
@anth-volk
anth-volk marked this pull request as ready for review October 27, 2026 17:11
@anth-volk
anth-volk requested a review from a team as a code owner October 27, 2026 17:11
@anth-volk
anth-volk merged commit 5fac30a into master Oct 27, 2026
15 checks passed
@anth-volk
anth-volk deleted the file-length-enforce branch October 27, 2026 17:11

This branch was previously deployed

1 inactive deployment
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 the file-length rule and delete its empty baseline

1 participant