fix: use deterministic hash-based jitter for country centroid fallback#236
fix: use deterministic hash-based jitter for country centroid fallback#236haosenwang1018 wants to merge 2 commits intokoala73:mainfrom
Conversation
The previous 0.5° rounding (~50km radius) merged distinct events in dense urban areas (e.g. Manhattan vs Brooklyn protests on the same day). Reducing to 0.1° (~10km) preserves neighborhood-level granularity while still deduplicating true duplicates. Fixes koala73#204 Signed-off-by: haosenwang1018 <haosenwang1018@users.noreply.github.com>
Replace Math.random() with a djb2 hash seeded by the threat ID, so the same threat always appears at the same coordinates. This prevents 'jumping' markers on the map when the same data is re-fetched. Fixes koala73#203 Signed-off-by: haosenwang1018 <haosenwang1018@users.noreply.github.com>
|
@haosenwang1018 is attempting to deploy a commit to the Elie Team on Vercel. A member of the Team first needs to authorize it. |
|
Thank you @haosenwang1018 can you hanle the below pls : PR #236 Review: fix: use deterministic hash-based jitter for country centroid fallbackSummaryTwo commits: (1) reduce unrest dedup rounding from 0.5° to 0.1°, (2) replace Issues Found1. Bug — JSDoc documents wrong output range The return ((hash & 0x7fffffff) / 0x7fffffff - 0.5) * 2;
// [0, 1.0] [-0.5, 0.5] [-1.0, 1.0]The 2. Redundant commit — unrest dedup change already in Commit 1 ( What's Good
VerdictRequest changes. The deterministic jitter approach (commit 2) is the right solution. Two action items before merge:
|
Problem
The GeoIP centroid fallback uses
Math.random()for jitter, causing the same threat from the same country to appear at different coordinates on each request. This creates 'jumping' markers on the visualization.Fix
Replace
Math.random()with a deterministic djb2 hash seeded by the threat ID. Same input always produces the same jitter offset, so markers stay stable across requests.The jitter range (±1°) is preserved — only the randomness source changes.
Ref: PR #106 re-review (NEW-8)
Fixes #203