Commit Graph
13 Commits
Author SHA1 Message Date
Hasan BasbunarandClaude Opus 5.5 9fb29e843d relay: the findings of the second max review, fixed
The review of bb03551..9c0730e reported 34 findings, each read again in the code. Fixed, each
with a test that fails on 9c0730e or on a mutant (14 mutants caught):
- Two of the first review's fixes went wrong: the 5 s cut of a client too slow cut the other box
  of a pair before it could be told the order, which then bound the request 10 minutes (no
  such cut for a hop now: it is told once it reads again); and an Ollama stream that ended
  whole, its last line unwritten to a client gone, read as a death (nothing is read after an
  end now).
- The floor's episode for a generation an earlier stop had marked is undone (the first
  review's change): it holds no engine memory, and revue 627 holds nothing back for a stop
  that stops nothing new.
- A request a stop reaches while it waits in the proxy is refused or cut then, never held or
  handed to the other box; a stop's window stays open until its abort_all is answered, and
  closes even when the stop raises.
- An order put before a death by order is said; a failed /v1/responses stream is never said
  finishing at its end; a keepalive's write ended by the client too slow is said so; the cut
  of a client too slow shuts its TCP side, as the pair's watch does.
- The pair's entry: an answer that came while its client left goes to nobody; a box that
  closed on a shared request after its client left is paused, as when it stays; a hop says an
  answer its engine aborted as an order, which binds nothing; a stop's stream whose engine
  knows no rid of it is drained, not closed.
Refuted: vLLM's message stream converter ends its stream after its error event, so taking it
out of reach before the probe costs nothing. Tests made sturdier where the review found them
timed or weak.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 03:07:01 +01:00
Hasan BasbunarandClaude Opus 5.5 d366290b3e relay: the findings of the max review of its rework, fixed
The review of 93746bf..bb03551 reported 41 findings, each read again in the code. Fixed, each
with a test that fails on 7d806dc or on a mutant (21 mutants caught):
- vLLM: the proxy's own close of the upstream (its client gone, a stop, its client too slow)
  was read by the pump as its engine cutting the stream, and bound the request 10 minutes:
  what the proxy ends itself (_aborted, stop, drain) is never a cut.
- A client too slow: its generation aborted then closed by the pump, once, and drained where
  the engine knows no rid of it; the relay no longer closes the upstream before the abort; a
  client that reads nothing at all is cut within SPOOL_CUT_WAIT_S; the other box is told no
  order after its engine's death; what ends the answer (its end, a death, a cut) goes past the
  spool's bound.
- vLLM's death on /v1/messages: probed on /health, out of every stop's reach before the probe,
  and said by a hop in words the entry reads as a death.
- Stops: one window per stop (_STOP_WINDOWS), closed when no engine listens, read as a
  generation goes out, after the size guard; the floor's episode counts what still runs.
- The pump's decisions are guarded; a dead, aborted or failed stream is never said finishing;
  PROXY_SPOOL_MAX_MIB is read as its siblings are; the deferred reads say what they follow.
Tests: the frozen client's helper reads several records and says when each abort and close
came; the stop's helper chooses its targets as the stop does; the timing tests wait for the
reads they mean; the in-process stop tests carry a test key, never this machine's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 01:08:42 +01:00
Hasan BasbunarandClaude Opus 5.5 4638cd138c relay: an SSE answer's end is read and decided as its engine sends it, whatever its client's pace (v6.53, decisions 1106 to 1109)
The pump read the engine into a queue of 1,024 events and waited when it was full: behind a
client that read nothing, it read nothing more, the end included, and what the proxy decides at
an engine's end (out of a stop's reach, the order read in systemd, the binding of decision
1019, the order told to the other box) waited for the relay to reach it. The twelfth to
fifteenth reviews of v1.43.0 found a window in that each time.

- The pump puts into a _Spool that never waits, bounded at SPOOL_MAX_BYTES (32 MiB,
  PROXY_SPOOL_MAX_MIB): past it, the generation is stopped and the client cut, CLIENT TOO SLOW.
- _engine_end decides a death or a cut as the pump reads it: out of reach, the order read
  once, the request bound or a hop's box told ("o", put before the death or the cut), the
  3 s of deferred reads started at the binding; _engine_end_late reads the order again at a
  dead stream's clean end. The relay only writes what was decided: a client that leaves first
  no longer leaves a death unbound, an order seen at the death binds nothing however late.
- The ends: [DONE], message_stop, response.completed, .incomplete and .failed (SSE_ENDS), an
  Ollama stream's last line (_NDJSON_DONE), and vLLM's death on its Anthropic route, said as a
  ValidationError of ChatCompletionStreamResponse, when the engine no longer answers.
