Commit Graph
10 Commits
Author SHA1 Message Date
Hasan BasbunarandClaude Opus 5.5 738bc5e4ab proxy: the serving unit's override flag proves an abandoned answer abortable
Only a chat or /generate stream proved that the engine takes the rid the
proxy imposes, and the proof was dropped at every engine restart: a box
served by Claude Code alone never had it, and each abandoned /v1/messages
answer was drained for up to DRAIN_MAX_S. Until an answer says otherwise,
the active unit named in PROXY_HOLD_UNITS starting its engine with
SGLANG_ENABLE_REQUEST_HEADER_OVERRIDES=1, on its command line or in the
launcher it runs, is now the proof. vLLM's lanes do not set it and keep
the drain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 02:11:24 +02:00
Hasan BasbunarandClaude Opus 5.5 645286bb35 proxy: abort an abandoned /v1/messages answer instead of draining it
The proxy believed the engine's Anthropic route ignores x-override-rid,
so an abandoned Claude Code answer was drained, decoding for nobody for
up to DRAIN_MAX_S (900 s). In v0.5.19, v0.5.21 and the flash nightly that
route builds its request through the chat route's
_convert_to_internal_request, which applies the header. The proxy now
imposes its rid on /v1/messages and aborts with it once a chat stream has
proven that the engine honours it; an Anthropic stream, whose msg_ id is
no rid, never decides that proof.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 02:11:24 +02: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 e0287b1296 tests: the stream that stays waits for the engine's records and allows no late abort
test_a_client_that_stays_is_relayed_untouched read FakeEngine.drained as
soon as the client held the [DONE], but the fake engine writes its drain
down after the [DONE] is out, on its own thread: the count read 0 once
in a full local run (2026-10-04, in the step that runs the offline
suite under the reaper). With a 0.3 s sleep put before the record, it
failed every time. It waits for the engine's records now, as the tests
above it do, the ignored aborts included, then half a second more, and
asks that none came: a proxy that aborts a request after relaying it
whole, at once, 0.1 s or 0.3 s after, fails it, and the proxy as it is
passes it ten runs of the file in ten.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 09:02:23 +02:00
Hasan Basbunar 509c6488f0 Merge branch 'worktree-agent-a2025cf2721ad6703' into fix/revue-v1.18.6 2026-09-25 12:11:32 +02:00
Hasan BasbunarandClaude Opus 5.5 ee70945604 tests: seven behaviours no test guarded, and the drafter's quantization in the drift
Each was proved by a mutant that passed the suite before and fails it now.
- The abort fake noticed the proxy's close only when a write failed, up to an event gap
  later, so a proxy that closed before it aborted passed all 6 tests: it peeks at the
  connection when the abort arrives, and closing first fails the two tests named for it.
- get.sh's only test used a clone never behind origin: a get.sh that installed without
  updating, or reset local commits away, passed it. The update, the refusal of local
  commits and their backup under FORCE_UPDATE=1 are driven now.
- oc-fit-limits main() ran with a `systemctl show` that answered "": fit(pool) instead of
  fit(pool, ceiling), or the ceiling read without the served name, passed.
- The cockpit's 409 "never two engines" was tested nowhere (`if reasons:` made
  `if False:` kept all 540 green); driven over HTTP with the states set by hand.
- The Agent relay was never built the way the cockpit builds it: an agent_config() that
  let every cookie through passed. Built with the real one, in front of a fake opencode.
- The image routes' CSRF check was read in the source: skipping it for them passed.
- drift() did not compare drafter.quantization, and its test rendered a flash launcher
  without "unquant": a launcher that lost it showed no drift. It is compared, and the
  test renders what install.sh renders.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 00:15:45 +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 795b97a270 install.sh: an update that changes nothing restarts nothing; a moved branch or tag restarts the engine; summaries that point at the right things
- I18: the proxy, the cockpit and opencode-web restart only when they are not
  running, when the run changed what they run, or when they started before a
  file they read changed (stale_since); units, the proxy copy and the
  generated opencode config are written only when their content changes.
  The proxy still follows an engine restart. On 1m, step 7 keeps a fitted
  pair under the table's bounds (oc-merge-limits.py --keep-lower, and the
  generator), instead of writing the bounds for the end fit to undo: 49
  opencode-web and 36 cockpit starts on 2026-09-23, 79 config backups
