f2335b3e50aecda46e2120d162fd15bd0a5746e8
Replace the proposed static `include_str!` regression guard for the fold-boundary IQN target hard-sync (issue #84, root-cause fix in commit `7c19b5903`) with a real GPU runtime test that exercises the contract end-to-end. The static guard only caught literal deletion of the call line — a stub body returning `Ok(())`, a copy against the wrong buffer, the wrong copy direction, or a queue against the wrong stream all pass the textual assertion silently. Test (`cuda_pipeline::gpu_iqn_head::tests::iqn_sync_target_from_online_makes_target_equal_online`): 1. Construct a `GpuIqnHead` with default `GpuIqnConfig` on the default CUDA stream. 2. Fill `online_params` ← 0.42 and `target_params` ← 0.99 via a single mapped-pinned staging buffer + `cuMemcpyDtoDAsync`. No HtoD copy is issued; the host write through `MappedF32Buffer::host_ptr` reaches the GPU through the device-mapped alias and the DtoD copies the staged values into each parameter buffer. The witnesses 0.42 / 0.99 are arbitrary distinct fp32 constants — the contract asserted is buffer equality, independent of magnitude. 3. Sanity: read both buffers back via fresh mapped-pinned destinations + DtoD, assert they differ pointwise. 4. Call `iqn.sync_target_from_online()`. 5. `stream.synchronize()` so the queued DtoD has retired. 6. Read both buffers back and assert bit-for-bit equality across all `total_params` slots using `f32::to_bits` (so any future NaN-bearing implementation also fails loud). Per `feedback_no_htod_htoh_only_mapped_pinned.md`, all CPU↔GPU communication routes through `cuMemHostAlloc(DEVICEMAP|PORTABLE)` mapped pinned memory. Tests are not exempt — fills and read-backs both use `MappedF32Buffer` + `cuMemcpyDtoDAsync`. Buffer access exposed via four new `#[cfg(test)] pub(crate)` accessors on `GpuIqnHead` (`online_params_slice`, `target_params_slice`, `total_params_for_test`, `stream_for_test`) so the public API is not widened. Test carries `#[ignore = "gpu"]` matching the smoke-test convention already used in `regression_detection.rs`. `cargo test -p ml --lib` on a CPU-only host (the worktree environment) skips it cleanly; the L40S smoke validation pool runs it via `--ignored`. Paired with a strengthened doc-block at the call site in `fused_training.rs::reset_for_fold` (boxed `DO NOT DELETE` warning + reference to the new test name and issue #84) so anyone touching the line sees the regression context inline before deleting. Touched: `gpu_iqn_head.rs` (4 cfg(test) accessors + tests mod with helpers + the runtime test, +217 LOC), `fused_training.rs` (boxed comment + test reference, +16 LOC, no behaviour change), `docs/dqn-wire-up-audit.md` (audit entry replacing the static-test entry from the previous proposal, +33 LOC). Verified: * `cargo check -p ml --lib` — clean at 13 warnings (workspace baseline). * `cargo test -p ml --lib --no-run` — clean at 24 warnings (test profile baseline). * `cargo test -p ml --lib state_reset_registry` — 3/3 existing tests pass (no 4th static-source test added). * `cargo test -p ml --lib gpu_iqn_head` — 1 test discovered, correctly reports `ignored, gpu` on this CPU-only worktree. Local run not attempted — worktree environment lacks a GPU. The test runs as part of L40S smoke validation via `--ignored`. No fingerprint change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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%