Strip transcript and reasoning from a change for privacy. Replaces the unhashed turn data with a minimal stub that has `redacted: true`. The change hash is NOT affected. Returns `true` if data was stripped, `false` if there was nothing to strip.
(change: &mut atomic_core::change::Change)
| 182 | /// |
| 183 | /// Returns `true` if data was stripped, `false` if there was nothing to strip. |
| 184 | pub fn strip_unhashed(change: &mut atomic_core::change::Change) -> bool { |
| 185 | let Some(unhashed) = change.unhashed.as_mut() else { |
| 186 | return false; |
| 187 | }; |
| 188 | let Some(obj) = unhashed.as_object_mut() else { |
| 189 | return false; |
| 190 | }; |
| 191 | |
| 192 | if !obj.contains_key(UNHASHED_KEY) { |
| 193 | return false; |
| 194 | } |
| 195 | |
| 196 | // Extract just the session_id and turn_number for the stub |
| 197 | let stub = if let Some(existing) = obj.get(UNHASHED_KEY) { |
| 198 | let session_id = existing |
| 199 | .get("session_id") |
| 200 | .and_then(|v| v.as_str()) |
| 201 | .unwrap_or("") |
| 202 | .to_string(); |
| 203 | let turn_number = existing |
| 204 | .get("turn_number") |
| 205 | .and_then(|v| v.as_u64()) |
| 206 | .unwrap_or(0) as u32; |
| 207 | |
| 208 | serde_json::json!({ |
| 209 | "session_id": session_id, |
| 210 | "turn_number": turn_number, |
| 211 | "transcript_format": "redacted", |
| 212 | "condensed_transcript": [], |
| 213 | "condensed_text": "", |
| 214 | "prompts": [], |
| 215 | "tools_used": [], |
| 216 | "reasoning": null, |
| 217 | "redacted": true |
| 218 | }) |
| 219 | } else { |
| 220 | serde_json::json!({ "redacted": true }) |
| 221 | }; |
| 222 | |
| 223 | obj.insert(UNHASHED_KEY.to_string(), stub); |
| 224 | true |
| 225 | } |
| 226 | |
| 227 | /// Check if a change has unhashed agent turn data. |
| 228 | pub fn has_unhashed(change: &atomic_core::change::Change) -> bool { |