altimate-code icon indicating copy to clipboard operation
altimate-code copied to clipboard

Identifier 48-bit timestamp wrap (2026-08-14) makes truncation cleanup delete fresh files — CI red + data loss

Open anandgupta42 opened this issue 3 months ago • 0 comments

Identifier.create packs timestamp * 4096 + counter into 6 bytes. That wraps every 2^36 ms (~795.4 days); the 26th wrap since epoch landed 2026-08-14T11:19:55Z. Post-wrap IDs decode to tiny timestamps, so both truncation cleanups (src/tool/truncate.ts and src/tool/truncation.ts) compute a pre-wrap cutoff that is astronomically larger than every new file's decoded timestamp — every truncated tool output written after Aug 14 is deleted on the next cleanup, and the Truncate > cleanup test fails on every CI run (first failure 2026-08-17, on unchanged code).

Fix: age files by mtime (no wrap) in both cleanups; stat failures keep the file (deletion fails safe). The ID encoding itself is upstream OpenCode code — sort-order across a wrap boundary is also briefly wrong, but nothing else in this repo compares decoded ID timestamps across windows.

anandgupta42 avatar Aug 17 '26 19:08 anandgupta42