<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shivya: Consensus-Free Distributed Resource-Sharing Mesh | Architecture</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Outfit:wght@500;600;700&display=swap" rel="stylesheet">
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true, theme: 'dark' });
</script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<style>
:root {
--bg-color: #070A13;
--card-bg: #0C0F1D;
--text-primary: #F8FAFC;
--text-secondary: #94A3B8;
--border-color: #1E293B;
--accent-color: #3B82F6;
--accent-glow: rgba(59, 130, 246, 0.15);
--p2p-color: #14B8A6;
--ws-color: #F43F5E;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Inter', sans-serif;
background-color: var(--bg-color);
color: var(--text-primary);
line-height: 1.6;
padding: 2rem;
}
.container {
max-width: 850px;
margin: 0 auto;
background: var(--card-bg);
border: 1px solid var(--border-color);
border-radius: 16px;
padding: 3rem;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}
.back-link {
display: inline-block;
margin-bottom: 2rem;
color: var(--accent-color);
text-decoration: none;
font-weight: 600;
font-family: 'Outfit', sans-serif;
transition: transform 0.2s;
}
.back-link:hover {
transform: translateX(-4px);
}
header { margin-bottom: 2.5rem; }
h1 {
font-family: 'Outfit', sans-serif;
font-size: 2.4rem;
font-weight: 700;
margin-bottom: 0.5rem;
letter-spacing: -0.02em;
background: linear-gradient(135deg, #F8FAFC 30%, #3B82F6 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
h2 {
font-family: 'Outfit', sans-serif;
font-size: 1.5rem;
margin-top: 2.5rem;
margin-bottom: 1.25rem;
border-bottom: 1px solid var(--border-color);
padding-bottom: 0.5rem;
color: #F8FAFC;
}
h3 {
font-family: 'Outfit', sans-serif;
font-size: 1.15rem;
margin-top: 1.5rem;
margin-bottom: 0.75rem;
color: #38BDF8;
}
p { margin-bottom: 1.25rem; color: var(--text-secondary); }
ul, ol { margin-left: 1.5rem; margin-bottom: 1.25rem; color: var(--text-secondary); }
li { margin-bottom: 0.5rem; }
code {
background-color: #1E293B;
padding: 0.2rem 0.4rem;
border-radius: 4px;
font-family: monospace;
font-size: 0.9em;
color: #38BDF8;
}
.mermaid-container {
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 1.5rem;
background: #090D1A;
margin: 2rem 0;
display: flex;
justify-content: center;
}
.math-block {
background-color: #090D1A;
padding: 1.5rem;
border-radius: 8px;
border: 1px solid var(--border-color);
margin: 1.5rem 0;
text-align: center;
}
footer {
margin-top: 3rem;
border-top: 1px solid var(--border-color);
padding-top: 1.5rem;
text-align: center;
font-size: 0.85rem;
color: var(--text-secondary);
}
</style>
</head>
<body>
<div class="container">
<a class="back-link" href="index.html">← Back to Home</a>
<header>
<h1>SHIVYA Technical Architecture</h1>
<p style="color: var(--accent-color); font-weight: 500;">Component Layout, P2P Kademlia Transport, & Live WebOS Bridge</p>
</header>
<section>
<h2>1. Component Layout</h2>
<p>
SHIVYA is constructed as a modular Rust virtual workspace. It enforces strict boundary conditions, decoupling core homeostatic computations from platform-specific asynchronous networking and telemetry collection routines.
</p>
<div class="mermaid-container">
<pre class="mermaid">
graph TD
classDef ui fill:#0F172A,stroke:#F43F5E,stroke-width:2px,color:#F8FAFC;
classDef run fill:#0F172A,stroke:#10B981,stroke-width:2px,color:#F8FAFC;
classDef net fill:#0F172A,stroke:#14B8A6,stroke-width:2px,color:#F8FAFC;
classDef core fill:#0F172A,stroke:#3B82F6,stroke-width:2px,color:#F8FAFC;
Dashboard["WebOS Dashboard (index.html)"]:::ui
CLI["shivya-cli (Tokio & UDS)"]:::run
WS["WebSocket Server (Port 9002)"]:::run
P2P["shivya-p2p (Kademlia & UDP)"]:::net
UDP["UDP Socket (Big-Endian Framed)"]:::net
L4["Layer 4: shivya-turing (Morphogenesis)"]:::core
L3["Layer 3: shivya-onsager (Thermodynamics)"]:::core
L2["Layer 2: shivya-morphic (Morphic VM)"]:::core
L1["Layer 1: shivya-flux (Gibbs Inference)"]:::core
L0["Layer 0: shivya-hodge (DEC Matrix Solver)"]:::core
Dashboard <-->|WebSocket Stream| WS
WS <-->|SystemStatus JSON| CLI
CLI -->|Steps Ensemble| L4
L4 --> L3 --> L2 --> L1 --> L0
CLI <-->|Routes Events| P2P
P2P <-->|Big-Endian UDP Packets| UDP
UDP <-->|Network Mesh| PeerNode["Peer Edge Node"]:::net
</pre>
</div>
<h2>2. Core Crate Layer Specifications</h2>
<h3>Layer 0: Topological Fabric (<code>crates/shivya-hodge</code>)</h3>
<p>Tracks event history inside a directed simplicial complex and reconciles conflict using DEC operators:</p>
<ul>
<li><strong>SimplicialStateComplex:</strong> Tracks vertices (events), edges (directed flows), and triangles (concurrent context boundaries).</li>
<li><strong>DEC Operators:</strong> Implements gradient (\(d_0\)), curl (\(d_1\)), and divergence (\(\delta_1 = d_0^T\)) operators.</li>
<li><strong>Conjugate Gradient Solver:</strong> A sparse solver optimized for symmetric positive semi-definite (SPSD) systems that runs with zero heap allocations.</li>
<li><strong>Geodesic Reconciler:</strong> Projects out rotational conflict flow (\(d_1^T \beta\)) by solving:
<div class="math-block">\[L_2 \beta = d_1 \Delta S \quad \text{where} \quad L_2 = d_1 d_1^T\]</div>
</li>
</ul>
<h3>Layer 1: Homeostasis (<code>crates/shivya-flux</code>)</h3>
<p>
Steps physical nodes as Active Inference agents. Agents maintain internal beliefs (\(\mu\)) and adapt to environmental fluctuations by minimizing Variational Free Energy (\(F\)) over sensory streams (\(s\)) via local continuous gradients.
</p>
<h3>Layer 2: Self-Optimizing Register Core (<code>crates/shivya-morphic</code>)</h3>
<p>
Evaluates state transition logic inside a stack-allocated Register VM with cycle budgets. If moving average free energy breaches novelty limits, the VM hot-swaps its instruction stream and expands its active state dimensions.
</p>
<h3>Layer 3: Thermodynamic Ensemble (<code>crates/shivya-onsager</code>)</h3>
<p>
Coordinates adjacent node blankets using Onsager Reciprocal Relations and Game-Theoretic FEP. Balances resource migration across symmetric conductance couplings (\(L_{ij} = L_{ji}\)).
</p>
<h3>Layer 4: Morphogenesis (<code>crates/shivya-turing</code>)</h3>
<p>
Solves activator-inhibitor partial differential equations using Runge-Kutta 4th Order (RK4). High-stress activator zones trigger vertex mitosis (node splits), while low-utility zones undergo apoptosis (culling).
</p>
<h2>3. Decentralized Kademlia Transport (<code>crates/shivya-p2p</code>)</h2>
<p>
Binds geographically separated daemons into a unified statistical causal field using a custom peer-to-peer UDP protocol:
</p>
<ul>
<li><strong>Kademlia XOR Routing Table:</strong> Nodes maintain stack-allocated routing tables ($K=4$) keyed by XOR distance (\(d(x,y) = x \oplus y\)).</li>
<li><strong>LRU Eviction Guard:</strong> Full buckets trigger asynchronous UDP pings to detect stale addresses, preserving network topological health.</li>
<li><strong>Fixed-Layout UDP Wire Protocol:</strong> Zero-heap, big-endian float serialization for transferring simplicial deltas and parameter migrations consistently across heterogeneous CPU architectures.</li>
</ul>
<h2>4. Native Edge Daemon & Visualizer Bridge (<code>crates/shivya-cli</code>)</h2>
<p>
Acts as the orchestrator running the multi-threaded Tokio runtime on bare-metal:
</p>
<ul>
<li><strong>System Sampler:</strong> Pulls real-time CPU load and network packet metrics using `sysinfo` to drive the active inference loop.</li>
<li><strong>WebSocket Telemetry Bridge:</strong> When booted with <code>--visualize</code>, spawns a TCP server on port <code>9002</code> using <code>tokio-tungstenite</code> to broadcast JSON-serialized state snapshots.</li>
<li><strong>Lagged Recovery Loop:</strong> Gracefully catches <code>RecvError::Lagged</code> events, bypassing blocked or throttled browser clients to protect the core compute loop from backpressure.</li>
</ul>
</section>
<footer>
SHIVYA Substrate Project © 2026. Released under MIT and Apache 2.0.
</footer>
</div>
</body>
</html>