MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / doctor_materialize_crdt

Function doctor_materialize_crdt

atomic-cli/src/commands/rpc.rs:3314–3377  ·  view source on GitHub ↗

`atomic doctor materialize-crdt` over MaintenanceService.Repair.

(args: &super::doctor::MaterializeCrdt)

Source from the content-addressed store, hash-verified

3312
3313/// `atomic doctor materialize-crdt` over MaintenanceService.Repair.
3314pub fn doctor_materialize_crdt(args: &super::doctor::MaterializeCrdt) -> CliResult<bool> {
3315 let Some(session) = Service::open()? else {
3316 return Ok(false);
3317 };
3318 // The current view is resolved client-side (same default the
3319 // in-process path uses); the daemon materializes it server-side.
3320 let view = match &args.view {
3321 Some(view) => view.clone(),
3322 None => {
3323 let marker = crate::commands::find_repository_root()?
3324 .join(".atomic")
3325 .join("current_view");
3326 std::fs::read_to_string(&marker)
3327 .map(|content| content.trim().to_string())
3328 .unwrap_or_else(|_| "dev".to_string())
3329 }
3330 };
3331 let request = pb::RepairRequest {
3332 repository: Some(session.reference.clone()),
3333 meta: None,
3334 action: pb::RepairAction::MaterializeCrdt as i32,
3335 force: args.force,
3336 view,
3337 };
3338 let response = session.repair(request.clone())?;
3339 println!("Materializing CRDT tables for view '{}'...", request.view);
3340 if args.force {
3341 print_warning("--force enabled: existing CRDT trunk rows may be overwritten");
3342 }
3343 print_success(&format!(
3344 "CRDT materialization complete in {:.1}s: {} changes scanned, {} changes applied, {} FileOps applied, {} already materialized, {} skipped",
3345 response.elapsed_ms as f64 / 1000.0,
3346 response.changes_scanned,
3347 response.changes_applied,
3348 response.file_ops_applied,
3349 response.file_ops_already_materialized,
3350 response.file_ops_skipped
3351 ));
3352 print_hint(&format!(
3353 "CRDT rows: trunks +{}, branches +{}, leaves +{}",
3354 response.trunks_created, response.branches_created, response.leaves_created
3355 ));
3356 if response.file_ops_skipped > 0 {
3357 let skip = response.skip_stats;
3358 if let Some(skip) = skip {
3359 print_hint(&format!(
3360 "Skipped FileOps: non_create={}, unresolved_path={}, unresolved_line={}, missing_range={}, non_create_trunk={}, non_create_leaf={}",
3361 skip.non_create_trunk,
3362 skip.unresolved_path,
3363 skip.unresolved_line,
3364 skip.missing_content_range,
3365 skip.non_insert_branch,
3366 skip.non_insert_leaf
3367 ));
3368 }
3369 if !response.skip_samples.is_empty() {
3370 print_hint(&format!(
3371 "Skip samples: {}",

Callers 1

runMethod · 0.85

Calls 8

find_repository_rootFunction · 0.85
print_warningFunction · 0.85
print_successFunction · 0.85
print_hintFunction · 0.85
openFunction · 0.50
cloneMethod · 0.45
repairMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected