Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
66d5546
fix(scheduling): release concurrency slot on hydration failure
Nov 17, 2026
1b68ce7
fix(auth): atomically consume refresh tokens during rotation
Nov 17, 2026
e796e26
fix(billing): scope RPM overrides to their configured group
Nov 17, 2026
e5363c2
fix(apicompat): preserve non-strict JSON Schema default
Nov 17, 2026
c1c8222
fix(claude): use Sonnet 4.6 for default account tests
Nov 17, 2026
6392d09
fix(openai): reject invalid UTF-8 before Responses routing
Nov 17, 2026
e22bacf
fix(gateway): apply account error rules in Anthropic compat paths
Nov 17, 2026
bfb3860
fix(scheduler): restore accounts when transient cooldowns expire
Nov 17, 2026
13776ca
test(scheduler): verify configured cooldown membership with PostgreSQ…
Nov 17, 2026
4a8d09b
test(scheduler): isolate configured-membership assertions from shared…
Nov 17, 2026
65b7e87
fix(billing): make group rate and RPM sync transactional
Nov 17, 2026
64e96aa
test(billing): verify group sync rollback against PostgreSQL
Nov 17, 2026
5e8bdab
fix(gateway): prevent request-wide account cooldowns and normalize Pi…
Nov 17, 2026
ecc0d2e
fix(gemini): preserve independent same-name parallel tool calls in st…
Nov 17, 2026
90a780f
docs(backport): submit one consolidated PR after full validation
Nov 17, 2026
3c366ab
fix(gemini): preserve structured response formats and valid tool schemas
Nov 17, 2026
42ebdcf
feat(gemini): add Carbon catalog, routing, thinking levels and introd…
Nov 17, 2026
c72a308
fix(openai): forward SSE keepalives without delaying first output fai…
Nov 17, 2026
1bb4ea2
fix(openai): keep first-output buffering bounded when temporary stora…
Nov 17, 2026
9513e87
fix(claude): retry once with rotated OAuth token across gateway proto…
Nov 17, 2026
7ee08e5
fix(auth): keep setup-token accounts recoverable after transient 401
Nov 17, 2026
4fa5d07
fix(gemini): keep quota bars visible while usage refreshes
Nov 17, 2026
fcac6ab
fix(openai): account health updates on terminal compatibility stream …
Nov 18, 2026
3e56431
fix(apicompat): keep prior reasoning separate from visible assistant …
Nov 18, 2026
d725ab3
fix(quota): preserve OpenAI upstream observation freshness across fai…
Nov 18, 2026
07abd5b
fix(frontend): keep account quota and rows visible during refresh
Nov 18, 2026
1653e11
fix(gateway): emit SSE error events when upstream fails after keepalive
Nov 18, 2026
9dd57ed
fix(openai): sanitize unsupported Python regexes in Responses tool sc…
Nov 18, 2026
aed6cc0
feat(claude): add Fable and Mythos 5.2 models and protocol support
Nov 18, 2026
8271b7f
fix(upstream): shorten dead TCP connection detection with bounded kee…
Nov 18, 2026
6814647
fix(openai): bound stream idle failover to one account switch
Nov 18, 2026
9a91f0d
feat(openai): add GPT-6.2 Sol and Astra standard model compatibility
Nov 18, 2026
76383ea
perf(openai): batch raw chat SSE flushes before upstream reads
Nov 18, 2026
100b583
fix(anthropic): preserve sparse cache-creation TTL snapshots in passt…
Nov 18, 2026
02fe90c
fix(anthropic): preserve cache creation TTL usage across compatibilit…
Nov 18, 2026
fc994ef
perf(ollama): preserve Chat reasoning with single-pass request edits
Nov 18, 2026
731d551
fix(billing): reconcile Anthropic cache TTL detail with usage logs
Nov 18, 2026
449cf40
test(openai): verify GPT-6.2 WebSocket eligibility and Composite routing
Nov 18, 2026
fa74ef0
fix(antigravity): retain streamed usage and add cache TTL database re…
Nov 19, 2026
7b24c3d
test(billing): cover TTL-only Anthropic cache in account statistics
Nov 19, 2026
3acfbe0
fix(gateway): harden streamed responses, OAuth rotation and shared le…
Nov 21, 2026
94da627
docs(backport): record gateway validation and remaining scope decisions
Nov 21, 2026
8d093df
test(gateway): satisfy lint and verify OAuth rollback without fixture…
Nov 21, 2026
6601085
test(gateway): make static analysis control flow and builder writes e…
Nov 21, 2026
29509a9
docs(backport): record verified code and blocked remote validation
Nov 21, 2026
aa2f369
fix(gateway): improve protocol fidelity, failover and usage accuracy
Nov 21, 2026
6605885
docs(backport): record validated gateway fixes and remaining review r…
Nov 21, 2026
b66b870
docs(backport): document remote CI block before consolidated PR
Nov 21, 2026
5b6733c
chore(ci): drop upstream-only CLA workflow from Lite
Nov 21, 2026
51cbaa4
chore(ci): remove obsolete Claude-branch RC image trigger
Nov 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 3 additions & 14 deletions .github/workflows/branch-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ on:
push:
tags:
- "internal-rc-*"
# 第三条等效触发:在裁剪分支上推送 commit message 含 [rc-build] 的提交。
# 适用于既没有 actions:write(workflow_dispatch API 403)、推 tag 也被
# git 代理拒绝的受限环境 —— 这是协作 agent 唯一能自助触发 RC 构建的通道。
# 关键字守卫见 check job 的 if:普通推送一律不构建,不会浪费额度。
branches:
- "claude/**"

