Skip to content

fix(tier2): report a chat-model refusal as an advisory dedup finding - #281

Merged
rng1995 merged 5 commits into
mainfrom
naren/port-tier2-refusal-advisory
Nov 2, 2026
Merged

rng1995 merged 5 commits into
mainfrom
naren/port-tier2-refusal-advisory

Conversation

@rng1995

@rng1995 rng1995 commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

When the chat LLM declines to classify a Tier 2 content cluster (a safety refusal), Tier 2 now reports an advisory MEDIUM finding instead of marking the scan incomplete.

  • IntraSkillValidator catches LLMClientRefusedError separately from other LLM failures. A refused cluster adds a CONTENT_DEDUP / llm_refused finding at MEDIUM severity.
    • The message names the overlapping sections, files and line ranges, in the same form as a DUPLICATE finding.
    • The finding points at the first member's file and line, and its metadata records source_files and the sanitized provider/model labels.
    • The suggestion says to review the overlap by hand or rerun with another chat model (--llm-model or SKILL_EVAL_LLM_MODEL).
  • llm_analysis in the JSON report gains clusters_refused. clusters_completed now counts clusters that returned a verdict, so completed + refused + failed = total.
  • Any other chat-LLM failure (HTTP error, timeout, truncation, empty or malformed reply) still marks the scan incomplete (deduplication-llm) and blocks, as before. A refusal next to such a failure does not hide it.
  • The console Tier 2 summary leaves out advisory refusals when it explains a failed result. A result that is incomplete because another cluster failed now shows "scan failed" with that error, not "duplicates found" with the refusal text. If a policy raises a refusal to HIGH or CRITICAL, the summary shows it as a scan failure.
  • Docs (docs/tier2-deduplication.mdx) and a CHANGELOG entry under Unreleased / Fixed.

Why

Some chat models refuse security-themed skill content, for example a skill about penetration testing or malware triage. Before this change the refusal surfaced as a failed cluster, so Tier 2 marked the scan incomplete. Under the default --block-on-dedup, validate then failed, and the tier2 / context-optimization-check commands exited non-zero.

Retrying usually does not help, because the same model refuses the same content again. The only workarounds were switching models or passing --no-block-on-dedup, which also stops real DUPLICATE findings from gating.

A refusal is not evidence of duplicated content. Tier 2 deduplication measures context bloat, not safety, so letting a refusal block the skill gave no protection and made Tier 2 unusable for these skills. The finding keeps the refused overlap visible in every report. Teams that want refusals to block can raise CONTENT_DEDUP.llm_refused to high in a validate --policy overlay.

Kept from public

  • Typed refusal detection in the inference layer. Public's _checked_content already raises LLMClientRefusedError for content_filter / refusal stop reasons and for an OpenAI message.refusal. An empty reply stays EmptyLLMResponseError, a failure, and is not treated as a refusal. This change only adds a branch for that existing type.
  • Bounded, sanitized failure diagnostics. Grouped llm_failure_diagnostic errors, safe_llm_labels, and "never log raw bodies" are unchanged. The refusal finding and log line use only the sanitized provider/model labels and never the provider's text. The end-to-end test checks that partial reply content from a content-filtered response stays out of the console, JSON and HTML output.
  • Fail-closed incomplete coverage. Every non-refusal failure still marks the scan incomplete, and a refusal cannot turn an incomplete scan into a pass.
  • Anthropic server-side refusal fallback. Public already retries a Claude 5.5+ refusal on a fallback model within the same call on the native endpoint. This change only applies when no fallback answers, or on providers without one.
  • Policy-based gating. No new CLI flag. Severity goes through the existing apply_policy path, so the policy overlay mechanism can raise the refusal.

Tests

Without the source change, all six new tests fail. With it, they pass.

  • tests/deduplication/intra_skill/test_intra_skill_validator.py:
    • test_llm_refusal_is_an_advisory_finding: one refused cluster gives a passing, complete result with one MEDIUM llm_refused finding. Checks location, message, suggestion, llm_analysis counts (0 completed / 1 refused / 0 failed) and that the refusal text is not echoed.
    • test_llm_refusal_beside_a_failed_cluster_keeps_the_scan_incomplete: refusal plus a provider failure stays incomplete (deduplication-llm), with counts 0 / 1 / 1.
    • test_llm_refusal_beside_a_duplicate_keeps_the_duplicate_blocking: refusal plus a HIGH DUPLICATE stays failed, not incomplete. Also covers the cross-file message.
    • test_policy_can_make_an_llm_refusal_blocking: CONTENT_DEDUP.llm_refused: high fails the result.
  • tests/test_tier2_command_failures.py::test_chat_refusal_is_advisory_in_real_cli_and_reports: runs the real tier2 CLI with the OpenAI SDK against a loopback server whose chat endpoint returns finish_reason: content_filter. It checks:
    • exit code 0, overall_status: passed
    • two MEDIUM llm_refused findings and clusters_refused == 2
    • no retry of the refused request
    • no leaked reply text or key in the console, JSON or HTML output
  • tests/test_commands.py::test_summarize_tier2_does_not_blame_an_advisory_llm_refusal: covers the console summary for incomplete, policy-escalated and advisory-only results.
  • Also ran, rebased on current main: tests/deduplication, tests/test_tier2_command_failures.py, tests/test_commands.py, tests/reporting and tests/inference (1,708 passed), and the full suite. Ran ruff check on the changed Python files and scripts/check_oss_boundary.py. ruff format --check reports no change in the lines this PR adds.
  • In the full suite, the timing-sensitive test_nvidia_build_bridge.py slow-drip test failed once under load and passed when rerun alone. Two groups of tests also fail on unmodified main on this host: the two sidecar_retains_* tests, because of host environment variables, and the generated custom-only grader tests in tests/tier3/test_judge_failure_artifacts.py, because the host's python3 is 3.9.

