Description
The reputation engine hardcodes scoring constants — BOND_SCORE_MAX = 50, DURATION_SCORE_MAX = 20, ATTESTATION_SCORE_MAX = 30, ONE_ETH_WEI, the 365-day cap, and the 5-attestation cap — directly in src/services/reputationService.ts and src/services/reputation/. Tuning the trust model requires a code change and redeploy, and there is no audit trail of weight changes. We should externalize these into versioned configuration so the model can be tuned and snapshotted.
Requirements and context
- Move weights/caps into
src/config/index.ts (validated with Zod) with sane defaults preserving current behavior.
- Include a
scoringModelVersion so src/jobs/scoreSnapshot.ts can record which model produced a score.
- Keep
computeBondScore/computeDurationScore/computeAttestationScore pure but parameterized.
- Document the model in
src/services/reputation/README.md.
Suggested execution
Create branch feature/config-driven-reputation.
- Refactor
src/services/reputationService.ts and src/services/reputation/score.ts.
- Add config schema + validation in
src/config/.
- Update
src/services/reputation/score.test.ts and add config tests.
- Update
docs/ reputation/model docs.
Test and commit
Run npm run test. Edge cases: default config == current scores (regression), invalid config rejected at boot, total capped at 100. Security: config from env validated, no eval.
Example commit message
feat: externalize reputation scoring weights into versioned config
Guidelines
- Minimum 95% test coverage
- Clear documentation in
src/services/reputation/README.md
- Timeframe: 96 hours
Description
The reputation engine hardcodes scoring constants —
BOND_SCORE_MAX = 50,DURATION_SCORE_MAX = 20,ATTESTATION_SCORE_MAX = 30,ONE_ETH_WEI, the 365-day cap, and the 5-attestation cap — directly insrc/services/reputationService.tsandsrc/services/reputation/. Tuning the trust model requires a code change and redeploy, and there is no audit trail of weight changes. We should externalize these into versioned configuration so the model can be tuned and snapshotted.Requirements and context
src/config/index.ts(validated with Zod) with sane defaults preserving current behavior.scoringModelVersionsosrc/jobs/scoreSnapshot.tscan record which model produced a score.computeBondScore/computeDurationScore/computeAttestationScorepure but parameterized.src/services/reputation/README.md.Suggested execution
Create branch
feature/config-driven-reputation.src/services/reputationService.tsandsrc/services/reputation/score.ts.src/config/.src/services/reputation/score.test.tsand add config tests.docs/reputation/model docs.Test and commit
Run
npm run test. Edge cases: default config == current scores (regression), invalid config rejected at boot, total capped at 100. Security: config from env validated, no eval.Example commit message
feat: externalize reputation scoring weights into versioned configGuidelines
src/services/reputation/README.md