Repository navigation
chore(cargo): adopt resolver 3 and tighten the workspace lint posture (#1836) - #1901
Conversation
…#1836) Resolver 3 changes nothing about feature unification — that was resolver 2, which the workspace already had. It defaults `resolver.incompatible-rust-versions` to `fallback`, so cargo prefers dependency versions whose declared `rust-version` is at or below the pinned 1.95. Cargo.lock is unchanged; the guard is against a future `cargo update` pulling a dep that raised its MSRV past the toolchain. New denies: `print_stdout`, `print_stderr`, `dbg_macro`, `todo`, `unimplemented`. The last three had zero occurrences and are pure regression guards. The `decdn` CLI allows both print lints at its crate roots because it is a terminal UI; the production `eprintln!` sites that run before the tracing subscriber exists carry a per-site `#[expect]` naming that reason. Every library crate and every node handler is now unable to print. `cast_possible_truncation` / `cast_sign_loss` / `cast_precision_loss` move from `warn` to `deny`. Zero new violations: CI clippy and the pre-commit hook both pass `-D warnings`, so all 190 casts were already fatal there — this only makes a bare local `cargo clippy` agree. `as_conversions` is deliberately not enabled; it fires on all 561 `as` casts including the widening ones. `[profile.dev.package]` raises the keystore KDF crates to `opt-level = 3`. `alloy`'s `signer-keystore` runs scrypt on every keystore encrypt and decrypt, and unoptimized scrypt costs ~0.5s per operation: the `decdn-cli` suite goes 3.79s -> 3.20s (-16%), with `key_gen_e2e` itself 16-22% faster. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017Dq8ucX9toDdyZdjDbnqBT
…1836) `elided_lifetimes_in_paths` makes a borrowing type path say so at the call site: `TableDefinition<'_, …>` across `channel_store`'s eleven redb table definitions, `EvictionContext<'_>` in the cache's admission and eviction policy traits and their impls, and `HashGroup<'_>` in `bundle_pull` — where the same type was already spelled `HashGroup<'_>` two lines above and two lines below. `unreachable_pub` narrows 46 items that were `pub` inside a private module to the visibility they actually had. 34 are the shared integration-test helper modules (`node/tests/support`, `cache/tests/util`, `cli/tests/common`), where `pub` was reflex rather than intent; the rest are `client-pull`'s `progress` and `ledger` internals, `common`'s `test_support`, and `load_shed`'s egress-budget helper. No item's real reachability changes — a `pub` in a private module was never reachable from outside the crate to begin with. Both fixes are machine-applicable; `cargo clippy --fix` produced the `unreachable_pub` half verbatim. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017Dq8ucX9toDdyZdjDbnqBT
…ms (#1836) 230 public items had no doc comment. 170 were struct fields and 24 enum variants — the shapes rustdoc renders as a bare name with nothing beside it, which is where the gap actually cost a reader: `ResolvedConfig`'s twelve sections, `ClientHandlerDeps`' required wiring, the `expected`/`recovered` pairs on every signature-recovery error, and the operands in `PoolError` that say why a node refused a voucher. The `alloy::sol!` generated-code explosion needed no new escape hatch: it already opts out at its twelve `mod sol_types` wrappers. Three recorder entries in the `recorders!` macro body also gained docs — the macro forwards `$(#[$meta])*`, so an entry without one generates an undocumented `pub fn`. Every comment added here is link-checked as well: the `doc` gate runs `cargo doc --document-private-items` under `-D warnings`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017Dq8ucX9toDdyZdjDbnqBT
There was a problem hiding this comment.
🟢 Approval recommended
The changes are largely policy/documentation/lint-driven with scoped allowances where needed, and no concrete correctness issues were identified in the updated code paths shown.
Pull request overview
This PR updates the workspace’s Cargo + lint configuration to adopt Cargo resolver v3 (MSRV-aware resolution) and tighten the workspace lint posture (docs, visibility, printing, numeric casts), with targeted code/documentation updates across crates to satisfy the new lint set. It also tunes dev-profile optimization for keystore/KDF dependencies to speed up test-heavy workflows.
Changes:
- Switch workspace to
resolver = "3"and document the MSRV-aware fallback behavior. - Enable/raise workspace lints (
missing_docs,unreachable_pub,elided_lifetimes_in_paths, print/todo/dbg/cast denies) and adjust code (docs, lifetimes, visibilities, per-site#[expect]/#[allow]) accordingly. - Optimize select crypto/KDF dependencies in dev builds (
opt-level = 3) to reduce e2e/keygen test latency.
File summaries
| File | Description |
|---|---|
| crates/reputation/src/local.rs | Add rustdoc for public config/errors and enum fields to satisfy missing_docs. |
| crates/protocol/src/message.rs | Document public error variant fields for missing_docs. |
| crates/protocol/src/framing.rs | Add variant docs to framing error type. |
| crates/node/tests/support/mod.rs | Narrow visibility of test helpers and add scoped #[expect] for stderr diagnostics. |
| crates/node/tests/node_origin_pull.rs | Add scoped #[expect] for intentional stderr diagnostics in tests. |
| crates/node/src/serve_economics.rs | Add doc comment on MarginPolicy::new inputs/semantics. |
| crates/node/src/selection.rs | Add docs for public fields on RankedCandidate. |
| crates/node/src/runtime/reload.rs | Document ReloadSnapshot field semantics. |
| crates/node/src/runtime/eviction.rs | Fix elided lifetime in EvictionContext<'_> usage and add field docs. |
| crates/node/src/pool_view.rs | Add docs to lifecycle enum variants/fields. |
| crates/node/src/metrics.rs | Add docs for recorder macro entries (and new probe/connection recorders). |
| crates/node/src/main.rs | Add per-site #[expect] and rationale for process-boundary eprintln!. |
| crates/node/src/load_shed/state.rs | Add docs for constructor semantics. |
| crates/node/src/load_shed/resource_pressure.rs | Add docs for constructor semantics. |
| crates/node/src/load_shed/mod.rs | Add docs for enums/trait method. |
| crates/node/src/load_shed/egress.rs | Add docs for EWMA seeding behavior. |
| crates/node/src/load_shed/controller.rs | Narrow helper visibility (pub(super)) and document controller construction. |
| crates/node/src/handlers/probe.rs | Document ALPN constant and handler constructor intent. |
| crates/node/src/handlers/dht.rs | Document ALPN constant. |
| crates/node/src/handlers/client/mod.rs | Add extensive docs for ClientHandlerDeps fields and ALPN constant. |
| crates/node/src/dht/capacity_bond_registry.rs | Document registry handle fields. |
| crates/node/src/commands/mod.rs | Add scoped #[expect] for early-startup eprintln!; clarify tracing init allowances. |
| crates/node/src/channel_store.rs | Fix elided lifetimes in TableDefinition<'_, ...> and related signatures. |
| crates/node/src/chain_events/shared_head.rs | Add docs to trait method contract. |
| crates/node/src/binding_check.rs | Document BindingReport field. |
| crates/node/src/admin.rs | Document admin wiring structs/constructors. |
| crates/incentive/src/voucher.rs | Document public struct fields and error fields. |
| crates/incentive/src/swap_venue.rs | Document venue variants and mock venue fields/helpers. |
| crates/incentive/src/stream_sig.rs | Document error fields. |
| crates/incentive/src/rate.rs | Document underpayment error operands. |
| crates/incentive/src/probe_sig.rs | Document error fields. |
| crates/incentive/src/lane.rs | Document public error operands in PoolError. |
| crates/incentive/src/eth_identity.rs | Add scoped #[expect] for interactive stderr prompts. |
| crates/incentive/src/capability.rs | Document public struct fields and error operands. |
| crates/incentive/src/bind_sig.rs | Document bad-length error field. |
| crates/e2e/src/chain.rs | Document deployed-contract address fields. |
| crates/common/src/identity.rs | Add doc comment for fresh_secret_key. |
| crates/common/src/config/resolved.rs | Document resolved-config structs and enums for missing_docs. |
| crates/common/src/config/mod.rs | Add scoped #[expect] on early-resolve functions that intentionally eprintln!. |
| crates/common/src/config/errors.rs | Document ConfigErrorBag::new. |
| crates/common/src/cli/setup.rs | Document flattened CLI args grouping. |
| crates/common/src/cli/publish.rs | Document flattened CLI args grouping. |
| crates/common/src/cli/pool.rs | Document flattened CLI args grouping. |
| crates/common/src/cli/node.rs | Add docs for CLI enums/flattened args and subcommand fields. |
| crates/common/src/cli/fetch.rs | Document flattened fetch args grouping. |
| crates/common/src/cli/config_cmd.rs | Document subcommand/flattened args fields. |
| crates/common/src/cli/common.rs | Narrow test-support helper visibility (pub(crate)). |
| crates/common/src/cli/bundle.rs | Document subcommand/flattened args fields. |
| crates/client-pull/src/scheduler.rs | Add scoped #[expect] for test-only stderr calibration diagnostic. |
| crates/client-pull/src/progress.rs | Narrow internal helper types/functions to pub(crate) and fix lint expectations. |
| crates/client-pull/src/pacer.rs | Add docs for ramp pacer fields. |
| crates/client-pull/src/lib.rs | Document public error/struct fields to satisfy missing_docs. |
| crates/client-pull/src/ledger.rs | Narrow constant visibility and align with unreachable_pub posture. |
| crates/client-pull/src/discovery.rs | Document enum variant fields. |
| crates/cli/tests/common/mod.rs | Narrow test helper visibility (pub(crate)). |
| crates/cli/tests/bundle_create.rs | Add scoped #[expect] for skip-path stderr diagnostic. |
| crates/cli/src/main.rs | Allow stderr at binary crate root for top-level error boundary. |
| crates/cli/src/lib.rs | Allow stdout/stderr at CLI library crate root (terminal UI exception). |
| crates/cli/src/known_chains.rs | Document chain-address fields. |
| crates/cli/src/commands/config.rs | Document enum variant field. |
| crates/cli/src/commands/chain_ctx.rs | Document resolved chain context fields. |
| crates/cli/src/commands/bundle_pull.rs | Fix elided lifetime in Vec<HashGroup<'_>>. |
| crates/cache/tests/util/mod.rs | Narrow test util visibility (pub(crate)). |
| crates/cache/src/policy/tinylfu.rs | Add docs + fix EvictionContext<'_> lifetime. |
| crates/cache/src/policy/sketch.rs | Add docs for public methods. |
| crates/cache/src/policy/mod.rs | Add docs and fix EvictionContext<'_> in trait signature. |
| crates/cache/src/policy/lru.rs | Add docs + fix EvictionContext<'_> lifetime. |
| crates/cache/src/engine.rs | Add test-only helper docs for policy wiring assertions. |
| crates/bao-range/src/ranged_store.rs | Add module docs + define RangedStoreError with documented variants. |
| crates/bao-range/src/lib.rs | Add brief module doc for ranged_store. |
| crates/bao-range/src/conformance.rs | Add docs for conformance factory trait and associated types. |
| CONTRIBUTING.md | Document resolver v3 rationale and updated lint posture. |
| CLAUDE.md | Mirror updated lint posture and contributor guidance. |
| CHANGELOG.md | Record lint posture/resolver/profile changes in changelog. |
| Cargo.toml | Switch to resolver 3, tighten workspace lints, and add dev-profile opt-level overrides for KDF deps. |
Review details
- Files reviewed: 75/75 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 82.66% (was 82.66%, ● 0.00%) — 71260/86212 lines
Showing top 50 of 59 changed files — see the workflow Step Summary for the full table. History
|
…es (#1836) Review of #1901 found ten doc comments added by the `missing_docs` commit that state something false. Bulk-documenting 230 items is exactly where that gets introduced, so each fix below was checked against the code, not the neighbours it was copied from. Wrong, now corrected: - `ClientHandlerDeps::local_populate` described waiting on an in-flight fill. It is the local fs/http/s3 origin pull-through deadline (`populate_local`), independent of `pull_through`. - `node_id` claimed it is echoed in signed responses. `StreamResponseBody` has no node-id field; the handler uses it only in `Debug`. - `max_concurrent_streams` said "across all connections". The semaphore is built inside `serve(conn)`, so it is per connection. - `eth_signer` claimed it signs lane bindings. It signs the `slash_sig` on a `StreamResponse`; bindings are verified, never signed. - `receipt_sink` said "completed deliveries". One receipt per accepted voucher, so a delivery emits several. - `max_blob_size_bytes` described the pull leg's received-bytes rule. The field it annotates is the serve gate, checked against the inspected size, and `0` disables it. - `redeem_hint` invented an accrual threshold; the hint fires on every accepted voucher, and `None` means no settlement service is wired. - `pull_through` / `pull_through_origin` overstated what `None` disables. - `RateError::Underpayment`'s `paid`/`bytes` are per-voucher deltas, not cumulative. - `RampPacer::floor` said "one chunk in practice". It is `PULL_WINDOW_FLOOR` — one chunk plus three chunk groups — and the constant's own comment plus a dedicated test exist to explain why one chunk deadlocks. - `FetchArgs::common` said "shared with `decdn fetch`" on `decdn fetch` itself, and named output handling, which lives on a sibling field. - `FrameError::Varint` listed "empty"; an empty buffer reads as truncated. - `ContractAddrs`: `PublisherRegistry` holds namespace ownership, not vetting state; `OriginAssignment` seats operators as origins for a publisher's namespaces, not the inverse; ADR 026 has no `§2`. Two lint escapes were wider than the thing they excuse: - `init_tracing`'s `#[allow(clippy::print_stderr)]` spanned the whole function, including the `LogLevelSetter` closure that runs on SIGHUP long after `registry.init()`. Scoped to the `#[cfg(not(feature = "otlp"))]` block. - `crates/cli/src/main.rs` took a crate-root `#![allow]` for one unconditional `eprintln!`. Now a function-level `#[expect]`, matching `decdn-node`'s. `resolve_security_into`'s `#[expect]` reason claimed tracing is never initialized at config-resolve time. It also runs from `runtime::reload::SecuritySection::resolve` on SIGHUP, where a subscriber is live — so its warnings reach boot stderr but not an operator's structured log stream. Reason corrected and the gap filed as #1902. Also: `egress_budget_bps` has one same-file caller, so it is private rather than `pub(super)`; three docs sat after their attribute; `bao-range` had the same module doc twice; the "twelve `mod sol_types` wrappers" claim was wrong (ten are wrappers, the rest opt out elsewhere); and the hard-coded cast counts are gone from `Cargo.toml` and `CHANGELOG.md` — the argument holds without numbers nothing regenerates. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017Dq8ucX9toDdyZdjDbnqBT
Merge of main brought #1901's tightened lint posture (missing_docs, unreachable_pub); the doctor submodules are private, so their items are crate-internal, not public API. Co-Authored-By: Claude Opus 4.8 <[email protected]>
* feat(cli): scaffold decdn node doctor (types, args, exit semantics) Co-Authored-By: Claude Opus 4.8 <[email protected]> * feat(cli): doctor report rendering (human checklist + json) Co-Authored-By: Claude Opus 4.8 <[email protected]> * feat(cli): doctor config check via resolve_config Co-Authored-By: Claude Opus 4.8 <[email protected]> * feat(cli): doctor disk & cache-budget check (statvfs vs eviction high-water) Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(cli): scope useless_conversion allow for statvfs block-count width fsblkcnt_t is u32 on macOS (u64::from is a real widening) but u64 on 64-bit Linux glibc (identity conversion), so `u64::from(stat.blocks())` trips clippy::useless_conversion on Linux CI while staying silent on macOS. Add a narrowly-scoped allow with a one-line justification on each conversion; keep u64::from over `as u64` per prior guidance. Co-Authored-By: Claude Opus 4.8 <[email protected]> * feat(cli): doctor on-disk state check (node.secret, keystore, redb) Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(cli): doctor state checks for keystore is_file and receipt log - Fix keystore finding to distinguish file vs non-file (Warn if exists but not regular file) - Add receipt log check using decdn_common::config::RECEIPT_LOG_FILE constant - Add tests for receipt log absent and present scenarios Co-Authored-By: Claude Opus 4.8 <[email protected]> * feat(cli): doctor chain check (rpc, chain_id, contract code) Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(cli): redact provider/transport errors in doctor chain findings RPC and get_code_at errors on the unreachable/DNS/TLS failure path embed reqwest's Display, which includes the request URL (and any API key in its path/query) verbatim. The doctor report is printed directly, not through sanitize_err_chain, so route both error sites through it before building the Finding detail. Co-Authored-By: Claude Opus 4.8 <[email protected]> * feat(cli): doctor origin check (http HEAD, fs stat, s3 shape) Co-Authored-By: Claude Opus 4.8 <[email protected]> * feat(cli): doctor port bindability check Co-Authored-By: Claude Opus 4.8 <[email protected]> * feat(cli): doctor live enrichment (health + metrics footprint) Co-Authored-By: Claude Opus 4.8 <[email protected]> * test(cli): end-to-end decdn node doctor offline json report Co-Authored-By: Claude Opus 4.8 <[email protected]> * test(cli): cover doctor state branches; live.rs skip-finding consistency Extract pure evaluate_redb/evaluate_receipts/evaluate_keystore helpers out of check_state (mirroring evaluate_secret) and unit-test their branches directly. Make probe_live push a Pass "live checks skipped" Finding when admin_url resolution or client construction fails, matching the existing client.health()-failure Pass path. Drop the unused _dir param from the config.rs test helper. Note in report.rs that JSON `ok` tracks Fail-count only, not --strict. Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(cli): document doctor public items; harden state stat errors, metric parse, json ok Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(cli): pub(crate) for doctor submodule items (unreachable_pub) Merge of main brought #1901's tightened lint posture (missing_docs, unreachable_pub); the doctor submodules are private, so their items are crate-internal, not public API. Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
Closes #1836.
Three commits, each self-contained (a lint and the fixes for it land together, or CI goes red). Kept on one branch rather than three stacked PRs because
ci.ymltriggers only onpull_request: branches: [main]— a stacked PR would run zero checks.What was decided
The issue listed five findings. Two things came out of investigating them that change it as written:
Finding 1's premise is wrong. The issue says resolver
"3""changes feature-unification behavior for target-specific dependencies". That is what resolver"2"changed, and we already had it. Resolver"3"'s only difference from"2"is MSRV-aware version selection: it defaultsresolver.incompatible-rust-versionstofallback. Adopted anyway — nothing resolves differently at 1.95 andCargo.lockis byte-identical, but it stops a futurecargo updatepulling a dep that raised its MSRV past the pinned toolchain.Finding 2's costs were measured, not estimated. A
cargo clippy --workspace --all-targetsrun with every candidate lint enabled, deduped byfile:line:dbg_macro/todo/unimplementeddeny— pure regression guardselided_lifetimes_in_pathswarn, all fixedunreachable_pubwarn, all fixedprint_stderrdeny+ 5 targeted#[expect]/#[allow]print_stdoutdeny+ one CLI crate-root allowmissing_docswarn, all documentedas_conversionsAlso rejected:
clippy::nursery(finding 5).redundant_pub_cratealone has ~500 candidates and is in direct tension withunreachable_pub;significant_drop_tighteninghas 427 lock sites and is false-positive-prone in async code. Andclippy::unreachable— all 7 sites are legitimate, two of them const-evalmatch NonZeroU64::new(N) { Some(v) => v, None => unreachable!() }where every other escape is already denied or forbidden.cast_possible_truncation/cast_sign_loss/cast_precision_lossgowarn->deny(finding 3) with zero new violations: CI clippy and the pre-commit hook both pass-D warnings, so all 190 casts were already fatal there. The change is that a bare localcargo clippynow agrees, and the lints can no longer be locally relaxed.Finding 4 — dev-profile tuning, measured
The workspace's analogue of risk-iq's Argon2 case is
scrypt:alloy'ssigner-keystoreruns it on every keystore encrypt and decrypt, on the path ofkey_gen_e2e, theanvil-e2ejourneys, andanvil_settlement_e2e. A/B on the same machine (548 crates recompiled, so the override demonstrably took effect):opt-level = 3decdn-clisuite (441 tests)key_gen_e2etestskey_gen_e2etestsAbout 0.5s per keystore operation. Real and free, but it does not reproduce risk-iq's 33.9s -> 4.9s: the default-feature workspace suite is ~46s for 3110 tests and is bounded by deliberate multi-second timeout tests in
client_loopbackandnode_origin_pull, so 0.6s is inside the noise there. Where it pays is theanvil-e2ejobs, one keygen per journey under 20- and 30-minute timeouts.risk-iq's other two levers (
debug = "line-tables-only", depsdebug = false) are not adopted. They trade real debuggability for build wall-clock and interact with CI'scargo llvm-cov nextestinstrumented run, so they need their own before/after numbers — a separate measurement, not a lint-posture change.Notable per-site decisions
print_stderris the awkward one. The 10 sites incommon/src/config/mod.rsalready carried three comments explainingeprintln!nottracing::warn!— tracing is not initialized at resolve time. They get a function-level#[expect(..., reason = ...)]reusing that rationale rather than a blanket module allow.init_tracinguses#[allow], not#[expect]: its onlyeprintln!sits under#[cfg(not(feature = "otlp"))], so an--all-featuresbuild would find the expectation unfulfilled.unused attribute 'expect'), so every print expect sits on the enclosing function.unreachable_pub's 46 fixes came verbatim fromcargo clippy --fix; 34 are shared integration-test helper modules wherepubwas reflex.recorders!macro body needed docs — it forwards$(#[$meta])*, so an undocumented entry generates an undocumentedpub fn.Verification
All four CI clippy invocations, checked by exit code rather than by grepping output:
Plus
cargo fmt --all --check,RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items,cargo deny check,cargo test --doc --workspace, and thedecdn-protocolpublic-api snapshot (158/158, snapshot unchanged — doc comments do not alter the rendered surface).cargo nextest run --workspace-> 3110 tests run: 3110 passed, 0 skipped, matching the pre-change baseline taken onmainatadab0342.git diff Cargo.lockis empty, as predicted for the resolver change.Out of scope either way:
contracts/test/ed25519-vectors/is a standalone crate with its own empty[workspace]table, inherits none of these lints, and is linted by no workflow.🤖 Generated with Claude Code
https://claude.ai/code/session_017Dq8ucX9toDdyZdjDbnqBT