Documentation
¶
Overview ¶
Package trust provides trust relationship management and vouching services for actor reputation systems.
Package trust provides trust network types and configuration for federated trust systems.
Index ¶
- Constants
- type Service
- func (s *Service) CreateTrustRelationship(ctx context.Context, relationship *TrustRelationship) error
- func (s *Service) DeleteTrustRelationship(ctx context.Context, trusterID, trusteeID string, category TrustCategory) error
- func (s *Service) GetTrustRelationships(ctx context.Context, trusterID string, limit int, cursor string) ([]*TrustRelationship, string, error)
- func (s *Service) GetTrustScore(ctx context.Context, fromActor, toActor string) (*TrustScore, error)
- func (s *Service) GetTrustSummary(ctx context.Context, actorID string) (*TrustSummary, error)
- func (s *Service) GetTrustedByRelationships(ctx context.Context, trusteeID string, limit int, cursor string) ([]*TrustRelationship, string, error)
- func (s *Service) GetUserTrustScore(ctx context.Context, userID string) (float64, error)
- func (s *Service) RecordTrustUpdate(ctx context.Context, update *TrustUpdate) error
- func (s *Service) UpdateTrustRelationship(ctx context.Context, relationship *TrustRelationship) error
- type TrustCategory
- type TrustEdge
- type TrustEvidence
- type TrustNetwork
- type TrustPropagationConfig
- type TrustRelationship
- type TrustRepositoryInterface
- type TrustScore
- type TrustSummary
- type TrustUpdate
Constants ¶
const ( TrustCategoryContent = storage.TrustCategoryContent TrustCategoryBehavior = storage.TrustCategoryBehavior TrustCategoryTechnical = storage.TrustCategoryTechnical TrustCategoryGeneral = storage.TrustCategoryGeneral )
Re-export constants from storage
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides methods for managing trust relationships
func NewService ¶
func NewService(repo TrustRepositoryInterface, logger *zap.Logger) *Service
NewService creates a new trust service
func (*Service) CreateTrustRelationship ¶
func (s *Service) CreateTrustRelationship(ctx context.Context, relationship *TrustRelationship) error
CreateTrustRelationship creates a new trust relationship
func (*Service) DeleteTrustRelationship ¶
func (s *Service) DeleteTrustRelationship(ctx context.Context, trusterID, trusteeID string, category TrustCategory) error
DeleteTrustRelationship removes a trust relationship
func (*Service) GetTrustRelationships ¶
func (s *Service) GetTrustRelationships(ctx context.Context, trusterID string, limit int, cursor string) ([]*TrustRelationship, string, error)
GetTrustRelationships retrieves trust relationships for a truster
func (*Service) GetTrustScore ¶
func (s *Service) GetTrustScore(ctx context.Context, fromActor, toActor string) (*TrustScore, error)
GetTrustScore retrieves the trust score between two actors
func (*Service) GetTrustSummary ¶
GetTrustSummary provides a summary view of an actor's trust status
func (*Service) GetTrustedByRelationships ¶
func (s *Service) GetTrustedByRelationships(ctx context.Context, trusteeID string, limit int, cursor string) ([]*TrustRelationship, string, error)
GetTrustedByRelationships retrieves relationships where the actor is trusted
func (*Service) GetUserTrustScore ¶
GetUserTrustScore retrieves the general trust score for a user
func (*Service) RecordTrustUpdate ¶
func (s *Service) RecordTrustUpdate(ctx context.Context, update *TrustUpdate) error
RecordTrustUpdate records a trust score update event
func (*Service) UpdateTrustRelationship ¶
func (s *Service) UpdateTrustRelationship(ctx context.Context, relationship *TrustRelationship) error
UpdateTrustRelationship updates an existing trust relationship
type TrustCategory ¶
type TrustCategory = storage.TrustCategory
TrustCategory and other type aliases to storage types - this breaks the import cycle
type TrustEdge ¶
type TrustEdge struct {
From string `json:"from"`
To string `json:"to"`
Category TrustCategory `json:"category"`
Score float64 `json:"score"`
Confidence float64 `json:"confidence"`
Weight float64 `json:"weight"` // Combined score * confidence
}
TrustEdge represents a single edge in the trust graph (for visualization)
type TrustEvidence ¶
type TrustEvidence = storage.TrustEvidence
TrustCategory and other type aliases to storage types - this breaks the import cycle
type TrustNetwork ¶
type TrustNetwork struct {
RootActorID string `json:"root_actor_id"`
Relationships []TrustRelationship `json:"relationships"`
Scores map[string]*TrustScore `json:"scores"`
Depth int `json:"depth"` // How many hops to include
MinScore float64 `json:"min_score"` // Minimum score to include
Generated time.Time `json:"generated"`
}
TrustNetwork represents a view of the trust network for analysis
type TrustPropagationConfig ¶
type TrustPropagationConfig struct {
MaxDepth int `json:"max_depth"` // Maximum hops for propagation
DecayFactor float64 `json:"decay_factor"` // How much trust decays per hop (0.0-1.0)
NegativeMultiplier float64 `json:"negative_multiplier"` // Weight for negative trust signals
MinPropagatedScore float64 `json:"min_propagated_score"` // Minimum score to propagate
CacheDuration int `json:"cache_duration_hours"` // How long to cache scores
}
TrustPropagationConfig configures how trust propagates through the network
func DefaultPropagationConfig ¶
func DefaultPropagationConfig() *TrustPropagationConfig
DefaultPropagationConfig returns the default trust propagation configuration
type TrustRelationship ¶
type TrustRelationship = storage.TrustRelationship
TrustCategory and other type aliases to storage types - this breaks the import cycle
type TrustRepositoryInterface ¶
type TrustRepositoryInterface interface {
CreateTrustRelationship(ctx context.Context, relationship *storage.TrustRelationship) error
GetTrustRelationship(ctx context.Context, trusterID, trusteeID, category string) (*storage.TrustRelationship, error)
UpdateTrustRelationship(ctx context.Context, relationship *storage.TrustRelationship) error
DeleteTrustRelationship(ctx context.Context, trusterID, trusteeID, category string) error
GetTrustRelationships(ctx context.Context, trusterID string, limit int, cursor string) ([]*storage.TrustRelationship, string, error)
GetTrustedByRelationships(ctx context.Context, trusteeID string, limit int, cursor string) ([]*storage.TrustRelationship, string, error)
GetTrustScore(ctx context.Context, actorID, category string) (*storage.TrustScore, error)
UpdateTrustScore(ctx context.Context, score *storage.TrustScore) error
RecordTrustUpdate(ctx context.Context, update *storage.TrustUpdate) error
GetAllTrustRelationships(ctx context.Context, limit int) ([]*storage.TrustRelationship, error)
GetUserTrustScore(ctx context.Context, userID string) (float64, error)
}
TrustRepositoryInterface defines the interface for trust operations
type TrustScore ¶
type TrustScore = storage.TrustScore
TrustCategory and other type aliases to storage types - this breaks the import cycle
type TrustSummary ¶
type TrustSummary struct {
ActorID string `json:"actor_id"`
OverallScore float64 `json:"overall_score"`
CategoryScores map[TrustCategory]float64 `json:"category_scores"`
TrustedByCount int `json:"trusted_by_count"`
TrustsCount int `json:"trusts_count"`
LastActive time.Time `json:"last_active"`
ReputationLevel string `json:"reputation_level"` // high, medium, low, new
}
TrustSummary provides a summary view of an actor's trust status
type TrustUpdate ¶
type TrustUpdate = storage.TrustUpdate
TrustCategory and other type aliases to storage types - this breaks the import cycle