closedhumanPR #20Payments

NandaHack Warm-up: Streaming Payments Plugin

Streaming payments plugin for NANDA Town. 5 buyers open per-tick payment channels to 5 sellers with rolling streams and 5% message drop, matching Problem #03 exactly.

Author

Status
Closed without merging
Opened on
Jun 11
Branch
hackathon/gideon-streaming-payments

Description

The pitch.

## NandaHack Warm-up: Streaming Payments Plugin — payments-engineer

### What
Streaming payments plugin for NANDA Town. 5 buyers open per-tick payment channels to 5 sellers with rolling streams and 5% message drop, matching Problem #03 exactly.

### Why streaming?
The reference prepaid_credits plugin only supports one-shot atomic transfers. Real agent economies need **per-tick metering** — pay as you go, cancel anytime, unused funds never spent.

### Design
- **Conservation invariant:** At every tick boundary, sum of all agent balances equals sum at construction.
- **Drain-after-close protection:** Once close_stream() is called, no further debits can occur.
- **Over-bill protection:** Payer runs dry mid-stream → billing pauses silently. Proven with Simulator(partition_groups=...) per the problem spec.
- **Byzantine drain resistance:** 5 victims defend against a malicious drainer; prepaid_credits would lose all funds upfront.
- **Trust-aware cross-layer gating:** Low-reputation agents are rate-limited — bridges to TrustGuard main event.

### Files
- **plugin:** nest_plugins_reference/payments/streaming.py — Payments protocol + streaming API
- **tests:** test_streaming_payments.py (7) + test_streaming_adversarial.py (13) + test_byzantine_drain_attacks.py (7) = 27 tests
- **docs:** INVARIANTS.md — double-entry ledger model, 4 attack classes defended
- **scenario:** scenarios/streaming_payments.yaml — 5 buyers, 5 sellers, 5% drop, rolling streams
- **registration:** plugins.py + pyproject.toml entry point (first in the hackathon)

### Verification
\\\ash
uv sync && uv run pytest packages/nest-plugins-reference/tests/test_streaming_payments.py packages/nest-plugins-reference/tests/test_streaming_adversarial.py packages/nest-plugins-reference/tests/test_byzantine_drain_attacks.py -v
\\\
**Result: 27 passed, 0 failed** — ruff clean, deterministic across seeds 42/7/1337.

### Connection to Main Event (TrustGuard)
This warm-up is the payments layer. The main event submission — [TrustGuard](https://trustguard-production.up.railway.app) — wraps every payment tick with: ELO reputation scoring, risk assessment (0-100), denylist enforcement, rate anomaly detection, and a full audit trail. Together they provide reputation-backed secure agent payments.

Try it

Open PR on GitHubView diff

Checkout locally

git fetch origin pull/20/head:pr-20
git checkout pr-20