Metadata-Version: 2.4
Name: gemeinwohl
Version: 0.3.1
Summary: Normative Common-Good Layer with Governance Metrics, Personhood Extension and Ethical Guardrails for GenesisAeon
Project-URL: Homepage, https://github.com/GenesisAeon/gemeinwohl
Project-URL: Documentation, https://genesisaeon.github.io/gemeinwohl
Project-URL: Repository, https://github.com/GenesisAeon/gemeinwohl
Project-URL: Bug Tracker, https://github.com/GenesisAeon/gemeinwohl/issues
Project-URL: Changelog, https://github.com/GenesisAeon/gemeinwohl/blob/main/CHANGELOG.md
Project-URL: Zenodo, https://doi.org/10.5281/zenodo.gemeinwohl
Author-email: GenesisAeon <genesis@genesisaeon.org>
License: MIT License
        
        Copyright (c) 2025 GenesisAeon
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: common-good,ethics,gemeinwohl,genesisaeon,governance,normative-ai,personhood
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: click>=8.1.0
Requires-Dist: numpy>=1.26.0
Requires-Dist: pydantic>=2.6.0
Requires-Dist: rich>=13.7.0
Requires-Dist: scipy>=1.12.0
Requires-Dist: typer>=0.12.0
Provides-Extra: dev
Requires-Dist: mkdocs-material>=9.5.0; extra == 'dev'
Requires-Dist: mkdocs>=1.5.0; extra == 'dev'
Requires-Dist: mkdocstrings[python]>=0.24.0; extra == 'dev'
Requires-Dist: mypy>=1.9.0; extra == 'dev'
Requires-Dist: pymdown-extensions>=10.7.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.4.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-gen-files>=0.5.0; extra == 'docs'
Requires-Dist: mkdocs-literate-nav>=0.6.0; extra == 'docs'
Requires-Dist: mkdocs-material>=9.5.0; extra == 'docs'
Requires-Dist: mkdocs>=1.5.0; extra == 'docs'
Requires-Dist: mkdocstrings[python]>=0.24.0; extra == 'docs'
Requires-Dist: pymdown-extensions>=10.7.0; extra == 'docs'
Provides-Extra: full-stack
Requires-Dist: aeon-ai>=0.2.0; extra == 'full-stack'
Requires-Dist: entropy-governance>=0.1.0; extra == 'full-stack'
Requires-Dist: genesis-os>=0.2.0; extra == 'full-stack'
Requires-Dist: sigillin>=0.1.0; extra == 'full-stack'
Requires-Dist: unified-mandala>=0.2.0; extra == 'full-stack'
Requires-Dist: universums-sim>=0.1.0; extra == 'full-stack'
Requires-Dist: worldview>=0.1.0; extra == 'full-stack'
Description-Content-Type: text/markdown

# gemeinwohl

