feat(runner, cli, research): metric/tap schema carriers + the C29 coverage walk
C29 compile/unit seam, tasks 6-10 -- iteration 1 of the self-description plan complete: every engine-shipped vocabulary entry now carries a gate-clean one-line meaning. - aura-runner: the internal tap recording sink threads its doc (the last unthreaded NodeSchema site) -- first full workspace build since the field became required. - aura-cli scaffold: the sample node's template carries a doc line plus a maintenance comment, so every scaffolded extension crate starts gate-clean; both extension-vocabulary fixture exemplars thread real meaning lines (the load seam walks these in iteration 2). New E2E: the scaffold's own doc must pass its own gate -- an alibi doc in the template would teach the wrong pattern to every new project, and the compiler checks only the field's presence, never its shape. - aura-research: metric_vocabulary()/tap_vocabulary() promote from bare name arrays to MetricSchema/TapSchema carriers (id + doc, 17 + 4 authored lines); callers adapt to .id with byte-identical output (introspection goldens unchanged). The #190 guard keeps its triple -- the doc column adds no fourth roster site. - Coverage: tests/self_description.rs walks all five vocabularies (blocks, metrics, taps, folds, std nodes) through doc_gate -- the guard that keeps any future edit from blanking a doc. Adjudicated review residue: the 17 metric doc strings are surfaced by no CLI path yet -- deliberate; task 8 pins callers byte-identical, the surfacing belongs to the CLI self-description work (#315). Plan-cited coordinates lib.rs:1003/:1283 resolved to the real caller sites (:1019/:1299); the plan's literal test code was reconciled to the real accessors (FoldRegistry::core().roster(), Env::std()). Gates: cargo test --workspace green (0 failed, incl. the new coverage walk + scaffold E2E); cargo clippy --workspace --all-targets -- -D warnings clean. refs #316
This commit is contained in:
@@ -727,6 +727,14 @@ pub fn content_id_of(canonical: &str) -> String {
|
||||
// Intrinsic validation (store-free).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// A shipped metric with its one-line meaning (C29). One carrier — the
|
||||
/// #190 guard keeps this list, the RMetrics serde fields, and the CLI
|
||||
/// count in lockstep; the doc column adds no fourth roster site.
|
||||
pub struct MetricSchema {
|
||||
pub id: &'static str,
|
||||
pub doc: &'static str,
|
||||
}
|
||||
|
||||
/// The closed declared-metric vocabulary: the scalar field names of the
|
||||
/// shipped metrics/selection types (RMetrics + RunMetrics scalars, plus the
|
||||
/// FamilySelection annotation scores). Single source for gate/stage checks
|
||||
@@ -746,25 +754,25 @@ pub fn content_id_of(canonical: &str) -> String {
|
||||
/// hand when the upstream field sets change (this list stays a hand-copy by
|
||||
/// the crate's ratified core-only isolation; #147 single-sourced the rankable
|
||||
/// roster elsewhere and the extended #190 guard pins this list's nesting).
|
||||
pub fn metric_vocabulary() -> &'static [&'static str] {
|
||||
pub fn metric_vocabulary() -> &'static [MetricSchema] {
|
||||
&[
|
||||
"expectancy_r",
|
||||
"win_rate",
|
||||
"avg_win_r",
|
||||
"avg_loss_r",
|
||||
"profit_factor",
|
||||
"max_r_drawdown",
|
||||
"sqn",
|
||||
"sqn_normalized",
|
||||
"net_expectancy_r",
|
||||
"n_trades",
|
||||
"n_open_at_end",
|
||||
"total_pips",
|
||||
"max_drawdown",
|
||||
"bias_sign_flips",
|
||||
"deflated_score",
|
||||
"overfit_probability",
|
||||
"neighbourhood_score",
|
||||
MetricSchema { id: "expectancy_r", doc: "mean realized R per closed trade — the headline E[R]" },
|
||||
MetricSchema { id: "win_rate", doc: "fraction of closed trades with positive realized R" },
|
||||
MetricSchema { id: "avg_win_r", doc: "mean realized R over winning trades" },
|
||||
MetricSchema { id: "avg_loss_r", doc: "mean realized R over losing trades" },
|
||||
MetricSchema { id: "profit_factor", doc: "gross winning R divided by absolute gross losing R" },
|
||||
MetricSchema { id: "max_r_drawdown", doc: "deepest peak-to-trough decline of the cumulative R curve" },
|
||||
MetricSchema { id: "sqn", doc: "System Quality Number: mean R over its std deviation, scaled by trade count" },
|
||||
MetricSchema { id: "sqn_normalized", doc: "SQN normalized to a 100-trade basis for n-independent comparison" },
|
||||
MetricSchema { id: "net_expectancy_r", doc: "expectancy net of the cost model's per-trade cost in R" },
|
||||
MetricSchema { id: "n_trades", doc: "count of closed trades in the run" },
|
||||
MetricSchema { id: "n_open_at_end", doc: "positions still open when the run ends" },
|
||||
MetricSchema { id: "total_pips", doc: "summed pip result over all closed trades" },
|
||||
MetricSchema { id: "max_drawdown", doc: "deepest peak-to-trough decline of the pip equity curve" },
|
||||
MetricSchema { id: "bias_sign_flips", doc: "count of sign changes in the strategy's bias stream" },
|
||||
MetricSchema { id: "deflated_score", doc: "selection score deflated for multiple testing against the bootstrap null" },
|
||||
MetricSchema { id: "overfit_probability", doc: "probability the selected edge is overfit, from the bootstrap null" },
|
||||
MetricSchema { id: "neighbourhood_score", doc: "plateau robustness: score aggregated over the param-space neighbourhood" },
|
||||
]
|
||||
}
|
||||
|
||||
@@ -773,12 +781,23 @@ pub fn emit_vocabulary() -> &'static [&'static str] {
|
||||
&["family_table", "selection_report"]
|
||||
}
|
||||
|
||||
/// A closed-vocabulary persisted-tap slot with its one-line meaning (C29).
|
||||
pub struct TapSchema {
|
||||
pub id: &'static str,
|
||||
pub doc: &'static str,
|
||||
}
|
||||
|
||||
/// The wrap convention's persisted sink names — the closed tap vocabulary
|
||||
/// (#201 decision 1). A genuinely new observable becomes a new entry or an
|
||||
/// authored sink in the strategy blueprint (C22: the choice of sinks is part
|
||||
/// of the experiment) — never an open node-path namespace in the document.
|
||||
pub fn tap_vocabulary() -> &'static [&'static str] {
|
||||
&["equity", "exposure", "r_equity", "net_r_equity"]
|
||||
pub fn tap_vocabulary() -> &'static [TapSchema] {
|
||||
&[
|
||||
TapSchema { id: "equity", doc: "cumulative pip equity per cycle" },
|
||||
TapSchema { id: "exposure", doc: "signed position exposure per cycle" },
|
||||
TapSchema { id: "r_equity", doc: "cumulative gross R per cycle" },
|
||||
TapSchema { id: "net_r_equity", doc: "cumulative net R per cycle, after the cost model" },
|
||||
]
|
||||
}
|
||||
|
||||
/// The closed archive-column vocabulary a campaign `data.bindings` VALUE may
|
||||
@@ -824,7 +843,7 @@ pub enum DocFault {
|
||||
}
|
||||
|
||||
fn is_known_metric(name: &str) -> bool {
|
||||
metric_vocabulary().contains(&name)
|
||||
metric_vocabulary().iter().any(|m| m.id == name)
|
||||
}
|
||||
|
||||
/// Intrinsic validation of a process document (P1 constraints included).
|
||||
@@ -1000,7 +1019,7 @@ pub fn validate_campaign(doc: &CampaignDoc) -> Vec<DocFault> {
|
||||
}
|
||||
}
|
||||
for (i, t) in doc.presentation.persist_taps.iter().enumerate() {
|
||||
if !tap_vocabulary().contains(&t.as_str()) {
|
||||
if !tap_vocabulary().iter().any(|k| k.id == t.as_str()) {
|
||||
faults.push(DocFault::UnknownTap { index: i, tap: t.clone() });
|
||||
}
|
||||
}
|
||||
@@ -1280,7 +1299,7 @@ pub fn open_slots_campaign(text: &str) -> Result<Vec<OpenSlot>, DocError> {
|
||||
"presentation",
|
||||
format!(
|
||||
"required section: persist_taps ({}) + emit",
|
||||
tap_vocabulary().join(" | ")
|
||||
tap_vocabulary().iter().map(|t| t.id).collect::<Vec<_>>().join(" | ")
|
||||
),
|
||||
));
|
||||
}
|
||||
@@ -2072,7 +2091,8 @@ mod tests {
|
||||
/// never an open node-path namespace in the document.
|
||||
#[test]
|
||||
fn tap_vocabulary_is_the_wrap_conventions_four_sink_names() {
|
||||
assert_eq!(tap_vocabulary(), ["equity", "exposure", "r_equity", "net_r_equity"]);
|
||||
let ids: Vec<&str> = tap_vocabulary().iter().map(|t| t.id).collect();
|
||||
assert_eq!(ids, ["equity", "exposure", "r_equity", "net_r_equity"]);
|
||||
}
|
||||
|
||||
/// Each `presentation.persist_taps` entry outside `tap_vocabulary()` is an
|
||||
@@ -2092,7 +2112,7 @@ mod tests {
|
||||
);
|
||||
// every in-vocabulary name passes
|
||||
let mut all = ok.clone();
|
||||
all.presentation.persist_taps = tap_vocabulary().iter().map(|t| t.to_string()).collect();
|
||||
all.presentation.persist_taps = tap_vocabulary().iter().map(|t| t.id.to_string()).collect();
|
||||
assert_eq!(validate_campaign(&all), Vec::new());
|
||||
}
|
||||
|
||||
@@ -2157,7 +2177,10 @@ mod tests {
|
||||
assert_eq!(slot.kind, SlotKind::TapKinds);
|
||||
assert_eq!(
|
||||
slot_kind_label(slot.kind),
|
||||
format!("list of: {}", tap_vocabulary().join(" | "))
|
||||
format!(
|
||||
"list of: {}",
|
||||
tap_vocabulary().iter().map(|t| t.id).collect::<Vec<_>>().join(" | ")
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
slot_kind_label(slot.kind),
|
||||
@@ -2188,7 +2211,7 @@ mod tests {
|
||||
pres.hint,
|
||||
format!(
|
||||
"required section: persist_taps ({}) + emit",
|
||||
tap_vocabulary().join(" | ")
|
||||
tap_vocabulary().iter().map(|t| t.id).collect::<Vec<_>>().join(" | ")
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user