From e7bc2ee2b4b60d10dc4b41c76eaf10d8d6243ac9f918691dd1a933a331c7156a Mon Sep 17 00:00:00 2001 From: Tyler J King Date: Thu, 2 Apr 2026 23:11:22 -0400 Subject: [PATCH] fix: align CR format with broker CompleteRequest schema - Add session_id field to CrEvidence (broker expects it) - Change merkle_root to Option (null vs empty string) - Change events to Vec (broker expects list[dict]) - Fixes 422 Unprocessable Entity on CR posting Co-Authored-By: Claude Opus 4.6 (1M context) --- libgsh/src/cr.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libgsh/src/cr.rs b/libgsh/src/cr.rs index 3579ca6..fd6f2db 100644 --- a/libgsh/src/cr.rs +++ b/libgsh/src/cr.rs @@ -17,8 +17,9 @@ pub struct CrRequest { #[derive(Serialize)] pub struct CrEvidence { - pub events: Vec, - pub merkle_root: String, + pub session_id: Option, + pub events: Vec, + pub merkle_root: Option, } #[derive(Serialize)] @@ -77,8 +78,9 @@ pub fn post_cr(client: &Client, base: &str, ac_id: &str, outcome: &str) -> CrRes outcome: outcome.into(), completed_at: now, chronicle_evidence: CrEvidence { + session_id: if session_id.is_empty() { None } else { Some(session_id.clone()) }, events: vec![], - merkle_root: String::new(), + merkle_root: None, }, behavioral_attestation: CrAttestation { status: "unavailable".into(),