Repository avatar
AI Tools
v0.1.0
active

redmule

io.github.Rylie-KIM/redmule

Hidden fraud exam for Solana fraud detectors: finds what they miss and generates training data.

Documentation

RedMule

The fraud exam your AI can't cram for.

Solana — Money That Moves · built in one day

Solana devnet Private mode Python FastAPI MCP Docker Tests

Demo video · Results · Devnet proof · Architecture · Run it · API · API proof · Claude Code · What's not built


Auto mode in the RedMule Workbench: the wallet graph, five trained models in turn, and precision and recall charted by iteration

Auto mode on the live site (MP4). Each iteration is a really trained model, trained beforehand and replayed. Try it · Earlier 2-minute narrated demo (previous UI)



RedMule landing page: two ways to try it on the left, a 3D graph of the real Solana devnet run on the right

The landing page. The 3D graph is the real devnet run: 1 source → 12 mules → 1 collector. Red means flagged by Model B.


Our fraud model scored 100.0 on practice. On a hidden exam it had never seen, it scored 2.1.

RedMule is the hidden exam. It generates labelled Solana laundering traffic, grades a fraud detector on fresh exams that a coding agent can't read, shows exactly which fraud patterns slip through, and generates the training data that closes the gap.

Architecture

  Browser (demo-ui: workbench + dashboard)            Claude Code / Cursor
                 │  X-API-Key                                │
                 │                                    MCP server (7 tools)
                 ▼                                           │
  ┌──────────────────────────────────────────┐               │
  │  Workspace API  :8000   FastAPI + SQLite  │◄──────────────┘
  │  datasets · models · runs · schema maps   │
  │  predicts locally, sends scores only      │
  └──────────────────────┬───────────────────┘
                         │  start exam (no labels) / submit scores
                         ▼
  ┌──────────────────────────────────────────┐
  │  Hidden exam server  :8001                │
  │  secret seed + labels in memory only      │
  │  opaque wallet ids · single use · 5/hour  │
  │  aggregate report · cheat scanner         │
  └──────────────────────────────────────────┘
        both import redmule/ (generator · features · scoring · training · insights)
        devnet_tx.csv ◄── fanout.mjs (real Solana devnet run, run by hand, mainnet refused)

Test results (make test, run on the final code): 63 pytest tests passed (18 core, 22 exam server, 23 workspace API). The MCP test client passed in local-fallback mode, and again in API mode against the live servers, with 9 tool calls. scripts/integration_test.py also passed, and every endpoint is shown with its real output in docs/API_PROOF.md. The TypeScript packages/ workspace passes its own 31 vitest tests (pnpm test) on the same merged code.

Why this matters now

  • There is no labelled fraud data on Solana. Real laundering is rare, gets confirmed months later and can't be shared. ML fraud models have nothing to learn from.
  • Privacy Rings hide amounts. Helius Privacy Rings went live on mainnet on 10 Nov 2026 and hide transfer amounts. Fraud rules built on amounts now see nothing.
  • AI agents write the fraud models, and they cram. A coding agent optimises for the tests it can see. Give it a visible test set and it learns the test set, not fraud.

So teams are shipping detectors that look perfect and catch almost nothing. RedMule makes that visible before an attacker does.

The result in one table

Each model sits the same 5 hidden exams, each generated from its own secret seed. Private mode is on, so the detector never sees amounts.

PracticeHidden exam
(mean of 5)
RangeOverfit gapFraud value escaped
Model A: trained on unrandomised data100.02.10.6–4.297.9 pts97.9%
Model B: trained on randomised data99.892.486.4–97.67.4 pts7.3%

Reproduce with python ringer.py --demo-seed 42. Default runs use fresh secret seeds, so the numbers move a little each run. Escape is value-weighted.

Why Model A fails. 98.5% of its feature weight sits on age_seconds. It learnt our simulator's fixed timing, not laundering. It is perfect on practice data drawn from the same simulator, and blind on anything else.

