-
Notifications
You must be signed in to change notification settings - Fork 0
fix(ops): hash diagnostic keys without DefaultHasher::new #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -799,11 +799,9 @@ impl OccurrenceLimiter { | |
| } | ||
|
|
||
| fn diagnostic_key(message: &str) -> u64 { | ||
| use std::collections::hash_map::DefaultHasher; | ||
| use std::hash::{Hash, Hasher}; | ||
| let mut hasher = DefaultHasher::new(); | ||
| message.hash(&mut hasher); | ||
| hasher.finish() | ||
| message.bytes().fold(0u64, |hash, byte| { | ||
| hash.wrapping_mul(31).wrapping_add(u64::from(byte)) | ||
| }) | ||
|
Comment on lines
+802
to
+804
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Use a collision-resistant identity rather than this base-31 fold. Distinct messages have trivial deterministic collisions—for example, Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| #[derive(Debug)] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: Limen-Neural/brainstem-daemon
Length of output: 4093
🏁 Script executed:
Repository: Limen-Neural/brainstem-daemon
Length of output: 15497
🏁 Script executed:
Repository: Limen-Neural/brainstem-daemon
Length of output: 15495
Use the full diagnostic message as the suppression identity.
diagnostic_keymaps distinct messages such as"Aa"and"BB"to2112.OccurrenceLimiter::recordresets state only when the numeric key changes. A colliding message can therefore share occurrence and suppression counts with the previous message.Store and compare the original message, or use a stronger stable identity key.
🤖 Prompt for AI Agents