Metadata-Version: 2.4
Name: pacif-framework
Version: 3.1.0
Summary: Statistically rigorous framework for predictive alignment: measures statistical coupling between user behavior and system context, and assesses estimate reliability.
Author-email: PACIF Framework Contributors <for.smirnov.maks@gmail.com>
Maintainer-email: ppiiyo <for.smirnov.maks@gmail.com>
License: Apache-2.0
Project-URL: Homepage, https://github.com/ppiiyo/pacif-framework
Project-URL: Documentation, https://github.com/ppiiyo/pacif-framework#readme
Project-URL: Repository, https://github.com/ppiiyo/pacif-framework
Project-URL: Bug Tracker, https://github.com/ppiiyo/pacif-framework/issues
Project-URL: DOI, https://doi.org/10.5281/zenodo.19902776
Project-URL: Demo, https://pacif-demo.streamlit.app
Project-URL: Changelog, https://github.com/ppiiyo/pacif-framework/blob/main/CHANGELOG.md
Keywords: algorithmic-accountability,mutual-information,recommendation-systems,causal-inference,audit,transparency,drift-detection,predictive-alignment,responsible-ai,fairness,filter-bubble
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Information Technology
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
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 :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: numba>=0.58
Requires-Dist: scipy>=1.10
Requires-Dist: pyyaml>=6.0
Provides-Extra: demo
Requires-Dist: streamlit>=1.28; extra == "demo"
Requires-Dist: pandas>=2.0; extra == "demo"
Requires-Dist: scikit-learn>=1.3; extra == "demo"
Provides-Extra: causal
Requires-Dist: scikit-learn>=1.3; extra == "causal"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: ruff>=0.1; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Requires-Dist: build>=1.0; extra == "dev"
Requires-Dist: twine>=4.0; extra == "dev"
Dynamic: license-file

# PACIF v3.0

**Predictive Alignment & Causal Information Flow**

> Measures statistical coupling between user behavior and system context, and assesses the reliability of that estimate.