- stop_generations skips what a stop marked already, ends a running vLLM relay's upstream at
  once, and a generation that starts while a stop is under way is that stop's (_STOP_WINDOW,
  8 s more when SGLang's abort_all did not go, the cockpit then sending its own); the stop
  route's finishing counts the streams whose end was read (_FINISHING).

Tests in tests/test_proxy_pair.py (the frozen client helper rewritten: one freeze, the effect
waited for, a binding's deferred reads counted, the end delayed at will), each failing on
93746bf's proxy, fifteen mutants caught; CLIENT TOO SLOW in dashboard/tests/test_lifecycle.py;
the floor stop tests start each with no stop under way. docs/pair.md says the bindings as
they are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 23:25:09 +01:00
Hasan BasbunarandClaude Opus 5.5 a2ec18965d role 10: the seventh review: bound as its client leaves, unbound by an order said after
What the seventh code review of v1.43.0 found in the proxy, each with a test that fails on the commit
before it or a mutant (decisions 1061 and 1062):
- Decision 1061: once a death was relayed, the watch left the connection to the other box open with no
  bound, and with that box silent the request was bound only after 60 s of silence, its retry running
  unbound on this box's engine meanwhile. The watch binds it within a second of its client leaving, and
  shuts the connection after PAIR_ORDER_GRACE_S (5 s); an order the other box says before that undoes the
  binding. An order read between the watch's read and its note is read again after the note (found
  re-reading this fix; a mutant without it fails its test).
- A request of this box's own client, bound at a vLLM death by a read of systemd that saw no stop job
  yet, stayed bound once the stop showed at the stream's clean end: unbound there now.
- A 409 for another checkpoint kept the checkpoint it proves stale, and the next requests went there for
  a 409 each: the row keeps the name and drops its revision ("moved checkpoint").
- A finished answer that is not a stream was taken out of a stop's reach at its relay: in the keeper's
  join a stop could still cut it. It is set as the engine gives it, under the stop's own lock, and the
  stop's answer says how many such answers are left to go out ("finishing").
- A recovery's mark counted for any restart of its run within 10 minutes, one the cockpit left behind
  included: it counts now for the restart it was written for only, the unit's state changing within
  RECOVERY_START_S (2 minutes) of it (decision 1062).
- An order split across two reads was missed by the wait for it; the words of an engine's death inside
  an Ollama tool call's arguments read as a death (a whole line's top-level error now, ndjson_death);
  the order's NDJSON line could follow a line over 64 KiB with no line end; a box never read since
  pair.json was had no first-read window in _pair_served_nowhere (peer_row_may_serve(None)).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 00:01:56 +01:00
Hasan BasbunarandClaude Opus 5.5 3c199fe3f9 role 10: the sixth review: the wait for an order holds in production, the relaying box says it late too
What the sixth code review of v1.43.0 found in the proxy, each with a test that fails on the commit
before it (decision 1058):
- Decision 1054's wait never held: the request's own watch saw the client gone and closed the connection
  to the other box within a second, and with nothing between the death and the order the wait never ran
  (bound 10 minutes in 5 runs of 5). The test of the commit before replaced that watch, which hid it; no
  test replaces it now. Once a death is relayed, the watch leaves that connection to the relay.
- The box that relays never said an order it saw only after a vLLM death: vLLM ends a dead stream
  cleanly ([DONE]), and the order is read again at that end, said before it.
- On vLLM a stop shut the upstream of a non-streamed answer being relayed: cut, taken for its engine's
  death, bound 10 minutes on a hop; and a floor stop that cut nothing held new generations back. An
  answer relayed whole is no stop target, and an answer a stop did cut is a stop.
- A refusal for another checkpoint of the model (409) read as one for another model: the other box's row
  dropped the name, and peer_may_serve said no box served it. The refusal's "served" says which.
- Decision 1059: a stop is an order again, marked or not, and lane_away says so.
- One rule for peer_may_serve and _pair_served_nowhere (peer_row_may_serve), one line reader for NDJSON
  (whole_lines), one test for the hold and the keeper (held_as_stream): copies of each had drifted. The
  keeper's choice for the Ollama routes has a test (a mutant without it fails it), and role 6 in the
  header says those routes wait in silence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 00:01:56 +01:00
