Skip to content

Feature/config driven reputation - #1228

Merged
Baskarayelu merged 3 commits into
CredenceOrg:mainfrom
charliechinedu19-netizen:feature/config-driven-reputation
Jul 30, 2026
Merged

Feature/config driven reputation#1228
Baskarayelu merged 3 commits into
CredenceOrg:mainfrom
charliechinedu19-netizen:feature/config-driven-reputation

Conversation

@charliechinedu19-netizen

Copy link
Copy Markdown
Contributor

Description

Externalizes reputation scoring weights (System B: src/services/reputation/) into versioned, environment-driven configuration, allowing operators to tune the scoring model via .env without code changes.

Closes #1005

Changes

New Environment Variables

Variable Default Description
REPUTATION_BOND_MULTIPLIER 0.01 Bond amount → score multiplier
REPUTATION_MAX_BOND_SCORE 1000 Bond score cap
REPUTATION_ATTESTATION_MULTIPLIER 0.1 Attestation weight → score multiplier
REPUTATION_MAX_ATTESTATION_WEIGHT 100 Attestation score cap
REPUTATION_MAX_DURATION_MS 31536000000 (1 year) Duration for full time weight
REPUTATION_TIME_DECAY_RATE 0.5 Exponential decay rate for time weight

Files Modified (12 files, +344/-49)

  • src/config/index.ts — Added Zod schema, Config interface fields, and mapper for 6 new vars
  • src/services/reputation/types.ts — Added ReputationModuleConfig interface
  • src/services/reputation/bondScore.ts — Parameterized; accepts optional ReputationModuleConfig, defaults to original constants
  • src/services/reputation/attestationScore.ts — Same pattern
  • src/services/reputation/timeWeight.ts — Same pattern; maxDuration param made optional (defaults from config)
  • src/services/reputation/score.ts — Threads config through calculateReputationScore, calculatePersistedReputationScore, recordScoreHistorySnapshot, and calculateReputationScoreWithCustomDuration
  • src/jobs/scoreSnapshot.ts — Defaults scoringModelVersion from loadConfig().reputation.scoringModelVersion instead of hardcoded '1.0.0'
  • src/services/reputation/README.md — Updated config docs, API signatures, and removed stale constants section
  • src/services/reputation/bondScore.test.ts, attestationScore.test.ts, timeWeight.test.ts, score.test.ts — Added config-driven test cases (+15 tests)

Backward Compatibility

All existing callers continue to work without changes. When no ReputationModuleConfig is passed, each scoring function falls back to module-level defaults that produce identical scores to the previous hardcoded constants. The SnapshotJobOptions.scoringModelVersion override still takes precedence over the config default.

Testing

  • All 123 tests pass (108 existing + 15 new)
  • Config validation test suite (`src/config/repu

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@charliechinedu19-netizen 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

@charliechinedu19-netizen

Copy link
Copy Markdown
Contributor Author

@Baskarayelu Please review and merge

@Baskarayelu
Baskarayelu merged commit 42f7a7e into CredenceOrg:main Jul 30, 2026
2 checks passed
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.

[Backend] Reputation engine: make scoring weights and thresholds config-driven, not hardcoded

2 participants