A handle could name a stored original that no longer existed
Found by attacking the 0.8.9 code rather than testing it. Both of these break the one
promise this store exists to keep — a handle you were given reads back — and both only
appear once the store is full enough to evict, which a long session reaches on its own.
1. Eviction could delete the entry the same call had just written. Eviction sorts by
file mtime; files written inside the same clock tick tie, and a tie can sort the newest
entry first. So the eviction pass at the end of store_ex was able to remove the very
entry whose handle was about to be returned.
Reproduced with a 6,000-byte budget and a 5,911-byte payload: store_ex answered with a
handle and the store was left holding zero files.
The entry a call just wrote is now exempt from that call's eviction pass. The byte budget
still holds, because an entry is only ever written when it fits the budget alone — keeping
it while evicting everything else cannot leave the store over budget.
2. The budget was compared against the payload, not against the bytes written. The JSON
wrapper adds a couple of hundred bytes, so a result that "fit" was written and then
immediately evicted by its own cleanup pass, handing back a handle to nothing. The check
now uses the size of the entry that actually lands on disk.
A third, smaller fix rides along: after cleanup, store_ex re-checks that the entry is
there and reports write-failed if it somehow is not, instead of returning a handle.
The property is now a test, not a hope
tests/test_ccr_lossless.py gains four tests:
- every handle
store_exreturns reads back byte-identical — checked over twelve
payloads under a budget small enough to force eviction constantly - the kept entry survives even when it is deliberately backdated to be the oldest file in
the store, so nothing but the exemption can save it - the budget is judged on bytes written
- the store is within budget after a successful write
Why 0.8.9 and 0.8.10 both exist today
0.8.9 fixed three measured ways the compression could lose data (a payload over 1 MB
dropped with nowhere to go, a 300-second timer that unlinked originals on read, and
retrieve reporting four different failures as one). 0.8.10 is what the adversarial pass
over that work turned up. The honest summary: the first round found the holes reachable
from the outside, the second found one reachable only from the inside.
Housekeeping
- 1829 passed, 2 skipped · ruff clean · zero dependencies (43 files scanned)
- wheel 342,209 bytes = 334 KB · 24,883 lines of Python across 43 modules