Hasan BasbunarandClaude Opus 5.5 7bfc2e719a proxy: an Ollama client never gets an SSE stream, and a stop cuts its stream at a line's end
What the fifth code review of v1.43.0 found on the Ollama routes, each with a test that fails on the
commit before it (decision 1052):
- The hold, and the keeper of an engine slow to answer, opened a text/event-stream for every streamed
  request, an Ollama one too, whose client reads a JSON object a line and no SSE event (found while
  checking the review's eleventh finding). Their requests wait in silence now, as a non-streamed one does.
- The stop of the commit before cut a stream where it was, half a line out; on a hop, the order line then
  joined that half, and the other box read neither. NDJSON is relayed line by line, and a stop cuts it at
  a line's end.
- That stop cut every answer that is not SSE, one the engine had finished and not streamed too: its client
  asked it again of a box short of memory. It cuts the Ollama routes' NDJSON only.
- The stream a hold opened read its answer with read(65536), which waits for a chunked body's end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 00:01:56 +01:00
Hasan BasbunarandClaude Opus 5.5 3e1b6605d8 proxy: Ollama streams reach their clients as they come, and a stopped one is cut
What the fourth code review of v1.43.0 found in the relay of what is not SSE, both older than the
pair, each with a test that fails on the commit before it (decision 1048):
- It read the engine with read(65536), which on a chunked body returns after 64 KiB or the end
  only: a client of the Ollama routes (/api/chat, /api/generate) got its NDJSON stream in bursts,
  most answers whole at their end, on a box alone too (since 2026-08-27). It reads with read1, as
  role 1 reads SSE since v6.6.
- v6.47 cut the SSE stream of a generation the cockpit stopped (an Abort all, the memory floor), so
  that a client never takes the part it got for a whole answer. This relay never read the stop, and
  SGLang ends a stopped Ollama stream with a last line that says it is done (done_reason "stop",
  python/sglang/srt/entrypoints/ollama/serving.py, v0.5.22), which it relayed. Once the stop is
  marked, what the engine sends is not relayed, and the client's connection is cut, not ended; a
  request the other box of a pair sent on is told first (decision 1031).
tests/test_proxy_floor_stop.py's engine speaks SGLang's Ollama routes, a last line "done" whatever
ended the generation. The stop's test also fails on a mutant that reads with read1 and never reads
the stop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 00:01:56 +01:00
Hasan BasbunarandClaude Opus 5.5 2178683be7 proxy stop: a request still on its way to the engine is ended once its connection opens
The third code review of 2026-10-26 found that 95dc290 made a narrow window worse. A stop that lands while a request is still being routed, before its connection to the engine opens, found no socket to close, marked the request aborted all the same, and a vLLM request then generated its whole answer, its client cut only at the end (8af149a closed it after abort_all's round trip, by which time it had usually connected). On SGLang the abort by rid sent then stopped nothing and made the relay skip its own. A request not connected yet is now its keeper's: _watch_client and _keep_waiting, which run through the whole wait, end its upstream once it opens (vLLM stops at the close, SGLang at its next disconnect check), and _forward cuts its client. The aborts by rid go only when abort_all did not, each in its own thread, since a single thread kept the last request's prefill going one ABORT_TIMEOUT_S per request before it, and when abort_all went they were second aborts the engine had already done. The log says whose stop it was, the floor's or the operator's. Three tests fail on the previous proxy, two of them on 8af149a too (26 in tests/test_proxy_floor_stop.py).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 23:14:44 +01:00
Hasan BasbunarandClaude Opus 5.5 3b5cbf74bc proxy stop: vLLM's waiting requests close first, the answer comes before the aborts by rid
The second code review of 2026-10-26 found four things in the floor's stop. Its refusals were written as an f-string, which the FeedOutcomes gate of dashboard/tests/test_lifecycle.py reads out of the AST: the CI was red, and 411 had no kind. They are literals again, 411 included. A vLLM request still in its prefill closed only after abort_all's round trip, a 404 that takes up to ABORT_TIMEOUT_S under the pressure the floor fights (2.0 s against 0.0 measured on a fake engine): those close first now, with no round trip. The aborts by rid of SGLang's waiting requests, one by one, held the cockpit's answer past its 8 s, and the cockpit then took the stop for one the proxy had not made: they run in their own thread after abort_all, and the answer comes at once (6.0 s before, under 2 s now). floor_refusal ended the floor's episode without the lock, so a stop that started another meanwhile lost it: it reads under the lock and ends only the episode it read. And PROXY_FLOOR_HOLD_S=0 keeps the pause off whatever the stop carries, as PROXY_MEM_FLOOR_GIB=0 does for the refusal for memory. The module's notes and its start line say that memory alone refuses nothing. Four tests fail on the previous proxy (24 in tests/test_proxy_floor_stop.py).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 23:14:43 +01:00
Hasan BasbunarandClaude Opus 5.5 61c80465bb proxy floor: abort_all always goes, and memory alone refuses nothing
The code review of 2026-10-26 found two holes in the floor's stop. abort_all was sent only when the proxy believed it served SGLang, and a switch from a vLLM lane kept _SERVED saying vllm until a request went through: a generation sent to the engine straight (bench.sh, needle.sh, an eval) then went on to the livelock the floor guards against. It is always tried now, and vLLM's 404 says only that it has no such route. And the proxy refused every new generation whenever MemAvailable was under its floor, with no stop and nothing running: an idle box short of memory for other programs (3.0 GiB on 2026-10-25 beside the flash) had every request refused where v1.40.2 served it, and a floor_gib of 99 carried by one stop answered 529 until the proxy restarted. A refusal for memory now follows a floor stop that cut a generation, until MemAvailable is back over the floor, PROXY_FLOOR_EPISODE_S (300 s) at most, and PROXY_MEM_FLOOR_GIB=0 keeps it off. The refused stops of test_the_stop_is_the_operators_alone now run beside a generation, which ends whole: its last assertion could not fail. Five tests fail on the previous proxy (20 in tests/test_proxy_floor_stop.py).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 23:14:43 +01:00
Hasan BasbunarandClaude Opus 5.5 aecf9ff4f4 proxy stop: abort_all goes first, a huge number or a chunked body is refused
The verification of 2026-10-26 found the floor's abort_all sent only after every abort by rid of the requests still waiting for their first byte, each up to ABORT_TIMEOUT_S on an engine the memory floor finds slow: up to the cockpit's 8 s fallback later than v1.40.2 sent it, at the very edge the floor guards. Each stopped generation is now marked first, so none relays the end its engine gives an aborted one, then abort_all goes, then the aborts by rid. A 310-digit hold_s or floor_gib raised OverflowError before the finite check and killed the handler: it reads as not given, as Infinity does. A chunked stop body was never read, so an operator's stop read as the floor's and held new generations back: it gets a 411. And the oversize count that finds the engine unreachable leaves the request untracked while it is held, as the two other returns that hold do. Three tests fail on the previous proxy (16 in tests/test_proxy_floor_stop.py).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 23:14:43 +01:00
Hasan BasbunarandClaude Opus 5.5 06d9354368 proxy stop: the wait belongs to a cut, and no number arms it past an hour
The two reviewers of v1.40.3 (2026-10-26) found the same door left open at the stop. A floor stop armed its 60 s hold before counting its targets, so a stop that cut nothing (the generations live outside this proxy) blacked out every new generation on an idle box for a minute, and number() believed Infinity: hold_s Infinity puts until=inf in the floor, floor_refusal's int(left + 0.999) then raises OverflowError in every handler, _handle has no except to answer with a 5xx, and the proxy stays blind until it is restarted. It takes the engine key, so no client can send it, but a cockpit bug should not blind every lane either. Now the hold belongs to a real cut (the floor_gib the cockpit carries is still recorded either way, it is how the proxy learns the value), non-finite numbers read as not given, and a hold is capped at an hour and a floor at 100 GiB (the box has 128, a stop is no siege).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 23:14:43 +01:00
Hasan BasbunarandClaude Opus 5.5 98c2341ca7 proxy v6.47, cockpit: a stopped generation's client is cut, never handed a cut answer as a whole one
SGLang ends an aborted generation as a finished one: stop_reason end_turn on /v1/messages (its
STOP_REASON_MAP has no "abort") and a last chunk with finish_reason "abort" on the OpenAI routes, which
LiteLLM reads as "stop". The cockpit's memory floor sent its abort_all to the engine straight, so each
client got the part generated before the stop as its whole answer: on the reference box, on
2026-10-25 at 07:42, Claude Code kept a compaction summary cut in the middle of a word. Measured on a
fake engine that ends as SGLang does, Hermes, the Anthropic SDK's stream and LiteLLM keep it too.

The cockpit's floor and its Abort all now ask the proxy (POST /proxy/stop, from this machine with the
engine's key): each generation it relays is stopped the way its engine has (by rid on SGLang, by
closing its connection on vLLM, where the floor could stop nothing) and its client's connection is
cut, with no end to its stream and no last chunk. Measured on the real clients, a cut made Claude
Code, opencode, pi and Hermes retry and get the whole answer with no duplicate, where an error event
made Claude Code fall back to a request without a stream and opencode and pi give up. After the
floor's stop, for its pause (60 s) and while MemAvailable stays under the floor, a new generation is
refused with 529 overloaded_error (503 off /v1/messages), Retry-After and the cause: the agents retry
within 1 to 3 s, and under cuts alone Hermes sent 54 requests in 400 s, each a whole prefill. On the
OpenAI routes a stream the engine ends as aborted is cut instead of relayed, whatever aborted it. A
proxy that does not take the stop leaves the cockpit's way of before. The Machine view says the floor
acts on every lane, and its banner says the clients were cut and retry. The tests of the vLLM lanes
point COCKPIT_PROXY at a closed port: a stop goes to the proxy first now, and never to the box's own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 23:14:43 +01:00