The isolation guard failed the offline suite: BenchAgentTiming.api_key sets QWEN38_API_KEY and its finally only runs when api_key() returns, so an exception on that line left the key in the environment for the files after it. The other classes of this file call _keep_env in their setUpClass; this one was the only one that had been left out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The image and video lanes' note, which says built, came right after the wheel, before the
source, its patches and the overlay: a preparation stopped there read as built, and the next
Load served the bare wheel (an idle lane holding a CPU core, a Stop timing out). The note is
written last now, and only when it changes: its date is one of the runtime's, and rewritten at
every run it told a serving lane it ran older files, and turned the video lane's Turbo off,
after every update (found in review of the first form of this fix).
The cockpit asks the 27B's draft whole, every file its index names and a link counting once its
blob is there, and its config set for the window the unit serves; an empty draft vocabulary is
none. build-token-map.py writes the vocabulary beside it, reads it back, then puts it in place,
and Library no longer counts a link to a blob gone as a weight file (found in review,
2026-10-15).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- 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>
Three graders passed what they should not: Oslo asked twice passed the Oslo-and-Bergen
case, the divisor of the right-tool case was never read, and empty arguments were parsed
as {}. A read past the timeout or a connection the engine dropped ended both tools in a
traceback and exit 1; bench-agent.py also missed a lane gone between turns, since the
post() that caught it was never called. Both exit 3 with a sentence now, and bench-agent
takes --timeout. The test that said the key never comes from the environment says what
the tools do: the file, with QWEN38_API_KEY as the override they offer. Found in review,
2026-09-24 (T12, T13, T26, T28).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
test_tools.py points HOME at a throwaway directory because the scripts it
imports read the serving API key at module level, so an import on a machine
without ~/.config/qwen38/api-key raises before a single test runs. It did that at
module level too, and unittest imports every module of a run before executing any
of them, so the assignment reached files that run long before it.
test_install_sudo replays install.sh for real, and install.sh sizes its disk
preflight from whether the checkpoints are already cached: 10 GB when they are,
230 GB when they are not. Under the borrowed HOME it saw an empty cache, died at
step 1 for lack of space, and reported that as a failure of the step 8 refusal it
never reached. Full-suite runs only, on a box that has the cache, which is how a
real ordering bug gets called a flake and muted.
HOME is now borrowed for the import and given straight back. Two gates in
tests/test_suite_isolation.py fail if any file in tests/ moves it, at import or on
the way out, and the import one names the file that did. Checked against the old
code: it names test_tools.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The keepalive loop is why this proxy exists and it had no test. An agent CLI
gives up on a silent stream: opencode and the AI SDK were measured dying at 140
to 180 seconds of silence, and a 200,000-token prefill on this hardware is
longer than that. Coverage put keepalive-proxy.py at 68% and the missing
statements were that whole loop, the max-silence drop, the mid-stream cut and the
non-streamed relay path. The production serving path also had no floor at all.
tests/test_proxy_keepalive.py (12 tests) scripts a fake engine's silences to the
millisecond, so the assertions are about behaviour and not timing luck:
- a silent engine gets keepalives and the real answer still arrives afterwards;
- the OpenAI keepalive is an AUTHENTIC empty chunk (choices: []) and not a
comment, because a comment is exactly what client stall detectors ignore. The
test parses it as JSON and requires the empty list;
- the Anthropic route gets the official event: ping and never the OpenAI chunk;
- EVERY record the client receives parses on its own, which is the v6.4 bug
(a keepalive injected mid-JSON-line) written as an assertion;
- a fast answer gets no keepalive at all;
- MAX_SILENCE_S drops the request, not sooner, and an Anthropic client is told
why instead of having its stream simply stop;
- a clean close with no [DONE] is end of stream and the proxy must not invent the
[DONE] the engine never sent, while a transport RESET is a different thing and
does produce an error event.
Writing it corrected two of my own mistakes rather than the code's, and both are
worth naming. The fake engine took its script from body.split() on the whole
JSON, so tokens read '"silent:0.9"}]}' and matched nothing: it never slept, and
three tests passed for the wrong reason. And a clean close is not a cut, so the
first version of the cut test asserted a message that only appears on a read
error; there are now two tests, one per case.
keepalive-proxy.py 68 -> 75%, with a floor, plus floors for patch-yarn (90%),
oc-fit-limits and build-token-map. tests/test_tools.py also had to stop depending
on the ambient HOME: conc-check.py reads the API key into a module constant at
line 37 and bench-agent resolves CONFIG at import, so importing either one
without ~/.config/qwen38/api-key raises before a test runs. It installs a
throwaway HOME with a throwaway key before any import, which is also what makes
its bench-agent tests meaningful: the key comes from the file and never from an
environment variable that ps would show, and a missing file exits 2 with a
sentence on stderr that names the path it looked in.
461 offline test functions, 38 CI gates. CI local 38/38.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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>
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>