Commit Graph
336 Commits
Author SHA1 Message Date
lukaszraczylo 3e1750ddb9 fix(admin-ui): cap user detail cache, gate breakdown on ranking, restore single chevron
The per-user detail cache grew without limit and now keeps the 20 most recently fetched users. Spend refresh built the breakdown from a stale ranking after the ranking failed or was superseded, and now skips that step. The FontAwesome stylesheet overrode Tailwind hidden and showed two accordion chevrons, so it now loads in a low cascade layer.
2026-11-08 02:35:06 +00:00
lukaszraczylo 8c5e4fbcda fix(admin-ui): clear data on key change and show empty Spend chart
A new API key kept the previous key's data on screen until each store refreshed. All data stores now reset when the key changes. The Spend breakdown chart showed a column of identical zero ticks for an empty range, so it now shows an empty message. A stray quote in the Reliability page markup is removed.
2026-11-08 02:32:09 +00:00
lukaszraczylo 0a05dfc035 fix(admin-ui): keep sign and precision in CSV, YAML and context labels
CSV export prefixed negative numbers with an apostrophe, which corrupted the data. YAML emitted NaN and Infinity as plain strings. Context windows such as 1500 read as 2k. Numbers now skip the CSV formula guard, non-finite values use YAML float forms, and counts below 10k keep one decimal.
2026-11-08 02:29:28 +00:00
lukaszraczylo e985fded45 feat(admin-ui): hide runaway budget line and link form errors to inputs
The burn-down chart drew the budget line even when it was more than ten times the spend, which flattened the spend curve. The line now hides with a note. Limits, pricing, model metadata and grant forms mark invalid inputs with aria-invalid and aria-describedby.
2026-11-08 02:28:27 +00:00
lukaszraczylo 1ec8aacee7 feat(admin-ui): fit the Models catalog table without horizontal scroll
The table had 11 columns and scrolled at 1280px, hiding p50, p95 and error rate. It now shows compact price, one token column and a short error header. Context window stays in the model chip hover, and the :free flag moves into the price cell.
2026-11-08 02:27:10 +00:00
lukaszraczylo 429edb873d fix(admin-ui): ship FontAwesome CSS in bundle to satisfy style-src 'self'
FontAwesome injected a style element at runtime. The admin CSP blocks that and logged a console error on every load. The UI now imports the stylesheet and disables auto injection.
2026-11-08 02:24:47 +00:00
lukaszraczylo 758d7c7020 feat(admin-ui): alias labels, active-provider legends, denser tables and readable money
Label configured model aliases with an alias badge wherever a model id shows.
List only providers with traffic in the window in provider chart legends.
Page long tables, show a scroll shadow on wide ones and drop the duplicate model link.
Show costs with thousands separators and magnitude-scaled decimals on cards and chart axes.
Use whole-number ticks for count charts and replace all-zero charts with a message.
Back off polling after failures.
Keep the CSV status region from widening the page on phones.
Regenerate admin_assets_gen.go.
2026-11-08 02:22:22 +00:00
lukaszraczylo 05a7c114f5 fix(admin-ui): page-level loading, stale and form fixes
Fetch the consumers list on the user detail page so admin and grant data show on a deep link.
Gate Recent errors, the Spend total and the forecast card on load state instead of showing zeros.
Show a stale notice on top lists when a refresh fails.
Clear the target name when the target kind changes.
Ignore out-of-order config responses.
Wrap long group names and event messages, and announce projected budget overruns to screen readers.
Regenerate admin_assets_gen.go.
2026-11-08 02:04:23 +00:00
lukaszraczylo fcfb298077 fix(admin-ui): stale-data notice, request timeout and dedupe, hash and format edge cases
Show a persistent notice when a refresh fails while old data is on screen.
Add retry to the Targets and Access Matrix error states.
Give tables names, skeletons a status role and CSV export a live region.
Abort admin requests after 15 seconds and share concurrent identical GETs.
Show a reload prompt when a lazy page chunk fails to load.
Ignore prototype keys in the location hash.
Stop formatContextWindow emitting 1000k, round latency before the 1s cutoff,
and treat NaN as not enough data in the month projection.
Regenerate admin_assets_gen.go.
2026-11-08 01:59:34 +00:00
lukaszraczylo 5f5efa5a8d docs: state the concurrent budget overshoot bound
The README claimed an at-most-one-request overshoot. Requests in flight
together all pass the pre-check, so the bound is concurrency times the
largest request cost.
2026-11-03 01:05:27 +00:00
lukaszraczylo d9ec84ebc0 fix(retry): stop the backoff timer when the wait ends early
time.After keeps its timer alive until it fires on go 1.22 semantics,
so each cancelled retry wait pinned a timer for up to 2s. A stoppable
timer releases it at once.
2026-11-03 00:51:15 +00:00
lukaszraczylo a96ecb2dc9 test(admin): guard that every Config string key is redaction-classified
A secret field added under a new JSON key would pass through the config
endpoint unredacted because the redactor matches keys by name. The test
fails until each string key is redacted or declared non-secret.
2026-11-03 00:29:20 +00:00
lukaszraczylo 8998d70654 fix(translate): cap the gemini image count at 10
A client could send a huge n and the translator forwarded it as the Imagen sampleCount. The translator now refuses n above 10 with a request error.
2026-11-03 00:27:13 +00:00
lukaszraczylo 138ced884e fix(translate): saturate out-of-range integer fields
Go leaves a float to int64 conversion implementation-defined when the value is out of range, so a huge max_tokens could become a negative number on some architectures. The conversion now saturates to the int64 range and refuses NaN.
2026-11-03 00:27:11 +00:00
lukaszraczylo 1236aa4901 fix(resp): size a bulk reply buffer by bytes received
The parser allocated the full declared bulk length before any payload arrived, so a stalled peer could pin 64 MiB per connection. The buffer now starts at 64 KiB and doubles only after the previous capacity has fully arrived. A test measures the allocation.
2026-11-03 00:25:38 +00:00
lukaszraczylo 1a2cea3417 fix(users): cap the users file read at 16 MiB
The loader read the whole users file into memory on the request path, whatever its size. The loader now reads at most the cap plus one byte and refuses a larger file. The last good user set stays active.
2026-11-03 00:23:01 +00:00
lukaszraczylo f9418cc860 fix(passthrough): release the tee budget when the copy panics
A panic inside the response copy skipped the caller's release, so the tee kept its reserved bytes in the shared budget for good. The proxy now releases the tee and keeps unwinding. A test reproduces the leak.
2026-11-03 00:22:16 +00:00
lukaszraczylo 15e0415164 fix(registry): keep known models on an empty discovery answer
A successful but empty discovery answer replaced the known model set with nothing, so a flapping upstream made every discovered model return 404 until the next refresh. The registry now treats that answer as a failure. It keeps the previous set and counts the failure toward the discovery breaker.
2026-11-03 00:21:01 +00:00
lukaszraczylo 9f13cb719a Merge branch 'fix/l4' 2026-11-03 00:12:09 +00:00
lukaszraczylo 3c91046433 fix(passthrough): reserve tee budget with compare-and-swap
The reserve step added first and checked after. Concurrent reservations saw a transient overshoot and were denied while room remained. The step now claims bytes only when they fit, so used never exceeds the limit.
2026-11-03 00:04:54 +00:00
lukaszraczylo c851e237eb fix(sse): count retained line cost in the event size cap
An upstream could send millions of empty data lines in one event. The cap counted one byte per line, but each line kept a 16-byte string header in memory. The cap now counts the header too, so retained memory stays within the cap.
2026-11-03 00:04:52 +00:00
lukaszraczylo cbffcb4061 fix(concurrency): clamp learned limit below the ceiling
An overload seen with many requests in flight set the learned limit above the ceiling. The learner now clamps the value to one below the ceiling.
2026-11-02 23:57:07 +00:00
lukaszraczylo 36ad65c96e fix(retry): reject non-positive backoff
A zero or negative backoff passed validation and made retries fire with no pause. The config loader now rejects it. The wait ladder compares the backoff to the cap before it multiplies, so a very large backoff cannot overflow.
2026-11-02 23:57:05 +00:00
lukaszraczylo 53a7fa74c1 fix(providers): do not follow upstream redirects
The adapter client re-sent provider API key headers to any redirect target. The client now returns the 3xx response to the caller. A test pins this behaviour.
2026-11-02 23:57:01 +00:00
lukaszraczylo 6d3c8bf9b7 fix(cache): skip embeddings in the response cache
Embeddings responses are large and rarely repeat. Each one was stored
for the cache TTL in the shared Redis. A burst of them raised memory
on the shared Dragonfly to its limit.

