fix(channel-monitor-v2): preserve migration checksums and privacy defaults
This commit is contained in:
@@ -977,7 +977,7 @@ func TestAPIContracts(t *testing.T) {
|
||||
"account_quota_notify_emails": [],
|
||||
"channel_monitor_enabled": true,
|
||||
"channel_monitor_mode": "v2",
|
||||
"channel_monitor_hide_throughput": false,
|
||||
"channel_monitor_hide_throughput": true,
|
||||
"channel_monitor_default_interval_seconds": 60,
|
||||
"available_channels_enabled": false,
|
||||
"model_plaza_enabled": false,
|
||||
@@ -1282,7 +1282,7 @@ func TestAPIContracts(t *testing.T) {
|
||||
"account_quota_notify_emails": [],
|
||||
"channel_monitor_enabled": true,
|
||||
"channel_monitor_mode": "v2",
|
||||
"channel_monitor_hide_throughput": false,
|
||||
"channel_monitor_hide_throughput": true,
|
||||
"channel_monitor_default_interval_seconds": 60,
|
||||
"available_channels_enabled": false,
|
||||
"model_plaza_enabled": false,
|
||||
|
||||
@@ -352,7 +352,7 @@ func (s *SettingService) GetPublicSettings(ctx context.Context) (*PublicSettings
|
||||
ChannelMonitorEnabled: !isFalseSettingValue(settings[SettingKeyChannelMonitorEnabled]),
|
||||
ChannelMonitorMode: normalizeChannelMonitorMode(settings[SettingKeyChannelMonitorMode]),
|
||||
ChannelMonitorDefaultIntervalSeconds: parseChannelMonitorInterval(settings[SettingKeyChannelMonitorDefaultIntervalSeconds]),
|
||||
ChannelMonitorHideThroughput: settings[SettingKeyChannelMonitorHideThroughput] == "true",
|
||||
ChannelMonitorHideThroughput: !isFalseSettingValue(settings[SettingKeyChannelMonitorHideThroughput]),
|
||||
|
||||
AvailableChannelsEnabled: settings[SettingKeyAvailableChannelsEnabled] == "true",
|
||||
|
||||
@@ -461,7 +461,7 @@ func (s *SettingService) GetChannelMonitorRuntime(ctx context.Context) ChannelMo
|
||||
Enabled: !isFalseSettingValue(vals[SettingKeyChannelMonitorEnabled]),
|
||||
Mode: normalizeChannelMonitorMode(vals[SettingKeyChannelMonitorMode]),
|
||||
DefaultIntervalSeconds: parseChannelMonitorInterval(vals[SettingKeyChannelMonitorDefaultIntervalSeconds]),
|
||||
HideThroughput: vals[SettingKeyChannelMonitorHideThroughput] != "false",
|
||||
HideThroughput: !isFalseSettingValue(vals[SettingKeyChannelMonitorHideThroughput]),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,21 @@ func TestSettingService_GetPublicSettings_ExposesCompactHomeEnabled(t *testing.T
|
||||
require.False(t, missingSettings.CompactHomeEnabled)
|
||||
}
|
||||
|
||||
func TestSettingService_ChannelMonitorHideThroughputDefaultsToPrivate(t *testing.T) {
|
||||
missing := NewSettingService(&settingPublicRepoStub{values: map[string]string{}}, &config.Config{}).GetChannelMonitorRuntime(context.Background())
|
||||
require.True(t, missing.HideThroughput)
|
||||
public, err := NewSettingService(&settingPublicRepoStub{values: map[string]string{}}, &config.Config{}).GetPublicSettings(context.Background())
|
||||
require.NoError(t, err)
|
||||
require.True(t, public.ChannelMonitorHideThroughput)
|
||||
|
||||
for _, value := range []string{"false", "0", "off", "disabled"} {
|
||||
runtime := NewSettingService(&settingPublicRepoStub{values: map[string]string{
|
||||
SettingKeyChannelMonitorHideThroughput: value,
|
||||
}}, &config.Config{}).GetChannelMonitorRuntime(context.Background())
|
||||
require.False(t, runtime.HideThroughput, "value=%q", value)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSettingService_GetPublicSettings_ExposesForceEmailOnThirdPartySignup(t *testing.T) {
|
||||
repo := &settingPublicRepoStub{
|
||||
values: map[string]string{
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
-- Factory presets for Channel Monitor V2 config:
|
||||
-- 1) ignored_error_categories: non-ops client/policy failures that should not
|
||||
-- dominate health error_rate by default (still shown greyed in breakdown).
|
||||
-- 2) health_thresholds cache floors are intentionally left at the tolerant
|
||||
-- zero/zero defaults from migration 198. Platforms without prompt caching
|
||||
-- must not be marked unhealthy by factory configuration.
|
||||
-- 2) health_thresholds cache floors: 85% watch / 60% critical (higher is better).
|
||||
--
|
||||
-- Only apply when the row still looks like factory empty ignore list and/or
|
||||
-- zero cache thresholds (operator customizations are left alone).
|
||||
@@ -21,3 +19,13 @@ SET ignored_error_categories = ARRAY[
|
||||
]::text[]
|
||||
WHERE id = 1
|
||||
AND COALESCE(cardinality(ignored_error_categories), 0) = 0;
|
||||
|
||||
UPDATE channel_monitor_v2_config
|
||||
SET health_thresholds = health_thresholds
|
||||
|| jsonb_build_object(
|
||||
'warning_cache_rate', 0.85,
|
||||
'critical_cache_rate', 0.60
|
||||
)
|
||||
WHERE id = 1
|
||||
AND COALESCE((health_thresholds->>'warning_cache_rate')::float8, 0) = 0
|
||||
AND COALESCE((health_thresholds->>'critical_cache_rate')::float8, 0) = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Soft switch: hide RPM/TPM throughput rates on user-facing Channel Monitor V2.
|
||||
-- Default true (rates hidden). Admins always see full metrics.
|
||||
-- Default false (rates visible). Admins always see full metrics.
|
||||
INSERT INTO settings (key, value)
|
||||
VALUES ('channel_monitor_hide_throughput', 'true')
|
||||
VALUES ('channel_monitor_hide_throughput', 'false')
|
||||
ON CONFLICT (key) DO NOTHING;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Correct factory defaults introduced by migrations 203 and 204 without
|
||||
-- mutating those already-applied migration files (which are checksum-locked).
|
||||
-- The setting was factory-created as false by migration 204. Existing
|
||||
-- installations need the same privacy-preserving default as new installs.
|
||||
UPDATE settings
|
||||
SET value = 'true', updated_at = NOW()
|
||||
WHERE key = 'channel_monitor_hide_throughput'
|
||||
AND LOWER(TRIM(value)) IN ('false', '0', 'off', 'disabled');
|
||||
Reference in New Issue
Block a user