Autodelegation based on more complex rules

Stephen Finucane stephen at
Thu Feb 25 02:39:37 AEDT 2021

On Mon, 2021-02-15 at 12:14 +0000, Ali Alnubani wrote:
> Hi all,
> There are currently 2 ways in Patchwork to autodelegate patches. Patchwork can
> either parse the hint header (X-Patchwork-Delegate), or it can lookup the
> fnmatch-formatted rules for the project.
> Projects using a MAINTAINERS file might want to use the same rules they
> already have there for delegation. These rules can be in the hundreds, and
> they can change very often. Managing these manually in django’s admin
> interface can be a bit hard (I have even seen that Django will render them
> extremely slowly, will cause very high CPU usage, and 5xx timeouts when
> loading a project’s admin page).
> Adding these rules can be automated using django’s management shell, however,
> there are cases where more complex rules might be needed to find the right
> delegate. An example is projects with a hierarchy of trees and maintainers,
> were patches changing files in more than a single sub-tree usually require
> delegating to the maintainer of a higher-level tree. Current rule priorities
> don’t support such a case, because we would need to consider all files changed
> at once, not separately.
> Can we implement a hook that would call an external and project-specific
> script in (specifically in find_delegate_by_filename()) to resolve
> the issues above? The script would be expected to take the filenames as an
> argument, and output a delegates email. This way, any complicated rules could
> be managed by that script.
> I realize there might be security implications to this though. Please let me
> know what you think.

As has been suggested elsewhere, I feel this is something that can and should
really be done outside of Patchwork now and the auto-delegation feature is
likely something we will eventually remove. You have the events API to spot new
patches arriving. You should be able to poll this and then use the patches API
to set the delegate based on a local rule engine. If you find features are
missing from the API, please let us know and we can try our best to add them.

Hopefully this helps,


> Thanks,
> Ali
> _______________________________________________
> Patchwork mailing list
> Patchwork at

More information about the Patchwork mailing list