1) Do nothing. IMAP client implementors are put on notice that servers
which unilaterally recycle keywords (including in a session) may happen
someday, and that client code which doesn't handle this is broken.
I vote this, with the restriction that permanent flags can't be dropped if any of them currently exist in mailbox. With that, I don't see how recycling could be much of a client problem. If you lose a permanentflag, just forget about it internally and possibly reuse that bit for some new flag. If you hadn't synced all flags in the session and were using cached flags, clear the flags as well.
Well .. there's one potential problem though:
(server supports 1 permanent keyword, there's no messages with flag1)
Client1: 1 fetch flags * 1 flags (\seen flag1) 1 OK
Client2: 2 store 1 flags (\seen flag2) * permanentflags (.. flag2) * 1 flags (\seen flag2) 2 OK
Client1: 3 noop * permanentflags (.. flag2) * 1 flags (\seen flag2) 3 OK
Now, the problem is that client1 still thinks that message 1 has flag1 when it sees it dropped from permanentflags.. So server should rather send:
* 1 flags (\seen) * permanentflags (.. flag2) * 1 flags (\seen flag2) 3 OK
Which may be more difficult to implement for servers..