facett-demo/src/demo_codevault.rs
//! **The `codevault` tab** — the Wreck-It-Ralph **Code Vault** (warehouse-navigator
//! -design.md §4) rendered over a slice of the nordisk warehouse: nordisk crates as
//! labeled **boxes** wired by dependency **connectors** in a dark 3D vault, with the
//! **shiny glowing transparent** box material and a live **glitch** (a reported
//! problem red-flickering like Vanellope).
//!
//! [`facett_graph3d::CodeVault`] already IS a [`Facet`](facett::Facet) (its Elm bridge
//! publishes the rich glitch/material/geometry `state_json`), so — like
//! [`crate::nordisk_helix`] — the demo just hands the deck a populated `CodeVault`; no
//! wrapper. [`demo_vault`] builds the fixture warehouse model that stands in for the
//! nornir warehouse-model feed until the sibling nornir agent emits it (the shape is
//! [`CodeGraph`]'s serde form, so swapping the fixture for `CodeGraph::from_json(feed)`
//! is a one-liner).
use egui::Color32;
use facett::graph3d::{CodeGraph, CodeNode, CodeVault, Layout3D, Material, NodeState};
/// The stable tab title (the deck/discovery-contract key + the legend key).
pub const TITLE: &str = "codevault";
/// Build the demo Code Vault over a slice of the nordisk warehouse: a dozen crates
/// across nornir / facett / holger / znippy / edda, wired by real-shaped dep edges,
/// with **one glitch** (`nornir-warehouse` — a reported problem, red-flickering) and
/// **two changed** units (freshly-touched, glowing amber). Emissive-transparent
/// material by default (the glowing translucent boxes). Force layout reads most like
/// the Wreck-It-Ralph wiring.
pub fn demo_vault() -> CodeVault {
// Per-repo categorical colours (recolour-by-repo, warehouse-navigator §5).
let nornir = Color32::from_rgb(90, 170, 250);
let facett = Color32::from_rgb(120, 210, 140);
let holger = Color32::from_rgb(200, 150, 240);
let znippy = Color32::from_rgb(240, 170, 70);
let edda = Color32::from_rgb(230, 120, 150);
let n = |label: &str, c: Color32, s: NodeState| CodeNode::new(label, c, s);
// 0..12
let nodes = vec![
n("edda-testmatrix", edda, NodeState::Ok), // 0
n("edda-git", edda, NodeState::Ok), // 1
n("facett-core", facett, NodeState::Ok), // 2
n("facett-graph3d", facett, NodeState::Changed), // 3 (freshly touched: this feature)
n("nornir-warehouse", nornir, NodeState::Glitch), // 4 (a reported problem)
n("nornir-viz", nornir, NodeState::Ok), // 5
n("nornir-release", nornir, NodeState::Ok), // 6
n("holger-server", holger, NodeState::Ok), // 7
n("holger-repo", holger, NodeState::Ok), // 8
n("znippy-compress", znippy, NodeState::Ok), // 9
n("znippy-codec", znippy, NodeState::Changed), // 10 (freshly touched)
n("facett-demo", facett, NodeState::Ok), // 11
];
// Dependency connectors (from → to).
let edges = vec![
(3, 2), // facett-graph3d → facett-core
(11, 2), // facett-demo → facett-core
(11, 3), // facett-demo → facett-graph3d
(5, 4), // nornir-viz → nornir-warehouse
(4, 0), // nornir-warehouse → edda-testmatrix
(6, 1), // nornir-release → edda-git
(6, 4), // nornir-release → nornir-warehouse
(7, 8), // holger-server → holger-repo
(8, 9), // holger-repo → znippy-compress
(9, 10), // znippy-compress → znippy-codec
(4, 9), // nornir-warehouse → znippy-compress (the glitch's wiring flickers)
(5, 2), // nornir-viz → facett-core
];
CodeVault::new(CodeGraph::new(nodes, edges), Layout3D::Force)
.with_title(TITLE)
.with_material(Material::EmissiveTransparent)
}
#[cfg(test)]
mod tests {
use super::*;
use facett::Facet;
#[test]
fn demo_vault_is_the_populated_nordisk_warehouse_with_a_glitch() {
let v = demo_vault();
let j = v.state_json();
// The deck keys off this exact title.
assert_eq!(v.title(), TITLE);
assert_eq!(j["boxes"], 12, "twelve nordisk crates as boxes");
assert_eq!(j["edges"], 12, "twelve dependency connectors");
// Exactly one reported problem lit as a glitch, two changed units.
assert_eq!(j["glitch_count"], 1);
assert_eq!(j["glitch_nodes"], serde_json::json!([4]), "nornir-warehouse glitches");
assert_eq!(j["changed_count"], 2);
// The shiny glowing transparent box material.
assert_eq!(j["material"], "emissive_transparent");
assert_eq!(j["emissive"], true);
}
}