Files
foxhunt/crates/ml-backtesting
jgrusewski a4127935a8 feat(ml-backtesting): BacktestHarness orchestrator + Ring 1b parity (C8)
BacktestHarness::new(cfg, &dev, trunk) constructs a MultiHorizonLoader
(inference_only=true), captures the trunk's perception Graph A using
loader.peek_first() as the template, then allocates a LobSimCuda.
run() walks the chronological snapshot stream, calls apply_snapshot on
every event, and at decision-stride boundaries:
  trunk.update_input_buffers(raw)
  → trunk.perception_forward_captured() → (probs[N_HORIZONS], proj)
  → sim.broadcast_alpha(&probs)
  → sim.step_decision(ts, target_vol, ann_factor, max_lots)

Returns RunStats { events_processed, decisions_taken }. The harness
deliberately accepts an externally-built CfcTrunk (random-init in v1)
because a checkpoint format isn't pinned in ml-alpha yet; when one
lands, the binary CLI (C9) can switch from new_random to load_checkpoint.

trainer_parity.rs Ring 1b — two ignored tests:

  peek_first_byte_equal_across_modes
    Verifies the Mbp10RawInput produced by the loader path used by the
    backtest harness (inference_only=true) is BYTE-EQUAL to what the
    trainer's loader (inference_only=false) produces from the same
    source. Guards against any future refactor accidentally diverging
    the two paths (e.g. someone special-casing inference path to skip
    regime feature computation). All 50 f32 fields + scalars compared
    via .to_bits() equality.

  inference_iteration_matches_chronological_snapshots
    Verifies next_inference_input() yields monotone-ts snapshots with
    correct cur==prev semantics on the first read and prev_ts==prior_ts
    afterwards.

Both tests skip gracefully when FOXHUNT_TEST_DATA fixtures lack
populated sidecars (the placeholder-empty bins committed in the
test_data/ tree).

GPU-side inference parity (probs[N_HORIZONS] bit-equal across loader
modes) is deferred until ml-alpha pins a checkpoint format and we have
a small checkpoint fixture to gate it on FOXHUNT_TEST_CKPT.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 08:52:49 +02:00
..