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(rubric): preserve source and complete linked guidance (#254)

Narendran Raghavan26d2b0d02de2
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b6246e1f..b25ba05e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -247,6 +247,7 @@ jobs:
tests/test_harbor_local_sandbox.py
tests/test_harbor_local_mode.py
tests/test_local_mode_contract.py
+ tests/validators/test_rubric_eval.py
tests/test_tier3_progress.py
tests/test_tier3_result_display.py
tests/test_harbor_runtime_preflight.py
@@ -297,6 +298,7 @@ jobs:
tests/embedding
tests/deduplication
tests/validators/test_similarity.py
+ tests/validators/test_rubric_eval.py
tests/reporting
tests/test_cli.py
tests/test_harbor_output_provenance.py
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b5915ee3..b1d975e2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -56,6 +56,15 @@ All notable changes to SkillEvaluator are documented in this file.
### Fixed
+- Rubric evaluation preserves the original `SKILL.md` text without adding YAML
+ separators and includes reachable local Markdown guides under their source
+ paths. Required guidance is collected before optional previews, with cycle
+ detection, secure contained reads, verified file-alias deduplication, a
+ 256-document ceiling, and the existing
+ 3,000-byte per-file / 30,000-byte supplementary limits. Missing, unsafe, or
+ oversized required guidance stops judging without a score or provider request
+ ([#233](https://github.com/NVIDIA/SkillEvaluator/issues/233)).
+
- PII credential findings mask their values and source lines. GitHub CI stages
scanner output privately, redacts recognized credential values from retained
reports and logs, and withholds detailed output when redaction cannot finish.
diff --git a/src/skillevaluator/validators/rubric_eval.py b/src/skillevaluator/validators/rubric_eval.py
index 945f1075..ff8ceaa4 100644
--- a/src/skillevaluator/validators/rubric_eval.py
+++ b/src/skillevaluator/validators/rubric_eval.py
@@ -17,11 +17,13 @@ from __future__ import annotations
import json
import math
import os
+import posixpath
import re
import stat
-from collections import Counter
+from collections import Counter, deque
from pathlib import Path
from typing import Any
+from urllib.parse import unquote, urlsplit
from skillevaluator.constants import (
RUBRIC_CRITERIA,
@@ -30,11 +32,14 @@ from skillevaluator.constants import (
RUBRIC_REASONING_EFFORT,
RUBRIC_REASONING_MAX_TOKENS,
RUBRIC_REASONING_MODEL_MARKERS,
+ SKILL_MANIFEST_VARIANTS,
)
from skillevaluator.inference.client import LLMClient
from skillevaluator.logging_config import get_logger
from skillevaluator.models.result import Finding, Severity, ValidationResult
+from skillevaluator.utils.secure_fs import SecureRoot
from skillevaluator.validators.base import ValidatorBase
+from skillevaluator.validators.markdown import markdown_link_targets, normalized_local_path
logger = get_logger(__name__)
@@ -43,6 +48,7 @@ _CRITERION_PASS_SCORE = 7
_MAX_SKILL_CONTENT_BYTES = 1024 * 1024
_MAX_SUPPLEMENTARY_FILE_BYTES = 3000
_MAX_SUPPLEMENTARY_TOTAL_BYTES = 30000
+_MAX_LINKED_MARKDOWN_FILES = 256
class _UnsafeRubricInputError(ValueError):
@@ -274,8 +280,13 @@ class RubricJudge(LLMClient):
if supplementary:
scripts = supplementary.get("scripts", {})
references = supplementary.get("references", {})
- if scripts or references:
+ linked_markdown = supplementary.get("linked_markdown", {})
+ if scripts or references or linked_markdown:
extra += "Supplementary Skill Content:\n"
+ if linked_markdown:
+ extra += "\nLinked Markdown (paths relative to skill root):\n"
+ for name, content in linked_markdown.items():
+ extra += f"--- {name} ---\n{content}\n\n"
if scripts:
extra += "\nScripts (from scripts/ directory):\n"
for name, content in scripts.items():
@@ -287,7 +298,7 @@ class RubricJudge(LLMClient):
return (
f"Skill Name: {skill_name}\n\n"
- f"SKILL.md Content:\n---\n{skill_content}\n---\n\n"
+ f"SKILL.md Content:\n{skill_content}\n\n"
f"{extra}"
f"Evaluation Criteria:\n{criteria_text}\n\n"
f"For each criterion, evaluate whether the skill meets the requirement.\n"
@@ -339,8 +350,11 @@ def _collect_supplementary_content(
skill_path: Path,
max_bytes_per_file: int = _MAX_SUPPLEMENTARY_FILE_BYTES,
max_total_bytes: int = _MAX_SUPPLEMENTARY_TOTAL_BYTES,
+ *,
+ manifest: Path | None = None,
+ skill_content: str | None = None,
) -> dict[str, dict[str, str]]:
- """Collect contained regular supplementary files using bounded reads."""
+ """Collect complete linked Markdown before optional bounded previews."""
result: dict[str, dict[str, str]] = {"scripts": {}, "references": {}}
total = 0
try:
@@ -348,6 +362,75 @@ def _collect_supplementary_content(
except OSError as exc:
raise _UnsafeRubricInputError(f"could not resolve skill root {skill_path}: {exc}") from exc
+ if manifest is None:
+ manifest = next(
+ (skill_path / name for name in SKILL_MANIFEST_VARIANTS if os.path.lexists(skill_path / name)), None
+ )
+ linked: dict[str, str] = {}
+ if manifest is not None:
+ if skill_content is None:
+ skill_content, _ = _read_bounded_rubric_file(
+ manifest, skill_root=skill_path, max_bytes=_MAX_SKILL_CONTENT_BYTES, truncate=False
+ )
+ pending = deque([(manifest.relative_to(skill_path).as_posix(), skill_content)])
+ seen = {pending[0][0]}
+ try:
+ manifest_stat = manifest.lstat()
+ # Path-stat identities are comparable on Windows; the secure reader's
+ # returned CRT fstat identity is not. Cached bytes only choose a read
+ # bound: every alias still passes the secure no-follow reader.
+ seen_payloads = (
+ {(manifest_stat.st_dev, manifest_stat.st_ino): skill_content.encode("utf-8")}
+ if manifest_stat.st_ino
+ else {}
+ )
+ with SecureRoot(resolved_root) as reader:
+ while pending:
+ source, content = pending.popleft()
+ for href in markdown_link_targets(content):
+ try:
+ destination = unquote(urlsplit(href).path).replace("\\", "/")
+ except ValueError:
+ continue
+ if posixpath.splitext(destination)[1].lower() not in {".md", ".markdown"}:
+ continue
+ local = normalized_local_path(href, reject_anchors=True)
+ if local is None:
+ continue
+ relative = posixpath.normpath(posixpath.join(posixpath.dirname(source), local))
+ if relative == ".." or relative.startswith("../"):
+ raise _UnsafeRubricInputError(f"linked Markdown escapes the skill root: {relative}")
+ if relative in seen:
+ continue
+ if len(seen) - 1 >= _MAX_LINKED_MARKDOWN_FILES:
+ raise _UnsafeRubricInputError(
+ f"linked Markdown exceeds the maximum of {_MAX_LINKED_MARKDOWN_FILES} documents"
+ )
+ metadata = (resolved_root / relative).lstat()
+ identity = (metadata.st_dev, metadata.st_ino)
+ cached = seen_payloads.get(identity) if metadata.st_ino else None
+ read_limit = (
+ len(cached) if cached is not None else min(max_bytes_per_file, max_total_bytes - total)
+ )
+ payload, _ = reader.read_bytes(Path(relative), read_limit, expected=metadata)
+ seen.add(relative)
+ if cached is not None:
+ if payload != cached:
+ raise _UnsafeRubricInputError(f"linked Markdown changed while collecting: {relative}")
+ continue
+ text = payload.decode("utf-8")
+ linked[relative] = text
+ if metadata.st_ino:
+ seen_payloads[identity] = payload
+ total += len(payload)
+ pending.append((relative, text))
+ except _UnsafeRubricInputError:
+ raise
+ except (OSError, ValueError) as exc:
+ raise _UnsafeRubricInputError(f"could not collect complete linked Markdown: {exc}") from exc
+ if linked:
+ result["linked_markdown"] = linked
+
for subdir, exts in [("scripts", ("*.py", "*.sh")), ("references", ("*.md",))]:
d = skill_path / subdir
if not os.path.lexists(d):
@@ -365,6 +448,8 @@ def _collect_supplementary_content(
raise _UnsafeRubricInputError(f"could not inspect supplementary directory {d}: {exc}") from exc
for ext in exts:
for f in sorted(d.glob(ext)):
+ if f.relative_to(skill_path).as_posix() in linked:
+ continue
if total >= max_total_bytes:
break
read_limit = min(max_bytes_per_file, max_total_bytes - total)
@@ -542,7 +627,7 @@ class RubricEvalValidator(ValidatorBase):
max_bytes=_MAX_SKILL_CONTENT_BYTES,
truncate=False,
)
- supplementary = _collect_supplementary_content(skill_path)
+ supplementary = _collect_supplementary_content(skill_path, manifest=manifest, skill_content=content)
except _UnsafeRubricInputError as exc:
return self._record_judge_failure(
result,
@@ -551,7 +636,7 @@ class RubricEvalValidator(ValidatorBase):
manifest=manifest,
message=f"Unsafe rubric input: {exc}",
check_name="unsafe_skill_input",
- suggestion="Replace symlinks and special files with contained regular UTF-8 files",
+ suggestion="Provide complete linked guidance in contained regular UTF-8 files within the rubric input limits",
)
from rich.console import Console
diff --git a/tests/validators/test_rubric_eval.py b/tests/validators/test_rubric_eval.py
index 201db03e..825637ce 100644
--- a/tests/validators/test_rubric_eval.py
+++ b/tests/validators/test_rubric_eval.py
@@ -21,6 +21,7 @@ from skillevaluator.validators.rubric_eval import (
RubricJudge,
_collect_supplementary_content,
_extract_json,
+ _UnsafeRubricInputError,
)
@@ -89,6 +90,14 @@ class TestRubricJudge:
assert "test-skill" in prompt
assert "This is a test skill" in prompt
+ @pytest.mark.parametrize(
+ "content", ["# Test", "---\nname: demo\n---\n# Test\n", "---\r\nname: demo\r\n---\r\n", ""]
+ )
+ def test_user_prompt_preserves_source_without_added_yaml_separators(self, content):
+ prompt = RubricJudge().create_user_prompt(skill_name="demo", skill_content=content)
+
+ assert f"SKILL.md Content:\n{content}\n\nEvaluation Criteria:" in prompt
+
def test_user_prompt_with_supplementary(self):
judge = RubricJudge()
prompt = judge.create_user_prompt(
@@ -259,6 +268,261 @@ class TestCollectSupplementaryContent:
assert len(result["scripts"]["big.py"]) < 200
+class TestLinkedRubricGuidance:
+ def test_collects_transitive_guides_with_cycles_and_distinct_source_paths(self, tmp_path):
+ root = _write_skill(tmp_path)
+ (root / "SKILL.md").write_text(
+ "[Guide][g]\n\n[g]: GUIDE.md#intro\n\n"
+ '<a href="guides/a/README.MD">A</a>\n'
+ "[Space](guides/with%20space.markdown?version=1#section)\n"
+ "![Image](missing.md)\n`[Example](missing.md)`\n"
+ "```md\n[Example](missing.md)\n```\n[Web](https://example.com/missing.md)\n"
+ "[Asset](missing.json)\n[Anchor](#intro)"
+ )
+ (root / "guides/a").mkdir(parents=True)
+ (root / "guides/b").mkdir()
+ guide = "Required guidance. [A](guides/a/README.MD#again)"
+ first = "A guidance. [B](../b/README.md?version=1)"
+ second = "B guidance. [Root](../../GUIDE.md) [Skill](../../SKILL.md)"
+ (root / "GUIDE.md").write_text(guide)
+ (root / "guides/a/README.MD").write_text(first)
+ (root / "guides/b/README.md").write_text(second)
+ (root / "guides/with space.markdown").write_text("Space guidance")
+
+ collected = _collect_supplementary_content(root)
+
+ assert collected["linked_markdown"] == {
+ "GUIDE.md": guide,
+ "guides/a/README.MD": first,
+ "guides/b/README.md": second,
+ "guides/with space.markdown": "Space guidance",
+ }
+
+ def test_required_guidance_gets_budget_before_optional_previews(self, tmp_path):
+ root = _write_skill(tmp_path)
+ (root / "SKILL.md").write_text("[Guide](GUIDE.md)")
+ (root / "GUIDE.md").write_text("required")
+ (root / "scripts").mkdir()
+ (root / "scripts/main.py").write_text("optional" * 100)
+
+ collected = _collect_supplementary_content(root, max_bytes_per_file=100, max_total_bytes=8)
+
+ assert collected["linked_markdown"] == {"GUIDE.md": "required"}
+ assert collected["scripts"] == {}
+
+ def test_linked_reference_is_not_duplicated_as_optional_preview(self, tmp_path):
+ root = _write_skill(tmp_path)
+ (root / "SKILL.md").write_text("[Guide](references/guide.md)")
+ (root / "references").mkdir()
+ (root / "references/guide.md").write_text("required")
+
+ collected = _collect_supplementary_content(root, max_total_bytes=8)
+
+ assert collected["linked_markdown"] == {"references/guide.md": "required"}
+ assert collected["references"] == {}
+
+ def test_exact_utf8_budget_preserves_complete_required_document(self, tmp_path):
+ root = _write_skill(tmp_path)
+ (root / "SKILL.md").write_text("[Guide](GUIDE.md)")
+ (root / "GUIDE.md").write_text("π", encoding="utf-8")
+
+ collected = _collect_supplementary_content(root, max_bytes_per_file=2, max_total_bytes=2)
+
+ assert collected["linked_markdown"] == {"GUIDE.md": "π"}
+
+ @pytest.mark.parametrize(("per_file", "total"), [(1, 10), (10, 1)])
+ def test_required_utf8_content_is_never_truncated(self, tmp_path, per_file, total):
+ root = _write_skill(tmp_path)
+ (root / "SKILL.md").write_text("[Guide](GUIDE.md)")
+ (root / "GUIDE.md").write_text("π", encoding="utf-8")
+
+ with pytest.raises(_UnsafeRubricInputError):
+ _collect_supplementary_content(root, max_bytes_per_file=per_file, max_total_bytes=total)
+
+ @pytest.mark.parametrize(
+ "case",
+ [
+ "missing",
+ "escape",
+ "encoded_escape",
+ "invalid_utf8",
+ "oversized",
+ "total_budget",
+ "symlink",
+ "ancestor_symlink",
+ "hardlink",
+ "directory",
+ "fifo",
+ ],
+ )
+ def test_incomplete_required_guidance_stops_before_judge(self, tmp_path, case):
+ root = _write_skill(tmp_path)
+ target = root / "GUIDE.md"
+ link = "GUIDE.md"
+ if case == "escape":
+ link = "../outside.md"
+ (tmp_path / "outside.md").write_text("outside")
+ elif case == "encoded_escape":
+ link = "%2e%2e%5coutside.md"
+ (tmp_path / "outside.md").write_text("outside")
+ elif case == "invalid_utf8":
+ target.write_bytes(b"\xff")
+ elif case == "oversized":
+ target.write_text("x" * 3001)
+ elif case == "total_budget":
+ for index in range(11):
+ (root / f"guide{index}.md").write_text("x" * 3000)
+ (root / "SKILL.md").write_text("\n".join(f"[Guide](guide{i}.md)" for i in range(11)))
+ elif case == "symlink":
+ (root / "actual.md").write_text("guidance")
+ target.symlink_to(root / "actual.md")
+ elif case == "ancestor_symlink":
+ (tmp_path / "outside").mkdir()
+ (tmp_path / "outside/guide.md").write_text("outside")
+ (root / "docs").symlink_to(tmp_path / "outside", target_is_directory=True)
+ link = "docs/guide.md"
+ elif case == "hardlink":
+ (tmp_path / "outside.md").write_text("outside")
+ os.link(tmp_path / "outside.md", target)
+ elif case == "directory":
+ target.mkdir()
+ elif case == "fifo":
+ if not hasattr(os, "mkfifo"):
+ pytest.skip("FIFO creation unavailable")
+ os.mkfifo(target)
+ if case != "total_budget":
+ (root / "SKILL.md").write_text(f"[Guide]({link})")
+
+ with patch.object(RubricJudge, "process") as judge:
+ result = RubricEvalValidator().validate(root)
+
+ judge.assert_not_called()
+ assert not result.passed
+ assert result.metadata["rubric_eval"]["execution_status"] == "failed"
+ assert result.metadata["rubric_eval"]["overall_score"] is None
+ assert any(f.check_name == "unsafe_skill_input" for f in result.findings)
+
+ def test_empty_document_graph_is_bounded_before_judging(self, tmp_path, monkeypatch):
+ from skillevaluator.validators import rubric_eval
+
+ root = _write_skill(tmp_path)
+ (root / "SKILL.md").write_text("[A](A.md) [B](B.md) [C](C.md)")
+ for name in ("A.md", "B.md", "C.md"):
+ (root / name).write_text("")
+ monkeypatch.setattr(rubric_eval, "_MAX_LINKED_MARKDOWN_FILES", 2, raising=False)
+
+ with patch.object(RubricJudge, "process") as judge:
+ result = RubricEvalValidator().validate(root)
+
+ judge.assert_not_called()
+ assert result.metadata["rubric_eval"]["execution_status"] == "failed"
+ assert result.metadata["rubric_eval"]["overall_score"] is None
+
+ def test_manifest_case_alias_cycle_does_not_apply_supplementary_size_limit(self, tmp_path):
+ root = _write_skill(tmp_path)
+ (root / "SKILL.md").write_text("[Guide](guide.md)\n" + "x" * 3100)
+ alias = root / "skill.md"
+ if not alias.exists() or not alias.samefile(root / "SKILL.md"):
+ pytest.skip("requires a case-insensitive filesystem")
+ (root / "guide.md").write_text("[Root](skill.md)")
+
+ collected = _collect_supplementary_content(root)
+
+ assert collected["linked_markdown"] == {"guide.md": "[Root](skill.md)"}
+
+ def test_guide_case_aliases_do_not_consume_budget_twice(self, tmp_path):
+ root = _write_skill(tmp_path)
+ (root / "SKILL.md").write_text("[First](GUIDE.md) [Again](guide.md)")
+ (root / "GUIDE.md").write_text("required")
+ alias = root / "guide.md"
+ if not alias.exists() or not alias.samefile(root / "GUIDE.md"):
+ pytest.skip("requires a case-insensitive filesystem")
+
+ collected = _collect_supplementary_content(root, max_total_bytes=8)
+
+ assert collected["linked_markdown"] == {"GUIDE.md": "required"}
+
+ def test_case_sensitive_guides_keep_distinct_evidence(self, tmp_path):
+ root = _write_skill(tmp_path)
+ (root / "SKILL.md").write_text("[Upper](GUIDE.md) [Lower](guide.md)")
+ (root / "GUIDE.md").write_text("UPPER")
+ (root / "guide.md").write_text("lower")
+ if (root / "GUIDE.md").samefile(root / "guide.md"):
+ pytest.skip("requires a case-sensitive filesystem")
+
+ assert _collect_supplementary_content(root)["linked_markdown"] == {"GUIDE.md": "UPPER", "guide.md": "lower"}
+
+ @pytest.mark.parametrize("unsafe_alias", ["ancestor_symlink", "hardlink"])
+ def test_known_manifest_identity_does_not_bypass_unsafe_path_rejection(self, tmp_path, unsafe_alias):
+ root = _write_skill(tmp_path)
+ (root / "SKILL.md").write_text("[Guide](guide.md)")
+ if unsafe_alias == "ancestor_symlink":
+ (root / "guide.md").write_text("[Alias](alias/SKILL.md)")
+ (root / "alias").symlink_to(root, target_is_directory=True)
+ else:
+ (root / "guide.md").write_text("[Alias](COPY.md)")
+ os.link(root / "SKILL.md", root / "COPY.md")
+ with patch.object(RubricJudge, "process") as judge:
+ result = RubricEvalValidator().validate(root)
+
+ judge.assert_not_called()
+ assert result.metadata["rubric_eval"]["execution_status"] == "failed"
+ assert result.metadata["rubric_eval"]["overall_score"] is None
+
+ @pytest.mark.parametrize("line_ending", [pytest.param("\n", id="lf"), pytest.param("\r\n", id="crlf")])
+ def test_case_alias_with_changed_manifest_bytes_is_rejected(self, tmp_path, line_ending):
+ root = _write_skill(tmp_path)
+ source = "[Guide](guide.md)\nOriginal source".replace("\n", line_ending)
+ manifest = root / "SKILL.md"
+ manifest.write_bytes(source.replace("Original", "Modified").encode("utf-8"))
+ if not (root / "skill.md").exists() or not (root / "skill.md").samefile(manifest):
+ pytest.skip("requires a case-insensitive filesystem")
+ (root / "guide.md").write_text("[Root](skill.md)")
+
+ with pytest.raises(_UnsafeRubricInputError, match="changed while collecting"):
+ _collect_supplementary_content(root, manifest=manifest, skill_content=source)
+
+ @pytest.mark.parametrize("href", ["%2Fimages/logo.png", "%2Fassets/data.json", "%2e%2e%5cassets/data.json"])
+ def test_non_markdown_assets_do_not_block_rubric_judging(self, tmp_path, href):
+ root = _write_skill(tmp_path)
+ (root / "SKILL.md").write_text(f"[Asset]({href})")
+ response = json.dumps({"checks": _complete_checks(), "score": 90, "overall_pass": True, "summary": "ok"})
+ with patch.object(RubricJudge, "completions", return_value=response) as provider:
+ result = RubricEvalValidator().validate(root)
+
+ assert result.metadata["rubric_eval"]["execution_status"] == "succeeded"
+ assert result.metadata["rubric_eval"]["overall_score"] == 90
+ assert provider.call_count == 1
+
+ def test_encoded_absolute_markdown_remains_blocked_before_judging(self, tmp_path):
+ root = _write_skill(tmp_path)
+ (root / "SKILL.md").write_text("[Guide](%2Fdocs/GUIDE.md)")
+ with patch.object(RubricJudge, "process") as judge:
+ result = RubricEvalValidator().validate(root)
+
+ judge.assert_not_called()
+ assert result.metadata["rubric_eval"]["execution_status"] == "failed"
+ assert result.metadata["rubric_eval"]["overall_score"] is None
+
+ @pytest.mark.parametrize("line_ending", [pytest.param("\n", id="lf"), pytest.param("\r\n", id="crlf")])
+ def test_successful_validator_sends_source_and_complete_guidance_to_provider(self, tmp_path, line_ending):
+ root = _write_skill(tmp_path)
+ source = "---\nname: demo\ndescription: demo\n---\n[Guide](GUIDE.md)\n".replace("\n", line_ending)
+ (root / "SKILL.md").write_bytes(source.encode("utf-8"))
+ (root / "GUIDE.md").write_text("Required guidance")
+ response = json.dumps({"checks": _complete_checks(), "score": 90, "overall_pass": True, "summary": "ok"})
+ with patch.object(RubricJudge, "completions", return_value=response) as provider:
+ result = RubricEvalValidator().validate(root)
+
+ assert result.metadata["rubric_eval"]["execution_status"] == "succeeded"
+ assert result.metadata["rubric_eval"]["overall_score"] == 90
+ prompt = provider.call_args.args[1]
+ assert f"SKILL.md Content:\n{source}\n\n" in prompt
+ assert "Linked Markdown (paths relative to skill root):" in prompt
+ assert "--- GUIDE.md ---\nRequired guidance" in prompt
+ assert (root / "SKILL.md").read_bytes() == source.encode("utf-8")
+
+
class TestRubricEvalValidator:
def test_no_skills_found_records_failed_execution_status(self, tmp_path):
validator = RubricEvalValidator()