Skip to main content

🔍 trustandverify

PyPI Python License: MIT Tests

Agentic knowledge verification using Subjective Logic confidence algebra.

trustandverify decomposes research questions into verifiable claims, gathers evidence from multiple search backends, scores confidence using formal Subjective Logic mathematics (Jøsang 2016), and produces provenance-rich reports with per-claim uncertainty quantification.


The Problem

Every major AI system treats confidence as a single scalar — or ignores it entirely. A confidence = 0.5 is meaningless: it could mean "strong evidence that the probability is 50%", or "we have literally no evidence and are guessing." These require fundamentally different downstream decisions.

trustandverify uses Subjective Logic opinion tuples (belief, disbelief, uncertainty, base_rate) so you always know not just what the AI thinks, but how much evidence it has.


Quick Start

pip install trustandverify[tavily,gemini]
import asyncio
from trustandverify import verify

report = asyncio.run(verify("Is remote work more productive than office work?"))
print(report.summary)
for claim in report.claims:
    op = claim.opinion
    print(f"  [{claim.verdict}] {claim.text}")
    print(f"    P={op.projected_probability():.3f}  b={op.belief:.3f} d={op.disbelief:.3f} u={op.uncertainty:.3f}")

Configured Usage

from trustandverify import TrustAgent, TrustConfig
from trustandverify.search import TavilySearch
from trustandverify.llm import GeminiBackend
from trustandverify.storage import SQLiteStorage
from trustandverify.export import JsonLdExporter, MarkdownExporter

config = TrustConfig(num_claims=5, max_sources_per_claim=3)

agent = TrustAgent(
    config=config,
    search=TavilySearch(),
    llm=GeminiBackend(),
    storage=SQLiteStorage("reports.db"),
)

report = await agent.verify("Is nuclear energy safer than solar?")

JsonLdExporter().render_to_file(report, "report.jsonld")
MarkdownExporter().render_to_file(report, "report.md")

Byzantine-Resistant Fusion

Byzantine fusion is off by default — standard cumulative fusion is used. When enabled, it removes discordant, low-trust sources before fusion:

config = TrustConfig(
    enable_byzantine=True,         # activate Byzantine filtering
    byzantine_threshold=0.15,      # discord score cutoff
    byzantine_min_agents=2,        # never reduce below this many
)

When Byzantine is off, score_claim() still runs a lightweight diagnostic and returns meta["byzantine_recommended"] — a flag indicating whether filtering would help, along with cohesion and discord details. This lets you surface a recommendation in your UI without changing the scoring behavior.


CLI

trustandverify "Is coffee healthy?"
trustandverify "Is coffee healthy?" --claims 5 --llm gemini --format markdown
trustandverify ui   # Launch Streamlit dashboard

Why Subjective Logic?

Scenario Scalar Confidence trustandverify Opinion
Strong evidence it's 50/50 0.5 b=0.45, d=0.45, u=0.10
No evidence at all 0.5 b=0.00, d=0.00, u=1.00
Sources violently disagree 0.5 b=0.40, d=0.40, u=0.20

Confidence algebra (from jsonld-ex 0.7.0):

  • Cumulative fusion — more independent agreeing sources → lower uncertainty
  • Byzantine-resistant fusion — optionally filter discordant, low-trust sources before fusion
  • Trust discount — .gov/.edu sources weighted higher than Reddit
  • Cohesion scoring — measures overall source agreement (0–1)
  • Pairwise conflict & opinion distance — surfaces where sources disagree, quantified with both evidential tension and metric distance

Install Options

pip install trustandverify                              # core only
pip install trustandverify[tavily,gemini]               # minimal working setup
pip install trustandverify[tavily,brave,openai,sqlite]  # typical setup
pip install trustandverify[all]                         # everything

Architecture

trustandverify/
├── core/        — TrustAgent, pipeline, models, config
├── scoring/     — Subjective Logic algebra (wraps jsonld-ex 0.7.0: fusion, Byzantine, cohesion, distance)
├── search/      — SearchBackend protocol + Tavily, Brave, Bing, SerpAPI
├── llm/         — LLMBackend protocol + Gemini, OpenAI, Anthropic, Ollama
├── storage/     — StorageBackend protocol + memory, SQLite, Postgres, Neo4j
├── cache/       — CacheBackend protocol + file cache, Redis
├── export/      — ExportBackend protocol + JSON-LD, Markdown, HTML, PDF
├── cli/         — Typer CLI
└── ui/          — Streamlit dashboard

Documentation


References

  • Jøsang, A. (2016). Subjective Logic: A Formalism for Reasoning Under Uncertainty. Springer.
  • jsonld-ex — JSON-LD 1.2 extensions with Subjective Logic confidence algebra
  • W3C PROV-O — Provenance Ontology

License

MIT — see LICENSE.

Metadata

Release files for trustandverify 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trustandverify 0.2.1
File Size Uploaded Provenance
trustandverify-0.2.1.tar.gz 45.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for trustandverify 0.2.1
File Interpreter ABI Platform
trustandverify-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 113.0 kB

Release files / trustandverify-0.2.1.tar.gz

Download URL trustandverify-0.2.1.tar.gz
Size 45.7 kB
Tags Source
SHA-256 checksum
How to use checksums
94bf59aed64037d76f4ecd05c16480d8b34f4d384a176c20c9a97aa6536ef03e
BLAKE2b-256 checksum
How to use checksums
455e773ebd0c46306ff10ff1777c7e3d8aa1cedd25db5730dc664f5f775f318c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 7, 2026.

Transparency log

Release files / trustandverify-0.2.1-py3-none-any.whl

Download URL trustandverify-0.2.1-py3-none-any.whl
Size 67.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc19aa11fa278b9fc2a9f84a7c21f8cf983d8f63bf255ca263149122db72b39b
BLAKE2b-256 checksum
How to use checksums
0790ed6b77483bb66789607c395c5ba6aea1c66be7fcb1d9104c43435ce37aed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 7, 2026.

Transparency log

Security for trustandverify 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for trustandverify-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page