refactor: cut the engine's backtest-metrics edge via RunReport<M>
C28 phase 2 (Stratification); realizes item 1 of the deferred #147. The engine's production surface no longer names a backtest-metric type: - RunReport becomes generic over its metric payload M; sweep/mc/walkforward/ blueprint thread the parameter (SweepPoint<M>, SweepFamily<M>, WindowRun<M>, WalkForwardResult<M>). RunManifest stays concrete and engine-owned (its selection: Option<FamilySelection> embeds the foundation-grade analysis type). - summarize and the MC assembly (McDraw/McFamily/McAggregate/RBootstrap/ r_bootstrap/monte_carlo) move to aura-backtest - McAggregate::from_draws reads RunMetrics fields by name, so generifying it is the phase-6 metric-vocabulary abstraction (#147 item 2), still deferred; wholesale relocation is the honest cut. The concrete instantiation lives in aura-backtest as `type RunReport = aura_engine::RunReport<RunMetrics>` + sibling aliases. - the statistics kernel (MetricStats/quantile/resample_block/SplitMix64) moves to the aura-analysis foundation; the engine re-imports it (inner->foundation, legal) and re-exports it so existing consumers stay source-compatible. Dependency inversion in one commit: aura-engine drops aura-backtest from [dependencies] (back to dev-deps for its SimBroker/RunMetrics test fixtures); aura-backtest gains aura-engine. Cycle-free for lib targets - the cycle closes only through the engine's dev-dep edge, the pattern aura-vocabulary already uses. aura-backtest reaches the kernel transitively through the engine re-export, so no aura-backtest -> aura-analysis edge exists (the C28 ladder permits backtest -> {core, engine} only). run_indexed / SplitMix64::next_f64 widened pub(crate) -> pub for cross-crate use. Consumers (registry/campaign/cli/composites/ingest/bench) rewired by import path only, no call-site logic changed. The c28_layering structural test extends to the full ladder: aura-analysis (no aura-* deps), aura-engine ⊆ {core, analysis}, aura-backtest ⊆ {core, engine}. Behaviour-preserving: 1448/0 tests, clippy -D warnings clean, serde shapes byte-identical (C18 - RunReport<M> keeps field order manifest,metrics; the CLI pre-serialized-splice contract unchanged), moved code traceable via git rename detection. Cycle-introduced broken intra-doc links fixed. closes #292
This commit is contained in:
@@ -10,6 +10,15 @@ publish.workspace = true
|
||||
# back (admitted under the amended C16 per-case policy, INDEX.md). RunReport
|
||||
# derives serde in aura-engine.
|
||||
aura-engine = { path = "../aura-engine" }
|
||||
# aura-backtest carries the trading instantiation of the metric-generic engine
|
||||
# (M = RunMetrics: RunReport/SweepFamily/SweepPoint/McFamily/RBootstrap/
|
||||
# WalkForwardResult aliases, RMetrics, r_metrics_from_rs) the registry indexes
|
||||
# and ranks (#291/#292, C28 phase 2 — process column, C28-legal).
|
||||
aura-backtest = { path = "../aura-backtest" }
|
||||
# aura-analysis is the foundation statistics kernel (MetricStats/resample_block/
|
||||
# SplitMix64) `null_best_of_k`'s trials-deflation reality-check reduces through
|
||||
# (#291).
|
||||
aura-analysis = { path = "../aura-analysis" }
|
||||
# the document stores' content-id primitive (put_process/put_campaign key on
|
||||
# aura_research::content_id_of, the same hash the doc types canonicalize to);
|
||||
# also PrimitiveBuilder, the referential tier's resolver signature.
|
||||
|
||||
@@ -10,9 +10,8 @@
|
||||
//! (`Registry::append`, `RunReport::to_json`) is untouched and still emits the
|
||||
//! tagged form, so this is a one-directional widening, not a format change.
|
||||
|
||||
use aura_engine::{
|
||||
FamilySelection, ProjectProvenance, RunManifest, RunMetrics, RunReport, Scalar, Timestamp,
|
||||
};
|
||||
use aura_backtest::{RunMetrics, RunReport};
|
||||
use aura_engine::{FamilySelection, ProjectProvenance, RunManifest, Scalar, Timestamp};
|
||||
use serde::de::{self, Deserializer};
|
||||
use serde::Deserialize;
|
||||
|
||||
|
||||
@@ -18,10 +18,11 @@ use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use aura_core::PrimitiveBuilder;
|
||||
use aura_analysis::{resample_block, MetricStats, SplitMix64};
|
||||
use aura_backtest::{r_metrics_from_rs, RunReport, SweepFamily, SweepPoint};
|
||||
use aura_engine::{
|
||||
blueprint_from_json, blueprint_identity_json, expected_max_of_normals, r_metrics_from_rs,
|
||||
resample_block, FamilySelection, MetricStats, RunReport, SelectionMode, SplitMix64,
|
||||
SweepFamily, SweepPoint,
|
||||
blueprint_from_json, blueprint_identity_json, expected_max_of_normals, FamilySelection,
|
||||
SelectionMode,
|
||||
};
|
||||
use aura_research::{CampaignDoc, DocRef};
|
||||
|
||||
@@ -528,7 +529,7 @@ fn resolve_metric(name: &str) -> Result<Metric, RegistryError> {
|
||||
/// block; a missing block reads `NEG_INFINITY` (the worst rank for the
|
||||
/// higher-is-better R keys), preserving `metric_cmp`'s documented contract.
|
||||
fn metric_value(rep: &RunReport, m: Metric) -> f64 {
|
||||
fn r_get(rep: &RunReport, f: impl Fn(&aura_engine::RMetrics) -> f64) -> f64 {
|
||||
fn r_get(rep: &RunReport, f: impl Fn(&aura_backtest::RMetrics) -> f64) -> f64 {
|
||||
rep.metrics.r.as_ref().map(f).unwrap_or(f64::NEG_INFINITY)
|
||||
}
|
||||
match m {
|
||||
@@ -943,8 +944,8 @@ impl From<std::io::Error> for RegistryError {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use aura_core::{Cell, Scalar, Timestamp};
|
||||
use aura_engine::RMetrics;
|
||||
use aura_engine::{RunManifest, RunMetrics, RunReport, SweepFamily, SweepPoint};
|
||||
use aura_backtest::{RMetrics, RunMetrics};
|
||||
use aura_engine::RunManifest;
|
||||
|
||||
fn report_with(total_pips: f64, max_drawdown: f64, flips: u64) -> RunReport {
|
||||
RunReport {
|
||||
@@ -1422,7 +1423,7 @@ mod tests {
|
||||
// `summarize_r`, which RETAINS it — and `optimize_deflated`'s R arm
|
||||
// resamples exactly that conduit, so a fixture without it cannot reach
|
||||
// the R-arm path under test.
|
||||
let mut r = aura_engine::r_metrics_from_rs(&net_trade_rs);
|
||||
let mut r = aura_backtest::r_metrics_from_rs(&net_trade_rs);
|
||||
r.net_trade_rs = net_trade_rs;
|
||||
SweepPoint {
|
||||
params: vec![],
|
||||
@@ -2530,7 +2531,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn campaign_run_record_roundtrips_with_annotator_fields() {
|
||||
use aura_engine::r_bootstrap;
|
||||
use aura_backtest::r_bootstrap;
|
||||
let path = temp_family_dir("campaign_run_annotator_roundtrip");
|
||||
let reg = Registry::open(&path);
|
||||
// r_bootstrap is pure given its seed (C1), and serde_json round-trips
|
||||
|
||||
@@ -19,9 +19,8 @@ use std::fs;
|
||||
use std::io::Write;
|
||||
|
||||
use aura_core::Scalar;
|
||||
use aura_engine::{
|
||||
FamilySelection, McFamily, RBootstrap, RunReport, SweepFamily, WalkForwardResult,
|
||||
};
|
||||
use aura_backtest::{McFamily, RBootstrap, RunReport, SweepFamily, WalkForwardResult};
|
||||
use aura_engine::FamilySelection;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{Generalization, Registry, RegistryError};
|
||||
|
||||
@@ -12,7 +12,8 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use aura_core::{Scalar, Timestamp};
|
||||
use aura_engine::{FamilySelection, RunManifest, RunMetrics, RunReport, SelectionMode};
|
||||
use aura_backtest::{RunMetrics, RunReport};
|
||||
use aura_engine::{FamilySelection, RunManifest, SelectionMode};
|
||||
use aura_registry::{
|
||||
CampaignRunRecord, CellRealization, FamilyKind, Registry, StageRealization, StageSelection,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user