Commit Graph
8 Commits
Author SHA1 Message Date
Hasan BasbunarandClaude Opus 5.5 4e22e96e44 proxy, cockpit: what an independent review found in this version, each with its test
A key header of 64 KB of "\n" was read in 8.7 s under the interpreter's lock, with no key, every stream of the box still: it is
refused at once. The red banner of a start that barely moves is no longer drawn again at each reading, its Stop with it. The
words of a box with no lane name what starts one, and a start's length by lane. llama-server's own /chat/completions gets a
chat keepalive. The relay's sign-in page names where this browser reaches the cockpit, through a tunnel or TLS. A body the
cockpit does not read is never its connection's next request. A chunked body shows its size in Traffic. The other box of a
pair is told before a silent stream is cut, and binds nothing for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 13:28:36 +01:00
Hasan BasbunarandClaude Opus 5.5 17c33a038e proxy v6.63: a silent engine's OpenAI stream ends with its error and a cut, never clean
Past MAX_SILENCE_S the proxy drops the request. On /v1/messages it says so in
an error event; on the OpenAI routes it wrote nothing and ended the stream
with the last chunk, so that openai-python and the AI SDK took an empty
answer, or half of one, for a finished one (2026-11-30). They now get an
explicit error event (upstream_silent) and the connection is cut with no last
chunk, as for an engine's cut, whether the engine had opened its stream or
never answered. /v1/messages is as it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 09:33:19 +01:00
Hasan BasbunarandClaude Opus 5.5 86a576584e proxy v6.63: a keepalive of its own for each route
One shape went to every stream but Anthropic's: a chat chunk whose choices
were empty. The commonest loop there is, chunk.choices[0].delta.content,
raised an IndexError on the first one (openai-python 3.60.0 and 2.54.0), and
inside a /v1/responses stream it raised "Expected to have received
`response.created`" in openai-python's .stream() and read as an error in the
AI SDK (6.0.174), as soon as the first token took more than KEEPALIVE_S
(measured against a fake engine, 2026-11-30).

