Repository navigation
v2.7.4 — the badge counts what the gate actually compressed
A correctness fix for the number the badge shows you. v2.7.3's badge could report the opposite of what happened.
The gate's own compressions were scored as misses
The PreToolUse gate rewrites a raw cat <big file> into an hcat run. Claude Code executes the rewritten command — the compression really happens, a real receipt lands — but it records the original cat … in the session transcript.
The badge and the session ledger attribute receipts by reading that recorded command, so every auto-rewritten compression banked zero savings and, being a large output, was then counted as a missed opportunity. The plugin's headline v2.7 feature compressed your file and got blamed for not compressing it.
Caught on a clean v2.7.3 install, on a 98 KB JSON the gate compressed 47.4% (~35409 → ~18627 tok):
before: ○ headroom idle · 36 big blobs uncompressed
after: ○ headroom idle · ~16.8k tok · $0.17 · 1× · 36 missed
If your badge has been sitting at "N big blobs uncompressed" while hcat receipts were clearly landing, this was why. Update and the numbers correct themselves — nothing to re-run.
The rewrite turns out to be recoverable from the transcript: Claude Code logs a hook_success attachment keyed by toolUseID carrying the gate's own stdout. Attribution now reads the command the gate announced and applies the same structural test to it — so a hook that merely mentions hcat in prose still counts as nothing, and output that quotes a receipt still can't inflate your savings.
dangi-hook needed no change: it reads its PostToolUse payload, which carries the post-rewrite command, so it had been getting these right all along.
A large passthrough is a miss, not a free pass
A receipt proves an hcat run, not a compression. When content is incompressible hcat emits a "passthrough" receipt with no ~B tok → ~A tok arrow — and those raw bytes really did enter the context window. Savings accounting already required the arrow, but the missed-opportunity counter exempted any receipt, so a large passthrough scored as neither a save nor a miss and the nudge went quiet on output that genuinely flooded the window.
The miss counter now requires an actual compression. This was never specific to gate rewrites, so it is fixed for model-invoked hcat too.
Hardening from the review of the fix
- A crash. jq's
test()throws on non-strings and an uncaught throw aborts the whole program — blank badge, dropped ledger, for the rest of the session. The new path reads a command out of any PreToolUse hook's stdout, so a third-party hook emitting{"command": 42}was one step from disabling attribution. Hardened at the predicate, covering the pre-existing call site too. - Scope. The attachment path had dropped the Bash-only invariant the command path holds implicitly; restored, plus a 64 KB bound on the JSON parse that runs each render.
- Tests that could not fail. Mutation testing showed the structural filters were entirely unpinned, and each negative was a bare absence-check on a poison-only transcript — passing vacuously whenever the pass aborted, which is exactly the crash above. Every negative now pairs its poison with a genuine compression and asserts the genuine numbers still render.
All five regressions are mutation-verified, each caught by exactly the test written for it.
Tests: 519 → 556 pass / 0 fail, shellcheck clean.
Full diff: v2.7.3...v2.7.4