ryo-executor 0.1.0

[experimental] Mutation execution engine for RYO - parallel execution, conflict detection, workspace management
Documentation
//! ASTRegApply implementation for module mutations
//!
//! Note: AddMod was consolidated into CreateMod.

use ryo_analysis::SymbolKind;
use ryo_mutations::basic::RemoveModMutation;
use ryo_mutations::MutationResult;

use crate::engine::{ASTMutationContext, ASTRegApply, MutationEvent};

impl ASTRegApply for RemoveModMutation {
    fn apply_to_registry(&self, ctx: &mut ASTMutationContext) -> MutationResult {
        // Use the provided SymbolId for O(1) access
        let target_id = self.module_id;

        // Verify the module exists
        if ctx.symbol_registry.kind(target_id) != Some(SymbolKind::Mod) {
            return MutationResult {
                mutation_type: "RemoveMod".to_string(),
                changes: 0,
                description: format!("Symbol {} is not a module", target_id),
            };
        }

        // Get the path before removing
        let path = ctx.symbol_registry.path(target_id).cloned();

        // Remove from registries
        ctx.symbol_registry.remove(target_id);
        ctx.ast_registry.remove(target_id);

        // Emit event
        if let Some(path) = path {
            ctx.emit(MutationEvent::SymbolRemoved { path });
        }

        MutationResult {
            mutation_type: "RemoveMod".to_string(),
            changes: 1,
            description: format!("Removed mod {}", target_id),
        }
    }
}