Skip to main content

active_weights

Function active_weights 

pub fn active_weights(opts: &Options) -> Result<Option<WeightsAndVintage>>
Expand description

Resolve the smell weights active for opts: Some((weights, vintage)) when a --defect-calibration artifact is configured and passes both the repo-identity guard and shape validation; None when no artifact is configured.

The returned weights are the artifact’s weights field verbatim — for a DefaultsKept artifact those ARE the defaults, so substituting them is inert by construction while the vintage stamp still records that the artifact was consulted.

Shape validation pins the weights to exactly the built-in smell names, in the built-in order, with finite non-negative values. Anything else is a corrupted or incompatible artifact — and rejecting it here is also what keeps interpolating the names into the code-health SQL injection-free.

§Errors

Propagates load failures, the check_repo_identity foreign-repo guard (see Options::allow_foreign_calibration), and shape-validation failures, all as hard errors: an explicitly configured artifact that cannot be applied is a configuration mistake, not a degradable state.