-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathradubrehar_test.go
More file actions
235 lines (219 loc) · 7.49 KB
/
radubrehar_test.go
File metadata and controls
235 lines (219 loc) · 7.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
package ditzy
import (
"testing"
)
//nolint:maintidx // Test data setup is inherently verbose
func TestRadubreharRomaniaTimezone(t *testing.T) {
// radubrehar's ACTUAL activity data from the system
// He lives in Transylvania, Romania (UTC+2 in winter, UTC+3 in summer)
// Profile explicitly says "Transylvania" and he works at Infinite Table
//
// ACTUAL quiet hours from logs: [0 1 2 3 4 5 6 7 8 9 22 23] - 12 quiet hours
// ACTUAL activeStartUTC = 10.5
// ACTUAL activeEndUTC = 16
//
// The issue: The system is selecting UTC-3 (84% confidence) when it should
// select UTC+2 (Romania). Looking at the activity histogram:
//
// In UTC-3: In UTC+2 (correct):
// 07:30 = 04:30 local 07:30 = 09:30 local ✓
// 09:00 = 06:00 local 09:00 = 11:00 local ✓ (perfect peak)
// 12:00 = 09:00 local 12:00 = 14:00 local ✓
// 17:00 = 14:00 local 17:00 = 19:00 local ✓ (evening)
// 20:00 = 17:00 local 20:00 = 22:00 local ✓
//
// In UTC-3, activity ends at ~20:30 UTC = 17:30 local, which means NO evening activity
// This is suspicious for an OSS developer. In UTC+2, evening activity exists.
// ACTUAL activity data from `go run ./cmd/locator --show-prompt radubrehar` (2025-11-29)
// The histogram shows times in UTC-3 (America/Sao_Paulo), so we convert back to UTC:
// UTC-3 time + 3 = UTC time
//
// Real pattern (in UTC-3 local time -> UTC):
// 03:30 local = 06:30 UTC: 1 event
// 04:00 local = 07:00 UTC: 5 events
// 04:30 local = 07:30 UTC: 1 event
// 05:00 local = 08:00 UTC: 1 event
// 06:00 local = 09:00 UTC: 2 events
// 06:30 local = 09:30 UTC: 2 events
// 07:00 local = 10:00 UTC: 1 event
// 07:30 local = 10:30 UTC: 8 events
// 08:00 local = 11:00 UTC: 10 events
// 08:30 local = 11:30 UTC: 8 events
// 09:00 local = 12:00 UTC: 23 events (peak)
// 09:30 local = 12:30 UTC: 11 events
// 10:00 local = 13:00 UTC: 11 events
// 10:30 local = 13:30 UTC: 6 events
// 11:00 local = 14:00 UTC: 5 events
// 11:30 local = 14:30 UTC: 7 events
// 12:00 local = 15:00 UTC: 6 events
// 12:30 local = 15:30 UTC: 5 events
// 13:00 local = 16:00 UTC: 0 events (lunch)
// 13:30 local = 16:30 UTC: 2 events
// 14:00 local = 17:00 UTC: 1 event
// 14:30 local = 17:30 UTC: 1 event
// 17:00 local = 20:00 UTC: 5 events
// 17:30 local = 20:30 UTC: 2 events
// 18:00 local = 21:00 UTC: 3 events
// 18:30 local = 21:30 UTC: 3 events
// 19:00 local = 22:00 UTC: 2 events
// 19:30 local = 22:30 UTC: 2 events
// 20:00 local = 23:00 UTC: 2 events
//
// In UTC+2 (Romania), this same UTC pattern becomes:
// 06:30 UTC = 08:30 local: 1 event (early morning)
// 07:00 UTC = 09:00 local: 5 events
// ...
// 12:00 UTC = 14:00 local: 23 events (afternoon peak)
// ...
// 16:00 UTC = 18:00 local: 0 events (evening break)
// ...
// 23:00 UTC = 01:00 local: 2 events (late night)
hourCounts := map[int]int{
6: 1, // 06:30 UTC
7: 6, // 07:00-07:30 UTC
8: 1, // 08:00 UTC
9: 4, // 09:00-09:30 UTC
10: 9, // 10:00-10:30 UTC
11: 18, // 11:00-11:30 UTC
12: 34, // 12:00-12:30 UTC - peak
13: 17, // 13:00-13:30 UTC
14: 12, // 14:00-14:30 UTC
15: 11, // 15:00-15:30 UTC
16: 2, // 16:00-16:30 UTC - lunch gap
17: 2, // 17:00-17:30 UTC
20: 7, // 20:00-20:30 UTC
21: 6, // 21:00-21:30 UTC
22: 4, // 22:00-22:30 UTC
23: 2, // 23:00 UTC
}
// Half-hour counts from actual histogram
halfHourCounts := map[float64]int{
6.5: 1, // 06:30 UTC
7.0: 5, // 07:00 UTC
7.5: 1, // 07:30 UTC
8.0: 1, // 08:00 UTC
9.0: 2, // 09:00 UTC
9.5: 2, // 09:30 UTC
10.0: 1, // 10:00 UTC
10.5: 8, // 10:30 UTC
11.0: 10, // 11:00 UTC
11.5: 8, // 11:30 UTC
12.0: 23, // 12:00 UTC - peak
12.5: 11, // 12:30 UTC
13.0: 11, // 13:00 UTC
13.5: 6, // 13:30 UTC
14.0: 5, // 14:00 UTC
14.5: 7, // 14:30 UTC
15.0: 6, // 15:00 UTC
15.5: 5, // 15:30 UTC
16.0: 0, // 16:00 UTC - lunch gap
16.5: 2, // 16:30 UTC
17.0: 1, // 17:00 UTC
17.5: 1, // 17:30 UTC
20.0: 5, // 20:00 UTC
20.5: 2, // 20:30 UTC
21.0: 3, // 21:00 UTC
21.5: 3, // 21:30 UTC
22.0: 2, // 22:00 UTC
22.5: 2, // 22:30 UTC
23.0: 2, // 23:00 UTC
}
totalActivity := 136
// ACTUAL quiet hours from logs: [0 1 2 3 4 5 6 7 8 9 10 23]
quietHours := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 23}
midQuiet := 4.5 // Middle of sleep period
activeStart := 10.5
// Lunch pattern at 16:00 UTC
bestGlobalLunch := globalLunchPattern{
startUTC: 16.0,
endUTC: 16.5,
confidence: 0.8,
dropPercent: 50.0,
}
// Evaluate candidates
candidates := evaluate(evaluationInput{
username: "radubrehar",
hourCounts: hourCounts,
halfHourCounts: halfHourCounts,
totalActivity: totalActivity,
quietHours: quietHours,
midQuiet: midQuiet,
activeStart: activeStart,
bestGlobalLunch: bestGlobalLunch,
profileTimezone: "",
})
// Check that we have multiple candidates
if len(candidates) < 3 {
t.Errorf("Expected at least 3 candidates, got %d", len(candidates))
}
// Log all candidates for debugging
t.Logf("All candidates for radubrehar:")
for i, c := range candidates {
t.Logf(" %d. UTC%+.0f (%.1f%% confidence)", i+1, c.offset, c.confidence)
if c.offset == 2 || c.offset == -3 {
t.Logf(" Sleep midpoint UTC: %.1f, Sleep buckets: %v", c.sleepMidUTC, c.sleepBucketsUTC)
sleepMidLocal := c.sleepMidUTC + c.offset
if sleepMidLocal < 0 {
sleepMidLocal += 24
}
if sleepMidLocal >= 24 {
sleepMidLocal -= 24
}
t.Logf(" Sleep midpoint local: %.1f", sleepMidLocal)
t.Logf(" Scoring details for UTC%+.0f:", c.offset)
for _, detail := range c.scoringDetails {
t.Logf(" %s", detail)
}
}
}
// Check that UTC+2 (Romania winter) or UTC+3 (Romania summer) is in the top 3
// The key insight: UTC-3 interpretation shows sustained activity at 3am-5am local,
// which is a highly unusual wake pattern. This should disqualify UTC-3 and push
// UTC+2 into the top 3.
foundRomania := false
romaniaPosition := -1
for i := 0; i < len(candidates) && i < 3; i++ {
offset := candidates[i].offset
if offset == 2 || offset == 3 {
foundRomania = true
romaniaPosition = i + 1
t.Logf("Found Romania timezone at position %d: UTC%+.0f with confidence %.1f%%",
i+1, offset, candidates[i].confidence)
break
}
}
if !foundRomania {
t.Errorf("UTC+2 or UTC+3 should be in top 3 candidates for radubrehar")
t.Logf("Top 3 candidates:")
for i := 0; i < len(candidates) && i < 3; i++ {
t.Logf(" %d. UTC%+.0f (%.1f%% confidence)",
i+1, candidates[i].offset, candidates[i].confidence)
}
}
// UTC+2 should be ABOVE UTC-3
// UTC-3 has sustained activity at 3am-5am local (middle of night wake pattern)
// which should heavily penalize it
utc2Position := -1
utc3Position := -1
for i, c := range candidates {
if c.offset == 2 && utc2Position == -1 {
utc2Position = i + 1
}
if c.offset == -3 && utc3Position == -1 {
utc3Position = i + 1
}
}
if utc2Position > 0 && utc3Position > 0 && utc2Position > utc3Position {
t.Errorf("UTC+2 (position %d) should be above UTC-3 (position %d) - UTC-3 has suspicious 3am-5am wake pattern",
utc2Position, utc3Position)
} else if utc2Position > 0 && utc3Position > 0 {
t.Logf("UTC+2 is at position %d, UTC-3 is at position %d (correctly ranked)", utc2Position, utc3Position)
}
// Check that UTC+2 has positive confidence (not negative)
for _, c := range candidates {
if c.offset == 2 && c.confidence < 0 {
t.Errorf("UTC+2 confidence should not be negative: %.1f%%", c.confidence)
}
}
_ = romaniaPosition // Used for logging above
}