Why Model B holds up. It was trained with domain randomisation, so it relies on network shape instead: median_hop_gap_s (0.44) and shared_funder_count (0.34). These survive hidden amounts.

Coverage by fraud pattern (pooled over the 5 exams):

PatternModel A caughtModel B caughtModel B value escaped
Fan-out / fan-in (source → N mules → collector)9.3%89.6%23.7%
Peel chain (5–15 hops, peeling off at each hop)0.1%100%0%

Model B's weak spot is fan-out / fan-in: it catches 90% of those wallets, yet 24% of the fraud value still escapes. That's the gap RedMule tells you to train on next. Its 100% on peel chains is not evidence of generalisation, because peel chains were in its training data.

Workbench: the sample case, iteration by iteration

The Workbench tab runs on a separate sample set (post-drain dispersal, generated with LiteSVM). Case T01 has 704 wallets, 251 of them fraud. Values show "–" until you press Run exam or Auto mode. Threshold 0.50:

StepChangePrecisionRecallMissed
BaselineFixed rule, no training93.0%79.3%52
Iteration 1XGBoost on connection counts79.9%87.3%32
Iteration 2+ shared funder, wallet age, KYC90.6%84.1%40
Iteration 3+ timing and pass-through99.6%94.8%13
Iteration 4Larger training set (train_v2)98.8%97.2%7

Read these with care: the data is synthetic, and features are computed over each wallet's full history, so they include information a live detector wouldn't have yet. The models are trained beforehand; the page replays their scores. The Tests, Run history and drain-analytics panels in the Workbench are illustrative samples, not measured results.

The loop that fixes it

The score is only half the product. Finding the gap and closing it is the other half:

 run hidden exam  →  coverage shows the weakest pattern  →  generate data weighted towards it  →  retrain  →  fresh hidden exam
The RedMule dashboard after three real loops: starter model runs at 40.0, 29.0 and 38.1, retrained models at 73.0, 83.8 and 83.5; coverage shows peel chain 100% caught and structuring as the weakest pattern at 62%