A chat stream gets an empty delta under the model the request named, a
/v1/completions stream a text_completion chunk, a /v1/responses stream a
comment until the engine's first event went out and OpenAI's own typed
keepalive after it, a route with a shape of its own a comment. Codex, whose
idle timer only an event resets, gets the typed event from the start
(0.144.4, its timer at 3 s, 6 s of prefill: answered). The order a box of a
pair sends the other is byte for byte as it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 09:33:19 +01:00
Hasan BasbunarandClaude Opus 5.5 0b27e26d99 proxy: the serving key is checked before a body is read
Without the identity wall, the engine's key is the port's one gate (README), and a
request without it still had its body read whole and, when large, counted by the
engine on the proxy's own key before the engine's 401. The proxy now applies the
engine's own rule first (measured on the live engine: bearer in any case, one space,
the key exactly) and answers the engine's own 401, before the body and before an
Expect: 100-continue invitation; /health and /metrics stay open. The test harnesses
decide which key their proxy holds, whatever HOME holds: those that give it one
present it, as every real client does, and those whose clients send none give it
none (the CI's offline step gives HOME a key). The cockpit knows the new outcome.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 15:01:56 +02:00
Hasan BasbunarandClaude Opus 5.5 dbf649932b v1.21.0: an engine restart no longer ends a session, and no engine starts on memory still held
Issue #26 reported a 27B engine dying about once a day with "CUDA error:
operation not permitted", systemd starting it again 17 s later, and the
fear that the restart lands in the window sglang#40948 blames for a DGX
Spark frozen 9.5 h. Measured on the reference box: a crashed engine's
memory is back 2 to 5 s after it dies, about 15 s before the restart.

engine-preflight.sh runs before every engine (27B, flash, image, video)
and refuses a start while what is left of an engine holds GPU memory,
while the driver holds more than 16 GiB that no process accounts for,
or while nvidia-smi does not answer; systemd tries again every 15 s.

The proxy (v6.28) holds a request while its engine comes back, through
a restart's stop half too, up to 1200 s: a streamed one gets its 200
and the keepalives at once. On a 503, opencode gave up after 151 s and
Claude Code after 325 s; both wait on a held stream (900 s measured).
An engine's mid-stream cut is passed on as a cut: the error event sent
in its place made Claude Code retry without a stream, give up on it
after about 330 s, and end with no answer.

The cockpit restarts an SGLang server left without its scheduler, once
it has been so for 2 min (COCKPIT_ZOMBIE_RESTART), tells one crash of a
serving lane from a boot that keeps dying, and says why a start waits
or was refused.

Tested end to end on the reference box: the flash lane's server sent
SIGQUIT under the real opencode and Claude Code, twice. The runs found
four faults the unit tests could not (a zombie probe docker refused, a
watched boot read as a boot again, a restart that ended the waits, the
cut's error event), each fixed with a test that fails without the fix.
After 632 to 1,068 s held, both clients got their whole answers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 23:20:35 +02:00
Hasan BasbunarandClaude Opus 5.5 2f88eff628 CI: ruff sees every script, no test file leaks its environment, one run of each suite less
- ruff F,E9 ran over a hand-kept list that left out engine-inputs.py and oc-merge-limits.py,
  both run by install.sh: the list comes from the tracked .py files now (the vendored
  flash-sglang/ overlay excepted), with a floor. An undefined name in either passed before.
- The isolation test ran one file and compared HOME alone, while four files left UPSTREAM,
  KEEPALIVE_S, CLIENT_IO_S, MAX_SILENCE_S, PROMPT_CEILING_TOKENS or SGLANG_API_KEY set for
  every module after them. Every unittest file now runs in a process of its own (four at
  a time, about 20 s here) and must hand back the whole environment, and the four restore
  what they set when their class is done. A class that moved HOME, or set UPSTREAM, and
  never put it back passed before.
- TheRender in test_lean_level.py needs jinja2, which no step installed: it ran only
  because the runner's python ships it, and without it the lean step reported OK with
  the render skipped. The discovery step installs it, and the TypeSafe SDK.
- 17 steps only re-ran a unittest module the discovery step already runs (combined, then
  each file directly) and the offline step runs again: four runs of each, no assertion
  added. They are gone, with the two installs they carried moved into the discovery step
  (one of them had a name YAML cut at its " #").

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 23:41:00 +02:00
Hasan BasbunarandClaude Opus 5.5 7c9156bb6a proxy tests: three names that promised what their assertions did not check
- "a smaller pool is picked up after invalidation" wrote the new pool into the cache by
  hand after invalidating: it reads through pool_tokens() from a fake /server_info now,
  so an invalidation that drops nothing fails it (it passed on its own before).
- "a deep schema is left untouched and reported" never read the report: the depth-bound
  line must be logged.
- "a non-streamed wall of markers is named" asserted only that the answer arrives: the
  proxy's journal line naming the corruption is read too.
Each mutant (a no-op invalidation, a silent depth bound, a silent corruption check) passed
its test before and fails it now.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 23:28:48 +02:00
Hasan BasbunarandClaude Opus 5 1e43b42c22 tests: the keepalive injection, and a coverage floor for the serving path
The keepalive loop is why this proxy exists and it had no test. An agent CLI
gives up on a silent stream: opencode and the AI SDK were measured dying at 140
to 180 seconds of silence, and a 200,000-token prefill on this hardware is
longer than that. Coverage put keepalive-proxy.py at 68% and the missing
statements were that whole loop, the max-silence drop, the mid-stream cut and the
non-streamed relay path. The production serving path also had no floor at all.

tests/test_proxy_keepalive.py (12 tests) scripts a fake engine's silences to the
millisecond, so the assertions are about behaviour and not timing luck:

- a silent engine gets keepalives and the real answer still arrives afterwards;
- the OpenAI keepalive is an AUTHENTIC empty chunk (choices: []) and not a
  comment, because a comment is exactly what client stall detectors ignore. The
  test parses it as JSON and requires the empty list;
- the Anthropic route gets the official event: ping and never the OpenAI chunk;
- EVERY record the client receives parses on its own, which is the v6.4 bug
  (a keepalive injected mid-JSON-line) written as an assertion;
- a fast answer gets no keepalive at all;
- MAX_SILENCE_S drops the request, not sooner, and an Anthropic client is told
  why instead of having its stream simply stop;
- a clean close with no [DONE] is end of stream and the proxy must not invent the
  [DONE] the engine never sent, while a transport RESET is a different thing and
  does produce an error event.

Writing it corrected two of my own mistakes rather than the code's, and both are
worth naming. The fake engine took its script from body.split() on the whole
JSON, so tokens read '"silent:0.9"}]}' and matched nothing: it never slept, and
three tests passed for the wrong reason. And a clean close is not a cut, so the
first version of the cut test asserted a message that only appears on a read
error; there are now two tests, one per case.

keepalive-proxy.py 68 -> 75%, with a floor, plus floors for patch-yarn (90%),
oc-fit-limits and build-token-map. tests/test_tools.py also had to stop depending
on the ambient HOME: conc-check.py reads the API key into a module constant at
line 37 and bench-agent resolves CONFIG at import, so importing either one
without ~/.config/qwen38/api-key raises before a test runs. It installs a
throwaway HOME with a throwaway key before any import, which is also what makes
its bench-agent tests meaningful: the key comes from the file and never from an
environment variable that ps would show, and a missing file exits 2 with a
sentence on stderr that names the path it looked in.

461 offline test functions, 38 CI gates. CI local 38/38.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 13:28:18 +02:00