Sorry, I know next to nothing about how iCloud works and even less about Cloudkit. I have on occasion offered “solutions” that appeared to work for me, at least once.
The article that @R2D2 posted in “ Best Option . . . “ is one of the most informative I have read. I had no idea that iCloud is a database.
It states, "iCloud is one of those features in macOS which works almost all the time for the great majority of users.” I agree, and that’s why I don’t depend on it.