style: cargo fmt --all
Formatting only. cargo fmt --check was already failing on main (accel SIMD kernels, agent, format, migrate, bench); CI now enforces it. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
bbe1baa208
commit
a3f7c6fe89
@@ -111,7 +111,11 @@ pub unsafe fn cosine_similarity(a: &[f32], b: &[f32]) -> f32 {
|
||||
}
|
||||
|
||||
let denom = (norm_a * norm_b).sqrt();
|
||||
if denom < f32::EPSILON { 0.0 } else { dot / denom }
|
||||
if denom < f32::EPSILON {
|
||||
0.0
|
||||
} else {
|
||||
dot / denom
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,11 @@ pub unsafe fn cosine_similarity(a: &[f32], b: &[f32]) -> f32 {
|
||||
}
|
||||
|
||||
let denom = (norm_a * norm_b).sqrt();
|
||||
if denom < f32::EPSILON { 0.0 } else { dot / denom }
|
||||
if denom < f32::EPSILON {
|
||||
0.0
|
||||
} else {
|
||||
dot / denom
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,11 @@ pub unsafe fn cosine_similarity(a: &[f32], b: &[f32]) -> f32 {
|
||||
}
|
||||
|
||||
let denom = (norm_a * norm_b).sqrt();
|
||||
if denom < f32::EPSILON { 0.0 } else { dot / denom }
|
||||
if denom < f32::EPSILON {
|
||||
0.0
|
||||
} else {
|
||||
dot / denom
|
||||
}
|
||||
}
|
||||
|
||||
/// NEON L2 distance.
|
||||
|
||||
@@ -21,7 +21,11 @@ pub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32 {
|
||||
norm_b += y * y;
|
||||
}
|
||||
let denom = (norm_a * norm_b).sqrt();
|
||||
if denom < f32::EPSILON { 0.0 } else { dot / denom }
|
||||
if denom < f32::EPSILON {
|
||||
0.0
|
||||
} else {
|
||||
dot / denom
|
||||
}
|
||||
}
|
||||
|
||||
pub fn batch_cosine(query: &[f32], vectors: &[&[f32]], results: &mut [(usize, f32)]) {
|
||||
|
||||
@@ -437,7 +437,11 @@ mod tests {
|
||||
fn rate_anomaly_names_offending_session() {
|
||||
let mut det = WriteAnomalyDetector::new(cfg());
|
||||
for i in 0..11 {
|
||||
det.record_write(event(1.0 + i as f64 * 0.1, "flood-session", MemorySource::User));
|
||||
det.record_write(event(
|
||||
1.0 + i as f64 * 0.1,
|
||||
"flood-session",
|
||||
MemorySource::User,
|
||||
));
|
||||
}
|
||||
let alert = det.check_rate_anomaly().unwrap();
|
||||
assert!(
|
||||
@@ -454,11 +458,19 @@ mod tests {
|
||||
let mut det = WriteAnomalyDetector::new(cfg());
|
||||
// 5 sessions with 1 write each (below any per-session limit)...
|
||||
for i in 0..5 {
|
||||
det.record_write(event(1.0 + i as f64 * 0.1, "minor-session", MemorySource::User));
|
||||
det.record_write(event(
|
||||
1.0 + i as f64 * 0.1,
|
||||
"minor-session",
|
||||
MemorySource::User,
|
||||
));
|
||||
}
|
||||
// ...plus one session responsible for the majority of the flood.
|
||||
for i in 0..8 {
|
||||
det.record_write(event(2.0 + i as f64 * 0.1, "major-session", MemorySource::User));
|
||||
det.record_write(event(
|
||||
2.0 + i as f64 * 0.1,
|
||||
"major-session",
|
||||
MemorySource::User,
|
||||
));
|
||||
}
|
||||
let alert = det.check_rate_anomaly().unwrap();
|
||||
assert!(
|
||||
|
||||
@@ -799,7 +799,12 @@ mod tests {
|
||||
#[test]
|
||||
fn test_access_memory_reactivation() {
|
||||
let mut engine = ConsolidationEngine::new(ConsolidationConfig::default());
|
||||
let id = engine.add_memory("chunk".to_string(), unit_vec(4, 0), UntrustedSource::User, 0.0);
|
||||
let id = engine.add_memory(
|
||||
"chunk".to_string(),
|
||||
unit_vec(4, 0),
|
||||
UntrustedSource::User,
|
||||
0.0,
|
||||
);
|
||||
|
||||
engine.access_memory(id, 5000.0);
|
||||
let rec = engine.get_by_id(id).unwrap();
|
||||
|
||||
@@ -427,7 +427,10 @@ impl HDF5Memory {
|
||||
if self.provenance.get(record_id as u64).is_none() {
|
||||
return; // nothing recorded yet this session — nothing to check
|
||||
}
|
||||
if !self.provenance.verify_integrity(record_id as u64, current_chunk) {
|
||||
if !self
|
||||
.provenance
|
||||
.verify_integrity(record_id as u64, current_chunk)
|
||||
{
|
||||
self.anomaly_alerts.push(anomaly::AnomalyAlert {
|
||||
severity: anomaly::Severity::High,
|
||||
message: format!(
|
||||
|
||||
@@ -1228,8 +1228,7 @@ mod tests {
|
||||
drop(wal); // simulate a restart without ever truncating the WAL
|
||||
|
||||
let mut wal2 = WalFile::open(&wal_path).unwrap();
|
||||
wal2.append_save(&make_wal_entry("second", &[2.0]))
|
||||
.unwrap();
|
||||
wal2.append_save(&make_wal_entry("second", &[2.0])).unwrap();
|
||||
drop(wal2);
|
||||
|
||||
let entries = WalFile::read_entries(&wal_path).unwrap();
|
||||
|
||||
@@ -242,7 +242,12 @@ fn run_quality_benchmark() {
|
||||
for i in 0..990 {
|
||||
let chunk = make_noise_content(i);
|
||||
let embedding = make_embedding(i + 100);
|
||||
engine.add_trusted_memory(chunk, embedding, TrustedSource::System, now + i as f64 * 0.1);
|
||||
engine.add_trusted_memory(
|
||||
chunk,
|
||||
embedding,
|
||||
TrustedSource::System,
|
||||
now + i as f64 * 0.1,
|
||||
);
|
||||
}
|
||||
|
||||
println!(" → Inserted {} records total", engine.records().len());
|
||||
|
||||
@@ -80,7 +80,10 @@ impl SymbolTableNode {
|
||||
offset_size: u8,
|
||||
) -> Result<SymbolTableNode, FormatError> {
|
||||
// signature(4) + version(1) + reserved(1) + number_of_symbols(2) = 8
|
||||
if offset.checked_add(8).is_none_or(|end| end > file_data.len()) {
|
||||
if offset
|
||||
.checked_add(8)
|
||||
.is_none_or(|end| end > file_data.len())
|
||||
{
|
||||
return Err(FormatError::UnexpectedEof {
|
||||
expected: offset.saturating_add(8),
|
||||
available: file_data.len(),
|
||||
@@ -103,12 +106,12 @@ impl SymbolTableNode {
|
||||
// Each entry: link_name_offset(os) + obj_hdr_addr(os) + cache_type(4) + reserved(4) + scratch(16)
|
||||
let entry_size = os + os + 4 + 4 + 16;
|
||||
let entries_start = offset + 8;
|
||||
let needed = entries_start
|
||||
.checked_add(num_symbols * entry_size)
|
||||
.ok_or(FormatError::UnexpectedEof {
|
||||
let needed = entries_start.checked_add(num_symbols * entry_size).ok_or(
|
||||
FormatError::UnexpectedEof {
|
||||
expected: usize::MAX,
|
||||
available: file_data.len(),
|
||||
})?;
|
||||
},
|
||||
)?;
|
||||
if needed > file_data.len() {
|
||||
return Err(FormatError::UnexpectedEof {
|
||||
expected: needed,
|
||||
|
||||
@@ -57,7 +57,11 @@ fn iso8601_now() -> String {
|
||||
.as_secs();
|
||||
let days = (secs / 86_400) as i64;
|
||||
let time_of_day = secs % 86_400;
|
||||
let (h, m, s) = (time_of_day / 3600, (time_of_day % 3600) / 60, time_of_day % 60);
|
||||
let (h, m, s) = (
|
||||
time_of_day / 3600,
|
||||
(time_of_day % 3600) / 60,
|
||||
time_of_day % 60,
|
||||
);
|
||||
let (y, mo, d) = civil_from_days(days);
|
||||
format!("{y:04}-{mo:02}-{d:02}T{h:02}:{m:02}:{s:02}Z")
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ pub use clawhdf5_format::dict_encoding::{DictEncoded, DictionaryEncoder};
|
||||
pub use clawhdf5_format::property_list::{
|
||||
DatasetCreateProps, FileAccessProps, FileCreateProps, lib_version,
|
||||
};
|
||||
#[cfg(feature = "provenance")]
|
||||
pub use clawhdf5_format::provenance;
|
||||
pub use clawhdf5_format::selection::Selection;
|
||||
pub use clawhdf5_format::superblock::swmr_flags;
|
||||
pub use clawhdf5_format::type_builders::{CompoundTypeBuilder, EnumTypeBuilder, FillTime};
|
||||
#[cfg(feature = "provenance")]
|
||||
pub use clawhdf5_format::provenance;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
@@ -426,7 +426,6 @@ impl<'f> Dataset<'f> {
|
||||
Ok(data_read::read_as_strings(&raw, &dt)?)
|
||||
}
|
||||
|
||||
|
||||
// ----- Selection-based read methods -----
|
||||
|
||||
/// Read selected elements as raw bytes.
|
||||
|
||||
Reference in New Issue
Block a user