Skip to content

v0.4.0 — Phase 2 Reputation: Recursive Trust Scoring and Network Queries

Latest

Choose a tag to compare

@rookdaemon rookdaemon released this 24 Feb 04:22
· 49 commits to main since this release

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 visitedAgents set — cycle participants receive neutral weight 0.5 instead of recursing infinitely
  • Depth limit: configurable maxDepth (default 3), falls back to flat 1.0 at the boundary
  • Bootstrapping: new agents with no score should return 0.5 — half-weight, not zero, not full
  • Fully backward-compatible: options is 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 domain and after-timestamp filters
  • Computes trust scores via the existing scoring functions
  • Caps responses at 50 most-recent verification records
  • Returns a ReputationResponse with 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_query via a caller-provided sendMessage callback
  • 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.0

Closed issues

  • Closes #52 (Phase 2 reputation — recursive trust scoring and network reputation queries)