jgrusewski f11bab542a test(ml-alpha): refresh test fixtures to match current kernel semantics
Updates 13 test files that were locked to stale kernel contracts.
Each change verified against the actual kernel/code (cuda/*.cu and
crates/ml-alpha/src/*) — not normalised to broken behavior:

Controller bootstrap values (isv_bootstrap.rs,
r5_controllers_and_soft_update.rs):
  * γ → 0.995 — `rl_gamma_controller.cu` GAMMA_MIN raised per
    `pearl_edge_lives_at_wave_timescale_not_tick` (long-horizon credit
    assignment on surfer-philosophy timescale)
  * entropy_coef → 0.5 — `rl_entropy_coef_controller.cu` COEF_MAX
    bootstrap at deficit=1.0 per
    `pearl_pi_actor_collapses_without_entropy_floor` (cold-start
    emergency exploration)
  * per_α → 0.4 — R9 derive-from-input pattern at kurt_excess=0
  * τ structurally pinned at TAU_BOOTSTRAP=0.005 — TAU_MAX (slot 573)
    equals bootstrap, controller has zero headroom upward (intentional
    per slot doc-comment)

Topology / horizon consolidation (bucket_transition_kernels.rs,
cfc_step_per_branch.rs, heads_block_diagonal.rs, heads_bit_equiv.rs,
bce_grad_finite_diff.rs):
  * N_HORIZONS: 5 → 3 (tercile layout: cut points [43, 86], dims
    [43, 43, 42]) — kernel-side `bucket_transition_kernels.cu` /
    `bce_loss_multi_horizon.cu` / `heads.rs` were consolidated
  * MAX_BUCKET_DIM: 28 → 96 (kernel #define MAX_BUCKET_DIM = 96)
  * Per-test asserts mirror tercile assignment via shared
    `tercile_bucket(c)` helper

Done-gating semantics (r3_ema_advantage.rs):
  * `compute_advantage_return.cu` line 30: `advantages[b] = done *
    (ret - vt)` — V learns from trade closes only, π trained via
    target-Q distillation + SAC entropy. Test now two-cohorts
    (done=1 sees -k, done=0 sees 0)

Anti-collapse mechanisms (r4_action_kernels.rs):
  * Thompson kernel applies ISV-driven epsilon-greedy floor (slot 588
    = 0.05) per `pearl_pi_actor_collapses_without_entropy_floor`.
    Wins/100 expectation widened to (1 − 0.05) × 100 ± 3σ ≈ ≥88

Confidence gate (trade_management_kernels.rs):
  * `rl_confidence_gate.cu` does NOT check `lots != 0 → skip` — the
    position-conditional escape was moved to the Phase 2.3 state-
    mandatory action mask (separate kernel). Case 3 now asserts gate
    fires regardless of position

Smoothness controller (smoothness_lambda_controller_invariants.rs):
  * TARGET_K_RATIO[2] = 0.1 (sqrt-scaling fix) — kernel comment at
    `smoothness_lambda_controller.cu:38-45` explains the migration
    from geometric to sqrt anchoring

PER buffer migration (r7d_per_wiring.rs):
  * CPU `trainer.replay` field replaced by GPU-resident
    `trainer.gpu_replay.replay_len_d` (graph-safe push). Test reads
    the counter via the canonical mapped-pinned pattern
    (`MappedI32Buffer` + `memcpy_dtod_async` + sync) per
    `feedback_no_htod_htoh_only_mapped_pinned`. Asserts mechanism
    invariants (monotone growth, bounded by MAX_INJECTS_PER_STEP,
    saturates at capacity) — looser than the old "len == step"
    because HER + n-step push counts vary per step

EMA-input sentinel-zero loops (isv_bootstrap.rs,
r5_controllers_and_soft_update.rs):
  * Switched from a sprawling negative exception list ("any slot in
    [417, RL_SLOTS_END) except these N constants") to a positive
    enumeration of the ~7 documented EMA-input slots. New ISV
    constants no longer break the test by being added to the slot
    range

Stale fixture (perception_forward_golden.bin):
  * Old golden was captured with probs.len() = 160; current model
    produces 96. Regenerated. Test logic captures-on-first-run +
    compares-on-subsequent-runs is unchanged

Latent kernel bug surfaced (bucket_transition_kernels.rs::
h_mag_per_bucket_kernel_computes_mean_abs_per_bucket):
  * `h_mag_per_bucket_kernel` launches with block_dim=32 but
    BUCKET_DIMS=[43, 43, 42] — only the first 32 channels contribute
    to the sum while the divisor uses the full bdim. Production
    launch site `perception.rs::h_mag_cfg` uses the same block_dim,
    so Controller D's dead-bucket signal is silently under-counted.
    Test asserts the IDEAL behavior (full-bucket mean) and DELIBERATELY
    FAILS until the kernel is fixed — per
    `pearl_tests_must_prove_not_lock_observations`
2026-05-29 00:22:18 +02:00

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
No description provided
Readme 849 MiB
Languages
Rust 88.2%
Cuda 7.7%
Python 1.3%
Shell 1.1%
PLpgSQL 0.8%
Other 0.8%