Skip to content

Commit f902be3

Browse files
mivertowskiclaude
andcommitted
style: run cargo fmt to fix formatting
Apply rustfmt to all files in the workspace. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0573e61 commit f902be3

18 files changed

Lines changed: 448 additions & 306 deletions

File tree

crates/rustkernel-accounting/src/detection.rs

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ impl SuspenseAccountDetection {
8787
indicators: indicators.clone(),
8888
};
8989

90-
if matches!(risk_level, SuspenseRiskLevel::High | SuspenseRiskLevel::Critical) {
90+
if matches!(
91+
risk_level,
92+
SuspenseRiskLevel::High | SuspenseRiskLevel::Critical
93+
) {
9194
high_risk_accounts.push(account_code.clone());
9295
}
9396

@@ -105,10 +108,7 @@ impl SuspenseAccountDetection {
105108
0.0
106109
} else {
107110
(high_risk_accounts.len() as f64 / candidates.len().max(1) as f64 * 50.0
108-
+ candidates
109-
.iter()
110-
.map(|c| c.suspense_score)
111-
.sum::<f64>()
111+
+ candidates.iter().map(|c| c.suspense_score).sum::<f64>()
112112
/ candidates.len().max(1) as f64)
113113
.min(100.0)
114114
};
@@ -127,16 +127,8 @@ impl SuspenseAccountDetection {
127127

128128
for entry in entries {
129129
// Extract debit and credit accounts
130-
let debits: Vec<_> = entry
131-
.lines
132-
.iter()
133-
.filter(|l| l.debit > 0.0)
134-
.collect();
135-
let credits: Vec<_> = entry
136-
.lines
137-
.iter()
138-
.filter(|l| l.credit > 0.0)
139-
.collect();
130+
let debits: Vec<_> = entry.lines.iter().filter(|l| l.debit > 0.0).collect();
131+
let credits: Vec<_> = entry.lines.iter().filter(|l| l.credit > 0.0).collect();
140132

141133
// Create edges between debit and credit accounts
142134
for debit_line in &debits {
@@ -217,10 +209,7 @@ impl SuspenseAccountDetection {
217209
}
218210

219211
/// Calculate suspense score from indicators.
220-
fn calculate_suspense_score(
221-
indicators: &[SuspenseIndicator],
222-
metrics: &AccountMetrics,
223-
) -> f64 {
212+
fn calculate_suspense_score(indicators: &[SuspenseIndicator], metrics: &AccountMetrics) -> f64 {
224213
let mut score = 0.0;
225214

226215
for indicator in indicators {
@@ -403,10 +392,8 @@ impl GaapViolationDetection {
403392
})
404393
.count();
405394

406-
let compliance_score = (100.0
407-
- (violations.len() as f64 * 2.0)
408-
- (major_violations as f64 * 10.0))
409-
.max(0.0);
395+
let compliance_score =
396+
(100.0 - (violations.len() as f64 * 2.0) - (major_violations as f64 * 10.0)).max(0.0);
410397

411398
GaapViolationResult {
412399
violations,
@@ -445,8 +432,9 @@ impl GaapViolationDetection {
445432
credit.account_code, debit.account_code
446433
),
447434
severity: GaapViolationSeverity::Major,
448-
remediation: "Route through retained earnings or appropriate capital account"
449-
.to_string(),
435+
remediation:
436+
"Route through retained earnings or appropriate capital account"
437+
.to_string(),
450438
});
451439
}
452440
}
@@ -499,12 +487,17 @@ impl GaapViolationDetection {
499487
}
500488

501489
/// Check for suspense account misuse.
502-
fn check_suspense_misuse(entry: &JournalEntry, config: &GaapDetectionConfig) -> Option<GaapViolation> {
490+
fn check_suspense_misuse(
491+
entry: &JournalEntry,
492+
config: &GaapDetectionConfig,
493+
) -> Option<GaapViolation> {
503494
let suspense_keywords = ["suspense", "clearing", "holding", "temporary"];
504495

505496
for line in &entry.lines {
506497
let account_lower = line.account_code.to_lowercase();
507-
let is_suspense = suspense_keywords.iter().any(|kw| account_lower.contains(kw));
498+
let is_suspense = suspense_keywords
499+
.iter()
500+
.any(|kw| account_lower.contains(kw));
508501

509502
if is_suspense {
510503
let amount = line.debit.max(line.credit);
@@ -520,8 +513,9 @@ impl GaapViolationDetection {
520513
amount, line.account_code
521514
),
522515
severity: GaapViolationSeverity::Minor,
523-
remediation: "Clear suspense account to proper account within reporting period"
524-
.to_string(),
516+
remediation:
517+
"Clear suspense account to proper account within reporting period"
518+
.to_string(),
525519
});
526520
}
527521
}
@@ -590,8 +584,9 @@ impl GaapViolationDetection {
590584
from, to
591585
),
592586
severity: GaapViolationSeverity::Critical,
593-
remediation: "Review entries for potential revenue inflation or wash transactions"
594-
.to_string(),
587+
remediation:
588+
"Review entries for potential revenue inflation or wash transactions"
589+
.to_string(),
595590
});
596591
}
597592

