Skip to main content

create_fact

Function create_fact 

Source
pub fn create_fact(
    mana_dir: &Path,
    params: FactParams,
) -> Result<FactResult, Error>
Expand description

Create a verified fact — a unit that encodes checked project knowledge.

Facts differ from regular units in that they:

  • Have unit_type = "fact" and the "fact" label
  • Require a verify command (the verification is the point)
  • Have a TTL (default 30 days) after which they are considered stale
  • Can reference source file paths for relevance scoring

§Errors

  • anyhow::Error — empty verify command, validation failure, or I/O error

§Example

use mana_core::api::create_fact;
use mana_core::ops::fact::FactParams;
use std::path::Path;

let r = create_fact(Path::new("/project/.mana"), FactParams {
    title: "Auth uses RS256 JWT signing".to_string(),
    verify: "grep -q 'RS256' src/auth.rs".to_string(),
    description: Some("JWT tokens are signed with RS256 (not HS256)".to_string()),
    paths: Some("src/auth.rs".to_string()),
    ttl_days: Some(90),
    pass_ok: true,
}).unwrap();
println!("Created fact {} (stale after {:?})", r.unit_id, r.unit.stale_after);