- I13: engine-inputs.py resolves a branch revision through refs/ and counts
  the ref, and reads the image wherever it is named (a moving tag); the flash
  draft vocabulary is built for MODEL_REV=main
- I14: an explicit CONTEXT_MODE=native writes the native opencode limits
- I15: an oc at ~/.local/bin/oc that is not ours is left alone; the command
  offered instead carries OPENCODE_CONFIG (I35)
- I16/I17: the summary sends clients to the proxy; --no-service names what
  ./uninstall.sh --list shows, the key-reading provider included
- tests: the smoke extraction ends at its own last check; the abort test's
  fake engine registers a request before its headers, as SGLang does (an
  abort landed in that gap once in a CI run)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 17:00:07 +02:00
Hasan BasbunarandClaude Opus 5.5 465c2204ba proxy v6.25: a caller that leaves a non-streamed answer stops its generation; a cut body reads as cut
- the caller of a non-streamed answer is watched while the proxy waits for
  it, and at its EOF the upstream connection is ended: SGLang checks its own
  HTTP client every 4 s for a non-streamed request and aborts it with its
  state present (_wait_one_response, types 1 and 3, both images). Measured on
  the box: a 69k-token prompt left after 5 s kept the engine busy 53.6 s
  through v6.24, and stopped 4.0 s after the caller left through v6.25; a
  decode stopped 0.2 s after. No rid needed, so it holds on /v1/messages too
- a request whose "stream" key says anything but false is left to the relay,
  whose abort-then-close order a stream needs (sglang#35255)
- no abort is sent once a non-streamed answer exists: it could only arrive
  after the request was over (the "aborted upstream" line of v6.24 aborted
  nothing, seen live)
- a non-streamed body the engine ends early is relayed without its final
  chunk, so the client sees the cut (http.client returns b"" at an early EOF
  and leaves the bytes owed in .length)
- the fake engines of test_proxy_abort and the fuzz answer as streams, so
  their requests now ask for one; the fuzz models the non-streamed path too
  (an engine that watches its caller) and fails on v6.24
- the cockpit knows the two new outcomes; CHANGELOG gains the wave 2 entries

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 15:02:13 +02:00
Hasan BasbunarandClaude Opus 5 66a033e6cc proxy: a client that gives up no longer leaves the engine decoding (v1.8.4)
6,582 "Received output for rid=... but the state was deleted in TokenizerManager"
lines on this box on 2026-09-09, one of them a request that decoded 6 min 8 s for
nobody (4,470 lines) on a lane that serves four concurrent requests.

abort_request() returns early once the rid has left rid_to_state, and the client
disconnect empties it first (generate_request catches CancelledError and calls
_discard_pending_req_states), so the AbortReq never reaches the scheduler.
Upstream fixed this in sglang#35255, merged 2026-09-04; neither image this repo
serves carries it (verified in the running container: _release_req_states_on_failure
0, abort_sent 0, _discard_pending_req_states 2).

Three holes on this side of the wire, all measured here:
  - the rid was learned from the first SSE event, so a client that gave up during
    prefill left a request the proxy could not name;
  - /v1/messages was aborted with msg_<uuid>, which the Anthropic route mints
    locally and the engine has never heard of: a no-op that logs like a success;
  - the abort ran in a thread racing resp.close(), the call that deletes the state
    the abort needs.

v6.14 names every request with x-override-rid on the routes that honour it, aborts
synchronously before closing, and only trusts a rid it invented once an answer has
proved the engine takes it (SGLANG_ENABLE_REQUEST_HEADER_OVERRIDES is off by
default upstream; the flash launcher, both 27B units and run.sh now pass it). Where
no rid can exist, the answer is drained to its end instead of being orphaned.

Measured on the box, same engine, same request, client killed mid-request:
223 flood lines and a held slot through v6.13, 0 through v6.14 (drained 18 s).
tests/test_proxy_abort.py reproduces the upstream early-return rule in a fake
engine, so the ordering is tested rather than intended.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01USJRpNtncA1Uo3WhDf5wtb
2026-09-09 21:34:22 +02:00