Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
69 lines
2.5 KiB
TypeScript
69 lines
2.5 KiB
TypeScript
import { calculateTotalPenalty, type AntiGamingAnomaly } from '../src/services/trendingScoring';
|
|
import type { AntiGamingConfig } from '../src/config/trending';
|
|
|
|
const antiGamingConfig: AntiGamingConfig = {
|
|
enabled: true,
|
|
velocityCaps: {
|
|
postLikes: { maxEventsPerWindow: 10, windowMinutes: 10, penaltyWeight: 0.4 },
|
|
postComments: { maxEventsPerWindow: 8, windowMinutes: 15, penaltyWeight: 0.3 },
|
|
repoFollows: { maxEventsPerWindow: 20, windowMinutes: 30, penaltyWeight: 0.5 },
|
|
userFollows: { maxEventsPerWindow: 15, windowMinutes: 20, penaltyWeight: 0.6 },
|
|
},
|
|
suspiciousPatterns: {
|
|
newAccountThreshold: 0.5,
|
|
newAccountAgeDays: 1,
|
|
lowActivityThreshold: 0.4,
|
|
minEngagementsForCheck: 5,
|
|
maxCommentsPerUserPerPost: 5,
|
|
ipClusterMinSharedUsers: 3,
|
|
newAccountPenaltyWeight: 0.5,
|
|
lowActivityPenaltyWeight: 0.3,
|
|
commentSpamPenaltyWeight: 0.2,
|
|
ipClusterPenaltyWeight: 0.4,
|
|
},
|
|
flaggedEntityDampening: {
|
|
dampeningMultiplier: 0.5,
|
|
anomalyCountThreshold: 2,
|
|
anomalyWindowHours: 48,
|
|
},
|
|
maxTotalPenalty: 0.95,
|
|
};
|
|
|
|
describe('trendingScoring.calculateTotalPenalty', () => {
|
|
it('uses postComments penalty weight for burst_comments anomalies', () => {
|
|
const anomalies: AntiGamingAnomaly[] = [
|
|
{ type: 'burst_comments', severity: 1, details: 'comment burst', actorIds: [] },
|
|
];
|
|
|
|
const penalty = calculateTotalPenalty(anomalies, antiGamingConfig);
|
|
|
|
expect(penalty).toBeCloseTo(0.3, 6);
|
|
});
|
|
|
|
it('applies different weights per anomaly type and sums penalties', () => {
|
|
const anomalies: AntiGamingAnomaly[] = [
|
|
{ type: 'burst_likes', severity: 0.5, details: 'like burst', actorIds: [] },
|
|
{ type: 'new_account_engagement', severity: 0.6, details: 'new accounts', actorIds: [] },
|
|
{ type: 'ip_cluster', severity: 0.5, details: 'shared ip', actorIds: [] },
|
|
];
|
|
|
|
const penalty = calculateTotalPenalty(anomalies, antiGamingConfig);
|
|
|
|
// 0.5*0.4 + 0.6*0.5 + 0.5*0.4 = 0.7
|
|
expect(penalty).toBeCloseTo(0.7, 6);
|
|
});
|
|
|
|
it('caps total penalty at maxTotalPenalty', () => {
|
|
const anomalies: AntiGamingAnomaly[] = [
|
|
{ type: 'new_account_engagement', severity: 1, details: 'a', actorIds: [] },
|
|
{ type: 'low_activity_engagers', severity: 1, details: 'b', actorIds: [] },
|
|
{ type: 'ip_cluster', severity: 1, details: 'c', actorIds: [] },
|
|
{ type: 'fake_followers', severity: 1, details: 'd', actorIds: [] },
|
|
];
|
|
|
|
const penalty = calculateTotalPenalty(anomalies, antiGamingConfig);
|
|
|
|
expect(penalty).toBe(antiGamingConfig.maxTotalPenalty);
|
|
});
|
|
});
|