Page MenuHomePhabricator

Integrate Community Configuration into AutoModerator
Closed, ResolvedPublic

Description

We have a number of configuration options for AutoModerator which can currently be customised only by editing MediaWiki:AutoModeratorConfig.json locally. We would like to integrate Community Configuration to make the process of configuration AutoModerator more seamless and user friendly.

Designs/copy

Initial explorations in the Figma files linked in T349238. Note that we're moving message strings such as edit summary out of config.

Community Config Technical Details

Note: Null data types are not supported in CC 2.0. For now, we should just use empty strings in our schema in places where we would otherwise use null and update code accordingly.

Step 1:
Download the extension and enable it per documentation here.

Step 2:
Update AutoModerator's extension.json to include the community configuration provider.

	"attributes": {
		"CommunityConfiguration": {
			"Providers": {
				"MyProvider": {
					"store": {
						"type": "wikipage",
						"args": [
							"MediaWiki:AutoModeratorConfig.json"
						]
					},
					"validator": {
						"type": "jsonschema",
						"args": [
							"AutoModerator\\Config\\Validation\\AutoModeratorConfigSchema"
						]
					},
					"type": "mw-config"
				}
			}
		}
	},

Step 3: Create an AutoModeratorConfigSchema class in the AutoModerator extension that will be referenced in your provider config from step 1:

class AutoModeratorConfigSchema extends JsonSchema
{
	public const AutoModeratorEnableRevisionCheck = [
		self::TYPE => self::TYPE_BOOLEAN
	];

         public const AutoModeratorFalsePositivePageTitle = [
	        self::REF => [ 'class' => MediaWikiDefinitions::class, 'field' => 'PageTitle' ],
         ];

	public const AutoModeratorSkipUserGroups = [
		self::TYPE => self::TYPE_ARRAY,
                self::ITEMS => [
			self::TYPE => self::TYPE_STRING,
		],
	];

	public const AutoModeratorUseEditFlagMinor = [
		self::TYPE => self::TYPE_BOOLEAN
	];

	public const AutoModeratorRevertTalkPageMessageEnabled = [
		self::TYPE => self::TYPE_BOOLEAN
	];

	public const AutoModeratorCautionLevel = [
		self::TYPE => self::TYPE_STRING,
		self::ENUM => ['Very cautious', 'Cautious', 'Somewhat cautious', 'Less cautious']
	];
}

You can then validate the configuration on wiki and ensure the types are being validated correctly.

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Kgraessle changed the task status from Stalled to Open.Jul 16 2024, 5:18 PM
Kgraessle changed the task status from Open to Stalled.Jul 16 2024, 7:28 PM
Kgraessle changed the task status from Stalled to Open.Jul 26 2024, 1:55 PM
Kgraessle changed the task status from Open to Stalled.Jul 26 2024, 3:05 PM
Kgraessle changed the task status from Stalled to Open.Jul 30 2024, 2:01 PM
Kgraessle changed the task status from Open to Stalled.Jul 31 2024, 2:11 PM
Kgraessle changed the task status from Stalled to Open.Aug 7 2024, 1:42 PM

These should be both merged. They are only waiting on our end on QA, but can already be used.

Note that this is an upstream bug. We look into it when we find the time, but the bug is not in our main code-bases, but in mediawiki core. The current workaround is to replace [foo] with \[foo\] in the message in the en.json file.

These should be both merged. They are only waiting on our end on QA, but can already be used.

Note that this is an upstream bug. We look into it when we find the time, but the bug is not in our main code-bases, but in mediawiki core. The current workaround is to replace [foo] with \[foo\] in the message in the en.json file.

@Michael
Great! thank you for the update. I'm still seeing the <br> tags not parsing correctly on help text and descriptions. My patch is here if you want to take a look.

Kgraessle changed the task status from Open to Stalled.Aug 8 2024, 4:19 PM

Note that this is an upstream bug. We look into it when we find the time, but the bug is not in our main code-bases, but in mediawiki core. The current workaround is to replace [foo] with \[foo\] in the message in the en.json file.

@Michael
Great! thank you for the update. I'm still seeing the <br> tags not parsing correctly on help text and descriptions. My patch is here if you want to take a look.

Mh, after trying it out, it seems <br> tags are not supported in any js-based interface message. The documentation seems to suggest to use <p> instead. I left two suggestions at the change. Hope that helps 🙂

Kgraessle changed the task status from Stalled to Open.Aug 19 2024, 4:56 PM

Moving this to engineering review- but keeping it as a WIP until after MW-1.43-notes (1.43.0-wmf.19; 2024-08-20) rolls out completely due to a dependency on CC configuration work.

I refactored to keep our validation and config hooks in place alongside the community configuration form.
I did this because of feedback from RTL and also when I was testing the user rights configuration, it was updating but causing some strange behavior (queueing the job before the precheck) and wasn't toggling between the values.

