refactor: split the aura-std roster into C28 layer crates
Phase 4 of the Stratification milestone. aura-std held four C28 ladder layers in one roster; this cuts them into layer-aligned, aura-core-only node crates so the import direction is enforced by the crate graph: - aura-std — engine nodes only (arithmetic/logic/rolling + sinks) - aura-market — session, resample - aura-strategy — bias, stops, sizer, cost-model machinery - aura-backtest — sim_broker, position_management - aura-vocabulary — the relocated closed std_vocabulary roster Node modules move verbatim (byte-identical renames); consumers are rewired by import path only. A new structural test (aura-vocabulary/tests/c28_layering.rs) asserts each node crate's [dependencies] stay within its C28-permitted inner set, catching the acyclic-but-outward violation the compiler misses. Behaviour byte-identical: full workspace suite green (1448 tests), no golden edited, clippy -D warnings clean. C28 Status block updated. closes #288
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
//! 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-std", &["aura-core"]), // engine
|
||||
("aura-market", &["aura-core"]), // market
|
||||
("aura-strategy", &["aura-core"]), // strategy
|
||||
("aura-backtest", &["aura-core"]), // backtest (may gain aura-strategy when it imports one)
|
||||
(
|
||||
"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:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user