From 71bfdd11433bacbf273f7be18e8aee5a37bcb16b Mon Sep 17 00:00:00 2001 From: Christopher Kevin Date: Sun, 4 Oct 2026 23:08:41 -0700 Subject: [PATCH 01/40] feat(reporting): add quantitative skill performance dashboard Signed-off-by: Christopher Kevin --- CHANGELOG.md | 3 + README.md | 3 +- THIRD_PARTY_NOTICES.md | 1 + docs/cli-reference.mdx | 21 + docs/reports.mdx | 57 ++ pyproject.toml | 4 + src/skillevaluator/cli.py | 17 +- src/skillevaluator/reporting/dashboard.py | 38 ++ src/skillevaluator/reporting/dashboard_app.py | 323 ++++++++++++ .../reporting/dashboard_data.py | 487 ++++++++++++++++++ tests/golden/cli_surface.json | 31 ++ tests/reporting/test_dashboard_app.py | 204 ++++++++ tests/reporting/test_dashboard_cli.py | 52 ++ tests/reporting/test_dashboard_data.py | 334 ++++++++++++ tests/test_oss_packaging.py | 11 +- uv.lock | 271 +++++++++- 16 files changed, 1853 insertions(+), 4 deletions(-) create mode 100644 src/skillevaluator/reporting/dashboard.py create mode 100644 src/skillevaluator/reporting/dashboard_app.py create mode 100644 src/skillevaluator/reporting/dashboard_data.py create mode 100644 tests/reporting/test_dashboard_app.py create mode 100644 tests/reporting/test_dashboard_cli.py create mode 100644 tests/reporting/test_dashboard_data.py diff --git a/CHANGELOG.md b/CHANGELOG.md index e2412f69c..8a786a61a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ All notable changes to SkillEvaluator are documented in this file. ### Added +- Optional `skillevaluator dashboard` tables for comparing saved Tier 3 reports + and retained runs across skills, models, harnesses, and skill conditions, + with paired token, agent runtime, and recorded USD cost differences. - Tier 3 support for Harbor GKE execution mode (`--env-mode gke`) and `--ek` argument forwarding. API keys, bearer tokens, and passwords passed in `--ek` keys or values are rejected to keep credentials out of process listings, while diff --git a/README.md b/README.md index 7d6538831..b8ca1bb74 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,8 @@ SkillEvaluator release or commit. See [CITATION.cff](CITATION.cff). ## Documentation See [the documentation](https://docs.nvidia.com/skills/skillevaluator/) for -setup, tier guides, reports, CI integration, and the CLI reference. +setup, tier guides, reports, CI integration, CLI reference, and +[performance dashboard](docs/reports.mdx#performance-dashboard). ## Installation and third-party software diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index a9953a327..da46792bc 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -10,6 +10,7 @@ records the exact resolved dependency set used for this release. | LLM | Anthropic (MIT), Boto3 (Apache-2.0), LiteLLM (MIT), OpenAI (Apache-2.0) | | Tier 3 | Harbor (Apache-2.0), MCP (MIT), OAuthLib (BSD-3-Clause), PyJWT (MIT), python-dotenv (BSD-3-Clause) | | Security | Bandit (Apache-2.0), pip-audit (Apache-2.0) | +| Dashboard | Streamlit (Apache-2.0) | ## Unicode security data diff --git a/docs/cli-reference.mdx b/docs/cli-reference.mdx index 8355a3ca8..e4d3e25b0 100644 --- a/docs/cli-reference.mdx +++ b/docs/cli-reference.mdx @@ -35,6 +35,7 @@ commands referenced below. | [init-harbor-task](#init-harbor-task) | Scaffold a bring-your-own-task Harbor starter | Nothing | | [view](#view) | Open the latest HTML live-evaluation report | A previous `tier3 evaluate` run | | [compare](#compare) | Compare live-evaluation results across agents | A previous `tier3 evaluate` run | +| [dashboard](#dashboard) | Filter quantitative tables and paired usage differences | Saved JSON reports or retained runs; dashboard extra | | [harbor-view](#harbor-view) | Browse retained Harbor job artifacts | A run made with `--harbor-keep-jobs` | | [doctor](#doctor) | Live-evaluation readiness check | Nothing | | [health-check](#health-check) | Quick CLI + backend readiness check | Nothing | @@ -501,6 +502,26 @@ skillevaluator compare ./my-skill | --- | --- | --- | | `--results-dir DIRECTORY` | unset | Results directory to read from. | +## dashboard + +Open the optional local tables dashboard. Install `skillevaluator[dashboard]` +first, then pass JSON reports, retained run directories, or directories containing +reports. With no paths, upload JSON files in the browser. + +```bash +skillevaluator dashboard reports/run-a.json reports/run-b.json +skillevaluator dashboard --no-browser --port 8502 +``` + +| Option | Default | Description | +| --- | --- | --- | +| `--port` | `8501` | Local server port, from 1 through 65535. | +| `--no-browser` | off | Start the server without opening a browser. | + +The server listens on `127.0.0.1`; Ctrl+C stops it. See the +[dashboard guide](reports.mdx#performance-dashboard) for measurements and +comparison eligibility. + ## harbor-view Open retained Harbor job artifacts with Harbor's trajectory browser. Takes a jobs directory as its argument and has no options. Jobs are only retained when the original run passed `--harbor-keep-jobs`. `skillevaluator tier3 harbor-view` is an identical tier-prefixed spelling. diff --git a/docs/reports.mdx b/docs/reports.mdx index 5d9efccec..4759601b7 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -536,6 +536,63 @@ skillevaluator harbor-view ./my-skill/evals/results/20260709_141530_12345_a1b2c3 (`skillevaluator tier3 harbor-view` is the same command under its expert alias.) +## Performance dashboard + +Install the optional Python dashboard and open saved JSON reports or individual +retained Tier 3 run directories: + +```bash +pip install "skillevaluator[dashboard]" +skillevaluator dashboard reports/run-a.json reports/run-b.json +skillevaluator dashboard ./my-skill/evals/results/ +# Start with an empty dashboard and upload several JSON reports in the browser: +skillevaluator dashboard +``` + +From a checkout, use `uv run --extra dashboard skillevaluator dashboard ...`. +The server runs at `http://127.0.0.1:8501`; use `--port 8502` for another port, +`--no-browser` to suppress opening a browser, and Ctrl+C to stop it. + +Filter the sortable tables by skill, model, harness, recorded harness features, +condition, and execution status. Download the visible performance or comparison +rows as CSV. Each performance row represents one run, harness, and condition. +The comparison table calculates **with skill minus without skill**, and percent +change relative to without skill. A negative usage difference means less usage; +a positive score difference means higher performance. Comparisons stay within +the same run and require successful conditions with matching trial coverage. + +Missing measurements stay unavailable: older JSON reports may contain token +counts without time or cost, and cost is shown only when recorded in USD. +For retained runs, duration measures agent execution rather than the entire +evaluation workflow. Cached tokens are shown separately and are not added again +to prompt plus completion tokens. No pricing estimates or new agent evaluations +are performed. Adverse conditions and harness features are displayed when +explicitly recorded; the dashboard does not run these experiments. + + +### Recorded harness features + +Features are experiment metadata, not inferred from the harness name. In a +canonical Tier 3 JSON payload, an agent or condition can include: + +```json +"dashboard_metadata": { + "harness_features": ["claude-rules:enabled", "memory:disabled"] +} +``` + +For retained runs, the dashboard also reads this metadata from `run_config.json` +(at the root or within the agent configuration) and each condition's +`summary.json`. An empty feature list records that no features were enabled; +an absent field is displayed as **unknown**. Differing recorded models or feature +configurations are kept separate when pairing conditions. + +An explicitly imported adverse condition uses `conditions.adverse`, +`trials_adverse`, `num_trials_adverse`, and `adverse` for its score in the same +agent payload. It appears in the performance table; usage differences are +calculated for with/without pairs only. Existing evaluator runs do not create +adverse trials through the dashboard. + ## Machine-readable contract For CI and tooling, two JSON entry points matter: diff --git a/pyproject.toml b/pyproject.toml index e86519489..0b6e2e050 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -77,6 +77,10 @@ security = [ "bandit>=1.9.4", "pip-audit>=2.10.0", ] +# Optional local UI for comparing saved reports; never imported by base commands. +dashboard = [ + "streamlit>=1.49,<2", +] # Full public install convenience bundle. all = [ "skillevaluator[tier2,tier3,security]", diff --git a/src/skillevaluator/cli.py b/src/skillevaluator/cli.py index e9d901a7d..ecae82626 100644 --- a/src/skillevaluator/cli.py +++ b/src/skillevaluator/cli.py @@ -163,7 +163,7 @@ def _validate_similarity_threshold(_ctx: click.Context, _param: click.Parameter, _TOP_LEVEL_COMMAND_HELP_GROUPS = ( ("Tier workflows", ("tier1", "tier2", "tier3")), - ("Core workflows", ("validate", "health-check", "doctor", "models")), + ("Core workflows", ("validate", "health-check", "doctor", "models", "dashboard")), ( "Tier 1 · Static and security", ("quality-check", "rubric-eval", "security-scan", "pii-scan", "lint-scripts"), @@ -3054,6 +3054,21 @@ def models_command(limit: int, as_json: bool) -> None: raise SystemExit(run_models_command(limit=limit, as_json=as_json)) +@cli.command("dashboard") +@click.argument("paths", nargs=-1, type=click.Path(exists=True, path_type=Path)) +@click.option("--port", type=click.IntRange(1, 65535), default=8501, show_default=True) +@click.option("--no-browser", is_flag=True, help="Start the server without opening a browser.") +def dashboard_command(paths: tuple[Path, ...], port: int, no_browser: bool) -> None: + """Compare saved JSON reports or retained Tier 3 run directories in tables. + + Install skillevaluator[dashboard] first. With no PATHS, upload JSON reports + in the browser. The server listens on 127.0.0.1; Ctrl+C stops it. + """ + from skillevaluator.reporting.dashboard import launch_dashboard + + raise SystemExit(launch_dashboard(paths, port=port, no_browser=no_browser)) + + @cli.command() @click.option( "-a", diff --git a/src/skillevaluator/reporting/dashboard.py b/src/skillevaluator/reporting/dashboard.py new file mode 100644 index 000000000..9fb675a87 --- /dev/null +++ b/src/skillevaluator/reporting/dashboard.py @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Launch the optional dashboard without importing UI dependencies into the CLI.""" + +from __future__ import annotations + +import importlib.util +import subprocess +import sys +from pathlib import Path + +import click + + +def launch_dashboard(paths: tuple[Path, ...], *, port: int = 8501, no_browser: bool = False) -> int: + """Run Streamlit on loopback with explicit paths and usage telemetry disabled.""" + if importlib.util.find_spec("streamlit") is None: + raise click.ClickException('Install the dashboard extra: pip install "skillevaluator[dashboard]"') + app = Path(__file__).with_name("dashboard_app.py") + command = [ + sys.executable, + "-m", + "streamlit", + "run", + str(app), + "--server.address=127.0.0.1", + f"--server.port={port}", + f"--server.headless={str(no_browser).lower()}", + "--browser.gatherUsageStats=false", + "--theme.primaryColor=#76b900", + "--", + *(str(path.resolve()) for path in paths), + ] + try: + return subprocess.call(command) + except KeyboardInterrupt: + return 0 diff --git a/src/skillevaluator/reporting/dashboard_app.py b/src/skillevaluator/reporting/dashboard_app.py new file mode 100644 index 000000000..7459b613c --- /dev/null +++ b/src/skillevaluator/reporting/dashboard_app.py @@ -0,0 +1,323 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Optional local Streamlit dashboard for quantitative Tier 3 reports. + +Run through ``skillevaluator dashboard`` so the dashboard extra is checked before +starting Streamlit. Only normalized quantitative data is displayed or exported. +""" + +from __future__ import annotations + +import csv +import io +import json +import sys +from pathlib import Path +from typing import Any + +import streamlit as st + +from skillevaluator.reporting.dashboard_data import comparison_rows, load_dashboard_path, parse_dashboard_report + +_DIMENSIONS = ("skill", "model", "harness", "features") +_MAX_UPLOAD_BYTES = 16 * 1024 * 1024 +_CONDITION_NAMES = {"with_skill": "With skill", "without_skill": "Without skill", "adverse": "Adverse skill"} +_USAGE_METRICS = ("total_tokens", "prompt_tokens", "completion_tokens", "cached_tokens", "duration_seconds", "cost_usd") +_PERFORMANCE_COLUMNS = ( + "skill", + "model", + "harness", + "condition", + "score", + "total_tokens", + "duration_seconds", + "cost_usd", + "status", + "features", + "pass_rate", + "trials", + "coverage", + "prompt_tokens", + "completion_tokens", + "cached_tokens", + "run_id", + "source", +) +_COMPARISON_COLUMNS = ( + "skill", + "model", + "harness", + "score_delta", + "total_tokens_delta", + "total_tokens_percent", + "duration_seconds_delta", + "duration_seconds_percent", + "cost_usd_delta", + "cost_usd_percent", + "comparison_status", + "features", + "coverage", + "with_score", + "without_score", + "with_pass_rate", + "without_pass_rate", + "pass_rate_delta", + *( + field + for metric in _USAGE_METRICS + for field in (f"with_{metric}", f"without_{metric}", f"{metric}_delta", f"{metric}_percent") + if field + not in { + "total_tokens_delta", + "total_tokens_percent", + "duration_seconds_delta", + "duration_seconds_percent", + "cost_usd_delta", + "cost_usd_percent", + } + ), + "run_id", + "source", +) + + +def rows_csv(rows: list[dict[str, Any]], columns: tuple[str, ...]) -> str: + """Export visible quantitative columns with spreadsheet-safe text cells.""" + buffer = io.StringIO(newline="") + writer = csv.DictWriter(buffer, fieldnames=columns, extrasaction="ignore") + writer.writeheader() + for row in rows: + cells: dict[str, Any] = {} + for column in columns: + value = row.get(column) + if isinstance(value, str) and ( + value.startswith(("\t", "\r", "\n")) or value.lstrip().startswith(("=", "+", "-", "@")) + ): + value = "'" + value + cells[column] = value + writer.writerow(cells) + return buffer.getvalue() + + +def _filter_rows(rows: list[dict[str, Any]], field: str, option_rows: list[dict[str, Any]]) -> list[dict[str, Any]]: + options = sorted({str(row.get(field) or "unknown") for row in option_rows}, key=str.casefold) + selected = st.sidebar.multiselect( + field.capitalize(), + options, + key=f"filter_{field}", + format_func=(lambda value: _CONDITION_NAMES.get(value, value)) if field == "condition" else str, + ) + return [row for row in rows if str(row.get(field) or "unknown") in selected] if selected else rows + + +def _performance_column_config() -> dict[str, Any]: + config: dict[str, Any] = { + "skill": st.column_config.TextColumn("Skill", width="medium"), + "model": st.column_config.TextColumn("Model", width="medium"), + "harness": st.column_config.TextColumn("Harness"), + "features": st.column_config.TextColumn("Features", width="medium"), + "condition": st.column_config.TextColumn("Condition"), + "score": st.column_config.NumberColumn("Score", format="%.3f", width="small"), + "pass_rate": st.column_config.NumberColumn("Pass rate", format="percent", width="small"), + "duration_seconds": st.column_config.NumberColumn("Duration (s)", format="%.2f", width="small"), + "cost_usd": st.column_config.NumberColumn("Cost (USD)", format="$%.4f", width="small"), + "status": st.column_config.TextColumn("Status"), + "trials": st.column_config.NumberColumn("Trials", format="%d"), + "coverage": st.column_config.TextColumn("Measurement coverage", width="large"), + "run_id": st.column_config.TextColumn("Run", width="medium"), + "source": st.column_config.TextColumn("Source", width="large"), + } + for field in ("total_tokens", "prompt_tokens", "completion_tokens", "cached_tokens"): + config[field] = st.column_config.NumberColumn(field.replace("_", " ").capitalize(), format="%d", width="small") + return config + + +def _comparison_column_config(columns: tuple[str, ...]) -> dict[str, Any]: + config: dict[str, Any] = {} + short_labels = { + "score_delta": "Score Δ", + "total_tokens_delta": "Tokens Δ", + "total_tokens_percent": "Tokens Δ (%)", + "duration_seconds_delta": "Time Δ (s)", + "duration_seconds_percent": "Time Δ (%)", + "cost_usd_delta": "Cost Δ (USD)", + "cost_usd_percent": "Cost Δ (%)", + } + for field in columns: + label = short_labels.get(field, field.replace("_", " ").capitalize()) + if field.endswith("_percent"): + config[field] = st.column_config.NumberColumn(label, format="%.1f%%", width="small") + elif "pass_rate" in field: + config[field] = st.column_config.NumberColumn(label, format="percent", width="small") + elif field.endswith("_score") or field == "score_delta": + config[field] = st.column_config.NumberColumn(label, format="%.3f", width="small") + elif "tokens" in field: + config[field] = st.column_config.NumberColumn(label, format="%d", width="small") + elif "duration_seconds" in field: + config[field] = st.column_config.NumberColumn(label, format="%.2f", width="small") + elif "cost_usd" in field: + config[field] = st.column_config.NumberColumn(label, format="$%.4f", width="small") + else: + config[field] = st.column_config.TextColumn(label) + return config + + +def _show_performance(rows: list[dict[str, Any]]) -> None: + if not rows: + st.info("No rows match these filters. Clear a filter to include more results.") + return + visible = [{column: row.get(column) for column in _PERFORMANCE_COLUMNS} for row in rows] + st.dataframe( + visible, + column_order=_PERFORMANCE_COLUMNS, + column_config=_performance_column_config(), + width="stretch", + hide_index=True, + key="performance_table", + ) + st.download_button( + "Download performance CSV", + rows_csv(rows, _PERFORMANCE_COLUMNS), + file_name="skill-performance.csv", + mime="text/csv", + key="download_performance", + ) + + +def _show_comparisons(rows: list[dict[str, Any]]) -> None: + comparisons = comparison_rows(rows) + st.caption("Conditions are paired within each run, skill, model, harness, and feature configuration.") + if not comparisons: + st.info("No comparisons are available. Load reports with with-skill and without-skill conditions.") + return + view = st.selectbox( + "Comparison metrics", + ("Overview", "Quality", "Tokens", "Duration", "Cost", "All metrics"), + key="comparison_metrics", + ) + identity = ("skill", "model", "harness") + details = ("comparison_status", "features", "coverage", "run_id", "source") + metric_sets = { + "Overview": ( + "score_delta", + "total_tokens_delta", + "total_tokens_percent", + "duration_seconds_delta", + "duration_seconds_percent", + "cost_usd_delta", + "cost_usd_percent", + ), + "Quality": ( + "with_score", + "without_score", + "score_delta", + "with_pass_rate", + "without_pass_rate", + "pass_rate_delta", + ), + "Tokens": tuple( + field + for metric in _USAGE_METRICS + if "tokens" in metric + for field in (f"with_{metric}", f"without_{metric}", f"{metric}_delta", f"{metric}_percent") + ), + "Duration": ( + "with_duration_seconds", + "without_duration_seconds", + "duration_seconds_delta", + "duration_seconds_percent", + ), + "Cost": ("with_cost_usd", "without_cost_usd", "cost_usd_delta", "cost_usd_percent"), + } + columns = (*identity, *metric_sets[view], *details) if view in metric_sets else _COMPARISON_COLUMNS + visible = [{column: row.get(column) for column in columns} for row in comparisons] + st.dataframe( + visible, + column_order=columns, + column_config=_comparison_column_config(columns), + width="stretch", + hide_index=True, + key="comparison_table", + ) + st.caption( + "Deltas are with skill minus without skill. Usage percentages use the without-skill value as the baseline. " + "Unavailable or ineligible comparisons stay blank. These are descriptive results, not significance tests." + ) + st.download_button( + "Download comparison CSV", + rows_csv(visible, columns), + file_name="skill-comparison.csv", + mime="text/csv", + key="download_comparisons", + ) + + +def main(paths: list[str] | None = None) -> None: + """Render the app, accepting CLI paths or a supplied path list for embedding.""" + st.set_page_config(page_title="Skill performance · SkillEvaluator", page_icon="▦", layout="wide") + st.title("Skill performance") + st.caption("SKILLEVALUATOR · Compare agent quality, tokens, duration, and cost across evaluation runs.") + st.sidebar.header("Reports") + uploads = st.sidebar.file_uploader( + "Upload JSON reports", + type=["json"], + accept_multiple_files=True, + help="Use Tier 3 JSON reports or consolidated SkillEvaluator JSON reports.", + key="report_uploads", + ) + rows: list[dict[str, Any]] = [] + warnings: list[str] = [] + for path in dict.fromkeys(str(Path(path).expanduser().resolve()) for path in (paths or [])): + data = load_dashboard_path(Path(path)) + rows.extend(data.rows) + warnings.extend(data.warnings) + for index, uploaded in enumerate(uploads): + contents = uploaded.getvalue() + if len(contents) > _MAX_UPLOAD_BYTES: + warnings.append(f"{uploaded.name}: report exceeds 16 MiB. Upload a smaller evaluation report.") + continue + try: + payload = json.loads(contents) + except (ValueError, UnicodeError, RecursionError): + warnings.append(f"{uploaded.name}: invalid JSON. Upload a UTF-8 JSON evaluation report.") + continue + data = parse_dashboard_report(payload, source=f"upload:{index + 1}:{uploaded.name}") + rows.extend(data.rows) + warnings.extend(data.warnings) + if warnings: + with st.expander(f"Report notices ({len(warnings)})", expanded=True): + for warning in dict.fromkeys(warnings): + st.warning(warning) + if not rows: + st.info("Upload JSON evaluation reports to start comparing results.") + st.caption("You can also open saved run directories with skillevaluator dashboard PATH [PATH …].") + return + + st.sidebar.header("Filter results") + st.sidebar.caption("Leave a filter empty to include all values.") + dimension_rows = rows + for field in _DIMENSIONS: + dimension_rows = _filter_rows(dimension_rows, field, rows) + dimension_rows = _filter_rows(dimension_rows, "status", rows) + performance_rows = _filter_rows(dimension_rows, "condition", rows) + st.sidebar.caption("The condition filter applies to performance. Comparisons retain both conditions.") + + run_count = len({(row["source"], row["run_id"]) for row in performance_rows}) + skill_count = len({row["skill"] for row in performance_rows}) + scored_count = sum(row.get("score") is not None for row in performance_rows) + summary = st.columns(4) + summary[0].metric("Runs", run_count) + summary[1].metric("Skills", skill_count) + summary[2].metric("Condition rows", len(performance_rows)) + summary[3].metric("Scored rows", scored_count) + st.caption("Blank cells mean the report did not record that measurement. Unknown settings remain labeled unknown.") + performance_tab, comparison_tab = st.tabs(["Performance", "With vs without skill"]) + with performance_tab: + _show_performance(performance_rows) + with comparison_tab: + _show_comparisons(dimension_rows) + + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py new file mode 100644 index 000000000..4e11df575 --- /dev/null +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -0,0 +1,487 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Read-only normalization of retained evaluations for the comparison dashboard. + +Usage totals require a measurement for every trial. Missing measurements stay +unknown, and differences require identical case/attempt coverage in both arms. +Agent execution time excludes environment setup and verifier execution. +""" + +from __future__ import annotations + +import json +import math +import os +import re +import stat +from collections import Counter +from dataclasses import dataclass, field +from datetime import datetime +from pathlib import Path +from typing import Any + +_USAGE = ("prompt_tokens", "completion_tokens", "total_tokens", "cached_tokens", "duration_seconds", "cost_usd") +_IDENTITY = ("source", "run_id", "skill", "model", "harness", "features") +_MAX_FILE_BYTES = 16 * 1024 * 1024 +_MAX_FILES = 1000 +_MAX_PATHS = 20_000 + + +@dataclass +class DashboardData: + rows: list[dict[str, Any]] = field(default_factory=list) + warnings: list[str] = field(default_factory=list) + + +def _dict(value: Any) -> dict[str, Any]: + return value if isinstance(value, dict) else {} + + +def _number(value: Any) -> float | None: + if isinstance(value, bool) or not isinstance(value, int | float): + return None + try: + number = float(value) + except OverflowError: + return None + return number if math.isfinite(number) else None + + +def _measurement(value: Any) -> float | None: + number = _number(value) + return number if number is not None and number >= 0 else None + + +def _count(value: Any) -> int | None: + return value if isinstance(value, int) and not isinstance(value, bool) and value >= 0 else None + + +def _features(*owners: dict[str, Any]) -> str: + for owner in owners: + metadata = _dict(owner.get("dashboard_metadata")) + features = metadata.get("harness_features") + if isinstance(features, str) and features.strip(): + return features.strip() + if isinstance(features, list) and all(isinstance(item, str) for item in features): + return ", ".join(sorted(set(features))) or "none (recorded)" + if isinstance(features, dict): + try: + return json.dumps(features, sort_keys=True, ensure_ascii=False, allow_nan=False) + except (ValueError, TypeError, RecursionError): + return "unknown" + return "unknown" + + +def _payloads(value: Any, depth: int = 0): + """Prefer authoritative per-validator results over a top-level Tier 3 mirror.""" + if depth > 32: + return + if isinstance(value, list): + for item in value: + yield from _payloads(item, depth + 1) + return + if not isinstance(value, dict): + return + if isinstance(value.get("results"), list): + for item in value["results"]: + yield from _payloads(item, depth + 1) + return + metadata = _dict(value.get("metadata")) + for candidate in (metadata.get("agent_eval"), value.get("tier3"), value.get("agent_eval")): + if isinstance(candidate, dict): + yield candidate + return + if isinstance(value.get("agents"), dict): + yield value + return + # Embedded catalog documents are supported; path references are resolved by + # load_dashboard_path, never by the parser for uploaded JSON. + if isinstance(value.get("skills"), list): + for item in value["skills"]: + yield from _payloads(item, depth + 1) + + +def _trial_keys(trials: list[dict[str, Any]]) -> tuple[tuple[str, str], ...] | None: + counts: Counter[str] = Counter() + keys = [] + implicit: set[str] = set() + seen_trials: dict[str, str] = {} + for trial in trials: + entry = trial.get("entry_id") + if not isinstance(entry, str) or not entry: + return None + trial_id = str(trial.get("trial_id") or "") + if trial_id and trial_id in seen_trials: + if seen_trials[trial_id] != entry: + return None + # Fallback multi-step rewards share one physical attempt identity. + continue + if trial_id: + seen_trials[trial_id] = entry + counts[entry] += 1 + attempt = trial.get("attempt") or trial.get("attempt_index") + # Native canonical reports omit attempt numbers, but Harbor trial IDs + # carry __attemptN when attempts are repeated. + match = re.search(r"(?:__|_)attempt[_-]?(\d+)(?:__|$)", trial_id) + if attempt is None and match: + attempt = int(match.group(1)) + if attempt is None: + implicit.add(entry) + keys.append((entry, str(attempt) if attempt is not None else f"ordinal:{counts[entry]}")) + if any(counts[entry] > 1 for entry in implicit): + return None + return tuple(sorted(keys)) + + +def _usage(trial: dict[str, Any]) -> dict[str, float | None]: + tokens = _dict(trial.get("tokens")) + prompt = _measurement(tokens.get("prompt")) + completion = _measurement(tokens.get("completion")) + return { + "prompt_tokens": prompt, + "completion_tokens": completion, + "total_tokens": prompt + completion if prompt is not None and completion is not None else None, + "cached_tokens": _measurement(tokens.get("cached")), + "duration_seconds": _measurement(trial.get("duration_seconds")), + "cost_usd": _measurement(trial.get("cost_usd")), + } + + +def _set_usage(row: dict[str, Any], usages: list[dict[str, Any]], expected: int | None = None) -> None: + expected = row["trials"] if expected is None else expected + row["_usage_coverage"] = {} + for metric in _USAGE: + values = [_measurement(usage.get(metric)) for usage in usages] + available = sum(value is not None for value in values) + row["_usage_coverage"][metric] = f"{available}/{expected}" + row[metric] = ( + _measurement(sum(value for value in values if value is not None)) + if values and available == len(values) == expected + else None + ) + eligibility = "complete" if row["_complete"] else "incomplete or unknown trial coverage" + row["coverage"] = ( + f"{row['trials']} trials ({eligibility}); tokens {row['_usage_coverage']['total_tokens']}, " + f"time {row['_usage_coverage']['duration_seconds']}, cost {row['_usage_coverage']['cost_usd']}" + ) + + +def parse_dashboard_report(payload: Any, source: str) -> DashboardData: + """Normalize canonical Tier 3, validate-report, and embedded catalog JSON.""" + output = DashboardData() + for report in _payloads(payload): + summary = _dict(report.get("summary")) + provenance = _dict(report.get("provenance")) + run_id = str(report.get("run_id") or summary.get("run_id") or "") + if not run_id and provenance.get("run_dir"): + run_id = Path(str(provenance["run_dir"])).name + if not run_id: + run_id = str(report.get("evaluated_at") or summary.get("evaluated_at") or "unknown") + truncation = _dict(report.get("report_truncation")) or _dict(report.get("truncation")) + if truncation.get("truncated"): + output.warnings.append(f"{source}: report details are truncated; comparisons are unavailable.") + for name, value in _dict(report.get("agents")).items(): + agent = _dict(value) + if not agent: + continue + conditions = _dict(agent.get("conditions")) + for condition, trial_field, score_field, count_field in ( + ("with_skill", "trials", "with_skill", "num_trials"), + ("without_skill", "trials_baseline", "baseline", "num_trials_baseline"), + ("adverse", "trials_adverse", "adverse", "num_trials_adverse"), + ): + details = _dict(conditions.get(condition)) + raw_trials = agent.get(trial_field) + if condition != "with_skill" and not details and not raw_trials and agent.get(score_field) is None: + continue + trials = ( + [trial for trial in (raw_trials or []) if isinstance(trial, dict)] + if isinstance(raw_trials, list) + else [] + ) + status = details.get("execution_status") or agent.get("execution_status") or "unknown" + if not isinstance(status, str) or status not in {"succeeded", "failed", "unknown", "skipped"}: + status = "unknown" + declared = _count(agent.get(count_field)) + if declared is None: + declared = len(trials) + expected = _count(details.get("expected_attempts")) + scored = _count(details.get("scored_attempts")) + keys = _trial_keys(trials) + logical_count = len(keys) if keys is not None else declared + complete = ( + status == "succeeded" + and declared > 0 + and len(trials) == declared + and keys is not None + and len(set(keys)) == len(keys) + and not truncation.get("truncated") + and (scored is None or scored == logical_count) + and (expected is None or scored == expected) + ) + row = { + "source": source, + "run_id": run_id, + "skill": str(report.get("skill_name") or summary.get("skill_name") or "unknown"), + "model": str(agent.get("model") or "unknown"), + "harness": str(agent.get("harness") or agent.get("name") or name), + "features": _features(details, agent, report), + "condition": condition, + "status": status, + "trials": logical_count, + "score": _number(agent.get(score_field)) if complete else None, + "pass_rate": _number(_dict(_dict(agent.get("pass_at_k")).get(condition)).get("rate")) + if complete + else None, + "_complete": complete, + "_trial_keys": keys, + "_dataset_digest": report.get("dataset_digest") or summary.get("dataset_digest"), + "_attempt_policy": report.get("attempt_policy"), + } + _set_usage(row, [_usage(trial) for trial in trials], expected=declared) + output.rows.append(row) + if not output.rows: + output.warnings.append(f"{source}: no supported Tier 3 agent results found.") + return output + + +def comparison_rows(rows: list[dict[str, Any]]) -> list[dict[str, Any]]: + """Compute with-minus-without differences only within an identical run.""" + groups: dict[tuple[Any, ...], list[dict[str, Any]]] = {} + for row in rows: + if row.get("condition") in {"with_skill", "without_skill"}: + groups.setdefault(tuple(row.get(key) for key in _IDENTITY), []).append(row) + comparisons = [] + for identity, arms in groups.items(): + with_rows = [row for row in arms if row["condition"] == "with_skill"] + without_rows = [row for row in arms if row["condition"] == "without_skill"] + result = dict(zip(_IDENTITY, identity, strict=True)) + status = "missing condition" + paired = False + if len(with_rows) > 1 or len(without_rows) > 1: + status = "ambiguous duplicate conditions" + elif with_rows and without_rows: + with_row, without_row = with_rows[0], without_rows[0] + paired = ( + with_row.get("_complete") + and without_row.get("_complete") + and with_row.get("_trial_keys") == without_row.get("_trial_keys") + and with_row.get("_dataset_digest") == without_row.get("_dataset_digest") + and with_row.get("_attempt_policy") == without_row.get("_attempt_policy") + ) + status = "comparable" if paired else "incomplete or mismatched coverage" + result["comparison_status"] = status + result["coverage"] = ( + f"{with_rows[0]['trials']} with / {without_rows[0]['trials']} without" + if with_rows and without_rows + else "missing condition" + ) + for metric in ("score", "pass_rate", *_USAGE): + with_value = _number(with_rows[0].get(metric)) if len(with_rows) == 1 else None + without_value = _number(without_rows[0].get(metric)) if len(without_rows) == 1 else None + result[f"with_{metric}"] = with_value + result[f"without_{metric}"] = without_value + available = paired and with_value is not None and without_value is not None + result[f"{metric}_delta"] = _number(with_value - without_value) if available else None + if metric in _USAGE: + result[f"{metric}_percent"] = ( + _number(100 * (with_value - without_value) / without_value) + if available and without_value != 0 + else None + ) + comparisons.append(result) + return comparisons + + +def _read_json(path: Path) -> Any: + if not stat.S_ISREG(path.stat().st_mode) or path.stat().st_size > _MAX_FILE_BYTES: + raise ValueError("JSON must be a regular file no larger than 16 MiB") + with path.open("rb") as stream: + data = stream.read(_MAX_FILE_BYTES + 1) + if len(data) > _MAX_FILE_BYTES: + raise ValueError("JSON exceeds 16 MiB") + return json.loads(data) + + +def _duration(result: dict[str, Any]) -> float | None: + execution = _dict(result.get("agent_execution")) + try: + started = datetime.fromisoformat(str(execution["started_at"])) + finished = datetime.fromisoformat(str(execution["finished_at"])) + return _measurement((finished - started).total_seconds()) + except (KeyError, TypeError, ValueError, OverflowError): + return None + + +def _native_usage(trial_dir: Path) -> dict[str, Any]: + trajectory = _dict(_read_json(trial_dir / "trajectory.json")) if (trial_dir / "trajectory.json").is_file() else {} + final = _dict(trajectory.get("final_metrics")) + result = _dict(_read_json(trial_dir / "result.json")) if (trial_dir / "result.json").is_file() else {} + agent_result = _dict(result.get("agent_result")) + prompt = _measurement(final.get("total_prompt_tokens")) + completion = _measurement(final.get("total_completion_tokens")) + cached = _measurement(final.get("total_cached_tokens")) + if prompt is None: + prompt = _measurement(agent_result.get("n_input_tokens")) + if completion is None: + completion = _measurement(agent_result.get("n_output_tokens")) + if cached is None: + cached = _measurement(agent_result.get("n_cache_tokens")) + # Constituent steps own their measured cost and execution time. The root + # may also mirror a step, so never add both the root and constituent values. + steps = result.get("step_results") + constituents = steps if isinstance(steps, list) and steps else [result] + if isinstance(steps, list) and steps: + + def step_total(key: str) -> float | None: + values = [_measurement(_dict(_dict(step).get("agent_result")).get(key)) for step in steps] + return _measurement(sum(values)) if all(value is not None for value in values) else None + + prompt = step_total("n_input_tokens") + completion = step_total("n_output_tokens") + cached = step_total("n_cache_tokens") + durations = [_duration(_dict(step)) for step in constituents] + costs = [_measurement(_dict(_dict(step).get("agent_result")).get("cost_usd")) for step in constituents] + return { + "prompt_tokens": prompt, + "completion_tokens": completion, + "total_tokens": prompt + completion if prompt is not None and completion is not None else None, + "cached_tokens": cached, + "duration_seconds": _measurement(sum(durations)) + if durations and all(value is not None for value in durations) + else None, + "cost_usd": _measurement(sum(costs)) if costs and all(value is not None for value in costs) else None, + } + + +def _load_native(path: Path) -> DashboardData: + from skillevaluator.evaluation.tier3_report import agent_eval_result_from_directory + + engine_result = _dict(_read_json(path / "result.json")) + skill = str(engine_result.get("skill_name") or "unknown") + result = agent_eval_result_from_directory(Path(skill), path, engine_result=engine_result, use_llm_judge=False) + if result is None: + return DashboardData(warnings=[f"{path}: no supported retained agent summaries found."]) + canonical = result.metadata["agent_eval"] + canonical["run_id"] = engine_result.get("run_id") or path.name + run_config = _dict(engine_result.get("run_config")) + if not run_config and (path / "run_config.json").is_file(): + run_config = _dict(_read_json(path / "run_config.json")) + canonical["dashboard_metadata"] = run_config.get("dashboard_metadata") + output = parse_dashboard_report(canonical, str(path)) + for row in output.rows: + # The report's agent keys identify repeated harness occurrences on disk. + agents = _dict(canonical.get("agents")) + name = next( + (key for key, agent in agents.items() if _dict(agent).get("name") == row["harness"]), row["harness"] + ) + agent_config = _dict(_dict(run_config.get("agents")).get(name)) + row["features"] = _features(agent_config, run_config) + row["harness"] = str(agent_config.get("agent") or row["harness"]) + variant = {"with_skill": "with-skill", "without_skill": "without-skill", "adverse": "adverse"}[row["condition"]] + summary_path = path / name / variant / "summary.json" + if summary_path.is_file(): + condition_summary = _dict(_read_json(summary_path)) + row["model"] = str(condition_summary.get("model") or row["model"]) + row["features"] = _features(condition_summary, agent_config, run_config) + trials_dir = path / name / variant / "trials" + usages_by_trial: dict[str, dict[str, Any]] = {} + if trials_dir.is_dir(): + for trial_dir in sorted(trials_dir.iterdir())[:513]: + if not trial_dir.is_dir() or trial_dir.is_symlink(): + continue + try: + reward = _dict(_read_json(trial_dir / "reward.json")) + physical_id = str(reward.get("trial_id") or trial_dir.name) + if physical_id not in usages_by_trial: + usages_by_trial[physical_id] = _native_usage(trial_dir) + except (OSError, ValueError, RecursionError) as exc: + output.warnings.append(f"{trial_dir}: cannot read usage: {exc}") + usages_by_trial[trial_dir.name] = {} + _set_usage(row, list(usages_by_trial.values())) + return output + + +def _load_report_file(path: Path) -> DashboardData: + payload = _read_json(path) + data = parse_dashboard_report(payload, str(path)) + if data.rows or not isinstance(payload, dict) or not isinstance(payload.get("skills"), list): + return data + output = DashboardData() + for entry in payload["skills"][:_MAX_FILES]: + entry = _dict(entry) + report_dir, report_name = entry.get("report_dir"), entry.get("json_report") + if not isinstance(report_dir, str) or not isinstance(report_name, str): + continue + try: + report_path = (path.parent / report_dir / report_name).resolve() + report_path.relative_to(path.parent.resolve()) + report = parse_dashboard_report(_read_json(report_path), str(report_path)) + except (OSError, ValueError, RecursionError) as exc: + output.warnings.append(f"{path}: cannot load catalog report: {exc}") + continue + output.rows.extend(report.rows) + output.warnings.extend(report.warnings) + if len(payload["skills"]) > _MAX_FILES: + output.warnings.append("Dashboard catalog limit reached; some inputs were omitted.") + if not output.rows: + output.warnings.extend(data.warnings) + return output + + +def load_dashboard_path(path: Path) -> DashboardData: + """Load one JSON report, a retained run, or a tree of reports and runs. + + Native run subtrees are consumed once and pruned, so their mirrored JSON + reports and constituent trials cannot become independent dashboard rows. + Directory symlinks are not traversed. + """ + path = path.expanduser().resolve() + output = DashboardData() + if path.is_file(): + try: + return _load_report_file(path) + except (OSError, ValueError, RecursionError) as exc: + return DashboardData(warnings=[f"{path}: cannot read report: {exc}"]) + if not path.is_dir(): + return DashboardData(warnings=[f"Dashboard input does not exist: {path}"]) + visited = 0 + files = 0 + for directory, subdirectories, filenames in os.walk(path, followlinks=False): + root = Path(directory) + subdirectories[:] = sorted(name for name in subdirectories if not (root / name).is_symlink()) + visited += len(subdirectories) + len(filenames) + if visited > _MAX_PATHS or files >= _MAX_FILES: + output.warnings.append("Dashboard discovery limit reached; some inputs were omitted.") + break + if "result.json" in filenames and "run_config.json" in filenames: + try: + data = _load_native(root) + except (OSError, ValueError, RecursionError) as exc: + data = DashboardData(warnings=[f"{root}: cannot load retained run: {exc}"]) + subdirectories.clear() + output.rows.extend(data.rows) + output.warnings.extend(data.warnings) + files += 1 + continue + for filename in sorted(filenames): + if not filename.endswith(".json"): + continue + files += 1 + try: + data = parse_dashboard_report(_read_json(root / filename), str(root / filename)) + except (OSError, ValueError, RecursionError) as exc: + output.warnings.append(f"{root / filename}: cannot read report: {exc}") + continue + output.rows.extend(data.rows) + # Avoid noisy warnings for unrelated config/dataset/summary files. + if data.rows: + output.warnings.extend(data.warnings) + if files >= _MAX_FILES: + output.warnings.append("Dashboard file limit reached; some inputs were omitted.") + subdirectories.clear() + break + if not output.rows: + output.warnings.append(f"{path}: no supported Tier 3 agent results found.") + return output diff --git a/tests/golden/cli_surface.json b/tests/golden/cli_surface.json index b777f2cac..3d8551705 100644 --- a/tests/golden/cli_surface.json +++ b/tests/golden/cli_surface.json @@ -173,6 +173,37 @@ } ] }, + "dashboard": { + "params": [ + { + "name": "paths", + "opts": [ + "paths" + ], + "param_type": "argument", + "type": "path" + }, + { + "default": "8501", + "name": "port", + "opts": [ + "--port" + ], + "param_type": "option", + "type": "integer range" + }, + { + "default": "False", + "is_flag": true, + "name": "no_browser", + "opts": [ + "--no-browser" + ], + "param_type": "option", + "type": "boolean" + } + ] + }, "dedup-scan": { "params": [ { diff --git a/tests/reporting/test_dashboard_app.py b/tests/reporting/test_dashboard_app.py new file mode 100644 index 000000000..2903965b6 --- /dev/null +++ b/tests/reporting/test_dashboard_app.py @@ -0,0 +1,204 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Exercise the actual optional Streamlit app and its dataframes without mocks.""" + +from __future__ import annotations + +import csv +import io +import json +from pathlib import Path + +import pytest + +pytest.importorskip("streamlit") +from streamlit.testing.v1 import AppTest + +from skillevaluator.reporting.dashboard_app import rows_csv + + +def _write_report( + path: Path, + *, + skill: str = "calculator", + model: str = "model-a", + harness: str = "opencode", + features: list[str] | None = None, + baseline_status: str = "succeeded", + measured: bool = True, +) -> Path: + def trial(score: float, tokens: int) -> dict: + value = {"entry_id": "case-1", "trial_id": "case-1__attempt1", "overall": score} + if measured: + value.update({"tokens": {"prompt": tokens, "completion": 20, "cached": 0}}) + return value + + report = { + "schema_version": "2.0", + "skill_name": skill, + "run_id": path.stem, + "agents": { + harness: { + "name": harness, + "model": model, + "dashboard_metadata": {"harness_features": features if features is not None else ["tools"]}, + "execution_status": "succeeded", + "conditions": { + "with_skill": {"execution_status": "succeeded", "expected_attempts": 1, "scored_attempts": 1}, + "without_skill": { + "execution_status": baseline_status, + "expected_attempts": 1, + "scored_attempts": 1, + }, + }, + "with_skill": 0.9, + "baseline": 0.6, + "num_trials": 1, + "num_trials_baseline": 1, + "trials": [trial(0.9, 120)], + "trials_baseline": [trial(0.6, 100)], + "pass_at_k": {"with_skill": {"rate": 1.0}, "without_skill": {"rate": 0.0}}, + "raw_transcript": "private execution text must stay out of the UI", + }, + }, + } + path.write_text(json.dumps(report), encoding="utf-8") + return path + + +def _app(paths: list[Path]) -> AppTest: + script = f"from skillevaluator.reporting.dashboard_app import main\nmain({[str(path) for path in paths]!r})\n" + return AppTest.from_string(script, default_timeout=15).run() + + +def test_empty_dashboard_has_upload_direction() -> None: + app = _app([]) + assert not app.exception + assert [message.value for message in app.info] == ["Upload JSON evaluation reports to start comparing results."] + assert len(app.dataframe) == 0 + + +def test_dashboard_renders_numeric_performance_and_paired_comparison(tmp_path: Path) -> None: + path = _write_report(tmp_path / "run-1.json") + app = _app([path, path]) + assert not app.exception + assert [tab.label for tab in app.tabs] == ["Performance", "With vs without skill"] + performance = app.dataframe[0].value + comparison = app.dataframe[1].value + assert len(performance) == 2 + assert performance["score"].tolist() == [0.9, 0.6] + assert performance["total_tokens"].tolist() == [140.0, 120.0] + assert performance["cost_usd"].isna().all() + assert performance["cached_tokens"].tolist() == [0.0, 0.0] + assert comparison["score_delta"].iloc[0] == pytest.approx(0.3) + assert comparison["total_tokens_delta"].iloc[0] == 20.0 + assert comparison["total_tokens_percent"].iloc[0] == pytest.approx(100 / 6) + assert comparison["comparison_status"].iloc[0] == "comparable" + assert "raw_transcript" not in performance.columns + assert all(not column.startswith("_") for column in performance.columns) + assert [metric.value for metric in app.metric] == ["1", "1", "2", "2"] + + +def test_dimension_filters_and_condition_retain_baseline_for_comparison(tmp_path: Path) -> None: + paths = [ + _write_report(tmp_path / "a.json"), + _write_report(tmp_path / "b.json", skill="summarizer", model="model-b", harness="claude-code", features=[]), + _write_report(tmp_path / "c.json", skill="calculator", model="model-c", features=["tools", "memory"]), + ] + app = _app(paths) + app.multiselect(key="filter_skill").set_value(["calculator"]) + app.multiselect(key="filter_model").set_value(["model-a"]) + app.multiselect(key="filter_harness").set_value(["opencode"]) + app.multiselect(key="filter_features").set_value(["tools"]) + app.multiselect(key="filter_status").set_value(["succeeded"]) + app.multiselect(key="filter_condition").set_value(["with_skill"]) + app.run() + assert not app.exception + assert app.dataframe[0].value["condition"].tolist() == ["with_skill"] + assert app.dataframe[1].value["score_delta"].iloc[0] == pytest.approx(0.3) + assert [metric.value for metric in app.metric] == ["1", "1", "1", "1"] + + app.multiselect(key="filter_model").set_value(["model-b"]).run() + assert not app.exception + assert len(app.dataframe) == 0 + assert "No rows match these filters" in app.info[0].value + assert "No comparisons are available" in app.info[1].value + + for widget in app.multiselect: + widget.set_value([]) + app.run() + assert not app.exception + assert len(app.dataframe[0].value) == 6 + assert len(app.dataframe[1].value) == 3 + + +def test_unmeasured_and_failed_baseline_are_not_zero_or_comparable(tmp_path: Path) -> None: + path = _write_report(tmp_path / "failed.json", baseline_status="failed", measured=False) + app = _app([path]) + assert not app.exception + performance = app.dataframe[0].value + assert performance["total_tokens"].isna().all() + assert performance["duration_seconds"].isna().all() + assert performance.loc[performance["condition"] == "without_skill", "score"].isna().all() + comparison = app.dataframe[1].value + assert comparison["score_delta"].isna().all() + assert comparison["comparison_status"].iloc[0] == "incomplete or mismatched coverage" + app.multiselect(key="filter_status").set_value(["succeeded"]).run() + assert not app.exception + assert len(app.dataframe[0].value) == 1 + assert app.dataframe[1].value["comparison_status"].iloc[0] == "missing condition" + + +def test_bad_report_does_not_hide_other_results(tmp_path: Path) -> None: + valid = _write_report(tmp_path / "valid.json") + invalid = tmp_path / "invalid.json" + invalid.write_text("{broken JSON", encoding="utf-8") + app = _app([invalid, valid, tmp_path / "missing.json"]) + assert not app.exception + assert len(app.warning) == 2 + assert len(app.dataframe[0].value) == 2 + + +@pytest.mark.parametrize( + ("view", "measured_column"), + [ + ("Overview", "total_tokens_delta"), + ("Quality", "with_pass_rate"), + ("Tokens", "with_total_tokens"), + ("Duration", "with_duration_seconds"), + ("Cost", "with_cost_usd"), + ("All metrics", "without_prompt_tokens"), + ], +) +def test_comparison_views_keep_measurements_numeric(tmp_path: Path, view: str, measured_column: str) -> None: + app = _app([_write_report(tmp_path / "run.json")]) + app.selectbox(key="comparison_metrics").set_value(view).run() + assert not app.exception + comparison = app.dataframe[1] + assert measured_column in comparison.value.columns + config = json.loads(comparison.proto.columns) + assert config[measured_column]["type_config"]["type"] == "number" + assert config["comparison_status"]["type_config"]["type"] == "text" + assert comparison.value["comparison_status"].iloc[0] == "comparable" + assert len(comparison.value.columns) == len(set(comparison.value.columns)) + if view == "All metrics": + for field in comparison.value.columns: + if any(metric in field for metric in ("tokens", "duration_seconds", "cost_usd", "score", "pass_rate")): + assert config[field]["type_config"]["type"] == "number", field + + +def test_csv_preserves_numeric_deltas_and_escapes_formula_strings() -> None: + exported = rows_csv( + [ + {"skill": ' =HYPERLINK("https://example.com")', "score_delta": -0.25, "cost_usd": None}, + {"skill": "\tprivate-name", "score_delta": 0.0, "cost_usd": 0.0}, + {"skill": "@SUM(A1)", "score_delta": 1.25, "cost_usd": 0.1, "_secret": "must not be exported"}, + ], + ("skill", "score_delta", "cost_usd"), + ) + cells = list(csv.DictReader(io.StringIO(exported))) + assert cells[0] == {"skill": '\' =HYPERLINK("https://example.com")', "score_delta": "-0.25", "cost_usd": ""} + assert cells[1] == {"skill": "'\tprivate-name", "score_delta": "0.0", "cost_usd": "0.0"} + assert cells[2]["skill"] == "'@SUM(A1)" + assert "must not be exported" not in exported diff --git a/tests/reporting/test_dashboard_cli.py b/tests/reporting/test_dashboard_cli.py new file mode 100644 index 000000000..e552ba239 --- /dev/null +++ b/tests/reporting/test_dashboard_cli.py @@ -0,0 +1,52 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""The optional dashboard launcher preserves the lightweight CLI contract.""" + +from __future__ import annotations + +import sys +from pathlib import Path + +from click.testing import CliRunner + +from skillevaluator.cli import cli +from skillevaluator.reporting import dashboard + + +def test_dashboard_help_and_input_validation() -> None: + runner = CliRunner() + help_result = runner.invoke(cli, ["dashboard", "--help"]) + assert help_result.exit_code == 0 + assert "retained Tier 3" in help_result.output + assert runner.invoke(cli, ["dashboard", "--port", "0"]).exit_code == 2 + assert runner.invoke(cli, ["dashboard", "missing-report-170.json"]).exit_code == 2 + + +def test_missing_extra_has_actionable_error(monkeypatch) -> None: + monkeypatch.setattr(dashboard.importlib.util, "find_spec", lambda _name: None) + result = CliRunner().invoke(cli, ["dashboard"]) + assert result.exit_code == 1 + assert 'pip install "skillevaluator[dashboard]"' in result.output + + +def test_launch_uses_loopback_and_literal_absolute_paths(tmp_path: Path, monkeypatch) -> None: + report = tmp_path / "report with spaces; literal.json" + report.write_text("{}", encoding="utf-8") + commands = [] + monkeypatch.setattr(dashboard.importlib.util, "find_spec", lambda _name: object()) + + def capture(command): + commands.append(command) + return 7 + + monkeypatch.setattr(dashboard.subprocess, "call", capture) + result = CliRunner().invoke(cli, ["dashboard", str(report), "--port", "8517", "--no-browser"]) + assert result.exit_code == 7 + command = commands[0] + assert command[:3] == [sys.executable, "-m", "streamlit"] + assert "--server.address=127.0.0.1" in command + assert "--server.port=8517" in command + assert "--server.headless=true" in command + assert "--browser.gatherUsageStats=false" in command + assert command[-2:] == ["--", str(report.resolve())] diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py new file mode 100644 index 000000000..0544fa762 --- /dev/null +++ b/tests/reporting/test_dashboard_data.py @@ -0,0 +1,334 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +from __future__ import annotations + +import copy +import json +from pathlib import Path + +import pytest + +from skillevaluator.reporting.dashboard_data import comparison_rows, load_dashboard_path, parse_dashboard_report + + +def _report() -> dict: + def trial(prompt: int, completion: int, seconds: float, cost: float) -> dict: + return { + "entry_id": "case-a", + "trial_id": "case-a__random", + "overall": 0.8, + "tokens": {"prompt": prompt, "completion": completion, "cached": 0}, + "duration_seconds": seconds, + "cost_usd": cost, + } + + return { + "schema_version": "2.0", + "skill_name": "calculator", + "run_id": "run-1", + "dataset_digest": "sha256:dataset", + "attempt_policy": {"max_attempts": 1}, + "agents": { + "claude-code": { + "name": "claude-code", + "model": "model-a", + "execution_status": "succeeded", + "with_skill": 0.8, + "baseline": 0.6, + "num_trials": 1, + "num_trials_baseline": 1, + "conditions": { + arm: {"execution_status": "succeeded", "expected_attempts": 1, "scored_attempts": 1} + for arm in ("with_skill", "without_skill") + }, + "trials": [trial(120, 30, 8, 0.02)], + "trials_baseline": [trial(100, 20, 10, 0.01)], + "pass_at_k": {"with_skill": {"rate": 1.0}, "without_skill": {"rate": 0.0}}, + } + }, + } + + +def test_with_without_differences_and_explicit_features() -> None: + report = _report() + report["dashboard_metadata"] = {"harness_features": ["rules", "memory"]} + data = parse_dashboard_report(report, "report.json") + assert len(data.rows) == 2 + assert data.rows[0]["features"] == "memory, rules" + comparison = comparison_rows(data.rows)[0] + assert comparison["comparison_status"] == "comparable" + assert comparison["score_delta"] == pytest.approx(0.2) + assert comparison["total_tokens_delta"] == 30 + assert comparison["total_tokens_percent"] == 25 + assert comparison["duration_seconds_delta"] == -2 + assert comparison["cost_usd_percent"] == 100 + + +def test_authoritative_validator_results_exclude_top_level_mirror() -> None: + first, second = _report(), _report() + second["skill_name"] = "second-skill" + wrapper = {"tier3": first, "results": [{"tier3": first}, {"metadata": {"agent_eval": second}}]} + data = parse_dashboard_report(wrapper, "combined.json") + assert len(data.rows) == 4 + assert {row["skill"] for row in data.rows} == {"calculator", "second-skill"} + assert len(comparison_rows(data.rows)) == 2 + assert parse_dashboard_report({"skills": [wrapper]}, "combined.json").rows == data.rows + + +def test_partial_missing_metrics_never_become_zero_or_partial_total() -> None: + report = _report() + agent = report["agents"]["claude-code"] + for field in ("trials", "trials_baseline"): + agent[field][0]["tokens"].pop("completion") + agent[field][0].pop("cost_usd") + data = parse_dashboard_report(report, "report.json") + assert data.rows[0]["total_tokens"] is None + assert data.rows[0]["cost_usd"] is None + comparison = comparison_rows(data.rows)[0] + assert comparison["prompt_tokens_delta"] == 20 + assert comparison["total_tokens_delta"] is None + assert comparison["cost_usd_delta"] is None + assert "cost 0/1" in data.rows[0]["coverage"] + + +@pytest.mark.parametrize("mutation", ["failed", "missing_trial", "truncated", "different_case", "missing_attempt"]) +def test_incomplete_or_unmatched_arms_block_all_deltas(mutation: str) -> None: + report = _report() + agent = report["agents"]["claude-code"] + if mutation == "failed": + agent["conditions"]["without_skill"]["execution_status"] = "failed" + elif mutation == "missing_trial": + agent["trials_baseline"] = [] + elif mutation == "truncated": + report["report_truncation"] = {"truncated": True} + elif mutation == "different_case": + agent["trials_baseline"][0]["entry_id"] = "case-b" + elif mutation == "missing_attempt": + agent["conditions"]["without_skill"]["expected_attempts"] = 2 + comparison = comparison_rows(parse_dashboard_report(report, "same.json").rows)[0] + assert comparison["comparison_status"] == "incomplete or mismatched coverage" + assert comparison["score_delta"] is None + assert comparison["total_tokens_delta"] is None + + +def test_disjoint_runs_features_and_duplicate_conditions_cannot_pair() -> None: + data = parse_dashboard_report(_report(), "first.json") + rows = copy.deepcopy(data.rows) + rows[1]["source"] = "second.json" + assert all(row["comparison_status"] == "missing condition" for row in comparison_rows(rows)) + rows = copy.deepcopy(data.rows) + rows[1]["features"] = "rules" + assert all(row["comparison_status"] == "missing condition" for row in comparison_rows(rows)) + duplicate = comparison_rows([*data.rows, data.rows[0]])[0] + assert duplicate["comparison_status"] == "ambiguous duplicate conditions" + assert duplicate["score_delta"] is None + + +def test_zero_baseline_and_nonfinite_values() -> None: + report = _report() + agent = report["agents"]["claude-code"] + agent["trials_baseline"][0]["cost_usd"] = 0 + agent["trials"][0]["duration_seconds"] = float("inf") + agent["trials"][0]["tokens"]["cached"] = True + report["dashboard_metadata"] = {"harness_features": {"invalid": float("nan")}} + data = parse_dashboard_report(report, "report.json") + assert data.rows[0]["features"] == "unknown" + assert data.rows[0]["cached_tokens"] is None + comparison = comparison_rows(data.rows)[0] + assert comparison["cost_usd_delta"] == 0.02 + assert comparison["cost_usd_percent"] is None + assert comparison["duration_seconds_delta"] is None + + +def test_malformed_status_and_aggregate_overflow_fail_closed() -> None: + report = _report() + agent = report["agents"]["claude-code"] + agent["execution_status"] = ["succeeded"] + agent["conditions"] = {} + assert all(row["status"] == "unknown" for row in parse_dashboard_report(report, "report.json").rows) + report = _report() + agent = report["agents"]["claude-code"] + agent["trials"][0]["tokens"] = {"prompt": 1e308, "completion": 1e308} + row = parse_dashboard_report(report, "report.json").rows[0] + assert row["total_tokens"] is None + + +def test_repeated_attempts_require_recorded_identity_and_match_exact_set() -> None: + report = _report() + agent = report["agents"]["claude-code"] + for field, count_field, arm in ( + ("trials", "num_trials", "with_skill"), + ("trials_baseline", "num_trials_baseline", "without_skill"), + ): + agent[field].append(copy.deepcopy(agent[field][0])) + agent[field][0]["trial_id"] = "case-a__attempt1__abc" + agent[field][1]["trial_id"] = "case-a__attempt2__def" + agent[count_field] = 2 + agent["conditions"][arm].update(expected_attempts=2, scored_attempts=2) + assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["comparison_status"] == "comparable" + agent["trials_baseline"][1]["trial_id"] = "case-a__attempt3__def" + assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["score_delta"] is None + for field in ("trials", "trials_baseline"): + for index, trial in enumerate(agent[field]): + trial["trial_id"] = f"case-a__unrelated-{index}" + assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["score_delta"] is None + + +def test_multistep_rewards_count_logical_attempt_once_and_sum_resources() -> None: + report = _report() + agent = report["agents"]["claude-code"] + for field, count_field in (("trials", "num_trials"), ("trials_baseline", "num_trials_baseline")): + agent[field].append(copy.deepcopy(agent[field][0])) + agent[count_field] = 2 + data = parse_dashboard_report(report, "report.json") + assert data.rows[0]["trials"] == 1 + assert data.rows[0]["total_tokens"] == 300 + assert comparison_rows(data.rows)[0]["score_delta"] == pytest.approx(0.2) + + +def test_explicit_adverse_row_has_no_invented_baseline_delta() -> None: + report = _report() + agent = report["agents"]["claude-code"] + agent.update(adverse=0.2, trials_adverse=copy.deepcopy(agent["trials"]), num_trials_adverse=1) + agent["conditions"]["adverse"] = {"execution_status": "succeeded", "expected_attempts": 1, "scored_attempts": 1} + data = parse_dashboard_report(report, "report.json") + assert [row["condition"] for row in data.rows] == ["with_skill", "without_skill", "adverse"] + assert data.rows[2]["score"] == 0.2 + assert len(comparison_rows(data.rows)) == 1 + + +def test_bad_input_is_diagnostic_and_directory_skips_symlinks(tmp_path: Path) -> None: + malformed = tmp_path / "broken.json" + malformed.write_text("{", encoding="utf-8") + assert load_dashboard_path(malformed).warnings + assert load_dashboard_path(tmp_path / "missing").warnings + good = tmp_path / "report.json" + good.write_text(json.dumps(_report()), encoding="utf-8") + (tmp_path / "loop").symlink_to(tmp_path, target_is_directory=True) + data = load_dashboard_path(tmp_path) + assert len(data.rows) == 2 + assert any("cannot read" in warning for warning in data.warnings) + + +def test_catalog_index_loads_authoritative_local_reports_with_containment(tmp_path: Path) -> None: + reports = tmp_path / "calculator" + reports.mkdir() + (reports / "current.json").write_text(json.dumps(_report())) + index = tmp_path / "catalog-summary.json" + index.write_text( + json.dumps( + { + "skills": [ + {"report_dir": "calculator", "json_report": "current.json"}, + {"report_dir": "..", "json_report": "outside.json"}, + ] + } + ) + ) + data = load_dashboard_path(index) + assert len(data.rows) == 2 + assert data.warnings + + +def _native_run(path: Path) -> None: + metrics = ["security", "skill_execution", "skill_efficiency", "accuracy", "goal_accuracy", "behavior_check"] + path.mkdir() + (path / "result.json").write_text(json.dumps({"skill_name": "native-skill", "run_id": "native-run"})) + (path / "run_config.json").write_text(json.dumps({"agents": {"opencode": {"agent": "opencode", "model": "m"}}})) + for variant, input_tokens in (("with-skill", 200), ("without-skill", 100)): + condition = path / "opencode" / variant + trial = condition / "trials" / "case-a__random" + trial.mkdir(parents=True) + (condition / "summary.json").write_text( + json.dumps( + { + "agent": "opencode", + "model": "m", + "scores": dict.fromkeys(metrics, 0.8), + "metrics": metrics, + "num_trials": 1, + "execution_status": "succeeded", + "expected_attempts": 1, + "scored_attempts": 1, + } + ) + ) + (trial / "reward.json").write_text( + json.dumps( + { + **dict.fromkeys(metrics, 0.8), + "entry_id": "case-a", + "trial_id": "case-a__random", + "overall": 0.8, + } + ) + ) + (trial / "trajectory.json").write_text( + json.dumps( + { + "steps": [], + "final_metrics": {"total_prompt_tokens": input_tokens, "total_completion_tokens": 10}, + } + ) + ) + (trial / "result.json").write_text( + json.dumps( + { + "agent_result": {"n_input_tokens": input_tokens, "n_output_tokens": 10, "cost_usd": None}, + "agent_execution": {"started_at": "2026-10-01T00:00:00Z", "finished_at": "2026-10-01T00:00:10Z"}, + } + ) + ) + + +def test_native_results_use_real_usage_and_prune_nested_mirrors(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + (run / "report.json").write_text(json.dumps(_report())) + data = load_dashboard_path(tmp_path) + assert len(data.rows) == 2 + assert data.rows[0]["skill"] == "native-skill" + assert data.rows[0]["prompt_tokens"] == 200 + assert data.rows[0]["duration_seconds"] == 10 + assert data.rows[0]["cost_usd"] is None + assert data.rows[0]["cached_tokens"] is None + comparison = comparison_rows(data.rows)[0] + assert comparison["comparison_status"] == "comparable" + assert comparison["total_tokens_delta"] == 100 + + +def test_native_different_condition_models_cannot_pair(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + baseline_summary = run / "opencode" / "without-skill" / "summary.json" + summary = json.loads(baseline_summary.read_text()) + summary["model"] = "different-model" + baseline_summary.write_text(json.dumps(summary)) + comparisons = comparison_rows(load_dashboard_path(run).rows) + assert len(comparisons) == 2 + assert all(row["comparison_status"] == "missing condition" for row in comparisons) + + +def test_multistep_native_cost_time_and_tokens_require_every_step(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + trial_result = run / "opencode" / "with-skill" / "trials" / "case-a__random" / "result.json" + result = json.loads(trial_result.read_text()) + step = { + "agent_result": {"n_input_tokens": 50, "n_output_tokens": 5, "n_cache_tokens": 0, "cost_usd": 0.1}, + "agent_execution": {"started_at": "2026-10-01T00:00:00Z", "finished_at": "2026-10-01T00:00:03Z"}, + } + result["step_results"] = [step, copy.deepcopy(step)] + trial_result.write_text(json.dumps(result)) + row = load_dashboard_path(run).rows[0] + assert row["prompt_tokens"] == 100 + assert row["duration_seconds"] == 6 + assert row["cost_usd"] == pytest.approx(0.2) + result["step_results"][1]["agent_result"].pop("n_input_tokens") + result["step_results"][1]["agent_result"].pop("cost_usd") + trial_result.write_text(json.dumps(result)) + row = load_dashboard_path(run).rows[0] + assert row["prompt_tokens"] is None + assert row["total_tokens"] is None + assert row["cost_usd"] is None diff --git a/tests/test_oss_packaging.py b/tests/test_oss_packaging.py index 770a3dcf8..089cf73ef 100644 --- a/tests/test_oss_packaging.py +++ b/tests/test_oss_packaging.py @@ -493,8 +493,17 @@ def test_release_lock_enforces_nspect_remediation_floors_without_removed_telemet ) assert all(version >= Version("1.28.1") for version in all_lock_versions["mcp"]) assert all(version >= Version("2.13.0") for version in all_lock_versions["pyjwt"]) + # The optional dashboard uses Streamlit's protobuf transport. It does not + # restore the removed evaluator telemetry integration or its dependencies. + protobuf_consumers = { + package["name"] + for package in _lock()["package"] + if any(dependency["name"] == "protobuf" for dependency in package.get("dependencies", [])) + } + assert protobuf_consumers == {"streamlit"} + assert extras["dashboard"] == ["streamlit>=1.49,<2"] + assert not any("streamlit" in dependency for dependency in project["project"]["dependencies"]) assert all(version >= Version("4.0.0") for version in all_lock_versions["oauthlib"]) - assert "protobuf" not in all_lock_versions assert not any(name.startswith("opentelemetry") for name in all_lock_versions) diff --git a/uv.lock b/uv.lock index 1ffe7179b..33ea5bc02 100644 --- a/uv.lock +++ b/uv.lock @@ -89,6 +89,22 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/fb/76/641ae371508676492379f16e2fa48f4e2c11741bd63c48be4b12a6b09cba/aiosignal-1.4.0-py3-none-any.whl", hash = "sha256:053243f8b92b990551949e63930a839ff0cf0b0ebbe0597b0f3fb19e1a0fe82e", size = 7490, upload-time = "2025-07-03T22:54:42.156Z" }, ] +[[package]] +name = "altair" +version = "6.3.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "jinja2" }, + { name = "jsonschema" }, + { name = "narwhals" }, + { name = "packaging" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e8/de/9731304fae332b5783fdc3ed18531dfaf4a3cc62a66aaaa74c047355b70f/altair-6.3.0.tar.gz", hash = "sha256:fa632121aca6d0fcb198a3d8a9f7d937fa5b7518ec947951cfffb44e736d97c8", size = 766362, upload-time = "2026-09-15T06:38:03.623Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ca/b9/10a8bb13a0462e0bc4e02c0b7b8237dc24ab590f5bb4be94bec5e8f1d532/altair-6.3.0-py3-none-any.whl", hash = "sha256:7defb6ca730676dfc99a299768e2769f51585fcb3dc960ea71aacc368929d65e", size = 797192, upload-time = "2026-09-15T06:38:01.791Z" }, +] + [[package]] name = "annotated-doc" version = "0.0.4" @@ -750,6 +766,40 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" }, ] +[[package]] +name = "httptools" +version = "0.9.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/3a/ec/deed52912ab7ca6c0b12859330c571c60c61d7267b341b28951fcbf13694/httptools-0.9.0.tar.gz", hash = "sha256:d484ebb7e3a3f3597b0f645fbd1b85633674ca808c1f5ba11c2caf7c66f5c8b6", size = 282523, upload-time = "2026-10-09T19:57:04.301Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/da/ed/0916b8b7ebd1deeaf22acba71b68c57b4b6b69aa1918f3812dea208b4276/httptools-0.9.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f9ccc9884241efceb4547a92955d128574c864681f11b7ea3ecbde295fafbe8b", size = 119039, upload-time = "2026-10-09T19:54:32.556Z" }, + { url = "https://files.pythonhosted.org/packages/c2/0b/9b6de4a01a563a904d0826c9069c824b330e1816df26c9bdf93f60b50857/httptools-0.9.0-cp312-cp312-macosx_11_0_x86_64.whl", hash = "sha256:45b3002392948dcf578029c89f6318e1289a993a1a5ec38a4161560fab60f811", size = 115051, upload-time = "2026-10-09T19:54:33.908Z" }, + { url = "https://files.pythonhosted.org/packages/85/3f/642113e9882f53158ecddf58003d25f18ded2c210ed23bf6eb663d4d51c3/httptools-0.9.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:3e3201fe4d46e0d15d7ff9fafc94a605da9eb82d2c5b9837f0368acb325481f1", size = 552848, upload-time = "2026-10-09T19:54:35.434Z" }, + { url = "https://files.pythonhosted.org/packages/95/4c/3ecc59c99c28652d8d08d9b5be65770a14d2cadc616dad94224cee2b0e7e/httptools-0.9.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:58a1b0ec4cbb930e69669f9771715b2c7898d3cdf064d9811f7a66afef96b544", size = 549181, upload-time = "2026-10-09T19:54:37.099Z" }, + { url = "https://files.pythonhosted.org/packages/43/ce/21f5b2759590b7054e38d3b704a3c6b853c3395c370b3d6f16c45aea0fc0/httptools-0.9.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:4c58dc91aefb31adad500aa68054334f429b840b36dd29e34e834101044cb2ef", size = 569121, upload-time = "2026-10-09T19:54:38.772Z" }, + { url = "https://files.pythonhosted.org/packages/52/c3/7c523aa8d0fa7a57010a3e1bbdebc209585009076465f3d1ae6a3f54b814/httptools-0.9.0-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:6b900073e7b8481ef1aaf4f6c1789d210a1db01a9da8789821578cfeb4c2d540", size = 487649, upload-time = "2026-10-09T19:54:40.398Z" }, + { url = "https://files.pythonhosted.org/packages/94/e2/d90d60002692b8afcbc06fb49ca3a4365b32abed6c40fb2b612c67721a00/httptools-0.9.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6c12d0393a903b58bc5f5a7406d6c5290acfb8284290d68547ce620c06f7d133", size = 529583, upload-time = "2026-10-09T19:54:42.296Z" }, + { url = "https://files.pythonhosted.org/packages/46/c0/19172874cde0344a20c85877a0b2d0dcfca31111729ad8a79e8b4ac4e207/httptools-0.9.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:29b0d823e3c1e7cd1093a5dc889245db693ef13ada624cd66e2262421ef38867", size = 552414, upload-time = "2026-10-09T19:54:44.19Z" }, + { url = "https://files.pythonhosted.org/packages/1b/b8/02ea7910f69e5371986b025fb3b410592106df54e977a5732fd1d95917b5/httptools-0.9.0-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:6ebd39ee26db460cfe5ab8b71a15d1149b289139a0d3981522757d6af620887e", size = 482400, upload-time = "2026-10-09T19:54:46.064Z" }, + { url = "https://files.pythonhosted.org/packages/de/97/f05eac916d44cbbfe43668a6a40ab93e7fd8f94d5120d1ce2d8e55c69871/httptools-0.9.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:4efbee349138a3fee7a4cc3a95abd2d499fae70dd5bff9fed9138d6f570f4283", size = 536148, upload-time = "2026-10-09T19:54:47.695Z" }, + { url = "https://files.pythonhosted.org/packages/b6/e9/9435dfcb7f1a1d6ebdc79a902164dfca70e33774c80bb60d25c630c31ef1/httptools-0.9.0-cp312-cp312-win32.whl", hash = "sha256:36fac804b8cfd6b935ae64f71349f833d2b6298404626d017a2c57bb942bc643", size = 86274, upload-time = "2026-10-09T19:54:49.1Z" }, + { url = "https://files.pythonhosted.org/packages/8b/69/813f1bf90be507d4166c437be1a413574d0e0abf36e2fec10c266661b0ee/httptools-0.9.0-cp312-cp312-win_amd64.whl", hash = "sha256:7e32b83bd8c2f8b6fa726ef34e63e21c4d7eddc277d40d4ef7245ea3ed28e5b6", size = 92446, upload-time = "2026-10-09T19:54:50.498Z" }, + { url = "https://files.pythonhosted.org/packages/ae/e0/1d29e328c4cafe843403341e1455e0aec18b0e6910fbb14f12b36b563f19/httptools-0.9.0-cp312-cp312-win_arm64.whl", hash = "sha256:813a32f94991b9627795528053c73a57d2ce3eb98ede89f0e1c7a31095938e81", size = 88676, upload-time = "2026-10-09T19:54:51.844Z" }, + { url = "https://files.pythonhosted.org/packages/9c/04/223994f8589750d2a36ceb43203e739cf75bd9e12c226680d73567766908/httptools-0.9.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:4fb995082fe41ec410b33c48b54fb1d44abb8a6ee762c31e8c42519e8c3a30a9", size = 117115, upload-time = "2026-10-09T19:54:53.356Z" }, + { url = "https://files.pythonhosted.org/packages/31/d8/b4407836e567a862ce79d78a628d785db99aba52e63496d68c60eed0d475/httptools-0.9.0-cp313-cp313-macosx_11_0_x86_64.whl", hash = "sha256:b9cd15cb7cf0d5cc41f649fd789aae12c56c3b83eff593f8e095c1d4555ad5c3", size = 113225, upload-time = "2026-10-09T19:54:54.81Z" }, + { url = "https://files.pythonhosted.org/packages/79/f6/0caa51b077492a7306bdbd9dfb907a2246985f0aed1fe2d086255921848b/httptools-0.9.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:088de1738e1af624466a01c35d652dbe6fb825be887c76d68aa850621d81db88", size = 520112, upload-time = "2026-10-09T19:54:56.3Z" }, + { url = "https://files.pythonhosted.org/packages/fa/da/7a47b7c2106bb10e6d4c04a139d045257a4f93c672fae6f0b9e92b1f7bc2/httptools-0.9.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6b1ac7f1bc6c0dbf90684b77571a51a21b2463909fd916ce0ac9bfc4d566dc75", size = 516079, upload-time = "2026-10-09T19:54:57.938Z" }, + { url = "https://files.pythonhosted.org/packages/0f/4d/417b42d2663acf4f5aeb2718dc894ec2be4e3dcfd8caa2d3bf9ee2dce511/httptools-0.9.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:b9430f65db521db7962ad951571d446171213686f96c998a54dc18ed574821e2", size = 535040, upload-time = "2026-10-09T19:54:59.769Z" }, + { url = "https://files.pythonhosted.org/packages/cb/de/8df4c09a33ddaf50f697719f20201cf93631ef4b50cec05e42acf179a7c1/httptools-0.9.0-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:52fe0176682a25b15370f23f5b0f1366a84771df89144fb0cd979cb72a94b5ca", size = 462799, upload-time = "2026-10-09T19:55:01.673Z" }, + { url = "https://files.pythonhosted.org/packages/e8/90/1bfe91e3fca29c541d85d7ba8ed92a406d4dd13608c281baf7ec75369fec/httptools-0.9.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:757e3f79cb865a7db94e0db5f4d0ed3284a69e39d53568f433982ea13c60cac1", size = 497596, upload-time = "2026-10-09T19:55:03.201Z" }, + { url = "https://files.pythonhosted.org/packages/b0/af/2bbd5af0dd7a0e0c3b63bfefafd87a07041eb13d7cd710fbf30708b70773/httptools-0.9.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:6ff5f0ed70783dcb9562dbd20edca51c3d4d277f128223709e3da6b75986d1d4", size = 517110, upload-time = "2026-10-09T19:55:05.011Z" }, + { url = "https://files.pythonhosted.org/packages/d4/7a/9f165817c3e27df9098f3d50a675417d8721253f1073434f48a3f9d9a6c2/httptools-0.9.0-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:c0f537e5e8152e8d9cae82804024790cb973061abd3b7ef8f66f46e2b5c7bb51", size = 459198, upload-time = "2026-10-09T19:55:06.985Z" }, + { url = "https://files.pythonhosted.org/packages/93/20/b93279e334946c359d39aaf405241c6fd60f9e60da709bc4156731a4413c/httptools-0.9.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:1a7f1df31829c258158be01bb04eb668c4fba7df1ddf2262131a972962e651b6", size = 502996, upload-time = "2026-10-09T19:55:08.733Z" }, + { url = "https://files.pythonhosted.org/packages/86/c9/ac3657943d40c5a9949b72565ee03151e480fb18c062c7c13c0c0276df6f/httptools-0.9.0-cp313-cp313-win32.whl", hash = "sha256:714bf348f468532d86bed670837e7d5ddff3834dd7f5d3c08066da400c86f088", size = 85878, upload-time = "2026-10-09T19:55:10.275Z" }, + { url = "https://files.pythonhosted.org/packages/74/69/d23079cd4bc16d11e49c3f51c2540c018736f26701a2a73183cae9255a1c/httptools-0.9.0-cp313-cp313-win_amd64.whl", hash = "sha256:805b0f2618e5d4c3e28f45b731eb1a0539691ae4a2f97b4ce014de0bf96a1ff5", size = 91549, upload-time = "2026-10-09T19:55:11.701Z" }, + { url = "https://files.pythonhosted.org/packages/0b/ed/5ff678a774b721f054c095f04d84fc536e7369ea4f4c9af3813a518d95b6/httptools-0.9.0-cp313-cp313-win_arm64.whl", hash = "sha256:bfdabac0c6d3d6a5be8c2a100a001c92c14a39bbafd5999545a675c493626e64", size = 88043, upload-time = "2026-10-09T19:55:13.046Z" }, +] + [[package]] name = "httpx" version = "0.28.1" @@ -838,6 +888,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/cb/b1/3846dd7f199d53cb17f49cba7e651e9ce294d8497c8c150530ed11865bb8/iniconfig-2.3.0-py3-none-any.whl", hash = "sha256:f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12", size = 7484, upload-time = "2025-10-18T21:55:41.639Z" }, ] +[[package]] +name = "itsdangerous" +version = "2.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/9c/cb/8ac0172223afbccb63986cc25049b154ecfb5e85932587206f42317be31d/itsdangerous-2.2.0.tar.gz", hash = "sha256:e0050c0b7da1eea53ffaf149c0cfbb5c6e2e2b69c4bef22c81fa6eb73e5f6173", size = 54410, upload-time = "2024-04-16T21:28:15.614Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/96/92447566d16df59b2a776c0fb82dbc4d9e07cd95062562af01e408583fc4/itsdangerous-2.2.0-py3-none-any.whl", hash = "sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef", size = 16234, upload-time = "2024-04-16T21:28:14.499Z" }, +] + [[package]] name = "jinja2" version = "3.1.6" @@ -1175,6 +1234,45 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/81/08/7036c080d7117f28a4af526d794aab6a84463126db031b007717c1a6676e/multidict-6.7.1-py3-none-any.whl", hash = "sha256:55d97cc6dae627efa6a6e548885712d4864b81110ac76fa4e534c03819fa4a56", size = 12319, upload-time = "2026-01-26T02:46:44.004Z" }, ] +[[package]] +name = "narwhals" +version = "2.27.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/bf/21/f64d6b2dbea7bf3f8c38cdc786dcc6ef012ca3d173ad208c782c9a7bedf6/narwhals-2.27.1.tar.gz", hash = "sha256:aed93076a3ea42d9c32c88e4eb5ea422a21937011cbe1f480f9572a523c82094", size = 735013, upload-time = "2026-10-10T06:52:18.113Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/89/5d4c86da1130d9059681e5b6cd7645df5c10279a6a079c5c37dcb2cc6f3f/narwhals-2.27.1-py3-none-any.whl", hash = "sha256:d057df13f5852b8e157596e82eb5e955fad267425df5e420e0ee9863da483b31", size = 483211, upload-time = "2026-10-10T06:52:16.32Z" }, +] + +[[package]] +name = "numpy" +version = "2.5.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/95/b0/c7453d0b6e2073c3264468b106ee1563750cecc910965e67357e3698c83e/numpy-2.5.4.tar.gz", hash = "sha256:9a94cf751c9ad8ebaa835bcd3d40dacf8534ad086b88c38029b65123c7999d2a", size = 20866315, upload-time = "2026-10-10T20:05:31.422Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d0/97/ba2074e92b7befea137e77ea8471e768bbd87c339b7e8c9f5a931949f977/numpy-2.5.4-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:c6342f54c67093cae5c0227eb0eb772fdb79f2a2c37a6eb278b9909ee06aa356", size = 17001609, upload-time = "2026-10-10T20:02:40.843Z" }, + { url = "https://files.pythonhosted.org/packages/ff/a9/bac826765e971d8e16e2064e9ac7525fd69b40ac17c905033a7f5442023f/numpy-2.5.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b11e8fda06a7d69f15ebf542660b74466c2e51094800c1fb794f47ad4faeef17", size = 12015718, upload-time = "2026-10-10T20:02:43.45Z" }, + { url = "https://files.pythonhosted.org/packages/31/2f/5ea3570fcb8ccd0882bea99436a513b2c85dad8f774a2057849130a8fb99/numpy-2.5.4-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:9cb18a327b49c5c337f972b03682f6a49855525faaf3c0d3e9c96cd0fd8880a8", size = 5451717, upload-time = "2026-10-10T20:02:46.169Z" }, + { url = "https://files.pythonhosted.org/packages/34/f2/b4fc1bafca03868220b5eaf729d2f21ebd7d7b151c0f9e144fe212bbca35/numpy-2.5.4-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:aec3fc4b32ff82421274f5d205c559c51c840c8df66a78efd7f3612dd005a26a", size = 6789926, upload-time = "2026-10-10T20:02:48.139Z" }, + { url = "https://files.pythonhosted.org/packages/dc/96/8319e2457ae4333c62c815c7006b869a4f60985c1e01024c2f8c6c040fe5/numpy-2.5.4-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:fe4d21ab149f15e4e6043dfb0de87e6e5f34ac176cde83060e9802981fca2ac2", size = 15695312, upload-time = "2026-10-10T20:02:50.115Z" }, + { url = "https://files.pythonhosted.org/packages/43/a3/c799c62e19c337e6d3770b08e475887fb30ce8477d3c09efca6b2f0228a6/numpy-2.5.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fbde6962867ee75b48b0ee29b2b9372ec5d617799dbaf38e82dc0596f2f7738a", size = 16727283, upload-time = "2026-10-10T20:02:53.186Z" }, + { url = "https://files.pythonhosted.org/packages/39/6b/3604e53fb00314d0dc1b94ec9125a1484f649c0a17480b1f0f0c7a9d6250/numpy-2.5.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:381a7a3d2e65e64c0ec302795ab9dc12bb1e73f150904699c153716177eebdaf", size = 17047890, upload-time = "2026-10-10T20:02:56.038Z" }, + { url = "https://files.pythonhosted.org/packages/4a/7a/e8b58a5289a0d464c52885de47c35a935cdd70c03a4c3ab94a5126416dd0/numpy-2.5.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b89d0aaae2fe498c648f4c4795c084db535af5bd98ef942b2a3681fb74ce8645", size = 18485839, upload-time = "2026-10-10T20:02:59.018Z" }, + { url = "https://files.pythonhosted.org/packages/6f/c9/47094f597015009f310b8c900def59065ef1ff5a6fe7b51fc65ec58ec2c6/numpy-2.5.4-cp312-cp312-win32.whl", hash = "sha256:9968ab7e49b93ac6e1c3b2239732183152c9150f16308d30b66a372cffe3483c", size = 6138936, upload-time = "2026-10-10T20:03:01.626Z" }, + { url = "https://files.pythonhosted.org/packages/12/33/fefe62073dc8acfd0f2b9ed7c003af2f50aa61555e113e6db02b8f79f145/numpy-2.5.4-cp312-cp312-win_amd64.whl", hash = "sha256:a7b1b6353e36a7e50de2973a38d705c88ee93adcf120673cee7f45a4a3fa223a", size = 12573091, upload-time = "2026-10-10T20:03:04.349Z" }, + { url = "https://files.pythonhosted.org/packages/1a/07/161270b0c2eec56e4c905f6d6d22e1b836887b2cb189d3f5820aa588e9dd/numpy-2.5.4-cp312-cp312-win_arm64.whl", hash = "sha256:aa1cce2ff3f8d953de38b76bf44602caeb69f101430208f64a10067f7cb4b1d3", size = 10521630, upload-time = "2026-10-10T20:03:06.767Z" }, + { url = "https://files.pythonhosted.org/packages/67/14/1c3ee0118a8fce08565a5d8482631608426a33af10a01077fada5dc7c119/numpy-2.5.4-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:2377da2dd3ba2c1200956acbab2a358c83b8e1f8531191672d1cd6ad83250d53", size = 16997729, upload-time = "2026-10-10T20:03:09.291Z" }, + { url = "https://files.pythonhosted.org/packages/83/8c/b0ea9477fb1f0d4484bbc5cba21678cc9969704d8d7f3f158d1db35f8e14/numpy-2.5.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:7415db95818b39ec475a5eea54d9e3b6bc83e3912158e46da3438cdce399804d", size = 12009826, upload-time = "2026-10-10T20:03:11.946Z" }, + { url = "https://files.pythonhosted.org/packages/e2/84/6a3d75b3ba3dfe84ac0053450753d1e6d250a8bf80f66474cc46d1fb643f/numpy-2.5.4-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:6d6a71b9d9a97c03633aa12565ef2825ffa036cc1d99cfd50dacf0f128af4fe2", size = 5445803, upload-time = "2026-10-10T20:03:14.329Z" }, + { url = "https://files.pythonhosted.org/packages/61/18/bb993f267ca20b376e07092a16793a5b31ed3138751e9ba480011a14d742/numpy-2.5.4-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:d8200f16437b289a5bb927c6e184eccc3e8389bc0070fea4cd5b9e13c1757959", size = 6786220, upload-time = "2026-10-10T20:03:16.602Z" }, + { url = "https://files.pythonhosted.org/packages/db/b6/135bb0953b61dc21c6cafa14b424ae666944e4899cf140e00c2b322a1a45/numpy-2.5.4-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1c2e71b04c6cad90026e544501bbe0ab9290fa8a4d845e7e8c0d124fb429c988", size = 15689178, upload-time = "2026-10-10T20:03:18.721Z" }, + { url = "https://files.pythonhosted.org/packages/da/24/3bd070f3269dc609d8f26b2643f62ef91bb415841c0b294805aaf7fe06da/numpy-2.5.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6ffa07666f8da0eef81d149934a626d0d95fbd6838432a33e66245423a9062c0", size = 16718044, upload-time = "2026-10-10T20:03:21.386Z" }, + { url = "https://files.pythonhosted.org/packages/c7/8e/9d15bd356b0a019c965312b1a3c6a727cac4cae5bc40045fbc12ce4cff9c/numpy-2.5.4-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:2fa3328f784fc8277fc48026f6cad516f5c561c5d8e2e39b3c9e0c8f23223b34", size = 17048364, upload-time = "2026-10-10T20:03:24.468Z" }, + { url = "https://files.pythonhosted.org/packages/dc/fe/9d5b560db964f15871885f2250795d15945f8699e17ef90c0c2ff4c875b2/numpy-2.5.4-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:b86966fbe4ad7de710422175572bcdc75fdedadfb54bc6fab7deabccddd7780b", size = 18474904, upload-time = "2026-10-10T20:03:27.895Z" }, + { url = "https://files.pythonhosted.org/packages/e9/98/d27552990f1bd611ef3e7466adadc78312ea2df63b83aad47fdc3d3ca8df/numpy-2.5.4-cp313-cp313-win32.whl", hash = "sha256:5258bc06526964be5face2fc6f756857a3f24f21ec3e72ca131337a75b165d6c", size = 6134537, upload-time = "2026-10-10T20:03:30.511Z" }, + { url = "https://files.pythonhosted.org/packages/90/8c/140a40398a66b4471211be1affdb6ed24c486d581bd28d07b7f2fcb69540/numpy-2.5.4-cp313-cp313-win_amd64.whl", hash = "sha256:8b4d2fd2d34e5f8c9235ee787de5631a37a28402b15cb80814df973d2be54129", size = 12566113, upload-time = "2026-10-10T20:03:32.612Z" }, + { url = "https://files.pythonhosted.org/packages/34/52/01d205e5e8ccb27b2b0b141e801f22b830198c979111b0fa44771438d9a9/numpy-2.5.4-cp313-cp313-win_arm64.whl", hash = "sha256:bc39ac66a7a9a3fbd6134fda43136b60ffde99c8f4501e64e0d2b24da137babf", size = 10519523, upload-time = "2026-10-10T20:03:35.163Z" }, +] + [[package]] name = "oauthlib" version = "4.0.0" @@ -1221,6 +1319,36 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/df/b2/87e62e8c3e2f4b32e5fe99e0b86d576da1312593b39f47d8ceef365e95ed/packaging-26.2-py3-none-any.whl", hash = "sha256:5fc45236b9446107ff2415ce77c807cee2862cb6fac22b8a73826d0693b0980e", size = 100195, upload-time = "2026-04-24T20:15:22.081Z" }, ] +[[package]] +name = "pandas" +version = "3.0.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "numpy" }, + { name = "python-dateutil" }, + { name = "tzdata", marker = "sys_platform == 'emscripten' or sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e2/17/d7b106e05bfa642e8694451e7d3d759c6a241c5386a5d962e4f66c047e06/pandas-3.0.6.tar.gz", hash = "sha256:66b07ef7315a31bfe1089cd3d71a7de781c9dca986762d0b4fe7c0ef17465d10", size = 4667686, upload-time = "2026-09-17T23:23:18.345Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/77/4c/597d588c055d4373cff19cbbc32d4dd046c7be8fadee957585b5ba9e5b24/pandas-3.0.6-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7dac2d65e9087e8e7b5a45fe15c4920911a221df061ab629943ce016489145c7", size = 10397411, upload-time = "2026-09-17T23:20:49.465Z" }, + { url = "https://files.pythonhosted.org/packages/18/8f/48907c7c707b61a8e5018c32e1a3f70623209bfb59020a2f6196159d3aa7/pandas-3.0.6-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:9dab635a549e58a053c7b0fa054dc0bd7be22f0ed9a720f4a85d5fb993276172", size = 10051279, upload-time = "2026-09-17T23:20:52.409Z" }, + { url = "https://files.pythonhosted.org/packages/67/fa/613d867c3d9554a61bafdec6f79565c8a3e73235feb52cc4a72ad2e0fa6a/pandas-3.0.6-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e3dccb584123b399c07562ac4d62543e90ede49ddf8ce3c13ffc64cbe828c281", size = 10303429, upload-time = "2026-09-17T23:20:55.597Z" }, + { url = "https://files.pythonhosted.org/packages/cb/67/0c0f18e38d7f2d2af8c24b3315bc4046e73bbdd4a5540405506671ad0c0d/pandas-3.0.6-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0704044b676496b8350e023b09f174a26772456c974a2b11c36bebb558c9490d", size = 10788193, upload-time = "2026-09-17T23:20:58.617Z" }, + { url = "https://files.pythonhosted.org/packages/39/53/1b57f3162501fe36687e4870e1b918a6458ca7386b173af75663ace95857/pandas-3.0.6-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e7c1905ef02c3d6d43d9dbd5b6ccb4da4870a0b0c821bbc103fbdb6f3ad2707b", size = 11323501, upload-time = "2026-09-17T23:21:01.911Z" }, + { url = "https://files.pythonhosted.org/packages/f2/d2/b1182e8d39100369d7f13f4a125a3fb6b096fef112c46d0566c25781ff68/pandas-3.0.6-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:569e114072b24fc4970c12e2b4bab252671668a40b324318903380cab0254c0c", size = 11838173, upload-time = "2026-09-17T23:21:04.85Z" }, + { url = "https://files.pythonhosted.org/packages/c7/33/5b717af24d2f27995e51e0875a269dddd373045216e34cf62e3aa764eaa1/pandas-3.0.6-cp312-cp312-pyemscripten_2024_0_wasm32.whl", hash = "sha256:2a8fc94be2ee5f1d86f97aacd8cc566f81680b6498e76f3007421bb5d98151bf", size = 7118499, upload-time = "2026-09-17T23:21:07.661Z" }, + { url = "https://files.pythonhosted.org/packages/bd/2a/14b3b17cd75cef4a1ee1af4234eb41cc1afe4103b98c2d80e8916abfd42b/pandas-3.0.6-cp312-cp312-win_amd64.whl", hash = "sha256:3ef908d28590b3f42d7070e7ad8f9b34b442b260b7f3c1afb57e0040c58cdb1b", size = 9661439, upload-time = "2026-09-17T23:21:10.959Z" }, + { url = "https://files.pythonhosted.org/packages/3b/11/3d580a604a1e35d69f6676847bd12db7d14344bc677b717f4413e79c5d0d/pandas-3.0.6-cp312-cp312-win_arm64.whl", hash = "sha256:f4e7c52eb108d752e7592268108fd3e98efd76d83a3125cdd06c621c2e44359b", size = 8959806, upload-time = "2026-09-17T23:21:13.851Z" }, + { url = "https://files.pythonhosted.org/packages/8e/1c/143605a1f6443ad50ebda78a31e5a3a10147fec2590e931584aaa5ff0a09/pandas-3.0.6-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:9ae8073aed8e21d1a7fe263dcdc6840743549722a6738198a0a46000fa9476f2", size = 10418900, upload-time = "2026-09-17T23:21:16.594Z" }, + { url = "https://files.pythonhosted.org/packages/ea/ca/87f8548f73d452aab35e4a90f8b39ae303295e0f2ef0b4055c44d6b3f1be/pandas-3.0.6-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:60d81f9e1799b36f3739e7fff44d1fbb2e8fd5a271b3863e03de9715fccda0fa", size = 10064785, upload-time = "2026-09-17T23:21:19.677Z" }, + { url = "https://files.pythonhosted.org/packages/43/1a/d951442e5607c6e3b2462eff8f420797d428aa74b87c6ecfe4f48553626e/pandas-3.0.6-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:097090508a1dd335013d39106fc10b20f4fd4a171638e47b77d55798ed9dab6c", size = 10245290, upload-time = "2026-09-17T23:21:22.797Z" }, + { url = "https://files.pythonhosted.org/packages/50/fa/96d50e1e6cd0b08b5e2b7c838f65ae644940f75a124063380b5ef73b6866/pandas-3.0.6-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1e92d9fa834c7d877130027cddc0cad8dcff97c1f6cca26bd6310f847228b658", size = 10757657, upload-time = "2026-09-17T23:21:25.673Z" }, + { url = "https://files.pythonhosted.org/packages/7b/12/f82d13a2cb703e1a8acee7e01fdc2b898d9cd0c00f07d1dfce63af43e350/pandas-3.0.6-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:b27c8d890e4aa2171437ae2a39de1d215e674158e4865c4023a8b31c932513b2", size = 11249114, upload-time = "2026-09-17T23:21:28.898Z" }, + { url = "https://files.pythonhosted.org/packages/1a/ce/8aef2e561a2f2c8b38c913c67373c65ba6748174e763d27c80271b24bd17/pandas-3.0.6-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:f8029ec0f1f89e4f985929ce1f6626dabf3140d61a4e9c1215afdab34eaf9a5d", size = 11820511, upload-time = "2026-09-17T23:21:32.11Z" }, + { url = "https://files.pythonhosted.org/packages/c0/bd/63cb67e6903ef6d9c2871916dbcbc09d254da0fe8b870cf62e16b21945f2/pandas-3.0.6-cp313-cp313-win_amd64.whl", hash = "sha256:f3ce8a6968045481e91a3990e797e348ce13db45ee164a7095bbc824e26c09dd", size = 9638092, upload-time = "2026-09-17T23:21:34.883Z" }, + { url = "https://files.pythonhosted.org/packages/75/2e/e7b35b712edb068d382ddc8b2bea8a04974100515ba2daa22b478b265842/pandas-3.0.6-cp313-cp313-win_arm64.whl", hash = "sha256:cc39303913e2ea129915670de5d1c9fbd647f543bb72e5543bac8baa94e9e42f", size = 8952032, upload-time = "2026-09-17T23:21:37.729Z" }, +] + [[package]] name = "pathspec" version = "1.1.1" @@ -1230,6 +1358,35 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/f1/d9/7fb5aa316bc299258e68c73ba3bddbc499654a07f151cba08f6153988714/pathspec-1.1.1-py3-none-any.whl", hash = "sha256:a00ce642f577bf7f473932318056212bc4f8bfdf53128c78bbd5af0b9b20b189", size = 57328, upload-time = "2026-04-27T01:46:07.06Z" }, ] +[[package]] +name = "pillow" +version = "12.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/1c/3d/bb7fca845737cf9d7dbde16ed1843984665ff2e0a518f5db43e77ec540b9/pillow-12.3.0.tar.gz", hash = "sha256:3b8182a766685eaa002637e28b4ec8d6b18819a0c71f579bf0dbaa5830297cce", size = 47025035, upload-time = "2026-07-01T11:56:38.965Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/37/bf/fb3ebff8ddcb76aac5a01389251bbbb9519922a9b520d8247c1ca864a25d/pillow-12.3.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:ba09209fbe443b4acccebe845d8a138b89a8f4fbaeedd44953490b5315d5e965", size = 5345969, upload-time = "2026-07-01T11:54:06.397Z" }, + { url = "https://files.pythonhosted.org/packages/d8/66/9a386a92561f402389a4fc70c18838bf6d35eb5eb5c6850b4b2dc64f5048/pillow-12.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ffd0c5368496f41b0944be820fcb7a838aa6e623d250b01acf2643939c3f99d7", size = 4780323, upload-time = "2026-07-01T11:54:09.351Z" }, + { url = "https://files.pythonhosted.org/packages/25/27/ac8f99618ffd3dde21db0f4d4b1d2ab00c0880595bfd17df103f7f39fd0c/pillow-12.3.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d9c7f76c0673154f044e9d78c8655fb4213f6ca31a836df48b40fe5d187717b9", size = 6266838, upload-time = "2026-07-01T11:54:11.71Z" }, + { url = "https://files.pythonhosted.org/packages/84/21/a35af28dcc61f37ed850a2d64c65c701321dfbf25085e469d5559360cbbf/pillow-12.3.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:78cb2c6865a35ab8ff8b75fd122f6033b92a62c82801110e48ddd6c936a45d91", size = 6940830, upload-time = "2026-07-01T11:54:13.732Z" }, + { url = "https://files.pythonhosted.org/packages/eb/51/8b08617af3ad95e33ce6d7dd2c99ed6c8298f7fb131636303956be022e25/pillow-12.3.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e491916b378fba47242221bb9ead245211b70d504f495d105d17b14a24b4907c", size = 6344383, upload-time = "2026-07-01T11:54:15.756Z" }, + { url = "https://files.pythonhosted.org/packages/1d/72/cf78ac9780bb93c28328f408973845a309d4d145041665f734572ced1b52/pillow-12.3.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:0dd2064cbc55aaec028ef5fbb60fa47bb6c3e7918e07ff17935284b227a9d2df", size = 7052934, upload-time = "2026-07-01T11:54:17.721Z" }, + { url = "https://files.pythonhosted.org/packages/20/20/25e0f4dc178a6bc0696793720055519a0de89e7661dae886992decbd2f81/pillow-12.3.0-cp312-cp312-win32.whl", hash = "sha256:dbce0b29841537a2fa4a214c2bbf14de3587c9680caa9b4e217568472490b28f", size = 6472684, upload-time = "2026-07-01T11:54:19.839Z" }, + { url = "https://files.pythonhosted.org/packages/45/89/da2f7971a317f83d807fdd4065c0af40208e59e692cc43d315a71a0e96d1/pillow-12.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:a2b55dd6b2a4c4b7d87ffa56bdb33fdc5fdb9a462173861a7bc097f17d91cb09", size = 7227137, upload-time = "2026-07-01T11:54:22.025Z" }, + { url = "https://files.pythonhosted.org/packages/de/47/4845a0a6c0dbf1db8456bd9fc791f13c5ced7ced20606d08a0aacfd25b49/pillow-12.3.0-cp312-cp312-win_arm64.whl", hash = "sha256:331b624368d4f1d069149002f25f44bc61c8919ce8ddb3c45bdad8f6e2d89510", size = 2568267, upload-time = "2026-07-01T11:54:24.051Z" }, + { url = "https://files.pythonhosted.org/packages/9d/ac/31fb64e1e7efb5a4b50cd3d92049ba89ac6e4d8d3bb6a74e15048ca3353e/pillow-12.3.0-cp313-cp313-ios_13_0_arm64_iphoneos.whl", hash = "sha256:21900ce7ba264168cd50defae43cd75d25c833ad4ad6e73ffc5596d12e25ac89", size = 4161684, upload-time = "2026-07-01T11:54:25.934Z" }, + { url = "https://files.pythonhosted.org/packages/87/b4/9805e23d2b4d77842b468513841fda254ee42f0289d25088340e4ff46e2d/pillow-12.3.0-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:4e8c2a84d977f50b9daed6eeaf3baef67d00d5d74d932288f02cb94518ee3ace", size = 4255487, upload-time = "2026-07-01T11:54:27.935Z" }, + { url = "https://files.pythonhosted.org/packages/df/39/ecf519435a200c693fe053a6ee4d835b41cf963a4dfc2551c4e637cb2a71/pillow-12.3.0-cp313-cp313-ios_13_0_x86_64_iphonesimulator.whl", hash = "sha256:ae26d61dfa7a47befdc7572b521024e8745f3d809bd95ca9505a7bba9ef849ec", size = 3696433, upload-time = "2026-07-01T11:54:29.813Z" }, + { url = "https://files.pythonhosted.org/packages/42/92/2fc3ffad878ae8dd5469ec1bc8eb83b71f48e13efdf68f02709003982a32/pillow-12.3.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:7a743ff716f746fc19a9557f60dab1600d4613255f8a7aeb3cdde4db7eb15a66", size = 5345889, upload-time = "2026-07-01T11:54:31.97Z" }, + { url = "https://files.pythonhosted.org/packages/10/76/8803c13605b763d33d156c4678fc77f8443389c0c51c8aef707bb02015f4/pillow-12.3.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:d69141514cc30b774ceea5e3ed3a6635c8d8a96edf664689b890f4089111fb35", size = 4780109, upload-time = "2026-07-01T11:54:34.026Z" }, + { url = "https://files.pythonhosted.org/packages/1f/01/e18aff37cb0b4aac47ac90f016d347a49aca667ef97f190b06ac2aabc928/pillow-12.3.0-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f7401aebd7f581d7f83a439d87d474999317ee099218e5ad25d125290990ba65", size = 6263736, upload-time = "2026-07-01T11:54:36.131Z" }, + { url = "https://files.pythonhosted.org/packages/f7/62/de5bdd77d935331f4f802edc11e4d82950f642caad6cb2f949837b8560e2/pillow-12.3.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0847a763afefb695bc912d7c131e7e0632d4edc1d8698f58ddabec8e46b8b6d3", size = 6937129, upload-time = "2026-07-01T11:54:38.216Z" }, + { url = "https://files.pythonhosted.org/packages/70/4d/105627a13300c5e0df1d174230b32fd1273062c96f7745fd552b945d1e1d/pillow-12.3.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:571b9fcb07b97ef3a492028fb3d2dc0993ca23a06138b0315286566d29ef718a", size = 6339562, upload-time = "2026-07-01T11:54:40.354Z" }, + { url = "https://files.pythonhosted.org/packages/6b/1d/f13de01a553988ab895ba1c722e06cf3144d4f57656fd5b81b6d881f1179/pillow-12.3.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:756c768d0c9c2955feb7a56c37ea24aea2e369f8d36a88da270b6a9f19e62b5e", size = 7049439, upload-time = "2026-07-01T11:54:42.489Z" }, + { url = "https://files.pythonhosted.org/packages/c9/f9/066794cca041b969964f779ee5fa66a9498bbf34248ac39c5d7954e4198f/pillow-12.3.0-cp313-cp313-win32.whl", hash = "sha256:a876864214e136f0eb367788dbd7df045f4806801518e2cfe9e13229cfe06d8f", size = 6473287, upload-time = "2026-07-01T11:54:44.9Z" }, + { url = "https://files.pythonhosted.org/packages/a6/9b/7a58e61d62be561da3a356fe2384d4059a6345fc130e23ef1c36a5b81d24/pillow-12.3.0-cp313-cp313-win_amd64.whl", hash = "sha256:1cca606cd25738df4ed873d5ad46bbdb3d83b5cbca291f6b4ff13a4df6b0bbe8", size = 7239691, upload-time = "2026-07-01T11:54:47.141Z" }, + { url = "https://files.pythonhosted.org/packages/aa/b0/c4ed4f0ef8f8fa5ee8351537db6650bb8189f7e118842978dd6589065692/pillow-12.3.0-cp313-cp313-win_arm64.whl", hash = "sha256:b629de27fda84b42cde7edef0d85f13b958b47f6e9bbcbba9b673c562a89bd8b", size = 2568185, upload-time = "2026-07-01T11:54:49.137Z" }, +] + [[package]] name = "pip" version = "26.2.1" @@ -1379,6 +1536,21 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/3a/ed/1cdcab6ba3d6ab7feca11fc14f0eeea80755bb53ef4e892079f31b10a25f/propcache-0.5.2-py3-none-any.whl", hash = "sha256:be1ddfcbb376e3de5d2e2db1d58d6d67463e6b4f9f040c000de8e300295465fe", size = 14036, upload-time = "2026-05-08T21:02:10.673Z" }, ] +[[package]] +name = "protobuf" +version = "7.36.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d9/89/5b8517baa72f84a67b8a307ba953c91057af618bf40bf676f3c03551f8f0/protobuf-7.36.2.tar.gz", hash = "sha256:497d0463ff3316681da6c0b9e8d06cb465d61abce00b613ab42226175644d1bb", size = 512737, upload-time = "2026-09-17T20:07:59.326Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/32/72/98342feb672507c8f3a69e34b4fa8961f608edba5c1a48a6f47156d92cb5/protobuf-7.36.2-cp310-abi3-macosx_10_9_universal2.whl", hash = "sha256:cbc70b17ee27e28894c7fee8bb04be1abead49e936bc70eb60052531eee2079e", size = 456039, upload-time = "2026-09-17T20:07:51.542Z" }, + { url = "https://files.pythonhosted.org/packages/b6/ea/91fdf7c2b8bbd49cde056f00a9df6773532987e1c00fe2830b895af95c7e/protobuf-7.36.2-cp310-abi3-manylinux2014_aarch64.whl", hash = "sha256:e11e1f0180583a2af89db6a2ecd9e8dc40aa6d2988ca175bfd0e6d12ea72d74e", size = 344219, upload-time = "2026-09-17T20:07:52.914Z" }, + { url = "https://files.pythonhosted.org/packages/17/ab/5fd5f8ece73fad885c5a09aa849b32d70472f954ba3a92d3bb5974ea953b/protobuf-7.36.2-cp310-abi3-manylinux2014_s390x.whl", hash = "sha256:f4fee11ec330d238b34a05c9b675f693c20415d1c5bd7d5320cc2f8a798eb9cf", size = 357223, upload-time = "2026-09-17T20:07:53.985Z" }, + { url = "https://files.pythonhosted.org/packages/db/f3/3996583dd2906297a637af12114deddf7658af6e683fedb83be061983fb5/protobuf-7.36.2-cp310-abi3-manylinux2014_x86_64.whl", hash = "sha256:89f23aa53c24553a2416fd4fd1ec06f74fa42b14b546d8883128813f775bbfd2", size = 343223, upload-time = "2026-09-17T20:07:54.931Z" }, + { url = "https://files.pythonhosted.org/packages/fc/1b/dcc64f358fcb51811b58ae40b3d28f820725f116d86487cc20bd4b130701/protobuf-7.36.2-cp310-abi3-win32.whl", hash = "sha256:912c1221170e16c08d1f086762f563dd61ff83c18b5fa6652952dfaded66f728", size = 442998, upload-time = "2026-09-17T20:07:55.826Z" }, + { url = "https://files.pythonhosted.org/packages/8a/55/b77bda4e5e5f5971fb51b07663694690e9afdb9402136c16a522bd621cad/protobuf-7.36.2-cp310-abi3-win_amd64.whl", hash = "sha256:a300819d441e078a5608c0d3c709796bb548136058fda017ae51d425b44fd353", size = 456514, upload-time = "2026-09-17T20:07:57.188Z" }, + { url = "https://files.pythonhosted.org/packages/e4/04/d52c7016b04b6c5108f26691f9d33ec82a9b65d041f1a9c771137693d618/protobuf-7.36.2-py3-none-any.whl", hash = "sha256:bdb3a345d48db958e6ce1f18e508beb0cc981d64f24088427549c866cd039f1e", size = 179806, upload-time = "2026-09-17T20:07:58.211Z" }, +] + [[package]] name = "py-serializable" version = "2.1.0" @@ -1391,6 +1563,28 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/9b/bf/7595e817906a29453ba4d99394e781b6fabe55d21f3c15d240f85dd06bb1/py_serializable-2.1.0-py3-none-any.whl", hash = "sha256:b56d5d686b5a03ba4f4db5e769dc32336e142fc3bd4d68a8c25579ebb0a67304", size = 23045, upload-time = "2025-07-21T09:56:46.848Z" }, ] +[[package]] +name = "pyarrow" +version = "25.0.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/3d/e3/27f57f80141379d60defe6703eb50a707325706f07fedfd1312c7a751995/pyarrow-25.0.1.tar.gz", hash = "sha256:9150a83248bfed9813ea3c3af74c3856c1984d444aa28e58bf7733b9750ddf6a", size = 1201653, upload-time = "2026-08-10T12:40:53.904Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a6/e2/9ab15b88cbfac28e16419ce5439ec29234c5172cb8259301b4ba639bdec0/pyarrow-25.0.1-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:df961f2e7ae9cf496459259d798652c70625f6c080650d6952f8c04053c58ee9", size = 35861559, upload-time = "2026-08-10T12:38:02.567Z" }, + { url = "https://files.pythonhosted.org/packages/58/79/a0036dbe1eabe1f73127427342f1d99982584c4a2cde2651d6c93499c6f6/pyarrow-25.0.1-cp312-cp312-macosx_12_0_x86_64.whl", hash = "sha256:cc4aa407fde9fc660be3939e49ea31f50f3e9fec17c0ec63159f7711edd3efc9", size = 37628383, upload-time = "2026-08-10T12:38:09.083Z" }, + { url = "https://files.pythonhosted.org/packages/13/49/d93a57d375f4bf0cf82913dd6bb54acafde83dd993be2282c81ac5616cad/pyarrow-25.0.1-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:4340f0ba6c1d2e13f21658de1d7c662ca2545018568d0030a1e9afca159d87e3", size = 46820190, upload-time = "2026-08-10T12:38:15.458Z" }, + { url = "https://files.pythonhosted.org/packages/60/c9/711ca85d79f1ec98f29a5eae2b051e25b4ecec5de3e3c0e2d5c5dcb15664/pyarrow-25.0.1-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:5389cdf79447ed1515c9e31620e6e1e2302249564d603f2ad727d4f6d313e4c3", size = 50102437, upload-time = "2026-08-10T12:38:22.487Z" }, + { url = "https://files.pythonhosted.org/packages/80/53/8fb8359ff17cfb6263a1cf3ebf7caec9fe197de118719e84fcb1d0618026/pyarrow-25.0.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:d51592cb7561e87877c506113e7adbf1342ab579e6c21f0ef44b8ba41cb74c80", size = 49942424, upload-time = "2026-08-10T12:38:28.755Z" }, + { url = "https://files.pythonhosted.org/packages/e8/83/4e5ae02a9341571b18a6fca380ac7a58ce6ddae7ab3c060208c0a1e79f02/pyarrow-25.0.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:6109c94d8b9f3b17a041daca16cacb2f651ad8f1ef70a4232c2c0f37a23da2a8", size = 53144206, upload-time = "2026-08-10T12:38:34.862Z" }, + { url = "https://files.pythonhosted.org/packages/65/ee/197cbf47e49f83e6ebeb946a5259a48a638dea27ac774db42fe78022179d/pyarrow-25.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:8858d7bfc22e3f51529aeaa4077225029724623e4595dc9eff8c793935c34140", size = 27953934, upload-time = "2026-08-10T12:38:39.808Z" }, + { url = "https://files.pythonhosted.org/packages/cc/8d/8f271a7a034c834910ec925d56fa4b29733b1380f5289419f5aaa3b02777/pyarrow-25.0.1-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:c7c534ec03c358a76ea3e505e74c1b6aef290af90c444dfd092dbfe23e755b85", size = 35855328, upload-time = "2026-08-10T12:38:45.489Z" }, + { url = "https://files.pythonhosted.org/packages/d2/cd/5bac242f4e841b9971d5eb94fdfe2577e2b70be983e27401e72055786037/pyarrow-25.0.1-cp313-cp313-macosx_12_0_x86_64.whl", hash = "sha256:dda9470024204d7bbf2042b47c6e8a0e47a3eeb8e34405882dfaea6577e0c153", size = 37622415, upload-time = "2026-08-10T12:38:51.107Z" }, + { url = "https://files.pythonhosted.org/packages/63/1f/96d03b4e1506524f7087adb0fd6b2f69f0c9c7aaff1ec36d8030082e15a5/pyarrow-25.0.1-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:44a9120ce5bd81936b8ab9a88076e3fd47c2c6838e0e43630fed83626aca81d9", size = 46813813, upload-time = "2026-08-10T12:38:57.773Z" }, + { url = "https://files.pythonhosted.org/packages/98/d6/33a411115b61dbfc16ad6ad73e71730f6fea654ee3667673bc53ab0e2fe7/pyarrow-25.0.1-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:0befcf816e45a1af33ac775a9970b749e4868a230c7372f0ae5e932bee27039f", size = 50104452, upload-time = "2026-08-10T12:39:04.579Z" }, + { url = "https://files.pythonhosted.org/packages/33/ae/b1b97c9ca87f9f9ddbb5230c798df94eccce61bd79b9b45458c69a478588/pyarrow-25.0.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:3f89685964f46e4216103c75483aac0c0692a5f72212d7ca835adba5ede56ce3", size = 49951343, upload-time = "2026-08-10T12:39:11.8Z" }, + { url = "https://files.pythonhosted.org/packages/98/9e/a112df5cfd5a68cb1d9fc31cfe38c28d5aec9f10865ce37ecef2e4450873/pyarrow-25.0.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:6943e2fe7954d29d84de45d29d34c8dc36ce96570e67d89aa9976e650a4a9138", size = 53144784, upload-time = "2026-08-10T12:39:20.503Z" }, + { url = "https://files.pythonhosted.org/packages/31/24/97e8bd98f1e3b07e2ba08bcdff690674fbe16d69a7d2712cc3884665e615/pyarrow-25.0.1-cp313-cp313-win_amd64.whl", hash = "sha256:31e49a7888fcdf3a835da33ae777f6bb9a866334e5a789282fc26dcf426f7f15", size = 27870159, upload-time = "2026-08-10T12:39:26.161Z" }, +] + [[package]] name = "pycparser" version = "3.0" @@ -1474,6 +1668,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/77/c1/6e422f34e569cf8e18df68d1939c81c099d2b61e4f7d9621c8a77560799c/pydantic_settings-2.14.2-py3-none-any.whl", hash = "sha256:a20c97b37910b6550d5ea50fbcc2d4187defe58cd57070b73863d069419c9440", size = 61715, upload-time = "2026-06-19T13:44:55.02Z" }, ] +[[package]] +name = "pydeck" +version = "0.9.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "jinja2" }, + { name = "numpy" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/f4/c9/f71032fca47ecc09d30904d9a610234b07139f89eabc2f054b141edcc30f/pydeck-0.9.3.tar.gz", hash = "sha256:695775cbfe51f5fdffbd9735ba469987fdc5efc96bc40a0ee4808170509c78b2", size = 5900912, upload-time = "2026-07-02T23:27:08.704Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6f/34/3998411437aff304a9ed4fa37a6fe1ef3132bcd2b5eac59851b80c86123c/pydeck-0.9.3-py2.py3-none-any.whl", hash = "sha256:d8a47c11c81fb12d51b1feb42427ff4f0e13cb599e48931021b2cba98b6849a6", size = 11428091, upload-time = "2026-07-02T23:27:06.399Z" }, +] + [[package]] name = "pygments" version = "2.20.0" @@ -1907,6 +2114,9 @@ all = [ { name = "pyjwt", extra = ["crypto"] }, { name = "python-dotenv" }, ] +dashboard = [ + { name = "streamlit" }, +] dev = [ { name = "build" }, { name = "httpx" }, @@ -1973,8 +2183,9 @@ requires-dist = [ { name = "skillevaluator", extras = ["llm"], marker = "extra == 'tier2'" }, { name = "skillevaluator", extras = ["llm"], marker = "extra == 'tier3'" }, { name = "skillevaluator", extras = ["tier2", "tier3", "security"], marker = "extra == 'all'" }, + { name = "streamlit", marker = "extra == 'dashboard'", specifier = ">=1.49,<2" }, ] -provides-extras = ["llm", "tier2", "tier3", "security", "all", "dev"] +provides-extras = ["llm", "tier2", "tier3", "security", "dashboard", "all", "dev"] [[package]] name = "sniffio" @@ -2044,6 +2255,37 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/2f/b2/60d86a3a99ae743e8a00a6df912f85269b3bc882ba217b8ce1690881c669/storage3-2.31.0-py3-none-any.whl", hash = "sha256:4bf46e8bea320743179a6beafdc7531c5242495e00e0cc22af7c7a9d69d4ed84", size = 28492, upload-time = "2026-06-04T13:37:22.792Z" }, ] +[[package]] +name = "streamlit" +version = "1.65.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "altair" }, + { name = "anyio" }, + { name = "click" }, + { name = "httptools" }, + { name = "itsdangerous" }, + { name = "numpy" }, + { name = "packaging" }, + { name = "pandas" }, + { name = "pillow" }, + { name = "protobuf" }, + { name = "pyarrow" }, + { name = "pydeck" }, + { name = "python-multipart" }, + { name = "requests" }, + { name = "starlette" }, + { name = "toml" }, + { name = "typing-extensions" }, + { name = "uvicorn" }, + { name = "watchdog", marker = "sys_platform != 'darwin'" }, + { name = "websockets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/8f/61/75c550a2d2acd79402aa1f32c8068c6cf47fa621d3995883a43caafeeadc/streamlit-1.65.0.tar.gz", hash = "sha256:42acd9ebdf3576a35584977c48a044ec0b5d3e4997fa9248809b9891598ac6a0", size = 9749831, upload-time = "2026-10-02T21:40:36.584Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fa/e3/5c9d2e88563c9974e53ac744b1523ebb1fd8f0ebb1ecc28a5f6f6bb0baea/streamlit-1.65.0-py3-none-any.whl", hash = "sha256:517a7254e223f4986d2b2e0745d02acf8ca64656943e63e422d345ce34a7495b", size = 10313469, upload-time = "2026-10-02T21:40:33.164Z" }, +] + [[package]] name = "strenum" version = "0.4.15" @@ -2261,6 +2503,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/dc/9b/47798a6c91d8bdb567fe2698fe81e0c6b7cb7ef4d13da4114b41d239f65d/typing_inspection-0.4.2-py3-none-any.whl", hash = "sha256:4ed1cacbdc298c220f1bd249ed5287caa16f34d44ef4e9c3d0cbad5b521545e7", size = 14611, upload-time = "2025-10-01T02:14:40.154Z" }, ] +[[package]] +name = "tzdata" +version = "2026.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d9/68/f1b440335057bfce71b6e50a9d09445aa2ecbd08359a337976627b8409e7/tzdata-2026.5.tar.gz", hash = "sha256:8cc73c0a0bfca7dbfa59235d60b2eff82231dee33f53d206db1acd9173cfc0a7", size = 200404, upload-time = "2026-10-03T09:23:14.143Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/94/21/1e5995a1c920cce14e4bffae20c665ec10e7ed03ab25e006cd741092b718/tzdata-2026.5-py2.py3-none-any.whl", hash = "sha256:b683bd1b6659ddcd810ff02ad09ba821d4bf1065072805063eb35c49617905ac", size = 347996, upload-time = "2026-10-03T09:23:12.535Z" }, +] + [[package]] name = "urllib3" version = "2.7.0" @@ -2283,6 +2534,24 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/a0/3a/eb70620ca2bf8213603d5c731460687c49fee38b0072f0b4a637781f0a53/uvicorn-0.50.0-py3-none-any.whl", hash = "sha256:05f0eb19edf38208f79f43df8a63081b48df31b0cd1e5997be957a4dc97d1b19", size = 72716, upload-time = "2026-07-04T05:03:24.848Z" }, ] +[[package]] +name = "watchdog" +version = "6.0.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/db/7d/7f3d619e951c88ed75c6037b246ddcf2d322812ee8ea189be89511721d54/watchdog-6.0.0.tar.gz", hash = "sha256:9ddf7c82fda3ae8e24decda1338ede66e1c99883db93711d8fb941eaa2d8c282", size = 131220, upload-time = "2024-11-01T14:07:13.037Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a9/c7/ca4bf3e518cb57a686b2feb4f55a1892fd9a3dd13f470fca14e00f80ea36/watchdog-6.0.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:7607498efa04a3542ae3e05e64da8202e58159aa1fa4acddf7678d34a35d4f13", size = 79079, upload-time = "2024-11-01T14:06:59.472Z" }, + { url = "https://files.pythonhosted.org/packages/5c/51/d46dc9332f9a647593c947b4b88e2381c8dfc0942d15b8edc0310fa4abb1/watchdog-6.0.0-py3-none-manylinux2014_armv7l.whl", hash = "sha256:9041567ee8953024c83343288ccc458fd0a2d811d6a0fd68c4c22609e3490379", size = 79078, upload-time = "2024-11-01T14:07:01.431Z" }, + { url = "https://files.pythonhosted.org/packages/d4/57/04edbf5e169cd318d5f07b4766fee38e825d64b6913ca157ca32d1a42267/watchdog-6.0.0-py3-none-manylinux2014_i686.whl", hash = "sha256:82dc3e3143c7e38ec49d61af98d6558288c415eac98486a5c581726e0737c00e", size = 79076, upload-time = "2024-11-01T14:07:02.568Z" }, + { url = "https://files.pythonhosted.org/packages/ab/cc/da8422b300e13cb187d2203f20b9253e91058aaf7db65b74142013478e66/watchdog-6.0.0-py3-none-manylinux2014_ppc64.whl", hash = "sha256:212ac9b8bf1161dc91bd09c048048a95ca3a4c4f5e5d4a7d1b1a7d5752a7f96f", size = 79077, upload-time = "2024-11-01T14:07:03.893Z" }, + { url = "https://files.pythonhosted.org/packages/2c/3b/b8964e04ae1a025c44ba8e4291f86e97fac443bca31de8bd98d3263d2fcf/watchdog-6.0.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:e3df4cbb9a450c6d49318f6d14f4bbc80d763fa587ba46ec86f99f9e6876bb26", size = 79078, upload-time = "2024-11-01T14:07:05.189Z" }, + { url = "https://files.pythonhosted.org/packages/62/ae/a696eb424bedff7407801c257d4b1afda455fe40821a2be430e173660e81/watchdog-6.0.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:2cce7cfc2008eb51feb6aab51251fd79b85d9894e98ba847408f662b3395ca3c", size = 79077, upload-time = "2024-11-01T14:07:06.376Z" }, + { url = "https://files.pythonhosted.org/packages/b5/e8/dbf020b4d98251a9860752a094d09a65e1b436ad181faf929983f697048f/watchdog-6.0.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:20ffe5b202af80ab4266dcd3e91aae72bf2da48c0d33bdb15c66658e685e94e2", size = 79078, upload-time = "2024-11-01T14:07:07.547Z" }, + { url = "https://files.pythonhosted.org/packages/07/f6/d0e5b343768e8bcb4cda79f0f2f55051bf26177ecd5651f84c07567461cf/watchdog-6.0.0-py3-none-win32.whl", hash = "sha256:07df1fdd701c5d4c8e55ef6cf55b8f0120fe1aef7ef39a1c6fc6bc2e606d517a", size = 79065, upload-time = "2024-11-01T14:07:09.525Z" }, + { url = "https://files.pythonhosted.org/packages/db/d9/c495884c6e548fce18a8f40568ff120bc3a4b7b99813081c8ac0c936fa64/watchdog-6.0.0-py3-none-win_amd64.whl", hash = "sha256:cbafb470cf848d93b5d013e2ecb245d4aa1c8fd0504e863ccefa32445359d680", size = 79070, upload-time = "2024-11-01T14:07:10.686Z" }, + { url = "https://files.pythonhosted.org/packages/33/e8/e40370e6d74ddba47f002a32919d91310d6074130fe4e17dabcafc15cbf1/watchdog-6.0.0-py3-none-win_ia64.whl", hash = "sha256:a1914259fa9e1454315171103c6a30961236f508b9b623eae470268bbcc6a22f", size = 79067, upload-time = "2024-11-01T14:07:11.845Z" }, +] + [[package]] name = "websocket-client" version = "1.9.2" From d48a36ddeaf89982da25086b5f5f78e65485c98b Mon Sep 17 00:00:00 2001 From: Christopher Kevin Date: Sun, 4 Oct 2026 23:21:56 -0700 Subject: [PATCH 02/40] fix(dashboard): preserve trial coverage and resource ownership Signed-off-by: Christopher Kevin --- .../reporting/dashboard_data.py | 110 +++++++++-- tests/reporting/test_dashboard_data.py | 176 +++++++++++++++++- 2 files changed, 266 insertions(+), 20 deletions(-) diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index 4e11df575..a30204edb 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -73,6 +73,37 @@ def _features(*owners: dict[str, Any]) -> str: return "unknown" +def _is_native_result(value: dict[str, Any]) -> bool: + return any( + isinstance(_dict(agent).get("with_skill"), dict) or isinstance(_dict(agent).get("without_skill"), dict) + for agent in _dict(value.get("agents")).values() + ) + + +def _trial_coverage_truncated(marker: dict[str, Any]) -> bool: + if not marker.get("truncated"): + return False + if marker.get("artifact_loading"): + return True + omitted = _dict(marker.get("omitted")) + # These budgets affect diagnostics, not the normalized trial population. + # Non-best detail pruning is checked per agent against its declared counts. + diagnostics = { + "raw_trial_rewards", + "raw_detail_fields", + "raw_reward_fields", + "raw_metric_values", + "unpaired_case_ids", + "comparison_payloads", + "evidence_entries", + "evaluator_cards", + "insight_items", + "custom_metric_discovery_trials", + "non_best_agent_details", + } + return not omitted or any(section not in diagnostics for section in omitted) + + def _payloads(value: Any, depth: int = 0): """Prefer authoritative per-validator results over a top-level Tier 3 mirror.""" if depth > 32: @@ -123,9 +154,9 @@ def _trial_keys(trials: list[dict[str, Any]]) -> tuple[tuple[str, str], ...] | N attempt = trial.get("attempt") or trial.get("attempt_index") # Native canonical reports omit attempt numbers, but Harbor trial IDs # carry __attemptN when attempts are repeated. - match = re.search(r"(?:__|_)attempt[_-]?(\d+)(?:__|$)", trial_id) - if attempt is None and match: - attempt = int(match.group(1)) + matches = re.findall(r"(?:__|_|-)attempt[_-]?(\d+)(?=__|$)", trial_id) + if attempt is None and matches: + attempt = int(matches[-1]) if attempt is None: implicit.add(entry) keys.append((entry, str(attempt) if attempt is not None else f"ordinal:{counts[entry]}")) @@ -171,6 +202,12 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: """Normalize canonical Tier 3, validate-report, and embedded catalog JSON.""" output = DashboardData() for report in _payloads(payload): + if _is_native_result(report): + output.warnings.append( + f"{source}: native engine JSON needs its retained run directory for trial data; " + "load the retained directory or a canonical Tier 3 report." + ) + continue summary = _dict(report.get("summary")) provenance = _dict(report.get("provenance")) run_id = str(report.get("run_id") or summary.get("run_id") or "") @@ -179,8 +216,14 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: if not run_id: run_id = str(report.get("evaluated_at") or summary.get("evaluated_at") or "unknown") truncation = _dict(report.get("report_truncation")) or _dict(report.get("truncation")) + coverage_truncated = _trial_coverage_truncated(truncation) if truncation.get("truncated"): - output.warnings.append(f"{source}: report details are truncated; comparisons are unavailable.") + message = ( + "trial data may be truncated; comparisons are unavailable." + if coverage_truncated + else "diagnostic details are truncated; complete trial coverage is checked separately." + ) + output.warnings.append(f"{source}: {message}") for name, value in _dict(report.get("agents")).items(): agent = _dict(value) if not agent: @@ -210,13 +253,22 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: scored = _count(details.get("scored_attempts")) keys = _trial_keys(trials) logical_count = len(keys) if keys is not None else declared + physical_counts = Counter(str(trial["trial_id"]) for trial in trials if trial.get("trial_id")) + ambiguous_ids = {trial_id for trial_id, count in physical_counts.items() if count > 1} + if ambiguous_ids: + notice = ( + f"{source}: canonical multi-step resource ownership is ambiguous; " + "usage totals are unavailable. Load the retained run directory for authoritative step measurements." + ) + if notice not in output.warnings: + output.warnings.append(notice) complete = ( status == "succeeded" and declared > 0 and len(trials) == declared and keys is not None and len(set(keys)) == len(keys) - and not truncation.get("truncated") + and not coverage_truncated and (scored is None or scored == logical_count) and (expected is None or scored == expected) ) @@ -238,10 +290,18 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: "_trial_keys": keys, "_dataset_digest": report.get("dataset_digest") or summary.get("dataset_digest"), "_attempt_policy": report.get("attempt_policy"), + "_expected_usage_trials": max( + logical_count, expected or 0, scored or 0, declared if len(trials) != declared else 0 + ), + "_ambiguous_trial_ids": tuple(sorted(ambiguous_ids)), } - _set_usage(row, [_usage(trial) for trial in trials], expected=declared) + _set_usage( + row, + [{} if str(trial.get("trial_id") or "") in ambiguous_ids else _usage(trial) for trial in trials], + expected=declared + max(0, row["_expected_usage_trials"] - logical_count), + ) output.rows.append(row) - if not output.rows: + if not output.rows and not output.warnings: output.warnings.append(f"{source}: no supported Tier 3 agent results found.") return output @@ -314,7 +374,7 @@ def _duration(result: dict[str, Any]) -> float | None: return None -def _native_usage(trial_dir: Path) -> dict[str, Any]: +def _native_usage(trial_dir: Path, *, require_steps: bool = False) -> dict[str, Any]: trajectory = _dict(_read_json(trial_dir / "trajectory.json")) if (trial_dir / "trajectory.json").is_file() else {} final = _dict(trajectory.get("final_metrics")) result = _dict(_read_json(trial_dir / "result.json")) if (trial_dir / "result.json").is_file() else {} @@ -331,6 +391,8 @@ def _native_usage(trial_dir: Path) -> dict[str, Any]: # Constituent steps own their measured cost and execution time. The root # may also mirror a step, so never add both the root and constituent values. steps = result.get("step_results") + if require_steps and not (isinstance(steps, list) and steps): + return {"_resource_scope_valid": False} constituents = steps if isinstance(steps, list) and steps else [result] if isinstance(steps, list) and steps: @@ -344,6 +406,7 @@ def step_total(key: str) -> float | None: durations = [_duration(_dict(step)) for step in constituents] costs = [_measurement(_dict(_dict(step).get("agent_result")).get("cost_usd")) for step in constituents] return { + "_resource_scope_valid": True, "prompt_tokens": prompt, "completion_tokens": completion, "total_tokens": prompt + completion if prompt is not None and completion is not None else None, @@ -370,6 +433,7 @@ def _load_native(path: Path) -> DashboardData: run_config = _dict(_read_json(path / "run_config.json")) canonical["dashboard_metadata"] = run_config.get("dashboard_metadata") output = parse_dashboard_report(canonical, str(path)) + unresolved_scope = False for row in output.rows: # The report's agent keys identify repeated harness occurrences on disk. agents = _dict(canonical.get("agents")) @@ -395,20 +459,32 @@ def _load_native(path: Path) -> DashboardData: reward = _dict(_read_json(trial_dir / "reward.json")) physical_id = str(reward.get("trial_id") or trial_dir.name) if physical_id not in usages_by_trial: - usages_by_trial[physical_id] = _native_usage(trial_dir) + usages_by_trial[physical_id] = _native_usage( + trial_dir, require_steps=physical_id in row["_ambiguous_trial_ids"] + ) + unresolved_scope |= usages_by_trial[physical_id].get("_resource_scope_valid") is False except (OSError, ValueError, RecursionError) as exc: output.warnings.append(f"{trial_dir}: cannot read usage: {exc}") usages_by_trial[trial_dir.name] = {} - _set_usage(row, list(usages_by_trial.values())) + _set_usage(row, list(usages_by_trial.values()), expected=row["_expected_usage_trials"]) + if not unresolved_scope: + output.warnings = [ + warning for warning in output.warnings if "canonical multi-step resource ownership" not in warning + ] return output -def _load_report_file(path: Path) -> DashboardData: +def _load_report_file(path: Path, ancestors: frozenset[Path] = frozenset()) -> DashboardData: + path = path.resolve() + if path in ancestors or len(ancestors) >= 16: + return DashboardData(warnings=[f"{path}: cyclic or excessively nested catalog reference skipped."]) + if path.name == "result.json" and (path.parent / "run_config.json").is_file(): + return _load_native(path.parent) payload = _read_json(path) data = parse_dashboard_report(payload, str(path)) - if data.rows or not isinstance(payload, dict) or not isinstance(payload.get("skills"), list): + if not isinstance(payload, dict) or not isinstance(payload.get("skills"), list): return data - output = DashboardData() + output = DashboardData(rows=data.rows, warnings=data.warnings if data.rows else []) for entry in payload["skills"][:_MAX_FILES]: entry = _dict(entry) report_dir, report_name = entry.get("report_dir"), entry.get("json_report") @@ -417,8 +493,8 @@ def _load_report_file(path: Path) -> DashboardData: try: report_path = (path.parent / report_dir / report_name).resolve() report_path.relative_to(path.parent.resolve()) - report = parse_dashboard_report(_read_json(report_path), str(report_path)) - except (OSError, ValueError, RecursionError) as exc: + report = _load_report_file(report_path, ancestors | {path}) + except (OSError, ValueError, RecursionError, TypeError, AttributeError) as exc: output.warnings.append(f"{path}: cannot load catalog report: {exc}") continue output.rows.extend(report.rows) @@ -442,7 +518,7 @@ def load_dashboard_path(path: Path) -> DashboardData: if path.is_file(): try: return _load_report_file(path) - except (OSError, ValueError, RecursionError) as exc: + except (OSError, ValueError, RecursionError, TypeError, AttributeError) as exc: return DashboardData(warnings=[f"{path}: cannot read report: {exc}"]) if not path.is_dir(): return DashboardData(warnings=[f"Dashboard input does not exist: {path}"]) @@ -458,7 +534,7 @@ def load_dashboard_path(path: Path) -> DashboardData: if "result.json" in filenames and "run_config.json" in filenames: try: data = _load_native(root) - except (OSError, ValueError, RecursionError) as exc: + except (OSError, ValueError, RecursionError, TypeError, AttributeError) as exc: data = DashboardData(warnings=[f"{root}: cannot load retained run: {exc}"]) subdirectories.clear() output.rows.extend(data.rows) diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index 0544fa762..53a43ccfd 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -5,6 +5,7 @@ import copy import json +import shutil from pathlib import Path import pytest @@ -92,6 +93,16 @@ def test_partial_missing_metrics_never_become_zero_or_partial_total() -> None: assert "cost 0/1" in data.rows[0]["coverage"] +def test_canonical_missing_attempt_keeps_usage_totals_unknown() -> None: + report = _report() + agent = report["agents"]["claude-code"] + agent["conditions"]["with_skill"].update(expected_attempts=2, scored_attempts=1, execution_status="failed") + row = parse_dashboard_report(report, "report.json").rows[0] + assert row["total_tokens"] is None + assert row["duration_seconds"] is None + assert "tokens 1/2" in row["coverage"] + + @pytest.mark.parametrize("mutation", ["failed", "missing_trial", "truncated", "different_case", "missing_attempt"]) def test_incomplete_or_unmatched_arms_block_all_deltas(mutation: str) -> None: report = _report() @@ -175,7 +186,7 @@ def test_repeated_attempts_require_recorded_identity_and_match_exact_set() -> No assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["score_delta"] is None -def test_multistep_rewards_count_logical_attempt_once_and_sum_resources() -> None: +def test_multistep_rewards_keep_logical_scores_without_ambiguous_resource_sums() -> None: report = _report() agent = report["agents"]["claude-code"] for field, count_field in (("trials", "num_trials"), ("trials_baseline", "num_trials_baseline")): @@ -183,8 +194,17 @@ def test_multistep_rewards_count_logical_attempt_once_and_sum_resources() -> Non agent[count_field] = 2 data = parse_dashboard_report(report, "report.json") assert data.rows[0]["trials"] == 1 - assert data.rows[0]["total_tokens"] == 300 - assert comparison_rows(data.rows)[0]["score_delta"] == pytest.approx(0.2) + assert data.rows[0]["total_tokens"] is None + assert data.rows[0]["duration_seconds"] is None + assert data.rows[0]["cost_usd"] is None + assert any("resource ownership is ambiguous" in warning for warning in data.warnings) + comparison = comparison_rows(data.rows)[0] + assert comparison["score_delta"] == pytest.approx(0.2) + assert comparison["total_tokens_delta"] is None + # Different counters do not establish whether each row measures one step + # or mirrors the same physical trial's trajectory. + agent["trials"][1]["tokens"]["prompt"] = 10 + assert parse_dashboard_report(report, "report.json").rows[0]["total_tokens"] is None def test_explicit_adverse_row_has_no_invented_baseline_delta() -> None: @@ -198,6 +218,26 @@ def test_explicit_adverse_row_has_no_invented_baseline_delta() -> None: assert len(comparison_rows(data.rows)) == 1 +@pytest.mark.parametrize("omitted", ["evidence_entries", "raw_trial_rewards", "non_best_agent_details"]) +def test_diagnostic_truncation_preserves_complete_trial_comparisons(omitted: str) -> None: + report = _report() + report["report_truncation"] = {"truncated": True, "omitted": {omitted: 50}} + data = parse_dashboard_report(report, "report.json") + assert data.warnings + assert data.rows[0]["score"] == 0.8 + assert comparison_rows(data.rows)[0]["comparison_status"] == "comparable" + + +def test_artifact_loading_truncation_blocks_comparisons() -> None: + report = _report() + report["report_truncation"] = { + "truncated": True, + "omitted": {"evidence_entries": 50}, + "artifact_loading": [{"code": "trial_limit", "artifact": "with-skill", "limit": 512}], + } + assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["score_delta"] is None + + def test_bad_input_is_diagnostic_and_directory_skips_symlinks(tmp_path: Path) -> None: malformed = tmp_path / "broken.json" malformed.write_text("{", encoding="utf-8") @@ -296,6 +336,98 @@ def test_native_results_use_real_usage_and_prune_nested_mirrors(tmp_path: Path) comparison = comparison_rows(data.rows)[0] assert comparison["comparison_status"] == "comparable" assert comparison["total_tokens_delta"] == 100 + assert load_dashboard_path(run / "result.json").rows == load_dashboard_path(run).rows + + +def test_catalog_native_and_mixed_references_are_loaded_without_cycles(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + index = tmp_path / "catalog.json" + reference = {"report_dir": "run", "json_report": "result.json"} + index.write_text(json.dumps({"skills": [reference]})) + assert load_dashboard_path(index).rows == load_dashboard_path(run).rows + index.write_text(json.dumps({"skills": [{"tier3": _report()}, reference]})) + assert len(load_dashboard_path(index).rows) == 4 + index.write_text(json.dumps({"skills": [reference, {"report_dir": ".", "json_report": "catalog.json"}]})) + data = load_dashboard_path(index) + assert len(data.rows) == 2 + assert any("cyclic" in warning for warning in data.warnings) + + +def test_uploaded_native_engine_json_needs_retained_artifacts() -> None: + raw_result = { + "skill_name": "native-skill", + "run_id": "native-run", + "agents": { + "opencode": { + "with_skill": {"security": 0.8}, + "without_skill": {"security": 0.6}, + "num_trials_with": 1, + "num_trials_without": 1, + } + }, + } + data = parse_dashboard_report(raw_result, "result.json") + assert data.rows == [] + assert any("retained run directory" in warning for warning in data.warnings) + + +@pytest.mark.parametrize("malformation", ["summary_status", "run_config_agents"]) +def test_malformed_native_schema_is_diagnostic_and_preserves_other_sources(tmp_path: Path, malformation: str) -> None: + run = tmp_path / "bad-run" + _native_run(run) + if malformation == "summary_status": + path = run / "opencode" / "with-skill" / "summary.json" + summary = json.loads(path.read_text()) + summary["execution_status"] = ["succeeded"] + path.write_text(json.dumps(summary)) + else: + (run / "run_config.json").write_text(json.dumps({"agents": [{"agent": "opencode"}]})) + assert load_dashboard_path(run / "result.json").warnings + (tmp_path / "valid.json").write_text(json.dumps(_report())) + data = load_dashboard_path(tmp_path) + assert len(data.rows) == 2 + assert {row["skill"] for row in data.rows} == {"calculator"} + assert data.warnings + + +def test_native_missing_attempt_does_not_publish_partial_usage_as_total(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + for variant in ("with-skill", "without-skill"): + summary_path = run / "opencode" / variant / "summary.json" + summary = json.loads(summary_path.read_text()) + summary.update(num_trials=2, expected_attempts=2, scored_attempts=2) + summary_path.write_text(json.dumps(summary)) + data = load_dashboard_path(run) + assert all(row["score"] is None and row["total_tokens"] is None for row in data.rows) + assert all(row["duration_seconds"] is None for row in data.rows) + assert all("tokens 1/2" in row["coverage"] and "time 1/2" in row["coverage"] for row in data.rows) + + +def test_native_generated_stop_on_pass_names_preserve_attempt_sets(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + for variant, label in (("with-skill", "with"), ("without-skill", "without")): + condition = run / "opencode" / variant + first_name = f"demo-opencode-{label}-case-a-attempt001__case-a__random1" + second_name = f"demo-opencode-{label}-case-a-attempt002__case-a__random2" + original = condition / "trials" / "case-a__random" + first = original.rename(original.with_name(first_name)) + second = first.with_name(second_name) + shutil.copytree(first, second) + for trial_dir in (first, second): + reward_path = trial_dir / "reward.json" + reward = json.loads(reward_path.read_text()) + reward["trial_id"] = trial_dir.name + reward_path.write_text(json.dumps(reward)) + summary_path = condition / "summary.json" + summary = json.loads(summary_path.read_text()) + summary.update(num_trials=2, expected_attempts=2, scored_attempts=2) + summary_path.write_text(json.dumps(summary)) + data = load_dashboard_path(run) + assert all(row["trials"] == 2 and row["score"] == 0.8 for row in data.rows) + assert comparison_rows(data.rows)[0]["comparison_status"] == "comparable" def test_native_different_condition_models_cannot_pair(tmp_path: Path) -> None: @@ -332,3 +464,41 @@ def test_multistep_native_cost_time_and_tokens_require_every_step(tmp_path: Path assert row["prompt_tokens"] is None assert row["total_tokens"] is None assert row["cost_usd"] is None + + +def test_native_duplicate_reward_rows_require_authoritative_step_scope(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + condition = run / "opencode" / "with-skill" + first = condition / "trials" / "case-a__random" + second = first.with_name("case-a__random__finish") + shutil.copytree(first, second) + summary_path = condition / "summary.json" + summary = json.loads(summary_path.read_text()) + summary["num_trials"] = 2 + summary_path.write_text(json.dumps(summary)) + for trial_dir in (first, second): + result_path = trial_dir / "result.json" + result = json.loads(result_path.read_text()) + step = { + "step_name": "prepare", + "agent_result": {"n_input_tokens": 50, "n_output_tokens": 5, "n_cache_tokens": 0, "cost_usd": 0.1}, + "agent_execution": result["agent_execution"], + } + result["step_results"] = [step, {**copy.deepcopy(step), "step_name": "finish"}] + result_path.write_text(json.dumps(result)) + row = load_dashboard_path(run).rows[0] + assert row["score"] == 0.8 + assert row["total_tokens"] == 110 + assert row["duration_seconds"] == 20 + assert row["cost_usd"] == pytest.approx(0.2) + for trial_dir in (first, second): + result_path = trial_dir / "result.json" + result = json.loads(result_path.read_text()) + result.pop("step_results") + result_path.write_text(json.dumps(result)) + data = load_dashboard_path(run) + assert data.rows[0]["score"] == 0.8 + assert data.rows[0]["total_tokens"] is None + assert data.rows[0]["duration_seconds"] is None + assert any("resource ownership is ambiguous" in warning for warning in data.warnings) From 059a59c1d139513dac77d392e6c0e11d957992be Mon Sep 17 00:00:00 2001 From: Christopher Kevin Date: Sun, 4 Oct 2026 23:25:05 -0700 Subject: [PATCH 03/40] docs(dashboard): clarify unavailable measurement reasons Signed-off-by: Christopher Kevin --- docs/reports.mdx | 4 ++++ src/skillevaluator/reporting/dashboard_app.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/reports.mdx b/docs/reports.mdx index 4759601b7..5310796e5 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -569,6 +569,10 @@ to prompt plus completion tokens. No pricing estimates or new agent evaluations are performed. Adverse conditions and harness features are displayed when explicitly recorded; the dashboard does not run these experiments. +Canonical JSON can omit resource ownership for multi-step trials. When several +reward rows share one physical trial, the dashboard keeps their usage totals +unavailable and shows a notice. Open the retained run directory to recover +totals from authoritative step results. ### Recorded harness features diff --git a/src/skillevaluator/reporting/dashboard_app.py b/src/skillevaluator/reporting/dashboard_app.py index 7459b613c..3ffe13b12 100644 --- a/src/skillevaluator/reporting/dashboard_app.py +++ b/src/skillevaluator/reporting/dashboard_app.py @@ -311,7 +311,7 @@ def main(paths: list[str] | None = None) -> None: summary[1].metric("Skills", skill_count) summary[2].metric("Condition rows", len(performance_rows)) summary[3].metric("Scored rows", scored_count) - st.caption("Blank cells mean the report did not record that measurement. Unknown settings remain labeled unknown.") + st.caption("Blank cells mean a measurement is missing, incomplete, or ambiguous. Unknown settings remain labeled unknown.") performance_tab, comparison_tab = st.tabs(["Performance", "With vs without skill"]) with performance_tab: _show_performance(performance_rows) From a175d20ccefa471d674b2ff315498b13bbd207d0 Mon Sep 17 00:00:00 2001 From: Christopher Kevin Date: Sun, 4 Oct 2026 23:55:02 -0700 Subject: [PATCH 04/40] fix(dashboard): enforce provenance and bounded artifact loading Signed-off-by: Christopher Kevin --- CHANGELOG.md | 2 + docs/reports.mdx | 3 + src/skillevaluator/reporting/dashboard.py | 1 + src/skillevaluator/reporting/dashboard_app.py | 15 +- .../reporting/dashboard_data.py | 193 +++++++++++++----- tests/reporting/test_dashboard_app.py | 29 +++ tests/reporting/test_dashboard_cli.py | 1 + tests/reporting/test_dashboard_data.py | 162 +++++++++++++++ tests/reporting/test_report_data_bounds.py | 57 ++++++ 9 files changed, 412 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a786a61a..101c73187 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -305,6 +305,8 @@ All notable changes to SkillEvaluator are documented in this file. ### Fixed +- Preserve missing Tier 3 token counters as `null` in canonical JSON exports + instead of reporting unmeasured usage as zero. - Report non-string YAML keys as validation errors in skills, rules, workflows, and plugin manifests instead of raising a `TypeError`, including frontmatter `metadata` keys. Show boolean, null, and date keys in a readable YAML form. diff --git a/docs/reports.mdx b/docs/reports.mdx index 5310796e5..579e63f93 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -563,6 +563,9 @@ the same run and require successful conditions with matching trial coverage. Missing measurements stay unavailable: older JSON reports may contain token counts without time or cost, and cost is shown only when recorded in USD. +Some older exports encoded missing token counters as zero. Open their retained +run directories to recover recorded counters, or regenerate the canonical JSON +with this version to preserve missing measurements as `null`. For retained runs, duration measures agent execution rather than the entire evaluation workflow. Cached tokens are shown separately and are not added again to prompt plus completion tokens. No pricing estimates or new agent evaluations diff --git a/src/skillevaluator/reporting/dashboard.py b/src/skillevaluator/reporting/dashboard.py index 9fb675a87..244dd46be 100644 --- a/src/skillevaluator/reporting/dashboard.py +++ b/src/skillevaluator/reporting/dashboard.py @@ -26,6 +26,7 @@ def launch_dashboard(paths: tuple[Path, ...], *, port: int = 8501, no_browser: b str(app), "--server.address=127.0.0.1", f"--server.port={port}", + "--server.maxUploadSize=16", f"--server.headless={str(no_browser).lower()}", "--browser.gatherUsageStats=false", "--theme.primaryColor=#76b900", diff --git a/src/skillevaluator/reporting/dashboard_app.py b/src/skillevaluator/reporting/dashboard_app.py index 3ffe13b12..65ce69547 100644 --- a/src/skillevaluator/reporting/dashboard_app.py +++ b/src/skillevaluator/reporting/dashboard_app.py @@ -263,13 +263,22 @@ def main(paths: list[str] | None = None) -> None: "Upload JSON reports", type=["json"], accept_multiple_files=True, - help="Use Tier 3 JSON reports or consolidated SkillEvaluator JSON reports.", + help="Use Tier 3 JSON reports or consolidated SkillEvaluator JSON reports, up to 16 MiB per file.", key="report_uploads", ) rows: list[dict[str, Any]] = [] warnings: list[str] = [] - for path in dict.fromkeys(str(Path(path).expanduser().resolve()) for path in (paths or [])): - data = load_dashboard_path(Path(path)) + seen_paths: set[Path] = set() + for supplied_path in paths or []: + try: + path = Path(supplied_path).expanduser().resolve() + except (OSError, ValueError, RuntimeError) as exc: + warnings.append(f"{supplied_path}: cannot resolve dashboard input: {exc}") + continue + if path in seen_paths: + continue + seen_paths.add(path) + data = load_dashboard_path(path) rows.extend(data.rows) warnings.extend(data.warnings) for index, uploaded in enumerate(uploads): diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index a30204edb..5174ac6c4 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -18,11 +18,13 @@ from collections import Counter from dataclasses import dataclass, field from datetime import datetime +from itertools import islice from pathlib import Path from typing import Any _USAGE = ("prompt_tokens", "completion_tokens", "total_tokens", "cached_tokens", "duration_seconds", "cost_usd") _IDENTITY = ("source", "run_id", "skill", "model", "harness", "features") +_PAIRING_IDENTITY = (*_IDENTITY, "_report_index", "_agent_key", "_feature_key") _MAX_FILE_BYTES = 16 * 1024 * 1024 _MAX_FILES = 1000 _MAX_PATHS = 20_000 @@ -34,6 +36,13 @@ class DashboardData: warnings: list[str] = field(default_factory=list) +@dataclass +class _CatalogBudget: + seen: set[Path] = field(default_factory=set) + files_remaining: int = field(default_factory=lambda: _MAX_FILES) + references_remaining: int = field(default_factory=lambda: _MAX_PATHS) + + def _dict(value: Any) -> dict[str, Any]: return value if isinstance(value, dict) else {} @@ -57,20 +66,26 @@ def _count(value: Any) -> int | None: return value if isinstance(value, int) and not isinstance(value, bool) and value >= 0 else None -def _features(*owners: dict[str, Any]) -> str: +def _feature_config(*owners: dict[str, Any]) -> tuple[str, str]: for owner in owners: metadata = _dict(owner.get("dashboard_metadata")) features = metadata.get("harness_features") if isinstance(features, str) and features.strip(): - return features.strip() + return features.strip(), json.dumps(["string", features.strip()], ensure_ascii=False) if isinstance(features, list) and all(isinstance(item, str) for item in features): - return ", ".join(sorted(set(features))) or "none (recorded)" + values = sorted(set(features)) + return ", ".join(values) or "none (recorded)", json.dumps(["list", values], ensure_ascii=False) if isinstance(features, dict): try: - return json.dumps(features, sort_keys=True, ensure_ascii=False, allow_nan=False) + value = json.dumps(features, sort_keys=True, ensure_ascii=False, allow_nan=False) + return value, json.dumps(["dict", features], sort_keys=True, ensure_ascii=False, allow_nan=False) except (ValueError, TypeError, RecursionError): - return "unknown" - return "unknown" + return "unknown", "unknown" + return "unknown", "unknown" + + +def _set_features(row: dict[str, Any], *owners: dict[str, Any]) -> None: + row["features"], row["_feature_key"] = _feature_config(*owners) def _is_native_result(value: dict[str, Any]) -> bool: @@ -151,12 +166,23 @@ def _trial_keys(trials: list[dict[str, Any]]) -> tuple[tuple[str, str], ...] | N if trial_id: seen_trials[trial_id] = entry counts[entry] += 1 - attempt = trial.get("attempt") or trial.get("attempt_index") + attempts = [trial[field] for field in ("attempt", "attempt_index") if trial.get(field) is not None] + normalized_attempts = [] + for attempt in attempts: + if isinstance(attempt, int) and not isinstance(attempt, bool) and attempt >= 0: + normalized_attempts.append(str(attempt)) + elif isinstance(attempt, str) and re.fullmatch(r"[0-9]+", attempt): + normalized_attempts.append(attempt.lstrip("0") or "0") + else: + return None + if len(set(normalized_attempts)) > 1: + return None + attempt = normalized_attempts[0] if normalized_attempts else None # Native canonical reports omit attempt numbers, but Harbor trial IDs # carry __attemptN when attempts are repeated. matches = re.findall(r"(?:__|_|-)attempt[_-]?(\d+)(?=__|$)", trial_id) if attempt is None and matches: - attempt = int(matches[-1]) + attempt = matches[-1].lstrip("0") or "0" if attempt is None: implicit.add(entry) keys.append((entry, str(attempt) if attempt is not None else f"ordinal:{counts[entry]}")) @@ -201,7 +227,7 @@ def _set_usage(row: dict[str, Any], usages: list[dict[str, Any]], expected: int def parse_dashboard_report(payload: Any, source: str) -> DashboardData: """Normalize canonical Tier 3, validate-report, and embedded catalog JSON.""" output = DashboardData() - for report in _payloads(payload): + for report_index, report in enumerate(_payloads(payload)): if _is_native_result(report): output.warnings.append( f"{source}: native engine JSON needs its retained run directory for trial data; " @@ -278,7 +304,6 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: "skill": str(report.get("skill_name") or summary.get("skill_name") or "unknown"), "model": str(agent.get("model") or "unknown"), "harness": str(agent.get("harness") or agent.get("name") or name), - "features": _features(details, agent, report), "condition": condition, "status": status, "trials": logical_count, @@ -287,6 +312,8 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: if complete else None, "_complete": complete, + "_report_index": report_index, + "_agent_key": str(name), "_trial_keys": keys, "_dataset_digest": report.get("dataset_digest") or summary.get("dataset_digest"), "_attempt_policy": report.get("attempt_policy"), @@ -295,6 +322,7 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: ), "_ambiguous_trial_ids": tuple(sorted(ambiguous_ids)), } + _set_features(row, details, agent, report) _set_usage( row, [{} if str(trial.get("trial_id") or "") in ambiguous_ids else _usage(trial) for trial in trials], @@ -311,12 +339,12 @@ def comparison_rows(rows: list[dict[str, Any]]) -> list[dict[str, Any]]: groups: dict[tuple[Any, ...], list[dict[str, Any]]] = {} for row in rows: if row.get("condition") in {"with_skill", "without_skill"}: - groups.setdefault(tuple(row.get(key) for key in _IDENTITY), []).append(row) + groups.setdefault(tuple(row.get(key) for key in _PAIRING_IDENTITY), []).append(row) comparisons = [] for identity, arms in groups.items(): with_rows = [row for row in arms if row["condition"] == "with_skill"] without_rows = [row for row in arms if row["condition"] == "without_skill"] - result = dict(zip(_IDENTITY, identity, strict=True)) + result = dict(zip(_PAIRING_IDENTITY, identity, strict=True)) status = "missing condition" paired = False if len(with_rows) > 1 or len(without_rows) > 1: @@ -364,6 +392,26 @@ def _read_json(path: Path) -> Any: return json.loads(data) +def _safe_native_path(path: Path, run_root: Path) -> bool: + try: + path.resolve().relative_to(run_root) + relative = path.relative_to(run_root) + except (ValueError, OSError, RuntimeError): + return False + current = run_root + for part in relative.parts: + current /= part + if current.is_symlink(): + return False + return True + + +def _read_native_json(path: Path, run_root: Path) -> Any: + if not _safe_native_path(path, run_root): + raise ValueError(f"symlink or external retained artifact skipped: {path}") + return _read_json(path) + + def _duration(result: dict[str, Any]) -> float | None: execution = _dict(result.get("agent_execution")) try: @@ -374,10 +422,16 @@ def _duration(result: dict[str, Any]) -> float | None: return None -def _native_usage(trial_dir: Path, *, require_steps: bool = False) -> dict[str, Any]: - trajectory = _dict(_read_json(trial_dir / "trajectory.json")) if (trial_dir / "trajectory.json").is_file() else {} +def _native_usage(trial_dir: Path, run_root: Path, *, require_steps: bool = False) -> dict[str, Any]: + trajectory = ( + _dict(_read_native_json(trial_dir / "trajectory.json", run_root)) + if (trial_dir / "trajectory.json").is_file() + else {} + ) final = _dict(trajectory.get("final_metrics")) - result = _dict(_read_json(trial_dir / "result.json")) if (trial_dir / "result.json").is_file() else {} + result = ( + _dict(_read_native_json(trial_dir / "result.json", run_root)) if (trial_dir / "result.json").is_file() else {} + ) agent_result = _dict(result.get("agent_result")) prompt = _measurement(final.get("total_prompt_tokens")) completion = _measurement(final.get("total_completion_tokens")) @@ -421,7 +475,7 @@ def step_total(key: str) -> float | None: def _load_native(path: Path) -> DashboardData: from skillevaluator.evaluation.tier3_report import agent_eval_result_from_directory - engine_result = _dict(_read_json(path / "result.json")) + engine_result = _dict(_read_native_json(path / "result.json", path)) skill = str(engine_result.get("skill_name") or "unknown") result = agent_eval_result_from_directory(Path(skill), path, engine_result=engine_result, use_llm_judge=False) if result is None: @@ -430,42 +484,50 @@ def _load_native(path: Path) -> DashboardData: canonical["run_id"] = engine_result.get("run_id") or path.name run_config = _dict(engine_result.get("run_config")) if not run_config and (path / "run_config.json").is_file(): - run_config = _dict(_read_json(path / "run_config.json")) + run_config = _dict(_read_native_json(path / "run_config.json", path)) canonical["dashboard_metadata"] = run_config.get("dashboard_metadata") output = parse_dashboard_report(canonical, str(path)) unresolved_scope = False for row in output.rows: # The report's agent keys identify repeated harness occurrences on disk. - agents = _dict(canonical.get("agents")) - name = next( - (key for key, agent in agents.items() if _dict(agent).get("name") == row["harness"]), row["harness"] - ) + name = row["_agent_key"] agent_config = _dict(_dict(run_config.get("agents")).get(name)) - row["features"] = _features(agent_config, run_config) + _set_features(row, agent_config, run_config) row["harness"] = str(agent_config.get("agent") or row["harness"]) variant = {"with_skill": "with-skill", "without_skill": "without-skill", "adverse": "adverse"}[row["condition"]] summary_path = path / name / variant / "summary.json" if summary_path.is_file(): - condition_summary = _dict(_read_json(summary_path)) + condition_summary = _dict(_read_native_json(summary_path, path)) row["model"] = str(condition_summary.get("model") or row["model"]) - row["features"] = _features(condition_summary, agent_config, run_config) + _set_features(row, condition_summary, agent_config, run_config) trials_dir = path / name / variant / "trials" usages_by_trial: dict[str, dict[str, Any]] = {} + if not _safe_native_path(trials_dir, path): + output.warnings.append(f"{trials_dir}: symlink or external retained directory skipped.") + _set_usage(row, [], expected=row["_expected_usage_trials"]) + continue if trials_dir.is_dir(): - for trial_dir in sorted(trials_dir.iterdir())[:513]: + trial_paths, truncated = _directory_entries(trials_dir, 4096) + trial_dirs = [candidate for candidate in trial_paths if candidate.is_dir() and not candidate.is_symlink()] + truncated |= len(trial_dirs) > 512 + for trial_dir in trial_dirs[:512]: if not trial_dir.is_dir() or trial_dir.is_symlink(): continue try: - reward = _dict(_read_json(trial_dir / "reward.json")) + reward = _dict(_read_native_json(trial_dir / "reward.json", path)) physical_id = str(reward.get("trial_id") or trial_dir.name) if physical_id not in usages_by_trial: usages_by_trial[physical_id] = _native_usage( - trial_dir, require_steps=physical_id in row["_ambiguous_trial_ids"] + trial_dir, path, require_steps=physical_id in row["_ambiguous_trial_ids"] ) unresolved_scope |= usages_by_trial[physical_id].get("_resource_scope_valid") is False except (OSError, ValueError, RecursionError) as exc: output.warnings.append(f"{trial_dir}: cannot read usage: {exc}") usages_by_trial[trial_dir.name] = {} + if truncated: + output.warnings.append(f"{trials_dir}: trial discovery limit reached; usage totals are unavailable.") + usages_by_trial["__omitted_trials__"] = {} + row["_expected_usage_trials"] = max(row["_expected_usage_trials"], len(usages_by_trial)) _set_usage(row, list(usages_by_trial.values()), expected=row["_expected_usage_trials"]) if not unresolved_scope: output.warnings = [ @@ -474,10 +536,19 @@ def _load_native(path: Path) -> DashboardData: return output -def _load_report_file(path: Path, ancestors: frozenset[Path] = frozenset()) -> DashboardData: +def _load_report_file( + path: Path, ancestors: frozenset[Path] = frozenset(), budget: _CatalogBudget | None = None +) -> DashboardData: + budget = budget if budget is not None else _CatalogBudget() path = path.resolve() if path in ancestors or len(ancestors) >= 16: return DashboardData(warnings=[f"{path}: cyclic or excessively nested catalog reference skipped."]) + if path in budget.seen: + return DashboardData() + if budget.files_remaining <= 0 or budget.references_remaining <= 0: + return DashboardData(warnings=["Dashboard catalog limit reached; some inputs were omitted."]) + budget.seen.add(path) + budget.files_remaining -= 1 if path.name == "result.json" and (path.parent / "run_config.json").is_file(): return _load_native(path.parent) payload = _read_json(path) @@ -490,11 +561,15 @@ def _load_report_file(path: Path, ancestors: frozenset[Path] = frozenset()) -> D report_dir, report_name = entry.get("report_dir"), entry.get("json_report") if not isinstance(report_dir, str) or not isinstance(report_name, str): continue + if budget.files_remaining <= 0 or budget.references_remaining <= 0: + output.warnings.append("Dashboard catalog limit reached; some inputs were omitted.") + break + budget.references_remaining -= 1 try: report_path = (path.parent / report_dir / report_name).resolve() report_path.relative_to(path.parent.resolve()) - report = _load_report_file(report_path, ancestors | {path}) - except (OSError, ValueError, RecursionError, TypeError, AttributeError) as exc: + report = _load_report_file(report_path, ancestors | {path}, budget) + except (OSError, ValueError, RecursionError, RuntimeError, TypeError, AttributeError) as exc: output.warnings.append(f"{path}: cannot load catalog report: {exc}") continue output.rows.extend(report.rows) @@ -506,6 +581,13 @@ def _load_report_file(path: Path, ancestors: frozenset[Path] = frozenset()) -> D return output +def _directory_entries(path: Path, limit: int) -> tuple[list[Path], bool]: + """Bound directory enumeration before sorting or allocating the full tree.""" + with os.scandir(path) as entries: + selected = [Path(entry.path) for entry in islice(entries, limit + 1)] + return sorted(selected[:limit]), len(selected) > limit + + def load_dashboard_path(path: Path) -> DashboardData: """Load one JSON report, a retained run, or a tree of reports and runs. @@ -513,51 +595,66 @@ def load_dashboard_path(path: Path) -> DashboardData: reports and constituent trials cannot become independent dashboard rows. Directory symlinks are not traversed. """ - path = path.expanduser().resolve() + try: + path = path.expanduser().resolve() + except (OSError, ValueError, RuntimeError) as exc: + return DashboardData(warnings=[f"{path}: cannot resolve dashboard input: {exc}"]) output = DashboardData() if path.is_file(): try: return _load_report_file(path) - except (OSError, ValueError, RecursionError, TypeError, AttributeError) as exc: + except (OSError, ValueError, RecursionError, RuntimeError, TypeError, AttributeError) as exc: return DashboardData(warnings=[f"{path}: cannot read report: {exc}"]) if not path.is_dir(): return DashboardData(warnings=[f"Dashboard input does not exist: {path}"]) visited = 0 files = 0 - for directory, subdirectories, filenames in os.walk(path, followlinks=False): - root = Path(directory) - subdirectories[:] = sorted(name for name in subdirectories if not (root / name).is_symlink()) - visited += len(subdirectories) + len(filenames) - if visited > _MAX_PATHS or files >= _MAX_FILES: + pending = [path] + while pending: + root = pending.pop() + if visited >= _MAX_PATHS or files >= _MAX_FILES: output.warnings.append("Dashboard discovery limit reached; some inputs were omitted.") break - if "result.json" in filenames and "run_config.json" in filenames: + if (root / "result.json").is_file() and (root / "run_config.json").is_file(): try: data = _load_native(root) - except (OSError, ValueError, RecursionError, TypeError, AttributeError) as exc: + except (OSError, ValueError, RecursionError, RuntimeError, TypeError, AttributeError) as exc: data = DashboardData(warnings=[f"{root}: cannot load retained run: {exc}"]) - subdirectories.clear() output.rows.extend(data.rows) output.warnings.extend(data.warnings) files += 1 continue - for filename in sorted(filenames): - if not filename.endswith(".json"): + try: + entries, truncated = _directory_entries(root, _MAX_PATHS - visited) + except OSError as exc: + output.warnings.append(f"{root}: cannot discover reports: {exc}") + continue + visited += len(entries) + if truncated: + output.warnings.append("Dashboard discovery limit reached; some inputs were omitted.") + subdirectories = [] + for entry in entries: + if files >= _MAX_FILES: + output.warnings.append("Dashboard file limit reached; some inputs were omitted.") + break + if entry.is_symlink(): + continue + if entry.is_dir(): + subdirectories.append(entry) + continue + if entry.suffix != ".json": continue files += 1 try: - data = parse_dashboard_report(_read_json(root / filename), str(root / filename)) + data = parse_dashboard_report(_read_json(entry), str(entry)) except (OSError, ValueError, RecursionError) as exc: - output.warnings.append(f"{root / filename}: cannot read report: {exc}") + output.warnings.append(f"{entry}: cannot read report: {exc}") continue output.rows.extend(data.rows) # Avoid noisy warnings for unrelated config/dataset/summary files. if data.rows: output.warnings.extend(data.warnings) - if files >= _MAX_FILES: - output.warnings.append("Dashboard file limit reached; some inputs were omitted.") - subdirectories.clear() - break + pending.extend(reversed(subdirectories)) if not output.rows: output.warnings.append(f"{path}: no supported Tier 3 agent results found.") return output diff --git a/tests/reporting/test_dashboard_app.py b/tests/reporting/test_dashboard_app.py index 2903965b6..0e77fd823 100644 --- a/tests/reporting/test_dashboard_app.py +++ b/tests/reporting/test_dashboard_app.py @@ -160,6 +160,35 @@ def test_bad_report_does_not_hide_other_results(tmp_path: Path) -> None: assert len(app.dataframe[0].value) == 2 +def test_status_filter_does_not_pair_arms_from_separate_embedded_reports(tmp_path: Path) -> None: + path = _write_report(tmp_path / "combined.json", baseline_status="failed") + first = json.loads(path.read_text()) + second = json.loads(path.read_text()) + second["agents"]["opencode"]["conditions"]["with_skill"]["execution_status"] = "failed" + second["agents"]["opencode"]["conditions"]["without_skill"]["execution_status"] = "succeeded" + path.write_text(json.dumps([first, second])) + app = _app([path]) + app.multiselect(key="filter_status").set_value(["succeeded"]).run() + assert not app.exception + comparisons = app.dataframe[1].value + assert len(comparisons) == 2 + assert comparisons["comparison_status"].tolist() == ["missing condition", "missing condition"] + assert comparisons["score_delta"].isna().all() + + +def test_cyclic_input_path_does_not_hide_valid_report(tmp_path: Path) -> None: + valid = _write_report(tmp_path / "valid.json") + loop = tmp_path / "loop.json" + try: + loop.symlink_to(loop) + except OSError: + pytest.skip("Symlinks are unavailable on this host") + app = _app([loop, valid]) + assert not app.exception + assert "cannot resolve" in app.warning[0].value + assert len(app.dataframe[0].value) == 2 + + @pytest.mark.parametrize( ("view", "measured_column"), [ diff --git a/tests/reporting/test_dashboard_cli.py b/tests/reporting/test_dashboard_cli.py index e552ba239..45c21b456 100644 --- a/tests/reporting/test_dashboard_cli.py +++ b/tests/reporting/test_dashboard_cli.py @@ -47,6 +47,7 @@ def capture(command): assert command[:3] == [sys.executable, "-m", "streamlit"] assert "--server.address=127.0.0.1" in command assert "--server.port=8517" in command + assert "--server.maxUploadSize=16" in command assert "--server.headless=true" in command assert "--browser.gatherUsageStats=false" in command assert command[-2:] == ["--", str(report.resolve())] diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index 53a43ccfd..ce5e278d9 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -136,6 +136,57 @@ def test_disjoint_runs_features_and_duplicate_conditions_cannot_pair() -> None: assert duplicate["score_delta"] is None +@pytest.mark.parametrize("scope", ["reports", "agents"]) +def test_status_filter_cannot_pair_different_report_or_agent_occurrences(scope: str) -> None: + first, second = _report(), _report() + first_agent = first["agents"]["claude-code"] + second_agent = second["agents"]["claude-code"] + first_agent["conditions"]["without_skill"]["execution_status"] = "failed" + second_agent["conditions"]["with_skill"]["execution_status"] = "failed" + if scope == "reports": + payload = [first, second] + else: + first["agents"]["second-occurrence"] = second_agent + payload = first + rows = [row for row in parse_dashboard_report(payload, "combined.json").rows if row["status"] == "succeeded"] + comparisons = comparison_rows(rows) + assert len(comparisons) == 2 + assert all(row["comparison_status"] == "missing condition" for row in comparisons) + assert all(row["score_delta"] is None for row in comparisons) + + +def test_display_identical_feature_labels_cannot_pair_different_configurations() -> None: + report = _report() + conditions = report["agents"]["claude-code"]["conditions"] + conditions["with_skill"]["dashboard_metadata"] = {"harness_features": ["memory, rules"]} + conditions["without_skill"]["dashboard_metadata"] = {"harness_features": ["memory", "rules"]} + rows = parse_dashboard_report(report, "report.json").rows + assert rows[0]["features"] == rows[1]["features"] + assert all(row["comparison_status"] == "missing condition" for row in comparison_rows(rows)) + + +def test_zero_attempt_identity_and_conflicting_attempt_fields() -> None: + report = _report() + agent = report["agents"]["claude-code"] + agent["trials"][0]["attempt"] = 0 + agent["trials_baseline"][0]["attempt"] = "000" + assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["comparison_status"] == "comparable" + agent["trials"][0]["attempt_index"] = 2 + agent["trials_baseline"][0]["attempt"] = 2 + comparison = comparison_rows(parse_dashboard_report(report, "report.json").rows)[0] + assert comparison["comparison_status"] == "incomplete or mismatched coverage" + assert comparison["score_delta"] is None + + +def test_long_numeric_attempt_suffix_is_normalized_without_integer_conversion() -> None: + report = _report() + agent = report["agents"]["claude-code"] + for field in ("trials", "trials_baseline"): + agent[field][0]["trial_id"] = "case-a__attempt" + "9" * 5000 + comparison = comparison_rows(parse_dashboard_report(report, "report.json").rows)[0] + assert comparison["comparison_status"] == "comparable" + + def test_zero_baseline_and_nonfinite_values() -> None: report = _report() agent = report["agents"]["claude-code"] @@ -354,6 +405,98 @@ def test_catalog_native_and_mixed_references_are_loaded_without_cycles(tmp_path: assert any("cyclic" in warning for warning in data.warnings) +def test_nested_catalog_references_load_each_report_once(tmp_path: Path) -> None: + (tmp_path / "report.json").write_text(json.dumps(_report())) + reference = {"report_dir": ".", "json_report": "report.json"} + (tmp_path / "child.json").write_text(json.dumps({"skills": [reference] * 10})) + child = {"report_dir": ".", "json_report": "child.json"} + index = tmp_path / "catalog.json" + index.write_text(json.dumps({"skills": [child] * 10})) + data = load_dashboard_path(index) + assert len(data.rows) == 2 + assert comparison_rows(data.rows)[0]["comparison_status"] == "comparable" + assert not data.warnings + + +def test_catalog_file_budget_is_shared_across_nested_references(tmp_path: Path, monkeypatch) -> None: + from skillevaluator.reporting import dashboard_data + + monkeypatch.setattr(dashboard_data, "_MAX_FILES", 3) + index = tmp_path / "catalog.json" + (tmp_path / "one.json").write_text(json.dumps(_report())) + second = _report() + second["skill_name"] = "second-skill" + (tmp_path / "two.json").write_text(json.dumps(second)) + (tmp_path / "child.json").write_text( + json.dumps({"skills": [{"report_dir": ".", "json_report": name} for name in ("one.json", "two.json")]}) + ) + index.write_text(json.dumps({"skills": [{"report_dir": ".", "json_report": "child.json"}]})) + data = load_dashboard_path(index) + assert len(data.rows) == 2 + assert any("catalog limit" in warning for warning in data.warnings) + + +def test_directory_enumeration_stops_before_materializing_all_entries(tmp_path: Path, monkeypatch) -> None: + from skillevaluator.reporting import dashboard_data + + real_scandir = dashboard_data.os.scandir + scanned = [] + + class CountingScanner: + def __enter__(self): + self.scanner = real_scandir(tmp_path) + return self + + def __exit__(self, *args): + self.scanner.close() + + def __iter__(self): + for entry in self.scanner: + scanned.append(entry.name) + yield entry + + for index in range(20): + (tmp_path / f"report-{index}.json").write_text(json.dumps(_report())) + monkeypatch.setattr(dashboard_data, "_MAX_PATHS", 4) + monkeypatch.setattr(dashboard_data.os, "scandir", lambda _path: CountingScanner()) + data = load_dashboard_path(tmp_path) + assert len(scanned) == 5 + assert len(data.rows) == 8 + assert any("discovery limit" in warning for warning in data.warnings) + + +def test_directory_file_budget_counts_malformed_reports(tmp_path: Path, monkeypatch) -> None: + from skillevaluator.reporting import dashboard_data + + monkeypatch.setattr(dashboard_data, "_MAX_FILES", 3) + for index in range(20): + (tmp_path / f"broken-{index}.json").write_text("{") + data = load_dashboard_path(tmp_path) + assert sum("cannot read report" in warning for warning in data.warnings) == 3 + assert any("file limit" in warning for warning in data.warnings) + + +def test_cyclic_input_catalog_and_native_symlinks_are_diagnostics(tmp_path: Path) -> None: + loop = tmp_path / "loop.json" + try: + loop.symlink_to(loop) + except OSError: + pytest.skip("Symlinks are unavailable on this host") + assert load_dashboard_path(loop).warnings + index = tmp_path / "catalog.json" + index.write_text(json.dumps({"skills": [{"report_dir": ".", "json_report": "loop.json"}]})) + assert load_dashboard_path(index).warnings + run = tmp_path / "run" + _native_run(run) + trials = run / "opencode" / "with-skill" / "trials" + shutil.rmtree(trials) + trials.symlink_to(trials, target_is_directory=True) + data = load_dashboard_path(run) + assert data.rows + assert any("symlink" in warning for warning in data.warnings) + assert next(row for row in data.rows if row["condition"] == "with_skill")["total_tokens"] is None + + def test_uploaded_native_engine_json_needs_retained_artifacts() -> None: raw_result = { "skill_name": "native-skill", @@ -442,6 +585,25 @@ def test_native_different_condition_models_cannot_pair(tmp_path: Path) -> None: assert all(row["comparison_status"] == "missing condition" for row in comparisons) +@pytest.mark.parametrize("artifact", ["trials", "trajectory.json", "result.json", "reward.json"]) +def test_native_usage_rejects_intermediate_directory_and_file_symlinks(tmp_path: Path, artifact: str) -> None: + run = tmp_path / "run" + _native_run(run) + trials = run / "opencode" / "with-skill" / "trials" + target = trials if artifact == "trials" else trials / "case-a__random" / artifact + outside = tmp_path / ("outside-trials" if artifact == "trials" else artifact) + target.rename(outside) + try: + target.symlink_to(outside, target_is_directory=artifact == "trials") + except OSError: + pytest.skip("Symlinks are unavailable on this host") + data = load_dashboard_path(run) + row = next(row for row in data.rows if row["condition"] == "with_skill") + assert row["total_tokens"] is None + assert row["duration_seconds"] is None + assert any("symlink" in warning for warning in data.warnings) + + def test_multistep_native_cost_time_and_tokens_require_every_step(tmp_path: Path) -> None: run = tmp_path / "run" _native_run(run) diff --git a/tests/reporting/test_report_data_bounds.py b/tests/reporting/test_report_data_bounds.py index d32d809e1..09cf8c76f 100644 --- a/tests/reporting/test_report_data_bounds.py +++ b/tests/reporting/test_report_data_bounds.py @@ -78,6 +78,63 @@ def test_normal_agent_artifacts_are_loaded_without_truncation_marker(tmp_path: P assert "_report_truncation" not in agents["codex"] +@pytest.mark.parametrize( + ("metrics", "expected_tokens", "expected_total", "native_total"), + [ + # Without both prompt and completion counters, canonical trials omit the + # token record (unavailable) instead of inventing zeros. + ({}, None, None, 22), + ({"total_prompt_tokens": 12}, None, None, 14), + ( + {"total_prompt_tokens": 0, "total_completion_tokens": 0, "total_cached_tokens": 0}, + {"prompt": 0, "completion": 0, "cached": 0}, + 0, + 0, + ), + ( + {"total_prompt_tokens": 10, "total_completion_tokens": 4, "total_cached_tokens": 2}, + {"prompt": 10, "completion": 4, "cached": 2}, + 14, + 14, + ), + ], +) +def test_missing_token_measurements_stay_unknown_in_canonical_exports( + tmp_path: Path, metrics: dict, expected_tokens: dict | None, expected_total: int | None, native_total: int +) -> None: + from skillevaluator.reporting import HTMLReporter, JSONReporter + from skillevaluator.reporting.dashboard_data import load_dashboard_path, parse_dashboard_report + + agent_dir = tmp_path / "codex" + _write_summary(agent_dir) + _write_trial( + agent_dir, + "case-001__1", + {"entry_id": "case-001", "trial_id": "case-001__1", "accuracy": 1.0}, + {"steps": [], "final_metrics": metrics}, + ) + (tmp_path / "result.json").write_text(json.dumps({"skill_name": "token-measurements"}), encoding="utf-8") + (tmp_path / "run_config.json").write_text( + json.dumps({"agents": {"codex": {"agent": "codex", "model": "test-model"}}}), encoding="utf-8" + ) + # Retained engine counters can recover usage even when an exported + # trajectory has no counters. The canonical export must not invent zeros. + (agent_dir / "with-skill" / "trials" / "case-001__1" / "result.json").write_text( + json.dumps({"agent_result": {"n_input_tokens": 20, "n_output_tokens": 2}}), encoding="utf-8" + ) + + result = agent_eval_result_from_directory(Path("token-measurements"), tmp_path, use_llm_judge=False) + assert result is not None + canonical = result.metadata["agent_eval"] + assert canonical["agents"]["codex"]["trials"][0].get("tokens") == expected_tokens + exported = json.loads(JSONReporter(include_timestamp=False).render_all([result])) + assert exported["results"][0]["tier3"]["agents"]["codex"]["trials"][0].get("tokens") == expected_tokens + assert parse_dashboard_report(exported, "report.json").rows[0]["total_tokens"] == expected_total + assert load_dashboard_path(tmp_path).rows[0]["total_tokens"] == native_total + # Existing HTML token consumers accept unavailable counters without an exception. + assert "tier3-full" in HTMLReporter(include_timestamp=False).render_all([result]) + + def test_report_loader_omits_unrepresentable_trajectory_token_counters(tmp_path: Path) -> None: agent_dir = tmp_path / "codex" _write_summary(agent_dir) From b0a95ad24e52c6bacef3530c5ef46a2c8e15e8ab Mon Sep 17 00:00:00 2001 From: Christopher Kevin Date: Mon, 5 Oct 2026 00:32:32 -0700 Subject: [PATCH 05/40] fix(dashboard): reject invalid coverage and align upload limits Signed-off-by: Christopher Kevin --- CHANGELOG.md | 2 + docs/reports.mdx | 3 + src/skillevaluator/reporting/dashboard_app.py | 6 +- .../reporting/dashboard_data.py | 49 +++++++++--- tests/reporting/test_dashboard_app.py | 3 +- tests/reporting/test_dashboard_data.py | 74 +++++++++++++++++++ 6 files changed, 123 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 101c73187..ac42c5174 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -307,6 +307,8 @@ All notable changes to SkillEvaluator are documented in this file. - Preserve missing Tier 3 token counters as `null` in canonical JSON exports instead of reporting unmeasured usage as zero. +- Keep dashboard comparisons unavailable for contradictory trial identities or + invalid coverage counts, and enforce the documented 16 MB browser upload limit. - Report non-string YAML keys as validation errors in skills, rules, workflows, and plugin manifests instead of raising a `TypeError`, including frontmatter `metadata` keys. Show boolean, null, and date keys in a readable YAML form. diff --git a/docs/reports.mdx b/docs/reports.mdx index 579e63f93..c2663ee95 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -552,6 +552,9 @@ skillevaluator dashboard From a checkout, use `uv run --extra dashboard skillevaluator dashboard ...`. The server runs at `http://127.0.0.1:8501`; use `--port 8502` for another port, `--no-browser` to suppress opening a browser, and Ctrl+C to stop it. +Browser uploads accept up to 16 MB (16,000,000 bytes) per file. Local JSON files +accept up to 16 MiB (16,777,216 bytes); larger files produce a notice while other +valid reports remain available. Filter the sortable tables by skill, model, harness, recorded harness features, condition, and execution status. Download the visible performance or comparison diff --git a/src/skillevaluator/reporting/dashboard_app.py b/src/skillevaluator/reporting/dashboard_app.py index 65ce69547..d1096bfb5 100644 --- a/src/skillevaluator/reporting/dashboard_app.py +++ b/src/skillevaluator/reporting/dashboard_app.py @@ -21,7 +21,7 @@ from skillevaluator.reporting.dashboard_data import comparison_rows, load_dashboard_path, parse_dashboard_report _DIMENSIONS = ("skill", "model", "harness", "features") -_MAX_UPLOAD_BYTES = 16 * 1024 * 1024 +_MAX_UPLOAD_BYTES = 16_000_000 _CONDITION_NAMES = {"with_skill": "With skill", "without_skill": "Without skill", "adverse": "Adverse skill"} _USAGE_METRICS = ("total_tokens", "prompt_tokens", "completion_tokens", "cached_tokens", "duration_seconds", "cost_usd") _PERFORMANCE_COLUMNS = ( @@ -263,7 +263,7 @@ def main(paths: list[str] | None = None) -> None: "Upload JSON reports", type=["json"], accept_multiple_files=True, - help="Use Tier 3 JSON reports or consolidated SkillEvaluator JSON reports, up to 16 MiB per file.", + help="Use Tier 3 JSON reports or consolidated SkillEvaluator JSON reports, up to 16 MB (16,000,000 bytes) per file.", key="report_uploads", ) rows: list[dict[str, Any]] = [] @@ -284,7 +284,7 @@ def main(paths: list[str] | None = None) -> None: for index, uploaded in enumerate(uploads): contents = uploaded.getvalue() if len(contents) > _MAX_UPLOAD_BYTES: - warnings.append(f"{uploaded.name}: report exceeds 16 MiB. Upload a smaller evaluation report.") + warnings.append(f"{uploaded.name}: report exceeds 16 MB (16,000,000 bytes). Upload a smaller evaluation report.") continue try: payload = json.loads(contents) diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index 5174ac6c4..0ab37c369 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -152,20 +152,12 @@ def _trial_keys(trials: list[dict[str, Any]]) -> tuple[tuple[str, str], ...] | N counts: Counter[str] = Counter() keys = [] implicit: set[str] = set() - seen_trials: dict[str, str] = {} + seen_trials: dict[str, tuple[str, str | None]] = {} for trial in trials: entry = trial.get("entry_id") if not isinstance(entry, str) or not entry: return None trial_id = str(trial.get("trial_id") or "") - if trial_id and trial_id in seen_trials: - if seen_trials[trial_id] != entry: - return None - # Fallback multi-step rewards share one physical attempt identity. - continue - if trial_id: - seen_trials[trial_id] = entry - counts[entry] += 1 attempts = [trial[field] for field in ("attempt", "attempt_index") if trial.get(field) is not None] normalized_attempts = [] for attempt in attempts: @@ -183,6 +175,14 @@ def _trial_keys(trials: list[dict[str, Any]]) -> tuple[tuple[str, str], ...] | N matches = re.findall(r"(?:__|_|-)attempt[_-]?(\d+)(?=__|$)", trial_id) if attempt is None and matches: attempt = matches[-1].lstrip("0") or "0" + if trial_id and trial_id in seen_trials: + if seen_trials[trial_id] != (entry, attempt): + return None + # Fallback multi-step rewards share one consistent attempt identity. + continue + if trial_id: + seen_trials[trial_id] = (entry, attempt) + counts[entry] += 1 if attempt is None: implicit.add(entry) keys.append((entry, str(attempt) if attempt is not None else f"ordinal:{counts[entry]}")) @@ -272,6 +272,19 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: status = details.get("execution_status") or agent.get("execution_status") or "unknown" if not isinstance(status, str) or status not in {"succeeded", "failed", "unknown", "skipped"}: status = "unknown" + invalid_counts = any( + owner.get(key) is not None and _count(owner[key]) is None + for owner, key in ( + (agent, count_field), + (details, "expected_attempts"), + (details, "scored_attempts"), + ) + ) + if invalid_counts: + output.warnings.append( + f"{source}: {name}/{condition}: invalid trial coverage counts; " + "measurements and comparisons are unavailable." + ) declared = _count(agent.get(count_field)) if declared is None: declared = len(trials) @@ -290,6 +303,7 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: output.warnings.append(notice) complete = ( status == "succeeded" + and not invalid_counts and declared > 0 and len(trials) == declared and keys is not None @@ -312,6 +326,7 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: if complete else None, "_complete": complete, + "_invalid_counts": invalid_counts, "_report_index": report_index, "_agent_key": str(name), "_trial_keys": keys, @@ -325,7 +340,11 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: _set_features(row, details, agent, report) _set_usage( row, - [{} if str(trial.get("trial_id") or "") in ambiguous_ids else _usage(trial) for trial in trials], + [] + if invalid_counts + else [ + {} if str(trial.get("trial_id") or "") in ambiguous_ids else _usage(trial) for trial in trials + ], expected=declared + max(0, row["_expected_usage_trials"] - logical_count), ) output.rows.append(row) @@ -500,6 +519,16 @@ def _load_native(path: Path) -> DashboardData: condition_summary = _dict(_read_native_json(summary_path, path)) row["model"] = str(condition_summary.get("model") or row["model"]) _set_features(row, condition_summary, agent_config, run_config) + row["_invalid_counts"] |= any( + condition_summary.get(key) is not None and _count(condition_summary[key]) is None + for key in ("num_trials", "expected_attempts", "scored_attempts") + ) + if row["_invalid_counts"]: + row["_complete"] = False + row["score"] = row["pass_rate"] = None + _set_usage(row, [], expected=row["_expected_usage_trials"]) + output.warnings.append(f"{summary_path}: invalid trial coverage counts; measurements are unavailable.") + continue trials_dir = path / name / variant / "trials" usages_by_trial: dict[str, dict[str, Any]] = {} if not _safe_native_path(trials_dir, path): diff --git a/tests/reporting/test_dashboard_app.py b/tests/reporting/test_dashboard_app.py index 0e77fd823..f8e79e2e8 100644 --- a/tests/reporting/test_dashboard_app.py +++ b/tests/reporting/test_dashboard_app.py @@ -185,7 +185,8 @@ def test_cyclic_input_path_does_not_hide_valid_report(tmp_path: Path) -> None: pytest.skip("Symlinks are unavailable on this host") app = _app([loop, valid]) assert not app.exception - assert "cannot resolve" in app.warning[0].value + assert len(app.warning) == 1 + assert str(loop) in app.warning[0].value assert len(app.dataframe[0].value) == 2 diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index ce5e278d9..7ba2b8097 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -103,6 +103,38 @@ def test_canonical_missing_attempt_keeps_usage_totals_unknown() -> None: assert "tokens 1/2" in row["coverage"] +@pytest.mark.parametrize("value", [True, -1, 1.5, "1"]) +@pytest.mark.parametrize("field", ["declared", "expected", "both_attempt_counts"]) +def test_present_invalid_coverage_counts_never_become_inferred_complete_counts(value: object, field: str) -> None: + report = _report() + agent = report["agents"]["claude-code"] + if field == "declared": + agent["num_trials"] = value + else: + agent["conditions"]["with_skill"]["expected_attempts"] = value + if field == "both_attempt_counts": + agent["conditions"]["with_skill"]["scored_attempts"] = value + data = parse_dashboard_report(report, "report.json") + assert data.rows[0]["score"] is None + assert data.rows[0]["total_tokens"] is None + assert data.rows[0]["duration_seconds"] is None + assert any("invalid trial coverage counts" in warning for warning in data.warnings) + comparison = comparison_rows(data.rows)[0] + assert comparison["comparison_status"] == "incomplete or mismatched coverage" + assert comparison["score_delta"] is None + + +def test_unrecorded_legacy_coverage_counts_preserve_observed_trial_pairing() -> None: + report = _report() + agent = report["agents"]["claude-code"] + for field in ("num_trials", "num_trials_baseline"): + agent.pop(field) + for condition in agent["conditions"].values(): + condition.pop("expected_attempts") + condition["scored_attempts"] = None + assert comparison_rows(parse_dashboard_report(report, "legacy.json").rows)[0]["comparison_status"] == "comparable" + + @pytest.mark.parametrize("mutation", ["failed", "missing_trial", "truncated", "different_case", "missing_attempt"]) def test_incomplete_or_unmatched_arms_block_all_deltas(mutation: str) -> None: report = _report() @@ -258,6 +290,28 @@ def test_multistep_rewards_keep_logical_scores_without_ambiguous_resource_sums() assert parse_dashboard_report(report, "report.json").rows[0]["total_tokens"] is None +@pytest.mark.parametrize("conflict", ["different_attempt", "conflicting_fields", "invalid_attempt"]) +def test_duplicate_physical_trials_require_consistent_attempt_identity(conflict: str) -> None: + report = _report() + agent = report["agents"]["claude-code"] + for field, count in (("trials", "num_trials"), ("trials_baseline", "num_trials_baseline")): + agent[field][0]["attempt"] = 1 + agent[field].append(copy.deepcopy(agent[field][0])) + agent[count] = 2 + assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["comparison_status"] == "comparable" + duplicate = agent["trials"][1] + if conflict == "different_attempt": + duplicate["attempt"] = 2 + elif conflict == "conflicting_fields": + duplicate["attempt_index"] = 2 + else: + duplicate["attempt"] = True + comparison = comparison_rows(parse_dashboard_report(report, "report.json").rows)[0] + assert comparison["comparison_status"] == "incomplete or mismatched coverage" + assert comparison["score_delta"] is None + assert comparison["pass_rate_delta"] is None + + def test_explicit_adverse_row_has_no_invented_baseline_delta() -> None: report = _report() agent = report["agents"]["claude-code"] @@ -585,6 +639,26 @@ def test_native_different_condition_models_cannot_pair(tmp_path: Path) -> None: assert all(row["comparison_status"] == "missing condition" for row in comparisons) +@pytest.mark.parametrize("value", [True, -1, 1.5, "1"]) +@pytest.mark.parametrize("field", ["num_trials", "expected_attempts", "scored_attempts"]) +def test_native_invalid_coverage_counts_cannot_be_hidden_by_canonical_normalization( + tmp_path: Path, field: str, value: object +) -> None: + run = tmp_path / "run" + _native_run(run) + summary_path = run / "opencode" / "with-skill" / "summary.json" + summary = json.loads(summary_path.read_text()) + summary[field] = value + summary_path.write_text(json.dumps(summary)) + data = load_dashboard_path(run) + row = next(row for row in data.rows if row["condition"] == "with_skill") + assert row["score"] is None + assert row["total_tokens"] is None + assert row["duration_seconds"] is None + assert any("invalid trial coverage counts" in warning for warning in data.warnings) + assert comparison_rows(data.rows)[0]["score_delta"] is None + + @pytest.mark.parametrize("artifact", ["trials", "trajectory.json", "result.json", "reward.json"]) def test_native_usage_rejects_intermediate_directory_and_file_symlinks(tmp_path: Path, artifact: str) -> None: run = tmp_path / "run" From 0800f0374400073364a280ae5f8ec472db76c2a0 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Wed, 14 Oct 2026 04:09:08 -0700 Subject: [PATCH 06/40] fix(dashboard): detect multi-step reward rows in retained runs Main's canonical Tier 3 report now collapses reward rows that share one physical trial into one logical trial and omits their token counters, and the collector's num_trials counts logical trials (num_reward_rows counts the rows). The dashboard found multi-step trials only through duplicate trial IDs in canonical trials, so after the merge a retained multi-step run without step_results reported the root mirror's tokens as the trial's usage. Count shared reward trial IDs in the retained trial directories, require authoritative step_results for those trials, and keep the ambiguity notice. The test fixture now writes the collector's current summary shape. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- .../reporting/dashboard_data.py | 45 ++++++++++++++----- tests/reporting/test_dashboard_data.py | 3 +- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index 0ab37c369..60ec9b9ae 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -224,6 +224,13 @@ def _set_usage(row: dict[str, Any], usages: list[dict[str, Any]], expected: int ) +def _ambiguous_resource_notice(source: str) -> str: + return ( + f"{source}: canonical multi-step resource ownership is ambiguous; " + "usage totals are unavailable. Load the retained run directory for authoritative step measurements." + ) + + def parse_dashboard_report(payload: Any, source: str) -> DashboardData: """Normalize canonical Tier 3, validate-report, and embedded catalog JSON.""" output = DashboardData() @@ -295,10 +302,7 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: physical_counts = Counter(str(trial["trial_id"]) for trial in trials if trial.get("trial_id")) ambiguous_ids = {trial_id for trial_id, count in physical_counts.items() if count > 1} if ambiguous_ids: - notice = ( - f"{source}: canonical multi-step resource ownership is ambiguous; " - "usage totals are unavailable. Load the retained run directory for authoritative step measurements." - ) + notice = _ambiguous_resource_notice(source) if notice not in output.warnings: output.warnings.append(notice) complete = ( @@ -539,17 +543,34 @@ def _load_native(path: Path) -> DashboardData: trial_paths, truncated = _directory_entries(trials_dir, 4096) trial_dirs = [candidate for candidate in trial_paths if candidate.is_dir() and not candidate.is_symlink()] truncated |= len(trial_dirs) > 512 + loaded: list[tuple[Path, dict[str, Any] | None]] = [] for trial_dir in trial_dirs[:512]: if not trial_dir.is_dir() or trial_dir.is_symlink(): continue try: - reward = _dict(_read_native_json(trial_dir / "reward.json", path)) - physical_id = str(reward.get("trial_id") or trial_dir.name) - if physical_id not in usages_by_trial: - usages_by_trial[physical_id] = _native_usage( - trial_dir, path, require_steps=physical_id in row["_ambiguous_trial_ids"] - ) - unresolved_scope |= usages_by_trial[physical_id].get("_resource_scope_valid") is False + loaded.append((trial_dir, _dict(_read_native_json(trial_dir / "reward.json", path)))) + except (OSError, ValueError, RecursionError) as exc: + output.warnings.append(f"{trial_dir}: cannot read usage: {exc}") + loaded.append((trial_dir, None)) + # Canonical reports collapse reward rows that share one physical + # trial, so count shared identities in the retained rows themselves. + physical_counts = Counter( + str(reward.get("trial_id") or trial_dir.name) for trial_dir, reward in loaded if reward is not None + ) + for trial_dir, reward in loaded: + if reward is None: + usages_by_trial[trial_dir.name] = {} + continue + physical_id = str(reward.get("trial_id") or trial_dir.name) + if physical_id in usages_by_trial: + continue + try: + usages_by_trial[physical_id] = _native_usage( + trial_dir, + path, + require_steps=physical_counts[physical_id] > 1 or physical_id in row["_ambiguous_trial_ids"], + ) + unresolved_scope |= usages_by_trial[physical_id].get("_resource_scope_valid") is False except (OSError, ValueError, RecursionError) as exc: output.warnings.append(f"{trial_dir}: cannot read usage: {exc}") usages_by_trial[trial_dir.name] = {} @@ -562,6 +583,8 @@ def _load_native(path: Path) -> DashboardData: output.warnings = [ warning for warning in output.warnings if "canonical multi-step resource ownership" not in warning ] + elif not any("canonical multi-step resource ownership" in warning for warning in output.warnings): + output.warnings.append(_ambiguous_resource_notice(str(path))) return output diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index 7ba2b8097..fd5caea85 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -711,7 +711,8 @@ def test_native_duplicate_reward_rows_require_authoritative_step_scope(tmp_path: shutil.copytree(first, second) summary_path = condition / "summary.json" summary = json.loads(summary_path.read_text()) - summary["num_trials"] = 2 + # The collector counts one logical trial and records its two reward rows. + summary["num_reward_rows"] = 2 summary_path.write_text(json.dumps(summary)) for trial_dir in (first, second): result_path = trial_dir / "result.json" From dac9ec8f483b4fb31a8c56481b7ce81ce9e370fa Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Wed, 14 Oct 2026 04:09:23 -0700 Subject: [PATCH 07/40] docs(dashboard): describe unmeasured token usage as omitted After the merge, canonical Tier 3 trials take main's representation: they leave out the token record when prompt or completion usage was not measured instead of writing null counters. Update the changelog entry and the dashboard guide to match. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- CHANGELOG.md | 4 ++-- docs/reports.mdx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac42c5174..a4619f063 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -305,8 +305,8 @@ All notable changes to SkillEvaluator are documented in this file. ### Fixed -- Preserve missing Tier 3 token counters as `null` in canonical JSON exports - instead of reporting unmeasured usage as zero. +- Omit unmeasured Tier 3 token usage from canonical JSON exports instead of + reporting it as zero. - Keep dashboard comparisons unavailable for contradictory trial identities or invalid coverage counts, and enforce the documented 16 MB browser upload limit. - Report non-string YAML keys as validation errors in skills, rules, workflows, diff --git a/docs/reports.mdx b/docs/reports.mdx index c2663ee95..015a57cf0 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -568,7 +568,7 @@ Missing measurements stay unavailable: older JSON reports may contain token counts without time or cost, and cost is shown only when recorded in USD. Some older exports encoded missing token counters as zero. Open their retained run directories to recover recorded counters, or regenerate the canonical JSON -with this version to preserve missing measurements as `null`. +with this version, which omits unmeasured token usage instead of recording zero. For retained runs, duration measures agent execution rather than the entire evaluation workflow. Cached tokens are shown separately and are not added again to prompt plus completion tokens. No pricing estimates or new agent evaluations From 1b489e5afdf643bf455a592e4b13df34d44ad996 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 01:43:19 -0700 Subject: [PATCH 08/40] style(dashboard): apply ruff format to dashboard_app.py Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- src/skillevaluator/reporting/dashboard_app.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/skillevaluator/reporting/dashboard_app.py b/src/skillevaluator/reporting/dashboard_app.py index d1096bfb5..4655b5ceb 100644 --- a/src/skillevaluator/reporting/dashboard_app.py +++ b/src/skillevaluator/reporting/dashboard_app.py @@ -284,7 +284,9 @@ def main(paths: list[str] | None = None) -> None: for index, uploaded in enumerate(uploads): contents = uploaded.getvalue() if len(contents) > _MAX_UPLOAD_BYTES: - warnings.append(f"{uploaded.name}: report exceeds 16 MB (16,000,000 bytes). Upload a smaller evaluation report.") + warnings.append( + f"{uploaded.name}: report exceeds 16 MB (16,000,000 bytes). Upload a smaller evaluation report." + ) continue try: payload = json.loads(contents) @@ -320,7 +322,9 @@ def main(paths: list[str] | None = None) -> None: summary[1].metric("Skills", skill_count) summary[2].metric("Condition rows", len(performance_rows)) summary[3].metric("Scored rows", scored_count) - st.caption("Blank cells mean a measurement is missing, incomplete, or ambiguous. Unknown settings remain labeled unknown.") + st.caption( + "Blank cells mean a measurement is missing, incomplete, or ambiguous. Unknown settings remain labeled unknown." + ) performance_tab, comparison_tab = st.tabs(["Performance", "With vs without skill"]) with performance_tab: _show_performance(performance_rows) From 6a7665b1fa84db029fc8ee9b0fc058f33ad32b0e Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 01:43:57 -0700 Subject: [PATCH 09/40] test(dashboard): use UTF-8 test I/O and a wider AppTest budget The Windows CI job decodes encoding-less read_text/write_text as cp1252, so every dashboard test file read or write now passes encoding="utf-8". AppTest's default_timeout is a wall-clock budget, and the first st.dataframe in each xdist worker imports pandas and pyarrow inside that timed thread (about 7 s cold against 1.5 s warm). Import them before AppTest and raise the ceiling to 60 s; passing runs are not slower. A cold `-n 8` run of tests/reporting had two AppTest failures that passed on the next run. Also assert that `dashboard` is listed under Core workflows in --help. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- tests/reporting/test_dashboard_app.py | 14 +++- tests/reporting/test_dashboard_data.py | 102 ++++++++++++++----------- tests/test_cli.py | 2 +- 3 files changed, 68 insertions(+), 50 deletions(-) diff --git a/tests/reporting/test_dashboard_app.py b/tests/reporting/test_dashboard_app.py index f8e79e2e8..3d1fa1bbe 100644 --- a/tests/reporting/test_dashboard_app.py +++ b/tests/reporting/test_dashboard_app.py @@ -13,10 +13,16 @@ import pytest pytest.importorskip("streamlit") +# st.dataframe otherwise imports these inside AppTest's timed script thread. +pytest.importorskip("pandas") +pytest.importorskip("pyarrow") from streamlit.testing.v1 import AppTest from skillevaluator.reporting.dashboard_app import rows_csv +# A ceiling for cold imports under xdist and coverage; passing runs finish far sooner. +_APP_TIMEOUT_SECONDS = 60 + def _write_report( path: Path, @@ -69,7 +75,7 @@ def trial(score: float, tokens: int) -> dict: def _app(paths: list[Path]) -> AppTest: script = f"from skillevaluator.reporting.dashboard_app import main\nmain({[str(path) for path in paths]!r})\n" - return AppTest.from_string(script, default_timeout=15).run() + return AppTest.from_string(script, default_timeout=_APP_TIMEOUT_SECONDS).run() def test_empty_dashboard_has_upload_direction() -> None: @@ -162,11 +168,11 @@ def test_bad_report_does_not_hide_other_results(tmp_path: Path) -> None: def test_status_filter_does_not_pair_arms_from_separate_embedded_reports(tmp_path: Path) -> None: path = _write_report(tmp_path / "combined.json", baseline_status="failed") - first = json.loads(path.read_text()) - second = json.loads(path.read_text()) + first = json.loads(path.read_text(encoding="utf-8")) + second = json.loads(path.read_text(encoding="utf-8")) second["agents"]["opencode"]["conditions"]["with_skill"]["execution_status"] = "failed" second["agents"]["opencode"]["conditions"]["without_skill"]["execution_status"] = "succeeded" - path.write_text(json.dumps([first, second])) + path.write_text(json.dumps([first, second]), encoding="utf-8") app = _app([path]) app.multiselect(key="filter_status").set_value(["succeeded"]).run() assert not app.exception diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index fd5caea85..d97ac25ee 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -359,7 +359,7 @@ def test_bad_input_is_diagnostic_and_directory_skips_symlinks(tmp_path: Path) -> def test_catalog_index_loads_authoritative_local_reports_with_containment(tmp_path: Path) -> None: reports = tmp_path / "calculator" reports.mkdir() - (reports / "current.json").write_text(json.dumps(_report())) + (reports / "current.json").write_text(json.dumps(_report()), encoding="utf-8") index = tmp_path / "catalog-summary.json" index.write_text( json.dumps( @@ -369,7 +369,8 @@ def test_catalog_index_loads_authoritative_local_reports_with_containment(tmp_pa {"report_dir": "..", "json_report": "outside.json"}, ] } - ) + ), + encoding="utf-8", ) data = load_dashboard_path(index) assert len(data.rows) == 2 @@ -379,8 +380,12 @@ def test_catalog_index_loads_authoritative_local_reports_with_containment(tmp_pa def _native_run(path: Path) -> None: metrics = ["security", "skill_execution", "skill_efficiency", "accuracy", "goal_accuracy", "behavior_check"] path.mkdir() - (path / "result.json").write_text(json.dumps({"skill_name": "native-skill", "run_id": "native-run"})) - (path / "run_config.json").write_text(json.dumps({"agents": {"opencode": {"agent": "opencode", "model": "m"}}})) + (path / "result.json").write_text( + json.dumps({"skill_name": "native-skill", "run_id": "native-run"}), encoding="utf-8" + ) + (path / "run_config.json").write_text( + json.dumps({"agents": {"opencode": {"agent": "opencode", "model": "m"}}}), encoding="utf-8" + ) for variant, input_tokens in (("with-skill", 200), ("without-skill", 100)): condition = path / "opencode" / variant trial = condition / "trials" / "case-a__random" @@ -397,7 +402,8 @@ def _native_run(path: Path) -> None: "expected_attempts": 1, "scored_attempts": 1, } - ) + ), + encoding="utf-8", ) (trial / "reward.json").write_text( json.dumps( @@ -407,7 +413,8 @@ def _native_run(path: Path) -> None: "trial_id": "case-a__random", "overall": 0.8, } - ) + ), + encoding="utf-8", ) (trial / "trajectory.json").write_text( json.dumps( @@ -415,7 +422,8 @@ def _native_run(path: Path) -> None: "steps": [], "final_metrics": {"total_prompt_tokens": input_tokens, "total_completion_tokens": 10}, } - ) + ), + encoding="utf-8", ) (trial / "result.json").write_text( json.dumps( @@ -423,14 +431,15 @@ def _native_run(path: Path) -> None: "agent_result": {"n_input_tokens": input_tokens, "n_output_tokens": 10, "cost_usd": None}, "agent_execution": {"started_at": "2026-10-01T00:00:00Z", "finished_at": "2026-10-01T00:00:10Z"}, } - ) + ), + encoding="utf-8", ) def test_native_results_use_real_usage_and_prune_nested_mirrors(tmp_path: Path) -> None: run = tmp_path / "run" _native_run(run) - (run / "report.json").write_text(json.dumps(_report())) + (run / "report.json").write_text(json.dumps(_report()), encoding="utf-8") data = load_dashboard_path(tmp_path) assert len(data.rows) == 2 assert data.rows[0]["skill"] == "native-skill" @@ -449,23 +458,25 @@ def test_catalog_native_and_mixed_references_are_loaded_without_cycles(tmp_path: _native_run(run) index = tmp_path / "catalog.json" reference = {"report_dir": "run", "json_report": "result.json"} - index.write_text(json.dumps({"skills": [reference]})) + index.write_text(json.dumps({"skills": [reference]}), encoding="utf-8") assert load_dashboard_path(index).rows == load_dashboard_path(run).rows - index.write_text(json.dumps({"skills": [{"tier3": _report()}, reference]})) + index.write_text(json.dumps({"skills": [{"tier3": _report()}, reference]}), encoding="utf-8") assert len(load_dashboard_path(index).rows) == 4 - index.write_text(json.dumps({"skills": [reference, {"report_dir": ".", "json_report": "catalog.json"}]})) + index.write_text( + json.dumps({"skills": [reference, {"report_dir": ".", "json_report": "catalog.json"}]}), encoding="utf-8" + ) data = load_dashboard_path(index) assert len(data.rows) == 2 assert any("cyclic" in warning for warning in data.warnings) def test_nested_catalog_references_load_each_report_once(tmp_path: Path) -> None: - (tmp_path / "report.json").write_text(json.dumps(_report())) + (tmp_path / "report.json").write_text(json.dumps(_report()), encoding="utf-8") reference = {"report_dir": ".", "json_report": "report.json"} - (tmp_path / "child.json").write_text(json.dumps({"skills": [reference] * 10})) + (tmp_path / "child.json").write_text(json.dumps({"skills": [reference] * 10}), encoding="utf-8") child = {"report_dir": ".", "json_report": "child.json"} index = tmp_path / "catalog.json" - index.write_text(json.dumps({"skills": [child] * 10})) + index.write_text(json.dumps({"skills": [child] * 10}), encoding="utf-8") data = load_dashboard_path(index) assert len(data.rows) == 2 assert comparison_rows(data.rows)[0]["comparison_status"] == "comparable" @@ -477,14 +488,15 @@ def test_catalog_file_budget_is_shared_across_nested_references(tmp_path: Path, monkeypatch.setattr(dashboard_data, "_MAX_FILES", 3) index = tmp_path / "catalog.json" - (tmp_path / "one.json").write_text(json.dumps(_report())) + (tmp_path / "one.json").write_text(json.dumps(_report()), encoding="utf-8") second = _report() second["skill_name"] = "second-skill" - (tmp_path / "two.json").write_text(json.dumps(second)) + (tmp_path / "two.json").write_text(json.dumps(second), encoding="utf-8") (tmp_path / "child.json").write_text( - json.dumps({"skills": [{"report_dir": ".", "json_report": name} for name in ("one.json", "two.json")]}) + json.dumps({"skills": [{"report_dir": ".", "json_report": name} for name in ("one.json", "two.json")]}), + encoding="utf-8", ) - index.write_text(json.dumps({"skills": [{"report_dir": ".", "json_report": "child.json"}]})) + index.write_text(json.dumps({"skills": [{"report_dir": ".", "json_report": "child.json"}]}), encoding="utf-8") data = load_dashboard_path(index) assert len(data.rows) == 2 assert any("catalog limit" in warning for warning in data.warnings) @@ -510,7 +522,7 @@ def __iter__(self): yield entry for index in range(20): - (tmp_path / f"report-{index}.json").write_text(json.dumps(_report())) + (tmp_path / f"report-{index}.json").write_text(json.dumps(_report()), encoding="utf-8") monkeypatch.setattr(dashboard_data, "_MAX_PATHS", 4) monkeypatch.setattr(dashboard_data.os, "scandir", lambda _path: CountingScanner()) data = load_dashboard_path(tmp_path) @@ -524,7 +536,7 @@ def test_directory_file_budget_counts_malformed_reports(tmp_path: Path, monkeypa monkeypatch.setattr(dashboard_data, "_MAX_FILES", 3) for index in range(20): - (tmp_path / f"broken-{index}.json").write_text("{") + (tmp_path / f"broken-{index}.json").write_text("{", encoding="utf-8") data = load_dashboard_path(tmp_path) assert sum("cannot read report" in warning for warning in data.warnings) == 3 assert any("file limit" in warning for warning in data.warnings) @@ -538,7 +550,7 @@ def test_cyclic_input_catalog_and_native_symlinks_are_diagnostics(tmp_path: Path pytest.skip("Symlinks are unavailable on this host") assert load_dashboard_path(loop).warnings index = tmp_path / "catalog.json" - index.write_text(json.dumps({"skills": [{"report_dir": ".", "json_report": "loop.json"}]})) + index.write_text(json.dumps({"skills": [{"report_dir": ".", "json_report": "loop.json"}]}), encoding="utf-8") assert load_dashboard_path(index).warnings run = tmp_path / "run" _native_run(run) @@ -575,13 +587,13 @@ def test_malformed_native_schema_is_diagnostic_and_preserves_other_sources(tmp_p _native_run(run) if malformation == "summary_status": path = run / "opencode" / "with-skill" / "summary.json" - summary = json.loads(path.read_text()) + summary = json.loads(path.read_text(encoding="utf-8")) summary["execution_status"] = ["succeeded"] - path.write_text(json.dumps(summary)) + path.write_text(json.dumps(summary), encoding="utf-8") else: - (run / "run_config.json").write_text(json.dumps({"agents": [{"agent": "opencode"}]})) + (run / "run_config.json").write_text(json.dumps({"agents": [{"agent": "opencode"}]}), encoding="utf-8") assert load_dashboard_path(run / "result.json").warnings - (tmp_path / "valid.json").write_text(json.dumps(_report())) + (tmp_path / "valid.json").write_text(json.dumps(_report()), encoding="utf-8") data = load_dashboard_path(tmp_path) assert len(data.rows) == 2 assert {row["skill"] for row in data.rows} == {"calculator"} @@ -593,9 +605,9 @@ def test_native_missing_attempt_does_not_publish_partial_usage_as_total(tmp_path _native_run(run) for variant in ("with-skill", "without-skill"): summary_path = run / "opencode" / variant / "summary.json" - summary = json.loads(summary_path.read_text()) + summary = json.loads(summary_path.read_text(encoding="utf-8")) summary.update(num_trials=2, expected_attempts=2, scored_attempts=2) - summary_path.write_text(json.dumps(summary)) + summary_path.write_text(json.dumps(summary), encoding="utf-8") data = load_dashboard_path(run) assert all(row["score"] is None and row["total_tokens"] is None for row in data.rows) assert all(row["duration_seconds"] is None for row in data.rows) @@ -615,13 +627,13 @@ def test_native_generated_stop_on_pass_names_preserve_attempt_sets(tmp_path: Pat shutil.copytree(first, second) for trial_dir in (first, second): reward_path = trial_dir / "reward.json" - reward = json.loads(reward_path.read_text()) + reward = json.loads(reward_path.read_text(encoding="utf-8")) reward["trial_id"] = trial_dir.name - reward_path.write_text(json.dumps(reward)) + reward_path.write_text(json.dumps(reward), encoding="utf-8") summary_path = condition / "summary.json" - summary = json.loads(summary_path.read_text()) + summary = json.loads(summary_path.read_text(encoding="utf-8")) summary.update(num_trials=2, expected_attempts=2, scored_attempts=2) - summary_path.write_text(json.dumps(summary)) + summary_path.write_text(json.dumps(summary), encoding="utf-8") data = load_dashboard_path(run) assert all(row["trials"] == 2 and row["score"] == 0.8 for row in data.rows) assert comparison_rows(data.rows)[0]["comparison_status"] == "comparable" @@ -631,9 +643,9 @@ def test_native_different_condition_models_cannot_pair(tmp_path: Path) -> None: run = tmp_path / "run" _native_run(run) baseline_summary = run / "opencode" / "without-skill" / "summary.json" - summary = json.loads(baseline_summary.read_text()) + summary = json.loads(baseline_summary.read_text(encoding="utf-8")) summary["model"] = "different-model" - baseline_summary.write_text(json.dumps(summary)) + baseline_summary.write_text(json.dumps(summary), encoding="utf-8") comparisons = comparison_rows(load_dashboard_path(run).rows) assert len(comparisons) == 2 assert all(row["comparison_status"] == "missing condition" for row in comparisons) @@ -647,9 +659,9 @@ def test_native_invalid_coverage_counts_cannot_be_hidden_by_canonical_normalizat run = tmp_path / "run" _native_run(run) summary_path = run / "opencode" / "with-skill" / "summary.json" - summary = json.loads(summary_path.read_text()) + summary = json.loads(summary_path.read_text(encoding="utf-8")) summary[field] = value - summary_path.write_text(json.dumps(summary)) + summary_path.write_text(json.dumps(summary), encoding="utf-8") data = load_dashboard_path(run) row = next(row for row in data.rows if row["condition"] == "with_skill") assert row["score"] is None @@ -682,20 +694,20 @@ def test_multistep_native_cost_time_and_tokens_require_every_step(tmp_path: Path run = tmp_path / "run" _native_run(run) trial_result = run / "opencode" / "with-skill" / "trials" / "case-a__random" / "result.json" - result = json.loads(trial_result.read_text()) + result = json.loads(trial_result.read_text(encoding="utf-8")) step = { "agent_result": {"n_input_tokens": 50, "n_output_tokens": 5, "n_cache_tokens": 0, "cost_usd": 0.1}, "agent_execution": {"started_at": "2026-10-01T00:00:00Z", "finished_at": "2026-10-01T00:00:03Z"}, } result["step_results"] = [step, copy.deepcopy(step)] - trial_result.write_text(json.dumps(result)) + trial_result.write_text(json.dumps(result), encoding="utf-8") row = load_dashboard_path(run).rows[0] assert row["prompt_tokens"] == 100 assert row["duration_seconds"] == 6 assert row["cost_usd"] == pytest.approx(0.2) result["step_results"][1]["agent_result"].pop("n_input_tokens") result["step_results"][1]["agent_result"].pop("cost_usd") - trial_result.write_text(json.dumps(result)) + trial_result.write_text(json.dumps(result), encoding="utf-8") row = load_dashboard_path(run).rows[0] assert row["prompt_tokens"] is None assert row["total_tokens"] is None @@ -710,20 +722,20 @@ def test_native_duplicate_reward_rows_require_authoritative_step_scope(tmp_path: second = first.with_name("case-a__random__finish") shutil.copytree(first, second) summary_path = condition / "summary.json" - summary = json.loads(summary_path.read_text()) + summary = json.loads(summary_path.read_text(encoding="utf-8")) # The collector counts one logical trial and records its two reward rows. summary["num_reward_rows"] = 2 - summary_path.write_text(json.dumps(summary)) + summary_path.write_text(json.dumps(summary), encoding="utf-8") for trial_dir in (first, second): result_path = trial_dir / "result.json" - result = json.loads(result_path.read_text()) + result = json.loads(result_path.read_text(encoding="utf-8")) step = { "step_name": "prepare", "agent_result": {"n_input_tokens": 50, "n_output_tokens": 5, "n_cache_tokens": 0, "cost_usd": 0.1}, "agent_execution": result["agent_execution"], } result["step_results"] = [step, {**copy.deepcopy(step), "step_name": "finish"}] - result_path.write_text(json.dumps(result)) + result_path.write_text(json.dumps(result), encoding="utf-8") row = load_dashboard_path(run).rows[0] assert row["score"] == 0.8 assert row["total_tokens"] == 110 @@ -731,9 +743,9 @@ def test_native_duplicate_reward_rows_require_authoritative_step_scope(tmp_path: assert row["cost_usd"] == pytest.approx(0.2) for trial_dir in (first, second): result_path = trial_dir / "result.json" - result = json.loads(result_path.read_text()) + result = json.loads(result_path.read_text(encoding="utf-8")) result.pop("step_results") - result_path.write_text(json.dumps(result)) + result_path.write_text(json.dumps(result), encoding="utf-8") data = load_dashboard_path(run) assert data.rows[0]["score"] == 0.8 assert data.rows[0]["total_tokens"] is None diff --git a/tests/test_cli.py b/tests/test_cli.py index b0d634a45..551ff06a4 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -64,7 +64,7 @@ def test_top_level_help_groups_commands_by_workflow() -> None: assert positions == sorted(positions) core = result.output.split("Core workflows:", 1)[1].split("Tier 1 · Static and security:", 1)[0] - assert all(command in core for command in ("validate", "health-check", "doctor", "models")) + assert all(command in core for command in ("validate", "health-check", "doctor", "models", "dashboard")) tier3 = result.output.split("Tier 3 · Live evaluation:", 1)[1] assert all(command in tier3 for command in ("create-eval-dataset", "compare", "view", "harbor-view")) assert "Other commands:" not in result.output From 30f173f9f573718a17204321d4da6c003a370281 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 01:51:01 -0700 Subject: [PATCH 10/40] fix(dashboard): read canonical agent_seconds and share main's agent-time rule Canonical Tier 3 JSON records each single-step trial's agent execution time as `agent_seconds`, but the dashboard only read a per-trial `duration_seconds` that no producer writes. Agent time and its delta were therefore blank for every uploaded, canonical, or validate report. Read `agent_seconds` first; an invalid value stays unavailable rather than falling back, and the legacy field is still read for hand-built payloads. Retained runs now use Harbor's shared `agent_execution_seconds`, which treats timestamps without a timezone as unavailable, so a run's dashboard time matches what its own canonical JSON and HTML report record. Label the column "Agent time" so it is not mistaken for wall-clock duration, add a contract test that builds the canonical payload with the producer and checks the dashboard against its `resources` block, and document the rule. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/reports.mdx | 13 ++- src/skillevaluator/reporting/dashboard_app.py | 10 ++- .../reporting/dashboard_data.py | 21 ++--- tests/reporting/test_dashboard_app.py | 1 + tests/reporting/test_dashboard_contract.py | 86 +++++++++++++++++++ tests/reporting/test_dashboard_data.py | 62 ++++++++++++- 6 files changed, 170 insertions(+), 23 deletions(-) create mode 100644 tests/reporting/test_dashboard_contract.py diff --git a/docs/reports.mdx b/docs/reports.mdx index 015a57cf0..7f440a2c4 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -564,13 +564,18 @@ change relative to without skill. A negative usage difference means less usage; a positive score difference means higher performance. Comparisons stay within the same run and require successful conditions with matching trial coverage. -Missing measurements stay unavailable: older JSON reports may contain token -counts without time or cost, and cost is shown only when recorded in USD. +Missing measurements stay unavailable, and cost is shown only when recorded in +USD. Canonical Tier 3 JSON records each single-step trial's agent execution time +(`agent_seconds`) when Harbor's timestamps carry a timezone. Timestamps without a +timezone are treated as unavailable, as in the HTML report's +[measured agent resources](#measured-agent-resources). Agent time excludes +environment setup and verification. Canonical JSON never records USD cost; open +the retained run directory to show Harbor's recorded `agent_result.cost_usd` and +multi-step totals. Some older exports encoded missing token counters as zero. Open their retained run directories to recover recorded counters, or regenerate the canonical JSON with this version, which omits unmeasured token usage instead of recording zero. -For retained runs, duration measures agent execution rather than the entire -evaluation workflow. Cached tokens are shown separately and are not added again +Cached tokens are shown separately and are not added again to prompt plus completion tokens. No pricing estimates or new agent evaluations are performed. Adverse conditions and harness features are displayed when explicitly recorded; the dashboard does not run these experiments. diff --git a/src/skillevaluator/reporting/dashboard_app.py b/src/skillevaluator/reporting/dashboard_app.py index 4655b5ceb..d055a4f85 100644 --- a/src/skillevaluator/reporting/dashboard_app.py +++ b/src/skillevaluator/reporting/dashboard_app.py @@ -120,7 +120,7 @@ def _performance_column_config() -> dict[str, Any]: "condition": st.column_config.TextColumn("Condition"), "score": st.column_config.NumberColumn("Score", format="%.3f", width="small"), "pass_rate": st.column_config.NumberColumn("Pass rate", format="percent", width="small"), - "duration_seconds": st.column_config.NumberColumn("Duration (s)", format="%.2f", width="small"), + "duration_seconds": st.column_config.NumberColumn("Agent time (s)", format="%.2f", width="small"), "cost_usd": st.column_config.NumberColumn("Cost (USD)", format="$%.4f", width="small"), "status": st.column_config.TextColumn("Status"), "trials": st.column_config.NumberColumn("Trials", format="%d"), @@ -139,8 +139,10 @@ def _comparison_column_config(columns: tuple[str, ...]) -> dict[str, Any]: "score_delta": "Score Δ", "total_tokens_delta": "Tokens Δ", "total_tokens_percent": "Tokens Δ (%)", - "duration_seconds_delta": "Time Δ (s)", - "duration_seconds_percent": "Time Δ (%)", + "duration_seconds_delta": "Agent time Δ (s)", + "duration_seconds_percent": "Agent time Δ (%)", + "with_duration_seconds": "With skill: agent time (s)", + "without_duration_seconds": "Without skill: agent time (s)", "cost_usd_delta": "Cost Δ (USD)", "cost_usd_percent": "Cost Δ (%)", } @@ -257,7 +259,7 @@ def main(paths: list[str] | None = None) -> None: """Render the app, accepting CLI paths or a supplied path list for embedding.""" st.set_page_config(page_title="Skill performance · SkillEvaluator", page_icon="▦", layout="wide") st.title("Skill performance") - st.caption("SKILLEVALUATOR · Compare agent quality, tokens, duration, and cost across evaluation runs.") + st.caption("SKILLEVALUATOR · Compare agent quality, tokens, agent time, and cost across evaluation runs.") st.sidebar.header("Reports") uploads = st.sidebar.file_uploader( "Upload JSON reports", diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index 60ec9b9ae..171514a0f 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -17,11 +17,12 @@ import stat from collections import Counter from dataclasses import dataclass, field -from datetime import datetime from itertools import islice from pathlib import Path from typing import Any +from skillevaluator.tier3.harbor.resource_usage import agent_execution_seconds + _USAGE = ("prompt_tokens", "completion_tokens", "total_tokens", "cached_tokens", "duration_seconds", "cost_usd") _IDENTITY = ("source", "run_id", "skill", "model", "harness", "features") _PAIRING_IDENTITY = (*_IDENTITY, "_report_index", "_agent_key", "_feature_key") @@ -200,7 +201,11 @@ def _usage(trial: dict[str, Any]) -> dict[str, float | None]: "completion_tokens": completion, "total_tokens": prompt + completion if prompt is not None and completion is not None else None, "cached_tokens": _measurement(tokens.get("cached")), - "duration_seconds": _measurement(trial.get("duration_seconds")), + # Canonical Tier 3 JSON records agent_seconds; duration_seconds is only + # read from hand-built payloads and never replaces an invalid agent_seconds. + "duration_seconds": _measurement( + trial["agent_seconds"] if "agent_seconds" in trial else trial.get("duration_seconds") + ), "cost_usd": _measurement(trial.get("cost_usd")), } @@ -435,16 +440,6 @@ def _read_native_json(path: Path, run_root: Path) -> Any: return _read_json(path) -def _duration(result: dict[str, Any]) -> float | None: - execution = _dict(result.get("agent_execution")) - try: - started = datetime.fromisoformat(str(execution["started_at"])) - finished = datetime.fromisoformat(str(execution["finished_at"])) - return _measurement((finished - started).total_seconds()) - except (KeyError, TypeError, ValueError, OverflowError): - return None - - def _native_usage(trial_dir: Path, run_root: Path, *, require_steps: bool = False) -> dict[str, Any]: trajectory = ( _dict(_read_native_json(trial_dir / "trajectory.json", run_root)) @@ -480,7 +475,7 @@ def step_total(key: str) -> float | None: prompt = step_total("n_input_tokens") completion = step_total("n_output_tokens") cached = step_total("n_cache_tokens") - durations = [_duration(_dict(step)) for step in constituents] + durations = [agent_execution_seconds(_dict(step)) for step in constituents] costs = [_measurement(_dict(_dict(step).get("agent_result")).get("cost_usd")) for step in constituents] return { "_resource_scope_valid": True, diff --git a/tests/reporting/test_dashboard_app.py b/tests/reporting/test_dashboard_app.py index 3d1fa1bbe..81ca05e2a 100644 --- a/tests/reporting/test_dashboard_app.py +++ b/tests/reporting/test_dashboard_app.py @@ -103,6 +103,7 @@ def test_dashboard_renders_numeric_performance_and_paired_comparison(tmp_path: P assert comparison["comparison_status"].iloc[0] == "comparable" assert "raw_transcript" not in performance.columns assert all(not column.startswith("_") for column in performance.columns) + assert json.loads(app.dataframe[0].proto.columns)["duration_seconds"]["label"] == "Agent time (s)" assert [metric.value for metric in app.metric] == ["1", "1", "2", "2"] diff --git a/tests/reporting/test_dashboard_contract.py b/tests/reporting/test_dashboard_contract.py new file mode 100644 index 000000000..b9571efb7 --- /dev/null +++ b/tests/reporting/test_dashboard_contract.py @@ -0,0 +1,86 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Contract test: dashboard measurements must agree with the canonical Tier 3 ``resources`` block. + +Builds the canonical payload with the producer's own loader/builder (agent_eval_result_from_directory), +so the test fails as soon as the producer and the dashboard disagree about field names or pairing rules. +""" + +from __future__ import annotations + +import json +from pathlib import Path + +import pytest + +from skillevaluator.evaluation.tier3_report import agent_eval_result_from_directory +from skillevaluator.reporting.dashboard_data import comparison_rows, load_dashboard_path, parse_dashboard_report +from skillevaluator.tier3.harbor.metrics import DEFAULT_METRICS + + +def _write(path: Path, value: object) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(value), encoding="utf-8") + + +def _retained_run(run: Path, *, attempts: int) -> Path: + scores = dict.fromkeys(DEFAULT_METRICS, 1.0) + _write(run / "run_config.json", {"agents": {"opencode": {"agent": "opencode", "model": "model-a"}}}) + _write(run / "result.json", {"skill_name": "demo", "run_id": run.name}) + for arm, prompt, seconds in (("with-skill", 20, 3), ("without-skill", 10, 5)): + condition = run / "opencode" / arm + count = 2 * attempts + _write( + condition / "summary.json", + { + "model": "model-a", + "scores": scores, + "metrics": list(DEFAULT_METRICS), + "num_trials": count, + "num_reward_rows": count, + "execution_status": "succeeded", + "expected_attempts": count, + "scored_attempts": count, + "pass_at_k": {"k": attempts, "rate": 1.0}, + }, + ) + for case in ("case-a", "case-b"): + for attempt in range(attempts): + # Harbor names repeated attempts __; no attempt ordinal is recorded. + trial = condition / "trials" / f"{case}__trial{attempt}" + _write(trial / "reward.json", {**scores, "entry_id": case, "trial_id": trial.name}) + _write( + trial / "trajectory.json", + {"steps": [{}], "final_metrics": {"total_prompt_tokens": prompt, "total_completion_tokens": 2}}, + ) + _write( + trial / "result.json", + { + "agent_execution": { + "started_at": "2026-10-11T00:00:00Z", + "finished_at": f"2026-10-11T00:00:0{seconds}Z", + } + }, + ) + return run + + +@pytest.mark.parametrize("attempts", [1]) +@pytest.mark.parametrize("source", ["canonical", "native"]) +def test_dashboard_matches_main_resources(tmp_path: Path, attempts: int, source: str) -> None: + run = _retained_run(tmp_path / "run", attempts=attempts) + canonical = agent_eval_result_from_directory(tmp_path, run, use_llm_judge=False).metadata["agent_eval"] + resources = canonical["agents"]["opencode"]["resources"] + assert resources["pairing"] == "matching case counts" + + data = load_dashboard_path(run) if source == "native" else parse_dashboard_report(canonical, "report.json") + by_condition = {row["condition"]: row for row in data.rows} + for condition, arm in (("with_skill", "with_skill"), ("without_skill", "baseline")): + assert by_condition[condition]["score"] is not None + assert by_condition[condition]["total_tokens"] == resources["tokens"][arm]["total"] + assert by_condition[condition]["duration_seconds"] == resources["agent_seconds"][arm]["total"] + comparison = comparison_rows(data.rows)[0] + assert comparison["comparison_status"] == "comparable" + assert comparison["total_tokens_delta"] == resources["tokens"]["delta"] + assert comparison["duration_seconds_delta"] == resources["agent_seconds"]["delta"] diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index d97ac25ee..cac162ed0 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -10,6 +10,7 @@ import pytest +from skillevaluator.evaluation.tier3_report import agent_eval_result_from_directory from skillevaluator.reporting.dashboard_data import comparison_rows, load_dashboard_path, parse_dashboard_report @@ -20,7 +21,9 @@ def trial(prompt: int, completion: int, seconds: float, cost: float) -> dict: "trial_id": "case-a__random", "overall": 0.8, "tokens": {"prompt": prompt, "completion": completion, "cached": 0}, - "duration_seconds": seconds, + "agent_seconds": seconds, + # Tier 3 canonical JSON does not produce cost_usd; it is kept to + # exercise the reader for hand-imported payloads. "cost_usd": cost, } @@ -223,7 +226,7 @@ def test_zero_baseline_and_nonfinite_values() -> None: report = _report() agent = report["agents"]["claude-code"] agent["trials_baseline"][0]["cost_usd"] = 0 - agent["trials"][0]["duration_seconds"] = float("inf") + agent["trials"][0]["agent_seconds"] = float("inf") agent["trials"][0]["tokens"]["cached"] = True report["dashboard_metadata"] = {"harness_features": {"invalid": float("nan")}} data = parse_dashboard_report(report, "report.json") @@ -235,6 +238,24 @@ def test_zero_baseline_and_nonfinite_values() -> None: assert comparison["duration_seconds_delta"] is None +def test_invalid_agent_seconds_does_not_fall_back_to_legacy_duration() -> None: + report = _report() + trial = report["agents"]["claude-code"]["trials"][0] + trial.update(agent_seconds=-1, duration_seconds=5) + row = parse_dashboard_report(report, "report.json").rows[0] + assert row["duration_seconds"] is None + assert "time 0/1" in row["coverage"] + + +def test_legacy_trial_duration_seconds_is_still_read() -> None: + report = _report() + agent = report["agents"]["claude-code"] + for field in ("trials", "trials_baseline"): + agent[field][0]["duration_seconds"] = agent[field][0].pop("agent_seconds") + data = parse_dashboard_report(report, "report.json") + assert [row["duration_seconds"] for row in data.rows] == [8.0, 10.0] + + def test_malformed_status_and_aggregate_overflow_fail_closed() -> None: report = _report() agent = report["agents"]["claude-code"] @@ -453,6 +474,43 @@ def test_native_results_use_real_usage_and_prune_nested_mirrors(tmp_path: Path) assert load_dashboard_path(run / "result.json").rows == load_dashboard_path(run).rows +def _canonical_export(run: Path) -> dict: + result = agent_eval_result_from_directory(Path("native-skill"), run, use_llm_judge=False) + assert result is not None + return json.loads(json.dumps(result.metadata["agent_eval"])) + + +def test_canonical_export_agent_seconds_matches_retained_run(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + canonical = parse_dashboard_report(_canonical_export(run), "r.json") + retained = load_dashboard_path(run) + assert ( + [row["duration_seconds"] for row in canonical.rows] + == [row["duration_seconds"] for row in retained.rows] + == [10.0, 10.0] + ) + assert all("time 1/1" in row["coverage"] for row in canonical.rows) + comparison = comparison_rows(canonical.rows)[0] + assert comparison["comparison_status"] == "comparable" + assert comparison["duration_seconds_delta"] == 0.0 + + +def test_retained_naive_timestamps_follow_canonical_timezone_policy(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + for result_path in run.glob("*/*/trials/*/result.json"): + result = json.loads(result_path.read_text(encoding="utf-8")) + result["agent_execution"] = {"started_at": "2026-10-01T00:00:00", "finished_at": "2026-10-01T00:00:10"} + result_path.write_text(json.dumps(result), encoding="utf-8") + rows = load_dashboard_path(run).rows + assert len(rows) == 2 + assert all(row["duration_seconds"] is None for row in rows) + assert all("time 0/1" in row["coverage"] for row in rows) + agent = _canonical_export(run)["agents"]["opencode"] + assert all("agent_seconds" not in trial for trial in agent["trials"] + agent["trials_baseline"]) + + def test_catalog_native_and_mixed_references_are_loaded_without_cycles(tmp_path: Path) -> None: run = tmp_path / "run" _native_run(run) From 088cebe8312ec5e2c29f3c9beb05dcb4ec1c1a08 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 01:53:59 -0700 Subject: [PATCH 11/40] fix(dashboard): pair repeated Harbor attempts by case like the HTML report Harbor names each repeated attempt __ without an attempt ordinal, so the dashboard treated every --n-attempts run above 1 as unpaired: scores and pass@k were blanked and every comparison was shown as mismatched coverage. The HTML report pairs these runs by matching case counts. Unnumbered attempts now pair by case count when every attempt has its own trial ID, which is the recorded identity of a physical attempt. Missing or shared trial IDs, mixed numbered and unnumbered attempts, and differing explicit attempt sets still fail closed. The dashboard no longer guesses attempt numbers from trial names, which also misread authored case IDs such as retry-attempt1. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/reports.mdx | 3 + .../reporting/dashboard_data.py | 14 +++-- tests/reporting/test_dashboard_contract.py | 2 +- tests/reporting/test_dashboard_data.py | 61 ++++++++++++++++--- 4 files changed, 65 insertions(+), 15 deletions(-) diff --git a/docs/reports.mdx b/docs/reports.mdx index 7f440a2c4..174b0e190 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -563,6 +563,9 @@ The comparison table calculates **with skill minus without skill**, and percent change relative to without skill. A negative usage difference means less usage; a positive score difference means higher performance. Comparisons stay within the same run and require successful conditions with matching trial coverage. +Repeated attempts pair by case, as in the HTML report: each arm must record the +same number of attempts for every case, and each attempt must have its own +trial ID. Missing measurements stay unavailable, and cost is shown only when recorded in USD. Canonical Tier 3 JSON records each single-step trial's agent execution time diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index 171514a0f..f5e8c1e9e 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -171,11 +171,6 @@ def _trial_keys(trials: list[dict[str, Any]]) -> tuple[tuple[str, str], ...] | N if len(set(normalized_attempts)) > 1: return None attempt = normalized_attempts[0] if normalized_attempts else None - # Native canonical reports omit attempt numbers, but Harbor trial IDs - # carry __attemptN when attempts are repeated. - matches = re.findall(r"(?:__|_|-)attempt[_-]?(\d+)(?=__|$)", trial_id) - if attempt is None and matches: - attempt = matches[-1].lstrip("0") or "0" if trial_id and trial_id in seen_trials: if seen_trials[trial_id] != (entry, attempt): return None @@ -187,7 +182,14 @@ def _trial_keys(trials: list[dict[str, Any]]) -> tuple[tuple[str, str], ...] | N if attempt is None: implicit.add(entry) keys.append((entry, str(attempt) if attempt is not None else f"ordinal:{counts[entry]}")) - if any(counts[entry] > 1 for entry in implicit): + # Harbor names repeated attempts __ without an ordinal, so + # unnumbered attempts pair by case count, as in the HTML report, only when + # each one has its own trial ID. + implicit_ids: dict[str, set[str]] = {} + for trial_id, (entry, attempt) in seen_trials.items(): + if attempt is None: + implicit_ids.setdefault(entry, set()).add(trial_id) + if any(counts[entry] > 1 and len(implicit_ids.get(entry, ())) != counts[entry] for entry in implicit): return None return tuple(sorted(keys)) diff --git a/tests/reporting/test_dashboard_contract.py b/tests/reporting/test_dashboard_contract.py index b9571efb7..58dd9abfb 100644 --- a/tests/reporting/test_dashboard_contract.py +++ b/tests/reporting/test_dashboard_contract.py @@ -66,7 +66,7 @@ def _retained_run(run: Path, *, attempts: int) -> Path: return run -@pytest.mark.parametrize("attempts", [1]) +@pytest.mark.parametrize("attempts", [1, 3]) @pytest.mark.parametrize("source", ["canonical", "native"]) def test_dashboard_matches_main_resources(tmp_path: Path, attempts: int, source: str) -> None: run = _retained_run(tmp_path / "run", attempts=attempts) diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index cac162ed0..a6b393047 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -269,26 +269,71 @@ def test_malformed_status_and_aggregate_overflow_fail_closed() -> None: assert row["total_tokens"] is None -def test_repeated_attempts_require_recorded_identity_and_match_exact_set() -> None: +def _repeated_attempts_report(trial_ids: tuple[str, ...]) -> dict: report = _report() agent = report["agents"]["claude-code"] for field, count_field, arm in ( ("trials", "num_trials", "with_skill"), ("trials_baseline", "num_trials_baseline", "without_skill"), ): - agent[field].append(copy.deepcopy(agent[field][0])) - agent[field][0]["trial_id"] = "case-a__attempt1__abc" - agent[field][1]["trial_id"] = "case-a__attempt2__def" - agent[count_field] = 2 - agent["conditions"][arm].update(expected_attempts=2, scored_attempts=2) + agent[field] = [{**copy.deepcopy(agent[field][0]), "trial_id": trial_id} for trial_id in trial_ids] + agent[count_field] = len(trial_ids) + agent["conditions"][arm].update(expected_attempts=len(trial_ids), scored_attempts=len(trial_ids)) + return report + + +def test_repeated_attempts_pair_by_case_with_distinct_trial_ids() -> None: + report = _repeated_attempts_report(("case-a__trial0", "case-a__trial1")) + agent = report["agents"]["claude-code"] + comparison = comparison_rows(parse_dashboard_report(report, "report.json").rows)[0] + assert comparison["comparison_status"] == "comparable" + assert comparison["score_delta"] == pytest.approx(0.2) + # Harbor's attempt names are random, so arms pair by case count, not by name. + agent["trials_baseline"][1]["trial_id"] = "case-a__trial2" assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["comparison_status"] == "comparable" - agent["trials_baseline"][1]["trial_id"] = "case-a__attempt3__def" - assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["score_delta"] is None for field in ("trials", "trials_baseline"): for index, trial in enumerate(agent[field]): trial["trial_id"] = f"case-a__unrelated-{index}" + assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["comparison_status"] == "comparable" + + report = _repeated_attempts_report(("case-a__trial0", "case-a__trial1")) + report["agents"]["claude-code"]["trials"][1]["trial_id"] = "" assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["score_delta"] is None + report = _repeated_attempts_report(("case-a__trial0", "case-a__trial1")) + report["agents"]["claude-code"]["trials"][1].update(entry_id="case-b", trial_id="case-a__trial0") + assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["score_delta"] is None + + report = _repeated_attempts_report(("case-a__trial0", "case-a__trial1")) + agent = report["agents"]["claude-code"] + agent["trials_baseline"].pop() + agent["num_trials_baseline"] = 1 + agent["conditions"]["without_skill"].update(expected_attempts=1, scored_attempts=1) + comparison = comparison_rows(parse_dashboard_report(report, "report.json").rows)[0] + assert comparison["comparison_status"] == "incomplete or mismatched coverage" + assert comparison["score_delta"] is None + + report = _repeated_attempts_report(("case-a__trial0", "case-a__trial1")) + agent = report["agents"]["claude-code"] + for field, attempts in (("trials", (1, 2)), ("trials_baseline", (1, 3))): + for trial, attempt in zip(agent[field], attempts, strict=True): + trial["attempt"] = attempt + comparison = comparison_rows(parse_dashboard_report(report, "report.json").rows)[0] + assert comparison["comparison_status"] == "incomplete or mismatched coverage" + assert comparison["score_delta"] is None + + report = _repeated_attempts_report(("case-a__trial0", "case-a__trial1")) + report["agents"]["claude-code"]["trials"][0]["attempt"] = 1 + assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["score_delta"] is None + + +def test_authored_case_id_containing_attempt_text_is_not_parsed() -> None: + report = _repeated_attempts_report(("retry-attempt1__aaa", "retry-attempt1__bbb")) + for field in ("trials", "trials_baseline"): + for trial in report["agents"]["claude-code"][field]: + trial["entry_id"] = "retry-attempt1" + assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["comparison_status"] == "comparable" + def test_multistep_rewards_keep_logical_scores_without_ambiguous_resource_sums() -> None: report = _report() From da9f1b2c352335e5111cc3395a07b1a51d5a6935 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 01:56:50 -0700 Subject: [PATCH 12/40] fix(dashboard): keep scores comparable when only a trajectory hit the loader bound The report loader caps each JSON artifact at 2 MiB, and Harbor trajectories are bounded by node count, not bytes. One large with-skill trajectory recorded an artifact_loading reason, and the dashboard then treated the whole report as truncated trial coverage and blanked every score, pass@k and comparison. The HTML report keeps those scores, because a trajectory feeds only per-trial tokens and steps, and canonical trials then omit tokens so coverage counts already keep token totals unavailable. Treat trajectory-only loader reasons as telemetry. Any other artifact, a malformed reason list, or a bare truncated marker still blocks comparisons, and the separate trial-count check still catches a missing trial. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/reports.mdx | 4 +- .../reporting/dashboard_data.py | 18 ++++- tests/reporting/test_dashboard_data.py | 67 +++++++++++++++++++ 3 files changed, 86 insertions(+), 3 deletions(-) diff --git a/docs/reports.mdx b/docs/reports.mdx index 174b0e190..ec542a74b 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -565,7 +565,9 @@ a positive score difference means higher performance. Comparisons stay within the same run and require successful conditions with matching trial coverage. Repeated attempts pair by case, as in the HTML report: each arm must record the same number of attempts for every case, and each attempt must have its own -trial ID. +trial ID. A trajectory above the report loader's size bound leaves that trial's +token counts unavailable in canonical JSON but does not block score comparisons; +any other loader truncation keeps comparisons unavailable. Missing measurements stay unavailable, and cost is shown only when recorded in USD. Canonical Tier 3 JSON records each single-step trial's agent execution time diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index f5e8c1e9e..40739702a 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -29,6 +29,9 @@ _MAX_FILE_BYTES = 16 * 1024 * 1024 _MAX_FILES = 1000 _MAX_PATHS = 20_000 +# Loader bounds on these artifacts drop only per-trial telemetry (tokens, steps). +# Canonical trials then omit those counters, so coverage counts keep totals blank. +_TELEMETRY_ARTIFACTS = frozenset({"trajectory"}) @dataclass @@ -99,7 +102,16 @@ def _is_native_result(value: dict[str, Any]) -> bool: def _trial_coverage_truncated(marker: dict[str, Any]) -> bool: if not marker.get("truncated"): return False - if marker.get("artifact_loading"): + loading = marker.get("artifact_loading") + if loading and ( + not isinstance(loading, list) + or any( + not isinstance(reason, dict) + or not isinstance(reason.get("artifact"), str) + or reason["artifact"] not in _TELEMETRY_ARTIFACTS + for reason in loading + ) + ): return True omitted = _dict(marker.get("omitted")) # These budgets affect diagnostics, not the normalized trial population. @@ -117,7 +129,9 @@ def _trial_coverage_truncated(marker: dict[str, Any]) -> bool: "custom_metric_discovery_trials", "non_best_agent_details", } - return not omitted or any(section not in diagnostics for section in omitted) + if not omitted: + return not loading # an unexplained truncation still fails closed + return any(section not in diagnostics for section in omitted) def _payloads(value: Any, depth: int = 0): diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index a6b393047..94375d8df 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -409,6 +409,56 @@ def test_artifact_loading_truncation_blocks_comparisons() -> None: assert comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["score_delta"] is None +_TRAJECTORY_BYTES = {"code": "json_bytes", "artifact": "trajectory", "limit": 2 * 1024 * 1024} + + +@pytest.mark.parametrize( + ("marker", "status"), + [ + ({"truncated": True, "omitted": {}, "artifact_loading": [_TRAJECTORY_BYTES]}, "comparable"), + ( + { + "truncated": True, + "omitted": {}, + "artifact_loading": [ + _TRAJECTORY_BYTES, + {"code": "json_bytes", "artifact": "reward", "limit": 2 * 1024 * 1024}, + ], + }, + "incomplete or mismatched coverage", + ), + ( + {"truncated": True, "artifact_loading": [{"artifact": "with-skill", "code": "trial_limit"}]}, + "incomplete or mismatched coverage", + ), + ( + {"truncated": True, "artifact_loading": [{"artifact": "mystery", "code": "json_bytes"}]}, + "incomplete or mismatched coverage", + ), + ( + {"truncated": True, "artifact_loading": [{"artifact": ["trajectory"], "code": "json_bytes"}]}, + "incomplete or mismatched coverage", + ), + ({"truncated": True}, "incomplete or mismatched coverage"), + ({"truncated": True, "artifact_loading": _TRAJECTORY_BYTES}, "incomplete or mismatched coverage"), + ], +) +def test_only_trajectory_loader_bounds_keep_trial_coverage(marker: dict, status: str) -> None: + report = _report() + report["report_truncation"] = marker + data = parse_dashboard_report(report, "report.json") + assert data.warnings + assert comparison_rows(data.rows)[0]["comparison_status"] == status + + +def test_trajectory_reason_does_not_hide_missing_trial() -> None: + report = _report() + report["agents"]["claude-code"]["trials_baseline"] = [] + report["report_truncation"] = {"truncated": True, "omitted": {}, "artifact_loading": [_TRAJECTORY_BYTES]} + status = comparison_rows(parse_dashboard_report(report, "report.json").rows)[0]["comparison_status"] + assert status == "incomplete or mismatched coverage" + + def test_bad_input_is_diagnostic_and_directory_skips_symlinks(tmp_path: Path) -> None: malformed = tmp_path / "broken.json" malformed.write_text("{", encoding="utf-8") @@ -556,6 +606,23 @@ def test_retained_naive_timestamps_follow_canonical_timezone_policy(tmp_path: Pa assert all("agent_seconds" not in trial for trial in agent["trials"] + agent["trials_baseline"]) +def test_oversized_trajectory_keeps_scores_comparable(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + trajectory = run / "opencode" / "with-skill" / "trials" / "case-a__random" / "trajectory.json" + # Larger than the report loader's 2 MiB JSON bound, below the dashboard's own. + trajectory.write_text(json.dumps({"steps": [], "padding": "x" * (3 * 1024 * 1024)}), encoding="utf-8") + comparison = comparison_rows(load_dashboard_path(run).rows)[0] + assert comparison["comparison_status"] == "comparable" + assert comparison["score_delta"] == 0 + canonical = _canonical_export(run) + assert canonical["report_truncation"]["artifact_loading"][0]["artifact"] == "trajectory" + rows = parse_dashboard_report(canonical, "r.json").rows + assert comparison_rows(rows)[0]["comparison_status"] == "comparable" + assert rows[0]["condition"] == "with_skill" + assert rows[0]["total_tokens"] is None + + def test_catalog_native_and_mixed_references_are_loaded_without_cycles(tmp_path: Path) -> None: run = tmp_path / "run" _native_run(run) From c91d6ec6590e0811c80c1610fb86169e8fd46acf Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 02:00:23 -0700 Subject: [PATCH 13/40] fix(dashboard): show report notices as plain text and widen CSV formula escaping Report notices can carry text taken from a shared report, such as agent keys, upload names and catalog paths. Streamlit parses alert bodies as Markdown, so a crafted key could render a remote image or a link. Each notice now renders with st.text under one fixed warning, and the expander counts unique notices instead of every duplicate. The CSV export also missed full-width formula prefixes (for example U+FF1D), which spreadsheets fold to "=". Text cells are now probed after NFKC normalization, and tests cover the CR, LF and NBSP cases too. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- src/skillevaluator/reporting/dashboard_app.py | 18 ++++---- tests/reporting/test_dashboard_app.py | 42 +++++++++++++++++-- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/src/skillevaluator/reporting/dashboard_app.py b/src/skillevaluator/reporting/dashboard_app.py index d055a4f85..efa61d88f 100644 --- a/src/skillevaluator/reporting/dashboard_app.py +++ b/src/skillevaluator/reporting/dashboard_app.py @@ -13,6 +13,7 @@ import io import json import sys +import unicodedata from pathlib import Path from typing import Any @@ -91,10 +92,11 @@ def rows_csv(rows: list[dict[str, Any]], columns: tuple[str, ...]) -> str: cells: dict[str, Any] = {} for column in columns: value = row.get(column) - if isinstance(value, str) and ( - value.startswith(("\t", "\r", "\n")) or value.lstrip().startswith(("=", "+", "-", "@")) - ): - value = "'" + value + if isinstance(value, str): + # NFKC folds full-width prefixes such as U+FF1D to their ASCII forms. + probe = unicodedata.normalize("NFKC", value).lstrip() + if value.startswith(("\t", "\r", "\n")) or probe.startswith(("=", "+", "-", "@")): + value = "'" + value cells[column] = value writer.writerow(cells) return buffer.getvalue() @@ -299,9 +301,11 @@ def main(paths: list[str] | None = None) -> None: rows.extend(data.rows) warnings.extend(data.warnings) if warnings: - with st.expander(f"Report notices ({len(warnings)})", expanded=True): - for warning in dict.fromkeys(warnings): - st.warning(warning) + notices = list(dict.fromkeys(warnings)) + with st.expander(f"Report notices ({len(notices)})", expanded=True): + st.warning("Some inputs were skipped or have incomplete measurements.") + for notice in notices: + st.text(notice) # st.text parses neither Markdown nor HTML if not rows: st.info("Upload JSON evaluation reports to start comparing results.") st.caption("You can also open saved run directories with skillevaluator dashboard PATH [PATH …].") diff --git a/tests/reporting/test_dashboard_app.py b/tests/reporting/test_dashboard_app.py index 81ca05e2a..8f7ac4037 100644 --- a/tests/reporting/test_dashboard_app.py +++ b/tests/reporting/test_dashboard_app.py @@ -163,10 +163,36 @@ def test_bad_report_does_not_hide_other_results(tmp_path: Path) -> None: invalid.write_text("{broken JSON", encoding="utf-8") app = _app([invalid, valid, tmp_path / "missing.json"]) assert not app.exception - assert len(app.warning) == 2 + assert len(app.warning) == 1 + assert len(app.text) == 2 assert len(app.dataframe[0].value) == 2 +def test_report_notices_are_plain_text(tmp_path: Path) -> None: + path = _write_report(tmp_path / "beacon.json") + report = json.loads(path.read_text(encoding="utf-8")) + agent = report["agents"].pop("opencode") + agent["num_trials"] = -1 + report["agents"]["![x](https://beacon.example.test/x.png)"] = agent + path.write_text(json.dumps(report), encoding="utf-8") + app = _app([path]) + assert not app.exception + assert not any("](" in warning.value for warning in app.warning) + assert any("beacon.example.test" in text.value for text in app.text) + + +def test_notice_count_matches_unique_notices(tmp_path: Path) -> None: + report = _write_report(tmp_path / "run.json") + payload = json.loads(report.read_text(encoding="utf-8")) + payload["agents"]["opencode"]["num_trials"] = -1 + report.write_text(json.dumps(payload), encoding="utf-8") + # The directory walk and the direct file path report the same notice for one file. + app = _app([tmp_path, report]) + assert not app.exception + assert app.expander[0].label == "Report notices (1)" + assert len(app.text) == 1 + + def test_status_filter_does_not_pair_arms_from_separate_embedded_reports(tmp_path: Path) -> None: path = _write_report(tmp_path / "combined.json", baseline_status="failed") first = json.loads(path.read_text(encoding="utf-8")) @@ -192,8 +218,8 @@ def test_cyclic_input_path_does_not_hide_valid_report(tmp_path: Path) -> None: pytest.skip("Symlinks are unavailable on this host") app = _app([loop, valid]) assert not app.exception - assert len(app.warning) == 1 - assert str(loop) in app.warning[0].value + assert len(app.text) == 1 + assert str(loop) in app.text[0].value assert len(app.dataframe[0].value) == 2 @@ -239,3 +265,13 @@ def test_csv_preserves_numeric_deltas_and_escapes_formula_strings() -> None: assert cells[1] == {"skill": "'\tprivate-name", "score_delta": "0.0", "cost_usd": "0.0"} assert cells[2]["skill"] == "'@SUM(A1)" assert "must not be exported" not in exported + + +@pytest.mark.parametrize( + "value", + ["\r=1", "\n=1", "\xa0=1", "\u3000=1", "\uff1d1", "\uff0b1", "\uff0d1", "\uff20A1"], +) +def test_csv_escapes_formula_prefixes_after_whitespace_and_width_folding(value: str) -> None: + exported = rows_csv([{"skill": value, "score_delta": -0.25, "cost_usd": 7}], ("skill", "score_delta", "cost_usd")) + cells = list(csv.DictReader(io.StringIO(exported))) + assert cells == [{"skill": "'" + value, "score_delta": "-0.25", "cost_usd": "7"}] From 46dea669adaeeb1c83dc03768651dca9a0044aaf Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 02:05:55 -0700 Subject: [PATCH 14/40] perf(dashboard): cache loaded reports across reruns and add Reload reports Streamlit reruns the whole script on every widget change, so each filter click reloaded every command-line path and re-decoded every upload. On a large retained run that made a filter change take seconds. Command-line inputs are now cached by path plus a cheap stat fingerprint, so a rewritten file or a new entry directly inside a directory is picked up on the next interaction. Deeper edits inside a directory, such as a run still writing trials, appear after the new Reload reports button. Uploads are cached by their widget file ID instead of hashing the bytes. The size check now uses the upload's recorded size, and every message and source label is unchanged. Both CSV download buttons no longer trigger a rerun, and new AppTests cover the upload path, including the 16 MB boundary and invalid JSON. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/reports.mdx | 7 + src/skillevaluator/reporting/dashboard_app.py | 53 ++++++-- tests/reporting/test_dashboard_app.py | 123 ++++++++++++++++++ 3 files changed, 173 insertions(+), 10 deletions(-) diff --git a/docs/reports.mdx b/docs/reports.mdx index ec542a74b..b6576617e 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -569,6 +569,13 @@ trial ID. A trajectory above the report loader's size bound leaves that trial's token counts unavailable in canonical JSON but does not block score comparisons; any other loader truncation keeps comparisons unavailable. +The dashboard reads each input once and reuses it while you filter or switch +views. Rewriting a JSON file passed on the command line, or adding an entry +directly inside a directory input, is picked up on the next interaction. Edits +deeper inside a directory input (for example a run that is still writing trials) +or in reports a catalog references appear after **Reload reports** in the +sidebar; a browser refresh does not re-read them. + Missing measurements stay unavailable, and cost is shown only when recorded in USD. Canonical Tier 3 JSON records each single-step trial's agent execution time (`agent_seconds`) when Harbor's timestamps carry a timezone. Timestamps without a diff --git a/src/skillevaluator/reporting/dashboard_app.py b/src/skillevaluator/reporting/dashboard_app.py index efa61d88f..5508513a5 100644 --- a/src/skillevaluator/reporting/dashboard_app.py +++ b/src/skillevaluator/reporting/dashboard_app.py @@ -19,10 +19,16 @@ import streamlit as st -from skillevaluator.reporting.dashboard_data import comparison_rows, load_dashboard_path, parse_dashboard_report +from skillevaluator.reporting.dashboard_data import ( + DashboardData, + comparison_rows, + load_dashboard_path, + parse_dashboard_report, +) _DIMENSIONS = ("skill", "model", "harness", "features") _MAX_UPLOAD_BYTES = 16_000_000 +_CACHE_ENTRIES = 64 _CONDITION_NAMES = {"with_skill": "With skill", "without_skill": "Without skill", "adverse": "Adverse skill"} _USAGE_METRICS = ("total_tokens", "prompt_tokens", "completion_tokens", "cached_tokens", "duration_seconds", "cost_usd") _PERFORMANCE_COLUMNS = ( @@ -83,6 +89,31 @@ ) +def _input_fingerprint(path: Path) -> tuple[int, int, int] | None: + """Cheap identity for one CLI input; nested directory edits need Reload reports.""" + try: + info = path.stat() + except OSError: + return None + return (info.st_mtime_ns, info.st_size, info.st_ino) + + +@st.cache_data(max_entries=_CACHE_ENTRIES, show_spinner="Loading reports…") +def _load_path_cached(path: str, fingerprint: tuple[int, int, int] | None) -> DashboardData: + return load_dashboard_path(Path(path)) # fingerprint is a cache key only + + +# Keyed on file_id, which is stable while the file stays in the widget; +# the leading underscore stops Streamlit hashing the uploaded bytes. +@st.cache_data(max_entries=_CACHE_ENTRIES, show_spinner=False) +def _parse_upload_cached(file_id: str, source: str, name: str, _contents: bytes) -> DashboardData: + try: + payload = json.loads(_contents) + except (ValueError, RecursionError): # UnicodeError is a ValueError subclass + return DashboardData(warnings=[f"{name}: invalid JSON. Upload a UTF-8 JSON evaluation report."]) + return parse_dashboard_report(payload, source=source) + + def rows_csv(rows: list[dict[str, Any]], columns: tuple[str, ...]) -> str: """Export visible quantitative columns with spreadsheet-safe text cells.""" buffer = io.StringIO(newline="") @@ -186,6 +217,7 @@ def _show_performance(rows: list[dict[str, Any]]) -> None: file_name="skill-performance.csv", mime="text/csv", key="download_performance", + on_click="ignore", ) @@ -254,6 +286,7 @@ def _show_comparisons(rows: list[dict[str, Any]]) -> None: file_name="skill-comparison.csv", mime="text/csv", key="download_comparisons", + on_click="ignore", ) @@ -270,6 +303,10 @@ def main(paths: list[str] | None = None) -> None: help="Use Tier 3 JSON reports or consolidated SkillEvaluator JSON reports, up to 16 MB (16,000,000 bytes) per file.", key="report_uploads", ) + if paths and st.sidebar.button( + "Reload reports", key="reload_reports", help="Re-read report files and run directories from disk." + ): + _load_path_cached.clear() rows: list[dict[str, Any]] = [] warnings: list[str] = [] seen_paths: set[Path] = set() @@ -282,22 +319,18 @@ def main(paths: list[str] | None = None) -> None: if path in seen_paths: continue seen_paths.add(path) - data = load_dashboard_path(path) + data = _load_path_cached(str(path), _input_fingerprint(path)) rows.extend(data.rows) warnings.extend(data.warnings) for index, uploaded in enumerate(uploads): - contents = uploaded.getvalue() - if len(contents) > _MAX_UPLOAD_BYTES: + if uploaded.size > _MAX_UPLOAD_BYTES: warnings.append( f"{uploaded.name}: report exceeds 16 MB (16,000,000 bytes). Upload a smaller evaluation report." ) continue - try: - payload = json.loads(contents) - except (ValueError, UnicodeError, RecursionError): - warnings.append(f"{uploaded.name}: invalid JSON. Upload a UTF-8 JSON evaluation report.") - continue - data = parse_dashboard_report(payload, source=f"upload:{index + 1}:{uploaded.name}") + data = _parse_upload_cached( + uploaded.file_id, f"upload:{index + 1}:{uploaded.name}", uploaded.name, uploaded.getvalue() + ) rows.extend(data.rows) warnings.extend(data.warnings) if warnings: diff --git a/tests/reporting/test_dashboard_app.py b/tests/reporting/test_dashboard_app.py index 8f7ac4037..f855d57fc 100644 --- a/tests/reporting/test_dashboard_app.py +++ b/tests/reporting/test_dashboard_app.py @@ -16,8 +16,10 @@ # st.dataframe otherwise imports these inside AppTest's timed script thread. pytest.importorskip("pandas") pytest.importorskip("pyarrow") +import streamlit as st from streamlit.testing.v1 import AppTest +from skillevaluator.reporting import dashboard_app from skillevaluator.reporting.dashboard_app import rows_csv # A ceiling for cold imports under xdist and coverage; passing runs finish far sooner. @@ -78,6 +80,28 @@ def _app(paths: list[Path]) -> AppTest: return AppTest.from_string(script, default_timeout=_APP_TIMEOUT_SECONDS).run() +def _upload_app() -> AppTest: + app = _app([]) + if not hasattr(app, "file_uploader"): + pytest.skip("This Streamlit version's AppTest cannot drive st.file_uploader") + return app + + +def _rewrite_score(path: Path, score: float) -> None: + report = json.loads(path.read_text(encoding="utf-8")) + report["agents"]["opencode"]["with_skill"] = score + report["agents"]["opencode"]["padding"] = "x" * 10 # change the size too, for coarse mtimes + path.write_text(json.dumps(report), encoding="utf-8") + + +@pytest.fixture(autouse=True) +def _clear_dashboard_cache(): + # Cached loads are process-wide, so keep each test's inputs isolated. + st.cache_data.clear() + yield + st.cache_data.clear() + + def test_empty_dashboard_has_upload_direction() -> None: app = _app([]) assert not app.exception @@ -105,6 +129,9 @@ def test_dashboard_renders_numeric_performance_and_paired_comparison(tmp_path: P assert all(not column.startswith("_") for column in performance.columns) assert json.loads(app.dataframe[0].proto.columns)["duration_seconds"]["label"] == "Agent time (s)" assert [metric.value for metric in app.metric] == ["1", "1", "2", "2"] + downloads = app.get("download_button") + assert len(downloads) == 2 + assert all(button.proto.ignore_rerun for button in downloads) def test_dimension_filters_and_condition_retain_baseline_for_comparison(tmp_path: Path) -> None: @@ -223,6 +250,102 @@ def test_cyclic_input_path_does_not_hide_valid_report(tmp_path: Path) -> None: assert len(app.dataframe[0].value) == 2 +def test_filter_reruns_do_not_reload_inputs(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: + calls: list[Path] = [] + real = dashboard_app.load_dashboard_path + + def counting(path: Path): + calls.append(path) + return real(path) + + monkeypatch.setattr(dashboard_app, "load_dashboard_path", counting) + path = _write_report(tmp_path / "run.json") + app = _app([path]) + for value in (["model-a"], [], ["model-a"]): + app.multiselect(key="filter_model").set_value(value).run() + assert not app.exception + assert calls == [path.resolve()] + + +def test_rewritten_report_file_is_reloaded_on_next_rerun(tmp_path: Path) -> None: + path = _write_report(tmp_path / "run.json") + app = _app([path]) + assert app.dataframe[0].value["score"].tolist() == [0.9, 0.6] + _rewrite_score(path, 0.5) + app.run() + assert not app.exception + assert app.dataframe[0].value["score"].tolist() == [0.5, 0.6] + + +def test_reload_button_rereads_nested_directory_edits(tmp_path: Path) -> None: + nested = tmp_path / "runs" / "a" + nested.mkdir(parents=True) + path = _write_report(nested / "run.json") + app = _app([tmp_path / "runs"]) + assert app.dataframe[0].value["score"].tolist() == [0.9, 0.6] + _rewrite_score(path, 0.5) + app.button(key="reload_reports").click().run() + assert not app.exception + assert app.dataframe[0].value["score"].tolist() == [0.5, 0.6] + + +def test_uploads_are_parsed_once_per_uploaded_file(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: + calls: list[str] = [] + real = dashboard_app.parse_dashboard_report + + def counting(payload, source): + calls.append(source) + return real(payload, source) + + monkeypatch.setattr(dashboard_app, "parse_dashboard_report", counting) + content = _write_report(tmp_path / "upload.json").read_bytes() + app = _upload_app() + app.file_uploader(key="report_uploads").set_value([("upload.json", content, "application/json")]).run() + assert len(app.dataframe[0].value) == 2 + app.multiselect(key="filter_condition").set_value(["with_skill"]).run() + assert not app.exception + assert calls == ["upload:1:upload.json"] + + +def test_uploaded_report_renders_with_upload_source(tmp_path: Path) -> None: + content = _write_report(tmp_path / "run.json").read_bytes() + app = _upload_app() + app.file_uploader(key="report_uploads").set_value(("run.json", content, "application/json")).run() + assert not app.exception + performance = app.dataframe[0].value + assert performance["source"].tolist() == ["upload:1:run.json", "upload:1:run.json"] + assert performance["total_tokens"].tolist() == [140.0, 120.0] + + +def test_upload_batch_reports_oversize_and_invalid_and_keeps_valid(tmp_path: Path) -> None: + content = _write_report(tmp_path / "run.json").read_bytes() + oversized = content + b" " * (16_000_001 - len(content)) + app = _upload_app() + app.file_uploader(key="report_uploads").set_value( + [ + ("big.json", oversized, "application/json"), + ("broken.json", b"{", "application/json"), + ("deep.json", b"[" * 100_000, "application/json"), + ("run.json", content, "application/json"), + ] + ).run() + assert not app.exception + notices = [text.value for text in app.text] + assert any(notice.startswith("big.json: report exceeds 16 MB") for notice in notices), notices + assert sum("invalid JSON" in notice for notice in notices) == 2, notices + assert len(app.dataframe[0].value) == 2 + + +def test_upload_at_exact_limit_is_accepted(tmp_path: Path) -> None: + content = _write_report(tmp_path / "run.json").read_bytes() + exact = content + b" " * (16_000_000 - len(content)) + assert len(exact) == 16_000_000 + app = _upload_app() + app.file_uploader(key="report_uploads").set_value(("exact.json", exact, "application/json")).run() + assert not app.exception + assert len(app.dataframe[0].value) == 2 + + @pytest.mark.parametrize( ("view", "measured_column"), [ From ab55db63fdb7ae53b12e581cd53b107083f39e44 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 02:08:53 -0700 Subject: [PATCH 15/40] fix(dashboard): load each report once when inputs overlap The dashboard skipped only inputs whose resolved paths were equal, so natural invocations such as a results directory plus a run inside it, a results directory plus its latest symlink, or a run plus its result.json loaded the same rows twice under the same source. Every pair then read as ambiguous duplicate conditions with blank deltas, and the condition row count doubled. Uploading the same file twice doubled the rows and the run count too. Rows reloaded from the same source, report, agent and condition are now kept once with a notice. That key is unique within one parse, so identical embedded reports in one file are still separate rows, and a CLI path and an upload of the same file keep their distinct sources. Byte-identical uploads are skipped with a notice; the digest is computed inside the cached upload parse, so it runs once per uploaded file. The existing notice-count test loads a directory and a file inside it, so it now also expects the overlap notice. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/reports.mdx | 4 +- src/skillevaluator/reporting/dashboard_app.py | 21 ++++++-- .../reporting/dashboard_data.py | 12 +++++ tests/reporting/test_dashboard_app.py | 52 ++++++++++++++++++- tests/reporting/test_dashboard_data.py | 16 +++++- 5 files changed, 97 insertions(+), 8 deletions(-) diff --git a/docs/reports.mdx b/docs/reports.mdx index b6576617e..083c2ec17 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -574,7 +574,9 @@ views. Rewriting a JSON file passed on the command line, or adding an entry directly inside a directory input, is picked up on the next interaction. Edits deeper inside a directory input (for example a run that is still writing trials) or in reports a catalog references appear after **Reload reports** in the -sidebar; a browser refresh does not re-read them. +sidebar; a browser refresh does not re-read them. Overlapping inputs, such as a +results directory and a run inside it, are loaded once. Byte-identical uploads +are skipped with a notice. Missing measurements stay unavailable, and cost is shown only when recorded in USD. Canonical Tier 3 JSON records each single-step trial's agent execution time diff --git a/src/skillevaluator/reporting/dashboard_app.py b/src/skillevaluator/reporting/dashboard_app.py index 5508513a5..6f9e8a16c 100644 --- a/src/skillevaluator/reporting/dashboard_app.py +++ b/src/skillevaluator/reporting/dashboard_app.py @@ -10,6 +10,7 @@ from __future__ import annotations import csv +import hashlib import io import json import sys @@ -22,6 +23,7 @@ from skillevaluator.reporting.dashboard_data import ( DashboardData, comparison_rows, + dedupe_rows, load_dashboard_path, parse_dashboard_report, ) @@ -106,12 +108,13 @@ def _load_path_cached(path: str, fingerprint: tuple[int, int, int] | None) -> Da # Keyed on file_id, which is stable while the file stays in the widget; # the leading underscore stops Streamlit hashing the uploaded bytes. @st.cache_data(max_entries=_CACHE_ENTRIES, show_spinner=False) -def _parse_upload_cached(file_id: str, source: str, name: str, _contents: bytes) -> DashboardData: +def _parse_upload_cached(file_id: str, source: str, name: str, _contents: bytes) -> tuple[str, DashboardData]: + digest = hashlib.sha256(_contents).hexdigest() try: payload = json.loads(_contents) except (ValueError, RecursionError): # UnicodeError is a ValueError subclass - return DashboardData(warnings=[f"{name}: invalid JSON. Upload a UTF-8 JSON evaluation report."]) - return parse_dashboard_report(payload, source=source) + return digest, DashboardData(warnings=[f"{name}: invalid JSON. Upload a UTF-8 JSON evaluation report."]) + return digest, parse_dashboard_report(payload, source=source) def rows_csv(rows: list[dict[str, Any]], columns: tuple[str, ...]) -> str: @@ -322,17 +325,27 @@ def main(paths: list[str] | None = None) -> None: data = _load_path_cached(str(path), _input_fingerprint(path)) rows.extend(data.rows) warnings.extend(data.warnings) + seen_uploads: set[str] = set() for index, uploaded in enumerate(uploads): if uploaded.size > _MAX_UPLOAD_BYTES: warnings.append( f"{uploaded.name}: report exceeds 16 MB (16,000,000 bytes). Upload a smaller evaluation report." ) continue - data = _parse_upload_cached( + digest, data = _parse_upload_cached( uploaded.file_id, f"upload:{index + 1}:{uploaded.name}", uploaded.name, uploaded.getvalue() ) + if digest in seen_uploads: + warnings.append(f"{uploaded.name}: identical to an earlier upload; skipped.") + continue + seen_uploads.add(digest) rows.extend(data.rows) warnings.extend(data.warnings) + # Overlapping CLI paths (a directory and a run inside it) reload rows under the same source. + rows, duplicate_count = dedupe_rows(rows) + if duplicate_count: + plural = "s" if duplicate_count != 1 else "" + warnings.append(f"Overlapping inputs: {duplicate_count} duplicate condition row{plural} loaded once.") if warnings: notices = list(dict.fromkeys(warnings)) with st.expander(f"Report notices ({len(notices)})", expanded=True): diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index 40739702a..1f3250ee2 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -378,6 +378,18 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: return output +def dedupe_rows(rows: list[dict[str, Any]]) -> tuple[list[dict[str, Any]], int]: + """Drop rows reloaded from the same resolved source; keys are unique within one parse.""" + seen: set[tuple[Any, ...]] = set() + kept = [] + for row in rows: + key = (row.get("source"), row.get("_report_index"), row.get("_agent_key"), row.get("condition")) + if key not in seen: + seen.add(key) + kept.append(row) + return kept, len(rows) - len(kept) + + def comparison_rows(rows: list[dict[str, Any]]) -> list[dict[str, Any]]: """Compute with-minus-without differences only within an identical run.""" groups: dict[tuple[Any, ...], list[dict[str, Any]]] = {} diff --git a/tests/reporting/test_dashboard_app.py b/tests/reporting/test_dashboard_app.py index f855d57fc..d923a205a 100644 --- a/tests/reporting/test_dashboard_app.py +++ b/tests/reporting/test_dashboard_app.py @@ -216,8 +216,38 @@ def test_notice_count_matches_unique_notices(tmp_path: Path) -> None: # The directory walk and the direct file path report the same notice for one file. app = _app([tmp_path, report]) assert not app.exception - assert app.expander[0].label == "Report notices (1)" - assert len(app.text) == 1 + assert app.expander[0].label == "Report notices (2)" + assert len(app.text) == 2 + assert app.text[1].value == "Overlapping inputs: 2 duplicate condition rows loaded once." + + +def test_directory_and_file_inside_it_load_once(tmp_path: Path) -> None: + report = _write_report(tmp_path / "run.json") + app = _app([tmp_path, report]) + assert not app.exception + assert len(app.dataframe[0].value) == 2 + comparison = app.dataframe[1].value + assert comparison["comparison_status"].tolist() == ["comparable"] + assert comparison["score_delta"].iloc[0] == pytest.approx(0.3) + assert any("duplicate" in text.value for text in app.text) + + +def test_results_dir_and_latest_symlink_load_once(tmp_path: Path) -> None: + results = tmp_path / "results" + run = results / "run-1" + run.mkdir(parents=True) + _write_report(run / "report.json") + try: + (results / "latest").symlink_to(run, target_is_directory=True) + except OSError: + pytest.skip("Symlinks are unavailable on this host") + app = _app([results, results / "latest"]) + assert not app.exception + assert len(app.dataframe[0].value) == 2 + comparison = app.dataframe[1].value + assert comparison["comparison_status"].tolist() == ["comparable"] + assert comparison["score_delta"].iloc[0] == pytest.approx(0.3) + assert any("duplicate" in text.value for text in app.text) def test_status_filter_does_not_pair_arms_from_separate_embedded_reports(tmp_path: Path) -> None: @@ -336,6 +366,24 @@ def test_upload_batch_reports_oversize_and_invalid_and_keeps_valid(tmp_path: Pat assert len(app.dataframe[0].value) == 2 +def test_identical_uploads_are_loaded_once(tmp_path: Path) -> None: + blob = _write_report(tmp_path / "run.json").read_bytes() + app = _upload_app() + app.file_uploader(key="report_uploads").set_value([("run.json", blob, "application/json")] * 2).run() + assert not app.exception + assert len(app.dataframe[0].value) == 2 + assert [metric.value for metric in app.metric] == ["1", "1", "2", "2"] + assert any("identical to an earlier upload; skipped." in text.value for text in app.text) + + other = _write_report(tmp_path / "other.json", model="model-b").read_bytes() + app.file_uploader(key="report_uploads").set_value( + [("run.json", blob, "application/json"), ("run.json", other, "application/json")] + ).run() + assert not app.exception + assert len(app.dataframe[0].value) == 4 + assert not any("identical to an earlier upload" in text.value for text in app.text) + + def test_upload_at_exact_limit_is_accepted(tmp_path: Path) -> None: content = _write_report(tmp_path / "run.json").read_bytes() exact = content + b" " * (16_000_000 - len(content)) diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index 94375d8df..85fa96df6 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -11,7 +11,12 @@ import pytest from skillevaluator.evaluation.tier3_report import agent_eval_result_from_directory -from skillevaluator.reporting.dashboard_data import comparison_rows, load_dashboard_path, parse_dashboard_report +from skillevaluator.reporting.dashboard_data import ( + comparison_rows, + dedupe_rows, + load_dashboard_path, + parse_dashboard_report, +) def _report() -> dict: @@ -171,6 +176,15 @@ def test_disjoint_runs_features_and_duplicate_conditions_cannot_pair() -> None: assert duplicate["score_delta"] is None +def test_dedupe_rows_drops_only_reloaded_rows() -> None: + rows = parse_dashboard_report(_report(), "x").rows + deduped, dropped = dedupe_rows(rows + copy.deepcopy(rows)) + assert (deduped, dropped) == (rows, 2) + # Identical embedded reports in one file are separate occurrences, not reloads. + assert dedupe_rows(parse_dashboard_report([_report(), _report()], "x").rows)[1] == 0 + assert comparison_rows(deduped)[0]["comparison_status"] == "comparable" + + @pytest.mark.parametrize("scope", ["reports", "agents"]) def test_status_filter_cannot_pair_different_report_or_agent_occurrences(scope: str) -> None: first, second = _report(), _report() From 305dd66ca80f37ab36745bac7cc40ef690d15952 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 02:13:39 -0700 Subject: [PATCH 16/40] fix(dashboard): keep malformed counts and unreadable trials inside their own row A declared trial count of about 2**64 or more passed the count check, and when the trials could not be keyed it became the row's trial count. The performance table then failed Arrow conversion, so one malformed report blanked every valid report on the page. Counts above one million, far beyond the 512-trial loader bound, are now treated as invalid coverage counts, so that row shows the usual notice with no score or usage. An unreadable trials directory in a retained run raised out of the run loader and dropped every agent and condition in the run. That condition now gets a notice and blank usage totals while the run's other rows load. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- .../reporting/dashboard_data.py | 14 ++++++++++--- tests/reporting/test_dashboard_app.py | 15 +++++++++++++ tests/reporting/test_dashboard_data.py | 21 +++++++++++++++++-- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index 1f3250ee2..a5f56df6e 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -29,6 +29,7 @@ _MAX_FILE_BYTES = 16 * 1024 * 1024 _MAX_FILES = 1000 _MAX_PATHS = 20_000 +_MAX_COUNT = 1_000_000 # far above report_data's 512-trial bound; larger values are malformed # Loader bounds on these artifacts drop only per-trial telemetry (tokens, steps). # Canonical trials then omit those counters, so coverage counts keep totals blank. _TELEMETRY_ARTIFACTS = frozenset({"trajectory"}) @@ -67,7 +68,7 @@ def _measurement(value: Any) -> float | None: def _count(value: Any) -> int | None: - return value if isinstance(value, int) and not isinstance(value, bool) and value >= 0 else None + return value if isinstance(value, int) and not isinstance(value, bool) and 0 <= value <= _MAX_COUNT else None def _feature_config(*owners: dict[str, Any]) -> tuple[str, str]: @@ -563,8 +564,15 @@ def _load_native(path: Path) -> DashboardData: _set_usage(row, [], expected=row["_expected_usage_trials"]) continue if trials_dir.is_dir(): - trial_paths, truncated = _directory_entries(trials_dir, 4096) - trial_dirs = [candidate for candidate in trial_paths if candidate.is_dir() and not candidate.is_symlink()] + try: + trial_paths, truncated = _directory_entries(trials_dir, 4096) + trial_dirs = [ + candidate for candidate in trial_paths if candidate.is_dir() and not candidate.is_symlink() + ] + except (OSError, ValueError) as exc: + output.warnings.append(f"{trials_dir}: cannot read retained trials: {exc}") + _set_usage(row, [], expected=row["_expected_usage_trials"]) + continue truncated |= len(trial_dirs) > 512 loaded: list[tuple[Path, dict[str, Any] | None]] = [] for trial_dir in trial_dirs[:512]: diff --git a/tests/reporting/test_dashboard_app.py b/tests/reporting/test_dashboard_app.py index d923a205a..b3896df3f 100644 --- a/tests/reporting/test_dashboard_app.py +++ b/tests/reporting/test_dashboard_app.py @@ -195,6 +195,21 @@ def test_bad_report_does_not_hide_other_results(tmp_path: Path) -> None: assert len(app.dataframe[0].value) == 2 +def test_oversized_trial_count_keeps_other_reports(tmp_path: Path) -> None: + valid = _write_report(tmp_path / "valid.json") + oversized = _write_report(tmp_path / "oversized.json") + report = json.loads(oversized.read_text(encoding="utf-8")) + agent = report["agents"]["opencode"] + agent["num_trials"] = 10**20 + for trial in agent["trials"]: + trial.pop("entry_id") + oversized.write_text(json.dumps(report), encoding="utf-8") + app = _app([valid, oversized]) + assert not app.exception + assert len(app.dataframe[0].value) == 4 + assert any("invalid trial coverage counts" in text.value for text in app.text) + + def test_report_notices_are_plain_text(tmp_path: Path) -> None: path = _write_report(tmp_path / "beacon.json") report = json.loads(path.read_text(encoding="utf-8")) diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index 85fa96df6..a90c2cfbb 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -5,6 +5,7 @@ import copy import json +import os import shutil from pathlib import Path @@ -111,7 +112,7 @@ def test_canonical_missing_attempt_keeps_usage_totals_unknown() -> None: assert "tokens 1/2" in row["coverage"] -@pytest.mark.parametrize("value", [True, -1, 1.5, "1"]) +@pytest.mark.parametrize("value", [True, -1, 1.5, "1", 10**30]) @pytest.mark.parametrize("field", ["declared", "expected", "both_attempt_counts"]) def test_present_invalid_coverage_counts_never_become_inferred_complete_counts(value: object, field: str) -> None: report = _report() @@ -835,7 +836,7 @@ def test_native_different_condition_models_cannot_pair(tmp_path: Path) -> None: assert all(row["comparison_status"] == "missing condition" for row in comparisons) -@pytest.mark.parametrize("value", [True, -1, 1.5, "1"]) +@pytest.mark.parametrize("value", [True, -1, 1.5, "1", 10**30]) @pytest.mark.parametrize("field", ["num_trials", "expected_attempts", "scored_attempts"]) def test_native_invalid_coverage_counts_cannot_be_hidden_by_canonical_normalization( tmp_path: Path, field: str, value: object @@ -855,6 +856,22 @@ def test_native_invalid_coverage_counts_cannot_be_hidden_by_canonical_normalizat assert comparison_rows(data.rows)[0]["score_delta"] is None +@pytest.mark.skipif(os.name == "nt" or os.geteuid() == 0, reason="Needs POSIX permissions enforced for this user") +def test_unreadable_condition_trials_keep_other_rows(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + trials = run / "opencode" / "with-skill" / "trials" + trials.chmod(0) + try: + data = load_dashboard_path(run) + finally: + trials.chmod(0o755) + assert len(data.rows) == 2 + assert next(row for row in data.rows if row["condition"] == "with_skill")["total_tokens"] is None + assert next(row for row in data.rows if row["condition"] == "without_skill")["total_tokens"] == 110 + assert any("cannot read retained trials" in warning for warning in data.warnings) + + @pytest.mark.parametrize("artifact", ["trials", "trajectory.json", "result.json", "reward.json"]) def test_native_usage_rejects_intermediate_directory_and_file_symlinks(tmp_path: Path, artifact: str) -> None: run = tmp_path / "run" From d2cab482b953cfd1f920da04c5ba528888fcbf6a Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 02:16:13 -0700 Subject: [PATCH 17/40] refactor(dashboard): name native trial bounds and tidy the retained-run loader The retained-run loader hard-coded 512 and 4096, the same trial bounds the canonical report loader uses, with nothing tying the two together. They are now named constants, and a test checks that they still match report_data. A repeated directory check that could never trigger is removed, the JSON reader stats each file once, the catalog and discovery limit notices are written once, _set_usage always takes an explicit expected count, and the multi-step ambiguity notice is matched exactly rather than by a copied substring. Messages and behaviour are unchanged. New tests cover the trial discovery limit without creating 513 directories, the local JSON size limit at and just past the boundary, and that a resolved multi-step scope leaves no ambiguity notice. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- .../reporting/dashboard_data.py | 39 +++++++------ tests/reporting/test_dashboard_data.py | 57 ++++++++++++++++++- 2 files changed, 77 insertions(+), 19 deletions(-) diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index a5f56df6e..ff50e9dfb 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -30,6 +30,12 @@ _MAX_FILES = 1000 _MAX_PATHS = 20_000 _MAX_COUNT = 1_000_000 # far above report_data's 512-trial bound; larger values are malformed +# Mirror report_data._MAX_TRIALS_PER_CONDITION / _MAX_TRIAL_PATHS_SCANNED so the +# dashboard totals the same bounded trial population as the canonical loader. +_MAX_NATIVE_TRIALS = 512 +_MAX_NATIVE_TRIAL_ENTRIES = 4096 +_CATALOG_LIMIT_NOTICE = "Dashboard catalog limit reached; some inputs were omitted." +_DISCOVERY_LIMIT_NOTICE = "Dashboard discovery limit reached; some inputs were omitted." # Loader bounds on these artifacts drop only per-trial telemetry (tokens, steps). # Canonical trials then omit those counters, so coverage counts keep totals blank. _TELEMETRY_ARTIFACTS = frozenset({"trajectory"}) @@ -227,8 +233,7 @@ def _usage(trial: dict[str, Any]) -> dict[str, float | None]: } -def _set_usage(row: dict[str, Any], usages: list[dict[str, Any]], expected: int | None = None) -> None: - expected = row["trials"] if expected is None else expected +def _set_usage(row: dict[str, Any], usages: list[dict[str, Any]], *, expected: int) -> None: row["_usage_coverage"] = {} for metric in _USAGE: values = [_measurement(usage.get(metric)) for usage in usages] @@ -440,7 +445,8 @@ def comparison_rows(rows: list[dict[str, Any]]) -> list[dict[str, Any]]: def _read_json(path: Path) -> Any: - if not stat.S_ISREG(path.stat().st_mode) or path.stat().st_size > _MAX_FILE_BYTES: + info = path.stat() + if not stat.S_ISREG(info.st_mode) or info.st_size > _MAX_FILE_BYTES: raise ValueError("JSON must be a regular file no larger than 16 MiB") with path.open("rb") as stream: data = stream.read(_MAX_FILE_BYTES + 1) @@ -565,7 +571,7 @@ def _load_native(path: Path) -> DashboardData: continue if trials_dir.is_dir(): try: - trial_paths, truncated = _directory_entries(trials_dir, 4096) + trial_paths, truncated = _directory_entries(trials_dir, _MAX_NATIVE_TRIAL_ENTRIES) trial_dirs = [ candidate for candidate in trial_paths if candidate.is_dir() and not candidate.is_symlink() ] @@ -573,11 +579,9 @@ def _load_native(path: Path) -> DashboardData: output.warnings.append(f"{trials_dir}: cannot read retained trials: {exc}") _set_usage(row, [], expected=row["_expected_usage_trials"]) continue - truncated |= len(trial_dirs) > 512 + truncated |= len(trial_dirs) > _MAX_NATIVE_TRIALS loaded: list[tuple[Path, dict[str, Any] | None]] = [] - for trial_dir in trial_dirs[:512]: - if not trial_dir.is_dir() or trial_dir.is_symlink(): - continue + for trial_dir in trial_dirs[:_MAX_NATIVE_TRIALS]: try: loaded.append((trial_dir, _dict(_read_native_json(trial_dir / "reward.json", path)))) except (OSError, ValueError, RecursionError) as exc: @@ -610,12 +614,11 @@ def _load_native(path: Path) -> DashboardData: usages_by_trial["__omitted_trials__"] = {} row["_expected_usage_trials"] = max(row["_expected_usage_trials"], len(usages_by_trial)) _set_usage(row, list(usages_by_trial.values()), expected=row["_expected_usage_trials"]) + notice = _ambiguous_resource_notice(str(path)) if not unresolved_scope: - output.warnings = [ - warning for warning in output.warnings if "canonical multi-step resource ownership" not in warning - ] - elif not any("canonical multi-step resource ownership" in warning for warning in output.warnings): - output.warnings.append(_ambiguous_resource_notice(str(path))) + output.warnings = [warning for warning in output.warnings if warning != notice] + elif notice not in output.warnings: + output.warnings.append(notice) return output @@ -629,7 +632,7 @@ def _load_report_file( if path in budget.seen: return DashboardData() if budget.files_remaining <= 0 or budget.references_remaining <= 0: - return DashboardData(warnings=["Dashboard catalog limit reached; some inputs were omitted."]) + return DashboardData(warnings=[_CATALOG_LIMIT_NOTICE]) budget.seen.add(path) budget.files_remaining -= 1 if path.name == "result.json" and (path.parent / "run_config.json").is_file(): @@ -645,7 +648,7 @@ def _load_report_file( if not isinstance(report_dir, str) or not isinstance(report_name, str): continue if budget.files_remaining <= 0 or budget.references_remaining <= 0: - output.warnings.append("Dashboard catalog limit reached; some inputs were omitted.") + output.warnings.append(_CATALOG_LIMIT_NOTICE) break budget.references_remaining -= 1 try: @@ -658,7 +661,7 @@ def _load_report_file( output.rows.extend(report.rows) output.warnings.extend(report.warnings) if len(payload["skills"]) > _MAX_FILES: - output.warnings.append("Dashboard catalog limit reached; some inputs were omitted.") + output.warnings.append(_CATALOG_LIMIT_NOTICE) if not output.rows: output.warnings.extend(data.warnings) return output @@ -696,7 +699,7 @@ def load_dashboard_path(path: Path) -> DashboardData: while pending: root = pending.pop() if visited >= _MAX_PATHS or files >= _MAX_FILES: - output.warnings.append("Dashboard discovery limit reached; some inputs were omitted.") + output.warnings.append(_DISCOVERY_LIMIT_NOTICE) break if (root / "result.json").is_file() and (root / "run_config.json").is_file(): try: @@ -714,7 +717,7 @@ def load_dashboard_path(path: Path) -> DashboardData: continue visited += len(entries) if truncated: - output.warnings.append("Dashboard discovery limit reached; some inputs were omitted.") + output.warnings.append(_DISCOVERY_LIMIT_NOTICE) subdirectories = [] for entry in entries: if files >= _MAX_FILES: diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index a90c2cfbb..0f1b52052 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -716,6 +716,59 @@ def __iter__(self): assert any("discovery limit" in warning for warning in data.warnings) +def test_native_trial_bounds_mirror_report_data() -> None: + from skillevaluator.reporting import dashboard_data + from skillevaluator.tier3.harbor import report_data + + assert dashboard_data._MAX_NATIVE_TRIALS == report_data._MAX_TRIALS_PER_CONDITION + assert dashboard_data._MAX_NATIVE_TRIAL_ENTRIES == report_data._MAX_TRIAL_PATHS_SCANNED + + +def test_native_trial_discovery_limit_keeps_usage_unavailable(tmp_path: Path, monkeypatch) -> None: + from skillevaluator.reporting import dashboard_data + + run = tmp_path / "run" + _native_run(run) + condition = run / "opencode" / "with-skill" + original = condition / "trials" / "case-a__random" + for index in (1, 2): + trial_dir = shutil.copytree(original, original.with_name(f"case-a__trial{index}")) + reward_path = trial_dir / "reward.json" + reward = json.loads(reward_path.read_text(encoding="utf-8")) + reward["trial_id"] = trial_dir.name + reward_path.write_text(json.dumps(reward), encoding="utf-8") + summary_path = condition / "summary.json" + summary = json.loads(summary_path.read_text(encoding="utf-8")) + summary.update(num_trials=3, expected_attempts=3, scored_attempts=3) + summary_path.write_text(json.dumps(summary), encoding="utf-8") + # Within the bound all three trials are measured. + assert next(row for row in load_dashboard_path(run).rows if row["condition"] == "with_skill")["total_tokens"] == 630 + monkeypatch.setattr(dashboard_data, "_MAX_NATIVE_TRIALS", 2) + data = load_dashboard_path(run) + row = next(row for row in data.rows if row["condition"] == "with_skill") + assert any("trial discovery limit reached; usage totals are unavailable." in warning for warning in data.warnings) + assert row["total_tokens"] is None + assert row["duration_seconds"] is None + + +def test_local_json_over_limit_is_a_notice_and_other_reports_load(tmp_path: Path, monkeypatch) -> None: + from skillevaluator.reporting import dashboard_data + + monkeypatch.setattr(dashboard_data, "_MAX_FILE_BYTES", 2048) + content = json.dumps(_report()) + exact = tmp_path / "exact.json" + exact.write_text(content.ljust(2048), encoding="utf-8") + oversized = tmp_path / "oversized.json" + oversized.write_text(content.ljust(2049), encoding="utf-8") + assert (exact.stat().st_size, oversized.stat().st_size) == (2048, 2049) + assert len(load_dashboard_path(exact).rows) == 2 + assert any("16 MiB" in warning for warning in load_dashboard_path(oversized).warnings) + data = load_dashboard_path(tmp_path) + assert {row["source"] for row in data.rows} == {str(exact.resolve())} + assert len(data.rows) == 2 + assert any(str(oversized.resolve()) in warning and "16 MiB" in warning for warning in data.warnings) + + def test_directory_file_budget_counts_malformed_reports(tmp_path: Path, monkeypatch) -> None: from skillevaluator.reporting import dashboard_data @@ -937,7 +990,9 @@ def test_native_duplicate_reward_rows_require_authoritative_step_scope(tmp_path: } result["step_results"] = [step, {**copy.deepcopy(step), "step_name": "finish"}] result_path.write_text(json.dumps(result), encoding="utf-8") - row = load_dashboard_path(run).rows[0] + data = load_dashboard_path(run) + assert not any("resource ownership is ambiguous" in warning for warning in data.warnings) + row = data.rows[0] assert row["score"] == 0.8 assert row["total_tokens"] == 110 assert row["duration_seconds"] == 20 From b95986f64c04d2610e2e8ba5a1333a968fd90301 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 02:19:47 -0700 Subject: [PATCH 18/40] feat(dashboard): explain why a pair is not comparable "incomplete or mismatched coverage" covered several different causes, so users had to read the JSON to learn why a pair had no deltas. A new Comparison reason column, included in every comparison view and in the CSV, names the first failing check: a failed or skipped arm, invalid trial counts, truncated trial data, incomplete coverage in one arm, different cases or attempts, a different dataset or attempt policy, a missing arm, or an arm loaded more than once. comparison_status and the pairing rules are unchanged. The status filter also ran before pairing, so filtering to succeeded rows turned a recorded failed baseline into "missing condition". Status now narrows the performance table only, like the condition filter, and the comparison shows the failed arm as the reason instead. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/reports.mdx | 5 ++- src/skillevaluator/reporting/dashboard_app.py | 9 ++-- .../reporting/dashboard_data.py | 27 ++++++++++++ tests/reporting/test_dashboard_app.py | 18 +++++++- tests/reporting/test_dashboard_data.py | 43 +++++++++++++++++-- 5 files changed, 91 insertions(+), 11 deletions(-) diff --git a/docs/reports.mdx b/docs/reports.mdx index 083c2ec17..80d97a66e 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -557,12 +557,15 @@ accept up to 16 MiB (16,777,216 bytes); larger files produce a notice while othe valid reports remain available. Filter the sortable tables by skill, model, harness, recorded harness features, -condition, and execution status. Download the visible performance or comparison +condition, and execution status. The status and condition filters narrow the +performance table only, so comparisons keep both arms; the other filters also +remove arms from comparisons. Download the visible performance or comparison rows as CSV. Each performance row represents one run, harness, and condition. The comparison table calculates **with skill minus without skill**, and percent change relative to without skill. A negative usage difference means less usage; a positive score difference means higher performance. Comparisons stay within the same run and require successful conditions with matching trial coverage. +When a pair's differences stay blank, the **Comparison reason** column says why. Repeated attempts pair by case, as in the HTML report: each arm must record the same number of attempts for every case, and each attempt must have its own trial ID. A trajectory above the report loader's size bound leaves that trial's diff --git a/src/skillevaluator/reporting/dashboard_app.py b/src/skillevaluator/reporting/dashboard_app.py index 6f9e8a16c..066d1fa3e 100644 --- a/src/skillevaluator/reporting/dashboard_app.py +++ b/src/skillevaluator/reporting/dashboard_app.py @@ -65,6 +65,7 @@ "cost_usd_delta", "cost_usd_percent", "comparison_status", + "comparison_reason", "features", "coverage", "with_score", @@ -236,7 +237,7 @@ def _show_comparisons(rows: list[dict[str, Any]]) -> None: key="comparison_metrics", ) identity = ("skill", "model", "harness") - details = ("comparison_status", "features", "coverage", "run_id", "source") + details = ("comparison_status", "comparison_reason", "features", "coverage", "run_id", "source") metric_sets = { "Overview": ( "score_delta", @@ -362,9 +363,9 @@ def main(paths: list[str] | None = None) -> None: dimension_rows = rows for field in _DIMENSIONS: dimension_rows = _filter_rows(dimension_rows, field, rows) - dimension_rows = _filter_rows(dimension_rows, "status", rows) - performance_rows = _filter_rows(dimension_rows, "condition", rows) - st.sidebar.caption("The condition filter applies to performance. Comparisons retain both conditions.") + performance_rows = _filter_rows(dimension_rows, "status", rows) + performance_rows = _filter_rows(performance_rows, "condition", rows) + st.sidebar.caption("Status and condition filters apply to performance. Comparisons retain both conditions.") run_count = len({(row["source"], row["run_id"]) for row in performance_rows}) skill_count = len({row["skill"] for row in performance_rows}) diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index ff50e9dfb..e4f96d606 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -358,6 +358,7 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: else None, "_complete": complete, "_invalid_counts": invalid_counts, + "_coverage_truncated": coverage_truncated, "_report_index": report_index, "_agent_key": str(name), "_trial_keys": keys, @@ -396,6 +397,28 @@ def dedupe_rows(rows: list[dict[str, Any]]) -> tuple[list[dict[str, Any]], int]: return kept, len(rows) - len(kept) +def _ineligible_reason(with_row: dict[str, Any], without_row: dict[str, Any]) -> str: + """Name the first check that keeps a with/without pair from being comparable.""" + arms = (("with-skill", with_row), ("without-skill", without_row)) + for label, row in arms: + if row.get("status") != "succeeded": + return f"{label} arm status {row.get('status') or 'unknown'}" + if with_row.get("_invalid_counts") or without_row.get("_invalid_counts"): + return "invalid trial counts" + if with_row.get("_coverage_truncated") or without_row.get("_coverage_truncated"): + return "trial data truncated" + for label, row in arms: + if not row.get("_complete"): + return f"{label} trial coverage incomplete" + if with_row.get("_trial_keys") != without_row.get("_trial_keys"): + return "different cases or attempts" + if with_row.get("_dataset_digest") != without_row.get("_dataset_digest"): + return "different dataset" + if with_row.get("_attempt_policy") != without_row.get("_attempt_policy"): + return "different attempt policy" + return "" + + def comparison_rows(rows: list[dict[str, Any]]) -> list[dict[str, Any]]: """Compute with-minus-without differences only within an identical run.""" groups: dict[tuple[Any, ...], list[dict[str, Any]]] = {} @@ -408,9 +431,11 @@ def comparison_rows(rows: list[dict[str, Any]]) -> list[dict[str, Any]]: without_rows = [row for row in arms if row["condition"] == "without_skill"] result = dict(zip(_PAIRING_IDENTITY, identity, strict=True)) status = "missing condition" + reason = f"no {'without' if with_rows else 'with'}-skill arm for this run and configuration" paired = False if len(with_rows) > 1 or len(without_rows) > 1: status = "ambiguous duplicate conditions" + reason = "same arm loaded more than once" elif with_rows and without_rows: with_row, without_row = with_rows[0], without_rows[0] paired = ( @@ -421,7 +446,9 @@ def comparison_rows(rows: list[dict[str, Any]]) -> list[dict[str, Any]]: and with_row.get("_attempt_policy") == without_row.get("_attempt_policy") ) status = "comparable" if paired else "incomplete or mismatched coverage" + reason = "" if paired else _ineligible_reason(with_row, without_row) result["comparison_status"] = status + result["comparison_reason"] = reason result["coverage"] = ( f"{with_rows[0]['trials']} with / {without_rows[0]['trials']} without" if with_rows and without_rows diff --git a/tests/reporting/test_dashboard_app.py b/tests/reporting/test_dashboard_app.py index b3896df3f..68cf2b2d1 100644 --- a/tests/reporting/test_dashboard_app.py +++ b/tests/reporting/test_dashboard_app.py @@ -181,7 +181,16 @@ def test_unmeasured_and_failed_baseline_are_not_zero_or_comparable(tmp_path: Pat app.multiselect(key="filter_status").set_value(["succeeded"]).run() assert not app.exception assert len(app.dataframe[0].value) == 1 - assert app.dataframe[1].value["comparison_status"].iloc[0] == "missing condition" + # Status narrows performance only, so the comparison still names the failed arm. + comparison = app.dataframe[1].value + assert comparison["comparison_status"].iloc[0] == "incomplete or mismatched coverage" + assert comparison["comparison_reason"].iloc[0] == "without-skill arm status failed" + assert comparison["coverage"].iloc[0] == "1 with / 1 without" + assert comparison["score_delta"].isna().all() + app.multiselect(key="filter_status").set_value(["failed"]).run() + assert not app.exception + assert app.dataframe[0].value["condition"].tolist() == ["without_skill"] + assert app.dataframe[1].value["comparison_reason"].tolist() == ["without-skill arm status failed"] def test_bad_report_does_not_hide_other_results(tmp_path: Path) -> None: @@ -277,7 +286,11 @@ def test_status_filter_does_not_pair_arms_from_separate_embedded_reports(tmp_pat assert not app.exception comparisons = app.dataframe[1].value assert len(comparisons) == 2 - assert comparisons["comparison_status"].tolist() == ["missing condition", "missing condition"] + assert comparisons["comparison_status"].tolist() == ["incomplete or mismatched coverage"] * 2 + assert comparisons["comparison_reason"].tolist() == [ + "without-skill arm status failed", + "with-skill arm status failed", + ] assert comparisons["score_delta"].isna().all() @@ -429,6 +442,7 @@ def test_comparison_views_keep_measurements_numeric(tmp_path: Path, view: str, m config = json.loads(comparison.proto.columns) assert config[measured_column]["type_config"]["type"] == "number" assert config["comparison_status"]["type_config"]["type"] == "text" + assert config["comparison_reason"]["type_config"]["type"] == "text" assert comparison.value["comparison_status"].iloc[0] == "comparable" assert len(comparison.value.columns) == len(set(comparison.value.columns)) if view == "All metrics": diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index 0f1b52052..23a5b02a9 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -68,6 +68,7 @@ def test_with_without_differences_and_explicit_features() -> None: assert data.rows[0]["features"] == "memory, rules" comparison = comparison_rows(data.rows)[0] assert comparison["comparison_status"] == "comparable" + assert comparison["comparison_reason"] == "" assert comparison["score_delta"] == pytest.approx(0.2) assert comparison["total_tokens_delta"] == 30 assert comparison["total_tokens_percent"] == 25 @@ -144,8 +145,18 @@ def test_unrecorded_legacy_coverage_counts_preserve_observed_trial_pairing() -> assert comparison_rows(parse_dashboard_report(report, "legacy.json").rows)[0]["comparison_status"] == "comparable" -@pytest.mark.parametrize("mutation", ["failed", "missing_trial", "truncated", "different_case", "missing_attempt"]) -def test_incomplete_or_unmatched_arms_block_all_deltas(mutation: str) -> None: +@pytest.mark.parametrize( + ("mutation", "reason"), + [ + ("failed", "without-skill arm status failed"), + ("missing_trial", "without-skill trial coverage incomplete"), + ("truncated", "trial data truncated"), + ("different_case", "different cases or attempts"), + ("missing_attempt", "without-skill trial coverage incomplete"), + ("invalid_count", "invalid trial counts"), + ], +) +def test_incomplete_or_unmatched_arms_block_all_deltas(mutation: str, reason: str) -> None: report = _report() agent = report["agents"]["claude-code"] if mutation == "failed": @@ -158,22 +169,46 @@ def test_incomplete_or_unmatched_arms_block_all_deltas(mutation: str) -> None: agent["trials_baseline"][0]["entry_id"] = "case-b" elif mutation == "missing_attempt": agent["conditions"]["without_skill"]["expected_attempts"] = 2 + elif mutation == "invalid_count": + agent["num_trials_baseline"] = -1 comparison = comparison_rows(parse_dashboard_report(report, "same.json").rows)[0] assert comparison["comparison_status"] == "incomplete or mismatched coverage" + assert comparison["comparison_reason"] == reason assert comparison["score_delta"] is None assert comparison["total_tokens_delta"] is None +@pytest.mark.parametrize( + ("field", "reason"), + [("_dataset_digest", "different dataset"), ("_attempt_policy", "different attempt policy")], +) +def test_tautological_pair_checks_have_reasons(field: str, reason: str) -> None: + rows = parse_dashboard_report(_report(), "same.json").rows + rows[1][field] = "other" + comparison = comparison_rows(rows)[0] + assert comparison["comparison_status"] == "incomplete or mismatched coverage" + assert comparison["comparison_reason"] == reason + assert comparison["score_delta"] is None + + def test_disjoint_runs_features_and_duplicate_conditions_cannot_pair() -> None: data = parse_dashboard_report(_report(), "first.json") rows = copy.deepcopy(data.rows) rows[1]["source"] = "second.json" - assert all(row["comparison_status"] == "missing condition" for row in comparison_rows(rows)) + comparisons = comparison_rows(rows) + assert all(row["comparison_status"] == "missing condition" for row in comparisons) + assert [row["comparison_reason"] for row in comparisons] == [ + "no without-skill arm for this run and configuration", + "no with-skill arm for this run and configuration", + ] rows = copy.deepcopy(data.rows) rows[1]["features"] = "rules" - assert all(row["comparison_status"] == "missing condition" for row in comparison_rows(rows)) + comparisons = comparison_rows(rows) + assert all(row["comparison_status"] == "missing condition" for row in comparisons) + assert all(row["comparison_reason"].startswith("no ") for row in comparisons) duplicate = comparison_rows([*data.rows, data.rows[0]])[0] assert duplicate["comparison_status"] == "ambiguous duplicate conditions" + assert duplicate["comparison_reason"] == "same arm loaded more than once" assert duplicate["score_delta"] is None From e09ee6bcfd1310adb073745d5906e94369f531d9 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 02:21:32 -0700 Subject: [PATCH 19/40] feat(dashboard): clearer empty states and an unrecorded-features notice When the filters excluded every row, the comparison tab still told users to load reports with both conditions, although such reports were loaded. It now says that no rows match the filters, as the performance tab does. When pairs exist but none is comparable, an info line points to the Comparison reason column. Coverage cells now read "1 trial" instead of "1 trials". No SkillEvaluator command writes dashboard_metadata.harness_features, so every evaluator-produced run shows features as unknown. When no loaded row records features, a caption says how to add them, and the reports guide states that the field is added by hand. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/reports.mdx | 6 +++-- src/skillevaluator/reporting/dashboard_app.py | 11 +++++++++ .../reporting/dashboard_data.py | 3 ++- tests/reporting/test_dashboard_app.py | 24 ++++++++++++++++++- tests/reporting/test_dashboard_data.py | 4 ++++ 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/docs/reports.mdx b/docs/reports.mdx index 80d97a66e..a46236d50 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -604,8 +604,10 @@ totals from authoritative step results. ### Recorded harness features -Features are experiment metadata, not inferred from the harness name. In a -canonical Tier 3 JSON payload, an agent or condition can include: +Features are experiment metadata, not inferred from the harness name. Current +SkillEvaluator commands do not record this field; add it to the canonical JSON +or to `run_config.json` by hand. In a canonical Tier 3 JSON payload, an agent or +condition can include: ```json "dashboard_metadata": { diff --git a/src/skillevaluator/reporting/dashboard_app.py b/src/skillevaluator/reporting/dashboard_app.py index 066d1fa3e..70f79ae86 100644 --- a/src/skillevaluator/reporting/dashboard_app.py +++ b/src/skillevaluator/reporting/dashboard_app.py @@ -226,6 +226,9 @@ def _show_performance(rows: list[dict[str, Any]]) -> None: def _show_comparisons(rows: list[dict[str, Any]]) -> None: + if not rows: + st.info("No rows match these filters. Clear a filter to include more results.") + return comparisons = comparison_rows(rows) st.caption("Conditions are paired within each run, skill, model, harness, and feature configuration.") if not comparisons: @@ -272,6 +275,8 @@ def _show_comparisons(rows: list[dict[str, Any]]) -> None: } columns = (*identity, *metric_sets[view], *details) if view in metric_sets else _COMPARISON_COLUMNS visible = [{column: row.get(column) for column in columns} for row in comparisons] + if not any(row["comparison_status"] == "comparable" for row in comparisons): + st.info("No pair is comparable. The Comparison reason column explains why.") st.dataframe( visible, column_order=columns, @@ -378,6 +383,12 @@ def main(paths: list[str] | None = None) -> None: st.caption( "Blank cells mean a measurement is missing, incomplete, or ambiguous. Unknown settings remain labeled unknown." ) + # Evaluator commands do not write harness features; "none (recorded)" counts as recorded. + if all(row.get("features") == "unknown" for row in rows): + st.caption( + "No harness features are recorded in these reports. Add dashboard_metadata.harness_features to compare " + "feature configurations; see Recorded harness features in the reports guide." + ) performance_tab, comparison_tab = st.tabs(["Performance", "With vs without skill"]) with performance_tab: _show_performance(performance_rows) diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index e4f96d606..761e4424c 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -246,7 +246,8 @@ def _set_usage(row: dict[str, Any], usages: list[dict[str, Any]], *, expected: i ) eligibility = "complete" if row["_complete"] else "incomplete or unknown trial coverage" row["coverage"] = ( - f"{row['trials']} trials ({eligibility}); tokens {row['_usage_coverage']['total_tokens']}, " + f"{row['trials']} trial{'' if row['trials'] == 1 else 's'} ({eligibility}); " + f"tokens {row['_usage_coverage']['total_tokens']}, " f"time {row['_usage_coverage']['duration_seconds']}, cost {row['_usage_coverage']['cost_usd']}" ) diff --git a/tests/reporting/test_dashboard_app.py b/tests/reporting/test_dashboard_app.py index 68cf2b2d1..465a8b0c7 100644 --- a/tests/reporting/test_dashboard_app.py +++ b/tests/reporting/test_dashboard_app.py @@ -35,6 +35,7 @@ def _write_report( features: list[str] | None = None, baseline_status: str = "succeeded", measured: bool = True, + record_features: bool = True, ) -> Path: def trial(score: float, tokens: int) -> dict: value = {"entry_id": "case-1", "trial_id": "case-1__attempt1", "overall": score} @@ -71,6 +72,8 @@ def trial(score: float, tokens: int) -> dict: }, }, } + if not record_features: + del report["agents"][harness]["dashboard_metadata"] path.write_text(json.dumps(report), encoding="utf-8") return path @@ -157,7 +160,7 @@ def test_dimension_filters_and_condition_retain_baseline_for_comparison(tmp_path assert not app.exception assert len(app.dataframe) == 0 assert "No rows match these filters" in app.info[0].value - assert "No comparisons are available" in app.info[1].value + assert "No rows match these filters" in app.info[1].value for widget in app.multiselect: widget.set_value([]) @@ -193,6 +196,25 @@ def test_unmeasured_and_failed_baseline_are_not_zero_or_comparable(tmp_path: Pat assert app.dataframe[1].value["comparison_reason"].tolist() == ["without-skill arm status failed"] +def test_no_comparable_pair_hint(tmp_path: Path) -> None: + app = _app([_write_report(tmp_path / "failed.json", baseline_status="failed")]) + assert not app.exception + assert any("No pair is comparable" in message.value for message in app.info) + app = _app([_write_report(tmp_path / "paired.json")]) + assert not app.exception + assert not any("No pair is comparable" in message.value for message in app.info) + + +def test_unrecorded_features_caption(tmp_path: Path) -> None: + app = _app([_write_report(tmp_path / "unrecorded.json", record_features=False)]) + assert not app.exception + assert app.dataframe[0].value["features"].tolist() == ["unknown", "unknown"] + assert any("No harness features are recorded" in caption.value for caption in app.caption) + app = _app([_write_report(tmp_path / "recorded.json")]) + assert not app.exception + assert not any("No harness features are recorded" in caption.value for caption in app.caption) + + def test_bad_report_does_not_hide_other_results(tmp_path: Path) -> None: valid = _write_report(tmp_path / "valid.json") invalid = tmp_path / "invalid.json" diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index 23a5b02a9..71554cd35 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -76,6 +76,10 @@ def test_with_without_differences_and_explicit_features() -> None: assert comparison["cost_usd_percent"] == 100 +def test_single_trial_coverage_label_is_singular() -> None: + assert parse_dashboard_report(_report(), "r").rows[0]["coverage"].startswith("1 trial (complete)") + + def test_authoritative_validator_results_exclude_top_level_mirror() -> None: first, second = _report(), _report() second["skill_name"] = "second-skill" From 7b5a0c02527733ead960dad3528057162a3da7b0 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 02:25:23 -0700 Subject: [PATCH 20/40] feat(dashboard): add per-trial token, time, and cost columns The performance table showed only usage totals summed over each row's trials, so a model or harness that ran more trials looked proportionally more expensive. Issue #170 is about comparing models and harnesses, where trial counts can differ. Each row now also carries tokens, agent time, and cost per trial. A total is published only when every expected trial is measured, so dividing it by the expected trial count gives an exact mean, and the per-trial value stays blank whenever the total does. The columns sit right after the score in the table and CSV; the totals remain. Comparison deltas are unchanged because pairs already require identical trial keys. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/reports.mdx | 3 ++ src/skillevaluator/reporting/dashboard_app.py | 8 ++++ .../reporting/dashboard_data.py | 4 ++ tests/reporting/test_dashboard_app.py | 15 +++++++ tests/reporting/test_dashboard_data.py | 41 +++++++++++++++++++ 5 files changed, 71 insertions(+) diff --git a/docs/reports.mdx b/docs/reports.mdx index a46236d50..b0c44df6a 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -561,6 +561,9 @@ condition, and execution status. The status and condition filters narrow the performance table only, so comparisons keep both arms; the other filters also remove arms from comparisons. Download the visible performance or comparison rows as CSV. Each performance row represents one run, harness, and condition. +Per-trial columns are means over the row's measured trials and stay blank when +any trial is unmeasured. They help compare rows with different trial counts, +but runs on different datasets are still not like-for-like. The comparison table calculates **with skill minus without skill**, and percent change relative to without skill. A negative usage difference means less usage; a positive score difference means higher performance. Comparisons stay within diff --git a/src/skillevaluator/reporting/dashboard_app.py b/src/skillevaluator/reporting/dashboard_app.py index 70f79ae86..c48e30d5f 100644 --- a/src/skillevaluator/reporting/dashboard_app.py +++ b/src/skillevaluator/reporting/dashboard_app.py @@ -39,6 +39,9 @@ "harness", "condition", "score", + "total_tokens_per_trial", + "duration_seconds_per_trial", + "cost_usd_per_trial", "total_tokens", "duration_seconds", "cost_usd", @@ -157,6 +160,11 @@ def _performance_column_config() -> dict[str, Any]: "condition": st.column_config.TextColumn("Condition"), "score": st.column_config.NumberColumn("Score", format="%.3f", width="small"), "pass_rate": st.column_config.NumberColumn("Pass rate", format="percent", width="small"), + "total_tokens_per_trial": st.column_config.NumberColumn("Tokens / trial", format="%.1f", width="small"), + "duration_seconds_per_trial": st.column_config.NumberColumn( + "Agent time / trial (s)", format="%.2f", width="small" + ), + "cost_usd_per_trial": st.column_config.NumberColumn("Cost / trial (USD)", format="$%.4f", width="small"), "duration_seconds": st.column_config.NumberColumn("Agent time (s)", format="%.2f", width="small"), "cost_usd": st.column_config.NumberColumn("Cost (USD)", format="$%.4f", width="small"), "status": st.column_config.TextColumn("Status"), diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index 761e4424c..ac43e3600 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -244,6 +244,10 @@ def _set_usage(row: dict[str, Any], usages: list[dict[str, Any]], *, expected: i if values and available == len(values) == expected else None ) + # A total exists only when every expected trial is measured, so this is an exact mean. + for metric in ("total_tokens", "duration_seconds", "cost_usd"): + total = row[metric] + row[f"{metric}_per_trial"] = _number(total / expected) if total is not None and expected else None eligibility = "complete" if row["_complete"] else "incomplete or unknown trial coverage" row["coverage"] = ( f"{row['trials']} trial{'' if row['trials'] == 1 else 's'} ({eligibility}); " diff --git a/tests/reporting/test_dashboard_app.py b/tests/reporting/test_dashboard_app.py index 465a8b0c7..2583c2bd0 100644 --- a/tests/reporting/test_dashboard_app.py +++ b/tests/reporting/test_dashboard_app.py @@ -137,6 +137,21 @@ def test_dashboard_renders_numeric_performance_and_paired_comparison(tmp_path: P assert all(button.proto.ignore_rerun for button in downloads) +def test_performance_table_shows_per_trial_usage(tmp_path: Path) -> None: + path = _write_report(tmp_path / "run.json") + app = _app([path]) + assert not app.exception + performance = app.dataframe[0] + assert performance.value["total_tokens_per_trial"].tolist() == [140.0, 120.0] + config = json.loads(performance.proto.columns) + assert config["total_tokens_per_trial"]["label"] == "Tokens / trial" + for field in ("total_tokens_per_trial", "duration_seconds_per_trial", "cost_usd_per_trial"): + assert config[field]["type_config"]["type"] == "number", field + rows = dashboard_app.load_dashboard_path(path).rows + header = next(csv.reader(io.StringIO(rows_csv(rows, dashboard_app._PERFORMANCE_COLUMNS)))) + assert header.index("total_tokens_per_trial") == header.index("score") + 1 + + def test_dimension_filters_and_condition_retain_baseline_for_comparison(tmp_path: Path) -> None: paths = [ _write_report(tmp_path / "a.json"), diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index 71554cd35..8ed9201d5 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -117,6 +117,38 @@ def test_canonical_missing_attempt_keeps_usage_totals_unknown() -> None: assert "tokens 1/2" in row["coverage"] +def test_per_trial_usage_normalizes_trial_counts() -> None: + per_trial = [] + for count in (2, 4): + report = _report() + agent = report["agents"]["claude-code"] + for field, count_field, arm in ( + ("trials", "num_trials", "with_skill"), + ("trials_baseline", "num_trials_baseline", "without_skill"), + ): + agent[field] = [ + {**copy.deepcopy(agent[field][0]), "entry_id": f"case-{index}", "trial_id": f"case-{index}__trial0"} + for index in range(count) + ] + agent[count_field] = count + agent["conditions"][arm].update(expected_attempts=count, scored_attempts=count) + rows = parse_dashboard_report(report, f"trials-{count}.json").rows + # Totals grow with the trial count; per-trial means do not. + assert [row["total_tokens"] for row in rows] == [150 * count, 120 * count] + per_trial.append([(row["total_tokens_per_trial"], row["duration_seconds_per_trial"]) for row in rows]) + assert per_trial == [[(150.0, 8.0), (120.0, 10.0)]] * 2 + + +def test_per_trial_usage_is_blank_when_any_trial_is_unmeasured() -> None: + report = _repeated_attempts_report(("case-a__trial0", "case-a__trial1")) + report["agents"]["claude-code"]["trials"][1]["tokens"].pop("completion") + with_row, without_row = parse_dashboard_report(report, "report.json").rows + assert with_row["total_tokens"] is None + assert with_row["total_tokens_per_trial"] is None + assert with_row["duration_seconds_per_trial"] == 8.0 + assert without_row["total_tokens_per_trial"] == 120.0 + + @pytest.mark.parametrize("value", [True, -1, 1.5, "1", 10**30]) @pytest.mark.parametrize("field", ["declared", "expected", "both_attempt_counts"]) def test_present_invalid_coverage_counts_never_become_inferred_complete_counts(value: object, field: str) -> None: @@ -623,6 +655,15 @@ def test_native_results_use_real_usage_and_prune_nested_mirrors(tmp_path: Path) assert load_dashboard_path(run / "result.json").rows == load_dashboard_path(run).rows +def test_native_per_trial_usage_uses_retained_measurements(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + rows = load_dashboard_path(run).rows + assert [row["total_tokens_per_trial"] for row in rows] == [210.0, 110.0] + assert [row["duration_seconds_per_trial"] for row in rows] == [10.0, 10.0] + assert [row["cost_usd_per_trial"] for row in rows] == [None, None] + + def _canonical_export(run: Path) -> dict: result = agent_eval_result_from_directory(Path("native-skill"), run, use_llm_judge=False) assert result is not None From 03c831ebe33217f41a8995f5effbf5f3770e94c0 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 01:49:44 -0700 Subject: [PATCH 21/40] fix(dashboard): give a working install command and list the dashboard extra skillevaluator is not published on PyPI, so the pip install command in the missing-extra error and the reports guide could not succeed and invited dependency confusion. Point both at the same uv tool install from GitHub that the installation guide uses, with [all,dashboard] so a reinstall keeps the evaluator extras. List the dashboard extra in the extras table and stop saying [all] installs every extra. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/cli-reference.mdx | 7 ++++--- docs/installation.mdx | 3 ++- docs/reports.mdx | 2 +- src/skillevaluator/reporting/dashboard.py | 7 ++++++- tests/reporting/test_dashboard_cli.py | 4 +++- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/docs/cli-reference.mdx b/docs/cli-reference.mdx index e4d3e25b0..f8d61029f 100644 --- a/docs/cli-reference.mdx +++ b/docs/cli-reference.mdx @@ -504,9 +504,10 @@ skillevaluator compare ./my-skill ## dashboard -Open the optional local tables dashboard. Install `skillevaluator[dashboard]` -first, then pass JSON reports, retained run directories, or directories containing -reports. With no paths, upload JSON files in the browser. +Open the optional local tables dashboard. Install the +[`dashboard` extra](installation.mdx#choosing-extras) first, then pass JSON +reports, retained run directories, or directories containing reports. With no +paths, upload JSON files in the browser. ```bash skillevaluator dashboard reports/run-a.json reports/run-b.json diff --git a/docs/installation.mdx b/docs/installation.mdx index 14729f6a3..b2ce09293 100644 --- a/docs/installation.mdx +++ b/docs/installation.mdx @@ -140,10 +140,11 @@ and environment backends. | `tier3` | Docker, local, and cloud live-agent evaluation through Harbor (pins `harbor==0.24.0` and requires `python-dotenv>=1.2.0`); includes `llm` | | `security` | Bandit and pip-audit | | `all` | `tier2`, `tier3`, and `security` in one bundle | +| `dashboard` | Local Streamlit tables for comparing saved reports and retained runs (`skillevaluator dashboard`); not included in `all` | | `dev` | Build, test, coverage, and formatting tools for contributors | -`[all]` installs every SkillEvaluator extra. External scanner tools, Docker, agent CLIs, and the Harbor extras for managed sandbox backends (such as `harbor[modal]==0.24.0`) stay separate no matter which extra you pick — see [Agents & Sandboxes](agents-and-sandboxes.mdx#where-trials-run). +`[all]` installs the evaluator extras (`tier2`, `tier3`, `security`); add `dashboard` with `[all,dashboard]`. External scanner tools, Docker, agent CLIs, and the Harbor extras for managed sandbox backends (such as `harbor[modal]==0.24.0`) stay separate no matter which extra you pick — see [Agents & Sandboxes](agents-and-sandboxes.mdx#where-trials-run). ## System tools diff --git a/docs/reports.mdx b/docs/reports.mdx index b0c44df6a..4c8a762ea 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -542,7 +542,7 @@ Install the optional Python dashboard and open saved JSON reports or individual retained Tier 3 run directories: ```bash -pip install "skillevaluator[dashboard]" +uv tool install --python 3.13 --reinstall "skillevaluator[all,dashboard] @ git+https://github.com/NVIDIA/SkillEvaluator.git" skillevaluator dashboard reports/run-a.json reports/run-b.json skillevaluator dashboard ./my-skill/evals/results/ # Start with an empty dashboard and upload several JSON reports in the browser: diff --git a/src/skillevaluator/reporting/dashboard.py b/src/skillevaluator/reporting/dashboard.py index 244dd46be..2e2239bef 100644 --- a/src/skillevaluator/reporting/dashboard.py +++ b/src/skillevaluator/reporting/dashboard.py @@ -16,7 +16,12 @@ def launch_dashboard(paths: tuple[Path, ...], *, port: int = 8501, no_browser: bool = False) -> int: """Run Streamlit on loopback with explicit paths and usage telemetry disabled.""" if importlib.util.find_spec("streamlit") is None: - raise click.ClickException('Install the dashboard extra: pip install "skillevaluator[dashboard]"') + raise click.ClickException( + "Install the dashboard extra: uv tool install --python 3.13 --reinstall " + '"skillevaluator[all,dashboard] @ git+https://github.com/NVIDIA/SkillEvaluator.git" ' + "(from a checkout: uv run --extra dashboard skillevaluator dashboard, " + 'or python -m pip install -e ".[dashboard]")' + ) app = Path(__file__).with_name("dashboard_app.py") command = [ sys.executable, diff --git a/tests/reporting/test_dashboard_cli.py b/tests/reporting/test_dashboard_cli.py index 45c21b456..40795913e 100644 --- a/tests/reporting/test_dashboard_cli.py +++ b/tests/reporting/test_dashboard_cli.py @@ -27,7 +27,9 @@ def test_missing_extra_has_actionable_error(monkeypatch) -> None: monkeypatch.setattr(dashboard.importlib.util, "find_spec", lambda _name: None) result = CliRunner().invoke(cli, ["dashboard"]) assert result.exit_code == 1 - assert 'pip install "skillevaluator[dashboard]"' in result.output + assert "skillevaluator[all,dashboard]" in result.output + assert "uv run --extra dashboard" in result.output + assert 'pip install "skillevaluator[dashboard]"' not in result.output def test_launch_uses_loopback_and_literal_absolute_paths(tmp_path: Path, monkeypatch) -> None: From 08a67f8da91ae538a8ab13082799f29f34fc2b24 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:20:49 -0700 Subject: [PATCH 22/40] fix(dashboard): isolate the Streamlit launcher from the caller's directory and prompts The launcher ran python -m streamlit from the caller's directory, so a streamlit.py there ran instead of Streamlit, a project .streamlit/config.toml could reopen CORS, and the reporting package directory shadowed stdlib html. Start Streamlit with -P from a dedicated dashboard_ui directory, restrict WebSocket Host headers to loopback, and pin CORS and XSRF protection. An explicit headless=false made Streamlit ask for an email and exit 255 without a TTY, so headless is now set only for --no-browser and the prompt is off. The file watcher banner and developer toolbar are switched off too. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/reports.mdx | 6 ++ src/skillevaluator/reporting/dashboard.py | 22 +++++- .../reporting/dashboard_ui/__init__.py | 2 + .../dashboard_ui/skillevaluator_dashboard.py | 14 ++++ tests/reporting/test_dashboard_cli.py | 78 ++++++++++++++++--- tests/reporting/test_dashboard_entry.py | 29 +++++++ 6 files changed, 135 insertions(+), 16 deletions(-) create mode 100644 src/skillevaluator/reporting/dashboard_ui/__init__.py create mode 100644 src/skillevaluator/reporting/dashboard_ui/skillevaluator_dashboard.py create mode 100644 tests/reporting/test_dashboard_entry.py diff --git a/docs/reports.mdx b/docs/reports.mdx index 4c8a762ea..a06506c0f 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -550,8 +550,14 @@ skillevaluator dashboard ``` From a checkout, use `uv run --extra dashboard skillevaluator dashboard ...`. +For live reload while developing the dashboard, run +`PYTHONPATH=src uv run --extra dashboard streamlit run src/skillevaluator/reporting/dashboard_ui/skillevaluator_dashboard.py -- PATH`; +`PYTHONPATH=src` lets Streamlit watch the package modules for changes. The server runs at `http://127.0.0.1:8501`; use `--port 8502` for another port, `--no-browser` to suppress opening a browser, and Ctrl+C to stop it. +The dashboard runs from its own package directory, so Streamlit settings or +secrets in your project's `.streamlit/` folder are not applied. It accepts +browser connections only for 127.0.0.1 and localhost. Browser uploads accept up to 16 MB (16,000,000 bytes) per file. Local JSON files accept up to 16 MiB (16,777,216 bytes); larger files produce a notice while other valid reports remain available. diff --git a/src/skillevaluator/reporting/dashboard.py b/src/skillevaluator/reporting/dashboard.py index 2e2239bef..eb1b570e6 100644 --- a/src/skillevaluator/reporting/dashboard.py +++ b/src/skillevaluator/reporting/dashboard.py @@ -6,12 +6,17 @@ from __future__ import annotations import importlib.util +import os import subprocess import sys from pathlib import Path import click +# Streamlit runs from this directory, so the caller's .streamlit/ settings and +# modules cannot replace the dashboard's own. +_APP = Path(__file__).with_name("dashboard_ui") / "skillevaluator_dashboard.py" + def launch_dashboard(paths: tuple[Path, ...], *, port: int = 8501, no_browser: bool = False) -> int: """Run Streamlit on loopback with explicit paths and usage telemetry disabled.""" @@ -22,23 +27,32 @@ def launch_dashboard(paths: tuple[Path, ...], *, port: int = 8501, no_browser: b "(from a checkout: uv run --extra dashboard skillevaluator dashboard, " 'or python -m pip install -e ".[dashboard]")' ) - app = Path(__file__).with_name("dashboard_app.py") + # -P keeps the working directory off sys.path. An explicit headless=false + # would trigger the first-run email prompt and override Streamlit's + # display detection, so the flag is only ever set to true. command = [ sys.executable, + "-P", "-m", "streamlit", "run", - str(app), + str(_APP), "--server.address=127.0.0.1", f"--server.port={port}", "--server.maxUploadSize=16", - f"--server.headless={str(no_browser).lower()}", + "--server.showEmailPrompt=false", + "--server.fileWatcherType=none", + "--server.enableCORS=true", + "--server.enableXsrfProtection=true", + "--client.toolbarMode=viewer", + *(["--server.headless=true"] if no_browser else []), "--browser.gatherUsageStats=false", "--theme.primaryColor=#76b900", "--", *(str(path.resolve()) for path in paths), ] + env = {**os.environ, "STREAMLIT_SERVER_ALLOWED_HOSTS": "127.0.0.1 localhost"} try: - return subprocess.call(command) + return subprocess.call(command, cwd=str(_APP.parent), env=env) except KeyboardInterrupt: return 0 diff --git a/src/skillevaluator/reporting/dashboard_ui/__init__.py b/src/skillevaluator/reporting/dashboard_ui/__init__.py new file mode 100644 index 000000000..52a7a9daf --- /dev/null +++ b/src/skillevaluator/reporting/dashboard_ui/__init__.py @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 diff --git a/src/skillevaluator/reporting/dashboard_ui/skillevaluator_dashboard.py b/src/skillevaluator/reporting/dashboard_ui/skillevaluator_dashboard.py new file mode 100644 index 000000000..2307c8f1c --- /dev/null +++ b/src/skillevaluator/reporting/dashboard_ui/skillevaluator_dashboard.py @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Streamlit entry script for the dashboard. + +Streamlit puts this script's directory first on sys.path, so the directory holds +only this uniquely named file and cannot shadow the standard library or a dependency. +""" + +import sys + +from skillevaluator.reporting.dashboard_app import main + +main(sys.argv[1:]) diff --git a/tests/reporting/test_dashboard_cli.py b/tests/reporting/test_dashboard_cli.py index 40795913e..3a54e6972 100644 --- a/tests/reporting/test_dashboard_cli.py +++ b/tests/reporting/test_dashboard_cli.py @@ -5,15 +5,33 @@ from __future__ import annotations +import importlib.util +import subprocess import sys from pathlib import Path +import pytest from click.testing import CliRunner from skillevaluator.cli import cli from skillevaluator.reporting import dashboard +def _capture_launch(monkeypatch, *args: str): + """Invoke the dashboard command with Streamlit present and the child process faked.""" + calls = [] + monkeypatch.setattr(dashboard.importlib.util, "find_spec", lambda _name: object()) + + def capture(command, **kwargs): + calls.append((command, kwargs)) + return 7 + + monkeypatch.setattr(dashboard.subprocess, "call", capture) + result = CliRunner().invoke(cli, ["dashboard", *args]) + command, kwargs = calls[0] + return result, command, kwargs + + def test_dashboard_help_and_input_validation() -> None: runner = CliRunner() help_result = runner.invoke(cli, ["dashboard", "--help"]) @@ -35,21 +53,57 @@ def test_missing_extra_has_actionable_error(monkeypatch) -> None: def test_launch_uses_loopback_and_literal_absolute_paths(tmp_path: Path, monkeypatch) -> None: report = tmp_path / "report with spaces; literal.json" report.write_text("{}", encoding="utf-8") - commands = [] - monkeypatch.setattr(dashboard.importlib.util, "find_spec", lambda _name: object()) - - def capture(command): - commands.append(command) - return 7 - - monkeypatch.setattr(dashboard.subprocess, "call", capture) - result = CliRunner().invoke(cli, ["dashboard", str(report), "--port", "8517", "--no-browser"]) + result, command, kwargs = _capture_launch(monkeypatch, str(report), "--port", "8517", "--no-browser") assert result.exit_code == 7 - command = commands[0] - assert command[:3] == [sys.executable, "-m", "streamlit"] + assert command[:4] == [sys.executable, "-P", "-m", "streamlit"] + app = Path(command[command.index("run") + 1]) + assert app.name == "skillevaluator_dashboard.py" + assert app.parent.name == "dashboard_ui" + assert Path(kwargs["cwd"]) == app.parent + assert kwargs["env"]["STREAMLIT_SERVER_ALLOWED_HOSTS"] == "127.0.0.1 localhost" assert "--server.address=127.0.0.1" in command assert "--server.port=8517" in command assert "--server.maxUploadSize=16" in command - assert "--server.headless=true" in command + for flag in ( + "--server.showEmailPrompt=false", + "--server.fileWatcherType=none", + "--server.enableCORS=true", + "--server.enableXsrfProtection=true", + "--client.toolbarMode=viewer", + "--server.headless=true", + ): + assert flag in command assert "--browser.gatherUsageStats=false" in command assert command[-2:] == ["--", str(report.resolve())] + + +def test_default_launch_does_not_force_headless(monkeypatch) -> None: + # An explicit headless=false makes Streamlit prompt for an email and exit without a TTY. + _result, command, _kwargs = _capture_launch(monkeypatch) + assert not any(arg.startswith("--server.headless") for arg in command) + + +def test_streamlit_script_directory_cannot_shadow_modules() -> None: + # Streamlit puts the script directory first on sys.path in the server. + app = dashboard._APP + assert app.is_file() + stems = {path.stem for path in app.parent.glob("*.py")} + assert stems <= {"__init__", app.stem} + assert not stems & set(sys.stdlib_module_names) + assert importlib.util.find_spec(app.stem) is None + + +def test_streamlit_is_not_shadowed_by_cwd(tmp_path: Path, monkeypatch) -> None: + pytest.importorskip("streamlit") + _result, command, _kwargs = _capture_launch(monkeypatch) + (tmp_path / "streamlit.py").write_text("raise SystemExit(3)\n", encoding="utf-8") + completed = subprocess.run( + [*command[:4], "version"], + cwd=tmp_path, + capture_output=True, + text=True, + encoding="utf-8", + timeout=60, + ) + assert completed.returncode == 0, completed.stderr + assert "Streamlit" in completed.stdout diff --git a/tests/reporting/test_dashboard_entry.py b/tests/reporting/test_dashboard_entry.py new file mode 100644 index 000000000..547a5152b --- /dev/null +++ b/tests/reporting/test_dashboard_entry.py @@ -0,0 +1,29 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Run the packaged Streamlit entry script that the dashboard launcher starts.""" + +from __future__ import annotations + +import sys + +import pytest + +pytest.importorskip("streamlit") +# st.dataframe otherwise imports these inside AppTest's timed script thread. +pytest.importorskip("pandas") +pytest.importorskip("pyarrow") +from streamlit.testing.v1 import AppTest + +from skillevaluator.reporting import dashboard + +# A ceiling for cold imports under xdist and coverage; passing runs finish far sooner. +_APP_TIMEOUT_SECONDS = 60 + + +def test_entry_script_runs_dashboard_main(monkeypatch) -> None: + # AppTest runs the script in this process, so it would otherwise read pytest's argv. + monkeypatch.setattr(sys, "argv", [str(dashboard._APP)]) + app = AppTest.from_file(str(dashboard._APP), default_timeout=_APP_TIMEOUT_SECONDS).run() + assert not app.exception + assert [message.value for message in app.info] == ["Upload JSON evaluation reports to start comparing results."] From bef6ea0a1b2f64428376df7d611a39a2daca79b4 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:22:33 -0700 Subject: [PATCH 23/40] feat(dashboard): use the next free port unless --port is given The launcher always passed --server.port=8501. Streamlit treats a port on the command line as manually set and exits with status 1 when it is busy, so a second dashboard or any other Streamlit app on 8501 made the plain command fail. Pass the port only when the user chose one, so Streamlit moves to the next free port otherwise, and print a hint when an explicit port fails. The --port option also gains help text. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/cli-reference.mdx | 2 +- docs/reports.mdx | 5 +++-- src/skillevaluator/cli.py | 9 +++++++-- src/skillevaluator/reporting/dashboard.py | 13 ++++++++++--- tests/golden/cli_surface.json | 1 - tests/reporting/test_dashboard_cli.py | 17 +++++++++++++++-- 6 files changed, 36 insertions(+), 11 deletions(-) diff --git a/docs/cli-reference.mdx b/docs/cli-reference.mdx index f8d61029f..fda947712 100644 --- a/docs/cli-reference.mdx +++ b/docs/cli-reference.mdx @@ -516,7 +516,7 @@ skillevaluator dashboard --no-browser --port 8502 | Option | Default | Description | | --- | --- | --- | -| `--port` | `8501` | Local server port, from 1 through 65535. | +| `--port` | `8501`, or the next free port | Local port on 127.0.0.1, from 1 through 65535. Pass it to require a specific port; the command fails if that port is busy. | | `--no-browser` | off | Start the server without opening a browser. | The server listens on `127.0.0.1`; Ctrl+C stops it. See the diff --git a/docs/reports.mdx b/docs/reports.mdx index a06506c0f..cf1d0603f 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -553,8 +553,9 @@ From a checkout, use `uv run --extra dashboard skillevaluator dashboard ...`. For live reload while developing the dashboard, run `PYTHONPATH=src uv run --extra dashboard streamlit run src/skillevaluator/reporting/dashboard_ui/skillevaluator_dashboard.py -- PATH`; `PYTHONPATH=src` lets Streamlit watch the package modules for changes. -The server runs at `http://127.0.0.1:8501`; use `--port 8502` for another port, -`--no-browser` to suppress opening a browser, and Ctrl+C to stop it. +The server runs at `http://127.0.0.1:8501`, or the next free port when 8501 is +busy; pass `--port 8502` to require a specific port. Use `--no-browser` to +suppress opening a browser, and Ctrl+C to stop it. The dashboard runs from its own package directory, so Streamlit settings or secrets in your project's `.streamlit/` folder are not applied. It accepts browser connections only for 127.0.0.1 and localhost. diff --git a/src/skillevaluator/cli.py b/src/skillevaluator/cli.py index ecae82626..1b3f7cae9 100644 --- a/src/skillevaluator/cli.py +++ b/src/skillevaluator/cli.py @@ -3056,9 +3056,14 @@ def models_command(limit: int, as_json: bool) -> None: @cli.command("dashboard") @click.argument("paths", nargs=-1, type=click.Path(exists=True, path_type=Path)) -@click.option("--port", type=click.IntRange(1, 65535), default=8501, show_default=True) +@click.option( + "--port", + type=click.IntRange(1, 65535), + default=None, + help="Local port on 127.0.0.1 (default 8501, or the next free port).", +) @click.option("--no-browser", is_flag=True, help="Start the server without opening a browser.") -def dashboard_command(paths: tuple[Path, ...], port: int, no_browser: bool) -> None: +def dashboard_command(paths: tuple[Path, ...], port: int | None, no_browser: bool) -> None: """Compare saved JSON reports or retained Tier 3 run directories in tables. Install skillevaluator[dashboard] first. With no PATHS, upload JSON reports diff --git a/src/skillevaluator/reporting/dashboard.py b/src/skillevaluator/reporting/dashboard.py index eb1b570e6..65847dc7f 100644 --- a/src/skillevaluator/reporting/dashboard.py +++ b/src/skillevaluator/reporting/dashboard.py @@ -18,7 +18,7 @@ _APP = Path(__file__).with_name("dashboard_ui") / "skillevaluator_dashboard.py" -def launch_dashboard(paths: tuple[Path, ...], *, port: int = 8501, no_browser: bool = False) -> int: +def launch_dashboard(paths: tuple[Path, ...], *, port: int | None = None, no_browser: bool = False) -> int: """Run Streamlit on loopback with explicit paths and usage telemetry disabled.""" if importlib.util.find_spec("streamlit") is None: raise click.ClickException( @@ -38,7 +38,9 @@ def launch_dashboard(paths: tuple[Path, ...], *, port: int = 8501, no_browser: b "run", str(_APP), "--server.address=127.0.0.1", - f"--server.port={port}", + # A port on the command line counts as manually set, and Streamlit then + # exits instead of moving to the next free port, so pass only a chosen one. + *([f"--server.port={port}"] if port is not None else []), "--server.maxUploadSize=16", "--server.showEmailPrompt=false", "--server.fileWatcherType=none", @@ -53,6 +55,11 @@ def launch_dashboard(paths: tuple[Path, ...], *, port: int = 8501, no_browser: b ] env = {**os.environ, "STREAMLIT_SERVER_ALLOWED_HOSTS": "127.0.0.1 localhost"} try: - return subprocess.call(command, cwd=str(_APP.parent), env=env) + code = subprocess.call(command, cwd=str(_APP.parent), env=env) except KeyboardInterrupt: return 0 + if port is not None and code > 0: + click.echo( + f"Streamlit exited with status {code}. If port {port} is in use, choose another with --port.", err=True + ) + return code diff --git a/tests/golden/cli_surface.json b/tests/golden/cli_surface.json index 3d8551705..36f93bf9e 100644 --- a/tests/golden/cli_surface.json +++ b/tests/golden/cli_surface.json @@ -184,7 +184,6 @@ "type": "path" }, { - "default": "8501", "name": "port", "opts": [ "--port" diff --git a/tests/reporting/test_dashboard_cli.py b/tests/reporting/test_dashboard_cli.py index 3a54e6972..3f0dfcfbc 100644 --- a/tests/reporting/test_dashboard_cli.py +++ b/tests/reporting/test_dashboard_cli.py @@ -17,14 +17,14 @@ from skillevaluator.reporting import dashboard -def _capture_launch(monkeypatch, *args: str): +def _capture_launch(monkeypatch, *args: str, returncode: int = 7): """Invoke the dashboard command with Streamlit present and the child process faked.""" calls = [] monkeypatch.setattr(dashboard.importlib.util, "find_spec", lambda _name: object()) def capture(command, **kwargs): calls.append((command, kwargs)) - return 7 + return returncode monkeypatch.setattr(dashboard.subprocess, "call", capture) result = CliRunner().invoke(cli, ["dashboard", *args]) @@ -37,6 +37,7 @@ def test_dashboard_help_and_input_validation() -> None: help_result = runner.invoke(cli, ["dashboard", "--help"]) assert help_result.exit_code == 0 assert "retained Tier 3" in help_result.output + assert "next free port" in " ".join(help_result.output.split()) assert runner.invoke(cli, ["dashboard", "--port", "0"]).exit_code == 2 assert runner.invoke(cli, ["dashboard", "missing-report-170.json"]).exit_code == 2 @@ -77,6 +78,18 @@ def test_launch_uses_loopback_and_literal_absolute_paths(tmp_path: Path, monkeyp assert command[-2:] == ["--", str(report.resolve())] +def test_default_launch_lets_streamlit_choose_port(monkeypatch) -> None: + # Streamlit moves to the next free port only when the port was not set explicitly. + _result, command, _kwargs = _capture_launch(monkeypatch) + assert not any(arg.startswith("--server.port") for arg in command) + + +def test_explicit_port_failure_has_hint(monkeypatch) -> None: + result, _command, _kwargs = _capture_launch(monkeypatch, "--port", "8517", returncode=1) + assert result.exit_code == 1 + assert "choose another with --port" in result.output + + def test_default_launch_does_not_force_headless(monkeypatch) -> None: # An explicit headless=false makes Streamlit prompt for an email and exit without a TTY. _result, command, _kwargs = _capture_launch(monkeypatch) From d48982859330c9e94228552861fe8e646605a307 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:25:59 -0700 Subject: [PATCH 24/40] fix(dashboard): forward SIGTERM so the Streamlit server is not orphaned Ctrl+C reaches the whole process group, but a SIGTERM sent only to the launcher, as an IDE stop button, a process supervisor, or kill PID does, killed the launcher and left Streamlit running and holding the port. Run Streamlit with Popen and forward SIGTERM and SIGHUP to it while waiting, so the launcher stays alive to report the exit status and the port hint. After Ctrl+C the launcher waits up to 10 seconds for Streamlit to stop before terminating it. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- src/skillevaluator/reporting/dashboard.py | 23 +++++- tests/reporting/test_dashboard_cli.py | 89 +++++++++++++++++++---- 2 files changed, 95 insertions(+), 17 deletions(-) diff --git a/src/skillevaluator/reporting/dashboard.py b/src/skillevaluator/reporting/dashboard.py index 65847dc7f..af3100294 100644 --- a/src/skillevaluator/reporting/dashboard.py +++ b/src/skillevaluator/reporting/dashboard.py @@ -7,9 +7,12 @@ import importlib.util import os +import signal import subprocess import sys +import threading from pathlib import Path +from typing import Any import click @@ -54,10 +57,26 @@ def launch_dashboard(paths: tuple[Path, ...], *, port: int | None = None, no_bro *(str(path.resolve()) for path in paths), ] env = {**os.environ, "STREAMLIT_SERVER_ALLOWED_HOSTS": "127.0.0.1 localhost"} + proc = subprocess.Popen(command, cwd=str(_APP.parent), env=env) + # Ctrl+C reaches the whole process group, but a SIGTERM or SIGHUP sent only + # to this process would otherwise leave Streamlit running on the port. + previous: dict[int, Any] = {} + if threading.current_thread() is threading.main_thread(): + for sig in (signal.SIGTERM, getattr(signal, "SIGHUP", None)): + if sig is not None: + previous[sig] = signal.signal(sig, lambda signum, _frame: proc.send_signal(signum)) try: - code = subprocess.call(command, cwd=str(_APP.parent), env=env) + code = proc.wait() except KeyboardInterrupt: - return 0 + try: + proc.wait(timeout=10) + except subprocess.TimeoutExpired: + proc.terminate() + proc.wait() + code = 0 + finally: + for sig, handler in previous.items(): + signal.signal(sig, handler) if port is not None and code > 0: click.echo( f"Streamlit exited with status {code}. If port {port} is in use, choose another with --port.", err=True diff --git a/tests/reporting/test_dashboard_cli.py b/tests/reporting/test_dashboard_cli.py index 3f0dfcfbc..c210661c8 100644 --- a/tests/reporting/test_dashboard_cli.py +++ b/tests/reporting/test_dashboard_cli.py @@ -6,6 +6,7 @@ from __future__ import annotations import importlib.util +import signal import subprocess import sys from pathlib import Path @@ -17,19 +18,41 @@ from skillevaluator.reporting import dashboard -def _capture_launch(monkeypatch, *args: str, returncode: int = 7): +class FakePopen: + """Stand in for the Streamlit child: record the launch, waits, and forwarded signals.""" + + def __init__(self, command: list[str], **kwargs) -> None: + self.command = command + self.kwargs = kwargs + self.sent: list[int] = [] + self.wait_timeouts: list[float | None] = [] + + def wait(self, timeout: float | None = None) -> int: + self.wait_timeouts.append(timeout) + return self.exit_code() + + def exit_code(self) -> int: + return 7 + + def send_signal(self, signum: int) -> None: + self.sent.append(signum) + + def terminate(self) -> None: + self.send_signal(signal.SIGTERM) + + +def _capture_launch(monkeypatch, *args: str, popen: type[FakePopen] = FakePopen): """Invoke the dashboard command with Streamlit present and the child process faked.""" - calls = [] + launched: list[FakePopen] = [] monkeypatch.setattr(dashboard.importlib.util, "find_spec", lambda _name: object()) - def capture(command, **kwargs): - calls.append((command, kwargs)) - return returncode + def start(command, **kwargs): + launched.append(popen(command, **kwargs)) + return launched[-1] - monkeypatch.setattr(dashboard.subprocess, "call", capture) + monkeypatch.setattr(dashboard.subprocess, "Popen", start) result = CliRunner().invoke(cli, ["dashboard", *args]) - command, kwargs = calls[0] - return result, command, kwargs + return result, launched[0] def test_dashboard_help_and_input_validation() -> None: @@ -54,8 +77,9 @@ def test_missing_extra_has_actionable_error(monkeypatch) -> None: def test_launch_uses_loopback_and_literal_absolute_paths(tmp_path: Path, monkeypatch) -> None: report = tmp_path / "report with spaces; literal.json" report.write_text("{}", encoding="utf-8") - result, command, kwargs = _capture_launch(monkeypatch, str(report), "--port", "8517", "--no-browser") + result, fake = _capture_launch(monkeypatch, str(report), "--port", "8517", "--no-browser") assert result.exit_code == 7 + command, kwargs = fake.command, fake.kwargs assert command[:4] == [sys.executable, "-P", "-m", "streamlit"] app = Path(command[command.index("run") + 1]) assert app.name == "skillevaluator_dashboard.py" @@ -80,20 +104,52 @@ def test_launch_uses_loopback_and_literal_absolute_paths(tmp_path: Path, monkeyp def test_default_launch_lets_streamlit_choose_port(monkeypatch) -> None: # Streamlit moves to the next free port only when the port was not set explicitly. - _result, command, _kwargs = _capture_launch(monkeypatch) - assert not any(arg.startswith("--server.port") for arg in command) + _result, fake = _capture_launch(monkeypatch) + assert not any(arg.startswith("--server.port") for arg in fake.command) def test_explicit_port_failure_has_hint(monkeypatch) -> None: - result, _command, _kwargs = _capture_launch(monkeypatch, "--port", "8517", returncode=1) + class BusyPortPopen(FakePopen): + def exit_code(self) -> int: + return 1 + + result, _fake = _capture_launch(monkeypatch, "--port", "8517", popen=BusyPortPopen) assert result.exit_code == 1 assert "choose another with --port" in result.output def test_default_launch_does_not_force_headless(monkeypatch) -> None: # An explicit headless=false makes Streamlit prompt for an email and exit without a TTY. - _result, command, _kwargs = _capture_launch(monkeypatch) - assert not any(arg.startswith("--server.headless") for arg in command) + _result, fake = _capture_launch(monkeypatch) + assert not any(arg.startswith("--server.headless") for arg in fake.command) + + +def test_sigterm_is_forwarded_to_streamlit(monkeypatch) -> None: + original = signal.getsignal(signal.SIGTERM) + + class TerminatedPopen(FakePopen): + def exit_code(self) -> int: + # A process manager sends SIGTERM to the launcher alone. + signal.getsignal(signal.SIGTERM)(signal.SIGTERM, None) + return -15 + + _result, fake = _capture_launch(monkeypatch, popen=TerminatedPopen) + assert fake.sent == [signal.SIGTERM] + assert signal.getsignal(signal.SIGTERM) is original + + +def test_ctrl_c_returns_zero(monkeypatch) -> None: + class InterruptedPopen(FakePopen): + def exit_code(self) -> int: + if len(self.wait_timeouts) == 1: + raise KeyboardInterrupt + return 0 + + result, fake = _capture_launch(monkeypatch, popen=InterruptedPopen) + assert result.exit_code == 0 + # The launcher waits for Streamlit to finish its own Ctrl+C shutdown. + assert fake.wait_timeouts == [None, 10] + assert fake.sent == [] def test_streamlit_script_directory_cannot_shadow_modules() -> None: @@ -108,7 +164,10 @@ def test_streamlit_script_directory_cannot_shadow_modules() -> None: def test_streamlit_is_not_shadowed_by_cwd(tmp_path: Path, monkeypatch) -> None: pytest.importorskip("streamlit") - _result, command, _kwargs = _capture_launch(monkeypatch) + _result, fake = _capture_launch(monkeypatch) + command = fake.command + # Restore the real subprocess.Popen before starting Python below. + monkeypatch.undo() (tmp_path / "streamlit.py").write_text("raise SystemExit(3)\n", encoding="utf-8") completed = subprocess.run( [*command[:4], "version"], From d44ff8115f9a4bd184b2903f32ddbf5342ae3971 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:27:41 -0700 Subject: [PATCH 25/40] docs(dashboard): align reports guide and CHANGELOG with recorded data The Unreleased Fixed entry for omitting unmeasured token usage describes behaviour main shipped in v0.5.0 (#83), and this PR changes no producer; the second Fixed entry describes the dashboard, which is itself new. Fold both into one Added entry that names what the dashboard compares, where time and cost come from, and how inputs are cached. In the reports guide, describe a performance row and the pairing rule precisely (same report and agent, dataset digest and attempt policy), drop the advice to regenerate canonical JSON (no command does that), describe multi-step trials as v0.5.0 canonical JSON writes them, document the agent_result token fallback, and list the accepted harness_features forms and their precedence. Two tests pin the precedence and the accepted forms. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- CHANGELOG.md | 14 +++++---- docs/reports.mdx | 39 ++++++++++++++----------- tests/reporting/test_dashboard_data.py | 40 ++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4619f063..de22811e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,14 @@ All notable changes to SkillEvaluator are documented in this file. ### Added - Optional `skillevaluator dashboard` tables for comparing saved Tier 3 reports - and retained runs across skills, models, harnesses, and skill conditions, - with paired token, agent runtime, and recorded USD cost differences. + and retained runs across skills, models, harnesses, recorded harness + features, and skill conditions. Paired with/without differences cover score, + pass@k, tokens, and agent execution time, plus USD cost when retained runs + record it, with per-trial means alongside totals. Comparisons require + matching complete trial coverage (repeated attempts pair by case, as in the + HTML report) and name the reason when a pair is not comparable. Inputs are + read once and reused between interactions (**Reload reports** re-reads them); + browser uploads are limited to 16 MB. Install it with the `dashboard` extra. - Tier 3 support for Harbor GKE execution mode (`--env-mode gke`) and `--ek` argument forwarding. API keys, bearer tokens, and passwords passed in `--ek` keys or values are rejected to keep credentials out of process listings, while @@ -305,10 +311,6 @@ All notable changes to SkillEvaluator are documented in this file. ### Fixed -- Omit unmeasured Tier 3 token usage from canonical JSON exports instead of - reporting it as zero. -- Keep dashboard comparisons unavailable for contradictory trial identities or - invalid coverage counts, and enforce the documented 16 MB browser upload limit. - Report non-string YAML keys as validation errors in skills, rules, workflows, and plugin manifests instead of raising a `TypeError`, including frontmatter `metadata` keys. Show boolean, null, and date keys in a readable YAML form. diff --git a/docs/reports.mdx b/docs/reports.mdx index cf1d0603f..d0f86fde4 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -567,14 +567,16 @@ Filter the sortable tables by skill, model, harness, recorded harness features, condition, and execution status. The status and condition filters narrow the performance table only, so comparisons keep both arms; the other filters also remove arms from comparisons. Download the visible performance or comparison -rows as CSV. Each performance row represents one run, harness, and condition. +rows as CSV. Each performance row is one run, agent (harness and model), +recorded feature configuration, and condition. Per-trial columns are means over the row's measured trials and stay blank when any trial is unmeasured. They help compare rows with different trial counts, but runs on different datasets are still not like-for-like. The comparison table calculates **with skill minus without skill**, and percent change relative to without skill. A negative usage difference means less usage; a positive score difference means higher performance. Comparisons stay within -the same run and require successful conditions with matching trial coverage. +the same report and agent and require successful conditions with matching trial +coverage, the same dataset digest, and the same attempt policy. When a pair's differences stay blank, the **Comparison reason** column says why. Repeated attempts pair by case, as in the HTML report: each arm must record the same number of attempts for every case, and each attempt must have its own @@ -598,19 +600,19 @@ timezone are treated as unavailable, as in the HTML report's [measured agent resources](#measured-agent-resources). Agent time excludes environment setup and verification. Canonical JSON never records USD cost; open the retained run directory to show Harbor's recorded `agent_result.cost_usd` and -multi-step totals. -Some older exports encoded missing token counters as zero. Open their retained -run directories to recover recorded counters, or regenerate the canonical JSON -with this version, which omits unmeasured token usage instead of recording zero. +multi-step totals. For retained runs whose trajectory lacks token totals, the +dashboard falls back to Harbor's `agent_result` token counters. +Some exports written before v0.5.0 encoded missing token counters as zero; open +their retained run directories to recover recorded counters. Cached tokens are shown separately and are not added again to prompt plus completion tokens. No pricing estimates or new agent evaluations are performed. Adverse conditions and harness features are displayed when explicitly recorded; the dashboard does not run these experiments. -Canonical JSON can omit resource ownership for multi-step trials. When several -reward rows share one physical trial, the dashboard keeps their usage totals -unavailable and shows a notice. Open the retained run directory to recover -totals from authoritative step results. +Since v0.5.0, canonical JSON collapses multi-step trials without per-trial token +or time totals, so they show as unmeasured. Older exports that repeat a trial ID +across reward rows show an ambiguity notice. Open the retained run directory to +recover totals from authoritative step results. ### Recorded harness features @@ -625,17 +627,20 @@ condition can include: } ``` -For retained runs, the dashboard also reads this metadata from `run_config.json` -(at the root or within the agent configuration) and each condition's -`summary.json`. An empty feature list records that no features were enabled; -an absent field is displayed as **unknown**. Differing recorded models or feature -configurations are kept separate when pairing conditions. +`harness_features` can be a list of strings, a non-empty string, or a JSON +object. For canonical JSON the condition's value wins over the agent's, which +wins over the report's. For retained runs the order is the condition's +`summary.json`, then the agent entry in `run_config.json`, then the root of +`run_config.json`. An empty feature list records that no features were enabled +and is shown as **none (recorded)**; an absent field is displayed as +**unknown**. Differing recorded models or feature configurations are kept +separate when pairing conditions. An explicitly imported adverse condition uses `conditions.adverse`, `trials_adverse`, `num_trials_adverse`, and `adverse` for its score in the same agent payload. It appears in the performance table; usage differences are -calculated for with/without pairs only. Existing evaluator runs do not create -adverse trials through the dashboard. +calculated for with/without pairs only. Adverse conditions are import-only +metadata: no evaluator command produces them, and the dashboard does not run them. ## Machine-readable contract diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index 8ed9201d5..0f2038b9d 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -1087,3 +1087,43 @@ def test_native_duplicate_reward_rows_require_authoritative_step_scope(tmp_path: assert data.rows[0]["total_tokens"] is None assert data.rows[0]["duration_seconds"] is None assert any("resource ownership is ambiguous" in warning for warning in data.warnings) + + +def test_retained_feature_metadata_precedence_summary_over_agent_over_root(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + (run / "run_config.json").write_text( + json.dumps( + { + "dashboard_metadata": {"harness_features": ["root"]}, + "agents": { + "opencode": { + "agent": "opencode", + "model": "m", + "dashboard_metadata": {"harness_features": ["agent"]}, + } + }, + } + ), + encoding="utf-8", + ) + summary_path = run / "opencode" / "without-skill" / "summary.json" + summary = json.loads(summary_path.read_text(encoding="utf-8")) + summary["dashboard_metadata"] = {"harness_features": ["summary"]} + summary_path.write_text(json.dumps(summary), encoding="utf-8") + + rows = {row["condition"]: row for row in load_dashboard_path(run).rows} + + assert rows["with_skill"]["features"] == "agent" + assert rows["without_skill"]["features"] == "summary" + assert all(item["comparison_status"] == "missing condition" for item in comparison_rows(list(rows.values()))) + + +def test_empty_feature_list_and_string_and_mapping_forms() -> None: + labels = [] + for value in ([], "rules on", {"memory": False, "rules": True}): + report = _report() + report["dashboard_metadata"] = {"harness_features": value} + labels.append(parse_dashboard_report(report, "r.json").rows[0]["features"]) + + assert labels == ["none (recorded)", "rules on", '{"memory": false, "rules": true}'] From e1d68e63c3cf5f82745ec19104a5125890e046f9 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:50:01 -0700 Subject: [PATCH 26/40] docs(dashboard): describe diagnostic truncation and per-trial means accurately The reports guide said every loader truncation other than an oversized trajectory blocks comparisons, but truncation limited to diagnostic details leaves pairs comparable with a notice, as a test already pins. The CHANGELOG entry placed per-trial means among the paired differences; they appear only in the performance table. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- CHANGELOG.md | 11 ++++++----- docs/reports.mdx | 7 +++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de22811e2..da09de8ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,11 +10,12 @@ All notable changes to SkillEvaluator are documented in this file. and retained runs across skills, models, harnesses, recorded harness features, and skill conditions. Paired with/without differences cover score, pass@k, tokens, and agent execution time, plus USD cost when retained runs - record it, with per-trial means alongside totals. Comparisons require - matching complete trial coverage (repeated attempts pair by case, as in the - HTML report) and name the reason when a pair is not comparable. Inputs are - read once and reused between interactions (**Reload reports** re-reads them); - browser uploads are limited to 16 MB. Install it with the `dashboard` extra. + record it; the performance table also shows per-trial means alongside + totals. Comparisons require matching complete trial coverage (repeated + attempts pair by case, as in the HTML report) and name the reason when a + pair is not comparable. Inputs are read once and reused between + interactions (**Reload reports** re-reads them); browser uploads are limited + to 16 MB. Install it with the `dashboard` extra. - Tier 3 support for Harbor GKE execution mode (`--env-mode gke`) and `--ek` argument forwarding. API keys, bearer tokens, and passwords passed in `--ek` keys or values are rejected to keep credentials out of process listings, while diff --git a/docs/reports.mdx b/docs/reports.mdx index d0f86fde4..d9e592c4d 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -581,8 +581,11 @@ When a pair's differences stay blank, the **Comparison reason** column says why. Repeated attempts pair by case, as in the HTML report: each arm must record the same number of attempts for every case, and each attempt must have its own trial ID. A trajectory above the report loader's size bound leaves that trial's -token counts unavailable in canonical JSON but does not block score comparisons; -any other loader truncation keeps comparisons unavailable. +token counts unavailable in canonical JSON but does not block score comparisons. +Truncation limited to diagnostic details, such as evidence, raw reward fields, +or non-best agent details, also leaves comparisons available, with a notice. +Truncation that drops trials or other trial artifacts, or that is not +explained, keeps comparisons unavailable. The dashboard reads each input once and reuses it while you filter or switch views. Rewriting a JSON file passed on the command line, or adding an entry From af3aa73b6b4d10819c59318aa54d6d402947bc41 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:55:00 -0700 Subject: [PATCH 27/40] fix(dashboard): count a canonical row's missing trials once in usage coverage When a canonical condition listed fewer trials than num_trials, the usage coverage denominator added the shortfall on top of the declared count, so 9 of 10 trials read "tokens 9/11". Trials missing from the declared count are now counted once; totals still stay unavailable until every trial is measured. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- .../reporting/dashboard_data.py | 3 ++- tests/reporting/test_dashboard_data.py | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index ac43e3600..4a6fb9f77 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -382,7 +382,8 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: else [ {} if str(trial.get("trial_id") or "") in ambiguous_ids else _usage(trial) for trial in trials ], - expected=declared + max(0, row["_expected_usage_trials"] - logical_count), + # Trials missing from the declared count are already part of it. + expected=declared + max(0, row["_expected_usage_trials"] - max(logical_count, declared)), ) output.rows.append(row) if not output.rows and not output.warnings: diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index 0f2038b9d..008d5f452 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -117,6 +117,26 @@ def test_canonical_missing_attempt_keeps_usage_totals_unknown() -> None: assert "tokens 1/2" in row["coverage"] +def test_canonical_missing_trial_counts_each_declared_trial_once() -> None: + report = _report() + agent = report["agents"]["claude-code"] + agent["num_trials"] = 10 + agent["conditions"]["with_skill"].update(expected_attempts=10, scored_attempts=10) + agent["trials"] = [ + {**copy.deepcopy(agent["trials"][0]), "entry_id": f"case-{index}", "trial_id": f"case-{index}__trial0"} + for index in range(9) + ] + row = parse_dashboard_report(report, "report.json").rows[0] + assert row["total_tokens"] is None + assert "tokens 9/10" in row["coverage"] + # Without case identities the shortfall still keeps totals unknown. + for trial in agent["trials"]: + trial.pop("entry_id") + row = parse_dashboard_report(report, "report.json").rows[0] + assert row["total_tokens"] is None + assert "tokens 9/10" in row["coverage"] + + def test_per_trial_usage_normalizes_trial_counts() -> None: per_trial = [] for count in (2, 4): From ace27f6a0e0a90e6488861ef827cc1d3bf5954c3 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:57:35 -0700 Subject: [PATCH 28/40] fix(dashboard): keep non-best agents' trials when loading large retained runs Retained runs were parsed through the canonical builder with its 2 MiB embedded-report budget, so a large multi-agent run lost every non-best agent's trials and showed "0 trials" with no score. The builder now takes enforce_embedded_size (default True for every other caller), and the dashboard turns it off because it never embeds the payload; loader truncation is still recorded. Canonical JSON that was pruned this way still fails closed, but the row now shows the declared trial count and the comparison reason says the trial details were pruned and to load the retained run directory. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- src/skillevaluator/evaluation/tier3_report.py | 20 +++++-- .../reporting/dashboard_data.py | 23 +++++++- tests/reporting/test_dashboard_data.py | 52 +++++++++++++++++++ 3 files changed, 88 insertions(+), 7 deletions(-) diff --git a/src/skillevaluator/evaluation/tier3_report.py b/src/skillevaluator/evaluation/tier3_report.py index 4121a5972..f1267fcda 100644 --- a/src/skillevaluator/evaluation/tier3_report.py +++ b/src/skillevaluator/evaluation/tier3_report.py @@ -461,8 +461,13 @@ def agent_eval_result_from_directory( evaluator_version: str | None = None, evaluated_source: dict[str, Any] | None = None, use_llm_judge: bool = True, + enforce_embedded_size: bool = True, ) -> ValidationResult | None: - """Build the canonical ``AGENT_EVAL`` result for one explicit Harbor run.""" + """Build the canonical ``AGENT_EVAL`` result for one explicit Harbor run. + + Read-only consumers that never embed the payload pass + ``enforce_embedded_size=False`` to keep every agent's trial details. + """ # Imported lazily so base-only Tier 1 workflows do not load Tier 3 helpers. from skillevaluator.tier3.harbor.report_data import ( load_agent_data, @@ -511,6 +516,7 @@ def agent_eval_result_from_directory( publication_target_conflict=run_truth.get("publication_target_conflict"), evaluated_source=evaluated_source, use_llm_judge=use_llm_judge, + enforce_embedded_size=enforce_embedded_size, ) return _validation_result_from_payload(payload) @@ -621,6 +627,7 @@ def build_agent_eval_payload( publication_target_conflict: str | None = None, evaluated_source: dict[str, Any] | None = None, use_llm_judge: bool = True, + enforce_embedded_size: bool = True, ) -> dict[str, Any] | None: """Assemble the canonical Tier 3 ``agent_eval`` payload from loaded agent data. @@ -633,7 +640,8 @@ def build_agent_eval_payload( ``trials`` + ``pass_at_k``) feeds the Trials tab, deterministic + LLM ``conclusions`` / ``recommendations`` / ``suggestions`` feed the Insights tab, and ``provenance`` (raw evaluators, raw lift, raw trial rewards) feeds the - Diagnostics tab. + Diagnostics tab. ``enforce_embedded_size=False`` skips the embedded-report + size pruning; loader truncation is still recorded in ``report_truncation``. """ from skillevaluator.tier3.harbor.report_data import ( build_dataset_snapshot, @@ -920,7 +928,7 @@ def build_agent_eval_payload( evidence_links, ) payload = _sanitize_json_numbers(payload) - _enforce_report_payload_budget(payload, report_budget) + _enforce_report_payload_budget(payload, report_budget, enforce_size=enforce_embedded_size) return payload @@ -1188,7 +1196,9 @@ def _prune_pass_at_k_pairing_diagnostics(payload: dict[str, Any], report_budget: report_budget.omit("unpaired_case_ids", omitted) -def _enforce_report_payload_budget(payload: dict[str, Any], report_budget: _ReportBudget) -> None: +def _enforce_report_payload_budget( + payload: dict[str, Any], report_budget: _ReportBudget, *, enforce_size: bool = True +) -> None: """Keep the complete self-contained payload within a hard serialized budget. Cardinality limits normally keep the payload comfortably below the cap. The @@ -1207,7 +1217,7 @@ def refresh_signal() -> None: # best-agent and top-level projections. _prune_pass_at_k_pairing_diagnostics(payload, report_budget) refresh_signal() - if _serialized_payload_size(payload) <= _MAX_EMBEDDED_REPORT_BYTES: + if not enforce_size or _serialized_payload_size(payload) <= _MAX_EMBEDDED_REPORT_BYTES: return provenance = payload.get("provenance") diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index 4a6fb9f77..2b508837e 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -282,6 +282,9 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: run_id = str(report.get("evaluated_at") or summary.get("evaluated_at") or "unknown") truncation = _dict(report.get("report_truncation")) or _dict(report.get("truncation")) coverage_truncated = _trial_coverage_truncated(truncation) + non_best_pruned = bool(truncation.get("truncated")) and "non_best_agent_details" in _dict( + truncation.get("omitted") + ) if truncation.get("truncated"): message = ( "trial data may be truncated; comparisons are unavailable." @@ -294,6 +297,15 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: if not agent: continue conditions = _dict(agent.get("conditions")) + # The embedded-size budget empties a non-best agent's trial details + # but keeps its declared counts. + details_pruned = ( + non_best_pruned + and str(name) != str(report.get("best_agent") or "") + and not conditions + and not agent.get("trials") + and not agent.get("trials_baseline") + ) for condition, trial_field, score_field, count_field in ( ("with_skill", "trials", "with_skill", "num_trials"), ("without_skill", "trials_baseline", "baseline", "num_trials_baseline"), @@ -327,6 +339,7 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: declared = _count(agent.get(count_field)) if declared is None: declared = len(trials) + pruned = details_pruned and not trials expected = _count(details.get("expected_attempts")) scored = _count(details.get("scored_attempts")) keys = _trial_keys(trials) @@ -356,7 +369,7 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: "harness": str(agent.get("harness") or agent.get("name") or name), "condition": condition, "status": status, - "trials": logical_count, + "trials": declared if pruned else logical_count, "score": _number(agent.get(score_field)) if complete else None, "pass_rate": _number(_dict(_dict(agent.get("pass_at_k")).get(condition)).get("rate")) if complete @@ -364,6 +377,7 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: "_complete": complete, "_invalid_counts": invalid_counts, "_coverage_truncated": coverage_truncated, + "_details_pruned": pruned, "_report_index": report_index, "_agent_key": str(name), "_trial_keys": keys, @@ -413,6 +427,8 @@ def _ineligible_reason(with_row: dict[str, Any], without_row: dict[str, Any]) -> return "invalid trial counts" if with_row.get("_coverage_truncated") or without_row.get("_coverage_truncated"): return "trial data truncated" + if with_row.get("_details_pruned") or without_row.get("_details_pruned"): + return "trial details pruned from embedded report; load the retained run directory" for label, row in arms: if not row.get("_complete"): return f"{label} trial coverage incomplete" @@ -563,7 +579,10 @@ def _load_native(path: Path) -> DashboardData: engine_result = _dict(_read_native_json(path / "result.json", path)) skill = str(engine_result.get("skill_name") or "unknown") - result = agent_eval_result_from_directory(Path(skill), path, engine_result=engine_result, use_llm_judge=False) + # The payload is parsed in memory, never embedded, so keep every agent's trials. + result = agent_eval_result_from_directory( + Path(skill), path, engine_result=engine_result, use_llm_judge=False, enforce_embedded_size=False + ) if result is None: return DashboardData(warnings=[f"{path}: no supported retained agent summaries found."]) canonical = result.metadata["agent_eval"] diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index 008d5f452..d8c691d5e 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -505,6 +505,26 @@ def test_diagnostic_truncation_preserves_complete_trial_comparisons(omitted: str assert comparison_rows(data.rows)[0]["comparison_status"] == "comparable" +def test_pruned_non_best_agent_reports_declared_trials_and_reason() -> None: + report = _report() + report["best_agent"] = "best" + report["agents"]["best"] = copy.deepcopy(report["agents"]["claude-code"]) + agent = report["agents"]["claude-code"] + agent.update(num_trials=5, num_trials_baseline=5, conditions={}, trials=[], trials_baseline=[]) + report["report_truncation"] = {"truncated": True, "omitted": {"non_best_agent_details": 12}} + data = parse_dashboard_report(report, "report.json") + rows = [row for row in data.rows if row["_agent_key"] == "claude-code"] + assert [row["trials"] for row in rows] == [5, 5] + assert all(row["score"] is None and "tokens 0/5" in row["coverage"] for row in rows) + comparisons = {row["_agent_key"]: row for row in comparison_rows(data.rows)} + assert comparisons["best"]["comparison_status"] == "comparable" + assert comparisons["claude-code"]["comparison_status"] == "incomplete or mismatched coverage" + assert comparisons["claude-code"]["comparison_reason"] == ( + "trial details pruned from embedded report; load the retained run directory" + ) + assert comparisons["claude-code"]["score_delta"] is None + + def test_artifact_loading_truncation_blocks_comparisons() -> None: report = _report() report["report_truncation"] = { @@ -738,6 +758,38 @@ def test_oversized_trajectory_keeps_scores_comparable(tmp_path: Path) -> None: assert rows[0]["total_tokens"] is None +def test_retained_run_keeps_non_best_agent_trials_beyond_embedded_budget(tmp_path: Path, monkeypatch) -> None: + from skillevaluator.evaluation import tier3_report + + run = tmp_path / "run" + _native_run(run) + shutil.copytree(run / "opencode", run / "codex") + config = json.loads((run / "run_config.json").read_text(encoding="utf-8")) + config["agents"]["codex"] = {"agent": "codex", "model": "m"} + (run / "run_config.json").write_text(json.dumps(config), encoding="utf-8") + for summary_path in run.glob("codex/*/summary.json"): + summary = json.loads(summary_path.read_text(encoding="utf-8")) + summary["agent"] = "codex" + summary_path.write_text(json.dumps(summary), encoding="utf-8") + # A budget just below the full payload prunes only the non-best agent's details. + budget = tier3_report._serialized_payload_size(_canonical_export(run)) - 200 + monkeypatch.setattr(tier3_report, "_MAX_EMBEDDED_REPORT_BYTES", budget) + canonical = _canonical_export(run) + assert canonical["report_truncation"]["omitted"]["non_best_agent_details"] + pruned = next(name for name in canonical["agents"] if name != canonical["best_agent"]) + + rows = load_dashboard_path(run).rows + assert len(rows) == 4 + assert all(row["trials"] == 1 and row["score"] == 0.8 and row["total_tokens"] is not None for row in rows) + assert all(row["comparison_status"] == "comparable" for row in comparison_rows(rows)) + # The bounded canonical export still fails closed for the pruned agent. + comparison = next( + row for row in comparison_rows(parse_dashboard_report(canonical, "r.json").rows) if row["_agent_key"] == pruned + ) + assert comparison["coverage"] == "1 with / 1 without" + assert comparison["comparison_reason"].startswith("trial details pruned from embedded report") + + def test_catalog_native_and_mixed_references_are_loaded_without_cycles(tmp_path: Path) -> None: run = tmp_path / "run" _native_run(run) From 9cd96b77c56ed9922322838e8e12e5d19f68e673 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:59:08 -0700 Subject: [PATCH 29/40] fix(dashboard): keep retained time and cost when trajectory.json is unreadable A malformed, oversized, or symlinked trajectory.json made the whole retained trial unmeasured, dropping the agent time and cost that result.json records and the documented agent_result token fallback. The canonical export keeps that time, so the retained run showed less than its own export. Now only the trajectory is skipped, with a per-trial notice, and tokens fall back to agent_result. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/reports.mdx | 5 ++-- .../reporting/dashboard_data.py | 18 ++++++++++----- tests/reporting/test_dashboard_data.py | 23 +++++++++++++++++-- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/docs/reports.mdx b/docs/reports.mdx index d9e592c4d..dd07926cf 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -603,8 +603,9 @@ timezone are treated as unavailable, as in the HTML report's [measured agent resources](#measured-agent-resources). Agent time excludes environment setup and verification. Canonical JSON never records USD cost; open the retained run directory to show Harbor's recorded `agent_result.cost_usd` and -multi-step totals. For retained runs whose trajectory lacks token totals, the -dashboard falls back to Harbor's `agent_result` token counters. +multi-step totals. For retained runs whose trajectory lacks token totals or +cannot be read, the dashboard falls back to Harbor's `agent_result` token +counters and keeps the trial's agent time and cost. Some exports written before v0.5.0 encoded missing token counters as zero; open their retained run directories to recover recorded counters. Cached tokens are shown separately and are not added again diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index 2b508837e..72c52d838 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -524,12 +524,17 @@ def _read_native_json(path: Path, run_root: Path) -> Any: return _read_json(path) -def _native_usage(trial_dir: Path, run_root: Path, *, require_steps: bool = False) -> dict[str, Any]: - trajectory = ( - _dict(_read_native_json(trial_dir / "trajectory.json", run_root)) - if (trial_dir / "trajectory.json").is_file() - else {} - ) +def _native_usage( + trial_dir: Path, run_root: Path, warnings: list[str], *, require_steps: bool = False +) -> dict[str, Any]: + trajectory: dict[str, Any] = {} + if (trial_dir / "trajectory.json").is_file(): + try: + trajectory = _dict(_read_native_json(trial_dir / "trajectory.json", run_root)) + except (OSError, ValueError, RecursionError) as exc: + # As in canonical JSON, this loses only the trajectory's token totals; + # result.json still records time, cost, and agent_result counters. + warnings.append(f"{trial_dir}: cannot read trajectory: {exc}") final = _dict(trajectory.get("final_metrics")) result = ( _dict(_read_native_json(trial_dir / "result.json", run_root)) if (trial_dir / "result.json").is_file() else {} @@ -655,6 +660,7 @@ def _load_native(path: Path) -> DashboardData: usages_by_trial[physical_id] = _native_usage( trial_dir, path, + output.warnings, require_steps=physical_counts[physical_id] > 1 or physical_id in row["_ambiguous_trial_ids"], ) unresolved_scope |= usages_by_trial[physical_id].get("_resource_scope_valid") is False diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index d8c691d5e..a124ed329 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -726,6 +726,20 @@ def test_canonical_export_agent_seconds_matches_retained_run(tmp_path: Path) -> assert comparison["duration_seconds_delta"] == 0.0 +def test_unreadable_trajectory_keeps_retained_time_and_token_fallback(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + trajectory = run / "opencode" / "with-skill" / "trials" / "case-a__random" / "trajectory.json" + trajectory.write_text("{not json", encoding="utf-8") + retained = load_dashboard_path(run) + canonical = parse_dashboard_report(_canonical_export(run), "r.json") + assert retained.rows[0]["duration_seconds"] == canonical.rows[0]["duration_seconds"] == 10.0 + assert comparison_rows(retained.rows)[0]["duration_seconds_delta"] == 0.0 + # Harbor's agent_result counters stand in for the unreadable trajectory totals. + assert retained.rows[0]["total_tokens"] == 210 + assert any("cannot read trajectory" in warning for warning in retained.warnings) + + def test_retained_naive_timestamps_follow_canonical_timezone_policy(tmp_path: Path) -> None: run = tmp_path / "run" _native_run(run) @@ -1091,8 +1105,13 @@ def test_native_usage_rejects_intermediate_directory_and_file_symlinks(tmp_path: pytest.skip("Symlinks are unavailable on this host") data = load_dashboard_path(run) row = next(row for row in data.rows if row["condition"] == "with_skill") - assert row["total_tokens"] is None - assert row["duration_seconds"] is None + if artifact == "trajectory.json": + # A skipped trajectory loses only its own totals; result.json still measures the trial. + assert row["total_tokens"] == 210 + assert row["duration_seconds"] == 10 + else: + assert row["total_tokens"] is None + assert row["duration_seconds"] is None assert any("symlink" in warning for warning in data.warnings) From 45dc37f11332c62cb44f372cfd12c13be2dd63cf Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 11:02:02 -0700 Subject: [PATCH 30/40] fix(dashboard): read harness features from a retained run's run_config.json The guide says to add dashboard_metadata to run_config.json by hand, but the loader read that file only when result.json had no embedded run_config, and every real run embeds one, so hand-added features stayed "unknown". The run directory's run_config.json now wins; the embedded copy is used, with a notice, only when the file cannot be read. The test fixture now embeds run_config in result.json the way the runner does. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/reports.mdx | 9 +++++---- src/skillevaluator/reporting/dashboard_data.py | 12 ++++++++++-- tests/reporting/test_dashboard_data.py | 13 +++++++++---- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/docs/reports.mdx b/docs/reports.mdx index dd07926cf..a2f571420 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -635,10 +635,11 @@ condition can include: object. For canonical JSON the condition's value wins over the agent's, which wins over the report's. For retained runs the order is the condition's `summary.json`, then the agent entry in `run_config.json`, then the root of -`run_config.json`. An empty feature list records that no features were enabled -and is shown as **none (recorded)**; an absent field is displayed as -**unknown**. Differing recorded models or feature configurations are kept -separate when pairing conditions. +`run_config.json`. Edit the run directory's `run_config.json`; the copy embedded +in `result.json` is used only when that file cannot be read. An empty feature +list records that no features were enabled and is shown as **none (recorded)**; +an absent field is displayed as **unknown**. Differing recorded models or +feature configurations are kept separate when pairing conditions. An explicitly imported adverse condition uses `conditions.adverse`, `trials_adverse`, `num_trials_adverse`, and `adverse` for its score in the same diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index 72c52d838..066499085 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -592,11 +592,19 @@ def _load_native(path: Path) -> DashboardData: return DashboardData(warnings=[f"{path}: no supported retained agent summaries found."]) canonical = result.metadata["agent_eval"] canonical["run_id"] = engine_result.get("run_id") or path.name + # The runner writes the same config into result.json, but run_config.json is + # the copy users edit to add dashboard_metadata, so it wins when readable. run_config = _dict(engine_result.get("run_config")) - if not run_config and (path / "run_config.json").is_file(): - run_config = _dict(_read_native_json(path / "run_config.json", path)) + config_warning = None + if (path / "run_config.json").is_file(): + try: + run_config = _dict(_read_native_json(path / "run_config.json", path)) or run_config + except (OSError, ValueError, RecursionError) as exc: + config_warning = f"{path / 'run_config.json'}: cannot read run config: {exc}" canonical["dashboard_metadata"] = run_config.get("dashboard_metadata") output = parse_dashboard_report(canonical, str(path)) + if config_warning: + output.warnings.append(config_warning) unresolved_scope = False for row in output.rows: # The report's agent keys identify repeated harness occurrences on disk. diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index a124ed329..2f9533539 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -622,12 +622,12 @@ def test_catalog_index_loads_authoritative_local_reports_with_containment(tmp_pa def _native_run(path: Path) -> None: metrics = ["security", "skill_execution", "skill_efficiency", "accuracy", "goal_accuracy", "behavior_check"] path.mkdir() + run_config = {"agents": {"opencode": {"agent": "opencode", "model": "m"}}} + # Like the runner, result.json embeds the config that run_config.json holds. (path / "result.json").write_text( - json.dumps({"skill_name": "native-skill", "run_id": "native-run"}), encoding="utf-8" - ) - (path / "run_config.json").write_text( - json.dumps({"agents": {"opencode": {"agent": "opencode", "model": "m"}}}), encoding="utf-8" + json.dumps({"skill_name": "native-skill", "run_id": "native-run", "run_config": run_config}), encoding="utf-8" ) + (path / "run_config.json").write_text(json.dumps(run_config), encoding="utf-8") for variant, input_tokens in (("with-skill", 200), ("without-skill", 100)): condition = path / "opencode" / variant trial = condition / "trials" / "case-a__random" @@ -1208,6 +1208,11 @@ def test_retained_feature_metadata_precedence_summary_over_agent_over_root(tmp_p assert rows["with_skill"]["features"] == "agent" assert rows["without_skill"]["features"] == "summary" assert all(item["comparison_status"] == "missing condition" for item in comparison_rows(list(rows.values()))) + # An unreadable run_config.json falls back to the copy in result.json. + (run / "run_config.json").write_text("{", encoding="utf-8") + data = load_dashboard_path(run) + assert [row["features"] for row in data.rows] == ["unknown", "summary"] + assert any("cannot read run config" in warning for warning in data.warnings) def test_empty_feature_list_and_string_and_mapping_forms() -> None: From 9071ab78add9885c60e006e93b467bf260545fdb Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 11:05:47 -0700 Subject: [PATCH 31/40] fix(dashboard): treat zero token counters in pre-0.5.0 exports as unavailable Canonical exports written before v0.5.0 recorded missing token counters as zero, and the dashboard showed those zeros as measured and published token differences against them. When a report's evaluator_version is earlier than 0.5.0, zero token counters are now unavailable and the source gets a notice pointing to the retained run directory. Missing or unparsable versions keep their values. Retained runs read counters from disk and do not show the notice. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/reports.mdx | 6 ++- .../reporting/dashboard_data.py | 51 +++++++++++++++++-- tests/reporting/test_dashboard_data.py | 43 ++++++++++++++++ 3 files changed, 93 insertions(+), 7 deletions(-) diff --git a/docs/reports.mdx b/docs/reports.mdx index a2f571420..3760236b2 100644 --- a/docs/reports.mdx +++ b/docs/reports.mdx @@ -606,8 +606,10 @@ the retained run directory to show Harbor's recorded `agent_result.cost_usd` and multi-step totals. For retained runs whose trajectory lacks token totals or cannot be read, the dashboard falls back to Harbor's `agent_result` token counters and keeps the trial's agent time and cost. -Some exports written before v0.5.0 encoded missing token counters as zero; open -their retained run directories to recover recorded counters. +Exports written before v0.5.0 could encode missing token counters as zero, so +when a canonical JSON report's `evaluator_version` is earlier than 0.5.0 the +dashboard shows its zero token counters as unavailable and adds a notice; open +the retained run directory to recover recorded counters. Cached tokens are shown separately and are not added again to prompt plus completion tokens. No pricing estimates or new agent evaluations are performed. Adverse conditions and harness features are displayed when diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index 066499085..027a1b149 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -21,6 +21,8 @@ from pathlib import Path from typing import Any +from packaging.version import Version + from skillevaluator.tier3.harbor.resource_usage import agent_execution_seconds _USAGE = ("prompt_tokens", "completion_tokens", "total_tokens", "cached_tokens", "duration_seconds", "cost_usd") @@ -39,6 +41,8 @@ # Loader bounds on these artifacts drop only per-trial telemetry (tokens, steps). # Canonical trials then omit those counters, so coverage counts keep totals blank. _TELEMETRY_ARTIFACTS = frozenset({"trajectory"}) +# Canonical exports from earlier evaluators wrote missing token counters as zero. +_ZERO_TOKEN_COUNTERS_FIXED_IN = Version("0.5.0") @dataclass @@ -215,15 +219,35 @@ def _trial_keys(trials: list[dict[str, Any]]) -> tuple[tuple[str, str], ...] | N return tuple(sorted(keys)) -def _usage(trial: dict[str, Any]) -> dict[str, float | None]: +def _zero_encodes_missing_tokens(report: dict[str, Any]) -> bool: + # The version names the run's evaluator, so re-exports of older runs also fail closed. + version = report.get("evaluator_version") or _dict(report.get("summary")).get("evaluator_version") + if not isinstance(version, str): + return False + try: + return Version(version) < _ZERO_TOKEN_COUNTERS_FIXED_IN + except ValueError: # InvalidVersion, or more digits than int() converts + return False + + +def _has_zero_token_counter(trials: list[dict[str, Any]]) -> bool: + return any( + _measurement(_dict(trial.get("tokens")).get(key)) == 0 + for trial in trials + for key in ("prompt", "completion", "cached") + ) + + +def _usage(trial: dict[str, Any], *, zero_tokens_missing: bool = False) -> dict[str, float | None]: tokens = _dict(trial.get("tokens")) - prompt = _measurement(tokens.get("prompt")) - completion = _measurement(tokens.get("completion")) + prompt, completion, cached = (_measurement(tokens.get(key)) for key in ("prompt", "completion", "cached")) + if zero_tokens_missing: + prompt, completion, cached = (value or None for value in (prompt, completion, cached)) return { "prompt_tokens": prompt, "completion_tokens": completion, "total_tokens": prompt + completion if prompt is not None and completion is not None else None, - "cached_tokens": _measurement(tokens.get("cached")), + "cached_tokens": cached, # Canonical Tier 3 JSON records agent_seconds; duration_seconds is only # read from hand-built payloads and never replaces an invalid agent_seconds. "duration_seconds": _measurement( @@ -263,6 +287,13 @@ def _ambiguous_resource_notice(source: str) -> str: ) +def _zero_token_notice(source: str) -> str: + return ( + f"{source}: exports before v0.5.0 may record missing token counters as zero; " + "zero token counters are shown as unavailable. Load the retained run directory for recorded counters." + ) + + def parse_dashboard_report(payload: Any, source: str) -> DashboardData: """Normalize canonical Tier 3, validate-report, and embedded catalog JSON.""" output = DashboardData() @@ -282,6 +313,7 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: run_id = str(report.get("evaluated_at") or summary.get("evaluated_at") or "unknown") truncation = _dict(report.get("report_truncation")) or _dict(report.get("truncation")) coverage_truncated = _trial_coverage_truncated(truncation) + zero_tokens_missing = _zero_encodes_missing_tokens(report) non_best_pruned = bool(truncation.get("truncated")) and "non_best_agent_details" in _dict( truncation.get("omitted") ) @@ -350,6 +382,10 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: notice = _ambiguous_resource_notice(source) if notice not in output.warnings: output.warnings.append(notice) + if zero_tokens_missing and _has_zero_token_counter(trials): + notice = _zero_token_notice(source) + if notice not in output.warnings: + output.warnings.append(notice) complete = ( status == "succeeded" and not invalid_counts @@ -394,7 +430,10 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: [] if invalid_counts else [ - {} if str(trial.get("trial_id") or "") in ambiguous_ids else _usage(trial) for trial in trials + {} + if str(trial.get("trial_id") or "") in ambiguous_ids + else _usage(trial, zero_tokens_missing=zero_tokens_missing) + for trial in trials ], # Trials missing from the declared count are already part of it. expected=declared + max(0, row["_expected_usage_trials"] - max(logical_count, declared)), @@ -603,6 +642,8 @@ def _load_native(path: Path) -> DashboardData: config_warning = f"{path / 'run_config.json'}: cannot read run config: {exc}" canonical["dashboard_metadata"] = run_config.get("dashboard_metadata") output = parse_dashboard_report(canonical, str(path)) + # Retained usage is read from disk below, so the export notice does not apply. + output.warnings = [warning for warning in output.warnings if warning != _zero_token_notice(str(path))] if config_warning: output.warnings.append(config_warning) unresolved_scope = False diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index 2f9533539..5f4cb412a 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -107,6 +107,32 @@ def test_partial_missing_metrics_never_become_zero_or_partial_total() -> None: assert "cost 0/1" in data.rows[0]["coverage"] +def test_pre_v050_zero_token_counters_are_unavailable() -> None: + report = _report() + report["evaluator_version"] = "0.4.0" + report["agents"]["claude-code"]["trials_baseline"][0]["tokens"] = {"prompt": 0, "completion": 0, "cached": 0} + data = parse_dashboard_report(report, "legacy.json") + with_row, without_row = data.rows + assert without_row["prompt_tokens"] is None + assert without_row["total_tokens"] is None + assert with_row["total_tokens"] == 150 + assert with_row["cached_tokens"] is None + comparison = comparison_rows(data.rows)[0] + assert comparison["comparison_status"] == "comparable" + assert comparison["score_delta"] == pytest.approx(0.2) + assert comparison["total_tokens_delta"] is None + assert any("before v0.5.0" in warning for warning in data.warnings) + report.pop("evaluator_version") + report["summary"] = {"evaluator_version": "0.4.1"} + assert parse_dashboard_report(report, "legacy.json").rows[1]["total_tokens"] is None + # Current, missing, or unparsable versions keep recorded zeros. + for version in ("0.5.0", None, "not-a-version", "9" * 5000): + report["summary"]["evaluator_version"] = version + data = parse_dashboard_report(report, "current.json") + assert data.rows[1]["total_tokens"] == 0 + assert not data.warnings + + def test_canonical_missing_attempt_keeps_usage_totals_unknown() -> None: report = _report() agent = report["agents"]["claude-code"] @@ -740,6 +766,23 @@ def test_unreadable_trajectory_keeps_retained_time_and_token_fallback(tmp_path: assert any("cannot read trajectory" in warning for warning in retained.warnings) +def test_retained_run_ignores_export_zero_token_notice(tmp_path: Path) -> None: + run = tmp_path / "run" + _native_run(run) + engine_result = json.loads((run / "result.json").read_text(encoding="utf-8")) + engine_result["evaluator_version"] = "0.4.0" + (run / "result.json").write_text(json.dumps(engine_result), encoding="utf-8") + for trajectory_path in run.glob("opencode/*/trials/*/trajectory.json"): + trajectory = json.loads(trajectory_path.read_text(encoding="utf-8")) + trajectory["final_metrics"]["total_cached_tokens"] = 0 + trajectory_path.write_text(json.dumps(trajectory), encoding="utf-8") + assert any("before v0.5.0" in warning for warning in parse_dashboard_report(_canonical_export(run), "r").warnings) + data = load_dashboard_path(run) + # Retained trajectories hold recorded counters, so their zeros stay measured. + assert [row["cached_tokens"] for row in data.rows] == [0, 0] + assert not any("before v0.5.0" in warning for warning in data.warnings) + + def test_retained_naive_timestamps_follow_canonical_timezone_policy(tmp_path: Path) -> None: run = tmp_path / "run" _native_run(run) From 01aed41dc705882264ff4b647e8635b02490dd3d Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:53:06 -0700 Subject: [PATCH 32/40] fix(dashboard): show a rewritten file over a stale directory copy A directory input is cached on the directory's own fingerprint, which does not change when a file inside it is rewritten in place. When the directory came before that file on the command line, dedupe_rows kept the directory's stale rows and dropped the file's fresh ones. Load the deepest inputs first so the explicitly named file wins. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- src/skillevaluator/reporting/dashboard_app.py | 5 +++++ tests/reporting/test_dashboard_app.py | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/skillevaluator/reporting/dashboard_app.py b/src/skillevaluator/reporting/dashboard_app.py index c48e30d5f..75ac9486c 100644 --- a/src/skillevaluator/reporting/dashboard_app.py +++ b/src/skillevaluator/reporting/dashboard_app.py @@ -327,6 +327,7 @@ def main(paths: list[str] | None = None) -> None: rows: list[dict[str, Any]] = [] warnings: list[str] = [] seen_paths: set[Path] = set() + inputs: list[Path] = [] for supplied_path in paths or []: try: path = Path(supplied_path).expanduser().resolve() @@ -336,6 +337,10 @@ def main(paths: list[str] | None = None) -> None: if path in seen_paths: continue seen_paths.add(path) + inputs.append(path) + # A directory's fingerprint misses in-place rewrites of files inside it, so load + # deeper inputs first and let dedupe_rows keep their fresher copy of shared rows. + for path in sorted(inputs, key=lambda item: len(item.parts), reverse=True): data = _load_path_cached(str(path), _input_fingerprint(path)) rows.extend(data.rows) warnings.extend(data.warnings) diff --git a/tests/reporting/test_dashboard_app.py b/tests/reporting/test_dashboard_app.py index 2583c2bd0..e274be703 100644 --- a/tests/reporting/test_dashboard_app.py +++ b/tests/reporting/test_dashboard_app.py @@ -293,6 +293,16 @@ def test_directory_and_file_inside_it_load_once(tmp_path: Path) -> None: assert any("duplicate" in text.value for text in app.text) +def test_rewritten_file_inside_directory_input_is_reloaded(tmp_path: Path) -> None: + report = _write_report(tmp_path / "run.json") + # The directory comes first, and its own fingerprint misses an in-place rewrite of the file. + app = _app([tmp_path, report]) + _rewrite_score(report, 0.5) + app.run() + assert not app.exception + assert app.dataframe[0].value["score"].tolist() == [0.5, 0.6] + + def test_results_dir_and_latest_symlink_load_once(tmp_path: Path) -> None: results = tmp_path / "results" run = results / "run-1" From a77d4ff12ea71341ba5d52cdc7e2b2309ca54f43 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:55:33 -0700 Subject: [PATCH 33/40] fix(dashboard): keep other inputs when a subdirectory is unreadable A directory input with a subdirectory the user cannot search (such as a root-owned trial directory from a container run) raised PermissionError from the native-run probe, and main() let it replace the whole page with a traceback. The directory walk now records a notice for that subdirectory and keeps going, and main() turns any unexpected load error for one input into a notice so the other inputs still render. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- src/skillevaluator/reporting/dashboard_app.py | 6 ++- .../reporting/dashboard_data.py | 8 +++- tests/reporting/test_dashboard_app.py | 37 +++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/skillevaluator/reporting/dashboard_app.py b/src/skillevaluator/reporting/dashboard_app.py index 75ac9486c..1cd827d0b 100644 --- a/src/skillevaluator/reporting/dashboard_app.py +++ b/src/skillevaluator/reporting/dashboard_app.py @@ -341,7 +341,11 @@ def main(paths: list[str] | None = None) -> None: # A directory's fingerprint misses in-place rewrites of files inside it, so load # deeper inputs first and let dedupe_rows keep their fresher copy of shared rows. for path in sorted(inputs, key=lambda item: len(item.parts), reverse=True): - data = _load_path_cached(str(path), _input_fingerprint(path)) + try: + data = _load_path_cached(str(path), _input_fingerprint(path)) + except Exception as exc: # one unreadable input must not hide the others + warnings.append(f"{path}: cannot load dashboard input: {exc}") + continue rows.extend(data.rows) warnings.extend(data.warnings) seen_uploads: set[str] = set() diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index 027a1b149..3f1be83ff 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -808,7 +808,13 @@ def load_dashboard_path(path: Path) -> DashboardData: if visited >= _MAX_PATHS or files >= _MAX_FILES: output.warnings.append(_DISCOVERY_LIMIT_NOTICE) break - if (root / "result.json").is_file() and (root / "run_config.json").is_file(): + try: + # is_file() re-raises EACCES for a subdirectory without search permission. + native_run = (root / "result.json").is_file() and (root / "run_config.json").is_file() + except OSError as exc: + output.warnings.append(f"{root}: cannot discover reports: {exc}") + continue + if native_run: try: data = _load_native(root) except (OSError, ValueError, RecursionError, RuntimeError, TypeError, AttributeError) as exc: diff --git a/tests/reporting/test_dashboard_app.py b/tests/reporting/test_dashboard_app.py index e274be703..cf71c9013 100644 --- a/tests/reporting/test_dashboard_app.py +++ b/tests/reporting/test_dashboard_app.py @@ -8,6 +8,7 @@ import csv import io import json +import os from pathlib import Path import pytest @@ -241,6 +242,42 @@ def test_bad_report_does_not_hide_other_results(tmp_path: Path) -> None: assert len(app.dataframe[0].value) == 2 +@pytest.mark.skipif(os.name == "nt" or os.geteuid() == 0, reason="Needs POSIX permissions enforced for this user") +def test_unreadable_subdirectory_does_not_hide_other_results(tmp_path: Path) -> None: + runs = tmp_path / "runs" + runs.mkdir() + _write_report(runs / "run.json") + locked = runs / "locked" + locked.mkdir() + other = _write_report(tmp_path / "other.json", model="model-b") + locked.chmod(0) + try: + app = _app([runs, other]) + finally: + locked.chmod(0o755) + assert not app.exception + assert len(app.dataframe[0].value) == 4 + assert any(text.value.startswith(f"{locked.resolve()}: cannot discover reports") for text in app.text) + + +def test_input_that_fails_to_load_does_not_hide_other_results(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: + real = dashboard_app.load_dashboard_path + unreadable = _write_report(tmp_path / "unreadable.json") + valid = _write_report(tmp_path / "valid.json", model="model-b") + + def failing(path: Path): + # Stands in for any error the loader does not anticipate. + if path == unreadable.resolve(): + raise PermissionError(13, "Permission denied", str(path)) + return real(path) + + monkeypatch.setattr(dashboard_app, "load_dashboard_path", failing) + app = _app([unreadable, valid]) + assert not app.exception + assert app.dataframe[0].value["model"].tolist() == ["model-b", "model-b"] + assert any(text.value.startswith(f"{unreadable.resolve()}: cannot load dashboard input:") for text in app.text) + + def test_oversized_trial_count_keeps_other_reports(tmp_path: Path) -> None: valid = _write_report(tmp_path / "valid.json") oversized = _write_report(tmp_path / "oversized.json") From b6e5bee0d90470ee1c8d71ef5b125e1b314acbd3 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:56:55 -0700 Subject: [PATCH 34/40] test(dashboard): exercise long attempt values in the attempt fields The long-attempt test only set trial_id, which stopped carrying attempt numbers when attempt pairing moved to the attempt and attempt_index fields, so it passed regardless of how attempts were normalized. It now sets a 5000-digit attempt with leading zeros on one arm and checks that it pairs with the same value, and not with a different one. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- tests/reporting/test_dashboard_data.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index 5f4cb412a..781ce5f3a 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -345,13 +345,18 @@ def test_zero_attempt_identity_and_conflicting_attempt_fields() -> None: assert comparison["score_delta"] is None -def test_long_numeric_attempt_suffix_is_normalized_without_integer_conversion() -> None: +def test_long_numeric_attempt_field_is_normalized_without_integer_conversion() -> None: report = _report() agent = report["agents"]["claude-code"] - for field in ("trials", "trials_baseline"): - agent[field][0]["trial_id"] = "case-a__attempt" + "9" * 5000 + # Longer than int()'s default 4300-digit limit for decimal strings. + agent["trials"][0]["attempt"] = "0" * 10 + "9" * 5000 + agent["trials_baseline"][0]["attempt"] = "9" * 5000 comparison = comparison_rows(parse_dashboard_report(report, "report.json").rows)[0] assert comparison["comparison_status"] == "comparable" + agent["trials_baseline"][0]["attempt"] = "9" * 4999 + "8" + comparison = comparison_rows(parse_dashboard_report(report, "report.json").rows)[0] + assert comparison["comparison_status"] == "incomplete or mismatched coverage" + assert comparison["comparison_reason"] == "different cases or attempts" def test_zero_baseline_and_nonfinite_values() -> None: From 263fedd78407e2bfdcd11564221bc1ef069dbc9f Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:57:52 -0700 Subject: [PATCH 35/40] test(dashboard): skip the directory symlink check where symlinks fail The directory-walk test created a symlink without the OSError guard the other symlink tests use, so it errored on Windows hosts without symlink rights. The malformed and missing-input checks now live in their own test, and the symlink test skips when the host cannot create one. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- tests/reporting/test_dashboard_data.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/reporting/test_dashboard_data.py b/tests/reporting/test_dashboard_data.py index 781ce5f3a..acab15e13 100644 --- a/tests/reporting/test_dashboard_data.py +++ b/tests/reporting/test_dashboard_data.py @@ -616,14 +616,21 @@ def test_trajectory_reason_does_not_hide_missing_trial() -> None: assert status == "incomplete or mismatched coverage" -def test_bad_input_is_diagnostic_and_directory_skips_symlinks(tmp_path: Path) -> None: +def test_bad_input_is_diagnostic(tmp_path: Path) -> None: malformed = tmp_path / "broken.json" malformed.write_text("{", encoding="utf-8") assert load_dashboard_path(malformed).warnings assert load_dashboard_path(tmp_path / "missing").warnings + + +def test_directory_skips_symlinks(tmp_path: Path) -> None: + (tmp_path / "broken.json").write_text("{", encoding="utf-8") good = tmp_path / "report.json" good.write_text(json.dumps(_report()), encoding="utf-8") - (tmp_path / "loop").symlink_to(tmp_path, target_is_directory=True) + try: + (tmp_path / "loop").symlink_to(tmp_path, target_is_directory=True) + except OSError: + pytest.skip("Symlinks are unavailable on this host") data = load_dashboard_path(tmp_path) assert len(data.rows) == 2 assert any("cannot read" in warning for warning in data.warnings) From 09d00f56227c5e0ef3596d201eba62deb2762b9b Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:53:51 -0700 Subject: [PATCH 36/40] fix(dashboard): require Streamlit 1.61 for the allowed-hosts check The launcher limits browser connections to 127.0.0.1 and localhost through server.allowedHosts, which Streamlit added in 1.61. Older releases ignore the setting without a warning, so the dashboard extra now requires 1.61. A new test checks that every setting the launcher passes exists in the installed Streamlit, and the packaging test pins the new floor. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- pyproject.toml | 3 ++- tests/reporting/test_dashboard_cli.py | 20 ++++++++++++++++++++ tests/test_oss_packaging.py | 4 +++- uv.lock | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0b6e2e050..4bb9b0dd6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,7 +79,8 @@ security = [ ] # Optional local UI for comparing saved reports; never imported by base commands. dashboard = [ - "streamlit>=1.49,<2", + # server.allowedHosts, which limits the dashboard to loopback host names, needs 1.61. + "streamlit>=1.61,<2", ] # Full public install convenience bundle. all = [ diff --git a/tests/reporting/test_dashboard_cli.py b/tests/reporting/test_dashboard_cli.py index c210661c8..eb675bcfb 100644 --- a/tests/reporting/test_dashboard_cli.py +++ b/tests/reporting/test_dashboard_cli.py @@ -6,6 +6,7 @@ from __future__ import annotations import importlib.util +import os import signal import subprocess import sys @@ -102,6 +103,25 @@ def test_launch_uses_loopback_and_literal_absolute_paths(tmp_path: Path, monkeyp assert command[-2:] == ["--", str(report.resolve())] +def test_launch_settings_exist_in_installed_streamlit(monkeypatch) -> None: + # Streamlit silently ignores settings it does not define; server.allowedHosts needs 1.61. + config = pytest.importorskip("streamlit.config") + # Filled on import; config._config_options stays None until Streamlit loads its config. + options = config._config_options_template + monkeypatch.delenv("STREAMLIT_SERVER_ALLOWED_HOSTS", raising=False) + _result, fake = _capture_launch(monkeypatch, "--port", "8517", "--no-browser") + command, env = fake.command, fake.kwargs["env"] + flags = command[command.index("run") + 2 : command.index("--")] + assert flags + for flag in flags: + name, separator, _value = flag.removeprefix("--").partition("=") + assert flag.startswith("--") and separator, flag + assert name in options and not options[name].deprecated, flag + env_options = {option.env_var: name for name, option in options.items()} + added = {name for name, value in env.items() if os.environ.get(name) != value} + assert {env_options.get(name) for name in added} == {"server.allowedHosts"} + + def test_default_launch_lets_streamlit_choose_port(monkeypatch) -> None: # Streamlit moves to the next free port only when the port was not set explicitly. _result, fake = _capture_launch(monkeypatch) diff --git a/tests/test_oss_packaging.py b/tests/test_oss_packaging.py index 089cf73ef..ab93b27a3 100644 --- a/tests/test_oss_packaging.py +++ b/tests/test_oss_packaging.py @@ -501,7 +501,9 @@ def test_release_lock_enforces_nspect_remediation_floors_without_removed_telemet if any(dependency["name"] == "protobuf" for dependency in package.get("dependencies", [])) } assert protobuf_consumers == {"streamlit"} - assert extras["dashboard"] == ["streamlit>=1.49,<2"] + # Older Streamlit releases silently ignore the launcher's server.allowedHosts setting. + assert extras["dashboard"] == ["streamlit>=1.61,<2"] + assert all(version >= Version("1.61") for version in all_lock_versions["streamlit"]) assert not any("streamlit" in dependency for dependency in project["project"]["dependencies"]) assert all(version >= Version("4.0.0") for version in all_lock_versions["oauthlib"]) assert not any(name.startswith("opentelemetry") for name in all_lock_versions) diff --git a/uv.lock b/uv.lock index 33ea5bc02..9b57dfe00 100644 --- a/uv.lock +++ b/uv.lock @@ -2183,7 +2183,7 @@ requires-dist = [ { name = "skillevaluator", extras = ["llm"], marker = "extra == 'tier2'" }, { name = "skillevaluator", extras = ["llm"], marker = "extra == 'tier3'" }, { name = "skillevaluator", extras = ["tier2", "tier3", "security"], marker = "extra == 'all'" }, - { name = "streamlit", marker = "extra == 'dashboard'", specifier = ">=1.49,<2" }, + { name = "streamlit", marker = "extra == 'dashboard'", specifier = ">=1.61,<2" }, ] provides-extras = ["llm", "tier2", "tier3", "security", "dashboard", "all", "dev"] From aecf9f4deb8a8c3a84637d98f2b7e9484cf1c4d2 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:55:03 -0700 Subject: [PATCH 37/40] fix(dashboard): exit with 128 plus the signal when Streamlit is killed When a signal killed Streamlit, the launcher passed the negative return code to SystemExit, so a forwarded SIGHUP exited 255 and SIGKILL 247. The launcher now exits 128 plus the signal number (129 and 137), as a shell does, and the busy-port hint stays limited to Streamlit's own errors. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- src/skillevaluator/reporting/dashboard.py | 3 ++- tests/reporting/test_dashboard_cli.py | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/skillevaluator/reporting/dashboard.py b/src/skillevaluator/reporting/dashboard.py index af3100294..ccaaaee63 100644 --- a/src/skillevaluator/reporting/dashboard.py +++ b/src/skillevaluator/reporting/dashboard.py @@ -81,4 +81,5 @@ def launch_dashboard(paths: tuple[Path, ...], *, port: int | None = None, no_bro click.echo( f"Streamlit exited with status {code}. If port {port} is in use, choose another with --port.", err=True ) - return code + # A child killed by signal N reports -N; exit with 128 + N as a shell would. + return 128 - code if code < 0 else code diff --git a/tests/reporting/test_dashboard_cli.py b/tests/reporting/test_dashboard_cli.py index eb675bcfb..f51ef169e 100644 --- a/tests/reporting/test_dashboard_cli.py +++ b/tests/reporting/test_dashboard_cli.py @@ -153,9 +153,25 @@ def exit_code(self) -> int: signal.getsignal(signal.SIGTERM)(signal.SIGTERM, None) return -15 - _result, fake = _capture_launch(monkeypatch, popen=TerminatedPopen) + result, fake = _capture_launch(monkeypatch, popen=TerminatedPopen) assert fake.sent == [signal.SIGTERM] assert signal.getsignal(signal.SIGTERM) is original + assert result.exit_code == 128 + signal.SIGTERM + + +@pytest.mark.skipif(not hasattr(signal, "SIGHUP"), reason="SIGHUP is POSIX-only") +def test_streamlit_killed_by_signal_exits_like_a_shell(monkeypatch) -> None: + class HungUpPopen(FakePopen): + def exit_code(self) -> int: + # Streamlit has no SIGHUP handler, so the forwarded signal kills it. + signal.getsignal(signal.SIGHUP)(signal.SIGHUP, None) + return -signal.SIGHUP + + result, fake = _capture_launch(monkeypatch, "--port", "8517", popen=HungUpPopen) + assert fake.sent == [signal.SIGHUP] + assert result.exit_code == 128 + signal.SIGHUP + # The busy-port hint is only for Streamlit's own failures. + assert "choose another with --port" not in result.output def test_ctrl_c_returns_zero(monkeypatch) -> None: From c6d1a33cb805bc369c56d71087b841cd0614658b Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 10:57:02 -0700 Subject: [PATCH 38/40] fix(dashboard): pass SIGINT on to Streamlit when only the launcher gets it The launcher assumed Ctrl+C always reached the whole process group. A SIGINT sent to the launcher's pid alone left Streamlit serving the port for 10 seconds until it was terminated. The launcher now sends SIGINT to Streamlit before waiting, outside Windows. A new test covers the timeout path that terminates a Streamlit that does not stop. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- src/skillevaluator/reporting/dashboard.py | 8 ++++++-- tests/reporting/test_dashboard_cli.py | 20 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/skillevaluator/reporting/dashboard.py b/src/skillevaluator/reporting/dashboard.py index ccaaaee63..1c37d8058 100644 --- a/src/skillevaluator/reporting/dashboard.py +++ b/src/skillevaluator/reporting/dashboard.py @@ -58,8 +58,8 @@ def launch_dashboard(paths: tuple[Path, ...], *, port: int | None = None, no_bro ] env = {**os.environ, "STREAMLIT_SERVER_ALLOWED_HOSTS": "127.0.0.1 localhost"} proc = subprocess.Popen(command, cwd=str(_APP.parent), env=env) - # Ctrl+C reaches the whole process group, but a SIGTERM or SIGHUP sent only - # to this process would otherwise leave Streamlit running on the port. + # A SIGTERM, SIGHUP, or SIGINT sent only to this process would otherwise + # leave Streamlit running on the port. previous: dict[int, Any] = {} if threading.current_thread() is threading.main_thread(): for sig in (signal.SIGTERM, getattr(signal, "SIGHUP", None)): @@ -68,6 +68,10 @@ def launch_dashboard(paths: tuple[Path, ...], *, port: int | None = None, no_bro try: code = proc.wait() except KeyboardInterrupt: + # Ctrl+C reaches the whole process group, but kill -INT on this pid does + # not; a repeated SIGINT only repeats Streamlit's stop request. + if sys.platform != "win32": + proc.send_signal(signal.SIGINT) try: proc.wait(timeout=10) except subprocess.TimeoutExpired: diff --git a/tests/reporting/test_dashboard_cli.py b/tests/reporting/test_dashboard_cli.py index f51ef169e..9ab48a68e 100644 --- a/tests/reporting/test_dashboard_cli.py +++ b/tests/reporting/test_dashboard_cli.py @@ -183,9 +183,25 @@ def exit_code(self) -> int: result, fake = _capture_launch(monkeypatch, popen=InterruptedPopen) assert result.exit_code == 0 - # The launcher waits for Streamlit to finish its own Ctrl+C shutdown. + # The launcher waits for Streamlit to finish its own Ctrl+C shutdown, and + # passes SIGINT on in case it was sent to the launcher alone. assert fake.wait_timeouts == [None, 10] - assert fake.sent == [] + assert fake.sent == ([] if sys.platform == "win32" else [signal.SIGINT]) + + +def test_ctrl_c_terminates_streamlit_that_does_not_stop(monkeypatch) -> None: + class StuckPopen(FakePopen): + def exit_code(self) -> int: + if len(self.wait_timeouts) == 1: + raise KeyboardInterrupt + if self.wait_timeouts[-1] is not None: + raise subprocess.TimeoutExpired(self.command, self.wait_timeouts[-1]) + return -signal.SIGTERM + + result, fake = _capture_launch(monkeypatch, popen=StuckPopen) + assert result.exit_code == 0 + assert fake.wait_timeouts == [None, 10, None] + assert fake.sent == ([] if sys.platform == "win32" else [signal.SIGINT]) + [signal.SIGTERM] def test_streamlit_script_directory_cannot_shadow_modules() -> None: From 9d539d2a8f018a9030640ab7e15264d56bd8a37e Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 11:19:02 -0700 Subject: [PATCH 39/40] fix(dashboard): detect pruned non-best agents whose conditions were compacted Since #77 the embedded-size budget compacts a non-best agent's conditions (status, errors and attempt counts) instead of dropping them, so requiring empty conditions no longer recognized a pruned agent. Its canonical row then read "0 with / 0 without" with a generic reason. Detect pruning from the truncation marker and the emptied trial lists only, which covers both report shapes. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- src/skillevaluator/reporting/dashboard_data.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/skillevaluator/reporting/dashboard_data.py b/src/skillevaluator/reporting/dashboard_data.py index 3f1be83ff..98e430bfd 100644 --- a/src/skillevaluator/reporting/dashboard_data.py +++ b/src/skillevaluator/reporting/dashboard_data.py @@ -330,11 +330,11 @@ def parse_dashboard_report(payload: Any, source: str) -> DashboardData: continue conditions = _dict(agent.get("conditions")) # The embedded-size budget empties a non-best agent's trial details - # but keeps its declared counts. + # but keeps its declared counts. Older reports also dropped its + # conditions; current ones keep a compacted copy. details_pruned = ( non_best_pruned and str(name) != str(report.get("best_agent") or "") - and not conditions and not agent.get("trials") and not agent.get("trials_baseline") ) From d2b0656e07928bf4aca1c32f75911c7bc8a29fc2 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Fri, 16 Oct 2026 11:47:52 -0700 Subject: [PATCH 40/40] test(dashboard): fake only Streamlit's module lookup in CLI tests The launcher tests replaced importlib.util.find_spec for every module with a stub that returned a bare object(). Under coverage, a sys.path change makes coverage look up the measured package through find_spec while the CLI runs; it got the stub, raised AttributeError ('object' has no attribute 'origin'), and the command exited 1. The Python 3.12 CI job (serial, with coverage) failed test_launch_uses_loopback_and_literal_absolute_paths and test_explicit_port_failure_has_hint this way. Fake only the "streamlit" lookup, with a real ModuleSpec, and pass every other name through. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- tests/reporting/test_dashboard_cli.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/reporting/test_dashboard_cli.py b/tests/reporting/test_dashboard_cli.py index 9ab48a68e..174d57b96 100644 --- a/tests/reporting/test_dashboard_cli.py +++ b/tests/reporting/test_dashboard_cli.py @@ -5,6 +5,7 @@ from __future__ import annotations +import importlib.machinery import importlib.util import os import signal @@ -42,10 +43,20 @@ def terminate(self) -> None: self.send_signal(signal.SIGTERM) +def _fake_streamlit_spec(monkeypatch, spec: importlib.machinery.ModuleSpec | None) -> None: + """Fake only Streamlit's lookup; coverage and pytest call find_spec for other modules.""" + find_spec = importlib.util.find_spec + monkeypatch.setattr( + dashboard.importlib.util, + "find_spec", + lambda name, *args, **kwargs: spec if name == "streamlit" else find_spec(name, *args, **kwargs), + ) + + def _capture_launch(monkeypatch, *args: str, popen: type[FakePopen] = FakePopen): """Invoke the dashboard command with Streamlit present and the child process faked.""" launched: list[FakePopen] = [] - monkeypatch.setattr(dashboard.importlib.util, "find_spec", lambda _name: object()) + _fake_streamlit_spec(monkeypatch, importlib.machinery.ModuleSpec("streamlit", None)) def start(command, **kwargs): launched.append(popen(command, **kwargs)) @@ -67,7 +78,7 @@ def test_dashboard_help_and_input_validation() -> None: def test_missing_extra_has_actionable_error(monkeypatch) -> None: - monkeypatch.setattr(dashboard.importlib.util, "find_spec", lambda _name: None) + _fake_streamlit_spec(monkeypatch, None) result = CliRunner().invoke(cli, ["dashboard"]) assert result.exit_code == 1 assert "skillevaluator[all,dashboard]" in result.output