reputation-types

Crates.ioreputation-types
lib.rsreputation-types
version0.1.0
created_at2025-07-15 19:56:43.772971+00
updated_at2025-07-15 19:56:43.772971+00
descriptionCore types and data structures for the KnowThat Reputation Engine
homepagehttps://github.com/Know-That-Ai/reputation-engine
repositoryhttps://github.com/Know-That-Ai/reputation-engine
max_upload_size
id1753885
size51,102
Dylan Hobbs (H0BB5)

documentation

https://docs.rs/reputation-types

README

Reputation Types

Crates.io Documentation License

Core data types and structures for the KnowThat Reputation Engine.

Overview

This crate provides the fundamental data structures used throughout the KnowThat reputation system, including agent data, reputation scores, and builders for constructing agent instances. It serves as the foundation for all reputation calculations and interactions.

Key Features

  • Type Safety: Strong type system with builder pattern for safe construction
  • Serialization: Full serde support for JSON serialization/deserialization
  • Validation: Built-in validation for all data structures
  • Documentation: Comprehensive documentation with examples
  • No Unsafe Code: #![forbid(unsafe_code)] for memory safety guarantees

Key Types

AgentData

Represents an MCP agent with all reputation-relevant data including:

  • Identity information (DID, verification status)
  • Interaction history (total interactions, reviews)
  • MCP level and capabilities
  • Timestamps for tracking

ReputationScore

The calculated reputation score containing:

  • Numerical score value
  • Confidence level and percentage
  • Calculation metadata

AgentDataBuilder

Fluent builder for constructing AgentData instances with validation.

Usage

Add this to your Cargo.toml:

[dependencies]
reputation-types = "0.1.0"

Basic Example

use reputation_types::{AgentData, AgentDataBuilder, ReputationScore};

// Create agent data using the builder
let agent = AgentDataBuilder::new("did:example:123")
    .total_interactions(150)
    .with_reviews(100, 4.5)
    .mcp_level(2)
    .identity_verified(true)
    .build()
    .unwrap();

println!("Agent: {}", agent.agent_id);
println!("Reviews: {} (avg: {})", agent.review_count, agent.average_rating);

Builder Pattern

use reputation_types::AgentData;

let agent = AgentData::builder("did:example:456")
    .total_interactions(60)
    .with_reviews(50, 3.8)
    .mcp_level(1)
    .identity_verified(false)
    .build()
    .unwrap();

Working with Reputation Scores

use reputation_types::ReputationScore;

let score = ReputationScore {
    score: 0.85,
    confidence: 0.92,
    // ... other fields
};

println!("Score: {:.2} ({}% confident)", score.score, (score.confidence * 100.0) as u8);

Features

Default Features

  • serde - Serialization support

Optional Features

  • wasm - WebAssembly compatibility (enables chrono/wasmbind)

License

Licensed under either of:

at your option.

Contributing

This is part of the KnowThat Reputation Engine project. Please see the main repository for contribution guidelines.

Commit count: 0

cargo fmt