Skip to content

Commit a5cd6ca

Browse files
authored
Merge pull request #110 from AdaWorldAPI/claude/cognitive-layer-stack-77KUH
fix: resolve clippy lints for Rust 1.93 CI
2 parents 1d61435 + cbd74a0 commit a5cd6ca

7 files changed

Lines changed: 15 additions & 27 deletions

File tree

crates/ladybug-contract/src/container.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl Container {
114114
return items[0].clone();
115115
}
116116
let threshold = items.len() / 2;
117-
let even = items.len() % 2 == 0;
117+
let even = items.len().is_multiple_of(2);
118118
let mut result = Container::zero();
119119
for word in 0..CONTAINER_WORDS {
120120
let mut out = 0u64;
@@ -236,7 +236,7 @@ impl Container {
236236
#[inline(always)]
237237
pub fn view(words: &[u64; CONTAINER_WORDS]) -> &Container {
238238
debug_assert!(
239-
words.as_ptr() as usize % 64 == 0,
239+
(words.as_ptr() as usize).is_multiple_of(64),
240240
"Container::view requires 64-byte aligned input"
241241
);
242242
unsafe { &*(words.as_ptr() as *const Container) }
@@ -249,7 +249,7 @@ impl Container {
249249
#[inline(always)]
250250
pub fn view_mut(words: &mut [u64; CONTAINER_WORDS]) -> &mut Container {
251251
debug_assert!(
252-
words.as_ptr() as usize % 64 == 0,
252+
(words.as_ptr() as usize).is_multiple_of(64),
253253
"Container::view_mut requires 64-byte aligned input"
254254
);
255255
unsafe { &mut *(words.as_mut_ptr() as *mut Container) }

crates/ladybug-contract/src/geometry.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
//! Container geometry — how content containers are interpreted.
22
33
/// How the content containers of a [`CogRecord`] are arranged and interpreted.
4-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default)]
55
#[repr(u8)]
66
pub enum ContainerGeometry {
77
/// 1 content container: flat 8K CAM fingerprint (default, most common).
88
/// Total record: 2 × 1 KB = 2 KB.
9+
#[default]
910
Cam = 0,
1011

1112
/// 3 content containers: X (what) + Y (where) + Z (how), holographic.
@@ -61,9 +62,3 @@ impl ContainerGeometry {
6162
}
6263
}
6364
}
64-
65-
impl Default for ContainerGeometry {
66-
fn default() -> Self {
67-
ContainerGeometry::Cam
68-
}
69-
}

crates/ladybug-contract/src/index_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,6 @@ pub mod types {
129129

130130
/// Check if a type ID is an edge type.
131131
pub fn is_edge(t: u16) -> bool {
132-
t >= EDGE_START && t <= EDGE_END
132+
(EDGE_START..=EDGE_END).contains(&t)
133133
}
134134
}

crates/ladybug-contract/src/legacy.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,17 @@ use crate::record::CogRecord;
1717
// V1 StepStatus
1818
// ============================================================================
1919

20-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
20+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
2121
#[serde(rename_all = "snake_case")]
2222
pub enum V1StepStatus {
23+
#[default]
2324
Pending,
2425
Running,
2526
Completed,
2627
Failed,
2728
Skipped,
2829
}
2930

30-
impl Default for V1StepStatus {
31-
fn default() -> Self {
32-
Self::Pending
33-
}
34-
}
35-
3631
// ============================================================================
3732
// V1 UnifiedStep (crewai-rust / n8n-rs schema)
3833
// ============================================================================
@@ -309,9 +304,7 @@ impl From<&CogRecord> for V1DataEnvelope {
309304
}
310305
}
311306
// Pad L8-L10 with zero (not yet stored in container metadata)
312-
for _ in 7..10 {
313-
layer_activations.push(0.0);
314-
}
307+
layer_activations.extend(std::iter::repeat_n(0.0, 3));
315308

316309
V1DataEnvelope {
317310
data: Value::Null,

crates/ladybug-contract/src/wire.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ impl CogPacket {
355355
/// Get all 10 satisfaction scores as an array.
356356
pub fn satisfaction_array(&self) -> [f32; 10] {
357357
let mut scores = [0.0f32; 10];
358-
for i in 0..10 {
359-
scores[i] = self.satisfaction(i as u8);
358+
for (i, score) in scores.iter_mut().enumerate() {
359+
*score = self.satisfaction(i as u8);
360360
}
361361
scores
362362
}
@@ -578,7 +578,7 @@ impl CogPacket {
578578

579579
// Determine number of containers from header
580580
let payload_count = ((header[7] >> 24) & 0xFF) as usize;
581-
let payload_count = payload_count.max(1).min(2);
581+
let payload_count = payload_count.clamp(1, 2);
582582
let expected_bytes = HEADER_BYTES + payload_count * CONTAINER_BYTES;
583583

584584
if data.len() < expected_bytes {
@@ -691,7 +691,7 @@ impl CogPacket {
691691
_ => (0x0Fu8, wire_ops::EXECUTE),
692692
};
693693

694-
let source_addr = ((prefix as u16) << 8) | 0x00;
694+
let source_addr = (prefix as u16) << 8;
695695
let target_addr = ((prefix as u16) << 8) | 0x01;
696696

697697
// Content hash expanded to container via SplitMix64

src/cognitive/cognitive_kernel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//! └──────────────────────────────────────────────────────────────────────┘
3131
//! ```
3232
33-
use crate::cognitive::layer_stack::{ConsciousnessSnapshot, LayerId, LayerNode, LayerResult, NUM_LAYERS};
33+
use crate::cognitive::layer_stack::{ConsciousnessSnapshot, LayerId, LayerResult, NUM_LAYERS};
3434
use crate::cognitive::metacog::MetaCognition;
3535
use crate::cognitive::satisfaction_gate::LayerSatisfaction;
3636
use crate::cognitive::sieve::SocraticSieve;

src/cognitive/sieve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl SocraticSieve {
203203
if sources.is_empty() {
204204
return TruthValue::unknown();
205205
}
206-
let mut merged = sources[0].clone();
206+
let mut merged = sources[0];
207207
for source in &sources[1..] {
208208
merged = merged.revision(source);
209209
}

0 commit comments

Comments
 (0)