Yes, it seems that ruff isn't installed in any of the directories in the PATH variable.
Chris's first message referred to ruff being installed in "our instance of CodeRunner (we know it's installed)". That raised a doubt in my mind as to whether ruff was installed on the Moodle server (which wouldn't work) or the Jobe server (which is what's required).
If ruff is definitely installed on the Jobe server, then I would assume it's not in a directory on the PATH.
When I was testing ruff, I first installed it with the command given on the ruff web page: "curl -LsSf https://astral.sh/ruff/install.sh | sh". But that installs in a a directory <home>/.cargo/bin, which won't be searched by Jobe as it has cleaned the PATH variable for security. I instead installed it using pip (as root) with the --break-system-packages command line option. I'd be a bit hesitant to do on a production server, but it worked fine on my development server, putting ruff at /usr/local/bin/ruff. It was then usable from CodeRunner.
Perhaps the first thing to try is to change your script to try executing /root/.cargo/bin/ruff rather than just ruff. It that doesn't work, talk to whoever installed ruff on jobe to find out where it landed up! You may be able to execute it by giving its full path to the subprocess run command, or you could ask the sysadmin to link to it from one of the standard executable directories, like /usr/local/bin.