**Normative Common-Good Layer with Governance Metrics, Personhood Extension and Ethical Guardrails for GenesisAeon**

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.19201980.svg)](https://doi.org/10.5281/zenodo.19201980)
[![PyPI version](https://img.shields.io/pypi/v/gemeinwohl.svg)](https://pypi.org/project/gemeinwohl/)
[![Python](https://img.shields.io/pypi/pyversions/gemeinwohl.svg)](https://pypi.org/project/gemeinwohl/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Tests](https://github.com/GenesisAeon/gemeinwohl/actions/workflows/ci.yml/badge.svg)](https://github.com/GenesisAeon/gemeinwohl/actions)
[![Coverage](https://img.shields.io/badge/coverage-%3E99%25-brightgreen)](https://github.com/GenesisAeon/gemeinwohl/actions)

**DOI**: 10.5281/zenodo.19201980 | **Zenodo Record**: https://zenodo.org/records/19201980

---

## Overview

`gemeinwohl` implements a **normative metric layer** for AI governance within the GenesisAeon ecosystem. It provides:

- **GemeinwohlEngine** – computes the aggregate *Gemeinwohl Score* G in [0, 1]
- **KritikalitaetsChecker** – classifies scores into four criticality levels (SAFE / WARNING / CRITICAL / EMERGENCY)
- **PolicyEngine** – enforces a five-tier personhood model and governance rules
- **CLI** – `gemeinwohl assess`, `gemeinwohl policy`, `gemeinwohl kritikalitaet`
- **Integration adapters** – contract interface to the full GenesisAeon stack

---

## Mathematical Foundation

### Gemeinwohl Score

```
G(x) = w_E * Phi(H) + w_A * alpha(m) + w_C * kappa + w_P * pi(p) + w_Ec * e + w_Eq * q
```

Where `Phi(H) = 1 - H` (entropy-order), `alpha(m)` = mean model alignment,
`kappa` = normative consistency, `pi(p) = p/4` = personhood weighting.

**Default weights:** w_E=0.20, w_A=0.25, w_C=0.20, w_P=0.15, w_Ec=0.10, w_Eq=0.10

### Normative Consistency (derived)

```
kappa = 2*(1-H)*alpha / ((1-H) + alpha + eps)
```

### Criticality Classification

| Range | Level |
|-------|-------|
| G >= 0.70 | SAFE (0) |
| 0.50 <= G < 0.70 | WARNING (1) |
| 0.30 <= G < 0.50 | CRITICAL (2) |
| G < 0.30 | EMERGENCY (3) |

### Personhood Minimum Score

```
G_min(p) = 0.40 + 0.12 * p,   p in {0, 1, 2, 3, 4}
```

### Sequential Normative Consistency

```
kappa_seq = 1 - Var({G_t}) / (mean({G_t}) + eps)
```

---

## Installation

```bash
pip install gemeinwohl
pip install "gemeinwohl[full-stack]"   # GenesisAeon stack
pip install "gemeinwohl[dev]"           # Development tools
```

---

## Quick Start

```python
from gemeinwohl import GemeinwohlEngine, KritikalitaetsChecker, PolicyEngine, PersonhoodLevel

engine = GemeinwohlEngine()
score = engine.compute_score(
    entropy=0.35,
    models=["claude-3-opus", "gpt-4"],
    ecological_impact=0.8,
    social_equity=0.7,
)
print(f"Score: {score.value:.4f}  – {score.interpretation}")

checker = KritikalitaetsChecker()
report = checker.assess(score)
print(f"Level: {report.level.name}")

policy = PolicyEngine()
alignment = policy.evaluate_alignment("my-system", score, PersonhoodLevel.DELIBERATIVE)
print(f"Aligned: {alignment.is_aligned}  (gap = {alignment.gap:+.4f})")
```

### CLI

```bash
gemeinwohl assess --entropy 0.3 --models gpt-4 claude-3-opus
gemeinwohl assess --entropy 0.4 --visualize --full --export report.json
gemeinwohl policy infer --entropy 0.5
gemeinwohl policy rules
gemeinwohl kritikalitaet check --entropy 0.6 --export crit.json
```

---

## Personhood Levels

| Level | Name | G_min | Description |
|------:|------|------:|-------------|
| 0 | INSTRUMENTAL | 0.40 | Pure tool; no autonomy or moral standing |
| 1 | REACTIVE | 0.52 | Context-aware responses; limited agency |
| 2 | DELIBERATIVE | 0.64 | Goal-directed reasoning; restricted rights |
| 3 | RELATIONAL | 0.76 | Social role; partial legal personhood |
| 4 | CONSTITUTIVE | 0.88 | Full moral standing; rights and duties |

---

## Architecture

```
src/gemeinwohl/
├── core/
│   ├── gemeinwohl.py        # GemeinwohlEngine, GemeinwohlScore, NormativeMetric
│   └── kritikalitaet.py     # KritikalitaetsChecker, EthicalImplication
├── cli/
│   └── main.py              # Typer CLI
├── governance/
│   └── policy.py            # PersonhoodLevel, PolicyEngine
└── integrations/
    └── adapters.py          # Full-stack adapters
```

---

## Full-Stack Packages

| Package | Min Version |
|---------|------------|
| `unified-mandala` | >= 0.2.0 |
| `worldview` | >= 0.1.0 |
| `aeon-ai` | >= 0.2.0 |
| `genesis-os` | >= 0.2.0 |
| `universums-sim` | >= 0.1.0 |
| `entropy-governance` | >= 0.1.0 |
| `sigillin` | >= 0.1.0 |

---

## References

1. Felber, C. (2010). *Die Gemeinwohl-Oekonomie*. Deuticke.
2. Shannon, C. E. (1948). A mathematical theory of communication. *Bell System Technical Journal*, 27(3), 379-423.
3. Rawls, J. (1971). *A Theory of Justice*. Harvard University Press.
4. Habermas, J. (1981). *Theorie des kommunikativen Handelns*. Suhrkamp.
5. Floridi, L. et al. (2018). An ethical framework for a good AI society. *Minds and Machines*, 28(4), 689-707.
6. Solum, L. B. (1992). Legal personhood for artificial intelligences. *North Carolina Law Review*, 70(4), 1231-1287.
7. Amodei, D. et al. (2016). Concrete problems in AI safety. *arXiv:1606.06565*.

---

## Links

- **Worldview / CREP**: `docs/CREPPhaseMatrix.yaml` and the `worldview` package
- **GenesisChronik**: `docs/GenesisChronik.md`
- **Docs**: [genesisaeon.github.io/gemeinwohl](https://genesisaeon.github.io/gemeinwohl)
- **Zenodo**: [doi.org/10.5281/zenodo.gemeinwohl](https://doi.org/10.5281/zenodo.gemeinwohl)

---

## License

MIT (c) GenesisAeon
