truce
TATF reference implementation — local agent trust scoring.
Score autonomous agents locally using the TRUCE Agent Trust Framework (TATF) — no server required.
Install
pip install truce
# With Ed25519 attestation signing:
pip install truce[crypto]
Quick Start
from truce import TATFScorer, Transaction
from datetime import datetime, timezone
scorer = TATFScorer()
# Ingest transaction history
transactions = [
Transaction(
timestamp=datetime(2026, 1, i, 10, 0, tzinfo=timezone.utc),
price=1000.0,
category="electronics",
counterparty_id=f"cp-{i % 10:03d}",
)
for i in range(1, 31) # 30 days of history
]
scorer.ingest("agent-123", transactions)
# Score the agent
result = scorer.score("agent-123", market_stability=0.8)
print(result.score) # 0.7925
print(result.routing) # AUTO_PASS
print(result.confidence) # (0.6795, 0.9055)
print(result.tier) # HIGH
print(result.cold_start) # False
Anomaly Detection
Score a new transaction against the agent's behavioral baseline:
from truce import RoutingDecision
# Normal transaction
normal = scorer.compute_anomaly(
"agent-123",
transaction=Transaction(
timestamp=datetime(2026, 2, 1, 11, 0, tzinfo=timezone.utc),
price=1050.0,
category="electronics",
counterparty_id="cp-001",
),
)
assert normal.routing == RoutingDecision.AUTO_PASS
# Suspicious transaction (3 AM, new category, extreme price)
suspicious = scorer.compute_anomaly(
"agent-123",
transaction=Transaction(
timestamp=datetime(2026, 2, 1, 3, 0, tzinfo=timezone.utc),
price=50000.0,
category="agriculture",
counterparty_id="cp-999",
concurrent_sessions=10,
),
)
print(suspicious.routing) # SOFT_HOLD or HARD_BLOCK
print(suspicious.composite) # Anomaly score (0-200)
print(suspicious.dimensions) # Per-dimension breakdown
Market Stress (AVX)
from truce import AVXCalculator, AVXEvent
avx = AVXCalculator(k_anonymity_min=5)
# Ingest market events from multiple firms
events = [
AVXEvent(firm_id=f"FIRM-{i}", price=100 + i, quantity=50)
for i in range(10)
]
avx.ingest("electronics", events)
result = avx.compute("electronics")
if result: # None if k-anonymity not satisfied
print(result.avx_score) # 0-100 stress level
print(result.dimensions.pd_score) # Panic Diversification
print(result.dimensions.pv_score) # Price Volatility
Trust Attestations
from truce import TATFAttestor
attestor = TATFAttestor(issuer_id="my-scorer")
alpha = scorer.score("agent-123")
anomaly = scorer.compute_anomaly("agent-123")
attestation = attestor.attest(alpha, anomaly)
# Returns a signed TATF Native attestation (spec §04)
# Verify
assert attestor.verify(attestation) # requires truce[crypto]
Six Scoring Dimensions
TATF scores agents across six behavioral dimensions:
| # | Dimension | Cap | Signal |
|---|---|---|---|
| 1 | Time anomaly | 35 | Operating outside normal hours |
| 2 | Concurrent sessions | 45 | Abnormal parallel activity |
| 3 | Price deviation | 40 | Unusual pricing behavior |
| 4 | Category anomaly | 30 | New product category |
| 5 | Negotiation rounds | 25 | Excessive bargaining |
| 6 | Counterparty concentration | 25 | Sudden relationship shift |
Composite range: 0-200. Routing: AUTO_PASS (<50), SOFT_HOLD (50-119), HARD_BLOCK (>=120).
No single dimension can trigger HARD_BLOCK alone.
Specification
This library implements TATF v0.1:
- Protocol-agnostic (works with A2A, ACP, MCP, or any agent protocol)
- Relative scoring (agents scored against their OWN baseline)
- Privacy-preserving (k-anonymity on aggregate metrics)
- Incrementally adoptable (implement layers independently)
License
Apache 2.0
Metadata
Release files for tatf 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tatf-0.1.0.tar.gz | 18.5 kB | Without provenance | Details for tatf-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tatf-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for tatf-0.1.0-py3-none-any.whl |
Total release size: 35.4 kB
Release files / tatf-0.1.0.tar.gz
| Download URL | tatf-0.1.0.tar.gz |
|---|---|
| Size | 18.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
410eb1e2161f520494e8aeba4975e50f30386f7360f90c8b52288653cf6b84b3
|
|
BLAKE2b-256 checksum How to use checksums |
38b0041ac2551ea965a852b7463ab947f679b0c690d7900d958bb38640421806
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / tatf-0.1.0-py3-none-any.whl
| Download URL | tatf-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bfa3b699fab37847cdbe94029b12b4a3ea74eea4450deb8345a2ac632604bc3a
|
|
BLAKE2b-256 checksum How to use checksums |
d41b98cf8cc2059c60682d7f8cc448fcefbaa73c6e6eb780ce135a974bca5d21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for tatf 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.