solve-score 0.1.0

Independent implementation of SOLVE v0.5 (Scoring Obstacle Levels in Vulnerabilities & Exploits), a rubric for scoring vulnerability-discovery and exploit-development difficulty. Reproduces the 16 published calibration assessments. Not affiliated with or endorsed by Irregular.
Documentation
//! The `maxplus` soft-maximum that combines component totals.

/// Soft maximum over component scores.
///
/// A challenge is hard if any single stage is hard, so the result tracks the maximum; several
/// hard stages together add at most one further point. The specification states:
///
/// - `maxplus(m, 0, …, 0) == m`
/// - `maxplus(m, m, …, m) == m + 1`
/// - `maxplus(0, 0, …, 0) == 0`
/// - the result lies in `[m, m + 1]`
///
/// For `m = max(values)` and `s = sum(values)`, the definition is
/// `m + (s - m) / ((n - 1) · m)`.
///
/// The specification also claims monotonicity in each parameter. That claim is false for
/// `m < 1`: the partial derivative in the maximum parameter is `1 - (s - m) / ((n - 1) · m²)`,
/// which is negative whenever `s - m > (n - 1) · m²`, reachable only when `m < 1`. See the
/// crate-level documentation.
///
/// Returns `0.0` for an empty slice, and the single value for a one-element slice, where the
/// definition would divide by zero. SOLVE itself always passes exactly four values.
#[must_use]
pub fn maxplus(values: &[f64]) -> f64 {
    let Some(&first) = values.first() else {
        return 0.0;
    };
    let max = values.iter().copied().fold(first, f64::max);
    if max == 0.0 || values.len() < 2 {
        return max;
    }
    let sum: f64 = values.iter().sum();
    #[allow(clippy::cast_precision_loss)]
    let n = values.len() as f64;
    max + (sum - max) / ((n - 1.0) * max)
}

/// Rescales a `maxplus` result from `[0, 11]` onto the SOLVE range `[0, 10]`.
///
/// Multiplies before dividing so that a straight-10 assessment lands on exactly `10.0`;
/// scaling by a precomputed `10.0 / 11.0` overshoots.
pub(crate) fn rescale(value: f64) -> f64 {
    value * 10.0 / 11.0
}