Skip to content

M63 (TASK-120-FREE): verity doctor [--format json] [--smoke] Health & Spawnability Diagnostics

1. Purpose & Architectural Decisions

  • Problem (P1.2): Users and coding agents need a fast, zero-cost diagnostic command to verify workstation MCP config health, SKILL.md presence, GUI-env spawnability of registered MCP commands, Ollama availability, non-secret auth refs, and installed local CLIs — without spending paid tokens or triggering macOS Keychain ACL popups.
  • Command Surface: verity doctor [--format text|json] [--smoke] [--check-keychain] implemented in src/verity/onboarding/doctor.py and wired in src/verity/cli.py.
  • Check Set: (1) workspace/project configs & SKILL.md validity, (2) durable MCP command spawnability simulating a minimal GUI PATH (sys.executable -m verity.mcp_server / binary exists and answers initialize), (3) Ollama GET /api/tags with a 250 ms timeout, (4) non-secret env-var & auth-file metadata checks, (5) local CLI probes cached in .verity/probe_cache.json.
  • Probe Cache: keyed by (binary_path, st_mtime_ns, st_size) + PATH, <300 ms warm runs, 300s TTL.
  • Zero-Popup Keychain Rule: never invoke /usr/bin/security find-generic-password unless --check-keychain is explicitly passed (500 ms timeout, without -w).
  • Opt-In Paid Smoke: --smoke runs a minimal ~10-token Reply with OK. check inside an isolated tempfile.TemporaryDirectory() (10–15s CLI / 5s HTTP) only when explicitly passed.
  • Free/Open-Core Boundary: zero Pro dependencies and zero verity_pro imports.

2. Target Files

File Change
src/verity/onboarding/doctor.py New diagnostics engine: config/SKILL.md validation, GUI-PATH spawnability probe, Ollama 250 ms probe, non-secret auth metadata, .verity/probe_cache.json cache, gated Keychain + --smoke
src/verity/cli.py Add verity doctor subcommand with --format text|json, --smoke, --check-keychain
tests/unit/test_doctor.py Unit tests for JSON health output, cache keying/invalidation, and smoke gating

3. ATDD Traceability Matrix

AC ID Acceptance Criterion Paired Benign / Negative Control Verification Tier Test Target
AC-63.1 verity doctor --format json returns structured health checks for configs, SKILL.md, durable MCP spawnability, Ollama /api/tags (250 ms timeout), and non-secret auth refs without writing secrets or calling Keychain by default. Negative control: no /usr/bin/security invocation occurs on the default path; secret values never appear in JSON output. unit tests/unit/test_doctor.py::test_doctor_json_reports_health_without_keychain
AC-63.2 .verity/probe_cache.json caches binary probe results keyed by (binary_path, st_mtime_ns, st_size) and completes warm runs cleanly (<300 ms), invalidating when mtime_ns changes. Paired control: unchanged binary re-uses the warm cache entry; bumped mtime_ns forces a re-probe. unit tests/unit/test_doctor.py::test_doctor_probe_cache_keyed_by_mtime_ns
AC-63.3 Without --smoke, zero paid LLM calls or subprocess prompt invocations execute; with --smoke, the minimal check runs inside an isolated TemporaryDirectory. Negative control: default run performs zero subprocess prompt invocations. unit tests/unit/test_doctor.py::test_doctor_smoke_gated_and_isolated
AC-63.4 Ruff linter and full unit test suite pass cleanly. Clean workspace yields zero lint errors. ruff uv run ruff check src tests && uv run pytest tests/

4. Verification Commands

uv run pytest tests/unit/test_doctor.py
uv run pytest tests/
uv run ruff check src tests

5. Execution Checklist

  • [ ] AC-63.1 implemented (verity doctor --format json health report, zero Keychain by default)
  • [ ] AC-63.2 implemented (.verity/probe_cache.json keyed by (binary_path, st_mtime_ns, st_size))
  • [ ] AC-63.3 implemented (--smoke gated + TemporaryDirectory isolation)
  • [ ] AC-63.4 verified green (ruff + full pytest)
  • [ ] Board #5 item PVTI_lAHOD-xmQM4Br351zhOMDt4 synced & status updated