feat: sync deployed v1.0.0-rc.38-custom.42

Sync production source including routing, billing, Astra detection and public uptime. Update custom build instructions and license packaging.
This commit is contained in:
cneicy committed 2026-09-26 04:49:11 +08:00
1 parent aa6c3f50f4
commit ceddfd3d6b
828 files changed
+122253 -13702

No files matched your search

+54
View File
@@ -9,6 +9,60 @@ import (
"github.com/stretchr/testify/require"
)
func TestRequestDetailsUserProjection(t *testing.T) {
other := NewLogOther()
other.SetPublic("model_ratio", 1)
other.SetAdmin("request_details", map[string]any{"session_id": "private-session", "correlation_key": "private-key"})
other.SetAdmin("request_policy", []any{map[string]any{"candidates": []string{"private-channel"}}})
log := &Log{CorrelationKey: "private-key", Other: other.JSONString()}
formatUserLogs([]*Log{log}, 0)
encoded, err := common.Marshal(log)
require.NoError(t, err)
require.NotContains(t, string(encoded), "private-")
require.NotContains(t, string(encoded), "request_details")
require.NotContains(t, string(encoded), "request_policy")
require.Contains(t, log.Other, "model_ratio")
}
func TestAstraRejectionUserProjectionShowsModelWithoutRoute(t *testing.T) {
other := NewLogOther()
other.SetPublic("error_code", "response_model_rejected")
other.SetAdmin("request_details", map[string]any{
"session_id": "private-session",
"model_guard": map[string]any{"attempts": []map[string]any{
{"expected_model": "gpt-6-astra", "returned_model": "gpt-5.6-luna", "reason": "model_mismatch", "channel_id": 1},
{"expected_model": "gpt-6-astra", "returned_model": "gpt-5.6-luna", "reason": "model_mismatch", "channel_id": 1},
}},
})
log := &Log{Other: other.JSONString()}
formatUserLogs([]*Log{log}, 0)
var projected map[string]any
require.NoError(t, common.UnmarshalJsonStr(log.Other, &projected))
assert.Equal(t, "model_mismatch", projected["model_guard_result"])
assert.Equal(t, "gpt-5.6-luna", projected["response_model"].(map[string]any)["returned_model"])
assert.NotContains(t, log.Other, "admin_info")
assert.NotContains(t, log.Other, "private-session")
assert.NotContains(t, log.Other, "channel_id")
other.SetAdmin("request_details", map[string]any{"model_guard": map[string]any{"attempts": []map[string]any{
{"expected_model": "gpt-6-astra", "reason": "confirmation_timeout", "channel_id": 1},
}}})
log.Other = other.JSONString()
formatUserLogs([]*Log{log}, 0)
projected = nil
require.NoError(t, common.UnmarshalJsonStr(log.Other, &projected))
assert.Equal(t, "confirmation_timeout", projected["model_guard_result"])
assert.NotContains(t, projected, "response_model")
other.SetPublic("error_code", "upstream_error")
log.Other = other.JSONString()
formatUserLogs([]*Log{log}, 0)
projected = nil
require.NoError(t, common.UnmarshalJsonStr(log.Other, &projected))
assert.NotContains(t, projected, "model_guard_result")
assert.NotContains(t, projected, "response_model")
}
// TestFormatUserLogsStripsQuotaSaturation verifies the admin-only quota
// saturation marker (nested under other.admin_info) is removed for non-admin
// log views, since formatUserLogs strips the whole admin_info object.