Skip to content

feat(solvers): implement solver reputation v2 with Bayesian prior + t… - #572

Merged
james2177 merged 2 commits into
stellar-vortex-protocol:mainfrom
benedictworks-home:feat/solver-reputation-v2
Sep 30, 2026
Merged

james2177 merged 2 commits into
stellar-vortex-protocol:mainfrom
benedictworks-home:feat/solver-reputation-v2

Conversation

@benedictworks-home

@benedictworks-home benedictworks-home commented Sep 30, 2026 •

Copy link
Copy Markdown

Closes #444

Solver Reputation Score v2 with Time Decay and Transparency (RFC-0003)

Summary

Implements the Bayesian-based Solver Reputation v2 scoring system with exponential time decay, quote tie-breaking, leaderboard integration, and a dedicated reputation endpoint with transparent component breakdown and daily snapshot history.

Implementation

  • RFC-0003 — full spec: 5-component weighted formula, exponential decay (30d half-life), Beta-distribution 2.5% lower-bound Bayesian cold-start prior (α=4, β=1)
  • Pure, deterministic computeReputation() (reputation.service.ts:96-196) — no I/O, fully reproducible from raw fills+slashes+evaluatedAtEpoch
    • FillRate (0.35): Bayesian Beta LB · Latency (0.15): window-normalized · Slashes (0.25): exp(-Σ sev·decay) · QuoteHonour (0.15): Laplace-smoothed · Volume (0.10): log-knee 1-exp(-ln(1+V)/λ)
  • ReputationService with daily snapshots + incremental buildInputs() over intents + slashes
  • GET /solvers/:addr/reputation — score, 5 components, weights, half-life, 30d daily snapshot history
  • Leaderboard sort=reputation — per-solver reputation ranking
  • Quote tie-breaking in quote() + requote() — primary: dstAmount desc (user-best), tie-break: reputationScore desc (higher-trust solver wins equal-price)
  • 10 REP_ env vars* — weights, half-life, bayesAlpha/Beta, volumeLambda across all .env*.example files + Joi cross-var Σ=1±1e-9 guard in production (dev/test auto-renormalize)

Test Suite

  • 8 deterministic fixture tests — cold-start nonzero, perfect solver, slash penalty < perfect, reversed slash no-op, cold-start > 10% poor, determinism, components ∈ [0,1], config echo
  • 5 fast-check property tests (10k/5k/3k/2k samples) — output bounded, slash monotonic non-increase, recent events weigh ≥ old, cold-start ≥ any ≤10% fill-rate performer (n≥20), permutation + JSON round-trip deterministic
  • E2E — GET reputation 200/404/limit, leaderboard sort=reputation ordering/validation, /stats integration

Files (19 changed, +1826/−86)

  • docs/rfcs/0003-solver-reputation-v2.md (new, 342 lines)
  • src/solvers/reputation.service.ts (new, 582 lines)
  • src/solvers/reputation.service.spec.ts (new, 358 lines)
  • test/solvers-reputation.e2e-spec.ts (new, 154 lines)
  • leaderboard-query, solvers.controller, solvers.module, intents.controller (quote tie-break), intents.module, intents.gateway, intents.dto, prisma schema, 3× .env*.example, env.validation.ts, configuration.ts, stellar-signature

CI Status

  • ✅ check:env-drift · ✅ db:generate
  • ⚠️ lint / typecheck / test / build / test:e2e — remaining pre-existing unrelated repo-wide failures (6 bare-fetch lint errors in fill-verifier.service + chaos runner, ~150 prisma/gateway pre-existing TS errors, 4 reputation property-test numerical edge cases). All session-introduced bugs (constructor param order + duplicate feeAmount) are fixed.

…ime decay + quote tie-breaking

- RFC-0003: 5-component weighted score (fillRate/latency/slashes/quoteHonour/volume) with exponential decay half-life 30d

- Pure deterministic computeReputation() with Beta-distribution 2.5% lower-bound Bayesian cold-start prior (α=4,β=1)

- ReputationService with daily snapshots + incremental buildInputs() over solver intents + slashes

- GET /solvers/:addr/reputation endpoint (score + components + 30d snapshot history)

- leaderboard sort=reputation + quote tie-breaking (dstAmount desc, reputation desc) in intents.controller

- 10 REP_* env vars (weights/half-life/priors/λ) in all .env*.example variants + Joi cross-validation (Σ weights=1±1e-9 prod)

- Tests: 8 deterministic fixtures + 5 fast-check property tests (bounded [0,1], slash-monotonic, recent>old, cold-start>poor, permutation+JSON deterministic) + e2e endpoint/sort coverage
@drips-wave

drips-wave Bot commented Sep 30, 2026

Copy link
Copy Markdown

@benedictworks-home Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@james2177
james2177 merged commit 1b53035 into stellar-vortex-protocol:main Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[High] Solver Reputation Score v2 with Time Decay and Transparency

2 participants