Skip to content

fix(skill-validator): match GitHub anchor algorithm for repeated whitespace - #65

Merged
potiuk merged 1 commit into
apache:mainfrom
andreahlert:fix/validator-em-dash-slugify
May 6, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
andreahlert:fix/validator-em-dash-slugify

Conversation

@andreahlert

Copy link
Copy Markdown
Contributor

Summary

skill-validator's slugify() was using re.sub(r"[\s]+", "-", text), which collapses runs of whitespace into a single dash. GitHub's anchor renderer (and doctoc, which generates our TOCs) replaces each whitespace character one-for-one, so a heading whose text contains an em-dash, like ## Mode B — conversational mentoring, has mode-b--conversational-mentoring as its real anchor (em-dash strips to "", leaving two adjacent spaces, each becoming a dash).

The validator was producing mode-b-conversational-mentoring (single dash) and reporting anchor 'X' not found against the doctoc-generated TOC anchor it had just slugified differently. Running skill-validate locally on main cuts from 191 violations to 153 with this single one-character fix, all of the dropped violations being false positives of this exact shape.

Change

  • tools/skill-validator/src/skill_validator/__init__.py: drop the + quantifier from ANCHOR_SPACE_PATTERN so each whitespace becomes its own dash.
  • tools/skill-validator/tests/test_validator.py: update the existing test_multiple_spaces expectation to match the actual GitHub algorithm (it had been pinning the bug), and add test_em_dash_in_heading for the canonical case.

Why now

This unblocks wiring skill-validator into prek + CI in a follow-up. With the false-positive noise removed, the remaining violations are real (broken links, missing-frontmatter keys, anchor renames the skills did not follow) and worth gating on.

What this does not fix

  • The 13 skills missing license: Apache-2.0 frontmatter (see #pending sibling PR).
  • The 13 broken links to deleted code-review.instructions.md.
  • The 4 unsubstituted <...> placeholders in pr-management-triage/comment-templates.md (need a decision on adopter-config convention vs. literal substitution).
  • Wiring the validator itself into prek + CI.

Each is a separate, scoped follow-up.

…espace

`slugify` was using `re.sub(r"[\s]+", "-", text)` which collapses runs of
whitespace into a single dash. GitHub's anchor renderer (and doctoc)
replace each whitespace character one-for-one, so headings whose text
contains an em-dash (which strips to "" between two surrounding spaces)
yield double-dash anchors. Concretely, "Mode B — conversational
mentoring" must slugify to `mode-b--conversational-mentoring`, matching
the doctoc-generated TOC anchor in `docs/modes.md`.

Validator was therefore producing single-dash slugs and reporting ~38
false-positive "anchor not found" violations against the real repo.

Drop the `+` quantifier so each whitespace becomes its own dash, and
update the existing `test_multiple_spaces` expectation to match the
actual GitHub algorithm. Add `test_em_dash_in_heading` to pin the
canonical case.

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

MOAR Cleanup!

@potiuk
potiuk merged commit b9258c3 into apache:main May 6, 2026
10 checks passed
@andreahlert andreahlert added the mode:platform Substrate / infra — not a mode (sandbox, CI, validators) label May 7, 2026
@andreahlert
andreahlert deleted the fix/validator-em-dash-slugify branch September 11, 2026 13:54
@potiuk potiuk added the substrate:framework-dev Tool substrate: build / validate / eval the framework itself label Sep 25, 2026
@zeroshade zeroshade mentioned this pull request Oct 13, 2026
4 of 5 tasks
@potiuk potiuk added the family:tools tools/* label Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

family:tools tools/* mode:platform Substrate / infra — not a mode (sandbox, CI, validators) substrate:framework-dev Tool substrate: build / validate / eval the framework itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants