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)
| 337 | /// assert_eq!(extract_session_short("ab"), "ab"); |
| 338 | /// ``` |
| 339 | pub fn extract_session_short(session_id: &str) -> String { |
| 340 | // Check for date prefix pattern: YYYY-MM-DD-<rest> |
| 341 | let id_part = if session_id.len() > 11 |
| 342 | && session_id.as_bytes()[4] == b'-' |
| 343 | && session_id.as_bytes()[7] == b'-' |
| 344 | && session_id.as_bytes()[10] == b'-' |
| 345 | { |
| 346 | // Skip the "YYYY-MM-DD-" prefix (11 chars) |
| 347 | &session_id[11..] |
| 348 | } else { |
| 349 | session_id |
| 350 | }; |
| 351 | |
| 352 | // Take the first 4 alphanumeric characters |
| 353 | let short: String = id_part |
| 354 | .chars() |
| 355 | .filter(|c| c.is_ascii_alphanumeric()) |
| 356 | .take(4) |
| 357 | .collect(); |
| 358 | |
| 359 | if short.is_empty() { |
| 360 | "0000".to_string() |
| 361 | } else { |
| 362 | short |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | /// Normalize the agent name for use in the `+tag`. |
| 367 | /// |
no test coverage detected