Commit Graph
8 Commits
Author SHA1 Message Date
Hasan BasbunarandClaude Opus 5.5 526d5993a5 pair: what two more reviewers found in the changes since the code review
Two independent reviewers (correctness, security; effort max) read eda19f8..87ae395 and
reproduced what follows; each fix was checked in the code and has a test that fails on
901862b:

- Decision 986 held a lane up forever while the other box stayed off once this box had
  restarted (a power cut): a box never read held every lane it does not load. A box
  that may serve a lane now holds it up (503, why) for PAIR_FIRST_READ_S (30 s) from the
  pair's load if it was never read, for PAIR_KNOWN_WAIT_S (15 min) from its last good
  read if it served it; then this box's lane answers it, as on a box alone.
- A box off without a reset made every such request wait the read's 5 s: a box whose
  last read failed slowly is read again in the background (one read at a time, its own
  function: a first try handed the read back to the background from the background).
- A box listing a model and refusing it twice fell through to this box's lane: a 503.
- TCP_USER_TIMEOUT cut a live stream whose client stopped reading for 25 s: dropped,
  keepalive alone sees a box that lost power.
- pair.py add: a Ctrl-C during the checks lost a working pair (both boxes put back now);
  an undo that came before the other box's write let that write land (a cancelled run
  is refused there); its record is dropped once the run succeeds (done); a restored
  entry's name is checked before it names a file; the messages say what was undone.
- The other box could end every generation of this one: SGLang aborts every request
  whose rid starts with one it aborts, and a request it sends on kept its own rid, in
  the body or the x-override-rid header. It never names one now.
- The pipe d27240a gave each request in flight doubled its descriptors, which the other
  box could exhaust (EMFILE at 256 hops), and select() refused any past 1024 (read as
  a caller gone by _client_left): the keepers poll() every 50 ms, no descriptor of their
  own (51 ms through the proxy for an answer of 35 ms at the engine, 502 on v1.41.0).
- Nested JSON from the other box (9,990 deep) broke GET /v1/models here and froze the
  cockpit once written back: its rows and its summary are rebuilt field by field.
- Its summary is kept 2 s: its reads were quiet and each one read this cockpit.
- Ollama's NDJSON streams reached the client whole at the end: relayed as they come.
- Docs and comments said holds, 404 and "within the hour" where the code does not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 10:57:57 +01:00
Hasan BasbunarandClaude Opus 5.5 87ae395d0d pair: a lane loaded nowhere is answered by the entry, add puts both boxes back (decisions 986-988)
Hasan's choices of 2026-11-03 on what the review and a pair simulated on the box found:

- 986: a lane name no box of the pair serves is answered by the box it was sent to,
  by the lane it serves, as on a box alone (961 refused it with a 404). Claude Code
  as installed names qwen3.8-27b, pi and Hermes qwen3.8-flash-next, and these lanes
  are often not the one loaded: they worked on a box alone and failed once paired.
  A box that may serve the name and does not answer still gets the 503 to try again
  with why: one that served it at its last good read (a restart), or one never read
  (not reached yet, another certificate at its address). A box whose last list is
  known and lacks the name does not hold it up, so this holds while the other box is
  off. Its line is said once a minute.
- 987: GET /v1/models stays a 503 while this box's engine does not answer (the
  cockpit's probe and claude-local.py read its first row as this box's model):
  docs/pair.md says so.
- 988: add run again on a pair that worked could leave it one way after a failure
  (this box's entry forgotten there, the other kept here). Each box now keeps what
  the run replaces, entries and certificates, under the run's token, and a failure
  puts both boxes back as they were, a pair they had included.

Tests that fail before this commit: a lane no box serves is answered here (OpenAI and
Anthropic), as is one the box that does not answer never served, add cut on a working
pair, a check failing on a working pair. Five tests of the 404 or of never-read
boxes follow the new rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 09:49:21 +01:00
Hasan BasbunarandClaude Opus 5.5 427872c2ed pair: what the code review at max effort and a pair simulated on the box found
Each found by the code review of feat/dual-spark at eda19f8 (9 finders, 4 verifiers,
2026-11-03) or by two proxies of this branch paired on the reference box with the
real clients, checked in the code, and fixed with a test that fails before it:

- pair.py add read each way through the other box's engine (GET /v1/models on its
  pair port): a lane loading, stopped or switching on either box failed the check,
  and add undid the pair on both boxes, a working one included. A box whose proxy
  answers over the pair's TLS, even with its engine's 503, is reached.