@@ -722,8 +717,7 @@ impl AccountGraph {
722717

723718
// Calculate average holding period
724719
if metrics.first_activity > 0 && metrics.last_activity > metrics.first_activity {
725-
let days =
726-
(metrics.last_activity - metrics.first_activity) as f64 / 86400.0;
720+
let days = (metrics.last_activity - metrics.first_activity) as f64 / 86400.0;
727721
metrics.avg_holding_days = days / metrics.transaction_count.max(1) as f64;
728722
}
729723

@@ -839,7 +833,11 @@ mod tests {
839833
assert!(suspense_candidate.is_some());
840834

841835
let candidate = suspense_candidate.unwrap();
842-
assert!(candidate.indicators.contains(&SuspenseIndicator::SuspenseNaming));
836+
assert!(
837+
candidate
838+
.indicators
839+
.contains(&SuspenseIndicator::SuspenseNaming)
840+
);
843841
}
844842

845843
#[test]
@@ -855,7 +853,12 @@ mod tests {
855853

856854
#[test]
857855
fn test_gaap_direct_revenue_expense() {
858-
let entries = vec![create_test_entry(1, "SALARIES_EXPENSE", "SALES_REVENUE", 10000.0)];
856+
let entries = vec![create_test_entry(
857+
1,
858+
"SALARIES_EXPENSE",
859+
"SALES_REVENUE",
860+
10000.0,
861+
)];
859862

860863
let mut account_types = HashMap::new();
861864
account_types.insert("SALES_REVENUE".to_string(), AccountType::Revenue);
@@ -916,7 +919,12 @@ mod tests {
916919

917920
#[test]
918921
fn test_gaap_improper_asset_expense() {
919-
let entries = vec![create_test_entry(1, "OFFICE_EXPENSE", "EQUIPMENT_ASSET", 15000.0)];
922+
let entries = vec![create_test_entry(
923+
1,
924+
"OFFICE_EXPENSE",
925+
"EQUIPMENT_ASSET",
926+
15000.0,
927+
)];
920928

921929
let mut account_types = HashMap::new();
922930
account_types.insert("EQUIPMENT_ASSET".to_string(), AccountType::Asset);

crates/rustkernel-accounting/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ pub fn register_all(
8484
.metadata()
8585
.clone(),
8686
)?;
87-
registry.register_metadata(
88-
detection::GaapViolationDetection::new()
89-
.metadata()
90-
.clone(),
91-
)?;
87+
registry.register_metadata(detection::GaapViolationDetection::new().metadata().clone())?;
9288

9389
tracing::info!("Registered 9 accounting kernels");
9490
Ok(())

crates/rustkernel-compliance/src/aml.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,10 +1244,10 @@ pub struct FlowReversalConfig {
12441244
impl Default for FlowReversalConfig {
12451245
fn default() -> Self {
12461246
Self {
1247-
max_window_seconds: 86400, // 24 hours
1247+
max_window_seconds: 86400, // 24 hours
12481248
suspicious_window_seconds: 3600, // 1 hour
1249-
critical_window_seconds: 300, // 5 minutes
1250-
min_amount_match_ratio: 0.9, // 90% match
1249+
critical_window_seconds: 300, // 5 minutes
1250+
min_amount_match_ratio: 0.9, // 90% match
12511251
}
12521252
}
12531253
}
@@ -1404,10 +1404,7 @@ impl FlowSplitRatio {
14041404
risk_level,
14051405
});
14061406

1407-
if matches!(
1408-
risk_level,
1409-
SplitRiskLevel::High | SplitRiskLevel::Critical
1410-
) {
1407+
if matches!(risk_level, SplitRiskLevel::High | SplitRiskLevel::Critical) {
14111408
structuring_entities.insert(source_id);
14121409
}
14131410
}
@@ -1481,7 +1478,8 @@ impl FlowSplitRatio {
14811478
) -> Vec<crate::types::FlowSplitPattern> {
14821479
// Sort by risk level (highest first), then by total amount
14831480
splits.sort_by(|a, b| {
1484-
let risk_ord = Self::risk_level_ord(&b.risk_level).cmp(&Self::risk_level_ord(&a.risk_level));
1481+
let risk_ord =
1482+
Self::risk_level_ord(&b.risk_level).cmp(&Self::risk_level_ord(&a.risk_level));
14851483
if risk_ord == std::cmp::Ordering::Equal {
14861484
b.total_amount
14871485
.partial_cmp(&a.total_amount)

crates/rustkernel-graph/src/cycles.rs

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,12 @@ impl ShortCycleParticipation {
268268
pub fn find_high_risk_nodes(graph: &CsrGraph) -> Vec<CycleParticipationResult> {
269269
Self::compute_all(graph)
270270
.into_iter()
271-
.filter(|r| matches!(r.risk_level, CycleRiskLevel::High | CycleRiskLevel::Critical))
271+
.filter(|r| {
272+
matches!(
273+
r.risk_level,
274+
CycleRiskLevel::High | CycleRiskLevel::Critical
275+
)
276+
})
272277
.collect()
273278
}
274279

@@ -300,26 +305,17 @@ mod tests {
300305

301306
fn create_triangle_graph() -> CsrGraph {
302307
// Undirected triangle: 0 - 1 - 2 - 0 (bidirectional edges)
303-
CsrGraph::from_edges(
304-
3,
305-
&[(0, 1), (1, 0), (0, 2), (2, 0), (1, 2), (2, 1)],
306-
)
308+
CsrGraph::from_edges(3, &[(0, 1), (1, 0), (0, 2), (2, 0), (1, 2), (2, 1)])
307309
}
308310

309311
fn create_square_graph() -> CsrGraph {
310312
// Square: 0 -> 1 -> 2 -> 3 -> 0
311-
CsrGraph::from_edges(
312-
4,
313-
&[(0, 1), (1, 2), (2, 3), (3, 0)],
314-
)
313+
CsrGraph::from_edges(4, &[(0, 1), (1, 2), (2, 3), (3, 0)])
315314
}
316315

317316
fn create_reciprocal_graph() -> CsrGraph {
318317
// Bidirectional edges: 0 <-> 1, 1 <-> 2
319-
CsrGraph::from_edges(
320-
3,
321-
&[(0, 1), (1, 0), (1, 2), (2, 1)],
322-
)
318+
CsrGraph::from_edges(3, &[(0, 1), (1, 0), (1, 2), (2, 1)])
323319
}
324320

325321
fn create_complex_graph() -> CsrGraph {
@@ -328,9 +324,19 @@ mod tests {
328324
5,
329325
&[
330326
// Triangle 0-1-2
331-
(0, 1), (1, 0), (1, 2), (2, 1), (0, 2), (2, 0),
327+
(0, 1),
328+
(1, 0),
329+
(1, 2),
330+
(2, 1),
331+
(0, 2),
332+
(2, 0),
332333
// Triangle 2-3-4
333-
(2, 3), (3, 2), (3, 4), (4, 3), (2, 4), (4, 2),
334+
(2, 3),
335+
(3, 2),
336+
(3, 4),
337+
(4, 3),
338+
(2, 4),
339+
(4, 2),
334340
],
335341
)
336342
}
@@ -357,17 +363,32 @@ mod tests {
357363
let counts = ShortCycleParticipation::detect_3_cycles(&graph);
358364

359365
// All three nodes participate in one triangle
360-
assert!(counts[0] >= 1, "Node 0 should participate in triangle: got {}", counts[0]);
361-
assert!(counts[1] >= 1, "Node 1 should participate in triangle: got {}", counts[1]);
362-
assert!(counts[2] >= 1, "Node 2 should participate in triangle: got {}", counts[2]);
366+
assert!(
367+
counts[0] >= 1,
368+
"Node 0 should participate in triangle: got {}",
369+
counts[0]
370+
);
371+
assert!(
372+
counts[1] >= 1,
373+
"Node 1 should participate in triangle: got {}",
374+
counts[1]
375+
);
376+
assert!(
377+
counts[2] >= 1,
378+
"Node 2 should participate in triangle: got {}",
379+
counts[2]
380+
);
363381
}
364382

365383
#[test]
366384
fn test_count_triangles() {
367385
let graph = create_triangle_graph();
368386
let count = ShortCycleParticipation::count_triangles(&graph);
369387

370-
assert_eq!(count, 1, "Should find 1 triangle in undirected triangle graph");
388+
assert_eq!(
389+
count, 1,
390+
"Should find 1 triangle in undirected triangle graph"
391+
);
371392
}
372393

373394
#[test]
@@ -424,7 +445,10 @@ mod tests {
424445

425446
assert_eq!(results.len(), 3);
426447
for result in &results {
427-
assert!(result.cycle_count_3hop >= 1, "Each node should have at least 1 triangle participation");
448+
assert!(
449+
result.cycle_count_3hop >= 1,
450+
"Each node should have at least 1 triangle participation"
451+
);
428452
assert_eq!(result.cycle_count_4hop, 0);
429453
}
430454
}

0 commit comments

Comments
 (0)