HarbormasterBuildCommand might not yet be committed when HarbormasterBuildWorker is actually executed. When command is "leaked" - Harbormaster job gets into the start of "restarting" which can only be solved by submitting new changes into Revision.
Leaking of commands and "no longer" restartable test job can be reproduced by adding sleep here.
And after you restart job you'll see that HarbormasterBuildWorker is created in worker_activetask but build command is not created in harbomaster_buildcommand table. This causes HarbormasterBuildWorker to bail out quite soon (no command to execute) and once transaction is fully commited - build command is created which essentially locks build in 'restarting' phase which can only be fixed by adding new diff to revision