refactor(capture): retire .expect() sites and drop quarantines#1894
Draft
goxberry wants to merge 1 commit into
Draft
refactor(capture): retire .expect() sites and drop quarantines#1894goxberry wants to merge 1 commit into
goxberry wants to merge 1 commit into
Conversation
Closes out the `lading_capture` `.expect()` cleanup. Both crate-root `#![allow(clippy::expect_used)]` quarantines are removed: - `lading_capture/src/lib.rs` - `lading_capture/src/bin/fuzz_capture_harness.rs` 11 production `.expect()` sites are addressed across the crate. Treatment mix mirrors the patterns established by #1884/#1890/#1891/#1893: **fn-level `#[expect(clippy::expect_used, reason = "...")]`** (7 sites across 7 functions; the .expect msg is the documented contract): - `test/writer.rs` (×4) — `InMemoryWriter` test/fuzz helper, gated by `#![cfg(any(test, feature = "fuzz"))]`. The mutex-poisoning and invalid-UTF-8 panics are the type's documented contract above each fn. - `manager/state_machine.rs::StateMachine::{record_captures, drain_and_write, write_metric_line}` — six `self.format.as_mut()` sites collapse to three fn-level annotations. `self.format` is `Some` throughout the operating state of the state machine. - `manager.rs::CaptureManager::start` — `self.shutdown.take()` is consumed exactly once here; `self.shutdown` is populated at construction. **Site-level `.unwrap_or_else(... unreachable!("..."))`** (4 sites, structural infallibles): - `manager.rs::RealClock::now_ms` — `SystemTime::duration_since(UNIX_EPOCH)` on a `start_system_time` captured at program start in a modern epoch. - `accumulator.rs` (×2) — `prost::Message::write_to_bytes` on an in-memory `Dogsketch` cannot fail. - `bin/fuzz_capture_harness.rs` — `OpIterator::next()` is structurally infinite (every match arm returns `Some(...)`, fallback is `unreachable!()`). `lading_capture` is now fully covered by the workspace-level `clippy::expect_used = "deny"`. No runtime behavior change. Verified with `bash ci/validate` (full suite: shellcheck, fmt, check, custom lints, clippy, deny, config validation, nextest, loom, kani, buf). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 22, 2026
Contributor
Author
This was referenced May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What does this PR do?
Closes out the
lading_capture.expect()cleanup. Both crate-root#![allow(clippy::expect_used)]quarantines are removed:lading_capture/src/lib.rslading_capture/src/bin/fuzz_capture_harness.rs11 production
.expect()sites are addressed across the crate. Treatment mix mirrors the patterns from #1884/#1890/#1891/#1893: fn-level#[expect]for contract-style invariants where the.expectmessage is the contract, and site-levelunreachable!()for structural infallibles.Sites covered
7 fn-level
#[expect(clippy::expect_used, reason = "...")]— the.expect()calls themselves are unchanged.test/writer.rs::InMemoryWriter::{get_bytes, get_string, parse_lines}+Write::writeInMemoryWriteris a test/fuzz helper (#![cfg(any(test, feature = "fuzz"))]). The mutex-poisoning and invalid-UTF-8 panics are documented contracts (see# Panicssections).manager/state_machine.rs::StateMachine::record_capturesself.format.as_mut()—formatisSomethroughout the operating state of the state machine.manager/state_machine.rs::StateMachine::drain_and_writemanager/state_machine.rs::StateMachine::write_metric_line.expect()calls collapse to one fn-level annotation)manager.rs::CaptureManager::startself.shutdown.take()—shutdownis populated at construction and consumed exactly once here.4 site-level
.unwrap_or_else(... unreachable!("..."))— structural infallibles.manager.rs::RealClock::now_ms(start_system_time + elapsed).duration_since(UNIX_EPOCH)start_system_timeis captured at program start in a modern epoch, well after UNIX_EPOCH.accumulator.rs:230, 525dogsketch.write_to_bytes()prost::Message::write_to_byteson an in-memory struct cannot fail.bin/fuzz_capture_harness.rs:389op_iter.next()OpIterator::next()is structurally infinite — every match arm returnsSome(...); the fallback isunreachable!().Discovery note
The initial survey reported "149 production sites" in
lading_capture. Once the quarantines were temporarily removed andcargo clippy -p lading-capture --all-targets --all-featureswas run, only 11 real sites surfaced. The bulk of the original 149 was inside#[cfg(test)] mod tests { ... }blocks at the bottom of.rsfiles — covered byallow-expect-in-tests = trueonce the crate-level allow is gone.Motivation
Second-to-last sub-stack in the cleanup chain. After this, only
lading(243 surveyed sites; similar pattern expected) remains to bring the whole workspace to zeroexpect_usedviolations.Related issues
Stacked on #1893.
Additional Notes
cargo build --all-targets --all-features✓bash ci/validate✓ (full suite, including kani proofs and loom tests)cargo clippy -p lading-capture --all-targets --all-features 2>&1 | grep -c expect_used→ 0