bluewave-labs / verifywise

Open source AI governance platform
https://verifywise.ai
GNU Affero General Public License v3.0
9 stars 7 forks source link

Calculating risk level using inputs from likelihood and risk severity #160

Open gorkem-bwl opened 3 hours ago

gorkem-bwl commented 3 hours ago

We have those likelihood categories:

We have those severity categories:

For calculating the risk level, you can map each category to numeric values as shown below:

image

Here is a sample TS code:

// Define mappings for Likelihood and Severity categories using enums
enum Likelihood {
    Rare = 1,
    Unlikely = 2,
    Possible = 3,
    Likely = 4,
    AlmostCertain = 5
}

enum Severity {
    Negligible = 1,
    Minor = 2,
    Moderate = 3,
    Major = 4,
    Critical = 5
}

// Define thresholds for risk levels based on the calculated score
function getRiskLevel(score: number): string {
    if (score <= 3) {
        return "Low";
    } else if (score <= 6) {
        return "Medium";
    } else if (score <= 9) {
        return "High";
    } else {
        return "Critical";
    }
}

// Main function to calculate the risk level using word inputs
function calculateRiskLevel(likelihoodWord: keyof typeof Likelihood, severityWord: keyof typeof Severity): string {
    // Step 1: Map words to numeric values using enums
    const likelihood = Likelihood[likelihoodWord];
    const severity = Severity[severityWord];

    // Step 2: Multiply likelihood and severity scores
    const riskScore = likelihood * severity;

    // Step 3: Determine risk level
    const riskLevel = getRiskLevel(riskScore);

    // Step 4: Return the calculated risk level
    return riskLevel;
}

// Example usage:
const likelihoodWord: keyof typeof Likelihood = "Likely";  // Input for likelihood
const severityWord: keyof typeof Severity = "Moderate";    // Input for severity

console.log(calculateRiskLevel(likelihoodWord, severityWord)); // Outputs "High"

This calculation is valid both for Vendor risks and project risks.

Also CC'ing @HarshP4585 and @MuhammadKhalilzadeh in case there is a need to change backend code/mock data here.

gorkem-bwl commented 2 hours ago

We can use 34x high labels for this purpose. The link to Figma design is here. You may or may not want to define them as a component (eg if labels can take height props, we are good, otherwise a new component might be needed, or we can change the labels to get height props)

gorkem-bwl commented 2 hours ago

Two examples of the final look:

image image