Skip to content

[CT-13] Implement reputation score time-decay function #921

@mftee

Description

@mftee

Problem

A carrier who performed excellently two years ago but has been inactive retains their peak score indefinitely. Old ratings are weighted equally with recent ones, meaning the score does not reflect a carrier's current reliability — a key piece of information for shippers choosing between carriers.

Proposed Solution

Implement a time-decay weighting algorithm in a new reputation contract inside contracts/package/reputation-decay/ that reduces the influence of older ratings on the composite score.

Note: All work must be done inside the contracts/package/ directory. Do not modify any existing contract files outside this folder.

Acceptance Criteria

  • Ratings less than 365 days old contribute at 100% weight
  • Ratings between 365-730 days old contribute at 70% weight
  • Ratings older than 730 days contribute at 40% weight
  • get_decayed_score(user_id, current_ledger_time) applies decay weights and returns the adjusted composite score (0-1000)
  • Decay thresholds and weight factors are configurable at contract initialization (stored in persistent storage)
  • Unit tests verify decay math for ratings at exactly 0 days, 366 days, and 731 days old using fixed input values and expected outputs

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions