Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
31f8ad4
fix(reporting): give exact LLM setup fixes and count named Tier 1 checks
chrisknvidia Nov 6, 2026
801acea
fix(reporting): stop validate from repeating its header in short term…
chrisknvidia Nov 6, 2026
d24cc56
Merge branch 'main' into fix/christopherk/validate-fix-lines
rng1995 Nov 7, 2026
6a1f186
Merge branch 'main' into fix/christopherk/validate-fix-lines
rng1995 Nov 7, 2026
319647f
fix(reporting): route Tier 1 setup advice and counts by what actually…
chrisknvidia Nov 13, 2026
f55d4bc
Merge main into fix/christopherk/validate-fix-lines
chrisknvidia Nov 13, 2026
845d441
Merge fix/christopherk/validate-fix-lines into fix/christopherk/valid…
chrisknvidia Nov 13, 2026
048d548
test(reporting): draw the live-view tests on a colourless console
chrisknvidia Nov 13, 2026
10ee7f4
fix(reporting): count Tier 1 validators in the summary row, like the …
chrisknvidia Nov 13, 2026
0137bee
Merge fix/christopherk/validate-fix-lines into fix/christopherk/valid…
chrisknvidia Nov 13, 2026
5ee48f8
Merge main into fix/christopherk/validate-fix-lines
chrisknvidia Nov 13, 2026
74bec2b
Merge fix/christopherk/validate-fix-lines into fix/christopherk/valid…
chrisknvidia Nov 13, 2026
616af6a
Merge main into fix/christopherk/validate-fix-lines
chrisknvidia Nov 13, 2026
bff9795
Merge fix/christopherk/validate-fix-lines into fix/christopherk/valid…
chrisknvidia Nov 13, 2026
ae8ed2e
Merge main into fix/christopherk/validate-repeated-header
chrisknvidia Nov 13, 2026
846f198
Merge main into fix/christopherk/validate-repeated-header
chrisknvidia Nov 13, 2026
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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,24 @@ All notable changes to SkillEvaluator are documented in this file.

### Fixed

- `validate` no longer repeats its header box in short terminal windows or
when a log warning prints mid-run. Only the tier that is still running is
redrawn; the header and finished tiers print once, and log records print
through the live view's console. The progress line now prints once, above
the final verdict.

- `validate` Tier 1 output: when only the `--llm` / `--llm-verify` stage
can't run, `what to fix` gives the exact `export` lines for the missing
provider or key instead of a scanner install or `--skip security`, and the
scanners row keeps the scanner version (`SkillSpector 2.12.0, LLM didn't
run`). A missing SkillSpector or a rejected baseline under `--llm` still
gets the scanner fix, and a `SKILLSPECTOR_PROVIDER` adapter set directly
gets advice for its own key instead of the public provider's. The summary
row now also gives the sub-check count (`9/10 checks passed (22
sub-checks)`). It counts validators, as the `Tier 1: 9 of 10 checks passed`
verdict line under it does, so the two agree, including with `--skip` and
`--fail-fast`.

- Configure CLI stdout to replace characters that its encoding cannot
represent, so reports and root help complete on legacy Windows code pages.
JSON dataset previews and validation output preserve Unicode values, using
Expand Down
19 changes: 19 additions & 0 deletions src/skillevaluator/logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,28 @@
_LOG_MARKUP = False


# While a live view owns the terminal, log records print through its console.
# Rich writes every other console past Live's stdout proxy, which leaves stale
# frame lines (a duplicated header) on screen.
_live_console: list[Console] = []


def route_logs_to(target: Console | None) -> None:
"""Print log records through *target* (a live view's console) until called with ``None``."""
_live_console[:] = [target] if target is not None else []


class _LiteralRichHandler(RichHandler):
"""Rich handler that also drops terminal escape sequences from log messages."""

def emit(self, record: logging.LogRecord) -> None:
own = self.console
self.console = _live_console[0] if _live_console else own
try:
super().emit(record)
finally:
self.console = own

