gabriel / muse public
Closed #52 Bug
filed by gabriel human · 24 days ago

fix(reflog): use long IDs in human text output

0 Anchors
Blast radius
Churn 30d
0 Proposals

muse reflog — use long IDs in human text output

Problem

_fmt_entry in muse/cli/commands/reflog.py renders commit IDs using short_id (12 hex chars) in the human text output:

def _fmt_entry(idx: int, entry: ReflogEntry, short: int = 12) -> str:
    new_short = sanitize_display(short_id(entry.new_id))
    old_short = (
        "initial"
        if entry.old_id == NULL_COMMIT_ID
        else sanitize_display(short_id(entry.old_id))
    )

This produces output like:

@{0} sha256:3f9a1c2d4e7b  (sha256:9b2e4a1f8c3d)  2026-06-28 14:22:11 UTC  claude-code  fix: off-by-one in total

Every other Muse command that surfaces a commit ID in human text uses long_id — the canonical sha256:<64-hex> form. The reflog is inconsistent and the IDs it displays cannot be passed directly to other commands without risk of prefix collision.

The docstring even contradicts itself: it claims short IDs are used "for consistency with all other Muse commands" when the opposite is true.

Additionally, the short: int = 12 parameter in _fmt_entry is declared but never referenced in the function body — dead parameter, should be removed.

The JSON output layer already uses long_id correctly via _ReflogEntryJson. Only the human text path needs fixing.

Fix

In muse/cli/commands/reflog.py:

  1. Replace both short_id(...) calls in _fmt_entry with long_id(...).
  2. Remove the unused short: int = 12 parameter.
  3. Update the docstring to reflect that full IDs are rendered.
  4. Update the format spec comment string at the top of run() docstring (<new_sha12><new_sha256>).

Correct output after the fix:

@{0} sha256:3f9a1c2d4e7b9c2a4f1d8e3b6c9f2d1a7e4b8c1f5a9d2e6b3c7f0a4d1e8b2c5f  (sha256:9b2e4a1f8c3d7b4e2c1a5f9d3e7b2c8f1a4e7b3c9f2a6d1e4b8c3f7a0d2e5b98)  2026-06-28 14:22:11 UTC  claude-code  fix: off-by-one in total

Deliverables

  • LI_01_fmt_entry uses long_id for new_id; output is sha256:<64-hex>
  • LI_02_fmt_entry uses long_id for old_id; "initial" sentinel unchanged
  • LI_03 — Unused short: int = 12 parameter removed from _fmt_entry signature
  • LI_04_fmt_entry docstring updated; no stale reference to short IDs or the false "consistency" claim
  • LI_05run() docstring format spec updated to reflect full IDs
  • LI_06 — Test: muse reflog human text output contains the full 64-hex commit ID of the most recent entry, not a 12-char prefix

Test file: tests/test_cmd_reflog_long_ids.py

Out of scope

  • JSON output — already correct (long_id used in _ReflogEntryJson).
  • Any other command's ID rendering.
Activity1
gabriel opened this issue 24 days ago
gabriel 15 days ago

Fixed on branch fix/reflog-long-ids, commit 97740e08.

All deliverables done:

  • LI_01/LI_02: _fmt_entry uses long_id for both new_id and old_id; the "initial" sentinel for a null old_id is unchanged.
  • LI_03: removed the unused short: int = 12 parameter (and the now-dead short_id import).
  • LI_04: docstring no longer claims short IDs are used "for consistency" — states the actual (now-correct) behavior.
  • LI_05: module-level format spec updated (<new_sha12><new_sha256>).
  • LI_06: new test file tests/test_cmd_reflog_long_ids.py, 7 tests, red-first, all green.

Also found and fixed a second occurrence of the bug: tests/test_reflog_supercharge.py had a whole test class (TestTextFormatShortId) explicitly asserting the buggy short-ID output as correct — renamed to TestTextFormatLongId and rewritten to assert the fixed behavior instead.

Full reflog regression sweep: 278 passed across 11 test files. Not yet merged to dev — bundling with a few other small tickets tonight.

closed this issue 15 days ago