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): report activation independently of task outcomes (#438)

Narendran Raghavan63f064f5d6ee
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bb00c189..91ee0d40 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,18 @@ All notable changes to SkillEvaluator are documented in this file.
without presenting missing judgments as verified skill defects. Unexpected
judge errors retain that inventory; intentionally skipped arms add no attempts.
+- Repeatable Tier 3 activation-validation recipe and offline acceptance suite.
+ Canonical trials separate expected target-skill use, trusted observed use or
+ unknown traces, task correctness, workflow diagnostics, resources and retained
+ evidence links. Fallback multi-step rows retain scoped observations without
+ claiming complete logical-trial activation or changing numeric grading.
+ Explicit `should_trigger` precedence is preserved, and standard baselines
+ retain trusted trajectory observations independently of null/N/A skill scores.
+ Primary skill identities match case-insensitively; accepted alternate use remains
+ optional, including the legacy alternate field, without changing numeric grades.
+ Unrendered activation diagnostics remain in canonical exports without consuming
+ HTML overview or failure-reason preview budgets.
+
- Run SkillEvaluator's own `skills/` through the pinned three-tier GitHub
callers, retaining Tier 1 as required and Tier 2/3 as advisory. A separate
consumer feedback listener preserves the reusable publisher's public path;
diff --git a/docs/tier3-live-evaluation.mdx b/docs/tier3-live-evaluation.mdx
index 6d849a98..6107ca02 100644
--- a/docs/tier3-live-evaluation.mdx
+++ b/docs/tier3-live-evaluation.mdx
@@ -68,6 +68,132 @@ When at least one positive trial activates the skill, lift remains eligible
subject to the comparison requirements below. This also makes activation
failures visible with `--skip-baseline`.
+## Repeatable activation validation
+
+Use the existing dataset generator, runner and trusted trajectory collector to
+check activation separately from answer quality. Start with
+`skillevaluator create-eval-dataset ./my-skill --full`, review the generated
+cases, and retain a versioned dataset with these four buckets:
+
+| Bucket | Authored expectation | What to check |
+| --- | --- | --- |
+| Explicit | `expected_skill: "my-skill"` | A request naming the skill invokes it. |
+| Implicit | `expected_skill: "my-skill"` | An in-scope request without its name still invokes it. |
+| Negative | `expected_skill: null` | An unrelated request succeeds without invoking it. |
+| Edge | Explicit skill name or `null`, chosen before running | A boundary input follows the skill's documented scope; retain the expected refusal, recovery or output. |
+
+Template generation with `--no-llm --full` needs an authored negative prompt in
+`evals/EVAL.md` to produce the negative bucket. Add the edge case yourself and
+make each `expected_skill` explicit. An authored `should_trigger` takes
+precedence, including `false` without a skill name. Unlabeled expectations and
+positive routing without a target identity remain unknown. Keep task correctness
+assertions outcome-oriented; a correct answer alone cannot demonstrate skill use.
+
+```bash title="Run the reviewed matrix through the normal harness"
+skillevaluator tier3 validate ./my-skill --strict
+skillevaluator tier3 evaluate ./my-skill --agents codex --env-mode docker \
+ --n-attempts 1 --grading-mode default
+```
+
+Use an explicit `--agent-model AGENT=MODEL` when needed for your provider.
+Repeat with `--grading-mode default_plus_custom` after configuring an authored
+custom grader. `--skip-baseline` supports a faster activation-only iteration;
+it cannot measure benefit or harm relative to the baseline. `custom_only`
+has no trusted standard activation contract and stays unknown in this view.
+
+Each canonical report trial now includes `activation_validation`:
+
+- `expected_activation` is true, false, or unknown (`null`). The without-skill
+ arm expects non-use even for an in-scope task.
+- `observed_activation` is `invoked`, `not_invoked`, or `unknown`, using only
+ the collector's trusted trajectory evidence. `expectation_status` compares
+ these as `matched`, `mismatched`, or `unknown`.
+ A standard baseline's explicit null/N/A skill scores do not prevent collecting
+ trajectory evidence; those scores stay N/A. The arm alone never proves non-use.
+- `task_outcome` retains accuracy and goal accuracy independently of routing;
+ `evidence_scopes[].workflow` retains workflow order, script execution and
+ recovery diagnostics, and `resources` retains available time/token counters.
+- `evidence_scopes[].artifacts` links to the retained reward and trajectory
+ paths relative to the run directory. Harbor viewer links remain on the trial.
+
+For fallback multi-step reward rows, the logical observation stays unknown and
+`observation_scope` is `reward_rows_only`; individual observations remain in
+`evidence_scopes`. This also applies when only one step row survives loading.
+A collector-materialized complete root trajectory with the collector-issued
+`invocation_evidence_scope: logical_trial` marker can support a logical
+observation. Historical rows without a scope marker retain their row evidence
+but cannot certify a complete logical observation. Missing or contradictory topology, unresolved subagent references,
+and unsupported traces remain unknown. Copied context and unreferenced child
+trajectories do not prove execution. `evidence_scopes_complete` describes
+whether all loaded row scopes fit in the report, not whether execution was
+complete. These fields do not change numeric grading or the existing lift
+eligibility policy.
+
+The following read-only recipe exports both arms from a specific retained run
+without calling another model. Replace the run directory with the one printed
+by evaluation. Keep this JSON beside the run's `result.json`, `run_config.json`,
+`attempt_policy.json` and `dataset_snapshot.json`; together they retain skill,
+task, model, harness, environment and grading identities. Review paired task
+outcomes for useful, no-benefit or harmful results, and retain the observed
+result even when it contradicts the expectation.
+
+```bash title="Export activation acceptance evidence"
+python - ./my-skill ./my-skill/evals/results/RUN_ID > activation-validation.json <<'PY'
+import json
+import sys
+from pathlib import Path
+from skillevaluator.evaluation.tier3_report import agent_eval_result_from_directory
+
+skill, run = (Path(arg).resolve() for arg in sys.argv[1:])
+config = json.loads((run / "run_config.json").read_text())
+result = agent_eval_result_from_directory(
+ skill, run,
+ env_mode=config.get("harbor", {}).get("environment", {}).get("value"),
+ use_llm_judge=False, enforce_embedded_size=False,
+)
+if result is None:
+ raise SystemExit("No retained agent results; activation is unknown")
+payload = result.metadata["agent_eval"]
+rows = []
+for name, agent in payload["agents"].items():
+ for condition, key in (("with-skill", "trials"), ("without-skill", "trials_baseline")):
+ for trial in agent[key]:
+ rows.append({
+ "agent": name, "model": agent["model"], "condition": condition,
+ "entry_id": trial["entry_id"], "trial_id": trial["trial_id"],
+ "harbor_viewer": trial.get("harbor_viewer"),
+ **trial["activation_validation"],
+ })
+print(json.dumps({
+ "run_dir": str(run), "run_id": payload["run_id"],
+ "skill_name": payload["skill_name"], "dataset_digest": payload["dataset_digest"],
+ "environment": payload["environment"], "grading": config.get("grading"),
+ "score_policy": payload["score_policy"],
+ "execution_status": payload["execution_status"],
+ "report_truncation": payload.get("report_truncation"), "rows": rows,
+}, indent=2, allow_nan=False))
+PY
+```
+
+A matched routing expectation is not a correctness pass. Unknown observations,
+missing rows and truncated reports are incomplete evidence, not successful
+non-use. Retain raw trajectories privately: they can contain task inputs and
+model outputs even after credential redaction.
+
+Contributors can repeat the fixture-backed acceptance suite without provider
+credentials. It exercises the production collector and report projection,
+including correct baseline answers, missed and irrelevant activation, missing
+traces, copied context, referenced subagents and multi-step completeness:
+
+```bash title="Offline acceptance suite from the repository root"
+python -m pytest tests/reporting/test_activation_validation.py \
+ tests/test_harbor_negative_control_evidence.py \
+ tests/test_harbor_collector_multistep_trajectory.py \
+ tests/test_checks_routing.py tests/tier3/test_failed_skill_reads.py \
+ tests/tier3/test_plugin_signals.py \
+ --basetemp="$(mktemp -d)/activation-tests"
+```
+
## Before you start
Every row below is checkable in seconds; the linked guide covers setup in
diff --git a/src/skillevaluator/evaluation/tier3_report.py b/src/skillevaluator/evaluation/tier3_report.py
index 29a5180e..300ab9e7 100644
--- a/src/skillevaluator/evaluation/tier3_report.py
+++ b/src/skillevaluator/evaluation/tier3_report.py
@@ -795,6 +795,7 @@ def build_agent_eval_payload(
report_budget,
baseline_only=baseline_only,
)
+ _attach_activation_expectations(agent_payloads, dataset or [], skill_name)
best = agent_payloads.get(best_agent, {})
if suggestions_v2 is None and run_dir is not None:
# Findings are per-agent evidence. Resolve the canonical best agent
@@ -2897,6 +2898,7 @@ def _normalize_trials(rewards: list[dict[str, Any]], metrics: list[str]) -> list
from skillevaluator.tier3.harbor.metrics import (
DEFAULT_METRIC_SET,
LEGACY_METRIC_SET,
+ metric_is_not_applicable,
metric_set_for_reward,
metric_set_for_rewards,
metric_value,
@@ -2979,9 +2981,17 @@ def _normalize_trials(rewards: list[dict[str, Any]], metrics: list[str]) -> list
(not declared_metric_set or str(declared_metric_set) in standard_metric_sets)
and metric_set in standard_metric_sets
and "skill_execution" in standard_metrics
- and metric_value(reward, "skill_execution") is not None
+ and (
+ metric_value(reward, "skill_execution") is not None
+ or metric_is_not_applicable(reward, "skill_execution")
+ )
)
- if not is_multi_row and is_standard_reward and reward.get("invocation_evidence_source") == "trajectory":
+ if (
+ not is_multi_row
+ and reward.get("invocation_evidence_scope") != "step"
+ and is_standard_reward
+ and reward.get("invocation_evidence_source") == "trajectory"
+ ):
for key in ("skill_invoked", "routing_passed"):
if type(reward.get(key)) is bool:
trial[key] = reward[key]
@@ -2990,10 +3000,123 @@ def _normalize_trials(rewards: list[dict[str, Any]], metrics: list[str]) -> list
harbor_viewer = _normalize_harbor_viewer_metadata(reward.get("harbor_viewer"))
if harbor_viewer:
trial["harbor_viewer"] = harbor_viewer
+ trial["activation_validation"] = _trial_activation_validation(group, trial)
out.append(trial)
return out
+def _trusted_observed_activation(reward: dict[str, Any]) -> str:
+ """Project collector-issued invocation evidence; never inspect trajectory or scores as proof."""
+ from skillevaluator.tier3.harbor.metrics import (
+ DEFAULT_METRIC_SET,
+ LEGACY_METRIC_SET,
+ metric_is_not_applicable,
+ metric_set_for_reward,
+ metric_value,
+ )
+
+ standard_sets = {DEFAULT_METRIC_SET, LEGACY_METRIC_SET}
+ declared = reward.get("metric_set") or reward.get("metric_set_version")
+ metric_set, metrics = metric_set_for_reward(reward)
+ if (
+ (declared and str(declared) not in standard_sets)
+ or metric_set not in standard_sets
+ or "skill_execution" not in metrics
+ or (metric_value(reward, "skill_execution") is None and not metric_is_not_applicable(reward, "skill_execution"))
+ or reward.get("invocation_evidence_source") != "trajectory"
+ ):
+ return "unknown"
+ invoked = reward.get("skill_invoked")
+ return ("invoked" if invoked else "not_invoked") if type(invoked) is bool else "unknown"
+
+
+def _trial_activation_validation(group: list[dict[str, Any]], trial: dict[str, Any]) -> dict[str, Any]:
+ """Keep routing, task quality, workflow and resources at their observed scopes.
+
+ Fallback reward rows do not prove a complete logical trajectory. Even when
+ every retained row says non-use, omitted steps may have used the skill.
+ Only a collector-produced single/merged root can certify logical non-use.
+ """
+ scopes: list[dict[str, Any]] = []
+ for index, reward in enumerate(group[:_MAX_EVIDENCE_PER_CARD]):
+ scope: dict[str, Any] = {"reward_row": index, "observed_activation": _trusted_observed_activation(reward)}
+ artifacts = reward.get("_activation_artifacts")
+ if isinstance(artifacts, dict):
+ scope["artifacts"] = {
+ key: value
+ for key, value in artifacts.items()
+ if key in {"reward", "trajectory"}
+ and isinstance(value, str)
+ and len(value) <= 4096
+ and not Path(value).is_absolute()
+ and ".." not in Path(value).parts
+ }
+ details = reward.get("details")
+ execution = details.get("skill_execution") if isinstance(details, dict) else None
+ workflow: dict[str, Any] = {}
+ if isinstance(execution, dict):
+ for key in ("workflow_order", "script_execution", "error_recovery"):
+ check = execution.get(key)
+ if isinstance(check, dict):
+ workflow[key] = {
+ "passed": check.get("passed") if type(check.get("passed")) is bool else None,
+ "score": _unit_interval_score(check.get("score")),
+ }
+ scope["workflow"] = workflow
+ scopes.append(scope)
+ logical_scope = len(group) == 1 and group[0].get("invocation_evidence_scope") == "logical_trial"
+ return {
+ "expected_activation": None,
+ "observed_activation": _trusted_observed_activation(group[0]) if logical_scope else "unknown",
+ "expectation_status": "unknown",
+ "observation_scope": "logical_trial" if logical_scope else "reward_rows_only",
+ "evidence_scopes": scopes,
+ "evidence_scopes_complete": len(group) <= _MAX_EVIDENCE_PER_CARD,
+ "task_outcome": {key: trial["scores"].get(key) for key in ("accuracy", "goal_accuracy")},
+ "resources": {key: trial[key] for key in ("steps", "tokens", "agent_seconds", "timing") if key in trial},
+ }
+
+
+def _attach_activation_expectations(
+ agents: dict[str, dict[str, Any]],
+ dataset: list[dict[str, Any]],
+ skill_name: str,
+) -> None:
+ """Compare authored expectations with observed use, independently of correctness."""
+ from skillevaluator.tier3.eval_core.checks import resolve_acceptable_skills, resolve_should_trigger
+
+ entries: dict[str, list[dict[str, Any]]] = {}
+ for entry in dataset:
+ if isinstance(entry, dict) and entry.get("id") is not None:
+ entries.setdefault(str(entry["id"]), []).append(entry)
+ for agent in agents.values():
+ for arm, baseline in (("trials", False), ("trials_baseline", True)):
+ for trial in agent.get(arm, []):
+ expected: bool | None = False if baseline else None
+ matches = entries.get(str(trial.get("entry_id")), [])
+ if not baseline and len(matches) == 1:
+ entry = matches[0]
+ should_trigger = resolve_should_trigger(entry)
+ if should_trigger is False:
+ expected = False
+ elif should_trigger is True:
+ expected_skill = entry.get("expected_skill")
+ if isinstance(expected_skill, str) and expected_skill.strip():
+ target = skill_name.strip().lower()
+ if expected_skill.strip().lower() == target:
+ expected = True
+ elif target not in {name.lower() for name in resolve_acceptable_skills(entry)}:
+ expected = False
+ # Allowed alternate use is optional, so neither use nor non-use is required.
+ validation = trial["activation_validation"]
+ validation["expected_activation"] = expected
+ observed = validation["observed_activation"]
+ if expected is not None and observed != "unknown":
+ validation["expectation_status"] = (
+ "matched" if (observed == "invoked") == expected else "mismatched"
+ )
+
+
def _trial_score_reasons(
rows: list[tuple[dict[str, Any], tuple[str, ...]]],
scores: dict[str, float],
diff --git a/src/skillevaluator/reporting/html.py b/src/skillevaluator/reporting/html.py
index 946b5082..25ddfe97 100644
--- a/src/skillevaluator/reporting/html.py
+++ b/src/skillevaluator/reporting/html.py
@@ -1277,14 +1277,27 @@ def _bounded_tier3_preview(payload: dict[str, Any] | None) -> tuple[dict[str, An
"""
if not payload:
return payload, {}
- serialized = _compact_json(payload)
+ # A private copy: the caller embeds ``payload`` itself as the canonical data.
+ slim = json.loads(_compact_json(payload))
+ # Activation diagnostics belong to the canonical export. The template does
+ # not render them, so duplicate per-trial copies must not spend overview or
+ # failure-reason space before the preview budget is applied.
+ agents = slim.get("agents")
+ containers = [slim, *(agents.values() if isinstance(agents, dict) else [])]
+ for container in containers:
+ if not isinstance(container, dict):
+ continue
+ for arm in ("trials", "trials_baseline"):
+ trials = container.get(arm)
+ for trial in trials if isinstance(trials, list) else []:
+ if isinstance(trial, dict):
+ trial.pop("activation_validation", None)
+ serialized = _compact_json(slim)
if len(serialized.encode("utf-8")) <= _TIER3_HTML_PREVIEW_TRIGGER_BYTES:
- return payload, {}
+ return slim, {}
from skillevaluator.evaluation.tier3_findings import failure_reason_text_slots, strip_failure_reason_text
- # A private copy: the caller embeds ``payload`` itself as the canonical data.
- slim = json.loads(serialized)
rendered_slots = list(failure_reason_text_slots(slim, include_top_level_cards=False))
deferred = [(container, key, container.pop(key)) for container, key in rendered_slots]
# The page renders each agent's cards, never the top-level card copy, so its
diff --git a/src/skillevaluator/tier3/harbor/collector.py b/src/skillevaluator/tier3/harbor/collector.py
index 39cd53c7..9d5db65b 100644
--- a/src/skillevaluator/tier3/harbor/collector.py
+++ b/src/skillevaluator/tier3/harbor/collector.py
@@ -5913,7 +5913,11 @@ def _annotate_security_attribution(
def _is_standard_skill_execution_reward(reward: dict[str, Any]) -> bool:
- """Return whether the reward carries a usable canonical standard score."""
+ """Admit standard invocation evidence independently of numeric skill grading.
+
+ A baseline's explicitly N/A skill score still has an observable trajectory.
+ Missing scores without the applicability marker do not establish support.
+ """
standard_metric_sets = {DEFAULT_METRIC_SET, LEGACY_METRIC_SET}
declared_metric_set = reward.get("metric_set") or reward.get("metric_set_version")
if declared_metric_set and str(declared_metric_set) not in standard_metric_sets:
@@ -5922,7 +5926,7 @@ def _is_standard_skill_execution_reward(reward: dict[str, Any]) -> bool:
return (
metric_set in standard_metric_sets
and "skill_execution" in metrics
- and metric_value(reward, "skill_execution") is not None
+ and (metric_value(reward, "skill_execution") is not None or metric_is_not_applicable(reward, "skill_execution"))
)
@@ -6137,7 +6141,7 @@ def _add_trusted_invocation_evidence(
"""Replace verifier-authored routing evidence on standard rewards only."""
if not _is_standard_skill_execution_reward(source_reward):
return
- for key in ("skill_invoked", "routing_passed", "invocation_evidence_source"):
+ for key in ("skill_invoked", "routing_passed", "invocation_evidence_source", "invocation_evidence_scope"):
clean_reward.pop(key, None)
if trial_root is None:
return
@@ -6155,6 +6159,7 @@ def _add_trusted_invocation_evidence(
else:
return
clean_reward["invocation_evidence_source"] = "trajectory"
+ clean_reward["invocation_evidence_scope"] = "step" if source_reward.get("_step_name") else "logical_trial"
def _can_restore_custom_metric_name(value: str) -> bool:
diff --git a/src/skillevaluator/tier3/harbor/report_data.py b/src/skillevaluator/tier3/harbor/report_data.py
index 747f793a..36520c07 100644
--- a/src/skillevaluator/tier3/harbor/report_data.py
+++ b/src/skillevaluator/tier3/harbor/report_data.py
@@ -848,6 +848,9 @@ def load_agent_data(
if not isinstance(reward, dict):
rewards_complete = False
continue
+ # Derive links from the bounded, admitted on-disk layout rather
+ # than accepting verifier-authored paths as provenance.
+ reward["_activation_artifacts"] = {"reward": reward_file.relative_to(results_dir).as_posix()}
if not reward.get("entry_id"):
reward["entry_id"] = trial_dir.name.split("__", 1)[0] if trial_dir.name else "unknown"
result_file = trial_dir / "result.json"
@@ -867,6 +870,9 @@ def load_agent_data(
artifact="trajectory",
)
if isinstance(trajectory, dict):
+ reward["_activation_artifacts"]["trajectory"] = trajectory_file.relative_to(
+ results_dir
+ ).as_posix()
final_metrics = trajectory.get("final_metrics", {})
if not isinstance(final_metrics, dict):
final_metrics = {}
diff --git a/tests/reporting/test_activation_validation.py b/tests/reporting/test_activation_validation.py
new file mode 100644
index 00000000..c0bf3a3b
--- /dev/null
+++ b/tests/reporting/test_activation_validation.py
@@ -0,0 +1,518 @@
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
+"""Repeatable activation acceptance cases through the trusted collector and report."""
+
+from __future__ import annotations
+
+import json
+from pathlib import Path
+
+import pytest
+
+from skillevaluator.evaluation.tier3_report import _normalize_trials, build_agent_eval_payload
+from skillevaluator.tier3.harbor.collector import _save_trials
+from skillevaluator.tier3.harbor.metrics import DEFAULT_METRIC_SET, DEFAULT_METRICS
+
+
+def _trajectory(skill: str | None = None) -> dict:
+ return {
+ "schema_version": "ATIF-v1.7",
+ "session_id": "root",
+ "trajectory_id": "root",
+ "agent": {"name": "codex", "version": "fixture"},
+ "steps": [
+ {
+ "step_id": 1,
+ "source": "agent",
+ "message": "done",
+ "tool_calls": (
+ [
+ {
+ "tool_call_id": "read",
+ "function_name": "Read",
+ "arguments": {"file_path": f"/workspace/skills/{skill}/SKILL.md"},
+ }
+ ]
+ if skill
+ else []
+ ),
+ }
+ ],
+ }
+
+
+def _collected(tmp_path: Path, trajectory: dict | None, *, variant: str = "with") -> dict:
+ trial = tmp_path / "job" / "case__attempt1"
+ (trial / "agent").mkdir(parents=True)
+ if trajectory is not None:
+ (trial / "agent" / "trajectory.json").write_text(json.dumps(trajectory))
+ reward = {
+ "entry_id": "case",
+ "_trial_name": "case__attempt1",
+ "_trial_root_name": "case__attempt1",
+ "metric_set": DEFAULT_METRIC_SET,
+ **dict.fromkeys(DEFAULT_METRICS, 1.0),
+ "details": {
+ "skill_execution": {
+ "workflow_order": {"score": 0.0, "passed": False},
+ "script_execution": {"score": 1.0, "passed": True},
+ }
+ },
+ # A verifier's invented invocation must be replaced, including when no trace exists.
+ "skill_invoked": True,
+ "invocation_evidence_source": "verifier",
+ }
+ if variant == "without":
+ for metric in ("skill_execution", "skill_efficiency"):
+ reward[metric] = None
+ reward["details"][metric] = {
+ "score": None,
+ "status": "not_applicable",
+ "reason": "N/A: this arm has no skill under test installed, so there is no skill to discover, run or route to",
+ }
+ _save_trials([reward], tmp_path / "saved", tmp_path / "job", skill_name="demo", agent="codex", variant=variant)
+ return json.loads(next((tmp_path / "saved").glob("*/reward.json")).read_text())
+
+
+def _payload(
+ rewards: list[dict],
+ expected_skill: object = "demo",
+ *,
+ baseline: list[dict] | None = None,
+ entry: dict | None = None,
+) -> dict:
+ payload = build_agent_eval_payload(
+ "demo",
+ {
+ "codex": {
+ "execution_status": "succeeded",
+ "with_skill": dict.fromkeys(DEFAULT_METRICS, 1.0),
+ "without_skill": {"security": 1.0, "accuracy": 1.0, "goal_accuracy": 1.0, "behavior_check": 1.0}
+ if baseline
+ else {},
+ "rewards": rewards,
+ "rewards_baseline": baseline or [],
+ "model": "fixture-model",
+ }
+ },
+ dataset=[entry if entry is not None else {"id": "case", "expected_skill": expected_skill}],
+ env_mode="docker",
+ run_id="fixture-run",
+ use_llm_judge=False,
+ )
+ assert payload is not None
+ return payload
+
+
+ ("skill", "expected_skill", "observed", "status"),
+ [
+ ("demo", "demo", "invoked", "matched"),
+ (None, "demo", "not_invoked", "mismatched"),
+ ("unrelated", "demo", "not_invoked", "mismatched"),
+ (None, None, "not_invoked", "matched"),
+ ("demo", None, "invoked", "mismatched"),
+ ],
+ ids=["explicit-use", "missed-implicit-use", "wrong-skill", "negative-non-use", "irrelevant-use"],
+)
+def test_activation_expectation_is_independent_of_perfect_task_score(
+ tmp_path: Path,
+ skill: str | None,
+ expected_skill: str | None,
+ observed: str,
+ status: str,
+) -> None:
+ reward = _collected(tmp_path, _trajectory(skill))
+ trial = _payload([reward], expected_skill)["trials"][0]
+ validation = trial["activation_validation"]
+ assert validation["expected_activation"] is (expected_skill == "demo")
+ assert validation["observed_activation"] == observed
+ assert validation["expectation_status"] == status
+ assert validation["task_outcome"] == {"accuracy": 1.0, "goal_accuracy": 1.0}
+ assert trial["overall"] == 1.0
+ assert validation["evidence_scopes"][0]["workflow"]["workflow_order"] == {"passed": False, "score": 0.0}
+
+
[email protected]("expected_skill", ["DEMO", " Demo "])
[email protected](("skill", "status"), [("demo", "matched"), (None, "mismatched")])
+def test_primary_activation_identity_is_case_insensitive(
+ tmp_path: Path, expected_skill: str, skill: str | None, status: str
+) -> None:
+ trial = _payload([_collected(tmp_path, _trajectory(skill))], expected_skill)["trials"][0]
+ validation = trial["activation_validation"]
+ assert validation["expected_activation"] is True
+ assert validation["expectation_status"] == status
+ assert trial["overall"] == 1.0
+
+
[email protected]("alias", ["acceptable_skills", "acceptable_alternates"])
[email protected]("skill", ["demo", None])
+def test_allowed_alternate_activation_is_optional(tmp_path: Path, alias: str, skill: str | None) -> None:
+ entry = {"id": "case", "expected_skill": "other", alias: [" DEMO "]}
+ trial = _payload([_collected(tmp_path, _trajectory(skill))], entry=entry)["trials"][0]
+ validation = trial["activation_validation"]
+ assert validation["expected_activation"] is None
+ assert validation["expectation_status"] == "unknown"
+ assert validation["observed_activation"] == ("invoked" if skill else "not_invoked")
+ assert trial["overall"] == 1.0
+
+
[email protected]("alias", ["acceptable_skills", "acceptable_alternates"])
[email protected](("skill", "status"), [("demo", "mismatched"), (None, "matched")])
+def test_explicit_negative_overrides_allowed_alternate(
+ tmp_path: Path, alias: str, skill: str | None, status: str
+) -> None:
+ entry = {"id": "case", "expected_skill": "other", alias: ["DEMO"], "should_trigger": False}
+ validation = _payload([_collected(tmp_path, _trajectory(skill))], entry=entry)["trials"][0][
+ "activation_validation"
+ ]
+ assert validation["expected_activation"] is False
+ assert validation["expectation_status"] == status
+
+
+ ("skill", "trace_present", "observed", "status"),
+ [
+ (None, True, "not_invoked", "matched"),
+ ("demo", True, "invoked", "mismatched"),
+ (None, False, "unknown", "unknown"),
+ ],
+ ids=["correct-baseline-non-use", "baseline-invocation", "missing-baseline-trace"],
+)
+def test_standard_baseline_retains_na_scores_and_independent_activation_evidence(
+ tmp_path: Path,
+ skill: str | None,
+ trace_present: bool,
+ observed: str,
+ status: str,
+) -> None:
+ with_skill = _collected(tmp_path / "with", _trajectory("demo"))
+ baseline = _collected(tmp_path / "without", _trajectory(skill) if trace_present else None, variant="without")
+ payload = _payload([with_skill], baseline=[baseline])
+ trial = payload["agents"]["codex"]["trials_baseline"][0]
+ validation = trial["activation_validation"]
+ assert validation["expected_activation"] is False
+ assert validation["observed_activation"] == observed
+ assert validation["expectation_status"] == status
+ assert validation["task_outcome"] == {"accuracy": 1.0, "goal_accuracy": 1.0}
+ for metric in ("skill_execution", "skill_efficiency"):
+ assert baseline[metric] is None
+ assert baseline["details"][metric]["score"] is None
+ assert baseline["details"][metric]["status"] == "not_applicable"
+ assert metric not in trial["scores"]
+ assert metric in trial["not_applicable_metrics"]
+ if trace_present:
+ assert baseline["skill_invoked"] is (skill == "demo")
+ assert baseline["invocation_evidence_scope"] == "logical_trial"
+ else:
+ assert "skill_invoked" not in baseline
+ assert "invocation_evidence_scope" not in baseline
+
+
+def test_missing_trace_stays_unknown_even_with_perfect_scores(tmp_path: Path) -> None:
+ trial = _payload([_collected(tmp_path, None)])["trials"][0]
+ assert trial["activation_validation"]["observed_activation"] == "unknown"
+ assert trial["activation_validation"]["expectation_status"] == "unknown"
+
+
[email protected]("referenced", [True, False])
+def test_only_referenced_subagent_proves_activation(tmp_path: Path, referenced: bool) -> None:
+ root = _trajectory()
+ child = _trajectory("demo")
+ child["trajectory_id"] = child["session_id"] = "child"
+ root["subagent_trajectories"] = [child]
+ if referenced:
+ root["steps"][0]["observation"] = {
+ "results": [
+ {
+ "content": "done",
+ "subagent_trajectory_ref": [{"trajectory_id": "child"}],
+ }
+ ]
+ }
+ validation = _payload([_collected(tmp_path, root)])["trials"][0]["activation_validation"]
+ assert validation["observed_activation"] == ("invoked" if referenced else "not_invoked")
+
+
+def test_copied_context_does_not_prove_activation(tmp_path: Path) -> None:
+ root = _trajectory("demo")
+ root["steps"][0]["is_copied_context"] = True
+ root["steps"].append({"step_id": 2, "source": "agent", "message": "done", "tool_calls": []})
+ validation = _payload([_collected(tmp_path, root)])["trials"][0]["activation_validation"]
+ assert validation["observed_activation"] == "not_invoked"
+
+
+def test_multistep_projection_retains_scoped_evidence_without_claiming_complete_trace() -> None:
+ rows = [
+ {
+ "trial_id": "logical",
+ "entry_id": "case",
+ "metric_set": DEFAULT_METRIC_SET,
+ **dict.fromkeys(DEFAULT_METRICS, 1.0),
+ "skill_invoked": invoked,
+ "invocation_evidence_source": "trajectory",
+ "_activation_artifacts": {"reward": f"codex/with-skill/trials/step-{index}/reward.json"},
+ }
+ for index, invoked in enumerate((True, False))
+ ]
+ [trial] = _normalize_trials(rows, list(DEFAULT_METRICS))
+ validation = trial["activation_validation"]
+ assert validation["observed_activation"] == "unknown"
+ assert [scope["observed_activation"] for scope in validation["evidence_scopes"]] == ["invoked", "not_invoked"]
+ assert validation["evidence_scopes"][1]["artifacts"]["reward"] == "codex/with-skill/trials/step-1/reward.json"
+ assert "skill_invoked" not in trial
+
+
+def test_custom_only_and_untrusted_flags_stay_unknown() -> None:
+ for contract, source in (("custom-only", "trajectory"), (DEFAULT_METRIC_SET, "verifier")):
+ [trial] = _normalize_trials(
+ [
+ {
+ "metric_set": contract,
+ "skill_execution": 1.0,
+ "skill_invoked": True,
+ "invocation_evidence_source": source,
+ }
+ ],
+ ["skill_execution"],
+ )
+ assert trial["activation_validation"]["observed_activation"] == "unknown"
+
+
+def test_dangling_subagent_reference_cannot_prove_non_use(tmp_path: Path) -> None:
+ root = _trajectory()
+ root["steps"][0]["observation"] = {
+ "results": [
+ {
+ "content": "missing child",
+ "subagent_trajectory_ref": [{"trajectory_id": "missing"}],
+ }
+ ]
+ }
+ validation = _payload([_collected(tmp_path, root)])["trials"][0]["activation_validation"]
+ assert validation["observed_activation"] == "unknown"
+
+
+def test_saved_run_links_each_observation_to_retained_artifacts(tmp_path: Path) -> None:
+ from skillevaluator.tier3.harbor.report_data import load_agent_data
+
+ reward = _collected(tmp_path, _trajectory("demo"))
+ condition = tmp_path / "run" / "codex" / "with-skill"
+ trial = condition / "trials" / "case"
+ trial.mkdir(parents=True)
+ (trial / "reward.json").write_text(json.dumps(reward))
+ (trial / "trajectory.json").write_text(json.dumps(_trajectory("demo")))
+ (condition / "summary.json").write_text(
+ json.dumps(
+ {
+ "scores": dict.fromkeys(DEFAULT_METRICS, 1.0),
+ "metrics": list(DEFAULT_METRICS),
+ "execution_status": "succeeded",
+ "num_trials": 1,
+ }
+ )
+ )
+ agents = load_agent_data(tmp_path / "run")
+ payload = build_agent_eval_payload(
+ "demo", agents, dataset=[{"id": "case", "expected_skill": "demo"}], use_llm_judge=False
+ )
+ assert payload is not None
+ scope = payload["trials"][0]["activation_validation"]["evidence_scopes"][0]
+ assert scope["artifacts"] == {
+ "reward": "codex/with-skill/trials/case/reward.json",
+ "trajectory": "codex/with-skill/trials/case/trajectory.json",
+ }
+ assert scope["observed_activation"] == "invoked"
+
+
+def test_missing_expectation_is_unknown_rather_than_a_negative_case() -> None:
+ reward = {
+ "entry_id": "case",
+ "metric_set": DEFAULT_METRIC_SET,
+ **dict.fromkeys(DEFAULT_METRICS, 1.0),
+ "skill_invoked": False,
+ "invocation_evidence_source": "trajectory",
+ }
+ payload = build_agent_eval_payload(
+ "demo",
+ {"codex": {"with_skill": dict.fromkeys(DEFAULT_METRICS, 1.0), "rewards": [reward]}},
+ dataset=[{"id": "case"}],
+ use_llm_judge=False,
+ )
+ assert payload is not None
+ validation = payload["trials"][0]["activation_validation"]
+ assert validation["expected_activation"] is None
+ assert validation["expectation_status"] == "unknown"
+
+
+def test_resource_diagnostics_do_not_imply_activation() -> None:
+ [trial] = _normalize_trials(
+ [
+ {
+ "accuracy": 1.0,
+ "_traj": {"steps": 2, "prompt_tokens": 10, "completion_tokens": 4},
+ "_agent_seconds": 3.0,
+ }
+ ],
+ ["accuracy"],
+ )
+ validation = trial["activation_validation"]
+ assert validation["observed_activation"] == "unknown"
+ assert validation["resources"] == {"steps": 2, "tokens": {"prompt": 10, "completion": 4}, "agent_seconds": 3.0}
+
+
+def test_omitted_multistep_rows_do_not_turn_one_retained_step_into_logical_non_use() -> None:
+ [trial] = _normalize_trials(
+ [
+ {
+ "trial_id": "logical",
+ "entry_id": "case",
+ "metric_set": DEFAULT_METRIC_SET,
+ **dict.fromkeys(DEFAULT_METRICS, 1.0),
+ "skill_invoked": False,
+ "invocation_evidence_source": "trajectory",
+ "invocation_evidence_scope": "step",
+ }
+ ],
+ list(DEFAULT_METRICS),
+ )
+ validation = trial["activation_validation"]
+ assert validation["observed_activation"] == "unknown"
+ assert validation["observation_scope"] == "reward_rows_only"
+ assert validation["evidence_scopes"][0]["observed_activation"] == "not_invoked"
+
+
+def test_collector_marks_logical_invocation_scope(tmp_path: Path) -> None:
+ reward = _collected(tmp_path, _trajectory("demo"))
+ assert reward["invocation_evidence_scope"] == "logical_trial"
+
+
[email protected]("complete", [True, False])
+def test_native_multistep_root_requires_every_authoritative_trajectory(tmp_path: Path, complete: bool) -> None:
+ job = tmp_path / "job"
+ trial = job / "case__attempt1"
+ trial.mkdir(parents=True)
+ (trial / "result.json").write_text(
+ json.dumps(
+ {
+ "config": {"agent": {"resume_trajectory": False}},
+ "step_results": [{"step_name": "prepare"}, {"step_name": "finish"}],
+ }
+ )
+ )
+ for step_name in ("prepare", "finish") if complete else ("prepare",):
+ agent = trial / "steps" / step_name / "agent"
+ agent.mkdir(parents=True)
+ trajectory = _trajectory("demo" if step_name == "finish" else None)
+ trajectory["session_id"] = trajectory["trajectory_id"] = step_name
+ (agent / "trajectory.json").write_text(json.dumps(trajectory))
+ reward = {
+ "entry_id": "case",
+ "_trial_name": "case__attempt1",
+ "_trial_root_name": "case__attempt1",
+ "metric_set": DEFAULT_METRIC_SET,
+ **dict.fromkeys(DEFAULT_METRICS, 1.0),
+ }
+ _save_trials([reward], tmp_path / "saved", job, skill_name="demo", agent="codex", variant="with")
+ saved = json.loads(next((tmp_path / "saved").glob("*/reward.json")).read_text())
+ validation = _payload([saved])["trials"][0]["activation_validation"]
+ assert validation["observed_activation"] == ("invoked" if complete else "unknown")
+ if complete:
+ assert saved["invocation_evidence_scope"] == "logical_trial"
+
+
+def test_collector_retains_step_scope_for_fallback_reward_rows(tmp_path: Path) -> None:
+ job = tmp_path / "job"
+ trial = job / "case__attempt1"
+ trial.mkdir(parents=True)
+ (trial / "result.json").write_text(json.dumps({"step_results": [{"step_name": "one"}]}))
+ agent = trial / "steps" / "one" / "agent"
+ agent.mkdir(parents=True)
+ (agent / "trajectory.json").write_text(json.dumps(_trajectory()))
+ reward = {
+ "entry_id": "case",
+ "_trial_name": "case__attempt1__one",
+ "_trial_root_name": "case__attempt1",
+ "_step_name": "one",
+ "metric_set": DEFAULT_METRIC_SET,
+ **dict.fromkeys(DEFAULT_METRICS, 1.0),
+ }
+ _save_trials([reward], tmp_path / "saved", job, skill_name="demo", agent="codex", variant="with")
+ saved = json.loads(next((tmp_path / "saved").glob("*/reward.json")).read_text())
+ assert saved["invocation_evidence_scope"] == "step"
+ validation = _payload([saved])["trials"][0]["activation_validation"]
+ assert validation["observed_activation"] == "unknown"
+ assert validation["evidence_scopes"][0]["observed_activation"] == "not_invoked"
+
+
+def test_historical_unspecified_scope_cannot_certify_a_complete_logical_trial(tmp_path: Path) -> None:
+ reward = _collected(tmp_path, _trajectory("demo"))
+ reward.pop("invocation_evidence_scope")
+ validation = _payload([reward])["trials"][0]["activation_validation"]
+ assert validation["observed_activation"] == "unknown"
+ assert validation["evidence_scopes"][0]["observed_activation"] == "invoked"
+
+
+ "entry",
+ [
+ {"id": "case", "expected_skill": "demo", "should_trigger": False},
+ {"id": "case", "should_trigger": False},
+ ],
+ ids=["named-negative", "nameless-negative"],
+)
[email protected](("skill", "status"), [(None, "matched"), ("demo", "mismatched")])
+def test_explicit_negative_precedence_matches_runner_contract(
+ tmp_path: Path,
+ entry: dict,
+ skill: str | None,
+ status: str,
+) -> None:
+ reward = _collected(tmp_path, _trajectory(skill))
+ validation = _payload([reward], entry=entry)["trials"][0]["activation_validation"]
+ assert validation["expected_activation"] is False
+ assert validation["expectation_status"] == status
+
+
+ "entry",
+ [
+ {"id": "case"},
+ {"id": "case", "should_trigger": True},
+ {"id": "case", "expected_skill": None, "should_trigger": True},
+ ],
+ ids=["unlabeled", "positive-without-target", "positive-with-null-target"],
+)
+def test_activation_expectation_needs_a_target_for_positive_routing(tmp_path: Path, entry: dict) -> None:
+ reward = _collected(tmp_path, _trajectory("demo"))
+ validation = _payload([reward], entry=entry)["trials"][0]["activation_validation"]
+ assert validation["expected_activation"] is None
+ assert validation["expectation_status"] == "unknown"
+
+
+def test_custom_only_na_skill_metrics_do_not_create_supported_activation(tmp_path: Path) -> None:
+ reward = _collected(tmp_path, _trajectory(), variant="without")
+ reward["metric_set"] = "custom-only"
+ reward["skill_invoked"] = False
+ reward["invocation_evidence_source"] = "trajectory"
+ reward["invocation_evidence_scope"] = "logical_trial"
+ [trial] = _normalize_trials([reward], list(DEFAULT_METRICS))
+ assert trial["activation_validation"]["observed_activation"] == "unknown"
+
+
+def test_null_skill_score_without_explicit_na_provenance_stays_unsupported() -> None:
+ [trial] = _normalize_trials(
+ [
+ {
+ "metric_set": DEFAULT_METRIC_SET,
+ **dict.fromkeys(DEFAULT_METRICS, 1.0),
+ "skill_execution": None,
+ "skill_invoked": False,
+ "invocation_evidence_source": "trajectory",
+ "invocation_evidence_scope": "logical_trial",
+ }
+ ],
+ list(DEFAULT_METRICS),
+ )
+ assert trial["activation_validation"]["observed_activation"] == "unknown"
diff --git a/tests/reporting/test_report_data_bounds.py b/tests/reporting/test_report_data_bounds.py
index 09cf8c76..7f488f65 100644
--- a/tests/reporting/test_report_data_bounds.py
+++ b/tests/reporting/test_report_data_bounds.py
@@ -72,6 +72,10 @@ def test_normal_agent_artifacts_are_loaded_without_truncation_marker(tmp_path: P
{
"entry_id": "case-001",
"accuracy": 1.0,
+ "_activation_artifacts": {
+ "reward": "codex/with-skill/trials/case-001__1/reward.json",
+ "trajectory": "codex/with-skill/trials/case-001__1/trajectory.json",
+ },
"_traj": {"steps": 1, "prompt_tokens": 10, "completion_tokens": 4, "cached_tokens": 2},
}
]
diff --git a/tests/reporting/test_tier3_failure_reasons.py b/tests/reporting/test_tier3_failure_reasons.py
index 96e1757c..e89f6cd4 100644
--- a/tests/reporting/test_tier3_failure_reasons.py
+++ b/tests/reporting/test_tier3_failure_reasons.py
@@ -716,6 +716,25 @@ def test_html_preview_keeps_the_overview_when_failure_reasons_overflow_it() -> N
assert "built-in method" not in html
+def test_html_preview_excludes_unrendered_activation_detail_without_changing_canonical_data() -> None:
+ data = _display_data(_failing_multi_agent_payload(2, 1))
+ detail = {"diagnostic": "unrendered-activation-detail" * 30_000}
+ data["trials"][0]["activation_validation"] = detail
+ for key in ("trials", "trials_baseline"):
+ data["agents"]["agent-0"][key][0]["activation_validation"] = detail
+ original = copy.deepcopy(data)
+
+ preview, notice = html_module._bounded_tier3_preview(data)
+
+ assert preview is not None
+ assert notice == {}
+ assert preview["best_agent"] == "agent-0"
+ assert _rendered_reason_count(preview) == _rendered_reason_count(data)
+ assert "unrendered-activation-detail" not in json.dumps(preview)
+ assert data == original
+ assert data["trials"][0]["activation_validation"] == detail
+
+
def test_html_preview_drops_failure_reasons_before_bounding_a_large_payload() -> None:
payload = _failing_multi_agent_payload(3, 60)
data = _display_data(payload)