Skip to main content

logicpearl_render/
lib.rs

1use logicpearl_core::{ArtifactRenderer, Result};
2use logicpearl_ir::{LogicPearlGateIr, RuleVerificationStatus};
3
4pub struct TextInspector;
5
6impl ArtifactRenderer<LogicPearlGateIr> for TextInspector {
7    fn render(&self, gate: &LogicPearlGateIr) -> Result<String> {
8        let mut lines = vec![
9            format!("Gate ID: {}", gate.gate_id),
10            format!("IR version: {}", gate.ir_version),
11            format!("Features: {}", gate.input_schema.features.len()),
12            format!("Rules: {}", gate.rules.len()),
13        ];
14        if let Some(verification) = &gate.verification {
15            if let Some(scope) = &verification.correctness_scope {
16                lines.push(format!("Correctness scope: {scope}"));
17            }
18        }
19        lines.push("Rule details:".to_string());
20        for rule in &gate.rules {
21            let status = match &rule.verification_status {
22                Some(RuleVerificationStatus::Z3Verified) => "z3_verified",
23                Some(RuleVerificationStatus::PipelineUnverified) => "pipeline_unverified",
24                Some(RuleVerificationStatus::HeuristicUnverified) => "heuristic_unverified",
25                Some(RuleVerificationStatus::RefinedUnverified) => "refined_unverified",
26                None => "unknown",
27            };
28            lines.push(format!("  bit {}: {} [{}]", rule.bit, rule.id, status));
29        }
30        Ok(lines.join("\n"))
31    }
32}