A clever 'append-only audit log' recently uncovered two significant accounting errors in splitrail, a popular usage tracker for command-line tools. This discovery highlights how crucial robust logging is for accurate data.
Ever wondered if your usage trackers are telling you the whole story? Well, a recent discovery shows why a smart approach to data logging is super important. It turns out that a simple 'append-only audit log' has just helped uncover two sneaky accounting bugs in splitrail, a widely used Rust-based tracker for command-line interface tools. What exactly happened? The main problem came from how some tools, like Claude Code, handle their session files. When you pick up a conversation again or clean it up, these tools can actually rewrite their data files in place. This means that records of your past usage, which you've already incurred, could just vanish from the files that trackers usually read. Imagine paying for something, and then the record of that usage simply disappears! Any usage tracker that just re-reads these 'live' files will miss these deleted entries, leading to incorrect totals. Your numbers from yesterday could change overnight without you knowing. This is exactly what happened to one user who noticed five of their assistant messages from Claude Code had disappeared between scans of the same file. The usage was there, then it was gone from the records. Thanks to the append-only log, which keeps every message ID and never lets history be rewritten, this discrepancy was caught. The good news is that both bugs were fixed quickly, within twelve days of being reported. One fix even came from the user who reported it, and the other from the maintainer based on the analysis provided. The main solution involved adding a local database (SQLite) to splitrail. This new feature stores usage data permanently and merges it with current session information, making sure no usage disappears if the original files are altered. What does this mean for you? It's a clear reminder that systems relying on constantly changing data can easily hide inaccuracies. For developers, it underlines the value of implementing robust, immutable logging — a simple log that only adds new data, never changes old data, can save a lot of headaches and ensure data integrity. For users, it means more reliable usage tracking, giving you a truer picture of your resource consumption without hidden surprises.