code wiki / hub / nx_dep_graph.nx

nx_dep_graph.nx

buildroot/runtime/hub/nx_dep_graph.nx

16262 B392 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind librarytopic dep
docsdependenciesstructsconstsfunctions

about

nx_dep_graph.nx -- V2.0 P-8: directed dependency graph + Tarjan SCC. Sovereign port of Tarjan's 1972 strongly-connected-components algorithm (Robert Tarjan, "Depth-first search and linear graph algorithms", SIAM J. Computing, 1972). Linear-time O(V+E) cycle detection across the substrate artifact graph. COMPOSES (per "avoid duplicate primitives" cardinal): nx_syscalls.sys_mmap (per-instance buffer allocation) COMPOSED BY: wiki/nx_pipeline_walker (V2.0 P-8.5; queued -- populates graph from extractor_nx import lists) wiki/nx_pipeline_route (V3+ /wiki/pipeline/graph view) wiki/nx_artifact_store (V3+ MEANINGFUL refinement: artifact with resolved imports + reverse-deps is more MEANINGFUL than orphans) V2.0 P-8 SCOPE: - NxDepGraph: parallel-pool adjacency list (from_rowid -> list of to_rowid) - nx_dep_graph_add_edge: caller-driven population - nx_dep_graph_tarjan_scc: iterative Tarjan SCC (NO recursion; substrate- friendly; bounded stack budget per NX_DEPG_MAX_STACK) - Per-rowid SCC ID assignment (scc_id[rowid] = scc index 0..N-1) - Accessors: deps / reverse-deps / scc-of / scc-size / cycle-detection V3+ SCOPE (TODO): - Topological sort within DAG (sccs treated as supernodes) - Critical-path computation (longest dep chain) - Pretty-printed graphviz / mermaid emit - Per-SCC quarantine recommendation (cycle = MEANINGFUL refinement blocker per V2_0_PIPELINE_BOOTSTRAP ยง2.2) REFERENCE: Tarjan 1972 -- the original DFS-based algorithm. Substrate implementation uses explicit work-stack + index/lowlink arrays (no recursive function calls). Status: V2.0 P-8. 2026-05-27.

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_dep_graph.nx nx_pipeline_graph_builder.nx nx_wiki_main.nx

imports: nx_syscalls.nx

imported by: nx_pipeline_graph_builder.nxnx_wiki_main.nx

structs

71struct NxDepGraph

consts

42const NX_DEPG_OK: i64 = 0
43const NX_DEPG_BAD_INPUT: i64 = 3040
44const NX_DEPG_GRAPH_FULL: i64 = 3041
45const NX_DEPG_EDGE_FULL: i64 = 3042
46const NX_DEPG_STACK_OVERFLOW: i64 = 3043
47const NX_DEPG_NOT_BUILT: i64 = 3044
48const NX_DEPG_LOOP_BUDGET: i64 = 3045
49const NX_DEPG_OUT_OF_RANGE: i64 = 3046
52const NX_DEPG_HARD_MAX_NODES: i64 = 10000
53const NX_DEPG_HARD_MAX_EDGES: i64 = 100000
54const NX_DEPG_MAX_STACK: i64 = 10000 // Tarjan work-stack cap
55const NX_DEPG_LOOP_BUDGET_CAP: i64 = 100000000
58const NX_DEPG_UNVISITED: i64 = 0 - 1

functions

102func nx_dep_graph_init(g: *NxDepGraph, nodes_cap: i64, edges_cap: i64) -> i64
calls 1: sys_mmap
143func nx_dep_graph_add_edge(g: *NxDepGraph, from_rowid: i64, to_rowid: i64) -> i64
169func nx_dep_graph_tarjan_scc(g: *NxDepGraph) -> i64
299func nx_dep_graph_scc_of(g: *NxDepGraph, rowid: i64) -> i64
308func nx_dep_graph_scc_size(g: *NxDepGraph, rowid: i64) -> i64
325func nx_dep_graph_is_in_cycle(g: *NxDepGraph, rowid: i64) -> i64
332func nx_dep_graph_deps_count(g: *NxDepGraph, rowid: i64) -> i64
340func nx_dep_graph_dep_at(g: *NxDepGraph, from_rowid: i64, i: i64) -> i64
352func nx_dep_graph_rev_deps_count(g: *NxDepGraph, rowid: i64) -> i64
366func nx_dep_graph_scc_count(g: *NxDepGraph) -> i64
373func nx_dep_graph_edge_count(g: *NxDepGraph) -> i64
380func nx_dep_graph_count_nodes_in_cycles(g: *NxDepGraph) -> i64