Metadata-Version: 2.5
Name: open-privacy-protocol
Version: 0.1.0a1
Summary: Open Privacy Protocol (OPP) for Python: validate privacy models, resolve sharing rules for PII redaction and confidential AI, and call OPP Engine.
Project-URL: Homepage, https://openprivacyprotocol.com/
Project-URL: Documentation, https://openprivacyprotocol.com/get-started/
Project-URL: Specification, https://openprivacyprotocol.com/spec/
Project-URL: Source, https://github.com/kannancet/opp-python
Project-URL: Issues, https://github.com/kannancet/opp-python/issues
Author: The Open Privacy Protocol Authors
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Keywords: ai-agents,confidential-ai,data-classification,gdpr,hipaa,llm,mcp,open-standard,pii,pii-redaction,privacy
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
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: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: jsonschema>=4.18
Requires-Dist: pyyaml>=6.0
Provides-Extra: test
Requires-Dist: pytest>=8; extra == 'test'
Description-Content-Type: text/markdown

<p align="center">
  <a href="https://openprivacyprotocol.com/">
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/kannancet/opp-python/main/assets/brand/logo-transparent-white.png">
      <img src="https://raw.githubusercontent.com/kannancet/opp-python/main/assets/brand/logo-transparent-dark.png" alt="Open Privacy Protocol" width="440">
    </picture>
  </a>
</p>

<h3 align="center">OPP for Python</h3>

<p align="center">
  <a href="https://pypi.org/project/open-privacy-protocol/"><img alt="PyPI" src="https://img.shields.io/pypi/v/open-privacy-protocol?color=8964F4&style=flat-square"></a>
  <a href="LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/badge/license-Apache--2.0-5689F5?style=flat-square"></a>
  <img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10%2B-0B1025?style=flat-square&logo=python&logoColor=white">
  <img alt="Typed" src="https://img.shields.io/badge/typing-typed-4C5FD7?style=flat-square">
</p>

<!-- opp-nav:start -->
<p align="center">
  <a href="https://openprivacyprotocol.com/">openprivacyprotocol.com</a> &nbsp;|&nbsp; <a href="https://github.com/kannancet/open-privacy-protocol">Spec</a> &nbsp;·&nbsp; <a href="https://github.com/kannancet/open-privacy-protocol-engine">Engine</a> &nbsp;·&nbsp; <a href="https://github.com/kannancet/open-privacy-protocol-model">Model</a> &nbsp;·&nbsp; <b>Python</b> &nbsp;·&nbsp; <a href="https://github.com/kannancet/opp-js">JavaScript</a>
</p>
<!-- opp-nav:end -->

---

The Python SDK for the [Open Privacy Protocol](https://openprivacyprotocol.com/) (OPP), the open standard for describing
what is private and confidential in any data. Use it to validate privacy models, decide what an agent may
share with each destination (PII redaction, pseudonymization, blocking), and call an
[OPP Engine](https://github.com/kannancet/open-privacy-protocol-engine) query server.

```bash
pip install open-privacy-protocol
```

## Quick start

```python
import opp

model = opp.Model("acme.opp.yaml")                  # validates against the bundled schemas and catalog
model.action("personal.email", "external_ai")      # 'pseudonymize'
model.action("special.health", "external_ai")      # 'block'
opp.strictest_action(["allow", "redact", "review"]) # 'review'
opp.preset_for_naics("622110")["id"]               # 'healthcare'
opp.validate("acme.opp.yaml")                      # [] when the document conforms
```

```bash
opp validate acme.opp.yaml       # validate any OPP document
opp classes --group special      # browse the baseline catalog
```

### Ask OPP Engine before an agent shares

```python
from opp.client import EngineClient

engine = EngineClient("http://127.0.0.1:8765", token="change-me")
result = engine.check("Email jane.doe@example.com about CE-204817", destination="external_ai")

if result["verdict"] in ("block", "review"):
    raise PermissionError(result["summary"])
send_to_llm(result["safe_content"] or original)   # pseudonymized when needed
```

Run the engine next to your agent with `opp-engine serve acme.opp.yaml --http 127.0.0.1:8765`.

## What is included

| | |
|---|---|
| `opp.Model`, `opp.Catalog` | Load a privacy model or catalog, validate it, resolve every class and concept |
| `Model.action(class, destination)` | The action for content of a class going to `internal`, `partner`, `external_ai` or `public` |
| `opp.validate`, `opp.schema_errors` | Conformance checks, with every problem listed |
| `opp.baseline()`, `opp.presets()`, `opp.preset_for_naics()` | The baseline catalog (33 classes) and 15 industry presets, bundled |
| `opp.client.EngineClient` | `check`, `explain`, `classes`, `model`, `health` against OPP Engine, no extra dependencies |
| `opp` CLI | `opp validate`, `opp classes` |

The bundled schemas, catalog and presets come from the
[specification repository](https://github.com/kannancet/open-privacy-protocol); `opp.SPEC_VERSION` names the version.

<!-- opp-project:start -->
## The Open Privacy Protocol project

| Part | Repository | What it is |
|---|---|---|
| **OPP Spec** | [`open-privacy-protocol`](https://github.com/kannancet/open-privacy-protocol) | Specification, JSON Schemas, baseline catalog, industry presets |
| **OPP Engine** | [`open-privacy-protocol-engine`](https://github.com/kannancet/open-privacy-protocol-engine) | Generates privacy models from your sources and serves them over MCP and HTTP |
| **OPP Model** | [`open-privacy-protocol-model`](https://github.com/kannancet/open-privacy-protocol-model) | Open-weight detector for private values and confidential topics |
| **OPP for Python** | [`opp-python`](https://github.com/kannancet/opp-python) **(this repository)** | `pip install open-privacy-protocol` |
| **OPP for JavaScript** | [`opp-js`](https://github.com/kannancet/opp-js) | `npm install open-privacy-protocol` |

Website and documentation: **[openprivacyprotocol.com](https://openprivacyprotocol.com/)**
<!-- opp-project:end -->

## Development

```bash
pip install -e ".[test]" && pytest
python scripts/sync_spec.py ../open-privacy-protocol   # refresh the bundled spec files
```

Releases are published to PyPI from a `v*` tag by [`.github/workflows/release.yml`](.github/workflows/release.yml).

## License

Licensed under the [Apache License, Version 2.0](LICENSE).
