From 5256b3d0ca59ec4c546d784031b46d87985fb3fc Mon Sep 17 00:00:00 2001 From: Brummel Date: Sat, 4 Jul 2026 15:12:40 +0200 Subject: [PATCH] refactor(registry): single-source the deflation-bootstrap constants (#199) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DEFLATION_N_RESAMPLES (1000) and DEFLATION_BLOCK_LEN (5) were duplicated as independent copies in aura-cli and aura-campaign — a silent-drift risk (an edit in one crate but not the other refuses nothing, it just produces a wrong deflation result). Promote a single definition into aura-registry, which owns optimize_deflated (the sole consumer of these counts); aura-cli imports it and aura-campaign re-exports it to keep its public path stable. DEFLATION_SEED stays cli-local (no campaign twin). Values unchanged; behaviour-preserving, suite green unchanged (1043/0). closes #199 --- crates/aura-campaign/src/lib.rs | 12 ++++++------ crates/aura-cli/src/main.rs | 10 +++++----- crates/aura-registry/src/lib.rs | 7 +++++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/crates/aura-campaign/src/lib.rs b/crates/aura-campaign/src/lib.rs index 9ea2c50..4de876e 100644 --- a/crates/aura-campaign/src/lib.rs +++ b/crates/aura-campaign/src/lib.rs @@ -116,12 +116,12 @@ pub const RANKABLE_METRICS: &[&str] = &[ "sqn", "sqn_normalized", "expectancy_r", "net_expectancy_r", ]; -/// Deflation resample count — the shipped CLI `select_winner` constant. -/// Duplicated against `aura-cli`'s private copy, tracked in #199. -pub const DEFLATION_N_RESAMPLES: usize = 1000; -/// Deflation moving-block length — the shipped CLI `select_winner` constant. -/// Duplicated against `aura-cli`'s private copy, tracked in #199. -pub const DEFLATION_BLOCK_LEN: usize = 5; +/// Deflation resample count — re-exported from `aura-registry`'s shared +/// definition (single-sourced, #199). +pub use aura_registry::DEFLATION_N_RESAMPLES; +/// Deflation moving-block length — re-exported from `aura-registry`'s shared +/// definition (single-sourced, #199). +pub use aura_registry::DEFLATION_BLOCK_LEN; /// Resolve one of the 14 [`PER_MEMBER_METRICS`] against a member's report. /// An R-metric name against `metrics.r == None` reads `None` (conservative diff --git a/crates/aura-cli/src/main.rs b/crates/aura-cli/src/main.rs index 2ba4fc7..68113eb 100644 --- a/crates/aura-cli/src/main.rs +++ b/crates/aura-cli/src/main.rs @@ -33,6 +33,7 @@ use aura_registry::{ check_r_metric, generalization, group_families, mc_member_reports, optimize_deflated, optimize_plateau, rank_by, sweep_member_reports, walkforward_member_reports, FamilyKind, FamilyMember, Generalization, NameKind, PlateauMode, Registry, RunTraces, WriteKind, + DEFLATION_BLOCK_LEN, DEFLATION_N_RESAMPLES, }; use aura_std::{ Add, Bias, CarryCost, ConstantCost, Delay, Ema, GatedRecorder, Gt, Latch, LinComb, LongOnly, Mul, @@ -65,11 +66,10 @@ const WF_REAL_IS_NS: i64 = 90 * WF_DAY_NS; const WF_REAL_OOS_NS: i64 = 30 * WF_DAY_NS; const WF_REAL_STEP_NS: i64 = 30 * WF_DAY_NS; -/// Trials-deflation resampling budget for walk-forward winner selection. Recorded -/// on each winner's manifest (so `overfit_probability` is reproducible by re-run); -/// CLI flags for these are a deferred refinement. -const DEFLATION_N_RESAMPLES: usize = 1000; -const DEFLATION_BLOCK_LEN: usize = 5; +/// Fixed RNG seed for the trials-deflation reality-check bootstrap in walk-forward +/// winner selection. Recorded on each winner's manifest (so `overfit_probability` +/// is reproducible by re-run); a CLI flag for it is a deferred refinement. The +/// resample count and block length are the shared `aura_registry::DEFLATION_*`. const DEFLATION_SEED: u64 = 0xDEF1_A7ED; /// The built-in synthetic price stream: rises through t=4 then reverses, so the diff --git a/crates/aura-registry/src/lib.rs b/crates/aura-registry/src/lib.rs index 5e77e3c..84f6a9f 100644 --- a/crates/aura-registry/src/lib.rs +++ b/crates/aura-registry/src/lib.rs @@ -595,6 +595,13 @@ pub fn optimize_plateau( )) } +/// Deflation-bootstrap default: the resample count of the null-distribution +/// bootstrap consumed by [`optimize_deflated`]. +pub const DEFLATION_N_RESAMPLES: usize = 1000; +/// Deflation-bootstrap default: the moving-block length of the null-distribution +/// bootstrap consumed by [`optimize_deflated`]. +pub const DEFLATION_BLOCK_LEN: usize = 5; + /// `optimize`'s argmax winner PLUS its trials-deflation provenance. The returned /// `SweepPoint` is byte-identical to `optimize(family, metric)` (additive, C23). /// R arm: a centred moving-block reality-check (`overfit_probability` =