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.
Python agent-evaluationagent-pluginsagent-securityagent-skillsagentic-aibenchmarkci-templatesclaude-codecodexevaluateevaluationharnesspluginplugin-evaluationsecurity-scannerskill-evalskill-evaluationskill-evaluatorskill-gap-analysisskills
fix(security): explain SkillSpector LLM provider outages as retriable incomplete scans (#342)
Narendran Raghavan9bda66d3bf69
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3cb31aba..ebcd2e63 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1040,6 +1040,17 @@ All notable changes to SkillEvaluator are documented in this file.forwarded to SkillSpector so its own deadline can be raised as well, and thesecurity result records the effective `skillspector_timeout_seconds`([#155](https://github.com/NVIDIA/SkillEvaluator/issues/155)).+- An `--llm` security scan whose LLM provider keeps failing after+ SkillSpector's bounded retries no longer reports only+ `skillspector-llm failed with unexpected exit code 2: scanner diagnostics were redacted`+ (or `skillspector reported execution_successful=false`). When every failure+ in the SkillSpector v2.12.0+ report is an `llm_connection_retries_exhausted`+ row on an LLM analyzer, the error says that the provider kept failing, that+ this is a retriable provider failure rather than a security finding, and+ that the full scan should be retried when the provider is available. Mixed,+ truncated, malformed or older reports keep the generic error. The scan stays+ `INCOMPLETE` with a nonzero exit, and static findings still decide a+ `FAILED` result.- `similarity-check --catalog` and `tier2 --catalog` no longer report a skillthat is already in the local catalog as an `EXACT_DUPLICATE` of its ownentry, which failed the run. An entry is skipped as the skill's own only whendiff --git a/docs/tier1-validation.mdx b/docs/tier1-validation.mdxindex 95596adf..b3d255b8 100644--- a/docs/tier1-validation.mdx+++ b/docs/tier1-validation.mdx@@ -541,6 +541,31 @@ Tier 1 checks always gate the exit code inside `validate`. Tier 2 gates when ittake up to twice the value before it is reported. See[Environment Variables](environment-variables.mdx#validation-tier-1).</Accordion>+ <Accordion title="The SkillSpector LLM provider keeps failing">+ With `--llm`, SkillSpector v2.12.0 and later retries a failing provider call+ a bounded number of times. When the provider still fails, for example+ because of rate limits or an outage, SkillSpector records the+ `llm_connection_retries_exhausted` reason and ends the LLM stage as failed.+ If that is the only cause in a report from SkillSpector v2.12.0 or later,+ the security error reads+ `skillspector-llm did not complete: the LLM provider kept failing after SkillSpector's bounded retries`+ and says that this is a retriable provider failure, not a security+ finding. Retry the full scan when the provider is available.++ The gate is unchanged: the security scan is `INCOMPLETE`, the command+ exits `1`, and findings from the static stage are kept, so a High or+ Critical static finding still makes the result `FAILED`.++ SkillEvaluator shows this message only when every failure that+ SkillSpector recorded is a provider-retry failure on an LLM analyzer.+ Reports that mix it with another cause, are truncated or malformed, or come+ from an older SkillSpector keep the generic error, such as+ `skillspector-llm failed with unexpected exit code 2`. SkillSpector v2.9.1+ to v2.11.2 used the same reason only for a connection error left after the+ provider SDK's own retries, so SkillEvaluator does not read it from those+ releases. A provider error that SkillSpector records under a different+ reason also keeps the generic error.+ </Accordion><Accordion title="An LLM-backed stage fails immediately">Configure a supported provider or select a keyless Tier 1 run with`skillevaluator tier1 ./my-skill --no-llm` ordiff --git a/src/skillevaluator/validators/security.py b/src/skillevaluator/validators/security.pyindex 1c6a1b66..95a47424 100644--- a/src/skillevaluator/validators/security.py+++ b/src/skillevaluator/validators/security.py@@ -51,7 +51,7 @@ from skillevaluator.provider_config import (resolve_llm_provider,skillspector_reasoning_effort,)-from skillevaluator.skillspector_provenance import sanitize_skillspector_llm_provenance+from skillevaluator.skillspector_provenance import SKILLSPECTOR_LLM_ANALYZERS, sanitize_skillspector_llm_provenancefrom skillevaluator.spdx import is_spdx_only_html_commentfrom skillevaluator.utils.path_security import matches_filesystem_namefrom skillevaluator.utils.scanner_install import prepare_skillspector@@ -445,6 +445,156 @@ def _skillspector_report_llm_provenance(report: object) -> dict | None:return sanitize_skillspector_llm_provenance(metadata.get("llm_provenance"))+# SkillSpector 2.12.0 and later retries transient provider failures, such as rate+# limits, in its own bounded loop and records a fatal+# ``llm_connection_retries_exhausted`` ledger row when that loop gives up. A+# fatal row makes ``execution_successful`` false, and the scan command prints the+# report before it exits with this code. Releases 2.9.1 to 2.11.2 used the same+# reason only for a connection error left after the provider SDK's own retries,+# so their reports keep the generic error.+_SKILLSPECTOR_EXECUTION_FAILED_EXIT_CODE = 2+_SKILLSPECTOR_PROVIDER_RETRY_VERSION = (2, 12, 0)+_SKILLSPECTOR_PROVIDER_RETRY_REASON = "llm_connection_retries_exhausted"+_SKILLSPECTOR_PROVIDER_RETRY_MAX_ROWS = 4096+_SKILLSPECTOR_PROVIDER_RETRY_MAX_MESSAGE = 4096+# The run-level row SkillSpector adds on SKILL.md when requested semantic+# analysis did not finish. It names no analyzer and is not fatal.+_SKILLSPECTOR_SEMANTIC_RUNTIME_ROW = {+ "outcome": "partial",+ "phase": "semantic_runtime",+ "reason_code": "semantic_runtime_incomplete",+ "message": "Requested semantic analysis did not produce complete per-source runtime telemetry.",+ "path": "SKILL.md",+ "start_line": None,+ "end_line": None,+ "fatal": False,+}+_SKILLSPECTOR_REPORT_FAILURE_MARKERS = ("error", "errors", "exceptions", "failed", "failure", "failures")+++def _skillspector_provider_retry_row(row: object) -> bool:+ """Return whether one ledger row is a provider-retry exhaustion on LLM analyzers only."""+ if not isinstance(row, dict):+ return False+ phase = row.get("phase")+ path = row.get("path")+ analyzers = row.get("analyzers")+ message = row.get("message")+ return (+ row.get("reason_code") == _SKILLSPECTOR_PROVIDER_RETRY_REASON+ and row.get("outcome") == "failed"+ and row.get("fatal") is True+ and phase in ("semantic", "meta")+ and isinstance(message, str)+ and 0 < len(message) <= _SKILLSPECTOR_PROVIDER_RETRY_MAX_MESSAGE+ and isinstance(path, str)+ and bool(path.strip())+ and isinstance(analyzers, list)+ and bool(analyzers)+ and all(isinstance(analyzer, str) and analyzer in SKILLSPECTOR_LLM_ANALYZERS for analyzer in analyzers)+ and len(set(analyzers)) == len(analyzers)+ # Only the meta analyzer runs in the meta phase.+ and all((analyzer == "meta_analyzer") == (phase == "meta") for analyzer in analyzers)+ )+++def _skillspector_provider_retries_exhausted(data: object) -> bool:+ """Return whether a failed LLM-stage report shows only an LLM provider outage.++ Every ledger exception must be a fatal ``llm_connection_retries_exhausted``+ row for LLM analyzers, apart from SkillSpector's run-level+ ``semantic_runtime_incomplete`` row on ``SKILL.md``. Exactly those analyzers+ must report ``failed``, every other analyzer must have finished, and every+ limitation must name one of the failed analyzers. Older,+ truncated, malformed or mixed reports return ``False`` and keep the generic+ error, so a scanner fault cannot pass for a provider outage.+ """+ if not isinstance(data, dict) or data.get("execution_successful") is not False:+ return False+ metadata = data.get("metadata")+ raw_version = metadata.get("skillspector_version") if isinstance(metadata, dict) else None+ if not isinstance(raw_version, str) or SEMVER_RE.fullmatch(raw_version) is None:+ return False+ if tuple(int(part) for part in raw_version.split(".")) < _SKILLSPECTOR_PROVIDER_RETRY_VERSION:+ return False+ completeness = data.get("analysis_completeness")+ if (+ not isinstance(completeness, dict)+ or completeness.get("execution_successful") is not False+ or completeness.get("status") != "failed"+ or completeness.get("is_complete") is not False+ ):+ return False+ for container in (data, completeness):+ if any(container.get(key) for key in _SKILLSPECTOR_REPORT_FAILURE_MARKERS):+ return False+ # A truncated list may hide a different cause.+ if any(+ isinstance(key, str) and key.endswith("_truncated") and value is not False and value is not None+ for key, value in container.items()+ ):+ return False++ rows = completeness.get("ledger_exceptions")+ if not isinstance(rows, list) or not 0 < len(rows) <= _SKILLSPECTOR_PROVIDER_RETRY_MAX_ROWS:+ return False+ provider_analyzers: set[str] = set()+ provider_messages: set[str] = set()+ for row in rows:+ if isinstance(row, dict) and row == _SKILLSPECTOR_SEMANTIC_RUNTIME_ROW and row["fatal"] is False:+ continue+ if not _skillspector_provider_retry_row(row):+ return False+ provider_analyzers.update(row["analyzers"])+ provider_messages.add(row["message"])+ if not provider_analyzers:+ return False++ statuses = completeness.get("analyzer_statuses")+ limitations = completeness.get("limitations", [])+ if not isinstance(statuses, list) or not isinstance(limitations, list):+ return False+ seen: set[str] = set()+ failed: set[str] = set()+ explained: set[str] = set()+ for status in statuses:+ if not isinstance(status, dict) or not isinstance(status.get("analyzer_id"), str):+ return False+ analyzer = status["analyzer_id"]+ if analyzer in seen:+ return False+ seen.add(analyzer)+ state = status.get("status")+ if state in ("completed", "not_applicable") and analyzer not in provider_analyzers:+ continue+ message = status.get("message")+ if (+ state != "failed"+ or analyzer not in provider_analyzers+ or any(status.get(key) for key in ("partial", "skipped", "unaccounted"))+ or status.get("reason_code") not in (None, _SKILLSPECTOR_PROVIDER_RETRY_REASON)+ or (message is not None and (not isinstance(message, str) or message not in provider_messages))+ ):+ return False+ failed.add(analyzer)+ explained.add(f"Analyzer {analyzer} status: failed.")+ if message is not None:+ explained.add(message)+ # Every analyzer named by a provider row must itself report the failure.+ return failed == provider_analyzers and all(+ isinstance(limitation, str) and limitation in explained for limitation in limitations+ )+++def _skillspector_provider_retry_error(stage_name: str) -> str:+ """Describe a provider outage in fixed text; no report field is quoted."""+ return (+ f"{stage_name} did not complete: the LLM provider kept failing after SkillSpector's bounded "+ f"retries ({_SKILLSPECTOR_PROVIDER_RETRY_REASON}). This is a retriable provider failure, not a "+ "security finding, and static findings are kept. Retry the full scan when the provider is available."+ )++def _copy_selected_environment(environ: Mapping[str, str], names: Iterable[str]) -> dict[str, str]:return {name: environ[name] for name in names if environ.get(name, "").strip()}@@ -1816,6 +1966,16 @@ class SecurityValidator(ValidatorBase):))if (+ use_llm+ and not error_message+ and tool_result.exit_code == _SKILLSPECTOR_EXECUTION_FAILED_EXIT_CODE+ and _skillspector_provider_retries_exhausted(data)+ ):+ # The stage stays incomplete; only the explanation changes.+ detail = _skillspector_provider_retry_error(stage_name)+ elif (+ # SkillSpector uses exit code 2 for both; a provider outage report+ # proves it accepted its input, including the baseline.baseline is not Noneand tool_result.error_message is Noneand tool_result.exit_code == _SKILLSPECTOR_INPUT_ERROR_EXIT_CODE@@ -1984,7 +2144,10 @@ class SecurityValidator(ValidatorBase):)return Falseif execution_successful is False:- result.add_error("skillspector reported execution_successful=false; security scan did not complete")+ if use_llm and _skillspector_provider_retries_exhausted(data):+ result.add_error(_skillspector_provider_retry_error(stage_name))+ else:+ result.add_error("skillspector reported execution_successful=false; security scan did not complete")return Falsefindings_after_filtering: int | None = Nonediff --git a/tests/validators/test_security.py b/tests/validators/test_security.pyindex 6055c37f..74710d86 100644--- a/tests/validators/test_security.py+++ b/tests/validators/test_security.py@@ -6391,6 +6391,534 @@ description: Testassert "aws" in findings_text+_GENERIC_LLM_EXIT_2_ERROR = "skillspector-llm failed with unexpected exit code 2: scanner diagnostics were redacted"+_PROVIDER_OUTAGE_ERROR_START = "skillspector-llm did not complete: the LLM provider kept failing"+_SEMANTIC_RUNTIME_ROW = {+ "outcome": "partial",+ "phase": "semantic_runtime",+ "reason_code": "semantic_runtime_incomplete",+ "message": "Requested semantic analysis did not produce complete per-source runtime telemetry.",+ "path": "SKILL.md",+ "start_line": None,+ "end_line": None,+ "fatal": False,+}+++def _skillspector_provider_outage_report(*, old_scanner: bool = False) -> dict:+ """Return a SkillSpector 2.13.3 LLM-stage report whose only fatal cause is provider retry exhaustion.++ ``old_scanner`` adds what SkillSpector can also emit for the same outage: a+ failed row for ``SKILL.md``, a High AE1 finding derived from the outage, and+ the run-level ``semantic_runtime_incomplete`` row.+ """+ row = {+ "outcome": "failed",+ "phase": "semantic",+ "reason_code": "llm_connection_retries_exhausted",+ "message": "Transient LLM provider failure persisted after bounded retries.",+ "path": "references/guide.md",+ "start_line": None,+ "end_line": None,+ "fatal": True,+ "error_class": "RateLimitError",+ "analyzers": ["mcp_tool_poisoning", "semantic_security_discovery"],+ }+ payload = _skillspector_json_report(llm_requested=True, llm_available=True)+ payload["metadata"]["skillspector_version"] = "2.13.3"+ payload["components"] = [+ {"path": "SKILL.md", "executable": False},+ {"path": "references/guide.md", "executable": False},+ ]+ payload["execution_successful"] = False+ completeness = payload["analysis_completeness"]+ completeness.update(+ {+ "execution_successful": False,+ "status": "failed",+ "is_complete": False,+ "total_components": 2,+ "scanned_components": 1,+ "fully_inspected_files": 1,+ "partially_inspected_files": 1,+ "coverage_percent": 50.0,+ "ledger_exceptions": [row],+ "limitations": [f"Analyzer {analyzer} status: failed." for analyzer in row["analyzers"]],+ }+ )+ for status in completeness["analyzer_statuses"]:+ if status["analyzer_id"] in row["analyzers"]:+ status.update({"status": "failed", "planned_work": 2, "completed": 1, "failed": 1})+ if old_scanner:+ completeness["ledger_exceptions"].append({**row, "path": "SKILL.md"})+ completeness["ledger_exceptions"].append(dict(_SEMANTIC_RUNTIME_ROW))+ for status in completeness["analyzer_statuses"]:+ if status["analyzer_id"] in row["analyzers"]:+ status.update({"planned_work": 3, "failed": 2})+ payload["issues"] = [+ {+ "id": "AE1",+ "finding_id": "finding-ae1",+ "confidence": 1.0,+ "category": "Analysis Evasion",+ "pattern": "Incomplete referenced artifact analysis",+ "severity": "HIGH",+ "finding": "references/guide.md (failed)",+ "location": {"file": "SKILL.md", "start_line": 7},+ "evidence": {+ "target_path": "references/guide.md",+ "target_disposition": "failed",+ "reasons": [+ {+ "reason_code": row["reason_code"],+ "phase": row["phase"],+ "message": row["message"],+ "analyzers": list(row["analyzers"]),+ }+ ],+ },+ }+ ]+ payload["risk_assessment"].update({"score": 80, "severity": "HIGH"})+ return payload+++def _run_llm_scan(+ mock_tools,+ skill_dir: Path,+ llm_report: dict,+ *,+ exit_code: int = 2,+ static_issues: list[dict] | None = None,+ error_message: str | None = None,+ baseline: Path | None = None,+) -> ValidationResult:+ """Run a static stage that completes, then an LLM stage that returns *llm_report*."""+ mock_tools.skillspector.is_available = True+ mock_tools.skillspector.run.side_effect = [+ ToolResult(+ success=True,+ stdout=json.dumps(_skillspector_json_report(static_issues)),+ stderr="",+ exit_code=1 if static_issues else 0,+ ),+ ToolResult(+ success=True,+ stdout=json.dumps(llm_report),+ stderr="",+ exit_code=exit_code,+ error_message=error_message,+ ),+ ]+ return SecurityValidator(use_llm=True, skillspector_baseline=baseline).validate_security_only(skill_dir)+++class TestSkillspectorProviderOutage:+ """A SkillSpector LLM provider outage stays INCOMPLETE and says the scan can be retried."""++ @pytest.mark.parametrize("old_scanner", [False, True], ids=["provider-rows", "with-ae1"])+ @patch("skillevaluator.validators.security.Tools")+ def test_provider_only_failure_is_incomplete_with_retry_advice(+ self,+ mock_tools,+ old_scanner: bool,+ sample_skill_dir: Path,+ ) -> None:+ result = _run_llm_scan(+ mock_tools, sample_skill_dir, _skillspector_provider_outage_report(old_scanner=old_scanner)+ )++ assert result.status == "incomplete"+ assert not result.passed+ assert result.incomplete_scans == ["skillspector-llm"]+ # Issues in the failed LLM report, including an outage-derived AE1, are not converted.+ assert result.findings == []+ assert len(result.errors) == 1+ error = result.errors[0]+ assert error.startswith(_PROVIDER_OUTAGE_ERROR_START)+ assert "(llm_connection_retries_exhausted)" in error+ assert "retriable provider failure" in error+ assert "Retry the full scan when the provider is available." in error+ assert "unexpected exit code" not in error+ report = json.loads(JSONReporter(include_timestamp=False).render_all([result]))+ assert report["overall_status"] == "incomplete"+ assert report["overall_passed"] is False+ # Strip styling and line wrapping, which depend on the terminal.+ cli_text = " ".join(re.sub(r"\x1b\[[0-9;]*m", "", CLIReporter().render_all([result])).split())+ assert "[INCOMPLETE] skillspector-llm did not complete" in cli_text+ assert "retriable provider failure, not a security finding" in cli_text++ @patch("skillevaluator.validators.security.Tools")+ def test_provider_outage_with_a_baseline_gets_only_the_retry_advice(+ self,+ mock_tools,+ sample_skill_dir: Path,+ tmp_path: Path,+ ) -> None:+ baseline = tmp_path / "audit" / "skillspector-baseline.yaml"+ baseline.parent.mkdir()+ baseline.write_text(+ 'version: 2\nrules:\n - id: "PE5"\n path: "SKILL.md"\n reason: "Reviewed"\n',+ encoding="utf-8",+ )++ result = _run_llm_scan(mock_tools, sample_skill_dir, _skillspector_provider_outage_report(), baseline=baseline)++ assert result.incomplete_scans == ["skillspector-llm"]+ [error] = result.errors+ assert error.startswith(_PROVIDER_OUTAGE_ERROR_START)+ assert "--baseline" not in error+ assert ".." not in error++ @patch("skillevaluator.validators.security.Tools")+ def test_provider_failure_keeps_static_findings_and_failed_verdict(+ self,+ mock_tools,+ sample_skill_dir: Path,+ ) -> None:+ static_issue = {+ "id": "DE1",+ "category": "Data Exfiltration",+ "pattern": "Data exfiltration",+ "severity": "HIGH",+ "finding": "Sends secrets to an untrusted endpoint",+ "location": {"file": "SKILL.md", "start_line": 3},+ }++ result = _run_llm_scan(+ mock_tools,+ sample_skill_dir,+ _skillspector_provider_outage_report(old_scanner=True),+ static_issues=[static_issue],+ )++ assert result.incomplete_scans == ["skillspector-llm"]+ assert [finding.check_name for finding in result.findings] == ["Data exfiltration (DE1)"]+ assert result.findings[0].severity == Severity.HIGH+ assert any(error.startswith(_PROVIDER_OUTAGE_ERROR_START) for error in result.errors)+ report = json.loads(JSONReporter(include_timestamp=False).render_all([result]))+ assert report["overall_status"] == "failed"+ assert report["overall_passed"] is False++ @pytest.mark.parametrize("exit_code", [0, 1])+ @patch("skillevaluator.validators.security.Tools")+ def test_failed_execution_with_policy_exit_code_gets_provider_message(+ self,+ mock_tools,+ exit_code: int,+ sample_skill_dir: Path,+ ) -> None:+ """A report with execution_successful=false is explained the same way after exit 0 or 1."""+ result = _run_llm_scan(+ mock_tools,+ sample_skill_dir,+ _skillspector_provider_outage_report(),+ exit_code=exit_code,+ )++ assert result.incomplete_scans == ["skillspector-llm"]+ assert result.findings == []+ assert len(result.errors) == 1+ assert result.errors[0].startswith(_PROVIDER_OUTAGE_ERROR_START)++ @pytest.mark.parametrize("phase", ["semantic", "meta"])+ @patch("skillevaluator.validators.security.Tools")+ def test_run_level_runtime_row_accompanies_provider_failure(+ self,+ mock_tools,+ phase: str,+ sample_skill_dir: Path,+ ) -> None:+ """The SKILL.md runtime row may accompany a helper-file or meta-analysis outage."""+ payload = _skillspector_provider_outage_report(old_scanner=True)+ completeness = payload["analysis_completeness"]+ provider_row, _skill_md_row, runtime_row = completeness["ledger_exceptions"]+ completeness["ledger_exceptions"] = [provider_row, runtime_row]+ if phase == "meta":+ provider_row.update({"phase": "meta", "analyzers": ["meta_analyzer"]})+ for status in completeness["analyzer_statuses"]:+ if status["analyzer_id"] == "meta_analyzer":+ status.update({"status": "failed", "planned_work": 1, "completed": 0, "failed": 1})+ elif status["status"] == "failed":+ status.update({"status": "completed", "completed": status["planned_work"], "failed": 0})+ completeness["limitations"] = ["Analyzer meta_analyzer status: failed."]++ result = _run_llm_scan(mock_tools, sample_skill_dir, payload)++ assert result.incomplete_scans == ["skillspector-llm"]+ assert len(result.errors) == 1+ assert result.errors[0].startswith(_PROVIDER_OUTAGE_ERROR_START)++ @pytest.mark.parametrize("exit_code", [2, 0])+ @pytest.mark.parametrize(+ ("version", "provider_message"),+ [("2.11.2", False), ("2.12.0", True)],+ ids=["sdk-retries-only", "own-retry-loop"],+ )+ @patch("skillevaluator.validators.security.Tools")+ def test_provider_message_needs_skillspector_2_12_0(+ self,+ mock_tools,+ version: str,+ provider_message: bool,+ exit_code: int,+ sample_skill_dir: Path,+ ) -> None:+ """Before 2.12.0 the reason covered only a connection error left after the provider SDK's retries."""+ payload = _skillspector_provider_outage_report()+ payload["metadata"]["skillspector_version"] = version++ result = _run_llm_scan(mock_tools, sample_skill_dir, payload, exit_code=exit_code)++ assert result.status == "incomplete"+ assert result.incomplete_scans == ["skillspector-llm"]+ if provider_message:+ assert len(result.errors) == 1+ assert result.errors[0].startswith(_PROVIDER_OUTAGE_ERROR_START)+ else:+ assert not any("LLM provider kept failing" in error for error in result.errors)+ if exit_code == 2:+ assert result.errors == [_GENERIC_LLM_EXIT_2_ERROR]++ @pytest.mark.parametrize("exit_code", [2, 0])+ @pytest.mark.parametrize(+ "mutation",+ [+ "mixed_static_failure",+ "mixed_llm_failure",+ "partial_runtime_limit",+ "truncated_ledger",+ "malformed_row",+ "non_llm_analyzer",+ "meta_analyzer_in_semantic_phase",+ "duplicate_analyzer",+ "older_scanner",+ "missing_version",+ "unknown_limitation",+ "unfinished_static_analyzer",+ "unaccounted_provider_work",+ "runtime_row_elsewhere",+ "runtime_row_reworded",+ "runtime_row_only",+ "reported_errors",+ "provider_analyzer_completed",+ "duplicate_status",+ "status_reason_mismatch",+ "unexplained_status_message",+ "unhashable_phase",+ "unhashable_status",+ "unhashable_status_message",+ "provider_analyzer_missing_status",+ "completeness_not_failed",+ "completeness_marked_complete",+ "empty_row_path",+ "oversized_row_message",+ "top_level_errors",+ "top_level_execution_successful",+ "completeness_execution_successful",+ "provider_status_partial",+ "provider_status_skipped",+ "row_outcome_skipped",+ "empty_row_analyzers",+ "empty_row_message",+ "oversized_ledger",+ "runtime_row_fatal_zero",+ ],+ )+ @patch("skillevaluator.validators.security.Tools")+ def test_uncertain_evidence_keeps_generic_error(+ self,+ mock_tools,+ mutation: str,+ exit_code: int,+ sample_skill_dir: Path,+ ) -> None:+ """Mixed, malformed, truncated or older reports cannot pass for a provider outage."""+ payload = _skillspector_provider_outage_report(old_scanner=True)+ completeness = payload["analysis_completeness"]+ rows = completeness["ledger_exceptions"]+ provider_row = rows[0]+ if mutation == "mixed_static_failure":+ rows.append({**provider_row, "phase": "static", "reason_code": "syntax_error", "path": "scripts/run.py"})+ elif mutation == "mixed_llm_failure":+ rows.append({**provider_row, "reason_code": "llm_response_refused"})+ elif mutation == "partial_runtime_limit":+ rows.append({**provider_row, "outcome": "partial", "fatal": False, "reason_code": "runtime_limit"})+ elif mutation == "truncated_ledger":+ completeness["ledger_exceptions_truncated"] = True+ elif mutation == "malformed_row":+ provider_row["fatal"] = "yes"+ elif mutation == "non_llm_analyzer":+ # A consistent report in which a static analyzer, not an LLM+ # analyzer, failed with the provider reason: only the LLM-analyzer+ # allowlist rejects it.+ provider_row["analyzers"] = ["static_yara"]+ completeness["ledger_exceptions"] = [provider_row, rows[-1]]+ for status in completeness["analyzer_statuses"]:+ if status["analyzer_id"] == "static_yara":+ status.update({"status": "failed", "completed": status["planned_work"] - 1, "failed": 1})+ elif status["status"] == "failed":+ status.update({"status": "completed", "completed": status["planned_work"], "failed": 0})+ completeness["limitations"] = ["Analyzer static_yara status: failed."]+ elif mutation == "meta_analyzer_in_semantic_phase":+ provider_row["analyzers"] = ["meta_analyzer"]+ elif mutation == "duplicate_analyzer":+ provider_row["analyzers"] = ["semantic_security_discovery", "semantic_security_discovery"]+ elif mutation == "older_scanner":+ payload["metadata"]["skillspector_version"] = "2.11.1"+ elif mutation == "missing_version":+ del payload["metadata"]["skillspector_version"]+ elif mutation == "unknown_limitation":+ completeness["limitations"].append("Artifact inspection incomplete for an unknown reason.")+ elif mutation == "unfinished_static_analyzer":+ static_status = next(s for s in completeness["analyzer_statuses"] if s["analyzer_id"] == "static_yara")+ static_status.update({"status": "failed", "completed": 0, "failed": static_status["planned_work"]})+ elif mutation == "unaccounted_provider_work":+ next(+ s for s in completeness["analyzer_statuses"] if s["analyzer_id"] == "semantic_security_discovery"+ ).update({"unaccounted": 1, "planned_work": 4})+ elif mutation == "runtime_row_elsewhere":+ rows[-1]["path"] = "references/guide.md"+ elif mutation == "runtime_row_reworded":+ rows[-1]["message"] = "Unrelated runtime data is missing."+ elif mutation == "runtime_row_only":+ completeness["ledger_exceptions"] = [rows[-1]]+ elif mutation == "reported_errors":+ completeness["errors"] = ["scanner fault"]+ elif mutation == "completeness_not_failed":+ completeness["status"] = "partial"+ elif mutation == "completeness_marked_complete":+ completeness["is_complete"] = True+ elif mutation == "empty_row_path":+ provider_row["path"] = " "+ elif mutation == "oversized_row_message":+ provider_row["message"] = "x" * 4097+ elif mutation == "top_level_errors":+ payload["errors"] = ["scanner fault"]+ elif mutation == "top_level_execution_successful":+ payload["execution_successful"] = True+ elif mutation == "completeness_execution_successful":+ completeness["execution_successful"] = True+ elif mutation == "row_outcome_skipped":+ provider_row["outcome"] = "skipped"+ elif mutation == "empty_row_analyzers":+ rows.append({**provider_row, "path": "references/extra.md", "analyzers": []})+ elif mutation == "empty_row_message":+ provider_row["message"] = ""+ elif mutation == "oversized_ledger":+ # Valid provider rows, one more than the 4096-row bound.+ rows.extend({**provider_row, "path": f"references/extra-{index}.md"} for index in range(4097 - len(rows)))+ elif mutation == "runtime_row_fatal_zero":+ # 0 == False, so only an identity check tells this row apart.+ rows[-1]["fatal"] = 0+ else:+ statuses = completeness["analyzer_statuses"]+ discovery = next(s for s in statuses if s["analyzer_id"] == "semantic_security_discovery")+ if mutation == "provider_analyzer_completed":+ discovery.update({"status": "completed", "completed": discovery["planned_work"], "failed": 0})+ completeness["limitations"].remove("Analyzer semantic_security_discovery status: failed.")+ elif mutation == "duplicate_status":+ statuses.append(dict(discovery))+ elif mutation == "status_reason_mismatch":+ discovery["reason_code"] = "analyzer_runtime_error"+ elif mutation == "unexplained_status_message":+ discovery["message"] = "Analyzer failed after beginning applicable work."+ completeness["limitations"] = ["Analyzer failed after beginning applicable work."]+ elif mutation == "unhashable_phase":+ provider_row["phase"] = ["semantic"]+ elif mutation == "unhashable_status":+ discovery["status"] = ["failed"]+ elif mutation == "unhashable_status_message":+ discovery["message"] = ["Transient LLM provider failure persisted after bounded retries."]+ elif mutation in ("provider_status_partial", "provider_status_skipped"):+ discovery.update({mutation.removeprefix("provider_status_"): 1, "planned_work": 4})+ elif mutation == "provider_analyzer_missing_status":+ # The row names an analyzer whose work no status accounts for.+ statuses.remove(next(s for s in statuses if s["analyzer_id"] == "mcp_tool_poisoning"))+ completeness["limitations"].remove("Analyzer mcp_tool_poisoning status: failed.")++ result = _run_llm_scan(mock_tools, sample_skill_dir, payload, exit_code=exit_code)++ assert result.status == "incomplete"+ assert result.incomplete_scans == ["skillspector-llm"]+ assert not any("LLM provider kept failing" in error for error in result.errors)+ if exit_code == 2:+ assert result.errors == [_GENERIC_LLM_EXIT_2_ERROR]++ @patch("skillevaluator.validators.security.Tools")+ def test_tool_error_message_wins_over_provider_message(+ self,+ mock_tools,+ sample_skill_dir: Path,+ ) -> None:+ """A runner error on the LLM stage is reported as is, even with an outage report on exit 2."""+ result = _run_llm_scan(+ mock_tools,+ sample_skill_dir,+ _skillspector_provider_outage_report(),+ error_message="skillspector execution failed: interrupted",+ )++ assert result.status == "incomplete"+ assert result.incomplete_scans == ["skillspector-llm"]+ assert result.errors == ["skillspector execution failed: interrupted"]++ @pytest.mark.parametrize(+ ("use_llm", "exit_code", "expected"),+ [+ (True, 3, "skillspector-llm failed with unexpected exit code 3: scanner diagnostics were redacted"),+ (False, 2, "skillspector failed with unexpected exit code 2: scanner diagnostics were redacted"),+ ],+ ids=["llm-exit-3", "static-stage"],+ )+ @patch("skillevaluator.validators.security.Tools")+ def test_provider_message_needs_llm_stage_exit_2(+ self,+ mock_tools,+ use_llm: bool,+ exit_code: int,+ expected: str,+ sample_skill_dir: Path,+ ) -> None:+ report = ToolResult(+ success=True,+ stdout=json.dumps(_skillspector_provider_outage_report()),+ stderr="",+ exit_code=exit_code,+ )+ static = ToolResult(success=True, stdout=json.dumps(_skillspector_json_report()), stderr="", exit_code=0)+ mock_tools.skillspector.is_available = True+ mock_tools.skillspector.run.side_effect = [static, report] if use_llm else [report]++ result = SecurityValidator(use_llm=use_llm).validate_security_only(sample_skill_dir)++ assert result.status == "incomplete"+ assert result.errors == [expected]++ def test_cli_provider_only_failure_exits_nonzero_as_incomplete(self, sample_skill_dir: Path) -> None:+ from click.testing import CliRunner++ from skillevaluator.cli import cli++ static = ToolResult(success=True, stdout=json.dumps(_skillspector_json_report()), stderr="", exit_code=0)+ outage = ToolResult(+ success=True,+ stdout=json.dumps(_skillspector_provider_outage_report(old_scanner=True)),+ stderr="",+ exit_code=2,+ )+ with patch("skillevaluator.validators.security.Tools") as mock_tools:+ mock_tools.skillspector.is_available = True+ mock_tools.skillspector.run.side_effect = [static, outage]+ outcome = CliRunner().invoke(cli, ["security-scan", str(sample_skill_dir), "--llm", "--report", "cli"])++ assert outcome.exit_code == 1, outcome.output+ output = " ".join(re.sub(r"\x1b\[[0-9;]*m", "", outcome.output).split())+ assert "INCOMPLETE" in output+ assert "retriable provider failure" in output+ assert "unexpected exit code" not in output++class TestFalsePositivePrevention:"""Tests that known false-positive scenarios are correctly suppressed."""