21. Architectural Mapping of the Pure-Rust Apparatus
21.1 Why Pure Rust with Zero External Dependencies?
Most scientific computing projects depend on hundreds of transitive third-party packages (pip, npm, or external crates). Over a five-year horizon, transitive dependencies suffer from supply-chain drift: an upstream linear-algebra routine changes its tie-breaking rule, a random-number library alters its normal-distribution sampler, or a YAML parser changes how it handles floating-point precision—silently breaking reproducibility.
To guarantee that seed = 2026 produces the exact same bit-for-bit mathematical audit today and twenty years from today, the entire Stochology Protocol is implemented in 100% pure Rust (2021 edition) with zero external crate dependencies:
- Deterministic Pseudo-Randomness & Online Moments (
stochology_core::rng): Implements Sebastiano Vigna’s 64-bitSplitMix64generator, exact Box-Muller normal, Marsaglia-Tsang (2000) Gamma, Beta, Student-$t$, Exponential, and Knuth/Atkinson Poisson samplers, Welford-Terriberry 4th-order streaming moments (OnlineMomentswith skewness, excess kurtosis, and Jarque-Bera test), and Künsch (1989) moving-block bootstrap (block_bootstrap_ci) directly from IEEE-754 primitives. - Cryptographic Hashing & Keyed Authentication (
stochology_core::sha256): Implements the full NIST FIPS 180-4 SHA-256 digest and RFC 2104HMAC-SHA256authentication (hmac_sha256_hex) from scratch to seal pre-registrations (preregistration_hash), temporal vaults (TemporalVault), and empirical datasets (data/SHA256SUMS). - Structured Card Parser (
stochology_core::card): Parses and validatescards/*.yamldirectly into strongly typed Rust structs (EpistemologicalCard) without external serialization macros.
21.2 The Five-Crate Workspace Architecture
The repository is organized as a layered Cargo workspace where dependency arrows flow strictly downward from the CLI to the foundational core:
21.3 Complete Mapping from Textbook Chapters to Rust Modules
| Textbook Chapter & Protocol Section | Mathematical Concept / Governing Equation | Rust Module & Primary Types | Verification Command |
|---|---|---|---|
| Ch. 2 (§1.1) — Bridge $L_1 \to L_2$ | Meng’s Identity ($\rho_{R,Y}$), Rubin (MCAR/MAR/MNAR), Stratified Manski Bounds, Lee (2009) Trimming Bounds, and $W_1$ | stochology_core::layers::{MengAudit, ManskiBounds, MissingnessMechanism, empirical_wasserstein_1} | cargo run --release --bin labs -- --layers |
| Ch. 2 (§1.1) — Bridge $L_2 \to L_3$ | Jensen’s Gap $\Delta_J = \mathbb{E}[f(X)] - f(\mathbb{E}[X])$, quantiles, and exact $O(n\log n)$ LOO $\mathrm{CRPS}$ | stochology_core::layers::{NonlinearSummary, exact_loo_empirical_crps} | cargo run --release --bin labs -- --layers |
| Ch. 2 (§1.1) — Bridge $L_3 \to L_1$ | Performative Prediction ($\theta_{\mathrm{SL}}, \theta_{\mathrm{PS}}, \theta_{\mathrm{PO}}$), PerfGD, and RRM contraction $\frac{\varepsilon\beta}{\gamma} < 1$ | stochology_core::layers::{PerformativeSystem, PerformativeDiagnostic} | labs --layers & gates -- --defect performativity |
| Ch. 4 (§1.2) — Uncertainty Typing | Cholesky Empirical Bayes Kennedy-O’Hagan GP $\delta(x)$ and Info-Gap ($\hat{\alpha}, \hat{\beta}$) + Sniedovich/Wald Safeguard | stochology_core::uncertainty::{KennedyOHaganDiscrepancy, cholesky_decompose, InfoGapOption} | labs --uncertainty & gates -- --defect sniedovich |
| Ch. 6 (§1.3) — Lens 1 (Information) | 3-step DPI Markov chain, SDPI hierarchy ($\eta_{\chi^2} \le \eta_{\mathrm{KL}} \le \eta_{\mathrm{TV}}$), Blahut-Arimoto $C(W)$, and Fano’s floor | stochology_lenses::information::{DpiMarkovChain, SdpiHierarchy, blahut_arimoto_capacity, fano_error_lower_bound} | cargo run --release --bin labs -- --lenses |
| Ch. 6 (§1.3) — Lens 2 (Time) | Itô variance drain $g_{\text{time}} = \mu - \frac{1}{2}\sigma^2$, asymmetric & empirical Kelly $f^{\ast}$ vs. Merton, and LSI mixing | stochology_lenses::time::{TimeKellyDiagnostic, empirical_kelly_optimal_fraction, MixingTimeAudit} | cargo run --release --bin labs -- --lenses |
| Ch. 6 (§1.3) — Lens 3 (Scale & Tail) | Hill $\hat{\alpha}_{k,n}$, Dekkers-Einmahl-de Haan $\hat{\xi}$, POT GPD, $\mathrm{ES}_{0.99}$, and tail_n_eff | stochology_lenses::tail::{HillTailDiagnostic, dedh_moment_tail_index, gpd_pot_fit, expected_shortfall_99} | cargo run --release --bin labs -- --lenses |
| Ch. 6 (§1.3) — Lens 4 (Invariance) | Pearl’s Ladder, linear ICP $\hat{S}^{\ast}$, Chow $F$-test, nonlinear Hermite NILE/IRM, Rosenbaum $\Lambda^{\ast}$ & Cinelli-Hazlett $RV_q$ | stochology_lenses::invariance::{run_icp, chow_invariance_f_stat, run_nonlinear_icp_nile, cinelli_hazlett_robustness_value} | cargo run --release --bin labs -- --lenses |
| Ch. 6 (§1.3) — Lens 5 (Decision) | Cost-Loss $p^{\ast} = \frac{C}{\eta L}$, $\mathrm{EVPI}$, Richardson $V(p^{\ast})$, Log Score, isotonic PAV CORP-Murphy, and Fair-Coin Benchmark | stochology_lenses::decision::{CostLossRule, CorpPavDecomposition, logarithmic_score, ExactCoinCalibrationBenchmark} | cargo run --release --bin labs -- --lenses |
| Ch. 8 (§1.3) — Machine & Authentic Form | $(\varepsilon, \delta)$-Almost-Perfect Machine $M=(T,\Phi,\theta)$ (P1–P5) and AuthenticModelForm ($\delta(x)+\hat{S}^{\ast}$) | stochology_lenses::machine::{AlmostPerfectMachine, AuthenticModelForm, IdentityClosureAudit} | gates (G8) & gates -- --defect machine |
| Ch. 10 (§1.3.7) — Relational Ontology | Śūnyatā/RQM/OSR, Prigogine Brusselator RK4 + Schnakenberg $d_i S$, Schelling tipping, Homo clausus, and Daisyworld RK4 | stochology_lenses::relational::{RelationalComplexSystemsSynthesis, DissipativeAutopoieticAudit, DaisyworldSystem} | labs --lenses & gates (G8) |
| Ch. 11 (§1.3.8) — Analog & Wave Computing | Horowitz energy wall, RLC-mechanical RK4 isomorphism, AIMC “Analog Wall” vs. NAT, PKU HP-INV, SIREN/Wave RNN, and Sensory DPI | stochology_lenses::analog::{AnalogWaveComputingSynthesis, AimcAnalogWallHpInvAudit, EmpiricalWaveAnalogAudit} | labs --lenses, gates (G8), --defect analog_wall |
| Ch. 12 (§1.3.9) — Critical Stochastic Rationality | Adorno’s Nichtidentische $\Delta_{\text{Nichtidentische}}$, Marcuse/Rouvroy preemption & “Stochastic Parrots”, 300T token autophagy & Alia noise cliff, and neurosymbolic/wave overcoming | stochology_lenses::critical::{CriticalStochasticRationalitySynthesis, EmpiricalCriticalRationalityAudit} | labs --lenses, labs --real-data, gates (G8), --defect instrumental_reason |
| Ch. 13 (§1.3.10) — Stochary-Conjectural Synthesis, Supply-Chain Physics & Cybernetics | 150-node cybernetic graph, 4 Ontological Stock Axioms, Powell’s 4 policy classes, Friston $G(\pi)$, Pearl Front-Door, Dierickx-Cool, Scarf $(S,s)$, Kingman VUT & MEIO decoupling (SupplyChainPhysicsAudit), Simchi-Levi $\mathrm{TTS}/\mathrm{TTR}$, $\beta$-CVaR + WDRO, Ashby/Conant/Beer VSM S1–S5/S3*/Algedonic, and PATE Q1–Q4 matrix | stochology_lenses::stocks::{StocharyConjecturalCyberneticSynthesis, SupplyChainPhysicsAudit, EmpiricalStocharyCyberneticAudit} | labs --lenses, labs --real-data, gates (G8), --defect stochary_cybernetics |
| Ch. 15–17 (§2) — Contract, $\Phi_1$–$\Phi_5$ & Card | Prohibitions 1–4, Moulton-Campbell $\tilde{m}$, exceedance profile $\rho_I(p)$, Chouldechova + KMR, and YAML Card | stochology_core::invariants::{ExceedanceDesignEffect, ChouldechovaAudit} & stochology_core::card::EpistemologicalCard | labs --invariants, gates, --defect cromwell/phi5/moulton/chouldechova |
| Ch. 18 (§3) — Funnel & SIGA Roadmap | 4 Eliminatory Filters, Lentz Incomplete Beta & SHELF $\mathrm{Beta}(\hat{\alpha},\hat{\beta})$, 8-Step SIGA, SBC $\chi^2$, GRAPA e-processes, and Gigerenzer trees | stochology_siga::funnel::{evaluate_four_filter_funnel, fit_shelf_beta_prior} & stochology_siga::roadmap::{EvidenceProcess, NaturalFrequencyMemo} | cargo run --release --bin labs -- --siga |
| Ch. 19 (§4) — Governance, Vault & Drift | Bitemporal Clock ($t_{\text{disp}}$), Canary, HMAC-SHA256 Vault (SealTampered), CORP Breaker, ExTRA-WCP-T, Online ACI, and 4 Label Shift Estimators | stochology_governance::{clock::*, vault::TemporalVault, drift::{AdaptiveConformalInference, *}} | labs --governance, gates -- --defect clock/vault/concept_drift |
| Ch. 20 (§5) — Empirical Synthesis (Lab 7) | End-to-end audit across all 13 empirical CSV datasets and 3 canonical YAML cards | stochology_cli (src/lib.rs & src/bin/labs.rs) | cargo run --release --bin labs -- --real-data |