Skip to content

Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.

fix: target dependency coverage and Tier 3 result integrity (#196)

Narendran Raghavan67629d3df2a5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 36c73254..386b4669 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -94,7 +94,31 @@ All notable changes to SkillEvaluator are documented in this file.
records its scoring policy. Reports separately expose measured token and
agent execution-time differences with complete matching-arm coverage, while
efficiency continues to measure routing and productive tool use.
-
+- Include schema-valid ATIF message content parts in final answers, conversation
+ summaries, and judge evidence references in the host and Harbor verifier.
+ Image and audio parts use markers without exposing their source paths.
+- Preserve scored Harbor trials when agent answers mention authentication errors
+ and per-step token usage is present but aggregate ATIF token metrics are absent
+ or zero. Explicit runtime exceptions and error events still invalidate trials.
+- Safety-classifier refusals, content filters and output-token truncation are
+ detected instead of being read as empty or malformed output. `--llm-verify`
+ and rubric evaluation report the cause, and `--llm-verify` keeps the
+ complete verdicts of a truncated reply. Claude 5.5 or later requests to the
+ native Claude API use server-side fallback to Claude Opus 4.8. In the Harbor
+ verifier, Bedrock retries a filtered Claude 5.5 reply on Claude Opus 4.8, and
+ a refusal or empty judge reply moves on to the next
+ `LLM_JUDGE_FALLBACK_MODELS` entry.
+- The Harbor verifier's last-resort judge model follows the selected provider.
+ With no judge or chat model configured, it used to request an OpenAI model
+ from Anthropic, Bedrock, NVIDIA Build and gateways. The unused host-side
+ `llm_judge.DEFAULT_JUDGE_MODEL` constant is removed.
+- Fixed Docker Codex and Claude Code setup wasting its timeout installing
+ distribution Node/npm before Harbor's own installers. Native, gateway Codex,
+ and NVIDIA Build agents now provision Node/npm only on the installer branches
+ that need them, while preserving installed-agent and version-pin checks.
+- Preserved multiline skill descriptions when saving and loading Tier 2
+ embedding catalogs. Descriptions can contain line breaks and tabs, while
+ catalog identifiers and other control characters remain strictly validated.
- Brought the published documentation in line with 0.5.0. It now covers how
standard grading builds judge evidence and rebuilds trajectories from
OpenCode and Codex logs, structured judge output and retries, the evidence
diff --git a/src/skillevaluator/tier3/harbor/report.py b/src/skillevaluator/tier3/harbor/report.py
index ed4049ce..64be5bc9 100644
--- a/src/skillevaluator/tier3/harbor/report.py
+++ b/src/skillevaluator/tier3/harbor/report.py
@@ -397,6 +397,16 @@ def _dedupe_report_reasons(reasons: list[Any]) -> list[str]:
return deduped
+def _applicable_accuracy_criteria(detail: dict[str, Any]) -> dict[Any, Any]:
+ """Return accuracy verdicts minus criteria the verifier excluded from the score."""
+ criteria = detail.get("criteria")
+ if not isinstance(criteria, dict):
+ return {}
+ raw_excluded = detail.get("excluded_criteria")
+ excluded = {name for name in raw_excluded if isinstance(name, str)} if isinstance(raw_excluded, list) else set()
+ return {name: verdict for name, verdict in criteria.items() if name not in excluded}
+
+
def _collect_fail_reasons(metric: str, trials: list[dict[str, Any]]) -> list[str]:
"""Extract human-readable failure reasons from trial details."""
reasons: list[Any] = []
@@ -415,8 +425,7 @@ def _collect_fail_reasons(metric: str, trials: list[dict[str, Any]]) -> list[str
reasons.append(reason)
elif metric == "accuracy":
- criteria = detail.get("criteria")
- criteria = criteria if isinstance(criteria, dict) else {}
+ criteria = _applicable_accuracy_criteria(detail)
for crit, passed in criteria.items():
if not passed:
reasons.append(f"{str(crit)[:480]} failed")
@@ -499,8 +508,7 @@ def _collect_pass_reasons(metric: str, trials: list[dict[str, Any]]) -> list[str
reasons.append(reason)
elif metric == "accuracy":
- criteria = detail.get("criteria")
- criteria = criteria if isinstance(criteria, dict) else {}
+ criteria = _applicable_accuracy_criteria(detail)
passed = [k for k, v in criteria.items() if v]
if passed:
reasons.append(f"Passed: {', '.join(str(item) for item in passed)[:504]}")
diff --git a/src/skillevaluator/validators/dependencies.py b/src/skillevaluator/validators/dependencies.py
index 9dd7d8f9..f3f1cada 100644
--- a/src/skillevaluator/validators/dependencies.py
+++ b/src/skillevaluator/validators/dependencies.py
@@ -142,7 +142,7 @@ class DependencySecurityValidator(ValidatorBase):
with SecureRoot(pyproject.parent) as root:
raw, _ = root.read_bytes(Path(pyproject.name), 1024 * 1024)
data = tomllib.loads(raw.decode("utf-8"))
- except (OSError, SecurePathError, UnicodeError, tomllib.TOMLDecodeError):
+ except (OSError, SecurePathError, UnicodeError, tomllib.TOMLDecodeError, RecursionError):
incomplete("cannot read a bounded regular TOML file")
return result
@@ -180,7 +180,7 @@ class DependencySecurityValidator(ValidatorBase):
if not isinstance(declaration, str) or "\n" in declaration or "\r" in declaration:
raise InvalidRequirement("invalid declaration")
requirement = Requirement(declaration)
- except InvalidRequirement:
+ except (InvalidRequirement, RecursionError):
incomplete(f"{label}: invalid requirement")
continue
if requirement.url:
@@ -189,7 +189,13 @@ class DependencySecurityValidator(ValidatorBase):
if requirement.marker:
# Audit every optional group, evaluating `extra` in its group context.
extra = group.removeprefix("optional group ") if group.startswith("optional group ") else ""
- if not requirement.marker.evaluate({"extra": extra}):
+ try:
+ # Unevaluable markers raise ValueError subclasses such as UndefinedComparison.
+ marker_matches = requirement.marker.evaluate({"extra": extra})
+ except (ValueError, RecursionError):
+ incomplete(f"{label}: environment marker cannot be evaluated")
+ continue
+ if not marker_matches:
result.add_message(f"pyproject.toml: {label} skipped (marker does not match scanner platform)")
continue
specifiers = list(requirement.specifier)
@@ -209,61 +215,77 @@ class DependencySecurityValidator(ValidatorBase):
incomplete(f"pip-audit not installed. {Tools.pip_audit.get_install_hint()}")
return result
- with tempfile.TemporaryDirectory(prefix="skillevaluator-dependencies-") as temporary_dir:
- requirements = Path(temporary_dir) / "requirements.txt"
- requirements.write_text("\n".join(sorted(pins)) + "\n", encoding="utf-8")
- tool_result = Tools.pip_audit.run(
- [
- "-r",
- str(requirements),
- "--no-deps",
- "--disable-pip",
- "--format",
- "json",
- "--progress-spinner",
- "off",
- ],
- timeout=180,
- )
+ # pip-audit rejects a requirements file that names one package twice, and
+ # optional groups may pin different versions of one package. Audit each
+ # version of a package in its own batch so neither pin is dropped.
+ batches: list[list[str]] = []
+ batch_counts: dict[str, int] = {}
+ for pin in sorted(pins):
+ name = canonicalize_name(Requirement(pin).name)
+ index = batch_counts.get(name, 0)
+ batch_counts[name] = index + 1
+ if index == len(batches):
+ batches.append([])
+ batches[index].append(pin)
+
+ audited: list[str] = []
+ for batch in batches:
+ with tempfile.TemporaryDirectory(prefix="skillevaluator-dependencies-") as temporary_dir:
+ requirements = Path(temporary_dir) / "requirements.txt"
+ requirements.write_text("\n".join(batch) + "\n", encoding="utf-8")
+ tool_result = Tools.pip_audit.run(
+ [
+ "-r",
+ str(requirements),
+ "--no-deps",
+ "--disable-pip",
+ "--format",
+ "json",
+ "--progress-spinner",
+ "off",
+ ],
+ timeout=180,
+ )
- if tool_result.error_message or tool_result.exit_code not in (0, 1):
- incomplete("pip-audit did not complete successfully")
- return result
- try:
- audit = json.loads(tool_result.stdout)
- dependencies = audit if isinstance(audit, list) else audit["dependencies"]
- if not isinstance(dependencies, list):
- raise ValueError("invalid inventory")
- returned_pins = set()
- for dep in dependencies:
- if not isinstance(dep, dict) or not isinstance(dep.get("vulns"), list):
- raise ValueError("invalid dependency")
- returned_pins.add((canonicalize_name(dep["name"]), Version(dep["version"])))
- if any(
- not isinstance(vuln, dict)
- or not isinstance(vuln.get("id"), str)
- or not isinstance(vuln.get("fix_versions", []), list)
- or any(not isinstance(version, str) for version in vuln.get("fix_versions", []))
- or ("severity" in vuln and not isinstance(vuln["severity"], str))
- or not isinstance(vuln.get("aliases", []), list)
- or any(not isinstance(alias, str) for alias in vuln.get("aliases", []))
- for vuln in dep["vulns"]
- ):
- raise ValueError("invalid advisory")
- expected_pins = {
- (canonicalize_name(requirement.name), Version(next(iter(requirement.specifier)).version))
- for pin in pins
- for requirement in [Requirement(pin)]
- }
- if returned_pins != expected_pins:
- raise ValueError("incomplete inventory")
- if tool_result.exit_code == 1 and not any(dep["vulns"] for dep in dependencies):
- raise ValueError("unexpected finding exit")
- except (KeyError, TypeError, ValueError, RecursionError):
- incomplete("pip-audit returned incomplete or invalid target evidence")
- return result
- self._process_pip_audit(tool_result.stdout, result, pyproject.name)
- result.metadata["dependency_coverage"]["audited_pins"] = sorted(pins)
+ if tool_result.error_message or tool_result.exit_code not in (0, 1):
+ incomplete("pip-audit did not complete successfully")
+ return result
+ try:
+ audit = json.loads(tool_result.stdout)
+ dependencies = audit if isinstance(audit, list) else audit["dependencies"]
+ if not isinstance(dependencies, list):
+ raise ValueError("invalid inventory")
+ returned_pins = set()
+ for dep in dependencies:
+ if not isinstance(dep, dict) or not isinstance(dep.get("vulns"), list):
+ raise ValueError("invalid dependency")
+ returned_pins.add((canonicalize_name(dep["name"]), Version(dep["version"])))
+ if any(
+ not isinstance(vuln, dict)
+ or not isinstance(vuln.get("id"), str)
+ or not isinstance(vuln.get("fix_versions", []), list)
+ or any(not isinstance(version, str) for version in vuln.get("fix_versions", []))
+ or ("severity" in vuln and not isinstance(vuln["severity"], str))
+ or not isinstance(vuln.get("aliases", []), list)
+ or any(not isinstance(alias, str) for alias in vuln.get("aliases", []))
+ for vuln in dep["vulns"]
+ ):
+ raise ValueError("invalid advisory")
+ expected_pins = {
+ (canonicalize_name(requirement.name), Version(next(iter(requirement.specifier)).version))
+ for pin in batch
+ for requirement in [Requirement(pin)]
+ }
+ if returned_pins != expected_pins:
+ raise ValueError("incomplete inventory")
+ if tool_result.exit_code == 1 and not any(dep["vulns"] for dep in dependencies):
+ raise ValueError("unexpected finding exit")
+ except (KeyError, TypeError, ValueError, RecursionError):
+ incomplete("pip-audit returned incomplete or invalid target evidence")
+ return result
+ self._process_pip_audit(tool_result.stdout, result, pyproject.name)
+ audited.extend(batch)
+ result.metadata["dependency_coverage"]["audited_pins"] = sorted(audited)
return result
diff --git a/src/skillevaluator/validators/security.py b/src/skillevaluator/validators/security.py
index 133cd9b4..122daf8a 100644
--- a/src/skillevaluator/validators/security.py
+++ b/src/skillevaluator/validators/security.py
@@ -347,7 +347,7 @@ def _comment_line_numbers(file_path: Path, lines: list[str]) -> frozenset[int]:
return _yaml_comment_line_numbers(lines)
if suffix == ".sh":
return _shell_comment_line_numbers(lines)
- if suffix in {".md", ".markdown"}:
+ if suffix in {".md", ".mdc", ".markdown"}:
return _markdown_comment_line_numbers(lines)
return _leading_hash_or_slash_comment_lines(lines)
diff --git a/tests/tier3/test_judge_result_semantics.py b/tests/tier3/test_judge_result_semantics.py
index 3fda9fcc..9a34da8b 100644
--- a/tests/tier3/test_judge_result_semantics.py
+++ b/tests/tier3/test_judge_result_semantics.py
@@ -15,6 +15,7 @@ from typing import Any
import pytest
from skillevaluator.tier3.eval_core import llm_judge
+from skillevaluator.tier3.harbor import report
_TEMPLATE = (
Path(__file__).resolve().parents[2] / "src" / "skillevaluator" / "tier3" / "harbor" / "templates" / "eval.py"
@@ -89,6 +90,27 @@ def test_negative_rubric_does_not_rewrite_supplied_evidence(module, monkeypatch)
assert evidence in calls[0]
[email protected]("module", [llm_judge, eval_template])
+def test_report_reasons_omit_excluded_accuracy_criteria(module, monkeypatch):
+ criteria = dict.fromkeys(_CRITERIA, True)
+ criteria["SKILL_IDENTIFIED"] = False
+ criteria["ACTION_CORRECT"] = False
+ response = json.dumps({"criteria": criteria, "score": 0.6, "reason": "declined correctly"})
+ monkeypatch.setattr(module, "call_public_llm", _pair_script([(response, None)], []))
+ detail = module.judge_accuracy("question", "answer", "evidence", skill_identification_applicable=False)
+ reward = {
+ "entry_id": "negative-001",
+ **dict.fromkeys(("security", "skill_execution", "skill_efficiency", "goal_accuracy", "behavior_check"), 1.0),
+ "accuracy": detail["score"],
+ "details": {"accuracy": detail},
+ }
+ findings = {finding["metric"]: finding for finding in report._extract_findings([reward])}
+ reasons = findings["accuracy"]["reasons"]
+ assert findings["accuracy"]["score"] == 0.75
+ assert "ACTION_CORRECT failed" in reasons
+ assert not any("SKILL_IDENTIFIED" in reason for reason in reasons)
+
+
@pytest.fixture(params=["shared", "template"])
def judge_module(request: pytest.FixtureRequest) -> ModuleType:
return llm_judge if request.param == "shared" else eval_template
diff --git a/tests/validators/test_pii_grouping.py b/tests/validators/test_pii_grouping.py
index 52fe4fe8..df17d08d 100644
--- a/tests/validators/test_pii_grouping.py
+++ b/tests/validators/test_pii_grouping.py
@@ -41,16 +41,25 @@ class TestPiiGroupingByValue:
@pytest.mark.parametrize("as_file", [True, False])
def test_mdc_rule_and_workflow_pii_is_scanned(self, tmp_path, as_file):
rule = tmp_path / "instructions.mdc"
- rule.write_text("---\ndescription: Contact rule\n---\nContact [email protected].\n")
+ rule.write_text("---\ndescription: Contact rule\n---\nContact [email protected].\n", encoding="utf-8")
target = rule if as_file else tmp_path
result = SecurityValidator().validate_pii_only(target)
assert "[email protected]" in {f.metadata.get("matched_value") for f in _email_findings(result)}
def test_clean_mdc_has_no_pii(self, tmp_path):
rule = tmp_path / "clean.mdc"
- rule.write_text("Respond briefly and use the configured contact directory.\n")
+ rule.write_text("Respond briefly and use the configured contact directory.\n", encoding="utf-8")
assert SecurityValidator().validate_pii_only(rule).passed
+ def test_mdc_headings_and_slash_lines_are_scanned_like_markdown(self, tmp_path):
+ rule = tmp_path / "escalation.mdc"
+ rule.write_text(
+ "---\ndescription: Escalation rule\n---\n# Escalate to [email protected]\n// Owner: [email protected]\n",
+ encoding="utf-8",
+ )
+ found = {f.metadata.get("matched_value") for f in _email_findings(SecurityValidator().validate_pii_only(rule))}
+ assert {"[email protected]", "[email protected]"} <= found
+
def test_repeated_value_collapses_to_one_finding(self, skill_with_repeated_emails):
result = SecurityValidator().validate_pii_only(skill_with_repeated_emails)
diff --git a/tests/validators/test_target_dependencies.py b/tests/validators/test_target_dependencies.py
index 9235e8d5..8a5b903a 100644
--- a/tests/validators/test_target_dependencies.py
+++ b/tests/validators/test_target_dependencies.py
@@ -13,15 +13,19 @@ from skillevaluator.validators.dependencies import DependencySecurityValidator
def audit(tmp_path, text, monkeypatch, *, exit_code=0, output=None, available=True):
target = tmp_path / "pyproject.toml"
- target.write_text(text)
+ target.write_text(text, encoding="utf-8")
calls = []
monkeypatch.setattr(type(Tools.pip_audit), "is_available", property(lambda _self: available))
def run(args, **kwargs):
assert "--local" not in args
assert "--no-deps" in args and "--disable-pip" in args
- requirements = Path(args[args.index("-r") + 1]).read_text().splitlines()
+ requirements = Path(args[args.index("-r") + 1]).read_text(encoding="utf-8").splitlines()
calls.extend(requirements)
+ names = [pin.split("==")[0].lower() for pin in requirements]
+ if len(names) != len(set(names)):
+ # Like pip-audit, reject one requirements file that names a package twice.
+ return ToolResult(True, "", "duplicate requirements", 1)
dependencies = [
{"name": pin.split("==")[0].lower(), "version": pin.split("==")[1], "vulns": []} for pin in requirements
]
@@ -45,6 +49,17 @@ def test_audits_target_pins_and_optional_groups(tmp_path, monkeypatch):
assert result.metadata["dependency_coverage"]["transitive_dependencies"] == "not audited"
+def test_conflicting_group_pins_are_each_audited(tmp_path, monkeypatch):
+ result, calls = audit(
+ tmp_path,
+ '[project]\ndependencies=["idna==3.10"]\n[project.optional-dependencies]\nlegacy=["idna==3.7"]',
+ monkeypatch,
+ )
+ assert result.status == "passed"
+ assert sorted(calls) == ["idna==3.10", "idna==3.7"]
+ assert result.metadata["dependency_coverage"]["audited_pins"] == ["idna==3.10", "idna==3.7"]
+
+
@pytest.mark.parametrize(
"declaration", ["requests>=2", "requests==2.*", "requests @ https://example.com/pkg.whl", "--local", "bad\n--local"]
)
@@ -72,6 +87,21 @@ def test_invalid_or_dynamic_metadata_is_incomplete(tmp_path, monkeypatch, text):
assert not calls
+ "text",
+ [
+ "x = " + "[" * 5000 + "]" * 5000,
+ "[project]\ndependencies=[\"idna==3.10; python_version ~= '3'\"]",
+ '[project]\ndependencies=["idna==3.10; ' + "(" * 3000 + "python_version > '3'" + ")" * 3000 + '"]',
+ ],
+ ids=["deeply-nested-toml", "unevaluable-marker", "deeply-nested-marker"],
+)
+def test_malformed_target_metadata_is_incomplete_not_a_crash(tmp_path, monkeypatch, text):
+ result, calls = audit(tmp_path, text, monkeypatch)
+ assert result.status == "incomplete"
+ assert not calls
+
+
def test_markers_are_explicitly_scoped(tmp_path, monkeypatch):
result, calls = audit(tmp_path, "[project]\ndependencies=[\"idna==3.10; python_version < '2'\"]", monkeypatch)
assert result.status == "passed"