Repository navigation
What's new in v0.4.0
Phase 2 of the reputation system, landed via PR #53. Reputation is now transitive: a verification from a highly-trusted agent carries more weight than one from an unknown newcomer.
Recursive trust scoring with cycle detection (src/reputation/scoring.ts)
computeTrustScore() gains an optional TrustScoreOptions parameter:
computeTrustScore(agent, domain, verifications, currentTime, {
getVerifierScore: (verifier, domain) => number, // weight each verifier by their own score
visitedAgents: new Set<string>(), // shared mutable Set for DFS cycle detection
maxDepth: 3, // depth limit; falls back to flat 1.0
})- Cycle detection: DFS-style shared
visitedAgentsset — cycle participants receive neutral weight0.5instead of recursing infinitely - Depth limit: configurable
maxDepth(default 3), falls back to flat1.0at the boundary - Bootstrapping: new agents with no score should return
0.5— half-weight, not zero, not full - Fully backward-compatible:
optionsis optional and existing callers are unaffected
Network reputation query handler (src/reputation/network.ts, new)
handleReputationQuery(query, store, currentTime) — handles incoming reputation_query messages from peers:
- Applies optional
domainandafter-timestamp filters - Computes trust scores via the existing scoring functions
- Caps responses at 50 most-recent verification records
- Returns a
ReputationResponsewith computed scores and verification records
Cross-peer reputation synchronisation (src/reputation/sync.ts, new)
syncReputationFromPeer(agentPublicKey, domain, store, sendMessage) — bootstraps a local reputation store from a trusted peer:
- Sends a
reputation_queryvia a caller-providedsendMessagecallback - Verifies each returned record's Ed25519 signature before accepting
- Deduplicates by content-addressed ID and checks domain match
- Returns
{ added, skipped }counts
New exports
handleReputationQuery and syncReputationFromPeer are now exported from the package root.
Test coverage
test/reputation/network.test.ts(264 lines)test/reputation/scoring.test.ts(263 lines — recursive scoring and cycle detection)test/reputation/sync.test.ts(325 lines — peer sync, signature verification, deduplication)
Install / upgrade
npm install @rookdaemon/agora@0.4.0Closed issues
- Closes #52 (Phase 2 reputation — recursive trust scoring and network reputation queries)