@@ -51,7 +51,7 @@ func TestCalculateOpenAI429ResetTime_5hExhausted(t *testing.T) {
5151 headers .Set ("x-codex-primary-used-percent" , "50" )
5252 headers .Set ("x-codex-primary-reset-after-seconds" , "500000" )
5353 headers .Set ("x-codex-primary-window-minutes" , "10080" ) // 7 days
54- headers .Set ("x-codex-secondary-used-percent" , "0 " )
54+ headers .Set ("x-codex-secondary-used-percent" , "100 " )
5555 headers .Set ("x-codex-secondary-reset-after-seconds" , "3600" ) // 1 hour
5656 headers .Set ("x-codex-secondary-window-minutes" , "300" ) // 5 hours
5757
@@ -122,7 +122,7 @@ func TestCalculateOpenAI429ResetTime_ReversedWindowOrder(t *testing.T) {
122122
123123 // Test when OpenAI sends primary as 5h and secondary as 7d (reversed)
124124 headers := http.Header {}
125- headers .Set ("x-codex-primary-used-percent" , "0 " ) // This is 5h remaining %
125+ headers .Set ("x-codex-primary-used-percent" , "100 " ) // This is 5h used %
126126 headers .Set ("x-codex-primary-reset-after-seconds" , "3600" ) // 1 hour
127127 headers .Set ("x-codex-primary-window-minutes" , "300" ) // 5 hours - smaller!
128128 headers .Set ("x-codex-secondary-used-percent" , "50" )
@@ -180,7 +180,7 @@ func TestHandle429_OpenAIPersistsCodexSnapshotImmediately(t *testing.T) {
180180 headers .Set ("x-codex-primary-used-percent" , "100" )
181181 headers .Set ("x-codex-primary-reset-after-seconds" , "604800" )
182182 headers .Set ("x-codex-primary-window-minutes" , "10080" )
183- headers .Set ("x-codex-secondary-used-percent" , "0 " )
183+ headers .Set ("x-codex-secondary-used-percent" , "100 " )
184184 headers .Set ("x-codex-secondary-reset-after-seconds" , "18000" )
185185 headers .Set ("x-codex-secondary-window-minutes" , "300" )
186186
@@ -224,15 +224,15 @@ func TestNormalizedCodexLimits(t *testing.T) {
224224 pUsed := 100.0
225225 pReset := 384607
226226 pWindow := 10080
227- sRemaining := 3.0
227+ sUsed := 3.0
228228 sReset := 17369
229229 sWindow := 300
230230
231231 snapshot := & OpenAICodexUsageSnapshot {
232232 PrimaryUsedPercent : & pUsed ,
233233 PrimaryResetAfterSeconds : & pReset ,
234234 PrimaryWindowMinutes : & pWindow ,
235- SecondaryUsedPercent : & sRemaining ,
235+ SecondaryUsedPercent : & sUsed ,
236236 SecondaryResetAfterSeconds : & sReset ,
237237 SecondaryWindowMinutes : & sWindow ,
238238 }
@@ -249,8 +249,8 @@ func TestNormalizedCodexLimits(t *testing.T) {
249249 if normalized .Reset7dSeconds == nil || * normalized .Reset7dSeconds != 384607 {
250250 t .Errorf ("expected Reset7dSeconds=384607, got %v" , normalized .Reset7dSeconds )
251251 }
252- if normalized .Used5hPercent == nil || * normalized .Used5hPercent != 97 .0 {
253- t .Errorf ("expected Used5hPercent=97 , got %v" , normalized .Used5hPercent )
252+ if normalized .Used5hPercent == nil || * normalized .Used5hPercent != 3 .0 {
253+ t .Errorf ("expected Used5hPercent=3 , got %v" , normalized .Used5hPercent )
254254 }
255255 if normalized .Reset5hSeconds == nil || * normalized .Reset5hSeconds != 17369 {
256256 t .Errorf ("expected Reset5hSeconds=17369, got %v" , normalized .Reset5hSeconds )
@@ -338,11 +338,11 @@ func TestRateLimitService_HandleUpstreamError_403FallsBackToRawBody(t *testing.T
338338
339339func TestNormalizedCodexLimits_OnlySecondaryData (t * testing.T ) {
340340 // Test when only secondary has data, no window_minutes
341- sRemaining := 60.0
341+ sUsed := 60.0
342342 sReset := 3000
343343
344344 snapshot := & OpenAICodexUsageSnapshot {
345- SecondaryUsedPercent : & sRemaining ,
345+ SecondaryUsedPercent : & sUsed ,
346346 SecondaryResetAfterSeconds : & sReset ,
347347 // No window_minutes, no primary data
348348 }
@@ -354,8 +354,8 @@ func TestNormalizedCodexLimits_OnlySecondaryData(t *testing.T) {
354354
355355 // Legacy assumption: primary=7d, secondary=5h
356356 // So secondary goes to 5h
357- if normalized .Used5hPercent == nil || * normalized .Used5hPercent != 40 .0 {
358- t .Errorf ("expected Used5hPercent=40 , got %v" , normalized .Used5hPercent )
357+ if normalized .Used5hPercent == nil || * normalized .Used5hPercent != 60 .0 {
358+ t .Errorf ("expected Used5hPercent=60 , got %v" , normalized .Used5hPercent )
359359 }
360360 if normalized .Reset5hSeconds == nil || * normalized .Reset5hSeconds != 3000 {
361361 t .Errorf ("expected Reset5hSeconds=3000, got %v" , normalized .Reset5hSeconds )
@@ -370,13 +370,13 @@ func TestNormalizedCodexLimits_BothDataNoWindowMinutes(t *testing.T) {
370370 // Test when both have data but no window_minutes
371371 pUsed := 100.0
372372 pReset := 400000
373- sRemaining := 30.0
373+ sUsed := 30.0
374374 sReset := 10000
375375
376376 snapshot := & OpenAICodexUsageSnapshot {
377377 PrimaryUsedPercent : & pUsed ,
378378 PrimaryResetAfterSeconds : & pReset ,
379- SecondaryUsedPercent : & sRemaining ,
379+ SecondaryUsedPercent : & sUsed ,
380380 SecondaryResetAfterSeconds : & sReset ,
381381 // No window_minutes
382382 }
@@ -393,8 +393,8 @@ func TestNormalizedCodexLimits_BothDataNoWindowMinutes(t *testing.T) {
393393 if normalized .Reset7dSeconds == nil || * normalized .Reset7dSeconds != 400000 {
394394 t .Errorf ("expected Reset7dSeconds=400000, got %v" , normalized .Reset7dSeconds )
395395 }
396- if normalized .Used5hPercent == nil || * normalized .Used5hPercent != 70 .0 {
397- t .Errorf ("expected Used5hPercent=70 , got %v" , normalized .Used5hPercent )
396+ if normalized .Used5hPercent == nil || * normalized .Used5hPercent != 30 .0 {
397+ t .Errorf ("expected Used5hPercent=30 , got %v" , normalized .Used5hPercent )
398398 }
399399 if normalized .Reset5hSeconds == nil || * normalized .Reset5hSeconds != 10000 {
400400 t .Errorf ("expected Reset5hSeconds=10000, got %v" , normalized .Reset5hSeconds )
@@ -425,7 +425,7 @@ func TestCalculateOpenAI429ResetTime_UserProvidedScenario(t *testing.T) {
425425 // This is the exact scenario from the user:
426426 // codex_7d_used_percent: 100
427427 // codex_7d_reset_after_seconds: 384607 (约4.5天后重置)
428- // codex_5h_used_percent: 97 (from upstream 3% remaining )
428+ // codex_5h_used_percent: 3 (from upstream 3% used )
429429 // codex_5h_reset_after_seconds: 17369 (约4.8小时后重置)
430430
431431 svc := & RateLimitService {}
0 commit comments