plan_corrections

Function plan_corrections 

Source
pub fn plan_corrections(
    correction: AngularCorrection,
    optic: &OpticProfile,
    range_m: f64,
    elevation_cf: f64,
    windage_cf: f64,
    prefs: &Preferences,
) -> Result<DialPlanReportV1, OpticError>
Expand description

Turns a TRUE angular AngularCorrection into ranked, executable dial/hold/hybrid plans for a real optic (MBA-1348) – see the module’s “plan_corrections and the CF rule” and “Honesty” doc sections for the conventions this function follows in every arm.

Returns exactly three plans, one per Strategy, in DialPlanReportV1::plans, ranked best-first: feasible: true plans always sort before feasible: false ones (MBA-1348 review fix I4 – HoldAll/Hybrid carry a residual of exactly 0.0 even when infeasible, so residual alone cannot be the primary key without risking an unexecutable plans[0]); among equally-feasible plans, ascending DialPlan::residual_linear_at_range_m (via f64::total_cmp, so ranking never panics regardless of input); ties are broken by prefs.prefer_hold (false ranks DialAll < Hybrid < HoldAll, true reverses that), and any remaining tie by Strategy’s own declaration order (DialAll, HoldAll, Hybrid) – see ranking_is_deterministic_and_preference_respected and infeasible_plans_never_outrank_a_feasible_one.

Err(OpticError) when optic.validate() fails; when correction, range_m, or prefs.max_hold_mil is not finite; when range_m / max_hold_mil is negative; or when elevation_cf / windage_cf is zero, negative, or non-finite (OpticError::NonPositiveTrackingFactor, MBA-1348 review fix I5 – the CF rule divides by it, so a non-positive value is not merely implausible, it is a hard arithmetic failure). Otherwise elevation_cf/windage_cf are trusted exactly as given, like crate::truing::scale_report_dial_values – this function does not re-apply crate::adjustment::tracking_cf_in_range’s tighter (0.5, 1.5) plausibility band; enforcing that band (if at all) remains a caller/CLI concern, matching that existing precedent.