Repository navigation
feat(tier3): report dataset coverage and label one-case starters #381
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
5 commits
Select commit
Hold shift + click to select a range
d84dbe6
feat(tier3): report dataset coverage and label one-case starters
chrisknvidia 76e0703
Merge origin/main
chrisknvidia 5c65362
Fix Tier 3 dataset coverage findings
chrisknvidia 4d05ad1
Merge remote-tracking branch 'origin/main' into feat/christopherk/dat…
chrisknvidia 53d3ea8
Merge remote-tracking branch 'origin/main' into feat/christopherk/dat…
chrisknvidia 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
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,100 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Descriptive dataset coverage, independent of validity and run gates.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import shlex | ||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| import yaml | ||
|
|
||
| from skillevaluator.tier3.dataset_utils import find_eval_file, load_dataset_entries | ||
| from skillevaluator.tier3.eval_core.checks import resolve_should_trigger | ||
| from skillevaluator.tier3.eval_core.llm_judge import _has_judge_reference | ||
| from skillevaluator.tier3.evals_config import EvalsConfigError, load_evals_config | ||
|
|
||
|
|
||
| def summarize_dataset(entries: list[dict[str, Any]]) -> dict[str, Any]: | ||
| """Count normalized cases without interpreting any count as sufficiency.""" | ||
| count = len(entries) | ||
| positive = sum(resolve_should_trigger(entry) is True for entry in entries) | ||
| negative = sum(resolve_should_trigger(entry) is False for entry in entries) | ||
| outcomes = sum(_has_judge_reference(entry.get("ground_truth")) for entry in entries) | ||
| behaviors = sum(_has_judge_reference(entry.get("expected_behavior")) for entry in entries) | ||
| gaps = [] | ||
| if not count: | ||
| gaps.append("no evaluation cases") | ||
| if not positive: | ||
| gaps.append("no positive case that should trigger the skill") | ||
| if not negative: | ||
| gaps.append("no negative case that should not trigger the skill") | ||
| unknown = count - positive - negative | ||
| if unknown: | ||
| gaps.append(f"{unknown} cases have no resolved should_trigger label") | ||
| if count - outcomes: | ||
| gaps.append(f"{count - outcomes} cases have no expected output, so accuracy and goal_accuracy are N/A for them") | ||
| if count - behaviors: | ||
| prefix = "no assertions; " if not behaviors else "" | ||
| gaps.append( | ||
| f"{prefix}{count - behaviors} cases have no assertions or expected behaviors, so behavior_check is N/A for them" | ||
| ) | ||
| return { | ||
| "case_count": count, | ||
| "starter": count == 1, | ||
| "positive_cases": positive, | ||
| "negative_cases": negative, | ||
| "unlabeled_trigger_cases": unknown, | ||
| "cases_with_expected_outcome": outcomes, | ||
| "cases_with_expected_behaviors": behaviors, | ||
| "gaps": gaps, | ||
| } | ||
|
|
||
|
|
||
| def coverage_text(coverage: dict[str, Any]) -> str: | ||
| count = coverage["case_count"] | ||
| lines = [ | ||
| f"Dataset coverage: {count} cases; {coverage['positive_cases']} positive, " | ||
| f"{coverage['negative_cases']} negative/non-trigger, " | ||
| f"{coverage['unlabeled_trigger_cases']} unlabeled trigger.", | ||
| f"Expected outcome: {coverage['cases_with_expected_outcome']}/{count}; " | ||
| f"assertions/expected behaviors: {coverage['cases_with_expected_behaviors']}/{count}.", | ||
| ] | ||
| if coverage["starter"]: | ||
| lines.append("One-case starter: a starting point, not a representative evaluation.") | ||
| lines.extend(f"Gap: {gap}." for gap in coverage["gaps"]) | ||
| return "\n".join(lines) | ||
|
|
||
|
|
||
| def dataset_coverage_result(skill_path: Path) -> dict[str, Any] | None: | ||
| """Load authored entries; leave invalid and native sources to their validators.""" | ||
| try: | ||
| config, _ = load_evals_config(skill_path) | ||
| if (config.get("harbor") or {}).get("task_source") == "native_harbor": | ||
| return None | ||
| dataset = find_eval_file(skill_path) | ||
| if dataset is None: | ||
| return None | ||
| coverage = summarize_dataset(load_dataset_entries(dataset)) | ||
| except (EvalsConfigError, ValueError, OSError, yaml.YAMLError): | ||
|
chrisknvidia marked this conversation as resolved.
Resolved
|
||
| return None | ||
| return { | ||
| "path": f"{dataset.relative_to(skill_path)}#coverage", | ||
| "status": "ok", | ||
| "message": coverage_text(coverage), | ||
| "coverage": coverage, | ||
| } | ||
|
|
||
|
|
||
| def starter_guidance(skill_path: Path) -> str | None: | ||
| result = dataset_coverage_result(skill_path) | ||
| if result is None: | ||
| return None | ||
| path = shlex.quote(str(skill_path)) | ||
| return ( | ||
| result["message"] + "\n" | ||
| f"Expand and review with: skillevaluator create-eval-dataset {path} --full\n" | ||
|
chrisknvidia marked this conversation as resolved.
Resolved
|
||
| f"Inspect coverage with: skillevaluator tier3 validate {path}" | ||
| ) | ||
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,135 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
| from click.testing import CliRunner | ||
|
|
||
| from skillevaluator.cli import cli | ||
| from skillevaluator.tier3.dataset_coverage import ( | ||
| coverage_text, | ||
| dataset_coverage_result, | ||
| summarize_dataset, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def skill(tmp_path): | ||
| root = tmp_path / "demo" | ||
| (root / "evals").mkdir(parents=True) | ||
| (root / "SKILL.md").write_text("---\nname: demo\ndescription: Compute values.\n---\n# Demo\n") | ||
| return root | ||
|
|
||
|
|
||
| def write_dataset(skill, cases): | ||
| (skill / "evals/evals.json").write_text(json.dumps({"skill_name": "demo", "evals": cases})) | ||
|
|
||
|
|
||
| def test_summary_counts_and_routing_resolution(): | ||
| result = summarize_dataset( | ||
| [ | ||
| {"expected_skill": "demo", "ground_truth": "answer", "expected_behavior": ["act"]}, | ||
| {"expected_skill": "demo", "should_trigger": False, "ground_truth": 0, "expected_behavior": [""]}, | ||
| {"expected_skill": "", "ground_truth": False}, | ||
| {}, | ||
| ] | ||
| ) | ||
| assert result["case_count"] == 4 | ||
| assert result["positive_cases"] == 1 | ||
| assert result["negative_cases"] == 2 | ||
| assert result["unlabeled_trigger_cases"] == 1 | ||
| assert result["cases_with_expected_outcome"] == 3 | ||
| assert result["cases_with_expected_behaviors"] == 1 | ||
| assert "1 cases have no resolved should_trigger label" in result["gaps"] | ||
| assert any("1 cases have no expected output" in gap for gap in result["gaps"]) | ||
| assert any("3 cases have no assertions" in gap for gap in result["gaps"]) | ||
| assert result["starter"] is False | ||
|
|
||
|
|
||
| def test_starter_and_empty_summary(): | ||
| starter = summarize_dataset([{"expected_skill": "demo", "ground_truth": " ", "expected_behavior": []}]) | ||
| assert starter["starter"] is True | ||
| assert "a starting point, not a representative evaluation" in coverage_text(starter) | ||
| assert "no negative case that should not trigger the skill" in starter["gaps"] | ||
| assert any("no assertions" in gap for gap in starter["gaps"]) | ||
| empty = summarize_dataset([]) | ||
| assert empty["case_count"] == 0 | ||
| assert empty["starter"] is False | ||
| assert "no evaluation cases" in empty["gaps"] | ||
|
|
||
|
|
||
| def test_more_cases_make_no_sufficiency_claim(): | ||
| summary = summarize_dataset( | ||
| [ | ||
| {"should_trigger": value, "ground_truth": "result", "expected_behavior": ["act"]} | ||
| for value in [True, False] * 20 | ||
| ] | ||
| ) | ||
| assert summary["gaps"] == [] | ||
| text = coverage_text(summary) | ||
| assert "40 cases" in text | ||
| assert "representative" not in text | ||
| assert "enough" not in text | ||
|
|
||
|
|
||
| def test_loader_normalizes_author_fields(skill): | ||
| write_dataset(skill, [{"id": "one", "prompt": "Compute.", "expected_output": "0", "assertions": ["Return 0."]}]) | ||
| result = dataset_coverage_result(skill) | ||
| assert result["coverage"]["positive_cases"] == 1 | ||
| assert result["coverage"]["cases_with_expected_outcome"] == 1 | ||
| assert result["coverage"]["cases_with_expected_behaviors"] == 1 | ||
|
|
||
|
|
||
| def test_validate_text_json_and_strict_info(skill): | ||
| write_dataset(skill, [{"id": "one", "prompt": "Compute.", "expected_output": ""}]) | ||
| runner = CliRunner() | ||
| text = runner.invoke(cli, ["tier3", "validate", str(skill), "--strict"]) | ||
| assert text.exit_code == 0, text.output | ||
| assert "Dataset coverage: 1 cases" in text.output | ||
| assert "a starting point, not a representative evaluation" in text.output | ||
| assert "no negative case" in text.output | ||
| assert "accuracy and goal_accuracy are N/A" in text.output | ||
| assert "no assertions" in text.output | ||
| result = runner.invoke(cli, ["tier3", "validate", str(skill), "--json", "--strict"]) | ||
| assert result.exit_code == 0, result.output | ||
| payload = json.loads(result.output) | ||
| assert isinstance(payload, list) | ||
| coverage = next(row for row in payload if row["path"] == "evals/evals.json#coverage") | ||
| assert coverage["status"] == "ok" | ||
| assert coverage["coverage"]["starter"] is True | ||
| assert all({"path", "status", "message"} <= row.keys() for row in payload) | ||
| assert not any(row["status"] == "warning" for row in payload) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("content", ["{invalid", '{"evals": []}', '["bad"]']) | ||
| def test_invalid_source_keeps_failure_exit(skill, content): | ||
| (skill / "evals/evals.json").write_text(content) | ||
| result = CliRunner().invoke(cli, ["tier3", "validate", str(skill), "--json"]) | ||
| assert result.exit_code == 1, result.output | ||
| assert any(row["status"] == "error" for row in json.loads(result.output)) | ||
|
|
||
|
|
||
| def test_missing_and_malformed_yaml_have_no_coverage(skill): | ||
| assert dataset_coverage_result(skill) is None | ||
| (skill / "evals/evals.yaml").write_text("cases: [") | ||
| assert dataset_coverage_result(skill) is None | ||
|
|
||
|
|
||
| def test_native_source_skips_even_if_dataset_present(skill): | ||
| write_dataset(skill, [{"id": "one", "prompt": "Compute."}]) | ||
| (skill / "evals/config.yml").write_text("harbor:\n task_source: native_harbor\n") | ||
| assert dataset_coverage_result(skill) is None | ||
| result = CliRunner().invoke(cli, ["tier3", "validate", str(skill), "--json"]) | ||
| assert not any("#coverage" in row["path"] for row in json.loads(result.output)) | ||
|
|
||
|
|
||
| def test_reference_starter_and_calculator(): | ||
| references = Path(__file__).parents[2] / "src/skillevaluator/tier3/reference_skills" | ||
| assert dataset_coverage_result(references / "text-analyzer")["coverage"]["starter"] is True | ||
| calculator = dataset_coverage_result(references / "calculator")["coverage"] | ||
| assert calculator["case_count"] == 2 | ||
| assert calculator["starter"] is False |
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
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.