Skip to content

plan 51: add MDS036 section-size-limits rule - #143

Merged
jeduden merged 4 commits into
mainfrom
claude/plan-51-section-size-limits
Apr 19, 2026
Merged

plan 51: add MDS036 section-size-limits rule#143
jeduden merged 4 commits into
mainfrom
claude/plan-51-section-size-limits

Conversation

@jeduden

@jeduden jeduden commented Apr 19, 2026

Copy link
Copy Markdown
Owner

MDS036 caps per-section line counts with lookup order per-heading
(regex), per-level, then default max. A section spans a heading up
to the next heading of any level, so nested subsections are measured
independently of their parent. Disabled by default.

Also primes MDS033's sync.Once warning in the integration fixture
runner so rules alphabetically after MDS033 don't inherit a spurious
"no allowed patterns" diagnostic from cross-test state.

@codecov

codecov Bot commented Apr 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.61%. Comparing base (ccd272a) to head (e802906).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #143      +/-   ##
==========================================
+ Coverage   86.35%   86.61%   +0.26%     
==========================================
  Files          94       95       +1     
  Lines       10149    10350     +201     
==========================================
+ Hits         8764     8965     +201     
  Misses        903      903              
  Partials      482      482              

☔ View full report in Codecov by Sentry.
📢 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.

MDS036 caps per-section line counts with lookup order per-heading
(regex), per-level, then default max. A section spans a heading up
to the next heading of any level, so nested subsections are measured
independently of their parent. Disabled by default.

Also primes MDS033's sync.Once warning in the integration fixture
runner so rules alphabetically after MDS033 don't inherit a spurious
"no allowed patterns" diagnostic from cross-test state.
@jeduden
jeduden force-pushed the claude/plan-51-section-size-limits branch from 32ddc21 to a81e970 Compare April 19, 2026 18:18
Add tests for uncovered branches (EnabledByDefault, int64/float
max, per-level/per-heading validation errors, map[any]any keys
from YAML). Drop the unreachable length<0 clamp and headingLine
fallback so all remaining statements are exercised.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Markdown lint rule (MDS036) to enforce per-section line-count limits, with configuration precedence by heading regex, heading level, then default max, and updates integration test setup to avoid a cross-test MDS033 warning artifact.

Changes:

  • Introduces MDS036 section-size-limits rule implementation + unit tests, rule docs, and fixture samples.
  • Registers the new rule across CLI/config/engine and updates the rules index.
  • Primes MDS033’s one-time “no allowed patterns” warning in the integration fixture runner to prevent order-dependent diagnostics.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
plan/51_section-level-size-limits.md Marks plan 51 complete and records implementation notes for MDS036.
PLAN.md Updates plan 51 status to completed.
internal/rules/sectionsizelimits/rule.go Implements the MDS036 rule logic and settings parsing.
internal/rules/sectionsizelimits/rule_test.go Adds unit coverage for section sizing and settings parsing/validation.
internal/rules/MDS036-section-size-limits/README.md Documents MDS036 behavior and configuration.
internal/rules/MDS036-section-size-limits/good/default.md Adds “good” fixture for default max behavior.
internal/rules/MDS036-section-size-limits/good/per-level.md Adds “good” fixture for per-level override behavior.
internal/rules/MDS036-section-size-limits/bad/default.md Adds “bad” fixture validating default max diagnostic.
internal/rules/MDS036-section-size-limits/bad/per-level.md Adds “bad” fixture validating per-level diagnostic.
internal/rules/index.md Adds MDS036 to the rule catalog index.
internal/integration/rules_test.go Primes MDS033’s sync.Once warning before running fixtures.
internal/engine/categories_test.go Ensures MDS036 is registered for category tests.
internal/config/config_test.go Ensures MDS036 is registered for config tests.
cmd/mdsmith/main.go Registers MDS036 with the CLI build via blank import.

Comment thread internal/rules/sectionsizelimits/rule.go Outdated
Comment thread internal/rules/sectionsizelimits/rule.go Outdated
Return all keys from DefaultSettings so re-applying defaults (as the
fixture runner cleanup does) fully clears PerLevel and PerHeading, not
just Max. Add a defensive headingLine fallback for headings with no
line segments, matching the existing pattern in emptysectionbody.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.

Align with max-file-length naming. "Size" was ambiguous (bytes?
tokens?); "length" mirrors the file-level analog and makes it clear
the limit counts lines. Renames:

- package sectionsizelimits -> maxsectionlength
- rule name section-size-limits -> max-section-length
- fixture dir MDS036-section-size-limits -> MDS036-max-section-length
@jeduden
jeduden requested a review from Copilot April 19, 2026 20:45
@jeduden jeduden added the queue Add to a PR to enqueue it label Apr 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Comment on lines +47 to +59
Per-level and per-heading overrides:

```yaml
rules:
max-section-length:
max: 100
per-level:
1: 200
2: 80
per-heading:
- pattern: "^Changelog$"
max: 500
```

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rule supports per-heading (regex-based) limits, but there are no integration fixture files exercising per-heading settings. Consider adding at least one good/ and one bad/ fixture that uses per-heading to validate YAML/front-matter decoding and end-to-end behavior (similar to the existing default/per-level fixtures).

Copilot uses AI. Check for mistakes.
4. Document configuration and examples.
1. [x] Define section boundary detection rules for heading levels.
2. [x] Add configuration for per-heading or per-pattern limits.
3. [x] Implement rule to count section length by lines or tokens.

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Task 3 still says the rule counts section length by "lines or tokens", but the implementation/config in this PR is line-based only (Max/per-level/per-heading are line counts). Update the task text to match the implemented behavior so the completed plan remains accurate.

Suggested change
3. [x] Implement rule to count section length by lines or tokens.
3. [x] Implement rule to count section length by lines.

Copilot uses AI. Check for mistakes.
@jeduden jeduden added queue:active Applied automatically when a PR is in an active batch and removed queue Add to a PR to enqueue it labels Apr 19, 2026
@jeduden

jeduden commented Apr 19, 2026

Copy link
Copy Markdown
Owner Author

🟢 Merge Queue — picked up

This PR is in the queue and will be batched with other queue-labelled PRs.

Next: No action needed — you'll get another comment when CI starts on the batch. View merge queue run.

@jeduden

jeduden commented Apr 19, 2026

Copy link
Copy Markdown
Owner Author

🔵 Merge Queue — CI running

Merged into batch branch merge-queue/batch-143-1776631862 alongside #147. View CI run.

Next: No action needed — you'll be notified when CI completes.

@jeduden

jeduden commented Apr 19, 2026

Copy link
Copy Markdown
Owner Author

Merge Queue — merged

This PR landed on main via commit fef3ac3. CI run that validated the merge.

Next: Done — nothing more to do here.

@jeduden jeduden removed the queue:active Applied automatically when a PR is in an active batch label Apr 19, 2026
@jeduden
jeduden merged commit 59480fe into main Apr 19, 2026
16 checks passed
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.

3 participants