git-refs: compact the push queue on Drain

main

Commit

Soph2mo ago

Enqueue only appends, so a long-lived session that re-enqueues the same checkpoint ref across many writes without pushing would grow the queue file unboundedly — Remove was the only point that rewrote it. Drain already de-duplicates in memory; now it also rewrites the file to that de-duplicated set when the on-disk queue held redundant lines (duplicate refs or malformed/blank records), bounding the file to one line per distinct queued ref.

readLocked reports the raw non-empty line count so Drain compacts only when rawLines > len(refs) (i.e. there was actually something redundant). The rewrite is factored into rewriteLocked, shared with Remove, and stays atomic (temp + rename). Drain still returns the refs and does not clear them — they survive until a confirmed Remove.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com Entire-Checkpoint: 5608d53754d2

Checkpoints

Build Checkpoints Store Based on Design

Claude CodeOpus 4.8
View session
Checkpoint 1