Expose Arena ELO sync in feature flags (#3821)

Adds ARENA_ELO_SYNC_ENABLED to the Dashboard Feature Flags registry (DB-overridable),
routes Arena ELO startup/status checks through the shared feature-flag resolver while
preserving the existing env fallback, and refreshes env docs (adds the missing
STREAM_READINESS_TIMEOUT_MS example) so env/doc sync stays green.

Integrated into release/v3.8.25.

Co-authored-by: R.D. <rogerproself@gmail.com>
This commit is contained in:
Randi
2026-06-14 07:45:02 -04:00
committed by GitHub
parent ebf06b5e6c
commit 31e4e46ef9
11 changed files with 143 additions and 41 deletions

View File

@@ -843,6 +843,7 @@
"batchConceptRetentionNote": "Results and error files are retained for 30 days (Anthropic: 29 days)"
},
"featureFlagOmnirouteEmergencyFallbackDescription": "Route budget-exhausted requests to the emergency free fallback provider/model.",
"featureFlagArenaEloSyncEnabledDescription": "Enable periodic Arena AI leaderboard ELO sync for model intelligence rankings.",
"sidebar": {
"home": "Home",
"dashboard": "Dashboard",
@@ -8720,7 +8721,7 @@
"subtitle": "Best free providers ranked by model ELO scores from Arena AI leaderboards",
"loading": "Loading rankings...",
"errorLoading": "Failed to load rankings",
"emptyState": "No rankings available yet. Arena ELO data syncs on startup (daily) — check back shortly, or trigger a manual sync. Set ARENA_ELO_SYNC_ENABLED=false to opt out.",
"emptyState": "No rankings available yet. Arena ELO data syncs on startup (daily) — check back shortly, or trigger a manual sync. Disable Arena ELO Sync in Feature Flags or set ARENA_ELO_SYNC_ENABLED=false to opt out.",
"bestModel": "Best",
"allCategories": "All Categories",
"categoryDefault": "Default",

View File

@@ -265,18 +265,18 @@ export async function registerNodejs(): Promise<void> {
console.warn("[STARTUP] Auto-refresh daemon failed to start (non-fatal):", msg);
}
// Arena ELO sync: model intelligence from the Arena AI leaderboard, powering the
// Free Provider Rankings page. On by default (opt out with ARENA_ELO_SYNC_ENABLED=false).
// Non-blocking — the initial sync is fire-and-forget and never fatal.
if (process.env.ARENA_ELO_SYNC_ENABLED !== "false") {
try {
const { initArenaEloSync } = await import("@/lib/arenaEloSync");
await initArenaEloSync();
try {
// Arena ELO sync: model intelligence from the Arena AI leaderboard, powering the
// Free Provider Rankings page. On by default; configurable from Dashboard Feature Flags.
// Non-blocking — the initial sync is fire-and-forget and never fatal.
const { initArenaEloSync } = await import("@/lib/arenaEloSync");
const started = await initArenaEloSync();
if (started) {
console.log("[STARTUP] Arena ELO sync initialized");
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn("[STARTUP] Arena ELO sync failed to start (non-fatal):", msg);
}
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn("[STARTUP] Arena ELO sync failed to start (non-fatal):", msg);
}
// Pricing sync: opt-in external pricing data (self-gated by PRICING_SYNC_ENABLED inside

View File

@@ -7,9 +7,11 @@
*
* Resolution order: user overrides > synced arena ELO > defaults
*
* On by default; opt out via ARENA_ELO_SYNC_ENABLED=false.
* On by default; opt out via Dashboard Feature Flags or ARENA_ELO_SYNC_ENABLED=false.
*/
import { isArenaEloSyncEnabled } from "@/shared/utils/featureFlags";
import { backupDbFile } from "./db/backup";
import {
bulkUpsertModelIntelligence,
@@ -176,6 +178,23 @@ let activeSyncIntervalMs = SYNC_INTERVAL_MS;
let firstSyncDone = false;
let syncInProgress = false;
function getErrorMessage(error: unknown): string {
return error instanceof Error ? error.message : String(error);
}
function getEffectiveArenaEloSyncEnabled(): boolean {
try {
return isArenaEloSyncEnabled();
} catch (error) {
console.warn(
`[ARENA_ELO_SYNC] Failed to resolve ARENA_ELO_SYNC_ENABLED feature flag: ${getErrorMessage(
error
)}`
);
return process.env.ARENA_ELO_SYNC_ENABLED !== "false";
}
}
// ─── Model name normalization ────────────────────────────
/**
@@ -507,7 +526,7 @@ export function stopArenaEloSync(): void {
* next scheduled sync time, interval, and active sources.
*/
export function getArenaEloSyncStatus(): SyncStatus {
const enabled = process.env.ARENA_ELO_SYNC_ENABLED !== "false";
const enabled = getEffectiveArenaEloSyncEnabled();
return {
enabled,
lastSync: lastSyncTime,
@@ -524,21 +543,23 @@ export function getArenaEloSyncStatus(): SyncStatus {
// ─── Init (called from server-init.ts) ───────────────────
/**
* Initialize Arena ELO sync if enabled via environment variable.
* Initialize Arena ELO sync if enabled via feature flag configuration.
*
* Reads `ARENA_ELO_SYNC_ENABLED` (default: true; set to `false` to opt out).
* Reads `ARENA_ELO_SYNC_ENABLED` (default: true; set to `false` to opt out)
* through the feature flag resolver, so DB overrides from the dashboard apply.
* When enabled, starts periodic sync with the interval from `ARENA_ELO_SYNC_INTERVAL`
* (default: 86400 seconds / daily).
*
* All errors during initialization or the initial sync are caught and logged
* — initialization is never fatal.
*/
export async function initArenaEloSync(): Promise<void> {
if (process.env.ARENA_ELO_SYNC_ENABLED === "false") {
export async function initArenaEloSync(): Promise<boolean> {
if (!getEffectiveArenaEloSyncEnabled()) {
console.log(
"[ARENA_ELO_SYNC] Disabled (ARENA_ELO_SYNC_ENABLED=false). Unset or =true to enable."
"[ARENA_ELO_SYNC] Disabled by the effective ARENA_ELO_SYNC_ENABLED feature flag. Enable it from Dashboard Feature Flags, unset the env var, or set it to true to enable."
);
return;
return false;
}
startPeriodicSync();
return true;
}

View File

@@ -133,14 +133,12 @@ async function startServer() {
}
// Arena ELO sync: model intelligence from leaderboard data (non-blocking, never fatal).
// On by default; opt out with ARENA_ELO_SYNC_ENABLED=false.
if (process.env.ARENA_ELO_SYNC_ENABLED !== "false") {
try {
const { initArenaEloSync } = await import("./lib/arenaEloSync");
await initArenaEloSync();
} catch (err) {
startupLog.warn({ error: getErrorMessage(err) }, "Arena ELO sync could not initialize");
}
// On by default; opt out with Dashboard Feature Flags or ARENA_ELO_SYNC_ENABLED=false.
try {
const { initArenaEloSync } = await import("./lib/arenaEloSync");
await initArenaEloSync();
} catch (err) {
startupLog.warn({ error: getErrorMessage(err) }, "Arena ELO sync could not initialize");
}
}

View File

@@ -199,7 +199,7 @@ export const FEATURE_FLAG_DEFINITIONS: FeatureFlagDefinition[] = [
warningLevel: "info",
},
// ──────────────── Runtime (9) ────────────────
// ──────────────── Runtime (10) ────────────────
{
key: "OMNIROUTE_MCP_ENFORCE_SCOPES",
label: "MCP Enforce Scopes",
@@ -302,6 +302,17 @@ export const FEATURE_FLAG_DEFINITIONS: FeatureFlagDefinition[] = [
requiresRestart: false,
warningLevel: "info",
},
{
key: "ARENA_ELO_SYNC_ENABLED",
label: "Arena ELO Sync",
description: "Enable periodic Arena AI leaderboard ELO sync for model intelligence rankings.",
descriptionI18nKey: "featureFlagArenaEloSyncEnabledDescription",
category: "runtime",
defaultValue: "true",
type: "boolean",
requiresRestart: false,
warningLevel: "info",
},
// ──────────────── CLI (3) ────────────────
{

View File

@@ -75,3 +75,7 @@ export function isCcCompatibleProviderEnabled(): boolean {
export function isModelCatalogNamesEnabled(): boolean {
return isFeatureFlagEnabled("MODEL_CATALOG_INCLUDE_NAMES");
}
export function isArenaEloSyncEnabled(): boolean {
return isFeatureFlagEnabled("ARENA_ELO_SYNC_ENABLED");
}