Commit Graph
4 Commits
Author SHA1 Message Date
Hasan Basbunar 2b39f7da47 tls test: a proxy that does not refuse the cert is killed, the test fails loud
test_unusable_cert_refuses_to_start waited proc.wait(timeout=10) and, when
the proxy did not refuse the unusable certificate, let TimeoutExpired escape
with the proxy (port 0) still running after the test: 37 orphans of exactly
this test were found on the box on 2026-11-19. On TimeoutExpired the test now
kills that process by its own pid and fails with a clear message. Proven by
mutation against a proxy whose refusal is removed: before, a process outlives
the test (pid seen alive after the run); after, the test fails with "did not
refuse ... (pid ..., killed)" and no process remains. The test stays green
against the real proxy.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 19:50:17 +01:00
Hasan BasbunarandClaude Opus 5.5 8bb32a2d17 tests: the port a test starts a server on stays its own beside the other jobs
ci-local.sh runs the six jobs side by side on one machine, and three of
them run the same test files. Eleven files took a port number out of a
socket they then closed, to start a proxy on it or to have a port where
nothing listens. Anyone could be handed that port before the server bound
it: a stranger could then answer in its place, and a dead port could come
alive. run_suite.py ran those files one at a time, which kept them apart
inside the suite job and not from the other jobs (code review,
2026-10-28, never seen in three runs).

tests/localports.py gives three answers. held() keeps a port bound and
never listening: a connection to it is refused and no other program can
bind it. serve() starts a server of the test's process on a held port,
beside the socket that keeps it (SO_REUSEPORT), so an engine that stops
and starts again keeps its port in between. spawn() starts a proxy in a
process of its own and keeps it once the socket listening on its port is
its own, read in /proc, else starts it again on another port. The
certificate test passes port 0, since nobody connects to a proxy that
refuses to start, and now checks that the refusal is the certificate's.

test_localports.py proves each answer on the machine, and fails on a test
file that takes a port the old way: on the tree before this commit it
names the eleven. With none left, the suite runs them four at a time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 11:51:55 +01:00
Hasan Basbunar 630f581862 keepalive-proxy v6.26: close the review's three open guard findings
S4: a key spelled with a JSON \u escape ("\u0074op_logprobs") carried
none of the bytes the guards scanned for, so the ceiling and the token-id
refusals were skipped; any escape in the body now forces the parse.

S5: the sampling and logprob guards also cover /v1/responses, /invocations
and /vertex_generate, read input_ids as a batch of lists, read
sampling_params as a list, read prompt as token ids on /v1/completions,
and the oversize guard reaches /generate and the other non-/v1/
generation routes.

S6: the TLS handshake no longer runs in the accept loop (one silent
connection parked every other client behind its timeout); it now runs in
the connection's own thread on its own budget, and a handshake that dies
leaves one journal line, no traceback.

Each change is held by a test that failed before and passes after; the
full offline suite and ci-local are green.
2026-09-26 21:22:49 +02:00
Hasan BasbunarandQwen3.8-flash-next via opencode c0eef5765f proxy v6.16: the TLS and identity walls operators kept building in front, built in
Two opt-in walls, both because local production asks them and both
designed so the loopback/tailnet default does not notice their
existence. TLS: name QWEN38_TLS_CERT (QWEN38_TLS_KEY when the key is
separate) and the socket speaks the operator's certificate, TLS1.2
floor, and refuses to start rather than half-wrap. Per-client identity:
QWEN38_CLIENT_KEYS_FILE, a JSON map of bearer token to label; when set
a /v1/ request without a listed key gets a 401 in its own dialect
(authentication_error parses on the Claude side, error.type on the
OpenAI side), /health stays open because a monitored endpoint behind an
identity wall stops being monitoring, and the label rides every journal
line of the request, which is the question one shared key can never
answer. Both walls fail closed: a cert that cannot load or a keys file
that is missing, empty or malformed boots nothing, because a wall that
vanished silently is worse than no wall. Authorization is still
forwarded verbatim, so this is identity in front of the engine's
--api-key, not a second key to rotate in two places. Nine tests drive
the real subprocess and socket (handshake, plain-rejected-beside-TLS,
the dialects of the 401, open /health, the refuse-to-start trios); the
guard crashed once already in development on ssl.TLSVersion.TLS1_2
against TLSv1_2, the exact class of bug these tests exist to catch
before an operator meets it at 2 a.m. on a unit whose Restart=always
respawns it into the same crash. The closed outcome vocabulary names
its own new member: the 401 registers as the fail kind, the same
reading its 400 and 413 siblings got, and the vocabulary gate pointed
at it before this line was written.

Co-Authored-By: Qwen3.8-flash-next via opencode <noreply@opencode.ai>
2026-09-13 17:53:34 +02:00