Skip to content

Examination pipeline ​

An examination applies a fixed, deterministic sequence of stages to a single content-addressed media item. Both the verity CLI (src/verity/cli.py) and FastAPI service (src/verity_api/service.py) compose the exact same stage objects — only progress reporting, concurrency/cancellation checks, and failure isolation differ.

End-to-end stage sequence ​

text
ingest ─► extract ─► forensics ─► analyze ─► select ─► detect (58 envs) ─► compile ─► report ─► export
StagePrimary Class / FunctionOn-disk Output
1. IngestMediaIngestorworkspace/media/<id>.<ext> (0o444), workspace/media/.<id>.json
2. ExtractFrameExtractor, FaceExtractor, MetadataExtractor, AudioExtractorworkspace/artifacts/<id>/{frames,faces,metadata,audio}/
3. ForensicsForensicsRunner + 5 analyzersworkspace/artifacts/<id>/forensics/forensics.json + PNGs
4. AnalyzeMediaAnalyzer<output_dir>/<id>/analysis.json
5. SelectDetectorSelector<output_dir>/<id>/selection.json
6. DetectDetectorRunner + env_managerworkspace/output/<id>_<detector_id>/ (result.json, finding.json, logs, PNGs)
7. CompileFindingsCompilerSorted FindingsCollection in memory (reads finding.jsons)
8. ReportReportGenerator<output_dir>/<id>/report.html + optional report.pdf
9. Export (optional)export_evidence_bundle<output_dir>/<id>/verity-evidence-<stem>-<id>.zip (MANIFEST.json, SHA256SUMS.txt)

Notice the intentional storage split: per-detector outputs live under workspace/output/, whereas case-level analysis.json, selection.json, reports, and exported evidence zips live under configurable output_dir (which defaults to <workspace>/output). In standalone single-binary mode (src/verity/paths.py), <workspace> defaults cleanly to <data_dir>/workspace (~/.local/share/verity/workspace or $VERITY_HOME/data/workspace).

Content-addressed case identity ​

A case is not a mutable database row — it is the directory tree keyed by the first 12 hex characters of the source file's SHA-256 checksum (media_id). Ingesting identical bytes twice reuses the same working copy idempotently, while modifying even a single bit creates a distinct case ID.

The CLI orchestration path (verity run & stage subcommands) ​

verity.cli.run executes synchronously for a file or directory of sorted files:

  1. Ingest via MediaIngestor.ingest().
  2. Extract using every configured extractor in config/pipeline.yaml (frame, face, metadata, audio).
  3. Forensics unless --no-forensics is passed, summarizing severity counts.
  4. Analyze & Select deterministically via MediaAnalyzer and DetectorSelector (honoring --include-untrained, --detector overrides, and paths.is_offline()). With --detector a,b, selection.decisions keeps all reasoning while rewriting included flags to reflect what ran.
  5. Run selected detectors sequentially via DetectorRunner.run(), writing finding.json beside each result.json.
  6. Compile & Report, saving analysis.json, selection.json, report.html, and (when --format pdf) report.pdf.

Individual stages are exposed cleanly on the CLI (verity ingest, extract, forensics, analyze, compile, report, export) for resumable or scripted investigations. Note that running verity extract automatically triggers _run_forensics afterward so forensic artifacts stay synchronized.

The API orchestration path (run_full_pipeline) ​

verity_api.service.run_full_pipeline wraps the same pipeline classes around a JobContext after upload (POST /api/media), adding three workflow guarantees:

  • Named steps & SSE streaming: declares extract, forensics, analyze, select, per-detector detect:<id>, compile, and report, streaming incremental logs over GET /api/jobs/{id}/events.
  • Cooperative cancellation: checks ctx.raise_if_cancelled() between extractors and between detectors.
  • Stage-level fail-soft containment: run_extract catches individual extractor errors (failed_extractors) and run_detectors catches individual detector crashes as failed steps while continuing the remaining panel. Even if zero detectors are eligible, the job completes with forensics, selection.json, and an explicit report showing nothing ran.

Every stage can also be launched standalone via HTTP (POST /api/extract, POST /api/forensics, POST /api/analyze, POST /api/compile, POST /api/report), and any completed or partial case can be sealed into a verifiable chain-of-custody archive via GET /api/media/{id}/export or verity export --media-id <id>.

Ordering guarantees ​

  1. Selection depends on analysis.json.
  2. Isolated detectors depend on staged artifacts/ copies.
  3. Compilation depends on every <media_id>_*/finding.json.
  4. Reports depend on analysis.json, selection.json, forensics.json, and FindingsCollection filtered strictly to selection.
  5. Exports hash and seal every artifact under MANIFEST.json + SHA256SUMS.txt.

Within every stage, media files, detectors, extractors, analyzers, and findings are iterated in explicit sorted order.

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