#![cfg_attr(coverage_nightly, coverage(off))]
use crate::models::unified_ast::{
ConfidenceLevel, Location, ProofAnnotation, ProofMap, PropertyType, VerificationMethod,
};
use crate::services::symbol_table::SymbolTable;
use parking_lot::RwLock;
use std::future::Future;
use std::path::Path;
use std::pin::Pin;
use std::sync::Arc;
use std::time::{Duration, Instant};
use thiserror::Error;
use tokio::task::JoinSet;
use tracing::{debug, error, info, warn};
#[derive(Debug, Error)]
pub enum ProofCollectionError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Parse error in file {path}: {message}")]
Parse {
path: std::path::PathBuf,
message: String,
},
#[error("Invalid metadata: {0}")]
InvalidMetadata(String),
#[error("Proof source error: {0}")]
ProofSource(String),
}
#[derive(Debug)]
pub struct ProofCollectionResult {
pub annotations: Vec<(Location, ProofAnnotation)>,
pub errors: Vec<ProofCollectionError>,
pub metrics: CollectionMetrics,
}
#[derive(Debug, Default)]
pub struct CollectionMetrics {
pub files_processed: usize,
pub annotations_found: usize,
pub cache_hits: usize,
pub duration_ms: u64,
}
pub trait ProofSource: Send + Sync {
fn collect(
&self,
project_root: &Path,
cache: &Arc<RwLock<ProofCache>>,
symbol_table: &Arc<SymbolTable>,
) -> Pin<
Box<dyn Future<Output = Result<ProofCollectionResult, ProofCollectionError>> + Send + '_>,
>;
fn clone_box(&self) -> Box<dyn ProofSource>;
}
#[derive(Debug, Default)]
pub struct ProofCache {
cache: std::collections::HashMap<String, Vec<ProofAnnotation>>,
file_times: std::collections::HashMap<std::path::PathBuf, std::time::SystemTime>,
}
pub struct ProofAnnotator {
sources: Vec<Box<dyn ProofSource>>,
cache: Arc<RwLock<ProofCache>>,
symbol_table: Arc<SymbolTable>,
}
#[derive(Debug)]
pub struct CacheStats {
pub size: usize,
pub files_tracked: usize,
}
#[derive(Debug, Clone)]
pub struct MockProofSource {
pub name: String,
pub delay_ms: u64,
pub annotation_count: usize,
}
include!("proof_annotator_cache.rs");
include!("proof_annotator_core.rs");
include!("proof_annotator_mock.rs");
include!("proof_annotator_tests.rs");