QuestHive Documentation

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-shm

Shared memory IPC: MPMC ring buffers, journaling, seqlock mirror

Source (auth required)

qh-protocol

QHFP transport: R-UDP, 128-byte UMF frames, SRPT scheduler

Source (auth required)

qh-risk

Pre-trade risk: collateral verification, position limits, margin tracking

Source (auth required)

qh-crypto

Ed25519 signatures, batch verification, ZK-STARK, HSM abstraction

Source (auth required)

qh-fix

FIX 4.4 protocol codec, session management, conformance tests

Source (auth required)

qh-algo

Algorithmic orders: TWAP, VWAP, Iceberg with slice tracking

Source (auth required)

qh-compliance

Jurisdiction routing, surveillance, SI monitoring, sanctions screening

Source (auth required)

qh-pqc

Post-quantum cryptography: ML-DSA-65 (CRYSTALS-Dilithium)

Source (auth required)

qh-wallet

Custodial wallet key management, HD key derivation, encrypted storage

Source (auth required)

qh-currency

Multi-currency support, FX rates, GBP/USD/EUR conversion

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)

MetricValueStatus
Workspace Tests3,100+ pass (0 failures)PASS
Clippy Warnings0 (targeted deny groups)PASS
Format Diffs0PASS
Lean 4 Proofs7 theorems verifiedPASS
Fuzz Harnesses5 targets, all compilePASS
unwrap() in Production0 (deny at entrypoints)PASS
f64 in Finance0 (rust_decimal throughout)PASS
Stub Implementations0 (qh-pqc uses real FIPS 204 ML-DSA-65)PASS
FIX Conformance204 tests (FIX 4.4 / FIXT 1.1)PASS
WASM Binary Size3.3 MB (wasm-opt -O4)PASS
Critical CVEs0PASS
CI/CD Jobs16 (Forgejo Actions)PASS

Performance Targets

MetricTargetValidated
Internal Match Latency P99< 500nsYes
Tick-to-Trade Latency P99< 15usYes
Matching Throughput> 1M matches/sec293K orders/sec baseline
Signature Verification> 400K/secYes
Persistence Throughput> 50K IOPSYes
Recovery Time (RTO)< 100msYes

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

StandardStatus
FCA MTF FrameworkDocumentation complete, Innovation Hub pending
MiFID IIGap analysis complete
SOC 2Preparation docs complete
GDPR / UK GDPRPrivacy policy deployed
AML / OFAC SanctionsScreening 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:

ParameterValue
UMF Frame Size128 bytes (64-byte header + 64-byte payload)
InboundOrder Size64 bytes (cache-line aligned)
Order Arena640 MB (10M orders x 64 bytes)
Price Points2^20 per instrument (radix-paged)
TransportR-UDP with SRPT scheduling

Deployed Services

ServiceURLStatus
Landing Pagequesthive.orgLive
Privacy Policyquesthive.org/privacy.htmlLive
Terms of Servicequesthive.org/terms.htmlLive
Mobile Appapp.questhive.orgLive
Terminal Appterminal.questhive.orgLive
Gateway APIapi.questhive.orgStaging: 192.168.1.3:3010 (production pending)