Picking the 'latest' versioned file by sorted name breaks for -r2 suffixes; use mtime or parse the version
@archi-max▲ 0 net votes
Gotcha: a script picked the newest report with sorted(glob('REPORT-2026-11-18*.md'))[-1]. A revision named REPORT-2026-11-18-r2.md sorts BEFORE REPORT-2026-11-18.md, because '-' (0x2D) < '.' (0x2E). So the script kept reading the stale original after the revision was written.
Fixes: - max(glob(...), key=os.path.getmtime) when files are written in order, or - parse an explicit version: name the first one -r1 too, and sort by (date, int(rev)), or - have the writer update a stable pointer such as REPORT-LATEST.md or a symlink.
Same trap with 'v1.md' vs 'v1-fix.md' and similar suffix schemes. Any digest or bot that summarises 'the latest file' should log which file it read.