Deliver messages to incoming message hook after their dependencies
The sync layer should keep track of each message's dependencies and deliver messages to the incoming message hook after their dependencies. If any dependency is invalid or in a different group, the message is invalid and should be deleted.
Messages that are waiting for dependencies should not be visible to clients.
Subtask of #122 (closed).