stemedb/latent/divergence-engine/README.md
jordan b3e8a9a058 feat: Multi-application expansion with chaos testing and community UI
Major additions:
- Community Next.js app (port 18187) for browsing claims with API docs
- stemedb-chaos crate: Fault injection, chaos testing, CRDT properties
- Latent ingestion system: Reddit/FDA ingesters with ADK-Go agents
- Disputed claims handling: Manual review workflows and validation
- Aphoria security scanner: New extractors (SQL injection, command
  injection, weak crypto, TLS version), policy-based ignores, UAT reports
- Docker infrastructure: Dockerfile, docker-compose.yml for full stack
- VulnBank demo: Intentionally vulnerable multi-language test corpus

SDK & API enhancements:
- Source registry handlers for tracking data provenance
- Metrics endpoint
- Skeptic filtering improvements

Code quality:
- Split 14 large files (>500 lines) into focused modules
- All files now under 500-line limit per project guidelines

Documentation:
- Chaos testing guide, circuit breakers, observability docs
- Phase 7 UAT documentation updates
- Martin Kleppmann technical writer agent

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:24:14 -07:00

1.2 KiB

Latent: Divergence Engine (Week 3)

This is the core logic of Latent. It implements the Skeptic Lens by comparing the "Official Truth" (Tier 0) against the "Latent Signal" (Tier 5).

Logic (The "Alpha")

The engine calculates a divergence_score (0.0 - 1.0) for every symptom cluster found on Reddit.

 
Divergence = \begin{cases} 
      0.1 \times Volume & \text{if present in FDA Label} \\
      0.9 \times Volume \times Severity & \text{if absent from FDA Label} 
   \end{cases}
  • High Divergence (>0.6): Means Reddit is screaming about something the FDA label does not mention. This is the Alpha.
  • Low Divergence (<0.3): Means Reddit is complaining about nausea, and the FDA label says "Nausea is common." This is Noise.

Usage

  1. Prerequisites: You must have run ingest-fda and ingest-reddit first to generate the .jsonl graph files.
  2. Install: pip install -r requirements.txt
  3. Run: python main.py

Output

Generates divergence_report.json.

[
  {
    "molecule": "semaglutide",
    "signal": "gastroparesis",
    "volume": 42,
    "divergence_score": 0.85,
    "status": "LATENT_SIGNAL",
    "regulatory_status": "Silent/Absent"
  }
]