-
Notifications
You must be signed in to change notification settings - Fork 56
fix: bug sweep — 8 confirmed correctness bugs across refresh, quota, storage, request & budget #637
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
19d023e
eb11a57
acc525f
23b02c3
2fbde45
7a3c241
001683e
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 |
|---|---|---|
|
|
@@ -198,7 +198,14 @@ export const DEFAULT_TOKEN_BUCKET_CONFIG: TokenBucketConfig = { | |
| tokensPerMinute: 6, | ||
| }; | ||
|
|
||
| const TOKEN_REFUND_WINDOW_MS = 30_000; | ||
| // Must cover the full request lifetime so a token consumed at request start can | ||
| // still be refunded when the request fails at the very end. The runtime proxy | ||
| // refunds on network error / upstream timeout, and the default fetch timeout is | ||
| // 60_000ms (config.ts fetchTimeoutMs) — measured AFTER token consumption and a | ||
| // token refresh. 90_000ms = that 60s timeout plus slack for the refresh and | ||
| // processing, so a genuinely timed-out request's token is reversed instead of | ||
| // leaking (gradual token-bucket starvation -> spurious token-exhausted skips). | ||
| const TOKEN_REFUND_WINDOW_MS = 90_000; | ||
|
Comment on lines
+201
to
+208
Contributor
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. 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 3 'fetchTimeoutMs|TOKEN_REFUND_WINDOW_MS|refundToken\(' lib testRepository: ndycode/codex-multi-auth Length of output: 50380 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== backend settings schema fetchTimeoutMs and related timeout bounds =="
sed -n '220,240p' lib/codex-manager/backend-settings-schema.ts
echo
echo "== resolveNumberSetting implementation and fetchTimeoutMs resolver =="
sed -n '1398,1424p' lib/config.ts
echo
echo "== rotation proxy timeout binding and refund paths =="
sed -n '1136,1160p' lib/runtime-rotation-proxy.ts
sed -n '1290,1342p' lib/runtime-rotation-rotation-proxy.ts 2>/dev/null || sed -n '1290,1342p' lib/runtime-rotation-proxy.ts
echo
echo "== rotation token tracker tests mentioning refund/prune window =="
rg -n 'refundToken|TOKEN_REFUND_WINDOW|90_000|60_000|fetchTimeoutMs' test lib/rotation.ts lib/accounts.tsRepository: ndycode/codex-multi-auth Length of output: 50380 🌐 Web query:
💡 Result: Based on an analysis of technical documentation and common repository structures, there is no standardized, widely recognized library or utility known globally as settings-hub-utils containing a clampBackendNumber method [1][2][3][4]. It is highly likely that this specific identifier refers to a private, project-specific internal utility function or a misremembered name from a custom configuration module [3][5][4]. The combination of settings-hub-utils and a 600,000ms (600 seconds/10 minutes) fetchTimeoutMs suggests a custom implementation for managing network request timeouts within a configuration-heavy application or CLI tool [5][6][7]. If you are encountering this in a specific codebase: 1. Search for the string "settings-hub-utils" within your local project files using grep or your IDE's global search to identify the file definition. 2. If the function is used to clamp a timeout value, it is likely enforcing a hard limit (e.g., ensuring a user-provided timeout value does not exceed 10 minutes) to prevent indefinitely hanging network requests [5][6]. 3. For context on similar patterns, developers often implement helper functions like clampNumber to ensure configuration values remain within safe, predefined bounds (min/max) during runtime [1][2][8]. If you can provide the specific repository or framework where you encountered this, further analysis can be performed. Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== clamping and validation for fetchTimeoutMs =="
rg -n 'clampBackendNumber|fetchTimeoutMs.*600_000|backends.*fetchTimeout|fetchTimeout.*limits' test lib --glob '*.ts' | head -80
echo
echo "== settings-hub-utils relevant tests =="
sed -n '1,58p' test/settings-hub-utils.test.ts
echo
echo "== settings-hub-utils relevant implementation candidates =="
rg -n 'export .*clampBackendNumber|function clampBackendNumber|const clampBackendNumber|clampBackendNumberForTests' lib test --glob '*.ts'Repository: ndycode/codex-multi-auth Length of output: 6295 bound the token refund window to the supported request budget.
🤖 Prompt for AI AgentsSource: Path instructions |
||
|
|
||
| interface TokenBucketEntry { | ||
| tokens: number; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.