Catch agent hallucinations before your users do.
Deterministic citation-span entailment, workspace AST symbol grounding, and surgical self-correction prompts in 0.128 ms P50 — zero LLM-as-a-Judge calls.
uvx --from git+https://github.com/codesphere-u/truthgate truthgate demo
Demo Run: truthgate demo audits 4 claims in 1.200 ms, flagging TG003 (polarity flip), TG004 (4.28 ms vs 42.8 ms), and TG008 (missing verify_token_v2()).
Symbol verify_token_v2 not found in src/auth/jwt.py AST (available: verify_token, decode_payload, TokenValidator).
Prevents responses from citing #L120-L150 on a 24-line file or non-existent paths (TG006).
1. [TG003] Offending statement: "TLS 1.0 is permitted..." → Evidence: "TLS 1.0 is not permitted in production environments."
2. [TG004] Claim reports '4.28 ms' vs source value [42.8 ms]. Rewrite using exact metric.
Catches Polarity Flips (TG003)
Detects omitted negations and antonym swaps like permitted vs prohibited or enabled vs disabled against cited RAG sources.
Stops Numeric Drift (TG004)
Matches decimals, percentages, latencies, and multi-currency literals (USD, UGX, EUR, ms) verbatim before decimal shifts slip through.
Grounds Files & AST Symbols (TG006–TG008)
Verifies referenced file paths, #Lstart-Lend line bounds, and Python AST / TS / JS / Go / Rust symbol tables directly against your repository.
Compiles Surgical Fixes (0.128 ms)
When verification fails, compiles a focused repair prompt naming only violating claims and exact ground-truth spans so agents fix errors in one hop.
Eight Deterministic Verification Gates
Citation entailment meets AST workspace symbol verification, exposed via CLI, Python SDK, REST API, and MCP.
Test claims interactively in Studio, inspect the 40-Scenario Benchmark, or wire up MCP & Docs.
Frequently Asked Questions
Why use TruthGate instead of an LLM-as-a-Judge guardrail?
LLM judges add 1–3 seconds of latency, extra API cost, and stochastic variance. TruthGate audits citations, negation flips, numeric drift, and AST symbols deterministically in 0.128 ms P50 with 100.0% precision and recall on its 40-scenario benchmark.
What rules does TruthGate check across text and code?
TG001–TG005 check phantom source IDs, IDF-weighted entity support, negation/antonym polarity inversions, numeric/currency drift, and uncited factual assertions. TG006–TG008 ground file paths, #Lstart-Lend ranges, and AST symbols.
Does TruthGate work as an MCP Server and HTTP Workbench?
Yes. Run truthgate mcp for Stdio JSON-RPC 2.0 MCP or truthgate serve-http for Streamable HTTP/SSE MCP, REST endpoints, Prometheus metrics, and the Workbench UI.