Files
OmniRoute/docs/adr/006-translator-registry.md
diegosouzapw f44ec7e1f2 feat: complete all 46 tasks — ADRs, eval framework, compliance, a11y, CLI, Playwright specs (Batch B)
T-30 — ADRs:
- 6 ADRs: SQLite, Fallback Strategy, OAuth, JS+JSDoc, Single-Tenant, Translator Registry

T-33 — JSDoc Coverage:
- Full JSDoc on all new modules (100% exported functions documented)

T-35 — Accessibility:
- a11yAudit.js: lightweight WCAG AA checker (aria-label, dialog role, alt text, labels)

T-38 — Password Reset CLI:
- bin/reset-password.mjs: interactive CLI tool for admin password reset

T-39 — Playwright Specs:
- tests/e2e/responsiveSpecs.mjs: viewports (375/768/1280), 4 pages, test matrix

T-42 — Eval Framework:
- evalRunner.js: 4 strategies (exact, contains, regex, custom) + golden set (10 cases)

T-43 — Compliance:
- audit_log table, noLog opt-out per API key, LOG_RETENTION_DAYS cleanup

TASKS.md: 46/46 Concluído 
Tests: 144/144 pass (119 existing + 25 new)
2026-02-14 19:18:02 -03:00

1.6 KiB

ADR-006: Translator Registry Pattern

Date: 2025-12-01
Status: Accepted
Deciders: @diegosouzapw

Context

OmniRoute translates requests between different LLM API formats (OpenAI ↔ Anthropic ↔ Google ↔ etc.). Each provider has a unique request/response schema. The translator must:

  • Convert incoming requests to the target provider's format
  • Convert streaming responses back to the client's expected format
  • Handle provider-specific features (tool calls, vision, system prompts)

Decision

Use a registry pattern for translators:

  1. Each provider pair has a translator module in src/sse/translators/
  2. Translators are registered by (sourceFormat, targetFormat) key
  3. The translateRequest() function auto-detects source format and applies the appropriate translator
  4. Translators handle both request translation and response stream mapping

Key translators:

  • openai → anthropic (and reverse)
  • openai → google (and reverse)
  • anthropic → google (and reverse)
  • Identity translators for same-format routing

Consequences

Positive

  • Adding a new provider requires only a new translator module
  • Each translator is independently testable
  • Auto-detection reduces configuration burden on users
  • Supports chained translation (A → B → C) if needed

Negative

  • O(n²) translator combinations as providers grow (mitigated by identity translators)
  • Some edge cases in format conversion (e.g., tool call schemas differ significantly)

Neutral

  • The Translator Playground UI provides visual testing of translation chains
  • Performance overhead is minimal (JSON transformation, no network calls)