Python reference implementation of the Agent Acknowledgment Record (AAR)
Project description
aar-ref-lib-py
Python reference implementation of the Agent Acknowledgment Record
(AAR) — the append-only, hash-chained ledger that
stores and aggregates AAP acknowledgment events, with Merkle checkpoints and the
normative §9 default reputation algorithm.
Install
pip install aar-manifest
What's in the box
| Module | Spec | Purpose |
|---|---|---|
entries |
§3, §5, §8 | RecordEntry, Checkpoint, ReputationResult |
ledger |
§3, §4 | canonicalize, compute_entry_hash, compute_commitment, build_genesis, append_event, verify_chain |
checkpoint |
§5 | merkle_root, build_inclusion_proof, verify_inclusion_proof, build_checkpoint |
aggregation |
§9 | aggregate_reputation — the normative default algorithm |
store |
§3/§4/§8 | InMemoryLedger — accept, withdraw, query, verify, reputation |
Usage
from aar_manifest import InMemoryLedger
ledger = InMemoryLedger("did:tutus:0xagg")
ev = {
"id": "urn:uuid:…",
"type": "ENDORSEMENT",
"issued_at": "2026-05-20T14:32:00Z",
"issuer": {"did": "did:web:alice"},
"subject": {"did": "did:web:bob"},
}
ledger.accept(ev) # chained Record Entry; raises on duplicate id (§4.1.2)
valid, errors = ledger.verify(recompute_hashes=True)
rep = ledger.reputation("did:web:bob", settlement_verified=lambda e: False)
The wrapped event is a plain dict (snake_case keys, as on the wire) so the
package takes no hard dependency on aap-manifest.
The default aggregation (spec §9)
weight(a) = type_weight × issuer_trust × value_weight × witness_factor
× time_decay × (0 if withdrawn else 1) × settlement_factor
value_weight = 1 + log10(1 + usd)applies only when settlement is verified (§6.3).settlement_factor = 0.5when a value is claimed but unverified (T2/T10), else 1.- The issuer-diversity penalty (§9.5) scales the aggregate by
diversity / 0.3when Simpson diversity over distinct issuers/controllers is below 0.3. - Recursive issuer trust is bounded at depth 2 with an attestation fallback (§9.4); pass
issuer_trust=orattestation=to drive it.
aggregate_reputation returns the full ReputationResult (the AAR §8
ReputationSource shape ADP consumes).
Hash chaining & checkpoints
compute_entry_hash hashes the immutable content (everything except
entry_hash and the mutable status fields withdrawn / withdrawal_ref), so a
withdrawal can flip those fields without breaking chain continuity (§3.2, §4.2,
§7.4). build_checkpoint produces a signed, prev-chained Merkle commitment;
build_inclusion_proof / verify_inclusion_proof give single-entry inclusion
proofs (§5.4).
How It Composes
aap-manifest constructs and weights acknowledgment events
aar-manifest stores, chains, federates, and aggregates them (this library)
aar-validate audits a ledger's chain, sequencing, and replay
Test
pip install -e ".[dev]"
pytest
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aar_manifest-1.0.0.tar.gz.
File metadata
- Download URL: aar_manifest-1.0.0.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
570fbbfdded015a0e1dfadb1e3a11f9a91461b99b675813c4d31b33556c99602
|
|
| MD5 |
b3781ecbf41bd5b364300dd0909c0ada
|
|
| BLAKE2b-256 |
a1d87732b42c952d154b6ea4bb33301e4d2742f60c6858d641820e6578318fc7
|
File details
Details for the file aar_manifest-1.0.0-py3-none-any.whl.
File metadata
- Download URL: aar_manifest-1.0.0-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a284834d940ad98cbe8d895fa58c44b1557799178df9e0b96bc05087c2e4c2aa
|
|
| MD5 |
f914027d9dca320a0803a33213eb2b81
|
|
| BLAKE2b-256 |
43351dac712d89ffe7d568fa202ed98c77dde4cdff4f137f71ea04069330f0ed
|