Skip to content

Architecture overview ​

Verity is an investigative deepfake examination workbench engineered around two foundational decisions:

  1. Preserve every detector's voice separately: never collapse multi-detector panels into a single opaque verdict — disagreement across architectures is the primary analytical finding.
  2. 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 via platformdirs, 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:

ComponentLocationRole
veritysrc/verity/Core pipeline: paths, ingest, extract, forensics, analyze, detect, compile, report, weights, runtime, export, cli
verity_apisrc/verity_api/FastAPI HTTP service and thread-pool JobManager wrapping pipeline objects
verity_uisrc/verity_ui/React / Mantine / Vite SPA served directly by FastAPI on port 8000
Detector environmentsdetectors/<id>/58 independent uv projects launched out of process

Unidirectional dependency direction ​

text
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/&lt;id&gt; (58 isolated uv envs)"]
  • verity knows nothing about FastAPI or React.
  • verity_api is 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 via JobContext instead 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 via verity.runtime.env_manager (or scripts/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, and transformers versions 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 built verity_ui SPA, 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_HOME mode: stores all mutable runtime state via platformdirs (~/.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 every detectors/<id>/weights to 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.

Core package responsibilities (src/verity/) ​

ModuleResponsibility
verity.pathsDual-mode platformdirs / VERITY_HOME / repo layout, persistent config.yaml, offline seal check
verity.ingestSHA-256 content-addressed media IDs (first 12 hex chars) and 0o444 read-only copies
verity.extractDeterministic frame, face, metadata, and audio extractors
verity.forensicsFive model-free analyzers emitting severity-sorted observations without verdicts
verity.analyzeffprobe + Haar face scan characterization and ordered rule-based DetectorSelector
verity.detectDetectorRegistry, staged DetectorRunner, and output_parser
verity.runtimeenv_manager — self-bootstraps uv + managed Pythons, builds profiles, warms HF/Torch caches
verity.compileFindingsCompiler sorting findings and computing trained-only aggregate scores
verity.reportDeterministic self-contained HTML + optional WeasyPrint PDF reports
verity.weightsVersion-2 manifest, SHA-256 verification gate, hub mirroring, HF bundling
verity.exportChain-of-custody .zip evidence bundles (MANIFEST.json + SHA256SUMS.txt) and USB airgap kits

Workspace & report layout ​

text
<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 zip

Note 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 ​

  1. 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.
  2. 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.
  3. Fail-soft isolation: Individual extractors, forensic analyzers, or detector subprocesses fail visibly as notice / neutral findings without losing the rest of the case.
  4. 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 onto verity.runtime.env_manager.main for container and shell workflows.
  • docker/entrypoint.sh — container entrypoint pulling missing trained weights when online before launching server or CLI jobs.

Verity v0.6.0 · Non-commercial forensic workbench (CC BY-NC 4.0) · Grounded in OpenWiki