Commit Graph
5 Commits
Author SHA1 Message Date
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