Metadata-Version: 2.4
Name: prograph-act
Version: 0.1.1
Summary: ProAct: the action layer over ProGraph. It decides and acts on your data, and records every decision with its proof.
Author: Brice Giesbrecht
License-Expression: Apache-2.0
Project-URL: Homepage, https://gitlab.com/briceg/proact
Project-URL: Source, https://gitlab.com/briceg/proact
Project-URL: Changelog, https://gitlab.com/briceg/proact/-/blob/main/docs/changelog.md
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Database
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: prograph[duckdb,shacl]<2,>=1.4
Requires-Dist: pyyaml>=6.0.0
Requires-Dist: numpy>=1.26
Requires-Dist: cryptography>=42
Provides-Extra: databricks
Requires-Dist: prograph[databricks]<2,>=1.4; extra == "databricks"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Dynamic: license-file

# ProAct

ProAct is the action layer over [ProGraph](https://gitlab.com/briceg/prograph)'s semantic layer. It decides and acts on your data, where it lives, and records every decision and action with its proof.

You write a decision contract: the evidence to read, the rules that decide, and the actions each outcome asks for. ProAct runs it, applies the governance you configured, writes effects such as holds and tasks into ProGraph's own store, and keeps an append-only record. Source tables are never written. ProAct provides mechanisms and does not judge what is risky or right.

## Install

ProAct needs Python 3.11 or later. It installs ProGraph 1.4 or later with DuckDB and SHACL validation:

```bash
pip install prograph-act
```

The package installs as `prograph-act` and imports as `proact`.

The `prograph-act[databricks]` extra keeps the event log and the package store on Delta tables through a Databricks SQL warehouse.

## Run the supply-chain demo

The demo generates 300 suppliers, runs the supplier-risk contract over them, and prints the holds it placed:

```bash
python -m proact.demo supply-chain
```

```text
297 decisions; 29 actions dispatched
S00175 Arddella Castings LLC SITE-SANCTIONED
S00231 Corlundon Wiring Co CONTROL-DENIED
S00100 Feylunda Assembly LLC SITE-SANCTIONED
S00257 Quillvane Trading Ltd HIGH-RISK
S00138 Solika Components Ltd SITE-SANCTIONED
S00149 Tevika Forge BV CONTROL-DENIED
S00056 Wenfordar Castings BV SITE-SANCTIONED
```

`python -m proact.demo supply-chain --walkthrough` goes further: a second run over unchanged data, an analyst's override, a legal hold that blocks an erasure, a candidate contract version read in shadow, and the calls out to a webhook and a file drop.

The same run from Python:

```python
import tempfile, warnings
from pathlib import Path
warnings.filterwarnings("ignore")
from proact.demo import supply_chain as demo
from proact.run import AllEligible

world = demo.build_world(Path(tempfile.mkdtemp()))            # tables, ProGraph engine, ProAct's log
cycle = world.runner.run(AllEligible(), demo.AS_OF)           # decide, record, request, act
print(len(cycle.run.packages), "decisions;", len(cycle.dispatched), "actions dispatched")
for row in world.ask(demo.HOLDS_Q):                           # SPARQL through ProGraph
    print(row["supplier"].rsplit("/", 1)[-1], row["name"], row["reason"])
```

The demo's contract, mapping, installation file and data generator are in [`proact/demo/supply_chain`](https://gitlab.com/briceg/proact/-/tree/main/proact/demo/supply_chain).

## Status

0.1.0 is the first release. ProAct is pre-1.0, and its API may change between minor versions. Known limits:

- Two runners that share one event log on a Delta warehouse can starve one another: one runner's commands keep losing the race to append.
- Dispatch on a SQL warehouse is slow, because each action is its own transaction.

## Where to go next

- [The guide](https://gitlab.com/briceg/proact/-/blob/main/docs/guide.md): the contract, evidence, deciding, acting, the record, and what is not built yet.
- [Supply chain](https://gitlab.com/briceg/proact/-/blob/main/examples/supply-chain/README.md): the lead demo's data and mapping.
- [Anti-money laundering](https://gitlab.com/briceg/proact/-/blob/main/examples/aml/README.md): the same core on a second domain, with a composite subject.
- [Turbofan](https://gitlab.com/briceg/proact/-/blob/main/examples/turbofan/README.md): a third, with a PSL program, SHACL shapes, OWL 2 RL entailment and an approval.
- [Changelog](https://gitlab.com/briceg/proact/-/blob/main/docs/changelog.md)

To work on ProAct from a clone: `pip install -e ".[dev]"`, then `python -m pytest tests examples`.
