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 "dify_inventory": evidence.apps,
65 "module_map": {
66 "depth": evidence.depth,
67 "modules": evidence.modules.iter().map(|module| json!({
68 "path": module.path,
69 "files": module.files,
70 "symbols": module.symbols,
71 "violations": module.violations,
72 "x": module.position.0,
73 "y": module.position.1
74 })).collect::<Vec<_>>(),
75 "links": evidence.links.iter().map(|(from, to, weight)| json!({
76 "from": from,
77 "to": to,
78 "weight": weight
79 })).collect::<Vec<_>>()
80 }
81 })
82}