Commit Graph
5 Commits
Author SHA1 Message Date
Hasan BasbunarandClaude Opus 5.5 c30fb75de7 proxy v6.29: a request whose body never arrived whole is not sent on
The proxy's fuzz suite failed about one run in ten on its relay
simulation, on v1.20.5 already (2 of 15 runs; 1 of 15 on v1.21.0), and
it failed the check of pull request #30. A caller that closed before the
last byte of its body left the proxy a short read, and the proxy sent
the engine what had come: of 300 requests closed with a reset at once
after sending, 11 were read short and sent on all the same. No engine
can serve that, so nothing was generated from one, but no request
should go out so: the proxy now ends it "CLIENT GONE before its body"
and asks the engine nothing.

The suite's own engine also fell over a body cut short, which is what
an engine sees when the proxy closes its side as a request goes out,
its caller gone, by design: it now counts that as the request it never
had, and still requires that a caller who left never gets a whole
answer. Over 30 runs each the simulation no longer fails, on either
proxy. tests/test_proxy_short_body.py pins the short read; two of its
three tests fail on v1.21.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 11:58:36 +02:00
Hasan BasbunarandClaude Opus 5.5 58eb1bcc1d CI: skips, the relay simulation and serving-port contact are checked, not assumed
- The declared-against-ran counts took a skipped test for a run one: a skip decorator on
  a whole class stayed green, and so did the TypeSafe SDK round trip whenever its install
  failed. The unittest runs are verbose now and a skip passes only for a reason the step
  lists as what the runner cannot have (the reference box, its cache, its units,
  opencode; the SDK's absence only off the runner). No cockpit test may skip.
- The relay simulation accepted an empty read as a whole stream, never checked that an
  abort reached the engine, compared aborted ids against a set that contained them, and
  ran under a floor of 15 of its 16 checks. A staying client must see [DONE], a stream
  closed under the engine without an abort first is a failure (after the last step too),
  aborts are checked against every rid a request ran under, and all 16 must run. Proved
  with an abort that never reaches the engine and a relay that drops streamed answers:
  green before, red now.
- "The offline suite touches nothing" compared listening sockets only, blind to a
  connection to a port that was already listening, the engine's on the box running
  ci-local.sh. Every python the suite starts now carries an audit hook recording a
  connect() to a serving port, with the test line that made it. It finds 47 today, all
  from dashboard/tests/test_cockpit_collectors.py (to :30000 and :30020), so this step
  stays red until that file stops reaching the box.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 18:58:44 +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 54e6fbd613 tests: concurrency, the relay boundary, and a mutation runner that cannot corrupt the tree
Three more classes the suite had no answer for, and one hazard in my own tool.

CONCURRENCY (dashboard/tests/test_concurrency.py, 9 tests). Every other suite
drives one request at a time, which is not how this stack is used: a person
clicks Switch in one tab while the autoheal fires and a second tab polls. The
cockpit's whole safety story is that only ONE privileged action runs, and nothing
tested it. 24 callers released from one barrier, eight attempts per property:
exactly one gets 202 and the other 23 get 409 with the running job named; a
refused parameter and an unknown action never take the lock, so they cannot cost
the next caller its turn; the lock is released even when starting raises (the
test makes it raise on purpose); the audit log has one unbroken JSON line per
started job, parsed back to prove no line was torn. Plus the shared state: the
snapshot the SSE stream serializes stays serializable under four writers, the
event ring stays bounded under six, and CpuTracker never returns a percentage
outside 0 to 100 while sampled from four threads.

THE RELAY BOUNDARY (12 property checks). agent_relay puts a browser interface on
a tailnet in front of an opencode that can run commands. Generated inputs now
assert that only the relay's own origin is ever allowed, that "null" never is (a
sandboxed iframe and a file:// page both send it), that host_name never returns a
port, that no caller header survives under a name the relay owns, and that the
upstream can never set a cookie named like the cockpit session, which would be
session fixation on the cockpit.

THE PATCH CLIs, measured honestly. patch-yarn.py read 0% while being genuinely
tested, because its suite drives it as a subprocess and coverage cannot see into
a child. Running main() in process makes the number true and adds the cases a
CLI test reaches least: 0% to 94%. Writing them corrected two more of my own
assumptions rather than the code's, and the tests are better for it: the tool
writes rope_type/factor/original_max_position_embeddings into rope_parameters
rather than a rope_scaling key, so the test now pins the factor at 4.0 against
the 262144 to 1010000 ratio, checks theta and the partial rotary factor survive,
checks the inner text_config is patched and not the outer, and checks the backup
is written before the rewrite.

MY OWN TOOL. tests/mutation.py edited the real file and restored it in a finally,
which is wrong twice: anything reading the repo at that instant sees a mutant (a
parallel test run reported 46 errors and one baffling parse failure, which was
this tool editing recipes.py underneath it), and a kill -9 between write and
restore leaves a mutated source staged for commit. It now copies the repo to a
temp directory and mutates the copy. Verified by killing a run mid-walk and
checking git diff. Same score, 90.8% and 80.0%.

420 offline test functions now, ~17,000 generated inputs per run, 84% branch
coverage on the dashboard and 47% on the root tools (was 38%). CI local 34/34.
TESTING.md carries the scoreboard and both of the mutation tool's bugs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 12:56:15 +02:00
Hasan BasbunarandClaude Opus 5 2365b645cc tests: measure the suite instead of trusting it (coverage, properties, fuzz, mutation)
This project was written with an AI coding agent, so the failure mode to defend
against is not a forgotten case: it is code and tests written together from the
same assumption, both wrong in the same way, green anyway. Four gates were added
that a suite cannot satisfy by agreeing with itself.

Nobody had ever run coverage here. First measurement: 68% overall, 14% of
cockpit.py, 0% of build-token-map.py, conc-check.py and bench-agent.py. Now 84%
overall and 55% of cockpit.py, with a per-module floor in CI (raised in a commit,
never lowered quietly) and a total floor.

Property-based checks (dashboard/tests/property_checks.py, 29 checks x 300
generated inputs): every parser returns and never raises on log-shaped text,
outcome_kind is total, _switches matches whole arguments so no flag can answer
for another, drift is reflexive and symmetric, validate() never raises on
arbitrary JSON, and fit(pool, ceiling) never grants more than the pool, never a
negative budget, always whole thousands, never less context for a bigger pool.
Writing that last one corrected my own assumption rather than the code's: fit
rounds down to a thousand, so a pool too small for a thousand-token answer
correctly returns (0, 0).

Proxy fuzz and simulation (tests/proxy_fuzz.py, 16 checks): arbitrary bytes and
arbitrary JSON through the tool-schema sanitizer, 400-deep nesting, 200 tools at
once, plus the properties that matter: a clean body comes back BYTE-IDENTICAL, a
pattern Python can compile is never dropped, a dropped one genuinely does not
compile, the output is valid JSON whenever it changed, and sanitizing twice
changes nothing more. Then RelaySimulation, a Hypothesis state machine driving a
real proxy and a fake engine that reproduces SGLang's abort rule, through
generated client behaviour, checking after every step that no abort was discarded
by the engine and no request was aborted with an id the engine never had. The
2026-09-09 production bug, expressed as a property instead of a story.

Mutation score (tests/mutation.py): 210 mutants in lifecycle.py, 53 surviving,
74.8%. Each survivor was read and turned into a test that names it: two
MutantsThatSurvived classes, 39 tests, and one survivor removed by deleting an
`if` whose body was `pass` (it decided nothing, so four mutants in it were
undetectable by construction). Second run: 90.8%, the rest largely equivalent
mutants. recipes.py: 80.0%. Both gated with a floor.

The tool had the bug every home-made mutation runner has, and it is recorded in
TESTING.md because it matters: CPython validates a .pyc against source mtime AND
size, so two mutants of the same length written inside one mtime granularity are
indistinguishable to that check and the interpreter re-runs the previous mutant's
bytecode. It reported a mutant as surviving that the suite kills in one second by
hand. Fixed with a __pycache__ sweep and PYTHONDONTWRITEBYTECODE=1; the 94.2% it
printed first was not real, 90.8% is.

Also: tests/test_tools.py (25 tests) covers the three tools that had none, among
them the BPE construction ranking that decides which 65,536 rows the draft head
keeps, and conc-check's contamination verdict, which is the one that accuses the
engine rather than the model. tests/testpy.sh resolves an interpreter that has
the tooling, repo-local first, because ci-local.sh runs every step under a
throwaway HOME and a gate that silently skipped there would be exactly the green
that checks nothing.

TESTING.md documents the layers, the floors, and what the tests found.

CI local 34/34.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 12:39:09 +02:00