trumly_core/lib.rs
1#![warn(missing_docs)]
2//! The trumly engine: parse, validate and run rules over a typed graph of markdown files.
3//!
4//! A model is a folder of markdown files. Each file is a node: YAML front matter (an `id`, a `type`,
5//! typed links and other fields) followed by a free-form body. This crate loads those files into a
6//! [`model::Graph`], checks its structure, and evaluates the rules the model carries. It is pure:
7//! it never reads a file or touches the network, so the caller supplies `(path, text)` pairs. That
8//! is what lets the same code run in the command line tool, the MCP server, and the browser (as WASM).
9//!
10//! ```
11//! use trumly_core::report::check;
12//!
13//! let files = vec![
14//! ("a.md".to_string(), "---\nid: a\ntype: note\n---\nHello.\n".to_string()),
15//! ("b.md".to_string(), "---\nid: b\ntype: note\nparent: missing\n---\n".to_string()),
16//! ];
17//! let report = check(files);
18//! assert_eq!(report.graph.len(), 2);
19//! // `b` names a parent that does not exist, so the structure check reports it.
20//! assert!(report.structure.errors.iter().any(|f| f.kind == "missing_parent"));
21//! assert_ne!(report.exit_code(), 0);
22//! ```
23//!
24//! Where to start: [`report::check`] does the whole job; [`load`], [`structure`] and [`rules`] are
25//! its stages; [`ops`] holds edits such as renaming a node and rewriting every link to it.
26
27pub mod format;
28pub mod load;
29pub mod model;
30pub mod ops;
31pub mod parse;
32pub mod report;
33pub mod rules;
34pub mod structure;