The live dashboard after three real loops in one workspace (runs #1–#6). Each pair is the starter model, then the same model after Generate targeted data → Retrain: 40.0 → 73.0, 29.0 → 83.8, 38.1 → 83.5. Coverage now flags structuring as the weakest pattern, so that is what the next round targets.

Real numbers from those loops. Every exam is freshly generated with a secret seed and mixes three attack patterns (50% fan-out / fan-in, 25% peel chain, 25% structuring):

LoopBefore: RedMule Score (peel chain / structuring caught)After one round of targeted data + retrain
scripts/integration_test.py40.0 (0.0% / 64.6%)73.0 (100.0% / 71.6%)
docs/API_PROOF.md29.0 (0.0% / 55.6%)83.8 (100.0% / 62.5%)
Dashboard buttons (headless click-through)38.1 (0% / —)83.5 (100% / 62.0%)
MCP tools (demo-ui/mcp_session.json)43.1 (0% / 60.2%)95.3 (100% / 84.8%)

"—" means that run's structuring rate wasn't recorded separately.

  • The starter model never saw a peel chain, and it catches none. One focused round, weighted by miss rate, closes that gap every time.
  • Structuring is the next weak spot. It improves less (for example 64.6% → 71.6%) because the targeted set puts only about a quarter of its weight on it. The dashboard now marks it weakest and puts 66% of the next round on it.
  • Fan-out / fan-in can dip a few points (for example 97.4% → 94.7%). That's within the run-to-run spread, but it isn't proof nothing regresses.
  • Each report also measures time to detect. In the MCP session the retrained model caught 100% of fraud scenarios before cash-out, a median of about 8 hours ahead.

Real Solana devnet run

We ran the laundering pattern for real: 1 source → 12 temporary mule wallets → 1 collector, 0.002 devnet SOL per mule (fanout.mjs). Model B then scored those wallets from the raw transfers (ringer.py --devnet). It flagged 14 of 14: all 12 mules, the collector and the source.

An honest caveat. An earlier Model B flagged only the 12 mules and missed the collector. We then added "burst" fan-in timing to the randomised generator, and kept the change only because it also raised the hidden-exam mean (92.2 → 92.4 on seed 42; 90.4 → 92.8 averaged over seeds 42, 7 and 123). Because we changed the generator after seeing this devnet result, the 14 / 14 is not an independent test. It shows the model now covers this timing shape.

Why the exam can't be crammed

Attack a coding agent might tryWhat stops it
Read the exam labelsLabels live in the exam server's memory only. They are never written to disk and never returned.
Memorise the examEvery exam is generated fresh from a secrets seed. No two are the same.
Infer labels from wallet idsWallets get random opaque ids (ex_…) and rows are shuffled.
Probe the exam over and overExams are single-use (a reused id gets 410), expire after 10 minutes and are rate-limited to 5 per hour per key.
Learn from per-wallet feedbackReports are aggregates only: score, escape, false alarms, coverage, hints.
Hard-code is_fraud into the detectorA cheat scanner (/scan) flags label and seed references, with file and line.
Lean on amountsPrivate mode withholds amount-based features, mirroring Privacy Rings.

RedMule Score = 100 × (1 − escape) × (1 − false alarms). Escape is value-weighted, so missing one whale costs more than missing many minnows.

How it works

flowchart LR
  subgraph WS["Developer workspace"]
    UI["demo-ui<br/>workbench + dashboard"]
    CC["Claude Code / Cursor<br/>MCP server, 7 tools"]
    API["Workspace API :8000<br/>FastAPI + SQLite"]
    CORE["redmule/ core<br/>generator · features · scoring · insights"]
    UI --> API
    CC --> API
    API --> CORE
  end
  subgraph EX["Hidden exam server :8001"]
    SEED["secret seed per exam<br/>labels in memory only"]
    REP["aggregate report<br/>score · coverage · hints"]
  end
  API -- "start exam (no labels)" --> SEED
  API -- "submit scores only" --> REP
  DEV["fanout.mjs<br/>real Solana devnet run"] --> CORE
  • redmule/ core: a synthetic laundering generator (fan-out / fan-in, peel chains and structuring, where deposits are kept just under a cap) mixed with honest look-alikes (payroll fan-out, exchange-sweep fan-in, peer-to-peer noise). Also wallet features, XGBoost models, scoring, coverage and insights. ringer.py is a thin CLI over it.
  • Hidden exam server (backend/exam_server/): issues fresh exams without labels, takes scores back and returns aggregates only.
  • Workspace API (backend/api/): generates training data (including focus_from_exam, which weights the weakest patterns by miss rate), trains models, runs exams by predicting locally and submitting only scores, and stores run history, coverage and insights. It also handles company schema mapping and devnet scoring.
  • MCP server (mcp-server/): 7 tools that call the API, with a local fallback to ringer.py when the API is down.
  • Demo UI (demo-ui/), one page with tabs:
    • a landing page with two ways to try it and the Three.js scene of the real devnet run;
    • Workbench (Analyse, Tests, Run history, Data) on the sample case;
    • Dashboard for the exam → targeted data → retrain loop. Locally it refreshes every few seconds, so runs started from the MCP appear on it. The deployed site shows a read-only snapshot (refresh it with python3 scripts/export_snapshot.py, then commit demo-ui/).

Run it in two commands

make install   # .venv with pinned deps (uv, --exclude-newer), npm install, build the MCP server
make dev       # exam server :8001 + workspace API and demo UI :8000   (FRESH=1 make dev = empty workspace)

Then open http://localhost:8000/demo-ui/ (the Dashboard is a tab on the same page), or run make demo to start everything and open the dashboard.

make test          # 63 pytest tests + MCP test client (local fallback, and API mode when `make dev` is running)
make integration   # the full loop against the live servers, printing real numbers
docker compose up  # same two services in containers (api :8000, exam :8001); .env / wallets.json are never copied in
CLI only, no servers
npm install && pip install -r requirements.txt
node setup.mjs                           # devnet test wallets in wallets.json (gitignored) + airdrop
node fanout.mjs                          # real devnet run: 1 → 12 mules → 1, writes devnet_tx.csv
python ringer.py --devnet devnet_tx.csv  # Model B scores the devnet wallets → devnet_scores.csv
python ringer.py                         # Model A vs B, practice vs 5 fresh hidden exams → results.json
python ringer.py --demo-seed 42          # the same, with reproducible seeds (the numbers above)

Add --public to turn private mode off. Don't serve the repo root with python -m http.server, because wallets.json lives there. make dev serves the UI safely.

Config comes from .env (see .env.example, demo values only): EXAM_SERVER_URL, EXAM_DEMO_KEY, WORKSPACE_API_KEY, EXAM_RATE_LIMIT_PER_HOUR (product default 5; make dev raises it to 30 for demos), REDMULE_API_URL, REDMULE_API_KEY.

Use it from Claude Code

make dev
claude mcp add redmule -- node mcp-server/dist/index.js

Tools: generate_training_data · train_model · run_exam · get_insights · list_runs · scan_detector · map_schema

Then just ask:

"Run the RedMule hidden exam on starter-fanout-only" → "What's our weakest fraud pattern?" → "Generate training data focused on that exam and retrain as starter-v2" → "Run the exam again"

A real captured session is in demo-ui/mcp_session.json:

StepTool callReal result
1run_exam {"model_name": "starter-fanout-only"}score 23.8 · practice 99.9 · peel chains caught 0%
2get_insights {}"Weak on peel_chain (0% caught): generate targeted training data"
3generate_training_data {"focus_from_exam": 1, "n_scenarios": 60}5,889 wallets, weighted peel chain 0.91 / fan-out 0.09
4train_model {"model_name": "starter-mcp-v2", "base_model": "starter-fanout-only"}practice 99.8 on 23,686 rows
5run_exam {"model_name": "starter-mcp-v2"}score 92.8 · peel chains caught 100%
6scan_detector {"paths": ["ringer.py"]}flags is_fraud, scenario_id and demo_seed references, with line numbers
7map_schema {"mapping": {"sender_pubkey": "wallet"}}saved; an unknown field returns 400 with the valid list

run_exam never returns labels or per-wallet exam results. If the API is down, three tools fall back to the local ringer.py, and each result says which mode was used.

Test your own detector: redmule-mcp (TypeScript, packages/)

The setup above grades RedMule's own Model A/B. The packages/ workspace grades a team's own detector, whatever it is. It runs the hidden exam on a remote server and hands back training suited to how that detector works. Install it from npm (once published):

claude mcp add redmule -e REDMULE_API_KEY=<key> -- npx -y redmule-mcp   # exam server: https://redmule-exam.onrender.com

The team's coding agent does the integration. RedMule gives the agent a precise contract and lets it write the glue:

  1. connect_detector returns the detector contract, column docs, adapter templates (Python, Node, HTTP wrapper) and a labelled sample bundle.
  2. The agent writes a small adapter: <detector_cmd> --in <dir> --out <file> writes [{ "wallet", "score" }] from the team's real detector.
  3. validate_harness checks the adapter against the contract. It also profiles how the detector works (ml_tabular, ml_graph, rules, hybrid, external_vendor) and returns concrete fixes.
  4. exam runs a fresh hidden streaming exam: a fraud scenario only counts as caught if it is flagged before its cash-out. The report gives the RedMule Score, a coverage map per fraud type, plain-language findings ("you let through 78% of new-sender fraud") and a training plan. Its next_actions are steps the agent can carry out.

The training it hands back depends on the detection method:

MethodWhat RedMule hands back
ml_tabularLabelled features + labels weighted towards the missed fraud types (focus_from_exam), plus retrain steps
ml_graphThe same scenarios as an edge list with node labels
rulesA calibration set plus mined rule candidates with measured precision and recall
hybrid / unknownBoth
external_vendor, or every type ≥ 85% caughtNo training: a report for the vendor or a regression exam
PackageWhat it does
packages/generatorSeeded generator: 7 fraud patterns (fan-out/fan-in, multi-layer, peel chain, round trip, new sender, address poisoning, post-drain dispersal), 7 honest look-alikes, modifiers, private mode, company schema conversion, mainnet lock
packages/scoringScenario-level, value-weighted RedMule Score, streaming "caught before cash-out", remediation by detection method, rule mining
packages/harnessContract, adapter templates, detector profiling, validate_harness (HTTP harness is a placeholder)
packages/exam-serverExpress exam server: server-only seeds and ranges, chunked streaming with look-ahead lock, 3 attempts/hour, single-use exams, aggregate-only reports, cheat scanner, /schema/* conversion
packages/mcp-server10 tools: connect_detector, validate_harness, configure_schema, generate_training_data, practice_eval, exam, get_insights, scan_detector, visualise, run_model_demo
pnpm install && pnpm test     # 31 tests, incl. the mainnet lock and an end-to-end exam loop
pnpm exam-server              # TS exam server on :8787 (the Python one above uses :8001)
pnpm build                    # bundles packages/mcp-server/dist/index.js

Going live: see DEPLOY.md. Live site: https://redmule.euanb08.workers.dev. The guide covers the website on Cloudflare, the exam server on Render (one-click deploy) and redmule-mcp on npm plus the MCP registry (io.github.Rylie-KIM/redmule). mcp-server/ (top level) and redmule-mcp both register as redmule, so add only one.

API endpoints

Real requests and responses for each of these are in docs/API_PROOF.md.

Hidden exam server (:8001, X-API-Key)

MethodPathWhat it does
GET/healthLiveness, version, exams held in memory
POST/exam/start (?runs=1..5)Fresh secret-seed exam (or N sub-exams): transactions and features with opaque ids. No labels, no pattern names.
POST/exam/{id}/submitTakes [{wallet, score}] and an optional threshold. Returns an aggregate report: score (mean/min/max for multi-run), escape, false alarms, coverage, time to detect, hints. Single use: a reused exam gets 410, an expired one 410.
POST/scanCheat scanner over the detector source: synthetic wallet ids, label references, demo seeds, magic amounts, devnet addresses (file + line)

Exam starts are limited to 5 per hour per key; over the limit returns 429 with retry_after.

Workspace API (:8000, X-API-Key; demo workspace "Keane Payments")

MethodPathWhat it does
GET/api/healthAPI status and whether the exam server is reachable
POST/api/train/generateTraining data; optional patterns (incl. structuring) or focus_from_exam (run id). Returns dataset id, rows, wallets, fraud share.
GET/api/datasets, /api/export/{id}.csvDatasets; CSV download using your schema-mapped column names
POST/api/models/trainTrain XGBoost from dataset_ids and/or a base_model. Returns model_id, practice score, feature weights, leak warnings.
GET/api/modelsSaved models with ids
POST/api/exam/runmodel_id or model_name, optional runs. Gets an exam from the exam server, predicts locally and submits scores only; the run is stored.
GET/api/runs, /api/runs/{id}Run history; one full report
GET/api/coverage/latest, /api/insights/latestLatest coverage; hints and next focus weights
POST/GET/api/schema/mapMap your column names onto RedMule's training columns
GET/api/devnet/latestReal devnet transfers, scores, flags and explorer links
POST/api/devnet/scoreRe-score devnet transfers with a trained model. Never sends transactions.
GET/api/summaryresults.json (Model A vs B), plus live from the latest real run, for the landing page
K="X-API-Key: ws_demo_keane_payments"
curl -s -X POST localhost:8000/api/exam/run -H "$K" -H 'Content-Type: application/json' -d '{"model_name":"starter-fanout-only"}'
curl -s localhost:8000/api/insights/latest -H "$K"
curl -s -X POST localhost:8000/api/train/generate -H "$K" -H 'Content-Type: application/json' -d '{"focus_from_exam":1}'
curl -s -X POST localhost:8000/api/models/train -H "$K" -H 'Content-Type: application/json' -d '{"model_name":"starter-v2","base_model":"starter-fanout-only"}'

Demo

Auto mode (current UI): docs/media/redmule-auto-mode.mp4

Earlier 2-minute video with voice-over (shows the previous UI): docs/media/redmule-demo.mp4

The narration in the demo video is voiced with ElevenLabs. The product itself has no voice feature. An in-app voice is on the roadmap in docs/VISION.md.

What is mocked or not built yet

We'd rather you hear this from us:

  • The exam server runs on localhost in the demo. It's a separate process holding seeds and labels in memory, but on one laptop that only hides them from the workspace code, not from someone with shell access. In production it is a remote host.
  • The CLI path (ringer.py) examines locally. That's the offline, reproducible --demo-seed mode. The API path uses the exam server.
  • Auth is demo auth. One seeded workspace ("Keane Payments", a fictional demo team) and static keys. There are no user accounts.
  • The cheat scanner is regex pattern-matching, not an LLM review.
  • The threshold on submit is applied by rescaling scores so the scorer's fixed 0.5 cut-off flags exactly the wallets at or above your threshold. The precision-recall curve and histograms still use the raw scores.
  • Docker was validated with docker compose config and a full build-and-run on spare ports (9000/9001). The demo video runs on make dev, not in containers.
  • Schema mapping covers the exported training CSV's columns, not raw transaction ingestion in a company's own format.
  • Only the 12-mule pattern ran on-chain (devnet). All training and exam data is synthetic and built in memory.
  • pay.mjs / guard.mjs are a separate invoice-payment experiment. Its risk scorer is a keyword placeholder, not the trained model.
  • packages/ (TypeScript): the HTTP harness can't call a hosted scoring endpoint yet, and LiteSVM execution is a TODO (datasets are marked executed: false). The Render free plan sleeps when idle and keeps exam state in memory.
  • Roadmap:
    • streaming exams released chunk by chunk, and more fraud types (new-sender, address poisoning, post-drain dispersal), in the Python path; packages/ already has them
    • LiteSVM execution
    • a GitHub "RedMule Verified" check
    • a public leaderboard

Safety

  • Devnet and test SOL only. fanout.mjs checks the genesis hash and refuses to run on mainnet.
  • Mule and collector keys exist in memory for one run and are never written to disk. The source key lives in wallets.json, which is gitignored.
  • All training and exam data is synthetic. Attack patterns follow public FATF typologies only.

Team

  • Hein Htet Phyo: ML (generator, features, Model A/B, hidden exam, scoring), the Solana devnet run, product direction and integration
  • Seoyeon Kim
  • Euan
  • Melissa

AI disclosure. Built with AI coding agents, directed by a human at every step:

  • Devin wrote the backend (the redmule/ core, hidden exam server, workspace API, MCP server, tests, Docker and scripts), using parallel sub-agents, and handled git.
  • Claude Code built the demo UI and this README.
  • The demo video's voice-over was made with ElevenLabs.

Before the hackathon only the build spec existed (now docs/VISION.md). All code was written on the day.

Built with FastAPI · uvicorn · pydantic · httpx · pytest · SQLite · xgboost · pandas · numpy · @modelcontextprotocol/sdk · @solana/web3.js · Three.js · Chart.js · ElevenLabs (video narration)

RedMule · the fraud exam your AI can't cram for

NPM
redmule-mcp
Install Command
npm install redmule-mcp