use crate::op::registry::LoweringRule;
pub fn registered_lowering_rules_section(rules: &[LoweringRule]) -> String {
let mut sorted: Vec<&LoweringRule> = rules.iter().collect();
sorted.sort_by(|a, b| {
(a.backend.as_str(), a.op_name.as_str(), a.id.0.as_str()).cmp(&(
b.backend.as_str(),
b.op_name.as_str(),
b.id.0.as_str(),
))
});
let mut lines: Vec<String> = Vec::new();
lines.push(format!("registered_lowering_rules: count={}", sorted.len()));
for rule in sorted {
lines.push(format!(
"registered_lowering_rule: id={}, op={}, backend={}, evidence={}, obligations={}",
rule.id.0,
rule.op_name,
rule.backend,
rule.required_evidence.len(),
rule.obligations.len(),
));
}
lines.join("\n")
}
pub fn audit_report_with_registry(
plan: &crate::planner::ExecutionPlan,
registry: &crate::op::registry::OperatorRegistry,
) -> String {
let base = crate::verify::audit_report(plan);
let section = registered_lowering_rules_section(registry.lowering_registry().rules());
format!("{base}\n{section}")
}