Files
OmniRoute/tests/unit/autoCombo
Hermes Developer 4150167a63 feat(routing): subscription-first auto groupings (auto/subscription, auto/thrifty)
OmniRoute answers "is this model free?" (hidePaidModels) and "can this
connection ever bill me?" (STRICT_ZERO_COST), but both fail closed and every
paid-side mechanism (cost-optimized, budgetCap, the cost-saver mode pack) is
tier-agnostic. Nothing answers "use the plan quota I already pay for; when it
runs out either stop, or step up one rung at a time; and come back when it
resets."

The blocker was that billing is a property of the CONNECTION, not the model:
classifyTier() keys on (provider, model), while the same model is plan-included
through an OAuth connection and metered through an API-key one. auth_type is
not a safe proxy in either direction. So this adds a curated per-connection
billing catalog, hand-set from published terms, following the same pattern
FreeModelBudget.hardStopGuaranteed already established. Uncurated resolves to
unknown and is consumed as metered, so new providers start outside the
subscription rung.

Two ids, sharing one rung model (subscription > keyless > free > cheap >
premium):

  - auto/subscription: rung 0 only, hard-stop overage only, live quota verified
    per connection. Fails CLOSED — an empty pool is the intended answer.
  - auto/thrifty: all rungs ordered, exhausted ones gated out, scoring still
    runs within the survivors. Fails OPEN one rung at a time.

Both reuse STRICT_ZERO_COST's connection-safety invariant: each connection in
allowedConnectionIds is verified individually and the array is rewritten to the
surviving subset, so autoStrategy.ts can only dispatch to a verified account.

Reset re-entry: a cached quota reading whose own resetAt has passed is now
stale regardless of TTL, and rung eligibility is recomputed per pool build with
no persisted demotion that could outlive a reset. clampCooldownToReset() is
implemented and tested but not yet wired — the quota cache is invalidated in
auth.ts before any cooldown is written, so resetAt must be captured earlier
there; that hot-path change belongs in its own PR.

Both ids are opt-in by being requested; no existing pool, strategy or default
changes. Settings are tuning-only on purpose (no enabled flag that could leave
auto/subscription silently serving paid capacity).

Also corrects docs/guides/TIERS.md, which advertised a combo strategy named
"subscription" that has never existed in ROUTING_STRATEGY_VALUES.
2026-08-22 11:55:05 -04:00
..