reputation-types 0.1.0

Core types and data structures for the KnowThat Reputation Engine
Documentation
  • Coverage
  • 100%
    47 out of 47 items documented5 out of 9 items with examples
  • Size
  • Source code size: 51.1 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 891.13 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 25s Average build duration of successful builds.
  • all releases: 25s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • H0BB5

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.