| 1597 | } |
| 1598 | |
| 1599 | fn loggable_evidence( |
| 1600 | mut fields: serde_json::Map<String, serde_json::Value>, |
| 1601 | ) -> serde_json::Map<String, serde_json::Value> { |
| 1602 | for repeated in ["interpretation", "version", "worktree_root"] { |
| 1603 | fields.remove(repeated); |
| 1604 | } |
| 1605 | if fields.remove("capture_token").is_some() { |
| 1606 | fields.insert("capture_token_present".into(), true.into()); |
| 1607 | } |
| 1608 | let long_lists: Vec<(String, usize)> = fields |
| 1609 | .iter() |
| 1610 | .filter_map(|(name, value)| value.as_array().map(|items| (name.clone(), items.len()))) |
| 1611 | .filter(|(_, len)| *len > LOGGED_EVIDENCE_ITEMS) |
| 1612 | .collect(); |
| 1613 | for (name, len) in long_lists { |
| 1614 | if let Some(serde_json::Value::Array(items)) = fields.get_mut(&name) { |
| 1615 | items.truncate(LOGGED_EVIDENCE_ITEMS); |
| 1616 | } |
| 1617 | fields.insert(format!("{name}_total"), len.into()); |
| 1618 | } |
| 1619 | fields |
| 1620 | } |
| 1621 | |
| 1622 | fn write_immutable_json<T: Serialize>(path: &Path, value: &T) -> CliResult<()> { |
| 1623 | let mut bytes = serde_json::to_vec(value) |