use std::path::Path;

use crate::inspect::smp::bundle::inspect_smp_file;
use crate::inspect::smp::services::{
    SmpPeriodicCompanyServiceTraceReport, build_periodic_company_service_trace_report,
};
use crate::inspect::smp::world::inspect_save_company_and_chairman_analysis_file;

pub fn inspect_save_periodic_company_service_trace_file(
    path: &Path,
) -> Result<SmpPeriodicCompanyServiceTraceReport, Box<dyn std::error::Error>> {
    let inspection = inspect_smp_file(path)?;
    let analysis = inspect_save_company_and_chairman_analysis_file(path)?;
    let mut trace = build_periodic_company_service_trace_report(&analysis);
    let _ = inspection;
    if trace.region_record_body_present || trace.placed_structure_record_body_present {
        trace.notes.push(
            "The current blockers are no longer collection identity; they are missing higher-layer consumer semantics for the region and infrastructure/placed-structure owner seams.".to_string(),
        );
    }
    Ok(trace)
}
