I think they key line is this:
Note that messages must not be modified once they’ve been delivered. IMAP (and Dovecot) requires that messages are immutable. If you wish to modify them in any way, create a new message instead and expunge the old one.
And from what you wrote before, I think you're moving messages between folders, which breaks Dovecot's knowledge of where emails are.
The problem still happens if I replace mv a/cur/$EXAMPLE_ID* a/.Archive/cur with cp a/cur/$EXAMPLE_ID_1:2, a/.Archive/cur/$EXAMPLE_ID_2:2, rm a/cur/$EXAMPLE_ID_1:2, in my repro script (and define $EXAMPLE_ID_1 and $EXAMPLE_ID_2 to be different).
Anyway, I thought that prohibition was about changing the content of a message file, not moving messages.
But maybe I've been too optimistic about how far that support is intended to extend.
I think it's a terrible idea to try and mix regular MUA access to mail handled by dovecot, it just leads to problems.
Only this problem so far. But maybe you are right. One reason I started this thread was to understand whether Dovecot's developers intend for this to work or not. If they do, I am happy to try to help fix whatever is happening.
It might be worth noting: sometimes doveadm sync does the right thing. In particular, I haven't had any trouble when moving emails that have been around for a while. (I tried making sure I don't move directly from new, but that's not enough.)
-- James