Skip to content

MDS037: Skip paragraphs inside generated sections - #166

Merged
jeduden merged 3 commits into
mainfrom
claude/mds037-skip-generated-uwvew
Apr 24, 2026
Merged

MDS037: Skip paragraphs inside generated sections#166
jeduden merged 3 commits into
mainfrom
claude/mds037-skip-generated-uwvew

Conversation

@jeduden

@jeduden jeduden commented Apr 22, 2026

Copy link
Copy Markdown
Owner

Summary

Implement automatic skipping of paragraphs inside <?include?> and <?catalog?> generated sections for the MDS037 duplicated content rule. This prevents false positives when content is included or cataloged from other files.

Key Changes

  • Added generatedRanges() function: Walks the AST to identify byte ranges covering the bodies of <?include?> and <?catalog?> directives by tracking opening and closing processing instruction markers.
  • Added inGeneratedRange() helper: Checks whether a given byte offset falls within any generated section range.
  • Updated extractParagraphs(): Now skips paragraphs whose first line starts within a generated section range. This applies both when checking a file and when indexing corpus files.
  • Added comprehensive test coverage:
    • TestCheck_SkipsIncludeGeneratedSection: Verifies paragraphs in <?include?> bodies are not flagged
    • TestCheck_SkipsCatalogGeneratedSection: Verifies paragraphs in <?catalog?> bodies are not flagged
    • TestCheck_DuplicateOutsideGeneratedSectionStillFires: Ensures real duplicates outside generated sections are still detected
    • TestCheck_CorpusSkipsIncludeGeneratedSection: Ensures corpus files don't index their generated content
    • TestGeneratedRanges_*: Unit tests for the range detection logic
  • Updated documentation: Added "Generated sections" section to README explaining the behavior and rationale.
  • Marked plan item complete: Updated plan/91 status from 🔲 to ✅ with all tasks and acceptance criteria checked.

Implementation Details

  • Generated ranges are computed once per file and cover only the content between opening and closing PI markers (not the markers themselves).
  • Only top-level, well-formed open/close pairs produce ranges; malformed markers are silently skipped since the generated-section rule (MDS031/MDS032) handles those errors.
  • The skip applies during both file checking and corpus indexing to prevent false matches when source files are included in host files.

https://claude.ai/code/session_018GsQpm14NmJL1XfxvLnGY1

Copilot AI review requested due to automatic review settings April 22, 2026 19:03
@codecov

codecov Bot commented Apr 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.04%. Comparing base (d983848) to head (9ee5f6c).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
internal/rules/duplicatedcontent/rule.go 92.85% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #166      +/-   ##
==========================================
+ Coverage   88.03%   88.04%   +0.01%     
==========================================
  Files         110      110              
  Lines       14106    14148      +42     
==========================================
+ Hits        12418    12457      +39     
- Misses       1228     1230       +2     
- Partials      460      461       +1     

☔ 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

Implements skipping of paragraph fingerprinting/checking inside <?include?> and <?catalog?> generated-section bodies for MDS037 (duplicated-content), to prevent false positives caused by included or catalog-rendered content being duplicated across files.

Changes:

  • Added generated-section range detection (generatedRanges) and offset lookup helper (inGeneratedRange) in MDS037.
  • Updated paragraph extraction to skip paragraphs whose first line starts inside a generated-section body (applies to both checked file and corpus indexing).
  • Added tests and updated MDS037 documentation; marked plan item 91 complete.

Reviewed changes

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

Show a summary per file
File Description
plan/91_mds037-skip-generated-sections.md Marks plan as complete and checks off tasks/acceptance criteria.
internal/rules/duplicatedcontent/rule.go Adds generated-section range detection + skips paragraphs inside generated bodies during extraction.
internal/rules/duplicatedcontent/rule_test.go Adds unit tests covering include/catalog skipping, corpus indexing skip, and basic range detection.
internal/rules/MDS037-duplicated-content/README.md Documents the new “Generated sections” behavior and rationale.
PLAN.md Updates plan status catalog entry for item 91 to ✅.

Comment thread internal/rules/duplicatedcontent/rule.go Outdated
Comment thread internal/rules/duplicatedcontent/rule_test.go
claude added 2 commits April 22, 2026 20:44
Walk top-level AST nodes once per file to collect [start, stop) byte
ranges for <?include?> and <?catalog?> directive bodies. extractParagraphs
checks each paragraph's first-line byte offset against those ranges and
skips any that fall inside one. The same extraction runs for corpus files
during index building, so a host file's generated copy is never indexed.

Closes plan 91.

https://claude.ai/code/session_018GsQpm14NmJL1XfxvLnGY1
Track nesting depth per directive so that an inner <?include?> inside
an outer <?include?> body does not prematurely close the outer byte
range. The outer range now correctly spans all content up to the outer
closing marker, keeping paragraphs after the inner pair inside the
generated section.

Adds TestGeneratedRanges_NestedSameNamePair and
TestCheck_SkipsNestedIncludeGeneratedSection as regression tests.

https://claude.ai/code/session_018GsQpm14NmJL1XfxvLnGY1
Copilot AI review requested due to automatic review settings April 22, 2026 20:45
@jeduden
jeduden force-pushed the claude/mds037-skip-generated-uwvew branch from cb825b2 to 8161d44 Compare April 22, 2026 20:45

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 internal/rules/duplicatedcontent/rule_test.go Outdated

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 no new comments.

@jeduden jeduden added queue Add to a PR to enqueue it queue:active Applied automatically when a PR is in an active batch labels Apr 24, 2026
@jeduden

jeduden commented Apr 24, 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 removed the queue Add to a PR to enqueue it label Apr 24, 2026
@jeduden

jeduden commented Apr 24, 2026

Copy link
Copy Markdown
Owner Author

🔵 Merge Queue — CI running

Merged into batch branch merge-queue/batch-166-1777048009. 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 24, 2026
@jeduden
jeduden merged commit 903f6a4 into main Apr 24, 2026
16 checks passed
@jeduden

jeduden commented Apr 24, 2026

Copy link
Copy Markdown
Owner Author

Merge Queue — merged

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

Next: Done — nothing more to do here.

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