Read every _id in the stat's range and return the largest gen_id + 1 (or 0 if none).
- Bounded clustered range scan over the same range the read path uses, projecting _id only:
db.system.stats.samples.find({_id: {$gte: "<coll_UUID>_<spec>_v1", $lt: "<coll_UUID>_<spec>_v2"}}, {_id: 1}) - gen_ids are not padded, so parse each one as a number; do not compare them as strings.
- No consistency requirements: a concurrent writer claiming the same gen_id is detected when page 0 is inserted.
See WRITING-11150, ANNEX II.