Skip to main content

TATF reference implementation — local agent trust scoring

Project description

truce

TATF reference implementation — local agent trust scoring.

License Spec Tests

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tatf-0.1.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tatf-0.1.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file tatf-0.1.0.tar.gz.

File metadata

  • Download URL: tatf-0.1.0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for tatf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 410eb1e2161f520494e8aeba4975e50f30386f7360f90c8b52288653cf6b84b3
MD5 0e523fafd19a2764519344008c900c64
BLAKE2b-256 38b0041ac2551ea965a852b7463ab947f679b0c690d7900d958bb38640421806

See more details on using hashes here.

File details

Details for the file tatf-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tatf-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for tatf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bfa3b699fab37847cdbe94029b12b4a3ea74eea4450deb8345a2ac632604bc3a
MD5 9d0d621e2db19beff7ec93ff651043ed
BLAKE2b-256 d41b98cf8cc2059c60682d7f8cc448fcefbaa73c6e6eb780ce135a974bca5d21

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page