Skip to content

Commit 57c900f

Browse files
Your Nameclaude
andcommitted
style: rustfmt this session's T1-T4a files
Line-length/wrapping-only reflow from cargo fmt -- no behavior change, full test suite already re-verified green (calm-core 1050/1050, calm-server 364/364, calm-cli, clippy clean in both default and --features index-bundles) after applying it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent e4f9884 commit 57c900f

7 files changed

Lines changed: 296 additions & 133 deletions

File tree

crates/calm-cli/src/main.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,10 @@ async fn main() -> Result<()> {
11501150
}
11511151
#[cfg(feature = "index-bundles")]
11521152
Commands::Bundle { action } => match action {
1153-
BundleAction::Export { project_root, output } => {
1153+
BundleAction::Export {
1154+
project_root,
1155+
output,
1156+
} => {
11541157
let root = std::fs::canonicalize(&project_root)?;
11551158
let db_path = calm_server::default_db_path(&root);
11561159
let config = calm_core::config::load_config_or_warn(&root);
@@ -1168,7 +1171,10 @@ async fn main() -> Result<()> {
11681171
let manifest = calm_core::bundle::inspect_bundle(&archive)?;
11691172
println!("{}", serde_json::to_string_pretty(&manifest)?);
11701173
}
1171-
BundleAction::Import { archive, project_root } => {
1174+
BundleAction::Import {
1175+
archive,
1176+
project_root,
1177+
} => {
11721178
let root = std::fs::canonicalize(&project_root)?;
11731179
let db_path = calm_server::default_db_path(&root);
11741180
let config = calm_core::config::load_config_or_warn(&root);
@@ -1187,7 +1193,9 @@ async fn main() -> Result<()> {
11871193
);
11881194
}
11891195
if !report.commit_matches {
1190-
println!(" (imported as a seed, not an exact match for this repo's current HEAD)");
1196+
println!(
1197+
" (imported as a seed, not an exact match for this repo's current HEAD)"
1198+
);
11911199
}
11921200
}
11931201
},

crates/calm-core/src/bundle.rs

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,7 @@ pub fn export_bundle(
173173

174174
{
175175
let src = Connection::open_with_flags(db_path, OpenFlags::SQLITE_OPEN_READ_ONLY)?;
176-
src.execute(
177-
"VACUUM INTO ?1",
178-
[snapshot_path.to_string_lossy().as_ref()],
179-
)?;
176+
src.execute("VACUUM INTO ?1", [snapshot_path.to_string_lossy().as_ref()])?;
180177
}
181178

182179
// Re-open the FRESH snapshot for integrity_check and stats -- verifies
@@ -236,10 +233,7 @@ pub fn export_bundle(
236233
MANIFEST_FILE_NAME,
237234
manifest_json.as_slice(),
238235
)?;
239-
tar_builder
240-
.into_inner()?
241-
.finish()?
242-
.flush()?;
236+
tar_builder.into_inner()?.finish()?.flush()?;
243237

244238
Ok(manifest)
245239
}
@@ -304,7 +298,8 @@ pub fn import_bundle(
304298
}
305299

306300
{
307-
let snap = Connection::open_with_flags(&extracted_db_path, OpenFlags::SQLITE_OPEN_READ_ONLY)?;
301+
let snap =
302+
Connection::open_with_flags(&extracted_db_path, OpenFlags::SQLITE_OPEN_READ_ONLY)?;
308303
check_integrity(&snap)?;
309304
}
310305

@@ -437,21 +432,19 @@ mod tests {
437432

438433
let config = Config::default();
439434
let archive_path = src_dir.path().join("bundle.tar.gz");
440-
let manifest =
441-
export_bundle(&db_path, src_dir.path(), &config, &archive_path).unwrap();
435+
let manifest = export_bundle(&db_path, src_dir.path(), &config, &archive_path).unwrap();
442436
assert_eq!(manifest.symbol_count, 1);
443437
assert_eq!(manifest.file_count, 1);
444438
assert!(archive_path.exists());
445439

446440
let dest_dir = tempfile::tempdir().unwrap();
447441
let dest_db_path = dest_dir.path().join("index.db");
448-
let report =
449-
import_bundle(&archive_path, dest_dir.path(), &dest_db_path, &config).unwrap();
442+
let report = import_bundle(&archive_path, dest_dir.path(), &dest_db_path, &config).unwrap();
450443
assert_eq!(report.manifest.symbol_count, 1);
451444
assert!(dest_db_path.exists());
452445

453-
let conn = Connection::open_with_flags(&dest_db_path, OpenFlags::SQLITE_OPEN_READ_ONLY)
454-
.unwrap();
446+
let conn =
447+
Connection::open_with_flags(&dest_db_path, OpenFlags::SQLITE_OPEN_READ_ONLY).unwrap();
455448
let count: i64 = conn
456449
.query_row("SELECT COUNT(*) FROM symbols", [], |r| r.get(0))
457450
.unwrap();
@@ -501,17 +494,33 @@ mod tests {
501494
manifest_header.set_mode(0o644);
502495
manifest_header.set_cksum();
503496
builder
504-
.append_data(&mut manifest_header, MANIFEST_FILE_NAME, manifest_json.as_slice())
497+
.append_data(
498+
&mut manifest_header,
499+
MANIFEST_FILE_NAME,
500+
manifest_json.as_slice(),
501+
)
502+
.unwrap();
503+
builder
504+
.into_inner()
505+
.unwrap()
506+
.finish()
507+
.unwrap()
508+
.flush()
505509
.unwrap();
506-
builder.into_inner().unwrap().finish().unwrap().flush().unwrap();
507510
}
508511

509512
let dest_dir = tempfile::tempdir().unwrap();
510513
let dest_db_path = dest_dir.path().join("index.db");
511-
let err = import_bundle(&tampered_path, dest_dir.path(), &dest_db_path, &config)
512-
.unwrap_err();
513-
assert!(matches!(err, BundleError::ChecksumMismatch { .. }), "{err:?}");
514-
assert!(!dest_db_path.exists(), "a failed import must not touch the destination at all");
514+
let err =
515+
import_bundle(&tampered_path, dest_dir.path(), &dest_db_path, &config).unwrap_err();
516+
assert!(
517+
matches!(err, BundleError::ChecksumMismatch { .. }),
518+
"{err:?}"
519+
);
520+
assert!(
521+
!dest_db_path.exists(),
522+
"a failed import must not touch the destination at all"
523+
);
515524
}
516525

517526
#[test]
@@ -546,15 +555,24 @@ mod tests {
546555
manifest_header.set_mode(0o644);
547556
manifest_header.set_cksum();
548557
builder
549-
.append_data(&mut manifest_header, MANIFEST_FILE_NAME, manifest_json.as_slice())
558+
.append_data(
559+
&mut manifest_header,
560+
MANIFEST_FILE_NAME,
561+
manifest_json.as_slice(),
562+
)
563+
.unwrap();
564+
builder
565+
.into_inner()
566+
.unwrap()
567+
.finish()
568+
.unwrap()
569+
.flush()
550570
.unwrap();
551-
builder.into_inner().unwrap().finish().unwrap().flush().unwrap();
552571
}
553572

554573
let dest_dir = tempfile::tempdir().unwrap();
555574
let dest_db_path = dest_dir.path().join("index.db");
556-
let err = import_bundle(&bumped_path, dest_dir.path(), &dest_db_path, &config)
557-
.unwrap_err();
575+
let err = import_bundle(&bumped_path, dest_dir.path(), &dest_db_path, &config).unwrap_err();
558576
assert!(matches!(err, BundleError::SchemaTooNew { .. }), "{err:?}");
559577
}
560578

@@ -618,16 +636,29 @@ mod tests {
618636
manifest_header.set_mode(0o644);
619637
manifest_header.set_cksum();
620638
builder
621-
.append_data(&mut manifest_header, MANIFEST_FILE_NAME, manifest_json.as_slice())
639+
.append_data(
640+
&mut manifest_header,
641+
MANIFEST_FILE_NAME,
642+
manifest_json.as_slice(),
643+
)
644+
.unwrap();
645+
builder
646+
.into_inner()
647+
.unwrap()
648+
.finish()
649+
.unwrap()
650+
.flush()
622651
.unwrap();
623-
builder.into_inner().unwrap().finish().unwrap().flush().unwrap();
624652
}
625653

626654
let dest_dir = tempfile::tempdir().unwrap();
627655
let dest_db_path = dest_dir.path().join("index.db");
628-
let err = import_bundle(&archive_path, dest_dir.path(), &dest_db_path, &config)
629-
.unwrap_err();
630-
assert!(matches!(err, BundleError::IntegrityCheckFailed(_)), "{err:?}");
656+
let err =
657+
import_bundle(&archive_path, dest_dir.path(), &dest_db_path, &config).unwrap_err();
658+
assert!(
659+
matches!(err, BundleError::IntegrityCheckFailed(_)),
660+
"{err:?}"
661+
);
631662
assert!(!dest_db_path.exists());
632663
}
633664

