Extract a short identifier from the session ID for the `+tag` suffix. Takes the first 4 hex characters from the session ID. If the session ID has a date prefix (e.g., `2026-01-15-abc123de-...`), skips the date part and uses the first 4 chars of the UUID portion. # Examples ```rust use atomic_agent::identity::extract_session_short; assert_eq!(extract_session_short("60f5cbd2-aa23-40ee-9085-4375d
(session_id: &str)
| 154 | /// assert_eq!(extract_session_short("ab"), "ab"); |
| 155 | /// ``` |
| 156 | pub fn extract_session_short(session_id: &str) -> String { |
| 157 | // Check for date prefix pattern: YYYY-MM-DD-<rest> |
| 158 | let id_part = if session_id.len() > 11 |
| 159 | && session_id.as_bytes()[4] == b'-' |
| 160 | && session_id.as_bytes()[7] == b'-' |
| 161 | && session_id.as_bytes()[10] == b'-' |
| 162 | { |
| 163 | // Skip the "YYYY-MM-DD-" prefix (11 chars) |
| 164 | &session_id[11..] |
| 165 | } else { |
| 166 | session_id |
| 167 | }; |
| 168 | |
| 169 | // Take the first 4 alphanumeric characters |
| 170 | let short: String = id_part |
| 171 | .chars() |
| 172 | .filter(|c| c.is_ascii_alphanumeric()) |
| 173 | .take(4) |
| 174 | .collect(); |
| 175 | |
| 176 | if short.is_empty() { |
| 177 | "0000".to_string() |
| 178 | } else { |
| 179 | short |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | /// Normalize the agent name for use in the `+tag`. |
| 184 | /// |
no test coverage detected