feat(oauth): persist usage snapshots and window cooldown#357
Open
DuckyProject wants to merge 1 commit intoWei-Shaw:mainfrom
Open
feat(oauth): persist usage snapshots and window cooldown#357DuckyProject wants to merge 1 commit intoWei-Shaw:mainfrom
DuckyProject wants to merge 1 commit intoWei-Shaw:mainfrom
Conversation
Contributor
Author
|
关于模拟用量的部分需要讨论是否融入此功能 |
86fd7d1 to
1245f07
Compare
624b6bc to
bbdc866
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
x-codex-*中,但此前未系统化落库,也无法用“窗口结束时间”驱动持续限流。本次改动
Backend
https://chatgpt.com/backend-api/codex/responses响应头解析x-codex-*,归一化为标准 5h/7d 字段并写入accounts.extra(包含codex_*_reset_at绝对时间)。accounts.rate_limit_reset_at,实现“持续 429 到窗口结束”(7d 优先,否则 5h)。x-codex-*推导真实 resetAt,替代通用 5 分钟 fallback。accounts.extra.{claude_usage_snapshot,gemini_usage_snapshot},并记录*_usage_updated_at与*_usage_source(gateway/test/probe)。accounts.rate_limit_reset_at(基于 5h/7d 的resets_at)。OAuthProbeService:默认关闭;启用后每check_interval_minutes对“闲置超过idle_threshold_minutes”的 OAuth/Setup-Token 账号做最小探测并同步快照。Frontend
account.extra快照(不再 per-row 调接口)。resets_at已过期的快照做展示层回退:显示 0% 且不显示倒计时,减少“过期假数据”影响。配置
oauth_probe(默认enabled: false),支持:check_interval_minutesidle_threshold_minutes(默认 15;仅闲置账号触发探活)request_timeout_secondsmax_concurrencymax_accounts_per_cycleTLS 指纹(确认点)
extra.enable_tls_fingerprint),在获取 OAuth usage(快照同步)时也会走同一套 TLS 指纹请求路径(DoWithTLS)。测试
cd backend && go test ./internal/service ./internal/repositorycd backend && go test ./...可能因internal/pkg/tlsfingerprint外网集成测试超时失败(与本 PR 逻辑无关)。风险/回滚
oauth_probe可能产生额外上游请求并消耗真实配额,因此默认关闭;如需回滚影响,保持oauth_probe.enabled=false即可。