Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

fix(config): keep codename hash architecture-stable on 32-bit (#2667)

Worktrunk Botf0ffe77d18b8
diff --git a/src/config/expansion.rs b/src/config/expansion.rs
index 98287f054..4acd819a5 100644
--- a/src/config/expansion.rs
+++ b/src/config/expansion.rs
@@ -496,7 +496,11 @@ fn codename_index(input: &str, position: usize, salt: usize, pool: &str, len: us
let digest = hasher.finalize();
let mut bytes = [0_u8; 8];
bytes.copy_from_slice(&digest[..8]);
- (u64::from_le_bytes(bytes) as usize) % len
+ // Take the modulo in u64 before narrowing — `as usize` on a 32-bit
+ // build truncates the upper 32 bits and would pick a different word
+ // than 64-bit for the same branch, defeating the whole point of
+ // hashing through a fixed-width type above.
+ (u64::from_le_bytes(bytes) % len as u64) as usize
}
fn codename(input: &str, words: usize) -> String {