Files
neuron-tai/.scratch/alpha-hardening/issues/05-a1-a5-persist-strike-ban-reputation_completed.md
2026-07-13 14:14:37 +02:00

41 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Status: done
# 05 — A1/A5: Persist strike, ban, and reputation state
## What to build
Registry strike/ban/reputation state today lives in RAM-only `_LocalContractState` — tracker restart wipes penalties. Persist to SQLite (same pattern as `BillingLedger` and `AccountStore`) so reputation carries forward per ADR-0016 §4.
**Code refs:**
- `packages/contracts/meshnet_contracts/__init__.py``RegistryContract`, `RegistryWallet`, in-memory `_state.registry` (~103206)
- `packages/tracker/meshnet_tracker/billing.py` — SQLite persistence pattern (~60, event log)
- `packages/tracker/meshnet_tracker/accounts.py` — SQLite + event replication (~4056)
Include fields for: `strike_count`, `banned`, `completed_job_count`, graduated **reputation score** (float, default 1.0), `last_audit_ts`, probation tracking.
**Scope split:** this issue owns **schema + persistence + load/reload** only. Reputation **scoring deltas** (audit pass/fail adjustments, decay rules) belong in issue 08.
## Test-first
1. Red: record strike, restart tracker process, strike count is 0 — must fail.
2. Green: persist + reload; gossip replicates strike events if multi-tracker.
3. Red: banned wallet registers node — must reject (wire to routing).
## Acceptance criteria
- [ ] Strike/ban/reputation survive tracker restart (SQLite or equivalent)
- [ ] `RegistryContract.list_wallets` reflects persisted state
- [ ] Banned wallet rejected at registration and excluded from routes
- [ ] Reputation score field present for routing/audit issues (0809)
- [ ] Event-sourced mutations compatible with future Raft (ADR-0019)
## ADR links
- [ADR-0016](../../docs/adr/0016-alpha-scope-and-known-limitations.md) §4
- [ADR-0018](../../docs/adr/0018-fraud-detection-verification-and-reputation.md) §6
## Blocked by
- `02-a2-unified-auth-boundary_completed.md`