code wiki / (root) / nx_substrate_diagram.nx

nx_substrate_diagram.nx

buildroot/runtime/nx_substrate_diagram.nx

9153 B242 linesdepth 5pulls 8 transitivereach 0 importersview sourcekind tooltopic substrate
docsdependenciesstructsconstsfunctions

about

nx_substrate_diagram.nx -- substrate-walker that BUILDS an nx_diagram and emits any of 4 formats (Mermaid / DOT / ASCII / JSON). Refactored 2026-05-13 to consume the nx_diagram primitive instead of hand-rolling Mermaid output. Reduces ~260 LOC to ~170 LOC and gives the substrate-walker 4 output formats for free. DEFAULT EMITTER: Mermaid (backward-compatible with prior tool). To emit other formats, edit the call near the bottom of main() -- nx_diagram_emit_dot(d) / nx_diagram_emit_ascii(d) / nx_diagram_emit_json(d). genealogy_id: mermaid_2015_javascript_diagram_text + graphviz_dot + plain_text_diagram_lineage lineage_id: graph_visualization_text_format axioms: NX_AX_REL_TRANSITIVITY (depends-on transitive)

dependencies 7 imports · 0 importers

nx_syscalls.nx nx_runtime.nx nx_axioms.nx nx_dirent.nx nx_fcntl.nx nx_tier.nx nx_diagram.nx nx_substrate_diagram.nx

imports: nx_syscalls.nxnx_runtime.nxnx_axioms.nxnx_dirent.nxnx_fcntl.nxnx_tier.nxnx_diagram.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap nx_diagram_new sys_mmap ↻ dia_collect_into_diagram nx_openat sys_mmap ↻ nx_dirent_read nx_dirent_iter nx_dirent_name_len dia_name_matches dia_module_from_filename nx_diagram_add_node nx_diagram_node_at sys_close println sys_write strlen sys_mmap ↻ dia_add_edges_for_module sys_mmap ↻ strlen ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close ↻ dia_find_module_idx strlen ↻ strneq nx_diagram_add_edge nx_diagram_edge_at nx_diagram_emit_mermaid println ↻ nx_diagram_node_at ↻ print sys_write ↻ strlen ↻ nx_diagram_edge_at ↻

structs

none

consts

31const NX_DIA_MAX_MODULES: nx_idx = 400
32const NX_DIA_MAX_EDGES: nx_idx = 4096
33const NX_DIA_MAX_NAME: nx_size = 96
34const NX_DIA_DIR_BUF: nx_size = 16384

functions

38func dia_name_matches(name: *u8, name_len: nx_size) -> nx_int
63func dia_module_from_filename(name: *u8, name_len: nx_size, out: *u8) -> nx_size
76func dia_collect_into_diagram(dir_path: *u8, d: *Diagram, names_buf: *u8) -> nx_idx
113func dia_find_module_idx(d: *Diagram, names_buf: *u8, name: *u8, name_len: nx_size) -> nx_idx
127func dia_add_edges_for_module(d: *Diagram, names_buf: *u8, from_idx: nx_idx) -> nx_int
215func main() -> i64