From fdaf39eff20e983c608057662c3ba2068eca0d04ab1e14f451159d24a97abb5d Mon Sep 17 00:00:00 2001 From: Tyler J King Date: Sun, 12 Apr 2026 06:54:31 -0400 Subject: [PATCH] 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 --- org-ops-core/src/ai_risk_analysis.rs | 31 +++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/org-ops-core/src/ai_risk_analysis.rs b/org-ops-core/src/ai_risk_analysis.rs index 1c49fb4..425f5d3 100644 --- a/org-ops-core/src/ai_risk_analysis.rs +++ b/org-ops-core/src/ai_risk_analysis.rs @@ -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, + }), + ); } }