rotalabs-graph
GNN-based trust propagation for AI systems.
Features
- Trust Graph Data Structure: Model trust relationships between AI components
- Multiple Propagation Algorithms: PageRank, EigenTrust, weighted propagation, and GNN-based
- Anomaly Detection: Detect circular trust, trust islands, and suspicious patterns
- Path Analysis: Find trust paths and bottlenecks between nodes
- Cluster Analysis: Identify trust communities using Louvain, label propagation, etc.
- Temporal Trust: Trust decay over time with history tracking
- Graph Metrics: Comprehensive metrics for trust health analysis
Installation
pip install rotalabs-graph
With GNN support (requires PyTorch):
pip install rotalabs-graph[gnn]
With visualization:
pip install rotalabs-graph[viz]
Quick Start
Create a Trust Graph
from datetime import datetime
from rotalabs_graph import TrustGraph, TrustNode, TrustEdge, NodeType, EdgeType
# Create graph
graph = TrustGraph()
# Add nodes
now = datetime.now()
graph.add_node(TrustNode(
id="user-1",
name="User",
node_type=NodeType.USER,
base_trust=1.0,
created_at=now,
updated_at=now,
))
graph.add_node(TrustNode(
id="model-gpt4",
name="GPT-4",
node_type=NodeType.MODEL,
base_trust=0.95,
created_at=now,
updated_at=now,
))
# Add trust edge
graph.add_edge(TrustEdge(
source_id="user-1",
target_id="model-gpt4",
edge_type=EdgeType.TRUSTS,
weight=0.9,
created_at=now,
))
print(f"Graph: {graph.num_nodes} nodes, {graph.num_edges} edges")
Detect Anomalies
from rotalabs_graph import AnomalyDetector
detector = AnomalyDetector()
anomalies = detector.detect_all(graph)
for anomaly in anomalies:
print(f"{anomaly.anomaly_type}: {anomaly.description}")
Find Trust Paths
from rotalabs_graph import PathAnalyzer
analyzer = PathAnalyzer()
paths = analyzer.find_all_paths(graph, "user-1", "model-gpt4")
for path in paths:
print(f"Path: {' -> '.join(path.node_ids)}, trust: {path.path_trust:.3f}")
Temporal Trust with Decay
from rotalabs_graph import TemporalTrustGraph, DecayFunction
# Create temporal graph with exponential decay
graph = TemporalTrustGraph(
decay_function=DecayFunction.EXPONENTIAL,
half_life_days=30.0,
track_history=True,
)
# Add node
graph.add_node("agent-1", initial_trust=0.9)
# Get current trust (with decay applied)
current = graph.get_current_trust("agent-1")
Node Types
| Type | Description |
|---|---|
MODEL |
AI/ML models |
AGENT |
AI agents |
USER |
Human users |
DATA_SOURCE |
Data sources |
TOOL |
Tools and APIs |
SERVICE |
External services |
Edge Types
| Type | Description |
|---|---|
TRUSTS |
General trust relationship |
DELEGATES |
Delegates authority to |
VERIFIES |
Verifies outputs of |
VALIDATES |
Validates results from |
DEPENDS_ON |
Depends on for operation |
CALLS |
Calls/invokes |
OWNS |
Owns/controls |
Propagation Algorithms
| Algorithm | Description |
|---|---|
PageRankPropagator |
Trust as voting, with damping |
EigenTrustPropagator |
Stationary distribution (Kamvar et al., 2003) |
WeightedPropagator |
BFS with decay per hop |
GNNPropagator |
Learned propagation with GCN/GAT/SAGE |
Anomaly Types
| Type | Description |
|---|---|
CIRCULAR_TRUST |
A trusts B trusts A |
TRUST_ISLAND |
Disconnected component |
SUSPICIOUS_CONCENTRATION |
Too many edges to one node |
TRUST_CLIFF |
Sudden trust drop in path |
ORPHAN_NODE |
Node with no connections |
API Reference
Core Types
TrustGraph- Main graph data structureTrustNode- Node representing an entityTrustEdge- Directed trust relationshipTrustScore- Computed trust valueNodeType,EdgeType- Type enumerations
Propagation
PageRankPropagator- PageRank-based trustEigenTrustPropagator- EigenTrust algorithmWeightedPropagator- Weighted path propagationGNNPropagator- GNN-based (requires torch-geometric)
Analysis
AnomalyDetector- Detect trust anomaliesPathAnalyzer- Analyze trust pathsClusterAnalyzer- Community detectionMetricsCalculator- Graph-level metrics
Temporal
TemporalTrustGraph- Trust with decayTrustHistory- Track trust changesDecayFunction- Decay function types
Links
- Documentation: https://rotalabs.github.io/rotalabs-graph/
- PyPI: https://pypi.org/project/rotalabs-graph/
- GitHub: https://github.com/rotalabs/rotalabs-graph
- Website: https://rotalabs.ai
- Contact: research@rotalabs.ai
License
Apache-2.0 License - see LICENSE for details.
Metadata
Release files for rotalabs-graph 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rotalabs_graph-1.1.0.tar.gz | 77.1 kB | Without provenance | Details for rotalabs_graph-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rotalabs_graph-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for rotalabs_graph-1.1.0-py3-none-any.whl |
Total release size: 167.4 kB
Release files / rotalabs_graph-1.1.0.tar.gz
| Download URL | rotalabs_graph-1.1.0.tar.gz |
|---|---|
| Size | 77.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc08d7ff4b3c2b6beda941763ce44bb86699f3714f76458b016444a63d7f59ac
|
|
BLAKE2b-256 checksum How to use checksums |
ec69e7467a187868dbf54229ee24147871bf87fbf637524f98eb50d86a75ee0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.6
|
Release files / rotalabs_graph-1.1.0-py3-none-any.whl
| Download URL | rotalabs_graph-1.1.0-py3-none-any.whl |
|---|---|
| Size | 90.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
12b8bbf9804046814ff8bb7fd5144d48188e03aa01a856a531efe8d7b31d77a3
|
|
BLAKE2b-256 checksum How to use checksums |
c51e6a207a12ffe7dce5eb74be2f6e6c23a9e0b8f6744609566a7f20e6176b42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.6
|
Security for rotalabs-graph 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.