weavatrix_rust/report/
mod.rs1mod html;
9mod layout;
10mod markdown;
11mod sections;
12mod tables;
13
14use crate::engine::Weavatrix;
15use blazingly_json::{Value, json};
16
17const ENGINE: &str = env!("CARGO_PKG_VERSION");
20
21pub struct Report {
23 pub markdown: String,
25 pub html: String,
27 pub data: Value,
29}
30
31pub fn compose(engine: &mut Weavatrix) -> Result<Report, String> {
42 let evidence = sections::gather(engine)?;
43 let summary = tables::summary(&evidence);
44 let sections = tables::sections(&evidence);
45 Ok(Report {
46 markdown: markdown::render(&summary, §ions, evidence.depth, ENGINE),
47 html: html::render(&summary, §ions, &evidence, ENGINE),
48 data: data(&evidence),
49 })
50}
51
52fn data(evidence: §ions::Evidence) -> Value {
53 json!({
54 "schema": "weavatrix.report.v1",
55 "engine": ENGINE,
56 "graph_stats": evidence.stats,
57 "verify_architecture": evidence.architecture,
58 "god_nodes": evidence.hubs,
59 "hot_path_review": evidence.hot,
60 "find_dead_code": evidence.dead,
61 "find_duplicates": evidence.duplicates,
62 "list_endpoints": evidence.endpoints,
63 "n8n_inventory": evidence.workflows,
64 "module_map": {
65 "depth": evidence.depth,
66 "modules": evidence.modules.iter().map(|module| json!({
67 "path": module.path,
68 "files": module.files,
69 "symbols": module.symbols,
70 "violations": module.violations,
71 "x": module.position.0,
72 "y": module.position.1
73 })).collect::<Vec<_>>(),
74 "links": evidence.links.iter().map(|(from, to, weight)| json!({
75 "from": from,
76 "to": to,
77 "weight": weight
78 })).collect::<Vec<_>>()
79 }
80 })
81}