Page MenuHomePhabricator

PendingChangesBot: Add revertrisk model check to auto-approval logic
Open, Needs TriagePublic

Description

Add a check using the Wikimedia revertrisk model (Multilingual revert risk) to determine if an edit has a high probability of being reverted. Since low risk alone does not indicate an edit should be automatically approved, this check identifies edits that should not be approved.

  • Query the revertrisk API to get the revert risk score for an edit. If the score exceeds a configurable threshold, the edit should not be automatically approved.
  • Add a configuration parameter to set the threshold value for the revertrisk score (e.g., 0.7, 0.8, etc.).

Include tests for:

  • API integration with the revertrisk model
  • Threshold comparison logic
  • Auto-approval blocking when threshold is exceeded
  • Configuration parameter handling

API Reference:

Code example

import json
from pywikibot.comms import http

url = 'https://api.wikimedia.org/service/lw/inference/v1/models/revertrisk-multilingual:predict'
headers = {
    'Content-Type': 'application/json',
    'User-Agent': 'PendingChangesBot/1.0 (https://fi.wikipedia.org/wiki/User:SeulojaBot)'
}
payload = json.dumps({'rev_id': 23599483, 'lang':'fi'})  # your rev ID

resp = http.fetch(url, method='POST', headers=headers, data=payload)
print(resp.text)

Other edit tests are located in autoreview.py.