Repository navigation
Conversation
TenantConf.fallback_model said an over-quota request without one passes through; since #150 it is refused. The ledger_usage note claimed usage is never capped; billing_record clamps every token count. The config generation's cache-key role was stated at three sites; the cache-key hash keeps it. The README now names both failover triggers.
…g sends GatewayResponse.step was set on video replies and read nowhere (views serve the vendor payload, never the response struct). In pump_sse every path that sets aborted inside the frame loop already returns, so the trailing check never fired. role::STORAGE came with the initial import; no code creates such a turn, and one a client sent would reach the vendor, so the estimate now counts it.
ledger_replay_batch and usage_rollup_advance built the same (minute, tenant, user, model) bucket entry inline.
json! serializes every interpolated expression, so an owned Value placed in it is deep-copied and dropped: the Anthropic content_block_start block, the synthesized Responses usage, the replayed message_start usage (already a clone), and the MCP JSON-RPC id. Each envelope is built first and the value moved in.
Six two-line inline WHY comments and four multi-line docs on private items, each compressed to one line with its fact intact.
On a keep-alive connection every streamed response ended about 44 ms late: the SSE tail goes out as small writes, Nagle holds the last one until the previous segment is acknowledged, and the client delays that ACK. Measured on Linux with oha against the mock upstream: one streaming request at a time ran at 22 requests/s with a p50 of 48 ms, while the same request on a fresh connection (curl) took under 1 ms. SDK clients and reverse proxies both pool connections, so every stream paid it.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Whole-repo review round over main@55abd059: every production file read in full (82 files, 29.5k lines), README and docs checked against the code, a LOC-justify pass, then a full Linux regression on a test host. The run turned up one real defect, a ~44 ms stall at the end of every streamed response on a keep-alive connection. Everything else is comment corrections, small cuts and ownership fixes.
Commits
TCP_NODELAYon each accepted connection (axum::serve::ListenerExt::tap_io).TenantConf.fallback_modelstill said a request over quota with no fallback passes through. Since model quota: refuse an over-quota request with no usable fallback #150 it is refused. The in-memoryledger_usagenote said usage is never capped, butbilling_recordclamps every token count. The config generation's cache-key role was stated at three places. The README now names both triggers for account failover.GatewayResponse.step: written on video replies and read nowhere.pump_sse: a trailingif out.aborted { break }that every abort path had already left.role::STORAGE: came with the initial import and no code creates such a turn. A client-sent one reaches the vendor, so the estimate counts it now.json!calls that deep-copied an ownedValue.docs/performance.mdrecords the stall and the numbers below.Net: production −33 lines, comments −20, tests −8.
Evidence
Gates
-D warnings) clean.cargo test --workspaceagainst Postgres 17 + Redis 7: 763 passed / 0 failed / 4 ignored.gwtest_*databases and Redis keys created by the env-gated suites.Stream stall (Linux, oha against the mock upstream, main vs this branch):
/v1/chat/completionsstream, 1 connection/v1/messagesstream, 1 connectionHot path: instructions per request (
perf stat, 200k requests per arm, arms interleaved with order swapped)./v1/messagesthroughput: from ~1.4k to 40k–90k req/s.Live vendor matrix (real keys, through the branch build): 191/194.
grokgroup; no Bedrock key is currently valid.xaigroup then reran 23/23 on both main and the branch.