1. 09 Feb, 2026 5 commits
    • shaw's avatar
      chore: update version · 51572b5d
      shaw authored
      51572b5d
    • QTom's avatar
      04cedce9
    • QTom's avatar
      feat(admin): 新增 CRS 同步预览和账号选择功能 · 5e0d7894
      QTom authored
      - 后端新增 PreviewFromCRS 接口,允许用户先预览 CRS 中的账号
      - 后端支持在同步时选择特定账号,不选中的账号将被跳过
      - 前端重构 SyncFromCrsModal 为三步向导:输入凭据 → 预览账号 → 执行同步
      - 改进表单无障碍性:添加 for/id 关联和 required 属性
      - 修复 Back 按钮返回时的状态清理
      - 新增 buildSelectedSet 和 shouldCreateAccount 的单元测试
      - 完整的向后兼容性:旧客户端不发送 selected_account_ids 时行为不变
      5e0d7894
    • erio's avatar
      fix: resolve CI failures from scope removal refactor · 9a479d1b
      erio authored
      - Fix gofmt alignment in ops_realtime_models.go
      - Remove SetAntigravityQuotaScopeLimit mock from api_contract_test.go
      - Add UpdateSortOrders mock to mockGroupRepoForGateway
      9a479d1b
    • erio's avatar
      refactor: replace scope-level rate limiting with model-level rate limiting · fc095bf0
      erio authored
      Merge functional changes from develop branch:
      - Remove AntigravityQuotaScope system (claude/gemini_text/gemini_image)
      - Replace with per-model rate limiting using resolveAntigravityModelKey
      - Remove model load statistics (IncrModelCallCount/GetModelLoadBatch)
      - Simplify account selection to unified priority→load→LRU algorithm
      - Remove SetAntigravityQuotaScopeLimit from AccountRepository
      - Clean up scope-related UI indicators and API fields
      fc095bf0
  2. 08 Feb, 2026 22 commits
  3. 07 Feb, 2026 13 commits
    • erio's avatar
      fix(gateway): restore upstream account forwarding with dedicated methods · 77b66653
      erio authored
      v0.1.74 merged upstream accounts into the OAuth path, causing requests
      to hit the wrong protocol and endpoint. Add three upstream-specific
      methods (testUpstreamConnection, ForwardUpstream, ForwardUpstreamGemini)
      that use base_url + apiKey auth and passthrough the original body, while
      reusing the existing response handling and error/retry logic.
      77b66653
    • yangjianbo's avatar
      fix: 修复函数签名变更后的调用参数不匹配 · 836ba14b
      yangjianbo authored
      
      
      - handleUpstreamError 补齐新增的三个参数 (0, "", false)
      - handleStreamingResponse 移除已删除的 nil 参数
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      836ba14b
    • yangjianbo's avatar
      fix(audit): 第二批审计修复 — P0 生产 Bug、安全加固、性能优化、缓存一致性、代码质量 · 2588fa6a
      yangjianbo authored
      
      
      基于 backend-code-audit 审计报告,修复剩余 P0/P1/P2 共 34 项问题:
      
      P0 生产 Bug:
      - 修复 time.Since(time.Now()) 计时逻辑错误 (P0-03)
      - generateRandomID 改用 crypto/rand 替代固定索引 (P0-04)
      - IncrementQuotaUsed 重写为 Ent 原子操作消除 TOCTOU 竞态 (P0-05)
      
      安全加固:
      - gateway/openai handler 错误响应替换为泛化消息,防止内部信息泄露 (P1-14)
      - usage_log_repo dateFormat 参数改用白名单映射,防止 SQL 注入 (P1-16)
      - 默认配置安全加固:sslmode=prefer、response_headers=true、mode=release (P1-18/19, P2-15)
      
      性能优化:
      - gateway handler 循环内 defer 替换为显式 releaseWait 闭包 (P1-02)
      - group_repo/promo_code_repo Count 前 Clone 查询避免状态污染 (P1-03)
      - usage_log_repo 四个查询添加 LIMIT 10000 防止 OOM (P1-07)
      - GetBatchUsageStats 添加时间范围参数,默认最近 30 天 (P1-10)
      - ip.go CIDR 预编译为包级变量 (P1-11)
      - BatchUpdateCredentials 重构为先验证后更新 (P1-13)
      
      缓存一致性:
      - billing_cache 添加 jitteredTTL 防止缓存雪崩 (P2-10)
      - DeductUserBalance/UpdateSubscriptionUsage 错误传播修复 (P2-12)
      - UserService.UpdateBalance 成功后异步失效 billingCache (P2-13)
      
      代码质量:
      - search 截断改为按 rune 处理,支持多字节字符 (P2-01)
      - TLS Handshake 改为 HandshakeContext 支持 context 取消 (P2-07)
      - CORS 预检添加 Access-Control-Max-Age: 86400 (P2-16)
      
      测试覆盖:
      - 新增 user_service_test.go(UpdateBalance 缓存失效 6 个用例)
      - 新增 batch_update_credentials_test.go(fail-fast + 类型验证 7 个用例)
      - 新增 response_transformer_test.go、ip_test.go、usage_log_repo_unit_test.go、search_truncate_test.go
      - 集成测试:IncrementQuotaUsed 并发测试、billing_cache 错误传播测试
      - config_test.go 补充 server.mode/sslmode 默认值断言
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      2588fa6a
    • erio's avatar
      feat: smart retry max 1 attempt + clear sticky session on failure · 3077fd27
      erio authored
      - Change antigravitySmartRetryMaxAttempts from 3 to 1 to prevent
        repeated rate limiting and long waits
      - Clear sticky session binding (DeleteSessionAccountID) after smart
        retry exhaustion, so subsequent requests don't hit the same
        rate-limited account
      - Add flow diagrams to Forward/ForwardGemini doc comments
      - Add comprehensive unit tests covering:
        - Sticky session cleared on retry failure (429, 503, network error)
        - Sticky session NOT cleared on retry success
        - Sticky session NOT cleared for non-sticky requests (empty hash)
        - Sticky session NOT cleared on long delay path (handled by handler)
        - Nil cache safety (no panic)
        - MaxAttempts constant verification
        - End-to-end retryLoop → switchError propagation with session clear
      3077fd27
    • shaw's avatar
      6aaa4aee
    • erio's avatar
      e3748da8
    • erio's avatar
      refactor: remove Anthropic digest chain from Messages handler · 86b503f8
      erio authored
      The digest chain fallback is only needed for Gemini endpoints, not
      for the Anthropic Messages API path. Remove the handler integration
      while keeping the reusable service/repository layer for future use.
      86b503f8
    • erio's avatar
      feat: add Anthropic sticky session digest chain matching via Trie · 50a783ff
      erio authored
      The previous fallback (step 3) in GenerateSessionHash hashed system +
      all messages together, producing a different hash each round as the
      conversation grew ([a] -> [a,b] -> [a,b,c]). This made fallback sticky
      sessions ineffective for multi-turn conversations.
      
      Implement per-message Trie digest chain matching (reusing Gemini's Trie
      infrastructure) so that the previous round's chain is always a prefix
      of the current round's chain, enabling reliable session affinity.
      50a783ff
    • yangjianbo's avatar
      fix(oauth): SessionStore.Stop() 添加 sync.Once 防重入保护 (P1-05) · f6ca7019
      yangjianbo authored
      
      
      oauth 和 openai 包的 SessionStore.Stop() 直接调用 close(stopCh),
      重复调用会导致 panic。使用 sync.Once 包裹确保幂等安全。
      
      新增单元测试覆盖连续调用和 50 goroutine 并发调用场景。
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      f6ca7019
    • yangjianbo's avatar
    • yangjianbo's avatar
      fix(security): 修复密码重置链接 Host Header 注入漏洞 (P0-07) · e75d3e35
      yangjianbo authored
      
      
      ForgotPassword 原来从 c.Request.Host 构建重置链接基础 URL,攻击者
      可伪造 Host 头将重置链接指向恶意域名窃取 token。
      
      修复方案:
      - ServerConfig 新增 frontend_url 配置项
      - auth_handler 改为从配置读取前端 URL,未配置时拒绝请求
      - Validate() 校验 frontend_url 必须为绝对 HTTP(S) URL
      - 新增 TestValidateServerFrontendURL 单元测试
      - config.example.yaml 添加配置说明
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      e75d3e35
    • shaw's avatar
      fix(gateway): harden digest logging and align antigravity ops · 1439eb39
      shaw authored
      - avoid panic by using safe UUID prefix truncation in Gemini digest fallback logs\n- remove unconditional Antigravity 429 full-body debug logs and honor log truncation config\n- align Antigravity quick preset mappings to opus 4.6-thinking targets only\n- restore scope rate-limit aggregation/output in ops availability stats
      1439eb39
    • yangjianbo's avatar
      perf(service): 优化 model 替换函数,用 gjson/sjson 替代全量 JSON 序列化 · 8226a4ce
      yangjianbo authored
      
      
      SSE 热路径中 replaceModelInSSELine 和 replaceModelInResponseBody 原来
      使用 json.Unmarshal/Marshal 对每个事件做全量反序列化再序列化,现改为
      gjson.Get/sjson.Set 精确字段操作,消除 O(n) 中间 map 分配,保持 JSON
      字段顺序不变。涉及 OpenAIGatewayService 和 GatewayService 两个服务。
      
      新增 23 个单元测试覆盖:顶层/嵌套 model 替换、不匹配跳过、空行/[DONE]/
      非法 JSON 等边界情况。
      
      Fixes: P1-08
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      8226a4ce