|
| 1 | +//! holon-viz demo — generates a sample tax-pipeline holarchy as a static HTML file. |
| 2 | +//! |
| 3 | +//! Usage (from project root): |
| 4 | +//! cargo run -p holon-viz --bin holon-viz-demo |
| 5 | +//! |
| 6 | +//! Writes: target/holon-viz-demo.html |
| 7 | +//! Open via Justfile: just demo-viz (builds + generates + opens via PowerShell) |
| 8 | +
|
| 9 | +use holon_viz::{CytoscapeGraph, Holon, HolonKind, HtmlRenderer}; |
| 10 | +use std::collections::HashMap; |
| 11 | +use std::path::PathBuf; |
| 12 | +use serde_json::Value; |
| 13 | + |
| 14 | +fn main() { |
| 15 | + let holons = sample_tax_pipeline(); |
| 16 | + let graph = CytoscapeGraph::from_holons(&holons); |
| 17 | + |
| 18 | + // Write alongside the cargo target dir so the Justfile PowerShell step |
| 19 | + // can find it at D:\Projects\l3dg3rr\target\holon-viz-demo.html |
| 20 | + let out_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) |
| 21 | + .join("../../target/holon-viz-demo.html"); |
| 22 | + |
| 23 | + match HtmlRenderer::write_to_file(&graph, &out_path) { |
| 24 | + Ok(()) => { |
| 25 | + let canonical = out_path.canonicalize().unwrap_or(out_path); |
| 26 | + println!("{}", canonical.display()); |
| 27 | + } |
| 28 | + Err(e) => { |
| 29 | + eprintln!("error: {e}"); |
| 30 | + std::process::exit(1); |
| 31 | + } |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +/// Build a holarchy that represents the l3dg3rr tax-ledger pipeline. |
| 36 | +fn sample_tax_pipeline() -> Vec<Holon> { |
| 37 | + let mut meta: HashMap<String, Value> = HashMap::new(); |
| 38 | + meta.insert("version".to_string(), Value::String("v1.9.0".to_string())); |
| 39 | + |
| 40 | + vec![ |
| 41 | + // ── Pipeline root ──────────────────────────────────────────────────── |
| 42 | + Holon { |
| 43 | + id: "pipeline".to_string(), |
| 44 | + label: "Tax Ledger Pipeline".to_string(), |
| 45 | + kind: HolonKind::CapsuleGroup, |
| 46 | + parent_id: None, |
| 47 | + children: vec![ |
| 48 | + "ingest".to_string(), |
| 49 | + "classify".to_string(), |
| 50 | + "reconcile".to_string(), |
| 51 | + "attest".to_string(), |
| 52 | + ], |
| 53 | + metadata: meta.clone(), |
| 54 | + }, |
| 55 | + // ── Stage nodes ────────────────────────────────────────────────────── |
| 56 | + Holon { |
| 57 | + id: "ingest".to_string(), |
| 58 | + label: "Ingest PDFs".to_string(), |
| 59 | + kind: HolonKind::SysmlBlock, |
| 60 | + parent_id: Some("pipeline".to_string()), |
| 61 | + children: vec!["docling".to_string(), "blake3-id".to_string()], |
| 62 | + metadata: HashMap::<String, Value>::new(), |
| 63 | + }, |
| 64 | + Holon { |
| 65 | + id: "classify".to_string(), |
| 66 | + label: "Classify Transactions".to_string(), |
| 67 | + kind: HolonKind::SysmlBlock, |
| 68 | + parent_id: Some("pipeline".to_string()), |
| 69 | + children: vec!["rhai-rules".to_string(), "flag-queue".to_string()], |
| 70 | + metadata: HashMap::<String, Value>::new(), |
| 71 | + }, |
| 72 | + Holon { |
| 73 | + id: "reconcile".to_string(), |
| 74 | + label: "Reconcile & Export".to_string(), |
| 75 | + kind: HolonKind::SysmlBlock, |
| 76 | + parent_id: Some("pipeline".to_string()), |
| 77 | + children: vec!["excel-workbook".to_string()], |
| 78 | + metadata: HashMap::<String, Value>::new(), |
| 79 | + }, |
| 80 | + Holon { |
| 81 | + id: "attest".to_string(), |
| 82 | + label: "Attest (CPA Sign-off)".to_string(), |
| 83 | + kind: HolonKind::SysmlBlock, |
| 84 | + parent_id: Some("pipeline".to_string()), |
| 85 | + children: vec!["audit-log".to_string()], |
| 86 | + metadata: HashMap::<String, Value>::new(), |
| 87 | + }, |
| 88 | + // ── Leaf nodes ─────────────────────────────────────────────────────── |
| 89 | + Holon { |
| 90 | + id: "docling".to_string(), |
| 91 | + label: "Docling OCR".to_string(), |
| 92 | + kind: HolonKind::ProcessNode, |
| 93 | + parent_id: Some("ingest".to_string()), |
| 94 | + children: vec![], |
| 95 | + metadata: HashMap::<String, Value>::new(), |
| 96 | + }, |
| 97 | + Holon { |
| 98 | + id: "blake3-id".to_string(), |
| 99 | + label: "Blake3 Content ID".to_string(), |
| 100 | + kind: HolonKind::ProcessNode, |
| 101 | + parent_id: Some("ingest".to_string()), |
| 102 | + children: vec![], |
| 103 | + metadata: HashMap::<String, Value>::new(), |
| 104 | + }, |
| 105 | + Holon { |
| 106 | + id: "rhai-rules".to_string(), |
| 107 | + label: "Rhai Rule Engine".to_string(), |
| 108 | + kind: HolonKind::ProcessNode, |
| 109 | + parent_id: Some("classify".to_string()), |
| 110 | + children: vec![], |
| 111 | + metadata: HashMap::<String, Value>::new(), |
| 112 | + }, |
| 113 | + Holon { |
| 114 | + id: "flag-queue".to_string(), |
| 115 | + label: "Flag Queue".to_string(), |
| 116 | + kind: HolonKind::ProcessNode, |
| 117 | + parent_id: Some("classify".to_string()), |
| 118 | + children: vec![], |
| 119 | + metadata: HashMap::<String, Value>::new(), |
| 120 | + }, |
| 121 | + Holon { |
| 122 | + id: "excel-workbook".to_string(), |
| 123 | + label: "Excel Workbook".to_string(), |
| 124 | + kind: HolonKind::OwlClass, |
| 125 | + parent_id: Some("reconcile".to_string()), |
| 126 | + children: vec![], |
| 127 | + metadata: HashMap::<String, Value>::new(), |
| 128 | + }, |
| 129 | + Holon { |
| 130 | + id: "audit-log".to_string(), |
| 131 | + label: "Immutable Audit Log".to_string(), |
| 132 | + kind: HolonKind::AuditEvent, |
| 133 | + parent_id: Some("attest".to_string()), |
| 134 | + children: vec![], |
| 135 | + metadata: HashMap::<String, Value>::new(), |
| 136 | + }, |
| 137 | + ] |
| 138 | +} |
0 commit comments