Skip to content

Commit dfd2ae4

Browse files
committed
fix(ci): clear clippy -D warnings across workspace
CI gate failed after the echobt history rewrite on doc_markdown, map_unwrap_or, double_must_use, and related pedantic lints. Make cargo clippy --workspace --all-targets -D warnings green again.
1 parent c82c8a0 commit dfd2ae4

34 files changed

Lines changed: 144 additions & 122 deletions

File tree

bins/miner/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn run(cli: Cli) -> Result<(), String> {
154154
};
155155
let result = deploy_or_dry_run(&params).map_err(|e| e.to_string())?;
156156
println!("compose-hash={}", result.compose_hash_hex);
157-
println!("receipt-public-key={}", receipt_public_key_hex);
157+
println!("receipt-public-key={receipt_public_key_hex}");
158158
println!("receipt-sk-host-path={}", receipt_sk_host_path.display());
159159
println!("phala_invoked={}", result.phala_invoked);
160160
println!("mode={mode:?}");

bins/validator/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use validator::{
2929
};
3030

3131
#[tokio::main]
32+
#[allow(clippy::too_many_lines)]
3233
async fn main() -> ExitCode {
3334
if let Err(e) = telemetry::init_tracing() {
3435
// Subscriber may already be set; continue with best-effort logs.
@@ -177,7 +178,7 @@ fn trust_root_dir() -> PathBuf {
177178
PathBuf::from("/etc/gbase/config")
178179
}
179180

180-
/// Load challenges + measurements; build AttestState, LocalTrustRoot, and FakeChain
181+
/// Load challenges + measurements; build `AttestState`, `LocalTrustRoot`, and `FakeChain`
181182
/// aligned with gateway (`GBASE_GATEWAY_HOTKEY` / `GBASE_FAKE_METAGRAPH_HOTKEYS`).
182183
fn build_runtime_trust(
183184
netuid: u16,
@@ -249,7 +250,7 @@ fn parse_fake_metagraph_hotkeys(owner: &[u8; 32]) -> Result<Vec<Vec<u8>>, String
249250
}
250251
let mut out = Vec::new();
251252
for part in raw.split(',') {
252-
let h = parse_hotkey_hex(part.trim()).map_err(|e| e.to_string())?;
253+
let h = parse_hotkey_hex(part.trim()).map_err(|e| e.clone())?;
253254
out.push(h.to_vec());
254255
}
255256
if out.is_empty() {
@@ -277,7 +278,7 @@ fn parse_hotkey_hex(s: &str) -> Result<[u8; 32], String> {
277278
.map_err(|v: Vec<u8>| format!("hotkey must be 32 bytes, got {}", v.len()))
278279
}
279280

280-
/// Optional 32-byte validator hotkey for D10 report_data binding (hex or zeros).
281+
/// Optional 32-byte validator hotkey for D10 `report_data` binding (hex or zeros).
281282
fn validator_hotkey_from_env() -> [u8; 32] {
282283
parse_hotkey_env("GBASE_VALIDATOR_HOTKEY_HEX").unwrap_or([0u8; 32])
283284
}

crates/agent-challenge/src/epoch_loop.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Headless epoch dispatch + single active signer (Metis N2).
22
3-
use std::collections::BTreeMap;
3+
use std::collections::{BTreeMap, BTreeSet};
44
use std::sync::{Arc, Mutex};
55
use std::time::{Duration, Instant};
66

@@ -96,7 +96,7 @@ pub trait EpochDispatchClient: Send + Sync + 'static {
9696
/// Single-active-signer registry.
9797
#[derive(Debug, Default)]
9898
pub struct ActiveSignerRegistry {
99-
held: Mutex<BTreeMap<(String, u64), ()>>,
99+
held: Mutex<BTreeSet<(String, u64)>>,
100100
}
101101

102102
/// RAII lease.
@@ -127,13 +127,12 @@ impl ActiveSignerRegistry {
127127
.held
128128
.lock()
129129
.unwrap_or_else(std::sync::PoisonError::into_inner);
130-
if g.contains_key(&key) {
130+
if !g.insert(key.clone()) {
131131
return Err(EpochLoopError::SignerAlreadyActive {
132132
challenge_id: challenge_id.to_owned(),
133133
epoch,
134134
});
135135
}
136-
g.insert(key.clone(), ());
137136
Ok(SignerGuard {
138137
reg: Arc::clone(self),
139138
key,
@@ -154,7 +153,7 @@ impl Drop for SignerGuard {
154153
/// Map graded leaves + epoch outcomes onto full `E` coverage (never silence).
155154
///
156155
/// Prefer `graded` when present. Else: TimedOut→Timeout, Failed→MinerError,
157-
/// CapacityExhausted / Completed-without-grade / missing → ChallengeInternal.
156+
/// `CapacityExhausted` / Completed-without-grade / missing → `ChallengeInternal`.
158157
#[must_use]
159158
pub fn score_map_covering_expected(
160159
expected: &std::collections::BTreeSet<[u8; KEY_LEN]>,
@@ -179,7 +178,7 @@ pub fn score_map_covering_expected(
179178
.collect()
180179
}
181180

182-
/// One epoch: parallel dispatch, deadline → TimedOut, `|E|` outcomes.
181+
/// One epoch: parallel dispatch, deadline → `TimedOut`, `|E|` outcomes.
183182
///
184183
/// # Errors
185184
/// Empty E/catalog, signer conflict, pack select, join panic.

crates/agent-challenge/src/expected_set.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Expected participant set `E` sealed at `block_B` (I7 / BUNDLE_SPEC §7 / D24).
1+
//! Expected participant set `E` sealed at `block_B` (I7 / `BUNDLE_SPEC` §7 / D24).
22
//!
33
//! Derivation is pure in `(block_hash, policy, metagraph_at(block_hash))`.
44
//! A moving tip is never an input — callers must pass an explicit pin.
@@ -57,7 +57,7 @@ pub struct ExpectedParticipant {
5757
pub struct ExpectedSet {
5858
/// Pin used for derivation (`block_hash`).
5959
pub block_hash: [u8; 32],
60-
/// Participants ordered by ascending hotkey bytes (BUNDLE_SPEC §7.2).
60+
/// Participants ordered by ascending hotkey bytes (`BUNDLE_SPEC` §7.2).
6161
pub participants: Vec<ExpectedParticipant>,
6262
}
6363

crates/agent-challenge/src/score.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Pure integer scoring rule (`AGENT_CHALLENGE` §5.4, scoring_version = 2).
1+
//! Pure integer scoring rule (`AGENT_CHALLENGE` §5.4, `scoring_version` = 2).
22
//!
33
//! Live path uses pack-bound v2 task identity and `answer_digest_v2(model.patch)`.
44
//! v2 scores **pure correctness** only — latency decay is removed. `duration_ms` is

crates/agent-challenge/src/task_gen.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const TASK_ID_DOMAIN: &[u8] = b"gbase-agent-task-id-v1";
6262
const TASK_BLOB_DOMAIN: &[u8] = b"gbase-agent-task-blob-v1";
6363
const ANSWER_DOMAIN: &[u8] = b"gbase-agent-answer-v1";
6464

65-
/// Domain tag for [`task_id_v2`] (distinct from v1 / WORK_RECEIPT / ATTEST).
65+
/// Domain tag for [`task_id_v2`] (distinct from v1 / `WORK_RECEIPT` / ATTEST).
6666
pub const TASK_ID_DOMAIN_V2: &[u8] = b"gbase-agent-task-id-v2";
6767
/// Domain tag for [`task_blob_v2`].
6868
pub const TASK_BLOB_DOMAIN_V2: &[u8] = b"gbase-agent-task-blob-v2";
@@ -99,7 +99,7 @@ pub fn answer_digest(task_blob: &[u8; 32]) -> [u8; 32] {
9999
finalize32(h)
100100
}
101101

102-
/// v2 task id: binds netuid, epoch, hotkey, pack_id, and scoring_version.
102+
/// v2 task id: binds netuid, epoch, hotkey, `pack_id`, and `scoring_version`.
103103
///
104104
/// `pack_id` is the UTF-8 pack identity bytes (same surface as receipt `pack_id`).
105105
#[must_use]
@@ -120,7 +120,7 @@ pub fn task_id_v2(
120120
finalize32(h)
121121
}
122122

123-
/// v2 task blob: binds `task_id_v2`, scoring_version, and pack_id.
123+
/// v2 task blob: binds `task_id_v2`, `scoring_version`, and `pack_id`.
124124
#[must_use]
125125
pub fn task_blob_v2(task_id: &[u8; 32], scoring_version: u16, pack_id: &[u8]) -> [u8; 32] {
126126
let mut h = Sha256::new();
@@ -133,7 +133,7 @@ pub fn task_blob_v2(task_id: &[u8; 32], scoring_version: u16, pack_id: &[u8]) ->
133133

134134
/// v2 answer digest: domain-tagged SHA-256 over returned `model.patch` bytes.
135135
///
136-
/// Distinct from receipt `patch_sha256` (untagged) and from v1 answer (over task_blob).
136+
/// Distinct from receipt `patch_sha256` (untagged) and from v1 answer (over `task_blob`).
137137
#[must_use]
138138
pub fn answer_digest_v2(model_patch: &[u8]) -> [u8; 32] {
139139
let mut h = Sha256::new();

crates/agent-challenge/tests/epoch_loop.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![allow(clippy::unwrap_used, clippy::expect_used)]
44

55
use std::collections::BTreeMap;
6+
use std::fmt::Write as _;
67
use std::sync::atomic::{AtomicUsize, Ordering};
78
use std::sync::Arc;
89
use std::time::{Duration, Instant};
@@ -161,7 +162,7 @@ fn format_outcome_table(result: &EpochDispatchResult) -> String {
161162
("capacity_exhausted", pack_id.as_str())
162163
}
163164
};
164-
s.push_str(&format!("{:<40} {k:<20} {p}\n", hex32(key)));
165+
let _ = writeln!(s, "{:<40} {k:<20} {p}", hex32(key));
165166
}
166167
s
167168
}
@@ -211,7 +212,7 @@ async fn s1_epoch_fast_slow_dead_outcomes() {
211212
assert_eq!(client.fast_before_slow.load(Ordering::SeqCst), 1);
212213
}
213214

214-
/// S2 — hang past deadline → TimedOut; epoch still completes with |E|.
215+
/// S2 — hang past deadline → `TimedOut`; epoch still completes with |E|.
215216
#[tokio::test]
216217
async fn s2_deadline_timeout_epoch_completes() {
217218
let expected = ExpectedSet {
@@ -258,7 +259,7 @@ async fn s3_second_signer_refused() {
258259
let _g2 = signers.try_acquire("agent-v1", 99).expect("after drop");
259260
}
260261

261-
/// S3b — run_epoch_dispatch refuses when lease already held.
262+
/// S3b — `run_epoch_dispatch` refuses when lease already held.
262263
#[tokio::test]
263264
async fn s3b_run_epoch_refuses_second_signer() {
264265
let expected = ExpectedSet {
@@ -278,7 +279,7 @@ async fn s3b_run_epoch_refuses_second_signer() {
278279
assert!(matches!(err, EpochLoopError::SignerAlreadyActive { .. }));
279280
}
280281

281-
/// S4 — abort in-flight JoinSet without leak.
282+
/// S4 — abort in-flight `JoinSet` without leak.
282283
#[tokio::test]
283284
async fn s4_cancel_aborts_inflight() {
284285
let expected = ExpectedSet {
@@ -298,7 +299,7 @@ async fn s4_cancel_aborts_inflight() {
298299
assert!(err.is_cancelled());
299300
}
300301

301-
/// Capacity gate: free_slots==0 → CapacityExhausted, no run_pack.
302+
/// Capacity gate: `free_slots==0``CapacityExhausted`, no `run_pack`.
302303
#[tokio::test]
303304
async fn capacity_exhausted_skips_run() {
304305
let expected = ExpectedSet {

crates/agent-challenge/tests/fixtures_f1_f11.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
//! Fixture-driven offline tests F1–F11 v2 successors (`AGENT_CHALLENGE` scoring_version = 2).
1+
//! Fixture-driven offline tests F1–F11 v2 successors (`AGENT_CHALLENGE` `scoring_version` = 2).
22
//!
33
//! Each F1–F11 case is a named v2 successor. Latency decay is removed: correct answers
44
//! always score `SCORE_MAX` regardless of `duration_ms`. Digests match
5-
//! `tests/fixtures/v2_*.hex` (pack-fixture-001 + FIXTURE_MODEL_PATCH).
5+
//! `tests/fixtures/v2_*.hex` (pack-fixture-001 + `FIXTURE_MODEL_PATCH`).
66
77
#![allow(clippy::unwrap_used, clippy::expect_used)]
88

@@ -12,13 +12,13 @@ use agent_challenge::{
1212
FIXTURE_MODEL_PATCH, FIXTURE_PACK_ID, SCORE_MAX, SCORING_VERSION,
1313
};
1414

15-
/// F1 v2 successor — miner 0x11 task_id golden.
15+
/// F1 v2 successor — miner 0x11 `task_id` golden.
1616
const F1_V2_TASK_ID: &str = "b1c18e56abe993e20e8dadcb72c7a7cadee8975e5741d15d1acb37f5ea367644";
17-
/// F1 v2 successor — task_blob golden.
17+
/// F1 v2 successor — `task_blob` golden.
1818
const F1_V2_TASK_BLOB: &str = "c563caca4fa3a7c5e834a88b0dae9eb1ef87f90fcddc9973e38d2730b347c441";
19-
/// F1/F11 v2 successor — answer_digest_v2(model.patch) golden (patch-only preimage).
19+
/// F1/F11 v2 successor — `answer_digest_v2(model.patch)` golden (patch-only preimage).
2020
const F1_V2_ANSWER: &str = "703b806158d655e5d37a5b45e3cbdf1e04735517805377199d108ae2a45ead5d";
21-
/// F11 v2 successor — miner 0x22 task_id golden.
21+
/// F11 v2 successor — miner 0x22 `task_id` golden.
2222
const F11_V2_TASK_ID: &str = "b99762643336fbf7abeb2c07085ff3d64ee1fd8d1c98b149c57a36ec0396228f";
2323

2424
fn miner11() -> [u8; 32] {
@@ -77,7 +77,7 @@ fn f1_v2_digests_and_score_max() {
7777
);
7878
}
7979

80-
/// F2 v2 — duration_ms=0 still full credit (latency ignored).
80+
/// F2 v2 — `duration_ms=0` still full credit (latency ignored).
8181
#[test]
8282
fn f2_v2_duration_zero_score_max() {
8383
assert_eq!(
@@ -103,7 +103,7 @@ fn f3_v2_duration_ignored_full_credit() {
103103
);
104104
}
105105

106-
/// F4 v2 — former hard boundary (10_000 ms) is full credit under correctness-only.
106+
/// F4 v2 — former hard boundary (`10_000` ms) is full credit under correctness-only.
107107
#[test]
108108
fn f4_v2_duration_ignored_full_credit() {
109109
assert_eq!(
@@ -296,7 +296,7 @@ fn reference_assertions_section_5_7_v2() {
296296
);
297297
}
298298

299-
/// Retired v1 echo fixture must not validate under live scoring_version 2.
299+
/// Retired v1 echo fixture must not validate under live `scoring_version` 2.
300300
#[test]
301301
fn f_echo_retired_v1_answer_does_not_validate() {
302302
let m = miner11();

crates/agent-challenge/tests/full_local_e2e.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ fn now_iso() -> String {
6262
.output()
6363
.ok()
6464
.and_then(|o| String::from_utf8(o.stdout).ok())
65-
.map(|s| s.trim().to_owned())
66-
.unwrap_or_else(|| "unknown".into())
65+
.map_or_else(|| "unknown".into(), |s| s.trim().to_owned())
6766
}
6867

6968
fn sk() -> [u8; KEY_LEN] {
@@ -284,9 +283,10 @@ fn harbor_enabled() -> bool {
284283
}
285284

286285
fn pack_dir() -> PathBuf {
287-
std::env::var("GBASE_VERIFY_PACK")
288-
.map(PathBuf::from)
289-
.unwrap_or_else(|_| PathBuf::from("/tmp/da_m18c_hf_pull/tasks/realpr-more-itertools-1136"))
286+
std::env::var("GBASE_VERIFY_PACK").map_or_else(
287+
|_| PathBuf::from("/tmp/da_m18c_hf_pull/tasks/realpr-more-itertools-1136"),
288+
PathBuf::from,
289+
)
290290
}
291291

292292
fn docker_base() -> String {
@@ -340,6 +340,7 @@ fn try_harbor_grade() -> Option<(u8, String)> {
340340

341341
/// S1 — runner epoch → intake/grade → |E| leaves → seal → validator Match.
342342
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
343+
#[allow(clippy::too_many_lines)]
343344
async fn s1_full_local_epoch_match_and_seal() {
344345
// --- 1. Runner epoch dispatch (fake miners, real loop) ---
345346
let expected = expected_set();
@@ -368,9 +369,10 @@ async fn s1_full_local_epoch_match_and_seal() {
368369
));
369370

370371
// --- 2. Intake + grade (real grade path; optional Harbor) ---
371-
let harbor_note = try_harbor_grade()
372-
.map(|(_, n)| n)
373-
.unwrap_or_else(|| "harbor_skipped (set GBASE_E2E_HARBOR=1 for live pack grade)".into());
372+
let harbor_note = try_harbor_grade().map_or_else(
373+
|| "harbor_skipped (set GBASE_E2E_HARBOR=1 for live pack grade)".into(),
374+
|(_, n)| n,
375+
);
374376
let grade_calls = Arc::new(AtomicU32::new(0));
375377
let verifier = FixtureVerifier {
376378
calls: Arc::clone(&grade_calls),

crates/agent-challenge/tests/gateway_submit_e2e.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Todo 28: emit_signed_leaf_set → GatewayClient POST /v1/weights/raw → seal → /v1/weights/latest.
1+
//! Todo 28: `emit_signed_leaf_set``GatewayClient` POST /v1/weights/raw → seal → /v1/weights/latest.
22
#![allow(clippy::unwrap_used, clippy::expect_used)]
33

44
use std::collections::{BTreeMap, BTreeSet};
@@ -116,6 +116,7 @@ fn gw_client(base: &str) -> GatewayClient {
116116

117117
/// S1: emit |E| → POST raw → seal → GET /v1/weights/latest 200 with |E| leaves.
118118
#[tokio::test]
119+
#[allow(clippy::too_many_lines)]
119120
async fn s1_emit_submit_seal_latest_serves_bundle() {
120121
let secret = sk();
121122
let pk = public_key_from_secret(&secret).unwrap();
@@ -232,7 +233,7 @@ async fn s1_emit_submit_seal_latest_serves_bundle() {
232233
let _ = shutdown.send(());
233234
}
234235

235-
/// S2: bad challenge_sig / untrusted key rejected; 5xx retry does not double-count.
236+
/// S2: bad `challenge_sig` / untrusted key rejected; 5xx retry does not double-count.
236237
#[tokio::test]
237238
async fn s2_bad_sig_rejected_and_retry_no_duplicate() {
238239
let secret = sk();
@@ -340,6 +341,5 @@ fn chrono_like_now() -> String {
340341
.output()
341342
.ok()
342343
.and_then(|o| String::from_utf8(o.stdout).ok())
343-
.map(|s| s.trim().to_owned())
344-
.unwrap_or_else(|| "unknown".into())
344+
.map_or_else(|| "unknown".into(), |s| s.trim().to_owned())
345345
}

0 commit comments

Comments
 (0)