Metadata-Version: 2.4
Name: aap-manifest
Version: 1.0.0
Summary: Python reference implementation of the Agent Acknowledgment Protocol (AAP)
Author-email: "David H. Friedel Jr." <dev@ai-manifests.org>
Maintainer-email: MarketAlly Pte Ltd <dev@ai-manifests.org>
License-Expression: Apache-2.0
Project-URL: Homepage, https://aap-manifest.dev
Project-URL: Repository, https://github.com/ai-manifests/aap-ref-lib-py
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
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 :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Dynamic: license-file

# aap-ref-lib-py

[![PyPI](https://img.shields.io/pypi/v/aap-manifest.svg)](https://pypi.org/project/aap-manifest/)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
[![Spec](https://img.shields.io/badge/spec-aap--manifest.dev-informational)](https://aap-manifest.dev)

Python reference implementation of the [Agent Acknowledgment Protocol
(AAP)](https://aap-manifest.dev) — typed acknowledgment events, the §7.2
reference weighting function, and a simple reputation derivation.

## Install

```bash
pip install aap-manifest
```

## What's in the box

| Module | Spec | Purpose |
|--------|------|---------|
| `entries` | §3, §4 | `AcknowledgmentEvent` and its parts; the `AckType` vocabulary |
| `weighting` | §7.2 | `compute_weight`, `type_weight`, `DEFAULT_TYPE_WEIGHTS` |
| `reputation` | §7.1 | `compute_reputation` — derive a subject's score from events |
| `store` | §9.3 / §9.4 | `InMemoryAcknowledgmentStore` — dup-id rejection, withdrawal handling |

## Usage

```python
from aap_manifest import (
    AcknowledgmentEvent, Issuer, Subject,
    compute_weight, InMemoryAcknowledgmentStore,
)

ev = AcknowledgmentEvent(
    id="urn:uuid:5f8a3c2e-…",
    type="ENDORSEMENT",
    issuer=Issuer(did="did:tutus:0xacme", key_id="did:tutus:0xacme#k"),
    subject=Subject(did="did:web:example.com:agents:code-reviewer"),
    signature=Signature(alg="EdDSA", value="…"),
    issued_at="2026-05-20T14:32:00Z",
)

result = compute_weight(ev, issuer_trust=0.8)   # value_weight applies only when verified

store = InMemoryAcknowledgmentStore()
store.append(ev)                                 # raises on duplicate id (§9.3)
rep = store.reputation("did:web:example.com:agents:code-reviewer")
```

## Reference weight (spec §7.2)

```
weight = type_weight × issuer_trust × value_weight × witness_factor × time_decay
```

- `value_weight = 1 + log10(1 + usd_equivalent)` applies **only when the
  settlement reference is verified** (§6.3); otherwise 1.
- `witness_factor = 1 + 0.25 × min(independent_witnesses, 4)`.
- `time_decay = exp(−Δt/τ)`, τ = 18 months; omit `now` for no decay.
- A `WITHDRAWAL` zeroes the weight (positive-only vocabulary, §9.1).

This is the **informative** AAP reference. The **normative** aggregation —
issuer-diversity penalty, recursive-trust bound, mandatory settlement
verification — lives in AAR §9 and ships in the `aar-manifest` package.

## How It Composes

```
aap-manifest   constructs and weights acknowledgment events  (this library)
aar-manifest   stores, chains, federates, and aggregates them
aap-validate   validates events against the schema + anti-abuse rules
```

## Test

```bash
pip install -e ".[dev]"
pytest
```

## License

Apache-2.0 — see [`LICENSE`](LICENSE) and [`NOTICE`](NOTICE).
