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!("--");
|
||||
}
|
||||
|
||||
/// 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) {
|
||||
let body = serde_json::json!({
|
||||
"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)}],
|
||||
});
|
||||
use crate::chronicle_client::ChronicleClient;
|
||||
|
||||
reqwest::blocking::Client::new()
|
||||
.post(webhook)
|
||||
.header("X-Forgejo-Event", "push")
|
||||
.json(&body)
|
||||
.timeout(std::time::Duration::from_secs(5))
|
||||
.send()
|
||||
.ok();
|
||||
let chronicle = ChronicleClient::from_legacy_webhook(webhook);
|
||||
chronicle.emit(
|
||||
"GOV_AI_RISK_ASSESSMENT",
|
||||
agent_did,
|
||||
&ChronicleClient::generate_id(),
|
||||
serde_json::json!({
|
||||
"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