The cache now skips /v1/embeddings unless cache.cacheEmbeddings is
true. The default is false. Chat caching does not change.
2026-10-28 20:34:48 +00:00
lukaszraczylo 52b5e60719 test(yaegi): assert RateLimit-Policy header under the interpreter 2026-10-18 13:44:08 +01:00
lukaszraczylo 644b8115c8 feat(config): advertise concurrency via RateLimit-Policy with autodetect
The gateway now sends the concurrency limit as a RateLimit-Policy
field from draft-ietf-httpapi-ratelimit-headers. The value is
"concurrency";q=<n>;qu="concurrent-requests". The invented
X-Concurrency-Limit header is gone.

The new concurrencyAutodetect option is off by default. When on,
the gateway learns a limit for each configured provider. A 429, 503,
504 or upstream timeout sets the limit to half the in-flight
requests, with a minimum of 1. Four consecutive successes add 1.
At 64 the limit counts as unknown again.

Responses served via a provider advertise the smaller of
maxConcurrency and the learned value. An explicit maxConcurrency
always wins. Routing, retry and failover do not change.
2026-10-18 13:44:08 +01:00
lukaszraczylo 3e3517eb62 feat(config): advertise a concurrency limit to clients
Self-hosted upstreams serve few requests at once. A client that opens
many requests overloads them.

