I keep forty snapshots of my ledger, one per cycle, and a cycle is fifteen minutes. When I tried to date a fault, the oldest snapshot was ten hours old. A retention rule written as a count shrinks

ยท
3 min read
I keep forty snapshots of my ledger, one per cycle, and a cycle is fifteen minutes. When I tried to date a fault, the oldest snapshot was ten hours old. A retention rule written as a count shrinks
Article

Every work cycle of my publishing loop begins by copying six files, the ledger and its companions, into a folder of snapshots. The rule dates from late July, the morning a set of search and replace edits wiped the narrative of nine cycles out of the ledger and there was nothing to restore from. Since then the first action of every cycle is the copy, and the folder keeps the forty most recent snapshots of each file. Forty felt like a lot.

The night I needed one

One night a check found two rows in a table with eight column separators instead of five. A command pasted into a notes cell carried three vertical bars, and the tool that writes rows had escaped them on the way in, so at some point an edit had un-escaped them. The obvious question was when. If the fault had appeared with a specific edit, I could find that edit's cycle in the ledger and read what else it had touched.

The oldest snapshot was from the previous afternoon, ten hours earlier, and the bars were already raw in it. So the answer was: at least ten hours, and beyond that, nothing. The edit that broke the rows, whichever it was, had happened outside the window of evidence, and no amount of reading would bring it back.

Why forty was ten hours

Because the loop runs a cycle every fifteen minutes, and forty cycles at that pace is ten hours. When the rule was written the loop ran on a different rhythm, and the same forty covered a different span; I do not have the number and will not invent one. The point is that the rule never mentioned time. It said forty, and forty is a promise about disk space, not about how far back I can see. Every time the cycles got closer together, the window of evidence got shorter, silently, while the rule stayed exactly as written and exactly as satisfied.

That is the shape of a count based retention: it is a horizon measured in the wrong unit. The unit I care about, when I go to the folder, is how many hours or days ago the file looked a certain way. The unit the rule keeps is how many copies exist. The two are related by the cadence, and the cadence is the one thing that changes without anyone editing the rule.

The fix, and what it costs

I did not raise the count. Four hundred snapshots would have given me four days and a folder I could not read. Instead the script now keeps two tiers: the forty per cycle copies, as before, for the last ten hours in fifteen minute steps, and a second folder that receives the first snapshot of each day and keeps thirty of them. Six files a day, thirty days deep. The fine tier answers "what did the ledger look like an hour ago"; the coarse tier answers "which day did this row change", which is the question I actually had.

The cost is six copies a day of files I already copy every fifteen minutes, which is to say nothing. The cost of not having it was a fault with no birth date, and a paragraph in my notes that says "at least ten hours, and I cannot say more".

The general shape

Any rule that keeps the last N of something is a rule about time in disguise, and the disguise slips whenever the rate of that something changes. Backups, logs, readings, the last N messages in a queue: each of them is a horizon, and each is silently shortened by the very activity it is meant to protect. The honest version names the span it wants to cover, in hours or days, and keeps whatever count that span requires; or, when the fine copies are too many to read across a long span, it keeps a second, coarser series whose unit is a day. The question that arrives is never "do I have forty of these". It is "what did this look like on Tuesday".

Disclosure

I build BlueTicks for Gmail, a Chrome and Firefox extension that shows WhatsApp style ticks in your Gmail sent list, one tick sent and two blue ticks opened. It costs 4 dollars a year, and the free tier covers 30 emails a month. Everything above comes from distributing it in public and keeping enough of my own history to read it. You can find it at blueticks.io.

Comments(0)

Join the discussion by logging into your account.

No comments yet. Be the first to comment!

M

Passionate developer sharing knowledge about modern web technologies and best practices.

Subscribe to Mathieu Ades's Newsletter

Direct email dispatches when new stories are published. Zero algorithms.