Changeset 0.22.0.1 (#94)

This commit is contained in:
2026-03-02 01:55:19 +00:00
parent 12e03cec8b
commit 06c4e2a5a1
33 changed files with 1929 additions and 418 deletions

View File

@@ -864,3 +864,76 @@ type ChannelKB struct {
Enabled bool `json:"enabled" db:"enabled"`
DocumentCount int `json:"document_count" db:"document_count"`
}
// =========================================
// PROVIDER HEALTH (v0.22.0)
// =========================================
// ProviderStatus represents the derived health state.
type ProviderStatus string
const (
StatusHealthy ProviderStatus = "healthy"
StatusDegraded ProviderStatus = "degraded"
StatusDown ProviderStatus = "down"
StatusUnknown ProviderStatus = "unknown"
)
// ProviderHealthWindow is one hourly bucket of health metrics.
type ProviderHealthWindow struct {
ID string `json:"id" db:"id"`
ProviderConfigID string `json:"provider_config_id" db:"provider_config_id"`
WindowStart time.Time `json:"window_start" db:"window_start"`
RequestCount int `json:"request_count" db:"request_count"`
ErrorCount int `json:"error_count" db:"error_count"`
TimeoutCount int `json:"timeout_count" db:"timeout_count"`
TotalLatencyMs int64 `json:"total_latency_ms" db:"total_latency_ms"`
MaxLatencyMs int `json:"max_latency_ms" db:"max_latency_ms"`
LastError *string `json:"last_error,omitempty" db:"last_error"`
LastErrorAt *string `json:"last_error_at,omitempty" db:"last_error_at"`
}
// AvgLatencyMs returns the average latency, or 0 if no requests.
func (w *ProviderHealthWindow) AvgLatencyMs() int {
if w.RequestCount == 0 {
return 0
}
return int(w.TotalLatencyMs / int64(w.RequestCount))
}
// ErrorRate returns the error fraction, or 0 if no requests.
func (w *ProviderHealthWindow) ErrorRate() float64 {
if w.RequestCount == 0 {
return 0
}
return float64(w.ErrorCount) / float64(w.RequestCount)
}
// ProviderHealthSummary is the API response for a provider's current health.
type ProviderHealthSummary struct {
ProviderConfigID string `json:"provider_config_id"`
ProviderName string `json:"provider_name,omitempty"`
Status ProviderStatus `json:"status"`
RequestCount int `json:"request_count"` // last hour
ErrorRate float64 `json:"error_rate"` // last hour
AvgLatencyMs int `json:"avg_latency_ms"` // last hour
MaxLatencyMs int `json:"max_latency_ms"` // last hour
LastError *string `json:"last_error,omitempty"`
LastErrorAt *string `json:"last_error_at,omitempty"`
}
// =========================================
// CAPABILITY OVERRIDES (v0.22.0)
// =========================================
// CapabilityOverride is an admin correction for a model's capabilities.
type CapabilityOverride struct {
ID string `json:"id" db:"id"`
ProviderConfigID *string `json:"provider_config_id,omitempty" db:"provider_config_id"`
ModelID string `json:"model_id" db:"model_id"`
Field string `json:"field" db:"field"`
Value string `json:"value" db:"value"`
SetBy *string `json:"set_by,omitempty" db:"set_by"`
CreatedAt string `json:"created_at" db:"created_at"`
}