Skip to content

M49 (TASK-87-FREE): Opt-In --llm-assist Semantic Alignment Analyzer on UCP Path B

Status Note (Done, v0.2.11)

  • Shipped in M49 (v0.2.11): DualPathRouter.route_server(...) is wired into ConsolidatedSecurityAuditor.audit_server(..., live_probe=True) for non-empty live_cap.tools; TEMPLATE_INDICATORS is corrected in src/verity/scanner/static_rules.py; pure-stdlib src/verity/scanner/semantic_assist.py provides SemanticAssistClient with input pre-sanitization and an exact evidence_span guard emitting VERITY-SEMANTIC-ASSIST-ADVISORY; verity scan exposes --llm-assist, --llm-provider, --llm-model, and --fail-on-advisory; and the paired unit tests pass.

Purpose & Architectural Decisions

  • 100% Deterministic Default: Without --llm-assist, verity scan performs zero HTTP/LLM calls and keeps 100% deterministic offline output and exit codes.
  • Anti-Hallucination & Prompt Hygiene: When --llm-assist is explicitly passed, SemanticAssistClient pre-sanitizes all ToolSemanticCheckInput fields via MetadataNormalizer.sanitize_text and enforces exact substring verification on SemanticFindingDraft.evidence_span (discarding fabricated findings).
  • Zero Extra AI SDK Dependencies: Support ollama, deepseek, openai, anthropic, and gemini via pure Python stdlib (urllib.request) emitting VERITY-SEMANTIC-ASSIST-ADVISORY.

Target Files

File Change
src/verity/discovery/auditor.py Wire DualPathRouter.route_server(...) when live_cap.tools is non-empty
src/verity/scanner/static_rules.py Fix TEMPLATE_INDICATORS pattern accuracy
src/verity/scanner/semantic_assist.py New pure-stdlib SemanticAssistClient with exact evidence_span verification
src/verity/cli.py Expose --llm-assist (and provider/model options) on verity scan
tests/unit/scanner/test_semantic_assist.py Zero-network default, sanitization, substring verification & provider tests

ATDD Traceability Matrix

AC ID Acceptance Criterion Paired Benign / Negative Control Verification Tier Test Target
AC-49.1 ConsolidatedSecurityAuditor.audit_server(..., live_probe=True) routes non-empty live_cap.tools through DualPathRouter. Empty tool list skips UCP plan generation cleanly. unit tests/unit/test_auditor_dual_path.py
AC-49.2 Without --llm-assist, verity scan executes zero HTTP/LLM requests. Monkeypatched urllib.request.urlopen is never called. unit tests/unit/scanner/test_semantic_assist.py::test_zero_network_by_default
AC-49.3 SemanticAssistClient sanitizes inputs and discards drafts whose evidence_span is not an exact substring. Valid evidence span emits VERITY-SEMANTIC-ASSIST-ADVISORY. unit tests/unit/scanner/test_semantic_assist.py::test_evidence_span_guard
AC-49.4 Mocked ollama/deepseek/openai/anthropic/gemini responses parse cleanly with 0 new dependencies in pyproject.toml; ruff clean. Malformed LLM payload degrades safely without crash. ruff uv run ruff check src tests