1731 Commits
Author SHA1 Message Date
9qeklajcandGitHub 18965b4ea4 Merge pull request #629 from jeroenubbink/fix/bill-served-candidate
fix: bill and forward failover requests as the provider that actually served
2026-07-22 23:23:07 +02:00
9qeklajc 97dc10a8ad harden impl. 2026-07-22 23:10:27 +02:00
9qeklajc 87850c97b9 Merge branch 'main' into fix/streaming-billing-finalization 2026-07-22 21:21:06 +02:00
9qeklajcandGitHub fcc87718ff Merge pull request #621 from Routstr/fix/propagate-cashu-storage-errors
fix: propagate Cashu storage errors
2026-07-22 21:18:10 +02:00
Jeroen UbbinkandClaude Fable 5 50437a1cc6 refactor: require explicit settlement identity at the billing seams
Make model_obj/provider_fee required (still nullable) on
adjust_payment_for_tokens, get_x_cashu_cost and the private pricing
helpers so a call site that fails to thread the served candidate is a
type error instead of a silent fallback to alias-map re-derivation.
calculate_cost keeps its defaults as the one documented fallback seam.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 15:13:40 +02:00
Jeroen UbbinkandClaude Fable 5 7f5a0cf1ae refactor: drop the dead model-instance alias map
get_model_instance now derives from the candidate map, leaving the
module-level alias map write-only; remove it so there is a single
authoritative alias source.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 15:12:21 +02:00
Jeroen UbbinkandClaude Fable 5 3f850c54f4 fix: re-reserve the serving candidate's max cost on failover
Admission and reservation were sized once to the best-ranked candidate's
max cost while settlement bills the candidate that actually serves, so a
failover to a pricier candidate could settle far beyond the admitted
envelope and consume balance reserved by other in-flight requests. Before
trying a fallback candidate, raise the reservation to its own envelope;
reject candidates the key cannot cover, exactly as admission would have
had they been ranked first.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 15:12:21 +02:00
Jeroen UbbinkandClaude Fable 5 df4d4c44e6 fix: fail over with each candidate provider's own model
The failover loop resolved a single Model for the request and reused it
for every provider: a fallback provider was asked to serve the routing
winner's model id and billed at the winner's pricing and fee. The alias
map now keeps (model, provider) candidate pairs, the proxy rebinds both
per attempt, and forwarding, max-cost echo, and settlement all use the
candidate actually being tried. On a failover serve the response's
model field now names the serving candidate's id.

The unified candidate lookup also applies the version-suffix strip
(-YYYYMMDD) that model resolution already had, so version-suffixed
requests no longer resolve a model yet 400 with "no provider found".

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 15:12:21 +02:00
Jeroen UbbinkandClaude Fable 5 02cd2cfeec test: fix concurrent mock leak in overrun finalization tests
Two tests entered patch("routstr.auth.calculate_cost", ...) inside
concurrently gathered tasks. Interleaved patch exits restore in the
wrong order, leaving the mock permanently installed for every later
test in the session. Hoist the patch around the gather.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 15:09:41 +02:00
Jeroen UbbinkandClaude Fable 5 0aebfc6dbe fix: bill the serving provider's fee on the USD-cost path
The USD-cost path (and the litellm pricing fallback) resolved the
provider fee via get_provider_for_model(model_id)[0] — the best-ranked
provider for the alias, not the one that served. Settlement callers in
the upstream handlers now pass their own provider_fee through
adjust_payment_for_tokens / get_x_cashu_cost into calculate_cost; the
string-derived fallback remains for callers without a serving provider.
Configured model pricing is unaffected (the fee is already baked into
cached pricing).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 15:09:41 +02:00
Jeroen UbbinkandClaude Fable 5 b76fa17f81 fix: thread the served model into x-cashu settlement pricing
X-Cashu handlers do not rewrite the upstream's echoed model string, so
get_x_cashu_cost previously priced whatever wire name the upstream
reported — the most collapse-prone alias lookup of all. The routed Model
is now threaded from forward_x_cashu_request through the chat and
Responses handler chains (and the litellm messages path) into
get_x_cashu_cost, so cost and refund are computed from the model that
actually served.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 15:09:41 +02:00
Jeroen UbbinkandClaude Fable 5 ed8ac914f9 fix: thread the served model into bearer settlement pricing
Settlement previously re-derived pricing from the response's model string
through the alias map, which resolves to the best-ranked candidate for
that alias — not necessarily the provider/model that actually served the
request. adjust_payment_for_tokens and calculate_cost now accept the
routed Model and bill its pricing directly; the string lookup remains as
a warning fallback for callers without routed identity (e.g. the generic
streaming finalizer).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 15:09:41 +02:00
thefux 6c762f0c3d fix: type reconciliation report mappings 2026-07-22 00:09:36 +00:00
thefux 2b4f70442a fix: recover stale Cashu reservations safely 2026-07-22 00:06:33 +00:00
9qeklajcandGitHub 99724cc5f5 Merge pull request #620 from Routstr/fix/fee-payout-crash-guard
fix: guard fee payouts against crash double-payments
2026-07-22 00:41:04 +02:00
9qeklajcandGitHub e19f679609 Merge pull request #622 from Routstr/fix/retry-cashu-storage-writes
fix: retry critical Cashu storage writes
2026-07-22 00:39:21 +02:00
9qeklajcandGitHub bd1edcef26 Merge pull request #624 from Routstr/coverage-tests-pr-619
test: extract passing coverage tests from #619
2026-07-19 12:54:51 +02:00
9qeklajc 22a94a68a4 test: extract passing coverage tests from #619 2026-07-18 15:58:54 +02:00
9qeklajc 4defe4f227 fix: identify reservation releases 2026-07-18 14:59:57 +02:00
9qeklajc f8125a8a2d Merge branch 'fix/fee-payout-crash-guard' into fix/streaming-billing-finalization 2026-07-18 14:57:15 +02:00
9qeklajc 999a5634fa fix: snapshot reservation cleanup state 2026-07-18 14:54:06 +02:00
9qeklajc 2c218cce49 fix: make reservation cleanup atomic 2026-07-18 14:48:02 +02:00
9qeklajc fa0b366f9a fix: fail safely on streaming billing errors 2026-07-18 14:42:03 +02:00
9qeklajc a3a4d69ed3 fix: make storage retries idempotent 2026-07-18 14:33:40 +02:00
9qeklajc c9533c872a fix: retry critical Cashu storage writes 2026-07-18 14:28:18 +02:00
9qeklajc 90da3803c6 fix: preserve caller recovery on storage errors 2026-07-18 14:22:16 +02:00
9qeklajc 8b3b59e176 fix: propagate Cashu transaction storage errors 2026-07-18 14:16:30 +02:00
9qeklajc be5e323c68 test: cover payout restart and migration safety 2026-07-18 14:13:20 +02:00
9qeklajc f6d1a41728 fix: checkpoint fee payouts before sending 2026-07-18 14:08:41 +02:00
9qeklajcandGitHub b3bf1f0e90 Merge pull request #613 from Routstr/fix-overflowing-in-mobile
fix overflow
2026-07-17 21:51:38 +02:00
9qeklajcandGitHub 3035292d2a Merge pull request #575 from Routstr/ehbp-proxy-refactor
EHBP proxy support, Tinfoil direct integration, rate limiting, wallet fixes and more
2026-07-17 20:22:14 +02:00
9qeklajcandGitHub ac436d0862 Merge pull request #618 from jeroenubbink/config/docker-compose-restart-unless-stopped
config: Ensure docker compose services are restarted unless explicitly stopped
2026-07-17 20:21:34 +02:00
Jeroen Ubbink 19082231f9 config: Ensure docker compose services are restarted unless explicitly stopped 2026-07-17 14:14:27 +02:00
9qeklajc 281607108c fix(ui): use dynamic viewport heights 2026-07-16 13:25:44 +02:00
9qeklajcandGitHub 8314f3c1b0 Merge pull request #614 from Routstr/pr-575-review-fixes
Fix review blockers: hop-by-hop headers, exact attestation routing, doc updates
2026-07-16 13:18:56 +02:00
9qeklajcandGitHub 1a9041766b Merge pull request #616 from Routstr/fix/ppq-upstream-inference-cost
fix: bill PPQ.AI BYOK upstream_inference_cost + BYOK fee
2026-07-16 13:16:30 +02:00
redshift 01c01fe8ad fix: bill PPQ.AI BYOK upstream_inference_cost + BYOK fee
PPQ.AI (BYOK) requests were billed at ~5% of their true cost because
_resolve_usd_cost fell through to usage.cost (a small BYOK routing fee)
instead of using cost_details.upstream_inference_cost (the real inference
cost). The proxy operator absorbed the inference cost.

