Skip to content

Commit 4b9c708

Browse files
tbitcsoz-agent
andcommitted
style: cargo fmt --all
Co-Authored-By: Oz <oz-agent@warp.dev>
1 parent f665259 commit 4b9c708

6 files changed

Lines changed: 25 additions & 47 deletions

File tree

crates/cpac-crypto/src/pqc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ fn keygen_mldsa65() -> CpacResult<PqcKeyPair> {
225225

226226
fn sign_mldsa65(message: &[u8], secret_key: &[u8]) -> CpacResult<Vec<u8>> {
227227
use ml_dsa::{MlDsa65, Seed, SigningKey};
228-
let seed: Seed = secret_key
229-
.try_into()
230-
.map_err(|_| CpacError::Encryption("invalid ML-DSA-65 seed length (expected 32 bytes)".into()))?;
228+
let seed: Seed = secret_key.try_into().map_err(|_| {
229+
CpacError::Encryption("invalid ML-DSA-65 seed length (expected 32 bytes)".into())
230+
})?;
231231
let sk = SigningKey::<MlDsa65>::from_seed(&seed);
232232
let sig = sk
233233
.sign_deterministic(message, &[])

crates/cpac-engine/src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,7 @@ pub fn compress(data: &[u8], config: &CompressConfig) -> CpacResult<CompressResu
452452
// per-block frame. The frame stores original_size = residual size so the
453453
// per-block decompressor returns the residual directly. The caller
454454
// (compress_parallel) stores metadata once and applies reconstruction.
455-
let msn_applied_externally =
456-
config.msn_metadata_external && !msn_metadata.is_empty();
455+
let msn_applied_externally = config.msn_metadata_external && !msn_metadata.is_empty();
457456
if msn_applied_externally {
458457
cpac_trace!(
459458
"[TRACE] Phase 2: MSN applied externally — metadata excluded from frame ({}B meta, {}B residual)",
@@ -1022,8 +1021,7 @@ pub(crate) fn decompress_with_dict(
10221021
let (header, payload) = cpac_frame::decode_frame(data)?;
10231022

10241023
// 2. Entropy decompress with dictionary
1025-
let decompressed_payload =
1026-
cpac_entropy::decompress_with_dict(payload, header.backend, dict)?;
1024+
let decompressed_payload = cpac_entropy::decompress_with_dict(payload, header.backend, dict)?;
10271025

10281026
// 2.5 MSN inline metadata split
10291027
let (inline_meta_bytes, data_to_unpreprocess) =
@@ -1046,8 +1044,7 @@ pub(crate) fn decompress_with_dict(
10461044
let mut result = if header.dag_descriptor.is_empty() {
10471045
cpac_transforms::unpreprocess(&data_to_unpreprocess, &[])
10481046
} else {
1049-
let (ids, metas, _consumed) =
1050-
cpac_dag::deserialize_dag_descriptor(&header.dag_descriptor)?;
1047+
let (ids, metas, _consumed) = cpac_dag::deserialize_dag_descriptor(&header.dag_descriptor)?;
10511048
let registry = cached_transform_registry();
10521049
let dag = TransformDAG::compile_from_ids(registry, &ids)?;
10531050
let meta_chain: Vec<(u8, Vec<u8>)> = ids.into_iter().zip(metas).collect();

crates/cpac-engine/src/parallel.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,11 @@ pub fn compress_parallel(
189189
// limit; truncating the probe is safe because we only need enough
190190
// data to detect the domain and build the field map.
191191
let probe_len = blocks[0].len().min(cpac_msn::MAX_DOMAIN_EXTRACT_SIZE);
192-
if let Ok(probe_result) =
193-
cpac_msn::extract(&blocks[0][..probe_len], probe_filename, config.msn_confidence)
194-
{
192+
if let Ok(probe_result) = cpac_msn::extract(
193+
&blocks[0][..probe_len],
194+
probe_filename,
195+
config.msn_confidence,
196+
) {
195197
cpac_trace!(
196198
"[TRACE] parallel MSN probe: applied={} domain={:?} conf={:.3} fields={}",
197199
probe_result.applied,
@@ -216,8 +218,7 @@ pub fn compress_parallel(
216218
// transform selection (logged for now; future phases use for projection).
217219
let typed_cols = probe_result.typed_columns();
218220
if !typed_cols.is_empty() {
219-
let analysis =
220-
cpac_cas::analyze_columns(&typed_cols.int_columns);
221+
let analysis = cpac_cas::analyze_columns(&typed_cols.int_columns);
221222
cpac_trace!(
222223
"[TRACE] Phase 6: CAS bridge → {} int cols, {} constraints, benefit={:.3}",
223224
typed_cols.int_columns.len(),
@@ -230,11 +231,7 @@ pub fn compress_parallel(
230231
);
231232
for (col_name, constraints) in &analysis.constraints {
232233
for c in constraints {
233-
cpac_trace!(
234-
"[TRACE] Phase 6: CAS col '{}': {:?}",
235-
col_name,
236-
c
237-
);
234+
cpac_trace!("[TRACE] Phase 6: CAS col '{}': {:?}", col_name, c);
238235
}
239236
}
240237
// Also analyze string columns for enumeration/length constraints
@@ -275,10 +272,7 @@ pub fn compress_parallel(
275272
&& config.dictionary.is_none()
276273
{
277274
let sample_count = block_count.min(DICT_TRAIN_MAX_BLOCKS);
278-
let samples: Vec<Vec<u8>> = blocks[..sample_count]
279-
.iter()
280-
.map(|b| b.to_vec())
281-
.collect();
275+
let samples: Vec<Vec<u8>> = blocks[..sample_count].iter().map(|b| b.to_vec()).collect();
282276
match cpac_dict::CpacDictionary::train(&samples, DICT_MAX_SIZE) {
283277
Ok(dict) => {
284278
cpac_trace!(

crates/cpac-engine/tests/phase1_bwt_parallel.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ fn roundtrip_block_size_text_with_smart_transforms() {
1414
let sentence = b"The quick brown fox jumps over the lazy dog. ";
1515
// 17 MB — the approximate per-block size the parallel path would create
1616
let block_size = 17 * 1024 * 1024;
17-
let data: Vec<u8> = sentence
18-
.iter()
19-
.copied()
20-
.cycle()
21-
.take(block_size)
22-
.collect();
17+
let data: Vec<u8> = sentence.iter().copied().cycle().take(block_size).collect();
2318

2419
let config = CompressConfig {
2520
backend: Some(Backend::Zstd),
@@ -57,12 +52,7 @@ fn roundtrip_block_size_json_with_smart_transforms() {
5752
let record = br#"{"name": "Alice", "age": 30, "city": "New York", "active": true}
5853
"#;
5954
let block_size = 17 * 1024 * 1024;
60-
let data: Vec<u8> = record
61-
.iter()
62-
.copied()
63-
.cycle()
64-
.take(block_size)
65-
.collect();
55+
let data: Vec<u8> = record.iter().copied().cycle().take(block_size).collect();
6656

6757
let config = CompressConfig {
6858
backend: Some(Backend::Zstd),

crates/cpac-msn/src/lib.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,13 @@ impl MsnResult {
164164
match value {
165165
serde_json::Value::Array(arr) if !arr.is_empty() => {
166166
// Try as all-integer
167-
let ints: Vec<i64> = arr
168-
.iter()
169-
.filter_map(|v| v.as_i64())
170-
.collect();
167+
let ints: Vec<i64> = arr.iter().filter_map(|v| v.as_i64()).collect();
171168
if ints.len() == arr.len() {
172169
cols.int_columns.push((name.clone(), ints));
173170
continue;
174171
}
175172
// Try as all-float (numbers including decimals)
176-
let floats: Vec<f64> = arr
177-
.iter()
178-
.filter_map(|v| v.as_f64())
179-
.collect();
173+
let floats: Vec<f64> = arr.iter().filter_map(|v| v.as_f64()).collect();
180174
if floats.len() == arr.len() {
181175
cols.float_columns.push((name.clone(), floats));
182176
continue;

crates/cpac-transforms/src/conditioned_bwt.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ impl TransformNode for ConditionedBwtTransform {
103103
if stream.len() >= MIN_STREAM_SIZE && stream.len() <= bwt::BWT_MAX_SIZE {
104104
// Try BWT+MTF+RLE on this stream
105105
if let Ok((bwt_data, original_idx)) = bwt::bwt_encode(stream) {
106-
let mtf_data = mtf::mtf_encode(&bwt_data)
107-
.unwrap_or(bwt_data);
106+
let mtf_data = mtf::mtf_encode(&bwt_data).unwrap_or(bwt_data);
108107
let (rle_data, _) = rle::rle_encode(&mtf_data);
109108

110109
// Only apply if it actually helps
@@ -220,7 +219,9 @@ mod tests {
220219
// Mix of text and structured data
221220
let mut data = Vec::new();
222221
data.extend_from_slice(
223-
b"The quick brown fox jumps over the lazy dog. ".repeat(15).as_slice(),
222+
b"The quick brown fox jumps over the lazy dog. "
223+
.repeat(15)
224+
.as_slice(),
224225
);
225226
// Add some numeric/structural bytes
226227
for i in 0u8..200 {
@@ -229,7 +230,9 @@ mod tests {
229230
data.push(0xFF);
230231
}
231232
data.extend_from_slice(
232-
b"Another repeated text segment for testing. ".repeat(10).as_slice(),
233+
b"Another repeated text segment for testing. "
234+
.repeat(10)
235+
.as_slice(),
233236
);
234237

235238
let ctx = TransformContext {

0 commit comments

Comments
 (0)