Skip to content

Commit ead5fc0

Browse files
authored
Merge pull request #105 from AdaWorldAPI/claude/code-review-SMMuY
fix: resolve CI build errors and warnings without #[allow] suppression
2 parents adb21c7 + 93c4888 commit ead5fc0

18 files changed

Lines changed: 294 additions & 279 deletions

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ quantum = [] # Quantum-inspired operators
4242
bench = [] # Benchmark suite (comparison vs Qdrant/Milvus)
4343
flight = ["arrow-flight", "tonic", "prost"] # Arrow Flight MCP server
4444
crewai = ["flight"] # crewAI orchestration (A2A, agent cards, thinking templates)
45+
json_fallback = [] # Legacy JSON MCP types (backwards compat)
4546

4647
# All features
4748
full = [

src/bin/flight_server.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use std::net::SocketAddr;
2424
use std::sync::Arc;
2525

2626
use parking_lot::RwLock;
27-
use tokio::net::TcpListener;
2827
use tonic::transport::Server;
2928

3029
use ladybug::flight::LadybugFlightService;

src/container/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use super::*;
44
use super::geometry::ContainerGeometry;
5-
use super::meta::{MetaView, MetaViewMut, W_NARS_BASE, SCHEMA_VERSION, W_CHECKSUM};
5+
use super::meta::{MetaView, MetaViewMut, SCHEMA_VERSION};
66
use super::record::CogRecord;
77
use super::cache::ContainerCache;
88
use super::search::{belichtungsmesser, cascade_search, MexicanHat, hamming_early_exit};
@@ -1021,7 +1021,7 @@ fn test_xyz_trace_and_probe() {
10211021
// 15. INSERT_LEAF: SPINE-GUIDED INSERTION
10221022
// ============================================================================
10231023

1024-
use super::insert::{insert_leaf, InsertResult, SPLIT_THRESHOLD, RESONANCE_THRESHOLD};
1024+
use super::insert::{insert_leaf, InsertResult, SPLIT_THRESHOLD};
10251025

10261026
#[test]
10271027
fn test_insert_path3_new_branch_into_empty_tree() {
@@ -1700,7 +1700,7 @@ fn test_redis_pipeline_building() {
17001700
// ============================================================================
17011701

17021702
use std::collections::HashMap;
1703-
use super::traversal::{self, DnSemiring};
1703+
use super::traversal::{self};
17041704

17051705
#[test]
17061706
fn test_boolean_bfs_traversal() {

src/core/scent.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,12 @@ fn timestamp() -> u64 {
510510

511511
// ========== SIMD Optimized Scent Scan ==========
512512

513-
#[cfg(target_arch = "x86_64")]
513+
#[cfg(all(target_arch = "x86_64", target_feature = "avx2"))]
514514
mod simd {
515-
516-
515+
use super::{SCENT_BYTES, BUCKETS, scent_distance};
516+
517517
/// SIMD-optimized scent scan (AVX2)
518518
/// Compares query against 256 scents, returns matching chunk IDs
519-
#[cfg(target_feature = "avx2")]
520519
pub fn find_chunks_simd(
521520
scents: &[[u8; SCENT_BYTES]; BUCKETS],
522521
query: &[u8; SCENT_BYTES],
@@ -590,7 +589,7 @@ mod tests {
590589
let fp = make_fp(0x42);
591590
idx.on_append(&fp, 0);
592591

593-
let (l1, l2) = idx.assign(&fp);
592+
let (l1, _l2) = idx.assign(&fp);
594593
assert_eq!(l1, 0x42);
595594

596595
let matches = idx.find_chunks(&extract_scent(&fp), 10);

src/core/simd.rs

Lines changed: 126 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,27 @@ use crate::core::Fingerprint;
1010
use crate::FINGERPRINT_U64;
1111

1212

13-
#[cfg(target_arch = "aarch64")]
14-
use std::arch::aarch64::*;
15-
1613
/// Compute Hamming distance between two fingerprints.
1714
///
1815
/// Automatically dispatches to the best SIMD implementation available.
1916
#[inline]
2017
pub fn hamming_distance(a: &Fingerprint, b: &Fingerprint) -> u32 {
2118
#[cfg(all(target_arch = "x86_64", target_feature = "avx512vpopcntdq"))]
22-
unsafe { return hamming_avx512(a, b); }
23-
19+
{ return unsafe { hamming_avx512(a, b) }; }
20+
2421
#[cfg(all(target_arch = "x86_64", target_feature = "avx2", not(target_feature = "avx512vpopcntdq")))]
25-
unsafe { return hamming_avx2(a, b); }
26-
22+
{ return unsafe { hamming_avx2(a, b) }; }
23+
2724
#[cfg(all(target_arch = "aarch64", target_feature = "neon"))]
28-
unsafe { return hamming_neon(a, b); }
29-
25+
{ return unsafe { hamming_neon(a, b) }; }
26+
3027
// Scalar fallback
31-
hamming_scalar(a, b)
28+
#[cfg(not(any(
29+
all(target_arch = "x86_64", target_feature = "avx512vpopcntdq"),
30+
all(target_arch = "x86_64", target_feature = "avx2"),
31+
all(target_arch = "aarch64", target_feature = "neon"),
32+
)))]
33+
{ return hamming_scalar(a, b); }
3234
}
3335

3436
/// Scalar implementation (works everywhere)
@@ -48,123 +50,135 @@ pub fn hamming_scalar(a: &Fingerprint, b: &Fingerprint) -> u32 {
4850
#[cfg(all(target_arch = "x86_64", target_feature = "avx512vpopcntdq"))]
4951
#[target_feature(enable = "avx512f", enable = "avx512vpopcntdq")]
5052
unsafe fn hamming_avx512(a: &Fingerprint, b: &Fingerprint) -> u32 {
51-
let a_ptr = a.as_raw().as_ptr();
52-
let b_ptr = b.as_raw().as_ptr();
53-
54-
let mut sum = _mm512_setzero_si512();
55-
56-
// Process 8 u64 at a time (512 bits)
57-
let mut i = 0;
58-
while i + 8 <= FINGERPRINT_U64 {
59-
let va = _mm512_loadu_si512(a_ptr.add(i) as *const __m512i);
60-
let vb = _mm512_loadu_si512(b_ptr.add(i) as *const __m512i);
61-
let xor = _mm512_xor_si512(va, vb);
62-
let popcnt = _mm512_popcnt_epi64(xor);
63-
sum = _mm512_add_epi64(sum, popcnt);
64-
i += 8;
65-
}
66-
67-
// Horizontal sum
68-
let mut total = _mm512_reduce_add_epi64(sum) as u32;
69-
70-
// Handle remaining (256 % 8 = 0, no remainder at 16K)
71-
while i < FINGERPRINT_U64 {
72-
total += (*a_ptr.add(i) ^ *b_ptr.add(i)).count_ones();
73-
i += 1;
53+
unsafe {
54+
use std::arch::x86_64::*;
55+
56+
let a_ptr = a.as_raw().as_ptr();
57+
let b_ptr = b.as_raw().as_ptr();
58+
59+
let mut sum = _mm512_setzero_si512();
60+
61+
// Process 8 u64 at a time (512 bits)
62+
let mut i = 0;
63+
while i + 8 <= FINGERPRINT_U64 {
64+
let va = _mm512_loadu_si512(a_ptr.add(i) as *const __m512i);
65+
let vb = _mm512_loadu_si512(b_ptr.add(i) as *const __m512i);
66+
let xor = _mm512_xor_si512(va, vb);
67+
let popcnt = _mm512_popcnt_epi64(xor);
68+
sum = _mm512_add_epi64(sum, popcnt);
69+
i += 8;
70+
}
71+
72+
// Horizontal sum
73+
let mut total = _mm512_reduce_add_epi64(sum) as u32;
74+
75+
// Handle remaining (256 % 8 = 0, no remainder at 16K)
76+
while i < FINGERPRINT_U64 {
77+
total += (*a_ptr.add(i) ^ *b_ptr.add(i)).count_ones();
78+
i += 1;
79+
}
80+
81+
total
7482
}
75-
76-
total
7783
}
7884

7985
/// AVX2 implementation (fallback for older x86_64)
8086
#[cfg(all(target_arch = "x86_64", target_feature = "avx2"))]
8187
#[target_feature(enable = "avx2")]
8288
unsafe fn hamming_avx2(a: &Fingerprint, b: &Fingerprint) -> u32 {
83-
let a_ptr = a.as_raw().as_ptr();
84-
let b_ptr = b.as_raw().as_ptr();
85-
86-
// Lookup table for 4-bit popcount
87-
let lookup = _mm256_setr_epi8(
88-
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
89-
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
90-
);
91-
let low_mask = _mm256_set1_epi8(0x0f);
92-
93-
let mut total_sum = _mm256_setzero_si256();
94-
95-
// Process 4 u64 at a time (256 bits)
96-
let mut i = 0;
97-
while i + 4 <= FINGERPRINT_U64 {
98-
let va = _mm256_loadu_si256(a_ptr.add(i) as *const __m256i);
99-
let vb = _mm256_loadu_si256(b_ptr.add(i) as *const __m256i);
100-
let xor = _mm256_xor_si256(va, vb);
101-
102-
// Popcount via lookup table
103-
let lo = _mm256_and_si256(xor, low_mask);
104-
let hi = _mm256_and_si256(_mm256_srli_epi16(xor, 4), low_mask);
105-
let popcnt_lo = _mm256_shuffle_epi8(lookup, lo);
106-
let popcnt_hi = _mm256_shuffle_epi8(lookup, hi);
107-
let popcnt = _mm256_add_epi8(popcnt_lo, popcnt_hi);
108-
109-
// Sum bytes
110-
let sad = _mm256_sad_epu8(popcnt, _mm256_setzero_si256());
111-
total_sum = _mm256_add_epi64(total_sum, sad);
112-
113-
i += 4;
114-
}
115-
116-
// Horizontal sum
117-
let sum_lo = _mm256_extracti128_si256(total_sum, 0);
118-
let sum_hi = _mm256_extracti128_si256(total_sum, 1);
119-
let sum128 = _mm_add_epi64(sum_lo, sum_hi);
120-
let mut total = (_mm_extract_epi64(sum128, 0) + _mm_extract_epi64(sum128, 1)) as u32;
121-
122-
// Handle remaining
123-
while i < FINGERPRINT_U64 {
124-
total += (*a_ptr.add(i) ^ *b_ptr.add(i)).count_ones();
125-
i += 1;
89+
unsafe {
90+
use std::arch::x86_64::*;
91+
92+
let a_ptr = a.as_raw().as_ptr();
93+
let b_ptr = b.as_raw().as_ptr();
94+
95+
// Lookup table for 4-bit popcount
96+
let lookup = _mm256_setr_epi8(
97+
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
98+
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
99+
);
100+
let low_mask = _mm256_set1_epi8(0x0f);
101+
102+
let mut total_sum = _mm256_setzero_si256();
103+
104+
// Process 4 u64 at a time (256 bits)
105+
let mut i = 0;
106+
while i + 4 <= FINGERPRINT_U64 {
107+
let va = _mm256_loadu_si256(a_ptr.add(i) as *const __m256i);
108+
let vb = _mm256_loadu_si256(b_ptr.add(i) as *const __m256i);
109+
let xor = _mm256_xor_si256(va, vb);
110+
111+
// Popcount via lookup table
112+
let lo = _mm256_and_si256(xor, low_mask);
113+
let hi = _mm256_and_si256(_mm256_srli_epi16(xor, 4), low_mask);
114+
let popcnt_lo = _mm256_shuffle_epi8(lookup, lo);
115+
let popcnt_hi = _mm256_shuffle_epi8(lookup, hi);
116+
let popcnt = _mm256_add_epi8(popcnt_lo, popcnt_hi);
117+
118+
// Sum bytes
119+
let sad = _mm256_sad_epu8(popcnt, _mm256_setzero_si256());
120+
total_sum = _mm256_add_epi64(total_sum, sad);
121+
122+
i += 4;
123+
}
124+
125+
// Horizontal sum
126+
let sum_lo = _mm256_extracti128_si256(total_sum, 0);
127+
let sum_hi = _mm256_extracti128_si256(total_sum, 1);
128+
let sum128 = _mm_add_epi64(sum_lo, sum_hi);
129+
let mut total = (_mm_extract_epi64(sum128, 0) + _mm_extract_epi64(sum128, 1)) as u32;
130+
131+
// Handle remaining
132+
while i < FINGERPRINT_U64 {
133+
total += (*a_ptr.add(i) ^ *b_ptr.add(i)).count_ones();
134+
i += 1;
135+
}
136+
137+
total
126138
}
127-
128-
total
129139
}
130140

131141
/// ARM NEON implementation
132142
#[cfg(all(target_arch = "aarch64", target_feature = "neon"))]
133143
#[target_feature(enable = "neon")]
134144
unsafe fn hamming_neon(a: &Fingerprint, b: &Fingerprint) -> u32 {
135-
let a_ptr = a.as_raw().as_ptr() as *const u8;
136-
let b_ptr = b.as_raw().as_ptr() as *const u8;
137-
138-
let mut sum = vdupq_n_u64(0);
139-
140-
// Process 16 bytes at a time
141-
let mut i = 0;
142-
let byte_len = FINGERPRINT_U64 * 8;
143-
while i + 16 <= byte_len {
144-
let va = vld1q_u8(a_ptr.add(i));
145-
let vb = vld1q_u8(b_ptr.add(i));
146-
let xor = veorq_u8(va, vb);
147-
let cnt = vcntq_u8(xor); // Count bits per byte
148-
149-
// Sum to 64-bit
150-
let sum16 = vpaddlq_u8(cnt); // u8 -> u16
151-
let sum32 = vpaddlq_u16(sum16); // u16 -> u32
152-
let sum64 = vpaddlq_u32(sum32); // u32 -> u64
153-
sum = vaddq_u64(sum, sum64);
154-
155-
i += 16;
156-
}
157-
158-
// Horizontal sum
159-
let mut total = (vgetq_lane_u64(sum, 0) + vgetq_lane_u64(sum, 1)) as u32;
160-
161-
// Handle remaining bytes
162-
while i < byte_len {
163-
total += (*a_ptr.add(i) ^ *b_ptr.add(i)).count_ones();
164-
i += 1;
145+
unsafe {
146+
use std::arch::aarch64::*;
147+
148+
let a_ptr = a.as_raw().as_ptr() as *const u8;
149+
let b_ptr = b.as_raw().as_ptr() as *const u8;
150+
151+
let mut sum = vdupq_n_u64(0);
152+
153+
// Process 16 bytes at a time
154+
let mut i = 0;
155+
let byte_len = FINGERPRINT_U64 * 8;
156+
while i + 16 <= byte_len {
157+
let va = vld1q_u8(a_ptr.add(i));
158+
let vb = vld1q_u8(b_ptr.add(i));
159+
let xor = veorq_u8(va, vb);
160+
let cnt = vcntq_u8(xor); // Count bits per byte
161+
162+
// Sum to 64-bit
163+
let sum16 = vpaddlq_u8(cnt); // u8 -> u16
164+
let sum32 = vpaddlq_u16(sum16); // u16 -> u32
165+
let sum64 = vpaddlq_u32(sum32); // u32 -> u64
166+
sum = vaddq_u64(sum, sum64);
167+
168+
i += 16;
169+
}
170+
171+
// Horizontal sum
172+
let mut total = (vgetq_lane_u64(sum, 0) + vgetq_lane_u64(sum, 1)) as u32;
173+
174+
// Handle remaining bytes
175+
while i < byte_len {
176+
total += (*a_ptr.add(i) ^ *b_ptr.add(i)).count_ones();
177+
i += 1;
178+
}
179+
180+
total
165181
}
166-
167-
total
168182
}
169183

170184
/// Batch Hamming distance computation (parallel)

src/core/vsa.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ mod tests {
262262
let cat1 = Fingerprint::from_content("cat instance 1");
263263
let cat2 = Fingerprint::from_content("cat instance 2");
264264
let cat3 = Fingerprint::from_content("cat instance 3");
265-
let dog = Fingerprint::from_content("dog");
265+
let _dog = Fingerprint::from_content("dog");
266266

267267
let prototype = Fingerprint::bundle(&[cat1.clone(), cat2.clone(), cat3.clone()]);
268268

@@ -287,7 +287,7 @@ mod tests {
287287
assert!(seq.similarity(&word1) < 0.9);
288288

289289
// But we can decode first word
290-
let decoded_first = seq.unbind(&Fingerprint::zero().permute(0));
290+
let _decoded_first = seq.unbind(&Fingerprint::zero().permute(0));
291291
// (This is a simplified test - real decoding needs iterative cleanup)
292292
}
293293

src/fabric/executor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ mod tests {
709709
let fp = random_fp(42);
710710
exec.registers.write(0x8000, fp);
711711

712-
let builder = FrameBuilder::new(1);
712+
let _builder = FrameBuilder::new(1);
713713

714714
// Simple program: LOAD, PERMUTE, HALT
715715
let program = vec![

src/fabric/mrna.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ mod tests {
368368
mrna.pollinate_from(Subsystem::Compression, &compress_fp);
369369

370370
// Check cross-pollination
371-
let cross = mrna.cross_pollinate(
371+
let _cross = mrna.cross_pollinate(
372372
Subsystem::Compression,
373373
&compress_fp,
374374
Subsystem::Query,

src/fabric/udp_transport.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -517,14 +517,11 @@ mod tests {
517517
let sender_addr = "127.0.0.1:0";
518518
let receiver_addr = "127.0.0.1:0";
519519

520-
let sender = UdpSender::new(sender_addr).unwrap();
521-
let receiver = UdpReceiver::new(receiver_addr).unwrap();
522-
523-
// Get actual bound addresses
524-
let receiver_actual = receiver.socket.local_addr().unwrap();
520+
let _sender = UdpSender::new(sender_addr).unwrap();
521+
let _receiver = UdpReceiver::new(receiver_addr).unwrap();
525522

526523
// Create sender with known destination
527-
let mut sender = UdpSender::new(sender_addr).unwrap();
524+
let sender = UdpSender::new(sender_addr).unwrap();
528525

529526
// Note: Full loopback test requires threads or async
530527
// Just verify construction works

0 commit comments

Comments
 (0)