🤖 Generated with Claude Code

Some chat models refuse to classify security-themed skill content. Tier 2
treated that refusal like any other LLM failure: the cluster counted as
failed, the scan was marked incomplete, and validate failed under the
default --block-on-dedup. The same model usually refuses again on a rerun,
so these skills could not pass Tier 2 without switching models or turning
off dedup gating altogether.

A refusal is no evidence of duplicated content. Context deduplication now
reports a refused cluster as a MEDIUM CONTENT_DEDUP/llm_refused finding
that names the overlapping sections, and counts it in the JSON report's
llm_analysis.clusters_refused. Other chat-LLM failures still leave the
scan incomplete. A policy overlay can raise CONTENT_DEDUP.llm_refused to
keep refusals blocking. The console Tier 2 summary no longer presents an
advisory refusal as the reason a result failed.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the validator, console summary, docs and CHANGELOG. A refusal no longer marks the scan incomplete, other chat failures still do, duplicates beside a refusal stay blocking, the policy override path is covered, and the real-CLI test confirms no retry and no provider text leaking into reports. ruff is clean and the dedup, command and reporting suites pass locally. No findings.

Reviewed with Claude Code.

rng1995 and others added 2 commits November 2, 2026 10:21
Resolve Tier 2 documentation conflicts by retaining the work-limit failure guidance alongside advisory model refusals.

Signed-off-by: Narendran Raghavan <[email protected]>
@rng1995
rng1995 enabled auto-merge (squash) November 2, 2026 18:28
@rng1995
rng1995 merged commit e093866 into main Nov 2, 2026
21 checks passed
@rng1995
rng1995 deleted the naren/port-tier2-refusal-advisory branch November 2, 2026 19:48
rng1995 added a commit that referenced this pull request Nov 2, 2026
Clean merge of the newer main (#281, #271, #293); CHANGELOG.md and
docs/agents-and-sandboxes.mdx auto-merged with no conflicts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
rng1995 added a commit that referenced this pull request Nov 6, 2026
* docs(changelog): move entries released in 0.7.0-0.7.2 out of Unreleased

0.7.0 (#314) and 0.7.1 (#327) never cut their sections on main, and 0.7.2
(#335) added its section below the whole Unreleased block, so Unreleased
still listed work that had already shipped.

Place each Unreleased entry under the release that shipped the PR that
added it:

- 0.7.0: the published section from the 0.7.0 tag, verbatim. It already
  holds the six entries that main had filed under 0.6.0, so 0.6.0 again
  matches the v0.6.0 tag, including the original run_config.json entry.
- 0.7.1: #264 #271 #274 #281 #284 #289 #293 #299 #316 #317 #318 #323
  #324 #326 #327, plus the #320 wording of the Windows Git-root entry,
  since #320 changed that 0.7.0 fix in 0.7.1.
- 0.7.2: #263 #265 #269 #270 #276 #279 #287 #290 #296 #309 #328 #330
  merged with the existing #335 entries.

Only post-v0.7.2 entries stay under Unreleased, with one heading per
subsection. Entry text is unchanged, apart from the published tag wording
in 0.7.0 and 0.6.0.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(release): prepare v0.8.0

Set the package, fallback, lock, citation and developer-guide versions to
0.8.0 and move every entry merged since v0.7.2 under
'## 0.8.0 - 2026-11-05', leaving Unreleased empty.

The refusal-fallback documentation test now reads the release section
that names CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK, requires it to be 0.8.0,
and requires exactly one entry there to name the switch.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(release): pin the verified 0.8.0 Tier 1 image and add its CI bundle

Pin onboarding to the Tier 1 image published by the reviewed main revision
55d2d04 in "Build and publish Tier 1 image" run 42158955180:
ghcr.io/nvidia/skillevaluator-tier1@sha256:9d5483243918937be4f2178f74cf7c622a531dee41e3176906994d52fa14950a
(config sha256:d17d6f5105ec5f1bf0cbe4dff0d693aae4ecf01e9c1c6a6ddb7830518acace33).
The workflow and publisher refs both move to 55d2d04.

ci/bundles/0.8.0 mirrors the 0.7.2 bundle. The templates, README and
release.json are the run's github-actions-onboarding artifact and match
ci/render_templates.py output for these pins byte for byte. The scanner
inventory and verification receipt come from the build's runtime-stage
version step, the five-case smoke receipt, the onboarding job's anonymous
pull, and the public manifest, whose config digest equals the smoke-tested
image ID. The ZIP uses the 0.7.2 layout (sorted members, inner checksums,
1980 timestamps, 0644, deflate level 9) and rebuilds to identical bytes.

Point the current-bundle links at 0.8.0 and list 0.7.2 as historical.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>

---------

Signed-off-by: Narendran Raghavan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant