Architecture overview
Verity is an investigative deepfake examination workbench engineered around two foundational decisions:
- Preserve every detector's voice separately: never collapse multi-detector panels into a single opaque verdict — disagreement across architectures is the primary analytical finding.
- Zero external runtime dependencies in deployment: ship one self-contained Linux binary (alongside a Docker option) that manages
uv, Python runtimes, 58 isolated environments, SHA-256-verified checkpoints, and case workspaces cleanly viaplatformdirs, then operates 100% air-gapped.
The repository consists of three core software surfaces plus isolated out-of-process detector runtimes and chain-of-custody exporters:
| Component | Location | Role |
|---|---|---|
verity | src/verity/ | Core pipeline: paths, ingest, extract, forensics, analyze, detect, compile, report, weights, runtime, export, cli |
verity_api | src/verity_api/ | FastAPI HTTP service and thread-pool JobManager wrapping pipeline objects |
verity_ui | src/verity_ui/ | React / Mantine / Vite SPA served directly by FastAPI on port 8000 |
| Detector environments | detectors/<id>/ | 58 independent uv projects launched out of process |
Unidirectional dependency direction
graph TD
UI["verity_ui (React SPA)"] --> API["verity_api (FastAPI + JobManager)"]
API --> CORE["verity (Pipeline + paths + runtime)"]
CORE --> MODELS["verity.models"]
CORE -. "uv subprocess / env_manager" .-> DET["detectors/<id> (58 isolated uv envs)"]verityknows nothing about FastAPI or React.verity_apiis strictly a thin adapter (src/verity_api/service.py) composing the exact same pipeline objects (MediaIngestor,ForensicsRunner,MediaAnalyzer,DetectorSelector,DetectorRunner,FindingsCompiler,ReportGenerator,export_evidence_bundle) and streaming steps viaJobContextinstead of stdout. This guarantees the CLI, HTTP API, Web Console, and PDF report cannot disagree on any probability or selection decision.detectors/<id>/run out of process viaverity.runtime.env_manager(orscripts/verity.py/verity-run), exchanging staged media copies,result.json,finding.json, PNG artifacts, and logs. Out-of-process execution is why dozens of mutually incompatible PyTorch, CUDA,timm, andtransformersversions coexist cleanly.
Why single binary + platformdirs + uv (instead of a 20 GB fat binary or Docker-only)
Lab forensic workstations are frequently offline or air-gapped after initial provisioning, run under locked-down non-root investigator accounts, and cannot always run a Docker daemon. Packaging everything directly inside a single binary would weigh 15–25 GB and break CUDA/PyTorch isolation. Instead, Verity uses a hybrid architecture cleanly implemented in src/verity/paths.py and src/verity/runtime/env_manager.py:
- Small single executable (
~130 MB): PyInstaller (scripts/build_binary.py) bundles only Python 3.12,verity,verity_api, the builtverity_uiSPA, config/Haar cascades, and the source/YAML/lock specs of all 58 detectors (never weight binaries). - Automatic dual-mode path resolution (
src/verity/paths.py):- Standalone binary /
VERITY_HOMEmode: stores all mutable runtime state viaplatformdirs(~/.local/share/verity,~/.cache/verity,~/.config/verity, or$VERITY_HOME/{data,cache,config}). On startup,ensure_bundled_detectors_extracted()unpacks bundled detector scripts while symlinking everydetectors/<id>/weightsto persistent<data_dir>/weights/<id>so upgrading the binary never deletes downloaded checkpoints. - Repository development mode: when running from an editable checkout with no
VERITY_HOME, preserves repo-local defaults (detectors/,workspace/,.detectorenvs/) so local tests and hacking need zero configuration.
- Standalone binary /
Core package responsibilities (src/verity/)
| Module | Responsibility |
|---|---|
verity.paths | Dual-mode platformdirs / VERITY_HOME / repo layout, persistent config.yaml, offline seal check |
verity.ingest | SHA-256 content-addressed media IDs (first 12 hex chars) and 0o444 read-only copies |
verity.extract | Deterministic frame, face, metadata, and audio extractors |
verity.forensics | Five model-free analyzers emitting severity-sorted observations without verdicts |
verity.analyze | ffprobe + Haar face scan characterization and ordered rule-based DetectorSelector |
verity.detect | DetectorRegistry, staged DetectorRunner, and output_parser |
verity.runtime | env_manager — self-bootstraps uv + managed Pythons, builds profiles, warms HF/Torch caches |
verity.compile | FindingsCompiler sorting findings and computing trained-only aggregate scores |
verity.report | Deterministic self-contained HTML + optional WeasyPrint PDF reports |
verity.weights | Version-2 manifest, SHA-256 verification gate, hub mirroring, HF bundling |
verity.export | Chain-of-custody .zip evidence bundles (MANIFEST.json + SHA256SUMS.txt) and USB airgap kits |
Workspace & report layout
<workspace>/ (data_dir/workspace in binary mode; ./workspace in dev)
media/
<media_id>.<ext> 0o444 read-only working copy
.<media_id>.json MediaInfo sidecar (full SHA-256 + source metadata)
artifacts/<media_id>/
{frames,faces,metadata,audio}/
forensics/ forensics.json + per-analyzer JSON & PNGs
output/
<media_id>_<detector_id>/ result.json, finding.json, logs, attention/face PNGs, timeline.png
<output_dir>/ (configurable; defaults to <workspace>/output)
<media_id>/ analysis.json, selection.json, report.html, report.pdf, evidence zipNote the intentional separation documented in src/verity_api/config.py: raw detector run directories always live under workspace/output/, whereas case-level reports and analysis JSON live under configurable output_dir.
Core engineering principles
- Determinism: Media IDs derive from SHA-256 bytes, video readers iterate sequentially, seeds (
0xC0FFEE) and cuDNN flags are pinned, JSON keys are sorted, and galleries sort by probability + filename tie-breaker. - Honest absence & trust tiers: Untrained (
backbone-only,random-init,untrained) heads are excluded by default and blocked from consensus; broken sub-modules (e.g., RECCE's untrained decoder) are audited at load and omitted. - Fail-soft isolation: Individual extractors, forensic analyzers, or detector subprocesses fail visibly as
notice/ neutral findings without losing the rest of the case. - Examiner sovereignty: Reports omit verdicts and aggregate scores; forensic analyzers emit observations with exact method caveats; evidence exports seal every file under
SHA256SUMS.txt.
Entrypoints
verity(src/verity/cli.py) — unified CLI (run,analyze,setup,doctor,serve,weights,airgap,export, and stage subcommands).verity-server(src/verity_api/main.py) — FastAPI server serving both/api/*and the compiled React SPA cleanly from source or PyInstaller frozen binaries.scripts/verity.py/verity-run— thin delegation shim ontoverity.runtime.env_manager.mainfor container and shell workflows.docker/entrypoint.sh— container entrypoint pulling missing trained weights when online before launchingserveror CLI jobs.
Related pages
- Examination pipeline — stage-by-stage orchestration flow.
- Web API and investigator console — FastAPI endpoints and React UX.
- Explainability artifacts and on-disk formats — file contracts and schemas.
- Deployment, configuration and air-gap operations —
platformdirs,setup --airgap-ready, and USB kits.