diag(rl): emit v9 eval_warmup state to JSONL + cleanup lints
Diag: surfaces `risk_stack.eval_warmup.{remaining,active,blend,
floor_*,target_*}` so the v9 defensive-warmup window is observable
in diag.jsonl. `remaining` is the counter; `blend` is the
defensive-vs-normal mix coefficient (1.0 = full defensive, 0.0 =
normal); `floor_*` reflect the LIVE override values (read AFTER the
warmup kernel ran). Pre-warmup the kernel is a no-op (remaining=-1),
so v9 train-phase diag is bit-identical to v8.
Cleanup: tightens unreachable_pub items in tests/behavioral/* and
tests/sp5_producer_unit_tests.rs (pub → pub(crate)), removes
unused_mut on 6 sp5 scratch buffers, renames unused `step` loop
counter in alpha_baseline example, and explicitly discards an
intentionally-no-op `Command::assert` in cli_integration_test.
Reduces lint count by ~25; remaining 3 dead_code warnings flag
SP15 Phase 2A behavioral scaffolding (Phase 2B never landed —
deliberate signal, not noise).
Pre-existing pearl per feedback_no_hiding: do NOT suppress these
with #[allow]; the warnings ARE the design call surface.
This commit is contained in:
@@ -907,7 +907,7 @@ fn main() -> Result<()> {
|
||||
.context("reset vol_obs min slot")?;
|
||||
}
|
||||
// Lockstep step loop.
|
||||
for step in 0..cli.horizon {
|
||||
for _ in 0..cli.horizon {
|
||||
// Gather current states (CPU; <100μs for N=500).
|
||||
let mut batched_states_host = vec![0.0_f32; n_par * STATE_DIM];
|
||||
for i in 0..n_par {
|
||||
|
||||
@@ -9,7 +9,7 @@ use ml::cuda_pipeline::lob_bar::LobBar;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct BehavioralResult {
|
||||
pub(crate) struct BehavioralResult {
|
||||
/// Action distribution keys: "hold", "flat", "long_quarter",
|
||||
/// "long_half", "long_full", "short_quarter", "short_half", "short_full".
|
||||
pub action_dist: HashMap<&'static str, f32>,
|
||||
@@ -27,7 +27,7 @@ pub struct BehavioralResult {
|
||||
/// each Phase 2B test rewrites the body to call the trainer methods it
|
||||
/// requires. The signature here is the load-bearing piece — keep it stable.
|
||||
#[allow(dead_code, unused_variables)]
|
||||
pub fn evaluate_policy_on_market(
|
||||
pub(crate) fn evaluate_policy_on_market(
|
||||
// Phase 2B swaps `&mut ()` for `&mut GpuDqnTrainer` once the per-test
|
||||
// trainer methods land. Until then the unit param keeps the signature
|
||||
// callable in tests that don't yet exercise the trainer path.
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
use ml::cuda_pipeline::lob_bar::LobBar;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum MagBucket { Quarter, Half, Full }
|
||||
pub(crate) enum MagBucket { Quarter, Half, Full }
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum OracleAction {
|
||||
pub(crate) enum OracleAction {
|
||||
Hold,
|
||||
Long(MagBucket),
|
||||
Short(MagBucket),
|
||||
@@ -16,12 +16,12 @@ pub enum OracleAction {
|
||||
}
|
||||
|
||||
/// Oracle for flat markets: always Hold.
|
||||
pub fn flat_market_oracle(bars: &[LobBar]) -> Vec<OracleAction> {
|
||||
pub(crate) fn flat_market_oracle(bars: &[LobBar]) -> Vec<OracleAction> {
|
||||
vec![OracleAction::Hold; bars.len()]
|
||||
}
|
||||
|
||||
/// Oracle for drift markets: take direction-of-trend, mag = Half.
|
||||
pub fn drift_market_oracle(bars: &[LobBar]) -> Vec<OracleAction> {
|
||||
pub(crate) fn drift_market_oracle(bars: &[LobBar]) -> Vec<OracleAction> {
|
||||
let mut actions = Vec::with_capacity(bars.len());
|
||||
actions.push(OracleAction::Hold); // first bar: no prior
|
||||
for w in bars.windows(2) {
|
||||
@@ -38,7 +38,7 @@ pub fn drift_market_oracle(bars: &[LobBar]) -> Vec<OracleAction> {
|
||||
}
|
||||
|
||||
/// Oracle for OU markets: reverse at ±2σ extremes.
|
||||
pub fn ou_market_oracle(bars: &[LobBar], mu: f32, sigma: f32) -> Vec<OracleAction> {
|
||||
pub(crate) fn ou_market_oracle(bars: &[LobBar], mu: f32, sigma: f32) -> Vec<OracleAction> {
|
||||
bars.iter().map(|b| {
|
||||
let z = (b.price - mu) / sigma.max(1e-6);
|
||||
if z > 2.0 { OracleAction::Short(MagBucket::Half) }
|
||||
|
||||
@@ -6,7 +6,7 @@ use rand::{Rng, SeedableRng};
|
||||
use rand::rngs::StdRng;
|
||||
|
||||
/// Flat market: constant base price + Gaussian noise.
|
||||
pub fn flat_market(n: usize, noise_sigma: f32, mean_spread: f32, seed: u64) -> Vec<LobBar> {
|
||||
pub(crate) fn flat_market(n: usize, noise_sigma: f32, mean_spread: f32, seed: u64) -> Vec<LobBar> {
|
||||
let mut rng = StdRng::seed_from_u64(seed);
|
||||
(0..n).map(|_| {
|
||||
let noise: f32 = rng.gen_range(-1.0..1.0) * noise_sigma;
|
||||
@@ -18,7 +18,7 @@ pub fn flat_market(n: usize, noise_sigma: f32, mean_spread: f32, seed: u64) -> V
|
||||
}
|
||||
|
||||
/// Drift market: drift μ + noise σ.
|
||||
pub fn drift_market(n: usize, mu: f32, sigma: f32, mean_spread: f32, seed: u64) -> Vec<LobBar> {
|
||||
pub(crate) fn drift_market(n: usize, mu: f32, sigma: f32, mean_spread: f32, seed: u64) -> Vec<LobBar> {
|
||||
let mut rng = StdRng::seed_from_u64(seed);
|
||||
let mut price: f32 = 4500.0;
|
||||
(0..n).map(|_| {
|
||||
@@ -31,7 +31,7 @@ pub fn drift_market(n: usize, mu: f32, sigma: f32, mean_spread: f32, seed: u64)
|
||||
}
|
||||
|
||||
/// OU process: mean-reverting around equilibrium.
|
||||
pub fn ou_market(n: usize, theta: f32, sigma_eq: f32, mu: f32,
|
||||
pub(crate) fn ou_market(n: usize, theta: f32, sigma_eq: f32, mu: f32,
|
||||
mean_spread: f32, seed: u64) -> Vec<LobBar> {
|
||||
let mut rng = StdRng::seed_from_u64(seed);
|
||||
let mut price: f32 = mu;
|
||||
@@ -45,7 +45,7 @@ pub fn ou_market(n: usize, theta: f32, sigma_eq: f32, mu: f32,
|
||||
}
|
||||
|
||||
/// Regime-switch: Markov chain over `n_regimes`, each with (mu, sigma).
|
||||
pub fn regime_switch_market(
|
||||
pub(crate) fn regime_switch_market(
|
||||
n: usize,
|
||||
regime_params: &[(f32, f32)],
|
||||
transition_matrix: &[Vec<f32>],
|
||||
|
||||
@@ -1980,7 +1980,7 @@ fn pearl_1_ext_num_atoms_threshold_cascade() {
|
||||
|
||||
let scratch_size: usize = 4;
|
||||
let base: i32 = 0;
|
||||
let mut scratch = unsafe { MappedF32Buffer::new(scratch_size) }.expect("scratch alloc");
|
||||
let scratch = unsafe { MappedF32Buffer::new(scratch_size) }.expect("scratch alloc");
|
||||
|
||||
let isv_dev = isv_buf.dev_ptr;
|
||||
let scr_dev = scratch.dev_ptr;
|
||||
@@ -2048,7 +2048,7 @@ fn pearl_1_ext_num_atoms_exact_threshold_falls_to_next_branch() {
|
||||
|
||||
let scratch_size: usize = 4;
|
||||
let base: i32 = 0;
|
||||
let mut scratch = unsafe { MappedF32Buffer::new(scratch_size) }.expect("scratch alloc");
|
||||
let scratch = unsafe { MappedF32Buffer::new(scratch_size) }.expect("scratch alloc");
|
||||
|
||||
let isv_dev = isv_buf.dev_ptr;
|
||||
let scr_dev = scratch.dev_ptr;
|
||||
|
||||
Reference in New Issue
Block a user