I’ve also diagrammed sentences for fun. I’m now a language teacher.
In the sentence, ”X is eaten by the machine,” X is in the subjective (what most languages call nominative, making “who” correct) and the patient, but the machine is the agent.
In the sentence, ”the machine eats X,” X is in the objective (often compared to accusative, but everything that isn’t subjective or possessive is objective in English) and the machine is both subjective and the agent.