Complete coderouter private-beta routing reliability

Merged
LA
2mo ago
+955-146

Adds manager-scoped account removal with encrypted-credential cascade and final-account route-token revocation, transient-safe provider reads, multi-account failure routing, refresh/KMS/RDS race tests, scrubbed alert signals, usage freshness metadata, Server-Timing, and accurate landing-page support states. Also includes the production backend needed by experimental cr pi.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Improves CodeRouter private beta reliability with safe, retried provider reads, multi-account failover, and secure manager-scoped deletion that cascades encrypted credentials and revokes route tokens when a team loses its last account. Adds usage freshness fields with Server-Timing mirrored in headers, rate-limit telemetry, and updates the landing page to reflect private beta and experimental cr pi.

  • New Features

    • DELETE api/coderouter/accounts/[accountId] (manage scope, team-scoped) with encrypted-credential cascade and final route-token revocation; returns legacyCleanupPending when rollback cleanup fails.
    • Account listing now returns usageAsOf, usageAgeSeconds, cacheMaxAgeSeconds, and Server-Timing; mirrors timing in x-coderouter-server-timing. Landing page clarifies: Codex and OpenCode Go available, Pi experimental, Claude Max and API-key routing coming soon.
  • Bug Fixes

    • Adds fetchProviderRead for one safe retry of read-only provider calls; used in Codex models, usage reads, and OpenCode config; reports rate limits and applies cooldowns; routes around refreshing/broken accounts.
    • Hardens refresh with lease coordination, rotated-token persistence via CAS, terminal error classification, and scrubbed error reporting via reportCoderouterFailure; coalesces Vercel AWS role exchanges for KMS.

Summary by CodeRabbit

  • New Features

    • Added permission- and team-scoped CodeRouter account removal with cleanup status reporting.
    • Account listings now include usage metadata, cache age, request timing, and improved cache handling.
    • Improved provider routing with transient-failure retries and fallback to healthy accounts.
    • Added shared credential refresh handling for more reliable encrypted provider access.
  • Bug Fixes

    • Improved credential refresh recovery and temporary provider failure handling.
    • Enhanced error reporting while protecting sensitive credentials.
  • Documentation

    • Updated CodeRouter messaging to reflect private beta availability and supported providers.