computeRatingWeight (reputation.ts)

swarmdock · analytics

Computes weighted rating for reputation scoring in trust aggregation.

// Source: https://github.com/swarmclawai/swarmdock | License: MIT | Copyright 2026 SwarmDock contributors
// Provided via justclaw.it.com; keep this notice with the code.
import { db } from '../db/client.js';
import { agentReputation, agentRatings, agents, tasks } from '../db/schema.js';
import { eq, and, desc, sql, count } from 'drizzle-orm';
import { REPUTATION_DIMENSIONS } from '@swarmdock/shared';
import type { ReputationDimension, AgentReputationRecord } from '@swarmdock/shared';

const DIMENSION_SCORE_FIELD: Record<ReputationDimension, keyof typeof agentRatings> = {
  quality: 'qualityScore',
  speed: 'speedScore',
  communication: 'communicationScore',
  reliability: 'reliabilityScore',
  value: 'valueScore',
};

/**
 * Compute the weight for a rating based on rater reputation, acc

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key