Something I've wondered: is the lock the first machine to do a discrete, conditional action? That'd make it a kind of ancestor to digital computers, before various automata and then Jacquard and Babbage. Feedback control goes back to the first millennium BC, too, but that seems more like analog computing.
That might be the screw (hold if push, moved if twisted). Though I suppose a screw could be seen as a very basic kind of lock.
Interesting point of view -- I hadn't thought of it that way. It seems to be a more recent invention, though.