An agentic fraud investigator that thinks in graphs.
Built on TigerGraph for Hacker House Goa 2026 · Task 04
📺 3-minute demo · 🎬 Teaser · 🌐 Live read-only demo · 📝 Blog post · 📊 Held-out results
A transaction scores 0.05 — as safe as a risk model gets. GraphSleuth found a 28-card fraud ring hiding behind it anyway, invisible to the score and visible only by walking the graph: one rare device, shared by cards that had never touched before. That single case is the reason this project exists — a risk score is a reason to look, never a verdict.
GraphSleuth investigates a fraud alert (risk score, customer report, or analyst request), gathers evidence from a TigerGraph knowledge graph and GraphRAG over policy, typologies and past cases, assesses risk under uncertainty, opens and progresses a case, recommends next-best actions within policy and approval limits, executes the ones it's authorized to act on, and writes what it learned back to the graph as case memory.
The analyst console mid-investigation — HHG-014, live on TigerGraph Savanna. 12 tool calls streamed, SAR filed.
- Status
- Design principle
- System architecture
- Investigation sequence
- Graph schema
- What it does
- Scored against the judging criteria
- Layout
- Run the analyst UI
- Read-only demo (Railway)
- TigerGraph backend
- Graph algorithms
- Counterfactuals and uncertainty
- Decision gate
- Mock action execution
- Autonomous monitor
- LLM layer
- Quick start
- Known limitations
- Submission checklist
- Credits
Runs end to end on TigerGraph Savanna. The graph (590,742 transactions, 14,318 cards, 5,565 closed cases, ~2.3M
edges, counts verified against the source) is loaded, 17 GSQL queries are installed, and all 20 benchmark
cases run through them and are written back to the graph as FraudCase vertices. The TigerGraph answers are
identical to the local backend's (0 differences over 100 field groups). GraphRAG is live (policy/typology/regulatory
chunks retrieved via TigerVector over the TigerGraph MCP server, grounding evidence, the case summary and the SAR
narrative), agent calls route through the MCP server end to end (verified against 69 live tools), and the LLM layer
runs on real Groq + Gemini keys. Graph algorithms (connected-component ring discovery, HITS hub ranking, card-to-card
link paths), counterfactual explanations with an uncertainty read-out, and an explicit decision-gate checklist (case
gate, corroboration count, stop threshold) are wired into the investigator and the UI. The UI itself follows
TigerGraph's own brand system (orange/blue/yellow/red/teal tokens, IBM Plex typography, sharp edges, light theme by
default) across both the local console and the read-only demo.
84 tests pass (pytest tests -q, excluding the live-TigerGraph suite which needs TG_HOST). Held-out results:
docs/eval_results.md.
The LLM proposes; a deterministic policy engine disposes. Fraud probability comes from graph features and a
calibrated scorer; action names, approval routes (auto / L1 / L2), the case-vs-report gate, rule R1–R10 and the
stop rule are enforced in code (agent/policy.py), so policy is never hallucinated. Only auto-route actions ever
execute themselves — L1/L2 actions wait for a human.
flowchart TB
subgraph Trigger["Trigger"]
T1["risk_score"] & T2["customer_report"] & T3["analyst_request"]
end
subgraph Agent["agent/ — orchestrator.py + investigator.py"]
direction TB
LOOP["Budgeted tool loop<br/>8-12 calls per case"]
FEAT["features.py + oof.py<br/>two-stage scorer"]
POL["policy.py<br/>R1-R10, deterministic, 30 unit tests"]
MOCK["mock_actions.py<br/>executes auto routes"]
MEM["memory.py<br/>similar_cases()"]
LOOP --> FEAT --> POL
POL -->|auto| MOCK
POL -->|L1 / L2| HUMAN["human approval<br/>via the UI"]
LOOP <--> MEM
end
subgraph Backend["backend.py ⇄ tg_backend.py"]
GSQL["17 installed GSQL queries"]
ALGO["ring_component · device_hub_rank<br/>card_link (graph algorithms)"]
end
subgraph TG["TigerGraph Savanna"]
GRAPH[("Graph store<br/>2.3M edges")]
VEC[("TigerVector<br/>policy · typology · regulatory")]
MCP["TigerGraph MCP<br/>69 tools"]
end
LLM["llm.py<br/>Groq + Gemini, fact-guarded"]
RAG["graphrag.py<br/>retrieval + grounding"]
Trigger --> LOOP
LOOP --> GSQL --> GRAPH
LOOP --> ALGO --> GRAPH
LOOP --> RAG --> VEC
Backend -.GRAPHSLEUTH_TG_VIA=mcp.-> MCP --> GRAPH
POL --> LLM
RAG --> LLM
POL --> MEM --> GRAPH
OUT["Answer file<br/>case + SAR + next_best_actions"]
UI["api/main.py (FastAPI + SSE)<br/>ui/index.html"]
POL --> OUT --> UI
LOOP -.step stream.-> UI
sequenceDiagram
participant C as case_pack.csv
participant O as Orchestrator
participant I as Investigator
participant TG as TigerGraph
participant R as GraphRAG
participant L as LLM (Groq/Gemini)
participant P as Policy engine
participant M as Case memory
C->>O: trigger (risk_score | customer_report | analyst_request)
O->>I: investigate(trig)
loop 8-12 tool calls, streamed to the UI
I->>TG: get_transaction, card_profile, card_window, ...
TG-->>I: evidence rows
I->>TG: device_neighbors / ring_component (if a ring signal fires)
TG-->>I: connected cards, devices
end
I->>R: retrieve(query built from the case's own signals)
R->>TG: TigerVector search
TG-->>R: grounded policy / typology / regulatory chunks
R-->>I: context pack (cited in evidence)
I->>P: Assessment(p, exposure, signals...)
P-->>O: initial next-best-actions (before evidence)
O->>O: simulate_evidence() — per the task's own rules
P-->>O: final next-best-actions + what_changed
O->>L: polish(summary, SAR) — behind the fact guard
L-->>O: reworded text, or the template if facts don't survive
O->>TG: write FraudCase vertex (case memory)
O-->>C: Answer (case, sar, next_best_actions, stop_reason)
erDiagram
Customer ||--o{ Card : OWNS
Card ||--o{ Transaction : MADE
Transaction }o--|| DeviceProfile : FROM_DEVICE
Transaction }o--|| BillingRegion : BILLED_IN
Transaction }o--|| EmailDomain : PURCHASER_EMAIL
Transaction ||--o| Transaction : NEXT
ClosedCase }o--o{ Transaction : INVOLVES
ClosedCase }o--|| Card : ON_CARD
ClosedCase }o--o{ Card : CONNECTED_TO
Card ||--o{ FraudCase : HAS_CASE
FraudCase }o--o{ Transaction : CASE_TXN
FraudCase }o--|| DeviceProfile : CASE_DEVICE
FraudCase }o--o{ Card : CASE_CONNECTED
FraudCase }o--o{ ClosedCase : SIMILAR_TO
Transaction {
int tid PK
datetime ts
double amt
string prod
string channel
double p "calibrated fraud probability"
}
DeviceProfile {
string id PK
int n_cards
double new_frac
double proxy_frac
}
FraudCase {
string id PK
string verdict
double fraud_probability
string status
datetime created
}
14 vertex/edge type pairs, ~2.3M edges once loaded. FraudCase is the case-memory write target — every investigation
closes the loop by adding one, so the next alert's similar_cases() query can find it.
Mapped directly to the task brief's ten capability points:
| Capability | Where |
|---|---|
| Trigger from risk score, customer report, or analyst request | case_pack.csv → agent/orchestrator.py |
| Gather evidence from the graph, transaction history, device/identity signals, prior cases, and external policy docs | agent/investigator.py (tool loop), agent/graphrag.py |
| Identify patterns, classify fraud type, assess risk level | agent/features.py, agent/oof.py, agent/investigator.py::_classify_pattern |
| Create and progress a case; record decisions and actions | agent/schemas.py::Case, written to TigerGraph as a FraudCase vertex |
| Case memory: retrieve similar cases, use prior outcomes | agent/memory.py, similar_cases(), cited in similar_prior_cases |
| Controlled evidence-gathering (ask customer, step-up auth, ask analyst) | evidence_requests in the answer schema, simulated per the task's rules |
| Next-best-action, initial vs. final, with approval routing | agent/policy.py, next_best_actions.{initial,final} |
Operate within policy/permissions; only auto self-executes |
agent/policy.py (routes) + agent/mock_actions.py (execution) |
| Know when to stop | agent/policy.py::stop_reached, stop_reason in every answer |
| Explain reasoning, cite the rule | agent/explain.py, evidence[].ref, reasons cite R1–R10 |
stateDiagram-v2
[*] --> Investigating
Investigating --> Legitimate: p ≤ 0.35
Investigating --> Uncertain: 0.35 < p < 0.65
Investigating --> Fraud: p ≥ 0.65
Uncertain --> EvidenceRequested: a single weak signal (R1)
EvidenceRequested --> Fraud: customer denies (R2)
EvidenceRequested --> Legitimate: customer confirms (R3)
EvidenceRequested --> Uncertain: no reply within 24h (R4)
Fraud --> Stopped: p ≥ 0.85 AND ≥2 independent evidence items
Legitimate --> Stopped: p ≤ 0.15 AND ≥2 independent evidence items
Uncertain --> Escalated: exposure > $500 OR evidence conflicts (R8)
Stopped --> [*]
Escalated --> [*]
The verdict band (0.35 / 0.65) decides what the agent believes; the stop rule (0.85 / 0.15 with ≥2 independent
evidence items, §6 of the policy) decides when it's allowed to stop looking. They're deliberately separate —
a case can be confidently fraud at p=0.70 and still not be "stopped" if the evidence is thin, which is exactly
when R1 says verify before blocking.
| Criterion | Weight | What we point to |
|---|---|---|
| Investigation accuracy | 25% | 20/20 answer files schema-valid, every ID real; held-out verdict accuracy 0.91–0.93, median exposure error $0.00 (eval) |
| Next-best-action | 25% | Full auto/L1/L2 approval routing, initial-vs-final with what_changed, R1–R10 enforced in code, not prompted |
| Case summary & explainability | 10% | Every evidence item cites a graph query or document; every action cites its rule number; standalone SAR narrative; explicit decision-gate checklist (case gate, corroboration, stop threshold) |
| Agentic design & engineering | 15% | Budgeted tool loop, deterministic policy engine, case memory loop closed via FraudCase writes, mock action execution on approval |
| Innovation | 15% | Connected-component ring discovery + HITS hub ranking as graph-algorithm tools; counterfactual/uncertainty explanations; autonomous monitor beyond the 20 cases; R6 measured and scoped rather than over-claimed |
| Demo quality | 10% | 3-minute walkthrough with live TigerGraph screen recording, live read-only deployment |
| Path | Purpose |
|---|---|
data/ |
Local DuckDB feature store and the TigerGraph REST loaders |
graph/ |
GSQL schema and installed queries |
agent/ |
Orchestrator, tools, scorer, policy engine, memory, mock actions, decision gate, SAR writer, answer schema |
eval/ |
Dev-set replay on closed cases and answer validation |
api/, ui/ |
FastAPI + SSE backend and a single-file vanilla-JS investigator UI |
static_demo/ |
Frozen, credential-free snapshot of the 20 cases — what's actually deployed on Railway |
cases/ |
The 20 benchmark answer files (graded submission) |
cases_extra/ |
Cases found by the autonomous monitor, beyond the 20 — Innovation, not accuracy |
docs/ |
Blog post, data findings, architecture diagram, demo script, eval results |
demo-video/ |
The 3-minute submission demo, its Hyperframes source, live screen recordings |
brag-output-*/ |
The short launch-teaser video, its Hyperframes source, and share copy |
.venv/bin/python run_cases.py # writes cases/HHG-001..020.json (validated: python -m eval.validate_answers cases)
.venv/bin/python -m uvicorn api.main:app --port 8000 # then open http://localhost:8000Pick a case and press Investigate to watch each tool call stream in, then read the evidence, the initial vs final
actions with their approval routes (L1/L2 actions wait for a human: Approve / Reject — approving or an auto route
fires the action via the mock action layer below), the evidence graph, the transaction timeline and the suspicious
activity report.
The evidence graph on HHG-014: 27 connected cards around one rare, proxied device.
graphsleuth-production.up.railway.app serves static_demo/ — a
frozen, pre-computed snapshot of all 20 cases plus the autonomous monitor's finds. It is a separate,
credential-free deployment: no TigerGraph secret, no LLM API key, no live-run capability, because the UI has no
login and a public host with real credentials would be a real exposure. "Investigate" replays the actual recorded
tool-call log client-side; nothing is sent anywhere. Regenerate the snapshot with scripts/freeze_static.py (needs
live TigerGraph + LLM credentials once, locally) — see static_demo/README.md.
flowchart LR
subgraph Local["Local / your machine"]
SEC["Savanna secrets<br/>TG_HOST, TG_SECRET<br/>GROQ_API_KEY, GEMINI_API_KEY"]
FZ["scripts/freeze_static.py<br/>runs the real 20 cases once"]
SEC --> FZ
end
subgraph Rail["Railway — graphsleuth-production"]
SD["static_demo/<br/>python -m http.server<br/>ZERO env vars"]
end
FZ -->|"commits static_demo/data/*.json<br/>(no secrets, just results)"| SD
SD -->|HTTPS| U["Anyone with the link"]
style Local fill:#fff1de,stroke:#c67a1e
style Rail fill:#eafaf1,stroke:#1f8a4c
The credentials never leave your machine. What ships to the public host is the output of a real run, not the ability to trigger one — the exact opposite of the full agent, which needs the secrets to function and therefore never gets a public, login-free deployment.
The agent talks to the graph through one interface (agent/backend.py). GRAPHSLEUTH_BACKEND=tigergraph switches it to
agent/tg_backend.py, which calls the installed GSQL queries in graph/queries.gsql. connect() blocks and retries
(up to 150s) until the workspace actually answers a query before handing back the connection: Savanna auto-suspends
when idle (required by the rules) and the first request after that wakes it, which otherwise surfaces as a confusing
Bad-Gateway/HTML-in-JSON error on whatever call happened to go first — hit and fixed live during development. Setup on
a Savanna workspace (auto-suspend and auto-resume ON):
cp .env.example .env # TG_HOST + TG_SECRET (a Database Secret; no password needed)
python -m data.export_tg # load-ready CSVs in data/store/tg/
python - <<'PY' # local-schema graph, so it never touches other graphs in the workspace
from pyTigerGraph import TigerGraphConnection; import os
from dotenv import load_dotenv; load_dotenv()
c = TigerGraphConnection(host=os.environ["TG_HOST"], graphname="", gsqlSecret=os.environ["TG_SECRET"], tgCloud=True); c.getToken(os.environ["TG_SECRET"])
print(c.gsql(open("graph/schema.gsql").read()))
PY
python -m data.load_tg # REST loader, idempotent (~25 min for the full graph)
python graph/install_queries.py # creates and installs the 17 queries (~5 min)
GRAPHSLEUTH_BACKEND=tigergraph python run_cases.py && pytest tests/test_tg_live.pyThe TigerGraph MCP server (tigergraph-mcp) connects to the workspace over stdio (verified: 69 tools listed);
agent/mcp_conn.py is the adapter that routes the agent's GraphRAG retrieval through it end to end, verified live.
GRAPHSLEUTH_TG_VIA=mcp routes the whole backend through it instead of direct REST — MCPConnection implements
the same pyTigerGraph-shaped subset (runInstalledQuery, getVerticesById, upsertVertex, upsertEdge,
getEdges) that TigerGraphBackend and TigerGraphCaseMemory call, so nothing else changes. Verified live end to
end (read and write, tests/test_tg_live.py::test_mcp_backend_reproduces_local_answer).
ring_component (connected-component ring discovery: hops only through devices that are rare AND mostly-New AND
mostly-proxied, so an ordinary shared device never floods the traversal), device_hub_rank (HITS power iteration over
the card-device bipartite graph, surfacing the device at the centre of a ring, not just the one with the most cards) and
card_link (hop distance between two specific cards). The investigator calls ring_component whenever its existing
single-device ring heuristic fires, to check whether the ring reaches beyond that one device.
For a case that fired the ring/testing/structuring/customer-report/recurring adjustments, GET /api/cases/{id}/counterfactuals replays the same deterministic probability formula with one signal flipped off,
reporting whether that would cross a policy threshold — plus how far the case sits from the nearest one. Shown in the UI
under the fraud-probability gauge after each live investigation.
The stop rule, corroboration count and case-opening gate already live inside agent/policy.py — this module makes
them legible instead of leaving them implicit in stop_reason prose. GET /api/cases/{id}/decision_gate returns an
explicit pass/fail checklist (case gate, independent-evidence corroboration ≥2, belief-conflict check, stop
threshold) computed straight from the investigation's own Assessment: no new detection logic, no change to any
verdict or action, and the 20 graded answer files are byte-identical with or without it. Shown as a "Decision gate"
card in both the live UI and the read-only demo.
The task brief allows blocking a card, filing a report, or messaging a customer to be "simulated, stubbed, or
represented through mock APIs." auto-route actions execute immediately after a run against a mock system of
record (card network, CRM, fraud monitor, regulatory filing queue); an L1/L2 action fires the same way the
moment a human approves it in the UI. Each execution produces a deterministic, timestamped receipt (data/store/ actions_taken.json), surfaced in the UI as an "Actions executed" card — never in the graded answer files, which
follow the task's exact schema.
Sweeps the whole graph for alerts the 20 sampled benchmark cases never triggered on — every ring-like device
find_rings() finds (not just HHG-014's) and the highest bank-risk-score transactions that were never sampled — and
investigates them the same way run_cases.py does. Output goes to cases_extra/ and is never written back to the
graph, kept separate from the 20 graded answers. Counts toward Innovation, not accuracy, per the task brief.
agent/llm.py routes to Groq (openai/gpt-oss-120b, fast tool loop) and Gemini (gemini-3.6-flash, synthesis;
embeddings) through their OpenAI-compatible endpoints, with retry/backoff, key rotation, provider fallback, an
on-disk cache and token accounting. agent/explain.py lets the model reword the case summary and SAR narrative
behind a fact guard: every number, amount, date and ID must survive, otherwise the template text is kept, and a
failed rewrite gets one repair round naming the missing values. Measured with the real providers: 16 of 20 summaries
were reworded and accepted; the SAR rewrites were rejected (the models drop card ids), so SARs stay on the checked
template. Known limit: the guard checks facts, not meaning, so a model can still add a mild inference (e.g. turning
"risk scores stay low" into "chosen to keep risk scores low"). run_cases.py --no-llm reproduces the template-only
answers. Keys: GROQ_API_KEY / GEMINI_API_KEY in .env, comma-separated to rotate several. No custom agent
framework (LangChain / LangGraph / CrewAI) — a hand-built tool loop and a separate policy engine, per the task
brief's explicit allowance for a custom implementation.
Verified end to end from a fresh clone: data/store/ (the DuckDB file and every trained model) is git-ignored, so a
fresh clone has none of it — it all has to be rebuilt once, in this order (each step reads the previous one's
output; --final trains on every labelled month, the plain/--dev form holds out from 2016-10-01 for the honest
offline eval in docs/eval_results.md). Budget ~25-35 minutes, almost all of it the two scorer runs.
python3.11 -m venv .venv && .venv/bin/pip install -r requirements.txt
cp .env.example .env # add Gemini/Groq keys and Savanna details (only needed for the LLM/TigerGraph paths)
DATA_DIR=../dataset/HHGOA_IEEE .venv/bin/python data/load_local.py # tx/ident/closed_cases/case_pack/cards -> data/store/graphsleuth.duckdb
.venv/bin/python -m agent.features # behavioural features -> the `feat` table (~1 min)
.venv/bin/python -m agent.scorer --final # calibrated fraud scorer, all months (~4 min)
.venv/bin/python -m agent.scorer --dev # same, held out from Oct 2016 (~4 min)
.venv/bin/python -m agent.pattern --final # pattern classifier, all months
.venv/bin/python -m agent.pattern # same, held out (bare = dev)
.venv/bin/python -m agent.precompute # scores every transaction -> scores_final / scores_dev
.venv/bin/python -m agent.oof # out-of-fold first-stage scores -> scores_oof (~4 min)
.venv/bin/python -m agent.episode --final # stage-2 episode (context) model, all months
.venv/bin/python -m agent.episode # same, held out (bare = dev)
.venv/bin/python -m pytest tests -q # 84 pass; test_tg_live.py skips without TG_HOSTOnce built, python run_cases.py (local backend by default; GRAPHSLEUTH_BACKEND=tigergraph for the real thing) and
python -m uvicorn api.main:app --port 8000 both work without repeating the steps above. Known limitation: the
stage-2 episode model's negative-sampling query (agent/episode.py, DuckDB USING SAMPLE without a fixed seed) is
not bit-for-bit reproducible between retrains, so a from-scratch rebuild's probabilities move a few points from run
to run; a full fresh-clone rebuild still passes eval.validate_answers 20/20 and every test that doesn't need a
live TigerGraph connection.
The provided dataset is not included in this repository. Only the provided dataset is used; the public Kaggle IEEE-CIS files are never used.
Said plainly, because a defensible system says what it doesn't do:
- R6 (shared origin) covers device profiles only, not billing region or recipient email. Region sharing was
measured and dropped: billing regions in this dataset hold 90–580 active cards in a 7-day window, with 8–16 of
them always scoring ≥0.5 by the model's ordinary false-positive rate — no threshold separates a real ring from a
big city. Recipient email (
R_emaildomain) isn't in the graph schema at all; adding it means a live schema change and reload we chose not to risk this close to the deadline. See docs/BLOG.md. - The fact guard on LLM rewrites checks numbers/IDs, not meaning — a model can still turn an observation into a causal claim.
- Simulated customer/analyst replies follow the agent's own belief (per the task's own rules — no real replies are provided), so they can't independently validate the verdict.
- The dev-set holdout has no ground truth for the exam distribution; its numbers are a proxy, not a guarantee.
| Deliverable | Status |
|---|---|
| Working agent | ✅ |
| GitHub repository | ✅ (this repo, public) |
| 20 answer files, schema-valid, every ID real, written to the graph | ✅ cases/ |
| TigerGraph Savanna + GSQL + graph algorithms + MCP + GraphRAG | ✅ |
| Analyst UI | ✅ ui/index.html, deployed read-only on Railway |
| Optional: autonomous monitoring beyond the 20 cases | ✅ cases_extra/ |
| 3–5 minute demo video | ✅ demo-video/graphsleuth-demo.mp4 — 3:00, live TigerGraph screen recording |
| Technical blog post | ✅ docs/BLOG.md |
Social post tagging @TigerGraphDB |
⏳ pending — teaser + copy ready in brag-output-2026-09-23-005129/share-copy.txt |
Dataset: IEEE-CIS Fraud Detection (Vesta Corporation, via the IEEE Computational Intelligence Society), repackaged for Hacker House Goa 2026 by TigerGraph. Built for TigerGraph's Hacker House Goa 2026, Task 04. Licensed under MIT — the dataset itself is not covered and is not redistributed here.