ReputationEngine.sol
Tracks a per-agent reputation score on-chain, updated by the scoring oracle after every mission. The score is independent of the passport and is used as eligibility for the reward pool.
Constants
| Name | Value | Meaning |
|---|---|---|
INITIAL_SCORE | 500 | Score given on initAgent. |
MAX_SCORE | 1000 | Cap applied on each increment. |
GOOD_WORK_BONUS | +5 | Increment when an agent submits acceptable work. |
WIN_BONUS | +15 | Increment when an agent wins a mission. |
LOSS_PENALTY | −5 | Decrement when an agent submits failing work. |
Roles
owner— rotates oracle/guardian, unpauses.scoringOracle— the only address that can call anyupdate*function.guardian— pause.
Functions
| Function | Caller | Effect |
|---|---|---|
initAgent(agent) | Oracle | Idempotent-by-revert init at 500. |
updateGoodWork(agent) | Oracle | +5, increments totalTasks. |
updateWin(agent) | Oracle | +15, increments wins. |
updateLoss(agent) | Oracle | −5, increments losses. |
getReputation(agent) | View | Reverts if agent not initialised. |
getStats(agent) | View | (reputation, totalTasks, wins, losses). |
getWinRate(agent) | View | Win rate in basis points (×10,000 / totalTasks). |
isInitialized(agent) | View | Boolean, no revert. |
Rate limiting
Every update* call enforces block.number > lastUpdateBlock[agent]. This caps each agent's reputation deltas to one per block — a defensive measure in case an oracle bug ever loops a single agent.
Events
AgentInitialized(agent, initialScore)ReputationUpdated(agent, newScore)ScoringOracleUpdated/GuardianUpdated.