Skip to content

Commit eb934af

Browse files
authored
Merge pull request anomalyco#888 from affaan-m/feat/ecc2-risk-scoring
feat(ecc2): add tool risk scoring and actions
2 parents 319f9ef + 8303970 commit eb934af

3 files changed

Lines changed: 282 additions & 26 deletions

File tree

‎ecc2/src/config/mod.rs‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ pub enum PaneLayout {
1111
Grid,
1212
}
1313

14+
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
15+
#[serde(default)]
16+
pub struct RiskThresholds {
17+
pub review: f64,
18+
pub confirm: f64,
19+
pub block: f64,
20+
}
21+
1422
#[derive(Debug, Clone, Serialize, Deserialize)]
1523
#[serde(default)]
1624
pub struct Config {
@@ -25,6 +33,7 @@ pub struct Config {
2533
pub token_budget: u64,
2634
pub theme: Theme,
2735
pub pane_layout: PaneLayout,
36+
pub risk_thresholds: RiskThresholds,
2837
}
2938

3039
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -48,11 +57,18 @@ impl Default for Config {
4857
token_budget: 500_000,
4958
theme: Theme::Dark,
5059
pane_layout: PaneLayout::Horizontal,
60+
risk_thresholds: Self::RISK_THRESHOLDS,
5161
}
5262
}
5363
}
5464

5565
impl Config {
66+
pub const RISK_THRESHOLDS: RiskThresholds = RiskThresholds {
67+
review: 0.35,
68+
confirm: 0.60,
69+
block: 0.85,
70+
};
71+
5672
pub fn load() -> Result<Self> {
5773
let config_path = dirs::home_dir()
5874
.unwrap_or_else(|| PathBuf::from("."))
@@ -69,6 +85,12 @@ impl Config {
6985
}
7086
}
7187

88+
impl Default for RiskThresholds {
89+
fn default() -> Self {
90+
Config::RISK_THRESHOLDS
91+
}
92+
}
93+
7294
#[cfg(test)]
7395
mod tests {
7496
use super::{Config, PaneLayout};
@@ -100,6 +122,7 @@ theme = "Dark"
100122
assert_eq!(config.cost_budget_usd, defaults.cost_budget_usd);
101123
assert_eq!(config.token_budget, defaults.token_budget);
102124
assert_eq!(config.pane_layout, defaults.pane_layout);
125+
assert_eq!(config.risk_thresholds, defaults.risk_thresholds);
103126
}
104127

105128
#[test]
@@ -113,4 +136,9 @@ theme = "Dark"
113136

114137
assert_eq!(config.pane_layout, PaneLayout::Grid);
115138
}
139+
140+
#[test]
141+
fn default_risk_thresholds_are_applied() {
142+
assert_eq!(Config::default().risk_thresholds, Config::RISK_THRESHOLDS);
143+
}
116144
}

0 commit comments

Comments
 (0)