feat: muse#54 item 3 — muse reflog compact
Adds `muse reflog compact [--branch <name>] [--dry-run] [--json]`: scans a log in storage order (oldest-first, matching how entries are actually appended) and merges each maximal run of 2+ ADJACENT entries sharing an operation category (commit/reset/merge/..., via the categorize_operation() helper lifted from `muse reflog stat` into muse/core/reflog.py so both commands share one definition) into a single summary entry spanning the run — old_id from the run's first entry, new_id/timestamp from its last, author preserved when the whole run shares one author, else "various". The same spirit as `muse rebase --squash` at the commit level: entries outside a qualifying run, and malformed lines, are left untouched; the write is atomic (tmp file + os.replace), following the exact pattern already used by expire_reflog.
Design decision (documented inline in reflog-followup.md): compaction is explicit/on-demand, never automatic on every append_reflog call — reflog entries are the safety-net audit trail for undoing accidental ref movements, so silently collapsing history on write would undermine that guarantee for anyone who hasn't looked at an entry yet.
Covered by tests/test_reflog_compact.py (11 cases: categorize_operation unit tests, core compact_reflog run-merging, different-category non-merging, lone-entry non-compaction, mixed-author -> "various", --dry-run leaves the file untouched, two separate runs split by a differing category both compact independently, plus 3 CLI integration tests for --json/--dry-run/invalid-branch). Confirmed genuine RED by reverting both changed files and re-running (ImportError: compact_reflog doesn't exist), then GREEN with the fix restored plus the full reflog regression suite (138 passed, zero regressions). Live-verified via muse-dev against a disposable /tmp sandbox (dry-run leaves 3 entries intact, real run merges them into 1 "commit (compacted 3 entries)" line).
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Semantic Changes
53 symbols
Files Changed
+1
~3
1230 in snapshot
0 comments
muse hub commit comment sha256:88a9fd7a7eb0cb829b95c6ba769f831ff0e29fe8336036a93d00730e5e908aff --body "your comment"
No comments yet. Be the first to start the discussion.