# 同一分支的新构建取消掉还在跑的旧构建:省额度,也避免旧 commit 的镜像
# 在后面覆盖掉新 commit 的 internal-rc 标签。
Expand All @@ -60,12 +54,7 @@ jobs:
name: 预检与元数据
runs-on: ubuntu-latest
timeout-minutes: 5
# 分支 push 只有在 commit message 显式带 [rc-build] 时才构建;
# workflow_dispatch 与 internal-rc-* 标签触发不受该关键字限制。
if: >-
github.event_name != 'push' ||
startsWith(github.ref, 'refs/tags/') ||
contains(github.event.head_commit.message, '[rc-build]')
# 只有显式手动 dispatch 或 internal-rc-* 标签推送能进入此 job。
outputs:
sha: ${{ steps.meta.outputs.sha }}
short_sha: ${{ steps.meta.outputs.short_sha }}
Expand Down Expand Up @@ -99,8 +88,8 @@ jobs:

# 分支/标签短名做 tag-safe 处理:镜像 tag 只允许 [A-Za-z0-9_.-]
# 且不能以分隔符开头,分支名里的 / 等非法字符统一替换成 -,再限长,
# 避免超出 128 字符的 tag 上限。分支触发和 internal-rc-* 标签触发
# 时 github.ref_name 分别是分支名 / 标签名,这里统一处理。
# 避免超出 128 字符的 tag 上限。手动选择分支时使用分支名,
# internal-rc-* 标签触发时使用标签名,这里统一处理。
SAFE_REF="$(echo "${TRIGGER_REF_NAME}" \
| tr '[:upper:]' '[:lower:]' \
| sed -E 's/[^a-z0-9._-]+/-/g; s/^[.-]+//; s/[.-]+$//')"
Expand Down
69 changes: 0 additions & 69 deletions .github/workflows/cla.yml

This file was deleted.