- No TCP keepalive between the boxes: a box that lost power or its cable held a
  request in flight to it for up to MAX_SILENCE_S (an hour in the unit), its client
  hearing nothing. Probes after 10 s, every 5 s, gone after 25 s, both ways.
- An error answer of the other box over 1 MiB went out cut to 1 MiB as if whole:
  error answers have the cap of a 200 now, and a 502 past it.
- A request the other box sent on could be held through a whole boot, then refused
  with a 409 inside the held stream, which its entry relayed as an answer: it is
  never held, its entry gets the 503 at once.
- pair.py remove asked the other box to forget a name, said it had whatever it
  answered, and a box renamed since was never forgotten: the other box forgets by
  the certificate it pins, and remove says when there was nothing to forget.
- NaN, Infinity and 1e400 in what the other box sends (its list, its summary) went
  into this box's answers and cockpit state, which a browser cannot parse: every view
  of the cockpit froze. Both read it as JSON.parse does now.
- The other box's cockpit stopped or not installed made its whole tile "HTTP 503":
  its summary says what it serves without its cockpit, and why.
- The tile's reads every 5 s wrote a journal line on both boxes, and pushed a paired
  box's requests out of the 800 lines the cockpit reads in about 34 minutes: a read
  of the tile writes no line, a box that does not answer is said once a minute.
- /api/chat, /api/generate and /invocations were not routed: a lane name there was
  answered by this box's model under the other's name.
- The first GET /v1/models after a start or a pairing listed this box's models
  alone: each peer's list is read as soon as the pair is.
- The docs say the pair port serves the tile's summary too, and what it holds.

Left for decisions: a lane name served by no box (404, decision 961) and GET
/v1/models while this box's engine is down (503), both against what a box alone
does; add run again on a working pair can leave it one way after a failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 06:25:33 +01:00
Hasan BasbunarandClaude Opus 5.5 eda19f84bb pair: an answer the other box cuts is said cut; the tile as its captures read
What the first run of the pair's tests and the tile's captures found (2026-11-03):

- A non-streamed answer of the other box, an error or a 200, whose body ended before its
  Content-Length went to the client as a whole one: http.client's read(n) hands a body cut
  short over as if it were complete and leaves the bytes still owed in .length (read() alone
  raises IncompleteRead), which the engine's relay already reads since 2026-09-24. Both reads
  of the pair now go through _pair_read_whole(): the client gets a 502 upstream_cut.
- The tile said "does not answer: box spark9 does not answer: ..." (the proxy's own words
  already name the box), and the other box's memory as "of 122 GiB" where this box says its
  own "of 121.6 GiB".
- pair.py dropped the key files of a format no release ever wrote; an entry of pair.json
  edited by hand into something else is passed over instead of stopping the cleanup.
- Tests: two still read the key file the pair no longer has; the journal's outcome lines are
  written after the answer's last byte, and six checks read them at once (one failed in a
  run): they wait for their line now. New: the cut 200, and the tile in the page (a box
  alone, the figures, a box that does not answer said once, its words as text only).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 04:44:04 +01:00
Hasan BasbunarandClaude Opus 5.5 cd85473a45 pair: the certificate is the pair's only credential; the two reviews' findings fixed
Two independent reviews of f50c7e4..ff450c7 (security; robustness and tests), each finding checked
again in the code before its fix.

Decision 978 (proposed after the security review, to be confirmed): the API key a box handed the
other as a "second lock" is also its cockpit's login, root on a box (SECURITY.md). No key is
exchanged any more, as between NVIDIA PAIR's nodes: the pinned certificate admits the other box on
the pair port, which takes PAIR_ROUTES and GET /v1/models only (403 "403 pair route refused"), and
the box that serves admits the request to its engine with its own key (_upstream_auth). An identity
wall (QWEN38_CLIENT_KEYS_FILE) no longer stops the pair. pair.json peers lose key_file; pair.py
swaps certificates only.

Also fixed, each with a test that fails without it:
- an answer not streamed from the other box was read whole: bounded by MAX_BODY_BYTES
  ("502 pair answer too large");
- an error answer cut on the way escaped _forward_peer: said as a cut (UPSTREAM CUT pair);
- a streamed request on the pair port never saw the entry's client leave during a prefill: _peek
  (the socket under TLS) now serves _client_left, _watch_client and _keep_waiting_inner;
- two boxes whose clocks disagree could not pair: certificate dates not checked
  (X509_V_FLAG_NO_CHECK_TIME), the pin being the certificate;