@@ -643,8 +674,7 @@ mod tests {
643674

644675
let dest_dir = tempfile::tempdir().unwrap();
645676
let dest_db_path = dest_dir.path().join("index.db");
646-
let report =
647-
import_bundle(&archive_path, dest_dir.path(), &dest_db_path, &config).unwrap();
677+
let report = import_bundle(&archive_path, dest_dir.path(), &dest_db_path, &config).unwrap();
648678
// Both sides have no git commit -> commit_matches is conservatively
649679
// false (never assume equality from two absences), which forces a
650680
// full reindex recommendation.

crates/calm-core/src/graph/digest.rs

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,10 @@ pub fn compute_digests(conn: &Connection) -> rusqlite::Result<()> {
344344
{
345345
let mut stmt = conn.prepare("SELECT qualified_name, name_tokens FROM symbols")?;
346346
let iter = stmt.query_map([], |r| {
347-
Ok((r.get::<_, String>(0)?, r.get::<_, Option<String>>(1)?.unwrap_or_default()))
347+
Ok((
348+
r.get::<_, String>(0)?,
349+
r.get::<_, Option<String>>(1)?.unwrap_or_default(),
350+
))
348351
})?;
349352
for row in iter {
350353
let (qn, tokens) = row?;
@@ -406,8 +409,9 @@ pub fn compute_digests(conn: &Connection) -> rusqlite::Result<()> {
406409

407410
let mut effects_by_symbol: HashMap<String, Vec<EffectFact>> = HashMap::new();
408411
{
409-
let mut stmt =
410-
conn.prepare("SELECT symbol_qn, effect_kind, target_text FROM symbol_effects ORDER BY line")?;
412+
let mut stmt = conn.prepare(
413+
"SELECT symbol_qn, effect_kind, target_text FROM symbol_effects ORDER BY line",
414+
)?;
411415
let iter = stmt.query_map([], |r| {
412416
Ok((
413417
r.get::<_, String>(0)?,
@@ -417,13 +421,10 @@ pub fn compute_digests(conn: &Connection) -> rusqlite::Result<()> {
417421
})?;
418422
for row in iter {
419423
let (qn, kind, target) = row?;
420-
effects_by_symbol
421-
.entry(qn)
422-
.or_default()
423-
.push(EffectFact {
424-
effect_kind: kind,
425-
target_text: target,
426-
});
424+
effects_by_symbol.entry(qn).or_default().push(EffectFact {
425+
effect_kind: kind,
426+
target_text: target,
427+
});
427428
}
428429
}
429430

@@ -461,7 +462,10 @@ pub fn compute_digests(conn: &Connection) -> rusqlite::Result<()> {
461462
let possible_truncated = possible.len() > MAX_POSSIBLE_CALLEES_SHOWN;
462463
possible.truncate(MAX_POSSIBLE_CALLEES_SHOWN);
463464

464-
let type_relations = type_relations_by_from.get(&row.qn).cloned().unwrap_or_default();
465+
let type_relations = type_relations_by_from
466+
.get(&row.qn)
467+
.cloned()
468+
.unwrap_or_default();
465469

466470
let mut effects = effects_by_symbol.get(&row.qn).cloned().unwrap_or_default();
467471
let effects_truncated = effects.len() > MAX_EFFECTS_SHOWN;
@@ -669,14 +673,32 @@ mod tests {
669673
signature: "fn refresh_session(token, store) -> User".to_string(),
670674
complexity: 7,
671675
confirmed_callees: vec![
672-
CalleeFact { name: "verify_token".to_string(), role_tags: vec!["verify".to_string(), "token".to_string()] },
673-
CalleeFact { name: "load_session".to_string(), role_tags: vec![] },
676+
CalleeFact {
677+
name: "verify_token".to_string(),
678+
role_tags: vec!["verify".to_string(), "token".to_string()],
679+
},
680+
CalleeFact {
681+
name: "load_session".to_string(),
682+
role_tags: vec![],
683+
},
674684
],
675-
possible_callees: vec![CalleeFact { name: "emit_event".to_string(), role_tags: vec!["emit".to_string()] }],
676-
type_relations: vec![TypeRelationFact { relation_kind: "implements".to_string(), target_text: "SessionRefresher".to_string() }],
685+
possible_callees: vec![CalleeFact {
686+
name: "emit_event".to_string(),
687+
role_tags: vec!["emit".to_string()],
688+
}],
689+
type_relations: vec![TypeRelationFact {
690+
relation_kind: "implements".to_string(),
691+
target_text: "SessionRefresher".to_string(),
692+
}],
677693
effects: vec![
678-
EffectFact { effect_kind: "write_field".to_string(), target_text: "last_refresh".to_string() },
679-
EffectFact { effect_kind: "explicit_throw".to_string(), target_text: "ExpiredToken".to_string() },
694+
EffectFact {
695+
effect_kind: "write_field".to_string(),
696+
target_text: "last_refresh".to_string(),
697+
},
698+
EffectFact {
699+
effect_kind: "explicit_throw".to_string(),
700+
target_text: "ExpiredToken".to_string(),
701+
},
680702
],
681703
recursive_component: false,
682704
truncated: false,
@@ -748,7 +770,8 @@ mod tests {
748770
"INSERT INTO symbol_effects (symbol_qn, effect_kind, target_text, source_path, line) \
749771
VALUES ('a.py::Foo::m', 'write_field', 'x', 'a.py', 1)",
750772
[],
751-
).unwrap();
773+
)
774+
.unwrap();
752775

753776
compute_digests(&conn).unwrap();
754777

0 commit comments

Comments
 (0)