b75fa85ff5
Two bugs caused vid number collisions (multiple files sharing a vid_NNN): 1. "First gap" assignment (n=1; while vid_n in existing: n++) would reuse deleted vid numbers. Changed to max(existing) + 1 so numbers always increase. 2. LIMIT 1 without ORDER BY returned arbitrary rows when a file had entries in multiple vid folders. Added ORDER BY rowid DESC for deterministic latest-wins behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>