- the hop header on the client port: no hop any more, a hop is the pair port's;
- cookies crossed the pair both ways; the client's key headers are never sent on;
- a peer's model ids with control characters were kept: dropped; _pair_why strips them;
- the pair port's handshake failures, said once a minute with a count;
- PairPort.check and stop could cross and leave a port open: one lock;
- pair.py: host keys checked whatever ~/.ssh/config says (StrictHostKeyChecking=yes, -T); an SSH
  cut once the other box wrote is undone there; a rollback that fails never hides why the pair
  failed; what the other box says is checked before it is printed;
- uninstall.sh --list tells a paired box only to unpair first;
- the tests: pair.json written whole and seen read (no fixed sleeps), no connection to a closed
  port number, journal counts taken before, the in-process class redeclares all 43 cases.

Tests written, not run yet (a measurement campaign runs on the box): run in the morning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 00:12:48 +01:00
Hasan BasbunarandClaude Opus 5.5 66c7c9ece0 uninstall.sh --list names a pair, and says to unpair first
The other box keeps this one until it is told (docs/pair.md). Two tests run the block as
uninstall.sh has it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 23:27:23 +01:00
Hasan BasbunarandClaude Opus 5.5 f50c7e411d pair: the two boxes talk over TLS both ways, paired in one command over SSH
Decisions 970-976 (02/11), after reading NVIDIA PAIR, its playbook and spec, NVIDIA's
connect-two-sparks playbook, SGLang's model gateway and sparkDash: keep this routing, which serves
the SGLang and vLLM lanes PAIR does not, and secure it as PAIR's nodes are secured.

keepalive-proxy.py (role 10, still v6.50, unreleased):
- each box has a certificate of its own (pair/identity, EC P-256, made once by pair.py) and pins
  the other's in pair.json by its SHA-256; a peer is https://host:port with cert_file and sha256;
- PairServer: the pair port (PAIR_PORT, 30002), TLS 1.3, a client certificate demanded, the chain
  ending at a pinned certificate and the certificate itself pinned; a request there is a hop from
  the box of its certificate, whatever its headers say; opened by PairPort within 2 s of pair.json
  naming a peer, closed once it names none (no restart);
- the entry sends to a peer's pair port only, with its own certificate, the peer's checked against
  its pin (chain, then fingerprint), never through a proxy of the environment; _pair_why says why
  a peer does not answer in words that say what to do;
- a pair.json that names no peer is a box alone (pair.py name alone made a lane name a 404);
- under TLS the socket under TLS is peeked at (_client_left, _watch_client): before, no peek was
  made through TLS, so a peer's engine generated to the end for an entry's client that was gone;
- the watcher shuts the TCP side of a TLS connection (SSLSocket.shutdown unwrapped it under the
  reading thread, whose read could fail with a ValueError).

pair.py, rewritten: `add HOST` pairs both boxes in one command over SSH (BatchMode, the destination
after --), sending itself and the request on standard input (no key on any command line), each box
writing new files and then pair.json at once (one commit point, checked by its own installed proxy),
then checks both ways and keeps nothing on either box when one fails; `remove` unpairs both; `status`,
`name` (before pairing), `identity`. An SSH that does not reach, an unknown host key, two boxes of one
name and an older proxy are said with what to do.

docs/pair.md and SECURITY.md say how; ci.yml counts 30002 among the serving ports a test must not
reach. Tests written, not run yet (a measurement campaign runs on the box tonight): CI in the morning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 23:25:44 +01:00
Hasan BasbunarandClaude Opus 5.5 aecb05286d pair.py: name the other box of a pair, its key on standard input; docs/pair.md
The entry of a pair is set up with one command: `ssh spark2 cat .config/qwen38/api-key | python3
pair.py add spark2 http://spark2:30001`. The key is read on standard input (or asked without echo),
never on a command line, and kept in ~/.config/qwen38/pair/<name>.key, mode 600 in a folder of mode
700; pair.json names the file, never the key. Before writing, the other box is asked its list with
that key, as the proxy asks it: a key it refuses, or a box that does not answer, gets nothing written
(--no-check writes it anyway). Names and addresses are judged by the proxy's own _pair_parse, so what
pair.py writes is what the proxy takes. `remove` drops a peer and its key, the last one leaving the
box alone; `status` says what each peer serves now, never a key; `name` sets this box's name.

tests/test_pair_tool.py: 8 tests against a fake peer. docs/pair.md says what a client sees, the
security of the link and the limits; the README's table points at it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 21:38:40 +01:00