refactor(ai_risk_analysis): migrate Chronicle emission to CloudEvents
Replace fake Forgejo push webhook for AI_RISK_ASSESSMENT with structured CloudEvents 1.0. Event now carries confidence_score, recommendation, test_results_analyzed, and diff_match as typed fields instead of a flat message string. Event rename: AI_RISK_ASSESSMENT -> GOV_AI_RISK_ASSESSMENT Signed-off-by: Tyler King <tking@guildhouse.dev>
This commit is contained in:
parent
8f2884d5fa
commit
fdaf39eff2
1 changed files with 17 additions and 14 deletions
|
|
@ -179,21 +179,24 @@ impl RiskAnalysis {
|
||||||
println!("--");
|
println!("--");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit AI_RISK_ASSESSMENT to Chronicle.
|
/// Emit GOV_AI_RISK_ASSESSMENT to Chronicle.
|
||||||
pub fn emit_chronicle(&self, agent_did: &str, playbook_name: &str, webhook: &str) {
|
pub fn emit_chronicle(&self, agent_did: &str, playbook_name: &str, webhook: &str) {
|
||||||
let body = serde_json::json!({
|
use crate::chronicle_client::ChronicleClient;
|
||||||
"pusher": {"login": agent_did},
|
|
||||||
"ref": "refs/ai/AI_RISK_ASSESSMENT",
|
|
||||||
"repository": {"full_name": "platform/ai-governance"},
|
|
||||||
"commits": [{"message": format!("AI_RISK_ASSESSMENT: {} {}%", playbook_name, self.confidence_score)}],
|
|
||||||
});
|
|
||||||
|
|
||||||
reqwest::blocking::Client::new()
|
let chronicle = ChronicleClient::from_legacy_webhook(webhook);
|
||||||
.post(webhook)
|
chronicle.emit(
|
||||||
.header("X-Forgejo-Event", "push")
|
"GOV_AI_RISK_ASSESSMENT",
|
||||||
.json(&body)
|
agent_did,
|
||||||
.timeout(std::time::Duration::from_secs(5))
|
&ChronicleClient::generate_id(),
|
||||||
.send()
|
serde_json::json!({
|
||||||
.ok();
|
"kind": "GOV_AI_RISK_ASSESSMENT",
|
||||||
|
"description": format!("{} {}% confidence", playbook_name, self.confidence_score),
|
||||||
|
"playbook": playbook_name,
|
||||||
|
"confidence_score": self.confidence_score,
|
||||||
|
"recommendation": self.recommendation,
|
||||||
|
"test_results_analyzed": self.test_results_analyzed,
|
||||||
|
"diff_match": self.diff_match,
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue