Skip to content

fix(quality): avoid substring false positives - #45

Merged
rng1995 merged 9 commits into
mainfrom
fix/christopherk/issue-30-keyword-boundaries
Aug 18, 2026
Merged

rng1995 merged 9 commits into
mainfrom
fix/christopherk/issue-30-keyword-boundaries

Conversation

@chrisknvidia

@chrisknvidia chrisknvidia commented Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • replace bare substring checks with boundary-aware matching for quality keywords, reserved names, API documentation, action verbs, and error handling
  • distinguish real XML tags, active MCP usage, actionable README references, actual year references, exclusivity claims, and local nested Markdown links from incidental text
  • keep schema and quality validation consistent and add the complete regression matrix for positive, negative, malformed, hidden, and contextual cases

Documentation parity

  • Updated the Fern Tier 1 quality guide with the new boundary-aware and context-aware semantics.
  • Documented which constructs intentionally affect scoring and which incidental text, examples, comments, external URLs, or unrelated troubleshooting text do not.
  • Added author guidance to fix the reported evidence instead of keyword-stuffing a skill.

Before / after

Input pattern Before After
Reserved word inside a larger token Could change the score by substring Matches only the complete reserved-name segment
XML-looking prose Could be mistaken for markup Only actual XML/HTML-like tags trigger the check
Negated MCP reference Could activate MCP requirements Active, non-negated MCP usage is required
README/external/nested links Link context could be conflated Actionable README and local nested Markdown links are distinguished
Incidental years/action verbs/exclusivity words Could satisfy heuristics inside unrelated text Requires the relevant temporal or instructional context

Validation

  • 142 passed for quality and schema validators on Python 3.12
  • 142 passed for quality and schema validators on Python 3.13
  • 716 passed across all validator tests
  • 3142 passed, 7 skipped, 4 deselected across the repository; the one additional deselected bridge test cannot bind its fixed test port because a pre-existing local process owns 127.0.0.1:18080
  • Ruff lint and formatting checks pass for every changed Python file
  • wheel and source distribution build, Twine strict validation, OSS-boundary scan, staged-diff secret scan, and minimal-wheel vulnerability audit pass
  • installed-wheel CLI smoke tests verify both a false-positive-heavy skill (100/A) and a negative control across CLI, JSON, Markdown, and HTML reports
  • fern check passes with 0 errors

Closes #30

Comment thread src/skillevaluator/models/skill.py Resolved

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two boundary/context false positives remain in this revision. Both are reproducible through the quality validator and should be covered before approval.

rng1995
rng1995 previously approved these changes Aug 12, 2026

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the final integrated diff at 3a3405e. Both remaining context false positives are fixed in 30c04be with regression coverage; all review threads are resolved. Local verification passed (158 focused validator tests; 3,175 full-suite tests; Ruff; OSS boundary), and all required GitHub Actions checks are green.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved after resolving the current main conflict at ec41fbc. The only conflict was CHANGELOG.md; the resolution preserves both PR #45’s boundary/context quality-scoring release note and main’s Tier 3 isolation release note, while all code changes from both sides remain intact. Final audit: git merge-tree is clean, all six review threads are resolved, the branch is mergeable, focused tests pass (158/158), all validator tests pass (732/732), the full suite passes (3753 passed, 13 skipped, 3 deselected), Ruff/diff/changed-file formatting pass, wheel/sdist build and Twine strict/OSS-boundary checks pass, and every final-SHA CI check is green. The transient Security classifier checkout certificate failure passed on the authorized failed-job rerun.

rng1995
rng1995 previously approved these changes Aug 12, 2026
@rng1995

rng1995 commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

@chrisknvidia - I've already reviewed and approved this PR. Feel free to approve and merge on your end.

@chrisknvidia

Copy link
Copy Markdown
Collaborator Author

@rng1995 : Can you approve again?

@rng1995
rng1995 merged commit aa195ca into main Aug 18, 2026
15 checks passed
@rng1995
rng1995 deleted the fix/christopherk/issue-30-keyword-boundaries branch August 18, 2026 10:38
@rmalani-nv

Copy link
Copy Markdown
Collaborator

@rng1995 So sorry about the delayed review on this PR. I'm fairly concerned about the heavy usage of regex-as-NLP in this PR, which will be very hard to maintain going forward.

I would recommend splitting this PR into two:

  1. Keep the changes that replace naive "foo" in content.lower() with word-boundary matching (_contains_term) and unify on one XML_TAG_RE. These changes address the main issue in quality_score.py keyword checks match bare substrings, so some rules fire on correct content and others cannot fail #30, so are well-motivated and low-risk.
  2. Revert these two pieces:
    a. Regex-as-NLP: This PR is trying to infer author intent (“is MCP negated here?”) from prose. That problem has no finite regex solution — every new phrasing needs another pattern. The 722-line test file enumerating ~60 cases is the tell: behavior is defined by examples, not by a rule, which gives false confidence that edge cases are handled. I would consider routing these semantic heuristics (negation/temporal/exclusivity), I would route to Tier-3 LLM judge instead.
    b. Markdown parsing: This PR reimplements a Markdown parser by hand (_markdown_link_targets, _without_fenced_code, _without_html_comments, _markdown_h2_sections) — ~150 lines handling escaping, nested parens, angle-bracket links, reference/shortcut links. For the structural Markdown work, I would recommend using a real parser (markdown-it-py) to get links/code-fences/comments/headings robustly.

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.

quality_score.py keyword checks match bare substrings, so some rules fire on correct content and others cannot fail

3 participants