WWDC 2019 Session 230 (Making Apps with Core Data) introduced a new Core Data feature, derived attributes. In a demo of the feature a postCount attribute was added to an entity, with the derived expression of "posts.@count". As far as I can tell the demo only worked because the context was "fresh". If you make any changes to a context, derived expressions yield stale results, even after the context is saved. Only a call to context.refreshAllObjects() (or context.reset()) refreshes them. To state that a bit differently, using the demo's example: tag.posts.count yields a correct value after context.save(), but tag.postCount does not. Until, that is, you call context.refreshAllObjects(). Or context.reset().
I filed a bug, together with a sample app.