One thread per connection plus max_inflight upstream slots; further requests wait in
line (queue_timeout) instead of being refused. A waiting caller that asked for a
stream is told why it waits with SSE comment lines (': junction: waiting for a free
slot (0 ahead of you)'), which the spec says every parser must ignore — a human
watching curl sees progress, a client sees nothing it could misinterpret. The real
answer then starts in the same stream and the comments simply stop.
Trade-off, stated in the README: a streaming caller gets its 200 before the upstream
is chosen, so a later upstream failure cannot be an HTTP status any more — it travels
as a data: {"error":...} event. Non-streaming callers get nothing injected and keep
their true status code.
Also: cache and endpoint state are locked (they are shared between threads now), and
the test stub forks per connection — a serial stub made a concurrent router look
serialised, which is exactly the kind of test that lies.
'need' now reads only max_tokens/max_completion_tokens as the client wrote them.
chars_per_token and default_max_tokens are gone (and rejected as unknown keywords, so
an old config fails loudly instead of steering nothing). A request that declares no
budget is not sized at all — the guessing is what made a 2048-context embedding
endpoint reject requests that carried no token budget in the first place.
tests: 'need' proven from a declared max_tokens, and a request without one proven to
route by model and path alone.
- TLS both directions behind one j_conn handle: https upstreams with SNI, chain and
hostname verification (system store or tls_ca) and a 'listen ... tls cert key'
listener. Handshake has a hard deadline; a peer that closes without close_notify
is EOF, not an error (HTTP/1.0 bodies end at close).
- Chunked request bodies decoded into the body buffer; chunked responses relayed
byte for byte so streaming is untouched.
- Memory-only LRU response cache (method+path+model+body), honouring no-store/
private, client no-cache, never caching streams, flushable at runtime.
- Header passthrough with hop-by-hop removal, per-endpoint static headers,
X-Forwarded-For/Proto, and X-Junction-{Endpoint,Ms,Cache} on every response.
- No separate reachability probe: the request itself is the test (the probe wedged
servers that serve one connection at a time).
- tests/run.sh: 34 checks incl. a TLS peer; refuses to start on a busy test port.
Rules are ordered and first-match-wins: model glob, path glob, required context,
hook/retry overrides, pass <endpoint>[,<endpoint>] [as <model>] or block.
Endpoints carry shell pre-hooks (exit != 0 = not yet, retried with backoff after an
optional wake command), an offline window after a failed connect, and two timeouts
(idle + total) so a thinking model logs still_working instead of looking hung.
tests/run.sh: 14 checks against C stubs (failing, gated, slow, dead endpoints).