Scardenasmolinar changed the task status from Open to In Progress.Sep 4 2024, 6:24 PM
Scardenasmolinar changed the status of subtask T366016: Design UX copy for AutoModerator Community Configuration from Stalled to In Progress.
Scardenasmolinar moved this task from Eng review to QA on the Moderator-Tools-Team (Kanban) board.

Change #1051822 merged by jenkins-bot:

[mediawiki/extensions/AutoModerator@master] Integrate Community Configuration into AutoModerator

https://gerrit.wikimedia.org/r/1051822

Hello! Thanks for the work on the CC integration. Unfortunately, there appears to be a minor issue that skimmed through code review. Filled as T374084: AutoModerator re-declares communityconfiguration-editor-form-submit-button-text i18n message, which is owned by CommunityConfiguration. If there is anything unclear about the issue or the proposed fix, happy to answer them (preferably, on the other task).

One issue that was pointed out to us - the links for Help:Minor edit and Manual:Bots should point to MediaWiki, at the following two links, instead of at the local wiki:

Any idea why the label for the skipped-user-groups field isn't displaying?

Screenshot 2024-09-10 at 13.59.37.png (578×1 px, 105 KB)

This should ideally be pulling options from the list of possible user rights, but I can only select from bot and autopatrol.

Screenshot 2024-09-10 at 15.46.48.png (260×1 px, 22 KB)

If I try to add another group I get an undefined error:

Screenshot 2024-09-10 at 15.47.45.png (632×1 px, 68 KB)

Change #1071939 had a related patch set uploaded (by Kgraessle; author: Kgraessle):

[mediawiki/extensions/AutoModerator@master] Integrate Community Configuration into AutoModerator - Fix message strings for user rights to skip and add all possible options

https://gerrit.wikimedia.org/r/1071939

Any idea why the label for the skipped-user-groups field isn't displaying?

Screenshot 2024-09-10 at 13.59.37.png (578×1 px, 105 KB)

This is due to the field changing its name from AutoModeratorSkipUserGroups to AutoModeratorSkipUserRights so the form label i18n messages needed to be updated.
I have a follow up patch out that fixes this, the Help:Minor edit and Manual:Bots links, and populating the user rights dynamically.

This should ideally be pulling options from the list of possible user rights, but I can only select from bot and autopatrol.

Screenshot 2024-09-10 at 15.46.48.png (260×1 px, 22 KB)

If I try to add another group I get an undefined error:

Screenshot 2024-09-10 at 15.47.45.png (632×1 px, 68 KB)

This requires a change to Community Configuration to work as we designed it - T374609: Support enums with dynamically generated options in Community Configuration.

In the meantime is there a stopgap version of this feature that we could implement? Something with no validation or options to select from, perhaps?

This should ideally be pulling options from the list of possible user rights, but I can only select from bot and autopatrol.

Screenshot 2024-09-10 at 15.46.48.png (260×1 px, 22 KB)

If I try to add another group I get an undefined error:

Screenshot 2024-09-10 at 15.47.45.png (632×1 px, 68 KB)

This requires a change to Community Configuration to work as we designed it - T374609: Support enums with dynamically generated options in Community Configuration.

In the meantime is there a stopgap version of this feature that we could implement? Something with no validation or options to select from, perhaps?

@Samwalton9-WMF we discussed this yesterday in engineering weekly and found a workaround which I have pushed to this patch.

Change #1071939 merged by jenkins-bot:

[mediawiki/extensions/AutoModerator@master] Integrate Community Configuration into AutoModerator - Fix message strings for user rights to skip and add all possible options

https://gerrit.wikimedia.org/r/1071939

Change #1072649 had a related patch set uploaded (by Scardenasmolinar; author: Scardenasmolinar):

[mediawiki/extensions/AutoModerator@master] Use wikiConfig instead of config when gtting threshold

https://gerrit.wikimedia.org/r/1072649

I've spotted a small bug in how we get the threshold in Util::getRevertThreshold. I have created a patch for review!

Merged the patch!

Thanks! Checking it out on Beta.

It looks like we don't have any dropdown of possible options, is that intentional? (I think it's OK, just clarifying)

I added some nonsense user rights and it looks like we're missing the automoderator-config-validator-userrights-not-allowed system message in the error:

Screenshot 2024-09-13 at 09.30.59.png (730×1 px, 126 KB)

Merged the patch!

Thanks! Checking it out on Beta.

It looks like we don't have any dropdown of possible options, is that intentional? (I think it's OK, just clarifying)

Yep! We removed the drop down options due to the message strings not populating.

I added some nonsense user rights and it looks like we're missing the automoderator-config-validator-userrights-not-allowed system message in the error:

Screenshot 2024-09-13 at 09.30.59.png (730×1 px, 126 KB)

So what's interesting is that message is actually set to

User right $1 does not exist please try another.

So I'm not sure why it's displaying the message key above it- can you add the query parameter

?uselang=qqx

to the end of the URL when that message appears and let me know what the message key is? I'm not an admin on beta so I cannot click save.

