Repository navigation
fix(quality): keep minimum score failures after policy changes #211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ca18ad6
Keep quality score thresholds after policy changes
YMuskrat 9411e1f
Show independent quality gate failures across reports
YMuskrat 4cb5cef
Merge latest NVIDIA main into quality minimum policy fix
YMuskrat 4d80785
Merge main into fix/quality-minimum-policy
rng1995 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Quality thresholds remain binding when policies reclassify findings.""" | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
| from click.testing import CliRunner | ||
|
|
||
| from skillevaluator.cli import cli | ||
| from skillevaluator.models.result import Finding, Severity, ValidationResult | ||
| from skillevaluator.validators.policy import ValidationPolicy, apply_policy | ||
| from skillevaluator.validators.quality_score import QualityScoreValidator | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def below_threshold_skill(tmp_path: Path) -> Path: | ||
| skill = tmp_path / "minimal-skill" | ||
| skill.mkdir() | ||
| (skill / "SKILL.md").write_text( | ||
| "---\n" | ||
| "name: minimal-skill\n" | ||
| "description: I can handle various things and stuff for your data documents and projects. " | ||
| "This general tool processes files and helps your workflow.\n" | ||
| "---\n" | ||
| "Short content.\n\n" | ||
| "## Instructions\n\n" | ||
| "The paradigm is synergy and awareness.\n", | ||
| encoding="utf-8", | ||
| ) | ||
| return skill | ||
|
|
||
|
|
||
| def test_raising_efficiency_severity_keeps_cli_minimum_score_failure( | ||
| below_threshold_skill: Path, tmp_path: Path | ||
| ) -> None: | ||
| result = QualityScoreValidator(min_score=70).validate(below_threshold_skill) | ||
| assert result.metadata["quality_scores"]["overall_score"] == 67.8 | ||
| assert not result.passed | ||
| policy = tmp_path / "stricter-policy.yaml" | ||
| policy.write_text("severity_overrides:\n QUALITY.quality_efficiency: medium\n", encoding="utf-8") | ||
| args = [ | ||
| "validate", | ||
| str(below_threshold_skill), | ||
| "--tiers", | ||
| "1", | ||
| "--checks", | ||
| "quality", | ||
| "--no-llm", | ||
| "-r", | ||
| "cli", | ||
| "-o", | ||
| str(tmp_path / "reports"), | ||
| ] | ||
|
|
||
| runner = CliRunner() | ||
| default = runner.invoke(cli, args) | ||
| stricter = runner.invoke(cli, [*args, "--policy", str(policy)]) | ||
|
|
||
| assert default.exit_code == 1, default.output | ||
| assert stricter.exit_code == 1, stricter.output | ||
| assert "[PASS] All validations passed" not in stricter.output | ||
| assert "67.8/100 is below the required 70/100" in stricter.output | ||
|
rng1995 marked this conversation as resolved.
Resolved
|
||
|
|
||
|
|
||
| def test_quality_minimum_survives_recalculation(below_threshold_skill: Path) -> None: | ||
| result = QualityScoreValidator(min_score=70).validate(below_threshold_skill) | ||
| errors = list(result.errors) | ||
|
|
||
| result.recalculate_from_findings() | ||
| result.recalculate_from_findings() | ||
|
|
||
| assert not result.passed | ||
| assert result.errors == errors | ||
| assert result.summary.errors == 1 | ||
| assert result.to_dict()["gate_failures"] == result.gate_failures | ||
|
|
||
|
|
||
| def test_lowering_all_quality_severities_does_not_disable_minimum(below_threshold_skill: Path) -> None: | ||
| result = QualityScoreValidator(min_score=70).validate(below_threshold_skill) | ||
|
|
||
| apply_policy([result], ValidationPolicy(severity_overrides={"QUALITY.*": Severity.INFO})) | ||
|
|
||
| assert not result.passed | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("merge_method", ["merge", "merge_with_prefix"]) | ||
| def test_quality_minimum_survives_merged_results(below_threshold_skill: Path, merge_method: str) -> None: | ||
| parent = ValidationResult() | ||
| for min_score in (70, 80): | ||
| child = QualityScoreValidator(min_score=min_score).validate(below_threshold_skill) | ||
| if merge_method == "merge_with_prefix": | ||
| parent.merge_with_prefix(child, "minimal-skill") | ||
| else: | ||
| parent.merge(child) | ||
|
|
||
| apply_policy([parent], ValidationPolicy(severity_overrides={"QUALITY.quality_efficiency": Severity.MEDIUM})) | ||
|
|
||
| assert not parent.passed | ||
| assert len(parent.gate_failures) == 2 | ||
| assert parent.summary.errors == 2 | ||
| assert "required 70/100" in parent.errors[0] | ||
| assert "required 80/100" in parent.errors[1] | ||
|
|
||
|
|
||
| def test_folder_average_does_not_hide_a_skill_below_minimum(below_threshold_skill: Path) -> None: | ||
| good_skill = below_threshold_skill.parent / "good-skill" | ||
| good_skill.mkdir() | ||
| (good_skill / "SKILL.md").write_text( | ||
| "---\n" | ||
| "name: good-skill\n" | ||
| "description: Converts CSV documents to JSON. Use when converting tabular files.\n" | ||
| "version: 1.0.0\n" | ||
| "metadata:\n" | ||
| " author: Test User <test@example.com>\n" | ||
| " tags: [csv, json]\n" | ||
| "---\n" | ||
| "## Purpose\n\nConvert tabular data.\n\n" | ||
| "## Instructions\n\n1. Read the input file.\n2. Write the JSON output.\n\n" | ||
| "## Examples\n\n```text\ninput.csv -> output.json\n```\n\n" | ||
| "## Prerequisites\n\nNone.\n\n" | ||
| "## Limitations\n\nOnly CSV files are supported.\n\n" | ||
| "## Troubleshooting\n\nReport invalid input errors.\n", | ||
| encoding="utf-8", | ||
| ) | ||
| result = QualityScoreValidator(min_score=70).validate(below_threshold_skill.parent) | ||
| assert result.metadata["quality_scores"]["overall_score"] > 70 | ||
|
|
||
| apply_policy([result], ValidationPolicy(severity_overrides={"QUALITY.quality_efficiency": Severity.MEDIUM})) | ||
|
|
||
| assert not result.passed | ||
| assert len(result.gate_failures) == 1 | ||
| assert result.gate_failures[0].startswith("[minimal-skill]") | ||
|
|
||
|
|
||
| def test_minimum_below_score_still_passes_after_policy(below_threshold_skill: Path) -> None: | ||
| result = QualityScoreValidator(min_score=67).validate(below_threshold_skill) | ||
|
|
||
| apply_policy([result], ValidationPolicy(severity_overrides={"QUALITY.quality_efficiency": Severity.MEDIUM})) | ||
|
|
||
| assert result.passed | ||
| assert "gate_failures" not in result.to_dict() | ||
|
|
||
|
|
||
| def test_quality_severity_waiver_still_passes_when_score_is_above_minimum(below_threshold_skill: Path) -> None: | ||
| manifest = below_threshold_skill / "SKILL.md" | ||
| manifest.write_text(manifest.read_text(encoding="utf-8").replace("name: minimal-skill", "name: Bad_Name")) | ||
| result = QualityScoreValidator(min_score=0).validate(below_threshold_skill) | ||
| assert not result.passed | ||
| assert result.metadata["quality_scores"]["overall_score"] > 0 | ||
|
|
||
| apply_policy([result], ValidationPolicy(severity_overrides={"QUALITY.*": Severity.INFO})) | ||
|
|
||
| assert result.passed | ||
| assert result.errors == [] | ||
|
|
||
|
|
||
| def test_policy_can_still_clear_a_severity_based_failure() -> None: | ||
| result = ValidationResult(validator_name="SCHEMA") | ||
| result.add_finding( | ||
| Finding( | ||
| category="SCHEMA", | ||
| severity=Severity.HIGH, | ||
| check_name="author_missing", | ||
| message="Missing author", | ||
| file_path="SKILL.md", | ||
| ) | ||
| ) | ||
|
|
||
| apply_policy([result], ValidationPolicy(severity_overrides={"SCHEMA.author_missing": Severity.INFO})) | ||
|
|
||
| assert result.passed | ||
| assert result.errors == [] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.