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(tier2): report a chat-model refusal as an advisory dedup finding (#281)
Narendran Raghavane0938665e599
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3550652c..be2f247c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -207,6 +207,14 @@ All notable changes to SkillEvaluator are documented in this file.Markdown sections are packed by paragraph, so short labels and fragments stayattached to their neighbours, source ranges retain blank-line gaps, and findingslist a split source once.+- A chat model that declines to classify a Tier 2 content cluster (a safety+ refusal, which some models return for security-themed skill content) no+ longer marks the scan incomplete and fails `validate` under the default+ `--block-on-dedup`. Tier 2 now reports the refusal as an advisory MEDIUM+ `llm_refused` finding that names the overlapping sections, and the JSON+ report's `llm_analysis` counts it in `clusters_refused`. Other chat-LLM+ failures still leave the scan incomplete. Raise `CONTENT_DEDUP.llm_refused`+ in a policy overlay to keep refusals blocking.- Local-mode verifier uploads now copy directly to the absent destination,avoiding an unnecessary rollback snapshot of an empty tests directory.Inputs and rewritten scripts are prepared privately before publication,diff --git a/docs/tier2-deduplication.mdx b/docs/tier2-deduplication.mdxindex a3e0adb9..2b3a5e25 100644--- a/docs/tier2-deduplication.mdx+++ b/docs/tier2-deduplication.mdx@@ -162,6 +162,15 @@ the JSON report records it under `work_limit`. A policy severity overridecannot turn the incomplete scan into a pass. Split the skill or remove repeatedmaterial, then rerun.+A model that declines to classify a cluster (a safety refusal, which some+models return for security-themed skill content) is reported differently. The+refusal is no evidence of duplication, and the same model usually refuses+again on a rerun, so Tier 2 records a MEDIUM `llm_refused` finding that names+the overlapping sections and does not block. Review that overlap by hand, or+rerun with another chat model (`--llm-model` or `SKILL_EVAL_LLM_MODEL`). To make+a refusal block `validate`, raise `CONTENT_DEDUP.llm_refused` to `high` in a+[policy overlay](tier1-validation.mdx#validation-profiles-and-policies).+## Compare skills across a collection`similarity-check` recursively discovers skill manifests, embeds each skill's@@ -355,6 +364,7 @@ handling terms before sending confidential skill content to a hosted endpoint.| A directory is a Windows junction or other reparse point | Rejected during the walk, like symbolic links || Embedding or chat-LLM analysis is incomplete | Reports an error; does not claim a clean result || Skill exceeds the content-chunk, comparison-work, or LLM-review limit (candidate clusters, cluster members, or prompt size) | Stops before the remaining analysis and reports the scan as incomplete; no duplicate-content finding is added |+ | The chat LLM declines to classify a cluster | Reports an advisory MEDIUM `llm_refused` finding for that cluster's sections |</Accordion><Accordion title="Inter-skill analysis">| Scenario | Behavior |diff --git a/src/skillevaluator/constants.py b/src/skillevaluator/constants.pyindex d25f72bd..ea540722 100644--- a/src/skillevaluator/constants.py+++ b/src/skillevaluator/constants.py@@ -261,6 +261,11 @@ CONTENT_DEDUP_TRIVIAL_DUP_MAX_CHARS = 400CONTENT_DEDUP_EMBEDDING_BATCH_SIZE = 64+# Check name of the advisory finding recorded when the chat LLM declines to+# classify a content cluster. A refusal is missing evidence about one cluster,+# not a failed scan, so it is reported as a MEDIUM finding instead of blocking.+CONTENT_DEDUP_LLM_REFUSED_CHECK = "llm_refused"+# Resource ceilings for untrusted skill content. Tier 2 sends collected text# to external embedding/LLM providers and performs pairwise comparisons, so# every stage must have an explicit upper bound.diff --git a/src/skillevaluator/deduplication/intra_skill/intra_skill_validator.py b/src/skillevaluator/deduplication/intra_skill/intra_skill_validator.pyindex a4d6c275..0167960d 100644--- a/src/skillevaluator/deduplication/intra_skill/intra_skill_validator.py+++ b/src/skillevaluator/deduplication/intra_skill/intra_skill_validator.py@@ -17,6 +17,7 @@ from pathlib import Pathfrom skillevaluator.constants import (CONTENT_DEDUP_EMBEDDING_BATCH_SIZE,CONTENT_DEDUP_LLM_REASONING_EFFORT,+ CONTENT_DEDUP_LLM_REFUSED_CHECK,CONTENT_DEDUP_MAX_CHUNKS,CONTENT_DEDUP_MAX_LLM_CLUSTERS,CONTENT_DEDUP_SIMILARITY_THRESHOLD,@@ -32,7 +33,7 @@ from skillevaluator.deduplication.intra_skill.semantic_clustering import Contentfrom skillevaluator.deduplication.utils.chunker import ContentChunk, chunk_filefrom skillevaluator.deduplication.utils.skill_collector import CollectedFile, SkillCollectionError, collect_filesfrom skillevaluator.embedding.client import EmbeddingClient, SimilarityConfigError, validate_embedding_vector-from skillevaluator.inference import LLMClient, LLMClientError+from skillevaluator.inference import LLMClient, LLMClientError, LLMClientRefusedErrorfrom skillevaluator.inference.diagnostics import llm_failure_diagnostic, safe_llm_labelsfrom skillevaluator.models.result import Finding, Severity, ValidationResultfrom skillevaluator.utils.tier2_paths import safe_path_label@@ -342,6 +343,11 @@ class IntraSkillValidator(ValidatorBase):verdict = analyze_cluster(llm, cluster)logger.info(" [thread] Verdict: %s (confidence: %.2f)", verdict.verdict, verdict.confidence)return (cluster, verdict, None)+ except LLMClientRefusedError:+ # The model declined to classify this content. That says nothing+ # about duplication and the same model usually refuses again, so+ # it carries neither a verdict nor a failure diagnostic.+ return (cluster, None, None)except Exception as exc:# A provider exception or malformed model response is missing# evidence, not a duplicate-content finding. Never log raw bodies.@@ -357,14 +363,25 @@ class IntraSkillValidator(ValidatorBase):failures = Counter(diagnostic for _, _, diagnostic in cluster_results if diagnostic is not None)failed_count = sum(failures.values())+ refused_count = sum(1 for _, verdict, diagnostic in cluster_results if verdict is None and diagnostic is None)result.metadata["llm_analysis"] = {"provider": provider,"model": model,"clusters_total": len(clusters),- "clusters_completed": len(clusters) - failed_count,+ "clusters_completed": len(clusters) - failed_count - refused_count,+ "clusters_refused": refused_count,"clusters_failed": failed_count,"failures": [{"count": count, "diagnostic": diagnostic} for diagnostic, count in sorted(failures.items())],}+ if refused_count:+ logger.warning(+ "LLM declined to classify %d of %d content clusters (provider: %s; model: %s); "+ "reported as advisory findings.",+ refused_count,+ len(clusters),+ provider,+ model,+ )if failures:result.mark_scan_incomplete("deduplication-llm")summary = (@@ -376,8 +393,39 @@ class IntraSkillValidator(ValidatorBase):logger.error("%s %s", summary, details)# Process results- for cluster, verdict, _ in cluster_results:+ for cluster, verdict, diagnostic in cluster_results:+ if diagnostic is not None:+ continue++ distinct_files = sorted({c.source_file for c in cluster.members})++ locations = []+ for c in cluster.members:+ locations.append(f'"{c.heading}" in {c.source_file} (lines {c.start_line}-{c.end_line})')+ location_text = "\n vs ".join(locations)+ if len(distinct_files) == 1:+ scope = f"within {distinct_files[0]}"+ else:+ scope = f"across {' and '.join(distinct_files)}"+if verdict is None:+ # Report the refused overlap so the author can review it, but+ # as an advisory: it is not evidence of duplicate content.+ result.add_finding(+ Finding(+ category="CONTENT_DEDUP",+ severity=Severity.MEDIUM,+ check_name=CONTENT_DEDUP_LLM_REFUSED_CHECK,+ message=f"The LLM declined to classify overlapping content {scope}:\n {location_text}",+ file_path=cluster.members[0].source_file,+ line_number=cluster.members[0].start_line,+ suggestion=(+ "Review this overlap manually, or rerun Tier 2 with another chat model "+ "(--llm-model or SKILL_EVAL_LLM_MODEL)."+ ),+ metadata={"source_files": distinct_files, "llm_provider": provider, "llm_model": model},+ )+ )continueseverity = verdict_to_severity(verdict)@@ -394,25 +442,12 @@ class IntraSkillValidator(ValidatorBase):if severity in (Severity.HIGH, Severity.MEDIUM) and _is_trivial_intra_file_duplicate(cluster):severity = Severity.LOW- distinct_files = sorted({c.source_file for c in cluster.members})-- locations = []- for c in cluster.members:- locations.append(f'"{c.heading}" in {c.source_file} (lines {c.start_line}-{c.end_line})')- location_text = "\n vs ".join(locations)-- if len(distinct_files) == 1:- message = f"Duplicate content found within {distinct_files[0]}:\n {location_text}"- else:- files_str = " and ".join(distinct_files)- message = f"Duplicate content found across {files_str}:\n {location_text}"-result.add_finding(Finding(category=verdict.verdict,severity=severity,check_name=verdict.verdict.lower(),- message=message,+ message=f"Duplicate content found {scope}:\n {location_text}",file_path=cluster.members[0].source_file,line_number=cluster.members[0].start_line,suggestion=verdict.suggestion,diff --git a/src/skillevaluator/reporting/console_ui.py b/src/skillevaluator/reporting/console_ui.pyindex 91b47781..22e96016 100644--- a/src/skillevaluator/reporting/console_ui.py+++ b/src/skillevaluator/reporting/console_ui.py@@ -39,6 +39,7 @@ from rich.live import Livefrom rich.panel import Panelfrom rich.text import Text+from skillevaluator.constants import CONTENT_DEDUP_LLM_REFUSED_CHECKfrom skillevaluator.reporting.base import get_skip_reasonfrom skillevaluator.utils.rich_markup import strip_terminal_controls@@ -55,6 +56,7 @@ INK = "#101403" # pill/badge foreground on green fills_TIER2_SCAN_FAILURE_CHECKS = frozenset({+ CONTENT_DEDUP_LLM_REFUSED_CHECK,"invalid_skill_root","invalid_text_encoding","path_access_error",@@ -783,13 +785,16 @@ def summarize_tier2(results: list[ValidationResult]) -> tuple[bool, bool, list[Tif failed:details: list[tuple[str, str]] = []for result in failed:- if result.findings:+ # An advisory LLM refusal never explains why a result failed; the+ # reports still carry it.+ findings = [finding for finding in result.findings if not _tier2_finding_is_advisory_refusal(finding)]+ if findings:details.extend(("error" if _tier2_finding_is_scan_failure(finding) else "duplicate",str(finding.message),)- for finding in result.findings+ for finding in findings)else:details.extend(("error", str(error)) for error in result.errors)@@ -827,6 +832,13 @@ def _tier2_finding_is_scan_failure(finding: object) -> bool:return check_name in _TIER2_SCAN_FAILURE_CHECKS or check_name.endswith("_limit") or check_name.endswith("_error")+def _tier2_finding_is_advisory_refusal(finding: object) -> bool:+ # A policy can raise a refusal to a blocking severity; it then reads as a scan failure.+ if getattr(finding, "check_name", None) != CONTENT_DEDUP_LLM_REFUSED_CHECK:+ return False+ return str(getattr(finding, "severity", "")).casefold() not in {"critical", "high"}++def summarize_tier3(result: ValidationResult) -> tuple[bool, bool, list[TierRow], str]:"""Return (ran, passed, rows, skip_reason) for the agent-eval result."""metadata = result.metadata if isinstance(result.metadata, dict) else {}diff --git a/tests/deduplication/intra_skill/test_intra_skill_validator.py b/tests/deduplication/intra_skill/test_intra_skill_validator.pyindex 5593269b..ce2be052 100644--- a/tests/deduplication/intra_skill/test_intra_skill_validator.py+++ b/tests/deduplication/intra_skill/test_intra_skill_validator.py@@ -18,7 +18,7 @@ from skillevaluator.deduplication.intra_skill.llm_analyzer import SYSTEM_PROMPT,from skillevaluator.deduplication.intra_skill.semantic_clustering import ContentClusterfrom skillevaluator.deduplication.utils.chunker import ContentChunkfrom skillevaluator.embedding.client import SimilarityConfigError-from skillevaluator.inference import LLMClientError, LLMVerdict+from skillevaluator.inference import LLMClientError, LLMClientRefusedError, LLMVerdictfrom skillevaluator.models.result import Severity@@ -515,6 +515,121 @@ class TestIntraSkillValidatorValidate:assert result.metadata["llm_analysis"]["clusters_failed"] == 1assert "1 of 2 content clusters" in result.errors[0]+ @patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.analyze_cluster")+ @patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.LLMClient")+ @patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.EmbeddingClient")+ def test_llm_refusal_is_an_advisory_finding(self, mock_embed, _mock_llm, mock_analyze, tmp_path: Path) -> None:+ """A safety refusal says nothing about duplication, so it must not block the skill."""+ skill_dir = tmp_path / "skill"+ skill_dir.mkdir()+ (skill_dir / "SKILL.md").write_text("## Section A\n" + "a" * 200 + "\n## Section B\n" + "b" * 200)+ mock_embed.return_value.embed.return_value = [[1.0, 0.0], [1.0, 0.0]]+ mock_analyze.side_effect = LLMClientRefusedError("private provider refusal text")++ result = IntraSkillValidator().validate(skill_dir)++ assert result.passed is True+ assert result.status != "incomplete"+ assert result.incomplete_scans == []+ assert result.errors == []+ [finding] = result.findings+ assert (finding.category, finding.check_name, finding.severity) == (+ "CONTENT_DEDUP",+ "llm_refused",+ Severity.MEDIUM,+ )+ # The author can find the refused overlap without rerunning the scan.+ assert (finding.file_path, finding.line_number) == ("SKILL.md", 1)+ assert finding.metadata["source_files"] == ["SKILL.md"]+ assert finding.message == (+ "The LLM declined to classify overlapping content within SKILL.md:\n"+ ' "## Section A" in SKILL.md (lines 1-2)\n'+ ' vs "## Section B" in SKILL.md (lines 3-4)'+ )+ assert "SKILL_EVAL_LLM_MODEL" in finding.suggestion+ assert "private provider refusal text" not in str(finding.to_dict())+ analysis = result.metadata["llm_analysis"]+ assert (analysis["clusters_completed"], analysis["clusters_refused"], analysis["clusters_failed"]) == (0, 1, 0)+ assert analysis["failures"] == []++ @patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.analyze_cluster")+ @patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.LLMClient")+ @patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.EmbeddingClient")+ def test_llm_refusal_beside_a_failed_cluster_keeps_the_scan_incomplete(+ self, mock_embed, _mock_llm, mock_analyze, tmp_path: Path+ ) -> None:+ skill = tmp_path / "skill"+ skill.mkdir()+ (skill / "SKILL.md").write_text("\n".join(f"## Section {letter}\n{letter.lower() * 200}" for letter in "ABCD"))+ mock_embed.return_value.embed.return_value = [[1.0, 0.0], [1.0, 0.0], [0.0, 1.0], [0.0, 1.0]]++ def analyze(_client, cluster):+ if any("Section A" in member.heading for member in cluster.members):+ raise LLMClientRefusedError("declined")+ raise RuntimeError("private provider response")++ mock_analyze.side_effect = analyze+ result = IntraSkillValidator().validate(skill)++ # Only the provider failure is missing coverage; the refusal stays advisory.+ assert result.status == "incomplete"+ assert result.incomplete_scans == ["deduplication-llm"]+ assert [finding.check_name for finding in result.findings] == ["llm_refused"]+ assert result.summary.medium_count == 1+ analysis = result.metadata["llm_analysis"]+ assert (analysis["clusters_completed"], analysis["clusters_refused"], analysis["clusters_failed"]) == (0, 1, 1)+ assert "1 of 2 content clusters" in result.errors[0]++ @patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.analyze_cluster")+ @patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.LLMClient")+ @patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.EmbeddingClient")+ def test_llm_refusal_beside_a_duplicate_keeps_the_duplicate_blocking(+ self, mock_embed, _mock_llm, mock_analyze, tmp_path: Path+ ) -> None:+ skill = tmp_path / "skill"+ skill.mkdir()+ (skill / "SKILL.md").write_text("## Section A\n" + "a" * 200 + "\n## Section B\n" + "b" * 200)+ (skill / "guide.md").write_text("## Section C\n" + "c" * 200 + "\n## Section D\n" + "d" * 200)+ mock_embed.return_value.embed.return_value = [[1.0, 0.0], [0.0, 1.0], [1.0, 0.0], [0.0, 1.0]]++ def analyze(_client, cluster):+ if any("Section A" in member.heading for member in cluster.members):+ return LLMVerdict("DUPLICATE", 0.9, "Same content", "Remove one")+ raise LLMClientRefusedError("declined")++ mock_analyze.side_effect = analyze+ result = IntraSkillValidator().validate(skill)++ assert result.status == "failed"+ assert result.incomplete_scans == []+ assert {(finding.check_name, finding.severity) for finding in result.findings} == {+ ("duplicate", Severity.HIGH),+ ("llm_refused", Severity.MEDIUM),+ }+ refusal = next(finding for finding in result.findings if finding.check_name == "llm_refused")+ assert refusal.message.startswith(+ "The LLM declined to classify overlapping content across SKILL.md and guide.md:"+ )+ assert refusal.metadata["source_files"] == ["SKILL.md", "guide.md"]++ @patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.analyze_cluster")+ @patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.LLMClient")+ @patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.EmbeddingClient")+ def test_policy_can_make_an_llm_refusal_blocking(self, mock_embed, _mock_llm, mock_analyze, tmp_path: Path) -> None:+ from skillevaluator.validators.policy import ValidationPolicy, apply_policy++ skill_dir = tmp_path / "skill"+ skill_dir.mkdir()+ (skill_dir / "SKILL.md").write_text("## Section A\n" + "a" * 200 + "\n## Section B\n" + "b" * 200)+ mock_embed.return_value.embed.return_value = [[1.0, 0.0], [1.0, 0.0]]+ mock_analyze.side_effect = LLMClientRefusedError("declined")+ result = IntraSkillValidator().validate(skill_dir)++ apply_policy([result], ValidationPolicy(severity_overrides={"CONTENT_DEDUP.llm_refused": Severity.HIGH}))++ assert result.passed is False+ assert result.findings[0].severity == Severity.HIGH+@patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.LLMClient")@patch("skillevaluator.deduplication.intra_skill.intra_skill_validator.EmbeddingClient")def test_llm_initialization_error_preserves_collection_evidence(self, mock_embed, mock_llm, tmp_path: Path) -> None:diff --git a/tests/test_commands.py b/tests/test_commands.pyindex 13647772..ad8a5c2c 100644--- a/tests/test_commands.py+++ b/tests/test_commands.py@@ -2956,6 +2956,51 @@ def test_summarize_tier2_lists_duplicate_details() -> None:assert any("2 more" in line for line in rendered)+def test_summarize_tier2_does_not_blame_an_advisory_llm_refusal() -> None:+ # A refusal is advisory: when another cluster's analysis failed, the+ # summary must name that failure, not list the refusal as a duplicate.+ from skillevaluator.models.result import Finding, Severity, ValidationResult+ from skillevaluator.reporting.console_ui import summarize_tier2++ def refusal(severity: Severity) -> Finding:+ return Finding(+ category="CONTENT_DEDUP",+ severity=severity,+ check_name="llm_refused",+ message="The LLM declined to classify overlapping content within SKILL.md",+ file_path="SKILL.md",+ )++ incomplete = ValidationResult(validator_name="Context Deduplication")+ incomplete.add_finding(refusal(Severity.MEDIUM))+ incomplete.mark_scan_incomplete("deduplication-llm")+ incomplete.add_error("LLM analysis did not complete for 1 of 2 content clusters")++ ran, ok, rows, _skip = summarize_tier2([incomplete])+ assert ran and not ok+ rendered = ["".join(chunk for chunk, _style in row.segments) for row in rows]+ assert any("scan failed" in line for line in rendered)+ assert not any("duplicates found" in line for line in rendered)+ assert [row.label for row in rows if row.glyph == "✗"] == ["error"]+ assert any("1 of 2 content clusters" in line for line in rendered)+ assert not any("declined" in line for line in rendered)++ # A policy that raises the refusal to a blocking severity reports it as a scan failure.+ blocking = ValidationResult(validator_name="Context Deduplication")+ blocking.add_finding(refusal(Severity.HIGH))++ _ran, ok, rows, _skip = summarize_tier2([blocking])+ rendered = ["".join(chunk for chunk, _style in row.segments) for row in rows]+ assert not ok+ assert any("scan failed" in line for line in rendered)+ assert [row.label for row in rows if row.glyph == "✗"] == ["error"]++ advisory = ValidationResult(validator_name="Context Deduplication")+ advisory.add_finding(refusal(Severity.MEDIUM))+ _ran, ok, _rows, _skip = summarize_tier2([advisory])+ assert ok++def test_rerun_hint_preserves_run_shaping_flags(monkeypatch) -> None:# The FAIL panel's rerun line must echo the user's actual invocation:# dropping --min-score (etc.) means following the hint can silentlydiff --git a/tests/test_harbor_local_mode.py b/tests/test_harbor_local_mode.pyindex 6c457319..48e58607 100644--- a/tests/test_harbor_local_mode.py+++ b/tests/test_harbor_local_mode.py@@ -3205,7 +3205,8 @@ def test_streamed_exec_cancellation_reaps_descendants(with environment.scoped_output_callback(on_output):task = asyncio.create_task(environment.exec(- 'printf "%s\\n" "$CANCEL_TOKEN"; (sleep 30) & printf \'%s\' "$!" > stream-cancel-child-pid; wait',+ # Callback readiness must follow the complete PID write, not just file creation.+ '(sleep 30) & printf \'%s\' "$!" > stream-cancel-child-pid; printf "%s\\n" "$CANCEL_TOKEN"; wait',env={"CANCEL_TOKEN": secret},))diff --git a/tests/test_tier2_command_failures.py b/tests/test_tier2_command_failures.pyindex 657c7c26..9c8cefcb 100644--- a/tests/test_tier2_command_failures.py+++ b/tests/test_tier2_command_failures.py@@ -337,3 +337,81 @@ def test_chat_http_diagnostics_after_successful_embedding(tmp_path: Path, monkeyassert "SKILL_EVAL_LLM_MODEL" in errors[0]elif chat_status == 429:assert "quota" in errors[0]+++def test_chat_refusal_is_advisory_in_real_cli_and_reports(tmp_path: Path, monkeypatch) -> None:+ """A content-filtered chat reply is an advisory finding, not a blocking incomplete scan."""+ requests = []++ class RefusingChatHandler(BaseHTTPRequestHandler):+ def do_POST(self):+ body = json.loads(self.rfile.read(int(self.headers["Content-Length"])))+ requests.append((self.path, body))+ if self.path == "/v1/embeddings":+ payload = {+ "data": [+ {"index": index, "embedding": [float(dimension == index // 2) for dimension in range(4)]}+ for index in range(len(body["input"]))+ ]+ }+ else:+ payload = {+ "id": "local-completion",+ "object": "chat.completion",+ "created": 0,+ "model": body["model"],+ "choices": [+ {+ "index": 0,+ "finish_reason": "content_filter",+ "message": {"role": "assistant", "content": "provider-private-token"},+ }+ ],+ }+ response = json.dumps(payload).encode()+ self.send_response(200)+ self.send_header("Content-Type", "application/json")+ self.send_header("Content-Length", str(len(response)))+ self.end_headers()+ self.wfile.write(response)++ def log_message(self, _format, *_args):+ pass++ server = ThreadingHTTPServer(("127.0.0.1", 0), RefusingChatHandler)+ thread = threading.Thread(target=server.serve_forever, daemon=True)+ thread.start()+ skill = tmp_path / "skill"+ skill.mkdir()+ (skill / "SKILL.md").write_text("\n".join(f"## Section {letter}\n{letter.lower() * 200}" for letter in "ABCD"))+ reports = tmp_path / "reports"+ for purpose in ("LLM", "EMBEDDING"):+ monkeypatch.setenv(f"SKILL_EVAL_{purpose}_PROVIDER", "openai-compatible")+ monkeypatch.setenv(f"SKILL_EVAL_{purpose}_BASE_URL", f"http://127.0.0.1:{server.server_port}/v1")+ monkeypatch.setenv(f"SKILL_EVAL_{purpose}_API_KEY", "local-test-key")+ monkeypatch.setenv(f"SKILL_EVAL_{purpose}_MODEL", f"local-{purpose.lower()}-model")+ try:+ invocation = CliRunner().invoke(cli, ["tier2", str(skill), "-o", str(reports)])+ finally:+ server.shutdown()+ server.server_close()+ thread.join(timeout=5)++ assert invocation.exit_code == 0, invocation.output+ # A refusal is not transient, so the same request is not retried.+ assert len([path for path, _body in requests if path == "/v1/chat/completions"]) == 2+ payload = json.loads((reports / "skillevaluator-tier2.json").read_text())+ result = payload["results"][0]+ assert payload["overall_status"] == "passed"+ assert result["status"] == "passed"+ assert [(finding["check_name"], finding["severity"]) for finding in result["findings"]] == [+ ("llm_refused", "medium"),+ ("llm_refused", "medium"),+ ]+ analysis = result["llm_analysis"]+ assert (analysis["clusters_completed"], analysis["clusters_refused"], analysis["clusters_failed"]) == (0, 2, 0)+ assert all(finding["metadata"]["llm_model"] == "local-llm-model" for finding in result["findings"])+ html = (reports / "skillevaluator-tier2.html").read_text()+ for output in (invocation.output, json.dumps(payload), html):+ assert "provider-private-token" not in output+ assert "local-test-key" not in output