Skip to content

Plan 61: Required Structure Rule Hardening (WIP) - #145

Merged
jeduden merged 4 commits into
mainfrom
claude/plan-61-required-structure-hardening
Apr 19, 2026
Merged

Plan 61: Required Structure Rule Hardening (WIP)#145
jeduden merged 4 commits into
mainfrom
claude/plan-61-required-structure-hardening

Conversation

@jeduden

@jeduden jeduden commented Apr 19, 2026

Copy link
Copy Markdown
Owner

Tracks work on plan 61 — Required Structure Rule Hardening.

Picked plan 61 because it was the only unblocked plan with no existing branch or PR: 50, 52 are large new features; 87 depends on unimplemented plan 86 (MDS034).

Changes by commit

  1. Plan bookkeeping (d3a8edc): flip status to 🔳 in plan/61_...md and regenerate PLAN.md.
  2. Named diagnostics (7c42b38):
    • Level-mismatch now names the offending heading: heading level mismatch for "Settings": expected h2, got h3.
    • Unexpected-section now names the required heading that was expected next: unexpected section "## Extra" (expected "## Settings").
    • Trailing extras (past the last required heading) keep the original shorter phrasing.
  3. Out-of-order detection (0070c88):
    • Document holding every required heading but in the wrong order previously produced both unexpected section X and missing required section X for the same heading.
    • Now emits a single section X out of order: expected after Y diagnostic; the schema index is claimed so no follow-up "missing" fires. Level mismatches on out-of-order matches are still reported.
    • Text-based matching excludes wildcard (...), ?, and {field}-interpolated schema headings where out-of-order semantics would need fuzzy/context-aware matching.

Inner loop extracted to matchRequired to stay within the gocognit threshold. README diagnostic table updated with the new messages and an out of order row.

Status

  • Mark plan as in-progress (🔳)
  • Expand unit tests with focused false-positive/negative fixtures (level-mismatch naming, extra-section context, trailing extras, out-of-order)
  • Refine matching logic for required headings (out-of-order claim)
  • Improve diagnostic messages (expected vs actual)
  • Update MDS020-required-structure/README.md
  • Broader audit of sync-point edge cases and front-matter/body sync false positives — deferred to a follow-up PR.

Test plan

  • go test ./... — passes (unrelated internal/corpus git-signing failures only in the local sandbox; CI green).
  • go vet ./... — clean.
  • go tool golangci-lint run — 0 issues.
  • go run ./cmd/mdsmith check . — 115 files checked, 0 failures.

@codecov

codecov Bot commented Apr 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.44%. Comparing base (ccd272a) to head (d80f67a).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
internal/rules/requiredstructure/rule.go 96.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #145      +/-   ##
==========================================
+ Coverage   86.35%   86.44%   +0.08%     
==========================================
  Files          94       94              
  Lines       10149    10186      +37     
==========================================
+ Hits         8764     8805      +41     
+ Misses        903      899       -4     
  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.

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

Updates plan tracking to mark Plan 61 (“Required Structure Rule Hardening”) as in-progress and keeps the generated plan index in sync.

Changes:

  • Set status: 🔳 in plan/61_required-structure-hardening.md.
  • Regenerated PLAN.md catalog table so Plan 61 shows as in-progress.

Reviewed changes

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

File Description
plan/61_required-structure-hardening.md Marks Plan 61 as in-progress (🔳) in front matter.
PLAN.md Updates the generated plans table entry for Plan 61 to reflect the new status.

@jeduden
jeduden marked this pull request as ready for review April 19, 2026 20:16
claude added 2 commits April 19, 2026 20:22
…ction

Hardens MDS020 diagnostics so authors can locate and interpret
structure failures without scanning the full document:

- Level mismatch now names the offending heading:
  "heading level mismatch for \"Settings\": expected h2, got h3".
- Unexpected-section diagnostic names the required heading the
  schema expected next:
  "unexpected section \"## Extra\" (expected \"## Settings\")".

README diagnostic table updated to match. Trailing-extra behavior
(past the last required heading) is unchanged and covered by a
new test.
Previously, when the document contained every required heading but
in the wrong order, MDS020 reported each displaced heading as both
"unexpected section" and "missing required section" — two
contradictory diagnostics for one structural problem.

Now the inner match loop checks whether a non-matching doc heading's
text is any later unclaimed required heading; if so, it emits a
single "section X out of order: expected after Y" diagnostic and
marks that schema index as claimed so no "missing required" follows.
Level mismatches on out-of-order matches are still reported.

Text-based matching intentionally excludes wildcard (`...`),
single-`?` and `{field}`-interpolated schema headings, where
out-of-order semantics would require fuzzy or context-aware
matching.

Inner loop extracted to matchRequired to keep cognitive complexity
within the gocognit threshold. README diagnostic table gains the
new row.

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 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread plan/61_required-structure-hardening.md
Integration fixtures pin the exact diagnostic strings and line
numbers for the three new/changed behaviours:

- bad/out-of-order.md — doc lists ## Tasks before ## Goal; schema
  lists ## Goal before ## Tasks; expects a single "section
  \"## Tasks\" out of order: expected after \"## Goal\"".
- bad/wrong-level.md — ### Goal under schema ## Goal; expects
  "heading level mismatch for \"Goal\": expected h2, got h3".
- bad/extra-section.md — ## Extra sits between required ## Goal
  and ## Tasks; expects "unexpected section \"## Extra\"
  (expected \"## Goal\")".
@jeduden jeduden added queue Add to a PR to enqueue it 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-145-1776631701. View CI run.

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

@jeduden jeduden removed the queue:active Applied automatically when a PR is in an active batch label Apr 19, 2026
@jeduden

jeduden commented Apr 19, 2026

Copy link
Copy Markdown
Owner Author

Merge Queue — merged

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

Next: Done — nothing more to do here.

@jeduden
jeduden merged commit f48ec68 into main Apr 19, 2026
12 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