Skip to content

protocol: keep the server and its session across read failures - #30

Merged
karalabe merged 3 commits into
dark-bio:mainfrom
karalabe:server-read-errors
Oct 2, 2026
Merged

karalabe merged 3 commits into
dark-bio:mainfrom
karalabe:server-read-errors

Conversation

@karalabe

@karalabe karalabe commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

A failed read no longer ends the protocol server. The reader keeps the server, its current session and the transport binding, logs a warning, and retries after a 100 ms pause on the stream clock. Closing the server cuts the pause short, and the end of the stream still ends it. Until now any read error other than a timeout closed the server for good, so on an Ark one USB bus reset or SET_INTERFACE from the host left it serving no host until its core restarted.

Retrying is safe because the transport keeps the binding and any partial frame across a failed read, and decryption needs frames in order. A failure that loses bytes still ends the session at the broken frame.

The first commit changes the server and tests it over the in-memory duplex, with a reader that fails on request and hands out one byte per read, so a failure can land inside a frame. The tests check that a failed read and a failing deadline setter are each retried after exactly the documented 100 ms and that a handshake then completes. They check that a failure inside a frame keeps the session while its deadlines keep running, that a failure losing the rest of a frame ends the session, and that closing ends the pause with the clock stopped. The connection driver's handshake read timeout step now waits out the pause, and the read failure test keeps its adapter error case for clients only.

The second commit extends the connection fuzz model with four kinds of server read failure. A failure inside a frame must keep the frame and the session while a short request expires during the pause. A failure that drops the rest of a frame must end that session without delivering anything past the gap, after which the server accepts a new one. Repeated read and deadline setter failures must each wait the full pause, and a reconnect after a failure must retire the old handles. The driver places read failures at byte positions in the duplex mock and checks every pause's deadline against the documented 100 ms. Five scenario tests cover the same paths, and the seeds are regenerated.

The third commit adds the corpus a fuzz campaign grew, minimized. The campaign ran the connection and envelope targets for about 5 minutes each on 24 jobs, then the connection target alone for 12 minutes on 32 jobs, with no findings. It grew the connection corpus from 664 to 1414 units, which set cover minimization brought down to 480, and minimization also trimmed the other targets.

On a development Ark whose USB reader replaces the read buffers a reset fails, this change survived port resets, SET_INTERFACE, 20 resets in a row and minutes left unconfigured. With a reader that loses its buffers on a reset, the server stays up but retries every 100 ms without end.

This changes behavior a consumer can rely on. The Ark firmware's reset button teardown ends its listener through the read error that no longer ends the server. The release carrying this should therefore be 0.14.0, and the firmware takes it only together with its reader fix.

karalabe and others added 3 commits October 2, 2026 13:49
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Astra <noreply@openai.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@karalabe
karalabe merged commit 2f879a6 into dark-bio:main Oct 2, 2026
12 checks passed
@karalabe karalabe mentioned this pull request Oct 2, 2026
karalabe added a commit that referenced this pull request Oct 2, 2026
Bumps the crate to v0.14.0 for the release that carries #30.

A failed read no longer ends the protocol server, which a consumer could
rely on, as the Ark firmware's reset button teardown did. So the release
takes the next minor version rather than a patch. Only the version lines
change, in Cargo.toml and the two lock files.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant