From ad1ef996ac9f7e5eb9e530075f5de013bf35b073 Mon Sep 17 00:00:00 2001 From: oratis Date: Sun, 9 Aug 2026 23:14:27 +0800 Subject: [PATCH] fix(analytics): escape the NUL separator so usage-ledger stops being binary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The compound cache key in summarize() used a raw 0x00 byte written directly into the source — a literal control character, not the escape sequence. Git classifies a file with a NUL in its first 8000 bytes as binary, so `git diff` reported "Bin 9679 -> 10779 bytes" instead of the change, `git blame` stopped working, and `file` reported `data` rather than UTF-8 text. Worth noting how it got in: I merged it in #17, and the reason nobody caught it is the bug itself — the file was undiffable, so review had nothing to look at. The separator choice is fine: NUL cannot collide with a YYYY-MM month or any agent_id. Only the encoding was wrong. Both occurrences are now the escape sequence, which evaluates to the same U+0000 character, so getWorkspaceUsage / getPlatformUsage group byte-identically. Verified: 0 NUL bytes remain, `file` reports UTF-8 text, the template still evaluates to a string containing U+0000, and an end-to-end aggregation still separates same-month agents correctly. npm test 678/678. Found by the background session on PR #27, which was branched before #23 and would have reverted that PR's documentation on this file; applied directly to main instead. Co-Authored-By: Claude Fable 5 --- server/usage-ledger.js | Bin 10779 -> 10789 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/server/usage-ledger.js b/server/usage-ledger.js index abb86002cf96f9b2a86cc701fefcf367325051b3..7d10d4c8e0b0174c55e058220dcd947468fb495b 100644 GIT binary patch delta 31 fcmbOovNU8vnj~9HsR0mdPM36Ngt6C4