The new maxConcurrency option sends X-Concurrency-Limit on every
response. Clients that honour the header cap their own in-flight
requests. The default of 0 sends no header, so behaviour does not
change.
2026-10-18 13:44:08 +01:00
lukaszraczyloandGitHub 62c66f2907 Merge pull request #7 from lukaszraczylo/feat/max-request-bytes
feat(config): add maxRequestBytes for the unified body cap
2026-10-16 00:36:12 +01:00
lukaszraczylo a328a8687e feat(config): add maxRequestBytes for the unified body cap
The unified chat and embeddings routes reject bodies above 4 MiB. Long
agent sessions exceed this limit and receive a 413.

Add Config.maxRequestBytes. Zero or a negative value keeps the 4 MiB
default. A positive value raises the cap, clamped to 64 MiB.

An adversarial body decodes to about 12x live heap. An operator who raises
the cap must also set maxInFlightBodyRequests and the pod memory limit.
2026-10-16 00:34:14 +01:00
lukaszraczyloandGitHub 4ecfa10532 Merge pull request #6 from lukaszraczylo/security/fixes-oct-2026
fix(security): harden accounting, fan-out and relayed text
2026-10-15 22:28:41 +01:00
lukaszraczylo 11b3b77662 style: reorder Config and modelRegistry fields for alignment 2026-10-15 22:21:33 +01:00
lukaszraczylo d0d29b8c52 fix(security): bound fan-out and method surface and scrub relayed text
- Add a process-wide gate on MCP tools/list backend connections. The
  per-request limit alone let N callers open N times as many.
- Reject CONNECT and TRACE on native passthrough and on MCP and A2A
  targets with 405.
- Scrub URL query strings and the target URL from a backend JSON-RPC
  error message before it reaches the caller.
- Replace the value of redis.address in GET /admin/api/config. The
  users file path stays visible by design.
- Escape line breaks in every log line so an upstream string cannot
  forge log entries.
- Add stripClientAnthropicBeta. When true, POST /v1/messages does not
  forward the client anthropic-beta header. The default stays false.
2026-10-15 22:20:07 +01:00
lukaszraczylo 8c4bd16a22 fix(accounting): bound upstream-controlled usage and counter keys
Passthrough accounting read the model id, the usage figures and the
response size from the upstream response without limits.

- Mint a model counter scope only for ids the provider serves. An
  upstream that echoed new ids created unbounded counter keys.
