Skip to main content

ryo_analysis/cascade/
mod.rs

1//! Cascade engine for propagating mutations through dependent code.
2//!
3//! This module provides a generalized system for tracking mutation impacts
4//! and automatically generating necessary follow-up changes.
5//!
6//! # Overview
7//!
8//! When a mutation is applied (e.g., renaming a symbol, adding a field),
9//! it can have cascading effects throughout the codebase. The cascade engine:
10//!
11//! 1. **Analyzes** the impact of a mutation
12//! 2. **Plans** the necessary cascade changes
13//! 3. **Executes** the changes in the correct order
14//!
15//! # Example
16//!
17//! ```rust,ignore
18//! use ryo_analysis::cascade::{CascadeEngine, CascadeStrategy};
19//!
20//! // Create an engine
21//! let engine = CascadeEngine::new(&graph, &registry)
22//!     .with_strategy(CascadeStrategy::safe());
23//!
24//! // Create a mutation spec
25//! let rename = RenameSpec::new(path, "NewName");
26//!
27//! // Analyze impacts
28//! let analysis = engine.analyze(&rename);
29//! println!("Affected files: {}", analysis.affected_file_count());
30//!
31//! // Generate a plan
32//! let plan = engine.plan(&rename);
33//!
34//! // Dry run first
35//! let dry_result = engine.execute(plan.clone(), true);
36//!
37//! // Then execute for real
38//! let result = engine.execute(plan, false);
39//! ```
40//!
41//! # Impact Levels
42//!
43//! Mutations are classified by their impact level:
44//!
45//! - **Local**: Changes only affect the same file
46//! - **Reference**: Changes affect references from other files
47//! - **Structural**: Changes affect type structure (fields, variants)
48//! - **Semantic**: Changes affect type behavior (derives, visibility)
49//!
50//! # Strategies
51//!
52//! The cascade engine supports different strategies for handling various situations:
53//!
54//! - `CascadeStrategy::default()` - Balanced approach
55//! - `CascadeStrategy::safe()` - Prioritize data protection
56//! - `CascadeStrategy::aggressive()` - Prioritize automation
57//! - `CascadeStrategy::interactive()` - Prompt for decisions
58
59mod analyzer;
60mod impact;
61mod spec;
62mod strategy;
63
64// === Analyzer ===
65pub use analyzer::CascadeAnalyzer;
66
67// === Spec ===
68pub use spec::{CascadeSpec, Visibility};
69
70// === Impact ===
71pub use impact::{ImpactLevel, ImpactSet};
72
73// === Strategy ===
74pub use strategy::CascadeStrategy;