5 changes: 1 addition & 4 deletions backend/cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,7 @@ func runMainServer() {

log.Println("Shutting down server...")

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

if err := app.Server.Shutdown(ctx); err != nil {
if err := shutdownHTTPServer(app.Server, time.Duration(cfg.Server.ShutdownDrainTimeout)*time.Second); err != nil {
log.Printf("Server forced to shutdown: %v", err)
}

Expand Down
25 changes: 25 additions & 0 deletions backend/cmd/server/shutdown.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"context"
"errors"
"net/http"
"time"
)

func shutdownHTTPServer(server *http.Server, timeout time.Duration) error {
if server == nil {
return nil
}
if timeout <= 0 {
timeout = 5 * time.Second
}
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
if err := server.Shutdown(ctx); err != nil {
// Shutdown stops accepting but does not close active long streams after
// the deadline. Close cancels their HTTP request contexts before cleanup.
return errors.Join(err, server.Close())
}
return nil
}
79 changes: 79 additions & 0 deletions backend/cmd/server/shutdown_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package main

import (
"context"
"errors"
"github.com/stretchr/testify/require"
"io"
"net/http"
"net/http/httptest"
"testing"
"time"
)

func TestShutdownHTTPServerClosesTimedOutStream(t *testing.T) {
entered := make(chan struct{})
canceled := make(chan struct{})
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/event-stream")
_, _ = io.WriteString(w, ": ready\n\n")
flusher, ok := w.(http.Flusher)
if !ok {
t.Error("stream writer does not support flushing")
return
}
flusher.Flush()
close(entered)
<-r.Context().Done()
close(canceled)
}))
defer server.Close()
resp, err := server.Client().Get(server.URL)
require.NoError(t, err)
defer func() { _ = resp.Body.Close() }()
<-entered
err = shutdownHTTPServer(server.Config, 20*time.Millisecond)
require.ErrorIs(t, err, context.DeadlineExceeded)
select {
case <-canceled:
case <-time.After(time.Second):
t.Error("drain timeout returned while the stream was still live")
server.CloseClientConnections()
}
}
func TestShutdownHTTPServerLetsActiveRequestFinish(t *testing.T) {
entered, finish := make(chan struct{}), make(chan struct{})
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
close(entered)
select {
case <-finish:
_, _ = io.WriteString(w, "complete")
case <-r.Context().Done():
t.Error("request canceled before drain timeout")
}
}))
defer server.Close()
result := make(chan error, 1)
go func() {
resp, err := server.Client().Get(server.URL)
if err != nil {
result <- err
return
}
defer func() { _ = resp.Body.Close() }()
b, err := io.ReadAll(resp.Body)
if string(b) != "complete" {
err = errors.New("incomplete response")
}
result <- err
}()
<-entered
stopped := make(chan error, 1)
go func() { stopped <- shutdownHTTPServer(server.Config, time.Second) }()
close(finish)
require.NoError(t, <-result)
require.NoError(t, <-stopped)
}
func TestShutdownHTTPServerNilIsSafe(t *testing.T) {
require.NoError(t, shutdownHTTPServer(nil, time.Second))
}
49 changes: 49 additions & 0 deletions backend/internal/config/backport_resource_config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package config

import (
"github.com/stretchr/testify/require"
"os"
"path/filepath"
"testing"
)

func TestBackportResourceDefaultsPreserveLitePolicy(t *testing.T) {
resetViperWithJWTSecret(t)
cfg, err := Load()
require.NoError(t, err)
require.Equal(t, 5, cfg.Server.ShutdownDrainTimeout)
require.Zero(t, cfg.Gateway.OpenAIWS.NativeReplayMaxSessionBytes)
require.EqualValues(t, 64<<20, cfg.Gateway.OpenAIWS.NativeReplayMaxTotalBytes)
require.Equal(t, 8192, cfg.Gateway.OpenAIWS.NativeReplayMaxItems)
require.Zero(t, cfg.Gateway.RequestBodyMemoryBudgetBytes)
}
func TestBackportResourceExplicitLimitsAndValidation(t *testing.T) {
for _, tc := range []struct {
name, body string
valid bool
}{
{"explicit", "server:\n shutdown_drain_timeout: 25\ngateway:\n openai_ws:\n native_replay_max_session_bytes: 4096\n native_replay_max_total_bytes: 8192\n native_replay_max_items: 32\n", true},
{"negative session", "gateway:\n openai_ws:\n native_replay_max_session_bytes: -1\n", false},
{"negative total", "gateway:\n openai_ws:\n native_replay_max_total_bytes: -1\n", false},
{"negative items", "gateway:\n openai_ws:\n native_replay_max_items: -1\n", false},
{"zero drain", "server:\n shutdown_drain_timeout: 0\n", false},
{"overflow drain", "server:\n shutdown_drain_timeout: 9223372036854775807\n", false},
} {
t.Run(tc.name, func(t *testing.T) {
resetViperWithJWTSecret(t)
p := filepath.Join(t.TempDir(), "config.yaml")
require.NoError(t, os.WriteFile(p, []byte(tc.body), 0600))
t.Setenv("CONFIG_FILE", p)
cfg, err := Load()
if !tc.valid {
require.Error(t, err)
return
}
require.NoError(t, err)
require.Equal(t, 25, cfg.Server.ShutdownDrainTimeout)
require.EqualValues(t, 4096, cfg.Gateway.OpenAIWS.NativeReplayMaxSessionBytes)
require.EqualValues(t, 8192, cfg.Gateway.OpenAIWS.NativeReplayMaxTotalBytes)
require.Equal(t, 32, cfg.Gateway.OpenAIWS.NativeReplayMaxItems)
})
}
}
43 changes: 34 additions & 9 deletions backend/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,16 @@ type PricingConfig struct {
type ServerConfig struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
Mode string `mapstructure:"mode"` // debug/release
EnableServerTiming bool `mapstructure:"enable_server_timing"` // Admin UI Server-Timing response header
ReadHeaderTimeout int `mapstructure:"read_header_timeout"` // 读取请求头超时(秒)
MaxHeaderBytes int `mapstructure:"max_header_bytes"` // 请求头最大字节数(HTTP/2 映射为 header-list 上限)
IdleTimeout int `mapstructure:"idle_timeout"` // 空闲连接超时(秒)
TrustedProxies []string `mapstructure:"trusted_proxies"` // 可信代理列表(CIDR/IP)
TrustedProxiesConfigured bool `mapstructure:"-" json:"-" yaml:"-"` // 是否显式配置了可信代理列表
MaxRequestBodySize int64 `mapstructure:"max_request_body_size"` // 全局最大请求体限制
H2C H2CConfig `mapstructure:"h2c"` // HTTP/2 Cleartext 配置
Mode string `mapstructure:"mode"` // debug/release
EnableServerTiming bool `mapstructure:"enable_server_timing"` // Admin UI Server-Timing response header
ReadHeaderTimeout int `mapstructure:"read_header_timeout"` // 读取请求头超时(秒)
MaxHeaderBytes int `mapstructure:"max_header_bytes"` // 请求头最大字节数(HTTP/2 映射为 header-list 上限)
ShutdownDrainTimeout int `mapstructure:"shutdown_drain_timeout"` // seconds; default 5 preserves existing deployment behavior
IdleTimeout int `mapstructure:"idle_timeout"` // 空闲连接超时(秒)
TrustedProxies []string `mapstructure:"trusted_proxies"` // 可信代理列表(CIDR/IP)
TrustedProxiesConfigured bool `mapstructure:"-" json:"-" yaml:"-"` // 是否显式配置了可信代理列表
MaxRequestBodySize int64 `mapstructure:"max_request_body_size"` // 全局最大请求体限制
H2C H2CConfig `mapstructure:"h2c"` // HTTP/2 Cleartext 配置
}

