# Reputation Types
[](https://crates.io/crates/reputation-types)
[](https://docs.rs/reputation-types)
[](https://github.com/knowthat-ai/reputation-engine)
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`:
```toml
[dependencies]
reputation-types = "0.1.0"
```
### Basic Example
```rust
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
```rust
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
```rust
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:
- Apache License, Version 2.0 ([LICENSE-APACHE](../../LICENSE-APACHE))
- MIT License ([LICENSE-MIT](../../LICENSE-MIT))
at your option.
## Contributing
This is part of the [KnowThat Reputation Engine](https://github.com/knowthat-ai/reputation-engine) project. Please see the main repository for contribution guidelines.