Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ All notable changes to SkillEvaluator are documented in this file.

### Added

- Tier 3 generation provenance distinguishes LLM, requested-template, and
template-fallback datasets, marks trace refinement and autopilot generation,
and displays the source and review state in terminal, HTML, and BENCHMARK
reports. Run payloads retain the generation record with shortened input hashes.

- `create-eval-dataset --grounding` selects skill, author-intent, or trace
grounding. Generated datasets record relative input provenance and review
flags for observed answers that differ from authored expectations and
authored behavior steps omitted by refinement output.

- `tier3 validate` reports informational dataset coverage counts and concrete
gaps in text and JSON. Generated one-case starters now explain their limits
and point authors to full dataset generation and coverage validation.
Expand Down
9 changes: 5 additions & 4 deletions docs/cli-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ skillevaluator create-eval-dataset ./my-skill --full
```

<Warning>
`--force` overwrites an existing `evals/evals.json`, including any hand-edited cases, and `--refine` implies `--force`. Use `--dry-run` first if you are unsure.
`--force` overwrites an existing `evals/evals.json`, including any hand-edited cases. `--refine` normally regenerates the dataset, but `--grounding trace` refines an existing file in place and preserves its authored cases. Use `--dry-run` first if you are unsure.
</Warning>

| Flag | Default | Effect |
Expand All @@ -539,9 +539,10 @@ skillevaluator create-eval-dataset ./my-skill --full
| `--dry-run` | off | Preview without writing. |
| `--force` | off | Overwrite existing `evals/evals.json`. |
| `--prompt PATH` | none | Developer eval-guidance file for generation (default: auto-detects `evals/EVAL.md`). |
| `--refine` | off | Refine cases using existing or collected trajectories. Reading trajectories from existing results does not require the `tier3` extra; when none exist, collecting one runs `claude-code` through Harbor and needs the `tier3` extra, Docker, and a configured provider (see [Eval Datasets](eval-datasets.mdx)). |
| `--from-results PATH` | none | With `--refine`: results path containing agent trajectories (default: latest results). |
| `--results-dir DIRECTORY` | unset | With `--refine`: external results root to search for trajectories. |
| `--grounding {skill,intent,trace}` | `skill` | Choose `SKILL.md`, author guidance (`evals/EVAL.md` or `--prompt`), or agent trajectories as the primary grounding source. |
| `--refine` | off | Refine generated cases with trajectories on top of the selected grounding source. Without `--grounding trace`, it regenerates the dataset; with trace grounding and an existing dataset, it refines those cases in place. If no trajectory exists, collection runs `claude-code` through Harbor and needs the `tier3` extra, Docker, and a configured provider (see [Eval Datasets](eval-datasets.mdx)). |
| `--from-results PATH` | none | With `--grounding trace` or `--refine`: results path containing agent trajectories (default: latest results). |
| `--results-dir DIRECTORY` | unset | With `--grounding trace` or `--refine`: external results root to search for trajectories. |

## init-custom-grader

Expand Down
32 changes: 30 additions & 2 deletions docs/eval-datasets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,38 @@ requirements for the live evaluation. Use `validate PATH --no-autopilot` to
require an existing source instead of generating one.

<Warning>
`--force` overwrites `evals/evals.json` without a backup. `--refine` implies
overwrite too — it produces the final version of the dataset.
`--force` overwrites `evals/evals.json` without a backup. Plain `--refine`
regenerates the dataset. With `--grounding trace`, an existing
`evals/evals.json` is refined in place without `--force`, preserving its
authored cases.
</Warning>

### Choose a grounding source

`create-eval-dataset --grounding skill|intent|trace` selects the primary
source used to generate and refine cases. The default, `skill`, preserves the
existing behavior and grounds cases in `SKILL.md`. `intent` requires author
guidance in `evals/EVAL.md` or a file passed with `--prompt`; that guidance is
the primary source, with `SKILL.md` as context. `trace` refines an existing
`evals/evals.json` in place, preserving its authored cases, or generates cases
first when no file exists. It accepts `--from-results` and `--results-dir`.
The existing `--refine` flag remains available to refine generated cases with
trajectories on top of the selected grounding source.

Generated datasets include a `generation` record with the mode, grounding
source, relative input paths and SHA-256 digests, generation time, and review
state. The mode is `llm`, `template_requested`, or `template_fallback`. After
reviewing the generated cases, authors can set
`generation.review_state: reviewed`.
Fallback records include a safe reason. Trace-refined datasets keep their
selected grounding and set `refined: true`. Autopilot records `llm` or
`template_fallback` with `skill` grounding. Cases whose authored expectations conflict with an observed answer, or
whose authored behavior steps are dropped by the refinement output, include
`review.status: needs_review` and reasons. The trace itself does not determine
whether every authored step occurred. A proposed ground truth based on an
observed answer is also flagged for review; inspect these cases before relying
on them as authored expectations.

### The four case buckets

`--full` with an LLM provider targets one case per bucket, including a negative
Expand Down
17 changes: 17 additions & 0 deletions docs/reports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,23 @@ report data and do not read the source tree or contact providers while rendering
Full downloads and preview omission counts remain available; with-skill token
charts are labeled separately from the resource table's two-arm comparisons.

### Dataset generation provenance

When a Tier 3 dataset has a generation record, the CLI evaluate summary,
validate's `AGENT_EVAL` section, the HTML overview, and `BENCHMARK.md` show one
dataset line. LLM-generated datasets name their grounding source and review
state. Template-generated datasets show whether templates were requested or
used as a fallback, explain that they are generic starters, and warn readers
to review them before relying on scores. The line adds the number of cases
marked `needs_review`; handwritten datasets and older datasets without
generation metadata have no line. Run reports retain the generation metadata,
with input hashes shortened to their first 12 characters and recorded paths
preserved. The LLM form is `Dataset: generated by <grounding> grounding, review
state <state>`. The template form is
`Dataset: generated from templates (requested|fallback: reason) — cases are
generic starters; review before relying on scores`. Either form appends
`; N cases need review` when applicable.

## File naming

Report filenames follow two patterns, both under the output directory:
Expand Down
14 changes: 12 additions & 2 deletions src/skillevaluator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,14 @@ def eval_source_exists() -> bool:
enabled=not quiet and progress != "off", stream=click.get_text_stream("stderr")
):
try:
service.create_autopilot_dataset(skill_path, use_llm=not no_llm)
if no_llm:
service.create_autopilot_dataset(
skill_path,
use_llm=False,
fallback_reason="public LLM provider is not configured",
)
else:
service.create_autopilot_dataset(skill_path, use_llm=True)
generated = True
except FileExistsError:
echo("Autopilot: an evaluation source appeared concurrently; reusing it unchanged.")
Expand All @@ -1147,7 +1154,7 @@ def eval_source_exists() -> bool:
echo(" Falling back to one deterministic starter case; review evals/ before using it as a benchmark.")
dataset_note = f"deterministic starter — LLM generation failed: {diagnostic} Review evals/."
if not eval_source_exists():
service.create_autopilot_dataset(skill_path, use_llm=False)
service.create_autopilot_dataset(skill_path, use_llm=False, fallback_reason=diagnostic)
generated = True
if not eval_source_exists():
raise click.ClickException("Autopilot dataset generation did not produce an evaluation source.")
Expand Down Expand Up @@ -3431,6 +3438,7 @@ def prepare_local_runtime() -> None:
@click.option("--dry-run", is_flag=True, help="Preview without writing.")
@click.option("--force", is_flag=True, help="Overwrite existing evals/evals.json.")
@click.option("--prompt", type=click.Path(exists=True, path_type=Path), default=None)
@click.option("--grounding", type=click.Choice(["skill", "intent", "trace"]), default="skill")
@click.option("--refine", is_flag=True, help="Refine cases using existing or collected trajectories.")
@click.option("--from-results", type=click.Path(exists=True, path_type=Path), default=None)
@click.option("--results-dir", type=click.Path(file_okay=False, dir_okay=True, path_type=Path), default=None)
Expand All @@ -3441,6 +3449,7 @@ def create_dataset(
dry_run: bool,
force: bool,
prompt: Path | None,
grounding: str,
refine: bool,
from_results: Path | None,
results_dir: Path | None,
Expand All @@ -3457,6 +3466,7 @@ def create_dataset(
dry_run=dry_run,
force=force,
prompt=prompt,
grounding=grounding,
refine=refine,
from_results=from_results,
results_dir=results_dir,
Expand Down
1 change: 1 addition & 0 deletions src/skillevaluator/evaluation/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class DatasetOptions:
dry_run: bool = False
force: bool = False
prompt: Path | None = None
grounding: str = "skill"
refine: bool = False
from_results: Path | None = None
results_dir: Path | None = None
Expand Down
10 changes: 8 additions & 2 deletions src/skillevaluator/evaluation/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,17 @@ def create_dataset(self, options: DatasetOptions) -> DatasetGenerationResult:

return _create_dataset(options.skill_path, **options.engine_kwargs())

def create_autopilot_dataset(self, skill_path: Path, *, use_llm: bool) -> Path:
def create_autopilot_dataset(
self,
skill_path: Path,
*,
use_llm: bool,
fallback_reason: str | None = None,
) -> Path:
"""Create one missing eval case for the CLI autopilot workflow."""
from skillevaluator.tier3.generate_dataset import generate_one_case

return generate_one_case(skill_path, use_llm=use_llm)
return generate_one_case(skill_path, use_llm=use_llm, fallback_reason=fallback_reason)

def discover_latest_results(self, skill_path: Path, results_dir: Path | None = None) -> Path | None:
"""Return the latest results directory for a skill, or None if absent.
Expand Down
14 changes: 14 additions & 0 deletions src/skillevaluator/evaluation/tier3_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ def agent_eval_result_from_directory(
persisted_dataset_summary=run_truth.get("dataset_summary"),
dataset_digest=run_truth.get("dataset_digest"),
dataset_digest_algorithm=run_truth.get("dataset_digest_algorithm"),
dataset_provenance=run_truth.get("dataset_provenance"),
run_id=run_truth.get("run_id"),
publication_target=publication_target,
publication_target_conflict=run_truth.get("publication_target_conflict"),
Expand Down Expand Up @@ -680,6 +681,7 @@ def build_agent_eval_payload(
persisted_dataset_summary: dict[str, Any] | None = None,
dataset_digest: str | None = None,
dataset_digest_algorithm: str | None = None,
dataset_provenance: dict[str, Any] | None = None,
historical_missing_score_policy: bool = False,
run_id: str | None = None,
publication_target: dict[str, str] | None = None,
Expand Down Expand Up @@ -886,6 +888,9 @@ def build_agent_eval_payload(
evidence_links = [link for link in harbor_summary.get("evidence_links") or [] if link.get("agent") in advice_agents]
best_evidence_links = [link for link in evidence_links if link.get("agent") == best_agent]

from skillevaluator.tier3.dataset_provenance import sanitize_generation_record

safe_dataset_provenance = sanitize_generation_record(dataset_provenance)
summary = {
"schema_version": _SCHEMA_VERSION,
"verdict": verdict,
Expand Down Expand Up @@ -916,6 +921,8 @@ def build_agent_eval_payload(
),
"scored_attempts": sum(_as_nonnegative_int(agent.get("scored_attempts")) for agent in agent_payloads.values()),
}
if safe_dataset_provenance is not None:
summary["dataset_provenance"] = safe_dataset_provenance
if publication_target_conflict in _PUBLICATION_TARGET_CONFLICT_MARKERS:
summary["publication_target_conflict"] = publication_target_conflict
case_selection = _case_selection(run_config)
Expand Down Expand Up @@ -993,6 +1000,7 @@ def build_agent_eval_payload(
"dataset_summary": dataset_summary,
"dataset_digest": effective_dataset_digest,
"dataset_digest_algorithm": effective_dataset_digest_algorithm,
"dataset_provenance": safe_dataset_provenance,
"score_policy": policy["score_policy"],
"run_id": run_id,
"publication_target": dict(publication_target) if isinstance(publication_target, dict) else None,
Expand Down Expand Up @@ -4169,6 +4177,12 @@ def _run_truth_metadata(
truth["dataset"] = [entry for entry in candidate["dataset"] if isinstance(entry, dict)]
if "dataset_summary" not in truth and isinstance(candidate.get("dataset_summary"), dict):
truth["dataset_summary"] = dict(candidate["dataset_summary"])
if "dataset_provenance" not in truth:
from skillevaluator.tier3.dataset_provenance import sanitize_generation_record

provenance = sanitize_generation_record(candidate.get("dataset_provenance"))
if provenance is not None:
truth["dataset_provenance"] = provenance
for field_name in ("evaluator_version", "dataset_digest", "dataset_digest_algorithm"):
value = candidate.get(field_name)
if field_name not in truth and isinstance(value, str) and value.strip():
Expand Down
5 changes: 5 additions & 0 deletions src/skillevaluator/reporting/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
from skillevaluator.reporting.run_status import resolve_run_status
from skillevaluator.reporting.tier3_scope import completed_agent_result, validate_report_scope
from skillevaluator.source_identity import evaluated_source_revision, recorded_evaluated_source
from skillevaluator.tier3.dataset_provenance import dataset_provenance_display
from skillevaluator.tier3_environments import HARBOR_ENV_MODES

if TYPE_CHECKING:
Expand Down Expand Up @@ -379,6 +380,10 @@ def _render_metadata(
else:
lines.append("- Tasks: not recorded (legacy or non-live result)")

dataset_line, _ = dataset_provenance_display(ae.get("dataset_provenance") if ae else None)
if dataset_line:
lines.append(f"- {_publication_safe_inline(dataset_line)}")

dataset_provenance = agent_eval_publication_dataset_provenance(ae)
if dataset_provenance is not None:
digest, digest_algorithm = dataset_provenance
Expand Down
10 changes: 10 additions & 0 deletions src/skillevaluator/reporting/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from rich.console import Console
from rich.panel import Panel
from rich.table import Table
from rich.text import Text

from skillevaluator.constants import (
DIMENSION_VERDICT_NEUTRAL_THRESHOLD,
Expand All @@ -53,6 +54,7 @@
from skillevaluator.reporting.presentation import FinalRenderContext, build_final_render_context, trial_coverage
from skillevaluator.reporting.run_status import Status, result_status
from skillevaluator.reporting.terminal_styles import AMBER, FAINT, GREEN, RED, TEXT, grade_style, lift_style
from skillevaluator.tier3.dataset_provenance import dataset_provenance_display
from skillevaluator.utils.rich_markup import escape_markup

if TYPE_CHECKING:
Expand Down Expand Up @@ -212,6 +214,11 @@ def _render_all_results(self, results: list[ValidationResult], console: Console)
if id(result) not in rendered:
agent_eval = result.metadata.get("agent_eval")
if isinstance(agent_eval, dict):
provenance_line, provenance_is_template = dataset_provenance_display(
agent_eval.get("dataset_provenance")
)
if provenance_line:
console.print(Text(f" {provenance_line}", style="yellow" if provenance_is_template else "dim"))
self._print_harbor_artifacts(agent_eval, console)

color = {Status.PASSED: "green", Status.FAILED: "red"}.get(context.command_status, "yellow")
Expand Down Expand Up @@ -411,6 +418,9 @@ def _print_agent_eval_tables(agent_eval: dict, console: Console) -> None:
f"\n [{vc}]Verdict: {verdict_text}[/{vc}] "
f"(composite lift = [{composite_style}]{composite_text}[/{composite_style}])"
)
provenance_line, provenance_is_template = dataset_provenance_display(agent_eval.get("dataset_provenance"))
if provenance_line:
console.print(Text(f" {provenance_line}", style="yellow" if provenance_is_template else "dim"))
if verdict == "inconclusive":
console.print(
" [yellow]Skill never activated. Scores are diagnostic only; no lift verdict was computed.[/yellow]"
Expand Down
6 changes: 6 additions & 0 deletions src/skillevaluator/reporting/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
from skillevaluator.reporting.trial_charts import steps_by_case_chart
from skillevaluator.skillspector_provenance import skillspector_provenance_records
from skillevaluator.source_identity import recorded_evaluated_source
from skillevaluator.tier3.dataset_provenance import dataset_provenance_display

if TYPE_CHECKING:
from skillevaluator.models import ValidationResult
Expand Down Expand Up @@ -3037,6 +3038,9 @@ def render_all(self, results: list[ValidationResult]) -> str:
tier2_summary = self._compute_tier_summary(tier2_results, presentation=context.tiers[2])
tier3_summary = self._compute_tier_summary(tier3_results, presentation=context.tiers[3])
tier3_preview, tier3_preview_notice = _bounded_tier3_preview(tier3_data)
tier3_dataset_provenance_line, tier3_dataset_provenance_warning = dataset_provenance_display(
tier3_data.get("dataset_provenance") if isinstance(tier3_data, dict) else None
)
tier3_canonical_data, tier3_canonical_encoding = _canonical_tier3_embed(tier3_data)
tier3_truncation = tier3_data.get("report_truncation", {}) if isinstance(tier3_data, dict) else {}

Expand Down Expand Up @@ -3376,6 +3380,8 @@ def _attach_quality_scores(skills: dict[str, dict[str, Any]]) -> None:
content_label_plural=cl + "s",
quality_scores=quality_scores_by_skill,
tier3=tier3_preview,
tier3_dataset_provenance_line=tier3_dataset_provenance_line,
tier3_dataset_provenance_warning=tier3_dataset_provenance_warning,
chart_assets=_load_chart_assets,
tier3_canonical_data=tier3_canonical_data,
tier3_canonical_encoding=tier3_canonical_encoding,
Expand Down
4 changes: 4 additions & 0 deletions src/skillevaluator/reporting/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
safe_url,
)
from skillevaluator.reporting.run_status import Status, resolve_run_status, result_status
from skillevaluator.tier3.dataset_provenance import dataset_provenance_display

if TYPE_CHECKING:
from skillevaluator.models import Finding, ValidationResult
Expand Down Expand Up @@ -355,6 +356,9 @@ def render_all(self, results: list[ValidationResult]) -> str:
lines.append("")
composite_text = _format_report_number(composite, signed=True)
lines.append(f"**Verdict:** {verdict} (composite lift = {composite_text})")
provenance_line, _ = dataset_provenance_display(ae.get("dataset_provenance"))
if provenance_line:
lines.append(_markdown_inline_text(provenance_line))
if verdict == "INCONCLUSIVE":
lines.append("Skill never activated. Scores are diagnostic only; no lift verdict was computed.")
runtime_number = _finite_report_number(runtime)
Expand Down
Loading
Loading