// H2CConfig HTTP/2 Cleartext 配置
Expand Down Expand Up @@ -540,6 +541,10 @@ type GatewayConfig struct {
// 等待上游响应头的超时时间(秒),0表示无超时
// 注意:这不影响流式数据传输,只控制等待响应头的时间
ResponseHeaderTimeout int `mapstructure:"response_header_timeout"`
// AntigravityFirstByteTimeout: Antigravity 上游首字节超时(秒),0表示禁用。
// 覆盖等待响应头以及响应头已返回但响应体尚无任何字节的阶段;
// 超时且尚未向客户端写出语义内容时切换账号。
AntigravityFirstByteTimeout int `mapstructure:"antigravity_first_byte_timeout"`
// OpenAIResponseHeaderTimeout: OpenAI/Codex 上游等待响应头的超时时间(秒),0表示无超时
// OpenAI/Codex 请求可能在上游排队较久;默认不使用通用响应头超时截断。
OpenAIResponseHeaderTimeout int `mapstructure:"openai_response_header_timeout"`
Expand Down Expand Up @@ -863,6 +868,11 @@ type GatewayOpenAIWSConfig struct {
PrewarmGenerateEnabled bool `mapstructure:"prewarm_generate_enabled"`
// ClientReadLimitBytes: 入站客户端 WS 单帧读取上限。
ClientReadLimitBytes int64 `mapstructure:"client_read_limit_bytes"`
// Native replay is opt-in. A zero budget preserves fail-closed later-turn behavior.
// Limits cover retained current-window history, including item descriptors.
NativeReplayMaxSessionBytes int64 `mapstructure:"native_replay_max_session_bytes"`
NativeReplayMaxTotalBytes int64 `mapstructure:"native_replay_max_total_bytes"`
NativeReplayMaxItems int `mapstructure:"native_replay_max_items"`
// HTTPBridgeEnabled: 首包过大时,保持客户端 WS,改用 HTTP Responses 上游。
HTTPBridgeEnabled bool `mapstructure:"http_bridge_enabled"`
// HTTPBridgeThresholdBytes: 触发 HTTP bridge 的入站 WS payload 阈值。
Expand Down Expand Up @@ -1629,6 +1639,7 @@ func setDefaults() {
viper.SetDefault("server.enable_server_timing", false)
viper.SetDefault("server.read_header_timeout", 10) // 10秒读取请求头
viper.SetDefault("server.max_header_bytes", 64*1024)
viper.SetDefault("server.shutdown_drain_timeout", 5)
viper.SetDefault("server.idle_timeout", 120) // 120秒空闲超时
viper.SetDefault("server.max_request_body_size", int64(256*1024*1024))
// H2C 默认配置
Expand Down Expand Up @@ -1868,6 +1879,7 @@ func setDefaults() {

// Gateway
viper.SetDefault("gateway.response_header_timeout", 600) // 600秒(10分钟)等待上游响应头,LLM高负载时可能排队较久
viper.SetDefault("gateway.antigravity_first_byte_timeout", 0)
viper.SetDefault("gateway.openai_response_header_timeout", 0)
viper.SetDefault("gateway.disable_openai_transport_error_cooldown", false)
viper.SetDefault("gateway.grok_response_header_timeout", 120)
Expand Down Expand Up @@ -1902,6 +1914,9 @@ func setDefaults() {
viper.SetDefault("gateway.openai_ws.store_disabled_force_new_conn", true)
viper.SetDefault("gateway.openai_ws.prewarm_generate_enabled", false)
viper.SetDefault("gateway.openai_ws.client_read_limit_bytes", 64*1024*1024)
viper.SetDefault("gateway.openai_ws.native_replay_max_session_bytes", 0)
viper.SetDefault("gateway.openai_ws.native_replay_max_total_bytes", 64*1024*1024)
viper.SetDefault("gateway.openai_ws.native_replay_max_items", 8192)
viper.SetDefault("gateway.openai_ws.http_bridge_enabled", true)
viper.SetDefault("gateway.openai_ws.http_bridge_threshold_bytes", 15*1024*1024)
viper.SetDefault("gateway.openai_ws.responses_websockets", false)
Expand Down Expand Up @@ -2154,6 +2169,9 @@ func (c *Config) Validate() error {
if c.Server.MaxHeaderBytes < 8*1024 || c.Server.MaxHeaderBytes > 1024*1024 {
return fmt.Errorf("server.max_header_bytes must be between 8192 and 1048576 bytes")
}
if c.Server.ShutdownDrainTimeout <= 0 || c.Server.ShutdownDrainTimeout > 86400 {
return fmt.Errorf("server.shutdown_drain_timeout must be between 1 and 86400 seconds")
}
if c.Server.IdleTimeout <= 0 {
return fmt.Errorf("server.idle_timeout must be positive")
}
Expand Down Expand Up @@ -2537,6 +2555,10 @@ func (c *Config) Validate() error {
if c.Gateway.ResponseHeaderTimeout < 0 {
return fmt.Errorf("gateway.response_header_timeout must be non-negative")
}
if c.Gateway.AntigravityFirstByteTimeout < 0 || c.Gateway.AntigravityFirstByteTimeout > 600 ||
(c.Gateway.AntigravityFirstByteTimeout > 0 && c.Gateway.AntigravityFirstByteTimeout < 5) {
return fmt.Errorf("gateway.antigravity_first_byte_timeout must be 0 or between 5-600 seconds")
}
if c.Gateway.OpenAIResponseHeaderTimeout < 0 {
return fmt.Errorf("gateway.openai_response_header_timeout must be non-negative")
}
Expand Down Expand Up @@ -2697,6 +2719,9 @@ func (c *Config) Validate() error {
if c.Gateway.OpenAIWS.ClientReadLimitBytes <= 0 {
return fmt.Errorf("gateway.openai_ws.client_read_limit_bytes must be positive")
}
if c.Gateway.OpenAIWS.NativeReplayMaxSessionBytes < 0 || c.Gateway.OpenAIWS.NativeReplayMaxTotalBytes < 0 || c.Gateway.OpenAIWS.NativeReplayMaxItems < 0 {
return fmt.Errorf("gateway.openai_ws native replay budgets must be non-negative")
}
if c.Gateway.OpenAIWS.HTTPBridgeThresholdBytes < 0 {
return fmt.Errorf("gateway.openai_ws.http_bridge_threshold_bytes must be non-negative")
}
Expand Down
Loading