0c8cb6ad5b9e07ddf8c073a68009f6daa15dbc48
Implements docs/superpowers/specs/2026-05-31-v9-defensive-eval-boundary-calibration.md.
Closes the [[pearl_adaptive_carryover_discipline]] gap: every adaptive
EMA must reset OR re-bootstrap at regime boundaries, never selectively
preserve train-acquired statistics.
Layer 1 — full EMA reset in `reset_session_state`:
- win_rate, avg_win/loss EMAs → neutral sentinels
- cumulative_dones → 0 (re-enter Kelly bootstrap)
- inventory_beta + inventory_variance EMAs → 0
- reward_clamp pos/neg max EMAs + clip_rate EMA → 0
- Kelly fraction → 1.0 (bootstrap)
Lifts Fix D's deliberate carryover (commit 7064c9269), which was
diagnosed in v8 fold-1 eval as the primary -$507k driver: agent
entered eval with train wr=0.34 EMA and took aggressively-sized
losing trades while EMA decayed to true eval wr=0.25.
Layer 2 — defensive warmup window:
- New `rl_eval_warmup_decay` CUDA kernel: single-thread single-block,
no atomics, mapped-pinned only. Runs after fused controllers each
step. Overrides 4 risk-sizing floors (Kelly safety_frac, IQN τ_min,
entropy_coef_min, PPO clip ε_min) with conservative defensive
values for the first 500 steps post-boundary, with linear decay
over the final 200 steps back to normal targets.
- 11 new ISV slots (685-695): remaining counter, configured
durations, defensive overrides (0.25/0.30/0.05/0.10), normal
targets (0.50/0.10/0.01/0.05).
- Sentinel counter = -1 at boot → kernel is no-op until reset arms it.
All boundary semantics live in ISV; no hardcoded constants in the
kernel. Build verified, all 13 risk-stack invariants + 5 controller
adaptive-floor tests + integrated-trainer smoke pass on RTX 3050.
Foxhunt
Production HFT trading system in Rust.
Architecture
The workspace contains 32 crates organized as follows:
Core Libraries (16)
| Crate | Purpose |
|---|---|
trading_engine |
Order processing, FIX 4.4, IB TWS, SIMD, RDTSC timing |
risk |
VaR, Kelly, circuit breakers, kill switches, compliance |
risk-data |
Risk data types and shared structures |
trading-data |
Trading data types |
ml |
DQN Rainbow, PPO, TFT, Mamba2, ensemble inference |
ml-data |
ML data types and feature definitions |
data |
Market data ingestion and storage |
backtesting |
Replay engine, strategy tester |
adaptive-strategy |
Ensemble execution, microstructure analysis |
common |
Shared types, resilience, error handling |
storage |
S3 and local model storage |
model_loader |
Model serialization and loading |
market-data |
Market data feed handlers |
database |
PostgreSQL access layer (SQLx) |
config |
Configuration management |
tli |
CLI commands and tooling |
Services (8)
| Service | Purpose |
|---|---|
backtesting_service |
gRPC backtesting service |
broker_gateway_service |
FIX routing, broker connectivity |
trading_service |
Core trading operations |
ml_training_service |
Model training orchestration |
data_acquisition_service |
Market data acquisition |
trading_agent_service |
Autonomous trading agents |
api_gateway |
gRPC API gateway with auth |
web-gateway |
Axum REST + WebSocket gateway |
Frontend
web-dashboard/ -- React 19 + TypeScript + Vite + TradingView charts.
Building
# Check compilation (no PostgreSQL required)
SQLX_OFFLINE=true cargo check --workspace
# Run tests for a specific crate
SQLX_OFFLINE=true cargo test -p <crate> --lib
# Clippy
SQLX_OFFLINE=true cargo clippy --workspace
ML Models
Four production model architectures on Candle v0.9.1 with CUDA:
- DQN Rainbow -- Deep Q-Network with prioritized replay, dueling heads, noisy nets
- PPO -- Proximal Policy Optimization with GAE and LSTM policies
- TFT -- Temporal Fusion Transformer for multi-horizon forecasting
- Mamba2 -- State space model for sequence prediction
Each model has a standalone trainer and a UnifiedTrainable adapter for the hyperopt pipeline.
Infrastructure
- Git: Gitea at
git.fxhnt.ai(Tailscale-only), Scaleway DEV1-S - Observability: OpenTelemetry OTLP (env
OTEL_EXPORTER_OTLP_ENDPOINT) - Database: PostgreSQL with SQLx offline mode for CI
License
Proprietary. All rights reserved.
Description
Languages
Rust
88.2%
Cuda
7.7%
Python
1.3%
Shell
1.1%
PLpgSQL
0.8%
Other
0.8%