* feat(dashboard): add RADAR_ENABLED flag (default off) * feat(db): radar feed cache + settings with encrypted supporter key * feat(radar): signed feed sync with pinned key and version floor - feedSchema.ts: Zod v4 schema mirroring the server feed format (discriminated union on budget.kind, enum constraints, etc.) - pinnedKeys.ts: Ed25519 SPKI-DER pinned key + env override for forks - verify.ts: signature verification over exact wire bytes, never throws - sync.ts: full download/verify/validate/cache pipeline with injectable deps, feature-flag gate, opt-in gate, version floor (numeric compare), and sanitized error reasons (no stack traces) - 40 tests covering: contract hash, key handling, sig verification, schema validation, version compare, all sync paths (disabled, opt_out, invalid_signature, invalid_schema, stale, updated, error), auth header injection, and cache-untouched assertions for every failure mode * feat(radar): read-time overlay merge rules over the free catalog Pure function applyFeed() merges the cached Radar feed over the static baseline catalog at read time, honoring 4 rules: 1. Feed never overwrites a local override field. 2. enabled:false disables the entry with disabledBy:"radar" provenance. 3. User-added entry NOT in the feed survives untouched. 4. User deletion tombstone prevents feed resurrection. getRadarCatalog() accessor in index.ts: flag off / no cache / corrupt payload all fall back to baseline. Valid cache applies the overlay and returns feed metadata (version, tier, fetchedAt). TDD: 19 tests (4 rules + dedup + origin + accessor flag/cache/corrupt/ valid/bad-feed + baselineToMergedEntries converter). * feat(dashboard): radar catalog and guided setup screens - API routes: GET /api/radar/catalog, POST /api/radar/sync, POST /api/radar/settings - All gated on RADAR_ENABLED flag (404 when off) - Error responses via buildErrorBody(), never raw stack/message - Settings never echoes clear supporter key (masked omr_****<last4>) - Sync delegates to syncRadar() server-side, never proxies feed URL - Dashboard pages: - /dashboard/radar: 4 states (flag off, opt-in pending, empty, populated) - /dashboard/radar/setup?provider=X: guided setup with steps, key URL, test connection - Uses existing Card component and next-intl patterns - Sidebar: radar entry in costs group with icon - i18n: pt-BR and en keys for radarPage and radarSetupPage namespaces - Tests: - radar-api-routes.test.ts: 11 tests (flag-off 404, flag-on shape, error sanitization) - radar-page-state.test.ts: 5 tests (pure state logic) - All 90 radar tests pass (including prior 74) * docs(radar): module doc and flag-off inertia test Add docs/frameworks/RADAR.md covering the flag gate, the separate data-sync opt-in and privacy promise, the Ed25519 signature/pinned-key security model, tiers, the read-time overlay merge rules, and the self-hosting env vars — plus index entries in CLAUDE.md/AGENTS.md/docs/README.md/REPOSITORY_MAP.md. Document RADAR_FEED_URL and RADAR_FEED_PUBKEY in .env.example and docs/reference/ENVIRONMENT.md to satisfy check:env-doc-sync, which was failing on this branch since the sync.ts commit added the reads. Add tests/unit/radar-inertia.test.ts as the single canonical place asserting the "RADAR_ENABLED off => zero behavioral delta" claim end to end: the three /api/radar/* routes 404, the flag resolves to the definition default with no override, getRadarCatalog() returns exactly the baseline without touching the cache, and computeFreeModelTotals() keeps its pinned values with the Radar module imported alongside it. * fix(db): renumber radar migration to 135 after collision with 134 The base branch introduced 134_proxy_logs_egress_ip while this branch carried 134_radar_cache_settings; the migration runner rejects duplicate numeric prefixes. This migration has never been applied to a real database (the PR is unmerged), so no retroactive isSchemaAlreadyApplied guard is needed. * i18n(radar): translate radar catalog and setup strings to all locales The UI-coverage ratchet measures (present - placeholder) / total_en, so the __MISSING__ sentinels that i18n:sync-ui writes do not count as covered — only real translations restore the metric. Scoped to this PR's namespaces (radarPage, radarSetupPage, sidebar.radar*) instead of a bulk sync, which would have pulled ~978 unrelated pending keys into this diff. Placeholders and code identifiers verified preserved across all 1682 strings. * fix(radar): trust the served-tier header instead of the signed body field The signed feed body always carries tier:"live" by design (one signed artifact per version — rewriting the field server-side per request would break the exact-bytes Ed25519 signature). The server now returns the tier ACTUALLY served via the x-omniroute-feed-tier response header, so free users on a delayed community snapshot no longer see "Ao vivo (tempo real)" in the UI. sync.ts now reads and validates that header (falling back to the body's tier only when the header is absent or holds an unrecognized value) and stores the served tier in the cache; index.ts already surfaces cache.tier to the UI unchanged. * test(combo): shorten an assert message that exceeded the line limit The assertion added by #9507 was 104 chars, so prettier reformatted it into five lines on the next commit that touched the file, pushing it past its frozen size (3449) and failing check:file-size. The message is shortened (the issue reference stays in the comment directly above); the assertion itself is unchanged, and the file is back to 3448 lines and prettier-clean. * i18n(radar): use the canonical zh-TW glossary terms The machine translation produced retired renderings the glossary gate blocks: 供應商 for provider (canonical 提供者) and 文檔 for documentation (canonical 文件). Fixed across the 11 affected radar strings; tests/unit/i18n-glossary-consistency-check.test.ts is back to 17/17. * fix(radar): point the default feed URL at the domain that exists radar.omniroute.dev was a placeholder for a domain that was never registered, so an out-of-the-box sync would fail DNS resolution for every user. The live feed is served from radar.omniroute.online (the subdomain the design always specified), now behind Cloudflare TLS. Forks still override it via RADAR_FEED_URL. --------- Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
11 KiB
title, version, lastUpdated
| title | version | lastUpdated |
|---|---|---|
| Radar Free-Model Catalog | 3.8.50 | 2026-08-05 |
Radar Free-Model Catalog
Source of truth:
src/lib/radar/,src/lib/db/radar.ts,src/app/api/radar/Last updated: 2026-08-05 — v3.8.50
Radar is an optional add-on that overlays a signed, freshly-curated free-model
catalog on top of the release baseline (FREE_MODEL_BUDGETS in
open-sse/config/freeModelCatalog.ts). It exists because the free-tier landscape moves
faster than release cadence — providers add, shrink, or discontinue free quotas between
releases, and the baseline catalog can only be refreshed when a new version ships.
Nothing that is free today stops being free. Radar never removes or paywalls a baseline entry; it only refreshes limits/status fields at read time and can layer in newly-discovered free models between releases. The baseline catalog itself is never mutated on disk — see Read-time overlay merge rules below.
Flag: RADAR_ENABLED (default off)
Radar is gated end-to-end by the RADAR_ENABLED feature flag
(src/shared/constants/featureFlagDefinitions.ts, category policies,
defaultValue: "false").
When the flag is off, the surface does not exist:
GET /api/radar/catalog,POST /api/radar/sync,POST /api/radar/settingsall return404before touching any Radar module.- The dashboard screens (
/dashboard/radar,/dashboard/radar/setup) rendernotFound(). getRadarCatalog()(src/lib/radar/index.ts) returns the untouched baseline — same entry count, same values, every entry taggedorigin: "baseline"— and never reads the feed cache.- No network call is ever made;
syncRadar()(src/lib/radar/sync.ts) returns{ status: "disabled" }at step 1 without touchingfetch.
This is a strict superset gate: flipping the flag on unlocks the screens, nothing more. It does not upload data, does not start a background sync, and does not change routing or model selection — see the separate opt-in below.
Data sync is a SEPARATE opt-in — the privacy promise
Turning RADAR_ENABLED on only unlocks the UI. Syncing the feed requires a second,
independent opt-in stored in radar_settings.opt_in (src/lib/db/radar.ts,
migration 136_radar_cache_settings.sql). syncRadar() checks the flag and the
opt-in before making any network call:
Flag off → { status: "disabled" } — no network call
Opt-in false → { status: "opt_out" } — no network call
When both are on, the sync path is:
GET <feed base URL>/v1/catalog/latestwith an optionalAuthorization: Bearer <supporter key>header (see below).- Nothing about the request, the operator, or their traffic is uploaded — it is a plain, unauthenticated-by-default GET. OmniRoute never posts usage data, provider configuration, or model traffic to the feed service.
- The response is verified, validated, and cached locally (see Security model). Nothing else touches the network for Radar.
The supporter key is an optional Bearer token (radar_settings.supporter_key)
that lets the feed service decide which tier to serve (see
Tiers). It is:
- Stored encrypted at rest with the same AES-256-GCM
encrypt()/decrypt()helpers (src/lib/db/encryption.ts) used for provider credentials. - Set via
POST /api/radar/settings({ supporterKey: "omr_" + 40 hex chars }) and never echoed back — the response returns a masked form (omr_****abcd). - Sent to the feed service as a Bearer token on the sync GET — nothing else about the key ever leaves the client.
Security model
Ed25519 signature over exact bytes
The feed payload is signed with Ed25519. verifyFeedBytes()
(src/lib/radar/verify.ts) verifies the signature over the exact response bytes
received over the wire — the payload is never re-serialized before verification, so a
byte-for-byte re-encoding cannot silently invalidate or bypass the signature check.
Verification failure (invalid_signature) aborts the sync before the payload is ever
parsed or cached.
Pinned public key + rotation
The verifying public key is pinned in src/lib/radar/pinnedKeys.ts
(PINNED_FEED_PUBLIC_KEYS), an array so a new key can be prepended ahead of a
rotation while old cached feeds signed with a previous key remain valid until
re-synced.
Fork-friendly env overrides
Two env vars let forks and self-hosters point the client at their own feed instead of the default OmniRoute service — see How to self-host a feed below:
| Var | Purpose |
|---|---|
RADAR_FEED_URL |
Overrides the feed base URL (default https://radar.omniroute.online). |
RADAR_FEED_PUBKEY |
Overrides the pinned public key (base64-DER SPKI or PEM), replacing the built-in array with this single key. |
Version floor
syncRadar() rejects a downloaded feed whose version is not strictly newer than the
currently cached version (compareVersions(), dotted YYYY.MM.DD.n comparison) —
{ status: "stale" }. This prevents a compromised or misconfigured feed endpoint from
rolling a client back to an older, differently-signed payload.
Schema validation
The downloaded bytes are parsed and validated against RadarFeedSchema
(src/lib/radar/feedSchema.ts, a Zod schema) after signature verification. A
schema mismatch returns { status: "invalid_schema" } and the cache is left
untouched. The cached payload is defensively re-validated again on every read
(getRadarCatalog()) — a corrupted or hand-edited cache row falls back to the
baseline rather than being served.
Tiers: community and live
The feed schema carries a tier: "community" | "live" field, decided server-side
by the feed service based on the request (presence and validity of the supporter key)
— the client never decides its own tier.
community— the free catalog delayed by roughly 30 days behind the freshest data. This is what an unauthenticated or invalid-key request receives.live— the freshest catalog, served to requests carrying a valid supporter key.
An invalid or expired supporter key degrades to community — it is never an
error. The sync path only distinguishes signature/schema/version failures (all
recoverable, all non-fatal to the cached state) from a successful { status: "updated", version, tier }. There is no tier-specific error path a client needs to
handle.
Read-time overlay merge rules
applyFeed() (src/lib/radar/applyFeed.ts) merges the cached feed over the
static baseline at read time, inside getRadarCatalog(). The baseline array
(FREE_MODEL_BUDGETS) is never mutated — a MergedEntry[] is computed fresh on every
call.
Four rules, in order of precedence:
- Feed never overwrites a local override. Per-field: if the operator has
customized a field on an entry (
localOverridesmap, keyedprovider:modelId), the feed's value for that specific field is skipped — the operator's value wins. enabled: falsedisables the entry, with provenance. A feed entry that turns an entry off setsenabled: falseanddisabledBy: "radar"on the merged result, so the UI can explain why an entry went from available to disabled.- A user-added entry not present in the feed survives untouched. Entries that only exist in the baseline (or were added locally) and have no corresponding feed entry pass through unchanged.
- A tombstoned entry is never resurrected. If the operator explicitly deleted an
entry (
tombstonesset), the feed re-adding thatprovider:modelIdin a later version does not bring it back.
Provenance markers
Every merged entry carries an origin field the UI renders as a badge:
"baseline"— untouched from the static release catalog."radar"— one or more fields were refreshed by the feed."local"— the operator has at least one local override on this entry (local overrides always win over the feed per rule 1, regardless of what the feed says).
Local surfaces — never a feed proxy
Three local routes back the UI, all under src/app/api/radar/:
| Route | Method | Purpose |
|---|---|---|
/api/radar/catalog |
GET | Returns the merged catalog (getRadarCatalog()) from the local cache. |
/api/radar/sync |
POST | Triggers syncRadar() server-side; returns the resulting status. |
/api/radar/settings |
POST | Sets opt-in and/or the (encrypted) supporter key. |
Hard rule: these routes never proxy the feed service. The browser only ever talks
to the local OmniRoute server; syncRadar() is the single module in the whole client
that touches the network for Radar (src/lib/radar/sync.ts), and it always runs
server-side, never client-side. This keeps the feed URL and any supporter key
out of client-facing network traffic entirely.
All three routes return 404 when RADAR_ENABLED is off (see
Flag above), and route error responses through
buildErrorBody()/sanitizeErrorMessage() per the repo-wide error-sanitization rule
(docs/security/ERROR_SANITIZATION.md).
How to self-host a feed
A fork or self-hoster that wants full control over the catalog can run their own feed service without touching client code:
- Serve a
GET /v1/catalog/latestendpoint returning a JSON body that satisfiesRadarFeedSchema(src/lib/radar/feedSchema.ts) — top-levelfeed: "omniroute-radar",schemaVersion: 1,version,tier,providers,models,quirks, andtotals. - Sign the exact response bytes with an Ed25519 key pair and return the base64
signature in the
x-omniroute-feed-signatureresponse header. - Set
RADAR_FEED_URLto the new base URL andRADAR_FEED_PUBKEYto the matching public key (base64-DER SPKI or PEM) — see the env var reference. - Enable
RADAR_ENABLEDand opt in viaPOST /api/radar/settings({ optIn: true }).
No other code changes are required — verifyFeedBytes() picks up the override
automatically (getFeedPublicKeys() in src/lib/radar/pinnedKeys.ts), and version
comparison, schema validation, and the merge rules apply identically to a self-hosted
feed.
Related docs
docs/security/ERROR_SANITIZATION.md— the error-response pattern the three/api/radar/*routes follow.docs/reference/ENVIRONMENT.md—RADAR_FEED_URL/RADAR_FEED_PUBKEYreference.