When using the MMAP v1 storage engine, query stages in a saved state receive invalidation notifications when documents get updated or deleted. Some stages flag documents that are deleted. The set of flagged documents is then read by the KEEP_MUTATIONS stage, which re-checks these documents against the query and returns them if they still match.
The invalidation mechanism described above is used only for MMAP v1; query plans running against storage engines such as WiredTiger never receive invalidations and never flag mutated documents for review by the KEEP_MUTATIONS stage. The planner's analysis phase should only add KEEP_MUTATIONS if the storage engine is MMAP v1.