billing ledger

This commit is contained in:
Dobromir Popov
2026-07-02 21:27:23 +02:00
parent 416ceba0f6
commit 57ec7c1e4b
6 changed files with 758 additions and 5 deletions

View File

@@ -724,12 +724,13 @@
"Unit tests: single-node route, 3-node split, exhausted balance, restart persistence"
],
"priority": 31,
"status": "open",
"status": "done",
"notes": "Pure off-chain — no Solana calls in this story. Reuses ComputeAttribution/work_units from packages/contracts.",
"dependsOn": [
"US-023",
"US-025"
]
],
"completionNotes": "BillingLedger in packages/tracker/meshnet_tracker/billing.py: event-sourced USDT ledger (credit/charge/payout/forfeit events, id-deduped), SQLite persistence, per-model price_per_1k_tokens (preset key or prices dict), 90/10 split by work units, walletless shares to protocol cut. server.py: 401/402 gate before routing, billing on non-streaming/streaming/relayed completion paths, GET /v1/billing/summary, POST /v1/billing/gossip, event push in _stats_loop (cursor advances only when all peers reached). CLI --billing-db. settle_node_payout/forfeit_pending are the US-033/034 hooks. 11 new tests in tests/test_billing_ledger.py; suite 195 passed (3 pre-existing ModuleNotFoundError: openai failures unrelated)."
},
{
"id": "US-032",