Skip to content

Commit 546b0d9

Browse files
mivertowskiclaude
andcommitted
fix: resolve all clippy warnings for v1.0.0 release
89 warnings fixed across 14 files: - Remove unused imports (backpressure, drain, llm) - Remove unnecessary mut (registry) - Remove unneeded return (audit) - Replace unwrap with expect (hot_reload) - Allow clippy::unwrap_used on IR fmt::Write to String (infallible) - Allow deprecated on intentional XOR demo usage (security) - Derive Default instead of manual impl (ring_kernel codegen) - Add doc comments to 57 undocumented struct fields across actor, backpressure, dlq, hot_reload, memory_pressure, registry, vector, llm, streaming modules Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7b4b4bf commit 546b0d9

17 files changed

Lines changed: 144 additions & 35 deletions

File tree

crates/ringkernel-core/src/actor.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,16 @@ pub enum RestartPolicy {
118118
},
119119
/// Restart the failed actor and all its siblings (children of the same parent).
120120
OneForAll {
121+
/// Maximum restart attempts within the time window.
121122
max_restarts: u32,
123+
/// Time window for counting restarts.
122124
window: Duration,
123125
},
124126
/// Restart the failed actor and all actors that were started after it.
125127
RestForOne {
128+
/// Maximum restart attempts within the time window.
126129
max_restarts: u32,
130+
/// Time window for counting restarts.
127131
window: Duration,
128132
},
129133
}
@@ -537,7 +541,7 @@ impl ActorSupervisor {
537541
});
538542
}
539543

