kaccy-reputation
Comprehensive reputation system for the Kaccy Protocol, providing on-chain and off-chain reputation tracking, AI-assisted scoring, dispute resolution, and cross-platform portability.
Features
Phase 0 (MVP) - Core Reputation
Reputation Scoring
- Score Components: Multi-dimensional scoring (commitment fulfillment, response time, quality rating, community trust, longevity)
- Weighted Calculation: Configurable weights for each component
- Score Bounds: 0-1000 range with delta validation (max ±50 positive, ±100 negative per update)
- Event-Based: All score changes tracked as events for auditability
Tier System
- 6 Tiers: Unverified, Bronze, Silver, Gold, Platinum, Diamond
- Tier Benefits: Dynamic benefits based on tier (fee discounts, token issuance limits, priority support)
- Tier History: Complete tracking of tier changes with timestamps
Commitment Tracking
- Commitment Lifecycle: Pending → Completed → Verified/Failed
- Evidence Submission: Users submit evidence, admins verify
- Expiration Handling: Auto-expire overdue commitments
Circuit Breaker
- Low Reputation Protection: Auto-disable features when score < 200
- Automatic Recovery: Restore privileges when score improves
- Admin Notifications: Alert admins on circuit breaker triggers
Phase 1 (Post-MVP) - Advanced Features
Advanced Scoring
- Component Confidence: Track confidence levels (VeryLow to VeryHigh) based on data availability
- Time Decay: Recent events weighted more heavily, inactivity decay after 90 days
- Score History: Daily snapshots with trend analysis
- Percentile Ranking: Compare users across the platform
Commitment Enhancements
- Milestone Commitments: Break large commitments into trackable milestones
- Recurring Commitments: Auto-generate periodic deliverables (weekly, monthly, quarterly)
- Commitment Templates: 15+ pre-defined templates for common commitment types
Holder Ratings
- Token Holder Ratings: 1-5 star rating system weighted by holdings
- Community Trust: Aggregate holder ratings into reputation score
- Minimum Requirements: Balance and duration requirements for rating eligibility
Event System
- Comprehensive Event Types: commitment_fulfilled, commitment_failed, holder_rating, quality_score, admin_adjustment, time_decay, circuit_breaker
- Event Replay: Recalculate scores from event history
- Notifications: Multi-severity notifications (Info, Warning, Critical)
Phase 2 - Future-Ready Features
Soulbound Tokens (SBT)
- On-Chain Reputation: Mint non-transferable reputation tokens
- Dynamic Metadata: Auto-update metadata with score changes
- Cross-Platform: Use reputation on other platforms via metadata URI
- Blockchain Integration:
OnChainSBTtrait for multiple blockchain support
use ;
let sbt_service = new;
let request = MintSBTRequest ;
let sbt = sbt_service.create_sbt.await?;
AI-Assisted Scoring
- Quality Evaluation: Automatic assessment of deliverable quality with aspect-based scoring
- Fraud Detection: Detect sybil attacks, score farming, vote manipulation
- Success Prediction: Predict commitment success probability using historical data
use ;
let ai_service = new;
let evaluation = ai_service.evaluate_quality.await?;
println!;
Dispute Resolution
- DAO Voting: Token-weighted voting on disputed commitments
- Quorum Requirements: Configurable voting thresholds
- Appeals Process: Time-limited appeals with admin review
use ;
let dispute_service = new;
let dispute = dispute_service.create_dispute.await?;
let vote = dispute_service.vote.await?;
let results = dispute_service.calculate_results.await?;
Reputation Portability
- Import: GitHub, LinkedIn, Stack Overflow, Twitter, Discord
- Score Calculation: Platform-specific algorithms for fair conversion
- Export: W3C Verifiable Credentials with cryptographic proofs
- Interoperability: Use Kaccy reputation on other platforms
use ;
let portability = new;
let result = portability.import_reputation.await?;
let credential = portability.export_reputation.await?;
Integration
The ReputationOrchestrator provides high-level workflows coordinating all features:
use ReputationOrchestrator;
let orchestrator = new;
// Complete workflow: First token → SBT minting
orchestrator.on_first_token_issuance.await?;
// Complete workflow: Commitment → AI eval → Score update → SBT update
let quality_score = orchestrator.evaluate_and_score_commitment.await?;
// Complete profile with all features
let profile = orchestrator.get_complete_profile.await?;
println!;
Score Components
| Component | Weight | Description |
|---|---|---|
| Commitment Fulfillment | 35% | Percentage of commitments successfully completed |
| Response Time | 15% | How quickly issuer responds to holders |
| Quality Rating | 30% | Average quality score of delivered outputs |
| Community Trust | 15% | Ratings from token holders |
| Longevity | 5% | Account age and activity consistency |
Tier System
| Tier | Score Range | Benefits |
|---|---|---|
| Diamond | 900-1000 | 5 tokens, 50% fee discount, verified badge |
| Platinum | 800-899 | 3 tokens, 30% fee discount, verified badge |
| Gold | 600-799 | 2 tokens, 15% fee discount, verified badge |
| Silver | 400-599 | 1 token, 5% fee discount |
| Bronze | 200-399 | 1 token, no fee discount, cannot issue |
| Unverified | 0-199 | Cannot issue tokens (circuit breaker) |
Architecture
Modules
kaccy-reputation/
├── src/
│ ├── lib.rs # Crate root, re-exports
│ ├── score.rs # Core scoring engine
│ ├── tier.rs # Tier definitions & benefits
│ ├── commitment.rs # Commitment tracking
│ ├── circuit_breaker.rs # Low reputation protection
│ ├── confidence.rs # Component confidence tracking
│ ├── time_decay.rs # Time-based score decay
│ ├── score_history.rs # Historical snapshots
│ ├── history.rs # Tier change history
│ ├── milestone.rs # Milestone commitments
│ ├── recurring.rs # Recurring commitments
│ ├── templates.rs # Commitment templates
│ ├── holder_ratings.rs # Token holder ratings
│ ├── events.rs # Event sourcing & notifications
│ ├── sbt.rs # Soulbound tokens
│ ├── ai_scoring.rs # AI evaluations & fraud detection
│ ├── dispute.rs # Dispute resolution & appeals
│ ├── portability.rs # Import/export reputation
│ ├── integration.rs # High-level orchestration
│ └── error.rs # Error types
└── Cargo.toml
Database Schema
See ../kaccy-db/migrations/ for complete schema:
001_initial_schema.sql- Core tables002_score_snapshots.sql- Score history003_recurring_and_templates.sql- Commitment enhancements004_component_confidence.sql- Confidence tracking005_audit_logs.sql- Audit trails006_phase2_tables.sql- SBT, AI, disputes, portability
Usage Examples
Basic Reputation Tracking
use ;
use dec;
let engine = new;
// Get current score
let score = engine.get_score.await?;
println!;
// Update score with event
let new_score = engine.update_score_with_event.await?;
Commitment Management
use ;
// Milestone commitment
let milestone_svc = new;
let commitment = milestone_svc.create_commitment.await?;
milestone_svc.complete_milestone.await?;
// Recurring commitment
let recurring_svc = new;
let recurring = recurring_svc.create.await?;
recurring_svc.generate_all_due.await?;
Holder Ratings
use ;
let rating_svc = new;
let rating = rating_svc.create_rating.await?;
let stats = rating_svc.get_stats.await?;
Error Handling
All operations return Result<T, ReputationError>:
match engine.get_score.await
Testing
# Run all tests
# Run with output
Dependencies
rust_decimal- Precise score calculationssqlx- Database querieschrono- Deadline handlingserde/serde_json- Serializationuuid- Unique identifierstokio- Async runtimeasync-trait- Async traitsthiserror- Error definitions
License
See LICENSE file in repository root.