Eighteen new tests, zero production-code changes; every line the review attributed in §N-8 is now covered (verified by a `cargo llvm-cov --show-missing-lines` before/after diff). - producer: the datagram stage's failure exits pinned as direct unit tests on `run_datagram_stage` (the serve layer discards StageExit, so the unit shape is the only place the exact matrix is assertable) — `ReplyFrameRejected` (a joint-bound-violating reply), `EgressEnded` via `next_reply`'s Err, `Io` via a failing write and a failing read; the `send`-failure arm got the serve-layer drop-witness treatment (full ASSOCIATE conversation, EOF after the refusal, the drop flag flips — teardown-at-birth on the failure path) - producer: the quiet wait's `Err(_)` arm (a read *error* ends the wait `Ok(())`, the accept future drops with its owned state — the client-gone contract's error-shaped twin; driven directly on `bind_quiet_wait_and_serve`) and the BIND reply#2 Domain-peer fallback (`TargetAddr::Domain(_, port)` → `0.0.0.0:port`, the data plane live end to end) - producer: the establisher's `None`-witness arm (the registration's optional witness seam) added to the existing unit test - consumer: the two front-door-bridge `split`s tested on live `Socks5Stream<BiStream>` streams via `build_skip_auth_bi_stream` (two duplexes joined the `open_and_negotiate` shape) — raw framed bytes through both halves; the BIND split leaves the take-guard untouched (`await_inbound` still reads the reply#2 phase) - consumer: the single-arm residue — spent `send_datagram`'s `Io` arm (+ the spent-`recv` `Ok(None)` shape asserted alongside), the mid-batch later-frame `Err` dropping the pending `Ok`s (the fail-loud-drops-pending semantics), ASSOCIATE `into_inner`'s `Ok` pairing, `BindDataPlane`'s `poll_flush`/`poll_shutdown` passthroughs (the BIND door's half-close), `read_reply2`'s version pin (a foreign producer's non-5 reply#2), the ASSOCIATE/BIND session `Debug` bodies, the spent-`close` no-op - egress/error: the three seam-handle `Debug` renders (TargetHandle / BindTargetHandle / BindAccept) and `SocksEstablishmentReason`'s `Display` (each variant renders as its canonical wire code) Coverage: 96.31% regions / 97.22% lines; no new accepted-uncovered entries (the residual uncovered lines are the pre-existing out-of-scope set + producer.rs 188-189's untestable `accept_bi` substrate-failure log arm). One test-only select-shape discovery recorded in the task Notes: `tokio::select!`'s random branch order can drop a not-yet-polled accept future before its owned state exists — the quiet-wait test parks once before erroring so both branches are guaranteed started. Verification: `cargo test` + `--all-features` green (375 tests), clippy `-D warnings` clean (native + wasm), fmt clean, `cargo doc` clean, both wasm checks clean.
12 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | |||
|---|---|---|---|---|---|---|---|---|---|---|
| implementation/fix-coverage-residue | Tests — the review-002 coverage residue (N-8: stage exits, splits, spent arms) | completed |
|
moderate | low | component | implementation |
Description
The review-002 coverage residue — the load-bearing gaps plus the
single-arm cosmetics, attributed in
docs/reviews/002-protocol-core-implementation-review.md §N-8 so
the next cargo llvm-cov run needs no re-derivation. Tests only;
rides after the three code-fix tasks so every test lands on the
final shapes (the C-1 spent posture, the C-3 gate entry, the N-4
vocabulary).
The headline gaps (the review's named priority):
- The datagram stage's three failure exits
(
src/producer.rs:374-386,405-414) — the ASSOCIATE teardown surface, untested anywhere (the harness's egress never fails post-reply):ReplyFrameRejected(an egress reply violating the joint bound)EgressEndedvianext_reply'sErr(the relay's end)EgressEndedvia a failingegress.send— at minimum this one gets the drop-witness treatmentegress_factory_called_once_and_dropped_with_the_stagegives the happy path- the stage's
Ioexit (a failing write/read)
- The two untested
splits (src/consumer.rs:437,771-774) —AssociateSession::splitandBindSession::spliton a live stream; the front-door-bridge surfaces (consumer.md), load-bearing for the batch-2 UDP/BIND doors. One test each (or the explicit "batch-2 door exercises it" note — prefer the test; the doors are not here yet).
The single-arm residue (batch freely; each is one small test):
consumer.rs:356-359—send_datagram's spent-streamIoarm (mirror thespent_session_*shapes; the spent-recvarm is covered).consumer.rs:419—recv_datagram's mid-batch later-frameErrarm (first frameOk, a later one garbage → the pendingOks dropped with the session — pin the fail-loud-drops-pending semantics).consumer.rs:453-456—AssociateSession::into_inner'sOkarm (mirrorinto_inner_pairs_the_pipe_with_the_teardown_owner).consumer.rs:636-642—BindDataPlane'spoll_flush/poll_shutdownpassthroughs (the BIND door's half-close rides these — one shutdown test).consumer.rs:843—read_reply2's version-mismatch arm (a foreign producer's non-5 version reply#2 — one unit test onread_reply2directly).producer.rs:560— the quiet wait'sErr(_)(I/O error, not EOF) arm;producer.rs:568— the BIND reply#2 Domain-peer fallback (TargetAddr::Domain(_, port)→0.0.0.0:port) — one factory returning a Domain peer pins it.egress.rs:72-74, 226-230, 275-279— the threeDebugimpl bodies (render once each);error.rs:113-115—SocksEstablishmentReason'sDisplay. Cosmetic; batch freely.
Explicitly out of scope (the review's accepted-uncovered
posture): rfc1928/client.rs:217-219 (use_password_auth's misuse
arm — review-001-era accepted-uncovered with a translated-error
note) and the fork's accepted-uncovered blocks. Do not chase them.
If any arm became unreachable by the code-fix tasks (e.g. the C-1
take-shape changes BindSession::split's reachability), record the
arm as resolved-by-change in the Notes rather than forcing a test
through an artificial shape.
Acceptance Criteria
- The stage's failure exits tested (
ReplyFrameRejected,EgressEndedboth arms,Io) — thesend-failure arm with the drop-witness assertion AssociateSession::split+BindSession::splittested on a live stream (or the batch-2-door note recorded per arm)- The single-arm residue covered: spent-
send, mid-batch later-frameErr, ASSOCIATEinto_inner'sOk,BindDataPlaneshutdown,read_reply2version mismatch, the quiet-waitErr(_)arm, the Domain-peer fallback, theDebug/Displayrenders cargo llvm-covre-run: the named lines covered or recorded as accepted-uncovered with a reason in the task Notescargo testgreen; clippy/fmt clean; both wasm checks clean
References
- docs/reviews/002-protocol-core-implementation-review.md §N-8 (the attributed line list — the task's source of truth)
- tests/harness.rs (the topology + egress shapes to extend)
- src/producer.rs
egress_factory_called_once_and_dropped_with_the_stage(the drop-witness pattern) - tests/consumer-connect.rs
into_inner_pairs_the_pipe_with_the_teardown_owner(the into_inner pattern)
Notes
Filled by the implementation agent (2026-09-24):
- All N-8-named lines covered; no accepted-uncovered entries
added. The
cargo llvm-cov --show-missing-linesdiff before → after: every line the review attributed (consumer.rs 356-359/ 419/437/453-456/636-642/771-774/843 pre-fix numbering; producer.rs 374-386/405-414/560/568; egress.rs 72-74/226-230/275-279; error.rs 113-115) is now covered. The suite grew 357 → 375 tests (145 lib unit / 38 associate / 41 bind / 40 connect / 41 integration / 30 harness / 37 differential / 3 doc-tests); TOTAL 96.31% regions / 97.22% lines. - The stage's failure exits were pinned as direct unit tests on
run_datagram_stage(the serve layer discardsStageExit, so the unit shape is the only place the exact exit matrix is assertable):datagram_stage_reply_frame_rejected_exit(an egress reply whose inner bytes violate the u16 joint bound →ReplyFrameRejected),datagram_stage_egress_relay_ended_exit_ via_next_reply(next_reply'sErr→EgressEnded),datagram_stage_write_failure_is_the_io_exit+datagram_stage_ read_failure_is_the_io_exit(a failing channel write/read →Io). Thesend-failure arm got the serve-layer drop-witness treatment:udp_egress_send_failure_ends_the_association_and_ drops_the_egress(a full ASSOCIATE conversation, one datagram in, the egress refuses it, EOF reaches the client, the stage exits, and the drop flag flips — teardown-at-birth on the failure path). The tests rideFailStream(a poll-failing stream) andOneReplyEgress/RelayEndedEgress/ParkedEgress(stage-shaped egress fakes), all inside the producer test module. - The two splits tested on live streams.
associate_split_ yields_live_halves_and_survives_the_round_tripandbind_split_ yields_live_halves_pre_reply2exercisetokio::io::spliton a liveSocks5Stream<BiStream>built by a new test helper (build_skip_auth_bi_stream— two duplexes joined viaBiStream::from_joined, the same shapeopen_and_negotiateassembles): raw framed bytes pass through both directions on the borrowed halves, and (BIND) the split leaves the take-guard untouched —await_inboundstill reads the reply#2 phase after the halves are dropped. No "batch-2 door exercises it" note needed; the tests stand alone. - The single-arm residue, test by test:
send_datagram_on_a_spent_stream_is_the_io_arm(the spent-streamIoarm — and the spent-recvshape asserted in the same test:Ok(None), the family's read-side posture),recv_datagram_mid_batch_later_frame_err_drops_the_pending_oks(first frameOk, a later one garbage → the pendingOks dropped with the session, the fail-loud-drops-pending semantics pinned),associate_into_inner_pairs_the_stream_with_the_teardown_owner(theTakenAssociateInnerOk arm — the CONNECTinto_inner_pairs_the_pipe_with_the_teardown_ownershape's ASSOCIATE mirror),bind_data_plane_poll_flush_and_poll_shutdown_pass_through(write →poll_flush→poll_shutdown— the bytes reach the peer and the EOF sentinel follows),read_reply2_rejects_a_foreign_producers_version(a non-5 version reply#2 →UnsupportedSocksVersion(0x04), loud),bind_quiet_wait_read_error_ends_the_wait_cleanly(the quiet wait'sErr(_)arm driven directly onbind_quiet_wait_and_serve— a read error ends the waitOk(())and the accept future drops with its owned state, the client-gone contract's error-shaped twin),bind_domain_peer_falls_back_to_the_ unspecified_address(a foreign accept handle carryingTargetAddr::Domain(_, port)peer → reply#2 carries0.0.0.0:port, data plane live),debug_impls_render_the_handle_surfaces(the three egress.rsDebugbodies — TargetHandle non-exhaustive, BindTargetHandle names the peer, BindAccept names the bind address),establishment_reason_display_renders_the_wire_code(theSocksEstablishmentReasonDisplay— each variant renders as its canonical wire code),associate_debug_renders_channel_liveness_ and_pending(the ASSOCIATE + BIND sessionDebugbodies),spent_associate_close_reaps_a_no_op(theclose-on-spent arm), andestablisher_records_identity_and_defaults_the_establishmentextended with theNone-witness arm. - A quiet-wait select-shape discovery (test-only note):
tokio::select!polls branches in random order — a read branch that errors on its first poll can win before the accept branch is ever polled, dropping the accept future at zero polls (the owned state never constructed; a drop flag would never fire — the first cut of the test caught this flake). The test'sFailReadStreamparks once (with a wake) then errors on the second poll so both branches are guaranteed started; the assertion then holds deterministically. Production semantics unaffected (either exit drops the accept future; the contract is exit-shaped, not poll-count-shaped). - One review-item line numbers shifted post-fix-tasks: the
review's
consumer.rs:396-398(the covered spent-recvarm) is now418(theinner.as_mut()else arm after the C-1/D-1 changes); it is covered by the same test that pins the spent-send arm.consumer.rs:937(the spent-bind test'serr().map()diagnostic closure) stays uncovered — it only evaluates onErr, and the spent shape isOk(None)by design (the C-1 posture); cosmetic, not chased. - Reachability check for the arm-became-unreachable clause: no
N-8 arm was made unreachable by the three code-fix tasks — every
named arm still exists at its (shifted) location and is now
tested. The explicit out-of-scope items stayed out of scope:
rfc1928/client.rs:217-219remains accepted-uncovered (with its translated-error note), as do the fork's other accepted-uncovered blocks. - Residual uncovered lines after this task (none new): producer
.rs 188-189 (the pump handler's
accept_bisubstrate-failure log arm — pre-existing, not in N-8's list; untestable without a brokenConnectionoutside alkcall's test surface), rfc1928/client.rs 217-219 + the fork internals (accepted- uncovered per review-001/002), wire.rs/mod.rs/target_addr.rs internals (pre-existing, not in N-8's list), and the test modules' own panic-guard/unreachable lines (coverage-of-tests noise).
Summary
Closed review 002's N-8 coverage residue with 18 new tests and zero
production-code changes: the datagram stage's three failure exits
pinned as direct unit tests on run_datagram_stage
(ReplyFrameRejected, EgressEnded via next_reply, Io via a
failing write and a failing read) plus the serve-layer drop-witness
test for the send-failure arm (the egress drops with the stage on
the failure path too); the two front-door-bridge splits tested on
live Socks5Stream<BiStream> streams (raw bytes through both
halves; the BIND split leaves the take-guard untouched); and the
single-arm residue (spent send_datagram's Io arm + the spent
recv shape, the mid-batch later-frame Err dropping pending Oks,
ASSOCIATE into_inner's Ok pairing, BindDataPlane's
poll_flush/poll_shutdown passthroughs, read_reply2's version
pin, the quiet wait's Err(_) arm, the BIND reply#2 Domain-peer
fallback 0.0.0.0:port, the three egress Debug renders, the
SocksEstablishmentReason Display, the ASSOCIATE/BIND session
Debug bodies, the spent-close no-op, and the establisher's
None-witness arm). cargo llvm-cov re-run: every N-8-named line
covered, no new accepted-uncovered entries (the residual uncovered
lines are the pre-existing out-of-scope set + producer.rs 188-189's
untestable accept_bi log arm). Verification: cargo test +
--all-features green (375 tests), clippy -D warnings clean
(native + wasm), fmt clean, cargo doc clean, both wasm checks
clean; coverage 96.31% regions / 97.22% lines.