From d51850b31f6e5f34f5d15d460fc15bcd91b4917a Mon Sep 17 00:00:00 2001 From: lawrencecchen <54008264+lawrencecchen@users.noreply.github.com> Date: Tue, 3 Nov 2026 11:31:24 +0000 Subject: [PATCH] fix(acpmux): opaque agent id takes its hex prefix with get, not a string slice (panic-ratchet red since #33209) #33209 (85ba3b53299) added `&hex[..HEX_LEN]` in opaque_agent_id.rs. The panic ratchet denies clippy::string_slice, and acpmux went from 94 to 95 hits, so the feat tip panic-ratchet is red since 92bf57ad70c9. The hex is always 64 ASCII digits; `hex.get(..HEX_LEN)` returns the same 20 digits with no panic path. The module's existing tests check the id length and value. --- cmux-tui/crates/acpmux/src/opaque_agent_id.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmux-tui/crates/acpmux/src/opaque_agent_id.rs b/cmux-tui/crates/acpmux/src/opaque_agent_id.rs index 9334d00f3e7b..ccdc1967a056 100644 --- a/cmux-tui/crates/acpmux/src/opaque_agent_id.rs +++ b/cmux-tui/crates/acpmux/src/opaque_agent_id.rs @@ -79,7 +79,8 @@ impl Key { let msg = format!("{}\0{harness}\0{session}", host.to_ascii_lowercase()); let mac = cmux_local_auth::frontend_proof::hmac_sha256(&self.0, msg.as_bytes()); let hex = cmux_local_auth::frontend_proof::hex(&mac); - format!("{PREFIX}{}", &hex[..HEX_LEN]) + // `hex` is 64 ASCII digits, so the prefix always exists; `get` keeps the panic ratchet at zero. + format!("{PREFIX}{}", hex.get(..HEX_LEN).unwrap_or(&hex)) } }