aaai_core/lib.rs
1//! # aaai-core
2//!
3//! Core engine for **aaai** (audit for asset integrity).
4//!
5//! This crate provides all domain logic: folder diffing, audit evaluation,
6//! report generation, secret masking, audit history, profiles, and project config.
7//! It is consumed by [`aaai-cli`] (the CLI binary) and [`aaai-gui`] (the desktop GUI).
8//!
9//! ## Module map
10//!
11//! ```text
12//! aaai-core
13//! ├── config — AuditDefinition YAML, entry fields, lockfile, I/O
14//! ├── diff — parallel folder diff (rayon), DiffEntry, IgnoreRules (.aaaiignore)
15//! ├── audit — AuditEngine, AuditResult, AuditStatus, AuditWarning
16//! ├── report — Markdown / JSON / HTML / SARIF v2.1.0 output
17//! ├── masking — regex-based secret redaction (9 built-in patterns)
18//! ├── history — append-only audit run log (~/.aaai/history.jsonl)
19//! ├── profile — named before/after/definition combos + user prefs (theme)
20//! ├── project — .aaai.yaml auto-discovery and project-level defaults
21//! └── templates — 8 built-in rule templates (version_bump, port_change, …)
22//! ```
23//!
24//! ## Quick start
25//!
26//! ```rust,no_run
27//! use aaai_core::{DiffEngine, AuditEngine, AuditDefinition};
28//! use std::path::Path;
29//!
30//! let diffs = DiffEngine::compare(Path::new("./before"), Path::new("./after")).unwrap();
31//! let definition = AuditDefinition::new_empty();
32//! let result = AuditEngine::evaluate(&diffs, &definition);
33//! println!("PASSED: {}", result.summary.is_passing());
34//! ```
35//!
36//! ## Exit code contract (used by aaai-cli)
37//!
38//! | Code | Meaning |
39//! |---|---|
40//! | 0 | PASSED — all entries OK or Ignored |
41//! | 1 | FAILED — one or more audit failures |
42//! | 2 | PENDING — unresolved entries |
43//! | 3 | ERROR — file-level errors |
44//! | 4 | CONFIG_ERROR — definition parse error |
45
46
47pub mod audit;
48pub mod config;
49pub mod diff;
50pub mod history;
51pub mod masking;
52pub mod profile;
53pub mod project;
54pub mod report;
55pub mod templates;
56
57pub use audit::engine::{AuditEngine, AuditOptions};
58pub use audit::result::{AuditResult, AuditStatus, AuditSummary, FileAuditResult};
59pub use config::definition::{AuditDefinition, AuditEntry, AuditStrategy};
60pub use diff::engine::DiffEngine;
61pub use diff::entry::{DiffEntry, DiffStats, DiffType, LARGE_FILE_THRESHOLD};
62pub use diff::ignore::IgnoreRules;
63pub use diff::progress::{DiffProgress, ProgressSink, ChannelProgress, NullProgress};
64pub use masking::engine::MaskingEngine;
65pub use report::generator::ReportGenerator;