Skip to content

feat(doctor): add Tier 1 scanner and Tier 2 provider readiness checks - #293

Merged
rng1995 merged 3 commits into
mainfrom
naren/port-doctor-tier-checks
Nov 2, 2026
Merged

rng1995 merged 3 commits into
mainfrom
naren/port-doctor-tier-checks

Conversation

@rng1995

@rng1995 rng1995 commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

doctor and health-check take --tier 1|2|3|all. Without --tier they still check Tier 3 only, exactly as before.

  • --tier 1 reports each external scanner that the --checks selection runs (default: validate's default checks):
    • Scanners per check: SkillSpector for security; Bandit, Semgrep and Gitleaks for code-integrity; pip-audit for dependency.
    • Each row shows the resolved executable, any SKILLEVALUATOR_*_PATH override, and the parsed version.
    • The version comes from a probe that goes through the existing ExternalTool.run. It is bounded by --timeout, starts no shell, and runs the scanner as its validator does: SkillSpector gets the same credential-free environment as the static scan, and Semgrep gets no network update check.
    • A scanner fails when it is missing, its override is malformed, its probe exits nonzero or times out, or it is older than the release the validators parse: Bandit 1.9.4 (the security extra floor) or Gitleaks 8.
    • An unreported version is a warning.
  • --tier 2 resolves the embedding provider and the LLM provider used for duplicate analysis, offline.
    • doctor --tier 2 --verify-models also sends one embedding request and one chat request. They go through the existing EmbeddingClient and LLMClient, with no retries, and --timeout bounds each request.
    • The timeout is passed to the OpenAI and Anthropic SDK clients explicitly, and to litellm for a Bedrock chat probe. Both SDKs ignore an httpx.Client timeout that equals httpx's 5-second default and fall back to their own 600 seconds, so --timeout 5 would otherwise not bound the read.
    • Failures use the existing bounded diagnostics: EmbeddingClient messages and llm_failure_diagnostic. Only the HTTP status and a remedy are shown, never a provider response body.
  • --tier all runs Tiers 1, 2 and 3 in order. A failed tier does not stop the next, and the exit code is 1 if any tier failed.
  • Option validation:
    • An explicit option for an unselected tier is a usage error (exit 2) before any probe runs. Examples: --checks without Tier 1, --env-mode with --tier 1, --verify-models with --tier 1.
    • --timeout with --tier 2 is rejected unless --verify-models sends live requests, because offline Tier 2 has nothing to bound. health-check never sends one, so its --timeout covers only Tier 1 scanner probes.
    • Unknown --checks names and a --timeout that is not finite, not positive or above 3600 seconds are rejected the same way. The upper bound keeps a huge value from overflowing the subprocess timer.
  • tier3 doctor is now its own Tier 3-only command. Its options are unchanged, and it has no --tier, --checks or --timeout.
  • Supporting changes:
    • New module src/skillevaluator/doctor.py. It does not import Harbor or provider SDKs unless a live probe was requested, so Tier 1 readiness works on a base install.
    • EmbeddingClient gains optional max_retries, http_client and timeout arguments, and LLMClient gains an optional timeout that it forwards to the OpenAI and Anthropic SDKs and to litellm for Bedrock. Defaults are unchanged.
    • ExternalTool.configuration_error exposes why an override was rejected.
  • Docs and changelog: CLI reference (doctor / health-check sections and the command table), Agents & Sandboxes readiness section, Configuration, Installation (system tools), Tier 1 validation, and a CHANGELOG entry under Unreleased / Added.

Why

Before this change, the only preflight was Tier 3 readiness, and it needs a provider and a backend. Problems with the other tiers showed up only partway through validate:

  • A missing, misconfigured or outdated Tier 1 scanner left the security or code-integrity scan INCOMPLETE.
  • An unconfigured or rejected Tier 2 provider left Tier 2 skipped or incomplete.
  • Nothing reported which SkillSpector version was on PATH.

Users and CI can now check each tier up front. health-check --tier 1 also works as a non-interactive scanner preflight.

This covers the readiness-reporting part of #42: one command reports the Tier 1 scanner state, including path, version, malformed override and incompatible version, and CI can require it.

@rookepoole offered to implement #42 and proposed a full contract there: a separate scanner-preflight command with --json, a consent-gated --bootstrap, and the same Bandit 1.9.4 and Gitleaks 8 floors this PR adopts. They also argued that scanner readiness should not extend doctor. This PR does not settle that. It covers only readiness reporting and leaves their open questions to maintainers: the command name and surface (doctor --tier 1 or scanner-preflight), the --json contract, and the bootstrap scope. It also leaves the SkillSpector bundling decision open, so it does not close the issue. The Tier 1 rows here can back either command surface.

Refs #42

Kept from public

  • Tier 3 contract. Bare doctor and health-check still check only Tier 3, with the same options and the same tier3.commands.doctor call. The CI wheel smoke test (placeholder key, no scanners) and the native-Windows local-mode step keep passing unchanged. The documented "offline readiness probes by default" behavior also still holds. An all-tier default would have failed both CI steps.
  • Offline by default. Live provider requests are opt-in through the existing --verify-models flag, and health-check never sends one. An alternative design probed models on every run.
  • Public provider resolution. The check uses resolve_embedding_provider and resolve_llm_provider with their existing setup guidance. It does not use a separate OpenAI-only provider config, so OpenAI, Anthropic, Bedrock, NVIDIA Build and OpenAI-compatible endpoints work through the same clients validate uses.
  • Public diagnostics and output hardening. Live failures go through llm_failure_diagnostic and EmbeddingClient's status-only messages. Configured labels pass through safe_llm_labels. Rows are printed with escape_markup on an emoji=False console, the same as the Tier 3 table, with pass/warn/fail styling.
  • Public scanner resolution. Scanner rows use Tools and ExternalTool as they are: interpreter-sibling preference, fail-closed overrides, existing install hints, and the bounded, shell-free runner. They do not use a separate subprocess path.

Tests

  • tests/test_doctor.py (new):
    • Tier 1 rows, using the real Tools entries with an in-process subprocess.run:
      • Each --checks selection probes exactly its scanners, with version for Gitleaks.
      • Version and path rows for all five scanners, and the explicit-override source.
      • SkillSpector's probe environment carries no provider key, and Semgrep's disables the update check.
      • Missing, malformed-override, timeout and nonzero-exit failures do not hide the other scanners, and scanner output never reaches a row.
      • Bandit 1.9.3 and Gitleaks 7.x fail at the version boundaries, and an unreported version warns.
      • Invalid timeouts are rejected.
    • Tier 2, using the real OpenAI SDK through httpx.MockTransport:
      • Offline resolution sends no request, and a missing provider or extra fails without network access.
      • --verify-models sends exactly one embedding request and one chat request, with every httpx timeout field set to --timeout. This includes 5 seconds, which the SDKs would otherwise replace with 600.
      • The Anthropic chat probe carries the same bound, and a Bedrock chat probe passes --timeout to litellm.
      • HTTP 401 and 500 responses whose bodies contain a canary report only the status. Neither request is retried, and the chat probe still runs after the embedding probe fails.
  • tests/test_cli.py:
    • Without --tier, both commands keep the old Tier 3 call.
    • Tier 1 and Tier 2 routing for both commands.
    • --verify-models reaches Tier 2.
    • --tier all keeps going after a failed tier.
    • 26 rejected option combinations, each exiting 2 before any probe. This includes tier3 doctor --tier/--checks/--timeout, health-check --verify-models, --timeout 1e300 and 3601, and --timeout with an offline --tier 2 for both commands.
    • --timeout reaches Tier 2 with --verify-models, still applies to Tier 1 under --tier all, and health-check --help describes it as Tier 1 only.
    • tier3 doctor stays Tier 3.
    • Every documented doctor / health-check example in docs/cli-reference.mdx parses.
  • tests/test_base_install.py: with every extras-only module blocked, doctor --tier 1 passes and doctor --tier 2 --verify-models reports the missing Tier 2 extra without importing it.
  • tests/embedding/test_client.py: max_retries, http_client and timeout reach the SDK.
  • tests/inference/test_llm_client.py: an explicit timeout reaches the OpenAI and Anthropic SDK constructors, and Bedrock forwards it to litellm only when it is set.
  • tests/golden/cli_surface.json: regenerated. Only doctor and health-check gain --tier, --checks and --timeout; tier3 doctor is unchanged.
  • Validation:
    • Full suite on current main: 18286 passed, 29 skipped. Fifteen failures are local only and also fail without this change. Two test_harbor_secure_docker_environment.py::*sidecar_retains_* failures come from host environment variables. Thirteen tier3/test_judge_failure_artifacts.py::test_generated_custom_only_script_* failures come from the host's Python 3.9 python3 running the generated verifier script.
    • ruff check and ruff format --check pass on the changed lines. Pre-existing format differences in tool_runner.py and tests/inference/test_llm_client.py are outside this diff.
    • The OSS boundary scan passes.
  • Manual:
    • doctor --tier 1, health-check --tier 2, doctor --tier all and doctor --tier 2 --verify-models against NVIDIA Build with a placeholder key. Both live probes reported HTTP 403 with a remedy and no response body.
    • Through an httpx.MockTransport, doctor --tier 2 --verify-models with timeouts of 4 and 5 seconds sent both requests with every httpx timeout field set to that value.
    • doctor --tier 1 --checks code --timeout 1e300, doctor --tier 2 --timeout 5 and health-check --tier 2 --timeout 5 exit 2 with a usage error.

🤖 Generated with Claude Code

rng1995 and others added 2 commits October 30, 2026 12:00
doctor and health-check only checked Tier 3 live-evaluation readiness.
A missing or outdated Tier 1 scanner (SkillSpector, Bandit, Semgrep,
Gitleaks, pip-audit) or an unconfigured or rejected Tier 2 provider only
showed up partway through validate, as an INCOMPLETE scan or a skipped
tier. Nothing showed which SkillSpector version was on PATH.

Both commands now take --tier 1|2|3|all. The default stays 3, so existing
scripts and CI see the same behavior.

- Tier 1 reports each external scanner that the --checks selection runs.
  Each row shows the resolved path, any executable override, and the
  version from a bounded, shell-free probe. SkillSpector is probed without
  provider credentials and Semgrep without its update check. A scanner
  fails when it is missing, its override is malformed, the probe fails or
  exceeds --timeout, or it is older than Bandit 1.9.4 or Gitleaks 8.
- Tier 2 resolves the embedding and LLM providers offline.
  doctor --tier 2 --verify-models also sends one embedding request and
  one chat request. They go through the existing clients with no retries
  and a timeout-bounded HTTP client. Only the HTTP status and a remedy are
  reported, never the provider's response body.
- --tier all runs every tier in order, and a failed tier does not stop the
  next. An option for an unselected tier is a usage error before any probe.
  tier3 doctor is now a separate, Tier 3-only command with unchanged
  options.

EmbeddingClient gains optional max_retries and http_client arguments,
matching LLMClient. ExternalTool exposes its override configuration error.

Refs #42

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The OpenAI and Anthropic SDKs ignore an httpx.Client timeout that equals
httpx's 5-second default and fall back to their own 600 seconds. With
--timeout 5, each Tier 2 live probe could therefore wait up to 10
minutes on a hung provider. A Bedrock chat probe goes through litellm,
which never saw the timeout at all.

- EmbeddingClient and LLMClient take an optional timeout. LLMClient
  passes it to the OpenAI and Anthropic SDK clients and to litellm for
  Bedrock. The default stays the provider's own.
- doctor passes --timeout to both probes explicitly, so every httpx
  timeout field carries the requested value, including 5 seconds.
- --timeout is capped at 3600 seconds. A huge value no longer overflows
  the subprocess timer with a traceback.
- --timeout with --tier 2 is a usage error unless --verify-models sends
  live requests. health-check never sends one, so its help and docs
  describe --timeout as Tier 1 only.

Tests cover the 5-second case for the OpenAI SDK path, the Anthropic
chat probe, the Bedrock litellm timeout, the timeout cap, and the
offline Tier 2 rejections for both commands.

Refs #42

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[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.

Review summary: no findings (no P1/P2/P3).

Checked: the scanner-to-check mapping against the validators (SkillSpector for security; Bandit, Semgrep and Gitleaks for code-integrity; pip-audit for dependency), which treat a missing scanner as incomplete, so a failing doctor row matches validate behavior; the Bandit 1.9.4 and Gitleaks 8 floors (pyproject extra, and the detect command used by the secrets scan); no floor for SkillSpector is correct because the validator keeps a legacy path for older reports; option validation (unselected-tier options, --timeout bounds and NaN, unknown --checks) and exit codes, which I exercised by hand; Tier 3 default behavior, tier3 doctor, the timeout passed to the OpenAI/Anthropic/litellm clients, status-only live diagnostics, docs and CHANGELOG.

Local verification (head b531e38): ruff check clean; pytest tests/test_doctor.py tests/test_cli.py tests/test_base_install.py tests/embedding/test_client.py tests/inference/test_llm_client.py tests/golden: 501 passed. Manual doctor --tier 1/2 runs behaved as documented.

Reviewed with Claude Code.

Conflicts: CHANGELOG.md, docs/tier1-validation.mdx

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rng1995
rng1995 merged commit 77fdf74 into main Nov 2, 2026
21 checks passed
@rng1995
rng1995 deleted the naren/port-doctor-tier-checks branch November 2, 2026 19:52
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