[![Streamlit Demo](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://pacif-demo.streamlit.app)
[![PyPI](https://img.shields.io/pypi/v/pacif-framework.svg)](https://pypi.org/project/pacif-framework/)
[![DOI](https://img.shields.io/badge/DOI-10.5281/zenodo.19902776-blue)](https://doi.org/10.5281/zenodo.19902776)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![CI](https://github.com/ppiiyo/pacif-framework/actions/workflows/ci.yml/badge.svg)](https://github.com/ppiiyo/pacif-framework/actions/workflows/ci.yml)

---

## Why PACIF exists

Modern recommendation systems are **closed-loop controllers**: user actions train the model, and the model shapes future exposure. These feedback loops can produce behavioral lock-in, filter bubbles, and algorithmic influence that is hard to observe from the outside.

Platforms, regulators, auditors, and researchers currently lack a **transparent, statistically rigorous, and audit-ready metric** that answers a simple question:

> *How tightly is user behavior coupled to the system’s recommendations — and can we trust that measurement?*

Existing approaches suffer from finite-sample bias, provide no reliability diagnostics, and are frequently misinterpreted as causal claims. PACIF was built to close that gap.

---

## What PACIF measures

PACIF quantifies **predictive alignment** between user actions (`U`) and system context / recommendations (`S`), with optional control for observed confounders (`C`).

It is deliberately **not** a measure of causality, user wellbeing, or “manipulation”. It is a production-ready diagnostic layer that tells you:

| Signal | What it tells you |
|--------|-------------------|
| **Signal Strength (MI)** | Intensity of statistical coupling (nats) |
| **Reliability** | Whether the estimate is statistically stable |
| **Drift** | Whether the relationship has shifted over time |
| **Audit Report** | Machine-readable YAML with anti-gaming flags |

### Core capabilities

- **Bias-corrected Mutual Information** — Miller–Madow correction removes first-order finite-sample bias.
- **Strict reliability diagnostics** — automatically flags unstable estimates via confidence-interval width thresholds.
- **Cumulative drift detection** — CUSUM + Page-Hinkley for non-stationary shifts in the alignment signal.
- **Regulator-ready audit reports** — YAML output with exclusion-rate, category-inflation, skew, and drift flags (schema 1.2).
- **Causal integration pattern** — synthetic PACIF-like features reduce Doubly Robust (DR) estimator bias in an illustrative simulation; see `causal_integration.py` (features are predictive by construction — not evidence on real data).

**Performance (reference):** >1,900 sessions/sec, p95 latency <1 ms (`examples/benchmark_throughput.py`).

---

## Explicit boundaries (important)

PACIF measures **statistical predictability**, not causality and not wellbeing.

- High mutual information indicates strong *association / coupling*, not that the algorithm *caused* the behavior.
- Normative or causal claims require intervention data, experimental design, or stronger identification assumptions.
- The framework is designed to be honest about uncertainty: unreliable estimates are explicitly marked.

Full practitioner guide: **[docs/INTERPRETATION.md](docs/INTERPRETATION.md)**  
Outreach one-pager: **[docs/POSITIONING.md](docs/POSITIONING.md)**

---

## Quick start

### Live demo (no install)

👉 **[Launch PACIF Demo](https://pacif-demo.streamlit.app)**

### Install

```bash
pip install pacif-framework
```

From source (development):

```bash
git clone https://github.com/ppiiyo/pacif-framework.git
cd pacif-framework
pip install -e ".[demo,dev]"
pytest tests/ -v
```

### Minimal usage

```python
from pacif_core import estimate_alignment, DriftDetector, AuditReporter
import numpy as np

events   = np.array([0, 1, 0, 2, 1, 0, 2, 1] * 20)
contexts = np.array([0, 1, 0, 1, 1, 0, 2, 1] * 20)

result = estimate_alignment(events, contexts)

if result["status"] == "success":
    print(f"MI: {result['mi_estimate']:.3f} nats")
    print(f"95% CI: {result['ci_95']}")
    print(f"Reliable: {result['reliable']}")
```

See `examples/basic_usage.py` for multi-session + drift + audit.

---

## Interpreting results

| Metric | Interpretation | Suggested action |
|--------|----------------|------------------|
| **Signal Strength (MI)** | Intensity of coupling | > 0.8 nats → investigate lock-in risk |
| **Reliability Ratio** | % of sessions with statistically valid estimates | < 70% → increase sample size or window |
| **Drift Status** | Significant change in the relationship over time | Drift detected → consider model recalibration |

Deep dive: [docs/INTERPRETATION.md](docs/INTERPRETATION.md)

---

## Who this is for

- **Responsible AI / Trust & Safety teams** — internal monitoring of recommendation influence and feedback loops.
- **Platforms** (social, e-commerce, content, news) — diagnostics for personalization strength and stability.
- **Regulators & compliance** — audit-ready, machine-readable reports with explicit reliability and anti-gaming signals.
- **Researchers** in algorithmic accountability, fairness, and causal inference — reproducible metric + integration path with DR estimators.
- **Auditors & third-party assessors** — independent quantification of human–algorithm coupling.

---

## Project structure

```
pacif-framework/
├── pacif_core/
│   ├── estimator.py      # Bias-corrected MI + reliability
│   ├── drift.py          # CUSUM + Page-Hinkley detectors
│   └── audit.py          # YAML audit reporter (schema 1.2)
├── tests/                # pytest suite
├── docs/
│   ├── INTERPRETATION.md
│   └── POSITIONING.md
├── examples/
│   ├── basic_usage.py
│   └── benchmark_throughput.py
├── app.py                # Streamlit demo
├── causal_integration.py # DR estimator illustration (synthetic)
└── .github/workflows/ci.yml
```

---

## Enterprise & audit integration

For production deployments, multi-tenant audit pipelines, custom connectors, or compliance reporting support, contact:

**for.smirnov.maks@gmail.com**

---

## Contributing

We welcome contributions. Algorithmic transparency should be a public good.

- 🐛 [Open an issue](https://github.com/ppiiyo/pacif-framework/issues)
- 💡 Pull requests are welcome (see [CONTRIBUTING.md](CONTRIBUTING.md))
- 📜 Please follow the [Code of Conduct](CODE_OF_CONDUCT.md)
- 🔒 [Security policy](SECURITY.md)

---

## Citation

If you use PACIF in research, audits, or product workflows, please cite:

```bibtex
@software{pacif_v3_2026,
  author       = {ppiiyo},
  title        = {PACIF v3.0: Predictive Alignment \& Causal Information Flow},
  year         = {2026},
  url          = {https://github.com/ppiiyo/pacif-framework},
  doi          = {10.5281/zenodo.19902776},
  license      = {Apache-2.0}
}
```

Also available as [`CITATION.cff`](CITATION.cff).

---

*Built for transparency, reproducibility, and algorithmic accountability.*  
© 2026 PACIF Framework Contributors
