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

Function doctor_materialize_crdt

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

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

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

Source from the content-addressed store, hash-verified

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

Callers 1

runMethod · 0.85

Calls 8

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

Tested by

no test coverage detected