Architecture Overview
QuestHive is an Electronic Communication Network (ECN) for trading Multi-Purpose Vouchers (MPVs) representing standardized labor units. The system uses a deterministic, single-threaded sequencer with sub-microsecond matching latency, shared-memory IPC, and hardware-aligned memory topologies.
Crate Reference
qh-core
Core types, repr(C) 64-byte aligned structures, newtypes for financial quantities
Source (auth required)qh-matching
Radix-paged order book, O(1) lookup, arena allocator, stop-loss/take-profit
Source (auth required)qh-risk
Pre-trade risk: collateral verification, position limits, margin tracking
Source (auth required)qh-compliance
Jurisdiction routing, surveillance, SI monitoring, sanctions screening
Source (auth required)qh-wallet
Custodial wallet key management, HD key derivation, encrypted storage
Source (auth required)Service Reference
gateway
REST + WebSocket API: 60+ endpoints, JWT/API-key auth, rate limiting
matching-engine
Core sequencer: radix-paged order book, CPU-pinned, SHM-backed
spooler
Transactional persistence: PostgreSQL binary COPY, WAL, batch writer
settlement-worker
On-chain settlement: ZK proofs, Solana batch processing, Merkle roots
Quality Metrics (v2.11.0)
| Metric | Value | Status |
|---|---|---|
| Workspace Tests | 3,100+ pass (0 failures) | PASS |
| Clippy Warnings | 0 (targeted deny groups) | PASS |
| Format Diffs | 0 | PASS |
| Lean 4 Proofs | 7 theorems verified | PASS |
| Fuzz Harnesses | 5 targets, all compile | PASS |
| unwrap() in Production | 0 (deny at entrypoints) | PASS |
| f64 in Finance | 0 (rust_decimal throughout) | PASS |
| Stub Implementations | 0 (qh-pqc uses real FIPS 204 ML-DSA-65) | PASS |
| FIX Conformance | 204 tests (FIX 4.4 / FIXT 1.1) | PASS |
| WASM Binary Size | 3.3 MB (wasm-opt -O4) | PASS |
| Critical CVEs | 0 | PASS |
| CI/CD Jobs | 16 (Forgejo Actions) | PASS |
Performance Targets
| Metric | Target | Validated |
|---|---|---|
| Internal Match Latency P99 | < 500ns | Yes |
| Tick-to-Trade Latency P99 | < 15us | Yes |
| Matching Throughput | > 1M matches/sec | 293K orders/sec baseline |
| Signature Verification | > 400K/sec | Yes |
| Persistence Throughput | > 50K IOPS | Yes |
| Recovery Time (RTO) | < 100ms | Yes |
Development
Prerequisites
# Nix flake (hermetic toolchain)
nix develop
# Or via cargo directly (requires Rust 1.70+, nightly for miri)
rustup default stable
Build and Test
# Build all crates
cargo build --workspace
# Run all tests (excludes WASM apps)
cargo test --workspace --exclude questhive-app --exclude terminal
# Lint
cargo clippy --workspace --exclude questhive --exclude app --exclude load-tests -- -D clippy::all -D clippy::unwrap_in_result -D clippy::todo -D clippy::dbg_macro
cargo fmt --all -- --check
# Full CI locally
make ci
Pre-Commit Hook
The pre-commit hook runs automatically on git commit. It enforces: format check, workspace compilation, clippy (-D warnings), core crate unit tests, Lean 4 proof verification (optional), cargo-deny (optional), cargo-audit (optional), emoji detection in staged .md files, and fuzz build check (optional). Bypass with git commit --no-verify.
Pre-Push Hook
The pre-push hook runs the full test suite before git push. It mirrors CI: format, clippy, full workspace tests, cargo-deny, cargo-audit. Bypass with git push --no-verify.
Compliance
| Standard | Status |
|---|---|
| FCA MTF Framework | Documentation complete, Innovation Hub pending |
| MiFID II | Gap analysis complete |
| SOC 2 | Preparation docs complete |
| GDPR / UK GDPR | Privacy policy deployed |
| AML / OFAC Sanctions | Screening integrated |
| FIPS 140-2 (ML-DSA-65) | Post-quantum module ready |
Protocol Specification
The canonical protocol specification is QUESTHIVE_PROTOCOL_SPEC.md in the repository root (authentication required). Key parameters:
| Parameter | Value |
|---|---|
| UMF Frame Size | 128 bytes (64-byte header + 64-byte payload) |
| InboundOrder Size | 64 bytes (cache-line aligned) |
| Order Arena | 640 MB (10M orders x 64 bytes) |
| Price Points | 2^20 per instrument (radix-paged) |
| Transport | R-UDP with SRPT scheduling |
Deployed Services
| Service | URL | Status |
|---|---|---|
| Landing Page | questhive.org | Live |
| Privacy Policy | questhive.org/privacy.html | Live |
| Terms of Service | questhive.org/terms.html | Live |
| Mobile App | app.questhive.org | Live |
| Terminal App | terminal.questhive.org | Live |
| Gateway API | api.questhive.org | Staging: 192.168.1.3:3010 (production pending) |