No description
Find a file
Benn1x 7139702f81
Some checks failed
Build & Test / build (push) Failing after 9s
docs: add README, architecture docs, and Forgejo CI workflow
- README.md with architecture overview, setup instructions, and signal formulas
- docs/architecture.md, anomaly-detection.md, configuration.md, analysis-pipeline.md
- Lumen added as git submodule (replaces hardcoded local path)
- lumen-bridge resolves relative paths for binary_path config
- .forgejo/workflows/build.yml for CI (build, test, fmt, clippy)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 15:52:40 +02:00
.forgejo/workflows docs: add README, architecture docs, and Forgejo CI workflow 2026-04-10 15:52:40 +02:00
alert-router feat: alert-router with tiered dispatch 2026-04-10 15:08:36 +02:00
anomaly-engine feat: anomaly-engine with rolling windows, 4 signals, and composite scorer 2026-04-10 15:03:48 +02:00
claude-client feat: claude-client with Anthropic API wrapper and retry logic 2026-04-10 15:10:32 +02:00
docs docs: add README, architecture docs, and Forgejo CI workflow 2026-04-10 15:52:40 +02:00
lumen@d499ec9c41 docs: add README, architecture docs, and Forgejo CI workflow 2026-04-10 15:52:40 +02:00
lumen-bridge docs: add README, architecture docs, and Forgejo CI workflow 2026-04-10 15:52:40 +02:00
pdf-generator feat: pdf-generator with Typst templates and auto-open 2026-04-10 15:17:40 +02:00
poly-sentinel feat: poly-sentinel main orchestrator with full pipeline wiring 2026-04-10 15:20:15 +02:00
polymarket-client feat: polymarket-client with WebSocket consumer and Gamma API 2026-04-10 15:07:03 +02:00
sentinel-types feat: scaffold workspace and sentinel-types crate 2026-04-10 15:00:40 +02:00
.gitignore chore: gitignore for target, reports, and superpowers 2026-04-10 15:20:57 +02:00
.gitmodules docs: add README, architecture docs, and Forgejo CI workflow 2026-04-10 15:52:40 +02:00
Cargo.lock docs: add README, architecture docs, and Forgejo CI workflow 2026-04-10 15:52:40 +02:00
Cargo.toml feat: scaffold workspace and sentinel-types crate 2026-04-10 15:00:40 +02:00
README.md docs: add README, architecture docs, and Forgejo CI workflow 2026-04-10 15:52:40 +02:00
sentinel.toml docs: add README, architecture docs, and Forgejo CI workflow 2026-04-10 15:52:40 +02:00

Poly-Sentinel

Real-time Polymarket insider trading detector. Monitors geopolitics prediction markets via WebSocket, detects anomalies through multi-signal statistical analysis, and triggers an AI verification pipeline that produces PDF reports.

How It Works

Polymarket WebSocket --> anomaly-engine --> alert-router
                                                |
                              LOW:  log only    |
                              MED:  terminal    |
                              HIGH: ----------->|
                                                v
                                          claude-client (Anthropic API)
                                                |
                                                v
                                          lumen-bridge (SSOTCS MCP)
                                                |
                                                v
                                          pdf-generator (Typst)
                                                |
                                                v
                                          Save + auto-open + terminal alert

Trade data streams in via WebSocket. Four statistical signals are computed in real-time and combined into a composite anomaly score. When the score crosses the HIGH threshold (>= 0.8), the system:

  1. Calls Claude to analyze the anomaly and produce a verdict
  2. Pipes Claude's narrative through Lumen's SSOTCS verification system
  3. If the trust score passes (> 0.7), generates a PDF report with full analysis

Anomaly Detection Signals

Signal Formula What It Detects
Volume Z-Score z = (v - mean) / stddev Sudden volume spikes vs. rolling baseline
Price-Volume Divergence PVD = dV% / max(dP%, e) Large volume without proportional price movement
Order Flow Imbalance OFI = |V_buy - V_sell| / (V_buy + V_sell) One-sided buying/selling pressure
Herfindahl Index HHI = sum(s_i / S)^2 Trade size concentration (few large actors)

Composite score: S = w1*sig(z_vol) + w2*sig(z_pvd) + w3*OFI + w4*HHI

Alert Tiers

Tier Condition Action
LOW S < 0.5 Structured log entry
MEDIUM 0.5 <= S < 0.8 Terminal alert with score breakdown
HIGH S >= 0.8 Full pipeline: Claude analysis -> Lumen verification -> PDF report

Project Structure

Crate Purpose
sentinel-types Shared types: Trade, Market, AnomalyScore, Config, Report
polymarket-client WebSocket consumer + Gamma API market discovery
anomaly-engine Rolling windows, 4 statistical signals, composite scorer
alert-router Tiered alert dispatch (log / terminal / pipeline)
claude-client Anthropic Messages API wrapper with 3x retry
lumen-bridge MCP client spawning Lumen's SSOTCS server for verification
pdf-generator Typst-based PDF report rendering with auto-open
poly-sentinel Main binary orchestrator wiring everything together

Prerequisites

  • Rust (edition 2024)
  • Typst CLI (cargo install typst-cli)
  • Anthropic API key (set as ANTHROPIC_API_KEY env var)
  • Lumen (included as git submodule)

Setup

# Clone with submodules
git clone --recurse-submodules ssh://git@tu-po.com/xemmerling/Poly-Sentinel.git
cd Poly-Sentinel

# Or if already cloned without submodules
git submodule update --init --recursive

# Install typst CLI
cargo install typst-cli

# Build
cargo build --release

# Set your API key
export ANTHROPIC_API_KEY="your-key-here"

# Run
cargo run --release

Configuration

All configuration lives in sentinel.toml. See docs/configuration.md for the full reference.

Key sections:

  • polymarket -- categories and specific market IDs to monitor
  • detection -- window size, signal weights, alert thresholds
  • claude -- API key env var name, model selection
  • lumen -- path to Lumen repo, MCP server name
  • output -- report directory, auto-open behavior

Documentation

License

See LICENSE for details.