Metadata-Version: 2.4
Name: stochology
Version: 0.1.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Dist: numpy>=2.0
Requires-Dist: matplotlib>=3.9
Requires-Dist: nbformat>=5.10 ; extra == 'all'
Requires-Dist: nbclient>=0.10 ; extra == 'all'
Requires-Dist: jupyter-client>=8.6 ; extra == 'all'
Requires-Dist: ipykernel>=6.29 ; extra == 'all'
Requires-Dist: pytest>=8.3 ; extra == 'all'
Requires-Dist: pytest-cov>=6.0 ; extra == 'all'
Requires-Dist: ruff>=0.13 ; extra == 'all'
Requires-Dist: bandit>=1.8 ; extra == 'all'
Requires-Dist: maturin>=1.16,<2.0 ; extra == 'dev'
Requires-Dist: pytest>=8.3 ; extra == 'dev'
Requires-Dist: pytest-cov>=6.0 ; extra == 'dev'
Requires-Dist: ruff>=0.13 ; extra == 'dev'
Requires-Dist: bandit>=1.8 ; extra == 'dev'
Requires-Dist: nbformat>=5.10 ; extra == 'notebooks'
Requires-Dist: nbclient>=0.10 ; extra == 'notebooks'
Requires-Dist: jupyter-client>=8.6 ; extra == 'notebooks'
Requires-Dist: ipykernel>=6.29 ; extra == 'notebooks'
Provides-Extra: all
Provides-Extra: dev
Provides-Extra: notebooks
License-File: LICENSE
Summary: Stochology: the theory and ethics of aim — PyO3 bindings and interactive laboratories
Keywords: stochastic,calibration,causality,uncertainty,decision-making,risk,epistemic,governance,vital-margin,pyo3
Home-Page: https://stochology.org
Author-email: Silvano Neto <dev@silvanoneto.com>
Maintainer-email: Silvano Neto <dev@silvanoneto.com>
License-Expression: MIT
Requires-Python: >=3.13
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Bug Tracker, https://github.com/0b3st4f3r4/stochology/issues
Project-URL: Documentation, https://stochology.org
Project-URL: Homepage, https://stochology.org
Project-URL: Repository, https://github.com/0b3st4f3r4/stochology

# Stochology (`stochology`)

[![PyPI version](https://img.shields.io/pypi/v/stochology.svg)](https://pypi.org/project/stochology/)
[![Python versions](https://img.shields.io/pypi/pyversions/stochology.svg)](https://pypi.org/project/stochology/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

**The Theory and Ethics of Aim** for judgment and decision-making under structural uncertainty when action must precede the outcome.

`stochology` provides high-performance Python bindings (via [PyO3](https://pyo3.rs/) and pure Rust) to the core mathematical operators, sequential agent–world–institution simulation environments, and empirical verification laboratories of the Stochology framework.

---

## The Nuclear Triad of Aim

Stochology organizes judgment under uncertainty into three non-substitutable safeguards:

$$M_{\mathrm{Leontief}} = \min(S_{\mathrm{epi}},\, S_{\mathrm{vital}},\, S_{\mathrm{gov}})$$

1. **Filter I · Epistemic Margin ($S_{\mathrm{epi}}$)** (`stochology.epistemic`): Manski–Lee partial identification bounds, Meng big-data paradox ($\rho_{R,Y}$), cluster design effects ($\mathrm{DEFF}$), multiverse analysis, and agnotology detection.
2. **Filter II · Vital Margin ($S_{\mathrm{vital}}$)** (`stochology.vital`): Hill heavy-tail index ($\alpha$), Jensen shortfall ($\Delta_J$), Kingman queueing basin, and non-ergodic survival criteria ($\mathrm{TTS}_{\mathrm{survival}} \ge \mathrm{TTR}_{\mathrm{recovery}}$).
3. **Filter III · Institutional Governance ($S_{\mathrm{gov}}$)** (`stochology.governance`): Goodhart performativity audits, CRPS decompositions, verifiable temporal commitments (`TemporalVault`), and algedonic channel verification.

Removing any single axis triggers structural collapse (Collapse Propositions 1, 2, and 3).

---

## Installation

```bash
pip install stochology
```

For interactive Jupyter notebook laboratories with visualization support:

```bash
pip install "stochology[notebooks]"
```

## Quickstart

```python
import stochology as st

# 1. Simulate the Sequential Agent-World-Institution Loop
env = st.engine.CommunityReserveEnv(seed=2026)
print(f"Initial reserve: {env.reserve}")

# 2. Access canonical operators and indicators
lab5 = st.labs.chapter(5)
print(f"Danish fire tail index (Hill alpha): {lab5['danish_tail_alpha']:.4f}")

# 3. Test triadic integrity and collapse propositions
agent = st.engine.StochologicalAgent()
report = agent.evaluate_integrity()
print(f"Triadic status: {report.status}")
```

---

## Architectural Invariants

1. **Pure Rust Foundation**: The underlying mathematical core (`crates/stochology` and `crates/stochology-cli`) is implemented in pure Rust (`std` only, zero external dependencies) with deterministic `SplitMix64` pseudo-random generators (`DEFAULT_SEED = 2026`).
2. **Deterministic & Bitwise Replicable**: Notebooks and laboratory scripts carry zero wall-clock reads and zero network access, guaranteeing bit-for-bit reproducibility.
3. **Sealed Datasets**: `stochology.datasets` reads sealed empirical datasets validated against cryptographic `SHA256SUMS` manifests.

---

## Layout & Local Development

When working directly within the source repository:

```
src/
├── Cargo.toml                standalone crate `stochology-py` (_core cdylib)
├── pyproject.toml            maturin configuration
├── rust/                     PyO3 bindings to Rust core
├── stochology/               public Python surface & typed stubs (py.typed)
├── tests/                    pytest parity and contract verification suite
└── scripts/run_notebooks.py  headless execution gate for notebooks/
```

### Development Setup

```bash
uv sync --directory src
uv run --directory src maturin develop --release
uv run --directory src pytest
```

Full gate from repository root:

```bash
./scripts/verify.sh --with-python
```

### Links

- **Textbook & Treatise**: [https://stochology.org](https://stochology.org)
- **Source Code**: [https://github.com/0b3st4f3r4/stochology](https://github.com/0b3st4f3r4/stochology)
- **Bug Tracker**: [https://github.com/0b3st4f3r4/stochology/issues](https://github.com/0b3st4f3r4/stochology/issues)

