mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-28 04:02:18 +01:00
Stale-gate recovery read a gate file, proved its holder dead, then unlinked the gate by pathname. Another admission could replace the gate at that same path in the gap between the read and the unlink, so recovery could delete a live replacement gate instead of the dead one it inspected. Recovery now records the exact bytes of the gate it inspected and re-checks the path immediately before removing it, unlinking only when the bytes still match. A device-and-inode check cannot do this: this filesystem reuses a just-freed inode number for a file created right after at the same path, so a replacement gate can carry the same identity as the one it replaced. The gate's own content gets a random per-acquisition token for this purpose. Co-authored-by: Paperclip <noreply@paperclip.ing>