The fix adds a BYOK-specific branch in _resolve_usd_cost: when is_byok is
true and cost_details.upstream_inference_cost is present, bill
upstream_inference_cost + byok_fee — what PPQ actually deducts from the
balance. Non-BYOK providers (e.g. OpenRouter) are unaffected because their
usage.cost already equals upstream_inference_cost.

Regression tests mirror the live glm-5.2-fast request from GitHub issue #615,
asserting the corrected billing (940,274 msats vs the old 45,202 msats — a
20.8× undercharge).

Closes #615
2026-07-16 17:01:55 +08:00
redshift 892aed61cc Fix mypy: move type: ignore onto ASGITransport line 2026-07-16 16:43:52 +08:00
9qeklajc c6733dbb62 fix overflow 2026-07-14 21:47:26 +02:00
redshift 57fef44ce7 Merge branch 'main' of https://github.com/Routstr/routstr-core into ehbp-proxy-refactor 2026-07-13 11:14:15 +08:00
9qeklajcandGitHub c671d277d3 Merge pull request #603 from Routstr/refund-sweep-behavior-tests
test: exercise refund sweep state transitions
2026-07-13 00:09:30 +02:00
9qeklajc 9460e24f21 fix: persist outbound Cashu tokens before sending 2026-07-13 00:07:00 +02:00
9qeklajcandGitHub f31929b538 Merge pull request #610 from Routstr/fix-mypy
fix mypy
2026-07-12 23:35:35 +02:00
9qeklajc 129ea7bb76 fix mypy 2026-07-12 23:33:22 +02:00
9qeklajcandGitHub b88c6d84fa Merge pull request #608 from Routstr/fix/refund-sweep-test-coverage
test: cover periodic refund sweep behavior
2026-07-12 23:06:51 +02:00
9qeklajcandGitHub 238beb3e52 Merge pull request #605 from Routstr/fix/admin-withdraw-transaction-audit
fix: record admin withdrawals as outgoing transactions
2026-07-12 15:05:20 +02:00
9qeklajcandGitHub dc833d9f5f Merge pull request #602 from Routstr/fix/auto-topup-transaction-recovery
fix: make auto-topup tokens recoverable
2026-07-12 14:57:03 +02:00
9qeklajc 31e7ff8fbd test: cover periodic refund sweep behavior 2026-07-12 14:54:26 +02:00
9qeklajc a1850dfa55 fix: record admin withdrawals as outgoing transactions 2026-07-12 14:49:51 +02:00
9qeklajcandGitHub 9eacabde0e Merge pull request #604 from Routstr/revert-600-fix/retry-cashu-transaction-storage
Revert "Retry Cashu transaction storage on transient DB failures"
2026-07-12 14:49:28 +02:00