pub fn next_id(dir: &Path) -> u64
Returns the next available id (max+1), starting at 1. Reads output/open_loops.idx. If missing, returns 1.
output/open_loops.idx