| Crates.io | kaccy-reputation |
| lib.rs | kaccy-reputation |
| version | 0.1.0 |
| created_at | 2026-01-18 22:38:43.978444+00 |
| updated_at | 2026-01-18 22:38:43.978444+00 |
| description | Reputation and scoring system for Kaccy Protocol - trust, fraud detection, and tier management |
| homepage | https://github.com/cool-japan/kaccy |
| repository | https://github.com/cool-japan/kaccy |
| max_upload_size | |
| id | 2053252 |
| size | 823,719 |
Comprehensive reputation system for the Kaccy Protocol, providing on-chain and off-chain reputation tracking, AI-assisted scoring, dispute resolution, and cross-platform portability.
OnChainSBT trait for multiple blockchain supportuse kaccy_reputation::{SBTService, MintSBTRequest};
let sbt_service = SBTService::new(pool);
let request = MintSBTRequest {
user_id,
initial_score: 750,
initial_tier: ReputationTier::Gold,
};
let sbt = sbt_service.create_sbt(request).await?;
use kaccy_reputation::{AIScoringService, EvaluateQualityRequest};
let ai_service = AIScoringService::new(pool);
let evaluation = ai_service.evaluate_quality(request).await?;
println!("Quality score: {}", evaluation.quality_score);
use kaccy_reputation::{DisputeService, CreateDisputeRequest, VoteDisputeRequest};
let dispute_service = DisputeService::new(pool);
let dispute = dispute_service.create_dispute(request).await?;
let vote = dispute_service.vote(vote_request).await?;
let results = dispute_service.calculate_results(dispute.id).await?;
use kaccy_reputation::{PortabilityService, ImportReputationRequest, Platform};
let portability = PortabilityService::new(pool);
let result = portability.import_reputation(ImportReputationRequest {
user_id,
platform: Platform::GitHub,
platform_user_id: "username".to_string(),
access_token: Some(token),
}).await?;
let credential = portability.export_reputation(ExportReputationRequest {
user_id,
include_proof: true,
expiration_days: Some(365),
}).await?;
The ReputationOrchestrator provides high-level workflows coordinating all features:
use kaccy_reputation::ReputationOrchestrator;
let orchestrator = ReputationOrchestrator::new(pool);
// Complete workflow: First token → SBT minting
orchestrator.on_first_token_issuance(user_id).await?;
// Complete workflow: Commitment → AI eval → Score update → SBT update
let quality_score = orchestrator.evaluate_and_score_commitment(
commitment_id,
user_id,
evidence_url,
evidence_description,
commitment_description,
).await?;
// Complete profile with all features
let profile = orchestrator.get_complete_profile(user_id).await?;
println!("Score: {}, Tier: {:?}, Clean: {}",
profile.score, profile.tier, profile.clean_record);
| 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 | 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) |
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
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, portabilityuse kaccy_reputation::{ReputationEngine, ReputationEventType};
use rust_decimal_macros::dec;
let engine = ReputationEngine::new(pool);
// Get current score
let score = engine.get_score(user_id).await?;
println!("Score: {}, Tier: {:?}", score.overall_score, score.tier);
// Update score with event
let new_score = engine.update_score_with_event(
user_id,
dec!(25),
ReputationEventType::CommitmentFulfilled,
Some("Delivered on time"),
).await?;
use kaccy_reputation::{MilestoneService, RecurringCommitmentService};
// Milestone commitment
let milestone_svc = MilestoneService::new(pool);
let commitment = milestone_svc.create_commitment(request).await?;
milestone_svc.complete_milestone(commitment.id, 0).await?;
// Recurring commitment
let recurring_svc = RecurringCommitmentService::new(pool);
let recurring = recurring_svc.create(request).await?;
recurring_svc.generate_all_due().await?;
use kaccy_reputation::{HolderRatingService, RatingRequest};
let rating_svc = HolderRatingService::new(pool);
let rating = rating_svc.create_rating(RatingRequest {
token_id,
holder_id,
issuer_id,
rating: 4,
comment: Some("Great project!".to_string()),
}).await?;
let stats = rating_svc.get_stats(issuer_id).await?;
All operations return Result<T, ReputationError>:
match engine.get_score(user_id).await {
Ok(score) => println!("Score: {}", score.overall_score),
Err(ReputationError::UserNotFound(id)) => println!("User {} not found", id),
Err(e) => println!("Error: {:?}", e),
}
# Run all tests
cargo test -p kaccy-reputation
# Run with output
cargo test -p kaccy-reputation -- --nocapture
rust_decimal - Precise score calculationssqlx - Database querieschrono - Deadline handlingserde / serde_json - Serializationuuid - Unique identifierstokio - Async runtimeasync-trait - Async traitsthiserror - Error definitionsSee LICENSE file in repository root.