use chrono::Utc;
use cortex_store::repo::{AuditEntry, AuditRepo};
use cortex_store::{Pool, StoreResult};
use serde_json::json;
pub const REFLECTION_QUARANTINE_OPERATION: &str = "reflection_quarantine";
pub fn quarantine_record(raw_output: &str, reason: &str, pool: &Pool) -> StoreResult<AuditEntry> {
let output_hash = blake3::hash(raw_output.as_bytes()).to_hex().to_string();
let entry = AuditEntry {
id: cortex_core::AuditRecordId::new(),
operation: REFLECTION_QUARANTINE_OPERATION.to_string(),
target_ref: format!("reflection_output:{output_hash}"),
before_hash: None,
after_hash: output_hash.clone(),
reason: reason.to_string(),
actor_json: json!({
"kind": "cortex_reflect",
"component": "parser"
}),
source_refs_json: json!({
"output_hash": output_hash,
"reason": reason
}),
created_at: Utc::now(),
};
AuditRepo::new(pool).append(&entry)?;
Ok(entry)
}