diff --git a/crates/aura-cli/tests/cli_run.rs b/crates/aura-cli/tests/cli_run.rs index e344ca5..ed92317 100644 --- a/crates/aura-cli/tests/cli_run.rs +++ b/crates/aura-cli/tests/cli_run.rs @@ -5222,3 +5222,59 @@ fn exit_codes_partition_usage_two_from_runtime_one() { "no data for a valid command is a runtime failure → 1; stderr: {}", String::from_utf8_lossy(&runtime.stderr)); } + +/// Characterization pin (byte-identity anchor for the mc R-bootstrap dissolution, +/// #210, the last verb). The current `aura mc --strategy r-sma --real` runs the +/// inline rolling walk-forward, pools the per-window OOS trade-R series, and +/// r-bootstraps E[R] (`mc_r_bootstrap_report`). The dissolution reroutes this +/// through the campaign `[std::sweep(argmax), std::walk_forward, std::monte_carlo]` +/// process, whose terminal monte_carlo stage does the identical +/// `StageBootstrap::PooledOos(r_bootstrap(...))` seeded from the campaign seed -- so +/// the campaign seed must carry the mc `--seed`. The wf winners are +/// deflation-seed-independent (argmax), so the pooled series, and thus the +/// bootstrap, is stable across that seed remap (the walkforward anchor already +/// proved winner seed-independence). The multi-point grid makes the per-window +/// winner selection non-degenerate. This pins the EXACT current bootstrap grade of +/// a fixed 2025 GER40 invocation; after the dissolution the same command must +/// reproduce these bytes (the acceptance gate). Gated on the GER40 archive; skips +/// cleanly on a data refusal. +#[test] +fn mc_r_bootstrap_real_e2e_pins_the_exact_current_grade() { + const FROM_MS: &str = "1735689600000"; + const TO_MS: &str = "1767225599000"; + let cwd = temp_cwd("mc-r-bootstrap-exact-grade"); + let out = std::process::Command::new(env!("CARGO_BIN_EXE_aura")) + .args([ + "mc", "--strategy", "r-sma", "--real", "GER40", + "--fast", "3,5", "--slow", "12,20", "--stop-length", "14", "--stop-k", "2.0", + "--block-len", "5", "--resamples", "1000", "--seed", "42", + "--from", FROM_MS, "--to", TO_MS, + ]) + .current_dir(&cwd) + .output() + .expect("spawn aura"); + if out.status.code() == Some(1) { + let stderr = String::from_utf8_lossy(&out.stderr); + assert!( + stderr.contains("no local data") || stderr.contains("no recorded geometry"), + "exit 1 must be a data refusal, got: {stderr}" + ); + eprintln!("skip: no local GER40 data"); + return; + } + assert_eq!(out.status.code(), Some(0), "exit: {:?}", out.status); + let stdout = String::from_utf8(out.stdout).expect("utf-8 stdout"); + let grade_line = stdout + .lines() + .find(|l| l.starts_with("{\"mc_r_bootstrap\":")) + .unwrap_or_else(|| panic!("the mc_r_bootstrap grade line: {stdout}")); + let v: serde_json::Value = serde_json::from_str(grade_line).expect("grade line parses as JSON"); + let mc = &v["mc_r_bootstrap"]; + assert_eq!(mc["block_len"].as_u64(), Some(5), "block_len: {grade_line}"); + assert_eq!(mc["n_resamples"].as_u64(), Some(1000), "n_resamples: {grade_line}"); + assert_eq!(mc["n_trades"].as_u64(), Some(20681), "pooled OOS trade count: {grade_line}"); + // EXACT bootstrap floats -- the byte-identity anchor the dissolution must preserve. + assert_eq!(mc["e_r"]["mean"].as_f64(), Some(-0.0025753095301594307), "E[R] mean: {grade_line}"); + assert_eq!(mc["e_r"]["p50"].as_f64(), Some(-0.0023049902245975227), "E[R] median: {grade_line}"); + assert_eq!(mc["prob_le_zero"].as_f64(), Some(0.558), "P(E[R] <= 0): {grade_line}"); +}