The cosmic web as fleet architecture.
Map your dependency ecosystem onto the large-scale structure of the universe. Filaments of repos connected by imports. Voids where no repos exist. Clusters of tightly-coupled modules. Hub nodes as critical infrastructure.
╭─ ★ cluster-core ──★──★ cluster-utils ─╮
╱ │ ╲
· · · · · · · · ★ hub-node · · · · · · VOID
╲ │ ╱
╰─ ★ filament-b ───★──★ filament-c ───★─── filament-d ─── · ·
│
★ cluster-deep
╱ │ ╲
★ ★ ★
In cosmology, the cosmic web is the largest known structure in the universe — a network of filaments, clusters, and voids stretching across billions of light-years. Matter isn't uniformly distributed; it clumps along filaments, accumulates at nodes, and leaves vast empty voids in between.
Your dependency ecosystem is the same:
| Cosmology | Fleet Architecture |
|---|---|
| Filaments | Chains of repos linked by imports — deep supply chains |
| Voids | Gaps in dependency-space — untapped niches, missing abstractions |
| Clusters | Tightly-coupled repo groups — should probably be one repo |
| Nodes | Critical hubs — single points of failure in the ecosystem |
| Density field | Smoothed map of where repos concentrate |
| LSS statistics | Correlation functions, power spectra — scaling relations of code |
Detect chains of repos connected by imports using Minimum Spanning Tree (MST) of the dependency graph. Long filaments = deep supply chains = fragile infrastructure.
use cosmic_web::{DependencyGraph, FilamentDetector};
let mut graph = DependencyGraph::new();
graph.add_edge("serde", "serde_json", 1.0);
graph.add_edge("serde_json", "my-api", 0.8);
graph.add_edge("my-api", "my-app", 0.6);
let detector = FilamentDetector::new(2);
let filaments = detector.detect(&graph);
for f in &filaments {
println!("Filament: {} repos, length={:.2}, strength={:.2}",
f.repos.len(), f.length, f.strength);
}Find empty regions of dependency-space using a watershed algorithm on a density field. Voids represent untapped niche space — no repos exist there yet.
use cosmic_web::{DependencyGraph, VoidDetector};
let graph = build_ecosystem_graph();
let detector = VoidDetector::new(50, 0.1);
let voids = detector.detect(&graph);
for v in &voids {
println!("Void: radius={:.2}, volume={:.2}, nearby={} repos",
v.radius, v.volume, v.nearby_repos);
}Detect groups of tightly-coupled repos with the friends-of-friends (FoF) algorithm. Clusters suggest modules that should be merged or refactored.
use cosmic_web::{DependencyGraph, ClusterDetector};
let graph = build_ecosystem_graph();
let detector = ClusterDetector::new(0.5);
let clusters = detector.detect(&graph);
for c in &clusters {
println!("Cluster: {} repos, mass={:.2}", c.repos.len(), c.mass);
}
// Cluster mass function (like the halo mass function!)
let (centers, counts) = ClusterDetector::mass_function(&clusters, 10);Identify repos depended on by many others using betweenness, degree, and eigenvector centrality. These are your single points of failure.
use cosmic_web::{DependencyGraph, HubDetector};
let graph = build_ecosystem_graph();
let detector = HubDetector::new(2);
let hubs = detector.detect(&graph);
for h in &hubs {
println!("Hub: {} — betweenness={:.3}, degree={}, eigenvector={:.3}",
h.repo, h.betweenness, h.degree, h.eigenvector_centrality);
}Kernel density estimation (KDE) on repo positions. Overdense regions are clusters, underdense are voids. Produces a smoothed density map of your ecosystem.
use cosmic_web::{DependencyGraph, DensityEstimator};
let mut graph = build_ecosystem_graph();
graph.compute_positions(100); // spring layout
let estimator = DensityEstimator::new(50, 0.3);
let field = estimator.estimate(graph.positions.as_ref().unwrap());
println!("Density contrast: {:.2}", field.contrast());
println!("Overdense cells: {}", field.overdense_cells(2.0).len());Compute two-point correlation functions, power spectra, and correlation lengths. Fit scaling relations and compare to cosmological values (γ ≈ 1.8, r₀ ≈ 5 h⁻¹ Mpc).
use cosmic_web::{DependencyGraph, LSSAnalyzer};
let graph = build_ecosystem_graph();
let analyzer = LSSAnalyzer::new(20);
let stats = analyzer.analyze(&graph);
println!("Correlation length: {:.2}", stats.correlation_length);
println!("Clusters: {}, Voids: {}, Filaments: {}",
stats.n_clusters, stats.n_voids, stats.n_filaments);
// Compare to cosmological scaling
let positions = graph.positions.unwrap();
let cf = analyzer.correlation_function(&positions);
let (gamma, r0) = analyzer.fit_scaling_relation(&cf);
println!("Scaling: ξ(r) ∝ (r/{:.2})^{:.2}", r0, gamma); ╭──────────────────────────────────────────────────────────╮
│ cosmic-web │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ filament │ │ void_ │ │ cluster │ │
│ │ (MST) │ │(watershed)│ │ (FoF) │ │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
│ │ │ │ │
│ └──────────────┼──────────────┘ │
│ │ │
│ ┌───────┴────────┐ │
│ │ density │ │
│ │ (KDE) │ │
│ └───────┬────────┘ │
│ │ │
│ ┌───────┴────────┐ │
│ │ large_scale │ │
│ │ (ξ, P(k), r₀) │ │
│ └────────────────┘ │
│ │
│ ┌──────────┐ ┌──────────────────────────────┐ │
│ │ node │ │ DependencyGraph │ │
│ │(centrality)│ │ (repos, edges, positions) │ │
│ └──────────┘ └──────────────────────────────┘ │
╰──────────────────────────────────────────────────────────╯
A dependency ecosystem mapped to the cosmic web:
VOID · · · · · · · · VOID
· · · · · · · · · · · ·
╭─★─★─★─╮
· · · · · │CLUSTER │ · · · · · · · ·
│ A │
· · · · · ╰───★────╯ · · · · · · · ·
│
· · · · · ★ HUB ★ · · · · · · · ·
╱ │ ╲
· · · ╭─★──★──★──★──★─╮ · · FILAMENT · ·
│ FILAMENT B │
· · · ╰──────★──────────╯ · · · · · · ·
│
· · · · · ╭──★──╮ · · · · · · · · ·
│CLUST│
· · · · · │ ER C │ · · · · · · · · ·
╰─★─★─╯
VOID · · · · · · · · VOID
Legend:
★= repo nodeCLUSTER= tightly-coupled groupFILAMENT= dependency chainHUB= critical node (high centrality)VOID= empty region (no repos)
[dependencies]
cosmic-web = "0.1"struct Filament {
repos: Vec<String>, // Repos in the chain
length: f64, // Total filament length
strength: f64, // Total edge weight
}
struct Void {
center: Vec<f64>, // Center of the void
radius: f64, // Effective radius
volume: f64, // Effective volume
nearby_repos: usize, // Repos near the boundary
}
struct Cluster {
repos: Vec<String>, // Member repos
mass: f64, // Total internal edge weight
centroid: Vec<f64>, // Center of mass
radius: f64, // Max distance from centroid
}
struct HubNode {
repo: String, // Repository name
betweenness: f64, // Betweenness centrality
degree: usize, // Connection count
eigenvector_centrality: f64, // Influence score
}
struct DensityField {
grid: Vec<Vec<f64>>, // 2D density grid
resolution: usize, // Grid resolution
bounds: (f64, f64), // Spatial bounds
}
struct LSSStats {
correlation_length: f64, // Scale where ξ(r) = 1
power_spectrum: Vec<f64>, // P(k) values
n_clusters: usize, // Cluster count
n_voids: usize, // Void count
n_filaments: usize, // Filament count
}| Component | Algorithm | Cosmological Analog |
|---|---|---|
| Filament detection | Kruskal's MST | Cosmic filament tracing |
| Void detection | Watershed on density field | Watershed void finder |
| Cluster detection | Friends-of-friends (FoF) | Halo finder |
| Hub identification | Brandes' betweenness + power iteration | Cluster centrality |
| Density estimation | Gaussian KDE | Galaxy density maps |
| LSS statistics | Two-point correlation, DFT | ξ(r), P(k) analysis |
In real cosmology:
- Filaments connect galaxy clusters, forming the backbone of the cosmic web
- Voids occupy ~80% of volume but contain <10% of matter
- Clusters sit at filament intersections — the most massive gravitationally bound objects
- The two-point correlation function ξ(r) ∝ (r/r₀)^(-γ) with γ ≈ 1.8
- The power spectrum P(k) encodes all clustering information
In your codebase, the same structures emerge naturally from dependency patterns. Deep filaments mean fragile supply chains. Large voids mean missed opportunities. Overweighted hubs mean bus factor = 1.
Map your universe. Find your structure.
MIT