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.

feat(tier3): declare deterministic checks in datasets without a custom grader (#403)

Christopher Kevinf6304e516763
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9fc28387..0b4172de 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,8 @@ All notable changes to SkillEvaluator are documented in this file.
### Added
+- Tier 3 datasets can declare deterministic behavior checks for script invocation and success, workspace files, and final-response text.
+
- `tier3 import-metrics` accepts versioned, normalized per-case custom scores
from external evaluations and writes clearly labeled JSON/Markdown reports.
Imports validate identities, metric metadata and values, retain declared
@@ -22,7 +24,6 @@ All notable changes to SkillEvaluator are documented in this file.
negative-case, Wilson interval, and paired-case coverage requirements. Show
the dataset-size status in evaluation, validation, HTML, and BENCHMARK output;
validation coverage notes remain informational.
-
- Experimental `hermes` Tier 3 agent for Docker and native NVIDIA Build routing,
pinned to Hermes v2026.9.24. Includes isolated skill staging, ATIF trajectories,
activation evidence, token accounting and retained execution diagnostics.
diff --git a/docs/eval-datasets.mdx b/docs/eval-datasets.mdx
index 69f3dca0..5b55670b 100644
--- a/docs/eval-datasets.mdx
+++ b/docs/eval-datasets.mdx
@@ -107,6 +107,34 @@ names such as `none.sh` intact.
The dataset file can be named `evals.json`, `evals.jsonl`, `evals.yaml`, or
`evals.yml` — `tier3 evaluate` accepts all four.
+### Deterministic checks
+
+Use the optional `checks` list for requirements that can be evaluated without
+a custom grader or language-model judge. Each check contributes one item to
+`behavior_check`; checks without the required evidence are reported as not
+checked and are excluded from its mean.
+
+```json
+{
+ "checks": [
+ {"type": "script_invoked", "script": "scripts/build.py"},
+ {"type": "command_succeeded", "script": "scripts/build.py"},
+ {"type": "file_exists", "path": "out/report.md"},
+ {"type": "output_matches", "pattern": "Report [0-9]+"},
+ {"type": "output_contains", "text": "Build complete"}
+ ]
+}
+```
+
+`script_invoked` checks command evidence in the trajectory. `command_succeeded`
+also requires recorded success; an invocation without an exit result is not
+checked. `file_exists` inspects the post-run workspace, not a path merely
+mentioned in the response. `output_matches` uses a regular expression and
+`output_contains` uses a literal substring; both inspect the final response.
+Unknown check types and invalid fields are dataset-validation errors. On a
+without-skill baseline, checks for scripts inside the evaluated skill are not
+checked because that skill is not installed.
+
<AccordionGroup>
<Accordion title="Legacy flat format">
Older datasets are a flat array of entries with `question` instead of
diff --git a/docs/reports.mdx b/docs/reports.mdx
index 1447887b..d6bf5c0e 100644
--- a/docs/reports.mdx
+++ b/docs/reports.mdx
@@ -568,7 +568,7 @@ dimensions, each answering one question:
| Security | Is it safe to use? | `security`, from deterministic trace checks |
| Correctness | Is the answer correct? | `accuracy`, from the `judge_accuracy` LLM judge |
| Discoverability | Was the right skill loaded when needed? | `skill_execution`, from deterministic trajectory checks |
-| Effectiveness | Did the skill help complete the task? | `goal_accuracy` and `behavior_check`, from LLM judges |
+| Effectiveness | Did the skill help complete the task? | `goal_accuracy` from an LLM judge; `behavior_check` from its judge and directly evaluated declared checks (checks-only cases make no judge call) |
| Efficiency | Did it avoid wasted tool or skill usage? | `skill_efficiency`, from deterministic trajectory checks |
Tool-efficiency checks classify explicit searches rooted at `/` as wasted work,
diff --git a/docs/tier3-live-evaluation.mdx b/docs/tier3-live-evaluation.mdx
index b8dd4d40..82a87a71 100644
--- a/docs/tier3-live-evaluation.mdx
+++ b/docs/tier3-live-evaluation.mdx
@@ -780,9 +780,11 @@ Tier 3 gate.
With `default` or `default_plus_custom` grading, SkillEvaluator's verifier
grades each trial after the agent finishes. `security`, `skill_execution`, and
-`skill_efficiency` are deterministic trajectory checks. `accuracy`,
-`goal_accuracy`, and `behavior_check` are LLM judges that call the configured
-evaluator provider. `custom_only` runs none of them.
+`skill_efficiency` are deterministic trajectory checks. `accuracy` and
+`goal_accuracy` are LLM judges that call the configured evaluator provider.
+`behavior_check` combines the behavior judge with directly evaluated declared
+checks; a checks-only case makes no behavior judge call. `custom_only` runs
+none of them.
The three LLM judges return verdicts only, and the verifier computes the
scores. A `score` field in a judge reply is ignored.
@@ -816,9 +818,11 @@ still score zero.
is invalid.
- `goal_accuracy` is `1.0` when the judge decides the goal was `achieved` and
`0.0` otherwise, the same binary scale as the RAGAS scorer.
-- `behavior_check` is the share of expected behaviors observed. The reply must
- judge every behavior exactly once, identified by its 1-based `step` number.
- A reply that skips, repeats, or invents a step is invalid.
+- `behavior_check` includes the share of expected behaviors observed and any
+ directly evaluated declared checks. When expected behaviors are present, the
+ reply must judge every behavior exactly once, identified by its 1-based
+ `step` number; a reply that skips, repeats, or invents a step is invalid.
+ A checks-only case is evaluated directly without a judge call.
Rewards record `judge_contract: skill-evaluator-judges-v2`. Results written
before this contract, whose `accuracy` included a `SKILL_IDENTIFIED` criterion,
@@ -1057,7 +1061,7 @@ unscored rather than converted to `0.0`.
| Security | Is it safe to use? | `security` | 1.0 | Deterministic checks of the trace and agent actions |
| Correctness | Is the answer correct? | `accuracy` | 1.0 | LLM judge (`judge_accuracy`) |
| Discoverability | Was the right skill loaded when needed? | `skill_execution` | 1.0 | Deterministic checks of the trajectory and tool calls |
-| Effectiveness | Did the skill help complete the task? | `goal_accuracy` + `behavior_check` | 0.5 + 0.5 | LLM judges (`judge_goal_accuracy`, `judge_behavior_check`) |
+| Effectiveness | Did the skill help complete the task? | `goal_accuracy` + `behavior_check` | 0.5 + 0.5 | LLM judge plus directly evaluated declared checks |
| Efficiency | Did it avoid wasted tool or skill usage? | `skill_efficiency` | 1.0 | Deterministic checks of the trajectory and tool calls |
The Security check's network rule warns when an agent's `curl`, `wget`, or
diff --git a/src/skillevaluator/tier3/eval_core/checks.py b/src/skillevaluator/tier3/eval_core/checks.py
index bb6b358c..257152bd 100644
--- a/src/skillevaluator/tier3/eval_core/checks.py
+++ b/src/skillevaluator/tier3/eval_core/checks.py
@@ -55,6 +55,20 @@ _mark_quoted_syntax = _shell_lexing._mark_quoted_syntax
_keep_attached_descriptors = _shell_lexing._keep_attached_descriptors
_shell_tokens = _shell_lexing._shell_tokens
+_EXIT_STATUS_RE = re.compile(
+ r"^[ \t]*\[?(?:exit_code|exit[ \t]+code|return_code|return[ \t]+code|"
+ r"process[ \t]+exited[ \t]+with[ \t]+code)\]?[ \t]*[=:]?[ \t]*(-?\d+)\]?[ \t]*\r?$",
+ re.IGNORECASE | re.MULTILINE,
+)
+
+
+def _exit_status(tc: dict[str, Any]) -> int | None:
+ if tc.get("is_error") is False:
+ return 0
+ match = _EXIT_STATUS_RE.search(str(tc.get("observation", "")))
+ return int(match.group(1)) if match else None
+
+
_ALLEXPORT_MARK = _script_invocation._ALLEXPORT_MARK
_ARITHMETIC_ASSIGNMENT_RE = _script_invocation._ARITHMETIC_ASSIGNMENT_RE
_ARITHMETIC_EXPANSION_RE = _script_invocation._ARITHMETIC_EXPANSION_RE
@@ -4685,11 +4699,6 @@ def check_error_recovery(
# Only complete status lines are execution evidence; source code and prose
# may mention exit_code=1 without describing this command's outcome.
- exit_status_re = re.compile(
- r"^[ \t]*\[?(?:exit_code|exit[ \t]+code|process[ \t]+exited[ \t]+with[ \t]+code)"
- r"\]?[ \t]*[=:]?[ \t]*(-?\d+)\]?[ \t]*\r?$",
- re.IGNORECASE | re.MULTILINE,
- )
# A type annotation such as `error: str | None = None` or `timeout: float = 30.0`
# is displayed source, not a diagnostic.
not_annotation = (
@@ -4792,7 +4801,7 @@ def check_error_recovery(
output = unified_output.group(1)
else:
# Other converters emit status/exit_code lines without an envelope.
- output = exit_status_re.sub("", observation)
+ output = _EXIT_STATUS_RE.sub("", observation)
output = re.sub(
r"^[ \t]*status=(?:completed|failed|error)[ \t]*\r?$",
"",
@@ -4814,14 +4823,6 @@ def check_error_recovery(
)
return all(counts and re.fullmatch(r"(?:.*:)?0", line) for line in lines)
- def _exit_status(tc: dict[str, Any]) -> int | None:
- # Harbor marks Claude Code results that exited 0 with tool_result_is_error
- # false and adds an exit status line only to failures.
- if tc.get("is_error") is False:
- return 0
- status = exit_status_re.search(str(tc.get("observation", "")))
- return int(status.group(1)) if status else None
-
def _is_failure(tc: dict[str, Any]) -> bool:
obs = str(tc.get("observation", ""))
exit_code = _exit_status(tc)
diff --git a/src/skillevaluator/tier3/eval_core/declarative_checks.py b/src/skillevaluator/tier3/eval_core/declarative_checks.py
new file mode 100644
index 00000000..30e6516b
--- /dev/null
+++ b/src/skillevaluator/tier3/eval_core/declarative_checks.py
@@ -0,0 +1,336 @@
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
+from __future__ import annotations
+
+import re
+from pathlib import Path
+from typing import Any
+
+if __package__:
+ from skillevaluator.tier3.eval_core import script_invocation as _script_invocation
+ from skillevaluator.tier3.eval_core.checks import (
+ _command_text,
+ _exit_status,
+ _is_execution_action,
+ _tool_call_shell,
+ )
+else:
+ import script_invocation as _script_invocation
+ from checks import _command_text, _exit_status, _is_execution_action, _tool_call_shell
+
+_cmd_executes_script = _script_invocation._cmd_executes_script
+_SHELL_SEPARATORS = _script_invocation._SHELL_SEPARATORS
+
+SUPPORTED_CHECK_TYPES = (
+ "script_invoked",
+ "command_succeeded",
+ "file_exists",
+ "output_matches",
+ "output_contains",
+)
+
+
+def validate_declarative_checks(value: object) -> list[str]:
+ if not isinstance(value, list):
+ return ["checks must be a list"]
+ errors = []
+ for index, check in enumerate(value):
+ where = f"checks[{index}]"
+ if not isinstance(check, dict):
+ errors.append(f"{where} must be an object")
+ continue
+ check_type = check.get("type")
+ if check_type not in SUPPORTED_CHECK_TYPES:
+ supported = ", ".join(SUPPORTED_CHECK_TYPES)
+ errors.append(f"{where} has unknown type {check_type!r}; supported types: {supported}")
+ continue
+ field = {
+ "script_invoked": "script",
+ "command_succeeded": "script",
+ "file_exists": "path",
+ "output_matches": "pattern",
+ "output_contains": "text",
+ }[check_type]
+ extra_fields = set(check) - {"type", field}
+ if extra_fields:
+ errors.append(f"{where} has unsupported field(s): {', '.join(sorted(extra_fields))}")
+ expected = check.get(field)
+ if not isinstance(expected, str) or not expected.strip():
+ errors.append(f"{where}.{field} must be a non-empty string")
+ continue
+ if check_type == "file_exists":
+ path = Path(expected)
+ if path.is_absolute() or ".." in path.parts:
+ errors.append(f"{where}.path must be relative and cannot traverse parent directories")
+ elif check_type == "output_matches":
+ try:
+ re.compile(expected)
+ except re.error as exc:
+ errors.append(f"{where}.pattern is not a valid regular expression: {exc}")
+ return errors
+
+
+def _invocations(tool_calls: list[dict[str, Any]], script: str) -> list[dict[str, Any]]:
+ calls = []
+ for call in tool_calls:
+ if not _is_execution_action(str(call.get("action", ""))):
+ continue
+ command = _command_text(call)
+ shell, modelled = _tool_call_shell(call)
+ if modelled:
+ verdict = _cmd_executes_script(command, script, _shell=shell)
+ else:
+ verdict = None if script in command else False
+ if verdict is True:
+ calls.append(call)
+ return calls
+
+
+def _script_exit_status(call: dict[str, Any], script: str) -> int | None:
+ status = _exit_status(call)
+ if status is None:
+ return None
+ command = _command_text(call)
+ tokens = _script_invocation._shell_tokens(command)
+ if any(
+ token
+ in {
+ "(",
+ ")",
+ "{",
+ "}",
+ "if",
+ "then",
+ "else",
+ "elif",
+ "fi",
+ "for",
+ "while",
+ "until",
+ "select",
+ "do",
+ "done",
+ "case",
+ "esac",
+ }
+ or re.fullmatch(r"-[A-Za-z]*c[A-Za-z]*", token)
+ for token in tokens
+ ):
+ return None
+ segments: list[list[str]] = [[]]
+ separators: list[str] = []
+ for token in tokens:
+ if token in _SHELL_SEPARATORS:
+ if not segments[-1]:
+ return None
+ separators.append(token)
+ segments.append([])
+ else:
+ segments[-1].append(token)
+ if not segments[-1]:
+ return None
+ shell, modelled = _tool_call_shell(call)
+ if not modelled:
+ return None
+ invocations = [
+ index
+ for index, segment in enumerate(segments)
+ if _cmd_executes_script(" ".join(segment), script, _shell=shell) is True
+ ]
+ if not invocations:
+ return None
+ last_invocation = invocations[-1]
+ following = separators[last_invocation:]
+ if any(separator != "&&" for separator in following):
+ return None
+ if last_invocation < len(segments) - 1 and status != 0:
+ return None
+ return status
+
+
+def _file_exists(path: str, roots: list[Path]) -> bool | None:
+ checked_root = False
+ relative = Path(path)
+ for root in roots:
+ try:
+ resolved_root = root.resolve(strict=True)
+ except OSError:
+ continue
+ checked_root = True
+ try:
+ candidate = (resolved_root / relative).resolve(strict=True)
+ except OSError:
+ continue
+ try:
+ candidate.relative_to(resolved_root)
+ except ValueError:
+ continue
+ if candidate.is_file():
+ return True
+ return False if checked_root else None
+
+
+def evaluate_declarative_checks(
+ checks: object,
+ *,
+ tool_calls: list[dict[str, Any]],
+ final_response: str,
+ workspace_roots: list[Path],
+) -> list[dict[str, Any]]:
+ results = []
+ if not isinstance(checks, list):
+ return results
+ for check in checks:
+ if not isinstance(check, dict):
+ results.append({"type": None, "passed": None, "reason": "Declarative check must be an object"})
+ continue
+ check_type = check.get("type")
+ if not isinstance(check_type, str) or check_type not in SUPPORTED_CHECK_TYPES:
+ supported = ", ".join(SUPPORTED_CHECK_TYPES)
+ results.append(
+ {
+ "type": check_type,
+ "passed": None,
+ "reason": f"Unknown check type {check_type!r}; supported types: {supported}",
+ }
+ )
+ continue
+ expected = check.get({"script_invoked": "script", "command_succeeded": "script"}.get(check_type, ""))
+ if check_type == "script_invoked":
+ passed = bool(_invocations(tool_calls, str(expected)))
+ reason = (
+ f"Invoked {expected}"
+ if passed
+ else f"Expected {expected} to be invoked, but no invocation was recorded"
+ )
+ elif check_type == "command_succeeded":
+ invocations = _invocations(tool_calls, str(expected))
+ statuses = [_script_exit_status(call, str(expected)) for call in invocations]
+ if not invocations:
+ passed = False
+ reason = f"Expected {expected} to exit successfully, but it was not invoked"
+ elif 0 in statuses:
+ passed = True
+ reason = f"Expected {expected} to exit successfully; it exited 0"
+ elif any(status is None for status in statuses):
+ passed = None
+ if any(_exit_status(call) is not None for call in invocations):
+ reason = (
+ f"Expected {expected} to exit successfully, but shell command status could not be attributed"
+ )
+ else:
+ reason = f"Expected {expected} to exit successfully, but exit status was not recorded"
+ else:
+ passed = False
+ status = statuses[-1]
+ reason = f"Expected {expected} to exit successfully; it was invoked but exited {status}"
+ elif check_type == "file_exists":
+ expected = check.get("path", "")
+ passed = _file_exists(str(expected), workspace_roots)
+ reason = (
+ f"Expected file {expected} to exist"
+ if passed is not False
+ else f"Expected file {expected} to exist, but it was not found"
+ )
+ if passed is None:
+ reason = f"Could not check whether file {expected} exists because workspace artifacts are unavailable"
+ elif check_type == "output_contains":
+ expected = check.get("text", "")
+ passed = str(expected) in final_response
+ reason = (
+ f"Final response contains {expected!r}"
+ if passed
+ else f"Expected final response to contain {expected!r}"
+ )
+ elif check_type == "output_matches":
+ expected = check.get("pattern", "")
+ try:
+ passed = re.search(str(expected), final_response) is not None
+ except re.error as exc:
+ passed = None
+ reason = f"Could not check output pattern because it is not a valid regular expression: {exc}"
+ else:
+ reason = (
+ f"Final response matches /{expected}/"
+ if passed
+ else f"Expected final response to match /{expected}/"
+ )
+ else:
+ raise AssertionError(f"Unhandled declarative check type: {check_type}")
+ results.append({"type": check_type, "passed": passed, "reason": reason, "expected": expected})
+ return results
+
+
+def mark_no_skill_script_checks(
+ checks: object,
+ results: list[dict[str, Any]],
+ *,
+ has_skill: object,
+ skill_metrics_on: bool,
+ evaluated_skill: str,
+) -> list[dict[str, Any]]:
+ if has_skill is not False or skill_metrics_on or not evaluated_skill or not isinstance(checks, list):
+ return results
+ skill_root = (Path("/workspace/skills") / evaluated_skill).resolve(strict=False)
+ for check, result in zip(checks, results, strict=False):
+ if (
+ not isinstance(check, dict)
+ or check.get("type") not in {"script_invoked", "command_succeeded"}
+ or not isinstance(check.get("script"), str)
+ ):
+ continue
+ script_path = Path(check["script"])
+ candidates = (
+ [script_path] if script_path.is_absolute() else [Path.cwd() / script_path, skill_root / script_path]
+ )
+ for candidate in candidates:
+ try:
+ candidate.resolve(strict=False).relative_to(skill_root)
+ except ValueError:
+ continue
+ result["passed"] = None
+ result["reason"] = "skill script; not applicable without the skill"
+ break
+ return results
+
+
+def combine_behavior_check(
+ judge_result: dict[str, Any],
+ declarative_results: list[dict[str, Any]],
+ judged_count: int,
+) -> dict[str, Any]:
+ checked = [item for item in declarative_results if item.get("passed") is not None]
+ not_checked = [item for item in declarative_results if item.get("passed") is None]
+ judge_score = judge_result.get("score")
+ has_judge_error = judge_result.get("status") == "error"
+ denominator = judged_count + len(checked)
+ if has_judge_error:
+ score = None
+ elif denominator:
+ judged_total = float(judge_score or 0.0) * judged_count
+ checked_total = sum(item.get("passed") is True for item in checked)
+ score = round((judged_total + checked_total) / denominator, 4)
+ else:
+ score = None
+ summary = f"Checked directly: {len(checked)}, judged: {judged_count}, not checked: {len(not_checked)}"
+ result = dict(judge_result)
+ result["score"] = score
+ result["status"] = "error" if has_judge_error else "accepted" if score is not None else "not_applicable"
+ old_reason = str(judge_result.get("reason") or "").strip()
+ if judge_result.get("status") == "not_applicable" and checked:
+ old_reason = ""
+ result["reason"] = f"{old_reason}; {summary}" if old_reason else summary
+ judged_results = judge_result.get("results")
+ judged_items = (
+ [item for item in judged_results if isinstance(item, dict)] if isinstance(judged_results, list) else []
+ )
+ result["results"] = [*judged_items, *checked]
+ result["declarative_checks"] = {
+ "results": declarative_results,
+ "checked_count": len(checked),
+ "judged_count": judged_count,
+ "not_checked_count": len(not_checked),
+ "summary": summary,
+ }
+ return result
diff --git a/src/skillevaluator/tier3/evals_spec.py b/src/skillevaluator/tier3/evals_spec.py
index 15cb3ac8..c44889d4 100644
--- a/src/skillevaluator/tier3/evals_spec.py
+++ b/src/skillevaluator/tier3/evals_spec.py
@@ -621,6 +621,7 @@ def _check_dataset(skill_path: Path, results: list[CheckResult]) -> bool:
def _validate_dataset_contents(path: Path, results: list[CheckResult]) -> None:
"""Validate the contents of a dataset file."""
from .dataset_utils import load_dataset_entries_with_format
+ from .eval_core.declarative_checks import validate_declarative_checks
try:
entries, dataset_format = load_dataset_entries_with_format(path)
@@ -677,6 +678,9 @@ def _validate_dataset_contents(path: Path, results: list[CheckResult]) -> None:
f"Missing required fields: {', '.join(sorted(missing_required))}",
)
)
+ if "checks" in entry:
+ for error in validate_declarative_checks(entry["checks"]):
+ results.append(CheckResult(f"entry {entry_id}", "error", error))
missing_recommended = DATASET_RECOMMENDED_FIELDS - set(entry.keys())
if dataset_format == "legacy" and missing_recommended:
results.append(
diff --git a/src/skillevaluator/tier3/harbor/adapter.py b/src/skillevaluator/tier3/harbor/adapter.py
index 3ce13c64..7823506e 100644
--- a/src/skillevaluator/tier3/harbor/adapter.py
+++ b/src/skillevaluator/tier3/harbor/adapter.py
@@ -2402,6 +2402,7 @@ def _copy_verifier(task_dir: Path) -> None:
(_EVAL_CORE_DIR / "atif_helpers.py", "ATIF evidence helpers"),
(_EVAL_CORE_DIR / "shell_lexing.py", "Shell lexical helper"),
(_EVAL_CORE_DIR / "script_invocation.py", "Shell invocation helper"),
+ (_EVAL_CORE_DIR / "declarative_checks.py", "Declarative checks helper"),
(_EVAL_CORE_DIR / "optional_reference.py", "Optional reference normalizer"),
(_EVAL_CORE_DIR / "checks.py", "Deterministic grading checks"),
(_EVAL_CORE_DIR / "secret_redaction.py", "Deterministic redaction helper"),
diff --git a/src/skillevaluator/tier3/harbor/report.py b/src/skillevaluator/tier3/harbor/report.py
index 44dc8977..de77f91a 100644
--- a/src/skillevaluator/tier3/harbor/report.py
+++ b/src/skillevaluator/tier3/harbor/report.py
@@ -449,6 +449,11 @@ def _collect_fail_reasons(metric: str, trials: list[dict[str, Any]]) -> list[str
continue
if reason := _bounded_reason_text(result.get("reason")):
reasons.append(reason)
+ declarative_checks = detail.get("declarative_checks")
+ if isinstance(declarative_checks, dict) and (
+ summary := _bounded_reason_text(declarative_checks.get("summary"))
+ ):
+ reasons.append(summary)
elif metric == "accuracy":
criteria = _applicable_accuracy_criteria(detail)
@@ -540,8 +545,9 @@ def _collect_pass_reasons(metric: str, trials: list[dict[str, Any]]) -> list[str
if metric == "behavior_check":
raw_results = detail.get("results")
results = [item for item in raw_results if isinstance(item, dict)] if isinstance(raw_results, list) else []
- passed_count = sum(1 for result in results if result.get("passed") is True)
- total = len(results)
+ judged_results = [result for result in results if result.get("step") is not None]
+ passed_count = sum(1 for result in judged_results if result.get("passed") is True)
+ total = len(judged_results)
if total:
reasons.append(f"{passed_count}/{total} expected behaviors observed")
if reason := _bounded_reason_text(detail.get("reason")):
diff --git a/src/skillevaluator/tier3/harbor/templates/eval.py b/src/skillevaluator/tier3/harbor/templates/eval.py
index 47b88cad..eb4f3a98 100644
--- a/src/skillevaluator/tier3/harbor/templates/eval.py
+++ b/src/skillevaluator/tier3/harbor/templates/eval.py
@@ -112,6 +112,26 @@ if _CHECKS_PATH.is_file():
else: # Source-tree template: the canonical module lives in the package.
from skillevaluator.tier3.eval_core import checks as _shared_checks
+_DECLARATIVE_CHECKS_PATH = _SCRIPT_TESTS_DIR / "declarative_checks.py"
+if _DECLARATIVE_CHECKS_PATH.is_file():
+ _declarative_spec = importlib.util.spec_from_file_location(
+ "_skillevaluator_shared_declarative_checks", _DECLARATIVE_CHECKS_PATH
+ )
+ assert _declarative_spec and _declarative_spec.loader
+ _shared_declarative_checks = importlib.util.module_from_spec(_declarative_spec)
+ _had_checks_module = "checks" in sys.modules
+ _previous_checks_module = sys.modules.get("checks")
+ sys.modules["checks"] = _shared_checks
+ try:
+ _declarative_spec.loader.exec_module(_shared_declarative_checks)
+ finally:
+ if _had_checks_module:
+ sys.modules["checks"] = _previous_checks_module
+ else:
+ sys.modules.pop("checks", None)
+else:
+ from skillevaluator.tier3.eval_core import declarative_checks as _shared_declarative_checks
+
AMBIGUOUS_OUTER_EXEC_OBSERVATION = _shared_checks.AMBIGUOUS_OUTER_EXEC_OBSERVATION
UNOBSERVED_INNER_CALL = _shared_checks.UNOBSERVED_INNER_CALL
UNSUPPORTED_NATIVE_CODEX_EXEC = _shared_checks.UNSUPPORTED_NATIVE_CODEX_EXEC
@@ -585,6 +605,13 @@ def _env_path(name, default):
return Path(os.environ.get(name, str(default)))
+def _declarative_workspace_roots():
+ roots = [Path.cwd(), Path("/workspace"), Path("/workspace/output")]
+ if artifact_root := os.environ.get("HARBOR_ARTIFACTS_DIR"):
+ roots.append(Path(artifact_root))
+ return list(dict.fromkeys(roots))
+
+
LOGS_DIR = _env_path("HARBOR_LOGS_DIR", "/logs")
AGENT_LOGS_DIR = _env_path("HARBOR_AGENT_LOGS_DIR", LOGS_DIR / "agent")
VERIFIER_DIR = _env_path("HARBOR_VERIFIER_DIR", LOGS_DIR / "verifier")
@@ -3849,6 +3876,7 @@ def main():
evaluated_skill = entry.get("evaluated_skill") or ""
acceptable_skills = _resolve_acceptable_skills(entry, expected_skill)
expected_behavior = normalize_expected_behaviors(entry.get("expected_behavior", []))
+ declarative_checks = entry.get("checks", [])
question = entry.get("question", "")
ground_truth = entry.get("ground_truth", "")
workspace_mode = entry.get("skill_workspace_mode", "isolated")
@@ -3894,6 +3922,38 @@ def main():
"trajectory_source": traj_meta.get("source"),
"trajectory_detail": traj_meta.get("warning") or traj_meta.get("note"),
}
+ if declarative_checks:
+ direct_results = _shared_declarative_checks.evaluate_declarative_checks(
+ declarative_checks,
+ tool_calls=[],
+ final_response="",
+ workspace_roots=_declarative_workspace_roots(),
+ )
+ direct_results = _shared_declarative_checks.mark_no_skill_script_checks(
+ declarative_checks,
+ direct_results,
+ has_skill=entry.get("has_skill", True),
+ skill_metrics_on=skill_metrics_on,
+ evaluated_skill=evaluated_skill,
+ )
+ judged_count = len(expected_behavior) if _has_judge_reference(expected_behavior) else 0
+ base_behavior = {
+ "score": judge_scores["behavior_check"],
+ "status": "accepted" if judged_count else "not_applicable",
+ "reason": "No trajectory or reconstructible agent log"
+ if judged_count
+ else _NO_EXPECTED_BEHAVIOR_REASON,
+ "results": [
+ {"step": index + 1, "passed": False, "reason": "No trajectory or reconstructible agent log"}
+ for index in range(judged_count)
+ ],
+ }
+ behavior_result = _shared_declarative_checks.combine_behavior_check(
+ base_behavior, direct_results, judged_count
+ )
+ judge_scores["behavior_check"] = behavior_result["score"]
+ judge_details["behavior_check"] = behavior_result
+ result["behavior_check"] = behavior_result["score"]
if judge_details:
result["details"] = judge_details
write_reward_outputs(result, 0.0)
@@ -4019,13 +4079,40 @@ def main():
details["goal_accuracy"] = ga_result
# ── Eval 6: behavior_check (LLM judge) ───────────────────────────
- bc_result = _call_required_judge(
- "behavior_check",
- judge_behavior_check,
- bundles["behavior_check"]["prompt_evidence"],
- expected_behavior,
- allow_not_applicable=not _has_judge_reference(expected_behavior),
- )
+ if declarative_checks:
+ if _has_judge_reference(expected_behavior):
+ bc_result = _call_required_judge(
+ "behavior_check",
+ judge_behavior_check,
+ bundles["behavior_check"]["prompt_evidence"],
+ expected_behavior,
+ )
+ else:
+ bc_result = _judge_not_applicable(_NO_EXPECTED_BEHAVIOR_REASON, results=[])
+ else:
+ bc_result = _call_required_judge(
+ "behavior_check",
+ judge_behavior_check,
+ bundles["behavior_check"]["prompt_evidence"],
+ expected_behavior,
+ allow_not_applicable=not _has_judge_reference(expected_behavior),
+ )
+ if declarative_checks:
+ direct_results = _shared_declarative_checks.evaluate_declarative_checks(
+ declarative_checks,
+ tool_calls=tool_calls,
+ final_response=_get_final_response(traj),
+ workspace_roots=_declarative_workspace_roots(),
+ )
+ direct_results = _shared_declarative_checks.mark_no_skill_script_checks(
+ declarative_checks,
+ direct_results,
+ has_skill=entry.get("has_skill", True),
+ skill_metrics_on=skill_metrics_on,
+ evaluated_skill=evaluated_skill,
+ )
+ judged_count = len(expected_behavior) if _has_judge_reference(expected_behavior) else 0
+ bc_result = _shared_declarative_checks.combine_behavior_check(bc_result, direct_results, judged_count)
bc_score = bc_result["score"]
details["behavior_check"] = bc_result
finally:
diff --git a/src/skillevaluator/tier3/plugin_prepare.py b/src/skillevaluator/tier3/plugin_prepare.py
index 4d0c73e1..3b3ac9b0 100644
--- a/src/skillevaluator/tier3/plugin_prepare.py
+++ b/src/skillevaluator/tier3/plugin_prepare.py
@@ -671,6 +671,12 @@ def _collect_dataset(
base_id = str(entry.get("id") or f"case-{index:03d}")
case_id = _unique_id(_safe_id(f"{skill}-{base_id}" if skill else base_id), seen)
combined = {**entry, "id": case_id, "plugin_eval_target": package.plugin_name}
+ if "checks" in combined:
+ from skillevaluator.tier3.eval_core.declarative_checks import validate_declarative_checks
+
+ errors = validate_declarative_checks(combined["checks"])
+ if errors:
+ raise PreparationError(f"invalid declarative checks for plugin case '{case_id}': {errors[0]}")
if skill is not None:
combined["plugin_eval_source_skill"] = skill
combined.setdefault("expected_skill", skill)
diff --git a/tests/tier3/test_declarative_checks.py b/tests/tier3/test_declarative_checks.py
new file mode 100644
index 00000000..85a0bffe
--- /dev/null
+++ b/tests/tier3/test_declarative_checks.py
@@ -0,0 +1,323 @@
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
+import importlib.util
+from pathlib import Path
+
+import pytest
+
+from skillevaluator.evaluation.tier3_findings import failure_reason
+from skillevaluator.tier3.eval_core.declarative_checks import (
+ combine_behavior_check,
+ evaluate_declarative_checks,
+ mark_no_skill_script_checks,
+ validate_declarative_checks,
+)
+from skillevaluator.tier3.harbor.adapter import _copy_verifier
+from skillevaluator.tier3.harbor.report import _collect_fail_reasons, _collect_pass_reasons
+
+
+def _evaluate(check, *, calls=None, response="", roots=None):
+ return evaluate_declarative_checks(
+ [check],
+ tool_calls=calls or [],
+ final_response=response,
+ workspace_roots=roots or [],
+ )[0]
+
+
+def _call(command, *, observation="", is_error=None):
+ call = {"action": "Bash", "action_input": {"command": command}, "observation": observation}
+ if is_error is not None:
+ call["is_error"] = is_error
+ return call
+
+
+def test_script_invoked_checks_command_trajectory_only():
+ check = {"type": "script_invoked", "script": "scripts/x.py"}
+
+ assert _evaluate(check, calls=[_call("python scripts/x.py")])["passed"] is True
+ assert (
+ _evaluate(
+ check,
+ calls=[{"action": "exec_command", "action_input": {"command": "python scripts/x.py"}}],
+ )["passed"]
+ is True
+ )
+ assert _evaluate(check, calls=[_call("cat scripts/x.py")])["passed"] is False
+
+
+def test_command_succeeded_requires_invocation_and_recorded_success():
+ check = {"type": "command_succeeded", "script": "scripts/x.py"}
+
+ assert _evaluate(check, calls=[_call("python scripts/x.py", observation="Exit code: 0")])["passed"] is True
+ failed = _evaluate(check, calls=[_call("python scripts/x.py", observation="Exit code: 2")])
+ assert failed["passed"] is False
+ assert failed["reason"] == "Expected scripts/x.py to exit successfully; it was invoked but exited 2"
+ assert _evaluate(check, calls=[_call("python scripts/x.py")])["passed"] is None
+ assert _evaluate(check, calls=[_call("python other.py", observation="Exit code: 0")])["passed"] is False
+
+
+def test_command_succeeded_uses_anchored_shared_exit_status():
+ check = {"type": "command_succeeded", "script": "scripts/x.py"}
+
+ failed = _evaluate(check, calls=[_call("python scripts/x.py", observation="Process exited with code 2")])
+ passed = _evaluate(check, calls=[_call("python scripts/x.py", observation="Process exited with code 0")])
+ claude_success = _evaluate(
+ check,
+ calls=[
+ _call(
+ "python scripts/x.py",
+ observation="pytest exit code: 1 (1 failed)",
+ is_error=False,
+ )
+ ],
+ )
+
+ assert failed["passed"] is False
+ assert passed["passed"] is True
+ assert claude_success["passed"] is True
+
+
+ ("command", "observation"),
+ [
+ ("python scripts/x.py | tail -20", "Process exited with code 0"),
+ ("python scripts/x.py || true", "Process exited with code 0"),
+ ("python scripts/x.py; echo done", "Process exited with code 0"),
+ ("bash -c 'python scripts/x.py; echo done'", "Process exited with code 0"),
+ ("python scripts/x.py && pytest -q", "Process exited with code 1"),
+ ],
+)
+def test_command_succeeded_does_not_attribute_shell_tail_status(command, observation):
+ result = _evaluate(
+ {"type": "command_succeeded", "script": "scripts/x.py"},
+ calls=[_call(command, observation=observation)],
+ )
+
+ assert result["passed"] is None
+ assert "could not be attributed" in result["reason"]
+
+
+def test_zero_exit_from_pure_and_chain_proves_script_success():
+ result = _evaluate(
+ {"type": "command_succeeded", "script": "scripts/x.py"},
+ calls=[_call("python scripts/x.py && pytest -q", observation="Process exited with code 0")],
+ )
+
+ assert result["passed"] is True
+
+
+def test_file_exists_uses_workspace_not_response_mentions(tmp_path: Path):
+ check = {"type": "file_exists", "path": "out/report.md"}
+ output = tmp_path / "out" / "report.md"
+ output.parent.mkdir()
+ output.write_text("done", encoding="utf-8")
+
+ assert _evaluate(check, roots=[tmp_path])["passed"] is True
+ output.unlink()
+ mentioned = _evaluate(check, response="Created out/report.md", roots=[tmp_path])
+ assert mentioned["passed"] is False
+ assert _evaluate(check, roots=[tmp_path / "unavailable"])["passed"] is None
+
+
+def test_final_response_checks_match_contains_and_regex():
+ assert _evaluate({"type": "output_contains", "text": "Report ready"}, response="Report ready.")["passed"] is True
+ assert _evaluate({"type": "output_contains", "text": "Report ready"}, response="Still working")["passed"] is False
+ assert _evaluate({"type": "output_matches", "pattern": r"Report \d+"}, response="Report 17")["passed"] is True
+ assert _evaluate({"type": "output_matches", "pattern": r"Report \d+"}, response="No report")["passed"] is False
+
+
+def test_runtime_invalid_regex_and_unknown_check_are_not_checked():
+ invalid_regex = _evaluate({"type": "output_matches", "pattern": "["}, response="ready")
+ unknown = _evaluate({"type": "made_up", "value": "x"})
+ malformed_type = _evaluate({"type": []})
+
+ assert invalid_regex["passed"] is None
+ assert "not a valid regular expression" in invalid_regex["reason"]
+ assert unknown["passed"] is None
+ assert "Unknown check type" in unknown["reason"]
+ assert malformed_type["passed"] is None
+ assert "Unknown check type" in malformed_type["reason"]
+
+
+def test_skill_script_checks_are_not_applicable_without_the_skill():
+ checks = [{"type": "script_invoked", "script": "scripts/x.py"}]
+ results = [{"type": "script_invoked", "passed": False, "reason": "not invoked"}]
+
+ marked = mark_no_skill_script_checks(
+ checks,
+ results,
+ has_skill=False,
+ skill_metrics_on=False,
+ evaluated_skill="demo",
+ )
+
+ assert marked[0]["passed"] is None
+ assert marked[0]["reason"] == "skill script; not applicable without the skill"
+
+
+def test_not_checked_items_are_excluded_and_coverage_is_reported():
+ result = combine_behavior_check(
+ {"score": 0.5, "status": "accepted", "results": [{"step": 1, "passed": True}]},
+ [{"type": "command_succeeded", "passed": None, "reason": "status unavailable"}],
+ judged_count=2,
+ )
+
+ assert result["score"] == 0.5
+ assert result["declarative_checks"]["summary"] == "Checked directly: 0, judged: 2, not checked: 1"
+
+
+def test_mixed_judged_and_direct_results_are_averaged():
+ result = combine_behavior_check(
+ {
+ "score": 0.5,
+ "status": "accepted",
+ "results": [{"step": 1, "passed": True}, {"step": 2, "passed": False}],
+ },
+ [
+ {"type": "output_contains", "passed": True, "reason": "found"},
+ {"type": "output_matches", "passed": False, "reason": "missing"},
+ ],
+ judged_count=2,
+ )
+
+ assert result["score"] == 0.5
+ assert result["declarative_checks"]["summary"] == "Checked directly: 2, judged: 2, not checked: 0"
+ assert result["results"][-1]["reason"] == "missing"
+
+
+def test_checks_only_compute_behavior_score_without_a_judge_result():
+ result = combine_behavior_check(
+ {"score": None, "status": "not_applicable", "reason": "N/A", "results": []},
+ [{"type": "output_contains", "passed": True, "reason": "found"}],
+ judged_count=0,
+ )
+
+ assert result["score"] == 1.0
+ assert result["status"] == "accepted"
+ assert result["reason"] == "Checked directly: 1, judged: 0, not checked: 0"
+
+
+def test_not_applicable_judge_reason_is_dropped_when_checks_are_scored():
+ result = combine_behavior_check(
+ {"score": None, "status": "not_applicable", "reason": "No expected behaviors", "results": []},
+ [{"type": "output_contains", "passed": True, "reason": "found"}],
+ judged_count=0,
+ )
+
+ assert result["reason"] == "Checked directly: 1, judged: 0, not checked: 0"
+
+
+def test_behavior_coverage_and_failure_reasons_reach_report_details():
+ detail = {
+ "reason": "Checked directly: 1, judged: 0, not checked: 0",
+ "results": [{"type": "output_contains", "passed": False, "reason": "Expected final response text"}],
+ "declarative_checks": {
+ "summary": "Checked directly: 1, judged: 0, not checked: 0",
+ },
+ }
+ trials = [{"detail": detail}]
+
+ assert "Checked directly: 1, judged: 0, not checked: 0" in _collect_fail_reasons("behavior_check", trials)
+ assert "Expected final response text" in _collect_fail_reasons("behavior_check", trials)
+ assert "Checked directly: 1, judged: 0, not checked: 0" in _collect_pass_reasons("behavior_check", trials)
+ assert "Checked directly: 1, judged: 0, not checked: 0" in failure_reason(detail)
+
+
+def test_pass_reasons_count_only_judged_behavior_results():
+ detail = {
+ "reason": "Checked directly: 1, judged: 1, not checked: 0",
+ "results": [
+ {"type": "output_contains", "passed": True, "reason": "found"},
+ {"step": 1, "passed": False, "reason": "not observed"},
+ ],
+ }
+
+ reasons = _collect_pass_reasons("behavior_check", [{"detail": detail}])
+
+ assert "0/1 expected behaviors observed" in reasons
+ assert not any("expected behaviors observed" in reason and "0/1" not in reason for reason in reasons)
+
+
+def test_unknown_check_type_lists_supported_types():
+ errors = validate_declarative_checks([{"type": "made_up", "value": "x"}])
+
+ assert len(errors) == 1
+ assert "made_up" in errors[0]
+ assert "script_invoked" in errors[0]
+ assert "output_contains" in errors[0]
+
+
+def test_dataset_validation_rejects_unknown_check_type(tmp_path):
+ import json
+
+ from skillevaluator.tier3.evals_spec import validate_skillevaluators
+
+ skill = tmp_path / "skill"
+ evals = skill / "evals"
+ evals.mkdir(parents=True)
+ (evals / "evals.json").write_text(
+ json.dumps(
+ {
+ "skill_name": "skill",
+ "evals": [
+ {
+ "id": "case-1",
+ "prompt": "Run it",
+ "expected_output": "Done",
+ "checks": [{"type": "made_up", "value": "x"}],
+ }
+ ],
+ }
+ ),
+ encoding="utf-8",
+ )
+
+ errors = [result.message for result in validate_skillevaluators(skill) if result.status == "error"]
+
+ assert any("made_up" in error and "script_invoked" in error for error in errors)
+
+
+def test_check_validation_rejects_unsafe_paths_and_invalid_patterns():
+ errors = validate_declarative_checks(
+ [
+ {"type": "file_exists", "path": "../outside"},
+ {"type": "output_matches", "pattern": "["},
+ ]
+ )
+
+ assert any("cannot traverse parent directories" in error for error in errors)
+ assert any("valid regular expression" in error for error in errors)
+
+
+def test_template_uses_shared_declarative_check_logic(harbor_eval_template):
+ calls = [_call("python scripts/x.py", observation="Exit code: 0")]
+ check = {"type": "command_succeeded", "script": "scripts/x.py"}
+
+ host = evaluate_declarative_checks([check], tool_calls=calls, final_response="", workspace_roots=[])
+ template = harbor_eval_template._shared_declarative_checks.evaluate_declarative_checks(
+ [check], tool_calls=calls, final_response="", workspace_roots=[]
+ )
+
+ assert template == host
+
+
+def test_standalone_bundle_stages_and_imports_the_shared_helper(tmp_path: Path, monkeypatch):
+ _copy_verifier(tmp_path)
+ helper_path = tmp_path / "tests/skill_evaluator/declarative_checks.py"
+ monkeypatch.syspath_prepend(str(helper_path.parent))
+ spec = importlib.util.spec_from_file_location("staged_declarative_checks", helper_path)
+ assert spec is not None and spec.loader is not None
+ staged = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(staged)
+
+ result = staged.evaluate_declarative_checks(
+ [{"type": "output_contains", "text": "ready"}],
+ tool_calls=[],
+ final_response="ready",
+ workspace_roots=[],
+ )
+
+ assert helper_path.is_file()
+ assert result[0]["passed"] is True
diff --git a/tests/tier3/test_judge_contracts.py b/tests/tier3/test_judge_contracts.py
index 67d5fe5a..972e8fe9 100644
--- a/tests/tier3/test_judge_contracts.py
+++ b/tests/tier3/test_judge_contracts.py
@@ -383,6 +383,32 @@ def _attempts(verifier_dir: Path) -> list[dict[str, Any]]:
return payload["attempts"]
+def test_checks_only_behavior_does_not_call_the_judge(tmp_path: Path) -> None:
+ verifier = _stage_verifier(
+ tmp_path,
+ {
+ "id": "case-1",
+ "has_skill": False,
+ "question": "Complete the task",
+ "ground_truth": "",
+ "expected_behavior": [],
+ "checks": [{"type": "output_contains", "text": "completed"}],
+ },
+ )
+
+ def fail_if_called(*args, **kwargs):
+ raise AssertionError("checks-only behavior must not invoke the judge")
+
+ verifier.judge_behavior_check = fail_if_called
+ verifier.call_public_llm = fail_if_called
+ verifier.main()
+
+ reward = json.loads(verifier.SKILL_EVALUATOR_REWARD_JSON.read_text(encoding="utf-8"))
+ behavior = reward["details"]["behavior_check"]
+ assert reward["behavior_check"] == 1.0
+ assert behavior["declarative_checks"]["summary"] == "Checked directly: 1, judged: 0, not checked: 0"
+
+
def test_scored_trial_records_judge_contract_and_every_attempt(tmp_path: Path) -> None:
verifier = _stage_verifier(tmp_path)
calls: list[str] = []
diff --git a/tests/tier3/test_plugin_dataset.py b/tests/tier3/test_plugin_dataset.py
index b251669d..c5826d07 100644
--- a/tests/tier3/test_plugin_dataset.py
+++ b/tests/tier3/test_plugin_dataset.py
@@ -114,6 +114,26 @@ def test_malformed_and_oversized_datasets_are_refused(tmp_path: Path) -> None:
stage_wrapper_skill(_package(root), tmp_path / "out2", evals_source=many, max_cases=4)
+ "checks",
+ [
+ [{"type": "output_matches", "pattern": "["}],
+ [{"type": "made_up", "value": "x"}],
+ ],
+)
+def test_plugin_dataset_rejects_invalid_declarative_checks(tmp_path: Path, checks: list[dict]) -> None:
+ root = _plugin(
+ tmp_path,
+ {
+ "skills/a/SKILL.md": _skill("a"),
+ "skills/a/evals/evals.json": [{"id": "case-1", "prompt": "Run", "checks": checks}],
+ },
+ )
+
+ with pytest.raises(PreparationError, match="invalid declarative checks"):
+ stage_wrapper_skill(_package(root), tmp_path / "out")
+
+
def test_linked_member_dataset_is_refused(tmp_path: Path) -> None:
root = _plugin(tmp_path, {"skills/a/SKILL.md": _skill("a")})
outside = _tree(tmp_path / "outside", {"evals.json": [{"prompt": "x"}]})