a56ab7859d
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
59 lines
2.4 KiB
Rust
59 lines
2.4 KiB
Rust
//! C28 structural fitness: the node crates obey the ladder import direction.
|
|
//! The compiler only rejects import cycles; an acyclic-but-outward dependency
|
|
//! (e.g. `aura-std` -> `aura-market`) would compile silently. This test reads
|
|
//! each node crate's `[dependencies]` table and asserts its intra-workspace edges
|
|
//! stay within the inner set C28 permits for that layer. `[dev-dependencies]` are
|
|
//! C28-exempt (tests may cross layers) and are deliberately not inspected.
|
|
|
|
use std::path::PathBuf;
|
|
|
|
fn workspace_root() -> PathBuf {
|
|
// aura-vocabulary/ + /../.. = workspace root (the repo idiom for reaching it).
|
|
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("..").join("..")
|
|
}
|
|
|
|
/// The `aura-*` keys under `[dependencies]` (NOT `[dev-dependencies]`) of a crate.
|
|
fn prod_intra_workspace_deps(crate_name: &str) -> Vec<String> {
|
|
let manifest = workspace_root()
|
|
.join("crates")
|
|
.join(crate_name)
|
|
.join("Cargo.toml");
|
|
let text = std::fs::read_to_string(&manifest)
|
|
.unwrap_or_else(|e| panic!("read {}: {e}", manifest.display()));
|
|
let doc: toml::Value = toml::from_str(&text).expect("Cargo.toml parses as TOML");
|
|
match doc.get("dependencies").and_then(|d| d.as_table()) {
|
|
Some(deps) => deps
|
|
.keys()
|
|
.filter(|k| k.starts_with("aura-"))
|
|
.cloned()
|
|
.collect(),
|
|
None => Vec::new(),
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn node_crates_obey_the_c28_import_direction() {
|
|
// (crate, the intra-workspace [dependencies] C28 permits for its layer)
|
|
let allowed: &[(&str, &[&str])] = &[
|
|
("aura-analysis", &[]), // foundation: no aura-* deps
|
|
("aura-std", &["aura-core"]),
|
|
("aura-market", &["aura-core"]),
|
|
("aura-strategy", &["aura-core"]),
|
|
("aura-engine", &["aura-core", "aura-analysis"]),
|
|
("aura-backtest", &["aura-core", "aura-engine"]),
|
|
(
|
|
"aura-vocabulary",
|
|
&["aura-core", "aura-std", "aura-market", "aura-strategy", "aura-backtest"],
|
|
),
|
|
];
|
|
for (crate_name, permitted) in allowed {
|
|
for dep in prod_intra_workspace_deps(crate_name) {
|
|
assert!(
|
|
permitted.contains(&dep.as_str()),
|
|
"C28 import-direction violation: `{crate_name}` [dependencies] on `{dep}`, \
|
|
outside its permitted inner set {permitted:?}"
|
|
);
|
|
}
|
|
}
|
|
}
|