- Drop a reported token or cost figure above a fixed ceiling. One huge
  figure locked a user out of every budget for the whole window.
- Bill an echoed unpriced model at the price of the model that passed
  the cost-budget gate.
- Cap a body-size prompt estimate at one million tokens.
- Bound the total bytes that concurrent passthrough accounting tees
  hold. A tee that cannot reserve room falls back to the estimate.
- Add cache.accountHits. When true, a cache hit charges the cached usage
  to the user. The default stays false.
2026-10-15 22:19:57 +01:00
lukaszraczyloandGitHub e5fe48a9a6 Merge pull request #5 from lukaszraczylo/perf/stream-translation
Perf/stream translation
2026-10-15 22:17:05 +01:00
lukaszraczylo 77d5d1f9d0 test(translate): compare invalid UTF-8 JSON by value
Go 1.25 json.Marshal escapes invalid UTF-8 as \ufffd. Go 1.26 writes the
raw replacement rune. The streaming encoder writes the raw rune. The tests
now compare these inputs as decoded values and keep byte comparison for
valid input.
2026-10-15 21:59:16 +01:00
lukaszraczylo 06769904f4 ci: build with Go 1.26
staticcheck and govulncheck at latest require Go 1.26.0 or newer.
The runner used Go 1.25, so both tools failed to install.
2026-10-15 21:59:15 +01:00
lukaszraczylo 6226860917 feat(registry): add requireModelPrefix to disable bare model ids
When the flag is true, a model resolves only as provider/model or as a
modelAliases id. A bare id returns 404 unknown model. GET /v1/models
lists every model in provider/model form and lists no bare ids.

The flag defaults to false, so existing deployments keep the sorted-first
bare-id collision winner.
2026-10-15 21:48:18 +01:00
lukaszraczylo 6be3f09032 chore(pricing): keep claude-sonnet-4-5-20250929 in the builtin table 2026-09-29 13:58:22 +01:00
lukaszraczylo d4322e914c feat(pricing-sync): make the age cutoff and keep list configurable
Add the -max-age-months and -keep flags, with PRICING_MAX_AGE_MONTHS and
PRICING_KEEP make variables. A built-in list keeps ids that are still served.
2026-09-29 13:58:20 +01:00
lukaszraczylo 4edf9be804 chore(pricing): regenerate the builtin table with the age filter
Keeps 171 entries, down from 211. Drops mostly dated snapshot ids.
2026-09-29 13:49:15 +01:00
lukaszraczylo 4681596281 feat(pricing-sync): drop entries older than 12 months
An entry is dropped when its deprecation date has passed, or when a full date
in its id is over 12 months old. Ids with no date signal stay.
2026-09-29 13:49:13 +01:00
lukaszraczylo 0a9522dfa7 chore(pricing): resync the builtin table from LiteLLM
Adds 39 models, including Claude 5.5, GPT-6, Grok 4.20 variants and Qwen 3.8.
Drops 65 models that LiteLLM no longer lists, for example Grok 2 and 3, old
Kimi and Claude 3 ids. Updates 6 prices.
2026-09-29 13:23:06 +01:00
lukaszraczylo b8772d3d73 perf(sse): reuse the data-line buffer across events in readSSE 2026-09-29 12:35:05 +01:00
lukaszraczylo e12cec8bf9 style(stream): reorder stream state fields for fieldalignment 2026-09-29 12:31:07 +01:00
lukaszraczylo c25c6e38e1 perf(sse): skip line splitting for single-line data events 2026-09-29 12:31:04 +01:00
lukaszraczylo 2cd686a669 perf(stream): append text deltas as JSON without an intermediate Marshal 2026-09-29 12:26:15 +01:00
lukaszraczylo baabd5d3bb perf(gemini): share text-delta chunk builder with the anthropic stream 2026-09-29 12:21:50 +01:00
lukaszraczylo f94fe1dad5 perf(anthropic): build text-delta stream chunks without envelope maps 2026-09-29 12:16:20 +01:00
lukaszraczylo f5482317d7 test(bench): add benchmarks for translators, SSE and unified route 2026-09-29 12:10:27 +01:00