540-
RestartPolicy::OneForOne { max_restarts, .. } => {
544+
RestartPolicy::OneForOne { .. } => {
541545
// Restart only the failed actor
542546
match self.restart_actor(failed_id, config) {
543547
Ok(new_id) => {
@@ -666,35 +670,56 @@ pub enum SupervisionAction {
666670
/// Actor marked as failed.
667671
MarkedFailed(ActorId),
668672
/// Actor was restarted.
669-
Restarted { old_id: ActorId, new_id: ActorId },
673+
Restarted {
674+
/// The original actor ID before restart.
675+
old_id: ActorId,
676+
/// The new actor ID after restart.
677+
new_id: ActorId,
678+
},
670679
/// A sibling was destroyed (OneForAll/RestForOne).
671680
DestroyedSibling(ActorId),
672681
/// All siblings destroyed, parent needs to re-create them.
673-
AllSiblingsDestroyed { parent: ActorId },
682+
AllSiblingsDestroyed {
683+
/// Parent actor that owns the destroyed siblings.
684+
parent: ActorId,
685+
},
674686
/// Failure escalated to parent supervisor.
675-
Escalated { failed: ActorId, escalated_to: Option<ActorId> },
687+
Escalated {
688+
/// Actor that failed.
689+
failed: ActorId,
690+
/// Parent supervisor the failure was escalated to.
691+
escalated_to: Option<ActorId>,
692+
},
676693
}
677694

678695
/// Errors from actor lifecycle operations.
679696
#[derive(Debug, Clone)]
680697
pub enum ActorError {
681698
/// No available actor slots in the pool.
682699
PoolExhausted {
700+
/// Total pool capacity.
683701
capacity: u32,
702+
/// Number of currently active actors.
684703
active: u32,
685704
},
686705
/// Invalid actor ID.
687706
InvalidId(ActorId),
688707
/// Invalid state transition.
689708
InvalidStateTransition {
709+
/// Actor that attempted the invalid transition.
690710
actor: ActorId,
711+
/// Current state of the actor.
691712
from: ActorState,
713+
/// Attempted target state.
692714
to: ActorState,
693715
},
694716
/// Actor has exceeded its maximum restart budget.
695717
MaxRestartsExceeded {
718+
/// Actor that exceeded its restart budget.
696719
actor: ActorId,
720+
/// Number of restarts attempted.
697721
restarts: u32,
722+
/// Maximum allowed restarts.
698723
max: u32,
699724
},
700725
}

crates/ringkernel-core/src/audit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,11 +1481,11 @@ impl AuditSink for CloudWatchSink {
14811481
fn flush(&self) -> std::io::Result<()> {
14821482
#[cfg(feature = "cloudwatch")]
14831483
{
1484-
return self.flush_to_cloudwatch();
1484+
self.flush_to_cloudwatch()
14851485
}
14861486
#[cfg(not(feature = "cloudwatch"))]
14871487
{
1488-
return self.flush_stub();
1488+
self.flush_stub()
14891489
}
14901490
}
14911491

crates/ringkernel-core/src/backpressure.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
//! ```
2626
2727
use std::sync::atomic::{AtomicI64, AtomicU64, Ordering};
28-
use std::time::Instant;
2928

3029
/// Flow control configuration for a K2K channel.
3130
#[derive(Debug, Clone)]
@@ -60,7 +59,10 @@ pub enum OverflowPolicy {
6059
/// Block the producer until credits are available.
6160
Block,
6261
/// Buffer messages locally (up to buffer_limit).
63-
Buffer { limit: u32 },
62+
Buffer {
63+
/// Maximum number of messages to buffer.
64+
limit: u32,
65+
},
6466
/// Drop the message and route to dead letter queue.
6567
DropToDlq,
6668
/// Drop the message silently (with metric increment).
@@ -210,13 +212,21 @@ impl FlowController {
210212
/// Snapshot of flow control metrics (non-atomic, for reporting).
211213
#[derive(Debug, Clone)]
212214
pub struct FlowMetricsSnapshot {
215+
/// Credits currently available to the producer.
213216
pub credits_available: i64,
217+
/// Total credits granted since creation.
214218
pub credits_granted: u64,
219+
/// Total credits consumed since creation.
215220
pub credits_consumed: u64,
221+
/// Number of backpressure events triggered.
216222
pub backpressure_events: u64,
223+
/// Number of messages routed to the dead letter queue.
217224
pub dlq_routed: u64,
225+
/// Number of messages silently dropped.
218226
pub dropped: u64,
227+
/// Number of high water mark signals emitted.
219228
pub high_water_signals: u64,
229+
/// Number of low water mark signals emitted.
220230
pub low_water_signals: u64,
221231
}
222232

crates/ringkernel-core/src/dlq.rs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,37 @@ use crate::runtime::KernelId;
1717
#[derive(Debug, Clone, PartialEq, Eq)]
1818
pub enum DeadLetterReason {
1919
/// Message processing failed after max retries.
20-
MaxRetriesExceeded { retries: u32, max: u32 },
20+
MaxRetriesExceeded {
21+
/// Number of retries attempted.
22+
retries: u32,
23+
/// Maximum retries allowed.
24+
max: u32,
25+
},
2126
/// Destination actor not found.
22-
ActorNotFound { actor_name: String },
27+
ActorNotFound {
28+
/// Name of the actor that was not found.
29+
actor_name: String,
30+
},
2331
/// Queue was full and overflow policy is DropToDlq.
24-
QueueFull { queue_capacity: usize },
32+
QueueFull {
33+
/// Capacity of the full queue.
34+
queue_capacity: usize,
35+
},
2536
/// Message TTL expired before delivery.
26-
TtlExpired { age: Duration },
37+
TtlExpired {
38+
/// Age of the message when it expired.
39+
age: Duration,
40+
},
2741
/// Actor was destroyed while message was in-flight.
28-
ActorDestroyed { actor_id: String },
42+
ActorDestroyed {
43+
/// ID of the destroyed actor.
44+
actor_id: String,
45+
},
2946
/// Explicit rejection by the actor's message handler.
30-
Rejected { reason: String },
47+
Rejected {
48+
/// Reason for rejection.
49+
reason: String,
50+
},
3151
}
3252

3353
impl std::fmt::Display for DeadLetterReason {

crates/ringkernel-core/src/drain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
use std::time::{Duration, Instant};
1010

11-
use crate::actor::{ActorId, ActorState, ActorSupervisor};
11+
use crate::actor::{ActorId, ActorSupervisor};
1212

1313
/// Shutdown phase.
1414
#[derive(Debug, Clone, Copy, PartialEq, Eq)]

crates/ringkernel-core/src/hot_reload.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ impl HotReloadConfig {
176176
};
177177

178178
// Apply the change
179-
self.entries.get_mut(key).unwrap().value = new_value;
179+
self.entries
180+
.get_mut(key)
181+
.expect("config entry must exist after contains_key check")
182+
.value = new_value;
180183

181184
// Audit trail
182185
self.changes.push(change);
@@ -232,8 +235,11 @@ pub enum ConfigUpdateError {
232235
NotReloadable(String),
233236
/// Value type doesn't match registered type.
234237
TypeMismatch {
238+
/// Configuration key with the type mismatch.
235239
key: String,
240+
/// Expected type name.
236241
expected: String,
242+
/// Actual type name provided.
237243
got: String,
238244
},
239245
/// Custom validation failed.

crates/ringkernel-core/src/memory_pressure.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,17 @@ pub enum AllocationResult {
142142
/// Allocation granted, within soft limit.
143143
Granted,
144144
/// Allocation granted, but soft limit exceeded (warning).
145-
GrantedWithWarning { usage_fraction: f64 },
145+
GrantedWithWarning {
146+
/// Fraction of memory budget currently in use (0.0 to 1.0).
147+
usage_fraction: f64,
148+
},
146149
/// Allocation denied — would exceed hard limit.
147-
Denied { requested: u64, available: u64 },
150+
Denied {
151+
/// Number of bytes requested.
152+
requested: u64,
153+
/// Number of bytes available.
154+
available: u64,
155+
},
148156
}
149157

150158
/// Global memory pressure monitor for all actors.

crates/ringkernel-core/src/registry.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,25 @@ pub struct RegistryEntry {
4646
pub enum RegistryEvent {
4747
/// A new actor was registered.
4848
Registered {
49+
/// Symbolic name of the registered actor.
4950
name: String,
51+
/// Kernel ID assigned to the actor.
5052
kernel_id: KernelId,
5153
},
5254
/// An actor was deregistered.
5355
Deregistered {
56+
/// Symbolic name of the deregistered actor.
5457
name: String,
58+
/// Kernel ID that was removed.
5559
kernel_id: KernelId,
5660
},
5761
/// An actor's registration was updated.
5862
Updated {
63+
/// Symbolic name of the updated actor.
5964
name: String,
65+
/// Previous kernel ID.
6066
old_kernel_id: KernelId,
67+
/// New kernel ID.
6168
new_kernel_id: KernelId,
6269
},
6370
}
@@ -287,10 +294,10 @@ impl Default for ActorRegistry {
287294
/// `**` matches any characters including `/`.
288295
/// `?` matches a single character.
289296
fn wildcard_match(pattern: &str, text: &str) -> bool {
290-
let mut p = pattern.chars().peekable();
291-
let mut t = text.chars().peekable();
297+
let p = pattern.chars().collect::<Vec<_>>();
298+
let t = text.chars().collect::<Vec<_>>();
292299

293-
wildcard_match_recursive(&mut p.collect::<Vec<_>>(), &mut t.collect::<Vec<_>>(), 0, 0)
300+
wildcard_match_recursive(&p, &t, 0, 0)
294301
}
295302

296303
fn wildcard_match_recursive(pattern: &[char], text: &[char], pi: usize, ti: usize) -> bool {

crates/ringkernel-core/src/security.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ pub struct MemoryEncryption {
404404

405405
impl MemoryEncryption {
406406
/// Create a new memory encryption manager.
407+
#[allow(deprecated)]
407408
pub fn new(config: EncryptionConfig) -> Self {
408409
let key_id = 1;
409410
let active_key = EncryptionKey::new(key_id, config.algorithm);
@@ -682,6 +683,7 @@ impl MemoryEncryption {
682683
}
683684

684685
/// Rotate encryption keys.
686+
#[allow(deprecated)]
685687
pub fn rotate_keys(&self) {
686688
let mut active = self.active_key.write().expect("active_key lock poisoned");
687689
let mut previous = self.previous_keys.write().expect("previous_keys lock poisoned");

crates/ringkernel-core/src/vector.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,17 @@ fn dot_product(a: &[f32], b: &[f32]) -> f32 {
247247
#[derive(Debug, Clone)]
248248
pub enum VectorStoreError {
249249
/// Vector dimension doesn't match store configuration.
250-
DimensionMismatch { expected: usize, got: usize },
250+
DimensionMismatch {
251+
/// Expected vector dimension.
252+
expected: usize,
253+
/// Actual vector dimension provided.
254+
got: usize,
255+
},
251256
/// Store is full.
252-
CapacityExceeded { capacity: usize },
257+
CapacityExceeded {
258+
/// Maximum capacity of the vector store.
259+
capacity: usize,
260+
},
253261
/// Vector not found.
254262
NotFound(u64),
255263
}

0 commit comments

Comments
 (0)