Change #1072805 had a related patch set uploaded (by Kgraessle; author: Kgraessle):

[mediawiki/extensions/AutoModerator@master] Update copy on caution level description.

https://gerrit.wikimedia.org/r/1072805

Change #1072649 merged by jenkins-bot:

[mediawiki/extensions/AutoModerator@master] Use wikiConfig instead of config when gtting threshold

https://gerrit.wikimedia.org/r/1072649

Change #1072805 had a related patch set uploaded (by Kgraessle; author: Kgraessle):

[mediawiki/extensions/AutoModerator@master] Update copy on caution level description.

https://gerrit.wikimedia.org/r/1072805

Can I suggest a small change to add to this patch too, just to clarify the first sentence. I also don't think the second sentence serves a purpose because this should be documented elsewhere, and isn't necessary information when setting the threshold in my opinion.

From

This extension leverages the new revert risk models that can calculate a score for every revision denoting the likelihood that the edit should be reverted. The models support only Wikipedia projects and trained on the main (article) namespace.

to

Automoderator uses machine learning models which calculate a score for every revision, denoting the likelihood that the edit should be revered.

I added some nonsense user rights and it looks like we're missing the automoderator-config-validator-userrights-not-allowed system message in the error:

Screenshot 2024-09-13 at 09.30.59.png (730×1 px, 126 KB)

So what's interesting is that message is actually set to

User right $1 does not exist please try another.

So I'm not sure why it's displaying the message key above it- can you add the query parameter

?uselang=qqx

to the end of the URL when that message appears and let me know what the message key is? I'm not an admin on beta so I cannot click save.

Unfortunately it seems like the page doesn't want to load when the language is set to qqx.

Screenshot 2024-09-16 at 10.08.52.png (674×1 px, 132 KB)

fwiw, the page loads for me

Screenshot 2024-09-16 at 17.28.45.png (1×2 px, 331 KB)

The reason why that text key is shown in the message is because AutoModerator's custom validator yields this as an error code in https://gerrit.wikimedia.org/g/mediawiki/extensions/AutoModerator/+/f2fadadfb57be5cc276ea86e701a9395de49e8fc/src/Config/Validation/AutoModeratorConfigValidation.php#82. The markup is:

<p>{{ errorCode }}</p>
		<ul
			v-if="errorResponse.errors"
		>
			<li
				v-for="( error, index ) in errorResponse.errors"
				:key="index"
				v-html="error.html"
			></li>
		</ul>
...

Change #1073821 had a related patch set uploaded (by Kgraessle; author: Kgraessle):

[mediawiki/extensions/AutoModerator@master] Fix default caution level

https://gerrit.wikimedia.org/r/1073821

Change #1073821 merged by jenkins-bot:

[mediawiki/extensions/AutoModerator@master] Fix default caution level

https://gerrit.wikimedia.org/r/1073821

fwiw, the page loads for me

Screenshot 2024-09-16 at 17.28.45.png (1×2 px, 331 KB)

The reason why that text key is shown in the message is because AutoModerator's custom validator yields this as an error code in https://gerrit.wikimedia.org/g/mediawiki/extensions/AutoModerator/+/f2fadadfb57be5cc276ea86e701a9395de49e8fc/src/Config/Validation/AutoModeratorConfigValidation.php#82. The markup is:

<p>{{ errorCode }}</p>
		<ul
			v-if="errorResponse.errors"
		>
			<li
				v-for="( error, index ) in errorResponse.errors"
				:key="index"
				v-html="error.html"
			></li>
		</ul>
...

It looks like this is the only remaining work to do here and then we can announce Community Configuration for Automoderator is ready for use!

@Samwalton9-WMF it seems this is the intended behavior if I'm understanding @Sgs correctly.

The errorCode is being displayed above the error message which in our case is the message key.
Do we want the error code to be something other than the message key?

@Samwalton9-WMF it seems this is the intended behavior if I'm understanding @Sgs correctly.

The errorCode is being displayed above the error message which in our case is the message key.
Do we want the error code to be something other than the message key?

Ah, I understand, thanks! I found this confusing because I thought a message wasn't being displayed correctly. I think users only need the bullet point ("User right x does not exist. Please try another.") rather than the error code too, if that's possible?

Samwalton9-WMF added subscribers: BAPerdana-WMF, Dogu, Renvoy.

We talked about this a little more and decided it's not a big deal.

@Dogu @Renvoy @BAPerdana-WMF You can now feel free to use [[Special:CommunityConfiguration/AutoModerator]] on your wiki to configure Automoderator, instead of using MediaWiki:AutoModeratorConfig.json. That MediaWiki page will still contain the json configuration, and will be updated by the Special page, so you can continue to look at its page history, watchlist it, etc. The strings for that Special page are translatable in TranslateWiki if you haven't already.

You may wish to update the 'Configure Automoderator' link on Automoderator's user page to point to this Special page instead of the .json page.