def render_message(self, record: logging.LogRecord, message: str) -> ConsoleRenderable:
# Imported here: skillevaluator.utils imports this module.
from skillevaluator.utils.rich_markup import strip_terminal_controls
Expand Down
171 changes: 127 additions & 44 deletions src/skillevaluator/reporting/console_ui.py
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import threading
import time
import unicodedata
from collections import Counter
from dataclasses import dataclass, field
from pathlib import Path
from typing import TYPE_CHECKING, TextIO
Expand All @@ -46,11 +47,13 @@
from rich.text import Text

from skillevaluator.constants import CONTENT_DEDUP_LLM_REFUSED_CHECK
from skillevaluator.logging_config import route_logs_to
from skillevaluator.reporting.base import (
get_skip_reason,
source_validation_errors,
source_validation_preview,
)
from skillevaluator.reporting.presentation import result_execution_status
from skillevaluator.reporting.terminal_styles import (
AMBER,
BRIGHT,
Expand Down Expand Up @@ -571,13 +574,13 @@ def start(self) -> None:
if not self.enabled:
return
if self._live_capable():
self._live = Live(
self,
console=self.console,
refresh_per_second=8,
vertical_overflow="visible",
)
self.console.print(self._header())
self.console.print()
# Only unfinished tiers stay live; finished ones print once above. A live
# region taller than the window can't be erased, so each redraw would repeat it.
self._live = Live(get_renderable=self._live_region, console=self.console, refresh_per_second=8)
self._live.start()
route_logs_to(self.console)
else:
from skillevaluator.tier3.harbor.progress import PlainProgressReporter

Expand Down Expand Up @@ -622,8 +625,8 @@ def tier_done(self, index: int, *, failed: bool = False, rows: list[TierRow] | N
block.duration = time.time() - block.started_at if block.started_at else None
block.rows = rows or []
self._complete_progress(index, "failed" if failed else "complete")
self._refresh()
self._flush_static()
self._refresh()

def tier_skip(self, index: int, reason: str) -> None:
if not self.enabled:
Expand All @@ -634,34 +637,20 @@ def tier_skip(self, index: int, reason: str) -> None:
# Multi-line reasons (setup instructions) continue on unlabeled rows.
lines = reason.split("\n") or [""]
block.rows = [TierRow("skipped" if index == 0 else "", [(line, MUTED)]) for index, line in enumerate(lines)]
self._refresh()
self._flush_static()
self._refresh()

def finish(self, verdict: Verdict, links: list[tuple[str, str]]) -> None:
if not self.enabled:
return
if self.progress_reporter is not None:
self.progress_reporter.close()
self.verdict = verdict
# Keep artifacts out of Live's refresh/stop buffers. After its render
# hook is removed, normal printing can distinguish TTY from capture.
self.links = []
if self._live is not None:
live = self._live
try:
live.update(self)
finally:
try:
live.stop()
finally:
self._live = None
else:
if len(self.blocks) >= 2:
self.console.print(self._gate())
self.console.print()
self.console.print(self._verdict_panel(verdict))
self.console.print()
self.links = links
self.stop()
if len(self.blocks) >= 2:
self.console.print(self._gate())
self.console.print()
self.console.print(self._verdict_panel(verdict))
self.console.print()
for line in self._footer_lines():
self.console.print(line)

Expand All @@ -670,6 +659,7 @@ def stop(self) -> None:
if self.progress_reporter is not None:
self.progress_reporter.close()
if self._live is not None:
route_logs_to(None)
self._live.stop()
self._live = None

Expand Down Expand Up @@ -849,17 +839,22 @@ def _footer_lines(self):

def _refresh(self) -> None:
if self._live is not None:
self._live.update(self)
self._live.refresh()

def _live_region(self) -> Group:
return Group(*(self._block_panel(b) for b in self.blocks[self._static_printed :] if b.status != PENDING))

def _flush_static(self) -> None:
"""Non-tty mode: print blocks once, as they complete."""
if self._live is not None or self._live_capable():
return
"""Print blocks once, in order, as they complete."""
done = []
for block in self.blocks[self._static_printed :]:
if block.status in (PENDING, RUNNING):
break
done.append(block)
# Advance first so the live region drops these blocks as they print above it.
self._static_printed += len(done)
for block in done:
self.console.print(self._block_panel(block))
self._static_printed += 1


def check_ticker_row(lineup: list[str], done: list[str], current: str | None) -> TierRow:
Expand Down Expand Up @@ -909,7 +904,8 @@ def _scanners_row(results: list[ValidationResult]) -> list[TierRow]:
states[scanner] = (version, MUTED)
for scan in r.incomplete_scans:
if (scanner := scan.removesuffix("-llm")) in _SCANNER_NAMES:
states[scanner] = ("didn't run", f"bold {RED}")
version = r.scanners.get(scanner) if scan != scanner else None
states[scanner] = (f"{version}, LLM didn't run" if version else "didn't run", f"bold {RED}")
segments: list[tuple[str, str]] = []
for scanner in [name for name in _SCANNER_NAMES if name in states]:
state, style = states[scanner]
Expand Down Expand Up @@ -1143,7 +1139,6 @@ def summarize_tier1(results: list[ValidationResult], lineup: list[str] | None =
results = [r for r in results if not _is_not_applicable(r)]

user_skipped = [r for r in results if _is_user_skipped(r)]
total = len(results) - len(user_skipped)
failed = [r for r in results if not r.passed and not _is_skipped(r)]
incomplete = [r for r in failed if r.is_incomplete]
broken = [r for r in failed if not r.is_incomplete]
Expand All @@ -1160,13 +1155,22 @@ def summarize_tier1(results: list[ValidationResult], lineup: list[str] | None =
if lineup:
rows.append(final_check_ticker_row(lineup, results))
rows += scanners
checks_segments: list[tuple[str, str]] = [(f"{total - len(failed)}/{total} passed", TEXT)]
if broken:
checks_segments += [(" · ", FAINT), (f"{len(broken)} failed", f"bold {RED}")]
if incomplete:
checks_segments += [(" · ", FAINT), (f"{len(incomplete)} didn't run", f"bold {RED}")]
if user_skipped:
checks_segments += [(" · ", FAINT), (f"{len(user_skipped)} skipped", MUTED)]

# Count validators with the verdict line's own classification (TierPresentation), so the two agree.
outcome = {id(r): result_execution_status(r) for r in results}
count = Counter(outcome.values())
executed = count["pass"] + count["fail"] + count["incomplete"]
checks_segments: list[tuple[str, str]] = [(f"{count['pass']}/{executed} checks passed", TEXT)]
if sub_checks := sum(
r.summary.checks_performed for r in results if outcome[id(r)] in {"pass", "fail", "incomplete"}
):
checks_segments.append((f" ({sub_checks} sub-checks)", MUTED))
if count["fail"]:
checks_segments += [(" · ", FAINT), (f"{count['fail']} failed", f"bold {RED}")]
if count["incomplete"]:
checks_segments += [(" · ", FAINT), (f"{count['incomplete']} didn't run", f"bold {RED}")]
if count["skipped"]:
checks_segments += [(" · ", FAINT), (f"{count['skipped']} skipped", MUTED)]
if warnings:
checks_segments += [(" · ", FAINT), (f"{warnings} warning{'s' if warnings != 1 else ''}", MUTED)]
rows.append(TierRow("summary" if lineup else "checks", checks_segments))
Expand Down Expand Up @@ -1213,8 +1217,10 @@ def summarize_tier1(results: list[ValidationResult], lineup: list[str] | None =
TierRow("quality", [(grade, f"bold {grade_style(grade, status=status)}"), (f" {score:.1f} / 100", TEXT)])
)
items = [_tier1_fix(r) for r in broken]
if incomplete:
items.append(_setup_fix(incomplete))
if setup := [r for r in incomplete if not _only_llm_stages_missing(r)]:
items.append(_setup_fix(setup))
if llm := [r for r in incomplete if _only_llm_stages_missing(r)]:
items.append(_llm_fix(llm))
return not failed, rows + fix_section_rows(items)


Expand Down Expand Up @@ -1259,6 +1265,83 @@ def _setup_fix(results: list[ValidationResult]) -> FixItem:
return FixItem("setup", problem, [*actions, f"or skip it: --skip {skip}"])


def _only_llm_stages_missing(result: ValidationResult) -> bool:
"""True when the check itself ran and only its ``--llm`` / ``--llm-verify`` stage did not.

``skillspector-llm`` is also recorded when SkillSpector is missing or its baseline is
rejected, before any scan runs; only a recorded SkillSpector version shows its static
scan completed.
"""
scans = result.incomplete_scans
if not scans or not all(s.endswith("-llm") or s.startswith("llm-") for s in scans):
return False
return "skillspector-llm" not in scans or "skillspector" in result.scanners


def _llm_fix(results: list[ValidationResult]) -> FixItem:
"""One item for checks whose LLM stage could not run: a missing key or a failed provider call."""
checks = ", ".join(dict.fromkeys(_short_name(r.validator_name) for r in results))
scans = {s for r in results for s in r.incomplete_scans}
flags = " / ".join(
f for f, on in (("--llm", "skillspector-llm" in scans), ("--llm-verify", "llm-verification" in scans)) if on
)
# SkillSpector reads its own provider settings when SKILLSPECTOR_PROVIDER names an adapter, so the
# public provider matters only for the other stages.
direct = _skillspector_adapter_fix() if "skillspector-llm" in scans else None
parts = [direct] if direct else []
if direct is None or "llm-verification" in scans:
reason, fixes = _public_provider_fix()
parts.append((f"--llm-verify: {reason}" if direct else reason, fixes))
reasons = "; ".join(reason for reason, _ in parts)
actions = [action for _, fixes in parts for action in fixes]
return FixItem(
"setup", f"{checks} LLM review didn't run: {reasons}", [*actions, f"or rerun without {flags or '--llm'}"]
)


def _public_provider_fix() -> tuple[str, list[str]]:
"""The problem and actions for the provider behind ``SKILL_EVAL_LLM_*``: a missing key or a failed call."""
from skillevaluator.provider_config import resolve_llm_provider

try:
resolve_llm_provider()
except ValueError as exc:
reason, *setup = str(exc).splitlines() or [""]
reason = reason.rstrip(".")
exports = [line.strip().removeprefix("export ") for line in setup if line.strip().startswith("export ")]
# Some errors name the accepted keys without an export line ("OPENAI_API_KEY or SKILL_EVAL_LLM_API_KEY ...").
keys = list(dict.fromkeys(re.findall(r"\b[A-Z][A-Z0-9_]*_KEY\b", reason)))
if exports:
return reason, [f"export {' '.join(exports)}"]
if keys:
return reason, [f"{'or ' if i else ''}export {key}='your-api-key'" for i, key in enumerate(keys)]
return reason, ["set up an LLM provider and key, then rerun"]
return "the LLM provider call failed", [
"check the key and model with: skillevaluator doctor --tier 2 --verify-models"
]


def _skillspector_adapter_fix() -> tuple[str, list[str]] | None:
"""The problem and actions for a failed SkillSpector LLM stage when ``SKILLSPECTOR_PROVIDER`` names its adapter.

``None`` when it does not: SkillSpector then runs on the provider bridged from ``SKILL_EVAL_LLM_*``.
"""
from skillevaluator.validators.security import _SKILLSPECTOR_EXPLICIT_PROVIDER_ENV

adapter = os.environ.get("SKILLSPECTOR_PROVIDER", "").strip().lower()
if adapter not in _SKILLSPECTOR_EXPLICIT_PROVIDER_ENV:
return None
key = next(
(name for name in sorted(_SKILLSPECTOR_EXPLICIT_PROVIDER_ENV[adapter]) if name.endswith("_API_KEY")), None
)
if key is not None and not os.environ.get(key, "").strip():
return f"{key} is not set for SKILLSPECTOR_PROVIDER={adapter}", [f"export {key}='your-api-key'"]
credentials = key or "your AWS credentials"
return f"SkillSpector's {adapter} provider call failed", [
f"check {credentials} and SKILLSPECTOR_MODEL for SKILLSPECTOR_PROVIDER={adapter}"
]


def _skip_name(validator_name: str) -> str:
"""The ``--skip`` value that leaves out the check producing *validator_name*."""
if validator_name == "Secrets Detection":
Expand Down
Loading
Loading